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