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