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