001
014
015 package com.liferay.portlet.documentlibrary.service.persistence;
016
017 import com.liferay.portal.NoSuchModelException;
018 import com.liferay.portal.kernel.bean.BeanReference;
019 import com.liferay.portal.kernel.cache.CacheRegistryUtil;
020 import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
021 import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
022 import com.liferay.portal.kernel.dao.orm.FinderPath;
023 import com.liferay.portal.kernel.dao.orm.Query;
024 import com.liferay.portal.kernel.dao.orm.QueryPos;
025 import com.liferay.portal.kernel.dao.orm.QueryUtil;
026 import com.liferay.portal.kernel.dao.orm.Session;
027 import com.liferay.portal.kernel.exception.SystemException;
028 import com.liferay.portal.kernel.log.Log;
029 import com.liferay.portal.kernel.log.LogFactoryUtil;
030 import com.liferay.portal.kernel.util.GetterUtil;
031 import com.liferay.portal.kernel.util.InstanceFactory;
032 import com.liferay.portal.kernel.util.OrderByComparator;
033 import com.liferay.portal.kernel.util.StringBundler;
034 import com.liferay.portal.kernel.util.StringPool;
035 import com.liferay.portal.kernel.util.StringUtil;
036 import com.liferay.portal.kernel.util.Validator;
037 import com.liferay.portal.kernel.uuid.PortalUUIDUtil;
038 import com.liferay.portal.model.CacheModel;
039 import com.liferay.portal.model.ModelListener;
040 import com.liferay.portal.service.persistence.UserPersistence;
041 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
042
043 import com.liferay.portlet.documentlibrary.NoSuchFileVersionException;
044 import com.liferay.portlet.documentlibrary.model.DLFileVersion;
045 import com.liferay.portlet.documentlibrary.model.impl.DLFileVersionImpl;
046 import com.liferay.portlet.documentlibrary.model.impl.DLFileVersionModelImpl;
047
048 import java.io.Serializable;
049
050 import java.util.ArrayList;
051 import java.util.Collections;
052 import java.util.List;
053
054
066 public class DLFileVersionPersistenceImpl extends BasePersistenceImpl<DLFileVersion>
067 implements DLFileVersionPersistence {
068
073 public static final String FINDER_CLASS_NAME_ENTITY = DLFileVersionImpl.class.getName();
074 public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
075 ".List1";
076 public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
077 ".List2";
078 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID = new FinderPath(DLFileVersionModelImpl.ENTITY_CACHE_ENABLED,
079 DLFileVersionModelImpl.FINDER_CACHE_ENABLED,
080 DLFileVersionImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
081 "findByUuid",
082 new String[] {
083 String.class.getName(),
084
085 "java.lang.Integer", "java.lang.Integer",
086 "com.liferay.portal.kernel.util.OrderByComparator"
087 });
088 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID = new FinderPath(DLFileVersionModelImpl.ENTITY_CACHE_ENABLED,
089 DLFileVersionModelImpl.FINDER_CACHE_ENABLED,
090 DLFileVersionImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
091 "findByUuid", new String[] { String.class.getName() },
092 DLFileVersionModelImpl.UUID_COLUMN_BITMASK);
093 public static final FinderPath FINDER_PATH_COUNT_BY_UUID = new FinderPath(DLFileVersionModelImpl.ENTITY_CACHE_ENABLED,
094 DLFileVersionModelImpl.FINDER_CACHE_ENABLED, Long.class,
095 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid",
096 new String[] { String.class.getName() });
097 public static final FinderPath FINDER_PATH_FETCH_BY_UUID_G = new FinderPath(DLFileVersionModelImpl.ENTITY_CACHE_ENABLED,
098 DLFileVersionModelImpl.FINDER_CACHE_ENABLED,
099 DLFileVersionImpl.class, FINDER_CLASS_NAME_ENTITY, "fetchByUUID_G",
100 new String[] { String.class.getName(), Long.class.getName() },
101 DLFileVersionModelImpl.UUID_COLUMN_BITMASK |
102 DLFileVersionModelImpl.GROUPID_COLUMN_BITMASK);
103 public static final FinderPath FINDER_PATH_COUNT_BY_UUID_G = new FinderPath(DLFileVersionModelImpl.ENTITY_CACHE_ENABLED,
104 DLFileVersionModelImpl.FINDER_CACHE_ENABLED, Long.class,
105 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUUID_G",
106 new String[] { String.class.getName(), Long.class.getName() });
107 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID_C = new FinderPath(DLFileVersionModelImpl.ENTITY_CACHE_ENABLED,
108 DLFileVersionModelImpl.FINDER_CACHE_ENABLED,
109 DLFileVersionImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
110 "findByUuid_C",
111 new String[] {
112 String.class.getName(), Long.class.getName(),
113
114 "java.lang.Integer", "java.lang.Integer",
115 "com.liferay.portal.kernel.util.OrderByComparator"
116 });
117 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C =
118 new FinderPath(DLFileVersionModelImpl.ENTITY_CACHE_ENABLED,
119 DLFileVersionModelImpl.FINDER_CACHE_ENABLED,
120 DLFileVersionImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
121 "findByUuid_C",
122 new String[] { String.class.getName(), Long.class.getName() },
123 DLFileVersionModelImpl.UUID_COLUMN_BITMASK |
124 DLFileVersionModelImpl.COMPANYID_COLUMN_BITMASK);
125 public static final FinderPath FINDER_PATH_COUNT_BY_UUID_C = new FinderPath(DLFileVersionModelImpl.ENTITY_CACHE_ENABLED,
126 DLFileVersionModelImpl.FINDER_CACHE_ENABLED, Long.class,
127 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid_C",
128 new String[] { String.class.getName(), Long.class.getName() });
129 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_FILEENTRYID =
130 new FinderPath(DLFileVersionModelImpl.ENTITY_CACHE_ENABLED,
131 DLFileVersionModelImpl.FINDER_CACHE_ENABLED,
132 DLFileVersionImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
133 "findByFileEntryId",
134 new String[] {
135 Long.class.getName(),
136
137 "java.lang.Integer", "java.lang.Integer",
138 "com.liferay.portal.kernel.util.OrderByComparator"
139 });
140 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_FILEENTRYID =
141 new FinderPath(DLFileVersionModelImpl.ENTITY_CACHE_ENABLED,
142 DLFileVersionModelImpl.FINDER_CACHE_ENABLED,
143 DLFileVersionImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
144 "findByFileEntryId", new String[] { Long.class.getName() },
145 DLFileVersionModelImpl.FILEENTRYID_COLUMN_BITMASK);
146 public static final FinderPath FINDER_PATH_COUNT_BY_FILEENTRYID = new FinderPath(DLFileVersionModelImpl.ENTITY_CACHE_ENABLED,
147 DLFileVersionModelImpl.FINDER_CACHE_ENABLED, Long.class,
148 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByFileEntryId",
149 new String[] { Long.class.getName() });
150 public static final FinderPath FINDER_PATH_FETCH_BY_F_V = new FinderPath(DLFileVersionModelImpl.ENTITY_CACHE_ENABLED,
151 DLFileVersionModelImpl.FINDER_CACHE_ENABLED,
152 DLFileVersionImpl.class, FINDER_CLASS_NAME_ENTITY, "fetchByF_V",
153 new String[] { Long.class.getName(), String.class.getName() },
154 DLFileVersionModelImpl.FILEENTRYID_COLUMN_BITMASK |
155 DLFileVersionModelImpl.VERSION_COLUMN_BITMASK);
156 public static final FinderPath FINDER_PATH_COUNT_BY_F_V = new FinderPath(DLFileVersionModelImpl.ENTITY_CACHE_ENABLED,
157 DLFileVersionModelImpl.FINDER_CACHE_ENABLED, Long.class,
158 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByF_V",
159 new String[] { Long.class.getName(), String.class.getName() });
160 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_F_S = new FinderPath(DLFileVersionModelImpl.ENTITY_CACHE_ENABLED,
161 DLFileVersionModelImpl.FINDER_CACHE_ENABLED,
162 DLFileVersionImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
163 "findByF_S",
164 new String[] {
165 Long.class.getName(), Integer.class.getName(),
166
167 "java.lang.Integer", "java.lang.Integer",
168 "com.liferay.portal.kernel.util.OrderByComparator"
169 });
170 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_F_S = new FinderPath(DLFileVersionModelImpl.ENTITY_CACHE_ENABLED,
171 DLFileVersionModelImpl.FINDER_CACHE_ENABLED,
172 DLFileVersionImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
173 "findByF_S",
174 new String[] { Long.class.getName(), Integer.class.getName() },
175 DLFileVersionModelImpl.FILEENTRYID_COLUMN_BITMASK |
176 DLFileVersionModelImpl.STATUS_COLUMN_BITMASK);
177 public static final FinderPath FINDER_PATH_COUNT_BY_F_S = new FinderPath(DLFileVersionModelImpl.ENTITY_CACHE_ENABLED,
178 DLFileVersionModelImpl.FINDER_CACHE_ENABLED, Long.class,
179 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByF_S",
180 new String[] { Long.class.getName(), Integer.class.getName() });
181 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F_S = new FinderPath(DLFileVersionModelImpl.ENTITY_CACHE_ENABLED,
182 DLFileVersionModelImpl.FINDER_CACHE_ENABLED,
183 DLFileVersionImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
184 "findByG_F_S",
185 new String[] {
186 Long.class.getName(), Long.class.getName(),
187 Integer.class.getName(),
188
189 "java.lang.Integer", "java.lang.Integer",
190 "com.liferay.portal.kernel.util.OrderByComparator"
191 });
192 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F_S = new FinderPath(DLFileVersionModelImpl.ENTITY_CACHE_ENABLED,
193 DLFileVersionModelImpl.FINDER_CACHE_ENABLED,
194 DLFileVersionImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
195 "findByG_F_S",
196 new String[] {
197 Long.class.getName(), Long.class.getName(),
198 Integer.class.getName()
199 },
200 DLFileVersionModelImpl.GROUPID_COLUMN_BITMASK |
201 DLFileVersionModelImpl.FOLDERID_COLUMN_BITMASK |
202 DLFileVersionModelImpl.STATUS_COLUMN_BITMASK);
203 public static final FinderPath FINDER_PATH_COUNT_BY_G_F_S = new FinderPath(DLFileVersionModelImpl.ENTITY_CACHE_ENABLED,
204 DLFileVersionModelImpl.FINDER_CACHE_ENABLED, Long.class,
205 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_F_S",
206 new String[] {
207 Long.class.getName(), Long.class.getName(),
208 Integer.class.getName()
209 });
210 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F_T_V = new FinderPath(DLFileVersionModelImpl.ENTITY_CACHE_ENABLED,
211 DLFileVersionModelImpl.FINDER_CACHE_ENABLED,
212 DLFileVersionImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
213 "findByG_F_T_V",
214 new String[] {
215 Long.class.getName(), Long.class.getName(),
216 String.class.getName(), String.class.getName(),
217
218 "java.lang.Integer", "java.lang.Integer",
219 "com.liferay.portal.kernel.util.OrderByComparator"
220 });
221 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F_T_V =
222 new FinderPath(DLFileVersionModelImpl.ENTITY_CACHE_ENABLED,
223 DLFileVersionModelImpl.FINDER_CACHE_ENABLED,
224 DLFileVersionImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
225 "findByG_F_T_V",
226 new String[] {
227 Long.class.getName(), Long.class.getName(),
228 String.class.getName(), String.class.getName()
229 },
230 DLFileVersionModelImpl.GROUPID_COLUMN_BITMASK |
231 DLFileVersionModelImpl.FOLDERID_COLUMN_BITMASK |
232 DLFileVersionModelImpl.TITLE_COLUMN_BITMASK |
233 DLFileVersionModelImpl.VERSION_COLUMN_BITMASK);
234 public static final FinderPath FINDER_PATH_COUNT_BY_G_F_T_V = new FinderPath(DLFileVersionModelImpl.ENTITY_CACHE_ENABLED,
235 DLFileVersionModelImpl.FINDER_CACHE_ENABLED, Long.class,
236 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_F_T_V",
237 new String[] {
238 Long.class.getName(), Long.class.getName(),
239 String.class.getName(), String.class.getName()
240 });
241 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(DLFileVersionModelImpl.ENTITY_CACHE_ENABLED,
242 DLFileVersionModelImpl.FINDER_CACHE_ENABLED,
243 DLFileVersionImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
244 "findAll", new String[0]);
245 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(DLFileVersionModelImpl.ENTITY_CACHE_ENABLED,
246 DLFileVersionModelImpl.FINDER_CACHE_ENABLED,
247 DLFileVersionImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
248 "findAll", new String[0]);
249 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(DLFileVersionModelImpl.ENTITY_CACHE_ENABLED,
250 DLFileVersionModelImpl.FINDER_CACHE_ENABLED, Long.class,
251 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
252
253
258 public void cacheResult(DLFileVersion dlFileVersion) {
259 EntityCacheUtil.putResult(DLFileVersionModelImpl.ENTITY_CACHE_ENABLED,
260 DLFileVersionImpl.class, dlFileVersion.getPrimaryKey(),
261 dlFileVersion);
262
263 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
264 new Object[] {
265 dlFileVersion.getUuid(),
266 Long.valueOf(dlFileVersion.getGroupId())
267 }, dlFileVersion);
268
269 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_F_V,
270 new Object[] {
271 Long.valueOf(dlFileVersion.getFileEntryId()),
272
273 dlFileVersion.getVersion()
274 }, dlFileVersion);
275
276 dlFileVersion.resetOriginalValues();
277 }
278
279
284 public void cacheResult(List<DLFileVersion> dlFileVersions) {
285 for (DLFileVersion dlFileVersion : dlFileVersions) {
286 if (EntityCacheUtil.getResult(
287 DLFileVersionModelImpl.ENTITY_CACHE_ENABLED,
288 DLFileVersionImpl.class, dlFileVersion.getPrimaryKey()) == null) {
289 cacheResult(dlFileVersion);
290 }
291 else {
292 dlFileVersion.resetOriginalValues();
293 }
294 }
295 }
296
297
304 @Override
305 public void clearCache() {
306 if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
307 CacheRegistryUtil.clear(DLFileVersionImpl.class.getName());
308 }
309
310 EntityCacheUtil.clearCache(DLFileVersionImpl.class.getName());
311
312 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
313 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
314 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
315 }
316
317
324 @Override
325 public void clearCache(DLFileVersion dlFileVersion) {
326 EntityCacheUtil.removeResult(DLFileVersionModelImpl.ENTITY_CACHE_ENABLED,
327 DLFileVersionImpl.class, dlFileVersion.getPrimaryKey());
328
329 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
330 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
331
332 clearUniqueFindersCache(dlFileVersion);
333 }
334
335 @Override
336 public void clearCache(List<DLFileVersion> dlFileVersions) {
337 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
338 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
339
340 for (DLFileVersion dlFileVersion : dlFileVersions) {
341 EntityCacheUtil.removeResult(DLFileVersionModelImpl.ENTITY_CACHE_ENABLED,
342 DLFileVersionImpl.class, dlFileVersion.getPrimaryKey());
343
344 clearUniqueFindersCache(dlFileVersion);
345 }
346 }
347
348 protected void clearUniqueFindersCache(DLFileVersion dlFileVersion) {
349 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
350 new Object[] {
351 dlFileVersion.getUuid(),
352 Long.valueOf(dlFileVersion.getGroupId())
353 });
354
355 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_F_V,
356 new Object[] {
357 Long.valueOf(dlFileVersion.getFileEntryId()),
358
359 dlFileVersion.getVersion()
360 });
361 }
362
363
369 public DLFileVersion create(long fileVersionId) {
370 DLFileVersion dlFileVersion = new DLFileVersionImpl();
371
372 dlFileVersion.setNew(true);
373 dlFileVersion.setPrimaryKey(fileVersionId);
374
375 String uuid = PortalUUIDUtil.generate();
376
377 dlFileVersion.setUuid(uuid);
378
379 return dlFileVersion;
380 }
381
382
390 public DLFileVersion remove(long fileVersionId)
391 throws NoSuchFileVersionException, SystemException {
392 return remove(Long.valueOf(fileVersionId));
393 }
394
395
403 @Override
404 public DLFileVersion remove(Serializable primaryKey)
405 throws NoSuchFileVersionException, SystemException {
406 Session session = null;
407
408 try {
409 session = openSession();
410
411 DLFileVersion dlFileVersion = (DLFileVersion)session.get(DLFileVersionImpl.class,
412 primaryKey);
413
414 if (dlFileVersion == null) {
415 if (_log.isWarnEnabled()) {
416 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
417 }
418
419 throw new NoSuchFileVersionException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
420 primaryKey);
421 }
422
423 return remove(dlFileVersion);
424 }
425 catch (NoSuchFileVersionException nsee) {
426 throw nsee;
427 }
428 catch (Exception e) {
429 throw processException(e);
430 }
431 finally {
432 closeSession(session);
433 }
434 }
435
436 @Override
437 protected DLFileVersion removeImpl(DLFileVersion dlFileVersion)
438 throws SystemException {
439 dlFileVersion = toUnwrappedModel(dlFileVersion);
440
441 Session session = null;
442
443 try {
444 session = openSession();
445
446 if (dlFileVersion.isCachedModel()) {
447 dlFileVersion = (DLFileVersion)session.get(DLFileVersionImpl.class,
448 dlFileVersion.getPrimaryKeyObj());
449 }
450
451 session.delete(dlFileVersion);
452 }
453 catch (Exception e) {
454 throw processException(e);
455 }
456 finally {
457 closeSession(session);
458 }
459
460 clearCache(dlFileVersion);
461
462 return dlFileVersion;
463 }
464
465 @Override
466 public DLFileVersion updateImpl(
467 com.liferay.portlet.documentlibrary.model.DLFileVersion dlFileVersion)
468 throws SystemException {
469 dlFileVersion = toUnwrappedModel(dlFileVersion);
470
471 boolean isNew = dlFileVersion.isNew();
472
473 DLFileVersionModelImpl dlFileVersionModelImpl = (DLFileVersionModelImpl)dlFileVersion;
474
475 if (Validator.isNull(dlFileVersion.getUuid())) {
476 String uuid = PortalUUIDUtil.generate();
477
478 dlFileVersion.setUuid(uuid);
479 }
480
481 Session session = null;
482
483 try {
484 session = openSession();
485
486 if (dlFileVersion.isNew()) {
487 session.save(dlFileVersion);
488
489 dlFileVersion.setNew(false);
490 }
491 else {
492 session.merge(dlFileVersion);
493 }
494 }
495 catch (Exception e) {
496 throw processException(e);
497 }
498 finally {
499 closeSession(session);
500 }
501
502 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
503
504 if (isNew || !DLFileVersionModelImpl.COLUMN_BITMASK_ENABLED) {
505 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
506 }
507
508 else {
509 if ((dlFileVersionModelImpl.getColumnBitmask() &
510 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID.getColumnBitmask()) != 0) {
511 Object[] args = new Object[] {
512 dlFileVersionModelImpl.getOriginalUuid()
513 };
514
515 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
516 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
517 args);
518
519 args = new Object[] { dlFileVersionModelImpl.getUuid() };
520
521 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
522 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
523 args);
524 }
525
526 if ((dlFileVersionModelImpl.getColumnBitmask() &
527 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C.getColumnBitmask()) != 0) {
528 Object[] args = new Object[] {
529 dlFileVersionModelImpl.getOriginalUuid(),
530 Long.valueOf(dlFileVersionModelImpl.getOriginalCompanyId())
531 };
532
533 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args);
534 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C,
535 args);
536
537 args = new Object[] {
538 dlFileVersionModelImpl.getUuid(),
539 Long.valueOf(dlFileVersionModelImpl.getCompanyId())
540 };
541
542 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args);
543 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C,
544 args);
545 }
546
547 if ((dlFileVersionModelImpl.getColumnBitmask() &
548 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_FILEENTRYID.getColumnBitmask()) != 0) {
549 Object[] args = new Object[] {
550 Long.valueOf(dlFileVersionModelImpl.getOriginalFileEntryId())
551 };
552
553 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_FILEENTRYID,
554 args);
555 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_FILEENTRYID,
556 args);
557
558 args = new Object[] {
559 Long.valueOf(dlFileVersionModelImpl.getFileEntryId())
560 };
561
562 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_FILEENTRYID,
563 args);
564 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_FILEENTRYID,
565 args);
566 }
567
568 if ((dlFileVersionModelImpl.getColumnBitmask() &
569 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_F_S.getColumnBitmask()) != 0) {
570 Object[] args = new Object[] {
571 Long.valueOf(dlFileVersionModelImpl.getOriginalFileEntryId()),
572 Integer.valueOf(dlFileVersionModelImpl.getOriginalStatus())
573 };
574
575 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_F_S, args);
576 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_F_S,
577 args);
578
579 args = new Object[] {
580 Long.valueOf(dlFileVersionModelImpl.getFileEntryId()),
581 Integer.valueOf(dlFileVersionModelImpl.getStatus())
582 };
583
584 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_F_S, args);
585 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_F_S,
586 args);
587 }
588
589 if ((dlFileVersionModelImpl.getColumnBitmask() &
590 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F_S.getColumnBitmask()) != 0) {
591 Object[] args = new Object[] {
592 Long.valueOf(dlFileVersionModelImpl.getOriginalGroupId()),
593 Long.valueOf(dlFileVersionModelImpl.getOriginalFolderId()),
594 Integer.valueOf(dlFileVersionModelImpl.getOriginalStatus())
595 };
596
597 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_F_S, args);
598 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F_S,
599 args);
600
601 args = new Object[] {
602 Long.valueOf(dlFileVersionModelImpl.getGroupId()),
603 Long.valueOf(dlFileVersionModelImpl.getFolderId()),
604 Integer.valueOf(dlFileVersionModelImpl.getStatus())
605 };
606
607 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_F_S, args);
608 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F_S,
609 args);
610 }
611
612 if ((dlFileVersionModelImpl.getColumnBitmask() &
613 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F_T_V.getColumnBitmask()) != 0) {
614 Object[] args = new Object[] {
615 Long.valueOf(dlFileVersionModelImpl.getOriginalGroupId()),
616 Long.valueOf(dlFileVersionModelImpl.getOriginalFolderId()),
617
618 dlFileVersionModelImpl.getOriginalTitle(),
619
620 dlFileVersionModelImpl.getOriginalVersion()
621 };
622
623 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_F_T_V, args);
624 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F_T_V,
625 args);
626
627 args = new Object[] {
628 Long.valueOf(dlFileVersionModelImpl.getGroupId()),
629 Long.valueOf(dlFileVersionModelImpl.getFolderId()),
630
631 dlFileVersionModelImpl.getTitle(),
632
633 dlFileVersionModelImpl.getVersion()
634 };
635
636 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_F_T_V, args);
637 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F_T_V,
638 args);
639 }
640 }
641
642 EntityCacheUtil.putResult(DLFileVersionModelImpl.ENTITY_CACHE_ENABLED,
643 DLFileVersionImpl.class, dlFileVersion.getPrimaryKey(),
644 dlFileVersion);
645
646 if (isNew) {
647 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
648 new Object[] {
649 dlFileVersion.getUuid(),
650 Long.valueOf(dlFileVersion.getGroupId())
651 }, dlFileVersion);
652
653 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_F_V,
654 new Object[] {
655 Long.valueOf(dlFileVersion.getFileEntryId()),
656
657 dlFileVersion.getVersion()
658 }, dlFileVersion);
659 }
660 else {
661 if ((dlFileVersionModelImpl.getColumnBitmask() &
662 FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) {
663 Object[] args = new Object[] {
664 dlFileVersionModelImpl.getOriginalUuid(),
665 Long.valueOf(dlFileVersionModelImpl.getOriginalGroupId())
666 };
667
668 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args);
669
670 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args);
671
672 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
673 new Object[] {
674 dlFileVersion.getUuid(),
675 Long.valueOf(dlFileVersion.getGroupId())
676 }, dlFileVersion);
677 }
678
679 if ((dlFileVersionModelImpl.getColumnBitmask() &
680 FINDER_PATH_FETCH_BY_F_V.getColumnBitmask()) != 0) {
681 Object[] args = new Object[] {
682 Long.valueOf(dlFileVersionModelImpl.getOriginalFileEntryId()),
683
684 dlFileVersionModelImpl.getOriginalVersion()
685 };
686
687 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_F_V, args);
688
689 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_F_V, args);
690
691 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_F_V,
692 new Object[] {
693 Long.valueOf(dlFileVersion.getFileEntryId()),
694
695 dlFileVersion.getVersion()
696 }, dlFileVersion);
697 }
698 }
699
700 return dlFileVersion;
701 }
702
703 protected DLFileVersion toUnwrappedModel(DLFileVersion dlFileVersion) {
704 if (dlFileVersion instanceof DLFileVersionImpl) {
705 return dlFileVersion;
706 }
707
708 DLFileVersionImpl dlFileVersionImpl = new DLFileVersionImpl();
709
710 dlFileVersionImpl.setNew(dlFileVersion.isNew());
711 dlFileVersionImpl.setPrimaryKey(dlFileVersion.getPrimaryKey());
712
713 dlFileVersionImpl.setUuid(dlFileVersion.getUuid());
714 dlFileVersionImpl.setFileVersionId(dlFileVersion.getFileVersionId());
715 dlFileVersionImpl.setGroupId(dlFileVersion.getGroupId());
716 dlFileVersionImpl.setCompanyId(dlFileVersion.getCompanyId());
717 dlFileVersionImpl.setUserId(dlFileVersion.getUserId());
718 dlFileVersionImpl.setUserName(dlFileVersion.getUserName());
719 dlFileVersionImpl.setCreateDate(dlFileVersion.getCreateDate());
720 dlFileVersionImpl.setModifiedDate(dlFileVersion.getModifiedDate());
721 dlFileVersionImpl.setRepositoryId(dlFileVersion.getRepositoryId());
722 dlFileVersionImpl.setFolderId(dlFileVersion.getFolderId());
723 dlFileVersionImpl.setFileEntryId(dlFileVersion.getFileEntryId());
724 dlFileVersionImpl.setExtension(dlFileVersion.getExtension());
725 dlFileVersionImpl.setMimeType(dlFileVersion.getMimeType());
726 dlFileVersionImpl.setTitle(dlFileVersion.getTitle());
727 dlFileVersionImpl.setDescription(dlFileVersion.getDescription());
728 dlFileVersionImpl.setChangeLog(dlFileVersion.getChangeLog());
729 dlFileVersionImpl.setExtraSettings(dlFileVersion.getExtraSettings());
730 dlFileVersionImpl.setFileEntryTypeId(dlFileVersion.getFileEntryTypeId());
731 dlFileVersionImpl.setVersion(dlFileVersion.getVersion());
732 dlFileVersionImpl.setSize(dlFileVersion.getSize());
733 dlFileVersionImpl.setChecksum(dlFileVersion.getChecksum());
734 dlFileVersionImpl.setStatus(dlFileVersion.getStatus());
735 dlFileVersionImpl.setStatusByUserId(dlFileVersion.getStatusByUserId());
736 dlFileVersionImpl.setStatusByUserName(dlFileVersion.getStatusByUserName());
737 dlFileVersionImpl.setStatusDate(dlFileVersion.getStatusDate());
738
739 return dlFileVersionImpl;
740 }
741
742
750 @Override
751 public DLFileVersion findByPrimaryKey(Serializable primaryKey)
752 throws NoSuchModelException, SystemException {
753 return findByPrimaryKey(((Long)primaryKey).longValue());
754 }
755
756
764 public DLFileVersion findByPrimaryKey(long fileVersionId)
765 throws NoSuchFileVersionException, SystemException {
766 DLFileVersion dlFileVersion = fetchByPrimaryKey(fileVersionId);
767
768 if (dlFileVersion == null) {
769 if (_log.isWarnEnabled()) {
770 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + fileVersionId);
771 }
772
773 throw new NoSuchFileVersionException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
774 fileVersionId);
775 }
776
777 return dlFileVersion;
778 }
779
780
787 @Override
788 public DLFileVersion fetchByPrimaryKey(Serializable primaryKey)
789 throws SystemException {
790 return fetchByPrimaryKey(((Long)primaryKey).longValue());
791 }
792
793
800 public DLFileVersion fetchByPrimaryKey(long fileVersionId)
801 throws SystemException {
802 DLFileVersion dlFileVersion = (DLFileVersion)EntityCacheUtil.getResult(DLFileVersionModelImpl.ENTITY_CACHE_ENABLED,
803 DLFileVersionImpl.class, fileVersionId);
804
805 if (dlFileVersion == _nullDLFileVersion) {
806 return null;
807 }
808
809 if (dlFileVersion == null) {
810 Session session = null;
811
812 boolean hasException = false;
813
814 try {
815 session = openSession();
816
817 dlFileVersion = (DLFileVersion)session.get(DLFileVersionImpl.class,
818 Long.valueOf(fileVersionId));
819 }
820 catch (Exception e) {
821 hasException = true;
822
823 throw processException(e);
824 }
825 finally {
826 if (dlFileVersion != null) {
827 cacheResult(dlFileVersion);
828 }
829 else if (!hasException) {
830 EntityCacheUtil.putResult(DLFileVersionModelImpl.ENTITY_CACHE_ENABLED,
831 DLFileVersionImpl.class, fileVersionId,
832 _nullDLFileVersion);
833 }
834
835 closeSession(session);
836 }
837 }
838
839 return dlFileVersion;
840 }
841
842
849 public List<DLFileVersion> findByUuid(String uuid)
850 throws SystemException {
851 return findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
852 }
853
854
867 public List<DLFileVersion> findByUuid(String uuid, int start, int end)
868 throws SystemException {
869 return findByUuid(uuid, start, end, null);
870 }
871
872
886 public List<DLFileVersion> findByUuid(String uuid, int start, int end,
887 OrderByComparator orderByComparator) throws SystemException {
888 FinderPath finderPath = null;
889 Object[] finderArgs = null;
890
891 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
892 (orderByComparator == null)) {
893 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID;
894 finderArgs = new Object[] { uuid };
895 }
896 else {
897 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID;
898 finderArgs = new Object[] { uuid, start, end, orderByComparator };
899 }
900
901 List<DLFileVersion> list = (List<DLFileVersion>)FinderCacheUtil.getResult(finderPath,
902 finderArgs, this);
903
904 if ((list != null) && !list.isEmpty()) {
905 for (DLFileVersion dlFileVersion : list) {
906 if (!Validator.equals(uuid, dlFileVersion.getUuid())) {
907 list = null;
908
909 break;
910 }
911 }
912 }
913
914 if (list == null) {
915 StringBundler query = null;
916
917 if (orderByComparator != null) {
918 query = new StringBundler(3 +
919 (orderByComparator.getOrderByFields().length * 3));
920 }
921 else {
922 query = new StringBundler(3);
923 }
924
925 query.append(_SQL_SELECT_DLFILEVERSION_WHERE);
926
927 if (uuid == null) {
928 query.append(_FINDER_COLUMN_UUID_UUID_1);
929 }
930 else {
931 if (uuid.equals(StringPool.BLANK)) {
932 query.append(_FINDER_COLUMN_UUID_UUID_3);
933 }
934 else {
935 query.append(_FINDER_COLUMN_UUID_UUID_2);
936 }
937 }
938
939 if (orderByComparator != null) {
940 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
941 orderByComparator);
942 }
943
944 else {
945 query.append(DLFileVersionModelImpl.ORDER_BY_JPQL);
946 }
947
948 String sql = query.toString();
949
950 Session session = null;
951
952 try {
953 session = openSession();
954
955 Query q = session.createQuery(sql);
956
957 QueryPos qPos = QueryPos.getInstance(q);
958
959 if (uuid != null) {
960 qPos.add(uuid);
961 }
962
963 list = (List<DLFileVersion>)QueryUtil.list(q, getDialect(),
964 start, end);
965 }
966 catch (Exception e) {
967 throw processException(e);
968 }
969 finally {
970 if (list == null) {
971 FinderCacheUtil.removeResult(finderPath, finderArgs);
972 }
973 else {
974 cacheResult(list);
975
976 FinderCacheUtil.putResult(finderPath, finderArgs, list);
977 }
978
979 closeSession(session);
980 }
981 }
982
983 return list;
984 }
985
986
995 public DLFileVersion findByUuid_First(String uuid,
996 OrderByComparator orderByComparator)
997 throws NoSuchFileVersionException, SystemException {
998 DLFileVersion dlFileVersion = fetchByUuid_First(uuid, orderByComparator);
999
1000 if (dlFileVersion != null) {
1001 return dlFileVersion;
1002 }
1003
1004 StringBundler msg = new StringBundler(4);
1005
1006 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1007
1008 msg.append("uuid=");
1009 msg.append(uuid);
1010
1011 msg.append(StringPool.CLOSE_CURLY_BRACE);
1012
1013 throw new NoSuchFileVersionException(msg.toString());
1014 }
1015
1016
1024 public DLFileVersion fetchByUuid_First(String uuid,
1025 OrderByComparator orderByComparator) throws SystemException {
1026 List<DLFileVersion> list = findByUuid(uuid, 0, 1, orderByComparator);
1027
1028 if (!list.isEmpty()) {
1029 return list.get(0);
1030 }
1031
1032 return null;
1033 }
1034
1035
1044 public DLFileVersion findByUuid_Last(String uuid,
1045 OrderByComparator orderByComparator)
1046 throws NoSuchFileVersionException, SystemException {
1047 DLFileVersion dlFileVersion = fetchByUuid_Last(uuid, orderByComparator);
1048
1049 if (dlFileVersion != null) {
1050 return dlFileVersion;
1051 }
1052
1053 StringBundler msg = new StringBundler(4);
1054
1055 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1056
1057 msg.append("uuid=");
1058 msg.append(uuid);
1059
1060 msg.append(StringPool.CLOSE_CURLY_BRACE);
1061
1062 throw new NoSuchFileVersionException(msg.toString());
1063 }
1064
1065
1073 public DLFileVersion fetchByUuid_Last(String uuid,
1074 OrderByComparator orderByComparator) throws SystemException {
1075 int count = countByUuid(uuid);
1076
1077 List<DLFileVersion> list = findByUuid(uuid, count - 1, count,
1078 orderByComparator);
1079
1080 if (!list.isEmpty()) {
1081 return list.get(0);
1082 }
1083
1084 return null;
1085 }
1086
1087
1097 public DLFileVersion[] findByUuid_PrevAndNext(long fileVersionId,
1098 String uuid, OrderByComparator orderByComparator)
1099 throws NoSuchFileVersionException, SystemException {
1100 DLFileVersion dlFileVersion = findByPrimaryKey(fileVersionId);
1101
1102 Session session = null;
1103
1104 try {
1105 session = openSession();
1106
1107 DLFileVersion[] array = new DLFileVersionImpl[3];
1108
1109 array[0] = getByUuid_PrevAndNext(session, dlFileVersion, uuid,
1110 orderByComparator, true);
1111
1112 array[1] = dlFileVersion;
1113
1114 array[2] = getByUuid_PrevAndNext(session, dlFileVersion, uuid,
1115 orderByComparator, false);
1116
1117 return array;
1118 }
1119 catch (Exception e) {
1120 throw processException(e);
1121 }
1122 finally {
1123 closeSession(session);
1124 }
1125 }
1126
1127 protected DLFileVersion getByUuid_PrevAndNext(Session session,
1128 DLFileVersion dlFileVersion, String uuid,
1129 OrderByComparator orderByComparator, boolean previous) {
1130 StringBundler query = null;
1131
1132 if (orderByComparator != null) {
1133 query = new StringBundler(6 +
1134 (orderByComparator.getOrderByFields().length * 6));
1135 }
1136 else {
1137 query = new StringBundler(3);
1138 }
1139
1140 query.append(_SQL_SELECT_DLFILEVERSION_WHERE);
1141
1142 if (uuid == null) {
1143 query.append(_FINDER_COLUMN_UUID_UUID_1);
1144 }
1145 else {
1146 if (uuid.equals(StringPool.BLANK)) {
1147 query.append(_FINDER_COLUMN_UUID_UUID_3);
1148 }
1149 else {
1150 query.append(_FINDER_COLUMN_UUID_UUID_2);
1151 }
1152 }
1153
1154 if (orderByComparator != null) {
1155 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1156
1157 if (orderByConditionFields.length > 0) {
1158 query.append(WHERE_AND);
1159 }
1160
1161 for (int i = 0; i < orderByConditionFields.length; i++) {
1162 query.append(_ORDER_BY_ENTITY_ALIAS);
1163 query.append(orderByConditionFields[i]);
1164
1165 if ((i + 1) < orderByConditionFields.length) {
1166 if (orderByComparator.isAscending() ^ previous) {
1167 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1168 }
1169 else {
1170 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1171 }
1172 }
1173 else {
1174 if (orderByComparator.isAscending() ^ previous) {
1175 query.append(WHERE_GREATER_THAN);
1176 }
1177 else {
1178 query.append(WHERE_LESSER_THAN);
1179 }
1180 }
1181 }
1182
1183 query.append(ORDER_BY_CLAUSE);
1184
1185 String[] orderByFields = orderByComparator.getOrderByFields();
1186
1187 for (int i = 0; i < orderByFields.length; i++) {
1188 query.append(_ORDER_BY_ENTITY_ALIAS);
1189 query.append(orderByFields[i]);
1190
1191 if ((i + 1) < orderByFields.length) {
1192 if (orderByComparator.isAscending() ^ previous) {
1193 query.append(ORDER_BY_ASC_HAS_NEXT);
1194 }
1195 else {
1196 query.append(ORDER_BY_DESC_HAS_NEXT);
1197 }
1198 }
1199 else {
1200 if (orderByComparator.isAscending() ^ previous) {
1201 query.append(ORDER_BY_ASC);
1202 }
1203 else {
1204 query.append(ORDER_BY_DESC);
1205 }
1206 }
1207 }
1208 }
1209
1210 else {
1211 query.append(DLFileVersionModelImpl.ORDER_BY_JPQL);
1212 }
1213
1214 String sql = query.toString();
1215
1216 Query q = session.createQuery(sql);
1217
1218 q.setFirstResult(0);
1219 q.setMaxResults(2);
1220
1221 QueryPos qPos = QueryPos.getInstance(q);
1222
1223 if (uuid != null) {
1224 qPos.add(uuid);
1225 }
1226
1227 if (orderByComparator != null) {
1228 Object[] values = orderByComparator.getOrderByConditionValues(dlFileVersion);
1229
1230 for (Object value : values) {
1231 qPos.add(value);
1232 }
1233 }
1234
1235 List<DLFileVersion> list = q.list();
1236
1237 if (list.size() == 2) {
1238 return list.get(1);
1239 }
1240 else {
1241 return null;
1242 }
1243 }
1244
1245
1254 public DLFileVersion findByUUID_G(String uuid, long groupId)
1255 throws NoSuchFileVersionException, SystemException {
1256 DLFileVersion dlFileVersion = fetchByUUID_G(uuid, groupId);
1257
1258 if (dlFileVersion == null) {
1259 StringBundler msg = new StringBundler(6);
1260
1261 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1262
1263 msg.append("uuid=");
1264 msg.append(uuid);
1265
1266 msg.append(", groupId=");
1267 msg.append(groupId);
1268
1269 msg.append(StringPool.CLOSE_CURLY_BRACE);
1270
1271 if (_log.isWarnEnabled()) {
1272 _log.warn(msg.toString());
1273 }
1274
1275 throw new NoSuchFileVersionException(msg.toString());
1276 }
1277
1278 return dlFileVersion;
1279 }
1280
1281
1289 public DLFileVersion fetchByUUID_G(String uuid, long groupId)
1290 throws SystemException {
1291 return fetchByUUID_G(uuid, groupId, true);
1292 }
1293
1294
1303 public DLFileVersion fetchByUUID_G(String uuid, long groupId,
1304 boolean retrieveFromCache) throws SystemException {
1305 Object[] finderArgs = new Object[] { uuid, groupId };
1306
1307 Object result = null;
1308
1309 if (retrieveFromCache) {
1310 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_UUID_G,
1311 finderArgs, this);
1312 }
1313
1314 if (result instanceof DLFileVersion) {
1315 DLFileVersion dlFileVersion = (DLFileVersion)result;
1316
1317 if (!Validator.equals(uuid, dlFileVersion.getUuid()) ||
1318 (groupId != dlFileVersion.getGroupId())) {
1319 result = null;
1320 }
1321 }
1322
1323 if (result == null) {
1324 StringBundler query = new StringBundler(4);
1325
1326 query.append(_SQL_SELECT_DLFILEVERSION_WHERE);
1327
1328 if (uuid == null) {
1329 query.append(_FINDER_COLUMN_UUID_G_UUID_1);
1330 }
1331 else {
1332 if (uuid.equals(StringPool.BLANK)) {
1333 query.append(_FINDER_COLUMN_UUID_G_UUID_3);
1334 }
1335 else {
1336 query.append(_FINDER_COLUMN_UUID_G_UUID_2);
1337 }
1338 }
1339
1340 query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
1341
1342 query.append(DLFileVersionModelImpl.ORDER_BY_JPQL);
1343
1344 String sql = query.toString();
1345
1346 Session session = null;
1347
1348 try {
1349 session = openSession();
1350
1351 Query q = session.createQuery(sql);
1352
1353 QueryPos qPos = QueryPos.getInstance(q);
1354
1355 if (uuid != null) {
1356 qPos.add(uuid);
1357 }
1358
1359 qPos.add(groupId);
1360
1361 List<DLFileVersion> list = q.list();
1362
1363 result = list;
1364
1365 DLFileVersion dlFileVersion = null;
1366
1367 if (list.isEmpty()) {
1368 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
1369 finderArgs, list);
1370 }
1371 else {
1372 dlFileVersion = list.get(0);
1373
1374 cacheResult(dlFileVersion);
1375
1376 if ((dlFileVersion.getUuid() == null) ||
1377 !dlFileVersion.getUuid().equals(uuid) ||
1378 (dlFileVersion.getGroupId() != groupId)) {
1379 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
1380 finderArgs, dlFileVersion);
1381 }
1382 }
1383
1384 return dlFileVersion;
1385 }
1386 catch (Exception e) {
1387 throw processException(e);
1388 }
1389 finally {
1390 if (result == null) {
1391 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
1392 finderArgs);
1393 }
1394
1395 closeSession(session);
1396 }
1397 }
1398 else {
1399 if (result instanceof List<?>) {
1400 return null;
1401 }
1402 else {
1403 return (DLFileVersion)result;
1404 }
1405 }
1406 }
1407
1408
1416 public List<DLFileVersion> findByUuid_C(String uuid, long companyId)
1417 throws SystemException {
1418 return findByUuid_C(uuid, companyId, QueryUtil.ALL_POS,
1419 QueryUtil.ALL_POS, null);
1420 }
1421
1422
1436 public List<DLFileVersion> findByUuid_C(String uuid, long companyId,
1437 int start, int end) throws SystemException {
1438 return findByUuid_C(uuid, companyId, start, end, null);
1439 }
1440
1441
1456 public List<DLFileVersion> findByUuid_C(String uuid, long companyId,
1457 int start, int end, OrderByComparator orderByComparator)
1458 throws SystemException {
1459 FinderPath finderPath = null;
1460 Object[] finderArgs = null;
1461
1462 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1463 (orderByComparator == null)) {
1464 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C;
1465 finderArgs = new Object[] { uuid, companyId };
1466 }
1467 else {
1468 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID_C;
1469 finderArgs = new Object[] {
1470 uuid, companyId,
1471
1472 start, end, orderByComparator
1473 };
1474 }
1475
1476 List<DLFileVersion> list = (List<DLFileVersion>)FinderCacheUtil.getResult(finderPath,
1477 finderArgs, this);
1478
1479 if ((list != null) && !list.isEmpty()) {
1480 for (DLFileVersion dlFileVersion : list) {
1481 if (!Validator.equals(uuid, dlFileVersion.getUuid()) ||
1482 (companyId != dlFileVersion.getCompanyId())) {
1483 list = null;
1484
1485 break;
1486 }
1487 }
1488 }
1489
1490 if (list == null) {
1491 StringBundler query = null;
1492
1493 if (orderByComparator != null) {
1494 query = new StringBundler(4 +
1495 (orderByComparator.getOrderByFields().length * 3));
1496 }
1497 else {
1498 query = new StringBundler(4);
1499 }
1500
1501 query.append(_SQL_SELECT_DLFILEVERSION_WHERE);
1502
1503 if (uuid == null) {
1504 query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1505 }
1506 else {
1507 if (uuid.equals(StringPool.BLANK)) {
1508 query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1509 }
1510 else {
1511 query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1512 }
1513 }
1514
1515 query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1516
1517 if (orderByComparator != null) {
1518 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1519 orderByComparator);
1520 }
1521
1522 else {
1523 query.append(DLFileVersionModelImpl.ORDER_BY_JPQL);
1524 }
1525
1526 String sql = query.toString();
1527
1528 Session session = null;
1529
1530 try {
1531 session = openSession();
1532
1533 Query q = session.createQuery(sql);
1534
1535 QueryPos qPos = QueryPos.getInstance(q);
1536
1537 if (uuid != null) {
1538 qPos.add(uuid);
1539 }
1540
1541 qPos.add(companyId);
1542
1543 list = (List<DLFileVersion>)QueryUtil.list(q, getDialect(),
1544 start, end);
1545 }
1546 catch (Exception e) {
1547 throw processException(e);
1548 }
1549 finally {
1550 if (list == null) {
1551 FinderCacheUtil.removeResult(finderPath, finderArgs);
1552 }
1553 else {
1554 cacheResult(list);
1555
1556 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1557 }
1558
1559 closeSession(session);
1560 }
1561 }
1562
1563 return list;
1564 }
1565
1566
1576 public DLFileVersion findByUuid_C_First(String uuid, long companyId,
1577 OrderByComparator orderByComparator)
1578 throws NoSuchFileVersionException, SystemException {
1579 DLFileVersion dlFileVersion = fetchByUuid_C_First(uuid, companyId,
1580 orderByComparator);
1581
1582 if (dlFileVersion != null) {
1583 return dlFileVersion;
1584 }
1585
1586 StringBundler msg = new StringBundler(6);
1587
1588 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1589
1590 msg.append("uuid=");
1591 msg.append(uuid);
1592
1593 msg.append(", companyId=");
1594 msg.append(companyId);
1595
1596 msg.append(StringPool.CLOSE_CURLY_BRACE);
1597
1598 throw new NoSuchFileVersionException(msg.toString());
1599 }
1600
1601
1610 public DLFileVersion fetchByUuid_C_First(String uuid, long companyId,
1611 OrderByComparator orderByComparator) throws SystemException {
1612 List<DLFileVersion> list = findByUuid_C(uuid, companyId, 0, 1,
1613 orderByComparator);
1614
1615 if (!list.isEmpty()) {
1616 return list.get(0);
1617 }
1618
1619 return null;
1620 }
1621
1622
1632 public DLFileVersion findByUuid_C_Last(String uuid, long companyId,
1633 OrderByComparator orderByComparator)
1634 throws NoSuchFileVersionException, SystemException {
1635 DLFileVersion dlFileVersion = fetchByUuid_C_Last(uuid, companyId,
1636 orderByComparator);
1637
1638 if (dlFileVersion != null) {
1639 return dlFileVersion;
1640 }
1641
1642 StringBundler msg = new StringBundler(6);
1643
1644 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1645
1646 msg.append("uuid=");
1647 msg.append(uuid);
1648
1649 msg.append(", companyId=");
1650 msg.append(companyId);
1651
1652 msg.append(StringPool.CLOSE_CURLY_BRACE);
1653
1654 throw new NoSuchFileVersionException(msg.toString());
1655 }
1656
1657
1666 public DLFileVersion fetchByUuid_C_Last(String uuid, long companyId,
1667 OrderByComparator orderByComparator) throws SystemException {
1668 int count = countByUuid_C(uuid, companyId);
1669
1670 List<DLFileVersion> list = findByUuid_C(uuid, companyId, count - 1,
1671 count, orderByComparator);
1672
1673 if (!list.isEmpty()) {
1674 return list.get(0);
1675 }
1676
1677 return null;
1678 }
1679
1680
1691 public DLFileVersion[] findByUuid_C_PrevAndNext(long fileVersionId,
1692 String uuid, long companyId, OrderByComparator orderByComparator)
1693 throws NoSuchFileVersionException, SystemException {
1694 DLFileVersion dlFileVersion = findByPrimaryKey(fileVersionId);
1695
1696 Session session = null;
1697
1698 try {
1699 session = openSession();
1700
1701 DLFileVersion[] array = new DLFileVersionImpl[3];
1702
1703 array[0] = getByUuid_C_PrevAndNext(session, dlFileVersion, uuid,
1704 companyId, orderByComparator, true);
1705
1706 array[1] = dlFileVersion;
1707
1708 array[2] = getByUuid_C_PrevAndNext(session, dlFileVersion, uuid,
1709 companyId, orderByComparator, false);
1710
1711 return array;
1712 }
1713 catch (Exception e) {
1714 throw processException(e);
1715 }
1716 finally {
1717 closeSession(session);
1718 }
1719 }
1720
1721 protected DLFileVersion getByUuid_C_PrevAndNext(Session session,
1722 DLFileVersion dlFileVersion, String uuid, long companyId,
1723 OrderByComparator orderByComparator, boolean previous) {
1724 StringBundler query = null;
1725
1726 if (orderByComparator != null) {
1727 query = new StringBundler(6 +
1728 (orderByComparator.getOrderByFields().length * 6));
1729 }
1730 else {
1731 query = new StringBundler(3);
1732 }
1733
1734 query.append(_SQL_SELECT_DLFILEVERSION_WHERE);
1735
1736 if (uuid == null) {
1737 query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1738 }
1739 else {
1740 if (uuid.equals(StringPool.BLANK)) {
1741 query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1742 }
1743 else {
1744 query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1745 }
1746 }
1747
1748 query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1749
1750 if (orderByComparator != null) {
1751 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1752
1753 if (orderByConditionFields.length > 0) {
1754 query.append(WHERE_AND);
1755 }
1756
1757 for (int i = 0; i < orderByConditionFields.length; i++) {
1758 query.append(_ORDER_BY_ENTITY_ALIAS);
1759 query.append(orderByConditionFields[i]);
1760
1761 if ((i + 1) < orderByConditionFields.length) {
1762 if (orderByComparator.isAscending() ^ previous) {
1763 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1764 }
1765 else {
1766 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1767 }
1768 }
1769 else {
1770 if (orderByComparator.isAscending() ^ previous) {
1771 query.append(WHERE_GREATER_THAN);
1772 }
1773 else {
1774 query.append(WHERE_LESSER_THAN);
1775 }
1776 }
1777 }
1778
1779 query.append(ORDER_BY_CLAUSE);
1780
1781 String[] orderByFields = orderByComparator.getOrderByFields();
1782
1783 for (int i = 0; i < orderByFields.length; i++) {
1784 query.append(_ORDER_BY_ENTITY_ALIAS);
1785 query.append(orderByFields[i]);
1786
1787 if ((i + 1) < orderByFields.length) {
1788 if (orderByComparator.isAscending() ^ previous) {
1789 query.append(ORDER_BY_ASC_HAS_NEXT);
1790 }
1791 else {
1792 query.append(ORDER_BY_DESC_HAS_NEXT);
1793 }
1794 }
1795 else {
1796 if (orderByComparator.isAscending() ^ previous) {
1797 query.append(ORDER_BY_ASC);
1798 }
1799 else {
1800 query.append(ORDER_BY_DESC);
1801 }
1802 }
1803 }
1804 }
1805
1806 else {
1807 query.append(DLFileVersionModelImpl.ORDER_BY_JPQL);
1808 }
1809
1810 String sql = query.toString();
1811
1812 Query q = session.createQuery(sql);
1813
1814 q.setFirstResult(0);
1815 q.setMaxResults(2);
1816
1817 QueryPos qPos = QueryPos.getInstance(q);
1818
1819 if (uuid != null) {
1820 qPos.add(uuid);
1821 }
1822
1823 qPos.add(companyId);
1824
1825 if (orderByComparator != null) {
1826 Object[] values = orderByComparator.getOrderByConditionValues(dlFileVersion);
1827
1828 for (Object value : values) {
1829 qPos.add(value);
1830 }
1831 }
1832
1833 List<DLFileVersion> list = q.list();
1834
1835 if (list.size() == 2) {
1836 return list.get(1);
1837 }
1838 else {
1839 return null;
1840 }
1841 }
1842
1843
1850 public List<DLFileVersion> findByFileEntryId(long fileEntryId)
1851 throws SystemException {
1852 return findByFileEntryId(fileEntryId, QueryUtil.ALL_POS,
1853 QueryUtil.ALL_POS, null);
1854 }
1855
1856
1869 public List<DLFileVersion> findByFileEntryId(long fileEntryId, int start,
1870 int end) throws SystemException {
1871 return findByFileEntryId(fileEntryId, start, end, null);
1872 }
1873
1874
1888 public List<DLFileVersion> findByFileEntryId(long fileEntryId, int start,
1889 int end, OrderByComparator orderByComparator) throws SystemException {
1890 FinderPath finderPath = null;
1891 Object[] finderArgs = null;
1892
1893 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1894 (orderByComparator == null)) {
1895 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_FILEENTRYID;
1896 finderArgs = new Object[] { fileEntryId };
1897 }
1898 else {
1899 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_FILEENTRYID;
1900 finderArgs = new Object[] { fileEntryId, start, end, orderByComparator };
1901 }
1902
1903 List<DLFileVersion> list = (List<DLFileVersion>)FinderCacheUtil.getResult(finderPath,
1904 finderArgs, this);
1905
1906 if ((list != null) && !list.isEmpty()) {
1907 for (DLFileVersion dlFileVersion : list) {
1908 if ((fileEntryId != dlFileVersion.getFileEntryId())) {
1909 list = null;
1910
1911 break;
1912 }
1913 }
1914 }
1915
1916 if (list == null) {
1917 StringBundler query = null;
1918
1919 if (orderByComparator != null) {
1920 query = new StringBundler(3 +
1921 (orderByComparator.getOrderByFields().length * 3));
1922 }
1923 else {
1924 query = new StringBundler(3);
1925 }
1926
1927 query.append(_SQL_SELECT_DLFILEVERSION_WHERE);
1928
1929 query.append(_FINDER_COLUMN_FILEENTRYID_FILEENTRYID_2);
1930
1931 if (orderByComparator != null) {
1932 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1933 orderByComparator);
1934 }
1935
1936 else {
1937 query.append(DLFileVersionModelImpl.ORDER_BY_JPQL);
1938 }
1939
1940 String sql = query.toString();
1941
1942 Session session = null;
1943
1944 try {
1945 session = openSession();
1946
1947 Query q = session.createQuery(sql);
1948
1949 QueryPos qPos = QueryPos.getInstance(q);
1950
1951 qPos.add(fileEntryId);
1952
1953 list = (List<DLFileVersion>)QueryUtil.list(q, getDialect(),
1954 start, end);
1955 }
1956 catch (Exception e) {
1957 throw processException(e);
1958 }
1959 finally {
1960 if (list == null) {
1961 FinderCacheUtil.removeResult(finderPath, finderArgs);
1962 }
1963 else {
1964 cacheResult(list);
1965
1966 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1967 }
1968
1969 closeSession(session);
1970 }
1971 }
1972
1973 return list;
1974 }
1975
1976
1985 public DLFileVersion findByFileEntryId_First(long fileEntryId,
1986 OrderByComparator orderByComparator)
1987 throws NoSuchFileVersionException, SystemException {
1988 DLFileVersion dlFileVersion = fetchByFileEntryId_First(fileEntryId,
1989 orderByComparator);
1990
1991 if (dlFileVersion != null) {
1992 return dlFileVersion;
1993 }
1994
1995 StringBundler msg = new StringBundler(4);
1996
1997 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1998
1999 msg.append("fileEntryId=");
2000 msg.append(fileEntryId);
2001
2002 msg.append(StringPool.CLOSE_CURLY_BRACE);
2003
2004 throw new NoSuchFileVersionException(msg.toString());
2005 }
2006
2007
2015 public DLFileVersion fetchByFileEntryId_First(long fileEntryId,
2016 OrderByComparator orderByComparator) throws SystemException {
2017 List<DLFileVersion> list = findByFileEntryId(fileEntryId, 0, 1,
2018 orderByComparator);
2019
2020 if (!list.isEmpty()) {
2021 return list.get(0);
2022 }
2023
2024 return null;
2025 }
2026
2027
2036 public DLFileVersion findByFileEntryId_Last(long fileEntryId,
2037 OrderByComparator orderByComparator)
2038 throws NoSuchFileVersionException, SystemException {
2039 DLFileVersion dlFileVersion = fetchByFileEntryId_Last(fileEntryId,
2040 orderByComparator);
2041
2042 if (dlFileVersion != null) {
2043 return dlFileVersion;
2044 }
2045
2046 StringBundler msg = new StringBundler(4);
2047
2048 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2049
2050 msg.append("fileEntryId=");
2051 msg.append(fileEntryId);
2052
2053 msg.append(StringPool.CLOSE_CURLY_BRACE);
2054
2055 throw new NoSuchFileVersionException(msg.toString());
2056 }
2057
2058
2066 public DLFileVersion fetchByFileEntryId_Last(long fileEntryId,
2067 OrderByComparator orderByComparator) throws SystemException {
2068 int count = countByFileEntryId(fileEntryId);
2069
2070 List<DLFileVersion> list = findByFileEntryId(fileEntryId, count - 1,
2071 count, orderByComparator);
2072
2073 if (!list.isEmpty()) {
2074 return list.get(0);
2075 }
2076
2077 return null;
2078 }
2079
2080
2090 public DLFileVersion[] findByFileEntryId_PrevAndNext(long fileVersionId,
2091 long fileEntryId, OrderByComparator orderByComparator)
2092 throws NoSuchFileVersionException, SystemException {
2093 DLFileVersion dlFileVersion = findByPrimaryKey(fileVersionId);
2094
2095 Session session = null;
2096
2097 try {
2098 session = openSession();
2099
2100 DLFileVersion[] array = new DLFileVersionImpl[3];
2101
2102 array[0] = getByFileEntryId_PrevAndNext(session, dlFileVersion,
2103 fileEntryId, orderByComparator, true);
2104
2105 array[1] = dlFileVersion;
2106
2107 array[2] = getByFileEntryId_PrevAndNext(session, dlFileVersion,
2108 fileEntryId, orderByComparator, false);
2109
2110 return array;
2111 }
2112 catch (Exception e) {
2113 throw processException(e);
2114 }
2115 finally {
2116 closeSession(session);
2117 }
2118 }
2119
2120 protected DLFileVersion getByFileEntryId_PrevAndNext(Session session,
2121 DLFileVersion dlFileVersion, long fileEntryId,
2122 OrderByComparator orderByComparator, boolean previous) {
2123 StringBundler query = null;
2124
2125 if (orderByComparator != null) {
2126 query = new StringBundler(6 +
2127 (orderByComparator.getOrderByFields().length * 6));
2128 }
2129 else {
2130 query = new StringBundler(3);
2131 }
2132
2133 query.append(_SQL_SELECT_DLFILEVERSION_WHERE);
2134
2135 query.append(_FINDER_COLUMN_FILEENTRYID_FILEENTRYID_2);
2136
2137 if (orderByComparator != null) {
2138 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2139
2140 if (orderByConditionFields.length > 0) {
2141 query.append(WHERE_AND);
2142 }
2143
2144 for (int i = 0; i < orderByConditionFields.length; i++) {
2145 query.append(_ORDER_BY_ENTITY_ALIAS);
2146 query.append(orderByConditionFields[i]);
2147
2148 if ((i + 1) < orderByConditionFields.length) {
2149 if (orderByComparator.isAscending() ^ previous) {
2150 query.append(WHERE_GREATER_THAN_HAS_NEXT);
2151 }
2152 else {
2153 query.append(WHERE_LESSER_THAN_HAS_NEXT);
2154 }
2155 }
2156 else {
2157 if (orderByComparator.isAscending() ^ previous) {
2158 query.append(WHERE_GREATER_THAN);
2159 }
2160 else {
2161 query.append(WHERE_LESSER_THAN);
2162 }
2163 }
2164 }
2165
2166 query.append(ORDER_BY_CLAUSE);
2167
2168 String[] orderByFields = orderByComparator.getOrderByFields();
2169
2170 for (int i = 0; i < orderByFields.length; i++) {
2171 query.append(_ORDER_BY_ENTITY_ALIAS);
2172 query.append(orderByFields[i]);
2173
2174 if ((i + 1) < orderByFields.length) {
2175 if (orderByComparator.isAscending() ^ previous) {
2176 query.append(ORDER_BY_ASC_HAS_NEXT);
2177 }
2178 else {
2179 query.append(ORDER_BY_DESC_HAS_NEXT);
2180 }
2181 }
2182 else {
2183 if (orderByComparator.isAscending() ^ previous) {
2184 query.append(ORDER_BY_ASC);
2185 }
2186 else {
2187 query.append(ORDER_BY_DESC);
2188 }
2189 }
2190 }
2191 }
2192
2193 else {
2194 query.append(DLFileVersionModelImpl.ORDER_BY_JPQL);
2195 }
2196
2197 String sql = query.toString();
2198
2199 Query q = session.createQuery(sql);
2200
2201 q.setFirstResult(0);
2202 q.setMaxResults(2);
2203
2204 QueryPos qPos = QueryPos.getInstance(q);
2205
2206 qPos.add(fileEntryId);
2207
2208 if (orderByComparator != null) {
2209 Object[] values = orderByComparator.getOrderByConditionValues(dlFileVersion);
2210
2211 for (Object value : values) {
2212 qPos.add(value);
2213 }
2214 }
2215
2216 List<DLFileVersion> list = q.list();
2217
2218 if (list.size() == 2) {
2219 return list.get(1);
2220 }
2221 else {
2222 return null;
2223 }
2224 }
2225
2226
2235 public DLFileVersion findByF_V(long fileEntryId, String version)
2236 throws NoSuchFileVersionException, SystemException {
2237 DLFileVersion dlFileVersion = fetchByF_V(fileEntryId, version);
2238
2239 if (dlFileVersion == null) {
2240 StringBundler msg = new StringBundler(6);
2241
2242 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2243
2244 msg.append("fileEntryId=");
2245 msg.append(fileEntryId);
2246
2247 msg.append(", version=");
2248 msg.append(version);
2249
2250 msg.append(StringPool.CLOSE_CURLY_BRACE);
2251
2252 if (_log.isWarnEnabled()) {
2253 _log.warn(msg.toString());
2254 }
2255
2256 throw new NoSuchFileVersionException(msg.toString());
2257 }
2258
2259 return dlFileVersion;
2260 }
2261
2262
2270 public DLFileVersion fetchByF_V(long fileEntryId, String version)
2271 throws SystemException {
2272 return fetchByF_V(fileEntryId, version, true);
2273 }
2274
2275
2284 public DLFileVersion fetchByF_V(long fileEntryId, String version,
2285 boolean retrieveFromCache) throws SystemException {
2286 Object[] finderArgs = new Object[] { fileEntryId, version };
2287
2288 Object result = null;
2289
2290 if (retrieveFromCache) {
2291 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_F_V,
2292 finderArgs, this);
2293 }
2294
2295 if (result instanceof DLFileVersion) {
2296 DLFileVersion dlFileVersion = (DLFileVersion)result;
2297
2298 if ((fileEntryId != dlFileVersion.getFileEntryId()) ||
2299 !Validator.equals(version, dlFileVersion.getVersion())) {
2300 result = null;
2301 }
2302 }
2303
2304 if (result == null) {
2305 StringBundler query = new StringBundler(4);
2306
2307 query.append(_SQL_SELECT_DLFILEVERSION_WHERE);
2308
2309 query.append(_FINDER_COLUMN_F_V_FILEENTRYID_2);
2310
2311 if (version == null) {
2312 query.append(_FINDER_COLUMN_F_V_VERSION_1);
2313 }
2314 else {
2315 if (version.equals(StringPool.BLANK)) {
2316 query.append(_FINDER_COLUMN_F_V_VERSION_3);
2317 }
2318 else {
2319 query.append(_FINDER_COLUMN_F_V_VERSION_2);
2320 }
2321 }
2322
2323 query.append(DLFileVersionModelImpl.ORDER_BY_JPQL);
2324
2325 String sql = query.toString();
2326
2327 Session session = null;
2328
2329 try {
2330 session = openSession();
2331
2332 Query q = session.createQuery(sql);
2333
2334 QueryPos qPos = QueryPos.getInstance(q);
2335
2336 qPos.add(fileEntryId);
2337
2338 if (version != null) {
2339 qPos.add(version);
2340 }
2341
2342 List<DLFileVersion> list = q.list();
2343
2344 result = list;
2345
2346 DLFileVersion dlFileVersion = null;
2347
2348 if (list.isEmpty()) {
2349 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_F_V,
2350 finderArgs, list);
2351 }
2352 else {
2353 dlFileVersion = list.get(0);
2354
2355 cacheResult(dlFileVersion);
2356
2357 if ((dlFileVersion.getFileEntryId() != fileEntryId) ||
2358 (dlFileVersion.getVersion() == null) ||
2359 !dlFileVersion.getVersion().equals(version)) {
2360 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_F_V,
2361 finderArgs, dlFileVersion);
2362 }
2363 }
2364
2365 return dlFileVersion;
2366 }
2367 catch (Exception e) {
2368 throw processException(e);
2369 }
2370 finally {
2371 if (result == null) {
2372 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_F_V,
2373 finderArgs);
2374 }
2375
2376 closeSession(session);
2377 }
2378 }
2379 else {
2380 if (result instanceof List<?>) {
2381 return null;
2382 }
2383 else {
2384 return (DLFileVersion)result;
2385 }
2386 }
2387 }
2388
2389
2397 public List<DLFileVersion> findByF_S(long fileEntryId, int status)
2398 throws SystemException {
2399 return findByF_S(fileEntryId, status, QueryUtil.ALL_POS,
2400 QueryUtil.ALL_POS, null);
2401 }
2402
2403
2417 public List<DLFileVersion> findByF_S(long fileEntryId, int status,
2418 int start, int end) throws SystemException {
2419 return findByF_S(fileEntryId, status, start, end, null);
2420 }
2421
2422
2437 public List<DLFileVersion> findByF_S(long fileEntryId, int status,
2438 int start, int end, OrderByComparator orderByComparator)
2439 throws SystemException {
2440 FinderPath finderPath = null;
2441 Object[] finderArgs = null;
2442
2443 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2444 (orderByComparator == null)) {
2445 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_F_S;
2446 finderArgs = new Object[] { fileEntryId, status };
2447 }
2448 else {
2449 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_F_S;
2450 finderArgs = new Object[] {
2451 fileEntryId, status,
2452
2453 start, end, orderByComparator
2454 };
2455 }
2456
2457 List<DLFileVersion> list = (List<DLFileVersion>)FinderCacheUtil.getResult(finderPath,
2458 finderArgs, this);
2459
2460 if ((list != null) && !list.isEmpty()) {
2461 for (DLFileVersion dlFileVersion : list) {
2462 if ((fileEntryId != dlFileVersion.getFileEntryId()) ||
2463 (status != dlFileVersion.getStatus())) {
2464 list = null;
2465
2466 break;
2467 }
2468 }
2469 }
2470
2471 if (list == null) {
2472 StringBundler query = null;
2473
2474 if (orderByComparator != null) {
2475 query = new StringBundler(4 +
2476 (orderByComparator.getOrderByFields().length * 3));
2477 }
2478 else {
2479 query = new StringBundler(4);
2480 }
2481
2482 query.append(_SQL_SELECT_DLFILEVERSION_WHERE);
2483
2484 query.append(_FINDER_COLUMN_F_S_FILEENTRYID_2);
2485
2486 query.append(_FINDER_COLUMN_F_S_STATUS_2);
2487
2488 if (orderByComparator != null) {
2489 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2490 orderByComparator);
2491 }
2492
2493 else {
2494 query.append(DLFileVersionModelImpl.ORDER_BY_JPQL);
2495 }
2496
2497 String sql = query.toString();
2498
2499 Session session = null;
2500
2501 try {
2502 session = openSession();
2503
2504 Query q = session.createQuery(sql);
2505
2506 QueryPos qPos = QueryPos.getInstance(q);
2507
2508 qPos.add(fileEntryId);
2509
2510 qPos.add(status);
2511
2512 list = (List<DLFileVersion>)QueryUtil.list(q, getDialect(),
2513 start, end);
2514 }
2515 catch (Exception e) {
2516 throw processException(e);
2517 }
2518 finally {
2519 if (list == null) {
2520 FinderCacheUtil.removeResult(finderPath, finderArgs);
2521 }
2522 else {
2523 cacheResult(list);
2524
2525 FinderCacheUtil.putResult(finderPath, finderArgs, list);
2526 }
2527
2528 closeSession(session);
2529 }
2530 }
2531
2532 return list;
2533 }
2534
2535
2545 public DLFileVersion findByF_S_First(long fileEntryId, int status,
2546 OrderByComparator orderByComparator)
2547 throws NoSuchFileVersionException, SystemException {
2548 DLFileVersion dlFileVersion = fetchByF_S_First(fileEntryId, status,
2549 orderByComparator);
2550
2551 if (dlFileVersion != null) {
2552 return dlFileVersion;
2553 }
2554
2555 StringBundler msg = new StringBundler(6);
2556
2557 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2558
2559 msg.append("fileEntryId=");
2560 msg.append(fileEntryId);
2561
2562 msg.append(", status=");
2563 msg.append(status);
2564
2565 msg.append(StringPool.CLOSE_CURLY_BRACE);
2566
2567 throw new NoSuchFileVersionException(msg.toString());
2568 }
2569
2570
2579 public DLFileVersion fetchByF_S_First(long fileEntryId, int status,
2580 OrderByComparator orderByComparator) throws SystemException {
2581 List<DLFileVersion> list = findByF_S(fileEntryId, status, 0, 1,
2582 orderByComparator);
2583
2584 if (!list.isEmpty()) {
2585 return list.get(0);
2586 }
2587
2588 return null;
2589 }
2590
2591
2601 public DLFileVersion findByF_S_Last(long fileEntryId, int status,
2602 OrderByComparator orderByComparator)
2603 throws NoSuchFileVersionException, SystemException {
2604 DLFileVersion dlFileVersion = fetchByF_S_Last(fileEntryId, status,
2605 orderByComparator);
2606
2607 if (dlFileVersion != null) {
2608 return dlFileVersion;
2609 }
2610
2611 StringBundler msg = new StringBundler(6);
2612
2613 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2614
2615 msg.append("fileEntryId=");
2616 msg.append(fileEntryId);
2617
2618 msg.append(", status=");
2619 msg.append(status);
2620
2621 msg.append(StringPool.CLOSE_CURLY_BRACE);
2622
2623 throw new NoSuchFileVersionException(msg.toString());
2624 }
2625
2626
2635 public DLFileVersion fetchByF_S_Last(long fileEntryId, int status,
2636 OrderByComparator orderByComparator) throws SystemException {
2637 int count = countByF_S(fileEntryId, status);
2638
2639 List<DLFileVersion> list = findByF_S(fileEntryId, status, count - 1,
2640 count, orderByComparator);
2641
2642 if (!list.isEmpty()) {
2643 return list.get(0);
2644 }
2645
2646 return null;
2647 }
2648
2649
2660 public DLFileVersion[] findByF_S_PrevAndNext(long fileVersionId,
2661 long fileEntryId, int status, OrderByComparator orderByComparator)
2662 throws NoSuchFileVersionException, SystemException {
2663 DLFileVersion dlFileVersion = findByPrimaryKey(fileVersionId);
2664
2665 Session session = null;
2666
2667 try {
2668 session = openSession();
2669
2670 DLFileVersion[] array = new DLFileVersionImpl[3];
2671
2672 array[0] = getByF_S_PrevAndNext(session, dlFileVersion,
2673 fileEntryId, status, orderByComparator, true);
2674
2675 array[1] = dlFileVersion;
2676
2677 array[2] = getByF_S_PrevAndNext(session, dlFileVersion,
2678 fileEntryId, status, orderByComparator, false);
2679
2680 return array;
2681 }
2682 catch (Exception e) {
2683 throw processException(e);
2684 }
2685 finally {
2686 closeSession(session);
2687 }
2688 }
2689
2690 protected DLFileVersion getByF_S_PrevAndNext(Session session,
2691 DLFileVersion dlFileVersion, long fileEntryId, int status,
2692 OrderByComparator orderByComparator, boolean previous) {
2693 StringBundler query = null;
2694
2695 if (orderByComparator != null) {
2696 query = new StringBundler(6 +
2697 (orderByComparator.getOrderByFields().length * 6));
2698 }
2699 else {
2700 query = new StringBundler(3);
2701 }
2702
2703 query.append(_SQL_SELECT_DLFILEVERSION_WHERE);
2704
2705 query.append(_FINDER_COLUMN_F_S_FILEENTRYID_2);
2706
2707 query.append(_FINDER_COLUMN_F_S_STATUS_2);
2708
2709 if (orderByComparator != null) {
2710 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2711
2712 if (orderByConditionFields.length > 0) {
2713 query.append(WHERE_AND);
2714 }
2715
2716 for (int i = 0; i < orderByConditionFields.length; i++) {
2717 query.append(_ORDER_BY_ENTITY_ALIAS);
2718 query.append(orderByConditionFields[i]);
2719
2720 if ((i + 1) < orderByConditionFields.length) {
2721 if (orderByComparator.isAscending() ^ previous) {
2722 query.append(WHERE_GREATER_THAN_HAS_NEXT);
2723 }
2724 else {
2725 query.append(WHERE_LESSER_THAN_HAS_NEXT);
2726 }
2727 }
2728 else {
2729 if (orderByComparator.isAscending() ^ previous) {
2730 query.append(WHERE_GREATER_THAN);
2731 }
2732 else {
2733 query.append(WHERE_LESSER_THAN);
2734 }
2735 }
2736 }
2737
2738 query.append(ORDER_BY_CLAUSE);
2739
2740 String[] orderByFields = orderByComparator.getOrderByFields();
2741
2742 for (int i = 0; i < orderByFields.length; i++) {
2743 query.append(_ORDER_BY_ENTITY_ALIAS);
2744 query.append(orderByFields[i]);
2745
2746 if ((i + 1) < orderByFields.length) {
2747 if (orderByComparator.isAscending() ^ previous) {
2748 query.append(ORDER_BY_ASC_HAS_NEXT);
2749 }
2750 else {
2751 query.append(ORDER_BY_DESC_HAS_NEXT);
2752 }
2753 }
2754 else {
2755 if (orderByComparator.isAscending() ^ previous) {
2756 query.append(ORDER_BY_ASC);
2757 }
2758 else {
2759 query.append(ORDER_BY_DESC);
2760 }
2761 }
2762 }
2763 }
2764
2765 else {
2766 query.append(DLFileVersionModelImpl.ORDER_BY_JPQL);
2767 }
2768
2769 String sql = query.toString();
2770
2771 Query q = session.createQuery(sql);
2772
2773 q.setFirstResult(0);
2774 q.setMaxResults(2);
2775
2776 QueryPos qPos = QueryPos.getInstance(q);
2777
2778 qPos.add(fileEntryId);
2779
2780 qPos.add(status);
2781
2782 if (orderByComparator != null) {
2783 Object[] values = orderByComparator.getOrderByConditionValues(dlFileVersion);
2784
2785 for (Object value : values) {
2786 qPos.add(value);
2787 }
2788 }
2789
2790 List<DLFileVersion> list = q.list();
2791
2792 if (list.size() == 2) {
2793 return list.get(1);
2794 }
2795 else {
2796 return null;
2797 }
2798 }
2799
2800
2809 public List<DLFileVersion> findByG_F_S(long groupId, long folderId,
2810 int status) throws SystemException {
2811 return findByG_F_S(groupId, folderId, status, QueryUtil.ALL_POS,
2812 QueryUtil.ALL_POS, null);
2813 }
2814
2815
2830 public List<DLFileVersion> findByG_F_S(long groupId, long folderId,
2831 int status, int start, int end) throws SystemException {
2832 return findByG_F_S(groupId, folderId, status, start, end, null);
2833 }
2834
2835
2851 public List<DLFileVersion> findByG_F_S(long groupId, long folderId,
2852 int status, int start, int end, OrderByComparator orderByComparator)
2853 throws SystemException {
2854 FinderPath finderPath = null;
2855 Object[] finderArgs = null;
2856
2857 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2858 (orderByComparator == null)) {
2859 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F_S;
2860 finderArgs = new Object[] { groupId, folderId, status };
2861 }
2862 else {
2863 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F_S;
2864 finderArgs = new Object[] {
2865 groupId, folderId, status,
2866
2867 start, end, orderByComparator
2868 };
2869 }
2870
2871 List<DLFileVersion> list = (List<DLFileVersion>)FinderCacheUtil.getResult(finderPath,
2872 finderArgs, this);
2873
2874 if ((list != null) && !list.isEmpty()) {
2875 for (DLFileVersion dlFileVersion : list) {
2876 if ((groupId != dlFileVersion.getGroupId()) ||
2877 (folderId != dlFileVersion.getFolderId()) ||
2878 (status != dlFileVersion.getStatus())) {
2879 list = null;
2880
2881 break;
2882 }
2883 }
2884 }
2885
2886 if (list == null) {
2887 StringBundler query = null;
2888
2889 if (orderByComparator != null) {
2890 query = new StringBundler(5 +
2891 (orderByComparator.getOrderByFields().length * 3));
2892 }
2893 else {
2894 query = new StringBundler(5);
2895 }
2896
2897 query.append(_SQL_SELECT_DLFILEVERSION_WHERE);
2898
2899 query.append(_FINDER_COLUMN_G_F_S_GROUPID_2);
2900
2901 query.append(_FINDER_COLUMN_G_F_S_FOLDERID_2);
2902
2903 query.append(_FINDER_COLUMN_G_F_S_STATUS_2);
2904
2905 if (orderByComparator != null) {
2906 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2907 orderByComparator);
2908 }
2909
2910 else {
2911 query.append(DLFileVersionModelImpl.ORDER_BY_JPQL);
2912 }
2913
2914 String sql = query.toString();
2915
2916 Session session = null;
2917
2918 try {
2919 session = openSession();
2920
2921 Query q = session.createQuery(sql);
2922
2923 QueryPos qPos = QueryPos.getInstance(q);
2924
2925 qPos.add(groupId);
2926
2927 qPos.add(folderId);
2928
2929 qPos.add(status);
2930
2931 list = (List<DLFileVersion>)QueryUtil.list(q, getDialect(),
2932 start, end);
2933 }
2934 catch (Exception e) {
2935 throw processException(e);
2936 }
2937 finally {
2938 if (list == null) {
2939 FinderCacheUtil.removeResult(finderPath, finderArgs);
2940 }
2941 else {
2942 cacheResult(list);
2943
2944 FinderCacheUtil.putResult(finderPath, finderArgs, list);
2945 }
2946
2947 closeSession(session);
2948 }
2949 }
2950
2951 return list;
2952 }
2953
2954
2965 public DLFileVersion findByG_F_S_First(long groupId, long folderId,
2966 int status, OrderByComparator orderByComparator)
2967 throws NoSuchFileVersionException, SystemException {
2968 DLFileVersion dlFileVersion = fetchByG_F_S_First(groupId, folderId,
2969 status, orderByComparator);
2970
2971 if (dlFileVersion != null) {
2972 return dlFileVersion;
2973 }
2974
2975 StringBundler msg = new StringBundler(8);
2976
2977 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2978
2979 msg.append("groupId=");
2980 msg.append(groupId);
2981
2982 msg.append(", folderId=");
2983 msg.append(folderId);
2984
2985 msg.append(", status=");
2986 msg.append(status);
2987
2988 msg.append(StringPool.CLOSE_CURLY_BRACE);
2989
2990 throw new NoSuchFileVersionException(msg.toString());
2991 }
2992
2993
3003 public DLFileVersion fetchByG_F_S_First(long groupId, long folderId,
3004 int status, OrderByComparator orderByComparator)
3005 throws SystemException {
3006 List<DLFileVersion> list = findByG_F_S(groupId, folderId, status, 0, 1,
3007 orderByComparator);
3008
3009 if (!list.isEmpty()) {
3010 return list.get(0);
3011 }
3012
3013 return null;
3014 }
3015
3016
3027 public DLFileVersion findByG_F_S_Last(long groupId, long folderId,
3028 int status, OrderByComparator orderByComparator)
3029 throws NoSuchFileVersionException, SystemException {
3030 DLFileVersion dlFileVersion = fetchByG_F_S_Last(groupId, folderId,
3031 status, orderByComparator);
3032
3033 if (dlFileVersion != null) {
3034 return dlFileVersion;
3035 }
3036
3037 StringBundler msg = new StringBundler(8);
3038
3039 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3040
3041 msg.append("groupId=");
3042 msg.append(groupId);
3043
3044 msg.append(", folderId=");
3045 msg.append(folderId);
3046
3047 msg.append(", status=");
3048 msg.append(status);
3049
3050 msg.append(StringPool.CLOSE_CURLY_BRACE);
3051
3052 throw new NoSuchFileVersionException(msg.toString());
3053 }
3054
3055
3065 public DLFileVersion fetchByG_F_S_Last(long groupId, long folderId,
3066 int status, OrderByComparator orderByComparator)
3067 throws SystemException {
3068 int count = countByG_F_S(groupId, folderId, status);
3069
3070 List<DLFileVersion> list = findByG_F_S(groupId, folderId, status,
3071 count - 1, count, orderByComparator);
3072
3073 if (!list.isEmpty()) {
3074 return list.get(0);
3075 }
3076
3077 return null;
3078 }
3079
3080
3092 public DLFileVersion[] findByG_F_S_PrevAndNext(long fileVersionId,
3093 long groupId, long folderId, int status,
3094 OrderByComparator orderByComparator)
3095 throws NoSuchFileVersionException, SystemException {
3096 DLFileVersion dlFileVersion = findByPrimaryKey(fileVersionId);
3097
3098 Session session = null;
3099
3100 try {
3101 session = openSession();
3102
3103 DLFileVersion[] array = new DLFileVersionImpl[3];
3104
3105 array[0] = getByG_F_S_PrevAndNext(session, dlFileVersion, groupId,
3106 folderId, status, orderByComparator, true);
3107
3108 array[1] = dlFileVersion;
3109
3110 array[2] = getByG_F_S_PrevAndNext(session, dlFileVersion, groupId,
3111 folderId, status, orderByComparator, false);
3112
3113 return array;
3114 }
3115 catch (Exception e) {
3116 throw processException(e);
3117 }
3118 finally {
3119 closeSession(session);
3120 }
3121 }
3122
3123 protected DLFileVersion getByG_F_S_PrevAndNext(Session session,
3124 DLFileVersion dlFileVersion, long groupId, long folderId, int status,
3125 OrderByComparator orderByComparator, boolean previous) {
3126 StringBundler query = null;
3127
3128 if (orderByComparator != null) {
3129 query = new StringBundler(6 +
3130 (orderByComparator.getOrderByFields().length * 6));
3131 }
3132 else {
3133 query = new StringBundler(3);
3134 }
3135
3136 query.append(_SQL_SELECT_DLFILEVERSION_WHERE);
3137
3138 query.append(_FINDER_COLUMN_G_F_S_GROUPID_2);
3139
3140 query.append(_FINDER_COLUMN_G_F_S_FOLDERID_2);
3141
3142 query.append(_FINDER_COLUMN_G_F_S_STATUS_2);
3143
3144 if (orderByComparator != null) {
3145 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3146
3147 if (orderByConditionFields.length > 0) {
3148 query.append(WHERE_AND);
3149 }
3150
3151 for (int i = 0; i < orderByConditionFields.length; i++) {
3152 query.append(_ORDER_BY_ENTITY_ALIAS);
3153 query.append(orderByConditionFields[i]);
3154
3155 if ((i + 1) < orderByConditionFields.length) {
3156 if (orderByComparator.isAscending() ^ previous) {
3157 query.append(WHERE_GREATER_THAN_HAS_NEXT);
3158 }
3159 else {
3160 query.append(WHERE_LESSER_THAN_HAS_NEXT);
3161 }
3162 }
3163 else {
3164 if (orderByComparator.isAscending() ^ previous) {
3165 query.append(WHERE_GREATER_THAN);
3166 }
3167 else {
3168 query.append(WHERE_LESSER_THAN);
3169 }
3170 }
3171 }
3172
3173 query.append(ORDER_BY_CLAUSE);
3174
3175 String[] orderByFields = orderByComparator.getOrderByFields();
3176
3177 for (int i = 0; i < orderByFields.length; i++) {
3178 query.append(_ORDER_BY_ENTITY_ALIAS);
3179 query.append(orderByFields[i]);
3180
3181 if ((i + 1) < orderByFields.length) {
3182 if (orderByComparator.isAscending() ^ previous) {
3183 query.append(ORDER_BY_ASC_HAS_NEXT);
3184 }
3185 else {
3186 query.append(ORDER_BY_DESC_HAS_NEXT);
3187 }
3188 }
3189 else {
3190 if (orderByComparator.isAscending() ^ previous) {
3191 query.append(ORDER_BY_ASC);
3192 }
3193 else {
3194 query.append(ORDER_BY_DESC);
3195 }
3196 }
3197 }
3198 }
3199
3200 else {
3201 query.append(DLFileVersionModelImpl.ORDER_BY_JPQL);
3202 }
3203
3204 String sql = query.toString();
3205
3206 Query q = session.createQuery(sql);
3207
3208 q.setFirstResult(0);
3209 q.setMaxResults(2);
3210
3211 QueryPos qPos = QueryPos.getInstance(q);
3212
3213 qPos.add(groupId);
3214
3215 qPos.add(folderId);
3216
3217 qPos.add(status);
3218
3219 if (orderByComparator != null) {
3220 Object[] values = orderByComparator.getOrderByConditionValues(dlFileVersion);
3221
3222 for (Object value : values) {
3223 qPos.add(value);
3224 }
3225 }
3226
3227 List<DLFileVersion> list = q.list();
3228
3229 if (list.size() == 2) {
3230 return list.get(1);
3231 }
3232 else {
3233 return null;
3234 }
3235 }
3236
3237
3247 public List<DLFileVersion> findByG_F_T_V(long groupId, long folderId,
3248 String title, String version) throws SystemException {
3249 return findByG_F_T_V(groupId, folderId, title, version,
3250 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
3251 }
3252
3253
3269 public List<DLFileVersion> findByG_F_T_V(long groupId, long folderId,
3270 String title, String version, int start, int end)
3271 throws SystemException {
3272 return findByG_F_T_V(groupId, folderId, title, version, start, end, null);
3273 }
3274
3275
3292 public List<DLFileVersion> findByG_F_T_V(long groupId, long folderId,
3293 String title, String version, int start, int end,
3294 OrderByComparator orderByComparator) throws SystemException {
3295 FinderPath finderPath = null;
3296 Object[] finderArgs = null;
3297
3298 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
3299 (orderByComparator == null)) {
3300 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F_T_V;
3301 finderArgs = new Object[] { groupId, folderId, title, version };
3302 }
3303 else {
3304 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F_T_V;
3305 finderArgs = new Object[] {
3306 groupId, folderId, title, version,
3307
3308 start, end, orderByComparator
3309 };
3310 }
3311
3312 List<DLFileVersion> list = (List<DLFileVersion>)FinderCacheUtil.getResult(finderPath,
3313 finderArgs, this);
3314
3315 if ((list != null) && !list.isEmpty()) {
3316 for (DLFileVersion dlFileVersion : list) {
3317 if ((groupId != dlFileVersion.getGroupId()) ||
3318 (folderId != dlFileVersion.getFolderId()) ||
3319 !Validator.equals(title, dlFileVersion.getTitle()) ||
3320 !Validator.equals(version, dlFileVersion.getVersion())) {
3321 list = null;
3322
3323 break;
3324 }
3325 }
3326 }
3327
3328 if (list == null) {
3329 StringBundler query = null;
3330
3331 if (orderByComparator != null) {
3332 query = new StringBundler(6 +
3333 (orderByComparator.getOrderByFields().length * 3));
3334 }
3335 else {
3336 query = new StringBundler(6);
3337 }
3338
3339 query.append(_SQL_SELECT_DLFILEVERSION_WHERE);
3340
3341 query.append(_FINDER_COLUMN_G_F_T_V_GROUPID_2);
3342
3343 query.append(_FINDER_COLUMN_G_F_T_V_FOLDERID_2);
3344
3345 if (title == null) {
3346 query.append(_FINDER_COLUMN_G_F_T_V_TITLE_1);
3347 }
3348 else {
3349 if (title.equals(StringPool.BLANK)) {
3350 query.append(_FINDER_COLUMN_G_F_T_V_TITLE_3);
3351 }
3352 else {
3353 query.append(_FINDER_COLUMN_G_F_T_V_TITLE_2);
3354 }
3355 }
3356
3357 if (version == null) {
3358 query.append(_FINDER_COLUMN_G_F_T_V_VERSION_1);
3359 }
3360 else {
3361 if (version.equals(StringPool.BLANK)) {
3362 query.append(_FINDER_COLUMN_G_F_T_V_VERSION_3);
3363 }
3364 else {
3365 query.append(_FINDER_COLUMN_G_F_T_V_VERSION_2);
3366 }
3367 }
3368
3369 if (orderByComparator != null) {
3370 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3371 orderByComparator);
3372 }
3373
3374 else {
3375 query.append(DLFileVersionModelImpl.ORDER_BY_JPQL);
3376 }
3377
3378 String sql = query.toString();
3379
3380 Session session = null;
3381
3382 try {
3383 session = openSession();
3384
3385 Query q = session.createQuery(sql);
3386
3387 QueryPos qPos = QueryPos.getInstance(q);
3388
3389 qPos.add(groupId);
3390
3391 qPos.add(folderId);
3392
3393 if (title != null) {
3394 qPos.add(title);
3395 }
3396
3397 if (version != null) {
3398 qPos.add(version);
3399 }
3400
3401 list = (List<DLFileVersion>)QueryUtil.list(q, getDialect(),
3402 start, end);
3403 }
3404 catch (Exception e) {
3405 throw processException(e);
3406 }
3407 finally {
3408 if (list == null) {
3409 FinderCacheUtil.removeResult(finderPath, finderArgs);
3410 }
3411 else {
3412 cacheResult(list);
3413
3414 FinderCacheUtil.putResult(finderPath, finderArgs, list);
3415 }
3416
3417 closeSession(session);
3418 }
3419 }
3420
3421 return list;
3422 }
3423
3424
3436 public DLFileVersion findByG_F_T_V_First(long groupId, long folderId,
3437 String title, String version, OrderByComparator orderByComparator)
3438 throws NoSuchFileVersionException, SystemException {
3439 DLFileVersion dlFileVersion = fetchByG_F_T_V_First(groupId, folderId,
3440 title, version, orderByComparator);
3441
3442 if (dlFileVersion != null) {
3443 return dlFileVersion;
3444 }
3445
3446 StringBundler msg = new StringBundler(10);
3447
3448 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3449
3450 msg.append("groupId=");
3451 msg.append(groupId);
3452
3453 msg.append(", folderId=");
3454 msg.append(folderId);
3455
3456 msg.append(", title=");
3457 msg.append(title);
3458
3459 msg.append(", version=");
3460 msg.append(version);
3461
3462 msg.append(StringPool.CLOSE_CURLY_BRACE);
3463
3464 throw new NoSuchFileVersionException(msg.toString());
3465 }
3466
3467
3478 public DLFileVersion fetchByG_F_T_V_First(long groupId, long folderId,
3479 String title, String version, OrderByComparator orderByComparator)
3480 throws SystemException {
3481 List<DLFileVersion> list = findByG_F_T_V(groupId, folderId, title,
3482 version, 0, 1, orderByComparator);
3483
3484 if (!list.isEmpty()) {
3485 return list.get(0);
3486 }
3487
3488 return null;
3489 }
3490
3491
3503 public DLFileVersion findByG_F_T_V_Last(long groupId, long folderId,
3504 String title, String version, OrderByComparator orderByComparator)
3505 throws NoSuchFileVersionException, SystemException {
3506 DLFileVersion dlFileVersion = fetchByG_F_T_V_Last(groupId, folderId,
3507 title, version, orderByComparator);
3508
3509 if (dlFileVersion != null) {
3510 return dlFileVersion;
3511 }
3512
3513 StringBundler msg = new StringBundler(10);
3514
3515 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3516
3517 msg.append("groupId=");
3518 msg.append(groupId);
3519
3520 msg.append(", folderId=");
3521 msg.append(folderId);
3522
3523 msg.append(", title=");
3524 msg.append(title);
3525
3526 msg.append(", version=");
3527 msg.append(version);
3528
3529 msg.append(StringPool.CLOSE_CURLY_BRACE);
3530
3531 throw new NoSuchFileVersionException(msg.toString());
3532 }
3533
3534
3545 public DLFileVersion fetchByG_F_T_V_Last(long groupId, long folderId,
3546 String title, String version, OrderByComparator orderByComparator)
3547 throws SystemException {
3548 int count = countByG_F_T_V(groupId, folderId, title, version);
3549
3550 List<DLFileVersion> list = findByG_F_T_V(groupId, folderId, title,
3551 version, count - 1, count, orderByComparator);
3552
3553 if (!list.isEmpty()) {
3554 return list.get(0);
3555 }
3556
3557 return null;
3558 }
3559
3560
3573 public DLFileVersion[] findByG_F_T_V_PrevAndNext(long fileVersionId,
3574 long groupId, long folderId, String title, String version,
3575 OrderByComparator orderByComparator)
3576 throws NoSuchFileVersionException, SystemException {
3577 DLFileVersion dlFileVersion = findByPrimaryKey(fileVersionId);
3578
3579 Session session = null;
3580
3581 try {
3582 session = openSession();
3583
3584 DLFileVersion[] array = new DLFileVersionImpl[3];
3585
3586 array[0] = getByG_F_T_V_PrevAndNext(session, dlFileVersion,
3587 groupId, folderId, title, version, orderByComparator, true);
3588
3589 array[1] = dlFileVersion;
3590
3591 array[2] = getByG_F_T_V_PrevAndNext(session, dlFileVersion,
3592 groupId, folderId, title, version, orderByComparator, false);
3593
3594 return array;
3595 }
3596 catch (Exception e) {
3597 throw processException(e);
3598 }
3599 finally {
3600 closeSession(session);
3601 }
3602 }
3603
3604 protected DLFileVersion getByG_F_T_V_PrevAndNext(Session session,
3605 DLFileVersion dlFileVersion, long groupId, long folderId, String title,
3606 String version, OrderByComparator orderByComparator, boolean previous) {
3607 StringBundler query = null;
3608
3609 if (orderByComparator != null) {
3610 query = new StringBundler(6 +
3611 (orderByComparator.getOrderByFields().length * 6));
3612 }
3613 else {
3614 query = new StringBundler(3);
3615 }
3616
3617 query.append(_SQL_SELECT_DLFILEVERSION_WHERE);
3618
3619 query.append(_FINDER_COLUMN_G_F_T_V_GROUPID_2);
3620
3621 query.append(_FINDER_COLUMN_G_F_T_V_FOLDERID_2);
3622
3623 if (title == null) {
3624 query.append(_FINDER_COLUMN_G_F_T_V_TITLE_1);
3625 }
3626 else {
3627 if (title.equals(StringPool.BLANK)) {
3628 query.append(_FINDER_COLUMN_G_F_T_V_TITLE_3);
3629 }
3630 else {
3631 query.append(_FINDER_COLUMN_G_F_T_V_TITLE_2);
3632 }
3633 }
3634
3635 if (version == null) {
3636 query.append(_FINDER_COLUMN_G_F_T_V_VERSION_1);
3637 }
3638 else {
3639 if (version.equals(StringPool.BLANK)) {
3640 query.append(_FINDER_COLUMN_G_F_T_V_VERSION_3);
3641 }
3642 else {
3643 query.append(_FINDER_COLUMN_G_F_T_V_VERSION_2);
3644 }
3645 }
3646
3647 if (orderByComparator != null) {
3648 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3649
3650 if (orderByConditionFields.length > 0) {
3651 query.append(WHERE_AND);
3652 }
3653
3654 for (int i = 0; i < orderByConditionFields.length; i++) {
3655 query.append(_ORDER_BY_ENTITY_ALIAS);
3656 query.append(orderByConditionFields[i]);
3657
3658 if ((i + 1) < orderByConditionFields.length) {
3659 if (orderByComparator.isAscending() ^ previous) {
3660 query.append(WHERE_GREATER_THAN_HAS_NEXT);
3661 }
3662 else {
3663 query.append(WHERE_LESSER_THAN_HAS_NEXT);
3664 }
3665 }
3666 else {
3667 if (orderByComparator.isAscending() ^ previous) {
3668 query.append(WHERE_GREATER_THAN);
3669 }
3670 else {
3671 query.append(WHERE_LESSER_THAN);
3672 }
3673 }
3674 }
3675
3676 query.append(ORDER_BY_CLAUSE);
3677
3678 String[] orderByFields = orderByComparator.getOrderByFields();
3679
3680 for (int i = 0; i < orderByFields.length; i++) {
3681 query.append(_ORDER_BY_ENTITY_ALIAS);
3682 query.append(orderByFields[i]);
3683
3684 if ((i + 1) < orderByFields.length) {
3685 if (orderByComparator.isAscending() ^ previous) {
3686 query.append(ORDER_BY_ASC_HAS_NEXT);
3687 }
3688 else {
3689 query.append(ORDER_BY_DESC_HAS_NEXT);
3690 }
3691 }
3692 else {
3693 if (orderByComparator.isAscending() ^ previous) {
3694 query.append(ORDER_BY_ASC);
3695 }
3696 else {
3697 query.append(ORDER_BY_DESC);
3698 }
3699 }
3700 }
3701 }
3702
3703 else {
3704 query.append(DLFileVersionModelImpl.ORDER_BY_JPQL);
3705 }
3706
3707 String sql = query.toString();
3708
3709 Query q = session.createQuery(sql);
3710
3711 q.setFirstResult(0);
3712 q.setMaxResults(2);
3713
3714 QueryPos qPos = QueryPos.getInstance(q);
3715
3716 qPos.add(groupId);
3717
3718 qPos.add(folderId);
3719
3720 if (title != null) {
3721 qPos.add(title);
3722 }
3723
3724 if (version != null) {
3725 qPos.add(version);
3726 }
3727
3728 if (orderByComparator != null) {
3729 Object[] values = orderByComparator.getOrderByConditionValues(dlFileVersion);
3730
3731 for (Object value : values) {
3732 qPos.add(value);
3733 }
3734 }
3735
3736 List<DLFileVersion> list = q.list();
3737
3738 if (list.size() == 2) {
3739 return list.get(1);
3740 }
3741 else {
3742 return null;
3743 }
3744 }
3745
3746
3752 public List<DLFileVersion> findAll() throws SystemException {
3753 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
3754 }
3755
3756
3768 public List<DLFileVersion> findAll(int start, int end)
3769 throws SystemException {
3770 return findAll(start, end, null);
3771 }
3772
3773
3786 public List<DLFileVersion> findAll(int start, int end,
3787 OrderByComparator orderByComparator) throws SystemException {
3788 FinderPath finderPath = null;
3789 Object[] finderArgs = new Object[] { start, end, orderByComparator };
3790
3791 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
3792 (orderByComparator == null)) {
3793 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
3794 finderArgs = FINDER_ARGS_EMPTY;
3795 }
3796 else {
3797 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
3798 finderArgs = new Object[] { start, end, orderByComparator };
3799 }
3800
3801 List<DLFileVersion> list = (List<DLFileVersion>)FinderCacheUtil.getResult(finderPath,
3802 finderArgs, this);
3803
3804 if (list == null) {
3805 StringBundler query = null;
3806 String sql = null;
3807
3808 if (orderByComparator != null) {
3809 query = new StringBundler(2 +
3810 (orderByComparator.getOrderByFields().length * 3));
3811
3812 query.append(_SQL_SELECT_DLFILEVERSION);
3813
3814 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3815 orderByComparator);
3816
3817 sql = query.toString();
3818 }
3819 else {
3820 sql = _SQL_SELECT_DLFILEVERSION.concat(DLFileVersionModelImpl.ORDER_BY_JPQL);
3821 }
3822
3823 Session session = null;
3824
3825 try {
3826 session = openSession();
3827
3828 Query q = session.createQuery(sql);
3829
3830 if (orderByComparator == null) {
3831 list = (List<DLFileVersion>)QueryUtil.list(q, getDialect(),
3832 start, end, false);
3833
3834 Collections.sort(list);
3835 }
3836 else {
3837 list = (List<DLFileVersion>)QueryUtil.list(q, getDialect(),
3838 start, end);
3839 }
3840 }
3841 catch (Exception e) {
3842 throw processException(e);
3843 }
3844 finally {
3845 if (list == null) {
3846 FinderCacheUtil.removeResult(finderPath, finderArgs);
3847 }
3848 else {
3849 cacheResult(list);
3850
3851 FinderCacheUtil.putResult(finderPath, finderArgs, list);
3852 }
3853
3854 closeSession(session);
3855 }
3856 }
3857
3858 return list;
3859 }
3860
3861
3867 public void removeByUuid(String uuid) throws SystemException {
3868 for (DLFileVersion dlFileVersion : findByUuid(uuid)) {
3869 remove(dlFileVersion);
3870 }
3871 }
3872
3873
3881 public DLFileVersion removeByUUID_G(String uuid, long groupId)
3882 throws NoSuchFileVersionException, SystemException {
3883 DLFileVersion dlFileVersion = findByUUID_G(uuid, groupId);
3884
3885 return remove(dlFileVersion);
3886 }
3887
3888
3895 public void removeByUuid_C(String uuid, long companyId)
3896 throws SystemException {
3897 for (DLFileVersion dlFileVersion : findByUuid_C(uuid, companyId)) {
3898 remove(dlFileVersion);
3899 }
3900 }
3901
3902
3908 public void removeByFileEntryId(long fileEntryId) throws SystemException {
3909 for (DLFileVersion dlFileVersion : findByFileEntryId(fileEntryId)) {
3910 remove(dlFileVersion);
3911 }
3912 }
3913
3914
3922 public DLFileVersion removeByF_V(long fileEntryId, String version)
3923 throws NoSuchFileVersionException, SystemException {
3924 DLFileVersion dlFileVersion = findByF_V(fileEntryId, version);
3925
3926 return remove(dlFileVersion);
3927 }
3928
3929
3936 public void removeByF_S(long fileEntryId, int status)
3937 throws SystemException {
3938 for (DLFileVersion dlFileVersion : findByF_S(fileEntryId, status)) {
3939 remove(dlFileVersion);
3940 }
3941 }
3942
3943
3951 public void removeByG_F_S(long groupId, long folderId, int status)
3952 throws SystemException {
3953 for (DLFileVersion dlFileVersion : findByG_F_S(groupId, folderId, status)) {
3954 remove(dlFileVersion);
3955 }
3956 }
3957
3958
3967 public void removeByG_F_T_V(long groupId, long folderId, String title,
3968 String version) throws SystemException {
3969 for (DLFileVersion dlFileVersion : findByG_F_T_V(groupId, folderId,
3970 title, version)) {
3971 remove(dlFileVersion);
3972 }
3973 }
3974
3975
3980 public void removeAll() throws SystemException {
3981 for (DLFileVersion dlFileVersion : findAll()) {
3982 remove(dlFileVersion);
3983 }
3984 }
3985
3986
3993 public int countByUuid(String uuid) throws SystemException {
3994 Object[] finderArgs = new Object[] { uuid };
3995
3996 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID,
3997 finderArgs, this);
3998
3999 if (count == null) {
4000 StringBundler query = new StringBundler(2);
4001
4002 query.append(_SQL_COUNT_DLFILEVERSION_WHERE);
4003
4004 if (uuid == null) {
4005 query.append(_FINDER_COLUMN_UUID_UUID_1);
4006 }
4007 else {
4008 if (uuid.equals(StringPool.BLANK)) {
4009 query.append(_FINDER_COLUMN_UUID_UUID_3);
4010 }
4011 else {
4012 query.append(_FINDER_COLUMN_UUID_UUID_2);
4013 }
4014 }
4015
4016 String sql = query.toString();
4017
4018 Session session = null;
4019
4020 try {
4021 session = openSession();
4022
4023 Query q = session.createQuery(sql);
4024
4025 QueryPos qPos = QueryPos.getInstance(q);
4026
4027 if (uuid != null) {
4028 qPos.add(uuid);
4029 }
4030
4031 count = (Long)q.uniqueResult();
4032 }
4033 catch (Exception e) {
4034 throw processException(e);
4035 }
4036 finally {
4037 if (count == null) {
4038 count = Long.valueOf(0);
4039 }
4040
4041 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID,
4042 finderArgs, count);
4043
4044 closeSession(session);
4045 }
4046 }
4047
4048 return count.intValue();
4049 }
4050
4051
4059 public int countByUUID_G(String uuid, long groupId)
4060 throws SystemException {
4061 Object[] finderArgs = new Object[] { uuid, groupId };
4062
4063 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID_G,
4064 finderArgs, this);
4065
4066 if (count == null) {
4067 StringBundler query = new StringBundler(3);
4068
4069 query.append(_SQL_COUNT_DLFILEVERSION_WHERE);
4070
4071 if (uuid == null) {
4072 query.append(_FINDER_COLUMN_UUID_G_UUID_1);
4073 }
4074 else {
4075 if (uuid.equals(StringPool.BLANK)) {
4076 query.append(_FINDER_COLUMN_UUID_G_UUID_3);
4077 }
4078 else {
4079 query.append(_FINDER_COLUMN_UUID_G_UUID_2);
4080 }
4081 }
4082
4083 query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
4084
4085 String sql = query.toString();
4086
4087 Session session = null;
4088
4089 try {
4090 session = openSession();
4091
4092 Query q = session.createQuery(sql);
4093
4094 QueryPos qPos = QueryPos.getInstance(q);
4095
4096 if (uuid != null) {
4097 qPos.add(uuid);
4098 }
4099
4100 qPos.add(groupId);
4101
4102 count = (Long)q.uniqueResult();
4103 }
4104 catch (Exception e) {
4105 throw processException(e);
4106 }
4107 finally {
4108 if (count == null) {
4109 count = Long.valueOf(0);
4110 }
4111
4112 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G,
4113 finderArgs, count);
4114
4115 closeSession(session);
4116 }
4117 }
4118
4119 return count.intValue();
4120 }
4121
4122
4130 public int countByUuid_C(String uuid, long companyId)
4131 throws SystemException {
4132 Object[] finderArgs = new Object[] { uuid, companyId };
4133
4134 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID_C,
4135 finderArgs, this);
4136
4137 if (count == null) {
4138 StringBundler query = new StringBundler(3);
4139
4140 query.append(_SQL_COUNT_DLFILEVERSION_WHERE);
4141
4142 if (uuid == null) {
4143 query.append(_FINDER_COLUMN_UUID_C_UUID_1);
4144 }
4145 else {
4146 if (uuid.equals(StringPool.BLANK)) {
4147 query.append(_FINDER_COLUMN_UUID_C_UUID_3);
4148 }
4149 else {
4150 query.append(_FINDER_COLUMN_UUID_C_UUID_2);
4151 }
4152 }
4153
4154 query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
4155
4156 String sql = query.toString();
4157
4158 Session session = null;
4159
4160 try {
4161 session = openSession();
4162
4163 Query q = session.createQuery(sql);
4164
4165 QueryPos qPos = QueryPos.getInstance(q);
4166
4167 if (uuid != null) {
4168 qPos.add(uuid);
4169 }
4170
4171 qPos.add(companyId);
4172
4173 count = (Long)q.uniqueResult();
4174 }
4175 catch (Exception e) {
4176 throw processException(e);
4177 }
4178 finally {
4179 if (count == null) {
4180 count = Long.valueOf(0);
4181 }
4182
4183 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_C,
4184 finderArgs, count);
4185
4186 closeSession(session);
4187 }
4188 }
4189
4190 return count.intValue();
4191 }
4192
4193
4200 public int countByFileEntryId(long fileEntryId) throws SystemException {
4201 Object[] finderArgs = new Object[] { fileEntryId };
4202
4203 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_FILEENTRYID,
4204 finderArgs, this);
4205
4206 if (count == null) {
4207 StringBundler query = new StringBundler(2);
4208
4209 query.append(_SQL_COUNT_DLFILEVERSION_WHERE);
4210
4211 query.append(_FINDER_COLUMN_FILEENTRYID_FILEENTRYID_2);
4212
4213 String sql = query.toString();
4214
4215 Session session = null;
4216
4217 try {
4218 session = openSession();
4219
4220 Query q = session.createQuery(sql);
4221
4222 QueryPos qPos = QueryPos.getInstance(q);
4223
4224 qPos.add(fileEntryId);
4225
4226 count = (Long)q.uniqueResult();
4227 }
4228 catch (Exception e) {
4229 throw processException(e);
4230 }
4231 finally {
4232 if (count == null) {
4233 count = Long.valueOf(0);
4234 }
4235
4236 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_FILEENTRYID,
4237 finderArgs, count);
4238
4239 closeSession(session);
4240 }
4241 }
4242
4243 return count.intValue();
4244 }
4245
4246
4254 public int countByF_V(long fileEntryId, String version)
4255 throws SystemException {
4256 Object[] finderArgs = new Object[] { fileEntryId, version };
4257
4258 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_F_V,
4259 finderArgs, this);
4260
4261 if (count == null) {
4262 StringBundler query = new StringBundler(3);
4263
4264 query.append(_SQL_COUNT_DLFILEVERSION_WHERE);
4265
4266 query.append(_FINDER_COLUMN_F_V_FILEENTRYID_2);
4267
4268 if (version == null) {
4269 query.append(_FINDER_COLUMN_F_V_VERSION_1);
4270 }
4271 else {
4272 if (version.equals(StringPool.BLANK)) {
4273 query.append(_FINDER_COLUMN_F_V_VERSION_3);
4274 }
4275 else {
4276 query.append(_FINDER_COLUMN_F_V_VERSION_2);
4277 }
4278 }
4279
4280 String sql = query.toString();
4281
4282 Session session = null;
4283
4284 try {
4285 session = openSession();
4286
4287 Query q = session.createQuery(sql);
4288
4289 QueryPos qPos = QueryPos.getInstance(q);
4290
4291 qPos.add(fileEntryId);
4292
4293 if (version != null) {
4294 qPos.add(version);
4295 }
4296
4297 count = (Long)q.uniqueResult();
4298 }
4299 catch (Exception e) {
4300 throw processException(e);
4301 }
4302 finally {
4303 if (count == null) {
4304 count = Long.valueOf(0);
4305 }
4306
4307 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_F_V, finderArgs,
4308 count);
4309
4310 closeSession(session);
4311 }
4312 }
4313
4314 return count.intValue();
4315 }
4316
4317
4325 public int countByF_S(long fileEntryId, int status)
4326 throws SystemException {
4327 Object[] finderArgs = new Object[] { fileEntryId, status };
4328
4329 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_F_S,
4330 finderArgs, this);
4331
4332 if (count == null) {
4333 StringBundler query = new StringBundler(3);
4334
4335 query.append(_SQL_COUNT_DLFILEVERSION_WHERE);
4336
4337 query.append(_FINDER_COLUMN_F_S_FILEENTRYID_2);
4338
4339 query.append(_FINDER_COLUMN_F_S_STATUS_2);
4340
4341 String sql = query.toString();
4342
4343 Session session = null;
4344
4345 try {
4346 session = openSession();
4347
4348 Query q = session.createQuery(sql);
4349
4350 QueryPos qPos = QueryPos.getInstance(q);
4351
4352 qPos.add(fileEntryId);
4353
4354 qPos.add(status);
4355
4356 count = (Long)q.uniqueResult();
4357 }
4358 catch (Exception e) {
4359 throw processException(e);
4360 }
4361 finally {
4362 if (count == null) {
4363 count = Long.valueOf(0);
4364 }
4365
4366 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_F_S, finderArgs,
4367 count);
4368
4369 closeSession(session);
4370 }
4371 }
4372
4373 return count.intValue();
4374 }
4375
4376
4385 public int countByG_F_S(long groupId, long folderId, int status)
4386 throws SystemException {
4387 Object[] finderArgs = new Object[] { groupId, folderId, status };
4388
4389 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_F_S,
4390 finderArgs, this);
4391
4392 if (count == null) {
4393 StringBundler query = new StringBundler(4);
4394
4395 query.append(_SQL_COUNT_DLFILEVERSION_WHERE);
4396
4397 query.append(_FINDER_COLUMN_G_F_S_GROUPID_2);
4398
4399 query.append(_FINDER_COLUMN_G_F_S_FOLDERID_2);
4400
4401 query.append(_FINDER_COLUMN_G_F_S_STATUS_2);
4402
4403 String sql = query.toString();
4404
4405 Session session = null;
4406
4407 try {
4408 session = openSession();
4409
4410 Query q = session.createQuery(sql);
4411
4412 QueryPos qPos = QueryPos.getInstance(q);
4413
4414 qPos.add(groupId);
4415
4416 qPos.add(folderId);
4417
4418 qPos.add(status);
4419
4420 count = (Long)q.uniqueResult();
4421 }
4422 catch (Exception e) {
4423 throw processException(e);
4424 }
4425 finally {
4426 if (count == null) {
4427 count = Long.valueOf(0);
4428 }
4429
4430 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_F_S,
4431 finderArgs, count);
4432
4433 closeSession(session);
4434 }
4435 }
4436
4437 return count.intValue();
4438 }
4439
4440
4450 public int countByG_F_T_V(long groupId, long folderId, String title,
4451 String version) throws SystemException {
4452 Object[] finderArgs = new Object[] { groupId, folderId, title, version };
4453
4454 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_F_T_V,
4455 finderArgs, this);
4456
4457 if (count == null) {
4458 StringBundler query = new StringBundler(5);
4459
4460 query.append(_SQL_COUNT_DLFILEVERSION_WHERE);
4461
4462 query.append(_FINDER_COLUMN_G_F_T_V_GROUPID_2);
4463
4464 query.append(_FINDER_COLUMN_G_F_T_V_FOLDERID_2);
4465
4466 if (title == null) {
4467 query.append(_FINDER_COLUMN_G_F_T_V_TITLE_1);
4468 }
4469 else {
4470 if (title.equals(StringPool.BLANK)) {
4471 query.append(_FINDER_COLUMN_G_F_T_V_TITLE_3);
4472 }
4473 else {
4474 query.append(_FINDER_COLUMN_G_F_T_V_TITLE_2);
4475 }
4476 }
4477
4478 if (version == null) {
4479 query.append(_FINDER_COLUMN_G_F_T_V_VERSION_1);
4480 }
4481 else {
4482 if (version.equals(StringPool.BLANK)) {
4483 query.append(_FINDER_COLUMN_G_F_T_V_VERSION_3);
4484 }
4485 else {
4486 query.append(_FINDER_COLUMN_G_F_T_V_VERSION_2);
4487 }
4488 }
4489
4490 String sql = query.toString();
4491
4492 Session session = null;
4493
4494 try {
4495 session = openSession();
4496
4497 Query q = session.createQuery(sql);
4498
4499 QueryPos qPos = QueryPos.getInstance(q);
4500
4501 qPos.add(groupId);
4502
4503 qPos.add(folderId);
4504
4505 if (title != null) {
4506 qPos.add(title);
4507 }
4508
4509 if (version != null) {
4510 qPos.add(version);
4511 }
4512
4513 count = (Long)q.uniqueResult();
4514 }
4515 catch (Exception e) {
4516 throw processException(e);
4517 }
4518 finally {
4519 if (count == null) {
4520 count = Long.valueOf(0);
4521 }
4522
4523 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_F_T_V,
4524 finderArgs, count);
4525
4526 closeSession(session);
4527 }
4528 }
4529
4530 return count.intValue();
4531 }
4532
4533
4539 public int countAll() throws SystemException {
4540 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
4541 FINDER_ARGS_EMPTY, this);
4542
4543 if (count == null) {
4544 Session session = null;
4545
4546 try {
4547 session = openSession();
4548
4549 Query q = session.createQuery(_SQL_COUNT_DLFILEVERSION);
4550
4551 count = (Long)q.uniqueResult();
4552 }
4553 catch (Exception e) {
4554 throw processException(e);
4555 }
4556 finally {
4557 if (count == null) {
4558 count = Long.valueOf(0);
4559 }
4560
4561 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
4562 FINDER_ARGS_EMPTY, count);
4563
4564 closeSession(session);
4565 }
4566 }
4567
4568 return count.intValue();
4569 }
4570
4571
4574 public void afterPropertiesSet() {
4575 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
4576 com.liferay.portal.util.PropsUtil.get(
4577 "value.object.listener.com.liferay.portlet.documentlibrary.model.DLFileVersion")));
4578
4579 if (listenerClassNames.length > 0) {
4580 try {
4581 List<ModelListener<DLFileVersion>> listenersList = new ArrayList<ModelListener<DLFileVersion>>();
4582
4583 for (String listenerClassName : listenerClassNames) {
4584 listenersList.add((ModelListener<DLFileVersion>)InstanceFactory.newInstance(
4585 listenerClassName));
4586 }
4587
4588 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
4589 }
4590 catch (Exception e) {
4591 _log.error(e);
4592 }
4593 }
4594 }
4595
4596 public void destroy() {
4597 EntityCacheUtil.removeCache(DLFileVersionImpl.class.getName());
4598 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
4599 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
4600 }
4601
4602 @BeanReference(type = DLContentPersistence.class)
4603 protected DLContentPersistence dlContentPersistence;
4604 @BeanReference(type = DLFileEntryPersistence.class)
4605 protected DLFileEntryPersistence dlFileEntryPersistence;
4606 @BeanReference(type = DLFileEntryMetadataPersistence.class)
4607 protected DLFileEntryMetadataPersistence dlFileEntryMetadataPersistence;
4608 @BeanReference(type = DLFileEntryTypePersistence.class)
4609 protected DLFileEntryTypePersistence dlFileEntryTypePersistence;
4610 @BeanReference(type = DLFileRankPersistence.class)
4611 protected DLFileRankPersistence dlFileRankPersistence;
4612 @BeanReference(type = DLFileShortcutPersistence.class)
4613 protected DLFileShortcutPersistence dlFileShortcutPersistence;
4614 @BeanReference(type = DLFileVersionPersistence.class)
4615 protected DLFileVersionPersistence dlFileVersionPersistence;
4616 @BeanReference(type = DLFolderPersistence.class)
4617 protected DLFolderPersistence dlFolderPersistence;
4618 @BeanReference(type = DLSyncPersistence.class)
4619 protected DLSyncPersistence dlSyncPersistence;
4620 @BeanReference(type = UserPersistence.class)
4621 protected UserPersistence userPersistence;
4622 private static final String _SQL_SELECT_DLFILEVERSION = "SELECT dlFileVersion FROM DLFileVersion dlFileVersion";
4623 private static final String _SQL_SELECT_DLFILEVERSION_WHERE = "SELECT dlFileVersion FROM DLFileVersion dlFileVersion WHERE ";
4624 private static final String _SQL_COUNT_DLFILEVERSION = "SELECT COUNT(dlFileVersion) FROM DLFileVersion dlFileVersion";
4625 private static final String _SQL_COUNT_DLFILEVERSION_WHERE = "SELECT COUNT(dlFileVersion) FROM DLFileVersion dlFileVersion WHERE ";
4626 private static final String _FINDER_COLUMN_UUID_UUID_1 = "dlFileVersion.uuid IS NULL";
4627 private static final String _FINDER_COLUMN_UUID_UUID_2 = "dlFileVersion.uuid = ?";
4628 private static final String _FINDER_COLUMN_UUID_UUID_3 = "(dlFileVersion.uuid IS NULL OR dlFileVersion.uuid = ?)";
4629 private static final String _FINDER_COLUMN_UUID_G_UUID_1 = "dlFileVersion.uuid IS NULL AND ";
4630 private static final String _FINDER_COLUMN_UUID_G_UUID_2 = "dlFileVersion.uuid = ? AND ";
4631 private static final String _FINDER_COLUMN_UUID_G_UUID_3 = "(dlFileVersion.uuid IS NULL OR dlFileVersion.uuid = ?) AND ";
4632 private static final String _FINDER_COLUMN_UUID_G_GROUPID_2 = "dlFileVersion.groupId = ?";
4633 private static final String _FINDER_COLUMN_UUID_C_UUID_1 = "dlFileVersion.uuid IS NULL AND ";
4634 private static final String _FINDER_COLUMN_UUID_C_UUID_2 = "dlFileVersion.uuid = ? AND ";
4635 private static final String _FINDER_COLUMN_UUID_C_UUID_3 = "(dlFileVersion.uuid IS NULL OR dlFileVersion.uuid = ?) AND ";
4636 private static final String _FINDER_COLUMN_UUID_C_COMPANYID_2 = "dlFileVersion.companyId = ?";
4637 private static final String _FINDER_COLUMN_FILEENTRYID_FILEENTRYID_2 = "dlFileVersion.fileEntryId = ?";
4638 private static final String _FINDER_COLUMN_F_V_FILEENTRYID_2 = "dlFileVersion.fileEntryId = ? AND ";
4639 private static final String _FINDER_COLUMN_F_V_VERSION_1 = "dlFileVersion.version IS NULL";
4640 private static final String _FINDER_COLUMN_F_V_VERSION_2 = "dlFileVersion.version = ?";
4641 private static final String _FINDER_COLUMN_F_V_VERSION_3 = "(dlFileVersion.version IS NULL OR dlFileVersion.version = ?)";
4642 private static final String _FINDER_COLUMN_F_S_FILEENTRYID_2 = "dlFileVersion.fileEntryId = ? AND ";
4643 private static final String _FINDER_COLUMN_F_S_STATUS_2 = "dlFileVersion.status = ?";
4644 private static final String _FINDER_COLUMN_G_F_S_GROUPID_2 = "dlFileVersion.groupId = ? AND ";
4645 private static final String _FINDER_COLUMN_G_F_S_FOLDERID_2 = "dlFileVersion.folderId = ? AND ";
4646 private static final String _FINDER_COLUMN_G_F_S_STATUS_2 = "dlFileVersion.status = ?";
4647 private static final String _FINDER_COLUMN_G_F_T_V_GROUPID_2 = "dlFileVersion.groupId = ? AND ";
4648 private static final String _FINDER_COLUMN_G_F_T_V_FOLDERID_2 = "dlFileVersion.folderId = ? AND ";
4649 private static final String _FINDER_COLUMN_G_F_T_V_TITLE_1 = "dlFileVersion.title IS NULL AND ";
4650 private static final String _FINDER_COLUMN_G_F_T_V_TITLE_2 = "dlFileVersion.title = ? AND ";
4651 private static final String _FINDER_COLUMN_G_F_T_V_TITLE_3 = "(dlFileVersion.title IS NULL OR dlFileVersion.title = ?) AND ";
4652 private static final String _FINDER_COLUMN_G_F_T_V_VERSION_1 = "dlFileVersion.version IS NULL";
4653 private static final String _FINDER_COLUMN_G_F_T_V_VERSION_2 = "dlFileVersion.version = ?";
4654 private static final String _FINDER_COLUMN_G_F_T_V_VERSION_3 = "(dlFileVersion.version IS NULL OR dlFileVersion.version = ?)";
4655 private static final String _ORDER_BY_ENTITY_ALIAS = "dlFileVersion.";
4656 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No DLFileVersion exists with the primary key ";
4657 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No DLFileVersion exists with the key {";
4658 private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
4659 private static Log _log = LogFactoryUtil.getLog(DLFileVersionPersistenceImpl.class);
4660 private static DLFileVersion _nullDLFileVersion = new DLFileVersionImpl() {
4661 @Override
4662 public Object clone() {
4663 return this;
4664 }
4665
4666 @Override
4667 public CacheModel<DLFileVersion> toCacheModel() {
4668 return _nullDLFileVersionCacheModel;
4669 }
4670 };
4671
4672 private static CacheModel<DLFileVersion> _nullDLFileVersionCacheModel = new CacheModel<DLFileVersion>() {
4673 public DLFileVersion toEntityModel() {
4674 return _nullDLFileVersion;
4675 }
4676 };
4677 }