001
014
015 package com.liferay.portlet.documentlibrary.service.persistence;
016
017 import com.liferay.portal.NoSuchModelException;
018 import com.liferay.portal.kernel.bean.BeanReference;
019 import com.liferay.portal.kernel.cache.CacheRegistryUtil;
020 import com.liferay.portal.kernel.dao.jdbc.MappingSqlQuery;
021 import com.liferay.portal.kernel.dao.jdbc.MappingSqlQueryFactoryUtil;
022 import com.liferay.portal.kernel.dao.jdbc.RowMapper;
023 import com.liferay.portal.kernel.dao.jdbc.SqlUpdate;
024 import com.liferay.portal.kernel.dao.jdbc.SqlUpdateFactoryUtil;
025 import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
026 import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
027 import com.liferay.portal.kernel.dao.orm.FinderPath;
028 import com.liferay.portal.kernel.dao.orm.Query;
029 import com.liferay.portal.kernel.dao.orm.QueryPos;
030 import com.liferay.portal.kernel.dao.orm.QueryUtil;
031 import com.liferay.portal.kernel.dao.orm.SQLQuery;
032 import com.liferay.portal.kernel.dao.orm.Session;
033 import com.liferay.portal.kernel.exception.SystemException;
034 import com.liferay.portal.kernel.log.Log;
035 import com.liferay.portal.kernel.log.LogFactoryUtil;
036 import com.liferay.portal.kernel.util.GetterUtil;
037 import com.liferay.portal.kernel.util.InstanceFactory;
038 import com.liferay.portal.kernel.util.OrderByComparator;
039 import com.liferay.portal.kernel.util.SetUtil;
040 import com.liferay.portal.kernel.util.StringBundler;
041 import com.liferay.portal.kernel.util.StringPool;
042 import com.liferay.portal.kernel.util.StringUtil;
043 import com.liferay.portal.kernel.util.Validator;
044 import com.liferay.portal.kernel.uuid.PortalUUIDUtil;
045 import com.liferay.portal.model.CacheModel;
046 import com.liferay.portal.model.ModelListener;
047 import com.liferay.portal.security.permission.InlineSQLHelperUtil;
048 import com.liferay.portal.service.persistence.BatchSessionUtil;
049 import com.liferay.portal.service.persistence.GroupPersistence;
050 import com.liferay.portal.service.persistence.LockPersistence;
051 import com.liferay.portal.service.persistence.ResourcePersistence;
052 import com.liferay.portal.service.persistence.UserPersistence;
053 import com.liferay.portal.service.persistence.WebDAVPropsPersistence;
054 import com.liferay.portal.service.persistence.WorkflowDefinitionLinkPersistence;
055 import com.liferay.portal.service.persistence.WorkflowInstanceLinkPersistence;
056 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
057
058 import com.liferay.portlet.documentlibrary.NoSuchFolderException;
059 import com.liferay.portlet.documentlibrary.model.DLFolder;
060 import com.liferay.portlet.documentlibrary.model.impl.DLFolderImpl;
061 import com.liferay.portlet.documentlibrary.model.impl.DLFolderModelImpl;
062 import com.liferay.portlet.expando.service.persistence.ExpandoValuePersistence;
063
064 import java.io.Serializable;
065
066 import java.util.ArrayList;
067 import java.util.Collections;
068 import java.util.List;
069 import java.util.Set;
070
071
083 public class DLFolderPersistenceImpl extends BasePersistenceImpl<DLFolder>
084 implements DLFolderPersistence {
085
090 public static final String FINDER_CLASS_NAME_ENTITY = DLFolderImpl.class.getName();
091 public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
092 ".List1";
093 public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
094 ".List2";
095 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID = new FinderPath(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
096 DLFolderModelImpl.FINDER_CACHE_ENABLED, DLFolderImpl.class,
097 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUuid",
098 new String[] {
099 String.class.getName(),
100
101 "java.lang.Integer", "java.lang.Integer",
102 "com.liferay.portal.kernel.util.OrderByComparator"
103 });
104 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID = new FinderPath(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
105 DLFolderModelImpl.FINDER_CACHE_ENABLED, DLFolderImpl.class,
106 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid",
107 new String[] { String.class.getName() },
108 DLFolderModelImpl.UUID_COLUMN_BITMASK);
109 public static final FinderPath FINDER_PATH_COUNT_BY_UUID = new FinderPath(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
110 DLFolderModelImpl.FINDER_CACHE_ENABLED, Long.class,
111 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid",
112 new String[] { String.class.getName() });
113 public static final FinderPath FINDER_PATH_FETCH_BY_UUID_G = new FinderPath(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
114 DLFolderModelImpl.FINDER_CACHE_ENABLED, DLFolderImpl.class,
115 FINDER_CLASS_NAME_ENTITY, "fetchByUUID_G",
116 new String[] { String.class.getName(), Long.class.getName() },
117 DLFolderModelImpl.UUID_COLUMN_BITMASK |
118 DLFolderModelImpl.GROUPID_COLUMN_BITMASK);
119 public static final FinderPath FINDER_PATH_COUNT_BY_UUID_G = new FinderPath(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
120 DLFolderModelImpl.FINDER_CACHE_ENABLED, Long.class,
121 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUUID_G",
122 new String[] { String.class.getName(), Long.class.getName() });
123 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID = new FinderPath(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
124 DLFolderModelImpl.FINDER_CACHE_ENABLED, DLFolderImpl.class,
125 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByGroupId",
126 new String[] {
127 Long.class.getName(),
128
129 "java.lang.Integer", "java.lang.Integer",
130 "com.liferay.portal.kernel.util.OrderByComparator"
131 });
132 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID =
133 new FinderPath(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
134 DLFolderModelImpl.FINDER_CACHE_ENABLED, DLFolderImpl.class,
135 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByGroupId",
136 new String[] { Long.class.getName() },
137 DLFolderModelImpl.GROUPID_COLUMN_BITMASK);
138 public static final FinderPath FINDER_PATH_COUNT_BY_GROUPID = new FinderPath(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
139 DLFolderModelImpl.FINDER_CACHE_ENABLED, Long.class,
140 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByGroupId",
141 new String[] { Long.class.getName() });
142 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID =
143 new FinderPath(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
144 DLFolderModelImpl.FINDER_CACHE_ENABLED, DLFolderImpl.class,
145 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByCompanyId",
146 new String[] {
147 Long.class.getName(),
148
149 "java.lang.Integer", "java.lang.Integer",
150 "com.liferay.portal.kernel.util.OrderByComparator"
151 });
152 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID =
153 new FinderPath(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
154 DLFolderModelImpl.FINDER_CACHE_ENABLED, DLFolderImpl.class,
155 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByCompanyId",
156 new String[] { Long.class.getName() },
157 DLFolderModelImpl.COMPANYID_COLUMN_BITMASK);
158 public static final FinderPath FINDER_PATH_COUNT_BY_COMPANYID = new FinderPath(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
159 DLFolderModelImpl.FINDER_CACHE_ENABLED, Long.class,
160 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByCompanyId",
161 new String[] { Long.class.getName() });
162 public static final FinderPath FINDER_PATH_FETCH_BY_REPOSITORYID = new FinderPath(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
163 DLFolderModelImpl.FINDER_CACHE_ENABLED, DLFolderImpl.class,
164 FINDER_CLASS_NAME_ENTITY, "fetchByRepositoryId",
165 new String[] { Long.class.getName() },
166 DLFolderModelImpl.REPOSITORYID_COLUMN_BITMASK);
167 public static final FinderPath FINDER_PATH_COUNT_BY_REPOSITORYID = new FinderPath(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
168 DLFolderModelImpl.FINDER_CACHE_ENABLED, Long.class,
169 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByRepositoryId",
170 new String[] { Long.class.getName() });
171 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_P = new FinderPath(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
172 DLFolderModelImpl.FINDER_CACHE_ENABLED, DLFolderImpl.class,
173 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_P",
174 new String[] {
175 Long.class.getName(), Long.class.getName(),
176
177 "java.lang.Integer", "java.lang.Integer",
178 "com.liferay.portal.kernel.util.OrderByComparator"
179 });
180 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P = new FinderPath(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
181 DLFolderModelImpl.FINDER_CACHE_ENABLED, DLFolderImpl.class,
182 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_P",
183 new String[] { Long.class.getName(), Long.class.getName() },
184 DLFolderModelImpl.GROUPID_COLUMN_BITMASK |
185 DLFolderModelImpl.PARENTFOLDERID_COLUMN_BITMASK);
186 public static final FinderPath FINDER_PATH_COUNT_BY_G_P = new FinderPath(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
187 DLFolderModelImpl.FINDER_CACHE_ENABLED, Long.class,
188 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_P",
189 new String[] { Long.class.getName(), Long.class.getName() });
190 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_P_N = new FinderPath(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
191 DLFolderModelImpl.FINDER_CACHE_ENABLED, DLFolderImpl.class,
192 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByP_N",
193 new String[] {
194 Long.class.getName(), String.class.getName(),
195
196 "java.lang.Integer", "java.lang.Integer",
197 "com.liferay.portal.kernel.util.OrderByComparator"
198 });
199 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_P_N = new FinderPath(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
200 DLFolderModelImpl.FINDER_CACHE_ENABLED, DLFolderImpl.class,
201 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByP_N",
202 new String[] { Long.class.getName(), String.class.getName() },
203 DLFolderModelImpl.PARENTFOLDERID_COLUMN_BITMASK |
204 DLFolderModelImpl.NAME_COLUMN_BITMASK);
205 public static final FinderPath FINDER_PATH_COUNT_BY_P_N = new FinderPath(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
206 DLFolderModelImpl.FINDER_CACHE_ENABLED, Long.class,
207 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByP_N",
208 new String[] { Long.class.getName(), String.class.getName() });
209 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_P_M = new FinderPath(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
210 DLFolderModelImpl.FINDER_CACHE_ENABLED, DLFolderImpl.class,
211 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_P_M",
212 new String[] {
213 Long.class.getName(), Long.class.getName(),
214 Boolean.class.getName(),
215
216 "java.lang.Integer", "java.lang.Integer",
217 "com.liferay.portal.kernel.util.OrderByComparator"
218 });
219 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_M = new FinderPath(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
220 DLFolderModelImpl.FINDER_CACHE_ENABLED, DLFolderImpl.class,
221 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_P_M",
222 new String[] {
223 Long.class.getName(), Long.class.getName(),
224 Boolean.class.getName()
225 },
226 DLFolderModelImpl.GROUPID_COLUMN_BITMASK |
227 DLFolderModelImpl.PARENTFOLDERID_COLUMN_BITMASK |
228 DLFolderModelImpl.MOUNTPOINT_COLUMN_BITMASK);
229 public static final FinderPath FINDER_PATH_COUNT_BY_G_P_M = new FinderPath(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
230 DLFolderModelImpl.FINDER_CACHE_ENABLED, Long.class,
231 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_P_M",
232 new String[] {
233 Long.class.getName(), Long.class.getName(),
234 Boolean.class.getName()
235 });
236 public static final FinderPath FINDER_PATH_FETCH_BY_G_P_N = new FinderPath(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
237 DLFolderModelImpl.FINDER_CACHE_ENABLED, DLFolderImpl.class,
238 FINDER_CLASS_NAME_ENTITY, "fetchByG_P_N",
239 new String[] {
240 Long.class.getName(), Long.class.getName(),
241 String.class.getName()
242 },
243 DLFolderModelImpl.GROUPID_COLUMN_BITMASK |
244 DLFolderModelImpl.PARENTFOLDERID_COLUMN_BITMASK |
245 DLFolderModelImpl.NAME_COLUMN_BITMASK);
246 public static final FinderPath FINDER_PATH_COUNT_BY_G_P_N = new FinderPath(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
247 DLFolderModelImpl.FINDER_CACHE_ENABLED, Long.class,
248 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_P_N",
249 new String[] {
250 Long.class.getName(), Long.class.getName(),
251 String.class.getName()
252 });
253 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
254 DLFolderModelImpl.FINDER_CACHE_ENABLED, DLFolderImpl.class,
255 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0]);
256 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
257 DLFolderModelImpl.FINDER_CACHE_ENABLED, DLFolderImpl.class,
258 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
259 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
260 DLFolderModelImpl.FINDER_CACHE_ENABLED, Long.class,
261 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
262
263
268 public void cacheResult(DLFolder dlFolder) {
269 EntityCacheUtil.putResult(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
270 DLFolderImpl.class, dlFolder.getPrimaryKey(), dlFolder);
271
272 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
273 new Object[] { dlFolder.getUuid(), Long.valueOf(
274 dlFolder.getGroupId()) }, dlFolder);
275
276 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_REPOSITORYID,
277 new Object[] { Long.valueOf(dlFolder.getRepositoryId()) }, dlFolder);
278
279 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_P_N,
280 new Object[] {
281 Long.valueOf(dlFolder.getGroupId()),
282 Long.valueOf(dlFolder.getParentFolderId()),
283
284 dlFolder.getName()
285 }, dlFolder);
286
287 dlFolder.resetOriginalValues();
288 }
289
290
295 public void cacheResult(List<DLFolder> dlFolders) {
296 for (DLFolder dlFolder : dlFolders) {
297 if (EntityCacheUtil.getResult(
298 DLFolderModelImpl.ENTITY_CACHE_ENABLED,
299 DLFolderImpl.class, dlFolder.getPrimaryKey()) == null) {
300 cacheResult(dlFolder);
301 }
302 else {
303 dlFolder.resetOriginalValues();
304 }
305 }
306 }
307
308
315 @Override
316 public void clearCache() {
317 if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
318 CacheRegistryUtil.clear(DLFolderImpl.class.getName());
319 }
320
321 EntityCacheUtil.clearCache(DLFolderImpl.class.getName());
322
323 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
324 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
325 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
326 }
327
328
335 @Override
336 public void clearCache(DLFolder dlFolder) {
337 EntityCacheUtil.removeResult(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
338 DLFolderImpl.class, dlFolder.getPrimaryKey());
339
340 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
341 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
342
343 clearUniqueFindersCache(dlFolder);
344 }
345
346 @Override
347 public void clearCache(List<DLFolder> dlFolders) {
348 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
349 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
350
351 for (DLFolder dlFolder : dlFolders) {
352 EntityCacheUtil.removeResult(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
353 DLFolderImpl.class, dlFolder.getPrimaryKey());
354
355 clearUniqueFindersCache(dlFolder);
356 }
357 }
358
359 protected void clearUniqueFindersCache(DLFolder dlFolder) {
360 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
361 new Object[] { dlFolder.getUuid(), Long.valueOf(
362 dlFolder.getGroupId()) });
363
364 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_REPOSITORYID,
365 new Object[] { Long.valueOf(dlFolder.getRepositoryId()) });
366
367 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_P_N,
368 new Object[] {
369 Long.valueOf(dlFolder.getGroupId()),
370 Long.valueOf(dlFolder.getParentFolderId()),
371
372 dlFolder.getName()
373 });
374 }
375
376
382 public DLFolder create(long folderId) {
383 DLFolder dlFolder = new DLFolderImpl();
384
385 dlFolder.setNew(true);
386 dlFolder.setPrimaryKey(folderId);
387
388 String uuid = PortalUUIDUtil.generate();
389
390 dlFolder.setUuid(uuid);
391
392 return dlFolder;
393 }
394
395
403 public DLFolder remove(long folderId)
404 throws NoSuchFolderException, SystemException {
405 return remove(Long.valueOf(folderId));
406 }
407
408
416 @Override
417 public DLFolder remove(Serializable primaryKey)
418 throws NoSuchFolderException, SystemException {
419 Session session = null;
420
421 try {
422 session = openSession();
423
424 DLFolder dlFolder = (DLFolder)session.get(DLFolderImpl.class,
425 primaryKey);
426
427 if (dlFolder == null) {
428 if (_log.isWarnEnabled()) {
429 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
430 }
431
432 throw new NoSuchFolderException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
433 primaryKey);
434 }
435
436 return remove(dlFolder);
437 }
438 catch (NoSuchFolderException nsee) {
439 throw nsee;
440 }
441 catch (Exception e) {
442 throw processException(e);
443 }
444 finally {
445 closeSession(session);
446 }
447 }
448
449 @Override
450 protected DLFolder removeImpl(DLFolder dlFolder) throws SystemException {
451 dlFolder = toUnwrappedModel(dlFolder);
452
453 try {
454 clearDLFileEntryTypes.clear(dlFolder.getPrimaryKey());
455 }
456 catch (Exception e) {
457 throw processException(e);
458 }
459 finally {
460 FinderCacheUtil.clearCache(DLFolderModelImpl.MAPPING_TABLE_DLFILEENTRYTYPES_DLFOLDERS_NAME);
461 }
462
463 Session session = null;
464
465 try {
466 session = openSession();
467
468 BatchSessionUtil.delete(session, dlFolder);
469 }
470 catch (Exception e) {
471 throw processException(e);
472 }
473 finally {
474 closeSession(session);
475 }
476
477 clearCache(dlFolder);
478
479 return dlFolder;
480 }
481
482 @Override
483 public DLFolder updateImpl(
484 com.liferay.portlet.documentlibrary.model.DLFolder dlFolder,
485 boolean merge) throws SystemException {
486 dlFolder = toUnwrappedModel(dlFolder);
487
488 boolean isNew = dlFolder.isNew();
489
490 DLFolderModelImpl dlFolderModelImpl = (DLFolderModelImpl)dlFolder;
491
492 if (Validator.isNull(dlFolder.getUuid())) {
493 String uuid = PortalUUIDUtil.generate();
494
495 dlFolder.setUuid(uuid);
496 }
497
498 Session session = null;
499
500 try {
501 session = openSession();
502
503 BatchSessionUtil.update(session, dlFolder, merge);
504
505 dlFolder.setNew(false);
506 }
507 catch (Exception e) {
508 throw processException(e);
509 }
510 finally {
511 closeSession(session);
512 }
513
514 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
515
516 if (isNew || !DLFolderModelImpl.COLUMN_BITMASK_ENABLED) {
517 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
518 }
519 else {
520 if ((dlFolderModelImpl.getColumnBitmask() &
521 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID.getColumnBitmask()) != 0) {
522 Object[] args = new Object[] { dlFolderModelImpl.getOriginalUuid() };
523
524 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
525 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
526 args);
527
528 args = new Object[] { dlFolderModelImpl.getUuid() };
529
530 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
531 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
532 args);
533 }
534
535 if ((dlFolderModelImpl.getColumnBitmask() &
536 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID.getColumnBitmask()) != 0) {
537 Object[] args = new Object[] {
538 Long.valueOf(dlFolderModelImpl.getOriginalGroupId())
539 };
540
541 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
542 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
543 args);
544
545 args = new Object[] { Long.valueOf(dlFolderModelImpl.getGroupId()) };
546
547 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
548 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
549 args);
550 }
551
552 if ((dlFolderModelImpl.getColumnBitmask() &
553 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID.getColumnBitmask()) != 0) {
554 Object[] args = new Object[] {
555 Long.valueOf(dlFolderModelImpl.getOriginalCompanyId())
556 };
557
558 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_COMPANYID,
559 args);
560 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
561 args);
562
563 args = new Object[] {
564 Long.valueOf(dlFolderModelImpl.getCompanyId())
565 };
566
567 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_COMPANYID,
568 args);
569 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
570 args);
571 }
572
573 if ((dlFolderModelImpl.getColumnBitmask() &
574 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P.getColumnBitmask()) != 0) {
575 Object[] args = new Object[] {
576 Long.valueOf(dlFolderModelImpl.getOriginalGroupId()),
577 Long.valueOf(dlFolderModelImpl.getOriginalParentFolderId())
578 };
579
580 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_P, args);
581 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P,
582 args);
583
584 args = new Object[] {
585 Long.valueOf(dlFolderModelImpl.getGroupId()),
586 Long.valueOf(dlFolderModelImpl.getParentFolderId())
587 };
588
589 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_P, args);
590 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P,
591 args);
592 }
593
594 if ((dlFolderModelImpl.getColumnBitmask() &
595 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_P_N.getColumnBitmask()) != 0) {
596 Object[] args = new Object[] {
597 Long.valueOf(dlFolderModelImpl.getOriginalParentFolderId()),
598
599 dlFolderModelImpl.getOriginalName()
600 };
601
602 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_P_N, args);
603 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_P_N,
604 args);
605
606 args = new Object[] {
607 Long.valueOf(dlFolderModelImpl.getParentFolderId()),
608
609 dlFolderModelImpl.getName()
610 };
611
612 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_P_N, args);
613 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_P_N,
614 args);
615 }
616
617 if ((dlFolderModelImpl.getColumnBitmask() &
618 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_M.getColumnBitmask()) != 0) {
619 Object[] args = new Object[] {
620 Long.valueOf(dlFolderModelImpl.getOriginalGroupId()),
621 Long.valueOf(dlFolderModelImpl.getOriginalParentFolderId()),
622 Boolean.valueOf(dlFolderModelImpl.getOriginalMountPoint())
623 };
624
625 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_P_M, args);
626 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_M,
627 args);
628
629 args = new Object[] {
630 Long.valueOf(dlFolderModelImpl.getGroupId()),
631 Long.valueOf(dlFolderModelImpl.getParentFolderId()),
632 Boolean.valueOf(dlFolderModelImpl.getMountPoint())
633 };
634
635 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_P_M, args);
636 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_M,
637 args);
638 }
639 }
640
641 EntityCacheUtil.putResult(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
642 DLFolderImpl.class, dlFolder.getPrimaryKey(), dlFolder);
643
644 if (isNew) {
645 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
646 new Object[] {
647 dlFolder.getUuid(), Long.valueOf(dlFolder.getGroupId())
648 }, dlFolder);
649
650 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_REPOSITORYID,
651 new Object[] { Long.valueOf(dlFolder.getRepositoryId()) },
652 dlFolder);
653
654 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_P_N,
655 new Object[] {
656 Long.valueOf(dlFolder.getGroupId()),
657 Long.valueOf(dlFolder.getParentFolderId()),
658
659 dlFolder.getName()
660 }, dlFolder);
661 }
662 else {
663 if ((dlFolderModelImpl.getColumnBitmask() &
664 FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) {
665 Object[] args = new Object[] {
666 dlFolderModelImpl.getOriginalUuid(),
667 Long.valueOf(dlFolderModelImpl.getOriginalGroupId())
668 };
669
670 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args);
671 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args);
672
673 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
674 new Object[] {
675 dlFolder.getUuid(), Long.valueOf(dlFolder.getGroupId())
676 }, dlFolder);
677 }
678
679 if ((dlFolderModelImpl.getColumnBitmask() &
680 FINDER_PATH_FETCH_BY_REPOSITORYID.getColumnBitmask()) != 0) {
681 Object[] args = new Object[] {
682 Long.valueOf(dlFolderModelImpl.getOriginalRepositoryId())
683 };
684
685 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_REPOSITORYID,
686 args);
687 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_REPOSITORYID,
688 args);
689
690 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_REPOSITORYID,
691 new Object[] { Long.valueOf(dlFolder.getRepositoryId()) },
692 dlFolder);
693 }
694
695 if ((dlFolderModelImpl.getColumnBitmask() &
696 FINDER_PATH_FETCH_BY_G_P_N.getColumnBitmask()) != 0) {
697 Object[] args = new Object[] {
698 Long.valueOf(dlFolderModelImpl.getOriginalGroupId()),
699 Long.valueOf(dlFolderModelImpl.getOriginalParentFolderId()),
700
701 dlFolderModelImpl.getOriginalName()
702 };
703
704 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_P_N, args);
705 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_P_N, args);
706
707 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_P_N,
708 new Object[] {
709 Long.valueOf(dlFolder.getGroupId()),
710 Long.valueOf(dlFolder.getParentFolderId()),
711
712 dlFolder.getName()
713 }, dlFolder);
714 }
715 }
716
717 return dlFolder;
718 }
719
720 protected DLFolder toUnwrappedModel(DLFolder dlFolder) {
721 if (dlFolder instanceof DLFolderImpl) {
722 return dlFolder;
723 }
724
725 DLFolderImpl dlFolderImpl = new DLFolderImpl();
726
727 dlFolderImpl.setNew(dlFolder.isNew());
728 dlFolderImpl.setPrimaryKey(dlFolder.getPrimaryKey());
729
730 dlFolderImpl.setUuid(dlFolder.getUuid());
731 dlFolderImpl.setFolderId(dlFolder.getFolderId());
732 dlFolderImpl.setGroupId(dlFolder.getGroupId());
733 dlFolderImpl.setCompanyId(dlFolder.getCompanyId());
734 dlFolderImpl.setUserId(dlFolder.getUserId());
735 dlFolderImpl.setUserName(dlFolder.getUserName());
736 dlFolderImpl.setCreateDate(dlFolder.getCreateDate());
737 dlFolderImpl.setModifiedDate(dlFolder.getModifiedDate());
738 dlFolderImpl.setRepositoryId(dlFolder.getRepositoryId());
739 dlFolderImpl.setMountPoint(dlFolder.isMountPoint());
740 dlFolderImpl.setParentFolderId(dlFolder.getParentFolderId());
741 dlFolderImpl.setName(dlFolder.getName());
742 dlFolderImpl.setDescription(dlFolder.getDescription());
743 dlFolderImpl.setLastPostDate(dlFolder.getLastPostDate());
744 dlFolderImpl.setDefaultFileEntryTypeId(dlFolder.getDefaultFileEntryTypeId());
745 dlFolderImpl.setOverrideFileEntryTypes(dlFolder.isOverrideFileEntryTypes());
746
747 return dlFolderImpl;
748 }
749
750
758 @Override
759 public DLFolder findByPrimaryKey(Serializable primaryKey)
760 throws NoSuchModelException, SystemException {
761 return findByPrimaryKey(((Long)primaryKey).longValue());
762 }
763
764
772 public DLFolder findByPrimaryKey(long folderId)
773 throws NoSuchFolderException, SystemException {
774 DLFolder dlFolder = fetchByPrimaryKey(folderId);
775
776 if (dlFolder == null) {
777 if (_log.isWarnEnabled()) {
778 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + folderId);
779 }
780
781 throw new NoSuchFolderException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
782 folderId);
783 }
784
785 return dlFolder;
786 }
787
788
795 @Override
796 public DLFolder fetchByPrimaryKey(Serializable primaryKey)
797 throws SystemException {
798 return fetchByPrimaryKey(((Long)primaryKey).longValue());
799 }
800
801
808 public DLFolder fetchByPrimaryKey(long folderId) throws SystemException {
809 DLFolder dlFolder = (DLFolder)EntityCacheUtil.getResult(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
810 DLFolderImpl.class, folderId);
811
812 if (dlFolder == _nullDLFolder) {
813 return null;
814 }
815
816 if (dlFolder == null) {
817 Session session = null;
818
819 boolean hasException = false;
820
821 try {
822 session = openSession();
823
824 dlFolder = (DLFolder)session.get(DLFolderImpl.class,
825 Long.valueOf(folderId));
826 }
827 catch (Exception e) {
828 hasException = true;
829
830 throw processException(e);
831 }
832 finally {
833 if (dlFolder != null) {
834 cacheResult(dlFolder);
835 }
836 else if (!hasException) {
837 EntityCacheUtil.putResult(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
838 DLFolderImpl.class, folderId, _nullDLFolder);
839 }
840
841 closeSession(session);
842 }
843 }
844
845 return dlFolder;
846 }
847
848
855 public List<DLFolder> findByUuid(String uuid) throws SystemException {
856 return findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
857 }
858
859
872 public List<DLFolder> findByUuid(String uuid, int start, int end)
873 throws SystemException {
874 return findByUuid(uuid, start, end, null);
875 }
876
877
891 public List<DLFolder> findByUuid(String uuid, int start, int end,
892 OrderByComparator orderByComparator) throws SystemException {
893 FinderPath finderPath = null;
894 Object[] finderArgs = null;
895
896 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
897 (orderByComparator == null)) {
898 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID;
899 finderArgs = new Object[] { uuid };
900 }
901 else {
902 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID;
903 finderArgs = new Object[] { uuid, start, end, orderByComparator };
904 }
905
906 List<DLFolder> list = (List<DLFolder>)FinderCacheUtil.getResult(finderPath,
907 finderArgs, this);
908
909 if ((list != null) && !list.isEmpty()) {
910 for (DLFolder dlFolder : list) {
911 if (!Validator.equals(uuid, dlFolder.getUuid())) {
912 list = null;
913
914 break;
915 }
916 }
917 }
918
919 if (list == null) {
920 StringBundler query = null;
921
922 if (orderByComparator != null) {
923 query = new StringBundler(3 +
924 (orderByComparator.getOrderByFields().length * 3));
925 }
926 else {
927 query = new StringBundler(3);
928 }
929
930 query.append(_SQL_SELECT_DLFOLDER_WHERE);
931
932 if (uuid == null) {
933 query.append(_FINDER_COLUMN_UUID_UUID_1);
934 }
935 else {
936 if (uuid.equals(StringPool.BLANK)) {
937 query.append(_FINDER_COLUMN_UUID_UUID_3);
938 }
939 else {
940 query.append(_FINDER_COLUMN_UUID_UUID_2);
941 }
942 }
943
944 if (orderByComparator != null) {
945 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
946 orderByComparator);
947 }
948
949 else {
950 query.append(DLFolderModelImpl.ORDER_BY_JPQL);
951 }
952
953 String sql = query.toString();
954
955 Session session = null;
956
957 try {
958 session = openSession();
959
960 Query q = session.createQuery(sql);
961
962 QueryPos qPos = QueryPos.getInstance(q);
963
964 if (uuid != null) {
965 qPos.add(uuid);
966 }
967
968 list = (List<DLFolder>)QueryUtil.list(q, getDialect(), start,
969 end);
970 }
971 catch (Exception e) {
972 throw processException(e);
973 }
974 finally {
975 if (list == null) {
976 FinderCacheUtil.removeResult(finderPath, finderArgs);
977 }
978 else {
979 cacheResult(list);
980
981 FinderCacheUtil.putResult(finderPath, finderArgs, list);
982 }
983
984 closeSession(session);
985 }
986 }
987
988 return list;
989 }
990
991
1004 public DLFolder findByUuid_First(String uuid,
1005 OrderByComparator orderByComparator)
1006 throws NoSuchFolderException, SystemException {
1007 List<DLFolder> list = findByUuid(uuid, 0, 1, orderByComparator);
1008
1009 if (list.isEmpty()) {
1010 StringBundler msg = new StringBundler(4);
1011
1012 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1013
1014 msg.append("uuid=");
1015 msg.append(uuid);
1016
1017 msg.append(StringPool.CLOSE_CURLY_BRACE);
1018
1019 throw new NoSuchFolderException(msg.toString());
1020 }
1021 else {
1022 return list.get(0);
1023 }
1024 }
1025
1026
1039 public DLFolder findByUuid_Last(String uuid,
1040 OrderByComparator orderByComparator)
1041 throws NoSuchFolderException, SystemException {
1042 int count = countByUuid(uuid);
1043
1044 List<DLFolder> list = findByUuid(uuid, count - 1, count,
1045 orderByComparator);
1046
1047 if (list.isEmpty()) {
1048 StringBundler msg = new StringBundler(4);
1049
1050 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1051
1052 msg.append("uuid=");
1053 msg.append(uuid);
1054
1055 msg.append(StringPool.CLOSE_CURLY_BRACE);
1056
1057 throw new NoSuchFolderException(msg.toString());
1058 }
1059 else {
1060 return list.get(0);
1061 }
1062 }
1063
1064
1078 public DLFolder[] findByUuid_PrevAndNext(long folderId, String uuid,
1079 OrderByComparator orderByComparator)
1080 throws NoSuchFolderException, SystemException {
1081 DLFolder dlFolder = findByPrimaryKey(folderId);
1082
1083 Session session = null;
1084
1085 try {
1086 session = openSession();
1087
1088 DLFolder[] array = new DLFolderImpl[3];
1089
1090 array[0] = getByUuid_PrevAndNext(session, dlFolder, uuid,
1091 orderByComparator, true);
1092
1093 array[1] = dlFolder;
1094
1095 array[2] = getByUuid_PrevAndNext(session, dlFolder, uuid,
1096 orderByComparator, false);
1097
1098 return array;
1099 }
1100 catch (Exception e) {
1101 throw processException(e);
1102 }
1103 finally {
1104 closeSession(session);
1105 }
1106 }
1107
1108 protected DLFolder getByUuid_PrevAndNext(Session session,
1109 DLFolder dlFolder, String uuid, OrderByComparator orderByComparator,
1110 boolean previous) {
1111 StringBundler query = null;
1112
1113 if (orderByComparator != null) {
1114 query = new StringBundler(6 +
1115 (orderByComparator.getOrderByFields().length * 6));
1116 }
1117 else {
1118 query = new StringBundler(3);
1119 }
1120
1121 query.append(_SQL_SELECT_DLFOLDER_WHERE);
1122
1123 if (uuid == null) {
1124 query.append(_FINDER_COLUMN_UUID_UUID_1);
1125 }
1126 else {
1127 if (uuid.equals(StringPool.BLANK)) {
1128 query.append(_FINDER_COLUMN_UUID_UUID_3);
1129 }
1130 else {
1131 query.append(_FINDER_COLUMN_UUID_UUID_2);
1132 }
1133 }
1134
1135 if (orderByComparator != null) {
1136 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1137
1138 if (orderByConditionFields.length > 0) {
1139 query.append(WHERE_AND);
1140 }
1141
1142 for (int i = 0; i < orderByConditionFields.length; i++) {
1143 query.append(_ORDER_BY_ENTITY_ALIAS);
1144 query.append(orderByConditionFields[i]);
1145
1146 if ((i + 1) < orderByConditionFields.length) {
1147 if (orderByComparator.isAscending() ^ previous) {
1148 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1149 }
1150 else {
1151 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1152 }
1153 }
1154 else {
1155 if (orderByComparator.isAscending() ^ previous) {
1156 query.append(WHERE_GREATER_THAN);
1157 }
1158 else {
1159 query.append(WHERE_LESSER_THAN);
1160 }
1161 }
1162 }
1163
1164 query.append(ORDER_BY_CLAUSE);
1165
1166 String[] orderByFields = orderByComparator.getOrderByFields();
1167
1168 for (int i = 0; i < orderByFields.length; i++) {
1169 query.append(_ORDER_BY_ENTITY_ALIAS);
1170 query.append(orderByFields[i]);
1171
1172 if ((i + 1) < orderByFields.length) {
1173 if (orderByComparator.isAscending() ^ previous) {
1174 query.append(ORDER_BY_ASC_HAS_NEXT);
1175 }
1176 else {
1177 query.append(ORDER_BY_DESC_HAS_NEXT);
1178 }
1179 }
1180 else {
1181 if (orderByComparator.isAscending() ^ previous) {
1182 query.append(ORDER_BY_ASC);
1183 }
1184 else {
1185 query.append(ORDER_BY_DESC);
1186 }
1187 }
1188 }
1189 }
1190
1191 else {
1192 query.append(DLFolderModelImpl.ORDER_BY_JPQL);
1193 }
1194
1195 String sql = query.toString();
1196
1197 Query q = session.createQuery(sql);
1198
1199 q.setFirstResult(0);
1200 q.setMaxResults(2);
1201
1202 QueryPos qPos = QueryPos.getInstance(q);
1203
1204 if (uuid != null) {
1205 qPos.add(uuid);
1206 }
1207
1208 if (orderByComparator != null) {
1209 Object[] values = orderByComparator.getOrderByConditionValues(dlFolder);
1210
1211 for (Object value : values) {
1212 qPos.add(value);
1213 }
1214 }
1215
1216 List<DLFolder> list = q.list();
1217
1218 if (list.size() == 2) {
1219 return list.get(1);
1220 }
1221 else {
1222 return null;
1223 }
1224 }
1225
1226
1235 public DLFolder findByUUID_G(String uuid, long groupId)
1236 throws NoSuchFolderException, SystemException {
1237 DLFolder dlFolder = fetchByUUID_G(uuid, groupId);
1238
1239 if (dlFolder == null) {
1240 StringBundler msg = new StringBundler(6);
1241
1242 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1243
1244 msg.append("uuid=");
1245 msg.append(uuid);
1246
1247 msg.append(", groupId=");
1248 msg.append(groupId);
1249
1250 msg.append(StringPool.CLOSE_CURLY_BRACE);
1251
1252 if (_log.isWarnEnabled()) {
1253 _log.warn(msg.toString());
1254 }
1255
1256 throw new NoSuchFolderException(msg.toString());
1257 }
1258
1259 return dlFolder;
1260 }
1261
1262
1270 public DLFolder fetchByUUID_G(String uuid, long groupId)
1271 throws SystemException {
1272 return fetchByUUID_G(uuid, groupId, true);
1273 }
1274
1275
1284 public DLFolder fetchByUUID_G(String uuid, long groupId,
1285 boolean retrieveFromCache) throws SystemException {
1286 Object[] finderArgs = new Object[] { uuid, groupId };
1287
1288 Object result = null;
1289
1290 if (retrieveFromCache) {
1291 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_UUID_G,
1292 finderArgs, this);
1293 }
1294
1295 if (result instanceof DLFolder) {
1296 DLFolder dlFolder = (DLFolder)result;
1297
1298 if (!Validator.equals(uuid, dlFolder.getUuid()) ||
1299 (groupId != dlFolder.getGroupId())) {
1300 result = null;
1301 }
1302 }
1303
1304 if (result == null) {
1305 StringBundler query = new StringBundler(4);
1306
1307 query.append(_SQL_SELECT_DLFOLDER_WHERE);
1308
1309 if (uuid == null) {
1310 query.append(_FINDER_COLUMN_UUID_G_UUID_1);
1311 }
1312 else {
1313 if (uuid.equals(StringPool.BLANK)) {
1314 query.append(_FINDER_COLUMN_UUID_G_UUID_3);
1315 }
1316 else {
1317 query.append(_FINDER_COLUMN_UUID_G_UUID_2);
1318 }
1319 }
1320
1321 query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
1322
1323 query.append(DLFolderModelImpl.ORDER_BY_JPQL);
1324
1325 String sql = query.toString();
1326
1327 Session session = null;
1328
1329 try {
1330 session = openSession();
1331
1332 Query q = session.createQuery(sql);
1333
1334 QueryPos qPos = QueryPos.getInstance(q);
1335
1336 if (uuid != null) {
1337 qPos.add(uuid);
1338 }
1339
1340 qPos.add(groupId);
1341
1342 List<DLFolder> list = q.list();
1343
1344 result = list;
1345
1346 DLFolder dlFolder = null;
1347
1348 if (list.isEmpty()) {
1349 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
1350 finderArgs, list);
1351 }
1352 else {
1353 dlFolder = list.get(0);
1354
1355 cacheResult(dlFolder);
1356
1357 if ((dlFolder.getUuid() == null) ||
1358 !dlFolder.getUuid().equals(uuid) ||
1359 (dlFolder.getGroupId() != groupId)) {
1360 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
1361 finderArgs, dlFolder);
1362 }
1363 }
1364
1365 return dlFolder;
1366 }
1367 catch (Exception e) {
1368 throw processException(e);
1369 }
1370 finally {
1371 if (result == null) {
1372 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
1373 finderArgs);
1374 }
1375
1376 closeSession(session);
1377 }
1378 }
1379 else {
1380 if (result instanceof List<?>) {
1381 return null;
1382 }
1383 else {
1384 return (DLFolder)result;
1385 }
1386 }
1387 }
1388
1389
1396 public List<DLFolder> findByGroupId(long groupId) throws SystemException {
1397 return findByGroupId(groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1398 }
1399
1400
1413 public List<DLFolder> findByGroupId(long groupId, int start, int end)
1414 throws SystemException {
1415 return findByGroupId(groupId, start, end, null);
1416 }
1417
1418
1432 public List<DLFolder> findByGroupId(long groupId, int start, int end,
1433 OrderByComparator orderByComparator) throws SystemException {
1434 FinderPath finderPath = null;
1435 Object[] finderArgs = null;
1436
1437 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1438 (orderByComparator == null)) {
1439 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID;
1440 finderArgs = new Object[] { groupId };
1441 }
1442 else {
1443 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID;
1444 finderArgs = new Object[] { groupId, start, end, orderByComparator };
1445 }
1446
1447 List<DLFolder> list = (List<DLFolder>)FinderCacheUtil.getResult(finderPath,
1448 finderArgs, this);
1449
1450 if ((list != null) && !list.isEmpty()) {
1451 for (DLFolder dlFolder : list) {
1452 if ((groupId != dlFolder.getGroupId())) {
1453 list = null;
1454
1455 break;
1456 }
1457 }
1458 }
1459
1460 if (list == null) {
1461 StringBundler query = null;
1462
1463 if (orderByComparator != null) {
1464 query = new StringBundler(3 +
1465 (orderByComparator.getOrderByFields().length * 3));
1466 }
1467 else {
1468 query = new StringBundler(3);
1469 }
1470
1471 query.append(_SQL_SELECT_DLFOLDER_WHERE);
1472
1473 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1474
1475 if (orderByComparator != null) {
1476 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1477 orderByComparator);
1478 }
1479
1480 else {
1481 query.append(DLFolderModelImpl.ORDER_BY_JPQL);
1482 }
1483
1484 String sql = query.toString();
1485
1486 Session session = null;
1487
1488 try {
1489 session = openSession();
1490
1491 Query q = session.createQuery(sql);
1492
1493 QueryPos qPos = QueryPos.getInstance(q);
1494
1495 qPos.add(groupId);
1496
1497 list = (List<DLFolder>)QueryUtil.list(q, getDialect(), start,
1498 end);
1499 }
1500 catch (Exception e) {
1501 throw processException(e);
1502 }
1503 finally {
1504 if (list == null) {
1505 FinderCacheUtil.removeResult(finderPath, finderArgs);
1506 }
1507 else {
1508 cacheResult(list);
1509
1510 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1511 }
1512
1513 closeSession(session);
1514 }
1515 }
1516
1517 return list;
1518 }
1519
1520
1533 public DLFolder findByGroupId_First(long groupId,
1534 OrderByComparator orderByComparator)
1535 throws NoSuchFolderException, SystemException {
1536 List<DLFolder> list = findByGroupId(groupId, 0, 1, orderByComparator);
1537
1538 if (list.isEmpty()) {
1539 StringBundler msg = new StringBundler(4);
1540
1541 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1542
1543 msg.append("groupId=");
1544 msg.append(groupId);
1545
1546 msg.append(StringPool.CLOSE_CURLY_BRACE);
1547
1548 throw new NoSuchFolderException(msg.toString());
1549 }
1550 else {
1551 return list.get(0);
1552 }
1553 }
1554
1555
1568 public DLFolder findByGroupId_Last(long groupId,
1569 OrderByComparator orderByComparator)
1570 throws NoSuchFolderException, SystemException {
1571 int count = countByGroupId(groupId);
1572
1573 List<DLFolder> list = findByGroupId(groupId, count - 1, count,
1574 orderByComparator);
1575
1576 if (list.isEmpty()) {
1577 StringBundler msg = new StringBundler(4);
1578
1579 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1580
1581 msg.append("groupId=");
1582 msg.append(groupId);
1583
1584 msg.append(StringPool.CLOSE_CURLY_BRACE);
1585
1586 throw new NoSuchFolderException(msg.toString());
1587 }
1588 else {
1589 return list.get(0);
1590 }
1591 }
1592
1593
1607 public DLFolder[] findByGroupId_PrevAndNext(long folderId, long groupId,
1608 OrderByComparator orderByComparator)
1609 throws NoSuchFolderException, SystemException {
1610 DLFolder dlFolder = findByPrimaryKey(folderId);
1611
1612 Session session = null;
1613
1614 try {
1615 session = openSession();
1616
1617 DLFolder[] array = new DLFolderImpl[3];
1618
1619 array[0] = getByGroupId_PrevAndNext(session, dlFolder, groupId,
1620 orderByComparator, true);
1621
1622 array[1] = dlFolder;
1623
1624 array[2] = getByGroupId_PrevAndNext(session, dlFolder, groupId,
1625 orderByComparator, false);
1626
1627 return array;
1628 }
1629 catch (Exception e) {
1630 throw processException(e);
1631 }
1632 finally {
1633 closeSession(session);
1634 }
1635 }
1636
1637 protected DLFolder getByGroupId_PrevAndNext(Session session,
1638 DLFolder dlFolder, long groupId, OrderByComparator orderByComparator,
1639 boolean previous) {
1640 StringBundler query = null;
1641
1642 if (orderByComparator != null) {
1643 query = new StringBundler(6 +
1644 (orderByComparator.getOrderByFields().length * 6));
1645 }
1646 else {
1647 query = new StringBundler(3);
1648 }
1649
1650 query.append(_SQL_SELECT_DLFOLDER_WHERE);
1651
1652 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1653
1654 if (orderByComparator != null) {
1655 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1656
1657 if (orderByConditionFields.length > 0) {
1658 query.append(WHERE_AND);
1659 }
1660
1661 for (int i = 0; i < orderByConditionFields.length; i++) {
1662 query.append(_ORDER_BY_ENTITY_ALIAS);
1663 query.append(orderByConditionFields[i]);
1664
1665 if ((i + 1) < orderByConditionFields.length) {
1666 if (orderByComparator.isAscending() ^ previous) {
1667 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1668 }
1669 else {
1670 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1671 }
1672 }
1673 else {
1674 if (orderByComparator.isAscending() ^ previous) {
1675 query.append(WHERE_GREATER_THAN);
1676 }
1677 else {
1678 query.append(WHERE_LESSER_THAN);
1679 }
1680 }
1681 }
1682
1683 query.append(ORDER_BY_CLAUSE);
1684
1685 String[] orderByFields = orderByComparator.getOrderByFields();
1686
1687 for (int i = 0; i < orderByFields.length; i++) {
1688 query.append(_ORDER_BY_ENTITY_ALIAS);
1689 query.append(orderByFields[i]);
1690
1691 if ((i + 1) < orderByFields.length) {
1692 if (orderByComparator.isAscending() ^ previous) {
1693 query.append(ORDER_BY_ASC_HAS_NEXT);
1694 }
1695 else {
1696 query.append(ORDER_BY_DESC_HAS_NEXT);
1697 }
1698 }
1699 else {
1700 if (orderByComparator.isAscending() ^ previous) {
1701 query.append(ORDER_BY_ASC);
1702 }
1703 else {
1704 query.append(ORDER_BY_DESC);
1705 }
1706 }
1707 }
1708 }
1709
1710 else {
1711 query.append(DLFolderModelImpl.ORDER_BY_JPQL);
1712 }
1713
1714 String sql = query.toString();
1715
1716 Query q = session.createQuery(sql);
1717
1718 q.setFirstResult(0);
1719 q.setMaxResults(2);
1720
1721 QueryPos qPos = QueryPos.getInstance(q);
1722
1723 qPos.add(groupId);
1724
1725 if (orderByComparator != null) {
1726 Object[] values = orderByComparator.getOrderByConditionValues(dlFolder);
1727
1728 for (Object value : values) {
1729 qPos.add(value);
1730 }
1731 }
1732
1733 List<DLFolder> list = q.list();
1734
1735 if (list.size() == 2) {
1736 return list.get(1);
1737 }
1738 else {
1739 return null;
1740 }
1741 }
1742
1743
1750 public List<DLFolder> filterFindByGroupId(long groupId)
1751 throws SystemException {
1752 return filterFindByGroupId(groupId, QueryUtil.ALL_POS,
1753 QueryUtil.ALL_POS, null);
1754 }
1755
1756
1769 public List<DLFolder> filterFindByGroupId(long groupId, int start, int end)
1770 throws SystemException {
1771 return filterFindByGroupId(groupId, start, end, null);
1772 }
1773
1774
1788 public List<DLFolder> filterFindByGroupId(long groupId, int start, int end,
1789 OrderByComparator orderByComparator) throws SystemException {
1790 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
1791 return findByGroupId(groupId, start, end, orderByComparator);
1792 }
1793
1794 StringBundler query = null;
1795
1796 if (orderByComparator != null) {
1797 query = new StringBundler(3 +
1798 (orderByComparator.getOrderByFields().length * 3));
1799 }
1800 else {
1801 query = new StringBundler(3);
1802 }
1803
1804 if (getDB().isSupportsInlineDistinct()) {
1805 query.append(_FILTER_SQL_SELECT_DLFOLDER_WHERE);
1806 }
1807 else {
1808 query.append(_FILTER_SQL_SELECT_DLFOLDER_NO_INLINE_DISTINCT_WHERE_1);
1809 }
1810
1811 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1812
1813 if (!getDB().isSupportsInlineDistinct()) {
1814 query.append(_FILTER_SQL_SELECT_DLFOLDER_NO_INLINE_DISTINCT_WHERE_2);
1815 }
1816
1817 if (orderByComparator != null) {
1818 if (getDB().isSupportsInlineDistinct()) {
1819 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1820 orderByComparator);
1821 }
1822 else {
1823 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
1824 orderByComparator);
1825 }
1826 }
1827
1828 else {
1829 if (getDB().isSupportsInlineDistinct()) {
1830 query.append(DLFolderModelImpl.ORDER_BY_JPQL);
1831 }
1832 else {
1833 query.append(DLFolderModelImpl.ORDER_BY_SQL);
1834 }
1835 }
1836
1837 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1838 DLFolder.class.getName(),
1839 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
1840
1841 Session session = null;
1842
1843 try {
1844 session = openSession();
1845
1846 SQLQuery q = session.createSQLQuery(sql);
1847
1848 if (getDB().isSupportsInlineDistinct()) {
1849 q.addEntity(_FILTER_ENTITY_ALIAS, DLFolderImpl.class);
1850 }
1851 else {
1852 q.addEntity(_FILTER_ENTITY_TABLE, DLFolderImpl.class);
1853 }
1854
1855 QueryPos qPos = QueryPos.getInstance(q);
1856
1857 qPos.add(groupId);
1858
1859 return (List<DLFolder>)QueryUtil.list(q, getDialect(), start, end);
1860 }
1861 catch (Exception e) {
1862 throw processException(e);
1863 }
1864 finally {
1865 closeSession(session);
1866 }
1867 }
1868
1869
1879 public DLFolder[] filterFindByGroupId_PrevAndNext(long folderId,
1880 long groupId, OrderByComparator orderByComparator)
1881 throws NoSuchFolderException, SystemException {
1882 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
1883 return findByGroupId_PrevAndNext(folderId, groupId,
1884 orderByComparator);
1885 }
1886
1887 DLFolder dlFolder = findByPrimaryKey(folderId);
1888
1889 Session session = null;
1890
1891 try {
1892 session = openSession();
1893
1894 DLFolder[] array = new DLFolderImpl[3];
1895
1896 array[0] = filterGetByGroupId_PrevAndNext(session, dlFolder,
1897 groupId, orderByComparator, true);
1898
1899 array[1] = dlFolder;
1900
1901 array[2] = filterGetByGroupId_PrevAndNext(session, dlFolder,
1902 groupId, orderByComparator, false);
1903
1904 return array;
1905 }
1906 catch (Exception e) {
1907 throw processException(e);
1908 }
1909 finally {
1910 closeSession(session);
1911 }
1912 }
1913
1914 protected DLFolder filterGetByGroupId_PrevAndNext(Session session,
1915 DLFolder dlFolder, long groupId, OrderByComparator orderByComparator,
1916 boolean previous) {
1917 StringBundler query = null;
1918
1919 if (orderByComparator != null) {
1920 query = new StringBundler(6 +
1921 (orderByComparator.getOrderByFields().length * 6));
1922 }
1923 else {
1924 query = new StringBundler(3);
1925 }
1926
1927 if (getDB().isSupportsInlineDistinct()) {
1928 query.append(_FILTER_SQL_SELECT_DLFOLDER_WHERE);
1929 }
1930 else {
1931 query.append(_FILTER_SQL_SELECT_DLFOLDER_NO_INLINE_DISTINCT_WHERE_1);
1932 }
1933
1934 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1935
1936 if (!getDB().isSupportsInlineDistinct()) {
1937 query.append(_FILTER_SQL_SELECT_DLFOLDER_NO_INLINE_DISTINCT_WHERE_2);
1938 }
1939
1940 if (orderByComparator != null) {
1941 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1942
1943 if (orderByConditionFields.length > 0) {
1944 query.append(WHERE_AND);
1945 }
1946
1947 for (int i = 0; i < orderByConditionFields.length; i++) {
1948 if (getDB().isSupportsInlineDistinct()) {
1949 query.append(_ORDER_BY_ENTITY_ALIAS);
1950 }
1951 else {
1952 query.append(_ORDER_BY_ENTITY_TABLE);
1953 }
1954
1955 query.append(orderByConditionFields[i]);
1956
1957 if ((i + 1) < orderByConditionFields.length) {
1958 if (orderByComparator.isAscending() ^ previous) {
1959 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1960 }
1961 else {
1962 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1963 }
1964 }
1965 else {
1966 if (orderByComparator.isAscending() ^ previous) {
1967 query.append(WHERE_GREATER_THAN);
1968 }
1969 else {
1970 query.append(WHERE_LESSER_THAN);
1971 }
1972 }
1973 }
1974
1975 query.append(ORDER_BY_CLAUSE);
1976
1977 String[] orderByFields = orderByComparator.getOrderByFields();
1978
1979 for (int i = 0; i < orderByFields.length; i++) {
1980 if (getDB().isSupportsInlineDistinct()) {
1981 query.append(_ORDER_BY_ENTITY_ALIAS);
1982 }
1983 else {
1984 query.append(_ORDER_BY_ENTITY_TABLE);
1985 }
1986
1987 query.append(orderByFields[i]);
1988
1989 if ((i + 1) < orderByFields.length) {
1990 if (orderByComparator.isAscending() ^ previous) {
1991 query.append(ORDER_BY_ASC_HAS_NEXT);
1992 }
1993 else {
1994 query.append(ORDER_BY_DESC_HAS_NEXT);
1995 }
1996 }
1997 else {
1998 if (orderByComparator.isAscending() ^ previous) {
1999 query.append(ORDER_BY_ASC);
2000 }
2001 else {
2002 query.append(ORDER_BY_DESC);
2003 }
2004 }
2005 }
2006 }
2007
2008 else {
2009 if (getDB().isSupportsInlineDistinct()) {
2010 query.append(DLFolderModelImpl.ORDER_BY_JPQL);
2011 }
2012 else {
2013 query.append(DLFolderModelImpl.ORDER_BY_SQL);
2014 }
2015 }
2016
2017 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2018 DLFolder.class.getName(),
2019 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2020
2021 SQLQuery q = session.createSQLQuery(sql);
2022
2023 q.setFirstResult(0);
2024 q.setMaxResults(2);
2025
2026 if (getDB().isSupportsInlineDistinct()) {
2027 q.addEntity(_FILTER_ENTITY_ALIAS, DLFolderImpl.class);
2028 }
2029 else {
2030 q.addEntity(_FILTER_ENTITY_TABLE, DLFolderImpl.class);
2031 }
2032
2033 QueryPos qPos = QueryPos.getInstance(q);
2034
2035 qPos.add(groupId);
2036
2037 if (orderByComparator != null) {
2038 Object[] values = orderByComparator.getOrderByConditionValues(dlFolder);
2039
2040 for (Object value : values) {
2041 qPos.add(value);
2042 }
2043 }
2044
2045 List<DLFolder> list = q.list();
2046
2047 if (list.size() == 2) {
2048 return list.get(1);
2049 }
2050 else {
2051 return null;
2052 }
2053 }
2054
2055
2062 public List<DLFolder> findByCompanyId(long companyId)
2063 throws SystemException {
2064 return findByCompanyId(companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
2065 null);
2066 }
2067
2068
2081 public List<DLFolder> findByCompanyId(long companyId, int start, int end)
2082 throws SystemException {
2083 return findByCompanyId(companyId, start, end, null);
2084 }
2085
2086
2100 public List<DLFolder> findByCompanyId(long companyId, int start, int end,
2101 OrderByComparator orderByComparator) throws SystemException {
2102 FinderPath finderPath = null;
2103 Object[] finderArgs = null;
2104
2105 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2106 (orderByComparator == null)) {
2107 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID;
2108 finderArgs = new Object[] { companyId };
2109 }
2110 else {
2111 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID;
2112 finderArgs = new Object[] { companyId, start, end, orderByComparator };
2113 }
2114
2115 List<DLFolder> list = (List<DLFolder>)FinderCacheUtil.getResult(finderPath,
2116 finderArgs, this);
2117
2118 if ((list != null) && !list.isEmpty()) {
2119 for (DLFolder dlFolder : list) {
2120 if ((companyId != dlFolder.getCompanyId())) {
2121 list = null;
2122
2123 break;
2124 }
2125 }
2126 }
2127
2128 if (list == null) {
2129 StringBundler query = null;
2130
2131 if (orderByComparator != null) {
2132 query = new StringBundler(3 +
2133 (orderByComparator.getOrderByFields().length * 3));
2134 }
2135 else {
2136 query = new StringBundler(3);
2137 }
2138
2139 query.append(_SQL_SELECT_DLFOLDER_WHERE);
2140
2141 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
2142
2143 if (orderByComparator != null) {
2144 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2145 orderByComparator);
2146 }
2147
2148 else {
2149 query.append(DLFolderModelImpl.ORDER_BY_JPQL);
2150 }
2151
2152 String sql = query.toString();
2153
2154 Session session = null;
2155
2156 try {
2157 session = openSession();
2158
2159 Query q = session.createQuery(sql);
2160
2161 QueryPos qPos = QueryPos.getInstance(q);
2162
2163 qPos.add(companyId);
2164
2165 list = (List<DLFolder>)QueryUtil.list(q, getDialect(), start,
2166 end);
2167 }
2168 catch (Exception e) {
2169 throw processException(e);
2170 }
2171 finally {
2172 if (list == null) {
2173 FinderCacheUtil.removeResult(finderPath, finderArgs);
2174 }
2175 else {
2176 cacheResult(list);
2177
2178 FinderCacheUtil.putResult(finderPath, finderArgs, list);
2179 }
2180
2181 closeSession(session);
2182 }
2183 }
2184
2185 return list;
2186 }
2187
2188
2201 public DLFolder findByCompanyId_First(long companyId,
2202 OrderByComparator orderByComparator)
2203 throws NoSuchFolderException, SystemException {
2204 List<DLFolder> list = findByCompanyId(companyId, 0, 1, orderByComparator);
2205
2206 if (list.isEmpty()) {
2207 StringBundler msg = new StringBundler(4);
2208
2209 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2210
2211 msg.append("companyId=");
2212 msg.append(companyId);
2213
2214 msg.append(StringPool.CLOSE_CURLY_BRACE);
2215
2216 throw new NoSuchFolderException(msg.toString());
2217 }
2218 else {
2219 return list.get(0);
2220 }
2221 }
2222
2223
2236 public DLFolder findByCompanyId_Last(long companyId,
2237 OrderByComparator orderByComparator)
2238 throws NoSuchFolderException, SystemException {
2239 int count = countByCompanyId(companyId);
2240
2241 List<DLFolder> list = findByCompanyId(companyId, count - 1, count,
2242 orderByComparator);
2243
2244 if (list.isEmpty()) {
2245 StringBundler msg = new StringBundler(4);
2246
2247 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2248
2249 msg.append("companyId=");
2250 msg.append(companyId);
2251
2252 msg.append(StringPool.CLOSE_CURLY_BRACE);
2253
2254 throw new NoSuchFolderException(msg.toString());
2255 }
2256 else {
2257 return list.get(0);
2258 }
2259 }
2260
2261
2275 public DLFolder[] findByCompanyId_PrevAndNext(long folderId,
2276 long companyId, OrderByComparator orderByComparator)
2277 throws NoSuchFolderException, SystemException {
2278 DLFolder dlFolder = findByPrimaryKey(folderId);
2279
2280 Session session = null;
2281
2282 try {
2283 session = openSession();
2284
2285 DLFolder[] array = new DLFolderImpl[3];
2286
2287 array[0] = getByCompanyId_PrevAndNext(session, dlFolder, companyId,
2288 orderByComparator, true);
2289
2290 array[1] = dlFolder;
2291
2292 array[2] = getByCompanyId_PrevAndNext(session, dlFolder, companyId,
2293 orderByComparator, false);
2294
2295 return array;
2296 }
2297 catch (Exception e) {
2298 throw processException(e);
2299 }
2300 finally {
2301 closeSession(session);
2302 }
2303 }
2304
2305 protected DLFolder getByCompanyId_PrevAndNext(Session session,
2306 DLFolder dlFolder, long companyId, OrderByComparator orderByComparator,
2307 boolean previous) {
2308 StringBundler query = null;
2309
2310 if (orderByComparator != null) {
2311 query = new StringBundler(6 +
2312 (orderByComparator.getOrderByFields().length * 6));
2313 }
2314 else {
2315 query = new StringBundler(3);
2316 }
2317
2318 query.append(_SQL_SELECT_DLFOLDER_WHERE);
2319
2320 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
2321
2322 if (orderByComparator != null) {
2323 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2324
2325 if (orderByConditionFields.length > 0) {
2326 query.append(WHERE_AND);
2327 }
2328
2329 for (int i = 0; i < orderByConditionFields.length; i++) {
2330 query.append(_ORDER_BY_ENTITY_ALIAS);
2331 query.append(orderByConditionFields[i]);
2332
2333 if ((i + 1) < orderByConditionFields.length) {
2334 if (orderByComparator.isAscending() ^ previous) {
2335 query.append(WHERE_GREATER_THAN_HAS_NEXT);
2336 }
2337 else {
2338 query.append(WHERE_LESSER_THAN_HAS_NEXT);
2339 }
2340 }
2341 else {
2342 if (orderByComparator.isAscending() ^ previous) {
2343 query.append(WHERE_GREATER_THAN);
2344 }
2345 else {
2346 query.append(WHERE_LESSER_THAN);
2347 }
2348 }
2349 }
2350
2351 query.append(ORDER_BY_CLAUSE);
2352
2353 String[] orderByFields = orderByComparator.getOrderByFields();
2354
2355 for (int i = 0; i < orderByFields.length; i++) {
2356 query.append(_ORDER_BY_ENTITY_ALIAS);
2357 query.append(orderByFields[i]);
2358
2359 if ((i + 1) < orderByFields.length) {
2360 if (orderByComparator.isAscending() ^ previous) {
2361 query.append(ORDER_BY_ASC_HAS_NEXT);
2362 }
2363 else {
2364 query.append(ORDER_BY_DESC_HAS_NEXT);
2365 }
2366 }
2367 else {
2368 if (orderByComparator.isAscending() ^ previous) {
2369 query.append(ORDER_BY_ASC);
2370 }
2371 else {
2372 query.append(ORDER_BY_DESC);
2373 }
2374 }
2375 }
2376 }
2377
2378 else {
2379 query.append(DLFolderModelImpl.ORDER_BY_JPQL);
2380 }
2381
2382 String sql = query.toString();
2383
2384 Query q = session.createQuery(sql);
2385
2386 q.setFirstResult(0);
2387 q.setMaxResults(2);
2388
2389 QueryPos qPos = QueryPos.getInstance(q);
2390
2391 qPos.add(companyId);
2392
2393 if (orderByComparator != null) {
2394 Object[] values = orderByComparator.getOrderByConditionValues(dlFolder);
2395
2396 for (Object value : values) {
2397 qPos.add(value);
2398 }
2399 }
2400
2401 List<DLFolder> list = q.list();
2402
2403 if (list.size() == 2) {
2404 return list.get(1);
2405 }
2406 else {
2407 return null;
2408 }
2409 }
2410
2411
2419 public DLFolder findByRepositoryId(long repositoryId)
2420 throws NoSuchFolderException, SystemException {
2421 DLFolder dlFolder = fetchByRepositoryId(repositoryId);
2422
2423 if (dlFolder == null) {
2424 StringBundler msg = new StringBundler(4);
2425
2426 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2427
2428 msg.append("repositoryId=");
2429 msg.append(repositoryId);
2430
2431 msg.append(StringPool.CLOSE_CURLY_BRACE);
2432
2433 if (_log.isWarnEnabled()) {
2434 _log.warn(msg.toString());
2435 }
2436
2437 throw new NoSuchFolderException(msg.toString());
2438 }
2439
2440 return dlFolder;
2441 }
2442
2443
2450 public DLFolder fetchByRepositoryId(long repositoryId)
2451 throws SystemException {
2452 return fetchByRepositoryId(repositoryId, true);
2453 }
2454
2455
2463 public DLFolder fetchByRepositoryId(long repositoryId,
2464 boolean retrieveFromCache) throws SystemException {
2465 Object[] finderArgs = new Object[] { repositoryId };
2466
2467 Object result = null;
2468
2469 if (retrieveFromCache) {
2470 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_REPOSITORYID,
2471 finderArgs, this);
2472 }
2473
2474 if (result instanceof DLFolder) {
2475 DLFolder dlFolder = (DLFolder)result;
2476
2477 if ((repositoryId != dlFolder.getRepositoryId())) {
2478 result = null;
2479 }
2480 }
2481
2482 if (result == null) {
2483 StringBundler query = new StringBundler(3);
2484
2485 query.append(_SQL_SELECT_DLFOLDER_WHERE);
2486
2487 query.append(_FINDER_COLUMN_REPOSITORYID_REPOSITORYID_2);
2488
2489 query.append(DLFolderModelImpl.ORDER_BY_JPQL);
2490
2491 String sql = query.toString();
2492
2493 Session session = null;
2494
2495 try {
2496 session = openSession();
2497
2498 Query q = session.createQuery(sql);
2499
2500 QueryPos qPos = QueryPos.getInstance(q);
2501
2502 qPos.add(repositoryId);
2503
2504 List<DLFolder> list = q.list();
2505
2506 result = list;
2507
2508 DLFolder dlFolder = null;
2509
2510 if (list.isEmpty()) {
2511 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_REPOSITORYID,
2512 finderArgs, list);
2513 }
2514 else {
2515 dlFolder = list.get(0);
2516
2517 cacheResult(dlFolder);
2518
2519 if ((dlFolder.getRepositoryId() != repositoryId)) {
2520 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_REPOSITORYID,
2521 finderArgs, dlFolder);
2522 }
2523 }
2524
2525 return dlFolder;
2526 }
2527 catch (Exception e) {
2528 throw processException(e);
2529 }
2530 finally {
2531 if (result == null) {
2532 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_REPOSITORYID,
2533 finderArgs);
2534 }
2535
2536 closeSession(session);
2537 }
2538 }
2539 else {
2540 if (result instanceof List<?>) {
2541 return null;
2542 }
2543 else {
2544 return (DLFolder)result;
2545 }
2546 }
2547 }
2548
2549
2557 public List<DLFolder> findByG_P(long groupId, long parentFolderId)
2558 throws SystemException {
2559 return findByG_P(groupId, parentFolderId, QueryUtil.ALL_POS,
2560 QueryUtil.ALL_POS, null);
2561 }
2562
2563
2577 public List<DLFolder> findByG_P(long groupId, long parentFolderId,
2578 int start, int end) throws SystemException {
2579 return findByG_P(groupId, parentFolderId, start, end, null);
2580 }
2581
2582
2597 public List<DLFolder> findByG_P(long groupId, long parentFolderId,
2598 int start, int end, OrderByComparator orderByComparator)
2599 throws SystemException {
2600 FinderPath finderPath = null;
2601 Object[] finderArgs = null;
2602
2603 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2604 (orderByComparator == null)) {
2605 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P;
2606 finderArgs = new Object[] { groupId, parentFolderId };
2607 }
2608 else {
2609 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_P;
2610 finderArgs = new Object[] {
2611 groupId, parentFolderId,
2612
2613 start, end, orderByComparator
2614 };
2615 }
2616
2617 List<DLFolder> list = (List<DLFolder>)FinderCacheUtil.getResult(finderPath,
2618 finderArgs, this);
2619
2620 if ((list != null) && !list.isEmpty()) {
2621 for (DLFolder dlFolder : list) {
2622 if ((groupId != dlFolder.getGroupId()) ||
2623 (parentFolderId != dlFolder.getParentFolderId())) {
2624 list = null;
2625
2626 break;
2627 }
2628 }
2629 }
2630
2631 if (list == null) {
2632 StringBundler query = null;
2633
2634 if (orderByComparator != null) {
2635 query = new StringBundler(4 +
2636 (orderByComparator.getOrderByFields().length * 3));
2637 }
2638 else {
2639 query = new StringBundler(4);
2640 }
2641
2642 query.append(_SQL_SELECT_DLFOLDER_WHERE);
2643
2644 query.append(_FINDER_COLUMN_G_P_GROUPID_2);
2645
2646 query.append(_FINDER_COLUMN_G_P_PARENTFOLDERID_2);
2647
2648 if (orderByComparator != null) {
2649 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2650 orderByComparator);
2651 }
2652
2653 else {
2654 query.append(DLFolderModelImpl.ORDER_BY_JPQL);
2655 }
2656
2657 String sql = query.toString();
2658
2659 Session session = null;
2660
2661 try {
2662 session = openSession();
2663
2664 Query q = session.createQuery(sql);
2665
2666 QueryPos qPos = QueryPos.getInstance(q);
2667
2668 qPos.add(groupId);
2669
2670 qPos.add(parentFolderId);
2671
2672 list = (List<DLFolder>)QueryUtil.list(q, getDialect(), start,
2673 end);
2674 }
2675 catch (Exception e) {
2676 throw processException(e);
2677 }
2678 finally {
2679 if (list == null) {
2680 FinderCacheUtil.removeResult(finderPath, finderArgs);
2681 }
2682 else {
2683 cacheResult(list);
2684
2685 FinderCacheUtil.putResult(finderPath, finderArgs, list);
2686 }
2687
2688 closeSession(session);
2689 }
2690 }
2691
2692 return list;
2693 }
2694
2695
2709 public DLFolder findByG_P_First(long groupId, long parentFolderId,
2710 OrderByComparator orderByComparator)
2711 throws NoSuchFolderException, SystemException {
2712 List<DLFolder> list = findByG_P(groupId, parentFolderId, 0, 1,
2713 orderByComparator);
2714
2715 if (list.isEmpty()) {
2716 StringBundler msg = new StringBundler(6);
2717
2718 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2719
2720 msg.append("groupId=");
2721 msg.append(groupId);
2722
2723 msg.append(", parentFolderId=");
2724 msg.append(parentFolderId);
2725
2726 msg.append(StringPool.CLOSE_CURLY_BRACE);
2727
2728 throw new NoSuchFolderException(msg.toString());
2729 }
2730 else {
2731 return list.get(0);
2732 }
2733 }
2734
2735
2749 public DLFolder findByG_P_Last(long groupId, long parentFolderId,
2750 OrderByComparator orderByComparator)
2751 throws NoSuchFolderException, SystemException {
2752 int count = countByG_P(groupId, parentFolderId);
2753
2754 List<DLFolder> list = findByG_P(groupId, parentFolderId, count - 1,
2755 count, orderByComparator);
2756
2757 if (list.isEmpty()) {
2758 StringBundler msg = new StringBundler(6);
2759
2760 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2761
2762 msg.append("groupId=");
2763 msg.append(groupId);
2764
2765 msg.append(", parentFolderId=");
2766 msg.append(parentFolderId);
2767
2768 msg.append(StringPool.CLOSE_CURLY_BRACE);
2769
2770 throw new NoSuchFolderException(msg.toString());
2771 }
2772 else {
2773 return list.get(0);
2774 }
2775 }
2776
2777
2792 public DLFolder[] findByG_P_PrevAndNext(long folderId, long groupId,
2793 long parentFolderId, OrderByComparator orderByComparator)
2794 throws NoSuchFolderException, SystemException {
2795 DLFolder dlFolder = findByPrimaryKey(folderId);
2796
2797 Session session = null;
2798
2799 try {
2800 session = openSession();
2801
2802 DLFolder[] array = new DLFolderImpl[3];
2803
2804 array[0] = getByG_P_PrevAndNext(session, dlFolder, groupId,
2805 parentFolderId, orderByComparator, true);
2806
2807 array[1] = dlFolder;
2808
2809 array[2] = getByG_P_PrevAndNext(session, dlFolder, groupId,
2810 parentFolderId, orderByComparator, false);
2811
2812 return array;
2813 }
2814 catch (Exception e) {
2815 throw processException(e);
2816 }
2817 finally {
2818 closeSession(session);
2819 }
2820 }
2821
2822 protected DLFolder getByG_P_PrevAndNext(Session session, DLFolder dlFolder,
2823 long groupId, long parentFolderId, OrderByComparator orderByComparator,
2824 boolean previous) {
2825 StringBundler query = null;
2826
2827 if (orderByComparator != null) {
2828 query = new StringBundler(6 +
2829 (orderByComparator.getOrderByFields().length * 6));
2830 }
2831 else {
2832 query = new StringBundler(3);
2833 }
2834
2835 query.append(_SQL_SELECT_DLFOLDER_WHERE);
2836
2837 query.append(_FINDER_COLUMN_G_P_GROUPID_2);
2838
2839 query.append(_FINDER_COLUMN_G_P_PARENTFOLDERID_2);
2840
2841 if (orderByComparator != null) {
2842 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2843
2844 if (orderByConditionFields.length > 0) {
2845 query.append(WHERE_AND);
2846 }
2847
2848 for (int i = 0; i < orderByConditionFields.length; i++) {
2849 query.append(_ORDER_BY_ENTITY_ALIAS);
2850 query.append(orderByConditionFields[i]);
2851
2852 if ((i + 1) < orderByConditionFields.length) {
2853 if (orderByComparator.isAscending() ^ previous) {
2854 query.append(WHERE_GREATER_THAN_HAS_NEXT);
2855 }
2856 else {
2857 query.append(WHERE_LESSER_THAN_HAS_NEXT);
2858 }
2859 }
2860 else {
2861 if (orderByComparator.isAscending() ^ previous) {
2862 query.append(WHERE_GREATER_THAN);
2863 }
2864 else {
2865 query.append(WHERE_LESSER_THAN);
2866 }
2867 }
2868 }
2869
2870 query.append(ORDER_BY_CLAUSE);
2871
2872 String[] orderByFields = orderByComparator.getOrderByFields();
2873
2874 for (int i = 0; i < orderByFields.length; i++) {
2875 query.append(_ORDER_BY_ENTITY_ALIAS);
2876 query.append(orderByFields[i]);
2877
2878 if ((i + 1) < orderByFields.length) {
2879 if (orderByComparator.isAscending() ^ previous) {
2880 query.append(ORDER_BY_ASC_HAS_NEXT);
2881 }
2882 else {
2883 query.append(ORDER_BY_DESC_HAS_NEXT);
2884 }
2885 }
2886 else {
2887 if (orderByComparator.isAscending() ^ previous) {
2888 query.append(ORDER_BY_ASC);
2889 }
2890 else {
2891 query.append(ORDER_BY_DESC);
2892 }
2893 }
2894 }
2895 }
2896
2897 else {
2898 query.append(DLFolderModelImpl.ORDER_BY_JPQL);
2899 }
2900
2901 String sql = query.toString();
2902
2903 Query q = session.createQuery(sql);
2904
2905 q.setFirstResult(0);
2906 q.setMaxResults(2);
2907
2908 QueryPos qPos = QueryPos.getInstance(q);
2909
2910 qPos.add(groupId);
2911
2912 qPos.add(parentFolderId);
2913
2914 if (orderByComparator != null) {
2915 Object[] values = orderByComparator.getOrderByConditionValues(dlFolder);
2916
2917 for (Object value : values) {
2918 qPos.add(value);
2919 }
2920 }
2921
2922 List<DLFolder> list = q.list();
2923
2924 if (list.size() == 2) {
2925 return list.get(1);
2926 }
2927 else {
2928 return null;
2929 }
2930 }
2931
2932
2940 public List<DLFolder> filterFindByG_P(long groupId, long parentFolderId)
2941 throws SystemException {
2942 return filterFindByG_P(groupId, parentFolderId, QueryUtil.ALL_POS,
2943 QueryUtil.ALL_POS, null);
2944 }
2945
2946
2960 public List<DLFolder> filterFindByG_P(long groupId, long parentFolderId,
2961 int start, int end) throws SystemException {
2962 return filterFindByG_P(groupId, parentFolderId, start, end, null);
2963 }
2964
2965
2980 public List<DLFolder> filterFindByG_P(long groupId, long parentFolderId,
2981 int start, int end, OrderByComparator orderByComparator)
2982 throws SystemException {
2983 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2984 return findByG_P(groupId, parentFolderId, start, end,
2985 orderByComparator);
2986 }
2987
2988 StringBundler query = null;
2989
2990 if (orderByComparator != null) {
2991 query = new StringBundler(4 +
2992 (orderByComparator.getOrderByFields().length * 3));
2993 }
2994 else {
2995 query = new StringBundler(4);
2996 }
2997
2998 if (getDB().isSupportsInlineDistinct()) {
2999 query.append(_FILTER_SQL_SELECT_DLFOLDER_WHERE);
3000 }
3001 else {
3002 query.append(_FILTER_SQL_SELECT_DLFOLDER_NO_INLINE_DISTINCT_WHERE_1);
3003 }
3004
3005 query.append(_FINDER_COLUMN_G_P_GROUPID_2);
3006
3007 query.append(_FINDER_COLUMN_G_P_PARENTFOLDERID_2);
3008
3009 if (!getDB().isSupportsInlineDistinct()) {
3010 query.append(_FILTER_SQL_SELECT_DLFOLDER_NO_INLINE_DISTINCT_WHERE_2);
3011 }
3012
3013 if (orderByComparator != null) {
3014 if (getDB().isSupportsInlineDistinct()) {
3015 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3016 orderByComparator);
3017 }
3018 else {
3019 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
3020 orderByComparator);
3021 }
3022 }
3023
3024 else {
3025 if (getDB().isSupportsInlineDistinct()) {
3026 query.append(DLFolderModelImpl.ORDER_BY_JPQL);
3027 }
3028 else {
3029 query.append(DLFolderModelImpl.ORDER_BY_SQL);
3030 }
3031 }
3032
3033 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
3034 DLFolder.class.getName(),
3035 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
3036
3037 Session session = null;
3038
3039 try {
3040 session = openSession();
3041
3042 SQLQuery q = session.createSQLQuery(sql);
3043
3044 if (getDB().isSupportsInlineDistinct()) {
3045 q.addEntity(_FILTER_ENTITY_ALIAS, DLFolderImpl.class);
3046 }
3047 else {
3048 q.addEntity(_FILTER_ENTITY_TABLE, DLFolderImpl.class);
3049 }
3050
3051 QueryPos qPos = QueryPos.getInstance(q);
3052
3053 qPos.add(groupId);
3054
3055 qPos.add(parentFolderId);
3056
3057 return (List<DLFolder>)QueryUtil.list(q, getDialect(), start, end);
3058 }
3059 catch (Exception e) {
3060 throw processException(e);
3061 }
3062 finally {
3063 closeSession(session);
3064 }
3065 }
3066
3067
3078 public DLFolder[] filterFindByG_P_PrevAndNext(long folderId, long groupId,
3079 long parentFolderId, OrderByComparator orderByComparator)
3080 throws NoSuchFolderException, SystemException {
3081 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
3082 return findByG_P_PrevAndNext(folderId, groupId, parentFolderId,
3083 orderByComparator);
3084 }
3085
3086 DLFolder dlFolder = findByPrimaryKey(folderId);
3087
3088 Session session = null;
3089
3090 try {
3091 session = openSession();
3092
3093 DLFolder[] array = new DLFolderImpl[3];
3094
3095 array[0] = filterGetByG_P_PrevAndNext(session, dlFolder, groupId,
3096 parentFolderId, orderByComparator, true);
3097
3098 array[1] = dlFolder;
3099
3100 array[2] = filterGetByG_P_PrevAndNext(session, dlFolder, groupId,
3101 parentFolderId, orderByComparator, false);
3102
3103 return array;
3104 }
3105 catch (Exception e) {
3106 throw processException(e);
3107 }
3108 finally {
3109 closeSession(session);
3110 }
3111 }
3112
3113 protected DLFolder filterGetByG_P_PrevAndNext(Session session,
3114 DLFolder dlFolder, long groupId, long parentFolderId,
3115 OrderByComparator orderByComparator, boolean previous) {
3116 StringBundler query = null;
3117
3118 if (orderByComparator != null) {
3119 query = new StringBundler(6 +
3120 (orderByComparator.getOrderByFields().length * 6));
3121 }
3122 else {
3123 query = new StringBundler(3);
3124 }
3125
3126 if (getDB().isSupportsInlineDistinct()) {
3127 query.append(_FILTER_SQL_SELECT_DLFOLDER_WHERE);
3128 }
3129 else {
3130 query.append(_FILTER_SQL_SELECT_DLFOLDER_NO_INLINE_DISTINCT_WHERE_1);
3131 }
3132
3133 query.append(_FINDER_COLUMN_G_P_GROUPID_2);
3134
3135 query.append(_FINDER_COLUMN_G_P_PARENTFOLDERID_2);
3136
3137 if (!getDB().isSupportsInlineDistinct()) {
3138 query.append(_FILTER_SQL_SELECT_DLFOLDER_NO_INLINE_DISTINCT_WHERE_2);
3139 }
3140
3141 if (orderByComparator != null) {
3142 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3143
3144 if (orderByConditionFields.length > 0) {
3145 query.append(WHERE_AND);
3146 }
3147
3148 for (int i = 0; i < orderByConditionFields.length; i++) {
3149 if (getDB().isSupportsInlineDistinct()) {
3150 query.append(_ORDER_BY_ENTITY_ALIAS);
3151 }
3152 else {
3153 query.append(_ORDER_BY_ENTITY_TABLE);
3154 }
3155
3156 query.append(orderByConditionFields[i]);
3157
3158 if ((i + 1) < orderByConditionFields.length) {
3159 if (orderByComparator.isAscending() ^ previous) {
3160 query.append(WHERE_GREATER_THAN_HAS_NEXT);
3161 }
3162 else {
3163 query.append(WHERE_LESSER_THAN_HAS_NEXT);
3164 }
3165 }
3166 else {
3167 if (orderByComparator.isAscending() ^ previous) {
3168 query.append(WHERE_GREATER_THAN);
3169 }
3170 else {
3171 query.append(WHERE_LESSER_THAN);
3172 }
3173 }
3174 }
3175
3176 query.append(ORDER_BY_CLAUSE);
3177
3178 String[] orderByFields = orderByComparator.getOrderByFields();
3179
3180 for (int i = 0; i < orderByFields.length; i++) {
3181 if (getDB().isSupportsInlineDistinct()) {
3182 query.append(_ORDER_BY_ENTITY_ALIAS);
3183 }
3184 else {
3185 query.append(_ORDER_BY_ENTITY_TABLE);
3186 }
3187
3188 query.append(orderByFields[i]);
3189
3190 if ((i + 1) < orderByFields.length) {
3191 if (orderByComparator.isAscending() ^ previous) {
3192 query.append(ORDER_BY_ASC_HAS_NEXT);
3193 }
3194 else {
3195 query.append(ORDER_BY_DESC_HAS_NEXT);
3196 }
3197 }
3198 else {
3199 if (orderByComparator.isAscending() ^ previous) {
3200 query.append(ORDER_BY_ASC);
3201 }
3202 else {
3203 query.append(ORDER_BY_DESC);
3204 }
3205 }
3206 }
3207 }
3208
3209 else {
3210 if (getDB().isSupportsInlineDistinct()) {
3211 query.append(DLFolderModelImpl.ORDER_BY_JPQL);
3212 }
3213 else {
3214 query.append(DLFolderModelImpl.ORDER_BY_SQL);
3215 }
3216 }
3217
3218 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
3219 DLFolder.class.getName(),
3220 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
3221
3222 SQLQuery q = session.createSQLQuery(sql);
3223
3224 q.setFirstResult(0);
3225 q.setMaxResults(2);
3226
3227 if (getDB().isSupportsInlineDistinct()) {
3228 q.addEntity(_FILTER_ENTITY_ALIAS, DLFolderImpl.class);
3229 }
3230 else {
3231 q.addEntity(_FILTER_ENTITY_TABLE, DLFolderImpl.class);
3232 }
3233
3234 QueryPos qPos = QueryPos.getInstance(q);
3235
3236 qPos.add(groupId);
3237
3238 qPos.add(parentFolderId);
3239
3240 if (orderByComparator != null) {
3241 Object[] values = orderByComparator.getOrderByConditionValues(dlFolder);
3242
3243 for (Object value : values) {
3244 qPos.add(value);
3245 }
3246 }
3247
3248 List<DLFolder> list = q.list();
3249
3250 if (list.size() == 2) {
3251 return list.get(1);
3252 }
3253 else {
3254 return null;
3255 }
3256 }
3257
3258
3266 public List<DLFolder> findByP_N(long parentFolderId, String name)
3267 throws SystemException {
3268 return findByP_N(parentFolderId, name, QueryUtil.ALL_POS,
3269 QueryUtil.ALL_POS, null);
3270 }
3271
3272
3286 public List<DLFolder> findByP_N(long parentFolderId, String name,
3287 int start, int end) throws SystemException {
3288 return findByP_N(parentFolderId, name, start, end, null);
3289 }
3290
3291
3306 public List<DLFolder> findByP_N(long parentFolderId, String name,
3307 int start, int end, OrderByComparator orderByComparator)
3308 throws SystemException {
3309 FinderPath finderPath = null;
3310 Object[] finderArgs = null;
3311
3312 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
3313 (orderByComparator == null)) {
3314 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_P_N;
3315 finderArgs = new Object[] { parentFolderId, name };
3316 }
3317 else {
3318 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_P_N;
3319 finderArgs = new Object[] {
3320 parentFolderId, name,
3321
3322 start, end, orderByComparator
3323 };
3324 }
3325
3326 List<DLFolder> list = (List<DLFolder>)FinderCacheUtil.getResult(finderPath,
3327 finderArgs, this);
3328
3329 if ((list != null) && !list.isEmpty()) {
3330 for (DLFolder dlFolder : list) {
3331 if ((parentFolderId != dlFolder.getParentFolderId()) ||
3332 !Validator.equals(name, dlFolder.getName())) {
3333 list = null;
3334
3335 break;
3336 }
3337 }
3338 }
3339
3340 if (list == null) {
3341 StringBundler query = null;
3342
3343 if (orderByComparator != null) {
3344 query = new StringBundler(4 +
3345 (orderByComparator.getOrderByFields().length * 3));
3346 }
3347 else {
3348 query = new StringBundler(4);
3349 }
3350
3351 query.append(_SQL_SELECT_DLFOLDER_WHERE);
3352
3353 query.append(_FINDER_COLUMN_P_N_PARENTFOLDERID_2);
3354
3355 if (name == null) {
3356 query.append(_FINDER_COLUMN_P_N_NAME_1);
3357 }
3358 else {
3359 if (name.equals(StringPool.BLANK)) {
3360 query.append(_FINDER_COLUMN_P_N_NAME_3);
3361 }
3362 else {
3363 query.append(_FINDER_COLUMN_P_N_NAME_2);
3364 }
3365 }
3366
3367 if (orderByComparator != null) {
3368 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3369 orderByComparator);
3370 }
3371
3372 else {
3373 query.append(DLFolderModelImpl.ORDER_BY_JPQL);
3374 }
3375
3376 String sql = query.toString();
3377
3378 Session session = null;
3379
3380 try {
3381 session = openSession();
3382
3383 Query q = session.createQuery(sql);
3384
3385 QueryPos qPos = QueryPos.getInstance(q);
3386
3387 qPos.add(parentFolderId);
3388
3389 if (name != null) {
3390 qPos.add(name);
3391 }
3392
3393 list = (List<DLFolder>)QueryUtil.list(q, getDialect(), start,
3394 end);
3395 }
3396 catch (Exception e) {
3397 throw processException(e);
3398 }
3399 finally {
3400 if (list == null) {
3401 FinderCacheUtil.removeResult(finderPath, finderArgs);
3402 }
3403 else {
3404 cacheResult(list);
3405
3406 FinderCacheUtil.putResult(finderPath, finderArgs, list);
3407 }
3408
3409 closeSession(session);
3410 }
3411 }
3412
3413 return list;
3414 }
3415
3416
3430 public DLFolder findByP_N_First(long parentFolderId, String name,
3431 OrderByComparator orderByComparator)
3432 throws NoSuchFolderException, SystemException {
3433 List<DLFolder> list = findByP_N(parentFolderId, name, 0, 1,
3434 orderByComparator);
3435
3436 if (list.isEmpty()) {
3437 StringBundler msg = new StringBundler(6);
3438
3439 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3440
3441 msg.append("parentFolderId=");
3442 msg.append(parentFolderId);
3443
3444 msg.append(", name=");
3445 msg.append(name);
3446
3447 msg.append(StringPool.CLOSE_CURLY_BRACE);
3448
3449 throw new NoSuchFolderException(msg.toString());
3450 }
3451 else {
3452 return list.get(0);
3453 }
3454 }
3455
3456
3470 public DLFolder findByP_N_Last(long parentFolderId, String name,
3471 OrderByComparator orderByComparator)
3472 throws NoSuchFolderException, SystemException {
3473 int count = countByP_N(parentFolderId, name);
3474
3475 List<DLFolder> list = findByP_N(parentFolderId, name, count - 1, count,
3476 orderByComparator);
3477
3478 if (list.isEmpty()) {
3479 StringBundler msg = new StringBundler(6);
3480
3481 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3482
3483 msg.append("parentFolderId=");
3484 msg.append(parentFolderId);
3485
3486 msg.append(", name=");
3487 msg.append(name);
3488
3489 msg.append(StringPool.CLOSE_CURLY_BRACE);
3490
3491 throw new NoSuchFolderException(msg.toString());
3492 }
3493 else {
3494 return list.get(0);
3495 }
3496 }
3497
3498
3513 public DLFolder[] findByP_N_PrevAndNext(long folderId, long parentFolderId,
3514 String name, OrderByComparator orderByComparator)
3515 throws NoSuchFolderException, SystemException {
3516 DLFolder dlFolder = findByPrimaryKey(folderId);
3517
3518 Session session = null;
3519
3520 try {
3521 session = openSession();
3522
3523 DLFolder[] array = new DLFolderImpl[3];
3524
3525 array[0] = getByP_N_PrevAndNext(session, dlFolder, parentFolderId,
3526 name, orderByComparator, true);
3527
3528 array[1] = dlFolder;
3529
3530 array[2] = getByP_N_PrevAndNext(session, dlFolder, parentFolderId,
3531 name, orderByComparator, false);
3532
3533 return array;
3534 }
3535 catch (Exception e) {
3536 throw processException(e);
3537 }
3538 finally {
3539 closeSession(session);
3540 }
3541 }
3542
3543 protected DLFolder getByP_N_PrevAndNext(Session session, DLFolder dlFolder,
3544 long parentFolderId, String name, OrderByComparator orderByComparator,
3545 boolean previous) {
3546 StringBundler query = null;
3547
3548 if (orderByComparator != null) {
3549 query = new StringBundler(6 +
3550 (orderByComparator.getOrderByFields().length * 6));
3551 }
3552 else {
3553 query = new StringBundler(3);
3554 }
3555
3556 query.append(_SQL_SELECT_DLFOLDER_WHERE);
3557
3558 query.append(_FINDER_COLUMN_P_N_PARENTFOLDERID_2);
3559
3560 if (name == null) {
3561 query.append(_FINDER_COLUMN_P_N_NAME_1);
3562 }
3563 else {
3564 if (name.equals(StringPool.BLANK)) {
3565 query.append(_FINDER_COLUMN_P_N_NAME_3);
3566 }
3567 else {
3568 query.append(_FINDER_COLUMN_P_N_NAME_2);
3569 }
3570 }
3571
3572 if (orderByComparator != null) {
3573 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3574
3575 if (orderByConditionFields.length > 0) {
3576 query.append(WHERE_AND);
3577 }
3578
3579 for (int i = 0; i < orderByConditionFields.length; i++) {
3580 query.append(_ORDER_BY_ENTITY_ALIAS);
3581 query.append(orderByConditionFields[i]);
3582
3583 if ((i + 1) < orderByConditionFields.length) {
3584 if (orderByComparator.isAscending() ^ previous) {
3585 query.append(WHERE_GREATER_THAN_HAS_NEXT);
3586 }
3587 else {
3588 query.append(WHERE_LESSER_THAN_HAS_NEXT);
3589 }
3590 }
3591 else {
3592 if (orderByComparator.isAscending() ^ previous) {
3593 query.append(WHERE_GREATER_THAN);
3594 }
3595 else {
3596 query.append(WHERE_LESSER_THAN);
3597 }
3598 }
3599 }
3600
3601 query.append(ORDER_BY_CLAUSE);
3602
3603 String[] orderByFields = orderByComparator.getOrderByFields();
3604
3605 for (int i = 0; i < orderByFields.length; i++) {
3606 query.append(_ORDER_BY_ENTITY_ALIAS);
3607 query.append(orderByFields[i]);
3608
3609 if ((i + 1) < orderByFields.length) {
3610 if (orderByComparator.isAscending() ^ previous) {
3611 query.append(ORDER_BY_ASC_HAS_NEXT);
3612 }
3613 else {
3614 query.append(ORDER_BY_DESC_HAS_NEXT);
3615 }
3616 }
3617 else {
3618 if (orderByComparator.isAscending() ^ previous) {
3619 query.append(ORDER_BY_ASC);
3620 }
3621 else {
3622 query.append(ORDER_BY_DESC);
3623 }
3624 }
3625 }
3626 }
3627
3628 else {
3629 query.append(DLFolderModelImpl.ORDER_BY_JPQL);
3630 }
3631
3632 String sql = query.toString();
3633
3634 Query q = session.createQuery(sql);
3635
3636 q.setFirstResult(0);
3637 q.setMaxResults(2);
3638
3639 QueryPos qPos = QueryPos.getInstance(q);
3640
3641 qPos.add(parentFolderId);
3642
3643 if (name != null) {
3644 qPos.add(name);
3645 }
3646
3647 if (orderByComparator != null) {
3648 Object[] values = orderByComparator.getOrderByConditionValues(dlFolder);
3649
3650 for (Object value : values) {
3651 qPos.add(value);
3652 }
3653 }
3654
3655 List<DLFolder> list = q.list();
3656
3657 if (list.size() == 2) {
3658 return list.get(1);
3659 }
3660 else {
3661 return null;
3662 }
3663 }
3664
3665
3674 public List<DLFolder> findByG_P_M(long groupId, long parentFolderId,
3675 boolean mountPoint) throws SystemException {
3676 return findByG_P_M(groupId, parentFolderId, mountPoint,
3677 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
3678 }
3679
3680
3695 public List<DLFolder> findByG_P_M(long groupId, long parentFolderId,
3696 boolean mountPoint, int start, int end) throws SystemException {
3697 return findByG_P_M(groupId, parentFolderId, mountPoint, start, end, null);
3698 }
3699
3700
3716 public List<DLFolder> findByG_P_M(long groupId, long parentFolderId,
3717 boolean mountPoint, int start, int end,
3718 OrderByComparator orderByComparator) throws SystemException {
3719 FinderPath finderPath = null;
3720 Object[] finderArgs = null;
3721
3722 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
3723 (orderByComparator == null)) {
3724 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_M;
3725 finderArgs = new Object[] { groupId, parentFolderId, mountPoint };
3726 }
3727 else {
3728 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_P_M;
3729 finderArgs = new Object[] {
3730 groupId, parentFolderId, mountPoint,
3731
3732 start, end, orderByComparator
3733 };
3734 }
3735
3736 List<DLFolder> list = (List<DLFolder>)FinderCacheUtil.getResult(finderPath,
3737 finderArgs, this);
3738
3739 if ((list != null) && !list.isEmpty()) {
3740 for (DLFolder dlFolder : list) {
3741 if ((groupId != dlFolder.getGroupId()) ||
3742 (parentFolderId != dlFolder.getParentFolderId()) ||
3743 (mountPoint != dlFolder.getMountPoint())) {
3744 list = null;
3745
3746 break;
3747 }
3748 }
3749 }
3750
3751 if (list == null) {
3752 StringBundler query = null;
3753
3754 if (orderByComparator != null) {
3755 query = new StringBundler(5 +
3756 (orderByComparator.getOrderByFields().length * 3));
3757 }
3758 else {
3759 query = new StringBundler(5);
3760 }
3761
3762 query.append(_SQL_SELECT_DLFOLDER_WHERE);
3763
3764 query.append(_FINDER_COLUMN_G_P_M_GROUPID_2);
3765
3766 query.append(_FINDER_COLUMN_G_P_M_PARENTFOLDERID_2);
3767
3768 query.append(_FINDER_COLUMN_G_P_M_MOUNTPOINT_2);
3769
3770 if (orderByComparator != null) {
3771 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3772 orderByComparator);
3773 }
3774
3775 else {
3776 query.append(DLFolderModelImpl.ORDER_BY_JPQL);
3777 }
3778
3779 String sql = query.toString();
3780
3781 Session session = null;
3782
3783 try {
3784 session = openSession();
3785
3786 Query q = session.createQuery(sql);
3787
3788 QueryPos qPos = QueryPos.getInstance(q);
3789
3790 qPos.add(groupId);
3791
3792 qPos.add(parentFolderId);
3793
3794 qPos.add(mountPoint);
3795
3796 list = (List<DLFolder>)QueryUtil.list(q, getDialect(), start,
3797 end);
3798 }
3799 catch (Exception e) {
3800 throw processException(e);
3801 }
3802 finally {
3803 if (list == null) {
3804 FinderCacheUtil.removeResult(finderPath, finderArgs);
3805 }
3806 else {
3807 cacheResult(list);
3808
3809 FinderCacheUtil.putResult(finderPath, finderArgs, list);
3810 }
3811
3812 closeSession(session);
3813 }
3814 }
3815
3816 return list;
3817 }
3818
3819
3834 public DLFolder findByG_P_M_First(long groupId, long parentFolderId,
3835 boolean mountPoint, OrderByComparator orderByComparator)
3836 throws NoSuchFolderException, SystemException {
3837 List<DLFolder> list = findByG_P_M(groupId, parentFolderId, mountPoint,
3838 0, 1, orderByComparator);
3839
3840 if (list.isEmpty()) {
3841 StringBundler msg = new StringBundler(8);
3842
3843 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3844
3845 msg.append("groupId=");
3846 msg.append(groupId);
3847
3848 msg.append(", parentFolderId=");
3849 msg.append(parentFolderId);
3850
3851 msg.append(", mountPoint=");
3852 msg.append(mountPoint);
3853
3854 msg.append(StringPool.CLOSE_CURLY_BRACE);
3855
3856 throw new NoSuchFolderException(msg.toString());
3857 }
3858 else {
3859 return list.get(0);
3860 }
3861 }
3862
3863
3878 public DLFolder findByG_P_M_Last(long groupId, long parentFolderId,
3879 boolean mountPoint, OrderByComparator orderByComparator)
3880 throws NoSuchFolderException, SystemException {
3881 int count = countByG_P_M(groupId, parentFolderId, mountPoint);
3882
3883 List<DLFolder> list = findByG_P_M(groupId, parentFolderId, mountPoint,
3884 count - 1, count, orderByComparator);
3885
3886 if (list.isEmpty()) {
3887 StringBundler msg = new StringBundler(8);
3888
3889 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3890
3891 msg.append("groupId=");
3892 msg.append(groupId);
3893
3894 msg.append(", parentFolderId=");
3895 msg.append(parentFolderId);
3896
3897 msg.append(", mountPoint=");
3898 msg.append(mountPoint);
3899
3900 msg.append(StringPool.CLOSE_CURLY_BRACE);
3901
3902 throw new NoSuchFolderException(msg.toString());
3903 }
3904 else {
3905 return list.get(0);
3906 }
3907 }
3908
3909
3925 public DLFolder[] findByG_P_M_PrevAndNext(long folderId, long groupId,
3926 long parentFolderId, boolean mountPoint,
3927 OrderByComparator orderByComparator)
3928 throws NoSuchFolderException, SystemException {
3929 DLFolder dlFolder = findByPrimaryKey(folderId);
3930
3931 Session session = null;
3932
3933 try {
3934 session = openSession();
3935
3936 DLFolder[] array = new DLFolderImpl[3];
3937
3938 array[0] = getByG_P_M_PrevAndNext(session, dlFolder, groupId,
3939 parentFolderId, mountPoint, orderByComparator, true);
3940
3941 array[1] = dlFolder;
3942
3943 array[2] = getByG_P_M_PrevAndNext(session, dlFolder, groupId,
3944 parentFolderId, mountPoint, orderByComparator, false);
3945
3946 return array;
3947 }
3948 catch (Exception e) {
3949 throw processException(e);
3950 }
3951 finally {
3952 closeSession(session);
3953 }
3954 }
3955
3956 protected DLFolder getByG_P_M_PrevAndNext(Session session,
3957 DLFolder dlFolder, long groupId, long parentFolderId,
3958 boolean mountPoint, OrderByComparator orderByComparator,
3959 boolean previous) {
3960 StringBundler query = null;
3961
3962 if (orderByComparator != null) {
3963 query = new StringBundler(6 +
3964 (orderByComparator.getOrderByFields().length * 6));
3965 }
3966 else {
3967 query = new StringBundler(3);
3968 }
3969
3970 query.append(_SQL_SELECT_DLFOLDER_WHERE);
3971
3972 query.append(_FINDER_COLUMN_G_P_M_GROUPID_2);
3973
3974 query.append(_FINDER_COLUMN_G_P_M_PARENTFOLDERID_2);
3975
3976 query.append(_FINDER_COLUMN_G_P_M_MOUNTPOINT_2);
3977
3978 if (orderByComparator != null) {
3979 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3980
3981 if (orderByConditionFields.length > 0) {
3982 query.append(WHERE_AND);
3983 }
3984
3985 for (int i = 0; i < orderByConditionFields.length; i++) {
3986 query.append(_ORDER_BY_ENTITY_ALIAS);
3987 query.append(orderByConditionFields[i]);
3988
3989 if ((i + 1) < orderByConditionFields.length) {
3990 if (orderByComparator.isAscending() ^ previous) {
3991 query.append(WHERE_GREATER_THAN_HAS_NEXT);
3992 }
3993 else {
3994 query.append(WHERE_LESSER_THAN_HAS_NEXT);
3995 }
3996 }
3997 else {
3998 if (orderByComparator.isAscending() ^ previous) {
3999 query.append(WHERE_GREATER_THAN);
4000 }
4001 else {
4002 query.append(WHERE_LESSER_THAN);
4003 }
4004 }
4005 }
4006
4007 query.append(ORDER_BY_CLAUSE);
4008
4009 String[] orderByFields = orderByComparator.getOrderByFields();
4010
4011 for (int i = 0; i < orderByFields.length; i++) {
4012 query.append(_ORDER_BY_ENTITY_ALIAS);
4013 query.append(orderByFields[i]);
4014
4015 if ((i + 1) < orderByFields.length) {
4016 if (orderByComparator.isAscending() ^ previous) {
4017 query.append(ORDER_BY_ASC_HAS_NEXT);
4018 }
4019 else {
4020 query.append(ORDER_BY_DESC_HAS_NEXT);
4021 }
4022 }
4023 else {
4024 if (orderByComparator.isAscending() ^ previous) {
4025 query.append(ORDER_BY_ASC);
4026 }
4027 else {
4028 query.append(ORDER_BY_DESC);
4029 }
4030 }
4031 }
4032 }
4033
4034 else {
4035 query.append(DLFolderModelImpl.ORDER_BY_JPQL);
4036 }
4037
4038 String sql = query.toString();
4039
4040 Query q = session.createQuery(sql);
4041
4042 q.setFirstResult(0);
4043 q.setMaxResults(2);
4044
4045 QueryPos qPos = QueryPos.getInstance(q);
4046
4047 qPos.add(groupId);
4048
4049 qPos.add(parentFolderId);
4050
4051 qPos.add(mountPoint);
4052
4053 if (orderByComparator != null) {
4054 Object[] values = orderByComparator.getOrderByConditionValues(dlFolder);
4055
4056 for (Object value : values) {
4057 qPos.add(value);
4058 }
4059 }
4060
4061 List<DLFolder> list = q.list();
4062
4063 if (list.size() == 2) {
4064 return list.get(1);
4065 }
4066 else {
4067 return null;
4068 }
4069 }
4070
4071
4080 public List<DLFolder> filterFindByG_P_M(long groupId, long parentFolderId,
4081 boolean mountPoint) throws SystemException {
4082 return filterFindByG_P_M(groupId, parentFolderId, mountPoint,
4083 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
4084 }
4085
4086
4101 public List<DLFolder> filterFindByG_P_M(long groupId, long parentFolderId,
4102 boolean mountPoint, int start, int end) throws SystemException {
4103 return filterFindByG_P_M(groupId, parentFolderId, mountPoint, start,
4104 end, null);
4105 }
4106
4107
4123 public List<DLFolder> filterFindByG_P_M(long groupId, long parentFolderId,
4124 boolean mountPoint, int start, int end,
4125 OrderByComparator orderByComparator) throws SystemException {
4126 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
4127 return findByG_P_M(groupId, parentFolderId, mountPoint, start, end,
4128 orderByComparator);
4129 }
4130
4131 StringBundler query = null;
4132
4133 if (orderByComparator != null) {
4134 query = new StringBundler(5 +
4135 (orderByComparator.getOrderByFields().length * 3));
4136 }
4137 else {
4138 query = new StringBundler(5);
4139 }
4140
4141 if (getDB().isSupportsInlineDistinct()) {
4142 query.append(_FILTER_SQL_SELECT_DLFOLDER_WHERE);
4143 }
4144 else {
4145 query.append(_FILTER_SQL_SELECT_DLFOLDER_NO_INLINE_DISTINCT_WHERE_1);
4146 }
4147
4148 query.append(_FINDER_COLUMN_G_P_M_GROUPID_2);
4149
4150 query.append(_FINDER_COLUMN_G_P_M_PARENTFOLDERID_2);
4151
4152 query.append(_FINDER_COLUMN_G_P_M_MOUNTPOINT_2);
4153
4154 if (!getDB().isSupportsInlineDistinct()) {
4155 query.append(_FILTER_SQL_SELECT_DLFOLDER_NO_INLINE_DISTINCT_WHERE_2);
4156 }
4157
4158 if (orderByComparator != null) {
4159 if (getDB().isSupportsInlineDistinct()) {
4160 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4161 orderByComparator);
4162 }
4163 else {
4164 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
4165 orderByComparator);
4166 }
4167 }
4168
4169 else {
4170 if (getDB().isSupportsInlineDistinct()) {
4171 query.append(DLFolderModelImpl.ORDER_BY_JPQL);
4172 }
4173 else {
4174 query.append(DLFolderModelImpl.ORDER_BY_SQL);
4175 }
4176 }
4177
4178 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
4179 DLFolder.class.getName(),
4180 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
4181
4182 Session session = null;
4183
4184 try {
4185 session = openSession();
4186
4187 SQLQuery q = session.createSQLQuery(sql);
4188
4189 if (getDB().isSupportsInlineDistinct()) {
4190 q.addEntity(_FILTER_ENTITY_ALIAS, DLFolderImpl.class);
4191 }
4192 else {
4193 q.addEntity(_FILTER_ENTITY_TABLE, DLFolderImpl.class);
4194 }
4195
4196 QueryPos qPos = QueryPos.getInstance(q);
4197
4198 qPos.add(groupId);
4199
4200 qPos.add(parentFolderId);
4201
4202 qPos.add(mountPoint);
4203
4204 return (List<DLFolder>)QueryUtil.list(q, getDialect(), start, end);
4205 }
4206 catch (Exception e) {
4207 throw processException(e);
4208 }
4209 finally {
4210 closeSession(session);
4211 }
4212 }
4213
4214
4226 public DLFolder[] filterFindByG_P_M_PrevAndNext(long folderId,
4227 long groupId, long parentFolderId, boolean mountPoint,
4228 OrderByComparator orderByComparator)
4229 throws NoSuchFolderException, SystemException {
4230 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
4231 return findByG_P_M_PrevAndNext(folderId, groupId, parentFolderId,
4232 mountPoint, orderByComparator);
4233 }
4234
4235 DLFolder dlFolder = findByPrimaryKey(folderId);
4236
4237 Session session = null;
4238
4239 try {
4240 session = openSession();
4241
4242 DLFolder[] array = new DLFolderImpl[3];
4243
4244 array[0] = filterGetByG_P_M_PrevAndNext(session, dlFolder, groupId,
4245 parentFolderId, mountPoint, orderByComparator, true);
4246
4247 array[1] = dlFolder;
4248
4249 array[2] = filterGetByG_P_M_PrevAndNext(session, dlFolder, groupId,
4250 parentFolderId, mountPoint, orderByComparator, false);
4251
4252 return array;
4253 }
4254 catch (Exception e) {
4255 throw processException(e);
4256 }
4257 finally {
4258 closeSession(session);
4259 }
4260 }
4261
4262 protected DLFolder filterGetByG_P_M_PrevAndNext(Session session,
4263 DLFolder dlFolder, long groupId, long parentFolderId,
4264 boolean mountPoint, OrderByComparator orderByComparator,
4265 boolean previous) {
4266 StringBundler query = null;
4267
4268 if (orderByComparator != null) {
4269 query = new StringBundler(6 +
4270 (orderByComparator.getOrderByFields().length * 6));
4271 }
4272 else {
4273 query = new StringBundler(3);
4274 }
4275
4276 if (getDB().isSupportsInlineDistinct()) {
4277 query.append(_FILTER_SQL_SELECT_DLFOLDER_WHERE);
4278 }
4279 else {
4280 query.append(_FILTER_SQL_SELECT_DLFOLDER_NO_INLINE_DISTINCT_WHERE_1);
4281 }
4282
4283 query.append(_FINDER_COLUMN_G_P_M_GROUPID_2);
4284
4285 query.append(_FINDER_COLUMN_G_P_M_PARENTFOLDERID_2);
4286
4287 query.append(_FINDER_COLUMN_G_P_M_MOUNTPOINT_2);
4288
4289 if (!getDB().isSupportsInlineDistinct()) {
4290 query.append(_FILTER_SQL_SELECT_DLFOLDER_NO_INLINE_DISTINCT_WHERE_2);
4291 }
4292
4293 if (orderByComparator != null) {
4294 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
4295
4296 if (orderByConditionFields.length > 0) {
4297 query.append(WHERE_AND);
4298 }
4299
4300 for (int i = 0; i < orderByConditionFields.length; i++) {
4301 if (getDB().isSupportsInlineDistinct()) {
4302 query.append(_ORDER_BY_ENTITY_ALIAS);
4303 }
4304 else {
4305 query.append(_ORDER_BY_ENTITY_TABLE);
4306 }
4307
4308 query.append(orderByConditionFields[i]);
4309
4310 if ((i + 1) < orderByConditionFields.length) {
4311 if (orderByComparator.isAscending() ^ previous) {
4312 query.append(WHERE_GREATER_THAN_HAS_NEXT);
4313 }
4314 else {
4315 query.append(WHERE_LESSER_THAN_HAS_NEXT);
4316 }
4317 }
4318 else {
4319 if (orderByComparator.isAscending() ^ previous) {
4320 query.append(WHERE_GREATER_THAN);
4321 }
4322 else {
4323 query.append(WHERE_LESSER_THAN);
4324 }
4325 }
4326 }
4327
4328 query.append(ORDER_BY_CLAUSE);
4329
4330 String[] orderByFields = orderByComparator.getOrderByFields();
4331
4332 for (int i = 0; i < orderByFields.length; i++) {
4333 if (getDB().isSupportsInlineDistinct()) {
4334 query.append(_ORDER_BY_ENTITY_ALIAS);
4335 }
4336 else {
4337 query.append(_ORDER_BY_ENTITY_TABLE);
4338 }
4339
4340 query.append(orderByFields[i]);
4341
4342 if ((i + 1) < orderByFields.length) {
4343 if (orderByComparator.isAscending() ^ previous) {
4344 query.append(ORDER_BY_ASC_HAS_NEXT);
4345 }
4346 else {
4347 query.append(ORDER_BY_DESC_HAS_NEXT);
4348 }
4349 }
4350 else {
4351 if (orderByComparator.isAscending() ^ previous) {
4352 query.append(ORDER_BY_ASC);
4353 }
4354 else {
4355 query.append(ORDER_BY_DESC);
4356 }
4357 }
4358 }
4359 }
4360
4361 else {
4362 if (getDB().isSupportsInlineDistinct()) {
4363 query.append(DLFolderModelImpl.ORDER_BY_JPQL);
4364 }
4365 else {
4366 query.append(DLFolderModelImpl.ORDER_BY_SQL);
4367 }
4368 }
4369
4370 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
4371 DLFolder.class.getName(),
4372 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
4373
4374 SQLQuery q = session.createSQLQuery(sql);
4375
4376 q.setFirstResult(0);
4377 q.setMaxResults(2);
4378
4379 if (getDB().isSupportsInlineDistinct()) {
4380 q.addEntity(_FILTER_ENTITY_ALIAS, DLFolderImpl.class);
4381 }
4382 else {
4383 q.addEntity(_FILTER_ENTITY_TABLE, DLFolderImpl.class);
4384 }
4385
4386 QueryPos qPos = QueryPos.getInstance(q);
4387
4388 qPos.add(groupId);
4389
4390 qPos.add(parentFolderId);
4391
4392 qPos.add(mountPoint);
4393
4394 if (orderByComparator != null) {
4395 Object[] values = orderByComparator.getOrderByConditionValues(dlFolder);
4396
4397 for (Object value : values) {
4398 qPos.add(value);
4399 }
4400 }
4401
4402 List<DLFolder> list = q.list();
4403
4404 if (list.size() == 2) {
4405 return list.get(1);
4406 }
4407 else {
4408 return null;
4409 }
4410 }
4411
4412
4422 public DLFolder findByG_P_N(long groupId, long parentFolderId, String name)
4423 throws NoSuchFolderException, SystemException {
4424 DLFolder dlFolder = fetchByG_P_N(groupId, parentFolderId, name);
4425
4426 if (dlFolder == null) {
4427 StringBundler msg = new StringBundler(8);
4428
4429 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4430
4431 msg.append("groupId=");
4432 msg.append(groupId);
4433
4434 msg.append(", parentFolderId=");
4435 msg.append(parentFolderId);
4436
4437 msg.append(", name=");
4438 msg.append(name);
4439
4440 msg.append(StringPool.CLOSE_CURLY_BRACE);
4441
4442 if (_log.isWarnEnabled()) {
4443 _log.warn(msg.toString());
4444 }
4445
4446 throw new NoSuchFolderException(msg.toString());
4447 }
4448
4449 return dlFolder;
4450 }
4451
4452
4461 public DLFolder fetchByG_P_N(long groupId, long parentFolderId, String name)
4462 throws SystemException {
4463 return fetchByG_P_N(groupId, parentFolderId, name, true);
4464 }
4465
4466
4476 public DLFolder fetchByG_P_N(long groupId, long parentFolderId,
4477 String name, boolean retrieveFromCache) throws SystemException {
4478 Object[] finderArgs = new Object[] { groupId, parentFolderId, name };
4479
4480 Object result = null;
4481
4482 if (retrieveFromCache) {
4483 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_G_P_N,
4484 finderArgs, this);
4485 }
4486
4487 if (result instanceof DLFolder) {
4488 DLFolder dlFolder = (DLFolder)result;
4489
4490 if ((groupId != dlFolder.getGroupId()) ||
4491 (parentFolderId != dlFolder.getParentFolderId()) ||
4492 !Validator.equals(name, dlFolder.getName())) {
4493 result = null;
4494 }
4495 }
4496
4497 if (result == null) {
4498 StringBundler query = new StringBundler(5);
4499
4500 query.append(_SQL_SELECT_DLFOLDER_WHERE);
4501
4502 query.append(_FINDER_COLUMN_G_P_N_GROUPID_2);
4503
4504 query.append(_FINDER_COLUMN_G_P_N_PARENTFOLDERID_2);
4505
4506 if (name == null) {
4507 query.append(_FINDER_COLUMN_G_P_N_NAME_1);
4508 }
4509 else {
4510 if (name.equals(StringPool.BLANK)) {
4511 query.append(_FINDER_COLUMN_G_P_N_NAME_3);
4512 }
4513 else {
4514 query.append(_FINDER_COLUMN_G_P_N_NAME_2);
4515 }
4516 }
4517
4518 query.append(DLFolderModelImpl.ORDER_BY_JPQL);
4519
4520 String sql = query.toString();
4521
4522 Session session = null;
4523
4524 try {
4525 session = openSession();
4526
4527 Query q = session.createQuery(sql);
4528
4529 QueryPos qPos = QueryPos.getInstance(q);
4530
4531 qPos.add(groupId);
4532
4533 qPos.add(parentFolderId);
4534
4535 if (name != null) {
4536 qPos.add(name);
4537 }
4538
4539 List<DLFolder> list = q.list();
4540
4541 result = list;
4542
4543 DLFolder dlFolder = null;
4544
4545 if (list.isEmpty()) {
4546 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_P_N,
4547 finderArgs, list);
4548 }
4549 else {
4550 dlFolder = list.get(0);
4551
4552 cacheResult(dlFolder);
4553
4554 if ((dlFolder.getGroupId() != groupId) ||
4555 (dlFolder.getParentFolderId() != parentFolderId) ||
4556 (dlFolder.getName() == null) ||
4557 !dlFolder.getName().equals(name)) {
4558 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_P_N,
4559 finderArgs, dlFolder);
4560 }
4561 }
4562
4563 return dlFolder;
4564 }
4565 catch (Exception e) {
4566 throw processException(e);
4567 }
4568 finally {
4569 if (result == null) {
4570 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_P_N,
4571 finderArgs);
4572 }
4573
4574 closeSession(session);
4575 }
4576 }
4577 else {
4578 if (result instanceof List<?>) {
4579 return null;
4580 }
4581 else {
4582 return (DLFolder)result;
4583 }
4584 }
4585 }
4586
4587
4593 public List<DLFolder> findAll() throws SystemException {
4594 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
4595 }
4596
4597
4609 public List<DLFolder> findAll(int start, int end) throws SystemException {
4610 return findAll(start, end, null);
4611 }
4612
4613
4626 public List<DLFolder> findAll(int start, int end,
4627 OrderByComparator orderByComparator) throws SystemException {
4628 FinderPath finderPath = null;
4629 Object[] finderArgs = new Object[] { start, end, orderByComparator };
4630
4631 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
4632 (orderByComparator == null)) {
4633 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
4634 finderArgs = FINDER_ARGS_EMPTY;
4635 }
4636 else {
4637 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
4638 finderArgs = new Object[] { start, end, orderByComparator };
4639 }
4640
4641 List<DLFolder> list = (List<DLFolder>)FinderCacheUtil.getResult(finderPath,
4642 finderArgs, this);
4643
4644 if (list == null) {
4645 StringBundler query = null;
4646 String sql = null;
4647
4648 if (orderByComparator != null) {
4649 query = new StringBundler(2 +
4650 (orderByComparator.getOrderByFields().length * 3));
4651
4652 query.append(_SQL_SELECT_DLFOLDER);
4653
4654 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4655 orderByComparator);
4656
4657 sql = query.toString();
4658 }
4659 else {
4660 sql = _SQL_SELECT_DLFOLDER.concat(DLFolderModelImpl.ORDER_BY_JPQL);
4661 }
4662
4663 Session session = null;
4664
4665 try {
4666 session = openSession();
4667
4668 Query q = session.createQuery(sql);
4669
4670 if (orderByComparator == null) {
4671 list = (List<DLFolder>)QueryUtil.list(q, getDialect(),
4672 start, end, false);
4673
4674 Collections.sort(list);
4675 }
4676 else {
4677 list = (List<DLFolder>)QueryUtil.list(q, getDialect(),
4678 start, end);
4679 }
4680 }
4681 catch (Exception e) {
4682 throw processException(e);
4683 }
4684 finally {
4685 if (list == null) {
4686 FinderCacheUtil.removeResult(finderPath, finderArgs);
4687 }
4688 else {
4689 cacheResult(list);
4690
4691 FinderCacheUtil.putResult(finderPath, finderArgs, list);
4692 }
4693
4694 closeSession(session);
4695 }
4696 }
4697
4698 return list;
4699 }
4700
4701
4707 public void removeByUuid(String uuid) throws SystemException {
4708 for (DLFolder dlFolder : findByUuid(uuid)) {
4709 remove(dlFolder);
4710 }
4711 }
4712
4713
4720 public void removeByUUID_G(String uuid, long groupId)
4721 throws NoSuchFolderException, SystemException {
4722 DLFolder dlFolder = findByUUID_G(uuid, groupId);
4723
4724 remove(dlFolder);
4725 }
4726
4727
4733 public void removeByGroupId(long groupId) throws SystemException {
4734 for (DLFolder dlFolder : findByGroupId(groupId)) {
4735 remove(dlFolder);
4736 }
4737 }
4738
4739
4745 public void removeByCompanyId(long companyId) throws SystemException {
4746 for (DLFolder dlFolder : findByCompanyId(companyId)) {
4747 remove(dlFolder);
4748 }
4749 }
4750
4751
4757 public void removeByRepositoryId(long repositoryId)
4758 throws NoSuchFolderException, SystemException {
4759 DLFolder dlFolder = findByRepositoryId(repositoryId);
4760
4761 remove(dlFolder);
4762 }
4763
4764
4771 public void removeByG_P(long groupId, long parentFolderId)
4772 throws SystemException {
4773 for (DLFolder dlFolder : findByG_P(groupId, parentFolderId)) {
4774 remove(dlFolder);
4775 }
4776 }
4777
4778
4785 public void removeByP_N(long parentFolderId, String name)
4786 throws SystemException {
4787 for (DLFolder dlFolder : findByP_N(parentFolderId, name)) {
4788 remove(dlFolder);
4789 }
4790 }
4791
4792
4800 public void removeByG_P_M(long groupId, long parentFolderId,
4801 boolean mountPoint) throws SystemException {
4802 for (DLFolder dlFolder : findByG_P_M(groupId, parentFolderId, mountPoint)) {
4803 remove(dlFolder);
4804 }
4805 }
4806
4807
4815 public void removeByG_P_N(long groupId, long parentFolderId, String name)
4816 throws NoSuchFolderException, SystemException {
4817 DLFolder dlFolder = findByG_P_N(groupId, parentFolderId, name);
4818
4819 remove(dlFolder);
4820 }
4821
4822
4827 public void removeAll() throws SystemException {
4828 for (DLFolder dlFolder : findAll()) {
4829 remove(dlFolder);
4830 }
4831 }
4832
4833
4840 public int countByUuid(String uuid) throws SystemException {
4841 Object[] finderArgs = new Object[] { uuid };
4842
4843 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID,
4844 finderArgs, this);
4845
4846 if (count == null) {
4847 StringBundler query = new StringBundler(2);
4848
4849 query.append(_SQL_COUNT_DLFOLDER_WHERE);
4850
4851 if (uuid == null) {
4852 query.append(_FINDER_COLUMN_UUID_UUID_1);
4853 }
4854 else {
4855 if (uuid.equals(StringPool.BLANK)) {
4856 query.append(_FINDER_COLUMN_UUID_UUID_3);
4857 }
4858 else {
4859 query.append(_FINDER_COLUMN_UUID_UUID_2);
4860 }
4861 }
4862
4863 String sql = query.toString();
4864
4865 Session session = null;
4866
4867 try {
4868 session = openSession();
4869
4870 Query q = session.createQuery(sql);
4871
4872 QueryPos qPos = QueryPos.getInstance(q);
4873
4874 if (uuid != null) {
4875 qPos.add(uuid);
4876 }
4877
4878 count = (Long)q.uniqueResult();
4879 }
4880 catch (Exception e) {
4881 throw processException(e);
4882 }
4883 finally {
4884 if (count == null) {
4885 count = Long.valueOf(0);
4886 }
4887
4888 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID,
4889 finderArgs, count);
4890
4891 closeSession(session);
4892 }
4893 }
4894
4895 return count.intValue();
4896 }
4897
4898
4906 public int countByUUID_G(String uuid, long groupId)
4907 throws SystemException {
4908 Object[] finderArgs = new Object[] { uuid, groupId };
4909
4910 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID_G,
4911 finderArgs, this);
4912
4913 if (count == null) {
4914 StringBundler query = new StringBundler(3);
4915
4916 query.append(_SQL_COUNT_DLFOLDER_WHERE);
4917
4918 if (uuid == null) {
4919 query.append(_FINDER_COLUMN_UUID_G_UUID_1);
4920 }
4921 else {
4922 if (uuid.equals(StringPool.BLANK)) {
4923 query.append(_FINDER_COLUMN_UUID_G_UUID_3);
4924 }
4925 else {
4926 query.append(_FINDER_COLUMN_UUID_G_UUID_2);
4927 }
4928 }
4929
4930 query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
4931
4932 String sql = query.toString();
4933
4934 Session session = null;
4935
4936 try {
4937 session = openSession();
4938
4939 Query q = session.createQuery(sql);
4940
4941 QueryPos qPos = QueryPos.getInstance(q);
4942
4943 if (uuid != null) {
4944 qPos.add(uuid);
4945 }
4946
4947 qPos.add(groupId);
4948
4949 count = (Long)q.uniqueResult();
4950 }
4951 catch (Exception e) {
4952 throw processException(e);
4953 }
4954 finally {
4955 if (count == null) {
4956 count = Long.valueOf(0);
4957 }
4958
4959 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G,
4960 finderArgs, count);
4961
4962 closeSession(session);
4963 }
4964 }
4965
4966 return count.intValue();
4967 }
4968
4969
4976 public int countByGroupId(long groupId) throws SystemException {
4977 Object[] finderArgs = new Object[] { groupId };
4978
4979 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_GROUPID,
4980 finderArgs, this);
4981
4982 if (count == null) {
4983 StringBundler query = new StringBundler(2);
4984
4985 query.append(_SQL_COUNT_DLFOLDER_WHERE);
4986
4987 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
4988
4989 String sql = query.toString();
4990
4991 Session session = null;
4992
4993 try {
4994 session = openSession();
4995
4996 Query q = session.createQuery(sql);
4997
4998 QueryPos qPos = QueryPos.getInstance(q);
4999
5000 qPos.add(groupId);
5001
5002 count = (Long)q.uniqueResult();
5003 }
5004 catch (Exception e) {
5005 throw processException(e);
5006 }
5007 finally {
5008 if (count == null) {
5009 count = Long.valueOf(0);
5010 }
5011
5012 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_GROUPID,
5013 finderArgs, count);
5014
5015 closeSession(session);
5016 }
5017 }
5018
5019 return count.intValue();
5020 }
5021
5022
5029 public int filterCountByGroupId(long groupId) throws SystemException {
5030 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
5031 return countByGroupId(groupId);
5032 }
5033
5034 StringBundler query = new StringBundler(2);
5035
5036 query.append(_FILTER_SQL_COUNT_DLFOLDER_WHERE);
5037
5038 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
5039
5040 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
5041 DLFolder.class.getName(),
5042 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
5043
5044 Session session = null;
5045
5046 try {
5047 session = openSession();
5048
5049 SQLQuery q = session.createSQLQuery(sql);
5050
5051 q.addScalar(COUNT_COLUMN_NAME,
5052 com.liferay.portal.kernel.dao.orm.Type.LONG);
5053
5054 QueryPos qPos = QueryPos.getInstance(q);
5055
5056 qPos.add(groupId);
5057
5058 Long count = (Long)q.uniqueResult();
5059
5060 return count.intValue();
5061 }
5062 catch (Exception e) {
5063 throw processException(e);
5064 }
5065 finally {
5066 closeSession(session);
5067 }
5068 }
5069
5070
5077 public int countByCompanyId(long companyId) throws SystemException {
5078 Object[] finderArgs = new Object[] { companyId };
5079
5080 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_COMPANYID,
5081 finderArgs, this);
5082
5083 if (count == null) {
5084 StringBundler query = new StringBundler(2);
5085
5086 query.append(_SQL_COUNT_DLFOLDER_WHERE);
5087
5088 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
5089
5090 String sql = query.toString();
5091
5092 Session session = null;
5093
5094 try {
5095 session = openSession();
5096
5097 Query q = session.createQuery(sql);
5098
5099 QueryPos qPos = QueryPos.getInstance(q);
5100
5101 qPos.add(companyId);
5102
5103 count = (Long)q.uniqueResult();
5104 }
5105 catch (Exception e) {
5106 throw processException(e);
5107 }
5108 finally {
5109 if (count == null) {
5110 count = Long.valueOf(0);
5111 }
5112
5113 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_COMPANYID,
5114 finderArgs, count);
5115
5116 closeSession(session);
5117 }
5118 }
5119
5120 return count.intValue();
5121 }
5122
5123
5130 public int countByRepositoryId(long repositoryId) throws SystemException {
5131 Object[] finderArgs = new Object[] { repositoryId };
5132
5133 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_REPOSITORYID,
5134 finderArgs, this);
5135
5136 if (count == null) {
5137 StringBundler query = new StringBundler(2);
5138
5139 query.append(_SQL_COUNT_DLFOLDER_WHERE);
5140
5141 query.append(_FINDER_COLUMN_REPOSITORYID_REPOSITORYID_2);
5142
5143 String sql = query.toString();
5144
5145 Session session = null;
5146
5147 try {
5148 session = openSession();
5149
5150 Query q = session.createQuery(sql);
5151
5152 QueryPos qPos = QueryPos.getInstance(q);
5153
5154 qPos.add(repositoryId);
5155
5156 count = (Long)q.uniqueResult();
5157 }
5158 catch (Exception e) {
5159 throw processException(e);
5160 }
5161 finally {
5162 if (count == null) {
5163 count = Long.valueOf(0);
5164 }
5165
5166 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_REPOSITORYID,
5167 finderArgs, count);
5168
5169 closeSession(session);
5170 }
5171 }
5172
5173 return count.intValue();
5174 }
5175
5176
5184 public int countByG_P(long groupId, long parentFolderId)
5185 throws SystemException {
5186 Object[] finderArgs = new Object[] { groupId, parentFolderId };
5187
5188 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_P,
5189 finderArgs, this);
5190
5191 if (count == null) {
5192 StringBundler query = new StringBundler(3);
5193
5194 query.append(_SQL_COUNT_DLFOLDER_WHERE);
5195
5196 query.append(_FINDER_COLUMN_G_P_GROUPID_2);
5197
5198 query.append(_FINDER_COLUMN_G_P_PARENTFOLDERID_2);
5199
5200 String sql = query.toString();
5201
5202 Session session = null;
5203
5204 try {
5205 session = openSession();
5206
5207 Query q = session.createQuery(sql);
5208
5209 QueryPos qPos = QueryPos.getInstance(q);
5210
5211 qPos.add(groupId);
5212
5213 qPos.add(parentFolderId);
5214
5215 count = (Long)q.uniqueResult();
5216 }
5217 catch (Exception e) {
5218 throw processException(e);
5219 }
5220 finally {
5221 if (count == null) {
5222 count = Long.valueOf(0);
5223 }
5224
5225 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_P, finderArgs,
5226 count);
5227
5228 closeSession(session);
5229 }
5230 }
5231
5232 return count.intValue();
5233 }
5234
5235
5243 public int filterCountByG_P(long groupId, long parentFolderId)
5244 throws SystemException {
5245 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
5246 return countByG_P(groupId, parentFolderId);
5247 }
5248
5249 StringBundler query = new StringBundler(3);
5250
5251 query.append(_FILTER_SQL_COUNT_DLFOLDER_WHERE);
5252
5253 query.append(_FINDER_COLUMN_G_P_GROUPID_2);
5254
5255 query.append(_FINDER_COLUMN_G_P_PARENTFOLDERID_2);
5256
5257 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
5258 DLFolder.class.getName(),
5259 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
5260
5261 Session session = null;
5262
5263 try {
5264 session = openSession();
5265
5266 SQLQuery q = session.createSQLQuery(sql);
5267
5268 q.addScalar(COUNT_COLUMN_NAME,
5269 com.liferay.portal.kernel.dao.orm.Type.LONG);
5270
5271 QueryPos qPos = QueryPos.getInstance(q);
5272
5273 qPos.add(groupId);
5274
5275 qPos.add(parentFolderId);
5276
5277 Long count = (Long)q.uniqueResult();
5278
5279 return count.intValue();
5280 }
5281 catch (Exception e) {
5282 throw processException(e);
5283 }
5284 finally {
5285 closeSession(session);
5286 }
5287 }
5288
5289
5297 public int countByP_N(long parentFolderId, String name)
5298 throws SystemException {
5299 Object[] finderArgs = new Object[] { parentFolderId, name };
5300
5301 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_P_N,
5302 finderArgs, this);
5303
5304 if (count == null) {
5305 StringBundler query = new StringBundler(3);
5306
5307 query.append(_SQL_COUNT_DLFOLDER_WHERE);
5308
5309 query.append(_FINDER_COLUMN_P_N_PARENTFOLDERID_2);
5310
5311 if (name == null) {
5312 query.append(_FINDER_COLUMN_P_N_NAME_1);
5313 }
5314 else {
5315 if (name.equals(StringPool.BLANK)) {
5316 query.append(_FINDER_COLUMN_P_N_NAME_3);
5317 }
5318 else {
5319 query.append(_FINDER_COLUMN_P_N_NAME_2);
5320 }
5321 }
5322
5323 String sql = query.toString();
5324
5325 Session session = null;
5326
5327 try {
5328 session = openSession();
5329
5330 Query q = session.createQuery(sql);
5331
5332 QueryPos qPos = QueryPos.getInstance(q);
5333
5334 qPos.add(parentFolderId);
5335
5336 if (name != null) {
5337 qPos.add(name);
5338 }
5339
5340 count = (Long)q.uniqueResult();
5341 }
5342 catch (Exception e) {
5343 throw processException(e);
5344 }
5345 finally {
5346 if (count == null) {
5347 count = Long.valueOf(0);
5348 }
5349
5350 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_P_N, finderArgs,
5351 count);
5352
5353 closeSession(session);
5354 }
5355 }
5356
5357 return count.intValue();
5358 }
5359
5360
5369 public int countByG_P_M(long groupId, long parentFolderId,
5370 boolean mountPoint) throws SystemException {
5371 Object[] finderArgs = new Object[] { groupId, parentFolderId, mountPoint };
5372
5373 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_P_M,
5374 finderArgs, this);
5375
5376 if (count == null) {
5377 StringBundler query = new StringBundler(4);
5378
5379 query.append(_SQL_COUNT_DLFOLDER_WHERE);
5380
5381 query.append(_FINDER_COLUMN_G_P_M_GROUPID_2);
5382
5383 query.append(_FINDER_COLUMN_G_P_M_PARENTFOLDERID_2);
5384
5385 query.append(_FINDER_COLUMN_G_P_M_MOUNTPOINT_2);
5386
5387 String sql = query.toString();
5388
5389 Session session = null;
5390
5391 try {
5392 session = openSession();
5393
5394 Query q = session.createQuery(sql);
5395
5396 QueryPos qPos = QueryPos.getInstance(q);
5397
5398 qPos.add(groupId);
5399
5400 qPos.add(parentFolderId);
5401
5402 qPos.add(mountPoint);
5403
5404 count = (Long)q.uniqueResult();
5405 }
5406 catch (Exception e) {
5407 throw processException(e);
5408 }
5409 finally {
5410 if (count == null) {
5411 count = Long.valueOf(0);
5412 }
5413
5414 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_P_M,
5415 finderArgs, count);
5416
5417 closeSession(session);
5418 }
5419 }
5420
5421 return count.intValue();
5422 }
5423
5424
5433 public int filterCountByG_P_M(long groupId, long parentFolderId,
5434 boolean mountPoint) throws SystemException {
5435 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
5436 return countByG_P_M(groupId, parentFolderId, mountPoint);
5437 }
5438
5439 StringBundler query = new StringBundler(4);
5440
5441 query.append(_FILTER_SQL_COUNT_DLFOLDER_WHERE);
5442
5443 query.append(_FINDER_COLUMN_G_P_M_GROUPID_2);
5444
5445 query.append(_FINDER_COLUMN_G_P_M_PARENTFOLDERID_2);
5446
5447 query.append(_FINDER_COLUMN_G_P_M_MOUNTPOINT_2);
5448
5449 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
5450 DLFolder.class.getName(),
5451 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
5452
5453 Session session = null;
5454
5455 try {
5456 session = openSession();
5457
5458 SQLQuery q = session.createSQLQuery(sql);
5459
5460 q.addScalar(COUNT_COLUMN_NAME,
5461 com.liferay.portal.kernel.dao.orm.Type.LONG);
5462
5463 QueryPos qPos = QueryPos.getInstance(q);
5464
5465 qPos.add(groupId);
5466
5467 qPos.add(parentFolderId);
5468
5469 qPos.add(mountPoint);
5470
5471 Long count = (Long)q.uniqueResult();
5472
5473 return count.intValue();
5474 }
5475 catch (Exception e) {
5476 throw processException(e);
5477 }
5478 finally {
5479 closeSession(session);
5480 }
5481 }
5482
5483
5492 public int countByG_P_N(long groupId, long parentFolderId, String name)
5493 throws SystemException {
5494 Object[] finderArgs = new Object[] { groupId, parentFolderId, name };
5495
5496 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_P_N,
5497 finderArgs, this);
5498
5499 if (count == null) {
5500 StringBundler query = new StringBundler(4);
5501
5502 query.append(_SQL_COUNT_DLFOLDER_WHERE);
5503
5504 query.append(_FINDER_COLUMN_G_P_N_GROUPID_2);
5505
5506 query.append(_FINDER_COLUMN_G_P_N_PARENTFOLDERID_2);
5507
5508 if (name == null) {
5509 query.append(_FINDER_COLUMN_G_P_N_NAME_1);
5510 }
5511 else {
5512 if (name.equals(StringPool.BLANK)) {
5513 query.append(_FINDER_COLUMN_G_P_N_NAME_3);
5514 }
5515 else {
5516 query.append(_FINDER_COLUMN_G_P_N_NAME_2);
5517 }
5518 }
5519
5520 String sql = query.toString();
5521
5522 Session session = null;
5523
5524 try {
5525 session = openSession();
5526
5527 Query q = session.createQuery(sql);
5528
5529 QueryPos qPos = QueryPos.getInstance(q);
5530
5531 qPos.add(groupId);
5532
5533 qPos.add(parentFolderId);
5534
5535 if (name != null) {
5536 qPos.add(name);
5537 }
5538
5539 count = (Long)q.uniqueResult();
5540 }
5541 catch (Exception e) {
5542 throw processException(e);
5543 }
5544 finally {
5545 if (count == null) {
5546 count = Long.valueOf(0);
5547 }
5548
5549 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_P_N,
5550 finderArgs, count);
5551
5552 closeSession(session);
5553 }
5554 }
5555
5556 return count.intValue();
5557 }
5558
5559
5565 public int countAll() throws SystemException {
5566 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
5567 FINDER_ARGS_EMPTY, this);
5568
5569 if (count == null) {
5570 Session session = null;
5571
5572 try {
5573 session = openSession();
5574
5575 Query q = session.createQuery(_SQL_COUNT_DLFOLDER);
5576
5577 count = (Long)q.uniqueResult();
5578 }
5579 catch (Exception e) {
5580 throw processException(e);
5581 }
5582 finally {
5583 if (count == null) {
5584 count = Long.valueOf(0);
5585 }
5586
5587 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
5588 FINDER_ARGS_EMPTY, count);
5589
5590 closeSession(session);
5591 }
5592 }
5593
5594 return count.intValue();
5595 }
5596
5597
5604 public List<com.liferay.portlet.documentlibrary.model.DLFileEntryType> getDLFileEntryTypes(
5605 long pk) throws SystemException {
5606 return getDLFileEntryTypes(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
5607 }
5608
5609
5622 public List<com.liferay.portlet.documentlibrary.model.DLFileEntryType> getDLFileEntryTypes(
5623 long pk, int start, int end) throws SystemException {
5624 return getDLFileEntryTypes(pk, start, end, null);
5625 }
5626
5627 public static final FinderPath FINDER_PATH_GET_DLFILEENTRYTYPES = new FinderPath(com.liferay.portlet.documentlibrary.model.impl.DLFileEntryTypeModelImpl.ENTITY_CACHE_ENABLED,
5628 DLFolderModelImpl.FINDER_CACHE_ENABLED_DLFILEENTRYTYPES_DLFOLDERS,
5629 com.liferay.portlet.documentlibrary.model.impl.DLFileEntryTypeImpl.class,
5630 DLFolderModelImpl.MAPPING_TABLE_DLFILEENTRYTYPES_DLFOLDERS_NAME,
5631 "getDLFileEntryTypes",
5632 new String[] {
5633 Long.class.getName(), "java.lang.Integer", "java.lang.Integer",
5634 "com.liferay.portal.kernel.util.OrderByComparator"
5635 });
5636
5637 static {
5638 FINDER_PATH_GET_DLFILEENTRYTYPES.setCacheKeyGeneratorCacheName(null);
5639 }
5640
5641
5655 public List<com.liferay.portlet.documentlibrary.model.DLFileEntryType> getDLFileEntryTypes(
5656 long pk, int start, int end, OrderByComparator orderByComparator)
5657 throws SystemException {
5658 Object[] finderArgs = new Object[] { pk, start, end, orderByComparator };
5659
5660 List<com.liferay.portlet.documentlibrary.model.DLFileEntryType> list = (List<com.liferay.portlet.documentlibrary.model.DLFileEntryType>)FinderCacheUtil.getResult(FINDER_PATH_GET_DLFILEENTRYTYPES,
5661 finderArgs, this);
5662
5663 if (list == null) {
5664 Session session = null;
5665
5666 try {
5667 session = openSession();
5668
5669 String sql = null;
5670
5671 if (orderByComparator != null) {
5672 sql = _SQL_GETDLFILEENTRYTYPES.concat(ORDER_BY_CLAUSE)
5673 .concat(orderByComparator.getOrderBy());
5674 }
5675 else {
5676 sql = _SQL_GETDLFILEENTRYTYPES;
5677 }
5678
5679 SQLQuery q = session.createSQLQuery(sql);
5680
5681 q.addEntity("DLFileEntryType",
5682 com.liferay.portlet.documentlibrary.model.impl.DLFileEntryTypeImpl.class);
5683
5684 QueryPos qPos = QueryPos.getInstance(q);
5685
5686 qPos.add(pk);
5687
5688 list = (List<com.liferay.portlet.documentlibrary.model.DLFileEntryType>)QueryUtil.list(q,
5689 getDialect(), start, end);
5690 }
5691 catch (Exception e) {
5692 throw processException(e);
5693 }
5694 finally {
5695 if (list == null) {
5696 FinderCacheUtil.removeResult(FINDER_PATH_GET_DLFILEENTRYTYPES,
5697 finderArgs);
5698 }
5699 else {
5700 dlFileEntryTypePersistence.cacheResult(list);
5701
5702 FinderCacheUtil.putResult(FINDER_PATH_GET_DLFILEENTRYTYPES,
5703 finderArgs, list);
5704 }
5705
5706 closeSession(session);
5707 }
5708 }
5709
5710 return list;
5711 }
5712
5713 public static final FinderPath FINDER_PATH_GET_DLFILEENTRYTYPES_SIZE = new FinderPath(com.liferay.portlet.documentlibrary.model.impl.DLFileEntryTypeModelImpl.ENTITY_CACHE_ENABLED,
5714 DLFolderModelImpl.FINDER_CACHE_ENABLED_DLFILEENTRYTYPES_DLFOLDERS,
5715 Long.class,
5716 DLFolderModelImpl.MAPPING_TABLE_DLFILEENTRYTYPES_DLFOLDERS_NAME,
5717 "getDLFileEntryTypesSize", new String[] { Long.class.getName() });
5718
5719 static {
5720 FINDER_PATH_GET_DLFILEENTRYTYPES_SIZE.setCacheKeyGeneratorCacheName(null);
5721 }
5722
5723
5730 public int getDLFileEntryTypesSize(long pk) throws SystemException {
5731 Object[] finderArgs = new Object[] { pk };
5732
5733 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_GET_DLFILEENTRYTYPES_SIZE,
5734 finderArgs, this);
5735
5736 if (count == null) {
5737 Session session = null;
5738
5739 try {
5740 session = openSession();
5741
5742 SQLQuery q = session.createSQLQuery(_SQL_GETDLFILEENTRYTYPESSIZE);
5743
5744 q.addScalar(COUNT_COLUMN_NAME,
5745 com.liferay.portal.kernel.dao.orm.Type.LONG);
5746
5747 QueryPos qPos = QueryPos.getInstance(q);
5748
5749 qPos.add(pk);
5750
5751 count = (Long)q.uniqueResult();
5752 }
5753 catch (Exception e) {
5754 throw processException(e);
5755 }
5756 finally {
5757 if (count == null) {
5758 count = Long.valueOf(0);
5759 }
5760
5761 FinderCacheUtil.putResult(FINDER_PATH_GET_DLFILEENTRYTYPES_SIZE,
5762 finderArgs, count);
5763
5764 closeSession(session);
5765 }
5766 }
5767
5768 return count.intValue();
5769 }
5770
5771 public static final FinderPath FINDER_PATH_CONTAINS_DLFILEENTRYTYPE = new FinderPath(com.liferay.portlet.documentlibrary.model.impl.DLFileEntryTypeModelImpl.ENTITY_CACHE_ENABLED,
5772 DLFolderModelImpl.FINDER_CACHE_ENABLED_DLFILEENTRYTYPES_DLFOLDERS,
5773 Boolean.class,
5774 DLFolderModelImpl.MAPPING_TABLE_DLFILEENTRYTYPES_DLFOLDERS_NAME,
5775 "containsDLFileEntryType",
5776 new String[] { Long.class.getName(), Long.class.getName() });
5777
5778
5786 public boolean containsDLFileEntryType(long pk, long dlFileEntryTypePK)
5787 throws SystemException {
5788 Object[] finderArgs = new Object[] { pk, dlFileEntryTypePK };
5789
5790 Boolean value = (Boolean)FinderCacheUtil.getResult(FINDER_PATH_CONTAINS_DLFILEENTRYTYPE,
5791 finderArgs, this);
5792
5793 if (value == null) {
5794 try {
5795 value = Boolean.valueOf(containsDLFileEntryType.contains(pk,
5796 dlFileEntryTypePK));
5797 }
5798 catch (Exception e) {
5799 throw processException(e);
5800 }
5801 finally {
5802 if (value == null) {
5803 value = Boolean.FALSE;
5804 }
5805
5806 FinderCacheUtil.putResult(FINDER_PATH_CONTAINS_DLFILEENTRYTYPE,
5807 finderArgs, value);
5808 }
5809 }
5810
5811 return value.booleanValue();
5812 }
5813
5814
5821 public boolean containsDLFileEntryTypes(long pk) throws SystemException {
5822 if (getDLFileEntryTypesSize(pk) > 0) {
5823 return true;
5824 }
5825 else {
5826 return false;
5827 }
5828 }
5829
5830
5837 public void addDLFileEntryType(long pk, long dlFileEntryTypePK)
5838 throws SystemException {
5839 try {
5840 addDLFileEntryType.add(pk, dlFileEntryTypePK);
5841 }
5842 catch (Exception e) {
5843 throw processException(e);
5844 }
5845 finally {
5846 FinderCacheUtil.clearCache(DLFolderModelImpl.MAPPING_TABLE_DLFILEENTRYTYPES_DLFOLDERS_NAME);
5847 }
5848 }
5849
5850
5857 public void addDLFileEntryType(long pk,
5858 com.liferay.portlet.documentlibrary.model.DLFileEntryType dlFileEntryType)
5859 throws SystemException {
5860 try {
5861 addDLFileEntryType.add(pk, dlFileEntryType.getPrimaryKey());
5862 }
5863 catch (Exception e) {
5864 throw processException(e);
5865 }
5866 finally {
5867 FinderCacheUtil.clearCache(DLFolderModelImpl.MAPPING_TABLE_DLFILEENTRYTYPES_DLFOLDERS_NAME);
5868 }
5869 }
5870
5871
5878 public void addDLFileEntryTypes(long pk, long[] dlFileEntryTypePKs)
5879 throws SystemException {
5880 try {
5881 for (long dlFileEntryTypePK : dlFileEntryTypePKs) {
5882 addDLFileEntryType.add(pk, dlFileEntryTypePK);
5883 }
5884 }
5885 catch (Exception e) {
5886 throw processException(e);
5887 }
5888 finally {
5889 FinderCacheUtil.clearCache(DLFolderModelImpl.MAPPING_TABLE_DLFILEENTRYTYPES_DLFOLDERS_NAME);
5890 }
5891 }
5892
5893
5900 public void addDLFileEntryTypes(long pk,
5901 List<com.liferay.portlet.documentlibrary.model.DLFileEntryType> dlFileEntryTypes)
5902 throws SystemException {
5903 try {
5904 for (com.liferay.portlet.documentlibrary.model.DLFileEntryType dlFileEntryType : dlFileEntryTypes) {
5905 addDLFileEntryType.add(pk, dlFileEntryType.getPrimaryKey());
5906 }
5907 }
5908 catch (Exception e) {
5909 throw processException(e);
5910 }
5911 finally {
5912 FinderCacheUtil.clearCache(DLFolderModelImpl.MAPPING_TABLE_DLFILEENTRYTYPES_DLFOLDERS_NAME);
5913 }
5914 }
5915
5916
5922 public void clearDLFileEntryTypes(long pk) throws SystemException {
5923 try {
5924 clearDLFileEntryTypes.clear(pk);
5925 }
5926 catch (Exception e) {
5927 throw processException(e);
5928 }
5929 finally {
5930 FinderCacheUtil.clearCache(DLFolderModelImpl.MAPPING_TABLE_DLFILEENTRYTYPES_DLFOLDERS_NAME);
5931 }
5932 }
5933
5934
5941 public void removeDLFileEntryType(long pk, long dlFileEntryTypePK)
5942 throws SystemException {
5943 try {
5944 removeDLFileEntryType.remove(pk, dlFileEntryTypePK);
5945 }
5946 catch (Exception e) {
5947 throw processException(e);
5948 }
5949 finally {
5950 FinderCacheUtil.clearCache(DLFolderModelImpl.MAPPING_TABLE_DLFILEENTRYTYPES_DLFOLDERS_NAME);
5951 }
5952 }
5953
5954
5961 public void removeDLFileEntryType(long pk,
5962 com.liferay.portlet.documentlibrary.model.DLFileEntryType dlFileEntryType)
5963 throws SystemException {
5964 try {
5965 removeDLFileEntryType.remove(pk, dlFileEntryType.getPrimaryKey());
5966 }
5967 catch (Exception e) {
5968 throw processException(e);
5969 }
5970 finally {
5971 FinderCacheUtil.clearCache(DLFolderModelImpl.MAPPING_TABLE_DLFILEENTRYTYPES_DLFOLDERS_NAME);
5972 }
5973 }
5974
5975
5982 public void removeDLFileEntryTypes(long pk, long[] dlFileEntryTypePKs)
5983 throws SystemException {
5984 try {
5985 for (long dlFileEntryTypePK : dlFileEntryTypePKs) {
5986 removeDLFileEntryType.remove(pk, dlFileEntryTypePK);
5987 }
5988 }
5989 catch (Exception e) {
5990 throw processException(e);
5991 }
5992 finally {
5993 FinderCacheUtil.clearCache(DLFolderModelImpl.MAPPING_TABLE_DLFILEENTRYTYPES_DLFOLDERS_NAME);
5994 }
5995 }
5996
5997
6004 public void removeDLFileEntryTypes(long pk,
6005 List<com.liferay.portlet.documentlibrary.model.DLFileEntryType> dlFileEntryTypes)
6006 throws SystemException {
6007 try {
6008 for (com.liferay.portlet.documentlibrary.model.DLFileEntryType dlFileEntryType : dlFileEntryTypes) {
6009 removeDLFileEntryType.remove(pk, dlFileEntryType.getPrimaryKey());
6010 }
6011 }
6012 catch (Exception e) {
6013 throw processException(e);
6014 }
6015 finally {
6016 FinderCacheUtil.clearCache(DLFolderModelImpl.MAPPING_TABLE_DLFILEENTRYTYPES_DLFOLDERS_NAME);
6017 }
6018 }
6019
6020
6027 public void setDLFileEntryTypes(long pk, long[] dlFileEntryTypePKs)
6028 throws SystemException {
6029 try {
6030 Set<Long> dlFileEntryTypePKSet = SetUtil.fromArray(dlFileEntryTypePKs);
6031
6032 List<com.liferay.portlet.documentlibrary.model.DLFileEntryType> dlFileEntryTypes =
6033 getDLFileEntryTypes(pk);
6034
6035 for (com.liferay.portlet.documentlibrary.model.DLFileEntryType dlFileEntryType : dlFileEntryTypes) {
6036 if (!dlFileEntryTypePKSet.remove(
6037 dlFileEntryType.getPrimaryKey())) {
6038 removeDLFileEntryType.remove(pk,
6039 dlFileEntryType.getPrimaryKey());
6040 }
6041 }
6042
6043 for (Long dlFileEntryTypePK : dlFileEntryTypePKSet) {
6044 addDLFileEntryType.add(pk, dlFileEntryTypePK);
6045 }
6046 }
6047 catch (Exception e) {
6048 throw processException(e);
6049 }
6050 finally {
6051 FinderCacheUtil.clearCache(DLFolderModelImpl.MAPPING_TABLE_DLFILEENTRYTYPES_DLFOLDERS_NAME);
6052 }
6053 }
6054
6055
6062 public void setDLFileEntryTypes(long pk,
6063 List<com.liferay.portlet.documentlibrary.model.DLFileEntryType> dlFileEntryTypes)
6064 throws SystemException {
6065 try {
6066 long[] dlFileEntryTypePKs = new long[dlFileEntryTypes.size()];
6067
6068 for (int i = 0; i < dlFileEntryTypes.size(); i++) {
6069 com.liferay.portlet.documentlibrary.model.DLFileEntryType dlFileEntryType =
6070 dlFileEntryTypes.get(i);
6071
6072 dlFileEntryTypePKs[i] = dlFileEntryType.getPrimaryKey();
6073 }
6074
6075 setDLFileEntryTypes(pk, dlFileEntryTypePKs);
6076 }
6077 catch (Exception e) {
6078 throw processException(e);
6079 }
6080 finally {
6081 FinderCacheUtil.clearCache(DLFolderModelImpl.MAPPING_TABLE_DLFILEENTRYTYPES_DLFOLDERS_NAME);
6082 }
6083 }
6084
6085
6088 public void afterPropertiesSet() {
6089 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
6090 com.liferay.portal.util.PropsUtil.get(
6091 "value.object.listener.com.liferay.portlet.documentlibrary.model.DLFolder")));
6092
6093 if (listenerClassNames.length > 0) {
6094 try {
6095 List<ModelListener<DLFolder>> listenersList = new ArrayList<ModelListener<DLFolder>>();
6096
6097 for (String listenerClassName : listenerClassNames) {
6098 listenersList.add((ModelListener<DLFolder>)InstanceFactory.newInstance(
6099 listenerClassName));
6100 }
6101
6102 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
6103 }
6104 catch (Exception e) {
6105 _log.error(e);
6106 }
6107 }
6108
6109 containsDLFileEntryType = new ContainsDLFileEntryType();
6110
6111 addDLFileEntryType = new AddDLFileEntryType();
6112 clearDLFileEntryTypes = new ClearDLFileEntryTypes();
6113 removeDLFileEntryType = new RemoveDLFileEntryType();
6114 }
6115
6116 public void destroy() {
6117 EntityCacheUtil.removeCache(DLFolderImpl.class.getName());
6118 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
6119 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
6120 }
6121
6122 @BeanReference(type = DLContentPersistence.class)
6123 protected DLContentPersistence dlContentPersistence;
6124 @BeanReference(type = DLFileEntryPersistence.class)
6125 protected DLFileEntryPersistence dlFileEntryPersistence;
6126 @BeanReference(type = DLFileEntryMetadataPersistence.class)
6127 protected DLFileEntryMetadataPersistence dlFileEntryMetadataPersistence;
6128 @BeanReference(type = DLFileEntryTypePersistence.class)
6129 protected DLFileEntryTypePersistence dlFileEntryTypePersistence;
6130 @BeanReference(type = DLFileRankPersistence.class)
6131 protected DLFileRankPersistence dlFileRankPersistence;
6132 @BeanReference(type = DLFileShortcutPersistence.class)
6133 protected DLFileShortcutPersistence dlFileShortcutPersistence;
6134 @BeanReference(type = DLFileVersionPersistence.class)
6135 protected DLFileVersionPersistence dlFileVersionPersistence;
6136 @BeanReference(type = DLFolderPersistence.class)
6137 protected DLFolderPersistence dlFolderPersistence;
6138 @BeanReference(type = DLSyncPersistence.class)
6139 protected DLSyncPersistence dlSyncPersistence;
6140 @BeanReference(type = GroupPersistence.class)
6141 protected GroupPersistence groupPersistence;
6142 @BeanReference(type = LockPersistence.class)
6143 protected LockPersistence lockPersistence;
6144 @BeanReference(type = ResourcePersistence.class)
6145 protected ResourcePersistence resourcePersistence;
6146 @BeanReference(type = UserPersistence.class)
6147 protected UserPersistence userPersistence;
6148 @BeanReference(type = WebDAVPropsPersistence.class)
6149 protected WebDAVPropsPersistence webDAVPropsPersistence;
6150 @BeanReference(type = WorkflowDefinitionLinkPersistence.class)
6151 protected WorkflowDefinitionLinkPersistence workflowDefinitionLinkPersistence;
6152 @BeanReference(type = WorkflowInstanceLinkPersistence.class)
6153 protected WorkflowInstanceLinkPersistence workflowInstanceLinkPersistence;
6154 @BeanReference(type = ExpandoValuePersistence.class)
6155 protected ExpandoValuePersistence expandoValuePersistence;
6156 protected ContainsDLFileEntryType containsDLFileEntryType;
6157 protected AddDLFileEntryType addDLFileEntryType;
6158 protected ClearDLFileEntryTypes clearDLFileEntryTypes;
6159 protected RemoveDLFileEntryType removeDLFileEntryType;
6160
6161 protected class ContainsDLFileEntryType {
6162 protected ContainsDLFileEntryType() {
6163 _mappingSqlQuery = MappingSqlQueryFactoryUtil.getMappingSqlQuery(getDataSource(),
6164 _SQL_CONTAINSDLFILEENTRYTYPE,
6165 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT },
6166 RowMapper.COUNT);
6167 }
6168
6169 protected boolean contains(long folderId, long fileEntryTypeId) {
6170 List<Integer> results = _mappingSqlQuery.execute(new Object[] {
6171 new Long(folderId), new Long(fileEntryTypeId)
6172 });
6173
6174 if (results.size() > 0) {
6175 Integer count = results.get(0);
6176
6177 if (count.intValue() > 0) {
6178 return true;
6179 }
6180 }
6181
6182 return false;
6183 }
6184
6185 private MappingSqlQuery<Integer> _mappingSqlQuery;
6186 }
6187
6188 protected class AddDLFileEntryType {
6189 protected AddDLFileEntryType() {
6190 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
6191 "INSERT INTO DLFileEntryTypes_DLFolders (folderId, fileEntryTypeId) VALUES (?, ?)",
6192 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
6193 }
6194
6195 protected void add(long folderId, long fileEntryTypeId)
6196 throws SystemException {
6197 if (!containsDLFileEntryType.contains(folderId, fileEntryTypeId)) {
6198 ModelListener<com.liferay.portlet.documentlibrary.model.DLFileEntryType>[] dlFileEntryTypeListeners =
6199 dlFileEntryTypePersistence.getListeners();
6200
6201 for (ModelListener<DLFolder> listener : listeners) {
6202 listener.onBeforeAddAssociation(folderId,
6203 com.liferay.portlet.documentlibrary.model.DLFileEntryType.class.getName(),
6204 fileEntryTypeId);
6205 }
6206
6207 for (ModelListener<com.liferay.portlet.documentlibrary.model.DLFileEntryType> listener : dlFileEntryTypeListeners) {
6208 listener.onBeforeAddAssociation(fileEntryTypeId,
6209 DLFolder.class.getName(), folderId);
6210 }
6211
6212 _sqlUpdate.update(new Object[] {
6213 new Long(folderId), new Long(fileEntryTypeId)
6214 });
6215
6216 for (ModelListener<DLFolder> listener : listeners) {
6217 listener.onAfterAddAssociation(folderId,
6218 com.liferay.portlet.documentlibrary.model.DLFileEntryType.class.getName(),
6219 fileEntryTypeId);
6220 }
6221
6222 for (ModelListener<com.liferay.portlet.documentlibrary.model.DLFileEntryType> listener : dlFileEntryTypeListeners) {
6223 listener.onAfterAddAssociation(fileEntryTypeId,
6224 DLFolder.class.getName(), folderId);
6225 }
6226 }
6227 }
6228
6229 private SqlUpdate _sqlUpdate;
6230 }
6231
6232 protected class ClearDLFileEntryTypes {
6233 protected ClearDLFileEntryTypes() {
6234 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
6235 "DELETE FROM DLFileEntryTypes_DLFolders WHERE folderId = ?",
6236 new int[] { java.sql.Types.BIGINT });
6237 }
6238
6239 protected void clear(long folderId) throws SystemException {
6240 ModelListener<com.liferay.portlet.documentlibrary.model.DLFileEntryType>[] dlFileEntryTypeListeners =
6241 dlFileEntryTypePersistence.getListeners();
6242
6243 List<com.liferay.portlet.documentlibrary.model.DLFileEntryType> dlFileEntryTypes =
6244 null;
6245
6246 if ((listeners.length > 0) ||
6247 (dlFileEntryTypeListeners.length > 0)) {
6248 dlFileEntryTypes = getDLFileEntryTypes(folderId);
6249
6250 for (com.liferay.portlet.documentlibrary.model.DLFileEntryType dlFileEntryType : dlFileEntryTypes) {
6251 for (ModelListener<DLFolder> listener : listeners) {
6252 listener.onBeforeRemoveAssociation(folderId,
6253 com.liferay.portlet.documentlibrary.model.DLFileEntryType.class.getName(),
6254 dlFileEntryType.getPrimaryKey());
6255 }
6256
6257 for (ModelListener<com.liferay.portlet.documentlibrary.model.DLFileEntryType> listener : dlFileEntryTypeListeners) {
6258 listener.onBeforeRemoveAssociation(dlFileEntryType.getPrimaryKey(),
6259 DLFolder.class.getName(), folderId);
6260 }
6261 }
6262 }
6263
6264 _sqlUpdate.update(new Object[] { new Long(folderId) });
6265
6266 if ((listeners.length > 0) ||
6267 (dlFileEntryTypeListeners.length > 0)) {
6268 for (com.liferay.portlet.documentlibrary.model.DLFileEntryType dlFileEntryType : dlFileEntryTypes) {
6269 for (ModelListener<DLFolder> listener : listeners) {
6270 listener.onAfterRemoveAssociation(folderId,
6271 com.liferay.portlet.documentlibrary.model.DLFileEntryType.class.getName(),
6272 dlFileEntryType.getPrimaryKey());
6273 }
6274
6275 for (ModelListener<com.liferay.portlet.documentlibrary.model.DLFileEntryType> listener : dlFileEntryTypeListeners) {
6276 listener.onAfterRemoveAssociation(dlFileEntryType.getPrimaryKey(),
6277 DLFolder.class.getName(), folderId);
6278 }
6279 }
6280 }
6281 }
6282
6283 private SqlUpdate _sqlUpdate;
6284 }
6285
6286 protected class RemoveDLFileEntryType {
6287 protected RemoveDLFileEntryType() {
6288 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
6289 "DELETE FROM DLFileEntryTypes_DLFolders WHERE folderId = ? AND fileEntryTypeId = ?",
6290 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
6291 }
6292
6293 protected void remove(long folderId, long fileEntryTypeId)
6294 throws SystemException {
6295 if (containsDLFileEntryType.contains(folderId, fileEntryTypeId)) {
6296 ModelListener<com.liferay.portlet.documentlibrary.model.DLFileEntryType>[] dlFileEntryTypeListeners =
6297 dlFileEntryTypePersistence.getListeners();
6298
6299 for (ModelListener<DLFolder> listener : listeners) {
6300 listener.onBeforeRemoveAssociation(folderId,
6301 com.liferay.portlet.documentlibrary.model.DLFileEntryType.class.getName(),
6302 fileEntryTypeId);
6303 }
6304
6305 for (ModelListener<com.liferay.portlet.documentlibrary.model.DLFileEntryType> listener : dlFileEntryTypeListeners) {
6306 listener.onBeforeRemoveAssociation(fileEntryTypeId,
6307 DLFolder.class.getName(), folderId);
6308 }
6309
6310 _sqlUpdate.update(new Object[] {
6311 new Long(folderId), new Long(fileEntryTypeId)
6312 });
6313
6314 for (ModelListener<DLFolder> listener : listeners) {
6315 listener.onAfterRemoveAssociation(folderId,
6316 com.liferay.portlet.documentlibrary.model.DLFileEntryType.class.getName(),
6317 fileEntryTypeId);
6318 }
6319
6320 for (ModelListener<com.liferay.portlet.documentlibrary.model.DLFileEntryType> listener : dlFileEntryTypeListeners) {
6321 listener.onAfterRemoveAssociation(fileEntryTypeId,
6322 DLFolder.class.getName(), folderId);
6323 }
6324 }
6325 }
6326
6327 private SqlUpdate _sqlUpdate;
6328 }
6329
6330 private static final String _SQL_SELECT_DLFOLDER = "SELECT dlFolder FROM DLFolder dlFolder";
6331 private static final String _SQL_SELECT_DLFOLDER_WHERE = "SELECT dlFolder FROM DLFolder dlFolder WHERE ";
6332 private static final String _SQL_COUNT_DLFOLDER = "SELECT COUNT(dlFolder) FROM DLFolder dlFolder";
6333 private static final String _SQL_COUNT_DLFOLDER_WHERE = "SELECT COUNT(dlFolder) FROM DLFolder dlFolder WHERE ";
6334 private static final String _SQL_GETDLFILEENTRYTYPES = "SELECT {DLFileEntryType.*} FROM DLFileEntryType INNER JOIN DLFileEntryTypes_DLFolders ON (DLFileEntryTypes_DLFolders.fileEntryTypeId = DLFileEntryType.fileEntryTypeId) WHERE (DLFileEntryTypes_DLFolders.folderId = ?)";
6335 private static final String _SQL_GETDLFILEENTRYTYPESSIZE = "SELECT COUNT(*) AS COUNT_VALUE FROM DLFileEntryTypes_DLFolders WHERE folderId = ?";
6336 private static final String _SQL_CONTAINSDLFILEENTRYTYPE = "SELECT COUNT(*) AS COUNT_VALUE FROM DLFileEntryTypes_DLFolders WHERE folderId = ? AND fileEntryTypeId = ?";
6337 private static final String _FINDER_COLUMN_UUID_UUID_1 = "dlFolder.uuid IS NULL";
6338 private static final String _FINDER_COLUMN_UUID_UUID_2 = "dlFolder.uuid = ?";
6339 private static final String _FINDER_COLUMN_UUID_UUID_3 = "(dlFolder.uuid IS NULL OR dlFolder.uuid = ?)";
6340 private static final String _FINDER_COLUMN_UUID_G_UUID_1 = "dlFolder.uuid IS NULL AND ";
6341 private static final String _FINDER_COLUMN_UUID_G_UUID_2 = "dlFolder.uuid = ? AND ";
6342 private static final String _FINDER_COLUMN_UUID_G_UUID_3 = "(dlFolder.uuid IS NULL OR dlFolder.uuid = ?) AND ";
6343 private static final String _FINDER_COLUMN_UUID_G_GROUPID_2 = "dlFolder.groupId = ?";
6344 private static final String _FINDER_COLUMN_GROUPID_GROUPID_2 = "dlFolder.groupId = ?";
6345 private static final String _FINDER_COLUMN_COMPANYID_COMPANYID_2 = "dlFolder.companyId = ?";
6346 private static final String _FINDER_COLUMN_REPOSITORYID_REPOSITORYID_2 = "dlFolder.repositoryId = ?";
6347 private static final String _FINDER_COLUMN_G_P_GROUPID_2 = "dlFolder.groupId = ? AND ";
6348 private static final String _FINDER_COLUMN_G_P_PARENTFOLDERID_2 = "dlFolder.parentFolderId = ?";
6349 private static final String _FINDER_COLUMN_P_N_PARENTFOLDERID_2 = "dlFolder.parentFolderId = ? AND ";
6350 private static final String _FINDER_COLUMN_P_N_NAME_1 = "dlFolder.name IS NULL";
6351 private static final String _FINDER_COLUMN_P_N_NAME_2 = "dlFolder.name = ?";
6352 private static final String _FINDER_COLUMN_P_N_NAME_3 = "(dlFolder.name IS NULL OR dlFolder.name = ?)";
6353 private static final String _FINDER_COLUMN_G_P_M_GROUPID_2 = "dlFolder.groupId = ? AND ";
6354 private static final String _FINDER_COLUMN_G_P_M_PARENTFOLDERID_2 = "dlFolder.parentFolderId = ? AND ";
6355 private static final String _FINDER_COLUMN_G_P_M_MOUNTPOINT_2 = "dlFolder.mountPoint = ?";
6356 private static final String _FINDER_COLUMN_G_P_N_GROUPID_2 = "dlFolder.groupId = ? AND ";
6357 private static final String _FINDER_COLUMN_G_P_N_PARENTFOLDERID_2 = "dlFolder.parentFolderId = ? AND ";
6358 private static final String _FINDER_COLUMN_G_P_N_NAME_1 = "dlFolder.name IS NULL";
6359 private static final String _FINDER_COLUMN_G_P_N_NAME_2 = "dlFolder.name = ?";
6360 private static final String _FINDER_COLUMN_G_P_N_NAME_3 = "(dlFolder.name IS NULL OR dlFolder.name = ?)";
6361 private static final String _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN = "dlFolder.folderId";
6362 private static final String _FILTER_SQL_SELECT_DLFOLDER_WHERE = "SELECT DISTINCT {dlFolder.*} FROM DLFolder dlFolder WHERE ";
6363 private static final String _FILTER_SQL_SELECT_DLFOLDER_NO_INLINE_DISTINCT_WHERE_1 =
6364 "SELECT {DLFolder.*} FROM (SELECT DISTINCT dlFolder.folderId FROM DLFolder dlFolder WHERE ";
6365 private static final String _FILTER_SQL_SELECT_DLFOLDER_NO_INLINE_DISTINCT_WHERE_2 =
6366 ") TEMP_TABLE INNER JOIN DLFolder ON TEMP_TABLE.folderId = DLFolder.folderId";
6367 private static final String _FILTER_SQL_COUNT_DLFOLDER_WHERE = "SELECT COUNT(DISTINCT dlFolder.folderId) AS COUNT_VALUE FROM DLFolder dlFolder WHERE ";
6368 private static final String _FILTER_ENTITY_ALIAS = "dlFolder";
6369 private static final String _FILTER_ENTITY_TABLE = "DLFolder";
6370 private static final String _ORDER_BY_ENTITY_ALIAS = "dlFolder.";
6371 private static final String _ORDER_BY_ENTITY_TABLE = "DLFolder.";
6372 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No DLFolder exists with the primary key ";
6373 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No DLFolder exists with the key {";
6374 private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
6375 private static Log _log = LogFactoryUtil.getLog(DLFolderPersistenceImpl.class);
6376 private static DLFolder _nullDLFolder = new DLFolderImpl() {
6377 @Override
6378 public Object clone() {
6379 return this;
6380 }
6381
6382 @Override
6383 public CacheModel<DLFolder> toCacheModel() {
6384 return _nullDLFolderCacheModel;
6385 }
6386 };
6387
6388 private static CacheModel<DLFolder> _nullDLFolderCacheModel = new CacheModel<DLFolder>() {
6389 public DLFolder toEntityModel() {
6390 return _nullDLFolder;
6391 }
6392 };
6393 }