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