1
14
15 package com.liferay.portlet.asset.service.persistence;
16
17 import com.liferay.portal.NoSuchModelException;
18 import com.liferay.portal.kernel.annotation.BeanReference;
19 import com.liferay.portal.kernel.cache.CacheRegistry;
20 import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
21 import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
22 import com.liferay.portal.kernel.dao.orm.FinderPath;
23 import com.liferay.portal.kernel.dao.orm.Query;
24 import com.liferay.portal.kernel.dao.orm.QueryPos;
25 import com.liferay.portal.kernel.dao.orm.QueryUtil;
26 import com.liferay.portal.kernel.dao.orm.Session;
27 import com.liferay.portal.kernel.exception.SystemException;
28 import com.liferay.portal.kernel.log.Log;
29 import com.liferay.portal.kernel.log.LogFactoryUtil;
30 import com.liferay.portal.kernel.util.GetterUtil;
31 import com.liferay.portal.kernel.util.OrderByComparator;
32 import com.liferay.portal.kernel.util.StringBundler;
33 import com.liferay.portal.kernel.util.StringPool;
34 import com.liferay.portal.kernel.util.StringUtil;
35 import com.liferay.portal.kernel.util.Validator;
36 import com.liferay.portal.kernel.uuid.PortalUUIDUtil;
37 import com.liferay.portal.model.ModelListener;
38 import com.liferay.portal.service.persistence.BatchSessionUtil;
39 import com.liferay.portal.service.persistence.GroupPersistence;
40 import com.liferay.portal.service.persistence.ResourcePersistence;
41 import com.liferay.portal.service.persistence.UserPersistence;
42 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
43
44 import com.liferay.portlet.asset.NoSuchVocabularyException;
45 import com.liferay.portlet.asset.model.AssetVocabulary;
46 import com.liferay.portlet.asset.model.impl.AssetVocabularyImpl;
47 import com.liferay.portlet.asset.model.impl.AssetVocabularyModelImpl;
48
49 import java.io.Serializable;
50
51 import java.util.ArrayList;
52 import java.util.Collections;
53 import java.util.List;
54
55
68 public class AssetVocabularyPersistenceImpl extends BasePersistenceImpl<AssetVocabulary>
69 implements AssetVocabularyPersistence {
70 public static final String FINDER_CLASS_NAME_ENTITY = AssetVocabularyImpl.class.getName();
71 public static final String FINDER_CLASS_NAME_LIST = FINDER_CLASS_NAME_ENTITY +
72 ".List";
73 public static final FinderPath FINDER_PATH_FIND_BY_UUID = new FinderPath(AssetVocabularyModelImpl.ENTITY_CACHE_ENABLED,
74 AssetVocabularyModelImpl.FINDER_CACHE_ENABLED,
75 FINDER_CLASS_NAME_LIST, "findByUuid",
76 new String[] { String.class.getName() });
77 public static final FinderPath FINDER_PATH_FIND_BY_OBC_UUID = new FinderPath(AssetVocabularyModelImpl.ENTITY_CACHE_ENABLED,
78 AssetVocabularyModelImpl.FINDER_CACHE_ENABLED,
79 FINDER_CLASS_NAME_LIST, "findByUuid",
80 new String[] {
81 String.class.getName(),
82
83 "java.lang.Integer", "java.lang.Integer",
84 "com.liferay.portal.kernel.util.OrderByComparator"
85 });
86 public static final FinderPath FINDER_PATH_COUNT_BY_UUID = new FinderPath(AssetVocabularyModelImpl.ENTITY_CACHE_ENABLED,
87 AssetVocabularyModelImpl.FINDER_CACHE_ENABLED,
88 FINDER_CLASS_NAME_LIST, "countByUuid",
89 new String[] { String.class.getName() });
90 public static final FinderPath FINDER_PATH_FETCH_BY_UUID_G = new FinderPath(AssetVocabularyModelImpl.ENTITY_CACHE_ENABLED,
91 AssetVocabularyModelImpl.FINDER_CACHE_ENABLED,
92 FINDER_CLASS_NAME_ENTITY, "fetchByUUID_G",
93 new String[] { String.class.getName(), Long.class.getName() });
94 public static final FinderPath FINDER_PATH_COUNT_BY_UUID_G = new FinderPath(AssetVocabularyModelImpl.ENTITY_CACHE_ENABLED,
95 AssetVocabularyModelImpl.FINDER_CACHE_ENABLED,
96 FINDER_CLASS_NAME_LIST, "countByUUID_G",
97 new String[] { String.class.getName(), Long.class.getName() });
98 public static final FinderPath FINDER_PATH_FIND_BY_GROUPID = new FinderPath(AssetVocabularyModelImpl.ENTITY_CACHE_ENABLED,
99 AssetVocabularyModelImpl.FINDER_CACHE_ENABLED,
100 FINDER_CLASS_NAME_LIST, "findByGroupId",
101 new String[] { Long.class.getName() });
102 public static final FinderPath FINDER_PATH_FIND_BY_OBC_GROUPID = new FinderPath(AssetVocabularyModelImpl.ENTITY_CACHE_ENABLED,
103 AssetVocabularyModelImpl.FINDER_CACHE_ENABLED,
104 FINDER_CLASS_NAME_LIST, "findByGroupId",
105 new String[] {
106 Long.class.getName(),
107
108 "java.lang.Integer", "java.lang.Integer",
109 "com.liferay.portal.kernel.util.OrderByComparator"
110 });
111 public static final FinderPath FINDER_PATH_COUNT_BY_GROUPID = new FinderPath(AssetVocabularyModelImpl.ENTITY_CACHE_ENABLED,
112 AssetVocabularyModelImpl.FINDER_CACHE_ENABLED,
113 FINDER_CLASS_NAME_LIST, "countByGroupId",
114 new String[] { Long.class.getName() });
115 public static final FinderPath FINDER_PATH_FIND_BY_COMPANYID = new FinderPath(AssetVocabularyModelImpl.ENTITY_CACHE_ENABLED,
116 AssetVocabularyModelImpl.FINDER_CACHE_ENABLED,
117 FINDER_CLASS_NAME_LIST, "findByCompanyId",
118 new String[] { Long.class.getName() });
119 public static final FinderPath FINDER_PATH_FIND_BY_OBC_COMPANYID = new FinderPath(AssetVocabularyModelImpl.ENTITY_CACHE_ENABLED,
120 AssetVocabularyModelImpl.FINDER_CACHE_ENABLED,
121 FINDER_CLASS_NAME_LIST, "findByCompanyId",
122 new String[] {
123 Long.class.getName(),
124
125 "java.lang.Integer", "java.lang.Integer",
126 "com.liferay.portal.kernel.util.OrderByComparator"
127 });
128 public static final FinderPath FINDER_PATH_COUNT_BY_COMPANYID = new FinderPath(AssetVocabularyModelImpl.ENTITY_CACHE_ENABLED,
129 AssetVocabularyModelImpl.FINDER_CACHE_ENABLED,
130 FINDER_CLASS_NAME_LIST, "countByCompanyId",
131 new String[] { Long.class.getName() });
132 public static final FinderPath FINDER_PATH_FETCH_BY_G_N = new FinderPath(AssetVocabularyModelImpl.ENTITY_CACHE_ENABLED,
133 AssetVocabularyModelImpl.FINDER_CACHE_ENABLED,
134 FINDER_CLASS_NAME_ENTITY, "fetchByG_N",
135 new String[] { Long.class.getName(), String.class.getName() });
136 public static final FinderPath FINDER_PATH_COUNT_BY_G_N = new FinderPath(AssetVocabularyModelImpl.ENTITY_CACHE_ENABLED,
137 AssetVocabularyModelImpl.FINDER_CACHE_ENABLED,
138 FINDER_CLASS_NAME_LIST, "countByG_N",
139 new String[] { Long.class.getName(), String.class.getName() });
140 public static final FinderPath FINDER_PATH_FIND_ALL = new FinderPath(AssetVocabularyModelImpl.ENTITY_CACHE_ENABLED,
141 AssetVocabularyModelImpl.FINDER_CACHE_ENABLED,
142 FINDER_CLASS_NAME_LIST, "findAll", new String[0]);
143 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(AssetVocabularyModelImpl.ENTITY_CACHE_ENABLED,
144 AssetVocabularyModelImpl.FINDER_CACHE_ENABLED,
145 FINDER_CLASS_NAME_LIST, "countAll", new String[0]);
146
147 public void cacheResult(AssetVocabulary assetVocabulary) {
148 EntityCacheUtil.putResult(AssetVocabularyModelImpl.ENTITY_CACHE_ENABLED,
149 AssetVocabularyImpl.class, assetVocabulary.getPrimaryKey(),
150 assetVocabulary);
151
152 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
153 new Object[] {
154 assetVocabulary.getUuid(),
155 new Long(assetVocabulary.getGroupId())
156 }, assetVocabulary);
157
158 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_N,
159 new Object[] {
160 new Long(assetVocabulary.getGroupId()),
161
162 assetVocabulary.getName()
163 }, assetVocabulary);
164 }
165
166 public void cacheResult(List<AssetVocabulary> assetVocabularies) {
167 for (AssetVocabulary assetVocabulary : assetVocabularies) {
168 if (EntityCacheUtil.getResult(
169 AssetVocabularyModelImpl.ENTITY_CACHE_ENABLED,
170 AssetVocabularyImpl.class,
171 assetVocabulary.getPrimaryKey(), this) == null) {
172 cacheResult(assetVocabulary);
173 }
174 }
175 }
176
177 public void clearCache() {
178 CacheRegistry.clear(AssetVocabularyImpl.class.getName());
179 EntityCacheUtil.clearCache(AssetVocabularyImpl.class.getName());
180 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
181 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
182 }
183
184 public AssetVocabulary create(long vocabularyId) {
185 AssetVocabulary assetVocabulary = new AssetVocabularyImpl();
186
187 assetVocabulary.setNew(true);
188 assetVocabulary.setPrimaryKey(vocabularyId);
189
190 String uuid = PortalUUIDUtil.generate();
191
192 assetVocabulary.setUuid(uuid);
193
194 return assetVocabulary;
195 }
196
197 public AssetVocabulary remove(Serializable primaryKey)
198 throws NoSuchModelException, SystemException {
199 return remove(((Long)primaryKey).longValue());
200 }
201
202 public AssetVocabulary remove(long vocabularyId)
203 throws NoSuchVocabularyException, SystemException {
204 Session session = null;
205
206 try {
207 session = openSession();
208
209 AssetVocabulary assetVocabulary = (AssetVocabulary)session.get(AssetVocabularyImpl.class,
210 new Long(vocabularyId));
211
212 if (assetVocabulary == null) {
213 if (_log.isWarnEnabled()) {
214 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + vocabularyId);
215 }
216
217 throw new NoSuchVocabularyException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
218 vocabularyId);
219 }
220
221 return remove(assetVocabulary);
222 }
223 catch (NoSuchVocabularyException nsee) {
224 throw nsee;
225 }
226 catch (Exception e) {
227 throw processException(e);
228 }
229 finally {
230 closeSession(session);
231 }
232 }
233
234 public AssetVocabulary remove(AssetVocabulary assetVocabulary)
235 throws SystemException {
236 for (ModelListener<AssetVocabulary> listener : listeners) {
237 listener.onBeforeRemove(assetVocabulary);
238 }
239
240 assetVocabulary = removeImpl(assetVocabulary);
241
242 for (ModelListener<AssetVocabulary> listener : listeners) {
243 listener.onAfterRemove(assetVocabulary);
244 }
245
246 return assetVocabulary;
247 }
248
249 protected AssetVocabulary removeImpl(AssetVocabulary assetVocabulary)
250 throws SystemException {
251 assetVocabulary = toUnwrappedModel(assetVocabulary);
252
253 Session session = null;
254
255 try {
256 session = openSession();
257
258 if (assetVocabulary.isCachedModel() ||
259 BatchSessionUtil.isEnabled()) {
260 Object staleObject = session.get(AssetVocabularyImpl.class,
261 assetVocabulary.getPrimaryKeyObj());
262
263 if (staleObject != null) {
264 session.evict(staleObject);
265 }
266 }
267
268 session.delete(assetVocabulary);
269
270 session.flush();
271 }
272 catch (Exception e) {
273 throw processException(e);
274 }
275 finally {
276 closeSession(session);
277 }
278
279 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
280
281 AssetVocabularyModelImpl assetVocabularyModelImpl = (AssetVocabularyModelImpl)assetVocabulary;
282
283 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
284 new Object[] {
285 assetVocabularyModelImpl.getOriginalUuid(),
286 new Long(assetVocabularyModelImpl.getOriginalGroupId())
287 });
288
289 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_N,
290 new Object[] {
291 new Long(assetVocabularyModelImpl.getOriginalGroupId()),
292
293 assetVocabularyModelImpl.getOriginalName()
294 });
295
296 EntityCacheUtil.removeResult(AssetVocabularyModelImpl.ENTITY_CACHE_ENABLED,
297 AssetVocabularyImpl.class, assetVocabulary.getPrimaryKey());
298
299 return assetVocabulary;
300 }
301
302 public AssetVocabulary updateImpl(
303 com.liferay.portlet.asset.model.AssetVocabulary assetVocabulary,
304 boolean merge) throws SystemException {
305 assetVocabulary = toUnwrappedModel(assetVocabulary);
306
307 boolean isNew = assetVocabulary.isNew();
308
309 AssetVocabularyModelImpl assetVocabularyModelImpl = (AssetVocabularyModelImpl)assetVocabulary;
310
311 if (Validator.isNull(assetVocabulary.getUuid())) {
312 String uuid = PortalUUIDUtil.generate();
313
314 assetVocabulary.setUuid(uuid);
315 }
316
317 Session session = null;
318
319 try {
320 session = openSession();
321
322 BatchSessionUtil.update(session, assetVocabulary, merge);
323
324 assetVocabulary.setNew(false);
325 }
326 catch (Exception e) {
327 throw processException(e);
328 }
329 finally {
330 closeSession(session);
331 }
332
333 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
334
335 EntityCacheUtil.putResult(AssetVocabularyModelImpl.ENTITY_CACHE_ENABLED,
336 AssetVocabularyImpl.class, assetVocabulary.getPrimaryKey(),
337 assetVocabulary);
338
339 if (!isNew &&
340 (!Validator.equals(assetVocabulary.getUuid(),
341 assetVocabularyModelImpl.getOriginalUuid()) ||
342 (assetVocabulary.getGroupId() != assetVocabularyModelImpl.getOriginalGroupId()))) {
343 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
344 new Object[] {
345 assetVocabularyModelImpl.getOriginalUuid(),
346 new Long(assetVocabularyModelImpl.getOriginalGroupId())
347 });
348 }
349
350 if (isNew ||
351 (!Validator.equals(assetVocabulary.getUuid(),
352 assetVocabularyModelImpl.getOriginalUuid()) ||
353 (assetVocabulary.getGroupId() != assetVocabularyModelImpl.getOriginalGroupId()))) {
354 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
355 new Object[] {
356 assetVocabulary.getUuid(),
357 new Long(assetVocabulary.getGroupId())
358 }, assetVocabulary);
359 }
360
361 if (!isNew &&
362 ((assetVocabulary.getGroupId() != assetVocabularyModelImpl.getOriginalGroupId()) ||
363 !Validator.equals(assetVocabulary.getName(),
364 assetVocabularyModelImpl.getOriginalName()))) {
365 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_N,
366 new Object[] {
367 new Long(assetVocabularyModelImpl.getOriginalGroupId()),
368
369 assetVocabularyModelImpl.getOriginalName()
370 });
371 }
372
373 if (isNew ||
374 ((assetVocabulary.getGroupId() != assetVocabularyModelImpl.getOriginalGroupId()) ||
375 !Validator.equals(assetVocabulary.getName(),
376 assetVocabularyModelImpl.getOriginalName()))) {
377 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_N,
378 new Object[] {
379 new Long(assetVocabulary.getGroupId()),
380
381 assetVocabulary.getName()
382 }, assetVocabulary);
383 }
384
385 return assetVocabulary;
386 }
387
388 protected AssetVocabulary toUnwrappedModel(AssetVocabulary assetVocabulary) {
389 if (assetVocabulary instanceof AssetVocabularyImpl) {
390 return assetVocabulary;
391 }
392
393 AssetVocabularyImpl assetVocabularyImpl = new AssetVocabularyImpl();
394
395 assetVocabularyImpl.setNew(assetVocabulary.isNew());
396 assetVocabularyImpl.setPrimaryKey(assetVocabulary.getPrimaryKey());
397
398 assetVocabularyImpl.setUuid(assetVocabulary.getUuid());
399 assetVocabularyImpl.setVocabularyId(assetVocabulary.getVocabularyId());
400 assetVocabularyImpl.setGroupId(assetVocabulary.getGroupId());
401 assetVocabularyImpl.setCompanyId(assetVocabulary.getCompanyId());
402 assetVocabularyImpl.setUserId(assetVocabulary.getUserId());
403 assetVocabularyImpl.setUserName(assetVocabulary.getUserName());
404 assetVocabularyImpl.setCreateDate(assetVocabulary.getCreateDate());
405 assetVocabularyImpl.setModifiedDate(assetVocabulary.getModifiedDate());
406 assetVocabularyImpl.setName(assetVocabulary.getName());
407 assetVocabularyImpl.setTitle(assetVocabulary.getTitle());
408 assetVocabularyImpl.setDescription(assetVocabulary.getDescription());
409 assetVocabularyImpl.setSettings(assetVocabulary.getSettings());
410
411 return assetVocabularyImpl;
412 }
413
414 public AssetVocabulary findByPrimaryKey(Serializable primaryKey)
415 throws NoSuchModelException, SystemException {
416 return findByPrimaryKey(((Long)primaryKey).longValue());
417 }
418
419 public AssetVocabulary findByPrimaryKey(long vocabularyId)
420 throws NoSuchVocabularyException, SystemException {
421 AssetVocabulary assetVocabulary = fetchByPrimaryKey(vocabularyId);
422
423 if (assetVocabulary == null) {
424 if (_log.isWarnEnabled()) {
425 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + vocabularyId);
426 }
427
428 throw new NoSuchVocabularyException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
429 vocabularyId);
430 }
431
432 return assetVocabulary;
433 }
434
435 public AssetVocabulary fetchByPrimaryKey(Serializable primaryKey)
436 throws SystemException {
437 return fetchByPrimaryKey(((Long)primaryKey).longValue());
438 }
439
440 public AssetVocabulary fetchByPrimaryKey(long vocabularyId)
441 throws SystemException {
442 AssetVocabulary assetVocabulary = (AssetVocabulary)EntityCacheUtil.getResult(AssetVocabularyModelImpl.ENTITY_CACHE_ENABLED,
443 AssetVocabularyImpl.class, vocabularyId, this);
444
445 if (assetVocabulary == null) {
446 Session session = null;
447
448 try {
449 session = openSession();
450
451 assetVocabulary = (AssetVocabulary)session.get(AssetVocabularyImpl.class,
452 new Long(vocabularyId));
453 }
454 catch (Exception e) {
455 throw processException(e);
456 }
457 finally {
458 if (assetVocabulary != null) {
459 cacheResult(assetVocabulary);
460 }
461
462 closeSession(session);
463 }
464 }
465
466 return assetVocabulary;
467 }
468
469 public List<AssetVocabulary> findByUuid(String uuid)
470 throws SystemException {
471 Object[] finderArgs = new Object[] { uuid };
472
473 List<AssetVocabulary> list = (List<AssetVocabulary>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_UUID,
474 finderArgs, this);
475
476 if (list == null) {
477 Session session = null;
478
479 try {
480 session = openSession();
481
482 StringBundler query = new StringBundler(3);
483
484 query.append(_SQL_SELECT_ASSETVOCABULARY_WHERE);
485
486 if (uuid == null) {
487 query.append(_FINDER_COLUMN_UUID_UUID_1);
488 }
489 else {
490 if (uuid.equals(StringPool.BLANK)) {
491 query.append(_FINDER_COLUMN_UUID_UUID_3);
492 }
493 else {
494 query.append(_FINDER_COLUMN_UUID_UUID_2);
495 }
496 }
497
498 query.append(AssetVocabularyModelImpl.ORDER_BY_JPQL);
499
500 String sql = query.toString();
501
502 Query q = session.createQuery(sql);
503
504 QueryPos qPos = QueryPos.getInstance(q);
505
506 if (uuid != null) {
507 qPos.add(uuid);
508 }
509
510 list = q.list();
511 }
512 catch (Exception e) {
513 throw processException(e);
514 }
515 finally {
516 if (list == null) {
517 list = new ArrayList<AssetVocabulary>();
518 }
519
520 cacheResult(list);
521
522 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_UUID, finderArgs,
523 list);
524
525 closeSession(session);
526 }
527 }
528
529 return list;
530 }
531
532 public List<AssetVocabulary> findByUuid(String uuid, int start, int end)
533 throws SystemException {
534 return findByUuid(uuid, start, end, null);
535 }
536
537 public List<AssetVocabulary> findByUuid(String uuid, int start, int end,
538 OrderByComparator orderByComparator) throws SystemException {
539 Object[] finderArgs = new Object[] {
540 uuid,
541
542 String.valueOf(start), String.valueOf(end),
543 String.valueOf(orderByComparator)
544 };
545
546 List<AssetVocabulary> list = (List<AssetVocabulary>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_UUID,
547 finderArgs, this);
548
549 if (list == null) {
550 Session session = null;
551
552 try {
553 session = openSession();
554
555 StringBundler query = null;
556
557 if (orderByComparator != null) {
558 query = new StringBundler(3 +
559 (orderByComparator.getOrderByFields().length * 3));
560 }
561 else {
562 query = new StringBundler(3);
563 }
564
565 query.append(_SQL_SELECT_ASSETVOCABULARY_WHERE);
566
567 if (uuid == null) {
568 query.append(_FINDER_COLUMN_UUID_UUID_1);
569 }
570 else {
571 if (uuid.equals(StringPool.BLANK)) {
572 query.append(_FINDER_COLUMN_UUID_UUID_3);
573 }
574 else {
575 query.append(_FINDER_COLUMN_UUID_UUID_2);
576 }
577 }
578
579 if (orderByComparator != null) {
580 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
581 orderByComparator);
582 }
583
584 else {
585 query.append(AssetVocabularyModelImpl.ORDER_BY_JPQL);
586 }
587
588 String sql = query.toString();
589
590 Query q = session.createQuery(sql);
591
592 QueryPos qPos = QueryPos.getInstance(q);
593
594 if (uuid != null) {
595 qPos.add(uuid);
596 }
597
598 list = (List<AssetVocabulary>)QueryUtil.list(q, getDialect(),
599 start, end);
600 }
601 catch (Exception e) {
602 throw processException(e);
603 }
604 finally {
605 if (list == null) {
606 list = new ArrayList<AssetVocabulary>();
607 }
608
609 cacheResult(list);
610
611 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_UUID,
612 finderArgs, list);
613
614 closeSession(session);
615 }
616 }
617
618 return list;
619 }
620
621 public AssetVocabulary findByUuid_First(String uuid,
622 OrderByComparator orderByComparator)
623 throws NoSuchVocabularyException, SystemException {
624 List<AssetVocabulary> list = findByUuid(uuid, 0, 1, orderByComparator);
625
626 if (list.isEmpty()) {
627 StringBundler msg = new StringBundler(4);
628
629 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
630
631 msg.append("uuid=");
632 msg.append(uuid);
633
634 msg.append(StringPool.CLOSE_CURLY_BRACE);
635
636 throw new NoSuchVocabularyException(msg.toString());
637 }
638 else {
639 return list.get(0);
640 }
641 }
642
643 public AssetVocabulary findByUuid_Last(String uuid,
644 OrderByComparator orderByComparator)
645 throws NoSuchVocabularyException, SystemException {
646 int count = countByUuid(uuid);
647
648 List<AssetVocabulary> list = findByUuid(uuid, count - 1, count,
649 orderByComparator);
650
651 if (list.isEmpty()) {
652 StringBundler msg = new StringBundler(4);
653
654 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
655
656 msg.append("uuid=");
657 msg.append(uuid);
658
659 msg.append(StringPool.CLOSE_CURLY_BRACE);
660
661 throw new NoSuchVocabularyException(msg.toString());
662 }
663 else {
664 return list.get(0);
665 }
666 }
667
668 public AssetVocabulary[] findByUuid_PrevAndNext(long vocabularyId,
669 String uuid, OrderByComparator orderByComparator)
670 throws NoSuchVocabularyException, SystemException {
671 AssetVocabulary assetVocabulary = findByPrimaryKey(vocabularyId);
672
673 int count = countByUuid(uuid);
674
675 Session session = null;
676
677 try {
678 session = openSession();
679
680 StringBundler query = null;
681
682 if (orderByComparator != null) {
683 query = new StringBundler(3 +
684 (orderByComparator.getOrderByFields().length * 3));
685 }
686 else {
687 query = new StringBundler(3);
688 }
689
690 query.append(_SQL_SELECT_ASSETVOCABULARY_WHERE);
691
692 if (uuid == null) {
693 query.append(_FINDER_COLUMN_UUID_UUID_1);
694 }
695 else {
696 if (uuid.equals(StringPool.BLANK)) {
697 query.append(_FINDER_COLUMN_UUID_UUID_3);
698 }
699 else {
700 query.append(_FINDER_COLUMN_UUID_UUID_2);
701 }
702 }
703
704 if (orderByComparator != null) {
705 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
706 orderByComparator);
707 }
708
709 else {
710 query.append(AssetVocabularyModelImpl.ORDER_BY_JPQL);
711 }
712
713 String sql = query.toString();
714
715 Query q = session.createQuery(sql);
716
717 QueryPos qPos = QueryPos.getInstance(q);
718
719 if (uuid != null) {
720 qPos.add(uuid);
721 }
722
723 Object[] objArray = QueryUtil.getPrevAndNext(q, count,
724 orderByComparator, assetVocabulary);
725
726 AssetVocabulary[] array = new AssetVocabularyImpl[3];
727
728 array[0] = (AssetVocabulary)objArray[0];
729 array[1] = (AssetVocabulary)objArray[1];
730 array[2] = (AssetVocabulary)objArray[2];
731
732 return array;
733 }
734 catch (Exception e) {
735 throw processException(e);
736 }
737 finally {
738 closeSession(session);
739 }
740 }
741
742 public AssetVocabulary findByUUID_G(String uuid, long groupId)
743 throws NoSuchVocabularyException, SystemException {
744 AssetVocabulary assetVocabulary = fetchByUUID_G(uuid, groupId);
745
746 if (assetVocabulary == null) {
747 StringBundler msg = new StringBundler(6);
748
749 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
750
751 msg.append("uuid=");
752 msg.append(uuid);
753
754 msg.append(", groupId=");
755 msg.append(groupId);
756
757 msg.append(StringPool.CLOSE_CURLY_BRACE);
758
759 if (_log.isWarnEnabled()) {
760 _log.warn(msg.toString());
761 }
762
763 throw new NoSuchVocabularyException(msg.toString());
764 }
765
766 return assetVocabulary;
767 }
768
769 public AssetVocabulary fetchByUUID_G(String uuid, long groupId)
770 throws SystemException {
771 return fetchByUUID_G(uuid, groupId, true);
772 }
773
774 public AssetVocabulary fetchByUUID_G(String uuid, long groupId,
775 boolean retrieveFromCache) throws SystemException {
776 Object[] finderArgs = new Object[] { uuid, new Long(groupId) };
777
778 Object result = null;
779
780 if (retrieveFromCache) {
781 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_UUID_G,
782 finderArgs, this);
783 }
784
785 if (result == null) {
786 Session session = null;
787
788 try {
789 session = openSession();
790
791 StringBundler query = new StringBundler(4);
792
793 query.append(_SQL_SELECT_ASSETVOCABULARY_WHERE);
794
795 if (uuid == null) {
796 query.append(_FINDER_COLUMN_UUID_G_UUID_1);
797 }
798 else {
799 if (uuid.equals(StringPool.BLANK)) {
800 query.append(_FINDER_COLUMN_UUID_G_UUID_3);
801 }
802 else {
803 query.append(_FINDER_COLUMN_UUID_G_UUID_2);
804 }
805 }
806
807 query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
808
809 query.append(AssetVocabularyModelImpl.ORDER_BY_JPQL);
810
811 String sql = query.toString();
812
813 Query q = session.createQuery(sql);
814
815 QueryPos qPos = QueryPos.getInstance(q);
816
817 if (uuid != null) {
818 qPos.add(uuid);
819 }
820
821 qPos.add(groupId);
822
823 List<AssetVocabulary> list = q.list();
824
825 result = list;
826
827 AssetVocabulary assetVocabulary = null;
828
829 if (list.isEmpty()) {
830 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
831 finderArgs, list);
832 }
833 else {
834 assetVocabulary = list.get(0);
835
836 cacheResult(assetVocabulary);
837
838 if ((assetVocabulary.getUuid() == null) ||
839 !assetVocabulary.getUuid().equals(uuid) ||
840 (assetVocabulary.getGroupId() != groupId)) {
841 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
842 finderArgs, assetVocabulary);
843 }
844 }
845
846 return assetVocabulary;
847 }
848 catch (Exception e) {
849 throw processException(e);
850 }
851 finally {
852 if (result == null) {
853 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
854 finderArgs, new ArrayList<AssetVocabulary>());
855 }
856
857 closeSession(session);
858 }
859 }
860 else {
861 if (result instanceof List<?>) {
862 return null;
863 }
864 else {
865 return (AssetVocabulary)result;
866 }
867 }
868 }
869
870 public List<AssetVocabulary> findByGroupId(long groupId)
871 throws SystemException {
872 Object[] finderArgs = new Object[] { new Long(groupId) };
873
874 List<AssetVocabulary> list = (List<AssetVocabulary>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_GROUPID,
875 finderArgs, this);
876
877 if (list == null) {
878 Session session = null;
879
880 try {
881 session = openSession();
882
883 StringBundler query = new StringBundler(3);
884
885 query.append(_SQL_SELECT_ASSETVOCABULARY_WHERE);
886
887 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
888
889 query.append(AssetVocabularyModelImpl.ORDER_BY_JPQL);
890
891 String sql = query.toString();
892
893 Query q = session.createQuery(sql);
894
895 QueryPos qPos = QueryPos.getInstance(q);
896
897 qPos.add(groupId);
898
899 list = q.list();
900 }
901 catch (Exception e) {
902 throw processException(e);
903 }
904 finally {
905 if (list == null) {
906 list = new ArrayList<AssetVocabulary>();
907 }
908
909 cacheResult(list);
910
911 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_GROUPID,
912 finderArgs, list);
913
914 closeSession(session);
915 }
916 }
917
918 return list;
919 }
920
921 public List<AssetVocabulary> findByGroupId(long groupId, int start, int end)
922 throws SystemException {
923 return findByGroupId(groupId, start, end, null);
924 }
925
926 public List<AssetVocabulary> findByGroupId(long groupId, int start,
927 int end, OrderByComparator orderByComparator) throws SystemException {
928 Object[] finderArgs = new Object[] {
929 new Long(groupId),
930
931 String.valueOf(start), String.valueOf(end),
932 String.valueOf(orderByComparator)
933 };
934
935 List<AssetVocabulary> list = (List<AssetVocabulary>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_GROUPID,
936 finderArgs, this);
937
938 if (list == null) {
939 Session session = null;
940
941 try {
942 session = openSession();
943
944 StringBundler query = null;
945
946 if (orderByComparator != null) {
947 query = new StringBundler(3 +
948 (orderByComparator.getOrderByFields().length * 3));
949 }
950 else {
951 query = new StringBundler(3);
952 }
953
954 query.append(_SQL_SELECT_ASSETVOCABULARY_WHERE);
955
956 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
957
958 if (orderByComparator != null) {
959 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
960 orderByComparator);
961 }
962
963 else {
964 query.append(AssetVocabularyModelImpl.ORDER_BY_JPQL);
965 }
966
967 String sql = query.toString();
968
969 Query q = session.createQuery(sql);
970
971 QueryPos qPos = QueryPos.getInstance(q);
972
973 qPos.add(groupId);
974
975 list = (List<AssetVocabulary>)QueryUtil.list(q, getDialect(),
976 start, end);
977 }
978 catch (Exception e) {
979 throw processException(e);
980 }
981 finally {
982 if (list == null) {
983 list = new ArrayList<AssetVocabulary>();
984 }
985
986 cacheResult(list);
987
988 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_GROUPID,
989 finderArgs, list);
990
991 closeSession(session);
992 }
993 }
994
995 return list;
996 }
997
998 public AssetVocabulary findByGroupId_First(long groupId,
999 OrderByComparator orderByComparator)
1000 throws NoSuchVocabularyException, SystemException {
1001 List<AssetVocabulary> list = findByGroupId(groupId, 0, 1,
1002 orderByComparator);
1003
1004 if (list.isEmpty()) {
1005 StringBundler msg = new StringBundler(4);
1006
1007 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1008
1009 msg.append("groupId=");
1010 msg.append(groupId);
1011
1012 msg.append(StringPool.CLOSE_CURLY_BRACE);
1013
1014 throw new NoSuchVocabularyException(msg.toString());
1015 }
1016 else {
1017 return list.get(0);
1018 }
1019 }
1020
1021 public AssetVocabulary findByGroupId_Last(long groupId,
1022 OrderByComparator orderByComparator)
1023 throws NoSuchVocabularyException, SystemException {
1024 int count = countByGroupId(groupId);
1025
1026 List<AssetVocabulary> list = findByGroupId(groupId, count - 1, count,
1027 orderByComparator);
1028
1029 if (list.isEmpty()) {
1030 StringBundler msg = new StringBundler(4);
1031
1032 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1033
1034 msg.append("groupId=");
1035 msg.append(groupId);
1036
1037 msg.append(StringPool.CLOSE_CURLY_BRACE);
1038
1039 throw new NoSuchVocabularyException(msg.toString());
1040 }
1041 else {
1042 return list.get(0);
1043 }
1044 }
1045
1046 public AssetVocabulary[] findByGroupId_PrevAndNext(long vocabularyId,
1047 long groupId, OrderByComparator orderByComparator)
1048 throws NoSuchVocabularyException, SystemException {
1049 AssetVocabulary assetVocabulary = findByPrimaryKey(vocabularyId);
1050
1051 int count = countByGroupId(groupId);
1052
1053 Session session = null;
1054
1055 try {
1056 session = openSession();
1057
1058 StringBundler query = null;
1059
1060 if (orderByComparator != null) {
1061 query = new StringBundler(3 +
1062 (orderByComparator.getOrderByFields().length * 3));
1063 }
1064 else {
1065 query = new StringBundler(3);
1066 }
1067
1068 query.append(_SQL_SELECT_ASSETVOCABULARY_WHERE);
1069
1070 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1071
1072 if (orderByComparator != null) {
1073 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1074 orderByComparator);
1075 }
1076
1077 else {
1078 query.append(AssetVocabularyModelImpl.ORDER_BY_JPQL);
1079 }
1080
1081 String sql = query.toString();
1082
1083 Query q = session.createQuery(sql);
1084
1085 QueryPos qPos = QueryPos.getInstance(q);
1086
1087 qPos.add(groupId);
1088
1089 Object[] objArray = QueryUtil.getPrevAndNext(q, count,
1090 orderByComparator, assetVocabulary);
1091
1092 AssetVocabulary[] array = new AssetVocabularyImpl[3];
1093
1094 array[0] = (AssetVocabulary)objArray[0];
1095 array[1] = (AssetVocabulary)objArray[1];
1096 array[2] = (AssetVocabulary)objArray[2];
1097
1098 return array;
1099 }
1100 catch (Exception e) {
1101 throw processException(e);
1102 }
1103 finally {
1104 closeSession(session);
1105 }
1106 }
1107
1108 public List<AssetVocabulary> findByCompanyId(long companyId)
1109 throws SystemException {
1110 Object[] finderArgs = new Object[] { new Long(companyId) };
1111
1112 List<AssetVocabulary> list = (List<AssetVocabulary>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_COMPANYID,
1113 finderArgs, this);
1114
1115 if (list == null) {
1116 Session session = null;
1117
1118 try {
1119 session = openSession();
1120
1121 StringBundler query = new StringBundler(3);
1122
1123 query.append(_SQL_SELECT_ASSETVOCABULARY_WHERE);
1124
1125 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
1126
1127 query.append(AssetVocabularyModelImpl.ORDER_BY_JPQL);
1128
1129 String sql = query.toString();
1130
1131 Query q = session.createQuery(sql);
1132
1133 QueryPos qPos = QueryPos.getInstance(q);
1134
1135 qPos.add(companyId);
1136
1137 list = q.list();
1138 }
1139 catch (Exception e) {
1140 throw processException(e);
1141 }
1142 finally {
1143 if (list == null) {
1144 list = new ArrayList<AssetVocabulary>();
1145 }
1146
1147 cacheResult(list);
1148
1149 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_COMPANYID,
1150 finderArgs, list);
1151
1152 closeSession(session);
1153 }
1154 }
1155
1156 return list;
1157 }
1158
1159 public List<AssetVocabulary> findByCompanyId(long companyId, int start,
1160 int end) throws SystemException {
1161 return findByCompanyId(companyId, start, end, null);
1162 }
1163
1164 public List<AssetVocabulary> findByCompanyId(long companyId, int start,
1165 int end, OrderByComparator orderByComparator) throws SystemException {
1166 Object[] finderArgs = new Object[] {
1167 new Long(companyId),
1168
1169 String.valueOf(start), String.valueOf(end),
1170 String.valueOf(orderByComparator)
1171 };
1172
1173 List<AssetVocabulary> list = (List<AssetVocabulary>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_COMPANYID,
1174 finderArgs, this);
1175
1176 if (list == null) {
1177 Session session = null;
1178
1179 try {
1180 session = openSession();
1181
1182 StringBundler query = null;
1183
1184 if (orderByComparator != null) {
1185 query = new StringBundler(3 +
1186 (orderByComparator.getOrderByFields().length * 3));
1187 }
1188 else {
1189 query = new StringBundler(3);
1190 }
1191
1192 query.append(_SQL_SELECT_ASSETVOCABULARY_WHERE);
1193
1194 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
1195
1196 if (orderByComparator != null) {
1197 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1198 orderByComparator);
1199 }
1200
1201 else {
1202 query.append(AssetVocabularyModelImpl.ORDER_BY_JPQL);
1203 }
1204
1205 String sql = query.toString();
1206
1207 Query q = session.createQuery(sql);
1208
1209 QueryPos qPos = QueryPos.getInstance(q);
1210
1211 qPos.add(companyId);
1212
1213 list = (List<AssetVocabulary>)QueryUtil.list(q, getDialect(),
1214 start, end);
1215 }
1216 catch (Exception e) {
1217 throw processException(e);
1218 }
1219 finally {
1220 if (list == null) {
1221 list = new ArrayList<AssetVocabulary>();
1222 }
1223
1224 cacheResult(list);
1225
1226 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_COMPANYID,
1227 finderArgs, list);
1228
1229 closeSession(session);
1230 }
1231 }
1232
1233 return list;
1234 }
1235
1236 public AssetVocabulary findByCompanyId_First(long companyId,
1237 OrderByComparator orderByComparator)
1238 throws NoSuchVocabularyException, SystemException {
1239 List<AssetVocabulary> list = findByCompanyId(companyId, 0, 1,
1240 orderByComparator);
1241
1242 if (list.isEmpty()) {
1243 StringBundler msg = new StringBundler(4);
1244
1245 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1246
1247 msg.append("companyId=");
1248 msg.append(companyId);
1249
1250 msg.append(StringPool.CLOSE_CURLY_BRACE);
1251
1252 throw new NoSuchVocabularyException(msg.toString());
1253 }
1254 else {
1255 return list.get(0);
1256 }
1257 }
1258
1259 public AssetVocabulary findByCompanyId_Last(long companyId,
1260 OrderByComparator orderByComparator)
1261 throws NoSuchVocabularyException, SystemException {
1262 int count = countByCompanyId(companyId);
1263
1264 List<AssetVocabulary> list = findByCompanyId(companyId, count - 1,
1265 count, orderByComparator);
1266
1267 if (list.isEmpty()) {
1268 StringBundler msg = new StringBundler(4);
1269
1270 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1271
1272 msg.append("companyId=");
1273 msg.append(companyId);
1274
1275 msg.append(StringPool.CLOSE_CURLY_BRACE);
1276
1277 throw new NoSuchVocabularyException(msg.toString());
1278 }
1279 else {
1280 return list.get(0);
1281 }
1282 }
1283
1284 public AssetVocabulary[] findByCompanyId_PrevAndNext(long vocabularyId,
1285 long companyId, OrderByComparator orderByComparator)
1286 throws NoSuchVocabularyException, SystemException {
1287 AssetVocabulary assetVocabulary = findByPrimaryKey(vocabularyId);
1288
1289 int count = countByCompanyId(companyId);
1290
1291 Session session = null;
1292
1293 try {
1294 session = openSession();
1295
1296 StringBundler query = null;
1297
1298 if (orderByComparator != null) {
1299 query = new StringBundler(3 +
1300 (orderByComparator.getOrderByFields().length * 3));
1301 }
1302 else {
1303 query = new StringBundler(3);
1304 }
1305
1306 query.append(_SQL_SELECT_ASSETVOCABULARY_WHERE);
1307
1308 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
1309
1310 if (orderByComparator != null) {
1311 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1312 orderByComparator);
1313 }
1314
1315 else {
1316 query.append(AssetVocabularyModelImpl.ORDER_BY_JPQL);
1317 }
1318
1319 String sql = query.toString();
1320
1321 Query q = session.createQuery(sql);
1322
1323 QueryPos qPos = QueryPos.getInstance(q);
1324
1325 qPos.add(companyId);
1326
1327 Object[] objArray = QueryUtil.getPrevAndNext(q, count,
1328 orderByComparator, assetVocabulary);
1329
1330 AssetVocabulary[] array = new AssetVocabularyImpl[3];
1331
1332 array[0] = (AssetVocabulary)objArray[0];
1333 array[1] = (AssetVocabulary)objArray[1];
1334 array[2] = (AssetVocabulary)objArray[2];
1335
1336 return array;
1337 }
1338 catch (Exception e) {
1339 throw processException(e);
1340 }
1341 finally {
1342 closeSession(session);
1343 }
1344 }
1345
1346 public AssetVocabulary findByG_N(long groupId, String name)
1347 throws NoSuchVocabularyException, SystemException {
1348 AssetVocabulary assetVocabulary = fetchByG_N(groupId, name);
1349
1350 if (assetVocabulary == null) {
1351 StringBundler msg = new StringBundler(6);
1352
1353 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1354
1355 msg.append("groupId=");
1356 msg.append(groupId);
1357
1358 msg.append(", name=");
1359 msg.append(name);
1360
1361 msg.append(StringPool.CLOSE_CURLY_BRACE);
1362
1363 if (_log.isWarnEnabled()) {
1364 _log.warn(msg.toString());
1365 }
1366
1367 throw new NoSuchVocabularyException(msg.toString());
1368 }
1369
1370 return assetVocabulary;
1371 }
1372
1373 public AssetVocabulary fetchByG_N(long groupId, String name)
1374 throws SystemException {
1375 return fetchByG_N(groupId, name, true);
1376 }
1377
1378 public AssetVocabulary fetchByG_N(long groupId, String name,
1379 boolean retrieveFromCache) throws SystemException {
1380 Object[] finderArgs = new Object[] { new Long(groupId), name };
1381
1382 Object result = null;
1383
1384 if (retrieveFromCache) {
1385 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_G_N,
1386 finderArgs, this);
1387 }
1388
1389 if (result == null) {
1390 Session session = null;
1391
1392 try {
1393 session = openSession();
1394
1395 StringBundler query = new StringBundler(4);
1396
1397 query.append(_SQL_SELECT_ASSETVOCABULARY_WHERE);
1398
1399 query.append(_FINDER_COLUMN_G_N_GROUPID_2);
1400
1401 if (name == null) {
1402 query.append(_FINDER_COLUMN_G_N_NAME_1);
1403 }
1404 else {
1405 if (name.equals(StringPool.BLANK)) {
1406 query.append(_FINDER_COLUMN_G_N_NAME_3);
1407 }
1408 else {
1409 query.append(_FINDER_COLUMN_G_N_NAME_2);
1410 }
1411 }
1412
1413 query.append(AssetVocabularyModelImpl.ORDER_BY_JPQL);
1414
1415 String sql = query.toString();
1416
1417 Query q = session.createQuery(sql);
1418
1419 QueryPos qPos = QueryPos.getInstance(q);
1420
1421 qPos.add(groupId);
1422
1423 if (name != null) {
1424 qPos.add(name);
1425 }
1426
1427 List<AssetVocabulary> list = q.list();
1428
1429 result = list;
1430
1431 AssetVocabulary assetVocabulary = null;
1432
1433 if (list.isEmpty()) {
1434 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_N,
1435 finderArgs, list);
1436 }
1437 else {
1438 assetVocabulary = list.get(0);
1439
1440 cacheResult(assetVocabulary);
1441
1442 if ((assetVocabulary.getGroupId() != groupId) ||
1443 (assetVocabulary.getName() == null) ||
1444 !assetVocabulary.getName().equals(name)) {
1445 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_N,
1446 finderArgs, assetVocabulary);
1447 }
1448 }
1449
1450 return assetVocabulary;
1451 }
1452 catch (Exception e) {
1453 throw processException(e);
1454 }
1455 finally {
1456 if (result == null) {
1457 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_N,
1458 finderArgs, new ArrayList<AssetVocabulary>());
1459 }
1460
1461 closeSession(session);
1462 }
1463 }
1464 else {
1465 if (result instanceof List<?>) {
1466 return null;
1467 }
1468 else {
1469 return (AssetVocabulary)result;
1470 }
1471 }
1472 }
1473
1474 public List<AssetVocabulary> findAll() throws SystemException {
1475 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1476 }
1477
1478 public List<AssetVocabulary> findAll(int start, int end)
1479 throws SystemException {
1480 return findAll(start, end, null);
1481 }
1482
1483 public List<AssetVocabulary> findAll(int start, int end,
1484 OrderByComparator orderByComparator) throws SystemException {
1485 Object[] finderArgs = new Object[] {
1486 String.valueOf(start), String.valueOf(end),
1487 String.valueOf(orderByComparator)
1488 };
1489
1490 List<AssetVocabulary> list = (List<AssetVocabulary>)FinderCacheUtil.getResult(FINDER_PATH_FIND_ALL,
1491 finderArgs, this);
1492
1493 if (list == null) {
1494 Session session = null;
1495
1496 try {
1497 session = openSession();
1498
1499 StringBundler query = null;
1500 String sql = null;
1501
1502 if (orderByComparator != null) {
1503 query = new StringBundler(2 +
1504 (orderByComparator.getOrderByFields().length * 3));
1505
1506 query.append(_SQL_SELECT_ASSETVOCABULARY);
1507
1508 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1509 orderByComparator);
1510
1511 sql = query.toString();
1512 }
1513
1514 else {
1515 sql = _SQL_SELECT_ASSETVOCABULARY.concat(AssetVocabularyModelImpl.ORDER_BY_JPQL);
1516 }
1517
1518 Query q = session.createQuery(sql);
1519
1520 if (orderByComparator == null) {
1521 list = (List<AssetVocabulary>)QueryUtil.list(q,
1522 getDialect(), start, end, false);
1523
1524 Collections.sort(list);
1525 }
1526 else {
1527 list = (List<AssetVocabulary>)QueryUtil.list(q,
1528 getDialect(), start, end);
1529 }
1530 }
1531 catch (Exception e) {
1532 throw processException(e);
1533 }
1534 finally {
1535 if (list == null) {
1536 list = new ArrayList<AssetVocabulary>();
1537 }
1538
1539 cacheResult(list);
1540
1541 FinderCacheUtil.putResult(FINDER_PATH_FIND_ALL, finderArgs, list);
1542
1543 closeSession(session);
1544 }
1545 }
1546
1547 return list;
1548 }
1549
1550 public void removeByUuid(String uuid) throws SystemException {
1551 for (AssetVocabulary assetVocabulary : findByUuid(uuid)) {
1552 remove(assetVocabulary);
1553 }
1554 }
1555
1556 public void removeByUUID_G(String uuid, long groupId)
1557 throws NoSuchVocabularyException, SystemException {
1558 AssetVocabulary assetVocabulary = findByUUID_G(uuid, groupId);
1559
1560 remove(assetVocabulary);
1561 }
1562
1563 public void removeByGroupId(long groupId) throws SystemException {
1564 for (AssetVocabulary assetVocabulary : findByGroupId(groupId)) {
1565 remove(assetVocabulary);
1566 }
1567 }
1568
1569 public void removeByCompanyId(long companyId) throws SystemException {
1570 for (AssetVocabulary assetVocabulary : findByCompanyId(companyId)) {
1571 remove(assetVocabulary);
1572 }
1573 }
1574
1575 public void removeByG_N(long groupId, String name)
1576 throws NoSuchVocabularyException, SystemException {
1577 AssetVocabulary assetVocabulary = findByG_N(groupId, name);
1578
1579 remove(assetVocabulary);
1580 }
1581
1582 public void removeAll() throws SystemException {
1583 for (AssetVocabulary assetVocabulary : findAll()) {
1584 remove(assetVocabulary);
1585 }
1586 }
1587
1588 public int countByUuid(String uuid) throws SystemException {
1589 Object[] finderArgs = new Object[] { uuid };
1590
1591 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID,
1592 finderArgs, this);
1593
1594 if (count == null) {
1595 Session session = null;
1596
1597 try {
1598 session = openSession();
1599
1600 StringBundler query = new StringBundler(2);
1601
1602 query.append(_SQL_COUNT_ASSETVOCABULARY_WHERE);
1603
1604 if (uuid == null) {
1605 query.append(_FINDER_COLUMN_UUID_UUID_1);
1606 }
1607 else {
1608 if (uuid.equals(StringPool.BLANK)) {
1609 query.append(_FINDER_COLUMN_UUID_UUID_3);
1610 }
1611 else {
1612 query.append(_FINDER_COLUMN_UUID_UUID_2);
1613 }
1614 }
1615
1616 String sql = query.toString();
1617
1618 Query q = session.createQuery(sql);
1619
1620 QueryPos qPos = QueryPos.getInstance(q);
1621
1622 if (uuid != null) {
1623 qPos.add(uuid);
1624 }
1625
1626 count = (Long)q.uniqueResult();
1627 }
1628 catch (Exception e) {
1629 throw processException(e);
1630 }
1631 finally {
1632 if (count == null) {
1633 count = Long.valueOf(0);
1634 }
1635
1636 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID,
1637 finderArgs, count);
1638
1639 closeSession(session);
1640 }
1641 }
1642
1643 return count.intValue();
1644 }
1645
1646 public int countByUUID_G(String uuid, long groupId)
1647 throws SystemException {
1648 Object[] finderArgs = new Object[] { uuid, new Long(groupId) };
1649
1650 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID_G,
1651 finderArgs, this);
1652
1653 if (count == null) {
1654 Session session = null;
1655
1656 try {
1657 session = openSession();
1658
1659 StringBundler query = new StringBundler(3);
1660
1661 query.append(_SQL_COUNT_ASSETVOCABULARY_WHERE);
1662
1663 if (uuid == null) {
1664 query.append(_FINDER_COLUMN_UUID_G_UUID_1);
1665 }
1666 else {
1667 if (uuid.equals(StringPool.BLANK)) {
1668 query.append(_FINDER_COLUMN_UUID_G_UUID_3);
1669 }
1670 else {
1671 query.append(_FINDER_COLUMN_UUID_G_UUID_2);
1672 }
1673 }
1674
1675 query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
1676
1677 String sql = query.toString();
1678
1679 Query q = session.createQuery(sql);
1680
1681 QueryPos qPos = QueryPos.getInstance(q);
1682
1683 if (uuid != null) {
1684 qPos.add(uuid);
1685 }
1686
1687 qPos.add(groupId);
1688
1689 count = (Long)q.uniqueResult();
1690 }
1691 catch (Exception e) {
1692 throw processException(e);
1693 }
1694 finally {
1695 if (count == null) {
1696 count = Long.valueOf(0);
1697 }
1698
1699 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G,
1700 finderArgs, count);
1701
1702 closeSession(session);
1703 }
1704 }
1705
1706 return count.intValue();
1707 }
1708
1709 public int countByGroupId(long groupId) throws SystemException {
1710 Object[] finderArgs = new Object[] { new Long(groupId) };
1711
1712 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_GROUPID,
1713 finderArgs, this);
1714
1715 if (count == null) {
1716 Session session = null;
1717
1718 try {
1719 session = openSession();
1720
1721 StringBundler query = new StringBundler(2);
1722
1723 query.append(_SQL_COUNT_ASSETVOCABULARY_WHERE);
1724
1725 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1726
1727 String sql = query.toString();
1728
1729 Query q = session.createQuery(sql);
1730
1731 QueryPos qPos = QueryPos.getInstance(q);
1732
1733 qPos.add(groupId);
1734
1735 count = (Long)q.uniqueResult();
1736 }
1737 catch (Exception e) {
1738 throw processException(e);
1739 }
1740 finally {
1741 if (count == null) {
1742 count = Long.valueOf(0);
1743 }
1744
1745 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_GROUPID,
1746 finderArgs, count);
1747
1748 closeSession(session);
1749 }
1750 }
1751
1752 return count.intValue();
1753 }
1754
1755 public int countByCompanyId(long companyId) throws SystemException {
1756 Object[] finderArgs = new Object[] { new Long(companyId) };
1757
1758 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_COMPANYID,
1759 finderArgs, this);
1760
1761 if (count == null) {
1762 Session session = null;
1763
1764 try {
1765 session = openSession();
1766
1767 StringBundler query = new StringBundler(2);
1768
1769 query.append(_SQL_COUNT_ASSETVOCABULARY_WHERE);
1770
1771 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
1772
1773 String sql = query.toString();
1774
1775 Query q = session.createQuery(sql);
1776
1777 QueryPos qPos = QueryPos.getInstance(q);
1778
1779 qPos.add(companyId);
1780
1781 count = (Long)q.uniqueResult();
1782 }
1783 catch (Exception e) {
1784 throw processException(e);
1785 }
1786 finally {
1787 if (count == null) {
1788 count = Long.valueOf(0);
1789 }
1790
1791 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_COMPANYID,
1792 finderArgs, count);
1793
1794 closeSession(session);
1795 }
1796 }
1797
1798 return count.intValue();
1799 }
1800
1801 public int countByG_N(long groupId, String name) throws SystemException {
1802 Object[] finderArgs = new Object[] { new Long(groupId), name };
1803
1804 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_N,
1805 finderArgs, this);
1806
1807 if (count == null) {
1808 Session session = null;
1809
1810 try {
1811 session = openSession();
1812
1813 StringBundler query = new StringBundler(3);
1814
1815 query.append(_SQL_COUNT_ASSETVOCABULARY_WHERE);
1816
1817 query.append(_FINDER_COLUMN_G_N_GROUPID_2);
1818
1819 if (name == null) {
1820 query.append(_FINDER_COLUMN_G_N_NAME_1);
1821 }
1822 else {
1823 if (name.equals(StringPool.BLANK)) {
1824 query.append(_FINDER_COLUMN_G_N_NAME_3);
1825 }
1826 else {
1827 query.append(_FINDER_COLUMN_G_N_NAME_2);
1828 }
1829 }
1830
1831 String sql = query.toString();
1832
1833 Query q = session.createQuery(sql);
1834
1835 QueryPos qPos = QueryPos.getInstance(q);
1836
1837 qPos.add(groupId);
1838
1839 if (name != null) {
1840 qPos.add(name);
1841 }
1842
1843 count = (Long)q.uniqueResult();
1844 }
1845 catch (Exception e) {
1846 throw processException(e);
1847 }
1848 finally {
1849 if (count == null) {
1850 count = Long.valueOf(0);
1851 }
1852
1853 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_N, finderArgs,
1854 count);
1855
1856 closeSession(session);
1857 }
1858 }
1859
1860 return count.intValue();
1861 }
1862
1863 public int countAll() throws SystemException {
1864 Object[] finderArgs = new Object[0];
1865
1866 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
1867 finderArgs, this);
1868
1869 if (count == null) {
1870 Session session = null;
1871
1872 try {
1873 session = openSession();
1874
1875 Query q = session.createQuery(_SQL_COUNT_ASSETVOCABULARY);
1876
1877 count = (Long)q.uniqueResult();
1878 }
1879 catch (Exception e) {
1880 throw processException(e);
1881 }
1882 finally {
1883 if (count == null) {
1884 count = Long.valueOf(0);
1885 }
1886
1887 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL, finderArgs,
1888 count);
1889
1890 closeSession(session);
1891 }
1892 }
1893
1894 return count.intValue();
1895 }
1896
1897 public void afterPropertiesSet() {
1898 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
1899 com.liferay.portal.util.PropsUtil.get(
1900 "value.object.listener.com.liferay.portlet.asset.model.AssetVocabulary")));
1901
1902 if (listenerClassNames.length > 0) {
1903 try {
1904 List<ModelListener<AssetVocabulary>> listenersList = new ArrayList<ModelListener<AssetVocabulary>>();
1905
1906 for (String listenerClassName : listenerClassNames) {
1907 listenersList.add((ModelListener<AssetVocabulary>)Class.forName(
1908 listenerClassName).newInstance());
1909 }
1910
1911 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
1912 }
1913 catch (Exception e) {
1914 _log.error(e);
1915 }
1916 }
1917 }
1918
1919 @BeanReference(type = AssetCategoryPersistence.class)
1920 protected AssetCategoryPersistence assetCategoryPersistence;
1921 @BeanReference(type = AssetCategoryPropertyPersistence.class)
1922 protected AssetCategoryPropertyPersistence assetCategoryPropertyPersistence;
1923 @BeanReference(type = AssetEntryPersistence.class)
1924 protected AssetEntryPersistence assetEntryPersistence;
1925 @BeanReference(type = AssetLinkPersistence.class)
1926 protected AssetLinkPersistence assetLinkPersistence;
1927 @BeanReference(type = AssetTagPersistence.class)
1928 protected AssetTagPersistence assetTagPersistence;
1929 @BeanReference(type = AssetTagPropertyPersistence.class)
1930 protected AssetTagPropertyPersistence assetTagPropertyPersistence;
1931 @BeanReference(type = AssetTagStatsPersistence.class)
1932 protected AssetTagStatsPersistence assetTagStatsPersistence;
1933 @BeanReference(type = AssetVocabularyPersistence.class)
1934 protected AssetVocabularyPersistence assetVocabularyPersistence;
1935 @BeanReference(type = GroupPersistence.class)
1936 protected GroupPersistence groupPersistence;
1937 @BeanReference(type = ResourcePersistence.class)
1938 protected ResourcePersistence resourcePersistence;
1939 @BeanReference(type = UserPersistence.class)
1940 protected UserPersistence userPersistence;
1941 private static final String _SQL_SELECT_ASSETVOCABULARY = "SELECT assetVocabulary FROM AssetVocabulary assetVocabulary";
1942 private static final String _SQL_SELECT_ASSETVOCABULARY_WHERE = "SELECT assetVocabulary FROM AssetVocabulary assetVocabulary WHERE ";
1943 private static final String _SQL_COUNT_ASSETVOCABULARY = "SELECT COUNT(assetVocabulary) FROM AssetVocabulary assetVocabulary";
1944 private static final String _SQL_COUNT_ASSETVOCABULARY_WHERE = "SELECT COUNT(assetVocabulary) FROM AssetVocabulary assetVocabulary WHERE ";
1945 private static final String _FINDER_COLUMN_UUID_UUID_1 = "assetVocabulary.uuid IS NULL";
1946 private static final String _FINDER_COLUMN_UUID_UUID_2 = "assetVocabulary.uuid = ?";
1947 private static final String _FINDER_COLUMN_UUID_UUID_3 = "(assetVocabulary.uuid IS NULL OR assetVocabulary.uuid = ?)";
1948 private static final String _FINDER_COLUMN_UUID_G_UUID_1 = "assetVocabulary.uuid IS NULL AND ";
1949 private static final String _FINDER_COLUMN_UUID_G_UUID_2 = "assetVocabulary.uuid = ? AND ";
1950 private static final String _FINDER_COLUMN_UUID_G_UUID_3 = "(assetVocabulary.uuid IS NULL OR assetVocabulary.uuid = ?) AND ";
1951 private static final String _FINDER_COLUMN_UUID_G_GROUPID_2 = "assetVocabulary.groupId = ?";
1952 private static final String _FINDER_COLUMN_GROUPID_GROUPID_2 = "assetVocabulary.groupId = ?";
1953 private static final String _FINDER_COLUMN_COMPANYID_COMPANYID_2 = "assetVocabulary.companyId = ?";
1954 private static final String _FINDER_COLUMN_G_N_GROUPID_2 = "assetVocabulary.groupId = ? AND ";
1955 private static final String _FINDER_COLUMN_G_N_NAME_1 = "assetVocabulary.name IS NULL";
1956 private static final String _FINDER_COLUMN_G_N_NAME_2 = "assetVocabulary.name = ?";
1957 private static final String _FINDER_COLUMN_G_N_NAME_3 = "(assetVocabulary.name IS NULL OR assetVocabulary.name = ?)";
1958 private static final String _ORDER_BY_ENTITY_ALIAS = "assetVocabulary.";
1959 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No AssetVocabulary exists with the primary key ";
1960 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No AssetVocabulary exists with the key {";
1961 private static Log _log = LogFactoryUtil.getLog(AssetVocabularyPersistenceImpl.class);
1962}