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