001
014
015 package com.liferay.portlet.documentlibrary.service.persistence;
016
017 import com.liferay.portal.NoSuchModelException;
018 import com.liferay.portal.kernel.annotation.BeanReference;
019 import com.liferay.portal.kernel.cache.CacheRegistryUtil;
020 import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
021 import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
022 import com.liferay.portal.kernel.dao.orm.FinderPath;
023 import com.liferay.portal.kernel.dao.orm.Query;
024 import com.liferay.portal.kernel.dao.orm.QueryPos;
025 import com.liferay.portal.kernel.dao.orm.QueryUtil;
026 import com.liferay.portal.kernel.dao.orm.SQLQuery;
027 import com.liferay.portal.kernel.dao.orm.Session;
028 import com.liferay.portal.kernel.exception.SystemException;
029 import com.liferay.portal.kernel.log.Log;
030 import com.liferay.portal.kernel.log.LogFactoryUtil;
031 import com.liferay.portal.kernel.util.GetterUtil;
032 import com.liferay.portal.kernel.util.InstanceFactory;
033 import com.liferay.portal.kernel.util.OrderByComparator;
034 import com.liferay.portal.kernel.util.StringBundler;
035 import com.liferay.portal.kernel.util.StringPool;
036 import com.liferay.portal.kernel.util.StringUtil;
037 import com.liferay.portal.kernel.util.Validator;
038 import com.liferay.portal.kernel.uuid.PortalUUIDUtil;
039 import com.liferay.portal.model.ModelListener;
040 import com.liferay.portal.security.permission.InlineSQLHelperUtil;
041 import com.liferay.portal.service.persistence.BatchSessionUtil;
042 import com.liferay.portal.service.persistence.ResourcePersistence;
043 import com.liferay.portal.service.persistence.UserPersistence;
044 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
045
046 import com.liferay.portlet.asset.service.persistence.AssetEntryPersistence;
047 import com.liferay.portlet.asset.service.persistence.AssetTagPersistence;
048 import com.liferay.portlet.documentlibrary.NoSuchFileShortcutException;
049 import com.liferay.portlet.documentlibrary.model.DLFileShortcut;
050 import com.liferay.portlet.documentlibrary.model.impl.DLFileShortcutImpl;
051 import com.liferay.portlet.documentlibrary.model.impl.DLFileShortcutModelImpl;
052
053 import java.io.Serializable;
054
055 import java.util.ArrayList;
056 import java.util.Collections;
057 import java.util.List;
058
059
075 public class DLFileShortcutPersistenceImpl extends BasePersistenceImpl<DLFileShortcut>
076 implements DLFileShortcutPersistence {
077 public static final String FINDER_CLASS_NAME_ENTITY = DLFileShortcutImpl.class.getName();
078 public static final String FINDER_CLASS_NAME_LIST = FINDER_CLASS_NAME_ENTITY +
079 ".List";
080 public static final FinderPath FINDER_PATH_FIND_BY_UUID = new FinderPath(DLFileShortcutModelImpl.ENTITY_CACHE_ENABLED,
081 DLFileShortcutModelImpl.FINDER_CACHE_ENABLED,
082 FINDER_CLASS_NAME_LIST, "findByUuid",
083 new String[] {
084 String.class.getName(),
085
086 "java.lang.Integer", "java.lang.Integer",
087 "com.liferay.portal.kernel.util.OrderByComparator"
088 });
089 public static final FinderPath FINDER_PATH_COUNT_BY_UUID = new FinderPath(DLFileShortcutModelImpl.ENTITY_CACHE_ENABLED,
090 DLFileShortcutModelImpl.FINDER_CACHE_ENABLED,
091 FINDER_CLASS_NAME_LIST, "countByUuid",
092 new String[] { String.class.getName() });
093 public static final FinderPath FINDER_PATH_FETCH_BY_UUID_G = new FinderPath(DLFileShortcutModelImpl.ENTITY_CACHE_ENABLED,
094 DLFileShortcutModelImpl.FINDER_CACHE_ENABLED,
095 FINDER_CLASS_NAME_ENTITY, "fetchByUUID_G",
096 new String[] { String.class.getName(), Long.class.getName() });
097 public static final FinderPath FINDER_PATH_COUNT_BY_UUID_G = new FinderPath(DLFileShortcutModelImpl.ENTITY_CACHE_ENABLED,
098 DLFileShortcutModelImpl.FINDER_CACHE_ENABLED,
099 FINDER_CLASS_NAME_LIST, "countByUUID_G",
100 new String[] { String.class.getName(), Long.class.getName() });
101 public static final FinderPath FINDER_PATH_FIND_BY_G_F = new FinderPath(DLFileShortcutModelImpl.ENTITY_CACHE_ENABLED,
102 DLFileShortcutModelImpl.FINDER_CACHE_ENABLED,
103 FINDER_CLASS_NAME_LIST, "findByG_F",
104 new String[] {
105 Long.class.getName(), Long.class.getName(),
106
107 "java.lang.Integer", "java.lang.Integer",
108 "com.liferay.portal.kernel.util.OrderByComparator"
109 });
110 public static final FinderPath FINDER_PATH_COUNT_BY_G_F = new FinderPath(DLFileShortcutModelImpl.ENTITY_CACHE_ENABLED,
111 DLFileShortcutModelImpl.FINDER_CACHE_ENABLED,
112 FINDER_CLASS_NAME_LIST, "countByG_F",
113 new String[] { Long.class.getName(), Long.class.getName() });
114 public static final FinderPath FINDER_PATH_FIND_BY_G_F_S = new FinderPath(DLFileShortcutModelImpl.ENTITY_CACHE_ENABLED,
115 DLFileShortcutModelImpl.FINDER_CACHE_ENABLED,
116 FINDER_CLASS_NAME_LIST, "findByG_F_S",
117 new String[] {
118 Long.class.getName(), Long.class.getName(),
119 Integer.class.getName(),
120
121 "java.lang.Integer", "java.lang.Integer",
122 "com.liferay.portal.kernel.util.OrderByComparator"
123 });
124 public static final FinderPath FINDER_PATH_COUNT_BY_G_F_S = new FinderPath(DLFileShortcutModelImpl.ENTITY_CACHE_ENABLED,
125 DLFileShortcutModelImpl.FINDER_CACHE_ENABLED,
126 FINDER_CLASS_NAME_LIST, "countByG_F_S",
127 new String[] {
128 Long.class.getName(), Long.class.getName(),
129 Integer.class.getName()
130 });
131 public static final FinderPath FINDER_PATH_FIND_BY_G_TF_TN = new FinderPath(DLFileShortcutModelImpl.ENTITY_CACHE_ENABLED,
132 DLFileShortcutModelImpl.FINDER_CACHE_ENABLED,
133 FINDER_CLASS_NAME_LIST, "findByG_TF_TN",
134 new String[] {
135 Long.class.getName(), Long.class.getName(),
136 String.class.getName(),
137
138 "java.lang.Integer", "java.lang.Integer",
139 "com.liferay.portal.kernel.util.OrderByComparator"
140 });
141 public static final FinderPath FINDER_PATH_COUNT_BY_G_TF_TN = new FinderPath(DLFileShortcutModelImpl.ENTITY_CACHE_ENABLED,
142 DLFileShortcutModelImpl.FINDER_CACHE_ENABLED,
143 FINDER_CLASS_NAME_LIST, "countByG_TF_TN",
144 new String[] {
145 Long.class.getName(), Long.class.getName(),
146 String.class.getName()
147 });
148 public static final FinderPath FINDER_PATH_FIND_BY_G_TF_TN_S = new FinderPath(DLFileShortcutModelImpl.ENTITY_CACHE_ENABLED,
149 DLFileShortcutModelImpl.FINDER_CACHE_ENABLED,
150 FINDER_CLASS_NAME_LIST, "findByG_TF_TN_S",
151 new String[] {
152 Long.class.getName(), Long.class.getName(),
153 String.class.getName(), Integer.class.getName(),
154
155 "java.lang.Integer", "java.lang.Integer",
156 "com.liferay.portal.kernel.util.OrderByComparator"
157 });
158 public static final FinderPath FINDER_PATH_COUNT_BY_G_TF_TN_S = new FinderPath(DLFileShortcutModelImpl.ENTITY_CACHE_ENABLED,
159 DLFileShortcutModelImpl.FINDER_CACHE_ENABLED,
160 FINDER_CLASS_NAME_LIST, "countByG_TF_TN_S",
161 new String[] {
162 Long.class.getName(), Long.class.getName(),
163 String.class.getName(), Integer.class.getName()
164 });
165 public static final FinderPath FINDER_PATH_FIND_ALL = new FinderPath(DLFileShortcutModelImpl.ENTITY_CACHE_ENABLED,
166 DLFileShortcutModelImpl.FINDER_CACHE_ENABLED,
167 FINDER_CLASS_NAME_LIST, "findAll", new String[0]);
168 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(DLFileShortcutModelImpl.ENTITY_CACHE_ENABLED,
169 DLFileShortcutModelImpl.FINDER_CACHE_ENABLED,
170 FINDER_CLASS_NAME_LIST, "countAll", new String[0]);
171
172
177 public void cacheResult(DLFileShortcut dlFileShortcut) {
178 EntityCacheUtil.putResult(DLFileShortcutModelImpl.ENTITY_CACHE_ENABLED,
179 DLFileShortcutImpl.class, dlFileShortcut.getPrimaryKey(),
180 dlFileShortcut);
181
182 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
183 new Object[] {
184 dlFileShortcut.getUuid(), new Long(dlFileShortcut.getGroupId())
185 }, dlFileShortcut);
186 }
187
188
193 public void cacheResult(List<DLFileShortcut> dlFileShortcuts) {
194 for (DLFileShortcut dlFileShortcut : dlFileShortcuts) {
195 if (EntityCacheUtil.getResult(
196 DLFileShortcutModelImpl.ENTITY_CACHE_ENABLED,
197 DLFileShortcutImpl.class,
198 dlFileShortcut.getPrimaryKey(), this) == null) {
199 cacheResult(dlFileShortcut);
200 }
201 }
202 }
203
204
211 public void clearCache() {
212 CacheRegistryUtil.clear(DLFileShortcutImpl.class.getName());
213 EntityCacheUtil.clearCache(DLFileShortcutImpl.class.getName());
214 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
215 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
216 }
217
218
225 public void clearCache(DLFileShortcut dlFileShortcut) {
226 EntityCacheUtil.removeResult(DLFileShortcutModelImpl.ENTITY_CACHE_ENABLED,
227 DLFileShortcutImpl.class, dlFileShortcut.getPrimaryKey());
228
229 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
230 new Object[] {
231 dlFileShortcut.getUuid(), new Long(dlFileShortcut.getGroupId())
232 });
233 }
234
235
241 public DLFileShortcut create(long fileShortcutId) {
242 DLFileShortcut dlFileShortcut = new DLFileShortcutImpl();
243
244 dlFileShortcut.setNew(true);
245 dlFileShortcut.setPrimaryKey(fileShortcutId);
246
247 String uuid = PortalUUIDUtil.generate();
248
249 dlFileShortcut.setUuid(uuid);
250
251 return dlFileShortcut;
252 }
253
254
262 public DLFileShortcut remove(Serializable primaryKey)
263 throws NoSuchModelException, SystemException {
264 return remove(((Long)primaryKey).longValue());
265 }
266
267
275 public DLFileShortcut remove(long fileShortcutId)
276 throws NoSuchFileShortcutException, SystemException {
277 Session session = null;
278
279 try {
280 session = openSession();
281
282 DLFileShortcut dlFileShortcut = (DLFileShortcut)session.get(DLFileShortcutImpl.class,
283 new Long(fileShortcutId));
284
285 if (dlFileShortcut == null) {
286 if (_log.isWarnEnabled()) {
287 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
288 fileShortcutId);
289 }
290
291 throw new NoSuchFileShortcutException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
292 fileShortcutId);
293 }
294
295 return remove(dlFileShortcut);
296 }
297 catch (NoSuchFileShortcutException nsee) {
298 throw nsee;
299 }
300 catch (Exception e) {
301 throw processException(e);
302 }
303 finally {
304 closeSession(session);
305 }
306 }
307
308 protected DLFileShortcut removeImpl(DLFileShortcut dlFileShortcut)
309 throws SystemException {
310 dlFileShortcut = toUnwrappedModel(dlFileShortcut);
311
312 Session session = null;
313
314 try {
315 session = openSession();
316
317 if (dlFileShortcut.isCachedModel() || BatchSessionUtil.isEnabled()) {
318 Object staleObject = session.get(DLFileShortcutImpl.class,
319 dlFileShortcut.getPrimaryKeyObj());
320
321 if (staleObject != null) {
322 session.evict(staleObject);
323 }
324 }
325
326 session.delete(dlFileShortcut);
327
328 session.flush();
329 }
330 catch (Exception e) {
331 throw processException(e);
332 }
333 finally {
334 closeSession(session);
335 }
336
337 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
338
339 DLFileShortcutModelImpl dlFileShortcutModelImpl = (DLFileShortcutModelImpl)dlFileShortcut;
340
341 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
342 new Object[] {
343 dlFileShortcutModelImpl.getOriginalUuid(),
344 new Long(dlFileShortcutModelImpl.getOriginalGroupId())
345 });
346
347 EntityCacheUtil.removeResult(DLFileShortcutModelImpl.ENTITY_CACHE_ENABLED,
348 DLFileShortcutImpl.class, dlFileShortcut.getPrimaryKey());
349
350 return dlFileShortcut;
351 }
352
353 public DLFileShortcut updateImpl(
354 com.liferay.portlet.documentlibrary.model.DLFileShortcut dlFileShortcut,
355 boolean merge) throws SystemException {
356 dlFileShortcut = toUnwrappedModel(dlFileShortcut);
357
358 boolean isNew = dlFileShortcut.isNew();
359
360 DLFileShortcutModelImpl dlFileShortcutModelImpl = (DLFileShortcutModelImpl)dlFileShortcut;
361
362 if (Validator.isNull(dlFileShortcut.getUuid())) {
363 String uuid = PortalUUIDUtil.generate();
364
365 dlFileShortcut.setUuid(uuid);
366 }
367
368 Session session = null;
369
370 try {
371 session = openSession();
372
373 BatchSessionUtil.update(session, dlFileShortcut, merge);
374
375 dlFileShortcut.setNew(false);
376 }
377 catch (Exception e) {
378 throw processException(e);
379 }
380 finally {
381 closeSession(session);
382 }
383
384 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
385
386 EntityCacheUtil.putResult(DLFileShortcutModelImpl.ENTITY_CACHE_ENABLED,
387 DLFileShortcutImpl.class, dlFileShortcut.getPrimaryKey(),
388 dlFileShortcut);
389
390 if (!isNew &&
391 (!Validator.equals(dlFileShortcut.getUuid(),
392 dlFileShortcutModelImpl.getOriginalUuid()) ||
393 (dlFileShortcut.getGroupId() != dlFileShortcutModelImpl.getOriginalGroupId()))) {
394 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
395 new Object[] {
396 dlFileShortcutModelImpl.getOriginalUuid(),
397 new Long(dlFileShortcutModelImpl.getOriginalGroupId())
398 });
399 }
400
401 if (isNew ||
402 (!Validator.equals(dlFileShortcut.getUuid(),
403 dlFileShortcutModelImpl.getOriginalUuid()) ||
404 (dlFileShortcut.getGroupId() != dlFileShortcutModelImpl.getOriginalGroupId()))) {
405 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
406 new Object[] {
407 dlFileShortcut.getUuid(),
408 new Long(dlFileShortcut.getGroupId())
409 }, dlFileShortcut);
410 }
411
412 return dlFileShortcut;
413 }
414
415 protected DLFileShortcut toUnwrappedModel(DLFileShortcut dlFileShortcut) {
416 if (dlFileShortcut instanceof DLFileShortcutImpl) {
417 return dlFileShortcut;
418 }
419
420 DLFileShortcutImpl dlFileShortcutImpl = new DLFileShortcutImpl();
421
422 dlFileShortcutImpl.setNew(dlFileShortcut.isNew());
423 dlFileShortcutImpl.setPrimaryKey(dlFileShortcut.getPrimaryKey());
424
425 dlFileShortcutImpl.setUuid(dlFileShortcut.getUuid());
426 dlFileShortcutImpl.setFileShortcutId(dlFileShortcut.getFileShortcutId());
427 dlFileShortcutImpl.setGroupId(dlFileShortcut.getGroupId());
428 dlFileShortcutImpl.setCompanyId(dlFileShortcut.getCompanyId());
429 dlFileShortcutImpl.setUserId(dlFileShortcut.getUserId());
430 dlFileShortcutImpl.setUserName(dlFileShortcut.getUserName());
431 dlFileShortcutImpl.setCreateDate(dlFileShortcut.getCreateDate());
432 dlFileShortcutImpl.setModifiedDate(dlFileShortcut.getModifiedDate());
433 dlFileShortcutImpl.setFolderId(dlFileShortcut.getFolderId());
434 dlFileShortcutImpl.setToFolderId(dlFileShortcut.getToFolderId());
435 dlFileShortcutImpl.setToName(dlFileShortcut.getToName());
436 dlFileShortcutImpl.setStatus(dlFileShortcut.getStatus());
437 dlFileShortcutImpl.setStatusByUserId(dlFileShortcut.getStatusByUserId());
438 dlFileShortcutImpl.setStatusByUserName(dlFileShortcut.getStatusByUserName());
439 dlFileShortcutImpl.setStatusDate(dlFileShortcut.getStatusDate());
440
441 return dlFileShortcutImpl;
442 }
443
444
452 public DLFileShortcut findByPrimaryKey(Serializable primaryKey)
453 throws NoSuchModelException, SystemException {
454 return findByPrimaryKey(((Long)primaryKey).longValue());
455 }
456
457
465 public DLFileShortcut findByPrimaryKey(long fileShortcutId)
466 throws NoSuchFileShortcutException, SystemException {
467 DLFileShortcut dlFileShortcut = fetchByPrimaryKey(fileShortcutId);
468
469 if (dlFileShortcut == null) {
470 if (_log.isWarnEnabled()) {
471 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + fileShortcutId);
472 }
473
474 throw new NoSuchFileShortcutException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
475 fileShortcutId);
476 }
477
478 return dlFileShortcut;
479 }
480
481
488 public DLFileShortcut fetchByPrimaryKey(Serializable primaryKey)
489 throws SystemException {
490 return fetchByPrimaryKey(((Long)primaryKey).longValue());
491 }
492
493
500 public DLFileShortcut fetchByPrimaryKey(long fileShortcutId)
501 throws SystemException {
502 DLFileShortcut dlFileShortcut = (DLFileShortcut)EntityCacheUtil.getResult(DLFileShortcutModelImpl.ENTITY_CACHE_ENABLED,
503 DLFileShortcutImpl.class, fileShortcutId, this);
504
505 if (dlFileShortcut == null) {
506 Session session = null;
507
508 try {
509 session = openSession();
510
511 dlFileShortcut = (DLFileShortcut)session.get(DLFileShortcutImpl.class,
512 new Long(fileShortcutId));
513 }
514 catch (Exception e) {
515 throw processException(e);
516 }
517 finally {
518 if (dlFileShortcut != null) {
519 cacheResult(dlFileShortcut);
520 }
521
522 closeSession(session);
523 }
524 }
525
526 return dlFileShortcut;
527 }
528
529
536 public List<DLFileShortcut> findByUuid(String uuid)
537 throws SystemException {
538 return findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
539 }
540
541
554 public List<DLFileShortcut> findByUuid(String uuid, int start, int end)
555 throws SystemException {
556 return findByUuid(uuid, start, end, null);
557 }
558
559
573 public List<DLFileShortcut> findByUuid(String uuid, int start, int end,
574 OrderByComparator orderByComparator) throws SystemException {
575 Object[] finderArgs = new Object[] {
576 uuid,
577
578 String.valueOf(start), String.valueOf(end),
579 String.valueOf(orderByComparator)
580 };
581
582 List<DLFileShortcut> list = (List<DLFileShortcut>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_UUID,
583 finderArgs, this);
584
585 if (list == null) {
586 Session session = null;
587
588 try {
589 session = openSession();
590
591 StringBundler query = null;
592
593 if (orderByComparator != null) {
594 query = new StringBundler(3 +
595 (orderByComparator.getOrderByFields().length * 3));
596 }
597 else {
598 query = new StringBundler(2);
599 }
600
601 query.append(_SQL_SELECT_DLFILESHORTCUT_WHERE);
602
603 if (uuid == null) {
604 query.append(_FINDER_COLUMN_UUID_UUID_1);
605 }
606 else {
607 if (uuid.equals(StringPool.BLANK)) {
608 query.append(_FINDER_COLUMN_UUID_UUID_3);
609 }
610 else {
611 query.append(_FINDER_COLUMN_UUID_UUID_2);
612 }
613 }
614
615 if (orderByComparator != null) {
616 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
617 orderByComparator);
618 }
619
620 String sql = query.toString();
621
622 Query q = session.createQuery(sql);
623
624 QueryPos qPos = QueryPos.getInstance(q);
625
626 if (uuid != null) {
627 qPos.add(uuid);
628 }
629
630 list = (List<DLFileShortcut>)QueryUtil.list(q, getDialect(),
631 start, end);
632 }
633 catch (Exception e) {
634 throw processException(e);
635 }
636 finally {
637 if (list == null) {
638 list = new ArrayList<DLFileShortcut>();
639 }
640
641 cacheResult(list);
642
643 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_UUID, finderArgs,
644 list);
645
646 closeSession(session);
647 }
648 }
649
650 return list;
651 }
652
653
666 public DLFileShortcut findByUuid_First(String uuid,
667 OrderByComparator orderByComparator)
668 throws NoSuchFileShortcutException, SystemException {
669 List<DLFileShortcut> list = findByUuid(uuid, 0, 1, orderByComparator);
670
671 if (list.isEmpty()) {
672 StringBundler msg = new StringBundler(4);
673
674 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
675
676 msg.append("uuid=");
677 msg.append(uuid);
678
679 msg.append(StringPool.CLOSE_CURLY_BRACE);
680
681 throw new NoSuchFileShortcutException(msg.toString());
682 }
683 else {
684 return list.get(0);
685 }
686 }
687
688
701 public DLFileShortcut findByUuid_Last(String uuid,
702 OrderByComparator orderByComparator)
703 throws NoSuchFileShortcutException, SystemException {
704 int count = countByUuid(uuid);
705
706 List<DLFileShortcut> list = findByUuid(uuid, count - 1, count,
707 orderByComparator);
708
709 if (list.isEmpty()) {
710 StringBundler msg = new StringBundler(4);
711
712 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
713
714 msg.append("uuid=");
715 msg.append(uuid);
716
717 msg.append(StringPool.CLOSE_CURLY_BRACE);
718
719 throw new NoSuchFileShortcutException(msg.toString());
720 }
721 else {
722 return list.get(0);
723 }
724 }
725
726
740 public DLFileShortcut[] findByUuid_PrevAndNext(long fileShortcutId,
741 String uuid, OrderByComparator orderByComparator)
742 throws NoSuchFileShortcutException, SystemException {
743 DLFileShortcut dlFileShortcut = findByPrimaryKey(fileShortcutId);
744
745 Session session = null;
746
747 try {
748 session = openSession();
749
750 DLFileShortcut[] array = new DLFileShortcutImpl[3];
751
752 array[0] = getByUuid_PrevAndNext(session, dlFileShortcut, uuid,
753 orderByComparator, true);
754
755 array[1] = dlFileShortcut;
756
757 array[2] = getByUuid_PrevAndNext(session, dlFileShortcut, uuid,
758 orderByComparator, false);
759
760 return array;
761 }
762 catch (Exception e) {
763 throw processException(e);
764 }
765 finally {
766 closeSession(session);
767 }
768 }
769
770 protected DLFileShortcut getByUuid_PrevAndNext(Session session,
771 DLFileShortcut dlFileShortcut, String uuid,
772 OrderByComparator orderByComparator, boolean previous) {
773 StringBundler query = null;
774
775 if (orderByComparator != null) {
776 query = new StringBundler(6 +
777 (orderByComparator.getOrderByFields().length * 6));
778 }
779 else {
780 query = new StringBundler(3);
781 }
782
783 query.append(_SQL_SELECT_DLFILESHORTCUT_WHERE);
784
785 if (uuid == null) {
786 query.append(_FINDER_COLUMN_UUID_UUID_1);
787 }
788 else {
789 if (uuid.equals(StringPool.BLANK)) {
790 query.append(_FINDER_COLUMN_UUID_UUID_3);
791 }
792 else {
793 query.append(_FINDER_COLUMN_UUID_UUID_2);
794 }
795 }
796
797 if (orderByComparator != null) {
798 String[] orderByFields = orderByComparator.getOrderByFields();
799
800 if (orderByFields.length > 0) {
801 query.append(WHERE_AND);
802 }
803
804 for (int i = 0; i < orderByFields.length; i++) {
805 query.append(_ORDER_BY_ENTITY_ALIAS);
806 query.append(orderByFields[i]);
807
808 if ((i + 1) < orderByFields.length) {
809 if (orderByComparator.isAscending() ^ previous) {
810 query.append(WHERE_GREATER_THAN_HAS_NEXT);
811 }
812 else {
813 query.append(WHERE_LESSER_THAN_HAS_NEXT);
814 }
815 }
816 else {
817 if (orderByComparator.isAscending() ^ previous) {
818 query.append(WHERE_GREATER_THAN);
819 }
820 else {
821 query.append(WHERE_LESSER_THAN);
822 }
823 }
824 }
825
826 query.append(ORDER_BY_CLAUSE);
827
828 for (int i = 0; i < orderByFields.length; i++) {
829 query.append(_ORDER_BY_ENTITY_ALIAS);
830 query.append(orderByFields[i]);
831
832 if ((i + 1) < orderByFields.length) {
833 if (orderByComparator.isAscending() ^ previous) {
834 query.append(ORDER_BY_ASC_HAS_NEXT);
835 }
836 else {
837 query.append(ORDER_BY_DESC_HAS_NEXT);
838 }
839 }
840 else {
841 if (orderByComparator.isAscending() ^ previous) {
842 query.append(ORDER_BY_ASC);
843 }
844 else {
845 query.append(ORDER_BY_DESC);
846 }
847 }
848 }
849 }
850
851 String sql = query.toString();
852
853 Query q = session.createQuery(sql);
854
855 q.setFirstResult(0);
856 q.setMaxResults(2);
857
858 QueryPos qPos = QueryPos.getInstance(q);
859
860 if (uuid != null) {
861 qPos.add(uuid);
862 }
863
864 if (orderByComparator != null) {
865 Object[] values = orderByComparator.getOrderByValues(dlFileShortcut);
866
867 for (Object value : values) {
868 qPos.add(value);
869 }
870 }
871
872 List<DLFileShortcut> list = q.list();
873
874 if (list.size() == 2) {
875 return list.get(1);
876 }
877 else {
878 return null;
879 }
880 }
881
882
891 public DLFileShortcut findByUUID_G(String uuid, long groupId)
892 throws NoSuchFileShortcutException, SystemException {
893 DLFileShortcut dlFileShortcut = fetchByUUID_G(uuid, groupId);
894
895 if (dlFileShortcut == null) {
896 StringBundler msg = new StringBundler(6);
897
898 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
899
900 msg.append("uuid=");
901 msg.append(uuid);
902
903 msg.append(", groupId=");
904 msg.append(groupId);
905
906 msg.append(StringPool.CLOSE_CURLY_BRACE);
907
908 if (_log.isWarnEnabled()) {
909 _log.warn(msg.toString());
910 }
911
912 throw new NoSuchFileShortcutException(msg.toString());
913 }
914
915 return dlFileShortcut;
916 }
917
918
926 public DLFileShortcut fetchByUUID_G(String uuid, long groupId)
927 throws SystemException {
928 return fetchByUUID_G(uuid, groupId, true);
929 }
930
931
939 public DLFileShortcut fetchByUUID_G(String uuid, long groupId,
940 boolean retrieveFromCache) throws SystemException {
941 Object[] finderArgs = new Object[] { uuid, groupId };
942
943 Object result = null;
944
945 if (retrieveFromCache) {
946 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_UUID_G,
947 finderArgs, this);
948 }
949
950 if (result == null) {
951 Session session = null;
952
953 try {
954 session = openSession();
955
956 StringBundler query = new StringBundler(3);
957
958 query.append(_SQL_SELECT_DLFILESHORTCUT_WHERE);
959
960 if (uuid == null) {
961 query.append(_FINDER_COLUMN_UUID_G_UUID_1);
962 }
963 else {
964 if (uuid.equals(StringPool.BLANK)) {
965 query.append(_FINDER_COLUMN_UUID_G_UUID_3);
966 }
967 else {
968 query.append(_FINDER_COLUMN_UUID_G_UUID_2);
969 }
970 }
971
972 query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
973
974 String sql = query.toString();
975
976 Query q = session.createQuery(sql);
977
978 QueryPos qPos = QueryPos.getInstance(q);
979
980 if (uuid != null) {
981 qPos.add(uuid);
982 }
983
984 qPos.add(groupId);
985
986 List<DLFileShortcut> list = q.list();
987
988 result = list;
989
990 DLFileShortcut dlFileShortcut = null;
991
992 if (list.isEmpty()) {
993 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
994 finderArgs, list);
995 }
996 else {
997 dlFileShortcut = list.get(0);
998
999 cacheResult(dlFileShortcut);
1000
1001 if ((dlFileShortcut.getUuid() == null) ||
1002 !dlFileShortcut.getUuid().equals(uuid) ||
1003 (dlFileShortcut.getGroupId() != groupId)) {
1004 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
1005 finderArgs, dlFileShortcut);
1006 }
1007 }
1008
1009 return dlFileShortcut;
1010 }
1011 catch (Exception e) {
1012 throw processException(e);
1013 }
1014 finally {
1015 if (result == null) {
1016 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
1017 finderArgs, new ArrayList<DLFileShortcut>());
1018 }
1019
1020 closeSession(session);
1021 }
1022 }
1023 else {
1024 if (result instanceof List<?>) {
1025 return null;
1026 }
1027 else {
1028 return (DLFileShortcut)result;
1029 }
1030 }
1031 }
1032
1033
1041 public List<DLFileShortcut> findByG_F(long groupId, long folderId)
1042 throws SystemException {
1043 return findByG_F(groupId, folderId, QueryUtil.ALL_POS,
1044 QueryUtil.ALL_POS, null);
1045 }
1046
1047
1061 public List<DLFileShortcut> findByG_F(long groupId, long folderId,
1062 int start, int end) throws SystemException {
1063 return findByG_F(groupId, folderId, start, end, null);
1064 }
1065
1066
1081 public List<DLFileShortcut> findByG_F(long groupId, long folderId,
1082 int start, int end, OrderByComparator orderByComparator)
1083 throws SystemException {
1084 Object[] finderArgs = new Object[] {
1085 groupId, folderId,
1086
1087 String.valueOf(start), String.valueOf(end),
1088 String.valueOf(orderByComparator)
1089 };
1090
1091 List<DLFileShortcut> list = (List<DLFileShortcut>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_G_F,
1092 finderArgs, this);
1093
1094 if (list == null) {
1095 Session session = null;
1096
1097 try {
1098 session = openSession();
1099
1100 StringBundler query = null;
1101
1102 if (orderByComparator != null) {
1103 query = new StringBundler(4 +
1104 (orderByComparator.getOrderByFields().length * 3));
1105 }
1106 else {
1107 query = new StringBundler(3);
1108 }
1109
1110 query.append(_SQL_SELECT_DLFILESHORTCUT_WHERE);
1111
1112 query.append(_FINDER_COLUMN_G_F_GROUPID_2);
1113
1114 query.append(_FINDER_COLUMN_G_F_FOLDERID_2);
1115
1116 if (orderByComparator != null) {
1117 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1118 orderByComparator);
1119 }
1120
1121 String sql = query.toString();
1122
1123 Query q = session.createQuery(sql);
1124
1125 QueryPos qPos = QueryPos.getInstance(q);
1126
1127 qPos.add(groupId);
1128
1129 qPos.add(folderId);
1130
1131 list = (List<DLFileShortcut>)QueryUtil.list(q, getDialect(),
1132 start, end);
1133 }
1134 catch (Exception e) {
1135 throw processException(e);
1136 }
1137 finally {
1138 if (list == null) {
1139 list = new ArrayList<DLFileShortcut>();
1140 }
1141
1142 cacheResult(list);
1143
1144 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_G_F, finderArgs,
1145 list);
1146
1147 closeSession(session);
1148 }
1149 }
1150
1151 return list;
1152 }
1153
1154
1168 public DLFileShortcut findByG_F_First(long groupId, long folderId,
1169 OrderByComparator orderByComparator)
1170 throws NoSuchFileShortcutException, SystemException {
1171 List<DLFileShortcut> list = findByG_F(groupId, folderId, 0, 1,
1172 orderByComparator);
1173
1174 if (list.isEmpty()) {
1175 StringBundler msg = new StringBundler(6);
1176
1177 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1178
1179 msg.append("groupId=");
1180 msg.append(groupId);
1181
1182 msg.append(", folderId=");
1183 msg.append(folderId);
1184
1185 msg.append(StringPool.CLOSE_CURLY_BRACE);
1186
1187 throw new NoSuchFileShortcutException(msg.toString());
1188 }
1189 else {
1190 return list.get(0);
1191 }
1192 }
1193
1194
1208 public DLFileShortcut findByG_F_Last(long groupId, long folderId,
1209 OrderByComparator orderByComparator)
1210 throws NoSuchFileShortcutException, SystemException {
1211 int count = countByG_F(groupId, folderId);
1212
1213 List<DLFileShortcut> list = findByG_F(groupId, folderId, count - 1,
1214 count, orderByComparator);
1215
1216 if (list.isEmpty()) {
1217 StringBundler msg = new StringBundler(6);
1218
1219 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1220
1221 msg.append("groupId=");
1222 msg.append(groupId);
1223
1224 msg.append(", folderId=");
1225 msg.append(folderId);
1226
1227 msg.append(StringPool.CLOSE_CURLY_BRACE);
1228
1229 throw new NoSuchFileShortcutException(msg.toString());
1230 }
1231 else {
1232 return list.get(0);
1233 }
1234 }
1235
1236
1251 public DLFileShortcut[] findByG_F_PrevAndNext(long fileShortcutId,
1252 long groupId, long folderId, OrderByComparator orderByComparator)
1253 throws NoSuchFileShortcutException, SystemException {
1254 DLFileShortcut dlFileShortcut = findByPrimaryKey(fileShortcutId);
1255
1256 Session session = null;
1257
1258 try {
1259 session = openSession();
1260
1261 DLFileShortcut[] array = new DLFileShortcutImpl[3];
1262
1263 array[0] = getByG_F_PrevAndNext(session, dlFileShortcut, groupId,
1264 folderId, orderByComparator, true);
1265
1266 array[1] = dlFileShortcut;
1267
1268 array[2] = getByG_F_PrevAndNext(session, dlFileShortcut, groupId,
1269 folderId, orderByComparator, false);
1270
1271 return array;
1272 }
1273 catch (Exception e) {
1274 throw processException(e);
1275 }
1276 finally {
1277 closeSession(session);
1278 }
1279 }
1280
1281 protected DLFileShortcut getByG_F_PrevAndNext(Session session,
1282 DLFileShortcut dlFileShortcut, long groupId, long folderId,
1283 OrderByComparator orderByComparator, boolean previous) {
1284 StringBundler query = null;
1285
1286 if (orderByComparator != null) {
1287 query = new StringBundler(6 +
1288 (orderByComparator.getOrderByFields().length * 6));
1289 }
1290 else {
1291 query = new StringBundler(3);
1292 }
1293
1294 query.append(_SQL_SELECT_DLFILESHORTCUT_WHERE);
1295
1296 query.append(_FINDER_COLUMN_G_F_GROUPID_2);
1297
1298 query.append(_FINDER_COLUMN_G_F_FOLDERID_2);
1299
1300 if (orderByComparator != null) {
1301 String[] orderByFields = orderByComparator.getOrderByFields();
1302
1303 if (orderByFields.length > 0) {
1304 query.append(WHERE_AND);
1305 }
1306
1307 for (int i = 0; i < orderByFields.length; i++) {
1308 query.append(_ORDER_BY_ENTITY_ALIAS);
1309 query.append(orderByFields[i]);
1310
1311 if ((i + 1) < orderByFields.length) {
1312 if (orderByComparator.isAscending() ^ previous) {
1313 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1314 }
1315 else {
1316 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1317 }
1318 }
1319 else {
1320 if (orderByComparator.isAscending() ^ previous) {
1321 query.append(WHERE_GREATER_THAN);
1322 }
1323 else {
1324 query.append(WHERE_LESSER_THAN);
1325 }
1326 }
1327 }
1328
1329 query.append(ORDER_BY_CLAUSE);
1330
1331 for (int i = 0; i < orderByFields.length; i++) {
1332 query.append(_ORDER_BY_ENTITY_ALIAS);
1333 query.append(orderByFields[i]);
1334
1335 if ((i + 1) < orderByFields.length) {
1336 if (orderByComparator.isAscending() ^ previous) {
1337 query.append(ORDER_BY_ASC_HAS_NEXT);
1338 }
1339 else {
1340 query.append(ORDER_BY_DESC_HAS_NEXT);
1341 }
1342 }
1343 else {
1344 if (orderByComparator.isAscending() ^ previous) {
1345 query.append(ORDER_BY_ASC);
1346 }
1347 else {
1348 query.append(ORDER_BY_DESC);
1349 }
1350 }
1351 }
1352 }
1353
1354 String sql = query.toString();
1355
1356 Query q = session.createQuery(sql);
1357
1358 q.setFirstResult(0);
1359 q.setMaxResults(2);
1360
1361 QueryPos qPos = QueryPos.getInstance(q);
1362
1363 qPos.add(groupId);
1364
1365 qPos.add(folderId);
1366
1367 if (orderByComparator != null) {
1368 Object[] values = orderByComparator.getOrderByValues(dlFileShortcut);
1369
1370 for (Object value : values) {
1371 qPos.add(value);
1372 }
1373 }
1374
1375 List<DLFileShortcut> list = q.list();
1376
1377 if (list.size() == 2) {
1378 return list.get(1);
1379 }
1380 else {
1381 return null;
1382 }
1383 }
1384
1385
1393 public List<DLFileShortcut> filterFindByG_F(long groupId, long folderId)
1394 throws SystemException {
1395 return filterFindByG_F(groupId, folderId, QueryUtil.ALL_POS,
1396 QueryUtil.ALL_POS, null);
1397 }
1398
1399
1413 public List<DLFileShortcut> filterFindByG_F(long groupId, long folderId,
1414 int start, int end) throws SystemException {
1415 return filterFindByG_F(groupId, folderId, start, end, null);
1416 }
1417
1418
1433 public List<DLFileShortcut> filterFindByG_F(long groupId, long folderId,
1434 int start, int end, OrderByComparator orderByComparator)
1435 throws SystemException {
1436 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
1437 return findByG_F(groupId, folderId, start, end, orderByComparator);
1438 }
1439
1440 Session session = null;
1441
1442 try {
1443 session = openSession();
1444
1445 StringBundler query = null;
1446
1447 if (orderByComparator != null) {
1448 query = new StringBundler(4 +
1449 (orderByComparator.getOrderByFields().length * 3));
1450 }
1451 else {
1452 query = new StringBundler(3);
1453 }
1454
1455 query.append(_FILTER_SQL_SELECT_DLFILESHORTCUT_WHERE);
1456
1457 query.append(_FINDER_COLUMN_G_F_GROUPID_2);
1458
1459 query.append(_FINDER_COLUMN_G_F_FOLDERID_2);
1460
1461 if (orderByComparator != null) {
1462 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1463 orderByComparator);
1464 }
1465
1466 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1467 DLFileShortcut.class.getName(), _FILTER_COLUMN_PK,
1468 _FILTER_COLUMN_USERID, groupId);
1469
1470 SQLQuery q = session.createSQLQuery(sql);
1471
1472 q.addEntity(_FILTER_ENTITY_ALIAS, DLFileShortcutImpl.class);
1473
1474 QueryPos qPos = QueryPos.getInstance(q);
1475
1476 qPos.add(groupId);
1477
1478 qPos.add(folderId);
1479
1480 return (List<DLFileShortcut>)QueryUtil.list(q, getDialect(), start,
1481 end);
1482 }
1483 catch (Exception e) {
1484 throw processException(e);
1485 }
1486 finally {
1487 closeSession(session);
1488 }
1489 }
1490
1491
1500 public List<DLFileShortcut> findByG_F_S(long groupId, long folderId,
1501 int status) throws SystemException {
1502 return findByG_F_S(groupId, folderId, status, QueryUtil.ALL_POS,
1503 QueryUtil.ALL_POS, null);
1504 }
1505
1506
1521 public List<DLFileShortcut> findByG_F_S(long groupId, long folderId,
1522 int status, int start, int end) throws SystemException {
1523 return findByG_F_S(groupId, folderId, status, start, end, null);
1524 }
1525
1526
1542 public List<DLFileShortcut> findByG_F_S(long groupId, long folderId,
1543 int status, int start, int end, OrderByComparator orderByComparator)
1544 throws SystemException {
1545 Object[] finderArgs = new Object[] {
1546 groupId, folderId, status,
1547
1548 String.valueOf(start), String.valueOf(end),
1549 String.valueOf(orderByComparator)
1550 };
1551
1552 List<DLFileShortcut> list = (List<DLFileShortcut>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_G_F_S,
1553 finderArgs, this);
1554
1555 if (list == null) {
1556 Session session = null;
1557
1558 try {
1559 session = openSession();
1560
1561 StringBundler query = null;
1562
1563 if (orderByComparator != null) {
1564 query = new StringBundler(5 +
1565 (orderByComparator.getOrderByFields().length * 3));
1566 }
1567 else {
1568 query = new StringBundler(4);
1569 }
1570
1571 query.append(_SQL_SELECT_DLFILESHORTCUT_WHERE);
1572
1573 query.append(_FINDER_COLUMN_G_F_S_GROUPID_2);
1574
1575 query.append(_FINDER_COLUMN_G_F_S_FOLDERID_2);
1576
1577 query.append(_FINDER_COLUMN_G_F_S_STATUS_2);
1578
1579 if (orderByComparator != null) {
1580 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1581 orderByComparator);
1582 }
1583
1584 String sql = query.toString();
1585
1586 Query q = session.createQuery(sql);
1587
1588 QueryPos qPos = QueryPos.getInstance(q);
1589
1590 qPos.add(groupId);
1591
1592 qPos.add(folderId);
1593
1594 qPos.add(status);
1595
1596 list = (List<DLFileShortcut>)QueryUtil.list(q, getDialect(),
1597 start, end);
1598 }
1599 catch (Exception e) {
1600 throw processException(e);
1601 }
1602 finally {
1603 if (list == null) {
1604 list = new ArrayList<DLFileShortcut>();
1605 }
1606
1607 cacheResult(list);
1608
1609 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_G_F_S,
1610 finderArgs, list);
1611
1612 closeSession(session);
1613 }
1614 }
1615
1616 return list;
1617 }
1618
1619
1634 public DLFileShortcut findByG_F_S_First(long groupId, long folderId,
1635 int status, OrderByComparator orderByComparator)
1636 throws NoSuchFileShortcutException, SystemException {
1637 List<DLFileShortcut> list = findByG_F_S(groupId, folderId, status, 0,
1638 1, orderByComparator);
1639
1640 if (list.isEmpty()) {
1641 StringBundler msg = new StringBundler(8);
1642
1643 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1644
1645 msg.append("groupId=");
1646 msg.append(groupId);
1647
1648 msg.append(", folderId=");
1649 msg.append(folderId);
1650
1651 msg.append(", status=");
1652 msg.append(status);
1653
1654 msg.append(StringPool.CLOSE_CURLY_BRACE);
1655
1656 throw new NoSuchFileShortcutException(msg.toString());
1657 }
1658 else {
1659 return list.get(0);
1660 }
1661 }
1662
1663
1678 public DLFileShortcut findByG_F_S_Last(long groupId, long folderId,
1679 int status, OrderByComparator orderByComparator)
1680 throws NoSuchFileShortcutException, SystemException {
1681 int count = countByG_F_S(groupId, folderId, status);
1682
1683 List<DLFileShortcut> list = findByG_F_S(groupId, folderId, status,
1684 count - 1, count, orderByComparator);
1685
1686 if (list.isEmpty()) {
1687 StringBundler msg = new StringBundler(8);
1688
1689 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1690
1691 msg.append("groupId=");
1692 msg.append(groupId);
1693
1694 msg.append(", folderId=");
1695 msg.append(folderId);
1696
1697 msg.append(", status=");
1698 msg.append(status);
1699
1700 msg.append(StringPool.CLOSE_CURLY_BRACE);
1701
1702 throw new NoSuchFileShortcutException(msg.toString());
1703 }
1704 else {
1705 return list.get(0);
1706 }
1707 }
1708
1709
1725 public DLFileShortcut[] findByG_F_S_PrevAndNext(long fileShortcutId,
1726 long groupId, long folderId, int status,
1727 OrderByComparator orderByComparator)
1728 throws NoSuchFileShortcutException, SystemException {
1729 DLFileShortcut dlFileShortcut = findByPrimaryKey(fileShortcutId);
1730
1731 Session session = null;
1732
1733 try {
1734 session = openSession();
1735
1736 DLFileShortcut[] array = new DLFileShortcutImpl[3];
1737
1738 array[0] = getByG_F_S_PrevAndNext(session, dlFileShortcut, groupId,
1739 folderId, status, orderByComparator, true);
1740
1741 array[1] = dlFileShortcut;
1742
1743 array[2] = getByG_F_S_PrevAndNext(session, dlFileShortcut, groupId,
1744 folderId, status, orderByComparator, false);
1745
1746 return array;
1747 }
1748 catch (Exception e) {
1749 throw processException(e);
1750 }
1751 finally {
1752 closeSession(session);
1753 }
1754 }
1755
1756 protected DLFileShortcut getByG_F_S_PrevAndNext(Session session,
1757 DLFileShortcut dlFileShortcut, long groupId, long folderId, int status,
1758 OrderByComparator orderByComparator, boolean previous) {
1759 StringBundler query = null;
1760
1761 if (orderByComparator != null) {
1762 query = new StringBundler(6 +
1763 (orderByComparator.getOrderByFields().length * 6));
1764 }
1765 else {
1766 query = new StringBundler(3);
1767 }
1768
1769 query.append(_SQL_SELECT_DLFILESHORTCUT_WHERE);
1770
1771 query.append(_FINDER_COLUMN_G_F_S_GROUPID_2);
1772
1773 query.append(_FINDER_COLUMN_G_F_S_FOLDERID_2);
1774
1775 query.append(_FINDER_COLUMN_G_F_S_STATUS_2);
1776
1777 if (orderByComparator != null) {
1778 String[] orderByFields = orderByComparator.getOrderByFields();
1779
1780 if (orderByFields.length > 0) {
1781 query.append(WHERE_AND);
1782 }
1783
1784 for (int i = 0; i < orderByFields.length; i++) {
1785 query.append(_ORDER_BY_ENTITY_ALIAS);
1786 query.append(orderByFields[i]);
1787
1788 if ((i + 1) < orderByFields.length) {
1789 if (orderByComparator.isAscending() ^ previous) {
1790 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1791 }
1792 else {
1793 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1794 }
1795 }
1796 else {
1797 if (orderByComparator.isAscending() ^ previous) {
1798 query.append(WHERE_GREATER_THAN);
1799 }
1800 else {
1801 query.append(WHERE_LESSER_THAN);
1802 }
1803 }
1804 }
1805
1806 query.append(ORDER_BY_CLAUSE);
1807
1808 for (int i = 0; i < orderByFields.length; i++) {
1809 query.append(_ORDER_BY_ENTITY_ALIAS);
1810 query.append(orderByFields[i]);
1811
1812 if ((i + 1) < orderByFields.length) {
1813 if (orderByComparator.isAscending() ^ previous) {
1814 query.append(ORDER_BY_ASC_HAS_NEXT);
1815 }
1816 else {
1817 query.append(ORDER_BY_DESC_HAS_NEXT);
1818 }
1819 }
1820 else {
1821 if (orderByComparator.isAscending() ^ previous) {
1822 query.append(ORDER_BY_ASC);
1823 }
1824 else {
1825 query.append(ORDER_BY_DESC);
1826 }
1827 }
1828 }
1829 }
1830
1831 String sql = query.toString();
1832
1833 Query q = session.createQuery(sql);
1834
1835 q.setFirstResult(0);
1836 q.setMaxResults(2);
1837
1838 QueryPos qPos = QueryPos.getInstance(q);
1839
1840 qPos.add(groupId);
1841
1842 qPos.add(folderId);
1843
1844 qPos.add(status);
1845
1846 if (orderByComparator != null) {
1847 Object[] values = orderByComparator.getOrderByValues(dlFileShortcut);
1848
1849 for (Object value : values) {
1850 qPos.add(value);
1851 }
1852 }
1853
1854 List<DLFileShortcut> list = q.list();
1855
1856 if (list.size() == 2) {
1857 return list.get(1);
1858 }
1859 else {
1860 return null;
1861 }
1862 }
1863
1864
1873 public List<DLFileShortcut> filterFindByG_F_S(long groupId, long folderId,
1874 int status) throws SystemException {
1875 return filterFindByG_F_S(groupId, folderId, status, QueryUtil.ALL_POS,
1876 QueryUtil.ALL_POS, null);
1877 }
1878
1879
1894 public List<DLFileShortcut> filterFindByG_F_S(long groupId, long folderId,
1895 int status, int start, int end) throws SystemException {
1896 return filterFindByG_F_S(groupId, folderId, status, start, end, null);
1897 }
1898
1899
1915 public List<DLFileShortcut> filterFindByG_F_S(long groupId, long folderId,
1916 int status, int start, int end, OrderByComparator orderByComparator)
1917 throws SystemException {
1918 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
1919 return findByG_F_S(groupId, folderId, status, start, end,
1920 orderByComparator);
1921 }
1922
1923 Session session = null;
1924
1925 try {
1926 session = openSession();
1927
1928 StringBundler query = null;
1929
1930 if (orderByComparator != null) {
1931 query = new StringBundler(5 +
1932 (orderByComparator.getOrderByFields().length * 3));
1933 }
1934 else {
1935 query = new StringBundler(4);
1936 }
1937
1938 query.append(_FILTER_SQL_SELECT_DLFILESHORTCUT_WHERE);
1939
1940 query.append(_FINDER_COLUMN_G_F_S_GROUPID_2);
1941
1942 query.append(_FINDER_COLUMN_G_F_S_FOLDERID_2);
1943
1944 query.append(_FINDER_COLUMN_G_F_S_STATUS_2);
1945
1946 if (orderByComparator != null) {
1947 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1948 orderByComparator);
1949 }
1950
1951 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1952 DLFileShortcut.class.getName(), _FILTER_COLUMN_PK,
1953 _FILTER_COLUMN_USERID, groupId);
1954
1955 SQLQuery q = session.createSQLQuery(sql);
1956
1957 q.addEntity(_FILTER_ENTITY_ALIAS, DLFileShortcutImpl.class);
1958
1959 QueryPos qPos = QueryPos.getInstance(q);
1960
1961 qPos.add(groupId);
1962
1963 qPos.add(folderId);
1964
1965 qPos.add(status);
1966
1967 return (List<DLFileShortcut>)QueryUtil.list(q, getDialect(), start,
1968 end);
1969 }
1970 catch (Exception e) {
1971 throw processException(e);
1972 }
1973 finally {
1974 closeSession(session);
1975 }
1976 }
1977
1978
1987 public List<DLFileShortcut> findByG_TF_TN(long groupId, long toFolderId,
1988 String toName) throws SystemException {
1989 return findByG_TF_TN(groupId, toFolderId, toName, QueryUtil.ALL_POS,
1990 QueryUtil.ALL_POS, null);
1991 }
1992
1993
2008 public List<DLFileShortcut> findByG_TF_TN(long groupId, long toFolderId,
2009 String toName, int start, int end) throws SystemException {
2010 return findByG_TF_TN(groupId, toFolderId, toName, start, end, null);
2011 }
2012
2013
2029 public List<DLFileShortcut> findByG_TF_TN(long groupId, long toFolderId,
2030 String toName, int start, int end, OrderByComparator orderByComparator)
2031 throws SystemException {
2032 Object[] finderArgs = new Object[] {
2033 groupId, toFolderId, toName,
2034
2035 String.valueOf(start), String.valueOf(end),
2036 String.valueOf(orderByComparator)
2037 };
2038
2039 List<DLFileShortcut> list = (List<DLFileShortcut>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_G_TF_TN,
2040 finderArgs, this);
2041
2042 if (list == null) {
2043 Session session = null;
2044
2045 try {
2046 session = openSession();
2047
2048 StringBundler query = null;
2049
2050 if (orderByComparator != null) {
2051 query = new StringBundler(5 +
2052 (orderByComparator.getOrderByFields().length * 3));
2053 }
2054 else {
2055 query = new StringBundler(4);
2056 }
2057
2058 query.append(_SQL_SELECT_DLFILESHORTCUT_WHERE);
2059
2060 query.append(_FINDER_COLUMN_G_TF_TN_GROUPID_2);
2061
2062 query.append(_FINDER_COLUMN_G_TF_TN_TOFOLDERID_2);
2063
2064 if (toName == null) {
2065 query.append(_FINDER_COLUMN_G_TF_TN_TONAME_1);
2066 }
2067 else {
2068 if (toName.equals(StringPool.BLANK)) {
2069 query.append(_FINDER_COLUMN_G_TF_TN_TONAME_3);
2070 }
2071 else {
2072 query.append(_FINDER_COLUMN_G_TF_TN_TONAME_2);
2073 }
2074 }
2075
2076 if (orderByComparator != null) {
2077 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2078 orderByComparator);
2079 }
2080
2081 String sql = query.toString();
2082
2083 Query q = session.createQuery(sql);
2084
2085 QueryPos qPos = QueryPos.getInstance(q);
2086
2087 qPos.add(groupId);
2088
2089 qPos.add(toFolderId);
2090
2091 if (toName != null) {
2092 qPos.add(toName);
2093 }
2094
2095 list = (List<DLFileShortcut>)QueryUtil.list(q, getDialect(),
2096 start, end);
2097 }
2098 catch (Exception e) {
2099 throw processException(e);
2100 }
2101 finally {
2102 if (list == null) {
2103 list = new ArrayList<DLFileShortcut>();
2104 }
2105
2106 cacheResult(list);
2107
2108 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_G_TF_TN,
2109 finderArgs, list);
2110
2111 closeSession(session);
2112 }
2113 }
2114
2115 return list;
2116 }
2117
2118
2133 public DLFileShortcut findByG_TF_TN_First(long groupId, long toFolderId,
2134 String toName, OrderByComparator orderByComparator)
2135 throws NoSuchFileShortcutException, SystemException {
2136 List<DLFileShortcut> list = findByG_TF_TN(groupId, toFolderId, toName,
2137 0, 1, orderByComparator);
2138
2139 if (list.isEmpty()) {
2140 StringBundler msg = new StringBundler(8);
2141
2142 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2143
2144 msg.append("groupId=");
2145 msg.append(groupId);
2146
2147 msg.append(", toFolderId=");
2148 msg.append(toFolderId);
2149
2150 msg.append(", toName=");
2151 msg.append(toName);
2152
2153 msg.append(StringPool.CLOSE_CURLY_BRACE);
2154
2155 throw new NoSuchFileShortcutException(msg.toString());
2156 }
2157 else {
2158 return list.get(0);
2159 }
2160 }
2161
2162
2177 public DLFileShortcut findByG_TF_TN_Last(long groupId, long toFolderId,
2178 String toName, OrderByComparator orderByComparator)
2179 throws NoSuchFileShortcutException, SystemException {
2180 int count = countByG_TF_TN(groupId, toFolderId, toName);
2181
2182 List<DLFileShortcut> list = findByG_TF_TN(groupId, toFolderId, toName,
2183 count - 1, count, orderByComparator);
2184
2185 if (list.isEmpty()) {
2186 StringBundler msg = new StringBundler(8);
2187
2188 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2189
2190 msg.append("groupId=");
2191 msg.append(groupId);
2192
2193 msg.append(", toFolderId=");
2194 msg.append(toFolderId);
2195
2196 msg.append(", toName=");
2197 msg.append(toName);
2198
2199 msg.append(StringPool.CLOSE_CURLY_BRACE);
2200
2201 throw new NoSuchFileShortcutException(msg.toString());
2202 }
2203 else {
2204 return list.get(0);
2205 }
2206 }
2207
2208
2224 public DLFileShortcut[] findByG_TF_TN_PrevAndNext(long fileShortcutId,
2225 long groupId, long toFolderId, String toName,
2226 OrderByComparator orderByComparator)
2227 throws NoSuchFileShortcutException, SystemException {
2228 DLFileShortcut dlFileShortcut = findByPrimaryKey(fileShortcutId);
2229
2230 Session session = null;
2231
2232 try {
2233 session = openSession();
2234
2235 DLFileShortcut[] array = new DLFileShortcutImpl[3];
2236
2237 array[0] = getByG_TF_TN_PrevAndNext(session, dlFileShortcut,
2238 groupId, toFolderId, toName, orderByComparator, true);
2239
2240 array[1] = dlFileShortcut;
2241
2242 array[2] = getByG_TF_TN_PrevAndNext(session, dlFileShortcut,
2243 groupId, toFolderId, toName, orderByComparator, false);
2244
2245 return array;
2246 }
2247 catch (Exception e) {
2248 throw processException(e);
2249 }
2250 finally {
2251 closeSession(session);
2252 }
2253 }
2254
2255 protected DLFileShortcut getByG_TF_TN_PrevAndNext(Session session,
2256 DLFileShortcut dlFileShortcut, long groupId, long toFolderId,
2257 String toName, OrderByComparator orderByComparator, boolean previous) {
2258 StringBundler query = null;
2259
2260 if (orderByComparator != null) {
2261 query = new StringBundler(6 +
2262 (orderByComparator.getOrderByFields().length * 6));
2263 }
2264 else {
2265 query = new StringBundler(3);
2266 }
2267
2268 query.append(_SQL_SELECT_DLFILESHORTCUT_WHERE);
2269
2270 query.append(_FINDER_COLUMN_G_TF_TN_GROUPID_2);
2271
2272 query.append(_FINDER_COLUMN_G_TF_TN_TOFOLDERID_2);
2273
2274 if (toName == null) {
2275 query.append(_FINDER_COLUMN_G_TF_TN_TONAME_1);
2276 }
2277 else {
2278 if (toName.equals(StringPool.BLANK)) {
2279 query.append(_FINDER_COLUMN_G_TF_TN_TONAME_3);
2280 }
2281 else {
2282 query.append(_FINDER_COLUMN_G_TF_TN_TONAME_2);
2283 }
2284 }
2285
2286 if (orderByComparator != null) {
2287 String[] orderByFields = orderByComparator.getOrderByFields();
2288
2289 if (orderByFields.length > 0) {
2290 query.append(WHERE_AND);
2291 }
2292
2293 for (int i = 0; i < orderByFields.length; i++) {
2294 query.append(_ORDER_BY_ENTITY_ALIAS);
2295 query.append(orderByFields[i]);
2296
2297 if ((i + 1) < orderByFields.length) {
2298 if (orderByComparator.isAscending() ^ previous) {
2299 query.append(WHERE_GREATER_THAN_HAS_NEXT);
2300 }
2301 else {
2302 query.append(WHERE_LESSER_THAN_HAS_NEXT);
2303 }
2304 }
2305 else {
2306 if (orderByComparator.isAscending() ^ previous) {
2307 query.append(WHERE_GREATER_THAN);
2308 }
2309 else {
2310 query.append(WHERE_LESSER_THAN);
2311 }
2312 }
2313 }
2314
2315 query.append(ORDER_BY_CLAUSE);
2316
2317 for (int i = 0; i < orderByFields.length; i++) {
2318 query.append(_ORDER_BY_ENTITY_ALIAS);
2319 query.append(orderByFields[i]);
2320
2321 if ((i + 1) < orderByFields.length) {
2322 if (orderByComparator.isAscending() ^ previous) {
2323 query.append(ORDER_BY_ASC_HAS_NEXT);
2324 }
2325 else {
2326 query.append(ORDER_BY_DESC_HAS_NEXT);
2327 }
2328 }
2329 else {
2330 if (orderByComparator.isAscending() ^ previous) {
2331 query.append(ORDER_BY_ASC);
2332 }
2333 else {
2334 query.append(ORDER_BY_DESC);
2335 }
2336 }
2337 }
2338 }
2339
2340 String sql = query.toString();
2341
2342 Query q = session.createQuery(sql);
2343
2344 q.setFirstResult(0);
2345 q.setMaxResults(2);
2346
2347 QueryPos qPos = QueryPos.getInstance(q);
2348
2349 qPos.add(groupId);
2350
2351 qPos.add(toFolderId);
2352
2353 if (toName != null) {
2354 qPos.add(toName);
2355 }
2356
2357 if (orderByComparator != null) {
2358 Object[] values = orderByComparator.getOrderByValues(dlFileShortcut);
2359
2360 for (Object value : values) {
2361 qPos.add(value);
2362 }
2363 }
2364
2365 List<DLFileShortcut> list = q.list();
2366
2367 if (list.size() == 2) {
2368 return list.get(1);
2369 }
2370 else {
2371 return null;
2372 }
2373 }
2374
2375
2384 public List<DLFileShortcut> filterFindByG_TF_TN(long groupId,
2385 long toFolderId, String toName) throws SystemException {
2386 return filterFindByG_TF_TN(groupId, toFolderId, toName,
2387 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
2388 }
2389
2390
2405 public List<DLFileShortcut> filterFindByG_TF_TN(long groupId,
2406 long toFolderId, String toName, int start, int end)
2407 throws SystemException {
2408 return filterFindByG_TF_TN(groupId, toFolderId, toName, start, end, null);
2409 }
2410
2411
2427 public List<DLFileShortcut> filterFindByG_TF_TN(long groupId,
2428 long toFolderId, String toName, int start, int end,
2429 OrderByComparator orderByComparator) throws SystemException {
2430 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2431 return findByG_TF_TN(groupId, toFolderId, toName, start, end,
2432 orderByComparator);
2433 }
2434
2435 Session session = null;
2436
2437 try {
2438 session = openSession();
2439
2440 StringBundler query = null;
2441
2442 if (orderByComparator != null) {
2443 query = new StringBundler(5 +
2444 (orderByComparator.getOrderByFields().length * 3));
2445 }
2446 else {
2447 query = new StringBundler(4);
2448 }
2449
2450 query.append(_FILTER_SQL_SELECT_DLFILESHORTCUT_WHERE);
2451
2452 query.append(_FINDER_COLUMN_G_TF_TN_GROUPID_2);
2453
2454 query.append(_FINDER_COLUMN_G_TF_TN_TOFOLDERID_2);
2455
2456 if (toName == null) {
2457 query.append(_FINDER_COLUMN_G_TF_TN_TONAME_1);
2458 }
2459 else {
2460 if (toName.equals(StringPool.BLANK)) {
2461 query.append(_FINDER_COLUMN_G_TF_TN_TONAME_3);
2462 }
2463 else {
2464 query.append(_FINDER_COLUMN_G_TF_TN_TONAME_2);
2465 }
2466 }
2467
2468 if (orderByComparator != null) {
2469 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2470 orderByComparator);
2471 }
2472
2473 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2474 DLFileShortcut.class.getName(), _FILTER_COLUMN_PK,
2475 _FILTER_COLUMN_USERID, groupId);
2476
2477 SQLQuery q = session.createSQLQuery(sql);
2478
2479 q.addEntity(_FILTER_ENTITY_ALIAS, DLFileShortcutImpl.class);
2480
2481 QueryPos qPos = QueryPos.getInstance(q);
2482
2483 qPos.add(groupId);
2484
2485 qPos.add(toFolderId);
2486
2487 if (toName != null) {
2488 qPos.add(toName);
2489 }
2490
2491 return (List<DLFileShortcut>)QueryUtil.list(q, getDialect(), start,
2492 end);
2493 }
2494 catch (Exception e) {
2495 throw processException(e);
2496 }
2497 finally {
2498 closeSession(session);
2499 }
2500 }
2501
2502
2512 public List<DLFileShortcut> findByG_TF_TN_S(long groupId, long toFolderId,
2513 String toName, int status) throws SystemException {
2514 return findByG_TF_TN_S(groupId, toFolderId, toName, status,
2515 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
2516 }
2517
2518
2534 public List<DLFileShortcut> findByG_TF_TN_S(long groupId, long toFolderId,
2535 String toName, int status, int start, int end)
2536 throws SystemException {
2537 return findByG_TF_TN_S(groupId, toFolderId, toName, status, start, end,
2538 null);
2539 }
2540
2541
2558 public List<DLFileShortcut> findByG_TF_TN_S(long groupId, long toFolderId,
2559 String toName, int status, int start, int end,
2560 OrderByComparator orderByComparator) throws SystemException {
2561 Object[] finderArgs = new Object[] {
2562 groupId, toFolderId, toName, status,
2563
2564 String.valueOf(start), String.valueOf(end),
2565 String.valueOf(orderByComparator)
2566 };
2567
2568 List<DLFileShortcut> list = (List<DLFileShortcut>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_G_TF_TN_S,
2569 finderArgs, this);
2570
2571 if (list == null) {
2572 Session session = null;
2573
2574 try {
2575 session = openSession();
2576
2577 StringBundler query = null;
2578
2579 if (orderByComparator != null) {
2580 query = new StringBundler(6 +
2581 (orderByComparator.getOrderByFields().length * 3));
2582 }
2583 else {
2584 query = new StringBundler(5);
2585 }
2586
2587 query.append(_SQL_SELECT_DLFILESHORTCUT_WHERE);
2588
2589 query.append(_FINDER_COLUMN_G_TF_TN_S_GROUPID_2);
2590
2591 query.append(_FINDER_COLUMN_G_TF_TN_S_TOFOLDERID_2);
2592
2593 if (toName == null) {
2594 query.append(_FINDER_COLUMN_G_TF_TN_S_TONAME_1);
2595 }
2596 else {
2597 if (toName.equals(StringPool.BLANK)) {
2598 query.append(_FINDER_COLUMN_G_TF_TN_S_TONAME_3);
2599 }
2600 else {
2601 query.append(_FINDER_COLUMN_G_TF_TN_S_TONAME_2);
2602 }
2603 }
2604
2605 query.append(_FINDER_COLUMN_G_TF_TN_S_STATUS_2);
2606
2607 if (orderByComparator != null) {
2608 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2609 orderByComparator);
2610 }
2611
2612 String sql = query.toString();
2613
2614 Query q = session.createQuery(sql);
2615
2616 QueryPos qPos = QueryPos.getInstance(q);
2617
2618 qPos.add(groupId);
2619
2620 qPos.add(toFolderId);
2621
2622 if (toName != null) {
2623 qPos.add(toName);
2624 }
2625
2626 qPos.add(status);
2627
2628 list = (List<DLFileShortcut>)QueryUtil.list(q, getDialect(),
2629 start, end);
2630 }
2631 catch (Exception e) {
2632 throw processException(e);
2633 }
2634 finally {
2635 if (list == null) {
2636 list = new ArrayList<DLFileShortcut>();
2637 }
2638
2639 cacheResult(list);
2640
2641 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_G_TF_TN_S,
2642 finderArgs, list);
2643
2644 closeSession(session);
2645 }
2646 }
2647
2648 return list;
2649 }
2650
2651
2667 public DLFileShortcut findByG_TF_TN_S_First(long groupId, long toFolderId,
2668 String toName, int status, OrderByComparator orderByComparator)
2669 throws NoSuchFileShortcutException, SystemException {
2670 List<DLFileShortcut> list = findByG_TF_TN_S(groupId, toFolderId,
2671 toName, status, 0, 1, orderByComparator);
2672
2673 if (list.isEmpty()) {
2674 StringBundler msg = new StringBundler(10);
2675
2676 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2677
2678 msg.append("groupId=");
2679 msg.append(groupId);
2680
2681 msg.append(", toFolderId=");
2682 msg.append(toFolderId);
2683
2684 msg.append(", toName=");
2685 msg.append(toName);
2686
2687 msg.append(", status=");
2688 msg.append(status);
2689
2690 msg.append(StringPool.CLOSE_CURLY_BRACE);
2691
2692 throw new NoSuchFileShortcutException(msg.toString());
2693 }
2694 else {
2695 return list.get(0);
2696 }
2697 }
2698
2699
2715 public DLFileShortcut findByG_TF_TN_S_Last(long groupId, long toFolderId,
2716 String toName, int status, OrderByComparator orderByComparator)
2717 throws NoSuchFileShortcutException, SystemException {
2718 int count = countByG_TF_TN_S(groupId, toFolderId, toName, status);
2719
2720 List<DLFileShortcut> list = findByG_TF_TN_S(groupId, toFolderId,
2721 toName, status, count - 1, count, orderByComparator);
2722
2723 if (list.isEmpty()) {
2724 StringBundler msg = new StringBundler(10);
2725
2726 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2727
2728 msg.append("groupId=");
2729 msg.append(groupId);
2730
2731 msg.append(", toFolderId=");
2732 msg.append(toFolderId);
2733
2734 msg.append(", toName=");
2735 msg.append(toName);
2736
2737 msg.append(", status=");
2738 msg.append(status);
2739
2740 msg.append(StringPool.CLOSE_CURLY_BRACE);
2741
2742 throw new NoSuchFileShortcutException(msg.toString());
2743 }
2744 else {
2745 return list.get(0);
2746 }
2747 }
2748
2749
2766 public DLFileShortcut[] findByG_TF_TN_S_PrevAndNext(long fileShortcutId,
2767 long groupId, long toFolderId, String toName, int status,
2768 OrderByComparator orderByComparator)
2769 throws NoSuchFileShortcutException, SystemException {
2770 DLFileShortcut dlFileShortcut = findByPrimaryKey(fileShortcutId);
2771
2772 Session session = null;
2773
2774 try {
2775 session = openSession();
2776
2777 DLFileShortcut[] array = new DLFileShortcutImpl[3];
2778
2779 array[0] = getByG_TF_TN_S_PrevAndNext(session, dlFileShortcut,
2780 groupId, toFolderId, toName, status, orderByComparator, true);
2781
2782 array[1] = dlFileShortcut;
2783
2784 array[2] = getByG_TF_TN_S_PrevAndNext(session, dlFileShortcut,
2785 groupId, toFolderId, toName, status, orderByComparator,
2786 false);
2787
2788 return array;
2789 }
2790 catch (Exception e) {
2791 throw processException(e);
2792 }
2793 finally {
2794 closeSession(session);
2795 }
2796 }
2797
2798 protected DLFileShortcut getByG_TF_TN_S_PrevAndNext(Session session,
2799 DLFileShortcut dlFileShortcut, long groupId, long toFolderId,
2800 String toName, int status, OrderByComparator orderByComparator,
2801 boolean previous) {
2802 StringBundler query = null;
2803
2804 if (orderByComparator != null) {
2805 query = new StringBundler(6 +
2806 (orderByComparator.getOrderByFields().length * 6));
2807 }
2808 else {
2809 query = new StringBundler(3);
2810 }
2811
2812 query.append(_SQL_SELECT_DLFILESHORTCUT_WHERE);
2813
2814 query.append(_FINDER_COLUMN_G_TF_TN_S_GROUPID_2);
2815
2816 query.append(_FINDER_COLUMN_G_TF_TN_S_TOFOLDERID_2);
2817
2818 if (toName == null) {
2819 query.append(_FINDER_COLUMN_G_TF_TN_S_TONAME_1);
2820 }
2821 else {
2822 if (toName.equals(StringPool.BLANK)) {
2823 query.append(_FINDER_COLUMN_G_TF_TN_S_TONAME_3);
2824 }
2825 else {
2826 query.append(_FINDER_COLUMN_G_TF_TN_S_TONAME_2);
2827 }
2828 }
2829
2830 query.append(_FINDER_COLUMN_G_TF_TN_S_STATUS_2);
2831
2832 if (orderByComparator != null) {
2833 String[] orderByFields = orderByComparator.getOrderByFields();
2834
2835 if (orderByFields.length > 0) {
2836 query.append(WHERE_AND);
2837 }
2838
2839 for (int i = 0; i < orderByFields.length; i++) {
2840 query.append(_ORDER_BY_ENTITY_ALIAS);
2841 query.append(orderByFields[i]);
2842
2843 if ((i + 1) < orderByFields.length) {
2844 if (orderByComparator.isAscending() ^ previous) {
2845 query.append(WHERE_GREATER_THAN_HAS_NEXT);
2846 }
2847 else {
2848 query.append(WHERE_LESSER_THAN_HAS_NEXT);
2849 }
2850 }
2851 else {
2852 if (orderByComparator.isAscending() ^ previous) {
2853 query.append(WHERE_GREATER_THAN);
2854 }
2855 else {
2856 query.append(WHERE_LESSER_THAN);
2857 }
2858 }
2859 }
2860
2861 query.append(ORDER_BY_CLAUSE);
2862
2863 for (int i = 0; i < orderByFields.length; i++) {
2864 query.append(_ORDER_BY_ENTITY_ALIAS);
2865 query.append(orderByFields[i]);
2866
2867 if ((i + 1) < orderByFields.length) {
2868 if (orderByComparator.isAscending() ^ previous) {
2869 query.append(ORDER_BY_ASC_HAS_NEXT);
2870 }
2871 else {
2872 query.append(ORDER_BY_DESC_HAS_NEXT);
2873 }
2874 }
2875 else {
2876 if (orderByComparator.isAscending() ^ previous) {
2877 query.append(ORDER_BY_ASC);
2878 }
2879 else {
2880 query.append(ORDER_BY_DESC);
2881 }
2882 }
2883 }
2884 }
2885
2886 String sql = query.toString();
2887
2888 Query q = session.createQuery(sql);
2889
2890 q.setFirstResult(0);
2891 q.setMaxResults(2);
2892
2893 QueryPos qPos = QueryPos.getInstance(q);
2894
2895 qPos.add(groupId);
2896
2897 qPos.add(toFolderId);
2898
2899 if (toName != null) {
2900 qPos.add(toName);
2901 }
2902
2903 qPos.add(status);
2904
2905 if (orderByComparator != null) {
2906 Object[] values = orderByComparator.getOrderByValues(dlFileShortcut);
2907
2908 for (Object value : values) {
2909 qPos.add(value);
2910 }
2911 }
2912
2913 List<DLFileShortcut> list = q.list();
2914
2915 if (list.size() == 2) {
2916 return list.get(1);
2917 }
2918 else {
2919 return null;
2920 }
2921 }
2922
2923
2933 public List<DLFileShortcut> filterFindByG_TF_TN_S(long groupId,
2934 long toFolderId, String toName, int status) throws SystemException {
2935 return filterFindByG_TF_TN_S(groupId, toFolderId, toName, status,
2936 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
2937 }
2938
2939
2955 public List<DLFileShortcut> filterFindByG_TF_TN_S(long groupId,
2956 long toFolderId, String toName, int status, int start, int end)
2957 throws SystemException {
2958 return filterFindByG_TF_TN_S(groupId, toFolderId, toName, status,
2959 start, end, null);
2960 }
2961
2962
2979 public List<DLFileShortcut> filterFindByG_TF_TN_S(long groupId,
2980 long toFolderId, String toName, int status, int start, int end,
2981 OrderByComparator orderByComparator) throws SystemException {
2982 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2983 return findByG_TF_TN_S(groupId, toFolderId, toName, status, start,
2984 end, orderByComparator);
2985 }
2986
2987 Session session = null;
2988
2989 try {
2990 session = openSession();
2991
2992 StringBundler query = null;
2993
2994 if (orderByComparator != null) {
2995 query = new StringBundler(6 +
2996 (orderByComparator.getOrderByFields().length * 3));
2997 }
2998 else {
2999 query = new StringBundler(5);
3000 }
3001
3002 query.append(_FILTER_SQL_SELECT_DLFILESHORTCUT_WHERE);
3003
3004 query.append(_FINDER_COLUMN_G_TF_TN_S_GROUPID_2);
3005
3006 query.append(_FINDER_COLUMN_G_TF_TN_S_TOFOLDERID_2);
3007
3008 if (toName == null) {
3009 query.append(_FINDER_COLUMN_G_TF_TN_S_TONAME_1);
3010 }
3011 else {
3012 if (toName.equals(StringPool.BLANK)) {
3013 query.append(_FINDER_COLUMN_G_TF_TN_S_TONAME_3);
3014 }
3015 else {
3016 query.append(_FINDER_COLUMN_G_TF_TN_S_TONAME_2);
3017 }
3018 }
3019
3020 query.append(_FINDER_COLUMN_G_TF_TN_S_STATUS_2);
3021
3022 if (orderByComparator != null) {
3023 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3024 orderByComparator);
3025 }
3026
3027 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
3028 DLFileShortcut.class.getName(), _FILTER_COLUMN_PK,
3029 _FILTER_COLUMN_USERID, groupId);
3030
3031 SQLQuery q = session.createSQLQuery(sql);
3032
3033 q.addEntity(_FILTER_ENTITY_ALIAS, DLFileShortcutImpl.class);
3034
3035 QueryPos qPos = QueryPos.getInstance(q);
3036
3037 qPos.add(groupId);
3038
3039 qPos.add(toFolderId);
3040
3041 if (toName != null) {
3042 qPos.add(toName);
3043 }
3044
3045 qPos.add(status);
3046
3047 return (List<DLFileShortcut>)QueryUtil.list(q, getDialect(), start,
3048 end);
3049 }
3050 catch (Exception e) {
3051 throw processException(e);
3052 }
3053 finally {
3054 closeSession(session);
3055 }
3056 }
3057
3058
3064 public List<DLFileShortcut> findAll() throws SystemException {
3065 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
3066 }
3067
3068
3080 public List<DLFileShortcut> findAll(int start, int end)
3081 throws SystemException {
3082 return findAll(start, end, null);
3083 }
3084
3085
3098 public List<DLFileShortcut> findAll(int start, int end,
3099 OrderByComparator orderByComparator) throws SystemException {
3100 Object[] finderArgs = new Object[] {
3101 String.valueOf(start), String.valueOf(end),
3102 String.valueOf(orderByComparator)
3103 };
3104
3105 List<DLFileShortcut> list = (List<DLFileShortcut>)FinderCacheUtil.getResult(FINDER_PATH_FIND_ALL,
3106 finderArgs, this);
3107
3108 if (list == null) {
3109 Session session = null;
3110
3111 try {
3112 session = openSession();
3113
3114 StringBundler query = null;
3115 String sql = null;
3116
3117 if (orderByComparator != null) {
3118 query = new StringBundler(2 +
3119 (orderByComparator.getOrderByFields().length * 3));
3120
3121 query.append(_SQL_SELECT_DLFILESHORTCUT);
3122
3123 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3124 orderByComparator);
3125
3126 sql = query.toString();
3127 }
3128 else {
3129 sql = _SQL_SELECT_DLFILESHORTCUT;
3130 }
3131
3132 Query q = session.createQuery(sql);
3133
3134 if (orderByComparator == null) {
3135 list = (List<DLFileShortcut>)QueryUtil.list(q,
3136 getDialect(), start, end, false);
3137
3138 Collections.sort(list);
3139 }
3140 else {
3141 list = (List<DLFileShortcut>)QueryUtil.list(q,
3142 getDialect(), start, end);
3143 }
3144 }
3145 catch (Exception e) {
3146 throw processException(e);
3147 }
3148 finally {
3149 if (list == null) {
3150 list = new ArrayList<DLFileShortcut>();
3151 }
3152
3153 cacheResult(list);
3154
3155 FinderCacheUtil.putResult(FINDER_PATH_FIND_ALL, finderArgs, list);
3156
3157 closeSession(session);
3158 }
3159 }
3160
3161 return list;
3162 }
3163
3164
3170 public void removeByUuid(String uuid) throws SystemException {
3171 for (DLFileShortcut dlFileShortcut : findByUuid(uuid)) {
3172 remove(dlFileShortcut);
3173 }
3174 }
3175
3176
3183 public void removeByUUID_G(String uuid, long groupId)
3184 throws NoSuchFileShortcutException, SystemException {
3185 DLFileShortcut dlFileShortcut = findByUUID_G(uuid, groupId);
3186
3187 remove(dlFileShortcut);
3188 }
3189
3190
3197 public void removeByG_F(long groupId, long folderId)
3198 throws SystemException {
3199 for (DLFileShortcut dlFileShortcut : findByG_F(groupId, folderId)) {
3200 remove(dlFileShortcut);
3201 }
3202 }
3203
3204
3212 public void removeByG_F_S(long groupId, long folderId, int status)
3213 throws SystemException {
3214 for (DLFileShortcut dlFileShortcut : findByG_F_S(groupId, folderId,
3215 status)) {
3216 remove(dlFileShortcut);
3217 }
3218 }
3219
3220
3228 public void removeByG_TF_TN(long groupId, long toFolderId, String toName)
3229 throws SystemException {
3230 for (DLFileShortcut dlFileShortcut : findByG_TF_TN(groupId, toFolderId,
3231 toName)) {
3232 remove(dlFileShortcut);
3233 }
3234 }
3235
3236
3245 public void removeByG_TF_TN_S(long groupId, long toFolderId, String toName,
3246 int status) throws SystemException {
3247 for (DLFileShortcut dlFileShortcut : findByG_TF_TN_S(groupId,
3248 toFolderId, toName, status)) {
3249 remove(dlFileShortcut);
3250 }
3251 }
3252
3253
3258 public void removeAll() throws SystemException {
3259 for (DLFileShortcut dlFileShortcut : findAll()) {
3260 remove(dlFileShortcut);
3261 }
3262 }
3263
3264
3271 public int countByUuid(String uuid) throws SystemException {
3272 Object[] finderArgs = new Object[] { uuid };
3273
3274 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID,
3275 finderArgs, this);
3276
3277 if (count == null) {
3278 Session session = null;
3279
3280 try {
3281 session = openSession();
3282
3283 StringBundler query = new StringBundler(2);
3284
3285 query.append(_SQL_COUNT_DLFILESHORTCUT_WHERE);
3286
3287 if (uuid == null) {
3288 query.append(_FINDER_COLUMN_UUID_UUID_1);
3289 }
3290 else {
3291 if (uuid.equals(StringPool.BLANK)) {
3292 query.append(_FINDER_COLUMN_UUID_UUID_3);
3293 }
3294 else {
3295 query.append(_FINDER_COLUMN_UUID_UUID_2);
3296 }
3297 }
3298
3299 String sql = query.toString();
3300
3301 Query q = session.createQuery(sql);
3302
3303 QueryPos qPos = QueryPos.getInstance(q);
3304
3305 if (uuid != null) {
3306 qPos.add(uuid);
3307 }
3308
3309 count = (Long)q.uniqueResult();
3310 }
3311 catch (Exception e) {
3312 throw processException(e);
3313 }
3314 finally {
3315 if (count == null) {
3316 count = Long.valueOf(0);
3317 }
3318
3319 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID,
3320 finderArgs, count);
3321
3322 closeSession(session);
3323 }
3324 }
3325
3326 return count.intValue();
3327 }
3328
3329
3337 public int countByUUID_G(String uuid, long groupId)
3338 throws SystemException {
3339 Object[] finderArgs = new Object[] { uuid, groupId };
3340
3341 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID_G,
3342 finderArgs, this);
3343
3344 if (count == null) {
3345 Session session = null;
3346
3347 try {
3348 session = openSession();
3349
3350 StringBundler query = new StringBundler(3);
3351
3352 query.append(_SQL_COUNT_DLFILESHORTCUT_WHERE);
3353
3354 if (uuid == null) {
3355 query.append(_FINDER_COLUMN_UUID_G_UUID_1);
3356 }
3357 else {
3358 if (uuid.equals(StringPool.BLANK)) {
3359 query.append(_FINDER_COLUMN_UUID_G_UUID_3);
3360 }
3361 else {
3362 query.append(_FINDER_COLUMN_UUID_G_UUID_2);
3363 }
3364 }
3365
3366 query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
3367
3368 String sql = query.toString();
3369
3370 Query q = session.createQuery(sql);
3371
3372 QueryPos qPos = QueryPos.getInstance(q);
3373
3374 if (uuid != null) {
3375 qPos.add(uuid);
3376 }
3377
3378 qPos.add(groupId);
3379
3380 count = (Long)q.uniqueResult();
3381 }
3382 catch (Exception e) {
3383 throw processException(e);
3384 }
3385 finally {
3386 if (count == null) {
3387 count = Long.valueOf(0);
3388 }
3389
3390 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G,
3391 finderArgs, count);
3392
3393 closeSession(session);
3394 }
3395 }
3396
3397 return count.intValue();
3398 }
3399
3400
3408 public int countByG_F(long groupId, long folderId)
3409 throws SystemException {
3410 Object[] finderArgs = new Object[] { groupId, folderId };
3411
3412 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_F,
3413 finderArgs, this);
3414
3415 if (count == null) {
3416 Session session = null;
3417
3418 try {
3419 session = openSession();
3420
3421 StringBundler query = new StringBundler(3);
3422
3423 query.append(_SQL_COUNT_DLFILESHORTCUT_WHERE);
3424
3425 query.append(_FINDER_COLUMN_G_F_GROUPID_2);
3426
3427 query.append(_FINDER_COLUMN_G_F_FOLDERID_2);
3428
3429 String sql = query.toString();
3430
3431 Query q = session.createQuery(sql);
3432
3433 QueryPos qPos = QueryPos.getInstance(q);
3434
3435 qPos.add(groupId);
3436
3437 qPos.add(folderId);
3438
3439 count = (Long)q.uniqueResult();
3440 }
3441 catch (Exception e) {
3442 throw processException(e);
3443 }
3444 finally {
3445 if (count == null) {
3446 count = Long.valueOf(0);
3447 }
3448
3449 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_F, finderArgs,
3450 count);
3451
3452 closeSession(session);
3453 }
3454 }
3455
3456 return count.intValue();
3457 }
3458
3459
3467 public int filterCountByG_F(long groupId, long folderId)
3468 throws SystemException {
3469 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
3470 return countByG_F(groupId, folderId);
3471 }
3472
3473 Session session = null;
3474
3475 try {
3476 session = openSession();
3477
3478 StringBundler query = new StringBundler(3);
3479
3480 query.append(_FILTER_SQL_COUNT_DLFILESHORTCUT_WHERE);
3481
3482 query.append(_FINDER_COLUMN_G_F_GROUPID_2);
3483
3484 query.append(_FINDER_COLUMN_G_F_FOLDERID_2);
3485
3486 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
3487 DLFileShortcut.class.getName(), _FILTER_COLUMN_PK,
3488 _FILTER_COLUMN_USERID, groupId);
3489
3490 SQLQuery q = session.createSQLQuery(sql);
3491
3492 q.addScalar(COUNT_COLUMN_NAME,
3493 com.liferay.portal.kernel.dao.orm.Type.LONG);
3494
3495 QueryPos qPos = QueryPos.getInstance(q);
3496
3497 qPos.add(groupId);
3498
3499 qPos.add(folderId);
3500
3501 Long count = (Long)q.uniqueResult();
3502
3503 return count.intValue();
3504 }
3505 catch (Exception e) {
3506 throw processException(e);
3507 }
3508 finally {
3509 closeSession(session);
3510 }
3511 }
3512
3513
3522 public int countByG_F_S(long groupId, long folderId, int status)
3523 throws SystemException {
3524 Object[] finderArgs = new Object[] { groupId, folderId, status };
3525
3526 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_F_S,
3527 finderArgs, this);
3528
3529 if (count == null) {
3530 Session session = null;
3531
3532 try {
3533 session = openSession();
3534
3535 StringBundler query = new StringBundler(4);
3536
3537 query.append(_SQL_COUNT_DLFILESHORTCUT_WHERE);
3538
3539 query.append(_FINDER_COLUMN_G_F_S_GROUPID_2);
3540
3541 query.append(_FINDER_COLUMN_G_F_S_FOLDERID_2);
3542
3543 query.append(_FINDER_COLUMN_G_F_S_STATUS_2);
3544
3545 String sql = query.toString();
3546
3547 Query q = session.createQuery(sql);
3548
3549 QueryPos qPos = QueryPos.getInstance(q);
3550
3551 qPos.add(groupId);
3552
3553 qPos.add(folderId);
3554
3555 qPos.add(status);
3556
3557 count = (Long)q.uniqueResult();
3558 }
3559 catch (Exception e) {
3560 throw processException(e);
3561 }
3562 finally {
3563 if (count == null) {
3564 count = Long.valueOf(0);
3565 }
3566
3567 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_F_S,
3568 finderArgs, count);
3569
3570 closeSession(session);
3571 }
3572 }
3573
3574 return count.intValue();
3575 }
3576
3577
3586 public int filterCountByG_F_S(long groupId, long folderId, int status)
3587 throws SystemException {
3588 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
3589 return countByG_F_S(groupId, folderId, status);
3590 }
3591
3592 Session session = null;
3593
3594 try {
3595 session = openSession();
3596
3597 StringBundler query = new StringBundler(4);
3598
3599 query.append(_FILTER_SQL_COUNT_DLFILESHORTCUT_WHERE);
3600
3601 query.append(_FINDER_COLUMN_G_F_S_GROUPID_2);
3602
3603 query.append(_FINDER_COLUMN_G_F_S_FOLDERID_2);
3604
3605 query.append(_FINDER_COLUMN_G_F_S_STATUS_2);
3606
3607 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
3608 DLFileShortcut.class.getName(), _FILTER_COLUMN_PK,
3609 _FILTER_COLUMN_USERID, groupId);
3610
3611 SQLQuery q = session.createSQLQuery(sql);
3612
3613 q.addScalar(COUNT_COLUMN_NAME,
3614 com.liferay.portal.kernel.dao.orm.Type.LONG);
3615
3616 QueryPos qPos = QueryPos.getInstance(q);
3617
3618 qPos.add(groupId);
3619
3620 qPos.add(folderId);
3621
3622 qPos.add(status);
3623
3624 Long count = (Long)q.uniqueResult();
3625
3626 return count.intValue();
3627 }
3628 catch (Exception e) {
3629 throw processException(e);
3630 }
3631 finally {
3632 closeSession(session);
3633 }
3634 }
3635
3636
3645 public int countByG_TF_TN(long groupId, long toFolderId, String toName)
3646 throws SystemException {
3647 Object[] finderArgs = new Object[] { groupId, toFolderId, toName };
3648
3649 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_TF_TN,
3650 finderArgs, this);
3651
3652 if (count == null) {
3653 Session session = null;
3654
3655 try {
3656 session = openSession();
3657
3658 StringBundler query = new StringBundler(4);
3659
3660 query.append(_SQL_COUNT_DLFILESHORTCUT_WHERE);
3661
3662 query.append(_FINDER_COLUMN_G_TF_TN_GROUPID_2);
3663
3664 query.append(_FINDER_COLUMN_G_TF_TN_TOFOLDERID_2);
3665
3666 if (toName == null) {
3667 query.append(_FINDER_COLUMN_G_TF_TN_TONAME_1);
3668 }
3669 else {
3670 if (toName.equals(StringPool.BLANK)) {
3671 query.append(_FINDER_COLUMN_G_TF_TN_TONAME_3);
3672 }
3673 else {
3674 query.append(_FINDER_COLUMN_G_TF_TN_TONAME_2);
3675 }
3676 }
3677
3678 String sql = query.toString();
3679
3680 Query q = session.createQuery(sql);
3681
3682 QueryPos qPos = QueryPos.getInstance(q);
3683
3684 qPos.add(groupId);
3685
3686 qPos.add(toFolderId);
3687
3688 if (toName != null) {
3689 qPos.add(toName);
3690 }
3691
3692 count = (Long)q.uniqueResult();
3693 }
3694 catch (Exception e) {
3695 throw processException(e);
3696 }
3697 finally {
3698 if (count == null) {
3699 count = Long.valueOf(0);
3700 }
3701
3702 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_TF_TN,
3703 finderArgs, count);
3704
3705 closeSession(session);
3706 }
3707 }
3708
3709 return count.intValue();
3710 }
3711
3712
3721 public int filterCountByG_TF_TN(long groupId, long toFolderId, String toName)
3722 throws SystemException {
3723 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
3724 return countByG_TF_TN(groupId, toFolderId, toName);
3725 }
3726
3727 Session session = null;
3728
3729 try {
3730 session = openSession();
3731
3732 StringBundler query = new StringBundler(4);
3733
3734 query.append(_FILTER_SQL_COUNT_DLFILESHORTCUT_WHERE);
3735
3736 query.append(_FINDER_COLUMN_G_TF_TN_GROUPID_2);
3737
3738 query.append(_FINDER_COLUMN_G_TF_TN_TOFOLDERID_2);
3739
3740 if (toName == null) {
3741 query.append(_FINDER_COLUMN_G_TF_TN_TONAME_1);
3742 }
3743 else {
3744 if (toName.equals(StringPool.BLANK)) {
3745 query.append(_FINDER_COLUMN_G_TF_TN_TONAME_3);
3746 }
3747 else {
3748 query.append(_FINDER_COLUMN_G_TF_TN_TONAME_2);
3749 }
3750 }
3751
3752 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
3753 DLFileShortcut.class.getName(), _FILTER_COLUMN_PK,
3754 _FILTER_COLUMN_USERID, groupId);
3755
3756 SQLQuery q = session.createSQLQuery(sql);
3757
3758 q.addScalar(COUNT_COLUMN_NAME,
3759 com.liferay.portal.kernel.dao.orm.Type.LONG);
3760
3761 QueryPos qPos = QueryPos.getInstance(q);
3762
3763 qPos.add(groupId);
3764
3765 qPos.add(toFolderId);
3766
3767 if (toName != null) {
3768 qPos.add(toName);
3769 }
3770
3771 Long count = (Long)q.uniqueResult();
3772
3773 return count.intValue();
3774 }
3775 catch (Exception e) {
3776 throw processException(e);
3777 }
3778 finally {
3779 closeSession(session);
3780 }
3781 }
3782
3783
3793 public int countByG_TF_TN_S(long groupId, long toFolderId, String toName,
3794 int status) throws SystemException {
3795 Object[] finderArgs = new Object[] { groupId, toFolderId, toName, status };
3796
3797 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_TF_TN_S,
3798 finderArgs, this);
3799
3800 if (count == null) {
3801 Session session = null;
3802
3803 try {
3804 session = openSession();
3805
3806 StringBundler query = new StringBundler(5);
3807
3808 query.append(_SQL_COUNT_DLFILESHORTCUT_WHERE);
3809
3810 query.append(_FINDER_COLUMN_G_TF_TN_S_GROUPID_2);
3811
3812 query.append(_FINDER_COLUMN_G_TF_TN_S_TOFOLDERID_2);
3813
3814 if (toName == null) {
3815 query.append(_FINDER_COLUMN_G_TF_TN_S_TONAME_1);
3816 }
3817 else {
3818 if (toName.equals(StringPool.BLANK)) {
3819 query.append(_FINDER_COLUMN_G_TF_TN_S_TONAME_3);
3820 }
3821 else {
3822 query.append(_FINDER_COLUMN_G_TF_TN_S_TONAME_2);
3823 }
3824 }
3825
3826 query.append(_FINDER_COLUMN_G_TF_TN_S_STATUS_2);
3827
3828 String sql = query.toString();
3829
3830 Query q = session.createQuery(sql);
3831
3832 QueryPos qPos = QueryPos.getInstance(q);
3833
3834 qPos.add(groupId);
3835
3836 qPos.add(toFolderId);
3837
3838 if (toName != null) {
3839 qPos.add(toName);
3840 }
3841
3842 qPos.add(status);
3843
3844 count = (Long)q.uniqueResult();
3845 }
3846 catch (Exception e) {
3847 throw processException(e);
3848 }
3849 finally {
3850 if (count == null) {
3851 count = Long.valueOf(0);
3852 }
3853
3854 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_TF_TN_S,
3855 finderArgs, count);
3856
3857 closeSession(session);
3858 }
3859 }
3860
3861 return count.intValue();
3862 }
3863
3864
3874 public int filterCountByG_TF_TN_S(long groupId, long toFolderId,
3875 String toName, int status) throws SystemException {
3876 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
3877 return countByG_TF_TN_S(groupId, toFolderId, toName, status);
3878 }
3879
3880 Session session = null;
3881
3882 try {
3883 session = openSession();
3884
3885 StringBundler query = new StringBundler(5);
3886
3887 query.append(_FILTER_SQL_COUNT_DLFILESHORTCUT_WHERE);
3888
3889 query.append(_FINDER_COLUMN_G_TF_TN_S_GROUPID_2);
3890
3891 query.append(_FINDER_COLUMN_G_TF_TN_S_TOFOLDERID_2);
3892
3893 if (toName == null) {
3894 query.append(_FINDER_COLUMN_G_TF_TN_S_TONAME_1);
3895 }
3896 else {
3897 if (toName.equals(StringPool.BLANK)) {
3898 query.append(_FINDER_COLUMN_G_TF_TN_S_TONAME_3);
3899 }
3900 else {
3901 query.append(_FINDER_COLUMN_G_TF_TN_S_TONAME_2);
3902 }
3903 }
3904
3905 query.append(_FINDER_COLUMN_G_TF_TN_S_STATUS_2);
3906
3907 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
3908 DLFileShortcut.class.getName(), _FILTER_COLUMN_PK,
3909 _FILTER_COLUMN_USERID, groupId);
3910
3911 SQLQuery q = session.createSQLQuery(sql);
3912
3913 q.addScalar(COUNT_COLUMN_NAME,
3914 com.liferay.portal.kernel.dao.orm.Type.LONG);
3915
3916 QueryPos qPos = QueryPos.getInstance(q);
3917
3918 qPos.add(groupId);
3919
3920 qPos.add(toFolderId);
3921
3922 if (toName != null) {
3923 qPos.add(toName);
3924 }
3925
3926 qPos.add(status);
3927
3928 Long count = (Long)q.uniqueResult();
3929
3930 return count.intValue();
3931 }
3932 catch (Exception e) {
3933 throw processException(e);
3934 }
3935 finally {
3936 closeSession(session);
3937 }
3938 }
3939
3940
3946 public int countAll() throws SystemException {
3947 Object[] finderArgs = new Object[0];
3948
3949 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
3950 finderArgs, this);
3951
3952 if (count == null) {
3953 Session session = null;
3954
3955 try {
3956 session = openSession();
3957
3958 Query q = session.createQuery(_SQL_COUNT_DLFILESHORTCUT);
3959
3960 count = (Long)q.uniqueResult();
3961 }
3962 catch (Exception e) {
3963 throw processException(e);
3964 }
3965 finally {
3966 if (count == null) {
3967 count = Long.valueOf(0);
3968 }
3969
3970 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL, finderArgs,
3971 count);
3972
3973 closeSession(session);
3974 }
3975 }
3976
3977 return count.intValue();
3978 }
3979
3980
3983 public void afterPropertiesSet() {
3984 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
3985 com.liferay.portal.util.PropsUtil.get(
3986 "value.object.listener.com.liferay.portlet.documentlibrary.model.DLFileShortcut")));
3987
3988 if (listenerClassNames.length > 0) {
3989 try {
3990 List<ModelListener<DLFileShortcut>> listenersList = new ArrayList<ModelListener<DLFileShortcut>>();
3991
3992 for (String listenerClassName : listenerClassNames) {
3993 listenersList.add((ModelListener<DLFileShortcut>)InstanceFactory.newInstance(
3994 listenerClassName));
3995 }
3996
3997 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
3998 }
3999 catch (Exception e) {
4000 _log.error(e);
4001 }
4002 }
4003 }
4004
4005 @BeanReference(type = DLFileEntryPersistence.class)
4006 protected DLFileEntryPersistence dlFileEntryPersistence;
4007 @BeanReference(type = DLFileRankPersistence.class)
4008 protected DLFileRankPersistence dlFileRankPersistence;
4009 @BeanReference(type = DLFileShortcutPersistence.class)
4010 protected DLFileShortcutPersistence dlFileShortcutPersistence;
4011 @BeanReference(type = DLFileVersionPersistence.class)
4012 protected DLFileVersionPersistence dlFileVersionPersistence;
4013 @BeanReference(type = DLFolderPersistence.class)
4014 protected DLFolderPersistence dlFolderPersistence;
4015 @BeanReference(type = ResourcePersistence.class)
4016 protected ResourcePersistence resourcePersistence;
4017 @BeanReference(type = UserPersistence.class)
4018 protected UserPersistence userPersistence;
4019 @BeanReference(type = AssetEntryPersistence.class)
4020 protected AssetEntryPersistence assetEntryPersistence;
4021 @BeanReference(type = AssetTagPersistence.class)
4022 protected AssetTagPersistence assetTagPersistence;
4023 private static final String _SQL_SELECT_DLFILESHORTCUT = "SELECT dlFileShortcut FROM DLFileShortcut dlFileShortcut";
4024 private static final String _SQL_SELECT_DLFILESHORTCUT_WHERE = "SELECT dlFileShortcut FROM DLFileShortcut dlFileShortcut WHERE ";
4025 private static final String _SQL_COUNT_DLFILESHORTCUT = "SELECT COUNT(dlFileShortcut) FROM DLFileShortcut dlFileShortcut";
4026 private static final String _SQL_COUNT_DLFILESHORTCUT_WHERE = "SELECT COUNT(dlFileShortcut) FROM DLFileShortcut dlFileShortcut WHERE ";
4027 private static final String _FINDER_COLUMN_UUID_UUID_1 = "dlFileShortcut.uuid IS NULL";
4028 private static final String _FINDER_COLUMN_UUID_UUID_2 = "dlFileShortcut.uuid = ?";
4029 private static final String _FINDER_COLUMN_UUID_UUID_3 = "(dlFileShortcut.uuid IS NULL OR dlFileShortcut.uuid = ?)";
4030 private static final String _FINDER_COLUMN_UUID_G_UUID_1 = "dlFileShortcut.uuid IS NULL AND ";
4031 private static final String _FINDER_COLUMN_UUID_G_UUID_2 = "dlFileShortcut.uuid = ? AND ";
4032 private static final String _FINDER_COLUMN_UUID_G_UUID_3 = "(dlFileShortcut.uuid IS NULL OR dlFileShortcut.uuid = ?) AND ";
4033 private static final String _FINDER_COLUMN_UUID_G_GROUPID_2 = "dlFileShortcut.groupId = ?";
4034 private static final String _FINDER_COLUMN_G_F_GROUPID_2 = "dlFileShortcut.groupId = ? AND ";
4035 private static final String _FINDER_COLUMN_G_F_FOLDERID_2 = "dlFileShortcut.folderId = ?";
4036 private static final String _FINDER_COLUMN_G_F_S_GROUPID_2 = "dlFileShortcut.groupId = ? AND ";
4037 private static final String _FINDER_COLUMN_G_F_S_FOLDERID_2 = "dlFileShortcut.folderId = ? AND ";
4038 private static final String _FINDER_COLUMN_G_F_S_STATUS_2 = "dlFileShortcut.status = ?";
4039 private static final String _FINDER_COLUMN_G_TF_TN_GROUPID_2 = "dlFileShortcut.groupId = ? AND ";
4040 private static final String _FINDER_COLUMN_G_TF_TN_TOFOLDERID_2 = "dlFileShortcut.toFolderId = ? AND ";
4041 private static final String _FINDER_COLUMN_G_TF_TN_TONAME_1 = "dlFileShortcut.toName IS NULL";
4042 private static final String _FINDER_COLUMN_G_TF_TN_TONAME_2 = "dlFileShortcut.toName = ?";
4043 private static final String _FINDER_COLUMN_G_TF_TN_TONAME_3 = "(dlFileShortcut.toName IS NULL OR dlFileShortcut.toName = ?)";
4044 private static final String _FINDER_COLUMN_G_TF_TN_S_GROUPID_2 = "dlFileShortcut.groupId = ? AND ";
4045 private static final String _FINDER_COLUMN_G_TF_TN_S_TOFOLDERID_2 = "dlFileShortcut.toFolderId = ? AND ";
4046 private static final String _FINDER_COLUMN_G_TF_TN_S_TONAME_1 = "dlFileShortcut.toName IS NULL AND ";
4047 private static final String _FINDER_COLUMN_G_TF_TN_S_TONAME_2 = "dlFileShortcut.toName = ? AND ";
4048 private static final String _FINDER_COLUMN_G_TF_TN_S_TONAME_3 = "(dlFileShortcut.toName IS NULL OR dlFileShortcut.toName = ?) AND ";
4049 private static final String _FINDER_COLUMN_G_TF_TN_S_STATUS_2 = "dlFileShortcut.status = ?";
4050 private static final String _FILTER_SQL_SELECT_DLFILESHORTCUT_WHERE = "SELECT DISTINCT {dlFileShortcut.*} FROM DLFileShortcut dlFileShortcut WHERE ";
4051 private static final String _FILTER_SQL_COUNT_DLFILESHORTCUT_WHERE = "SELECT COUNT(DISTINCT dlFileShortcut.fileShortcutId) AS COUNT_VALUE FROM DLFileShortcut dlFileShortcut WHERE ";
4052 private static final String _FILTER_COLUMN_PK = "dlFileShortcut.fileShortcutId";
4053 private static final String _FILTER_COLUMN_USERID = "dlFileShortcut.userId";
4054 private static final String _FILTER_ENTITY_ALIAS = "dlFileShortcut";
4055 private static final String _ORDER_BY_ENTITY_ALIAS = "dlFileShortcut.";
4056 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No DLFileShortcut exists with the primary key ";
4057 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No DLFileShortcut exists with the key {";
4058 private static Log _log = LogFactoryUtil.getLog(DLFileShortcutPersistenceImpl.class);
4059 }