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 BatchSessionUtil.delete(session, assetEntry);
305 }
306 catch (Exception e) {
307 throw processException(e);
308 }
309 finally {
310 closeSession(session);
311 }
312
313 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
314
315 AssetEntryModelImpl assetEntryModelImpl = (AssetEntryModelImpl)assetEntry;
316
317 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_CU,
318 new Object[] {
319 new Long(assetEntryModelImpl.getGroupId()),
320
321 assetEntryModelImpl.getClassUuid()
322 });
323
324 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_C,
325 new Object[] {
326 new Long(assetEntryModelImpl.getClassNameId()),
327 new Long(assetEntryModelImpl.getClassPK())
328 });
329
330 EntityCacheUtil.removeResult(AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
331 AssetEntryImpl.class, assetEntry.getPrimaryKey());
332
333 return assetEntry;
334 }
335
336 public AssetEntry updateImpl(
337 com.liferay.portlet.asset.model.AssetEntry assetEntry, boolean merge)
338 throws SystemException {
339 assetEntry = toUnwrappedModel(assetEntry);
340
341 boolean isNew = assetEntry.isNew();
342
343 AssetEntryModelImpl assetEntryModelImpl = (AssetEntryModelImpl)assetEntry;
344
345 Session session = null;
346
347 try {
348 session = openSession();
349
350 BatchSessionUtil.update(session, assetEntry, merge);
351
352 assetEntry.setNew(false);
353 }
354 catch (Exception e) {
355 throw processException(e);
356 }
357 finally {
358 closeSession(session);
359 }
360
361 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
362
363 EntityCacheUtil.putResult(AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
364 AssetEntryImpl.class, assetEntry.getPrimaryKey(), assetEntry);
365
366 if (!isNew &&
367 ((assetEntry.getGroupId() != assetEntryModelImpl.getOriginalGroupId()) ||
368 !Validator.equals(assetEntry.getClassUuid(),
369 assetEntryModelImpl.getOriginalClassUuid()))) {
370 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_CU,
371 new Object[] {
372 new Long(assetEntryModelImpl.getOriginalGroupId()),
373
374 assetEntryModelImpl.getOriginalClassUuid()
375 });
376 }
377
378 if (isNew ||
379 ((assetEntry.getGroupId() != assetEntryModelImpl.getOriginalGroupId()) ||
380 !Validator.equals(assetEntry.getClassUuid(),
381 assetEntryModelImpl.getOriginalClassUuid()))) {
382 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_CU,
383 new Object[] {
384 new Long(assetEntry.getGroupId()),
385
386 assetEntry.getClassUuid()
387 }, assetEntry);
388 }
389
390 if (!isNew &&
391 ((assetEntry.getClassNameId() != assetEntryModelImpl.getOriginalClassNameId()) ||
392 (assetEntry.getClassPK() != assetEntryModelImpl.getOriginalClassPK()))) {
393 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_C,
394 new Object[] {
395 new Long(assetEntryModelImpl.getOriginalClassNameId()),
396 new Long(assetEntryModelImpl.getOriginalClassPK())
397 });
398 }
399
400 if (isNew ||
401 ((assetEntry.getClassNameId() != assetEntryModelImpl.getOriginalClassNameId()) ||
402 (assetEntry.getClassPK() != assetEntryModelImpl.getOriginalClassPK()))) {
403 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C,
404 new Object[] {
405 new Long(assetEntry.getClassNameId()),
406 new Long(assetEntry.getClassPK())
407 }, assetEntry);
408 }
409
410 return assetEntry;
411 }
412
413 protected AssetEntry toUnwrappedModel(AssetEntry assetEntry) {
414 if (assetEntry instanceof AssetEntryImpl) {
415 return assetEntry;
416 }
417
418 AssetEntryImpl assetEntryImpl = new AssetEntryImpl();
419
420 assetEntryImpl.setNew(assetEntry.isNew());
421 assetEntryImpl.setPrimaryKey(assetEntry.getPrimaryKey());
422
423 assetEntryImpl.setEntryId(assetEntry.getEntryId());
424 assetEntryImpl.setGroupId(assetEntry.getGroupId());
425 assetEntryImpl.setCompanyId(assetEntry.getCompanyId());
426 assetEntryImpl.setUserId(assetEntry.getUserId());
427 assetEntryImpl.setUserName(assetEntry.getUserName());
428 assetEntryImpl.setCreateDate(assetEntry.getCreateDate());
429 assetEntryImpl.setModifiedDate(assetEntry.getModifiedDate());
430 assetEntryImpl.setClassNameId(assetEntry.getClassNameId());
431 assetEntryImpl.setClassPK(assetEntry.getClassPK());
432 assetEntryImpl.setClassUuid(assetEntry.getClassUuid());
433 assetEntryImpl.setVisible(assetEntry.isVisible());
434 assetEntryImpl.setStartDate(assetEntry.getStartDate());
435 assetEntryImpl.setEndDate(assetEntry.getEndDate());
436 assetEntryImpl.setPublishDate(assetEntry.getPublishDate());
437 assetEntryImpl.setExpirationDate(assetEntry.getExpirationDate());
438 assetEntryImpl.setMimeType(assetEntry.getMimeType());
439 assetEntryImpl.setTitle(assetEntry.getTitle());
440 assetEntryImpl.setDescription(assetEntry.getDescription());
441 assetEntryImpl.setSummary(assetEntry.getSummary());
442 assetEntryImpl.setUrl(assetEntry.getUrl());
443 assetEntryImpl.setHeight(assetEntry.getHeight());
444 assetEntryImpl.setWidth(assetEntry.getWidth());
445 assetEntryImpl.setPriority(assetEntry.getPriority());
446 assetEntryImpl.setViewCount(assetEntry.getViewCount());
447
448 return assetEntryImpl;
449 }
450
451
459 public AssetEntry findByPrimaryKey(Serializable primaryKey)
460 throws NoSuchModelException, SystemException {
461 return findByPrimaryKey(((Long)primaryKey).longValue());
462 }
463
464
472 public AssetEntry findByPrimaryKey(long entryId)
473 throws NoSuchEntryException, SystemException {
474 AssetEntry assetEntry = fetchByPrimaryKey(entryId);
475
476 if (assetEntry == null) {
477 if (_log.isWarnEnabled()) {
478 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + entryId);
479 }
480
481 throw new NoSuchEntryException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
482 entryId);
483 }
484
485 return assetEntry;
486 }
487
488
495 public AssetEntry fetchByPrimaryKey(Serializable primaryKey)
496 throws SystemException {
497 return fetchByPrimaryKey(((Long)primaryKey).longValue());
498 }
499
500
507 public AssetEntry fetchByPrimaryKey(long entryId) throws SystemException {
508 AssetEntry assetEntry = (AssetEntry)EntityCacheUtil.getResult(AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
509 AssetEntryImpl.class, entryId, this);
510
511 if (assetEntry == null) {
512 Session session = null;
513
514 try {
515 session = openSession();
516
517 assetEntry = (AssetEntry)session.get(AssetEntryImpl.class,
518 new Long(entryId));
519 }
520 catch (Exception e) {
521 throw processException(e);
522 }
523 finally {
524 if (assetEntry != null) {
525 cacheResult(assetEntry);
526 }
527
528 closeSession(session);
529 }
530 }
531
532 return assetEntry;
533 }
534
535
542 public List<AssetEntry> findByCompanyId(long companyId)
543 throws SystemException {
544 return findByCompanyId(companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
545 null);
546 }
547
548
561 public List<AssetEntry> findByCompanyId(long companyId, int start, int end)
562 throws SystemException {
563 return findByCompanyId(companyId, start, end, null);
564 }
565
566
580 public List<AssetEntry> findByCompanyId(long companyId, int start, int end,
581 OrderByComparator orderByComparator) throws SystemException {
582 Object[] finderArgs = new Object[] {
583 companyId,
584
585 String.valueOf(start), String.valueOf(end),
586 String.valueOf(orderByComparator)
587 };
588
589 List<AssetEntry> list = (List<AssetEntry>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_COMPANYID,
590 finderArgs, this);
591
592 if (list == null) {
593 StringBundler query = null;
594
595 if (orderByComparator != null) {
596 query = new StringBundler(3 +
597 (orderByComparator.getOrderByFields().length * 3));
598 }
599 else {
600 query = new StringBundler(2);
601 }
602
603 query.append(_SQL_SELECT_ASSETENTRY_WHERE);
604
605 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
606
607 if (orderByComparator != null) {
608 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
609 orderByComparator);
610 }
611
612 String sql = query.toString();
613
614 Session session = null;
615
616 try {
617 session = openSession();
618
619 Query q = session.createQuery(sql);
620
621 QueryPos qPos = QueryPos.getInstance(q);
622
623 qPos.add(companyId);
624
625 list = (List<AssetEntry>)QueryUtil.list(q, getDialect(), start,
626 end);
627 }
628 catch (Exception e) {
629 throw processException(e);
630 }
631 finally {
632 if (list == null) {
633 FinderCacheUtil.removeResult(FINDER_PATH_FIND_BY_COMPANYID,
634 finderArgs);
635 }
636 else {
637 cacheResult(list);
638
639 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_COMPANYID,
640 finderArgs, list);
641 }
642
643 closeSession(session);
644 }
645 }
646
647 return list;
648 }
649
650
663 public AssetEntry findByCompanyId_First(long companyId,
664 OrderByComparator orderByComparator)
665 throws NoSuchEntryException, SystemException {
666 List<AssetEntry> list = findByCompanyId(companyId, 0, 1,
667 orderByComparator);
668
669 if (list.isEmpty()) {
670 StringBundler msg = new StringBundler(4);
671
672 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
673
674 msg.append("companyId=");
675 msg.append(companyId);
676
677 msg.append(StringPool.CLOSE_CURLY_BRACE);
678
679 throw new NoSuchEntryException(msg.toString());
680 }
681 else {
682 return list.get(0);
683 }
684 }
685
686
699 public AssetEntry findByCompanyId_Last(long companyId,
700 OrderByComparator orderByComparator)
701 throws NoSuchEntryException, SystemException {
702 int count = countByCompanyId(companyId);
703
704 List<AssetEntry> list = findByCompanyId(companyId, count - 1, count,
705 orderByComparator);
706
707 if (list.isEmpty()) {
708 StringBundler msg = new StringBundler(4);
709
710 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
711
712 msg.append("companyId=");
713 msg.append(companyId);
714
715 msg.append(StringPool.CLOSE_CURLY_BRACE);
716
717 throw new NoSuchEntryException(msg.toString());
718 }
719 else {
720 return list.get(0);
721 }
722 }
723
724
738 public AssetEntry[] findByCompanyId_PrevAndNext(long entryId,
739 long companyId, OrderByComparator orderByComparator)
740 throws NoSuchEntryException, SystemException {
741 AssetEntry assetEntry = findByPrimaryKey(entryId);
742
743 Session session = null;
744
745 try {
746 session = openSession();
747
748 AssetEntry[] array = new AssetEntryImpl[3];
749
750 array[0] = getByCompanyId_PrevAndNext(session, assetEntry,
751 companyId, orderByComparator, true);
752
753 array[1] = assetEntry;
754
755 array[2] = getByCompanyId_PrevAndNext(session, assetEntry,
756 companyId, orderByComparator, false);
757
758 return array;
759 }
760 catch (Exception e) {
761 throw processException(e);
762 }
763 finally {
764 closeSession(session);
765 }
766 }
767
768 protected AssetEntry getByCompanyId_PrevAndNext(Session session,
769 AssetEntry assetEntry, long companyId,
770 OrderByComparator orderByComparator, boolean previous) {
771 StringBundler query = null;
772
773 if (orderByComparator != null) {
774 query = new StringBundler(6 +
775 (orderByComparator.getOrderByFields().length * 6));
776 }
777 else {
778 query = new StringBundler(3);
779 }
780
781 query.append(_SQL_SELECT_ASSETENTRY_WHERE);
782
783 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
784
785 if (orderByComparator != null) {
786 String[] orderByFields = orderByComparator.getOrderByFields();
787
788 if (orderByFields.length > 0) {
789 query.append(WHERE_AND);
790 }
791
792 for (int i = 0; i < orderByFields.length; i++) {
793 query.append(_ORDER_BY_ENTITY_ALIAS);
794 query.append(orderByFields[i]);
795
796 if ((i + 1) < orderByFields.length) {
797 if (orderByComparator.isAscending() ^ previous) {
798 query.append(WHERE_GREATER_THAN_HAS_NEXT);
799 }
800 else {
801 query.append(WHERE_LESSER_THAN_HAS_NEXT);
802 }
803 }
804 else {
805 if (orderByComparator.isAscending() ^ previous) {
806 query.append(WHERE_GREATER_THAN);
807 }
808 else {
809 query.append(WHERE_LESSER_THAN);
810 }
811 }
812 }
813
814 query.append(ORDER_BY_CLAUSE);
815
816 for (int i = 0; i < orderByFields.length; i++) {
817 query.append(_ORDER_BY_ENTITY_ALIAS);
818 query.append(orderByFields[i]);
819
820 if ((i + 1) < orderByFields.length) {
821 if (orderByComparator.isAscending() ^ previous) {
822 query.append(ORDER_BY_ASC_HAS_NEXT);
823 }
824 else {
825 query.append(ORDER_BY_DESC_HAS_NEXT);
826 }
827 }
828 else {
829 if (orderByComparator.isAscending() ^ previous) {
830 query.append(ORDER_BY_ASC);
831 }
832 else {
833 query.append(ORDER_BY_DESC);
834 }
835 }
836 }
837 }
838
839 String sql = query.toString();
840
841 Query q = session.createQuery(sql);
842
843 q.setFirstResult(0);
844 q.setMaxResults(2);
845
846 QueryPos qPos = QueryPos.getInstance(q);
847
848 qPos.add(companyId);
849
850 if (orderByComparator != null) {
851 Object[] values = orderByComparator.getOrderByValues(assetEntry);
852
853 for (Object value : values) {
854 qPos.add(value);
855 }
856 }
857
858 List<AssetEntry> list = q.list();
859
860 if (list.size() == 2) {
861 return list.get(1);
862 }
863 else {
864 return null;
865 }
866 }
867
868
877 public AssetEntry findByG_CU(long groupId, String classUuid)
878 throws NoSuchEntryException, SystemException {
879 AssetEntry assetEntry = fetchByG_CU(groupId, classUuid);
880
881 if (assetEntry == null) {
882 StringBundler msg = new StringBundler(6);
883
884 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
885
886 msg.append("groupId=");
887 msg.append(groupId);
888
889 msg.append(", classUuid=");
890 msg.append(classUuid);
891
892 msg.append(StringPool.CLOSE_CURLY_BRACE);
893
894 if (_log.isWarnEnabled()) {
895 _log.warn(msg.toString());
896 }
897
898 throw new NoSuchEntryException(msg.toString());
899 }
900
901 return assetEntry;
902 }
903
904
912 public AssetEntry fetchByG_CU(long groupId, String classUuid)
913 throws SystemException {
914 return fetchByG_CU(groupId, classUuid, true);
915 }
916
917
925 public AssetEntry fetchByG_CU(long groupId, String classUuid,
926 boolean retrieveFromCache) throws SystemException {
927 Object[] finderArgs = new Object[] { groupId, classUuid };
928
929 Object result = null;
930
931 if (retrieveFromCache) {
932 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_G_CU,
933 finderArgs, this);
934 }
935
936 if (result == null) {
937 StringBundler query = new StringBundler(3);
938
939 query.append(_SQL_SELECT_ASSETENTRY_WHERE);
940
941 query.append(_FINDER_COLUMN_G_CU_GROUPID_2);
942
943 if (classUuid == null) {
944 query.append(_FINDER_COLUMN_G_CU_CLASSUUID_1);
945 }
946 else {
947 if (classUuid.equals(StringPool.BLANK)) {
948 query.append(_FINDER_COLUMN_G_CU_CLASSUUID_3);
949 }
950 else {
951 query.append(_FINDER_COLUMN_G_CU_CLASSUUID_2);
952 }
953 }
954
955 String sql = query.toString();
956
957 Session session = null;
958
959 try {
960 session = openSession();
961
962 Query q = session.createQuery(sql);
963
964 QueryPos qPos = QueryPos.getInstance(q);
965
966 qPos.add(groupId);
967
968 if (classUuid != null) {
969 qPos.add(classUuid);
970 }
971
972 List<AssetEntry> list = q.list();
973
974 result = list;
975
976 AssetEntry assetEntry = null;
977
978 if (list.isEmpty()) {
979 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_CU,
980 finderArgs, list);
981 }
982 else {
983 assetEntry = list.get(0);
984
985 cacheResult(assetEntry);
986
987 if ((assetEntry.getGroupId() != groupId) ||
988 (assetEntry.getClassUuid() == null) ||
989 !assetEntry.getClassUuid().equals(classUuid)) {
990 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_CU,
991 finderArgs, assetEntry);
992 }
993 }
994
995 return assetEntry;
996 }
997 catch (Exception e) {
998 throw processException(e);
999 }
1000 finally {
1001 if (result == null) {
1002 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_CU,
1003 finderArgs);
1004 }
1005
1006 closeSession(session);
1007 }
1008 }
1009 else {
1010 if (result instanceof List<?>) {
1011 return null;
1012 }
1013 else {
1014 return (AssetEntry)result;
1015 }
1016 }
1017 }
1018
1019
1028 public AssetEntry findByC_C(long classNameId, long classPK)
1029 throws NoSuchEntryException, SystemException {
1030 AssetEntry assetEntry = fetchByC_C(classNameId, classPK);
1031
1032 if (assetEntry == null) {
1033 StringBundler msg = new StringBundler(6);
1034
1035 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1036
1037 msg.append("classNameId=");
1038 msg.append(classNameId);
1039
1040 msg.append(", classPK=");
1041 msg.append(classPK);
1042
1043 msg.append(StringPool.CLOSE_CURLY_BRACE);
1044
1045 if (_log.isWarnEnabled()) {
1046 _log.warn(msg.toString());
1047 }
1048
1049 throw new NoSuchEntryException(msg.toString());
1050 }
1051
1052 return assetEntry;
1053 }
1054
1055
1063 public AssetEntry fetchByC_C(long classNameId, long classPK)
1064 throws SystemException {
1065 return fetchByC_C(classNameId, classPK, true);
1066 }
1067
1068
1076 public AssetEntry fetchByC_C(long classNameId, long classPK,
1077 boolean retrieveFromCache) throws SystemException {
1078 Object[] finderArgs = new Object[] { classNameId, classPK };
1079
1080 Object result = null;
1081
1082 if (retrieveFromCache) {
1083 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_C_C,
1084 finderArgs, this);
1085 }
1086
1087 if (result == null) {
1088 StringBundler query = new StringBundler(3);
1089
1090 query.append(_SQL_SELECT_ASSETENTRY_WHERE);
1091
1092 query.append(_FINDER_COLUMN_C_C_CLASSNAMEID_2);
1093
1094 query.append(_FINDER_COLUMN_C_C_CLASSPK_2);
1095
1096 String sql = query.toString();
1097
1098 Session session = null;
1099
1100 try {
1101 session = openSession();
1102
1103 Query q = session.createQuery(sql);
1104
1105 QueryPos qPos = QueryPos.getInstance(q);
1106
1107 qPos.add(classNameId);
1108
1109 qPos.add(classPK);
1110
1111 List<AssetEntry> list = q.list();
1112
1113 result = list;
1114
1115 AssetEntry assetEntry = null;
1116
1117 if (list.isEmpty()) {
1118 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C,
1119 finderArgs, list);
1120 }
1121 else {
1122 assetEntry = list.get(0);
1123
1124 cacheResult(assetEntry);
1125
1126 if ((assetEntry.getClassNameId() != classNameId) ||
1127 (assetEntry.getClassPK() != classPK)) {
1128 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C,
1129 finderArgs, assetEntry);
1130 }
1131 }
1132
1133 return assetEntry;
1134 }
1135 catch (Exception e) {
1136 throw processException(e);
1137 }
1138 finally {
1139 if (result == null) {
1140 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_C,
1141 finderArgs);
1142 }
1143
1144 closeSession(session);
1145 }
1146 }
1147 else {
1148 if (result instanceof List<?>) {
1149 return null;
1150 }
1151 else {
1152 return (AssetEntry)result;
1153 }
1154 }
1155 }
1156
1157
1163 public List<AssetEntry> findAll() throws SystemException {
1164 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1165 }
1166
1167
1179 public List<AssetEntry> findAll(int start, int end)
1180 throws SystemException {
1181 return findAll(start, end, null);
1182 }
1183
1184
1197 public List<AssetEntry> findAll(int start, int end,
1198 OrderByComparator orderByComparator) throws SystemException {
1199 Object[] finderArgs = new Object[] {
1200 String.valueOf(start), String.valueOf(end),
1201 String.valueOf(orderByComparator)
1202 };
1203
1204 List<AssetEntry> list = (List<AssetEntry>)FinderCacheUtil.getResult(FINDER_PATH_FIND_ALL,
1205 finderArgs, this);
1206
1207 if (list == null) {
1208 StringBundler query = null;
1209 String sql = null;
1210
1211 if (orderByComparator != null) {
1212 query = new StringBundler(2 +
1213 (orderByComparator.getOrderByFields().length * 3));
1214
1215 query.append(_SQL_SELECT_ASSETENTRY);
1216
1217 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1218 orderByComparator);
1219
1220 sql = query.toString();
1221 }
1222 else {
1223 sql = _SQL_SELECT_ASSETENTRY;
1224 }
1225
1226 Session session = null;
1227
1228 try {
1229 session = openSession();
1230
1231 Query q = session.createQuery(sql);
1232
1233 if (orderByComparator == null) {
1234 list = (List<AssetEntry>)QueryUtil.list(q, getDialect(),
1235 start, end, false);
1236
1237 Collections.sort(list);
1238 }
1239 else {
1240 list = (List<AssetEntry>)QueryUtil.list(q, getDialect(),
1241 start, end);
1242 }
1243 }
1244 catch (Exception e) {
1245 throw processException(e);
1246 }
1247 finally {
1248 if (list == null) {
1249 FinderCacheUtil.removeResult(FINDER_PATH_FIND_ALL,
1250 finderArgs);
1251 }
1252 else {
1253 cacheResult(list);
1254
1255 FinderCacheUtil.putResult(FINDER_PATH_FIND_ALL, finderArgs,
1256 list);
1257 }
1258
1259 closeSession(session);
1260 }
1261 }
1262
1263 return list;
1264 }
1265
1266
1272 public void removeByCompanyId(long companyId) throws SystemException {
1273 for (AssetEntry assetEntry : findByCompanyId(companyId)) {
1274 remove(assetEntry);
1275 }
1276 }
1277
1278
1285 public void removeByG_CU(long groupId, String classUuid)
1286 throws NoSuchEntryException, SystemException {
1287 AssetEntry assetEntry = findByG_CU(groupId, classUuid);
1288
1289 remove(assetEntry);
1290 }
1291
1292
1299 public void removeByC_C(long classNameId, long classPK)
1300 throws NoSuchEntryException, SystemException {
1301 AssetEntry assetEntry = findByC_C(classNameId, classPK);
1302
1303 remove(assetEntry);
1304 }
1305
1306
1311 public void removeAll() throws SystemException {
1312 for (AssetEntry assetEntry : findAll()) {
1313 remove(assetEntry);
1314 }
1315 }
1316
1317
1324 public int countByCompanyId(long companyId) throws SystemException {
1325 Object[] finderArgs = new Object[] { companyId };
1326
1327 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_COMPANYID,
1328 finderArgs, this);
1329
1330 if (count == null) {
1331 StringBundler query = new StringBundler(2);
1332
1333 query.append(_SQL_COUNT_ASSETENTRY_WHERE);
1334
1335 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
1336
1337 String sql = query.toString();
1338
1339 Session session = null;
1340
1341 try {
1342 session = openSession();
1343
1344 Query q = session.createQuery(sql);
1345
1346 QueryPos qPos = QueryPos.getInstance(q);
1347
1348 qPos.add(companyId);
1349
1350 count = (Long)q.uniqueResult();
1351 }
1352 catch (Exception e) {
1353 throw processException(e);
1354 }
1355 finally {
1356 if (count == null) {
1357 count = Long.valueOf(0);
1358 }
1359
1360 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_COMPANYID,
1361 finderArgs, count);
1362
1363 closeSession(session);
1364 }
1365 }
1366
1367 return count.intValue();
1368 }
1369
1370
1378 public int countByG_CU(long groupId, String classUuid)
1379 throws SystemException {
1380 Object[] finderArgs = new Object[] { groupId, classUuid };
1381
1382 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_CU,
1383 finderArgs, this);
1384
1385 if (count == null) {
1386 StringBundler query = new StringBundler(3);
1387
1388 query.append(_SQL_COUNT_ASSETENTRY_WHERE);
1389
1390 query.append(_FINDER_COLUMN_G_CU_GROUPID_2);
1391
1392 if (classUuid == null) {
1393 query.append(_FINDER_COLUMN_G_CU_CLASSUUID_1);
1394 }
1395 else {
1396 if (classUuid.equals(StringPool.BLANK)) {
1397 query.append(_FINDER_COLUMN_G_CU_CLASSUUID_3);
1398 }
1399 else {
1400 query.append(_FINDER_COLUMN_G_CU_CLASSUUID_2);
1401 }
1402 }
1403
1404 String sql = query.toString();
1405
1406 Session session = null;
1407
1408 try {
1409 session = openSession();
1410
1411 Query q = session.createQuery(sql);
1412
1413 QueryPos qPos = QueryPos.getInstance(q);
1414
1415 qPos.add(groupId);
1416
1417 if (classUuid != null) {
1418 qPos.add(classUuid);
1419 }
1420
1421 count = (Long)q.uniqueResult();
1422 }
1423 catch (Exception e) {
1424 throw processException(e);
1425 }
1426 finally {
1427 if (count == null) {
1428 count = Long.valueOf(0);
1429 }
1430
1431 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_CU,
1432 finderArgs, count);
1433
1434 closeSession(session);
1435 }
1436 }
1437
1438 return count.intValue();
1439 }
1440
1441
1449 public int countByC_C(long classNameId, long classPK)
1450 throws SystemException {
1451 Object[] finderArgs = new Object[] { classNameId, classPK };
1452
1453 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_C,
1454 finderArgs, this);
1455
1456 if (count == null) {
1457 StringBundler query = new StringBundler(3);
1458
1459 query.append(_SQL_COUNT_ASSETENTRY_WHERE);
1460
1461 query.append(_FINDER_COLUMN_C_C_CLASSNAMEID_2);
1462
1463 query.append(_FINDER_COLUMN_C_C_CLASSPK_2);
1464
1465 String sql = query.toString();
1466
1467 Session session = null;
1468
1469 try {
1470 session = openSession();
1471
1472 Query q = session.createQuery(sql);
1473
1474 QueryPos qPos = QueryPos.getInstance(q);
1475
1476 qPos.add(classNameId);
1477
1478 qPos.add(classPK);
1479
1480 count = (Long)q.uniqueResult();
1481 }
1482 catch (Exception e) {
1483 throw processException(e);
1484 }
1485 finally {
1486 if (count == null) {
1487 count = Long.valueOf(0);
1488 }
1489
1490 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_C, finderArgs,
1491 count);
1492
1493 closeSession(session);
1494 }
1495 }
1496
1497 return count.intValue();
1498 }
1499
1500
1506 public int countAll() throws SystemException {
1507 Object[] finderArgs = new Object[0];
1508
1509 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
1510 finderArgs, this);
1511
1512 if (count == null) {
1513 Session session = null;
1514
1515 try {
1516 session = openSession();
1517
1518 Query q = session.createQuery(_SQL_COUNT_ASSETENTRY);
1519
1520 count = (Long)q.uniqueResult();
1521 }
1522 catch (Exception e) {
1523 throw processException(e);
1524 }
1525 finally {
1526 if (count == null) {
1527 count = Long.valueOf(0);
1528 }
1529
1530 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL, finderArgs,
1531 count);
1532
1533 closeSession(session);
1534 }
1535 }
1536
1537 return count.intValue();
1538 }
1539
1540
1547 public List<com.liferay.portlet.asset.model.AssetCategory> getAssetCategories(
1548 long pk) throws SystemException {
1549 return getAssetCategories(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
1550 }
1551
1552
1565 public List<com.liferay.portlet.asset.model.AssetCategory> getAssetCategories(
1566 long pk, int start, int end) throws SystemException {
1567 return getAssetCategories(pk, start, end, null);
1568 }
1569
1570 public static final FinderPath FINDER_PATH_GET_ASSETCATEGORIES = new FinderPath(com.liferay.portlet.asset.model.impl.AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
1571 AssetEntryModelImpl.FINDER_CACHE_ENABLED_ASSETENTRIES_ASSETCATEGORIES,
1572 AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME,
1573 "getAssetCategories",
1574 new String[] {
1575 Long.class.getName(), "java.lang.Integer", "java.lang.Integer",
1576 "com.liferay.portal.kernel.util.OrderByComparator"
1577 });
1578
1579
1593 public List<com.liferay.portlet.asset.model.AssetCategory> getAssetCategories(
1594 long pk, int start, int end, OrderByComparator orderByComparator)
1595 throws SystemException {
1596 Object[] finderArgs = new Object[] {
1597 pk, String.valueOf(start), String.valueOf(end),
1598 String.valueOf(orderByComparator)
1599 };
1600
1601 List<com.liferay.portlet.asset.model.AssetCategory> list = (List<com.liferay.portlet.asset.model.AssetCategory>)FinderCacheUtil.getResult(FINDER_PATH_GET_ASSETCATEGORIES,
1602 finderArgs, this);
1603
1604 if (list == null) {
1605 Session session = null;
1606
1607 try {
1608 session = openSession();
1609
1610 String sql = null;
1611
1612 if (orderByComparator != null) {
1613 sql = _SQL_GETASSETCATEGORIES.concat(ORDER_BY_CLAUSE)
1614 .concat(orderByComparator.getOrderBy());
1615 }
1616 else {
1617 sql = _SQL_GETASSETCATEGORIES.concat(com.liferay.portlet.asset.model.impl.AssetCategoryModelImpl.ORDER_BY_SQL);
1618 }
1619
1620 SQLQuery q = session.createSQLQuery(sql);
1621
1622 q.addEntity("AssetCategory",
1623 com.liferay.portlet.asset.model.impl.AssetCategoryImpl.class);
1624
1625 QueryPos qPos = QueryPos.getInstance(q);
1626
1627 qPos.add(pk);
1628
1629 list = (List<com.liferay.portlet.asset.model.AssetCategory>)QueryUtil.list(q,
1630 getDialect(), start, end);
1631 }
1632 catch (Exception e) {
1633 throw processException(e);
1634 }
1635 finally {
1636 if (list == null) {
1637 FinderCacheUtil.removeResult(FINDER_PATH_GET_ASSETCATEGORIES,
1638 finderArgs);
1639 }
1640 else {
1641 assetCategoryPersistence.cacheResult(list);
1642
1643 FinderCacheUtil.putResult(FINDER_PATH_GET_ASSETCATEGORIES,
1644 finderArgs, list);
1645 }
1646
1647 closeSession(session);
1648 }
1649 }
1650
1651 return list;
1652 }
1653
1654 public static final FinderPath FINDER_PATH_GET_ASSETCATEGORIES_SIZE = new FinderPath(com.liferay.portlet.asset.model.impl.AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
1655 AssetEntryModelImpl.FINDER_CACHE_ENABLED_ASSETENTRIES_ASSETCATEGORIES,
1656 AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME,
1657 "getAssetCategoriesSize", new String[] { Long.class.getName() });
1658
1659
1666 public int getAssetCategoriesSize(long pk) throws SystemException {
1667 Object[] finderArgs = new Object[] { pk };
1668
1669 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_GET_ASSETCATEGORIES_SIZE,
1670 finderArgs, this);
1671
1672 if (count == null) {
1673 Session session = null;
1674
1675 try {
1676 session = openSession();
1677
1678 SQLQuery q = session.createSQLQuery(_SQL_GETASSETCATEGORIESSIZE);
1679
1680 q.addScalar(COUNT_COLUMN_NAME,
1681 com.liferay.portal.kernel.dao.orm.Type.LONG);
1682
1683 QueryPos qPos = QueryPos.getInstance(q);
1684
1685 qPos.add(pk);
1686
1687 count = (Long)q.uniqueResult();
1688 }
1689 catch (Exception e) {
1690 throw processException(e);
1691 }
1692 finally {
1693 if (count == null) {
1694 count = Long.valueOf(0);
1695 }
1696
1697 FinderCacheUtil.putResult(FINDER_PATH_GET_ASSETCATEGORIES_SIZE,
1698 finderArgs, count);
1699
1700 closeSession(session);
1701 }
1702 }
1703
1704 return count.intValue();
1705 }
1706
1707 public static final FinderPath FINDER_PATH_CONTAINS_ASSETCATEGORY = new FinderPath(com.liferay.portlet.asset.model.impl.AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
1708 AssetEntryModelImpl.FINDER_CACHE_ENABLED_ASSETENTRIES_ASSETCATEGORIES,
1709 AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME,
1710 "containsAssetCategory",
1711 new String[] { Long.class.getName(), Long.class.getName() });
1712
1713
1721 public boolean containsAssetCategory(long pk, long assetCategoryPK)
1722 throws SystemException {
1723 Object[] finderArgs = new Object[] { pk, assetCategoryPK };
1724
1725 Boolean value = (Boolean)FinderCacheUtil.getResult(FINDER_PATH_CONTAINS_ASSETCATEGORY,
1726 finderArgs, this);
1727
1728 if (value == null) {
1729 try {
1730 value = Boolean.valueOf(containsAssetCategory.contains(pk,
1731 assetCategoryPK));
1732 }
1733 catch (Exception e) {
1734 throw processException(e);
1735 }
1736 finally {
1737 if (value == null) {
1738 value = Boolean.FALSE;
1739 }
1740
1741 FinderCacheUtil.putResult(FINDER_PATH_CONTAINS_ASSETCATEGORY,
1742 finderArgs, value);
1743 }
1744 }
1745
1746 return value.booleanValue();
1747 }
1748
1749
1756 public boolean containsAssetCategories(long pk) throws SystemException {
1757 if (getAssetCategoriesSize(pk) > 0) {
1758 return true;
1759 }
1760 else {
1761 return false;
1762 }
1763 }
1764
1765
1772 public void addAssetCategory(long pk, long assetCategoryPK)
1773 throws SystemException {
1774 try {
1775 addAssetCategory.add(pk, assetCategoryPK);
1776 }
1777 catch (Exception e) {
1778 throw processException(e);
1779 }
1780 finally {
1781 FinderCacheUtil.clearCache(AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
1782 }
1783 }
1784
1785
1792 public void addAssetCategory(long pk,
1793 com.liferay.portlet.asset.model.AssetCategory assetCategory)
1794 throws SystemException {
1795 try {
1796 addAssetCategory.add(pk, assetCategory.getPrimaryKey());
1797 }
1798 catch (Exception e) {
1799 throw processException(e);
1800 }
1801 finally {
1802 FinderCacheUtil.clearCache(AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
1803 }
1804 }
1805
1806
1813 public void addAssetCategories(long pk, long[] assetCategoryPKs)
1814 throws SystemException {
1815 try {
1816 for (long assetCategoryPK : assetCategoryPKs) {
1817 addAssetCategory.add(pk, assetCategoryPK);
1818 }
1819 }
1820 catch (Exception e) {
1821 throw processException(e);
1822 }
1823 finally {
1824 FinderCacheUtil.clearCache(AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
1825 }
1826 }
1827
1828
1835 public void addAssetCategories(long pk,
1836 List<com.liferay.portlet.asset.model.AssetCategory> assetCategories)
1837 throws SystemException {
1838 try {
1839 for (com.liferay.portlet.asset.model.AssetCategory assetCategory : assetCategories) {
1840 addAssetCategory.add(pk, assetCategory.getPrimaryKey());
1841 }
1842 }
1843 catch (Exception e) {
1844 throw processException(e);
1845 }
1846 finally {
1847 FinderCacheUtil.clearCache(AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
1848 }
1849 }
1850
1851
1857 public void clearAssetCategories(long pk) throws SystemException {
1858 try {
1859 clearAssetCategories.clear(pk);
1860 }
1861 catch (Exception e) {
1862 throw processException(e);
1863 }
1864 finally {
1865 FinderCacheUtil.clearCache(AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
1866 }
1867 }
1868
1869
1876 public void removeAssetCategory(long pk, long assetCategoryPK)
1877 throws SystemException {
1878 try {
1879 removeAssetCategory.remove(pk, assetCategoryPK);
1880 }
1881 catch (Exception e) {
1882 throw processException(e);
1883 }
1884 finally {
1885 FinderCacheUtil.clearCache(AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
1886 }
1887 }
1888
1889
1896 public void removeAssetCategory(long pk,
1897 com.liferay.portlet.asset.model.AssetCategory assetCategory)
1898 throws SystemException {
1899 try {
1900 removeAssetCategory.remove(pk, assetCategory.getPrimaryKey());
1901 }
1902 catch (Exception e) {
1903 throw processException(e);
1904 }
1905 finally {
1906 FinderCacheUtil.clearCache(AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
1907 }
1908 }
1909
1910
1917 public void removeAssetCategories(long pk, long[] assetCategoryPKs)
1918 throws SystemException {
1919 try {
1920 for (long assetCategoryPK : assetCategoryPKs) {
1921 removeAssetCategory.remove(pk, assetCategoryPK);
1922 }
1923 }
1924 catch (Exception e) {
1925 throw processException(e);
1926 }
1927 finally {
1928 FinderCacheUtil.clearCache(AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
1929 }
1930 }
1931
1932
1939 public void removeAssetCategories(long pk,
1940 List<com.liferay.portlet.asset.model.AssetCategory> assetCategories)
1941 throws SystemException {
1942 try {
1943 for (com.liferay.portlet.asset.model.AssetCategory assetCategory : assetCategories) {
1944 removeAssetCategory.remove(pk, assetCategory.getPrimaryKey());
1945 }
1946 }
1947 catch (Exception e) {
1948 throw processException(e);
1949 }
1950 finally {
1951 FinderCacheUtil.clearCache(AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
1952 }
1953 }
1954
1955
1962 public void setAssetCategories(long pk, long[] assetCategoryPKs)
1963 throws SystemException {
1964 try {
1965 Set<Long> assetCategoryPKSet = SetUtil.fromArray(assetCategoryPKs);
1966
1967 List<com.liferay.portlet.asset.model.AssetCategory> assetCategories = getAssetCategories(pk);
1968
1969 for (com.liferay.portlet.asset.model.AssetCategory assetCategory : assetCategories) {
1970 if (!assetCategoryPKSet.remove(assetCategory.getPrimaryKey())) {
1971 removeAssetCategory.remove(pk, assetCategory.getPrimaryKey());
1972 }
1973 }
1974
1975 for (Long assetCategoryPK : assetCategoryPKSet) {
1976 addAssetCategory.add(pk, assetCategoryPK);
1977 }
1978 }
1979 catch (Exception e) {
1980 throw processException(e);
1981 }
1982 finally {
1983 FinderCacheUtil.clearCache(AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
1984 }
1985 }
1986
1987
1994 public void setAssetCategories(long pk,
1995 List<com.liferay.portlet.asset.model.AssetCategory> assetCategories)
1996 throws SystemException {
1997 try {
1998 long[] assetCategoryPKs = new long[assetCategories.size()];
1999
2000 for (int i = 0; i < assetCategories.size(); i++) {
2001 com.liferay.portlet.asset.model.AssetCategory assetCategory = assetCategories.get(i);
2002
2003 assetCategoryPKs[i] = assetCategory.getPrimaryKey();
2004 }
2005
2006 setAssetCategories(pk, assetCategoryPKs);
2007 }
2008 catch (Exception e) {
2009 throw processException(e);
2010 }
2011 finally {
2012 FinderCacheUtil.clearCache(AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
2013 }
2014 }
2015
2016
2023 public List<com.liferay.portlet.asset.model.AssetTag> getAssetTags(long pk)
2024 throws SystemException {
2025 return getAssetTags(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
2026 }
2027
2028
2041 public List<com.liferay.portlet.asset.model.AssetTag> getAssetTags(
2042 long pk, int start, int end) throws SystemException {
2043 return getAssetTags(pk, start, end, null);
2044 }
2045
2046 public static final FinderPath FINDER_PATH_GET_ASSETTAGS = new FinderPath(com.liferay.portlet.asset.model.impl.AssetTagModelImpl.ENTITY_CACHE_ENABLED,
2047 AssetEntryModelImpl.FINDER_CACHE_ENABLED_ASSETENTRIES_ASSETTAGS,
2048 AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETTAGS_NAME,
2049 "getAssetTags",
2050 new String[] {
2051 Long.class.getName(), "java.lang.Integer", "java.lang.Integer",
2052 "com.liferay.portal.kernel.util.OrderByComparator"
2053 });
2054
2055
2069 public List<com.liferay.portlet.asset.model.AssetTag> getAssetTags(
2070 long pk, int start, int end, OrderByComparator orderByComparator)
2071 throws SystemException {
2072 Object[] finderArgs = new Object[] {
2073 pk, String.valueOf(start), String.valueOf(end),
2074 String.valueOf(orderByComparator)
2075 };
2076
2077 List<com.liferay.portlet.asset.model.AssetTag> list = (List<com.liferay.portlet.asset.model.AssetTag>)FinderCacheUtil.getResult(FINDER_PATH_GET_ASSETTAGS,
2078 finderArgs, this);
2079
2080 if (list == null) {
2081 Session session = null;
2082
2083 try {
2084 session = openSession();
2085
2086 String sql = null;
2087
2088 if (orderByComparator != null) {
2089 sql = _SQL_GETASSETTAGS.concat(ORDER_BY_CLAUSE)
2090 .concat(orderByComparator.getOrderBy());
2091 }
2092 else {
2093 sql = _SQL_GETASSETTAGS.concat(com.liferay.portlet.asset.model.impl.AssetTagModelImpl.ORDER_BY_SQL);
2094 }
2095
2096 SQLQuery q = session.createSQLQuery(sql);
2097
2098 q.addEntity("AssetTag",
2099 com.liferay.portlet.asset.model.impl.AssetTagImpl.class);
2100
2101 QueryPos qPos = QueryPos.getInstance(q);
2102
2103 qPos.add(pk);
2104
2105 list = (List<com.liferay.portlet.asset.model.AssetTag>)QueryUtil.list(q,
2106 getDialect(), start, end);
2107 }
2108 catch (Exception e) {
2109 throw processException(e);
2110 }
2111 finally {
2112 if (list == null) {
2113 FinderCacheUtil.removeResult(FINDER_PATH_GET_ASSETTAGS,
2114 finderArgs);
2115 }
2116 else {
2117 assetTagPersistence.cacheResult(list);
2118
2119 FinderCacheUtil.putResult(FINDER_PATH_GET_ASSETTAGS,
2120 finderArgs, list);
2121 }
2122
2123 closeSession(session);
2124 }
2125 }
2126
2127 return list;
2128 }
2129
2130 public static final FinderPath FINDER_PATH_GET_ASSETTAGS_SIZE = new FinderPath(com.liferay.portlet.asset.model.impl.AssetTagModelImpl.ENTITY_CACHE_ENABLED,
2131 AssetEntryModelImpl.FINDER_CACHE_ENABLED_ASSETENTRIES_ASSETTAGS,
2132 AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETTAGS_NAME,
2133 "getAssetTagsSize", new String[] { Long.class.getName() });
2134
2135
2142 public int getAssetTagsSize(long pk) throws SystemException {
2143 Object[] finderArgs = new Object[] { pk };
2144
2145 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_GET_ASSETTAGS_SIZE,
2146 finderArgs, this);
2147
2148 if (count == null) {
2149 Session session = null;
2150
2151 try {
2152 session = openSession();
2153
2154 SQLQuery q = session.createSQLQuery(_SQL_GETASSETTAGSSIZE);
2155
2156 q.addScalar(COUNT_COLUMN_NAME,
2157 com.liferay.portal.kernel.dao.orm.Type.LONG);
2158
2159 QueryPos qPos = QueryPos.getInstance(q);
2160
2161 qPos.add(pk);
2162
2163 count = (Long)q.uniqueResult();
2164 }
2165 catch (Exception e) {
2166 throw processException(e);
2167 }
2168 finally {
2169 if (count == null) {
2170 count = Long.valueOf(0);
2171 }
2172
2173 FinderCacheUtil.putResult(FINDER_PATH_GET_ASSETTAGS_SIZE,
2174 finderArgs, count);
2175
2176 closeSession(session);
2177 }
2178 }
2179
2180 return count.intValue();
2181 }
2182
2183 public static final FinderPath FINDER_PATH_CONTAINS_ASSETTAG = new FinderPath(com.liferay.portlet.asset.model.impl.AssetTagModelImpl.ENTITY_CACHE_ENABLED,
2184 AssetEntryModelImpl.FINDER_CACHE_ENABLED_ASSETENTRIES_ASSETTAGS,
2185 AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETTAGS_NAME,
2186 "containsAssetTag",
2187 new String[] { Long.class.getName(), Long.class.getName() });
2188
2189
2197 public boolean containsAssetTag(long pk, long assetTagPK)
2198 throws SystemException {
2199 Object[] finderArgs = new Object[] { pk, assetTagPK };
2200
2201 Boolean value = (Boolean)FinderCacheUtil.getResult(FINDER_PATH_CONTAINS_ASSETTAG,
2202 finderArgs, this);
2203
2204 if (value == null) {
2205 try {
2206 value = Boolean.valueOf(containsAssetTag.contains(pk, assetTagPK));
2207 }
2208 catch (Exception e) {
2209 throw processException(e);
2210 }
2211 finally {
2212 if (value == null) {
2213 value = Boolean.FALSE;
2214 }
2215
2216 FinderCacheUtil.putResult(FINDER_PATH_CONTAINS_ASSETTAG,
2217 finderArgs, value);
2218 }
2219 }
2220
2221 return value.booleanValue();
2222 }
2223
2224
2231 public boolean containsAssetTags(long pk) throws SystemException {
2232 if (getAssetTagsSize(pk) > 0) {
2233 return true;
2234 }
2235 else {
2236 return false;
2237 }
2238 }
2239
2240
2247 public void addAssetTag(long pk, long assetTagPK) throws SystemException {
2248 try {
2249 addAssetTag.add(pk, assetTagPK);
2250 }
2251 catch (Exception e) {
2252 throw processException(e);
2253 }
2254 finally {
2255 FinderCacheUtil.clearCache(AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETTAGS_NAME);
2256 }
2257 }
2258
2259
2266 public void addAssetTag(long pk,
2267 com.liferay.portlet.asset.model.AssetTag assetTag)
2268 throws SystemException {
2269 try {
2270 addAssetTag.add(pk, assetTag.getPrimaryKey());
2271 }
2272 catch (Exception e) {
2273 throw processException(e);
2274 }
2275 finally {
2276 FinderCacheUtil.clearCache(AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETTAGS_NAME);
2277 }
2278 }
2279
2280
2287 public void addAssetTags(long pk, long[] assetTagPKs)
2288 throws SystemException {
2289 try {
2290 for (long assetTagPK : assetTagPKs) {
2291 addAssetTag.add(pk, assetTagPK);
2292 }
2293 }
2294 catch (Exception e) {
2295 throw processException(e);
2296 }
2297 finally {
2298 FinderCacheUtil.clearCache(AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETTAGS_NAME);
2299 }
2300 }
2301
2302
2309 public void addAssetTags(long pk,
2310 List<com.liferay.portlet.asset.model.AssetTag> assetTags)
2311 throws SystemException {
2312 try {
2313 for (com.liferay.portlet.asset.model.AssetTag assetTag : assetTags) {
2314 addAssetTag.add(pk, assetTag.getPrimaryKey());
2315 }
2316 }
2317 catch (Exception e) {
2318 throw processException(e);
2319 }
2320 finally {
2321 FinderCacheUtil.clearCache(AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETTAGS_NAME);
2322 }
2323 }
2324
2325
2331 public void clearAssetTags(long pk) throws SystemException {
2332 try {
2333 clearAssetTags.clear(pk);
2334 }
2335 catch (Exception e) {
2336 throw processException(e);
2337 }
2338 finally {
2339 FinderCacheUtil.clearCache(AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETTAGS_NAME);
2340 }
2341 }
2342
2343
2350 public void removeAssetTag(long pk, long assetTagPK)
2351 throws SystemException {
2352 try {
2353 removeAssetTag.remove(pk, assetTagPK);
2354 }
2355 catch (Exception e) {
2356 throw processException(e);
2357 }
2358 finally {
2359 FinderCacheUtil.clearCache(AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETTAGS_NAME);
2360 }
2361 }
2362
2363
2370 public void removeAssetTag(long pk,
2371 com.liferay.portlet.asset.model.AssetTag assetTag)
2372 throws SystemException {
2373 try {
2374 removeAssetTag.remove(pk, assetTag.getPrimaryKey());
2375 }
2376 catch (Exception e) {
2377 throw processException(e);
2378 }
2379 finally {
2380 FinderCacheUtil.clearCache(AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETTAGS_NAME);
2381 }
2382 }
2383
2384
2391 public void removeAssetTags(long pk, long[] assetTagPKs)
2392 throws SystemException {
2393 try {
2394 for (long assetTagPK : assetTagPKs) {
2395 removeAssetTag.remove(pk, assetTagPK);
2396 }
2397 }
2398 catch (Exception e) {
2399 throw processException(e);
2400 }
2401 finally {
2402 FinderCacheUtil.clearCache(AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETTAGS_NAME);
2403 }
2404 }
2405
2406
2413 public void removeAssetTags(long pk,
2414 List<com.liferay.portlet.asset.model.AssetTag> assetTags)
2415 throws SystemException {
2416 try {
2417 for (com.liferay.portlet.asset.model.AssetTag assetTag : assetTags) {
2418 removeAssetTag.remove(pk, assetTag.getPrimaryKey());
2419 }
2420 }
2421 catch (Exception e) {
2422 throw processException(e);
2423 }
2424 finally {
2425 FinderCacheUtil.clearCache(AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETTAGS_NAME);
2426 }
2427 }
2428
2429
2436 public void setAssetTags(long pk, long[] assetTagPKs)
2437 throws SystemException {
2438 try {
2439 Set<Long> assetTagPKSet = SetUtil.fromArray(assetTagPKs);
2440
2441 List<com.liferay.portlet.asset.model.AssetTag> assetTags = getAssetTags(pk);
2442
2443 for (com.liferay.portlet.asset.model.AssetTag assetTag : assetTags) {
2444 if (!assetTagPKSet.remove(assetTag.getPrimaryKey())) {
2445 removeAssetTag.remove(pk, assetTag.getPrimaryKey());
2446 }
2447 }
2448
2449 for (Long assetTagPK : assetTagPKSet) {
2450 addAssetTag.add(pk, assetTagPK);
2451 }
2452 }
2453 catch (Exception e) {
2454 throw processException(e);
2455 }
2456 finally {
2457 FinderCacheUtil.clearCache(AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETTAGS_NAME);
2458 }
2459 }
2460
2461
2468 public void setAssetTags(long pk,
2469 List<com.liferay.portlet.asset.model.AssetTag> assetTags)
2470 throws SystemException {
2471 try {
2472 long[] assetTagPKs = new long[assetTags.size()];
2473
2474 for (int i = 0; i < assetTags.size(); i++) {
2475 com.liferay.portlet.asset.model.AssetTag assetTag = assetTags.get(i);
2476
2477 assetTagPKs[i] = assetTag.getPrimaryKey();
2478 }
2479
2480 setAssetTags(pk, assetTagPKs);
2481 }
2482 catch (Exception e) {
2483 throw processException(e);
2484 }
2485 finally {
2486 FinderCacheUtil.clearCache(AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETTAGS_NAME);
2487 }
2488 }
2489
2490
2493 public void afterPropertiesSet() {
2494 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
2495 com.liferay.portal.util.PropsUtil.get(
2496 "value.object.listener.com.liferay.portlet.asset.model.AssetEntry")));
2497
2498 if (listenerClassNames.length > 0) {
2499 try {
2500 List<ModelListener<AssetEntry>> listenersList = new ArrayList<ModelListener<AssetEntry>>();
2501
2502 for (String listenerClassName : listenerClassNames) {
2503 listenersList.add((ModelListener<AssetEntry>)InstanceFactory.newInstance(
2504 listenerClassName));
2505 }
2506
2507 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
2508 }
2509 catch (Exception e) {
2510 _log.error(e);
2511 }
2512 }
2513
2514 containsAssetCategory = new ContainsAssetCategory(this);
2515
2516 addAssetCategory = new AddAssetCategory(this);
2517 clearAssetCategories = new ClearAssetCategories(this);
2518 removeAssetCategory = new RemoveAssetCategory(this);
2519
2520 containsAssetTag = new ContainsAssetTag(this);
2521
2522 addAssetTag = new AddAssetTag(this);
2523 clearAssetTags = new ClearAssetTags(this);
2524 removeAssetTag = new RemoveAssetTag(this);
2525 }
2526
2527 public void destroy() {
2528 EntityCacheUtil.removeCache(AssetEntryImpl.class.getName());
2529 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
2530 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST);
2531 }
2532
2533 @BeanReference(type = AssetCategoryPersistence.class)
2534 protected AssetCategoryPersistence assetCategoryPersistence;
2535 @BeanReference(type = AssetCategoryPropertyPersistence.class)
2536 protected AssetCategoryPropertyPersistence assetCategoryPropertyPersistence;
2537 @BeanReference(type = AssetEntryPersistence.class)
2538 protected AssetEntryPersistence assetEntryPersistence;
2539 @BeanReference(type = AssetLinkPersistence.class)
2540 protected AssetLinkPersistence assetLinkPersistence;
2541 @BeanReference(type = AssetTagPersistence.class)
2542 protected AssetTagPersistence assetTagPersistence;
2543 @BeanReference(type = AssetTagPropertyPersistence.class)
2544 protected AssetTagPropertyPersistence assetTagPropertyPersistence;
2545 @BeanReference(type = AssetTagStatsPersistence.class)
2546 protected AssetTagStatsPersistence assetTagStatsPersistence;
2547 @BeanReference(type = AssetVocabularyPersistence.class)
2548 protected AssetVocabularyPersistence assetVocabularyPersistence;
2549 @BeanReference(type = CompanyPersistence.class)
2550 protected CompanyPersistence companyPersistence;
2551 @BeanReference(type = GroupPersistence.class)
2552 protected GroupPersistence groupPersistence;
2553 @BeanReference(type = ResourcePersistence.class)
2554 protected ResourcePersistence resourcePersistence;
2555 @BeanReference(type = UserPersistence.class)
2556 protected UserPersistence userPersistence;
2557 @BeanReference(type = BlogsEntryPersistence.class)
2558 protected BlogsEntryPersistence blogsEntryPersistence;
2559 @BeanReference(type = BookmarksEntryPersistence.class)
2560 protected BookmarksEntryPersistence bookmarksEntryPersistence;
2561 @BeanReference(type = DLFileEntryPersistence.class)
2562 protected DLFileEntryPersistence dlFileEntryPersistence;
2563 @BeanReference(type = DLFolderPersistence.class)
2564 protected DLFolderPersistence dlFolderPersistence;
2565 @BeanReference(type = JournalArticlePersistence.class)
2566 protected JournalArticlePersistence journalArticlePersistence;
2567 @BeanReference(type = JournalArticleResourcePersistence.class)
2568 protected JournalArticleResourcePersistence journalArticleResourcePersistence;
2569 @BeanReference(type = MBMessagePersistence.class)
2570 protected MBMessagePersistence mbMessagePersistence;
2571 @BeanReference(type = SocialEquityLogPersistence.class)
2572 protected SocialEquityLogPersistence socialEquityLogPersistence;
2573 @BeanReference(type = WikiPagePersistence.class)
2574 protected WikiPagePersistence wikiPagePersistence;
2575 @BeanReference(type = WikiPageResourcePersistence.class)
2576 protected WikiPageResourcePersistence wikiPageResourcePersistence;
2577 protected ContainsAssetCategory containsAssetCategory;
2578 protected AddAssetCategory addAssetCategory;
2579 protected ClearAssetCategories clearAssetCategories;
2580 protected RemoveAssetCategory removeAssetCategory;
2581 protected ContainsAssetTag containsAssetTag;
2582 protected AddAssetTag addAssetTag;
2583 protected ClearAssetTags clearAssetTags;
2584 protected RemoveAssetTag removeAssetTag;
2585
2586 protected class ContainsAssetCategory {
2587 protected ContainsAssetCategory(
2588 AssetEntryPersistenceImpl persistenceImpl) {
2589 super();
2590
2591 _mappingSqlQuery = MappingSqlQueryFactoryUtil.getMappingSqlQuery(getDataSource(),
2592 _SQL_CONTAINSASSETCATEGORY,
2593 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT },
2594 RowMapper.COUNT);
2595 }
2596
2597 protected boolean contains(long entryId, long categoryId) {
2598 List<Integer> results = _mappingSqlQuery.execute(new Object[] {
2599 new Long(entryId), new Long(categoryId)
2600 });
2601
2602 if (results.size() > 0) {
2603 Integer count = results.get(0);
2604
2605 if (count.intValue() > 0) {
2606 return true;
2607 }
2608 }
2609
2610 return false;
2611 }
2612
2613 private MappingSqlQuery<Integer> _mappingSqlQuery;
2614 }
2615
2616 protected class AddAssetCategory {
2617 protected AddAssetCategory(AssetEntryPersistenceImpl persistenceImpl) {
2618 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
2619 "INSERT INTO AssetEntries_AssetCategories (entryId, categoryId) VALUES (?, ?)",
2620 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
2621 _persistenceImpl = persistenceImpl;
2622 }
2623
2624 protected void add(long entryId, long categoryId)
2625 throws SystemException {
2626 if (!_persistenceImpl.containsAssetCategory.contains(entryId,
2627 categoryId)) {
2628 ModelListener<com.liferay.portlet.asset.model.AssetCategory>[] assetCategoryListeners =
2629 assetCategoryPersistence.getListeners();
2630
2631 for (ModelListener<AssetEntry> listener : listeners) {
2632 listener.onBeforeAddAssociation(entryId,
2633 com.liferay.portlet.asset.model.AssetCategory.class.getName(),
2634 categoryId);
2635 }
2636
2637 for (ModelListener<com.liferay.portlet.asset.model.AssetCategory> listener : assetCategoryListeners) {
2638 listener.onBeforeAddAssociation(categoryId,
2639 AssetEntry.class.getName(), entryId);
2640 }
2641
2642 _sqlUpdate.update(new Object[] {
2643 new Long(entryId), new Long(categoryId)
2644 });
2645
2646 for (ModelListener<AssetEntry> listener : listeners) {
2647 listener.onAfterAddAssociation(entryId,
2648 com.liferay.portlet.asset.model.AssetCategory.class.getName(),
2649 categoryId);
2650 }
2651
2652 for (ModelListener<com.liferay.portlet.asset.model.AssetCategory> listener : assetCategoryListeners) {
2653 listener.onAfterAddAssociation(categoryId,
2654 AssetEntry.class.getName(), entryId);
2655 }
2656 }
2657 }
2658
2659 private SqlUpdate _sqlUpdate;
2660 private AssetEntryPersistenceImpl _persistenceImpl;
2661 }
2662
2663 protected class ClearAssetCategories {
2664 protected ClearAssetCategories(
2665 AssetEntryPersistenceImpl persistenceImpl) {
2666 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
2667 "DELETE FROM AssetEntries_AssetCategories WHERE entryId = ?",
2668 new int[] { java.sql.Types.BIGINT });
2669 }
2670
2671 protected void clear(long entryId) throws SystemException {
2672 ModelListener<com.liferay.portlet.asset.model.AssetCategory>[] assetCategoryListeners =
2673 assetCategoryPersistence.getListeners();
2674
2675 List<com.liferay.portlet.asset.model.AssetCategory> assetCategories = null;
2676
2677 if ((listeners.length > 0) || (assetCategoryListeners.length > 0)) {
2678 assetCategories = getAssetCategories(entryId);
2679
2680 for (com.liferay.portlet.asset.model.AssetCategory assetCategory : assetCategories) {
2681 for (ModelListener<AssetEntry> listener : listeners) {
2682 listener.onBeforeRemoveAssociation(entryId,
2683 com.liferay.portlet.asset.model.AssetCategory.class.getName(),
2684 assetCategory.getPrimaryKey());
2685 }
2686
2687 for (ModelListener<com.liferay.portlet.asset.model.AssetCategory> listener : assetCategoryListeners) {
2688 listener.onBeforeRemoveAssociation(assetCategory.getPrimaryKey(),
2689 AssetEntry.class.getName(), entryId);
2690 }
2691 }
2692 }
2693
2694 _sqlUpdate.update(new Object[] { new Long(entryId) });
2695
2696 if ((listeners.length > 0) || (assetCategoryListeners.length > 0)) {
2697 for (com.liferay.portlet.asset.model.AssetCategory assetCategory : assetCategories) {
2698 for (ModelListener<AssetEntry> listener : listeners) {
2699 listener.onAfterRemoveAssociation(entryId,
2700 com.liferay.portlet.asset.model.AssetCategory.class.getName(),
2701 assetCategory.getPrimaryKey());
2702 }
2703
2704 for (ModelListener<com.liferay.portlet.asset.model.AssetCategory> listener : assetCategoryListeners) {
2705 listener.onAfterRemoveAssociation(assetCategory.getPrimaryKey(),
2706 AssetEntry.class.getName(), entryId);
2707 }
2708 }
2709 }
2710 }
2711
2712 private SqlUpdate _sqlUpdate;
2713 }
2714
2715 protected class RemoveAssetCategory {
2716 protected RemoveAssetCategory(AssetEntryPersistenceImpl persistenceImpl) {
2717 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
2718 "DELETE FROM AssetEntries_AssetCategories WHERE entryId = ? AND categoryId = ?",
2719 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
2720 _persistenceImpl = persistenceImpl;
2721 }
2722
2723 protected void remove(long entryId, long categoryId)
2724 throws SystemException {
2725 if (_persistenceImpl.containsAssetCategory.contains(entryId,
2726 categoryId)) {
2727 ModelListener<com.liferay.portlet.asset.model.AssetCategory>[] assetCategoryListeners =
2728 assetCategoryPersistence.getListeners();
2729
2730 for (ModelListener<AssetEntry> listener : listeners) {
2731 listener.onBeforeRemoveAssociation(entryId,
2732 com.liferay.portlet.asset.model.AssetCategory.class.getName(),
2733 categoryId);
2734 }
2735
2736 for (ModelListener<com.liferay.portlet.asset.model.AssetCategory> listener : assetCategoryListeners) {
2737 listener.onBeforeRemoveAssociation(categoryId,
2738 AssetEntry.class.getName(), entryId);
2739 }
2740
2741 _sqlUpdate.update(new Object[] {
2742 new Long(entryId), new Long(categoryId)
2743 });
2744
2745 for (ModelListener<AssetEntry> listener : listeners) {
2746 listener.onAfterRemoveAssociation(entryId,
2747 com.liferay.portlet.asset.model.AssetCategory.class.getName(),
2748 categoryId);
2749 }
2750
2751 for (ModelListener<com.liferay.portlet.asset.model.AssetCategory> listener : assetCategoryListeners) {
2752 listener.onAfterRemoveAssociation(categoryId,
2753 AssetEntry.class.getName(), entryId);
2754 }
2755 }
2756 }
2757
2758 private SqlUpdate _sqlUpdate;
2759 private AssetEntryPersistenceImpl _persistenceImpl;
2760 }
2761
2762 protected class ContainsAssetTag {
2763 protected ContainsAssetTag(AssetEntryPersistenceImpl persistenceImpl) {
2764 super();
2765
2766 _mappingSqlQuery = MappingSqlQueryFactoryUtil.getMappingSqlQuery(getDataSource(),
2767 _SQL_CONTAINSASSETTAG,
2768 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT },
2769 RowMapper.COUNT);
2770 }
2771
2772 protected boolean contains(long entryId, long tagId) {
2773 List<Integer> results = _mappingSqlQuery.execute(new Object[] {
2774 new Long(entryId), new Long(tagId)
2775 });
2776
2777 if (results.size() > 0) {
2778 Integer count = results.get(0);
2779
2780 if (count.intValue() > 0) {
2781 return true;
2782 }
2783 }
2784
2785 return false;
2786 }
2787
2788 private MappingSqlQuery<Integer> _mappingSqlQuery;
2789 }
2790
2791 protected class AddAssetTag {
2792 protected AddAssetTag(AssetEntryPersistenceImpl persistenceImpl) {
2793 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
2794 "INSERT INTO AssetEntries_AssetTags (entryId, tagId) VALUES (?, ?)",
2795 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
2796 _persistenceImpl = persistenceImpl;
2797 }
2798
2799 protected void add(long entryId, long tagId) throws SystemException {
2800 if (!_persistenceImpl.containsAssetTag.contains(entryId, tagId)) {
2801 ModelListener<com.liferay.portlet.asset.model.AssetTag>[] assetTagListeners =
2802 assetTagPersistence.getListeners();
2803
2804 for (ModelListener<AssetEntry> listener : listeners) {
2805 listener.onBeforeAddAssociation(entryId,
2806 com.liferay.portlet.asset.model.AssetTag.class.getName(),
2807 tagId);
2808 }
2809
2810 for (ModelListener<com.liferay.portlet.asset.model.AssetTag> listener : assetTagListeners) {
2811 listener.onBeforeAddAssociation(tagId,
2812 AssetEntry.class.getName(), entryId);
2813 }
2814
2815 _sqlUpdate.update(new Object[] {
2816 new Long(entryId), new Long(tagId)
2817 });
2818
2819 for (ModelListener<AssetEntry> listener : listeners) {
2820 listener.onAfterAddAssociation(entryId,
2821 com.liferay.portlet.asset.model.AssetTag.class.getName(),
2822 tagId);
2823 }
2824
2825 for (ModelListener<com.liferay.portlet.asset.model.AssetTag> listener : assetTagListeners) {
2826 listener.onAfterAddAssociation(tagId,
2827 AssetEntry.class.getName(), entryId);
2828 }
2829 }
2830 }
2831
2832 private SqlUpdate _sqlUpdate;
2833 private AssetEntryPersistenceImpl _persistenceImpl;
2834 }
2835
2836 protected class ClearAssetTags {
2837 protected ClearAssetTags(AssetEntryPersistenceImpl persistenceImpl) {
2838 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
2839 "DELETE FROM AssetEntries_AssetTags WHERE entryId = ?",
2840 new int[] { java.sql.Types.BIGINT });
2841 }
2842
2843 protected void clear(long entryId) throws SystemException {
2844 ModelListener<com.liferay.portlet.asset.model.AssetTag>[] assetTagListeners =
2845 assetTagPersistence.getListeners();
2846
2847 List<com.liferay.portlet.asset.model.AssetTag> assetTags = null;
2848
2849 if ((listeners.length > 0) || (assetTagListeners.length > 0)) {
2850 assetTags = getAssetTags(entryId);
2851
2852 for (com.liferay.portlet.asset.model.AssetTag assetTag : assetTags) {
2853 for (ModelListener<AssetEntry> listener : listeners) {
2854 listener.onBeforeRemoveAssociation(entryId,
2855 com.liferay.portlet.asset.model.AssetTag.class.getName(),
2856 assetTag.getPrimaryKey());
2857 }
2858
2859 for (ModelListener<com.liferay.portlet.asset.model.AssetTag> listener : assetTagListeners) {
2860 listener.onBeforeRemoveAssociation(assetTag.getPrimaryKey(),
2861 AssetEntry.class.getName(), entryId);
2862 }
2863 }
2864 }
2865
2866 _sqlUpdate.update(new Object[] { new Long(entryId) });
2867
2868 if ((listeners.length > 0) || (assetTagListeners.length > 0)) {
2869 for (com.liferay.portlet.asset.model.AssetTag assetTag : assetTags) {
2870 for (ModelListener<AssetEntry> listener : listeners) {
2871 listener.onAfterRemoveAssociation(entryId,
2872 com.liferay.portlet.asset.model.AssetTag.class.getName(),
2873 assetTag.getPrimaryKey());
2874 }
2875
2876 for (ModelListener<com.liferay.portlet.asset.model.AssetTag> listener : assetTagListeners) {
2877 listener.onAfterRemoveAssociation(assetTag.getPrimaryKey(),
2878 AssetEntry.class.getName(), entryId);
2879 }
2880 }
2881 }
2882 }
2883
2884 private SqlUpdate _sqlUpdate;
2885 }
2886
2887 protected class RemoveAssetTag {
2888 protected RemoveAssetTag(AssetEntryPersistenceImpl persistenceImpl) {
2889 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
2890 "DELETE FROM AssetEntries_AssetTags WHERE entryId = ? AND tagId = ?",
2891 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
2892 _persistenceImpl = persistenceImpl;
2893 }
2894
2895 protected void remove(long entryId, long tagId)
2896 throws SystemException {
2897 if (_persistenceImpl.containsAssetTag.contains(entryId, tagId)) {
2898 ModelListener<com.liferay.portlet.asset.model.AssetTag>[] assetTagListeners =
2899 assetTagPersistence.getListeners();
2900
2901 for (ModelListener<AssetEntry> listener : listeners) {
2902 listener.onBeforeRemoveAssociation(entryId,
2903 com.liferay.portlet.asset.model.AssetTag.class.getName(),
2904 tagId);
2905 }
2906
2907 for (ModelListener<com.liferay.portlet.asset.model.AssetTag> listener : assetTagListeners) {
2908 listener.onBeforeRemoveAssociation(tagId,
2909 AssetEntry.class.getName(), entryId);
2910 }
2911
2912 _sqlUpdate.update(new Object[] {
2913 new Long(entryId), new Long(tagId)
2914 });
2915
2916 for (ModelListener<AssetEntry> listener : listeners) {
2917 listener.onAfterRemoveAssociation(entryId,
2918 com.liferay.portlet.asset.model.AssetTag.class.getName(),
2919 tagId);
2920 }
2921
2922 for (ModelListener<com.liferay.portlet.asset.model.AssetTag> listener : assetTagListeners) {
2923 listener.onAfterRemoveAssociation(tagId,
2924 AssetEntry.class.getName(), entryId);
2925 }
2926 }
2927 }
2928
2929 private SqlUpdate _sqlUpdate;
2930 private AssetEntryPersistenceImpl _persistenceImpl;
2931 }
2932
2933 private static final String _SQL_SELECT_ASSETENTRY = "SELECT assetEntry FROM AssetEntry assetEntry";
2934 private static final String _SQL_SELECT_ASSETENTRY_WHERE = "SELECT assetEntry FROM AssetEntry assetEntry WHERE ";
2935 private static final String _SQL_COUNT_ASSETENTRY = "SELECT COUNT(assetEntry) FROM AssetEntry assetEntry";
2936 private static final String _SQL_COUNT_ASSETENTRY_WHERE = "SELECT COUNT(assetEntry) FROM AssetEntry assetEntry WHERE ";
2937 private static final String _SQL_GETASSETCATEGORIES = "SELECT {AssetCategory.*} FROM AssetCategory INNER JOIN AssetEntries_AssetCategories ON (AssetEntries_AssetCategories.categoryId = AssetCategory.categoryId) WHERE (AssetEntries_AssetCategories.entryId = ?)";
2938 private static final String _SQL_GETASSETCATEGORIESSIZE = "SELECT COUNT(*) AS COUNT_VALUE FROM AssetEntries_AssetCategories WHERE entryId = ?";
2939 private static final String _SQL_CONTAINSASSETCATEGORY = "SELECT COUNT(*) AS COUNT_VALUE FROM AssetEntries_AssetCategories WHERE entryId = ? AND categoryId = ?";
2940 private static final String _SQL_GETASSETTAGS = "SELECT {AssetTag.*} FROM AssetTag INNER JOIN AssetEntries_AssetTags ON (AssetEntries_AssetTags.tagId = AssetTag.tagId) WHERE (AssetEntries_AssetTags.entryId = ?)";
2941 private static final String _SQL_GETASSETTAGSSIZE = "SELECT COUNT(*) AS COUNT_VALUE FROM AssetEntries_AssetTags WHERE entryId = ?";
2942 private static final String _SQL_CONTAINSASSETTAG = "SELECT COUNT(*) AS COUNT_VALUE FROM AssetEntries_AssetTags WHERE entryId = ? AND tagId = ?";
2943 private static final String _FINDER_COLUMN_COMPANYID_COMPANYID_2 = "assetEntry.companyId = ?";
2944 private static final String _FINDER_COLUMN_G_CU_GROUPID_2 = "assetEntry.groupId = ? AND ";
2945 private static final String _FINDER_COLUMN_G_CU_CLASSUUID_1 = "assetEntry.classUuid IS NULL";
2946 private static final String _FINDER_COLUMN_G_CU_CLASSUUID_2 = "assetEntry.classUuid = ?";
2947 private static final String _FINDER_COLUMN_G_CU_CLASSUUID_3 = "(assetEntry.classUuid IS NULL OR assetEntry.classUuid = ?)";
2948 private static final String _FINDER_COLUMN_C_C_CLASSNAMEID_2 = "assetEntry.classNameId = ? AND ";
2949 private static final String _FINDER_COLUMN_C_C_CLASSPK_2 = "assetEntry.classPK = ?";
2950 private static final String _ORDER_BY_ENTITY_ALIAS = "assetEntry.";
2951 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No AssetEntry exists with the primary key ";
2952 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No AssetEntry exists with the key {";
2953 private static Log _log = LogFactoryUtil.getLog(AssetEntryPersistenceImpl.class);
2954 }