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 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
247 new Object[] {
248 dlFileEntryType.getUuid(),
249 Long.valueOf(dlFileEntryType.getGroupId())
250 });
251
252 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_N,
253 new Object[] {
254 Long.valueOf(dlFileEntryType.getGroupId()),
255
256 dlFileEntryType.getName()
257 });
258 }
259
260
266 public DLFileEntryType create(long fileEntryTypeId) {
267 DLFileEntryType dlFileEntryType = new DLFileEntryTypeImpl();
268
269 dlFileEntryType.setNew(true);
270 dlFileEntryType.setPrimaryKey(fileEntryTypeId);
271
272 String uuid = PortalUUIDUtil.generate();
273
274 dlFileEntryType.setUuid(uuid);
275
276 return dlFileEntryType;
277 }
278
279
287 @Override
288 public DLFileEntryType remove(Serializable primaryKey)
289 throws NoSuchModelException, SystemException {
290 return remove(((Long)primaryKey).longValue());
291 }
292
293
301 public DLFileEntryType remove(long fileEntryTypeId)
302 throws NoSuchFileEntryTypeException, SystemException {
303 Session session = null;
304
305 try {
306 session = openSession();
307
308 DLFileEntryType dlFileEntryType = (DLFileEntryType)session.get(DLFileEntryTypeImpl.class,
309 Long.valueOf(fileEntryTypeId));
310
311 if (dlFileEntryType == null) {
312 if (_log.isWarnEnabled()) {
313 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
314 fileEntryTypeId);
315 }
316
317 throw new NoSuchFileEntryTypeException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
318 fileEntryTypeId);
319 }
320
321 return dlFileEntryTypePersistence.remove(dlFileEntryType);
322 }
323 catch (NoSuchFileEntryTypeException nsee) {
324 throw nsee;
325 }
326 catch (Exception e) {
327 throw processException(e);
328 }
329 finally {
330 closeSession(session);
331 }
332 }
333
334
341 @Override
342 public DLFileEntryType remove(DLFileEntryType dlFileEntryType)
343 throws SystemException {
344 return super.remove(dlFileEntryType);
345 }
346
347 @Override
348 protected DLFileEntryType removeImpl(DLFileEntryType dlFileEntryType)
349 throws SystemException {
350 dlFileEntryType = toUnwrappedModel(dlFileEntryType);
351
352 try {
353 clearDLFolders.clear(dlFileEntryType.getPrimaryKey());
354 }
355 catch (Exception e) {
356 throw processException(e);
357 }
358 finally {
359 FinderCacheUtil.clearCache(DLFileEntryTypeModelImpl.MAPPING_TABLE_DLFILEENTRYTYPES_DLFOLDERS_NAME);
360 }
361
362 try {
363 clearDDMStructures.clear(dlFileEntryType.getPrimaryKey());
364 }
365 catch (Exception e) {
366 throw processException(e);
367 }
368 finally {
369 FinderCacheUtil.clearCache(DLFileEntryTypeModelImpl.MAPPING_TABLE_DLFILEENTRYTYPES_DDMSTRUCTURES_NAME);
370 }
371
372 Session session = null;
373
374 try {
375 session = openSession();
376
377 BatchSessionUtil.delete(session, dlFileEntryType);
378 }
379 catch (Exception e) {
380 throw processException(e);
381 }
382 finally {
383 closeSession(session);
384 }
385
386 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
387 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
388
389 DLFileEntryTypeModelImpl dlFileEntryTypeModelImpl = (DLFileEntryTypeModelImpl)dlFileEntryType;
390
391 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
392 new Object[] {
393 dlFileEntryTypeModelImpl.getUuid(),
394 Long.valueOf(dlFileEntryTypeModelImpl.getGroupId())
395 });
396
397 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_N,
398 new Object[] {
399 Long.valueOf(dlFileEntryTypeModelImpl.getGroupId()),
400
401 dlFileEntryTypeModelImpl.getName()
402 });
403
404 EntityCacheUtil.removeResult(DLFileEntryTypeModelImpl.ENTITY_CACHE_ENABLED,
405 DLFileEntryTypeImpl.class, dlFileEntryType.getPrimaryKey());
406
407 return dlFileEntryType;
408 }
409
410 @Override
411 public DLFileEntryType updateImpl(
412 com.liferay.portlet.documentlibrary.model.DLFileEntryType dlFileEntryType,
413 boolean merge) throws SystemException {
414 dlFileEntryType = toUnwrappedModel(dlFileEntryType);
415
416 boolean isNew = dlFileEntryType.isNew();
417
418 DLFileEntryTypeModelImpl dlFileEntryTypeModelImpl = (DLFileEntryTypeModelImpl)dlFileEntryType;
419
420 if (Validator.isNull(dlFileEntryType.getUuid())) {
421 String uuid = PortalUUIDUtil.generate();
422
423 dlFileEntryType.setUuid(uuid);
424 }
425
426 Session session = null;
427
428 try {
429 session = openSession();
430
431 BatchSessionUtil.update(session, dlFileEntryType, merge);
432
433 dlFileEntryType.setNew(false);
434 }
435 catch (Exception e) {
436 throw processException(e);
437 }
438 finally {
439 closeSession(session);
440 }
441
442 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
443
444 if (isNew || !DLFileEntryTypeModelImpl.COLUMN_BITMASK_ENABLED) {
445 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
446 }
447
448 else {
449 if ((dlFileEntryTypeModelImpl.getColumnBitmask() &
450 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID.getColumnBitmask()) != 0) {
451 Object[] args = new Object[] {
452 dlFileEntryTypeModelImpl.getOriginalUuid()
453 };
454
455 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
456 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
457 args);
458
459 args = new Object[] { dlFileEntryTypeModelImpl.getUuid() };
460
461 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
462 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
463 args);
464 }
465
466 if ((dlFileEntryTypeModelImpl.getColumnBitmask() &
467 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID.getColumnBitmask()) != 0) {
468 Object[] args = new Object[] {
469 Long.valueOf(dlFileEntryTypeModelImpl.getOriginalGroupId())
470 };
471
472 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
473 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
474 args);
475
476 args = new Object[] {
477 Long.valueOf(dlFileEntryTypeModelImpl.getGroupId())
478 };
479
480 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
481 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
482 args);
483 }
484 }
485
486 EntityCacheUtil.putResult(DLFileEntryTypeModelImpl.ENTITY_CACHE_ENABLED,
487 DLFileEntryTypeImpl.class, dlFileEntryType.getPrimaryKey(),
488 dlFileEntryType);
489
490 if (isNew) {
491 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
492 new Object[] {
493 dlFileEntryType.getUuid(),
494 Long.valueOf(dlFileEntryType.getGroupId())
495 }, dlFileEntryType);
496
497 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_N,
498 new Object[] {
499 Long.valueOf(dlFileEntryType.getGroupId()),
500
501 dlFileEntryType.getName()
502 }, dlFileEntryType);
503 }
504 else {
505 if ((dlFileEntryTypeModelImpl.getColumnBitmask() &
506 FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) {
507 Object[] args = new Object[] {
508 dlFileEntryTypeModelImpl.getOriginalUuid(),
509 Long.valueOf(dlFileEntryTypeModelImpl.getOriginalGroupId())
510 };
511
512 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args);
513 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args);
514
515 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
516 new Object[] {
517 dlFileEntryType.getUuid(),
518 Long.valueOf(dlFileEntryType.getGroupId())
519 }, dlFileEntryType);
520 }
521
522 if ((dlFileEntryTypeModelImpl.getColumnBitmask() &
523 FINDER_PATH_FETCH_BY_G_N.getColumnBitmask()) != 0) {
524 Object[] args = new Object[] {
525 Long.valueOf(dlFileEntryTypeModelImpl.getOriginalGroupId()),
526
527 dlFileEntryTypeModelImpl.getOriginalName()
528 };
529
530 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_N, args);
531 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_N, args);
532
533 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_N,
534 new Object[] {
535 Long.valueOf(dlFileEntryType.getGroupId()),
536
537 dlFileEntryType.getName()
538 }, dlFileEntryType);
539 }
540 }
541
542 return dlFileEntryType;
543 }
544
545 protected DLFileEntryType toUnwrappedModel(DLFileEntryType dlFileEntryType) {
546 if (dlFileEntryType instanceof DLFileEntryTypeImpl) {
547 return dlFileEntryType;
548 }
549
550 DLFileEntryTypeImpl dlFileEntryTypeImpl = new DLFileEntryTypeImpl();
551
552 dlFileEntryTypeImpl.setNew(dlFileEntryType.isNew());
553 dlFileEntryTypeImpl.setPrimaryKey(dlFileEntryType.getPrimaryKey());
554
555 dlFileEntryTypeImpl.setUuid(dlFileEntryType.getUuid());
556 dlFileEntryTypeImpl.setFileEntryTypeId(dlFileEntryType.getFileEntryTypeId());
557 dlFileEntryTypeImpl.setGroupId(dlFileEntryType.getGroupId());
558 dlFileEntryTypeImpl.setCompanyId(dlFileEntryType.getCompanyId());
559 dlFileEntryTypeImpl.setUserId(dlFileEntryType.getUserId());
560 dlFileEntryTypeImpl.setUserName(dlFileEntryType.getUserName());
561 dlFileEntryTypeImpl.setCreateDate(dlFileEntryType.getCreateDate());
562 dlFileEntryTypeImpl.setModifiedDate(dlFileEntryType.getModifiedDate());
563 dlFileEntryTypeImpl.setName(dlFileEntryType.getName());
564 dlFileEntryTypeImpl.setDescription(dlFileEntryType.getDescription());
565
566 return dlFileEntryTypeImpl;
567 }
568
569
577 @Override
578 public DLFileEntryType findByPrimaryKey(Serializable primaryKey)
579 throws NoSuchModelException, SystemException {
580 return findByPrimaryKey(((Long)primaryKey).longValue());
581 }
582
583
591 public DLFileEntryType findByPrimaryKey(long fileEntryTypeId)
592 throws NoSuchFileEntryTypeException, SystemException {
593 DLFileEntryType dlFileEntryType = fetchByPrimaryKey(fileEntryTypeId);
594
595 if (dlFileEntryType == null) {
596 if (_log.isWarnEnabled()) {
597 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + fileEntryTypeId);
598 }
599
600 throw new NoSuchFileEntryTypeException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
601 fileEntryTypeId);
602 }
603
604 return dlFileEntryType;
605 }
606
607
614 @Override
615 public DLFileEntryType fetchByPrimaryKey(Serializable primaryKey)
616 throws SystemException {
617 return fetchByPrimaryKey(((Long)primaryKey).longValue());
618 }
619
620
627 public DLFileEntryType fetchByPrimaryKey(long fileEntryTypeId)
628 throws SystemException {
629 DLFileEntryType dlFileEntryType = (DLFileEntryType)EntityCacheUtil.getResult(DLFileEntryTypeModelImpl.ENTITY_CACHE_ENABLED,
630 DLFileEntryTypeImpl.class, fileEntryTypeId);
631
632 if (dlFileEntryType == _nullDLFileEntryType) {
633 return null;
634 }
635
636 if (dlFileEntryType == null) {
637 Session session = null;
638
639 boolean hasException = false;
640
641 try {
642 session = openSession();
643
644 dlFileEntryType = (DLFileEntryType)session.get(DLFileEntryTypeImpl.class,
645 Long.valueOf(fileEntryTypeId));
646 }
647 catch (Exception e) {
648 hasException = true;
649
650 throw processException(e);
651 }
652 finally {
653 if (dlFileEntryType != null) {
654 cacheResult(dlFileEntryType);
655 }
656 else if (!hasException) {
657 EntityCacheUtil.putResult(DLFileEntryTypeModelImpl.ENTITY_CACHE_ENABLED,
658 DLFileEntryTypeImpl.class, fileEntryTypeId,
659 _nullDLFileEntryType);
660 }
661
662 closeSession(session);
663 }
664 }
665
666 return dlFileEntryType;
667 }
668
669
676 public List<DLFileEntryType> findByUuid(String uuid)
677 throws SystemException {
678 return findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
679 }
680
681
694 public List<DLFileEntryType> findByUuid(String uuid, int start, int end)
695 throws SystemException {
696 return findByUuid(uuid, start, end, null);
697 }
698
699
713 public List<DLFileEntryType> findByUuid(String uuid, int start, int end,
714 OrderByComparator orderByComparator) throws SystemException {
715 FinderPath finderPath = null;
716 Object[] finderArgs = null;
717
718 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
719 (orderByComparator == null)) {
720 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID;
721 finderArgs = new Object[] { uuid };
722 }
723 else {
724 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID;
725 finderArgs = new Object[] { uuid, start, end, orderByComparator };
726 }
727
728 List<DLFileEntryType> list = (List<DLFileEntryType>)FinderCacheUtil.getResult(finderPath,
729 finderArgs, this);
730
731 if (list == null) {
732 StringBundler query = null;
733
734 if (orderByComparator != null) {
735 query = new StringBundler(3 +
736 (orderByComparator.getOrderByFields().length * 3));
737 }
738 else {
739 query = new StringBundler(2);
740 }
741
742 query.append(_SQL_SELECT_DLFILEENTRYTYPE_WHERE);
743
744 if (uuid == null) {
745 query.append(_FINDER_COLUMN_UUID_UUID_1);
746 }
747 else {
748 if (uuid.equals(StringPool.BLANK)) {
749 query.append(_FINDER_COLUMN_UUID_UUID_3);
750 }
751 else {
752 query.append(_FINDER_COLUMN_UUID_UUID_2);
753 }
754 }
755
756 if (orderByComparator != null) {
757 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
758 orderByComparator);
759 }
760
761 String sql = query.toString();
762
763 Session session = null;
764
765 try {
766 session = openSession();
767
768 Query q = session.createQuery(sql);
769
770 QueryPos qPos = QueryPos.getInstance(q);
771
772 if (uuid != null) {
773 qPos.add(uuid);
774 }
775
776 list = (List<DLFileEntryType>)QueryUtil.list(q, getDialect(),
777 start, end);
778 }
779 catch (Exception e) {
780 throw processException(e);
781 }
782 finally {
783 if (list == null) {
784 FinderCacheUtil.removeResult(finderPath, finderArgs);
785 }
786 else {
787 cacheResult(list);
788
789 FinderCacheUtil.putResult(finderPath, finderArgs, list);
790 }
791
792 closeSession(session);
793 }
794 }
795
796 return list;
797 }
798
799
812 public DLFileEntryType findByUuid_First(String uuid,
813 OrderByComparator orderByComparator)
814 throws NoSuchFileEntryTypeException, SystemException {
815 List<DLFileEntryType> list = findByUuid(uuid, 0, 1, orderByComparator);
816
817 if (list.isEmpty()) {
818 StringBundler msg = new StringBundler(4);
819
820 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
821
822 msg.append("uuid=");
823 msg.append(uuid);
824
825 msg.append(StringPool.CLOSE_CURLY_BRACE);
826
827 throw new NoSuchFileEntryTypeException(msg.toString());
828 }
829 else {
830 return list.get(0);
831 }
832 }
833
834
847 public DLFileEntryType findByUuid_Last(String uuid,
848 OrderByComparator orderByComparator)
849 throws NoSuchFileEntryTypeException, SystemException {
850 int count = countByUuid(uuid);
851
852 List<DLFileEntryType> list = findByUuid(uuid, count - 1, count,
853 orderByComparator);
854
855 if (list.isEmpty()) {
856 StringBundler msg = new StringBundler(4);
857
858 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
859
860 msg.append("uuid=");
861 msg.append(uuid);
862
863 msg.append(StringPool.CLOSE_CURLY_BRACE);
864
865 throw new NoSuchFileEntryTypeException(msg.toString());
866 }
867 else {
868 return list.get(0);
869 }
870 }
871
872
886 public DLFileEntryType[] findByUuid_PrevAndNext(long fileEntryTypeId,
887 String uuid, OrderByComparator orderByComparator)
888 throws NoSuchFileEntryTypeException, SystemException {
889 DLFileEntryType dlFileEntryType = findByPrimaryKey(fileEntryTypeId);
890
891 Session session = null;
892
893 try {
894 session = openSession();
895
896 DLFileEntryType[] array = new DLFileEntryTypeImpl[3];
897
898 array[0] = getByUuid_PrevAndNext(session, dlFileEntryType, uuid,
899 orderByComparator, true);
900
901 array[1] = dlFileEntryType;
902
903 array[2] = getByUuid_PrevAndNext(session, dlFileEntryType, uuid,
904 orderByComparator, false);
905
906 return array;
907 }
908 catch (Exception e) {
909 throw processException(e);
910 }
911 finally {
912 closeSession(session);
913 }
914 }
915
916 protected DLFileEntryType getByUuid_PrevAndNext(Session session,
917 DLFileEntryType dlFileEntryType, String uuid,
918 OrderByComparator orderByComparator, boolean previous) {
919 StringBundler query = null;
920
921 if (orderByComparator != null) {
922 query = new StringBundler(6 +
923 (orderByComparator.getOrderByFields().length * 6));
924 }
925 else {
926 query = new StringBundler(3);
927 }
928
929 query.append(_SQL_SELECT_DLFILEENTRYTYPE_WHERE);
930
931 if (uuid == null) {
932 query.append(_FINDER_COLUMN_UUID_UUID_1);
933 }
934 else {
935 if (uuid.equals(StringPool.BLANK)) {
936 query.append(_FINDER_COLUMN_UUID_UUID_3);
937 }
938 else {
939 query.append(_FINDER_COLUMN_UUID_UUID_2);
940 }
941 }
942
943 if (orderByComparator != null) {
944 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
945
946 if (orderByConditionFields.length > 0) {
947 query.append(WHERE_AND);
948 }
949
950 for (int i = 0; i < orderByConditionFields.length; i++) {
951 query.append(_ORDER_BY_ENTITY_ALIAS);
952 query.append(orderByConditionFields[i]);
953
954 if ((i + 1) < orderByConditionFields.length) {
955 if (orderByComparator.isAscending() ^ previous) {
956 query.append(WHERE_GREATER_THAN_HAS_NEXT);
957 }
958 else {
959 query.append(WHERE_LESSER_THAN_HAS_NEXT);
960 }
961 }
962 else {
963 if (orderByComparator.isAscending() ^ previous) {
964 query.append(WHERE_GREATER_THAN);
965 }
966 else {
967 query.append(WHERE_LESSER_THAN);
968 }
969 }
970 }
971
972 query.append(ORDER_BY_CLAUSE);
973
974 String[] orderByFields = orderByComparator.getOrderByFields();
975
976 for (int i = 0; i < orderByFields.length; i++) {
977 query.append(_ORDER_BY_ENTITY_ALIAS);
978 query.append(orderByFields[i]);
979
980 if ((i + 1) < orderByFields.length) {
981 if (orderByComparator.isAscending() ^ previous) {
982 query.append(ORDER_BY_ASC_HAS_NEXT);
983 }
984 else {
985 query.append(ORDER_BY_DESC_HAS_NEXT);
986 }
987 }
988 else {
989 if (orderByComparator.isAscending() ^ previous) {
990 query.append(ORDER_BY_ASC);
991 }
992 else {
993 query.append(ORDER_BY_DESC);
994 }
995 }
996 }
997 }
998
999 String sql = query.toString();
1000
1001 Query q = session.createQuery(sql);
1002
1003 q.setFirstResult(0);
1004 q.setMaxResults(2);
1005
1006 QueryPos qPos = QueryPos.getInstance(q);
1007
1008 if (uuid != null) {
1009 qPos.add(uuid);
1010 }
1011
1012 if (orderByComparator != null) {
1013 Object[] values = orderByComparator.getOrderByConditionValues(dlFileEntryType);
1014
1015 for (Object value : values) {
1016 qPos.add(value);
1017 }
1018 }
1019
1020 List<DLFileEntryType> list = q.list();
1021
1022 if (list.size() == 2) {
1023 return list.get(1);
1024 }
1025 else {
1026 return null;
1027 }
1028 }
1029
1030
1039 public DLFileEntryType findByUUID_G(String uuid, long groupId)
1040 throws NoSuchFileEntryTypeException, SystemException {
1041 DLFileEntryType dlFileEntryType = fetchByUUID_G(uuid, groupId);
1042
1043 if (dlFileEntryType == null) {
1044 StringBundler msg = new StringBundler(6);
1045
1046 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1047
1048 msg.append("uuid=");
1049 msg.append(uuid);
1050
1051 msg.append(", groupId=");
1052 msg.append(groupId);
1053
1054 msg.append(StringPool.CLOSE_CURLY_BRACE);
1055
1056 if (_log.isWarnEnabled()) {
1057 _log.warn(msg.toString());
1058 }
1059
1060 throw new NoSuchFileEntryTypeException(msg.toString());
1061 }
1062
1063 return dlFileEntryType;
1064 }
1065
1066
1074 public DLFileEntryType fetchByUUID_G(String uuid, long groupId)
1075 throws SystemException {
1076 return fetchByUUID_G(uuid, groupId, true);
1077 }
1078
1079
1088 public DLFileEntryType fetchByUUID_G(String uuid, long groupId,
1089 boolean retrieveFromCache) throws SystemException {
1090 Object[] finderArgs = new Object[] { uuid, groupId };
1091
1092 Object result = null;
1093
1094 if (retrieveFromCache) {
1095 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_UUID_G,
1096 finderArgs, this);
1097 }
1098
1099 if (result == null) {
1100 StringBundler query = new StringBundler(3);
1101
1102 query.append(_SQL_SELECT_DLFILEENTRYTYPE_WHERE);
1103
1104 if (uuid == null) {
1105 query.append(_FINDER_COLUMN_UUID_G_UUID_1);
1106 }
1107 else {
1108 if (uuid.equals(StringPool.BLANK)) {
1109 query.append(_FINDER_COLUMN_UUID_G_UUID_3);
1110 }
1111 else {
1112 query.append(_FINDER_COLUMN_UUID_G_UUID_2);
1113 }
1114 }
1115
1116 query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
1117
1118 String sql = query.toString();
1119
1120 Session session = null;
1121
1122 try {
1123 session = openSession();
1124
1125 Query q = session.createQuery(sql);
1126
1127 QueryPos qPos = QueryPos.getInstance(q);
1128
1129 if (uuid != null) {
1130 qPos.add(uuid);
1131 }
1132
1133 qPos.add(groupId);
1134
1135 List<DLFileEntryType> list = q.list();
1136
1137 result = list;
1138
1139 DLFileEntryType dlFileEntryType = null;
1140
1141 if (list.isEmpty()) {
1142 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
1143 finderArgs, list);
1144 }
1145 else {
1146 dlFileEntryType = list.get(0);
1147
1148 cacheResult(dlFileEntryType);
1149
1150 if ((dlFileEntryType.getUuid() == null) ||
1151 !dlFileEntryType.getUuid().equals(uuid) ||
1152 (dlFileEntryType.getGroupId() != groupId)) {
1153 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
1154 finderArgs, dlFileEntryType);
1155 }
1156 }
1157
1158 return dlFileEntryType;
1159 }
1160 catch (Exception e) {
1161 throw processException(e);
1162 }
1163 finally {
1164 if (result == null) {
1165 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
1166 finderArgs);
1167 }
1168
1169 closeSession(session);
1170 }
1171 }
1172 else {
1173 if (result instanceof List<?>) {
1174 return null;
1175 }
1176 else {
1177 return (DLFileEntryType)result;
1178 }
1179 }
1180 }
1181
1182
1189 public List<DLFileEntryType> findByGroupId(long groupId)
1190 throws SystemException {
1191 return findByGroupId(groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1192 }
1193
1194
1207 public List<DLFileEntryType> findByGroupId(long groupId, int start, int end)
1208 throws SystemException {
1209 return findByGroupId(groupId, start, end, null);
1210 }
1211
1212
1226 public List<DLFileEntryType> findByGroupId(long groupId, int start,
1227 int end, OrderByComparator orderByComparator) throws SystemException {
1228 FinderPath finderPath = null;
1229 Object[] finderArgs = null;
1230
1231 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1232 (orderByComparator == null)) {
1233 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID;
1234 finderArgs = new Object[] { groupId };
1235 }
1236 else {
1237 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID;
1238 finderArgs = new Object[] { groupId, start, end, orderByComparator };
1239 }
1240
1241 List<DLFileEntryType> list = (List<DLFileEntryType>)FinderCacheUtil.getResult(finderPath,
1242 finderArgs, this);
1243
1244 if (list == null) {
1245 StringBundler query = null;
1246
1247 if (orderByComparator != null) {
1248 query = new StringBundler(3 +
1249 (orderByComparator.getOrderByFields().length * 3));
1250 }
1251 else {
1252 query = new StringBundler(2);
1253 }
1254
1255 query.append(_SQL_SELECT_DLFILEENTRYTYPE_WHERE);
1256
1257 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1258
1259 if (orderByComparator != null) {
1260 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1261 orderByComparator);
1262 }
1263
1264 String sql = query.toString();
1265
1266 Session session = null;
1267
1268 try {
1269 session = openSession();
1270
1271 Query q = session.createQuery(sql);
1272
1273 QueryPos qPos = QueryPos.getInstance(q);
1274
1275 qPos.add(groupId);
1276
1277 list = (List<DLFileEntryType>)QueryUtil.list(q, getDialect(),
1278 start, end);
1279 }
1280 catch (Exception e) {
1281 throw processException(e);
1282 }
1283 finally {
1284 if (list == null) {
1285 FinderCacheUtil.removeResult(finderPath, finderArgs);
1286 }
1287 else {
1288 cacheResult(list);
1289
1290 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1291 }
1292
1293 closeSession(session);
1294 }
1295 }
1296
1297 return list;
1298 }
1299
1300
1313 public DLFileEntryType findByGroupId_First(long groupId,
1314 OrderByComparator orderByComparator)
1315 throws NoSuchFileEntryTypeException, SystemException {
1316 List<DLFileEntryType> list = findByGroupId(groupId, 0, 1,
1317 orderByComparator);
1318
1319 if (list.isEmpty()) {
1320 StringBundler msg = new StringBundler(4);
1321
1322 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1323
1324 msg.append("groupId=");
1325 msg.append(groupId);
1326
1327 msg.append(StringPool.CLOSE_CURLY_BRACE);
1328
1329 throw new NoSuchFileEntryTypeException(msg.toString());
1330 }
1331 else {
1332 return list.get(0);
1333 }
1334 }
1335
1336
1349 public DLFileEntryType findByGroupId_Last(long groupId,
1350 OrderByComparator orderByComparator)
1351 throws NoSuchFileEntryTypeException, SystemException {
1352 int count = countByGroupId(groupId);
1353
1354 List<DLFileEntryType> list = findByGroupId(groupId, count - 1, count,
1355 orderByComparator);
1356
1357 if (list.isEmpty()) {
1358 StringBundler msg = new StringBundler(4);
1359
1360 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1361
1362 msg.append("groupId=");
1363 msg.append(groupId);
1364
1365 msg.append(StringPool.CLOSE_CURLY_BRACE);
1366
1367 throw new NoSuchFileEntryTypeException(msg.toString());
1368 }
1369 else {
1370 return list.get(0);
1371 }
1372 }
1373
1374
1388 public DLFileEntryType[] findByGroupId_PrevAndNext(long fileEntryTypeId,
1389 long groupId, OrderByComparator orderByComparator)
1390 throws NoSuchFileEntryTypeException, SystemException {
1391 DLFileEntryType dlFileEntryType = findByPrimaryKey(fileEntryTypeId);
1392
1393 Session session = null;
1394
1395 try {
1396 session = openSession();
1397
1398 DLFileEntryType[] array = new DLFileEntryTypeImpl[3];
1399
1400 array[0] = getByGroupId_PrevAndNext(session, dlFileEntryType,
1401 groupId, orderByComparator, true);
1402
1403 array[1] = dlFileEntryType;
1404
1405 array[2] = getByGroupId_PrevAndNext(session, dlFileEntryType,
1406 groupId, orderByComparator, false);
1407
1408 return array;
1409 }
1410 catch (Exception e) {
1411 throw processException(e);
1412 }
1413 finally {
1414 closeSession(session);
1415 }
1416 }
1417
1418 protected DLFileEntryType getByGroupId_PrevAndNext(Session session,
1419 DLFileEntryType dlFileEntryType, long groupId,
1420 OrderByComparator orderByComparator, boolean previous) {
1421 StringBundler query = null;
1422
1423 if (orderByComparator != null) {
1424 query = new StringBundler(6 +
1425 (orderByComparator.getOrderByFields().length * 6));
1426 }
1427 else {
1428 query = new StringBundler(3);
1429 }
1430
1431 query.append(_SQL_SELECT_DLFILEENTRYTYPE_WHERE);
1432
1433 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1434
1435 if (orderByComparator != null) {
1436 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1437
1438 if (orderByConditionFields.length > 0) {
1439 query.append(WHERE_AND);
1440 }
1441
1442 for (int i = 0; i < orderByConditionFields.length; i++) {
1443 query.append(_ORDER_BY_ENTITY_ALIAS);
1444 query.append(orderByConditionFields[i]);
1445
1446 if ((i + 1) < orderByConditionFields.length) {
1447 if (orderByComparator.isAscending() ^ previous) {
1448 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1449 }
1450 else {
1451 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1452 }
1453 }
1454 else {
1455 if (orderByComparator.isAscending() ^ previous) {
1456 query.append(WHERE_GREATER_THAN);
1457 }
1458 else {
1459 query.append(WHERE_LESSER_THAN);
1460 }
1461 }
1462 }
1463
1464 query.append(ORDER_BY_CLAUSE);
1465
1466 String[] orderByFields = orderByComparator.getOrderByFields();
1467
1468 for (int i = 0; i < orderByFields.length; i++) {
1469 query.append(_ORDER_BY_ENTITY_ALIAS);
1470 query.append(orderByFields[i]);
1471
1472 if ((i + 1) < orderByFields.length) {
1473 if (orderByComparator.isAscending() ^ previous) {
1474 query.append(ORDER_BY_ASC_HAS_NEXT);
1475 }
1476 else {
1477 query.append(ORDER_BY_DESC_HAS_NEXT);
1478 }
1479 }
1480 else {
1481 if (orderByComparator.isAscending() ^ previous) {
1482 query.append(ORDER_BY_ASC);
1483 }
1484 else {
1485 query.append(ORDER_BY_DESC);
1486 }
1487 }
1488 }
1489 }
1490
1491 String sql = query.toString();
1492
1493 Query q = session.createQuery(sql);
1494
1495 q.setFirstResult(0);
1496 q.setMaxResults(2);
1497
1498 QueryPos qPos = QueryPos.getInstance(q);
1499
1500 qPos.add(groupId);
1501
1502 if (orderByComparator != null) {
1503 Object[] values = orderByComparator.getOrderByConditionValues(dlFileEntryType);
1504
1505 for (Object value : values) {
1506 qPos.add(value);
1507 }
1508 }
1509
1510 List<DLFileEntryType> list = q.list();
1511
1512 if (list.size() == 2) {
1513 return list.get(1);
1514 }
1515 else {
1516 return null;
1517 }
1518 }
1519
1520
1531 public List<DLFileEntryType> findByGroupId(long[] groupIds)
1532 throws SystemException {
1533 return findByGroupId(groupIds, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
1534 null);
1535 }
1536
1537
1550 public List<DLFileEntryType> findByGroupId(long[] groupIds, int start,
1551 int end) throws SystemException {
1552 return findByGroupId(groupIds, start, end, null);
1553 }
1554
1555
1569 public List<DLFileEntryType> findByGroupId(long[] groupIds, int start,
1570 int end, OrderByComparator orderByComparator) throws SystemException {
1571 FinderPath finderPath = null;
1572 Object[] finderArgs = null;
1573
1574 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1575 (orderByComparator == null)) {
1576 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID;
1577 finderArgs = new Object[] { StringUtil.merge(groupIds) };
1578 }
1579 else {
1580 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID;
1581 finderArgs = new Object[] {
1582 StringUtil.merge(groupIds),
1583
1584 start, end, orderByComparator
1585 };
1586 }
1587
1588 List<DLFileEntryType> list = (List<DLFileEntryType>)FinderCacheUtil.getResult(finderPath,
1589 finderArgs, this);
1590
1591 if (list == null) {
1592 StringBundler query = new StringBundler();
1593
1594 query.append(_SQL_SELECT_DLFILEENTRYTYPE_WHERE);
1595
1596 boolean conjunctionable = false;
1597
1598 if ((groupIds == null) || (groupIds.length > 0)) {
1599 if (conjunctionable) {
1600 query.append(WHERE_AND);
1601 }
1602
1603 query.append(StringPool.OPEN_PARENTHESIS);
1604
1605 for (int i = 0; i < groupIds.length; i++) {
1606 query.append(_FINDER_COLUMN_GROUPID_GROUPID_5);
1607
1608 if ((i + 1) < groupIds.length) {
1609 query.append(WHERE_OR);
1610 }
1611 }
1612
1613 query.append(StringPool.CLOSE_PARENTHESIS);
1614
1615 conjunctionable = true;
1616 }
1617
1618 if (orderByComparator != null) {
1619 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1620 orderByComparator);
1621 }
1622
1623 String sql = query.toString();
1624
1625 Session session = null;
1626
1627 try {
1628 session = openSession();
1629
1630 Query q = session.createQuery(sql);
1631
1632 QueryPos qPos = QueryPos.getInstance(q);
1633
1634 if (groupIds != null) {
1635 qPos.add(groupIds);
1636 }
1637
1638 list = (List<DLFileEntryType>)QueryUtil.list(q, getDialect(),
1639 start, end);
1640 }
1641 catch (Exception e) {
1642 throw processException(e);
1643 }
1644 finally {
1645 if (list == null) {
1646 FinderCacheUtil.removeResult(finderPath, finderArgs);
1647 }
1648 else {
1649 cacheResult(list);
1650
1651 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1652 }
1653
1654 closeSession(session);
1655 }
1656 }
1657
1658 return list;
1659 }
1660
1661
1668 public List<DLFileEntryType> filterFindByGroupId(long groupId)
1669 throws SystemException {
1670 return filterFindByGroupId(groupId, QueryUtil.ALL_POS,
1671 QueryUtil.ALL_POS, null);
1672 }
1673
1674
1687 public List<DLFileEntryType> filterFindByGroupId(long groupId, int start,
1688 int end) throws SystemException {
1689 return filterFindByGroupId(groupId, start, end, null);
1690 }
1691
1692
1706 public List<DLFileEntryType> filterFindByGroupId(long groupId, int start,
1707 int end, OrderByComparator orderByComparator) throws SystemException {
1708 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
1709 return findByGroupId(groupId, start, end, orderByComparator);
1710 }
1711
1712 StringBundler query = null;
1713
1714 if (orderByComparator != null) {
1715 query = new StringBundler(3 +
1716 (orderByComparator.getOrderByFields().length * 3));
1717 }
1718 else {
1719 query = new StringBundler(2);
1720 }
1721
1722 if (getDB().isSupportsInlineDistinct()) {
1723 query.append(_FILTER_SQL_SELECT_DLFILEENTRYTYPE_WHERE);
1724 }
1725 else {
1726 query.append(_FILTER_SQL_SELECT_DLFILEENTRYTYPE_NO_INLINE_DISTINCT_WHERE_1);
1727 }
1728
1729 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1730
1731 if (!getDB().isSupportsInlineDistinct()) {
1732 query.append(_FILTER_SQL_SELECT_DLFILEENTRYTYPE_NO_INLINE_DISTINCT_WHERE_2);
1733 }
1734
1735 if (orderByComparator != null) {
1736 if (getDB().isSupportsInlineDistinct()) {
1737 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1738 orderByComparator);
1739 }
1740 else {
1741 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
1742 orderByComparator);
1743 }
1744 }
1745
1746 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1747 DLFileEntryType.class.getName(),
1748 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
1749
1750 Session session = null;
1751
1752 try {
1753 session = openSession();
1754
1755 SQLQuery q = session.createSQLQuery(sql);
1756
1757 if (getDB().isSupportsInlineDistinct()) {
1758 q.addEntity(_FILTER_ENTITY_ALIAS, DLFileEntryTypeImpl.class);
1759 }
1760 else {
1761 q.addEntity(_FILTER_ENTITY_TABLE, DLFileEntryTypeImpl.class);
1762 }
1763
1764 QueryPos qPos = QueryPos.getInstance(q);
1765
1766 qPos.add(groupId);
1767
1768 return (List<DLFileEntryType>)QueryUtil.list(q, getDialect(),
1769 start, end);
1770 }
1771 catch (Exception e) {
1772 throw processException(e);
1773 }
1774 finally {
1775 closeSession(session);
1776 }
1777 }
1778
1779
1789 public DLFileEntryType[] filterFindByGroupId_PrevAndNext(
1790 long fileEntryTypeId, long groupId, OrderByComparator orderByComparator)
1791 throws NoSuchFileEntryTypeException, SystemException {
1792 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
1793 return findByGroupId_PrevAndNext(fileEntryTypeId, groupId,
1794 orderByComparator);
1795 }
1796
1797 DLFileEntryType dlFileEntryType = findByPrimaryKey(fileEntryTypeId);
1798
1799 Session session = null;
1800
1801 try {
1802 session = openSession();
1803
1804 DLFileEntryType[] array = new DLFileEntryTypeImpl[3];
1805
1806 array[0] = filterGetByGroupId_PrevAndNext(session, dlFileEntryType,
1807 groupId, orderByComparator, true);
1808
1809 array[1] = dlFileEntryType;
1810
1811 array[2] = filterGetByGroupId_PrevAndNext(session, dlFileEntryType,
1812 groupId, orderByComparator, false);
1813
1814 return array;
1815 }
1816 catch (Exception e) {
1817 throw processException(e);
1818 }
1819 finally {
1820 closeSession(session);
1821 }
1822 }
1823
1824 protected DLFileEntryType filterGetByGroupId_PrevAndNext(Session session,
1825 DLFileEntryType dlFileEntryType, long groupId,
1826 OrderByComparator orderByComparator, boolean previous) {
1827 StringBundler query = null;
1828
1829 if (orderByComparator != null) {
1830 query = new StringBundler(6 +
1831 (orderByComparator.getOrderByFields().length * 6));
1832 }
1833 else {
1834 query = new StringBundler(3);
1835 }
1836
1837 if (getDB().isSupportsInlineDistinct()) {
1838 query.append(_FILTER_SQL_SELECT_DLFILEENTRYTYPE_WHERE);
1839 }
1840 else {
1841 query.append(_FILTER_SQL_SELECT_DLFILEENTRYTYPE_NO_INLINE_DISTINCT_WHERE_1);
1842 }
1843
1844 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1845
1846 if (!getDB().isSupportsInlineDistinct()) {
1847 query.append(_FILTER_SQL_SELECT_DLFILEENTRYTYPE_NO_INLINE_DISTINCT_WHERE_2);
1848 }
1849
1850 if (orderByComparator != null) {
1851 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1852
1853 if (orderByConditionFields.length > 0) {
1854 query.append(WHERE_AND);
1855 }
1856
1857 for (int i = 0; i < orderByConditionFields.length; i++) {
1858 if (getDB().isSupportsInlineDistinct()) {
1859 query.append(_ORDER_BY_ENTITY_ALIAS);
1860 }
1861 else {
1862 query.append(_ORDER_BY_ENTITY_TABLE);
1863 }
1864
1865 query.append(orderByConditionFields[i]);
1866
1867 if ((i + 1) < orderByConditionFields.length) {
1868 if (orderByComparator.isAscending() ^ previous) {
1869 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1870 }
1871 else {
1872 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1873 }
1874 }
1875 else {
1876 if (orderByComparator.isAscending() ^ previous) {
1877 query.append(WHERE_GREATER_THAN);
1878 }
1879 else {
1880 query.append(WHERE_LESSER_THAN);
1881 }
1882 }
1883 }
1884
1885 query.append(ORDER_BY_CLAUSE);
1886
1887 String[] orderByFields = orderByComparator.getOrderByFields();
1888
1889 for (int i = 0; i < orderByFields.length; i++) {
1890 if (getDB().isSupportsInlineDistinct()) {
1891 query.append(_ORDER_BY_ENTITY_ALIAS);
1892 }
1893 else {
1894 query.append(_ORDER_BY_ENTITY_TABLE);
1895 }
1896
1897 query.append(orderByFields[i]);
1898
1899 if ((i + 1) < orderByFields.length) {
1900 if (orderByComparator.isAscending() ^ previous) {
1901 query.append(ORDER_BY_ASC_HAS_NEXT);
1902 }
1903 else {
1904 query.append(ORDER_BY_DESC_HAS_NEXT);
1905 }
1906 }
1907 else {
1908 if (orderByComparator.isAscending() ^ previous) {
1909 query.append(ORDER_BY_ASC);
1910 }
1911 else {
1912 query.append(ORDER_BY_DESC);
1913 }
1914 }
1915 }
1916 }
1917
1918 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1919 DLFileEntryType.class.getName(),
1920 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
1921
1922 SQLQuery q = session.createSQLQuery(sql);
1923
1924 q.setFirstResult(0);
1925 q.setMaxResults(2);
1926
1927 if (getDB().isSupportsInlineDistinct()) {
1928 q.addEntity(_FILTER_ENTITY_ALIAS, DLFileEntryTypeImpl.class);
1929 }
1930 else {
1931 q.addEntity(_FILTER_ENTITY_TABLE, DLFileEntryTypeImpl.class);
1932 }
1933
1934 QueryPos qPos = QueryPos.getInstance(q);
1935
1936 qPos.add(groupId);
1937
1938 if (orderByComparator != null) {
1939 Object[] values = orderByComparator.getOrderByConditionValues(dlFileEntryType);
1940
1941 for (Object value : values) {
1942 qPos.add(value);
1943 }
1944 }
1945
1946 List<DLFileEntryType> list = q.list();
1947
1948 if (list.size() == 2) {
1949 return list.get(1);
1950 }
1951 else {
1952 return null;
1953 }
1954 }
1955
1956
1963 public List<DLFileEntryType> filterFindByGroupId(long[] groupIds)
1964 throws SystemException {
1965 return filterFindByGroupId(groupIds, QueryUtil.ALL_POS,
1966 QueryUtil.ALL_POS, null);
1967 }
1968
1969
1982 public List<DLFileEntryType> filterFindByGroupId(long[] groupIds,
1983 int start, int end) throws SystemException {
1984 return filterFindByGroupId(groupIds, start, end, null);
1985 }
1986
1987
2001 public List<DLFileEntryType> filterFindByGroupId(long[] groupIds,
2002 int start, int end, OrderByComparator orderByComparator)
2003 throws SystemException {
2004 if (!InlineSQLHelperUtil.isEnabled(groupIds)) {
2005 return findByGroupId(groupIds, start, end, orderByComparator);
2006 }
2007
2008 StringBundler query = new StringBundler();
2009
2010 if (getDB().isSupportsInlineDistinct()) {
2011 query.append(_FILTER_SQL_SELECT_DLFILEENTRYTYPE_WHERE);
2012 }
2013 else {
2014 query.append(_FILTER_SQL_SELECT_DLFILEENTRYTYPE_NO_INLINE_DISTINCT_WHERE_1);
2015 }
2016
2017 boolean conjunctionable = false;
2018
2019 if ((groupIds == null) || (groupIds.length > 0)) {
2020 if (conjunctionable) {
2021 query.append(WHERE_AND);
2022 }
2023
2024 query.append(StringPool.OPEN_PARENTHESIS);
2025
2026 for (int i = 0; i < groupIds.length; i++) {
2027 query.append(_FINDER_COLUMN_GROUPID_GROUPID_5);
2028
2029 if ((i + 1) < groupIds.length) {
2030 query.append(WHERE_OR);
2031 }
2032 }
2033
2034 query.append(StringPool.CLOSE_PARENTHESIS);
2035
2036 conjunctionable = true;
2037 }
2038
2039 if (!getDB().isSupportsInlineDistinct()) {
2040 query.append(_FILTER_SQL_SELECT_DLFILEENTRYTYPE_NO_INLINE_DISTINCT_WHERE_2);
2041 }
2042
2043 if (orderByComparator != null) {
2044 if (getDB().isSupportsInlineDistinct()) {
2045 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2046 orderByComparator);
2047 }
2048 else {
2049 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
2050 orderByComparator);
2051 }
2052 }
2053
2054 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2055 DLFileEntryType.class.getName(),
2056 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupIds);
2057
2058 Session session = null;
2059
2060 try {
2061 session = openSession();
2062
2063 SQLQuery q = session.createSQLQuery(sql);
2064
2065 if (getDB().isSupportsInlineDistinct()) {
2066 q.addEntity(_FILTER_ENTITY_ALIAS, DLFileEntryTypeImpl.class);
2067 }
2068 else {
2069 q.addEntity(_FILTER_ENTITY_TABLE, DLFileEntryTypeImpl.class);
2070 }
2071
2072 QueryPos qPos = QueryPos.getInstance(q);
2073
2074 if (groupIds != null) {
2075 qPos.add(groupIds);
2076 }
2077
2078 return (List<DLFileEntryType>)QueryUtil.list(q, getDialect(),
2079 start, end);
2080 }
2081 catch (Exception e) {
2082 throw processException(e);
2083 }
2084 finally {
2085 closeSession(session);
2086 }
2087 }
2088
2089
2098 public DLFileEntryType findByG_N(long groupId, String name)
2099 throws NoSuchFileEntryTypeException, SystemException {
2100 DLFileEntryType dlFileEntryType = fetchByG_N(groupId, name);
2101
2102 if (dlFileEntryType == null) {
2103 StringBundler msg = new StringBundler(6);
2104
2105 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2106
2107 msg.append("groupId=");
2108 msg.append(groupId);
2109
2110 msg.append(", name=");
2111 msg.append(name);
2112
2113 msg.append(StringPool.CLOSE_CURLY_BRACE);
2114
2115 if (_log.isWarnEnabled()) {
2116 _log.warn(msg.toString());
2117 }
2118
2119 throw new NoSuchFileEntryTypeException(msg.toString());
2120 }
2121
2122 return dlFileEntryType;
2123 }
2124
2125
2133 public DLFileEntryType fetchByG_N(long groupId, String name)
2134 throws SystemException {
2135 return fetchByG_N(groupId, name, true);
2136 }
2137
2138
2147 public DLFileEntryType fetchByG_N(long groupId, String name,
2148 boolean retrieveFromCache) throws SystemException {
2149 Object[] finderArgs = new Object[] { groupId, name };
2150
2151 Object result = null;
2152
2153 if (retrieveFromCache) {
2154 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_G_N,
2155 finderArgs, this);
2156 }
2157
2158 if (result == null) {
2159 StringBundler query = new StringBundler(3);
2160
2161 query.append(_SQL_SELECT_DLFILEENTRYTYPE_WHERE);
2162
2163 query.append(_FINDER_COLUMN_G_N_GROUPID_2);
2164
2165 if (name == null) {
2166 query.append(_FINDER_COLUMN_G_N_NAME_1);
2167 }
2168 else {
2169 if (name.equals(StringPool.BLANK)) {
2170 query.append(_FINDER_COLUMN_G_N_NAME_3);
2171 }
2172 else {
2173 query.append(_FINDER_COLUMN_G_N_NAME_2);
2174 }
2175 }
2176
2177 String sql = query.toString();
2178
2179 Session session = null;
2180
2181 try {
2182 session = openSession();
2183
2184 Query q = session.createQuery(sql);
2185
2186 QueryPos qPos = QueryPos.getInstance(q);
2187
2188 qPos.add(groupId);
2189
2190 if (name != null) {
2191 qPos.add(name);
2192 }
2193
2194 List<DLFileEntryType> list = q.list();
2195
2196 result = list;
2197
2198 DLFileEntryType dlFileEntryType = null;
2199
2200 if (list.isEmpty()) {
2201 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_N,
2202 finderArgs, list);
2203 }
2204 else {
2205 dlFileEntryType = list.get(0);
2206
2207 cacheResult(dlFileEntryType);
2208
2209 if ((dlFileEntryType.getGroupId() != groupId) ||
2210 (dlFileEntryType.getName() == null) ||
2211 !dlFileEntryType.getName().equals(name)) {
2212 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_N,
2213 finderArgs, dlFileEntryType);
2214 }
2215 }
2216
2217 return dlFileEntryType;
2218 }
2219 catch (Exception e) {
2220 throw processException(e);
2221 }
2222 finally {
2223 if (result == null) {
2224 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_N,
2225 finderArgs);
2226 }
2227
2228 closeSession(session);
2229 }
2230 }
2231 else {
2232 if (result instanceof List<?>) {
2233 return null;
2234 }
2235 else {
2236 return (DLFileEntryType)result;
2237 }
2238 }
2239 }
2240
2241
2247 public List<DLFileEntryType> findAll() throws SystemException {
2248 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
2249 }
2250
2251
2263 public List<DLFileEntryType> findAll(int start, int end)
2264 throws SystemException {
2265 return findAll(start, end, null);
2266 }
2267
2268
2281 public List<DLFileEntryType> findAll(int start, int end,
2282 OrderByComparator orderByComparator) throws SystemException {
2283 FinderPath finderPath = null;
2284 Object[] finderArgs = new Object[] { start, end, orderByComparator };
2285
2286 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2287 (orderByComparator == null)) {
2288 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
2289 finderArgs = FINDER_ARGS_EMPTY;
2290 }
2291 else {
2292 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
2293 finderArgs = new Object[] { start, end, orderByComparator };
2294 }
2295
2296 List<DLFileEntryType> list = (List<DLFileEntryType>)FinderCacheUtil.getResult(finderPath,
2297 finderArgs, this);
2298
2299 if (list == null) {
2300 StringBundler query = null;
2301 String sql = null;
2302
2303 if (orderByComparator != null) {
2304 query = new StringBundler(2 +
2305 (orderByComparator.getOrderByFields().length * 3));
2306
2307 query.append(_SQL_SELECT_DLFILEENTRYTYPE);
2308
2309 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2310 orderByComparator);
2311
2312 sql = query.toString();
2313 }
2314 else {
2315 sql = _SQL_SELECT_DLFILEENTRYTYPE;
2316 }
2317
2318 Session session = null;
2319
2320 try {
2321 session = openSession();
2322
2323 Query q = session.createQuery(sql);
2324
2325 if (orderByComparator == null) {
2326 list = (List<DLFileEntryType>)QueryUtil.list(q,
2327 getDialect(), start, end, false);
2328
2329 Collections.sort(list);
2330 }
2331 else {
2332 list = (List<DLFileEntryType>)QueryUtil.list(q,
2333 getDialect(), start, end);
2334 }
2335 }
2336 catch (Exception e) {
2337 throw processException(e);
2338 }
2339 finally {
2340 if (list == null) {
2341 FinderCacheUtil.removeResult(finderPath, finderArgs);
2342 }
2343 else {
2344 cacheResult(list);
2345
2346 FinderCacheUtil.putResult(finderPath, finderArgs, list);
2347 }
2348
2349 closeSession(session);
2350 }
2351 }
2352
2353 return list;
2354 }
2355
2356
2362 public void removeByUuid(String uuid) throws SystemException {
2363 for (DLFileEntryType dlFileEntryType : findByUuid(uuid)) {
2364 dlFileEntryTypePersistence.remove(dlFileEntryType);
2365 }
2366 }
2367
2368
2375 public void removeByUUID_G(String uuid, long groupId)
2376 throws NoSuchFileEntryTypeException, SystemException {
2377 DLFileEntryType dlFileEntryType = findByUUID_G(uuid, groupId);
2378
2379 dlFileEntryTypePersistence.remove(dlFileEntryType);
2380 }
2381
2382
2388 public void removeByGroupId(long groupId) throws SystemException {
2389 for (DLFileEntryType dlFileEntryType : findByGroupId(groupId)) {
2390 dlFileEntryTypePersistence.remove(dlFileEntryType);
2391 }
2392 }
2393
2394
2401 public void removeByG_N(long groupId, String name)
2402 throws NoSuchFileEntryTypeException, SystemException {
2403 DLFileEntryType dlFileEntryType = findByG_N(groupId, name);
2404
2405 dlFileEntryTypePersistence.remove(dlFileEntryType);
2406 }
2407
2408
2413 public void removeAll() throws SystemException {
2414 for (DLFileEntryType dlFileEntryType : findAll()) {
2415 dlFileEntryTypePersistence.remove(dlFileEntryType);
2416 }
2417 }
2418
2419
2426 public int countByUuid(String uuid) throws SystemException {
2427 Object[] finderArgs = new Object[] { uuid };
2428
2429 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID,
2430 finderArgs, this);
2431
2432 if (count == null) {
2433 StringBundler query = new StringBundler(2);
2434
2435 query.append(_SQL_COUNT_DLFILEENTRYTYPE_WHERE);
2436
2437 if (uuid == null) {
2438 query.append(_FINDER_COLUMN_UUID_UUID_1);
2439 }
2440 else {
2441 if (uuid.equals(StringPool.BLANK)) {
2442 query.append(_FINDER_COLUMN_UUID_UUID_3);
2443 }
2444 else {
2445 query.append(_FINDER_COLUMN_UUID_UUID_2);
2446 }
2447 }
2448
2449 String sql = query.toString();
2450
2451 Session session = null;
2452
2453 try {
2454 session = openSession();
2455
2456 Query q = session.createQuery(sql);
2457
2458 QueryPos qPos = QueryPos.getInstance(q);
2459
2460 if (uuid != null) {
2461 qPos.add(uuid);
2462 }
2463
2464 count = (Long)q.uniqueResult();
2465 }
2466 catch (Exception e) {
2467 throw processException(e);
2468 }
2469 finally {
2470 if (count == null) {
2471 count = Long.valueOf(0);
2472 }
2473
2474 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID,
2475 finderArgs, count);
2476
2477 closeSession(session);
2478 }
2479 }
2480
2481 return count.intValue();
2482 }
2483
2484
2492 public int countByUUID_G(String uuid, long groupId)
2493 throws SystemException {
2494 Object[] finderArgs = new Object[] { uuid, groupId };
2495
2496 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID_G,
2497 finderArgs, this);
2498
2499 if (count == null) {
2500 StringBundler query = new StringBundler(3);
2501
2502 query.append(_SQL_COUNT_DLFILEENTRYTYPE_WHERE);
2503
2504 if (uuid == null) {
2505 query.append(_FINDER_COLUMN_UUID_G_UUID_1);
2506 }
2507 else {
2508 if (uuid.equals(StringPool.BLANK)) {
2509 query.append(_FINDER_COLUMN_UUID_G_UUID_3);
2510 }
2511 else {
2512 query.append(_FINDER_COLUMN_UUID_G_UUID_2);
2513 }
2514 }
2515
2516 query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
2517
2518 String sql = query.toString();
2519
2520 Session session = null;
2521
2522 try {
2523 session = openSession();
2524
2525 Query q = session.createQuery(sql);
2526
2527 QueryPos qPos = QueryPos.getInstance(q);
2528
2529 if (uuid != null) {
2530 qPos.add(uuid);
2531 }
2532
2533 qPos.add(groupId);
2534
2535 count = (Long)q.uniqueResult();
2536 }
2537 catch (Exception e) {
2538 throw processException(e);
2539 }
2540 finally {
2541 if (count == null) {
2542 count = Long.valueOf(0);
2543 }
2544
2545 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G,
2546 finderArgs, count);
2547
2548 closeSession(session);
2549 }
2550 }
2551
2552 return count.intValue();
2553 }
2554
2555
2562 public int countByGroupId(long groupId) throws SystemException {
2563 Object[] finderArgs = new Object[] { groupId };
2564
2565 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_GROUPID,
2566 finderArgs, this);
2567
2568 if (count == null) {
2569 StringBundler query = new StringBundler(2);
2570
2571 query.append(_SQL_COUNT_DLFILEENTRYTYPE_WHERE);
2572
2573 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2574
2575 String sql = query.toString();
2576
2577 Session session = null;
2578
2579 try {
2580 session = openSession();
2581
2582 Query q = session.createQuery(sql);
2583
2584 QueryPos qPos = QueryPos.getInstance(q);
2585
2586 qPos.add(groupId);
2587
2588 count = (Long)q.uniqueResult();
2589 }
2590 catch (Exception e) {
2591 throw processException(e);
2592 }
2593 finally {
2594 if (count == null) {
2595 count = Long.valueOf(0);
2596 }
2597
2598 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_GROUPID,
2599 finderArgs, count);
2600
2601 closeSession(session);
2602 }
2603 }
2604
2605 return count.intValue();
2606 }
2607
2608
2615 public int countByGroupId(long[] groupIds) throws SystemException {
2616 Object[] finderArgs = new Object[] { StringUtil.merge(groupIds) };
2617
2618 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_GROUPID,
2619 finderArgs, this);
2620
2621 if (count == null) {
2622 StringBundler query = new StringBundler();
2623
2624 query.append(_SQL_COUNT_DLFILEENTRYTYPE_WHERE);
2625
2626 boolean conjunctionable = false;
2627
2628 if ((groupIds == null) || (groupIds.length > 0)) {
2629 if (conjunctionable) {
2630 query.append(WHERE_AND);
2631 }
2632
2633 query.append(StringPool.OPEN_PARENTHESIS);
2634
2635 for (int i = 0; i < groupIds.length; i++) {
2636 query.append(_FINDER_COLUMN_GROUPID_GROUPID_5);
2637
2638 if ((i + 1) < groupIds.length) {
2639 query.append(WHERE_OR);
2640 }
2641 }
2642
2643 query.append(StringPool.CLOSE_PARENTHESIS);
2644
2645 conjunctionable = true;
2646 }
2647
2648 String sql = query.toString();
2649
2650 Session session = null;
2651
2652 try {
2653 session = openSession();
2654
2655 Query q = session.createQuery(sql);
2656
2657 QueryPos qPos = QueryPos.getInstance(q);
2658
2659 if (groupIds != null) {
2660 qPos.add(groupIds);
2661 }
2662
2663 count = (Long)q.uniqueResult();
2664 }
2665 catch (Exception e) {
2666 throw processException(e);
2667 }
2668 finally {
2669 if (count == null) {
2670 count = Long.valueOf(0);
2671 }
2672
2673 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_GROUPID,
2674 finderArgs, count);
2675
2676 closeSession(session);
2677 }
2678 }
2679
2680 return count.intValue();
2681 }
2682
2683
2690 public int filterCountByGroupId(long groupId) throws SystemException {
2691 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2692 return countByGroupId(groupId);
2693 }
2694
2695 StringBundler query = new StringBundler(2);
2696
2697 query.append(_FILTER_SQL_COUNT_DLFILEENTRYTYPE_WHERE);
2698
2699 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2700
2701 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2702 DLFileEntryType.class.getName(),
2703 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2704
2705 Session session = null;
2706
2707 try {
2708 session = openSession();
2709
2710 SQLQuery q = session.createSQLQuery(sql);
2711
2712 q.addScalar(COUNT_COLUMN_NAME,
2713 com.liferay.portal.kernel.dao.orm.Type.LONG);
2714
2715 QueryPos qPos = QueryPos.getInstance(q);
2716
2717 qPos.add(groupId);
2718
2719 Long count = (Long)q.uniqueResult();
2720
2721 return count.intValue();
2722 }
2723 catch (Exception e) {
2724 throw processException(e);
2725 }
2726 finally {
2727 closeSession(session);
2728 }
2729 }
2730
2731
2738 public int filterCountByGroupId(long[] groupIds) throws SystemException {
2739 if (!InlineSQLHelperUtil.isEnabled(groupIds)) {
2740 return countByGroupId(groupIds);
2741 }
2742
2743 StringBundler query = new StringBundler();
2744
2745 query.append(_FILTER_SQL_COUNT_DLFILEENTRYTYPE_WHERE);
2746
2747 boolean conjunctionable = false;
2748
2749 if ((groupIds == null) || (groupIds.length > 0)) {
2750 if (conjunctionable) {
2751 query.append(WHERE_AND);
2752 }
2753
2754 query.append(StringPool.OPEN_PARENTHESIS);
2755
2756 for (int i = 0; i < groupIds.length; i++) {
2757 query.append(_FINDER_COLUMN_GROUPID_GROUPID_5);
2758
2759 if ((i + 1) < groupIds.length) {
2760 query.append(WHERE_OR);
2761 }
2762 }
2763
2764 query.append(StringPool.CLOSE_PARENTHESIS);
2765
2766 conjunctionable = true;
2767 }
2768
2769 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2770 DLFileEntryType.class.getName(),
2771 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupIds);
2772
2773 Session session = null;
2774
2775 try {
2776 session = openSession();
2777
2778 SQLQuery q = session.createSQLQuery(sql);
2779
2780 q.addScalar(COUNT_COLUMN_NAME,
2781 com.liferay.portal.kernel.dao.orm.Type.LONG);
2782
2783 QueryPos qPos = QueryPos.getInstance(q);
2784
2785 if (groupIds != null) {
2786 qPos.add(groupIds);
2787 }
2788
2789 Long count = (Long)q.uniqueResult();
2790
2791 return count.intValue();
2792 }
2793 catch (Exception e) {
2794 throw processException(e);
2795 }
2796 finally {
2797 closeSession(session);
2798 }
2799 }
2800
2801
2809 public int countByG_N(long groupId, String name) throws SystemException {
2810 Object[] finderArgs = new Object[] { groupId, name };
2811
2812 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_N,
2813 finderArgs, this);
2814
2815 if (count == null) {
2816 StringBundler query = new StringBundler(3);
2817
2818 query.append(_SQL_COUNT_DLFILEENTRYTYPE_WHERE);
2819
2820 query.append(_FINDER_COLUMN_G_N_GROUPID_2);
2821
2822 if (name == null) {
2823 query.append(_FINDER_COLUMN_G_N_NAME_1);
2824 }
2825 else {
2826 if (name.equals(StringPool.BLANK)) {
2827 query.append(_FINDER_COLUMN_G_N_NAME_3);
2828 }
2829 else {
2830 query.append(_FINDER_COLUMN_G_N_NAME_2);
2831 }
2832 }
2833
2834 String sql = query.toString();
2835
2836 Session session = null;
2837
2838 try {
2839 session = openSession();
2840
2841 Query q = session.createQuery(sql);
2842
2843 QueryPos qPos = QueryPos.getInstance(q);
2844
2845 qPos.add(groupId);
2846
2847 if (name != null) {
2848 qPos.add(name);
2849 }
2850
2851 count = (Long)q.uniqueResult();
2852 }
2853 catch (Exception e) {
2854 throw processException(e);
2855 }
2856 finally {
2857 if (count == null) {
2858 count = Long.valueOf(0);
2859 }
2860
2861 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_N, finderArgs,
2862 count);
2863
2864 closeSession(session);
2865 }
2866 }
2867
2868 return count.intValue();
2869 }
2870
2871
2877 public int countAll() throws SystemException {
2878 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
2879 FINDER_ARGS_EMPTY, this);
2880
2881 if (count == null) {
2882 Session session = null;
2883
2884 try {
2885 session = openSession();
2886
2887 Query q = session.createQuery(_SQL_COUNT_DLFILEENTRYTYPE);
2888
2889 count = (Long)q.uniqueResult();
2890 }
2891 catch (Exception e) {
2892 throw processException(e);
2893 }
2894 finally {
2895 if (count == null) {
2896 count = Long.valueOf(0);
2897 }
2898
2899 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
2900 FINDER_ARGS_EMPTY, count);
2901
2902 closeSession(session);
2903 }
2904 }
2905
2906 return count.intValue();
2907 }
2908
2909
2916 public List<com.liferay.portlet.documentlibrary.model.DLFolder> getDLFolders(
2917 long pk) throws SystemException {
2918 return getDLFolders(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
2919 }
2920
2921
2934 public List<com.liferay.portlet.documentlibrary.model.DLFolder> getDLFolders(
2935 long pk, int start, int end) throws SystemException {
2936 return getDLFolders(pk, start, end, null);
2937 }
2938
2939 public static final FinderPath FINDER_PATH_GET_DLFOLDERS = new FinderPath(com.liferay.portlet.documentlibrary.model.impl.DLFolderModelImpl.ENTITY_CACHE_ENABLED,
2940 DLFileEntryTypeModelImpl.FINDER_CACHE_ENABLED_DLFILEENTRYTYPES_DLFOLDERS,
2941 com.liferay.portlet.documentlibrary.model.impl.DLFolderImpl.class,
2942 DLFileEntryTypeModelImpl.MAPPING_TABLE_DLFILEENTRYTYPES_DLFOLDERS_NAME,
2943 "getDLFolders",
2944 new String[] {
2945 Long.class.getName(), "java.lang.Integer", "java.lang.Integer",
2946 "com.liferay.portal.kernel.util.OrderByComparator"
2947 });
2948
2949
2963 public List<com.liferay.portlet.documentlibrary.model.DLFolder> getDLFolders(
2964 long pk, int start, int end, OrderByComparator orderByComparator)
2965 throws SystemException {
2966 Object[] finderArgs = new Object[] { pk, start, end, orderByComparator };
2967
2968 List<com.liferay.portlet.documentlibrary.model.DLFolder> list = (List<com.liferay.portlet.documentlibrary.model.DLFolder>)FinderCacheUtil.getResult(FINDER_PATH_GET_DLFOLDERS,
2969 finderArgs, this);
2970
2971 if (list == null) {
2972 Session session = null;
2973
2974 try {
2975 session = openSession();
2976
2977 String sql = null;
2978
2979 if (orderByComparator != null) {
2980 sql = _SQL_GETDLFOLDERS.concat(ORDER_BY_CLAUSE)
2981 .concat(orderByComparator.getOrderBy());
2982 }
2983 else {
2984 sql = _SQL_GETDLFOLDERS.concat(com.liferay.portlet.documentlibrary.model.impl.DLFolderModelImpl.ORDER_BY_SQL);
2985 }
2986
2987 SQLQuery q = session.createSQLQuery(sql);
2988
2989 q.addEntity("DLFolder",
2990 com.liferay.portlet.documentlibrary.model.impl.DLFolderImpl.class);
2991
2992 QueryPos qPos = QueryPos.getInstance(q);
2993
2994 qPos.add(pk);
2995
2996 list = (List<com.liferay.portlet.documentlibrary.model.DLFolder>)QueryUtil.list(q,
2997 getDialect(), start, end);
2998 }
2999 catch (Exception e) {
3000 throw processException(e);
3001 }
3002 finally {
3003 if (list == null) {
3004 FinderCacheUtil.removeResult(FINDER_PATH_GET_DLFOLDERS,
3005 finderArgs);
3006 }
3007 else {
3008 dlFolderPersistence.cacheResult(list);
3009
3010 FinderCacheUtil.putResult(FINDER_PATH_GET_DLFOLDERS,
3011 finderArgs, list);
3012 }
3013
3014 closeSession(session);
3015 }
3016 }
3017
3018 return list;
3019 }
3020
3021 public static final FinderPath FINDER_PATH_GET_DLFOLDERS_SIZE = new FinderPath(com.liferay.portlet.documentlibrary.model.impl.DLFolderModelImpl.ENTITY_CACHE_ENABLED,
3022 DLFileEntryTypeModelImpl.FINDER_CACHE_ENABLED_DLFILEENTRYTYPES_DLFOLDERS,
3023 Long.class,
3024 DLFileEntryTypeModelImpl.MAPPING_TABLE_DLFILEENTRYTYPES_DLFOLDERS_NAME,
3025 "getDLFoldersSize", new String[] { Long.class.getName() });
3026
3027
3034 public int getDLFoldersSize(long pk) throws SystemException {
3035 Object[] finderArgs = new Object[] { pk };
3036
3037 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_GET_DLFOLDERS_SIZE,
3038 finderArgs, this);
3039
3040 if (count == null) {
3041 Session session = null;
3042
3043 try {
3044 session = openSession();
3045
3046 SQLQuery q = session.createSQLQuery(_SQL_GETDLFOLDERSSIZE);
3047
3048 q.addScalar(COUNT_COLUMN_NAME,
3049 com.liferay.portal.kernel.dao.orm.Type.LONG);
3050
3051 QueryPos qPos = QueryPos.getInstance(q);
3052
3053 qPos.add(pk);
3054
3055 count = (Long)q.uniqueResult();
3056 }
3057 catch (Exception e) {
3058 throw processException(e);
3059 }
3060 finally {
3061 if (count == null) {
3062 count = Long.valueOf(0);
3063 }
3064
3065 FinderCacheUtil.putResult(FINDER_PATH_GET_DLFOLDERS_SIZE,
3066 finderArgs, count);
3067
3068 closeSession(session);
3069 }
3070 }
3071
3072 return count.intValue();
3073 }
3074
3075 public static final FinderPath FINDER_PATH_CONTAINS_DLFOLDER = new FinderPath(com.liferay.portlet.documentlibrary.model.impl.DLFolderModelImpl.ENTITY_CACHE_ENABLED,
3076 DLFileEntryTypeModelImpl.FINDER_CACHE_ENABLED_DLFILEENTRYTYPES_DLFOLDERS,
3077 Boolean.class,
3078 DLFileEntryTypeModelImpl.MAPPING_TABLE_DLFILEENTRYTYPES_DLFOLDERS_NAME,
3079 "containsDLFolder",
3080 new String[] { Long.class.getName(), Long.class.getName() });
3081
3082
3090 public boolean containsDLFolder(long pk, long dlFolderPK)
3091 throws SystemException {
3092 Object[] finderArgs = new Object[] { pk, dlFolderPK };
3093
3094 Boolean value = (Boolean)FinderCacheUtil.getResult(FINDER_PATH_CONTAINS_DLFOLDER,
3095 finderArgs, this);
3096
3097 if (value == null) {
3098 try {
3099 value = Boolean.valueOf(containsDLFolder.contains(pk, dlFolderPK));
3100 }
3101 catch (Exception e) {
3102 throw processException(e);
3103 }
3104 finally {
3105 if (value == null) {
3106 value = Boolean.FALSE;
3107 }
3108
3109 FinderCacheUtil.putResult(FINDER_PATH_CONTAINS_DLFOLDER,
3110 finderArgs, value);
3111 }
3112 }
3113
3114 return value.booleanValue();
3115 }
3116
3117
3124 public boolean containsDLFolders(long pk) throws SystemException {
3125 if (getDLFoldersSize(pk) > 0) {
3126 return true;
3127 }
3128 else {
3129 return false;
3130 }
3131 }
3132
3133
3140 public void addDLFolder(long pk, long dlFolderPK) throws SystemException {
3141 try {
3142 addDLFolder.add(pk, dlFolderPK);
3143 }
3144 catch (Exception e) {
3145 throw processException(e);
3146 }
3147 finally {
3148 FinderCacheUtil.clearCache(DLFileEntryTypeModelImpl.MAPPING_TABLE_DLFILEENTRYTYPES_DLFOLDERS_NAME);
3149 }
3150 }
3151
3152
3159 public void addDLFolder(long pk,
3160 com.liferay.portlet.documentlibrary.model.DLFolder dlFolder)
3161 throws SystemException {
3162 try {
3163 addDLFolder.add(pk, dlFolder.getPrimaryKey());
3164 }
3165 catch (Exception e) {
3166 throw processException(e);
3167 }
3168 finally {
3169 FinderCacheUtil.clearCache(DLFileEntryTypeModelImpl.MAPPING_TABLE_DLFILEENTRYTYPES_DLFOLDERS_NAME);
3170 }
3171 }
3172
3173
3180 public void addDLFolders(long pk, long[] dlFolderPKs)
3181 throws SystemException {
3182 try {
3183 for (long dlFolderPK : dlFolderPKs) {
3184 addDLFolder.add(pk, dlFolderPK);
3185 }
3186 }
3187 catch (Exception e) {
3188 throw processException(e);
3189 }
3190 finally {
3191 FinderCacheUtil.clearCache(DLFileEntryTypeModelImpl.MAPPING_TABLE_DLFILEENTRYTYPES_DLFOLDERS_NAME);
3192 }
3193 }
3194
3195
3202 public void addDLFolders(long pk,
3203 List<com.liferay.portlet.documentlibrary.model.DLFolder> dlFolders)
3204 throws SystemException {
3205 try {
3206 for (com.liferay.portlet.documentlibrary.model.DLFolder dlFolder : dlFolders) {
3207 addDLFolder.add(pk, dlFolder.getPrimaryKey());
3208 }
3209 }
3210 catch (Exception e) {
3211 throw processException(e);
3212 }
3213 finally {
3214 FinderCacheUtil.clearCache(DLFileEntryTypeModelImpl.MAPPING_TABLE_DLFILEENTRYTYPES_DLFOLDERS_NAME);
3215 }
3216 }
3217
3218
3224 public void clearDLFolders(long pk) throws SystemException {
3225 try {
3226 clearDLFolders.clear(pk);
3227 }
3228 catch (Exception e) {
3229 throw processException(e);
3230 }
3231 finally {
3232 FinderCacheUtil.clearCache(DLFileEntryTypeModelImpl.MAPPING_TABLE_DLFILEENTRYTYPES_DLFOLDERS_NAME);
3233 }
3234 }
3235
3236
3243 public void removeDLFolder(long pk, long dlFolderPK)
3244 throws SystemException {
3245 try {
3246 removeDLFolder.remove(pk, dlFolderPK);
3247 }
3248 catch (Exception e) {
3249 throw processException(e);
3250 }
3251 finally {
3252 FinderCacheUtil.clearCache(DLFileEntryTypeModelImpl.MAPPING_TABLE_DLFILEENTRYTYPES_DLFOLDERS_NAME);
3253 }
3254 }
3255
3256
3263 public void removeDLFolder(long pk,
3264 com.liferay.portlet.documentlibrary.model.DLFolder dlFolder)
3265 throws SystemException {
3266 try {
3267 removeDLFolder.remove(pk, dlFolder.getPrimaryKey());
3268 }
3269 catch (Exception e) {
3270 throw processException(e);
3271 }
3272 finally {
3273 FinderCacheUtil.clearCache(DLFileEntryTypeModelImpl.MAPPING_TABLE_DLFILEENTRYTYPES_DLFOLDERS_NAME);
3274 }
3275 }
3276
3277
3284 public void removeDLFolders(long pk, long[] dlFolderPKs)
3285 throws SystemException {
3286 try {
3287 for (long dlFolderPK : dlFolderPKs) {
3288 removeDLFolder.remove(pk, dlFolderPK);
3289 }
3290 }
3291 catch (Exception e) {
3292 throw processException(e);
3293 }
3294 finally {
3295 FinderCacheUtil.clearCache(DLFileEntryTypeModelImpl.MAPPING_TABLE_DLFILEENTRYTYPES_DLFOLDERS_NAME);
3296 }
3297 }
3298
3299
3306 public void removeDLFolders(long pk,
3307 List<com.liferay.portlet.documentlibrary.model.DLFolder> dlFolders)
3308 throws SystemException {
3309 try {
3310 for (com.liferay.portlet.documentlibrary.model.DLFolder dlFolder : dlFolders) {
3311 removeDLFolder.remove(pk, dlFolder.getPrimaryKey());
3312 }
3313 }
3314 catch (Exception e) {
3315 throw processException(e);
3316 }
3317 finally {
3318 FinderCacheUtil.clearCache(DLFileEntryTypeModelImpl.MAPPING_TABLE_DLFILEENTRYTYPES_DLFOLDERS_NAME);
3319 }
3320 }
3321
3322
3329 public void setDLFolders(long pk, long[] dlFolderPKs)
3330 throws SystemException {
3331 try {
3332 Set<Long> dlFolderPKSet = SetUtil.fromArray(dlFolderPKs);
3333
3334 List<com.liferay.portlet.documentlibrary.model.DLFolder> dlFolders = getDLFolders(pk);
3335
3336 for (com.liferay.portlet.documentlibrary.model.DLFolder dlFolder : dlFolders) {
3337 if (!dlFolderPKSet.remove(dlFolder.getPrimaryKey())) {
3338 removeDLFolder.remove(pk, dlFolder.getPrimaryKey());
3339 }
3340 }
3341
3342 for (Long dlFolderPK : dlFolderPKSet) {
3343 addDLFolder.add(pk, dlFolderPK);
3344 }
3345 }
3346 catch (Exception e) {
3347 throw processException(e);
3348 }
3349 finally {
3350 FinderCacheUtil.clearCache(DLFileEntryTypeModelImpl.MAPPING_TABLE_DLFILEENTRYTYPES_DLFOLDERS_NAME);
3351 }
3352 }
3353
3354
3361 public void setDLFolders(long pk,
3362 List<com.liferay.portlet.documentlibrary.model.DLFolder> dlFolders)
3363 throws SystemException {
3364 try {
3365 long[] dlFolderPKs = new long[dlFolders.size()];
3366
3367 for (int i = 0; i < dlFolders.size(); i++) {
3368 com.liferay.portlet.documentlibrary.model.DLFolder dlFolder = dlFolders.get(i);
3369
3370 dlFolderPKs[i] = dlFolder.getPrimaryKey();
3371 }
3372
3373 setDLFolders(pk, dlFolderPKs);
3374 }
3375 catch (Exception e) {
3376 throw processException(e);
3377 }
3378 finally {
3379 FinderCacheUtil.clearCache(DLFileEntryTypeModelImpl.MAPPING_TABLE_DLFILEENTRYTYPES_DLFOLDERS_NAME);
3380 }
3381 }
3382
3383
3390 public List<com.liferay.portlet.dynamicdatamapping.model.DDMStructure> getDDMStructures(
3391 long pk) throws SystemException {
3392 return getDDMStructures(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
3393 }
3394
3395
3408 public List<com.liferay.portlet.dynamicdatamapping.model.DDMStructure> getDDMStructures(
3409 long pk, int start, int end) throws SystemException {
3410 return getDDMStructures(pk, start, end, null);
3411 }
3412
3413 public static final FinderPath FINDER_PATH_GET_DDMSTRUCTURES = new FinderPath(com.liferay.portlet.dynamicdatamapping.model.impl.DDMStructureModelImpl.ENTITY_CACHE_ENABLED,
3414 DLFileEntryTypeModelImpl.FINDER_CACHE_ENABLED_DLFILEENTRYTYPES_DDMSTRUCTURES,
3415 com.liferay.portlet.dynamicdatamapping.model.impl.DDMStructureImpl.class,
3416 DLFileEntryTypeModelImpl.MAPPING_TABLE_DLFILEENTRYTYPES_DDMSTRUCTURES_NAME,
3417 "getDDMStructures",
3418 new String[] {
3419 Long.class.getName(), "java.lang.Integer", "java.lang.Integer",
3420 "com.liferay.portal.kernel.util.OrderByComparator"
3421 });
3422
3423
3437 public List<com.liferay.portlet.dynamicdatamapping.model.DDMStructure> getDDMStructures(
3438 long pk, int start, int end, OrderByComparator orderByComparator)
3439 throws SystemException {
3440 Object[] finderArgs = new Object[] { pk, start, end, orderByComparator };
3441
3442 List<com.liferay.portlet.dynamicdatamapping.model.DDMStructure> list = (List<com.liferay.portlet.dynamicdatamapping.model.DDMStructure>)FinderCacheUtil.getResult(FINDER_PATH_GET_DDMSTRUCTURES,
3443 finderArgs, this);
3444
3445 if (list == null) {
3446 Session session = null;
3447
3448 try {
3449 session = openSession();
3450
3451 String sql = null;
3452
3453 if (orderByComparator != null) {
3454 sql = _SQL_GETDDMSTRUCTURES.concat(ORDER_BY_CLAUSE)
3455 .concat(orderByComparator.getOrderBy());
3456 }
3457 else {
3458 sql = _SQL_GETDDMSTRUCTURES;
3459 }
3460
3461 SQLQuery q = session.createSQLQuery(sql);
3462
3463 q.addEntity("DDMStructure",
3464 com.liferay.portlet.dynamicdatamapping.model.impl.DDMStructureImpl.class);
3465
3466 QueryPos qPos = QueryPos.getInstance(q);
3467
3468 qPos.add(pk);
3469
3470 list = (List<com.liferay.portlet.dynamicdatamapping.model.DDMStructure>)QueryUtil.list(q,
3471 getDialect(), start, end);
3472 }
3473 catch (Exception e) {
3474 throw processException(e);
3475 }
3476 finally {
3477 if (list == null) {
3478 FinderCacheUtil.removeResult(FINDER_PATH_GET_DDMSTRUCTURES,
3479 finderArgs);
3480 }
3481 else {
3482 ddmStructurePersistence.cacheResult(list);
3483
3484 FinderCacheUtil.putResult(FINDER_PATH_GET_DDMSTRUCTURES,
3485 finderArgs, list);
3486 }
3487
3488 closeSession(session);
3489 }
3490 }
3491
3492 return list;
3493 }
3494
3495 public static final FinderPath FINDER_PATH_GET_DDMSTRUCTURES_SIZE = new FinderPath(com.liferay.portlet.dynamicdatamapping.model.impl.DDMStructureModelImpl.ENTITY_CACHE_ENABLED,
3496 DLFileEntryTypeModelImpl.FINDER_CACHE_ENABLED_DLFILEENTRYTYPES_DDMSTRUCTURES,
3497 Long.class,
3498 DLFileEntryTypeModelImpl.MAPPING_TABLE_DLFILEENTRYTYPES_DDMSTRUCTURES_NAME,
3499 "getDDMStructuresSize", new String[] { Long.class.getName() });
3500
3501
3508 public int getDDMStructuresSize(long pk) throws SystemException {
3509 Object[] finderArgs = new Object[] { pk };
3510
3511 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_GET_DDMSTRUCTURES_SIZE,
3512 finderArgs, this);
3513
3514 if (count == null) {
3515 Session session = null;
3516
3517 try {
3518 session = openSession();
3519
3520 SQLQuery q = session.createSQLQuery(_SQL_GETDDMSTRUCTURESSIZE);
3521
3522 q.addScalar(COUNT_COLUMN_NAME,
3523 com.liferay.portal.kernel.dao.orm.Type.LONG);
3524
3525 QueryPos qPos = QueryPos.getInstance(q);
3526
3527 qPos.add(pk);
3528
3529 count = (Long)q.uniqueResult();
3530 }
3531 catch (Exception e) {
3532 throw processException(e);
3533 }
3534 finally {
3535 if (count == null) {
3536 count = Long.valueOf(0);
3537 }
3538
3539 FinderCacheUtil.putResult(FINDER_PATH_GET_DDMSTRUCTURES_SIZE,
3540 finderArgs, count);
3541
3542 closeSession(session);
3543 }
3544 }
3545
3546 return count.intValue();
3547 }
3548
3549 public static final FinderPath FINDER_PATH_CONTAINS_DDMSTRUCTURE = new FinderPath(com.liferay.portlet.dynamicdatamapping.model.impl.DDMStructureModelImpl.ENTITY_CACHE_ENABLED,
3550 DLFileEntryTypeModelImpl.FINDER_CACHE_ENABLED_DLFILEENTRYTYPES_DDMSTRUCTURES,
3551 Boolean.class,
3552 DLFileEntryTypeModelImpl.MAPPING_TABLE_DLFILEENTRYTYPES_DDMSTRUCTURES_NAME,
3553 "containsDDMStructure",
3554 new String[] { Long.class.getName(), Long.class.getName() });
3555
3556
3564 public boolean containsDDMStructure(long pk, long ddmStructurePK)
3565 throws SystemException {
3566 Object[] finderArgs = new Object[] { pk, ddmStructurePK };
3567
3568 Boolean value = (Boolean)FinderCacheUtil.getResult(FINDER_PATH_CONTAINS_DDMSTRUCTURE,
3569 finderArgs, this);
3570
3571 if (value == null) {
3572 try {
3573 value = Boolean.valueOf(containsDDMStructure.contains(pk,
3574 ddmStructurePK));
3575 }
3576 catch (Exception e) {
3577 throw processException(e);
3578 }
3579 finally {
3580 if (value == null) {
3581 value = Boolean.FALSE;
3582 }
3583
3584 FinderCacheUtil.putResult(FINDER_PATH_CONTAINS_DDMSTRUCTURE,
3585 finderArgs, value);
3586 }
3587 }
3588
3589 return value.booleanValue();
3590 }
3591
3592
3599 public boolean containsDDMStructures(long pk) throws SystemException {
3600 if (getDDMStructuresSize(pk) > 0) {
3601 return true;
3602 }
3603 else {
3604 return false;
3605 }
3606 }
3607
3608
3615 public void addDDMStructure(long pk, long ddmStructurePK)
3616 throws SystemException {
3617 try {
3618 addDDMStructure.add(pk, ddmStructurePK);
3619 }
3620 catch (Exception e) {
3621 throw processException(e);
3622 }
3623 finally {
3624 FinderCacheUtil.clearCache(DLFileEntryTypeModelImpl.MAPPING_TABLE_DLFILEENTRYTYPES_DDMSTRUCTURES_NAME);
3625 }
3626 }
3627
3628
3635 public void addDDMStructure(long pk,
3636 com.liferay.portlet.dynamicdatamapping.model.DDMStructure ddmStructure)
3637 throws SystemException {
3638 try {
3639 addDDMStructure.add(pk, ddmStructure.getPrimaryKey());
3640 }
3641 catch (Exception e) {
3642 throw processException(e);
3643 }
3644 finally {
3645 FinderCacheUtil.clearCache(DLFileEntryTypeModelImpl.MAPPING_TABLE_DLFILEENTRYTYPES_DDMSTRUCTURES_NAME);
3646 }
3647 }
3648
3649
3656 public void addDDMStructures(long pk, long[] ddmStructurePKs)
3657 throws SystemException {
3658 try {
3659 for (long ddmStructurePK : ddmStructurePKs) {
3660 addDDMStructure.add(pk, ddmStructurePK);
3661 }
3662 }
3663 catch (Exception e) {
3664 throw processException(e);
3665 }
3666 finally {
3667 FinderCacheUtil.clearCache(DLFileEntryTypeModelImpl.MAPPING_TABLE_DLFILEENTRYTYPES_DDMSTRUCTURES_NAME);
3668 }
3669 }
3670
3671
3678 public void addDDMStructures(long pk,
3679 List<com.liferay.portlet.dynamicdatamapping.model.DDMStructure> ddmStructures)
3680 throws SystemException {
3681 try {
3682 for (com.liferay.portlet.dynamicdatamapping.model.DDMStructure ddmStructure : ddmStructures) {
3683 addDDMStructure.add(pk, ddmStructure.getPrimaryKey());
3684 }
3685 }
3686 catch (Exception e) {
3687 throw processException(e);
3688 }
3689 finally {
3690 FinderCacheUtil.clearCache(DLFileEntryTypeModelImpl.MAPPING_TABLE_DLFILEENTRYTYPES_DDMSTRUCTURES_NAME);
3691 }
3692 }
3693
3694
3700 public void clearDDMStructures(long pk) throws SystemException {
3701 try {
3702 clearDDMStructures.clear(pk);
3703 }
3704 catch (Exception e) {
3705 throw processException(e);
3706 }
3707 finally {
3708 FinderCacheUtil.clearCache(DLFileEntryTypeModelImpl.MAPPING_TABLE_DLFILEENTRYTYPES_DDMSTRUCTURES_NAME);
3709 }
3710 }
3711
3712
3719 public void removeDDMStructure(long pk, long ddmStructurePK)
3720 throws SystemException {
3721 try {
3722 removeDDMStructure.remove(pk, ddmStructurePK);
3723 }
3724 catch (Exception e) {
3725 throw processException(e);
3726 }
3727 finally {
3728 FinderCacheUtil.clearCache(DLFileEntryTypeModelImpl.MAPPING_TABLE_DLFILEENTRYTYPES_DDMSTRUCTURES_NAME);
3729 }
3730 }
3731
3732
3739 public void removeDDMStructure(long pk,
3740 com.liferay.portlet.dynamicdatamapping.model.DDMStructure ddmStructure)
3741 throws SystemException {
3742 try {
3743 removeDDMStructure.remove(pk, ddmStructure.getPrimaryKey());
3744 }
3745 catch (Exception e) {
3746 throw processException(e);
3747 }
3748 finally {
3749 FinderCacheUtil.clearCache(DLFileEntryTypeModelImpl.MAPPING_TABLE_DLFILEENTRYTYPES_DDMSTRUCTURES_NAME);
3750 }
3751 }
3752
3753
3760 public void removeDDMStructures(long pk, long[] ddmStructurePKs)
3761 throws SystemException {
3762 try {
3763 for (long ddmStructurePK : ddmStructurePKs) {
3764 removeDDMStructure.remove(pk, ddmStructurePK);
3765 }
3766 }
3767 catch (Exception e) {
3768 throw processException(e);
3769 }
3770 finally {
3771 FinderCacheUtil.clearCache(DLFileEntryTypeModelImpl.MAPPING_TABLE_DLFILEENTRYTYPES_DDMSTRUCTURES_NAME);
3772 }
3773 }
3774
3775
3782 public void removeDDMStructures(long pk,
3783 List<com.liferay.portlet.dynamicdatamapping.model.DDMStructure> ddmStructures)
3784 throws SystemException {
3785 try {
3786 for (com.liferay.portlet.dynamicdatamapping.model.DDMStructure ddmStructure : ddmStructures) {
3787 removeDDMStructure.remove(pk, ddmStructure.getPrimaryKey());
3788 }
3789 }
3790 catch (Exception e) {
3791 throw processException(e);
3792 }
3793 finally {
3794 FinderCacheUtil.clearCache(DLFileEntryTypeModelImpl.MAPPING_TABLE_DLFILEENTRYTYPES_DDMSTRUCTURES_NAME);
3795 }
3796 }
3797
3798
3805 public void setDDMStructures(long pk, long[] ddmStructurePKs)
3806 throws SystemException {
3807 try {
3808 Set<Long> ddmStructurePKSet = SetUtil.fromArray(ddmStructurePKs);
3809
3810 List<com.liferay.portlet.dynamicdatamapping.model.DDMStructure> ddmStructures =
3811 getDDMStructures(pk);
3812
3813 for (com.liferay.portlet.dynamicdatamapping.model.DDMStructure ddmStructure : ddmStructures) {
3814 if (!ddmStructurePKSet.remove(ddmStructure.getPrimaryKey())) {
3815 removeDDMStructure.remove(pk, ddmStructure.getPrimaryKey());
3816 }
3817 }
3818
3819 for (Long ddmStructurePK : ddmStructurePKSet) {
3820 addDDMStructure.add(pk, ddmStructurePK);
3821 }
3822 }
3823 catch (Exception e) {
3824 throw processException(e);
3825 }
3826 finally {
3827 FinderCacheUtil.clearCache(DLFileEntryTypeModelImpl.MAPPING_TABLE_DLFILEENTRYTYPES_DDMSTRUCTURES_NAME);
3828 }
3829 }
3830
3831
3838 public void setDDMStructures(long pk,
3839 List<com.liferay.portlet.dynamicdatamapping.model.DDMStructure> ddmStructures)
3840 throws SystemException {
3841 try {
3842 long[] ddmStructurePKs = new long[ddmStructures.size()];
3843
3844 for (int i = 0; i < ddmStructures.size(); i++) {
3845 com.liferay.portlet.dynamicdatamapping.model.DDMStructure ddmStructure =
3846 ddmStructures.get(i);
3847
3848 ddmStructurePKs[i] = ddmStructure.getPrimaryKey();
3849 }
3850
3851 setDDMStructures(pk, ddmStructurePKs);
3852 }
3853 catch (Exception e) {
3854 throw processException(e);
3855 }
3856 finally {
3857 FinderCacheUtil.clearCache(DLFileEntryTypeModelImpl.MAPPING_TABLE_DLFILEENTRYTYPES_DDMSTRUCTURES_NAME);
3858 }
3859 }
3860
3861
3864 public void afterPropertiesSet() {
3865 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
3866 com.liferay.portal.util.PropsUtil.get(
3867 "value.object.listener.com.liferay.portlet.documentlibrary.model.DLFileEntryType")));
3868
3869 if (listenerClassNames.length > 0) {
3870 try {
3871 List<ModelListener<DLFileEntryType>> listenersList = new ArrayList<ModelListener<DLFileEntryType>>();
3872
3873 for (String listenerClassName : listenerClassNames) {
3874 listenersList.add((ModelListener<DLFileEntryType>)InstanceFactory.newInstance(
3875 listenerClassName));
3876 }
3877
3878 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
3879 }
3880 catch (Exception e) {
3881 _log.error(e);
3882 }
3883 }
3884
3885 containsDLFolder = new ContainsDLFolder(this);
3886
3887 addDLFolder = new AddDLFolder(this);
3888 clearDLFolders = new ClearDLFolders(this);
3889 removeDLFolder = new RemoveDLFolder(this);
3890
3891 containsDDMStructure = new ContainsDDMStructure(this);
3892
3893 addDDMStructure = new AddDDMStructure(this);
3894 clearDDMStructures = new ClearDDMStructures(this);
3895 removeDDMStructure = new RemoveDDMStructure(this);
3896 }
3897
3898 public void destroy() {
3899 EntityCacheUtil.removeCache(DLFileEntryTypeImpl.class.getName());
3900 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
3901 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
3902 }
3903
3904 @BeanReference(type = DLContentPersistence.class)
3905 protected DLContentPersistence dlContentPersistence;
3906 @BeanReference(type = DLFileEntryPersistence.class)
3907 protected DLFileEntryPersistence dlFileEntryPersistence;
3908 @BeanReference(type = DLFileEntryMetadataPersistence.class)
3909 protected DLFileEntryMetadataPersistence dlFileEntryMetadataPersistence;
3910 @BeanReference(type = DLFileEntryTypePersistence.class)
3911 protected DLFileEntryTypePersistence dlFileEntryTypePersistence;
3912 @BeanReference(type = DLFileRankPersistence.class)
3913 protected DLFileRankPersistence dlFileRankPersistence;
3914 @BeanReference(type = DLFileShortcutPersistence.class)
3915 protected DLFileShortcutPersistence dlFileShortcutPersistence;
3916 @BeanReference(type = DLFileVersionPersistence.class)
3917 protected DLFileVersionPersistence dlFileVersionPersistence;
3918 @BeanReference(type = DLFolderPersistence.class)
3919 protected DLFolderPersistence dlFolderPersistence;
3920 @BeanReference(type = DLSyncPersistence.class)
3921 protected DLSyncPersistence dlSyncPersistence;
3922 @BeanReference(type = ResourcePersistence.class)
3923 protected ResourcePersistence resourcePersistence;
3924 @BeanReference(type = UserPersistence.class)
3925 protected UserPersistence userPersistence;
3926 @BeanReference(type = WorkflowDefinitionLinkPersistence.class)
3927 protected WorkflowDefinitionLinkPersistence workflowDefinitionLinkPersistence;
3928 @BeanReference(type = WorkflowInstanceLinkPersistence.class)
3929 protected WorkflowInstanceLinkPersistence workflowInstanceLinkPersistence;
3930 @BeanReference(type = DDMStructurePersistence.class)
3931 protected DDMStructurePersistence ddmStructurePersistence;
3932 protected ContainsDLFolder containsDLFolder;
3933 protected AddDLFolder addDLFolder;
3934 protected ClearDLFolders clearDLFolders;
3935 protected RemoveDLFolder removeDLFolder;
3936 protected ContainsDDMStructure containsDDMStructure;
3937 protected AddDDMStructure addDDMStructure;
3938 protected ClearDDMStructures clearDDMStructures;
3939 protected RemoveDDMStructure removeDDMStructure;
3940
3941 protected class ContainsDLFolder {
3942 protected ContainsDLFolder(
3943 DLFileEntryTypePersistenceImpl persistenceImpl) {
3944 super();
3945
3946 _mappingSqlQuery = MappingSqlQueryFactoryUtil.getMappingSqlQuery(getDataSource(),
3947 _SQL_CONTAINSDLFOLDER,
3948 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT },
3949 RowMapper.COUNT);
3950 }
3951
3952 protected boolean contains(long fileEntryTypeId, long folderId) {
3953 List<Integer> results = _mappingSqlQuery.execute(new Object[] {
3954 new Long(fileEntryTypeId), new Long(folderId)
3955 });
3956
3957 if (results.size() > 0) {
3958 Integer count = results.get(0);
3959
3960 if (count.intValue() > 0) {
3961 return true;
3962 }
3963 }
3964
3965 return false;
3966 }
3967
3968 private MappingSqlQuery<Integer> _mappingSqlQuery;
3969 }
3970
3971 protected class AddDLFolder {
3972 protected AddDLFolder(DLFileEntryTypePersistenceImpl persistenceImpl) {
3973 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
3974 "INSERT INTO DLFileEntryTypes_DLFolders (fileEntryTypeId, folderId) VALUES (?, ?)",
3975 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
3976 _persistenceImpl = persistenceImpl;
3977 }
3978
3979 protected void add(long fileEntryTypeId, long folderId)
3980 throws SystemException {
3981 if (!_persistenceImpl.containsDLFolder.contains(fileEntryTypeId,
3982 folderId)) {
3983 ModelListener<com.liferay.portlet.documentlibrary.model.DLFolder>[] dlFolderListeners =
3984 dlFolderPersistence.getListeners();
3985
3986 for (ModelListener<DLFileEntryType> listener : listeners) {
3987 listener.onBeforeAddAssociation(fileEntryTypeId,
3988 com.liferay.portlet.documentlibrary.model.DLFolder.class.getName(),
3989 folderId);
3990 }
3991
3992 for (ModelListener<com.liferay.portlet.documentlibrary.model.DLFolder> listener : dlFolderListeners) {
3993 listener.onBeforeAddAssociation(folderId,
3994 DLFileEntryType.class.getName(), fileEntryTypeId);
3995 }
3996
3997 _sqlUpdate.update(new Object[] {
3998 new Long(fileEntryTypeId), new Long(folderId)
3999 });
4000
4001 for (ModelListener<DLFileEntryType> listener : listeners) {
4002 listener.onAfterAddAssociation(fileEntryTypeId,
4003 com.liferay.portlet.documentlibrary.model.DLFolder.class.getName(),
4004 folderId);
4005 }
4006
4007 for (ModelListener<com.liferay.portlet.documentlibrary.model.DLFolder> listener : dlFolderListeners) {
4008 listener.onAfterAddAssociation(folderId,
4009 DLFileEntryType.class.getName(), fileEntryTypeId);
4010 }
4011 }
4012 }
4013
4014 private SqlUpdate _sqlUpdate;
4015 private DLFileEntryTypePersistenceImpl _persistenceImpl;
4016 }
4017
4018 protected class ClearDLFolders {
4019 protected ClearDLFolders(DLFileEntryTypePersistenceImpl persistenceImpl) {
4020 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
4021 "DELETE FROM DLFileEntryTypes_DLFolders WHERE fileEntryTypeId = ?",
4022 new int[] { java.sql.Types.BIGINT });
4023 }
4024
4025 protected void clear(long fileEntryTypeId) throws SystemException {
4026 ModelListener<com.liferay.portlet.documentlibrary.model.DLFolder>[] dlFolderListeners =
4027 dlFolderPersistence.getListeners();
4028
4029 List<com.liferay.portlet.documentlibrary.model.DLFolder> dlFolders = null;
4030
4031 if ((listeners.length > 0) || (dlFolderListeners.length > 0)) {
4032 dlFolders = getDLFolders(fileEntryTypeId);
4033
4034 for (com.liferay.portlet.documentlibrary.model.DLFolder dlFolder : dlFolders) {
4035 for (ModelListener<DLFileEntryType> listener : listeners) {
4036 listener.onBeforeRemoveAssociation(fileEntryTypeId,
4037 com.liferay.portlet.documentlibrary.model.DLFolder.class.getName(),
4038 dlFolder.getPrimaryKey());
4039 }
4040
4041 for (ModelListener<com.liferay.portlet.documentlibrary.model.DLFolder> listener : dlFolderListeners) {
4042 listener.onBeforeRemoveAssociation(dlFolder.getPrimaryKey(),
4043 DLFileEntryType.class.getName(), fileEntryTypeId);
4044 }
4045 }
4046 }
4047
4048 _sqlUpdate.update(new Object[] { new Long(fileEntryTypeId) });
4049
4050 if ((listeners.length > 0) || (dlFolderListeners.length > 0)) {
4051 for (com.liferay.portlet.documentlibrary.model.DLFolder dlFolder : dlFolders) {
4052 for (ModelListener<DLFileEntryType> listener : listeners) {
4053 listener.onAfterRemoveAssociation(fileEntryTypeId,
4054 com.liferay.portlet.documentlibrary.model.DLFolder.class.getName(),
4055 dlFolder.getPrimaryKey());
4056 }
4057
4058 for (ModelListener<com.liferay.portlet.documentlibrary.model.DLFolder> listener : dlFolderListeners) {
4059 listener.onAfterRemoveAssociation(dlFolder.getPrimaryKey(),
4060 DLFileEntryType.class.getName(), fileEntryTypeId);
4061 }
4062 }
4063 }
4064 }
4065
4066 private SqlUpdate _sqlUpdate;
4067 }
4068
4069 protected class RemoveDLFolder {
4070 protected RemoveDLFolder(DLFileEntryTypePersistenceImpl persistenceImpl) {
4071 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
4072 "DELETE FROM DLFileEntryTypes_DLFolders WHERE fileEntryTypeId = ? AND folderId = ?",
4073 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
4074 _persistenceImpl = persistenceImpl;
4075 }
4076
4077 protected void remove(long fileEntryTypeId, long folderId)
4078 throws SystemException {
4079 if (_persistenceImpl.containsDLFolder.contains(fileEntryTypeId,
4080 folderId)) {
4081 ModelListener<com.liferay.portlet.documentlibrary.model.DLFolder>[] dlFolderListeners =
4082 dlFolderPersistence.getListeners();
4083
4084 for (ModelListener<DLFileEntryType> listener : listeners) {
4085 listener.onBeforeRemoveAssociation(fileEntryTypeId,
4086 com.liferay.portlet.documentlibrary.model.DLFolder.class.getName(),
4087 folderId);
4088 }
4089
4090 for (ModelListener<com.liferay.portlet.documentlibrary.model.DLFolder> listener : dlFolderListeners) {
4091 listener.onBeforeRemoveAssociation(folderId,
4092 DLFileEntryType.class.getName(), fileEntryTypeId);
4093 }
4094
4095 _sqlUpdate.update(new Object[] {
4096 new Long(fileEntryTypeId), new Long(folderId)
4097 });
4098
4099 for (ModelListener<DLFileEntryType> listener : listeners) {
4100 listener.onAfterRemoveAssociation(fileEntryTypeId,
4101 com.liferay.portlet.documentlibrary.model.DLFolder.class.getName(),
4102 folderId);
4103 }
4104
4105 for (ModelListener<com.liferay.portlet.documentlibrary.model.DLFolder> listener : dlFolderListeners) {
4106 listener.onAfterRemoveAssociation(folderId,
4107 DLFileEntryType.class.getName(), fileEntryTypeId);
4108 }
4109 }
4110 }
4111
4112 private SqlUpdate _sqlUpdate;
4113 private DLFileEntryTypePersistenceImpl _persistenceImpl;
4114 }
4115
4116 protected class ContainsDDMStructure {
4117 protected ContainsDDMStructure(
4118 DLFileEntryTypePersistenceImpl persistenceImpl) {
4119 super();
4120
4121 _mappingSqlQuery = MappingSqlQueryFactoryUtil.getMappingSqlQuery(getDataSource(),
4122 _SQL_CONTAINSDDMSTRUCTURE,
4123 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT },
4124 RowMapper.COUNT);
4125 }
4126
4127 protected boolean contains(long fileEntryTypeId, long structureId) {
4128 List<Integer> results = _mappingSqlQuery.execute(new Object[] {
4129 new Long(fileEntryTypeId), new Long(structureId)
4130 });
4131
4132 if (results.size() > 0) {
4133 Integer count = results.get(0);
4134
4135 if (count.intValue() > 0) {
4136 return true;
4137 }
4138 }
4139
4140 return false;
4141 }
4142
4143 private MappingSqlQuery<Integer> _mappingSqlQuery;
4144 }
4145
4146 protected class AddDDMStructure {
4147 protected AddDDMStructure(
4148 DLFileEntryTypePersistenceImpl persistenceImpl) {
4149 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
4150 "INSERT INTO DLFileEntryTypes_DDMStructures (fileEntryTypeId, structureId) VALUES (?, ?)",
4151 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
4152 _persistenceImpl = persistenceImpl;
4153 }
4154
4155 protected void add(long fileEntryTypeId, long structureId)
4156 throws SystemException {
4157 if (!_persistenceImpl.containsDDMStructure.contains(
4158 fileEntryTypeId, structureId)) {
4159 ModelListener<com.liferay.portlet.dynamicdatamapping.model.DDMStructure>[] ddmStructureListeners =
4160 ddmStructurePersistence.getListeners();
4161
4162 for (ModelListener<DLFileEntryType> listener : listeners) {
4163 listener.onBeforeAddAssociation(fileEntryTypeId,
4164 com.liferay.portlet.dynamicdatamapping.model.DDMStructure.class.getName(),
4165 structureId);
4166 }
4167
4168 for (ModelListener<com.liferay.portlet.dynamicdatamapping.model.DDMStructure> listener : ddmStructureListeners) {
4169 listener.onBeforeAddAssociation(structureId,
4170 DLFileEntryType.class.getName(), fileEntryTypeId);
4171 }
4172
4173 _sqlUpdate.update(new Object[] {
4174 new Long(fileEntryTypeId), new Long(structureId)
4175 });
4176
4177 for (ModelListener<DLFileEntryType> listener : listeners) {
4178 listener.onAfterAddAssociation(fileEntryTypeId,
4179 com.liferay.portlet.dynamicdatamapping.model.DDMStructure.class.getName(),
4180 structureId);
4181 }
4182
4183 for (ModelListener<com.liferay.portlet.dynamicdatamapping.model.DDMStructure> listener : ddmStructureListeners) {
4184 listener.onAfterAddAssociation(structureId,
4185 DLFileEntryType.class.getName(), fileEntryTypeId);
4186 }
4187 }
4188 }
4189
4190 private SqlUpdate _sqlUpdate;
4191 private DLFileEntryTypePersistenceImpl _persistenceImpl;
4192 }
4193
4194 protected class ClearDDMStructures {
4195 protected ClearDDMStructures(
4196 DLFileEntryTypePersistenceImpl persistenceImpl) {
4197 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
4198 "DELETE FROM DLFileEntryTypes_DDMStructures WHERE fileEntryTypeId = ?",
4199 new int[] { java.sql.Types.BIGINT });
4200 }
4201
4202 protected void clear(long fileEntryTypeId) throws SystemException {
4203 ModelListener<com.liferay.portlet.dynamicdatamapping.model.DDMStructure>[] ddmStructureListeners =
4204 ddmStructurePersistence.getListeners();
4205
4206 List<com.liferay.portlet.dynamicdatamapping.model.DDMStructure> ddmStructures =
4207 null;
4208
4209 if ((listeners.length > 0) || (ddmStructureListeners.length > 0)) {
4210 ddmStructures = getDDMStructures(fileEntryTypeId);
4211
4212 for (com.liferay.portlet.dynamicdatamapping.model.DDMStructure ddmStructure : ddmStructures) {
4213 for (ModelListener<DLFileEntryType> listener : listeners) {
4214 listener.onBeforeRemoveAssociation(fileEntryTypeId,
4215 com.liferay.portlet.dynamicdatamapping.model.DDMStructure.class.getName(),
4216 ddmStructure.getPrimaryKey());
4217 }
4218
4219 for (ModelListener<com.liferay.portlet.dynamicdatamapping.model.DDMStructure> listener : ddmStructureListeners) {
4220 listener.onBeforeRemoveAssociation(ddmStructure.getPrimaryKey(),
4221 DLFileEntryType.class.getName(), fileEntryTypeId);
4222 }
4223 }
4224 }
4225
4226 _sqlUpdate.update(new Object[] { new Long(fileEntryTypeId) });
4227
4228 if ((listeners.length > 0) || (ddmStructureListeners.length > 0)) {
4229 for (com.liferay.portlet.dynamicdatamapping.model.DDMStructure ddmStructure : ddmStructures) {
4230 for (ModelListener<DLFileEntryType> listener : listeners) {
4231 listener.onAfterRemoveAssociation(fileEntryTypeId,
4232 com.liferay.portlet.dynamicdatamapping.model.DDMStructure.class.getName(),
4233 ddmStructure.getPrimaryKey());
4234 }
4235
4236 for (ModelListener<com.liferay.portlet.dynamicdatamapping.model.DDMStructure> listener : ddmStructureListeners) {
4237 listener.onAfterRemoveAssociation(ddmStructure.getPrimaryKey(),
4238 DLFileEntryType.class.getName(), fileEntryTypeId);
4239 }
4240 }
4241 }
4242 }
4243
4244 private SqlUpdate _sqlUpdate;
4245 }
4246
4247 protected class RemoveDDMStructure {
4248 protected RemoveDDMStructure(
4249 DLFileEntryTypePersistenceImpl persistenceImpl) {
4250 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
4251 "DELETE FROM DLFileEntryTypes_DDMStructures WHERE fileEntryTypeId = ? AND structureId = ?",
4252 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
4253 _persistenceImpl = persistenceImpl;
4254 }
4255
4256 protected void remove(long fileEntryTypeId, long structureId)
4257 throws SystemException {
4258 if (_persistenceImpl.containsDDMStructure.contains(
4259 fileEntryTypeId, structureId)) {
4260 ModelListener<com.liferay.portlet.dynamicdatamapping.model.DDMStructure>[] ddmStructureListeners =
4261 ddmStructurePersistence.getListeners();
4262
4263 for (ModelListener<DLFileEntryType> listener : listeners) {
4264 listener.onBeforeRemoveAssociation(fileEntryTypeId,
4265 com.liferay.portlet.dynamicdatamapping.model.DDMStructure.class.getName(),
4266 structureId);
4267 }
4268
4269 for (ModelListener<com.liferay.portlet.dynamicdatamapping.model.DDMStructure> listener : ddmStructureListeners) {
4270 listener.onBeforeRemoveAssociation(structureId,
4271 DLFileEntryType.class.getName(), fileEntryTypeId);
4272 }
4273
4274 _sqlUpdate.update(new Object[] {
4275 new Long(fileEntryTypeId), new Long(structureId)
4276 });
4277
4278 for (ModelListener<DLFileEntryType> listener : listeners) {
4279 listener.onAfterRemoveAssociation(fileEntryTypeId,
4280 com.liferay.portlet.dynamicdatamapping.model.DDMStructure.class.getName(),
4281 structureId);
4282 }
4283
4284 for (ModelListener<com.liferay.portlet.dynamicdatamapping.model.DDMStructure> listener : ddmStructureListeners) {
4285 listener.onAfterRemoveAssociation(structureId,
4286 DLFileEntryType.class.getName(), fileEntryTypeId);
4287 }
4288 }
4289 }
4290
4291 private SqlUpdate _sqlUpdate;
4292 private DLFileEntryTypePersistenceImpl _persistenceImpl;
4293 }
4294
4295 private static final String _SQL_SELECT_DLFILEENTRYTYPE = "SELECT dlFileEntryType FROM DLFileEntryType dlFileEntryType";
4296 private static final String _SQL_SELECT_DLFILEENTRYTYPE_WHERE = "SELECT dlFileEntryType FROM DLFileEntryType dlFileEntryType WHERE ";
4297 private static final String _SQL_COUNT_DLFILEENTRYTYPE = "SELECT COUNT(dlFileEntryType) FROM DLFileEntryType dlFileEntryType";
4298 private static final String _SQL_COUNT_DLFILEENTRYTYPE_WHERE = "SELECT COUNT(dlFileEntryType) FROM DLFileEntryType dlFileEntryType WHERE ";
4299 private static final String _SQL_GETDLFOLDERS = "SELECT {DLFolder.*} FROM DLFolder INNER JOIN DLFileEntryTypes_DLFolders ON (DLFileEntryTypes_DLFolders.folderId = DLFolder.folderId) WHERE (DLFileEntryTypes_DLFolders.fileEntryTypeId = ?)";
4300 private static final String _SQL_GETDLFOLDERSSIZE = "SELECT COUNT(*) AS COUNT_VALUE FROM DLFileEntryTypes_DLFolders WHERE fileEntryTypeId = ?";
4301 private static final String _SQL_CONTAINSDLFOLDER = "SELECT COUNT(*) AS COUNT_VALUE FROM DLFileEntryTypes_DLFolders WHERE fileEntryTypeId = ? AND folderId = ?";
4302 private static final String _SQL_GETDDMSTRUCTURES = "SELECT {DDMStructure.*} FROM DDMStructure INNER JOIN DLFileEntryTypes_DDMStructures ON (DLFileEntryTypes_DDMStructures.structureId = DDMStructure.structureId) WHERE (DLFileEntryTypes_DDMStructures.fileEntryTypeId = ?)";
4303 private static final String _SQL_GETDDMSTRUCTURESSIZE = "SELECT COUNT(*) AS COUNT_VALUE FROM DLFileEntryTypes_DDMStructures WHERE fileEntryTypeId = ?";
4304 private static final String _SQL_CONTAINSDDMSTRUCTURE = "SELECT COUNT(*) AS COUNT_VALUE FROM DLFileEntryTypes_DDMStructures WHERE fileEntryTypeId = ? AND structureId = ?";
4305 private static final String _FINDER_COLUMN_UUID_UUID_1 = "dlFileEntryType.uuid IS NULL";
4306 private static final String _FINDER_COLUMN_UUID_UUID_2 = "dlFileEntryType.uuid = ?";
4307 private static final String _FINDER_COLUMN_UUID_UUID_3 = "(dlFileEntryType.uuid IS NULL OR dlFileEntryType.uuid = ?)";
4308 private static final String _FINDER_COLUMN_UUID_G_UUID_1 = "dlFileEntryType.uuid IS NULL AND ";
4309 private static final String _FINDER_COLUMN_UUID_G_UUID_2 = "dlFileEntryType.uuid = ? AND ";
4310 private static final String _FINDER_COLUMN_UUID_G_UUID_3 = "(dlFileEntryType.uuid IS NULL OR dlFileEntryType.uuid = ?) AND ";
4311 private static final String _FINDER_COLUMN_UUID_G_GROUPID_2 = "dlFileEntryType.groupId = ?";
4312 private static final String _FINDER_COLUMN_GROUPID_GROUPID_2 = "dlFileEntryType.groupId = ?";
4313 private static final String _FINDER_COLUMN_GROUPID_GROUPID_5 = "(" +
4314 _removeConjunction(_FINDER_COLUMN_GROUPID_GROUPID_2) + ")";
4315 private static final String _FINDER_COLUMN_G_N_GROUPID_2 = "dlFileEntryType.groupId = ? AND ";
4316 private static final String _FINDER_COLUMN_G_N_NAME_1 = "dlFileEntryType.name IS NULL";
4317 private static final String _FINDER_COLUMN_G_N_NAME_2 = "dlFileEntryType.name = ?";
4318 private static final String _FINDER_COLUMN_G_N_NAME_3 = "(dlFileEntryType.name IS NULL OR dlFileEntryType.name = ?)";
4319
4320 private static String _removeConjunction(String sql) {
4321 int pos = sql.indexOf(" AND ");
4322
4323 if (pos != -1) {
4324 sql = sql.substring(0, pos);
4325 }
4326
4327 return sql;
4328 }
4329
4330 private static final String _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN = "dlFileEntryType.fileEntryTypeId";
4331 private static final String _FILTER_SQL_SELECT_DLFILEENTRYTYPE_WHERE = "SELECT DISTINCT {dlFileEntryType.*} FROM DLFileEntryType dlFileEntryType WHERE ";
4332 private static final String _FILTER_SQL_SELECT_DLFILEENTRYTYPE_NO_INLINE_DISTINCT_WHERE_1 =
4333 "SELECT {DLFileEntryType.*} FROM (SELECT DISTINCT dlFileEntryType.fileEntryTypeId FROM DLFileEntryType dlFileEntryType WHERE ";
4334 private static final String _FILTER_SQL_SELECT_DLFILEENTRYTYPE_NO_INLINE_DISTINCT_WHERE_2 =
4335 ") TEMP_TABLE INNER JOIN DLFileEntryType ON TEMP_TABLE.fileEntryTypeId = DLFileEntryType.fileEntryTypeId";
4336 private static final String _FILTER_SQL_COUNT_DLFILEENTRYTYPE_WHERE = "SELECT COUNT(DISTINCT dlFileEntryType.fileEntryTypeId) AS COUNT_VALUE FROM DLFileEntryType dlFileEntryType WHERE ";
4337 private static final String _FILTER_ENTITY_ALIAS = "dlFileEntryType";
4338 private static final String _FILTER_ENTITY_TABLE = "DLFileEntryType";
4339 private static final String _ORDER_BY_ENTITY_ALIAS = "dlFileEntryType.";
4340 private static final String _ORDER_BY_ENTITY_TABLE = "DLFileEntryType.";
4341 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No DLFileEntryType exists with the primary key ";
4342 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No DLFileEntryType exists with the key {";
4343 private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
4344 private static Log _log = LogFactoryUtil.getLog(DLFileEntryTypePersistenceImpl.class);
4345 private static DLFileEntryType _nullDLFileEntryType = new DLFileEntryTypeImpl() {
4346 @Override
4347 public Object clone() {
4348 return this;
4349 }
4350
4351 @Override
4352 public CacheModel<DLFileEntryType> toCacheModel() {
4353 return _nullDLFileEntryTypeCacheModel;
4354 }
4355 };
4356
4357 private static CacheModel<DLFileEntryType> _nullDLFileEntryTypeCacheModel = new CacheModel<DLFileEntryType>() {
4358 public DLFileEntryType toEntityModel() {
4359 return _nullDLFileEntryType;
4360 }
4361 };
4362 }