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