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.ResourcePersistence;
050 import com.liferay.portal.service.persistence.UserPersistence;
051 import com.liferay.portal.service.persistence.WorkflowDefinitionLinkPersistence;
052 import com.liferay.portal.service.persistence.WorkflowInstanceLinkPersistence;
053 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
054
055 import com.liferay.portlet.documentlibrary.NoSuchFileEntryTypeException;
056 import com.liferay.portlet.documentlibrary.model.DLFileEntryType;
057 import com.liferay.portlet.documentlibrary.model.impl.DLFileEntryTypeImpl;
058 import com.liferay.portlet.documentlibrary.model.impl.DLFileEntryTypeModelImpl;
059 import com.liferay.portlet.dynamicdatamapping.service.persistence.DDMStructurePersistence;
060
061 import java.io.Serializable;
062
063 import java.util.ArrayList;
064 import java.util.Collections;
065 import java.util.List;
066 import java.util.Set;
067
068
080 public class DLFileEntryTypePersistenceImpl extends BasePersistenceImpl<DLFileEntryType>
081 implements DLFileEntryTypePersistence {
082
087 public static final String FINDER_CLASS_NAME_ENTITY = DLFileEntryTypeImpl.class.getName();
088 public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
089 ".List1";
090 public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
091 ".List2";
092 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID = new FinderPath(DLFileEntryTypeModelImpl.ENTITY_CACHE_ENABLED,
093 DLFileEntryTypeModelImpl.FINDER_CACHE_ENABLED,
094 DLFileEntryTypeImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
095 "findByUuid",
096 new String[] {
097 String.class.getName(),
098
099 "java.lang.Integer", "java.lang.Integer",
100 "com.liferay.portal.kernel.util.OrderByComparator"
101 });
102 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID = new FinderPath(DLFileEntryTypeModelImpl.ENTITY_CACHE_ENABLED,
103 DLFileEntryTypeModelImpl.FINDER_CACHE_ENABLED,
104 DLFileEntryTypeImpl.class,
105 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid",
106 new String[] { String.class.getName() },
107 DLFileEntryTypeModelImpl.UUID_COLUMN_BITMASK);
108 public static final FinderPath FINDER_PATH_COUNT_BY_UUID = new FinderPath(DLFileEntryTypeModelImpl.ENTITY_CACHE_ENABLED,
109 DLFileEntryTypeModelImpl.FINDER_CACHE_ENABLED, Long.class,
110 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid",
111 new String[] { String.class.getName() });
112 public static final FinderPath FINDER_PATH_FETCH_BY_UUID_G = new FinderPath(DLFileEntryTypeModelImpl.ENTITY_CACHE_ENABLED,
113 DLFileEntryTypeModelImpl.FINDER_CACHE_ENABLED,
114 DLFileEntryTypeImpl.class, FINDER_CLASS_NAME_ENTITY,
115 "fetchByUUID_G",
116 new String[] { String.class.getName(), Long.class.getName() },
117 DLFileEntryTypeModelImpl.UUID_COLUMN_BITMASK |
118 DLFileEntryTypeModelImpl.GROUPID_COLUMN_BITMASK);
119 public static final FinderPath FINDER_PATH_COUNT_BY_UUID_G = new FinderPath(DLFileEntryTypeModelImpl.ENTITY_CACHE_ENABLED,
120 DLFileEntryTypeModelImpl.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(DLFileEntryTypeModelImpl.ENTITY_CACHE_ENABLED,
124 DLFileEntryTypeModelImpl.FINDER_CACHE_ENABLED,
125 DLFileEntryTypeImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
126 "findByGroupId",
127 new String[] {
128 Long.class.getName(),
129
130 "java.lang.Integer", "java.lang.Integer",
131 "com.liferay.portal.kernel.util.OrderByComparator"
132 });
133 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID =
134 new FinderPath(DLFileEntryTypeModelImpl.ENTITY_CACHE_ENABLED,
135 DLFileEntryTypeModelImpl.FINDER_CACHE_ENABLED,
136 DLFileEntryTypeImpl.class,
137 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByGroupId",
138 new String[] { Long.class.getName() },
139 DLFileEntryTypeModelImpl.GROUPID_COLUMN_BITMASK);
140 public static final FinderPath FINDER_PATH_COUNT_BY_GROUPID = new FinderPath(DLFileEntryTypeModelImpl.ENTITY_CACHE_ENABLED,
141 DLFileEntryTypeModelImpl.FINDER_CACHE_ENABLED, Long.class,
142 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByGroupId",
143 new String[] { Long.class.getName() });
144 public static final FinderPath FINDER_PATH_FETCH_BY_G_N = new FinderPath(DLFileEntryTypeModelImpl.ENTITY_CACHE_ENABLED,
145 DLFileEntryTypeModelImpl.FINDER_CACHE_ENABLED,
146 DLFileEntryTypeImpl.class, FINDER_CLASS_NAME_ENTITY, "fetchByG_N",
147 new String[] { Long.class.getName(), String.class.getName() },
148 DLFileEntryTypeModelImpl.GROUPID_COLUMN_BITMASK |
149 DLFileEntryTypeModelImpl.NAME_COLUMN_BITMASK);
150 public static final FinderPath FINDER_PATH_COUNT_BY_G_N = new FinderPath(DLFileEntryTypeModelImpl.ENTITY_CACHE_ENABLED,
151 DLFileEntryTypeModelImpl.FINDER_CACHE_ENABLED, Long.class,
152 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_N",
153 new String[] { Long.class.getName(), String.class.getName() });
154 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(DLFileEntryTypeModelImpl.ENTITY_CACHE_ENABLED,
155 DLFileEntryTypeModelImpl.FINDER_CACHE_ENABLED,
156 DLFileEntryTypeImpl.class,
157 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
158 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(DLFileEntryTypeModelImpl.ENTITY_CACHE_ENABLED,
159 DLFileEntryTypeModelImpl.FINDER_CACHE_ENABLED,
160 DLFileEntryTypeImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
161 "findAll", new String[0]);
162 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(DLFileEntryTypeModelImpl.ENTITY_CACHE_ENABLED,
163 DLFileEntryTypeModelImpl.FINDER_CACHE_ENABLED, Long.class,
164 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
165
166
171 public void cacheResult(DLFileEntryType dlFileEntryType) {
172 EntityCacheUtil.putResult(DLFileEntryTypeModelImpl.ENTITY_CACHE_ENABLED,
173 DLFileEntryTypeImpl.class, dlFileEntryType.getPrimaryKey(),
174 dlFileEntryType);
175
176 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
177 new Object[] {
178 dlFileEntryType.getUuid(),
179 Long.valueOf(dlFileEntryType.getGroupId())
180 }, dlFileEntryType);
181
182 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_N,
183 new Object[] {
184 Long.valueOf(dlFileEntryType.getGroupId()),
185
186 dlFileEntryType.getName()
187 }, dlFileEntryType);
188
189 dlFileEntryType.resetOriginalValues();
190 }
191
192
197 public void cacheResult(List<DLFileEntryType> dlFileEntryTypes) {
198 for (DLFileEntryType dlFileEntryType : dlFileEntryTypes) {
199 if (EntityCacheUtil.getResult(
200 DLFileEntryTypeModelImpl.ENTITY_CACHE_ENABLED,
201 DLFileEntryTypeImpl.class,
202 dlFileEntryType.getPrimaryKey()) == null) {
203 cacheResult(dlFileEntryType);
204 }
205 else {
206 dlFileEntryType.resetOriginalValues();
207 }
208 }
209 }
210
211
218 @Override
219 public void clearCache() {
220 if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
221 CacheRegistryUtil.clear(DLFileEntryTypeImpl.class.getName());
222 }
223
224 EntityCacheUtil.clearCache(DLFileEntryTypeImpl.class.getName());
225
226 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
227 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
228 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
229 }
230
231
238 @Override
239 public void clearCache(DLFileEntryType dlFileEntryType) {
240 EntityCacheUtil.removeResult(DLFileEntryTypeModelImpl.ENTITY_CACHE_ENABLED,
241 DLFileEntryTypeImpl.class, dlFileEntryType.getPrimaryKey());
242
243 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
244 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
245
246 clearUniqueFindersCache(dlFileEntryType);
247 }
248
249 @Override
250 public void clearCache(List<DLFileEntryType> dlFileEntryTypes) {
251 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
252 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
253
254 for (DLFileEntryType dlFileEntryType : dlFileEntryTypes) {
255 EntityCacheUtil.removeResult(DLFileEntryTypeModelImpl.ENTITY_CACHE_ENABLED,
256 DLFileEntryTypeImpl.class, dlFileEntryType.getPrimaryKey());
257
258 clearUniqueFindersCache(dlFileEntryType);
259 }
260 }
261
262 protected void clearUniqueFindersCache(DLFileEntryType dlFileEntryType) {
263 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
264 new Object[] {
265 dlFileEntryType.getUuid(),
266 Long.valueOf(dlFileEntryType.getGroupId())
267 });
268
269 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_N,
270 new Object[] {
271 Long.valueOf(dlFileEntryType.getGroupId()),
272
273 dlFileEntryType.getName()
274 });
275 }
276
277
283 public DLFileEntryType create(long fileEntryTypeId) {
284 DLFileEntryType dlFileEntryType = new DLFileEntryTypeImpl();
285
286 dlFileEntryType.setNew(true);
287 dlFileEntryType.setPrimaryKey(fileEntryTypeId);
288
289 String uuid = PortalUUIDUtil.generate();
290
291 dlFileEntryType.setUuid(uuid);
292
293 return dlFileEntryType;
294 }
295
296
304 public DLFileEntryType remove(long fileEntryTypeId)
305 throws NoSuchFileEntryTypeException, SystemException {
306 return remove(Long.valueOf(fileEntryTypeId));
307 }
308
309
317 @Override
318 public DLFileEntryType remove(Serializable primaryKey)
319 throws NoSuchFileEntryTypeException, SystemException {
320 Session session = null;
321
322 try {
323 session = openSession();
324
325 DLFileEntryType dlFileEntryType = (DLFileEntryType)session.get(DLFileEntryTypeImpl.class,
326 primaryKey);
327
328 if (dlFileEntryType == null) {
329 if (_log.isWarnEnabled()) {
330 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
331 }
332
333 throw new NoSuchFileEntryTypeException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
334 primaryKey);
335 }
336
337 return remove(dlFileEntryType);
338 }
339 catch (NoSuchFileEntryTypeException nsee) {
340 throw nsee;
341 }
342 catch (Exception e) {
343 throw processException(e);
344 }
345 finally {
346 closeSession(session);
347 }
348 }
349
350 @Override
351 protected DLFileEntryType removeImpl(DLFileEntryType dlFileEntryType)
352 throws SystemException {
353 dlFileEntryType = toUnwrappedModel(dlFileEntryType);
354
355 try {
356 clearDLFolders.clear(dlFileEntryType.getPrimaryKey());
357 }
358 catch (Exception e) {
359 throw processException(e);
360 }
361 finally {
362 FinderCacheUtil.clearCache(DLFileEntryTypeModelImpl.MAPPING_TABLE_DLFILEENTRYTYPES_DLFOLDERS_NAME);
363 }
364
365 try {
366 clearDDMStructures.clear(dlFileEntryType.getPrimaryKey());
367 }
368 catch (Exception e) {
369 throw processException(e);
370 }
371 finally {
372 FinderCacheUtil.clearCache(DLFileEntryTypeModelImpl.MAPPING_TABLE_DLFILEENTRYTYPES_DDMSTRUCTURES_NAME);
373 }
374
375 Session session = null;
376
377 try {
378 session = openSession();
379
380 BatchSessionUtil.delete(session, dlFileEntryType);
381 }
382 catch (Exception e) {
383 throw processException(e);
384 }
385 finally {
386 closeSession(session);
387 }
388
389 clearCache(dlFileEntryType);
390
391 return dlFileEntryType;
392 }
393
394 @Override
395 public DLFileEntryType updateImpl(
396 com.liferay.portlet.documentlibrary.model.DLFileEntryType dlFileEntryType,
397 boolean merge) throws SystemException {
398 dlFileEntryType = toUnwrappedModel(dlFileEntryType);
399
400 boolean isNew = dlFileEntryType.isNew();
401
402 DLFileEntryTypeModelImpl dlFileEntryTypeModelImpl = (DLFileEntryTypeModelImpl)dlFileEntryType;
403
404 if (Validator.isNull(dlFileEntryType.getUuid())) {
405 String uuid = PortalUUIDUtil.generate();
406
407 dlFileEntryType.setUuid(uuid);
408 }
409
410 Session session = null;
411
412 try {
413 session = openSession();
414
415 BatchSessionUtil.update(session, dlFileEntryType, merge);
416
417 dlFileEntryType.setNew(false);
418 }
419 catch (Exception e) {
420 throw processException(e);
421 }
422 finally {
423 closeSession(session);
424 }
425
426 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
427
428 if (isNew || !DLFileEntryTypeModelImpl.COLUMN_BITMASK_ENABLED) {
429 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
430 }
431
432 else {
433 if ((dlFileEntryTypeModelImpl.getColumnBitmask() &
434 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID.getColumnBitmask()) != 0) {
435 Object[] args = new Object[] {
436 dlFileEntryTypeModelImpl.getOriginalUuid()
437 };
438
439 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
440 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
441 args);
442
443 args = new Object[] { dlFileEntryTypeModelImpl.getUuid() };
444
445 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
446 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
447 args);
448 }
449
450 if ((dlFileEntryTypeModelImpl.getColumnBitmask() &
451 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID.getColumnBitmask()) != 0) {
452 Object[] args = new Object[] {
453 Long.valueOf(dlFileEntryTypeModelImpl.getOriginalGroupId())
454 };
455
456 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
457 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
458 args);
459
460 args = new Object[] {
461 Long.valueOf(dlFileEntryTypeModelImpl.getGroupId())
462 };
463
464 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
465 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
466 args);
467 }
468 }
469
470 EntityCacheUtil.putResult(DLFileEntryTypeModelImpl.ENTITY_CACHE_ENABLED,
471 DLFileEntryTypeImpl.class, dlFileEntryType.getPrimaryKey(),
472 dlFileEntryType);
473
474 if (isNew) {
475 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
476 new Object[] {
477 dlFileEntryType.getUuid(),
478 Long.valueOf(dlFileEntryType.getGroupId())
479 }, dlFileEntryType);
480
481 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_N,
482 new Object[] {
483 Long.valueOf(dlFileEntryType.getGroupId()),
484
485 dlFileEntryType.getName()
486 }, dlFileEntryType);
487 }
488 else {
489 if ((dlFileEntryTypeModelImpl.getColumnBitmask() &
490 FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) {
491 Object[] args = new Object[] {
492 dlFileEntryTypeModelImpl.getOriginalUuid(),
493 Long.valueOf(dlFileEntryTypeModelImpl.getOriginalGroupId())
494 };
495
496 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args);
497 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args);
498
499 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
500 new Object[] {
501 dlFileEntryType.getUuid(),
502 Long.valueOf(dlFileEntryType.getGroupId())
503 }, dlFileEntryType);
504 }
505
506 if ((dlFileEntryTypeModelImpl.getColumnBitmask() &
507 FINDER_PATH_FETCH_BY_G_N.getColumnBitmask()) != 0) {
508 Object[] args = new Object[] {
509 Long.valueOf(dlFileEntryTypeModelImpl.getOriginalGroupId()),
510
511 dlFileEntryTypeModelImpl.getOriginalName()
512 };
513
514 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_N, args);
515 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_N, args);
516
517 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_N,
518 new Object[] {
519 Long.valueOf(dlFileEntryType.getGroupId()),
520
521 dlFileEntryType.getName()
522 }, dlFileEntryType);
523 }
524 }
525
526 return dlFileEntryType;
527 }
528
529 protected DLFileEntryType toUnwrappedModel(DLFileEntryType dlFileEntryType) {
530 if (dlFileEntryType instanceof DLFileEntryTypeImpl) {
531 return dlFileEntryType;
532 }
533
534 DLFileEntryTypeImpl dlFileEntryTypeImpl = new DLFileEntryTypeImpl();
535
536 dlFileEntryTypeImpl.setNew(dlFileEntryType.isNew());
537 dlFileEntryTypeImpl.setPrimaryKey(dlFileEntryType.getPrimaryKey());
538
539 dlFileEntryTypeImpl.setUuid(dlFileEntryType.getUuid());
540 dlFileEntryTypeImpl.setFileEntryTypeId(dlFileEntryType.getFileEntryTypeId());
541 dlFileEntryTypeImpl.setGroupId(dlFileEntryType.getGroupId());
542 dlFileEntryTypeImpl.setCompanyId(dlFileEntryType.getCompanyId());
543 dlFileEntryTypeImpl.setUserId(dlFileEntryType.getUserId());
544 dlFileEntryTypeImpl.setUserName(dlFileEntryType.getUserName());
545 dlFileEntryTypeImpl.setCreateDate(dlFileEntryType.getCreateDate());
546 dlFileEntryTypeImpl.setModifiedDate(dlFileEntryType.getModifiedDate());
547 dlFileEntryTypeImpl.setName(dlFileEntryType.getName());
548 dlFileEntryTypeImpl.setDescription(dlFileEntryType.getDescription());
549
550 return dlFileEntryTypeImpl;
551 }
552
553
561 @Override
562 public DLFileEntryType findByPrimaryKey(Serializable primaryKey)
563 throws NoSuchModelException, SystemException {
564 return findByPrimaryKey(((Long)primaryKey).longValue());
565 }
566
567
575 public DLFileEntryType findByPrimaryKey(long fileEntryTypeId)
576 throws NoSuchFileEntryTypeException, SystemException {
577 DLFileEntryType dlFileEntryType = fetchByPrimaryKey(fileEntryTypeId);
578
579 if (dlFileEntryType == null) {
580 if (_log.isWarnEnabled()) {
581 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + fileEntryTypeId);
582 }
583
584 throw new NoSuchFileEntryTypeException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
585 fileEntryTypeId);
586 }
587
588 return dlFileEntryType;
589 }
590
591
598 @Override
599 public DLFileEntryType fetchByPrimaryKey(Serializable primaryKey)
600 throws SystemException {
601 return fetchByPrimaryKey(((Long)primaryKey).longValue());
602 }
603
604
611 public DLFileEntryType fetchByPrimaryKey(long fileEntryTypeId)
612 throws SystemException {
613 DLFileEntryType dlFileEntryType = (DLFileEntryType)EntityCacheUtil.getResult(DLFileEntryTypeModelImpl.ENTITY_CACHE_ENABLED,
614 DLFileEntryTypeImpl.class, fileEntryTypeId);
615
616 if (dlFileEntryType == _nullDLFileEntryType) {
617 return null;
618 }
619
620 if (dlFileEntryType == null) {
621 Session session = null;
622
623 boolean hasException = false;
624
625 try {
626 session = openSession();
627
628 dlFileEntryType = (DLFileEntryType)session.get(DLFileEntryTypeImpl.class,
629 Long.valueOf(fileEntryTypeId));
630 }
631 catch (Exception e) {
632 hasException = true;
633
634 throw processException(e);
635 }
636 finally {
637 if (dlFileEntryType != null) {
638 cacheResult(dlFileEntryType);
639 }
640 else if (!hasException) {
641 EntityCacheUtil.putResult(DLFileEntryTypeModelImpl.ENTITY_CACHE_ENABLED,
642 DLFileEntryTypeImpl.class, fileEntryTypeId,
643 _nullDLFileEntryType);
644 }
645
646 closeSession(session);
647 }
648 }
649
650 return dlFileEntryType;
651 }
652
653
660 public List<DLFileEntryType> findByUuid(String uuid)
661 throws SystemException {
662 return findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
663 }
664
665
678 public List<DLFileEntryType> findByUuid(String uuid, int start, int end)
679 throws SystemException {
680 return findByUuid(uuid, start, end, null);
681 }
682
683
697 public List<DLFileEntryType> findByUuid(String uuid, int start, int end,
698 OrderByComparator orderByComparator) throws SystemException {
699 FinderPath finderPath = null;
700 Object[] finderArgs = null;
701
702 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
703 (orderByComparator == null)) {
704 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID;
705 finderArgs = new Object[] { uuid };
706 }
707 else {
708 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID;
709 finderArgs = new Object[] { uuid, start, end, orderByComparator };
710 }
711
712 List<DLFileEntryType> list = (List<DLFileEntryType>)FinderCacheUtil.getResult(finderPath,
713 finderArgs, this);
714
715 if (list == null) {
716 StringBundler query = null;
717
718 if (orderByComparator != null) {
719 query = new StringBundler(3 +
720 (orderByComparator.getOrderByFields().length * 3));
721 }
722 else {
723 query = new StringBundler(2);
724 }
725
726 query.append(_SQL_SELECT_DLFILEENTRYTYPE_WHERE);
727
728 if (uuid == null) {
729 query.append(_FINDER_COLUMN_UUID_UUID_1);
730 }
731 else {
732 if (uuid.equals(StringPool.BLANK)) {
733 query.append(_FINDER_COLUMN_UUID_UUID_3);
734 }
735 else {
736 query.append(_FINDER_COLUMN_UUID_UUID_2);
737 }
738 }
739
740 if (orderByComparator != null) {
741 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
742 orderByComparator);
743 }
744
745 String sql = query.toString();
746
747 Session session = null;
748
749 try {
750 session = openSession();
751
752 Query q = session.createQuery(sql);
753
754 QueryPos qPos = QueryPos.getInstance(q);
755
756 if (uuid != null) {
757 qPos.add(uuid);
758 }
759
760 list = (List<DLFileEntryType>)QueryUtil.list(q, getDialect(),
761 start, end);
762 }
763 catch (Exception e) {
764 throw processException(e);
765 }
766 finally {
767 if (list == null) {
768 FinderCacheUtil.removeResult(finderPath, finderArgs);
769 }
770 else {
771 cacheResult(list);
772
773 FinderCacheUtil.putResult(finderPath, finderArgs, list);
774 }
775
776 closeSession(session);
777 }
778 }
779
780 return list;
781 }
782
783
796 public DLFileEntryType findByUuid_First(String uuid,
797 OrderByComparator orderByComparator)
798 throws NoSuchFileEntryTypeException, SystemException {
799 List<DLFileEntryType> list = findByUuid(uuid, 0, 1, orderByComparator);
800
801 if (list.isEmpty()) {
802 StringBundler msg = new StringBundler(4);
803
804 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
805
806 msg.append("uuid=");
807 msg.append(uuid);
808
809 msg.append(StringPool.CLOSE_CURLY_BRACE);
810
811 throw new NoSuchFileEntryTypeException(msg.toString());
812 }
813 else {
814 return list.get(0);
815 }
816 }
817
818
831 public DLFileEntryType findByUuid_Last(String uuid,
832 OrderByComparator orderByComparator)
833 throws NoSuchFileEntryTypeException, SystemException {
834 int count = countByUuid(uuid);
835
836 List<DLFileEntryType> list = findByUuid(uuid, count - 1, count,
837 orderByComparator);
838
839 if (list.isEmpty()) {
840 StringBundler msg = new StringBundler(4);
841
842 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
843
844 msg.append("uuid=");
845 msg.append(uuid);
846
847 msg.append(StringPool.CLOSE_CURLY_BRACE);
848
849 throw new NoSuchFileEntryTypeException(msg.toString());
850 }
851 else {
852 return list.get(0);
853 }
854 }
855
856
870 public DLFileEntryType[] findByUuid_PrevAndNext(long fileEntryTypeId,
871 String uuid, OrderByComparator orderByComparator)
872 throws NoSuchFileEntryTypeException, SystemException {
873 DLFileEntryType dlFileEntryType = findByPrimaryKey(fileEntryTypeId);
874
875 Session session = null;
876
877 try {
878 session = openSession();
879
880 DLFileEntryType[] array = new DLFileEntryTypeImpl[3];
881
882 array[0] = getByUuid_PrevAndNext(session, dlFileEntryType, uuid,
883 orderByComparator, true);
884
885 array[1] = dlFileEntryType;
886
887 array[2] = getByUuid_PrevAndNext(session, dlFileEntryType, uuid,
888 orderByComparator, false);
889
890 return array;
891 }
892 catch (Exception e) {
893 throw processException(e);
894 }
895 finally {
896 closeSession(session);
897 }
898 }
899
900 protected DLFileEntryType getByUuid_PrevAndNext(Session session,
901 DLFileEntryType dlFileEntryType, String uuid,
902 OrderByComparator orderByComparator, boolean previous) {
903 StringBundler query = null;
904
905 if (orderByComparator != null) {
906 query = new StringBundler(6 +
907 (orderByComparator.getOrderByFields().length * 6));
908 }
909 else {
910 query = new StringBundler(3);
911 }
912
913 query.append(_SQL_SELECT_DLFILEENTRYTYPE_WHERE);
914
915 if (uuid == null) {
916 query.append(_FINDER_COLUMN_UUID_UUID_1);
917 }
918 else {
919 if (uuid.equals(StringPool.BLANK)) {
920 query.append(_FINDER_COLUMN_UUID_UUID_3);
921 }
922 else {
923 query.append(_FINDER_COLUMN_UUID_UUID_2);
924 }
925 }
926
927 if (orderByComparator != null) {
928 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
929
930 if (orderByConditionFields.length > 0) {
931 query.append(WHERE_AND);
932 }
933
934 for (int i = 0; i < orderByConditionFields.length; i++) {
935 query.append(_ORDER_BY_ENTITY_ALIAS);
936 query.append(orderByConditionFields[i]);
937
938 if ((i + 1) < orderByConditionFields.length) {
939 if (orderByComparator.isAscending() ^ previous) {
940 query.append(WHERE_GREATER_THAN_HAS_NEXT);
941 }
942 else {
943 query.append(WHERE_LESSER_THAN_HAS_NEXT);
944 }
945 }
946 else {
947 if (orderByComparator.isAscending() ^ previous) {
948 query.append(WHERE_GREATER_THAN);
949 }
950 else {
951 query.append(WHERE_LESSER_THAN);
952 }
953 }
954 }
955
956 query.append(ORDER_BY_CLAUSE);
957
958 String[] orderByFields = orderByComparator.getOrderByFields();
959
960 for (int i = 0; i < orderByFields.length; i++) {
961 query.append(_ORDER_BY_ENTITY_ALIAS);
962 query.append(orderByFields[i]);
963
964 if ((i + 1) < orderByFields.length) {
965 if (orderByComparator.isAscending() ^ previous) {
966 query.append(ORDER_BY_ASC_HAS_NEXT);
967 }
968 else {
969 query.append(ORDER_BY_DESC_HAS_NEXT);
970 }
971 }
972 else {
973 if (orderByComparator.isAscending() ^ previous) {
974 query.append(ORDER_BY_ASC);
975 }
976 else {
977 query.append(ORDER_BY_DESC);
978 }
979 }
980 }
981 }
982
983 String sql = query.toString();
984
985 Query q = session.createQuery(sql);
986
987 q.setFirstResult(0);
988 q.setMaxResults(2);
989
990 QueryPos qPos = QueryPos.getInstance(q);
991
992 if (uuid != null) {
993 qPos.add(uuid);
994 }
995
996 if (orderByComparator != null) {
997 Object[] values = orderByComparator.getOrderByConditionValues(dlFileEntryType);
998
999 for (Object value : values) {
1000 qPos.add(value);
1001 }
1002 }
1003
1004 List<DLFileEntryType> list = q.list();
1005
1006 if (list.size() == 2) {
1007 return list.get(1);
1008 }
1009 else {
1010 return null;
1011 }
1012 }
1013
1014
1023 public DLFileEntryType findByUUID_G(String uuid, long groupId)
1024 throws NoSuchFileEntryTypeException, SystemException {
1025 DLFileEntryType dlFileEntryType = fetchByUUID_G(uuid, groupId);
1026
1027 if (dlFileEntryType == null) {
1028 StringBundler msg = new StringBundler(6);
1029
1030 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1031
1032 msg.append("uuid=");
1033 msg.append(uuid);
1034
1035 msg.append(", groupId=");
1036 msg.append(groupId);
1037
1038 msg.append(StringPool.CLOSE_CURLY_BRACE);
1039
1040 if (_log.isWarnEnabled()) {
1041 _log.warn(msg.toString());
1042 }
1043
1044 throw new NoSuchFileEntryTypeException(msg.toString());
1045 }
1046
1047 return dlFileEntryType;
1048 }
1049
1050
1058 public DLFileEntryType fetchByUUID_G(String uuid, long groupId)
1059 throws SystemException {
1060 return fetchByUUID_G(uuid, groupId, true);
1061 }
1062
1063
1072 public DLFileEntryType fetchByUUID_G(String uuid, long groupId,
1073 boolean retrieveFromCache) throws SystemException {
1074 Object[] finderArgs = new Object[] { uuid, groupId };
1075
1076 Object result = null;
1077
1078 if (retrieveFromCache) {
1079 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_UUID_G,
1080 finderArgs, this);
1081 }
1082
1083 if (result == null) {
1084 StringBundler query = new StringBundler(3);
1085
1086 query.append(_SQL_SELECT_DLFILEENTRYTYPE_WHERE);
1087
1088 if (uuid == null) {
1089 query.append(_FINDER_COLUMN_UUID_G_UUID_1);
1090 }
1091 else {
1092 if (uuid.equals(StringPool.BLANK)) {
1093 query.append(_FINDER_COLUMN_UUID_G_UUID_3);
1094 }
1095 else {
1096 query.append(_FINDER_COLUMN_UUID_G_UUID_2);
1097 }
1098 }
1099
1100 query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
1101
1102 String sql = query.toString();
1103
1104 Session session = null;
1105
1106 try {
1107 session = openSession();
1108
1109 Query q = session.createQuery(sql);
1110
1111 QueryPos qPos = QueryPos.getInstance(q);
1112
1113 if (uuid != null) {
1114 qPos.add(uuid);
1115 }
1116
1117 qPos.add(groupId);
1118
1119 List<DLFileEntryType> list = q.list();
1120
1121 result = list;
1122
1123 DLFileEntryType dlFileEntryType = null;
1124
1125 if (list.isEmpty()) {
1126 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
1127 finderArgs, list);
1128 }
1129 else {
1130 dlFileEntryType = list.get(0);
1131
1132 cacheResult(dlFileEntryType);
1133
1134 if ((dlFileEntryType.getUuid() == null) ||
1135 !dlFileEntryType.getUuid().equals(uuid) ||
1136 (dlFileEntryType.getGroupId() != groupId)) {
1137 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
1138 finderArgs, dlFileEntryType);
1139 }
1140 }
1141
1142 return dlFileEntryType;
1143 }
1144 catch (Exception e) {
1145 throw processException(e);
1146 }
1147 finally {
1148 if (result == null) {
1149 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
1150 finderArgs);
1151 }
1152
1153 closeSession(session);
1154 }
1155 }
1156 else {
1157 if (result instanceof List<?>) {
1158 return null;
1159 }
1160 else {
1161 return (DLFileEntryType)result;
1162 }
1163 }
1164 }
1165
1166
1173 public List<DLFileEntryType> findByGroupId(long groupId)
1174 throws SystemException {
1175 return findByGroupId(groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1176 }
1177
1178
1191 public List<DLFileEntryType> findByGroupId(long groupId, int start, int end)
1192 throws SystemException {
1193 return findByGroupId(groupId, start, end, null);
1194 }
1195
1196
1210 public List<DLFileEntryType> findByGroupId(long groupId, int start,
1211 int end, OrderByComparator orderByComparator) throws SystemException {
1212 FinderPath finderPath = null;
1213 Object[] finderArgs = null;
1214
1215 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1216 (orderByComparator == null)) {
1217 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID;
1218 finderArgs = new Object[] { groupId };
1219 }
1220 else {
1221 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID;
1222 finderArgs = new Object[] { groupId, start, end, orderByComparator };
1223 }
1224
1225 List<DLFileEntryType> list = (List<DLFileEntryType>)FinderCacheUtil.getResult(finderPath,
1226 finderArgs, this);
1227
1228 if (list == null) {
1229 StringBundler query = null;
1230
1231 if (orderByComparator != null) {
1232 query = new StringBundler(3 +
1233 (orderByComparator.getOrderByFields().length * 3));
1234 }
1235 else {
1236 query = new StringBundler(2);
1237 }
1238
1239 query.append(_SQL_SELECT_DLFILEENTRYTYPE_WHERE);
1240
1241 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1242
1243 if (orderByComparator != null) {
1244 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1245 orderByComparator);
1246 }
1247
1248 String sql = query.toString();
1249
1250 Session session = null;
1251
1252 try {
1253 session = openSession();
1254
1255 Query q = session.createQuery(sql);
1256
1257 QueryPos qPos = QueryPos.getInstance(q);
1258
1259 qPos.add(groupId);
1260
1261 list = (List<DLFileEntryType>)QueryUtil.list(q, getDialect(),
1262 start, end);
1263 }
1264 catch (Exception e) {
1265 throw processException(e);
1266 }
1267 finally {
1268 if (list == null) {
1269 FinderCacheUtil.removeResult(finderPath, finderArgs);
1270 }
1271 else {
1272 cacheResult(list);
1273
1274 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1275 }
1276
1277 closeSession(session);
1278 }
1279 }
1280
1281 return list;
1282 }
1283
1284
1297 public DLFileEntryType findByGroupId_First(long groupId,
1298 OrderByComparator orderByComparator)
1299 throws NoSuchFileEntryTypeException, SystemException {
1300 List<DLFileEntryType> list = findByGroupId(groupId, 0, 1,
1301 orderByComparator);
1302
1303 if (list.isEmpty()) {
1304 StringBundler msg = new StringBundler(4);
1305
1306 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1307
1308 msg.append("groupId=");
1309 msg.append(groupId);
1310
1311 msg.append(StringPool.CLOSE_CURLY_BRACE);
1312
1313 throw new NoSuchFileEntryTypeException(msg.toString());
1314 }
1315 else {
1316 return list.get(0);
1317 }
1318 }
1319
1320
1333 public DLFileEntryType findByGroupId_Last(long groupId,
1334 OrderByComparator orderByComparator)
1335 throws NoSuchFileEntryTypeException, SystemException {
1336 int count = countByGroupId(groupId);
1337
1338 List<DLFileEntryType> list = findByGroupId(groupId, count - 1, count,
1339 orderByComparator);
1340
1341 if (list.isEmpty()) {
1342 StringBundler msg = new StringBundler(4);
1343
1344 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1345
1346 msg.append("groupId=");
1347 msg.append(groupId);
1348
1349 msg.append(StringPool.CLOSE_CURLY_BRACE);
1350
1351 throw new NoSuchFileEntryTypeException(msg.toString());
1352 }
1353 else {
1354 return list.get(0);
1355 }
1356 }
1357
1358
1372 public DLFileEntryType[] findByGroupId_PrevAndNext(long fileEntryTypeId,
1373 long groupId, OrderByComparator orderByComparator)
1374 throws NoSuchFileEntryTypeException, SystemException {
1375 DLFileEntryType dlFileEntryType = findByPrimaryKey(fileEntryTypeId);
1376
1377 Session session = null;
1378
1379 try {
1380 session = openSession();
1381
1382 DLFileEntryType[] array = new DLFileEntryTypeImpl[3];
1383
1384 array[0] = getByGroupId_PrevAndNext(session, dlFileEntryType,
1385 groupId, orderByComparator, true);
1386
1387 array[1] = dlFileEntryType;
1388
1389 array[2] = getByGroupId_PrevAndNext(session, dlFileEntryType,
1390 groupId, orderByComparator, false);
1391
1392 return array;
1393 }
1394 catch (Exception e) {
1395 throw processException(e);
1396 }
1397 finally {
1398 closeSession(session);
1399 }
1400 }
1401
1402 protected DLFileEntryType getByGroupId_PrevAndNext(Session session,
1403 DLFileEntryType dlFileEntryType, long groupId,
1404 OrderByComparator orderByComparator, boolean previous) {
1405 StringBundler query = null;
1406
1407 if (orderByComparator != null) {
1408 query = new StringBundler(6 +
1409 (orderByComparator.getOrderByFields().length * 6));
1410 }
1411 else {
1412 query = new StringBundler(3);
1413 }
1414
1415 query.append(_SQL_SELECT_DLFILEENTRYTYPE_WHERE);
1416
1417 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1418
1419 if (orderByComparator != null) {
1420 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1421
1422 if (orderByConditionFields.length > 0) {
1423 query.append(WHERE_AND);
1424 }
1425
1426 for (int i = 0; i < orderByConditionFields.length; i++) {
1427 query.append(_ORDER_BY_ENTITY_ALIAS);
1428 query.append(orderByConditionFields[i]);
1429
1430 if ((i + 1) < orderByConditionFields.length) {
1431 if (orderByComparator.isAscending() ^ previous) {
1432 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1433 }
1434 else {
1435 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1436 }
1437 }
1438 else {
1439 if (orderByComparator.isAscending() ^ previous) {
1440 query.append(WHERE_GREATER_THAN);
1441 }
1442 else {
1443 query.append(WHERE_LESSER_THAN);
1444 }
1445 }
1446 }
1447
1448 query.append(ORDER_BY_CLAUSE);
1449
1450 String[] orderByFields = orderByComparator.getOrderByFields();
1451
1452 for (int i = 0; i < orderByFields.length; i++) {
1453 query.append(_ORDER_BY_ENTITY_ALIAS);
1454 query.append(orderByFields[i]);
1455
1456 if ((i + 1) < orderByFields.length) {
1457 if (orderByComparator.isAscending() ^ previous) {
1458 query.append(ORDER_BY_ASC_HAS_NEXT);
1459 }
1460 else {
1461 query.append(ORDER_BY_DESC_HAS_NEXT);
1462 }
1463 }
1464 else {
1465 if (orderByComparator.isAscending() ^ previous) {
1466 query.append(ORDER_BY_ASC);
1467 }
1468 else {
1469 query.append(ORDER_BY_DESC);
1470 }
1471 }
1472 }
1473 }
1474
1475 String sql = query.toString();
1476
1477 Query q = session.createQuery(sql);
1478
1479 q.setFirstResult(0);
1480 q.setMaxResults(2);
1481
1482 QueryPos qPos = QueryPos.getInstance(q);
1483
1484 qPos.add(groupId);
1485
1486 if (orderByComparator != null) {
1487 Object[] values = orderByComparator.getOrderByConditionValues(dlFileEntryType);
1488
1489 for (Object value : values) {
1490 qPos.add(value);
1491 }
1492 }
1493
1494 List<DLFileEntryType> list = q.list();
1495
1496 if (list.size() == 2) {
1497 return list.get(1);
1498 }
1499 else {
1500 return null;
1501 }
1502 }
1503
1504
1515 public List<DLFileEntryType> findByGroupId(long[] groupIds)
1516 throws SystemException {
1517 return findByGroupId(groupIds, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
1518 null);
1519 }
1520
1521
1534 public List<DLFileEntryType> findByGroupId(long[] groupIds, int start,
1535 int end) throws SystemException {
1536 return findByGroupId(groupIds, start, end, null);
1537 }
1538
1539
1553 public List<DLFileEntryType> findByGroupId(long[] groupIds, int start,
1554 int end, OrderByComparator orderByComparator) throws SystemException {
1555 FinderPath finderPath = null;
1556 Object[] finderArgs = null;
1557
1558 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1559 (orderByComparator == null)) {
1560 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID;
1561 finderArgs = new Object[] { StringUtil.merge(groupIds) };
1562 }
1563 else {
1564 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID;
1565 finderArgs = new Object[] {
1566 StringUtil.merge(groupIds),
1567
1568 start, end, orderByComparator
1569 };
1570 }
1571
1572 List<DLFileEntryType> list = (List<DLFileEntryType>)FinderCacheUtil.getResult(finderPath,
1573 finderArgs, this);
1574
1575 if (list == null) {
1576 StringBundler query = new StringBundler();
1577
1578 query.append(_SQL_SELECT_DLFILEENTRYTYPE_WHERE);
1579
1580 boolean conjunctionable = false;
1581
1582 if ((groupIds == null) || (groupIds.length > 0)) {
1583 if (conjunctionable) {
1584 query.append(WHERE_AND);
1585 }
1586
1587 query.append(StringPool.OPEN_PARENTHESIS);
1588
1589 for (int i = 0; i < groupIds.length; i++) {
1590 query.append(_FINDER_COLUMN_GROUPID_GROUPID_5);
1591
1592 if ((i + 1) < groupIds.length) {
1593 query.append(WHERE_OR);
1594 }
1595 }
1596
1597 query.append(StringPool.CLOSE_PARENTHESIS);
1598
1599 conjunctionable = true;
1600 }
1601
1602 if (orderByComparator != null) {
1603 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1604 orderByComparator);
1605 }
1606
1607 String sql = query.toString();
1608
1609 Session session = null;
1610
1611 try {
1612 session = openSession();
1613
1614 Query q = session.createQuery(sql);
1615
1616 QueryPos qPos = QueryPos.getInstance(q);
1617
1618 if (groupIds != null) {
1619 qPos.add(groupIds);
1620 }
1621
1622 list = (List<DLFileEntryType>)QueryUtil.list(q, getDialect(),
1623 start, end);
1624 }
1625 catch (Exception e) {
1626 throw processException(e);
1627 }
1628 finally {
1629 if (list == null) {
1630 FinderCacheUtil.removeResult(finderPath, finderArgs);
1631 }
1632 else {
1633 cacheResult(list);
1634
1635 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1636 }
1637
1638 closeSession(session);
1639 }
1640 }
1641
1642 return list;
1643 }
1644
1645
1652 public List<DLFileEntryType> filterFindByGroupId(long groupId)
1653 throws SystemException {
1654 return filterFindByGroupId(groupId, QueryUtil.ALL_POS,
1655 QueryUtil.ALL_POS, null);
1656 }
1657
1658
1671 public List<DLFileEntryType> filterFindByGroupId(long groupId, int start,
1672 int end) throws SystemException {
1673 return filterFindByGroupId(groupId, start, end, null);
1674 }
1675
1676
1690 public List<DLFileEntryType> filterFindByGroupId(long groupId, int start,
1691 int end, OrderByComparator orderByComparator) throws SystemException {
1692 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
1693 return findByGroupId(groupId, start, end, orderByComparator);
1694 }
1695
1696 StringBundler query = null;
1697
1698 if (orderByComparator != null) {
1699 query = new StringBundler(3 +
1700 (orderByComparator.getOrderByFields().length * 3));
1701 }
1702 else {
1703 query = new StringBundler(2);
1704 }
1705
1706 if (getDB().isSupportsInlineDistinct()) {
1707 query.append(_FILTER_SQL_SELECT_DLFILEENTRYTYPE_WHERE);
1708 }
1709 else {
1710 query.append(_FILTER_SQL_SELECT_DLFILEENTRYTYPE_NO_INLINE_DISTINCT_WHERE_1);
1711 }
1712
1713 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1714
1715 if (!getDB().isSupportsInlineDistinct()) {
1716 query.append(_FILTER_SQL_SELECT_DLFILEENTRYTYPE_NO_INLINE_DISTINCT_WHERE_2);
1717 }
1718
1719 if (orderByComparator != null) {
1720 if (getDB().isSupportsInlineDistinct()) {
1721 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1722 orderByComparator);
1723 }
1724 else {
1725 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
1726 orderByComparator);
1727 }
1728 }
1729
1730 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1731 DLFileEntryType.class.getName(),
1732 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
1733
1734 Session session = null;
1735
1736 try {
1737 session = openSession();
1738
1739 SQLQuery q = session.createSQLQuery(sql);
1740
1741 if (getDB().isSupportsInlineDistinct()) {
1742 q.addEntity(_FILTER_ENTITY_ALIAS, DLFileEntryTypeImpl.class);
1743 }
1744 else {
1745 q.addEntity(_FILTER_ENTITY_TABLE, DLFileEntryTypeImpl.class);
1746 }
1747
1748 QueryPos qPos = QueryPos.getInstance(q);
1749
1750 qPos.add(groupId);
1751
1752 return (List<DLFileEntryType>)QueryUtil.list(q, getDialect(),
1753 start, end);
1754 }
1755 catch (Exception e) {
1756 throw processException(e);
1757 }
1758 finally {
1759 closeSession(session);
1760 }
1761 }
1762
1763
1773 public DLFileEntryType[] filterFindByGroupId_PrevAndNext(
1774 long fileEntryTypeId, long groupId, OrderByComparator orderByComparator)
1775 throws NoSuchFileEntryTypeException, SystemException {
1776 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
1777 return findByGroupId_PrevAndNext(fileEntryTypeId, groupId,
1778 orderByComparator);
1779 }
1780
1781 DLFileEntryType dlFileEntryType = findByPrimaryKey(fileEntryTypeId);
1782
1783 Session session = null;
1784
1785 try {
1786 session = openSession();
1787
1788 DLFileEntryType[] array = new DLFileEntryTypeImpl[3];
1789
1790 array[0] = filterGetByGroupId_PrevAndNext(session, dlFileEntryType,
1791 groupId, orderByComparator, true);
1792
1793 array[1] = dlFileEntryType;
1794
1795 array[2] = filterGetByGroupId_PrevAndNext(session, dlFileEntryType,
1796 groupId, orderByComparator, false);
1797
1798 return array;
1799 }
1800 catch (Exception e) {
1801 throw processException(e);
1802 }
1803 finally {
1804 closeSession(session);
1805 }
1806 }
1807
1808 protected DLFileEntryType filterGetByGroupId_PrevAndNext(Session session,
1809 DLFileEntryType dlFileEntryType, long groupId,
1810 OrderByComparator orderByComparator, boolean previous) {
1811 StringBundler query = null;
1812
1813 if (orderByComparator != null) {
1814 query = new StringBundler(6 +
1815 (orderByComparator.getOrderByFields().length * 6));
1816 }
1817 else {
1818 query = new StringBundler(3);
1819 }
1820
1821 if (getDB().isSupportsInlineDistinct()) {
1822 query.append(_FILTER_SQL_SELECT_DLFILEENTRYTYPE_WHERE);
1823 }
1824 else {
1825 query.append(_FILTER_SQL_SELECT_DLFILEENTRYTYPE_NO_INLINE_DISTINCT_WHERE_1);
1826 }
1827
1828 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1829
1830 if (!getDB().isSupportsInlineDistinct()) {
1831 query.append(_FILTER_SQL_SELECT_DLFILEENTRYTYPE_NO_INLINE_DISTINCT_WHERE_2);
1832 }
1833
1834 if (orderByComparator != null) {
1835 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1836
1837 if (orderByConditionFields.length > 0) {
1838 query.append(WHERE_AND);
1839 }
1840
1841 for (int i = 0; i < orderByConditionFields.length; i++) {
1842 if (getDB().isSupportsInlineDistinct()) {
1843 query.append(_ORDER_BY_ENTITY_ALIAS);
1844 }
1845 else {
1846 query.append(_ORDER_BY_ENTITY_TABLE);
1847 }
1848
1849 query.append(orderByConditionFields[i]);
1850
1851 if ((i + 1) < orderByConditionFields.length) {
1852 if (orderByComparator.isAscending() ^ previous) {
1853 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1854 }
1855 else {
1856 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1857 }
1858 }
1859 else {
1860 if (orderByComparator.isAscending() ^ previous) {
1861 query.append(WHERE_GREATER_THAN);
1862 }
1863 else {
1864 query.append(WHERE_LESSER_THAN);
1865 }
1866 }
1867 }
1868
1869 query.append(ORDER_BY_CLAUSE);
1870
1871 String[] orderByFields = orderByComparator.getOrderByFields();
1872
1873 for (int i = 0; i < orderByFields.length; i++) {
1874 if (getDB().isSupportsInlineDistinct()) {
1875 query.append(_ORDER_BY_ENTITY_ALIAS);
1876 }
1877 else {
1878 query.append(_ORDER_BY_ENTITY_TABLE);
1879 }
1880
1881 query.append(orderByFields[i]);
1882
1883 if ((i + 1) < orderByFields.length) {
1884 if (orderByComparator.isAscending() ^ previous) {
1885 query.append(ORDER_BY_ASC_HAS_NEXT);
1886 }
1887 else {
1888 query.append(ORDER_BY_DESC_HAS_NEXT);
1889 }
1890 }
1891 else {
1892 if (orderByComparator.isAscending() ^ previous) {
1893 query.append(ORDER_BY_ASC);
1894 }
1895 else {
1896 query.append(ORDER_BY_DESC);
1897 }
1898 }
1899 }
1900 }
1901
1902 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1903 DLFileEntryType.class.getName(),
1904 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
1905
1906 SQLQuery q = session.createSQLQuery(sql);
1907
1908 q.setFirstResult(0);
1909 q.setMaxResults(2);
1910
1911 if (getDB().isSupportsInlineDistinct()) {
1912 q.addEntity(_FILTER_ENTITY_ALIAS, DLFileEntryTypeImpl.class);
1913 }
1914 else {
1915 q.addEntity(_FILTER_ENTITY_TABLE, DLFileEntryTypeImpl.class);
1916 }
1917
1918 QueryPos qPos = QueryPos.getInstance(q);
1919
1920 qPos.add(groupId);
1921
1922 if (orderByComparator != null) {
1923 Object[] values = orderByComparator.getOrderByConditionValues(dlFileEntryType);
1924
1925 for (Object value : values) {
1926 qPos.add(value);
1927 }
1928 }
1929
1930 List<DLFileEntryType> list = q.list();
1931
1932 if (list.size() == 2) {
1933 return list.get(1);
1934 }
1935 else {
1936 return null;
1937 }
1938 }
1939
1940
1947 public List<DLFileEntryType> filterFindByGroupId(long[] groupIds)
1948 throws SystemException {
1949 return filterFindByGroupId(groupIds, QueryUtil.ALL_POS,
1950 QueryUtil.ALL_POS, null);
1951 }
1952
1953
1966 public List<DLFileEntryType> filterFindByGroupId(long[] groupIds,
1967 int start, int end) throws SystemException {
1968 return filterFindByGroupId(groupIds, start, end, null);
1969 }
1970
1971
1985 public List<DLFileEntryType> filterFindByGroupId(long[] groupIds,
1986 int start, int end, OrderByComparator orderByComparator)
1987 throws SystemException {
1988 if (!InlineSQLHelperUtil.isEnabled(groupIds)) {
1989 return findByGroupId(groupIds, start, end, orderByComparator);
1990 }
1991
1992 StringBundler query = new StringBundler();
1993
1994 if (getDB().isSupportsInlineDistinct()) {
1995 query.append(_FILTER_SQL_SELECT_DLFILEENTRYTYPE_WHERE);
1996 }
1997 else {
1998 query.append(_FILTER_SQL_SELECT_DLFILEENTRYTYPE_NO_INLINE_DISTINCT_WHERE_1);
1999 }
2000
2001 boolean conjunctionable = false;
2002
2003 if ((groupIds == null) || (groupIds.length > 0)) {
2004 if (conjunctionable) {
2005 query.append(WHERE_AND);
2006 }
2007
2008 query.append(StringPool.OPEN_PARENTHESIS);
2009
2010 for (int i = 0; i < groupIds.length; i++) {
2011 query.append(_FINDER_COLUMN_GROUPID_GROUPID_5);
2012
2013 if ((i + 1) < groupIds.length) {
2014 query.append(WHERE_OR);
2015 }
2016 }
2017
2018 query.append(StringPool.CLOSE_PARENTHESIS);
2019
2020 conjunctionable = true;
2021 }
2022
2023 if (!getDB().isSupportsInlineDistinct()) {
2024 query.append(_FILTER_SQL_SELECT_DLFILEENTRYTYPE_NO_INLINE_DISTINCT_WHERE_2);
2025 }
2026
2027 if (orderByComparator != null) {
2028 if (getDB().isSupportsInlineDistinct()) {
2029 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2030 orderByComparator);
2031 }
2032 else {
2033 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
2034 orderByComparator);
2035 }
2036 }
2037
2038 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2039 DLFileEntryType.class.getName(),
2040 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupIds);
2041
2042 Session session = null;
2043
2044 try {
2045 session = openSession();
2046
2047 SQLQuery q = session.createSQLQuery(sql);
2048
2049 if (getDB().isSupportsInlineDistinct()) {
2050 q.addEntity(_FILTER_ENTITY_ALIAS, DLFileEntryTypeImpl.class);
2051 }
2052 else {
2053 q.addEntity(_FILTER_ENTITY_TABLE, DLFileEntryTypeImpl.class);
2054 }
2055
2056 QueryPos qPos = QueryPos.getInstance(q);
2057
2058 if (groupIds != null) {
2059 qPos.add(groupIds);
2060 }
2061
2062 return (List<DLFileEntryType>)QueryUtil.list(q, getDialect(),
2063 start, end);
2064 }
2065 catch (Exception e) {
2066 throw processException(e);
2067 }
2068 finally {
2069 closeSession(session);
2070 }
2071 }
2072
2073
2082 public DLFileEntryType findByG_N(long groupId, String name)
2083 throws NoSuchFileEntryTypeException, SystemException {
2084 DLFileEntryType dlFileEntryType = fetchByG_N(groupId, name);
2085
2086 if (dlFileEntryType == null) {
2087 StringBundler msg = new StringBundler(6);
2088
2089 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2090
2091 msg.append("groupId=");
2092 msg.append(groupId);
2093
2094 msg.append(", name=");
2095 msg.append(name);
2096
2097 msg.append(StringPool.CLOSE_CURLY_BRACE);
2098
2099 if (_log.isWarnEnabled()) {
2100 _log.warn(msg.toString());
2101 }
2102
2103 throw new NoSuchFileEntryTypeException(msg.toString());
2104 }
2105
2106 return dlFileEntryType;
2107 }
2108
2109
2117 public DLFileEntryType fetchByG_N(long groupId, String name)
2118 throws SystemException {
2119 return fetchByG_N(groupId, name, true);
2120 }
2121
2122
2131 public DLFileEntryType fetchByG_N(long groupId, String name,
2132 boolean retrieveFromCache) throws SystemException {
2133 Object[] finderArgs = new Object[] { groupId, name };
2134
2135 Object result = null;
2136
2137 if (retrieveFromCache) {
2138 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_G_N,
2139 finderArgs, this);
2140 }
2141
2142 if (result == null) {
2143 StringBundler query = new StringBundler(3);
2144
2145 query.append(_SQL_SELECT_DLFILEENTRYTYPE_WHERE);
2146
2147 query.append(_FINDER_COLUMN_G_N_GROUPID_2);
2148
2149 if (name == null) {
2150 query.append(_FINDER_COLUMN_G_N_NAME_1);
2151 }
2152 else {
2153 if (name.equals(StringPool.BLANK)) {
2154 query.append(_FINDER_COLUMN_G_N_NAME_3);
2155 }
2156 else {
2157 query.append(_FINDER_COLUMN_G_N_NAME_2);
2158 }
2159 }
2160
2161 String sql = query.toString();
2162
2163 Session session = null;
2164
2165 try {
2166 session = openSession();
2167
2168 Query q = session.createQuery(sql);
2169
2170 QueryPos qPos = QueryPos.getInstance(q);
2171
2172 qPos.add(groupId);
2173
2174 if (name != null) {
2175 qPos.add(name);
2176 }
2177
2178 List<DLFileEntryType> list = q.list();
2179
2180 result = list;
2181
2182 DLFileEntryType dlFileEntryType = null;
2183
2184 if (list.isEmpty()) {
2185 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_N,
2186 finderArgs, list);
2187 }
2188 else {
2189 dlFileEntryType = list.get(0);
2190
2191 cacheResult(dlFileEntryType);
2192
2193 if ((dlFileEntryType.getGroupId() != groupId) ||
2194 (dlFileEntryType.getName() == null) ||
2195 !dlFileEntryType.getName().equals(name)) {
2196 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_N,
2197 finderArgs, dlFileEntryType);
2198 }
2199 }
2200
2201 return dlFileEntryType;
2202 }
2203 catch (Exception e) {
2204 throw processException(e);
2205 }
2206 finally {
2207 if (result == null) {
2208 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_N,
2209 finderArgs);
2210 }
2211
2212 closeSession(session);
2213 }
2214 }
2215 else {
2216 if (result instanceof List<?>) {
2217 return null;
2218 }
2219 else {
2220 return (DLFileEntryType)result;
2221 }
2222 }
2223 }
2224
2225
2231 public List<DLFileEntryType> findAll() throws SystemException {
2232 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
2233 }
2234
2235
2247 public List<DLFileEntryType> findAll(int start, int end)
2248 throws SystemException {
2249 return findAll(start, end, null);
2250 }
2251
2252
2265 public List<DLFileEntryType> findAll(int start, int end,
2266 OrderByComparator orderByComparator) throws SystemException {
2267 FinderPath finderPath = null;
2268 Object[] finderArgs = new Object[] { start, end, orderByComparator };
2269
2270 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2271 (orderByComparator == null)) {
2272 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
2273 finderArgs = FINDER_ARGS_EMPTY;
2274 }
2275 else {
2276 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
2277 finderArgs = new Object[] { start, end, orderByComparator };
2278 }
2279
2280 List<DLFileEntryType> list = (List<DLFileEntryType>)FinderCacheUtil.getResult(finderPath,
2281 finderArgs, this);
2282
2283 if (list == null) {
2284 StringBundler query = null;
2285 String sql = null;
2286
2287 if (orderByComparator != null) {
2288 query = new StringBundler(2 +
2289 (orderByComparator.getOrderByFields().length * 3));
2290
2291 query.append(_SQL_SELECT_DLFILEENTRYTYPE);
2292
2293 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2294 orderByComparator);
2295
2296 sql = query.toString();
2297 }
2298 else {
2299 sql = _SQL_SELECT_DLFILEENTRYTYPE;
2300 }
2301
2302 Session session = null;
2303
2304 try {
2305 session = openSession();
2306
2307 Query q = session.createQuery(sql);
2308
2309 if (orderByComparator == null) {
2310 list = (List<DLFileEntryType>)QueryUtil.list(q,
2311 getDialect(), start, end, false);
2312
2313 Collections.sort(list);
2314 }
2315 else {
2316 list = (List<DLFileEntryType>)QueryUtil.list(q,
2317 getDialect(), start, end);
2318 }
2319 }
2320 catch (Exception e) {
2321 throw processException(e);
2322 }
2323 finally {
2324 if (list == null) {
2325 FinderCacheUtil.removeResult(finderPath, finderArgs);
2326 }
2327 else {
2328 cacheResult(list);
2329
2330 FinderCacheUtil.putResult(finderPath, finderArgs, list);
2331 }
2332
2333 closeSession(session);
2334 }
2335 }
2336
2337 return list;
2338 }
2339
2340
2346 public void removeByUuid(String uuid) throws SystemException {
2347 for (DLFileEntryType dlFileEntryType : findByUuid(uuid)) {
2348 remove(dlFileEntryType);
2349 }
2350 }
2351
2352
2359 public void removeByUUID_G(String uuid, long groupId)
2360 throws NoSuchFileEntryTypeException, SystemException {
2361 DLFileEntryType dlFileEntryType = findByUUID_G(uuid, groupId);
2362
2363 remove(dlFileEntryType);
2364 }
2365
2366
2372 public void removeByGroupId(long groupId) throws SystemException {
2373 for (DLFileEntryType dlFileEntryType : findByGroupId(groupId)) {
2374 remove(dlFileEntryType);
2375 }
2376 }
2377
2378
2385 public void removeByG_N(long groupId, String name)
2386 throws NoSuchFileEntryTypeException, SystemException {
2387 DLFileEntryType dlFileEntryType = findByG_N(groupId, name);
2388
2389 remove(dlFileEntryType);
2390 }
2391
2392
2397 public void removeAll() throws SystemException {
2398 for (DLFileEntryType dlFileEntryType : findAll()) {
2399 remove(dlFileEntryType);
2400 }
2401 }
2402
2403
2410 public int countByUuid(String uuid) throws SystemException {
2411 Object[] finderArgs = new Object[] { uuid };
2412
2413 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID,
2414 finderArgs, this);
2415
2416 if (count == null) {
2417 StringBundler query = new StringBundler(2);
2418
2419 query.append(_SQL_COUNT_DLFILEENTRYTYPE_WHERE);
2420
2421 if (uuid == null) {
2422 query.append(_FINDER_COLUMN_UUID_UUID_1);
2423 }
2424 else {
2425 if (uuid.equals(StringPool.BLANK)) {
2426 query.append(_FINDER_COLUMN_UUID_UUID_3);
2427 }
2428 else {
2429 query.append(_FINDER_COLUMN_UUID_UUID_2);
2430 }
2431 }
2432
2433 String sql = query.toString();
2434
2435 Session session = null;
2436
2437 try {
2438 session = openSession();
2439
2440 Query q = session.createQuery(sql);
2441
2442 QueryPos qPos = QueryPos.getInstance(q);
2443
2444 if (uuid != null) {
2445 qPos.add(uuid);
2446 }
2447
2448 count = (Long)q.uniqueResult();
2449 }
2450 catch (Exception e) {
2451 throw processException(e);
2452 }
2453 finally {
2454 if (count == null) {
2455 count = Long.valueOf(0);
2456 }
2457
2458 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID,
2459 finderArgs, count);
2460
2461 closeSession(session);
2462 }
2463 }
2464
2465 return count.intValue();
2466 }
2467
2468
2476 public int countByUUID_G(String uuid, long groupId)
2477 throws SystemException {
2478 Object[] finderArgs = new Object[] { uuid, groupId };
2479
2480 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID_G,
2481 finderArgs, this);
2482
2483 if (count == null) {
2484 StringBundler query = new StringBundler(3);
2485
2486 query.append(_SQL_COUNT_DLFILEENTRYTYPE_WHERE);
2487
2488 if (uuid == null) {
2489 query.append(_FINDER_COLUMN_UUID_G_UUID_1);
2490 }
2491 else {
2492 if (uuid.equals(StringPool.BLANK)) {
2493 query.append(_FINDER_COLUMN_UUID_G_UUID_3);
2494 }
2495 else {
2496 query.append(_FINDER_COLUMN_UUID_G_UUID_2);
2497 }
2498 }
2499
2500 query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
2501
2502 String sql = query.toString();
2503
2504 Session session = null;
2505
2506 try {
2507 session = openSession();
2508
2509 Query q = session.createQuery(sql);
2510
2511 QueryPos qPos = QueryPos.getInstance(q);
2512
2513 if (uuid != null) {
2514 qPos.add(uuid);
2515 }
2516
2517 qPos.add(groupId);
2518
2519 count = (Long)q.uniqueResult();
2520 }
2521 catch (Exception e) {
2522 throw processException(e);
2523 }
2524 finally {
2525 if (count == null) {
2526 count = Long.valueOf(0);
2527 }
2528
2529 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G,
2530 finderArgs, count);
2531
2532 closeSession(session);
2533 }
2534 }
2535
2536 return count.intValue();
2537 }
2538
2539
2546 public int countByGroupId(long groupId) throws SystemException {
2547 Object[] finderArgs = new Object[] { groupId };
2548
2549 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_GROUPID,
2550 finderArgs, this);
2551
2552 if (count == null) {
2553 StringBundler query = new StringBundler(2);
2554
2555 query.append(_SQL_COUNT_DLFILEENTRYTYPE_WHERE);
2556
2557 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2558
2559 String sql = query.toString();
2560
2561 Session session = null;
2562
2563 try {
2564 session = openSession();
2565
2566 Query q = session.createQuery(sql);
2567
2568 QueryPos qPos = QueryPos.getInstance(q);
2569
2570 qPos.add(groupId);
2571
2572 count = (Long)q.uniqueResult();
2573 }
2574 catch (Exception e) {
2575 throw processException(e);
2576 }
2577 finally {
2578 if (count == null) {
2579 count = Long.valueOf(0);
2580 }
2581
2582 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_GROUPID,
2583 finderArgs, count);
2584
2585 closeSession(session);
2586 }
2587 }
2588
2589 return count.intValue();
2590 }
2591
2592
2599 public int countByGroupId(long[] groupIds) throws SystemException {
2600 Object[] finderArgs = new Object[] { StringUtil.merge(groupIds) };
2601
2602 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_GROUPID,
2603 finderArgs, this);
2604
2605 if (count == null) {
2606 StringBundler query = new StringBundler();
2607
2608 query.append(_SQL_COUNT_DLFILEENTRYTYPE_WHERE);
2609
2610 boolean conjunctionable = false;
2611
2612 if ((groupIds == null) || (groupIds.length > 0)) {
2613 if (conjunctionable) {
2614 query.append(WHERE_AND);
2615 }
2616
2617 query.append(StringPool.OPEN_PARENTHESIS);
2618
2619 for (int i = 0; i < groupIds.length; i++) {
2620 query.append(_FINDER_COLUMN_GROUPID_GROUPID_5);
2621
2622 if ((i + 1) < groupIds.length) {
2623 query.append(WHERE_OR);
2624 }
2625 }
2626
2627 query.append(StringPool.CLOSE_PARENTHESIS);
2628
2629 conjunctionable = true;
2630 }
2631
2632 String sql = query.toString();
2633
2634 Session session = null;
2635
2636 try {
2637 session = openSession();
2638
2639 Query q = session.createQuery(sql);
2640
2641 QueryPos qPos = QueryPos.getInstance(q);
2642
2643 if (groupIds != null) {
2644 qPos.add(groupIds);
2645 }
2646
2647 count = (Long)q.uniqueResult();
2648 }
2649 catch (Exception e) {
2650 throw processException(e);
2651 }
2652 finally {
2653 if (count == null) {
2654 count = Long.valueOf(0);
2655 }
2656
2657 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_GROUPID,
2658 finderArgs, count);
2659
2660 closeSession(session);
2661 }
2662 }
2663
2664 return count.intValue();
2665 }
2666
2667
2674 public int filterCountByGroupId(long groupId) throws SystemException {
2675 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2676 return countByGroupId(groupId);
2677 }
2678
2679 StringBundler query = new StringBundler(2);
2680
2681 query.append(_FILTER_SQL_COUNT_DLFILEENTRYTYPE_WHERE);
2682
2683 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2684
2685 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2686 DLFileEntryType.class.getName(),
2687 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2688
2689 Session session = null;
2690
2691 try {
2692 session = openSession();
2693
2694 SQLQuery q = session.createSQLQuery(sql);
2695
2696 q.addScalar(COUNT_COLUMN_NAME,
2697 com.liferay.portal.kernel.dao.orm.Type.LONG);
2698
2699 QueryPos qPos = QueryPos.getInstance(q);
2700
2701 qPos.add(groupId);
2702
2703 Long count = (Long)q.uniqueResult();
2704
2705 return count.intValue();
2706 }
2707 catch (Exception e) {
2708 throw processException(e);
2709 }
2710 finally {
2711 closeSession(session);
2712 }
2713 }
2714
2715
2722 public int filterCountByGroupId(long[] groupIds) throws SystemException {
2723 if (!InlineSQLHelperUtil.isEnabled(groupIds)) {
2724 return countByGroupId(groupIds);
2725 }
2726
2727 StringBundler query = new StringBundler();
2728
2729 query.append(_FILTER_SQL_COUNT_DLFILEENTRYTYPE_WHERE);
2730
2731 boolean conjunctionable = false;
2732
2733 if ((groupIds == null) || (groupIds.length > 0)) {
2734 if (conjunctionable) {
2735 query.append(WHERE_AND);
2736 }
2737
2738 query.append(StringPool.OPEN_PARENTHESIS);
2739
2740 for (int i = 0; i < groupIds.length; i++) {
2741 query.append(_FINDER_COLUMN_GROUPID_GROUPID_5);
2742
2743 if ((i + 1) < groupIds.length) {
2744 query.append(WHERE_OR);
2745 }
2746 }
2747
2748 query.append(StringPool.CLOSE_PARENTHESIS);
2749
2750 conjunctionable = true;
2751 }
2752
2753 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2754 DLFileEntryType.class.getName(),
2755 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupIds);
2756
2757 Session session = null;
2758
2759 try {
2760 session = openSession();
2761
2762 SQLQuery q = session.createSQLQuery(sql);
2763
2764 q.addScalar(COUNT_COLUMN_NAME,
2765 com.liferay.portal.kernel.dao.orm.Type.LONG);
2766
2767 QueryPos qPos = QueryPos.getInstance(q);
2768
2769 if (groupIds != null) {
2770 qPos.add(groupIds);
2771 }
2772
2773 Long count = (Long)q.uniqueResult();
2774
2775 return count.intValue();
2776 }
2777 catch (Exception e) {
2778 throw processException(e);
2779 }
2780 finally {
2781 closeSession(session);
2782 }
2783 }
2784
2785
2793 public int countByG_N(long groupId, String name) throws SystemException {
2794 Object[] finderArgs = new Object[] { groupId, name };
2795
2796 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_N,
2797 finderArgs, this);
2798
2799 if (count == null) {
2800 StringBundler query = new StringBundler(3);
2801
2802 query.append(_SQL_COUNT_DLFILEENTRYTYPE_WHERE);
2803
2804 query.append(_FINDER_COLUMN_G_N_GROUPID_2);
2805
2806 if (name == null) {
2807 query.append(_FINDER_COLUMN_G_N_NAME_1);
2808 }
2809 else {
2810 if (name.equals(StringPool.BLANK)) {
2811 query.append(_FINDER_COLUMN_G_N_NAME_3);
2812 }
2813 else {
2814 query.append(_FINDER_COLUMN_G_N_NAME_2);
2815 }
2816 }
2817
2818 String sql = query.toString();
2819
2820 Session session = null;
2821
2822 try {
2823 session = openSession();
2824
2825 Query q = session.createQuery(sql);
2826
2827 QueryPos qPos = QueryPos.getInstance(q);
2828
2829 qPos.add(groupId);
2830
2831 if (name != null) {
2832 qPos.add(name);
2833 }
2834
2835 count = (Long)q.uniqueResult();
2836 }
2837 catch (Exception e) {
2838 throw processException(e);
2839 }
2840 finally {
2841 if (count == null) {
2842 count = Long.valueOf(0);
2843 }
2844
2845 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_N, finderArgs,
2846 count);
2847
2848 closeSession(session);
2849 }
2850 }
2851
2852 return count.intValue();
2853 }
2854
2855
2861 public int countAll() throws SystemException {
2862 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
2863 FINDER_ARGS_EMPTY, this);
2864
2865 if (count == null) {
2866 Session session = null;
2867
2868 try {
2869 session = openSession();
2870
2871 Query q = session.createQuery(_SQL_COUNT_DLFILEENTRYTYPE);
2872
2873 count = (Long)q.uniqueResult();
2874 }
2875 catch (Exception e) {
2876 throw processException(e);
2877 }
2878 finally {
2879 if (count == null) {
2880 count = Long.valueOf(0);
2881 }
2882
2883 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
2884 FINDER_ARGS_EMPTY, count);
2885
2886 closeSession(session);
2887 }
2888 }
2889
2890 return count.intValue();
2891 }
2892
2893
2900 public List<com.liferay.portlet.documentlibrary.model.DLFolder> getDLFolders(
2901 long pk) throws SystemException {
2902 return getDLFolders(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
2903 }
2904
2905
2918 public List<com.liferay.portlet.documentlibrary.model.DLFolder> getDLFolders(
2919 long pk, int start, int end) throws SystemException {
2920 return getDLFolders(pk, start, end, null);
2921 }
2922
2923 public static final FinderPath FINDER_PATH_GET_DLFOLDERS = new FinderPath(com.liferay.portlet.documentlibrary.model.impl.DLFolderModelImpl.ENTITY_CACHE_ENABLED,
2924 DLFileEntryTypeModelImpl.FINDER_CACHE_ENABLED_DLFILEENTRYTYPES_DLFOLDERS,
2925 com.liferay.portlet.documentlibrary.model.impl.DLFolderImpl.class,
2926 DLFileEntryTypeModelImpl.MAPPING_TABLE_DLFILEENTRYTYPES_DLFOLDERS_NAME,
2927 "getDLFolders",
2928 new String[] {
2929 Long.class.getName(), "java.lang.Integer", "java.lang.Integer",
2930 "com.liferay.portal.kernel.util.OrderByComparator"
2931 });
2932
2933
2947 public List<com.liferay.portlet.documentlibrary.model.DLFolder> getDLFolders(
2948 long pk, int start, int end, OrderByComparator orderByComparator)
2949 throws SystemException {
2950 Object[] finderArgs = new Object[] { pk, start, end, orderByComparator };
2951
2952 List<com.liferay.portlet.documentlibrary.model.DLFolder> list = (List<com.liferay.portlet.documentlibrary.model.DLFolder>)FinderCacheUtil.getResult(FINDER_PATH_GET_DLFOLDERS,
2953 finderArgs, this);
2954
2955 if (list == null) {
2956 Session session = null;
2957
2958 try {
2959 session = openSession();
2960
2961 String sql = null;
2962
2963 if (orderByComparator != null) {
2964 sql = _SQL_GETDLFOLDERS.concat(ORDER_BY_CLAUSE)
2965 .concat(orderByComparator.getOrderBy());
2966 }
2967 else {
2968 sql = _SQL_GETDLFOLDERS.concat(com.liferay.portlet.documentlibrary.model.impl.DLFolderModelImpl.ORDER_BY_SQL);
2969 }
2970
2971 SQLQuery q = session.createSQLQuery(sql);
2972
2973 q.addEntity("DLFolder",
2974 com.liferay.portlet.documentlibrary.model.impl.DLFolderImpl.class);
2975
2976 QueryPos qPos = QueryPos.getInstance(q);
2977
2978 qPos.add(pk);
2979
2980 list = (List<com.liferay.portlet.documentlibrary.model.DLFolder>)QueryUtil.list(q,
2981 getDialect(), start, end);
2982 }
2983 catch (Exception e) {
2984 throw processException(e);
2985 }
2986 finally {
2987 if (list == null) {
2988 FinderCacheUtil.removeResult(FINDER_PATH_GET_DLFOLDERS,
2989 finderArgs);
2990 }
2991 else {
2992 dlFolderPersistence.cacheResult(list);
2993
2994 FinderCacheUtil.putResult(FINDER_PATH_GET_DLFOLDERS,
2995 finderArgs, list);
2996 }
2997
2998 closeSession(session);
2999 }
3000 }
3001
3002 return list;
3003 }
3004
3005 public static final FinderPath FINDER_PATH_GET_DLFOLDERS_SIZE = new FinderPath(com.liferay.portlet.documentlibrary.model.impl.DLFolderModelImpl.ENTITY_CACHE_ENABLED,
3006 DLFileEntryTypeModelImpl.FINDER_CACHE_ENABLED_DLFILEENTRYTYPES_DLFOLDERS,
3007 Long.class,
3008 DLFileEntryTypeModelImpl.MAPPING_TABLE_DLFILEENTRYTYPES_DLFOLDERS_NAME,
3009 "getDLFoldersSize", new String[] { Long.class.getName() });
3010
3011
3018 public int getDLFoldersSize(long pk) throws SystemException {
3019 Object[] finderArgs = new Object[] { pk };
3020
3021 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_GET_DLFOLDERS_SIZE,
3022 finderArgs, this);
3023
3024 if (count == null) {
3025 Session session = null;
3026
3027 try {
3028 session = openSession();
3029
3030 SQLQuery q = session.createSQLQuery(_SQL_GETDLFOLDERSSIZE);
3031
3032 q.addScalar(COUNT_COLUMN_NAME,
3033 com.liferay.portal.kernel.dao.orm.Type.LONG);
3034
3035 QueryPos qPos = QueryPos.getInstance(q);
3036
3037 qPos.add(pk);
3038
3039 count = (Long)q.uniqueResult();
3040 }
3041 catch (Exception e) {
3042 throw processException(e);
3043 }
3044 finally {
3045 if (count == null) {
3046 count = Long.valueOf(0);
3047 }
3048
3049 FinderCacheUtil.putResult(FINDER_PATH_GET_DLFOLDERS_SIZE,
3050 finderArgs, count);
3051
3052 closeSession(session);
3053 }
3054 }
3055
3056 return count.intValue();
3057 }
3058
3059 public static final FinderPath FINDER_PATH_CONTAINS_DLFOLDER = new FinderPath(com.liferay.portlet.documentlibrary.model.impl.DLFolderModelImpl.ENTITY_CACHE_ENABLED,
3060 DLFileEntryTypeModelImpl.FINDER_CACHE_ENABLED_DLFILEENTRYTYPES_DLFOLDERS,
3061 Boolean.class,
3062 DLFileEntryTypeModelImpl.MAPPING_TABLE_DLFILEENTRYTYPES_DLFOLDERS_NAME,
3063 "containsDLFolder",
3064 new String[] { Long.class.getName(), Long.class.getName() });
3065
3066
3074 public boolean containsDLFolder(long pk, long dlFolderPK)
3075 throws SystemException {
3076 Object[] finderArgs = new Object[] { pk, dlFolderPK };
3077
3078 Boolean value = (Boolean)FinderCacheUtil.getResult(FINDER_PATH_CONTAINS_DLFOLDER,
3079 finderArgs, this);
3080
3081 if (value == null) {
3082 try {
3083 value = Boolean.valueOf(containsDLFolder.contains(pk, dlFolderPK));
3084 }
3085 catch (Exception e) {
3086 throw processException(e);
3087 }
3088 finally {
3089 if (value == null) {
3090 value = Boolean.FALSE;
3091 }
3092
3093 FinderCacheUtil.putResult(FINDER_PATH_CONTAINS_DLFOLDER,
3094 finderArgs, value);
3095 }
3096 }
3097
3098 return value.booleanValue();
3099 }
3100
3101
3108 public boolean containsDLFolders(long pk) throws SystemException {
3109 if (getDLFoldersSize(pk) > 0) {
3110 return true;
3111 }
3112 else {
3113 return false;
3114 }
3115 }
3116
3117
3124 public void addDLFolder(long pk, long dlFolderPK) throws SystemException {
3125 try {
3126 addDLFolder.add(pk, dlFolderPK);
3127 }
3128 catch (Exception e) {
3129 throw processException(e);
3130 }
3131 finally {
3132 FinderCacheUtil.clearCache(DLFileEntryTypeModelImpl.MAPPING_TABLE_DLFILEENTRYTYPES_DLFOLDERS_NAME);
3133 }
3134 }
3135
3136
3143 public void addDLFolder(long pk,
3144 com.liferay.portlet.documentlibrary.model.DLFolder dlFolder)
3145 throws SystemException {
3146 try {
3147 addDLFolder.add(pk, dlFolder.getPrimaryKey());
3148 }
3149 catch (Exception e) {
3150 throw processException(e);
3151 }
3152 finally {
3153 FinderCacheUtil.clearCache(DLFileEntryTypeModelImpl.MAPPING_TABLE_DLFILEENTRYTYPES_DLFOLDERS_NAME);
3154 }
3155 }
3156
3157
3164 public void addDLFolders(long pk, long[] dlFolderPKs)
3165 throws SystemException {
3166 try {
3167 for (long dlFolderPK : dlFolderPKs) {
3168 addDLFolder.add(pk, dlFolderPK);
3169 }
3170 }
3171 catch (Exception e) {
3172 throw processException(e);
3173 }
3174 finally {
3175 FinderCacheUtil.clearCache(DLFileEntryTypeModelImpl.MAPPING_TABLE_DLFILEENTRYTYPES_DLFOLDERS_NAME);
3176 }
3177 }
3178
3179
3186 public void addDLFolders(long pk,
3187 List<com.liferay.portlet.documentlibrary.model.DLFolder> dlFolders)
3188 throws SystemException {
3189 try {
3190 for (com.liferay.portlet.documentlibrary.model.DLFolder dlFolder : dlFolders) {
3191 addDLFolder.add(pk, dlFolder.getPrimaryKey());
3192 }
3193 }
3194 catch (Exception e) {
3195 throw processException(e);
3196 }
3197 finally {
3198 FinderCacheUtil.clearCache(DLFileEntryTypeModelImpl.MAPPING_TABLE_DLFILEENTRYTYPES_DLFOLDERS_NAME);
3199 }
3200 }
3201
3202
3208 public void clearDLFolders(long pk) throws SystemException {
3209 try {
3210 clearDLFolders.clear(pk);
3211 }
3212 catch (Exception e) {
3213 throw processException(e);
3214 }
3215 finally {
3216 FinderCacheUtil.clearCache(DLFileEntryTypeModelImpl.MAPPING_TABLE_DLFILEENTRYTYPES_DLFOLDERS_NAME);
3217 }
3218 }
3219
3220
3227 public void removeDLFolder(long pk, long dlFolderPK)
3228 throws SystemException {
3229 try {
3230 removeDLFolder.remove(pk, dlFolderPK);
3231 }
3232 catch (Exception e) {
3233 throw processException(e);
3234 }
3235 finally {
3236 FinderCacheUtil.clearCache(DLFileEntryTypeModelImpl.MAPPING_TABLE_DLFILEENTRYTYPES_DLFOLDERS_NAME);
3237 }
3238 }
3239
3240
3247 public void removeDLFolder(long pk,
3248 com.liferay.portlet.documentlibrary.model.DLFolder dlFolder)
3249 throws SystemException {
3250 try {
3251 removeDLFolder.remove(pk, dlFolder.getPrimaryKey());
3252 }
3253 catch (Exception e) {
3254 throw processException(e);
3255 }
3256 finally {
3257 FinderCacheUtil.clearCache(DLFileEntryTypeModelImpl.MAPPING_TABLE_DLFILEENTRYTYPES_DLFOLDERS_NAME);
3258 }
3259 }
3260
3261
3268 public void removeDLFolders(long pk, long[] dlFolderPKs)
3269 throws SystemException {
3270 try {
3271 for (long dlFolderPK : dlFolderPKs) {
3272 removeDLFolder.remove(pk, dlFolderPK);
3273 }
3274 }
3275 catch (Exception e) {
3276 throw processException(e);
3277 }
3278 finally {
3279 FinderCacheUtil.clearCache(DLFileEntryTypeModelImpl.MAPPING_TABLE_DLFILEENTRYTYPES_DLFOLDERS_NAME);
3280 }
3281 }
3282
3283
3290 public void removeDLFolders(long pk,
3291 List<com.liferay.portlet.documentlibrary.model.DLFolder> dlFolders)
3292 throws SystemException {
3293 try {
3294 for (com.liferay.portlet.documentlibrary.model.DLFolder dlFolder : dlFolders) {
3295 removeDLFolder.remove(pk, dlFolder.getPrimaryKey());
3296 }
3297 }
3298 catch (Exception e) {
3299 throw processException(e);
3300 }
3301 finally {
3302 FinderCacheUtil.clearCache(DLFileEntryTypeModelImpl.MAPPING_TABLE_DLFILEENTRYTYPES_DLFOLDERS_NAME);
3303 }
3304 }
3305
3306
3313 public void setDLFolders(long pk, long[] dlFolderPKs)
3314 throws SystemException {
3315 try {
3316 Set<Long> dlFolderPKSet = SetUtil.fromArray(dlFolderPKs);
3317
3318 List<com.liferay.portlet.documentlibrary.model.DLFolder> dlFolders = getDLFolders(pk);
3319
3320 for (com.liferay.portlet.documentlibrary.model.DLFolder dlFolder : dlFolders) {
3321 if (!dlFolderPKSet.remove(dlFolder.getPrimaryKey())) {
3322 removeDLFolder.remove(pk, dlFolder.getPrimaryKey());
3323 }
3324 }
3325
3326 for (Long dlFolderPK : dlFolderPKSet) {
3327 addDLFolder.add(pk, dlFolderPK);
3328 }
3329 }
3330 catch (Exception e) {
3331 throw processException(e);
3332 }
3333 finally {
3334 FinderCacheUtil.clearCache(DLFileEntryTypeModelImpl.MAPPING_TABLE_DLFILEENTRYTYPES_DLFOLDERS_NAME);
3335 }
3336 }
3337
3338
3345 public void setDLFolders(long pk,
3346 List<com.liferay.portlet.documentlibrary.model.DLFolder> dlFolders)
3347 throws SystemException {
3348 try {
3349 long[] dlFolderPKs = new long[dlFolders.size()];
3350
3351 for (int i = 0; i < dlFolders.size(); i++) {
3352 com.liferay.portlet.documentlibrary.model.DLFolder dlFolder = dlFolders.get(i);
3353
3354 dlFolderPKs[i] = dlFolder.getPrimaryKey();
3355 }
3356
3357 setDLFolders(pk, dlFolderPKs);
3358 }
3359 catch (Exception e) {
3360 throw processException(e);
3361 }
3362 finally {
3363 FinderCacheUtil.clearCache(DLFileEntryTypeModelImpl.MAPPING_TABLE_DLFILEENTRYTYPES_DLFOLDERS_NAME);
3364 }
3365 }
3366
3367
3374 public List<com.liferay.portlet.dynamicdatamapping.model.DDMStructure> getDDMStructures(
3375 long pk) throws SystemException {
3376 return getDDMStructures(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
3377 }
3378
3379
3392 public List<com.liferay.portlet.dynamicdatamapping.model.DDMStructure> getDDMStructures(
3393 long pk, int start, int end) throws SystemException {
3394 return getDDMStructures(pk, start, end, null);
3395 }
3396
3397 public static final FinderPath FINDER_PATH_GET_DDMSTRUCTURES = new FinderPath(com.liferay.portlet.dynamicdatamapping.model.impl.DDMStructureModelImpl.ENTITY_CACHE_ENABLED,
3398 DLFileEntryTypeModelImpl.FINDER_CACHE_ENABLED_DLFILEENTRYTYPES_DDMSTRUCTURES,
3399 com.liferay.portlet.dynamicdatamapping.model.impl.DDMStructureImpl.class,
3400 DLFileEntryTypeModelImpl.MAPPING_TABLE_DLFILEENTRYTYPES_DDMSTRUCTURES_NAME,
3401 "getDDMStructures",
3402 new String[] {
3403 Long.class.getName(), "java.lang.Integer", "java.lang.Integer",
3404 "com.liferay.portal.kernel.util.OrderByComparator"
3405 });
3406
3407
3421 public List<com.liferay.portlet.dynamicdatamapping.model.DDMStructure> getDDMStructures(
3422 long pk, int start, int end, OrderByComparator orderByComparator)
3423 throws SystemException {
3424 Object[] finderArgs = new Object[] { pk, start, end, orderByComparator };
3425
3426 List<com.liferay.portlet.dynamicdatamapping.model.DDMStructure> list = (List<com.liferay.portlet.dynamicdatamapping.model.DDMStructure>)FinderCacheUtil.getResult(FINDER_PATH_GET_DDMSTRUCTURES,
3427 finderArgs, this);
3428
3429 if (list == null) {
3430 Session session = null;
3431
3432 try {
3433 session = openSession();
3434
3435 String sql = null;
3436
3437 if (orderByComparator != null) {
3438 sql = _SQL_GETDDMSTRUCTURES.concat(ORDER_BY_CLAUSE)
3439 .concat(orderByComparator.getOrderBy());
3440 }
3441 else {
3442 sql = _SQL_GETDDMSTRUCTURES;
3443 }
3444
3445 SQLQuery q = session.createSQLQuery(sql);
3446
3447 q.addEntity("DDMStructure",
3448 com.liferay.portlet.dynamicdatamapping.model.impl.DDMStructureImpl.class);
3449
3450 QueryPos qPos = QueryPos.getInstance(q);
3451
3452 qPos.add(pk);
3453
3454 list = (List<com.liferay.portlet.dynamicdatamapping.model.DDMStructure>)QueryUtil.list(q,
3455 getDialect(), start, end);
3456 }
3457 catch (Exception e) {
3458 throw processException(e);
3459 }
3460 finally {
3461 if (list == null) {
3462 FinderCacheUtil.removeResult(FINDER_PATH_GET_DDMSTRUCTURES,
3463 finderArgs);
3464 }
3465 else {
3466 ddmStructurePersistence.cacheResult(list);
3467
3468 FinderCacheUtil.putResult(FINDER_PATH_GET_DDMSTRUCTURES,
3469 finderArgs, list);
3470 }
3471
3472 closeSession(session);
3473 }
3474 }
3475
3476 return list;
3477 }
3478
3479 public static final FinderPath FINDER_PATH_GET_DDMSTRUCTURES_SIZE = new FinderPath(com.liferay.portlet.dynamicdatamapping.model.impl.DDMStructureModelImpl.ENTITY_CACHE_ENABLED,
3480 DLFileEntryTypeModelImpl.FINDER_CACHE_ENABLED_DLFILEENTRYTYPES_DDMSTRUCTURES,
3481 Long.class,
3482 DLFileEntryTypeModelImpl.MAPPING_TABLE_DLFILEENTRYTYPES_DDMSTRUCTURES_NAME,
3483 "getDDMStructuresSize", new String[] { Long.class.getName() });
3484
3485
3492 public int getDDMStructuresSize(long pk) throws SystemException {
3493 Object[] finderArgs = new Object[] { pk };
3494
3495 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_GET_DDMSTRUCTURES_SIZE,
3496 finderArgs, this);
3497
3498 if (count == null) {
3499 Session session = null;
3500
3501 try {
3502 session = openSession();
3503
3504 SQLQuery q = session.createSQLQuery(_SQL_GETDDMSTRUCTURESSIZE);
3505
3506 q.addScalar(COUNT_COLUMN_NAME,
3507 com.liferay.portal.kernel.dao.orm.Type.LONG);
3508
3509 QueryPos qPos = QueryPos.getInstance(q);
3510
3511 qPos.add(pk);
3512
3513 count = (Long)q.uniqueResult();
3514 }
3515 catch (Exception e) {
3516 throw processException(e);
3517 }
3518 finally {
3519 if (count == null) {
3520 count = Long.valueOf(0);
3521 }
3522
3523 FinderCacheUtil.putResult(FINDER_PATH_GET_DDMSTRUCTURES_SIZE,
3524 finderArgs, count);
3525
3526 closeSession(session);
3527 }
3528 }
3529
3530 return count.intValue();
3531 }
3532
3533 public static final FinderPath FINDER_PATH_CONTAINS_DDMSTRUCTURE = new FinderPath(com.liferay.portlet.dynamicdatamapping.model.impl.DDMStructureModelImpl.ENTITY_CACHE_ENABLED,
3534 DLFileEntryTypeModelImpl.FINDER_CACHE_ENABLED_DLFILEENTRYTYPES_DDMSTRUCTURES,
3535 Boolean.class,
3536 DLFileEntryTypeModelImpl.MAPPING_TABLE_DLFILEENTRYTYPES_DDMSTRUCTURES_NAME,
3537 "containsDDMStructure",
3538 new String[] { Long.class.getName(), Long.class.getName() });
3539
3540
3548 public boolean containsDDMStructure(long pk, long ddmStructurePK)
3549 throws SystemException {
3550 Object[] finderArgs = new Object[] { pk, ddmStructurePK };
3551
3552 Boolean value = (Boolean)FinderCacheUtil.getResult(FINDER_PATH_CONTAINS_DDMSTRUCTURE,
3553 finderArgs, this);
3554
3555 if (value == null) {
3556 try {
3557 value = Boolean.valueOf(containsDDMStructure.contains(pk,
3558 ddmStructurePK));
3559 }
3560 catch (Exception e) {
3561 throw processException(e);
3562 }
3563 finally {
3564 if (value == null) {
3565 value = Boolean.FALSE;
3566 }
3567
3568 FinderCacheUtil.putResult(FINDER_PATH_CONTAINS_DDMSTRUCTURE,
3569 finderArgs, value);
3570 }
3571 }
3572
3573 return value.booleanValue();
3574 }
3575
3576
3583 public boolean containsDDMStructures(long pk) throws SystemException {
3584 if (getDDMStructuresSize(pk) > 0) {
3585 return true;
3586 }
3587 else {
3588 return false;
3589 }
3590 }
3591
3592
3599 public void addDDMStructure(long pk, long ddmStructurePK)
3600 throws SystemException {
3601 try {
3602 addDDMStructure.add(pk, ddmStructurePK);
3603 }
3604 catch (Exception e) {
3605 throw processException(e);
3606 }
3607 finally {
3608 FinderCacheUtil.clearCache(DLFileEntryTypeModelImpl.MAPPING_TABLE_DLFILEENTRYTYPES_DDMSTRUCTURES_NAME);
3609 }
3610 }
3611
3612
3619 public void addDDMStructure(long pk,
3620 com.liferay.portlet.dynamicdatamapping.model.DDMStructure ddmStructure)
3621 throws SystemException {
3622 try {
3623 addDDMStructure.add(pk, ddmStructure.getPrimaryKey());
3624 }
3625 catch (Exception e) {
3626 throw processException(e);
3627 }
3628 finally {
3629 FinderCacheUtil.clearCache(DLFileEntryTypeModelImpl.MAPPING_TABLE_DLFILEENTRYTYPES_DDMSTRUCTURES_NAME);
3630 }
3631 }
3632
3633
3640 public void addDDMStructures(long pk, long[] ddmStructurePKs)
3641 throws SystemException {
3642 try {
3643 for (long ddmStructurePK : ddmStructurePKs) {
3644 addDDMStructure.add(pk, ddmStructurePK);
3645 }
3646 }
3647 catch (Exception e) {
3648 throw processException(e);
3649 }
3650 finally {
3651 FinderCacheUtil.clearCache(DLFileEntryTypeModelImpl.MAPPING_TABLE_DLFILEENTRYTYPES_DDMSTRUCTURES_NAME);
3652 }
3653 }
3654
3655
3662 public void addDDMStructures(long pk,
3663 List<com.liferay.portlet.dynamicdatamapping.model.DDMStructure> ddmStructures)
3664 throws SystemException {
3665 try {
3666 for (com.liferay.portlet.dynamicdatamapping.model.DDMStructure ddmStructure : ddmStructures) {
3667 addDDMStructure.add(pk, ddmStructure.getPrimaryKey());
3668 }
3669 }
3670 catch (Exception e) {
3671 throw processException(e);
3672 }
3673 finally {
3674 FinderCacheUtil.clearCache(DLFileEntryTypeModelImpl.MAPPING_TABLE_DLFILEENTRYTYPES_DDMSTRUCTURES_NAME);
3675 }
3676 }
3677
3678
3684 public void clearDDMStructures(long pk) throws SystemException {
3685 try {
3686 clearDDMStructures.clear(pk);
3687 }
3688 catch (Exception e) {
3689 throw processException(e);
3690 }
3691 finally {
3692 FinderCacheUtil.clearCache(DLFileEntryTypeModelImpl.MAPPING_TABLE_DLFILEENTRYTYPES_DDMSTRUCTURES_NAME);
3693 }
3694 }
3695
3696
3703 public void removeDDMStructure(long pk, long ddmStructurePK)
3704 throws SystemException {
3705 try {
3706 removeDDMStructure.remove(pk, ddmStructurePK);
3707 }
3708 catch (Exception e) {
3709 throw processException(e);
3710 }
3711 finally {
3712 FinderCacheUtil.clearCache(DLFileEntryTypeModelImpl.MAPPING_TABLE_DLFILEENTRYTYPES_DDMSTRUCTURES_NAME);
3713 }
3714 }
3715
3716
3723 public void removeDDMStructure(long pk,
3724 com.liferay.portlet.dynamicdatamapping.model.DDMStructure ddmStructure)
3725 throws SystemException {
3726 try {
3727 removeDDMStructure.remove(pk, ddmStructure.getPrimaryKey());
3728 }
3729 catch (Exception e) {
3730 throw processException(e);
3731 }
3732 finally {
3733 FinderCacheUtil.clearCache(DLFileEntryTypeModelImpl.MAPPING_TABLE_DLFILEENTRYTYPES_DDMSTRUCTURES_NAME);
3734 }
3735 }
3736
3737
3744 public void removeDDMStructures(long pk, long[] ddmStructurePKs)
3745 throws SystemException {
3746 try {
3747 for (long ddmStructurePK : ddmStructurePKs) {
3748 removeDDMStructure.remove(pk, ddmStructurePK);
3749 }
3750 }
3751 catch (Exception e) {
3752 throw processException(e);
3753 }
3754 finally {
3755 FinderCacheUtil.clearCache(DLFileEntryTypeModelImpl.MAPPING_TABLE_DLFILEENTRYTYPES_DDMSTRUCTURES_NAME);
3756 }
3757 }
3758
3759
3766 public void removeDDMStructures(long pk,
3767 List<com.liferay.portlet.dynamicdatamapping.model.DDMStructure> ddmStructures)
3768 throws SystemException {
3769 try {
3770 for (com.liferay.portlet.dynamicdatamapping.model.DDMStructure ddmStructure : ddmStructures) {
3771 removeDDMStructure.remove(pk, ddmStructure.getPrimaryKey());
3772 }
3773 }
3774 catch (Exception e) {
3775 throw processException(e);
3776 }
3777 finally {
3778 FinderCacheUtil.clearCache(DLFileEntryTypeModelImpl.MAPPING_TABLE_DLFILEENTRYTYPES_DDMSTRUCTURES_NAME);
3779 }
3780 }
3781
3782
3789 public void setDDMStructures(long pk, long[] ddmStructurePKs)
3790 throws SystemException {
3791 try {
3792 Set<Long> ddmStructurePKSet = SetUtil.fromArray(ddmStructurePKs);
3793
3794 List<com.liferay.portlet.dynamicdatamapping.model.DDMStructure> ddmStructures =
3795 getDDMStructures(pk);
3796
3797 for (com.liferay.portlet.dynamicdatamapping.model.DDMStructure ddmStructure : ddmStructures) {
3798 if (!ddmStructurePKSet.remove(ddmStructure.getPrimaryKey())) {
3799 removeDDMStructure.remove(pk, ddmStructure.getPrimaryKey());
3800 }
3801 }
3802
3803 for (Long ddmStructurePK : ddmStructurePKSet) {
3804 addDDMStructure.add(pk, ddmStructurePK);
3805 }
3806 }
3807 catch (Exception e) {
3808 throw processException(e);
3809 }
3810 finally {
3811 FinderCacheUtil.clearCache(DLFileEntryTypeModelImpl.MAPPING_TABLE_DLFILEENTRYTYPES_DDMSTRUCTURES_NAME);
3812 }
3813 }
3814
3815
3822 public void setDDMStructures(long pk,
3823 List<com.liferay.portlet.dynamicdatamapping.model.DDMStructure> ddmStructures)
3824 throws SystemException {
3825 try {
3826 long[] ddmStructurePKs = new long[ddmStructures.size()];
3827
3828 for (int i = 0; i < ddmStructures.size(); i++) {
3829 com.liferay.portlet.dynamicdatamapping.model.DDMStructure ddmStructure =
3830 ddmStructures.get(i);
3831
3832 ddmStructurePKs[i] = ddmStructure.getPrimaryKey();
3833 }
3834
3835 setDDMStructures(pk, ddmStructurePKs);
3836 }
3837 catch (Exception e) {
3838 throw processException(e);
3839 }
3840 finally {
3841 FinderCacheUtil.clearCache(DLFileEntryTypeModelImpl.MAPPING_TABLE_DLFILEENTRYTYPES_DDMSTRUCTURES_NAME);
3842 }
3843 }
3844
3845
3848 public void afterPropertiesSet() {
3849 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
3850 com.liferay.portal.util.PropsUtil.get(
3851 "value.object.listener.com.liferay.portlet.documentlibrary.model.DLFileEntryType")));
3852
3853 if (listenerClassNames.length > 0) {
3854 try {
3855 List<ModelListener<DLFileEntryType>> listenersList = new ArrayList<ModelListener<DLFileEntryType>>();
3856
3857 for (String listenerClassName : listenerClassNames) {
3858 listenersList.add((ModelListener<DLFileEntryType>)InstanceFactory.newInstance(
3859 listenerClassName));
3860 }
3861
3862 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
3863 }
3864 catch (Exception e) {
3865 _log.error(e);
3866 }
3867 }
3868
3869 containsDLFolder = new ContainsDLFolder();
3870
3871 addDLFolder = new AddDLFolder();
3872 clearDLFolders = new ClearDLFolders();
3873 removeDLFolder = new RemoveDLFolder();
3874
3875 containsDDMStructure = new ContainsDDMStructure();
3876
3877 addDDMStructure = new AddDDMStructure();
3878 clearDDMStructures = new ClearDDMStructures();
3879 removeDDMStructure = new RemoveDDMStructure();
3880 }
3881
3882 public void destroy() {
3883 EntityCacheUtil.removeCache(DLFileEntryTypeImpl.class.getName());
3884 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
3885 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
3886 }
3887
3888 @BeanReference(type = DLContentPersistence.class)
3889 protected DLContentPersistence dlContentPersistence;
3890 @BeanReference(type = DLFileEntryPersistence.class)
3891 protected DLFileEntryPersistence dlFileEntryPersistence;
3892 @BeanReference(type = DLFileEntryMetadataPersistence.class)
3893 protected DLFileEntryMetadataPersistence dlFileEntryMetadataPersistence;
3894 @BeanReference(type = DLFileEntryTypePersistence.class)
3895 protected DLFileEntryTypePersistence dlFileEntryTypePersistence;
3896 @BeanReference(type = DLFileRankPersistence.class)
3897 protected DLFileRankPersistence dlFileRankPersistence;
3898 @BeanReference(type = DLFileShortcutPersistence.class)
3899 protected DLFileShortcutPersistence dlFileShortcutPersistence;
3900 @BeanReference(type = DLFileVersionPersistence.class)
3901 protected DLFileVersionPersistence dlFileVersionPersistence;
3902 @BeanReference(type = DLFolderPersistence.class)
3903 protected DLFolderPersistence dlFolderPersistence;
3904 @BeanReference(type = DLSyncPersistence.class)
3905 protected DLSyncPersistence dlSyncPersistence;
3906 @BeanReference(type = ResourcePersistence.class)
3907 protected ResourcePersistence resourcePersistence;
3908 @BeanReference(type = UserPersistence.class)
3909 protected UserPersistence userPersistence;
3910 @BeanReference(type = WorkflowDefinitionLinkPersistence.class)
3911 protected WorkflowDefinitionLinkPersistence workflowDefinitionLinkPersistence;
3912 @BeanReference(type = WorkflowInstanceLinkPersistence.class)
3913 protected WorkflowInstanceLinkPersistence workflowInstanceLinkPersistence;
3914 @BeanReference(type = DDMStructurePersistence.class)
3915 protected DDMStructurePersistence ddmStructurePersistence;
3916 protected ContainsDLFolder containsDLFolder;
3917 protected AddDLFolder addDLFolder;
3918 protected ClearDLFolders clearDLFolders;
3919 protected RemoveDLFolder removeDLFolder;
3920 protected ContainsDDMStructure containsDDMStructure;
3921 protected AddDDMStructure addDDMStructure;
3922 protected ClearDDMStructures clearDDMStructures;
3923 protected RemoveDDMStructure removeDDMStructure;
3924
3925 protected class ContainsDLFolder {
3926 protected ContainsDLFolder() {
3927 _mappingSqlQuery = MappingSqlQueryFactoryUtil.getMappingSqlQuery(getDataSource(),
3928 _SQL_CONTAINSDLFOLDER,
3929 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT },
3930 RowMapper.COUNT);
3931 }
3932
3933 protected boolean contains(long fileEntryTypeId, long folderId) {
3934 List<Integer> results = _mappingSqlQuery.execute(new Object[] {
3935 new Long(fileEntryTypeId), new Long(folderId)
3936 });
3937
3938 if (results.size() > 0) {
3939 Integer count = results.get(0);
3940
3941 if (count.intValue() > 0) {
3942 return true;
3943 }
3944 }
3945
3946 return false;
3947 }
3948
3949 private MappingSqlQuery<Integer> _mappingSqlQuery;
3950 }
3951
3952 protected class AddDLFolder {
3953 protected AddDLFolder() {
3954 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
3955 "INSERT INTO DLFileEntryTypes_DLFolders (fileEntryTypeId, folderId) VALUES (?, ?)",
3956 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
3957 }
3958
3959 protected void add(long fileEntryTypeId, long folderId)
3960 throws SystemException {
3961 if (!containsDLFolder.contains(fileEntryTypeId, folderId)) {
3962 ModelListener<com.liferay.portlet.documentlibrary.model.DLFolder>[] dlFolderListeners =
3963 dlFolderPersistence.getListeners();
3964
3965 for (ModelListener<DLFileEntryType> listener : listeners) {
3966 listener.onBeforeAddAssociation(fileEntryTypeId,
3967 com.liferay.portlet.documentlibrary.model.DLFolder.class.getName(),
3968 folderId);
3969 }
3970
3971 for (ModelListener<com.liferay.portlet.documentlibrary.model.DLFolder> listener : dlFolderListeners) {
3972 listener.onBeforeAddAssociation(folderId,
3973 DLFileEntryType.class.getName(), fileEntryTypeId);
3974 }
3975
3976 _sqlUpdate.update(new Object[] {
3977 new Long(fileEntryTypeId), new Long(folderId)
3978 });
3979
3980 for (ModelListener<DLFileEntryType> listener : listeners) {
3981 listener.onAfterAddAssociation(fileEntryTypeId,
3982 com.liferay.portlet.documentlibrary.model.DLFolder.class.getName(),
3983 folderId);
3984 }
3985
3986 for (ModelListener<com.liferay.portlet.documentlibrary.model.DLFolder> listener : dlFolderListeners) {
3987 listener.onAfterAddAssociation(folderId,
3988 DLFileEntryType.class.getName(), fileEntryTypeId);
3989 }
3990 }
3991 }
3992
3993 private SqlUpdate _sqlUpdate;
3994 }
3995
3996 protected class ClearDLFolders {
3997 protected ClearDLFolders() {
3998 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
3999 "DELETE FROM DLFileEntryTypes_DLFolders WHERE fileEntryTypeId = ?",
4000 new int[] { java.sql.Types.BIGINT });
4001 }
4002
4003 protected void clear(long fileEntryTypeId) throws SystemException {
4004 ModelListener<com.liferay.portlet.documentlibrary.model.DLFolder>[] dlFolderListeners =
4005 dlFolderPersistence.getListeners();
4006
4007 List<com.liferay.portlet.documentlibrary.model.DLFolder> dlFolders = null;
4008
4009 if ((listeners.length > 0) || (dlFolderListeners.length > 0)) {
4010 dlFolders = getDLFolders(fileEntryTypeId);
4011
4012 for (com.liferay.portlet.documentlibrary.model.DLFolder dlFolder : dlFolders) {
4013 for (ModelListener<DLFileEntryType> listener : listeners) {
4014 listener.onBeforeRemoveAssociation(fileEntryTypeId,
4015 com.liferay.portlet.documentlibrary.model.DLFolder.class.getName(),
4016 dlFolder.getPrimaryKey());
4017 }
4018
4019 for (ModelListener<com.liferay.portlet.documentlibrary.model.DLFolder> listener : dlFolderListeners) {
4020 listener.onBeforeRemoveAssociation(dlFolder.getPrimaryKey(),
4021 DLFileEntryType.class.getName(), fileEntryTypeId);
4022 }
4023 }
4024 }
4025
4026 _sqlUpdate.update(new Object[] { new Long(fileEntryTypeId) });
4027
4028 if ((listeners.length > 0) || (dlFolderListeners.length > 0)) {
4029 for (com.liferay.portlet.documentlibrary.model.DLFolder dlFolder : dlFolders) {
4030 for (ModelListener<DLFileEntryType> listener : listeners) {
4031 listener.onAfterRemoveAssociation(fileEntryTypeId,
4032 com.liferay.portlet.documentlibrary.model.DLFolder.class.getName(),
4033 dlFolder.getPrimaryKey());
4034 }
4035
4036 for (ModelListener<com.liferay.portlet.documentlibrary.model.DLFolder> listener : dlFolderListeners) {
4037 listener.onAfterRemoveAssociation(dlFolder.getPrimaryKey(),
4038 DLFileEntryType.class.getName(), fileEntryTypeId);
4039 }
4040 }
4041 }
4042 }
4043
4044 private SqlUpdate _sqlUpdate;
4045 }
4046
4047 protected class RemoveDLFolder {
4048 protected RemoveDLFolder() {
4049 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
4050 "DELETE FROM DLFileEntryTypes_DLFolders WHERE fileEntryTypeId = ? AND folderId = ?",
4051 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
4052 }
4053
4054 protected void remove(long fileEntryTypeId, long folderId)
4055 throws SystemException {
4056 if (containsDLFolder.contains(fileEntryTypeId, folderId)) {
4057 ModelListener<com.liferay.portlet.documentlibrary.model.DLFolder>[] dlFolderListeners =
4058 dlFolderPersistence.getListeners();
4059
4060 for (ModelListener<DLFileEntryType> listener : listeners) {
4061 listener.onBeforeRemoveAssociation(fileEntryTypeId,
4062 com.liferay.portlet.documentlibrary.model.DLFolder.class.getName(),
4063 folderId);
4064 }
4065
4066 for (ModelListener<com.liferay.portlet.documentlibrary.model.DLFolder> listener : dlFolderListeners) {
4067 listener.onBeforeRemoveAssociation(folderId,
4068 DLFileEntryType.class.getName(), fileEntryTypeId);
4069 }
4070
4071 _sqlUpdate.update(new Object[] {
4072 new Long(fileEntryTypeId), new Long(folderId)
4073 });
4074
4075 for (ModelListener<DLFileEntryType> listener : listeners) {
4076 listener.onAfterRemoveAssociation(fileEntryTypeId,
4077 com.liferay.portlet.documentlibrary.model.DLFolder.class.getName(),
4078 folderId);
4079 }
4080
4081 for (ModelListener<com.liferay.portlet.documentlibrary.model.DLFolder> listener : dlFolderListeners) {
4082 listener.onAfterRemoveAssociation(folderId,
4083 DLFileEntryType.class.getName(), fileEntryTypeId);
4084 }
4085 }
4086 }
4087
4088 private SqlUpdate _sqlUpdate;
4089 }
4090
4091 protected class ContainsDDMStructure {
4092 protected ContainsDDMStructure() {
4093 _mappingSqlQuery = MappingSqlQueryFactoryUtil.getMappingSqlQuery(getDataSource(),
4094 _SQL_CONTAINSDDMSTRUCTURE,
4095 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT },
4096 RowMapper.COUNT);
4097 }
4098
4099 protected boolean contains(long fileEntryTypeId, long structureId) {
4100 List<Integer> results = _mappingSqlQuery.execute(new Object[] {
4101 new Long(fileEntryTypeId), new Long(structureId)
4102 });
4103
4104 if (results.size() > 0) {
4105 Integer count = results.get(0);
4106
4107 if (count.intValue() > 0) {
4108 return true;
4109 }
4110 }
4111
4112 return false;
4113 }
4114
4115 private MappingSqlQuery<Integer> _mappingSqlQuery;
4116 }
4117
4118 protected class AddDDMStructure {
4119 protected AddDDMStructure() {
4120 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
4121 "INSERT INTO DLFileEntryTypes_DDMStructures (fileEntryTypeId, structureId) VALUES (?, ?)",
4122 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
4123 }
4124
4125 protected void add(long fileEntryTypeId, long structureId)
4126 throws SystemException {
4127 if (!containsDDMStructure.contains(fileEntryTypeId, structureId)) {
4128 ModelListener<com.liferay.portlet.dynamicdatamapping.model.DDMStructure>[] ddmStructureListeners =
4129 ddmStructurePersistence.getListeners();
4130
4131 for (ModelListener<DLFileEntryType> listener : listeners) {
4132 listener.onBeforeAddAssociation(fileEntryTypeId,
4133 com.liferay.portlet.dynamicdatamapping.model.DDMStructure.class.getName(),
4134 structureId);
4135 }
4136
4137 for (ModelListener<com.liferay.portlet.dynamicdatamapping.model.DDMStructure> listener : ddmStructureListeners) {
4138 listener.onBeforeAddAssociation(structureId,
4139 DLFileEntryType.class.getName(), fileEntryTypeId);
4140 }
4141
4142 _sqlUpdate.update(new Object[] {
4143 new Long(fileEntryTypeId), new Long(structureId)
4144 });
4145
4146 for (ModelListener<DLFileEntryType> listener : listeners) {
4147 listener.onAfterAddAssociation(fileEntryTypeId,
4148 com.liferay.portlet.dynamicdatamapping.model.DDMStructure.class.getName(),
4149 structureId);
4150 }
4151
4152 for (ModelListener<com.liferay.portlet.dynamicdatamapping.model.DDMStructure> listener : ddmStructureListeners) {
4153 listener.onAfterAddAssociation(structureId,
4154 DLFileEntryType.class.getName(), fileEntryTypeId);
4155 }
4156 }
4157 }
4158
4159 private SqlUpdate _sqlUpdate;
4160 }
4161
4162 protected class ClearDDMStructures {
4163 protected ClearDDMStructures() {
4164 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
4165 "DELETE FROM DLFileEntryTypes_DDMStructures WHERE fileEntryTypeId = ?",
4166 new int[] { java.sql.Types.BIGINT });
4167 }
4168
4169 protected void clear(long fileEntryTypeId) throws SystemException {
4170 ModelListener<com.liferay.portlet.dynamicdatamapping.model.DDMStructure>[] ddmStructureListeners =
4171 ddmStructurePersistence.getListeners();
4172
4173 List<com.liferay.portlet.dynamicdatamapping.model.DDMStructure> ddmStructures =
4174 null;
4175
4176 if ((listeners.length > 0) || (ddmStructureListeners.length > 0)) {
4177 ddmStructures = getDDMStructures(fileEntryTypeId);
4178
4179 for (com.liferay.portlet.dynamicdatamapping.model.DDMStructure ddmStructure : ddmStructures) {
4180 for (ModelListener<DLFileEntryType> listener : listeners) {
4181 listener.onBeforeRemoveAssociation(fileEntryTypeId,
4182 com.liferay.portlet.dynamicdatamapping.model.DDMStructure.class.getName(),
4183 ddmStructure.getPrimaryKey());
4184 }
4185
4186 for (ModelListener<com.liferay.portlet.dynamicdatamapping.model.DDMStructure> listener : ddmStructureListeners) {
4187 listener.onBeforeRemoveAssociation(ddmStructure.getPrimaryKey(),
4188 DLFileEntryType.class.getName(), fileEntryTypeId);
4189 }
4190 }
4191 }
4192
4193 _sqlUpdate.update(new Object[] { new Long(fileEntryTypeId) });
4194
4195 if ((listeners.length > 0) || (ddmStructureListeners.length > 0)) {
4196 for (com.liferay.portlet.dynamicdatamapping.model.DDMStructure ddmStructure : ddmStructures) {
4197 for (ModelListener<DLFileEntryType> listener : listeners) {
4198 listener.onAfterRemoveAssociation(fileEntryTypeId,
4199 com.liferay.portlet.dynamicdatamapping.model.DDMStructure.class.getName(),
4200 ddmStructure.getPrimaryKey());
4201 }
4202
4203 for (ModelListener<com.liferay.portlet.dynamicdatamapping.model.DDMStructure> listener : ddmStructureListeners) {
4204 listener.onAfterRemoveAssociation(ddmStructure.getPrimaryKey(),
4205 DLFileEntryType.class.getName(), fileEntryTypeId);
4206 }
4207 }
4208 }
4209 }
4210
4211 private SqlUpdate _sqlUpdate;
4212 }
4213
4214 protected class RemoveDDMStructure {
4215 protected RemoveDDMStructure() {
4216 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
4217 "DELETE FROM DLFileEntryTypes_DDMStructures WHERE fileEntryTypeId = ? AND structureId = ?",
4218 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
4219 }
4220
4221 protected void remove(long fileEntryTypeId, long structureId)
4222 throws SystemException {
4223 if (containsDDMStructure.contains(fileEntryTypeId, structureId)) {
4224 ModelListener<com.liferay.portlet.dynamicdatamapping.model.DDMStructure>[] ddmStructureListeners =
4225 ddmStructurePersistence.getListeners();
4226
4227 for (ModelListener<DLFileEntryType> listener : listeners) {
4228 listener.onBeforeRemoveAssociation(fileEntryTypeId,
4229 com.liferay.portlet.dynamicdatamapping.model.DDMStructure.class.getName(),
4230 structureId);
4231 }
4232
4233 for (ModelListener<com.liferay.portlet.dynamicdatamapping.model.DDMStructure> listener : ddmStructureListeners) {
4234 listener.onBeforeRemoveAssociation(structureId,
4235 DLFileEntryType.class.getName(), fileEntryTypeId);
4236 }
4237
4238 _sqlUpdate.update(new Object[] {
4239 new Long(fileEntryTypeId), new Long(structureId)
4240 });
4241
4242 for (ModelListener<DLFileEntryType> listener : listeners) {
4243 listener.onAfterRemoveAssociation(fileEntryTypeId,
4244 com.liferay.portlet.dynamicdatamapping.model.DDMStructure.class.getName(),
4245 structureId);
4246 }
4247
4248 for (ModelListener<com.liferay.portlet.dynamicdatamapping.model.DDMStructure> listener : ddmStructureListeners) {
4249 listener.onAfterRemoveAssociation(structureId,
4250 DLFileEntryType.class.getName(), fileEntryTypeId);
4251 }
4252 }
4253 }
4254
4255 private SqlUpdate _sqlUpdate;
4256 }
4257
4258 private static final String _SQL_SELECT_DLFILEENTRYTYPE = "SELECT dlFileEntryType FROM DLFileEntryType dlFileEntryType";
4259 private static final String _SQL_SELECT_DLFILEENTRYTYPE_WHERE = "SELECT dlFileEntryType FROM DLFileEntryType dlFileEntryType WHERE ";
4260 private static final String _SQL_COUNT_DLFILEENTRYTYPE = "SELECT COUNT(dlFileEntryType) FROM DLFileEntryType dlFileEntryType";
4261 private static final String _SQL_COUNT_DLFILEENTRYTYPE_WHERE = "SELECT COUNT(dlFileEntryType) FROM DLFileEntryType dlFileEntryType WHERE ";
4262 private static final String _SQL_GETDLFOLDERS = "SELECT {DLFolder.*} FROM DLFolder INNER JOIN DLFileEntryTypes_DLFolders ON (DLFileEntryTypes_DLFolders.folderId = DLFolder.folderId) WHERE (DLFileEntryTypes_DLFolders.fileEntryTypeId = ?)";
4263 private static final String _SQL_GETDLFOLDERSSIZE = "SELECT COUNT(*) AS COUNT_VALUE FROM DLFileEntryTypes_DLFolders WHERE fileEntryTypeId = ?";
4264 private static final String _SQL_CONTAINSDLFOLDER = "SELECT COUNT(*) AS COUNT_VALUE FROM DLFileEntryTypes_DLFolders WHERE fileEntryTypeId = ? AND folderId = ?";
4265 private static final String _SQL_GETDDMSTRUCTURES = "SELECT {DDMStructure.*} FROM DDMStructure INNER JOIN DLFileEntryTypes_DDMStructures ON (DLFileEntryTypes_DDMStructures.structureId = DDMStructure.structureId) WHERE (DLFileEntryTypes_DDMStructures.fileEntryTypeId = ?)";
4266 private static final String _SQL_GETDDMSTRUCTURESSIZE = "SELECT COUNT(*) AS COUNT_VALUE FROM DLFileEntryTypes_DDMStructures WHERE fileEntryTypeId = ?";
4267 private static final String _SQL_CONTAINSDDMSTRUCTURE = "SELECT COUNT(*) AS COUNT_VALUE FROM DLFileEntryTypes_DDMStructures WHERE fileEntryTypeId = ? AND structureId = ?";
4268 private static final String _FINDER_COLUMN_UUID_UUID_1 = "dlFileEntryType.uuid IS NULL";
4269 private static final String _FINDER_COLUMN_UUID_UUID_2 = "dlFileEntryType.uuid = ?";
4270 private static final String _FINDER_COLUMN_UUID_UUID_3 = "(dlFileEntryType.uuid IS NULL OR dlFileEntryType.uuid = ?)";
4271 private static final String _FINDER_COLUMN_UUID_G_UUID_1 = "dlFileEntryType.uuid IS NULL AND ";
4272 private static final String _FINDER_COLUMN_UUID_G_UUID_2 = "dlFileEntryType.uuid = ? AND ";
4273 private static final String _FINDER_COLUMN_UUID_G_UUID_3 = "(dlFileEntryType.uuid IS NULL OR dlFileEntryType.uuid = ?) AND ";
4274 private static final String _FINDER_COLUMN_UUID_G_GROUPID_2 = "dlFileEntryType.groupId = ?";
4275 private static final String _FINDER_COLUMN_GROUPID_GROUPID_2 = "dlFileEntryType.groupId = ?";
4276 private static final String _FINDER_COLUMN_GROUPID_GROUPID_5 = "(" +
4277 _removeConjunction(_FINDER_COLUMN_GROUPID_GROUPID_2) + ")";
4278 private static final String _FINDER_COLUMN_G_N_GROUPID_2 = "dlFileEntryType.groupId = ? AND ";
4279 private static final String _FINDER_COLUMN_G_N_NAME_1 = "dlFileEntryType.name IS NULL";
4280 private static final String _FINDER_COLUMN_G_N_NAME_2 = "dlFileEntryType.name = ?";
4281 private static final String _FINDER_COLUMN_G_N_NAME_3 = "(dlFileEntryType.name IS NULL OR dlFileEntryType.name = ?)";
4282
4283 private static String _removeConjunction(String sql) {
4284 int pos = sql.indexOf(" AND ");
4285
4286 if (pos != -1) {
4287 sql = sql.substring(0, pos);
4288 }
4289
4290 return sql;
4291 }
4292
4293 private static final String _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN = "dlFileEntryType.fileEntryTypeId";
4294 private static final String _FILTER_SQL_SELECT_DLFILEENTRYTYPE_WHERE = "SELECT DISTINCT {dlFileEntryType.*} FROM DLFileEntryType dlFileEntryType WHERE ";
4295 private static final String _FILTER_SQL_SELECT_DLFILEENTRYTYPE_NO_INLINE_DISTINCT_WHERE_1 =
4296 "SELECT {DLFileEntryType.*} FROM (SELECT DISTINCT dlFileEntryType.fileEntryTypeId FROM DLFileEntryType dlFileEntryType WHERE ";
4297 private static final String _FILTER_SQL_SELECT_DLFILEENTRYTYPE_NO_INLINE_DISTINCT_WHERE_2 =
4298 ") TEMP_TABLE INNER JOIN DLFileEntryType ON TEMP_TABLE.fileEntryTypeId = DLFileEntryType.fileEntryTypeId";
4299 private static final String _FILTER_SQL_COUNT_DLFILEENTRYTYPE_WHERE = "SELECT COUNT(DISTINCT dlFileEntryType.fileEntryTypeId) AS COUNT_VALUE FROM DLFileEntryType dlFileEntryType WHERE ";
4300 private static final String _FILTER_ENTITY_ALIAS = "dlFileEntryType";
4301 private static final String _FILTER_ENTITY_TABLE = "DLFileEntryType";
4302 private static final String _ORDER_BY_ENTITY_ALIAS = "dlFileEntryType.";
4303 private static final String _ORDER_BY_ENTITY_TABLE = "DLFileEntryType.";
4304 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No DLFileEntryType exists with the primary key ";
4305 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No DLFileEntryType exists with the key {";
4306 private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
4307 private static Log _log = LogFactoryUtil.getLog(DLFileEntryTypePersistenceImpl.class);
4308 private static DLFileEntryType _nullDLFileEntryType = new DLFileEntryTypeImpl() {
4309 @Override
4310 public Object clone() {
4311 return this;
4312 }
4313
4314 @Override
4315 public CacheModel<DLFileEntryType> toCacheModel() {
4316 return _nullDLFileEntryTypeCacheModel;
4317 }
4318 };
4319
4320 private static CacheModel<DLFileEntryType> _nullDLFileEntryTypeCacheModel = new CacheModel<DLFileEntryType>() {
4321 public DLFileEntryType toEntityModel() {
4322 return _nullDLFileEntryType;
4323 }
4324 };
4325 }