1
19
20 package com.liferay.portlet.imagegallery.service.persistence;
21
22 import com.liferay.portal.SystemException;
23 import com.liferay.portal.kernel.dao.orm.DynamicQuery;
24 import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
25 import com.liferay.portal.kernel.dao.orm.Query;
26 import com.liferay.portal.kernel.dao.orm.QueryPos;
27 import com.liferay.portal.kernel.dao.orm.QueryUtil;
28 import com.liferay.portal.kernel.dao.orm.Session;
29 import com.liferay.portal.kernel.log.Log;
30 import com.liferay.portal.kernel.log.LogFactoryUtil;
31 import com.liferay.portal.kernel.util.GetterUtil;
32 import com.liferay.portal.kernel.util.OrderByComparator;
33 import com.liferay.portal.kernel.util.StringPool;
34 import com.liferay.portal.kernel.util.StringUtil;
35 import com.liferay.portal.kernel.util.Validator;
36 import com.liferay.portal.kernel.uuid.PortalUUIDUtil;
37 import com.liferay.portal.model.ModelListener;
38 import com.liferay.portal.service.persistence.BatchSessionUtil;
39 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
40
41 import com.liferay.portlet.imagegallery.NoSuchFolderException;
42 import com.liferay.portlet.imagegallery.model.IGFolder;
43 import com.liferay.portlet.imagegallery.model.impl.IGFolderImpl;
44 import com.liferay.portlet.imagegallery.model.impl.IGFolderModelImpl;
45
46 import java.util.ArrayList;
47 import java.util.Collections;
48 import java.util.Iterator;
49 import java.util.List;
50
51
57 public class IGFolderPersistenceImpl extends BasePersistenceImpl
58 implements IGFolderPersistence {
59 public IGFolder create(long folderId) {
60 IGFolder igFolder = new IGFolderImpl();
61
62 igFolder.setNew(true);
63 igFolder.setPrimaryKey(folderId);
64
65 String uuid = PortalUUIDUtil.generate();
66
67 igFolder.setUuid(uuid);
68
69 return igFolder;
70 }
71
72 public IGFolder remove(long folderId)
73 throws NoSuchFolderException, SystemException {
74 Session session = null;
75
76 try {
77 session = openSession();
78
79 IGFolder igFolder = (IGFolder)session.get(IGFolderImpl.class,
80 new Long(folderId));
81
82 if (igFolder == null) {
83 if (_log.isWarnEnabled()) {
84 _log.warn("No IGFolder exists with the primary key " +
85 folderId);
86 }
87
88 throw new NoSuchFolderException(
89 "No IGFolder exists with the primary key " + folderId);
90 }
91
92 return remove(igFolder);
93 }
94 catch (NoSuchFolderException nsee) {
95 throw nsee;
96 }
97 catch (Exception e) {
98 throw processException(e);
99 }
100 finally {
101 closeSession(session);
102 }
103 }
104
105 public IGFolder remove(IGFolder igFolder) throws SystemException {
106 for (ModelListener listener : listeners) {
107 listener.onBeforeRemove(igFolder);
108 }
109
110 igFolder = removeImpl(igFolder);
111
112 for (ModelListener listener : listeners) {
113 listener.onAfterRemove(igFolder);
114 }
115
116 return igFolder;
117 }
118
119 protected IGFolder removeImpl(IGFolder igFolder) throws SystemException {
120 Session session = null;
121
122 try {
123 session = openSession();
124
125 if (BatchSessionUtil.isEnabled()) {
126 Object staleObject = session.get(IGFolderImpl.class,
127 igFolder.getPrimaryKeyObj());
128
129 if (staleObject != null) {
130 session.evict(staleObject);
131 }
132 }
133
134 session.delete(igFolder);
135
136 session.flush();
137
138 return igFolder;
139 }
140 catch (Exception e) {
141 throw processException(e);
142 }
143 finally {
144 closeSession(session);
145
146 FinderCacheUtil.clearCache(IGFolder.class.getName());
147 }
148 }
149
150
153 public IGFolder update(IGFolder igFolder) throws SystemException {
154 if (_log.isWarnEnabled()) {
155 _log.warn(
156 "Using the deprecated update(IGFolder igFolder) method. Use update(IGFolder igFolder, boolean merge) instead.");
157 }
158
159 return update(igFolder, false);
160 }
161
162
175 public IGFolder update(IGFolder igFolder, boolean merge)
176 throws SystemException {
177 boolean isNew = igFolder.isNew();
178
179 for (ModelListener listener : listeners) {
180 if (isNew) {
181 listener.onBeforeCreate(igFolder);
182 }
183 else {
184 listener.onBeforeUpdate(igFolder);
185 }
186 }
187
188 igFolder = updateImpl(igFolder, merge);
189
190 for (ModelListener listener : listeners) {
191 if (isNew) {
192 listener.onAfterCreate(igFolder);
193 }
194 else {
195 listener.onAfterUpdate(igFolder);
196 }
197 }
198
199 return igFolder;
200 }
201
202 public IGFolder updateImpl(
203 com.liferay.portlet.imagegallery.model.IGFolder igFolder, boolean merge)
204 throws SystemException {
205 if (Validator.isNull(igFolder.getUuid())) {
206 String uuid = PortalUUIDUtil.generate();
207
208 igFolder.setUuid(uuid);
209 }
210
211 Session session = null;
212
213 try {
214 session = openSession();
215
216 BatchSessionUtil.update(session, igFolder, merge);
217
218 igFolder.setNew(false);
219
220 return igFolder;
221 }
222 catch (Exception e) {
223 throw processException(e);
224 }
225 finally {
226 closeSession(session);
227
228 FinderCacheUtil.clearCache(IGFolder.class.getName());
229 }
230 }
231
232 public IGFolder findByPrimaryKey(long folderId)
233 throws NoSuchFolderException, SystemException {
234 IGFolder igFolder = fetchByPrimaryKey(folderId);
235
236 if (igFolder == null) {
237 if (_log.isWarnEnabled()) {
238 _log.warn("No IGFolder exists with the primary key " +
239 folderId);
240 }
241
242 throw new NoSuchFolderException(
243 "No IGFolder exists with the primary key " + folderId);
244 }
245
246 return igFolder;
247 }
248
249 public IGFolder fetchByPrimaryKey(long folderId) throws SystemException {
250 Session session = null;
251
252 try {
253 session = openSession();
254
255 return (IGFolder)session.get(IGFolderImpl.class, new Long(folderId));
256 }
257 catch (Exception e) {
258 throw processException(e);
259 }
260 finally {
261 closeSession(session);
262 }
263 }
264
265 public List<IGFolder> findByUuid(String uuid) throws SystemException {
266 boolean finderClassNameCacheEnabled = IGFolderModelImpl.CACHE_ENABLED;
267 String finderClassName = IGFolder.class.getName();
268 String finderMethodName = "findByUuid";
269 String[] finderParams = new String[] { String.class.getName() };
270 Object[] finderArgs = new Object[] { uuid };
271
272 Object result = null;
273
274 if (finderClassNameCacheEnabled) {
275 result = FinderCacheUtil.getResult(finderClassName,
276 finderMethodName, finderParams, finderArgs, this);
277 }
278
279 if (result == null) {
280 Session session = null;
281
282 try {
283 session = openSession();
284
285 StringBuilder query = new StringBuilder();
286
287 query.append(
288 "FROM com.liferay.portlet.imagegallery.model.IGFolder WHERE ");
289
290 if (uuid == null) {
291 query.append("uuid_ IS NULL");
292 }
293 else {
294 query.append("uuid_ = ?");
295 }
296
297 query.append(" ");
298
299 query.append("ORDER BY ");
300
301 query.append("folderId ASC, ");
302 query.append("name ASC");
303
304 Query q = session.createQuery(query.toString());
305
306 QueryPos qPos = QueryPos.getInstance(q);
307
308 if (uuid != null) {
309 qPos.add(uuid);
310 }
311
312 List<IGFolder> list = q.list();
313
314 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
315 finderClassName, finderMethodName, finderParams,
316 finderArgs, list);
317
318 return list;
319 }
320 catch (Exception e) {
321 throw processException(e);
322 }
323 finally {
324 closeSession(session);
325 }
326 }
327 else {
328 return (List<IGFolder>)result;
329 }
330 }
331
332 public List<IGFolder> findByUuid(String uuid, int start, int end)
333 throws SystemException {
334 return findByUuid(uuid, start, end, null);
335 }
336
337 public List<IGFolder> findByUuid(String uuid, int start, int end,
338 OrderByComparator obc) throws SystemException {
339 boolean finderClassNameCacheEnabled = IGFolderModelImpl.CACHE_ENABLED;
340 String finderClassName = IGFolder.class.getName();
341 String finderMethodName = "findByUuid";
342 String[] finderParams = new String[] {
343 String.class.getName(),
344
345 "java.lang.Integer", "java.lang.Integer",
346 "com.liferay.portal.kernel.util.OrderByComparator"
347 };
348 Object[] finderArgs = new Object[] {
349 uuid,
350
351 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
352 };
353
354 Object result = null;
355
356 if (finderClassNameCacheEnabled) {
357 result = FinderCacheUtil.getResult(finderClassName,
358 finderMethodName, finderParams, finderArgs, this);
359 }
360
361 if (result == null) {
362 Session session = null;
363
364 try {
365 session = openSession();
366
367 StringBuilder query = new StringBuilder();
368
369 query.append(
370 "FROM com.liferay.portlet.imagegallery.model.IGFolder WHERE ");
371
372 if (uuid == null) {
373 query.append("uuid_ IS NULL");
374 }
375 else {
376 query.append("uuid_ = ?");
377 }
378
379 query.append(" ");
380
381 if (obc != null) {
382 query.append("ORDER BY ");
383 query.append(obc.getOrderBy());
384 }
385
386 else {
387 query.append("ORDER BY ");
388
389 query.append("folderId ASC, ");
390 query.append("name ASC");
391 }
392
393 Query q = session.createQuery(query.toString());
394
395 QueryPos qPos = QueryPos.getInstance(q);
396
397 if (uuid != null) {
398 qPos.add(uuid);
399 }
400
401 List<IGFolder> list = (List<IGFolder>)QueryUtil.list(q,
402 getDialect(), start, end);
403
404 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
405 finderClassName, finderMethodName, finderParams,
406 finderArgs, list);
407
408 return list;
409 }
410 catch (Exception e) {
411 throw processException(e);
412 }
413 finally {
414 closeSession(session);
415 }
416 }
417 else {
418 return (List<IGFolder>)result;
419 }
420 }
421
422 public IGFolder findByUuid_First(String uuid, OrderByComparator obc)
423 throws NoSuchFolderException, SystemException {
424 List<IGFolder> list = findByUuid(uuid, 0, 1, obc);
425
426 if (list.size() == 0) {
427 StringBuilder msg = new StringBuilder();
428
429 msg.append("No IGFolder exists with the key {");
430
431 msg.append("uuid=" + uuid);
432
433 msg.append(StringPool.CLOSE_CURLY_BRACE);
434
435 throw new NoSuchFolderException(msg.toString());
436 }
437 else {
438 return list.get(0);
439 }
440 }
441
442 public IGFolder findByUuid_Last(String uuid, OrderByComparator obc)
443 throws NoSuchFolderException, SystemException {
444 int count = countByUuid(uuid);
445
446 List<IGFolder> list = findByUuid(uuid, count - 1, count, obc);
447
448 if (list.size() == 0) {
449 StringBuilder msg = new StringBuilder();
450
451 msg.append("No IGFolder exists with the key {");
452
453 msg.append("uuid=" + uuid);
454
455 msg.append(StringPool.CLOSE_CURLY_BRACE);
456
457 throw new NoSuchFolderException(msg.toString());
458 }
459 else {
460 return list.get(0);
461 }
462 }
463
464 public IGFolder[] findByUuid_PrevAndNext(long folderId, String uuid,
465 OrderByComparator obc) throws NoSuchFolderException, SystemException {
466 IGFolder igFolder = findByPrimaryKey(folderId);
467
468 int count = countByUuid(uuid);
469
470 Session session = null;
471
472 try {
473 session = openSession();
474
475 StringBuilder query = new StringBuilder();
476
477 query.append(
478 "FROM com.liferay.portlet.imagegallery.model.IGFolder WHERE ");
479
480 if (uuid == null) {
481 query.append("uuid_ IS NULL");
482 }
483 else {
484 query.append("uuid_ = ?");
485 }
486
487 query.append(" ");
488
489 if (obc != null) {
490 query.append("ORDER BY ");
491 query.append(obc.getOrderBy());
492 }
493
494 else {
495 query.append("ORDER BY ");
496
497 query.append("folderId ASC, ");
498 query.append("name ASC");
499 }
500
501 Query q = session.createQuery(query.toString());
502
503 QueryPos qPos = QueryPos.getInstance(q);
504
505 if (uuid != null) {
506 qPos.add(uuid);
507 }
508
509 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc, igFolder);
510
511 IGFolder[] array = new IGFolderImpl[3];
512
513 array[0] = (IGFolder)objArray[0];
514 array[1] = (IGFolder)objArray[1];
515 array[2] = (IGFolder)objArray[2];
516
517 return array;
518 }
519 catch (Exception e) {
520 throw processException(e);
521 }
522 finally {
523 closeSession(session);
524 }
525 }
526
527 public IGFolder findByUUID_G(String uuid, long groupId)
528 throws NoSuchFolderException, SystemException {
529 IGFolder igFolder = fetchByUUID_G(uuid, groupId);
530
531 if (igFolder == null) {
532 StringBuilder msg = new StringBuilder();
533
534 msg.append("No IGFolder exists with the key {");
535
536 msg.append("uuid=" + uuid);
537
538 msg.append(", ");
539 msg.append("groupId=" + groupId);
540
541 msg.append(StringPool.CLOSE_CURLY_BRACE);
542
543 if (_log.isWarnEnabled()) {
544 _log.warn(msg.toString());
545 }
546
547 throw new NoSuchFolderException(msg.toString());
548 }
549
550 return igFolder;
551 }
552
553 public IGFolder fetchByUUID_G(String uuid, long groupId)
554 throws SystemException {
555 boolean finderClassNameCacheEnabled = IGFolderModelImpl.CACHE_ENABLED;
556 String finderClassName = IGFolder.class.getName();
557 String finderMethodName = "fetchByUUID_G";
558 String[] finderParams = new String[] {
559 String.class.getName(), Long.class.getName()
560 };
561 Object[] finderArgs = new Object[] { uuid, new Long(groupId) };
562
563 Object result = null;
564
565 if (finderClassNameCacheEnabled) {
566 result = FinderCacheUtil.getResult(finderClassName,
567 finderMethodName, finderParams, finderArgs, this);
568 }
569
570 if (result == null) {
571 Session session = null;
572
573 try {
574 session = openSession();
575
576 StringBuilder query = new StringBuilder();
577
578 query.append(
579 "FROM com.liferay.portlet.imagegallery.model.IGFolder WHERE ");
580
581 if (uuid == null) {
582 query.append("uuid_ IS NULL");
583 }
584 else {
585 query.append("uuid_ = ?");
586 }
587
588 query.append(" AND ");
589
590 query.append("groupId = ?");
591
592 query.append(" ");
593
594 query.append("ORDER BY ");
595
596 query.append("folderId ASC, ");
597 query.append("name ASC");
598
599 Query q = session.createQuery(query.toString());
600
601 QueryPos qPos = QueryPos.getInstance(q);
602
603 if (uuid != null) {
604 qPos.add(uuid);
605 }
606
607 qPos.add(groupId);
608
609 List<IGFolder> list = q.list();
610
611 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
612 finderClassName, finderMethodName, finderParams,
613 finderArgs, list);
614
615 if (list.size() == 0) {
616 return null;
617 }
618 else {
619 return list.get(0);
620 }
621 }
622 catch (Exception e) {
623 throw processException(e);
624 }
625 finally {
626 closeSession(session);
627 }
628 }
629 else {
630 List<IGFolder> list = (List<IGFolder>)result;
631
632 if (list.size() == 0) {
633 return null;
634 }
635 else {
636 return list.get(0);
637 }
638 }
639 }
640
641 public List<IGFolder> findByGroupId(long groupId) throws SystemException {
642 boolean finderClassNameCacheEnabled = IGFolderModelImpl.CACHE_ENABLED;
643 String finderClassName = IGFolder.class.getName();
644 String finderMethodName = "findByGroupId";
645 String[] finderParams = new String[] { Long.class.getName() };
646 Object[] finderArgs = new Object[] { new Long(groupId) };
647
648 Object result = null;
649
650 if (finderClassNameCacheEnabled) {
651 result = FinderCacheUtil.getResult(finderClassName,
652 finderMethodName, finderParams, finderArgs, this);
653 }
654
655 if (result == null) {
656 Session session = null;
657
658 try {
659 session = openSession();
660
661 StringBuilder query = new StringBuilder();
662
663 query.append(
664 "FROM com.liferay.portlet.imagegallery.model.IGFolder WHERE ");
665
666 query.append("groupId = ?");
667
668 query.append(" ");
669
670 query.append("ORDER BY ");
671
672 query.append("folderId ASC, ");
673 query.append("name ASC");
674
675 Query q = session.createQuery(query.toString());
676
677 QueryPos qPos = QueryPos.getInstance(q);
678
679 qPos.add(groupId);
680
681 List<IGFolder> list = q.list();
682
683 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
684 finderClassName, finderMethodName, finderParams,
685 finderArgs, list);
686
687 return list;
688 }
689 catch (Exception e) {
690 throw processException(e);
691 }
692 finally {
693 closeSession(session);
694 }
695 }
696 else {
697 return (List<IGFolder>)result;
698 }
699 }
700
701 public List<IGFolder> findByGroupId(long groupId, int start, int end)
702 throws SystemException {
703 return findByGroupId(groupId, start, end, null);
704 }
705
706 public List<IGFolder> findByGroupId(long groupId, int start, int end,
707 OrderByComparator obc) throws SystemException {
708 boolean finderClassNameCacheEnabled = IGFolderModelImpl.CACHE_ENABLED;
709 String finderClassName = IGFolder.class.getName();
710 String finderMethodName = "findByGroupId";
711 String[] finderParams = new String[] {
712 Long.class.getName(),
713
714 "java.lang.Integer", "java.lang.Integer",
715 "com.liferay.portal.kernel.util.OrderByComparator"
716 };
717 Object[] finderArgs = new Object[] {
718 new Long(groupId),
719
720 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
721 };
722
723 Object result = null;
724
725 if (finderClassNameCacheEnabled) {
726 result = FinderCacheUtil.getResult(finderClassName,
727 finderMethodName, finderParams, finderArgs, this);
728 }
729
730 if (result == null) {
731 Session session = null;
732
733 try {
734 session = openSession();
735
736 StringBuilder query = new StringBuilder();
737
738 query.append(
739 "FROM com.liferay.portlet.imagegallery.model.IGFolder WHERE ");
740
741 query.append("groupId = ?");
742
743 query.append(" ");
744
745 if (obc != null) {
746 query.append("ORDER BY ");
747 query.append(obc.getOrderBy());
748 }
749
750 else {
751 query.append("ORDER BY ");
752
753 query.append("folderId ASC, ");
754 query.append("name ASC");
755 }
756
757 Query q = session.createQuery(query.toString());
758
759 QueryPos qPos = QueryPos.getInstance(q);
760
761 qPos.add(groupId);
762
763 List<IGFolder> list = (List<IGFolder>)QueryUtil.list(q,
764 getDialect(), start, end);
765
766 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
767 finderClassName, finderMethodName, finderParams,
768 finderArgs, list);
769
770 return list;
771 }
772 catch (Exception e) {
773 throw processException(e);
774 }
775 finally {
776 closeSession(session);
777 }
778 }
779 else {
780 return (List<IGFolder>)result;
781 }
782 }
783
784 public IGFolder findByGroupId_First(long groupId, OrderByComparator obc)
785 throws NoSuchFolderException, SystemException {
786 List<IGFolder> list = findByGroupId(groupId, 0, 1, obc);
787
788 if (list.size() == 0) {
789 StringBuilder msg = new StringBuilder();
790
791 msg.append("No IGFolder exists with the key {");
792
793 msg.append("groupId=" + groupId);
794
795 msg.append(StringPool.CLOSE_CURLY_BRACE);
796
797 throw new NoSuchFolderException(msg.toString());
798 }
799 else {
800 return list.get(0);
801 }
802 }
803
804 public IGFolder findByGroupId_Last(long groupId, OrderByComparator obc)
805 throws NoSuchFolderException, SystemException {
806 int count = countByGroupId(groupId);
807
808 List<IGFolder> list = findByGroupId(groupId, count - 1, count, obc);
809
810 if (list.size() == 0) {
811 StringBuilder msg = new StringBuilder();
812
813 msg.append("No IGFolder exists with the key {");
814
815 msg.append("groupId=" + groupId);
816
817 msg.append(StringPool.CLOSE_CURLY_BRACE);
818
819 throw new NoSuchFolderException(msg.toString());
820 }
821 else {
822 return list.get(0);
823 }
824 }
825
826 public IGFolder[] findByGroupId_PrevAndNext(long folderId, long groupId,
827 OrderByComparator obc) throws NoSuchFolderException, SystemException {
828 IGFolder igFolder = findByPrimaryKey(folderId);
829
830 int count = countByGroupId(groupId);
831
832 Session session = null;
833
834 try {
835 session = openSession();
836
837 StringBuilder query = new StringBuilder();
838
839 query.append(
840 "FROM com.liferay.portlet.imagegallery.model.IGFolder WHERE ");
841
842 query.append("groupId = ?");
843
844 query.append(" ");
845
846 if (obc != null) {
847 query.append("ORDER BY ");
848 query.append(obc.getOrderBy());
849 }
850
851 else {
852 query.append("ORDER BY ");
853
854 query.append("folderId ASC, ");
855 query.append("name ASC");
856 }
857
858 Query q = session.createQuery(query.toString());
859
860 QueryPos qPos = QueryPos.getInstance(q);
861
862 qPos.add(groupId);
863
864 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc, igFolder);
865
866 IGFolder[] array = new IGFolderImpl[3];
867
868 array[0] = (IGFolder)objArray[0];
869 array[1] = (IGFolder)objArray[1];
870 array[2] = (IGFolder)objArray[2];
871
872 return array;
873 }
874 catch (Exception e) {
875 throw processException(e);
876 }
877 finally {
878 closeSession(session);
879 }
880 }
881
882 public List<IGFolder> findByCompanyId(long companyId)
883 throws SystemException {
884 boolean finderClassNameCacheEnabled = IGFolderModelImpl.CACHE_ENABLED;
885 String finderClassName = IGFolder.class.getName();
886 String finderMethodName = "findByCompanyId";
887 String[] finderParams = new String[] { Long.class.getName() };
888 Object[] finderArgs = new Object[] { new Long(companyId) };
889
890 Object result = null;
891
892 if (finderClassNameCacheEnabled) {
893 result = FinderCacheUtil.getResult(finderClassName,
894 finderMethodName, finderParams, finderArgs, this);
895 }
896
897 if (result == null) {
898 Session session = null;
899
900 try {
901 session = openSession();
902
903 StringBuilder query = new StringBuilder();
904
905 query.append(
906 "FROM com.liferay.portlet.imagegallery.model.IGFolder WHERE ");
907
908 query.append("companyId = ?");
909
910 query.append(" ");
911
912 query.append("ORDER BY ");
913
914 query.append("folderId ASC, ");
915 query.append("name ASC");
916
917 Query q = session.createQuery(query.toString());
918
919 QueryPos qPos = QueryPos.getInstance(q);
920
921 qPos.add(companyId);
922
923 List<IGFolder> list = q.list();
924
925 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
926 finderClassName, finderMethodName, finderParams,
927 finderArgs, list);
928
929 return list;
930 }
931 catch (Exception e) {
932 throw processException(e);
933 }
934 finally {
935 closeSession(session);
936 }
937 }
938 else {
939 return (List<IGFolder>)result;
940 }
941 }
942
943 public List<IGFolder> findByCompanyId(long companyId, int start, int end)
944 throws SystemException {
945 return findByCompanyId(companyId, start, end, null);
946 }
947
948 public List<IGFolder> findByCompanyId(long companyId, int start, int end,
949 OrderByComparator obc) throws SystemException {
950 boolean finderClassNameCacheEnabled = IGFolderModelImpl.CACHE_ENABLED;
951 String finderClassName = IGFolder.class.getName();
952 String finderMethodName = "findByCompanyId";
953 String[] finderParams = new String[] {
954 Long.class.getName(),
955
956 "java.lang.Integer", "java.lang.Integer",
957 "com.liferay.portal.kernel.util.OrderByComparator"
958 };
959 Object[] finderArgs = new Object[] {
960 new Long(companyId),
961
962 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
963 };
964
965 Object result = null;
966
967 if (finderClassNameCacheEnabled) {
968 result = FinderCacheUtil.getResult(finderClassName,
969 finderMethodName, finderParams, finderArgs, this);
970 }
971
972 if (result == null) {
973 Session session = null;
974
975 try {
976 session = openSession();
977
978 StringBuilder query = new StringBuilder();
979
980 query.append(
981 "FROM com.liferay.portlet.imagegallery.model.IGFolder WHERE ");
982
983 query.append("companyId = ?");
984
985 query.append(" ");
986
987 if (obc != null) {
988 query.append("ORDER BY ");
989 query.append(obc.getOrderBy());
990 }
991
992 else {
993 query.append("ORDER BY ");
994
995 query.append("folderId ASC, ");
996 query.append("name ASC");
997 }
998
999 Query q = session.createQuery(query.toString());
1000
1001 QueryPos qPos = QueryPos.getInstance(q);
1002
1003 qPos.add(companyId);
1004
1005 List<IGFolder> list = (List<IGFolder>)QueryUtil.list(q,
1006 getDialect(), start, end);
1007
1008 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
1009 finderClassName, finderMethodName, finderParams,
1010 finderArgs, list);
1011
1012 return list;
1013 }
1014 catch (Exception e) {
1015 throw processException(e);
1016 }
1017 finally {
1018 closeSession(session);
1019 }
1020 }
1021 else {
1022 return (List<IGFolder>)result;
1023 }
1024 }
1025
1026 public IGFolder findByCompanyId_First(long companyId, OrderByComparator obc)
1027 throws NoSuchFolderException, SystemException {
1028 List<IGFolder> list = findByCompanyId(companyId, 0, 1, obc);
1029
1030 if (list.size() == 0) {
1031 StringBuilder msg = new StringBuilder();
1032
1033 msg.append("No IGFolder exists with the key {");
1034
1035 msg.append("companyId=" + companyId);
1036
1037 msg.append(StringPool.CLOSE_CURLY_BRACE);
1038
1039 throw new NoSuchFolderException(msg.toString());
1040 }
1041 else {
1042 return list.get(0);
1043 }
1044 }
1045
1046 public IGFolder findByCompanyId_Last(long companyId, OrderByComparator obc)
1047 throws NoSuchFolderException, SystemException {
1048 int count = countByCompanyId(companyId);
1049
1050 List<IGFolder> list = findByCompanyId(companyId, count - 1, count, obc);
1051
1052 if (list.size() == 0) {
1053 StringBuilder msg = new StringBuilder();
1054
1055 msg.append("No IGFolder exists with the key {");
1056
1057 msg.append("companyId=" + companyId);
1058
1059 msg.append(StringPool.CLOSE_CURLY_BRACE);
1060
1061 throw new NoSuchFolderException(msg.toString());
1062 }
1063 else {
1064 return list.get(0);
1065 }
1066 }
1067
1068 public IGFolder[] findByCompanyId_PrevAndNext(long folderId,
1069 long companyId, OrderByComparator obc)
1070 throws NoSuchFolderException, SystemException {
1071 IGFolder igFolder = findByPrimaryKey(folderId);
1072
1073 int count = countByCompanyId(companyId);
1074
1075 Session session = null;
1076
1077 try {
1078 session = openSession();
1079
1080 StringBuilder query = new StringBuilder();
1081
1082 query.append(
1083 "FROM com.liferay.portlet.imagegallery.model.IGFolder WHERE ");
1084
1085 query.append("companyId = ?");
1086
1087 query.append(" ");
1088
1089 if (obc != null) {
1090 query.append("ORDER BY ");
1091 query.append(obc.getOrderBy());
1092 }
1093
1094 else {
1095 query.append("ORDER BY ");
1096
1097 query.append("folderId ASC, ");
1098 query.append("name ASC");
1099 }
1100
1101 Query q = session.createQuery(query.toString());
1102
1103 QueryPos qPos = QueryPos.getInstance(q);
1104
1105 qPos.add(companyId);
1106
1107 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc, igFolder);
1108
1109 IGFolder[] array = new IGFolderImpl[3];
1110
1111 array[0] = (IGFolder)objArray[0];
1112 array[1] = (IGFolder)objArray[1];
1113 array[2] = (IGFolder)objArray[2];
1114
1115 return array;
1116 }
1117 catch (Exception e) {
1118 throw processException(e);
1119 }
1120 finally {
1121 closeSession(session);
1122 }
1123 }
1124
1125 public List<IGFolder> findByG_P(long groupId, long parentFolderId)
1126 throws SystemException {
1127 boolean finderClassNameCacheEnabled = IGFolderModelImpl.CACHE_ENABLED;
1128 String finderClassName = IGFolder.class.getName();
1129 String finderMethodName = "findByG_P";
1130 String[] finderParams = new String[] {
1131 Long.class.getName(), Long.class.getName()
1132 };
1133 Object[] finderArgs = new Object[] {
1134 new Long(groupId), new Long(parentFolderId)
1135 };
1136
1137 Object result = null;
1138
1139 if (finderClassNameCacheEnabled) {
1140 result = FinderCacheUtil.getResult(finderClassName,
1141 finderMethodName, finderParams, finderArgs, this);
1142 }
1143
1144 if (result == null) {
1145 Session session = null;
1146
1147 try {
1148 session = openSession();
1149
1150 StringBuilder query = new StringBuilder();
1151
1152 query.append(
1153 "FROM com.liferay.portlet.imagegallery.model.IGFolder WHERE ");
1154
1155 query.append("groupId = ?");
1156
1157 query.append(" AND ");
1158
1159 query.append("parentFolderId = ?");
1160
1161 query.append(" ");
1162
1163 query.append("ORDER BY ");
1164
1165 query.append("folderId ASC, ");
1166 query.append("name ASC");
1167
1168 Query q = session.createQuery(query.toString());
1169
1170 QueryPos qPos = QueryPos.getInstance(q);
1171
1172 qPos.add(groupId);
1173
1174 qPos.add(parentFolderId);
1175
1176 List<IGFolder> list = q.list();
1177
1178 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
1179 finderClassName, finderMethodName, finderParams,
1180 finderArgs, list);
1181
1182 return list;
1183 }
1184 catch (Exception e) {
1185 throw processException(e);
1186 }
1187 finally {
1188 closeSession(session);
1189 }
1190 }
1191 else {
1192 return (List<IGFolder>)result;
1193 }
1194 }
1195
1196 public List<IGFolder> findByG_P(long groupId, long parentFolderId,
1197 int start, int end) throws SystemException {
1198 return findByG_P(groupId, parentFolderId, start, end, null);
1199 }
1200
1201 public List<IGFolder> findByG_P(long groupId, long parentFolderId,
1202 int start, int end, OrderByComparator obc) throws SystemException {
1203 boolean finderClassNameCacheEnabled = IGFolderModelImpl.CACHE_ENABLED;
1204 String finderClassName = IGFolder.class.getName();
1205 String finderMethodName = "findByG_P";
1206 String[] finderParams = new String[] {
1207 Long.class.getName(), Long.class.getName(),
1208
1209 "java.lang.Integer", "java.lang.Integer",
1210 "com.liferay.portal.kernel.util.OrderByComparator"
1211 };
1212 Object[] finderArgs = new Object[] {
1213 new Long(groupId), new Long(parentFolderId),
1214
1215 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
1216 };
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 StringBuilder query = new StringBuilder();
1232
1233 query.append(
1234 "FROM com.liferay.portlet.imagegallery.model.IGFolder WHERE ");
1235
1236 query.append("groupId = ?");
1237
1238 query.append(" AND ");
1239
1240 query.append("parentFolderId = ?");
1241
1242 query.append(" ");
1243
1244 if (obc != null) {
1245 query.append("ORDER BY ");
1246 query.append(obc.getOrderBy());
1247 }
1248
1249 else {
1250 query.append("ORDER BY ");
1251
1252 query.append("folderId ASC, ");
1253 query.append("name ASC");
1254 }
1255
1256 Query q = session.createQuery(query.toString());
1257
1258 QueryPos qPos = QueryPos.getInstance(q);
1259
1260 qPos.add(groupId);
1261
1262 qPos.add(parentFolderId);
1263
1264 List<IGFolder> list = (List<IGFolder>)QueryUtil.list(q,
1265 getDialect(), start, end);
1266
1267 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
1268 finderClassName, finderMethodName, finderParams,
1269 finderArgs, list);
1270
1271 return list;
1272 }
1273 catch (Exception e) {
1274 throw processException(e);
1275 }
1276 finally {
1277 closeSession(session);
1278 }
1279 }
1280 else {
1281 return (List<IGFolder>)result;
1282 }
1283 }
1284
1285 public IGFolder findByG_P_First(long groupId, long parentFolderId,
1286 OrderByComparator obc) throws NoSuchFolderException, SystemException {
1287 List<IGFolder> list = findByG_P(groupId, parentFolderId, 0, 1, obc);
1288
1289 if (list.size() == 0) {
1290 StringBuilder msg = new StringBuilder();
1291
1292 msg.append("No IGFolder exists with the key {");
1293
1294 msg.append("groupId=" + groupId);
1295
1296 msg.append(", ");
1297 msg.append("parentFolderId=" + parentFolderId);
1298
1299 msg.append(StringPool.CLOSE_CURLY_BRACE);
1300
1301 throw new NoSuchFolderException(msg.toString());
1302 }
1303 else {
1304 return list.get(0);
1305 }
1306 }
1307
1308 public IGFolder findByG_P_Last(long groupId, long parentFolderId,
1309 OrderByComparator obc) throws NoSuchFolderException, SystemException {
1310 int count = countByG_P(groupId, parentFolderId);
1311
1312 List<IGFolder> list = findByG_P(groupId, parentFolderId, count - 1,
1313 count, obc);
1314
1315 if (list.size() == 0) {
1316 StringBuilder msg = new StringBuilder();
1317
1318 msg.append("No IGFolder exists with the key {");
1319
1320 msg.append("groupId=" + groupId);
1321
1322 msg.append(", ");
1323 msg.append("parentFolderId=" + parentFolderId);
1324
1325 msg.append(StringPool.CLOSE_CURLY_BRACE);
1326
1327 throw new NoSuchFolderException(msg.toString());
1328 }
1329 else {
1330 return list.get(0);
1331 }
1332 }
1333
1334 public IGFolder[] findByG_P_PrevAndNext(long folderId, long groupId,
1335 long parentFolderId, OrderByComparator obc)
1336 throws NoSuchFolderException, SystemException {
1337 IGFolder igFolder = findByPrimaryKey(folderId);
1338
1339 int count = countByG_P(groupId, parentFolderId);
1340
1341 Session session = null;
1342
1343 try {
1344 session = openSession();
1345
1346 StringBuilder query = new StringBuilder();
1347
1348 query.append(
1349 "FROM com.liferay.portlet.imagegallery.model.IGFolder WHERE ");
1350
1351 query.append("groupId = ?");
1352
1353 query.append(" AND ");
1354
1355 query.append("parentFolderId = ?");
1356
1357 query.append(" ");
1358
1359 if (obc != null) {
1360 query.append("ORDER BY ");
1361 query.append(obc.getOrderBy());
1362 }
1363
1364 else {
1365 query.append("ORDER BY ");
1366
1367 query.append("folderId ASC, ");
1368 query.append("name ASC");
1369 }
1370
1371 Query q = session.createQuery(query.toString());
1372
1373 QueryPos qPos = QueryPos.getInstance(q);
1374
1375 qPos.add(groupId);
1376
1377 qPos.add(parentFolderId);
1378
1379 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc, igFolder);
1380
1381 IGFolder[] array = new IGFolderImpl[3];
1382
1383 array[0] = (IGFolder)objArray[0];
1384 array[1] = (IGFolder)objArray[1];
1385 array[2] = (IGFolder)objArray[2];
1386
1387 return array;
1388 }
1389 catch (Exception e) {
1390 throw processException(e);
1391 }
1392 finally {
1393 closeSession(session);
1394 }
1395 }
1396
1397 public IGFolder findByG_P_N(long groupId, long parentFolderId, String name)
1398 throws NoSuchFolderException, SystemException {
1399 IGFolder igFolder = fetchByG_P_N(groupId, parentFolderId, name);
1400
1401 if (igFolder == null) {
1402 StringBuilder msg = new StringBuilder();
1403
1404 msg.append("No IGFolder exists with the key {");
1405
1406 msg.append("groupId=" + groupId);
1407
1408 msg.append(", ");
1409 msg.append("parentFolderId=" + parentFolderId);
1410
1411 msg.append(", ");
1412 msg.append("name=" + name);
1413
1414 msg.append(StringPool.CLOSE_CURLY_BRACE);
1415
1416 if (_log.isWarnEnabled()) {
1417 _log.warn(msg.toString());
1418 }
1419
1420 throw new NoSuchFolderException(msg.toString());
1421 }
1422
1423 return igFolder;
1424 }
1425
1426 public IGFolder fetchByG_P_N(long groupId, long parentFolderId, String name)
1427 throws SystemException {
1428 boolean finderClassNameCacheEnabled = IGFolderModelImpl.CACHE_ENABLED;
1429 String finderClassName = IGFolder.class.getName();
1430 String finderMethodName = "fetchByG_P_N";
1431 String[] finderParams = new String[] {
1432 Long.class.getName(), Long.class.getName(),
1433 String.class.getName()
1434 };
1435 Object[] finderArgs = new Object[] {
1436 new Long(groupId), new Long(parentFolderId),
1437
1438 name
1439 };
1440
1441 Object result = null;
1442
1443 if (finderClassNameCacheEnabled) {
1444 result = FinderCacheUtil.getResult(finderClassName,
1445 finderMethodName, finderParams, finderArgs, this);
1446 }
1447
1448 if (result == null) {
1449 Session session = null;
1450
1451 try {
1452 session = openSession();
1453
1454 StringBuilder query = new StringBuilder();
1455
1456 query.append(
1457 "FROM com.liferay.portlet.imagegallery.model.IGFolder WHERE ");
1458
1459 query.append("groupId = ?");
1460
1461 query.append(" AND ");
1462
1463 query.append("parentFolderId = ?");
1464
1465 query.append(" AND ");
1466
1467 if (name == null) {
1468 query.append("name IS NULL");
1469 }
1470 else {
1471 query.append("name = ?");
1472 }
1473
1474 query.append(" ");
1475
1476 query.append("ORDER BY ");
1477
1478 query.append("folderId ASC, ");
1479 query.append("name ASC");
1480
1481 Query q = session.createQuery(query.toString());
1482
1483 QueryPos qPos = QueryPos.getInstance(q);
1484
1485 qPos.add(groupId);
1486
1487 qPos.add(parentFolderId);
1488
1489 if (name != null) {
1490 qPos.add(name);
1491 }
1492
1493 List<IGFolder> list = q.list();
1494
1495 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
1496 finderClassName, finderMethodName, finderParams,
1497 finderArgs, list);
1498
1499 if (list.size() == 0) {
1500 return null;
1501 }
1502 else {
1503 return list.get(0);
1504 }
1505 }
1506 catch (Exception e) {
1507 throw processException(e);
1508 }
1509 finally {
1510 closeSession(session);
1511 }
1512 }
1513 else {
1514 List<IGFolder> list = (List<IGFolder>)result;
1515
1516 if (list.size() == 0) {
1517 return null;
1518 }
1519 else {
1520 return list.get(0);
1521 }
1522 }
1523 }
1524
1525 public List<Object> findWithDynamicQuery(DynamicQuery dynamicQuery)
1526 throws SystemException {
1527 Session session = null;
1528
1529 try {
1530 session = openSession();
1531
1532 dynamicQuery.compile(session);
1533
1534 return dynamicQuery.list();
1535 }
1536 catch (Exception e) {
1537 throw processException(e);
1538 }
1539 finally {
1540 closeSession(session);
1541 }
1542 }
1543
1544 public List<Object> findWithDynamicQuery(DynamicQuery dynamicQuery,
1545 int start, int end) throws SystemException {
1546 Session session = null;
1547
1548 try {
1549 session = openSession();
1550
1551 dynamicQuery.setLimit(start, end);
1552
1553 dynamicQuery.compile(session);
1554
1555 return dynamicQuery.list();
1556 }
1557 catch (Exception e) {
1558 throw processException(e);
1559 }
1560 finally {
1561 closeSession(session);
1562 }
1563 }
1564
1565 public List<IGFolder> findAll() throws SystemException {
1566 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1567 }
1568
1569 public List<IGFolder> findAll(int start, int end) throws SystemException {
1570 return findAll(start, end, null);
1571 }
1572
1573 public List<IGFolder> findAll(int start, int end, OrderByComparator obc)
1574 throws SystemException {
1575 boolean finderClassNameCacheEnabled = IGFolderModelImpl.CACHE_ENABLED;
1576 String finderClassName = IGFolder.class.getName();
1577 String finderMethodName = "findAll";
1578 String[] finderParams = new String[] {
1579 "java.lang.Integer", "java.lang.Integer",
1580 "com.liferay.portal.kernel.util.OrderByComparator"
1581 };
1582 Object[] finderArgs = new Object[] {
1583 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
1584 };
1585
1586 Object result = null;
1587
1588 if (finderClassNameCacheEnabled) {
1589 result = FinderCacheUtil.getResult(finderClassName,
1590 finderMethodName, finderParams, finderArgs, this);
1591 }
1592
1593 if (result == null) {
1594 Session session = null;
1595
1596 try {
1597 session = openSession();
1598
1599 StringBuilder query = new StringBuilder();
1600
1601 query.append(
1602 "FROM com.liferay.portlet.imagegallery.model.IGFolder ");
1603
1604 if (obc != null) {
1605 query.append("ORDER BY ");
1606 query.append(obc.getOrderBy());
1607 }
1608
1609 else {
1610 query.append("ORDER BY ");
1611
1612 query.append("folderId ASC, ");
1613 query.append("name ASC");
1614 }
1615
1616 Query q = session.createQuery(query.toString());
1617
1618 List<IGFolder> list = null;
1619
1620 if (obc == null) {
1621 list = (List<IGFolder>)QueryUtil.list(q, getDialect(),
1622 start, end, false);
1623
1624 Collections.sort(list);
1625 }
1626 else {
1627 list = (List<IGFolder>)QueryUtil.list(q, getDialect(),
1628 start, end);
1629 }
1630
1631 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
1632 finderClassName, finderMethodName, finderParams,
1633 finderArgs, list);
1634
1635 return list;
1636 }
1637 catch (Exception e) {
1638 throw processException(e);
1639 }
1640 finally {
1641 closeSession(session);
1642 }
1643 }
1644 else {
1645 return (List<IGFolder>)result;
1646 }
1647 }
1648
1649 public void removeByUuid(String uuid) throws SystemException {
1650 for (IGFolder igFolder : findByUuid(uuid)) {
1651 remove(igFolder);
1652 }
1653 }
1654
1655 public void removeByUUID_G(String uuid, long groupId)
1656 throws NoSuchFolderException, SystemException {
1657 IGFolder igFolder = findByUUID_G(uuid, groupId);
1658
1659 remove(igFolder);
1660 }
1661
1662 public void removeByGroupId(long groupId) throws SystemException {
1663 for (IGFolder igFolder : findByGroupId(groupId)) {
1664 remove(igFolder);
1665 }
1666 }
1667
1668 public void removeByCompanyId(long companyId) throws SystemException {
1669 for (IGFolder igFolder : findByCompanyId(companyId)) {
1670 remove(igFolder);
1671 }
1672 }
1673
1674 public void removeByG_P(long groupId, long parentFolderId)
1675 throws SystemException {
1676 for (IGFolder igFolder : findByG_P(groupId, parentFolderId)) {
1677 remove(igFolder);
1678 }
1679 }
1680
1681 public void removeByG_P_N(long groupId, long parentFolderId, String name)
1682 throws NoSuchFolderException, SystemException {
1683 IGFolder igFolder = findByG_P_N(groupId, parentFolderId, name);
1684
1685 remove(igFolder);
1686 }
1687
1688 public void removeAll() throws SystemException {
1689 for (IGFolder igFolder : findAll()) {
1690 remove(igFolder);
1691 }
1692 }
1693
1694 public int countByUuid(String uuid) throws SystemException {
1695 boolean finderClassNameCacheEnabled = IGFolderModelImpl.CACHE_ENABLED;
1696 String finderClassName = IGFolder.class.getName();
1697 String finderMethodName = "countByUuid";
1698 String[] finderParams = new String[] { String.class.getName() };
1699 Object[] finderArgs = new Object[] { uuid };
1700
1701 Object result = null;
1702
1703 if (finderClassNameCacheEnabled) {
1704 result = FinderCacheUtil.getResult(finderClassName,
1705 finderMethodName, finderParams, finderArgs, this);
1706 }
1707
1708 if (result == null) {
1709 Session session = null;
1710
1711 try {
1712 session = openSession();
1713
1714 StringBuilder query = new StringBuilder();
1715
1716 query.append("SELECT COUNT(*) ");
1717 query.append(
1718 "FROM com.liferay.portlet.imagegallery.model.IGFolder WHERE ");
1719
1720 if (uuid == null) {
1721 query.append("uuid_ IS NULL");
1722 }
1723 else {
1724 query.append("uuid_ = ?");
1725 }
1726
1727 query.append(" ");
1728
1729 Query q = session.createQuery(query.toString());
1730
1731 QueryPos qPos = QueryPos.getInstance(q);
1732
1733 if (uuid != null) {
1734 qPos.add(uuid);
1735 }
1736
1737 Long count = null;
1738
1739 Iterator<Long> itr = q.list().iterator();
1740
1741 if (itr.hasNext()) {
1742 count = itr.next();
1743 }
1744
1745 if (count == null) {
1746 count = new Long(0);
1747 }
1748
1749 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
1750 finderClassName, finderMethodName, finderParams,
1751 finderArgs, count);
1752
1753 return count.intValue();
1754 }
1755 catch (Exception e) {
1756 throw processException(e);
1757 }
1758 finally {
1759 closeSession(session);
1760 }
1761 }
1762 else {
1763 return ((Long)result).intValue();
1764 }
1765 }
1766
1767 public int countByUUID_G(String uuid, long groupId)
1768 throws SystemException {
1769 boolean finderClassNameCacheEnabled = IGFolderModelImpl.CACHE_ENABLED;
1770 String finderClassName = IGFolder.class.getName();
1771 String finderMethodName = "countByUUID_G";
1772 String[] finderParams = new String[] {
1773 String.class.getName(), Long.class.getName()
1774 };
1775 Object[] finderArgs = new Object[] { uuid, new Long(groupId) };
1776
1777 Object result = null;
1778
1779 if (finderClassNameCacheEnabled) {
1780 result = FinderCacheUtil.getResult(finderClassName,
1781 finderMethodName, finderParams, finderArgs, this);
1782 }
1783
1784 if (result == null) {
1785 Session session = null;
1786
1787 try {
1788 session = openSession();
1789
1790 StringBuilder query = new StringBuilder();
1791
1792 query.append("SELECT COUNT(*) ");
1793 query.append(
1794 "FROM com.liferay.portlet.imagegallery.model.IGFolder WHERE ");
1795
1796 if (uuid == null) {
1797 query.append("uuid_ IS NULL");
1798 }
1799 else {
1800 query.append("uuid_ = ?");
1801 }
1802
1803 query.append(" AND ");
1804
1805 query.append("groupId = ?");
1806
1807 query.append(" ");
1808
1809 Query q = session.createQuery(query.toString());
1810
1811 QueryPos qPos = QueryPos.getInstance(q);
1812
1813 if (uuid != null) {
1814 qPos.add(uuid);
1815 }
1816
1817 qPos.add(groupId);
1818
1819 Long count = null;
1820
1821 Iterator<Long> itr = q.list().iterator();
1822
1823 if (itr.hasNext()) {
1824 count = itr.next();
1825 }
1826
1827 if (count == null) {
1828 count = new Long(0);
1829 }
1830
1831 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
1832 finderClassName, finderMethodName, finderParams,
1833 finderArgs, count);
1834
1835 return count.intValue();
1836 }
1837 catch (Exception e) {
1838 throw processException(e);
1839 }
1840 finally {
1841 closeSession(session);
1842 }
1843 }
1844 else {
1845 return ((Long)result).intValue();
1846 }
1847 }
1848
1849 public int countByGroupId(long groupId) throws SystemException {
1850 boolean finderClassNameCacheEnabled = IGFolderModelImpl.CACHE_ENABLED;
1851 String finderClassName = IGFolder.class.getName();
1852 String finderMethodName = "countByGroupId";
1853 String[] finderParams = new String[] { Long.class.getName() };
1854 Object[] finderArgs = new Object[] { new Long(groupId) };
1855
1856 Object result = null;
1857
1858 if (finderClassNameCacheEnabled) {
1859 result = FinderCacheUtil.getResult(finderClassName,
1860 finderMethodName, finderParams, finderArgs, this);
1861 }
1862
1863 if (result == null) {
1864 Session session = null;
1865
1866 try {
1867 session = openSession();
1868
1869 StringBuilder query = new StringBuilder();
1870
1871 query.append("SELECT COUNT(*) ");
1872 query.append(
1873 "FROM com.liferay.portlet.imagegallery.model.IGFolder WHERE ");
1874
1875 query.append("groupId = ?");
1876
1877 query.append(" ");
1878
1879 Query q = session.createQuery(query.toString());
1880
1881 QueryPos qPos = QueryPos.getInstance(q);
1882
1883 qPos.add(groupId);
1884
1885 Long count = null;
1886
1887 Iterator<Long> itr = q.list().iterator();
1888
1889 if (itr.hasNext()) {
1890 count = itr.next();
1891 }
1892
1893 if (count == null) {
1894 count = new Long(0);
1895 }
1896
1897 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
1898 finderClassName, finderMethodName, finderParams,
1899 finderArgs, count);
1900
1901 return count.intValue();
1902 }
1903 catch (Exception e) {
1904 throw processException(e);
1905 }
1906 finally {
1907 closeSession(session);
1908 }
1909 }
1910 else {
1911 return ((Long)result).intValue();
1912 }
1913 }
1914
1915 public int countByCompanyId(long companyId) throws SystemException {
1916 boolean finderClassNameCacheEnabled = IGFolderModelImpl.CACHE_ENABLED;
1917 String finderClassName = IGFolder.class.getName();
1918 String finderMethodName = "countByCompanyId";
1919 String[] finderParams = new String[] { Long.class.getName() };
1920 Object[] finderArgs = new Object[] { new Long(companyId) };
1921
1922 Object result = null;
1923
1924 if (finderClassNameCacheEnabled) {
1925 result = FinderCacheUtil.getResult(finderClassName,
1926 finderMethodName, finderParams, finderArgs, this);
1927 }
1928
1929 if (result == null) {
1930 Session session = null;
1931
1932 try {
1933 session = openSession();
1934
1935 StringBuilder query = new StringBuilder();
1936
1937 query.append("SELECT COUNT(*) ");
1938 query.append(
1939 "FROM com.liferay.portlet.imagegallery.model.IGFolder WHERE ");
1940
1941 query.append("companyId = ?");
1942
1943 query.append(" ");
1944
1945 Query q = session.createQuery(query.toString());
1946
1947 QueryPos qPos = QueryPos.getInstance(q);
1948
1949 qPos.add(companyId);
1950
1951 Long count = null;
1952
1953 Iterator<Long> itr = q.list().iterator();
1954
1955 if (itr.hasNext()) {
1956 count = itr.next();
1957 }
1958
1959 if (count == null) {
1960 count = new Long(0);
1961 }
1962
1963 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
1964 finderClassName, finderMethodName, finderParams,
1965 finderArgs, count);
1966
1967 return count.intValue();
1968 }
1969 catch (Exception e) {
1970 throw processException(e);
1971 }
1972 finally {
1973 closeSession(session);
1974 }
1975 }
1976 else {
1977 return ((Long)result).intValue();
1978 }
1979 }
1980
1981 public int countByG_P(long groupId, long parentFolderId)
1982 throws SystemException {
1983 boolean finderClassNameCacheEnabled = IGFolderModelImpl.CACHE_ENABLED;
1984 String finderClassName = IGFolder.class.getName();
1985 String finderMethodName = "countByG_P";
1986 String[] finderParams = new String[] {
1987 Long.class.getName(), Long.class.getName()
1988 };
1989 Object[] finderArgs = new Object[] {
1990 new Long(groupId), new Long(parentFolderId)
1991 };
1992
1993 Object result = null;
1994
1995 if (finderClassNameCacheEnabled) {
1996 result = FinderCacheUtil.getResult(finderClassName,
1997 finderMethodName, finderParams, finderArgs, this);
1998 }
1999
2000 if (result == null) {
2001 Session session = null;
2002
2003 try {
2004 session = openSession();
2005
2006 StringBuilder query = new StringBuilder();
2007
2008 query.append("SELECT COUNT(*) ");
2009 query.append(
2010 "FROM com.liferay.portlet.imagegallery.model.IGFolder WHERE ");
2011
2012 query.append("groupId = ?");
2013
2014 query.append(" AND ");
2015
2016 query.append("parentFolderId = ?");
2017
2018 query.append(" ");
2019
2020 Query q = session.createQuery(query.toString());
2021
2022 QueryPos qPos = QueryPos.getInstance(q);
2023
2024 qPos.add(groupId);
2025
2026 qPos.add(parentFolderId);
2027
2028 Long count = null;
2029
2030 Iterator<Long> itr = q.list().iterator();
2031
2032 if (itr.hasNext()) {
2033 count = itr.next();
2034 }
2035
2036 if (count == null) {
2037 count = new Long(0);
2038 }
2039
2040 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
2041 finderClassName, finderMethodName, finderParams,
2042 finderArgs, count);
2043
2044 return count.intValue();
2045 }
2046 catch (Exception e) {
2047 throw processException(e);
2048 }
2049 finally {
2050 closeSession(session);
2051 }
2052 }
2053 else {
2054 return ((Long)result).intValue();
2055 }
2056 }
2057
2058 public int countByG_P_N(long groupId, long parentFolderId, String name)
2059 throws SystemException {
2060 boolean finderClassNameCacheEnabled = IGFolderModelImpl.CACHE_ENABLED;
2061 String finderClassName = IGFolder.class.getName();
2062 String finderMethodName = "countByG_P_N";
2063 String[] finderParams = new String[] {
2064 Long.class.getName(), Long.class.getName(),
2065 String.class.getName()
2066 };
2067 Object[] finderArgs = new Object[] {
2068 new Long(groupId), new Long(parentFolderId),
2069
2070 name
2071 };
2072
2073 Object result = null;
2074
2075 if (finderClassNameCacheEnabled) {
2076 result = FinderCacheUtil.getResult(finderClassName,
2077 finderMethodName, finderParams, finderArgs, this);
2078 }
2079
2080 if (result == null) {
2081 Session session = null;
2082
2083 try {
2084 session = openSession();
2085
2086 StringBuilder query = new StringBuilder();
2087
2088 query.append("SELECT COUNT(*) ");
2089 query.append(
2090 "FROM com.liferay.portlet.imagegallery.model.IGFolder WHERE ");
2091
2092 query.append("groupId = ?");
2093
2094 query.append(" AND ");
2095
2096 query.append("parentFolderId = ?");
2097
2098 query.append(" AND ");
2099
2100 if (name == null) {
2101 query.append("name IS NULL");
2102 }
2103 else {
2104 query.append("name = ?");
2105 }
2106
2107 query.append(" ");
2108
2109 Query q = session.createQuery(query.toString());
2110
2111 QueryPos qPos = QueryPos.getInstance(q);
2112
2113 qPos.add(groupId);
2114
2115 qPos.add(parentFolderId);
2116
2117 if (name != null) {
2118 qPos.add(name);
2119 }
2120
2121 Long count = null;
2122
2123 Iterator<Long> itr = q.list().iterator();
2124
2125 if (itr.hasNext()) {
2126 count = itr.next();
2127 }
2128
2129 if (count == null) {
2130 count = new Long(0);
2131 }
2132
2133 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
2134 finderClassName, finderMethodName, finderParams,
2135 finderArgs, count);
2136
2137 return count.intValue();
2138 }
2139 catch (Exception e) {
2140 throw processException(e);
2141 }
2142 finally {
2143 closeSession(session);
2144 }
2145 }
2146 else {
2147 return ((Long)result).intValue();
2148 }
2149 }
2150
2151 public int countAll() throws SystemException {
2152 boolean finderClassNameCacheEnabled = IGFolderModelImpl.CACHE_ENABLED;
2153 String finderClassName = IGFolder.class.getName();
2154 String finderMethodName = "countAll";
2155 String[] finderParams = new String[] { };
2156 Object[] finderArgs = new Object[] { };
2157
2158 Object result = null;
2159
2160 if (finderClassNameCacheEnabled) {
2161 result = FinderCacheUtil.getResult(finderClassName,
2162 finderMethodName, finderParams, finderArgs, this);
2163 }
2164
2165 if (result == null) {
2166 Session session = null;
2167
2168 try {
2169 session = openSession();
2170
2171 Query q = session.createQuery(
2172 "SELECT COUNT(*) FROM com.liferay.portlet.imagegallery.model.IGFolder");
2173
2174 Long count = null;
2175
2176 Iterator<Long> itr = q.list().iterator();
2177
2178 if (itr.hasNext()) {
2179 count = itr.next();
2180 }
2181
2182 if (count == null) {
2183 count = new Long(0);
2184 }
2185
2186 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
2187 finderClassName, finderMethodName, finderParams,
2188 finderArgs, count);
2189
2190 return count.intValue();
2191 }
2192 catch (Exception e) {
2193 throw processException(e);
2194 }
2195 finally {
2196 closeSession(session);
2197 }
2198 }
2199 else {
2200 return ((Long)result).intValue();
2201 }
2202 }
2203
2204 public void afterPropertiesSet() {
2205 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
2206 com.liferay.portal.util.PropsUtil.get(
2207 "value.object.listener.com.liferay.portlet.imagegallery.model.IGFolder")));
2208
2209 if (listenerClassNames.length > 0) {
2210 try {
2211 List<ModelListener> listenersList = new ArrayList<ModelListener>();
2212
2213 for (String listenerClassName : listenerClassNames) {
2214 listenersList.add((ModelListener)Class.forName(
2215 listenerClassName).newInstance());
2216 }
2217
2218 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
2219 }
2220 catch (Exception e) {
2221 _log.error(e);
2222 }
2223 }
2224 }
2225
2226 private static Log _log = LogFactoryUtil.getLog(IGFolderPersistenceImpl.class);
2227}