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