001
014
015 package com.liferay.portlet.asset.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.orm.EntityCacheUtil;
021 import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
022 import com.liferay.portal.kernel.dao.orm.FinderPath;
023 import com.liferay.portal.kernel.dao.orm.Query;
024 import com.liferay.portal.kernel.dao.orm.QueryPos;
025 import com.liferay.portal.kernel.dao.orm.QueryUtil;
026 import com.liferay.portal.kernel.dao.orm.SQLQuery;
027 import com.liferay.portal.kernel.dao.orm.Session;
028 import com.liferay.portal.kernel.exception.SystemException;
029 import com.liferay.portal.kernel.log.Log;
030 import com.liferay.portal.kernel.log.LogFactoryUtil;
031 import com.liferay.portal.kernel.util.GetterUtil;
032 import com.liferay.portal.kernel.util.InstanceFactory;
033 import com.liferay.portal.kernel.util.OrderByComparator;
034 import com.liferay.portal.kernel.util.StringBundler;
035 import com.liferay.portal.kernel.util.StringPool;
036 import com.liferay.portal.kernel.util.StringUtil;
037 import com.liferay.portal.kernel.util.Validator;
038 import com.liferay.portal.kernel.uuid.PortalUUIDUtil;
039 import com.liferay.portal.model.CacheModel;
040 import com.liferay.portal.model.ModelListener;
041 import com.liferay.portal.security.permission.InlineSQLHelperUtil;
042 import com.liferay.portal.service.persistence.BatchSessionUtil;
043 import com.liferay.portal.service.persistence.GroupPersistence;
044 import com.liferay.portal.service.persistence.ResourcePersistence;
045 import com.liferay.portal.service.persistence.UserPersistence;
046 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
047
048 import com.liferay.portlet.asset.NoSuchVocabularyException;
049 import com.liferay.portlet.asset.model.AssetVocabulary;
050 import com.liferay.portlet.asset.model.impl.AssetVocabularyImpl;
051 import com.liferay.portlet.asset.model.impl.AssetVocabularyModelImpl;
052
053 import java.io.Serializable;
054
055 import java.util.ArrayList;
056 import java.util.Collections;
057 import java.util.List;
058
059
071 public class AssetVocabularyPersistenceImpl extends BasePersistenceImpl<AssetVocabulary>
072 implements AssetVocabularyPersistence {
073
078 public static final String FINDER_CLASS_NAME_ENTITY = AssetVocabularyImpl.class.getName();
079 public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
080 ".List1";
081 public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
082 ".List2";
083 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID = new FinderPath(AssetVocabularyModelImpl.ENTITY_CACHE_ENABLED,
084 AssetVocabularyModelImpl.FINDER_CACHE_ENABLED,
085 AssetVocabularyImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
086 "findByUuid",
087 new String[] {
088 String.class.getName(),
089
090 "java.lang.Integer", "java.lang.Integer",
091 "com.liferay.portal.kernel.util.OrderByComparator"
092 });
093 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID = new FinderPath(AssetVocabularyModelImpl.ENTITY_CACHE_ENABLED,
094 AssetVocabularyModelImpl.FINDER_CACHE_ENABLED,
095 AssetVocabularyImpl.class,
096 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid",
097 new String[] { String.class.getName() },
098 AssetVocabularyModelImpl.UUID_COLUMN_BITMASK);
099 public static final FinderPath FINDER_PATH_COUNT_BY_UUID = new FinderPath(AssetVocabularyModelImpl.ENTITY_CACHE_ENABLED,
100 AssetVocabularyModelImpl.FINDER_CACHE_ENABLED, Long.class,
101 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid",
102 new String[] { String.class.getName() });
103 public static final FinderPath FINDER_PATH_FETCH_BY_UUID_G = new FinderPath(AssetVocabularyModelImpl.ENTITY_CACHE_ENABLED,
104 AssetVocabularyModelImpl.FINDER_CACHE_ENABLED,
105 AssetVocabularyImpl.class, FINDER_CLASS_NAME_ENTITY,
106 "fetchByUUID_G",
107 new String[] { String.class.getName(), Long.class.getName() },
108 AssetVocabularyModelImpl.UUID_COLUMN_BITMASK |
109 AssetVocabularyModelImpl.GROUPID_COLUMN_BITMASK);
110 public static final FinderPath FINDER_PATH_COUNT_BY_UUID_G = new FinderPath(AssetVocabularyModelImpl.ENTITY_CACHE_ENABLED,
111 AssetVocabularyModelImpl.FINDER_CACHE_ENABLED, Long.class,
112 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUUID_G",
113 new String[] { String.class.getName(), Long.class.getName() });
114 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID = new FinderPath(AssetVocabularyModelImpl.ENTITY_CACHE_ENABLED,
115 AssetVocabularyModelImpl.FINDER_CACHE_ENABLED,
116 AssetVocabularyImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
117 "findByGroupId",
118 new String[] {
119 Long.class.getName(),
120
121 "java.lang.Integer", "java.lang.Integer",
122 "com.liferay.portal.kernel.util.OrderByComparator"
123 });
124 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID =
125 new FinderPath(AssetVocabularyModelImpl.ENTITY_CACHE_ENABLED,
126 AssetVocabularyModelImpl.FINDER_CACHE_ENABLED,
127 AssetVocabularyImpl.class,
128 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByGroupId",
129 new String[] { Long.class.getName() },
130 AssetVocabularyModelImpl.GROUPID_COLUMN_BITMASK);
131 public static final FinderPath FINDER_PATH_COUNT_BY_GROUPID = new FinderPath(AssetVocabularyModelImpl.ENTITY_CACHE_ENABLED,
132 AssetVocabularyModelImpl.FINDER_CACHE_ENABLED, Long.class,
133 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByGroupId",
134 new String[] { Long.class.getName() });
135 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID =
136 new FinderPath(AssetVocabularyModelImpl.ENTITY_CACHE_ENABLED,
137 AssetVocabularyModelImpl.FINDER_CACHE_ENABLED,
138 AssetVocabularyImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
139 "findByCompanyId",
140 new String[] {
141 Long.class.getName(),
142
143 "java.lang.Integer", "java.lang.Integer",
144 "com.liferay.portal.kernel.util.OrderByComparator"
145 });
146 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID =
147 new FinderPath(AssetVocabularyModelImpl.ENTITY_CACHE_ENABLED,
148 AssetVocabularyModelImpl.FINDER_CACHE_ENABLED,
149 AssetVocabularyImpl.class,
150 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByCompanyId",
151 new String[] { Long.class.getName() },
152 AssetVocabularyModelImpl.COMPANYID_COLUMN_BITMASK);
153 public static final FinderPath FINDER_PATH_COUNT_BY_COMPANYID = new FinderPath(AssetVocabularyModelImpl.ENTITY_CACHE_ENABLED,
154 AssetVocabularyModelImpl.FINDER_CACHE_ENABLED, Long.class,
155 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByCompanyId",
156 new String[] { Long.class.getName() });
157 public static final FinderPath FINDER_PATH_FETCH_BY_G_N = new FinderPath(AssetVocabularyModelImpl.ENTITY_CACHE_ENABLED,
158 AssetVocabularyModelImpl.FINDER_CACHE_ENABLED,
159 AssetVocabularyImpl.class, FINDER_CLASS_NAME_ENTITY, "fetchByG_N",
160 new String[] { Long.class.getName(), String.class.getName() },
161 AssetVocabularyModelImpl.GROUPID_COLUMN_BITMASK |
162 AssetVocabularyModelImpl.NAME_COLUMN_BITMASK);
163 public static final FinderPath FINDER_PATH_COUNT_BY_G_N = new FinderPath(AssetVocabularyModelImpl.ENTITY_CACHE_ENABLED,
164 AssetVocabularyModelImpl.FINDER_CACHE_ENABLED, Long.class,
165 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_N",
166 new String[] { Long.class.getName(), String.class.getName() });
167 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(AssetVocabularyModelImpl.ENTITY_CACHE_ENABLED,
168 AssetVocabularyModelImpl.FINDER_CACHE_ENABLED,
169 AssetVocabularyImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
170 "findAll", new String[0]);
171 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(AssetVocabularyModelImpl.ENTITY_CACHE_ENABLED,
172 AssetVocabularyModelImpl.FINDER_CACHE_ENABLED,
173 AssetVocabularyImpl.class,
174 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
175 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(AssetVocabularyModelImpl.ENTITY_CACHE_ENABLED,
176 AssetVocabularyModelImpl.FINDER_CACHE_ENABLED, Long.class,
177 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
178
179
184 public void cacheResult(AssetVocabulary assetVocabulary) {
185 EntityCacheUtil.putResult(AssetVocabularyModelImpl.ENTITY_CACHE_ENABLED,
186 AssetVocabularyImpl.class, assetVocabulary.getPrimaryKey(),
187 assetVocabulary);
188
189 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
190 new Object[] {
191 assetVocabulary.getUuid(),
192 Long.valueOf(assetVocabulary.getGroupId())
193 }, assetVocabulary);
194
195 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_N,
196 new Object[] {
197 Long.valueOf(assetVocabulary.getGroupId()),
198
199 assetVocabulary.getName()
200 }, assetVocabulary);
201
202 assetVocabulary.resetOriginalValues();
203 }
204
205
210 public void cacheResult(List<AssetVocabulary> assetVocabularies) {
211 for (AssetVocabulary assetVocabulary : assetVocabularies) {
212 if (EntityCacheUtil.getResult(
213 AssetVocabularyModelImpl.ENTITY_CACHE_ENABLED,
214 AssetVocabularyImpl.class,
215 assetVocabulary.getPrimaryKey()) == null) {
216 cacheResult(assetVocabulary);
217 }
218 else {
219 assetVocabulary.resetOriginalValues();
220 }
221 }
222 }
223
224
231 @Override
232 public void clearCache() {
233 if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
234 CacheRegistryUtil.clear(AssetVocabularyImpl.class.getName());
235 }
236
237 EntityCacheUtil.clearCache(AssetVocabularyImpl.class.getName());
238
239 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
240 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
241 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
242 }
243
244
251 @Override
252 public void clearCache(AssetVocabulary assetVocabulary) {
253 EntityCacheUtil.removeResult(AssetVocabularyModelImpl.ENTITY_CACHE_ENABLED,
254 AssetVocabularyImpl.class, assetVocabulary.getPrimaryKey());
255
256 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
257 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
258
259 clearUniqueFindersCache(assetVocabulary);
260 }
261
262 @Override
263 public void clearCache(List<AssetVocabulary> assetVocabularies) {
264 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
265 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
266
267 for (AssetVocabulary assetVocabulary : assetVocabularies) {
268 EntityCacheUtil.removeResult(AssetVocabularyModelImpl.ENTITY_CACHE_ENABLED,
269 AssetVocabularyImpl.class, assetVocabulary.getPrimaryKey());
270
271 clearUniqueFindersCache(assetVocabulary);
272 }
273 }
274
275 protected void clearUniqueFindersCache(AssetVocabulary assetVocabulary) {
276 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
277 new Object[] {
278 assetVocabulary.getUuid(),
279 Long.valueOf(assetVocabulary.getGroupId())
280 });
281
282 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_N,
283 new Object[] {
284 Long.valueOf(assetVocabulary.getGroupId()),
285
286 assetVocabulary.getName()
287 });
288 }
289
290
296 public AssetVocabulary create(long vocabularyId) {
297 AssetVocabulary assetVocabulary = new AssetVocabularyImpl();
298
299 assetVocabulary.setNew(true);
300 assetVocabulary.setPrimaryKey(vocabularyId);
301
302 String uuid = PortalUUIDUtil.generate();
303
304 assetVocabulary.setUuid(uuid);
305
306 return assetVocabulary;
307 }
308
309
317 public AssetVocabulary remove(long vocabularyId)
318 throws NoSuchVocabularyException, SystemException {
319 return remove(Long.valueOf(vocabularyId));
320 }
321
322
330 @Override
331 public AssetVocabulary remove(Serializable primaryKey)
332 throws NoSuchVocabularyException, SystemException {
333 Session session = null;
334
335 try {
336 session = openSession();
337
338 AssetVocabulary assetVocabulary = (AssetVocabulary)session.get(AssetVocabularyImpl.class,
339 primaryKey);
340
341 if (assetVocabulary == null) {
342 if (_log.isWarnEnabled()) {
343 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
344 }
345
346 throw new NoSuchVocabularyException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
347 primaryKey);
348 }
349
350 return remove(assetVocabulary);
351 }
352 catch (NoSuchVocabularyException nsee) {
353 throw nsee;
354 }
355 catch (Exception e) {
356 throw processException(e);
357 }
358 finally {
359 closeSession(session);
360 }
361 }
362
363 @Override
364 protected AssetVocabulary removeImpl(AssetVocabulary assetVocabulary)
365 throws SystemException {
366 assetVocabulary = toUnwrappedModel(assetVocabulary);
367
368 Session session = null;
369
370 try {
371 session = openSession();
372
373 BatchSessionUtil.delete(session, assetVocabulary);
374 }
375 catch (Exception e) {
376 throw processException(e);
377 }
378 finally {
379 closeSession(session);
380 }
381
382 clearCache(assetVocabulary);
383
384 return assetVocabulary;
385 }
386
387 @Override
388 public AssetVocabulary updateImpl(
389 com.liferay.portlet.asset.model.AssetVocabulary assetVocabulary,
390 boolean merge) throws SystemException {
391 assetVocabulary = toUnwrappedModel(assetVocabulary);
392
393 boolean isNew = assetVocabulary.isNew();
394
395 AssetVocabularyModelImpl assetVocabularyModelImpl = (AssetVocabularyModelImpl)assetVocabulary;
396
397 if (Validator.isNull(assetVocabulary.getUuid())) {
398 String uuid = PortalUUIDUtil.generate();
399
400 assetVocabulary.setUuid(uuid);
401 }
402
403 Session session = null;
404
405 try {
406 session = openSession();
407
408 BatchSessionUtil.update(session, assetVocabulary, merge);
409
410 assetVocabulary.setNew(false);
411 }
412 catch (Exception e) {
413 throw processException(e);
414 }
415 finally {
416 closeSession(session);
417 }
418
419 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
420
421 if (isNew || !AssetVocabularyModelImpl.COLUMN_BITMASK_ENABLED) {
422 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
423 }
424 else {
425 if ((assetVocabularyModelImpl.getColumnBitmask() &
426 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID.getColumnBitmask()) != 0) {
427 Object[] args = new Object[] {
428 assetVocabularyModelImpl.getOriginalUuid()
429 };
430
431 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
432 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
433 args);
434
435 args = new Object[] { assetVocabularyModelImpl.getUuid() };
436
437 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
438 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
439 args);
440 }
441
442 if ((assetVocabularyModelImpl.getColumnBitmask() &
443 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID.getColumnBitmask()) != 0) {
444 Object[] args = new Object[] {
445 Long.valueOf(assetVocabularyModelImpl.getOriginalGroupId())
446 };
447
448 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
449 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
450 args);
451
452 args = new Object[] {
453 Long.valueOf(assetVocabularyModelImpl.getGroupId())
454 };
455
456 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
457 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
458 args);
459 }
460
461 if ((assetVocabularyModelImpl.getColumnBitmask() &
462 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID.getColumnBitmask()) != 0) {
463 Object[] args = new Object[] {
464 Long.valueOf(assetVocabularyModelImpl.getOriginalCompanyId())
465 };
466
467 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_COMPANYID,
468 args);
469 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
470 args);
471
472 args = new Object[] {
473 Long.valueOf(assetVocabularyModelImpl.getCompanyId())
474 };
475
476 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_COMPANYID,
477 args);
478 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
479 args);
480 }
481 }
482
483 EntityCacheUtil.putResult(AssetVocabularyModelImpl.ENTITY_CACHE_ENABLED,
484 AssetVocabularyImpl.class, assetVocabulary.getPrimaryKey(),
485 assetVocabulary);
486
487 if (isNew) {
488 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
489 new Object[] {
490 assetVocabulary.getUuid(),
491 Long.valueOf(assetVocabulary.getGroupId())
492 }, assetVocabulary);
493
494 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_N,
495 new Object[] {
496 Long.valueOf(assetVocabulary.getGroupId()),
497
498 assetVocabulary.getName()
499 }, assetVocabulary);
500 }
501 else {
502 if ((assetVocabularyModelImpl.getColumnBitmask() &
503 FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) {
504 Object[] args = new Object[] {
505 assetVocabularyModelImpl.getOriginalUuid(),
506 Long.valueOf(assetVocabularyModelImpl.getOriginalGroupId())
507 };
508
509 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args);
510 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args);
511
512 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
513 new Object[] {
514 assetVocabulary.getUuid(),
515 Long.valueOf(assetVocabulary.getGroupId())
516 }, assetVocabulary);
517 }
518
519 if ((assetVocabularyModelImpl.getColumnBitmask() &
520 FINDER_PATH_FETCH_BY_G_N.getColumnBitmask()) != 0) {
521 Object[] args = new Object[] {
522 Long.valueOf(assetVocabularyModelImpl.getOriginalGroupId()),
523
524 assetVocabularyModelImpl.getOriginalName()
525 };
526
527 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_N, args);
528 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_N, args);
529
530 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_N,
531 new Object[] {
532 Long.valueOf(assetVocabulary.getGroupId()),
533
534 assetVocabulary.getName()
535 }, assetVocabulary);
536 }
537 }
538
539 return assetVocabulary;
540 }
541
542 protected AssetVocabulary toUnwrappedModel(AssetVocabulary assetVocabulary) {
543 if (assetVocabulary instanceof AssetVocabularyImpl) {
544 return assetVocabulary;
545 }
546
547 AssetVocabularyImpl assetVocabularyImpl = new AssetVocabularyImpl();
548
549 assetVocabularyImpl.setNew(assetVocabulary.isNew());
550 assetVocabularyImpl.setPrimaryKey(assetVocabulary.getPrimaryKey());
551
552 assetVocabularyImpl.setUuid(assetVocabulary.getUuid());
553 assetVocabularyImpl.setVocabularyId(assetVocabulary.getVocabularyId());
554 assetVocabularyImpl.setGroupId(assetVocabulary.getGroupId());
555 assetVocabularyImpl.setCompanyId(assetVocabulary.getCompanyId());
556 assetVocabularyImpl.setUserId(assetVocabulary.getUserId());
557 assetVocabularyImpl.setUserName(assetVocabulary.getUserName());
558 assetVocabularyImpl.setCreateDate(assetVocabulary.getCreateDate());
559 assetVocabularyImpl.setModifiedDate(assetVocabulary.getModifiedDate());
560 assetVocabularyImpl.setName(assetVocabulary.getName());
561 assetVocabularyImpl.setTitle(assetVocabulary.getTitle());
562 assetVocabularyImpl.setDescription(assetVocabulary.getDescription());
563 assetVocabularyImpl.setSettings(assetVocabulary.getSettings());
564
565 return assetVocabularyImpl;
566 }
567
568
576 @Override
577 public AssetVocabulary findByPrimaryKey(Serializable primaryKey)
578 throws NoSuchModelException, SystemException {
579 return findByPrimaryKey(((Long)primaryKey).longValue());
580 }
581
582
590 public AssetVocabulary findByPrimaryKey(long vocabularyId)
591 throws NoSuchVocabularyException, SystemException {
592 AssetVocabulary assetVocabulary = fetchByPrimaryKey(vocabularyId);
593
594 if (assetVocabulary == null) {
595 if (_log.isWarnEnabled()) {
596 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + vocabularyId);
597 }
598
599 throw new NoSuchVocabularyException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
600 vocabularyId);
601 }
602
603 return assetVocabulary;
604 }
605
606
613 @Override
614 public AssetVocabulary fetchByPrimaryKey(Serializable primaryKey)
615 throws SystemException {
616 return fetchByPrimaryKey(((Long)primaryKey).longValue());
617 }
618
619
626 public AssetVocabulary fetchByPrimaryKey(long vocabularyId)
627 throws SystemException {
628 AssetVocabulary assetVocabulary = (AssetVocabulary)EntityCacheUtil.getResult(AssetVocabularyModelImpl.ENTITY_CACHE_ENABLED,
629 AssetVocabularyImpl.class, vocabularyId);
630
631 if (assetVocabulary == _nullAssetVocabulary) {
632 return null;
633 }
634
635 if (assetVocabulary == null) {
636 Session session = null;
637
638 boolean hasException = false;
639
640 try {
641 session = openSession();
642
643 assetVocabulary = (AssetVocabulary)session.get(AssetVocabularyImpl.class,
644 Long.valueOf(vocabularyId));
645 }
646 catch (Exception e) {
647 hasException = true;
648
649 throw processException(e);
650 }
651 finally {
652 if (assetVocabulary != null) {
653 cacheResult(assetVocabulary);
654 }
655 else if (!hasException) {
656 EntityCacheUtil.putResult(AssetVocabularyModelImpl.ENTITY_CACHE_ENABLED,
657 AssetVocabularyImpl.class, vocabularyId,
658 _nullAssetVocabulary);
659 }
660
661 closeSession(session);
662 }
663 }
664
665 return assetVocabulary;
666 }
667
668
675 public List<AssetVocabulary> findByUuid(String uuid)
676 throws SystemException {
677 return findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
678 }
679
680
693 public List<AssetVocabulary> findByUuid(String uuid, int start, int end)
694 throws SystemException {
695 return findByUuid(uuid, start, end, null);
696 }
697
698
712 public List<AssetVocabulary> findByUuid(String uuid, int start, int end,
713 OrderByComparator orderByComparator) throws SystemException {
714 FinderPath finderPath = null;
715 Object[] finderArgs = null;
716
717 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
718 (orderByComparator == null)) {
719 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID;
720 finderArgs = new Object[] { uuid };
721 }
722 else {
723 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID;
724 finderArgs = new Object[] { uuid, start, end, orderByComparator };
725 }
726
727 List<AssetVocabulary> list = (List<AssetVocabulary>)FinderCacheUtil.getResult(finderPath,
728 finderArgs, this);
729
730 if ((list != null) && !list.isEmpty()) {
731 for (AssetVocabulary assetVocabulary : list) {
732 if (!Validator.equals(uuid, assetVocabulary.getUuid())) {
733 list = null;
734
735 break;
736 }
737 }
738 }
739
740 if (list == null) {
741 StringBundler query = null;
742
743 if (orderByComparator != null) {
744 query = new StringBundler(3 +
745 (orderByComparator.getOrderByFields().length * 3));
746 }
747 else {
748 query = new StringBundler(3);
749 }
750
751 query.append(_SQL_SELECT_ASSETVOCABULARY_WHERE);
752
753 if (uuid == null) {
754 query.append(_FINDER_COLUMN_UUID_UUID_1);
755 }
756 else {
757 if (uuid.equals(StringPool.BLANK)) {
758 query.append(_FINDER_COLUMN_UUID_UUID_3);
759 }
760 else {
761 query.append(_FINDER_COLUMN_UUID_UUID_2);
762 }
763 }
764
765 if (orderByComparator != null) {
766 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
767 orderByComparator);
768 }
769
770 else {
771 query.append(AssetVocabularyModelImpl.ORDER_BY_JPQL);
772 }
773
774 String sql = query.toString();
775
776 Session session = null;
777
778 try {
779 session = openSession();
780
781 Query q = session.createQuery(sql);
782
783 QueryPos qPos = QueryPos.getInstance(q);
784
785 if (uuid != null) {
786 qPos.add(uuid);
787 }
788
789 list = (List<AssetVocabulary>)QueryUtil.list(q, getDialect(),
790 start, end);
791 }
792 catch (Exception e) {
793 throw processException(e);
794 }
795 finally {
796 if (list == null) {
797 FinderCacheUtil.removeResult(finderPath, finderArgs);
798 }
799 else {
800 cacheResult(list);
801
802 FinderCacheUtil.putResult(finderPath, finderArgs, list);
803 }
804
805 closeSession(session);
806 }
807 }
808
809 return list;
810 }
811
812
825 public AssetVocabulary findByUuid_First(String uuid,
826 OrderByComparator orderByComparator)
827 throws NoSuchVocabularyException, SystemException {
828 List<AssetVocabulary> list = findByUuid(uuid, 0, 1, orderByComparator);
829
830 if (list.isEmpty()) {
831 StringBundler msg = new StringBundler(4);
832
833 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
834
835 msg.append("uuid=");
836 msg.append(uuid);
837
838 msg.append(StringPool.CLOSE_CURLY_BRACE);
839
840 throw new NoSuchVocabularyException(msg.toString());
841 }
842 else {
843 return list.get(0);
844 }
845 }
846
847
860 public AssetVocabulary findByUuid_Last(String uuid,
861 OrderByComparator orderByComparator)
862 throws NoSuchVocabularyException, SystemException {
863 int count = countByUuid(uuid);
864
865 List<AssetVocabulary> list = findByUuid(uuid, count - 1, count,
866 orderByComparator);
867
868 if (list.isEmpty()) {
869 StringBundler msg = new StringBundler(4);
870
871 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
872
873 msg.append("uuid=");
874 msg.append(uuid);
875
876 msg.append(StringPool.CLOSE_CURLY_BRACE);
877
878 throw new NoSuchVocabularyException(msg.toString());
879 }
880 else {
881 return list.get(0);
882 }
883 }
884
885
899 public AssetVocabulary[] findByUuid_PrevAndNext(long vocabularyId,
900 String uuid, OrderByComparator orderByComparator)
901 throws NoSuchVocabularyException, SystemException {
902 AssetVocabulary assetVocabulary = findByPrimaryKey(vocabularyId);
903
904 Session session = null;
905
906 try {
907 session = openSession();
908
909 AssetVocabulary[] array = new AssetVocabularyImpl[3];
910
911 array[0] = getByUuid_PrevAndNext(session, assetVocabulary, uuid,
912 orderByComparator, true);
913
914 array[1] = assetVocabulary;
915
916 array[2] = getByUuid_PrevAndNext(session, assetVocabulary, uuid,
917 orderByComparator, false);
918
919 return array;
920 }
921 catch (Exception e) {
922 throw processException(e);
923 }
924 finally {
925 closeSession(session);
926 }
927 }
928
929 protected AssetVocabulary getByUuid_PrevAndNext(Session session,
930 AssetVocabulary assetVocabulary, String uuid,
931 OrderByComparator orderByComparator, boolean previous) {
932 StringBundler query = null;
933
934 if (orderByComparator != null) {
935 query = new StringBundler(6 +
936 (orderByComparator.getOrderByFields().length * 6));
937 }
938 else {
939 query = new StringBundler(3);
940 }
941
942 query.append(_SQL_SELECT_ASSETVOCABULARY_WHERE);
943
944 if (uuid == null) {
945 query.append(_FINDER_COLUMN_UUID_UUID_1);
946 }
947 else {
948 if (uuid.equals(StringPool.BLANK)) {
949 query.append(_FINDER_COLUMN_UUID_UUID_3);
950 }
951 else {
952 query.append(_FINDER_COLUMN_UUID_UUID_2);
953 }
954 }
955
956 if (orderByComparator != null) {
957 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
958
959 if (orderByConditionFields.length > 0) {
960 query.append(WHERE_AND);
961 }
962
963 for (int i = 0; i < orderByConditionFields.length; i++) {
964 query.append(_ORDER_BY_ENTITY_ALIAS);
965 query.append(orderByConditionFields[i]);
966
967 if ((i + 1) < orderByConditionFields.length) {
968 if (orderByComparator.isAscending() ^ previous) {
969 query.append(WHERE_GREATER_THAN_HAS_NEXT);
970 }
971 else {
972 query.append(WHERE_LESSER_THAN_HAS_NEXT);
973 }
974 }
975 else {
976 if (orderByComparator.isAscending() ^ previous) {
977 query.append(WHERE_GREATER_THAN);
978 }
979 else {
980 query.append(WHERE_LESSER_THAN);
981 }
982 }
983 }
984
985 query.append(ORDER_BY_CLAUSE);
986
987 String[] orderByFields = orderByComparator.getOrderByFields();
988
989 for (int i = 0; i < orderByFields.length; i++) {
990 query.append(_ORDER_BY_ENTITY_ALIAS);
991 query.append(orderByFields[i]);
992
993 if ((i + 1) < orderByFields.length) {
994 if (orderByComparator.isAscending() ^ previous) {
995 query.append(ORDER_BY_ASC_HAS_NEXT);
996 }
997 else {
998 query.append(ORDER_BY_DESC_HAS_NEXT);
999 }
1000 }
1001 else {
1002 if (orderByComparator.isAscending() ^ previous) {
1003 query.append(ORDER_BY_ASC);
1004 }
1005 else {
1006 query.append(ORDER_BY_DESC);
1007 }
1008 }
1009 }
1010 }
1011
1012 else {
1013 query.append(AssetVocabularyModelImpl.ORDER_BY_JPQL);
1014 }
1015
1016 String sql = query.toString();
1017
1018 Query q = session.createQuery(sql);
1019
1020 q.setFirstResult(0);
1021 q.setMaxResults(2);
1022
1023 QueryPos qPos = QueryPos.getInstance(q);
1024
1025 if (uuid != null) {
1026 qPos.add(uuid);
1027 }
1028
1029 if (orderByComparator != null) {
1030 Object[] values = orderByComparator.getOrderByConditionValues(assetVocabulary);
1031
1032 for (Object value : values) {
1033 qPos.add(value);
1034 }
1035 }
1036
1037 List<AssetVocabulary> list = q.list();
1038
1039 if (list.size() == 2) {
1040 return list.get(1);
1041 }
1042 else {
1043 return null;
1044 }
1045 }
1046
1047
1056 public AssetVocabulary findByUUID_G(String uuid, long groupId)
1057 throws NoSuchVocabularyException, SystemException {
1058 AssetVocabulary assetVocabulary = fetchByUUID_G(uuid, groupId);
1059
1060 if (assetVocabulary == null) {
1061 StringBundler msg = new StringBundler(6);
1062
1063 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1064
1065 msg.append("uuid=");
1066 msg.append(uuid);
1067
1068 msg.append(", groupId=");
1069 msg.append(groupId);
1070
1071 msg.append(StringPool.CLOSE_CURLY_BRACE);
1072
1073 if (_log.isWarnEnabled()) {
1074 _log.warn(msg.toString());
1075 }
1076
1077 throw new NoSuchVocabularyException(msg.toString());
1078 }
1079
1080 return assetVocabulary;
1081 }
1082
1083
1091 public AssetVocabulary fetchByUUID_G(String uuid, long groupId)
1092 throws SystemException {
1093 return fetchByUUID_G(uuid, groupId, true);
1094 }
1095
1096
1105 public AssetVocabulary fetchByUUID_G(String uuid, long groupId,
1106 boolean retrieveFromCache) throws SystemException {
1107 Object[] finderArgs = new Object[] { uuid, groupId };
1108
1109 Object result = null;
1110
1111 if (retrieveFromCache) {
1112 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_UUID_G,
1113 finderArgs, this);
1114 }
1115
1116 if (result instanceof AssetVocabulary) {
1117 AssetVocabulary assetVocabulary = (AssetVocabulary)result;
1118
1119 if (!Validator.equals(uuid, assetVocabulary.getUuid()) ||
1120 (groupId != assetVocabulary.getGroupId())) {
1121 result = null;
1122 }
1123 }
1124
1125 if (result == null) {
1126 StringBundler query = new StringBundler(4);
1127
1128 query.append(_SQL_SELECT_ASSETVOCABULARY_WHERE);
1129
1130 if (uuid == null) {
1131 query.append(_FINDER_COLUMN_UUID_G_UUID_1);
1132 }
1133 else {
1134 if (uuid.equals(StringPool.BLANK)) {
1135 query.append(_FINDER_COLUMN_UUID_G_UUID_3);
1136 }
1137 else {
1138 query.append(_FINDER_COLUMN_UUID_G_UUID_2);
1139 }
1140 }
1141
1142 query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
1143
1144 query.append(AssetVocabularyModelImpl.ORDER_BY_JPQL);
1145
1146 String sql = query.toString();
1147
1148 Session session = null;
1149
1150 try {
1151 session = openSession();
1152
1153 Query q = session.createQuery(sql);
1154
1155 QueryPos qPos = QueryPos.getInstance(q);
1156
1157 if (uuid != null) {
1158 qPos.add(uuid);
1159 }
1160
1161 qPos.add(groupId);
1162
1163 List<AssetVocabulary> list = q.list();
1164
1165 result = list;
1166
1167 AssetVocabulary assetVocabulary = null;
1168
1169 if (list.isEmpty()) {
1170 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
1171 finderArgs, list);
1172 }
1173 else {
1174 assetVocabulary = list.get(0);
1175
1176 cacheResult(assetVocabulary);
1177
1178 if ((assetVocabulary.getUuid() == null) ||
1179 !assetVocabulary.getUuid().equals(uuid) ||
1180 (assetVocabulary.getGroupId() != groupId)) {
1181 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
1182 finderArgs, assetVocabulary);
1183 }
1184 }
1185
1186 return assetVocabulary;
1187 }
1188 catch (Exception e) {
1189 throw processException(e);
1190 }
1191 finally {
1192 if (result == null) {
1193 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
1194 finderArgs);
1195 }
1196
1197 closeSession(session);
1198 }
1199 }
1200 else {
1201 if (result instanceof List<?>) {
1202 return null;
1203 }
1204 else {
1205 return (AssetVocabulary)result;
1206 }
1207 }
1208 }
1209
1210
1217 public List<AssetVocabulary> findByGroupId(long groupId)
1218 throws SystemException {
1219 return findByGroupId(groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1220 }
1221
1222
1235 public List<AssetVocabulary> findByGroupId(long groupId, int start, int end)
1236 throws SystemException {
1237 return findByGroupId(groupId, start, end, null);
1238 }
1239
1240
1254 public List<AssetVocabulary> findByGroupId(long groupId, int start,
1255 int end, OrderByComparator orderByComparator) throws SystemException {
1256 FinderPath finderPath = null;
1257 Object[] finderArgs = null;
1258
1259 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1260 (orderByComparator == null)) {
1261 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID;
1262 finderArgs = new Object[] { groupId };
1263 }
1264 else {
1265 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID;
1266 finderArgs = new Object[] { groupId, start, end, orderByComparator };
1267 }
1268
1269 List<AssetVocabulary> list = (List<AssetVocabulary>)FinderCacheUtil.getResult(finderPath,
1270 finderArgs, this);
1271
1272 if ((list != null) && !list.isEmpty()) {
1273 for (AssetVocabulary assetVocabulary : list) {
1274 if ((groupId != assetVocabulary.getGroupId())) {
1275 list = null;
1276
1277 break;
1278 }
1279 }
1280 }
1281
1282 if (list == null) {
1283 StringBundler query = null;
1284
1285 if (orderByComparator != null) {
1286 query = new StringBundler(3 +
1287 (orderByComparator.getOrderByFields().length * 3));
1288 }
1289 else {
1290 query = new StringBundler(3);
1291 }
1292
1293 query.append(_SQL_SELECT_ASSETVOCABULARY_WHERE);
1294
1295 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1296
1297 if (orderByComparator != null) {
1298 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1299 orderByComparator);
1300 }
1301
1302 else {
1303 query.append(AssetVocabularyModelImpl.ORDER_BY_JPQL);
1304 }
1305
1306 String sql = query.toString();
1307
1308 Session session = null;
1309
1310 try {
1311 session = openSession();
1312
1313 Query q = session.createQuery(sql);
1314
1315 QueryPos qPos = QueryPos.getInstance(q);
1316
1317 qPos.add(groupId);
1318
1319 list = (List<AssetVocabulary>)QueryUtil.list(q, getDialect(),
1320 start, end);
1321 }
1322 catch (Exception e) {
1323 throw processException(e);
1324 }
1325 finally {
1326 if (list == null) {
1327 FinderCacheUtil.removeResult(finderPath, finderArgs);
1328 }
1329 else {
1330 cacheResult(list);
1331
1332 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1333 }
1334
1335 closeSession(session);
1336 }
1337 }
1338
1339 return list;
1340 }
1341
1342
1355 public AssetVocabulary findByGroupId_First(long groupId,
1356 OrderByComparator orderByComparator)
1357 throws NoSuchVocabularyException, SystemException {
1358 List<AssetVocabulary> list = findByGroupId(groupId, 0, 1,
1359 orderByComparator);
1360
1361 if (list.isEmpty()) {
1362 StringBundler msg = new StringBundler(4);
1363
1364 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1365
1366 msg.append("groupId=");
1367 msg.append(groupId);
1368
1369 msg.append(StringPool.CLOSE_CURLY_BRACE);
1370
1371 throw new NoSuchVocabularyException(msg.toString());
1372 }
1373 else {
1374 return list.get(0);
1375 }
1376 }
1377
1378
1391 public AssetVocabulary findByGroupId_Last(long groupId,
1392 OrderByComparator orderByComparator)
1393 throws NoSuchVocabularyException, SystemException {
1394 int count = countByGroupId(groupId);
1395
1396 List<AssetVocabulary> list = findByGroupId(groupId, count - 1, count,
1397 orderByComparator);
1398
1399 if (list.isEmpty()) {
1400 StringBundler msg = new StringBundler(4);
1401
1402 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1403
1404 msg.append("groupId=");
1405 msg.append(groupId);
1406
1407 msg.append(StringPool.CLOSE_CURLY_BRACE);
1408
1409 throw new NoSuchVocabularyException(msg.toString());
1410 }
1411 else {
1412 return list.get(0);
1413 }
1414 }
1415
1416
1430 public AssetVocabulary[] findByGroupId_PrevAndNext(long vocabularyId,
1431 long groupId, OrderByComparator orderByComparator)
1432 throws NoSuchVocabularyException, SystemException {
1433 AssetVocabulary assetVocabulary = findByPrimaryKey(vocabularyId);
1434
1435 Session session = null;
1436
1437 try {
1438 session = openSession();
1439
1440 AssetVocabulary[] array = new AssetVocabularyImpl[3];
1441
1442 array[0] = getByGroupId_PrevAndNext(session, assetVocabulary,
1443 groupId, orderByComparator, true);
1444
1445 array[1] = assetVocabulary;
1446
1447 array[2] = getByGroupId_PrevAndNext(session, assetVocabulary,
1448 groupId, orderByComparator, false);
1449
1450 return array;
1451 }
1452 catch (Exception e) {
1453 throw processException(e);
1454 }
1455 finally {
1456 closeSession(session);
1457 }
1458 }
1459
1460 protected AssetVocabulary getByGroupId_PrevAndNext(Session session,
1461 AssetVocabulary assetVocabulary, long groupId,
1462 OrderByComparator orderByComparator, boolean previous) {
1463 StringBundler query = null;
1464
1465 if (orderByComparator != null) {
1466 query = new StringBundler(6 +
1467 (orderByComparator.getOrderByFields().length * 6));
1468 }
1469 else {
1470 query = new StringBundler(3);
1471 }
1472
1473 query.append(_SQL_SELECT_ASSETVOCABULARY_WHERE);
1474
1475 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1476
1477 if (orderByComparator != null) {
1478 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1479
1480 if (orderByConditionFields.length > 0) {
1481 query.append(WHERE_AND);
1482 }
1483
1484 for (int i = 0; i < orderByConditionFields.length; i++) {
1485 query.append(_ORDER_BY_ENTITY_ALIAS);
1486 query.append(orderByConditionFields[i]);
1487
1488 if ((i + 1) < orderByConditionFields.length) {
1489 if (orderByComparator.isAscending() ^ previous) {
1490 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1491 }
1492 else {
1493 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1494 }
1495 }
1496 else {
1497 if (orderByComparator.isAscending() ^ previous) {
1498 query.append(WHERE_GREATER_THAN);
1499 }
1500 else {
1501 query.append(WHERE_LESSER_THAN);
1502 }
1503 }
1504 }
1505
1506 query.append(ORDER_BY_CLAUSE);
1507
1508 String[] orderByFields = orderByComparator.getOrderByFields();
1509
1510 for (int i = 0; i < orderByFields.length; i++) {
1511 query.append(_ORDER_BY_ENTITY_ALIAS);
1512 query.append(orderByFields[i]);
1513
1514 if ((i + 1) < orderByFields.length) {
1515 if (orderByComparator.isAscending() ^ previous) {
1516 query.append(ORDER_BY_ASC_HAS_NEXT);
1517 }
1518 else {
1519 query.append(ORDER_BY_DESC_HAS_NEXT);
1520 }
1521 }
1522 else {
1523 if (orderByComparator.isAscending() ^ previous) {
1524 query.append(ORDER_BY_ASC);
1525 }
1526 else {
1527 query.append(ORDER_BY_DESC);
1528 }
1529 }
1530 }
1531 }
1532
1533 else {
1534 query.append(AssetVocabularyModelImpl.ORDER_BY_JPQL);
1535 }
1536
1537 String sql = query.toString();
1538
1539 Query q = session.createQuery(sql);
1540
1541 q.setFirstResult(0);
1542 q.setMaxResults(2);
1543
1544 QueryPos qPos = QueryPos.getInstance(q);
1545
1546 qPos.add(groupId);
1547
1548 if (orderByComparator != null) {
1549 Object[] values = orderByComparator.getOrderByConditionValues(assetVocabulary);
1550
1551 for (Object value : values) {
1552 qPos.add(value);
1553 }
1554 }
1555
1556 List<AssetVocabulary> list = q.list();
1557
1558 if (list.size() == 2) {
1559 return list.get(1);
1560 }
1561 else {
1562 return null;
1563 }
1564 }
1565
1566
1573 public List<AssetVocabulary> filterFindByGroupId(long groupId)
1574 throws SystemException {
1575 return filterFindByGroupId(groupId, QueryUtil.ALL_POS,
1576 QueryUtil.ALL_POS, null);
1577 }
1578
1579
1592 public List<AssetVocabulary> filterFindByGroupId(long groupId, int start,
1593 int end) throws SystemException {
1594 return filterFindByGroupId(groupId, start, end, null);
1595 }
1596
1597
1611 public List<AssetVocabulary> filterFindByGroupId(long groupId, int start,
1612 int end, OrderByComparator orderByComparator) throws SystemException {
1613 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
1614 return findByGroupId(groupId, start, end, orderByComparator);
1615 }
1616
1617 StringBundler query = null;
1618
1619 if (orderByComparator != null) {
1620 query = new StringBundler(3 +
1621 (orderByComparator.getOrderByFields().length * 3));
1622 }
1623 else {
1624 query = new StringBundler(3);
1625 }
1626
1627 if (getDB().isSupportsInlineDistinct()) {
1628 query.append(_FILTER_SQL_SELECT_ASSETVOCABULARY_WHERE);
1629 }
1630 else {
1631 query.append(_FILTER_SQL_SELECT_ASSETVOCABULARY_NO_INLINE_DISTINCT_WHERE_1);
1632 }
1633
1634 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1635
1636 if (!getDB().isSupportsInlineDistinct()) {
1637 query.append(_FILTER_SQL_SELECT_ASSETVOCABULARY_NO_INLINE_DISTINCT_WHERE_2);
1638 }
1639
1640 if (orderByComparator != null) {
1641 if (getDB().isSupportsInlineDistinct()) {
1642 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1643 orderByComparator);
1644 }
1645 else {
1646 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
1647 orderByComparator);
1648 }
1649 }
1650
1651 else {
1652 if (getDB().isSupportsInlineDistinct()) {
1653 query.append(AssetVocabularyModelImpl.ORDER_BY_JPQL);
1654 }
1655 else {
1656 query.append(AssetVocabularyModelImpl.ORDER_BY_SQL);
1657 }
1658 }
1659
1660 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1661 AssetVocabulary.class.getName(),
1662 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
1663
1664 Session session = null;
1665
1666 try {
1667 session = openSession();
1668
1669 SQLQuery q = session.createSQLQuery(sql);
1670
1671 if (getDB().isSupportsInlineDistinct()) {
1672 q.addEntity(_FILTER_ENTITY_ALIAS, AssetVocabularyImpl.class);
1673 }
1674 else {
1675 q.addEntity(_FILTER_ENTITY_TABLE, AssetVocabularyImpl.class);
1676 }
1677
1678 QueryPos qPos = QueryPos.getInstance(q);
1679
1680 qPos.add(groupId);
1681
1682 return (List<AssetVocabulary>)QueryUtil.list(q, getDialect(),
1683 start, end);
1684 }
1685 catch (Exception e) {
1686 throw processException(e);
1687 }
1688 finally {
1689 closeSession(session);
1690 }
1691 }
1692
1693
1703 public AssetVocabulary[] filterFindByGroupId_PrevAndNext(
1704 long vocabularyId, long groupId, OrderByComparator orderByComparator)
1705 throws NoSuchVocabularyException, SystemException {
1706 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
1707 return findByGroupId_PrevAndNext(vocabularyId, groupId,
1708 orderByComparator);
1709 }
1710
1711 AssetVocabulary assetVocabulary = findByPrimaryKey(vocabularyId);
1712
1713 Session session = null;
1714
1715 try {
1716 session = openSession();
1717
1718 AssetVocabulary[] array = new AssetVocabularyImpl[3];
1719
1720 array[0] = filterGetByGroupId_PrevAndNext(session, assetVocabulary,
1721 groupId, orderByComparator, true);
1722
1723 array[1] = assetVocabulary;
1724
1725 array[2] = filterGetByGroupId_PrevAndNext(session, assetVocabulary,
1726 groupId, orderByComparator, false);
1727
1728 return array;
1729 }
1730 catch (Exception e) {
1731 throw processException(e);
1732 }
1733 finally {
1734 closeSession(session);
1735 }
1736 }
1737
1738 protected AssetVocabulary filterGetByGroupId_PrevAndNext(Session session,
1739 AssetVocabulary assetVocabulary, long groupId,
1740 OrderByComparator orderByComparator, boolean previous) {
1741 StringBundler query = null;
1742
1743 if (orderByComparator != null) {
1744 query = new StringBundler(6 +
1745 (orderByComparator.getOrderByFields().length * 6));
1746 }
1747 else {
1748 query = new StringBundler(3);
1749 }
1750
1751 if (getDB().isSupportsInlineDistinct()) {
1752 query.append(_FILTER_SQL_SELECT_ASSETVOCABULARY_WHERE);
1753 }
1754 else {
1755 query.append(_FILTER_SQL_SELECT_ASSETVOCABULARY_NO_INLINE_DISTINCT_WHERE_1);
1756 }
1757
1758 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1759
1760 if (!getDB().isSupportsInlineDistinct()) {
1761 query.append(_FILTER_SQL_SELECT_ASSETVOCABULARY_NO_INLINE_DISTINCT_WHERE_2);
1762 }
1763
1764 if (orderByComparator != null) {
1765 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1766
1767 if (orderByConditionFields.length > 0) {
1768 query.append(WHERE_AND);
1769 }
1770
1771 for (int i = 0; i < orderByConditionFields.length; i++) {
1772 if (getDB().isSupportsInlineDistinct()) {
1773 query.append(_ORDER_BY_ENTITY_ALIAS);
1774 }
1775 else {
1776 query.append(_ORDER_BY_ENTITY_TABLE);
1777 }
1778
1779 query.append(orderByConditionFields[i]);
1780
1781 if ((i + 1) < orderByConditionFields.length) {
1782 if (orderByComparator.isAscending() ^ previous) {
1783 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1784 }
1785 else {
1786 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1787 }
1788 }
1789 else {
1790 if (orderByComparator.isAscending() ^ previous) {
1791 query.append(WHERE_GREATER_THAN);
1792 }
1793 else {
1794 query.append(WHERE_LESSER_THAN);
1795 }
1796 }
1797 }
1798
1799 query.append(ORDER_BY_CLAUSE);
1800
1801 String[] orderByFields = orderByComparator.getOrderByFields();
1802
1803 for (int i = 0; i < orderByFields.length; i++) {
1804 if (getDB().isSupportsInlineDistinct()) {
1805 query.append(_ORDER_BY_ENTITY_ALIAS);
1806 }
1807 else {
1808 query.append(_ORDER_BY_ENTITY_TABLE);
1809 }
1810
1811 query.append(orderByFields[i]);
1812
1813 if ((i + 1) < orderByFields.length) {
1814 if (orderByComparator.isAscending() ^ previous) {
1815 query.append(ORDER_BY_ASC_HAS_NEXT);
1816 }
1817 else {
1818 query.append(ORDER_BY_DESC_HAS_NEXT);
1819 }
1820 }
1821 else {
1822 if (orderByComparator.isAscending() ^ previous) {
1823 query.append(ORDER_BY_ASC);
1824 }
1825 else {
1826 query.append(ORDER_BY_DESC);
1827 }
1828 }
1829 }
1830 }
1831
1832 else {
1833 if (getDB().isSupportsInlineDistinct()) {
1834 query.append(AssetVocabularyModelImpl.ORDER_BY_JPQL);
1835 }
1836 else {
1837 query.append(AssetVocabularyModelImpl.ORDER_BY_SQL);
1838 }
1839 }
1840
1841 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1842 AssetVocabulary.class.getName(),
1843 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
1844
1845 SQLQuery q = session.createSQLQuery(sql);
1846
1847 q.setFirstResult(0);
1848 q.setMaxResults(2);
1849
1850 if (getDB().isSupportsInlineDistinct()) {
1851 q.addEntity(_FILTER_ENTITY_ALIAS, AssetVocabularyImpl.class);
1852 }
1853 else {
1854 q.addEntity(_FILTER_ENTITY_TABLE, AssetVocabularyImpl.class);
1855 }
1856
1857 QueryPos qPos = QueryPos.getInstance(q);
1858
1859 qPos.add(groupId);
1860
1861 if (orderByComparator != null) {
1862 Object[] values = orderByComparator.getOrderByConditionValues(assetVocabulary);
1863
1864 for (Object value : values) {
1865 qPos.add(value);
1866 }
1867 }
1868
1869 List<AssetVocabulary> list = q.list();
1870
1871 if (list.size() == 2) {
1872 return list.get(1);
1873 }
1874 else {
1875 return null;
1876 }
1877 }
1878
1879
1886 public List<AssetVocabulary> findByCompanyId(long companyId)
1887 throws SystemException {
1888 return findByCompanyId(companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
1889 null);
1890 }
1891
1892
1905 public List<AssetVocabulary> findByCompanyId(long companyId, int start,
1906 int end) throws SystemException {
1907 return findByCompanyId(companyId, start, end, null);
1908 }
1909
1910
1924 public List<AssetVocabulary> findByCompanyId(long companyId, int start,
1925 int end, OrderByComparator orderByComparator) throws SystemException {
1926 FinderPath finderPath = null;
1927 Object[] finderArgs = null;
1928
1929 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1930 (orderByComparator == null)) {
1931 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID;
1932 finderArgs = new Object[] { companyId };
1933 }
1934 else {
1935 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID;
1936 finderArgs = new Object[] { companyId, start, end, orderByComparator };
1937 }
1938
1939 List<AssetVocabulary> list = (List<AssetVocabulary>)FinderCacheUtil.getResult(finderPath,
1940 finderArgs, this);
1941
1942 if ((list != null) && !list.isEmpty()) {
1943 for (AssetVocabulary assetVocabulary : list) {
1944 if ((companyId != assetVocabulary.getCompanyId())) {
1945 list = null;
1946
1947 break;
1948 }
1949 }
1950 }
1951
1952 if (list == null) {
1953 StringBundler query = null;
1954
1955 if (orderByComparator != null) {
1956 query = new StringBundler(3 +
1957 (orderByComparator.getOrderByFields().length * 3));
1958 }
1959 else {
1960 query = new StringBundler(3);
1961 }
1962
1963 query.append(_SQL_SELECT_ASSETVOCABULARY_WHERE);
1964
1965 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
1966
1967 if (orderByComparator != null) {
1968 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1969 orderByComparator);
1970 }
1971
1972 else {
1973 query.append(AssetVocabularyModelImpl.ORDER_BY_JPQL);
1974 }
1975
1976 String sql = query.toString();
1977
1978 Session session = null;
1979
1980 try {
1981 session = openSession();
1982
1983 Query q = session.createQuery(sql);
1984
1985 QueryPos qPos = QueryPos.getInstance(q);
1986
1987 qPos.add(companyId);
1988
1989 list = (List<AssetVocabulary>)QueryUtil.list(q, getDialect(),
1990 start, end);
1991 }
1992 catch (Exception e) {
1993 throw processException(e);
1994 }
1995 finally {
1996 if (list == null) {
1997 FinderCacheUtil.removeResult(finderPath, finderArgs);
1998 }
1999 else {
2000 cacheResult(list);
2001
2002 FinderCacheUtil.putResult(finderPath, finderArgs, list);
2003 }
2004
2005 closeSession(session);
2006 }
2007 }
2008
2009 return list;
2010 }
2011
2012
2025 public AssetVocabulary findByCompanyId_First(long companyId,
2026 OrderByComparator orderByComparator)
2027 throws NoSuchVocabularyException, SystemException {
2028 List<AssetVocabulary> list = findByCompanyId(companyId, 0, 1,
2029 orderByComparator);
2030
2031 if (list.isEmpty()) {
2032 StringBundler msg = new StringBundler(4);
2033
2034 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2035
2036 msg.append("companyId=");
2037 msg.append(companyId);
2038
2039 msg.append(StringPool.CLOSE_CURLY_BRACE);
2040
2041 throw new NoSuchVocabularyException(msg.toString());
2042 }
2043 else {
2044 return list.get(0);
2045 }
2046 }
2047
2048
2061 public AssetVocabulary findByCompanyId_Last(long companyId,
2062 OrderByComparator orderByComparator)
2063 throws NoSuchVocabularyException, SystemException {
2064 int count = countByCompanyId(companyId);
2065
2066 List<AssetVocabulary> list = findByCompanyId(companyId, count - 1,
2067 count, orderByComparator);
2068
2069 if (list.isEmpty()) {
2070 StringBundler msg = new StringBundler(4);
2071
2072 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2073
2074 msg.append("companyId=");
2075 msg.append(companyId);
2076
2077 msg.append(StringPool.CLOSE_CURLY_BRACE);
2078
2079 throw new NoSuchVocabularyException(msg.toString());
2080 }
2081 else {
2082 return list.get(0);
2083 }
2084 }
2085
2086
2100 public AssetVocabulary[] findByCompanyId_PrevAndNext(long vocabularyId,
2101 long companyId, OrderByComparator orderByComparator)
2102 throws NoSuchVocabularyException, SystemException {
2103 AssetVocabulary assetVocabulary = findByPrimaryKey(vocabularyId);
2104
2105 Session session = null;
2106
2107 try {
2108 session = openSession();
2109
2110 AssetVocabulary[] array = new AssetVocabularyImpl[3];
2111
2112 array[0] = getByCompanyId_PrevAndNext(session, assetVocabulary,
2113 companyId, orderByComparator, true);
2114
2115 array[1] = assetVocabulary;
2116
2117 array[2] = getByCompanyId_PrevAndNext(session, assetVocabulary,
2118 companyId, orderByComparator, false);
2119
2120 return array;
2121 }
2122 catch (Exception e) {
2123 throw processException(e);
2124 }
2125 finally {
2126 closeSession(session);
2127 }
2128 }
2129
2130 protected AssetVocabulary getByCompanyId_PrevAndNext(Session session,
2131 AssetVocabulary assetVocabulary, long companyId,
2132 OrderByComparator orderByComparator, boolean previous) {
2133 StringBundler query = null;
2134
2135 if (orderByComparator != null) {
2136 query = new StringBundler(6 +
2137 (orderByComparator.getOrderByFields().length * 6));
2138 }
2139 else {
2140 query = new StringBundler(3);
2141 }
2142
2143 query.append(_SQL_SELECT_ASSETVOCABULARY_WHERE);
2144
2145 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
2146
2147 if (orderByComparator != null) {
2148 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2149
2150 if (orderByConditionFields.length > 0) {
2151 query.append(WHERE_AND);
2152 }
2153
2154 for (int i = 0; i < orderByConditionFields.length; i++) {
2155 query.append(_ORDER_BY_ENTITY_ALIAS);
2156 query.append(orderByConditionFields[i]);
2157
2158 if ((i + 1) < orderByConditionFields.length) {
2159 if (orderByComparator.isAscending() ^ previous) {
2160 query.append(WHERE_GREATER_THAN_HAS_NEXT);
2161 }
2162 else {
2163 query.append(WHERE_LESSER_THAN_HAS_NEXT);
2164 }
2165 }
2166 else {
2167 if (orderByComparator.isAscending() ^ previous) {
2168 query.append(WHERE_GREATER_THAN);
2169 }
2170 else {
2171 query.append(WHERE_LESSER_THAN);
2172 }
2173 }
2174 }
2175
2176 query.append(ORDER_BY_CLAUSE);
2177
2178 String[] orderByFields = orderByComparator.getOrderByFields();
2179
2180 for (int i = 0; i < orderByFields.length; i++) {
2181 query.append(_ORDER_BY_ENTITY_ALIAS);
2182 query.append(orderByFields[i]);
2183
2184 if ((i + 1) < orderByFields.length) {
2185 if (orderByComparator.isAscending() ^ previous) {
2186 query.append(ORDER_BY_ASC_HAS_NEXT);
2187 }
2188 else {
2189 query.append(ORDER_BY_DESC_HAS_NEXT);
2190 }
2191 }
2192 else {
2193 if (orderByComparator.isAscending() ^ previous) {
2194 query.append(ORDER_BY_ASC);
2195 }
2196 else {
2197 query.append(ORDER_BY_DESC);
2198 }
2199 }
2200 }
2201 }
2202
2203 else {
2204 query.append(AssetVocabularyModelImpl.ORDER_BY_JPQL);
2205 }
2206
2207 String sql = query.toString();
2208
2209 Query q = session.createQuery(sql);
2210
2211 q.setFirstResult(0);
2212 q.setMaxResults(2);
2213
2214 QueryPos qPos = QueryPos.getInstance(q);
2215
2216 qPos.add(companyId);
2217
2218 if (orderByComparator != null) {
2219 Object[] values = orderByComparator.getOrderByConditionValues(assetVocabulary);
2220
2221 for (Object value : values) {
2222 qPos.add(value);
2223 }
2224 }
2225
2226 List<AssetVocabulary> list = q.list();
2227
2228 if (list.size() == 2) {
2229 return list.get(1);
2230 }
2231 else {
2232 return null;
2233 }
2234 }
2235
2236
2245 public AssetVocabulary findByG_N(long groupId, String name)
2246 throws NoSuchVocabularyException, SystemException {
2247 AssetVocabulary assetVocabulary = fetchByG_N(groupId, name);
2248
2249 if (assetVocabulary == null) {
2250 StringBundler msg = new StringBundler(6);
2251
2252 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2253
2254 msg.append("groupId=");
2255 msg.append(groupId);
2256
2257 msg.append(", name=");
2258 msg.append(name);
2259
2260 msg.append(StringPool.CLOSE_CURLY_BRACE);
2261
2262 if (_log.isWarnEnabled()) {
2263 _log.warn(msg.toString());
2264 }
2265
2266 throw new NoSuchVocabularyException(msg.toString());
2267 }
2268
2269 return assetVocabulary;
2270 }
2271
2272
2280 public AssetVocabulary fetchByG_N(long groupId, String name)
2281 throws SystemException {
2282 return fetchByG_N(groupId, name, true);
2283 }
2284
2285
2294 public AssetVocabulary fetchByG_N(long groupId, String name,
2295 boolean retrieveFromCache) throws SystemException {
2296 Object[] finderArgs = new Object[] { groupId, name };
2297
2298 Object result = null;
2299
2300 if (retrieveFromCache) {
2301 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_G_N,
2302 finderArgs, this);
2303 }
2304
2305 if (result instanceof AssetVocabulary) {
2306 AssetVocabulary assetVocabulary = (AssetVocabulary)result;
2307
2308 if ((groupId != assetVocabulary.getGroupId()) ||
2309 !Validator.equals(name, assetVocabulary.getName())) {
2310 result = null;
2311 }
2312 }
2313
2314 if (result == null) {
2315 StringBundler query = new StringBundler(4);
2316
2317 query.append(_SQL_SELECT_ASSETVOCABULARY_WHERE);
2318
2319 query.append(_FINDER_COLUMN_G_N_GROUPID_2);
2320
2321 if (name == null) {
2322 query.append(_FINDER_COLUMN_G_N_NAME_1);
2323 }
2324 else {
2325 if (name.equals(StringPool.BLANK)) {
2326 query.append(_FINDER_COLUMN_G_N_NAME_3);
2327 }
2328 else {
2329 query.append(_FINDER_COLUMN_G_N_NAME_2);
2330 }
2331 }
2332
2333 query.append(AssetVocabularyModelImpl.ORDER_BY_JPQL);
2334
2335 String sql = query.toString();
2336
2337 Session session = null;
2338
2339 try {
2340 session = openSession();
2341
2342 Query q = session.createQuery(sql);
2343
2344 QueryPos qPos = QueryPos.getInstance(q);
2345
2346 qPos.add(groupId);
2347
2348 if (name != null) {
2349 qPos.add(name);
2350 }
2351
2352 List<AssetVocabulary> list = q.list();
2353
2354 result = list;
2355
2356 AssetVocabulary assetVocabulary = null;
2357
2358 if (list.isEmpty()) {
2359 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_N,
2360 finderArgs, list);
2361 }
2362 else {
2363 assetVocabulary = list.get(0);
2364
2365 cacheResult(assetVocabulary);
2366
2367 if ((assetVocabulary.getGroupId() != groupId) ||
2368 (assetVocabulary.getName() == null) ||
2369 !assetVocabulary.getName().equals(name)) {
2370 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_N,
2371 finderArgs, assetVocabulary);
2372 }
2373 }
2374
2375 return assetVocabulary;
2376 }
2377 catch (Exception e) {
2378 throw processException(e);
2379 }
2380 finally {
2381 if (result == null) {
2382 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_N,
2383 finderArgs);
2384 }
2385
2386 closeSession(session);
2387 }
2388 }
2389 else {
2390 if (result instanceof List<?>) {
2391 return null;
2392 }
2393 else {
2394 return (AssetVocabulary)result;
2395 }
2396 }
2397 }
2398
2399
2405 public List<AssetVocabulary> findAll() throws SystemException {
2406 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
2407 }
2408
2409
2421 public List<AssetVocabulary> findAll(int start, int end)
2422 throws SystemException {
2423 return findAll(start, end, null);
2424 }
2425
2426
2439 public List<AssetVocabulary> findAll(int start, int end,
2440 OrderByComparator orderByComparator) throws SystemException {
2441 FinderPath finderPath = null;
2442 Object[] finderArgs = new Object[] { start, end, orderByComparator };
2443
2444 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2445 (orderByComparator == null)) {
2446 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
2447 finderArgs = FINDER_ARGS_EMPTY;
2448 }
2449 else {
2450 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
2451 finderArgs = new Object[] { start, end, orderByComparator };
2452 }
2453
2454 List<AssetVocabulary> list = (List<AssetVocabulary>)FinderCacheUtil.getResult(finderPath,
2455 finderArgs, this);
2456
2457 if (list == null) {
2458 StringBundler query = null;
2459 String sql = null;
2460
2461 if (orderByComparator != null) {
2462 query = new StringBundler(2 +
2463 (orderByComparator.getOrderByFields().length * 3));
2464
2465 query.append(_SQL_SELECT_ASSETVOCABULARY);
2466
2467 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2468 orderByComparator);
2469
2470 sql = query.toString();
2471 }
2472 else {
2473 sql = _SQL_SELECT_ASSETVOCABULARY.concat(AssetVocabularyModelImpl.ORDER_BY_JPQL);
2474 }
2475
2476 Session session = null;
2477
2478 try {
2479 session = openSession();
2480
2481 Query q = session.createQuery(sql);
2482
2483 if (orderByComparator == null) {
2484 list = (List<AssetVocabulary>)QueryUtil.list(q,
2485 getDialect(), start, end, false);
2486
2487 Collections.sort(list);
2488 }
2489 else {
2490 list = (List<AssetVocabulary>)QueryUtil.list(q,
2491 getDialect(), start, end);
2492 }
2493 }
2494 catch (Exception e) {
2495 throw processException(e);
2496 }
2497 finally {
2498 if (list == null) {
2499 FinderCacheUtil.removeResult(finderPath, finderArgs);
2500 }
2501 else {
2502 cacheResult(list);
2503
2504 FinderCacheUtil.putResult(finderPath, finderArgs, list);
2505 }
2506
2507 closeSession(session);
2508 }
2509 }
2510
2511 return list;
2512 }
2513
2514
2520 public void removeByUuid(String uuid) throws SystemException {
2521 for (AssetVocabulary assetVocabulary : findByUuid(uuid)) {
2522 remove(assetVocabulary);
2523 }
2524 }
2525
2526
2533 public void removeByUUID_G(String uuid, long groupId)
2534 throws NoSuchVocabularyException, SystemException {
2535 AssetVocabulary assetVocabulary = findByUUID_G(uuid, groupId);
2536
2537 remove(assetVocabulary);
2538 }
2539
2540
2546 public void removeByGroupId(long groupId) throws SystemException {
2547 for (AssetVocabulary assetVocabulary : findByGroupId(groupId)) {
2548 remove(assetVocabulary);
2549 }
2550 }
2551
2552
2558 public void removeByCompanyId(long companyId) throws SystemException {
2559 for (AssetVocabulary assetVocabulary : findByCompanyId(companyId)) {
2560 remove(assetVocabulary);
2561 }
2562 }
2563
2564
2571 public void removeByG_N(long groupId, String name)
2572 throws NoSuchVocabularyException, SystemException {
2573 AssetVocabulary assetVocabulary = findByG_N(groupId, name);
2574
2575 remove(assetVocabulary);
2576 }
2577
2578
2583 public void removeAll() throws SystemException {
2584 for (AssetVocabulary assetVocabulary : findAll()) {
2585 remove(assetVocabulary);
2586 }
2587 }
2588
2589
2596 public int countByUuid(String uuid) throws SystemException {
2597 Object[] finderArgs = new Object[] { uuid };
2598
2599 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID,
2600 finderArgs, this);
2601
2602 if (count == null) {
2603 StringBundler query = new StringBundler(2);
2604
2605 query.append(_SQL_COUNT_ASSETVOCABULARY_WHERE);
2606
2607 if (uuid == null) {
2608 query.append(_FINDER_COLUMN_UUID_UUID_1);
2609 }
2610 else {
2611 if (uuid.equals(StringPool.BLANK)) {
2612 query.append(_FINDER_COLUMN_UUID_UUID_3);
2613 }
2614 else {
2615 query.append(_FINDER_COLUMN_UUID_UUID_2);
2616 }
2617 }
2618
2619 String sql = query.toString();
2620
2621 Session session = null;
2622
2623 try {
2624 session = openSession();
2625
2626 Query q = session.createQuery(sql);
2627
2628 QueryPos qPos = QueryPos.getInstance(q);
2629
2630 if (uuid != null) {
2631 qPos.add(uuid);
2632 }
2633
2634 count = (Long)q.uniqueResult();
2635 }
2636 catch (Exception e) {
2637 throw processException(e);
2638 }
2639 finally {
2640 if (count == null) {
2641 count = Long.valueOf(0);
2642 }
2643
2644 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID,
2645 finderArgs, count);
2646
2647 closeSession(session);
2648 }
2649 }
2650
2651 return count.intValue();
2652 }
2653
2654
2662 public int countByUUID_G(String uuid, long groupId)
2663 throws SystemException {
2664 Object[] finderArgs = new Object[] { uuid, groupId };
2665
2666 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID_G,
2667 finderArgs, this);
2668
2669 if (count == null) {
2670 StringBundler query = new StringBundler(3);
2671
2672 query.append(_SQL_COUNT_ASSETVOCABULARY_WHERE);
2673
2674 if (uuid == null) {
2675 query.append(_FINDER_COLUMN_UUID_G_UUID_1);
2676 }
2677 else {
2678 if (uuid.equals(StringPool.BLANK)) {
2679 query.append(_FINDER_COLUMN_UUID_G_UUID_3);
2680 }
2681 else {
2682 query.append(_FINDER_COLUMN_UUID_G_UUID_2);
2683 }
2684 }
2685
2686 query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
2687
2688 String sql = query.toString();
2689
2690 Session session = null;
2691
2692 try {
2693 session = openSession();
2694
2695 Query q = session.createQuery(sql);
2696
2697 QueryPos qPos = QueryPos.getInstance(q);
2698
2699 if (uuid != null) {
2700 qPos.add(uuid);
2701 }
2702
2703 qPos.add(groupId);
2704
2705 count = (Long)q.uniqueResult();
2706 }
2707 catch (Exception e) {
2708 throw processException(e);
2709 }
2710 finally {
2711 if (count == null) {
2712 count = Long.valueOf(0);
2713 }
2714
2715 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G,
2716 finderArgs, count);
2717
2718 closeSession(session);
2719 }
2720 }
2721
2722 return count.intValue();
2723 }
2724
2725
2732 public int countByGroupId(long groupId) throws SystemException {
2733 Object[] finderArgs = new Object[] { groupId };
2734
2735 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_GROUPID,
2736 finderArgs, this);
2737
2738 if (count == null) {
2739 StringBundler query = new StringBundler(2);
2740
2741 query.append(_SQL_COUNT_ASSETVOCABULARY_WHERE);
2742
2743 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2744
2745 String sql = query.toString();
2746
2747 Session session = null;
2748
2749 try {
2750 session = openSession();
2751
2752 Query q = session.createQuery(sql);
2753
2754 QueryPos qPos = QueryPos.getInstance(q);
2755
2756 qPos.add(groupId);
2757
2758 count = (Long)q.uniqueResult();
2759 }
2760 catch (Exception e) {
2761 throw processException(e);
2762 }
2763 finally {
2764 if (count == null) {
2765 count = Long.valueOf(0);
2766 }
2767
2768 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_GROUPID,
2769 finderArgs, count);
2770
2771 closeSession(session);
2772 }
2773 }
2774
2775 return count.intValue();
2776 }
2777
2778
2785 public int filterCountByGroupId(long groupId) throws SystemException {
2786 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2787 return countByGroupId(groupId);
2788 }
2789
2790 StringBundler query = new StringBundler(2);
2791
2792 query.append(_FILTER_SQL_COUNT_ASSETVOCABULARY_WHERE);
2793
2794 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2795
2796 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2797 AssetVocabulary.class.getName(),
2798 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2799
2800 Session session = null;
2801
2802 try {
2803 session = openSession();
2804
2805 SQLQuery q = session.createSQLQuery(sql);
2806
2807 q.addScalar(COUNT_COLUMN_NAME,
2808 com.liferay.portal.kernel.dao.orm.Type.LONG);
2809
2810 QueryPos qPos = QueryPos.getInstance(q);
2811
2812 qPos.add(groupId);
2813
2814 Long count = (Long)q.uniqueResult();
2815
2816 return count.intValue();
2817 }
2818 catch (Exception e) {
2819 throw processException(e);
2820 }
2821 finally {
2822 closeSession(session);
2823 }
2824 }
2825
2826
2833 public int countByCompanyId(long companyId) throws SystemException {
2834 Object[] finderArgs = new Object[] { companyId };
2835
2836 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_COMPANYID,
2837 finderArgs, this);
2838
2839 if (count == null) {
2840 StringBundler query = new StringBundler(2);
2841
2842 query.append(_SQL_COUNT_ASSETVOCABULARY_WHERE);
2843
2844 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
2845
2846 String sql = query.toString();
2847
2848 Session session = null;
2849
2850 try {
2851 session = openSession();
2852
2853 Query q = session.createQuery(sql);
2854
2855 QueryPos qPos = QueryPos.getInstance(q);
2856
2857 qPos.add(companyId);
2858
2859 count = (Long)q.uniqueResult();
2860 }
2861 catch (Exception e) {
2862 throw processException(e);
2863 }
2864 finally {
2865 if (count == null) {
2866 count = Long.valueOf(0);
2867 }
2868
2869 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_COMPANYID,
2870 finderArgs, count);
2871
2872 closeSession(session);
2873 }
2874 }
2875
2876 return count.intValue();
2877 }
2878
2879
2887 public int countByG_N(long groupId, String name) throws SystemException {
2888 Object[] finderArgs = new Object[] { groupId, name };
2889
2890 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_N,
2891 finderArgs, this);
2892
2893 if (count == null) {
2894 StringBundler query = new StringBundler(3);
2895
2896 query.append(_SQL_COUNT_ASSETVOCABULARY_WHERE);
2897
2898 query.append(_FINDER_COLUMN_G_N_GROUPID_2);
2899
2900 if (name == null) {
2901 query.append(_FINDER_COLUMN_G_N_NAME_1);
2902 }
2903 else {
2904 if (name.equals(StringPool.BLANK)) {
2905 query.append(_FINDER_COLUMN_G_N_NAME_3);
2906 }
2907 else {
2908 query.append(_FINDER_COLUMN_G_N_NAME_2);
2909 }
2910 }
2911
2912 String sql = query.toString();
2913
2914 Session session = null;
2915
2916 try {
2917 session = openSession();
2918
2919 Query q = session.createQuery(sql);
2920
2921 QueryPos qPos = QueryPos.getInstance(q);
2922
2923 qPos.add(groupId);
2924
2925 if (name != null) {
2926 qPos.add(name);
2927 }
2928
2929 count = (Long)q.uniqueResult();
2930 }
2931 catch (Exception e) {
2932 throw processException(e);
2933 }
2934 finally {
2935 if (count == null) {
2936 count = Long.valueOf(0);
2937 }
2938
2939 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_N, finderArgs,
2940 count);
2941
2942 closeSession(session);
2943 }
2944 }
2945
2946 return count.intValue();
2947 }
2948
2949
2955 public int countAll() throws SystemException {
2956 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
2957 FINDER_ARGS_EMPTY, this);
2958
2959 if (count == null) {
2960 Session session = null;
2961
2962 try {
2963 session = openSession();
2964
2965 Query q = session.createQuery(_SQL_COUNT_ASSETVOCABULARY);
2966
2967 count = (Long)q.uniqueResult();
2968 }
2969 catch (Exception e) {
2970 throw processException(e);
2971 }
2972 finally {
2973 if (count == null) {
2974 count = Long.valueOf(0);
2975 }
2976
2977 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
2978 FINDER_ARGS_EMPTY, count);
2979
2980 closeSession(session);
2981 }
2982 }
2983
2984 return count.intValue();
2985 }
2986
2987
2990 public void afterPropertiesSet() {
2991 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
2992 com.liferay.portal.util.PropsUtil.get(
2993 "value.object.listener.com.liferay.portlet.asset.model.AssetVocabulary")));
2994
2995 if (listenerClassNames.length > 0) {
2996 try {
2997 List<ModelListener<AssetVocabulary>> listenersList = new ArrayList<ModelListener<AssetVocabulary>>();
2998
2999 for (String listenerClassName : listenerClassNames) {
3000 listenersList.add((ModelListener<AssetVocabulary>)InstanceFactory.newInstance(
3001 listenerClassName));
3002 }
3003
3004 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
3005 }
3006 catch (Exception e) {
3007 _log.error(e);
3008 }
3009 }
3010 }
3011
3012 public void destroy() {
3013 EntityCacheUtil.removeCache(AssetVocabularyImpl.class.getName());
3014 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
3015 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
3016 }
3017
3018 @BeanReference(type = AssetCategoryPersistence.class)
3019 protected AssetCategoryPersistence assetCategoryPersistence;
3020 @BeanReference(type = AssetCategoryPropertyPersistence.class)
3021 protected AssetCategoryPropertyPersistence assetCategoryPropertyPersistence;
3022 @BeanReference(type = AssetEntryPersistence.class)
3023 protected AssetEntryPersistence assetEntryPersistence;
3024 @BeanReference(type = AssetLinkPersistence.class)
3025 protected AssetLinkPersistence assetLinkPersistence;
3026 @BeanReference(type = AssetTagPersistence.class)
3027 protected AssetTagPersistence assetTagPersistence;
3028 @BeanReference(type = AssetTagPropertyPersistence.class)
3029 protected AssetTagPropertyPersistence assetTagPropertyPersistence;
3030 @BeanReference(type = AssetTagStatsPersistence.class)
3031 protected AssetTagStatsPersistence assetTagStatsPersistence;
3032 @BeanReference(type = AssetVocabularyPersistence.class)
3033 protected AssetVocabularyPersistence assetVocabularyPersistence;
3034 @BeanReference(type = GroupPersistence.class)
3035 protected GroupPersistence groupPersistence;
3036 @BeanReference(type = ResourcePersistence.class)
3037 protected ResourcePersistence resourcePersistence;
3038 @BeanReference(type = UserPersistence.class)
3039 protected UserPersistence userPersistence;
3040 private static final String _SQL_SELECT_ASSETVOCABULARY = "SELECT assetVocabulary FROM AssetVocabulary assetVocabulary";
3041 private static final String _SQL_SELECT_ASSETVOCABULARY_WHERE = "SELECT assetVocabulary FROM AssetVocabulary assetVocabulary WHERE ";
3042 private static final String _SQL_COUNT_ASSETVOCABULARY = "SELECT COUNT(assetVocabulary) FROM AssetVocabulary assetVocabulary";
3043 private static final String _SQL_COUNT_ASSETVOCABULARY_WHERE = "SELECT COUNT(assetVocabulary) FROM AssetVocabulary assetVocabulary WHERE ";
3044 private static final String _FINDER_COLUMN_UUID_UUID_1 = "assetVocabulary.uuid IS NULL";
3045 private static final String _FINDER_COLUMN_UUID_UUID_2 = "assetVocabulary.uuid = ?";
3046 private static final String _FINDER_COLUMN_UUID_UUID_3 = "(assetVocabulary.uuid IS NULL OR assetVocabulary.uuid = ?)";
3047 private static final String _FINDER_COLUMN_UUID_G_UUID_1 = "assetVocabulary.uuid IS NULL AND ";
3048 private static final String _FINDER_COLUMN_UUID_G_UUID_2 = "assetVocabulary.uuid = ? AND ";
3049 private static final String _FINDER_COLUMN_UUID_G_UUID_3 = "(assetVocabulary.uuid IS NULL OR assetVocabulary.uuid = ?) AND ";
3050 private static final String _FINDER_COLUMN_UUID_G_GROUPID_2 = "assetVocabulary.groupId = ?";
3051 private static final String _FINDER_COLUMN_GROUPID_GROUPID_2 = "assetVocabulary.groupId = ?";
3052 private static final String _FINDER_COLUMN_COMPANYID_COMPANYID_2 = "assetVocabulary.companyId = ?";
3053 private static final String _FINDER_COLUMN_G_N_GROUPID_2 = "assetVocabulary.groupId = ? AND ";
3054 private static final String _FINDER_COLUMN_G_N_NAME_1 = "assetVocabulary.name IS NULL";
3055 private static final String _FINDER_COLUMN_G_N_NAME_2 = "assetVocabulary.name = ?";
3056 private static final String _FINDER_COLUMN_G_N_NAME_3 = "(assetVocabulary.name IS NULL OR assetVocabulary.name = ?)";
3057 private static final String _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN = "assetVocabulary.vocabularyId";
3058 private static final String _FILTER_SQL_SELECT_ASSETVOCABULARY_WHERE = "SELECT DISTINCT {assetVocabulary.*} FROM AssetVocabulary assetVocabulary WHERE ";
3059 private static final String _FILTER_SQL_SELECT_ASSETVOCABULARY_NO_INLINE_DISTINCT_WHERE_1 =
3060 "SELECT {AssetVocabulary.*} FROM (SELECT DISTINCT assetVocabulary.vocabularyId FROM AssetVocabulary assetVocabulary WHERE ";
3061 private static final String _FILTER_SQL_SELECT_ASSETVOCABULARY_NO_INLINE_DISTINCT_WHERE_2 =
3062 ") TEMP_TABLE INNER JOIN AssetVocabulary ON TEMP_TABLE.vocabularyId = AssetVocabulary.vocabularyId";
3063 private static final String _FILTER_SQL_COUNT_ASSETVOCABULARY_WHERE = "SELECT COUNT(DISTINCT assetVocabulary.vocabularyId) AS COUNT_VALUE FROM AssetVocabulary assetVocabulary WHERE ";
3064 private static final String _FILTER_ENTITY_ALIAS = "assetVocabulary";
3065 private static final String _FILTER_ENTITY_TABLE = "AssetVocabulary";
3066 private static final String _ORDER_BY_ENTITY_ALIAS = "assetVocabulary.";
3067 private static final String _ORDER_BY_ENTITY_TABLE = "AssetVocabulary.";
3068 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No AssetVocabulary exists with the primary key ";
3069 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No AssetVocabulary exists with the key {";
3070 private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
3071 private static Log _log = LogFactoryUtil.getLog(AssetVocabularyPersistenceImpl.class);
3072 private static AssetVocabulary _nullAssetVocabulary = new AssetVocabularyImpl() {
3073 @Override
3074 public Object clone() {
3075 return this;
3076 }
3077
3078 @Override
3079 public CacheModel<AssetVocabulary> toCacheModel() {
3080 return _nullAssetVocabularyCacheModel;
3081 }
3082 };
3083
3084 private static CacheModel<AssetVocabulary> _nullAssetVocabularyCacheModel = new CacheModel<AssetVocabulary>() {
3085 public AssetVocabulary toEntityModel() {
3086 return _nullAssetVocabulary;
3087 }
3088 };
3089 }