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
090 public class AssetEntryPersistenceImpl extends BasePersistenceImpl<AssetEntry>
091 implements AssetEntryPersistence {
092 public static final String FINDER_CLASS_NAME_ENTITY = AssetEntryImpl.class.getName();
093 public static final String FINDER_CLASS_NAME_LIST = FINDER_CLASS_NAME_ENTITY +
094 ".List";
095 public static final FinderPath FINDER_PATH_FIND_BY_COMPANYID = new FinderPath(AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
096 AssetEntryModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
097 "findByCompanyId",
098 new String[] {
099 Long.class.getName(),
100
101 "java.lang.Integer", "java.lang.Integer",
102 "com.liferay.portal.kernel.util.OrderByComparator"
103 });
104 public static final FinderPath FINDER_PATH_COUNT_BY_COMPANYID = new FinderPath(AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
105 AssetEntryModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
106 "countByCompanyId", new String[] { Long.class.getName() });
107 public static final FinderPath FINDER_PATH_FETCH_BY_G_CU = new FinderPath(AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
108 AssetEntryModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_ENTITY,
109 "fetchByG_CU",
110 new String[] { Long.class.getName(), String.class.getName() });
111 public static final FinderPath FINDER_PATH_COUNT_BY_G_CU = new FinderPath(AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
112 AssetEntryModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
113 "countByG_CU",
114 new String[] { Long.class.getName(), String.class.getName() });
115 public static final FinderPath FINDER_PATH_FETCH_BY_C_C = new FinderPath(AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
116 AssetEntryModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_ENTITY,
117 "fetchByC_C",
118 new String[] { Long.class.getName(), Long.class.getName() });
119 public static final FinderPath FINDER_PATH_COUNT_BY_C_C = new FinderPath(AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
120 AssetEntryModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
121 "countByC_C",
122 new String[] { Long.class.getName(), Long.class.getName() });
123 public static final FinderPath FINDER_PATH_FIND_ALL = new FinderPath(AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
124 AssetEntryModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
125 "findAll", new String[0]);
126 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
127 AssetEntryModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
128 "countAll", new String[0]);
129
130
135 public void cacheResult(AssetEntry assetEntry) {
136 EntityCacheUtil.putResult(AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
137 AssetEntryImpl.class, assetEntry.getPrimaryKey(), assetEntry);
138
139 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_CU,
140 new Object[] {
141 new Long(assetEntry.getGroupId()),
142
143 assetEntry.getClassUuid()
144 }, assetEntry);
145
146 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C,
147 new Object[] {
148 new Long(assetEntry.getClassNameId()),
149 new Long(assetEntry.getClassPK())
150 }, assetEntry);
151 }
152
153
158 public void cacheResult(List<AssetEntry> assetEntries) {
159 for (AssetEntry assetEntry : assetEntries) {
160 if (EntityCacheUtil.getResult(
161 AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
162 AssetEntryImpl.class, assetEntry.getPrimaryKey(), this) == null) {
163 cacheResult(assetEntry);
164 }
165 }
166 }
167
168
175 public void clearCache() {
176 CacheRegistryUtil.clear(AssetEntryImpl.class.getName());
177 EntityCacheUtil.clearCache(AssetEntryImpl.class.getName());
178 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
179 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
180 }
181
182
189 public void clearCache(AssetEntry assetEntry) {
190 EntityCacheUtil.removeResult(AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
191 AssetEntryImpl.class, assetEntry.getPrimaryKey());
192
193 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_CU,
194 new Object[] {
195 new Long(assetEntry.getGroupId()),
196
197 assetEntry.getClassUuid()
198 });
199
200 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_C,
201 new Object[] {
202 new Long(assetEntry.getClassNameId()),
203 new Long(assetEntry.getClassPK())
204 });
205 }
206
207
213 public AssetEntry create(long entryId) {
214 AssetEntry assetEntry = new AssetEntryImpl();
215
216 assetEntry.setNew(true);
217 assetEntry.setPrimaryKey(entryId);
218
219 return assetEntry;
220 }
221
222
230 public AssetEntry remove(Serializable primaryKey)
231 throws NoSuchModelException, SystemException {
232 return remove(((Long)primaryKey).longValue());
233 }
234
235
243 public AssetEntry remove(long entryId)
244 throws NoSuchEntryException, SystemException {
245 Session session = null;
246
247 try {
248 session = openSession();
249
250 AssetEntry assetEntry = (AssetEntry)session.get(AssetEntryImpl.class,
251 new Long(entryId));
252
253 if (assetEntry == null) {
254 if (_log.isWarnEnabled()) {
255 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + entryId);
256 }
257
258 throw new NoSuchEntryException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
259 entryId);
260 }
261
262 return remove(assetEntry);
263 }
264 catch (NoSuchEntryException nsee) {
265 throw nsee;
266 }
267 catch (Exception e) {
268 throw processException(e);
269 }
270 finally {
271 closeSession(session);
272 }
273 }
274
275 protected AssetEntry removeImpl(AssetEntry assetEntry)
276 throws SystemException {
277 assetEntry = toUnwrappedModel(assetEntry);
278
279 try {
280 clearAssetCategories.clear(assetEntry.getPrimaryKey());
281 }
282 catch (Exception e) {
283 throw processException(e);
284 }
285 finally {
286 FinderCacheUtil.clearCache(AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
287 }
288
289 try {
290 clearAssetTags.clear(assetEntry.getPrimaryKey());
291 }
292 catch (Exception e) {
293 throw processException(e);
294 }
295 finally {
296 FinderCacheUtil.clearCache(AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETTAGS_NAME);
297 }
298
299 Session session = null;
300
301 try {
302 session = openSession();
303
304 if (assetEntry.isCachedModel() || BatchSessionUtil.isEnabled()) {
305 Object staleObject = session.get(AssetEntryImpl.class,
306 assetEntry.getPrimaryKeyObj());
307
308 if (staleObject != null) {
309 session.evict(staleObject);
310 }
311 }
312
313 session.delete(assetEntry);
314
315 session.flush();
316 }
317 catch (Exception e) {
318 throw processException(e);
319 }
320 finally {
321 closeSession(session);
322 }
323
324 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
325
326 AssetEntryModelImpl assetEntryModelImpl = (AssetEntryModelImpl)assetEntry;
327
328 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_CU,
329 new Object[] {
330 new Long(assetEntryModelImpl.getOriginalGroupId()),
331
332 assetEntryModelImpl.getOriginalClassUuid()
333 });
334
335 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_C,
336 new Object[] {
337 new Long(assetEntryModelImpl.getOriginalClassNameId()),
338 new Long(assetEntryModelImpl.getOriginalClassPK())
339 });
340
341 EntityCacheUtil.removeResult(AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
342 AssetEntryImpl.class, assetEntry.getPrimaryKey());
343
344 return assetEntry;
345 }
346
347 public AssetEntry updateImpl(
348 com.liferay.portlet.asset.model.AssetEntry assetEntry, boolean merge)
349 throws SystemException {
350 assetEntry = toUnwrappedModel(assetEntry);
351
352 boolean isNew = assetEntry.isNew();
353
354 AssetEntryModelImpl assetEntryModelImpl = (AssetEntryModelImpl)assetEntry;
355
356 Session session = null;
357
358 try {
359 session = openSession();
360
361 BatchSessionUtil.update(session, assetEntry, merge);
362
363 assetEntry.setNew(false);
364 }
365 catch (Exception e) {
366 throw processException(e);
367 }
368 finally {
369 closeSession(session);
370 }
371
372 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
373
374 EntityCacheUtil.putResult(AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
375 AssetEntryImpl.class, assetEntry.getPrimaryKey(), assetEntry);
376
377 if (!isNew &&
378 ((assetEntry.getGroupId() != assetEntryModelImpl.getOriginalGroupId()) ||
379 !Validator.equals(assetEntry.getClassUuid(),
380 assetEntryModelImpl.getOriginalClassUuid()))) {
381 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_CU,
382 new Object[] {
383 new Long(assetEntryModelImpl.getOriginalGroupId()),
384
385 assetEntryModelImpl.getOriginalClassUuid()
386 });
387 }
388
389 if (isNew ||
390 ((assetEntry.getGroupId() != assetEntryModelImpl.getOriginalGroupId()) ||
391 !Validator.equals(assetEntry.getClassUuid(),
392 assetEntryModelImpl.getOriginalClassUuid()))) {
393 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_CU,
394 new Object[] {
395 new Long(assetEntry.getGroupId()),
396
397 assetEntry.getClassUuid()
398 }, assetEntry);
399 }
400
401 if (!isNew &&
402 ((assetEntry.getClassNameId() != assetEntryModelImpl.getOriginalClassNameId()) ||
403 (assetEntry.getClassPK() != assetEntryModelImpl.getOriginalClassPK()))) {
404 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_C,
405 new Object[] {
406 new Long(assetEntryModelImpl.getOriginalClassNameId()),
407 new Long(assetEntryModelImpl.getOriginalClassPK())
408 });
409 }
410
411 if (isNew ||
412 ((assetEntry.getClassNameId() != assetEntryModelImpl.getOriginalClassNameId()) ||
413 (assetEntry.getClassPK() != assetEntryModelImpl.getOriginalClassPK()))) {
414 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C,
415 new Object[] {
416 new Long(assetEntry.getClassNameId()),
417 new Long(assetEntry.getClassPK())
418 }, assetEntry);
419 }
420
421 return assetEntry;
422 }
423
424 protected AssetEntry toUnwrappedModel(AssetEntry assetEntry) {
425 if (assetEntry instanceof AssetEntryImpl) {
426 return assetEntry;
427 }
428
429 AssetEntryImpl assetEntryImpl = new AssetEntryImpl();
430
431 assetEntryImpl.setNew(assetEntry.isNew());
432 assetEntryImpl.setPrimaryKey(assetEntry.getPrimaryKey());
433
434 assetEntryImpl.setEntryId(assetEntry.getEntryId());
435 assetEntryImpl.setGroupId(assetEntry.getGroupId());
436 assetEntryImpl.setCompanyId(assetEntry.getCompanyId());
437 assetEntryImpl.setUserId(assetEntry.getUserId());
438 assetEntryImpl.setUserName(assetEntry.getUserName());
439 assetEntryImpl.setCreateDate(assetEntry.getCreateDate());
440 assetEntryImpl.setModifiedDate(assetEntry.getModifiedDate());
441 assetEntryImpl.setClassNameId(assetEntry.getClassNameId());
442 assetEntryImpl.setClassPK(assetEntry.getClassPK());
443 assetEntryImpl.setClassUuid(assetEntry.getClassUuid());
444 assetEntryImpl.setVisible(assetEntry.isVisible());
445 assetEntryImpl.setStartDate(assetEntry.getStartDate());
446 assetEntryImpl.setEndDate(assetEntry.getEndDate());
447 assetEntryImpl.setPublishDate(assetEntry.getPublishDate());
448 assetEntryImpl.setExpirationDate(assetEntry.getExpirationDate());
449 assetEntryImpl.setMimeType(assetEntry.getMimeType());
450 assetEntryImpl.setTitle(assetEntry.getTitle());
451 assetEntryImpl.setDescription(assetEntry.getDescription());
452 assetEntryImpl.setSummary(assetEntry.getSummary());
453 assetEntryImpl.setUrl(assetEntry.getUrl());
454 assetEntryImpl.setHeight(assetEntry.getHeight());
455 assetEntryImpl.setWidth(assetEntry.getWidth());
456 assetEntryImpl.setPriority(assetEntry.getPriority());
457 assetEntryImpl.setViewCount(assetEntry.getViewCount());
458
459 return assetEntryImpl;
460 }
461
462
470 public AssetEntry findByPrimaryKey(Serializable primaryKey)
471 throws NoSuchModelException, SystemException {
472 return findByPrimaryKey(((Long)primaryKey).longValue());
473 }
474
475
483 public AssetEntry findByPrimaryKey(long entryId)
484 throws NoSuchEntryException, SystemException {
485 AssetEntry assetEntry = fetchByPrimaryKey(entryId);
486
487 if (assetEntry == null) {
488 if (_log.isWarnEnabled()) {
489 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + entryId);
490 }
491
492 throw new NoSuchEntryException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
493 entryId);
494 }
495
496 return assetEntry;
497 }
498
499
506 public AssetEntry fetchByPrimaryKey(Serializable primaryKey)
507 throws SystemException {
508 return fetchByPrimaryKey(((Long)primaryKey).longValue());
509 }
510
511
518 public AssetEntry fetchByPrimaryKey(long entryId) throws SystemException {
519 AssetEntry assetEntry = (AssetEntry)EntityCacheUtil.getResult(AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
520 AssetEntryImpl.class, entryId, this);
521
522 if (assetEntry == null) {
523 Session session = null;
524
525 try {
526 session = openSession();
527
528 assetEntry = (AssetEntry)session.get(AssetEntryImpl.class,
529 new Long(entryId));
530 }
531 catch (Exception e) {
532 throw processException(e);
533 }
534 finally {
535 if (assetEntry != null) {
536 cacheResult(assetEntry);
537 }
538
539 closeSession(session);
540 }
541 }
542
543 return assetEntry;
544 }
545
546
553 public List<AssetEntry> findByCompanyId(long companyId)
554 throws SystemException {
555 return findByCompanyId(companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
556 null);
557 }
558
559
572 public List<AssetEntry> findByCompanyId(long companyId, int start, int end)
573 throws SystemException {
574 return findByCompanyId(companyId, start, end, null);
575 }
576
577
591 public List<AssetEntry> findByCompanyId(long companyId, int start, int end,
592 OrderByComparator orderByComparator) throws SystemException {
593 Object[] finderArgs = new Object[] {
594 companyId,
595
596 String.valueOf(start), String.valueOf(end),
597 String.valueOf(orderByComparator)
598 };
599
600 List<AssetEntry> list = (List<AssetEntry>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_COMPANYID,
601 finderArgs, this);
602
603 if (list == null) {
604 Session session = null;
605
606 try {
607 session = openSession();
608
609 StringBundler query = null;
610
611 if (orderByComparator != null) {
612 query = new StringBundler(3 +
613 (orderByComparator.getOrderByFields().length * 3));
614 }
615 else {
616 query = new StringBundler(2);
617 }
618
619 query.append(_SQL_SELECT_ASSETENTRY_WHERE);
620
621 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
622
623 if (orderByComparator != null) {
624 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
625 orderByComparator);
626 }
627
628 String sql = query.toString();
629
630 Query q = session.createQuery(sql);
631
632 QueryPos qPos = QueryPos.getInstance(q);
633
634 qPos.add(companyId);
635
636 list = (List<AssetEntry>)QueryUtil.list(q, getDialect(), start,
637 end);
638 }
639 catch (Exception e) {
640 throw processException(e);
641 }
642 finally {
643 if (list == null) {
644 list = new ArrayList<AssetEntry>();
645 }
646
647 cacheResult(list);
648
649 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_COMPANYID,
650 finderArgs, list);
651
652 closeSession(session);
653 }
654 }
655
656 return list;
657 }
658
659
672 public AssetEntry findByCompanyId_First(long companyId,
673 OrderByComparator orderByComparator)
674 throws NoSuchEntryException, SystemException {
675 List<AssetEntry> list = findByCompanyId(companyId, 0, 1,
676 orderByComparator);
677
678 if (list.isEmpty()) {
679 StringBundler msg = new StringBundler(4);
680
681 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
682
683 msg.append("companyId=");
684 msg.append(companyId);
685
686 msg.append(StringPool.CLOSE_CURLY_BRACE);
687
688 throw new NoSuchEntryException(msg.toString());
689 }
690 else {
691 return list.get(0);
692 }
693 }
694
695
708 public AssetEntry findByCompanyId_Last(long companyId,
709 OrderByComparator orderByComparator)
710 throws NoSuchEntryException, SystemException {
711 int count = countByCompanyId(companyId);
712
713 List<AssetEntry> list = findByCompanyId(companyId, count - 1, count,
714 orderByComparator);
715
716 if (list.isEmpty()) {
717 StringBundler msg = new StringBundler(4);
718
719 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
720
721 msg.append("companyId=");
722 msg.append(companyId);
723
724 msg.append(StringPool.CLOSE_CURLY_BRACE);
725
726 throw new NoSuchEntryException(msg.toString());
727 }
728 else {
729 return list.get(0);
730 }
731 }
732
733
747 public AssetEntry[] findByCompanyId_PrevAndNext(long entryId,
748 long companyId, OrderByComparator orderByComparator)
749 throws NoSuchEntryException, SystemException {
750 AssetEntry assetEntry = findByPrimaryKey(entryId);
751
752 Session session = null;
753
754 try {
755 session = openSession();
756
757 AssetEntry[] array = new AssetEntryImpl[3];
758
759 array[0] = getByCompanyId_PrevAndNext(session, assetEntry,
760 companyId, orderByComparator, true);
761
762 array[1] = assetEntry;
763
764 array[2] = getByCompanyId_PrevAndNext(session, assetEntry,
765 companyId, orderByComparator, false);
766
767 return array;
768 }
769 catch (Exception e) {
770 throw processException(e);
771 }
772 finally {
773 closeSession(session);
774 }
775 }
776
777 protected AssetEntry getByCompanyId_PrevAndNext(Session session,
778 AssetEntry assetEntry, long companyId,
779 OrderByComparator orderByComparator, boolean previous) {
780 StringBundler query = null;
781
782 if (orderByComparator != null) {
783 query = new StringBundler(6 +
784 (orderByComparator.getOrderByFields().length * 6));
785 }
786 else {
787 query = new StringBundler(3);
788 }
789
790 query.append(_SQL_SELECT_ASSETENTRY_WHERE);
791
792 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
793
794 if (orderByComparator != null) {
795 String[] orderByFields = orderByComparator.getOrderByFields();
796
797 if (orderByFields.length > 0) {
798 query.append(WHERE_AND);
799 }
800
801 for (int i = 0; i < orderByFields.length; i++) {
802 query.append(_ORDER_BY_ENTITY_ALIAS);
803 query.append(orderByFields[i]);
804
805 if ((i + 1) < orderByFields.length) {
806 if (orderByComparator.isAscending() ^ previous) {
807 query.append(WHERE_GREATER_THAN_HAS_NEXT);
808 }
809 else {
810 query.append(WHERE_LESSER_THAN_HAS_NEXT);
811 }
812 }
813 else {
814 if (orderByComparator.isAscending() ^ previous) {
815 query.append(WHERE_GREATER_THAN);
816 }
817 else {
818 query.append(WHERE_LESSER_THAN);
819 }
820 }
821 }
822
823 query.append(ORDER_BY_CLAUSE);
824
825 for (int i = 0; i < orderByFields.length; i++) {
826 query.append(_ORDER_BY_ENTITY_ALIAS);
827 query.append(orderByFields[i]);
828
829 if ((i + 1) < orderByFields.length) {
830 if (orderByComparator.isAscending() ^ previous) {
831 query.append(ORDER_BY_ASC_HAS_NEXT);
832 }
833 else {
834 query.append(ORDER_BY_DESC_HAS_NEXT);
835 }
836 }
837 else {
838 if (orderByComparator.isAscending() ^ previous) {
839 query.append(ORDER_BY_ASC);
840 }
841 else {
842 query.append(ORDER_BY_DESC);
843 }
844 }
845 }
846 }
847
848 String sql = query.toString();
849
850 Query q = session.createQuery(sql);
851
852 q.setFirstResult(0);
853 q.setMaxResults(2);
854
855 QueryPos qPos = QueryPos.getInstance(q);
856
857 qPos.add(companyId);
858
859 if (orderByComparator != null) {
860 Object[] values = orderByComparator.getOrderByValues(assetEntry);
861
862 for (Object value : values) {
863 qPos.add(value);
864 }
865 }
866
867 List<AssetEntry> list = q.list();
868
869 if (list.size() == 2) {
870 return list.get(1);
871 }
872 else {
873 return null;
874 }
875 }
876
877
886 public AssetEntry findByG_CU(long groupId, String classUuid)
887 throws NoSuchEntryException, SystemException {
888 AssetEntry assetEntry = fetchByG_CU(groupId, classUuid);
889
890 if (assetEntry == null) {
891 StringBundler msg = new StringBundler(6);
892
893 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
894
895 msg.append("groupId=");
896 msg.append(groupId);
897
898 msg.append(", classUuid=");
899 msg.append(classUuid);
900
901 msg.append(StringPool.CLOSE_CURLY_BRACE);
902
903 if (_log.isWarnEnabled()) {
904 _log.warn(msg.toString());
905 }
906
907 throw new NoSuchEntryException(msg.toString());
908 }
909
910 return assetEntry;
911 }
912
913
921 public AssetEntry fetchByG_CU(long groupId, String classUuid)
922 throws SystemException {
923 return fetchByG_CU(groupId, classUuid, true);
924 }
925
926
934 public AssetEntry fetchByG_CU(long groupId, String classUuid,
935 boolean retrieveFromCache) throws SystemException {
936 Object[] finderArgs = new Object[] { groupId, classUuid };
937
938 Object result = null;
939
940 if (retrieveFromCache) {
941 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_G_CU,
942 finderArgs, this);
943 }
944
945 if (result == null) {
946 Session session = null;
947
948 try {
949 session = openSession();
950
951 StringBundler query = new StringBundler(3);
952
953 query.append(_SQL_SELECT_ASSETENTRY_WHERE);
954
955 query.append(_FINDER_COLUMN_G_CU_GROUPID_2);
956
957 if (classUuid == null) {
958 query.append(_FINDER_COLUMN_G_CU_CLASSUUID_1);
959 }
960 else {
961 if (classUuid.equals(StringPool.BLANK)) {
962 query.append(_FINDER_COLUMN_G_CU_CLASSUUID_3);
963 }
964 else {
965 query.append(_FINDER_COLUMN_G_CU_CLASSUUID_2);
966 }
967 }
968
969 String sql = query.toString();
970
971 Query q = session.createQuery(sql);
972
973 QueryPos qPos = QueryPos.getInstance(q);
974
975 qPos.add(groupId);
976
977 if (classUuid != null) {
978 qPos.add(classUuid);
979 }
980
981 List<AssetEntry> list = q.list();
982
983 result = list;
984
985 AssetEntry assetEntry = null;
986
987 if (list.isEmpty()) {
988 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_CU,
989 finderArgs, list);
990 }
991 else {
992 assetEntry = list.get(0);
993
994 cacheResult(assetEntry);
995
996 if ((assetEntry.getGroupId() != groupId) ||
997 (assetEntry.getClassUuid() == null) ||
998 !assetEntry.getClassUuid().equals(classUuid)) {
999 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_CU,
1000 finderArgs, assetEntry);
1001 }
1002 }
1003
1004 return assetEntry;
1005 }
1006 catch (Exception e) {
1007 throw processException(e);
1008 }
1009 finally {
1010 if (result == null) {
1011 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_CU,
1012 finderArgs, new ArrayList<AssetEntry>());
1013 }
1014
1015 closeSession(session);
1016 }
1017 }
1018 else {
1019 if (result instanceof List<?>) {
1020 return null;
1021 }
1022 else {
1023 return (AssetEntry)result;
1024 }
1025 }
1026 }
1027
1028
1037 public AssetEntry findByC_C(long classNameId, long classPK)
1038 throws NoSuchEntryException, SystemException {
1039 AssetEntry assetEntry = fetchByC_C(classNameId, classPK);
1040
1041 if (assetEntry == null) {
1042 StringBundler msg = new StringBundler(6);
1043
1044 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1045
1046 msg.append("classNameId=");
1047 msg.append(classNameId);
1048
1049 msg.append(", classPK=");
1050 msg.append(classPK);
1051
1052 msg.append(StringPool.CLOSE_CURLY_BRACE);
1053
1054 if (_log.isWarnEnabled()) {
1055 _log.warn(msg.toString());
1056 }
1057
1058 throw new NoSuchEntryException(msg.toString());
1059 }
1060
1061 return assetEntry;
1062 }
1063
1064
1072 public AssetEntry fetchByC_C(long classNameId, long classPK)
1073 throws SystemException {
1074 return fetchByC_C(classNameId, classPK, true);
1075 }
1076
1077
1085 public AssetEntry fetchByC_C(long classNameId, long classPK,
1086 boolean retrieveFromCache) throws SystemException {
1087 Object[] finderArgs = new Object[] { classNameId, classPK };
1088
1089 Object result = null;
1090
1091 if (retrieveFromCache) {
1092 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_C_C,
1093 finderArgs, this);
1094 }
1095
1096 if (result == null) {
1097 Session session = null;
1098
1099 try {
1100 session = openSession();
1101
1102 StringBundler query = new StringBundler(3);
1103
1104 query.append(_SQL_SELECT_ASSETENTRY_WHERE);
1105
1106 query.append(_FINDER_COLUMN_C_C_CLASSNAMEID_2);
1107
1108 query.append(_FINDER_COLUMN_C_C_CLASSPK_2);
1109
1110 String sql = query.toString();
1111
1112 Query q = session.createQuery(sql);
1113
1114 QueryPos qPos = QueryPos.getInstance(q);
1115
1116 qPos.add(classNameId);
1117
1118 qPos.add(classPK);
1119
1120 List<AssetEntry> list = q.list();
1121
1122 result = list;
1123
1124 AssetEntry assetEntry = null;
1125
1126 if (list.isEmpty()) {
1127 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C,
1128 finderArgs, list);
1129 }
1130 else {
1131 assetEntry = list.get(0);
1132
1133 cacheResult(assetEntry);
1134
1135 if ((assetEntry.getClassNameId() != classNameId) ||
1136 (assetEntry.getClassPK() != classPK)) {
1137 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C,
1138 finderArgs, assetEntry);
1139 }
1140 }
1141
1142 return assetEntry;
1143 }
1144 catch (Exception e) {
1145 throw processException(e);
1146 }
1147 finally {
1148 if (result == null) {
1149 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C,
1150 finderArgs, new ArrayList<AssetEntry>());
1151 }
1152
1153 closeSession(session);
1154 }
1155 }
1156 else {
1157 if (result instanceof List<?>) {
1158 return null;
1159 }
1160 else {
1161 return (AssetEntry)result;
1162 }
1163 }
1164 }
1165
1166
1172 public List<AssetEntry> findAll() throws SystemException {
1173 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1174 }
1175
1176
1188 public List<AssetEntry> findAll(int start, int end)
1189 throws SystemException {
1190 return findAll(start, end, null);
1191 }
1192
1193
1206 public List<AssetEntry> findAll(int start, int end,
1207 OrderByComparator orderByComparator) throws SystemException {
1208 Object[] finderArgs = new Object[] {
1209 String.valueOf(start), String.valueOf(end),
1210 String.valueOf(orderByComparator)
1211 };
1212
1213 List<AssetEntry> list = (List<AssetEntry>)FinderCacheUtil.getResult(FINDER_PATH_FIND_ALL,
1214 finderArgs, this);
1215
1216 if (list == null) {
1217 Session session = null;
1218
1219 try {
1220 session = openSession();
1221
1222 StringBundler query = null;
1223 String sql = null;
1224
1225 if (orderByComparator != null) {
1226 query = new StringBundler(2 +
1227 (orderByComparator.getOrderByFields().length * 3));
1228
1229 query.append(_SQL_SELECT_ASSETENTRY);
1230
1231 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1232 orderByComparator);
1233
1234 sql = query.toString();
1235 }
1236 else {
1237 sql = _SQL_SELECT_ASSETENTRY;
1238 }
1239
1240 Query q = session.createQuery(sql);
1241
1242 if (orderByComparator == null) {
1243 list = (List<AssetEntry>)QueryUtil.list(q, getDialect(),
1244 start, end, false);
1245
1246 Collections.sort(list);
1247 }
1248 else {
1249 list = (List<AssetEntry>)QueryUtil.list(q, getDialect(),
1250 start, end);
1251 }
1252 }
1253 catch (Exception e) {
1254 throw processException(e);
1255 }
1256 finally {
1257 if (list == null) {
1258 list = new ArrayList<AssetEntry>();
1259 }
1260
1261 cacheResult(list);
1262
1263 FinderCacheUtil.putResult(FINDER_PATH_FIND_ALL, finderArgs, list);
1264
1265 closeSession(session);
1266 }
1267 }
1268
1269 return list;
1270 }
1271
1272
1278 public void removeByCompanyId(long companyId) throws SystemException {
1279 for (AssetEntry assetEntry : findByCompanyId(companyId)) {
1280 remove(assetEntry);
1281 }
1282 }
1283
1284
1291 public void removeByG_CU(long groupId, String classUuid)
1292 throws NoSuchEntryException, SystemException {
1293 AssetEntry assetEntry = findByG_CU(groupId, classUuid);
1294
1295 remove(assetEntry);
1296 }
1297
1298
1305 public void removeByC_C(long classNameId, long classPK)
1306 throws NoSuchEntryException, SystemException {
1307 AssetEntry assetEntry = findByC_C(classNameId, classPK);
1308
1309 remove(assetEntry);
1310 }
1311
1312
1317 public void removeAll() throws SystemException {
1318 for (AssetEntry assetEntry : findAll()) {
1319 remove(assetEntry);
1320 }
1321 }
1322
1323
1330 public int countByCompanyId(long companyId) throws SystemException {
1331 Object[] finderArgs = new Object[] { companyId };
1332
1333 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_COMPANYID,
1334 finderArgs, this);
1335
1336 if (count == null) {
1337 Session session = null;
1338
1339 try {
1340 session = openSession();
1341
1342 StringBundler query = new StringBundler(2);
1343
1344 query.append(_SQL_COUNT_ASSETENTRY_WHERE);
1345
1346 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
1347
1348 String sql = query.toString();
1349
1350 Query q = session.createQuery(sql);
1351
1352 QueryPos qPos = QueryPos.getInstance(q);
1353
1354 qPos.add(companyId);
1355
1356 count = (Long)q.uniqueResult();
1357 }
1358 catch (Exception e) {
1359 throw processException(e);
1360 }
1361 finally {
1362 if (count == null) {
1363 count = Long.valueOf(0);
1364 }
1365
1366 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_COMPANYID,
1367 finderArgs, count);
1368
1369 closeSession(session);
1370 }
1371 }
1372
1373 return count.intValue();
1374 }
1375
1376
1384 public int countByG_CU(long groupId, String classUuid)
1385 throws SystemException {
1386 Object[] finderArgs = new Object[] { groupId, classUuid };
1387
1388 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_CU,
1389 finderArgs, this);
1390
1391 if (count == null) {
1392 Session session = null;
1393
1394 try {
1395 session = openSession();
1396
1397 StringBundler query = new StringBundler(3);
1398
1399 query.append(_SQL_COUNT_ASSETENTRY_WHERE);
1400
1401 query.append(_FINDER_COLUMN_G_CU_GROUPID_2);
1402
1403 if (classUuid == null) {
1404 query.append(_FINDER_COLUMN_G_CU_CLASSUUID_1);
1405 }
1406 else {
1407 if (classUuid.equals(StringPool.BLANK)) {
1408 query.append(_FINDER_COLUMN_G_CU_CLASSUUID_3);
1409 }
1410 else {
1411 query.append(_FINDER_COLUMN_G_CU_CLASSUUID_2);
1412 }
1413 }
1414
1415 String sql = query.toString();
1416
1417 Query q = session.createQuery(sql);
1418
1419 QueryPos qPos = QueryPos.getInstance(q);
1420
1421 qPos.add(groupId);
1422
1423 if (classUuid != null) {
1424 qPos.add(classUuid);
1425 }
1426
1427 count = (Long)q.uniqueResult();
1428 }
1429 catch (Exception e) {
1430 throw processException(e);
1431 }
1432 finally {
1433 if (count == null) {
1434 count = Long.valueOf(0);
1435 }
1436
1437 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_CU,
1438 finderArgs, count);
1439
1440 closeSession(session);
1441 }
1442 }
1443
1444 return count.intValue();
1445 }
1446
1447
1455 public int countByC_C(long classNameId, long classPK)
1456 throws SystemException {
1457 Object[] finderArgs = new Object[] { classNameId, classPK };
1458
1459 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_C,
1460 finderArgs, this);
1461
1462 if (count == null) {
1463 Session session = null;
1464
1465 try {
1466 session = openSession();
1467
1468 StringBundler query = new StringBundler(3);
1469
1470 query.append(_SQL_COUNT_ASSETENTRY_WHERE);
1471
1472 query.append(_FINDER_COLUMN_C_C_CLASSNAMEID_2);
1473
1474 query.append(_FINDER_COLUMN_C_C_CLASSPK_2);
1475
1476 String sql = query.toString();
1477
1478 Query q = session.createQuery(sql);
1479
1480 QueryPos qPos = QueryPos.getInstance(q);
1481
1482 qPos.add(classNameId);
1483
1484 qPos.add(classPK);
1485
1486 count = (Long)q.uniqueResult();
1487 }
1488 catch (Exception e) {
1489 throw processException(e);
1490 }
1491 finally {
1492 if (count == null) {
1493 count = Long.valueOf(0);
1494 }
1495
1496 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_C, finderArgs,
1497 count);
1498
1499 closeSession(session);
1500 }
1501 }
1502
1503 return count.intValue();
1504 }
1505
1506
1512 public int countAll() throws SystemException {
1513 Object[] finderArgs = new Object[0];
1514
1515 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
1516 finderArgs, this);
1517
1518 if (count == null) {
1519 Session session = null;
1520
1521 try {
1522 session = openSession();
1523
1524 Query q = session.createQuery(_SQL_COUNT_ASSETENTRY);
1525
1526 count = (Long)q.uniqueResult();
1527 }
1528 catch (Exception e) {
1529 throw processException(e);
1530 }
1531 finally {
1532 if (count == null) {
1533 count = Long.valueOf(0);
1534 }
1535
1536 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL, finderArgs,
1537 count);
1538
1539 closeSession(session);
1540 }
1541 }
1542
1543 return count.intValue();
1544 }
1545
1546
1553 public List<com.liferay.portlet.asset.model.AssetCategory> getAssetCategories(
1554 long pk) throws SystemException {
1555 return getAssetCategories(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
1556 }
1557
1558
1571 public List<com.liferay.portlet.asset.model.AssetCategory> getAssetCategories(
1572 long pk, int start, int end) throws SystemException {
1573 return getAssetCategories(pk, start, end, null);
1574 }
1575
1576 public static final FinderPath FINDER_PATH_GET_ASSETCATEGORIES = new FinderPath(com.liferay.portlet.asset.model.impl.AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
1577 AssetEntryModelImpl.FINDER_CACHE_ENABLED_ASSETENTRIES_ASSETCATEGORIES,
1578 AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME,
1579 "getAssetCategories",
1580 new String[] {
1581 Long.class.getName(), "java.lang.Integer", "java.lang.Integer",
1582 "com.liferay.portal.kernel.util.OrderByComparator"
1583 });
1584
1585
1599 public List<com.liferay.portlet.asset.model.AssetCategory> getAssetCategories(
1600 long pk, int start, int end, OrderByComparator orderByComparator)
1601 throws SystemException {
1602 Object[] finderArgs = new Object[] {
1603 pk, String.valueOf(start), String.valueOf(end),
1604 String.valueOf(orderByComparator)
1605 };
1606
1607 List<com.liferay.portlet.asset.model.AssetCategory> list = (List<com.liferay.portlet.asset.model.AssetCategory>)FinderCacheUtil.getResult(FINDER_PATH_GET_ASSETCATEGORIES,
1608 finderArgs, this);
1609
1610 if (list == null) {
1611 Session session = null;
1612
1613 try {
1614 session = openSession();
1615
1616 String sql = null;
1617
1618 if (orderByComparator != null) {
1619 sql = _SQL_GETASSETCATEGORIES.concat(ORDER_BY_CLAUSE)
1620 .concat(orderByComparator.getOrderBy());
1621 }
1622 else {
1623 sql = _SQL_GETASSETCATEGORIES.concat(com.liferay.portlet.asset.model.impl.AssetCategoryModelImpl.ORDER_BY_SQL);
1624 }
1625
1626 SQLQuery q = session.createSQLQuery(sql);
1627
1628 q.addEntity("AssetCategory",
1629 com.liferay.portlet.asset.model.impl.AssetCategoryImpl.class);
1630
1631 QueryPos qPos = QueryPos.getInstance(q);
1632
1633 qPos.add(pk);
1634
1635 list = (List<com.liferay.portlet.asset.model.AssetCategory>)QueryUtil.list(q,
1636 getDialect(), start, end);
1637 }
1638 catch (Exception e) {
1639 throw processException(e);
1640 }
1641 finally {
1642 if (list == null) {
1643 list = new ArrayList<com.liferay.portlet.asset.model.AssetCategory>();
1644 }
1645
1646 assetCategoryPersistence.cacheResult(list);
1647
1648 FinderCacheUtil.putResult(FINDER_PATH_GET_ASSETCATEGORIES,
1649 finderArgs, list);
1650
1651 closeSession(session);
1652 }
1653 }
1654
1655 return list;
1656 }
1657
1658 public static final FinderPath FINDER_PATH_GET_ASSETCATEGORIES_SIZE = new FinderPath(com.liferay.portlet.asset.model.impl.AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
1659 AssetEntryModelImpl.FINDER_CACHE_ENABLED_ASSETENTRIES_ASSETCATEGORIES,
1660 AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME,
1661 "getAssetCategoriesSize", new String[] { Long.class.getName() });
1662
1663
1670 public int getAssetCategoriesSize(long pk) throws SystemException {
1671 Object[] finderArgs = new Object[] { pk };
1672
1673 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_GET_ASSETCATEGORIES_SIZE,
1674 finderArgs, this);
1675
1676 if (count == null) {
1677 Session session = null;
1678
1679 try {
1680 session = openSession();
1681
1682 SQLQuery q = session.createSQLQuery(_SQL_GETASSETCATEGORIESSIZE);
1683
1684 q.addScalar(COUNT_COLUMN_NAME,
1685 com.liferay.portal.kernel.dao.orm.Type.LONG);
1686
1687 QueryPos qPos = QueryPos.getInstance(q);
1688
1689 qPos.add(pk);
1690
1691 count = (Long)q.uniqueResult();
1692 }
1693 catch (Exception e) {
1694 throw processException(e);
1695 }
1696 finally {
1697 if (count == null) {
1698 count = Long.valueOf(0);
1699 }
1700
1701 FinderCacheUtil.putResult(FINDER_PATH_GET_ASSETCATEGORIES_SIZE,
1702 finderArgs, count);
1703
1704 closeSession(session);
1705 }
1706 }
1707
1708 return count.intValue();
1709 }
1710
1711 public static final FinderPath FINDER_PATH_CONTAINS_ASSETCATEGORY = new FinderPath(com.liferay.portlet.asset.model.impl.AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
1712 AssetEntryModelImpl.FINDER_CACHE_ENABLED_ASSETENTRIES_ASSETCATEGORIES,
1713 AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME,
1714 "containsAssetCategory",
1715 new String[] { Long.class.getName(), Long.class.getName() });
1716
1717
1725 public boolean containsAssetCategory(long pk, long assetCategoryPK)
1726 throws SystemException {
1727 Object[] finderArgs = new Object[] { pk, assetCategoryPK };
1728
1729 Boolean value = (Boolean)FinderCacheUtil.getResult(FINDER_PATH_CONTAINS_ASSETCATEGORY,
1730 finderArgs, this);
1731
1732 if (value == null) {
1733 try {
1734 value = Boolean.valueOf(containsAssetCategory.contains(pk,
1735 assetCategoryPK));
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_ASSETCATEGORY,
1746 finderArgs, value);
1747 }
1748 }
1749
1750 return value.booleanValue();
1751 }
1752
1753
1760 public boolean containsAssetCategories(long pk) throws SystemException {
1761 if (getAssetCategoriesSize(pk) > 0) {
1762 return true;
1763 }
1764 else {
1765 return false;
1766 }
1767 }
1768
1769
1776 public void addAssetCategory(long pk, long assetCategoryPK)
1777 throws SystemException {
1778 try {
1779 addAssetCategory.add(pk, assetCategoryPK);
1780 }
1781 catch (Exception e) {
1782 throw processException(e);
1783 }
1784 finally {
1785 FinderCacheUtil.clearCache(AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
1786 }
1787 }
1788
1789
1796 public void addAssetCategory(long pk,
1797 com.liferay.portlet.asset.model.AssetCategory assetCategory)
1798 throws SystemException {
1799 try {
1800 addAssetCategory.add(pk, assetCategory.getPrimaryKey());
1801 }
1802 catch (Exception e) {
1803 throw processException(e);
1804 }
1805 finally {
1806 FinderCacheUtil.clearCache(AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
1807 }
1808 }
1809
1810
1817 public void addAssetCategories(long pk, long[] assetCategoryPKs)
1818 throws SystemException {
1819 try {
1820 for (long assetCategoryPK : assetCategoryPKs) {
1821 addAssetCategory.add(pk, assetCategoryPK);
1822 }
1823 }
1824 catch (Exception e) {
1825 throw processException(e);
1826 }
1827 finally {
1828 FinderCacheUtil.clearCache(AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
1829 }
1830 }
1831
1832
1839 public void addAssetCategories(long pk,
1840 List<com.liferay.portlet.asset.model.AssetCategory> assetCategories)
1841 throws SystemException {
1842 try {
1843 for (com.liferay.portlet.asset.model.AssetCategory assetCategory : assetCategories) {
1844 addAssetCategory.add(pk, assetCategory.getPrimaryKey());
1845 }
1846 }
1847 catch (Exception e) {
1848 throw processException(e);
1849 }
1850 finally {
1851 FinderCacheUtil.clearCache(AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
1852 }
1853 }
1854
1855
1861 public void clearAssetCategories(long pk) throws SystemException {
1862 try {
1863 clearAssetCategories.clear(pk);
1864 }
1865 catch (Exception e) {
1866 throw processException(e);
1867 }
1868 finally {
1869 FinderCacheUtil.clearCache(AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
1870 }
1871 }
1872
1873
1880 public void removeAssetCategory(long pk, long assetCategoryPK)
1881 throws SystemException {
1882 try {
1883 removeAssetCategory.remove(pk, assetCategoryPK);
1884 }
1885 catch (Exception e) {
1886 throw processException(e);
1887 }
1888 finally {
1889 FinderCacheUtil.clearCache(AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
1890 }
1891 }
1892
1893
1900 public void removeAssetCategory(long pk,
1901 com.liferay.portlet.asset.model.AssetCategory assetCategory)
1902 throws SystemException {
1903 try {
1904 removeAssetCategory.remove(pk, assetCategory.getPrimaryKey());
1905 }
1906 catch (Exception e) {
1907 throw processException(e);
1908 }
1909 finally {
1910 FinderCacheUtil.clearCache(AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
1911 }
1912 }
1913
1914
1921 public void removeAssetCategories(long pk, long[] assetCategoryPKs)
1922 throws SystemException {
1923 try {
1924 for (long assetCategoryPK : assetCategoryPKs) {
1925 removeAssetCategory.remove(pk, assetCategoryPK);
1926 }
1927 }
1928 catch (Exception e) {
1929 throw processException(e);
1930 }
1931 finally {
1932 FinderCacheUtil.clearCache(AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
1933 }
1934 }
1935
1936
1943 public void removeAssetCategories(long pk,
1944 List<com.liferay.portlet.asset.model.AssetCategory> assetCategories)
1945 throws SystemException {
1946 try {
1947 for (com.liferay.portlet.asset.model.AssetCategory assetCategory : assetCategories) {
1948 removeAssetCategory.remove(pk, assetCategory.getPrimaryKey());
1949 }
1950 }
1951 catch (Exception e) {
1952 throw processException(e);
1953 }
1954 finally {
1955 FinderCacheUtil.clearCache(AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
1956 }
1957 }
1958
1959
1966 public void setAssetCategories(long pk, long[] assetCategoryPKs)
1967 throws SystemException {
1968 try {
1969 Set<Long> assetCategoryPKSet = SetUtil.fromArray(assetCategoryPKs);
1970
1971 List<com.liferay.portlet.asset.model.AssetCategory> assetCategories = getAssetCategories(pk);
1972
1973 for (com.liferay.portlet.asset.model.AssetCategory assetCategory : assetCategories) {
1974 if (!assetCategoryPKSet.remove(assetCategory.getPrimaryKey())) {
1975 removeAssetCategory.remove(pk, assetCategory.getPrimaryKey());
1976 }
1977 }
1978
1979 for (Long assetCategoryPK : assetCategoryPKSet) {
1980 addAssetCategory.add(pk, assetCategoryPK);
1981 }
1982 }
1983 catch (Exception e) {
1984 throw processException(e);
1985 }
1986 finally {
1987 FinderCacheUtil.clearCache(AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
1988 }
1989 }
1990
1991
1998 public void setAssetCategories(long pk,
1999 List<com.liferay.portlet.asset.model.AssetCategory> assetCategories)
2000 throws SystemException {
2001 try {
2002 long[] assetCategoryPKs = new long[assetCategories.size()];
2003
2004 for (int i = 0; i < assetCategories.size(); i++) {
2005 com.liferay.portlet.asset.model.AssetCategory assetCategory = assetCategories.get(i);
2006
2007 assetCategoryPKs[i] = assetCategory.getPrimaryKey();
2008 }
2009
2010 setAssetCategories(pk, assetCategoryPKs);
2011 }
2012 catch (Exception e) {
2013 throw processException(e);
2014 }
2015 finally {
2016 FinderCacheUtil.clearCache(AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
2017 }
2018 }
2019
2020
2027 public List<com.liferay.portlet.asset.model.AssetTag> getAssetTags(long pk)
2028 throws SystemException {
2029 return getAssetTags(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
2030 }
2031
2032
2045 public List<com.liferay.portlet.asset.model.AssetTag> getAssetTags(
2046 long pk, int start, int end) throws SystemException {
2047 return getAssetTags(pk, start, end, null);
2048 }
2049
2050 public static final FinderPath FINDER_PATH_GET_ASSETTAGS = new FinderPath(com.liferay.portlet.asset.model.impl.AssetTagModelImpl.ENTITY_CACHE_ENABLED,
2051 AssetEntryModelImpl.FINDER_CACHE_ENABLED_ASSETENTRIES_ASSETTAGS,
2052 AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETTAGS_NAME,
2053 "getAssetTags",
2054 new String[] {
2055 Long.class.getName(), "java.lang.Integer", "java.lang.Integer",
2056 "com.liferay.portal.kernel.util.OrderByComparator"
2057 });
2058
2059
2073 public List<com.liferay.portlet.asset.model.AssetTag> getAssetTags(
2074 long pk, int start, int end, OrderByComparator orderByComparator)
2075 throws SystemException {
2076 Object[] finderArgs = new Object[] {
2077 pk, String.valueOf(start), String.valueOf(end),
2078 String.valueOf(orderByComparator)
2079 };
2080
2081 List<com.liferay.portlet.asset.model.AssetTag> list = (List<com.liferay.portlet.asset.model.AssetTag>)FinderCacheUtil.getResult(FINDER_PATH_GET_ASSETTAGS,
2082 finderArgs, this);
2083
2084 if (list == null) {
2085 Session session = null;
2086
2087 try {
2088 session = openSession();
2089
2090 String sql = null;
2091
2092 if (orderByComparator != null) {
2093 sql = _SQL_GETASSETTAGS.concat(ORDER_BY_CLAUSE)
2094 .concat(orderByComparator.getOrderBy());
2095 }
2096 else {
2097 sql = _SQL_GETASSETTAGS.concat(com.liferay.portlet.asset.model.impl.AssetTagModelImpl.ORDER_BY_SQL);
2098 }
2099
2100 SQLQuery q = session.createSQLQuery(sql);
2101
2102 q.addEntity("AssetTag",
2103 com.liferay.portlet.asset.model.impl.AssetTagImpl.class);
2104
2105 QueryPos qPos = QueryPos.getInstance(q);
2106
2107 qPos.add(pk);
2108
2109 list = (List<com.liferay.portlet.asset.model.AssetTag>)QueryUtil.list(q,
2110 getDialect(), start, end);
2111 }
2112 catch (Exception e) {
2113 throw processException(e);
2114 }
2115 finally {
2116 if (list == null) {
2117 list = new ArrayList<com.liferay.portlet.asset.model.AssetTag>();
2118 }
2119
2120 assetTagPersistence.cacheResult(list);
2121
2122 FinderCacheUtil.putResult(FINDER_PATH_GET_ASSETTAGS,
2123 finderArgs, list);
2124
2125 closeSession(session);
2126 }
2127 }
2128
2129 return list;
2130 }
2131
2132 public static final FinderPath FINDER_PATH_GET_ASSETTAGS_SIZE = new FinderPath(com.liferay.portlet.asset.model.impl.AssetTagModelImpl.ENTITY_CACHE_ENABLED,
2133 AssetEntryModelImpl.FINDER_CACHE_ENABLED_ASSETENTRIES_ASSETTAGS,
2134 AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETTAGS_NAME,
2135 "getAssetTagsSize", new String[] { Long.class.getName() });
2136
2137
2144 public int getAssetTagsSize(long pk) throws SystemException {
2145 Object[] finderArgs = new Object[] { pk };
2146
2147 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_GET_ASSETTAGS_SIZE,
2148 finderArgs, this);
2149
2150 if (count == null) {
2151 Session session = null;
2152
2153 try {
2154 session = openSession();
2155
2156 SQLQuery q = session.createSQLQuery(_SQL_GETASSETTAGSSIZE);
2157
2158 q.addScalar(COUNT_COLUMN_NAME,
2159 com.liferay.portal.kernel.dao.orm.Type.LONG);
2160
2161 QueryPos qPos = QueryPos.getInstance(q);
2162
2163 qPos.add(pk);
2164
2165 count = (Long)q.uniqueResult();
2166 }
2167 catch (Exception e) {
2168 throw processException(e);
2169 }
2170 finally {
2171 if (count == null) {
2172 count = Long.valueOf(0);
2173 }
2174
2175 FinderCacheUtil.putResult(FINDER_PATH_GET_ASSETTAGS_SIZE,
2176 finderArgs, count);
2177
2178 closeSession(session);
2179 }
2180 }
2181
2182 return count.intValue();
2183 }
2184
2185 public static final FinderPath FINDER_PATH_CONTAINS_ASSETTAG = new FinderPath(com.liferay.portlet.asset.model.impl.AssetTagModelImpl.ENTITY_CACHE_ENABLED,
2186 AssetEntryModelImpl.FINDER_CACHE_ENABLED_ASSETENTRIES_ASSETTAGS,
2187 AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETTAGS_NAME,
2188 "containsAssetTag",
2189 new String[] { Long.class.getName(), Long.class.getName() });
2190
2191
2199 public boolean containsAssetTag(long pk, long assetTagPK)
2200 throws SystemException {
2201 Object[] finderArgs = new Object[] { pk, assetTagPK };
2202
2203 Boolean value = (Boolean)FinderCacheUtil.getResult(FINDER_PATH_CONTAINS_ASSETTAG,
2204 finderArgs, this);
2205
2206 if (value == null) {
2207 try {
2208 value = Boolean.valueOf(containsAssetTag.contains(pk, assetTagPK));
2209 }
2210 catch (Exception e) {
2211 throw processException(e);
2212 }
2213 finally {
2214 if (value == null) {
2215 value = Boolean.FALSE;
2216 }
2217
2218 FinderCacheUtil.putResult(FINDER_PATH_CONTAINS_ASSETTAG,
2219 finderArgs, value);
2220 }
2221 }
2222
2223 return value.booleanValue();
2224 }
2225
2226
2233 public boolean containsAssetTags(long pk) throws SystemException {
2234 if (getAssetTagsSize(pk) > 0) {
2235 return true;
2236 }
2237 else {
2238 return false;
2239 }
2240 }
2241
2242
2249 public void addAssetTag(long pk, long assetTagPK) throws SystemException {
2250 try {
2251 addAssetTag.add(pk, assetTagPK);
2252 }
2253 catch (Exception e) {
2254 throw processException(e);
2255 }
2256 finally {
2257 FinderCacheUtil.clearCache(AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETTAGS_NAME);
2258 }
2259 }
2260
2261
2268 public void addAssetTag(long pk,
2269 com.liferay.portlet.asset.model.AssetTag assetTag)
2270 throws SystemException {
2271 try {
2272 addAssetTag.add(pk, assetTag.getPrimaryKey());
2273 }
2274 catch (Exception e) {
2275 throw processException(e);
2276 }
2277 finally {
2278 FinderCacheUtil.clearCache(AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETTAGS_NAME);
2279 }
2280 }
2281
2282
2289 public void addAssetTags(long pk, long[] assetTagPKs)
2290 throws SystemException {
2291 try {
2292 for (long assetTagPK : assetTagPKs) {
2293 addAssetTag.add(pk, assetTagPK);
2294 }
2295 }
2296 catch (Exception e) {
2297 throw processException(e);
2298 }
2299 finally {
2300 FinderCacheUtil.clearCache(AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETTAGS_NAME);
2301 }
2302 }
2303
2304
2311 public void addAssetTags(long pk,
2312 List<com.liferay.portlet.asset.model.AssetTag> assetTags)
2313 throws SystemException {
2314 try {
2315 for (com.liferay.portlet.asset.model.AssetTag assetTag : assetTags) {
2316 addAssetTag.add(pk, assetTag.getPrimaryKey());
2317 }
2318 }
2319 catch (Exception e) {
2320 throw processException(e);
2321 }
2322 finally {
2323 FinderCacheUtil.clearCache(AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETTAGS_NAME);
2324 }
2325 }
2326
2327
2333 public void clearAssetTags(long pk) throws SystemException {
2334 try {
2335 clearAssetTags.clear(pk);
2336 }
2337 catch (Exception e) {
2338 throw processException(e);
2339 }
2340 finally {
2341 FinderCacheUtil.clearCache(AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETTAGS_NAME);
2342 }
2343 }
2344
2345
2352 public void removeAssetTag(long pk, long assetTagPK)
2353 throws SystemException {
2354 try {
2355 removeAssetTag.remove(pk, assetTagPK);
2356 }
2357 catch (Exception e) {
2358 throw processException(e);
2359 }
2360 finally {
2361 FinderCacheUtil.clearCache(AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETTAGS_NAME);
2362 }
2363 }
2364
2365
2372 public void removeAssetTag(long pk,
2373 com.liferay.portlet.asset.model.AssetTag assetTag)
2374 throws SystemException {
2375 try {
2376 removeAssetTag.remove(pk, assetTag.getPrimaryKey());
2377 }
2378 catch (Exception e) {
2379 throw processException(e);
2380 }
2381 finally {
2382 FinderCacheUtil.clearCache(AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETTAGS_NAME);
2383 }
2384 }
2385
2386
2393 public void removeAssetTags(long pk, long[] assetTagPKs)
2394 throws SystemException {
2395 try {
2396 for (long assetTagPK : assetTagPKs) {
2397 removeAssetTag.remove(pk, assetTagPK);
2398 }
2399 }
2400 catch (Exception e) {
2401 throw processException(e);
2402 }
2403 finally {
2404 FinderCacheUtil.clearCache(AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETTAGS_NAME);
2405 }
2406 }
2407
2408
2415 public void removeAssetTags(long pk,
2416 List<com.liferay.portlet.asset.model.AssetTag> assetTags)
2417 throws SystemException {
2418 try {
2419 for (com.liferay.portlet.asset.model.AssetTag assetTag : assetTags) {
2420 removeAssetTag.remove(pk, assetTag.getPrimaryKey());
2421 }
2422 }
2423 catch (Exception e) {
2424 throw processException(e);
2425 }
2426 finally {
2427 FinderCacheUtil.clearCache(AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETTAGS_NAME);
2428 }
2429 }
2430
2431
2438 public void setAssetTags(long pk, long[] assetTagPKs)
2439 throws SystemException {
2440 try {
2441 Set<Long> assetTagPKSet = SetUtil.fromArray(assetTagPKs);
2442
2443 List<com.liferay.portlet.asset.model.AssetTag> assetTags = getAssetTags(pk);
2444
2445 for (com.liferay.portlet.asset.model.AssetTag assetTag : assetTags) {
2446 if (!assetTagPKSet.remove(assetTag.getPrimaryKey())) {
2447 removeAssetTag.remove(pk, assetTag.getPrimaryKey());
2448 }
2449 }
2450
2451 for (Long assetTagPK : assetTagPKSet) {
2452 addAssetTag.add(pk, assetTagPK);
2453 }
2454 }
2455 catch (Exception e) {
2456 throw processException(e);
2457 }
2458 finally {
2459 FinderCacheUtil.clearCache(AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETTAGS_NAME);
2460 }
2461 }
2462
2463
2470 public void setAssetTags(long pk,
2471 List<com.liferay.portlet.asset.model.AssetTag> assetTags)
2472 throws SystemException {
2473 try {
2474 long[] assetTagPKs = new long[assetTags.size()];
2475
2476 for (int i = 0; i < assetTags.size(); i++) {
2477 com.liferay.portlet.asset.model.AssetTag assetTag = assetTags.get(i);
2478
2479 assetTagPKs[i] = assetTag.getPrimaryKey();
2480 }
2481
2482 setAssetTags(pk, assetTagPKs);
2483 }
2484 catch (Exception e) {
2485 throw processException(e);
2486 }
2487 finally {
2488 FinderCacheUtil.clearCache(AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETTAGS_NAME);
2489 }
2490 }
2491
2492
2495 public void afterPropertiesSet() {
2496 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
2497 com.liferay.portal.util.PropsUtil.get(
2498 "value.object.listener.com.liferay.portlet.asset.model.AssetEntry")));
2499
2500 if (listenerClassNames.length > 0) {
2501 try {
2502 List<ModelListener<AssetEntry>> listenersList = new ArrayList<ModelListener<AssetEntry>>();
2503
2504 for (String listenerClassName : listenerClassNames) {
2505 listenersList.add((ModelListener<AssetEntry>)InstanceFactory.newInstance(
2506 listenerClassName));
2507 }
2508
2509 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
2510 }
2511 catch (Exception e) {
2512 _log.error(e);
2513 }
2514 }
2515
2516 containsAssetCategory = new ContainsAssetCategory(this);
2517
2518 addAssetCategory = new AddAssetCategory(this);
2519 clearAssetCategories = new ClearAssetCategories(this);
2520 removeAssetCategory = new RemoveAssetCategory(this);
2521
2522 containsAssetTag = new ContainsAssetTag(this);
2523
2524 addAssetTag = new AddAssetTag(this);
2525 clearAssetTags = new ClearAssetTags(this);
2526 removeAssetTag = new RemoveAssetTag(this);
2527 }
2528
2529 @BeanReference(type = AssetCategoryPersistence.class)
2530 protected AssetCategoryPersistence assetCategoryPersistence;
2531 @BeanReference(type = AssetCategoryPropertyPersistence.class)
2532 protected AssetCategoryPropertyPersistence assetCategoryPropertyPersistence;
2533 @BeanReference(type = AssetEntryPersistence.class)
2534 protected AssetEntryPersistence assetEntryPersistence;
2535 @BeanReference(type = AssetLinkPersistence.class)
2536 protected AssetLinkPersistence assetLinkPersistence;
2537 @BeanReference(type = AssetTagPersistence.class)
2538 protected AssetTagPersistence assetTagPersistence;
2539 @BeanReference(type = AssetTagPropertyPersistence.class)
2540 protected AssetTagPropertyPersistence assetTagPropertyPersistence;
2541 @BeanReference(type = AssetTagStatsPersistence.class)
2542 protected AssetTagStatsPersistence assetTagStatsPersistence;
2543 @BeanReference(type = AssetVocabularyPersistence.class)
2544 protected AssetVocabularyPersistence assetVocabularyPersistence;
2545 @BeanReference(type = CompanyPersistence.class)
2546 protected CompanyPersistence companyPersistence;
2547 @BeanReference(type = GroupPersistence.class)
2548 protected GroupPersistence groupPersistence;
2549 @BeanReference(type = ResourcePersistence.class)
2550 protected ResourcePersistence resourcePersistence;
2551 @BeanReference(type = UserPersistence.class)
2552 protected UserPersistence userPersistence;
2553 @BeanReference(type = BlogsEntryPersistence.class)
2554 protected BlogsEntryPersistence blogsEntryPersistence;
2555 @BeanReference(type = BookmarksEntryPersistence.class)
2556 protected BookmarksEntryPersistence bookmarksEntryPersistence;
2557 @BeanReference(type = DLFileEntryPersistence.class)
2558 protected DLFileEntryPersistence dlFileEntryPersistence;
2559 @BeanReference(type = DLFolderPersistence.class)
2560 protected DLFolderPersistence dlFolderPersistence;
2561 @BeanReference(type = JournalArticlePersistence.class)
2562 protected JournalArticlePersistence journalArticlePersistence;
2563 @BeanReference(type = JournalArticleResourcePersistence.class)
2564 protected JournalArticleResourcePersistence journalArticleResourcePersistence;
2565 @BeanReference(type = MBMessagePersistence.class)
2566 protected MBMessagePersistence mbMessagePersistence;
2567 @BeanReference(type = SocialEquityLogPersistence.class)
2568 protected SocialEquityLogPersistence socialEquityLogPersistence;
2569 @BeanReference(type = WikiPagePersistence.class)
2570 protected WikiPagePersistence wikiPagePersistence;
2571 @BeanReference(type = WikiPageResourcePersistence.class)
2572 protected WikiPageResourcePersistence wikiPageResourcePersistence;
2573 protected ContainsAssetCategory containsAssetCategory;
2574 protected AddAssetCategory addAssetCategory;
2575 protected ClearAssetCategories clearAssetCategories;
2576 protected RemoveAssetCategory removeAssetCategory;
2577 protected ContainsAssetTag containsAssetTag;
2578 protected AddAssetTag addAssetTag;
2579 protected ClearAssetTags clearAssetTags;
2580 protected RemoveAssetTag removeAssetTag;
2581
2582 protected class ContainsAssetCategory {
2583 protected ContainsAssetCategory(
2584 AssetEntryPersistenceImpl persistenceImpl) {
2585 super();
2586
2587 _mappingSqlQuery = MappingSqlQueryFactoryUtil.getMappingSqlQuery(getDataSource(),
2588 _SQL_CONTAINSASSETCATEGORY,
2589 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT },
2590 RowMapper.COUNT);
2591 }
2592
2593 protected boolean contains(long entryId, long categoryId) {
2594 List<Integer> results = _mappingSqlQuery.execute(new Object[] {
2595 new Long(entryId), new Long(categoryId)
2596 });
2597
2598 if (results.size() > 0) {
2599 Integer count = results.get(0);
2600
2601 if (count.intValue() > 0) {
2602 return true;
2603 }
2604 }
2605
2606 return false;
2607 }
2608
2609 private MappingSqlQuery<Integer> _mappingSqlQuery;
2610 }
2611
2612 protected class AddAssetCategory {
2613 protected AddAssetCategory(AssetEntryPersistenceImpl persistenceImpl) {
2614 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
2615 "INSERT INTO AssetEntries_AssetCategories (entryId, categoryId) VALUES (?, ?)",
2616 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
2617 _persistenceImpl = persistenceImpl;
2618 }
2619
2620 protected void add(long entryId, long categoryId)
2621 throws SystemException {
2622 if (!_persistenceImpl.containsAssetCategory.contains(entryId,
2623 categoryId)) {
2624 ModelListener<com.liferay.portlet.asset.model.AssetCategory>[] assetCategoryListeners =
2625 assetCategoryPersistence.getListeners();
2626
2627 for (ModelListener<AssetEntry> listener : listeners) {
2628 listener.onBeforeAddAssociation(entryId,
2629 com.liferay.portlet.asset.model.AssetCategory.class.getName(),
2630 categoryId);
2631 }
2632
2633 for (ModelListener<com.liferay.portlet.asset.model.AssetCategory> listener : assetCategoryListeners) {
2634 listener.onBeforeAddAssociation(categoryId,
2635 AssetEntry.class.getName(), entryId);
2636 }
2637
2638 _sqlUpdate.update(new Object[] {
2639 new Long(entryId), new Long(categoryId)
2640 });
2641
2642 for (ModelListener<AssetEntry> listener : listeners) {
2643 listener.onAfterAddAssociation(entryId,
2644 com.liferay.portlet.asset.model.AssetCategory.class.getName(),
2645 categoryId);
2646 }
2647
2648 for (ModelListener<com.liferay.portlet.asset.model.AssetCategory> listener : assetCategoryListeners) {
2649 listener.onAfterAddAssociation(categoryId,
2650 AssetEntry.class.getName(), entryId);
2651 }
2652 }
2653 }
2654
2655 private SqlUpdate _sqlUpdate;
2656 private AssetEntryPersistenceImpl _persistenceImpl;
2657 }
2658
2659 protected class ClearAssetCategories {
2660 protected ClearAssetCategories(
2661 AssetEntryPersistenceImpl persistenceImpl) {
2662 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
2663 "DELETE FROM AssetEntries_AssetCategories WHERE entryId = ?",
2664 new int[] { java.sql.Types.BIGINT });
2665 }
2666
2667 protected void clear(long entryId) throws SystemException {
2668 ModelListener<com.liferay.portlet.asset.model.AssetCategory>[] assetCategoryListeners =
2669 assetCategoryPersistence.getListeners();
2670
2671 List<com.liferay.portlet.asset.model.AssetCategory> assetCategories = null;
2672
2673 if ((listeners.length > 0) || (assetCategoryListeners.length > 0)) {
2674 assetCategories = getAssetCategories(entryId);
2675
2676 for (com.liferay.portlet.asset.model.AssetCategory assetCategory : assetCategories) {
2677 for (ModelListener<AssetEntry> listener : listeners) {
2678 listener.onBeforeRemoveAssociation(entryId,
2679 com.liferay.portlet.asset.model.AssetCategory.class.getName(),
2680 assetCategory.getPrimaryKey());
2681 }
2682
2683 for (ModelListener<com.liferay.portlet.asset.model.AssetCategory> listener : assetCategoryListeners) {
2684 listener.onBeforeRemoveAssociation(assetCategory.getPrimaryKey(),
2685 AssetEntry.class.getName(), entryId);
2686 }
2687 }
2688 }
2689
2690 _sqlUpdate.update(new Object[] { new Long(entryId) });
2691
2692 if ((listeners.length > 0) || (assetCategoryListeners.length > 0)) {
2693 for (com.liferay.portlet.asset.model.AssetCategory assetCategory : assetCategories) {
2694 for (ModelListener<AssetEntry> listener : listeners) {
2695 listener.onAfterRemoveAssociation(entryId,
2696 com.liferay.portlet.asset.model.AssetCategory.class.getName(),
2697 assetCategory.getPrimaryKey());
2698 }
2699
2700 for (ModelListener<com.liferay.portlet.asset.model.AssetCategory> listener : assetCategoryListeners) {
2701 listener.onAfterRemoveAssociation(assetCategory.getPrimaryKey(),
2702 AssetEntry.class.getName(), entryId);
2703 }
2704 }
2705 }
2706 }
2707
2708 private SqlUpdate _sqlUpdate;
2709 }
2710
2711 protected class RemoveAssetCategory {
2712 protected RemoveAssetCategory(AssetEntryPersistenceImpl persistenceImpl) {
2713 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
2714 "DELETE FROM AssetEntries_AssetCategories WHERE entryId = ? AND categoryId = ?",
2715 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
2716 _persistenceImpl = persistenceImpl;
2717 }
2718
2719 protected void remove(long entryId, long categoryId)
2720 throws SystemException {
2721 if (_persistenceImpl.containsAssetCategory.contains(entryId,
2722 categoryId)) {
2723 ModelListener<com.liferay.portlet.asset.model.AssetCategory>[] assetCategoryListeners =
2724 assetCategoryPersistence.getListeners();
2725
2726 for (ModelListener<AssetEntry> listener : listeners) {
2727 listener.onBeforeRemoveAssociation(entryId,
2728 com.liferay.portlet.asset.model.AssetCategory.class.getName(),
2729 categoryId);
2730 }
2731
2732 for (ModelListener<com.liferay.portlet.asset.model.AssetCategory> listener : assetCategoryListeners) {
2733 listener.onBeforeRemoveAssociation(categoryId,
2734 AssetEntry.class.getName(), entryId);
2735 }
2736
2737 _sqlUpdate.update(new Object[] {
2738 new Long(entryId), new Long(categoryId)
2739 });
2740
2741 for (ModelListener<AssetEntry> listener : listeners) {
2742 listener.onAfterRemoveAssociation(entryId,
2743 com.liferay.portlet.asset.model.AssetCategory.class.getName(),
2744 categoryId);
2745 }
2746
2747 for (ModelListener<com.liferay.portlet.asset.model.AssetCategory> listener : assetCategoryListeners) {
2748 listener.onAfterRemoveAssociation(categoryId,
2749 AssetEntry.class.getName(), entryId);
2750 }
2751 }
2752 }
2753
2754 private SqlUpdate _sqlUpdate;
2755 private AssetEntryPersistenceImpl _persistenceImpl;
2756 }
2757
2758 protected class ContainsAssetTag {
2759 protected ContainsAssetTag(AssetEntryPersistenceImpl persistenceImpl) {
2760 super();
2761
2762 _mappingSqlQuery = MappingSqlQueryFactoryUtil.getMappingSqlQuery(getDataSource(),
2763 _SQL_CONTAINSASSETTAG,
2764 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT },
2765 RowMapper.COUNT);
2766 }
2767
2768 protected boolean contains(long entryId, long tagId) {
2769 List<Integer> results = _mappingSqlQuery.execute(new Object[] {
2770 new Long(entryId), new Long(tagId)
2771 });
2772
2773 if (results.size() > 0) {
2774 Integer count = results.get(0);
2775
2776 if (count.intValue() > 0) {
2777 return true;
2778 }
2779 }
2780
2781 return false;
2782 }
2783
2784 private MappingSqlQuery<Integer> _mappingSqlQuery;
2785 }
2786
2787 protected class AddAssetTag {
2788 protected AddAssetTag(AssetEntryPersistenceImpl persistenceImpl) {
2789 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
2790 "INSERT INTO AssetEntries_AssetTags (entryId, tagId) VALUES (?, ?)",
2791 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
2792 _persistenceImpl = persistenceImpl;
2793 }
2794
2795 protected void add(long entryId, long tagId) throws SystemException {
2796 if (!_persistenceImpl.containsAssetTag.contains(entryId, tagId)) {
2797 ModelListener<com.liferay.portlet.asset.model.AssetTag>[] assetTagListeners =
2798 assetTagPersistence.getListeners();
2799
2800 for (ModelListener<AssetEntry> listener : listeners) {
2801 listener.onBeforeAddAssociation(entryId,
2802 com.liferay.portlet.asset.model.AssetTag.class.getName(),
2803 tagId);
2804 }
2805
2806 for (ModelListener<com.liferay.portlet.asset.model.AssetTag> listener : assetTagListeners) {
2807 listener.onBeforeAddAssociation(tagId,
2808 AssetEntry.class.getName(), entryId);
2809 }
2810
2811 _sqlUpdate.update(new Object[] {
2812 new Long(entryId), new Long(tagId)
2813 });
2814
2815 for (ModelListener<AssetEntry> listener : listeners) {
2816 listener.onAfterAddAssociation(entryId,
2817 com.liferay.portlet.asset.model.AssetTag.class.getName(),
2818 tagId);
2819 }
2820
2821 for (ModelListener<com.liferay.portlet.asset.model.AssetTag> listener : assetTagListeners) {
2822 listener.onAfterAddAssociation(tagId,
2823 AssetEntry.class.getName(), entryId);
2824 }
2825 }
2826 }
2827
2828 private SqlUpdate _sqlUpdate;
2829 private AssetEntryPersistenceImpl _persistenceImpl;
2830 }
2831
2832 protected class ClearAssetTags {
2833 protected ClearAssetTags(AssetEntryPersistenceImpl persistenceImpl) {
2834 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
2835 "DELETE FROM AssetEntries_AssetTags WHERE entryId = ?",
2836 new int[] { java.sql.Types.BIGINT });
2837 }
2838
2839 protected void clear(long entryId) throws SystemException {
2840 ModelListener<com.liferay.portlet.asset.model.AssetTag>[] assetTagListeners =
2841 assetTagPersistence.getListeners();
2842
2843 List<com.liferay.portlet.asset.model.AssetTag> assetTags = null;
2844
2845 if ((listeners.length > 0) || (assetTagListeners.length > 0)) {
2846 assetTags = getAssetTags(entryId);
2847
2848 for (com.liferay.portlet.asset.model.AssetTag assetTag : assetTags) {
2849 for (ModelListener<AssetEntry> listener : listeners) {
2850 listener.onBeforeRemoveAssociation(entryId,
2851 com.liferay.portlet.asset.model.AssetTag.class.getName(),
2852 assetTag.getPrimaryKey());
2853 }
2854
2855 for (ModelListener<com.liferay.portlet.asset.model.AssetTag> listener : assetTagListeners) {
2856 listener.onBeforeRemoveAssociation(assetTag.getPrimaryKey(),
2857 AssetEntry.class.getName(), entryId);
2858 }
2859 }
2860 }
2861
2862 _sqlUpdate.update(new Object[] { new Long(entryId) });
2863
2864 if ((listeners.length > 0) || (assetTagListeners.length > 0)) {
2865 for (com.liferay.portlet.asset.model.AssetTag assetTag : assetTags) {
2866 for (ModelListener<AssetEntry> listener : listeners) {
2867 listener.onAfterRemoveAssociation(entryId,
2868 com.liferay.portlet.asset.model.AssetTag.class.getName(),
2869 assetTag.getPrimaryKey());
2870 }
2871
2872 for (ModelListener<com.liferay.portlet.asset.model.AssetTag> listener : assetTagListeners) {
2873 listener.onAfterRemoveAssociation(assetTag.getPrimaryKey(),
2874 AssetEntry.class.getName(), entryId);
2875 }
2876 }
2877 }
2878 }
2879
2880 private SqlUpdate _sqlUpdate;
2881 }
2882
2883 protected class RemoveAssetTag {
2884 protected RemoveAssetTag(AssetEntryPersistenceImpl persistenceImpl) {
2885 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
2886 "DELETE FROM AssetEntries_AssetTags WHERE entryId = ? AND tagId = ?",
2887 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
2888 _persistenceImpl = persistenceImpl;
2889 }
2890
2891 protected void remove(long entryId, long tagId)
2892 throws SystemException {
2893 if (_persistenceImpl.containsAssetTag.contains(entryId, tagId)) {
2894 ModelListener<com.liferay.portlet.asset.model.AssetTag>[] assetTagListeners =
2895 assetTagPersistence.getListeners();
2896
2897 for (ModelListener<AssetEntry> listener : listeners) {
2898 listener.onBeforeRemoveAssociation(entryId,
2899 com.liferay.portlet.asset.model.AssetTag.class.getName(),
2900 tagId);
2901 }
2902
2903 for (ModelListener<com.liferay.portlet.asset.model.AssetTag> listener : assetTagListeners) {
2904 listener.onBeforeRemoveAssociation(tagId,
2905 AssetEntry.class.getName(), entryId);
2906 }
2907
2908 _sqlUpdate.update(new Object[] {
2909 new Long(entryId), new Long(tagId)
2910 });
2911
2912 for (ModelListener<AssetEntry> listener : listeners) {
2913 listener.onAfterRemoveAssociation(entryId,
2914 com.liferay.portlet.asset.model.AssetTag.class.getName(),
2915 tagId);
2916 }
2917
2918 for (ModelListener<com.liferay.portlet.asset.model.AssetTag> listener : assetTagListeners) {
2919 listener.onAfterRemoveAssociation(tagId,
2920 AssetEntry.class.getName(), entryId);
2921 }
2922 }
2923 }
2924
2925 private SqlUpdate _sqlUpdate;
2926 private AssetEntryPersistenceImpl _persistenceImpl;
2927 }
2928
2929 private static final String _SQL_SELECT_ASSETENTRY = "SELECT assetEntry FROM AssetEntry assetEntry";
2930 private static final String _SQL_SELECT_ASSETENTRY_WHERE = "SELECT assetEntry FROM AssetEntry assetEntry WHERE ";
2931 private static final String _SQL_COUNT_ASSETENTRY = "SELECT COUNT(assetEntry) FROM AssetEntry assetEntry";
2932 private static final String _SQL_COUNT_ASSETENTRY_WHERE = "SELECT COUNT(assetEntry) FROM AssetEntry assetEntry WHERE ";
2933 private static final String _SQL_GETASSETCATEGORIES = "SELECT {AssetCategory.*} FROM AssetCategory INNER JOIN AssetEntries_AssetCategories ON (AssetEntries_AssetCategories.categoryId = AssetCategory.categoryId) WHERE (AssetEntries_AssetCategories.entryId = ?)";
2934 private static final String _SQL_GETASSETCATEGORIESSIZE = "SELECT COUNT(*) AS COUNT_VALUE FROM AssetEntries_AssetCategories WHERE entryId = ?";
2935 private static final String _SQL_CONTAINSASSETCATEGORY = "SELECT COUNT(*) AS COUNT_VALUE FROM AssetEntries_AssetCategories WHERE entryId = ? AND categoryId = ?";
2936 private static final String _SQL_GETASSETTAGS = "SELECT {AssetTag.*} FROM AssetTag INNER JOIN AssetEntries_AssetTags ON (AssetEntries_AssetTags.tagId = AssetTag.tagId) WHERE (AssetEntries_AssetTags.entryId = ?)";
2937 private static final String _SQL_GETASSETTAGSSIZE = "SELECT COUNT(*) AS COUNT_VALUE FROM AssetEntries_AssetTags WHERE entryId = ?";
2938 private static final String _SQL_CONTAINSASSETTAG = "SELECT COUNT(*) AS COUNT_VALUE FROM AssetEntries_AssetTags WHERE entryId = ? AND tagId = ?";
2939 private static final String _FINDER_COLUMN_COMPANYID_COMPANYID_2 = "assetEntry.companyId = ?";
2940 private static final String _FINDER_COLUMN_G_CU_GROUPID_2 = "assetEntry.groupId = ? AND ";
2941 private static final String _FINDER_COLUMN_G_CU_CLASSUUID_1 = "assetEntry.classUuid IS NULL";
2942 private static final String _FINDER_COLUMN_G_CU_CLASSUUID_2 = "assetEntry.classUuid = ?";
2943 private static final String _FINDER_COLUMN_G_CU_CLASSUUID_3 = "(assetEntry.classUuid IS NULL OR assetEntry.classUuid = ?)";
2944 private static final String _FINDER_COLUMN_C_C_CLASSNAMEID_2 = "assetEntry.classNameId = ? AND ";
2945 private static final String _FINDER_COLUMN_C_C_CLASSPK_2 = "assetEntry.classPK = ?";
2946 private static final String _ORDER_BY_ENTITY_ALIAS = "assetEntry.";
2947 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No AssetEntry exists with the primary key ";
2948 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No AssetEntry exists with the key {";
2949 private static Log _log = LogFactoryUtil.getLog(AssetEntryPersistenceImpl.class);
2950 }