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