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