1
14
15 package com.liferay.portlet.documentlibrary.service.persistence;
16
17 import com.liferay.portal.NoSuchModelException;
18 import com.liferay.portal.kernel.annotation.BeanReference;
19 import com.liferay.portal.kernel.cache.CacheRegistry;
20 import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
21 import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
22 import com.liferay.portal.kernel.dao.orm.FinderPath;
23 import com.liferay.portal.kernel.dao.orm.Query;
24 import com.liferay.portal.kernel.dao.orm.QueryPos;
25 import com.liferay.portal.kernel.dao.orm.QueryUtil;
26 import com.liferay.portal.kernel.dao.orm.Session;
27 import com.liferay.portal.kernel.exception.SystemException;
28 import com.liferay.portal.kernel.log.Log;
29 import com.liferay.portal.kernel.log.LogFactoryUtil;
30 import com.liferay.portal.kernel.util.GetterUtil;
31 import com.liferay.portal.kernel.util.OrderByComparator;
32 import com.liferay.portal.kernel.util.StringBundler;
33 import com.liferay.portal.kernel.util.StringPool;
34 import com.liferay.portal.kernel.util.StringUtil;
35 import com.liferay.portal.kernel.util.Validator;
36 import com.liferay.portal.model.ModelListener;
37 import com.liferay.portal.service.persistence.BatchSessionUtil;
38 import com.liferay.portal.service.persistence.ResourcePersistence;
39 import com.liferay.portal.service.persistence.UserPersistence;
40 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
41
42 import com.liferay.portlet.asset.service.persistence.AssetEntryPersistence;
43 import com.liferay.portlet.documentlibrary.NoSuchFileVersionException;
44 import com.liferay.portlet.documentlibrary.model.DLFileVersion;
45 import com.liferay.portlet.documentlibrary.model.impl.DLFileVersionImpl;
46 import com.liferay.portlet.documentlibrary.model.impl.DLFileVersionModelImpl;
47
48 import java.io.Serializable;
49
50 import java.util.ArrayList;
51 import java.util.Collections;
52 import java.util.List;
53
54
67 public class DLFileVersionPersistenceImpl extends BasePersistenceImpl<DLFileVersion>
68 implements DLFileVersionPersistence {
69 public static final String FINDER_CLASS_NAME_ENTITY = DLFileVersionImpl.class.getName();
70 public static final String FINDER_CLASS_NAME_LIST = FINDER_CLASS_NAME_ENTITY +
71 ".List";
72 public static final FinderPath FINDER_PATH_FIND_BY_G_F_N = new FinderPath(DLFileVersionModelImpl.ENTITY_CACHE_ENABLED,
73 DLFileVersionModelImpl.FINDER_CACHE_ENABLED,
74 FINDER_CLASS_NAME_LIST, "findByG_F_N",
75 new String[] {
76 Long.class.getName(), Long.class.getName(),
77 String.class.getName()
78 });
79 public static final FinderPath FINDER_PATH_FIND_BY_OBC_G_F_N = new FinderPath(DLFileVersionModelImpl.ENTITY_CACHE_ENABLED,
80 DLFileVersionModelImpl.FINDER_CACHE_ENABLED,
81 FINDER_CLASS_NAME_LIST, "findByG_F_N",
82 new String[] {
83 Long.class.getName(), Long.class.getName(),
84 String.class.getName(),
85
86 "java.lang.Integer", "java.lang.Integer",
87 "com.liferay.portal.kernel.util.OrderByComparator"
88 });
89 public static final FinderPath FINDER_PATH_COUNT_BY_G_F_N = new FinderPath(DLFileVersionModelImpl.ENTITY_CACHE_ENABLED,
90 DLFileVersionModelImpl.FINDER_CACHE_ENABLED,
91 FINDER_CLASS_NAME_LIST, "countByG_F_N",
92 new String[] {
93 Long.class.getName(), Long.class.getName(),
94 String.class.getName()
95 });
96 public static final FinderPath FINDER_PATH_FETCH_BY_G_F_N_V = new FinderPath(DLFileVersionModelImpl.ENTITY_CACHE_ENABLED,
97 DLFileVersionModelImpl.FINDER_CACHE_ENABLED,
98 FINDER_CLASS_NAME_ENTITY, "fetchByG_F_N_V",
99 new String[] {
100 Long.class.getName(), Long.class.getName(),
101 String.class.getName(), String.class.getName()
102 });
103 public static final FinderPath FINDER_PATH_COUNT_BY_G_F_N_V = new FinderPath(DLFileVersionModelImpl.ENTITY_CACHE_ENABLED,
104 DLFileVersionModelImpl.FINDER_CACHE_ENABLED,
105 FINDER_CLASS_NAME_LIST, "countByG_F_N_V",
106 new String[] {
107 Long.class.getName(), Long.class.getName(),
108 String.class.getName(), String.class.getName()
109 });
110 public static final FinderPath FINDER_PATH_FIND_BY_G_F_N_S = new FinderPath(DLFileVersionModelImpl.ENTITY_CACHE_ENABLED,
111 DLFileVersionModelImpl.FINDER_CACHE_ENABLED,
112 FINDER_CLASS_NAME_LIST, "findByG_F_N_S",
113 new String[] {
114 Long.class.getName(), Long.class.getName(),
115 String.class.getName(), Integer.class.getName()
116 });
117 public static final FinderPath FINDER_PATH_FIND_BY_OBC_G_F_N_S = new FinderPath(DLFileVersionModelImpl.ENTITY_CACHE_ENABLED,
118 DLFileVersionModelImpl.FINDER_CACHE_ENABLED,
119 FINDER_CLASS_NAME_LIST, "findByG_F_N_S",
120 new String[] {
121 Long.class.getName(), Long.class.getName(),
122 String.class.getName(), Integer.class.getName(),
123
124 "java.lang.Integer", "java.lang.Integer",
125 "com.liferay.portal.kernel.util.OrderByComparator"
126 });
127 public static final FinderPath FINDER_PATH_COUNT_BY_G_F_N_S = new FinderPath(DLFileVersionModelImpl.ENTITY_CACHE_ENABLED,
128 DLFileVersionModelImpl.FINDER_CACHE_ENABLED,
129 FINDER_CLASS_NAME_LIST, "countByG_F_N_S",
130 new String[] {
131 Long.class.getName(), Long.class.getName(),
132 String.class.getName(), Integer.class.getName()
133 });
134 public static final FinderPath FINDER_PATH_FIND_ALL = new FinderPath(DLFileVersionModelImpl.ENTITY_CACHE_ENABLED,
135 DLFileVersionModelImpl.FINDER_CACHE_ENABLED,
136 FINDER_CLASS_NAME_LIST, "findAll", new String[0]);
137 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(DLFileVersionModelImpl.ENTITY_CACHE_ENABLED,
138 DLFileVersionModelImpl.FINDER_CACHE_ENABLED,
139 FINDER_CLASS_NAME_LIST, "countAll", new String[0]);
140
141 public void cacheResult(DLFileVersion dlFileVersion) {
142 EntityCacheUtil.putResult(DLFileVersionModelImpl.ENTITY_CACHE_ENABLED,
143 DLFileVersionImpl.class, dlFileVersion.getPrimaryKey(),
144 dlFileVersion);
145
146 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_F_N_V,
147 new Object[] {
148 new Long(dlFileVersion.getGroupId()),
149 new Long(dlFileVersion.getFolderId()),
150
151 dlFileVersion.getName(),
152
153 dlFileVersion.getVersion()
154 }, dlFileVersion);
155 }
156
157 public void cacheResult(List<DLFileVersion> dlFileVersions) {
158 for (DLFileVersion dlFileVersion : dlFileVersions) {
159 if (EntityCacheUtil.getResult(
160 DLFileVersionModelImpl.ENTITY_CACHE_ENABLED,
161 DLFileVersionImpl.class, dlFileVersion.getPrimaryKey(),
162 this) == null) {
163 cacheResult(dlFileVersion);
164 }
165 }
166 }
167
168 public void clearCache() {
169 CacheRegistry.clear(DLFileVersionImpl.class.getName());
170 EntityCacheUtil.clearCache(DLFileVersionImpl.class.getName());
171 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
172 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
173 }
174
175 public DLFileVersion create(long fileVersionId) {
176 DLFileVersion dlFileVersion = new DLFileVersionImpl();
177
178 dlFileVersion.setNew(true);
179 dlFileVersion.setPrimaryKey(fileVersionId);
180
181 return dlFileVersion;
182 }
183
184 public DLFileVersion remove(Serializable primaryKey)
185 throws NoSuchModelException, SystemException {
186 return remove(((Long)primaryKey).longValue());
187 }
188
189 public DLFileVersion remove(long fileVersionId)
190 throws NoSuchFileVersionException, SystemException {
191 Session session = null;
192
193 try {
194 session = openSession();
195
196 DLFileVersion dlFileVersion = (DLFileVersion)session.get(DLFileVersionImpl.class,
197 new Long(fileVersionId));
198
199 if (dlFileVersion == null) {
200 if (_log.isWarnEnabled()) {
201 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + fileVersionId);
202 }
203
204 throw new NoSuchFileVersionException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
205 fileVersionId);
206 }
207
208 return remove(dlFileVersion);
209 }
210 catch (NoSuchFileVersionException nsee) {
211 throw nsee;
212 }
213 catch (Exception e) {
214 throw processException(e);
215 }
216 finally {
217 closeSession(session);
218 }
219 }
220
221 public DLFileVersion remove(DLFileVersion dlFileVersion)
222 throws SystemException {
223 for (ModelListener<DLFileVersion> listener : listeners) {
224 listener.onBeforeRemove(dlFileVersion);
225 }
226
227 dlFileVersion = removeImpl(dlFileVersion);
228
229 for (ModelListener<DLFileVersion> listener : listeners) {
230 listener.onAfterRemove(dlFileVersion);
231 }
232
233 return dlFileVersion;
234 }
235
236 protected DLFileVersion removeImpl(DLFileVersion dlFileVersion)
237 throws SystemException {
238 dlFileVersion = toUnwrappedModel(dlFileVersion);
239
240 Session session = null;
241
242 try {
243 session = openSession();
244
245 if (dlFileVersion.isCachedModel() || BatchSessionUtil.isEnabled()) {
246 Object staleObject = session.get(DLFileVersionImpl.class,
247 dlFileVersion.getPrimaryKeyObj());
248
249 if (staleObject != null) {
250 session.evict(staleObject);
251 }
252 }
253
254 session.delete(dlFileVersion);
255
256 session.flush();
257 }
258 catch (Exception e) {
259 throw processException(e);
260 }
261 finally {
262 closeSession(session);
263 }
264
265 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
266
267 DLFileVersionModelImpl dlFileVersionModelImpl = (DLFileVersionModelImpl)dlFileVersion;
268
269 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_F_N_V,
270 new Object[] {
271 new Long(dlFileVersionModelImpl.getOriginalGroupId()),
272 new Long(dlFileVersionModelImpl.getOriginalFolderId()),
273
274 dlFileVersionModelImpl.getOriginalName(),
275
276 dlFileVersionModelImpl.getOriginalVersion()
277 });
278
279 EntityCacheUtil.removeResult(DLFileVersionModelImpl.ENTITY_CACHE_ENABLED,
280 DLFileVersionImpl.class, dlFileVersion.getPrimaryKey());
281
282 return dlFileVersion;
283 }
284
285 public DLFileVersion updateImpl(
286 com.liferay.portlet.documentlibrary.model.DLFileVersion dlFileVersion,
287 boolean merge) throws SystemException {
288 dlFileVersion = toUnwrappedModel(dlFileVersion);
289
290 boolean isNew = dlFileVersion.isNew();
291
292 DLFileVersionModelImpl dlFileVersionModelImpl = (DLFileVersionModelImpl)dlFileVersion;
293
294 Session session = null;
295
296 try {
297 session = openSession();
298
299 BatchSessionUtil.update(session, dlFileVersion, merge);
300
301 dlFileVersion.setNew(false);
302 }
303 catch (Exception e) {
304 throw processException(e);
305 }
306 finally {
307 closeSession(session);
308 }
309
310 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
311
312 EntityCacheUtil.putResult(DLFileVersionModelImpl.ENTITY_CACHE_ENABLED,
313 DLFileVersionImpl.class, dlFileVersion.getPrimaryKey(),
314 dlFileVersion);
315
316 if (!isNew &&
317 ((dlFileVersion.getGroupId() != dlFileVersionModelImpl.getOriginalGroupId()) ||
318 (dlFileVersion.getFolderId() != dlFileVersionModelImpl.getOriginalFolderId()) ||
319 !Validator.equals(dlFileVersion.getName(),
320 dlFileVersionModelImpl.getOriginalName()) ||
321 !Validator.equals(dlFileVersion.getVersion(),
322 dlFileVersionModelImpl.getOriginalVersion()))) {
323 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_F_N_V,
324 new Object[] {
325 new Long(dlFileVersionModelImpl.getOriginalGroupId()),
326 new Long(dlFileVersionModelImpl.getOriginalFolderId()),
327
328 dlFileVersionModelImpl.getOriginalName(),
329
330 dlFileVersionModelImpl.getOriginalVersion()
331 });
332 }
333
334 if (isNew ||
335 ((dlFileVersion.getGroupId() != dlFileVersionModelImpl.getOriginalGroupId()) ||
336 (dlFileVersion.getFolderId() != dlFileVersionModelImpl.getOriginalFolderId()) ||
337 !Validator.equals(dlFileVersion.getName(),
338 dlFileVersionModelImpl.getOriginalName()) ||
339 !Validator.equals(dlFileVersion.getVersion(),
340 dlFileVersionModelImpl.getOriginalVersion()))) {
341 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_F_N_V,
342 new Object[] {
343 new Long(dlFileVersion.getGroupId()),
344 new Long(dlFileVersion.getFolderId()),
345
346 dlFileVersion.getName(),
347
348 dlFileVersion.getVersion()
349 }, dlFileVersion);
350 }
351
352 return dlFileVersion;
353 }
354
355 protected DLFileVersion toUnwrappedModel(DLFileVersion dlFileVersion) {
356 if (dlFileVersion instanceof DLFileVersionImpl) {
357 return dlFileVersion;
358 }
359
360 DLFileVersionImpl dlFileVersionImpl = new DLFileVersionImpl();
361
362 dlFileVersionImpl.setNew(dlFileVersion.isNew());
363 dlFileVersionImpl.setPrimaryKey(dlFileVersion.getPrimaryKey());
364
365 dlFileVersionImpl.setFileVersionId(dlFileVersion.getFileVersionId());
366 dlFileVersionImpl.setGroupId(dlFileVersion.getGroupId());
367 dlFileVersionImpl.setCompanyId(dlFileVersion.getCompanyId());
368 dlFileVersionImpl.setUserId(dlFileVersion.getUserId());
369 dlFileVersionImpl.setUserName(dlFileVersion.getUserName());
370 dlFileVersionImpl.setCreateDate(dlFileVersion.getCreateDate());
371 dlFileVersionImpl.setFolderId(dlFileVersion.getFolderId());
372 dlFileVersionImpl.setName(dlFileVersion.getName());
373 dlFileVersionImpl.setDescription(dlFileVersion.getDescription());
374 dlFileVersionImpl.setVersion(dlFileVersion.getVersion());
375 dlFileVersionImpl.setSize(dlFileVersion.getSize());
376 dlFileVersionImpl.setStatus(dlFileVersion.getStatus());
377 dlFileVersionImpl.setStatusByUserId(dlFileVersion.getStatusByUserId());
378 dlFileVersionImpl.setStatusByUserName(dlFileVersion.getStatusByUserName());
379 dlFileVersionImpl.setStatusDate(dlFileVersion.getStatusDate());
380
381 return dlFileVersionImpl;
382 }
383
384 public DLFileVersion findByPrimaryKey(Serializable primaryKey)
385 throws NoSuchModelException, SystemException {
386 return findByPrimaryKey(((Long)primaryKey).longValue());
387 }
388
389 public DLFileVersion findByPrimaryKey(long fileVersionId)
390 throws NoSuchFileVersionException, SystemException {
391 DLFileVersion dlFileVersion = fetchByPrimaryKey(fileVersionId);
392
393 if (dlFileVersion == null) {
394 if (_log.isWarnEnabled()) {
395 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + fileVersionId);
396 }
397
398 throw new NoSuchFileVersionException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
399 fileVersionId);
400 }
401
402 return dlFileVersion;
403 }
404
405 public DLFileVersion fetchByPrimaryKey(Serializable primaryKey)
406 throws SystemException {
407 return fetchByPrimaryKey(((Long)primaryKey).longValue());
408 }
409
410 public DLFileVersion fetchByPrimaryKey(long fileVersionId)
411 throws SystemException {
412 DLFileVersion dlFileVersion = (DLFileVersion)EntityCacheUtil.getResult(DLFileVersionModelImpl.ENTITY_CACHE_ENABLED,
413 DLFileVersionImpl.class, fileVersionId, this);
414
415 if (dlFileVersion == null) {
416 Session session = null;
417
418 try {
419 session = openSession();
420
421 dlFileVersion = (DLFileVersion)session.get(DLFileVersionImpl.class,
422 new Long(fileVersionId));
423 }
424 catch (Exception e) {
425 throw processException(e);
426 }
427 finally {
428 if (dlFileVersion != null) {
429 cacheResult(dlFileVersion);
430 }
431
432 closeSession(session);
433 }
434 }
435
436 return dlFileVersion;
437 }
438
439 public List<DLFileVersion> findByG_F_N(long groupId, long folderId,
440 String name) throws SystemException {
441 Object[] finderArgs = new Object[] {
442 new Long(groupId), new Long(folderId),
443
444 name
445 };
446
447 List<DLFileVersion> list = (List<DLFileVersion>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_G_F_N,
448 finderArgs, this);
449
450 if (list == null) {
451 Session session = null;
452
453 try {
454 session = openSession();
455
456 StringBundler query = new StringBundler(5);
457
458 query.append(_SQL_SELECT_DLFILEVERSION_WHERE);
459
460 query.append(_FINDER_COLUMN_G_F_N_GROUPID_2);
461
462 query.append(_FINDER_COLUMN_G_F_N_FOLDERID_2);
463
464 if (name == null) {
465 query.append(_FINDER_COLUMN_G_F_N_NAME_1);
466 }
467 else {
468 if (name.equals(StringPool.BLANK)) {
469 query.append(_FINDER_COLUMN_G_F_N_NAME_3);
470 }
471 else {
472 query.append(_FINDER_COLUMN_G_F_N_NAME_2);
473 }
474 }
475
476 query.append(DLFileVersionModelImpl.ORDER_BY_JPQL);
477
478 String sql = query.toString();
479
480 Query q = session.createQuery(sql);
481
482 QueryPos qPos = QueryPos.getInstance(q);
483
484 qPos.add(groupId);
485
486 qPos.add(folderId);
487
488 if (name != null) {
489 qPos.add(name);
490 }
491
492 list = q.list();
493 }
494 catch (Exception e) {
495 throw processException(e);
496 }
497 finally {
498 if (list == null) {
499 list = new ArrayList<DLFileVersion>();
500 }
501
502 cacheResult(list);
503
504 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_G_F_N,
505 finderArgs, list);
506
507 closeSession(session);
508 }
509 }
510
511 return list;
512 }
513
514 public List<DLFileVersion> findByG_F_N(long groupId, long folderId,
515 String name, int start, int end) throws SystemException {
516 return findByG_F_N(groupId, folderId, name, start, end, null);
517 }
518
519 public List<DLFileVersion> findByG_F_N(long groupId, long folderId,
520 String name, int start, int end, OrderByComparator orderByComparator)
521 throws SystemException {
522 Object[] finderArgs = new Object[] {
523 new Long(groupId), new Long(folderId),
524
525 name,
526
527 String.valueOf(start), String.valueOf(end),
528 String.valueOf(orderByComparator)
529 };
530
531 List<DLFileVersion> list = (List<DLFileVersion>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_G_F_N,
532 finderArgs, this);
533
534 if (list == null) {
535 Session session = null;
536
537 try {
538 session = openSession();
539
540 StringBundler query = null;
541
542 if (orderByComparator != null) {
543 query = new StringBundler(5 +
544 (orderByComparator.getOrderByFields().length * 3));
545 }
546 else {
547 query = new StringBundler(5);
548 }
549
550 query.append(_SQL_SELECT_DLFILEVERSION_WHERE);
551
552 query.append(_FINDER_COLUMN_G_F_N_GROUPID_2);
553
554 query.append(_FINDER_COLUMN_G_F_N_FOLDERID_2);
555
556 if (name == null) {
557 query.append(_FINDER_COLUMN_G_F_N_NAME_1);
558 }
559 else {
560 if (name.equals(StringPool.BLANK)) {
561 query.append(_FINDER_COLUMN_G_F_N_NAME_3);
562 }
563 else {
564 query.append(_FINDER_COLUMN_G_F_N_NAME_2);
565 }
566 }
567
568 if (orderByComparator != null) {
569 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
570 orderByComparator);
571 }
572
573 else {
574 query.append(DLFileVersionModelImpl.ORDER_BY_JPQL);
575 }
576
577 String sql = query.toString();
578
579 Query q = session.createQuery(sql);
580
581 QueryPos qPos = QueryPos.getInstance(q);
582
583 qPos.add(groupId);
584
585 qPos.add(folderId);
586
587 if (name != null) {
588 qPos.add(name);
589 }
590
591 list = (List<DLFileVersion>)QueryUtil.list(q, getDialect(),
592 start, end);
593 }
594 catch (Exception e) {
595 throw processException(e);
596 }
597 finally {
598 if (list == null) {
599 list = new ArrayList<DLFileVersion>();
600 }
601
602 cacheResult(list);
603
604 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_G_F_N,
605 finderArgs, list);
606
607 closeSession(session);
608 }
609 }
610
611 return list;
612 }
613
614 public DLFileVersion findByG_F_N_First(long groupId, long folderId,
615 String name, OrderByComparator orderByComparator)
616 throws NoSuchFileVersionException, SystemException {
617 List<DLFileVersion> list = findByG_F_N(groupId, folderId, name, 0, 1,
618 orderByComparator);
619
620 if (list.isEmpty()) {
621 StringBundler msg = new StringBundler(8);
622
623 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
624
625 msg.append("groupId=");
626 msg.append(groupId);
627
628 msg.append(", folderId=");
629 msg.append(folderId);
630
631 msg.append(", name=");
632 msg.append(name);
633
634 msg.append(StringPool.CLOSE_CURLY_BRACE);
635
636 throw new NoSuchFileVersionException(msg.toString());
637 }
638 else {
639 return list.get(0);
640 }
641 }
642
643 public DLFileVersion findByG_F_N_Last(long groupId, long folderId,
644 String name, OrderByComparator orderByComparator)
645 throws NoSuchFileVersionException, SystemException {
646 int count = countByG_F_N(groupId, folderId, name);
647
648 List<DLFileVersion> list = findByG_F_N(groupId, folderId, name,
649 count - 1, count, orderByComparator);
650
651 if (list.isEmpty()) {
652 StringBundler msg = new StringBundler(8);
653
654 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
655
656 msg.append("groupId=");
657 msg.append(groupId);
658
659 msg.append(", folderId=");
660 msg.append(folderId);
661
662 msg.append(", name=");
663 msg.append(name);
664
665 msg.append(StringPool.CLOSE_CURLY_BRACE);
666
667 throw new NoSuchFileVersionException(msg.toString());
668 }
669 else {
670 return list.get(0);
671 }
672 }
673
674 public DLFileVersion[] findByG_F_N_PrevAndNext(long fileVersionId,
675 long groupId, long folderId, String name,
676 OrderByComparator orderByComparator)
677 throws NoSuchFileVersionException, SystemException {
678 DLFileVersion dlFileVersion = findByPrimaryKey(fileVersionId);
679
680 int count = countByG_F_N(groupId, folderId, name);
681
682 Session session = null;
683
684 try {
685 session = openSession();
686
687 StringBundler query = null;
688
689 if (orderByComparator != null) {
690 query = new StringBundler(5 +
691 (orderByComparator.getOrderByFields().length * 3));
692 }
693 else {
694 query = new StringBundler(5);
695 }
696
697 query.append(_SQL_SELECT_DLFILEVERSION_WHERE);
698
699 query.append(_FINDER_COLUMN_G_F_N_GROUPID_2);
700
701 query.append(_FINDER_COLUMN_G_F_N_FOLDERID_2);
702
703 if (name == null) {
704 query.append(_FINDER_COLUMN_G_F_N_NAME_1);
705 }
706 else {
707 if (name.equals(StringPool.BLANK)) {
708 query.append(_FINDER_COLUMN_G_F_N_NAME_3);
709 }
710 else {
711 query.append(_FINDER_COLUMN_G_F_N_NAME_2);
712 }
713 }
714
715 if (orderByComparator != null) {
716 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
717 orderByComparator);
718 }
719
720 else {
721 query.append(DLFileVersionModelImpl.ORDER_BY_JPQL);
722 }
723
724 String sql = query.toString();
725
726 Query q = session.createQuery(sql);
727
728 QueryPos qPos = QueryPos.getInstance(q);
729
730 qPos.add(groupId);
731
732 qPos.add(folderId);
733
734 if (name != null) {
735 qPos.add(name);
736 }
737
738 Object[] objArray = QueryUtil.getPrevAndNext(q, count,
739 orderByComparator, dlFileVersion);
740
741 DLFileVersion[] array = new DLFileVersionImpl[3];
742
743 array[0] = (DLFileVersion)objArray[0];
744 array[1] = (DLFileVersion)objArray[1];
745 array[2] = (DLFileVersion)objArray[2];
746
747 return array;
748 }
749 catch (Exception e) {
750 throw processException(e);
751 }
752 finally {
753 closeSession(session);
754 }
755 }
756
757 public DLFileVersion findByG_F_N_V(long groupId, long folderId,
758 String name, String version)
759 throws NoSuchFileVersionException, SystemException {
760 DLFileVersion dlFileVersion = fetchByG_F_N_V(groupId, folderId, name,
761 version);
762
763 if (dlFileVersion == null) {
764 StringBundler msg = new StringBundler(10);
765
766 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
767
768 msg.append("groupId=");
769 msg.append(groupId);
770
771 msg.append(", folderId=");
772 msg.append(folderId);
773
774 msg.append(", name=");
775 msg.append(name);
776
777 msg.append(", version=");
778 msg.append(version);
779
780 msg.append(StringPool.CLOSE_CURLY_BRACE);
781
782 if (_log.isWarnEnabled()) {
783 _log.warn(msg.toString());
784 }
785
786 throw new NoSuchFileVersionException(msg.toString());
787 }
788
789 return dlFileVersion;
790 }
791
792 public DLFileVersion fetchByG_F_N_V(long groupId, long folderId,
793 String name, String version) throws SystemException {
794 return fetchByG_F_N_V(groupId, folderId, name, version, true);
795 }
796
797 public DLFileVersion fetchByG_F_N_V(long groupId, long folderId,
798 String name, String version, boolean retrieveFromCache)
799 throws SystemException {
800 Object[] finderArgs = new Object[] {
801 new Long(groupId), new Long(folderId),
802
803 name,
804
805 version
806 };
807
808 Object result = null;
809
810 if (retrieveFromCache) {
811 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_G_F_N_V,
812 finderArgs, this);
813 }
814
815 if (result == null) {
816 Session session = null;
817
818 try {
819 session = openSession();
820
821 StringBundler query = new StringBundler(6);
822
823 query.append(_SQL_SELECT_DLFILEVERSION_WHERE);
824
825 query.append(_FINDER_COLUMN_G_F_N_V_GROUPID_2);
826
827 query.append(_FINDER_COLUMN_G_F_N_V_FOLDERID_2);
828
829 if (name == null) {
830 query.append(_FINDER_COLUMN_G_F_N_V_NAME_1);
831 }
832 else {
833 if (name.equals(StringPool.BLANK)) {
834 query.append(_FINDER_COLUMN_G_F_N_V_NAME_3);
835 }
836 else {
837 query.append(_FINDER_COLUMN_G_F_N_V_NAME_2);
838 }
839 }
840
841 if (version == null) {
842 query.append(_FINDER_COLUMN_G_F_N_V_VERSION_1);
843 }
844 else {
845 if (version.equals(StringPool.BLANK)) {
846 query.append(_FINDER_COLUMN_G_F_N_V_VERSION_3);
847 }
848 else {
849 query.append(_FINDER_COLUMN_G_F_N_V_VERSION_2);
850 }
851 }
852
853 query.append(DLFileVersionModelImpl.ORDER_BY_JPQL);
854
855 String sql = query.toString();
856
857 Query q = session.createQuery(sql);
858
859 QueryPos qPos = QueryPos.getInstance(q);
860
861 qPos.add(groupId);
862
863 qPos.add(folderId);
864
865 if (name != null) {
866 qPos.add(name);
867 }
868
869 if (version != null) {
870 qPos.add(version);
871 }
872
873 List<DLFileVersion> list = q.list();
874
875 result = list;
876
877 DLFileVersion dlFileVersion = null;
878
879 if (list.isEmpty()) {
880 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_F_N_V,
881 finderArgs, list);
882 }
883 else {
884 dlFileVersion = list.get(0);
885
886 cacheResult(dlFileVersion);
887
888 if ((dlFileVersion.getGroupId() != groupId) ||
889 (dlFileVersion.getFolderId() != folderId) ||
890 (dlFileVersion.getName() == null) ||
891 !dlFileVersion.getName().equals(name) ||
892 (dlFileVersion.getVersion() == null) ||
893 !dlFileVersion.getVersion().equals(version)) {
894 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_F_N_V,
895 finderArgs, dlFileVersion);
896 }
897 }
898
899 return dlFileVersion;
900 }
901 catch (Exception e) {
902 throw processException(e);
903 }
904 finally {
905 if (result == null) {
906 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_F_N_V,
907 finderArgs, new ArrayList<DLFileVersion>());
908 }
909
910 closeSession(session);
911 }
912 }
913 else {
914 if (result instanceof List<?>) {
915 return null;
916 }
917 else {
918 return (DLFileVersion)result;
919 }
920 }
921 }
922
923 public List<DLFileVersion> findByG_F_N_S(long groupId, long folderId,
924 String name, int status) throws SystemException {
925 Object[] finderArgs = new Object[] {
926 new Long(groupId), new Long(folderId),
927
928 name, new Integer(status)
929 };
930
931 List<DLFileVersion> list = (List<DLFileVersion>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_G_F_N_S,
932 finderArgs, this);
933
934 if (list == null) {
935 Session session = null;
936
937 try {
938 session = openSession();
939
940 StringBundler query = new StringBundler(6);
941
942 query.append(_SQL_SELECT_DLFILEVERSION_WHERE);
943
944 query.append(_FINDER_COLUMN_G_F_N_S_GROUPID_2);
945
946 query.append(_FINDER_COLUMN_G_F_N_S_FOLDERID_2);
947
948 if (name == null) {
949 query.append(_FINDER_COLUMN_G_F_N_S_NAME_1);
950 }
951 else {
952 if (name.equals(StringPool.BLANK)) {
953 query.append(_FINDER_COLUMN_G_F_N_S_NAME_3);
954 }
955 else {
956 query.append(_FINDER_COLUMN_G_F_N_S_NAME_2);
957 }
958 }
959
960 query.append(_FINDER_COLUMN_G_F_N_S_STATUS_2);
961
962 query.append(DLFileVersionModelImpl.ORDER_BY_JPQL);
963
964 String sql = query.toString();
965
966 Query q = session.createQuery(sql);
967
968 QueryPos qPos = QueryPos.getInstance(q);
969
970 qPos.add(groupId);
971
972 qPos.add(folderId);
973
974 if (name != null) {
975 qPos.add(name);
976 }
977
978 qPos.add(status);
979
980 list = q.list();
981 }
982 catch (Exception e) {
983 throw processException(e);
984 }
985 finally {
986 if (list == null) {
987 list = new ArrayList<DLFileVersion>();
988 }
989
990 cacheResult(list);
991
992 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_G_F_N_S,
993 finderArgs, list);
994
995 closeSession(session);
996 }
997 }
998
999 return list;
1000 }
1001
1002 public List<DLFileVersion> findByG_F_N_S(long groupId, long folderId,
1003 String name, int status, int start, int end) throws SystemException {
1004 return findByG_F_N_S(groupId, folderId, name, status, start, end, null);
1005 }
1006
1007 public List<DLFileVersion> findByG_F_N_S(long groupId, long folderId,
1008 String name, int status, int start, int end,
1009 OrderByComparator orderByComparator) throws SystemException {
1010 Object[] finderArgs = new Object[] {
1011 new Long(groupId), new Long(folderId),
1012
1013 name, new Integer(status),
1014
1015 String.valueOf(start), String.valueOf(end),
1016 String.valueOf(orderByComparator)
1017 };
1018
1019 List<DLFileVersion> list = (List<DLFileVersion>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_G_F_N_S,
1020 finderArgs, this);
1021
1022 if (list == null) {
1023 Session session = null;
1024
1025 try {
1026 session = openSession();
1027
1028 StringBundler query = null;
1029
1030 if (orderByComparator != null) {
1031 query = new StringBundler(6 +
1032 (orderByComparator.getOrderByFields().length * 3));
1033 }
1034 else {
1035 query = new StringBundler(6);
1036 }
1037
1038 query.append(_SQL_SELECT_DLFILEVERSION_WHERE);
1039
1040 query.append(_FINDER_COLUMN_G_F_N_S_GROUPID_2);
1041
1042 query.append(_FINDER_COLUMN_G_F_N_S_FOLDERID_2);
1043
1044 if (name == null) {
1045 query.append(_FINDER_COLUMN_G_F_N_S_NAME_1);
1046 }
1047 else {
1048 if (name.equals(StringPool.BLANK)) {
1049 query.append(_FINDER_COLUMN_G_F_N_S_NAME_3);
1050 }
1051 else {
1052 query.append(_FINDER_COLUMN_G_F_N_S_NAME_2);
1053 }
1054 }
1055
1056 query.append(_FINDER_COLUMN_G_F_N_S_STATUS_2);
1057
1058 if (orderByComparator != null) {
1059 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1060 orderByComparator);
1061 }
1062
1063 else {
1064 query.append(DLFileVersionModelImpl.ORDER_BY_JPQL);
1065 }
1066
1067 String sql = query.toString();
1068
1069 Query q = session.createQuery(sql);
1070
1071 QueryPos qPos = QueryPos.getInstance(q);
1072
1073 qPos.add(groupId);
1074
1075 qPos.add(folderId);
1076
1077 if (name != null) {
1078 qPos.add(name);
1079 }
1080
1081 qPos.add(status);
1082
1083 list = (List<DLFileVersion>)QueryUtil.list(q, getDialect(),
1084 start, end);
1085 }
1086 catch (Exception e) {
1087 throw processException(e);
1088 }
1089 finally {
1090 if (list == null) {
1091 list = new ArrayList<DLFileVersion>();
1092 }
1093
1094 cacheResult(list);
1095
1096 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_G_F_N_S,
1097 finderArgs, list);
1098
1099 closeSession(session);
1100 }
1101 }
1102
1103 return list;
1104 }
1105
1106 public DLFileVersion findByG_F_N_S_First(long groupId, long folderId,
1107 String name, int status, OrderByComparator orderByComparator)
1108 throws NoSuchFileVersionException, SystemException {
1109 List<DLFileVersion> list = findByG_F_N_S(groupId, folderId, name,
1110 status, 0, 1, orderByComparator);
1111
1112 if (list.isEmpty()) {
1113 StringBundler msg = new StringBundler(10);
1114
1115 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1116
1117 msg.append("groupId=");
1118 msg.append(groupId);
1119
1120 msg.append(", folderId=");
1121 msg.append(folderId);
1122
1123 msg.append(", name=");
1124 msg.append(name);
1125
1126 msg.append(", status=");
1127 msg.append(status);
1128
1129 msg.append(StringPool.CLOSE_CURLY_BRACE);
1130
1131 throw new NoSuchFileVersionException(msg.toString());
1132 }
1133 else {
1134 return list.get(0);
1135 }
1136 }
1137
1138 public DLFileVersion findByG_F_N_S_Last(long groupId, long folderId,
1139 String name, int status, OrderByComparator orderByComparator)
1140 throws NoSuchFileVersionException, SystemException {
1141 int count = countByG_F_N_S(groupId, folderId, name, status);
1142
1143 List<DLFileVersion> list = findByG_F_N_S(groupId, folderId, name,
1144 status, count - 1, count, orderByComparator);
1145
1146 if (list.isEmpty()) {
1147 StringBundler msg = new StringBundler(10);
1148
1149 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1150
1151 msg.append("groupId=");
1152 msg.append(groupId);
1153
1154 msg.append(", folderId=");
1155 msg.append(folderId);
1156
1157 msg.append(", name=");
1158 msg.append(name);
1159
1160 msg.append(", status=");
1161 msg.append(status);
1162
1163 msg.append(StringPool.CLOSE_CURLY_BRACE);
1164
1165 throw new NoSuchFileVersionException(msg.toString());
1166 }
1167 else {
1168 return list.get(0);
1169 }
1170 }
1171
1172 public DLFileVersion[] findByG_F_N_S_PrevAndNext(long fileVersionId,
1173 long groupId, long folderId, String name, int status,
1174 OrderByComparator orderByComparator)
1175 throws NoSuchFileVersionException, SystemException {
1176 DLFileVersion dlFileVersion = findByPrimaryKey(fileVersionId);
1177
1178 int count = countByG_F_N_S(groupId, folderId, name, status);
1179
1180 Session session = null;
1181
1182 try {
1183 session = openSession();
1184
1185 StringBundler query = null;
1186
1187 if (orderByComparator != null) {
1188 query = new StringBundler(6 +
1189 (orderByComparator.getOrderByFields().length * 3));
1190 }
1191 else {
1192 query = new StringBundler(6);
1193 }
1194
1195 query.append(_SQL_SELECT_DLFILEVERSION_WHERE);
1196
1197 query.append(_FINDER_COLUMN_G_F_N_S_GROUPID_2);
1198
1199 query.append(_FINDER_COLUMN_G_F_N_S_FOLDERID_2);
1200
1201 if (name == null) {
1202 query.append(_FINDER_COLUMN_G_F_N_S_NAME_1);
1203 }
1204 else {
1205 if (name.equals(StringPool.BLANK)) {
1206 query.append(_FINDER_COLUMN_G_F_N_S_NAME_3);
1207 }
1208 else {
1209 query.append(_FINDER_COLUMN_G_F_N_S_NAME_2);
1210 }
1211 }
1212
1213 query.append(_FINDER_COLUMN_G_F_N_S_STATUS_2);
1214
1215 if (orderByComparator != null) {
1216 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1217 orderByComparator);
1218 }
1219
1220 else {
1221 query.append(DLFileVersionModelImpl.ORDER_BY_JPQL);
1222 }
1223
1224 String sql = query.toString();
1225
1226 Query q = session.createQuery(sql);
1227
1228 QueryPos qPos = QueryPos.getInstance(q);
1229
1230 qPos.add(groupId);
1231
1232 qPos.add(folderId);
1233
1234 if (name != null) {
1235 qPos.add(name);
1236 }
1237
1238 qPos.add(status);
1239
1240 Object[] objArray = QueryUtil.getPrevAndNext(q, count,
1241 orderByComparator, dlFileVersion);
1242
1243 DLFileVersion[] array = new DLFileVersionImpl[3];
1244
1245 array[0] = (DLFileVersion)objArray[0];
1246 array[1] = (DLFileVersion)objArray[1];
1247 array[2] = (DLFileVersion)objArray[2];
1248
1249 return array;
1250 }
1251 catch (Exception e) {
1252 throw processException(e);
1253 }
1254 finally {
1255 closeSession(session);
1256 }
1257 }
1258
1259 public List<DLFileVersion> findAll() throws SystemException {
1260 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1261 }
1262
1263 public List<DLFileVersion> findAll(int start, int end)
1264 throws SystemException {
1265 return findAll(start, end, null);
1266 }
1267
1268 public List<DLFileVersion> findAll(int start, int end,
1269 OrderByComparator orderByComparator) throws SystemException {
1270 Object[] finderArgs = new Object[] {
1271 String.valueOf(start), String.valueOf(end),
1272 String.valueOf(orderByComparator)
1273 };
1274
1275 List<DLFileVersion> list = (List<DLFileVersion>)FinderCacheUtil.getResult(FINDER_PATH_FIND_ALL,
1276 finderArgs, this);
1277
1278 if (list == null) {
1279 Session session = null;
1280
1281 try {
1282 session = openSession();
1283
1284 StringBundler query = null;
1285 String sql = null;
1286
1287 if (orderByComparator != null) {
1288 query = new StringBundler(2 +
1289 (orderByComparator.getOrderByFields().length * 3));
1290
1291 query.append(_SQL_SELECT_DLFILEVERSION);
1292
1293 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1294 orderByComparator);
1295
1296 sql = query.toString();
1297 }
1298
1299 else {
1300 sql = _SQL_SELECT_DLFILEVERSION.concat(DLFileVersionModelImpl.ORDER_BY_JPQL);
1301 }
1302
1303 Query q = session.createQuery(sql);
1304
1305 if (orderByComparator == null) {
1306 list = (List<DLFileVersion>)QueryUtil.list(q, getDialect(),
1307 start, end, false);
1308
1309 Collections.sort(list);
1310 }
1311 else {
1312 list = (List<DLFileVersion>)QueryUtil.list(q, getDialect(),
1313 start, end);
1314 }
1315 }
1316 catch (Exception e) {
1317 throw processException(e);
1318 }
1319 finally {
1320 if (list == null) {
1321 list = new ArrayList<DLFileVersion>();
1322 }
1323
1324 cacheResult(list);
1325
1326 FinderCacheUtil.putResult(FINDER_PATH_FIND_ALL, finderArgs, list);
1327
1328 closeSession(session);
1329 }
1330 }
1331
1332 return list;
1333 }
1334
1335 public void removeByG_F_N(long groupId, long folderId, String name)
1336 throws SystemException {
1337 for (DLFileVersion dlFileVersion : findByG_F_N(groupId, folderId, name)) {
1338 remove(dlFileVersion);
1339 }
1340 }
1341
1342 public void removeByG_F_N_V(long groupId, long folderId, String name,
1343 String version) throws NoSuchFileVersionException, SystemException {
1344 DLFileVersion dlFileVersion = findByG_F_N_V(groupId, folderId, name,
1345 version);
1346
1347 remove(dlFileVersion);
1348 }
1349
1350 public void removeByG_F_N_S(long groupId, long folderId, String name,
1351 int status) throws SystemException {
1352 for (DLFileVersion dlFileVersion : findByG_F_N_S(groupId, folderId,
1353 name, status)) {
1354 remove(dlFileVersion);
1355 }
1356 }
1357
1358 public void removeAll() throws SystemException {
1359 for (DLFileVersion dlFileVersion : findAll()) {
1360 remove(dlFileVersion);
1361 }
1362 }
1363
1364 public int countByG_F_N(long groupId, long folderId, String name)
1365 throws SystemException {
1366 Object[] finderArgs = new Object[] {
1367 new Long(groupId), new Long(folderId),
1368
1369 name
1370 };
1371
1372 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_F_N,
1373 finderArgs, this);
1374
1375 if (count == null) {
1376 Session session = null;
1377
1378 try {
1379 session = openSession();
1380
1381 StringBundler query = new StringBundler(4);
1382
1383 query.append(_SQL_COUNT_DLFILEVERSION_WHERE);
1384
1385 query.append(_FINDER_COLUMN_G_F_N_GROUPID_2);
1386
1387 query.append(_FINDER_COLUMN_G_F_N_FOLDERID_2);
1388
1389 if (name == null) {
1390 query.append(_FINDER_COLUMN_G_F_N_NAME_1);
1391 }
1392 else {
1393 if (name.equals(StringPool.BLANK)) {
1394 query.append(_FINDER_COLUMN_G_F_N_NAME_3);
1395 }
1396 else {
1397 query.append(_FINDER_COLUMN_G_F_N_NAME_2);
1398 }
1399 }
1400
1401 String sql = query.toString();
1402
1403 Query q = session.createQuery(sql);
1404
1405 QueryPos qPos = QueryPos.getInstance(q);
1406
1407 qPos.add(groupId);
1408
1409 qPos.add(folderId);
1410
1411 if (name != null) {
1412 qPos.add(name);
1413 }
1414
1415 count = (Long)q.uniqueResult();
1416 }
1417 catch (Exception e) {
1418 throw processException(e);
1419 }
1420 finally {
1421 if (count == null) {
1422 count = Long.valueOf(0);
1423 }
1424
1425 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_F_N,
1426 finderArgs, count);
1427
1428 closeSession(session);
1429 }
1430 }
1431
1432 return count.intValue();
1433 }
1434
1435 public int countByG_F_N_V(long groupId, long folderId, String name,
1436 String version) throws SystemException {
1437 Object[] finderArgs = new Object[] {
1438 new Long(groupId), new Long(folderId),
1439
1440 name,
1441
1442 version
1443 };
1444
1445 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_F_N_V,
1446 finderArgs, this);
1447
1448 if (count == null) {
1449 Session session = null;
1450
1451 try {
1452 session = openSession();
1453
1454 StringBundler query = new StringBundler(5);
1455
1456 query.append(_SQL_COUNT_DLFILEVERSION_WHERE);
1457
1458 query.append(_FINDER_COLUMN_G_F_N_V_GROUPID_2);
1459
1460 query.append(_FINDER_COLUMN_G_F_N_V_FOLDERID_2);
1461
1462 if (name == null) {
1463 query.append(_FINDER_COLUMN_G_F_N_V_NAME_1);
1464 }
1465 else {
1466 if (name.equals(StringPool.BLANK)) {
1467 query.append(_FINDER_COLUMN_G_F_N_V_NAME_3);
1468 }
1469 else {
1470 query.append(_FINDER_COLUMN_G_F_N_V_NAME_2);
1471 }
1472 }
1473
1474 if (version == null) {
1475 query.append(_FINDER_COLUMN_G_F_N_V_VERSION_1);
1476 }
1477 else {
1478 if (version.equals(StringPool.BLANK)) {
1479 query.append(_FINDER_COLUMN_G_F_N_V_VERSION_3);
1480 }
1481 else {
1482 query.append(_FINDER_COLUMN_G_F_N_V_VERSION_2);
1483 }
1484 }
1485
1486 String sql = query.toString();
1487
1488 Query q = session.createQuery(sql);
1489
1490 QueryPos qPos = QueryPos.getInstance(q);
1491
1492 qPos.add(groupId);
1493
1494 qPos.add(folderId);
1495
1496 if (name != null) {
1497 qPos.add(name);
1498 }
1499
1500 if (version != null) {
1501 qPos.add(version);
1502 }
1503
1504 count = (Long)q.uniqueResult();
1505 }
1506 catch (Exception e) {
1507 throw processException(e);
1508 }
1509 finally {
1510 if (count == null) {
1511 count = Long.valueOf(0);
1512 }
1513
1514 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_F_N_V,
1515 finderArgs, count);
1516
1517 closeSession(session);
1518 }
1519 }
1520
1521 return count.intValue();
1522 }
1523
1524 public int countByG_F_N_S(long groupId, long folderId, String name,
1525 int status) throws SystemException {
1526 Object[] finderArgs = new Object[] {
1527 new Long(groupId), new Long(folderId),
1528
1529 name, new Integer(status)
1530 };
1531
1532 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_F_N_S,
1533 finderArgs, this);
1534
1535 if (count == null) {
1536 Session session = null;
1537
1538 try {
1539 session = openSession();
1540
1541 StringBundler query = new StringBundler(5);
1542
1543 query.append(_SQL_COUNT_DLFILEVERSION_WHERE);
1544
1545 query.append(_FINDER_COLUMN_G_F_N_S_GROUPID_2);
1546
1547 query.append(_FINDER_COLUMN_G_F_N_S_FOLDERID_2);
1548
1549 if (name == null) {
1550 query.append(_FINDER_COLUMN_G_F_N_S_NAME_1);
1551 }
1552 else {
1553 if (name.equals(StringPool.BLANK)) {
1554 query.append(_FINDER_COLUMN_G_F_N_S_NAME_3);
1555 }
1556 else {
1557 query.append(_FINDER_COLUMN_G_F_N_S_NAME_2);
1558 }
1559 }
1560
1561 query.append(_FINDER_COLUMN_G_F_N_S_STATUS_2);
1562
1563 String sql = query.toString();
1564
1565 Query q = session.createQuery(sql);
1566
1567 QueryPos qPos = QueryPos.getInstance(q);
1568
1569 qPos.add(groupId);
1570
1571 qPos.add(folderId);
1572
1573 if (name != null) {
1574 qPos.add(name);
1575 }
1576
1577 qPos.add(status);
1578
1579 count = (Long)q.uniqueResult();
1580 }
1581 catch (Exception e) {
1582 throw processException(e);
1583 }
1584 finally {
1585 if (count == null) {
1586 count = Long.valueOf(0);
1587 }
1588
1589 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_F_N_S,
1590 finderArgs, count);
1591
1592 closeSession(session);
1593 }
1594 }
1595
1596 return count.intValue();
1597 }
1598
1599 public int countAll() throws SystemException {
1600 Object[] finderArgs = new Object[0];
1601
1602 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
1603 finderArgs, this);
1604
1605 if (count == null) {
1606 Session session = null;
1607
1608 try {
1609 session = openSession();
1610
1611 Query q = session.createQuery(_SQL_COUNT_DLFILEVERSION);
1612
1613 count = (Long)q.uniqueResult();
1614 }
1615 catch (Exception e) {
1616 throw processException(e);
1617 }
1618 finally {
1619 if (count == null) {
1620 count = Long.valueOf(0);
1621 }
1622
1623 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL, finderArgs,
1624 count);
1625
1626 closeSession(session);
1627 }
1628 }
1629
1630 return count.intValue();
1631 }
1632
1633 public void afterPropertiesSet() {
1634 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
1635 com.liferay.portal.util.PropsUtil.get(
1636 "value.object.listener.com.liferay.portlet.documentlibrary.model.DLFileVersion")));
1637
1638 if (listenerClassNames.length > 0) {
1639 try {
1640 List<ModelListener<DLFileVersion>> listenersList = new ArrayList<ModelListener<DLFileVersion>>();
1641
1642 for (String listenerClassName : listenerClassNames) {
1643 listenersList.add((ModelListener<DLFileVersion>)Class.forName(
1644 listenerClassName).newInstance());
1645 }
1646
1647 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
1648 }
1649 catch (Exception e) {
1650 _log.error(e);
1651 }
1652 }
1653 }
1654
1655 @BeanReference(type = DLFileEntryPersistence.class)
1656 protected DLFileEntryPersistence dlFileEntryPersistence;
1657 @BeanReference(type = DLFileRankPersistence.class)
1658 protected DLFileRankPersistence dlFileRankPersistence;
1659 @BeanReference(type = DLFileShortcutPersistence.class)
1660 protected DLFileShortcutPersistence dlFileShortcutPersistence;
1661 @BeanReference(type = DLFileVersionPersistence.class)
1662 protected DLFileVersionPersistence dlFileVersionPersistence;
1663 @BeanReference(type = DLFolderPersistence.class)
1664 protected DLFolderPersistence dlFolderPersistence;
1665 @BeanReference(type = ResourcePersistence.class)
1666 protected ResourcePersistence resourcePersistence;
1667 @BeanReference(type = UserPersistence.class)
1668 protected UserPersistence userPersistence;
1669 @BeanReference(type = AssetEntryPersistence.class)
1670 protected AssetEntryPersistence assetEntryPersistence;
1671 private static final String _SQL_SELECT_DLFILEVERSION = "SELECT dlFileVersion FROM DLFileVersion dlFileVersion";
1672 private static final String _SQL_SELECT_DLFILEVERSION_WHERE = "SELECT dlFileVersion FROM DLFileVersion dlFileVersion WHERE ";
1673 private static final String _SQL_COUNT_DLFILEVERSION = "SELECT COUNT(dlFileVersion) FROM DLFileVersion dlFileVersion";
1674 private static final String _SQL_COUNT_DLFILEVERSION_WHERE = "SELECT COUNT(dlFileVersion) FROM DLFileVersion dlFileVersion WHERE ";
1675 private static final String _FINDER_COLUMN_G_F_N_GROUPID_2 = "dlFileVersion.groupId = ? AND ";
1676 private static final String _FINDER_COLUMN_G_F_N_FOLDERID_2 = "dlFileVersion.folderId = ? AND ";
1677 private static final String _FINDER_COLUMN_G_F_N_NAME_1 = "dlFileVersion.name IS NULL";
1678 private static final String _FINDER_COLUMN_G_F_N_NAME_2 = "dlFileVersion.name = ?";
1679 private static final String _FINDER_COLUMN_G_F_N_NAME_3 = "(dlFileVersion.name IS NULL OR dlFileVersion.name = ?)";
1680 private static final String _FINDER_COLUMN_G_F_N_V_GROUPID_2 = "dlFileVersion.groupId = ? AND ";
1681 private static final String _FINDER_COLUMN_G_F_N_V_FOLDERID_2 = "dlFileVersion.folderId = ? AND ";
1682 private static final String _FINDER_COLUMN_G_F_N_V_NAME_1 = "dlFileVersion.name IS NULL AND ";
1683 private static final String _FINDER_COLUMN_G_F_N_V_NAME_2 = "dlFileVersion.name = ? AND ";
1684 private static final String _FINDER_COLUMN_G_F_N_V_NAME_3 = "(dlFileVersion.name IS NULL OR dlFileVersion.name = ?) AND ";
1685 private static final String _FINDER_COLUMN_G_F_N_V_VERSION_1 = "dlFileVersion.version IS NULL";
1686 private static final String _FINDER_COLUMN_G_F_N_V_VERSION_2 = "dlFileVersion.version = ?";
1687 private static final String _FINDER_COLUMN_G_F_N_V_VERSION_3 = "(dlFileVersion.version IS NULL OR dlFileVersion.version = ?)";
1688 private static final String _FINDER_COLUMN_G_F_N_S_GROUPID_2 = "dlFileVersion.groupId = ? AND ";
1689 private static final String _FINDER_COLUMN_G_F_N_S_FOLDERID_2 = "dlFileVersion.folderId = ? AND ";
1690 private static final String _FINDER_COLUMN_G_F_N_S_NAME_1 = "dlFileVersion.name IS NULL AND ";
1691 private static final String _FINDER_COLUMN_G_F_N_S_NAME_2 = "dlFileVersion.name = ? AND ";
1692 private static final String _FINDER_COLUMN_G_F_N_S_NAME_3 = "(dlFileVersion.name IS NULL OR dlFileVersion.name = ?) AND ";
1693 private static final String _FINDER_COLUMN_G_F_N_S_STATUS_2 = "dlFileVersion.status = ?";
1694 private static final String _ORDER_BY_ENTITY_ALIAS = "dlFileVersion.";
1695 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No DLFileVersion exists with the primary key ";
1696 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No DLFileVersion exists with the key {";
1697 private static Log _log = LogFactoryUtil.getLog(DLFileVersionPersistenceImpl.class);
1698}