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