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_WITHOUT_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_WITH_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
520 else {
521 if ((dlFolderModelImpl.getColumnBitmask() &
522 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID.getColumnBitmask()) != 0) {
523 Object[] args = new Object[] { dlFolderModelImpl.getOriginalUuid() };
524
525 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
526 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
527 args);
528
529 args = new Object[] { dlFolderModelImpl.getUuid() };
530
531 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
532 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
533 args);
534 }
535
536 if ((dlFolderModelImpl.getColumnBitmask() &
537 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID.getColumnBitmask()) != 0) {
538 Object[] args = new Object[] {
539 Long.valueOf(dlFolderModelImpl.getOriginalGroupId())
540 };
541
542 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
543 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
544 args);
545
546 args = new Object[] { Long.valueOf(dlFolderModelImpl.getGroupId()) };
547
548 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
549 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
550 args);
551 }
552
553 if ((dlFolderModelImpl.getColumnBitmask() &
554 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID.getColumnBitmask()) != 0) {
555 Object[] args = new Object[] {
556 Long.valueOf(dlFolderModelImpl.getOriginalCompanyId())
557 };
558
559 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_COMPANYID,
560 args);
561 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
562 args);
563
564 args = new Object[] {
565 Long.valueOf(dlFolderModelImpl.getCompanyId())
566 };
567
568 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_COMPANYID,
569 args);
570 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
571 args);
572 }
573
574 if ((dlFolderModelImpl.getColumnBitmask() &
575 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P.getColumnBitmask()) != 0) {
576 Object[] args = new Object[] {
577 Long.valueOf(dlFolderModelImpl.getOriginalGroupId()),
578 Long.valueOf(dlFolderModelImpl.getOriginalParentFolderId())
579 };
580
581 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_P, args);
582 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P,
583 args);
584
585 args = new Object[] {
586 Long.valueOf(dlFolderModelImpl.getGroupId()),
587 Long.valueOf(dlFolderModelImpl.getParentFolderId())
588 };
589
590 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_P, args);
591 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P,
592 args);
593 }
594
595 if ((dlFolderModelImpl.getColumnBitmask() &
596 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_P_N.getColumnBitmask()) != 0) {
597 Object[] args = new Object[] {
598 Long.valueOf(dlFolderModelImpl.getOriginalParentFolderId()),
599
600 dlFolderModelImpl.getOriginalName()
601 };
602
603 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_P_N, args);
604 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_P_N,
605 args);
606
607 args = new Object[] {
608 Long.valueOf(dlFolderModelImpl.getParentFolderId()),
609
610 dlFolderModelImpl.getName()
611 };
612
613 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_P_N, args);
614 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_P_N,
615 args);
616 }
617
618 if ((dlFolderModelImpl.getColumnBitmask() &
619 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_M.getColumnBitmask()) != 0) {
620 Object[] args = new Object[] {
621 Long.valueOf(dlFolderModelImpl.getOriginalGroupId()),
622 Long.valueOf(dlFolderModelImpl.getOriginalParentFolderId()),
623 Boolean.valueOf(dlFolderModelImpl.getOriginalMountPoint())
624 };
625
626 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_P_M, args);
627 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_M,
628 args);
629
630 args = new Object[] {
631 Long.valueOf(dlFolderModelImpl.getGroupId()),
632 Long.valueOf(dlFolderModelImpl.getParentFolderId()),
633 Boolean.valueOf(dlFolderModelImpl.getMountPoint())
634 };
635
636 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_P_M, args);
637 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_M,
638 args);
639 }
640 }
641
642 EntityCacheUtil.putResult(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
643 DLFolderImpl.class, dlFolder.getPrimaryKey(), dlFolder);
644
645 if (isNew) {
646 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
647 new Object[] {
648 dlFolder.getUuid(), Long.valueOf(dlFolder.getGroupId())
649 }, dlFolder);
650
651 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_REPOSITORYID,
652 new Object[] { Long.valueOf(dlFolder.getRepositoryId()) },
653 dlFolder);
654
655 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_P_N,
656 new Object[] {
657 Long.valueOf(dlFolder.getGroupId()),
658 Long.valueOf(dlFolder.getParentFolderId()),
659
660 dlFolder.getName()
661 }, dlFolder);
662 }
663 else {
664 if ((dlFolderModelImpl.getColumnBitmask() &
665 FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) {
666 Object[] args = new Object[] {
667 dlFolderModelImpl.getOriginalUuid(),
668 Long.valueOf(dlFolderModelImpl.getOriginalGroupId())
669 };
670
671 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args);
672 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args);
673
674 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
675 new Object[] {
676 dlFolder.getUuid(), Long.valueOf(dlFolder.getGroupId())
677 }, dlFolder);
678 }
679
680 if ((dlFolderModelImpl.getColumnBitmask() &
681 FINDER_PATH_FETCH_BY_REPOSITORYID.getColumnBitmask()) != 0) {
682 Object[] args = new Object[] {
683 Long.valueOf(dlFolderModelImpl.getOriginalRepositoryId())
684 };
685
686 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_REPOSITORYID,
687 args);
688 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_REPOSITORYID,
689 args);
690
691 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_REPOSITORYID,
692 new Object[] { Long.valueOf(dlFolder.getRepositoryId()) },
693 dlFolder);
694 }
695
696 if ((dlFolderModelImpl.getColumnBitmask() &
697 FINDER_PATH_FETCH_BY_G_P_N.getColumnBitmask()) != 0) {
698 Object[] args = new Object[] {
699 Long.valueOf(dlFolderModelImpl.getOriginalGroupId()),
700 Long.valueOf(dlFolderModelImpl.getOriginalParentFolderId()),
701
702 dlFolderModelImpl.getOriginalName()
703 };
704
705 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_P_N, args);
706 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_P_N, args);
707
708 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_P_N,
709 new Object[] {
710 Long.valueOf(dlFolder.getGroupId()),
711 Long.valueOf(dlFolder.getParentFolderId()),
712
713 dlFolder.getName()
714 }, dlFolder);
715 }
716 }
717
718 return dlFolder;
719 }
720
721 protected DLFolder toUnwrappedModel(DLFolder dlFolder) {
722 if (dlFolder instanceof DLFolderImpl) {
723 return dlFolder;
724 }
725
726 DLFolderImpl dlFolderImpl = new DLFolderImpl();
727
728 dlFolderImpl.setNew(dlFolder.isNew());
729 dlFolderImpl.setPrimaryKey(dlFolder.getPrimaryKey());
730
731 dlFolderImpl.setUuid(dlFolder.getUuid());
732 dlFolderImpl.setFolderId(dlFolder.getFolderId());
733 dlFolderImpl.setGroupId(dlFolder.getGroupId());
734 dlFolderImpl.setCompanyId(dlFolder.getCompanyId());
735 dlFolderImpl.setUserId(dlFolder.getUserId());
736 dlFolderImpl.setUserName(dlFolder.getUserName());
737 dlFolderImpl.setCreateDate(dlFolder.getCreateDate());
738 dlFolderImpl.setModifiedDate(dlFolder.getModifiedDate());
739 dlFolderImpl.setRepositoryId(dlFolder.getRepositoryId());
740 dlFolderImpl.setMountPoint(dlFolder.isMountPoint());
741 dlFolderImpl.setParentFolderId(dlFolder.getParentFolderId());
742 dlFolderImpl.setName(dlFolder.getName());
743 dlFolderImpl.setDescription(dlFolder.getDescription());
744 dlFolderImpl.setLastPostDate(dlFolder.getLastPostDate());
745 dlFolderImpl.setDefaultFileEntryTypeId(dlFolder.getDefaultFileEntryTypeId());
746 dlFolderImpl.setOverrideFileEntryTypes(dlFolder.isOverrideFileEntryTypes());
747
748 return dlFolderImpl;
749 }
750
751
759 @Override
760 public DLFolder findByPrimaryKey(Serializable primaryKey)
761 throws NoSuchModelException, SystemException {
762 return findByPrimaryKey(((Long)primaryKey).longValue());
763 }
764
765
773 public DLFolder findByPrimaryKey(long folderId)
774 throws NoSuchFolderException, SystemException {
775 DLFolder dlFolder = fetchByPrimaryKey(folderId);
776
777 if (dlFolder == null) {
778 if (_log.isWarnEnabled()) {
779 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + folderId);
780 }
781
782 throw new NoSuchFolderException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
783 folderId);
784 }
785
786 return dlFolder;
787 }
788
789
796 @Override
797 public DLFolder fetchByPrimaryKey(Serializable primaryKey)
798 throws SystemException {
799 return fetchByPrimaryKey(((Long)primaryKey).longValue());
800 }
801
802
809 public DLFolder fetchByPrimaryKey(long folderId) throws SystemException {
810 DLFolder dlFolder = (DLFolder)EntityCacheUtil.getResult(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
811 DLFolderImpl.class, folderId);
812
813 if (dlFolder == _nullDLFolder) {
814 return null;
815 }
816
817 if (dlFolder == null) {
818 Session session = null;
819
820 boolean hasException = false;
821
822 try {
823 session = openSession();
824
825 dlFolder = (DLFolder)session.get(DLFolderImpl.class,
826 Long.valueOf(folderId));
827 }
828 catch (Exception e) {
829 hasException = true;
830
831 throw processException(e);
832 }
833 finally {
834 if (dlFolder != null) {
835 cacheResult(dlFolder);
836 }
837 else if (!hasException) {
838 EntityCacheUtil.putResult(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
839 DLFolderImpl.class, folderId, _nullDLFolder);
840 }
841
842 closeSession(session);
843 }
844 }
845
846 return dlFolder;
847 }
848
849
856 public List<DLFolder> findByUuid(String uuid) throws SystemException {
857 return findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
858 }
859
860
873 public List<DLFolder> findByUuid(String uuid, int start, int end)
874 throws SystemException {
875 return findByUuid(uuid, start, end, null);
876 }
877
878
892 public List<DLFolder> findByUuid(String uuid, int start, int end,
893 OrderByComparator orderByComparator) throws SystemException {
894 FinderPath finderPath = null;
895 Object[] finderArgs = null;
896
897 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
898 (orderByComparator == null)) {
899 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID;
900 finderArgs = new Object[] { uuid };
901 }
902 else {
903 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID;
904 finderArgs = new Object[] { uuid, start, end, orderByComparator };
905 }
906
907 List<DLFolder> list = (List<DLFolder>)FinderCacheUtil.getResult(finderPath,
908 finderArgs, this);
909
910 if (list == null) {
911 StringBundler query = null;
912
913 if (orderByComparator != null) {
914 query = new StringBundler(3 +
915 (orderByComparator.getOrderByFields().length * 3));
916 }
917 else {
918 query = new StringBundler(3);
919 }
920
921 query.append(_SQL_SELECT_DLFOLDER_WHERE);
922
923 if (uuid == null) {
924 query.append(_FINDER_COLUMN_UUID_UUID_1);
925 }
926 else {
927 if (uuid.equals(StringPool.BLANK)) {
928 query.append(_FINDER_COLUMN_UUID_UUID_3);
929 }
930 else {
931 query.append(_FINDER_COLUMN_UUID_UUID_2);
932 }
933 }
934
935 if (orderByComparator != null) {
936 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
937 orderByComparator);
938 }
939
940 else {
941 query.append(DLFolderModelImpl.ORDER_BY_JPQL);
942 }
943
944 String sql = query.toString();
945
946 Session session = null;
947
948 try {
949 session = openSession();
950
951 Query q = session.createQuery(sql);
952
953 QueryPos qPos = QueryPos.getInstance(q);
954
955 if (uuid != null) {
956 qPos.add(uuid);
957 }
958
959 list = (List<DLFolder>)QueryUtil.list(q, getDialect(), start,
960 end);
961 }
962 catch (Exception e) {
963 throw processException(e);
964 }
965 finally {
966 if (list == null) {
967 FinderCacheUtil.removeResult(finderPath, finderArgs);
968 }
969 else {
970 cacheResult(list);
971
972 FinderCacheUtil.putResult(finderPath, finderArgs, list);
973 }
974
975 closeSession(session);
976 }
977 }
978
979 return list;
980 }
981
982
995 public DLFolder findByUuid_First(String uuid,
996 OrderByComparator orderByComparator)
997 throws NoSuchFolderException, SystemException {
998 List<DLFolder> list = findByUuid(uuid, 0, 1, orderByComparator);
999
1000 if (list.isEmpty()) {
1001 StringBundler msg = new StringBundler(4);
1002
1003 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1004
1005 msg.append("uuid=");
1006 msg.append(uuid);
1007
1008 msg.append(StringPool.CLOSE_CURLY_BRACE);
1009
1010 throw new NoSuchFolderException(msg.toString());
1011 }
1012 else {
1013 return list.get(0);
1014 }
1015 }
1016
1017
1030 public DLFolder findByUuid_Last(String uuid,
1031 OrderByComparator orderByComparator)
1032 throws NoSuchFolderException, SystemException {
1033 int count = countByUuid(uuid);
1034
1035 List<DLFolder> list = findByUuid(uuid, count - 1, count,
1036 orderByComparator);
1037
1038 if (list.isEmpty()) {
1039 StringBundler msg = new StringBundler(4);
1040
1041 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1042
1043 msg.append("uuid=");
1044 msg.append(uuid);
1045
1046 msg.append(StringPool.CLOSE_CURLY_BRACE);
1047
1048 throw new NoSuchFolderException(msg.toString());
1049 }
1050 else {
1051 return list.get(0);
1052 }
1053 }
1054
1055
1069 public DLFolder[] findByUuid_PrevAndNext(long folderId, String uuid,
1070 OrderByComparator orderByComparator)
1071 throws NoSuchFolderException, SystemException {
1072 DLFolder dlFolder = findByPrimaryKey(folderId);
1073
1074 Session session = null;
1075
1076 try {
1077 session = openSession();
1078
1079 DLFolder[] array = new DLFolderImpl[3];
1080
1081 array[0] = getByUuid_PrevAndNext(session, dlFolder, uuid,
1082 orderByComparator, true);
1083
1084 array[1] = dlFolder;
1085
1086 array[2] = getByUuid_PrevAndNext(session, dlFolder, uuid,
1087 orderByComparator, false);
1088
1089 return array;
1090 }
1091 catch (Exception e) {
1092 throw processException(e);
1093 }
1094 finally {
1095 closeSession(session);
1096 }
1097 }
1098
1099 protected DLFolder getByUuid_PrevAndNext(Session session,
1100 DLFolder dlFolder, String uuid, OrderByComparator orderByComparator,
1101 boolean previous) {
1102 StringBundler query = null;
1103
1104 if (orderByComparator != null) {
1105 query = new StringBundler(6 +
1106 (orderByComparator.getOrderByFields().length * 6));
1107 }
1108 else {
1109 query = new StringBundler(3);
1110 }
1111
1112 query.append(_SQL_SELECT_DLFOLDER_WHERE);
1113
1114 if (uuid == null) {
1115 query.append(_FINDER_COLUMN_UUID_UUID_1);
1116 }
1117 else {
1118 if (uuid.equals(StringPool.BLANK)) {
1119 query.append(_FINDER_COLUMN_UUID_UUID_3);
1120 }
1121 else {
1122 query.append(_FINDER_COLUMN_UUID_UUID_2);
1123 }
1124 }
1125
1126 if (orderByComparator != null) {
1127 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1128
1129 if (orderByConditionFields.length > 0) {
1130 query.append(WHERE_AND);
1131 }
1132
1133 for (int i = 0; i < orderByConditionFields.length; i++) {
1134 query.append(_ORDER_BY_ENTITY_ALIAS);
1135 query.append(orderByConditionFields[i]);
1136
1137 if ((i + 1) < orderByConditionFields.length) {
1138 if (orderByComparator.isAscending() ^ previous) {
1139 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1140 }
1141 else {
1142 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1143 }
1144 }
1145 else {
1146 if (orderByComparator.isAscending() ^ previous) {
1147 query.append(WHERE_GREATER_THAN);
1148 }
1149 else {
1150 query.append(WHERE_LESSER_THAN);
1151 }
1152 }
1153 }
1154
1155 query.append(ORDER_BY_CLAUSE);
1156
1157 String[] orderByFields = orderByComparator.getOrderByFields();
1158
1159 for (int i = 0; i < orderByFields.length; i++) {
1160 query.append(_ORDER_BY_ENTITY_ALIAS);
1161 query.append(orderByFields[i]);
1162
1163 if ((i + 1) < orderByFields.length) {
1164 if (orderByComparator.isAscending() ^ previous) {
1165 query.append(ORDER_BY_ASC_HAS_NEXT);
1166 }
1167 else {
1168 query.append(ORDER_BY_DESC_HAS_NEXT);
1169 }
1170 }
1171 else {
1172 if (orderByComparator.isAscending() ^ previous) {
1173 query.append(ORDER_BY_ASC);
1174 }
1175 else {
1176 query.append(ORDER_BY_DESC);
1177 }
1178 }
1179 }
1180 }
1181
1182 else {
1183 query.append(DLFolderModelImpl.ORDER_BY_JPQL);
1184 }
1185
1186 String sql = query.toString();
1187
1188 Query q = session.createQuery(sql);
1189
1190 q.setFirstResult(0);
1191 q.setMaxResults(2);
1192
1193 QueryPos qPos = QueryPos.getInstance(q);
1194
1195 if (uuid != null) {
1196 qPos.add(uuid);
1197 }
1198
1199 if (orderByComparator != null) {
1200 Object[] values = orderByComparator.getOrderByConditionValues(dlFolder);
1201
1202 for (Object value : values) {
1203 qPos.add(value);
1204 }
1205 }
1206
1207 List<DLFolder> list = q.list();
1208
1209 if (list.size() == 2) {
1210 return list.get(1);
1211 }
1212 else {
1213 return null;
1214 }
1215 }
1216
1217
1226 public DLFolder findByUUID_G(String uuid, long groupId)
1227 throws NoSuchFolderException, SystemException {
1228 DLFolder dlFolder = fetchByUUID_G(uuid, groupId);
1229
1230 if (dlFolder == null) {
1231 StringBundler msg = new StringBundler(6);
1232
1233 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1234
1235 msg.append("uuid=");
1236 msg.append(uuid);
1237
1238 msg.append(", groupId=");
1239 msg.append(groupId);
1240
1241 msg.append(StringPool.CLOSE_CURLY_BRACE);
1242
1243 if (_log.isWarnEnabled()) {
1244 _log.warn(msg.toString());
1245 }
1246
1247 throw new NoSuchFolderException(msg.toString());
1248 }
1249
1250 return dlFolder;
1251 }
1252
1253
1261 public DLFolder fetchByUUID_G(String uuid, long groupId)
1262 throws SystemException {
1263 return fetchByUUID_G(uuid, groupId, true);
1264 }
1265
1266
1275 public DLFolder fetchByUUID_G(String uuid, long groupId,
1276 boolean retrieveFromCache) throws SystemException {
1277 Object[] finderArgs = new Object[] { uuid, groupId };
1278
1279 Object result = null;
1280
1281 if (retrieveFromCache) {
1282 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_UUID_G,
1283 finderArgs, this);
1284 }
1285
1286 if (result == null) {
1287 StringBundler query = new StringBundler(4);
1288
1289 query.append(_SQL_SELECT_DLFOLDER_WHERE);
1290
1291 if (uuid == null) {
1292 query.append(_FINDER_COLUMN_UUID_G_UUID_1);
1293 }
1294 else {
1295 if (uuid.equals(StringPool.BLANK)) {
1296 query.append(_FINDER_COLUMN_UUID_G_UUID_3);
1297 }
1298 else {
1299 query.append(_FINDER_COLUMN_UUID_G_UUID_2);
1300 }
1301 }
1302
1303 query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
1304
1305 query.append(DLFolderModelImpl.ORDER_BY_JPQL);
1306
1307 String sql = query.toString();
1308
1309 Session session = null;
1310
1311 try {
1312 session = openSession();
1313
1314 Query q = session.createQuery(sql);
1315
1316 QueryPos qPos = QueryPos.getInstance(q);
1317
1318 if (uuid != null) {
1319 qPos.add(uuid);
1320 }
1321
1322 qPos.add(groupId);
1323
1324 List<DLFolder> list = q.list();
1325
1326 result = list;
1327
1328 DLFolder dlFolder = null;
1329
1330 if (list.isEmpty()) {
1331 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
1332 finderArgs, list);
1333 }
1334 else {
1335 dlFolder = list.get(0);
1336
1337 cacheResult(dlFolder);
1338
1339 if ((dlFolder.getUuid() == null) ||
1340 !dlFolder.getUuid().equals(uuid) ||
1341 (dlFolder.getGroupId() != groupId)) {
1342 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
1343 finderArgs, dlFolder);
1344 }
1345 }
1346
1347 return dlFolder;
1348 }
1349 catch (Exception e) {
1350 throw processException(e);
1351 }
1352 finally {
1353 if (result == null) {
1354 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
1355 finderArgs);
1356 }
1357
1358 closeSession(session);
1359 }
1360 }
1361 else {
1362 if (result instanceof List<?>) {
1363 return null;
1364 }
1365 else {
1366 return (DLFolder)result;
1367 }
1368 }
1369 }
1370
1371
1378 public List<DLFolder> findByGroupId(long groupId) throws SystemException {
1379 return findByGroupId(groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1380 }
1381
1382
1395 public List<DLFolder> findByGroupId(long groupId, int start, int end)
1396 throws SystemException {
1397 return findByGroupId(groupId, start, end, null);
1398 }
1399
1400
1414 public List<DLFolder> findByGroupId(long groupId, int start, int end,
1415 OrderByComparator orderByComparator) throws SystemException {
1416 FinderPath finderPath = null;
1417 Object[] finderArgs = null;
1418
1419 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1420 (orderByComparator == null)) {
1421 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID;
1422 finderArgs = new Object[] { groupId };
1423 }
1424 else {
1425 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID;
1426 finderArgs = new Object[] { groupId, start, end, orderByComparator };
1427 }
1428
1429 List<DLFolder> list = (List<DLFolder>)FinderCacheUtil.getResult(finderPath,
1430 finderArgs, this);
1431
1432 if (list == null) {
1433 StringBundler query = null;
1434
1435 if (orderByComparator != null) {
1436 query = new StringBundler(3 +
1437 (orderByComparator.getOrderByFields().length * 3));
1438 }
1439 else {
1440 query = new StringBundler(3);
1441 }
1442
1443 query.append(_SQL_SELECT_DLFOLDER_WHERE);
1444
1445 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1446
1447 if (orderByComparator != null) {
1448 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1449 orderByComparator);
1450 }
1451
1452 else {
1453 query.append(DLFolderModelImpl.ORDER_BY_JPQL);
1454 }
1455
1456 String sql = query.toString();
1457
1458 Session session = null;
1459
1460 try {
1461 session = openSession();
1462
1463 Query q = session.createQuery(sql);
1464
1465 QueryPos qPos = QueryPos.getInstance(q);
1466
1467 qPos.add(groupId);
1468
1469 list = (List<DLFolder>)QueryUtil.list(q, getDialect(), start,
1470 end);
1471 }
1472 catch (Exception e) {
1473 throw processException(e);
1474 }
1475 finally {
1476 if (list == null) {
1477 FinderCacheUtil.removeResult(finderPath, finderArgs);
1478 }
1479 else {
1480 cacheResult(list);
1481
1482 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1483 }
1484
1485 closeSession(session);
1486 }
1487 }
1488
1489 return list;
1490 }
1491
1492
1505 public DLFolder findByGroupId_First(long groupId,
1506 OrderByComparator orderByComparator)
1507 throws NoSuchFolderException, SystemException {
1508 List<DLFolder> list = findByGroupId(groupId, 0, 1, orderByComparator);
1509
1510 if (list.isEmpty()) {
1511 StringBundler msg = new StringBundler(4);
1512
1513 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1514
1515 msg.append("groupId=");
1516 msg.append(groupId);
1517
1518 msg.append(StringPool.CLOSE_CURLY_BRACE);
1519
1520 throw new NoSuchFolderException(msg.toString());
1521 }
1522 else {
1523 return list.get(0);
1524 }
1525 }
1526
1527
1540 public DLFolder findByGroupId_Last(long groupId,
1541 OrderByComparator orderByComparator)
1542 throws NoSuchFolderException, SystemException {
1543 int count = countByGroupId(groupId);
1544
1545 List<DLFolder> list = findByGroupId(groupId, count - 1, count,
1546 orderByComparator);
1547
1548 if (list.isEmpty()) {
1549 StringBundler msg = new StringBundler(4);
1550
1551 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1552
1553 msg.append("groupId=");
1554 msg.append(groupId);
1555
1556 msg.append(StringPool.CLOSE_CURLY_BRACE);
1557
1558 throw new NoSuchFolderException(msg.toString());
1559 }
1560 else {
1561 return list.get(0);
1562 }
1563 }
1564
1565
1579 public DLFolder[] findByGroupId_PrevAndNext(long folderId, long groupId,
1580 OrderByComparator orderByComparator)
1581 throws NoSuchFolderException, SystemException {
1582 DLFolder dlFolder = findByPrimaryKey(folderId);
1583
1584 Session session = null;
1585
1586 try {
1587 session = openSession();
1588
1589 DLFolder[] array = new DLFolderImpl[3];
1590
1591 array[0] = getByGroupId_PrevAndNext(session, dlFolder, groupId,
1592 orderByComparator, true);
1593
1594 array[1] = dlFolder;
1595
1596 array[2] = getByGroupId_PrevAndNext(session, dlFolder, groupId,
1597 orderByComparator, false);
1598
1599 return array;
1600 }
1601 catch (Exception e) {
1602 throw processException(e);
1603 }
1604 finally {
1605 closeSession(session);
1606 }
1607 }
1608
1609 protected DLFolder getByGroupId_PrevAndNext(Session session,
1610 DLFolder dlFolder, long groupId, OrderByComparator orderByComparator,
1611 boolean previous) {
1612 StringBundler query = null;
1613
1614 if (orderByComparator != null) {
1615 query = new StringBundler(6 +
1616 (orderByComparator.getOrderByFields().length * 6));
1617 }
1618 else {
1619 query = new StringBundler(3);
1620 }
1621
1622 query.append(_SQL_SELECT_DLFOLDER_WHERE);
1623
1624 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1625
1626 if (orderByComparator != null) {
1627 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1628
1629 if (orderByConditionFields.length > 0) {
1630 query.append(WHERE_AND);
1631 }
1632
1633 for (int i = 0; i < orderByConditionFields.length; i++) {
1634 query.append(_ORDER_BY_ENTITY_ALIAS);
1635 query.append(orderByConditionFields[i]);
1636
1637 if ((i + 1) < orderByConditionFields.length) {
1638 if (orderByComparator.isAscending() ^ previous) {
1639 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1640 }
1641 else {
1642 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1643 }
1644 }
1645 else {
1646 if (orderByComparator.isAscending() ^ previous) {
1647 query.append(WHERE_GREATER_THAN);
1648 }
1649 else {
1650 query.append(WHERE_LESSER_THAN);
1651 }
1652 }
1653 }
1654
1655 query.append(ORDER_BY_CLAUSE);
1656
1657 String[] orderByFields = orderByComparator.getOrderByFields();
1658
1659 for (int i = 0; i < orderByFields.length; i++) {
1660 query.append(_ORDER_BY_ENTITY_ALIAS);
1661 query.append(orderByFields[i]);
1662
1663 if ((i + 1) < orderByFields.length) {
1664 if (orderByComparator.isAscending() ^ previous) {
1665 query.append(ORDER_BY_ASC_HAS_NEXT);
1666 }
1667 else {
1668 query.append(ORDER_BY_DESC_HAS_NEXT);
1669 }
1670 }
1671 else {
1672 if (orderByComparator.isAscending() ^ previous) {
1673 query.append(ORDER_BY_ASC);
1674 }
1675 else {
1676 query.append(ORDER_BY_DESC);
1677 }
1678 }
1679 }
1680 }
1681
1682 else {
1683 query.append(DLFolderModelImpl.ORDER_BY_JPQL);
1684 }
1685
1686 String sql = query.toString();
1687
1688 Query q = session.createQuery(sql);
1689
1690 q.setFirstResult(0);
1691 q.setMaxResults(2);
1692
1693 QueryPos qPos = QueryPos.getInstance(q);
1694
1695 qPos.add(groupId);
1696
1697 if (orderByComparator != null) {
1698 Object[] values = orderByComparator.getOrderByConditionValues(dlFolder);
1699
1700 for (Object value : values) {
1701 qPos.add(value);
1702 }
1703 }
1704
1705 List<DLFolder> list = q.list();
1706
1707 if (list.size() == 2) {
1708 return list.get(1);
1709 }
1710 else {
1711 return null;
1712 }
1713 }
1714
1715
1722 public List<DLFolder> filterFindByGroupId(long groupId)
1723 throws SystemException {
1724 return filterFindByGroupId(groupId, QueryUtil.ALL_POS,
1725 QueryUtil.ALL_POS, null);
1726 }
1727
1728
1741 public List<DLFolder> filterFindByGroupId(long groupId, int start, int end)
1742 throws SystemException {
1743 return filterFindByGroupId(groupId, start, end, null);
1744 }
1745
1746
1760 public List<DLFolder> filterFindByGroupId(long groupId, int start, int end,
1761 OrderByComparator orderByComparator) throws SystemException {
1762 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
1763 return findByGroupId(groupId, start, end, orderByComparator);
1764 }
1765
1766 StringBundler query = null;
1767
1768 if (orderByComparator != null) {
1769 query = new StringBundler(3 +
1770 (orderByComparator.getOrderByFields().length * 3));
1771 }
1772 else {
1773 query = new StringBundler(3);
1774 }
1775
1776 if (getDB().isSupportsInlineDistinct()) {
1777 query.append(_FILTER_SQL_SELECT_DLFOLDER_WHERE);
1778 }
1779 else {
1780 query.append(_FILTER_SQL_SELECT_DLFOLDER_NO_INLINE_DISTINCT_WHERE_1);
1781 }
1782
1783 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1784
1785 if (!getDB().isSupportsInlineDistinct()) {
1786 query.append(_FILTER_SQL_SELECT_DLFOLDER_NO_INLINE_DISTINCT_WHERE_2);
1787 }
1788
1789 if (orderByComparator != null) {
1790 if (getDB().isSupportsInlineDistinct()) {
1791 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1792 orderByComparator);
1793 }
1794 else {
1795 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
1796 orderByComparator);
1797 }
1798 }
1799
1800 else {
1801 if (getDB().isSupportsInlineDistinct()) {
1802 query.append(DLFolderModelImpl.ORDER_BY_JPQL);
1803 }
1804 else {
1805 query.append(DLFolderModelImpl.ORDER_BY_SQL);
1806 }
1807 }
1808
1809 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1810 DLFolder.class.getName(),
1811 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
1812
1813 Session session = null;
1814
1815 try {
1816 session = openSession();
1817
1818 SQLQuery q = session.createSQLQuery(sql);
1819
1820 if (getDB().isSupportsInlineDistinct()) {
1821 q.addEntity(_FILTER_ENTITY_ALIAS, DLFolderImpl.class);
1822 }
1823 else {
1824 q.addEntity(_FILTER_ENTITY_TABLE, DLFolderImpl.class);
1825 }
1826
1827 QueryPos qPos = QueryPos.getInstance(q);
1828
1829 qPos.add(groupId);
1830
1831 return (List<DLFolder>)QueryUtil.list(q, getDialect(), start, end);
1832 }
1833 catch (Exception e) {
1834 throw processException(e);
1835 }
1836 finally {
1837 closeSession(session);
1838 }
1839 }
1840
1841
1851 public DLFolder[] filterFindByGroupId_PrevAndNext(long folderId,
1852 long groupId, OrderByComparator orderByComparator)
1853 throws NoSuchFolderException, SystemException {
1854 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
1855 return findByGroupId_PrevAndNext(folderId, groupId,
1856 orderByComparator);
1857 }
1858
1859 DLFolder dlFolder = findByPrimaryKey(folderId);
1860
1861 Session session = null;
1862
1863 try {
1864 session = openSession();
1865
1866 DLFolder[] array = new DLFolderImpl[3];
1867
1868 array[0] = filterGetByGroupId_PrevAndNext(session, dlFolder,
1869 groupId, orderByComparator, true);
1870
1871 array[1] = dlFolder;
1872
1873 array[2] = filterGetByGroupId_PrevAndNext(session, dlFolder,
1874 groupId, orderByComparator, false);
1875
1876 return array;
1877 }
1878 catch (Exception e) {
1879 throw processException(e);
1880 }
1881 finally {
1882 closeSession(session);
1883 }
1884 }
1885
1886 protected DLFolder filterGetByGroupId_PrevAndNext(Session session,
1887 DLFolder dlFolder, long groupId, OrderByComparator orderByComparator,
1888 boolean previous) {
1889 StringBundler query = null;
1890
1891 if (orderByComparator != null) {
1892 query = new StringBundler(6 +
1893 (orderByComparator.getOrderByFields().length * 6));
1894 }
1895 else {
1896 query = new StringBundler(3);
1897 }
1898
1899 if (getDB().isSupportsInlineDistinct()) {
1900 query.append(_FILTER_SQL_SELECT_DLFOLDER_WHERE);
1901 }
1902 else {
1903 query.append(_FILTER_SQL_SELECT_DLFOLDER_NO_INLINE_DISTINCT_WHERE_1);
1904 }
1905
1906 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1907
1908 if (!getDB().isSupportsInlineDistinct()) {
1909 query.append(_FILTER_SQL_SELECT_DLFOLDER_NO_INLINE_DISTINCT_WHERE_2);
1910 }
1911
1912 if (orderByComparator != null) {
1913 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1914
1915 if (orderByConditionFields.length > 0) {
1916 query.append(WHERE_AND);
1917 }
1918
1919 for (int i = 0; i < orderByConditionFields.length; i++) {
1920 if (getDB().isSupportsInlineDistinct()) {
1921 query.append(_ORDER_BY_ENTITY_ALIAS);
1922 }
1923 else {
1924 query.append(_ORDER_BY_ENTITY_TABLE);
1925 }
1926
1927 query.append(orderByConditionFields[i]);
1928
1929 if ((i + 1) < orderByConditionFields.length) {
1930 if (orderByComparator.isAscending() ^ previous) {
1931 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1932 }
1933 else {
1934 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1935 }
1936 }
1937 else {
1938 if (orderByComparator.isAscending() ^ previous) {
1939 query.append(WHERE_GREATER_THAN);
1940 }
1941 else {
1942 query.append(WHERE_LESSER_THAN);
1943 }
1944 }
1945 }
1946
1947 query.append(ORDER_BY_CLAUSE);
1948
1949 String[] orderByFields = orderByComparator.getOrderByFields();
1950
1951 for (int i = 0; i < orderByFields.length; i++) {
1952 if (getDB().isSupportsInlineDistinct()) {
1953 query.append(_ORDER_BY_ENTITY_ALIAS);
1954 }
1955 else {
1956 query.append(_ORDER_BY_ENTITY_TABLE);
1957 }
1958
1959 query.append(orderByFields[i]);
1960
1961 if ((i + 1) < orderByFields.length) {
1962 if (orderByComparator.isAscending() ^ previous) {
1963 query.append(ORDER_BY_ASC_HAS_NEXT);
1964 }
1965 else {
1966 query.append(ORDER_BY_DESC_HAS_NEXT);
1967 }
1968 }
1969 else {
1970 if (orderByComparator.isAscending() ^ previous) {
1971 query.append(ORDER_BY_ASC);
1972 }
1973 else {
1974 query.append(ORDER_BY_DESC);
1975 }
1976 }
1977 }
1978 }
1979
1980 else {
1981 if (getDB().isSupportsInlineDistinct()) {
1982 query.append(DLFolderModelImpl.ORDER_BY_JPQL);
1983 }
1984 else {
1985 query.append(DLFolderModelImpl.ORDER_BY_SQL);
1986 }
1987 }
1988
1989 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1990 DLFolder.class.getName(),
1991 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
1992
1993 SQLQuery q = session.createSQLQuery(sql);
1994
1995 q.setFirstResult(0);
1996 q.setMaxResults(2);
1997
1998 if (getDB().isSupportsInlineDistinct()) {
1999 q.addEntity(_FILTER_ENTITY_ALIAS, DLFolderImpl.class);
2000 }
2001 else {
2002 q.addEntity(_FILTER_ENTITY_TABLE, DLFolderImpl.class);
2003 }
2004
2005 QueryPos qPos = QueryPos.getInstance(q);
2006
2007 qPos.add(groupId);
2008
2009 if (orderByComparator != null) {
2010 Object[] values = orderByComparator.getOrderByConditionValues(dlFolder);
2011
2012 for (Object value : values) {
2013 qPos.add(value);
2014 }
2015 }
2016
2017 List<DLFolder> list = q.list();
2018
2019 if (list.size() == 2) {
2020 return list.get(1);
2021 }
2022 else {
2023 return null;
2024 }
2025 }
2026
2027
2034 public List<DLFolder> findByCompanyId(long companyId)
2035 throws SystemException {
2036 return findByCompanyId(companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
2037 null);
2038 }
2039
2040
2053 public List<DLFolder> findByCompanyId(long companyId, int start, int end)
2054 throws SystemException {
2055 return findByCompanyId(companyId, start, end, null);
2056 }
2057
2058
2072 public List<DLFolder> findByCompanyId(long companyId, int start, int end,
2073 OrderByComparator orderByComparator) throws SystemException {
2074 FinderPath finderPath = null;
2075 Object[] finderArgs = null;
2076
2077 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2078 (orderByComparator == null)) {
2079 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID;
2080 finderArgs = new Object[] { companyId };
2081 }
2082 else {
2083 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID;
2084 finderArgs = new Object[] { companyId, start, end, orderByComparator };
2085 }
2086
2087 List<DLFolder> list = (List<DLFolder>)FinderCacheUtil.getResult(finderPath,
2088 finderArgs, this);
2089
2090 if (list == null) {
2091 StringBundler query = null;
2092
2093 if (orderByComparator != null) {
2094 query = new StringBundler(3 +
2095 (orderByComparator.getOrderByFields().length * 3));
2096 }
2097 else {
2098 query = new StringBundler(3);
2099 }
2100
2101 query.append(_SQL_SELECT_DLFOLDER_WHERE);
2102
2103 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
2104
2105 if (orderByComparator != null) {
2106 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2107 orderByComparator);
2108 }
2109
2110 else {
2111 query.append(DLFolderModelImpl.ORDER_BY_JPQL);
2112 }
2113
2114 String sql = query.toString();
2115
2116 Session session = null;
2117
2118 try {
2119 session = openSession();
2120
2121 Query q = session.createQuery(sql);
2122
2123 QueryPos qPos = QueryPos.getInstance(q);
2124
2125 qPos.add(companyId);
2126
2127 list = (List<DLFolder>)QueryUtil.list(q, getDialect(), start,
2128 end);
2129 }
2130 catch (Exception e) {
2131 throw processException(e);
2132 }
2133 finally {
2134 if (list == null) {
2135 FinderCacheUtil.removeResult(finderPath, finderArgs);
2136 }
2137 else {
2138 cacheResult(list);
2139
2140 FinderCacheUtil.putResult(finderPath, finderArgs, list);
2141 }
2142
2143 closeSession(session);
2144 }
2145 }
2146
2147 return list;
2148 }
2149
2150
2163 public DLFolder findByCompanyId_First(long companyId,
2164 OrderByComparator orderByComparator)
2165 throws NoSuchFolderException, SystemException {
2166 List<DLFolder> list = findByCompanyId(companyId, 0, 1, orderByComparator);
2167
2168 if (list.isEmpty()) {
2169 StringBundler msg = new StringBundler(4);
2170
2171 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2172
2173 msg.append("companyId=");
2174 msg.append(companyId);
2175
2176 msg.append(StringPool.CLOSE_CURLY_BRACE);
2177
2178 throw new NoSuchFolderException(msg.toString());
2179 }
2180 else {
2181 return list.get(0);
2182 }
2183 }
2184
2185
2198 public DLFolder findByCompanyId_Last(long companyId,
2199 OrderByComparator orderByComparator)
2200 throws NoSuchFolderException, SystemException {
2201 int count = countByCompanyId(companyId);
2202
2203 List<DLFolder> list = findByCompanyId(companyId, count - 1, count,
2204 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
2237 public DLFolder[] findByCompanyId_PrevAndNext(long folderId,
2238 long companyId, OrderByComparator orderByComparator)
2239 throws NoSuchFolderException, SystemException {
2240 DLFolder dlFolder = findByPrimaryKey(folderId);
2241
2242 Session session = null;
2243
2244 try {
2245 session = openSession();
2246
2247 DLFolder[] array = new DLFolderImpl[3];
2248
2249 array[0] = getByCompanyId_PrevAndNext(session, dlFolder, companyId,
2250 orderByComparator, true);
2251
2252 array[1] = dlFolder;
2253
2254 array[2] = getByCompanyId_PrevAndNext(session, dlFolder, companyId,
2255 orderByComparator, false);
2256
2257 return array;
2258 }
2259 catch (Exception e) {
2260 throw processException(e);
2261 }
2262 finally {
2263 closeSession(session);
2264 }
2265 }
2266
2267 protected DLFolder getByCompanyId_PrevAndNext(Session session,
2268 DLFolder dlFolder, long companyId, OrderByComparator orderByComparator,
2269 boolean previous) {
2270 StringBundler query = null;
2271
2272 if (orderByComparator != null) {
2273 query = new StringBundler(6 +
2274 (orderByComparator.getOrderByFields().length * 6));
2275 }
2276 else {
2277 query = new StringBundler(3);
2278 }
2279
2280 query.append(_SQL_SELECT_DLFOLDER_WHERE);
2281
2282 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
2283
2284 if (orderByComparator != null) {
2285 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2286
2287 if (orderByConditionFields.length > 0) {
2288 query.append(WHERE_AND);
2289 }
2290
2291 for (int i = 0; i < orderByConditionFields.length; i++) {
2292 query.append(_ORDER_BY_ENTITY_ALIAS);
2293 query.append(orderByConditionFields[i]);
2294
2295 if ((i + 1) < orderByConditionFields.length) {
2296 if (orderByComparator.isAscending() ^ previous) {
2297 query.append(WHERE_GREATER_THAN_HAS_NEXT);
2298 }
2299 else {
2300 query.append(WHERE_LESSER_THAN_HAS_NEXT);
2301 }
2302 }
2303 else {
2304 if (orderByComparator.isAscending() ^ previous) {
2305 query.append(WHERE_GREATER_THAN);
2306 }
2307 else {
2308 query.append(WHERE_LESSER_THAN);
2309 }
2310 }
2311 }
2312
2313 query.append(ORDER_BY_CLAUSE);
2314
2315 String[] orderByFields = orderByComparator.getOrderByFields();
2316
2317 for (int i = 0; i < orderByFields.length; i++) {
2318 query.append(_ORDER_BY_ENTITY_ALIAS);
2319 query.append(orderByFields[i]);
2320
2321 if ((i + 1) < orderByFields.length) {
2322 if (orderByComparator.isAscending() ^ previous) {
2323 query.append(ORDER_BY_ASC_HAS_NEXT);
2324 }
2325 else {
2326 query.append(ORDER_BY_DESC_HAS_NEXT);
2327 }
2328 }
2329 else {
2330 if (orderByComparator.isAscending() ^ previous) {
2331 query.append(ORDER_BY_ASC);
2332 }
2333 else {
2334 query.append(ORDER_BY_DESC);
2335 }
2336 }
2337 }
2338 }
2339
2340 else {
2341 query.append(DLFolderModelImpl.ORDER_BY_JPQL);
2342 }
2343
2344 String sql = query.toString();
2345
2346 Query q = session.createQuery(sql);
2347
2348 q.setFirstResult(0);
2349 q.setMaxResults(2);
2350
2351 QueryPos qPos = QueryPos.getInstance(q);
2352
2353 qPos.add(companyId);
2354
2355 if (orderByComparator != null) {
2356 Object[] values = orderByComparator.getOrderByConditionValues(dlFolder);
2357
2358 for (Object value : values) {
2359 qPos.add(value);
2360 }
2361 }
2362
2363 List<DLFolder> list = q.list();
2364
2365 if (list.size() == 2) {
2366 return list.get(1);
2367 }
2368 else {
2369 return null;
2370 }
2371 }
2372
2373
2381 public DLFolder findByRepositoryId(long repositoryId)
2382 throws NoSuchFolderException, SystemException {
2383 DLFolder dlFolder = fetchByRepositoryId(repositoryId);
2384
2385 if (dlFolder == null) {
2386 StringBundler msg = new StringBundler(4);
2387
2388 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2389
2390 msg.append("repositoryId=");
2391 msg.append(repositoryId);
2392
2393 msg.append(StringPool.CLOSE_CURLY_BRACE);
2394
2395 if (_log.isWarnEnabled()) {
2396 _log.warn(msg.toString());
2397 }
2398
2399 throw new NoSuchFolderException(msg.toString());
2400 }
2401
2402 return dlFolder;
2403 }
2404
2405
2412 public DLFolder fetchByRepositoryId(long repositoryId)
2413 throws SystemException {
2414 return fetchByRepositoryId(repositoryId, true);
2415 }
2416
2417
2425 public DLFolder fetchByRepositoryId(long repositoryId,
2426 boolean retrieveFromCache) throws SystemException {
2427 Object[] finderArgs = new Object[] { repositoryId };
2428
2429 Object result = null;
2430
2431 if (retrieveFromCache) {
2432 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_REPOSITORYID,
2433 finderArgs, this);
2434 }
2435
2436 if (result == null) {
2437 StringBundler query = new StringBundler(3);
2438
2439 query.append(_SQL_SELECT_DLFOLDER_WHERE);
2440
2441 query.append(_FINDER_COLUMN_REPOSITORYID_REPOSITORYID_2);
2442
2443 query.append(DLFolderModelImpl.ORDER_BY_JPQL);
2444
2445 String sql = query.toString();
2446
2447 Session session = null;
2448
2449 try {
2450 session = openSession();
2451
2452 Query q = session.createQuery(sql);
2453
2454 QueryPos qPos = QueryPos.getInstance(q);
2455
2456 qPos.add(repositoryId);
2457
2458 List<DLFolder> list = q.list();
2459
2460 result = list;
2461
2462 DLFolder dlFolder = null;
2463
2464 if (list.isEmpty()) {
2465 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_REPOSITORYID,
2466 finderArgs, list);
2467 }
2468 else {
2469 dlFolder = list.get(0);
2470
2471 cacheResult(dlFolder);
2472
2473 if ((dlFolder.getRepositoryId() != repositoryId)) {
2474 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_REPOSITORYID,
2475 finderArgs, dlFolder);
2476 }
2477 }
2478
2479 return dlFolder;
2480 }
2481 catch (Exception e) {
2482 throw processException(e);
2483 }
2484 finally {
2485 if (result == null) {
2486 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_REPOSITORYID,
2487 finderArgs);
2488 }
2489
2490 closeSession(session);
2491 }
2492 }
2493 else {
2494 if (result instanceof List<?>) {
2495 return null;
2496 }
2497 else {
2498 return (DLFolder)result;
2499 }
2500 }
2501 }
2502
2503
2511 public List<DLFolder> findByG_P(long groupId, long parentFolderId)
2512 throws SystemException {
2513 return findByG_P(groupId, parentFolderId, QueryUtil.ALL_POS,
2514 QueryUtil.ALL_POS, null);
2515 }
2516
2517
2531 public List<DLFolder> findByG_P(long groupId, long parentFolderId,
2532 int start, int end) throws SystemException {
2533 return findByG_P(groupId, parentFolderId, start, end, null);
2534 }
2535
2536
2551 public List<DLFolder> findByG_P(long groupId, long parentFolderId,
2552 int start, int end, OrderByComparator orderByComparator)
2553 throws SystemException {
2554 FinderPath finderPath = null;
2555 Object[] finderArgs = null;
2556
2557 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2558 (orderByComparator == null)) {
2559 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P;
2560 finderArgs = new Object[] { groupId, parentFolderId };
2561 }
2562 else {
2563 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_P;
2564 finderArgs = new Object[] {
2565 groupId, parentFolderId,
2566
2567 start, end, orderByComparator
2568 };
2569 }
2570
2571 List<DLFolder> list = (List<DLFolder>)FinderCacheUtil.getResult(finderPath,
2572 finderArgs, this);
2573
2574 if (list == null) {
2575 StringBundler query = null;
2576
2577 if (orderByComparator != null) {
2578 query = new StringBundler(4 +
2579 (orderByComparator.getOrderByFields().length * 3));
2580 }
2581 else {
2582 query = new StringBundler(4);
2583 }
2584
2585 query.append(_SQL_SELECT_DLFOLDER_WHERE);
2586
2587 query.append(_FINDER_COLUMN_G_P_GROUPID_2);
2588
2589 query.append(_FINDER_COLUMN_G_P_PARENTFOLDERID_2);
2590
2591 if (orderByComparator != null) {
2592 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2593 orderByComparator);
2594 }
2595
2596 else {
2597 query.append(DLFolderModelImpl.ORDER_BY_JPQL);
2598 }
2599
2600 String sql = query.toString();
2601
2602 Session session = null;
2603
2604 try {
2605 session = openSession();
2606
2607 Query q = session.createQuery(sql);
2608
2609 QueryPos qPos = QueryPos.getInstance(q);
2610
2611 qPos.add(groupId);
2612
2613 qPos.add(parentFolderId);
2614
2615 list = (List<DLFolder>)QueryUtil.list(q, getDialect(), start,
2616 end);
2617 }
2618 catch (Exception e) {
2619 throw processException(e);
2620 }
2621 finally {
2622 if (list == null) {
2623 FinderCacheUtil.removeResult(finderPath, finderArgs);
2624 }
2625 else {
2626 cacheResult(list);
2627
2628 FinderCacheUtil.putResult(finderPath, finderArgs, list);
2629 }
2630
2631 closeSession(session);
2632 }
2633 }
2634
2635 return list;
2636 }
2637
2638
2652 public DLFolder findByG_P_First(long groupId, long parentFolderId,
2653 OrderByComparator orderByComparator)
2654 throws NoSuchFolderException, SystemException {
2655 List<DLFolder> list = findByG_P(groupId, parentFolderId, 0, 1,
2656 orderByComparator);
2657
2658 if (list.isEmpty()) {
2659 StringBundler msg = new StringBundler(6);
2660
2661 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2662
2663 msg.append("groupId=");
2664 msg.append(groupId);
2665
2666 msg.append(", parentFolderId=");
2667 msg.append(parentFolderId);
2668
2669 msg.append(StringPool.CLOSE_CURLY_BRACE);
2670
2671 throw new NoSuchFolderException(msg.toString());
2672 }
2673 else {
2674 return list.get(0);
2675 }
2676 }
2677
2678
2692 public DLFolder findByG_P_Last(long groupId, long parentFolderId,
2693 OrderByComparator orderByComparator)
2694 throws NoSuchFolderException, SystemException {
2695 int count = countByG_P(groupId, parentFolderId);
2696
2697 List<DLFolder> list = findByG_P(groupId, parentFolderId, count - 1,
2698 count, orderByComparator);
2699
2700 if (list.isEmpty()) {
2701 StringBundler msg = new StringBundler(6);
2702
2703 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2704
2705 msg.append("groupId=");
2706 msg.append(groupId);
2707
2708 msg.append(", parentFolderId=");
2709 msg.append(parentFolderId);
2710
2711 msg.append(StringPool.CLOSE_CURLY_BRACE);
2712
2713 throw new NoSuchFolderException(msg.toString());
2714 }
2715 else {
2716 return list.get(0);
2717 }
2718 }
2719
2720
2735 public DLFolder[] findByG_P_PrevAndNext(long folderId, long groupId,
2736 long parentFolderId, OrderByComparator orderByComparator)
2737 throws NoSuchFolderException, SystemException {
2738 DLFolder dlFolder = findByPrimaryKey(folderId);
2739
2740 Session session = null;
2741
2742 try {
2743 session = openSession();
2744
2745 DLFolder[] array = new DLFolderImpl[3];
2746
2747 array[0] = getByG_P_PrevAndNext(session, dlFolder, groupId,
2748 parentFolderId, orderByComparator, true);
2749
2750 array[1] = dlFolder;
2751
2752 array[2] = getByG_P_PrevAndNext(session, dlFolder, groupId,
2753 parentFolderId, orderByComparator, false);
2754
2755 return array;
2756 }
2757 catch (Exception e) {
2758 throw processException(e);
2759 }
2760 finally {
2761 closeSession(session);
2762 }
2763 }
2764
2765 protected DLFolder getByG_P_PrevAndNext(Session session, DLFolder dlFolder,
2766 long groupId, long parentFolderId, OrderByComparator orderByComparator,
2767 boolean previous) {
2768 StringBundler query = null;
2769
2770 if (orderByComparator != null) {
2771 query = new StringBundler(6 +
2772 (orderByComparator.getOrderByFields().length * 6));
2773 }
2774 else {
2775 query = new StringBundler(3);
2776 }
2777
2778 query.append(_SQL_SELECT_DLFOLDER_WHERE);
2779
2780 query.append(_FINDER_COLUMN_G_P_GROUPID_2);
2781
2782 query.append(_FINDER_COLUMN_G_P_PARENTFOLDERID_2);
2783
2784 if (orderByComparator != null) {
2785 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2786
2787 if (orderByConditionFields.length > 0) {
2788 query.append(WHERE_AND);
2789 }
2790
2791 for (int i = 0; i < orderByConditionFields.length; i++) {
2792 query.append(_ORDER_BY_ENTITY_ALIAS);
2793 query.append(orderByConditionFields[i]);
2794
2795 if ((i + 1) < orderByConditionFields.length) {
2796 if (orderByComparator.isAscending() ^ previous) {
2797 query.append(WHERE_GREATER_THAN_HAS_NEXT);
2798 }
2799 else {
2800 query.append(WHERE_LESSER_THAN_HAS_NEXT);
2801 }
2802 }
2803 else {
2804 if (orderByComparator.isAscending() ^ previous) {
2805 query.append(WHERE_GREATER_THAN);
2806 }
2807 else {
2808 query.append(WHERE_LESSER_THAN);
2809 }
2810 }
2811 }
2812
2813 query.append(ORDER_BY_CLAUSE);
2814
2815 String[] orderByFields = orderByComparator.getOrderByFields();
2816
2817 for (int i = 0; i < orderByFields.length; i++) {
2818 query.append(_ORDER_BY_ENTITY_ALIAS);
2819 query.append(orderByFields[i]);
2820
2821 if ((i + 1) < orderByFields.length) {
2822 if (orderByComparator.isAscending() ^ previous) {
2823 query.append(ORDER_BY_ASC_HAS_NEXT);
2824 }
2825 else {
2826 query.append(ORDER_BY_DESC_HAS_NEXT);
2827 }
2828 }
2829 else {
2830 if (orderByComparator.isAscending() ^ previous) {
2831 query.append(ORDER_BY_ASC);
2832 }
2833 else {
2834 query.append(ORDER_BY_DESC);
2835 }
2836 }
2837 }
2838 }
2839
2840 else {
2841 query.append(DLFolderModelImpl.ORDER_BY_JPQL);
2842 }
2843
2844 String sql = query.toString();
2845
2846 Query q = session.createQuery(sql);
2847
2848 q.setFirstResult(0);
2849 q.setMaxResults(2);
2850
2851 QueryPos qPos = QueryPos.getInstance(q);
2852
2853 qPos.add(groupId);
2854
2855 qPos.add(parentFolderId);
2856
2857 if (orderByComparator != null) {
2858 Object[] values = orderByComparator.getOrderByConditionValues(dlFolder);
2859
2860 for (Object value : values) {
2861 qPos.add(value);
2862 }
2863 }
2864
2865 List<DLFolder> list = q.list();
2866
2867 if (list.size() == 2) {
2868 return list.get(1);
2869 }
2870 else {
2871 return null;
2872 }
2873 }
2874
2875
2883 public List<DLFolder> filterFindByG_P(long groupId, long parentFolderId)
2884 throws SystemException {
2885 return filterFindByG_P(groupId, parentFolderId, QueryUtil.ALL_POS,
2886 QueryUtil.ALL_POS, null);
2887 }
2888
2889
2903 public List<DLFolder> filterFindByG_P(long groupId, long parentFolderId,
2904 int start, int end) throws SystemException {
2905 return filterFindByG_P(groupId, parentFolderId, start, end, null);
2906 }
2907
2908
2923 public List<DLFolder> filterFindByG_P(long groupId, long parentFolderId,
2924 int start, int end, OrderByComparator orderByComparator)
2925 throws SystemException {
2926 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2927 return findByG_P(groupId, parentFolderId, start, end,
2928 orderByComparator);
2929 }
2930
2931 StringBundler query = null;
2932
2933 if (orderByComparator != null) {
2934 query = new StringBundler(4 +
2935 (orderByComparator.getOrderByFields().length * 3));
2936 }
2937 else {
2938 query = new StringBundler(4);
2939 }
2940
2941 if (getDB().isSupportsInlineDistinct()) {
2942 query.append(_FILTER_SQL_SELECT_DLFOLDER_WHERE);
2943 }
2944 else {
2945 query.append(_FILTER_SQL_SELECT_DLFOLDER_NO_INLINE_DISTINCT_WHERE_1);
2946 }
2947
2948 query.append(_FINDER_COLUMN_G_P_GROUPID_2);
2949
2950 query.append(_FINDER_COLUMN_G_P_PARENTFOLDERID_2);
2951
2952 if (!getDB().isSupportsInlineDistinct()) {
2953 query.append(_FILTER_SQL_SELECT_DLFOLDER_NO_INLINE_DISTINCT_WHERE_2);
2954 }
2955
2956 if (orderByComparator != null) {
2957 if (getDB().isSupportsInlineDistinct()) {
2958 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2959 orderByComparator);
2960 }
2961 else {
2962 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
2963 orderByComparator);
2964 }
2965 }
2966
2967 else {
2968 if (getDB().isSupportsInlineDistinct()) {
2969 query.append(DLFolderModelImpl.ORDER_BY_JPQL);
2970 }
2971 else {
2972 query.append(DLFolderModelImpl.ORDER_BY_SQL);
2973 }
2974 }
2975
2976 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2977 DLFolder.class.getName(),
2978 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2979
2980 Session session = null;
2981
2982 try {
2983 session = openSession();
2984
2985 SQLQuery q = session.createSQLQuery(sql);
2986
2987 if (getDB().isSupportsInlineDistinct()) {
2988 q.addEntity(_FILTER_ENTITY_ALIAS, DLFolderImpl.class);
2989 }
2990 else {
2991 q.addEntity(_FILTER_ENTITY_TABLE, DLFolderImpl.class);
2992 }
2993
2994 QueryPos qPos = QueryPos.getInstance(q);
2995
2996 qPos.add(groupId);
2997
2998 qPos.add(parentFolderId);
2999
3000 return (List<DLFolder>)QueryUtil.list(q, getDialect(), start, end);
3001 }
3002 catch (Exception e) {
3003 throw processException(e);
3004 }
3005 finally {
3006 closeSession(session);
3007 }
3008 }
3009
3010
3021 public DLFolder[] filterFindByG_P_PrevAndNext(long folderId, long groupId,
3022 long parentFolderId, OrderByComparator orderByComparator)
3023 throws NoSuchFolderException, SystemException {
3024 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
3025 return findByG_P_PrevAndNext(folderId, groupId, parentFolderId,
3026 orderByComparator);
3027 }
3028
3029 DLFolder dlFolder = findByPrimaryKey(folderId);
3030
3031 Session session = null;
3032
3033 try {
3034 session = openSession();
3035
3036 DLFolder[] array = new DLFolderImpl[3];
3037
3038 array[0] = filterGetByG_P_PrevAndNext(session, dlFolder, groupId,
3039 parentFolderId, orderByComparator, true);
3040
3041 array[1] = dlFolder;
3042
3043 array[2] = filterGetByG_P_PrevAndNext(session, dlFolder, groupId,
3044 parentFolderId, orderByComparator, false);
3045
3046 return array;
3047 }
3048 catch (Exception e) {
3049 throw processException(e);
3050 }
3051 finally {
3052 closeSession(session);
3053 }
3054 }
3055
3056 protected DLFolder filterGetByG_P_PrevAndNext(Session session,
3057 DLFolder dlFolder, long groupId, long parentFolderId,
3058 OrderByComparator orderByComparator, boolean previous) {
3059 StringBundler query = null;
3060
3061 if (orderByComparator != null) {
3062 query = new StringBundler(6 +
3063 (orderByComparator.getOrderByFields().length * 6));
3064 }
3065 else {
3066 query = new StringBundler(3);
3067 }
3068
3069 if (getDB().isSupportsInlineDistinct()) {
3070 query.append(_FILTER_SQL_SELECT_DLFOLDER_WHERE);
3071 }
3072 else {
3073 query.append(_FILTER_SQL_SELECT_DLFOLDER_NO_INLINE_DISTINCT_WHERE_1);
3074 }
3075
3076 query.append(_FINDER_COLUMN_G_P_GROUPID_2);
3077
3078 query.append(_FINDER_COLUMN_G_P_PARENTFOLDERID_2);
3079
3080 if (!getDB().isSupportsInlineDistinct()) {
3081 query.append(_FILTER_SQL_SELECT_DLFOLDER_NO_INLINE_DISTINCT_WHERE_2);
3082 }
3083
3084 if (orderByComparator != null) {
3085 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3086
3087 if (orderByConditionFields.length > 0) {
3088 query.append(WHERE_AND);
3089 }
3090
3091 for (int i = 0; i < orderByConditionFields.length; i++) {
3092 if (getDB().isSupportsInlineDistinct()) {
3093 query.append(_ORDER_BY_ENTITY_ALIAS);
3094 }
3095 else {
3096 query.append(_ORDER_BY_ENTITY_TABLE);
3097 }
3098
3099 query.append(orderByConditionFields[i]);
3100
3101 if ((i + 1) < orderByConditionFields.length) {
3102 if (orderByComparator.isAscending() ^ previous) {
3103 query.append(WHERE_GREATER_THAN_HAS_NEXT);
3104 }
3105 else {
3106 query.append(WHERE_LESSER_THAN_HAS_NEXT);
3107 }
3108 }
3109 else {
3110 if (orderByComparator.isAscending() ^ previous) {
3111 query.append(WHERE_GREATER_THAN);
3112 }
3113 else {
3114 query.append(WHERE_LESSER_THAN);
3115 }
3116 }
3117 }
3118
3119 query.append(ORDER_BY_CLAUSE);
3120
3121 String[] orderByFields = orderByComparator.getOrderByFields();
3122
3123 for (int i = 0; i < orderByFields.length; i++) {
3124 if (getDB().isSupportsInlineDistinct()) {
3125 query.append(_ORDER_BY_ENTITY_ALIAS);
3126 }
3127 else {
3128 query.append(_ORDER_BY_ENTITY_TABLE);
3129 }
3130
3131 query.append(orderByFields[i]);
3132
3133 if ((i + 1) < orderByFields.length) {
3134 if (orderByComparator.isAscending() ^ previous) {
3135 query.append(ORDER_BY_ASC_HAS_NEXT);
3136 }
3137 else {
3138 query.append(ORDER_BY_DESC_HAS_NEXT);
3139 }
3140 }
3141 else {
3142 if (orderByComparator.isAscending() ^ previous) {
3143 query.append(ORDER_BY_ASC);
3144 }
3145 else {
3146 query.append(ORDER_BY_DESC);
3147 }
3148 }
3149 }
3150 }
3151
3152 else {
3153 if (getDB().isSupportsInlineDistinct()) {
3154 query.append(DLFolderModelImpl.ORDER_BY_JPQL);
3155 }
3156 else {
3157 query.append(DLFolderModelImpl.ORDER_BY_SQL);
3158 }
3159 }
3160
3161 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
3162 DLFolder.class.getName(),
3163 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
3164
3165 SQLQuery q = session.createSQLQuery(sql);
3166
3167 q.setFirstResult(0);
3168 q.setMaxResults(2);
3169
3170 if (getDB().isSupportsInlineDistinct()) {
3171 q.addEntity(_FILTER_ENTITY_ALIAS, DLFolderImpl.class);
3172 }
3173 else {
3174 q.addEntity(_FILTER_ENTITY_TABLE, DLFolderImpl.class);
3175 }
3176
3177 QueryPos qPos = QueryPos.getInstance(q);
3178
3179 qPos.add(groupId);
3180
3181 qPos.add(parentFolderId);
3182
3183 if (orderByComparator != null) {
3184 Object[] values = orderByComparator.getOrderByConditionValues(dlFolder);
3185
3186 for (Object value : values) {
3187 qPos.add(value);
3188 }
3189 }
3190
3191 List<DLFolder> list = q.list();
3192
3193 if (list.size() == 2) {
3194 return list.get(1);
3195 }
3196 else {
3197 return null;
3198 }
3199 }
3200
3201
3209 public List<DLFolder> findByP_N(long parentFolderId, String name)
3210 throws SystemException {
3211 return findByP_N(parentFolderId, name, QueryUtil.ALL_POS,
3212 QueryUtil.ALL_POS, null);
3213 }
3214
3215
3229 public List<DLFolder> findByP_N(long parentFolderId, String name,
3230 int start, int end) throws SystemException {
3231 return findByP_N(parentFolderId, name, start, end, null);
3232 }
3233
3234
3249 public List<DLFolder> findByP_N(long parentFolderId, String name,
3250 int start, int end, OrderByComparator orderByComparator)
3251 throws SystemException {
3252 FinderPath finderPath = null;
3253 Object[] finderArgs = null;
3254
3255 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
3256 (orderByComparator == null)) {
3257 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_P_N;
3258 finderArgs = new Object[] { parentFolderId, name };
3259 }
3260 else {
3261 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_P_N;
3262 finderArgs = new Object[] {
3263 parentFolderId, name,
3264
3265 start, end, orderByComparator
3266 };
3267 }
3268
3269 List<DLFolder> list = (List<DLFolder>)FinderCacheUtil.getResult(finderPath,
3270 finderArgs, this);
3271
3272 if (list == null) {
3273 StringBundler query = null;
3274
3275 if (orderByComparator != null) {
3276 query = new StringBundler(4 +
3277 (orderByComparator.getOrderByFields().length * 3));
3278 }
3279 else {
3280 query = new StringBundler(4);
3281 }
3282
3283 query.append(_SQL_SELECT_DLFOLDER_WHERE);
3284
3285 query.append(_FINDER_COLUMN_P_N_PARENTFOLDERID_2);
3286
3287 if (name == null) {
3288 query.append(_FINDER_COLUMN_P_N_NAME_1);
3289 }
3290 else {
3291 if (name.equals(StringPool.BLANK)) {
3292 query.append(_FINDER_COLUMN_P_N_NAME_3);
3293 }
3294 else {
3295 query.append(_FINDER_COLUMN_P_N_NAME_2);
3296 }
3297 }
3298
3299 if (orderByComparator != null) {
3300 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3301 orderByComparator);
3302 }
3303
3304 else {
3305 query.append(DLFolderModelImpl.ORDER_BY_JPQL);
3306 }
3307
3308 String sql = query.toString();
3309
3310 Session session = null;
3311
3312 try {
3313 session = openSession();
3314
3315 Query q = session.createQuery(sql);
3316
3317 QueryPos qPos = QueryPos.getInstance(q);
3318
3319 qPos.add(parentFolderId);
3320
3321 if (name != null) {
3322 qPos.add(name);
3323 }
3324
3325 list = (List<DLFolder>)QueryUtil.list(q, getDialect(), start,
3326 end);
3327 }
3328 catch (Exception e) {
3329 throw processException(e);
3330 }
3331 finally {
3332 if (list == null) {
3333 FinderCacheUtil.removeResult(finderPath, finderArgs);
3334 }
3335 else {
3336 cacheResult(list);
3337
3338 FinderCacheUtil.putResult(finderPath, finderArgs, list);
3339 }
3340
3341 closeSession(session);
3342 }
3343 }
3344
3345 return list;
3346 }
3347
3348
3362 public DLFolder findByP_N_First(long parentFolderId, String name,
3363 OrderByComparator orderByComparator)
3364 throws NoSuchFolderException, SystemException {
3365 List<DLFolder> list = findByP_N(parentFolderId, name, 0, 1,
3366 orderByComparator);
3367
3368 if (list.isEmpty()) {
3369 StringBundler msg = new StringBundler(6);
3370
3371 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3372
3373 msg.append("parentFolderId=");
3374 msg.append(parentFolderId);
3375
3376 msg.append(", name=");
3377 msg.append(name);
3378
3379 msg.append(StringPool.CLOSE_CURLY_BRACE);
3380
3381 throw new NoSuchFolderException(msg.toString());
3382 }
3383 else {
3384 return list.get(0);
3385 }
3386 }
3387
3388
3402 public DLFolder findByP_N_Last(long parentFolderId, String name,
3403 OrderByComparator orderByComparator)
3404 throws NoSuchFolderException, SystemException {
3405 int count = countByP_N(parentFolderId, name);
3406
3407 List<DLFolder> list = findByP_N(parentFolderId, name, count - 1, count,
3408 orderByComparator);
3409
3410 if (list.isEmpty()) {
3411 StringBundler msg = new StringBundler(6);
3412
3413 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3414
3415 msg.append("parentFolderId=");
3416 msg.append(parentFolderId);
3417
3418 msg.append(", name=");
3419 msg.append(name);
3420
3421 msg.append(StringPool.CLOSE_CURLY_BRACE);
3422
3423 throw new NoSuchFolderException(msg.toString());
3424 }
3425 else {
3426 return list.get(0);
3427 }
3428 }
3429
3430
3445 public DLFolder[] findByP_N_PrevAndNext(long folderId, long parentFolderId,
3446 String name, OrderByComparator orderByComparator)
3447 throws NoSuchFolderException, SystemException {
3448 DLFolder dlFolder = findByPrimaryKey(folderId);
3449
3450 Session session = null;
3451
3452 try {
3453 session = openSession();
3454
3455 DLFolder[] array = new DLFolderImpl[3];
3456
3457 array[0] = getByP_N_PrevAndNext(session, dlFolder, parentFolderId,
3458 name, orderByComparator, true);
3459
3460 array[1] = dlFolder;
3461
3462 array[2] = getByP_N_PrevAndNext(session, dlFolder, parentFolderId,
3463 name, orderByComparator, false);
3464
3465 return array;
3466 }
3467 catch (Exception e) {
3468 throw processException(e);
3469 }
3470 finally {
3471 closeSession(session);
3472 }
3473 }
3474
3475 protected DLFolder getByP_N_PrevAndNext(Session session, DLFolder dlFolder,
3476 long parentFolderId, String name, OrderByComparator orderByComparator,
3477 boolean previous) {
3478 StringBundler query = null;
3479
3480 if (orderByComparator != null) {
3481 query = new StringBundler(6 +
3482 (orderByComparator.getOrderByFields().length * 6));
3483 }
3484 else {
3485 query = new StringBundler(3);
3486 }
3487
3488 query.append(_SQL_SELECT_DLFOLDER_WHERE);
3489
3490 query.append(_FINDER_COLUMN_P_N_PARENTFOLDERID_2);
3491
3492 if (name == null) {
3493 query.append(_FINDER_COLUMN_P_N_NAME_1);
3494 }
3495 else {
3496 if (name.equals(StringPool.BLANK)) {
3497 query.append(_FINDER_COLUMN_P_N_NAME_3);
3498 }
3499 else {
3500 query.append(_FINDER_COLUMN_P_N_NAME_2);
3501 }
3502 }
3503
3504 if (orderByComparator != null) {
3505 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3506
3507 if (orderByConditionFields.length > 0) {
3508 query.append(WHERE_AND);
3509 }
3510
3511 for (int i = 0; i < orderByConditionFields.length; i++) {
3512 query.append(_ORDER_BY_ENTITY_ALIAS);
3513 query.append(orderByConditionFields[i]);
3514
3515 if ((i + 1) < orderByConditionFields.length) {
3516 if (orderByComparator.isAscending() ^ previous) {
3517 query.append(WHERE_GREATER_THAN_HAS_NEXT);
3518 }
3519 else {
3520 query.append(WHERE_LESSER_THAN_HAS_NEXT);
3521 }
3522 }
3523 else {
3524 if (orderByComparator.isAscending() ^ previous) {
3525 query.append(WHERE_GREATER_THAN);
3526 }
3527 else {
3528 query.append(WHERE_LESSER_THAN);
3529 }
3530 }
3531 }
3532
3533 query.append(ORDER_BY_CLAUSE);
3534
3535 String[] orderByFields = orderByComparator.getOrderByFields();
3536
3537 for (int i = 0; i < orderByFields.length; i++) {
3538 query.append(_ORDER_BY_ENTITY_ALIAS);
3539 query.append(orderByFields[i]);
3540
3541 if ((i + 1) < orderByFields.length) {
3542 if (orderByComparator.isAscending() ^ previous) {
3543 query.append(ORDER_BY_ASC_HAS_NEXT);
3544 }
3545 else {
3546 query.append(ORDER_BY_DESC_HAS_NEXT);
3547 }
3548 }
3549 else {
3550 if (orderByComparator.isAscending() ^ previous) {
3551 query.append(ORDER_BY_ASC);
3552 }
3553 else {
3554 query.append(ORDER_BY_DESC);
3555 }
3556 }
3557 }
3558 }
3559
3560 else {
3561 query.append(DLFolderModelImpl.ORDER_BY_JPQL);
3562 }
3563
3564 String sql = query.toString();
3565
3566 Query q = session.createQuery(sql);
3567
3568 q.setFirstResult(0);
3569 q.setMaxResults(2);
3570
3571 QueryPos qPos = QueryPos.getInstance(q);
3572
3573 qPos.add(parentFolderId);
3574
3575 if (name != null) {
3576 qPos.add(name);
3577 }
3578
3579 if (orderByComparator != null) {
3580 Object[] values = orderByComparator.getOrderByConditionValues(dlFolder);
3581
3582 for (Object value : values) {
3583 qPos.add(value);
3584 }
3585 }
3586
3587 List<DLFolder> list = q.list();
3588
3589 if (list.size() == 2) {
3590 return list.get(1);
3591 }
3592 else {
3593 return null;
3594 }
3595 }
3596
3597
3606 public List<DLFolder> findByG_P_M(long groupId, long parentFolderId,
3607 boolean mountPoint) throws SystemException {
3608 return findByG_P_M(groupId, parentFolderId, mountPoint,
3609 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
3610 }
3611
3612
3627 public List<DLFolder> findByG_P_M(long groupId, long parentFolderId,
3628 boolean mountPoint, int start, int end) throws SystemException {
3629 return findByG_P_M(groupId, parentFolderId, mountPoint, start, end, null);
3630 }
3631
3632
3648 public List<DLFolder> findByG_P_M(long groupId, long parentFolderId,
3649 boolean mountPoint, int start, int end,
3650 OrderByComparator orderByComparator) throws SystemException {
3651 FinderPath finderPath = null;
3652 Object[] finderArgs = null;
3653
3654 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
3655 (orderByComparator == null)) {
3656 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_M;
3657 finderArgs = new Object[] { groupId, parentFolderId, mountPoint };
3658 }
3659 else {
3660 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_P_M;
3661 finderArgs = new Object[] {
3662 groupId, parentFolderId, mountPoint,
3663
3664 start, end, orderByComparator
3665 };
3666 }
3667
3668 List<DLFolder> list = (List<DLFolder>)FinderCacheUtil.getResult(finderPath,
3669 finderArgs, this);
3670
3671 if (list == null) {
3672 StringBundler query = null;
3673
3674 if (orderByComparator != null) {
3675 query = new StringBundler(5 +
3676 (orderByComparator.getOrderByFields().length * 3));
3677 }
3678 else {
3679 query = new StringBundler(5);
3680 }
3681
3682 query.append(_SQL_SELECT_DLFOLDER_WHERE);
3683
3684 query.append(_FINDER_COLUMN_G_P_M_GROUPID_2);
3685
3686 query.append(_FINDER_COLUMN_G_P_M_PARENTFOLDERID_2);
3687
3688 query.append(_FINDER_COLUMN_G_P_M_MOUNTPOINT_2);
3689
3690 if (orderByComparator != null) {
3691 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3692 orderByComparator);
3693 }
3694
3695 else {
3696 query.append(DLFolderModelImpl.ORDER_BY_JPQL);
3697 }
3698
3699 String sql = query.toString();
3700
3701 Session session = null;
3702
3703 try {
3704 session = openSession();
3705
3706 Query q = session.createQuery(sql);
3707
3708 QueryPos qPos = QueryPos.getInstance(q);
3709
3710 qPos.add(groupId);
3711
3712 qPos.add(parentFolderId);
3713
3714 qPos.add(mountPoint);
3715
3716 list = (List<DLFolder>)QueryUtil.list(q, getDialect(), start,
3717 end);
3718 }
3719 catch (Exception e) {
3720 throw processException(e);
3721 }
3722 finally {
3723 if (list == null) {
3724 FinderCacheUtil.removeResult(finderPath, finderArgs);
3725 }
3726 else {
3727 cacheResult(list);
3728
3729 FinderCacheUtil.putResult(finderPath, finderArgs, list);
3730 }
3731
3732 closeSession(session);
3733 }
3734 }
3735
3736 return list;
3737 }
3738
3739
3754 public DLFolder findByG_P_M_First(long groupId, long parentFolderId,
3755 boolean mountPoint, OrderByComparator orderByComparator)
3756 throws NoSuchFolderException, SystemException {
3757 List<DLFolder> list = findByG_P_M(groupId, parentFolderId, mountPoint,
3758 0, 1, orderByComparator);
3759
3760 if (list.isEmpty()) {
3761 StringBundler msg = new StringBundler(8);
3762
3763 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3764
3765 msg.append("groupId=");
3766 msg.append(groupId);
3767
3768 msg.append(", parentFolderId=");
3769 msg.append(parentFolderId);
3770
3771 msg.append(", mountPoint=");
3772 msg.append(mountPoint);
3773
3774 msg.append(StringPool.CLOSE_CURLY_BRACE);
3775
3776 throw new NoSuchFolderException(msg.toString());
3777 }
3778 else {
3779 return list.get(0);
3780 }
3781 }
3782
3783
3798 public DLFolder findByG_P_M_Last(long groupId, long parentFolderId,
3799 boolean mountPoint, OrderByComparator orderByComparator)
3800 throws NoSuchFolderException, SystemException {
3801 int count = countByG_P_M(groupId, parentFolderId, mountPoint);
3802
3803 List<DLFolder> list = findByG_P_M(groupId, parentFolderId, mountPoint,
3804 count - 1, count, orderByComparator);
3805
3806 if (list.isEmpty()) {
3807 StringBundler msg = new StringBundler(8);
3808
3809 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3810
3811 msg.append("groupId=");
3812 msg.append(groupId);
3813
3814 msg.append(", parentFolderId=");
3815 msg.append(parentFolderId);
3816
3817 msg.append(", mountPoint=");
3818 msg.append(mountPoint);
3819
3820 msg.append(StringPool.CLOSE_CURLY_BRACE);
3821
3822 throw new NoSuchFolderException(msg.toString());
3823 }
3824 else {
3825 return list.get(0);
3826 }
3827 }
3828
3829
3845 public DLFolder[] findByG_P_M_PrevAndNext(long folderId, long groupId,
3846 long parentFolderId, boolean mountPoint,
3847 OrderByComparator orderByComparator)
3848 throws NoSuchFolderException, SystemException {
3849 DLFolder dlFolder = findByPrimaryKey(folderId);
3850
3851 Session session = null;
3852
3853 try {
3854 session = openSession();
3855
3856 DLFolder[] array = new DLFolderImpl[3];
3857
3858 array[0] = getByG_P_M_PrevAndNext(session, dlFolder, groupId,
3859 parentFolderId, mountPoint, orderByComparator, true);
3860
3861 array[1] = dlFolder;
3862
3863 array[2] = getByG_P_M_PrevAndNext(session, dlFolder, groupId,
3864 parentFolderId, mountPoint, orderByComparator, false);
3865
3866 return array;
3867 }
3868 catch (Exception e) {
3869 throw processException(e);
3870 }
3871 finally {
3872 closeSession(session);
3873 }
3874 }
3875
3876 protected DLFolder getByG_P_M_PrevAndNext(Session session,
3877 DLFolder dlFolder, long groupId, long parentFolderId,
3878 boolean mountPoint, OrderByComparator orderByComparator,
3879 boolean previous) {
3880 StringBundler query = null;
3881
3882 if (orderByComparator != null) {
3883 query = new StringBundler(6 +
3884 (orderByComparator.getOrderByFields().length * 6));
3885 }
3886 else {
3887 query = new StringBundler(3);
3888 }
3889
3890 query.append(_SQL_SELECT_DLFOLDER_WHERE);
3891
3892 query.append(_FINDER_COLUMN_G_P_M_GROUPID_2);
3893
3894 query.append(_FINDER_COLUMN_G_P_M_PARENTFOLDERID_2);
3895
3896 query.append(_FINDER_COLUMN_G_P_M_MOUNTPOINT_2);
3897
3898 if (orderByComparator != null) {
3899 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3900
3901 if (orderByConditionFields.length > 0) {
3902 query.append(WHERE_AND);
3903 }
3904
3905 for (int i = 0; i < orderByConditionFields.length; i++) {
3906 query.append(_ORDER_BY_ENTITY_ALIAS);
3907 query.append(orderByConditionFields[i]);
3908
3909 if ((i + 1) < orderByConditionFields.length) {
3910 if (orderByComparator.isAscending() ^ previous) {
3911 query.append(WHERE_GREATER_THAN_HAS_NEXT);
3912 }
3913 else {
3914 query.append(WHERE_LESSER_THAN_HAS_NEXT);
3915 }
3916 }
3917 else {
3918 if (orderByComparator.isAscending() ^ previous) {
3919 query.append(WHERE_GREATER_THAN);
3920 }
3921 else {
3922 query.append(WHERE_LESSER_THAN);
3923 }
3924 }
3925 }
3926
3927 query.append(ORDER_BY_CLAUSE);
3928
3929 String[] orderByFields = orderByComparator.getOrderByFields();
3930
3931 for (int i = 0; i < orderByFields.length; i++) {
3932 query.append(_ORDER_BY_ENTITY_ALIAS);
3933 query.append(orderByFields[i]);
3934
3935 if ((i + 1) < orderByFields.length) {
3936 if (orderByComparator.isAscending() ^ previous) {
3937 query.append(ORDER_BY_ASC_HAS_NEXT);
3938 }
3939 else {
3940 query.append(ORDER_BY_DESC_HAS_NEXT);
3941 }
3942 }
3943 else {
3944 if (orderByComparator.isAscending() ^ previous) {
3945 query.append(ORDER_BY_ASC);
3946 }
3947 else {
3948 query.append(ORDER_BY_DESC);
3949 }
3950 }
3951 }
3952 }
3953
3954 else {
3955 query.append(DLFolderModelImpl.ORDER_BY_JPQL);
3956 }
3957
3958 String sql = query.toString();
3959
3960 Query q = session.createQuery(sql);
3961
3962 q.setFirstResult(0);
3963 q.setMaxResults(2);
3964
3965 QueryPos qPos = QueryPos.getInstance(q);
3966
3967 qPos.add(groupId);
3968
3969 qPos.add(parentFolderId);
3970
3971 qPos.add(mountPoint);
3972
3973 if (orderByComparator != null) {
3974 Object[] values = orderByComparator.getOrderByConditionValues(dlFolder);
3975
3976 for (Object value : values) {
3977 qPos.add(value);
3978 }
3979 }
3980
3981 List<DLFolder> list = q.list();
3982
3983 if (list.size() == 2) {
3984 return list.get(1);
3985 }
3986 else {
3987 return null;
3988 }
3989 }
3990
3991
4000 public List<DLFolder> filterFindByG_P_M(long groupId, long parentFolderId,
4001 boolean mountPoint) throws SystemException {
4002 return filterFindByG_P_M(groupId, parentFolderId, mountPoint,
4003 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
4004 }
4005
4006
4021 public List<DLFolder> filterFindByG_P_M(long groupId, long parentFolderId,
4022 boolean mountPoint, int start, int end) throws SystemException {
4023 return filterFindByG_P_M(groupId, parentFolderId, mountPoint, start,
4024 end, null);
4025 }
4026
4027
4043 public List<DLFolder> filterFindByG_P_M(long groupId, long parentFolderId,
4044 boolean mountPoint, int start, int end,
4045 OrderByComparator orderByComparator) throws SystemException {
4046 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
4047 return findByG_P_M(groupId, parentFolderId, mountPoint, start, end,
4048 orderByComparator);
4049 }
4050
4051 StringBundler query = null;
4052
4053 if (orderByComparator != null) {
4054 query = new StringBundler(5 +
4055 (orderByComparator.getOrderByFields().length * 3));
4056 }
4057 else {
4058 query = new StringBundler(5);
4059 }
4060
4061 if (getDB().isSupportsInlineDistinct()) {
4062 query.append(_FILTER_SQL_SELECT_DLFOLDER_WHERE);
4063 }
4064 else {
4065 query.append(_FILTER_SQL_SELECT_DLFOLDER_NO_INLINE_DISTINCT_WHERE_1);
4066 }
4067
4068 query.append(_FINDER_COLUMN_G_P_M_GROUPID_2);
4069
4070 query.append(_FINDER_COLUMN_G_P_M_PARENTFOLDERID_2);
4071
4072 query.append(_FINDER_COLUMN_G_P_M_MOUNTPOINT_2);
4073
4074 if (!getDB().isSupportsInlineDistinct()) {
4075 query.append(_FILTER_SQL_SELECT_DLFOLDER_NO_INLINE_DISTINCT_WHERE_2);
4076 }
4077
4078 if (orderByComparator != null) {
4079 if (getDB().isSupportsInlineDistinct()) {
4080 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4081 orderByComparator);
4082 }
4083 else {
4084 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
4085 orderByComparator);
4086 }
4087 }
4088
4089 else {
4090 if (getDB().isSupportsInlineDistinct()) {
4091 query.append(DLFolderModelImpl.ORDER_BY_JPQL);
4092 }
4093 else {
4094 query.append(DLFolderModelImpl.ORDER_BY_SQL);
4095 }
4096 }
4097
4098 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
4099 DLFolder.class.getName(),
4100 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
4101
4102 Session session = null;
4103
4104 try {
4105 session = openSession();
4106
4107 SQLQuery q = session.createSQLQuery(sql);
4108
4109 if (getDB().isSupportsInlineDistinct()) {
4110 q.addEntity(_FILTER_ENTITY_ALIAS, DLFolderImpl.class);
4111 }
4112 else {
4113 q.addEntity(_FILTER_ENTITY_TABLE, DLFolderImpl.class);
4114 }
4115
4116 QueryPos qPos = QueryPos.getInstance(q);
4117
4118 qPos.add(groupId);
4119
4120 qPos.add(parentFolderId);
4121
4122 qPos.add(mountPoint);
4123
4124 return (List<DLFolder>)QueryUtil.list(q, getDialect(), start, end);
4125 }
4126 catch (Exception e) {
4127 throw processException(e);
4128 }
4129 finally {
4130 closeSession(session);
4131 }
4132 }
4133
4134
4146 public DLFolder[] filterFindByG_P_M_PrevAndNext(long folderId,
4147 long groupId, long parentFolderId, boolean mountPoint,
4148 OrderByComparator orderByComparator)
4149 throws NoSuchFolderException, SystemException {
4150 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
4151 return findByG_P_M_PrevAndNext(folderId, groupId, parentFolderId,
4152 mountPoint, orderByComparator);
4153 }
4154
4155 DLFolder dlFolder = findByPrimaryKey(folderId);
4156
4157 Session session = null;
4158
4159 try {
4160 session = openSession();
4161
4162 DLFolder[] array = new DLFolderImpl[3];
4163
4164 array[0] = filterGetByG_P_M_PrevAndNext(session, dlFolder, groupId,
4165 parentFolderId, mountPoint, orderByComparator, true);
4166
4167 array[1] = dlFolder;
4168
4169 array[2] = filterGetByG_P_M_PrevAndNext(session, dlFolder, groupId,
4170 parentFolderId, mountPoint, orderByComparator, false);
4171
4172 return array;
4173 }
4174 catch (Exception e) {
4175 throw processException(e);
4176 }
4177 finally {
4178 closeSession(session);
4179 }
4180 }
4181
4182 protected DLFolder filterGetByG_P_M_PrevAndNext(Session session,
4183 DLFolder dlFolder, long groupId, long parentFolderId,
4184 boolean mountPoint, OrderByComparator orderByComparator,
4185 boolean previous) {
4186 StringBundler query = null;
4187
4188 if (orderByComparator != null) {
4189 query = new StringBundler(6 +
4190 (orderByComparator.getOrderByFields().length * 6));
4191 }
4192 else {
4193 query = new StringBundler(3);
4194 }
4195
4196 if (getDB().isSupportsInlineDistinct()) {
4197 query.append(_FILTER_SQL_SELECT_DLFOLDER_WHERE);
4198 }
4199 else {
4200 query.append(_FILTER_SQL_SELECT_DLFOLDER_NO_INLINE_DISTINCT_WHERE_1);
4201 }
4202
4203 query.append(_FINDER_COLUMN_G_P_M_GROUPID_2);
4204
4205 query.append(_FINDER_COLUMN_G_P_M_PARENTFOLDERID_2);
4206
4207 query.append(_FINDER_COLUMN_G_P_M_MOUNTPOINT_2);
4208
4209 if (!getDB().isSupportsInlineDistinct()) {
4210 query.append(_FILTER_SQL_SELECT_DLFOLDER_NO_INLINE_DISTINCT_WHERE_2);
4211 }
4212
4213 if (orderByComparator != null) {
4214 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
4215
4216 if (orderByConditionFields.length > 0) {
4217 query.append(WHERE_AND);
4218 }
4219
4220 for (int i = 0; i < orderByConditionFields.length; i++) {
4221 if (getDB().isSupportsInlineDistinct()) {
4222 query.append(_ORDER_BY_ENTITY_ALIAS);
4223 }
4224 else {
4225 query.append(_ORDER_BY_ENTITY_TABLE);
4226 }
4227
4228 query.append(orderByConditionFields[i]);
4229
4230 if ((i + 1) < orderByConditionFields.length) {
4231 if (orderByComparator.isAscending() ^ previous) {
4232 query.append(WHERE_GREATER_THAN_HAS_NEXT);
4233 }
4234 else {
4235 query.append(WHERE_LESSER_THAN_HAS_NEXT);
4236 }
4237 }
4238 else {
4239 if (orderByComparator.isAscending() ^ previous) {
4240 query.append(WHERE_GREATER_THAN);
4241 }
4242 else {
4243 query.append(WHERE_LESSER_THAN);
4244 }
4245 }
4246 }
4247
4248 query.append(ORDER_BY_CLAUSE);
4249
4250 String[] orderByFields = orderByComparator.getOrderByFields();
4251
4252 for (int i = 0; i < orderByFields.length; i++) {
4253 if (getDB().isSupportsInlineDistinct()) {
4254 query.append(_ORDER_BY_ENTITY_ALIAS);
4255 }
4256 else {
4257 query.append(_ORDER_BY_ENTITY_TABLE);
4258 }
4259
4260 query.append(orderByFields[i]);
4261
4262 if ((i + 1) < orderByFields.length) {
4263 if (orderByComparator.isAscending() ^ previous) {
4264 query.append(ORDER_BY_ASC_HAS_NEXT);
4265 }
4266 else {
4267 query.append(ORDER_BY_DESC_HAS_NEXT);
4268 }
4269 }
4270 else {
4271 if (orderByComparator.isAscending() ^ previous) {
4272 query.append(ORDER_BY_ASC);
4273 }
4274 else {
4275 query.append(ORDER_BY_DESC);
4276 }
4277 }
4278 }
4279 }
4280
4281 else {
4282 if (getDB().isSupportsInlineDistinct()) {
4283 query.append(DLFolderModelImpl.ORDER_BY_JPQL);
4284 }
4285 else {
4286 query.append(DLFolderModelImpl.ORDER_BY_SQL);
4287 }
4288 }
4289
4290 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
4291 DLFolder.class.getName(),
4292 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
4293
4294 SQLQuery q = session.createSQLQuery(sql);
4295
4296 q.setFirstResult(0);
4297 q.setMaxResults(2);
4298
4299 if (getDB().isSupportsInlineDistinct()) {
4300 q.addEntity(_FILTER_ENTITY_ALIAS, DLFolderImpl.class);
4301 }
4302 else {
4303 q.addEntity(_FILTER_ENTITY_TABLE, DLFolderImpl.class);
4304 }
4305
4306 QueryPos qPos = QueryPos.getInstance(q);
4307
4308 qPos.add(groupId);
4309
4310 qPos.add(parentFolderId);
4311
4312 qPos.add(mountPoint);
4313
4314 if (orderByComparator != null) {
4315 Object[] values = orderByComparator.getOrderByConditionValues(dlFolder);
4316
4317 for (Object value : values) {
4318 qPos.add(value);
4319 }
4320 }
4321
4322 List<DLFolder> list = q.list();
4323
4324 if (list.size() == 2) {
4325 return list.get(1);
4326 }
4327 else {
4328 return null;
4329 }
4330 }
4331
4332
4342 public DLFolder findByG_P_N(long groupId, long parentFolderId, String name)
4343 throws NoSuchFolderException, SystemException {
4344 DLFolder dlFolder = fetchByG_P_N(groupId, parentFolderId, name);
4345
4346 if (dlFolder == null) {
4347 StringBundler msg = new StringBundler(8);
4348
4349 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4350
4351 msg.append("groupId=");
4352 msg.append(groupId);
4353
4354 msg.append(", parentFolderId=");
4355 msg.append(parentFolderId);
4356
4357 msg.append(", name=");
4358 msg.append(name);
4359
4360 msg.append(StringPool.CLOSE_CURLY_BRACE);
4361
4362 if (_log.isWarnEnabled()) {
4363 _log.warn(msg.toString());
4364 }
4365
4366 throw new NoSuchFolderException(msg.toString());
4367 }
4368
4369 return dlFolder;
4370 }
4371
4372
4381 public DLFolder fetchByG_P_N(long groupId, long parentFolderId, String name)
4382 throws SystemException {
4383 return fetchByG_P_N(groupId, parentFolderId, name, true);
4384 }
4385
4386
4396 public DLFolder fetchByG_P_N(long groupId, long parentFolderId,
4397 String name, boolean retrieveFromCache) throws SystemException {
4398 Object[] finderArgs = new Object[] { groupId, parentFolderId, name };
4399
4400 Object result = null;
4401
4402 if (retrieveFromCache) {
4403 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_G_P_N,
4404 finderArgs, this);
4405 }
4406
4407 if (result == null) {
4408 StringBundler query = new StringBundler(5);
4409
4410 query.append(_SQL_SELECT_DLFOLDER_WHERE);
4411
4412 query.append(_FINDER_COLUMN_G_P_N_GROUPID_2);
4413
4414 query.append(_FINDER_COLUMN_G_P_N_PARENTFOLDERID_2);
4415
4416 if (name == null) {
4417 query.append(_FINDER_COLUMN_G_P_N_NAME_1);
4418 }
4419 else {
4420 if (name.equals(StringPool.BLANK)) {
4421 query.append(_FINDER_COLUMN_G_P_N_NAME_3);
4422 }
4423 else {
4424 query.append(_FINDER_COLUMN_G_P_N_NAME_2);
4425 }
4426 }
4427
4428 query.append(DLFolderModelImpl.ORDER_BY_JPQL);
4429
4430 String sql = query.toString();
4431
4432 Session session = null;
4433
4434 try {
4435 session = openSession();
4436
4437 Query q = session.createQuery(sql);
4438
4439 QueryPos qPos = QueryPos.getInstance(q);
4440
4441 qPos.add(groupId);
4442
4443 qPos.add(parentFolderId);
4444
4445 if (name != null) {
4446 qPos.add(name);
4447 }
4448
4449 List<DLFolder> list = q.list();
4450
4451 result = list;
4452
4453 DLFolder dlFolder = null;
4454
4455 if (list.isEmpty()) {
4456 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_P_N,
4457 finderArgs, list);
4458 }
4459 else {
4460 dlFolder = list.get(0);
4461
4462 cacheResult(dlFolder);
4463
4464 if ((dlFolder.getGroupId() != groupId) ||
4465 (dlFolder.getParentFolderId() != parentFolderId) ||
4466 (dlFolder.getName() == null) ||
4467 !dlFolder.getName().equals(name)) {
4468 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_P_N,
4469 finderArgs, dlFolder);
4470 }
4471 }
4472
4473 return dlFolder;
4474 }
4475 catch (Exception e) {
4476 throw processException(e);
4477 }
4478 finally {
4479 if (result == null) {
4480 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_P_N,
4481 finderArgs);
4482 }
4483
4484 closeSession(session);
4485 }
4486 }
4487 else {
4488 if (result instanceof List<?>) {
4489 return null;
4490 }
4491 else {
4492 return (DLFolder)result;
4493 }
4494 }
4495 }
4496
4497
4503 public List<DLFolder> findAll() throws SystemException {
4504 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
4505 }
4506
4507
4519 public List<DLFolder> findAll(int start, int end) throws SystemException {
4520 return findAll(start, end, null);
4521 }
4522
4523
4536 public List<DLFolder> findAll(int start, int end,
4537 OrderByComparator orderByComparator) throws SystemException {
4538 FinderPath finderPath = null;
4539 Object[] finderArgs = new Object[] { start, end, orderByComparator };
4540
4541 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
4542 (orderByComparator == null)) {
4543 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
4544 finderArgs = FINDER_ARGS_EMPTY;
4545 }
4546 else {
4547 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
4548 finderArgs = new Object[] { start, end, orderByComparator };
4549 }
4550
4551 List<DLFolder> list = (List<DLFolder>)FinderCacheUtil.getResult(finderPath,
4552 finderArgs, this);
4553
4554 if (list == null) {
4555 StringBundler query = null;
4556 String sql = null;
4557
4558 if (orderByComparator != null) {
4559 query = new StringBundler(2 +
4560 (orderByComparator.getOrderByFields().length * 3));
4561
4562 query.append(_SQL_SELECT_DLFOLDER);
4563
4564 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4565 orderByComparator);
4566
4567 sql = query.toString();
4568 }
4569 else {
4570 sql = _SQL_SELECT_DLFOLDER.concat(DLFolderModelImpl.ORDER_BY_JPQL);
4571 }
4572
4573 Session session = null;
4574
4575 try {
4576 session = openSession();
4577
4578 Query q = session.createQuery(sql);
4579
4580 if (orderByComparator == null) {
4581 list = (List<DLFolder>)QueryUtil.list(q, getDialect(),
4582 start, end, false);
4583
4584 Collections.sort(list);
4585 }
4586 else {
4587 list = (List<DLFolder>)QueryUtil.list(q, getDialect(),
4588 start, end);
4589 }
4590 }
4591 catch (Exception e) {
4592 throw processException(e);
4593 }
4594 finally {
4595 if (list == null) {
4596 FinderCacheUtil.removeResult(finderPath, finderArgs);
4597 }
4598 else {
4599 cacheResult(list);
4600
4601 FinderCacheUtil.putResult(finderPath, finderArgs, list);
4602 }
4603
4604 closeSession(session);
4605 }
4606 }
4607
4608 return list;
4609 }
4610
4611
4617 public void removeByUuid(String uuid) throws SystemException {
4618 for (DLFolder dlFolder : findByUuid(uuid)) {
4619 remove(dlFolder);
4620 }
4621 }
4622
4623
4630 public void removeByUUID_G(String uuid, long groupId)
4631 throws NoSuchFolderException, SystemException {
4632 DLFolder dlFolder = findByUUID_G(uuid, groupId);
4633
4634 remove(dlFolder);
4635 }
4636
4637
4643 public void removeByGroupId(long groupId) throws SystemException {
4644 for (DLFolder dlFolder : findByGroupId(groupId)) {
4645 remove(dlFolder);
4646 }
4647 }
4648
4649
4655 public void removeByCompanyId(long companyId) throws SystemException {
4656 for (DLFolder dlFolder : findByCompanyId(companyId)) {
4657 remove(dlFolder);
4658 }
4659 }
4660
4661
4667 public void removeByRepositoryId(long repositoryId)
4668 throws NoSuchFolderException, SystemException {
4669 DLFolder dlFolder = findByRepositoryId(repositoryId);
4670
4671 remove(dlFolder);
4672 }
4673
4674
4681 public void removeByG_P(long groupId, long parentFolderId)
4682 throws SystemException {
4683 for (DLFolder dlFolder : findByG_P(groupId, parentFolderId)) {
4684 remove(dlFolder);
4685 }
4686 }
4687
4688
4695 public void removeByP_N(long parentFolderId, String name)
4696 throws SystemException {
4697 for (DLFolder dlFolder : findByP_N(parentFolderId, name)) {
4698 remove(dlFolder);
4699 }
4700 }
4701
4702
4710 public void removeByG_P_M(long groupId, long parentFolderId,
4711 boolean mountPoint) throws SystemException {
4712 for (DLFolder dlFolder : findByG_P_M(groupId, parentFolderId, mountPoint)) {
4713 remove(dlFolder);
4714 }
4715 }
4716
4717
4725 public void removeByG_P_N(long groupId, long parentFolderId, String name)
4726 throws NoSuchFolderException, SystemException {
4727 DLFolder dlFolder = findByG_P_N(groupId, parentFolderId, name);
4728
4729 remove(dlFolder);
4730 }
4731
4732
4737 public void removeAll() throws SystemException {
4738 for (DLFolder dlFolder : findAll()) {
4739 remove(dlFolder);
4740 }
4741 }
4742
4743
4750 public int countByUuid(String uuid) throws SystemException {
4751 Object[] finderArgs = new Object[] { uuid };
4752
4753 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID,
4754 finderArgs, this);
4755
4756 if (count == null) {
4757 StringBundler query = new StringBundler(2);
4758
4759 query.append(_SQL_COUNT_DLFOLDER_WHERE);
4760
4761 if (uuid == null) {
4762 query.append(_FINDER_COLUMN_UUID_UUID_1);
4763 }
4764 else {
4765 if (uuid.equals(StringPool.BLANK)) {
4766 query.append(_FINDER_COLUMN_UUID_UUID_3);
4767 }
4768 else {
4769 query.append(_FINDER_COLUMN_UUID_UUID_2);
4770 }
4771 }
4772
4773 String sql = query.toString();
4774
4775 Session session = null;
4776
4777 try {
4778 session = openSession();
4779
4780 Query q = session.createQuery(sql);
4781
4782 QueryPos qPos = QueryPos.getInstance(q);
4783
4784 if (uuid != null) {
4785 qPos.add(uuid);
4786 }
4787
4788 count = (Long)q.uniqueResult();
4789 }
4790 catch (Exception e) {
4791 throw processException(e);
4792 }
4793 finally {
4794 if (count == null) {
4795 count = Long.valueOf(0);
4796 }
4797
4798 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID,
4799 finderArgs, count);
4800
4801 closeSession(session);
4802 }
4803 }
4804
4805 return count.intValue();
4806 }
4807
4808
4816 public int countByUUID_G(String uuid, long groupId)
4817 throws SystemException {
4818 Object[] finderArgs = new Object[] { uuid, groupId };
4819
4820 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID_G,
4821 finderArgs, this);
4822
4823 if (count == null) {
4824 StringBundler query = new StringBundler(3);
4825
4826 query.append(_SQL_COUNT_DLFOLDER_WHERE);
4827
4828 if (uuid == null) {
4829 query.append(_FINDER_COLUMN_UUID_G_UUID_1);
4830 }
4831 else {
4832 if (uuid.equals(StringPool.BLANK)) {
4833 query.append(_FINDER_COLUMN_UUID_G_UUID_3);
4834 }
4835 else {
4836 query.append(_FINDER_COLUMN_UUID_G_UUID_2);
4837 }
4838 }
4839
4840 query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
4841
4842 String sql = query.toString();
4843
4844 Session session = null;
4845
4846 try {
4847 session = openSession();
4848
4849 Query q = session.createQuery(sql);
4850
4851 QueryPos qPos = QueryPos.getInstance(q);
4852
4853 if (uuid != null) {
4854 qPos.add(uuid);
4855 }
4856
4857 qPos.add(groupId);
4858
4859 count = (Long)q.uniqueResult();
4860 }
4861 catch (Exception e) {
4862 throw processException(e);
4863 }
4864 finally {
4865 if (count == null) {
4866 count = Long.valueOf(0);
4867 }
4868
4869 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G,
4870 finderArgs, count);
4871
4872 closeSession(session);
4873 }
4874 }
4875
4876 return count.intValue();
4877 }
4878
4879
4886 public int countByGroupId(long groupId) throws SystemException {
4887 Object[] finderArgs = new Object[] { groupId };
4888
4889 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_GROUPID,
4890 finderArgs, this);
4891
4892 if (count == null) {
4893 StringBundler query = new StringBundler(2);
4894
4895 query.append(_SQL_COUNT_DLFOLDER_WHERE);
4896
4897 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
4898
4899 String sql = query.toString();
4900
4901 Session session = null;
4902
4903 try {
4904 session = openSession();
4905
4906 Query q = session.createQuery(sql);
4907
4908 QueryPos qPos = QueryPos.getInstance(q);
4909
4910 qPos.add(groupId);
4911
4912 count = (Long)q.uniqueResult();
4913 }
4914 catch (Exception e) {
4915 throw processException(e);
4916 }
4917 finally {
4918 if (count == null) {
4919 count = Long.valueOf(0);
4920 }
4921
4922 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_GROUPID,
4923 finderArgs, count);
4924
4925 closeSession(session);
4926 }
4927 }
4928
4929 return count.intValue();
4930 }
4931
4932
4939 public int filterCountByGroupId(long groupId) throws SystemException {
4940 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
4941 return countByGroupId(groupId);
4942 }
4943
4944 StringBundler query = new StringBundler(2);
4945
4946 query.append(_FILTER_SQL_COUNT_DLFOLDER_WHERE);
4947
4948 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
4949
4950 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
4951 DLFolder.class.getName(),
4952 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
4953
4954 Session session = null;
4955
4956 try {
4957 session = openSession();
4958
4959 SQLQuery q = session.createSQLQuery(sql);
4960
4961 q.addScalar(COUNT_COLUMN_NAME,
4962 com.liferay.portal.kernel.dao.orm.Type.LONG);
4963
4964 QueryPos qPos = QueryPos.getInstance(q);
4965
4966 qPos.add(groupId);
4967
4968 Long count = (Long)q.uniqueResult();
4969
4970 return count.intValue();
4971 }
4972 catch (Exception e) {
4973 throw processException(e);
4974 }
4975 finally {
4976 closeSession(session);
4977 }
4978 }
4979
4980
4987 public int countByCompanyId(long companyId) throws SystemException {
4988 Object[] finderArgs = new Object[] { companyId };
4989
4990 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_COMPANYID,
4991 finderArgs, this);
4992
4993 if (count == null) {
4994 StringBundler query = new StringBundler(2);
4995
4996 query.append(_SQL_COUNT_DLFOLDER_WHERE);
4997
4998 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
4999
5000 String sql = query.toString();
5001
5002 Session session = null;
5003
5004 try {
5005 session = openSession();
5006
5007 Query q = session.createQuery(sql);
5008
5009 QueryPos qPos = QueryPos.getInstance(q);
5010
5011 qPos.add(companyId);
5012
5013 count = (Long)q.uniqueResult();
5014 }
5015 catch (Exception e) {
5016 throw processException(e);
5017 }
5018 finally {
5019 if (count == null) {
5020 count = Long.valueOf(0);
5021 }
5022
5023 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_COMPANYID,
5024 finderArgs, count);
5025
5026 closeSession(session);
5027 }
5028 }
5029
5030 return count.intValue();
5031 }
5032
5033
5040 public int countByRepositoryId(long repositoryId) throws SystemException {
5041 Object[] finderArgs = new Object[] { repositoryId };
5042
5043 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_REPOSITORYID,
5044 finderArgs, this);
5045
5046 if (count == null) {
5047 StringBundler query = new StringBundler(2);
5048
5049 query.append(_SQL_COUNT_DLFOLDER_WHERE);
5050
5051 query.append(_FINDER_COLUMN_REPOSITORYID_REPOSITORYID_2);
5052
5053 String sql = query.toString();
5054
5055 Session session = null;
5056
5057 try {
5058 session = openSession();
5059
5060 Query q = session.createQuery(sql);
5061
5062 QueryPos qPos = QueryPos.getInstance(q);
5063
5064 qPos.add(repositoryId);
5065
5066 count = (Long)q.uniqueResult();
5067 }
5068 catch (Exception e) {
5069 throw processException(e);
5070 }
5071 finally {
5072 if (count == null) {
5073 count = Long.valueOf(0);
5074 }
5075
5076 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_REPOSITORYID,
5077 finderArgs, count);
5078
5079 closeSession(session);
5080 }
5081 }
5082
5083 return count.intValue();
5084 }
5085
5086
5094 public int countByG_P(long groupId, long parentFolderId)
5095 throws SystemException {
5096 Object[] finderArgs = new Object[] { groupId, parentFolderId };
5097
5098 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_P,
5099 finderArgs, this);
5100
5101 if (count == null) {
5102 StringBundler query = new StringBundler(3);
5103
5104 query.append(_SQL_COUNT_DLFOLDER_WHERE);
5105
5106 query.append(_FINDER_COLUMN_G_P_GROUPID_2);
5107
5108 query.append(_FINDER_COLUMN_G_P_PARENTFOLDERID_2);
5109
5110 String sql = query.toString();
5111
5112 Session session = null;
5113
5114 try {
5115 session = openSession();
5116
5117 Query q = session.createQuery(sql);
5118
5119 QueryPos qPos = QueryPos.getInstance(q);
5120
5121 qPos.add(groupId);
5122
5123 qPos.add(parentFolderId);
5124
5125 count = (Long)q.uniqueResult();
5126 }
5127 catch (Exception e) {
5128 throw processException(e);
5129 }
5130 finally {
5131 if (count == null) {
5132 count = Long.valueOf(0);
5133 }
5134
5135 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_P, finderArgs,
5136 count);
5137
5138 closeSession(session);
5139 }
5140 }
5141
5142 return count.intValue();
5143 }
5144
5145
5153 public int filterCountByG_P(long groupId, long parentFolderId)
5154 throws SystemException {
5155 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
5156 return countByG_P(groupId, parentFolderId);
5157 }
5158
5159 StringBundler query = new StringBundler(3);
5160
5161 query.append(_FILTER_SQL_COUNT_DLFOLDER_WHERE);
5162
5163 query.append(_FINDER_COLUMN_G_P_GROUPID_2);
5164
5165 query.append(_FINDER_COLUMN_G_P_PARENTFOLDERID_2);
5166
5167 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
5168 DLFolder.class.getName(),
5169 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
5170
5171 Session session = null;
5172
5173 try {
5174 session = openSession();
5175
5176 SQLQuery q = session.createSQLQuery(sql);
5177
5178 q.addScalar(COUNT_COLUMN_NAME,
5179 com.liferay.portal.kernel.dao.orm.Type.LONG);
5180
5181 QueryPos qPos = QueryPos.getInstance(q);
5182
5183 qPos.add(groupId);
5184
5185 qPos.add(parentFolderId);
5186
5187 Long count = (Long)q.uniqueResult();
5188
5189 return count.intValue();
5190 }
5191 catch (Exception e) {
5192 throw processException(e);
5193 }
5194 finally {
5195 closeSession(session);
5196 }
5197 }
5198
5199
5207 public int countByP_N(long parentFolderId, String name)
5208 throws SystemException {
5209 Object[] finderArgs = new Object[] { parentFolderId, name };
5210
5211 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_P_N,
5212 finderArgs, this);
5213
5214 if (count == null) {
5215 StringBundler query = new StringBundler(3);
5216
5217 query.append(_SQL_COUNT_DLFOLDER_WHERE);
5218
5219 query.append(_FINDER_COLUMN_P_N_PARENTFOLDERID_2);
5220
5221 if (name == null) {
5222 query.append(_FINDER_COLUMN_P_N_NAME_1);
5223 }
5224 else {
5225 if (name.equals(StringPool.BLANK)) {
5226 query.append(_FINDER_COLUMN_P_N_NAME_3);
5227 }
5228 else {
5229 query.append(_FINDER_COLUMN_P_N_NAME_2);
5230 }
5231 }
5232
5233 String sql = query.toString();
5234
5235 Session session = null;
5236
5237 try {
5238 session = openSession();
5239
5240 Query q = session.createQuery(sql);
5241
5242 QueryPos qPos = QueryPos.getInstance(q);
5243
5244 qPos.add(parentFolderId);
5245
5246 if (name != null) {
5247 qPos.add(name);
5248 }
5249
5250 count = (Long)q.uniqueResult();
5251 }
5252 catch (Exception e) {
5253 throw processException(e);
5254 }
5255 finally {
5256 if (count == null) {
5257 count = Long.valueOf(0);
5258 }
5259
5260 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_P_N, finderArgs,
5261 count);
5262
5263 closeSession(session);
5264 }
5265 }
5266
5267 return count.intValue();
5268 }
5269
5270
5279 public int countByG_P_M(long groupId, long parentFolderId,
5280 boolean mountPoint) throws SystemException {
5281 Object[] finderArgs = new Object[] { groupId, parentFolderId, mountPoint };
5282
5283 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_P_M,
5284 finderArgs, this);
5285
5286 if (count == null) {
5287 StringBundler query = new StringBundler(4);
5288
5289 query.append(_SQL_COUNT_DLFOLDER_WHERE);
5290
5291 query.append(_FINDER_COLUMN_G_P_M_GROUPID_2);
5292
5293 query.append(_FINDER_COLUMN_G_P_M_PARENTFOLDERID_2);
5294
5295 query.append(_FINDER_COLUMN_G_P_M_MOUNTPOINT_2);
5296
5297 String sql = query.toString();
5298
5299 Session session = null;
5300
5301 try {
5302 session = openSession();
5303
5304 Query q = session.createQuery(sql);
5305
5306 QueryPos qPos = QueryPos.getInstance(q);
5307
5308 qPos.add(groupId);
5309
5310 qPos.add(parentFolderId);
5311
5312 qPos.add(mountPoint);
5313
5314 count = (Long)q.uniqueResult();
5315 }
5316 catch (Exception e) {
5317 throw processException(e);
5318 }
5319 finally {
5320 if (count == null) {
5321 count = Long.valueOf(0);
5322 }
5323
5324 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_P_M,
5325 finderArgs, count);
5326
5327 closeSession(session);
5328 }
5329 }
5330
5331 return count.intValue();
5332 }
5333
5334
5343 public int filterCountByG_P_M(long groupId, long parentFolderId,
5344 boolean mountPoint) throws SystemException {
5345 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
5346 return countByG_P_M(groupId, parentFolderId, mountPoint);
5347 }
5348
5349 StringBundler query = new StringBundler(4);
5350
5351 query.append(_FILTER_SQL_COUNT_DLFOLDER_WHERE);
5352
5353 query.append(_FINDER_COLUMN_G_P_M_GROUPID_2);
5354
5355 query.append(_FINDER_COLUMN_G_P_M_PARENTFOLDERID_2);
5356
5357 query.append(_FINDER_COLUMN_G_P_M_MOUNTPOINT_2);
5358
5359 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
5360 DLFolder.class.getName(),
5361 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
5362
5363 Session session = null;
5364
5365 try {
5366 session = openSession();
5367
5368 SQLQuery q = session.createSQLQuery(sql);
5369
5370 q.addScalar(COUNT_COLUMN_NAME,
5371 com.liferay.portal.kernel.dao.orm.Type.LONG);
5372
5373 QueryPos qPos = QueryPos.getInstance(q);
5374
5375 qPos.add(groupId);
5376
5377 qPos.add(parentFolderId);
5378
5379 qPos.add(mountPoint);
5380
5381 Long count = (Long)q.uniqueResult();
5382
5383 return count.intValue();
5384 }
5385 catch (Exception e) {
5386 throw processException(e);
5387 }
5388 finally {
5389 closeSession(session);
5390 }
5391 }
5392
5393
5402 public int countByG_P_N(long groupId, long parentFolderId, String name)
5403 throws SystemException {
5404 Object[] finderArgs = new Object[] { groupId, parentFolderId, name };
5405
5406 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_P_N,
5407 finderArgs, this);
5408
5409 if (count == null) {
5410 StringBundler query = new StringBundler(4);
5411
5412 query.append(_SQL_COUNT_DLFOLDER_WHERE);
5413
5414 query.append(_FINDER_COLUMN_G_P_N_GROUPID_2);
5415
5416 query.append(_FINDER_COLUMN_G_P_N_PARENTFOLDERID_2);
5417
5418 if (name == null) {
5419 query.append(_FINDER_COLUMN_G_P_N_NAME_1);
5420 }
5421 else {
5422 if (name.equals(StringPool.BLANK)) {
5423 query.append(_FINDER_COLUMN_G_P_N_NAME_3);
5424 }
5425 else {
5426 query.append(_FINDER_COLUMN_G_P_N_NAME_2);
5427 }
5428 }
5429
5430 String sql = query.toString();
5431
5432 Session session = null;
5433
5434 try {
5435 session = openSession();
5436
5437 Query q = session.createQuery(sql);
5438
5439 QueryPos qPos = QueryPos.getInstance(q);
5440
5441 qPos.add(groupId);
5442
5443 qPos.add(parentFolderId);
5444
5445 if (name != null) {
5446 qPos.add(name);
5447 }
5448
5449 count = (Long)q.uniqueResult();
5450 }
5451 catch (Exception e) {
5452 throw processException(e);
5453 }
5454 finally {
5455 if (count == null) {
5456 count = Long.valueOf(0);
5457 }
5458
5459 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_P_N,
5460 finderArgs, count);
5461
5462 closeSession(session);
5463 }
5464 }
5465
5466 return count.intValue();
5467 }
5468
5469
5475 public int countAll() throws SystemException {
5476 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
5477 FINDER_ARGS_EMPTY, this);
5478
5479 if (count == null) {
5480 Session session = null;
5481
5482 try {
5483 session = openSession();
5484
5485 Query q = session.createQuery(_SQL_COUNT_DLFOLDER);
5486
5487 count = (Long)q.uniqueResult();
5488 }
5489 catch (Exception e) {
5490 throw processException(e);
5491 }
5492 finally {
5493 if (count == null) {
5494 count = Long.valueOf(0);
5495 }
5496
5497 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
5498 FINDER_ARGS_EMPTY, count);
5499
5500 closeSession(session);
5501 }
5502 }
5503
5504 return count.intValue();
5505 }
5506
5507
5514 public List<com.liferay.portlet.documentlibrary.model.DLFileEntryType> getDLFileEntryTypes(
5515 long pk) throws SystemException {
5516 return getDLFileEntryTypes(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
5517 }
5518
5519
5532 public List<com.liferay.portlet.documentlibrary.model.DLFileEntryType> getDLFileEntryTypes(
5533 long pk, int start, int end) throws SystemException {
5534 return getDLFileEntryTypes(pk, start, end, null);
5535 }
5536
5537 public static final FinderPath FINDER_PATH_GET_DLFILEENTRYTYPES = new FinderPath(com.liferay.portlet.documentlibrary.model.impl.DLFileEntryTypeModelImpl.ENTITY_CACHE_ENABLED,
5538 DLFolderModelImpl.FINDER_CACHE_ENABLED_DLFILEENTRYTYPES_DLFOLDERS,
5539 com.liferay.portlet.documentlibrary.model.impl.DLFileEntryTypeImpl.class,
5540 DLFolderModelImpl.MAPPING_TABLE_DLFILEENTRYTYPES_DLFOLDERS_NAME,
5541 "getDLFileEntryTypes",
5542 new String[] {
5543 Long.class.getName(), "java.lang.Integer", "java.lang.Integer",
5544 "com.liferay.portal.kernel.util.OrderByComparator"
5545 });
5546
5547
5561 public List<com.liferay.portlet.documentlibrary.model.DLFileEntryType> getDLFileEntryTypes(
5562 long pk, int start, int end, OrderByComparator orderByComparator)
5563 throws SystemException {
5564 Object[] finderArgs = new Object[] { pk, start, end, orderByComparator };
5565
5566 List<com.liferay.portlet.documentlibrary.model.DLFileEntryType> list = (List<com.liferay.portlet.documentlibrary.model.DLFileEntryType>)FinderCacheUtil.getResult(FINDER_PATH_GET_DLFILEENTRYTYPES,
5567 finderArgs, this);
5568
5569 if (list == null) {
5570 Session session = null;
5571
5572 try {
5573 session = openSession();
5574
5575 String sql = null;
5576
5577 if (orderByComparator != null) {
5578 sql = _SQL_GETDLFILEENTRYTYPES.concat(ORDER_BY_CLAUSE)
5579 .concat(orderByComparator.getOrderBy());
5580 }
5581 else {
5582 sql = _SQL_GETDLFILEENTRYTYPES;
5583 }
5584
5585 SQLQuery q = session.createSQLQuery(sql);
5586
5587 q.addEntity("DLFileEntryType",
5588 com.liferay.portlet.documentlibrary.model.impl.DLFileEntryTypeImpl.class);
5589
5590 QueryPos qPos = QueryPos.getInstance(q);
5591
5592 qPos.add(pk);
5593
5594 list = (List<com.liferay.portlet.documentlibrary.model.DLFileEntryType>)QueryUtil.list(q,
5595 getDialect(), start, end);
5596 }
5597 catch (Exception e) {
5598 throw processException(e);
5599 }
5600 finally {
5601 if (list == null) {
5602 FinderCacheUtil.removeResult(FINDER_PATH_GET_DLFILEENTRYTYPES,
5603 finderArgs);
5604 }
5605 else {
5606 dlFileEntryTypePersistence.cacheResult(list);
5607
5608 FinderCacheUtil.putResult(FINDER_PATH_GET_DLFILEENTRYTYPES,
5609 finderArgs, list);
5610 }
5611
5612 closeSession(session);
5613 }
5614 }
5615
5616 return list;
5617 }
5618
5619 public static final FinderPath FINDER_PATH_GET_DLFILEENTRYTYPES_SIZE = new FinderPath(com.liferay.portlet.documentlibrary.model.impl.DLFileEntryTypeModelImpl.ENTITY_CACHE_ENABLED,
5620 DLFolderModelImpl.FINDER_CACHE_ENABLED_DLFILEENTRYTYPES_DLFOLDERS,
5621 Long.class,
5622 DLFolderModelImpl.MAPPING_TABLE_DLFILEENTRYTYPES_DLFOLDERS_NAME,
5623 "getDLFileEntryTypesSize", new String[] { Long.class.getName() });
5624
5625
5632 public int getDLFileEntryTypesSize(long pk) throws SystemException {
5633 Object[] finderArgs = new Object[] { pk };
5634
5635 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_GET_DLFILEENTRYTYPES_SIZE,
5636 finderArgs, this);
5637
5638 if (count == null) {
5639 Session session = null;
5640
5641 try {
5642 session = openSession();
5643
5644 SQLQuery q = session.createSQLQuery(_SQL_GETDLFILEENTRYTYPESSIZE);
5645
5646 q.addScalar(COUNT_COLUMN_NAME,
5647 com.liferay.portal.kernel.dao.orm.Type.LONG);
5648
5649 QueryPos qPos = QueryPos.getInstance(q);
5650
5651 qPos.add(pk);
5652
5653 count = (Long)q.uniqueResult();
5654 }
5655 catch (Exception e) {
5656 throw processException(e);
5657 }
5658 finally {
5659 if (count == null) {
5660 count = Long.valueOf(0);
5661 }
5662
5663 FinderCacheUtil.putResult(FINDER_PATH_GET_DLFILEENTRYTYPES_SIZE,
5664 finderArgs, count);
5665
5666 closeSession(session);
5667 }
5668 }
5669
5670 return count.intValue();
5671 }
5672
5673 public static final FinderPath FINDER_PATH_CONTAINS_DLFILEENTRYTYPE = new FinderPath(com.liferay.portlet.documentlibrary.model.impl.DLFileEntryTypeModelImpl.ENTITY_CACHE_ENABLED,
5674 DLFolderModelImpl.FINDER_CACHE_ENABLED_DLFILEENTRYTYPES_DLFOLDERS,
5675 Boolean.class,
5676 DLFolderModelImpl.MAPPING_TABLE_DLFILEENTRYTYPES_DLFOLDERS_NAME,
5677 "containsDLFileEntryType",
5678 new String[] { Long.class.getName(), Long.class.getName() });
5679
5680
5688 public boolean containsDLFileEntryType(long pk, long dlFileEntryTypePK)
5689 throws SystemException {
5690 Object[] finderArgs = new Object[] { pk, dlFileEntryTypePK };
5691
5692 Boolean value = (Boolean)FinderCacheUtil.getResult(FINDER_PATH_CONTAINS_DLFILEENTRYTYPE,
5693 finderArgs, this);
5694
5695 if (value == null) {
5696 try {
5697 value = Boolean.valueOf(containsDLFileEntryType.contains(pk,
5698 dlFileEntryTypePK));
5699 }
5700 catch (Exception e) {
5701 throw processException(e);
5702 }
5703 finally {
5704 if (value == null) {
5705 value = Boolean.FALSE;
5706 }
5707
5708 FinderCacheUtil.putResult(FINDER_PATH_CONTAINS_DLFILEENTRYTYPE,
5709 finderArgs, value);
5710 }
5711 }
5712
5713 return value.booleanValue();
5714 }
5715
5716
5723 public boolean containsDLFileEntryTypes(long pk) throws SystemException {
5724 if (getDLFileEntryTypesSize(pk) > 0) {
5725 return true;
5726 }
5727 else {
5728 return false;
5729 }
5730 }
5731
5732
5739 public void addDLFileEntryType(long pk, long dlFileEntryTypePK)
5740 throws SystemException {
5741 try {
5742 addDLFileEntryType.add(pk, dlFileEntryTypePK);
5743 }
5744 catch (Exception e) {
5745 throw processException(e);
5746 }
5747 finally {
5748 FinderCacheUtil.clearCache(DLFolderModelImpl.MAPPING_TABLE_DLFILEENTRYTYPES_DLFOLDERS_NAME);
5749 }
5750 }
5751
5752
5759 public void addDLFileEntryType(long pk,
5760 com.liferay.portlet.documentlibrary.model.DLFileEntryType dlFileEntryType)
5761 throws SystemException {
5762 try {
5763 addDLFileEntryType.add(pk, dlFileEntryType.getPrimaryKey());
5764 }
5765 catch (Exception e) {
5766 throw processException(e);
5767 }
5768 finally {
5769 FinderCacheUtil.clearCache(DLFolderModelImpl.MAPPING_TABLE_DLFILEENTRYTYPES_DLFOLDERS_NAME);
5770 }
5771 }
5772
5773
5780 public void addDLFileEntryTypes(long pk, long[] dlFileEntryTypePKs)
5781 throws SystemException {
5782 try {
5783 for (long dlFileEntryTypePK : dlFileEntryTypePKs) {
5784 addDLFileEntryType.add(pk, dlFileEntryTypePK);
5785 }
5786 }
5787 catch (Exception e) {
5788 throw processException(e);
5789 }
5790 finally {
5791 FinderCacheUtil.clearCache(DLFolderModelImpl.MAPPING_TABLE_DLFILEENTRYTYPES_DLFOLDERS_NAME);
5792 }
5793 }
5794
5795
5802 public void addDLFileEntryTypes(long pk,
5803 List<com.liferay.portlet.documentlibrary.model.DLFileEntryType> dlFileEntryTypes)
5804 throws SystemException {
5805 try {
5806 for (com.liferay.portlet.documentlibrary.model.DLFileEntryType dlFileEntryType : dlFileEntryTypes) {
5807 addDLFileEntryType.add(pk, dlFileEntryType.getPrimaryKey());
5808 }
5809 }
5810 catch (Exception e) {
5811 throw processException(e);
5812 }
5813 finally {
5814 FinderCacheUtil.clearCache(DLFolderModelImpl.MAPPING_TABLE_DLFILEENTRYTYPES_DLFOLDERS_NAME);
5815 }
5816 }
5817
5818
5824 public void clearDLFileEntryTypes(long pk) throws SystemException {
5825 try {
5826 clearDLFileEntryTypes.clear(pk);
5827 }
5828 catch (Exception e) {
5829 throw processException(e);
5830 }
5831 finally {
5832 FinderCacheUtil.clearCache(DLFolderModelImpl.MAPPING_TABLE_DLFILEENTRYTYPES_DLFOLDERS_NAME);
5833 }
5834 }
5835
5836
5843 public void removeDLFileEntryType(long pk, long dlFileEntryTypePK)
5844 throws SystemException {
5845 try {
5846 removeDLFileEntryType.remove(pk, dlFileEntryTypePK);
5847 }
5848 catch (Exception e) {
5849 throw processException(e);
5850 }
5851 finally {
5852 FinderCacheUtil.clearCache(DLFolderModelImpl.MAPPING_TABLE_DLFILEENTRYTYPES_DLFOLDERS_NAME);
5853 }
5854 }
5855
5856
5863 public void removeDLFileEntryType(long pk,
5864 com.liferay.portlet.documentlibrary.model.DLFileEntryType dlFileEntryType)
5865 throws SystemException {
5866 try {
5867 removeDLFileEntryType.remove(pk, dlFileEntryType.getPrimaryKey());
5868 }
5869 catch (Exception e) {
5870 throw processException(e);
5871 }
5872 finally {
5873 FinderCacheUtil.clearCache(DLFolderModelImpl.MAPPING_TABLE_DLFILEENTRYTYPES_DLFOLDERS_NAME);
5874 }
5875 }
5876
5877
5884 public void removeDLFileEntryTypes(long pk, long[] dlFileEntryTypePKs)
5885 throws SystemException {
5886 try {
5887 for (long dlFileEntryTypePK : dlFileEntryTypePKs) {
5888 removeDLFileEntryType.remove(pk, dlFileEntryTypePK);
5889 }
5890 }
5891 catch (Exception e) {
5892 throw processException(e);
5893 }
5894 finally {
5895 FinderCacheUtil.clearCache(DLFolderModelImpl.MAPPING_TABLE_DLFILEENTRYTYPES_DLFOLDERS_NAME);
5896 }
5897 }
5898
5899
5906 public void removeDLFileEntryTypes(long pk,
5907 List<com.liferay.portlet.documentlibrary.model.DLFileEntryType> dlFileEntryTypes)
5908 throws SystemException {
5909 try {
5910 for (com.liferay.portlet.documentlibrary.model.DLFileEntryType dlFileEntryType : dlFileEntryTypes) {
5911 removeDLFileEntryType.remove(pk, dlFileEntryType.getPrimaryKey());
5912 }
5913 }
5914 catch (Exception e) {
5915 throw processException(e);
5916 }
5917 finally {
5918 FinderCacheUtil.clearCache(DLFolderModelImpl.MAPPING_TABLE_DLFILEENTRYTYPES_DLFOLDERS_NAME);
5919 }
5920 }
5921
5922
5929 public void setDLFileEntryTypes(long pk, long[] dlFileEntryTypePKs)
5930 throws SystemException {
5931 try {
5932 Set<Long> dlFileEntryTypePKSet = SetUtil.fromArray(dlFileEntryTypePKs);
5933
5934 List<com.liferay.portlet.documentlibrary.model.DLFileEntryType> dlFileEntryTypes =
5935 getDLFileEntryTypes(pk);
5936
5937 for (com.liferay.portlet.documentlibrary.model.DLFileEntryType dlFileEntryType : dlFileEntryTypes) {
5938 if (!dlFileEntryTypePKSet.remove(
5939 dlFileEntryType.getPrimaryKey())) {
5940 removeDLFileEntryType.remove(pk,
5941 dlFileEntryType.getPrimaryKey());
5942 }
5943 }
5944
5945 for (Long dlFileEntryTypePK : dlFileEntryTypePKSet) {
5946 addDLFileEntryType.add(pk, dlFileEntryTypePK);
5947 }
5948 }
5949 catch (Exception e) {
5950 throw processException(e);
5951 }
5952 finally {
5953 FinderCacheUtil.clearCache(DLFolderModelImpl.MAPPING_TABLE_DLFILEENTRYTYPES_DLFOLDERS_NAME);
5954 }
5955 }
5956
5957
5964 public void setDLFileEntryTypes(long pk,
5965 List<com.liferay.portlet.documentlibrary.model.DLFileEntryType> dlFileEntryTypes)
5966 throws SystemException {
5967 try {
5968 long[] dlFileEntryTypePKs = new long[dlFileEntryTypes.size()];
5969
5970 for (int i = 0; i < dlFileEntryTypes.size(); i++) {
5971 com.liferay.portlet.documentlibrary.model.DLFileEntryType dlFileEntryType =
5972 dlFileEntryTypes.get(i);
5973
5974 dlFileEntryTypePKs[i] = dlFileEntryType.getPrimaryKey();
5975 }
5976
5977 setDLFileEntryTypes(pk, dlFileEntryTypePKs);
5978 }
5979 catch (Exception e) {
5980 throw processException(e);
5981 }
5982 finally {
5983 FinderCacheUtil.clearCache(DLFolderModelImpl.MAPPING_TABLE_DLFILEENTRYTYPES_DLFOLDERS_NAME);
5984 }
5985 }
5986
5987
5990 public void afterPropertiesSet() {
5991 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
5992 com.liferay.portal.util.PropsUtil.get(
5993 "value.object.listener.com.liferay.portlet.documentlibrary.model.DLFolder")));
5994
5995 if (listenerClassNames.length > 0) {
5996 try {
5997 List<ModelListener<DLFolder>> listenersList = new ArrayList<ModelListener<DLFolder>>();
5998
5999 for (String listenerClassName : listenerClassNames) {
6000 listenersList.add((ModelListener<DLFolder>)InstanceFactory.newInstance(
6001 listenerClassName));
6002 }
6003
6004 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
6005 }
6006 catch (Exception e) {
6007 _log.error(e);
6008 }
6009 }
6010
6011 containsDLFileEntryType = new ContainsDLFileEntryType();
6012
6013 addDLFileEntryType = new AddDLFileEntryType();
6014 clearDLFileEntryTypes = new ClearDLFileEntryTypes();
6015 removeDLFileEntryType = new RemoveDLFileEntryType();
6016 }
6017
6018 public void destroy() {
6019 EntityCacheUtil.removeCache(DLFolderImpl.class.getName());
6020 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
6021 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
6022 }
6023
6024 @BeanReference(type = DLContentPersistence.class)
6025 protected DLContentPersistence dlContentPersistence;
6026 @BeanReference(type = DLFileEntryPersistence.class)
6027 protected DLFileEntryPersistence dlFileEntryPersistence;
6028 @BeanReference(type = DLFileEntryMetadataPersistence.class)
6029 protected DLFileEntryMetadataPersistence dlFileEntryMetadataPersistence;
6030 @BeanReference(type = DLFileEntryTypePersistence.class)
6031 protected DLFileEntryTypePersistence dlFileEntryTypePersistence;
6032 @BeanReference(type = DLFileRankPersistence.class)
6033 protected DLFileRankPersistence dlFileRankPersistence;
6034 @BeanReference(type = DLFileShortcutPersistence.class)
6035 protected DLFileShortcutPersistence dlFileShortcutPersistence;
6036 @BeanReference(type = DLFileVersionPersistence.class)
6037 protected DLFileVersionPersistence dlFileVersionPersistence;
6038 @BeanReference(type = DLFolderPersistence.class)
6039 protected DLFolderPersistence dlFolderPersistence;
6040 @BeanReference(type = DLSyncPersistence.class)
6041 protected DLSyncPersistence dlSyncPersistence;
6042 @BeanReference(type = GroupPersistence.class)
6043 protected GroupPersistence groupPersistence;
6044 @BeanReference(type = LockPersistence.class)
6045 protected LockPersistence lockPersistence;
6046 @BeanReference(type = ResourcePersistence.class)
6047 protected ResourcePersistence resourcePersistence;
6048 @BeanReference(type = UserPersistence.class)
6049 protected UserPersistence userPersistence;
6050 @BeanReference(type = WebDAVPropsPersistence.class)
6051 protected WebDAVPropsPersistence webDAVPropsPersistence;
6052 @BeanReference(type = WorkflowDefinitionLinkPersistence.class)
6053 protected WorkflowDefinitionLinkPersistence workflowDefinitionLinkPersistence;
6054 @BeanReference(type = WorkflowInstanceLinkPersistence.class)
6055 protected WorkflowInstanceLinkPersistence workflowInstanceLinkPersistence;
6056 @BeanReference(type = ExpandoValuePersistence.class)
6057 protected ExpandoValuePersistence expandoValuePersistence;
6058 protected ContainsDLFileEntryType containsDLFileEntryType;
6059 protected AddDLFileEntryType addDLFileEntryType;
6060 protected ClearDLFileEntryTypes clearDLFileEntryTypes;
6061 protected RemoveDLFileEntryType removeDLFileEntryType;
6062
6063 protected class ContainsDLFileEntryType {
6064 protected ContainsDLFileEntryType() {
6065 _mappingSqlQuery = MappingSqlQueryFactoryUtil.getMappingSqlQuery(getDataSource(),
6066 _SQL_CONTAINSDLFILEENTRYTYPE,
6067 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT },
6068 RowMapper.COUNT);
6069 }
6070
6071 protected boolean contains(long folderId, long fileEntryTypeId) {
6072 List<Integer> results = _mappingSqlQuery.execute(new Object[] {
6073 new Long(folderId), new Long(fileEntryTypeId)
6074 });
6075
6076 if (results.size() > 0) {
6077 Integer count = results.get(0);
6078
6079 if (count.intValue() > 0) {
6080 return true;
6081 }
6082 }
6083
6084 return false;
6085 }
6086
6087 private MappingSqlQuery<Integer> _mappingSqlQuery;
6088 }
6089
6090 protected class AddDLFileEntryType {
6091 protected AddDLFileEntryType() {
6092 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
6093 "INSERT INTO DLFileEntryTypes_DLFolders (folderId, fileEntryTypeId) VALUES (?, ?)",
6094 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
6095 }
6096
6097 protected void add(long folderId, long fileEntryTypeId)
6098 throws SystemException {
6099 if (!containsDLFileEntryType.contains(folderId, fileEntryTypeId)) {
6100 ModelListener<com.liferay.portlet.documentlibrary.model.DLFileEntryType>[] dlFileEntryTypeListeners =
6101 dlFileEntryTypePersistence.getListeners();
6102
6103 for (ModelListener<DLFolder> listener : listeners) {
6104 listener.onBeforeAddAssociation(folderId,
6105 com.liferay.portlet.documentlibrary.model.DLFileEntryType.class.getName(),
6106 fileEntryTypeId);
6107 }
6108
6109 for (ModelListener<com.liferay.portlet.documentlibrary.model.DLFileEntryType> listener : dlFileEntryTypeListeners) {
6110 listener.onBeforeAddAssociation(fileEntryTypeId,
6111 DLFolder.class.getName(), folderId);
6112 }
6113
6114 _sqlUpdate.update(new Object[] {
6115 new Long(folderId), new Long(fileEntryTypeId)
6116 });
6117
6118 for (ModelListener<DLFolder> listener : listeners) {
6119 listener.onAfterAddAssociation(folderId,
6120 com.liferay.portlet.documentlibrary.model.DLFileEntryType.class.getName(),
6121 fileEntryTypeId);
6122 }
6123
6124 for (ModelListener<com.liferay.portlet.documentlibrary.model.DLFileEntryType> listener : dlFileEntryTypeListeners) {
6125 listener.onAfterAddAssociation(fileEntryTypeId,
6126 DLFolder.class.getName(), folderId);
6127 }
6128 }
6129 }
6130
6131 private SqlUpdate _sqlUpdate;
6132 }
6133
6134 protected class ClearDLFileEntryTypes {
6135 protected ClearDLFileEntryTypes() {
6136 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
6137 "DELETE FROM DLFileEntryTypes_DLFolders WHERE folderId = ?",
6138 new int[] { java.sql.Types.BIGINT });
6139 }
6140
6141 protected void clear(long folderId) throws SystemException {
6142 ModelListener<com.liferay.portlet.documentlibrary.model.DLFileEntryType>[] dlFileEntryTypeListeners =
6143 dlFileEntryTypePersistence.getListeners();
6144
6145 List<com.liferay.portlet.documentlibrary.model.DLFileEntryType> dlFileEntryTypes =
6146 null;
6147
6148 if ((listeners.length > 0) ||
6149 (dlFileEntryTypeListeners.length > 0)) {
6150 dlFileEntryTypes = getDLFileEntryTypes(folderId);
6151
6152 for (com.liferay.portlet.documentlibrary.model.DLFileEntryType dlFileEntryType : dlFileEntryTypes) {
6153 for (ModelListener<DLFolder> listener : listeners) {
6154 listener.onBeforeRemoveAssociation(folderId,
6155 com.liferay.portlet.documentlibrary.model.DLFileEntryType.class.getName(),
6156 dlFileEntryType.getPrimaryKey());
6157 }
6158
6159 for (ModelListener<com.liferay.portlet.documentlibrary.model.DLFileEntryType> listener : dlFileEntryTypeListeners) {
6160 listener.onBeforeRemoveAssociation(dlFileEntryType.getPrimaryKey(),
6161 DLFolder.class.getName(), folderId);
6162 }
6163 }
6164 }
6165
6166 _sqlUpdate.update(new Object[] { new Long(folderId) });
6167
6168 if ((listeners.length > 0) ||
6169 (dlFileEntryTypeListeners.length > 0)) {
6170 for (com.liferay.portlet.documentlibrary.model.DLFileEntryType dlFileEntryType : dlFileEntryTypes) {
6171 for (ModelListener<DLFolder> listener : listeners) {
6172 listener.onAfterRemoveAssociation(folderId,
6173 com.liferay.portlet.documentlibrary.model.DLFileEntryType.class.getName(),
6174 dlFileEntryType.getPrimaryKey());
6175 }
6176
6177 for (ModelListener<com.liferay.portlet.documentlibrary.model.DLFileEntryType> listener : dlFileEntryTypeListeners) {
6178 listener.onAfterRemoveAssociation(dlFileEntryType.getPrimaryKey(),
6179 DLFolder.class.getName(), folderId);
6180 }
6181 }
6182 }
6183 }
6184
6185 private SqlUpdate _sqlUpdate;
6186 }
6187
6188 protected class RemoveDLFileEntryType {
6189 protected RemoveDLFileEntryType() {
6190 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
6191 "DELETE FROM DLFileEntryTypes_DLFolders WHERE folderId = ? AND fileEntryTypeId = ?",
6192 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
6193 }
6194
6195 protected void remove(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.onBeforeRemoveAssociation(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.onBeforeRemoveAssociation(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.onAfterRemoveAssociation(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.onAfterRemoveAssociation(fileEntryTypeId,
6224 DLFolder.class.getName(), folderId);
6225 }
6226 }
6227 }
6228
6229 private SqlUpdate _sqlUpdate;
6230 }
6231
6232 private static final String _SQL_SELECT_DLFOLDER = "SELECT dlFolder FROM DLFolder dlFolder";
6233 private static final String _SQL_SELECT_DLFOLDER_WHERE = "SELECT dlFolder FROM DLFolder dlFolder WHERE ";
6234 private static final String _SQL_COUNT_DLFOLDER = "SELECT COUNT(dlFolder) FROM DLFolder dlFolder";
6235 private static final String _SQL_COUNT_DLFOLDER_WHERE = "SELECT COUNT(dlFolder) FROM DLFolder dlFolder WHERE ";
6236 private static final String _SQL_GETDLFILEENTRYTYPES = "SELECT {DLFileEntryType.*} FROM DLFileEntryType INNER JOIN DLFileEntryTypes_DLFolders ON (DLFileEntryTypes_DLFolders.fileEntryTypeId = DLFileEntryType.fileEntryTypeId) WHERE (DLFileEntryTypes_DLFolders.folderId = ?)";
6237 private static final String _SQL_GETDLFILEENTRYTYPESSIZE = "SELECT COUNT(*) AS COUNT_VALUE FROM DLFileEntryTypes_DLFolders WHERE folderId = ?";
6238 private static final String _SQL_CONTAINSDLFILEENTRYTYPE = "SELECT COUNT(*) AS COUNT_VALUE FROM DLFileEntryTypes_DLFolders WHERE folderId = ? AND fileEntryTypeId = ?";
6239 private static final String _FINDER_COLUMN_UUID_UUID_1 = "dlFolder.uuid IS NULL";
6240 private static final String _FINDER_COLUMN_UUID_UUID_2 = "dlFolder.uuid = ?";
6241 private static final String _FINDER_COLUMN_UUID_UUID_3 = "(dlFolder.uuid IS NULL OR dlFolder.uuid = ?)";
6242 private static final String _FINDER_COLUMN_UUID_G_UUID_1 = "dlFolder.uuid IS NULL AND ";
6243 private static final String _FINDER_COLUMN_UUID_G_UUID_2 = "dlFolder.uuid = ? AND ";
6244 private static final String _FINDER_COLUMN_UUID_G_UUID_3 = "(dlFolder.uuid IS NULL OR dlFolder.uuid = ?) AND ";
6245 private static final String _FINDER_COLUMN_UUID_G_GROUPID_2 = "dlFolder.groupId = ?";
6246 private static final String _FINDER_COLUMN_GROUPID_GROUPID_2 = "dlFolder.groupId = ?";
6247 private static final String _FINDER_COLUMN_COMPANYID_COMPANYID_2 = "dlFolder.companyId = ?";
6248 private static final String _FINDER_COLUMN_REPOSITORYID_REPOSITORYID_2 = "dlFolder.repositoryId = ?";
6249 private static final String _FINDER_COLUMN_G_P_GROUPID_2 = "dlFolder.groupId = ? AND ";
6250 private static final String _FINDER_COLUMN_G_P_PARENTFOLDERID_2 = "dlFolder.parentFolderId = ?";
6251 private static final String _FINDER_COLUMN_P_N_PARENTFOLDERID_2 = "dlFolder.parentFolderId = ? AND ";
6252 private static final String _FINDER_COLUMN_P_N_NAME_1 = "dlFolder.name IS NULL";
6253 private static final String _FINDER_COLUMN_P_N_NAME_2 = "dlFolder.name = ?";
6254 private static final String _FINDER_COLUMN_P_N_NAME_3 = "(dlFolder.name IS NULL OR dlFolder.name = ?)";
6255 private static final String _FINDER_COLUMN_G_P_M_GROUPID_2 = "dlFolder.groupId = ? AND ";
6256 private static final String _FINDER_COLUMN_G_P_M_PARENTFOLDERID_2 = "dlFolder.parentFolderId = ? AND ";
6257 private static final String _FINDER_COLUMN_G_P_M_MOUNTPOINT_2 = "dlFolder.mountPoint = ?";
6258 private static final String _FINDER_COLUMN_G_P_N_GROUPID_2 = "dlFolder.groupId = ? AND ";
6259 private static final String _FINDER_COLUMN_G_P_N_PARENTFOLDERID_2 = "dlFolder.parentFolderId = ? AND ";
6260 private static final String _FINDER_COLUMN_G_P_N_NAME_1 = "dlFolder.name IS NULL";
6261 private static final String _FINDER_COLUMN_G_P_N_NAME_2 = "dlFolder.name = ?";
6262 private static final String _FINDER_COLUMN_G_P_N_NAME_3 = "(dlFolder.name IS NULL OR dlFolder.name = ?)";
6263 private static final String _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN = "dlFolder.folderId";
6264 private static final String _FILTER_SQL_SELECT_DLFOLDER_WHERE = "SELECT DISTINCT {dlFolder.*} FROM DLFolder dlFolder WHERE ";
6265 private static final String _FILTER_SQL_SELECT_DLFOLDER_NO_INLINE_DISTINCT_WHERE_1 =
6266 "SELECT {DLFolder.*} FROM (SELECT DISTINCT dlFolder.folderId FROM DLFolder dlFolder WHERE ";
6267 private static final String _FILTER_SQL_SELECT_DLFOLDER_NO_INLINE_DISTINCT_WHERE_2 =
6268 ") TEMP_TABLE INNER JOIN DLFolder ON TEMP_TABLE.folderId = DLFolder.folderId";
6269 private static final String _FILTER_SQL_COUNT_DLFOLDER_WHERE = "SELECT COUNT(DISTINCT dlFolder.folderId) AS COUNT_VALUE FROM DLFolder dlFolder WHERE ";
6270 private static final String _FILTER_ENTITY_ALIAS = "dlFolder";
6271 private static final String _FILTER_ENTITY_TABLE = "DLFolder";
6272 private static final String _ORDER_BY_ENTITY_ALIAS = "dlFolder.";
6273 private static final String _ORDER_BY_ENTITY_TABLE = "DLFolder.";
6274 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No DLFolder exists with the primary key ";
6275 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No DLFolder exists with the key {";
6276 private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
6277 private static Log _log = LogFactoryUtil.getLog(DLFolderPersistenceImpl.class);
6278 private static DLFolder _nullDLFolder = new DLFolderImpl() {
6279 @Override
6280 public Object clone() {
6281 return this;
6282 }
6283
6284 @Override
6285 public CacheModel<DLFolder> toCacheModel() {
6286 return _nullDLFolderCacheModel;
6287 }
6288 };
6289
6290 private static CacheModel<DLFolder> _nullDLFolderCacheModel = new CacheModel<DLFolder>() {
6291 public DLFolder toEntityModel() {
6292 return _nullDLFolder;
6293 }
6294 };
6295 }