001
014
015 package com.liferay.portlet.asset.service.persistence;
016
017 import com.liferay.portal.NoSuchModelException;
018 import com.liferay.portal.kernel.annotation.BeanReference;
019 import com.liferay.portal.kernel.cache.CacheRegistryUtil;
020 import com.liferay.portal.kernel.dao.jdbc.MappingSqlQuery;
021 import com.liferay.portal.kernel.dao.jdbc.MappingSqlQueryFactoryUtil;
022 import com.liferay.portal.kernel.dao.jdbc.RowMapper;
023 import com.liferay.portal.kernel.dao.jdbc.SqlUpdate;
024 import com.liferay.portal.kernel.dao.jdbc.SqlUpdateFactoryUtil;
025 import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
026 import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
027 import com.liferay.portal.kernel.dao.orm.FinderPath;
028 import com.liferay.portal.kernel.dao.orm.Query;
029 import com.liferay.portal.kernel.dao.orm.QueryPos;
030 import com.liferay.portal.kernel.dao.orm.QueryUtil;
031 import com.liferay.portal.kernel.dao.orm.SQLQuery;
032 import com.liferay.portal.kernel.dao.orm.Session;
033 import com.liferay.portal.kernel.exception.SystemException;
034 import com.liferay.portal.kernel.log.Log;
035 import com.liferay.portal.kernel.log.LogFactoryUtil;
036 import com.liferay.portal.kernel.util.GetterUtil;
037 import com.liferay.portal.kernel.util.InstanceFactory;
038 import com.liferay.portal.kernel.util.OrderByComparator;
039 import com.liferay.portal.kernel.util.SetUtil;
040 import com.liferay.portal.kernel.util.StringBundler;
041 import com.liferay.portal.kernel.util.StringPool;
042 import com.liferay.portal.kernel.util.StringUtil;
043 import com.liferay.portal.kernel.util.Validator;
044 import com.liferay.portal.model.ModelListener;
045 import com.liferay.portal.service.persistence.BatchSessionUtil;
046 import com.liferay.portal.service.persistence.CompanyPersistence;
047 import com.liferay.portal.service.persistence.GroupPersistence;
048 import com.liferay.portal.service.persistence.ResourcePersistence;
049 import com.liferay.portal.service.persistence.UserPersistence;
050 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
051
052 import com.liferay.portlet.asset.NoSuchEntryException;
053 import com.liferay.portlet.asset.model.AssetEntry;
054 import com.liferay.portlet.asset.model.impl.AssetEntryImpl;
055 import com.liferay.portlet.asset.model.impl.AssetEntryModelImpl;
056 import com.liferay.portlet.blogs.service.persistence.BlogsEntryPersistence;
057 import com.liferay.portlet.bookmarks.service.persistence.BookmarksEntryPersistence;
058 import com.liferay.portlet.documentlibrary.service.persistence.DLFileEntryPersistence;
059 import com.liferay.portlet.documentlibrary.service.persistence.DLFolderPersistence;
060 import com.liferay.portlet.journal.service.persistence.JournalArticlePersistence;
061 import com.liferay.portlet.journal.service.persistence.JournalArticleResourcePersistence;
062 import com.liferay.portlet.messageboards.service.persistence.MBMessagePersistence;
063 import com.liferay.portlet.social.service.persistence.SocialEquityLogPersistence;
064 import com.liferay.portlet.wiki.service.persistence.WikiPagePersistence;
065 import com.liferay.portlet.wiki.service.persistence.WikiPageResourcePersistence;
066
067 import java.io.Serializable;
068
069 import java.util.ArrayList;
070 import java.util.Collections;
071 import java.util.List;
072 import java.util.Set;
073
074
080 public class AssetEntryPersistenceImpl extends BasePersistenceImpl<AssetEntry>
081 implements AssetEntryPersistence {
082 public static final String FINDER_CLASS_NAME_ENTITY = AssetEntryImpl.class.getName();
083 public static final String FINDER_CLASS_NAME_LIST = FINDER_CLASS_NAME_ENTITY +
084 ".List";
085 public static final FinderPath FINDER_PATH_FIND_BY_COMPANYID = new FinderPath(AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
086 AssetEntryModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
087 "findByCompanyId",
088 new String[] {
089 Long.class.getName(),
090
091 "java.lang.Integer", "java.lang.Integer",
092 "com.liferay.portal.kernel.util.OrderByComparator"
093 });
094 public static final FinderPath FINDER_PATH_COUNT_BY_COMPANYID = new FinderPath(AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
095 AssetEntryModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
096 "countByCompanyId", new String[] { Long.class.getName() });
097 public static final FinderPath FINDER_PATH_FETCH_BY_G_CU = new FinderPath(AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
098 AssetEntryModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_ENTITY,
099 "fetchByG_CU",
100 new String[] { Long.class.getName(), String.class.getName() });
101 public static final FinderPath FINDER_PATH_COUNT_BY_G_CU = new FinderPath(AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
102 AssetEntryModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
103 "countByG_CU",
104 new String[] { Long.class.getName(), String.class.getName() });
105 public static final FinderPath FINDER_PATH_FETCH_BY_C_C = new FinderPath(AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
106 AssetEntryModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_ENTITY,
107 "fetchByC_C",
108 new String[] { Long.class.getName(), Long.class.getName() });
109 public static final FinderPath FINDER_PATH_COUNT_BY_C_C = new FinderPath(AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
110 AssetEntryModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
111 "countByC_C",
112 new String[] { Long.class.getName(), Long.class.getName() });
113 public static final FinderPath FINDER_PATH_FIND_ALL = new FinderPath(AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
114 AssetEntryModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
115 "findAll", new String[0]);
116 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
117 AssetEntryModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
118 "countAll", new String[0]);
119
120 public void cacheResult(AssetEntry assetEntry) {
121 EntityCacheUtil.putResult(AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
122 AssetEntryImpl.class, assetEntry.getPrimaryKey(), assetEntry);
123
124 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_CU,
125 new Object[] {
126 new Long(assetEntry.getGroupId()),
127
128 assetEntry.getClassUuid()
129 }, assetEntry);
130
131 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C,
132 new Object[] {
133 new Long(assetEntry.getClassNameId()),
134 new Long(assetEntry.getClassPK())
135 }, assetEntry);
136 }
137
138 public void cacheResult(List<AssetEntry> assetEntries) {
139 for (AssetEntry assetEntry : assetEntries) {
140 if (EntityCacheUtil.getResult(
141 AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
142 AssetEntryImpl.class, assetEntry.getPrimaryKey(), this) == null) {
143 cacheResult(assetEntry);
144 }
145 }
146 }
147
148 public void clearCache() {
149 CacheRegistryUtil.clear(AssetEntryImpl.class.getName());
150 EntityCacheUtil.clearCache(AssetEntryImpl.class.getName());
151 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
152 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
153 }
154
155 public void clearCache(AssetEntry assetEntry) {
156 EntityCacheUtil.removeResult(AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
157 AssetEntryImpl.class, assetEntry.getPrimaryKey());
158
159 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_CU,
160 new Object[] {
161 new Long(assetEntry.getGroupId()),
162
163 assetEntry.getClassUuid()
164 });
165
166 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_C,
167 new Object[] {
168 new Long(assetEntry.getClassNameId()),
169 new Long(assetEntry.getClassPK())
170 });
171 }
172
173 public AssetEntry create(long entryId) {
174 AssetEntry assetEntry = new AssetEntryImpl();
175
176 assetEntry.setNew(true);
177 assetEntry.setPrimaryKey(entryId);
178
179 return assetEntry;
180 }
181
182 public AssetEntry remove(Serializable primaryKey)
183 throws NoSuchModelException, SystemException {
184 return remove(((Long)primaryKey).longValue());
185 }
186
187 public AssetEntry remove(long entryId)
188 throws NoSuchEntryException, SystemException {
189 Session session = null;
190
191 try {
192 session = openSession();
193
194 AssetEntry assetEntry = (AssetEntry)session.get(AssetEntryImpl.class,
195 new Long(entryId));
196
197 if (assetEntry == null) {
198 if (_log.isWarnEnabled()) {
199 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + entryId);
200 }
201
202 throw new NoSuchEntryException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
203 entryId);
204 }
205
206 return remove(assetEntry);
207 }
208 catch (NoSuchEntryException nsee) {
209 throw nsee;
210 }
211 catch (Exception e) {
212 throw processException(e);
213 }
214 finally {
215 closeSession(session);
216 }
217 }
218
219 protected AssetEntry removeImpl(AssetEntry assetEntry)
220 throws SystemException {
221 assetEntry = toUnwrappedModel(assetEntry);
222
223 try {
224 clearAssetCategories.clear(assetEntry.getPrimaryKey());
225 }
226 catch (Exception e) {
227 throw processException(e);
228 }
229 finally {
230 FinderCacheUtil.clearCache(AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
231 }
232
233 try {
234 clearAssetTags.clear(assetEntry.getPrimaryKey());
235 }
236 catch (Exception e) {
237 throw processException(e);
238 }
239 finally {
240 FinderCacheUtil.clearCache(AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETTAGS_NAME);
241 }
242
243 Session session = null;
244
245 try {
246 session = openSession();
247
248 if (assetEntry.isCachedModel() || BatchSessionUtil.isEnabled()) {
249 Object staleObject = session.get(AssetEntryImpl.class,
250 assetEntry.getPrimaryKeyObj());
251
252 if (staleObject != null) {
253 session.evict(staleObject);
254 }
255 }
256
257 session.delete(assetEntry);
258
259 session.flush();
260 }
261 catch (Exception e) {
262 throw processException(e);
263 }
264 finally {
265 closeSession(session);
266 }
267
268 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
269
270 AssetEntryModelImpl assetEntryModelImpl = (AssetEntryModelImpl)assetEntry;
271
272 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_CU,
273 new Object[] {
274 new Long(assetEntryModelImpl.getOriginalGroupId()),
275
276 assetEntryModelImpl.getOriginalClassUuid()
277 });
278
279 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_C,
280 new Object[] {
281 new Long(assetEntryModelImpl.getOriginalClassNameId()),
282 new Long(assetEntryModelImpl.getOriginalClassPK())
283 });
284
285 EntityCacheUtil.removeResult(AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
286 AssetEntryImpl.class, assetEntry.getPrimaryKey());
287
288 return assetEntry;
289 }
290
291 public AssetEntry updateImpl(
292 com.liferay.portlet.asset.model.AssetEntry assetEntry, boolean merge)
293 throws SystemException {
294 assetEntry = toUnwrappedModel(assetEntry);
295
296 boolean isNew = assetEntry.isNew();
297
298 AssetEntryModelImpl assetEntryModelImpl = (AssetEntryModelImpl)assetEntry;
299
300 Session session = null;
301
302 try {
303 session = openSession();
304
305 BatchSessionUtil.update(session, assetEntry, merge);
306
307 assetEntry.setNew(false);
308 }
309 catch (Exception e) {
310 throw processException(e);
311 }
312 finally {
313 closeSession(session);
314 }
315
316 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
317
318 EntityCacheUtil.putResult(AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
319 AssetEntryImpl.class, assetEntry.getPrimaryKey(), assetEntry);
320
321 if (!isNew &&
322 ((assetEntry.getGroupId() != assetEntryModelImpl.getOriginalGroupId()) ||
323 !Validator.equals(assetEntry.getClassUuid(),
324 assetEntryModelImpl.getOriginalClassUuid()))) {
325 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_CU,
326 new Object[] {
327 new Long(assetEntryModelImpl.getOriginalGroupId()),
328
329 assetEntryModelImpl.getOriginalClassUuid()
330 });
331 }
332
333 if (isNew ||
334 ((assetEntry.getGroupId() != assetEntryModelImpl.getOriginalGroupId()) ||
335 !Validator.equals(assetEntry.getClassUuid(),
336 assetEntryModelImpl.getOriginalClassUuid()))) {
337 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_CU,
338 new Object[] {
339 new Long(assetEntry.getGroupId()),
340
341 assetEntry.getClassUuid()
342 }, assetEntry);
343 }
344
345 if (!isNew &&
346 ((assetEntry.getClassNameId() != assetEntryModelImpl.getOriginalClassNameId()) ||
347 (assetEntry.getClassPK() != assetEntryModelImpl.getOriginalClassPK()))) {
348 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_C,
349 new Object[] {
350 new Long(assetEntryModelImpl.getOriginalClassNameId()),
351 new Long(assetEntryModelImpl.getOriginalClassPK())
352 });
353 }
354
355 if (isNew ||
356 ((assetEntry.getClassNameId() != assetEntryModelImpl.getOriginalClassNameId()) ||
357 (assetEntry.getClassPK() != assetEntryModelImpl.getOriginalClassPK()))) {
358 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C,
359 new Object[] {
360 new Long(assetEntry.getClassNameId()),
361 new Long(assetEntry.getClassPK())
362 }, assetEntry);
363 }
364
365 return assetEntry;
366 }
367
368 protected AssetEntry toUnwrappedModel(AssetEntry assetEntry) {
369 if (assetEntry instanceof AssetEntryImpl) {
370 return assetEntry;
371 }
372
373 AssetEntryImpl assetEntryImpl = new AssetEntryImpl();
374
375 assetEntryImpl.setNew(assetEntry.isNew());
376 assetEntryImpl.setPrimaryKey(assetEntry.getPrimaryKey());
377
378 assetEntryImpl.setEntryId(assetEntry.getEntryId());
379 assetEntryImpl.setGroupId(assetEntry.getGroupId());
380 assetEntryImpl.setCompanyId(assetEntry.getCompanyId());
381 assetEntryImpl.setUserId(assetEntry.getUserId());
382 assetEntryImpl.setUserName(assetEntry.getUserName());
383 assetEntryImpl.setCreateDate(assetEntry.getCreateDate());
384 assetEntryImpl.setModifiedDate(assetEntry.getModifiedDate());
385 assetEntryImpl.setClassNameId(assetEntry.getClassNameId());
386 assetEntryImpl.setClassPK(assetEntry.getClassPK());
387 assetEntryImpl.setClassUuid(assetEntry.getClassUuid());
388 assetEntryImpl.setVisible(assetEntry.isVisible());
389 assetEntryImpl.setStartDate(assetEntry.getStartDate());
390 assetEntryImpl.setEndDate(assetEntry.getEndDate());
391 assetEntryImpl.setPublishDate(assetEntry.getPublishDate());
392 assetEntryImpl.setExpirationDate(assetEntry.getExpirationDate());
393 assetEntryImpl.setMimeType(assetEntry.getMimeType());
394 assetEntryImpl.setTitle(assetEntry.getTitle());
395 assetEntryImpl.setDescription(assetEntry.getDescription());
396 assetEntryImpl.setSummary(assetEntry.getSummary());
397 assetEntryImpl.setUrl(assetEntry.getUrl());
398 assetEntryImpl.setHeight(assetEntry.getHeight());
399 assetEntryImpl.setWidth(assetEntry.getWidth());
400 assetEntryImpl.setPriority(assetEntry.getPriority());
401 assetEntryImpl.setViewCount(assetEntry.getViewCount());
402
403 return assetEntryImpl;
404 }
405
406 public AssetEntry findByPrimaryKey(Serializable primaryKey)
407 throws NoSuchModelException, SystemException {
408 return findByPrimaryKey(((Long)primaryKey).longValue());
409 }
410
411 public AssetEntry findByPrimaryKey(long entryId)
412 throws NoSuchEntryException, SystemException {
413 AssetEntry assetEntry = fetchByPrimaryKey(entryId);
414
415 if (assetEntry == null) {
416 if (_log.isWarnEnabled()) {
417 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + entryId);
418 }
419
420 throw new NoSuchEntryException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
421 entryId);
422 }
423
424 return assetEntry;
425 }
426
427 public AssetEntry fetchByPrimaryKey(Serializable primaryKey)
428 throws SystemException {
429 return fetchByPrimaryKey(((Long)primaryKey).longValue());
430 }
431
432 public AssetEntry fetchByPrimaryKey(long entryId) throws SystemException {
433 AssetEntry assetEntry = (AssetEntry)EntityCacheUtil.getResult(AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
434 AssetEntryImpl.class, entryId, this);
435
436 if (assetEntry == null) {
437 Session session = null;
438
439 try {
440 session = openSession();
441
442 assetEntry = (AssetEntry)session.get(AssetEntryImpl.class,
443 new Long(entryId));
444 }
445 catch (Exception e) {
446 throw processException(e);
447 }
448 finally {
449 if (assetEntry != null) {
450 cacheResult(assetEntry);
451 }
452
453 closeSession(session);
454 }
455 }
456
457 return assetEntry;
458 }
459
460 public List<AssetEntry> findByCompanyId(long companyId)
461 throws SystemException {
462 return findByCompanyId(companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
463 null);
464 }
465
466 public List<AssetEntry> findByCompanyId(long companyId, int start, int end)
467 throws SystemException {
468 return findByCompanyId(companyId, start, end, null);
469 }
470
471 public List<AssetEntry> findByCompanyId(long companyId, int start, int end,
472 OrderByComparator orderByComparator) throws SystemException {
473 Object[] finderArgs = new Object[] {
474 companyId,
475
476 String.valueOf(start), String.valueOf(end),
477 String.valueOf(orderByComparator)
478 };
479
480 List<AssetEntry> list = (List<AssetEntry>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_COMPANYID,
481 finderArgs, this);
482
483 if (list == null) {
484 Session session = null;
485
486 try {
487 session = openSession();
488
489 StringBundler query = null;
490
491 if (orderByComparator != null) {
492 query = new StringBundler(3 +
493 (orderByComparator.getOrderByFields().length * 3));
494 }
495 else {
496 query = new StringBundler(2);
497 }
498
499 query.append(_SQL_SELECT_ASSETENTRY_WHERE);
500
501 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
502
503 if (orderByComparator != null) {
504 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
505 orderByComparator);
506 }
507
508 String sql = query.toString();
509
510 Query q = session.createQuery(sql);
511
512 QueryPos qPos = QueryPos.getInstance(q);
513
514 qPos.add(companyId);
515
516 list = (List<AssetEntry>)QueryUtil.list(q, getDialect(), start,
517 end);
518 }
519 catch (Exception e) {
520 throw processException(e);
521 }
522 finally {
523 if (list == null) {
524 list = new ArrayList<AssetEntry>();
525 }
526
527 cacheResult(list);
528
529 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_COMPANYID,
530 finderArgs, list);
531
532 closeSession(session);
533 }
534 }
535
536 return list;
537 }
538
539 public AssetEntry findByCompanyId_First(long companyId,
540 OrderByComparator orderByComparator)
541 throws NoSuchEntryException, SystemException {
542 List<AssetEntry> list = findByCompanyId(companyId, 0, 1,
543 orderByComparator);
544
545 if (list.isEmpty()) {
546 StringBundler msg = new StringBundler(4);
547
548 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
549
550 msg.append("companyId=");
551 msg.append(companyId);
552
553 msg.append(StringPool.CLOSE_CURLY_BRACE);
554
555 throw new NoSuchEntryException(msg.toString());
556 }
557 else {
558 return list.get(0);
559 }
560 }
561
562 public AssetEntry findByCompanyId_Last(long companyId,
563 OrderByComparator orderByComparator)
564 throws NoSuchEntryException, SystemException {
565 int count = countByCompanyId(companyId);
566
567 List<AssetEntry> list = findByCompanyId(companyId, count - 1, count,
568 orderByComparator);
569
570 if (list.isEmpty()) {
571 StringBundler msg = new StringBundler(4);
572
573 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
574
575 msg.append("companyId=");
576 msg.append(companyId);
577
578 msg.append(StringPool.CLOSE_CURLY_BRACE);
579
580 throw new NoSuchEntryException(msg.toString());
581 }
582 else {
583 return list.get(0);
584 }
585 }
586
587 public AssetEntry[] findByCompanyId_PrevAndNext(long entryId,
588 long companyId, OrderByComparator orderByComparator)
589 throws NoSuchEntryException, SystemException {
590 AssetEntry assetEntry = findByPrimaryKey(entryId);
591
592 Session session = null;
593
594 try {
595 session = openSession();
596
597 AssetEntry[] array = new AssetEntryImpl[3];
598
599 array[0] = getByCompanyId_PrevAndNext(session, assetEntry,
600 companyId, orderByComparator, true);
601
602 array[1] = assetEntry;
603
604 array[2] = getByCompanyId_PrevAndNext(session, assetEntry,
605 companyId, orderByComparator, false);
606
607 return array;
608 }
609 catch (Exception e) {
610 throw processException(e);
611 }
612 finally {
613 closeSession(session);
614 }
615 }
616
617 protected AssetEntry getByCompanyId_PrevAndNext(Session session,
618 AssetEntry assetEntry, long companyId,
619 OrderByComparator orderByComparator, boolean previous) {
620 StringBundler query = null;
621
622 if (orderByComparator != null) {
623 query = new StringBundler(6 +
624 (orderByComparator.getOrderByFields().length * 6));
625 }
626 else {
627 query = new StringBundler(3);
628 }
629
630 query.append(_SQL_SELECT_ASSETENTRY_WHERE);
631
632 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
633
634 if (orderByComparator != null) {
635 String[] orderByFields = orderByComparator.getOrderByFields();
636
637 if (orderByFields.length > 0) {
638 query.append(WHERE_AND);
639 }
640
641 for (int i = 0; i < orderByFields.length; i++) {
642 query.append(_ORDER_BY_ENTITY_ALIAS);
643 query.append(orderByFields[i]);
644
645 if ((i + 1) < orderByFields.length) {
646 if (orderByComparator.isAscending() ^ previous) {
647 query.append(WHERE_GREATER_THAN_HAS_NEXT);
648 }
649 else {
650 query.append(WHERE_LESSER_THAN_HAS_NEXT);
651 }
652 }
653 else {
654 if (orderByComparator.isAscending() ^ previous) {
655 query.append(WHERE_GREATER_THAN);
656 }
657 else {
658 query.append(WHERE_LESSER_THAN);
659 }
660 }
661 }
662
663 query.append(ORDER_BY_CLAUSE);
664
665 for (int i = 0; i < orderByFields.length; i++) {
666 query.append(_ORDER_BY_ENTITY_ALIAS);
667 query.append(orderByFields[i]);
668
669 if ((i + 1) < orderByFields.length) {
670 if (orderByComparator.isAscending() ^ previous) {
671 query.append(ORDER_BY_ASC_HAS_NEXT);
672 }
673 else {
674 query.append(ORDER_BY_DESC_HAS_NEXT);
675 }
676 }
677 else {
678 if (orderByComparator.isAscending() ^ previous) {
679 query.append(ORDER_BY_ASC);
680 }
681 else {
682 query.append(ORDER_BY_DESC);
683 }
684 }
685 }
686 }
687
688 String sql = query.toString();
689
690 Query q = session.createQuery(sql);
691
692 q.setFirstResult(0);
693 q.setMaxResults(2);
694
695 QueryPos qPos = QueryPos.getInstance(q);
696
697 qPos.add(companyId);
698
699 if (orderByComparator != null) {
700 Object[] values = orderByComparator.getOrderByValues(assetEntry);
701
702 for (Object value : values) {
703 qPos.add(value);
704 }
705 }
706
707 List<AssetEntry> list = q.list();
708
709 if (list.size() == 2) {
710 return list.get(1);
711 }
712 else {
713 return null;
714 }
715 }
716
717 public AssetEntry findByG_CU(long groupId, String classUuid)
718 throws NoSuchEntryException, SystemException {
719 AssetEntry assetEntry = fetchByG_CU(groupId, classUuid);
720
721 if (assetEntry == null) {
722 StringBundler msg = new StringBundler(6);
723
724 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
725
726 msg.append("groupId=");
727 msg.append(groupId);
728
729 msg.append(", classUuid=");
730 msg.append(classUuid);
731
732 msg.append(StringPool.CLOSE_CURLY_BRACE);
733
734 if (_log.isWarnEnabled()) {
735 _log.warn(msg.toString());
736 }
737
738 throw new NoSuchEntryException(msg.toString());
739 }
740
741 return assetEntry;
742 }
743
744 public AssetEntry fetchByG_CU(long groupId, String classUuid)
745 throws SystemException {
746 return fetchByG_CU(groupId, classUuid, true);
747 }
748
749 public AssetEntry fetchByG_CU(long groupId, String classUuid,
750 boolean retrieveFromCache) throws SystemException {
751 Object[] finderArgs = new Object[] { groupId, classUuid };
752
753 Object result = null;
754
755 if (retrieveFromCache) {
756 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_G_CU,
757 finderArgs, this);
758 }
759
760 if (result == null) {
761 Session session = null;
762
763 try {
764 session = openSession();
765
766 StringBundler query = new StringBundler(3);
767
768 query.append(_SQL_SELECT_ASSETENTRY_WHERE);
769
770 query.append(_FINDER_COLUMN_G_CU_GROUPID_2);
771
772 if (classUuid == null) {
773 query.append(_FINDER_COLUMN_G_CU_CLASSUUID_1);
774 }
775 else {
776 if (classUuid.equals(StringPool.BLANK)) {
777 query.append(_FINDER_COLUMN_G_CU_CLASSUUID_3);
778 }
779 else {
780 query.append(_FINDER_COLUMN_G_CU_CLASSUUID_2);
781 }
782 }
783
784 String sql = query.toString();
785
786 Query q = session.createQuery(sql);
787
788 QueryPos qPos = QueryPos.getInstance(q);
789
790 qPos.add(groupId);
791
792 if (classUuid != null) {
793 qPos.add(classUuid);
794 }
795
796 List<AssetEntry> list = q.list();
797
798 result = list;
799
800 AssetEntry assetEntry = null;
801
802 if (list.isEmpty()) {
803 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_CU,
804 finderArgs, list);
805 }
806 else {
807 assetEntry = list.get(0);
808
809 cacheResult(assetEntry);
810
811 if ((assetEntry.getGroupId() != groupId) ||
812 (assetEntry.getClassUuid() == null) ||
813 !assetEntry.getClassUuid().equals(classUuid)) {
814 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_CU,
815 finderArgs, assetEntry);
816 }
817 }
818
819 return assetEntry;
820 }
821 catch (Exception e) {
822 throw processException(e);
823 }
824 finally {
825 if (result == null) {
826 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_CU,
827 finderArgs, new ArrayList<AssetEntry>());
828 }
829
830 closeSession(session);
831 }
832 }
833 else {
834 if (result instanceof List<?>) {
835 return null;
836 }
837 else {
838 return (AssetEntry)result;
839 }
840 }
841 }
842
843 public AssetEntry findByC_C(long classNameId, long classPK)
844 throws NoSuchEntryException, SystemException {
845 AssetEntry assetEntry = fetchByC_C(classNameId, classPK);
846
847 if (assetEntry == null) {
848 StringBundler msg = new StringBundler(6);
849
850 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
851
852 msg.append("classNameId=");
853 msg.append(classNameId);
854
855 msg.append(", classPK=");
856 msg.append(classPK);
857
858 msg.append(StringPool.CLOSE_CURLY_BRACE);
859
860 if (_log.isWarnEnabled()) {
861 _log.warn(msg.toString());
862 }
863
864 throw new NoSuchEntryException(msg.toString());
865 }
866
867 return assetEntry;
868 }
869
870 public AssetEntry fetchByC_C(long classNameId, long classPK)
871 throws SystemException {
872 return fetchByC_C(classNameId, classPK, true);
873 }
874
875 public AssetEntry fetchByC_C(long classNameId, long classPK,
876 boolean retrieveFromCache) throws SystemException {
877 Object[] finderArgs = new Object[] { classNameId, classPK };
878
879 Object result = null;
880
881 if (retrieveFromCache) {
882 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_C_C,
883 finderArgs, this);
884 }
885
886 if (result == null) {
887 Session session = null;
888
889 try {
890 session = openSession();
891
892 StringBundler query = new StringBundler(3);
893
894 query.append(_SQL_SELECT_ASSETENTRY_WHERE);
895
896 query.append(_FINDER_COLUMN_C_C_CLASSNAMEID_2);
897
898 query.append(_FINDER_COLUMN_C_C_CLASSPK_2);
899
900 String sql = query.toString();
901
902 Query q = session.createQuery(sql);
903
904 QueryPos qPos = QueryPos.getInstance(q);
905
906 qPos.add(classNameId);
907
908 qPos.add(classPK);
909
910 List<AssetEntry> list = q.list();
911
912 result = list;
913
914 AssetEntry assetEntry = null;
915
916 if (list.isEmpty()) {
917 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C,
918 finderArgs, list);
919 }
920 else {
921 assetEntry = list.get(0);
922
923 cacheResult(assetEntry);
924
925 if ((assetEntry.getClassNameId() != classNameId) ||
926 (assetEntry.getClassPK() != classPK)) {
927 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C,
928 finderArgs, assetEntry);
929 }
930 }
931
932 return assetEntry;
933 }
934 catch (Exception e) {
935 throw processException(e);
936 }
937 finally {
938 if (result == null) {
939 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C,
940 finderArgs, new ArrayList<AssetEntry>());
941 }
942
943 closeSession(session);
944 }
945 }
946 else {
947 if (result instanceof List<?>) {
948 return null;
949 }
950 else {
951 return (AssetEntry)result;
952 }
953 }
954 }
955
956 public List<AssetEntry> findAll() throws SystemException {
957 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
958 }
959
960 public List<AssetEntry> findAll(int start, int end)
961 throws SystemException {
962 return findAll(start, end, null);
963 }
964
965 public List<AssetEntry> findAll(int start, int end,
966 OrderByComparator orderByComparator) throws SystemException {
967 Object[] finderArgs = new Object[] {
968 String.valueOf(start), String.valueOf(end),
969 String.valueOf(orderByComparator)
970 };
971
972 List<AssetEntry> list = (List<AssetEntry>)FinderCacheUtil.getResult(FINDER_PATH_FIND_ALL,
973 finderArgs, this);
974
975 if (list == null) {
976 Session session = null;
977
978 try {
979 session = openSession();
980
981 StringBundler query = null;
982 String sql = null;
983
984 if (orderByComparator != null) {
985 query = new StringBundler(2 +
986 (orderByComparator.getOrderByFields().length * 3));
987
988 query.append(_SQL_SELECT_ASSETENTRY);
989
990 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
991 orderByComparator);
992
993 sql = query.toString();
994 }
995 else {
996 sql = _SQL_SELECT_ASSETENTRY;
997 }
998
999 Query q = session.createQuery(sql);
1000
1001 if (orderByComparator == null) {
1002 list = (List<AssetEntry>)QueryUtil.list(q, getDialect(),
1003 start, end, false);
1004
1005 Collections.sort(list);
1006 }
1007 else {
1008 list = (List<AssetEntry>)QueryUtil.list(q, getDialect(),
1009 start, end);
1010 }
1011 }
1012 catch (Exception e) {
1013 throw processException(e);
1014 }
1015 finally {
1016 if (list == null) {
1017 list = new ArrayList<AssetEntry>();
1018 }
1019
1020 cacheResult(list);
1021
1022 FinderCacheUtil.putResult(FINDER_PATH_FIND_ALL, finderArgs, list);
1023
1024 closeSession(session);
1025 }
1026 }
1027
1028 return list;
1029 }
1030
1031 public void removeByCompanyId(long companyId) throws SystemException {
1032 for (AssetEntry assetEntry : findByCompanyId(companyId)) {
1033 remove(assetEntry);
1034 }
1035 }
1036
1037 public void removeByG_CU(long groupId, String classUuid)
1038 throws NoSuchEntryException, SystemException {
1039 AssetEntry assetEntry = findByG_CU(groupId, classUuid);
1040
1041 remove(assetEntry);
1042 }
1043
1044 public void removeByC_C(long classNameId, long classPK)
1045 throws NoSuchEntryException, SystemException {
1046 AssetEntry assetEntry = findByC_C(classNameId, classPK);
1047
1048 remove(assetEntry);
1049 }
1050
1051 public void removeAll() throws SystemException {
1052 for (AssetEntry assetEntry : findAll()) {
1053 remove(assetEntry);
1054 }
1055 }
1056
1057 public int countByCompanyId(long companyId) throws SystemException {
1058 Object[] finderArgs = new Object[] { companyId };
1059
1060 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_COMPANYID,
1061 finderArgs, this);
1062
1063 if (count == null) {
1064 Session session = null;
1065
1066 try {
1067 session = openSession();
1068
1069 StringBundler query = new StringBundler(2);
1070
1071 query.append(_SQL_COUNT_ASSETENTRY_WHERE);
1072
1073 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
1074
1075 String sql = query.toString();
1076
1077 Query q = session.createQuery(sql);
1078
1079 QueryPos qPos = QueryPos.getInstance(q);
1080
1081 qPos.add(companyId);
1082
1083 count = (Long)q.uniqueResult();
1084 }
1085 catch (Exception e) {
1086 throw processException(e);
1087 }
1088 finally {
1089 if (count == null) {
1090 count = Long.valueOf(0);
1091 }
1092
1093 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_COMPANYID,
1094 finderArgs, count);
1095
1096 closeSession(session);
1097 }
1098 }
1099
1100 return count.intValue();
1101 }
1102
1103 public int countByG_CU(long groupId, String classUuid)
1104 throws SystemException {
1105 Object[] finderArgs = new Object[] { groupId, classUuid };
1106
1107 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_CU,
1108 finderArgs, this);
1109
1110 if (count == null) {
1111 Session session = null;
1112
1113 try {
1114 session = openSession();
1115
1116 StringBundler query = new StringBundler(3);
1117
1118 query.append(_SQL_COUNT_ASSETENTRY_WHERE);
1119
1120 query.append(_FINDER_COLUMN_G_CU_GROUPID_2);
1121
1122 if (classUuid == null) {
1123 query.append(_FINDER_COLUMN_G_CU_CLASSUUID_1);
1124 }
1125 else {
1126 if (classUuid.equals(StringPool.BLANK)) {
1127 query.append(_FINDER_COLUMN_G_CU_CLASSUUID_3);
1128 }
1129 else {
1130 query.append(_FINDER_COLUMN_G_CU_CLASSUUID_2);
1131 }
1132 }
1133
1134 String sql = query.toString();
1135
1136 Query q = session.createQuery(sql);
1137
1138 QueryPos qPos = QueryPos.getInstance(q);
1139
1140 qPos.add(groupId);
1141
1142 if (classUuid != null) {
1143 qPos.add(classUuid);
1144 }
1145
1146 count = (Long)q.uniqueResult();
1147 }
1148 catch (Exception e) {
1149 throw processException(e);
1150 }
1151 finally {
1152 if (count == null) {
1153 count = Long.valueOf(0);
1154 }
1155
1156 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_CU,
1157 finderArgs, count);
1158
1159 closeSession(session);
1160 }
1161 }
1162
1163 return count.intValue();
1164 }
1165
1166 public int countByC_C(long classNameId, long classPK)
1167 throws SystemException {
1168 Object[] finderArgs = new Object[] { classNameId, classPK };
1169
1170 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_C,
1171 finderArgs, this);
1172
1173 if (count == null) {
1174 Session session = null;
1175
1176 try {
1177 session = openSession();
1178
1179 StringBundler query = new StringBundler(3);
1180
1181 query.append(_SQL_COUNT_ASSETENTRY_WHERE);
1182
1183 query.append(_FINDER_COLUMN_C_C_CLASSNAMEID_2);
1184
1185 query.append(_FINDER_COLUMN_C_C_CLASSPK_2);
1186
1187 String sql = query.toString();
1188
1189 Query q = session.createQuery(sql);
1190
1191 QueryPos qPos = QueryPos.getInstance(q);
1192
1193 qPos.add(classNameId);
1194
1195 qPos.add(classPK);
1196
1197 count = (Long)q.uniqueResult();
1198 }
1199 catch (Exception e) {
1200 throw processException(e);
1201 }
1202 finally {
1203 if (count == null) {
1204 count = Long.valueOf(0);
1205 }
1206
1207 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_C, finderArgs,
1208 count);
1209
1210 closeSession(session);
1211 }
1212 }
1213
1214 return count.intValue();
1215 }
1216
1217 public int countAll() throws SystemException {
1218 Object[] finderArgs = new Object[0];
1219
1220 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
1221 finderArgs, this);
1222
1223 if (count == null) {
1224 Session session = null;
1225
1226 try {
1227 session = openSession();
1228
1229 Query q = session.createQuery(_SQL_COUNT_ASSETENTRY);
1230
1231 count = (Long)q.uniqueResult();
1232 }
1233 catch (Exception e) {
1234 throw processException(e);
1235 }
1236 finally {
1237 if (count == null) {
1238 count = Long.valueOf(0);
1239 }
1240
1241 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL, finderArgs,
1242 count);
1243
1244 closeSession(session);
1245 }
1246 }
1247
1248 return count.intValue();
1249 }
1250
1251 public List<com.liferay.portlet.asset.model.AssetCategory> getAssetCategories(
1252 long pk) throws SystemException {
1253 return getAssetCategories(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
1254 }
1255
1256 public List<com.liferay.portlet.asset.model.AssetCategory> getAssetCategories(
1257 long pk, int start, int end) throws SystemException {
1258 return getAssetCategories(pk, start, end, null);
1259 }
1260
1261 public static final FinderPath FINDER_PATH_GET_ASSETCATEGORIES = new FinderPath(com.liferay.portlet.asset.model.impl.AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
1262 AssetEntryModelImpl.FINDER_CACHE_ENABLED_ASSETENTRIES_ASSETCATEGORIES,
1263 AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME,
1264 "getAssetCategories",
1265 new String[] {
1266 Long.class.getName(), "java.lang.Integer", "java.lang.Integer",
1267 "com.liferay.portal.kernel.util.OrderByComparator"
1268 });
1269
1270 public List<com.liferay.portlet.asset.model.AssetCategory> getAssetCategories(
1271 long pk, int start, int end, OrderByComparator orderByComparator)
1272 throws SystemException {
1273 Object[] finderArgs = new Object[] {
1274 pk, String.valueOf(start), String.valueOf(end),
1275 String.valueOf(orderByComparator)
1276 };
1277
1278 List<com.liferay.portlet.asset.model.AssetCategory> list = (List<com.liferay.portlet.asset.model.AssetCategory>)FinderCacheUtil.getResult(FINDER_PATH_GET_ASSETCATEGORIES,
1279 finderArgs, this);
1280
1281 if (list == null) {
1282 Session session = null;
1283
1284 try {
1285 session = openSession();
1286
1287 String sql = null;
1288
1289 if (orderByComparator != null) {
1290 sql = _SQL_GETASSETCATEGORIES.concat(ORDER_BY_CLAUSE)
1291 .concat(orderByComparator.getOrderBy());
1292 }
1293 else {
1294 sql = _SQL_GETASSETCATEGORIES.concat(com.liferay.portlet.asset.model.impl.AssetCategoryModelImpl.ORDER_BY_SQL);
1295 }
1296
1297 SQLQuery q = session.createSQLQuery(sql);
1298
1299 q.addEntity("AssetCategory",
1300 com.liferay.portlet.asset.model.impl.AssetCategoryImpl.class);
1301
1302 QueryPos qPos = QueryPos.getInstance(q);
1303
1304 qPos.add(pk);
1305
1306 list = (List<com.liferay.portlet.asset.model.AssetCategory>)QueryUtil.list(q,
1307 getDialect(), start, end);
1308 }
1309 catch (Exception e) {
1310 throw processException(e);
1311 }
1312 finally {
1313 if (list == null) {
1314 list = new ArrayList<com.liferay.portlet.asset.model.AssetCategory>();
1315 }
1316
1317 assetCategoryPersistence.cacheResult(list);
1318
1319 FinderCacheUtil.putResult(FINDER_PATH_GET_ASSETCATEGORIES,
1320 finderArgs, list);
1321
1322 closeSession(session);
1323 }
1324 }
1325
1326 return list;
1327 }
1328
1329 public static final FinderPath FINDER_PATH_GET_ASSETCATEGORIES_SIZE = new FinderPath(com.liferay.portlet.asset.model.impl.AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
1330 AssetEntryModelImpl.FINDER_CACHE_ENABLED_ASSETENTRIES_ASSETCATEGORIES,
1331 AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME,
1332 "getAssetCategoriesSize", new String[] { Long.class.getName() });
1333
1334 public int getAssetCategoriesSize(long pk) throws SystemException {
1335 Object[] finderArgs = new Object[] { pk };
1336
1337 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_GET_ASSETCATEGORIES_SIZE,
1338 finderArgs, this);
1339
1340 if (count == null) {
1341 Session session = null;
1342
1343 try {
1344 session = openSession();
1345
1346 SQLQuery q = session.createSQLQuery(_SQL_GETASSETCATEGORIESSIZE);
1347
1348 q.addScalar(COUNT_COLUMN_NAME,
1349 com.liferay.portal.kernel.dao.orm.Type.LONG);
1350
1351 QueryPos qPos = QueryPos.getInstance(q);
1352
1353 qPos.add(pk);
1354
1355 count = (Long)q.uniqueResult();
1356 }
1357 catch (Exception e) {
1358 throw processException(e);
1359 }
1360 finally {
1361 if (count == null) {
1362 count = Long.valueOf(0);
1363 }
1364
1365 FinderCacheUtil.putResult(FINDER_PATH_GET_ASSETCATEGORIES_SIZE,
1366 finderArgs, count);
1367
1368 closeSession(session);
1369 }
1370 }
1371
1372 return count.intValue();
1373 }
1374
1375 public static final FinderPath FINDER_PATH_CONTAINS_ASSETCATEGORY = new FinderPath(com.liferay.portlet.asset.model.impl.AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
1376 AssetEntryModelImpl.FINDER_CACHE_ENABLED_ASSETENTRIES_ASSETCATEGORIES,
1377 AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME,
1378 "containsAssetCategory",
1379 new String[] { Long.class.getName(), Long.class.getName() });
1380
1381 public boolean containsAssetCategory(long pk, long assetCategoryPK)
1382 throws SystemException {
1383 Object[] finderArgs = new Object[] { pk, assetCategoryPK };
1384
1385 Boolean value = (Boolean)FinderCacheUtil.getResult(FINDER_PATH_CONTAINS_ASSETCATEGORY,
1386 finderArgs, this);
1387
1388 if (value == null) {
1389 try {
1390 value = Boolean.valueOf(containsAssetCategory.contains(pk,
1391 assetCategoryPK));
1392 }
1393 catch (Exception e) {
1394 throw processException(e);
1395 }
1396 finally {
1397 if (value == null) {
1398 value = Boolean.FALSE;
1399 }
1400
1401 FinderCacheUtil.putResult(FINDER_PATH_CONTAINS_ASSETCATEGORY,
1402 finderArgs, value);
1403 }
1404 }
1405
1406 return value.booleanValue();
1407 }
1408
1409 public boolean containsAssetCategories(long pk) throws SystemException {
1410 if (getAssetCategoriesSize(pk) > 0) {
1411 return true;
1412 }
1413 else {
1414 return false;
1415 }
1416 }
1417
1418 public void addAssetCategory(long pk, long assetCategoryPK)
1419 throws SystemException {
1420 try {
1421 addAssetCategory.add(pk, assetCategoryPK);
1422 }
1423 catch (Exception e) {
1424 throw processException(e);
1425 }
1426 finally {
1427 FinderCacheUtil.clearCache(AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
1428 }
1429 }
1430
1431 public void addAssetCategory(long pk,
1432 com.liferay.portlet.asset.model.AssetCategory assetCategory)
1433 throws SystemException {
1434 try {
1435 addAssetCategory.add(pk, assetCategory.getPrimaryKey());
1436 }
1437 catch (Exception e) {
1438 throw processException(e);
1439 }
1440 finally {
1441 FinderCacheUtil.clearCache(AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
1442 }
1443 }
1444
1445 public void addAssetCategories(long pk, long[] assetCategoryPKs)
1446 throws SystemException {
1447 try {
1448 for (long assetCategoryPK : assetCategoryPKs) {
1449 addAssetCategory.add(pk, assetCategoryPK);
1450 }
1451 }
1452 catch (Exception e) {
1453 throw processException(e);
1454 }
1455 finally {
1456 FinderCacheUtil.clearCache(AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
1457 }
1458 }
1459
1460 public void addAssetCategories(long pk,
1461 List<com.liferay.portlet.asset.model.AssetCategory> assetCategories)
1462 throws SystemException {
1463 try {
1464 for (com.liferay.portlet.asset.model.AssetCategory assetCategory : assetCategories) {
1465 addAssetCategory.add(pk, assetCategory.getPrimaryKey());
1466 }
1467 }
1468 catch (Exception e) {
1469 throw processException(e);
1470 }
1471 finally {
1472 FinderCacheUtil.clearCache(AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
1473 }
1474 }
1475
1476 public void clearAssetCategories(long pk) throws SystemException {
1477 try {
1478 clearAssetCategories.clear(pk);
1479 }
1480 catch (Exception e) {
1481 throw processException(e);
1482 }
1483 finally {
1484 FinderCacheUtil.clearCache(AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
1485 }
1486 }
1487
1488 public void removeAssetCategory(long pk, long assetCategoryPK)
1489 throws SystemException {
1490 try {
1491 removeAssetCategory.remove(pk, assetCategoryPK);
1492 }
1493 catch (Exception e) {
1494 throw processException(e);
1495 }
1496 finally {
1497 FinderCacheUtil.clearCache(AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
1498 }
1499 }
1500
1501 public void removeAssetCategory(long pk,
1502 com.liferay.portlet.asset.model.AssetCategory assetCategory)
1503 throws SystemException {
1504 try {
1505 removeAssetCategory.remove(pk, assetCategory.getPrimaryKey());
1506 }
1507 catch (Exception e) {
1508 throw processException(e);
1509 }
1510 finally {
1511 FinderCacheUtil.clearCache(AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
1512 }
1513 }
1514
1515 public void removeAssetCategories(long pk, long[] assetCategoryPKs)
1516 throws SystemException {
1517 try {
1518 for (long assetCategoryPK : assetCategoryPKs) {
1519 removeAssetCategory.remove(pk, assetCategoryPK);
1520 }
1521 }
1522 catch (Exception e) {
1523 throw processException(e);
1524 }
1525 finally {
1526 FinderCacheUtil.clearCache(AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
1527 }
1528 }
1529
1530 public void removeAssetCategories(long pk,
1531 List<com.liferay.portlet.asset.model.AssetCategory> assetCategories)
1532 throws SystemException {
1533 try {
1534 for (com.liferay.portlet.asset.model.AssetCategory assetCategory : assetCategories) {
1535 removeAssetCategory.remove(pk, assetCategory.getPrimaryKey());
1536 }
1537 }
1538 catch (Exception e) {
1539 throw processException(e);
1540 }
1541 finally {
1542 FinderCacheUtil.clearCache(AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
1543 }
1544 }
1545
1546 public void setAssetCategories(long pk, long[] assetCategoryPKs)
1547 throws SystemException {
1548 try {
1549 Set<Long> assetCategoryPKSet = SetUtil.fromArray(assetCategoryPKs);
1550
1551 List<com.liferay.portlet.asset.model.AssetCategory> assetCategories = getAssetCategories(pk);
1552
1553 for (com.liferay.portlet.asset.model.AssetCategory assetCategory : assetCategories) {
1554 if (!assetCategoryPKSet.contains(assetCategory.getPrimaryKey())) {
1555 removeAssetCategory.remove(pk, assetCategory.getPrimaryKey());
1556 }
1557 else {
1558 assetCategoryPKSet.remove(assetCategory.getPrimaryKey());
1559 }
1560 }
1561
1562 for (Long assetCategoryPK : assetCategoryPKSet) {
1563 addAssetCategory.add(pk, assetCategoryPK);
1564 }
1565 }
1566 catch (Exception e) {
1567 throw processException(e);
1568 }
1569 finally {
1570 FinderCacheUtil.clearCache(AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
1571 }
1572 }
1573
1574 public void setAssetCategories(long pk,
1575 List<com.liferay.portlet.asset.model.AssetCategory> assetCategories)
1576 throws SystemException {
1577 try {
1578 long[] assetCategoryPKs = new long[assetCategories.size()];
1579
1580 for (int i = 0; i < assetCategories.size(); i++) {
1581 com.liferay.portlet.asset.model.AssetCategory assetCategory = assetCategories.get(i);
1582
1583 assetCategoryPKs[i] = assetCategory.getPrimaryKey();
1584 }
1585
1586 setAssetCategories(pk, assetCategoryPKs);
1587 }
1588 catch (Exception e) {
1589 throw processException(e);
1590 }
1591 finally {
1592 FinderCacheUtil.clearCache(AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
1593 }
1594 }
1595
1596 public List<com.liferay.portlet.asset.model.AssetTag> getAssetTags(long pk)
1597 throws SystemException {
1598 return getAssetTags(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
1599 }
1600
1601 public List<com.liferay.portlet.asset.model.AssetTag> getAssetTags(
1602 long pk, int start, int end) throws SystemException {
1603 return getAssetTags(pk, start, end, null);
1604 }
1605
1606 public static final FinderPath FINDER_PATH_GET_ASSETTAGS = new FinderPath(com.liferay.portlet.asset.model.impl.AssetTagModelImpl.ENTITY_CACHE_ENABLED,
1607 AssetEntryModelImpl.FINDER_CACHE_ENABLED_ASSETENTRIES_ASSETTAGS,
1608 AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETTAGS_NAME,
1609 "getAssetTags",
1610 new String[] {
1611 Long.class.getName(), "java.lang.Integer", "java.lang.Integer",
1612 "com.liferay.portal.kernel.util.OrderByComparator"
1613 });
1614
1615 public List<com.liferay.portlet.asset.model.AssetTag> getAssetTags(
1616 long pk, int start, int end, OrderByComparator orderByComparator)
1617 throws SystemException {
1618 Object[] finderArgs = new Object[] {
1619 pk, String.valueOf(start), String.valueOf(end),
1620 String.valueOf(orderByComparator)
1621 };
1622
1623 List<com.liferay.portlet.asset.model.AssetTag> list = (List<com.liferay.portlet.asset.model.AssetTag>)FinderCacheUtil.getResult(FINDER_PATH_GET_ASSETTAGS,
1624 finderArgs, this);
1625
1626 if (list == null) {
1627 Session session = null;
1628
1629 try {
1630 session = openSession();
1631
1632 String sql = null;
1633
1634 if (orderByComparator != null) {
1635 sql = _SQL_GETASSETTAGS.concat(ORDER_BY_CLAUSE)
1636 .concat(orderByComparator.getOrderBy());
1637 }
1638 else {
1639 sql = _SQL_GETASSETTAGS.concat(com.liferay.portlet.asset.model.impl.AssetTagModelImpl.ORDER_BY_SQL);
1640 }
1641
1642 SQLQuery q = session.createSQLQuery(sql);
1643
1644 q.addEntity("AssetTag",
1645 com.liferay.portlet.asset.model.impl.AssetTagImpl.class);
1646
1647 QueryPos qPos = QueryPos.getInstance(q);
1648
1649 qPos.add(pk);
1650
1651 list = (List<com.liferay.portlet.asset.model.AssetTag>)QueryUtil.list(q,
1652 getDialect(), start, end);
1653 }
1654 catch (Exception e) {
1655 throw processException(e);
1656 }
1657 finally {
1658 if (list == null) {
1659 list = new ArrayList<com.liferay.portlet.asset.model.AssetTag>();
1660 }
1661
1662 assetTagPersistence.cacheResult(list);
1663
1664 FinderCacheUtil.putResult(FINDER_PATH_GET_ASSETTAGS,
1665 finderArgs, list);
1666
1667 closeSession(session);
1668 }
1669 }
1670
1671 return list;
1672 }
1673
1674 public static final FinderPath FINDER_PATH_GET_ASSETTAGS_SIZE = new FinderPath(com.liferay.portlet.asset.model.impl.AssetTagModelImpl.ENTITY_CACHE_ENABLED,
1675 AssetEntryModelImpl.FINDER_CACHE_ENABLED_ASSETENTRIES_ASSETTAGS,
1676 AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETTAGS_NAME,
1677 "getAssetTagsSize", new String[] { Long.class.getName() });
1678
1679 public int getAssetTagsSize(long pk) throws SystemException {
1680 Object[] finderArgs = new Object[] { pk };
1681
1682 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_GET_ASSETTAGS_SIZE,
1683 finderArgs, this);
1684
1685 if (count == null) {
1686 Session session = null;
1687
1688 try {
1689 session = openSession();
1690
1691 SQLQuery q = session.createSQLQuery(_SQL_GETASSETTAGSSIZE);
1692
1693 q.addScalar(COUNT_COLUMN_NAME,
1694 com.liferay.portal.kernel.dao.orm.Type.LONG);
1695
1696 QueryPos qPos = QueryPos.getInstance(q);
1697
1698 qPos.add(pk);
1699
1700 count = (Long)q.uniqueResult();
1701 }
1702 catch (Exception e) {
1703 throw processException(e);
1704 }
1705 finally {
1706 if (count == null) {
1707 count = Long.valueOf(0);
1708 }
1709
1710 FinderCacheUtil.putResult(FINDER_PATH_GET_ASSETTAGS_SIZE,
1711 finderArgs, count);
1712
1713 closeSession(session);
1714 }
1715 }
1716
1717 return count.intValue();
1718 }
1719
1720 public static final FinderPath FINDER_PATH_CONTAINS_ASSETTAG = new FinderPath(com.liferay.portlet.asset.model.impl.AssetTagModelImpl.ENTITY_CACHE_ENABLED,
1721 AssetEntryModelImpl.FINDER_CACHE_ENABLED_ASSETENTRIES_ASSETTAGS,
1722 AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETTAGS_NAME,
1723 "containsAssetTag",
1724 new String[] { Long.class.getName(), Long.class.getName() });
1725
1726 public boolean containsAssetTag(long pk, long assetTagPK)
1727 throws SystemException {
1728 Object[] finderArgs = new Object[] { pk, assetTagPK };
1729
1730 Boolean value = (Boolean)FinderCacheUtil.getResult(FINDER_PATH_CONTAINS_ASSETTAG,
1731 finderArgs, this);
1732
1733 if (value == null) {
1734 try {
1735 value = Boolean.valueOf(containsAssetTag.contains(pk, assetTagPK));
1736 }
1737 catch (Exception e) {
1738 throw processException(e);
1739 }
1740 finally {
1741 if (value == null) {
1742 value = Boolean.FALSE;
1743 }
1744
1745 FinderCacheUtil.putResult(FINDER_PATH_CONTAINS_ASSETTAG,
1746 finderArgs, value);
1747 }
1748 }
1749
1750 return value.booleanValue();
1751 }
1752
1753 public boolean containsAssetTags(long pk) throws SystemException {
1754 if (getAssetTagsSize(pk) > 0) {
1755 return true;
1756 }
1757 else {
1758 return false;
1759 }
1760 }
1761
1762 public void addAssetTag(long pk, long assetTagPK) throws SystemException {
1763 try {
1764 addAssetTag.add(pk, assetTagPK);
1765 }
1766 catch (Exception e) {
1767 throw processException(e);
1768 }
1769 finally {
1770 FinderCacheUtil.clearCache(AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETTAGS_NAME);
1771 }
1772 }
1773
1774 public void addAssetTag(long pk,
1775 com.liferay.portlet.asset.model.AssetTag assetTag)
1776 throws SystemException {
1777 try {
1778 addAssetTag.add(pk, assetTag.getPrimaryKey());
1779 }
1780 catch (Exception e) {
1781 throw processException(e);
1782 }
1783 finally {
1784 FinderCacheUtil.clearCache(AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETTAGS_NAME);
1785 }
1786 }
1787
1788 public void addAssetTags(long pk, long[] assetTagPKs)
1789 throws SystemException {
1790 try {
1791 for (long assetTagPK : assetTagPKs) {
1792 addAssetTag.add(pk, assetTagPK);
1793 }
1794 }
1795 catch (Exception e) {
1796 throw processException(e);
1797 }
1798 finally {
1799 FinderCacheUtil.clearCache(AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETTAGS_NAME);
1800 }
1801 }
1802
1803 public void addAssetTags(long pk,
1804 List<com.liferay.portlet.asset.model.AssetTag> assetTags)
1805 throws SystemException {
1806 try {
1807 for (com.liferay.portlet.asset.model.AssetTag assetTag : assetTags) {
1808 addAssetTag.add(pk, assetTag.getPrimaryKey());
1809 }
1810 }
1811 catch (Exception e) {
1812 throw processException(e);
1813 }
1814 finally {
1815 FinderCacheUtil.clearCache(AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETTAGS_NAME);
1816 }
1817 }
1818
1819 public void clearAssetTags(long pk) throws SystemException {
1820 try {
1821 clearAssetTags.clear(pk);
1822 }
1823 catch (Exception e) {
1824 throw processException(e);
1825 }
1826 finally {
1827 FinderCacheUtil.clearCache(AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETTAGS_NAME);
1828 }
1829 }
1830
1831 public void removeAssetTag(long pk, long assetTagPK)
1832 throws SystemException {
1833 try {
1834 removeAssetTag.remove(pk, assetTagPK);
1835 }
1836 catch (Exception e) {
1837 throw processException(e);
1838 }
1839 finally {
1840 FinderCacheUtil.clearCache(AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETTAGS_NAME);
1841 }
1842 }
1843
1844 public void removeAssetTag(long pk,
1845 com.liferay.portlet.asset.model.AssetTag assetTag)
1846 throws SystemException {
1847 try {
1848 removeAssetTag.remove(pk, assetTag.getPrimaryKey());
1849 }
1850 catch (Exception e) {
1851 throw processException(e);
1852 }
1853 finally {
1854 FinderCacheUtil.clearCache(AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETTAGS_NAME);
1855 }
1856 }
1857
1858 public void removeAssetTags(long pk, long[] assetTagPKs)
1859 throws SystemException {
1860 try {
1861 for (long assetTagPK : assetTagPKs) {
1862 removeAssetTag.remove(pk, assetTagPK);
1863 }
1864 }
1865 catch (Exception e) {
1866 throw processException(e);
1867 }
1868 finally {
1869 FinderCacheUtil.clearCache(AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETTAGS_NAME);
1870 }
1871 }
1872
1873 public void removeAssetTags(long pk,
1874 List<com.liferay.portlet.asset.model.AssetTag> assetTags)
1875 throws SystemException {
1876 try {
1877 for (com.liferay.portlet.asset.model.AssetTag assetTag : assetTags) {
1878 removeAssetTag.remove(pk, assetTag.getPrimaryKey());
1879 }
1880 }
1881 catch (Exception e) {
1882 throw processException(e);
1883 }
1884 finally {
1885 FinderCacheUtil.clearCache(AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETTAGS_NAME);
1886 }
1887 }
1888
1889 public void setAssetTags(long pk, long[] assetTagPKs)
1890 throws SystemException {
1891 try {
1892 Set<Long> assetTagPKSet = SetUtil.fromArray(assetTagPKs);
1893
1894 List<com.liferay.portlet.asset.model.AssetTag> assetTags = getAssetTags(pk);
1895
1896 for (com.liferay.portlet.asset.model.AssetTag assetTag : assetTags) {
1897 if (!assetTagPKSet.contains(assetTag.getPrimaryKey())) {
1898 removeAssetTag.remove(pk, assetTag.getPrimaryKey());
1899 }
1900 else {
1901 assetTagPKSet.remove(assetTag.getPrimaryKey());
1902 }
1903 }
1904
1905 for (Long assetTagPK : assetTagPKSet) {
1906 addAssetTag.add(pk, assetTagPK);
1907 }
1908 }
1909 catch (Exception e) {
1910 throw processException(e);
1911 }
1912 finally {
1913 FinderCacheUtil.clearCache(AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETTAGS_NAME);
1914 }
1915 }
1916
1917 public void setAssetTags(long pk,
1918 List<com.liferay.portlet.asset.model.AssetTag> assetTags)
1919 throws SystemException {
1920 try {
1921 long[] assetTagPKs = new long[assetTags.size()];
1922
1923 for (int i = 0; i < assetTags.size(); i++) {
1924 com.liferay.portlet.asset.model.AssetTag assetTag = assetTags.get(i);
1925
1926 assetTagPKs[i] = assetTag.getPrimaryKey();
1927 }
1928
1929 setAssetTags(pk, assetTagPKs);
1930 }
1931 catch (Exception e) {
1932 throw processException(e);
1933 }
1934 finally {
1935 FinderCacheUtil.clearCache(AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETTAGS_NAME);
1936 }
1937 }
1938
1939 public void afterPropertiesSet() {
1940 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
1941 com.liferay.portal.util.PropsUtil.get(
1942 "value.object.listener.com.liferay.portlet.asset.model.AssetEntry")));
1943
1944 if (listenerClassNames.length > 0) {
1945 try {
1946 List<ModelListener<AssetEntry>> listenersList = new ArrayList<ModelListener<AssetEntry>>();
1947
1948 for (String listenerClassName : listenerClassNames) {
1949 listenersList.add((ModelListener<AssetEntry>)InstanceFactory.newInstance(
1950 listenerClassName));
1951 }
1952
1953 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
1954 }
1955 catch (Exception e) {
1956 _log.error(e);
1957 }
1958 }
1959
1960 containsAssetCategory = new ContainsAssetCategory(this);
1961
1962 addAssetCategory = new AddAssetCategory(this);
1963 clearAssetCategories = new ClearAssetCategories(this);
1964 removeAssetCategory = new RemoveAssetCategory(this);
1965
1966 containsAssetTag = new ContainsAssetTag(this);
1967
1968 addAssetTag = new AddAssetTag(this);
1969 clearAssetTags = new ClearAssetTags(this);
1970 removeAssetTag = new RemoveAssetTag(this);
1971 }
1972
1973 @BeanReference(type = AssetCategoryPersistence.class)
1974 protected AssetCategoryPersistence assetCategoryPersistence;
1975 @BeanReference(type = AssetCategoryPropertyPersistence.class)
1976 protected AssetCategoryPropertyPersistence assetCategoryPropertyPersistence;
1977 @BeanReference(type = AssetEntryPersistence.class)
1978 protected AssetEntryPersistence assetEntryPersistence;
1979 @BeanReference(type = AssetLinkPersistence.class)
1980 protected AssetLinkPersistence assetLinkPersistence;
1981 @BeanReference(type = AssetTagPersistence.class)
1982 protected AssetTagPersistence assetTagPersistence;
1983 @BeanReference(type = AssetTagPropertyPersistence.class)
1984 protected AssetTagPropertyPersistence assetTagPropertyPersistence;
1985 @BeanReference(type = AssetTagStatsPersistence.class)
1986 protected AssetTagStatsPersistence assetTagStatsPersistence;
1987 @BeanReference(type = AssetVocabularyPersistence.class)
1988 protected AssetVocabularyPersistence assetVocabularyPersistence;
1989 @BeanReference(type = CompanyPersistence.class)
1990 protected CompanyPersistence companyPersistence;
1991 @BeanReference(type = GroupPersistence.class)
1992 protected GroupPersistence groupPersistence;
1993 @BeanReference(type = ResourcePersistence.class)
1994 protected ResourcePersistence resourcePersistence;
1995 @BeanReference(type = UserPersistence.class)
1996 protected UserPersistence userPersistence;
1997 @BeanReference(type = BlogsEntryPersistence.class)
1998 protected BlogsEntryPersistence blogsEntryPersistence;
1999 @BeanReference(type = BookmarksEntryPersistence.class)
2000 protected BookmarksEntryPersistence bookmarksEntryPersistence;
2001 @BeanReference(type = DLFileEntryPersistence.class)
2002 protected DLFileEntryPersistence dlFileEntryPersistence;
2003 @BeanReference(type = DLFolderPersistence.class)
2004 protected DLFolderPersistence dlFolderPersistence;
2005 @BeanReference(type = JournalArticlePersistence.class)
2006 protected JournalArticlePersistence journalArticlePersistence;
2007 @BeanReference(type = JournalArticleResourcePersistence.class)
2008 protected JournalArticleResourcePersistence journalArticleResourcePersistence;
2009 @BeanReference(type = MBMessagePersistence.class)
2010 protected MBMessagePersistence mbMessagePersistence;
2011 @BeanReference(type = SocialEquityLogPersistence.class)
2012 protected SocialEquityLogPersistence socialEquityLogPersistence;
2013 @BeanReference(type = WikiPagePersistence.class)
2014 protected WikiPagePersistence wikiPagePersistence;
2015 @BeanReference(type = WikiPageResourcePersistence.class)
2016 protected WikiPageResourcePersistence wikiPageResourcePersistence;
2017 protected ContainsAssetCategory containsAssetCategory;
2018 protected AddAssetCategory addAssetCategory;
2019 protected ClearAssetCategories clearAssetCategories;
2020 protected RemoveAssetCategory removeAssetCategory;
2021 protected ContainsAssetTag containsAssetTag;
2022 protected AddAssetTag addAssetTag;
2023 protected ClearAssetTags clearAssetTags;
2024 protected RemoveAssetTag removeAssetTag;
2025
2026 protected class ContainsAssetCategory {
2027 protected ContainsAssetCategory(
2028 AssetEntryPersistenceImpl persistenceImpl) {
2029 super();
2030
2031 _mappingSqlQuery = MappingSqlQueryFactoryUtil.getMappingSqlQuery(getDataSource(),
2032 _SQL_CONTAINSASSETCATEGORY,
2033 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT },
2034 RowMapper.COUNT);
2035 }
2036
2037 protected boolean contains(long entryId, long categoryId) {
2038 List<Integer> results = _mappingSqlQuery.execute(new Object[] {
2039 new Long(entryId), new Long(categoryId)
2040 });
2041
2042 if (results.size() > 0) {
2043 Integer count = results.get(0);
2044
2045 if (count.intValue() > 0) {
2046 return true;
2047 }
2048 }
2049
2050 return false;
2051 }
2052
2053 private MappingSqlQuery<Integer> _mappingSqlQuery;
2054 }
2055
2056 protected class AddAssetCategory {
2057 protected AddAssetCategory(AssetEntryPersistenceImpl persistenceImpl) {
2058 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
2059 "INSERT INTO AssetEntries_AssetCategories (entryId, categoryId) VALUES (?, ?)",
2060 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
2061 _persistenceImpl = persistenceImpl;
2062 }
2063
2064 protected void add(long entryId, long categoryId)
2065 throws SystemException {
2066 if (!_persistenceImpl.containsAssetCategory.contains(entryId,
2067 categoryId)) {
2068 ModelListener<com.liferay.portlet.asset.model.AssetCategory>[] assetCategoryListeners =
2069 assetCategoryPersistence.getListeners();
2070
2071 for (ModelListener<AssetEntry> listener : listeners) {
2072 listener.onBeforeAddAssociation(entryId,
2073 com.liferay.portlet.asset.model.AssetCategory.class.getName(),
2074 categoryId);
2075 }
2076
2077 for (ModelListener<com.liferay.portlet.asset.model.AssetCategory> listener : assetCategoryListeners) {
2078 listener.onBeforeAddAssociation(categoryId,
2079 AssetEntry.class.getName(), entryId);
2080 }
2081
2082 _sqlUpdate.update(new Object[] {
2083 new Long(entryId), new Long(categoryId)
2084 });
2085
2086 for (ModelListener<AssetEntry> listener : listeners) {
2087 listener.onAfterAddAssociation(entryId,
2088 com.liferay.portlet.asset.model.AssetCategory.class.getName(),
2089 categoryId);
2090 }
2091
2092 for (ModelListener<com.liferay.portlet.asset.model.AssetCategory> listener : assetCategoryListeners) {
2093 listener.onAfterAddAssociation(categoryId,
2094 AssetEntry.class.getName(), entryId);
2095 }
2096 }
2097 }
2098
2099 private SqlUpdate _sqlUpdate;
2100 private AssetEntryPersistenceImpl _persistenceImpl;
2101 }
2102
2103 protected class ClearAssetCategories {
2104 protected ClearAssetCategories(
2105 AssetEntryPersistenceImpl persistenceImpl) {
2106 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
2107 "DELETE FROM AssetEntries_AssetCategories WHERE entryId = ?",
2108 new int[] { java.sql.Types.BIGINT });
2109 }
2110
2111 protected void clear(long entryId) throws SystemException {
2112 ModelListener<com.liferay.portlet.asset.model.AssetCategory>[] assetCategoryListeners =
2113 assetCategoryPersistence.getListeners();
2114
2115 List<com.liferay.portlet.asset.model.AssetCategory> assetCategories = null;
2116
2117 if ((listeners.length > 0) || (assetCategoryListeners.length > 0)) {
2118 assetCategories = getAssetCategories(entryId);
2119
2120 for (com.liferay.portlet.asset.model.AssetCategory assetCategory : assetCategories) {
2121 for (ModelListener<AssetEntry> listener : listeners) {
2122 listener.onBeforeRemoveAssociation(entryId,
2123 com.liferay.portlet.asset.model.AssetCategory.class.getName(),
2124 assetCategory.getPrimaryKey());
2125 }
2126
2127 for (ModelListener<com.liferay.portlet.asset.model.AssetCategory> listener : assetCategoryListeners) {
2128 listener.onBeforeRemoveAssociation(assetCategory.getPrimaryKey(),
2129 AssetEntry.class.getName(), entryId);
2130 }
2131 }
2132 }
2133
2134 _sqlUpdate.update(new Object[] { new Long(entryId) });
2135
2136 if ((listeners.length > 0) || (assetCategoryListeners.length > 0)) {
2137 for (com.liferay.portlet.asset.model.AssetCategory assetCategory : assetCategories) {
2138 for (ModelListener<AssetEntry> listener : listeners) {
2139 listener.onAfterRemoveAssociation(entryId,
2140 com.liferay.portlet.asset.model.AssetCategory.class.getName(),
2141 assetCategory.getPrimaryKey());
2142 }
2143
2144 for (ModelListener<com.liferay.portlet.asset.model.AssetCategory> listener : assetCategoryListeners) {
2145 listener.onAfterRemoveAssociation(assetCategory.getPrimaryKey(),
2146 AssetEntry.class.getName(), entryId);
2147 }
2148 }
2149 }
2150 }
2151
2152 private SqlUpdate _sqlUpdate;
2153 }
2154
2155 protected class RemoveAssetCategory {
2156 protected RemoveAssetCategory(AssetEntryPersistenceImpl persistenceImpl) {
2157 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
2158 "DELETE FROM AssetEntries_AssetCategories WHERE entryId = ? AND categoryId = ?",
2159 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
2160 _persistenceImpl = persistenceImpl;
2161 }
2162
2163 protected void remove(long entryId, long categoryId)
2164 throws SystemException {
2165 if (_persistenceImpl.containsAssetCategory.contains(entryId,
2166 categoryId)) {
2167 ModelListener<com.liferay.portlet.asset.model.AssetCategory>[] assetCategoryListeners =
2168 assetCategoryPersistence.getListeners();
2169
2170 for (ModelListener<AssetEntry> listener : listeners) {
2171 listener.onBeforeRemoveAssociation(entryId,
2172 com.liferay.portlet.asset.model.AssetCategory.class.getName(),
2173 categoryId);
2174 }
2175
2176 for (ModelListener<com.liferay.portlet.asset.model.AssetCategory> listener : assetCategoryListeners) {
2177 listener.onBeforeRemoveAssociation(categoryId,
2178 AssetEntry.class.getName(), entryId);
2179 }
2180
2181 _sqlUpdate.update(new Object[] {
2182 new Long(entryId), new Long(categoryId)
2183 });
2184
2185 for (ModelListener<AssetEntry> listener : listeners) {
2186 listener.onAfterRemoveAssociation(entryId,
2187 com.liferay.portlet.asset.model.AssetCategory.class.getName(),
2188 categoryId);
2189 }
2190
2191 for (ModelListener<com.liferay.portlet.asset.model.AssetCategory> listener : assetCategoryListeners) {
2192 listener.onAfterRemoveAssociation(categoryId,
2193 AssetEntry.class.getName(), entryId);
2194 }
2195 }
2196 }
2197
2198 private SqlUpdate _sqlUpdate;
2199 private AssetEntryPersistenceImpl _persistenceImpl;
2200 }
2201
2202 protected class ContainsAssetTag {
2203 protected ContainsAssetTag(AssetEntryPersistenceImpl persistenceImpl) {
2204 super();
2205
2206 _mappingSqlQuery = MappingSqlQueryFactoryUtil.getMappingSqlQuery(getDataSource(),
2207 _SQL_CONTAINSASSETTAG,
2208 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT },
2209 RowMapper.COUNT);
2210 }
2211
2212 protected boolean contains(long entryId, long tagId) {
2213 List<Integer> results = _mappingSqlQuery.execute(new Object[] {
2214 new Long(entryId), new Long(tagId)
2215 });
2216
2217 if (results.size() > 0) {
2218 Integer count = results.get(0);
2219
2220 if (count.intValue() > 0) {
2221 return true;
2222 }
2223 }
2224
2225 return false;
2226 }
2227
2228 private MappingSqlQuery<Integer> _mappingSqlQuery;
2229 }
2230
2231 protected class AddAssetTag {
2232 protected AddAssetTag(AssetEntryPersistenceImpl persistenceImpl) {
2233 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
2234 "INSERT INTO AssetEntries_AssetTags (entryId, tagId) VALUES (?, ?)",
2235 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
2236 _persistenceImpl = persistenceImpl;
2237 }
2238
2239 protected void add(long entryId, long tagId) throws SystemException {
2240 if (!_persistenceImpl.containsAssetTag.contains(entryId, tagId)) {
2241 ModelListener<com.liferay.portlet.asset.model.AssetTag>[] assetTagListeners =
2242 assetTagPersistence.getListeners();
2243
2244 for (ModelListener<AssetEntry> listener : listeners) {
2245 listener.onBeforeAddAssociation(entryId,
2246 com.liferay.portlet.asset.model.AssetTag.class.getName(),
2247 tagId);
2248 }
2249
2250 for (ModelListener<com.liferay.portlet.asset.model.AssetTag> listener : assetTagListeners) {
2251 listener.onBeforeAddAssociation(tagId,
2252 AssetEntry.class.getName(), entryId);
2253 }
2254
2255 _sqlUpdate.update(new Object[] {
2256 new Long(entryId), new Long(tagId)
2257 });
2258
2259 for (ModelListener<AssetEntry> listener : listeners) {
2260 listener.onAfterAddAssociation(entryId,
2261 com.liferay.portlet.asset.model.AssetTag.class.getName(),
2262 tagId);
2263 }
2264
2265 for (ModelListener<com.liferay.portlet.asset.model.AssetTag> listener : assetTagListeners) {
2266 listener.onAfterAddAssociation(tagId,
2267 AssetEntry.class.getName(), entryId);
2268 }
2269 }
2270 }
2271
2272 private SqlUpdate _sqlUpdate;
2273 private AssetEntryPersistenceImpl _persistenceImpl;
2274 }
2275
2276 protected class ClearAssetTags {
2277 protected ClearAssetTags(AssetEntryPersistenceImpl persistenceImpl) {
2278 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
2279 "DELETE FROM AssetEntries_AssetTags WHERE entryId = ?",
2280 new int[] { java.sql.Types.BIGINT });
2281 }
2282
2283 protected void clear(long entryId) throws SystemException {
2284 ModelListener<com.liferay.portlet.asset.model.AssetTag>[] assetTagListeners =
2285 assetTagPersistence.getListeners();
2286
2287 List<com.liferay.portlet.asset.model.AssetTag> assetTags = null;
2288
2289 if ((listeners.length > 0) || (assetTagListeners.length > 0)) {
2290 assetTags = getAssetTags(entryId);
2291
2292 for (com.liferay.portlet.asset.model.AssetTag assetTag : assetTags) {
2293 for (ModelListener<AssetEntry> listener : listeners) {
2294 listener.onBeforeRemoveAssociation(entryId,
2295 com.liferay.portlet.asset.model.AssetTag.class.getName(),
2296 assetTag.getPrimaryKey());
2297 }
2298
2299 for (ModelListener<com.liferay.portlet.asset.model.AssetTag> listener : assetTagListeners) {
2300 listener.onBeforeRemoveAssociation(assetTag.getPrimaryKey(),
2301 AssetEntry.class.getName(), entryId);
2302 }
2303 }
2304 }
2305
2306 _sqlUpdate.update(new Object[] { new Long(entryId) });
2307
2308 if ((listeners.length > 0) || (assetTagListeners.length > 0)) {
2309 for (com.liferay.portlet.asset.model.AssetTag assetTag : assetTags) {
2310 for (ModelListener<AssetEntry> listener : listeners) {
2311 listener.onAfterRemoveAssociation(entryId,
2312 com.liferay.portlet.asset.model.AssetTag.class.getName(),
2313 assetTag.getPrimaryKey());
2314 }
2315
2316 for (ModelListener<com.liferay.portlet.asset.model.AssetTag> listener : assetTagListeners) {
2317 listener.onAfterRemoveAssociation(assetTag.getPrimaryKey(),
2318 AssetEntry.class.getName(), entryId);
2319 }
2320 }
2321 }
2322 }
2323
2324 private SqlUpdate _sqlUpdate;
2325 }
2326
2327 protected class RemoveAssetTag {
2328 protected RemoveAssetTag(AssetEntryPersistenceImpl persistenceImpl) {
2329 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
2330 "DELETE FROM AssetEntries_AssetTags WHERE entryId = ? AND tagId = ?",
2331 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
2332 _persistenceImpl = persistenceImpl;
2333 }
2334
2335 protected void remove(long entryId, long tagId)
2336 throws SystemException {
2337 if (_persistenceImpl.containsAssetTag.contains(entryId, tagId)) {
2338 ModelListener<com.liferay.portlet.asset.model.AssetTag>[] assetTagListeners =
2339 assetTagPersistence.getListeners();
2340
2341 for (ModelListener<AssetEntry> listener : listeners) {
2342 listener.onBeforeRemoveAssociation(entryId,
2343 com.liferay.portlet.asset.model.AssetTag.class.getName(),
2344 tagId);
2345 }
2346
2347 for (ModelListener<com.liferay.portlet.asset.model.AssetTag> listener : assetTagListeners) {
2348 listener.onBeforeRemoveAssociation(tagId,
2349 AssetEntry.class.getName(), entryId);
2350 }
2351
2352 _sqlUpdate.update(new Object[] {
2353 new Long(entryId), new Long(tagId)
2354 });
2355
2356 for (ModelListener<AssetEntry> listener : listeners) {
2357 listener.onAfterRemoveAssociation(entryId,
2358 com.liferay.portlet.asset.model.AssetTag.class.getName(),
2359 tagId);
2360 }
2361
2362 for (ModelListener<com.liferay.portlet.asset.model.AssetTag> listener : assetTagListeners) {
2363 listener.onAfterRemoveAssociation(tagId,
2364 AssetEntry.class.getName(), entryId);
2365 }
2366 }
2367 }
2368
2369 private SqlUpdate _sqlUpdate;
2370 private AssetEntryPersistenceImpl _persistenceImpl;
2371 }
2372
2373 private static final String _SQL_SELECT_ASSETENTRY = "SELECT assetEntry FROM AssetEntry assetEntry";
2374 private static final String _SQL_SELECT_ASSETENTRY_WHERE = "SELECT assetEntry FROM AssetEntry assetEntry WHERE ";
2375 private static final String _SQL_COUNT_ASSETENTRY = "SELECT COUNT(assetEntry) FROM AssetEntry assetEntry";
2376 private static final String _SQL_COUNT_ASSETENTRY_WHERE = "SELECT COUNT(assetEntry) FROM AssetEntry assetEntry WHERE ";
2377 private static final String _SQL_GETASSETCATEGORIES = "SELECT {AssetCategory.*} FROM AssetCategory INNER JOIN AssetEntries_AssetCategories ON (AssetEntries_AssetCategories.categoryId = AssetCategory.categoryId) WHERE (AssetEntries_AssetCategories.entryId = ?)";
2378 private static final String _SQL_GETASSETCATEGORIESSIZE = "SELECT COUNT(*) AS COUNT_VALUE FROM AssetEntries_AssetCategories WHERE entryId = ?";
2379 private static final String _SQL_CONTAINSASSETCATEGORY = "SELECT COUNT(*) AS COUNT_VALUE FROM AssetEntries_AssetCategories WHERE entryId = ? AND categoryId = ?";
2380 private static final String _SQL_GETASSETTAGS = "SELECT {AssetTag.*} FROM AssetTag INNER JOIN AssetEntries_AssetTags ON (AssetEntries_AssetTags.tagId = AssetTag.tagId) WHERE (AssetEntries_AssetTags.entryId = ?)";
2381 private static final String _SQL_GETASSETTAGSSIZE = "SELECT COUNT(*) AS COUNT_VALUE FROM AssetEntries_AssetTags WHERE entryId = ?";
2382 private static final String _SQL_CONTAINSASSETTAG = "SELECT COUNT(*) AS COUNT_VALUE FROM AssetEntries_AssetTags WHERE entryId = ? AND tagId = ?";
2383 private static final String _FINDER_COLUMN_COMPANYID_COMPANYID_2 = "assetEntry.companyId = ?";
2384 private static final String _FINDER_COLUMN_G_CU_GROUPID_2 = "assetEntry.groupId = ? AND ";
2385 private static final String _FINDER_COLUMN_G_CU_CLASSUUID_1 = "assetEntry.classUuid IS NULL";
2386 private static final String _FINDER_COLUMN_G_CU_CLASSUUID_2 = "assetEntry.classUuid = ?";
2387 private static final String _FINDER_COLUMN_G_CU_CLASSUUID_3 = "(assetEntry.classUuid IS NULL OR assetEntry.classUuid = ?)";
2388 private static final String _FINDER_COLUMN_C_C_CLASSNAMEID_2 = "assetEntry.classNameId = ? AND ";
2389 private static final String _FINDER_COLUMN_C_C_CLASSPK_2 = "assetEntry.classPK = ?";
2390 private static final String _ORDER_BY_ENTITY_ALIAS = "assetEntry.";
2391 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No AssetEntry exists with the primary key ";
2392 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No AssetEntry exists with the key {";
2393 private static Log _log = LogFactoryUtil.getLog(AssetEntryPersistenceImpl.class);
2394 }