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 "SELECT dlFileShortcut FROM DLFileShortcut dlFileShortcut WHERE ");
445
446 if (uuid == null) {
447 query.append("dlFileShortcut.uuid IS NULL");
448 }
449 else {
450 query.append("dlFileShortcut.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 "SELECT dlFileShortcut FROM DLFileShortcut dlFileShortcut WHERE ");
511
512 if (uuid == null) {
513 query.append("dlFileShortcut.uuid IS NULL");
514 }
515 else {
516 query.append("dlFileShortcut.uuid = ?");
517 }
518
519 query.append(" ");
520
521 if (obc != null) {
522 query.append("ORDER BY ");
523
524 String[] orderByFields = obc.getOrderByFields();
525
526 for (int i = 0; i < orderByFields.length; i++) {
527 query.append("dlFileShortcut.");
528 query.append(orderByFields[i]);
529
530 if (obc.isAscending()) {
531 query.append(" ASC");
532 }
533 else {
534 query.append(" DESC");
535 }
536
537 if ((i + 1) < orderByFields.length) {
538 query.append(", ");
539 }
540 }
541 }
542
543 Query q = session.createQuery(query.toString());
544
545 QueryPos qPos = QueryPos.getInstance(q);
546
547 if (uuid != null) {
548 qPos.add(uuid);
549 }
550
551 list = (List<DLFileShortcut>)QueryUtil.list(q, getDialect(),
552 start, end);
553 }
554 catch (Exception e) {
555 throw processException(e);
556 }
557 finally {
558 if (list == null) {
559 list = new ArrayList<DLFileShortcut>();
560 }
561
562 cacheResult(list);
563
564 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_UUID,
565 finderArgs, list);
566
567 closeSession(session);
568 }
569 }
570
571 return list;
572 }
573
574 public DLFileShortcut findByUuid_First(String uuid, OrderByComparator obc)
575 throws NoSuchFileShortcutException, SystemException {
576 List<DLFileShortcut> list = findByUuid(uuid, 0, 1, obc);
577
578 if (list.isEmpty()) {
579 StringBuilder msg = new StringBuilder();
580
581 msg.append("No DLFileShortcut exists with the key {");
582
583 msg.append("uuid=" + uuid);
584
585 msg.append(StringPool.CLOSE_CURLY_BRACE);
586
587 throw new NoSuchFileShortcutException(msg.toString());
588 }
589 else {
590 return list.get(0);
591 }
592 }
593
594 public DLFileShortcut findByUuid_Last(String uuid, OrderByComparator obc)
595 throws NoSuchFileShortcutException, SystemException {
596 int count = countByUuid(uuid);
597
598 List<DLFileShortcut> list = findByUuid(uuid, count - 1, count, obc);
599
600 if (list.isEmpty()) {
601 StringBuilder msg = new StringBuilder();
602
603 msg.append("No DLFileShortcut exists with the key {");
604
605 msg.append("uuid=" + uuid);
606
607 msg.append(StringPool.CLOSE_CURLY_BRACE);
608
609 throw new NoSuchFileShortcutException(msg.toString());
610 }
611 else {
612 return list.get(0);
613 }
614 }
615
616 public DLFileShortcut[] findByUuid_PrevAndNext(long fileShortcutId,
617 String uuid, OrderByComparator obc)
618 throws NoSuchFileShortcutException, SystemException {
619 DLFileShortcut dlFileShortcut = findByPrimaryKey(fileShortcutId);
620
621 int count = countByUuid(uuid);
622
623 Session session = null;
624
625 try {
626 session = openSession();
627
628 StringBuilder query = new StringBuilder();
629
630 query.append(
631 "SELECT dlFileShortcut FROM DLFileShortcut dlFileShortcut WHERE ");
632
633 if (uuid == null) {
634 query.append("dlFileShortcut.uuid IS NULL");
635 }
636 else {
637 query.append("dlFileShortcut.uuid = ?");
638 }
639
640 query.append(" ");
641
642 if (obc != null) {
643 query.append("ORDER BY ");
644
645 String[] orderByFields = obc.getOrderByFields();
646
647 for (int i = 0; i < orderByFields.length; i++) {
648 query.append("dlFileShortcut.");
649 query.append(orderByFields[i]);
650
651 if (obc.isAscending()) {
652 query.append(" ASC");
653 }
654 else {
655 query.append(" DESC");
656 }
657
658 if ((i + 1) < orderByFields.length) {
659 query.append(", ");
660 }
661 }
662 }
663
664 Query q = session.createQuery(query.toString());
665
666 QueryPos qPos = QueryPos.getInstance(q);
667
668 if (uuid != null) {
669 qPos.add(uuid);
670 }
671
672 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
673 dlFileShortcut);
674
675 DLFileShortcut[] array = new DLFileShortcutImpl[3];
676
677 array[0] = (DLFileShortcut)objArray[0];
678 array[1] = (DLFileShortcut)objArray[1];
679 array[2] = (DLFileShortcut)objArray[2];
680
681 return array;
682 }
683 catch (Exception e) {
684 throw processException(e);
685 }
686 finally {
687 closeSession(session);
688 }
689 }
690
691 public DLFileShortcut findByUUID_G(String uuid, long groupId)
692 throws NoSuchFileShortcutException, SystemException {
693 DLFileShortcut dlFileShortcut = fetchByUUID_G(uuid, groupId);
694
695 if (dlFileShortcut == null) {
696 StringBuilder msg = new StringBuilder();
697
698 msg.append("No DLFileShortcut exists with the key {");
699
700 msg.append("uuid=" + uuid);
701
702 msg.append(", ");
703 msg.append("groupId=" + groupId);
704
705 msg.append(StringPool.CLOSE_CURLY_BRACE);
706
707 if (_log.isWarnEnabled()) {
708 _log.warn(msg.toString());
709 }
710
711 throw new NoSuchFileShortcutException(msg.toString());
712 }
713
714 return dlFileShortcut;
715 }
716
717 public DLFileShortcut fetchByUUID_G(String uuid, long groupId)
718 throws SystemException {
719 return fetchByUUID_G(uuid, groupId, true);
720 }
721
722 public DLFileShortcut fetchByUUID_G(String uuid, long groupId,
723 boolean retrieveFromCache) throws SystemException {
724 Object[] finderArgs = new Object[] { uuid, new Long(groupId) };
725
726 Object result = null;
727
728 if (retrieveFromCache) {
729 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_UUID_G,
730 finderArgs, this);
731 }
732
733 if (result == null) {
734 Session session = null;
735
736 try {
737 session = openSession();
738
739 StringBuilder query = new StringBuilder();
740
741 query.append(
742 "SELECT dlFileShortcut FROM DLFileShortcut dlFileShortcut WHERE ");
743
744 if (uuid == null) {
745 query.append("dlFileShortcut.uuid IS NULL");
746 }
747 else {
748 query.append("dlFileShortcut.uuid = ?");
749 }
750
751 query.append(" AND ");
752
753 query.append("dlFileShortcut.groupId = ?");
754
755 query.append(" ");
756
757 Query q = session.createQuery(query.toString());
758
759 QueryPos qPos = QueryPos.getInstance(q);
760
761 if (uuid != null) {
762 qPos.add(uuid);
763 }
764
765 qPos.add(groupId);
766
767 List<DLFileShortcut> list = q.list();
768
769 result = list;
770
771 DLFileShortcut dlFileShortcut = null;
772
773 if (list.isEmpty()) {
774 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
775 finderArgs, list);
776 }
777 else {
778 dlFileShortcut = list.get(0);
779
780 cacheResult(dlFileShortcut);
781
782 if ((dlFileShortcut.getUuid() == null) ||
783 !dlFileShortcut.getUuid().equals(uuid) ||
784 (dlFileShortcut.getGroupId() != groupId)) {
785 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
786 finderArgs, dlFileShortcut);
787 }
788 }
789
790 return dlFileShortcut;
791 }
792 catch (Exception e) {
793 throw processException(e);
794 }
795 finally {
796 if (result == null) {
797 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
798 finderArgs, new ArrayList<DLFileShortcut>());
799 }
800
801 closeSession(session);
802 }
803 }
804 else {
805 if (result instanceof List) {
806 return null;
807 }
808 else {
809 return (DLFileShortcut)result;
810 }
811 }
812 }
813
814 public List<DLFileShortcut> findByFolderId(long folderId)
815 throws SystemException {
816 Object[] finderArgs = new Object[] { new Long(folderId) };
817
818 List<DLFileShortcut> list = (List<DLFileShortcut>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_FOLDERID,
819 finderArgs, this);
820
821 if (list == null) {
822 Session session = null;
823
824 try {
825 session = openSession();
826
827 StringBuilder query = new StringBuilder();
828
829 query.append(
830 "SELECT dlFileShortcut FROM DLFileShortcut dlFileShortcut WHERE ");
831
832 query.append("dlFileShortcut.folderId = ?");
833
834 query.append(" ");
835
836 Query q = session.createQuery(query.toString());
837
838 QueryPos qPos = QueryPos.getInstance(q);
839
840 qPos.add(folderId);
841
842 list = q.list();
843 }
844 catch (Exception e) {
845 throw processException(e);
846 }
847 finally {
848 if (list == null) {
849 list = new ArrayList<DLFileShortcut>();
850 }
851
852 cacheResult(list);
853
854 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_FOLDERID,
855 finderArgs, list);
856
857 closeSession(session);
858 }
859 }
860
861 return list;
862 }
863
864 public List<DLFileShortcut> findByFolderId(long folderId, int start, int end)
865 throws SystemException {
866 return findByFolderId(folderId, start, end, null);
867 }
868
869 public List<DLFileShortcut> findByFolderId(long folderId, int start,
870 int end, OrderByComparator obc) throws SystemException {
871 Object[] finderArgs = new Object[] {
872 new Long(folderId),
873
874 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
875 };
876
877 List<DLFileShortcut> list = (List<DLFileShortcut>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_FOLDERID,
878 finderArgs, this);
879
880 if (list == null) {
881 Session session = null;
882
883 try {
884 session = openSession();
885
886 StringBuilder query = new StringBuilder();
887
888 query.append(
889 "SELECT dlFileShortcut FROM DLFileShortcut dlFileShortcut WHERE ");
890
891 query.append("dlFileShortcut.folderId = ?");
892
893 query.append(" ");
894
895 if (obc != null) {
896 query.append("ORDER BY ");
897
898 String[] orderByFields = obc.getOrderByFields();
899
900 for (int i = 0; i < orderByFields.length; i++) {
901 query.append("dlFileShortcut.");
902 query.append(orderByFields[i]);
903
904 if (obc.isAscending()) {
905 query.append(" ASC");
906 }
907 else {
908 query.append(" DESC");
909 }
910
911 if ((i + 1) < orderByFields.length) {
912 query.append(", ");
913 }
914 }
915 }
916
917 Query q = session.createQuery(query.toString());
918
919 QueryPos qPos = QueryPos.getInstance(q);
920
921 qPos.add(folderId);
922
923 list = (List<DLFileShortcut>)QueryUtil.list(q, getDialect(),
924 start, end);
925 }
926 catch (Exception e) {
927 throw processException(e);
928 }
929 finally {
930 if (list == null) {
931 list = new ArrayList<DLFileShortcut>();
932 }
933
934 cacheResult(list);
935
936 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_FOLDERID,
937 finderArgs, list);
938
939 closeSession(session);
940 }
941 }
942
943 return list;
944 }
945
946 public DLFileShortcut findByFolderId_First(long folderId,
947 OrderByComparator obc)
948 throws NoSuchFileShortcutException, SystemException {
949 List<DLFileShortcut> list = findByFolderId(folderId, 0, 1, obc);
950
951 if (list.isEmpty()) {
952 StringBuilder msg = new StringBuilder();
953
954 msg.append("No DLFileShortcut exists with the key {");
955
956 msg.append("folderId=" + folderId);
957
958 msg.append(StringPool.CLOSE_CURLY_BRACE);
959
960 throw new NoSuchFileShortcutException(msg.toString());
961 }
962 else {
963 return list.get(0);
964 }
965 }
966
967 public DLFileShortcut findByFolderId_Last(long folderId,
968 OrderByComparator obc)
969 throws NoSuchFileShortcutException, SystemException {
970 int count = countByFolderId(folderId);
971
972 List<DLFileShortcut> list = findByFolderId(folderId, count - 1, count,
973 obc);
974
975 if (list.isEmpty()) {
976 StringBuilder msg = new StringBuilder();
977
978 msg.append("No DLFileShortcut exists with the key {");
979
980 msg.append("folderId=" + folderId);
981
982 msg.append(StringPool.CLOSE_CURLY_BRACE);
983
984 throw new NoSuchFileShortcutException(msg.toString());
985 }
986 else {
987 return list.get(0);
988 }
989 }
990
991 public DLFileShortcut[] findByFolderId_PrevAndNext(long fileShortcutId,
992 long folderId, OrderByComparator obc)
993 throws NoSuchFileShortcutException, SystemException {
994 DLFileShortcut dlFileShortcut = findByPrimaryKey(fileShortcutId);
995
996 int count = countByFolderId(folderId);
997
998 Session session = null;
999
1000 try {
1001 session = openSession();
1002
1003 StringBuilder query = new StringBuilder();
1004
1005 query.append(
1006 "SELECT dlFileShortcut FROM DLFileShortcut dlFileShortcut WHERE ");
1007
1008 query.append("dlFileShortcut.folderId = ?");
1009
1010 query.append(" ");
1011
1012 if (obc != null) {
1013 query.append("ORDER BY ");
1014
1015 String[] orderByFields = obc.getOrderByFields();
1016
1017 for (int i = 0; i < orderByFields.length; i++) {
1018 query.append("dlFileShortcut.");
1019 query.append(orderByFields[i]);
1020
1021 if (obc.isAscending()) {
1022 query.append(" ASC");
1023 }
1024 else {
1025 query.append(" DESC");
1026 }
1027
1028 if ((i + 1) < orderByFields.length) {
1029 query.append(", ");
1030 }
1031 }
1032 }
1033
1034 Query q = session.createQuery(query.toString());
1035
1036 QueryPos qPos = QueryPos.getInstance(q);
1037
1038 qPos.add(folderId);
1039
1040 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
1041 dlFileShortcut);
1042
1043 DLFileShortcut[] array = new DLFileShortcutImpl[3];
1044
1045 array[0] = (DLFileShortcut)objArray[0];
1046 array[1] = (DLFileShortcut)objArray[1];
1047 array[2] = (DLFileShortcut)objArray[2];
1048
1049 return array;
1050 }
1051 catch (Exception e) {
1052 throw processException(e);
1053 }
1054 finally {
1055 closeSession(session);
1056 }
1057 }
1058
1059 public List<DLFileShortcut> findByTF_TN(long toFolderId, String toName)
1060 throws SystemException {
1061 Object[] finderArgs = new Object[] { new Long(toFolderId), toName };
1062
1063 List<DLFileShortcut> list = (List<DLFileShortcut>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_TF_TN,
1064 finderArgs, this);
1065
1066 if (list == null) {
1067 Session session = null;
1068
1069 try {
1070 session = openSession();
1071
1072 StringBuilder query = new StringBuilder();
1073
1074 query.append(
1075 "SELECT dlFileShortcut FROM DLFileShortcut dlFileShortcut WHERE ");
1076
1077 query.append("dlFileShortcut.toFolderId = ?");
1078
1079 query.append(" AND ");
1080
1081 if (toName == null) {
1082 query.append("dlFileShortcut.toName IS NULL");
1083 }
1084 else {
1085 query.append("dlFileShortcut.toName = ?");
1086 }
1087
1088 query.append(" ");
1089
1090 Query q = session.createQuery(query.toString());
1091
1092 QueryPos qPos = QueryPos.getInstance(q);
1093
1094 qPos.add(toFolderId);
1095
1096 if (toName != null) {
1097 qPos.add(toName);
1098 }
1099
1100 list = q.list();
1101 }
1102 catch (Exception e) {
1103 throw processException(e);
1104 }
1105 finally {
1106 if (list == null) {
1107 list = new ArrayList<DLFileShortcut>();
1108 }
1109
1110 cacheResult(list);
1111
1112 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_TF_TN,
1113 finderArgs, list);
1114
1115 closeSession(session);
1116 }
1117 }
1118
1119 return list;
1120 }
1121
1122 public List<DLFileShortcut> findByTF_TN(long toFolderId, String toName,
1123 int start, int end) throws SystemException {
1124 return findByTF_TN(toFolderId, toName, start, end, null);
1125 }
1126
1127 public List<DLFileShortcut> findByTF_TN(long toFolderId, String toName,
1128 int start, int end, OrderByComparator obc) throws SystemException {
1129 Object[] finderArgs = new Object[] {
1130 new Long(toFolderId),
1131
1132 toName,
1133
1134 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
1135 };
1136
1137 List<DLFileShortcut> list = (List<DLFileShortcut>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_TF_TN,
1138 finderArgs, this);
1139
1140 if (list == null) {
1141 Session session = null;
1142
1143 try {
1144 session = openSession();
1145
1146 StringBuilder query = new StringBuilder();
1147
1148 query.append(
1149 "SELECT dlFileShortcut FROM DLFileShortcut dlFileShortcut WHERE ");
1150
1151 query.append("dlFileShortcut.toFolderId = ?");
1152
1153 query.append(" AND ");
1154
1155 if (toName == null) {
1156 query.append("dlFileShortcut.toName IS NULL");
1157 }
1158 else {
1159 query.append("dlFileShortcut.toName = ?");
1160 }
1161
1162 query.append(" ");
1163
1164 if (obc != null) {
1165 query.append("ORDER BY ");
1166
1167 String[] orderByFields = obc.getOrderByFields();
1168
1169 for (int i = 0; i < orderByFields.length; i++) {
1170 query.append("dlFileShortcut.");
1171 query.append(orderByFields[i]);
1172
1173 if (obc.isAscending()) {
1174 query.append(" ASC");
1175 }
1176 else {
1177 query.append(" DESC");
1178 }
1179
1180 if ((i + 1) < orderByFields.length) {
1181 query.append(", ");
1182 }
1183 }
1184 }
1185
1186 Query q = session.createQuery(query.toString());
1187
1188 QueryPos qPos = QueryPos.getInstance(q);
1189
1190 qPos.add(toFolderId);
1191
1192 if (toName != null) {
1193 qPos.add(toName);
1194 }
1195
1196 list = (List<DLFileShortcut>)QueryUtil.list(q, getDialect(),
1197 start, end);
1198 }
1199 catch (Exception e) {
1200 throw processException(e);
1201 }
1202 finally {
1203 if (list == null) {
1204 list = new ArrayList<DLFileShortcut>();
1205 }
1206
1207 cacheResult(list);
1208
1209 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_TF_TN,
1210 finderArgs, list);
1211
1212 closeSession(session);
1213 }
1214 }
1215
1216 return list;
1217 }
1218
1219 public DLFileShortcut findByTF_TN_First(long toFolderId, String toName,
1220 OrderByComparator obc)
1221 throws NoSuchFileShortcutException, SystemException {
1222 List<DLFileShortcut> list = findByTF_TN(toFolderId, toName, 0, 1, obc);
1223
1224 if (list.isEmpty()) {
1225 StringBuilder msg = new StringBuilder();
1226
1227 msg.append("No DLFileShortcut exists with the key {");
1228
1229 msg.append("toFolderId=" + toFolderId);
1230
1231 msg.append(", ");
1232 msg.append("toName=" + toName);
1233
1234 msg.append(StringPool.CLOSE_CURLY_BRACE);
1235
1236 throw new NoSuchFileShortcutException(msg.toString());
1237 }
1238 else {
1239 return list.get(0);
1240 }
1241 }
1242
1243 public DLFileShortcut findByTF_TN_Last(long toFolderId, String toName,
1244 OrderByComparator obc)
1245 throws NoSuchFileShortcutException, SystemException {
1246 int count = countByTF_TN(toFolderId, toName);
1247
1248 List<DLFileShortcut> list = findByTF_TN(toFolderId, toName, count - 1,
1249 count, obc);
1250
1251 if (list.isEmpty()) {
1252 StringBuilder msg = new StringBuilder();
1253
1254 msg.append("No DLFileShortcut exists with the key {");
1255
1256 msg.append("toFolderId=" + toFolderId);
1257
1258 msg.append(", ");
1259 msg.append("toName=" + toName);
1260
1261 msg.append(StringPool.CLOSE_CURLY_BRACE);
1262
1263 throw new NoSuchFileShortcutException(msg.toString());
1264 }
1265 else {
1266 return list.get(0);
1267 }
1268 }
1269
1270 public DLFileShortcut[] findByTF_TN_PrevAndNext(long fileShortcutId,
1271 long toFolderId, String toName, OrderByComparator obc)
1272 throws NoSuchFileShortcutException, SystemException {
1273 DLFileShortcut dlFileShortcut = findByPrimaryKey(fileShortcutId);
1274
1275 int count = countByTF_TN(toFolderId, toName);
1276
1277 Session session = null;
1278
1279 try {
1280 session = openSession();
1281
1282 StringBuilder query = new StringBuilder();
1283
1284 query.append(
1285 "SELECT dlFileShortcut FROM DLFileShortcut dlFileShortcut WHERE ");
1286
1287 query.append("dlFileShortcut.toFolderId = ?");
1288
1289 query.append(" AND ");
1290
1291 if (toName == null) {
1292 query.append("dlFileShortcut.toName IS NULL");
1293 }
1294 else {
1295 query.append("dlFileShortcut.toName = ?");
1296 }
1297
1298 query.append(" ");
1299
1300 if (obc != null) {
1301 query.append("ORDER BY ");
1302
1303 String[] orderByFields = obc.getOrderByFields();
1304
1305 for (int i = 0; i < orderByFields.length; i++) {
1306 query.append("dlFileShortcut.");
1307 query.append(orderByFields[i]);
1308
1309 if (obc.isAscending()) {
1310 query.append(" ASC");
1311 }
1312 else {
1313 query.append(" DESC");
1314 }
1315
1316 if ((i + 1) < orderByFields.length) {
1317 query.append(", ");
1318 }
1319 }
1320 }
1321
1322 Query q = session.createQuery(query.toString());
1323
1324 QueryPos qPos = QueryPos.getInstance(q);
1325
1326 qPos.add(toFolderId);
1327
1328 if (toName != null) {
1329 qPos.add(toName);
1330 }
1331
1332 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
1333 dlFileShortcut);
1334
1335 DLFileShortcut[] array = new DLFileShortcutImpl[3];
1336
1337 array[0] = (DLFileShortcut)objArray[0];
1338 array[1] = (DLFileShortcut)objArray[1];
1339 array[2] = (DLFileShortcut)objArray[2];
1340
1341 return array;
1342 }
1343 catch (Exception e) {
1344 throw processException(e);
1345 }
1346 finally {
1347 closeSession(session);
1348 }
1349 }
1350
1351 public List<Object> findWithDynamicQuery(DynamicQuery dynamicQuery)
1352 throws SystemException {
1353 Session session = null;
1354
1355 try {
1356 session = openSession();
1357
1358 dynamicQuery.compile(session);
1359
1360 return dynamicQuery.list();
1361 }
1362 catch (Exception e) {
1363 throw processException(e);
1364 }
1365 finally {
1366 closeSession(session);
1367 }
1368 }
1369
1370 public List<Object> findWithDynamicQuery(DynamicQuery dynamicQuery,
1371 int start, int end) throws SystemException {
1372 Session session = null;
1373
1374 try {
1375 session = openSession();
1376
1377 dynamicQuery.setLimit(start, end);
1378
1379 dynamicQuery.compile(session);
1380
1381 return dynamicQuery.list();
1382 }
1383 catch (Exception e) {
1384 throw processException(e);
1385 }
1386 finally {
1387 closeSession(session);
1388 }
1389 }
1390
1391 public List<DLFileShortcut> findAll() throws SystemException {
1392 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1393 }
1394
1395 public List<DLFileShortcut> findAll(int start, int end)
1396 throws SystemException {
1397 return findAll(start, end, null);
1398 }
1399
1400 public List<DLFileShortcut> findAll(int start, int end,
1401 OrderByComparator obc) throws SystemException {
1402 Object[] finderArgs = new Object[] {
1403 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
1404 };
1405
1406 List<DLFileShortcut> list = (List<DLFileShortcut>)FinderCacheUtil.getResult(FINDER_PATH_FIND_ALL,
1407 finderArgs, this);
1408
1409 if (list == null) {
1410 Session session = null;
1411
1412 try {
1413 session = openSession();
1414
1415 StringBuilder query = new StringBuilder();
1416
1417 query.append(
1418 "SELECT dlFileShortcut FROM DLFileShortcut dlFileShortcut ");
1419
1420 if (obc != null) {
1421 query.append("ORDER BY ");
1422
1423 String[] orderByFields = obc.getOrderByFields();
1424
1425 for (int i = 0; i < orderByFields.length; i++) {
1426 query.append("dlFileShortcut.");
1427 query.append(orderByFields[i]);
1428
1429 if (obc.isAscending()) {
1430 query.append(" ASC");
1431 }
1432 else {
1433 query.append(" DESC");
1434 }
1435
1436 if ((i + 1) < orderByFields.length) {
1437 query.append(", ");
1438 }
1439 }
1440 }
1441
1442 Query q = session.createQuery(query.toString());
1443
1444 if (obc == null) {
1445 list = (List<DLFileShortcut>)QueryUtil.list(q,
1446 getDialect(), start, end, false);
1447
1448 Collections.sort(list);
1449 }
1450 else {
1451 list = (List<DLFileShortcut>)QueryUtil.list(q,
1452 getDialect(), start, end);
1453 }
1454 }
1455 catch (Exception e) {
1456 throw processException(e);
1457 }
1458 finally {
1459 if (list == null) {
1460 list = new ArrayList<DLFileShortcut>();
1461 }
1462
1463 cacheResult(list);
1464
1465 FinderCacheUtil.putResult(FINDER_PATH_FIND_ALL, finderArgs, list);
1466
1467 closeSession(session);
1468 }
1469 }
1470
1471 return list;
1472 }
1473
1474 public void removeByUuid(String uuid) throws SystemException {
1475 for (DLFileShortcut dlFileShortcut : findByUuid(uuid)) {
1476 remove(dlFileShortcut);
1477 }
1478 }
1479
1480 public void removeByUUID_G(String uuid, long groupId)
1481 throws NoSuchFileShortcutException, SystemException {
1482 DLFileShortcut dlFileShortcut = findByUUID_G(uuid, groupId);
1483
1484 remove(dlFileShortcut);
1485 }
1486
1487 public void removeByFolderId(long folderId) throws SystemException {
1488 for (DLFileShortcut dlFileShortcut : findByFolderId(folderId)) {
1489 remove(dlFileShortcut);
1490 }
1491 }
1492
1493 public void removeByTF_TN(long toFolderId, String toName)
1494 throws SystemException {
1495 for (DLFileShortcut dlFileShortcut : findByTF_TN(toFolderId, toName)) {
1496 remove(dlFileShortcut);
1497 }
1498 }
1499
1500 public void removeAll() throws SystemException {
1501 for (DLFileShortcut dlFileShortcut : findAll()) {
1502 remove(dlFileShortcut);
1503 }
1504 }
1505
1506 public int countByUuid(String uuid) throws SystemException {
1507 Object[] finderArgs = new Object[] { uuid };
1508
1509 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID,
1510 finderArgs, this);
1511
1512 if (count == null) {
1513 Session session = null;
1514
1515 try {
1516 session = openSession();
1517
1518 StringBuilder query = new StringBuilder();
1519
1520 query.append("SELECT COUNT(dlFileShortcut) ");
1521 query.append("FROM DLFileShortcut dlFileShortcut WHERE ");
1522
1523 if (uuid == null) {
1524 query.append("dlFileShortcut.uuid IS NULL");
1525 }
1526 else {
1527 query.append("dlFileShortcut.uuid = ?");
1528 }
1529
1530 query.append(" ");
1531
1532 Query q = session.createQuery(query.toString());
1533
1534 QueryPos qPos = QueryPos.getInstance(q);
1535
1536 if (uuid != null) {
1537 qPos.add(uuid);
1538 }
1539
1540 count = (Long)q.uniqueResult();
1541 }
1542 catch (Exception e) {
1543 throw processException(e);
1544 }
1545 finally {
1546 if (count == null) {
1547 count = Long.valueOf(0);
1548 }
1549
1550 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID,
1551 finderArgs, count);
1552
1553 closeSession(session);
1554 }
1555 }
1556
1557 return count.intValue();
1558 }
1559
1560 public int countByUUID_G(String uuid, long groupId)
1561 throws SystemException {
1562 Object[] finderArgs = new Object[] { uuid, new Long(groupId) };
1563
1564 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID_G,
1565 finderArgs, this);
1566
1567 if (count == null) {
1568 Session session = null;
1569
1570 try {
1571 session = openSession();
1572
1573 StringBuilder query = new StringBuilder();
1574
1575 query.append("SELECT COUNT(dlFileShortcut) ");
1576 query.append("FROM DLFileShortcut dlFileShortcut WHERE ");
1577
1578 if (uuid == null) {
1579 query.append("dlFileShortcut.uuid IS NULL");
1580 }
1581 else {
1582 query.append("dlFileShortcut.uuid = ?");
1583 }
1584
1585 query.append(" AND ");
1586
1587 query.append("dlFileShortcut.groupId = ?");
1588
1589 query.append(" ");
1590
1591 Query q = session.createQuery(query.toString());
1592
1593 QueryPos qPos = QueryPos.getInstance(q);
1594
1595 if (uuid != null) {
1596 qPos.add(uuid);
1597 }
1598
1599 qPos.add(groupId);
1600
1601 count = (Long)q.uniqueResult();
1602 }
1603 catch (Exception e) {
1604 throw processException(e);
1605 }
1606 finally {
1607 if (count == null) {
1608 count = Long.valueOf(0);
1609 }
1610
1611 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G,
1612 finderArgs, count);
1613
1614 closeSession(session);
1615 }
1616 }
1617
1618 return count.intValue();
1619 }
1620
1621 public int countByFolderId(long folderId) throws SystemException {
1622 Object[] finderArgs = new Object[] { new Long(folderId) };
1623
1624 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_FOLDERID,
1625 finderArgs, this);
1626
1627 if (count == null) {
1628 Session session = null;
1629
1630 try {
1631 session = openSession();
1632
1633 StringBuilder query = new StringBuilder();
1634
1635 query.append("SELECT COUNT(dlFileShortcut) ");
1636 query.append("FROM DLFileShortcut dlFileShortcut WHERE ");
1637
1638 query.append("dlFileShortcut.folderId = ?");
1639
1640 query.append(" ");
1641
1642 Query q = session.createQuery(query.toString());
1643
1644 QueryPos qPos = QueryPos.getInstance(q);
1645
1646 qPos.add(folderId);
1647
1648 count = (Long)q.uniqueResult();
1649 }
1650 catch (Exception e) {
1651 throw processException(e);
1652 }
1653 finally {
1654 if (count == null) {
1655 count = Long.valueOf(0);
1656 }
1657
1658 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_FOLDERID,
1659 finderArgs, count);
1660
1661 closeSession(session);
1662 }
1663 }
1664
1665 return count.intValue();
1666 }
1667
1668 public int countByTF_TN(long toFolderId, String toName)
1669 throws SystemException {
1670 Object[] finderArgs = new Object[] { new Long(toFolderId), toName };
1671
1672 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_TF_TN,
1673 finderArgs, this);
1674
1675 if (count == null) {
1676 Session session = null;
1677
1678 try {
1679 session = openSession();
1680
1681 StringBuilder query = new StringBuilder();
1682
1683 query.append("SELECT COUNT(dlFileShortcut) ");
1684 query.append("FROM DLFileShortcut dlFileShortcut WHERE ");
1685
1686 query.append("dlFileShortcut.toFolderId = ?");
1687
1688 query.append(" AND ");
1689
1690 if (toName == null) {
1691 query.append("dlFileShortcut.toName IS NULL");
1692 }
1693 else {
1694 query.append("dlFileShortcut.toName = ?");
1695 }
1696
1697 query.append(" ");
1698
1699 Query q = session.createQuery(query.toString());
1700
1701 QueryPos qPos = QueryPos.getInstance(q);
1702
1703 qPos.add(toFolderId);
1704
1705 if (toName != null) {
1706 qPos.add(toName);
1707 }
1708
1709 count = (Long)q.uniqueResult();
1710 }
1711 catch (Exception e) {
1712 throw processException(e);
1713 }
1714 finally {
1715 if (count == null) {
1716 count = Long.valueOf(0);
1717 }
1718
1719 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_TF_TN,
1720 finderArgs, count);
1721
1722 closeSession(session);
1723 }
1724 }
1725
1726 return count.intValue();
1727 }
1728
1729 public int countAll() throws SystemException {
1730 Object[] finderArgs = new Object[0];
1731
1732 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
1733 finderArgs, this);
1734
1735 if (count == null) {
1736 Session session = null;
1737
1738 try {
1739 session = openSession();
1740
1741 Query q = session.createQuery(
1742 "SELECT COUNT(dlFileShortcut) FROM DLFileShortcut dlFileShortcut");
1743
1744 count = (Long)q.uniqueResult();
1745 }
1746 catch (Exception e) {
1747 throw processException(e);
1748 }
1749 finally {
1750 if (count == null) {
1751 count = Long.valueOf(0);
1752 }
1753
1754 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL, finderArgs,
1755 count);
1756
1757 closeSession(session);
1758 }
1759 }
1760
1761 return count.intValue();
1762 }
1763
1764 public void afterPropertiesSet() {
1765 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
1766 com.liferay.portal.util.PropsUtil.get(
1767 "value.object.listener.com.liferay.portlet.documentlibrary.model.DLFileShortcut")));
1768
1769 if (listenerClassNames.length > 0) {
1770 try {
1771 List<ModelListener<DLFileShortcut>> listenersList = new ArrayList<ModelListener<DLFileShortcut>>();
1772
1773 for (String listenerClassName : listenerClassNames) {
1774 listenersList.add((ModelListener<DLFileShortcut>)Class.forName(
1775 listenerClassName).newInstance());
1776 }
1777
1778 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
1779 }
1780 catch (Exception e) {
1781 _log.error(e);
1782 }
1783 }
1784 }
1785
1786 @BeanReference(name = "com.liferay.portlet.documentlibrary.service.persistence.DLFileEntryPersistence.impl")
1787 protected com.liferay.portlet.documentlibrary.service.persistence.DLFileEntryPersistence dlFileEntryPersistence;
1788 @BeanReference(name = "com.liferay.portlet.documentlibrary.service.persistence.DLFileRankPersistence.impl")
1789 protected com.liferay.portlet.documentlibrary.service.persistence.DLFileRankPersistence dlFileRankPersistence;
1790 @BeanReference(name = "com.liferay.portlet.documentlibrary.service.persistence.DLFileShortcutPersistence.impl")
1791 protected com.liferay.portlet.documentlibrary.service.persistence.DLFileShortcutPersistence dlFileShortcutPersistence;
1792 @BeanReference(name = "com.liferay.portlet.documentlibrary.service.persistence.DLFileVersionPersistence.impl")
1793 protected com.liferay.portlet.documentlibrary.service.persistence.DLFileVersionPersistence dlFileVersionPersistence;
1794 @BeanReference(name = "com.liferay.portlet.documentlibrary.service.persistence.DLFolderPersistence.impl")
1795 protected com.liferay.portlet.documentlibrary.service.persistence.DLFolderPersistence dlFolderPersistence;
1796 @BeanReference(name = "com.liferay.portal.service.persistence.ResourcePersistence.impl")
1797 protected com.liferay.portal.service.persistence.ResourcePersistence resourcePersistence;
1798 @BeanReference(name = "com.liferay.portal.service.persistence.UserPersistence.impl")
1799 protected com.liferay.portal.service.persistence.UserPersistence userPersistence;
1800 private static Log _log = LogFactoryUtil.getLog(DLFileShortcutPersistenceImpl.class);
1801}