001
014
015 package com.liferay.portlet.documentlibrary.service.persistence;
016
017 import com.liferay.portal.NoSuchModelException;
018 import com.liferay.portal.kernel.annotation.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.SQLQuery;
027 import com.liferay.portal.kernel.dao.orm.Session;
028 import com.liferay.portal.kernel.exception.SystemException;
029 import com.liferay.portal.kernel.log.Log;
030 import com.liferay.portal.kernel.log.LogFactoryUtil;
031 import com.liferay.portal.kernel.util.GetterUtil;
032 import com.liferay.portal.kernel.util.InstanceFactory;
033 import com.liferay.portal.kernel.util.OrderByComparator;
034 import com.liferay.portal.kernel.util.StringBundler;
035 import com.liferay.portal.kernel.util.StringPool;
036 import com.liferay.portal.kernel.util.StringUtil;
037 import com.liferay.portal.kernel.util.Validator;
038 import com.liferay.portal.kernel.uuid.PortalUUIDUtil;
039 import com.liferay.portal.model.ModelListener;
040 import com.liferay.portal.security.permission.InlineSQLHelperUtil;
041 import com.liferay.portal.service.persistence.BatchSessionUtil;
042 import com.liferay.portal.service.persistence.LockPersistence;
043 import com.liferay.portal.service.persistence.ResourcePersistence;
044 import com.liferay.portal.service.persistence.UserPersistence;
045 import com.liferay.portal.service.persistence.WebDAVPropsPersistence;
046 import com.liferay.portal.service.persistence.WorkflowInstanceLinkPersistence;
047 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
048
049 import com.liferay.portlet.asset.service.persistence.AssetCategoryPersistence;
050 import com.liferay.portlet.asset.service.persistence.AssetEntryPersistence;
051 import com.liferay.portlet.asset.service.persistence.AssetTagPersistence;
052 import com.liferay.portlet.documentlibrary.NoSuchFileEntryException;
053 import com.liferay.portlet.documentlibrary.model.DLFileEntry;
054 import com.liferay.portlet.documentlibrary.model.impl.DLFileEntryImpl;
055 import com.liferay.portlet.documentlibrary.model.impl.DLFileEntryModelImpl;
056 import com.liferay.portlet.expando.service.persistence.ExpandoValuePersistence;
057 import com.liferay.portlet.messageboards.service.persistence.MBDiscussionPersistence;
058 import com.liferay.portlet.messageboards.service.persistence.MBMessagePersistence;
059 import com.liferay.portlet.ratings.service.persistence.RatingsEntryPersistence;
060 import com.liferay.portlet.ratings.service.persistence.RatingsStatsPersistence;
061 import com.liferay.portlet.social.service.persistence.SocialActivityPersistence;
062
063 import java.io.Serializable;
064
065 import java.util.ArrayList;
066 import java.util.Collections;
067 import java.util.List;
068
069
085 public class DLFileEntryPersistenceImpl extends BasePersistenceImpl<DLFileEntry>
086 implements DLFileEntryPersistence {
087 public static final String FINDER_CLASS_NAME_ENTITY = DLFileEntryImpl.class.getName();
088 public static final String FINDER_CLASS_NAME_LIST = FINDER_CLASS_NAME_ENTITY +
089 ".List";
090 public static final FinderPath FINDER_PATH_FIND_BY_UUID = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
091 DLFileEntryModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
092 "findByUuid",
093 new String[] {
094 String.class.getName(),
095
096 "java.lang.Integer", "java.lang.Integer",
097 "com.liferay.portal.kernel.util.OrderByComparator"
098 });
099 public static final FinderPath FINDER_PATH_COUNT_BY_UUID = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
100 DLFileEntryModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
101 "countByUuid", new String[] { String.class.getName() });
102 public static final FinderPath FINDER_PATH_FETCH_BY_UUID_G = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
103 DLFileEntryModelImpl.FINDER_CACHE_ENABLED,
104 FINDER_CLASS_NAME_ENTITY, "fetchByUUID_G",
105 new String[] { String.class.getName(), Long.class.getName() });
106 public static final FinderPath FINDER_PATH_COUNT_BY_UUID_G = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
107 DLFileEntryModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
108 "countByUUID_G",
109 new String[] { String.class.getName(), Long.class.getName() });
110 public static final FinderPath FINDER_PATH_FIND_BY_GROUPID = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
111 DLFileEntryModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
112 "findByGroupId",
113 new String[] {
114 Long.class.getName(),
115
116 "java.lang.Integer", "java.lang.Integer",
117 "com.liferay.portal.kernel.util.OrderByComparator"
118 });
119 public static final FinderPath FINDER_PATH_COUNT_BY_GROUPID = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
120 DLFileEntryModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
121 "countByGroupId", new String[] { Long.class.getName() });
122 public static final FinderPath FINDER_PATH_FIND_BY_COMPANYID = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
123 DLFileEntryModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
124 "findByCompanyId",
125 new String[] {
126 Long.class.getName(),
127
128 "java.lang.Integer", "java.lang.Integer",
129 "com.liferay.portal.kernel.util.OrderByComparator"
130 });
131 public static final FinderPath FINDER_PATH_COUNT_BY_COMPANYID = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
132 DLFileEntryModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
133 "countByCompanyId", new String[] { Long.class.getName() });
134 public static final FinderPath FINDER_PATH_FIND_BY_G_U = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
135 DLFileEntryModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
136 "findByG_U",
137 new String[] {
138 Long.class.getName(), Long.class.getName(),
139
140 "java.lang.Integer", "java.lang.Integer",
141 "com.liferay.portal.kernel.util.OrderByComparator"
142 });
143 public static final FinderPath FINDER_PATH_COUNT_BY_G_U = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
144 DLFileEntryModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
145 "countByG_U",
146 new String[] { Long.class.getName(), Long.class.getName() });
147 public static final FinderPath FINDER_PATH_FIND_BY_G_F = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
148 DLFileEntryModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
149 "findByG_F",
150 new String[] {
151 Long.class.getName(), Long.class.getName(),
152
153 "java.lang.Integer", "java.lang.Integer",
154 "com.liferay.portal.kernel.util.OrderByComparator"
155 });
156 public static final FinderPath FINDER_PATH_COUNT_BY_G_F = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
157 DLFileEntryModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
158 "countByG_F",
159 new String[] { Long.class.getName(), Long.class.getName() });
160 public static final FinderPath FINDER_PATH_FIND_BY_G_U_F = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
161 DLFileEntryModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
162 "findByG_U_F",
163 new String[] {
164 Long.class.getName(), Long.class.getName(), Long.class.getName(),
165
166 "java.lang.Integer", "java.lang.Integer",
167 "com.liferay.portal.kernel.util.OrderByComparator"
168 });
169 public static final FinderPath FINDER_PATH_COUNT_BY_G_U_F = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
170 DLFileEntryModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
171 "countByG_U_F",
172 new String[] {
173 Long.class.getName(), Long.class.getName(), Long.class.getName()
174 });
175 public static final FinderPath FINDER_PATH_FETCH_BY_G_F_N = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
176 DLFileEntryModelImpl.FINDER_CACHE_ENABLED,
177 FINDER_CLASS_NAME_ENTITY, "fetchByG_F_N",
178 new String[] {
179 Long.class.getName(), Long.class.getName(),
180 String.class.getName()
181 });
182 public static final FinderPath FINDER_PATH_COUNT_BY_G_F_N = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
183 DLFileEntryModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
184 "countByG_F_N",
185 new String[] {
186 Long.class.getName(), Long.class.getName(),
187 String.class.getName()
188 });
189 public static final FinderPath FINDER_PATH_FETCH_BY_G_F_T = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
190 DLFileEntryModelImpl.FINDER_CACHE_ENABLED,
191 FINDER_CLASS_NAME_ENTITY, "fetchByG_F_T",
192 new String[] {
193 Long.class.getName(), Long.class.getName(),
194 String.class.getName()
195 });
196 public static final FinderPath FINDER_PATH_COUNT_BY_G_F_T = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
197 DLFileEntryModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
198 "countByG_F_T",
199 new String[] {
200 Long.class.getName(), Long.class.getName(),
201 String.class.getName()
202 });
203 public static final FinderPath FINDER_PATH_FIND_ALL = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
204 DLFileEntryModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
205 "findAll", new String[0]);
206 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
207 DLFileEntryModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
208 "countAll", new String[0]);
209
210
215 public void cacheResult(DLFileEntry dlFileEntry) {
216 EntityCacheUtil.putResult(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
217 DLFileEntryImpl.class, dlFileEntry.getPrimaryKey(), dlFileEntry);
218
219 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
220 new Object[] {
221 dlFileEntry.getUuid(), new Long(dlFileEntry.getGroupId())
222 }, dlFileEntry);
223
224 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_F_N,
225 new Object[] {
226 new Long(dlFileEntry.getGroupId()),
227 new Long(dlFileEntry.getFolderId()),
228
229 dlFileEntry.getName()
230 }, dlFileEntry);
231
232 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_F_T,
233 new Object[] {
234 new Long(dlFileEntry.getGroupId()),
235 new Long(dlFileEntry.getFolderId()),
236
237 dlFileEntry.getTitle()
238 }, dlFileEntry);
239 }
240
241
246 public void cacheResult(List<DLFileEntry> dlFileEntries) {
247 for (DLFileEntry dlFileEntry : dlFileEntries) {
248 if (EntityCacheUtil.getResult(
249 DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
250 DLFileEntryImpl.class, dlFileEntry.getPrimaryKey(), this) == null) {
251 cacheResult(dlFileEntry);
252 }
253 }
254 }
255
256
263 public void clearCache() {
264 CacheRegistryUtil.clear(DLFileEntryImpl.class.getName());
265 EntityCacheUtil.clearCache(DLFileEntryImpl.class.getName());
266 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
267 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
268 }
269
270
277 public void clearCache(DLFileEntry dlFileEntry) {
278 EntityCacheUtil.removeResult(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
279 DLFileEntryImpl.class, dlFileEntry.getPrimaryKey());
280
281 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
282 new Object[] {
283 dlFileEntry.getUuid(), new Long(dlFileEntry.getGroupId())
284 });
285
286 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_F_N,
287 new Object[] {
288 new Long(dlFileEntry.getGroupId()),
289 new Long(dlFileEntry.getFolderId()),
290
291 dlFileEntry.getName()
292 });
293
294 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_F_T,
295 new Object[] {
296 new Long(dlFileEntry.getGroupId()),
297 new Long(dlFileEntry.getFolderId()),
298
299 dlFileEntry.getTitle()
300 });
301 }
302
303
309 public DLFileEntry create(long fileEntryId) {
310 DLFileEntry dlFileEntry = new DLFileEntryImpl();
311
312 dlFileEntry.setNew(true);
313 dlFileEntry.setPrimaryKey(fileEntryId);
314
315 String uuid = PortalUUIDUtil.generate();
316
317 dlFileEntry.setUuid(uuid);
318
319 return dlFileEntry;
320 }
321
322
330 public DLFileEntry remove(Serializable primaryKey)
331 throws NoSuchModelException, SystemException {
332 return remove(((Long)primaryKey).longValue());
333 }
334
335
343 public DLFileEntry remove(long fileEntryId)
344 throws NoSuchFileEntryException, SystemException {
345 Session session = null;
346
347 try {
348 session = openSession();
349
350 DLFileEntry dlFileEntry = (DLFileEntry)session.get(DLFileEntryImpl.class,
351 new Long(fileEntryId));
352
353 if (dlFileEntry == null) {
354 if (_log.isWarnEnabled()) {
355 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + fileEntryId);
356 }
357
358 throw new NoSuchFileEntryException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
359 fileEntryId);
360 }
361
362 return remove(dlFileEntry);
363 }
364 catch (NoSuchFileEntryException nsee) {
365 throw nsee;
366 }
367 catch (Exception e) {
368 throw processException(e);
369 }
370 finally {
371 closeSession(session);
372 }
373 }
374
375 protected DLFileEntry removeImpl(DLFileEntry dlFileEntry)
376 throws SystemException {
377 dlFileEntry = toUnwrappedModel(dlFileEntry);
378
379 Session session = null;
380
381 try {
382 session = openSession();
383
384 if (dlFileEntry.isCachedModel() || BatchSessionUtil.isEnabled()) {
385 Object staleObject = session.get(DLFileEntryImpl.class,
386 dlFileEntry.getPrimaryKeyObj());
387
388 if (staleObject != null) {
389 session.evict(staleObject);
390 }
391 }
392
393 session.delete(dlFileEntry);
394
395 session.flush();
396 }
397 catch (Exception e) {
398 throw processException(e);
399 }
400 finally {
401 closeSession(session);
402 }
403
404 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
405
406 DLFileEntryModelImpl dlFileEntryModelImpl = (DLFileEntryModelImpl)dlFileEntry;
407
408 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
409 new Object[] {
410 dlFileEntryModelImpl.getOriginalUuid(),
411 new Long(dlFileEntryModelImpl.getOriginalGroupId())
412 });
413
414 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_F_N,
415 new Object[] {
416 new Long(dlFileEntryModelImpl.getOriginalGroupId()),
417 new Long(dlFileEntryModelImpl.getOriginalFolderId()),
418
419 dlFileEntryModelImpl.getOriginalName()
420 });
421
422 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_F_T,
423 new Object[] {
424 new Long(dlFileEntryModelImpl.getOriginalGroupId()),
425 new Long(dlFileEntryModelImpl.getOriginalFolderId()),
426
427 dlFileEntryModelImpl.getOriginalTitle()
428 });
429
430 EntityCacheUtil.removeResult(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
431 DLFileEntryImpl.class, dlFileEntry.getPrimaryKey());
432
433 return dlFileEntry;
434 }
435
436 public DLFileEntry updateImpl(
437 com.liferay.portlet.documentlibrary.model.DLFileEntry dlFileEntry,
438 boolean merge) throws SystemException {
439 dlFileEntry = toUnwrappedModel(dlFileEntry);
440
441 boolean isNew = dlFileEntry.isNew();
442
443 DLFileEntryModelImpl dlFileEntryModelImpl = (DLFileEntryModelImpl)dlFileEntry;
444
445 if (Validator.isNull(dlFileEntry.getUuid())) {
446 String uuid = PortalUUIDUtil.generate();
447
448 dlFileEntry.setUuid(uuid);
449 }
450
451 Session session = null;
452
453 try {
454 session = openSession();
455
456 BatchSessionUtil.update(session, dlFileEntry, merge);
457
458 dlFileEntry.setNew(false);
459 }
460 catch (Exception e) {
461 throw processException(e);
462 }
463 finally {
464 closeSession(session);
465 }
466
467 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
468
469 EntityCacheUtil.putResult(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
470 DLFileEntryImpl.class, dlFileEntry.getPrimaryKey(), dlFileEntry);
471
472 if (!isNew &&
473 (!Validator.equals(dlFileEntry.getUuid(),
474 dlFileEntryModelImpl.getOriginalUuid()) ||
475 (dlFileEntry.getGroupId() != dlFileEntryModelImpl.getOriginalGroupId()))) {
476 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
477 new Object[] {
478 dlFileEntryModelImpl.getOriginalUuid(),
479 new Long(dlFileEntryModelImpl.getOriginalGroupId())
480 });
481 }
482
483 if (isNew ||
484 (!Validator.equals(dlFileEntry.getUuid(),
485 dlFileEntryModelImpl.getOriginalUuid()) ||
486 (dlFileEntry.getGroupId() != dlFileEntryModelImpl.getOriginalGroupId()))) {
487 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
488 new Object[] {
489 dlFileEntry.getUuid(), new Long(dlFileEntry.getGroupId())
490 }, dlFileEntry);
491 }
492
493 if (!isNew &&
494 ((dlFileEntry.getGroupId() != dlFileEntryModelImpl.getOriginalGroupId()) ||
495 (dlFileEntry.getFolderId() != dlFileEntryModelImpl.getOriginalFolderId()) ||
496 !Validator.equals(dlFileEntry.getName(),
497 dlFileEntryModelImpl.getOriginalName()))) {
498 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_F_N,
499 new Object[] {
500 new Long(dlFileEntryModelImpl.getOriginalGroupId()),
501 new Long(dlFileEntryModelImpl.getOriginalFolderId()),
502
503 dlFileEntryModelImpl.getOriginalName()
504 });
505 }
506
507 if (isNew ||
508 ((dlFileEntry.getGroupId() != dlFileEntryModelImpl.getOriginalGroupId()) ||
509 (dlFileEntry.getFolderId() != dlFileEntryModelImpl.getOriginalFolderId()) ||
510 !Validator.equals(dlFileEntry.getName(),
511 dlFileEntryModelImpl.getOriginalName()))) {
512 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_F_N,
513 new Object[] {
514 new Long(dlFileEntry.getGroupId()),
515 new Long(dlFileEntry.getFolderId()),
516
517 dlFileEntry.getName()
518 }, dlFileEntry);
519 }
520
521 if (!isNew &&
522 ((dlFileEntry.getGroupId() != dlFileEntryModelImpl.getOriginalGroupId()) ||
523 (dlFileEntry.getFolderId() != dlFileEntryModelImpl.getOriginalFolderId()) ||
524 !Validator.equals(dlFileEntry.getTitle(),
525 dlFileEntryModelImpl.getOriginalTitle()))) {
526 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_F_T,
527 new Object[] {
528 new Long(dlFileEntryModelImpl.getOriginalGroupId()),
529 new Long(dlFileEntryModelImpl.getOriginalFolderId()),
530
531 dlFileEntryModelImpl.getOriginalTitle()
532 });
533 }
534
535 if (isNew ||
536 ((dlFileEntry.getGroupId() != dlFileEntryModelImpl.getOriginalGroupId()) ||
537 (dlFileEntry.getFolderId() != dlFileEntryModelImpl.getOriginalFolderId()) ||
538 !Validator.equals(dlFileEntry.getTitle(),
539 dlFileEntryModelImpl.getOriginalTitle()))) {
540 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_F_T,
541 new Object[] {
542 new Long(dlFileEntry.getGroupId()),
543 new Long(dlFileEntry.getFolderId()),
544
545 dlFileEntry.getTitle()
546 }, dlFileEntry);
547 }
548
549 return dlFileEntry;
550 }
551
552 protected DLFileEntry toUnwrappedModel(DLFileEntry dlFileEntry) {
553 if (dlFileEntry instanceof DLFileEntryImpl) {
554 return dlFileEntry;
555 }
556
557 DLFileEntryImpl dlFileEntryImpl = new DLFileEntryImpl();
558
559 dlFileEntryImpl.setNew(dlFileEntry.isNew());
560 dlFileEntryImpl.setPrimaryKey(dlFileEntry.getPrimaryKey());
561
562 dlFileEntryImpl.setUuid(dlFileEntry.getUuid());
563 dlFileEntryImpl.setFileEntryId(dlFileEntry.getFileEntryId());
564 dlFileEntryImpl.setGroupId(dlFileEntry.getGroupId());
565 dlFileEntryImpl.setCompanyId(dlFileEntry.getCompanyId());
566 dlFileEntryImpl.setUserId(dlFileEntry.getUserId());
567 dlFileEntryImpl.setUserName(dlFileEntry.getUserName());
568 dlFileEntryImpl.setVersionUserId(dlFileEntry.getVersionUserId());
569 dlFileEntryImpl.setVersionUserName(dlFileEntry.getVersionUserName());
570 dlFileEntryImpl.setCreateDate(dlFileEntry.getCreateDate());
571 dlFileEntryImpl.setModifiedDate(dlFileEntry.getModifiedDate());
572 dlFileEntryImpl.setFolderId(dlFileEntry.getFolderId());
573 dlFileEntryImpl.setName(dlFileEntry.getName());
574 dlFileEntryImpl.setExtension(dlFileEntry.getExtension());
575 dlFileEntryImpl.setTitle(dlFileEntry.getTitle());
576 dlFileEntryImpl.setDescription(dlFileEntry.getDescription());
577 dlFileEntryImpl.setExtraSettings(dlFileEntry.getExtraSettings());
578 dlFileEntryImpl.setVersion(dlFileEntry.getVersion());
579 dlFileEntryImpl.setSize(dlFileEntry.getSize());
580 dlFileEntryImpl.setReadCount(dlFileEntry.getReadCount());
581
582 return dlFileEntryImpl;
583 }
584
585
593 public DLFileEntry findByPrimaryKey(Serializable primaryKey)
594 throws NoSuchModelException, SystemException {
595 return findByPrimaryKey(((Long)primaryKey).longValue());
596 }
597
598
606 public DLFileEntry findByPrimaryKey(long fileEntryId)
607 throws NoSuchFileEntryException, SystemException {
608 DLFileEntry dlFileEntry = fetchByPrimaryKey(fileEntryId);
609
610 if (dlFileEntry == null) {
611 if (_log.isWarnEnabled()) {
612 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + fileEntryId);
613 }
614
615 throw new NoSuchFileEntryException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
616 fileEntryId);
617 }
618
619 return dlFileEntry;
620 }
621
622
629 public DLFileEntry fetchByPrimaryKey(Serializable primaryKey)
630 throws SystemException {
631 return fetchByPrimaryKey(((Long)primaryKey).longValue());
632 }
633
634
641 public DLFileEntry fetchByPrimaryKey(long fileEntryId)
642 throws SystemException {
643 DLFileEntry dlFileEntry = (DLFileEntry)EntityCacheUtil.getResult(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
644 DLFileEntryImpl.class, fileEntryId, this);
645
646 if (dlFileEntry == null) {
647 Session session = null;
648
649 try {
650 session = openSession();
651
652 dlFileEntry = (DLFileEntry)session.get(DLFileEntryImpl.class,
653 new Long(fileEntryId));
654 }
655 catch (Exception e) {
656 throw processException(e);
657 }
658 finally {
659 if (dlFileEntry != null) {
660 cacheResult(dlFileEntry);
661 }
662
663 closeSession(session);
664 }
665 }
666
667 return dlFileEntry;
668 }
669
670
677 public List<DLFileEntry> findByUuid(String uuid) throws SystemException {
678 return findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
679 }
680
681
694 public List<DLFileEntry> findByUuid(String uuid, int start, int end)
695 throws SystemException {
696 return findByUuid(uuid, start, end, null);
697 }
698
699
713 public List<DLFileEntry> findByUuid(String uuid, int start, int end,
714 OrderByComparator orderByComparator) throws SystemException {
715 Object[] finderArgs = new Object[] {
716 uuid,
717
718 String.valueOf(start), String.valueOf(end),
719 String.valueOf(orderByComparator)
720 };
721
722 List<DLFileEntry> list = (List<DLFileEntry>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_UUID,
723 finderArgs, this);
724
725 if (list == null) {
726 Session session = null;
727
728 try {
729 session = openSession();
730
731 StringBundler query = null;
732
733 if (orderByComparator != null) {
734 query = new StringBundler(3 +
735 (orderByComparator.getOrderByFields().length * 3));
736 }
737 else {
738 query = new StringBundler(3);
739 }
740
741 query.append(_SQL_SELECT_DLFILEENTRY_WHERE);
742
743 if (uuid == null) {
744 query.append(_FINDER_COLUMN_UUID_UUID_1);
745 }
746 else {
747 if (uuid.equals(StringPool.BLANK)) {
748 query.append(_FINDER_COLUMN_UUID_UUID_3);
749 }
750 else {
751 query.append(_FINDER_COLUMN_UUID_UUID_2);
752 }
753 }
754
755 if (orderByComparator != null) {
756 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
757 orderByComparator);
758 }
759
760 else {
761 query.append(DLFileEntryModelImpl.ORDER_BY_JPQL);
762 }
763
764 String sql = query.toString();
765
766 Query q = session.createQuery(sql);
767
768 QueryPos qPos = QueryPos.getInstance(q);
769
770 if (uuid != null) {
771 qPos.add(uuid);
772 }
773
774 list = (List<DLFileEntry>)QueryUtil.list(q, getDialect(),
775 start, end);
776 }
777 catch (Exception e) {
778 throw processException(e);
779 }
780 finally {
781 if (list == null) {
782 list = new ArrayList<DLFileEntry>();
783 }
784
785 cacheResult(list);
786
787 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_UUID, finderArgs,
788 list);
789
790 closeSession(session);
791 }
792 }
793
794 return list;
795 }
796
797
810 public DLFileEntry findByUuid_First(String uuid,
811 OrderByComparator orderByComparator)
812 throws NoSuchFileEntryException, SystemException {
813 List<DLFileEntry> list = findByUuid(uuid, 0, 1, orderByComparator);
814
815 if (list.isEmpty()) {
816 StringBundler msg = new StringBundler(4);
817
818 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
819
820 msg.append("uuid=");
821 msg.append(uuid);
822
823 msg.append(StringPool.CLOSE_CURLY_BRACE);
824
825 throw new NoSuchFileEntryException(msg.toString());
826 }
827 else {
828 return list.get(0);
829 }
830 }
831
832
845 public DLFileEntry findByUuid_Last(String uuid,
846 OrderByComparator orderByComparator)
847 throws NoSuchFileEntryException, SystemException {
848 int count = countByUuid(uuid);
849
850 List<DLFileEntry> list = findByUuid(uuid, count - 1, count,
851 orderByComparator);
852
853 if (list.isEmpty()) {
854 StringBundler msg = new StringBundler(4);
855
856 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
857
858 msg.append("uuid=");
859 msg.append(uuid);
860
861 msg.append(StringPool.CLOSE_CURLY_BRACE);
862
863 throw new NoSuchFileEntryException(msg.toString());
864 }
865 else {
866 return list.get(0);
867 }
868 }
869
870
884 public DLFileEntry[] findByUuid_PrevAndNext(long fileEntryId, String uuid,
885 OrderByComparator orderByComparator)
886 throws NoSuchFileEntryException, SystemException {
887 DLFileEntry dlFileEntry = findByPrimaryKey(fileEntryId);
888
889 Session session = null;
890
891 try {
892 session = openSession();
893
894 DLFileEntry[] array = new DLFileEntryImpl[3];
895
896 array[0] = getByUuid_PrevAndNext(session, dlFileEntry, uuid,
897 orderByComparator, true);
898
899 array[1] = dlFileEntry;
900
901 array[2] = getByUuid_PrevAndNext(session, dlFileEntry, uuid,
902 orderByComparator, false);
903
904 return array;
905 }
906 catch (Exception e) {
907 throw processException(e);
908 }
909 finally {
910 closeSession(session);
911 }
912 }
913
914 protected DLFileEntry getByUuid_PrevAndNext(Session session,
915 DLFileEntry dlFileEntry, String uuid,
916 OrderByComparator orderByComparator, boolean previous) {
917 StringBundler query = null;
918
919 if (orderByComparator != null) {
920 query = new StringBundler(6 +
921 (orderByComparator.getOrderByFields().length * 6));
922 }
923 else {
924 query = new StringBundler(3);
925 }
926
927 query.append(_SQL_SELECT_DLFILEENTRY_WHERE);
928
929 if (uuid == null) {
930 query.append(_FINDER_COLUMN_UUID_UUID_1);
931 }
932 else {
933 if (uuid.equals(StringPool.BLANK)) {
934 query.append(_FINDER_COLUMN_UUID_UUID_3);
935 }
936 else {
937 query.append(_FINDER_COLUMN_UUID_UUID_2);
938 }
939 }
940
941 if (orderByComparator != null) {
942 String[] orderByFields = orderByComparator.getOrderByFields();
943
944 if (orderByFields.length > 0) {
945 query.append(WHERE_AND);
946 }
947
948 for (int i = 0; i < orderByFields.length; i++) {
949 query.append(_ORDER_BY_ENTITY_ALIAS);
950 query.append(orderByFields[i]);
951
952 if ((i + 1) < orderByFields.length) {
953 if (orderByComparator.isAscending() ^ previous) {
954 query.append(WHERE_GREATER_THAN_HAS_NEXT);
955 }
956 else {
957 query.append(WHERE_LESSER_THAN_HAS_NEXT);
958 }
959 }
960 else {
961 if (orderByComparator.isAscending() ^ previous) {
962 query.append(WHERE_GREATER_THAN);
963 }
964 else {
965 query.append(WHERE_LESSER_THAN);
966 }
967 }
968 }
969
970 query.append(ORDER_BY_CLAUSE);
971
972 for (int i = 0; i < orderByFields.length; i++) {
973 query.append(_ORDER_BY_ENTITY_ALIAS);
974 query.append(orderByFields[i]);
975
976 if ((i + 1) < orderByFields.length) {
977 if (orderByComparator.isAscending() ^ previous) {
978 query.append(ORDER_BY_ASC_HAS_NEXT);
979 }
980 else {
981 query.append(ORDER_BY_DESC_HAS_NEXT);
982 }
983 }
984 else {
985 if (orderByComparator.isAscending() ^ previous) {
986 query.append(ORDER_BY_ASC);
987 }
988 else {
989 query.append(ORDER_BY_DESC);
990 }
991 }
992 }
993 }
994
995 else {
996 query.append(DLFileEntryModelImpl.ORDER_BY_JPQL);
997 }
998
999 String sql = query.toString();
1000
1001 Query q = session.createQuery(sql);
1002
1003 q.setFirstResult(0);
1004 q.setMaxResults(2);
1005
1006 QueryPos qPos = QueryPos.getInstance(q);
1007
1008 if (uuid != null) {
1009 qPos.add(uuid);
1010 }
1011
1012 if (orderByComparator != null) {
1013 Object[] values = orderByComparator.getOrderByValues(dlFileEntry);
1014
1015 for (Object value : values) {
1016 qPos.add(value);
1017 }
1018 }
1019
1020 List<DLFileEntry> list = q.list();
1021
1022 if (list.size() == 2) {
1023 return list.get(1);
1024 }
1025 else {
1026 return null;
1027 }
1028 }
1029
1030
1039 public DLFileEntry findByUUID_G(String uuid, long groupId)
1040 throws NoSuchFileEntryException, SystemException {
1041 DLFileEntry dlFileEntry = fetchByUUID_G(uuid, groupId);
1042
1043 if (dlFileEntry == null) {
1044 StringBundler msg = new StringBundler(6);
1045
1046 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1047
1048 msg.append("uuid=");
1049 msg.append(uuid);
1050
1051 msg.append(", groupId=");
1052 msg.append(groupId);
1053
1054 msg.append(StringPool.CLOSE_CURLY_BRACE);
1055
1056 if (_log.isWarnEnabled()) {
1057 _log.warn(msg.toString());
1058 }
1059
1060 throw new NoSuchFileEntryException(msg.toString());
1061 }
1062
1063 return dlFileEntry;
1064 }
1065
1066
1074 public DLFileEntry fetchByUUID_G(String uuid, long groupId)
1075 throws SystemException {
1076 return fetchByUUID_G(uuid, groupId, true);
1077 }
1078
1079
1087 public DLFileEntry fetchByUUID_G(String uuid, long groupId,
1088 boolean retrieveFromCache) throws SystemException {
1089 Object[] finderArgs = new Object[] { uuid, groupId };
1090
1091 Object result = null;
1092
1093 if (retrieveFromCache) {
1094 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_UUID_G,
1095 finderArgs, this);
1096 }
1097
1098 if (result == null) {
1099 Session session = null;
1100
1101 try {
1102 session = openSession();
1103
1104 StringBundler query = new StringBundler(4);
1105
1106 query.append(_SQL_SELECT_DLFILEENTRY_WHERE);
1107
1108 if (uuid == null) {
1109 query.append(_FINDER_COLUMN_UUID_G_UUID_1);
1110 }
1111 else {
1112 if (uuid.equals(StringPool.BLANK)) {
1113 query.append(_FINDER_COLUMN_UUID_G_UUID_3);
1114 }
1115 else {
1116 query.append(_FINDER_COLUMN_UUID_G_UUID_2);
1117 }
1118 }
1119
1120 query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
1121
1122 query.append(DLFileEntryModelImpl.ORDER_BY_JPQL);
1123
1124 String sql = query.toString();
1125
1126 Query q = session.createQuery(sql);
1127
1128 QueryPos qPos = QueryPos.getInstance(q);
1129
1130 if (uuid != null) {
1131 qPos.add(uuid);
1132 }
1133
1134 qPos.add(groupId);
1135
1136 List<DLFileEntry> list = q.list();
1137
1138 result = list;
1139
1140 DLFileEntry dlFileEntry = null;
1141
1142 if (list.isEmpty()) {
1143 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
1144 finderArgs, list);
1145 }
1146 else {
1147 dlFileEntry = list.get(0);
1148
1149 cacheResult(dlFileEntry);
1150
1151 if ((dlFileEntry.getUuid() == null) ||
1152 !dlFileEntry.getUuid().equals(uuid) ||
1153 (dlFileEntry.getGroupId() != groupId)) {
1154 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
1155 finderArgs, dlFileEntry);
1156 }
1157 }
1158
1159 return dlFileEntry;
1160 }
1161 catch (Exception e) {
1162 throw processException(e);
1163 }
1164 finally {
1165 if (result == null) {
1166 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
1167 finderArgs, new ArrayList<DLFileEntry>());
1168 }
1169
1170 closeSession(session);
1171 }
1172 }
1173 else {
1174 if (result instanceof List<?>) {
1175 return null;
1176 }
1177 else {
1178 return (DLFileEntry)result;
1179 }
1180 }
1181 }
1182
1183
1190 public List<DLFileEntry> findByGroupId(long groupId)
1191 throws SystemException {
1192 return findByGroupId(groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1193 }
1194
1195
1208 public List<DLFileEntry> findByGroupId(long groupId, int start, int end)
1209 throws SystemException {
1210 return findByGroupId(groupId, start, end, null);
1211 }
1212
1213
1227 public List<DLFileEntry> findByGroupId(long groupId, int start, int end,
1228 OrderByComparator orderByComparator) throws SystemException {
1229 Object[] finderArgs = new Object[] {
1230 groupId,
1231
1232 String.valueOf(start), String.valueOf(end),
1233 String.valueOf(orderByComparator)
1234 };
1235
1236 List<DLFileEntry> list = (List<DLFileEntry>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_GROUPID,
1237 finderArgs, this);
1238
1239 if (list == null) {
1240 Session session = null;
1241
1242 try {
1243 session = openSession();
1244
1245 StringBundler query = null;
1246
1247 if (orderByComparator != null) {
1248 query = new StringBundler(3 +
1249 (orderByComparator.getOrderByFields().length * 3));
1250 }
1251 else {
1252 query = new StringBundler(3);
1253 }
1254
1255 query.append(_SQL_SELECT_DLFILEENTRY_WHERE);
1256
1257 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1258
1259 if (orderByComparator != null) {
1260 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1261 orderByComparator);
1262 }
1263
1264 else {
1265 query.append(DLFileEntryModelImpl.ORDER_BY_JPQL);
1266 }
1267
1268 String sql = query.toString();
1269
1270 Query q = session.createQuery(sql);
1271
1272 QueryPos qPos = QueryPos.getInstance(q);
1273
1274 qPos.add(groupId);
1275
1276 list = (List<DLFileEntry>)QueryUtil.list(q, getDialect(),
1277 start, end);
1278 }
1279 catch (Exception e) {
1280 throw processException(e);
1281 }
1282 finally {
1283 if (list == null) {
1284 list = new ArrayList<DLFileEntry>();
1285 }
1286
1287 cacheResult(list);
1288
1289 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_GROUPID,
1290 finderArgs, list);
1291
1292 closeSession(session);
1293 }
1294 }
1295
1296 return list;
1297 }
1298
1299
1312 public DLFileEntry findByGroupId_First(long groupId,
1313 OrderByComparator orderByComparator)
1314 throws NoSuchFileEntryException, SystemException {
1315 List<DLFileEntry> list = findByGroupId(groupId, 0, 1, orderByComparator);
1316
1317 if (list.isEmpty()) {
1318 StringBundler msg = new StringBundler(4);
1319
1320 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1321
1322 msg.append("groupId=");
1323 msg.append(groupId);
1324
1325 msg.append(StringPool.CLOSE_CURLY_BRACE);
1326
1327 throw new NoSuchFileEntryException(msg.toString());
1328 }
1329 else {
1330 return list.get(0);
1331 }
1332 }
1333
1334
1347 public DLFileEntry findByGroupId_Last(long groupId,
1348 OrderByComparator orderByComparator)
1349 throws NoSuchFileEntryException, SystemException {
1350 int count = countByGroupId(groupId);
1351
1352 List<DLFileEntry> list = findByGroupId(groupId, count - 1, count,
1353 orderByComparator);
1354
1355 if (list.isEmpty()) {
1356 StringBundler msg = new StringBundler(4);
1357
1358 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1359
1360 msg.append("groupId=");
1361 msg.append(groupId);
1362
1363 msg.append(StringPool.CLOSE_CURLY_BRACE);
1364
1365 throw new NoSuchFileEntryException(msg.toString());
1366 }
1367 else {
1368 return list.get(0);
1369 }
1370 }
1371
1372
1386 public DLFileEntry[] findByGroupId_PrevAndNext(long fileEntryId,
1387 long groupId, OrderByComparator orderByComparator)
1388 throws NoSuchFileEntryException, SystemException {
1389 DLFileEntry dlFileEntry = findByPrimaryKey(fileEntryId);
1390
1391 Session session = null;
1392
1393 try {
1394 session = openSession();
1395
1396 DLFileEntry[] array = new DLFileEntryImpl[3];
1397
1398 array[0] = getByGroupId_PrevAndNext(session, dlFileEntry, groupId,
1399 orderByComparator, true);
1400
1401 array[1] = dlFileEntry;
1402
1403 array[2] = getByGroupId_PrevAndNext(session, dlFileEntry, groupId,
1404 orderByComparator, false);
1405
1406 return array;
1407 }
1408 catch (Exception e) {
1409 throw processException(e);
1410 }
1411 finally {
1412 closeSession(session);
1413 }
1414 }
1415
1416 protected DLFileEntry getByGroupId_PrevAndNext(Session session,
1417 DLFileEntry dlFileEntry, long groupId,
1418 OrderByComparator orderByComparator, boolean previous) {
1419 StringBundler query = null;
1420
1421 if (orderByComparator != null) {
1422 query = new StringBundler(6 +
1423 (orderByComparator.getOrderByFields().length * 6));
1424 }
1425 else {
1426 query = new StringBundler(3);
1427 }
1428
1429 query.append(_SQL_SELECT_DLFILEENTRY_WHERE);
1430
1431 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1432
1433 if (orderByComparator != null) {
1434 String[] orderByFields = orderByComparator.getOrderByFields();
1435
1436 if (orderByFields.length > 0) {
1437 query.append(WHERE_AND);
1438 }
1439
1440 for (int i = 0; i < orderByFields.length; i++) {
1441 query.append(_ORDER_BY_ENTITY_ALIAS);
1442 query.append(orderByFields[i]);
1443
1444 if ((i + 1) < orderByFields.length) {
1445 if (orderByComparator.isAscending() ^ previous) {
1446 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1447 }
1448 else {
1449 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1450 }
1451 }
1452 else {
1453 if (orderByComparator.isAscending() ^ previous) {
1454 query.append(WHERE_GREATER_THAN);
1455 }
1456 else {
1457 query.append(WHERE_LESSER_THAN);
1458 }
1459 }
1460 }
1461
1462 query.append(ORDER_BY_CLAUSE);
1463
1464 for (int i = 0; i < orderByFields.length; i++) {
1465 query.append(_ORDER_BY_ENTITY_ALIAS);
1466 query.append(orderByFields[i]);
1467
1468 if ((i + 1) < orderByFields.length) {
1469 if (orderByComparator.isAscending() ^ previous) {
1470 query.append(ORDER_BY_ASC_HAS_NEXT);
1471 }
1472 else {
1473 query.append(ORDER_BY_DESC_HAS_NEXT);
1474 }
1475 }
1476 else {
1477 if (orderByComparator.isAscending() ^ previous) {
1478 query.append(ORDER_BY_ASC);
1479 }
1480 else {
1481 query.append(ORDER_BY_DESC);
1482 }
1483 }
1484 }
1485 }
1486
1487 else {
1488 query.append(DLFileEntryModelImpl.ORDER_BY_JPQL);
1489 }
1490
1491 String sql = query.toString();
1492
1493 Query q = session.createQuery(sql);
1494
1495 q.setFirstResult(0);
1496 q.setMaxResults(2);
1497
1498 QueryPos qPos = QueryPos.getInstance(q);
1499
1500 qPos.add(groupId);
1501
1502 if (orderByComparator != null) {
1503 Object[] values = orderByComparator.getOrderByValues(dlFileEntry);
1504
1505 for (Object value : values) {
1506 qPos.add(value);
1507 }
1508 }
1509
1510 List<DLFileEntry> list = q.list();
1511
1512 if (list.size() == 2) {
1513 return list.get(1);
1514 }
1515 else {
1516 return null;
1517 }
1518 }
1519
1520
1527 public List<DLFileEntry> filterFindByGroupId(long groupId)
1528 throws SystemException {
1529 return filterFindByGroupId(groupId, QueryUtil.ALL_POS,
1530 QueryUtil.ALL_POS, null);
1531 }
1532
1533
1546 public List<DLFileEntry> filterFindByGroupId(long groupId, int start,
1547 int end) throws SystemException {
1548 return filterFindByGroupId(groupId, start, end, null);
1549 }
1550
1551
1565 public List<DLFileEntry> filterFindByGroupId(long groupId, int start,
1566 int end, OrderByComparator orderByComparator) throws SystemException {
1567 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
1568 return findByGroupId(groupId, start, end, orderByComparator);
1569 }
1570
1571 Session session = null;
1572
1573 try {
1574 session = openSession();
1575
1576 StringBundler query = null;
1577
1578 if (orderByComparator != null) {
1579 query = new StringBundler(3 +
1580 (orderByComparator.getOrderByFields().length * 3));
1581 }
1582 else {
1583 query = new StringBundler(3);
1584 }
1585
1586 query.append(_FILTER_SQL_SELECT_DLFILEENTRY_WHERE);
1587
1588 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1589
1590 if (orderByComparator != null) {
1591 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1592 orderByComparator);
1593 }
1594
1595 else {
1596 query.append(DLFileEntryModelImpl.ORDER_BY_JPQL);
1597 }
1598
1599 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1600 DLFileEntry.class.getName(), _FILTER_COLUMN_PK,
1601 _FILTER_COLUMN_USERID, groupId);
1602
1603 SQLQuery q = session.createSQLQuery(sql);
1604
1605 q.addEntity(_FILTER_ENTITY_ALIAS, DLFileEntryImpl.class);
1606
1607 QueryPos qPos = QueryPos.getInstance(q);
1608
1609 qPos.add(groupId);
1610
1611 return (List<DLFileEntry>)QueryUtil.list(q, getDialect(), start, end);
1612 }
1613 catch (Exception e) {
1614 throw processException(e);
1615 }
1616 finally {
1617 closeSession(session);
1618 }
1619 }
1620
1621
1628 public List<DLFileEntry> findByCompanyId(long companyId)
1629 throws SystemException {
1630 return findByCompanyId(companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
1631 null);
1632 }
1633
1634
1647 public List<DLFileEntry> findByCompanyId(long companyId, int start, int end)
1648 throws SystemException {
1649 return findByCompanyId(companyId, start, end, null);
1650 }
1651
1652
1666 public List<DLFileEntry> findByCompanyId(long companyId, int start,
1667 int end, OrderByComparator orderByComparator) throws SystemException {
1668 Object[] finderArgs = new Object[] {
1669 companyId,
1670
1671 String.valueOf(start), String.valueOf(end),
1672 String.valueOf(orderByComparator)
1673 };
1674
1675 List<DLFileEntry> list = (List<DLFileEntry>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_COMPANYID,
1676 finderArgs, this);
1677
1678 if (list == null) {
1679 Session session = null;
1680
1681 try {
1682 session = openSession();
1683
1684 StringBundler query = null;
1685
1686 if (orderByComparator != null) {
1687 query = new StringBundler(3 +
1688 (orderByComparator.getOrderByFields().length * 3));
1689 }
1690 else {
1691 query = new StringBundler(3);
1692 }
1693
1694 query.append(_SQL_SELECT_DLFILEENTRY_WHERE);
1695
1696 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
1697
1698 if (orderByComparator != null) {
1699 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1700 orderByComparator);
1701 }
1702
1703 else {
1704 query.append(DLFileEntryModelImpl.ORDER_BY_JPQL);
1705 }
1706
1707 String sql = query.toString();
1708
1709 Query q = session.createQuery(sql);
1710
1711 QueryPos qPos = QueryPos.getInstance(q);
1712
1713 qPos.add(companyId);
1714
1715 list = (List<DLFileEntry>)QueryUtil.list(q, getDialect(),
1716 start, end);
1717 }
1718 catch (Exception e) {
1719 throw processException(e);
1720 }
1721 finally {
1722 if (list == null) {
1723 list = new ArrayList<DLFileEntry>();
1724 }
1725
1726 cacheResult(list);
1727
1728 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_COMPANYID,
1729 finderArgs, list);
1730
1731 closeSession(session);
1732 }
1733 }
1734
1735 return list;
1736 }
1737
1738
1751 public DLFileEntry findByCompanyId_First(long companyId,
1752 OrderByComparator orderByComparator)
1753 throws NoSuchFileEntryException, SystemException {
1754 List<DLFileEntry> list = findByCompanyId(companyId, 0, 1,
1755 orderByComparator);
1756
1757 if (list.isEmpty()) {
1758 StringBundler msg = new StringBundler(4);
1759
1760 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1761
1762 msg.append("companyId=");
1763 msg.append(companyId);
1764
1765 msg.append(StringPool.CLOSE_CURLY_BRACE);
1766
1767 throw new NoSuchFileEntryException(msg.toString());
1768 }
1769 else {
1770 return list.get(0);
1771 }
1772 }
1773
1774
1787 public DLFileEntry findByCompanyId_Last(long companyId,
1788 OrderByComparator orderByComparator)
1789 throws NoSuchFileEntryException, SystemException {
1790 int count = countByCompanyId(companyId);
1791
1792 List<DLFileEntry> list = findByCompanyId(companyId, count - 1, count,
1793 orderByComparator);
1794
1795 if (list.isEmpty()) {
1796 StringBundler msg = new StringBundler(4);
1797
1798 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1799
1800 msg.append("companyId=");
1801 msg.append(companyId);
1802
1803 msg.append(StringPool.CLOSE_CURLY_BRACE);
1804
1805 throw new NoSuchFileEntryException(msg.toString());
1806 }
1807 else {
1808 return list.get(0);
1809 }
1810 }
1811
1812
1826 public DLFileEntry[] findByCompanyId_PrevAndNext(long fileEntryId,
1827 long companyId, OrderByComparator orderByComparator)
1828 throws NoSuchFileEntryException, SystemException {
1829 DLFileEntry dlFileEntry = findByPrimaryKey(fileEntryId);
1830
1831 Session session = null;
1832
1833 try {
1834 session = openSession();
1835
1836 DLFileEntry[] array = new DLFileEntryImpl[3];
1837
1838 array[0] = getByCompanyId_PrevAndNext(session, dlFileEntry,
1839 companyId, orderByComparator, true);
1840
1841 array[1] = dlFileEntry;
1842
1843 array[2] = getByCompanyId_PrevAndNext(session, dlFileEntry,
1844 companyId, orderByComparator, false);
1845
1846 return array;
1847 }
1848 catch (Exception e) {
1849 throw processException(e);
1850 }
1851 finally {
1852 closeSession(session);
1853 }
1854 }
1855
1856 protected DLFileEntry getByCompanyId_PrevAndNext(Session session,
1857 DLFileEntry dlFileEntry, long companyId,
1858 OrderByComparator orderByComparator, boolean previous) {
1859 StringBundler query = null;
1860
1861 if (orderByComparator != null) {
1862 query = new StringBundler(6 +
1863 (orderByComparator.getOrderByFields().length * 6));
1864 }
1865 else {
1866 query = new StringBundler(3);
1867 }
1868
1869 query.append(_SQL_SELECT_DLFILEENTRY_WHERE);
1870
1871 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
1872
1873 if (orderByComparator != null) {
1874 String[] orderByFields = orderByComparator.getOrderByFields();
1875
1876 if (orderByFields.length > 0) {
1877 query.append(WHERE_AND);
1878 }
1879
1880 for (int i = 0; i < orderByFields.length; i++) {
1881 query.append(_ORDER_BY_ENTITY_ALIAS);
1882 query.append(orderByFields[i]);
1883
1884 if ((i + 1) < orderByFields.length) {
1885 if (orderByComparator.isAscending() ^ previous) {
1886 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1887 }
1888 else {
1889 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1890 }
1891 }
1892 else {
1893 if (orderByComparator.isAscending() ^ previous) {
1894 query.append(WHERE_GREATER_THAN);
1895 }
1896 else {
1897 query.append(WHERE_LESSER_THAN);
1898 }
1899 }
1900 }
1901
1902 query.append(ORDER_BY_CLAUSE);
1903
1904 for (int i = 0; i < orderByFields.length; i++) {
1905 query.append(_ORDER_BY_ENTITY_ALIAS);
1906 query.append(orderByFields[i]);
1907
1908 if ((i + 1) < orderByFields.length) {
1909 if (orderByComparator.isAscending() ^ previous) {
1910 query.append(ORDER_BY_ASC_HAS_NEXT);
1911 }
1912 else {
1913 query.append(ORDER_BY_DESC_HAS_NEXT);
1914 }
1915 }
1916 else {
1917 if (orderByComparator.isAscending() ^ previous) {
1918 query.append(ORDER_BY_ASC);
1919 }
1920 else {
1921 query.append(ORDER_BY_DESC);
1922 }
1923 }
1924 }
1925 }
1926
1927 else {
1928 query.append(DLFileEntryModelImpl.ORDER_BY_JPQL);
1929 }
1930
1931 String sql = query.toString();
1932
1933 Query q = session.createQuery(sql);
1934
1935 q.setFirstResult(0);
1936 q.setMaxResults(2);
1937
1938 QueryPos qPos = QueryPos.getInstance(q);
1939
1940 qPos.add(companyId);
1941
1942 if (orderByComparator != null) {
1943 Object[] values = orderByComparator.getOrderByValues(dlFileEntry);
1944
1945 for (Object value : values) {
1946 qPos.add(value);
1947 }
1948 }
1949
1950 List<DLFileEntry> list = q.list();
1951
1952 if (list.size() == 2) {
1953 return list.get(1);
1954 }
1955 else {
1956 return null;
1957 }
1958 }
1959
1960
1968 public List<DLFileEntry> findByG_U(long groupId, long userId)
1969 throws SystemException {
1970 return findByG_U(groupId, userId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
1971 null);
1972 }
1973
1974
1988 public List<DLFileEntry> findByG_U(long groupId, long userId, int start,
1989 int end) throws SystemException {
1990 return findByG_U(groupId, userId, start, end, null);
1991 }
1992
1993
2008 public List<DLFileEntry> findByG_U(long groupId, long userId, int start,
2009 int end, OrderByComparator orderByComparator) throws SystemException {
2010 Object[] finderArgs = new Object[] {
2011 groupId, userId,
2012
2013 String.valueOf(start), String.valueOf(end),
2014 String.valueOf(orderByComparator)
2015 };
2016
2017 List<DLFileEntry> list = (List<DLFileEntry>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_G_U,
2018 finderArgs, this);
2019
2020 if (list == null) {
2021 Session session = null;
2022
2023 try {
2024 session = openSession();
2025
2026 StringBundler query = null;
2027
2028 if (orderByComparator != null) {
2029 query = new StringBundler(4 +
2030 (orderByComparator.getOrderByFields().length * 3));
2031 }
2032 else {
2033 query = new StringBundler(4);
2034 }
2035
2036 query.append(_SQL_SELECT_DLFILEENTRY_WHERE);
2037
2038 query.append(_FINDER_COLUMN_G_U_GROUPID_2);
2039
2040 query.append(_FINDER_COLUMN_G_U_USERID_2);
2041
2042 if (orderByComparator != null) {
2043 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2044 orderByComparator);
2045 }
2046
2047 else {
2048 query.append(DLFileEntryModelImpl.ORDER_BY_JPQL);
2049 }
2050
2051 String sql = query.toString();
2052
2053 Query q = session.createQuery(sql);
2054
2055 QueryPos qPos = QueryPos.getInstance(q);
2056
2057 qPos.add(groupId);
2058
2059 qPos.add(userId);
2060
2061 list = (List<DLFileEntry>)QueryUtil.list(q, getDialect(),
2062 start, end);
2063 }
2064 catch (Exception e) {
2065 throw processException(e);
2066 }
2067 finally {
2068 if (list == null) {
2069 list = new ArrayList<DLFileEntry>();
2070 }
2071
2072 cacheResult(list);
2073
2074 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_G_U, finderArgs,
2075 list);
2076
2077 closeSession(session);
2078 }
2079 }
2080
2081 return list;
2082 }
2083
2084
2098 public DLFileEntry findByG_U_First(long groupId, long userId,
2099 OrderByComparator orderByComparator)
2100 throws NoSuchFileEntryException, SystemException {
2101 List<DLFileEntry> list = findByG_U(groupId, userId, 0, 1,
2102 orderByComparator);
2103
2104 if (list.isEmpty()) {
2105 StringBundler msg = new StringBundler(6);
2106
2107 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2108
2109 msg.append("groupId=");
2110 msg.append(groupId);
2111
2112 msg.append(", userId=");
2113 msg.append(userId);
2114
2115 msg.append(StringPool.CLOSE_CURLY_BRACE);
2116
2117 throw new NoSuchFileEntryException(msg.toString());
2118 }
2119 else {
2120 return list.get(0);
2121 }
2122 }
2123
2124
2138 public DLFileEntry findByG_U_Last(long groupId, long userId,
2139 OrderByComparator orderByComparator)
2140 throws NoSuchFileEntryException, SystemException {
2141 int count = countByG_U(groupId, userId);
2142
2143 List<DLFileEntry> list = findByG_U(groupId, userId, count - 1, count,
2144 orderByComparator);
2145
2146 if (list.isEmpty()) {
2147 StringBundler msg = new StringBundler(6);
2148
2149 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2150
2151 msg.append("groupId=");
2152 msg.append(groupId);
2153
2154 msg.append(", userId=");
2155 msg.append(userId);
2156
2157 msg.append(StringPool.CLOSE_CURLY_BRACE);
2158
2159 throw new NoSuchFileEntryException(msg.toString());
2160 }
2161 else {
2162 return list.get(0);
2163 }
2164 }
2165
2166
2181 public DLFileEntry[] findByG_U_PrevAndNext(long fileEntryId, long groupId,
2182 long userId, OrderByComparator orderByComparator)
2183 throws NoSuchFileEntryException, SystemException {
2184 DLFileEntry dlFileEntry = findByPrimaryKey(fileEntryId);
2185
2186 Session session = null;
2187
2188 try {
2189 session = openSession();
2190
2191 DLFileEntry[] array = new DLFileEntryImpl[3];
2192
2193 array[0] = getByG_U_PrevAndNext(session, dlFileEntry, groupId,
2194 userId, orderByComparator, true);
2195
2196 array[1] = dlFileEntry;
2197
2198 array[2] = getByG_U_PrevAndNext(session, dlFileEntry, groupId,
2199 userId, orderByComparator, false);
2200
2201 return array;
2202 }
2203 catch (Exception e) {
2204 throw processException(e);
2205 }
2206 finally {
2207 closeSession(session);
2208 }
2209 }
2210
2211 protected DLFileEntry getByG_U_PrevAndNext(Session session,
2212 DLFileEntry dlFileEntry, long groupId, long userId,
2213 OrderByComparator orderByComparator, boolean previous) {
2214 StringBundler query = null;
2215
2216 if (orderByComparator != null) {
2217 query = new StringBundler(6 +
2218 (orderByComparator.getOrderByFields().length * 6));
2219 }
2220 else {
2221 query = new StringBundler(3);
2222 }
2223
2224 query.append(_SQL_SELECT_DLFILEENTRY_WHERE);
2225
2226 query.append(_FINDER_COLUMN_G_U_GROUPID_2);
2227
2228 query.append(_FINDER_COLUMN_G_U_USERID_2);
2229
2230 if (orderByComparator != null) {
2231 String[] orderByFields = orderByComparator.getOrderByFields();
2232
2233 if (orderByFields.length > 0) {
2234 query.append(WHERE_AND);
2235 }
2236
2237 for (int i = 0; i < orderByFields.length; i++) {
2238 query.append(_ORDER_BY_ENTITY_ALIAS);
2239 query.append(orderByFields[i]);
2240
2241 if ((i + 1) < orderByFields.length) {
2242 if (orderByComparator.isAscending() ^ previous) {
2243 query.append(WHERE_GREATER_THAN_HAS_NEXT);
2244 }
2245 else {
2246 query.append(WHERE_LESSER_THAN_HAS_NEXT);
2247 }
2248 }
2249 else {
2250 if (orderByComparator.isAscending() ^ previous) {
2251 query.append(WHERE_GREATER_THAN);
2252 }
2253 else {
2254 query.append(WHERE_LESSER_THAN);
2255 }
2256 }
2257 }
2258
2259 query.append(ORDER_BY_CLAUSE);
2260
2261 for (int i = 0; i < orderByFields.length; i++) {
2262 query.append(_ORDER_BY_ENTITY_ALIAS);
2263 query.append(orderByFields[i]);
2264
2265 if ((i + 1) < orderByFields.length) {
2266 if (orderByComparator.isAscending() ^ previous) {
2267 query.append(ORDER_BY_ASC_HAS_NEXT);
2268 }
2269 else {
2270 query.append(ORDER_BY_DESC_HAS_NEXT);
2271 }
2272 }
2273 else {
2274 if (orderByComparator.isAscending() ^ previous) {
2275 query.append(ORDER_BY_ASC);
2276 }
2277 else {
2278 query.append(ORDER_BY_DESC);
2279 }
2280 }
2281 }
2282 }
2283
2284 else {
2285 query.append(DLFileEntryModelImpl.ORDER_BY_JPQL);
2286 }
2287
2288 String sql = query.toString();
2289
2290 Query q = session.createQuery(sql);
2291
2292 q.setFirstResult(0);
2293 q.setMaxResults(2);
2294
2295 QueryPos qPos = QueryPos.getInstance(q);
2296
2297 qPos.add(groupId);
2298
2299 qPos.add(userId);
2300
2301 if (orderByComparator != null) {
2302 Object[] values = orderByComparator.getOrderByValues(dlFileEntry);
2303
2304 for (Object value : values) {
2305 qPos.add(value);
2306 }
2307 }
2308
2309 List<DLFileEntry> list = q.list();
2310
2311 if (list.size() == 2) {
2312 return list.get(1);
2313 }
2314 else {
2315 return null;
2316 }
2317 }
2318
2319
2327 public List<DLFileEntry> filterFindByG_U(long groupId, long userId)
2328 throws SystemException {
2329 return filterFindByG_U(groupId, userId, QueryUtil.ALL_POS,
2330 QueryUtil.ALL_POS, null);
2331 }
2332
2333
2347 public List<DLFileEntry> filterFindByG_U(long groupId, long userId,
2348 int start, int end) throws SystemException {
2349 return filterFindByG_U(groupId, userId, start, end, null);
2350 }
2351
2352
2367 public List<DLFileEntry> filterFindByG_U(long groupId, long userId,
2368 int start, int end, OrderByComparator orderByComparator)
2369 throws SystemException {
2370 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2371 return findByG_U(groupId, userId, start, end, orderByComparator);
2372 }
2373
2374 Session session = null;
2375
2376 try {
2377 session = openSession();
2378
2379 StringBundler query = null;
2380
2381 if (orderByComparator != null) {
2382 query = new StringBundler(4 +
2383 (orderByComparator.getOrderByFields().length * 3));
2384 }
2385 else {
2386 query = new StringBundler(4);
2387 }
2388
2389 query.append(_FILTER_SQL_SELECT_DLFILEENTRY_WHERE);
2390
2391 query.append(_FINDER_COLUMN_G_U_GROUPID_2);
2392
2393 query.append(_FINDER_COLUMN_G_U_USERID_2);
2394
2395 if (orderByComparator != null) {
2396 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2397 orderByComparator);
2398 }
2399
2400 else {
2401 query.append(DLFileEntryModelImpl.ORDER_BY_JPQL);
2402 }
2403
2404 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2405 DLFileEntry.class.getName(), _FILTER_COLUMN_PK,
2406 _FILTER_COLUMN_USERID, groupId);
2407
2408 SQLQuery q = session.createSQLQuery(sql);
2409
2410 q.addEntity(_FILTER_ENTITY_ALIAS, DLFileEntryImpl.class);
2411
2412 QueryPos qPos = QueryPos.getInstance(q);
2413
2414 qPos.add(groupId);
2415
2416 qPos.add(userId);
2417
2418 return (List<DLFileEntry>)QueryUtil.list(q, getDialect(), start, end);
2419 }
2420 catch (Exception e) {
2421 throw processException(e);
2422 }
2423 finally {
2424 closeSession(session);
2425 }
2426 }
2427
2428
2436 public List<DLFileEntry> findByG_F(long groupId, long folderId)
2437 throws SystemException {
2438 return findByG_F(groupId, folderId, QueryUtil.ALL_POS,
2439 QueryUtil.ALL_POS, null);
2440 }
2441
2442
2456 public List<DLFileEntry> findByG_F(long groupId, long folderId, int start,
2457 int end) throws SystemException {
2458 return findByG_F(groupId, folderId, start, end, null);
2459 }
2460
2461
2476 public List<DLFileEntry> findByG_F(long groupId, long folderId, int start,
2477 int end, OrderByComparator orderByComparator) throws SystemException {
2478 Object[] finderArgs = new Object[] {
2479 groupId, folderId,
2480
2481 String.valueOf(start), String.valueOf(end),
2482 String.valueOf(orderByComparator)
2483 };
2484
2485 List<DLFileEntry> list = (List<DLFileEntry>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_G_F,
2486 finderArgs, this);
2487
2488 if (list == null) {
2489 Session session = null;
2490
2491 try {
2492 session = openSession();
2493
2494 StringBundler query = null;
2495
2496 if (orderByComparator != null) {
2497 query = new StringBundler(4 +
2498 (orderByComparator.getOrderByFields().length * 3));
2499 }
2500 else {
2501 query = new StringBundler(4);
2502 }
2503
2504 query.append(_SQL_SELECT_DLFILEENTRY_WHERE);
2505
2506 query.append(_FINDER_COLUMN_G_F_GROUPID_2);
2507
2508 query.append(_FINDER_COLUMN_G_F_FOLDERID_2);
2509
2510 if (orderByComparator != null) {
2511 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2512 orderByComparator);
2513 }
2514
2515 else {
2516 query.append(DLFileEntryModelImpl.ORDER_BY_JPQL);
2517 }
2518
2519 String sql = query.toString();
2520
2521 Query q = session.createQuery(sql);
2522
2523 QueryPos qPos = QueryPos.getInstance(q);
2524
2525 qPos.add(groupId);
2526
2527 qPos.add(folderId);
2528
2529 list = (List<DLFileEntry>)QueryUtil.list(q, getDialect(),
2530 start, end);
2531 }
2532 catch (Exception e) {
2533 throw processException(e);
2534 }
2535 finally {
2536 if (list == null) {
2537 list = new ArrayList<DLFileEntry>();
2538 }
2539
2540 cacheResult(list);
2541
2542 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_G_F, finderArgs,
2543 list);
2544
2545 closeSession(session);
2546 }
2547 }
2548
2549 return list;
2550 }
2551
2552
2566 public DLFileEntry findByG_F_First(long groupId, long folderId,
2567 OrderByComparator orderByComparator)
2568 throws NoSuchFileEntryException, SystemException {
2569 List<DLFileEntry> list = findByG_F(groupId, folderId, 0, 1,
2570 orderByComparator);
2571
2572 if (list.isEmpty()) {
2573 StringBundler msg = new StringBundler(6);
2574
2575 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2576
2577 msg.append("groupId=");
2578 msg.append(groupId);
2579
2580 msg.append(", folderId=");
2581 msg.append(folderId);
2582
2583 msg.append(StringPool.CLOSE_CURLY_BRACE);
2584
2585 throw new NoSuchFileEntryException(msg.toString());
2586 }
2587 else {
2588 return list.get(0);
2589 }
2590 }
2591
2592
2606 public DLFileEntry findByG_F_Last(long groupId, long folderId,
2607 OrderByComparator orderByComparator)
2608 throws NoSuchFileEntryException, SystemException {
2609 int count = countByG_F(groupId, folderId);
2610
2611 List<DLFileEntry> list = findByG_F(groupId, folderId, count - 1, count,
2612 orderByComparator);
2613
2614 if (list.isEmpty()) {
2615 StringBundler msg = new StringBundler(6);
2616
2617 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2618
2619 msg.append("groupId=");
2620 msg.append(groupId);
2621
2622 msg.append(", folderId=");
2623 msg.append(folderId);
2624
2625 msg.append(StringPool.CLOSE_CURLY_BRACE);
2626
2627 throw new NoSuchFileEntryException(msg.toString());
2628 }
2629 else {
2630 return list.get(0);
2631 }
2632 }
2633
2634
2649 public DLFileEntry[] findByG_F_PrevAndNext(long fileEntryId, long groupId,
2650 long folderId, OrderByComparator orderByComparator)
2651 throws NoSuchFileEntryException, SystemException {
2652 DLFileEntry dlFileEntry = findByPrimaryKey(fileEntryId);
2653
2654 Session session = null;
2655
2656 try {
2657 session = openSession();
2658
2659 DLFileEntry[] array = new DLFileEntryImpl[3];
2660
2661 array[0] = getByG_F_PrevAndNext(session, dlFileEntry, groupId,
2662 folderId, orderByComparator, true);
2663
2664 array[1] = dlFileEntry;
2665
2666 array[2] = getByG_F_PrevAndNext(session, dlFileEntry, groupId,
2667 folderId, orderByComparator, false);
2668
2669 return array;
2670 }
2671 catch (Exception e) {
2672 throw processException(e);
2673 }
2674 finally {
2675 closeSession(session);
2676 }
2677 }
2678
2679 protected DLFileEntry getByG_F_PrevAndNext(Session session,
2680 DLFileEntry dlFileEntry, long groupId, long folderId,
2681 OrderByComparator orderByComparator, boolean previous) {
2682 StringBundler query = null;
2683
2684 if (orderByComparator != null) {
2685 query = new StringBundler(6 +
2686 (orderByComparator.getOrderByFields().length * 6));
2687 }
2688 else {
2689 query = new StringBundler(3);
2690 }
2691
2692 query.append(_SQL_SELECT_DLFILEENTRY_WHERE);
2693
2694 query.append(_FINDER_COLUMN_G_F_GROUPID_2);
2695
2696 query.append(_FINDER_COLUMN_G_F_FOLDERID_2);
2697
2698 if (orderByComparator != null) {
2699 String[] orderByFields = orderByComparator.getOrderByFields();
2700
2701 if (orderByFields.length > 0) {
2702 query.append(WHERE_AND);
2703 }
2704
2705 for (int i = 0; i < orderByFields.length; i++) {
2706 query.append(_ORDER_BY_ENTITY_ALIAS);
2707 query.append(orderByFields[i]);
2708
2709 if ((i + 1) < orderByFields.length) {
2710 if (orderByComparator.isAscending() ^ previous) {
2711 query.append(WHERE_GREATER_THAN_HAS_NEXT);
2712 }
2713 else {
2714 query.append(WHERE_LESSER_THAN_HAS_NEXT);
2715 }
2716 }
2717 else {
2718 if (orderByComparator.isAscending() ^ previous) {
2719 query.append(WHERE_GREATER_THAN);
2720 }
2721 else {
2722 query.append(WHERE_LESSER_THAN);
2723 }
2724 }
2725 }
2726
2727 query.append(ORDER_BY_CLAUSE);
2728
2729 for (int i = 0; i < orderByFields.length; i++) {
2730 query.append(_ORDER_BY_ENTITY_ALIAS);
2731 query.append(orderByFields[i]);
2732
2733 if ((i + 1) < orderByFields.length) {
2734 if (orderByComparator.isAscending() ^ previous) {
2735 query.append(ORDER_BY_ASC_HAS_NEXT);
2736 }
2737 else {
2738 query.append(ORDER_BY_DESC_HAS_NEXT);
2739 }
2740 }
2741 else {
2742 if (orderByComparator.isAscending() ^ previous) {
2743 query.append(ORDER_BY_ASC);
2744 }
2745 else {
2746 query.append(ORDER_BY_DESC);
2747 }
2748 }
2749 }
2750 }
2751
2752 else {
2753 query.append(DLFileEntryModelImpl.ORDER_BY_JPQL);
2754 }
2755
2756 String sql = query.toString();
2757
2758 Query q = session.createQuery(sql);
2759
2760 q.setFirstResult(0);
2761 q.setMaxResults(2);
2762
2763 QueryPos qPos = QueryPos.getInstance(q);
2764
2765 qPos.add(groupId);
2766
2767 qPos.add(folderId);
2768
2769 if (orderByComparator != null) {
2770 Object[] values = orderByComparator.getOrderByValues(dlFileEntry);
2771
2772 for (Object value : values) {
2773 qPos.add(value);
2774 }
2775 }
2776
2777 List<DLFileEntry> list = q.list();
2778
2779 if (list.size() == 2) {
2780 return list.get(1);
2781 }
2782 else {
2783 return null;
2784 }
2785 }
2786
2787
2799 public List<DLFileEntry> findByG_F(long groupId, long[] folderIds)
2800 throws SystemException {
2801 return findByG_F(groupId, folderIds, QueryUtil.ALL_POS,
2802 QueryUtil.ALL_POS, null);
2803 }
2804
2805
2819 public List<DLFileEntry> findByG_F(long groupId, long[] folderIds,
2820 int start, int end) throws SystemException {
2821 return findByG_F(groupId, folderIds, start, end, null);
2822 }
2823
2824
2839 public List<DLFileEntry> findByG_F(long groupId, long[] folderIds,
2840 int start, int end, OrderByComparator orderByComparator)
2841 throws SystemException {
2842 Object[] finderArgs = new Object[] {
2843 groupId, StringUtil.merge(folderIds),
2844
2845 String.valueOf(start), String.valueOf(end),
2846 String.valueOf(orderByComparator)
2847 };
2848
2849 List<DLFileEntry> list = (List<DLFileEntry>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_G_F,
2850 finderArgs, this);
2851
2852 if (list == null) {
2853 Session session = null;
2854
2855 try {
2856 session = openSession();
2857
2858 StringBundler query = new StringBundler();
2859
2860 query.append(_SQL_SELECT_DLFILEENTRY_WHERE);
2861
2862 boolean conjunctionable = false;
2863
2864 if (conjunctionable) {
2865 query.append(WHERE_AND);
2866 }
2867
2868 query.append(_FINDER_COLUMN_G_F_GROUPID_5);
2869
2870 conjunctionable = true;
2871
2872 if ((folderIds == null) || (folderIds.length > 0)) {
2873 if (conjunctionable) {
2874 query.append(WHERE_AND);
2875 }
2876
2877 query.append(StringPool.OPEN_PARENTHESIS);
2878
2879 for (int i = 0; i < folderIds.length; i++) {
2880 query.append(_FINDER_COLUMN_G_F_FOLDERID_5);
2881
2882 if ((i + 1) < folderIds.length) {
2883 query.append(WHERE_OR);
2884 }
2885 }
2886
2887 query.append(StringPool.CLOSE_PARENTHESIS);
2888
2889 conjunctionable = true;
2890 }
2891
2892 if (orderByComparator != null) {
2893 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2894 orderByComparator);
2895 }
2896
2897 else {
2898 query.append(DLFileEntryModelImpl.ORDER_BY_JPQL);
2899 }
2900
2901 String sql = query.toString();
2902
2903 Query q = session.createQuery(sql);
2904
2905 QueryPos qPos = QueryPos.getInstance(q);
2906
2907 qPos.add(groupId);
2908
2909 if (folderIds != null) {
2910 qPos.add(folderIds);
2911 }
2912
2913 list = (List<DLFileEntry>)QueryUtil.list(q, getDialect(),
2914 start, end);
2915 }
2916 catch (Exception e) {
2917 throw processException(e);
2918 }
2919 finally {
2920 if (list == null) {
2921 list = new ArrayList<DLFileEntry>();
2922 }
2923
2924 cacheResult(list);
2925
2926 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_G_F, finderArgs,
2927 list);
2928
2929 closeSession(session);
2930 }
2931 }
2932
2933 return list;
2934 }
2935
2936
2944 public List<DLFileEntry> filterFindByG_F(long groupId, long folderId)
2945 throws SystemException {
2946 return filterFindByG_F(groupId, folderId, QueryUtil.ALL_POS,
2947 QueryUtil.ALL_POS, null);
2948 }
2949
2950
2964 public List<DLFileEntry> filterFindByG_F(long groupId, long folderId,
2965 int start, int end) throws SystemException {
2966 return filterFindByG_F(groupId, folderId, start, end, null);
2967 }
2968
2969
2984 public List<DLFileEntry> filterFindByG_F(long groupId, long folderId,
2985 int start, int end, OrderByComparator orderByComparator)
2986 throws SystemException {
2987 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2988 return findByG_F(groupId, folderId, start, end, orderByComparator);
2989 }
2990
2991 Session session = null;
2992
2993 try {
2994 session = openSession();
2995
2996 StringBundler query = null;
2997
2998 if (orderByComparator != null) {
2999 query = new StringBundler(4 +
3000 (orderByComparator.getOrderByFields().length * 3));
3001 }
3002 else {
3003 query = new StringBundler(4);
3004 }
3005
3006 query.append(_FILTER_SQL_SELECT_DLFILEENTRY_WHERE);
3007
3008 query.append(_FINDER_COLUMN_G_F_GROUPID_2);
3009
3010 query.append(_FINDER_COLUMN_G_F_FOLDERID_2);
3011
3012 if (orderByComparator != null) {
3013 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3014 orderByComparator);
3015 }
3016
3017 else {
3018 query.append(DLFileEntryModelImpl.ORDER_BY_JPQL);
3019 }
3020
3021 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
3022 DLFileEntry.class.getName(), _FILTER_COLUMN_PK,
3023 _FILTER_COLUMN_USERID, groupId);
3024
3025 SQLQuery q = session.createSQLQuery(sql);
3026
3027 q.addEntity(_FILTER_ENTITY_ALIAS, DLFileEntryImpl.class);
3028
3029 QueryPos qPos = QueryPos.getInstance(q);
3030
3031 qPos.add(groupId);
3032
3033 qPos.add(folderId);
3034
3035 return (List<DLFileEntry>)QueryUtil.list(q, getDialect(), start, end);
3036 }
3037 catch (Exception e) {
3038 throw processException(e);
3039 }
3040 finally {
3041 closeSession(session);
3042 }
3043 }
3044
3045
3057 public List<DLFileEntry> filterFindByG_F(long groupId, long[] folderIds)
3058 throws SystemException {
3059 return filterFindByG_F(groupId, folderIds, QueryUtil.ALL_POS,
3060 QueryUtil.ALL_POS, null);
3061 }
3062
3063
3077 public List<DLFileEntry> filterFindByG_F(long groupId, long[] folderIds,
3078 int start, int end) throws SystemException {
3079 return filterFindByG_F(groupId, folderIds, start, end, null);
3080 }
3081
3082
3097 public List<DLFileEntry> filterFindByG_F(long groupId, long[] folderIds,
3098 int start, int end, OrderByComparator orderByComparator)
3099 throws SystemException {
3100 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
3101 return findByG_F(groupId, folderIds, start, end, orderByComparator);
3102 }
3103
3104 Session session = null;
3105
3106 try {
3107 session = openSession();
3108
3109 StringBundler query = new StringBundler();
3110
3111 query.append(_FILTER_SQL_SELECT_DLFILEENTRY_WHERE);
3112
3113 boolean conjunctionable = false;
3114
3115 if (conjunctionable) {
3116 query.append(WHERE_AND);
3117 }
3118
3119 query.append(_FINDER_COLUMN_G_F_GROUPID_5);
3120
3121 conjunctionable = true;
3122
3123 if ((folderIds == null) || (folderIds.length > 0)) {
3124 if (conjunctionable) {
3125 query.append(WHERE_AND);
3126 }
3127
3128 query.append(StringPool.OPEN_PARENTHESIS);
3129
3130 for (int i = 0; i < folderIds.length; i++) {
3131 query.append(_FINDER_COLUMN_G_F_FOLDERID_5);
3132
3133 if ((i + 1) < folderIds.length) {
3134 query.append(WHERE_OR);
3135 }
3136 }
3137
3138 query.append(StringPool.CLOSE_PARENTHESIS);
3139
3140 conjunctionable = true;
3141 }
3142
3143 if (orderByComparator != null) {
3144 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3145 orderByComparator);
3146 }
3147
3148 else {
3149 query.append(DLFileEntryModelImpl.ORDER_BY_JPQL);
3150 }
3151
3152 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
3153 DLFileEntry.class.getName(), _FILTER_COLUMN_PK,
3154 _FILTER_COLUMN_USERID, groupId);
3155
3156 SQLQuery q = session.createSQLQuery(sql);
3157
3158 q.addEntity(_FILTER_ENTITY_ALIAS, DLFileEntryImpl.class);
3159
3160 QueryPos qPos = QueryPos.getInstance(q);
3161
3162 qPos.add(groupId);
3163
3164 if (folderIds != null) {
3165 qPos.add(folderIds);
3166 }
3167
3168 return (List<DLFileEntry>)QueryUtil.list(q, getDialect(), start, end);
3169 }
3170 catch (Exception e) {
3171 throw processException(e);
3172 }
3173 finally {
3174 closeSession(session);
3175 }
3176 }
3177
3178
3187 public List<DLFileEntry> findByG_U_F(long groupId, long userId,
3188 long folderId) throws SystemException {
3189 return findByG_U_F(groupId, userId, folderId, QueryUtil.ALL_POS,
3190 QueryUtil.ALL_POS, null);
3191 }
3192
3193
3208 public List<DLFileEntry> findByG_U_F(long groupId, long userId,
3209 long folderId, int start, int end) throws SystemException {
3210 return findByG_U_F(groupId, userId, folderId, start, end, null);
3211 }
3212
3213
3229 public List<DLFileEntry> findByG_U_F(long groupId, long userId,
3230 long folderId, int start, int end, OrderByComparator orderByComparator)
3231 throws SystemException {
3232 Object[] finderArgs = new Object[] {
3233 groupId, userId, folderId,
3234
3235 String.valueOf(start), String.valueOf(end),
3236 String.valueOf(orderByComparator)
3237 };
3238
3239 List<DLFileEntry> list = (List<DLFileEntry>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_G_U_F,
3240 finderArgs, this);
3241
3242 if (list == null) {
3243 Session session = null;
3244
3245 try {
3246 session = openSession();
3247
3248 StringBundler query = null;
3249
3250 if (orderByComparator != null) {
3251 query = new StringBundler(5 +
3252 (orderByComparator.getOrderByFields().length * 3));
3253 }
3254 else {
3255 query = new StringBundler(5);
3256 }
3257
3258 query.append(_SQL_SELECT_DLFILEENTRY_WHERE);
3259
3260 query.append(_FINDER_COLUMN_G_U_F_GROUPID_2);
3261
3262 query.append(_FINDER_COLUMN_G_U_F_USERID_2);
3263
3264 query.append(_FINDER_COLUMN_G_U_F_FOLDERID_2);
3265
3266 if (orderByComparator != null) {
3267 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3268 orderByComparator);
3269 }
3270
3271 else {
3272 query.append(DLFileEntryModelImpl.ORDER_BY_JPQL);
3273 }
3274
3275 String sql = query.toString();
3276
3277 Query q = session.createQuery(sql);
3278
3279 QueryPos qPos = QueryPos.getInstance(q);
3280
3281 qPos.add(groupId);
3282
3283 qPos.add(userId);
3284
3285 qPos.add(folderId);
3286
3287 list = (List<DLFileEntry>)QueryUtil.list(q, getDialect(),
3288 start, end);
3289 }
3290 catch (Exception e) {
3291 throw processException(e);
3292 }
3293 finally {
3294 if (list == null) {
3295 list = new ArrayList<DLFileEntry>();
3296 }
3297
3298 cacheResult(list);
3299
3300 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_G_U_F,
3301 finderArgs, list);
3302
3303 closeSession(session);
3304 }
3305 }
3306
3307 return list;
3308 }
3309
3310
3325 public DLFileEntry findByG_U_F_First(long groupId, long userId,
3326 long folderId, OrderByComparator orderByComparator)
3327 throws NoSuchFileEntryException, SystemException {
3328 List<DLFileEntry> list = findByG_U_F(groupId, userId, folderId, 0, 1,
3329 orderByComparator);
3330
3331 if (list.isEmpty()) {
3332 StringBundler msg = new StringBundler(8);
3333
3334 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3335
3336 msg.append("groupId=");
3337 msg.append(groupId);
3338
3339 msg.append(", userId=");
3340 msg.append(userId);
3341
3342 msg.append(", folderId=");
3343 msg.append(folderId);
3344
3345 msg.append(StringPool.CLOSE_CURLY_BRACE);
3346
3347 throw new NoSuchFileEntryException(msg.toString());
3348 }
3349 else {
3350 return list.get(0);
3351 }
3352 }
3353
3354
3369 public DLFileEntry findByG_U_F_Last(long groupId, long userId,
3370 long folderId, OrderByComparator orderByComparator)
3371 throws NoSuchFileEntryException, SystemException {
3372 int count = countByG_U_F(groupId, userId, folderId);
3373
3374 List<DLFileEntry> list = findByG_U_F(groupId, userId, folderId,
3375 count - 1, count, orderByComparator);
3376
3377 if (list.isEmpty()) {
3378 StringBundler msg = new StringBundler(8);
3379
3380 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3381
3382 msg.append("groupId=");
3383 msg.append(groupId);
3384
3385 msg.append(", userId=");
3386 msg.append(userId);
3387
3388 msg.append(", folderId=");
3389 msg.append(folderId);
3390
3391 msg.append(StringPool.CLOSE_CURLY_BRACE);
3392
3393 throw new NoSuchFileEntryException(msg.toString());
3394 }
3395 else {
3396 return list.get(0);
3397 }
3398 }
3399
3400
3416 public DLFileEntry[] findByG_U_F_PrevAndNext(long fileEntryId,
3417 long groupId, long userId, long folderId,
3418 OrderByComparator orderByComparator)
3419 throws NoSuchFileEntryException, SystemException {
3420 DLFileEntry dlFileEntry = findByPrimaryKey(fileEntryId);
3421
3422 Session session = null;
3423
3424 try {
3425 session = openSession();
3426
3427 DLFileEntry[] array = new DLFileEntryImpl[3];
3428
3429 array[0] = getByG_U_F_PrevAndNext(session, dlFileEntry, groupId,
3430 userId, folderId, orderByComparator, true);
3431
3432 array[1] = dlFileEntry;
3433
3434 array[2] = getByG_U_F_PrevAndNext(session, dlFileEntry, groupId,
3435 userId, folderId, orderByComparator, false);
3436
3437 return array;
3438 }
3439 catch (Exception e) {
3440 throw processException(e);
3441 }
3442 finally {
3443 closeSession(session);
3444 }
3445 }
3446
3447 protected DLFileEntry getByG_U_F_PrevAndNext(Session session,
3448 DLFileEntry dlFileEntry, long groupId, long userId, long folderId,
3449 OrderByComparator orderByComparator, boolean previous) {
3450 StringBundler query = null;
3451
3452 if (orderByComparator != null) {
3453 query = new StringBundler(6 +
3454 (orderByComparator.getOrderByFields().length * 6));
3455 }
3456 else {
3457 query = new StringBundler(3);
3458 }
3459
3460 query.append(_SQL_SELECT_DLFILEENTRY_WHERE);
3461
3462 query.append(_FINDER_COLUMN_G_U_F_GROUPID_2);
3463
3464 query.append(_FINDER_COLUMN_G_U_F_USERID_2);
3465
3466 query.append(_FINDER_COLUMN_G_U_F_FOLDERID_2);
3467
3468 if (orderByComparator != null) {
3469 String[] orderByFields = orderByComparator.getOrderByFields();
3470
3471 if (orderByFields.length > 0) {
3472 query.append(WHERE_AND);
3473 }
3474
3475 for (int i = 0; i < orderByFields.length; i++) {
3476 query.append(_ORDER_BY_ENTITY_ALIAS);
3477 query.append(orderByFields[i]);
3478
3479 if ((i + 1) < orderByFields.length) {
3480 if (orderByComparator.isAscending() ^ previous) {
3481 query.append(WHERE_GREATER_THAN_HAS_NEXT);
3482 }
3483 else {
3484 query.append(WHERE_LESSER_THAN_HAS_NEXT);
3485 }
3486 }
3487 else {
3488 if (orderByComparator.isAscending() ^ previous) {
3489 query.append(WHERE_GREATER_THAN);
3490 }
3491 else {
3492 query.append(WHERE_LESSER_THAN);
3493 }
3494 }
3495 }
3496
3497 query.append(ORDER_BY_CLAUSE);
3498
3499 for (int i = 0; i < orderByFields.length; i++) {
3500 query.append(_ORDER_BY_ENTITY_ALIAS);
3501 query.append(orderByFields[i]);
3502
3503 if ((i + 1) < orderByFields.length) {
3504 if (orderByComparator.isAscending() ^ previous) {
3505 query.append(ORDER_BY_ASC_HAS_NEXT);
3506 }
3507 else {
3508 query.append(ORDER_BY_DESC_HAS_NEXT);
3509 }
3510 }
3511 else {
3512 if (orderByComparator.isAscending() ^ previous) {
3513 query.append(ORDER_BY_ASC);
3514 }
3515 else {
3516 query.append(ORDER_BY_DESC);
3517 }
3518 }
3519 }
3520 }
3521
3522 else {
3523 query.append(DLFileEntryModelImpl.ORDER_BY_JPQL);
3524 }
3525
3526 String sql = query.toString();
3527
3528 Query q = session.createQuery(sql);
3529
3530 q.setFirstResult(0);
3531 q.setMaxResults(2);
3532
3533 QueryPos qPos = QueryPos.getInstance(q);
3534
3535 qPos.add(groupId);
3536
3537 qPos.add(userId);
3538
3539 qPos.add(folderId);
3540
3541 if (orderByComparator != null) {
3542 Object[] values = orderByComparator.getOrderByValues(dlFileEntry);
3543
3544 for (Object value : values) {
3545 qPos.add(value);
3546 }
3547 }
3548
3549 List<DLFileEntry> list = q.list();
3550
3551 if (list.size() == 2) {
3552 return list.get(1);
3553 }
3554 else {
3555 return null;
3556 }
3557 }
3558
3559
3572 public List<DLFileEntry> findByG_U_F(long groupId, long userId,
3573 long[] folderIds) throws SystemException {
3574 return findByG_U_F(groupId, userId, folderIds, QueryUtil.ALL_POS,
3575 QueryUtil.ALL_POS, null);
3576 }
3577
3578
3593 public List<DLFileEntry> findByG_U_F(long groupId, long userId,
3594 long[] folderIds, int start, int end) throws SystemException {
3595 return findByG_U_F(groupId, userId, folderIds, start, end, null);
3596 }
3597
3598
3614 public List<DLFileEntry> findByG_U_F(long groupId, long userId,
3615 long[] folderIds, int start, int end,
3616 OrderByComparator orderByComparator) throws SystemException {
3617 Object[] finderArgs = new Object[] {
3618 groupId, userId, StringUtil.merge(folderIds),
3619
3620 String.valueOf(start), String.valueOf(end),
3621 String.valueOf(orderByComparator)
3622 };
3623
3624 List<DLFileEntry> list = (List<DLFileEntry>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_G_U_F,
3625 finderArgs, this);
3626
3627 if (list == null) {
3628 Session session = null;
3629
3630 try {
3631 session = openSession();
3632
3633 StringBundler query = new StringBundler();
3634
3635 query.append(_SQL_SELECT_DLFILEENTRY_WHERE);
3636
3637 boolean conjunctionable = false;
3638
3639 if (conjunctionable) {
3640 query.append(WHERE_AND);
3641 }
3642
3643 query.append(_FINDER_COLUMN_G_U_F_GROUPID_5);
3644
3645 conjunctionable = true;
3646
3647 if (conjunctionable) {
3648 query.append(WHERE_AND);
3649 }
3650
3651 query.append(_FINDER_COLUMN_G_U_F_USERID_5);
3652
3653 conjunctionable = true;
3654
3655 if ((folderIds == null) || (folderIds.length > 0)) {
3656 if (conjunctionable) {
3657 query.append(WHERE_AND);
3658 }
3659
3660 query.append(StringPool.OPEN_PARENTHESIS);
3661
3662 for (int i = 0; i < folderIds.length; i++) {
3663 query.append(_FINDER_COLUMN_G_U_F_FOLDERID_5);
3664
3665 if ((i + 1) < folderIds.length) {
3666 query.append(WHERE_OR);
3667 }
3668 }
3669
3670 query.append(StringPool.CLOSE_PARENTHESIS);
3671
3672 conjunctionable = true;
3673 }
3674
3675 if (orderByComparator != null) {
3676 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3677 orderByComparator);
3678 }
3679
3680 else {
3681 query.append(DLFileEntryModelImpl.ORDER_BY_JPQL);
3682 }
3683
3684 String sql = query.toString();
3685
3686 Query q = session.createQuery(sql);
3687
3688 QueryPos qPos = QueryPos.getInstance(q);
3689
3690 qPos.add(groupId);
3691
3692 qPos.add(userId);
3693
3694 if (folderIds != null) {
3695 qPos.add(folderIds);
3696 }
3697
3698 list = (List<DLFileEntry>)QueryUtil.list(q, getDialect(),
3699 start, end);
3700 }
3701 catch (Exception e) {
3702 throw processException(e);
3703 }
3704 finally {
3705 if (list == null) {
3706 list = new ArrayList<DLFileEntry>();
3707 }
3708
3709 cacheResult(list);
3710
3711 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_G_U_F,
3712 finderArgs, list);
3713
3714 closeSession(session);
3715 }
3716 }
3717
3718 return list;
3719 }
3720
3721
3730 public List<DLFileEntry> filterFindByG_U_F(long groupId, long userId,
3731 long folderId) throws SystemException {
3732 return filterFindByG_U_F(groupId, userId, folderId, QueryUtil.ALL_POS,
3733 QueryUtil.ALL_POS, null);
3734 }
3735
3736
3751 public List<DLFileEntry> filterFindByG_U_F(long groupId, long userId,
3752 long folderId, int start, int end) throws SystemException {
3753 return filterFindByG_U_F(groupId, userId, folderId, start, end, null);
3754 }
3755
3756
3772 public List<DLFileEntry> filterFindByG_U_F(long groupId, long userId,
3773 long folderId, int start, int end, OrderByComparator orderByComparator)
3774 throws SystemException {
3775 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
3776 return findByG_U_F(groupId, userId, folderId, start, end,
3777 orderByComparator);
3778 }
3779
3780 Session session = null;
3781
3782 try {
3783 session = openSession();
3784
3785 StringBundler query = null;
3786
3787 if (orderByComparator != null) {
3788 query = new StringBundler(5 +
3789 (orderByComparator.getOrderByFields().length * 3));
3790 }
3791 else {
3792 query = new StringBundler(5);
3793 }
3794
3795 query.append(_FILTER_SQL_SELECT_DLFILEENTRY_WHERE);
3796
3797 query.append(_FINDER_COLUMN_G_U_F_GROUPID_2);
3798
3799 query.append(_FINDER_COLUMN_G_U_F_USERID_2);
3800
3801 query.append(_FINDER_COLUMN_G_U_F_FOLDERID_2);
3802
3803 if (orderByComparator != null) {
3804 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3805 orderByComparator);
3806 }
3807
3808 else {
3809 query.append(DLFileEntryModelImpl.ORDER_BY_JPQL);
3810 }
3811
3812 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
3813 DLFileEntry.class.getName(), _FILTER_COLUMN_PK,
3814 _FILTER_COLUMN_USERID, groupId);
3815
3816 SQLQuery q = session.createSQLQuery(sql);
3817
3818 q.addEntity(_FILTER_ENTITY_ALIAS, DLFileEntryImpl.class);
3819
3820 QueryPos qPos = QueryPos.getInstance(q);
3821
3822 qPos.add(groupId);
3823
3824 qPos.add(userId);
3825
3826 qPos.add(folderId);
3827
3828 return (List<DLFileEntry>)QueryUtil.list(q, getDialect(), start, end);
3829 }
3830 catch (Exception e) {
3831 throw processException(e);
3832 }
3833 finally {
3834 closeSession(session);
3835 }
3836 }
3837
3838
3851 public List<DLFileEntry> filterFindByG_U_F(long groupId, long userId,
3852 long[] folderIds) throws SystemException {
3853 return filterFindByG_U_F(groupId, userId, folderIds, QueryUtil.ALL_POS,
3854 QueryUtil.ALL_POS, null);
3855 }
3856
3857
3872 public List<DLFileEntry> filterFindByG_U_F(long groupId, long userId,
3873 long[] folderIds, int start, int end) throws SystemException {
3874 return filterFindByG_U_F(groupId, userId, folderIds, start, end, null);
3875 }
3876
3877
3893 public List<DLFileEntry> filterFindByG_U_F(long groupId, long userId,
3894 long[] folderIds, int start, int end,
3895 OrderByComparator orderByComparator) throws SystemException {
3896 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
3897 return findByG_U_F(groupId, userId, folderIds, start, end,
3898 orderByComparator);
3899 }
3900
3901 Session session = null;
3902
3903 try {
3904 session = openSession();
3905
3906 StringBundler query = new StringBundler();
3907
3908 query.append(_FILTER_SQL_SELECT_DLFILEENTRY_WHERE);
3909
3910 boolean conjunctionable = false;
3911
3912 if (conjunctionable) {
3913 query.append(WHERE_AND);
3914 }
3915
3916 query.append(_FINDER_COLUMN_G_U_F_GROUPID_5);
3917
3918 conjunctionable = true;
3919
3920 if (conjunctionable) {
3921 query.append(WHERE_AND);
3922 }
3923
3924 query.append(_FINDER_COLUMN_G_U_F_USERID_5);
3925
3926 conjunctionable = true;
3927
3928 if ((folderIds == null) || (folderIds.length > 0)) {
3929 if (conjunctionable) {
3930 query.append(WHERE_AND);
3931 }
3932
3933 query.append(StringPool.OPEN_PARENTHESIS);
3934
3935 for (int i = 0; i < folderIds.length; i++) {
3936 query.append(_FINDER_COLUMN_G_U_F_FOLDERID_5);
3937
3938 if ((i + 1) < folderIds.length) {
3939 query.append(WHERE_OR);
3940 }
3941 }
3942
3943 query.append(StringPool.CLOSE_PARENTHESIS);
3944
3945 conjunctionable = true;
3946 }
3947
3948 if (orderByComparator != null) {
3949 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3950 orderByComparator);
3951 }
3952
3953 else {
3954 query.append(DLFileEntryModelImpl.ORDER_BY_JPQL);
3955 }
3956
3957 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
3958 DLFileEntry.class.getName(), _FILTER_COLUMN_PK,
3959 _FILTER_COLUMN_USERID, groupId);
3960
3961 SQLQuery q = session.createSQLQuery(sql);
3962
3963 q.addEntity(_FILTER_ENTITY_ALIAS, DLFileEntryImpl.class);
3964
3965 QueryPos qPos = QueryPos.getInstance(q);
3966
3967 qPos.add(groupId);
3968
3969 qPos.add(userId);
3970
3971 if (folderIds != null) {
3972 qPos.add(folderIds);
3973 }
3974
3975 return (List<DLFileEntry>)QueryUtil.list(q, getDialect(), start, end);
3976 }
3977 catch (Exception e) {
3978 throw processException(e);
3979 }
3980 finally {
3981 closeSession(session);
3982 }
3983 }
3984
3985
3995 public DLFileEntry findByG_F_N(long groupId, long folderId, String name)
3996 throws NoSuchFileEntryException, SystemException {
3997 DLFileEntry dlFileEntry = fetchByG_F_N(groupId, folderId, name);
3998
3999 if (dlFileEntry == null) {
4000 StringBundler msg = new StringBundler(8);
4001
4002 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4003
4004 msg.append("groupId=");
4005 msg.append(groupId);
4006
4007 msg.append(", folderId=");
4008 msg.append(folderId);
4009
4010 msg.append(", name=");
4011 msg.append(name);
4012
4013 msg.append(StringPool.CLOSE_CURLY_BRACE);
4014
4015 if (_log.isWarnEnabled()) {
4016 _log.warn(msg.toString());
4017 }
4018
4019 throw new NoSuchFileEntryException(msg.toString());
4020 }
4021
4022 return dlFileEntry;
4023 }
4024
4025
4034 public DLFileEntry fetchByG_F_N(long groupId, long folderId, String name)
4035 throws SystemException {
4036 return fetchByG_F_N(groupId, folderId, name, true);
4037 }
4038
4039
4048 public DLFileEntry fetchByG_F_N(long groupId, long folderId, String name,
4049 boolean retrieveFromCache) throws SystemException {
4050 Object[] finderArgs = new Object[] { groupId, folderId, name };
4051
4052 Object result = null;
4053
4054 if (retrieveFromCache) {
4055 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_G_F_N,
4056 finderArgs, this);
4057 }
4058
4059 if (result == null) {
4060 Session session = null;
4061
4062 try {
4063 session = openSession();
4064
4065 StringBundler query = new StringBundler(5);
4066
4067 query.append(_SQL_SELECT_DLFILEENTRY_WHERE);
4068
4069 query.append(_FINDER_COLUMN_G_F_N_GROUPID_2);
4070
4071 query.append(_FINDER_COLUMN_G_F_N_FOLDERID_2);
4072
4073 if (name == null) {
4074 query.append(_FINDER_COLUMN_G_F_N_NAME_1);
4075 }
4076 else {
4077 if (name.equals(StringPool.BLANK)) {
4078 query.append(_FINDER_COLUMN_G_F_N_NAME_3);
4079 }
4080 else {
4081 query.append(_FINDER_COLUMN_G_F_N_NAME_2);
4082 }
4083 }
4084
4085 query.append(DLFileEntryModelImpl.ORDER_BY_JPQL);
4086
4087 String sql = query.toString();
4088
4089 Query q = session.createQuery(sql);
4090
4091 QueryPos qPos = QueryPos.getInstance(q);
4092
4093 qPos.add(groupId);
4094
4095 qPos.add(folderId);
4096
4097 if (name != null) {
4098 qPos.add(name);
4099 }
4100
4101 List<DLFileEntry> list = q.list();
4102
4103 result = list;
4104
4105 DLFileEntry dlFileEntry = null;
4106
4107 if (list.isEmpty()) {
4108 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_F_N,
4109 finderArgs, list);
4110 }
4111 else {
4112 dlFileEntry = list.get(0);
4113
4114 cacheResult(dlFileEntry);
4115
4116 if ((dlFileEntry.getGroupId() != groupId) ||
4117 (dlFileEntry.getFolderId() != folderId) ||
4118 (dlFileEntry.getName() == null) ||
4119 !dlFileEntry.getName().equals(name)) {
4120 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_F_N,
4121 finderArgs, dlFileEntry);
4122 }
4123 }
4124
4125 return dlFileEntry;
4126 }
4127 catch (Exception e) {
4128 throw processException(e);
4129 }
4130 finally {
4131 if (result == null) {
4132 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_F_N,
4133 finderArgs, new ArrayList<DLFileEntry>());
4134 }
4135
4136 closeSession(session);
4137 }
4138 }
4139 else {
4140 if (result instanceof List<?>) {
4141 return null;
4142 }
4143 else {
4144 return (DLFileEntry)result;
4145 }
4146 }
4147 }
4148
4149
4159 public DLFileEntry findByG_F_T(long groupId, long folderId, String title)
4160 throws NoSuchFileEntryException, SystemException {
4161 DLFileEntry dlFileEntry = fetchByG_F_T(groupId, folderId, title);
4162
4163 if (dlFileEntry == null) {
4164 StringBundler msg = new StringBundler(8);
4165
4166 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4167
4168 msg.append("groupId=");
4169 msg.append(groupId);
4170
4171 msg.append(", folderId=");
4172 msg.append(folderId);
4173
4174 msg.append(", title=");
4175 msg.append(title);
4176
4177 msg.append(StringPool.CLOSE_CURLY_BRACE);
4178
4179 if (_log.isWarnEnabled()) {
4180 _log.warn(msg.toString());
4181 }
4182
4183 throw new NoSuchFileEntryException(msg.toString());
4184 }
4185
4186 return dlFileEntry;
4187 }
4188
4189
4198 public DLFileEntry fetchByG_F_T(long groupId, long folderId, String title)
4199 throws SystemException {
4200 return fetchByG_F_T(groupId, folderId, title, true);
4201 }
4202
4203
4212 public DLFileEntry fetchByG_F_T(long groupId, long folderId, String title,
4213 boolean retrieveFromCache) throws SystemException {
4214 Object[] finderArgs = new Object[] { groupId, folderId, title };
4215
4216 Object result = null;
4217
4218 if (retrieveFromCache) {
4219 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_G_F_T,
4220 finderArgs, this);
4221 }
4222
4223 if (result == null) {
4224 Session session = null;
4225
4226 try {
4227 session = openSession();
4228
4229 StringBundler query = new StringBundler(5);
4230
4231 query.append(_SQL_SELECT_DLFILEENTRY_WHERE);
4232
4233 query.append(_FINDER_COLUMN_G_F_T_GROUPID_2);
4234
4235 query.append(_FINDER_COLUMN_G_F_T_FOLDERID_2);
4236
4237 if (title == null) {
4238 query.append(_FINDER_COLUMN_G_F_T_TITLE_1);
4239 }
4240 else {
4241 if (title.equals(StringPool.BLANK)) {
4242 query.append(_FINDER_COLUMN_G_F_T_TITLE_3);
4243 }
4244 else {
4245 query.append(_FINDER_COLUMN_G_F_T_TITLE_2);
4246 }
4247 }
4248
4249 query.append(DLFileEntryModelImpl.ORDER_BY_JPQL);
4250
4251 String sql = query.toString();
4252
4253 Query q = session.createQuery(sql);
4254
4255 QueryPos qPos = QueryPos.getInstance(q);
4256
4257 qPos.add(groupId);
4258
4259 qPos.add(folderId);
4260
4261 if (title != null) {
4262 qPos.add(title);
4263 }
4264
4265 List<DLFileEntry> list = q.list();
4266
4267 result = list;
4268
4269 DLFileEntry dlFileEntry = null;
4270
4271 if (list.isEmpty()) {
4272 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_F_T,
4273 finderArgs, list);
4274 }
4275 else {
4276 dlFileEntry = list.get(0);
4277
4278 cacheResult(dlFileEntry);
4279
4280 if ((dlFileEntry.getGroupId() != groupId) ||
4281 (dlFileEntry.getFolderId() != folderId) ||
4282 (dlFileEntry.getTitle() == null) ||
4283 !dlFileEntry.getTitle().equals(title)) {
4284 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_F_T,
4285 finderArgs, dlFileEntry);
4286 }
4287 }
4288
4289 return dlFileEntry;
4290 }
4291 catch (Exception e) {
4292 throw processException(e);
4293 }
4294 finally {
4295 if (result == null) {
4296 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_F_T,
4297 finderArgs, new ArrayList<DLFileEntry>());
4298 }
4299
4300 closeSession(session);
4301 }
4302 }
4303 else {
4304 if (result instanceof List<?>) {
4305 return null;
4306 }
4307 else {
4308 return (DLFileEntry)result;
4309 }
4310 }
4311 }
4312
4313
4319 public List<DLFileEntry> findAll() throws SystemException {
4320 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
4321 }
4322
4323
4335 public List<DLFileEntry> findAll(int start, int end)
4336 throws SystemException {
4337 return findAll(start, end, null);
4338 }
4339
4340
4353 public List<DLFileEntry> findAll(int start, int end,
4354 OrderByComparator orderByComparator) throws SystemException {
4355 Object[] finderArgs = new Object[] {
4356 String.valueOf(start), String.valueOf(end),
4357 String.valueOf(orderByComparator)
4358 };
4359
4360 List<DLFileEntry> list = (List<DLFileEntry>)FinderCacheUtil.getResult(FINDER_PATH_FIND_ALL,
4361 finderArgs, this);
4362
4363 if (list == null) {
4364 Session session = null;
4365
4366 try {
4367 session = openSession();
4368
4369 StringBundler query = null;
4370 String sql = null;
4371
4372 if (orderByComparator != null) {
4373 query = new StringBundler(2 +
4374 (orderByComparator.getOrderByFields().length * 3));
4375
4376 query.append(_SQL_SELECT_DLFILEENTRY);
4377
4378 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4379 orderByComparator);
4380
4381 sql = query.toString();
4382 }
4383 else {
4384 sql = _SQL_SELECT_DLFILEENTRY.concat(DLFileEntryModelImpl.ORDER_BY_JPQL);
4385 }
4386
4387 Query q = session.createQuery(sql);
4388
4389 if (orderByComparator == null) {
4390 list = (List<DLFileEntry>)QueryUtil.list(q, getDialect(),
4391 start, end, false);
4392
4393 Collections.sort(list);
4394 }
4395 else {
4396 list = (List<DLFileEntry>)QueryUtil.list(q, getDialect(),
4397 start, end);
4398 }
4399 }
4400 catch (Exception e) {
4401 throw processException(e);
4402 }
4403 finally {
4404 if (list == null) {
4405 list = new ArrayList<DLFileEntry>();
4406 }
4407
4408 cacheResult(list);
4409
4410 FinderCacheUtil.putResult(FINDER_PATH_FIND_ALL, finderArgs, list);
4411
4412 closeSession(session);
4413 }
4414 }
4415
4416 return list;
4417 }
4418
4419
4425 public void removeByUuid(String uuid) throws SystemException {
4426 for (DLFileEntry dlFileEntry : findByUuid(uuid)) {
4427 remove(dlFileEntry);
4428 }
4429 }
4430
4431
4438 public void removeByUUID_G(String uuid, long groupId)
4439 throws NoSuchFileEntryException, SystemException {
4440 DLFileEntry dlFileEntry = findByUUID_G(uuid, groupId);
4441
4442 remove(dlFileEntry);
4443 }
4444
4445
4451 public void removeByGroupId(long groupId) throws SystemException {
4452 for (DLFileEntry dlFileEntry : findByGroupId(groupId)) {
4453 remove(dlFileEntry);
4454 }
4455 }
4456
4457
4463 public void removeByCompanyId(long companyId) throws SystemException {
4464 for (DLFileEntry dlFileEntry : findByCompanyId(companyId)) {
4465 remove(dlFileEntry);
4466 }
4467 }
4468
4469
4476 public void removeByG_U(long groupId, long userId)
4477 throws SystemException {
4478 for (DLFileEntry dlFileEntry : findByG_U(groupId, userId)) {
4479 remove(dlFileEntry);
4480 }
4481 }
4482
4483
4490 public void removeByG_F(long groupId, long folderId)
4491 throws SystemException {
4492 for (DLFileEntry dlFileEntry : findByG_F(groupId, folderId)) {
4493 remove(dlFileEntry);
4494 }
4495 }
4496
4497
4505 public void removeByG_U_F(long groupId, long userId, long folderId)
4506 throws SystemException {
4507 for (DLFileEntry dlFileEntry : findByG_U_F(groupId, userId, folderId)) {
4508 remove(dlFileEntry);
4509 }
4510 }
4511
4512
4520 public void removeByG_F_N(long groupId, long folderId, String name)
4521 throws NoSuchFileEntryException, SystemException {
4522 DLFileEntry dlFileEntry = findByG_F_N(groupId, folderId, name);
4523
4524 remove(dlFileEntry);
4525 }
4526
4527
4535 public void removeByG_F_T(long groupId, long folderId, String title)
4536 throws NoSuchFileEntryException, SystemException {
4537 DLFileEntry dlFileEntry = findByG_F_T(groupId, folderId, title);
4538
4539 remove(dlFileEntry);
4540 }
4541
4542
4547 public void removeAll() throws SystemException {
4548 for (DLFileEntry dlFileEntry : findAll()) {
4549 remove(dlFileEntry);
4550 }
4551 }
4552
4553
4560 public int countByUuid(String uuid) throws SystemException {
4561 Object[] finderArgs = new Object[] { uuid };
4562
4563 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID,
4564 finderArgs, this);
4565
4566 if (count == null) {
4567 Session session = null;
4568
4569 try {
4570 session = openSession();
4571
4572 StringBundler query = new StringBundler(2);
4573
4574 query.append(_SQL_COUNT_DLFILEENTRY_WHERE);
4575
4576 if (uuid == null) {
4577 query.append(_FINDER_COLUMN_UUID_UUID_1);
4578 }
4579 else {
4580 if (uuid.equals(StringPool.BLANK)) {
4581 query.append(_FINDER_COLUMN_UUID_UUID_3);
4582 }
4583 else {
4584 query.append(_FINDER_COLUMN_UUID_UUID_2);
4585 }
4586 }
4587
4588 String sql = query.toString();
4589
4590 Query q = session.createQuery(sql);
4591
4592 QueryPos qPos = QueryPos.getInstance(q);
4593
4594 if (uuid != null) {
4595 qPos.add(uuid);
4596 }
4597
4598 count = (Long)q.uniqueResult();
4599 }
4600 catch (Exception e) {
4601 throw processException(e);
4602 }
4603 finally {
4604 if (count == null) {
4605 count = Long.valueOf(0);
4606 }
4607
4608 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID,
4609 finderArgs, count);
4610
4611 closeSession(session);
4612 }
4613 }
4614
4615 return count.intValue();
4616 }
4617
4618
4626 public int countByUUID_G(String uuid, long groupId)
4627 throws SystemException {
4628 Object[] finderArgs = new Object[] { uuid, groupId };
4629
4630 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID_G,
4631 finderArgs, this);
4632
4633 if (count == null) {
4634 Session session = null;
4635
4636 try {
4637 session = openSession();
4638
4639 StringBundler query = new StringBundler(3);
4640
4641 query.append(_SQL_COUNT_DLFILEENTRY_WHERE);
4642
4643 if (uuid == null) {
4644 query.append(_FINDER_COLUMN_UUID_G_UUID_1);
4645 }
4646 else {
4647 if (uuid.equals(StringPool.BLANK)) {
4648 query.append(_FINDER_COLUMN_UUID_G_UUID_3);
4649 }
4650 else {
4651 query.append(_FINDER_COLUMN_UUID_G_UUID_2);
4652 }
4653 }
4654
4655 query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
4656
4657 String sql = query.toString();
4658
4659 Query q = session.createQuery(sql);
4660
4661 QueryPos qPos = QueryPos.getInstance(q);
4662
4663 if (uuid != null) {
4664 qPos.add(uuid);
4665 }
4666
4667 qPos.add(groupId);
4668
4669 count = (Long)q.uniqueResult();
4670 }
4671 catch (Exception e) {
4672 throw processException(e);
4673 }
4674 finally {
4675 if (count == null) {
4676 count = Long.valueOf(0);
4677 }
4678
4679 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G,
4680 finderArgs, count);
4681
4682 closeSession(session);
4683 }
4684 }
4685
4686 return count.intValue();
4687 }
4688
4689
4696 public int countByGroupId(long groupId) throws SystemException {
4697 Object[] finderArgs = new Object[] { groupId };
4698
4699 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_GROUPID,
4700 finderArgs, this);
4701
4702 if (count == null) {
4703 Session session = null;
4704
4705 try {
4706 session = openSession();
4707
4708 StringBundler query = new StringBundler(2);
4709
4710 query.append(_SQL_COUNT_DLFILEENTRY_WHERE);
4711
4712 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
4713
4714 String sql = query.toString();
4715
4716 Query q = session.createQuery(sql);
4717
4718 QueryPos qPos = QueryPos.getInstance(q);
4719
4720 qPos.add(groupId);
4721
4722 count = (Long)q.uniqueResult();
4723 }
4724 catch (Exception e) {
4725 throw processException(e);
4726 }
4727 finally {
4728 if (count == null) {
4729 count = Long.valueOf(0);
4730 }
4731
4732 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_GROUPID,
4733 finderArgs, count);
4734
4735 closeSession(session);
4736 }
4737 }
4738
4739 return count.intValue();
4740 }
4741
4742
4749 public int filterCountByGroupId(long groupId) throws SystemException {
4750 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
4751 return countByGroupId(groupId);
4752 }
4753
4754 Session session = null;
4755
4756 try {
4757 session = openSession();
4758
4759 StringBundler query = new StringBundler(2);
4760
4761 query.append(_FILTER_SQL_COUNT_DLFILEENTRY_WHERE);
4762
4763 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
4764
4765 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
4766 DLFileEntry.class.getName(), _FILTER_COLUMN_PK,
4767 _FILTER_COLUMN_USERID, groupId);
4768
4769 SQLQuery q = session.createSQLQuery(sql);
4770
4771 q.addScalar(COUNT_COLUMN_NAME,
4772 com.liferay.portal.kernel.dao.orm.Type.LONG);
4773
4774 QueryPos qPos = QueryPos.getInstance(q);
4775
4776 qPos.add(groupId);
4777
4778 Long count = (Long)q.uniqueResult();
4779
4780 return count.intValue();
4781 }
4782 catch (Exception e) {
4783 throw processException(e);
4784 }
4785 finally {
4786 closeSession(session);
4787 }
4788 }
4789
4790
4797 public int countByCompanyId(long companyId) throws SystemException {
4798 Object[] finderArgs = new Object[] { companyId };
4799
4800 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_COMPANYID,
4801 finderArgs, this);
4802
4803 if (count == null) {
4804 Session session = null;
4805
4806 try {
4807 session = openSession();
4808
4809 StringBundler query = new StringBundler(2);
4810
4811 query.append(_SQL_COUNT_DLFILEENTRY_WHERE);
4812
4813 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
4814
4815 String sql = query.toString();
4816
4817 Query q = session.createQuery(sql);
4818
4819 QueryPos qPos = QueryPos.getInstance(q);
4820
4821 qPos.add(companyId);
4822
4823 count = (Long)q.uniqueResult();
4824 }
4825 catch (Exception e) {
4826 throw processException(e);
4827 }
4828 finally {
4829 if (count == null) {
4830 count = Long.valueOf(0);
4831 }
4832
4833 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_COMPANYID,
4834 finderArgs, count);
4835
4836 closeSession(session);
4837 }
4838 }
4839
4840 return count.intValue();
4841 }
4842
4843
4851 public int countByG_U(long groupId, long userId) throws SystemException {
4852 Object[] finderArgs = new Object[] { groupId, userId };
4853
4854 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_U,
4855 finderArgs, this);
4856
4857 if (count == null) {
4858 Session session = null;
4859
4860 try {
4861 session = openSession();
4862
4863 StringBundler query = new StringBundler(3);
4864
4865 query.append(_SQL_COUNT_DLFILEENTRY_WHERE);
4866
4867 query.append(_FINDER_COLUMN_G_U_GROUPID_2);
4868
4869 query.append(_FINDER_COLUMN_G_U_USERID_2);
4870
4871 String sql = query.toString();
4872
4873 Query q = session.createQuery(sql);
4874
4875 QueryPos qPos = QueryPos.getInstance(q);
4876
4877 qPos.add(groupId);
4878
4879 qPos.add(userId);
4880
4881 count = (Long)q.uniqueResult();
4882 }
4883 catch (Exception e) {
4884 throw processException(e);
4885 }
4886 finally {
4887 if (count == null) {
4888 count = Long.valueOf(0);
4889 }
4890
4891 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_U, finderArgs,
4892 count);
4893
4894 closeSession(session);
4895 }
4896 }
4897
4898 return count.intValue();
4899 }
4900
4901
4909 public int filterCountByG_U(long groupId, long userId)
4910 throws SystemException {
4911 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
4912 return countByG_U(groupId, userId);
4913 }
4914
4915 Session session = null;
4916
4917 try {
4918 session = openSession();
4919
4920 StringBundler query = new StringBundler(3);
4921
4922 query.append(_FILTER_SQL_COUNT_DLFILEENTRY_WHERE);
4923
4924 query.append(_FINDER_COLUMN_G_U_GROUPID_2);
4925
4926 query.append(_FINDER_COLUMN_G_U_USERID_2);
4927
4928 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
4929 DLFileEntry.class.getName(), _FILTER_COLUMN_PK,
4930 _FILTER_COLUMN_USERID, groupId);
4931
4932 SQLQuery q = session.createSQLQuery(sql);
4933
4934 q.addScalar(COUNT_COLUMN_NAME,
4935 com.liferay.portal.kernel.dao.orm.Type.LONG);
4936
4937 QueryPos qPos = QueryPos.getInstance(q);
4938
4939 qPos.add(groupId);
4940
4941 qPos.add(userId);
4942
4943 Long count = (Long)q.uniqueResult();
4944
4945 return count.intValue();
4946 }
4947 catch (Exception e) {
4948 throw processException(e);
4949 }
4950 finally {
4951 closeSession(session);
4952 }
4953 }
4954
4955
4963 public int countByG_F(long groupId, long folderId)
4964 throws SystemException {
4965 Object[] finderArgs = new Object[] { groupId, folderId };
4966
4967 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_F,
4968 finderArgs, this);
4969
4970 if (count == null) {
4971 Session session = null;
4972
4973 try {
4974 session = openSession();
4975
4976 StringBundler query = new StringBundler(3);
4977
4978 query.append(_SQL_COUNT_DLFILEENTRY_WHERE);
4979
4980 query.append(_FINDER_COLUMN_G_F_GROUPID_2);
4981
4982 query.append(_FINDER_COLUMN_G_F_FOLDERID_2);
4983
4984 String sql = query.toString();
4985
4986 Query q = session.createQuery(sql);
4987
4988 QueryPos qPos = QueryPos.getInstance(q);
4989
4990 qPos.add(groupId);
4991
4992 qPos.add(folderId);
4993
4994 count = (Long)q.uniqueResult();
4995 }
4996 catch (Exception e) {
4997 throw processException(e);
4998 }
4999 finally {
5000 if (count == null) {
5001 count = Long.valueOf(0);
5002 }
5003
5004 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_F, finderArgs,
5005 count);
5006
5007 closeSession(session);
5008 }
5009 }
5010
5011 return count.intValue();
5012 }
5013
5014
5022 public int countByG_F(long groupId, long[] folderIds)
5023 throws SystemException {
5024 Object[] finderArgs = new Object[] { groupId, StringUtil.merge(folderIds) };
5025
5026 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_F,
5027 finderArgs, this);
5028
5029 if (count == null) {
5030 Session session = null;
5031
5032 try {
5033 session = openSession();
5034
5035 StringBundler query = new StringBundler();
5036
5037 query.append(_SQL_COUNT_DLFILEENTRY_WHERE);
5038
5039 boolean conjunctionable = false;
5040
5041 if (conjunctionable) {
5042 query.append(WHERE_AND);
5043 }
5044
5045 query.append(_FINDER_COLUMN_G_F_GROUPID_5);
5046
5047 conjunctionable = true;
5048
5049 if ((folderIds == null) || (folderIds.length > 0)) {
5050 if (conjunctionable) {
5051 query.append(WHERE_AND);
5052 }
5053
5054 query.append(StringPool.OPEN_PARENTHESIS);
5055
5056 for (int i = 0; i < folderIds.length; i++) {
5057 query.append(_FINDER_COLUMN_G_F_FOLDERID_5);
5058
5059 if ((i + 1) < folderIds.length) {
5060 query.append(WHERE_OR);
5061 }
5062 }
5063
5064 query.append(StringPool.CLOSE_PARENTHESIS);
5065
5066 conjunctionable = true;
5067 }
5068
5069 String sql = query.toString();
5070
5071 Query q = session.createQuery(sql);
5072
5073 QueryPos qPos = QueryPos.getInstance(q);
5074
5075 qPos.add(groupId);
5076
5077 if (folderIds != null) {
5078 qPos.add(folderIds);
5079 }
5080
5081 count = (Long)q.uniqueResult();
5082 }
5083 catch (Exception e) {
5084 throw processException(e);
5085 }
5086 finally {
5087 if (count == null) {
5088 count = Long.valueOf(0);
5089 }
5090
5091 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_F, finderArgs,
5092 count);
5093
5094 closeSession(session);
5095 }
5096 }
5097
5098 return count.intValue();
5099 }
5100
5101
5109 public int filterCountByG_F(long groupId, long folderId)
5110 throws SystemException {
5111 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
5112 return countByG_F(groupId, folderId);
5113 }
5114
5115 Session session = null;
5116
5117 try {
5118 session = openSession();
5119
5120 StringBundler query = new StringBundler(3);
5121
5122 query.append(_FILTER_SQL_COUNT_DLFILEENTRY_WHERE);
5123
5124 query.append(_FINDER_COLUMN_G_F_GROUPID_2);
5125
5126 query.append(_FINDER_COLUMN_G_F_FOLDERID_2);
5127
5128 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
5129 DLFileEntry.class.getName(), _FILTER_COLUMN_PK,
5130 _FILTER_COLUMN_USERID, groupId);
5131
5132 SQLQuery q = session.createSQLQuery(sql);
5133
5134 q.addScalar(COUNT_COLUMN_NAME,
5135 com.liferay.portal.kernel.dao.orm.Type.LONG);
5136
5137 QueryPos qPos = QueryPos.getInstance(q);
5138
5139 qPos.add(groupId);
5140
5141 qPos.add(folderId);
5142
5143 Long count = (Long)q.uniqueResult();
5144
5145 return count.intValue();
5146 }
5147 catch (Exception e) {
5148 throw processException(e);
5149 }
5150 finally {
5151 closeSession(session);
5152 }
5153 }
5154
5155
5163 public int filterCountByG_F(long groupId, long[] folderIds)
5164 throws SystemException {
5165 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
5166 return countByG_F(groupId, folderIds);
5167 }
5168
5169 Session session = null;
5170
5171 try {
5172 session = openSession();
5173
5174 StringBundler query = new StringBundler();
5175
5176 query.append(_FILTER_SQL_COUNT_DLFILEENTRY_WHERE);
5177
5178 boolean conjunctionable = false;
5179
5180 if (conjunctionable) {
5181 query.append(WHERE_AND);
5182 }
5183
5184 query.append(_FINDER_COLUMN_G_F_GROUPID_5);
5185
5186 conjunctionable = true;
5187
5188 if ((folderIds == null) || (folderIds.length > 0)) {
5189 if (conjunctionable) {
5190 query.append(WHERE_AND);
5191 }
5192
5193 query.append(StringPool.OPEN_PARENTHESIS);
5194
5195 for (int i = 0; i < folderIds.length; i++) {
5196 query.append(_FINDER_COLUMN_G_F_FOLDERID_5);
5197
5198 if ((i + 1) < folderIds.length) {
5199 query.append(WHERE_OR);
5200 }
5201 }
5202
5203 query.append(StringPool.CLOSE_PARENTHESIS);
5204
5205 conjunctionable = true;
5206 }
5207
5208 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
5209 DLFileEntry.class.getName(), _FILTER_COLUMN_PK,
5210 _FILTER_COLUMN_USERID, groupId);
5211
5212 SQLQuery q = session.createSQLQuery(sql);
5213
5214 q.addScalar(COUNT_COLUMN_NAME,
5215 com.liferay.portal.kernel.dao.orm.Type.LONG);
5216
5217 QueryPos qPos = QueryPos.getInstance(q);
5218
5219 qPos.add(groupId);
5220
5221 if (folderIds != null) {
5222 qPos.add(folderIds);
5223 }
5224
5225 Long count = (Long)q.uniqueResult();
5226
5227 return count.intValue();
5228 }
5229 catch (Exception e) {
5230 throw processException(e);
5231 }
5232 finally {
5233 closeSession(session);
5234 }
5235 }
5236
5237
5246 public int countByG_U_F(long groupId, long userId, long folderId)
5247 throws SystemException {
5248 Object[] finderArgs = new Object[] { groupId, userId, folderId };
5249
5250 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_U_F,
5251 finderArgs, this);
5252
5253 if (count == null) {
5254 Session session = null;
5255
5256 try {
5257 session = openSession();
5258
5259 StringBundler query = new StringBundler(4);
5260
5261 query.append(_SQL_COUNT_DLFILEENTRY_WHERE);
5262
5263 query.append(_FINDER_COLUMN_G_U_F_GROUPID_2);
5264
5265 query.append(_FINDER_COLUMN_G_U_F_USERID_2);
5266
5267 query.append(_FINDER_COLUMN_G_U_F_FOLDERID_2);
5268
5269 String sql = query.toString();
5270
5271 Query q = session.createQuery(sql);
5272
5273 QueryPos qPos = QueryPos.getInstance(q);
5274
5275 qPos.add(groupId);
5276
5277 qPos.add(userId);
5278
5279 qPos.add(folderId);
5280
5281 count = (Long)q.uniqueResult();
5282 }
5283 catch (Exception e) {
5284 throw processException(e);
5285 }
5286 finally {
5287 if (count == null) {
5288 count = Long.valueOf(0);
5289 }
5290
5291 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_U_F,
5292 finderArgs, count);
5293
5294 closeSession(session);
5295 }
5296 }
5297
5298 return count.intValue();
5299 }
5300
5301
5310 public int countByG_U_F(long groupId, long userId, long[] folderIds)
5311 throws SystemException {
5312 Object[] finderArgs = new Object[] {
5313 groupId, userId, StringUtil.merge(folderIds)
5314 };
5315
5316 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_U_F,
5317 finderArgs, this);
5318
5319 if (count == null) {
5320 Session session = null;
5321
5322 try {
5323 session = openSession();
5324
5325 StringBundler query = new StringBundler();
5326
5327 query.append(_SQL_COUNT_DLFILEENTRY_WHERE);
5328
5329 boolean conjunctionable = false;
5330
5331 if (conjunctionable) {
5332 query.append(WHERE_AND);
5333 }
5334
5335 query.append(_FINDER_COLUMN_G_U_F_GROUPID_5);
5336
5337 conjunctionable = true;
5338
5339 if (conjunctionable) {
5340 query.append(WHERE_AND);
5341 }
5342
5343 query.append(_FINDER_COLUMN_G_U_F_USERID_5);
5344
5345 conjunctionable = true;
5346
5347 if ((folderIds == null) || (folderIds.length > 0)) {
5348 if (conjunctionable) {
5349 query.append(WHERE_AND);
5350 }
5351
5352 query.append(StringPool.OPEN_PARENTHESIS);
5353
5354 for (int i = 0; i < folderIds.length; i++) {
5355 query.append(_FINDER_COLUMN_G_U_F_FOLDERID_5);
5356
5357 if ((i + 1) < folderIds.length) {
5358 query.append(WHERE_OR);
5359 }
5360 }
5361
5362 query.append(StringPool.CLOSE_PARENTHESIS);
5363
5364 conjunctionable = true;
5365 }
5366
5367 String sql = query.toString();
5368
5369 Query q = session.createQuery(sql);
5370
5371 QueryPos qPos = QueryPos.getInstance(q);
5372
5373 qPos.add(groupId);
5374
5375 qPos.add(userId);
5376
5377 if (folderIds != null) {
5378 qPos.add(folderIds);
5379 }
5380
5381 count = (Long)q.uniqueResult();
5382 }
5383 catch (Exception e) {
5384 throw processException(e);
5385 }
5386 finally {
5387 if (count == null) {
5388 count = Long.valueOf(0);
5389 }
5390
5391 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_U_F,
5392 finderArgs, count);
5393
5394 closeSession(session);
5395 }
5396 }
5397
5398 return count.intValue();
5399 }
5400
5401
5410 public int filterCountByG_U_F(long groupId, long userId, long folderId)
5411 throws SystemException {
5412 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
5413 return countByG_U_F(groupId, userId, folderId);
5414 }
5415
5416 Session session = null;
5417
5418 try {
5419 session = openSession();
5420
5421 StringBundler query = new StringBundler(4);
5422
5423 query.append(_FILTER_SQL_COUNT_DLFILEENTRY_WHERE);
5424
5425 query.append(_FINDER_COLUMN_G_U_F_GROUPID_2);
5426
5427 query.append(_FINDER_COLUMN_G_U_F_USERID_2);
5428
5429 query.append(_FINDER_COLUMN_G_U_F_FOLDERID_2);
5430
5431 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
5432 DLFileEntry.class.getName(), _FILTER_COLUMN_PK,
5433 _FILTER_COLUMN_USERID, groupId);
5434
5435 SQLQuery q = session.createSQLQuery(sql);
5436
5437 q.addScalar(COUNT_COLUMN_NAME,
5438 com.liferay.portal.kernel.dao.orm.Type.LONG);
5439
5440 QueryPos qPos = QueryPos.getInstance(q);
5441
5442 qPos.add(groupId);
5443
5444 qPos.add(userId);
5445
5446 qPos.add(folderId);
5447
5448 Long count = (Long)q.uniqueResult();
5449
5450 return count.intValue();
5451 }
5452 catch (Exception e) {
5453 throw processException(e);
5454 }
5455 finally {
5456 closeSession(session);
5457 }
5458 }
5459
5460
5469 public int filterCountByG_U_F(long groupId, long userId, long[] folderIds)
5470 throws SystemException {
5471 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
5472 return countByG_U_F(groupId, userId, folderIds);
5473 }
5474
5475 Session session = null;
5476
5477 try {
5478 session = openSession();
5479
5480 StringBundler query = new StringBundler();
5481
5482 query.append(_FILTER_SQL_COUNT_DLFILEENTRY_WHERE);
5483
5484 boolean conjunctionable = false;
5485
5486 if (conjunctionable) {
5487 query.append(WHERE_AND);
5488 }
5489
5490 query.append(_FINDER_COLUMN_G_U_F_GROUPID_5);
5491
5492 conjunctionable = true;
5493
5494 if (conjunctionable) {
5495 query.append(WHERE_AND);
5496 }
5497
5498 query.append(_FINDER_COLUMN_G_U_F_USERID_5);
5499
5500 conjunctionable = true;
5501
5502 if ((folderIds == null) || (folderIds.length > 0)) {
5503 if (conjunctionable) {
5504 query.append(WHERE_AND);
5505 }
5506
5507 query.append(StringPool.OPEN_PARENTHESIS);
5508
5509 for (int i = 0; i < folderIds.length; i++) {
5510 query.append(_FINDER_COLUMN_G_U_F_FOLDERID_5);
5511
5512 if ((i + 1) < folderIds.length) {
5513 query.append(WHERE_OR);
5514 }
5515 }
5516
5517 query.append(StringPool.CLOSE_PARENTHESIS);
5518
5519 conjunctionable = true;
5520 }
5521
5522 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
5523 DLFileEntry.class.getName(), _FILTER_COLUMN_PK,
5524 _FILTER_COLUMN_USERID, groupId);
5525
5526 SQLQuery q = session.createSQLQuery(sql);
5527
5528 q.addScalar(COUNT_COLUMN_NAME,
5529 com.liferay.portal.kernel.dao.orm.Type.LONG);
5530
5531 QueryPos qPos = QueryPos.getInstance(q);
5532
5533 qPos.add(groupId);
5534
5535 qPos.add(userId);
5536
5537 if (folderIds != null) {
5538 qPos.add(folderIds);
5539 }
5540
5541 Long count = (Long)q.uniqueResult();
5542
5543 return count.intValue();
5544 }
5545 catch (Exception e) {
5546 throw processException(e);
5547 }
5548 finally {
5549 closeSession(session);
5550 }
5551 }
5552
5553
5562 public int countByG_F_N(long groupId, long folderId, String name)
5563 throws SystemException {
5564 Object[] finderArgs = new Object[] { groupId, folderId, name };
5565
5566 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_F_N,
5567 finderArgs, this);
5568
5569 if (count == null) {
5570 Session session = null;
5571
5572 try {
5573 session = openSession();
5574
5575 StringBundler query = new StringBundler(4);
5576
5577 query.append(_SQL_COUNT_DLFILEENTRY_WHERE);
5578
5579 query.append(_FINDER_COLUMN_G_F_N_GROUPID_2);
5580
5581 query.append(_FINDER_COLUMN_G_F_N_FOLDERID_2);
5582
5583 if (name == null) {
5584 query.append(_FINDER_COLUMN_G_F_N_NAME_1);
5585 }
5586 else {
5587 if (name.equals(StringPool.BLANK)) {
5588 query.append(_FINDER_COLUMN_G_F_N_NAME_3);
5589 }
5590 else {
5591 query.append(_FINDER_COLUMN_G_F_N_NAME_2);
5592 }
5593 }
5594
5595 String sql = query.toString();
5596
5597 Query q = session.createQuery(sql);
5598
5599 QueryPos qPos = QueryPos.getInstance(q);
5600
5601 qPos.add(groupId);
5602
5603 qPos.add(folderId);
5604
5605 if (name != null) {
5606 qPos.add(name);
5607 }
5608
5609 count = (Long)q.uniqueResult();
5610 }
5611 catch (Exception e) {
5612 throw processException(e);
5613 }
5614 finally {
5615 if (count == null) {
5616 count = Long.valueOf(0);
5617 }
5618
5619 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_F_N,
5620 finderArgs, count);
5621
5622 closeSession(session);
5623 }
5624 }
5625
5626 return count.intValue();
5627 }
5628
5629
5638 public int filterCountByG_F_N(long groupId, long folderId, String name)
5639 throws SystemException {
5640 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
5641 return countByG_F_N(groupId, folderId, name);
5642 }
5643
5644 Session session = null;
5645
5646 try {
5647 session = openSession();
5648
5649 StringBundler query = new StringBundler(4);
5650
5651 query.append(_FILTER_SQL_COUNT_DLFILEENTRY_WHERE);
5652
5653 query.append(_FINDER_COLUMN_G_F_N_GROUPID_2);
5654
5655 query.append(_FINDER_COLUMN_G_F_N_FOLDERID_2);
5656
5657 if (name == null) {
5658 query.append(_FINDER_COLUMN_G_F_N_NAME_1);
5659 }
5660 else {
5661 if (name.equals(StringPool.BLANK)) {
5662 query.append(_FINDER_COLUMN_G_F_N_NAME_3);
5663 }
5664 else {
5665 query.append(_FINDER_COLUMN_G_F_N_NAME_2);
5666 }
5667 }
5668
5669 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
5670 DLFileEntry.class.getName(), _FILTER_COLUMN_PK,
5671 _FILTER_COLUMN_USERID, groupId);
5672
5673 SQLQuery q = session.createSQLQuery(sql);
5674
5675 q.addScalar(COUNT_COLUMN_NAME,
5676 com.liferay.portal.kernel.dao.orm.Type.LONG);
5677
5678 QueryPos qPos = QueryPos.getInstance(q);
5679
5680 qPos.add(groupId);
5681
5682 qPos.add(folderId);
5683
5684 if (name != null) {
5685 qPos.add(name);
5686 }
5687
5688 Long count = (Long)q.uniqueResult();
5689
5690 return count.intValue();
5691 }
5692 catch (Exception e) {
5693 throw processException(e);
5694 }
5695 finally {
5696 closeSession(session);
5697 }
5698 }
5699
5700
5709 public int countByG_F_T(long groupId, long folderId, String title)
5710 throws SystemException {
5711 Object[] finderArgs = new Object[] { groupId, folderId, title };
5712
5713 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_F_T,
5714 finderArgs, this);
5715
5716 if (count == null) {
5717 Session session = null;
5718
5719 try {
5720 session = openSession();
5721
5722 StringBundler query = new StringBundler(4);
5723
5724 query.append(_SQL_COUNT_DLFILEENTRY_WHERE);
5725
5726 query.append(_FINDER_COLUMN_G_F_T_GROUPID_2);
5727
5728 query.append(_FINDER_COLUMN_G_F_T_FOLDERID_2);
5729
5730 if (title == null) {
5731 query.append(_FINDER_COLUMN_G_F_T_TITLE_1);
5732 }
5733 else {
5734 if (title.equals(StringPool.BLANK)) {
5735 query.append(_FINDER_COLUMN_G_F_T_TITLE_3);
5736 }
5737 else {
5738 query.append(_FINDER_COLUMN_G_F_T_TITLE_2);
5739 }
5740 }
5741
5742 String sql = query.toString();
5743
5744 Query q = session.createQuery(sql);
5745
5746 QueryPos qPos = QueryPos.getInstance(q);
5747
5748 qPos.add(groupId);
5749
5750 qPos.add(folderId);
5751
5752 if (title != null) {
5753 qPos.add(title);
5754 }
5755
5756 count = (Long)q.uniqueResult();
5757 }
5758 catch (Exception e) {
5759 throw processException(e);
5760 }
5761 finally {
5762 if (count == null) {
5763 count = Long.valueOf(0);
5764 }
5765
5766 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_F_T,
5767 finderArgs, count);
5768
5769 closeSession(session);
5770 }
5771 }
5772
5773 return count.intValue();
5774 }
5775
5776
5785 public int filterCountByG_F_T(long groupId, long folderId, String title)
5786 throws SystemException {
5787 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
5788 return countByG_F_T(groupId, folderId, title);
5789 }
5790
5791 Session session = null;
5792
5793 try {
5794 session = openSession();
5795
5796 StringBundler query = new StringBundler(4);
5797
5798 query.append(_FILTER_SQL_COUNT_DLFILEENTRY_WHERE);
5799
5800 query.append(_FINDER_COLUMN_G_F_T_GROUPID_2);
5801
5802 query.append(_FINDER_COLUMN_G_F_T_FOLDERID_2);
5803
5804 if (title == null) {
5805 query.append(_FINDER_COLUMN_G_F_T_TITLE_1);
5806 }
5807 else {
5808 if (title.equals(StringPool.BLANK)) {
5809 query.append(_FINDER_COLUMN_G_F_T_TITLE_3);
5810 }
5811 else {
5812 query.append(_FINDER_COLUMN_G_F_T_TITLE_2);
5813 }
5814 }
5815
5816 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
5817 DLFileEntry.class.getName(), _FILTER_COLUMN_PK,
5818 _FILTER_COLUMN_USERID, groupId);
5819
5820 SQLQuery q = session.createSQLQuery(sql);
5821
5822 q.addScalar(COUNT_COLUMN_NAME,
5823 com.liferay.portal.kernel.dao.orm.Type.LONG);
5824
5825 QueryPos qPos = QueryPos.getInstance(q);
5826
5827 qPos.add(groupId);
5828
5829 qPos.add(folderId);
5830
5831 if (title != null) {
5832 qPos.add(title);
5833 }
5834
5835 Long count = (Long)q.uniqueResult();
5836
5837 return count.intValue();
5838 }
5839 catch (Exception e) {
5840 throw processException(e);
5841 }
5842 finally {
5843 closeSession(session);
5844 }
5845 }
5846
5847
5853 public int countAll() throws SystemException {
5854 Object[] finderArgs = new Object[0];
5855
5856 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
5857 finderArgs, this);
5858
5859 if (count == null) {
5860 Session session = null;
5861
5862 try {
5863 session = openSession();
5864
5865 Query q = session.createQuery(_SQL_COUNT_DLFILEENTRY);
5866
5867 count = (Long)q.uniqueResult();
5868 }
5869 catch (Exception e) {
5870 throw processException(e);
5871 }
5872 finally {
5873 if (count == null) {
5874 count = Long.valueOf(0);
5875 }
5876
5877 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL, finderArgs,
5878 count);
5879
5880 closeSession(session);
5881 }
5882 }
5883
5884 return count.intValue();
5885 }
5886
5887
5890 public void afterPropertiesSet() {
5891 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
5892 com.liferay.portal.util.PropsUtil.get(
5893 "value.object.listener.com.liferay.portlet.documentlibrary.model.DLFileEntry")));
5894
5895 if (listenerClassNames.length > 0) {
5896 try {
5897 List<ModelListener<DLFileEntry>> listenersList = new ArrayList<ModelListener<DLFileEntry>>();
5898
5899 for (String listenerClassName : listenerClassNames) {
5900 listenersList.add((ModelListener<DLFileEntry>)InstanceFactory.newInstance(
5901 listenerClassName));
5902 }
5903
5904 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
5905 }
5906 catch (Exception e) {
5907 _log.error(e);
5908 }
5909 }
5910 }
5911
5912 @BeanReference(type = DLFileEntryPersistence.class)
5913 protected DLFileEntryPersistence dlFileEntryPersistence;
5914 @BeanReference(type = DLFileRankPersistence.class)
5915 protected DLFileRankPersistence dlFileRankPersistence;
5916 @BeanReference(type = DLFileShortcutPersistence.class)
5917 protected DLFileShortcutPersistence dlFileShortcutPersistence;
5918 @BeanReference(type = DLFileVersionPersistence.class)
5919 protected DLFileVersionPersistence dlFileVersionPersistence;
5920 @BeanReference(type = DLFolderPersistence.class)
5921 protected DLFolderPersistence dlFolderPersistence;
5922 @BeanReference(type = LockPersistence.class)
5923 protected LockPersistence lockPersistence;
5924 @BeanReference(type = ResourcePersistence.class)
5925 protected ResourcePersistence resourcePersistence;
5926 @BeanReference(type = UserPersistence.class)
5927 protected UserPersistence userPersistence;
5928 @BeanReference(type = WebDAVPropsPersistence.class)
5929 protected WebDAVPropsPersistence webDAVPropsPersistence;
5930 @BeanReference(type = WorkflowInstanceLinkPersistence.class)
5931 protected WorkflowInstanceLinkPersistence workflowInstanceLinkPersistence;
5932 @BeanReference(type = AssetCategoryPersistence.class)
5933 protected AssetCategoryPersistence assetCategoryPersistence;
5934 @BeanReference(type = AssetEntryPersistence.class)
5935 protected AssetEntryPersistence assetEntryPersistence;
5936 @BeanReference(type = AssetTagPersistence.class)
5937 protected AssetTagPersistence assetTagPersistence;
5938 @BeanReference(type = ExpandoValuePersistence.class)
5939 protected ExpandoValuePersistence expandoValuePersistence;
5940 @BeanReference(type = MBDiscussionPersistence.class)
5941 protected MBDiscussionPersistence mbDiscussionPersistence;
5942 @BeanReference(type = MBMessagePersistence.class)
5943 protected MBMessagePersistence mbMessagePersistence;
5944 @BeanReference(type = RatingsEntryPersistence.class)
5945 protected RatingsEntryPersistence ratingsEntryPersistence;
5946 @BeanReference(type = RatingsStatsPersistence.class)
5947 protected RatingsStatsPersistence ratingsStatsPersistence;
5948 @BeanReference(type = SocialActivityPersistence.class)
5949 protected SocialActivityPersistence socialActivityPersistence;
5950 private static final String _SQL_SELECT_DLFILEENTRY = "SELECT dlFileEntry FROM DLFileEntry dlFileEntry";
5951 private static final String _SQL_SELECT_DLFILEENTRY_WHERE = "SELECT dlFileEntry FROM DLFileEntry dlFileEntry WHERE ";
5952 private static final String _SQL_COUNT_DLFILEENTRY = "SELECT COUNT(dlFileEntry) FROM DLFileEntry dlFileEntry";
5953 private static final String _SQL_COUNT_DLFILEENTRY_WHERE = "SELECT COUNT(dlFileEntry) FROM DLFileEntry dlFileEntry WHERE ";
5954 private static final String _FINDER_COLUMN_UUID_UUID_1 = "dlFileEntry.uuid IS NULL";
5955 private static final String _FINDER_COLUMN_UUID_UUID_2 = "dlFileEntry.uuid = ?";
5956 private static final String _FINDER_COLUMN_UUID_UUID_3 = "(dlFileEntry.uuid IS NULL OR dlFileEntry.uuid = ?)";
5957 private static final String _FINDER_COLUMN_UUID_G_UUID_1 = "dlFileEntry.uuid IS NULL AND ";
5958 private static final String _FINDER_COLUMN_UUID_G_UUID_2 = "dlFileEntry.uuid = ? AND ";
5959 private static final String _FINDER_COLUMN_UUID_G_UUID_3 = "(dlFileEntry.uuid IS NULL OR dlFileEntry.uuid = ?) AND ";
5960 private static final String _FINDER_COLUMN_UUID_G_GROUPID_2 = "dlFileEntry.groupId = ?";
5961 private static final String _FINDER_COLUMN_GROUPID_GROUPID_2 = "dlFileEntry.groupId = ?";
5962 private static final String _FINDER_COLUMN_COMPANYID_COMPANYID_2 = "dlFileEntry.companyId = ?";
5963 private static final String _FINDER_COLUMN_G_U_GROUPID_2 = "dlFileEntry.groupId = ? AND ";
5964 private static final String _FINDER_COLUMN_G_U_USERID_2 = "dlFileEntry.userId = ?";
5965 private static final String _FINDER_COLUMN_G_F_GROUPID_2 = "dlFileEntry.groupId = ? AND ";
5966 private static final String _FINDER_COLUMN_G_F_GROUPID_5 = "(" +
5967 _removeConjunction(_FINDER_COLUMN_G_F_GROUPID_2) + ")";
5968 private static final String _FINDER_COLUMN_G_F_FOLDERID_2 = "dlFileEntry.folderId = ?";
5969 private static final String _FINDER_COLUMN_G_F_FOLDERID_5 = "(" +
5970 _removeConjunction(_FINDER_COLUMN_G_F_FOLDERID_2) + ")";
5971 private static final String _FINDER_COLUMN_G_U_F_GROUPID_2 = "dlFileEntry.groupId = ? AND ";
5972 private static final String _FINDER_COLUMN_G_U_F_GROUPID_5 = "(" +
5973 _removeConjunction(_FINDER_COLUMN_G_U_F_GROUPID_2) + ")";
5974 private static final String _FINDER_COLUMN_G_U_F_USERID_2 = "dlFileEntry.userId = ? AND ";
5975 private static final String _FINDER_COLUMN_G_U_F_USERID_5 = "(" +
5976 _removeConjunction(_FINDER_COLUMN_G_U_F_USERID_2) + ")";
5977 private static final String _FINDER_COLUMN_G_U_F_FOLDERID_2 = "dlFileEntry.folderId = ?";
5978 private static final String _FINDER_COLUMN_G_U_F_FOLDERID_5 = "(" +
5979 _removeConjunction(_FINDER_COLUMN_G_U_F_FOLDERID_2) + ")";
5980 private static final String _FINDER_COLUMN_G_F_N_GROUPID_2 = "dlFileEntry.groupId = ? AND ";
5981 private static final String _FINDER_COLUMN_G_F_N_FOLDERID_2 = "dlFileEntry.folderId = ? AND ";
5982 private static final String _FINDER_COLUMN_G_F_N_NAME_1 = "dlFileEntry.name IS NULL";
5983 private static final String _FINDER_COLUMN_G_F_N_NAME_2 = "dlFileEntry.name = ?";
5984 private static final String _FINDER_COLUMN_G_F_N_NAME_3 = "(dlFileEntry.name IS NULL OR dlFileEntry.name = ?)";
5985 private static final String _FINDER_COLUMN_G_F_T_GROUPID_2 = "dlFileEntry.groupId = ? AND ";
5986 private static final String _FINDER_COLUMN_G_F_T_FOLDERID_2 = "dlFileEntry.folderId = ? AND ";
5987 private static final String _FINDER_COLUMN_G_F_T_TITLE_1 = "dlFileEntry.title IS NULL";
5988 private static final String _FINDER_COLUMN_G_F_T_TITLE_2 = "dlFileEntry.title = ?";
5989 private static final String _FINDER_COLUMN_G_F_T_TITLE_3 = "(dlFileEntry.title IS NULL OR dlFileEntry.title = ?)";
5990
5991 private static String _removeConjunction(String sql) {
5992 int pos = sql.indexOf(" AND ");
5993
5994 if (pos != -1) {
5995 sql = sql.substring(0, pos);
5996 }
5997
5998 return sql;
5999 }
6000
6001 private static final String _FILTER_SQL_SELECT_DLFILEENTRY_WHERE = "SELECT DISTINCT {dlFileEntry.*} FROM DLFileEntry dlFileEntry WHERE ";
6002 private static final String _FILTER_SQL_COUNT_DLFILEENTRY_WHERE = "SELECT COUNT(DISTINCT dlFileEntry.fileEntryId) AS COUNT_VALUE FROM DLFileEntry dlFileEntry WHERE ";
6003 private static final String _FILTER_COLUMN_PK = "dlFileEntry.fileEntryId";
6004 private static final String _FILTER_COLUMN_USERID = "dlFileEntry.userId";
6005 private static final String _FILTER_ENTITY_ALIAS = "dlFileEntry";
6006 private static final String _ORDER_BY_ENTITY_ALIAS = "dlFileEntry.";
6007 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No DLFileEntry exists with the primary key ";
6008 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No DLFileEntry exists with the key {";
6009 private static Log _log = LogFactoryUtil.getLog(DLFileEntryPersistenceImpl.class);
6010 }