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 cacheUniqueFindersCache(AssetVocabulary assetVocabulary) {
276 if (assetVocabulary.isNew()) {
277 Object[] args = new Object[] {
278 assetVocabulary.getUuid(),
279 Long.valueOf(assetVocabulary.getGroupId())
280 };
281
282 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G, args,
283 Long.valueOf(1));
284 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G, args,
285 assetVocabulary);
286
287 args = new Object[] {
288 Long.valueOf(assetVocabulary.getGroupId()),
289
290 assetVocabulary.getName()
291 };
292
293 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_N, args,
294 Long.valueOf(1));
295 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_N, args,
296 assetVocabulary);
297 }
298 else {
299 AssetVocabularyModelImpl assetVocabularyModelImpl = (AssetVocabularyModelImpl)assetVocabulary;
300
301 if ((assetVocabularyModelImpl.getColumnBitmask() &
302 FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) {
303 Object[] args = new Object[] {
304 assetVocabulary.getUuid(),
305 Long.valueOf(assetVocabulary.getGroupId())
306 };
307
308 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G, args,
309 Long.valueOf(1));
310 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G, args,
311 assetVocabulary);
312 }
313
314 if ((assetVocabularyModelImpl.getColumnBitmask() &
315 FINDER_PATH_FETCH_BY_G_N.getColumnBitmask()) != 0) {
316 Object[] args = new Object[] {
317 Long.valueOf(assetVocabulary.getGroupId()),
318
319 assetVocabulary.getName()
320 };
321
322 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_N, args,
323 Long.valueOf(1));
324 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_N, args,
325 assetVocabulary);
326 }
327 }
328 }
329
330 protected void clearUniqueFindersCache(AssetVocabulary assetVocabulary) {
331 AssetVocabularyModelImpl assetVocabularyModelImpl = (AssetVocabularyModelImpl)assetVocabulary;
332
333 Object[] args = new Object[] {
334 assetVocabulary.getUuid(),
335 Long.valueOf(assetVocabulary.getGroupId())
336 };
337
338 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args);
339 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args);
340
341 if ((assetVocabularyModelImpl.getColumnBitmask() &
342 FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) {
343 args = new Object[] {
344 assetVocabularyModelImpl.getOriginalUuid(),
345 Long.valueOf(assetVocabularyModelImpl.getOriginalGroupId())
346 };
347
348 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args);
349 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args);
350 }
351
352 args = new Object[] {
353 Long.valueOf(assetVocabulary.getGroupId()),
354
355 assetVocabulary.getName()
356 };
357
358 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_N, args);
359 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_N, args);
360
361 if ((assetVocabularyModelImpl.getColumnBitmask() &
362 FINDER_PATH_FETCH_BY_G_N.getColumnBitmask()) != 0) {
363 args = new Object[] {
364 Long.valueOf(assetVocabularyModelImpl.getOriginalGroupId()),
365
366 assetVocabularyModelImpl.getOriginalName()
367 };
368
369 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_N, args);
370 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_N, args);
371 }
372 }
373
374
380 public AssetVocabulary create(long vocabularyId) {
381 AssetVocabulary assetVocabulary = new AssetVocabularyImpl();
382
383 assetVocabulary.setNew(true);
384 assetVocabulary.setPrimaryKey(vocabularyId);
385
386 String uuid = PortalUUIDUtil.generate();
387
388 assetVocabulary.setUuid(uuid);
389
390 return assetVocabulary;
391 }
392
393
401 public AssetVocabulary remove(long vocabularyId)
402 throws NoSuchVocabularyException, SystemException {
403 return remove(Long.valueOf(vocabularyId));
404 }
405
406
414 @Override
415 public AssetVocabulary remove(Serializable primaryKey)
416 throws NoSuchVocabularyException, SystemException {
417 Session session = null;
418
419 try {
420 session = openSession();
421
422 AssetVocabulary assetVocabulary = (AssetVocabulary)session.get(AssetVocabularyImpl.class,
423 primaryKey);
424
425 if (assetVocabulary == null) {
426 if (_log.isWarnEnabled()) {
427 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
428 }
429
430 throw new NoSuchVocabularyException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
431 primaryKey);
432 }
433
434 return remove(assetVocabulary);
435 }
436 catch (NoSuchVocabularyException nsee) {
437 throw nsee;
438 }
439 catch (Exception e) {
440 throw processException(e);
441 }
442 finally {
443 closeSession(session);
444 }
445 }
446
447 @Override
448 protected AssetVocabulary removeImpl(AssetVocabulary assetVocabulary)
449 throws SystemException {
450 assetVocabulary = toUnwrappedModel(assetVocabulary);
451
452 Session session = null;
453
454 try {
455 session = openSession();
456
457 BatchSessionUtil.delete(session, assetVocabulary);
458 }
459 catch (Exception e) {
460 throw processException(e);
461 }
462 finally {
463 closeSession(session);
464 }
465
466 clearCache(assetVocabulary);
467
468 return assetVocabulary;
469 }
470
471 @Override
472 public AssetVocabulary updateImpl(
473 com.liferay.portlet.asset.model.AssetVocabulary assetVocabulary,
474 boolean merge) throws SystemException {
475 assetVocabulary = toUnwrappedModel(assetVocabulary);
476
477 boolean isNew = assetVocabulary.isNew();
478
479 AssetVocabularyModelImpl assetVocabularyModelImpl = (AssetVocabularyModelImpl)assetVocabulary;
480
481 if (Validator.isNull(assetVocabulary.getUuid())) {
482 String uuid = PortalUUIDUtil.generate();
483
484 assetVocabulary.setUuid(uuid);
485 }
486
487 Session session = null;
488
489 try {
490 session = openSession();
491
492 BatchSessionUtil.update(session, assetVocabulary, merge);
493
494 assetVocabulary.setNew(false);
495 }
496 catch (Exception e) {
497 throw processException(e);
498 }
499 finally {
500 closeSession(session);
501 }
502
503 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
504
505 if (isNew || !AssetVocabularyModelImpl.COLUMN_BITMASK_ENABLED) {
506 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
507 }
508
509 else {
510 if ((assetVocabularyModelImpl.getColumnBitmask() &
511 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID.getColumnBitmask()) != 0) {
512 Object[] args = new Object[] {
513 assetVocabularyModelImpl.getOriginalUuid()
514 };
515
516 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
517 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
518 args);
519
520 args = new Object[] { assetVocabularyModelImpl.getUuid() };
521
522 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
523 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
524 args);
525 }
526
527 if ((assetVocabularyModelImpl.getColumnBitmask() &
528 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID.getColumnBitmask()) != 0) {
529 Object[] args = new Object[] {
530 Long.valueOf(assetVocabularyModelImpl.getOriginalGroupId())
531 };
532
533 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
534 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
535 args);
536
537 args = new Object[] {
538 Long.valueOf(assetVocabularyModelImpl.getGroupId())
539 };
540
541 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
542 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
543 args);
544 }
545
546 if ((assetVocabularyModelImpl.getColumnBitmask() &
547 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID.getColumnBitmask()) != 0) {
548 Object[] args = new Object[] {
549 Long.valueOf(assetVocabularyModelImpl.getOriginalCompanyId())
550 };
551
552 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_COMPANYID,
553 args);
554 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
555 args);
556
557 args = new Object[] {
558 Long.valueOf(assetVocabularyModelImpl.getCompanyId())
559 };
560
561 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_COMPANYID,
562 args);
563 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
564 args);
565 }
566 }
567
568 EntityCacheUtil.putResult(AssetVocabularyModelImpl.ENTITY_CACHE_ENABLED,
569 AssetVocabularyImpl.class, assetVocabulary.getPrimaryKey(),
570 assetVocabulary);
571
572 clearUniqueFindersCache(assetVocabulary);
573 cacheUniqueFindersCache(assetVocabulary);
574
575 return assetVocabulary;
576 }
577
578 protected AssetVocabulary toUnwrappedModel(AssetVocabulary assetVocabulary) {
579 if (assetVocabulary instanceof AssetVocabularyImpl) {
580 return assetVocabulary;
581 }
582
583 AssetVocabularyImpl assetVocabularyImpl = new AssetVocabularyImpl();
584
585 assetVocabularyImpl.setNew(assetVocabulary.isNew());
586 assetVocabularyImpl.setPrimaryKey(assetVocabulary.getPrimaryKey());
587
588 assetVocabularyImpl.setUuid(assetVocabulary.getUuid());
589 assetVocabularyImpl.setVocabularyId(assetVocabulary.getVocabularyId());
590 assetVocabularyImpl.setGroupId(assetVocabulary.getGroupId());
591 assetVocabularyImpl.setCompanyId(assetVocabulary.getCompanyId());
592 assetVocabularyImpl.setUserId(assetVocabulary.getUserId());
593 assetVocabularyImpl.setUserName(assetVocabulary.getUserName());
594 assetVocabularyImpl.setCreateDate(assetVocabulary.getCreateDate());
595 assetVocabularyImpl.setModifiedDate(assetVocabulary.getModifiedDate());
596 assetVocabularyImpl.setName(assetVocabulary.getName());
597 assetVocabularyImpl.setTitle(assetVocabulary.getTitle());
598 assetVocabularyImpl.setDescription(assetVocabulary.getDescription());
599 assetVocabularyImpl.setSettings(assetVocabulary.getSettings());
600
601 return assetVocabularyImpl;
602 }
603
604
612 @Override
613 public AssetVocabulary findByPrimaryKey(Serializable primaryKey)
614 throws NoSuchModelException, SystemException {
615 return findByPrimaryKey(((Long)primaryKey).longValue());
616 }
617
618
626 public AssetVocabulary findByPrimaryKey(long vocabularyId)
627 throws NoSuchVocabularyException, SystemException {
628 AssetVocabulary assetVocabulary = fetchByPrimaryKey(vocabularyId);
629
630 if (assetVocabulary == null) {
631 if (_log.isWarnEnabled()) {
632 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + vocabularyId);
633 }
634
635 throw new NoSuchVocabularyException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
636 vocabularyId);
637 }
638
639 return assetVocabulary;
640 }
641
642
649 @Override
650 public AssetVocabulary fetchByPrimaryKey(Serializable primaryKey)
651 throws SystemException {
652 return fetchByPrimaryKey(((Long)primaryKey).longValue());
653 }
654
655
662 public AssetVocabulary fetchByPrimaryKey(long vocabularyId)
663 throws SystemException {
664 AssetVocabulary assetVocabulary = (AssetVocabulary)EntityCacheUtil.getResult(AssetVocabularyModelImpl.ENTITY_CACHE_ENABLED,
665 AssetVocabularyImpl.class, vocabularyId);
666
667 if (assetVocabulary == _nullAssetVocabulary) {
668 return null;
669 }
670
671 if (assetVocabulary == null) {
672 Session session = null;
673
674 boolean hasException = false;
675
676 try {
677 session = openSession();
678
679 assetVocabulary = (AssetVocabulary)session.get(AssetVocabularyImpl.class,
680 Long.valueOf(vocabularyId));
681 }
682 catch (Exception e) {
683 hasException = true;
684
685 throw processException(e);
686 }
687 finally {
688 if (assetVocabulary != null) {
689 cacheResult(assetVocabulary);
690 }
691 else if (!hasException) {
692 EntityCacheUtil.putResult(AssetVocabularyModelImpl.ENTITY_CACHE_ENABLED,
693 AssetVocabularyImpl.class, vocabularyId,
694 _nullAssetVocabulary);
695 }
696
697 closeSession(session);
698 }
699 }
700
701 return assetVocabulary;
702 }
703
704
711 public List<AssetVocabulary> findByUuid(String uuid)
712 throws SystemException {
713 return findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
714 }
715
716
729 public List<AssetVocabulary> findByUuid(String uuid, int start, int end)
730 throws SystemException {
731 return findByUuid(uuid, start, end, null);
732 }
733
734
748 public List<AssetVocabulary> findByUuid(String uuid, int start, int end,
749 OrderByComparator orderByComparator) throws SystemException {
750 FinderPath finderPath = null;
751 Object[] finderArgs = null;
752
753 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
754 (orderByComparator == null)) {
755 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID;
756 finderArgs = new Object[] { uuid };
757 }
758 else {
759 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID;
760 finderArgs = new Object[] { uuid, start, end, orderByComparator };
761 }
762
763 List<AssetVocabulary> list = (List<AssetVocabulary>)FinderCacheUtil.getResult(finderPath,
764 finderArgs, this);
765
766 if ((list != null) && !list.isEmpty()) {
767 for (AssetVocabulary assetVocabulary : list) {
768 if (!Validator.equals(uuid, assetVocabulary.getUuid())) {
769 list = null;
770
771 break;
772 }
773 }
774 }
775
776 if (list == null) {
777 StringBundler query = null;
778
779 if (orderByComparator != null) {
780 query = new StringBundler(3 +
781 (orderByComparator.getOrderByFields().length * 3));
782 }
783 else {
784 query = new StringBundler(3);
785 }
786
787 query.append(_SQL_SELECT_ASSETVOCABULARY_WHERE);
788
789 if (uuid == null) {
790 query.append(_FINDER_COLUMN_UUID_UUID_1);
791 }
792 else {
793 if (uuid.equals(StringPool.BLANK)) {
794 query.append(_FINDER_COLUMN_UUID_UUID_3);
795 }
796 else {
797 query.append(_FINDER_COLUMN_UUID_UUID_2);
798 }
799 }
800
801 if (orderByComparator != null) {
802 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
803 orderByComparator);
804 }
805
806 else {
807 query.append(AssetVocabularyModelImpl.ORDER_BY_JPQL);
808 }
809
810 String sql = query.toString();
811
812 Session session = null;
813
814 try {
815 session = openSession();
816
817 Query q = session.createQuery(sql);
818
819 QueryPos qPos = QueryPos.getInstance(q);
820
821 if (uuid != null) {
822 qPos.add(uuid);
823 }
824
825 list = (List<AssetVocabulary>)QueryUtil.list(q, getDialect(),
826 start, end);
827 }
828 catch (Exception e) {
829 throw processException(e);
830 }
831 finally {
832 if (list == null) {
833 FinderCacheUtil.removeResult(finderPath, finderArgs);
834 }
835 else {
836 cacheResult(list);
837
838 FinderCacheUtil.putResult(finderPath, finderArgs, list);
839 }
840
841 closeSession(session);
842 }
843 }
844
845 return list;
846 }
847
848
857 public AssetVocabulary findByUuid_First(String uuid,
858 OrderByComparator orderByComparator)
859 throws NoSuchVocabularyException, SystemException {
860 AssetVocabulary assetVocabulary = fetchByUuid_First(uuid,
861 orderByComparator);
862
863 if (assetVocabulary != null) {
864 return assetVocabulary;
865 }
866
867 StringBundler msg = new StringBundler(4);
868
869 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
870
871 msg.append("uuid=");
872 msg.append(uuid);
873
874 msg.append(StringPool.CLOSE_CURLY_BRACE);
875
876 throw new NoSuchVocabularyException(msg.toString());
877 }
878
879
887 public AssetVocabulary fetchByUuid_First(String uuid,
888 OrderByComparator orderByComparator) throws SystemException {
889 List<AssetVocabulary> list = findByUuid(uuid, 0, 1, orderByComparator);
890
891 if (!list.isEmpty()) {
892 return list.get(0);
893 }
894
895 return null;
896 }
897
898
907 public AssetVocabulary findByUuid_Last(String uuid,
908 OrderByComparator orderByComparator)
909 throws NoSuchVocabularyException, SystemException {
910 AssetVocabulary assetVocabulary = fetchByUuid_Last(uuid,
911 orderByComparator);
912
913 if (assetVocabulary != null) {
914 return assetVocabulary;
915 }
916
917 StringBundler msg = new StringBundler(4);
918
919 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
920
921 msg.append("uuid=");
922 msg.append(uuid);
923
924 msg.append(StringPool.CLOSE_CURLY_BRACE);
925
926 throw new NoSuchVocabularyException(msg.toString());
927 }
928
929
937 public AssetVocabulary fetchByUuid_Last(String uuid,
938 OrderByComparator orderByComparator) throws SystemException {
939 int count = countByUuid(uuid);
940
941 List<AssetVocabulary> list = findByUuid(uuid, count - 1, count,
942 orderByComparator);
943
944 if (!list.isEmpty()) {
945 return list.get(0);
946 }
947
948 return null;
949 }
950
951
961 public AssetVocabulary[] findByUuid_PrevAndNext(long vocabularyId,
962 String uuid, OrderByComparator orderByComparator)
963 throws NoSuchVocabularyException, SystemException {
964 AssetVocabulary assetVocabulary = findByPrimaryKey(vocabularyId);
965
966 Session session = null;
967
968 try {
969 session = openSession();
970
971 AssetVocabulary[] array = new AssetVocabularyImpl[3];
972
973 array[0] = getByUuid_PrevAndNext(session, assetVocabulary, uuid,
974 orderByComparator, true);
975
976 array[1] = assetVocabulary;
977
978 array[2] = getByUuid_PrevAndNext(session, assetVocabulary, uuid,
979 orderByComparator, false);
980
981 return array;
982 }
983 catch (Exception e) {
984 throw processException(e);
985 }
986 finally {
987 closeSession(session);
988 }
989 }
990
991 protected AssetVocabulary getByUuid_PrevAndNext(Session session,
992 AssetVocabulary assetVocabulary, String uuid,
993 OrderByComparator orderByComparator, boolean previous) {
994 StringBundler query = null;
995
996 if (orderByComparator != null) {
997 query = new StringBundler(6 +
998 (orderByComparator.getOrderByFields().length * 6));
999 }
1000 else {
1001 query = new StringBundler(3);
1002 }
1003
1004 query.append(_SQL_SELECT_ASSETVOCABULARY_WHERE);
1005
1006 if (uuid == null) {
1007 query.append(_FINDER_COLUMN_UUID_UUID_1);
1008 }
1009 else {
1010 if (uuid.equals(StringPool.BLANK)) {
1011 query.append(_FINDER_COLUMN_UUID_UUID_3);
1012 }
1013 else {
1014 query.append(_FINDER_COLUMN_UUID_UUID_2);
1015 }
1016 }
1017
1018 if (orderByComparator != null) {
1019 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1020
1021 if (orderByConditionFields.length > 0) {
1022 query.append(WHERE_AND);
1023 }
1024
1025 for (int i = 0; i < orderByConditionFields.length; i++) {
1026 query.append(_ORDER_BY_ENTITY_ALIAS);
1027 query.append(orderByConditionFields[i]);
1028
1029 if ((i + 1) < orderByConditionFields.length) {
1030 if (orderByComparator.isAscending() ^ previous) {
1031 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1032 }
1033 else {
1034 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1035 }
1036 }
1037 else {
1038 if (orderByComparator.isAscending() ^ previous) {
1039 query.append(WHERE_GREATER_THAN);
1040 }
1041 else {
1042 query.append(WHERE_LESSER_THAN);
1043 }
1044 }
1045 }
1046
1047 query.append(ORDER_BY_CLAUSE);
1048
1049 String[] orderByFields = orderByComparator.getOrderByFields();
1050
1051 for (int i = 0; i < orderByFields.length; i++) {
1052 query.append(_ORDER_BY_ENTITY_ALIAS);
1053 query.append(orderByFields[i]);
1054
1055 if ((i + 1) < orderByFields.length) {
1056 if (orderByComparator.isAscending() ^ previous) {
1057 query.append(ORDER_BY_ASC_HAS_NEXT);
1058 }
1059 else {
1060 query.append(ORDER_BY_DESC_HAS_NEXT);
1061 }
1062 }
1063 else {
1064 if (orderByComparator.isAscending() ^ previous) {
1065 query.append(ORDER_BY_ASC);
1066 }
1067 else {
1068 query.append(ORDER_BY_DESC);
1069 }
1070 }
1071 }
1072 }
1073
1074 else {
1075 query.append(AssetVocabularyModelImpl.ORDER_BY_JPQL);
1076 }
1077
1078 String sql = query.toString();
1079
1080 Query q = session.createQuery(sql);
1081
1082 q.setFirstResult(0);
1083 q.setMaxResults(2);
1084
1085 QueryPos qPos = QueryPos.getInstance(q);
1086
1087 if (uuid != null) {
1088 qPos.add(uuid);
1089 }
1090
1091 if (orderByComparator != null) {
1092 Object[] values = orderByComparator.getOrderByConditionValues(assetVocabulary);
1093
1094 for (Object value : values) {
1095 qPos.add(value);
1096 }
1097 }
1098
1099 List<AssetVocabulary> list = q.list();
1100
1101 if (list.size() == 2) {
1102 return list.get(1);
1103 }
1104 else {
1105 return null;
1106 }
1107 }
1108
1109
1118 public AssetVocabulary findByUUID_G(String uuid, long groupId)
1119 throws NoSuchVocabularyException, SystemException {
1120 AssetVocabulary assetVocabulary = fetchByUUID_G(uuid, groupId);
1121
1122 if (assetVocabulary == null) {
1123 StringBundler msg = new StringBundler(6);
1124
1125 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1126
1127 msg.append("uuid=");
1128 msg.append(uuid);
1129
1130 msg.append(", groupId=");
1131 msg.append(groupId);
1132
1133 msg.append(StringPool.CLOSE_CURLY_BRACE);
1134
1135 if (_log.isWarnEnabled()) {
1136 _log.warn(msg.toString());
1137 }
1138
1139 throw new NoSuchVocabularyException(msg.toString());
1140 }
1141
1142 return assetVocabulary;
1143 }
1144
1145
1153 public AssetVocabulary fetchByUUID_G(String uuid, long groupId)
1154 throws SystemException {
1155 return fetchByUUID_G(uuid, groupId, true);
1156 }
1157
1158
1167 public AssetVocabulary fetchByUUID_G(String uuid, long groupId,
1168 boolean retrieveFromCache) throws SystemException {
1169 Object[] finderArgs = new Object[] { uuid, groupId };
1170
1171 Object result = null;
1172
1173 if (retrieveFromCache) {
1174 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_UUID_G,
1175 finderArgs, this);
1176 }
1177
1178 if (result instanceof AssetVocabulary) {
1179 AssetVocabulary assetVocabulary = (AssetVocabulary)result;
1180
1181 if (!Validator.equals(uuid, assetVocabulary.getUuid()) ||
1182 (groupId != assetVocabulary.getGroupId())) {
1183 result = null;
1184 }
1185 }
1186
1187 if (result == null) {
1188 StringBundler query = new StringBundler(4);
1189
1190 query.append(_SQL_SELECT_ASSETVOCABULARY_WHERE);
1191
1192 if (uuid == null) {
1193 query.append(_FINDER_COLUMN_UUID_G_UUID_1);
1194 }
1195 else {
1196 if (uuid.equals(StringPool.BLANK)) {
1197 query.append(_FINDER_COLUMN_UUID_G_UUID_3);
1198 }
1199 else {
1200 query.append(_FINDER_COLUMN_UUID_G_UUID_2);
1201 }
1202 }
1203
1204 query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
1205
1206 query.append(AssetVocabularyModelImpl.ORDER_BY_JPQL);
1207
1208 String sql = query.toString();
1209
1210 Session session = null;
1211
1212 try {
1213 session = openSession();
1214
1215 Query q = session.createQuery(sql);
1216
1217 QueryPos qPos = QueryPos.getInstance(q);
1218
1219 if (uuid != null) {
1220 qPos.add(uuid);
1221 }
1222
1223 qPos.add(groupId);
1224
1225 List<AssetVocabulary> list = q.list();
1226
1227 result = list;
1228
1229 AssetVocabulary assetVocabulary = null;
1230
1231 if (list.isEmpty()) {
1232 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
1233 finderArgs, list);
1234 }
1235 else {
1236 assetVocabulary = list.get(0);
1237
1238 cacheResult(assetVocabulary);
1239
1240 if ((assetVocabulary.getUuid() == null) ||
1241 !assetVocabulary.getUuid().equals(uuid) ||
1242 (assetVocabulary.getGroupId() != groupId)) {
1243 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
1244 finderArgs, assetVocabulary);
1245 }
1246 }
1247
1248 return assetVocabulary;
1249 }
1250 catch (Exception e) {
1251 throw processException(e);
1252 }
1253 finally {
1254 if (result == null) {
1255 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
1256 finderArgs);
1257 }
1258
1259 closeSession(session);
1260 }
1261 }
1262 else {
1263 if (result instanceof List<?>) {
1264 return null;
1265 }
1266 else {
1267 return (AssetVocabulary)result;
1268 }
1269 }
1270 }
1271
1272
1279 public List<AssetVocabulary> findByGroupId(long groupId)
1280 throws SystemException {
1281 return findByGroupId(groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1282 }
1283
1284
1297 public List<AssetVocabulary> findByGroupId(long groupId, int start, int end)
1298 throws SystemException {
1299 return findByGroupId(groupId, start, end, null);
1300 }
1301
1302
1316 public List<AssetVocabulary> findByGroupId(long groupId, int start,
1317 int end, OrderByComparator orderByComparator) throws SystemException {
1318 FinderPath finderPath = null;
1319 Object[] finderArgs = null;
1320
1321 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1322 (orderByComparator == null)) {
1323 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID;
1324 finderArgs = new Object[] { groupId };
1325 }
1326 else {
1327 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID;
1328 finderArgs = new Object[] { groupId, start, end, orderByComparator };
1329 }
1330
1331 List<AssetVocabulary> list = (List<AssetVocabulary>)FinderCacheUtil.getResult(finderPath,
1332 finderArgs, this);
1333
1334 if ((list != null) && !list.isEmpty()) {
1335 for (AssetVocabulary assetVocabulary : list) {
1336 if ((groupId != assetVocabulary.getGroupId())) {
1337 list = null;
1338
1339 break;
1340 }
1341 }
1342 }
1343
1344 if (list == null) {
1345 StringBundler query = null;
1346
1347 if (orderByComparator != null) {
1348 query = new StringBundler(3 +
1349 (orderByComparator.getOrderByFields().length * 3));
1350 }
1351 else {
1352 query = new StringBundler(3);
1353 }
1354
1355 query.append(_SQL_SELECT_ASSETVOCABULARY_WHERE);
1356
1357 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1358
1359 if (orderByComparator != null) {
1360 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1361 orderByComparator);
1362 }
1363
1364 else {
1365 query.append(AssetVocabularyModelImpl.ORDER_BY_JPQL);
1366 }
1367
1368 String sql = query.toString();
1369
1370 Session session = null;
1371
1372 try {
1373 session = openSession();
1374
1375 Query q = session.createQuery(sql);
1376
1377 QueryPos qPos = QueryPos.getInstance(q);
1378
1379 qPos.add(groupId);
1380
1381 list = (List<AssetVocabulary>)QueryUtil.list(q, getDialect(),
1382 start, end);
1383 }
1384 catch (Exception e) {
1385 throw processException(e);
1386 }
1387 finally {
1388 if (list == null) {
1389 FinderCacheUtil.removeResult(finderPath, finderArgs);
1390 }
1391 else {
1392 cacheResult(list);
1393
1394 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1395 }
1396
1397 closeSession(session);
1398 }
1399 }
1400
1401 return list;
1402 }
1403
1404
1413 public AssetVocabulary findByGroupId_First(long groupId,
1414 OrderByComparator orderByComparator)
1415 throws NoSuchVocabularyException, SystemException {
1416 AssetVocabulary assetVocabulary = fetchByGroupId_First(groupId,
1417 orderByComparator);
1418
1419 if (assetVocabulary != null) {
1420 return assetVocabulary;
1421 }
1422
1423 StringBundler msg = new StringBundler(4);
1424
1425 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1426
1427 msg.append("groupId=");
1428 msg.append(groupId);
1429
1430 msg.append(StringPool.CLOSE_CURLY_BRACE);
1431
1432 throw new NoSuchVocabularyException(msg.toString());
1433 }
1434
1435
1443 public AssetVocabulary fetchByGroupId_First(long groupId,
1444 OrderByComparator orderByComparator) throws SystemException {
1445 List<AssetVocabulary> list = findByGroupId(groupId, 0, 1,
1446 orderByComparator);
1447
1448 if (!list.isEmpty()) {
1449 return list.get(0);
1450 }
1451
1452 return null;
1453 }
1454
1455
1464 public AssetVocabulary findByGroupId_Last(long groupId,
1465 OrderByComparator orderByComparator)
1466 throws NoSuchVocabularyException, SystemException {
1467 AssetVocabulary assetVocabulary = fetchByGroupId_Last(groupId,
1468 orderByComparator);
1469
1470 if (assetVocabulary != null) {
1471 return assetVocabulary;
1472 }
1473
1474 StringBundler msg = new StringBundler(4);
1475
1476 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1477
1478 msg.append("groupId=");
1479 msg.append(groupId);
1480
1481 msg.append(StringPool.CLOSE_CURLY_BRACE);
1482
1483 throw new NoSuchVocabularyException(msg.toString());
1484 }
1485
1486
1494 public AssetVocabulary fetchByGroupId_Last(long groupId,
1495 OrderByComparator orderByComparator) throws SystemException {
1496 int count = countByGroupId(groupId);
1497
1498 List<AssetVocabulary> list = findByGroupId(groupId, count - 1, count,
1499 orderByComparator);
1500
1501 if (!list.isEmpty()) {
1502 return list.get(0);
1503 }
1504
1505 return null;
1506 }
1507
1508
1518 public AssetVocabulary[] findByGroupId_PrevAndNext(long vocabularyId,
1519 long groupId, OrderByComparator orderByComparator)
1520 throws NoSuchVocabularyException, SystemException {
1521 AssetVocabulary assetVocabulary = findByPrimaryKey(vocabularyId);
1522
1523 Session session = null;
1524
1525 try {
1526 session = openSession();
1527
1528 AssetVocabulary[] array = new AssetVocabularyImpl[3];
1529
1530 array[0] = getByGroupId_PrevAndNext(session, assetVocabulary,
1531 groupId, orderByComparator, true);
1532
1533 array[1] = assetVocabulary;
1534
1535 array[2] = getByGroupId_PrevAndNext(session, assetVocabulary,
1536 groupId, orderByComparator, false);
1537
1538 return array;
1539 }
1540 catch (Exception e) {
1541 throw processException(e);
1542 }
1543 finally {
1544 closeSession(session);
1545 }
1546 }
1547
1548 protected AssetVocabulary getByGroupId_PrevAndNext(Session session,
1549 AssetVocabulary assetVocabulary, long groupId,
1550 OrderByComparator orderByComparator, boolean previous) {
1551 StringBundler query = null;
1552
1553 if (orderByComparator != null) {
1554 query = new StringBundler(6 +
1555 (orderByComparator.getOrderByFields().length * 6));
1556 }
1557 else {
1558 query = new StringBundler(3);
1559 }
1560
1561 query.append(_SQL_SELECT_ASSETVOCABULARY_WHERE);
1562
1563 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1564
1565 if (orderByComparator != null) {
1566 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1567
1568 if (orderByConditionFields.length > 0) {
1569 query.append(WHERE_AND);
1570 }
1571
1572 for (int i = 0; i < orderByConditionFields.length; i++) {
1573 query.append(_ORDER_BY_ENTITY_ALIAS);
1574 query.append(orderByConditionFields[i]);
1575
1576 if ((i + 1) < orderByConditionFields.length) {
1577 if (orderByComparator.isAscending() ^ previous) {
1578 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1579 }
1580 else {
1581 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1582 }
1583 }
1584 else {
1585 if (orderByComparator.isAscending() ^ previous) {
1586 query.append(WHERE_GREATER_THAN);
1587 }
1588 else {
1589 query.append(WHERE_LESSER_THAN);
1590 }
1591 }
1592 }
1593
1594 query.append(ORDER_BY_CLAUSE);
1595
1596 String[] orderByFields = orderByComparator.getOrderByFields();
1597
1598 for (int i = 0; i < orderByFields.length; i++) {
1599 query.append(_ORDER_BY_ENTITY_ALIAS);
1600 query.append(orderByFields[i]);
1601
1602 if ((i + 1) < orderByFields.length) {
1603 if (orderByComparator.isAscending() ^ previous) {
1604 query.append(ORDER_BY_ASC_HAS_NEXT);
1605 }
1606 else {
1607 query.append(ORDER_BY_DESC_HAS_NEXT);
1608 }
1609 }
1610 else {
1611 if (orderByComparator.isAscending() ^ previous) {
1612 query.append(ORDER_BY_ASC);
1613 }
1614 else {
1615 query.append(ORDER_BY_DESC);
1616 }
1617 }
1618 }
1619 }
1620
1621 else {
1622 query.append(AssetVocabularyModelImpl.ORDER_BY_JPQL);
1623 }
1624
1625 String sql = query.toString();
1626
1627 Query q = session.createQuery(sql);
1628
1629 q.setFirstResult(0);
1630 q.setMaxResults(2);
1631
1632 QueryPos qPos = QueryPos.getInstance(q);
1633
1634 qPos.add(groupId);
1635
1636 if (orderByComparator != null) {
1637 Object[] values = orderByComparator.getOrderByConditionValues(assetVocabulary);
1638
1639 for (Object value : values) {
1640 qPos.add(value);
1641 }
1642 }
1643
1644 List<AssetVocabulary> list = q.list();
1645
1646 if (list.size() == 2) {
1647 return list.get(1);
1648 }
1649 else {
1650 return null;
1651 }
1652 }
1653
1654
1661 public List<AssetVocabulary> filterFindByGroupId(long groupId)
1662 throws SystemException {
1663 return filterFindByGroupId(groupId, QueryUtil.ALL_POS,
1664 QueryUtil.ALL_POS, null);
1665 }
1666
1667
1680 public List<AssetVocabulary> filterFindByGroupId(long groupId, int start,
1681 int end) throws SystemException {
1682 return filterFindByGroupId(groupId, start, end, null);
1683 }
1684
1685
1699 public List<AssetVocabulary> filterFindByGroupId(long groupId, int start,
1700 int end, OrderByComparator orderByComparator) throws SystemException {
1701 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
1702 return findByGroupId(groupId, start, end, orderByComparator);
1703 }
1704
1705 StringBundler query = null;
1706
1707 if (orderByComparator != null) {
1708 query = new StringBundler(3 +
1709 (orderByComparator.getOrderByFields().length * 3));
1710 }
1711 else {
1712 query = new StringBundler(3);
1713 }
1714
1715 if (getDB().isSupportsInlineDistinct()) {
1716 query.append(_FILTER_SQL_SELECT_ASSETVOCABULARY_WHERE);
1717 }
1718 else {
1719 query.append(_FILTER_SQL_SELECT_ASSETVOCABULARY_NO_INLINE_DISTINCT_WHERE_1);
1720 }
1721
1722 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1723
1724 if (!getDB().isSupportsInlineDistinct()) {
1725 query.append(_FILTER_SQL_SELECT_ASSETVOCABULARY_NO_INLINE_DISTINCT_WHERE_2);
1726 }
1727
1728 if (orderByComparator != null) {
1729 if (getDB().isSupportsInlineDistinct()) {
1730 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1731 orderByComparator);
1732 }
1733 else {
1734 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
1735 orderByComparator);
1736 }
1737 }
1738
1739 else {
1740 if (getDB().isSupportsInlineDistinct()) {
1741 query.append(AssetVocabularyModelImpl.ORDER_BY_JPQL);
1742 }
1743 else {
1744 query.append(AssetVocabularyModelImpl.ORDER_BY_SQL);
1745 }
1746 }
1747
1748 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1749 AssetVocabulary.class.getName(),
1750 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
1751
1752 Session session = null;
1753
1754 try {
1755 session = openSession();
1756
1757 SQLQuery q = session.createSQLQuery(sql);
1758
1759 if (getDB().isSupportsInlineDistinct()) {
1760 q.addEntity(_FILTER_ENTITY_ALIAS, AssetVocabularyImpl.class);
1761 }
1762 else {
1763 q.addEntity(_FILTER_ENTITY_TABLE, AssetVocabularyImpl.class);
1764 }
1765
1766 QueryPos qPos = QueryPos.getInstance(q);
1767
1768 qPos.add(groupId);
1769
1770 return (List<AssetVocabulary>)QueryUtil.list(q, getDialect(),
1771 start, end);
1772 }
1773 catch (Exception e) {
1774 throw processException(e);
1775 }
1776 finally {
1777 closeSession(session);
1778 }
1779 }
1780
1781
1791 public AssetVocabulary[] filterFindByGroupId_PrevAndNext(
1792 long vocabularyId, long groupId, OrderByComparator orderByComparator)
1793 throws NoSuchVocabularyException, SystemException {
1794 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
1795 return findByGroupId_PrevAndNext(vocabularyId, groupId,
1796 orderByComparator);
1797 }
1798
1799 AssetVocabulary assetVocabulary = findByPrimaryKey(vocabularyId);
1800
1801 Session session = null;
1802
1803 try {
1804 session = openSession();
1805
1806 AssetVocabulary[] array = new AssetVocabularyImpl[3];
1807
1808 array[0] = filterGetByGroupId_PrevAndNext(session, assetVocabulary,
1809 groupId, orderByComparator, true);
1810
1811 array[1] = assetVocabulary;
1812
1813 array[2] = filterGetByGroupId_PrevAndNext(session, assetVocabulary,
1814 groupId, orderByComparator, false);
1815
1816 return array;
1817 }
1818 catch (Exception e) {
1819 throw processException(e);
1820 }
1821 finally {
1822 closeSession(session);
1823 }
1824 }
1825
1826 protected AssetVocabulary filterGetByGroupId_PrevAndNext(Session session,
1827 AssetVocabulary assetVocabulary, long groupId,
1828 OrderByComparator orderByComparator, boolean previous) {
1829 StringBundler query = null;
1830
1831 if (orderByComparator != null) {
1832 query = new StringBundler(6 +
1833 (orderByComparator.getOrderByFields().length * 6));
1834 }
1835 else {
1836 query = new StringBundler(3);
1837 }
1838
1839 if (getDB().isSupportsInlineDistinct()) {
1840 query.append(_FILTER_SQL_SELECT_ASSETVOCABULARY_WHERE);
1841 }
1842 else {
1843 query.append(_FILTER_SQL_SELECT_ASSETVOCABULARY_NO_INLINE_DISTINCT_WHERE_1);
1844 }
1845
1846 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1847
1848 if (!getDB().isSupportsInlineDistinct()) {
1849 query.append(_FILTER_SQL_SELECT_ASSETVOCABULARY_NO_INLINE_DISTINCT_WHERE_2);
1850 }
1851
1852 if (orderByComparator != null) {
1853 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1854
1855 if (orderByConditionFields.length > 0) {
1856 query.append(WHERE_AND);
1857 }
1858
1859 for (int i = 0; i < orderByConditionFields.length; i++) {
1860 if (getDB().isSupportsInlineDistinct()) {
1861 query.append(_ORDER_BY_ENTITY_ALIAS);
1862 }
1863 else {
1864 query.append(_ORDER_BY_ENTITY_TABLE);
1865 }
1866
1867 query.append(orderByConditionFields[i]);
1868
1869 if ((i + 1) < orderByConditionFields.length) {
1870 if (orderByComparator.isAscending() ^ previous) {
1871 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1872 }
1873 else {
1874 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1875 }
1876 }
1877 else {
1878 if (orderByComparator.isAscending() ^ previous) {
1879 query.append(WHERE_GREATER_THAN);
1880 }
1881 else {
1882 query.append(WHERE_LESSER_THAN);
1883 }
1884 }
1885 }
1886
1887 query.append(ORDER_BY_CLAUSE);
1888
1889 String[] orderByFields = orderByComparator.getOrderByFields();
1890
1891 for (int i = 0; i < orderByFields.length; i++) {
1892 if (getDB().isSupportsInlineDistinct()) {
1893 query.append(_ORDER_BY_ENTITY_ALIAS);
1894 }
1895 else {
1896 query.append(_ORDER_BY_ENTITY_TABLE);
1897 }
1898
1899 query.append(orderByFields[i]);
1900
1901 if ((i + 1) < orderByFields.length) {
1902 if (orderByComparator.isAscending() ^ previous) {
1903 query.append(ORDER_BY_ASC_HAS_NEXT);
1904 }
1905 else {
1906 query.append(ORDER_BY_DESC_HAS_NEXT);
1907 }
1908 }
1909 else {
1910 if (orderByComparator.isAscending() ^ previous) {
1911 query.append(ORDER_BY_ASC);
1912 }
1913 else {
1914 query.append(ORDER_BY_DESC);
1915 }
1916 }
1917 }
1918 }
1919
1920 else {
1921 if (getDB().isSupportsInlineDistinct()) {
1922 query.append(AssetVocabularyModelImpl.ORDER_BY_JPQL);
1923 }
1924 else {
1925 query.append(AssetVocabularyModelImpl.ORDER_BY_SQL);
1926 }
1927 }
1928
1929 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1930 AssetVocabulary.class.getName(),
1931 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
1932
1933 SQLQuery q = session.createSQLQuery(sql);
1934
1935 q.setFirstResult(0);
1936 q.setMaxResults(2);
1937
1938 if (getDB().isSupportsInlineDistinct()) {
1939 q.addEntity(_FILTER_ENTITY_ALIAS, AssetVocabularyImpl.class);
1940 }
1941 else {
1942 q.addEntity(_FILTER_ENTITY_TABLE, AssetVocabularyImpl.class);
1943 }
1944
1945 QueryPos qPos = QueryPos.getInstance(q);
1946
1947 qPos.add(groupId);
1948
1949 if (orderByComparator != null) {
1950 Object[] values = orderByComparator.getOrderByConditionValues(assetVocabulary);
1951
1952 for (Object value : values) {
1953 qPos.add(value);
1954 }
1955 }
1956
1957 List<AssetVocabulary> list = q.list();
1958
1959 if (list.size() == 2) {
1960 return list.get(1);
1961 }
1962 else {
1963 return null;
1964 }
1965 }
1966
1967
1974 public List<AssetVocabulary> findByCompanyId(long companyId)
1975 throws SystemException {
1976 return findByCompanyId(companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
1977 null);
1978 }
1979
1980
1993 public List<AssetVocabulary> findByCompanyId(long companyId, int start,
1994 int end) throws SystemException {
1995 return findByCompanyId(companyId, start, end, null);
1996 }
1997
1998
2012 public List<AssetVocabulary> findByCompanyId(long companyId, int start,
2013 int end, OrderByComparator orderByComparator) throws SystemException {
2014 FinderPath finderPath = null;
2015 Object[] finderArgs = null;
2016
2017 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2018 (orderByComparator == null)) {
2019 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID;
2020 finderArgs = new Object[] { companyId };
2021 }
2022 else {
2023 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID;
2024 finderArgs = new Object[] { companyId, start, end, orderByComparator };
2025 }
2026
2027 List<AssetVocabulary> list = (List<AssetVocabulary>)FinderCacheUtil.getResult(finderPath,
2028 finderArgs, this);
2029
2030 if ((list != null) && !list.isEmpty()) {
2031 for (AssetVocabulary assetVocabulary : list) {
2032 if ((companyId != assetVocabulary.getCompanyId())) {
2033 list = null;
2034
2035 break;
2036 }
2037 }
2038 }
2039
2040 if (list == null) {
2041 StringBundler query = null;
2042
2043 if (orderByComparator != null) {
2044 query = new StringBundler(3 +
2045 (orderByComparator.getOrderByFields().length * 3));
2046 }
2047 else {
2048 query = new StringBundler(3);
2049 }
2050
2051 query.append(_SQL_SELECT_ASSETVOCABULARY_WHERE);
2052
2053 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
2054
2055 if (orderByComparator != null) {
2056 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2057 orderByComparator);
2058 }
2059
2060 else {
2061 query.append(AssetVocabularyModelImpl.ORDER_BY_JPQL);
2062 }
2063
2064 String sql = query.toString();
2065
2066 Session session = null;
2067
2068 try {
2069 session = openSession();
2070
2071 Query q = session.createQuery(sql);
2072
2073 QueryPos qPos = QueryPos.getInstance(q);
2074
2075 qPos.add(companyId);
2076
2077 list = (List<AssetVocabulary>)QueryUtil.list(q, getDialect(),
2078 start, end);
2079 }
2080 catch (Exception e) {
2081 throw processException(e);
2082 }
2083 finally {
2084 if (list == null) {
2085 FinderCacheUtil.removeResult(finderPath, finderArgs);
2086 }
2087 else {
2088 cacheResult(list);
2089
2090 FinderCacheUtil.putResult(finderPath, finderArgs, list);
2091 }
2092
2093 closeSession(session);
2094 }
2095 }
2096
2097 return list;
2098 }
2099
2100
2109 public AssetVocabulary findByCompanyId_First(long companyId,
2110 OrderByComparator orderByComparator)
2111 throws NoSuchVocabularyException, SystemException {
2112 AssetVocabulary assetVocabulary = fetchByCompanyId_First(companyId,
2113 orderByComparator);
2114
2115 if (assetVocabulary != null) {
2116 return assetVocabulary;
2117 }
2118
2119 StringBundler msg = new StringBundler(4);
2120
2121 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2122
2123 msg.append("companyId=");
2124 msg.append(companyId);
2125
2126 msg.append(StringPool.CLOSE_CURLY_BRACE);
2127
2128 throw new NoSuchVocabularyException(msg.toString());
2129 }
2130
2131
2139 public AssetVocabulary fetchByCompanyId_First(long companyId,
2140 OrderByComparator orderByComparator) throws SystemException {
2141 List<AssetVocabulary> list = findByCompanyId(companyId, 0, 1,
2142 orderByComparator);
2143
2144 if (!list.isEmpty()) {
2145 return list.get(0);
2146 }
2147
2148 return null;
2149 }
2150
2151
2160 public AssetVocabulary findByCompanyId_Last(long companyId,
2161 OrderByComparator orderByComparator)
2162 throws NoSuchVocabularyException, SystemException {
2163 AssetVocabulary assetVocabulary = fetchByCompanyId_Last(companyId,
2164 orderByComparator);
2165
2166 if (assetVocabulary != null) {
2167 return assetVocabulary;
2168 }
2169
2170 StringBundler msg = new StringBundler(4);
2171
2172 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2173
2174 msg.append("companyId=");
2175 msg.append(companyId);
2176
2177 msg.append(StringPool.CLOSE_CURLY_BRACE);
2178
2179 throw new NoSuchVocabularyException(msg.toString());
2180 }
2181
2182
2190 public AssetVocabulary fetchByCompanyId_Last(long companyId,
2191 OrderByComparator orderByComparator) throws SystemException {
2192 int count = countByCompanyId(companyId);
2193
2194 List<AssetVocabulary> list = findByCompanyId(companyId, count - 1,
2195 count, orderByComparator);
2196
2197 if (!list.isEmpty()) {
2198 return list.get(0);
2199 }
2200
2201 return null;
2202 }
2203
2204
2214 public AssetVocabulary[] findByCompanyId_PrevAndNext(long vocabularyId,
2215 long companyId, OrderByComparator orderByComparator)
2216 throws NoSuchVocabularyException, SystemException {
2217 AssetVocabulary assetVocabulary = findByPrimaryKey(vocabularyId);
2218
2219 Session session = null;
2220
2221 try {
2222 session = openSession();
2223
2224 AssetVocabulary[] array = new AssetVocabularyImpl[3];
2225
2226 array[0] = getByCompanyId_PrevAndNext(session, assetVocabulary,
2227 companyId, orderByComparator, true);
2228
2229 array[1] = assetVocabulary;
2230
2231 array[2] = getByCompanyId_PrevAndNext(session, assetVocabulary,
2232 companyId, orderByComparator, false);
2233
2234 return array;
2235 }
2236 catch (Exception e) {
2237 throw processException(e);
2238 }
2239 finally {
2240 closeSession(session);
2241 }
2242 }
2243
2244 protected AssetVocabulary getByCompanyId_PrevAndNext(Session session,
2245 AssetVocabulary assetVocabulary, long companyId,
2246 OrderByComparator orderByComparator, boolean previous) {
2247 StringBundler query = null;
2248
2249 if (orderByComparator != null) {
2250 query = new StringBundler(6 +
2251 (orderByComparator.getOrderByFields().length * 6));
2252 }
2253 else {
2254 query = new StringBundler(3);
2255 }
2256
2257 query.append(_SQL_SELECT_ASSETVOCABULARY_WHERE);
2258
2259 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
2260
2261 if (orderByComparator != null) {
2262 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2263
2264 if (orderByConditionFields.length > 0) {
2265 query.append(WHERE_AND);
2266 }
2267
2268 for (int i = 0; i < orderByConditionFields.length; i++) {
2269 query.append(_ORDER_BY_ENTITY_ALIAS);
2270 query.append(orderByConditionFields[i]);
2271
2272 if ((i + 1) < orderByConditionFields.length) {
2273 if (orderByComparator.isAscending() ^ previous) {
2274 query.append(WHERE_GREATER_THAN_HAS_NEXT);
2275 }
2276 else {
2277 query.append(WHERE_LESSER_THAN_HAS_NEXT);
2278 }
2279 }
2280 else {
2281 if (orderByComparator.isAscending() ^ previous) {
2282 query.append(WHERE_GREATER_THAN);
2283 }
2284 else {
2285 query.append(WHERE_LESSER_THAN);
2286 }
2287 }
2288 }
2289
2290 query.append(ORDER_BY_CLAUSE);
2291
2292 String[] orderByFields = orderByComparator.getOrderByFields();
2293
2294 for (int i = 0; i < orderByFields.length; i++) {
2295 query.append(_ORDER_BY_ENTITY_ALIAS);
2296 query.append(orderByFields[i]);
2297
2298 if ((i + 1) < orderByFields.length) {
2299 if (orderByComparator.isAscending() ^ previous) {
2300 query.append(ORDER_BY_ASC_HAS_NEXT);
2301 }
2302 else {
2303 query.append(ORDER_BY_DESC_HAS_NEXT);
2304 }
2305 }
2306 else {
2307 if (orderByComparator.isAscending() ^ previous) {
2308 query.append(ORDER_BY_ASC);
2309 }
2310 else {
2311 query.append(ORDER_BY_DESC);
2312 }
2313 }
2314 }
2315 }
2316
2317 else {
2318 query.append(AssetVocabularyModelImpl.ORDER_BY_JPQL);
2319 }
2320
2321 String sql = query.toString();
2322
2323 Query q = session.createQuery(sql);
2324
2325 q.setFirstResult(0);
2326 q.setMaxResults(2);
2327
2328 QueryPos qPos = QueryPos.getInstance(q);
2329
2330 qPos.add(companyId);
2331
2332 if (orderByComparator != null) {
2333 Object[] values = orderByComparator.getOrderByConditionValues(assetVocabulary);
2334
2335 for (Object value : values) {
2336 qPos.add(value);
2337 }
2338 }
2339
2340 List<AssetVocabulary> list = q.list();
2341
2342 if (list.size() == 2) {
2343 return list.get(1);
2344 }
2345 else {
2346 return null;
2347 }
2348 }
2349
2350
2359 public AssetVocabulary findByG_N(long groupId, String name)
2360 throws NoSuchVocabularyException, SystemException {
2361 AssetVocabulary assetVocabulary = fetchByG_N(groupId, name);
2362
2363 if (assetVocabulary == null) {
2364 StringBundler msg = new StringBundler(6);
2365
2366 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2367
2368 msg.append("groupId=");
2369 msg.append(groupId);
2370
2371 msg.append(", name=");
2372 msg.append(name);
2373
2374 msg.append(StringPool.CLOSE_CURLY_BRACE);
2375
2376 if (_log.isWarnEnabled()) {
2377 _log.warn(msg.toString());
2378 }
2379
2380 throw new NoSuchVocabularyException(msg.toString());
2381 }
2382
2383 return assetVocabulary;
2384 }
2385
2386
2394 public AssetVocabulary fetchByG_N(long groupId, String name)
2395 throws SystemException {
2396 return fetchByG_N(groupId, name, true);
2397 }
2398
2399
2408 public AssetVocabulary fetchByG_N(long groupId, String name,
2409 boolean retrieveFromCache) throws SystemException {
2410 Object[] finderArgs = new Object[] { groupId, name };
2411
2412 Object result = null;
2413
2414 if (retrieveFromCache) {
2415 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_G_N,
2416 finderArgs, this);
2417 }
2418
2419 if (result instanceof AssetVocabulary) {
2420 AssetVocabulary assetVocabulary = (AssetVocabulary)result;
2421
2422 if ((groupId != assetVocabulary.getGroupId()) ||
2423 !Validator.equals(name, assetVocabulary.getName())) {
2424 result = null;
2425 }
2426 }
2427
2428 if (result == null) {
2429 StringBundler query = new StringBundler(4);
2430
2431 query.append(_SQL_SELECT_ASSETVOCABULARY_WHERE);
2432
2433 query.append(_FINDER_COLUMN_G_N_GROUPID_2);
2434
2435 if (name == null) {
2436 query.append(_FINDER_COLUMN_G_N_NAME_1);
2437 }
2438 else {
2439 if (name.equals(StringPool.BLANK)) {
2440 query.append(_FINDER_COLUMN_G_N_NAME_3);
2441 }
2442 else {
2443 query.append(_FINDER_COLUMN_G_N_NAME_2);
2444 }
2445 }
2446
2447 query.append(AssetVocabularyModelImpl.ORDER_BY_JPQL);
2448
2449 String sql = query.toString();
2450
2451 Session session = null;
2452
2453 try {
2454 session = openSession();
2455
2456 Query q = session.createQuery(sql);
2457
2458 QueryPos qPos = QueryPos.getInstance(q);
2459
2460 qPos.add(groupId);
2461
2462 if (name != null) {
2463 qPos.add(name);
2464 }
2465
2466 List<AssetVocabulary> list = q.list();
2467
2468 result = list;
2469
2470 AssetVocabulary assetVocabulary = null;
2471
2472 if (list.isEmpty()) {
2473 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_N,
2474 finderArgs, list);
2475 }
2476 else {
2477 assetVocabulary = list.get(0);
2478
2479 cacheResult(assetVocabulary);
2480
2481 if ((assetVocabulary.getGroupId() != groupId) ||
2482 (assetVocabulary.getName() == null) ||
2483 !assetVocabulary.getName().equals(name)) {
2484 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_N,
2485 finderArgs, assetVocabulary);
2486 }
2487 }
2488
2489 return assetVocabulary;
2490 }
2491 catch (Exception e) {
2492 throw processException(e);
2493 }
2494 finally {
2495 if (result == null) {
2496 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_N,
2497 finderArgs);
2498 }
2499
2500 closeSession(session);
2501 }
2502 }
2503 else {
2504 if (result instanceof List<?>) {
2505 return null;
2506 }
2507 else {
2508 return (AssetVocabulary)result;
2509 }
2510 }
2511 }
2512
2513
2519 public List<AssetVocabulary> findAll() throws SystemException {
2520 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
2521 }
2522
2523
2535 public List<AssetVocabulary> findAll(int start, int end)
2536 throws SystemException {
2537 return findAll(start, end, null);
2538 }
2539
2540
2553 public List<AssetVocabulary> findAll(int start, int end,
2554 OrderByComparator orderByComparator) throws SystemException {
2555 FinderPath finderPath = null;
2556 Object[] finderArgs = new Object[] { start, end, orderByComparator };
2557
2558 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2559 (orderByComparator == null)) {
2560 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
2561 finderArgs = FINDER_ARGS_EMPTY;
2562 }
2563 else {
2564 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
2565 finderArgs = new Object[] { start, end, orderByComparator };
2566 }
2567
2568 List<AssetVocabulary> list = (List<AssetVocabulary>)FinderCacheUtil.getResult(finderPath,
2569 finderArgs, this);
2570
2571 if (list == null) {
2572 StringBundler query = null;
2573 String sql = null;
2574
2575 if (orderByComparator != null) {
2576 query = new StringBundler(2 +
2577 (orderByComparator.getOrderByFields().length * 3));
2578
2579 query.append(_SQL_SELECT_ASSETVOCABULARY);
2580
2581 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2582 orderByComparator);
2583
2584 sql = query.toString();
2585 }
2586 else {
2587 sql = _SQL_SELECT_ASSETVOCABULARY.concat(AssetVocabularyModelImpl.ORDER_BY_JPQL);
2588 }
2589
2590 Session session = null;
2591
2592 try {
2593 session = openSession();
2594
2595 Query q = session.createQuery(sql);
2596
2597 if (orderByComparator == null) {
2598 list = (List<AssetVocabulary>)QueryUtil.list(q,
2599 getDialect(), start, end, false);
2600
2601 Collections.sort(list);
2602 }
2603 else {
2604 list = (List<AssetVocabulary>)QueryUtil.list(q,
2605 getDialect(), start, end);
2606 }
2607 }
2608 catch (Exception e) {
2609 throw processException(e);
2610 }
2611 finally {
2612 if (list == null) {
2613 FinderCacheUtil.removeResult(finderPath, finderArgs);
2614 }
2615 else {
2616 cacheResult(list);
2617
2618 FinderCacheUtil.putResult(finderPath, finderArgs, list);
2619 }
2620
2621 closeSession(session);
2622 }
2623 }
2624
2625 return list;
2626 }
2627
2628
2634 public void removeByUuid(String uuid) throws SystemException {
2635 for (AssetVocabulary assetVocabulary : findByUuid(uuid)) {
2636 remove(assetVocabulary);
2637 }
2638 }
2639
2640
2648 public AssetVocabulary removeByUUID_G(String uuid, long groupId)
2649 throws NoSuchVocabularyException, SystemException {
2650 AssetVocabulary assetVocabulary = findByUUID_G(uuid, groupId);
2651
2652 return remove(assetVocabulary);
2653 }
2654
2655
2661 public void removeByGroupId(long groupId) throws SystemException {
2662 for (AssetVocabulary assetVocabulary : findByGroupId(groupId)) {
2663 remove(assetVocabulary);
2664 }
2665 }
2666
2667
2673 public void removeByCompanyId(long companyId) throws SystemException {
2674 for (AssetVocabulary assetVocabulary : findByCompanyId(companyId)) {
2675 remove(assetVocabulary);
2676 }
2677 }
2678
2679
2687 public AssetVocabulary removeByG_N(long groupId, String name)
2688 throws NoSuchVocabularyException, SystemException {
2689 AssetVocabulary assetVocabulary = findByG_N(groupId, name);
2690
2691 return remove(assetVocabulary);
2692 }
2693
2694
2699 public void removeAll() throws SystemException {
2700 for (AssetVocabulary assetVocabulary : findAll()) {
2701 remove(assetVocabulary);
2702 }
2703 }
2704
2705
2712 public int countByUuid(String uuid) throws SystemException {
2713 Object[] finderArgs = new Object[] { uuid };
2714
2715 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID,
2716 finderArgs, this);
2717
2718 if (count == null) {
2719 StringBundler query = new StringBundler(2);
2720
2721 query.append(_SQL_COUNT_ASSETVOCABULARY_WHERE);
2722
2723 if (uuid == null) {
2724 query.append(_FINDER_COLUMN_UUID_UUID_1);
2725 }
2726 else {
2727 if (uuid.equals(StringPool.BLANK)) {
2728 query.append(_FINDER_COLUMN_UUID_UUID_3);
2729 }
2730 else {
2731 query.append(_FINDER_COLUMN_UUID_UUID_2);
2732 }
2733 }
2734
2735 String sql = query.toString();
2736
2737 Session session = null;
2738
2739 try {
2740 session = openSession();
2741
2742 Query q = session.createQuery(sql);
2743
2744 QueryPos qPos = QueryPos.getInstance(q);
2745
2746 if (uuid != null) {
2747 qPos.add(uuid);
2748 }
2749
2750 count = (Long)q.uniqueResult();
2751 }
2752 catch (Exception e) {
2753 throw processException(e);
2754 }
2755 finally {
2756 if (count == null) {
2757 count = Long.valueOf(0);
2758 }
2759
2760 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID,
2761 finderArgs, count);
2762
2763 closeSession(session);
2764 }
2765 }
2766
2767 return count.intValue();
2768 }
2769
2770
2778 public int countByUUID_G(String uuid, long groupId)
2779 throws SystemException {
2780 Object[] finderArgs = new Object[] { uuid, groupId };
2781
2782 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID_G,
2783 finderArgs, this);
2784
2785 if (count == null) {
2786 StringBundler query = new StringBundler(3);
2787
2788 query.append(_SQL_COUNT_ASSETVOCABULARY_WHERE);
2789
2790 if (uuid == null) {
2791 query.append(_FINDER_COLUMN_UUID_G_UUID_1);
2792 }
2793 else {
2794 if (uuid.equals(StringPool.BLANK)) {
2795 query.append(_FINDER_COLUMN_UUID_G_UUID_3);
2796 }
2797 else {
2798 query.append(_FINDER_COLUMN_UUID_G_UUID_2);
2799 }
2800 }
2801
2802 query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
2803
2804 String sql = query.toString();
2805
2806 Session session = null;
2807
2808 try {
2809 session = openSession();
2810
2811 Query q = session.createQuery(sql);
2812
2813 QueryPos qPos = QueryPos.getInstance(q);
2814
2815 if (uuid != null) {
2816 qPos.add(uuid);
2817 }
2818
2819 qPos.add(groupId);
2820
2821 count = (Long)q.uniqueResult();
2822 }
2823 catch (Exception e) {
2824 throw processException(e);
2825 }
2826 finally {
2827 if (count == null) {
2828 count = Long.valueOf(0);
2829 }
2830
2831 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G,
2832 finderArgs, count);
2833
2834 closeSession(session);
2835 }
2836 }
2837
2838 return count.intValue();
2839 }
2840
2841
2848 public int countByGroupId(long groupId) throws SystemException {
2849 Object[] finderArgs = new Object[] { groupId };
2850
2851 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_GROUPID,
2852 finderArgs, this);
2853
2854 if (count == null) {
2855 StringBundler query = new StringBundler(2);
2856
2857 query.append(_SQL_COUNT_ASSETVOCABULARY_WHERE);
2858
2859 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2860
2861 String sql = query.toString();
2862
2863 Session session = null;
2864
2865 try {
2866 session = openSession();
2867
2868 Query q = session.createQuery(sql);
2869
2870 QueryPos qPos = QueryPos.getInstance(q);
2871
2872 qPos.add(groupId);
2873
2874 count = (Long)q.uniqueResult();
2875 }
2876 catch (Exception e) {
2877 throw processException(e);
2878 }
2879 finally {
2880 if (count == null) {
2881 count = Long.valueOf(0);
2882 }
2883
2884 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_GROUPID,
2885 finderArgs, count);
2886
2887 closeSession(session);
2888 }
2889 }
2890
2891 return count.intValue();
2892 }
2893
2894
2901 public int filterCountByGroupId(long groupId) throws SystemException {
2902 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2903 return countByGroupId(groupId);
2904 }
2905
2906 StringBundler query = new StringBundler(2);
2907
2908 query.append(_FILTER_SQL_COUNT_ASSETVOCABULARY_WHERE);
2909
2910 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2911
2912 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2913 AssetVocabulary.class.getName(),
2914 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2915
2916 Session session = null;
2917
2918 try {
2919 session = openSession();
2920
2921 SQLQuery q = session.createSQLQuery(sql);
2922
2923 q.addScalar(COUNT_COLUMN_NAME,
2924 com.liferay.portal.kernel.dao.orm.Type.LONG);
2925
2926 QueryPos qPos = QueryPos.getInstance(q);
2927
2928 qPos.add(groupId);
2929
2930 Long count = (Long)q.uniqueResult();
2931
2932 return count.intValue();
2933 }
2934 catch (Exception e) {
2935 throw processException(e);
2936 }
2937 finally {
2938 closeSession(session);
2939 }
2940 }
2941
2942
2949 public int countByCompanyId(long companyId) throws SystemException {
2950 Object[] finderArgs = new Object[] { companyId };
2951
2952 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_COMPANYID,
2953 finderArgs, this);
2954
2955 if (count == null) {
2956 StringBundler query = new StringBundler(2);
2957
2958 query.append(_SQL_COUNT_ASSETVOCABULARY_WHERE);
2959
2960 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
2961
2962 String sql = query.toString();
2963
2964 Session session = null;
2965
2966 try {
2967 session = openSession();
2968
2969 Query q = session.createQuery(sql);
2970
2971 QueryPos qPos = QueryPos.getInstance(q);
2972
2973 qPos.add(companyId);
2974
2975 count = (Long)q.uniqueResult();
2976 }
2977 catch (Exception e) {
2978 throw processException(e);
2979 }
2980 finally {
2981 if (count == null) {
2982 count = Long.valueOf(0);
2983 }
2984
2985 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_COMPANYID,
2986 finderArgs, count);
2987
2988 closeSession(session);
2989 }
2990 }
2991
2992 return count.intValue();
2993 }
2994
2995
3003 public int countByG_N(long groupId, String name) throws SystemException {
3004 Object[] finderArgs = new Object[] { groupId, name };
3005
3006 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_N,
3007 finderArgs, this);
3008
3009 if (count == null) {
3010 StringBundler query = new StringBundler(3);
3011
3012 query.append(_SQL_COUNT_ASSETVOCABULARY_WHERE);
3013
3014 query.append(_FINDER_COLUMN_G_N_GROUPID_2);
3015
3016 if (name == null) {
3017 query.append(_FINDER_COLUMN_G_N_NAME_1);
3018 }
3019 else {
3020 if (name.equals(StringPool.BLANK)) {
3021 query.append(_FINDER_COLUMN_G_N_NAME_3);
3022 }
3023 else {
3024 query.append(_FINDER_COLUMN_G_N_NAME_2);
3025 }
3026 }
3027
3028 String sql = query.toString();
3029
3030 Session session = null;
3031
3032 try {
3033 session = openSession();
3034
3035 Query q = session.createQuery(sql);
3036
3037 QueryPos qPos = QueryPos.getInstance(q);
3038
3039 qPos.add(groupId);
3040
3041 if (name != null) {
3042 qPos.add(name);
3043 }
3044
3045 count = (Long)q.uniqueResult();
3046 }
3047 catch (Exception e) {
3048 throw processException(e);
3049 }
3050 finally {
3051 if (count == null) {
3052 count = Long.valueOf(0);
3053 }
3054
3055 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_N, finderArgs,
3056 count);
3057
3058 closeSession(session);
3059 }
3060 }
3061
3062 return count.intValue();
3063 }
3064
3065
3071 public int countAll() throws SystemException {
3072 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
3073 FINDER_ARGS_EMPTY, this);
3074
3075 if (count == null) {
3076 Session session = null;
3077
3078 try {
3079 session = openSession();
3080
3081 Query q = session.createQuery(_SQL_COUNT_ASSETVOCABULARY);
3082
3083 count = (Long)q.uniqueResult();
3084 }
3085 catch (Exception e) {
3086 throw processException(e);
3087 }
3088 finally {
3089 if (count == null) {
3090 count = Long.valueOf(0);
3091 }
3092
3093 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
3094 FINDER_ARGS_EMPTY, count);
3095
3096 closeSession(session);
3097 }
3098 }
3099
3100 return count.intValue();
3101 }
3102
3103
3106 public void afterPropertiesSet() {
3107 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
3108 com.liferay.portal.util.PropsUtil.get(
3109 "value.object.listener.com.liferay.portlet.asset.model.AssetVocabulary")));
3110
3111 if (listenerClassNames.length > 0) {
3112 try {
3113 List<ModelListener<AssetVocabulary>> listenersList = new ArrayList<ModelListener<AssetVocabulary>>();
3114
3115 for (String listenerClassName : listenerClassNames) {
3116 Class<?> clazz = getClass();
3117
3118 listenersList.add((ModelListener<AssetVocabulary>)InstanceFactory.newInstance(
3119 clazz.getClassLoader(), listenerClassName));
3120 }
3121
3122 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
3123 }
3124 catch (Exception e) {
3125 _log.error(e);
3126 }
3127 }
3128 }
3129
3130 public void destroy() {
3131 EntityCacheUtil.removeCache(AssetVocabularyImpl.class.getName());
3132 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
3133 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
3134 }
3135
3136 @BeanReference(type = AssetCategoryPersistence.class)
3137 protected AssetCategoryPersistence assetCategoryPersistence;
3138 @BeanReference(type = AssetCategoryPropertyPersistence.class)
3139 protected AssetCategoryPropertyPersistence assetCategoryPropertyPersistence;
3140 @BeanReference(type = AssetEntryPersistence.class)
3141 protected AssetEntryPersistence assetEntryPersistence;
3142 @BeanReference(type = AssetLinkPersistence.class)
3143 protected AssetLinkPersistence assetLinkPersistence;
3144 @BeanReference(type = AssetTagPersistence.class)
3145 protected AssetTagPersistence assetTagPersistence;
3146 @BeanReference(type = AssetTagPropertyPersistence.class)
3147 protected AssetTagPropertyPersistence assetTagPropertyPersistence;
3148 @BeanReference(type = AssetTagStatsPersistence.class)
3149 protected AssetTagStatsPersistence assetTagStatsPersistence;
3150 @BeanReference(type = AssetVocabularyPersistence.class)
3151 protected AssetVocabularyPersistence assetVocabularyPersistence;
3152 @BeanReference(type = GroupPersistence.class)
3153 protected GroupPersistence groupPersistence;
3154 @BeanReference(type = ResourcePersistence.class)
3155 protected ResourcePersistence resourcePersistence;
3156 @BeanReference(type = UserPersistence.class)
3157 protected UserPersistence userPersistence;
3158 private static final String _SQL_SELECT_ASSETVOCABULARY = "SELECT assetVocabulary FROM AssetVocabulary assetVocabulary";
3159 private static final String _SQL_SELECT_ASSETVOCABULARY_WHERE = "SELECT assetVocabulary FROM AssetVocabulary assetVocabulary WHERE ";
3160 private static final String _SQL_COUNT_ASSETVOCABULARY = "SELECT COUNT(assetVocabulary) FROM AssetVocabulary assetVocabulary";
3161 private static final String _SQL_COUNT_ASSETVOCABULARY_WHERE = "SELECT COUNT(assetVocabulary) FROM AssetVocabulary assetVocabulary WHERE ";
3162 private static final String _FINDER_COLUMN_UUID_UUID_1 = "assetVocabulary.uuid IS NULL";
3163 private static final String _FINDER_COLUMN_UUID_UUID_2 = "assetVocabulary.uuid = ?";
3164 private static final String _FINDER_COLUMN_UUID_UUID_3 = "(assetVocabulary.uuid IS NULL OR assetVocabulary.uuid = ?)";
3165 private static final String _FINDER_COLUMN_UUID_G_UUID_1 = "assetVocabulary.uuid IS NULL AND ";
3166 private static final String _FINDER_COLUMN_UUID_G_UUID_2 = "assetVocabulary.uuid = ? AND ";
3167 private static final String _FINDER_COLUMN_UUID_G_UUID_3 = "(assetVocabulary.uuid IS NULL OR assetVocabulary.uuid = ?) AND ";
3168 private static final String _FINDER_COLUMN_UUID_G_GROUPID_2 = "assetVocabulary.groupId = ?";
3169 private static final String _FINDER_COLUMN_GROUPID_GROUPID_2 = "assetVocabulary.groupId = ?";
3170 private static final String _FINDER_COLUMN_COMPANYID_COMPANYID_2 = "assetVocabulary.companyId = ?";
3171 private static final String _FINDER_COLUMN_G_N_GROUPID_2 = "assetVocabulary.groupId = ? AND ";
3172 private static final String _FINDER_COLUMN_G_N_NAME_1 = "assetVocabulary.name IS NULL";
3173 private static final String _FINDER_COLUMN_G_N_NAME_2 = "assetVocabulary.name = ?";
3174 private static final String _FINDER_COLUMN_G_N_NAME_3 = "(assetVocabulary.name IS NULL OR assetVocabulary.name = ?)";
3175 private static final String _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN = "assetVocabulary.vocabularyId";
3176 private static final String _FILTER_SQL_SELECT_ASSETVOCABULARY_WHERE = "SELECT DISTINCT {assetVocabulary.*} FROM AssetVocabulary assetVocabulary WHERE ";
3177 private static final String _FILTER_SQL_SELECT_ASSETVOCABULARY_NO_INLINE_DISTINCT_WHERE_1 =
3178 "SELECT {AssetVocabulary.*} FROM (SELECT DISTINCT assetVocabulary.vocabularyId FROM AssetVocabulary assetVocabulary WHERE ";
3179 private static final String _FILTER_SQL_SELECT_ASSETVOCABULARY_NO_INLINE_DISTINCT_WHERE_2 =
3180 ") TEMP_TABLE INNER JOIN AssetVocabulary ON TEMP_TABLE.vocabularyId = AssetVocabulary.vocabularyId";
3181 private static final String _FILTER_SQL_COUNT_ASSETVOCABULARY_WHERE = "SELECT COUNT(DISTINCT assetVocabulary.vocabularyId) AS COUNT_VALUE FROM AssetVocabulary assetVocabulary WHERE ";
3182 private static final String _FILTER_ENTITY_ALIAS = "assetVocabulary";
3183 private static final String _FILTER_ENTITY_TABLE = "AssetVocabulary";
3184 private static final String _ORDER_BY_ENTITY_ALIAS = "assetVocabulary.";
3185 private static final String _ORDER_BY_ENTITY_TABLE = "AssetVocabulary.";
3186 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No AssetVocabulary exists with the primary key ";
3187 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No AssetVocabulary exists with the key {";
3188 private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
3189 private static Log _log = LogFactoryUtil.getLog(AssetVocabularyPersistenceImpl.class);
3190 private static AssetVocabulary _nullAssetVocabulary = new AssetVocabularyImpl() {
3191 @Override
3192 public Object clone() {
3193 return this;
3194 }
3195
3196 @Override
3197 public CacheModel<AssetVocabulary> toCacheModel() {
3198 return _nullAssetVocabularyCacheModel;
3199 }
3200 };
3201
3202 private static CacheModel<AssetVocabulary> _nullAssetVocabularyCacheModel = new CacheModel<AssetVocabulary>() {
3203 public AssetVocabulary toEntityModel() {
3204 return _nullAssetVocabulary;
3205 }
3206 };
3207 }