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