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