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.orm.DynamicQuery;
28 import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
29 import com.liferay.portal.kernel.dao.orm.Query;
30 import com.liferay.portal.kernel.dao.orm.QueryPos;
31 import com.liferay.portal.kernel.dao.orm.QueryUtil;
32 import com.liferay.portal.kernel.dao.orm.Session;
33 import com.liferay.portal.kernel.log.Log;
34 import com.liferay.portal.kernel.log.LogFactoryUtil;
35 import com.liferay.portal.kernel.util.GetterUtil;
36 import com.liferay.portal.kernel.util.OrderByComparator;
37 import com.liferay.portal.kernel.util.StringPool;
38 import com.liferay.portal.kernel.util.StringUtil;
39 import com.liferay.portal.model.ModelListener;
40 import com.liferay.portal.service.persistence.BatchSessionUtil;
41 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
42
43 import com.liferay.portlet.tags.NoSuchVocabularyException;
44 import com.liferay.portlet.tags.model.TagsVocabulary;
45 import com.liferay.portlet.tags.model.impl.TagsVocabularyImpl;
46 import com.liferay.portlet.tags.model.impl.TagsVocabularyModelImpl;
47
48 import java.util.ArrayList;
49 import java.util.Collections;
50 import java.util.Iterator;
51 import java.util.List;
52
53
59 public class TagsVocabularyPersistenceImpl extends BasePersistenceImpl
60 implements TagsVocabularyPersistence {
61 public TagsVocabulary create(long vocabularyId) {
62 TagsVocabulary tagsVocabulary = new TagsVocabularyImpl();
63
64 tagsVocabulary.setNew(true);
65 tagsVocabulary.setPrimaryKey(vocabularyId);
66
67 return tagsVocabulary;
68 }
69
70 public TagsVocabulary remove(long vocabularyId)
71 throws NoSuchVocabularyException, SystemException {
72 Session session = null;
73
74 try {
75 session = openSession();
76
77 TagsVocabulary tagsVocabulary = (TagsVocabulary)session.get(TagsVocabularyImpl.class,
78 new Long(vocabularyId));
79
80 if (tagsVocabulary == null) {
81 if (_log.isWarnEnabled()) {
82 _log.warn("No TagsVocabulary exists with the primary key " +
83 vocabularyId);
84 }
85
86 throw new NoSuchVocabularyException(
87 "No TagsVocabulary exists with the primary key " +
88 vocabularyId);
89 }
90
91 return remove(tagsVocabulary);
92 }
93 catch (NoSuchVocabularyException nsee) {
94 throw nsee;
95 }
96 catch (Exception e) {
97 throw processException(e);
98 }
99 finally {
100 closeSession(session);
101 }
102 }
103
104 public TagsVocabulary remove(TagsVocabulary tagsVocabulary)
105 throws SystemException {
106 for (ModelListener listener : listeners) {
107 listener.onBeforeRemove(tagsVocabulary);
108 }
109
110 tagsVocabulary = removeImpl(tagsVocabulary);
111
112 for (ModelListener listener : listeners) {
113 listener.onAfterRemove(tagsVocabulary);
114 }
115
116 return tagsVocabulary;
117 }
118
119 protected TagsVocabulary removeImpl(TagsVocabulary tagsVocabulary)
120 throws SystemException {
121 Session session = null;
122
123 try {
124 session = openSession();
125
126 if (BatchSessionUtil.isEnabled()) {
127 Object staleObject = session.get(TagsVocabularyImpl.class,
128 tagsVocabulary.getPrimaryKeyObj());
129
130 if (staleObject != null) {
131 session.evict(staleObject);
132 }
133 }
134
135 session.delete(tagsVocabulary);
136
137 session.flush();
138
139 return tagsVocabulary;
140 }
141 catch (Exception e) {
142 throw processException(e);
143 }
144 finally {
145 closeSession(session);
146
147 FinderCacheUtil.clearCache(TagsVocabulary.class.getName());
148 }
149 }
150
151
154 public TagsVocabulary update(TagsVocabulary tagsVocabulary)
155 throws SystemException {
156 if (_log.isWarnEnabled()) {
157 _log.warn(
158 "Using the deprecated update(TagsVocabulary tagsVocabulary) method. Use update(TagsVocabulary tagsVocabulary, boolean merge) instead.");
159 }
160
161 return update(tagsVocabulary, false);
162 }
163
164
177 public TagsVocabulary update(TagsVocabulary tagsVocabulary, boolean merge)
178 throws SystemException {
179 boolean isNew = tagsVocabulary.isNew();
180
181 for (ModelListener listener : listeners) {
182 if (isNew) {
183 listener.onBeforeCreate(tagsVocabulary);
184 }
185 else {
186 listener.onBeforeUpdate(tagsVocabulary);
187 }
188 }
189
190 tagsVocabulary = updateImpl(tagsVocabulary, merge);
191
192 for (ModelListener listener : listeners) {
193 if (isNew) {
194 listener.onAfterCreate(tagsVocabulary);
195 }
196 else {
197 listener.onAfterUpdate(tagsVocabulary);
198 }
199 }
200
201 return tagsVocabulary;
202 }
203
204 public TagsVocabulary updateImpl(
205 com.liferay.portlet.tags.model.TagsVocabulary tagsVocabulary,
206 boolean merge) throws SystemException {
207 Session session = null;
208
209 try {
210 session = openSession();
211
212 BatchSessionUtil.update(session, tagsVocabulary, merge);
213
214 tagsVocabulary.setNew(false);
215
216 return tagsVocabulary;
217 }
218 catch (Exception e) {
219 throw processException(e);
220 }
221 finally {
222 closeSession(session);
223
224 FinderCacheUtil.clearCache(TagsVocabulary.class.getName());
225 }
226 }
227
228 public TagsVocabulary findByPrimaryKey(long vocabularyId)
229 throws NoSuchVocabularyException, SystemException {
230 TagsVocabulary tagsVocabulary = fetchByPrimaryKey(vocabularyId);
231
232 if (tagsVocabulary == null) {
233 if (_log.isWarnEnabled()) {
234 _log.warn("No TagsVocabulary exists with the primary key " +
235 vocabularyId);
236 }
237
238 throw new NoSuchVocabularyException(
239 "No TagsVocabulary exists with the primary key " +
240 vocabularyId);
241 }
242
243 return tagsVocabulary;
244 }
245
246 public TagsVocabulary fetchByPrimaryKey(long vocabularyId)
247 throws SystemException {
248 Session session = null;
249
250 try {
251 session = openSession();
252
253 return (TagsVocabulary)session.get(TagsVocabularyImpl.class,
254 new Long(vocabularyId));
255 }
256 catch (Exception e) {
257 throw processException(e);
258 }
259 finally {
260 closeSession(session);
261 }
262 }
263
264 public TagsVocabulary findByG_N(long groupId, String name)
265 throws NoSuchVocabularyException, SystemException {
266 TagsVocabulary tagsVocabulary = fetchByG_N(groupId, name);
267
268 if (tagsVocabulary == null) {
269 StringBuilder msg = new StringBuilder();
270
271 msg.append("No TagsVocabulary exists with the key {");
272
273 msg.append("groupId=" + groupId);
274
275 msg.append(", ");
276 msg.append("name=" + name);
277
278 msg.append(StringPool.CLOSE_CURLY_BRACE);
279
280 if (_log.isWarnEnabled()) {
281 _log.warn(msg.toString());
282 }
283
284 throw new NoSuchVocabularyException(msg.toString());
285 }
286
287 return tagsVocabulary;
288 }
289
290 public TagsVocabulary fetchByG_N(long groupId, String name)
291 throws SystemException {
292 boolean finderClassNameCacheEnabled = TagsVocabularyModelImpl.CACHE_ENABLED;
293 String finderClassName = TagsVocabulary.class.getName();
294 String finderMethodName = "fetchByG_N";
295 String[] finderParams = new String[] {
296 Long.class.getName(), String.class.getName()
297 };
298 Object[] finderArgs = new Object[] { new Long(groupId), name };
299
300 Object result = null;
301
302 if (finderClassNameCacheEnabled) {
303 result = FinderCacheUtil.getResult(finderClassName,
304 finderMethodName, finderParams, finderArgs, this);
305 }
306
307 if (result == null) {
308 Session session = null;
309
310 try {
311 session = openSession();
312
313 StringBuilder query = new StringBuilder();
314
315 query.append(
316 "FROM com.liferay.portlet.tags.model.TagsVocabulary WHERE ");
317
318 query.append("groupId = ?");
319
320 query.append(" AND ");
321
322 if (name == null) {
323 query.append("name IS NULL");
324 }
325 else {
326 query.append("name = ?");
327 }
328
329 query.append(" ");
330
331 query.append("ORDER BY ");
332
333 query.append("name ASC");
334
335 Query q = session.createQuery(query.toString());
336
337 QueryPos qPos = QueryPos.getInstance(q);
338
339 qPos.add(groupId);
340
341 if (name != null) {
342 qPos.add(name);
343 }
344
345 List<TagsVocabulary> list = q.list();
346
347 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
348 finderClassName, finderMethodName, finderParams,
349 finderArgs, list);
350
351 if (list.size() == 0) {
352 return null;
353 }
354 else {
355 return list.get(0);
356 }
357 }
358 catch (Exception e) {
359 throw processException(e);
360 }
361 finally {
362 closeSession(session);
363 }
364 }
365 else {
366 List<TagsVocabulary> list = (List<TagsVocabulary>)result;
367
368 if (list.size() == 0) {
369 return null;
370 }
371 else {
372 return list.get(0);
373 }
374 }
375 }
376
377 public List<TagsVocabulary> findByG_F(long groupId, boolean folksonomy)
378 throws SystemException {
379 boolean finderClassNameCacheEnabled = TagsVocabularyModelImpl.CACHE_ENABLED;
380 String finderClassName = TagsVocabulary.class.getName();
381 String finderMethodName = "findByG_F";
382 String[] finderParams = new String[] {
383 Long.class.getName(), Boolean.class.getName()
384 };
385 Object[] finderArgs = new Object[] {
386 new Long(groupId), Boolean.valueOf(folksonomy)
387 };
388
389 Object result = null;
390
391 if (finderClassNameCacheEnabled) {
392 result = FinderCacheUtil.getResult(finderClassName,
393 finderMethodName, finderParams, finderArgs, this);
394 }
395
396 if (result == null) {
397 Session session = null;
398
399 try {
400 session = openSession();
401
402 StringBuilder query = new StringBuilder();
403
404 query.append(
405 "FROM com.liferay.portlet.tags.model.TagsVocabulary WHERE ");
406
407 query.append("groupId = ?");
408
409 query.append(" AND ");
410
411 query.append("folksonomy = ?");
412
413 query.append(" ");
414
415 query.append("ORDER BY ");
416
417 query.append("name ASC");
418
419 Query q = session.createQuery(query.toString());
420
421 QueryPos qPos = QueryPos.getInstance(q);
422
423 qPos.add(groupId);
424
425 qPos.add(folksonomy);
426
427 List<TagsVocabulary> list = q.list();
428
429 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
430 finderClassName, finderMethodName, finderParams,
431 finderArgs, list);
432
433 return list;
434 }
435 catch (Exception e) {
436 throw processException(e);
437 }
438 finally {
439 closeSession(session);
440 }
441 }
442 else {
443 return (List<TagsVocabulary>)result;
444 }
445 }
446
447 public List<TagsVocabulary> findByG_F(long groupId, boolean folksonomy,
448 int start, int end) throws SystemException {
449 return findByG_F(groupId, folksonomy, start, end, null);
450 }
451
452 public List<TagsVocabulary> findByG_F(long groupId, boolean folksonomy,
453 int start, int end, OrderByComparator obc) throws SystemException {
454 boolean finderClassNameCacheEnabled = TagsVocabularyModelImpl.CACHE_ENABLED;
455 String finderClassName = TagsVocabulary.class.getName();
456 String finderMethodName = "findByG_F";
457 String[] finderParams = new String[] {
458 Long.class.getName(), Boolean.class.getName(),
459
460 "java.lang.Integer", "java.lang.Integer",
461 "com.liferay.portal.kernel.util.OrderByComparator"
462 };
463 Object[] finderArgs = new Object[] {
464 new Long(groupId), Boolean.valueOf(folksonomy),
465
466 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
467 };
468
469 Object result = null;
470
471 if (finderClassNameCacheEnabled) {
472 result = FinderCacheUtil.getResult(finderClassName,
473 finderMethodName, finderParams, finderArgs, this);
474 }
475
476 if (result == null) {
477 Session session = null;
478
479 try {
480 session = openSession();
481
482 StringBuilder query = new StringBuilder();
483
484 query.append(
485 "FROM com.liferay.portlet.tags.model.TagsVocabulary WHERE ");
486
487 query.append("groupId = ?");
488
489 query.append(" AND ");
490
491 query.append("folksonomy = ?");
492
493 query.append(" ");
494
495 if (obc != null) {
496 query.append("ORDER BY ");
497 query.append(obc.getOrderBy());
498 }
499
500 else {
501 query.append("ORDER BY ");
502
503 query.append("name ASC");
504 }
505
506 Query q = session.createQuery(query.toString());
507
508 QueryPos qPos = QueryPos.getInstance(q);
509
510 qPos.add(groupId);
511
512 qPos.add(folksonomy);
513
514 List<TagsVocabulary> list = (List<TagsVocabulary>)QueryUtil.list(q,
515 getDialect(), start, end);
516
517 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
518 finderClassName, finderMethodName, finderParams,
519 finderArgs, list);
520
521 return list;
522 }
523 catch (Exception e) {
524 throw processException(e);
525 }
526 finally {
527 closeSession(session);
528 }
529 }
530 else {
531 return (List<TagsVocabulary>)result;
532 }
533 }
534
535 public TagsVocabulary findByG_F_First(long groupId, boolean folksonomy,
536 OrderByComparator obc)
537 throws NoSuchVocabularyException, SystemException {
538 List<TagsVocabulary> list = findByG_F(groupId, folksonomy, 0, 1, obc);
539
540 if (list.size() == 0) {
541 StringBuilder msg = new StringBuilder();
542
543 msg.append("No TagsVocabulary exists with the key {");
544
545 msg.append("groupId=" + groupId);
546
547 msg.append(", ");
548 msg.append("folksonomy=" + folksonomy);
549
550 msg.append(StringPool.CLOSE_CURLY_BRACE);
551
552 throw new NoSuchVocabularyException(msg.toString());
553 }
554 else {
555 return list.get(0);
556 }
557 }
558
559 public TagsVocabulary findByG_F_Last(long groupId, boolean folksonomy,
560 OrderByComparator obc)
561 throws NoSuchVocabularyException, SystemException {
562 int count = countByG_F(groupId, folksonomy);
563
564 List<TagsVocabulary> list = findByG_F(groupId, folksonomy, count - 1,
565 count, obc);
566
567 if (list.size() == 0) {
568 StringBuilder msg = new StringBuilder();
569
570 msg.append("No TagsVocabulary exists with the key {");
571
572 msg.append("groupId=" + groupId);
573
574 msg.append(", ");
575 msg.append("folksonomy=" + folksonomy);
576
577 msg.append(StringPool.CLOSE_CURLY_BRACE);
578
579 throw new NoSuchVocabularyException(msg.toString());
580 }
581 else {
582 return list.get(0);
583 }
584 }
585
586 public TagsVocabulary[] findByG_F_PrevAndNext(long vocabularyId,
587 long groupId, boolean folksonomy, OrderByComparator obc)
588 throws NoSuchVocabularyException, SystemException {
589 TagsVocabulary tagsVocabulary = findByPrimaryKey(vocabularyId);
590
591 int count = countByG_F(groupId, folksonomy);
592
593 Session session = null;
594
595 try {
596 session = openSession();
597
598 StringBuilder query = new StringBuilder();
599
600 query.append(
601 "FROM com.liferay.portlet.tags.model.TagsVocabulary WHERE ");
602
603 query.append("groupId = ?");
604
605 query.append(" AND ");
606
607 query.append("folksonomy = ?");
608
609 query.append(" ");
610
611 if (obc != null) {
612 query.append("ORDER BY ");
613 query.append(obc.getOrderBy());
614 }
615
616 else {
617 query.append("ORDER BY ");
618
619 query.append("name ASC");
620 }
621
622 Query q = session.createQuery(query.toString());
623
624 QueryPos qPos = QueryPos.getInstance(q);
625
626 qPos.add(groupId);
627
628 qPos.add(folksonomy);
629
630 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
631 tagsVocabulary);
632
633 TagsVocabulary[] array = new TagsVocabularyImpl[3];
634
635 array[0] = (TagsVocabulary)objArray[0];
636 array[1] = (TagsVocabulary)objArray[1];
637 array[2] = (TagsVocabulary)objArray[2];
638
639 return array;
640 }
641 catch (Exception e) {
642 throw processException(e);
643 }
644 finally {
645 closeSession(session);
646 }
647 }
648
649 public List<TagsVocabulary> findByC_F(long companyId, boolean folksonomy)
650 throws SystemException {
651 boolean finderClassNameCacheEnabled = TagsVocabularyModelImpl.CACHE_ENABLED;
652 String finderClassName = TagsVocabulary.class.getName();
653 String finderMethodName = "findByC_F";
654 String[] finderParams = new String[] {
655 Long.class.getName(), Boolean.class.getName()
656 };
657 Object[] finderArgs = new Object[] {
658 new Long(companyId), Boolean.valueOf(folksonomy)
659 };
660
661 Object result = null;
662
663 if (finderClassNameCacheEnabled) {
664 result = FinderCacheUtil.getResult(finderClassName,
665 finderMethodName, finderParams, finderArgs, this);
666 }
667
668 if (result == null) {
669 Session session = null;
670
671 try {
672 session = openSession();
673
674 StringBuilder query = new StringBuilder();
675
676 query.append(
677 "FROM com.liferay.portlet.tags.model.TagsVocabulary WHERE ");
678
679 query.append("companyId = ?");
680
681 query.append(" AND ");
682
683 query.append("folksonomy = ?");
684
685 query.append(" ");
686
687 query.append("ORDER BY ");
688
689 query.append("name ASC");
690
691 Query q = session.createQuery(query.toString());
692
693 QueryPos qPos = QueryPos.getInstance(q);
694
695 qPos.add(companyId);
696
697 qPos.add(folksonomy);
698
699 List<TagsVocabulary> list = q.list();
700
701 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
702 finderClassName, finderMethodName, finderParams,
703 finderArgs, list);
704
705 return list;
706 }
707 catch (Exception e) {
708 throw processException(e);
709 }
710 finally {
711 closeSession(session);
712 }
713 }
714 else {
715 return (List<TagsVocabulary>)result;
716 }
717 }
718
719 public List<TagsVocabulary> findByC_F(long companyId, boolean folksonomy,
720 int start, int end) throws SystemException {
721 return findByC_F(companyId, folksonomy, start, end, null);
722 }
723
724 public List<TagsVocabulary> findByC_F(long companyId, boolean folksonomy,
725 int start, int end, OrderByComparator obc) throws SystemException {
726 boolean finderClassNameCacheEnabled = TagsVocabularyModelImpl.CACHE_ENABLED;
727 String finderClassName = TagsVocabulary.class.getName();
728 String finderMethodName = "findByC_F";
729 String[] finderParams = new String[] {
730 Long.class.getName(), Boolean.class.getName(),
731
732 "java.lang.Integer", "java.lang.Integer",
733 "com.liferay.portal.kernel.util.OrderByComparator"
734 };
735 Object[] finderArgs = new Object[] {
736 new Long(companyId), Boolean.valueOf(folksonomy),
737
738 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
739 };
740
741 Object result = null;
742
743 if (finderClassNameCacheEnabled) {
744 result = FinderCacheUtil.getResult(finderClassName,
745 finderMethodName, finderParams, finderArgs, this);
746 }
747
748 if (result == null) {
749 Session session = null;
750
751 try {
752 session = openSession();
753
754 StringBuilder query = new StringBuilder();
755
756 query.append(
757 "FROM com.liferay.portlet.tags.model.TagsVocabulary WHERE ");
758
759 query.append("companyId = ?");
760
761 query.append(" AND ");
762
763 query.append("folksonomy = ?");
764
765 query.append(" ");
766
767 if (obc != null) {
768 query.append("ORDER BY ");
769 query.append(obc.getOrderBy());
770 }
771
772 else {
773 query.append("ORDER BY ");
774
775 query.append("name ASC");
776 }
777
778 Query q = session.createQuery(query.toString());
779
780 QueryPos qPos = QueryPos.getInstance(q);
781
782 qPos.add(companyId);
783
784 qPos.add(folksonomy);
785
786 List<TagsVocabulary> list = (List<TagsVocabulary>)QueryUtil.list(q,
787 getDialect(), start, end);
788
789 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
790 finderClassName, finderMethodName, finderParams,
791 finderArgs, list);
792
793 return list;
794 }
795 catch (Exception e) {
796 throw processException(e);
797 }
798 finally {
799 closeSession(session);
800 }
801 }
802 else {
803 return (List<TagsVocabulary>)result;
804 }
805 }
806
807 public TagsVocabulary findByC_F_First(long companyId, boolean folksonomy,
808 OrderByComparator obc)
809 throws NoSuchVocabularyException, SystemException {
810 List<TagsVocabulary> list = findByC_F(companyId, folksonomy, 0, 1, obc);
811
812 if (list.size() == 0) {
813 StringBuilder msg = new StringBuilder();
814
815 msg.append("No TagsVocabulary exists with the key {");
816
817 msg.append("companyId=" + companyId);
818
819 msg.append(", ");
820 msg.append("folksonomy=" + folksonomy);
821
822 msg.append(StringPool.CLOSE_CURLY_BRACE);
823
824 throw new NoSuchVocabularyException(msg.toString());
825 }
826 else {
827 return list.get(0);
828 }
829 }
830
831 public TagsVocabulary findByC_F_Last(long companyId, boolean folksonomy,
832 OrderByComparator obc)
833 throws NoSuchVocabularyException, SystemException {
834 int count = countByC_F(companyId, folksonomy);
835
836 List<TagsVocabulary> list = findByC_F(companyId, folksonomy, count - 1,
837 count, obc);
838
839 if (list.size() == 0) {
840 StringBuilder msg = new StringBuilder();
841
842 msg.append("No TagsVocabulary exists with the key {");
843
844 msg.append("companyId=" + companyId);
845
846 msg.append(", ");
847 msg.append("folksonomy=" + folksonomy);
848
849 msg.append(StringPool.CLOSE_CURLY_BRACE);
850
851 throw new NoSuchVocabularyException(msg.toString());
852 }
853 else {
854 return list.get(0);
855 }
856 }
857
858 public TagsVocabulary[] findByC_F_PrevAndNext(long vocabularyId,
859 long companyId, boolean folksonomy, OrderByComparator obc)
860 throws NoSuchVocabularyException, SystemException {
861 TagsVocabulary tagsVocabulary = findByPrimaryKey(vocabularyId);
862
863 int count = countByC_F(companyId, folksonomy);
864
865 Session session = null;
866
867 try {
868 session = openSession();
869
870 StringBuilder query = new StringBuilder();
871
872 query.append(
873 "FROM com.liferay.portlet.tags.model.TagsVocabulary WHERE ");
874
875 query.append("companyId = ?");
876
877 query.append(" AND ");
878
879 query.append("folksonomy = ?");
880
881 query.append(" ");
882
883 if (obc != null) {
884 query.append("ORDER BY ");
885 query.append(obc.getOrderBy());
886 }
887
888 else {
889 query.append("ORDER BY ");
890
891 query.append("name ASC");
892 }
893
894 Query q = session.createQuery(query.toString());
895
896 QueryPos qPos = QueryPos.getInstance(q);
897
898 qPos.add(companyId);
899
900 qPos.add(folksonomy);
901
902 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
903 tagsVocabulary);
904
905 TagsVocabulary[] array = new TagsVocabularyImpl[3];
906
907 array[0] = (TagsVocabulary)objArray[0];
908 array[1] = (TagsVocabulary)objArray[1];
909 array[2] = (TagsVocabulary)objArray[2];
910
911 return array;
912 }
913 catch (Exception e) {
914 throw processException(e);
915 }
916 finally {
917 closeSession(session);
918 }
919 }
920
921 public List<Object> findWithDynamicQuery(DynamicQuery dynamicQuery)
922 throws SystemException {
923 Session session = null;
924
925 try {
926 session = openSession();
927
928 dynamicQuery.compile(session);
929
930 return dynamicQuery.list();
931 }
932 catch (Exception e) {
933 throw processException(e);
934 }
935 finally {
936 closeSession(session);
937 }
938 }
939
940 public List<Object> findWithDynamicQuery(DynamicQuery dynamicQuery,
941 int start, int end) throws SystemException {
942 Session session = null;
943
944 try {
945 session = openSession();
946
947 dynamicQuery.setLimit(start, end);
948
949 dynamicQuery.compile(session);
950
951 return dynamicQuery.list();
952 }
953 catch (Exception e) {
954 throw processException(e);
955 }
956 finally {
957 closeSession(session);
958 }
959 }
960
961 public List<TagsVocabulary> findAll() throws SystemException {
962 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
963 }
964
965 public List<TagsVocabulary> findAll(int start, int end)
966 throws SystemException {
967 return findAll(start, end, null);
968 }
969
970 public List<TagsVocabulary> findAll(int start, int end,
971 OrderByComparator obc) throws SystemException {
972 boolean finderClassNameCacheEnabled = TagsVocabularyModelImpl.CACHE_ENABLED;
973 String finderClassName = TagsVocabulary.class.getName();
974 String finderMethodName = "findAll";
975 String[] finderParams = new String[] {
976 "java.lang.Integer", "java.lang.Integer",
977 "com.liferay.portal.kernel.util.OrderByComparator"
978 };
979 Object[] finderArgs = new Object[] {
980 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
981 };
982
983 Object result = null;
984
985 if (finderClassNameCacheEnabled) {
986 result = FinderCacheUtil.getResult(finderClassName,
987 finderMethodName, finderParams, finderArgs, this);
988 }
989
990 if (result == null) {
991 Session session = null;
992
993 try {
994 session = openSession();
995
996 StringBuilder query = new StringBuilder();
997
998 query.append(
999 "FROM com.liferay.portlet.tags.model.TagsVocabulary ");
1000
1001 if (obc != null) {
1002 query.append("ORDER BY ");
1003 query.append(obc.getOrderBy());
1004 }
1005
1006 else {
1007 query.append("ORDER BY ");
1008
1009 query.append("name ASC");
1010 }
1011
1012 Query q = session.createQuery(query.toString());
1013
1014 List<TagsVocabulary> list = null;
1015
1016 if (obc == null) {
1017 list = (List<TagsVocabulary>)QueryUtil.list(q,
1018 getDialect(), start, end, false);
1019
1020 Collections.sort(list);
1021 }
1022 else {
1023 list = (List<TagsVocabulary>)QueryUtil.list(q,
1024 getDialect(), start, end);
1025 }
1026
1027 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
1028 finderClassName, finderMethodName, finderParams,
1029 finderArgs, list);
1030
1031 return list;
1032 }
1033 catch (Exception e) {
1034 throw processException(e);
1035 }
1036 finally {
1037 closeSession(session);
1038 }
1039 }
1040 else {
1041 return (List<TagsVocabulary>)result;
1042 }
1043 }
1044
1045 public void removeByG_N(long groupId, String name)
1046 throws NoSuchVocabularyException, SystemException {
1047 TagsVocabulary tagsVocabulary = findByG_N(groupId, name);
1048
1049 remove(tagsVocabulary);
1050 }
1051
1052 public void removeByG_F(long groupId, boolean folksonomy)
1053 throws SystemException {
1054 for (TagsVocabulary tagsVocabulary : findByG_F(groupId, folksonomy)) {
1055 remove(tagsVocabulary);
1056 }
1057 }
1058
1059 public void removeByC_F(long companyId, boolean folksonomy)
1060 throws SystemException {
1061 for (TagsVocabulary tagsVocabulary : findByC_F(companyId, folksonomy)) {
1062 remove(tagsVocabulary);
1063 }
1064 }
1065
1066 public void removeAll() throws SystemException {
1067 for (TagsVocabulary tagsVocabulary : findAll()) {
1068 remove(tagsVocabulary);
1069 }
1070 }
1071
1072 public int countByG_N(long groupId, String name) throws SystemException {
1073 boolean finderClassNameCacheEnabled = TagsVocabularyModelImpl.CACHE_ENABLED;
1074 String finderClassName = TagsVocabulary.class.getName();
1075 String finderMethodName = "countByG_N";
1076 String[] finderParams = new String[] {
1077 Long.class.getName(), String.class.getName()
1078 };
1079 Object[] finderArgs = new Object[] { new Long(groupId), name };
1080
1081 Object result = null;
1082
1083 if (finderClassNameCacheEnabled) {
1084 result = FinderCacheUtil.getResult(finderClassName,
1085 finderMethodName, finderParams, finderArgs, this);
1086 }
1087
1088 if (result == null) {
1089 Session session = null;
1090
1091 try {
1092 session = openSession();
1093
1094 StringBuilder query = new StringBuilder();
1095
1096 query.append("SELECT COUNT(*) ");
1097 query.append(
1098 "FROM com.liferay.portlet.tags.model.TagsVocabulary WHERE ");
1099
1100 query.append("groupId = ?");
1101
1102 query.append(" AND ");
1103
1104 if (name == null) {
1105 query.append("name IS NULL");
1106 }
1107 else {
1108 query.append("name = ?");
1109 }
1110
1111 query.append(" ");
1112
1113 Query q = session.createQuery(query.toString());
1114
1115 QueryPos qPos = QueryPos.getInstance(q);
1116
1117 qPos.add(groupId);
1118
1119 if (name != null) {
1120 qPos.add(name);
1121 }
1122
1123 Long count = null;
1124
1125 Iterator<Long> itr = q.list().iterator();
1126
1127 if (itr.hasNext()) {
1128 count = itr.next();
1129 }
1130
1131 if (count == null) {
1132 count = new Long(0);
1133 }
1134
1135 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
1136 finderClassName, finderMethodName, finderParams,
1137 finderArgs, count);
1138
1139 return count.intValue();
1140 }
1141 catch (Exception e) {
1142 throw processException(e);
1143 }
1144 finally {
1145 closeSession(session);
1146 }
1147 }
1148 else {
1149 return ((Long)result).intValue();
1150 }
1151 }
1152
1153 public int countByG_F(long groupId, boolean folksonomy)
1154 throws SystemException {
1155 boolean finderClassNameCacheEnabled = TagsVocabularyModelImpl.CACHE_ENABLED;
1156 String finderClassName = TagsVocabulary.class.getName();
1157 String finderMethodName = "countByG_F";
1158 String[] finderParams = new String[] {
1159 Long.class.getName(), Boolean.class.getName()
1160 };
1161 Object[] finderArgs = new Object[] {
1162 new Long(groupId), Boolean.valueOf(folksonomy)
1163 };
1164
1165 Object result = null;
1166
1167 if (finderClassNameCacheEnabled) {
1168 result = FinderCacheUtil.getResult(finderClassName,
1169 finderMethodName, finderParams, finderArgs, this);
1170 }
1171
1172 if (result == null) {
1173 Session session = null;
1174
1175 try {
1176 session = openSession();
1177
1178 StringBuilder query = new StringBuilder();
1179
1180 query.append("SELECT COUNT(*) ");
1181 query.append(
1182 "FROM com.liferay.portlet.tags.model.TagsVocabulary WHERE ");
1183
1184 query.append("groupId = ?");
1185
1186 query.append(" AND ");
1187
1188 query.append("folksonomy = ?");
1189
1190 query.append(" ");
1191
1192 Query q = session.createQuery(query.toString());
1193
1194 QueryPos qPos = QueryPos.getInstance(q);
1195
1196 qPos.add(groupId);
1197
1198 qPos.add(folksonomy);
1199
1200 Long count = null;
1201
1202 Iterator<Long> itr = q.list().iterator();
1203
1204 if (itr.hasNext()) {
1205 count = itr.next();
1206 }
1207
1208 if (count == null) {
1209 count = new Long(0);
1210 }
1211
1212 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
1213 finderClassName, finderMethodName, finderParams,
1214 finderArgs, count);
1215
1216 return count.intValue();
1217 }
1218 catch (Exception e) {
1219 throw processException(e);
1220 }
1221 finally {
1222 closeSession(session);
1223 }
1224 }
1225 else {
1226 return ((Long)result).intValue();
1227 }
1228 }
1229
1230 public int countByC_F(long companyId, boolean folksonomy)
1231 throws SystemException {
1232 boolean finderClassNameCacheEnabled = TagsVocabularyModelImpl.CACHE_ENABLED;
1233 String finderClassName = TagsVocabulary.class.getName();
1234 String finderMethodName = "countByC_F";
1235 String[] finderParams = new String[] {
1236 Long.class.getName(), Boolean.class.getName()
1237 };
1238 Object[] finderArgs = new Object[] {
1239 new Long(companyId), Boolean.valueOf(folksonomy)
1240 };
1241
1242 Object result = null;
1243
1244 if (finderClassNameCacheEnabled) {
1245 result = FinderCacheUtil.getResult(finderClassName,
1246 finderMethodName, finderParams, finderArgs, this);
1247 }
1248
1249 if (result == null) {
1250 Session session = null;
1251
1252 try {
1253 session = openSession();
1254
1255 StringBuilder query = new StringBuilder();
1256
1257 query.append("SELECT COUNT(*) ");
1258 query.append(
1259 "FROM com.liferay.portlet.tags.model.TagsVocabulary WHERE ");
1260
1261 query.append("companyId = ?");
1262
1263 query.append(" AND ");
1264
1265 query.append("folksonomy = ?");
1266
1267 query.append(" ");
1268
1269 Query q = session.createQuery(query.toString());
1270
1271 QueryPos qPos = QueryPos.getInstance(q);
1272
1273 qPos.add(companyId);
1274
1275 qPos.add(folksonomy);
1276
1277 Long count = null;
1278
1279 Iterator<Long> itr = q.list().iterator();
1280
1281 if (itr.hasNext()) {
1282 count = itr.next();
1283 }
1284
1285 if (count == null) {
1286 count = new Long(0);
1287 }
1288
1289 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
1290 finderClassName, finderMethodName, finderParams,
1291 finderArgs, count);
1292
1293 return count.intValue();
1294 }
1295 catch (Exception e) {
1296 throw processException(e);
1297 }
1298 finally {
1299 closeSession(session);
1300 }
1301 }
1302 else {
1303 return ((Long)result).intValue();
1304 }
1305 }
1306
1307 public int countAll() throws SystemException {
1308 boolean finderClassNameCacheEnabled = TagsVocabularyModelImpl.CACHE_ENABLED;
1309 String finderClassName = TagsVocabulary.class.getName();
1310 String finderMethodName = "countAll";
1311 String[] finderParams = new String[] { };
1312 Object[] finderArgs = new Object[] { };
1313
1314 Object result = null;
1315
1316 if (finderClassNameCacheEnabled) {
1317 result = FinderCacheUtil.getResult(finderClassName,
1318 finderMethodName, finderParams, finderArgs, this);
1319 }
1320
1321 if (result == null) {
1322 Session session = null;
1323
1324 try {
1325 session = openSession();
1326
1327 Query q = session.createQuery(
1328 "SELECT COUNT(*) FROM com.liferay.portlet.tags.model.TagsVocabulary");
1329
1330 Long count = null;
1331
1332 Iterator<Long> itr = q.list().iterator();
1333
1334 if (itr.hasNext()) {
1335 count = itr.next();
1336 }
1337
1338 if (count == null) {
1339 count = new Long(0);
1340 }
1341
1342 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
1343 finderClassName, finderMethodName, finderParams,
1344 finderArgs, count);
1345
1346 return count.intValue();
1347 }
1348 catch (Exception e) {
1349 throw processException(e);
1350 }
1351 finally {
1352 closeSession(session);
1353 }
1354 }
1355 else {
1356 return ((Long)result).intValue();
1357 }
1358 }
1359
1360 public void afterPropertiesSet() {
1361 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
1362 com.liferay.portal.util.PropsUtil.get(
1363 "value.object.listener.com.liferay.portlet.tags.model.TagsVocabulary")));
1364
1365 if (listenerClassNames.length > 0) {
1366 try {
1367 List<ModelListener> listenersList = new ArrayList<ModelListener>();
1368
1369 for (String listenerClassName : listenerClassNames) {
1370 listenersList.add((ModelListener)Class.forName(
1371 listenerClassName).newInstance());
1372 }
1373
1374 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
1375 }
1376 catch (Exception e) {
1377 _log.error(e);
1378 }
1379 }
1380 }
1381
1382 @BeanReference(name = "com.liferay.portlet.tags.service.persistence.TagsAssetPersistence.impl")
1383 protected com.liferay.portlet.tags.service.persistence.TagsAssetPersistence tagsAssetPersistence;
1384 @BeanReference(name = "com.liferay.portlet.tags.service.persistence.TagsEntryPersistence.impl")
1385 protected com.liferay.portlet.tags.service.persistence.TagsEntryPersistence tagsEntryPersistence;
1386 @BeanReference(name = "com.liferay.portlet.tags.service.persistence.TagsPropertyPersistence.impl")
1387 protected com.liferay.portlet.tags.service.persistence.TagsPropertyPersistence tagsPropertyPersistence;
1388 @BeanReference(name = "com.liferay.portlet.tags.service.persistence.TagsSourcePersistence.impl")
1389 protected com.liferay.portlet.tags.service.persistence.TagsSourcePersistence tagsSourcePersistence;
1390 @BeanReference(name = "com.liferay.portlet.tags.service.persistence.TagsVocabularyPersistence.impl")
1391 protected com.liferay.portlet.tags.service.persistence.TagsVocabularyPersistence tagsVocabularyPersistence;
1392 @BeanReference(name = "com.liferay.portal.service.persistence.ResourcePersistence.impl")
1393 protected com.liferay.portal.service.persistence.ResourcePersistence resourcePersistence;
1394 @BeanReference(name = "com.liferay.portal.service.persistence.UserPersistence.impl")
1395 protected com.liferay.portal.service.persistence.UserPersistence userPersistence;
1396 private static Log _log = LogFactoryUtil.getLog(TagsVocabularyPersistenceImpl.class);
1397}