1
14
15 package com.liferay.portlet.asset.service.persistence;
16
17 import com.liferay.portal.NoSuchModelException;
18 import com.liferay.portal.kernel.annotation.BeanReference;
19 import com.liferay.portal.kernel.cache.CacheRegistry;
20 import com.liferay.portal.kernel.dao.jdbc.MappingSqlQuery;
21 import com.liferay.portal.kernel.dao.jdbc.MappingSqlQueryFactoryUtil;
22 import com.liferay.portal.kernel.dao.jdbc.RowMapper;
23 import com.liferay.portal.kernel.dao.jdbc.SqlUpdate;
24 import com.liferay.portal.kernel.dao.jdbc.SqlUpdateFactoryUtil;
25 import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
26 import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
27 import com.liferay.portal.kernel.dao.orm.FinderPath;
28 import com.liferay.portal.kernel.dao.orm.Query;
29 import com.liferay.portal.kernel.dao.orm.QueryPos;
30 import com.liferay.portal.kernel.dao.orm.QueryUtil;
31 import com.liferay.portal.kernel.dao.orm.SQLQuery;
32 import com.liferay.portal.kernel.dao.orm.Session;
33 import com.liferay.portal.kernel.dao.orm.Type;
34 import com.liferay.portal.kernel.exception.SystemException;
35 import com.liferay.portal.kernel.log.Log;
36 import com.liferay.portal.kernel.log.LogFactoryUtil;
37 import com.liferay.portal.kernel.util.GetterUtil;
38 import com.liferay.portal.kernel.util.InstanceFactory;
39 import com.liferay.portal.kernel.util.OrderByComparator;
40 import com.liferay.portal.kernel.util.SetUtil;
41 import com.liferay.portal.kernel.util.StringBundler;
42 import com.liferay.portal.kernel.util.StringPool;
43 import com.liferay.portal.kernel.util.StringUtil;
44 import com.liferay.portal.model.ModelListener;
45 import com.liferay.portal.security.permission.InlineSQLHelperUtil;
46 import com.liferay.portal.service.persistence.BatchSessionUtil;
47 import com.liferay.portal.service.persistence.ResourcePersistence;
48 import com.liferay.portal.service.persistence.UserPersistence;
49 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
50
51 import com.liferay.portlet.asset.NoSuchTagException;
52 import com.liferay.portlet.asset.model.AssetTag;
53 import com.liferay.portlet.asset.model.impl.AssetTagImpl;
54 import com.liferay.portlet.asset.model.impl.AssetTagModelImpl;
55
56 import java.io.Serializable;
57
58 import java.sql.Types;
59
60 import java.util.ArrayList;
61 import java.util.Collections;
62 import java.util.List;
63 import java.util.Set;
64
65
78 public class AssetTagPersistenceImpl extends BasePersistenceImpl<AssetTag>
79 implements AssetTagPersistence {
80 public static final String FINDER_CLASS_NAME_ENTITY = AssetTagImpl.class.getName();
81 public static final String FINDER_CLASS_NAME_LIST = FINDER_CLASS_NAME_ENTITY +
82 ".List";
83 public static final FinderPath FINDER_PATH_FIND_BY_GROUPID = new FinderPath(AssetTagModelImpl.ENTITY_CACHE_ENABLED,
84 AssetTagModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
85 "findByGroupId",
86 new String[] {
87 Long.class.getName(),
88
89 "java.lang.Integer", "java.lang.Integer",
90 "com.liferay.portal.kernel.util.OrderByComparator"
91 });
92 public static final FinderPath FINDER_PATH_COUNT_BY_GROUPID = new FinderPath(AssetTagModelImpl.ENTITY_CACHE_ENABLED,
93 AssetTagModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
94 "countByGroupId", new String[] { Long.class.getName() });
95 public static final FinderPath FINDER_PATH_FIND_ALL = new FinderPath(AssetTagModelImpl.ENTITY_CACHE_ENABLED,
96 AssetTagModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
97 "findAll", new String[0]);
98 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(AssetTagModelImpl.ENTITY_CACHE_ENABLED,
99 AssetTagModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
100 "countAll", new String[0]);
101
102 public void cacheResult(AssetTag assetTag) {
103 EntityCacheUtil.putResult(AssetTagModelImpl.ENTITY_CACHE_ENABLED,
104 AssetTagImpl.class, assetTag.getPrimaryKey(), assetTag);
105 }
106
107 public void cacheResult(List<AssetTag> assetTags) {
108 for (AssetTag assetTag : assetTags) {
109 if (EntityCacheUtil.getResult(
110 AssetTagModelImpl.ENTITY_CACHE_ENABLED,
111 AssetTagImpl.class, assetTag.getPrimaryKey(), this) == null) {
112 cacheResult(assetTag);
113 }
114 }
115 }
116
117 public void clearCache() {
118 CacheRegistry.clear(AssetTagImpl.class.getName());
119 EntityCacheUtil.clearCache(AssetTagImpl.class.getName());
120 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
121 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
122 }
123
124 public void clearCache(AssetTag assetTag) {
125 EntityCacheUtil.removeResult(AssetTagModelImpl.ENTITY_CACHE_ENABLED,
126 AssetTagImpl.class, assetTag.getPrimaryKey());
127 }
128
129 public AssetTag create(long tagId) {
130 AssetTag assetTag = new AssetTagImpl();
131
132 assetTag.setNew(true);
133 assetTag.setPrimaryKey(tagId);
134
135 return assetTag;
136 }
137
138 public AssetTag remove(Serializable primaryKey)
139 throws NoSuchModelException, SystemException {
140 return remove(((Long)primaryKey).longValue());
141 }
142
143 public AssetTag remove(long tagId)
144 throws NoSuchTagException, SystemException {
145 Session session = null;
146
147 try {
148 session = openSession();
149
150 AssetTag assetTag = (AssetTag)session.get(AssetTagImpl.class,
151 new Long(tagId));
152
153 if (assetTag == null) {
154 if (_log.isWarnEnabled()) {
155 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + tagId);
156 }
157
158 throw new NoSuchTagException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
159 tagId);
160 }
161
162 return remove(assetTag);
163 }
164 catch (NoSuchTagException nsee) {
165 throw nsee;
166 }
167 catch (Exception e) {
168 throw processException(e);
169 }
170 finally {
171 closeSession(session);
172 }
173 }
174
175 public AssetTag remove(AssetTag assetTag) throws SystemException {
176 for (ModelListener<AssetTag> listener : listeners) {
177 listener.onBeforeRemove(assetTag);
178 }
179
180 assetTag = removeImpl(assetTag);
181
182 for (ModelListener<AssetTag> listener : listeners) {
183 listener.onAfterRemove(assetTag);
184 }
185
186 return assetTag;
187 }
188
189 protected AssetTag removeImpl(AssetTag assetTag) throws SystemException {
190 assetTag = toUnwrappedModel(assetTag);
191
192 try {
193 clearAssetEntries.clear(assetTag.getPrimaryKey());
194 }
195 catch (Exception e) {
196 throw processException(e);
197 }
198 finally {
199 FinderCacheUtil.clearCache(AssetTagModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETTAGS_NAME);
200 }
201
202 Session session = null;
203
204 try {
205 session = openSession();
206
207 if (assetTag.isCachedModel() || BatchSessionUtil.isEnabled()) {
208 Object staleObject = session.get(AssetTagImpl.class,
209 assetTag.getPrimaryKeyObj());
210
211 if (staleObject != null) {
212 session.evict(staleObject);
213 }
214 }
215
216 session.delete(assetTag);
217
218 session.flush();
219 }
220 catch (Exception e) {
221 throw processException(e);
222 }
223 finally {
224 closeSession(session);
225 }
226
227 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
228
229 EntityCacheUtil.removeResult(AssetTagModelImpl.ENTITY_CACHE_ENABLED,
230 AssetTagImpl.class, assetTag.getPrimaryKey());
231
232 return assetTag;
233 }
234
235 public AssetTag updateImpl(
236 com.liferay.portlet.asset.model.AssetTag assetTag, boolean merge)
237 throws SystemException {
238 assetTag = toUnwrappedModel(assetTag);
239
240 Session session = null;
241
242 try {
243 session = openSession();
244
245 BatchSessionUtil.update(session, assetTag, merge);
246
247 assetTag.setNew(false);
248 }
249 catch (Exception e) {
250 throw processException(e);
251 }
252 finally {
253 closeSession(session);
254 }
255
256 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
257
258 EntityCacheUtil.putResult(AssetTagModelImpl.ENTITY_CACHE_ENABLED,
259 AssetTagImpl.class, assetTag.getPrimaryKey(), assetTag);
260
261 return assetTag;
262 }
263
264 protected AssetTag toUnwrappedModel(AssetTag assetTag) {
265 if (assetTag instanceof AssetTagImpl) {
266 return assetTag;
267 }
268
269 AssetTagImpl assetTagImpl = new AssetTagImpl();
270
271 assetTagImpl.setNew(assetTag.isNew());
272 assetTagImpl.setPrimaryKey(assetTag.getPrimaryKey());
273
274 assetTagImpl.setTagId(assetTag.getTagId());
275 assetTagImpl.setGroupId(assetTag.getGroupId());
276 assetTagImpl.setCompanyId(assetTag.getCompanyId());
277 assetTagImpl.setUserId(assetTag.getUserId());
278 assetTagImpl.setUserName(assetTag.getUserName());
279 assetTagImpl.setCreateDate(assetTag.getCreateDate());
280 assetTagImpl.setModifiedDate(assetTag.getModifiedDate());
281 assetTagImpl.setName(assetTag.getName());
282 assetTagImpl.setAssetCount(assetTag.getAssetCount());
283
284 return assetTagImpl;
285 }
286
287 public AssetTag findByPrimaryKey(Serializable primaryKey)
288 throws NoSuchModelException, SystemException {
289 return findByPrimaryKey(((Long)primaryKey).longValue());
290 }
291
292 public AssetTag findByPrimaryKey(long tagId)
293 throws NoSuchTagException, SystemException {
294 AssetTag assetTag = fetchByPrimaryKey(tagId);
295
296 if (assetTag == null) {
297 if (_log.isWarnEnabled()) {
298 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + tagId);
299 }
300
301 throw new NoSuchTagException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
302 tagId);
303 }
304
305 return assetTag;
306 }
307
308 public AssetTag fetchByPrimaryKey(Serializable primaryKey)
309 throws SystemException {
310 return fetchByPrimaryKey(((Long)primaryKey).longValue());
311 }
312
313 public AssetTag fetchByPrimaryKey(long tagId) throws SystemException {
314 AssetTag assetTag = (AssetTag)EntityCacheUtil.getResult(AssetTagModelImpl.ENTITY_CACHE_ENABLED,
315 AssetTagImpl.class, tagId, this);
316
317 if (assetTag == null) {
318 Session session = null;
319
320 try {
321 session = openSession();
322
323 assetTag = (AssetTag)session.get(AssetTagImpl.class,
324 new Long(tagId));
325 }
326 catch (Exception e) {
327 throw processException(e);
328 }
329 finally {
330 if (assetTag != null) {
331 cacheResult(assetTag);
332 }
333
334 closeSession(session);
335 }
336 }
337
338 return assetTag;
339 }
340
341 public List<AssetTag> findByGroupId(long groupId) throws SystemException {
342 return findByGroupId(groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
343 }
344
345 public List<AssetTag> findByGroupId(long groupId, int start, int end)
346 throws SystemException {
347 return findByGroupId(groupId, start, end, null);
348 }
349
350 public List<AssetTag> findByGroupId(long groupId, int start, int end,
351 OrderByComparator orderByComparator) throws SystemException {
352 Object[] finderArgs = new Object[] {
353 new Long(groupId),
354
355 String.valueOf(start), String.valueOf(end),
356 String.valueOf(orderByComparator)
357 };
358
359 List<AssetTag> list = (List<AssetTag>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_GROUPID,
360 finderArgs, this);
361
362 if (list == null) {
363 Session session = null;
364
365 try {
366 session = openSession();
367
368 StringBundler query = null;
369
370 if (orderByComparator != null) {
371 query = new StringBundler(3 +
372 (orderByComparator.getOrderByFields().length * 3));
373 }
374 else {
375 query = new StringBundler(3);
376 }
377
378 query.append(_SQL_SELECT_ASSETTAG_WHERE);
379
380 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
381
382 if (orderByComparator != null) {
383 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
384 orderByComparator);
385 }
386
387 else {
388 query.append(AssetTagModelImpl.ORDER_BY_JPQL);
389 }
390
391 String sql = query.toString();
392
393 Query q = session.createQuery(sql);
394
395 QueryPos qPos = QueryPos.getInstance(q);
396
397 qPos.add(groupId);
398
399 list = (List<AssetTag>)QueryUtil.list(q, getDialect(), start,
400 end);
401 }
402 catch (Exception e) {
403 throw processException(e);
404 }
405 finally {
406 if (list == null) {
407 list = new ArrayList<AssetTag>();
408 }
409
410 cacheResult(list);
411
412 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_GROUPID,
413 finderArgs, list);
414
415 closeSession(session);
416 }
417 }
418
419 return list;
420 }
421
422 public AssetTag findByGroupId_First(long groupId,
423 OrderByComparator orderByComparator)
424 throws NoSuchTagException, SystemException {
425 List<AssetTag> list = findByGroupId(groupId, 0, 1, orderByComparator);
426
427 if (list.isEmpty()) {
428 StringBundler msg = new StringBundler(4);
429
430 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
431
432 msg.append("groupId=");
433 msg.append(groupId);
434
435 msg.append(StringPool.CLOSE_CURLY_BRACE);
436
437 throw new NoSuchTagException(msg.toString());
438 }
439 else {
440 return list.get(0);
441 }
442 }
443
444 public AssetTag findByGroupId_Last(long groupId,
445 OrderByComparator orderByComparator)
446 throws NoSuchTagException, SystemException {
447 int count = countByGroupId(groupId);
448
449 List<AssetTag> list = findByGroupId(groupId, count - 1, count,
450 orderByComparator);
451
452 if (list.isEmpty()) {
453 StringBundler msg = new StringBundler(4);
454
455 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
456
457 msg.append("groupId=");
458 msg.append(groupId);
459
460 msg.append(StringPool.CLOSE_CURLY_BRACE);
461
462 throw new NoSuchTagException(msg.toString());
463 }
464 else {
465 return list.get(0);
466 }
467 }
468
469 public AssetTag[] findByGroupId_PrevAndNext(long tagId, long groupId,
470 OrderByComparator orderByComparator)
471 throws NoSuchTagException, SystemException {
472 AssetTag assetTag = findByPrimaryKey(tagId);
473
474 Session session = null;
475
476 try {
477 session = openSession();
478
479 AssetTag[] array = new AssetTagImpl[3];
480
481 array[0] = getByGroupId_PrevAndNext(session, assetTag, groupId,
482 orderByComparator, true);
483
484 array[1] = assetTag;
485
486 array[2] = getByGroupId_PrevAndNext(session, assetTag, groupId,
487 orderByComparator, false);
488
489 return array;
490 }
491 catch (Exception e) {
492 throw processException(e);
493 }
494 finally {
495 closeSession(session);
496 }
497 }
498
499 protected AssetTag getByGroupId_PrevAndNext(Session session,
500 AssetTag assetTag, long groupId, OrderByComparator orderByComparator,
501 boolean previous) {
502 StringBundler query = null;
503
504 if (orderByComparator != null) {
505 query = new StringBundler(6 +
506 (orderByComparator.getOrderByFields().length * 6));
507 }
508 else {
509 query = new StringBundler(3);
510 }
511
512 query.append(_SQL_SELECT_ASSETTAG_WHERE);
513
514 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
515
516 if (orderByComparator != null) {
517 String[] orderByFields = orderByComparator.getOrderByFields();
518
519 if (orderByFields.length > 0) {
520 query.append(WHERE_AND);
521 }
522
523 for (int i = 0; i < orderByFields.length; i++) {
524 query.append(_ORDER_BY_ENTITY_ALIAS);
525 query.append(orderByFields[i]);
526
527 if ((i + 1) < orderByFields.length) {
528 if (orderByComparator.isAscending() ^ previous) {
529 query.append(WHERE_GREATER_THAN_HAS_NEXT);
530 }
531 else {
532 query.append(WHERE_LESSER_THAN_HAS_NEXT);
533 }
534 }
535 else {
536 if (orderByComparator.isAscending() ^ previous) {
537 query.append(WHERE_GREATER_THAN);
538 }
539 else {
540 query.append(WHERE_LESSER_THAN);
541 }
542 }
543 }
544
545 query.append(ORDER_BY_CLAUSE);
546
547 for (int i = 0; i < orderByFields.length; i++) {
548 query.append(_ORDER_BY_ENTITY_ALIAS);
549 query.append(orderByFields[i]);
550
551 if ((i + 1) < orderByFields.length) {
552 if (orderByComparator.isAscending() ^ previous) {
553 query.append(ORDER_BY_ASC_HAS_NEXT);
554 }
555 else {
556 query.append(ORDER_BY_DESC_HAS_NEXT);
557 }
558 }
559 else {
560 if (orderByComparator.isAscending() ^ previous) {
561 query.append(ORDER_BY_ASC);
562 }
563 else {
564 query.append(ORDER_BY_DESC);
565 }
566 }
567 }
568 }
569
570 else {
571 query.append(AssetTagModelImpl.ORDER_BY_JPQL);
572 }
573
574 String sql = query.toString();
575
576 Query q = session.createQuery(sql);
577
578 q.setFirstResult(0);
579 q.setMaxResults(2);
580
581 QueryPos qPos = QueryPos.getInstance(q);
582
583 qPos.add(groupId);
584
585 if (orderByComparator != null) {
586 Object[] values = orderByComparator.getOrderByValues(assetTag);
587
588 for (Object value : values) {
589 qPos.add(value);
590 }
591 }
592
593 List<AssetTag> list = q.list();
594
595 if (list.size() == 2) {
596 return list.get(1);
597 }
598 else {
599 return null;
600 }
601 }
602
603 public List<AssetTag> filterFindByGroupId(long groupId)
604 throws SystemException {
605 return filterFindByGroupId(groupId, QueryUtil.ALL_POS,
606 QueryUtil.ALL_POS, null);
607 }
608
609 public List<AssetTag> filterFindByGroupId(long groupId, int start, int end)
610 throws SystemException {
611 return filterFindByGroupId(groupId, start, end, null);
612 }
613
614 public List<AssetTag> filterFindByGroupId(long groupId, int start, int end,
615 OrderByComparator orderByComparator) throws SystemException {
616 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
617 return findByGroupId(groupId, start, end, orderByComparator);
618 }
619
620 Session session = null;
621
622 try {
623 session = openSession();
624
625 StringBundler query = null;
626
627 if (orderByComparator != null) {
628 query = new StringBundler(3 +
629 (orderByComparator.getOrderByFields().length * 3));
630 }
631 else {
632 query = new StringBundler(3);
633 }
634
635 query.append(_FILTER_SQL_SELECT_ASSETTAG_WHERE);
636
637 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
638
639 if (orderByComparator != null) {
640 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
641 orderByComparator);
642 }
643
644 else {
645 query.append(AssetTagModelImpl.ORDER_BY_JPQL);
646 }
647
648 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
649 AssetTag.class.getName(), _FILTER_COLUMN_TAGID,
650 _FILTER_COLUMN_USERID, groupId);
651
652 SQLQuery q = session.createSQLQuery(sql);
653
654 q.addEntity(_FILTER_ENTITY_ALIAS, AssetTagImpl.class);
655
656 QueryPos qPos = QueryPos.getInstance(q);
657
658 qPos.add(groupId);
659
660 return (List<AssetTag>)QueryUtil.list(q, getDialect(), start, end);
661 }
662 catch (Exception e) {
663 throw processException(e);
664 }
665 finally {
666 closeSession(session);
667 }
668 }
669
670 public List<AssetTag> findAll() throws SystemException {
671 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
672 }
673
674 public List<AssetTag> findAll(int start, int end) throws SystemException {
675 return findAll(start, end, null);
676 }
677
678 public List<AssetTag> findAll(int start, int end,
679 OrderByComparator orderByComparator) throws SystemException {
680 Object[] finderArgs = new Object[] {
681 String.valueOf(start), String.valueOf(end),
682 String.valueOf(orderByComparator)
683 };
684
685 List<AssetTag> list = (List<AssetTag>)FinderCacheUtil.getResult(FINDER_PATH_FIND_ALL,
686 finderArgs, this);
687
688 if (list == null) {
689 Session session = null;
690
691 try {
692 session = openSession();
693
694 StringBundler query = null;
695 String sql = null;
696
697 if (orderByComparator != null) {
698 query = new StringBundler(2 +
699 (orderByComparator.getOrderByFields().length * 3));
700
701 query.append(_SQL_SELECT_ASSETTAG);
702
703 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
704 orderByComparator);
705
706 sql = query.toString();
707 }
708
709 else {
710 sql = _SQL_SELECT_ASSETTAG.concat(AssetTagModelImpl.ORDER_BY_JPQL);
711 }
712
713 Query q = session.createQuery(sql);
714
715 if (orderByComparator == null) {
716 list = (List<AssetTag>)QueryUtil.list(q, getDialect(),
717 start, end, false);
718
719 Collections.sort(list);
720 }
721 else {
722 list = (List<AssetTag>)QueryUtil.list(q, getDialect(),
723 start, end);
724 }
725 }
726 catch (Exception e) {
727 throw processException(e);
728 }
729 finally {
730 if (list == null) {
731 list = new ArrayList<AssetTag>();
732 }
733
734 cacheResult(list);
735
736 FinderCacheUtil.putResult(FINDER_PATH_FIND_ALL, finderArgs, list);
737
738 closeSession(session);
739 }
740 }
741
742 return list;
743 }
744
745 public void removeByGroupId(long groupId) throws SystemException {
746 for (AssetTag assetTag : findByGroupId(groupId)) {
747 remove(assetTag);
748 }
749 }
750
751 public void removeAll() throws SystemException {
752 for (AssetTag assetTag : findAll()) {
753 remove(assetTag);
754 }
755 }
756
757 public int countByGroupId(long groupId) throws SystemException {
758 Object[] finderArgs = new Object[] { new Long(groupId) };
759
760 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_GROUPID,
761 finderArgs, this);
762
763 if (count == null) {
764 Session session = null;
765
766 try {
767 session = openSession();
768
769 StringBundler query = new StringBundler(2);
770
771 query.append(_SQL_COUNT_ASSETTAG_WHERE);
772
773 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
774
775 String sql = query.toString();
776
777 Query q = session.createQuery(sql);
778
779 QueryPos qPos = QueryPos.getInstance(q);
780
781 qPos.add(groupId);
782
783 count = (Long)q.uniqueResult();
784 }
785 catch (Exception e) {
786 throw processException(e);
787 }
788 finally {
789 if (count == null) {
790 count = Long.valueOf(0);
791 }
792
793 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_GROUPID,
794 finderArgs, count);
795
796 closeSession(session);
797 }
798 }
799
800 return count.intValue();
801 }
802
803 public int filterCountByGroupId(long groupId) throws SystemException {
804 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
805 return countByGroupId(groupId);
806 }
807
808 Session session = null;
809
810 try {
811 session = openSession();
812
813 StringBundler query = new StringBundler(2);
814
815 query.append(_FILTER_SQL_COUNT_ASSETTAG_WHERE);
816
817 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
818
819 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
820 AssetTag.class.getName(), _FILTER_COLUMN_TAGID,
821 _FILTER_COLUMN_USERID, groupId);
822
823 SQLQuery q = session.createSQLQuery(sql);
824
825 q.addScalar(COUNT_COLUMN_NAME, Type.LONG);
826
827 QueryPos qPos = QueryPos.getInstance(q);
828
829 qPos.add(groupId);
830
831 Long count = (Long)q.uniqueResult();
832
833 return count.intValue();
834 }
835 catch (Exception e) {
836 throw processException(e);
837 }
838 finally {
839 closeSession(session);
840 }
841 }
842
843 public int countAll() throws SystemException {
844 Object[] finderArgs = new Object[0];
845
846 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
847 finderArgs, this);
848
849 if (count == null) {
850 Session session = null;
851
852 try {
853 session = openSession();
854
855 Query q = session.createQuery(_SQL_COUNT_ASSETTAG);
856
857 count = (Long)q.uniqueResult();
858 }
859 catch (Exception e) {
860 throw processException(e);
861 }
862 finally {
863 if (count == null) {
864 count = Long.valueOf(0);
865 }
866
867 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL, finderArgs,
868 count);
869
870 closeSession(session);
871 }
872 }
873
874 return count.intValue();
875 }
876
877 public List<com.liferay.portlet.asset.model.AssetEntry> getAssetEntries(
878 long pk) throws SystemException {
879 return getAssetEntries(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
880 }
881
882 public List<com.liferay.portlet.asset.model.AssetEntry> getAssetEntries(
883 long pk, int start, int end) throws SystemException {
884 return getAssetEntries(pk, start, end, null);
885 }
886
887 public static final FinderPath FINDER_PATH_GET_ASSETENTRIES = new FinderPath(com.liferay.portlet.asset.model.impl.AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
888 AssetTagModelImpl.FINDER_CACHE_ENABLED_ASSETENTRIES_ASSETTAGS,
889 AssetTagModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETTAGS_NAME,
890 "getAssetEntries",
891 new String[] {
892 Long.class.getName(), "java.lang.Integer", "java.lang.Integer",
893 "com.liferay.portal.kernel.util.OrderByComparator"
894 });
895
896 public List<com.liferay.portlet.asset.model.AssetEntry> getAssetEntries(
897 long pk, int start, int end, OrderByComparator orderByComparator)
898 throws SystemException {
899 Object[] finderArgs = new Object[] {
900 new Long(pk), String.valueOf(start), String.valueOf(end),
901 String.valueOf(orderByComparator)
902 };
903
904 List<com.liferay.portlet.asset.model.AssetEntry> list = (List<com.liferay.portlet.asset.model.AssetEntry>)FinderCacheUtil.getResult(FINDER_PATH_GET_ASSETENTRIES,
905 finderArgs, this);
906
907 if (list == null) {
908 Session session = null;
909
910 try {
911 session = openSession();
912
913 String sql = null;
914
915 if (orderByComparator != null) {
916 sql = _SQL_GETASSETENTRIES.concat(ORDER_BY_CLAUSE)
917 .concat(orderByComparator.getOrderBy());
918 }
919
920 sql = _SQL_GETASSETENTRIES;
921
922 SQLQuery q = session.createSQLQuery(sql);
923
924 q.addEntity("AssetEntry",
925 com.liferay.portlet.asset.model.impl.AssetEntryImpl.class);
926
927 QueryPos qPos = QueryPos.getInstance(q);
928
929 qPos.add(pk);
930
931 list = (List<com.liferay.portlet.asset.model.AssetEntry>)QueryUtil.list(q,
932 getDialect(), start, end);
933 }
934 catch (Exception e) {
935 throw processException(e);
936 }
937 finally {
938 if (list == null) {
939 list = new ArrayList<com.liferay.portlet.asset.model.AssetEntry>();
940 }
941
942 assetEntryPersistence.cacheResult(list);
943
944 FinderCacheUtil.putResult(FINDER_PATH_GET_ASSETENTRIES,
945 finderArgs, list);
946
947 closeSession(session);
948 }
949 }
950
951 return list;
952 }
953
954 public static final FinderPath FINDER_PATH_GET_ASSETENTRIES_SIZE = new FinderPath(com.liferay.portlet.asset.model.impl.AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
955 AssetTagModelImpl.FINDER_CACHE_ENABLED_ASSETENTRIES_ASSETTAGS,
956 AssetTagModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETTAGS_NAME,
957 "getAssetEntriesSize", new String[] { Long.class.getName() });
958
959 public int getAssetEntriesSize(long pk) throws SystemException {
960 Object[] finderArgs = new Object[] { new Long(pk) };
961
962 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_GET_ASSETENTRIES_SIZE,
963 finderArgs, this);
964
965 if (count == null) {
966 Session session = null;
967
968 try {
969 session = openSession();
970
971 SQLQuery q = session.createSQLQuery(_SQL_GETASSETENTRIESSIZE);
972
973 q.addScalar(COUNT_COLUMN_NAME, Type.LONG);
974
975 QueryPos qPos = QueryPos.getInstance(q);
976
977 qPos.add(pk);
978
979 count = (Long)q.uniqueResult();
980 }
981 catch (Exception e) {
982 throw processException(e);
983 }
984 finally {
985 if (count == null) {
986 count = Long.valueOf(0);
987 }
988
989 FinderCacheUtil.putResult(FINDER_PATH_GET_ASSETENTRIES_SIZE,
990 finderArgs, count);
991
992 closeSession(session);
993 }
994 }
995
996 return count.intValue();
997 }
998
999 public static final FinderPath FINDER_PATH_CONTAINS_ASSETENTRY = new FinderPath(com.liferay.portlet.asset.model.impl.AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
1000 AssetTagModelImpl.FINDER_CACHE_ENABLED_ASSETENTRIES_ASSETTAGS,
1001 AssetTagModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETTAGS_NAME,
1002 "containsAssetEntry",
1003 new String[] { Long.class.getName(), Long.class.getName() });
1004
1005 public boolean containsAssetEntry(long pk, long assetEntryPK)
1006 throws SystemException {
1007 Object[] finderArgs = new Object[] { new Long(pk), new Long(assetEntryPK) };
1008
1009 Boolean value = (Boolean)FinderCacheUtil.getResult(FINDER_PATH_CONTAINS_ASSETENTRY,
1010 finderArgs, this);
1011
1012 if (value == null) {
1013 try {
1014 value = Boolean.valueOf(containsAssetEntry.contains(pk,
1015 assetEntryPK));
1016 }
1017 catch (Exception e) {
1018 throw processException(e);
1019 }
1020 finally {
1021 if (value == null) {
1022 value = Boolean.FALSE;
1023 }
1024
1025 FinderCacheUtil.putResult(FINDER_PATH_CONTAINS_ASSETENTRY,
1026 finderArgs, value);
1027 }
1028 }
1029
1030 return value.booleanValue();
1031 }
1032
1033 public boolean containsAssetEntries(long pk) throws SystemException {
1034 if (getAssetEntriesSize(pk) > 0) {
1035 return true;
1036 }
1037 else {
1038 return false;
1039 }
1040 }
1041
1042 public void addAssetEntry(long pk, long assetEntryPK)
1043 throws SystemException {
1044 try {
1045 addAssetEntry.add(pk, assetEntryPK);
1046 }
1047 catch (Exception e) {
1048 throw processException(e);
1049 }
1050 finally {
1051 FinderCacheUtil.clearCache(AssetTagModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETTAGS_NAME);
1052 }
1053 }
1054
1055 public void addAssetEntry(long pk,
1056 com.liferay.portlet.asset.model.AssetEntry assetEntry)
1057 throws SystemException {
1058 try {
1059 addAssetEntry.add(pk, assetEntry.getPrimaryKey());
1060 }
1061 catch (Exception e) {
1062 throw processException(e);
1063 }
1064 finally {
1065 FinderCacheUtil.clearCache(AssetTagModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETTAGS_NAME);
1066 }
1067 }
1068
1069 public void addAssetEntries(long pk, long[] assetEntryPKs)
1070 throws SystemException {
1071 try {
1072 for (long assetEntryPK : assetEntryPKs) {
1073 addAssetEntry.add(pk, assetEntryPK);
1074 }
1075 }
1076 catch (Exception e) {
1077 throw processException(e);
1078 }
1079 finally {
1080 FinderCacheUtil.clearCache(AssetTagModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETTAGS_NAME);
1081 }
1082 }
1083
1084 public void addAssetEntries(long pk,
1085 List<com.liferay.portlet.asset.model.AssetEntry> assetEntries)
1086 throws SystemException {
1087 try {
1088 for (com.liferay.portlet.asset.model.AssetEntry assetEntry : assetEntries) {
1089 addAssetEntry.add(pk, assetEntry.getPrimaryKey());
1090 }
1091 }
1092 catch (Exception e) {
1093 throw processException(e);
1094 }
1095 finally {
1096 FinderCacheUtil.clearCache(AssetTagModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETTAGS_NAME);
1097 }
1098 }
1099
1100 public void clearAssetEntries(long pk) throws SystemException {
1101 try {
1102 clearAssetEntries.clear(pk);
1103 }
1104 catch (Exception e) {
1105 throw processException(e);
1106 }
1107 finally {
1108 FinderCacheUtil.clearCache(AssetTagModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETTAGS_NAME);
1109 }
1110 }
1111
1112 public void removeAssetEntry(long pk, long assetEntryPK)
1113 throws SystemException {
1114 try {
1115 removeAssetEntry.remove(pk, assetEntryPK);
1116 }
1117 catch (Exception e) {
1118 throw processException(e);
1119 }
1120 finally {
1121 FinderCacheUtil.clearCache(AssetTagModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETTAGS_NAME);
1122 }
1123 }
1124
1125 public void removeAssetEntry(long pk,
1126 com.liferay.portlet.asset.model.AssetEntry assetEntry)
1127 throws SystemException {
1128 try {
1129 removeAssetEntry.remove(pk, assetEntry.getPrimaryKey());
1130 }
1131 catch (Exception e) {
1132 throw processException(e);
1133 }
1134 finally {
1135 FinderCacheUtil.clearCache(AssetTagModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETTAGS_NAME);
1136 }
1137 }
1138
1139 public void removeAssetEntries(long pk, long[] assetEntryPKs)
1140 throws SystemException {
1141 try {
1142 for (long assetEntryPK : assetEntryPKs) {
1143 removeAssetEntry.remove(pk, assetEntryPK);
1144 }
1145 }
1146 catch (Exception e) {
1147 throw processException(e);
1148 }
1149 finally {
1150 FinderCacheUtil.clearCache(AssetTagModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETTAGS_NAME);
1151 }
1152 }
1153
1154 public void removeAssetEntries(long pk,
1155 List<com.liferay.portlet.asset.model.AssetEntry> assetEntries)
1156 throws SystemException {
1157 try {
1158 for (com.liferay.portlet.asset.model.AssetEntry assetEntry : assetEntries) {
1159 removeAssetEntry.remove(pk, assetEntry.getPrimaryKey());
1160 }
1161 }
1162 catch (Exception e) {
1163 throw processException(e);
1164 }
1165 finally {
1166 FinderCacheUtil.clearCache(AssetTagModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETTAGS_NAME);
1167 }
1168 }
1169
1170 public void setAssetEntries(long pk, long[] assetEntryPKs)
1171 throws SystemException {
1172 try {
1173 Set<Long> assetEntryPKSet = SetUtil.fromArray(assetEntryPKs);
1174
1175 List<com.liferay.portlet.asset.model.AssetEntry> assetEntries = getAssetEntries(pk);
1176
1177 for (com.liferay.portlet.asset.model.AssetEntry assetEntry : assetEntries) {
1178 if (!assetEntryPKSet.contains(assetEntry.getPrimaryKey())) {
1179 removeAssetEntry.remove(pk, assetEntry.getPrimaryKey());
1180 }
1181 else {
1182 assetEntryPKSet.remove(assetEntry.getPrimaryKey());
1183 }
1184 }
1185
1186 for (Long assetEntryPK : assetEntryPKSet) {
1187 addAssetEntry.add(pk, assetEntryPK);
1188 }
1189 }
1190 catch (Exception e) {
1191 throw processException(e);
1192 }
1193 finally {
1194 FinderCacheUtil.clearCache(AssetTagModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETTAGS_NAME);
1195 }
1196 }
1197
1198 public void setAssetEntries(long pk,
1199 List<com.liferay.portlet.asset.model.AssetEntry> assetEntries)
1200 throws SystemException {
1201 try {
1202 long[] assetEntryPKs = new long[assetEntries.size()];
1203
1204 for (int i = 0; i < assetEntries.size(); i++) {
1205 com.liferay.portlet.asset.model.AssetEntry assetEntry = assetEntries.get(i);
1206
1207 assetEntryPKs[i] = assetEntry.getPrimaryKey();
1208 }
1209
1210 setAssetEntries(pk, assetEntryPKs);
1211 }
1212 catch (Exception e) {
1213 throw processException(e);
1214 }
1215 finally {
1216 FinderCacheUtil.clearCache(AssetTagModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETTAGS_NAME);
1217 }
1218 }
1219
1220 public void afterPropertiesSet() {
1221 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
1222 com.liferay.portal.util.PropsUtil.get(
1223 "value.object.listener.com.liferay.portlet.asset.model.AssetTag")));
1224
1225 if (listenerClassNames.length > 0) {
1226 try {
1227 List<ModelListener<AssetTag>> listenersList = new ArrayList<ModelListener<AssetTag>>();
1228
1229 for (String listenerClassName : listenerClassNames) {
1230 listenersList.add((ModelListener<AssetTag>)InstanceFactory.newInstance(
1231 listenerClassName));
1232 }
1233
1234 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
1235 }
1236 catch (Exception e) {
1237 _log.error(e);
1238 }
1239 }
1240
1241 containsAssetEntry = new ContainsAssetEntry(this);
1242
1243 addAssetEntry = new AddAssetEntry(this);
1244 clearAssetEntries = new ClearAssetEntries(this);
1245 removeAssetEntry = new RemoveAssetEntry(this);
1246 }
1247
1248 @BeanReference(type = AssetCategoryPersistence.class)
1249 protected AssetCategoryPersistence assetCategoryPersistence;
1250 @BeanReference(type = AssetCategoryPropertyPersistence.class)
1251 protected AssetCategoryPropertyPersistence assetCategoryPropertyPersistence;
1252 @BeanReference(type = AssetEntryPersistence.class)
1253 protected AssetEntryPersistence assetEntryPersistence;
1254 @BeanReference(type = AssetLinkPersistence.class)
1255 protected AssetLinkPersistence assetLinkPersistence;
1256 @BeanReference(type = AssetTagPersistence.class)
1257 protected AssetTagPersistence assetTagPersistence;
1258 @BeanReference(type = AssetTagPropertyPersistence.class)
1259 protected AssetTagPropertyPersistence assetTagPropertyPersistence;
1260 @BeanReference(type = AssetTagStatsPersistence.class)
1261 protected AssetTagStatsPersistence assetTagStatsPersistence;
1262 @BeanReference(type = AssetVocabularyPersistence.class)
1263 protected AssetVocabularyPersistence assetVocabularyPersistence;
1264 @BeanReference(type = ResourcePersistence.class)
1265 protected ResourcePersistence resourcePersistence;
1266 @BeanReference(type = UserPersistence.class)
1267 protected UserPersistence userPersistence;
1268 protected ContainsAssetEntry containsAssetEntry;
1269 protected AddAssetEntry addAssetEntry;
1270 protected ClearAssetEntries clearAssetEntries;
1271 protected RemoveAssetEntry removeAssetEntry;
1272
1273 protected class ContainsAssetEntry {
1274 protected ContainsAssetEntry(AssetTagPersistenceImpl persistenceImpl) {
1275 super();
1276
1277 _mappingSqlQuery = MappingSqlQueryFactoryUtil.getMappingSqlQuery(getDataSource(),
1278 _SQL_CONTAINSASSETENTRY,
1279 new int[] { Types.BIGINT, Types.BIGINT }, RowMapper.COUNT);
1280 }
1281
1282 protected boolean contains(long tagId, long entryId) {
1283 List<Integer> results = _mappingSqlQuery.execute(new Object[] {
1284 new Long(tagId), new Long(entryId)
1285 });
1286
1287 if (results.size() > 0) {
1288 Integer count = results.get(0);
1289
1290 if (count.intValue() > 0) {
1291 return true;
1292 }
1293 }
1294
1295 return false;
1296 }
1297
1298 private MappingSqlQuery<Integer> _mappingSqlQuery;
1299 }
1300
1301 protected class AddAssetEntry {
1302 protected AddAssetEntry(AssetTagPersistenceImpl persistenceImpl) {
1303 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
1304 "INSERT INTO AssetEntries_AssetTags (tagId, entryId) VALUES (?, ?)",
1305 new int[] { Types.BIGINT, Types.BIGINT });
1306 _persistenceImpl = persistenceImpl;
1307 }
1308
1309 protected void add(long tagId, long entryId) throws SystemException {
1310 if (!_persistenceImpl.containsAssetEntry.contains(tagId, entryId)) {
1311 ModelListener<com.liferay.portlet.asset.model.AssetEntry>[] assetEntryListeners =
1312 assetEntryPersistence.getListeners();
1313
1314 for (ModelListener<AssetTag> listener : listeners) {
1315 listener.onBeforeAddAssociation(tagId,
1316 com.liferay.portlet.asset.model.AssetEntry.class.getName(),
1317 entryId);
1318 }
1319
1320 for (ModelListener<com.liferay.portlet.asset.model.AssetEntry> listener : assetEntryListeners) {
1321 listener.onBeforeAddAssociation(entryId,
1322 AssetTag.class.getName(), tagId);
1323 }
1324
1325 _sqlUpdate.update(new Object[] {
1326 new Long(tagId), new Long(entryId)
1327 });
1328
1329 for (ModelListener<AssetTag> listener : listeners) {
1330 listener.onAfterAddAssociation(tagId,
1331 com.liferay.portlet.asset.model.AssetEntry.class.getName(),
1332 entryId);
1333 }
1334
1335 for (ModelListener<com.liferay.portlet.asset.model.AssetEntry> listener : assetEntryListeners) {
1336 listener.onAfterAddAssociation(entryId,
1337 AssetTag.class.getName(), tagId);
1338 }
1339 }
1340 }
1341
1342 private SqlUpdate _sqlUpdate;
1343 private AssetTagPersistenceImpl _persistenceImpl;
1344 }
1345
1346 protected class ClearAssetEntries {
1347 protected ClearAssetEntries(AssetTagPersistenceImpl persistenceImpl) {
1348 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
1349 "DELETE FROM AssetEntries_AssetTags WHERE tagId = ?",
1350 new int[] { Types.BIGINT });
1351 }
1352
1353 protected void clear(long tagId) throws SystemException {
1354 ModelListener<com.liferay.portlet.asset.model.AssetEntry>[] assetEntryListeners =
1355 assetEntryPersistence.getListeners();
1356
1357 List<com.liferay.portlet.asset.model.AssetEntry> assetEntries = null;
1358
1359 if ((listeners.length > 0) || (assetEntryListeners.length > 0)) {
1360 assetEntries = getAssetEntries(tagId);
1361
1362 for (com.liferay.portlet.asset.model.AssetEntry assetEntry : assetEntries) {
1363 for (ModelListener<AssetTag> listener : listeners) {
1364 listener.onBeforeRemoveAssociation(tagId,
1365 com.liferay.portlet.asset.model.AssetEntry.class.getName(),
1366 assetEntry.getPrimaryKey());
1367 }
1368
1369 for (ModelListener<com.liferay.portlet.asset.model.AssetEntry> listener : assetEntryListeners) {
1370 listener.onBeforeRemoveAssociation(assetEntry.getPrimaryKey(),
1371 AssetTag.class.getName(), tagId);
1372 }
1373 }
1374 }
1375
1376 _sqlUpdate.update(new Object[] { new Long(tagId) });
1377
1378 if ((listeners.length > 0) || (assetEntryListeners.length > 0)) {
1379 for (com.liferay.portlet.asset.model.AssetEntry assetEntry : assetEntries) {
1380 for (ModelListener<AssetTag> listener : listeners) {
1381 listener.onAfterRemoveAssociation(tagId,
1382 com.liferay.portlet.asset.model.AssetEntry.class.getName(),
1383 assetEntry.getPrimaryKey());
1384 }
1385
1386 for (ModelListener<com.liferay.portlet.asset.model.AssetEntry> listener : assetEntryListeners) {
1387 listener.onAfterRemoveAssociation(assetEntry.getPrimaryKey(),
1388 AssetTag.class.getName(), tagId);
1389 }
1390 }
1391 }
1392 }
1393
1394 private SqlUpdate _sqlUpdate;
1395 }
1396
1397 protected class RemoveAssetEntry {
1398 protected RemoveAssetEntry(AssetTagPersistenceImpl persistenceImpl) {
1399 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
1400 "DELETE FROM AssetEntries_AssetTags WHERE tagId = ? AND entryId = ?",
1401 new int[] { Types.BIGINT, Types.BIGINT });
1402 _persistenceImpl = persistenceImpl;
1403 }
1404
1405 protected void remove(long tagId, long entryId)
1406 throws SystemException {
1407 if (_persistenceImpl.containsAssetEntry.contains(tagId, entryId)) {
1408 ModelListener<com.liferay.portlet.asset.model.AssetEntry>[] assetEntryListeners =
1409 assetEntryPersistence.getListeners();
1410
1411 for (ModelListener<AssetTag> listener : listeners) {
1412 listener.onBeforeRemoveAssociation(tagId,
1413 com.liferay.portlet.asset.model.AssetEntry.class.getName(),
1414 entryId);
1415 }
1416
1417 for (ModelListener<com.liferay.portlet.asset.model.AssetEntry> listener : assetEntryListeners) {
1418 listener.onBeforeRemoveAssociation(entryId,
1419 AssetTag.class.getName(), tagId);
1420 }
1421
1422 _sqlUpdate.update(new Object[] {
1423 new Long(tagId), new Long(entryId)
1424 });
1425
1426 for (ModelListener<AssetTag> listener : listeners) {
1427 listener.onAfterRemoveAssociation(tagId,
1428 com.liferay.portlet.asset.model.AssetEntry.class.getName(),
1429 entryId);
1430 }
1431
1432 for (ModelListener<com.liferay.portlet.asset.model.AssetEntry> listener : assetEntryListeners) {
1433 listener.onAfterRemoveAssociation(entryId,
1434 AssetTag.class.getName(), tagId);
1435 }
1436 }
1437 }
1438
1439 private SqlUpdate _sqlUpdate;
1440 private AssetTagPersistenceImpl _persistenceImpl;
1441 }
1442
1443 private static final String _SQL_SELECT_ASSETTAG = "SELECT assetTag FROM AssetTag assetTag";
1444 private static final String _SQL_SELECT_ASSETTAG_WHERE = "SELECT assetTag FROM AssetTag assetTag WHERE ";
1445 private static final String _SQL_COUNT_ASSETTAG = "SELECT COUNT(assetTag) FROM AssetTag assetTag";
1446 private static final String _SQL_COUNT_ASSETTAG_WHERE = "SELECT COUNT(assetTag) FROM AssetTag assetTag WHERE ";
1447 private static final String _SQL_GETASSETENTRIES = "SELECT {AssetEntry.*} FROM AssetEntry INNER JOIN AssetEntries_AssetTags ON (AssetEntries_AssetTags.entryId = AssetEntry.entryId) WHERE (AssetEntries_AssetTags.tagId = ?)";
1448 private static final String _SQL_GETASSETENTRIESSIZE = "SELECT COUNT(*) AS COUNT_VALUE FROM AssetEntries_AssetTags WHERE tagId = ?";
1449 private static final String _SQL_CONTAINSASSETENTRY = "SELECT COUNT(*) AS COUNT_VALUE FROM AssetEntries_AssetTags WHERE tagId = ? AND entryId = ?";
1450 private static final String _FINDER_COLUMN_GROUPID_GROUPID_2 = "assetTag.groupId = ?";
1451 private static final String _FILTER_SQL_SELECT_ASSETTAG_WHERE = "SELECT DISTINCT {assetTag.*} FROM AssetTag assetTag WHERE ";
1452 private static final String _FILTER_SQL_COUNT_ASSETTAG_WHERE = "SELECT COUNT(DISTINCT assetTag.tagId) AS COUNT_VALUE FROM AssetTag assetTag WHERE ";
1453 private static final String _FILTER_COLUMN_TAGID = "assetTag.tagId";
1454 private static final String _FILTER_COLUMN_USERID = "assetTag.userId";
1455 private static final String _FILTER_ENTITY_ALIAS = "assetTag";
1456 private static final String _ORDER_BY_ENTITY_ALIAS = "assetTag.";
1457 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No AssetTag exists with the primary key ";
1458 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No AssetTag exists with the key {";
1459 private static Log _log = LogFactoryUtil.getLog(AssetTagPersistenceImpl.class);
1460}