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