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