1
14
15 package com.liferay.portlet.tags.service.persistence;
16
17 import com.liferay.portal.NoSuchModelException;
18 import com.liferay.portal.SystemException;
19 import com.liferay.portal.kernel.annotation.BeanReference;
20 import com.liferay.portal.kernel.cache.CacheRegistry;
21 import com.liferay.portal.kernel.dao.jdbc.MappingSqlQuery;
22 import com.liferay.portal.kernel.dao.jdbc.MappingSqlQueryFactoryUtil;
23 import com.liferay.portal.kernel.dao.jdbc.RowMapper;
24 import com.liferay.portal.kernel.dao.jdbc.SqlUpdate;
25 import com.liferay.portal.kernel.dao.jdbc.SqlUpdateFactoryUtil;
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.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.blogs.service.persistence.BlogsEntryPersistence;
52 import com.liferay.portlet.bookmarks.service.persistence.BookmarksEntryPersistence;
53 import com.liferay.portlet.documentlibrary.service.persistence.DLFileEntryPersistence;
54 import com.liferay.portlet.journal.service.persistence.JournalArticlePersistence;
55 import com.liferay.portlet.journal.service.persistence.JournalArticleResourcePersistence;
56 import com.liferay.portlet.messageboards.service.persistence.MBMessagePersistence;
57 import com.liferay.portlet.tags.NoSuchAssetException;
58 import com.liferay.portlet.tags.model.TagsAsset;
59 import com.liferay.portlet.tags.model.impl.TagsAssetImpl;
60 import com.liferay.portlet.tags.model.impl.TagsAssetModelImpl;
61 import com.liferay.portlet.wiki.service.persistence.WikiPagePersistence;
62 import com.liferay.portlet.wiki.service.persistence.WikiPageResourcePersistence;
63
64 import java.io.Serializable;
65
66 import java.sql.Types;
67
68 import java.util.ArrayList;
69 import java.util.Collections;
70 import java.util.List;
71 import java.util.Set;
72
73
86 public class TagsAssetPersistenceImpl extends BasePersistenceImpl<TagsAsset>
87 implements TagsAssetPersistence {
88 public static final String FINDER_CLASS_NAME_ENTITY = TagsAssetImpl.class.getName();
89 public static final String FINDER_CLASS_NAME_LIST = FINDER_CLASS_NAME_ENTITY +
90 ".List";
91 public static final FinderPath FINDER_PATH_FIND_BY_COMPANYID = new FinderPath(TagsAssetModelImpl.ENTITY_CACHE_ENABLED,
92 TagsAssetModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
93 "findByCompanyId", new String[] { Long.class.getName() });
94 public static final FinderPath FINDER_PATH_FIND_BY_OBC_COMPANYID = new FinderPath(TagsAssetModelImpl.ENTITY_CACHE_ENABLED,
95 TagsAssetModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
96 "findByCompanyId",
97 new String[] {
98 Long.class.getName(),
99
100 "java.lang.Integer", "java.lang.Integer",
101 "com.liferay.portal.kernel.util.OrderByComparator"
102 });
103 public static final FinderPath FINDER_PATH_COUNT_BY_COMPANYID = new FinderPath(TagsAssetModelImpl.ENTITY_CACHE_ENABLED,
104 TagsAssetModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
105 "countByCompanyId", new String[] { Long.class.getName() });
106 public static final FinderPath FINDER_PATH_FETCH_BY_C_C = new FinderPath(TagsAssetModelImpl.ENTITY_CACHE_ENABLED,
107 TagsAssetModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_ENTITY,
108 "fetchByC_C",
109 new String[] { Long.class.getName(), Long.class.getName() });
110 public static final FinderPath FINDER_PATH_COUNT_BY_C_C = new FinderPath(TagsAssetModelImpl.ENTITY_CACHE_ENABLED,
111 TagsAssetModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
112 "countByC_C",
113 new String[] { Long.class.getName(), Long.class.getName() });
114 public static final FinderPath FINDER_PATH_FIND_ALL = new FinderPath(TagsAssetModelImpl.ENTITY_CACHE_ENABLED,
115 TagsAssetModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
116 "findAll", new String[0]);
117 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(TagsAssetModelImpl.ENTITY_CACHE_ENABLED,
118 TagsAssetModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
119 "countAll", new String[0]);
120
121 public void cacheResult(TagsAsset tagsAsset) {
122 EntityCacheUtil.putResult(TagsAssetModelImpl.ENTITY_CACHE_ENABLED,
123 TagsAssetImpl.class, tagsAsset.getPrimaryKey(), tagsAsset);
124
125 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C,
126 new Object[] {
127 new Long(tagsAsset.getClassNameId()),
128 new Long(tagsAsset.getClassPK())
129 }, tagsAsset);
130 }
131
132 public void cacheResult(List<TagsAsset> tagsAssets) {
133 for (TagsAsset tagsAsset : tagsAssets) {
134 if (EntityCacheUtil.getResult(
135 TagsAssetModelImpl.ENTITY_CACHE_ENABLED,
136 TagsAssetImpl.class, tagsAsset.getPrimaryKey(), this) == null) {
137 cacheResult(tagsAsset);
138 }
139 }
140 }
141
142 public void clearCache() {
143 CacheRegistry.clear(TagsAssetImpl.class.getName());
144 EntityCacheUtil.clearCache(TagsAssetImpl.class.getName());
145 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
146 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
147 }
148
149 public TagsAsset create(long assetId) {
150 TagsAsset tagsAsset = new TagsAssetImpl();
151
152 tagsAsset.setNew(true);
153 tagsAsset.setPrimaryKey(assetId);
154
155 return tagsAsset;
156 }
157
158 public TagsAsset remove(Serializable primaryKey)
159 throws NoSuchModelException, SystemException {
160 return remove(((Long)primaryKey).longValue());
161 }
162
163 public TagsAsset remove(long assetId)
164 throws NoSuchAssetException, SystemException {
165 Session session = null;
166
167 try {
168 session = openSession();
169
170 TagsAsset tagsAsset = (TagsAsset)session.get(TagsAssetImpl.class,
171 new Long(assetId));
172
173 if (tagsAsset == null) {
174 if (_log.isWarnEnabled()) {
175 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + assetId);
176 }
177
178 throw new NoSuchAssetException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
179 assetId);
180 }
181
182 return remove(tagsAsset);
183 }
184 catch (NoSuchAssetException nsee) {
185 throw nsee;
186 }
187 catch (Exception e) {
188 throw processException(e);
189 }
190 finally {
191 closeSession(session);
192 }
193 }
194
195 public TagsAsset remove(TagsAsset tagsAsset) throws SystemException {
196 for (ModelListener<TagsAsset> listener : listeners) {
197 listener.onBeforeRemove(tagsAsset);
198 }
199
200 tagsAsset = removeImpl(tagsAsset);
201
202 for (ModelListener<TagsAsset> listener : listeners) {
203 listener.onAfterRemove(tagsAsset);
204 }
205
206 return tagsAsset;
207 }
208
209 protected TagsAsset removeImpl(TagsAsset tagsAsset)
210 throws SystemException {
211 tagsAsset = toUnwrappedModel(tagsAsset);
212
213 try {
214 clearTagsEntries.clear(tagsAsset.getPrimaryKey());
215 }
216 catch (Exception e) {
217 throw processException(e);
218 }
219 finally {
220 FinderCacheUtil.clearCache(TagsAssetModelImpl.MAPPING_TABLE_TAGSASSETS_TAGSENTRIES_NAME);
221 }
222
223 Session session = null;
224
225 try {
226 session = openSession();
227
228 if (tagsAsset.isCachedModel() || BatchSessionUtil.isEnabled()) {
229 Object staleObject = session.get(TagsAssetImpl.class,
230 tagsAsset.getPrimaryKeyObj());
231
232 if (staleObject != null) {
233 session.evict(staleObject);
234 }
235 }
236
237 session.delete(tagsAsset);
238
239 session.flush();
240 }
241 catch (Exception e) {
242 throw processException(e);
243 }
244 finally {
245 closeSession(session);
246 }
247
248 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
249
250 TagsAssetModelImpl tagsAssetModelImpl = (TagsAssetModelImpl)tagsAsset;
251
252 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_C,
253 new Object[] {
254 new Long(tagsAssetModelImpl.getOriginalClassNameId()),
255 new Long(tagsAssetModelImpl.getOriginalClassPK())
256 });
257
258 EntityCacheUtil.removeResult(TagsAssetModelImpl.ENTITY_CACHE_ENABLED,
259 TagsAssetImpl.class, tagsAsset.getPrimaryKey());
260
261 return tagsAsset;
262 }
263
264
267 public TagsAsset update(TagsAsset tagsAsset) throws SystemException {
268 if (_log.isWarnEnabled()) {
269 _log.warn(
270 "Using the deprecated update(TagsAsset tagsAsset) method. Use update(TagsAsset tagsAsset, boolean merge) instead.");
271 }
272
273 return update(tagsAsset, false);
274 }
275
276 public TagsAsset updateImpl(
277 com.liferay.portlet.tags.model.TagsAsset tagsAsset, boolean merge)
278 throws SystemException {
279 tagsAsset = toUnwrappedModel(tagsAsset);
280
281 boolean isNew = tagsAsset.isNew();
282
283 TagsAssetModelImpl tagsAssetModelImpl = (TagsAssetModelImpl)tagsAsset;
284
285 Session session = null;
286
287 try {
288 session = openSession();
289
290 BatchSessionUtil.update(session, tagsAsset, merge);
291
292 tagsAsset.setNew(false);
293 }
294 catch (Exception e) {
295 throw processException(e);
296 }
297 finally {
298 closeSession(session);
299 }
300
301 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
302
303 EntityCacheUtil.putResult(TagsAssetModelImpl.ENTITY_CACHE_ENABLED,
304 TagsAssetImpl.class, tagsAsset.getPrimaryKey(), tagsAsset);
305
306 if (!isNew &&
307 ((tagsAsset.getClassNameId() != tagsAssetModelImpl.getOriginalClassNameId()) ||
308 (tagsAsset.getClassPK() != tagsAssetModelImpl.getOriginalClassPK()))) {
309 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_C,
310 new Object[] {
311 new Long(tagsAssetModelImpl.getOriginalClassNameId()),
312 new Long(tagsAssetModelImpl.getOriginalClassPK())
313 });
314 }
315
316 if (isNew ||
317 ((tagsAsset.getClassNameId() != tagsAssetModelImpl.getOriginalClassNameId()) ||
318 (tagsAsset.getClassPK() != tagsAssetModelImpl.getOriginalClassPK()))) {
319 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C,
320 new Object[] {
321 new Long(tagsAsset.getClassNameId()),
322 new Long(tagsAsset.getClassPK())
323 }, tagsAsset);
324 }
325
326 return tagsAsset;
327 }
328
329 protected TagsAsset toUnwrappedModel(TagsAsset tagsAsset) {
330 if (tagsAsset instanceof TagsAssetImpl) {
331 return tagsAsset;
332 }
333
334 TagsAssetImpl tagsAssetImpl = new TagsAssetImpl();
335
336 tagsAssetImpl.setNew(tagsAsset.isNew());
337 tagsAssetImpl.setPrimaryKey(tagsAsset.getPrimaryKey());
338
339 tagsAssetImpl.setAssetId(tagsAsset.getAssetId());
340 tagsAssetImpl.setGroupId(tagsAsset.getGroupId());
341 tagsAssetImpl.setCompanyId(tagsAsset.getCompanyId());
342 tagsAssetImpl.setUserId(tagsAsset.getUserId());
343 tagsAssetImpl.setUserName(tagsAsset.getUserName());
344 tagsAssetImpl.setCreateDate(tagsAsset.getCreateDate());
345 tagsAssetImpl.setModifiedDate(tagsAsset.getModifiedDate());
346 tagsAssetImpl.setClassNameId(tagsAsset.getClassNameId());
347 tagsAssetImpl.setClassPK(tagsAsset.getClassPK());
348 tagsAssetImpl.setVisible(tagsAsset.isVisible());
349 tagsAssetImpl.setStartDate(tagsAsset.getStartDate());
350 tagsAssetImpl.setEndDate(tagsAsset.getEndDate());
351 tagsAssetImpl.setPublishDate(tagsAsset.getPublishDate());
352 tagsAssetImpl.setExpirationDate(tagsAsset.getExpirationDate());
353 tagsAssetImpl.setMimeType(tagsAsset.getMimeType());
354 tagsAssetImpl.setTitle(tagsAsset.getTitle());
355 tagsAssetImpl.setDescription(tagsAsset.getDescription());
356 tagsAssetImpl.setSummary(tagsAsset.getSummary());
357 tagsAssetImpl.setUrl(tagsAsset.getUrl());
358 tagsAssetImpl.setHeight(tagsAsset.getHeight());
359 tagsAssetImpl.setWidth(tagsAsset.getWidth());
360 tagsAssetImpl.setPriority(tagsAsset.getPriority());
361 tagsAssetImpl.setViewCount(tagsAsset.getViewCount());
362
363 return tagsAssetImpl;
364 }
365
366 public TagsAsset findByPrimaryKey(Serializable primaryKey)
367 throws NoSuchModelException, SystemException {
368 return findByPrimaryKey(((Long)primaryKey).longValue());
369 }
370
371 public TagsAsset findByPrimaryKey(long assetId)
372 throws NoSuchAssetException, SystemException {
373 TagsAsset tagsAsset = fetchByPrimaryKey(assetId);
374
375 if (tagsAsset == null) {
376 if (_log.isWarnEnabled()) {
377 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + assetId);
378 }
379
380 throw new NoSuchAssetException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
381 assetId);
382 }
383
384 return tagsAsset;
385 }
386
387 public TagsAsset fetchByPrimaryKey(Serializable primaryKey)
388 throws SystemException {
389 return fetchByPrimaryKey(((Long)primaryKey).longValue());
390 }
391
392 public TagsAsset fetchByPrimaryKey(long assetId) throws SystemException {
393 TagsAsset tagsAsset = (TagsAsset)EntityCacheUtil.getResult(TagsAssetModelImpl.ENTITY_CACHE_ENABLED,
394 TagsAssetImpl.class, assetId, this);
395
396 if (tagsAsset == null) {
397 Session session = null;
398
399 try {
400 session = openSession();
401
402 tagsAsset = (TagsAsset)session.get(TagsAssetImpl.class,
403 new Long(assetId));
404 }
405 catch (Exception e) {
406 throw processException(e);
407 }
408 finally {
409 if (tagsAsset != null) {
410 cacheResult(tagsAsset);
411 }
412
413 closeSession(session);
414 }
415 }
416
417 return tagsAsset;
418 }
419
420 public List<TagsAsset> findByCompanyId(long companyId)
421 throws SystemException {
422 Object[] finderArgs = new Object[] { new Long(companyId) };
423
424 List<TagsAsset> list = (List<TagsAsset>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_COMPANYID,
425 finderArgs, this);
426
427 if (list == null) {
428 Session session = null;
429
430 try {
431 session = openSession();
432
433 StringBundler query = new StringBundler(2);
434
435 query.append(_SQL_SELECT_TAGSASSET_WHERE);
436
437 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
438
439 String sql = query.toString();
440
441 Query q = session.createQuery(sql);
442
443 QueryPos qPos = QueryPos.getInstance(q);
444
445 qPos.add(companyId);
446
447 list = q.list();
448 }
449 catch (Exception e) {
450 throw processException(e);
451 }
452 finally {
453 if (list == null) {
454 list = new ArrayList<TagsAsset>();
455 }
456
457 cacheResult(list);
458
459 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_COMPANYID,
460 finderArgs, list);
461
462 closeSession(session);
463 }
464 }
465
466 return list;
467 }
468
469 public List<TagsAsset> findByCompanyId(long companyId, int start, int end)
470 throws SystemException {
471 return findByCompanyId(companyId, start, end, null);
472 }
473
474 public List<TagsAsset> findByCompanyId(long companyId, int start, int end,
475 OrderByComparator orderByComparator) throws SystemException {
476 Object[] finderArgs = new Object[] {
477 new Long(companyId),
478
479 String.valueOf(start), String.valueOf(end),
480 String.valueOf(orderByComparator)
481 };
482
483 List<TagsAsset> list = (List<TagsAsset>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_COMPANYID,
484 finderArgs, this);
485
486 if (list == null) {
487 Session session = null;
488
489 try {
490 session = openSession();
491
492 StringBundler query = null;
493
494 if (orderByComparator != null) {
495 query = new StringBundler(3 +
496 (orderByComparator.getOrderByFields().length * 3));
497 }
498 else {
499 query = new StringBundler(2);
500 }
501
502 query.append(_SQL_SELECT_TAGSASSET_WHERE);
503
504 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
505
506 if (orderByComparator != null) {
507 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
508 orderByComparator);
509 }
510
511 String sql = query.toString();
512
513 Query q = session.createQuery(sql);
514
515 QueryPos qPos = QueryPos.getInstance(q);
516
517 qPos.add(companyId);
518
519 list = (List<TagsAsset>)QueryUtil.list(q, getDialect(), start,
520 end);
521 }
522 catch (Exception e) {
523 throw processException(e);
524 }
525 finally {
526 if (list == null) {
527 list = new ArrayList<TagsAsset>();
528 }
529
530 cacheResult(list);
531
532 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_COMPANYID,
533 finderArgs, list);
534
535 closeSession(session);
536 }
537 }
538
539 return list;
540 }
541
542 public TagsAsset findByCompanyId_First(long companyId,
543 OrderByComparator orderByComparator)
544 throws NoSuchAssetException, SystemException {
545 List<TagsAsset> list = findByCompanyId(companyId, 0, 1,
546 orderByComparator);
547
548 if (list.isEmpty()) {
549 StringBundler msg = new StringBundler(4);
550
551 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
552
553 msg.append("companyId=");
554 msg.append(companyId);
555
556 msg.append(StringPool.CLOSE_CURLY_BRACE);
557
558 throw new NoSuchAssetException(msg.toString());
559 }
560 else {
561 return list.get(0);
562 }
563 }
564
565 public TagsAsset findByCompanyId_Last(long companyId,
566 OrderByComparator orderByComparator)
567 throws NoSuchAssetException, SystemException {
568 int count = countByCompanyId(companyId);
569
570 List<TagsAsset> list = findByCompanyId(companyId, count - 1, count,
571 orderByComparator);
572
573 if (list.isEmpty()) {
574 StringBundler msg = new StringBundler(4);
575
576 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
577
578 msg.append("companyId=");
579 msg.append(companyId);
580
581 msg.append(StringPool.CLOSE_CURLY_BRACE);
582
583 throw new NoSuchAssetException(msg.toString());
584 }
585 else {
586 return list.get(0);
587 }
588 }
589
590 public TagsAsset[] findByCompanyId_PrevAndNext(long assetId,
591 long companyId, OrderByComparator orderByComparator)
592 throws NoSuchAssetException, SystemException {
593 TagsAsset tagsAsset = findByPrimaryKey(assetId);
594
595 int count = countByCompanyId(companyId);
596
597 Session session = null;
598
599 try {
600 session = openSession();
601
602 StringBundler query = null;
603
604 if (orderByComparator != null) {
605 query = new StringBundler(3 +
606 (orderByComparator.getOrderByFields().length * 3));
607 }
608 else {
609 query = new StringBundler(2);
610 }
611
612 query.append(_SQL_SELECT_TAGSASSET_WHERE);
613
614 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
615
616 if (orderByComparator != null) {
617 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
618 orderByComparator);
619 }
620
621 String sql = query.toString();
622
623 Query q = session.createQuery(sql);
624
625 QueryPos qPos = QueryPos.getInstance(q);
626
627 qPos.add(companyId);
628
629 Object[] objArray = QueryUtil.getPrevAndNext(q, count,
630 orderByComparator, tagsAsset);
631
632 TagsAsset[] array = new TagsAssetImpl[3];
633
634 array[0] = (TagsAsset)objArray[0];
635 array[1] = (TagsAsset)objArray[1];
636 array[2] = (TagsAsset)objArray[2];
637
638 return array;
639 }
640 catch (Exception e) {
641 throw processException(e);
642 }
643 finally {
644 closeSession(session);
645 }
646 }
647
648 public TagsAsset findByC_C(long classNameId, long classPK)
649 throws NoSuchAssetException, SystemException {
650 TagsAsset tagsAsset = fetchByC_C(classNameId, classPK);
651
652 if (tagsAsset == null) {
653 StringBundler msg = new StringBundler(6);
654
655 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
656
657 msg.append("classNameId=");
658 msg.append(classNameId);
659
660 msg.append(", classPK=");
661 msg.append(classPK);
662
663 msg.append(StringPool.CLOSE_CURLY_BRACE);
664
665 if (_log.isWarnEnabled()) {
666 _log.warn(msg.toString());
667 }
668
669 throw new NoSuchAssetException(msg.toString());
670 }
671
672 return tagsAsset;
673 }
674
675 public TagsAsset fetchByC_C(long classNameId, long classPK)
676 throws SystemException {
677 return fetchByC_C(classNameId, classPK, true);
678 }
679
680 public TagsAsset fetchByC_C(long classNameId, long classPK,
681 boolean retrieveFromCache) throws SystemException {
682 Object[] finderArgs = new Object[] {
683 new Long(classNameId), new Long(classPK)
684 };
685
686 Object result = null;
687
688 if (retrieveFromCache) {
689 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_C_C,
690 finderArgs, this);
691 }
692
693 if (result == null) {
694 Session session = null;
695
696 try {
697 session = openSession();
698
699 StringBundler query = new StringBundler(3);
700
701 query.append(_SQL_SELECT_TAGSASSET_WHERE);
702
703 query.append(_FINDER_COLUMN_C_C_CLASSNAMEID_2);
704
705 query.append(_FINDER_COLUMN_C_C_CLASSPK_2);
706
707 String sql = query.toString();
708
709 Query q = session.createQuery(sql);
710
711 QueryPos qPos = QueryPos.getInstance(q);
712
713 qPos.add(classNameId);
714
715 qPos.add(classPK);
716
717 List<TagsAsset> list = q.list();
718
719 result = list;
720
721 TagsAsset tagsAsset = null;
722
723 if (list.isEmpty()) {
724 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C,
725 finderArgs, list);
726 }
727 else {
728 tagsAsset = list.get(0);
729
730 cacheResult(tagsAsset);
731
732 if ((tagsAsset.getClassNameId() != classNameId) ||
733 (tagsAsset.getClassPK() != classPK)) {
734 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C,
735 finderArgs, tagsAsset);
736 }
737 }
738
739 return tagsAsset;
740 }
741 catch (Exception e) {
742 throw processException(e);
743 }
744 finally {
745 if (result == null) {
746 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C,
747 finderArgs, new ArrayList<TagsAsset>());
748 }
749
750 closeSession(session);
751 }
752 }
753 else {
754 if (result instanceof List<?>) {
755 return null;
756 }
757 else {
758 return (TagsAsset)result;
759 }
760 }
761 }
762
763 public List<TagsAsset> findAll() throws SystemException {
764 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
765 }
766
767 public List<TagsAsset> findAll(int start, int end)
768 throws SystemException {
769 return findAll(start, end, null);
770 }
771
772 public List<TagsAsset> findAll(int start, int end,
773 OrderByComparator orderByComparator) throws SystemException {
774 Object[] finderArgs = new Object[] {
775 String.valueOf(start), String.valueOf(end),
776 String.valueOf(orderByComparator)
777 };
778
779 List<TagsAsset> list = (List<TagsAsset>)FinderCacheUtil.getResult(FINDER_PATH_FIND_ALL,
780 finderArgs, this);
781
782 if (list == null) {
783 Session session = null;
784
785 try {
786 session = openSession();
787
788 StringBundler query = null;
789 String sql = null;
790
791 if (orderByComparator != null) {
792 query = new StringBundler(2 +
793 (orderByComparator.getOrderByFields().length * 3));
794
795 query.append(_SQL_SELECT_TAGSASSET);
796
797 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
798 orderByComparator);
799
800 sql = query.toString();
801 }
802
803 sql = _SQL_SELECT_TAGSASSET;
804
805 Query q = session.createQuery(sql);
806
807 if (orderByComparator == null) {
808 list = (List<TagsAsset>)QueryUtil.list(q, getDialect(),
809 start, end, false);
810
811 Collections.sort(list);
812 }
813 else {
814 list = (List<TagsAsset>)QueryUtil.list(q, getDialect(),
815 start, end);
816 }
817 }
818 catch (Exception e) {
819 throw processException(e);
820 }
821 finally {
822 if (list == null) {
823 list = new ArrayList<TagsAsset>();
824 }
825
826 cacheResult(list);
827
828 FinderCacheUtil.putResult(FINDER_PATH_FIND_ALL, finderArgs, list);
829
830 closeSession(session);
831 }
832 }
833
834 return list;
835 }
836
837 public void removeByCompanyId(long companyId) throws SystemException {
838 for (TagsAsset tagsAsset : findByCompanyId(companyId)) {
839 remove(tagsAsset);
840 }
841 }
842
843 public void removeByC_C(long classNameId, long classPK)
844 throws NoSuchAssetException, SystemException {
845 TagsAsset tagsAsset = findByC_C(classNameId, classPK);
846
847 remove(tagsAsset);
848 }
849
850 public void removeAll() throws SystemException {
851 for (TagsAsset tagsAsset : findAll()) {
852 remove(tagsAsset);
853 }
854 }
855
856 public int countByCompanyId(long companyId) throws SystemException {
857 Object[] finderArgs = new Object[] { new Long(companyId) };
858
859 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_COMPANYID,
860 finderArgs, this);
861
862 if (count == null) {
863 Session session = null;
864
865 try {
866 session = openSession();
867
868 StringBundler query = new StringBundler(2);
869
870 query.append(_SQL_COUNT_TAGSASSET_WHERE);
871
872 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
873
874 String sql = query.toString();
875
876 Query q = session.createQuery(sql);
877
878 QueryPos qPos = QueryPos.getInstance(q);
879
880 qPos.add(companyId);
881
882 count = (Long)q.uniqueResult();
883 }
884 catch (Exception e) {
885 throw processException(e);
886 }
887 finally {
888 if (count == null) {
889 count = Long.valueOf(0);
890 }
891
892 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_COMPANYID,
893 finderArgs, count);
894
895 closeSession(session);
896 }
897 }
898
899 return count.intValue();
900 }
901
902 public int countByC_C(long classNameId, long classPK)
903 throws SystemException {
904 Object[] finderArgs = new Object[] {
905 new Long(classNameId), new Long(classPK)
906 };
907
908 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_C,
909 finderArgs, this);
910
911 if (count == null) {
912 Session session = null;
913
914 try {
915 session = openSession();
916
917 StringBundler query = new StringBundler(3);
918
919 query.append(_SQL_COUNT_TAGSASSET_WHERE);
920
921 query.append(_FINDER_COLUMN_C_C_CLASSNAMEID_2);
922
923 query.append(_FINDER_COLUMN_C_C_CLASSPK_2);
924
925 String sql = query.toString();
926
927 Query q = session.createQuery(sql);
928
929 QueryPos qPos = QueryPos.getInstance(q);
930
931 qPos.add(classNameId);
932
933 qPos.add(classPK);
934
935 count = (Long)q.uniqueResult();
936 }
937 catch (Exception e) {
938 throw processException(e);
939 }
940 finally {
941 if (count == null) {
942 count = Long.valueOf(0);
943 }
944
945 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_C, finderArgs,
946 count);
947
948 closeSession(session);
949 }
950 }
951
952 return count.intValue();
953 }
954
955 public int countAll() throws SystemException {
956 Object[] finderArgs = new Object[0];
957
958 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
959 finderArgs, this);
960
961 if (count == null) {
962 Session session = null;
963
964 try {
965 session = openSession();
966
967 Query q = session.createQuery(_SQL_COUNT_TAGSASSET);
968
969 count = (Long)q.uniqueResult();
970 }
971 catch (Exception e) {
972 throw processException(e);
973 }
974 finally {
975 if (count == null) {
976 count = Long.valueOf(0);
977 }
978
979 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL, finderArgs,
980 count);
981
982 closeSession(session);
983 }
984 }
985
986 return count.intValue();
987 }
988
989 public List<com.liferay.portlet.tags.model.TagsEntry> getTagsEntries(
990 long pk) throws SystemException {
991 return getTagsEntries(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
992 }
993
994 public List<com.liferay.portlet.tags.model.TagsEntry> getTagsEntries(
995 long pk, int start, int end) throws SystemException {
996 return getTagsEntries(pk, start, end, null);
997 }
998
999 public static final FinderPath FINDER_PATH_GET_TAGSENTRIES = new FinderPath(com.liferay.portlet.tags.model.impl.TagsEntryModelImpl.ENTITY_CACHE_ENABLED,
1000 TagsAssetModelImpl.FINDER_CACHE_ENABLED_TAGSASSETS_TAGSENTRIES,
1001 TagsAssetModelImpl.MAPPING_TABLE_TAGSASSETS_TAGSENTRIES_NAME,
1002 "getTagsEntries",
1003 new String[] {
1004 Long.class.getName(), "java.lang.Integer", "java.lang.Integer",
1005 "com.liferay.portal.kernel.util.OrderByComparator"
1006 });
1007
1008 public List<com.liferay.portlet.tags.model.TagsEntry> getTagsEntries(
1009 long pk, int start, int end, OrderByComparator orderByComparator)
1010 throws SystemException {
1011 Object[] finderArgs = new Object[] {
1012 new Long(pk), String.valueOf(start), String.valueOf(end),
1013 String.valueOf(orderByComparator)
1014 };
1015
1016 List<com.liferay.portlet.tags.model.TagsEntry> list = (List<com.liferay.portlet.tags.model.TagsEntry>)FinderCacheUtil.getResult(FINDER_PATH_GET_TAGSENTRIES,
1017 finderArgs, this);
1018
1019 if (list == null) {
1020 Session session = null;
1021
1022 try {
1023 session = openSession();
1024
1025 String sql = null;
1026
1027 if (orderByComparator != null) {
1028 sql = _SQL_GETTAGSENTRIES.concat(ORDER_BY_CLAUSE)
1029 .concat(orderByComparator.getOrderBy());
1030 }
1031
1032 else {
1033 sql = _SQL_GETTAGSENTRIES.concat(com.liferay.portlet.tags.model.impl.TagsEntryModelImpl.ORDER_BY_SQL);
1034 }
1035
1036 SQLQuery q = session.createSQLQuery(sql);
1037
1038 q.addEntity("TagsEntry",
1039 com.liferay.portlet.tags.model.impl.TagsEntryImpl.class);
1040
1041 QueryPos qPos = QueryPos.getInstance(q);
1042
1043 qPos.add(pk);
1044
1045 list = (List<com.liferay.portlet.tags.model.TagsEntry>)QueryUtil.list(q,
1046 getDialect(), start, end);
1047 }
1048 catch (Exception e) {
1049 throw processException(e);
1050 }
1051 finally {
1052 if (list == null) {
1053 list = new ArrayList<com.liferay.portlet.tags.model.TagsEntry>();
1054 }
1055
1056 tagsEntryPersistence.cacheResult(list);
1057
1058 FinderCacheUtil.putResult(FINDER_PATH_GET_TAGSENTRIES,
1059 finderArgs, list);
1060
1061 closeSession(session);
1062 }
1063 }
1064
1065 return list;
1066 }
1067
1068 public static final FinderPath FINDER_PATH_GET_TAGSENTRIES_SIZE = new FinderPath(com.liferay.portlet.tags.model.impl.TagsEntryModelImpl.ENTITY_CACHE_ENABLED,
1069 TagsAssetModelImpl.FINDER_CACHE_ENABLED_TAGSASSETS_TAGSENTRIES,
1070 TagsAssetModelImpl.MAPPING_TABLE_TAGSASSETS_TAGSENTRIES_NAME,
1071 "getTagsEntriesSize", new String[] { Long.class.getName() });
1072
1073 public int getTagsEntriesSize(long pk) throws SystemException {
1074 Object[] finderArgs = new Object[] { new Long(pk) };
1075
1076 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_GET_TAGSENTRIES_SIZE,
1077 finderArgs, this);
1078
1079 if (count == null) {
1080 Session session = null;
1081
1082 try {
1083 session = openSession();
1084
1085 SQLQuery q = session.createSQLQuery(_SQL_GETTAGSENTRIESSIZE);
1086
1087 q.addScalar(COUNT_COLUMN_NAME, Type.LONG);
1088
1089 QueryPos qPos = QueryPos.getInstance(q);
1090
1091 qPos.add(pk);
1092
1093 count = (Long)q.uniqueResult();
1094 }
1095 catch (Exception e) {
1096 throw processException(e);
1097 }
1098 finally {
1099 if (count == null) {
1100 count = Long.valueOf(0);
1101 }
1102
1103 FinderCacheUtil.putResult(FINDER_PATH_GET_TAGSENTRIES_SIZE,
1104 finderArgs, count);
1105
1106 closeSession(session);
1107 }
1108 }
1109
1110 return count.intValue();
1111 }
1112
1113 public static final FinderPath FINDER_PATH_CONTAINS_TAGSENTRY = new FinderPath(com.liferay.portlet.tags.model.impl.TagsEntryModelImpl.ENTITY_CACHE_ENABLED,
1114 TagsAssetModelImpl.FINDER_CACHE_ENABLED_TAGSASSETS_TAGSENTRIES,
1115 TagsAssetModelImpl.MAPPING_TABLE_TAGSASSETS_TAGSENTRIES_NAME,
1116 "containsTagsEntry",
1117 new String[] { Long.class.getName(), Long.class.getName() });
1118
1119 public boolean containsTagsEntry(long pk, long tagsEntryPK)
1120 throws SystemException {
1121 Object[] finderArgs = new Object[] { new Long(pk), new Long(tagsEntryPK) };
1122
1123 Boolean value = (Boolean)FinderCacheUtil.getResult(FINDER_PATH_CONTAINS_TAGSENTRY,
1124 finderArgs, this);
1125
1126 if (value == null) {
1127 try {
1128 value = Boolean.valueOf(containsTagsEntry.contains(pk,
1129 tagsEntryPK));
1130 }
1131 catch (Exception e) {
1132 throw processException(e);
1133 }
1134 finally {
1135 if (value == null) {
1136 value = Boolean.FALSE;
1137 }
1138
1139 FinderCacheUtil.putResult(FINDER_PATH_CONTAINS_TAGSENTRY,
1140 finderArgs, value);
1141 }
1142 }
1143
1144 return value.booleanValue();
1145 }
1146
1147 public boolean containsTagsEntries(long pk) throws SystemException {
1148 if (getTagsEntriesSize(pk) > 0) {
1149 return true;
1150 }
1151 else {
1152 return false;
1153 }
1154 }
1155
1156 public void addTagsEntry(long pk, long tagsEntryPK)
1157 throws SystemException {
1158 try {
1159 addTagsEntry.add(pk, tagsEntryPK);
1160 }
1161 catch (Exception e) {
1162 throw processException(e);
1163 }
1164 finally {
1165 FinderCacheUtil.clearCache(TagsAssetModelImpl.MAPPING_TABLE_TAGSASSETS_TAGSENTRIES_NAME);
1166 }
1167 }
1168
1169 public void addTagsEntry(long pk,
1170 com.liferay.portlet.tags.model.TagsEntry tagsEntry)
1171 throws SystemException {
1172 try {
1173 addTagsEntry.add(pk, tagsEntry.getPrimaryKey());
1174 }
1175 catch (Exception e) {
1176 throw processException(e);
1177 }
1178 finally {
1179 FinderCacheUtil.clearCache(TagsAssetModelImpl.MAPPING_TABLE_TAGSASSETS_TAGSENTRIES_NAME);
1180 }
1181 }
1182
1183 public void addTagsEntries(long pk, long[] tagsEntryPKs)
1184 throws SystemException {
1185 try {
1186 for (long tagsEntryPK : tagsEntryPKs) {
1187 addTagsEntry.add(pk, tagsEntryPK);
1188 }
1189 }
1190 catch (Exception e) {
1191 throw processException(e);
1192 }
1193 finally {
1194 FinderCacheUtil.clearCache(TagsAssetModelImpl.MAPPING_TABLE_TAGSASSETS_TAGSENTRIES_NAME);
1195 }
1196 }
1197
1198 public void addTagsEntries(long pk,
1199 List<com.liferay.portlet.tags.model.TagsEntry> tagsEntries)
1200 throws SystemException {
1201 try {
1202 for (com.liferay.portlet.tags.model.TagsEntry tagsEntry : tagsEntries) {
1203 addTagsEntry.add(pk, tagsEntry.getPrimaryKey());
1204 }
1205 }
1206 catch (Exception e) {
1207 throw processException(e);
1208 }
1209 finally {
1210 FinderCacheUtil.clearCache(TagsAssetModelImpl.MAPPING_TABLE_TAGSASSETS_TAGSENTRIES_NAME);
1211 }
1212 }
1213
1214 public void clearTagsEntries(long pk) throws SystemException {
1215 try {
1216 clearTagsEntries.clear(pk);
1217 }
1218 catch (Exception e) {
1219 throw processException(e);
1220 }
1221 finally {
1222 FinderCacheUtil.clearCache(TagsAssetModelImpl.MAPPING_TABLE_TAGSASSETS_TAGSENTRIES_NAME);
1223 }
1224 }
1225
1226 public void removeTagsEntry(long pk, long tagsEntryPK)
1227 throws SystemException {
1228 try {
1229 removeTagsEntry.remove(pk, tagsEntryPK);
1230 }
1231 catch (Exception e) {
1232 throw processException(e);
1233 }
1234 finally {
1235 FinderCacheUtil.clearCache(TagsAssetModelImpl.MAPPING_TABLE_TAGSASSETS_TAGSENTRIES_NAME);
1236 }
1237 }
1238
1239 public void removeTagsEntry(long pk,
1240 com.liferay.portlet.tags.model.TagsEntry tagsEntry)
1241 throws SystemException {
1242 try {
1243 removeTagsEntry.remove(pk, tagsEntry.getPrimaryKey());
1244 }
1245 catch (Exception e) {
1246 throw processException(e);
1247 }
1248 finally {
1249 FinderCacheUtil.clearCache(TagsAssetModelImpl.MAPPING_TABLE_TAGSASSETS_TAGSENTRIES_NAME);
1250 }
1251 }
1252
1253 public void removeTagsEntries(long pk, long[] tagsEntryPKs)
1254 throws SystemException {
1255 try {
1256 for (long tagsEntryPK : tagsEntryPKs) {
1257 removeTagsEntry.remove(pk, tagsEntryPK);
1258 }
1259 }
1260 catch (Exception e) {
1261 throw processException(e);
1262 }
1263 finally {
1264 FinderCacheUtil.clearCache(TagsAssetModelImpl.MAPPING_TABLE_TAGSASSETS_TAGSENTRIES_NAME);
1265 }
1266 }
1267
1268 public void removeTagsEntries(long pk,
1269 List<com.liferay.portlet.tags.model.TagsEntry> tagsEntries)
1270 throws SystemException {
1271 try {
1272 for (com.liferay.portlet.tags.model.TagsEntry tagsEntry : tagsEntries) {
1273 removeTagsEntry.remove(pk, tagsEntry.getPrimaryKey());
1274 }
1275 }
1276 catch (Exception e) {
1277 throw processException(e);
1278 }
1279 finally {
1280 FinderCacheUtil.clearCache(TagsAssetModelImpl.MAPPING_TABLE_TAGSASSETS_TAGSENTRIES_NAME);
1281 }
1282 }
1283
1284 public void setTagsEntries(long pk, long[] tagsEntryPKs)
1285 throws SystemException {
1286 try {
1287 Set<Long> tagsEntryPKSet = SetUtil.fromArray(tagsEntryPKs);
1288
1289 List<com.liferay.portlet.tags.model.TagsEntry> tagsEntries = getTagsEntries(pk);
1290
1291 for (com.liferay.portlet.tags.model.TagsEntry tagsEntry : tagsEntries) {
1292 if (!tagsEntryPKSet.contains(tagsEntry.getPrimaryKey())) {
1293 removeTagsEntry.remove(pk, tagsEntry.getPrimaryKey());
1294 }
1295 else {
1296 tagsEntryPKSet.remove(tagsEntry.getPrimaryKey());
1297 }
1298 }
1299
1300 for (Long tagsEntryPK : tagsEntryPKSet) {
1301 addTagsEntry.add(pk, tagsEntryPK);
1302 }
1303 }
1304 catch (Exception e) {
1305 throw processException(e);
1306 }
1307 finally {
1308 FinderCacheUtil.clearCache(TagsAssetModelImpl.MAPPING_TABLE_TAGSASSETS_TAGSENTRIES_NAME);
1309 }
1310 }
1311
1312 public void setTagsEntries(long pk,
1313 List<com.liferay.portlet.tags.model.TagsEntry> tagsEntries)
1314 throws SystemException {
1315 try {
1316 long[] tagsEntryPKs = new long[tagsEntries.size()];
1317
1318 for (int i = 0; i < tagsEntries.size(); i++) {
1319 com.liferay.portlet.tags.model.TagsEntry tagsEntry = tagsEntries.get(i);
1320
1321 tagsEntryPKs[i] = tagsEntry.getPrimaryKey();
1322 }
1323
1324 setTagsEntries(pk, tagsEntryPKs);
1325 }
1326 catch (Exception e) {
1327 throw processException(e);
1328 }
1329 finally {
1330 FinderCacheUtil.clearCache(TagsAssetModelImpl.MAPPING_TABLE_TAGSASSETS_TAGSENTRIES_NAME);
1331 }
1332 }
1333
1334 public void afterPropertiesSet() {
1335 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
1336 com.liferay.portal.util.PropsUtil.get(
1337 "value.object.listener.com.liferay.portlet.tags.model.TagsAsset")));
1338
1339 if (listenerClassNames.length > 0) {
1340 try {
1341 List<ModelListener<TagsAsset>> listenersList = new ArrayList<ModelListener<TagsAsset>>();
1342
1343 for (String listenerClassName : listenerClassNames) {
1344 listenersList.add((ModelListener<TagsAsset>)Class.forName(
1345 listenerClassName).newInstance());
1346 }
1347
1348 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
1349 }
1350 catch (Exception e) {
1351 _log.error(e);
1352 }
1353 }
1354
1355 containsTagsEntry = new ContainsTagsEntry(this);
1356
1357 addTagsEntry = new AddTagsEntry(this);
1358 clearTagsEntries = new ClearTagsEntries(this);
1359 removeTagsEntry = new RemoveTagsEntry(this);
1360 }
1361
1362 @BeanReference(type = TagsAssetPersistence.class)
1363 protected TagsAssetPersistence tagsAssetPersistence;
1364 @BeanReference(type = TagsEntryPersistence.class)
1365 protected TagsEntryPersistence tagsEntryPersistence;
1366 @BeanReference(type = TagsPropertyPersistence.class)
1367 protected TagsPropertyPersistence tagsPropertyPersistence;
1368 @BeanReference(type = TagsSourcePersistence.class)
1369 protected TagsSourcePersistence tagsSourcePersistence;
1370 @BeanReference(type = TagsVocabularyPersistence.class)
1371 protected TagsVocabularyPersistence tagsVocabularyPersistence;
1372 @BeanReference(type = CompanyPersistence.class)
1373 protected CompanyPersistence companyPersistence;
1374 @BeanReference(type = GroupPersistence.class)
1375 protected GroupPersistence groupPersistence;
1376 @BeanReference(type = ResourcePersistence.class)
1377 protected ResourcePersistence resourcePersistence;
1378 @BeanReference(type = UserPersistence.class)
1379 protected UserPersistence userPersistence;
1380 @BeanReference(type = BlogsEntryPersistence.class)
1381 protected BlogsEntryPersistence blogsEntryPersistence;
1382 @BeanReference(type = BookmarksEntryPersistence.class)
1383 protected BookmarksEntryPersistence bookmarksEntryPersistence;
1384 @BeanReference(type = DLFileEntryPersistence.class)
1385 protected DLFileEntryPersistence dlFileEntryPersistence;
1386 @BeanReference(type = JournalArticlePersistence.class)
1387 protected JournalArticlePersistence journalArticlePersistence;
1388 @BeanReference(type = JournalArticleResourcePersistence.class)
1389 protected JournalArticleResourcePersistence journalArticleResourcePersistence;
1390 @BeanReference(type = MBMessagePersistence.class)
1391 protected MBMessagePersistence mbMessagePersistence;
1392 @BeanReference(type = WikiPagePersistence.class)
1393 protected WikiPagePersistence wikiPagePersistence;
1394 @BeanReference(type = WikiPageResourcePersistence.class)
1395 protected WikiPageResourcePersistence wikiPageResourcePersistence;
1396 protected ContainsTagsEntry containsTagsEntry;
1397 protected AddTagsEntry addTagsEntry;
1398 protected ClearTagsEntries clearTagsEntries;
1399 protected RemoveTagsEntry removeTagsEntry;
1400
1401 protected class ContainsTagsEntry {
1402 protected ContainsTagsEntry(TagsAssetPersistenceImpl persistenceImpl) {
1403 super();
1404
1405 _mappingSqlQuery = MappingSqlQueryFactoryUtil.getMappingSqlQuery(getDataSource(),
1406 _SQL_CONTAINSTAGSENTRY,
1407 new int[] { Types.BIGINT, Types.BIGINT }, RowMapper.COUNT);
1408 }
1409
1410 protected boolean contains(long assetId, long entryId) {
1411 List<Integer> results = _mappingSqlQuery.execute(new Object[] {
1412 new Long(assetId), new Long(entryId)
1413 });
1414
1415 if (results.size() > 0) {
1416 Integer count = results.get(0);
1417
1418 if (count.intValue() > 0) {
1419 return true;
1420 }
1421 }
1422
1423 return false;
1424 }
1425
1426 private MappingSqlQuery _mappingSqlQuery;
1427 }
1428
1429 protected class AddTagsEntry {
1430 protected AddTagsEntry(TagsAssetPersistenceImpl persistenceImpl) {
1431 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
1432 "INSERT INTO TagsAssets_TagsEntries (assetId, entryId) VALUES (?, ?)",
1433 new int[] { Types.BIGINT, Types.BIGINT });
1434 _persistenceImpl = persistenceImpl;
1435 }
1436
1437 protected void add(long assetId, long entryId)
1438 throws SystemException {
1439 if (!_persistenceImpl.containsTagsEntry.contains(assetId, entryId)) {
1440 ModelListener<com.liferay.portlet.tags.model.TagsEntry>[] tagsEntryListeners =
1441 tagsEntryPersistence.getListeners();
1442
1443 for (ModelListener<TagsAsset> listener : listeners) {
1444 listener.onBeforeAddAssociation(assetId,
1445 com.liferay.portlet.tags.model.TagsEntry.class.getName(),
1446 entryId);
1447 }
1448
1449 for (ModelListener<com.liferay.portlet.tags.model.TagsEntry> listener : tagsEntryListeners) {
1450 listener.onBeforeAddAssociation(entryId,
1451 TagsAsset.class.getName(), assetId);
1452 }
1453
1454 _sqlUpdate.update(new Object[] {
1455 new Long(assetId), new Long(entryId)
1456 });
1457
1458 for (ModelListener<TagsAsset> listener : listeners) {
1459 listener.onAfterAddAssociation(assetId,
1460 com.liferay.portlet.tags.model.TagsEntry.class.getName(),
1461 entryId);
1462 }
1463
1464 for (ModelListener<com.liferay.portlet.tags.model.TagsEntry> listener : tagsEntryListeners) {
1465 listener.onAfterAddAssociation(entryId,
1466 TagsAsset.class.getName(), assetId);
1467 }
1468 }
1469 }
1470
1471 private SqlUpdate _sqlUpdate;
1472 private TagsAssetPersistenceImpl _persistenceImpl;
1473 }
1474
1475 protected class ClearTagsEntries {
1476 protected ClearTagsEntries(TagsAssetPersistenceImpl persistenceImpl) {
1477 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
1478 "DELETE FROM TagsAssets_TagsEntries WHERE assetId = ?",
1479 new int[] { Types.BIGINT });
1480 }
1481
1482 protected void clear(long assetId) throws SystemException {
1483 ModelListener<com.liferay.portlet.tags.model.TagsEntry>[] tagsEntryListeners =
1484 tagsEntryPersistence.getListeners();
1485
1486 List<com.liferay.portlet.tags.model.TagsEntry> tagsEntries = null;
1487
1488 if ((listeners.length > 0) || (tagsEntryListeners.length > 0)) {
1489 tagsEntries = getTagsEntries(assetId);
1490
1491 for (com.liferay.portlet.tags.model.TagsEntry tagsEntry : tagsEntries) {
1492 for (ModelListener<TagsAsset> listener : listeners) {
1493 listener.onBeforeRemoveAssociation(assetId,
1494 com.liferay.portlet.tags.model.TagsEntry.class.getName(),
1495 tagsEntry.getPrimaryKey());
1496 }
1497
1498 for (ModelListener<com.liferay.portlet.tags.model.TagsEntry> listener : tagsEntryListeners) {
1499 listener.onBeforeRemoveAssociation(tagsEntry.getPrimaryKey(),
1500 TagsAsset.class.getName(), assetId);
1501 }
1502 }
1503 }
1504
1505 _sqlUpdate.update(new Object[] { new Long(assetId) });
1506
1507 if ((listeners.length > 0) || (tagsEntryListeners.length > 0)) {
1508 for (com.liferay.portlet.tags.model.TagsEntry tagsEntry : tagsEntries) {
1509 for (ModelListener<TagsAsset> listener : listeners) {
1510 listener.onAfterRemoveAssociation(assetId,
1511 com.liferay.portlet.tags.model.TagsEntry.class.getName(),
1512 tagsEntry.getPrimaryKey());
1513 }
1514
1515 for (ModelListener<com.liferay.portlet.tags.model.TagsEntry> listener : tagsEntryListeners) {
1516 listener.onAfterRemoveAssociation(tagsEntry.getPrimaryKey(),
1517 TagsAsset.class.getName(), assetId);
1518 }
1519 }
1520 }
1521 }
1522
1523 private SqlUpdate _sqlUpdate;
1524 }
1525
1526 protected class RemoveTagsEntry {
1527 protected RemoveTagsEntry(TagsAssetPersistenceImpl persistenceImpl) {
1528 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
1529 "DELETE FROM TagsAssets_TagsEntries WHERE assetId = ? AND entryId = ?",
1530 new int[] { Types.BIGINT, Types.BIGINT });
1531 _persistenceImpl = persistenceImpl;
1532 }
1533
1534 protected void remove(long assetId, long entryId)
1535 throws SystemException {
1536 if (_persistenceImpl.containsTagsEntry.contains(assetId, entryId)) {
1537 ModelListener<com.liferay.portlet.tags.model.TagsEntry>[] tagsEntryListeners =
1538 tagsEntryPersistence.getListeners();
1539
1540 for (ModelListener<TagsAsset> listener : listeners) {
1541 listener.onBeforeRemoveAssociation(assetId,
1542 com.liferay.portlet.tags.model.TagsEntry.class.getName(),
1543 entryId);
1544 }
1545
1546 for (ModelListener<com.liferay.portlet.tags.model.TagsEntry> listener : tagsEntryListeners) {
1547 listener.onBeforeRemoveAssociation(entryId,
1548 TagsAsset.class.getName(), assetId);
1549 }
1550
1551 _sqlUpdate.update(new Object[] {
1552 new Long(assetId), new Long(entryId)
1553 });
1554
1555 for (ModelListener<TagsAsset> listener : listeners) {
1556 listener.onAfterRemoveAssociation(assetId,
1557 com.liferay.portlet.tags.model.TagsEntry.class.getName(),
1558 entryId);
1559 }
1560
1561 for (ModelListener<com.liferay.portlet.tags.model.TagsEntry> listener : tagsEntryListeners) {
1562 listener.onAfterRemoveAssociation(entryId,
1563 TagsAsset.class.getName(), assetId);
1564 }
1565 }
1566 }
1567
1568 private SqlUpdate _sqlUpdate;
1569 private TagsAssetPersistenceImpl _persistenceImpl;
1570 }
1571
1572 private static final String _SQL_SELECT_TAGSASSET = "SELECT tagsAsset FROM TagsAsset tagsAsset";
1573 private static final String _SQL_SELECT_TAGSASSET_WHERE = "SELECT tagsAsset FROM TagsAsset tagsAsset WHERE ";
1574 private static final String _SQL_COUNT_TAGSASSET = "SELECT COUNT(tagsAsset) FROM TagsAsset tagsAsset";
1575 private static final String _SQL_COUNT_TAGSASSET_WHERE = "SELECT COUNT(tagsAsset) FROM TagsAsset tagsAsset WHERE ";
1576 private static final String _SQL_GETTAGSENTRIES = "SELECT {TagsEntry.*} FROM TagsEntry INNER JOIN TagsAssets_TagsEntries ON (TagsAssets_TagsEntries.entryId = TagsEntry.entryId) WHERE (TagsAssets_TagsEntries.assetId = ?)";
1577 private static final String _SQL_GETTAGSENTRIESSIZE = "SELECT COUNT(*) AS COUNT_VALUE FROM TagsAssets_TagsEntries WHERE assetId = ?";
1578 private static final String _SQL_CONTAINSTAGSENTRY = "SELECT COUNT(*) AS COUNT_VALUE FROM TagsAssets_TagsEntries WHERE assetId = ? AND entryId = ?";
1579 private static final String _FINDER_COLUMN_COMPANYID_COMPANYID_2 = "tagsAsset.companyId = ?";
1580 private static final String _FINDER_COLUMN_C_C_CLASSNAMEID_2 = "tagsAsset.classNameId = ? AND ";
1581 private static final String _FINDER_COLUMN_C_C_CLASSPK_2 = "tagsAsset.classPK = ?";
1582 private static final String _ORDER_BY_ENTITY_ALIAS = "tagsAsset.";
1583 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No TagsAsset exists with the primary key ";
1584 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No TagsAsset exists with the key {";
1585 private static Log _log = LogFactoryUtil.getLog(TagsAssetPersistenceImpl.class);
1586}