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
425 else {
426 if ((assetVocabularyModelImpl.getColumnBitmask() &
427 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID.getColumnBitmask()) != 0) {
428 Object[] args = new Object[] {
429 assetVocabularyModelImpl.getOriginalUuid()
430 };
431
432 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
433 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
434 args);
435
436 args = new Object[] { assetVocabularyModelImpl.getUuid() };
437
438 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
439 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
440 args);
441 }
442
443 if ((assetVocabularyModelImpl.getColumnBitmask() &
444 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID.getColumnBitmask()) != 0) {
445 Object[] args = new Object[] {
446 Long.valueOf(assetVocabularyModelImpl.getOriginalGroupId())
447 };
448
449 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
450 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
451 args);
452
453 args = new Object[] {
454 Long.valueOf(assetVocabularyModelImpl.getGroupId())
455 };
456
457 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
458 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
459 args);
460 }
461
462 if ((assetVocabularyModelImpl.getColumnBitmask() &
463 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID.getColumnBitmask()) != 0) {
464 Object[] args = new Object[] {
465 Long.valueOf(assetVocabularyModelImpl.getOriginalCompanyId())
466 };
467
468 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_COMPANYID,
469 args);
470 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
471 args);
472
473 args = new Object[] {
474 Long.valueOf(assetVocabularyModelImpl.getCompanyId())
475 };
476
477 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_COMPANYID,
478 args);
479 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
480 args);
481 }
482 }
483
484 EntityCacheUtil.putResult(AssetVocabularyModelImpl.ENTITY_CACHE_ENABLED,
485 AssetVocabularyImpl.class, assetVocabulary.getPrimaryKey(),
486 assetVocabulary);
487
488 if (isNew) {
489 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
490 new Object[] {
491 assetVocabulary.getUuid(),
492 Long.valueOf(assetVocabulary.getGroupId())
493 }, assetVocabulary);
494
495 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_N,
496 new Object[] {
497 Long.valueOf(assetVocabulary.getGroupId()),
498
499 assetVocabulary.getName()
500 }, assetVocabulary);
501 }
502 else {
503 if ((assetVocabularyModelImpl.getColumnBitmask() &
504 FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) {
505 Object[] args = new Object[] {
506 assetVocabularyModelImpl.getOriginalUuid(),
507 Long.valueOf(assetVocabularyModelImpl.getOriginalGroupId())
508 };
509
510 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args);
511
512 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args);
513
514 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
515 new Object[] {
516 assetVocabulary.getUuid(),
517 Long.valueOf(assetVocabulary.getGroupId())
518 }, assetVocabulary);
519 }
520
521 if ((assetVocabularyModelImpl.getColumnBitmask() &
522 FINDER_PATH_FETCH_BY_G_N.getColumnBitmask()) != 0) {
523 Object[] args = new Object[] {
524 Long.valueOf(assetVocabularyModelImpl.getOriginalGroupId()),
525
526 assetVocabularyModelImpl.getOriginalName()
527 };
528
529 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_N, args);
530
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(assetVocabulary.getGroupId()),
536
537 assetVocabulary.getName()
538 }, assetVocabulary);
539 }
540 }
541
542 return assetVocabulary;
543 }
544
545 protected AssetVocabulary toUnwrappedModel(AssetVocabulary assetVocabulary) {
546 if (assetVocabulary instanceof AssetVocabularyImpl) {
547 return assetVocabulary;
548 }
549
550 AssetVocabularyImpl assetVocabularyImpl = new AssetVocabularyImpl();
551
552 assetVocabularyImpl.setNew(assetVocabulary.isNew());
553 assetVocabularyImpl.setPrimaryKey(assetVocabulary.getPrimaryKey());
554
555 assetVocabularyImpl.setUuid(assetVocabulary.getUuid());
556 assetVocabularyImpl.setVocabularyId(assetVocabulary.getVocabularyId());
557 assetVocabularyImpl.setGroupId(assetVocabulary.getGroupId());
558 assetVocabularyImpl.setCompanyId(assetVocabulary.getCompanyId());
559 assetVocabularyImpl.setUserId(assetVocabulary.getUserId());
560 assetVocabularyImpl.setUserName(assetVocabulary.getUserName());
561 assetVocabularyImpl.setCreateDate(assetVocabulary.getCreateDate());
562 assetVocabularyImpl.setModifiedDate(assetVocabulary.getModifiedDate());
563 assetVocabularyImpl.setName(assetVocabulary.getName());
564 assetVocabularyImpl.setTitle(assetVocabulary.getTitle());
565 assetVocabularyImpl.setDescription(assetVocabulary.getDescription());
566 assetVocabularyImpl.setSettings(assetVocabulary.getSettings());
567
568 return assetVocabularyImpl;
569 }
570
571
579 @Override
580 public AssetVocabulary findByPrimaryKey(Serializable primaryKey)
581 throws NoSuchModelException, SystemException {
582 return findByPrimaryKey(((Long)primaryKey).longValue());
583 }
584
585
593 public AssetVocabulary findByPrimaryKey(long vocabularyId)
594 throws NoSuchVocabularyException, SystemException {
595 AssetVocabulary assetVocabulary = fetchByPrimaryKey(vocabularyId);
596
597 if (assetVocabulary == null) {
598 if (_log.isWarnEnabled()) {
599 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + vocabularyId);
600 }
601
602 throw new NoSuchVocabularyException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
603 vocabularyId);
604 }
605
606 return assetVocabulary;
607 }
608
609
616 @Override
617 public AssetVocabulary fetchByPrimaryKey(Serializable primaryKey)
618 throws SystemException {
619 return fetchByPrimaryKey(((Long)primaryKey).longValue());
620 }
621
622
629 public AssetVocabulary fetchByPrimaryKey(long vocabularyId)
630 throws SystemException {
631 AssetVocabulary assetVocabulary = (AssetVocabulary)EntityCacheUtil.getResult(AssetVocabularyModelImpl.ENTITY_CACHE_ENABLED,
632 AssetVocabularyImpl.class, vocabularyId);
633
634 if (assetVocabulary == _nullAssetVocabulary) {
635 return null;
636 }
637
638 if (assetVocabulary == null) {
639 Session session = null;
640
641 boolean hasException = false;
642
643 try {
644 session = openSession();
645
646 assetVocabulary = (AssetVocabulary)session.get(AssetVocabularyImpl.class,
647 Long.valueOf(vocabularyId));
648 }
649 catch (Exception e) {
650 hasException = true;
651
652 throw processException(e);
653 }
654 finally {
655 if (assetVocabulary != null) {
656 cacheResult(assetVocabulary);
657 }
658 else if (!hasException) {
659 EntityCacheUtil.putResult(AssetVocabularyModelImpl.ENTITY_CACHE_ENABLED,
660 AssetVocabularyImpl.class, vocabularyId,
661 _nullAssetVocabulary);
662 }
663
664 closeSession(session);
665 }
666 }
667
668 return assetVocabulary;
669 }
670
671
678 public List<AssetVocabulary> findByUuid(String uuid)
679 throws SystemException {
680 return findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
681 }
682
683
696 public List<AssetVocabulary> findByUuid(String uuid, int start, int end)
697 throws SystemException {
698 return findByUuid(uuid, start, end, null);
699 }
700
701
715 public List<AssetVocabulary> findByUuid(String uuid, int start, int end,
716 OrderByComparator orderByComparator) throws SystemException {
717 FinderPath finderPath = null;
718 Object[] finderArgs = null;
719
720 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
721 (orderByComparator == null)) {
722 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID;
723 finderArgs = new Object[] { uuid };
724 }
725 else {
726 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID;
727 finderArgs = new Object[] { uuid, start, end, orderByComparator };
728 }
729
730 List<AssetVocabulary> list = (List<AssetVocabulary>)FinderCacheUtil.getResult(finderPath,
731 finderArgs, this);
732
733 if ((list != null) && !list.isEmpty()) {
734 for (AssetVocabulary assetVocabulary : list) {
735 if (!Validator.equals(uuid, assetVocabulary.getUuid())) {
736 list = null;
737
738 break;
739 }
740 }
741 }
742
743 if (list == null) {
744 StringBundler query = null;
745
746 if (orderByComparator != null) {
747 query = new StringBundler(3 +
748 (orderByComparator.getOrderByFields().length * 3));
749 }
750 else {
751 query = new StringBundler(3);
752 }
753
754 query.append(_SQL_SELECT_ASSETVOCABULARY_WHERE);
755
756 if (uuid == null) {
757 query.append(_FINDER_COLUMN_UUID_UUID_1);
758 }
759 else {
760 if (uuid.equals(StringPool.BLANK)) {
761 query.append(_FINDER_COLUMN_UUID_UUID_3);
762 }
763 else {
764 query.append(_FINDER_COLUMN_UUID_UUID_2);
765 }
766 }
767
768 if (orderByComparator != null) {
769 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
770 orderByComparator);
771 }
772
773 else {
774 query.append(AssetVocabularyModelImpl.ORDER_BY_JPQL);
775 }
776
777 String sql = query.toString();
778
779 Session session = null;
780
781 try {
782 session = openSession();
783
784 Query q = session.createQuery(sql);
785
786 QueryPos qPos = QueryPos.getInstance(q);
787
788 if (uuid != null) {
789 qPos.add(uuid);
790 }
791
792 list = (List<AssetVocabulary>)QueryUtil.list(q, getDialect(),
793 start, end);
794 }
795 catch (Exception e) {
796 throw processException(e);
797 }
798 finally {
799 if (list == null) {
800 FinderCacheUtil.removeResult(finderPath, finderArgs);
801 }
802 else {
803 cacheResult(list);
804
805 FinderCacheUtil.putResult(finderPath, finderArgs, list);
806 }
807
808 closeSession(session);
809 }
810 }
811
812 return list;
813 }
814
815
824 public AssetVocabulary findByUuid_First(String uuid,
825 OrderByComparator orderByComparator)
826 throws NoSuchVocabularyException, SystemException {
827 AssetVocabulary assetVocabulary = fetchByUuid_First(uuid,
828 orderByComparator);
829
830 if (assetVocabulary != null) {
831 return assetVocabulary;
832 }
833
834 StringBundler msg = new StringBundler(4);
835
836 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
837
838 msg.append("uuid=");
839 msg.append(uuid);
840
841 msg.append(StringPool.CLOSE_CURLY_BRACE);
842
843 throw new NoSuchVocabularyException(msg.toString());
844 }
845
846
854 public AssetVocabulary fetchByUuid_First(String uuid,
855 OrderByComparator orderByComparator) throws SystemException {
856 List<AssetVocabulary> list = findByUuid(uuid, 0, 1, orderByComparator);
857
858 if (!list.isEmpty()) {
859 return list.get(0);
860 }
861
862 return null;
863 }
864
865
874 public AssetVocabulary findByUuid_Last(String uuid,
875 OrderByComparator orderByComparator)
876 throws NoSuchVocabularyException, SystemException {
877 AssetVocabulary assetVocabulary = fetchByUuid_Last(uuid,
878 orderByComparator);
879
880 if (assetVocabulary != null) {
881 return assetVocabulary;
882 }
883
884 StringBundler msg = new StringBundler(4);
885
886 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
887
888 msg.append("uuid=");
889 msg.append(uuid);
890
891 msg.append(StringPool.CLOSE_CURLY_BRACE);
892
893 throw new NoSuchVocabularyException(msg.toString());
894 }
895
896
904 public AssetVocabulary fetchByUuid_Last(String uuid,
905 OrderByComparator orderByComparator) throws SystemException {
906 int count = countByUuid(uuid);
907
908 List<AssetVocabulary> list = findByUuid(uuid, count - 1, count,
909 orderByComparator);
910
911 if (!list.isEmpty()) {
912 return list.get(0);
913 }
914
915 return null;
916 }
917
918
928 public AssetVocabulary[] findByUuid_PrevAndNext(long vocabularyId,
929 String uuid, OrderByComparator orderByComparator)
930 throws NoSuchVocabularyException, SystemException {
931 AssetVocabulary assetVocabulary = findByPrimaryKey(vocabularyId);
932
933 Session session = null;
934
935 try {
936 session = openSession();
937
938 AssetVocabulary[] array = new AssetVocabularyImpl[3];
939
940 array[0] = getByUuid_PrevAndNext(session, assetVocabulary, uuid,
941 orderByComparator, true);
942
943 array[1] = assetVocabulary;
944
945 array[2] = getByUuid_PrevAndNext(session, assetVocabulary, uuid,
946 orderByComparator, false);
947
948 return array;
949 }
950 catch (Exception e) {
951 throw processException(e);
952 }
953 finally {
954 closeSession(session);
955 }
956 }
957
958 protected AssetVocabulary getByUuid_PrevAndNext(Session session,
959 AssetVocabulary assetVocabulary, String uuid,
960 OrderByComparator orderByComparator, boolean previous) {
961 StringBundler query = null;
962
963 if (orderByComparator != null) {
964 query = new StringBundler(6 +
965 (orderByComparator.getOrderByFields().length * 6));
966 }
967 else {
968 query = new StringBundler(3);
969 }
970
971 query.append(_SQL_SELECT_ASSETVOCABULARY_WHERE);
972
973 if (uuid == null) {
974 query.append(_FINDER_COLUMN_UUID_UUID_1);
975 }
976 else {
977 if (uuid.equals(StringPool.BLANK)) {
978 query.append(_FINDER_COLUMN_UUID_UUID_3);
979 }
980 else {
981 query.append(_FINDER_COLUMN_UUID_UUID_2);
982 }
983 }
984
985 if (orderByComparator != null) {
986 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
987
988 if (orderByConditionFields.length > 0) {
989 query.append(WHERE_AND);
990 }
991
992 for (int i = 0; i < orderByConditionFields.length; i++) {
993 query.append(_ORDER_BY_ENTITY_ALIAS);
994 query.append(orderByConditionFields[i]);
995
996 if ((i + 1) < orderByConditionFields.length) {
997 if (orderByComparator.isAscending() ^ previous) {
998 query.append(WHERE_GREATER_THAN_HAS_NEXT);
999 }
1000 else {
1001 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1002 }
1003 }
1004 else {
1005 if (orderByComparator.isAscending() ^ previous) {
1006 query.append(WHERE_GREATER_THAN);
1007 }
1008 else {
1009 query.append(WHERE_LESSER_THAN);
1010 }
1011 }
1012 }
1013
1014 query.append(ORDER_BY_CLAUSE);
1015
1016 String[] orderByFields = orderByComparator.getOrderByFields();
1017
1018 for (int i = 0; i < orderByFields.length; i++) {
1019 query.append(_ORDER_BY_ENTITY_ALIAS);
1020 query.append(orderByFields[i]);
1021
1022 if ((i + 1) < orderByFields.length) {
1023 if (orderByComparator.isAscending() ^ previous) {
1024 query.append(ORDER_BY_ASC_HAS_NEXT);
1025 }
1026 else {
1027 query.append(ORDER_BY_DESC_HAS_NEXT);
1028 }
1029 }
1030 else {
1031 if (orderByComparator.isAscending() ^ previous) {
1032 query.append(ORDER_BY_ASC);
1033 }
1034 else {
1035 query.append(ORDER_BY_DESC);
1036 }
1037 }
1038 }
1039 }
1040
1041 else {
1042 query.append(AssetVocabularyModelImpl.ORDER_BY_JPQL);
1043 }
1044
1045 String sql = query.toString();
1046
1047 Query q = session.createQuery(sql);
1048
1049 q.setFirstResult(0);
1050 q.setMaxResults(2);
1051
1052 QueryPos qPos = QueryPos.getInstance(q);
1053
1054 if (uuid != null) {
1055 qPos.add(uuid);
1056 }
1057
1058 if (orderByComparator != null) {
1059 Object[] values = orderByComparator.getOrderByConditionValues(assetVocabulary);
1060
1061 for (Object value : values) {
1062 qPos.add(value);
1063 }
1064 }
1065
1066 List<AssetVocabulary> list = q.list();
1067
1068 if (list.size() == 2) {
1069 return list.get(1);
1070 }
1071 else {
1072 return null;
1073 }
1074 }
1075
1076
1085 public AssetVocabulary findByUUID_G(String uuid, long groupId)
1086 throws NoSuchVocabularyException, SystemException {
1087 AssetVocabulary assetVocabulary = fetchByUUID_G(uuid, groupId);
1088
1089 if (assetVocabulary == null) {
1090 StringBundler msg = new StringBundler(6);
1091
1092 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1093
1094 msg.append("uuid=");
1095 msg.append(uuid);
1096
1097 msg.append(", groupId=");
1098 msg.append(groupId);
1099
1100 msg.append(StringPool.CLOSE_CURLY_BRACE);
1101
1102 if (_log.isWarnEnabled()) {
1103 _log.warn(msg.toString());
1104 }
1105
1106 throw new NoSuchVocabularyException(msg.toString());
1107 }
1108
1109 return assetVocabulary;
1110 }
1111
1112
1120 public AssetVocabulary fetchByUUID_G(String uuid, long groupId)
1121 throws SystemException {
1122 return fetchByUUID_G(uuid, groupId, true);
1123 }
1124
1125
1134 public AssetVocabulary fetchByUUID_G(String uuid, long groupId,
1135 boolean retrieveFromCache) throws SystemException {
1136 Object[] finderArgs = new Object[] { uuid, groupId };
1137
1138 Object result = null;
1139
1140 if (retrieveFromCache) {
1141 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_UUID_G,
1142 finderArgs, this);
1143 }
1144
1145 if (result instanceof AssetVocabulary) {
1146 AssetVocabulary assetVocabulary = (AssetVocabulary)result;
1147
1148 if (!Validator.equals(uuid, assetVocabulary.getUuid()) ||
1149 (groupId != assetVocabulary.getGroupId())) {
1150 result = null;
1151 }
1152 }
1153
1154 if (result == null) {
1155 StringBundler query = new StringBundler(4);
1156
1157 query.append(_SQL_SELECT_ASSETVOCABULARY_WHERE);
1158
1159 if (uuid == null) {
1160 query.append(_FINDER_COLUMN_UUID_G_UUID_1);
1161 }
1162 else {
1163 if (uuid.equals(StringPool.BLANK)) {
1164 query.append(_FINDER_COLUMN_UUID_G_UUID_3);
1165 }
1166 else {
1167 query.append(_FINDER_COLUMN_UUID_G_UUID_2);
1168 }
1169 }
1170
1171 query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
1172
1173 query.append(AssetVocabularyModelImpl.ORDER_BY_JPQL);
1174
1175 String sql = query.toString();
1176
1177 Session session = null;
1178
1179 try {
1180 session = openSession();
1181
1182 Query q = session.createQuery(sql);
1183
1184 QueryPos qPos = QueryPos.getInstance(q);
1185
1186 if (uuid != null) {
1187 qPos.add(uuid);
1188 }
1189
1190 qPos.add(groupId);
1191
1192 List<AssetVocabulary> list = q.list();
1193
1194 result = list;
1195
1196 AssetVocabulary assetVocabulary = null;
1197
1198 if (list.isEmpty()) {
1199 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
1200 finderArgs, list);
1201 }
1202 else {
1203 assetVocabulary = list.get(0);
1204
1205 cacheResult(assetVocabulary);
1206
1207 if ((assetVocabulary.getUuid() == null) ||
1208 !assetVocabulary.getUuid().equals(uuid) ||
1209 (assetVocabulary.getGroupId() != groupId)) {
1210 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
1211 finderArgs, assetVocabulary);
1212 }
1213 }
1214
1215 return assetVocabulary;
1216 }
1217 catch (Exception e) {
1218 throw processException(e);
1219 }
1220 finally {
1221 if (result == null) {
1222 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
1223 finderArgs);
1224 }
1225
1226 closeSession(session);
1227 }
1228 }
1229 else {
1230 if (result instanceof List<?>) {
1231 return null;
1232 }
1233 else {
1234 return (AssetVocabulary)result;
1235 }
1236 }
1237 }
1238
1239
1246 public List<AssetVocabulary> findByGroupId(long groupId)
1247 throws SystemException {
1248 return findByGroupId(groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1249 }
1250
1251
1264 public List<AssetVocabulary> findByGroupId(long groupId, int start, int end)
1265 throws SystemException {
1266 return findByGroupId(groupId, start, end, null);
1267 }
1268
1269
1283 public List<AssetVocabulary> findByGroupId(long groupId, int start,
1284 int end, OrderByComparator orderByComparator) throws SystemException {
1285 FinderPath finderPath = null;
1286 Object[] finderArgs = null;
1287
1288 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1289 (orderByComparator == null)) {
1290 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID;
1291 finderArgs = new Object[] { groupId };
1292 }
1293 else {
1294 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID;
1295 finderArgs = new Object[] { groupId, start, end, orderByComparator };
1296 }
1297
1298 List<AssetVocabulary> list = (List<AssetVocabulary>)FinderCacheUtil.getResult(finderPath,
1299 finderArgs, this);
1300
1301 if ((list != null) && !list.isEmpty()) {
1302 for (AssetVocabulary assetVocabulary : list) {
1303 if ((groupId != assetVocabulary.getGroupId())) {
1304 list = null;
1305
1306 break;
1307 }
1308 }
1309 }
1310
1311 if (list == null) {
1312 StringBundler query = null;
1313
1314 if (orderByComparator != null) {
1315 query = new StringBundler(3 +
1316 (orderByComparator.getOrderByFields().length * 3));
1317 }
1318 else {
1319 query = new StringBundler(3);
1320 }
1321
1322 query.append(_SQL_SELECT_ASSETVOCABULARY_WHERE);
1323
1324 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1325
1326 if (orderByComparator != null) {
1327 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1328 orderByComparator);
1329 }
1330
1331 else {
1332 query.append(AssetVocabularyModelImpl.ORDER_BY_JPQL);
1333 }
1334
1335 String sql = query.toString();
1336
1337 Session session = null;
1338
1339 try {
1340 session = openSession();
1341
1342 Query q = session.createQuery(sql);
1343
1344 QueryPos qPos = QueryPos.getInstance(q);
1345
1346 qPos.add(groupId);
1347
1348 list = (List<AssetVocabulary>)QueryUtil.list(q, getDialect(),
1349 start, end);
1350 }
1351 catch (Exception e) {
1352 throw processException(e);
1353 }
1354 finally {
1355 if (list == null) {
1356 FinderCacheUtil.removeResult(finderPath, finderArgs);
1357 }
1358 else {
1359 cacheResult(list);
1360
1361 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1362 }
1363
1364 closeSession(session);
1365 }
1366 }
1367
1368 return list;
1369 }
1370
1371
1380 public AssetVocabulary findByGroupId_First(long groupId,
1381 OrderByComparator orderByComparator)
1382 throws NoSuchVocabularyException, SystemException {
1383 AssetVocabulary assetVocabulary = fetchByGroupId_First(groupId,
1384 orderByComparator);
1385
1386 if (assetVocabulary != null) {
1387 return assetVocabulary;
1388 }
1389
1390 StringBundler msg = new StringBundler(4);
1391
1392 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1393
1394 msg.append("groupId=");
1395 msg.append(groupId);
1396
1397 msg.append(StringPool.CLOSE_CURLY_BRACE);
1398
1399 throw new NoSuchVocabularyException(msg.toString());
1400 }
1401
1402
1410 public AssetVocabulary fetchByGroupId_First(long groupId,
1411 OrderByComparator orderByComparator) throws SystemException {
1412 List<AssetVocabulary> list = findByGroupId(groupId, 0, 1,
1413 orderByComparator);
1414
1415 if (!list.isEmpty()) {
1416 return list.get(0);
1417 }
1418
1419 return null;
1420 }
1421
1422
1431 public AssetVocabulary findByGroupId_Last(long groupId,
1432 OrderByComparator orderByComparator)
1433 throws NoSuchVocabularyException, SystemException {
1434 AssetVocabulary assetVocabulary = fetchByGroupId_Last(groupId,
1435 orderByComparator);
1436
1437 if (assetVocabulary != null) {
1438 return assetVocabulary;
1439 }
1440
1441 StringBundler msg = new StringBundler(4);
1442
1443 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1444
1445 msg.append("groupId=");
1446 msg.append(groupId);
1447
1448 msg.append(StringPool.CLOSE_CURLY_BRACE);
1449
1450 throw new NoSuchVocabularyException(msg.toString());
1451 }
1452
1453
1461 public AssetVocabulary fetchByGroupId_Last(long groupId,
1462 OrderByComparator orderByComparator) throws SystemException {
1463 int count = countByGroupId(groupId);
1464
1465 List<AssetVocabulary> list = findByGroupId(groupId, count - 1, count,
1466 orderByComparator);
1467
1468 if (!list.isEmpty()) {
1469 return list.get(0);
1470 }
1471
1472 return null;
1473 }
1474
1475
1485 public AssetVocabulary[] findByGroupId_PrevAndNext(long vocabularyId,
1486 long groupId, OrderByComparator orderByComparator)
1487 throws NoSuchVocabularyException, SystemException {
1488 AssetVocabulary assetVocabulary = findByPrimaryKey(vocabularyId);
1489
1490 Session session = null;
1491
1492 try {
1493 session = openSession();
1494
1495 AssetVocabulary[] array = new AssetVocabularyImpl[3];
1496
1497 array[0] = getByGroupId_PrevAndNext(session, assetVocabulary,
1498 groupId, orderByComparator, true);
1499
1500 array[1] = assetVocabulary;
1501
1502 array[2] = getByGroupId_PrevAndNext(session, assetVocabulary,
1503 groupId, orderByComparator, false);
1504
1505 return array;
1506 }
1507 catch (Exception e) {
1508 throw processException(e);
1509 }
1510 finally {
1511 closeSession(session);
1512 }
1513 }
1514
1515 protected AssetVocabulary getByGroupId_PrevAndNext(Session session,
1516 AssetVocabulary assetVocabulary, long groupId,
1517 OrderByComparator orderByComparator, boolean previous) {
1518 StringBundler query = null;
1519
1520 if (orderByComparator != null) {
1521 query = new StringBundler(6 +
1522 (orderByComparator.getOrderByFields().length * 6));
1523 }
1524 else {
1525 query = new StringBundler(3);
1526 }
1527
1528 query.append(_SQL_SELECT_ASSETVOCABULARY_WHERE);
1529
1530 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1531
1532 if (orderByComparator != null) {
1533 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1534
1535 if (orderByConditionFields.length > 0) {
1536 query.append(WHERE_AND);
1537 }
1538
1539 for (int i = 0; i < orderByConditionFields.length; i++) {
1540 query.append(_ORDER_BY_ENTITY_ALIAS);
1541 query.append(orderByConditionFields[i]);
1542
1543 if ((i + 1) < orderByConditionFields.length) {
1544 if (orderByComparator.isAscending() ^ previous) {
1545 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1546 }
1547 else {
1548 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1549 }
1550 }
1551 else {
1552 if (orderByComparator.isAscending() ^ previous) {
1553 query.append(WHERE_GREATER_THAN);
1554 }
1555 else {
1556 query.append(WHERE_LESSER_THAN);
1557 }
1558 }
1559 }
1560
1561 query.append(ORDER_BY_CLAUSE);
1562
1563 String[] orderByFields = orderByComparator.getOrderByFields();
1564
1565 for (int i = 0; i < orderByFields.length; i++) {
1566 query.append(_ORDER_BY_ENTITY_ALIAS);
1567 query.append(orderByFields[i]);
1568
1569 if ((i + 1) < orderByFields.length) {
1570 if (orderByComparator.isAscending() ^ previous) {
1571 query.append(ORDER_BY_ASC_HAS_NEXT);
1572 }
1573 else {
1574 query.append(ORDER_BY_DESC_HAS_NEXT);
1575 }
1576 }
1577 else {
1578 if (orderByComparator.isAscending() ^ previous) {
1579 query.append(ORDER_BY_ASC);
1580 }
1581 else {
1582 query.append(ORDER_BY_DESC);
1583 }
1584 }
1585 }
1586 }
1587
1588 else {
1589 query.append(AssetVocabularyModelImpl.ORDER_BY_JPQL);
1590 }
1591
1592 String sql = query.toString();
1593
1594 Query q = session.createQuery(sql);
1595
1596 q.setFirstResult(0);
1597 q.setMaxResults(2);
1598
1599 QueryPos qPos = QueryPos.getInstance(q);
1600
1601 qPos.add(groupId);
1602
1603 if (orderByComparator != null) {
1604 Object[] values = orderByComparator.getOrderByConditionValues(assetVocabulary);
1605
1606 for (Object value : values) {
1607 qPos.add(value);
1608 }
1609 }
1610
1611 List<AssetVocabulary> list = q.list();
1612
1613 if (list.size() == 2) {
1614 return list.get(1);
1615 }
1616 else {
1617 return null;
1618 }
1619 }
1620
1621
1628 public List<AssetVocabulary> filterFindByGroupId(long groupId)
1629 throws SystemException {
1630 return filterFindByGroupId(groupId, QueryUtil.ALL_POS,
1631 QueryUtil.ALL_POS, null);
1632 }
1633
1634
1647 public List<AssetVocabulary> filterFindByGroupId(long groupId, int start,
1648 int end) throws SystemException {
1649 return filterFindByGroupId(groupId, start, end, null);
1650 }
1651
1652
1666 public List<AssetVocabulary> filterFindByGroupId(long groupId, int start,
1667 int end, OrderByComparator orderByComparator) throws SystemException {
1668 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
1669 return findByGroupId(groupId, start, end, orderByComparator);
1670 }
1671
1672 StringBundler query = null;
1673
1674 if (orderByComparator != null) {
1675 query = new StringBundler(3 +
1676 (orderByComparator.getOrderByFields().length * 3));
1677 }
1678 else {
1679 query = new StringBundler(3);
1680 }
1681
1682 if (getDB().isSupportsInlineDistinct()) {
1683 query.append(_FILTER_SQL_SELECT_ASSETVOCABULARY_WHERE);
1684 }
1685 else {
1686 query.append(_FILTER_SQL_SELECT_ASSETVOCABULARY_NO_INLINE_DISTINCT_WHERE_1);
1687 }
1688
1689 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1690
1691 if (!getDB().isSupportsInlineDistinct()) {
1692 query.append(_FILTER_SQL_SELECT_ASSETVOCABULARY_NO_INLINE_DISTINCT_WHERE_2);
1693 }
1694
1695 if (orderByComparator != null) {
1696 if (getDB().isSupportsInlineDistinct()) {
1697 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1698 orderByComparator);
1699 }
1700 else {
1701 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
1702 orderByComparator);
1703 }
1704 }
1705
1706 else {
1707 if (getDB().isSupportsInlineDistinct()) {
1708 query.append(AssetVocabularyModelImpl.ORDER_BY_JPQL);
1709 }
1710 else {
1711 query.append(AssetVocabularyModelImpl.ORDER_BY_SQL);
1712 }
1713 }
1714
1715 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1716 AssetVocabulary.class.getName(),
1717 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
1718
1719 Session session = null;
1720
1721 try {
1722 session = openSession();
1723
1724 SQLQuery q = session.createSQLQuery(sql);
1725
1726 if (getDB().isSupportsInlineDistinct()) {
1727 q.addEntity(_FILTER_ENTITY_ALIAS, AssetVocabularyImpl.class);
1728 }
1729 else {
1730 q.addEntity(_FILTER_ENTITY_TABLE, AssetVocabularyImpl.class);
1731 }
1732
1733 QueryPos qPos = QueryPos.getInstance(q);
1734
1735 qPos.add(groupId);
1736
1737 return (List<AssetVocabulary>)QueryUtil.list(q, getDialect(),
1738 start, end);
1739 }
1740 catch (Exception e) {
1741 throw processException(e);
1742 }
1743 finally {
1744 closeSession(session);
1745 }
1746 }
1747
1748
1758 public AssetVocabulary[] filterFindByGroupId_PrevAndNext(
1759 long vocabularyId, long groupId, OrderByComparator orderByComparator)
1760 throws NoSuchVocabularyException, SystemException {
1761 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
1762 return findByGroupId_PrevAndNext(vocabularyId, groupId,
1763 orderByComparator);
1764 }
1765
1766 AssetVocabulary assetVocabulary = findByPrimaryKey(vocabularyId);
1767
1768 Session session = null;
1769
1770 try {
1771 session = openSession();
1772
1773 AssetVocabulary[] array = new AssetVocabularyImpl[3];
1774
1775 array[0] = filterGetByGroupId_PrevAndNext(session, assetVocabulary,
1776 groupId, orderByComparator, true);
1777
1778 array[1] = assetVocabulary;
1779
1780 array[2] = filterGetByGroupId_PrevAndNext(session, assetVocabulary,
1781 groupId, orderByComparator, false);
1782
1783 return array;
1784 }
1785 catch (Exception e) {
1786 throw processException(e);
1787 }
1788 finally {
1789 closeSession(session);
1790 }
1791 }
1792
1793 protected AssetVocabulary filterGetByGroupId_PrevAndNext(Session session,
1794 AssetVocabulary assetVocabulary, long groupId,
1795 OrderByComparator orderByComparator, boolean previous) {
1796 StringBundler query = null;
1797
1798 if (orderByComparator != null) {
1799 query = new StringBundler(6 +
1800 (orderByComparator.getOrderByFields().length * 6));
1801 }
1802 else {
1803 query = new StringBundler(3);
1804 }
1805
1806 if (getDB().isSupportsInlineDistinct()) {
1807 query.append(_FILTER_SQL_SELECT_ASSETVOCABULARY_WHERE);
1808 }
1809 else {
1810 query.append(_FILTER_SQL_SELECT_ASSETVOCABULARY_NO_INLINE_DISTINCT_WHERE_1);
1811 }
1812
1813 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1814
1815 if (!getDB().isSupportsInlineDistinct()) {
1816 query.append(_FILTER_SQL_SELECT_ASSETVOCABULARY_NO_INLINE_DISTINCT_WHERE_2);
1817 }
1818
1819 if (orderByComparator != null) {
1820 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1821
1822 if (orderByConditionFields.length > 0) {
1823 query.append(WHERE_AND);
1824 }
1825
1826 for (int i = 0; i < orderByConditionFields.length; i++) {
1827 if (getDB().isSupportsInlineDistinct()) {
1828 query.append(_ORDER_BY_ENTITY_ALIAS);
1829 }
1830 else {
1831 query.append(_ORDER_BY_ENTITY_TABLE);
1832 }
1833
1834 query.append(orderByConditionFields[i]);
1835
1836 if ((i + 1) < orderByConditionFields.length) {
1837 if (orderByComparator.isAscending() ^ previous) {
1838 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1839 }
1840 else {
1841 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1842 }
1843 }
1844 else {
1845 if (orderByComparator.isAscending() ^ previous) {
1846 query.append(WHERE_GREATER_THAN);
1847 }
1848 else {
1849 query.append(WHERE_LESSER_THAN);
1850 }
1851 }
1852 }
1853
1854 query.append(ORDER_BY_CLAUSE);
1855
1856 String[] orderByFields = orderByComparator.getOrderByFields();
1857
1858 for (int i = 0; i < orderByFields.length; i++) {
1859 if (getDB().isSupportsInlineDistinct()) {
1860 query.append(_ORDER_BY_ENTITY_ALIAS);
1861 }
1862 else {
1863 query.append(_ORDER_BY_ENTITY_TABLE);
1864 }
1865
1866 query.append(orderByFields[i]);
1867
1868 if ((i + 1) < orderByFields.length) {
1869 if (orderByComparator.isAscending() ^ previous) {
1870 query.append(ORDER_BY_ASC_HAS_NEXT);
1871 }
1872 else {
1873 query.append(ORDER_BY_DESC_HAS_NEXT);
1874 }
1875 }
1876 else {
1877 if (orderByComparator.isAscending() ^ previous) {
1878 query.append(ORDER_BY_ASC);
1879 }
1880 else {
1881 query.append(ORDER_BY_DESC);
1882 }
1883 }
1884 }
1885 }
1886
1887 else {
1888 if (getDB().isSupportsInlineDistinct()) {
1889 query.append(AssetVocabularyModelImpl.ORDER_BY_JPQL);
1890 }
1891 else {
1892 query.append(AssetVocabularyModelImpl.ORDER_BY_SQL);
1893 }
1894 }
1895
1896 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1897 AssetVocabulary.class.getName(),
1898 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
1899
1900 SQLQuery q = session.createSQLQuery(sql);
1901
1902 q.setFirstResult(0);
1903 q.setMaxResults(2);
1904
1905 if (getDB().isSupportsInlineDistinct()) {
1906 q.addEntity(_FILTER_ENTITY_ALIAS, AssetVocabularyImpl.class);
1907 }
1908 else {
1909 q.addEntity(_FILTER_ENTITY_TABLE, AssetVocabularyImpl.class);
1910 }
1911
1912 QueryPos qPos = QueryPos.getInstance(q);
1913
1914 qPos.add(groupId);
1915
1916 if (orderByComparator != null) {
1917 Object[] values = orderByComparator.getOrderByConditionValues(assetVocabulary);
1918
1919 for (Object value : values) {
1920 qPos.add(value);
1921 }
1922 }
1923
1924 List<AssetVocabulary> list = q.list();
1925
1926 if (list.size() == 2) {
1927 return list.get(1);
1928 }
1929 else {
1930 return null;
1931 }
1932 }
1933
1934
1941 public List<AssetVocabulary> findByCompanyId(long companyId)
1942 throws SystemException {
1943 return findByCompanyId(companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
1944 null);
1945 }
1946
1947
1960 public List<AssetVocabulary> findByCompanyId(long companyId, int start,
1961 int end) throws SystemException {
1962 return findByCompanyId(companyId, start, end, null);
1963 }
1964
1965
1979 public List<AssetVocabulary> findByCompanyId(long companyId, int start,
1980 int end, OrderByComparator orderByComparator) throws SystemException {
1981 FinderPath finderPath = null;
1982 Object[] finderArgs = null;
1983
1984 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1985 (orderByComparator == null)) {
1986 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID;
1987 finderArgs = new Object[] { companyId };
1988 }
1989 else {
1990 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID;
1991 finderArgs = new Object[] { companyId, start, end, orderByComparator };
1992 }
1993
1994 List<AssetVocabulary> list = (List<AssetVocabulary>)FinderCacheUtil.getResult(finderPath,
1995 finderArgs, this);
1996
1997 if ((list != null) && !list.isEmpty()) {
1998 for (AssetVocabulary assetVocabulary : list) {
1999 if ((companyId != assetVocabulary.getCompanyId())) {
2000 list = null;
2001
2002 break;
2003 }
2004 }
2005 }
2006
2007 if (list == null) {
2008 StringBundler query = null;
2009
2010 if (orderByComparator != null) {
2011 query = new StringBundler(3 +
2012 (orderByComparator.getOrderByFields().length * 3));
2013 }
2014 else {
2015 query = new StringBundler(3);
2016 }
2017
2018 query.append(_SQL_SELECT_ASSETVOCABULARY_WHERE);
2019
2020 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
2021
2022 if (orderByComparator != null) {
2023 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2024 orderByComparator);
2025 }
2026
2027 else {
2028 query.append(AssetVocabularyModelImpl.ORDER_BY_JPQL);
2029 }
2030
2031 String sql = query.toString();
2032
2033 Session session = null;
2034
2035 try {
2036 session = openSession();
2037
2038 Query q = session.createQuery(sql);
2039
2040 QueryPos qPos = QueryPos.getInstance(q);
2041
2042 qPos.add(companyId);
2043
2044 list = (List<AssetVocabulary>)QueryUtil.list(q, getDialect(),
2045 start, end);
2046 }
2047 catch (Exception e) {
2048 throw processException(e);
2049 }
2050 finally {
2051 if (list == null) {
2052 FinderCacheUtil.removeResult(finderPath, finderArgs);
2053 }
2054 else {
2055 cacheResult(list);
2056
2057 FinderCacheUtil.putResult(finderPath, finderArgs, list);
2058 }
2059
2060 closeSession(session);
2061 }
2062 }
2063
2064 return list;
2065 }
2066
2067
2076 public AssetVocabulary findByCompanyId_First(long companyId,
2077 OrderByComparator orderByComparator)
2078 throws NoSuchVocabularyException, SystemException {
2079 AssetVocabulary assetVocabulary = fetchByCompanyId_First(companyId,
2080 orderByComparator);
2081
2082 if (assetVocabulary != null) {
2083 return assetVocabulary;
2084 }
2085
2086 StringBundler msg = new StringBundler(4);
2087
2088 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2089
2090 msg.append("companyId=");
2091 msg.append(companyId);
2092
2093 msg.append(StringPool.CLOSE_CURLY_BRACE);
2094
2095 throw new NoSuchVocabularyException(msg.toString());
2096 }
2097
2098
2106 public AssetVocabulary fetchByCompanyId_First(long companyId,
2107 OrderByComparator orderByComparator) throws SystemException {
2108 List<AssetVocabulary> list = findByCompanyId(companyId, 0, 1,
2109 orderByComparator);
2110
2111 if (!list.isEmpty()) {
2112 return list.get(0);
2113 }
2114
2115 return null;
2116 }
2117
2118
2127 public AssetVocabulary findByCompanyId_Last(long companyId,
2128 OrderByComparator orderByComparator)
2129 throws NoSuchVocabularyException, SystemException {
2130 AssetVocabulary assetVocabulary = fetchByCompanyId_Last(companyId,
2131 orderByComparator);
2132
2133 if (assetVocabulary != null) {
2134 return assetVocabulary;
2135 }
2136
2137 StringBundler msg = new StringBundler(4);
2138
2139 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2140
2141 msg.append("companyId=");
2142 msg.append(companyId);
2143
2144 msg.append(StringPool.CLOSE_CURLY_BRACE);
2145
2146 throw new NoSuchVocabularyException(msg.toString());
2147 }
2148
2149
2157 public AssetVocabulary fetchByCompanyId_Last(long companyId,
2158 OrderByComparator orderByComparator) throws SystemException {
2159 int count = countByCompanyId(companyId);
2160
2161 List<AssetVocabulary> list = findByCompanyId(companyId, count - 1,
2162 count, orderByComparator);
2163
2164 if (!list.isEmpty()) {
2165 return list.get(0);
2166 }
2167
2168 return null;
2169 }
2170
2171
2181 public AssetVocabulary[] findByCompanyId_PrevAndNext(long vocabularyId,
2182 long companyId, OrderByComparator orderByComparator)
2183 throws NoSuchVocabularyException, SystemException {
2184 AssetVocabulary assetVocabulary = findByPrimaryKey(vocabularyId);
2185
2186 Session session = null;
2187
2188 try {
2189 session = openSession();
2190
2191 AssetVocabulary[] array = new AssetVocabularyImpl[3];
2192
2193 array[0] = getByCompanyId_PrevAndNext(session, assetVocabulary,
2194 companyId, orderByComparator, true);
2195
2196 array[1] = assetVocabulary;
2197
2198 array[2] = getByCompanyId_PrevAndNext(session, assetVocabulary,
2199 companyId, orderByComparator, false);
2200
2201 return array;
2202 }
2203 catch (Exception e) {
2204 throw processException(e);
2205 }
2206 finally {
2207 closeSession(session);
2208 }
2209 }
2210
2211 protected AssetVocabulary getByCompanyId_PrevAndNext(Session session,
2212 AssetVocabulary assetVocabulary, long companyId,
2213 OrderByComparator orderByComparator, boolean previous) {
2214 StringBundler query = null;
2215
2216 if (orderByComparator != null) {
2217 query = new StringBundler(6 +
2218 (orderByComparator.getOrderByFields().length * 6));
2219 }
2220 else {
2221 query = new StringBundler(3);
2222 }
2223
2224 query.append(_SQL_SELECT_ASSETVOCABULARY_WHERE);
2225
2226 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
2227
2228 if (orderByComparator != null) {
2229 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2230
2231 if (orderByConditionFields.length > 0) {
2232 query.append(WHERE_AND);
2233 }
2234
2235 for (int i = 0; i < orderByConditionFields.length; i++) {
2236 query.append(_ORDER_BY_ENTITY_ALIAS);
2237 query.append(orderByConditionFields[i]);
2238
2239 if ((i + 1) < orderByConditionFields.length) {
2240 if (orderByComparator.isAscending() ^ previous) {
2241 query.append(WHERE_GREATER_THAN_HAS_NEXT);
2242 }
2243 else {
2244 query.append(WHERE_LESSER_THAN_HAS_NEXT);
2245 }
2246 }
2247 else {
2248 if (orderByComparator.isAscending() ^ previous) {
2249 query.append(WHERE_GREATER_THAN);
2250 }
2251 else {
2252 query.append(WHERE_LESSER_THAN);
2253 }
2254 }
2255 }
2256
2257 query.append(ORDER_BY_CLAUSE);
2258
2259 String[] orderByFields = orderByComparator.getOrderByFields();
2260
2261 for (int i = 0; i < orderByFields.length; i++) {
2262 query.append(_ORDER_BY_ENTITY_ALIAS);
2263 query.append(orderByFields[i]);
2264
2265 if ((i + 1) < orderByFields.length) {
2266 if (orderByComparator.isAscending() ^ previous) {
2267 query.append(ORDER_BY_ASC_HAS_NEXT);
2268 }
2269 else {
2270 query.append(ORDER_BY_DESC_HAS_NEXT);
2271 }
2272 }
2273 else {
2274 if (orderByComparator.isAscending() ^ previous) {
2275 query.append(ORDER_BY_ASC);
2276 }
2277 else {
2278 query.append(ORDER_BY_DESC);
2279 }
2280 }
2281 }
2282 }
2283
2284 else {
2285 query.append(AssetVocabularyModelImpl.ORDER_BY_JPQL);
2286 }
2287
2288 String sql = query.toString();
2289
2290 Query q = session.createQuery(sql);
2291
2292 q.setFirstResult(0);
2293 q.setMaxResults(2);
2294
2295 QueryPos qPos = QueryPos.getInstance(q);
2296
2297 qPos.add(companyId);
2298
2299 if (orderByComparator != null) {
2300 Object[] values = orderByComparator.getOrderByConditionValues(assetVocabulary);
2301
2302 for (Object value : values) {
2303 qPos.add(value);
2304 }
2305 }
2306
2307 List<AssetVocabulary> list = q.list();
2308
2309 if (list.size() == 2) {
2310 return list.get(1);
2311 }
2312 else {
2313 return null;
2314 }
2315 }
2316
2317
2326 public AssetVocabulary findByG_N(long groupId, String name)
2327 throws NoSuchVocabularyException, SystemException {
2328 AssetVocabulary assetVocabulary = fetchByG_N(groupId, name);
2329
2330 if (assetVocabulary == null) {
2331 StringBundler msg = new StringBundler(6);
2332
2333 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2334
2335 msg.append("groupId=");
2336 msg.append(groupId);
2337
2338 msg.append(", name=");
2339 msg.append(name);
2340
2341 msg.append(StringPool.CLOSE_CURLY_BRACE);
2342
2343 if (_log.isWarnEnabled()) {
2344 _log.warn(msg.toString());
2345 }
2346
2347 throw new NoSuchVocabularyException(msg.toString());
2348 }
2349
2350 return assetVocabulary;
2351 }
2352
2353
2361 public AssetVocabulary fetchByG_N(long groupId, String name)
2362 throws SystemException {
2363 return fetchByG_N(groupId, name, true);
2364 }
2365
2366
2375 public AssetVocabulary fetchByG_N(long groupId, String name,
2376 boolean retrieveFromCache) throws SystemException {
2377 Object[] finderArgs = new Object[] { groupId, name };
2378
2379 Object result = null;
2380
2381 if (retrieveFromCache) {
2382 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_G_N,
2383 finderArgs, this);
2384 }
2385
2386 if (result instanceof AssetVocabulary) {
2387 AssetVocabulary assetVocabulary = (AssetVocabulary)result;
2388
2389 if ((groupId != assetVocabulary.getGroupId()) ||
2390 !Validator.equals(name, assetVocabulary.getName())) {
2391 result = null;
2392 }
2393 }
2394
2395 if (result == null) {
2396 StringBundler query = new StringBundler(4);
2397
2398 query.append(_SQL_SELECT_ASSETVOCABULARY_WHERE);
2399
2400 query.append(_FINDER_COLUMN_G_N_GROUPID_2);
2401
2402 if (name == null) {
2403 query.append(_FINDER_COLUMN_G_N_NAME_1);
2404 }
2405 else {
2406 if (name.equals(StringPool.BLANK)) {
2407 query.append(_FINDER_COLUMN_G_N_NAME_3);
2408 }
2409 else {
2410 query.append(_FINDER_COLUMN_G_N_NAME_2);
2411 }
2412 }
2413
2414 query.append(AssetVocabularyModelImpl.ORDER_BY_JPQL);
2415
2416 String sql = query.toString();
2417
2418 Session session = null;
2419
2420 try {
2421 session = openSession();
2422
2423 Query q = session.createQuery(sql);
2424
2425 QueryPos qPos = QueryPos.getInstance(q);
2426
2427 qPos.add(groupId);
2428
2429 if (name != null) {
2430 qPos.add(name);
2431 }
2432
2433 List<AssetVocabulary> list = q.list();
2434
2435 result = list;
2436
2437 AssetVocabulary assetVocabulary = null;
2438
2439 if (list.isEmpty()) {
2440 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_N,
2441 finderArgs, list);
2442 }
2443 else {
2444 assetVocabulary = list.get(0);
2445
2446 cacheResult(assetVocabulary);
2447
2448 if ((assetVocabulary.getGroupId() != groupId) ||
2449 (assetVocabulary.getName() == null) ||
2450 !assetVocabulary.getName().equals(name)) {
2451 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_N,
2452 finderArgs, assetVocabulary);
2453 }
2454 }
2455
2456 return assetVocabulary;
2457 }
2458 catch (Exception e) {
2459 throw processException(e);
2460 }
2461 finally {
2462 if (result == null) {
2463 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_N,
2464 finderArgs);
2465 }
2466
2467 closeSession(session);
2468 }
2469 }
2470 else {
2471 if (result instanceof List<?>) {
2472 return null;
2473 }
2474 else {
2475 return (AssetVocabulary)result;
2476 }
2477 }
2478 }
2479
2480
2486 public List<AssetVocabulary> findAll() throws SystemException {
2487 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
2488 }
2489
2490
2502 public List<AssetVocabulary> findAll(int start, int end)
2503 throws SystemException {
2504 return findAll(start, end, null);
2505 }
2506
2507
2520 public List<AssetVocabulary> findAll(int start, int end,
2521 OrderByComparator orderByComparator) throws SystemException {
2522 FinderPath finderPath = null;
2523 Object[] finderArgs = new Object[] { start, end, orderByComparator };
2524
2525 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2526 (orderByComparator == null)) {
2527 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
2528 finderArgs = FINDER_ARGS_EMPTY;
2529 }
2530 else {
2531 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
2532 finderArgs = new Object[] { start, end, orderByComparator };
2533 }
2534
2535 List<AssetVocabulary> list = (List<AssetVocabulary>)FinderCacheUtil.getResult(finderPath,
2536 finderArgs, this);
2537
2538 if (list == null) {
2539 StringBundler query = null;
2540 String sql = null;
2541
2542 if (orderByComparator != null) {
2543 query = new StringBundler(2 +
2544 (orderByComparator.getOrderByFields().length * 3));
2545
2546 query.append(_SQL_SELECT_ASSETVOCABULARY);
2547
2548 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2549 orderByComparator);
2550
2551 sql = query.toString();
2552 }
2553 else {
2554 sql = _SQL_SELECT_ASSETVOCABULARY.concat(AssetVocabularyModelImpl.ORDER_BY_JPQL);
2555 }
2556
2557 Session session = null;
2558
2559 try {
2560 session = openSession();
2561
2562 Query q = session.createQuery(sql);
2563
2564 if (orderByComparator == null) {
2565 list = (List<AssetVocabulary>)QueryUtil.list(q,
2566 getDialect(), start, end, false);
2567
2568 Collections.sort(list);
2569 }
2570 else {
2571 list = (List<AssetVocabulary>)QueryUtil.list(q,
2572 getDialect(), start, end);
2573 }
2574 }
2575 catch (Exception e) {
2576 throw processException(e);
2577 }
2578 finally {
2579 if (list == null) {
2580 FinderCacheUtil.removeResult(finderPath, finderArgs);
2581 }
2582 else {
2583 cacheResult(list);
2584
2585 FinderCacheUtil.putResult(finderPath, finderArgs, list);
2586 }
2587
2588 closeSession(session);
2589 }
2590 }
2591
2592 return list;
2593 }
2594
2595
2601 public void removeByUuid(String uuid) throws SystemException {
2602 for (AssetVocabulary assetVocabulary : findByUuid(uuid)) {
2603 remove(assetVocabulary);
2604 }
2605 }
2606
2607
2615 public AssetVocabulary removeByUUID_G(String uuid, long groupId)
2616 throws NoSuchVocabularyException, SystemException {
2617 AssetVocabulary assetVocabulary = findByUUID_G(uuid, groupId);
2618
2619 return remove(assetVocabulary);
2620 }
2621
2622
2628 public void removeByGroupId(long groupId) throws SystemException {
2629 for (AssetVocabulary assetVocabulary : findByGroupId(groupId)) {
2630 remove(assetVocabulary);
2631 }
2632 }
2633
2634
2640 public void removeByCompanyId(long companyId) throws SystemException {
2641 for (AssetVocabulary assetVocabulary : findByCompanyId(companyId)) {
2642 remove(assetVocabulary);
2643 }
2644 }
2645
2646
2654 public AssetVocabulary removeByG_N(long groupId, String name)
2655 throws NoSuchVocabularyException, SystemException {
2656 AssetVocabulary assetVocabulary = findByG_N(groupId, name);
2657
2658 return remove(assetVocabulary);
2659 }
2660
2661
2666 public void removeAll() throws SystemException {
2667 for (AssetVocabulary assetVocabulary : findAll()) {
2668 remove(assetVocabulary);
2669 }
2670 }
2671
2672
2679 public int countByUuid(String uuid) throws SystemException {
2680 Object[] finderArgs = new Object[] { uuid };
2681
2682 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID,
2683 finderArgs, this);
2684
2685 if (count == null) {
2686 StringBundler query = new StringBundler(2);
2687
2688 query.append(_SQL_COUNT_ASSETVOCABULARY_WHERE);
2689
2690 if (uuid == null) {
2691 query.append(_FINDER_COLUMN_UUID_UUID_1);
2692 }
2693 else {
2694 if (uuid.equals(StringPool.BLANK)) {
2695 query.append(_FINDER_COLUMN_UUID_UUID_3);
2696 }
2697 else {
2698 query.append(_FINDER_COLUMN_UUID_UUID_2);
2699 }
2700 }
2701
2702 String sql = query.toString();
2703
2704 Session session = null;
2705
2706 try {
2707 session = openSession();
2708
2709 Query q = session.createQuery(sql);
2710
2711 QueryPos qPos = QueryPos.getInstance(q);
2712
2713 if (uuid != null) {
2714 qPos.add(uuid);
2715 }
2716
2717 count = (Long)q.uniqueResult();
2718 }
2719 catch (Exception e) {
2720 throw processException(e);
2721 }
2722 finally {
2723 if (count == null) {
2724 count = Long.valueOf(0);
2725 }
2726
2727 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID,
2728 finderArgs, count);
2729
2730 closeSession(session);
2731 }
2732 }
2733
2734 return count.intValue();
2735 }
2736
2737
2745 public int countByUUID_G(String uuid, long groupId)
2746 throws SystemException {
2747 Object[] finderArgs = new Object[] { uuid, groupId };
2748
2749 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID_G,
2750 finderArgs, this);
2751
2752 if (count == null) {
2753 StringBundler query = new StringBundler(3);
2754
2755 query.append(_SQL_COUNT_ASSETVOCABULARY_WHERE);
2756
2757 if (uuid == null) {
2758 query.append(_FINDER_COLUMN_UUID_G_UUID_1);
2759 }
2760 else {
2761 if (uuid.equals(StringPool.BLANK)) {
2762 query.append(_FINDER_COLUMN_UUID_G_UUID_3);
2763 }
2764 else {
2765 query.append(_FINDER_COLUMN_UUID_G_UUID_2);
2766 }
2767 }
2768
2769 query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
2770
2771 String sql = query.toString();
2772
2773 Session session = null;
2774
2775 try {
2776 session = openSession();
2777
2778 Query q = session.createQuery(sql);
2779
2780 QueryPos qPos = QueryPos.getInstance(q);
2781
2782 if (uuid != null) {
2783 qPos.add(uuid);
2784 }
2785
2786 qPos.add(groupId);
2787
2788 count = (Long)q.uniqueResult();
2789 }
2790 catch (Exception e) {
2791 throw processException(e);
2792 }
2793 finally {
2794 if (count == null) {
2795 count = Long.valueOf(0);
2796 }
2797
2798 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G,
2799 finderArgs, count);
2800
2801 closeSession(session);
2802 }
2803 }
2804
2805 return count.intValue();
2806 }
2807
2808
2815 public int countByGroupId(long groupId) throws SystemException {
2816 Object[] finderArgs = new Object[] { groupId };
2817
2818 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_GROUPID,
2819 finderArgs, this);
2820
2821 if (count == null) {
2822 StringBundler query = new StringBundler(2);
2823
2824 query.append(_SQL_COUNT_ASSETVOCABULARY_WHERE);
2825
2826 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2827
2828 String sql = query.toString();
2829
2830 Session session = null;
2831
2832 try {
2833 session = openSession();
2834
2835 Query q = session.createQuery(sql);
2836
2837 QueryPos qPos = QueryPos.getInstance(q);
2838
2839 qPos.add(groupId);
2840
2841 count = (Long)q.uniqueResult();
2842 }
2843 catch (Exception e) {
2844 throw processException(e);
2845 }
2846 finally {
2847 if (count == null) {
2848 count = Long.valueOf(0);
2849 }
2850
2851 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_GROUPID,
2852 finderArgs, count);
2853
2854 closeSession(session);
2855 }
2856 }
2857
2858 return count.intValue();
2859 }
2860
2861
2868 public int filterCountByGroupId(long groupId) throws SystemException {
2869 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2870 return countByGroupId(groupId);
2871 }
2872
2873 StringBundler query = new StringBundler(2);
2874
2875 query.append(_FILTER_SQL_COUNT_ASSETVOCABULARY_WHERE);
2876
2877 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2878
2879 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2880 AssetVocabulary.class.getName(),
2881 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2882
2883 Session session = null;
2884
2885 try {
2886 session = openSession();
2887
2888 SQLQuery q = session.createSQLQuery(sql);
2889
2890 q.addScalar(COUNT_COLUMN_NAME,
2891 com.liferay.portal.kernel.dao.orm.Type.LONG);
2892
2893 QueryPos qPos = QueryPos.getInstance(q);
2894
2895 qPos.add(groupId);
2896
2897 Long count = (Long)q.uniqueResult();
2898
2899 return count.intValue();
2900 }
2901 catch (Exception e) {
2902 throw processException(e);
2903 }
2904 finally {
2905 closeSession(session);
2906 }
2907 }
2908
2909
2916 public int countByCompanyId(long companyId) throws SystemException {
2917 Object[] finderArgs = new Object[] { companyId };
2918
2919 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_COMPANYID,
2920 finderArgs, this);
2921
2922 if (count == null) {
2923 StringBundler query = new StringBundler(2);
2924
2925 query.append(_SQL_COUNT_ASSETVOCABULARY_WHERE);
2926
2927 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
2928
2929 String sql = query.toString();
2930
2931 Session session = null;
2932
2933 try {
2934 session = openSession();
2935
2936 Query q = session.createQuery(sql);
2937
2938 QueryPos qPos = QueryPos.getInstance(q);
2939
2940 qPos.add(companyId);
2941
2942 count = (Long)q.uniqueResult();
2943 }
2944 catch (Exception e) {
2945 throw processException(e);
2946 }
2947 finally {
2948 if (count == null) {
2949 count = Long.valueOf(0);
2950 }
2951
2952 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_COMPANYID,
2953 finderArgs, count);
2954
2955 closeSession(session);
2956 }
2957 }
2958
2959 return count.intValue();
2960 }
2961
2962
2970 public int countByG_N(long groupId, String name) throws SystemException {
2971 Object[] finderArgs = new Object[] { groupId, name };
2972
2973 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_N,
2974 finderArgs, this);
2975
2976 if (count == null) {
2977 StringBundler query = new StringBundler(3);
2978
2979 query.append(_SQL_COUNT_ASSETVOCABULARY_WHERE);
2980
2981 query.append(_FINDER_COLUMN_G_N_GROUPID_2);
2982
2983 if (name == null) {
2984 query.append(_FINDER_COLUMN_G_N_NAME_1);
2985 }
2986 else {
2987 if (name.equals(StringPool.BLANK)) {
2988 query.append(_FINDER_COLUMN_G_N_NAME_3);
2989 }
2990 else {
2991 query.append(_FINDER_COLUMN_G_N_NAME_2);
2992 }
2993 }
2994
2995 String sql = query.toString();
2996
2997 Session session = null;
2998
2999 try {
3000 session = openSession();
3001
3002 Query q = session.createQuery(sql);
3003
3004 QueryPos qPos = QueryPos.getInstance(q);
3005
3006 qPos.add(groupId);
3007
3008 if (name != null) {
3009 qPos.add(name);
3010 }
3011
3012 count = (Long)q.uniqueResult();
3013 }
3014 catch (Exception e) {
3015 throw processException(e);
3016 }
3017 finally {
3018 if (count == null) {
3019 count = Long.valueOf(0);
3020 }
3021
3022 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_N, finderArgs,
3023 count);
3024
3025 closeSession(session);
3026 }
3027 }
3028
3029 return count.intValue();
3030 }
3031
3032
3038 public int countAll() throws SystemException {
3039 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
3040 FINDER_ARGS_EMPTY, this);
3041
3042 if (count == null) {
3043 Session session = null;
3044
3045 try {
3046 session = openSession();
3047
3048 Query q = session.createQuery(_SQL_COUNT_ASSETVOCABULARY);
3049
3050 count = (Long)q.uniqueResult();
3051 }
3052 catch (Exception e) {
3053 throw processException(e);
3054 }
3055 finally {
3056 if (count == null) {
3057 count = Long.valueOf(0);
3058 }
3059
3060 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
3061 FINDER_ARGS_EMPTY, count);
3062
3063 closeSession(session);
3064 }
3065 }
3066
3067 return count.intValue();
3068 }
3069
3070
3073 public void afterPropertiesSet() {
3074 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
3075 com.liferay.portal.util.PropsUtil.get(
3076 "value.object.listener.com.liferay.portlet.asset.model.AssetVocabulary")));
3077
3078 if (listenerClassNames.length > 0) {
3079 try {
3080 List<ModelListener<AssetVocabulary>> listenersList = new ArrayList<ModelListener<AssetVocabulary>>();
3081
3082 for (String listenerClassName : listenerClassNames) {
3083 listenersList.add((ModelListener<AssetVocabulary>)InstanceFactory.newInstance(
3084 listenerClassName));
3085 }
3086
3087 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
3088 }
3089 catch (Exception e) {
3090 _log.error(e);
3091 }
3092 }
3093 }
3094
3095 public void destroy() {
3096 EntityCacheUtil.removeCache(AssetVocabularyImpl.class.getName());
3097 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
3098 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
3099 }
3100
3101 @BeanReference(type = AssetCategoryPersistence.class)
3102 protected AssetCategoryPersistence assetCategoryPersistence;
3103 @BeanReference(type = AssetCategoryPropertyPersistence.class)
3104 protected AssetCategoryPropertyPersistence assetCategoryPropertyPersistence;
3105 @BeanReference(type = AssetEntryPersistence.class)
3106 protected AssetEntryPersistence assetEntryPersistence;
3107 @BeanReference(type = AssetLinkPersistence.class)
3108 protected AssetLinkPersistence assetLinkPersistence;
3109 @BeanReference(type = AssetTagPersistence.class)
3110 protected AssetTagPersistence assetTagPersistence;
3111 @BeanReference(type = AssetTagPropertyPersistence.class)
3112 protected AssetTagPropertyPersistence assetTagPropertyPersistence;
3113 @BeanReference(type = AssetTagStatsPersistence.class)
3114 protected AssetTagStatsPersistence assetTagStatsPersistence;
3115 @BeanReference(type = AssetVocabularyPersistence.class)
3116 protected AssetVocabularyPersistence assetVocabularyPersistence;
3117 @BeanReference(type = GroupPersistence.class)
3118 protected GroupPersistence groupPersistence;
3119 @BeanReference(type = ResourcePersistence.class)
3120 protected ResourcePersistence resourcePersistence;
3121 @BeanReference(type = UserPersistence.class)
3122 protected UserPersistence userPersistence;
3123 private static final String _SQL_SELECT_ASSETVOCABULARY = "SELECT assetVocabulary FROM AssetVocabulary assetVocabulary";
3124 private static final String _SQL_SELECT_ASSETVOCABULARY_WHERE = "SELECT assetVocabulary FROM AssetVocabulary assetVocabulary WHERE ";
3125 private static final String _SQL_COUNT_ASSETVOCABULARY = "SELECT COUNT(assetVocabulary) FROM AssetVocabulary assetVocabulary";
3126 private static final String _SQL_COUNT_ASSETVOCABULARY_WHERE = "SELECT COUNT(assetVocabulary) FROM AssetVocabulary assetVocabulary WHERE ";
3127 private static final String _FINDER_COLUMN_UUID_UUID_1 = "assetVocabulary.uuid IS NULL";
3128 private static final String _FINDER_COLUMN_UUID_UUID_2 = "assetVocabulary.uuid = ?";
3129 private static final String _FINDER_COLUMN_UUID_UUID_3 = "(assetVocabulary.uuid IS NULL OR assetVocabulary.uuid = ?)";
3130 private static final String _FINDER_COLUMN_UUID_G_UUID_1 = "assetVocabulary.uuid IS NULL AND ";
3131 private static final String _FINDER_COLUMN_UUID_G_UUID_2 = "assetVocabulary.uuid = ? AND ";
3132 private static final String _FINDER_COLUMN_UUID_G_UUID_3 = "(assetVocabulary.uuid IS NULL OR assetVocabulary.uuid = ?) AND ";
3133 private static final String _FINDER_COLUMN_UUID_G_GROUPID_2 = "assetVocabulary.groupId = ?";
3134 private static final String _FINDER_COLUMN_GROUPID_GROUPID_2 = "assetVocabulary.groupId = ?";
3135 private static final String _FINDER_COLUMN_COMPANYID_COMPANYID_2 = "assetVocabulary.companyId = ?";
3136 private static final String _FINDER_COLUMN_G_N_GROUPID_2 = "assetVocabulary.groupId = ? AND ";
3137 private static final String _FINDER_COLUMN_G_N_NAME_1 = "assetVocabulary.name IS NULL";
3138 private static final String _FINDER_COLUMN_G_N_NAME_2 = "assetVocabulary.name = ?";
3139 private static final String _FINDER_COLUMN_G_N_NAME_3 = "(assetVocabulary.name IS NULL OR assetVocabulary.name = ?)";
3140 private static final String _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN = "assetVocabulary.vocabularyId";
3141 private static final String _FILTER_SQL_SELECT_ASSETVOCABULARY_WHERE = "SELECT DISTINCT {assetVocabulary.*} FROM AssetVocabulary assetVocabulary WHERE ";
3142 private static final String _FILTER_SQL_SELECT_ASSETVOCABULARY_NO_INLINE_DISTINCT_WHERE_1 =
3143 "SELECT {AssetVocabulary.*} FROM (SELECT DISTINCT assetVocabulary.vocabularyId FROM AssetVocabulary assetVocabulary WHERE ";
3144 private static final String _FILTER_SQL_SELECT_ASSETVOCABULARY_NO_INLINE_DISTINCT_WHERE_2 =
3145 ") TEMP_TABLE INNER JOIN AssetVocabulary ON TEMP_TABLE.vocabularyId = AssetVocabulary.vocabularyId";
3146 private static final String _FILTER_SQL_COUNT_ASSETVOCABULARY_WHERE = "SELECT COUNT(DISTINCT assetVocabulary.vocabularyId) AS COUNT_VALUE FROM AssetVocabulary assetVocabulary WHERE ";
3147 private static final String _FILTER_ENTITY_ALIAS = "assetVocabulary";
3148 private static final String _FILTER_ENTITY_TABLE = "AssetVocabulary";
3149 private static final String _ORDER_BY_ENTITY_ALIAS = "assetVocabulary.";
3150 private static final String _ORDER_BY_ENTITY_TABLE = "AssetVocabulary.";
3151 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No AssetVocabulary exists with the primary key ";
3152 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No AssetVocabulary exists with the key {";
3153 private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
3154 private static Log _log = LogFactoryUtil.getLog(AssetVocabularyPersistenceImpl.class);
3155 private static AssetVocabulary _nullAssetVocabulary = new AssetVocabularyImpl() {
3156 @Override
3157 public Object clone() {
3158 return this;
3159 }
3160
3161 @Override
3162 public CacheModel<AssetVocabulary> toCacheModel() {
3163 return _nullAssetVocabularyCacheModel;
3164 }
3165 };
3166
3167 private static CacheModel<AssetVocabulary> _nullAssetVocabularyCacheModel = new CacheModel<AssetVocabulary>() {
3168 public AssetVocabulary toEntityModel() {
3169 return _nullAssetVocabulary;
3170 }
3171 };
3172 }