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.model.ModelListener;
044 import com.liferay.portal.security.permission.InlineSQLHelperUtil;
045 import com.liferay.portal.service.persistence.BatchSessionUtil;
046 import com.liferay.portal.service.persistence.ResourcePersistence;
047 import com.liferay.portal.service.persistence.UserPersistence;
048 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
049
050 import com.liferay.portlet.asset.NoSuchTagException;
051 import com.liferay.portlet.asset.model.AssetTag;
052 import com.liferay.portlet.asset.model.impl.AssetTagImpl;
053 import com.liferay.portlet.asset.model.impl.AssetTagModelImpl;
054
055 import java.io.Serializable;
056
057 import java.util.ArrayList;
058 import java.util.Collections;
059 import java.util.List;
060 import java.util.Set;
061
062
078 public class AssetTagPersistenceImpl extends BasePersistenceImpl<AssetTag>
079 implements AssetTagPersistence {
080 public static final String FINDER_CLASS_NAME_ENTITY = AssetTagImpl.class.getName();
081 public static final String FINDER_CLASS_NAME_LIST = FINDER_CLASS_NAME_ENTITY +
082 ".List";
083 public static final FinderPath FINDER_PATH_FIND_BY_GROUPID = new FinderPath(AssetTagModelImpl.ENTITY_CACHE_ENABLED,
084 AssetTagModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
085 "findByGroupId",
086 new String[] {
087 Long.class.getName(),
088
089 "java.lang.Integer", "java.lang.Integer",
090 "com.liferay.portal.kernel.util.OrderByComparator"
091 });
092 public static final FinderPath FINDER_PATH_COUNT_BY_GROUPID = new FinderPath(AssetTagModelImpl.ENTITY_CACHE_ENABLED,
093 AssetTagModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
094 "countByGroupId", new String[] { Long.class.getName() });
095 public static final FinderPath FINDER_PATH_FIND_ALL = new FinderPath(AssetTagModelImpl.ENTITY_CACHE_ENABLED,
096 AssetTagModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
097 "findAll", new String[0]);
098 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(AssetTagModelImpl.ENTITY_CACHE_ENABLED,
099 AssetTagModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
100 "countAll", new String[0]);
101
102
107 public void cacheResult(AssetTag assetTag) {
108 EntityCacheUtil.putResult(AssetTagModelImpl.ENTITY_CACHE_ENABLED,
109 AssetTagImpl.class, assetTag.getPrimaryKey(), assetTag);
110 }
111
112
117 public void cacheResult(List<AssetTag> assetTags) {
118 for (AssetTag assetTag : assetTags) {
119 if (EntityCacheUtil.getResult(
120 AssetTagModelImpl.ENTITY_CACHE_ENABLED,
121 AssetTagImpl.class, assetTag.getPrimaryKey(), this) == null) {
122 cacheResult(assetTag);
123 }
124 }
125 }
126
127
134 public void clearCache() {
135 CacheRegistryUtil.clear(AssetTagImpl.class.getName());
136 EntityCacheUtil.clearCache(AssetTagImpl.class.getName());
137 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
138 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
139 }
140
141
148 public void clearCache(AssetTag assetTag) {
149 EntityCacheUtil.removeResult(AssetTagModelImpl.ENTITY_CACHE_ENABLED,
150 AssetTagImpl.class, assetTag.getPrimaryKey());
151 }
152
153
159 public AssetTag create(long tagId) {
160 AssetTag assetTag = new AssetTagImpl();
161
162 assetTag.setNew(true);
163 assetTag.setPrimaryKey(tagId);
164
165 return assetTag;
166 }
167
168
176 public AssetTag remove(Serializable primaryKey)
177 throws NoSuchModelException, SystemException {
178 return remove(((Long)primaryKey).longValue());
179 }
180
181
189 public AssetTag remove(long tagId)
190 throws NoSuchTagException, SystemException {
191 Session session = null;
192
193 try {
194 session = openSession();
195
196 AssetTag assetTag = (AssetTag)session.get(AssetTagImpl.class,
197 new Long(tagId));
198
199 if (assetTag == null) {
200 if (_log.isWarnEnabled()) {
201 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + tagId);
202 }
203
204 throw new NoSuchTagException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
205 tagId);
206 }
207
208 return remove(assetTag);
209 }
210 catch (NoSuchTagException nsee) {
211 throw nsee;
212 }
213 catch (Exception e) {
214 throw processException(e);
215 }
216 finally {
217 closeSession(session);
218 }
219 }
220
221 protected AssetTag removeImpl(AssetTag assetTag) throws SystemException {
222 assetTag = toUnwrappedModel(assetTag);
223
224 try {
225 clearAssetEntries.clear(assetTag.getPrimaryKey());
226 }
227 catch (Exception e) {
228 throw processException(e);
229 }
230 finally {
231 FinderCacheUtil.clearCache(AssetTagModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETTAGS_NAME);
232 }
233
234 Session session = null;
235
236 try {
237 session = openSession();
238
239 BatchSessionUtil.delete(session, assetTag);
240 }
241 catch (Exception e) {
242 throw processException(e);
243 }
244 finally {
245 closeSession(session);
246 }
247
248 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
249
250 EntityCacheUtil.removeResult(AssetTagModelImpl.ENTITY_CACHE_ENABLED,
251 AssetTagImpl.class, assetTag.getPrimaryKey());
252
253 return assetTag;
254 }
255
256 public AssetTag updateImpl(
257 com.liferay.portlet.asset.model.AssetTag assetTag, boolean merge)
258 throws SystemException {
259 assetTag = toUnwrappedModel(assetTag);
260
261 Session session = null;
262
263 try {
264 session = openSession();
265
266 BatchSessionUtil.update(session, assetTag, merge);
267
268 assetTag.setNew(false);
269 }
270 catch (Exception e) {
271 throw processException(e);
272 }
273 finally {
274 closeSession(session);
275 }
276
277 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
278
279 EntityCacheUtil.putResult(AssetTagModelImpl.ENTITY_CACHE_ENABLED,
280 AssetTagImpl.class, assetTag.getPrimaryKey(), assetTag);
281
282 return assetTag;
283 }
284
285 protected AssetTag toUnwrappedModel(AssetTag assetTag) {
286 if (assetTag instanceof AssetTagImpl) {
287 return assetTag;
288 }
289
290 AssetTagImpl assetTagImpl = new AssetTagImpl();
291
292 assetTagImpl.setNew(assetTag.isNew());
293 assetTagImpl.setPrimaryKey(assetTag.getPrimaryKey());
294
295 assetTagImpl.setTagId(assetTag.getTagId());
296 assetTagImpl.setGroupId(assetTag.getGroupId());
297 assetTagImpl.setCompanyId(assetTag.getCompanyId());
298 assetTagImpl.setUserId(assetTag.getUserId());
299 assetTagImpl.setUserName(assetTag.getUserName());
300 assetTagImpl.setCreateDate(assetTag.getCreateDate());
301 assetTagImpl.setModifiedDate(assetTag.getModifiedDate());
302 assetTagImpl.setName(assetTag.getName());
303 assetTagImpl.setAssetCount(assetTag.getAssetCount());
304
305 return assetTagImpl;
306 }
307
308
316 public AssetTag findByPrimaryKey(Serializable primaryKey)
317 throws NoSuchModelException, SystemException {
318 return findByPrimaryKey(((Long)primaryKey).longValue());
319 }
320
321
329 public AssetTag findByPrimaryKey(long tagId)
330 throws NoSuchTagException, SystemException {
331 AssetTag assetTag = fetchByPrimaryKey(tagId);
332
333 if (assetTag == null) {
334 if (_log.isWarnEnabled()) {
335 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + tagId);
336 }
337
338 throw new NoSuchTagException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
339 tagId);
340 }
341
342 return assetTag;
343 }
344
345
352 public AssetTag fetchByPrimaryKey(Serializable primaryKey)
353 throws SystemException {
354 return fetchByPrimaryKey(((Long)primaryKey).longValue());
355 }
356
357
364 public AssetTag fetchByPrimaryKey(long tagId) throws SystemException {
365 AssetTag assetTag = (AssetTag)EntityCacheUtil.getResult(AssetTagModelImpl.ENTITY_CACHE_ENABLED,
366 AssetTagImpl.class, tagId, this);
367
368 if (assetTag == null) {
369 Session session = null;
370
371 try {
372 session = openSession();
373
374 assetTag = (AssetTag)session.get(AssetTagImpl.class,
375 new Long(tagId));
376 }
377 catch (Exception e) {
378 throw processException(e);
379 }
380 finally {
381 if (assetTag != null) {
382 cacheResult(assetTag);
383 }
384
385 closeSession(session);
386 }
387 }
388
389 return assetTag;
390 }
391
392
399 public List<AssetTag> findByGroupId(long groupId) throws SystemException {
400 return findByGroupId(groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
401 }
402
403
416 public List<AssetTag> findByGroupId(long groupId, int start, int end)
417 throws SystemException {
418 return findByGroupId(groupId, start, end, null);
419 }
420
421
435 public List<AssetTag> findByGroupId(long groupId, int start, int end,
436 OrderByComparator orderByComparator) throws SystemException {
437 Object[] finderArgs = new Object[] {
438 groupId,
439
440 String.valueOf(start), String.valueOf(end),
441 String.valueOf(orderByComparator)
442 };
443
444 List<AssetTag> list = (List<AssetTag>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_GROUPID,
445 finderArgs, this);
446
447 if (list == null) {
448 Session session = null;
449
450 try {
451 session = openSession();
452
453 StringBundler query = null;
454
455 if (orderByComparator != null) {
456 query = new StringBundler(3 +
457 (orderByComparator.getOrderByFields().length * 3));
458 }
459 else {
460 query = new StringBundler(3);
461 }
462
463 query.append(_SQL_SELECT_ASSETTAG_WHERE);
464
465 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
466
467 if (orderByComparator != null) {
468 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
469 orderByComparator);
470 }
471
472 else {
473 query.append(AssetTagModelImpl.ORDER_BY_JPQL);
474 }
475
476 String sql = query.toString();
477
478 Query q = session.createQuery(sql);
479
480 QueryPos qPos = QueryPos.getInstance(q);
481
482 qPos.add(groupId);
483
484 list = (List<AssetTag>)QueryUtil.list(q, getDialect(), start,
485 end);
486 }
487 catch (Exception e) {
488 throw processException(e);
489 }
490 finally {
491 if (list == null) {
492 list = new ArrayList<AssetTag>();
493 }
494
495 cacheResult(list);
496
497 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_GROUPID,
498 finderArgs, list);
499
500 closeSession(session);
501 }
502 }
503
504 return list;
505 }
506
507
520 public AssetTag findByGroupId_First(long groupId,
521 OrderByComparator orderByComparator)
522 throws NoSuchTagException, SystemException {
523 List<AssetTag> list = findByGroupId(groupId, 0, 1, orderByComparator);
524
525 if (list.isEmpty()) {
526 StringBundler msg = new StringBundler(4);
527
528 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
529
530 msg.append("groupId=");
531 msg.append(groupId);
532
533 msg.append(StringPool.CLOSE_CURLY_BRACE);
534
535 throw new NoSuchTagException(msg.toString());
536 }
537 else {
538 return list.get(0);
539 }
540 }
541
542
555 public AssetTag findByGroupId_Last(long groupId,
556 OrderByComparator orderByComparator)
557 throws NoSuchTagException, SystemException {
558 int count = countByGroupId(groupId);
559
560 List<AssetTag> list = findByGroupId(groupId, count - 1, count,
561 orderByComparator);
562
563 if (list.isEmpty()) {
564 StringBundler msg = new StringBundler(4);
565
566 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
567
568 msg.append("groupId=");
569 msg.append(groupId);
570
571 msg.append(StringPool.CLOSE_CURLY_BRACE);
572
573 throw new NoSuchTagException(msg.toString());
574 }
575 else {
576 return list.get(0);
577 }
578 }
579
580
594 public AssetTag[] findByGroupId_PrevAndNext(long tagId, long groupId,
595 OrderByComparator orderByComparator)
596 throws NoSuchTagException, SystemException {
597 AssetTag assetTag = findByPrimaryKey(tagId);
598
599 Session session = null;
600
601 try {
602 session = openSession();
603
604 AssetTag[] array = new AssetTagImpl[3];
605
606 array[0] = getByGroupId_PrevAndNext(session, assetTag, groupId,
607 orderByComparator, true);
608
609 array[1] = assetTag;
610
611 array[2] = getByGroupId_PrevAndNext(session, assetTag, groupId,
612 orderByComparator, false);
613
614 return array;
615 }
616 catch (Exception e) {
617 throw processException(e);
618 }
619 finally {
620 closeSession(session);
621 }
622 }
623
624 protected AssetTag getByGroupId_PrevAndNext(Session session,
625 AssetTag assetTag, long groupId, OrderByComparator orderByComparator,
626 boolean previous) {
627 StringBundler query = null;
628
629 if (orderByComparator != null) {
630 query = new StringBundler(6 +
631 (orderByComparator.getOrderByFields().length * 6));
632 }
633 else {
634 query = new StringBundler(3);
635 }
636
637 query.append(_SQL_SELECT_ASSETTAG_WHERE);
638
639 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
640
641 if (orderByComparator != null) {
642 String[] orderByFields = orderByComparator.getOrderByFields();
643
644 if (orderByFields.length > 0) {
645 query.append(WHERE_AND);
646 }
647
648 for (int i = 0; i < orderByFields.length; i++) {
649 query.append(_ORDER_BY_ENTITY_ALIAS);
650 query.append(orderByFields[i]);
651
652 if ((i + 1) < orderByFields.length) {
653 if (orderByComparator.isAscending() ^ previous) {
654 query.append(WHERE_GREATER_THAN_HAS_NEXT);
655 }
656 else {
657 query.append(WHERE_LESSER_THAN_HAS_NEXT);
658 }
659 }
660 else {
661 if (orderByComparator.isAscending() ^ previous) {
662 query.append(WHERE_GREATER_THAN);
663 }
664 else {
665 query.append(WHERE_LESSER_THAN);
666 }
667 }
668 }
669
670 query.append(ORDER_BY_CLAUSE);
671
672 for (int i = 0; i < orderByFields.length; i++) {
673 query.append(_ORDER_BY_ENTITY_ALIAS);
674 query.append(orderByFields[i]);
675
676 if ((i + 1) < orderByFields.length) {
677 if (orderByComparator.isAscending() ^ previous) {
678 query.append(ORDER_BY_ASC_HAS_NEXT);
679 }
680 else {
681 query.append(ORDER_BY_DESC_HAS_NEXT);
682 }
683 }
684 else {
685 if (orderByComparator.isAscending() ^ previous) {
686 query.append(ORDER_BY_ASC);
687 }
688 else {
689 query.append(ORDER_BY_DESC);
690 }
691 }
692 }
693 }
694
695 else {
696 query.append(AssetTagModelImpl.ORDER_BY_JPQL);
697 }
698
699 String sql = query.toString();
700
701 Query q = session.createQuery(sql);
702
703 q.setFirstResult(0);
704 q.setMaxResults(2);
705
706 QueryPos qPos = QueryPos.getInstance(q);
707
708 qPos.add(groupId);
709
710 if (orderByComparator != null) {
711 Object[] values = orderByComparator.getOrderByValues(assetTag);
712
713 for (Object value : values) {
714 qPos.add(value);
715 }
716 }
717
718 List<AssetTag> list = q.list();
719
720 if (list.size() == 2) {
721 return list.get(1);
722 }
723 else {
724 return null;
725 }
726 }
727
728
735 public List<AssetTag> filterFindByGroupId(long groupId)
736 throws SystemException {
737 return filterFindByGroupId(groupId, QueryUtil.ALL_POS,
738 QueryUtil.ALL_POS, null);
739 }
740
741
754 public List<AssetTag> filterFindByGroupId(long groupId, int start, int end)
755 throws SystemException {
756 return filterFindByGroupId(groupId, start, end, null);
757 }
758
759
773 public List<AssetTag> filterFindByGroupId(long groupId, int start, int end,
774 OrderByComparator orderByComparator) throws SystemException {
775 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
776 return findByGroupId(groupId, start, end, orderByComparator);
777 }
778
779 Session session = null;
780
781 try {
782 session = openSession();
783
784 StringBundler query = null;
785
786 if (orderByComparator != null) {
787 query = new StringBundler(3 +
788 (orderByComparator.getOrderByFields().length * 3));
789 }
790 else {
791 query = new StringBundler(3);
792 }
793
794 if (getDB().isSupportsInlineDistinct()) {
795 query.append(_FILTER_SQL_SELECT_ASSETTAG_WHERE);
796 }
797 else {
798 query.append(_FILTER_SQL_SELECT_ASSETTAG_NO_INLINE_DISTINCT_WHERE);
799 }
800
801 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
802
803 if (orderByComparator != null) {
804 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
805 orderByComparator);
806 }
807
808 else {
809 query.append(AssetTagModelImpl.ORDER_BY_JPQL);
810 }
811
812 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
813 AssetTag.class.getName(), _FILTER_COLUMN_PK,
814 _FILTER_COLUMN_USERID, groupId);
815
816 SQLQuery q = session.createSQLQuery(sql);
817
818 q.addEntity(_FILTER_ENTITY_ALIAS, AssetTagImpl.class);
819
820 QueryPos qPos = QueryPos.getInstance(q);
821
822 qPos.add(groupId);
823
824 return (List<AssetTag>)QueryUtil.list(q, getDialect(), start, end);
825 }
826 catch (Exception e) {
827 throw processException(e);
828 }
829 finally {
830 closeSession(session);
831 }
832 }
833
834
840 public List<AssetTag> findAll() throws SystemException {
841 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
842 }
843
844
856 public List<AssetTag> findAll(int start, int end) throws SystemException {
857 return findAll(start, end, null);
858 }
859
860
873 public List<AssetTag> findAll(int start, int end,
874 OrderByComparator orderByComparator) throws SystemException {
875 Object[] finderArgs = new Object[] {
876 String.valueOf(start), String.valueOf(end),
877 String.valueOf(orderByComparator)
878 };
879
880 List<AssetTag> list = (List<AssetTag>)FinderCacheUtil.getResult(FINDER_PATH_FIND_ALL,
881 finderArgs, this);
882
883 if (list == null) {
884 Session session = null;
885
886 try {
887 session = openSession();
888
889 StringBundler query = null;
890 String sql = null;
891
892 if (orderByComparator != null) {
893 query = new StringBundler(2 +
894 (orderByComparator.getOrderByFields().length * 3));
895
896 query.append(_SQL_SELECT_ASSETTAG);
897
898 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
899 orderByComparator);
900
901 sql = query.toString();
902 }
903 else {
904 sql = _SQL_SELECT_ASSETTAG.concat(AssetTagModelImpl.ORDER_BY_JPQL);
905 }
906
907 Query q = session.createQuery(sql);
908
909 if (orderByComparator == null) {
910 list = (List<AssetTag>)QueryUtil.list(q, getDialect(),
911 start, end, false);
912
913 Collections.sort(list);
914 }
915 else {
916 list = (List<AssetTag>)QueryUtil.list(q, getDialect(),
917 start, end);
918 }
919 }
920 catch (Exception e) {
921 throw processException(e);
922 }
923 finally {
924 if (list == null) {
925 list = new ArrayList<AssetTag>();
926 }
927
928 cacheResult(list);
929
930 FinderCacheUtil.putResult(FINDER_PATH_FIND_ALL, finderArgs, list);
931
932 closeSession(session);
933 }
934 }
935
936 return list;
937 }
938
939
945 public void removeByGroupId(long groupId) throws SystemException {
946 for (AssetTag assetTag : findByGroupId(groupId)) {
947 remove(assetTag);
948 }
949 }
950
951
956 public void removeAll() throws SystemException {
957 for (AssetTag assetTag : findAll()) {
958 remove(assetTag);
959 }
960 }
961
962
969 public int countByGroupId(long groupId) throws SystemException {
970 Object[] finderArgs = new Object[] { groupId };
971
972 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_GROUPID,
973 finderArgs, this);
974
975 if (count == null) {
976 Session session = null;
977
978 try {
979 session = openSession();
980
981 StringBundler query = new StringBundler(2);
982
983 query.append(_SQL_COUNT_ASSETTAG_WHERE);
984
985 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
986
987 String sql = query.toString();
988
989 Query q = session.createQuery(sql);
990
991 QueryPos qPos = QueryPos.getInstance(q);
992
993 qPos.add(groupId);
994
995 count = (Long)q.uniqueResult();
996 }
997 catch (Exception e) {
998 throw processException(e);
999 }
1000 finally {
1001 if (count == null) {
1002 count = Long.valueOf(0);
1003 }
1004
1005 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_GROUPID,
1006 finderArgs, count);
1007
1008 closeSession(session);
1009 }
1010 }
1011
1012 return count.intValue();
1013 }
1014
1015
1022 public int filterCountByGroupId(long groupId) throws SystemException {
1023 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
1024 return countByGroupId(groupId);
1025 }
1026
1027 Session session = null;
1028
1029 try {
1030 session = openSession();
1031
1032 StringBundler query = new StringBundler(2);
1033
1034 query.append(_FILTER_SQL_COUNT_ASSETTAG_WHERE);
1035
1036 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1037
1038 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1039 AssetTag.class.getName(), _FILTER_COLUMN_PK,
1040 _FILTER_COLUMN_USERID, groupId);
1041
1042 SQLQuery q = session.createSQLQuery(sql);
1043
1044 q.addScalar(COUNT_COLUMN_NAME,
1045 com.liferay.portal.kernel.dao.orm.Type.LONG);
1046
1047 QueryPos qPos = QueryPos.getInstance(q);
1048
1049 qPos.add(groupId);
1050
1051 Long count = (Long)q.uniqueResult();
1052
1053 return count.intValue();
1054 }
1055 catch (Exception e) {
1056 throw processException(e);
1057 }
1058 finally {
1059 closeSession(session);
1060 }
1061 }
1062
1063
1069 public int countAll() throws SystemException {
1070 Object[] finderArgs = new Object[0];
1071
1072 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
1073 finderArgs, this);
1074
1075 if (count == null) {
1076 Session session = null;
1077
1078 try {
1079 session = openSession();
1080
1081 Query q = session.createQuery(_SQL_COUNT_ASSETTAG);
1082
1083 count = (Long)q.uniqueResult();
1084 }
1085 catch (Exception e) {
1086 throw processException(e);
1087 }
1088 finally {
1089 if (count == null) {
1090 count = Long.valueOf(0);
1091 }
1092
1093 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL, finderArgs,
1094 count);
1095
1096 closeSession(session);
1097 }
1098 }
1099
1100 return count.intValue();
1101 }
1102
1103
1110 public List<com.liferay.portlet.asset.model.AssetEntry> getAssetEntries(
1111 long pk) throws SystemException {
1112 return getAssetEntries(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
1113 }
1114
1115
1128 public List<com.liferay.portlet.asset.model.AssetEntry> getAssetEntries(
1129 long pk, int start, int end) throws SystemException {
1130 return getAssetEntries(pk, start, end, null);
1131 }
1132
1133 public static final FinderPath FINDER_PATH_GET_ASSETENTRIES = new FinderPath(com.liferay.portlet.asset.model.impl.AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
1134 AssetTagModelImpl.FINDER_CACHE_ENABLED_ASSETENTRIES_ASSETTAGS,
1135 AssetTagModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETTAGS_NAME,
1136 "getAssetEntries",
1137 new String[] {
1138 Long.class.getName(), "java.lang.Integer", "java.lang.Integer",
1139 "com.liferay.portal.kernel.util.OrderByComparator"
1140 });
1141
1142
1156 public List<com.liferay.portlet.asset.model.AssetEntry> getAssetEntries(
1157 long pk, int start, int end, OrderByComparator orderByComparator)
1158 throws SystemException {
1159 Object[] finderArgs = new Object[] {
1160 pk, String.valueOf(start), String.valueOf(end),
1161 String.valueOf(orderByComparator)
1162 };
1163
1164 List<com.liferay.portlet.asset.model.AssetEntry> list = (List<com.liferay.portlet.asset.model.AssetEntry>)FinderCacheUtil.getResult(FINDER_PATH_GET_ASSETENTRIES,
1165 finderArgs, this);
1166
1167 if (list == null) {
1168 Session session = null;
1169
1170 try {
1171 session = openSession();
1172
1173 String sql = null;
1174
1175 if (orderByComparator != null) {
1176 sql = _SQL_GETASSETENTRIES.concat(ORDER_BY_CLAUSE)
1177 .concat(orderByComparator.getOrderBy());
1178 }
1179 else {
1180 sql = _SQL_GETASSETENTRIES;
1181 }
1182
1183 SQLQuery q = session.createSQLQuery(sql);
1184
1185 q.addEntity("AssetEntry",
1186 com.liferay.portlet.asset.model.impl.AssetEntryImpl.class);
1187
1188 QueryPos qPos = QueryPos.getInstance(q);
1189
1190 qPos.add(pk);
1191
1192 list = (List<com.liferay.portlet.asset.model.AssetEntry>)QueryUtil.list(q,
1193 getDialect(), start, end);
1194 }
1195 catch (Exception e) {
1196 throw processException(e);
1197 }
1198 finally {
1199 if (list == null) {
1200 list = new ArrayList<com.liferay.portlet.asset.model.AssetEntry>();
1201 }
1202
1203 assetEntryPersistence.cacheResult(list);
1204
1205 FinderCacheUtil.putResult(FINDER_PATH_GET_ASSETENTRIES,
1206 finderArgs, list);
1207
1208 closeSession(session);
1209 }
1210 }
1211
1212 return list;
1213 }
1214
1215 public static final FinderPath FINDER_PATH_GET_ASSETENTRIES_SIZE = new FinderPath(com.liferay.portlet.asset.model.impl.AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
1216 AssetTagModelImpl.FINDER_CACHE_ENABLED_ASSETENTRIES_ASSETTAGS,
1217 AssetTagModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETTAGS_NAME,
1218 "getAssetEntriesSize", new String[] { Long.class.getName() });
1219
1220
1227 public int getAssetEntriesSize(long pk) throws SystemException {
1228 Object[] finderArgs = new Object[] { pk };
1229
1230 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_GET_ASSETENTRIES_SIZE,
1231 finderArgs, this);
1232
1233 if (count == null) {
1234 Session session = null;
1235
1236 try {
1237 session = openSession();
1238
1239 SQLQuery q = session.createSQLQuery(_SQL_GETASSETENTRIESSIZE);
1240
1241 q.addScalar(COUNT_COLUMN_NAME,
1242 com.liferay.portal.kernel.dao.orm.Type.LONG);
1243
1244 QueryPos qPos = QueryPos.getInstance(q);
1245
1246 qPos.add(pk);
1247
1248 count = (Long)q.uniqueResult();
1249 }
1250 catch (Exception e) {
1251 throw processException(e);
1252 }
1253 finally {
1254 if (count == null) {
1255 count = Long.valueOf(0);
1256 }
1257
1258 FinderCacheUtil.putResult(FINDER_PATH_GET_ASSETENTRIES_SIZE,
1259 finderArgs, count);
1260
1261 closeSession(session);
1262 }
1263 }
1264
1265 return count.intValue();
1266 }
1267
1268 public static final FinderPath FINDER_PATH_CONTAINS_ASSETENTRY = new FinderPath(com.liferay.portlet.asset.model.impl.AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
1269 AssetTagModelImpl.FINDER_CACHE_ENABLED_ASSETENTRIES_ASSETTAGS,
1270 AssetTagModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETTAGS_NAME,
1271 "containsAssetEntry",
1272 new String[] { Long.class.getName(), Long.class.getName() });
1273
1274
1282 public boolean containsAssetEntry(long pk, long assetEntryPK)
1283 throws SystemException {
1284 Object[] finderArgs = new Object[] { pk, assetEntryPK };
1285
1286 Boolean value = (Boolean)FinderCacheUtil.getResult(FINDER_PATH_CONTAINS_ASSETENTRY,
1287 finderArgs, this);
1288
1289 if (value == null) {
1290 try {
1291 value = Boolean.valueOf(containsAssetEntry.contains(pk,
1292 assetEntryPK));
1293 }
1294 catch (Exception e) {
1295 throw processException(e);
1296 }
1297 finally {
1298 if (value == null) {
1299 value = Boolean.FALSE;
1300 }
1301
1302 FinderCacheUtil.putResult(FINDER_PATH_CONTAINS_ASSETENTRY,
1303 finderArgs, value);
1304 }
1305 }
1306
1307 return value.booleanValue();
1308 }
1309
1310
1317 public boolean containsAssetEntries(long pk) throws SystemException {
1318 if (getAssetEntriesSize(pk) > 0) {
1319 return true;
1320 }
1321 else {
1322 return false;
1323 }
1324 }
1325
1326
1333 public void addAssetEntry(long pk, long assetEntryPK)
1334 throws SystemException {
1335 try {
1336 addAssetEntry.add(pk, assetEntryPK);
1337 }
1338 catch (Exception e) {
1339 throw processException(e);
1340 }
1341 finally {
1342 FinderCacheUtil.clearCache(AssetTagModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETTAGS_NAME);
1343 }
1344 }
1345
1346
1353 public void addAssetEntry(long pk,
1354 com.liferay.portlet.asset.model.AssetEntry assetEntry)
1355 throws SystemException {
1356 try {
1357 addAssetEntry.add(pk, assetEntry.getPrimaryKey());
1358 }
1359 catch (Exception e) {
1360 throw processException(e);
1361 }
1362 finally {
1363 FinderCacheUtil.clearCache(AssetTagModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETTAGS_NAME);
1364 }
1365 }
1366
1367
1374 public void addAssetEntries(long pk, long[] assetEntryPKs)
1375 throws SystemException {
1376 try {
1377 for (long assetEntryPK : assetEntryPKs) {
1378 addAssetEntry.add(pk, assetEntryPK);
1379 }
1380 }
1381 catch (Exception e) {
1382 throw processException(e);
1383 }
1384 finally {
1385 FinderCacheUtil.clearCache(AssetTagModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETTAGS_NAME);
1386 }
1387 }
1388
1389
1396 public void addAssetEntries(long pk,
1397 List<com.liferay.portlet.asset.model.AssetEntry> assetEntries)
1398 throws SystemException {
1399 try {
1400 for (com.liferay.portlet.asset.model.AssetEntry assetEntry : assetEntries) {
1401 addAssetEntry.add(pk, assetEntry.getPrimaryKey());
1402 }
1403 }
1404 catch (Exception e) {
1405 throw processException(e);
1406 }
1407 finally {
1408 FinderCacheUtil.clearCache(AssetTagModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETTAGS_NAME);
1409 }
1410 }
1411
1412
1418 public void clearAssetEntries(long pk) throws SystemException {
1419 try {
1420 clearAssetEntries.clear(pk);
1421 }
1422 catch (Exception e) {
1423 throw processException(e);
1424 }
1425 finally {
1426 FinderCacheUtil.clearCache(AssetTagModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETTAGS_NAME);
1427 }
1428 }
1429
1430
1437 public void removeAssetEntry(long pk, long assetEntryPK)
1438 throws SystemException {
1439 try {
1440 removeAssetEntry.remove(pk, assetEntryPK);
1441 }
1442 catch (Exception e) {
1443 throw processException(e);
1444 }
1445 finally {
1446 FinderCacheUtil.clearCache(AssetTagModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETTAGS_NAME);
1447 }
1448 }
1449
1450
1457 public void removeAssetEntry(long pk,
1458 com.liferay.portlet.asset.model.AssetEntry assetEntry)
1459 throws SystemException {
1460 try {
1461 removeAssetEntry.remove(pk, assetEntry.getPrimaryKey());
1462 }
1463 catch (Exception e) {
1464 throw processException(e);
1465 }
1466 finally {
1467 FinderCacheUtil.clearCache(AssetTagModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETTAGS_NAME);
1468 }
1469 }
1470
1471
1478 public void removeAssetEntries(long pk, long[] assetEntryPKs)
1479 throws SystemException {
1480 try {
1481 for (long assetEntryPK : assetEntryPKs) {
1482 removeAssetEntry.remove(pk, assetEntryPK);
1483 }
1484 }
1485 catch (Exception e) {
1486 throw processException(e);
1487 }
1488 finally {
1489 FinderCacheUtil.clearCache(AssetTagModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETTAGS_NAME);
1490 }
1491 }
1492
1493
1500 public void removeAssetEntries(long pk,
1501 List<com.liferay.portlet.asset.model.AssetEntry> assetEntries)
1502 throws SystemException {
1503 try {
1504 for (com.liferay.portlet.asset.model.AssetEntry assetEntry : assetEntries) {
1505 removeAssetEntry.remove(pk, assetEntry.getPrimaryKey());
1506 }
1507 }
1508 catch (Exception e) {
1509 throw processException(e);
1510 }
1511 finally {
1512 FinderCacheUtil.clearCache(AssetTagModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETTAGS_NAME);
1513 }
1514 }
1515
1516
1523 public void setAssetEntries(long pk, long[] assetEntryPKs)
1524 throws SystemException {
1525 try {
1526 Set<Long> assetEntryPKSet = SetUtil.fromArray(assetEntryPKs);
1527
1528 List<com.liferay.portlet.asset.model.AssetEntry> assetEntries = getAssetEntries(pk);
1529
1530 for (com.liferay.portlet.asset.model.AssetEntry assetEntry : assetEntries) {
1531 if (!assetEntryPKSet.remove(assetEntry.getPrimaryKey())) {
1532 removeAssetEntry.remove(pk, assetEntry.getPrimaryKey());
1533 }
1534 }
1535
1536 for (Long assetEntryPK : assetEntryPKSet) {
1537 addAssetEntry.add(pk, assetEntryPK);
1538 }
1539 }
1540 catch (Exception e) {
1541 throw processException(e);
1542 }
1543 finally {
1544 FinderCacheUtil.clearCache(AssetTagModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETTAGS_NAME);
1545 }
1546 }
1547
1548
1555 public void setAssetEntries(long pk,
1556 List<com.liferay.portlet.asset.model.AssetEntry> assetEntries)
1557 throws SystemException {
1558 try {
1559 long[] assetEntryPKs = new long[assetEntries.size()];
1560
1561 for (int i = 0; i < assetEntries.size(); i++) {
1562 com.liferay.portlet.asset.model.AssetEntry assetEntry = assetEntries.get(i);
1563
1564 assetEntryPKs[i] = assetEntry.getPrimaryKey();
1565 }
1566
1567 setAssetEntries(pk, assetEntryPKs);
1568 }
1569 catch (Exception e) {
1570 throw processException(e);
1571 }
1572 finally {
1573 FinderCacheUtil.clearCache(AssetTagModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETTAGS_NAME);
1574 }
1575 }
1576
1577
1580 public void afterPropertiesSet() {
1581 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
1582 com.liferay.portal.util.PropsUtil.get(
1583 "value.object.listener.com.liferay.portlet.asset.model.AssetTag")));
1584
1585 if (listenerClassNames.length > 0) {
1586 try {
1587 List<ModelListener<AssetTag>> listenersList = new ArrayList<ModelListener<AssetTag>>();
1588
1589 for (String listenerClassName : listenerClassNames) {
1590 listenersList.add((ModelListener<AssetTag>)InstanceFactory.newInstance(
1591 listenerClassName));
1592 }
1593
1594 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
1595 }
1596 catch (Exception e) {
1597 _log.error(e);
1598 }
1599 }
1600
1601 containsAssetEntry = new ContainsAssetEntry(this);
1602
1603 addAssetEntry = new AddAssetEntry(this);
1604 clearAssetEntries = new ClearAssetEntries(this);
1605 removeAssetEntry = new RemoveAssetEntry(this);
1606 }
1607
1608 public void destroy() {
1609 EntityCacheUtil.removeCache(AssetTagImpl.class.getName());
1610 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
1611 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST);
1612 }
1613
1614 @BeanReference(type = AssetCategoryPersistence.class)
1615 protected AssetCategoryPersistence assetCategoryPersistence;
1616 @BeanReference(type = AssetCategoryPropertyPersistence.class)
1617 protected AssetCategoryPropertyPersistence assetCategoryPropertyPersistence;
1618 @BeanReference(type = AssetEntryPersistence.class)
1619 protected AssetEntryPersistence assetEntryPersistence;
1620 @BeanReference(type = AssetLinkPersistence.class)
1621 protected AssetLinkPersistence assetLinkPersistence;
1622 @BeanReference(type = AssetTagPersistence.class)
1623 protected AssetTagPersistence assetTagPersistence;
1624 @BeanReference(type = AssetTagPropertyPersistence.class)
1625 protected AssetTagPropertyPersistence assetTagPropertyPersistence;
1626 @BeanReference(type = AssetTagStatsPersistence.class)
1627 protected AssetTagStatsPersistence assetTagStatsPersistence;
1628 @BeanReference(type = AssetVocabularyPersistence.class)
1629 protected AssetVocabularyPersistence assetVocabularyPersistence;
1630 @BeanReference(type = ResourcePersistence.class)
1631 protected ResourcePersistence resourcePersistence;
1632 @BeanReference(type = UserPersistence.class)
1633 protected UserPersistence userPersistence;
1634 protected ContainsAssetEntry containsAssetEntry;
1635 protected AddAssetEntry addAssetEntry;
1636 protected ClearAssetEntries clearAssetEntries;
1637 protected RemoveAssetEntry removeAssetEntry;
1638
1639 protected class ContainsAssetEntry {
1640 protected ContainsAssetEntry(AssetTagPersistenceImpl persistenceImpl) {
1641 super();
1642
1643 _mappingSqlQuery = MappingSqlQueryFactoryUtil.getMappingSqlQuery(getDataSource(),
1644 _SQL_CONTAINSASSETENTRY,
1645 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT },
1646 RowMapper.COUNT);
1647 }
1648
1649 protected boolean contains(long tagId, long entryId) {
1650 List<Integer> results = _mappingSqlQuery.execute(new Object[] {
1651 new Long(tagId), new Long(entryId)
1652 });
1653
1654 if (results.size() > 0) {
1655 Integer count = results.get(0);
1656
1657 if (count.intValue() > 0) {
1658 return true;
1659 }
1660 }
1661
1662 return false;
1663 }
1664
1665 private MappingSqlQuery<Integer> _mappingSqlQuery;
1666 }
1667
1668 protected class AddAssetEntry {
1669 protected AddAssetEntry(AssetTagPersistenceImpl persistenceImpl) {
1670 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
1671 "INSERT INTO AssetEntries_AssetTags (tagId, entryId) VALUES (?, ?)",
1672 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
1673 _persistenceImpl = persistenceImpl;
1674 }
1675
1676 protected void add(long tagId, long entryId) throws SystemException {
1677 if (!_persistenceImpl.containsAssetEntry.contains(tagId, entryId)) {
1678 ModelListener<com.liferay.portlet.asset.model.AssetEntry>[] assetEntryListeners =
1679 assetEntryPersistence.getListeners();
1680
1681 for (ModelListener<AssetTag> listener : listeners) {
1682 listener.onBeforeAddAssociation(tagId,
1683 com.liferay.portlet.asset.model.AssetEntry.class.getName(),
1684 entryId);
1685 }
1686
1687 for (ModelListener<com.liferay.portlet.asset.model.AssetEntry> listener : assetEntryListeners) {
1688 listener.onBeforeAddAssociation(entryId,
1689 AssetTag.class.getName(), tagId);
1690 }
1691
1692 _sqlUpdate.update(new Object[] {
1693 new Long(tagId), new Long(entryId)
1694 });
1695
1696 for (ModelListener<AssetTag> listener : listeners) {
1697 listener.onAfterAddAssociation(tagId,
1698 com.liferay.portlet.asset.model.AssetEntry.class.getName(),
1699 entryId);
1700 }
1701
1702 for (ModelListener<com.liferay.portlet.asset.model.AssetEntry> listener : assetEntryListeners) {
1703 listener.onAfterAddAssociation(entryId,
1704 AssetTag.class.getName(), tagId);
1705 }
1706 }
1707 }
1708
1709 private SqlUpdate _sqlUpdate;
1710 private AssetTagPersistenceImpl _persistenceImpl;
1711 }
1712
1713 protected class ClearAssetEntries {
1714 protected ClearAssetEntries(AssetTagPersistenceImpl persistenceImpl) {
1715 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
1716 "DELETE FROM AssetEntries_AssetTags WHERE tagId = ?",
1717 new int[] { java.sql.Types.BIGINT });
1718 }
1719
1720 protected void clear(long tagId) throws SystemException {
1721 ModelListener<com.liferay.portlet.asset.model.AssetEntry>[] assetEntryListeners =
1722 assetEntryPersistence.getListeners();
1723
1724 List<com.liferay.portlet.asset.model.AssetEntry> assetEntries = null;
1725
1726 if ((listeners.length > 0) || (assetEntryListeners.length > 0)) {
1727 assetEntries = getAssetEntries(tagId);
1728
1729 for (com.liferay.portlet.asset.model.AssetEntry assetEntry : assetEntries) {
1730 for (ModelListener<AssetTag> listener : listeners) {
1731 listener.onBeforeRemoveAssociation(tagId,
1732 com.liferay.portlet.asset.model.AssetEntry.class.getName(),
1733 assetEntry.getPrimaryKey());
1734 }
1735
1736 for (ModelListener<com.liferay.portlet.asset.model.AssetEntry> listener : assetEntryListeners) {
1737 listener.onBeforeRemoveAssociation(assetEntry.getPrimaryKey(),
1738 AssetTag.class.getName(), tagId);
1739 }
1740 }
1741 }
1742
1743 _sqlUpdate.update(new Object[] { new Long(tagId) });
1744
1745 if ((listeners.length > 0) || (assetEntryListeners.length > 0)) {
1746 for (com.liferay.portlet.asset.model.AssetEntry assetEntry : assetEntries) {
1747 for (ModelListener<AssetTag> listener : listeners) {
1748 listener.onAfterRemoveAssociation(tagId,
1749 com.liferay.portlet.asset.model.AssetEntry.class.getName(),
1750 assetEntry.getPrimaryKey());
1751 }
1752
1753 for (ModelListener<com.liferay.portlet.asset.model.AssetEntry> listener : assetEntryListeners) {
1754 listener.onAfterRemoveAssociation(assetEntry.getPrimaryKey(),
1755 AssetTag.class.getName(), tagId);
1756 }
1757 }
1758 }
1759 }
1760
1761 private SqlUpdate _sqlUpdate;
1762 }
1763
1764 protected class RemoveAssetEntry {
1765 protected RemoveAssetEntry(AssetTagPersistenceImpl persistenceImpl) {
1766 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
1767 "DELETE FROM AssetEntries_AssetTags WHERE tagId = ? AND entryId = ?",
1768 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
1769 _persistenceImpl = persistenceImpl;
1770 }
1771
1772 protected void remove(long tagId, long entryId)
1773 throws SystemException {
1774 if (_persistenceImpl.containsAssetEntry.contains(tagId, entryId)) {
1775 ModelListener<com.liferay.portlet.asset.model.AssetEntry>[] assetEntryListeners =
1776 assetEntryPersistence.getListeners();
1777
1778 for (ModelListener<AssetTag> listener : listeners) {
1779 listener.onBeforeRemoveAssociation(tagId,
1780 com.liferay.portlet.asset.model.AssetEntry.class.getName(),
1781 entryId);
1782 }
1783
1784 for (ModelListener<com.liferay.portlet.asset.model.AssetEntry> listener : assetEntryListeners) {
1785 listener.onBeforeRemoveAssociation(entryId,
1786 AssetTag.class.getName(), tagId);
1787 }
1788
1789 _sqlUpdate.update(new Object[] {
1790 new Long(tagId), new Long(entryId)
1791 });
1792
1793 for (ModelListener<AssetTag> listener : listeners) {
1794 listener.onAfterRemoveAssociation(tagId,
1795 com.liferay.portlet.asset.model.AssetEntry.class.getName(),
1796 entryId);
1797 }
1798
1799 for (ModelListener<com.liferay.portlet.asset.model.AssetEntry> listener : assetEntryListeners) {
1800 listener.onAfterRemoveAssociation(entryId,
1801 AssetTag.class.getName(), tagId);
1802 }
1803 }
1804 }
1805
1806 private SqlUpdate _sqlUpdate;
1807 private AssetTagPersistenceImpl _persistenceImpl;
1808 }
1809
1810 private static final String _SQL_SELECT_ASSETTAG = "SELECT assetTag FROM AssetTag assetTag";
1811 private static final String _SQL_SELECT_ASSETTAG_WHERE = "SELECT assetTag FROM AssetTag assetTag WHERE ";
1812 private static final String _SQL_COUNT_ASSETTAG = "SELECT COUNT(assetTag) FROM AssetTag assetTag";
1813 private static final String _SQL_COUNT_ASSETTAG_WHERE = "SELECT COUNT(assetTag) FROM AssetTag assetTag WHERE ";
1814 private static final String _SQL_GETASSETENTRIES = "SELECT {AssetEntry.*} FROM AssetEntry INNER JOIN AssetEntries_AssetTags ON (AssetEntries_AssetTags.entryId = AssetEntry.entryId) WHERE (AssetEntries_AssetTags.tagId = ?)";
1815 private static final String _SQL_GETASSETENTRIESSIZE = "SELECT COUNT(*) AS COUNT_VALUE FROM AssetEntries_AssetTags WHERE tagId = ?";
1816 private static final String _SQL_CONTAINSASSETENTRY = "SELECT COUNT(*) AS COUNT_VALUE FROM AssetEntries_AssetTags WHERE tagId = ? AND entryId = ?";
1817 private static final String _FINDER_COLUMN_GROUPID_GROUPID_2 = "assetTag.groupId = ?";
1818 private static final String _FILTER_SQL_SELECT_ASSETTAG_WHERE = "SELECT DISTINCT {assetTag.*} FROM AssetTag assetTag WHERE ";
1819 private static final String _FILTER_SQL_SELECT_ASSETTAG_NO_INLINE_DISTINCT_WHERE =
1820 "SELECT {assetTag.*} FROM (SELECT DISTINCT tagId FROM AssetTag) assetTag2 INNER JOIN AssetTag assetTag ON (assetTag2.tagId = assetTag.tagId) WHERE ";
1821 private static final String _FILTER_SQL_COUNT_ASSETTAG_WHERE = "SELECT COUNT(DISTINCT assetTag.tagId) AS COUNT_VALUE FROM AssetTag assetTag WHERE ";
1822 private static final String _FILTER_COLUMN_PK = "assetTag.tagId";
1823 private static final String _FILTER_COLUMN_USERID = "assetTag.userId";
1824 private static final String _FILTER_ENTITY_ALIAS = "assetTag";
1825 private static final String _ORDER_BY_ENTITY_ALIAS = "assetTag.";
1826 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No AssetTag exists with the primary key ";
1827 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No AssetTag exists with the key {";
1828 private static Log _log = LogFactoryUtil.getLog(AssetTagPersistenceImpl.class);
1829 }