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