1
14
15 package com.liferay.portlet.documentlibrary.service.persistence;
16
17 import com.liferay.portal.NoSuchModelException;
18 import com.liferay.portal.SystemException;
19 import com.liferay.portal.kernel.annotation.BeanReference;
20 import com.liferay.portal.kernel.cache.CacheRegistry;
21 import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
22 import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
23 import com.liferay.portal.kernel.dao.orm.FinderPath;
24 import com.liferay.portal.kernel.dao.orm.Query;
25 import com.liferay.portal.kernel.dao.orm.QueryPos;
26 import com.liferay.portal.kernel.dao.orm.QueryUtil;
27 import com.liferay.portal.kernel.dao.orm.Session;
28 import com.liferay.portal.kernel.log.Log;
29 import com.liferay.portal.kernel.log.LogFactoryUtil;
30 import com.liferay.portal.kernel.util.GetterUtil;
31 import com.liferay.portal.kernel.util.OrderByComparator;
32 import com.liferay.portal.kernel.util.StringBundler;
33 import com.liferay.portal.kernel.util.StringPool;
34 import com.liferay.portal.kernel.util.StringUtil;
35 import com.liferay.portal.kernel.util.Validator;
36 import com.liferay.portal.kernel.uuid.PortalUUIDUtil;
37 import com.liferay.portal.model.ModelListener;
38 import com.liferay.portal.service.persistence.BatchSessionUtil;
39 import com.liferay.portal.service.persistence.LayoutPersistence;
40 import com.liferay.portal.service.persistence.LockPersistence;
41 import com.liferay.portal.service.persistence.ResourcePersistence;
42 import com.liferay.portal.service.persistence.UserPersistence;
43 import com.liferay.portal.service.persistence.WebDAVPropsPersistence;
44 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
45
46 import com.liferay.portlet.documentlibrary.NoSuchFolderException;
47 import com.liferay.portlet.documentlibrary.model.DLFolder;
48 import com.liferay.portlet.documentlibrary.model.impl.DLFolderImpl;
49 import com.liferay.portlet.documentlibrary.model.impl.DLFolderModelImpl;
50 import com.liferay.portlet.expando.service.persistence.ExpandoValuePersistence;
51
52 import java.io.Serializable;
53
54 import java.util.ArrayList;
55 import java.util.Collections;
56 import java.util.List;
57
58
71 public class DLFolderPersistenceImpl extends BasePersistenceImpl<DLFolder>
72 implements DLFolderPersistence {
73 public static final String FINDER_CLASS_NAME_ENTITY = DLFolderImpl.class.getName();
74 public static final String FINDER_CLASS_NAME_LIST = FINDER_CLASS_NAME_ENTITY +
75 ".List";
76 public static final FinderPath FINDER_PATH_FIND_BY_UUID = new FinderPath(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
77 DLFolderModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
78 "findByUuid", new String[] { String.class.getName() });
79 public static final FinderPath FINDER_PATH_FIND_BY_OBC_UUID = new FinderPath(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
80 DLFolderModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
81 "findByUuid",
82 new String[] {
83 String.class.getName(),
84
85 "java.lang.Integer", "java.lang.Integer",
86 "com.liferay.portal.kernel.util.OrderByComparator"
87 });
88 public static final FinderPath FINDER_PATH_COUNT_BY_UUID = new FinderPath(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
89 DLFolderModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
90 "countByUuid", new String[] { String.class.getName() });
91 public static final FinderPath FINDER_PATH_FETCH_BY_UUID_G = new FinderPath(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
92 DLFolderModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_ENTITY,
93 "fetchByUUID_G",
94 new String[] { String.class.getName(), Long.class.getName() });
95 public static final FinderPath FINDER_PATH_COUNT_BY_UUID_G = new FinderPath(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
96 DLFolderModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
97 "countByUUID_G",
98 new String[] { String.class.getName(), Long.class.getName() });
99 public static final FinderPath FINDER_PATH_FIND_BY_GROUPID = new FinderPath(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
100 DLFolderModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
101 "findByGroupId", new String[] { Long.class.getName() });
102 public static final FinderPath FINDER_PATH_FIND_BY_OBC_GROUPID = new FinderPath(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
103 DLFolderModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
104 "findByGroupId",
105 new String[] {
106 Long.class.getName(),
107
108 "java.lang.Integer", "java.lang.Integer",
109 "com.liferay.portal.kernel.util.OrderByComparator"
110 });
111 public static final FinderPath FINDER_PATH_COUNT_BY_GROUPID = new FinderPath(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
112 DLFolderModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
113 "countByGroupId", new String[] { Long.class.getName() });
114 public static final FinderPath FINDER_PATH_FIND_BY_COMPANYID = new FinderPath(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
115 DLFolderModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
116 "findByCompanyId", new String[] { Long.class.getName() });
117 public static final FinderPath FINDER_PATH_FIND_BY_OBC_COMPANYID = new FinderPath(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
118 DLFolderModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
119 "findByCompanyId",
120 new String[] {
121 Long.class.getName(),
122
123 "java.lang.Integer", "java.lang.Integer",
124 "com.liferay.portal.kernel.util.OrderByComparator"
125 });
126 public static final FinderPath FINDER_PATH_COUNT_BY_COMPANYID = new FinderPath(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
127 DLFolderModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
128 "countByCompanyId", new String[] { Long.class.getName() });
129 public static final FinderPath FINDER_PATH_FIND_BY_G_P = new FinderPath(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
130 DLFolderModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
131 "findByG_P",
132 new String[] { Long.class.getName(), Long.class.getName() });
133 public static final FinderPath FINDER_PATH_FIND_BY_OBC_G_P = new FinderPath(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
134 DLFolderModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
135 "findByG_P",
136 new String[] {
137 Long.class.getName(), Long.class.getName(),
138
139 "java.lang.Integer", "java.lang.Integer",
140 "com.liferay.portal.kernel.util.OrderByComparator"
141 });
142 public static final FinderPath FINDER_PATH_COUNT_BY_G_P = new FinderPath(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
143 DLFolderModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
144 "countByG_P",
145 new String[] { Long.class.getName(), Long.class.getName() });
146 public static final FinderPath FINDER_PATH_FIND_BY_P_N = new FinderPath(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
147 DLFolderModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
148 "findByP_N",
149 new String[] { Long.class.getName(), String.class.getName() });
150 public static final FinderPath FINDER_PATH_FIND_BY_OBC_P_N = new FinderPath(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
151 DLFolderModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
152 "findByP_N",
153 new String[] {
154 Long.class.getName(), String.class.getName(),
155
156 "java.lang.Integer", "java.lang.Integer",
157 "com.liferay.portal.kernel.util.OrderByComparator"
158 });
159 public static final FinderPath FINDER_PATH_COUNT_BY_P_N = new FinderPath(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
160 DLFolderModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
161 "countByP_N",
162 new String[] { Long.class.getName(), String.class.getName() });
163 public static final FinderPath FINDER_PATH_FETCH_BY_G_P_N = new FinderPath(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
164 DLFolderModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_ENTITY,
165 "fetchByG_P_N",
166 new String[] {
167 Long.class.getName(), Long.class.getName(),
168 String.class.getName()
169 });
170 public static final FinderPath FINDER_PATH_COUNT_BY_G_P_N = new FinderPath(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
171 DLFolderModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
172 "countByG_P_N",
173 new String[] {
174 Long.class.getName(), Long.class.getName(),
175 String.class.getName()
176 });
177 public static final FinderPath FINDER_PATH_FIND_ALL = new FinderPath(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
178 DLFolderModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
179 "findAll", new String[0]);
180 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
181 DLFolderModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
182 "countAll", new String[0]);
183
184 public void cacheResult(DLFolder dlFolder) {
185 EntityCacheUtil.putResult(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
186 DLFolderImpl.class, dlFolder.getPrimaryKey(), dlFolder);
187
188 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
189 new Object[] { dlFolder.getUuid(), new Long(dlFolder.getGroupId()) },
190 dlFolder);
191
192 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_P_N,
193 new Object[] {
194 new Long(dlFolder.getGroupId()),
195 new Long(dlFolder.getParentFolderId()),
196
197 dlFolder.getName()
198 }, dlFolder);
199 }
200
201 public void cacheResult(List<DLFolder> dlFolders) {
202 for (DLFolder dlFolder : dlFolders) {
203 if (EntityCacheUtil.getResult(
204 DLFolderModelImpl.ENTITY_CACHE_ENABLED,
205 DLFolderImpl.class, dlFolder.getPrimaryKey(), this) == null) {
206 cacheResult(dlFolder);
207 }
208 }
209 }
210
211 public void clearCache() {
212 CacheRegistry.clear(DLFolderImpl.class.getName());
213 EntityCacheUtil.clearCache(DLFolderImpl.class.getName());
214 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
215 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
216 }
217
218 public DLFolder create(long folderId) {
219 DLFolder dlFolder = new DLFolderImpl();
220
221 dlFolder.setNew(true);
222 dlFolder.setPrimaryKey(folderId);
223
224 String uuid = PortalUUIDUtil.generate();
225
226 dlFolder.setUuid(uuid);
227
228 return dlFolder;
229 }
230
231 public DLFolder remove(Serializable primaryKey)
232 throws NoSuchModelException, SystemException {
233 return remove(((Long)primaryKey).longValue());
234 }
235
236 public DLFolder remove(long folderId)
237 throws NoSuchFolderException, SystemException {
238 Session session = null;
239
240 try {
241 session = openSession();
242
243 DLFolder dlFolder = (DLFolder)session.get(DLFolderImpl.class,
244 new Long(folderId));
245
246 if (dlFolder == null) {
247 if (_log.isWarnEnabled()) {
248 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + folderId);
249 }
250
251 throw new NoSuchFolderException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
252 folderId);
253 }
254
255 return remove(dlFolder);
256 }
257 catch (NoSuchFolderException nsee) {
258 throw nsee;
259 }
260 catch (Exception e) {
261 throw processException(e);
262 }
263 finally {
264 closeSession(session);
265 }
266 }
267
268 public DLFolder remove(DLFolder dlFolder) throws SystemException {
269 for (ModelListener<DLFolder> listener : listeners) {
270 listener.onBeforeRemove(dlFolder);
271 }
272
273 dlFolder = removeImpl(dlFolder);
274
275 for (ModelListener<DLFolder> listener : listeners) {
276 listener.onAfterRemove(dlFolder);
277 }
278
279 return dlFolder;
280 }
281
282 protected DLFolder removeImpl(DLFolder dlFolder) throws SystemException {
283 dlFolder = toUnwrappedModel(dlFolder);
284
285 Session session = null;
286
287 try {
288 session = openSession();
289
290 if (dlFolder.isCachedModel() || BatchSessionUtil.isEnabled()) {
291 Object staleObject = session.get(DLFolderImpl.class,
292 dlFolder.getPrimaryKeyObj());
293
294 if (staleObject != null) {
295 session.evict(staleObject);
296 }
297 }
298
299 session.delete(dlFolder);
300
301 session.flush();
302 }
303 catch (Exception e) {
304 throw processException(e);
305 }
306 finally {
307 closeSession(session);
308 }
309
310 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
311
312 DLFolderModelImpl dlFolderModelImpl = (DLFolderModelImpl)dlFolder;
313
314 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
315 new Object[] {
316 dlFolderModelImpl.getOriginalUuid(),
317 new Long(dlFolderModelImpl.getOriginalGroupId())
318 });
319
320 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_P_N,
321 new Object[] {
322 new Long(dlFolderModelImpl.getOriginalGroupId()),
323 new Long(dlFolderModelImpl.getOriginalParentFolderId()),
324
325 dlFolderModelImpl.getOriginalName()
326 });
327
328 EntityCacheUtil.removeResult(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
329 DLFolderImpl.class, dlFolder.getPrimaryKey());
330
331 return dlFolder;
332 }
333
334
337 public DLFolder update(DLFolder dlFolder) throws SystemException {
338 if (_log.isWarnEnabled()) {
339 _log.warn(
340 "Using the deprecated update(DLFolder dlFolder) method. Use update(DLFolder dlFolder, boolean merge) instead.");
341 }
342
343 return update(dlFolder, false);
344 }
345
346 public DLFolder updateImpl(
347 com.liferay.portlet.documentlibrary.model.DLFolder dlFolder,
348 boolean merge) throws SystemException {
349 dlFolder = toUnwrappedModel(dlFolder);
350
351 boolean isNew = dlFolder.isNew();
352
353 DLFolderModelImpl dlFolderModelImpl = (DLFolderModelImpl)dlFolder;
354
355 if (Validator.isNull(dlFolder.getUuid())) {
356 String uuid = PortalUUIDUtil.generate();
357
358 dlFolder.setUuid(uuid);
359 }
360
361 Session session = null;
362
363 try {
364 session = openSession();
365
366 BatchSessionUtil.update(session, dlFolder, merge);
367
368 dlFolder.setNew(false);
369 }
370 catch (Exception e) {
371 throw processException(e);
372 }
373 finally {
374 closeSession(session);
375 }
376
377 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
378
379 EntityCacheUtil.putResult(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
380 DLFolderImpl.class, dlFolder.getPrimaryKey(), dlFolder);
381
382 if (!isNew &&
383 (!Validator.equals(dlFolder.getUuid(),
384 dlFolderModelImpl.getOriginalUuid()) ||
385 (dlFolder.getGroupId() != dlFolderModelImpl.getOriginalGroupId()))) {
386 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
387 new Object[] {
388 dlFolderModelImpl.getOriginalUuid(),
389 new Long(dlFolderModelImpl.getOriginalGroupId())
390 });
391 }
392
393 if (isNew ||
394 (!Validator.equals(dlFolder.getUuid(),
395 dlFolderModelImpl.getOriginalUuid()) ||
396 (dlFolder.getGroupId() != dlFolderModelImpl.getOriginalGroupId()))) {
397 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
398 new Object[] { dlFolder.getUuid(), new Long(
399 dlFolder.getGroupId()) }, dlFolder);
400 }
401
402 if (!isNew &&
403 ((dlFolder.getGroupId() != dlFolderModelImpl.getOriginalGroupId()) ||
404 (dlFolder.getParentFolderId() != dlFolderModelImpl.getOriginalParentFolderId()) ||
405 !Validator.equals(dlFolder.getName(),
406 dlFolderModelImpl.getOriginalName()))) {
407 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_P_N,
408 new Object[] {
409 new Long(dlFolderModelImpl.getOriginalGroupId()),
410 new Long(dlFolderModelImpl.getOriginalParentFolderId()),
411
412 dlFolderModelImpl.getOriginalName()
413 });
414 }
415
416 if (isNew ||
417 ((dlFolder.getGroupId() != dlFolderModelImpl.getOriginalGroupId()) ||
418 (dlFolder.getParentFolderId() != dlFolderModelImpl.getOriginalParentFolderId()) ||
419 !Validator.equals(dlFolder.getName(),
420 dlFolderModelImpl.getOriginalName()))) {
421 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_P_N,
422 new Object[] {
423 new Long(dlFolder.getGroupId()),
424 new Long(dlFolder.getParentFolderId()),
425
426 dlFolder.getName()
427 }, dlFolder);
428 }
429
430 return dlFolder;
431 }
432
433 protected DLFolder toUnwrappedModel(DLFolder dlFolder) {
434 if (dlFolder instanceof DLFolderImpl) {
435 return dlFolder;
436 }
437
438 DLFolderImpl dlFolderImpl = new DLFolderImpl();
439
440 dlFolderImpl.setNew(dlFolder.isNew());
441 dlFolderImpl.setPrimaryKey(dlFolder.getPrimaryKey());
442
443 dlFolderImpl.setUuid(dlFolder.getUuid());
444 dlFolderImpl.setFolderId(dlFolder.getFolderId());
445 dlFolderImpl.setGroupId(dlFolder.getGroupId());
446 dlFolderImpl.setCompanyId(dlFolder.getCompanyId());
447 dlFolderImpl.setUserId(dlFolder.getUserId());
448 dlFolderImpl.setUserName(dlFolder.getUserName());
449 dlFolderImpl.setCreateDate(dlFolder.getCreateDate());
450 dlFolderImpl.setModifiedDate(dlFolder.getModifiedDate());
451 dlFolderImpl.setParentFolderId(dlFolder.getParentFolderId());
452 dlFolderImpl.setName(dlFolder.getName());
453 dlFolderImpl.setDescription(dlFolder.getDescription());
454 dlFolderImpl.setLastPostDate(dlFolder.getLastPostDate());
455
456 return dlFolderImpl;
457 }
458
459 public DLFolder findByPrimaryKey(Serializable primaryKey)
460 throws NoSuchModelException, SystemException {
461 return findByPrimaryKey(((Long)primaryKey).longValue());
462 }
463
464 public DLFolder findByPrimaryKey(long folderId)
465 throws NoSuchFolderException, SystemException {
466 DLFolder dlFolder = fetchByPrimaryKey(folderId);
467
468 if (dlFolder == null) {
469 if (_log.isWarnEnabled()) {
470 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + folderId);
471 }
472
473 throw new NoSuchFolderException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
474 folderId);
475 }
476
477 return dlFolder;
478 }
479
480 public DLFolder fetchByPrimaryKey(Serializable primaryKey)
481 throws SystemException {
482 return fetchByPrimaryKey(((Long)primaryKey).longValue());
483 }
484
485 public DLFolder fetchByPrimaryKey(long folderId) throws SystemException {
486 DLFolder dlFolder = (DLFolder)EntityCacheUtil.getResult(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
487 DLFolderImpl.class, folderId, this);
488
489 if (dlFolder == null) {
490 Session session = null;
491
492 try {
493 session = openSession();
494
495 dlFolder = (DLFolder)session.get(DLFolderImpl.class,
496 new Long(folderId));
497 }
498 catch (Exception e) {
499 throw processException(e);
500 }
501 finally {
502 if (dlFolder != null) {
503 cacheResult(dlFolder);
504 }
505
506 closeSession(session);
507 }
508 }
509
510 return dlFolder;
511 }
512
513 public List<DLFolder> findByUuid(String uuid) throws SystemException {
514 Object[] finderArgs = new Object[] { uuid };
515
516 List<DLFolder> list = (List<DLFolder>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_UUID,
517 finderArgs, this);
518
519 if (list == null) {
520 Session session = null;
521
522 try {
523 session = openSession();
524
525 StringBundler query = new StringBundler(3);
526
527 query.append(_SQL_SELECT_DLFOLDER_WHERE);
528
529 if (uuid == null) {
530 query.append(_FINDER_COLUMN_UUID_UUID_1);
531 }
532 else {
533 if (uuid.equals(StringPool.BLANK)) {
534 query.append(_FINDER_COLUMN_UUID_UUID_3);
535 }
536 else {
537 query.append(_FINDER_COLUMN_UUID_UUID_2);
538 }
539 }
540
541 query.append(DLFolderModelImpl.ORDER_BY_JPQL);
542
543 String sql = query.toString();
544
545 Query q = session.createQuery(sql);
546
547 QueryPos qPos = QueryPos.getInstance(q);
548
549 if (uuid != null) {
550 qPos.add(uuid);
551 }
552
553 list = q.list();
554 }
555 catch (Exception e) {
556 throw processException(e);
557 }
558 finally {
559 if (list == null) {
560 list = new ArrayList<DLFolder>();
561 }
562
563 cacheResult(list);
564
565 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_UUID, finderArgs,
566 list);
567
568 closeSession(session);
569 }
570 }
571
572 return list;
573 }
574
575 public List<DLFolder> findByUuid(String uuid, int start, int end)
576 throws SystemException {
577 return findByUuid(uuid, start, end, null);
578 }
579
580 public List<DLFolder> findByUuid(String uuid, int start, int end,
581 OrderByComparator orderByComparator) throws SystemException {
582 Object[] finderArgs = new Object[] {
583 uuid,
584
585 String.valueOf(start), String.valueOf(end),
586 String.valueOf(orderByComparator)
587 };
588
589 List<DLFolder> list = (List<DLFolder>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_UUID,
590 finderArgs, this);
591
592 if (list == null) {
593 Session session = null;
594
595 try {
596 session = openSession();
597
598 StringBundler query = null;
599
600 if (orderByComparator != null) {
601 query = new StringBundler(3 +
602 (orderByComparator.getOrderByFields().length * 3));
603 }
604 else {
605 query = new StringBundler(3);
606 }
607
608 query.append(_SQL_SELECT_DLFOLDER_WHERE);
609
610 if (uuid == null) {
611 query.append(_FINDER_COLUMN_UUID_UUID_1);
612 }
613 else {
614 if (uuid.equals(StringPool.BLANK)) {
615 query.append(_FINDER_COLUMN_UUID_UUID_3);
616 }
617 else {
618 query.append(_FINDER_COLUMN_UUID_UUID_2);
619 }
620 }
621
622 if (orderByComparator != null) {
623 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
624 orderByComparator);
625 }
626
627 else {
628 query.append(DLFolderModelImpl.ORDER_BY_JPQL);
629 }
630
631 String sql = query.toString();
632
633 Query q = session.createQuery(sql);
634
635 QueryPos qPos = QueryPos.getInstance(q);
636
637 if (uuid != null) {
638 qPos.add(uuid);
639 }
640
641 list = (List<DLFolder>)QueryUtil.list(q, getDialect(), start,
642 end);
643 }
644 catch (Exception e) {
645 throw processException(e);
646 }
647 finally {
648 if (list == null) {
649 list = new ArrayList<DLFolder>();
650 }
651
652 cacheResult(list);
653
654 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_UUID,
655 finderArgs, list);
656
657 closeSession(session);
658 }
659 }
660
661 return list;
662 }
663
664 public DLFolder findByUuid_First(String uuid,
665 OrderByComparator orderByComparator)
666 throws NoSuchFolderException, SystemException {
667 List<DLFolder> list = findByUuid(uuid, 0, 1, orderByComparator);
668
669 if (list.isEmpty()) {
670 StringBundler msg = new StringBundler(4);
671
672 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
673
674 msg.append("uuid=");
675 msg.append(uuid);
676
677 msg.append(StringPool.CLOSE_CURLY_BRACE);
678
679 throw new NoSuchFolderException(msg.toString());
680 }
681 else {
682 return list.get(0);
683 }
684 }
685
686 public DLFolder findByUuid_Last(String uuid,
687 OrderByComparator orderByComparator)
688 throws NoSuchFolderException, SystemException {
689 int count = countByUuid(uuid);
690
691 List<DLFolder> list = findByUuid(uuid, count - 1, count,
692 orderByComparator);
693
694 if (list.isEmpty()) {
695 StringBundler msg = new StringBundler(4);
696
697 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
698
699 msg.append("uuid=");
700 msg.append(uuid);
701
702 msg.append(StringPool.CLOSE_CURLY_BRACE);
703
704 throw new NoSuchFolderException(msg.toString());
705 }
706 else {
707 return list.get(0);
708 }
709 }
710
711 public DLFolder[] findByUuid_PrevAndNext(long folderId, String uuid,
712 OrderByComparator orderByComparator)
713 throws NoSuchFolderException, SystemException {
714 DLFolder dlFolder = findByPrimaryKey(folderId);
715
716 int count = countByUuid(uuid);
717
718 Session session = null;
719
720 try {
721 session = openSession();
722
723 StringBundler query = null;
724
725 if (orderByComparator != null) {
726 query = new StringBundler(3 +
727 (orderByComparator.getOrderByFields().length * 3));
728 }
729 else {
730 query = new StringBundler(3);
731 }
732
733 query.append(_SQL_SELECT_DLFOLDER_WHERE);
734
735 if (uuid == null) {
736 query.append(_FINDER_COLUMN_UUID_UUID_1);
737 }
738 else {
739 if (uuid.equals(StringPool.BLANK)) {
740 query.append(_FINDER_COLUMN_UUID_UUID_3);
741 }
742 else {
743 query.append(_FINDER_COLUMN_UUID_UUID_2);
744 }
745 }
746
747 if (orderByComparator != null) {
748 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
749 orderByComparator);
750 }
751
752 else {
753 query.append(DLFolderModelImpl.ORDER_BY_JPQL);
754 }
755
756 String sql = query.toString();
757
758 Query q = session.createQuery(sql);
759
760 QueryPos qPos = QueryPos.getInstance(q);
761
762 if (uuid != null) {
763 qPos.add(uuid);
764 }
765
766 Object[] objArray = QueryUtil.getPrevAndNext(q, count,
767 orderByComparator, dlFolder);
768
769 DLFolder[] array = new DLFolderImpl[3];
770
771 array[0] = (DLFolder)objArray[0];
772 array[1] = (DLFolder)objArray[1];
773 array[2] = (DLFolder)objArray[2];
774
775 return array;
776 }
777 catch (Exception e) {
778 throw processException(e);
779 }
780 finally {
781 closeSession(session);
782 }
783 }
784
785 public DLFolder findByUUID_G(String uuid, long groupId)
786 throws NoSuchFolderException, SystemException {
787 DLFolder dlFolder = fetchByUUID_G(uuid, groupId);
788
789 if (dlFolder == null) {
790 StringBundler msg = new StringBundler(6);
791
792 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
793
794 msg.append("uuid=");
795 msg.append(uuid);
796
797 msg.append(", groupId=");
798 msg.append(groupId);
799
800 msg.append(StringPool.CLOSE_CURLY_BRACE);
801
802 if (_log.isWarnEnabled()) {
803 _log.warn(msg.toString());
804 }
805
806 throw new NoSuchFolderException(msg.toString());
807 }
808
809 return dlFolder;
810 }
811
812 public DLFolder fetchByUUID_G(String uuid, long groupId)
813 throws SystemException {
814 return fetchByUUID_G(uuid, groupId, true);
815 }
816
817 public DLFolder fetchByUUID_G(String uuid, long groupId,
818 boolean retrieveFromCache) throws SystemException {
819 Object[] finderArgs = new Object[] { uuid, new Long(groupId) };
820
821 Object result = null;
822
823 if (retrieveFromCache) {
824 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_UUID_G,
825 finderArgs, this);
826 }
827
828 if (result == null) {
829 Session session = null;
830
831 try {
832 session = openSession();
833
834 StringBundler query = new StringBundler(4);
835
836 query.append(_SQL_SELECT_DLFOLDER_WHERE);
837
838 if (uuid == null) {
839 query.append(_FINDER_COLUMN_UUID_G_UUID_1);
840 }
841 else {
842 if (uuid.equals(StringPool.BLANK)) {
843 query.append(_FINDER_COLUMN_UUID_G_UUID_3);
844 }
845 else {
846 query.append(_FINDER_COLUMN_UUID_G_UUID_2);
847 }
848 }
849
850 query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
851
852 query.append(DLFolderModelImpl.ORDER_BY_JPQL);
853
854 String sql = query.toString();
855
856 Query q = session.createQuery(sql);
857
858 QueryPos qPos = QueryPos.getInstance(q);
859
860 if (uuid != null) {
861 qPos.add(uuid);
862 }
863
864 qPos.add(groupId);
865
866 List<DLFolder> list = q.list();
867
868 result = list;
869
870 DLFolder dlFolder = null;
871
872 if (list.isEmpty()) {
873 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
874 finderArgs, list);
875 }
876 else {
877 dlFolder = list.get(0);
878
879 cacheResult(dlFolder);
880
881 if ((dlFolder.getUuid() == null) ||
882 !dlFolder.getUuid().equals(uuid) ||
883 (dlFolder.getGroupId() != groupId)) {
884 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
885 finderArgs, dlFolder);
886 }
887 }
888
889 return dlFolder;
890 }
891 catch (Exception e) {
892 throw processException(e);
893 }
894 finally {
895 if (result == null) {
896 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
897 finderArgs, new ArrayList<DLFolder>());
898 }
899
900 closeSession(session);
901 }
902 }
903 else {
904 if (result instanceof List<?>) {
905 return null;
906 }
907 else {
908 return (DLFolder)result;
909 }
910 }
911 }
912
913 public List<DLFolder> findByGroupId(long groupId) throws SystemException {
914 Object[] finderArgs = new Object[] { new Long(groupId) };
915
916 List<DLFolder> list = (List<DLFolder>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_GROUPID,
917 finderArgs, this);
918
919 if (list == null) {
920 Session session = null;
921
922 try {
923 session = openSession();
924
925 StringBundler query = new StringBundler(3);
926
927 query.append(_SQL_SELECT_DLFOLDER_WHERE);
928
929 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
930
931 query.append(DLFolderModelImpl.ORDER_BY_JPQL);
932
933 String sql = query.toString();
934
935 Query q = session.createQuery(sql);
936
937 QueryPos qPos = QueryPos.getInstance(q);
938
939 qPos.add(groupId);
940
941 list = q.list();
942 }
943 catch (Exception e) {
944 throw processException(e);
945 }
946 finally {
947 if (list == null) {
948 list = new ArrayList<DLFolder>();
949 }
950
951 cacheResult(list);
952
953 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_GROUPID,
954 finderArgs, list);
955
956 closeSession(session);
957 }
958 }
959
960 return list;
961 }
962
963 public List<DLFolder> findByGroupId(long groupId, int start, int end)
964 throws SystemException {
965 return findByGroupId(groupId, start, end, null);
966 }
967
968 public List<DLFolder> findByGroupId(long groupId, int start, int end,
969 OrderByComparator orderByComparator) throws SystemException {
970 Object[] finderArgs = new Object[] {
971 new Long(groupId),
972
973 String.valueOf(start), String.valueOf(end),
974 String.valueOf(orderByComparator)
975 };
976
977 List<DLFolder> list = (List<DLFolder>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_GROUPID,
978 finderArgs, this);
979
980 if (list == null) {
981 Session session = null;
982
983 try {
984 session = openSession();
985
986 StringBundler query = null;
987
988 if (orderByComparator != null) {
989 query = new StringBundler(3 +
990 (orderByComparator.getOrderByFields().length * 3));
991 }
992 else {
993 query = new StringBundler(3);
994 }
995
996 query.append(_SQL_SELECT_DLFOLDER_WHERE);
997
998 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
999
1000 if (orderByComparator != null) {
1001 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1002 orderByComparator);
1003 }
1004
1005 else {
1006 query.append(DLFolderModelImpl.ORDER_BY_JPQL);
1007 }
1008
1009 String sql = query.toString();
1010
1011 Query q = session.createQuery(sql);
1012
1013 QueryPos qPos = QueryPos.getInstance(q);
1014
1015 qPos.add(groupId);
1016
1017 list = (List<DLFolder>)QueryUtil.list(q, getDialect(), start,
1018 end);
1019 }
1020 catch (Exception e) {
1021 throw processException(e);
1022 }
1023 finally {
1024 if (list == null) {
1025 list = new ArrayList<DLFolder>();
1026 }
1027
1028 cacheResult(list);
1029
1030 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_GROUPID,
1031 finderArgs, list);
1032
1033 closeSession(session);
1034 }
1035 }
1036
1037 return list;
1038 }
1039
1040 public DLFolder findByGroupId_First(long groupId,
1041 OrderByComparator orderByComparator)
1042 throws NoSuchFolderException, SystemException {
1043 List<DLFolder> list = findByGroupId(groupId, 0, 1, orderByComparator);
1044
1045 if (list.isEmpty()) {
1046 StringBundler msg = new StringBundler(4);
1047
1048 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1049
1050 msg.append("groupId=");
1051 msg.append(groupId);
1052
1053 msg.append(StringPool.CLOSE_CURLY_BRACE);
1054
1055 throw new NoSuchFolderException(msg.toString());
1056 }
1057 else {
1058 return list.get(0);
1059 }
1060 }
1061
1062 public DLFolder findByGroupId_Last(long groupId,
1063 OrderByComparator orderByComparator)
1064 throws NoSuchFolderException, SystemException {
1065 int count = countByGroupId(groupId);
1066
1067 List<DLFolder> list = findByGroupId(groupId, count - 1, count,
1068 orderByComparator);
1069
1070 if (list.isEmpty()) {
1071 StringBundler msg = new StringBundler(4);
1072
1073 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1074
1075 msg.append("groupId=");
1076 msg.append(groupId);
1077
1078 msg.append(StringPool.CLOSE_CURLY_BRACE);
1079
1080 throw new NoSuchFolderException(msg.toString());
1081 }
1082 else {
1083 return list.get(0);
1084 }
1085 }
1086
1087 public DLFolder[] findByGroupId_PrevAndNext(long folderId, long groupId,
1088 OrderByComparator orderByComparator)
1089 throws NoSuchFolderException, SystemException {
1090 DLFolder dlFolder = findByPrimaryKey(folderId);
1091
1092 int count = countByGroupId(groupId);
1093
1094 Session session = null;
1095
1096 try {
1097 session = openSession();
1098
1099 StringBundler query = null;
1100
1101 if (orderByComparator != null) {
1102 query = new StringBundler(3 +
1103 (orderByComparator.getOrderByFields().length * 3));
1104 }
1105 else {
1106 query = new StringBundler(3);
1107 }
1108
1109 query.append(_SQL_SELECT_DLFOLDER_WHERE);
1110
1111 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1112
1113 if (orderByComparator != null) {
1114 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1115 orderByComparator);
1116 }
1117
1118 else {
1119 query.append(DLFolderModelImpl.ORDER_BY_JPQL);
1120 }
1121
1122 String sql = query.toString();
1123
1124 Query q = session.createQuery(sql);
1125
1126 QueryPos qPos = QueryPos.getInstance(q);
1127
1128 qPos.add(groupId);
1129
1130 Object[] objArray = QueryUtil.getPrevAndNext(q, count,
1131 orderByComparator, dlFolder);
1132
1133 DLFolder[] array = new DLFolderImpl[3];
1134
1135 array[0] = (DLFolder)objArray[0];
1136 array[1] = (DLFolder)objArray[1];
1137 array[2] = (DLFolder)objArray[2];
1138
1139 return array;
1140 }
1141 catch (Exception e) {
1142 throw processException(e);
1143 }
1144 finally {
1145 closeSession(session);
1146 }
1147 }
1148
1149 public List<DLFolder> findByCompanyId(long companyId)
1150 throws SystemException {
1151 Object[] finderArgs = new Object[] { new Long(companyId) };
1152
1153 List<DLFolder> list = (List<DLFolder>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_COMPANYID,
1154 finderArgs, this);
1155
1156 if (list == null) {
1157 Session session = null;
1158
1159 try {
1160 session = openSession();
1161
1162 StringBundler query = new StringBundler(3);
1163
1164 query.append(_SQL_SELECT_DLFOLDER_WHERE);
1165
1166 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
1167
1168 query.append(DLFolderModelImpl.ORDER_BY_JPQL);
1169
1170 String sql = query.toString();
1171
1172 Query q = session.createQuery(sql);
1173
1174 QueryPos qPos = QueryPos.getInstance(q);
1175
1176 qPos.add(companyId);
1177
1178 list = q.list();
1179 }
1180 catch (Exception e) {
1181 throw processException(e);
1182 }
1183 finally {
1184 if (list == null) {
1185 list = new ArrayList<DLFolder>();
1186 }
1187
1188 cacheResult(list);
1189
1190 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_COMPANYID,
1191 finderArgs, list);
1192
1193 closeSession(session);
1194 }
1195 }
1196
1197 return list;
1198 }
1199
1200 public List<DLFolder> findByCompanyId(long companyId, int start, int end)
1201 throws SystemException {
1202 return findByCompanyId(companyId, start, end, null);
1203 }
1204
1205 public List<DLFolder> findByCompanyId(long companyId, int start, int end,
1206 OrderByComparator orderByComparator) throws SystemException {
1207 Object[] finderArgs = new Object[] {
1208 new Long(companyId),
1209
1210 String.valueOf(start), String.valueOf(end),
1211 String.valueOf(orderByComparator)
1212 };
1213
1214 List<DLFolder> list = (List<DLFolder>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_COMPANYID,
1215 finderArgs, this);
1216
1217 if (list == null) {
1218 Session session = null;
1219
1220 try {
1221 session = openSession();
1222
1223 StringBundler query = null;
1224
1225 if (orderByComparator != null) {
1226 query = new StringBundler(3 +
1227 (orderByComparator.getOrderByFields().length * 3));
1228 }
1229 else {
1230 query = new StringBundler(3);
1231 }
1232
1233 query.append(_SQL_SELECT_DLFOLDER_WHERE);
1234
1235 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
1236
1237 if (orderByComparator != null) {
1238 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1239 orderByComparator);
1240 }
1241
1242 else {
1243 query.append(DLFolderModelImpl.ORDER_BY_JPQL);
1244 }
1245
1246 String sql = query.toString();
1247
1248 Query q = session.createQuery(sql);
1249
1250 QueryPos qPos = QueryPos.getInstance(q);
1251
1252 qPos.add(companyId);
1253
1254 list = (List<DLFolder>)QueryUtil.list(q, getDialect(), start,
1255 end);
1256 }
1257 catch (Exception e) {
1258 throw processException(e);
1259 }
1260 finally {
1261 if (list == null) {
1262 list = new ArrayList<DLFolder>();
1263 }
1264
1265 cacheResult(list);
1266
1267 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_COMPANYID,
1268 finderArgs, list);
1269
1270 closeSession(session);
1271 }
1272 }
1273
1274 return list;
1275 }
1276
1277 public DLFolder findByCompanyId_First(long companyId,
1278 OrderByComparator orderByComparator)
1279 throws NoSuchFolderException, SystemException {
1280 List<DLFolder> list = findByCompanyId(companyId, 0, 1, orderByComparator);
1281
1282 if (list.isEmpty()) {
1283 StringBundler msg = new StringBundler(4);
1284
1285 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1286
1287 msg.append("companyId=");
1288 msg.append(companyId);
1289
1290 msg.append(StringPool.CLOSE_CURLY_BRACE);
1291
1292 throw new NoSuchFolderException(msg.toString());
1293 }
1294 else {
1295 return list.get(0);
1296 }
1297 }
1298
1299 public DLFolder findByCompanyId_Last(long companyId,
1300 OrderByComparator orderByComparator)
1301 throws NoSuchFolderException, SystemException {
1302 int count = countByCompanyId(companyId);
1303
1304 List<DLFolder> list = findByCompanyId(companyId, count - 1, count,
1305 orderByComparator);
1306
1307 if (list.isEmpty()) {
1308 StringBundler msg = new StringBundler(4);
1309
1310 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1311
1312 msg.append("companyId=");
1313 msg.append(companyId);
1314
1315 msg.append(StringPool.CLOSE_CURLY_BRACE);
1316
1317 throw new NoSuchFolderException(msg.toString());
1318 }
1319 else {
1320 return list.get(0);
1321 }
1322 }
1323
1324 public DLFolder[] findByCompanyId_PrevAndNext(long folderId,
1325 long companyId, OrderByComparator orderByComparator)
1326 throws NoSuchFolderException, SystemException {
1327 DLFolder dlFolder = findByPrimaryKey(folderId);
1328
1329 int count = countByCompanyId(companyId);
1330
1331 Session session = null;
1332
1333 try {
1334 session = openSession();
1335
1336 StringBundler query = null;
1337
1338 if (orderByComparator != null) {
1339 query = new StringBundler(3 +
1340 (orderByComparator.getOrderByFields().length * 3));
1341 }
1342 else {
1343 query = new StringBundler(3);
1344 }
1345
1346 query.append(_SQL_SELECT_DLFOLDER_WHERE);
1347
1348 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
1349
1350 if (orderByComparator != null) {
1351 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1352 orderByComparator);
1353 }
1354
1355 else {
1356 query.append(DLFolderModelImpl.ORDER_BY_JPQL);
1357 }
1358
1359 String sql = query.toString();
1360
1361 Query q = session.createQuery(sql);
1362
1363 QueryPos qPos = QueryPos.getInstance(q);
1364
1365 qPos.add(companyId);
1366
1367 Object[] objArray = QueryUtil.getPrevAndNext(q, count,
1368 orderByComparator, dlFolder);
1369
1370 DLFolder[] array = new DLFolderImpl[3];
1371
1372 array[0] = (DLFolder)objArray[0];
1373 array[1] = (DLFolder)objArray[1];
1374 array[2] = (DLFolder)objArray[2];
1375
1376 return array;
1377 }
1378 catch (Exception e) {
1379 throw processException(e);
1380 }
1381 finally {
1382 closeSession(session);
1383 }
1384 }
1385
1386 public List<DLFolder> findByG_P(long groupId, long parentFolderId)
1387 throws SystemException {
1388 Object[] finderArgs = new Object[] {
1389 new Long(groupId), new Long(parentFolderId)
1390 };
1391
1392 List<DLFolder> list = (List<DLFolder>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_G_P,
1393 finderArgs, this);
1394
1395 if (list == null) {
1396 Session session = null;
1397
1398 try {
1399 session = openSession();
1400
1401 StringBundler query = new StringBundler(4);
1402
1403 query.append(_SQL_SELECT_DLFOLDER_WHERE);
1404
1405 query.append(_FINDER_COLUMN_G_P_GROUPID_2);
1406
1407 query.append(_FINDER_COLUMN_G_P_PARENTFOLDERID_2);
1408
1409 query.append(DLFolderModelImpl.ORDER_BY_JPQL);
1410
1411 String sql = query.toString();
1412
1413 Query q = session.createQuery(sql);
1414
1415 QueryPos qPos = QueryPos.getInstance(q);
1416
1417 qPos.add(groupId);
1418
1419 qPos.add(parentFolderId);
1420
1421 list = q.list();
1422 }
1423 catch (Exception e) {
1424 throw processException(e);
1425 }
1426 finally {
1427 if (list == null) {
1428 list = new ArrayList<DLFolder>();
1429 }
1430
1431 cacheResult(list);
1432
1433 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_G_P, finderArgs,
1434 list);
1435
1436 closeSession(session);
1437 }
1438 }
1439
1440 return list;
1441 }
1442
1443 public List<DLFolder> findByG_P(long groupId, long parentFolderId,
1444 int start, int end) throws SystemException {
1445 return findByG_P(groupId, parentFolderId, start, end, null);
1446 }
1447
1448 public List<DLFolder> findByG_P(long groupId, long parentFolderId,
1449 int start, int end, OrderByComparator orderByComparator)
1450 throws SystemException {
1451 Object[] finderArgs = new Object[] {
1452 new Long(groupId), new Long(parentFolderId),
1453
1454 String.valueOf(start), String.valueOf(end),
1455 String.valueOf(orderByComparator)
1456 };
1457
1458 List<DLFolder> list = (List<DLFolder>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_G_P,
1459 finderArgs, this);
1460
1461 if (list == null) {
1462 Session session = null;
1463
1464 try {
1465 session = openSession();
1466
1467 StringBundler query = null;
1468
1469 if (orderByComparator != null) {
1470 query = new StringBundler(4 +
1471 (orderByComparator.getOrderByFields().length * 3));
1472 }
1473 else {
1474 query = new StringBundler(4);
1475 }
1476
1477 query.append(_SQL_SELECT_DLFOLDER_WHERE);
1478
1479 query.append(_FINDER_COLUMN_G_P_GROUPID_2);
1480
1481 query.append(_FINDER_COLUMN_G_P_PARENTFOLDERID_2);
1482
1483 if (orderByComparator != null) {
1484 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1485 orderByComparator);
1486 }
1487
1488 else {
1489 query.append(DLFolderModelImpl.ORDER_BY_JPQL);
1490 }
1491
1492 String sql = query.toString();
1493
1494 Query q = session.createQuery(sql);
1495
1496 QueryPos qPos = QueryPos.getInstance(q);
1497
1498 qPos.add(groupId);
1499
1500 qPos.add(parentFolderId);
1501
1502 list = (List<DLFolder>)QueryUtil.list(q, getDialect(), start,
1503 end);
1504 }
1505 catch (Exception e) {
1506 throw processException(e);
1507 }
1508 finally {
1509 if (list == null) {
1510 list = new ArrayList<DLFolder>();
1511 }
1512
1513 cacheResult(list);
1514
1515 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_G_P,
1516 finderArgs, list);
1517
1518 closeSession(session);
1519 }
1520 }
1521
1522 return list;
1523 }
1524
1525 public DLFolder findByG_P_First(long groupId, long parentFolderId,
1526 OrderByComparator orderByComparator)
1527 throws NoSuchFolderException, SystemException {
1528 List<DLFolder> list = findByG_P(groupId, parentFolderId, 0, 1,
1529 orderByComparator);
1530
1531 if (list.isEmpty()) {
1532 StringBundler msg = new StringBundler(6);
1533
1534 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1535
1536 msg.append("groupId=");
1537 msg.append(groupId);
1538
1539 msg.append(", parentFolderId=");
1540 msg.append(parentFolderId);
1541
1542 msg.append(StringPool.CLOSE_CURLY_BRACE);
1543
1544 throw new NoSuchFolderException(msg.toString());
1545 }
1546 else {
1547 return list.get(0);
1548 }
1549 }
1550
1551 public DLFolder findByG_P_Last(long groupId, long parentFolderId,
1552 OrderByComparator orderByComparator)
1553 throws NoSuchFolderException, SystemException {
1554 int count = countByG_P(groupId, parentFolderId);
1555
1556 List<DLFolder> list = findByG_P(groupId, parentFolderId, count - 1,
1557 count, orderByComparator);
1558
1559 if (list.isEmpty()) {
1560 StringBundler msg = new StringBundler(6);
1561
1562 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1563
1564 msg.append("groupId=");
1565 msg.append(groupId);
1566
1567 msg.append(", parentFolderId=");
1568 msg.append(parentFolderId);
1569
1570 msg.append(StringPool.CLOSE_CURLY_BRACE);
1571
1572 throw new NoSuchFolderException(msg.toString());
1573 }
1574 else {
1575 return list.get(0);
1576 }
1577 }
1578
1579 public DLFolder[] findByG_P_PrevAndNext(long folderId, long groupId,
1580 long parentFolderId, OrderByComparator orderByComparator)
1581 throws NoSuchFolderException, SystemException {
1582 DLFolder dlFolder = findByPrimaryKey(folderId);
1583
1584 int count = countByG_P(groupId, parentFolderId);
1585
1586 Session session = null;
1587
1588 try {
1589 session = openSession();
1590
1591 StringBundler query = null;
1592
1593 if (orderByComparator != null) {
1594 query = new StringBundler(4 +
1595 (orderByComparator.getOrderByFields().length * 3));
1596 }
1597 else {
1598 query = new StringBundler(4);
1599 }
1600
1601 query.append(_SQL_SELECT_DLFOLDER_WHERE);
1602
1603 query.append(_FINDER_COLUMN_G_P_GROUPID_2);
1604
1605 query.append(_FINDER_COLUMN_G_P_PARENTFOLDERID_2);
1606
1607 if (orderByComparator != null) {
1608 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1609 orderByComparator);
1610 }
1611
1612 else {
1613 query.append(DLFolderModelImpl.ORDER_BY_JPQL);
1614 }
1615
1616 String sql = query.toString();
1617
1618 Query q = session.createQuery(sql);
1619
1620 QueryPos qPos = QueryPos.getInstance(q);
1621
1622 qPos.add(groupId);
1623
1624 qPos.add(parentFolderId);
1625
1626 Object[] objArray = QueryUtil.getPrevAndNext(q, count,
1627 orderByComparator, dlFolder);
1628
1629 DLFolder[] array = new DLFolderImpl[3];
1630
1631 array[0] = (DLFolder)objArray[0];
1632 array[1] = (DLFolder)objArray[1];
1633 array[2] = (DLFolder)objArray[2];
1634
1635 return array;
1636 }
1637 catch (Exception e) {
1638 throw processException(e);
1639 }
1640 finally {
1641 closeSession(session);
1642 }
1643 }
1644
1645 public List<DLFolder> findByP_N(long parentFolderId, String name)
1646 throws SystemException {
1647 Object[] finderArgs = new Object[] { new Long(parentFolderId), name };
1648
1649 List<DLFolder> list = (List<DLFolder>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_P_N,
1650 finderArgs, this);
1651
1652 if (list == null) {
1653 Session session = null;
1654
1655 try {
1656 session = openSession();
1657
1658 StringBundler query = new StringBundler(4);
1659
1660 query.append(_SQL_SELECT_DLFOLDER_WHERE);
1661
1662 query.append(_FINDER_COLUMN_P_N_PARENTFOLDERID_2);
1663
1664 if (name == null) {
1665 query.append(_FINDER_COLUMN_P_N_NAME_1);
1666 }
1667 else {
1668 if (name.equals(StringPool.BLANK)) {
1669 query.append(_FINDER_COLUMN_P_N_NAME_3);
1670 }
1671 else {
1672 query.append(_FINDER_COLUMN_P_N_NAME_2);
1673 }
1674 }
1675
1676 query.append(DLFolderModelImpl.ORDER_BY_JPQL);
1677
1678 String sql = query.toString();
1679
1680 Query q = session.createQuery(sql);
1681
1682 QueryPos qPos = QueryPos.getInstance(q);
1683
1684 qPos.add(parentFolderId);
1685
1686 if (name != null) {
1687 qPos.add(name);
1688 }
1689
1690 list = q.list();
1691 }
1692 catch (Exception e) {
1693 throw processException(e);
1694 }
1695 finally {
1696 if (list == null) {
1697 list = new ArrayList<DLFolder>();
1698 }
1699
1700 cacheResult(list);
1701
1702 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_P_N, finderArgs,
1703 list);
1704
1705 closeSession(session);
1706 }
1707 }
1708
1709 return list;
1710 }
1711
1712 public List<DLFolder> findByP_N(long parentFolderId, String name,
1713 int start, int end) throws SystemException {
1714 return findByP_N(parentFolderId, name, start, end, null);
1715 }
1716
1717 public List<DLFolder> findByP_N(long parentFolderId, String name,
1718 int start, int end, OrderByComparator orderByComparator)
1719 throws SystemException {
1720 Object[] finderArgs = new Object[] {
1721 new Long(parentFolderId),
1722
1723 name,
1724
1725 String.valueOf(start), String.valueOf(end),
1726 String.valueOf(orderByComparator)
1727 };
1728
1729 List<DLFolder> list = (List<DLFolder>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_P_N,
1730 finderArgs, this);
1731
1732 if (list == null) {
1733 Session session = null;
1734
1735 try {
1736 session = openSession();
1737
1738 StringBundler query = null;
1739
1740 if (orderByComparator != null) {
1741 query = new StringBundler(4 +
1742 (orderByComparator.getOrderByFields().length * 3));
1743 }
1744 else {
1745 query = new StringBundler(4);
1746 }
1747
1748 query.append(_SQL_SELECT_DLFOLDER_WHERE);
1749
1750 query.append(_FINDER_COLUMN_P_N_PARENTFOLDERID_2);
1751
1752 if (name == null) {
1753 query.append(_FINDER_COLUMN_P_N_NAME_1);
1754 }
1755 else {
1756 if (name.equals(StringPool.BLANK)) {
1757 query.append(_FINDER_COLUMN_P_N_NAME_3);
1758 }
1759 else {
1760 query.append(_FINDER_COLUMN_P_N_NAME_2);
1761 }
1762 }
1763
1764 if (orderByComparator != null) {
1765 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1766 orderByComparator);
1767 }
1768
1769 else {
1770 query.append(DLFolderModelImpl.ORDER_BY_JPQL);
1771 }
1772
1773 String sql = query.toString();
1774
1775 Query q = session.createQuery(sql);
1776
1777 QueryPos qPos = QueryPos.getInstance(q);
1778
1779 qPos.add(parentFolderId);
1780
1781 if (name != null) {
1782 qPos.add(name);
1783 }
1784
1785 list = (List<DLFolder>)QueryUtil.list(q, getDialect(), start,
1786 end);
1787 }
1788 catch (Exception e) {
1789 throw processException(e);
1790 }
1791 finally {
1792 if (list == null) {
1793 list = new ArrayList<DLFolder>();
1794 }
1795
1796 cacheResult(list);
1797
1798 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_P_N,
1799 finderArgs, list);
1800
1801 closeSession(session);
1802 }
1803 }
1804
1805 return list;
1806 }
1807
1808 public DLFolder findByP_N_First(long parentFolderId, String name,
1809 OrderByComparator orderByComparator)
1810 throws NoSuchFolderException, SystemException {
1811 List<DLFolder> list = findByP_N(parentFolderId, name, 0, 1,
1812 orderByComparator);
1813
1814 if (list.isEmpty()) {
1815 StringBundler msg = new StringBundler(6);
1816
1817 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1818
1819 msg.append("parentFolderId=");
1820 msg.append(parentFolderId);
1821
1822 msg.append(", name=");
1823 msg.append(name);
1824
1825 msg.append(StringPool.CLOSE_CURLY_BRACE);
1826
1827 throw new NoSuchFolderException(msg.toString());
1828 }
1829 else {
1830 return list.get(0);
1831 }
1832 }
1833
1834 public DLFolder findByP_N_Last(long parentFolderId, String name,
1835 OrderByComparator orderByComparator)
1836 throws NoSuchFolderException, SystemException {
1837 int count = countByP_N(parentFolderId, name);
1838
1839 List<DLFolder> list = findByP_N(parentFolderId, name, count - 1, count,
1840 orderByComparator);
1841
1842 if (list.isEmpty()) {
1843 StringBundler msg = new StringBundler(6);
1844
1845 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1846
1847 msg.append("parentFolderId=");
1848 msg.append(parentFolderId);
1849
1850 msg.append(", name=");
1851 msg.append(name);
1852
1853 msg.append(StringPool.CLOSE_CURLY_BRACE);
1854
1855 throw new NoSuchFolderException(msg.toString());
1856 }
1857 else {
1858 return list.get(0);
1859 }
1860 }
1861
1862 public DLFolder[] findByP_N_PrevAndNext(long folderId, long parentFolderId,
1863 String name, OrderByComparator orderByComparator)
1864 throws NoSuchFolderException, SystemException {
1865 DLFolder dlFolder = findByPrimaryKey(folderId);
1866
1867 int count = countByP_N(parentFolderId, name);
1868
1869 Session session = null;
1870
1871 try {
1872 session = openSession();
1873
1874 StringBundler query = null;
1875
1876 if (orderByComparator != null) {
1877 query = new StringBundler(4 +
1878 (orderByComparator.getOrderByFields().length * 3));
1879 }
1880 else {
1881 query = new StringBundler(4);
1882 }
1883
1884 query.append(_SQL_SELECT_DLFOLDER_WHERE);
1885
1886 query.append(_FINDER_COLUMN_P_N_PARENTFOLDERID_2);
1887
1888 if (name == null) {
1889 query.append(_FINDER_COLUMN_P_N_NAME_1);
1890 }
1891 else {
1892 if (name.equals(StringPool.BLANK)) {
1893 query.append(_FINDER_COLUMN_P_N_NAME_3);
1894 }
1895 else {
1896 query.append(_FINDER_COLUMN_P_N_NAME_2);
1897 }
1898 }
1899
1900 if (orderByComparator != null) {
1901 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1902 orderByComparator);
1903 }
1904
1905 else {
1906 query.append(DLFolderModelImpl.ORDER_BY_JPQL);
1907 }
1908
1909 String sql = query.toString();
1910
1911 Query q = session.createQuery(sql);
1912
1913 QueryPos qPos = QueryPos.getInstance(q);
1914
1915 qPos.add(parentFolderId);
1916
1917 if (name != null) {
1918 qPos.add(name);
1919 }
1920
1921 Object[] objArray = QueryUtil.getPrevAndNext(q, count,
1922 orderByComparator, dlFolder);
1923
1924 DLFolder[] array = new DLFolderImpl[3];
1925
1926 array[0] = (DLFolder)objArray[0];
1927 array[1] = (DLFolder)objArray[1];
1928 array[2] = (DLFolder)objArray[2];
1929
1930 return array;
1931 }
1932 catch (Exception e) {
1933 throw processException(e);
1934 }
1935 finally {
1936 closeSession(session);
1937 }
1938 }
1939
1940 public DLFolder findByG_P_N(long groupId, long parentFolderId, String name)
1941 throws NoSuchFolderException, SystemException {
1942 DLFolder dlFolder = fetchByG_P_N(groupId, parentFolderId, name);
1943
1944 if (dlFolder == null) {
1945 StringBundler msg = new StringBundler(8);
1946
1947 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1948
1949 msg.append("groupId=");
1950 msg.append(groupId);
1951
1952 msg.append(", parentFolderId=");
1953 msg.append(parentFolderId);
1954
1955 msg.append(", name=");
1956 msg.append(name);
1957
1958 msg.append(StringPool.CLOSE_CURLY_BRACE);
1959
1960 if (_log.isWarnEnabled()) {
1961 _log.warn(msg.toString());
1962 }
1963
1964 throw new NoSuchFolderException(msg.toString());
1965 }
1966
1967 return dlFolder;
1968 }
1969
1970 public DLFolder fetchByG_P_N(long groupId, long parentFolderId, String name)
1971 throws SystemException {
1972 return fetchByG_P_N(groupId, parentFolderId, name, true);
1973 }
1974
1975 public DLFolder fetchByG_P_N(long groupId, long parentFolderId,
1976 String name, boolean retrieveFromCache) throws SystemException {
1977 Object[] finderArgs = new Object[] {
1978 new Long(groupId), new Long(parentFolderId),
1979
1980 name
1981 };
1982
1983 Object result = null;
1984
1985 if (retrieveFromCache) {
1986 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_G_P_N,
1987 finderArgs, this);
1988 }
1989
1990 if (result == null) {
1991 Session session = null;
1992
1993 try {
1994 session = openSession();
1995
1996 StringBundler query = new StringBundler(5);
1997
1998 query.append(_SQL_SELECT_DLFOLDER_WHERE);
1999
2000 query.append(_FINDER_COLUMN_G_P_N_GROUPID_2);
2001
2002 query.append(_FINDER_COLUMN_G_P_N_PARENTFOLDERID_2);
2003
2004 if (name == null) {
2005 query.append(_FINDER_COLUMN_G_P_N_NAME_1);
2006 }
2007 else {
2008 if (name.equals(StringPool.BLANK)) {
2009 query.append(_FINDER_COLUMN_G_P_N_NAME_3);
2010 }
2011 else {
2012 query.append(_FINDER_COLUMN_G_P_N_NAME_2);
2013 }
2014 }
2015
2016 query.append(DLFolderModelImpl.ORDER_BY_JPQL);
2017
2018 String sql = query.toString();
2019
2020 Query q = session.createQuery(sql);
2021
2022 QueryPos qPos = QueryPos.getInstance(q);
2023
2024 qPos.add(groupId);
2025
2026 qPos.add(parentFolderId);
2027
2028 if (name != null) {
2029 qPos.add(name);
2030 }
2031
2032 List<DLFolder> list = q.list();
2033
2034 result = list;
2035
2036 DLFolder dlFolder = null;
2037
2038 if (list.isEmpty()) {
2039 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_P_N,
2040 finderArgs, list);
2041 }
2042 else {
2043 dlFolder = list.get(0);
2044
2045 cacheResult(dlFolder);
2046
2047 if ((dlFolder.getGroupId() != groupId) ||
2048 (dlFolder.getParentFolderId() != parentFolderId) ||
2049 (dlFolder.getName() == null) ||
2050 !dlFolder.getName().equals(name)) {
2051 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_P_N,
2052 finderArgs, dlFolder);
2053 }
2054 }
2055
2056 return dlFolder;
2057 }
2058 catch (Exception e) {
2059 throw processException(e);
2060 }
2061 finally {
2062 if (result == null) {
2063 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_P_N,
2064 finderArgs, new ArrayList<DLFolder>());
2065 }
2066
2067 closeSession(session);
2068 }
2069 }
2070 else {
2071 if (result instanceof List<?>) {
2072 return null;
2073 }
2074 else {
2075 return (DLFolder)result;
2076 }
2077 }
2078 }
2079
2080 public List<DLFolder> findAll() throws SystemException {
2081 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
2082 }
2083
2084 public List<DLFolder> findAll(int start, int end) throws SystemException {
2085 return findAll(start, end, null);
2086 }
2087
2088 public List<DLFolder> findAll(int start, int end,
2089 OrderByComparator orderByComparator) throws SystemException {
2090 Object[] finderArgs = new Object[] {
2091 String.valueOf(start), String.valueOf(end),
2092 String.valueOf(orderByComparator)
2093 };
2094
2095 List<DLFolder> list = (List<DLFolder>)FinderCacheUtil.getResult(FINDER_PATH_FIND_ALL,
2096 finderArgs, this);
2097
2098 if (list == null) {
2099 Session session = null;
2100
2101 try {
2102 session = openSession();
2103
2104 StringBundler query = null;
2105 String sql = null;
2106
2107 if (orderByComparator != null) {
2108 query = new StringBundler(2 +
2109 (orderByComparator.getOrderByFields().length * 3));
2110
2111 query.append(_SQL_SELECT_DLFOLDER);
2112
2113 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2114 orderByComparator);
2115
2116 sql = query.toString();
2117 }
2118
2119 else {
2120 sql = _SQL_SELECT_DLFOLDER.concat(DLFolderModelImpl.ORDER_BY_JPQL);
2121 }
2122
2123 Query q = session.createQuery(sql);
2124
2125 if (orderByComparator == null) {
2126 list = (List<DLFolder>)QueryUtil.list(q, getDialect(),
2127 start, end, false);
2128
2129 Collections.sort(list);
2130 }
2131 else {
2132 list = (List<DLFolder>)QueryUtil.list(q, getDialect(),
2133 start, end);
2134 }
2135 }
2136 catch (Exception e) {
2137 throw processException(e);
2138 }
2139 finally {
2140 if (list == null) {
2141 list = new ArrayList<DLFolder>();
2142 }
2143
2144 cacheResult(list);
2145
2146 FinderCacheUtil.putResult(FINDER_PATH_FIND_ALL, finderArgs, list);
2147
2148 closeSession(session);
2149 }
2150 }
2151
2152 return list;
2153 }
2154
2155 public void removeByUuid(String uuid) throws SystemException {
2156 for (DLFolder dlFolder : findByUuid(uuid)) {
2157 remove(dlFolder);
2158 }
2159 }
2160
2161 public void removeByUUID_G(String uuid, long groupId)
2162 throws NoSuchFolderException, SystemException {
2163 DLFolder dlFolder = findByUUID_G(uuid, groupId);
2164
2165 remove(dlFolder);
2166 }
2167
2168 public void removeByGroupId(long groupId) throws SystemException {
2169 for (DLFolder dlFolder : findByGroupId(groupId)) {
2170 remove(dlFolder);
2171 }
2172 }
2173
2174 public void removeByCompanyId(long companyId) throws SystemException {
2175 for (DLFolder dlFolder : findByCompanyId(companyId)) {
2176 remove(dlFolder);
2177 }
2178 }
2179
2180 public void removeByG_P(long groupId, long parentFolderId)
2181 throws SystemException {
2182 for (DLFolder dlFolder : findByG_P(groupId, parentFolderId)) {
2183 remove(dlFolder);
2184 }
2185 }
2186
2187 public void removeByP_N(long parentFolderId, String name)
2188 throws SystemException {
2189 for (DLFolder dlFolder : findByP_N(parentFolderId, name)) {
2190 remove(dlFolder);
2191 }
2192 }
2193
2194 public void removeByG_P_N(long groupId, long parentFolderId, String name)
2195 throws NoSuchFolderException, SystemException {
2196 DLFolder dlFolder = findByG_P_N(groupId, parentFolderId, name);
2197
2198 remove(dlFolder);
2199 }
2200
2201 public void removeAll() throws SystemException {
2202 for (DLFolder dlFolder : findAll()) {
2203 remove(dlFolder);
2204 }
2205 }
2206
2207 public int countByUuid(String uuid) throws SystemException {
2208 Object[] finderArgs = new Object[] { uuid };
2209
2210 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID,
2211 finderArgs, this);
2212
2213 if (count == null) {
2214 Session session = null;
2215
2216 try {
2217 session = openSession();
2218
2219 StringBundler query = new StringBundler(2);
2220
2221 query.append(_SQL_COUNT_DLFOLDER_WHERE);
2222
2223 if (uuid == null) {
2224 query.append(_FINDER_COLUMN_UUID_UUID_1);
2225 }
2226 else {
2227 if (uuid.equals(StringPool.BLANK)) {
2228 query.append(_FINDER_COLUMN_UUID_UUID_3);
2229 }
2230 else {
2231 query.append(_FINDER_COLUMN_UUID_UUID_2);
2232 }
2233 }
2234
2235 String sql = query.toString();
2236
2237 Query q = session.createQuery(sql);
2238
2239 QueryPos qPos = QueryPos.getInstance(q);
2240
2241 if (uuid != null) {
2242 qPos.add(uuid);
2243 }
2244
2245 count = (Long)q.uniqueResult();
2246 }
2247 catch (Exception e) {
2248 throw processException(e);
2249 }
2250 finally {
2251 if (count == null) {
2252 count = Long.valueOf(0);
2253 }
2254
2255 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID,
2256 finderArgs, count);
2257
2258 closeSession(session);
2259 }
2260 }
2261
2262 return count.intValue();
2263 }
2264
2265 public int countByUUID_G(String uuid, long groupId)
2266 throws SystemException {
2267 Object[] finderArgs = new Object[] { uuid, new Long(groupId) };
2268
2269 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID_G,
2270 finderArgs, this);
2271
2272 if (count == null) {
2273 Session session = null;
2274
2275 try {
2276 session = openSession();
2277
2278 StringBundler query = new StringBundler(3);
2279
2280 query.append(_SQL_COUNT_DLFOLDER_WHERE);
2281
2282 if (uuid == null) {
2283 query.append(_FINDER_COLUMN_UUID_G_UUID_1);
2284 }
2285 else {
2286 if (uuid.equals(StringPool.BLANK)) {
2287 query.append(_FINDER_COLUMN_UUID_G_UUID_3);
2288 }
2289 else {
2290 query.append(_FINDER_COLUMN_UUID_G_UUID_2);
2291 }
2292 }
2293
2294 query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
2295
2296 String sql = query.toString();
2297
2298 Query q = session.createQuery(sql);
2299
2300 QueryPos qPos = QueryPos.getInstance(q);
2301
2302 if (uuid != null) {
2303 qPos.add(uuid);
2304 }
2305
2306 qPos.add(groupId);
2307
2308 count = (Long)q.uniqueResult();
2309 }
2310 catch (Exception e) {
2311 throw processException(e);
2312 }
2313 finally {
2314 if (count == null) {
2315 count = Long.valueOf(0);
2316 }
2317
2318 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G,
2319 finderArgs, count);
2320
2321 closeSession(session);
2322 }
2323 }
2324
2325 return count.intValue();
2326 }
2327
2328 public int countByGroupId(long groupId) throws SystemException {
2329 Object[] finderArgs = new Object[] { new Long(groupId) };
2330
2331 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_GROUPID,
2332 finderArgs, this);
2333
2334 if (count == null) {
2335 Session session = null;
2336
2337 try {
2338 session = openSession();
2339
2340 StringBundler query = new StringBundler(2);
2341
2342 query.append(_SQL_COUNT_DLFOLDER_WHERE);
2343
2344 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2345
2346 String sql = query.toString();
2347
2348 Query q = session.createQuery(sql);
2349
2350 QueryPos qPos = QueryPos.getInstance(q);
2351
2352 qPos.add(groupId);
2353
2354 count = (Long)q.uniqueResult();
2355 }
2356 catch (Exception e) {
2357 throw processException(e);
2358 }
2359 finally {
2360 if (count == null) {
2361 count = Long.valueOf(0);
2362 }
2363
2364 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_GROUPID,
2365 finderArgs, count);
2366
2367 closeSession(session);
2368 }
2369 }
2370
2371 return count.intValue();
2372 }
2373
2374 public int countByCompanyId(long companyId) throws SystemException {
2375 Object[] finderArgs = new Object[] { new Long(companyId) };
2376
2377 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_COMPANYID,
2378 finderArgs, this);
2379
2380 if (count == null) {
2381 Session session = null;
2382
2383 try {
2384 session = openSession();
2385
2386 StringBundler query = new StringBundler(2);
2387
2388 query.append(_SQL_COUNT_DLFOLDER_WHERE);
2389
2390 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
2391
2392 String sql = query.toString();
2393
2394 Query q = session.createQuery(sql);
2395
2396 QueryPos qPos = QueryPos.getInstance(q);
2397
2398 qPos.add(companyId);
2399
2400 count = (Long)q.uniqueResult();
2401 }
2402 catch (Exception e) {
2403 throw processException(e);
2404 }
2405 finally {
2406 if (count == null) {
2407 count = Long.valueOf(0);
2408 }
2409
2410 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_COMPANYID,
2411 finderArgs, count);
2412
2413 closeSession(session);
2414 }
2415 }
2416
2417 return count.intValue();
2418 }
2419
2420 public int countByG_P(long groupId, long parentFolderId)
2421 throws SystemException {
2422 Object[] finderArgs = new Object[] {
2423 new Long(groupId), new Long(parentFolderId)
2424 };
2425
2426 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_P,
2427 finderArgs, this);
2428
2429 if (count == null) {
2430 Session session = null;
2431
2432 try {
2433 session = openSession();
2434
2435 StringBundler query = new StringBundler(3);
2436
2437 query.append(_SQL_COUNT_DLFOLDER_WHERE);
2438
2439 query.append(_FINDER_COLUMN_G_P_GROUPID_2);
2440
2441 query.append(_FINDER_COLUMN_G_P_PARENTFOLDERID_2);
2442
2443 String sql = query.toString();
2444
2445 Query q = session.createQuery(sql);
2446
2447 QueryPos qPos = QueryPos.getInstance(q);
2448
2449 qPos.add(groupId);
2450
2451 qPos.add(parentFolderId);
2452
2453 count = (Long)q.uniqueResult();
2454 }
2455 catch (Exception e) {
2456 throw processException(e);
2457 }
2458 finally {
2459 if (count == null) {
2460 count = Long.valueOf(0);
2461 }
2462
2463 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_P, finderArgs,
2464 count);
2465
2466 closeSession(session);
2467 }
2468 }
2469
2470 return count.intValue();
2471 }
2472
2473 public int countByP_N(long parentFolderId, String name)
2474 throws SystemException {
2475 Object[] finderArgs = new Object[] { new Long(parentFolderId), name };
2476
2477 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_P_N,
2478 finderArgs, this);
2479
2480 if (count == null) {
2481 Session session = null;
2482
2483 try {
2484 session = openSession();
2485
2486 StringBundler query = new StringBundler(3);
2487
2488 query.append(_SQL_COUNT_DLFOLDER_WHERE);
2489
2490 query.append(_FINDER_COLUMN_P_N_PARENTFOLDERID_2);
2491
2492 if (name == null) {
2493 query.append(_FINDER_COLUMN_P_N_NAME_1);
2494 }
2495 else {
2496 if (name.equals(StringPool.BLANK)) {
2497 query.append(_FINDER_COLUMN_P_N_NAME_3);
2498 }
2499 else {
2500 query.append(_FINDER_COLUMN_P_N_NAME_2);
2501 }
2502 }
2503
2504 String sql = query.toString();
2505
2506 Query q = session.createQuery(sql);
2507
2508 QueryPos qPos = QueryPos.getInstance(q);
2509
2510 qPos.add(parentFolderId);
2511
2512 if (name != null) {
2513 qPos.add(name);
2514 }
2515
2516 count = (Long)q.uniqueResult();
2517 }
2518 catch (Exception e) {
2519 throw processException(e);
2520 }
2521 finally {
2522 if (count == null) {
2523 count = Long.valueOf(0);
2524 }
2525
2526 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_P_N, finderArgs,
2527 count);
2528
2529 closeSession(session);
2530 }
2531 }
2532
2533 return count.intValue();
2534 }
2535
2536 public int countByG_P_N(long groupId, long parentFolderId, String name)
2537 throws SystemException {
2538 Object[] finderArgs = new Object[] {
2539 new Long(groupId), new Long(parentFolderId),
2540
2541 name
2542 };
2543
2544 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_P_N,
2545 finderArgs, this);
2546
2547 if (count == null) {
2548 Session session = null;
2549
2550 try {
2551 session = openSession();
2552
2553 StringBundler query = new StringBundler(4);
2554
2555 query.append(_SQL_COUNT_DLFOLDER_WHERE);
2556
2557 query.append(_FINDER_COLUMN_G_P_N_GROUPID_2);
2558
2559 query.append(_FINDER_COLUMN_G_P_N_PARENTFOLDERID_2);
2560
2561 if (name == null) {
2562 query.append(_FINDER_COLUMN_G_P_N_NAME_1);
2563 }
2564 else {
2565 if (name.equals(StringPool.BLANK)) {
2566 query.append(_FINDER_COLUMN_G_P_N_NAME_3);
2567 }
2568 else {
2569 query.append(_FINDER_COLUMN_G_P_N_NAME_2);
2570 }
2571 }
2572
2573 String sql = query.toString();
2574
2575 Query q = session.createQuery(sql);
2576
2577 QueryPos qPos = QueryPos.getInstance(q);
2578
2579 qPos.add(groupId);
2580
2581 qPos.add(parentFolderId);
2582
2583 if (name != null) {
2584 qPos.add(name);
2585 }
2586
2587 count = (Long)q.uniqueResult();
2588 }
2589 catch (Exception e) {
2590 throw processException(e);
2591 }
2592 finally {
2593 if (count == null) {
2594 count = Long.valueOf(0);
2595 }
2596
2597 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_P_N,
2598 finderArgs, count);
2599
2600 closeSession(session);
2601 }
2602 }
2603
2604 return count.intValue();
2605 }
2606
2607 public int countAll() throws SystemException {
2608 Object[] finderArgs = new Object[0];
2609
2610 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
2611 finderArgs, this);
2612
2613 if (count == null) {
2614 Session session = null;
2615
2616 try {
2617 session = openSession();
2618
2619 Query q = session.createQuery(_SQL_COUNT_DLFOLDER);
2620
2621 count = (Long)q.uniqueResult();
2622 }
2623 catch (Exception e) {
2624 throw processException(e);
2625 }
2626 finally {
2627 if (count == null) {
2628 count = Long.valueOf(0);
2629 }
2630
2631 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL, finderArgs,
2632 count);
2633
2634 closeSession(session);
2635 }
2636 }
2637
2638 return count.intValue();
2639 }
2640
2641 public void afterPropertiesSet() {
2642 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
2643 com.liferay.portal.util.PropsUtil.get(
2644 "value.object.listener.com.liferay.portlet.documentlibrary.model.DLFolder")));
2645
2646 if (listenerClassNames.length > 0) {
2647 try {
2648 List<ModelListener<DLFolder>> listenersList = new ArrayList<ModelListener<DLFolder>>();
2649
2650 for (String listenerClassName : listenerClassNames) {
2651 listenersList.add((ModelListener<DLFolder>)Class.forName(
2652 listenerClassName).newInstance());
2653 }
2654
2655 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
2656 }
2657 catch (Exception e) {
2658 _log.error(e);
2659 }
2660 }
2661 }
2662
2663 @BeanReference(type = DLFileEntryPersistence.class)
2664 protected DLFileEntryPersistence dlFileEntryPersistence;
2665 @BeanReference(type = DLFileRankPersistence.class)
2666 protected DLFileRankPersistence dlFileRankPersistence;
2667 @BeanReference(type = DLFileShortcutPersistence.class)
2668 protected DLFileShortcutPersistence dlFileShortcutPersistence;
2669 @BeanReference(type = DLFileVersionPersistence.class)
2670 protected DLFileVersionPersistence dlFileVersionPersistence;
2671 @BeanReference(type = DLFolderPersistence.class)
2672 protected DLFolderPersistence dlFolderPersistence;
2673 @BeanReference(type = LayoutPersistence.class)
2674 protected LayoutPersistence layoutPersistence;
2675 @BeanReference(type = LockPersistence.class)
2676 protected LockPersistence lockPersistence;
2677 @BeanReference(type = ResourcePersistence.class)
2678 protected ResourcePersistence resourcePersistence;
2679 @BeanReference(type = UserPersistence.class)
2680 protected UserPersistence userPersistence;
2681 @BeanReference(type = WebDAVPropsPersistence.class)
2682 protected WebDAVPropsPersistence webDAVPropsPersistence;
2683 @BeanReference(type = ExpandoValuePersistence.class)
2684 protected ExpandoValuePersistence expandoValuePersistence;
2685 private static final String _SQL_SELECT_DLFOLDER = "SELECT dlFolder FROM DLFolder dlFolder";
2686 private static final String _SQL_SELECT_DLFOLDER_WHERE = "SELECT dlFolder FROM DLFolder dlFolder WHERE ";
2687 private static final String _SQL_COUNT_DLFOLDER = "SELECT COUNT(dlFolder) FROM DLFolder dlFolder";
2688 private static final String _SQL_COUNT_DLFOLDER_WHERE = "SELECT COUNT(dlFolder) FROM DLFolder dlFolder WHERE ";
2689 private static final String _FINDER_COLUMN_UUID_UUID_1 = "dlFolder.uuid IS NULL";
2690 private static final String _FINDER_COLUMN_UUID_UUID_2 = "dlFolder.uuid = ?";
2691 private static final String _FINDER_COLUMN_UUID_UUID_3 = "(dlFolder.uuid IS NULL OR dlFolder.uuid = ?)";
2692 private static final String _FINDER_COLUMN_UUID_G_UUID_1 = "dlFolder.uuid IS NULL AND ";
2693 private static final String _FINDER_COLUMN_UUID_G_UUID_2 = "dlFolder.uuid = ? AND ";
2694 private static final String _FINDER_COLUMN_UUID_G_UUID_3 = "(dlFolder.uuid IS NULL OR dlFolder.uuid = ?) AND ";
2695 private static final String _FINDER_COLUMN_UUID_G_GROUPID_2 = "dlFolder.groupId = ?";
2696 private static final String _FINDER_COLUMN_GROUPID_GROUPID_2 = "dlFolder.groupId = ?";
2697 private static final String _FINDER_COLUMN_COMPANYID_COMPANYID_2 = "dlFolder.companyId = ?";
2698 private static final String _FINDER_COLUMN_G_P_GROUPID_2 = "dlFolder.groupId = ? AND ";
2699 private static final String _FINDER_COLUMN_G_P_PARENTFOLDERID_2 = "dlFolder.parentFolderId = ?";
2700 private static final String _FINDER_COLUMN_P_N_PARENTFOLDERID_2 = "dlFolder.parentFolderId = ? AND ";
2701 private static final String _FINDER_COLUMN_P_N_NAME_1 = "dlFolder.name IS NULL";
2702 private static final String _FINDER_COLUMN_P_N_NAME_2 = "dlFolder.name = ?";
2703 private static final String _FINDER_COLUMN_P_N_NAME_3 = "(dlFolder.name IS NULL OR dlFolder.name = ?)";
2704 private static final String _FINDER_COLUMN_G_P_N_GROUPID_2 = "dlFolder.groupId = ? AND ";
2705 private static final String _FINDER_COLUMN_G_P_N_PARENTFOLDERID_2 = "dlFolder.parentFolderId = ? AND ";
2706 private static final String _FINDER_COLUMN_G_P_N_NAME_1 = "dlFolder.name IS NULL";
2707 private static final String _FINDER_COLUMN_G_P_N_NAME_2 = "dlFolder.name = ?";
2708 private static final String _FINDER_COLUMN_G_P_N_NAME_3 = "(dlFolder.name IS NULL OR dlFolder.name = ?)";
2709 private static final String _ORDER_BY_ENTITY_ALIAS = "dlFolder.";
2710 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No DLFolder exists with the primary key ";
2711 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No DLFolder exists with the key {";
2712 private static Log _log = LogFactoryUtil.getLog(DLFolderPersistenceImpl.class);
2713}