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