1
22
23 package com.liferay.portlet.documentlibrary.service.persistence;
24
25 import com.liferay.portal.SystemException;
26 import com.liferay.portal.kernel.dao.orm.DynamicQuery;
27 import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
28 import com.liferay.portal.kernel.dao.orm.Query;
29 import com.liferay.portal.kernel.dao.orm.QueryPos;
30 import com.liferay.portal.kernel.dao.orm.QueryUtil;
31 import com.liferay.portal.kernel.dao.orm.Session;
32 import com.liferay.portal.kernel.util.GetterUtil;
33 import com.liferay.portal.kernel.util.ListUtil;
34 import com.liferay.portal.kernel.util.OrderByComparator;
35 import com.liferay.portal.kernel.util.StringPool;
36 import com.liferay.portal.kernel.util.StringUtil;
37 import com.liferay.portal.kernel.util.Validator;
38 import com.liferay.portal.kernel.uuid.PortalUUIDUtil;
39 import com.liferay.portal.model.ModelListener;
40 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
41
42 import com.liferay.portlet.documentlibrary.NoSuchFileShortcutException;
43 import com.liferay.portlet.documentlibrary.model.DLFileShortcut;
44 import com.liferay.portlet.documentlibrary.model.impl.DLFileShortcutImpl;
45 import com.liferay.portlet.documentlibrary.model.impl.DLFileShortcutModelImpl;
46
47 import org.apache.commons.logging.Log;
48 import org.apache.commons.logging.LogFactory;
49
50 import java.util.ArrayList;
51 import java.util.Collections;
52 import java.util.Iterator;
53 import java.util.List;
54
55
61 public class DLFileShortcutPersistenceImpl extends BasePersistenceImpl
62 implements DLFileShortcutPersistence {
63 public DLFileShortcut create(long fileShortcutId) {
64 DLFileShortcut dlFileShortcut = new DLFileShortcutImpl();
65
66 dlFileShortcut.setNew(true);
67 dlFileShortcut.setPrimaryKey(fileShortcutId);
68
69 String uuid = PortalUUIDUtil.generate();
70
71 dlFileShortcut.setUuid(uuid);
72
73 return dlFileShortcut;
74 }
75
76 public DLFileShortcut remove(long fileShortcutId)
77 throws NoSuchFileShortcutException, SystemException {
78 Session session = null;
79
80 try {
81 session = openSession();
82
83 DLFileShortcut dlFileShortcut = (DLFileShortcut)session.get(DLFileShortcutImpl.class,
84 new Long(fileShortcutId));
85
86 if (dlFileShortcut == null) {
87 if (_log.isWarnEnabled()) {
88 _log.warn("No DLFileShortcut exists with the primary key " +
89 fileShortcutId);
90 }
91
92 throw new NoSuchFileShortcutException(
93 "No DLFileShortcut exists with the primary key " +
94 fileShortcutId);
95 }
96
97 return remove(dlFileShortcut);
98 }
99 catch (NoSuchFileShortcutException nsee) {
100 throw nsee;
101 }
102 catch (Exception e) {
103 throw processException(e);
104 }
105 finally {
106 closeSession(session);
107 }
108 }
109
110 public DLFileShortcut remove(DLFileShortcut dlFileShortcut)
111 throws SystemException {
112 if (_listeners.length > 0) {
113 for (ModelListener listener : _listeners) {
114 listener.onBeforeRemove(dlFileShortcut);
115 }
116 }
117
118 dlFileShortcut = removeImpl(dlFileShortcut);
119
120 if (_listeners.length > 0) {
121 for (ModelListener listener : _listeners) {
122 listener.onAfterRemove(dlFileShortcut);
123 }
124 }
125
126 return dlFileShortcut;
127 }
128
129 protected DLFileShortcut removeImpl(DLFileShortcut dlFileShortcut)
130 throws SystemException {
131 Session session = null;
132
133 try {
134 session = openSession();
135
136 session.delete(dlFileShortcut);
137
138 session.flush();
139
140 return dlFileShortcut;
141 }
142 catch (Exception e) {
143 throw processException(e);
144 }
145 finally {
146 closeSession(session);
147
148 FinderCacheUtil.clearCache(DLFileShortcut.class.getName());
149 }
150 }
151
152
155 public DLFileShortcut update(DLFileShortcut dlFileShortcut)
156 throws SystemException {
157 if (_log.isWarnEnabled()) {
158 _log.warn(
159 "Using the deprecated update(DLFileShortcut dlFileShortcut) method. Use update(DLFileShortcut dlFileShortcut, boolean merge) instead.");
160 }
161
162 return update(dlFileShortcut, false);
163 }
164
165
178 public DLFileShortcut update(DLFileShortcut dlFileShortcut, boolean merge)
179 throws SystemException {
180 boolean isNew = dlFileShortcut.isNew();
181
182 if (_listeners.length > 0) {
183 for (ModelListener listener : _listeners) {
184 if (isNew) {
185 listener.onBeforeCreate(dlFileShortcut);
186 }
187 else {
188 listener.onBeforeUpdate(dlFileShortcut);
189 }
190 }
191 }
192
193 dlFileShortcut = updateImpl(dlFileShortcut, merge);
194
195 if (_listeners.length > 0) {
196 for (ModelListener listener : _listeners) {
197 if (isNew) {
198 listener.onAfterCreate(dlFileShortcut);
199 }
200 else {
201 listener.onAfterUpdate(dlFileShortcut);
202 }
203 }
204 }
205
206 return dlFileShortcut;
207 }
208
209 public DLFileShortcut updateImpl(
210 com.liferay.portlet.documentlibrary.model.DLFileShortcut dlFileShortcut,
211 boolean merge) throws SystemException {
212 if (Validator.isNull(dlFileShortcut.getUuid())) {
213 String uuid = PortalUUIDUtil.generate();
214
215 dlFileShortcut.setUuid(uuid);
216 }
217
218 Session session = null;
219
220 try {
221 session = openSession();
222
223 if (merge) {
224 session.merge(dlFileShortcut);
225 }
226 else {
227 if (dlFileShortcut.isNew()) {
228 session.save(dlFileShortcut);
229 }
230 }
231
232 session.flush();
233
234 dlFileShortcut.setNew(false);
235
236 return dlFileShortcut;
237 }
238 catch (Exception e) {
239 throw processException(e);
240 }
241 finally {
242 closeSession(session);
243
244 FinderCacheUtil.clearCache(DLFileShortcut.class.getName());
245 }
246 }
247
248 public DLFileShortcut findByPrimaryKey(long fileShortcutId)
249 throws NoSuchFileShortcutException, SystemException {
250 DLFileShortcut dlFileShortcut = fetchByPrimaryKey(fileShortcutId);
251
252 if (dlFileShortcut == null) {
253 if (_log.isWarnEnabled()) {
254 _log.warn("No DLFileShortcut exists with the primary key " +
255 fileShortcutId);
256 }
257
258 throw new NoSuchFileShortcutException(
259 "No DLFileShortcut exists with the primary key " +
260 fileShortcutId);
261 }
262
263 return dlFileShortcut;
264 }
265
266 public DLFileShortcut fetchByPrimaryKey(long fileShortcutId)
267 throws SystemException {
268 Session session = null;
269
270 try {
271 session = openSession();
272
273 return (DLFileShortcut)session.get(DLFileShortcutImpl.class,
274 new Long(fileShortcutId));
275 }
276 catch (Exception e) {
277 throw processException(e);
278 }
279 finally {
280 closeSession(session);
281 }
282 }
283
284 public List<DLFileShortcut> findByUuid(String uuid)
285 throws SystemException {
286 boolean finderClassNameCacheEnabled = DLFileShortcutModelImpl.CACHE_ENABLED;
287 String finderClassName = DLFileShortcut.class.getName();
288 String finderMethodName = "findByUuid";
289 String[] finderParams = new String[] { String.class.getName() };
290 Object[] finderArgs = new Object[] { uuid };
291
292 Object result = null;
293
294 if (finderClassNameCacheEnabled) {
295 result = FinderCacheUtil.getResult(finderClassName,
296 finderMethodName, finderParams, finderArgs, this);
297 }
298
299 if (result == null) {
300 Session session = null;
301
302 try {
303 session = openSession();
304
305 StringBuilder query = new StringBuilder();
306
307 query.append(
308 "FROM com.liferay.portlet.documentlibrary.model.DLFileShortcut WHERE ");
309
310 if (uuid == null) {
311 query.append("uuid_ IS NULL");
312 }
313 else {
314 query.append("uuid_ = ?");
315 }
316
317 query.append(" ");
318
319 Query q = session.createQuery(query.toString());
320
321 QueryPos qPos = QueryPos.getInstance(q);
322
323 if (uuid != null) {
324 qPos.add(uuid);
325 }
326
327 List<DLFileShortcut> list = q.list();
328
329 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
330 finderClassName, finderMethodName, finderParams,
331 finderArgs, list);
332
333 return list;
334 }
335 catch (Exception e) {
336 throw processException(e);
337 }
338 finally {
339 closeSession(session);
340 }
341 }
342 else {
343 return (List<DLFileShortcut>)result;
344 }
345 }
346
347 public List<DLFileShortcut> findByUuid(String uuid, int start, int end)
348 throws SystemException {
349 return findByUuid(uuid, start, end, null);
350 }
351
352 public List<DLFileShortcut> findByUuid(String uuid, int start, int end,
353 OrderByComparator obc) throws SystemException {
354 boolean finderClassNameCacheEnabled = DLFileShortcutModelImpl.CACHE_ENABLED;
355 String finderClassName = DLFileShortcut.class.getName();
356 String finderMethodName = "findByUuid";
357 String[] finderParams = new String[] {
358 String.class.getName(),
359
360 "java.lang.Integer", "java.lang.Integer",
361 "com.liferay.portal.kernel.util.OrderByComparator"
362 };
363 Object[] finderArgs = new Object[] {
364 uuid,
365
366 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
367 };
368
369 Object result = null;
370
371 if (finderClassNameCacheEnabled) {
372 result = FinderCacheUtil.getResult(finderClassName,
373 finderMethodName, finderParams, finderArgs, this);
374 }
375
376 if (result == null) {
377 Session session = null;
378
379 try {
380 session = openSession();
381
382 StringBuilder query = new StringBuilder();
383
384 query.append(
385 "FROM com.liferay.portlet.documentlibrary.model.DLFileShortcut WHERE ");
386
387 if (uuid == null) {
388 query.append("uuid_ IS NULL");
389 }
390 else {
391 query.append("uuid_ = ?");
392 }
393
394 query.append(" ");
395
396 if (obc != null) {
397 query.append("ORDER BY ");
398 query.append(obc.getOrderBy());
399 }
400
401 Query q = session.createQuery(query.toString());
402
403 QueryPos qPos = QueryPos.getInstance(q);
404
405 if (uuid != null) {
406 qPos.add(uuid);
407 }
408
409 List<DLFileShortcut> list = (List<DLFileShortcut>)QueryUtil.list(q,
410 getDialect(), start, end);
411
412 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
413 finderClassName, finderMethodName, finderParams,
414 finderArgs, list);
415
416 return list;
417 }
418 catch (Exception e) {
419 throw processException(e);
420 }
421 finally {
422 closeSession(session);
423 }
424 }
425 else {
426 return (List<DLFileShortcut>)result;
427 }
428 }
429
430 public DLFileShortcut findByUuid_First(String uuid, OrderByComparator obc)
431 throws NoSuchFileShortcutException, SystemException {
432 List<DLFileShortcut> list = findByUuid(uuid, 0, 1, obc);
433
434 if (list.size() == 0) {
435 StringBuilder msg = new StringBuilder();
436
437 msg.append("No DLFileShortcut exists with the key {");
438
439 msg.append("uuid=" + uuid);
440
441 msg.append(StringPool.CLOSE_CURLY_BRACE);
442
443 throw new NoSuchFileShortcutException(msg.toString());
444 }
445 else {
446 return list.get(0);
447 }
448 }
449
450 public DLFileShortcut findByUuid_Last(String uuid, OrderByComparator obc)
451 throws NoSuchFileShortcutException, SystemException {
452 int count = countByUuid(uuid);
453
454 List<DLFileShortcut> list = findByUuid(uuid, count - 1, count, obc);
455
456 if (list.size() == 0) {
457 StringBuilder msg = new StringBuilder();
458
459 msg.append("No DLFileShortcut exists with the key {");
460
461 msg.append("uuid=" + uuid);
462
463 msg.append(StringPool.CLOSE_CURLY_BRACE);
464
465 throw new NoSuchFileShortcutException(msg.toString());
466 }
467 else {
468 return list.get(0);
469 }
470 }
471
472 public DLFileShortcut[] findByUuid_PrevAndNext(long fileShortcutId,
473 String uuid, OrderByComparator obc)
474 throws NoSuchFileShortcutException, SystemException {
475 DLFileShortcut dlFileShortcut = findByPrimaryKey(fileShortcutId);
476
477 int count = countByUuid(uuid);
478
479 Session session = null;
480
481 try {
482 session = openSession();
483
484 StringBuilder query = new StringBuilder();
485
486 query.append(
487 "FROM com.liferay.portlet.documentlibrary.model.DLFileShortcut WHERE ");
488
489 if (uuid == null) {
490 query.append("uuid_ IS NULL");
491 }
492 else {
493 query.append("uuid_ = ?");
494 }
495
496 query.append(" ");
497
498 if (obc != null) {
499 query.append("ORDER BY ");
500 query.append(obc.getOrderBy());
501 }
502
503 Query q = session.createQuery(query.toString());
504
505 QueryPos qPos = QueryPos.getInstance(q);
506
507 if (uuid != null) {
508 qPos.add(uuid);
509 }
510
511 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
512 dlFileShortcut);
513
514 DLFileShortcut[] array = new DLFileShortcutImpl[3];
515
516 array[0] = (DLFileShortcut)objArray[0];
517 array[1] = (DLFileShortcut)objArray[1];
518 array[2] = (DLFileShortcut)objArray[2];
519
520 return array;
521 }
522 catch (Exception e) {
523 throw processException(e);
524 }
525 finally {
526 closeSession(session);
527 }
528 }
529
530 public List<DLFileShortcut> findByFolderId(long folderId)
531 throws SystemException {
532 boolean finderClassNameCacheEnabled = DLFileShortcutModelImpl.CACHE_ENABLED;
533 String finderClassName = DLFileShortcut.class.getName();
534 String finderMethodName = "findByFolderId";
535 String[] finderParams = new String[] { Long.class.getName() };
536 Object[] finderArgs = new Object[] { new Long(folderId) };
537
538 Object result = null;
539
540 if (finderClassNameCacheEnabled) {
541 result = FinderCacheUtil.getResult(finderClassName,
542 finderMethodName, finderParams, finderArgs, this);
543 }
544
545 if (result == null) {
546 Session session = null;
547
548 try {
549 session = openSession();
550
551 StringBuilder query = new StringBuilder();
552
553 query.append(
554 "FROM com.liferay.portlet.documentlibrary.model.DLFileShortcut WHERE ");
555
556 query.append("folderId = ?");
557
558 query.append(" ");
559
560 Query q = session.createQuery(query.toString());
561
562 QueryPos qPos = QueryPos.getInstance(q);
563
564 qPos.add(folderId);
565
566 List<DLFileShortcut> list = q.list();
567
568 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
569 finderClassName, finderMethodName, finderParams,
570 finderArgs, list);
571
572 return list;
573 }
574 catch (Exception e) {
575 throw processException(e);
576 }
577 finally {
578 closeSession(session);
579 }
580 }
581 else {
582 return (List<DLFileShortcut>)result;
583 }
584 }
585
586 public List<DLFileShortcut> findByFolderId(long folderId, int start, int end)
587 throws SystemException {
588 return findByFolderId(folderId, start, end, null);
589 }
590
591 public List<DLFileShortcut> findByFolderId(long folderId, int start,
592 int end, OrderByComparator obc) throws SystemException {
593 boolean finderClassNameCacheEnabled = DLFileShortcutModelImpl.CACHE_ENABLED;
594 String finderClassName = DLFileShortcut.class.getName();
595 String finderMethodName = "findByFolderId";
596 String[] finderParams = new String[] {
597 Long.class.getName(),
598
599 "java.lang.Integer", "java.lang.Integer",
600 "com.liferay.portal.kernel.util.OrderByComparator"
601 };
602 Object[] finderArgs = new Object[] {
603 new Long(folderId),
604
605 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
606 };
607
608 Object result = null;
609
610 if (finderClassNameCacheEnabled) {
611 result = FinderCacheUtil.getResult(finderClassName,
612 finderMethodName, finderParams, finderArgs, this);
613 }
614
615 if (result == null) {
616 Session session = null;
617
618 try {
619 session = openSession();
620
621 StringBuilder query = new StringBuilder();
622
623 query.append(
624 "FROM com.liferay.portlet.documentlibrary.model.DLFileShortcut WHERE ");
625
626 query.append("folderId = ?");
627
628 query.append(" ");
629
630 if (obc != null) {
631 query.append("ORDER BY ");
632 query.append(obc.getOrderBy());
633 }
634
635 Query q = session.createQuery(query.toString());
636
637 QueryPos qPos = QueryPos.getInstance(q);
638
639 qPos.add(folderId);
640
641 List<DLFileShortcut> list = (List<DLFileShortcut>)QueryUtil.list(q,
642 getDialect(), start, end);
643
644 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
645 finderClassName, finderMethodName, finderParams,
646 finderArgs, list);
647
648 return list;
649 }
650 catch (Exception e) {
651 throw processException(e);
652 }
653 finally {
654 closeSession(session);
655 }
656 }
657 else {
658 return (List<DLFileShortcut>)result;
659 }
660 }
661
662 public DLFileShortcut findByFolderId_First(long folderId,
663 OrderByComparator obc)
664 throws NoSuchFileShortcutException, SystemException {
665 List<DLFileShortcut> list = findByFolderId(folderId, 0, 1, obc);
666
667 if (list.size() == 0) {
668 StringBuilder msg = new StringBuilder();
669
670 msg.append("No DLFileShortcut exists with the key {");
671
672 msg.append("folderId=" + folderId);
673
674 msg.append(StringPool.CLOSE_CURLY_BRACE);
675
676 throw new NoSuchFileShortcutException(msg.toString());
677 }
678 else {
679 return list.get(0);
680 }
681 }
682
683 public DLFileShortcut findByFolderId_Last(long folderId,
684 OrderByComparator obc)
685 throws NoSuchFileShortcutException, SystemException {
686 int count = countByFolderId(folderId);
687
688 List<DLFileShortcut> list = findByFolderId(folderId, count - 1, count,
689 obc);
690
691 if (list.size() == 0) {
692 StringBuilder msg = new StringBuilder();
693
694 msg.append("No DLFileShortcut exists with the key {");
695
696 msg.append("folderId=" + folderId);
697
698 msg.append(StringPool.CLOSE_CURLY_BRACE);
699
700 throw new NoSuchFileShortcutException(msg.toString());
701 }
702 else {
703 return list.get(0);
704 }
705 }
706
707 public DLFileShortcut[] findByFolderId_PrevAndNext(long fileShortcutId,
708 long folderId, OrderByComparator obc)
709 throws NoSuchFileShortcutException, SystemException {
710 DLFileShortcut dlFileShortcut = findByPrimaryKey(fileShortcutId);
711
712 int count = countByFolderId(folderId);
713
714 Session session = null;
715
716 try {
717 session = openSession();
718
719 StringBuilder query = new StringBuilder();
720
721 query.append(
722 "FROM com.liferay.portlet.documentlibrary.model.DLFileShortcut WHERE ");
723
724 query.append("folderId = ?");
725
726 query.append(" ");
727
728 if (obc != null) {
729 query.append("ORDER BY ");
730 query.append(obc.getOrderBy());
731 }
732
733 Query q = session.createQuery(query.toString());
734
735 QueryPos qPos = QueryPos.getInstance(q);
736
737 qPos.add(folderId);
738
739 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
740 dlFileShortcut);
741
742 DLFileShortcut[] array = new DLFileShortcutImpl[3];
743
744 array[0] = (DLFileShortcut)objArray[0];
745 array[1] = (DLFileShortcut)objArray[1];
746 array[2] = (DLFileShortcut)objArray[2];
747
748 return array;
749 }
750 catch (Exception e) {
751 throw processException(e);
752 }
753 finally {
754 closeSession(session);
755 }
756 }
757
758 public List<DLFileShortcut> findByTF_TN(long toFolderId, String toName)
759 throws SystemException {
760 boolean finderClassNameCacheEnabled = DLFileShortcutModelImpl.CACHE_ENABLED;
761 String finderClassName = DLFileShortcut.class.getName();
762 String finderMethodName = "findByTF_TN";
763 String[] finderParams = new String[] {
764 Long.class.getName(), String.class.getName()
765 };
766 Object[] finderArgs = new Object[] { new Long(toFolderId), toName };
767
768 Object result = null;
769
770 if (finderClassNameCacheEnabled) {
771 result = FinderCacheUtil.getResult(finderClassName,
772 finderMethodName, finderParams, finderArgs, this);
773 }
774
775 if (result == null) {
776 Session session = null;
777
778 try {
779 session = openSession();
780
781 StringBuilder query = new StringBuilder();
782
783 query.append(
784 "FROM com.liferay.portlet.documentlibrary.model.DLFileShortcut WHERE ");
785
786 query.append("toFolderId = ?");
787
788 query.append(" AND ");
789
790 if (toName == null) {
791 query.append("toName IS NULL");
792 }
793 else {
794 query.append("toName = ?");
795 }
796
797 query.append(" ");
798
799 Query q = session.createQuery(query.toString());
800
801 QueryPos qPos = QueryPos.getInstance(q);
802
803 qPos.add(toFolderId);
804
805 if (toName != null) {
806 qPos.add(toName);
807 }
808
809 List<DLFileShortcut> list = q.list();
810
811 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
812 finderClassName, finderMethodName, finderParams,
813 finderArgs, list);
814
815 return list;
816 }
817 catch (Exception e) {
818 throw processException(e);
819 }
820 finally {
821 closeSession(session);
822 }
823 }
824 else {
825 return (List<DLFileShortcut>)result;
826 }
827 }
828
829 public List<DLFileShortcut> findByTF_TN(long toFolderId, String toName,
830 int start, int end) throws SystemException {
831 return findByTF_TN(toFolderId, toName, start, end, null);
832 }
833
834 public List<DLFileShortcut> findByTF_TN(long toFolderId, String toName,
835 int start, int end, OrderByComparator obc) throws SystemException {
836 boolean finderClassNameCacheEnabled = DLFileShortcutModelImpl.CACHE_ENABLED;
837 String finderClassName = DLFileShortcut.class.getName();
838 String finderMethodName = "findByTF_TN";
839 String[] finderParams = new String[] {
840 Long.class.getName(), String.class.getName(),
841
842 "java.lang.Integer", "java.lang.Integer",
843 "com.liferay.portal.kernel.util.OrderByComparator"
844 };
845 Object[] finderArgs = new Object[] {
846 new Long(toFolderId),
847
848 toName,
849
850 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
851 };
852
853 Object result = null;
854
855 if (finderClassNameCacheEnabled) {
856 result = FinderCacheUtil.getResult(finderClassName,
857 finderMethodName, finderParams, finderArgs, this);
858 }
859
860 if (result == null) {
861 Session session = null;
862
863 try {
864 session = openSession();
865
866 StringBuilder query = new StringBuilder();
867
868 query.append(
869 "FROM com.liferay.portlet.documentlibrary.model.DLFileShortcut WHERE ");
870
871 query.append("toFolderId = ?");
872
873 query.append(" AND ");
874
875 if (toName == null) {
876 query.append("toName IS NULL");
877 }
878 else {
879 query.append("toName = ?");
880 }
881
882 query.append(" ");
883
884 if (obc != null) {
885 query.append("ORDER BY ");
886 query.append(obc.getOrderBy());
887 }
888
889 Query q = session.createQuery(query.toString());
890
891 QueryPos qPos = QueryPos.getInstance(q);
892
893 qPos.add(toFolderId);
894
895 if (toName != null) {
896 qPos.add(toName);
897 }
898
899 List<DLFileShortcut> list = (List<DLFileShortcut>)QueryUtil.list(q,
900 getDialect(), start, end);
901
902 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
903 finderClassName, finderMethodName, finderParams,
904 finderArgs, list);
905
906 return list;
907 }
908 catch (Exception e) {
909 throw processException(e);
910 }
911 finally {
912 closeSession(session);
913 }
914 }
915 else {
916 return (List<DLFileShortcut>)result;
917 }
918 }
919
920 public DLFileShortcut findByTF_TN_First(long toFolderId, String toName,
921 OrderByComparator obc)
922 throws NoSuchFileShortcutException, SystemException {
923 List<DLFileShortcut> list = findByTF_TN(toFolderId, toName, 0, 1, obc);
924
925 if (list.size() == 0) {
926 StringBuilder msg = new StringBuilder();
927
928 msg.append("No DLFileShortcut exists with the key {");
929
930 msg.append("toFolderId=" + toFolderId);
931
932 msg.append(", ");
933 msg.append("toName=" + toName);
934
935 msg.append(StringPool.CLOSE_CURLY_BRACE);
936
937 throw new NoSuchFileShortcutException(msg.toString());
938 }
939 else {
940 return list.get(0);
941 }
942 }
943
944 public DLFileShortcut findByTF_TN_Last(long toFolderId, String toName,
945 OrderByComparator obc)
946 throws NoSuchFileShortcutException, SystemException {
947 int count = countByTF_TN(toFolderId, toName);
948
949 List<DLFileShortcut> list = findByTF_TN(toFolderId, toName, count - 1,
950 count, obc);
951
952 if (list.size() == 0) {
953 StringBuilder msg = new StringBuilder();
954
955 msg.append("No DLFileShortcut exists with the key {");
956
957 msg.append("toFolderId=" + toFolderId);
958
959 msg.append(", ");
960 msg.append("toName=" + toName);
961
962 msg.append(StringPool.CLOSE_CURLY_BRACE);
963
964 throw new NoSuchFileShortcutException(msg.toString());
965 }
966 else {
967 return list.get(0);
968 }
969 }
970
971 public DLFileShortcut[] findByTF_TN_PrevAndNext(long fileShortcutId,
972 long toFolderId, String toName, OrderByComparator obc)
973 throws NoSuchFileShortcutException, SystemException {
974 DLFileShortcut dlFileShortcut = findByPrimaryKey(fileShortcutId);
975
976 int count = countByTF_TN(toFolderId, toName);
977
978 Session session = null;
979
980 try {
981 session = openSession();
982
983 StringBuilder query = new StringBuilder();
984
985 query.append(
986 "FROM com.liferay.portlet.documentlibrary.model.DLFileShortcut WHERE ");
987
988 query.append("toFolderId = ?");
989
990 query.append(" AND ");
991
992 if (toName == null) {
993 query.append("toName IS NULL");
994 }
995 else {
996 query.append("toName = ?");
997 }
998
999 query.append(" ");
1000
1001 if (obc != null) {
1002 query.append("ORDER BY ");
1003 query.append(obc.getOrderBy());
1004 }
1005
1006 Query q = session.createQuery(query.toString());
1007
1008 QueryPos qPos = QueryPos.getInstance(q);
1009
1010 qPos.add(toFolderId);
1011
1012 if (toName != null) {
1013 qPos.add(toName);
1014 }
1015
1016 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
1017 dlFileShortcut);
1018
1019 DLFileShortcut[] array = new DLFileShortcutImpl[3];
1020
1021 array[0] = (DLFileShortcut)objArray[0];
1022 array[1] = (DLFileShortcut)objArray[1];
1023 array[2] = (DLFileShortcut)objArray[2];
1024
1025 return array;
1026 }
1027 catch (Exception e) {
1028 throw processException(e);
1029 }
1030 finally {
1031 closeSession(session);
1032 }
1033 }
1034
1035 public List<Object> findWithDynamicQuery(DynamicQuery dynamicQuery)
1036 throws SystemException {
1037 Session session = null;
1038
1039 try {
1040 session = openSession();
1041
1042 dynamicQuery.compile(session);
1043
1044 return dynamicQuery.list();
1045 }
1046 catch (Exception e) {
1047 throw processException(e);
1048 }
1049 finally {
1050 closeSession(session);
1051 }
1052 }
1053
1054 public List<Object> findWithDynamicQuery(DynamicQuery dynamicQuery,
1055 int start, int end) throws SystemException {
1056 Session session = null;
1057
1058 try {
1059 session = openSession();
1060
1061 dynamicQuery.setLimit(start, end);
1062
1063 dynamicQuery.compile(session);
1064
1065 return dynamicQuery.list();
1066 }
1067 catch (Exception e) {
1068 throw processException(e);
1069 }
1070 finally {
1071 closeSession(session);
1072 }
1073 }
1074
1075 public List<DLFileShortcut> findAll() throws SystemException {
1076 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1077 }
1078
1079 public List<DLFileShortcut> findAll(int start, int end)
1080 throws SystemException {
1081 return findAll(start, end, null);
1082 }
1083
1084 public List<DLFileShortcut> findAll(int start, int end,
1085 OrderByComparator obc) throws SystemException {
1086 boolean finderClassNameCacheEnabled = DLFileShortcutModelImpl.CACHE_ENABLED;
1087 String finderClassName = DLFileShortcut.class.getName();
1088 String finderMethodName = "findAll";
1089 String[] finderParams = new String[] {
1090 "java.lang.Integer", "java.lang.Integer",
1091 "com.liferay.portal.kernel.util.OrderByComparator"
1092 };
1093 Object[] finderArgs = new Object[] {
1094 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
1095 };
1096
1097 Object result = null;
1098
1099 if (finderClassNameCacheEnabled) {
1100 result = FinderCacheUtil.getResult(finderClassName,
1101 finderMethodName, finderParams, finderArgs, this);
1102 }
1103
1104 if (result == null) {
1105 Session session = null;
1106
1107 try {
1108 session = openSession();
1109
1110 StringBuilder query = new StringBuilder();
1111
1112 query.append(
1113 "FROM com.liferay.portlet.documentlibrary.model.DLFileShortcut ");
1114
1115 if (obc != null) {
1116 query.append("ORDER BY ");
1117 query.append(obc.getOrderBy());
1118 }
1119
1120 Query q = session.createQuery(query.toString());
1121
1122 List<DLFileShortcut> list = (List<DLFileShortcut>)QueryUtil.list(q,
1123 getDialect(), start, end);
1124
1125 if (obc == null) {
1126 Collections.sort(list);
1127 }
1128
1129 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
1130 finderClassName, finderMethodName, finderParams,
1131 finderArgs, list);
1132
1133 return list;
1134 }
1135 catch (Exception e) {
1136 throw processException(e);
1137 }
1138 finally {
1139 closeSession(session);
1140 }
1141 }
1142 else {
1143 return (List<DLFileShortcut>)result;
1144 }
1145 }
1146
1147 public void removeByUuid(String uuid) throws SystemException {
1148 for (DLFileShortcut dlFileShortcut : findByUuid(uuid)) {
1149 remove(dlFileShortcut);
1150 }
1151 }
1152
1153 public void removeByFolderId(long folderId) throws SystemException {
1154 for (DLFileShortcut dlFileShortcut : findByFolderId(folderId)) {
1155 remove(dlFileShortcut);
1156 }
1157 }
1158
1159 public void removeByTF_TN(long toFolderId, String toName)
1160 throws SystemException {
1161 for (DLFileShortcut dlFileShortcut : findByTF_TN(toFolderId, toName)) {
1162 remove(dlFileShortcut);
1163 }
1164 }
1165
1166 public void removeAll() throws SystemException {
1167 for (DLFileShortcut dlFileShortcut : findAll()) {
1168 remove(dlFileShortcut);
1169 }
1170 }
1171
1172 public int countByUuid(String uuid) throws SystemException {
1173 boolean finderClassNameCacheEnabled = DLFileShortcutModelImpl.CACHE_ENABLED;
1174 String finderClassName = DLFileShortcut.class.getName();
1175 String finderMethodName = "countByUuid";
1176 String[] finderParams = new String[] { String.class.getName() };
1177 Object[] finderArgs = new Object[] { uuid };
1178
1179 Object result = null;
1180
1181 if (finderClassNameCacheEnabled) {
1182 result = FinderCacheUtil.getResult(finderClassName,
1183 finderMethodName, finderParams, finderArgs, this);
1184 }
1185
1186 if (result == null) {
1187 Session session = null;
1188
1189 try {
1190 session = openSession();
1191
1192 StringBuilder query = new StringBuilder();
1193
1194 query.append("SELECT COUNT(*) ");
1195 query.append(
1196 "FROM com.liferay.portlet.documentlibrary.model.DLFileShortcut WHERE ");
1197
1198 if (uuid == null) {
1199 query.append("uuid_ IS NULL");
1200 }
1201 else {
1202 query.append("uuid_ = ?");
1203 }
1204
1205 query.append(" ");
1206
1207 Query q = session.createQuery(query.toString());
1208
1209 QueryPos qPos = QueryPos.getInstance(q);
1210
1211 if (uuid != null) {
1212 qPos.add(uuid);
1213 }
1214
1215 Long count = null;
1216
1217 Iterator<Long> itr = q.list().iterator();
1218
1219 if (itr.hasNext()) {
1220 count = itr.next();
1221 }
1222
1223 if (count == null) {
1224 count = new Long(0);
1225 }
1226
1227 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
1228 finderClassName, finderMethodName, finderParams,
1229 finderArgs, count);
1230
1231 return count.intValue();
1232 }
1233 catch (Exception e) {
1234 throw processException(e);
1235 }
1236 finally {
1237 closeSession(session);
1238 }
1239 }
1240 else {
1241 return ((Long)result).intValue();
1242 }
1243 }
1244
1245 public int countByFolderId(long folderId) throws SystemException {
1246 boolean finderClassNameCacheEnabled = DLFileShortcutModelImpl.CACHE_ENABLED;
1247 String finderClassName = DLFileShortcut.class.getName();
1248 String finderMethodName = "countByFolderId";
1249 String[] finderParams = new String[] { Long.class.getName() };
1250 Object[] finderArgs = new Object[] { new Long(folderId) };
1251
1252 Object result = null;
1253
1254 if (finderClassNameCacheEnabled) {
1255 result = FinderCacheUtil.getResult(finderClassName,
1256 finderMethodName, finderParams, finderArgs, this);
1257 }
1258
1259 if (result == null) {
1260 Session session = null;
1261
1262 try {
1263 session = openSession();
1264
1265 StringBuilder query = new StringBuilder();
1266
1267 query.append("SELECT COUNT(*) ");
1268 query.append(
1269 "FROM com.liferay.portlet.documentlibrary.model.DLFileShortcut WHERE ");
1270
1271 query.append("folderId = ?");
1272
1273 query.append(" ");
1274
1275 Query q = session.createQuery(query.toString());
1276
1277 QueryPos qPos = QueryPos.getInstance(q);
1278
1279 qPos.add(folderId);
1280
1281 Long count = null;
1282
1283 Iterator<Long> itr = q.list().iterator();
1284
1285 if (itr.hasNext()) {
1286 count = itr.next();
1287 }
1288
1289 if (count == null) {
1290 count = new Long(0);
1291 }
1292
1293 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
1294 finderClassName, finderMethodName, finderParams,
1295 finderArgs, count);
1296
1297 return count.intValue();
1298 }
1299 catch (Exception e) {
1300 throw processException(e);
1301 }
1302 finally {
1303 closeSession(session);
1304 }
1305 }
1306 else {
1307 return ((Long)result).intValue();
1308 }
1309 }
1310
1311 public int countByTF_TN(long toFolderId, String toName)
1312 throws SystemException {
1313 boolean finderClassNameCacheEnabled = DLFileShortcutModelImpl.CACHE_ENABLED;
1314 String finderClassName = DLFileShortcut.class.getName();
1315 String finderMethodName = "countByTF_TN";
1316 String[] finderParams = new String[] {
1317 Long.class.getName(), String.class.getName()
1318 };
1319 Object[] finderArgs = new Object[] { new Long(toFolderId), toName };
1320
1321 Object result = null;
1322
1323 if (finderClassNameCacheEnabled) {
1324 result = FinderCacheUtil.getResult(finderClassName,
1325 finderMethodName, finderParams, finderArgs, this);
1326 }
1327
1328 if (result == null) {
1329 Session session = null;
1330
1331 try {
1332 session = openSession();
1333
1334 StringBuilder query = new StringBuilder();
1335
1336 query.append("SELECT COUNT(*) ");
1337 query.append(
1338 "FROM com.liferay.portlet.documentlibrary.model.DLFileShortcut WHERE ");
1339
1340 query.append("toFolderId = ?");
1341
1342 query.append(" AND ");
1343
1344 if (toName == null) {
1345 query.append("toName IS NULL");
1346 }
1347 else {
1348 query.append("toName = ?");
1349 }
1350
1351 query.append(" ");
1352
1353 Query q = session.createQuery(query.toString());
1354
1355 QueryPos qPos = QueryPos.getInstance(q);
1356
1357 qPos.add(toFolderId);
1358
1359 if (toName != null) {
1360 qPos.add(toName);
1361 }
1362
1363 Long count = null;
1364
1365 Iterator<Long> itr = q.list().iterator();
1366
1367 if (itr.hasNext()) {
1368 count = itr.next();
1369 }
1370
1371 if (count == null) {
1372 count = new Long(0);
1373 }
1374
1375 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
1376 finderClassName, finderMethodName, finderParams,
1377 finderArgs, count);
1378
1379 return count.intValue();
1380 }
1381 catch (Exception e) {
1382 throw processException(e);
1383 }
1384 finally {
1385 closeSession(session);
1386 }
1387 }
1388 else {
1389 return ((Long)result).intValue();
1390 }
1391 }
1392
1393 public int countAll() throws SystemException {
1394 boolean finderClassNameCacheEnabled = DLFileShortcutModelImpl.CACHE_ENABLED;
1395 String finderClassName = DLFileShortcut.class.getName();
1396 String finderMethodName = "countAll";
1397 String[] finderParams = new String[] { };
1398 Object[] finderArgs = new Object[] { };
1399
1400 Object result = null;
1401
1402 if (finderClassNameCacheEnabled) {
1403 result = FinderCacheUtil.getResult(finderClassName,
1404 finderMethodName, finderParams, finderArgs, this);
1405 }
1406
1407 if (result == null) {
1408 Session session = null;
1409
1410 try {
1411 session = openSession();
1412
1413 Query q = session.createQuery(
1414 "SELECT COUNT(*) FROM com.liferay.portlet.documentlibrary.model.DLFileShortcut");
1415
1416 Long count = null;
1417
1418 Iterator<Long> itr = q.list().iterator();
1419
1420 if (itr.hasNext()) {
1421 count = itr.next();
1422 }
1423
1424 if (count == null) {
1425 count = new Long(0);
1426 }
1427
1428 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
1429 finderClassName, finderMethodName, finderParams,
1430 finderArgs, count);
1431
1432 return count.intValue();
1433 }
1434 catch (Exception e) {
1435 throw processException(e);
1436 }
1437 finally {
1438 closeSession(session);
1439 }
1440 }
1441 else {
1442 return ((Long)result).intValue();
1443 }
1444 }
1445
1446 public void registerListener(ModelListener listener) {
1447 List<ModelListener> listeners = ListUtil.fromArray(_listeners);
1448
1449 listeners.add(listener);
1450
1451 _listeners = listeners.toArray(new ModelListener[listeners.size()]);
1452 }
1453
1454 public void unregisterListener(ModelListener listener) {
1455 List<ModelListener> listeners = ListUtil.fromArray(_listeners);
1456
1457 listeners.remove(listener);
1458
1459 _listeners = listeners.toArray(new ModelListener[listeners.size()]);
1460 }
1461
1462 public void afterPropertiesSet() {
1463 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
1464 com.liferay.portal.util.PropsUtil.get(
1465 "value.object.listener.com.liferay.portlet.documentlibrary.model.DLFileShortcut")));
1466
1467 if (listenerClassNames.length > 0) {
1468 try {
1469 List<ModelListener> listeners = new ArrayList<ModelListener>();
1470
1471 for (String listenerClassName : listenerClassNames) {
1472 listeners.add((ModelListener)Class.forName(
1473 listenerClassName).newInstance());
1474 }
1475
1476 _listeners = listeners.toArray(new ModelListener[listeners.size()]);
1477 }
1478 catch (Exception e) {
1479 _log.error(e);
1480 }
1481 }
1482 }
1483
1484 private static Log _log = LogFactory.getLog(DLFileShortcutPersistenceImpl.class);
1485 private ModelListener[] _listeners = new ModelListener[0];
1486}