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