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