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.GroupPersistence;
043 import com.liferay.portal.service.persistence.UserPersistence;
044 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
045
046 import com.liferay.portlet.asset.NoSuchVocabularyException;
047 import com.liferay.portlet.asset.model.AssetVocabulary;
048 import com.liferay.portlet.asset.model.impl.AssetVocabularyImpl;
049 import com.liferay.portlet.asset.model.impl.AssetVocabularyModelImpl;
050
051 import java.io.Serializable;
052
053 import java.util.ArrayList;
054 import java.util.Collections;
055 import java.util.List;
056
057
069 public class AssetVocabularyPersistenceImpl extends BasePersistenceImpl<AssetVocabulary>
070 implements AssetVocabularyPersistence {
071
076 public static final String FINDER_CLASS_NAME_ENTITY = AssetVocabularyImpl.class.getName();
077 public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
078 ".List1";
079 public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
080 ".List2";
081 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID = new FinderPath(AssetVocabularyModelImpl.ENTITY_CACHE_ENABLED,
082 AssetVocabularyModelImpl.FINDER_CACHE_ENABLED,
083 AssetVocabularyImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
084 "findByUuid",
085 new String[] {
086 String.class.getName(),
087
088 "java.lang.Integer", "java.lang.Integer",
089 "com.liferay.portal.kernel.util.OrderByComparator"
090 });
091 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID = new FinderPath(AssetVocabularyModelImpl.ENTITY_CACHE_ENABLED,
092 AssetVocabularyModelImpl.FINDER_CACHE_ENABLED,
093 AssetVocabularyImpl.class,
094 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid",
095 new String[] { String.class.getName() },
096 AssetVocabularyModelImpl.UUID_COLUMN_BITMASK);
097 public static final FinderPath FINDER_PATH_COUNT_BY_UUID = new FinderPath(AssetVocabularyModelImpl.ENTITY_CACHE_ENABLED,
098 AssetVocabularyModelImpl.FINDER_CACHE_ENABLED, Long.class,
099 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid",
100 new String[] { String.class.getName() });
101 public static final FinderPath FINDER_PATH_FETCH_BY_UUID_G = new FinderPath(AssetVocabularyModelImpl.ENTITY_CACHE_ENABLED,
102 AssetVocabularyModelImpl.FINDER_CACHE_ENABLED,
103 AssetVocabularyImpl.class, FINDER_CLASS_NAME_ENTITY,
104 "fetchByUUID_G",
105 new String[] { String.class.getName(), Long.class.getName() },
106 AssetVocabularyModelImpl.UUID_COLUMN_BITMASK |
107 AssetVocabularyModelImpl.GROUPID_COLUMN_BITMASK);
108 public static final FinderPath FINDER_PATH_COUNT_BY_UUID_G = new FinderPath(AssetVocabularyModelImpl.ENTITY_CACHE_ENABLED,
109 AssetVocabularyModelImpl.FINDER_CACHE_ENABLED, Long.class,
110 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUUID_G",
111 new String[] { String.class.getName(), Long.class.getName() });
112 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID_C = new FinderPath(AssetVocabularyModelImpl.ENTITY_CACHE_ENABLED,
113 AssetVocabularyModelImpl.FINDER_CACHE_ENABLED,
114 AssetVocabularyImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
115 "findByUuid_C",
116 new String[] {
117 String.class.getName(), Long.class.getName(),
118
119 "java.lang.Integer", "java.lang.Integer",
120 "com.liferay.portal.kernel.util.OrderByComparator"
121 });
122 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C =
123 new FinderPath(AssetVocabularyModelImpl.ENTITY_CACHE_ENABLED,
124 AssetVocabularyModelImpl.FINDER_CACHE_ENABLED,
125 AssetVocabularyImpl.class,
126 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid_C",
127 new String[] { String.class.getName(), Long.class.getName() },
128 AssetVocabularyModelImpl.UUID_COLUMN_BITMASK |
129 AssetVocabularyModelImpl.COMPANYID_COLUMN_BITMASK);
130 public static final FinderPath FINDER_PATH_COUNT_BY_UUID_C = new FinderPath(AssetVocabularyModelImpl.ENTITY_CACHE_ENABLED,
131 AssetVocabularyModelImpl.FINDER_CACHE_ENABLED, Long.class,
132 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid_C",
133 new String[] { String.class.getName(), Long.class.getName() });
134 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID = new FinderPath(AssetVocabularyModelImpl.ENTITY_CACHE_ENABLED,
135 AssetVocabularyModelImpl.FINDER_CACHE_ENABLED,
136 AssetVocabularyImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
137 "findByGroupId",
138 new String[] {
139 Long.class.getName(),
140
141 "java.lang.Integer", "java.lang.Integer",
142 "com.liferay.portal.kernel.util.OrderByComparator"
143 });
144 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID =
145 new FinderPath(AssetVocabularyModelImpl.ENTITY_CACHE_ENABLED,
146 AssetVocabularyModelImpl.FINDER_CACHE_ENABLED,
147 AssetVocabularyImpl.class,
148 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByGroupId",
149 new String[] { Long.class.getName() },
150 AssetVocabularyModelImpl.GROUPID_COLUMN_BITMASK);
151 public static final FinderPath FINDER_PATH_COUNT_BY_GROUPID = new FinderPath(AssetVocabularyModelImpl.ENTITY_CACHE_ENABLED,
152 AssetVocabularyModelImpl.FINDER_CACHE_ENABLED, Long.class,
153 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByGroupId",
154 new String[] { Long.class.getName() });
155 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID =
156 new FinderPath(AssetVocabularyModelImpl.ENTITY_CACHE_ENABLED,
157 AssetVocabularyModelImpl.FINDER_CACHE_ENABLED,
158 AssetVocabularyImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
159 "findByCompanyId",
160 new String[] {
161 Long.class.getName(),
162
163 "java.lang.Integer", "java.lang.Integer",
164 "com.liferay.portal.kernel.util.OrderByComparator"
165 });
166 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID =
167 new FinderPath(AssetVocabularyModelImpl.ENTITY_CACHE_ENABLED,
168 AssetVocabularyModelImpl.FINDER_CACHE_ENABLED,
169 AssetVocabularyImpl.class,
170 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByCompanyId",
171 new String[] { Long.class.getName() },
172 AssetVocabularyModelImpl.COMPANYID_COLUMN_BITMASK);
173 public static final FinderPath FINDER_PATH_COUNT_BY_COMPANYID = new FinderPath(AssetVocabularyModelImpl.ENTITY_CACHE_ENABLED,
174 AssetVocabularyModelImpl.FINDER_CACHE_ENABLED, Long.class,
175 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByCompanyId",
176 new String[] { Long.class.getName() });
177 public static final FinderPath FINDER_PATH_FETCH_BY_G_N = new FinderPath(AssetVocabularyModelImpl.ENTITY_CACHE_ENABLED,
178 AssetVocabularyModelImpl.FINDER_CACHE_ENABLED,
179 AssetVocabularyImpl.class, FINDER_CLASS_NAME_ENTITY, "fetchByG_N",
180 new String[] { Long.class.getName(), String.class.getName() },
181 AssetVocabularyModelImpl.GROUPID_COLUMN_BITMASK |
182 AssetVocabularyModelImpl.NAME_COLUMN_BITMASK);
183 public static final FinderPath FINDER_PATH_COUNT_BY_G_N = new FinderPath(AssetVocabularyModelImpl.ENTITY_CACHE_ENABLED,
184 AssetVocabularyModelImpl.FINDER_CACHE_ENABLED, Long.class,
185 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_N",
186 new String[] { Long.class.getName(), String.class.getName() });
187 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(AssetVocabularyModelImpl.ENTITY_CACHE_ENABLED,
188 AssetVocabularyModelImpl.FINDER_CACHE_ENABLED,
189 AssetVocabularyImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
190 "findAll", new String[0]);
191 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(AssetVocabularyModelImpl.ENTITY_CACHE_ENABLED,
192 AssetVocabularyModelImpl.FINDER_CACHE_ENABLED,
193 AssetVocabularyImpl.class,
194 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
195 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(AssetVocabularyModelImpl.ENTITY_CACHE_ENABLED,
196 AssetVocabularyModelImpl.FINDER_CACHE_ENABLED, Long.class,
197 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
198
199
204 public void cacheResult(AssetVocabulary assetVocabulary) {
205 EntityCacheUtil.putResult(AssetVocabularyModelImpl.ENTITY_CACHE_ENABLED,
206 AssetVocabularyImpl.class, assetVocabulary.getPrimaryKey(),
207 assetVocabulary);
208
209 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
210 new Object[] {
211 assetVocabulary.getUuid(),
212 Long.valueOf(assetVocabulary.getGroupId())
213 }, assetVocabulary);
214
215 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_N,
216 new Object[] {
217 Long.valueOf(assetVocabulary.getGroupId()),
218
219 assetVocabulary.getName()
220 }, assetVocabulary);
221
222 assetVocabulary.resetOriginalValues();
223 }
224
225
230 public void cacheResult(List<AssetVocabulary> assetVocabularies) {
231 for (AssetVocabulary assetVocabulary : assetVocabularies) {
232 if (EntityCacheUtil.getResult(
233 AssetVocabularyModelImpl.ENTITY_CACHE_ENABLED,
234 AssetVocabularyImpl.class,
235 assetVocabulary.getPrimaryKey()) == null) {
236 cacheResult(assetVocabulary);
237 }
238 else {
239 assetVocabulary.resetOriginalValues();
240 }
241 }
242 }
243
244
251 @Override
252 public void clearCache() {
253 if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
254 CacheRegistryUtil.clear(AssetVocabularyImpl.class.getName());
255 }
256
257 EntityCacheUtil.clearCache(AssetVocabularyImpl.class.getName());
258
259 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
260 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
261 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
262 }
263
264
271 @Override
272 public void clearCache(AssetVocabulary assetVocabulary) {
273 EntityCacheUtil.removeResult(AssetVocabularyModelImpl.ENTITY_CACHE_ENABLED,
274 AssetVocabularyImpl.class, assetVocabulary.getPrimaryKey());
275
276 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
277 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
278
279 clearUniqueFindersCache(assetVocabulary);
280 }
281
282 @Override
283 public void clearCache(List<AssetVocabulary> assetVocabularies) {
284 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
285 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
286
287 for (AssetVocabulary assetVocabulary : assetVocabularies) {
288 EntityCacheUtil.removeResult(AssetVocabularyModelImpl.ENTITY_CACHE_ENABLED,
289 AssetVocabularyImpl.class, assetVocabulary.getPrimaryKey());
290
291 clearUniqueFindersCache(assetVocabulary);
292 }
293 }
294
295 protected void clearUniqueFindersCache(AssetVocabulary assetVocabulary) {
296 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
297 new Object[] {
298 assetVocabulary.getUuid(),
299 Long.valueOf(assetVocabulary.getGroupId())
300 });
301
302 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_N,
303 new Object[] {
304 Long.valueOf(assetVocabulary.getGroupId()),
305
306 assetVocabulary.getName()
307 });
308 }
309
310
316 public AssetVocabulary create(long vocabularyId) {
317 AssetVocabulary assetVocabulary = new AssetVocabularyImpl();
318
319 assetVocabulary.setNew(true);
320 assetVocabulary.setPrimaryKey(vocabularyId);
321
322 String uuid = PortalUUIDUtil.generate();
323
324 assetVocabulary.setUuid(uuid);
325
326 return assetVocabulary;
327 }
328
329
337 public AssetVocabulary remove(long vocabularyId)
338 throws NoSuchVocabularyException, SystemException {
339 return remove(Long.valueOf(vocabularyId));
340 }
341
342
350 @Override
351 public AssetVocabulary remove(Serializable primaryKey)
352 throws NoSuchVocabularyException, SystemException {
353 Session session = null;
354
355 try {
356 session = openSession();
357
358 AssetVocabulary assetVocabulary = (AssetVocabulary)session.get(AssetVocabularyImpl.class,
359 primaryKey);
360
361 if (assetVocabulary == null) {
362 if (_log.isWarnEnabled()) {
363 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
364 }
365
366 throw new NoSuchVocabularyException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
367 primaryKey);
368 }
369
370 return remove(assetVocabulary);
371 }
372 catch (NoSuchVocabularyException nsee) {
373 throw nsee;
374 }
375 catch (Exception e) {
376 throw processException(e);
377 }
378 finally {
379 closeSession(session);
380 }
381 }
382
383 @Override
384 protected AssetVocabulary removeImpl(AssetVocabulary assetVocabulary)
385 throws SystemException {
386 assetVocabulary = toUnwrappedModel(assetVocabulary);
387
388 Session session = null;
389
390 try {
391 session = openSession();
392
393 if (assetVocabulary.isCachedModel()) {
394 assetVocabulary = (AssetVocabulary)session.get(AssetVocabularyImpl.class,
395 assetVocabulary.getPrimaryKeyObj());
396 }
397
398 session.delete(assetVocabulary);
399 }
400 catch (Exception e) {
401 throw processException(e);
402 }
403 finally {
404 closeSession(session);
405 }
406
407 clearCache(assetVocabulary);
408
409 return assetVocabulary;
410 }
411
412 @Override
413 public AssetVocabulary updateImpl(
414 com.liferay.portlet.asset.model.AssetVocabulary assetVocabulary)
415 throws SystemException {
416 assetVocabulary = toUnwrappedModel(assetVocabulary);
417
418 boolean isNew = assetVocabulary.isNew();
419
420 AssetVocabularyModelImpl assetVocabularyModelImpl = (AssetVocabularyModelImpl)assetVocabulary;
421
422 if (Validator.isNull(assetVocabulary.getUuid())) {
423 String uuid = PortalUUIDUtil.generate();
424
425 assetVocabulary.setUuid(uuid);
426 }
427
428 Session session = null;
429
430 try {
431 session = openSession();
432
433 if (assetVocabulary.isNew()) {
434 session.save(assetVocabulary);
435
436 assetVocabulary.setNew(false);
437 }
438 else {
439 session.merge(assetVocabulary);
440 }
441 }
442 catch (Exception e) {
443 throw processException(e);
444 }
445 finally {
446 closeSession(session);
447 }
448
449 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
450
451 if (isNew || !AssetVocabularyModelImpl.COLUMN_BITMASK_ENABLED) {
452 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
453 }
454
455 else {
456 if ((assetVocabularyModelImpl.getColumnBitmask() &
457 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID.getColumnBitmask()) != 0) {
458 Object[] args = new Object[] {
459 assetVocabularyModelImpl.getOriginalUuid()
460 };
461
462 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
463 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
464 args);
465
466 args = new Object[] { assetVocabularyModelImpl.getUuid() };
467
468 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
469 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
470 args);
471 }
472
473 if ((assetVocabularyModelImpl.getColumnBitmask() &
474 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C.getColumnBitmask()) != 0) {
475 Object[] args = new Object[] {
476 assetVocabularyModelImpl.getOriginalUuid(),
477 Long.valueOf(assetVocabularyModelImpl.getOriginalCompanyId())
478 };
479
480 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args);
481 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C,
482 args);
483
484 args = new Object[] {
485 assetVocabularyModelImpl.getUuid(),
486 Long.valueOf(assetVocabularyModelImpl.getCompanyId())
487 };
488
489 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args);
490 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C,
491 args);
492 }
493
494 if ((assetVocabularyModelImpl.getColumnBitmask() &
495 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID.getColumnBitmask()) != 0) {
496 Object[] args = new Object[] {
497 Long.valueOf(assetVocabularyModelImpl.getOriginalGroupId())
498 };
499
500 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
501 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
502 args);
503
504 args = new Object[] {
505 Long.valueOf(assetVocabularyModelImpl.getGroupId())
506 };
507
508 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
509 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
510 args);
511 }
512
513 if ((assetVocabularyModelImpl.getColumnBitmask() &
514 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID.getColumnBitmask()) != 0) {
515 Object[] args = new Object[] {
516 Long.valueOf(assetVocabularyModelImpl.getOriginalCompanyId())
517 };
518
519 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_COMPANYID,
520 args);
521 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
522 args);
523
524 args = new Object[] {
525 Long.valueOf(assetVocabularyModelImpl.getCompanyId())
526 };
527
528 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_COMPANYID,
529 args);
530 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
531 args);
532 }
533 }
534
535 EntityCacheUtil.putResult(AssetVocabularyModelImpl.ENTITY_CACHE_ENABLED,
536 AssetVocabularyImpl.class, assetVocabulary.getPrimaryKey(),
537 assetVocabulary);
538
539 if (isNew) {
540 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
541 new Object[] {
542 assetVocabulary.getUuid(),
543 Long.valueOf(assetVocabulary.getGroupId())
544 }, assetVocabulary);
545
546 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_N,
547 new Object[] {
548 Long.valueOf(assetVocabulary.getGroupId()),
549
550 assetVocabulary.getName()
551 }, assetVocabulary);
552 }
553 else {
554 if ((assetVocabularyModelImpl.getColumnBitmask() &
555 FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) {
556 Object[] args = new Object[] {
557 assetVocabularyModelImpl.getOriginalUuid(),
558 Long.valueOf(assetVocabularyModelImpl.getOriginalGroupId())
559 };
560
561 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args);
562
563 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args);
564
565 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
566 new Object[] {
567 assetVocabulary.getUuid(),
568 Long.valueOf(assetVocabulary.getGroupId())
569 }, assetVocabulary);
570 }
571
572 if ((assetVocabularyModelImpl.getColumnBitmask() &
573 FINDER_PATH_FETCH_BY_G_N.getColumnBitmask()) != 0) {
574 Object[] args = new Object[] {
575 Long.valueOf(assetVocabularyModelImpl.getOriginalGroupId()),
576
577 assetVocabularyModelImpl.getOriginalName()
578 };
579
580 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_N, args);
581
582 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_N, args);
583
584 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_N,
585 new Object[] {
586 Long.valueOf(assetVocabulary.getGroupId()),
587
588 assetVocabulary.getName()
589 }, assetVocabulary);
590 }
591 }
592
593 return assetVocabulary;
594 }
595
596 protected AssetVocabulary toUnwrappedModel(AssetVocabulary assetVocabulary) {
597 if (assetVocabulary instanceof AssetVocabularyImpl) {
598 return assetVocabulary;
599 }
600
601 AssetVocabularyImpl assetVocabularyImpl = new AssetVocabularyImpl();
602
603 assetVocabularyImpl.setNew(assetVocabulary.isNew());
604 assetVocabularyImpl.setPrimaryKey(assetVocabulary.getPrimaryKey());
605
606 assetVocabularyImpl.setUuid(assetVocabulary.getUuid());
607 assetVocabularyImpl.setVocabularyId(assetVocabulary.getVocabularyId());
608 assetVocabularyImpl.setGroupId(assetVocabulary.getGroupId());
609 assetVocabularyImpl.setCompanyId(assetVocabulary.getCompanyId());
610 assetVocabularyImpl.setUserId(assetVocabulary.getUserId());
611 assetVocabularyImpl.setUserName(assetVocabulary.getUserName());
612 assetVocabularyImpl.setCreateDate(assetVocabulary.getCreateDate());
613 assetVocabularyImpl.setModifiedDate(assetVocabulary.getModifiedDate());
614 assetVocabularyImpl.setName(assetVocabulary.getName());
615 assetVocabularyImpl.setTitle(assetVocabulary.getTitle());
616 assetVocabularyImpl.setDescription(assetVocabulary.getDescription());
617 assetVocabularyImpl.setSettings(assetVocabulary.getSettings());
618
619 return assetVocabularyImpl;
620 }
621
622
630 @Override
631 public AssetVocabulary findByPrimaryKey(Serializable primaryKey)
632 throws NoSuchModelException, SystemException {
633 return findByPrimaryKey(((Long)primaryKey).longValue());
634 }
635
636
644 public AssetVocabulary findByPrimaryKey(long vocabularyId)
645 throws NoSuchVocabularyException, SystemException {
646 AssetVocabulary assetVocabulary = fetchByPrimaryKey(vocabularyId);
647
648 if (assetVocabulary == null) {
649 if (_log.isWarnEnabled()) {
650 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + vocabularyId);
651 }
652
653 throw new NoSuchVocabularyException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
654 vocabularyId);
655 }
656
657 return assetVocabulary;
658 }
659
660
667 @Override
668 public AssetVocabulary fetchByPrimaryKey(Serializable primaryKey)
669 throws SystemException {
670 return fetchByPrimaryKey(((Long)primaryKey).longValue());
671 }
672
673
680 public AssetVocabulary fetchByPrimaryKey(long vocabularyId)
681 throws SystemException {
682 AssetVocabulary assetVocabulary = (AssetVocabulary)EntityCacheUtil.getResult(AssetVocabularyModelImpl.ENTITY_CACHE_ENABLED,
683 AssetVocabularyImpl.class, vocabularyId);
684
685 if (assetVocabulary == _nullAssetVocabulary) {
686 return null;
687 }
688
689 if (assetVocabulary == null) {
690 Session session = null;
691
692 boolean hasException = false;
693
694 try {
695 session = openSession();
696
697 assetVocabulary = (AssetVocabulary)session.get(AssetVocabularyImpl.class,
698 Long.valueOf(vocabularyId));
699 }
700 catch (Exception e) {
701 hasException = true;
702
703 throw processException(e);
704 }
705 finally {
706 if (assetVocabulary != null) {
707 cacheResult(assetVocabulary);
708 }
709 else if (!hasException) {
710 EntityCacheUtil.putResult(AssetVocabularyModelImpl.ENTITY_CACHE_ENABLED,
711 AssetVocabularyImpl.class, vocabularyId,
712 _nullAssetVocabulary);
713 }
714
715 closeSession(session);
716 }
717 }
718
719 return assetVocabulary;
720 }
721
722
729 public List<AssetVocabulary> findByUuid(String uuid)
730 throws SystemException {
731 return findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
732 }
733
734
747 public List<AssetVocabulary> findByUuid(String uuid, int start, int end)
748 throws SystemException {
749 return findByUuid(uuid, start, end, null);
750 }
751
752
766 public List<AssetVocabulary> findByUuid(String uuid, int start, int end,
767 OrderByComparator orderByComparator) throws SystemException {
768 FinderPath finderPath = null;
769 Object[] finderArgs = null;
770
771 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
772 (orderByComparator == null)) {
773 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID;
774 finderArgs = new Object[] { uuid };
775 }
776 else {
777 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID;
778 finderArgs = new Object[] { uuid, start, end, orderByComparator };
779 }
780
781 List<AssetVocabulary> list = (List<AssetVocabulary>)FinderCacheUtil.getResult(finderPath,
782 finderArgs, this);
783
784 if ((list != null) && !list.isEmpty()) {
785 for (AssetVocabulary assetVocabulary : list) {
786 if (!Validator.equals(uuid, assetVocabulary.getUuid())) {
787 list = null;
788
789 break;
790 }
791 }
792 }
793
794 if (list == null) {
795 StringBundler query = null;
796
797 if (orderByComparator != null) {
798 query = new StringBundler(3 +
799 (orderByComparator.getOrderByFields().length * 3));
800 }
801 else {
802 query = new StringBundler(3);
803 }
804
805 query.append(_SQL_SELECT_ASSETVOCABULARY_WHERE);
806
807 if (uuid == null) {
808 query.append(_FINDER_COLUMN_UUID_UUID_1);
809 }
810 else {
811 if (uuid.equals(StringPool.BLANK)) {
812 query.append(_FINDER_COLUMN_UUID_UUID_3);
813 }
814 else {
815 query.append(_FINDER_COLUMN_UUID_UUID_2);
816 }
817 }
818
819 if (orderByComparator != null) {
820 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
821 orderByComparator);
822 }
823
824 else {
825 query.append(AssetVocabularyModelImpl.ORDER_BY_JPQL);
826 }
827
828 String sql = query.toString();
829
830 Session session = null;
831
832 try {
833 session = openSession();
834
835 Query q = session.createQuery(sql);
836
837 QueryPos qPos = QueryPos.getInstance(q);
838
839 if (uuid != null) {
840 qPos.add(uuid);
841 }
842
843 list = (List<AssetVocabulary>)QueryUtil.list(q, getDialect(),
844 start, end);
845 }
846 catch (Exception e) {
847 throw processException(e);
848 }
849 finally {
850 if (list == null) {
851 FinderCacheUtil.removeResult(finderPath, finderArgs);
852 }
853 else {
854 cacheResult(list);
855
856 FinderCacheUtil.putResult(finderPath, finderArgs, list);
857 }
858
859 closeSession(session);
860 }
861 }
862
863 return list;
864 }
865
866
875 public AssetVocabulary findByUuid_First(String uuid,
876 OrderByComparator orderByComparator)
877 throws NoSuchVocabularyException, SystemException {
878 AssetVocabulary assetVocabulary = fetchByUuid_First(uuid,
879 orderByComparator);
880
881 if (assetVocabulary != null) {
882 return assetVocabulary;
883 }
884
885 StringBundler msg = new StringBundler(4);
886
887 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
888
889 msg.append("uuid=");
890 msg.append(uuid);
891
892 msg.append(StringPool.CLOSE_CURLY_BRACE);
893
894 throw new NoSuchVocabularyException(msg.toString());
895 }
896
897
905 public AssetVocabulary fetchByUuid_First(String uuid,
906 OrderByComparator orderByComparator) throws SystemException {
907 List<AssetVocabulary> list = findByUuid(uuid, 0, 1, orderByComparator);
908
909 if (!list.isEmpty()) {
910 return list.get(0);
911 }
912
913 return null;
914 }
915
916
925 public AssetVocabulary findByUuid_Last(String uuid,
926 OrderByComparator orderByComparator)
927 throws NoSuchVocabularyException, SystemException {
928 AssetVocabulary assetVocabulary = fetchByUuid_Last(uuid,
929 orderByComparator);
930
931 if (assetVocabulary != null) {
932 return assetVocabulary;
933 }
934
935 StringBundler msg = new StringBundler(4);
936
937 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
938
939 msg.append("uuid=");
940 msg.append(uuid);
941
942 msg.append(StringPool.CLOSE_CURLY_BRACE);
943
944 throw new NoSuchVocabularyException(msg.toString());
945 }
946
947
955 public AssetVocabulary fetchByUuid_Last(String uuid,
956 OrderByComparator orderByComparator) throws SystemException {
957 int count = countByUuid(uuid);
958
959 List<AssetVocabulary> list = findByUuid(uuid, count - 1, count,
960 orderByComparator);
961
962 if (!list.isEmpty()) {
963 return list.get(0);
964 }
965
966 return null;
967 }
968
969
979 public AssetVocabulary[] findByUuid_PrevAndNext(long vocabularyId,
980 String uuid, OrderByComparator orderByComparator)
981 throws NoSuchVocabularyException, SystemException {
982 AssetVocabulary assetVocabulary = findByPrimaryKey(vocabularyId);
983
984 Session session = null;
985
986 try {
987 session = openSession();
988
989 AssetVocabulary[] array = new AssetVocabularyImpl[3];
990
991 array[0] = getByUuid_PrevAndNext(session, assetVocabulary, uuid,
992 orderByComparator, true);
993
994 array[1] = assetVocabulary;
995
996 array[2] = getByUuid_PrevAndNext(session, assetVocabulary, uuid,
997 orderByComparator, false);
998
999 return array;
1000 }
1001 catch (Exception e) {
1002 throw processException(e);
1003 }
1004 finally {
1005 closeSession(session);
1006 }
1007 }
1008
1009 protected AssetVocabulary getByUuid_PrevAndNext(Session session,
1010 AssetVocabulary assetVocabulary, String uuid,
1011 OrderByComparator orderByComparator, boolean previous) {
1012 StringBundler query = null;
1013
1014 if (orderByComparator != null) {
1015 query = new StringBundler(6 +
1016 (orderByComparator.getOrderByFields().length * 6));
1017 }
1018 else {
1019 query = new StringBundler(3);
1020 }
1021
1022 query.append(_SQL_SELECT_ASSETVOCABULARY_WHERE);
1023
1024 if (uuid == null) {
1025 query.append(_FINDER_COLUMN_UUID_UUID_1);
1026 }
1027 else {
1028 if (uuid.equals(StringPool.BLANK)) {
1029 query.append(_FINDER_COLUMN_UUID_UUID_3);
1030 }
1031 else {
1032 query.append(_FINDER_COLUMN_UUID_UUID_2);
1033 }
1034 }
1035
1036 if (orderByComparator != null) {
1037 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1038
1039 if (orderByConditionFields.length > 0) {
1040 query.append(WHERE_AND);
1041 }
1042
1043 for (int i = 0; i < orderByConditionFields.length; i++) {
1044 query.append(_ORDER_BY_ENTITY_ALIAS);
1045 query.append(orderByConditionFields[i]);
1046
1047 if ((i + 1) < orderByConditionFields.length) {
1048 if (orderByComparator.isAscending() ^ previous) {
1049 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1050 }
1051 else {
1052 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1053 }
1054 }
1055 else {
1056 if (orderByComparator.isAscending() ^ previous) {
1057 query.append(WHERE_GREATER_THAN);
1058 }
1059 else {
1060 query.append(WHERE_LESSER_THAN);
1061 }
1062 }
1063 }
1064
1065 query.append(ORDER_BY_CLAUSE);
1066
1067 String[] orderByFields = orderByComparator.getOrderByFields();
1068
1069 for (int i = 0; i < orderByFields.length; i++) {
1070 query.append(_ORDER_BY_ENTITY_ALIAS);
1071 query.append(orderByFields[i]);
1072
1073 if ((i + 1) < orderByFields.length) {
1074 if (orderByComparator.isAscending() ^ previous) {
1075 query.append(ORDER_BY_ASC_HAS_NEXT);
1076 }
1077 else {
1078 query.append(ORDER_BY_DESC_HAS_NEXT);
1079 }
1080 }
1081 else {
1082 if (orderByComparator.isAscending() ^ previous) {
1083 query.append(ORDER_BY_ASC);
1084 }
1085 else {
1086 query.append(ORDER_BY_DESC);
1087 }
1088 }
1089 }
1090 }
1091
1092 else {
1093 query.append(AssetVocabularyModelImpl.ORDER_BY_JPQL);
1094 }
1095
1096 String sql = query.toString();
1097
1098 Query q = session.createQuery(sql);
1099
1100 q.setFirstResult(0);
1101 q.setMaxResults(2);
1102
1103 QueryPos qPos = QueryPos.getInstance(q);
1104
1105 if (uuid != null) {
1106 qPos.add(uuid);
1107 }
1108
1109 if (orderByComparator != null) {
1110 Object[] values = orderByComparator.getOrderByConditionValues(assetVocabulary);
1111
1112 for (Object value : values) {
1113 qPos.add(value);
1114 }
1115 }
1116
1117 List<AssetVocabulary> list = q.list();
1118
1119 if (list.size() == 2) {
1120 return list.get(1);
1121 }
1122 else {
1123 return null;
1124 }
1125 }
1126
1127
1136 public AssetVocabulary findByUUID_G(String uuid, long groupId)
1137 throws NoSuchVocabularyException, SystemException {
1138 AssetVocabulary assetVocabulary = fetchByUUID_G(uuid, groupId);
1139
1140 if (assetVocabulary == null) {
1141 StringBundler msg = new StringBundler(6);
1142
1143 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1144
1145 msg.append("uuid=");
1146 msg.append(uuid);
1147
1148 msg.append(", groupId=");
1149 msg.append(groupId);
1150
1151 msg.append(StringPool.CLOSE_CURLY_BRACE);
1152
1153 if (_log.isWarnEnabled()) {
1154 _log.warn(msg.toString());
1155 }
1156
1157 throw new NoSuchVocabularyException(msg.toString());
1158 }
1159
1160 return assetVocabulary;
1161 }
1162
1163
1171 public AssetVocabulary fetchByUUID_G(String uuid, long groupId)
1172 throws SystemException {
1173 return fetchByUUID_G(uuid, groupId, true);
1174 }
1175
1176
1185 public AssetVocabulary fetchByUUID_G(String uuid, long groupId,
1186 boolean retrieveFromCache) throws SystemException {
1187 Object[] finderArgs = new Object[] { uuid, groupId };
1188
1189 Object result = null;
1190
1191 if (retrieveFromCache) {
1192 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_UUID_G,
1193 finderArgs, this);
1194 }
1195
1196 if (result instanceof AssetVocabulary) {
1197 AssetVocabulary assetVocabulary = (AssetVocabulary)result;
1198
1199 if (!Validator.equals(uuid, assetVocabulary.getUuid()) ||
1200 (groupId != assetVocabulary.getGroupId())) {
1201 result = null;
1202 }
1203 }
1204
1205 if (result == null) {
1206 StringBundler query = new StringBundler(4);
1207
1208 query.append(_SQL_SELECT_ASSETVOCABULARY_WHERE);
1209
1210 if (uuid == null) {
1211 query.append(_FINDER_COLUMN_UUID_G_UUID_1);
1212 }
1213 else {
1214 if (uuid.equals(StringPool.BLANK)) {
1215 query.append(_FINDER_COLUMN_UUID_G_UUID_3);
1216 }
1217 else {
1218 query.append(_FINDER_COLUMN_UUID_G_UUID_2);
1219 }
1220 }
1221
1222 query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
1223
1224 query.append(AssetVocabularyModelImpl.ORDER_BY_JPQL);
1225
1226 String sql = query.toString();
1227
1228 Session session = null;
1229
1230 try {
1231 session = openSession();
1232
1233 Query q = session.createQuery(sql);
1234
1235 QueryPos qPos = QueryPos.getInstance(q);
1236
1237 if (uuid != null) {
1238 qPos.add(uuid);
1239 }
1240
1241 qPos.add(groupId);
1242
1243 List<AssetVocabulary> list = q.list();
1244
1245 result = list;
1246
1247 AssetVocabulary assetVocabulary = null;
1248
1249 if (list.isEmpty()) {
1250 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
1251 finderArgs, list);
1252 }
1253 else {
1254 assetVocabulary = list.get(0);
1255
1256 cacheResult(assetVocabulary);
1257
1258 if ((assetVocabulary.getUuid() == null) ||
1259 !assetVocabulary.getUuid().equals(uuid) ||
1260 (assetVocabulary.getGroupId() != groupId)) {
1261 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
1262 finderArgs, assetVocabulary);
1263 }
1264 }
1265
1266 return assetVocabulary;
1267 }
1268 catch (Exception e) {
1269 throw processException(e);
1270 }
1271 finally {
1272 if (result == null) {
1273 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
1274 finderArgs);
1275 }
1276
1277 closeSession(session);
1278 }
1279 }
1280 else {
1281 if (result instanceof List<?>) {
1282 return null;
1283 }
1284 else {
1285 return (AssetVocabulary)result;
1286 }
1287 }
1288 }
1289
1290
1298 public List<AssetVocabulary> findByUuid_C(String uuid, long companyId)
1299 throws SystemException {
1300 return findByUuid_C(uuid, companyId, QueryUtil.ALL_POS,
1301 QueryUtil.ALL_POS, null);
1302 }
1303
1304
1318 public List<AssetVocabulary> findByUuid_C(String uuid, long companyId,
1319 int start, int end) throws SystemException {
1320 return findByUuid_C(uuid, companyId, start, end, null);
1321 }
1322
1323
1338 public List<AssetVocabulary> findByUuid_C(String uuid, long companyId,
1339 int start, int end, OrderByComparator orderByComparator)
1340 throws SystemException {
1341 FinderPath finderPath = null;
1342 Object[] finderArgs = null;
1343
1344 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1345 (orderByComparator == null)) {
1346 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C;
1347 finderArgs = new Object[] { uuid, companyId };
1348 }
1349 else {
1350 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID_C;
1351 finderArgs = new Object[] {
1352 uuid, companyId,
1353
1354 start, end, orderByComparator
1355 };
1356 }
1357
1358 List<AssetVocabulary> list = (List<AssetVocabulary>)FinderCacheUtil.getResult(finderPath,
1359 finderArgs, this);
1360
1361 if ((list != null) && !list.isEmpty()) {
1362 for (AssetVocabulary assetVocabulary : list) {
1363 if (!Validator.equals(uuid, assetVocabulary.getUuid()) ||
1364 (companyId != assetVocabulary.getCompanyId())) {
1365 list = null;
1366
1367 break;
1368 }
1369 }
1370 }
1371
1372 if (list == null) {
1373 StringBundler query = null;
1374
1375 if (orderByComparator != null) {
1376 query = new StringBundler(4 +
1377 (orderByComparator.getOrderByFields().length * 3));
1378 }
1379 else {
1380 query = new StringBundler(4);
1381 }
1382
1383 query.append(_SQL_SELECT_ASSETVOCABULARY_WHERE);
1384
1385 if (uuid == null) {
1386 query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1387 }
1388 else {
1389 if (uuid.equals(StringPool.BLANK)) {
1390 query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1391 }
1392 else {
1393 query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1394 }
1395 }
1396
1397 query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1398
1399 if (orderByComparator != null) {
1400 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1401 orderByComparator);
1402 }
1403
1404 else {
1405 query.append(AssetVocabularyModelImpl.ORDER_BY_JPQL);
1406 }
1407
1408 String sql = query.toString();
1409
1410 Session session = null;
1411
1412 try {
1413 session = openSession();
1414
1415 Query q = session.createQuery(sql);
1416
1417 QueryPos qPos = QueryPos.getInstance(q);
1418
1419 if (uuid != null) {
1420 qPos.add(uuid);
1421 }
1422
1423 qPos.add(companyId);
1424
1425 list = (List<AssetVocabulary>)QueryUtil.list(q, getDialect(),
1426 start, end);
1427 }
1428 catch (Exception e) {
1429 throw processException(e);
1430 }
1431 finally {
1432 if (list == null) {
1433 FinderCacheUtil.removeResult(finderPath, finderArgs);
1434 }
1435 else {
1436 cacheResult(list);
1437
1438 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1439 }
1440
1441 closeSession(session);
1442 }
1443 }
1444
1445 return list;
1446 }
1447
1448
1458 public AssetVocabulary findByUuid_C_First(String uuid, long companyId,
1459 OrderByComparator orderByComparator)
1460 throws NoSuchVocabularyException, SystemException {
1461 AssetVocabulary assetVocabulary = fetchByUuid_C_First(uuid, companyId,
1462 orderByComparator);
1463
1464 if (assetVocabulary != null) {
1465 return assetVocabulary;
1466 }
1467
1468 StringBundler msg = new StringBundler(6);
1469
1470 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1471
1472 msg.append("uuid=");
1473 msg.append(uuid);
1474
1475 msg.append(", companyId=");
1476 msg.append(companyId);
1477
1478 msg.append(StringPool.CLOSE_CURLY_BRACE);
1479
1480 throw new NoSuchVocabularyException(msg.toString());
1481 }
1482
1483
1492 public AssetVocabulary fetchByUuid_C_First(String uuid, long companyId,
1493 OrderByComparator orderByComparator) throws SystemException {
1494 List<AssetVocabulary> list = findByUuid_C(uuid, companyId, 0, 1,
1495 orderByComparator);
1496
1497 if (!list.isEmpty()) {
1498 return list.get(0);
1499 }
1500
1501 return null;
1502 }
1503
1504
1514 public AssetVocabulary findByUuid_C_Last(String uuid, long companyId,
1515 OrderByComparator orderByComparator)
1516 throws NoSuchVocabularyException, SystemException {
1517 AssetVocabulary assetVocabulary = fetchByUuid_C_Last(uuid, companyId,
1518 orderByComparator);
1519
1520 if (assetVocabulary != null) {
1521 return assetVocabulary;
1522 }
1523
1524 StringBundler msg = new StringBundler(6);
1525
1526 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1527
1528 msg.append("uuid=");
1529 msg.append(uuid);
1530
1531 msg.append(", companyId=");
1532 msg.append(companyId);
1533
1534 msg.append(StringPool.CLOSE_CURLY_BRACE);
1535
1536 throw new NoSuchVocabularyException(msg.toString());
1537 }
1538
1539
1548 public AssetVocabulary fetchByUuid_C_Last(String uuid, long companyId,
1549 OrderByComparator orderByComparator) throws SystemException {
1550 int count = countByUuid_C(uuid, companyId);
1551
1552 List<AssetVocabulary> list = findByUuid_C(uuid, companyId, count - 1,
1553 count, orderByComparator);
1554
1555 if (!list.isEmpty()) {
1556 return list.get(0);
1557 }
1558
1559 return null;
1560 }
1561
1562
1573 public AssetVocabulary[] findByUuid_C_PrevAndNext(long vocabularyId,
1574 String uuid, long companyId, OrderByComparator orderByComparator)
1575 throws NoSuchVocabularyException, SystemException {
1576 AssetVocabulary assetVocabulary = findByPrimaryKey(vocabularyId);
1577
1578 Session session = null;
1579
1580 try {
1581 session = openSession();
1582
1583 AssetVocabulary[] array = new AssetVocabularyImpl[3];
1584
1585 array[0] = getByUuid_C_PrevAndNext(session, assetVocabulary, uuid,
1586 companyId, orderByComparator, true);
1587
1588 array[1] = assetVocabulary;
1589
1590 array[2] = getByUuid_C_PrevAndNext(session, assetVocabulary, uuid,
1591 companyId, orderByComparator, false);
1592
1593 return array;
1594 }
1595 catch (Exception e) {
1596 throw processException(e);
1597 }
1598 finally {
1599 closeSession(session);
1600 }
1601 }
1602
1603 protected AssetVocabulary getByUuid_C_PrevAndNext(Session session,
1604 AssetVocabulary assetVocabulary, String uuid, long companyId,
1605 OrderByComparator orderByComparator, boolean previous) {
1606 StringBundler query = null;
1607
1608 if (orderByComparator != null) {
1609 query = new StringBundler(6 +
1610 (orderByComparator.getOrderByFields().length * 6));
1611 }
1612 else {
1613 query = new StringBundler(3);
1614 }
1615
1616 query.append(_SQL_SELECT_ASSETVOCABULARY_WHERE);
1617
1618 if (uuid == null) {
1619 query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1620 }
1621 else {
1622 if (uuid.equals(StringPool.BLANK)) {
1623 query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1624 }
1625 else {
1626 query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1627 }
1628 }
1629
1630 query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1631
1632 if (orderByComparator != null) {
1633 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1634
1635 if (orderByConditionFields.length > 0) {
1636 query.append(WHERE_AND);
1637 }
1638
1639 for (int i = 0; i < orderByConditionFields.length; i++) {
1640 query.append(_ORDER_BY_ENTITY_ALIAS);
1641 query.append(orderByConditionFields[i]);
1642
1643 if ((i + 1) < orderByConditionFields.length) {
1644 if (orderByComparator.isAscending() ^ previous) {
1645 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1646 }
1647 else {
1648 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1649 }
1650 }
1651 else {
1652 if (orderByComparator.isAscending() ^ previous) {
1653 query.append(WHERE_GREATER_THAN);
1654 }
1655 else {
1656 query.append(WHERE_LESSER_THAN);
1657 }
1658 }
1659 }
1660
1661 query.append(ORDER_BY_CLAUSE);
1662
1663 String[] orderByFields = orderByComparator.getOrderByFields();
1664
1665 for (int i = 0; i < orderByFields.length; i++) {
1666 query.append(_ORDER_BY_ENTITY_ALIAS);
1667 query.append(orderByFields[i]);
1668
1669 if ((i + 1) < orderByFields.length) {
1670 if (orderByComparator.isAscending() ^ previous) {
1671 query.append(ORDER_BY_ASC_HAS_NEXT);
1672 }
1673 else {
1674 query.append(ORDER_BY_DESC_HAS_NEXT);
1675 }
1676 }
1677 else {
1678 if (orderByComparator.isAscending() ^ previous) {
1679 query.append(ORDER_BY_ASC);
1680 }
1681 else {
1682 query.append(ORDER_BY_DESC);
1683 }
1684 }
1685 }
1686 }
1687
1688 else {
1689 query.append(AssetVocabularyModelImpl.ORDER_BY_JPQL);
1690 }
1691
1692 String sql = query.toString();
1693
1694 Query q = session.createQuery(sql);
1695
1696 q.setFirstResult(0);
1697 q.setMaxResults(2);
1698
1699 QueryPos qPos = QueryPos.getInstance(q);
1700
1701 if (uuid != null) {
1702 qPos.add(uuid);
1703 }
1704
1705 qPos.add(companyId);
1706
1707 if (orderByComparator != null) {
1708 Object[] values = orderByComparator.getOrderByConditionValues(assetVocabulary);
1709
1710 for (Object value : values) {
1711 qPos.add(value);
1712 }
1713 }
1714
1715 List<AssetVocabulary> list = q.list();
1716
1717 if (list.size() == 2) {
1718 return list.get(1);
1719 }
1720 else {
1721 return null;
1722 }
1723 }
1724
1725
1732 public List<AssetVocabulary> findByGroupId(long groupId)
1733 throws SystemException {
1734 return findByGroupId(groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1735 }
1736
1737
1750 public List<AssetVocabulary> findByGroupId(long groupId, int start, int end)
1751 throws SystemException {
1752 return findByGroupId(groupId, start, end, null);
1753 }
1754
1755
1769 public List<AssetVocabulary> findByGroupId(long groupId, int start,
1770 int end, OrderByComparator orderByComparator) throws SystemException {
1771 FinderPath finderPath = null;
1772 Object[] finderArgs = null;
1773
1774 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1775 (orderByComparator == null)) {
1776 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID;
1777 finderArgs = new Object[] { groupId };
1778 }
1779 else {
1780 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID;
1781 finderArgs = new Object[] { groupId, start, end, orderByComparator };
1782 }
1783
1784 List<AssetVocabulary> list = (List<AssetVocabulary>)FinderCacheUtil.getResult(finderPath,
1785 finderArgs, this);
1786
1787 if ((list != null) && !list.isEmpty()) {
1788 for (AssetVocabulary assetVocabulary : list) {
1789 if ((groupId != assetVocabulary.getGroupId())) {
1790 list = null;
1791
1792 break;
1793 }
1794 }
1795 }
1796
1797 if (list == null) {
1798 StringBundler query = null;
1799
1800 if (orderByComparator != null) {
1801 query = new StringBundler(3 +
1802 (orderByComparator.getOrderByFields().length * 3));
1803 }
1804 else {
1805 query = new StringBundler(3);
1806 }
1807
1808 query.append(_SQL_SELECT_ASSETVOCABULARY_WHERE);
1809
1810 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1811
1812 if (orderByComparator != null) {
1813 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1814 orderByComparator);
1815 }
1816
1817 else {
1818 query.append(AssetVocabularyModelImpl.ORDER_BY_JPQL);
1819 }
1820
1821 String sql = query.toString();
1822
1823 Session session = null;
1824
1825 try {
1826 session = openSession();
1827
1828 Query q = session.createQuery(sql);
1829
1830 QueryPos qPos = QueryPos.getInstance(q);
1831
1832 qPos.add(groupId);
1833
1834 list = (List<AssetVocabulary>)QueryUtil.list(q, getDialect(),
1835 start, end);
1836 }
1837 catch (Exception e) {
1838 throw processException(e);
1839 }
1840 finally {
1841 if (list == null) {
1842 FinderCacheUtil.removeResult(finderPath, finderArgs);
1843 }
1844 else {
1845 cacheResult(list);
1846
1847 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1848 }
1849
1850 closeSession(session);
1851 }
1852 }
1853
1854 return list;
1855 }
1856
1857
1866 public AssetVocabulary findByGroupId_First(long groupId,
1867 OrderByComparator orderByComparator)
1868 throws NoSuchVocabularyException, SystemException {
1869 AssetVocabulary assetVocabulary = fetchByGroupId_First(groupId,
1870 orderByComparator);
1871
1872 if (assetVocabulary != null) {
1873 return assetVocabulary;
1874 }
1875
1876 StringBundler msg = new StringBundler(4);
1877
1878 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1879
1880 msg.append("groupId=");
1881 msg.append(groupId);
1882
1883 msg.append(StringPool.CLOSE_CURLY_BRACE);
1884
1885 throw new NoSuchVocabularyException(msg.toString());
1886 }
1887
1888
1896 public AssetVocabulary fetchByGroupId_First(long groupId,
1897 OrderByComparator orderByComparator) throws SystemException {
1898 List<AssetVocabulary> list = findByGroupId(groupId, 0, 1,
1899 orderByComparator);
1900
1901 if (!list.isEmpty()) {
1902 return list.get(0);
1903 }
1904
1905 return null;
1906 }
1907
1908
1917 public AssetVocabulary findByGroupId_Last(long groupId,
1918 OrderByComparator orderByComparator)
1919 throws NoSuchVocabularyException, SystemException {
1920 AssetVocabulary assetVocabulary = fetchByGroupId_Last(groupId,
1921 orderByComparator);
1922
1923 if (assetVocabulary != null) {
1924 return assetVocabulary;
1925 }
1926
1927 StringBundler msg = new StringBundler(4);
1928
1929 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1930
1931 msg.append("groupId=");
1932 msg.append(groupId);
1933
1934 msg.append(StringPool.CLOSE_CURLY_BRACE);
1935
1936 throw new NoSuchVocabularyException(msg.toString());
1937 }
1938
1939
1947 public AssetVocabulary fetchByGroupId_Last(long groupId,
1948 OrderByComparator orderByComparator) throws SystemException {
1949 int count = countByGroupId(groupId);
1950
1951 List<AssetVocabulary> list = findByGroupId(groupId, count - 1, count,
1952 orderByComparator);
1953
1954 if (!list.isEmpty()) {
1955 return list.get(0);
1956 }
1957
1958 return null;
1959 }
1960
1961
1971 public AssetVocabulary[] findByGroupId_PrevAndNext(long vocabularyId,
1972 long groupId, OrderByComparator orderByComparator)
1973 throws NoSuchVocabularyException, SystemException {
1974 AssetVocabulary assetVocabulary = findByPrimaryKey(vocabularyId);
1975
1976 Session session = null;
1977
1978 try {
1979 session = openSession();
1980
1981 AssetVocabulary[] array = new AssetVocabularyImpl[3];
1982
1983 array[0] = getByGroupId_PrevAndNext(session, assetVocabulary,
1984 groupId, orderByComparator, true);
1985
1986 array[1] = assetVocabulary;
1987
1988 array[2] = getByGroupId_PrevAndNext(session, assetVocabulary,
1989 groupId, orderByComparator, false);
1990
1991 return array;
1992 }
1993 catch (Exception e) {
1994 throw processException(e);
1995 }
1996 finally {
1997 closeSession(session);
1998 }
1999 }
2000
2001 protected AssetVocabulary getByGroupId_PrevAndNext(Session session,
2002 AssetVocabulary assetVocabulary, long groupId,
2003 OrderByComparator orderByComparator, boolean previous) {
2004 StringBundler query = null;
2005
2006 if (orderByComparator != null) {
2007 query = new StringBundler(6 +
2008 (orderByComparator.getOrderByFields().length * 6));
2009 }
2010 else {
2011 query = new StringBundler(3);
2012 }
2013
2014 query.append(_SQL_SELECT_ASSETVOCABULARY_WHERE);
2015
2016 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2017
2018 if (orderByComparator != null) {
2019 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2020
2021 if (orderByConditionFields.length > 0) {
2022 query.append(WHERE_AND);
2023 }
2024
2025 for (int i = 0; i < orderByConditionFields.length; i++) {
2026 query.append(_ORDER_BY_ENTITY_ALIAS);
2027 query.append(orderByConditionFields[i]);
2028
2029 if ((i + 1) < orderByConditionFields.length) {
2030 if (orderByComparator.isAscending() ^ previous) {
2031 query.append(WHERE_GREATER_THAN_HAS_NEXT);
2032 }
2033 else {
2034 query.append(WHERE_LESSER_THAN_HAS_NEXT);
2035 }
2036 }
2037 else {
2038 if (orderByComparator.isAscending() ^ previous) {
2039 query.append(WHERE_GREATER_THAN);
2040 }
2041 else {
2042 query.append(WHERE_LESSER_THAN);
2043 }
2044 }
2045 }
2046
2047 query.append(ORDER_BY_CLAUSE);
2048
2049 String[] orderByFields = orderByComparator.getOrderByFields();
2050
2051 for (int i = 0; i < orderByFields.length; i++) {
2052 query.append(_ORDER_BY_ENTITY_ALIAS);
2053 query.append(orderByFields[i]);
2054
2055 if ((i + 1) < orderByFields.length) {
2056 if (orderByComparator.isAscending() ^ previous) {
2057 query.append(ORDER_BY_ASC_HAS_NEXT);
2058 }
2059 else {
2060 query.append(ORDER_BY_DESC_HAS_NEXT);
2061 }
2062 }
2063 else {
2064 if (orderByComparator.isAscending() ^ previous) {
2065 query.append(ORDER_BY_ASC);
2066 }
2067 else {
2068 query.append(ORDER_BY_DESC);
2069 }
2070 }
2071 }
2072 }
2073
2074 else {
2075 query.append(AssetVocabularyModelImpl.ORDER_BY_JPQL);
2076 }
2077
2078 String sql = query.toString();
2079
2080 Query q = session.createQuery(sql);
2081
2082 q.setFirstResult(0);
2083 q.setMaxResults(2);
2084
2085 QueryPos qPos = QueryPos.getInstance(q);
2086
2087 qPos.add(groupId);
2088
2089 if (orderByComparator != null) {
2090 Object[] values = orderByComparator.getOrderByConditionValues(assetVocabulary);
2091
2092 for (Object value : values) {
2093 qPos.add(value);
2094 }
2095 }
2096
2097 List<AssetVocabulary> list = q.list();
2098
2099 if (list.size() == 2) {
2100 return list.get(1);
2101 }
2102 else {
2103 return null;
2104 }
2105 }
2106
2107
2114 public List<AssetVocabulary> filterFindByGroupId(long groupId)
2115 throws SystemException {
2116 return filterFindByGroupId(groupId, QueryUtil.ALL_POS,
2117 QueryUtil.ALL_POS, null);
2118 }
2119
2120
2133 public List<AssetVocabulary> filterFindByGroupId(long groupId, int start,
2134 int end) throws SystemException {
2135 return filterFindByGroupId(groupId, start, end, null);
2136 }
2137
2138
2152 public List<AssetVocabulary> filterFindByGroupId(long groupId, int start,
2153 int end, OrderByComparator orderByComparator) throws SystemException {
2154 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2155 return findByGroupId(groupId, start, end, orderByComparator);
2156 }
2157
2158 StringBundler query = null;
2159
2160 if (orderByComparator != null) {
2161 query = new StringBundler(3 +
2162 (orderByComparator.getOrderByFields().length * 3));
2163 }
2164 else {
2165 query = new StringBundler(3);
2166 }
2167
2168 if (getDB().isSupportsInlineDistinct()) {
2169 query.append(_FILTER_SQL_SELECT_ASSETVOCABULARY_WHERE);
2170 }
2171 else {
2172 query.append(_FILTER_SQL_SELECT_ASSETVOCABULARY_NO_INLINE_DISTINCT_WHERE_1);
2173 }
2174
2175 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2176
2177 if (!getDB().isSupportsInlineDistinct()) {
2178 query.append(_FILTER_SQL_SELECT_ASSETVOCABULARY_NO_INLINE_DISTINCT_WHERE_2);
2179 }
2180
2181 if (orderByComparator != null) {
2182 if (getDB().isSupportsInlineDistinct()) {
2183 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2184 orderByComparator);
2185 }
2186 else {
2187 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
2188 orderByComparator);
2189 }
2190 }
2191
2192 else {
2193 if (getDB().isSupportsInlineDistinct()) {
2194 query.append(AssetVocabularyModelImpl.ORDER_BY_JPQL);
2195 }
2196 else {
2197 query.append(AssetVocabularyModelImpl.ORDER_BY_SQL);
2198 }
2199 }
2200
2201 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2202 AssetVocabulary.class.getName(),
2203 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2204
2205 Session session = null;
2206
2207 try {
2208 session = openSession();
2209
2210 SQLQuery q = session.createSQLQuery(sql);
2211
2212 if (getDB().isSupportsInlineDistinct()) {
2213 q.addEntity(_FILTER_ENTITY_ALIAS, AssetVocabularyImpl.class);
2214 }
2215 else {
2216 q.addEntity(_FILTER_ENTITY_TABLE, AssetVocabularyImpl.class);
2217 }
2218
2219 QueryPos qPos = QueryPos.getInstance(q);
2220
2221 qPos.add(groupId);
2222
2223 return (List<AssetVocabulary>)QueryUtil.list(q, getDialect(),
2224 start, end);
2225 }
2226 catch (Exception e) {
2227 throw processException(e);
2228 }
2229 finally {
2230 closeSession(session);
2231 }
2232 }
2233
2234
2244 public AssetVocabulary[] filterFindByGroupId_PrevAndNext(
2245 long vocabularyId, long groupId, OrderByComparator orderByComparator)
2246 throws NoSuchVocabularyException, SystemException {
2247 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2248 return findByGroupId_PrevAndNext(vocabularyId, groupId,
2249 orderByComparator);
2250 }
2251
2252 AssetVocabulary assetVocabulary = findByPrimaryKey(vocabularyId);
2253
2254 Session session = null;
2255
2256 try {
2257 session = openSession();
2258
2259 AssetVocabulary[] array = new AssetVocabularyImpl[3];
2260
2261 array[0] = filterGetByGroupId_PrevAndNext(session, assetVocabulary,
2262 groupId, orderByComparator, true);
2263
2264 array[1] = assetVocabulary;
2265
2266 array[2] = filterGetByGroupId_PrevAndNext(session, assetVocabulary,
2267 groupId, orderByComparator, false);
2268
2269 return array;
2270 }
2271 catch (Exception e) {
2272 throw processException(e);
2273 }
2274 finally {
2275 closeSession(session);
2276 }
2277 }
2278
2279 protected AssetVocabulary filterGetByGroupId_PrevAndNext(Session session,
2280 AssetVocabulary assetVocabulary, long groupId,
2281 OrderByComparator orderByComparator, boolean previous) {
2282 StringBundler query = null;
2283
2284 if (orderByComparator != null) {
2285 query = new StringBundler(6 +
2286 (orderByComparator.getOrderByFields().length * 6));
2287 }
2288 else {
2289 query = new StringBundler(3);
2290 }
2291
2292 if (getDB().isSupportsInlineDistinct()) {
2293 query.append(_FILTER_SQL_SELECT_ASSETVOCABULARY_WHERE);
2294 }
2295 else {
2296 query.append(_FILTER_SQL_SELECT_ASSETVOCABULARY_NO_INLINE_DISTINCT_WHERE_1);
2297 }
2298
2299 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2300
2301 if (!getDB().isSupportsInlineDistinct()) {
2302 query.append(_FILTER_SQL_SELECT_ASSETVOCABULARY_NO_INLINE_DISTINCT_WHERE_2);
2303 }
2304
2305 if (orderByComparator != null) {
2306 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2307
2308 if (orderByConditionFields.length > 0) {
2309 query.append(WHERE_AND);
2310 }
2311
2312 for (int i = 0; i < orderByConditionFields.length; i++) {
2313 if (getDB().isSupportsInlineDistinct()) {
2314 query.append(_ORDER_BY_ENTITY_ALIAS);
2315 }
2316 else {
2317 query.append(_ORDER_BY_ENTITY_TABLE);
2318 }
2319
2320 query.append(orderByConditionFields[i]);
2321
2322 if ((i + 1) < orderByConditionFields.length) {
2323 if (orderByComparator.isAscending() ^ previous) {
2324 query.append(WHERE_GREATER_THAN_HAS_NEXT);
2325 }
2326 else {
2327 query.append(WHERE_LESSER_THAN_HAS_NEXT);
2328 }
2329 }
2330 else {
2331 if (orderByComparator.isAscending() ^ previous) {
2332 query.append(WHERE_GREATER_THAN);
2333 }
2334 else {
2335 query.append(WHERE_LESSER_THAN);
2336 }
2337 }
2338 }
2339
2340 query.append(ORDER_BY_CLAUSE);
2341
2342 String[] orderByFields = orderByComparator.getOrderByFields();
2343
2344 for (int i = 0; i < orderByFields.length; i++) {
2345 if (getDB().isSupportsInlineDistinct()) {
2346 query.append(_ORDER_BY_ENTITY_ALIAS);
2347 }
2348 else {
2349 query.append(_ORDER_BY_ENTITY_TABLE);
2350 }
2351
2352 query.append(orderByFields[i]);
2353
2354 if ((i + 1) < orderByFields.length) {
2355 if (orderByComparator.isAscending() ^ previous) {
2356 query.append(ORDER_BY_ASC_HAS_NEXT);
2357 }
2358 else {
2359 query.append(ORDER_BY_DESC_HAS_NEXT);
2360 }
2361 }
2362 else {
2363 if (orderByComparator.isAscending() ^ previous) {
2364 query.append(ORDER_BY_ASC);
2365 }
2366 else {
2367 query.append(ORDER_BY_DESC);
2368 }
2369 }
2370 }
2371 }
2372
2373 else {
2374 if (getDB().isSupportsInlineDistinct()) {
2375 query.append(AssetVocabularyModelImpl.ORDER_BY_JPQL);
2376 }
2377 else {
2378 query.append(AssetVocabularyModelImpl.ORDER_BY_SQL);
2379 }
2380 }
2381
2382 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2383 AssetVocabulary.class.getName(),
2384 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2385
2386 SQLQuery q = session.createSQLQuery(sql);
2387
2388 q.setFirstResult(0);
2389 q.setMaxResults(2);
2390
2391 if (getDB().isSupportsInlineDistinct()) {
2392 q.addEntity(_FILTER_ENTITY_ALIAS, AssetVocabularyImpl.class);
2393 }
2394 else {
2395 q.addEntity(_FILTER_ENTITY_TABLE, AssetVocabularyImpl.class);
2396 }
2397
2398 QueryPos qPos = QueryPos.getInstance(q);
2399
2400 qPos.add(groupId);
2401
2402 if (orderByComparator != null) {
2403 Object[] values = orderByComparator.getOrderByConditionValues(assetVocabulary);
2404
2405 for (Object value : values) {
2406 qPos.add(value);
2407 }
2408 }
2409
2410 List<AssetVocabulary> list = q.list();
2411
2412 if (list.size() == 2) {
2413 return list.get(1);
2414 }
2415 else {
2416 return null;
2417 }
2418 }
2419
2420
2427 public List<AssetVocabulary> findByCompanyId(long companyId)
2428 throws SystemException {
2429 return findByCompanyId(companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
2430 null);
2431 }
2432
2433
2446 public List<AssetVocabulary> findByCompanyId(long companyId, int start,
2447 int end) throws SystemException {
2448 return findByCompanyId(companyId, start, end, null);
2449 }
2450
2451
2465 public List<AssetVocabulary> findByCompanyId(long companyId, int start,
2466 int end, OrderByComparator orderByComparator) throws SystemException {
2467 FinderPath finderPath = null;
2468 Object[] finderArgs = null;
2469
2470 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2471 (orderByComparator == null)) {
2472 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID;
2473 finderArgs = new Object[] { companyId };
2474 }
2475 else {
2476 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID;
2477 finderArgs = new Object[] { companyId, start, end, orderByComparator };
2478 }
2479
2480 List<AssetVocabulary> list = (List<AssetVocabulary>)FinderCacheUtil.getResult(finderPath,
2481 finderArgs, this);
2482
2483 if ((list != null) && !list.isEmpty()) {
2484 for (AssetVocabulary assetVocabulary : list) {
2485 if ((companyId != assetVocabulary.getCompanyId())) {
2486 list = null;
2487
2488 break;
2489 }
2490 }
2491 }
2492
2493 if (list == null) {
2494 StringBundler query = null;
2495
2496 if (orderByComparator != null) {
2497 query = new StringBundler(3 +
2498 (orderByComparator.getOrderByFields().length * 3));
2499 }
2500 else {
2501 query = new StringBundler(3);
2502 }
2503
2504 query.append(_SQL_SELECT_ASSETVOCABULARY_WHERE);
2505
2506 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
2507
2508 if (orderByComparator != null) {
2509 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2510 orderByComparator);
2511 }
2512
2513 else {
2514 query.append(AssetVocabularyModelImpl.ORDER_BY_JPQL);
2515 }
2516
2517 String sql = query.toString();
2518
2519 Session session = null;
2520
2521 try {
2522 session = openSession();
2523
2524 Query q = session.createQuery(sql);
2525
2526 QueryPos qPos = QueryPos.getInstance(q);
2527
2528 qPos.add(companyId);
2529
2530 list = (List<AssetVocabulary>)QueryUtil.list(q, getDialect(),
2531 start, end);
2532 }
2533 catch (Exception e) {
2534 throw processException(e);
2535 }
2536 finally {
2537 if (list == null) {
2538 FinderCacheUtil.removeResult(finderPath, finderArgs);
2539 }
2540 else {
2541 cacheResult(list);
2542
2543 FinderCacheUtil.putResult(finderPath, finderArgs, list);
2544 }
2545
2546 closeSession(session);
2547 }
2548 }
2549
2550 return list;
2551 }
2552
2553
2562 public AssetVocabulary findByCompanyId_First(long companyId,
2563 OrderByComparator orderByComparator)
2564 throws NoSuchVocabularyException, SystemException {
2565 AssetVocabulary assetVocabulary = fetchByCompanyId_First(companyId,
2566 orderByComparator);
2567
2568 if (assetVocabulary != null) {
2569 return assetVocabulary;
2570 }
2571
2572 StringBundler msg = new StringBundler(4);
2573
2574 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2575
2576 msg.append("companyId=");
2577 msg.append(companyId);
2578
2579 msg.append(StringPool.CLOSE_CURLY_BRACE);
2580
2581 throw new NoSuchVocabularyException(msg.toString());
2582 }
2583
2584
2592 public AssetVocabulary fetchByCompanyId_First(long companyId,
2593 OrderByComparator orderByComparator) throws SystemException {
2594 List<AssetVocabulary> list = findByCompanyId(companyId, 0, 1,
2595 orderByComparator);
2596
2597 if (!list.isEmpty()) {
2598 return list.get(0);
2599 }
2600
2601 return null;
2602 }
2603
2604
2613 public AssetVocabulary findByCompanyId_Last(long companyId,
2614 OrderByComparator orderByComparator)
2615 throws NoSuchVocabularyException, SystemException {
2616 AssetVocabulary assetVocabulary = fetchByCompanyId_Last(companyId,
2617 orderByComparator);
2618
2619 if (assetVocabulary != null) {
2620 return assetVocabulary;
2621 }
2622
2623 StringBundler msg = new StringBundler(4);
2624
2625 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2626
2627 msg.append("companyId=");
2628 msg.append(companyId);
2629
2630 msg.append(StringPool.CLOSE_CURLY_BRACE);
2631
2632 throw new NoSuchVocabularyException(msg.toString());
2633 }
2634
2635
2643 public AssetVocabulary fetchByCompanyId_Last(long companyId,
2644 OrderByComparator orderByComparator) throws SystemException {
2645 int count = countByCompanyId(companyId);
2646
2647 List<AssetVocabulary> list = findByCompanyId(companyId, count - 1,
2648 count, orderByComparator);
2649
2650 if (!list.isEmpty()) {
2651 return list.get(0);
2652 }
2653
2654 return null;
2655 }
2656
2657
2667 public AssetVocabulary[] findByCompanyId_PrevAndNext(long vocabularyId,
2668 long companyId, OrderByComparator orderByComparator)
2669 throws NoSuchVocabularyException, SystemException {
2670 AssetVocabulary assetVocabulary = findByPrimaryKey(vocabularyId);
2671
2672 Session session = null;
2673
2674 try {
2675 session = openSession();
2676
2677 AssetVocabulary[] array = new AssetVocabularyImpl[3];
2678
2679 array[0] = getByCompanyId_PrevAndNext(session, assetVocabulary,
2680 companyId, orderByComparator, true);
2681
2682 array[1] = assetVocabulary;
2683
2684 array[2] = getByCompanyId_PrevAndNext(session, assetVocabulary,
2685 companyId, orderByComparator, false);
2686
2687 return array;
2688 }
2689 catch (Exception e) {
2690 throw processException(e);
2691 }
2692 finally {
2693 closeSession(session);
2694 }
2695 }
2696
2697 protected AssetVocabulary getByCompanyId_PrevAndNext(Session session,
2698 AssetVocabulary assetVocabulary, long companyId,
2699 OrderByComparator orderByComparator, boolean previous) {
2700 StringBundler query = null;
2701
2702 if (orderByComparator != null) {
2703 query = new StringBundler(6 +
2704 (orderByComparator.getOrderByFields().length * 6));
2705 }
2706 else {
2707 query = new StringBundler(3);
2708 }
2709
2710 query.append(_SQL_SELECT_ASSETVOCABULARY_WHERE);
2711
2712 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
2713
2714 if (orderByComparator != null) {
2715 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2716
2717 if (orderByConditionFields.length > 0) {
2718 query.append(WHERE_AND);
2719 }
2720
2721 for (int i = 0; i < orderByConditionFields.length; i++) {
2722 query.append(_ORDER_BY_ENTITY_ALIAS);
2723 query.append(orderByConditionFields[i]);
2724
2725 if ((i + 1) < orderByConditionFields.length) {
2726 if (orderByComparator.isAscending() ^ previous) {
2727 query.append(WHERE_GREATER_THAN_HAS_NEXT);
2728 }
2729 else {
2730 query.append(WHERE_LESSER_THAN_HAS_NEXT);
2731 }
2732 }
2733 else {
2734 if (orderByComparator.isAscending() ^ previous) {
2735 query.append(WHERE_GREATER_THAN);
2736 }
2737 else {
2738 query.append(WHERE_LESSER_THAN);
2739 }
2740 }
2741 }
2742
2743 query.append(ORDER_BY_CLAUSE);
2744
2745 String[] orderByFields = orderByComparator.getOrderByFields();
2746
2747 for (int i = 0; i < orderByFields.length; i++) {
2748 query.append(_ORDER_BY_ENTITY_ALIAS);
2749 query.append(orderByFields[i]);
2750
2751 if ((i + 1) < orderByFields.length) {
2752 if (orderByComparator.isAscending() ^ previous) {
2753 query.append(ORDER_BY_ASC_HAS_NEXT);
2754 }
2755 else {
2756 query.append(ORDER_BY_DESC_HAS_NEXT);
2757 }
2758 }
2759 else {
2760 if (orderByComparator.isAscending() ^ previous) {
2761 query.append(ORDER_BY_ASC);
2762 }
2763 else {
2764 query.append(ORDER_BY_DESC);
2765 }
2766 }
2767 }
2768 }
2769
2770 else {
2771 query.append(AssetVocabularyModelImpl.ORDER_BY_JPQL);
2772 }
2773
2774 String sql = query.toString();
2775
2776 Query q = session.createQuery(sql);
2777
2778 q.setFirstResult(0);
2779 q.setMaxResults(2);
2780
2781 QueryPos qPos = QueryPos.getInstance(q);
2782
2783 qPos.add(companyId);
2784
2785 if (orderByComparator != null) {
2786 Object[] values = orderByComparator.getOrderByConditionValues(assetVocabulary);
2787
2788 for (Object value : values) {
2789 qPos.add(value);
2790 }
2791 }
2792
2793 List<AssetVocabulary> list = q.list();
2794
2795 if (list.size() == 2) {
2796 return list.get(1);
2797 }
2798 else {
2799 return null;
2800 }
2801 }
2802
2803
2812 public AssetVocabulary findByG_N(long groupId, String name)
2813 throws NoSuchVocabularyException, SystemException {
2814 AssetVocabulary assetVocabulary = fetchByG_N(groupId, name);
2815
2816 if (assetVocabulary == null) {
2817 StringBundler msg = new StringBundler(6);
2818
2819 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2820
2821 msg.append("groupId=");
2822 msg.append(groupId);
2823
2824 msg.append(", name=");
2825 msg.append(name);
2826
2827 msg.append(StringPool.CLOSE_CURLY_BRACE);
2828
2829 if (_log.isWarnEnabled()) {
2830 _log.warn(msg.toString());
2831 }
2832
2833 throw new NoSuchVocabularyException(msg.toString());
2834 }
2835
2836 return assetVocabulary;
2837 }
2838
2839
2847 public AssetVocabulary fetchByG_N(long groupId, String name)
2848 throws SystemException {
2849 return fetchByG_N(groupId, name, true);
2850 }
2851
2852
2861 public AssetVocabulary fetchByG_N(long groupId, String name,
2862 boolean retrieveFromCache) throws SystemException {
2863 Object[] finderArgs = new Object[] { groupId, name };
2864
2865 Object result = null;
2866
2867 if (retrieveFromCache) {
2868 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_G_N,
2869 finderArgs, this);
2870 }
2871
2872 if (result instanceof AssetVocabulary) {
2873 AssetVocabulary assetVocabulary = (AssetVocabulary)result;
2874
2875 if ((groupId != assetVocabulary.getGroupId()) ||
2876 !Validator.equals(name, assetVocabulary.getName())) {
2877 result = null;
2878 }
2879 }
2880
2881 if (result == null) {
2882 StringBundler query = new StringBundler(4);
2883
2884 query.append(_SQL_SELECT_ASSETVOCABULARY_WHERE);
2885
2886 query.append(_FINDER_COLUMN_G_N_GROUPID_2);
2887
2888 if (name == null) {
2889 query.append(_FINDER_COLUMN_G_N_NAME_1);
2890 }
2891 else {
2892 if (name.equals(StringPool.BLANK)) {
2893 query.append(_FINDER_COLUMN_G_N_NAME_3);
2894 }
2895 else {
2896 query.append(_FINDER_COLUMN_G_N_NAME_2);
2897 }
2898 }
2899
2900 query.append(AssetVocabularyModelImpl.ORDER_BY_JPQL);
2901
2902 String sql = query.toString();
2903
2904 Session session = null;
2905
2906 try {
2907 session = openSession();
2908
2909 Query q = session.createQuery(sql);
2910
2911 QueryPos qPos = QueryPos.getInstance(q);
2912
2913 qPos.add(groupId);
2914
2915 if (name != null) {
2916 qPos.add(name);
2917 }
2918
2919 List<AssetVocabulary> list = q.list();
2920
2921 result = list;
2922
2923 AssetVocabulary assetVocabulary = null;
2924
2925 if (list.isEmpty()) {
2926 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_N,
2927 finderArgs, list);
2928 }
2929 else {
2930 assetVocabulary = list.get(0);
2931
2932 cacheResult(assetVocabulary);
2933
2934 if ((assetVocabulary.getGroupId() != groupId) ||
2935 (assetVocabulary.getName() == null) ||
2936 !assetVocabulary.getName().equals(name)) {
2937 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_N,
2938 finderArgs, assetVocabulary);
2939 }
2940 }
2941
2942 return assetVocabulary;
2943 }
2944 catch (Exception e) {
2945 throw processException(e);
2946 }
2947 finally {
2948 if (result == null) {
2949 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_N,
2950 finderArgs);
2951 }
2952
2953 closeSession(session);
2954 }
2955 }
2956 else {
2957 if (result instanceof List<?>) {
2958 return null;
2959 }
2960 else {
2961 return (AssetVocabulary)result;
2962 }
2963 }
2964 }
2965
2966
2972 public List<AssetVocabulary> findAll() throws SystemException {
2973 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
2974 }
2975
2976
2988 public List<AssetVocabulary> findAll(int start, int end)
2989 throws SystemException {
2990 return findAll(start, end, null);
2991 }
2992
2993
3006 public List<AssetVocabulary> findAll(int start, int end,
3007 OrderByComparator orderByComparator) throws SystemException {
3008 FinderPath finderPath = null;
3009 Object[] finderArgs = new Object[] { start, end, orderByComparator };
3010
3011 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
3012 (orderByComparator == null)) {
3013 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
3014 finderArgs = FINDER_ARGS_EMPTY;
3015 }
3016 else {
3017 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
3018 finderArgs = new Object[] { start, end, orderByComparator };
3019 }
3020
3021 List<AssetVocabulary> list = (List<AssetVocabulary>)FinderCacheUtil.getResult(finderPath,
3022 finderArgs, this);
3023
3024 if (list == null) {
3025 StringBundler query = null;
3026 String sql = null;
3027
3028 if (orderByComparator != null) {
3029 query = new StringBundler(2 +
3030 (orderByComparator.getOrderByFields().length * 3));
3031
3032 query.append(_SQL_SELECT_ASSETVOCABULARY);
3033
3034 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3035 orderByComparator);
3036
3037 sql = query.toString();
3038 }
3039 else {
3040 sql = _SQL_SELECT_ASSETVOCABULARY.concat(AssetVocabularyModelImpl.ORDER_BY_JPQL);
3041 }
3042
3043 Session session = null;
3044
3045 try {
3046 session = openSession();
3047
3048 Query q = session.createQuery(sql);
3049
3050 if (orderByComparator == null) {
3051 list = (List<AssetVocabulary>)QueryUtil.list(q,
3052 getDialect(), start, end, false);
3053
3054 Collections.sort(list);
3055 }
3056 else {
3057 list = (List<AssetVocabulary>)QueryUtil.list(q,
3058 getDialect(), start, end);
3059 }
3060 }
3061 catch (Exception e) {
3062 throw processException(e);
3063 }
3064 finally {
3065 if (list == null) {
3066 FinderCacheUtil.removeResult(finderPath, finderArgs);
3067 }
3068 else {
3069 cacheResult(list);
3070
3071 FinderCacheUtil.putResult(finderPath, finderArgs, list);
3072 }
3073
3074 closeSession(session);
3075 }
3076 }
3077
3078 return list;
3079 }
3080
3081
3087 public void removeByUuid(String uuid) throws SystemException {
3088 for (AssetVocabulary assetVocabulary : findByUuid(uuid)) {
3089 remove(assetVocabulary);
3090 }
3091 }
3092
3093
3101 public AssetVocabulary removeByUUID_G(String uuid, long groupId)
3102 throws NoSuchVocabularyException, SystemException {
3103 AssetVocabulary assetVocabulary = findByUUID_G(uuid, groupId);
3104
3105 return remove(assetVocabulary);
3106 }
3107
3108
3115 public void removeByUuid_C(String uuid, long companyId)
3116 throws SystemException {
3117 for (AssetVocabulary assetVocabulary : findByUuid_C(uuid, companyId)) {
3118 remove(assetVocabulary);
3119 }
3120 }
3121
3122
3128 public void removeByGroupId(long groupId) throws SystemException {
3129 for (AssetVocabulary assetVocabulary : findByGroupId(groupId)) {
3130 remove(assetVocabulary);
3131 }
3132 }
3133
3134
3140 public void removeByCompanyId(long companyId) throws SystemException {
3141 for (AssetVocabulary assetVocabulary : findByCompanyId(companyId)) {
3142 remove(assetVocabulary);
3143 }
3144 }
3145
3146
3154 public AssetVocabulary removeByG_N(long groupId, String name)
3155 throws NoSuchVocabularyException, SystemException {
3156 AssetVocabulary assetVocabulary = findByG_N(groupId, name);
3157
3158 return remove(assetVocabulary);
3159 }
3160
3161
3166 public void removeAll() throws SystemException {
3167 for (AssetVocabulary assetVocabulary : findAll()) {
3168 remove(assetVocabulary);
3169 }
3170 }
3171
3172
3179 public int countByUuid(String uuid) throws SystemException {
3180 Object[] finderArgs = new Object[] { uuid };
3181
3182 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID,
3183 finderArgs, this);
3184
3185 if (count == null) {
3186 StringBundler query = new StringBundler(2);
3187
3188 query.append(_SQL_COUNT_ASSETVOCABULARY_WHERE);
3189
3190 if (uuid == null) {
3191 query.append(_FINDER_COLUMN_UUID_UUID_1);
3192 }
3193 else {
3194 if (uuid.equals(StringPool.BLANK)) {
3195 query.append(_FINDER_COLUMN_UUID_UUID_3);
3196 }
3197 else {
3198 query.append(_FINDER_COLUMN_UUID_UUID_2);
3199 }
3200 }
3201
3202 String sql = query.toString();
3203
3204 Session session = null;
3205
3206 try {
3207 session = openSession();
3208
3209 Query q = session.createQuery(sql);
3210
3211 QueryPos qPos = QueryPos.getInstance(q);
3212
3213 if (uuid != null) {
3214 qPos.add(uuid);
3215 }
3216
3217 count = (Long)q.uniqueResult();
3218 }
3219 catch (Exception e) {
3220 throw processException(e);
3221 }
3222 finally {
3223 if (count == null) {
3224 count = Long.valueOf(0);
3225 }
3226
3227 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID,
3228 finderArgs, count);
3229
3230 closeSession(session);
3231 }
3232 }
3233
3234 return count.intValue();
3235 }
3236
3237
3245 public int countByUUID_G(String uuid, long groupId)
3246 throws SystemException {
3247 Object[] finderArgs = new Object[] { uuid, groupId };
3248
3249 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID_G,
3250 finderArgs, this);
3251
3252 if (count == null) {
3253 StringBundler query = new StringBundler(3);
3254
3255 query.append(_SQL_COUNT_ASSETVOCABULARY_WHERE);
3256
3257 if (uuid == null) {
3258 query.append(_FINDER_COLUMN_UUID_G_UUID_1);
3259 }
3260 else {
3261 if (uuid.equals(StringPool.BLANK)) {
3262 query.append(_FINDER_COLUMN_UUID_G_UUID_3);
3263 }
3264 else {
3265 query.append(_FINDER_COLUMN_UUID_G_UUID_2);
3266 }
3267 }
3268
3269 query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
3270
3271 String sql = query.toString();
3272
3273 Session session = null;
3274
3275 try {
3276 session = openSession();
3277
3278 Query q = session.createQuery(sql);
3279
3280 QueryPos qPos = QueryPos.getInstance(q);
3281
3282 if (uuid != null) {
3283 qPos.add(uuid);
3284 }
3285
3286 qPos.add(groupId);
3287
3288 count = (Long)q.uniqueResult();
3289 }
3290 catch (Exception e) {
3291 throw processException(e);
3292 }
3293 finally {
3294 if (count == null) {
3295 count = Long.valueOf(0);
3296 }
3297
3298 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G,
3299 finderArgs, count);
3300
3301 closeSession(session);
3302 }
3303 }
3304
3305 return count.intValue();
3306 }
3307
3308
3316 public int countByUuid_C(String uuid, long companyId)
3317 throws SystemException {
3318 Object[] finderArgs = new Object[] { uuid, companyId };
3319
3320 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID_C,
3321 finderArgs, this);
3322
3323 if (count == null) {
3324 StringBundler query = new StringBundler(3);
3325
3326 query.append(_SQL_COUNT_ASSETVOCABULARY_WHERE);
3327
3328 if (uuid == null) {
3329 query.append(_FINDER_COLUMN_UUID_C_UUID_1);
3330 }
3331 else {
3332 if (uuid.equals(StringPool.BLANK)) {
3333 query.append(_FINDER_COLUMN_UUID_C_UUID_3);
3334 }
3335 else {
3336 query.append(_FINDER_COLUMN_UUID_C_UUID_2);
3337 }
3338 }
3339
3340 query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
3341
3342 String sql = query.toString();
3343
3344 Session session = null;
3345
3346 try {
3347 session = openSession();
3348
3349 Query q = session.createQuery(sql);
3350
3351 QueryPos qPos = QueryPos.getInstance(q);
3352
3353 if (uuid != null) {
3354 qPos.add(uuid);
3355 }
3356
3357 qPos.add(companyId);
3358
3359 count = (Long)q.uniqueResult();
3360 }
3361 catch (Exception e) {
3362 throw processException(e);
3363 }
3364 finally {
3365 if (count == null) {
3366 count = Long.valueOf(0);
3367 }
3368
3369 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_C,
3370 finderArgs, count);
3371
3372 closeSession(session);
3373 }
3374 }
3375
3376 return count.intValue();
3377 }
3378
3379
3386 public int countByGroupId(long groupId) throws SystemException {
3387 Object[] finderArgs = new Object[] { groupId };
3388
3389 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_GROUPID,
3390 finderArgs, this);
3391
3392 if (count == null) {
3393 StringBundler query = new StringBundler(2);
3394
3395 query.append(_SQL_COUNT_ASSETVOCABULARY_WHERE);
3396
3397 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
3398
3399 String sql = query.toString();
3400
3401 Session session = null;
3402
3403 try {
3404 session = openSession();
3405
3406 Query q = session.createQuery(sql);
3407
3408 QueryPos qPos = QueryPos.getInstance(q);
3409
3410 qPos.add(groupId);
3411
3412 count = (Long)q.uniqueResult();
3413 }
3414 catch (Exception e) {
3415 throw processException(e);
3416 }
3417 finally {
3418 if (count == null) {
3419 count = Long.valueOf(0);
3420 }
3421
3422 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_GROUPID,
3423 finderArgs, count);
3424
3425 closeSession(session);
3426 }
3427 }
3428
3429 return count.intValue();
3430 }
3431
3432
3439 public int filterCountByGroupId(long groupId) throws SystemException {
3440 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
3441 return countByGroupId(groupId);
3442 }
3443
3444 StringBundler query = new StringBundler(2);
3445
3446 query.append(_FILTER_SQL_COUNT_ASSETVOCABULARY_WHERE);
3447
3448 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
3449
3450 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
3451 AssetVocabulary.class.getName(),
3452 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
3453
3454 Session session = null;
3455
3456 try {
3457 session = openSession();
3458
3459 SQLQuery q = session.createSQLQuery(sql);
3460
3461 q.addScalar(COUNT_COLUMN_NAME,
3462 com.liferay.portal.kernel.dao.orm.Type.LONG);
3463
3464 QueryPos qPos = QueryPos.getInstance(q);
3465
3466 qPos.add(groupId);
3467
3468 Long count = (Long)q.uniqueResult();
3469
3470 return count.intValue();
3471 }
3472 catch (Exception e) {
3473 throw processException(e);
3474 }
3475 finally {
3476 closeSession(session);
3477 }
3478 }
3479
3480
3487 public int countByCompanyId(long companyId) throws SystemException {
3488 Object[] finderArgs = new Object[] { companyId };
3489
3490 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_COMPANYID,
3491 finderArgs, this);
3492
3493 if (count == null) {
3494 StringBundler query = new StringBundler(2);
3495
3496 query.append(_SQL_COUNT_ASSETVOCABULARY_WHERE);
3497
3498 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
3499
3500 String sql = query.toString();
3501
3502 Session session = null;
3503
3504 try {
3505 session = openSession();
3506
3507 Query q = session.createQuery(sql);
3508
3509 QueryPos qPos = QueryPos.getInstance(q);
3510
3511 qPos.add(companyId);
3512
3513 count = (Long)q.uniqueResult();
3514 }
3515 catch (Exception e) {
3516 throw processException(e);
3517 }
3518 finally {
3519 if (count == null) {
3520 count = Long.valueOf(0);
3521 }
3522
3523 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_COMPANYID,
3524 finderArgs, count);
3525
3526 closeSession(session);
3527 }
3528 }
3529
3530 return count.intValue();
3531 }
3532
3533
3541 public int countByG_N(long groupId, String name) throws SystemException {
3542 Object[] finderArgs = new Object[] { groupId, name };
3543
3544 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_N,
3545 finderArgs, this);
3546
3547 if (count == null) {
3548 StringBundler query = new StringBundler(3);
3549
3550 query.append(_SQL_COUNT_ASSETVOCABULARY_WHERE);
3551
3552 query.append(_FINDER_COLUMN_G_N_GROUPID_2);
3553
3554 if (name == null) {
3555 query.append(_FINDER_COLUMN_G_N_NAME_1);
3556 }
3557 else {
3558 if (name.equals(StringPool.BLANK)) {
3559 query.append(_FINDER_COLUMN_G_N_NAME_3);
3560 }
3561 else {
3562 query.append(_FINDER_COLUMN_G_N_NAME_2);
3563 }
3564 }
3565
3566 String sql = query.toString();
3567
3568 Session session = null;
3569
3570 try {
3571 session = openSession();
3572
3573 Query q = session.createQuery(sql);
3574
3575 QueryPos qPos = QueryPos.getInstance(q);
3576
3577 qPos.add(groupId);
3578
3579 if (name != null) {
3580 qPos.add(name);
3581 }
3582
3583 count = (Long)q.uniqueResult();
3584 }
3585 catch (Exception e) {
3586 throw processException(e);
3587 }
3588 finally {
3589 if (count == null) {
3590 count = Long.valueOf(0);
3591 }
3592
3593 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_N, finderArgs,
3594 count);
3595
3596 closeSession(session);
3597 }
3598 }
3599
3600 return count.intValue();
3601 }
3602
3603
3609 public int countAll() throws SystemException {
3610 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
3611 FINDER_ARGS_EMPTY, this);
3612
3613 if (count == null) {
3614 Session session = null;
3615
3616 try {
3617 session = openSession();
3618
3619 Query q = session.createQuery(_SQL_COUNT_ASSETVOCABULARY);
3620
3621 count = (Long)q.uniqueResult();
3622 }
3623 catch (Exception e) {
3624 throw processException(e);
3625 }
3626 finally {
3627 if (count == null) {
3628 count = Long.valueOf(0);
3629 }
3630
3631 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
3632 FINDER_ARGS_EMPTY, count);
3633
3634 closeSession(session);
3635 }
3636 }
3637
3638 return count.intValue();
3639 }
3640
3641
3644 public void afterPropertiesSet() {
3645 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
3646 com.liferay.portal.util.PropsUtil.get(
3647 "value.object.listener.com.liferay.portlet.asset.model.AssetVocabulary")));
3648
3649 if (listenerClassNames.length > 0) {
3650 try {
3651 List<ModelListener<AssetVocabulary>> listenersList = new ArrayList<ModelListener<AssetVocabulary>>();
3652
3653 for (String listenerClassName : listenerClassNames) {
3654 listenersList.add((ModelListener<AssetVocabulary>)InstanceFactory.newInstance(
3655 listenerClassName));
3656 }
3657
3658 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
3659 }
3660 catch (Exception e) {
3661 _log.error(e);
3662 }
3663 }
3664 }
3665
3666 public void destroy() {
3667 EntityCacheUtil.removeCache(AssetVocabularyImpl.class.getName());
3668 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
3669 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
3670 }
3671
3672 @BeanReference(type = AssetCategoryPersistence.class)
3673 protected AssetCategoryPersistence assetCategoryPersistence;
3674 @BeanReference(type = AssetCategoryPropertyPersistence.class)
3675 protected AssetCategoryPropertyPersistence assetCategoryPropertyPersistence;
3676 @BeanReference(type = AssetEntryPersistence.class)
3677 protected AssetEntryPersistence assetEntryPersistence;
3678 @BeanReference(type = AssetLinkPersistence.class)
3679 protected AssetLinkPersistence assetLinkPersistence;
3680 @BeanReference(type = AssetTagPersistence.class)
3681 protected AssetTagPersistence assetTagPersistence;
3682 @BeanReference(type = AssetTagPropertyPersistence.class)
3683 protected AssetTagPropertyPersistence assetTagPropertyPersistence;
3684 @BeanReference(type = AssetTagStatsPersistence.class)
3685 protected AssetTagStatsPersistence assetTagStatsPersistence;
3686 @BeanReference(type = AssetVocabularyPersistence.class)
3687 protected AssetVocabularyPersistence assetVocabularyPersistence;
3688 @BeanReference(type = GroupPersistence.class)
3689 protected GroupPersistence groupPersistence;
3690 @BeanReference(type = UserPersistence.class)
3691 protected UserPersistence userPersistence;
3692 private static final String _SQL_SELECT_ASSETVOCABULARY = "SELECT assetVocabulary FROM AssetVocabulary assetVocabulary";
3693 private static final String _SQL_SELECT_ASSETVOCABULARY_WHERE = "SELECT assetVocabulary FROM AssetVocabulary assetVocabulary WHERE ";
3694 private static final String _SQL_COUNT_ASSETVOCABULARY = "SELECT COUNT(assetVocabulary) FROM AssetVocabulary assetVocabulary";
3695 private static final String _SQL_COUNT_ASSETVOCABULARY_WHERE = "SELECT COUNT(assetVocabulary) FROM AssetVocabulary assetVocabulary WHERE ";
3696 private static final String _FINDER_COLUMN_UUID_UUID_1 = "assetVocabulary.uuid IS NULL";
3697 private static final String _FINDER_COLUMN_UUID_UUID_2 = "assetVocabulary.uuid = ?";
3698 private static final String _FINDER_COLUMN_UUID_UUID_3 = "(assetVocabulary.uuid IS NULL OR assetVocabulary.uuid = ?)";
3699 private static final String _FINDER_COLUMN_UUID_G_UUID_1 = "assetVocabulary.uuid IS NULL AND ";
3700 private static final String _FINDER_COLUMN_UUID_G_UUID_2 = "assetVocabulary.uuid = ? AND ";
3701 private static final String _FINDER_COLUMN_UUID_G_UUID_3 = "(assetVocabulary.uuid IS NULL OR assetVocabulary.uuid = ?) AND ";
3702 private static final String _FINDER_COLUMN_UUID_G_GROUPID_2 = "assetVocabulary.groupId = ?";
3703 private static final String _FINDER_COLUMN_UUID_C_UUID_1 = "assetVocabulary.uuid IS NULL AND ";
3704 private static final String _FINDER_COLUMN_UUID_C_UUID_2 = "assetVocabulary.uuid = ? AND ";
3705 private static final String _FINDER_COLUMN_UUID_C_UUID_3 = "(assetVocabulary.uuid IS NULL OR assetVocabulary.uuid = ?) AND ";
3706 private static final String _FINDER_COLUMN_UUID_C_COMPANYID_2 = "assetVocabulary.companyId = ?";
3707 private static final String _FINDER_COLUMN_GROUPID_GROUPID_2 = "assetVocabulary.groupId = ?";
3708 private static final String _FINDER_COLUMN_COMPANYID_COMPANYID_2 = "assetVocabulary.companyId = ?";
3709 private static final String _FINDER_COLUMN_G_N_GROUPID_2 = "assetVocabulary.groupId = ? AND ";
3710 private static final String _FINDER_COLUMN_G_N_NAME_1 = "assetVocabulary.name IS NULL";
3711 private static final String _FINDER_COLUMN_G_N_NAME_2 = "assetVocabulary.name = ?";
3712 private static final String _FINDER_COLUMN_G_N_NAME_3 = "(assetVocabulary.name IS NULL OR assetVocabulary.name = ?)";
3713 private static final String _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN = "assetVocabulary.vocabularyId";
3714 private static final String _FILTER_SQL_SELECT_ASSETVOCABULARY_WHERE = "SELECT DISTINCT {assetVocabulary.*} FROM AssetVocabulary assetVocabulary WHERE ";
3715 private static final String _FILTER_SQL_SELECT_ASSETVOCABULARY_NO_INLINE_DISTINCT_WHERE_1 =
3716 "SELECT {AssetVocabulary.*} FROM (SELECT DISTINCT assetVocabulary.vocabularyId FROM AssetVocabulary assetVocabulary WHERE ";
3717 private static final String _FILTER_SQL_SELECT_ASSETVOCABULARY_NO_INLINE_DISTINCT_WHERE_2 =
3718 ") TEMP_TABLE INNER JOIN AssetVocabulary ON TEMP_TABLE.vocabularyId = AssetVocabulary.vocabularyId";
3719 private static final String _FILTER_SQL_COUNT_ASSETVOCABULARY_WHERE = "SELECT COUNT(DISTINCT assetVocabulary.vocabularyId) AS COUNT_VALUE FROM AssetVocabulary assetVocabulary WHERE ";
3720 private static final String _FILTER_ENTITY_ALIAS = "assetVocabulary";
3721 private static final String _FILTER_ENTITY_TABLE = "AssetVocabulary";
3722 private static final String _ORDER_BY_ENTITY_ALIAS = "assetVocabulary.";
3723 private static final String _ORDER_BY_ENTITY_TABLE = "AssetVocabulary.";
3724 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No AssetVocabulary exists with the primary key ";
3725 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No AssetVocabulary exists with the key {";
3726 private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
3727 private static Log _log = LogFactoryUtil.getLog(AssetVocabularyPersistenceImpl.class);
3728 private static AssetVocabulary _nullAssetVocabulary = new AssetVocabularyImpl() {
3729 @Override
3730 public Object clone() {
3731 return this;
3732 }
3733
3734 @Override
3735 public CacheModel<AssetVocabulary> toCacheModel() {
3736 return _nullAssetVocabularyCacheModel;
3737 }
3738 };
3739
3740 private static CacheModel<AssetVocabulary> _nullAssetVocabularyCacheModel = new CacheModel<AssetVocabulary>() {
3741 public AssetVocabulary toEntityModel() {
3742 return _nullAssetVocabulary;
3743 }
3744 };
3745 }