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