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