001
014
015 package com.liferay.portlet.asset.service.persistence;
016
017 import com.liferay.portal.NoSuchModelException;
018 import com.liferay.portal.kernel.cache.CacheRegistryUtil;
019 import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
020 import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
021 import com.liferay.portal.kernel.dao.orm.FinderPath;
022 import com.liferay.portal.kernel.dao.orm.Query;
023 import com.liferay.portal.kernel.dao.orm.QueryPos;
024 import com.liferay.portal.kernel.dao.orm.QueryUtil;
025 import com.liferay.portal.kernel.dao.orm.SQLQuery;
026 import com.liferay.portal.kernel.dao.orm.Session;
027 import com.liferay.portal.kernel.exception.SystemException;
028 import com.liferay.portal.kernel.log.Log;
029 import com.liferay.portal.kernel.log.LogFactoryUtil;
030 import com.liferay.portal.kernel.util.GetterUtil;
031 import com.liferay.portal.kernel.util.InstanceFactory;
032 import com.liferay.portal.kernel.util.OrderByComparator;
033 import com.liferay.portal.kernel.util.StringBundler;
034 import com.liferay.portal.kernel.util.StringPool;
035 import com.liferay.portal.kernel.util.StringUtil;
036 import com.liferay.portal.kernel.util.UnmodifiableList;
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.impl.BasePersistenceImpl;
043
044 import com.liferay.portlet.asset.NoSuchVocabularyException;
045 import com.liferay.portlet.asset.model.AssetVocabulary;
046 import com.liferay.portlet.asset.model.impl.AssetVocabularyImpl;
047 import com.liferay.portlet.asset.model.impl.AssetVocabularyModelImpl;
048
049 import java.io.Serializable;
050
051 import java.util.ArrayList;
052 import java.util.Collections;
053 import java.util.List;
054
055
067 public class AssetVocabularyPersistenceImpl extends BasePersistenceImpl<AssetVocabulary>
068 implements AssetVocabularyPersistence {
069
074 public static final String FINDER_CLASS_NAME_ENTITY = AssetVocabularyImpl.class.getName();
075 public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
076 ".List1";
077 public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
078 ".List2";
079 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(AssetVocabularyModelImpl.ENTITY_CACHE_ENABLED,
080 AssetVocabularyModelImpl.FINDER_CACHE_ENABLED,
081 AssetVocabularyImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
082 "findAll", new String[0]);
083 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(AssetVocabularyModelImpl.ENTITY_CACHE_ENABLED,
084 AssetVocabularyModelImpl.FINDER_CACHE_ENABLED,
085 AssetVocabularyImpl.class,
086 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
087 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(AssetVocabularyModelImpl.ENTITY_CACHE_ENABLED,
088 AssetVocabularyModelImpl.FINDER_CACHE_ENABLED, Long.class,
089 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
090 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID = new FinderPath(AssetVocabularyModelImpl.ENTITY_CACHE_ENABLED,
091 AssetVocabularyModelImpl.FINDER_CACHE_ENABLED,
092 AssetVocabularyImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
093 "findByUuid",
094 new String[] {
095 String.class.getName(),
096
097 Integer.class.getName(), Integer.class.getName(),
098 OrderByComparator.class.getName()
099 });
100 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID = new FinderPath(AssetVocabularyModelImpl.ENTITY_CACHE_ENABLED,
101 AssetVocabularyModelImpl.FINDER_CACHE_ENABLED,
102 AssetVocabularyImpl.class,
103 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid",
104 new String[] { String.class.getName() },
105 AssetVocabularyModelImpl.UUID_COLUMN_BITMASK |
106 AssetVocabularyModelImpl.NAME_COLUMN_BITMASK);
107 public static final FinderPath FINDER_PATH_COUNT_BY_UUID = new FinderPath(AssetVocabularyModelImpl.ENTITY_CACHE_ENABLED,
108 AssetVocabularyModelImpl.FINDER_CACHE_ENABLED, Long.class,
109 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid",
110 new String[] { String.class.getName() });
111
112
119 public List<AssetVocabulary> findByUuid(String uuid)
120 throws SystemException {
121 return findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
122 }
123
124
137 public List<AssetVocabulary> findByUuid(String uuid, int start, int end)
138 throws SystemException {
139 return findByUuid(uuid, start, end, null);
140 }
141
142
156 public List<AssetVocabulary> findByUuid(String uuid, int start, int end,
157 OrderByComparator orderByComparator) throws SystemException {
158 boolean pagination = true;
159 FinderPath finderPath = null;
160 Object[] finderArgs = null;
161
162 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
163 (orderByComparator == null)) {
164 pagination = false;
165 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID;
166 finderArgs = new Object[] { uuid };
167 }
168 else {
169 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID;
170 finderArgs = new Object[] { uuid, start, end, orderByComparator };
171 }
172
173 List<AssetVocabulary> list = (List<AssetVocabulary>)FinderCacheUtil.getResult(finderPath,
174 finderArgs, this);
175
176 if ((list != null) && !list.isEmpty()) {
177 for (AssetVocabulary assetVocabulary : list) {
178 if (!Validator.equals(uuid, assetVocabulary.getUuid())) {
179 list = null;
180
181 break;
182 }
183 }
184 }
185
186 if (list == null) {
187 StringBundler query = null;
188
189 if (orderByComparator != null) {
190 query = new StringBundler(3 +
191 (orderByComparator.getOrderByFields().length * 3));
192 }
193 else {
194 query = new StringBundler(3);
195 }
196
197 query.append(_SQL_SELECT_ASSETVOCABULARY_WHERE);
198
199 if (uuid == null) {
200 query.append(_FINDER_COLUMN_UUID_UUID_1);
201 }
202 else {
203 if (uuid.equals(StringPool.BLANK)) {
204 query.append(_FINDER_COLUMN_UUID_UUID_3);
205 }
206 else {
207 query.append(_FINDER_COLUMN_UUID_UUID_2);
208 }
209 }
210
211 if (orderByComparator != null) {
212 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
213 orderByComparator);
214 }
215 else
216 if (pagination) {
217 query.append(AssetVocabularyModelImpl.ORDER_BY_JPQL);
218 }
219
220 String sql = query.toString();
221
222 Session session = null;
223
224 try {
225 session = openSession();
226
227 Query q = session.createQuery(sql);
228
229 QueryPos qPos = QueryPos.getInstance(q);
230
231 if (uuid != null) {
232 qPos.add(uuid);
233 }
234
235 if (!pagination) {
236 list = (List<AssetVocabulary>)QueryUtil.list(q,
237 getDialect(), start, end, false);
238
239 Collections.sort(list);
240
241 list = new UnmodifiableList<AssetVocabulary>(list);
242 }
243 else {
244 list = (List<AssetVocabulary>)QueryUtil.list(q,
245 getDialect(), start, end);
246 }
247
248 cacheResult(list);
249
250 FinderCacheUtil.putResult(finderPath, finderArgs, list);
251 }
252 catch (Exception e) {
253 FinderCacheUtil.removeResult(finderPath, finderArgs);
254
255 throw processException(e);
256 }
257 finally {
258 closeSession(session);
259 }
260 }
261
262 return list;
263 }
264
265
274 public AssetVocabulary findByUuid_First(String uuid,
275 OrderByComparator orderByComparator)
276 throws NoSuchVocabularyException, SystemException {
277 AssetVocabulary assetVocabulary = fetchByUuid_First(uuid,
278 orderByComparator);
279
280 if (assetVocabulary != null) {
281 return assetVocabulary;
282 }
283
284 StringBundler msg = new StringBundler(4);
285
286 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
287
288 msg.append("uuid=");
289 msg.append(uuid);
290
291 msg.append(StringPool.CLOSE_CURLY_BRACE);
292
293 throw new NoSuchVocabularyException(msg.toString());
294 }
295
296
304 public AssetVocabulary fetchByUuid_First(String uuid,
305 OrderByComparator orderByComparator) throws SystemException {
306 List<AssetVocabulary> list = findByUuid(uuid, 0, 1, orderByComparator);
307
308 if (!list.isEmpty()) {
309 return list.get(0);
310 }
311
312 return null;
313 }
314
315
324 public AssetVocabulary findByUuid_Last(String uuid,
325 OrderByComparator orderByComparator)
326 throws NoSuchVocabularyException, SystemException {
327 AssetVocabulary assetVocabulary = fetchByUuid_Last(uuid,
328 orderByComparator);
329
330 if (assetVocabulary != null) {
331 return assetVocabulary;
332 }
333
334 StringBundler msg = new StringBundler(4);
335
336 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
337
338 msg.append("uuid=");
339 msg.append(uuid);
340
341 msg.append(StringPool.CLOSE_CURLY_BRACE);
342
343 throw new NoSuchVocabularyException(msg.toString());
344 }
345
346
354 public AssetVocabulary fetchByUuid_Last(String uuid,
355 OrderByComparator orderByComparator) throws SystemException {
356 int count = countByUuid(uuid);
357
358 List<AssetVocabulary> list = findByUuid(uuid, count - 1, count,
359 orderByComparator);
360
361 if (!list.isEmpty()) {
362 return list.get(0);
363 }
364
365 return null;
366 }
367
368
378 public AssetVocabulary[] findByUuid_PrevAndNext(long vocabularyId,
379 String uuid, OrderByComparator orderByComparator)
380 throws NoSuchVocabularyException, SystemException {
381 AssetVocabulary assetVocabulary = findByPrimaryKey(vocabularyId);
382
383 Session session = null;
384
385 try {
386 session = openSession();
387
388 AssetVocabulary[] array = new AssetVocabularyImpl[3];
389
390 array[0] = getByUuid_PrevAndNext(session, assetVocabulary, uuid,
391 orderByComparator, true);
392
393 array[1] = assetVocabulary;
394
395 array[2] = getByUuid_PrevAndNext(session, assetVocabulary, uuid,
396 orderByComparator, false);
397
398 return array;
399 }
400 catch (Exception e) {
401 throw processException(e);
402 }
403 finally {
404 closeSession(session);
405 }
406 }
407
408 protected AssetVocabulary getByUuid_PrevAndNext(Session session,
409 AssetVocabulary assetVocabulary, String uuid,
410 OrderByComparator orderByComparator, boolean previous) {
411 StringBundler query = null;
412
413 if (orderByComparator != null) {
414 query = new StringBundler(6 +
415 (orderByComparator.getOrderByFields().length * 6));
416 }
417 else {
418 query = new StringBundler(3);
419 }
420
421 query.append(_SQL_SELECT_ASSETVOCABULARY_WHERE);
422
423 if (uuid == null) {
424 query.append(_FINDER_COLUMN_UUID_UUID_1);
425 }
426 else {
427 if (uuid.equals(StringPool.BLANK)) {
428 query.append(_FINDER_COLUMN_UUID_UUID_3);
429 }
430 else {
431 query.append(_FINDER_COLUMN_UUID_UUID_2);
432 }
433 }
434
435 if (orderByComparator != null) {
436 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
437
438 if (orderByConditionFields.length > 0) {
439 query.append(WHERE_AND);
440 }
441
442 for (int i = 0; i < orderByConditionFields.length; i++) {
443 query.append(_ORDER_BY_ENTITY_ALIAS);
444 query.append(orderByConditionFields[i]);
445
446 if ((i + 1) < orderByConditionFields.length) {
447 if (orderByComparator.isAscending() ^ previous) {
448 query.append(WHERE_GREATER_THAN_HAS_NEXT);
449 }
450 else {
451 query.append(WHERE_LESSER_THAN_HAS_NEXT);
452 }
453 }
454 else {
455 if (orderByComparator.isAscending() ^ previous) {
456 query.append(WHERE_GREATER_THAN);
457 }
458 else {
459 query.append(WHERE_LESSER_THAN);
460 }
461 }
462 }
463
464 query.append(ORDER_BY_CLAUSE);
465
466 String[] orderByFields = orderByComparator.getOrderByFields();
467
468 for (int i = 0; i < orderByFields.length; i++) {
469 query.append(_ORDER_BY_ENTITY_ALIAS);
470 query.append(orderByFields[i]);
471
472 if ((i + 1) < orderByFields.length) {
473 if (orderByComparator.isAscending() ^ previous) {
474 query.append(ORDER_BY_ASC_HAS_NEXT);
475 }
476 else {
477 query.append(ORDER_BY_DESC_HAS_NEXT);
478 }
479 }
480 else {
481 if (orderByComparator.isAscending() ^ previous) {
482 query.append(ORDER_BY_ASC);
483 }
484 else {
485 query.append(ORDER_BY_DESC);
486 }
487 }
488 }
489 }
490 else {
491 query.append(AssetVocabularyModelImpl.ORDER_BY_JPQL);
492 }
493
494 String sql = query.toString();
495
496 Query q = session.createQuery(sql);
497
498 q.setFirstResult(0);
499 q.setMaxResults(2);
500
501 QueryPos qPos = QueryPos.getInstance(q);
502
503 if (uuid != null) {
504 qPos.add(uuid);
505 }
506
507 if (orderByComparator != null) {
508 Object[] values = orderByComparator.getOrderByConditionValues(assetVocabulary);
509
510 for (Object value : values) {
511 qPos.add(value);
512 }
513 }
514
515 List<AssetVocabulary> list = q.list();
516
517 if (list.size() == 2) {
518 return list.get(1);
519 }
520 else {
521 return null;
522 }
523 }
524
525
531 public void removeByUuid(String uuid) throws SystemException {
532 for (AssetVocabulary assetVocabulary : findByUuid(uuid,
533 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
534 remove(assetVocabulary);
535 }
536 }
537
538
545 public int countByUuid(String uuid) throws SystemException {
546 FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID;
547
548 Object[] finderArgs = new Object[] { uuid };
549
550 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
551 this);
552
553 if (count == null) {
554 StringBundler query = new StringBundler(2);
555
556 query.append(_SQL_COUNT_ASSETVOCABULARY_WHERE);
557
558 if (uuid == null) {
559 query.append(_FINDER_COLUMN_UUID_UUID_1);
560 }
561 else {
562 if (uuid.equals(StringPool.BLANK)) {
563 query.append(_FINDER_COLUMN_UUID_UUID_3);
564 }
565 else {
566 query.append(_FINDER_COLUMN_UUID_UUID_2);
567 }
568 }
569
570 String sql = query.toString();
571
572 Session session = null;
573
574 try {
575 session = openSession();
576
577 Query q = session.createQuery(sql);
578
579 QueryPos qPos = QueryPos.getInstance(q);
580
581 if (uuid != null) {
582 qPos.add(uuid);
583 }
584
585 count = (Long)q.uniqueResult();
586
587 FinderCacheUtil.putResult(finderPath, finderArgs, count);
588 }
589 catch (Exception e) {
590 FinderCacheUtil.removeResult(finderPath, finderArgs);
591
592 throw processException(e);
593 }
594 finally {
595 closeSession(session);
596 }
597 }
598
599 return count.intValue();
600 }
601
602 private static final String _FINDER_COLUMN_UUID_UUID_1 = "assetVocabulary.uuid IS NULL";
603 private static final String _FINDER_COLUMN_UUID_UUID_2 = "assetVocabulary.uuid = ?";
604 private static final String _FINDER_COLUMN_UUID_UUID_3 = "(assetVocabulary.uuid IS NULL OR assetVocabulary.uuid = ?)";
605 public static final FinderPath FINDER_PATH_FETCH_BY_UUID_G = new FinderPath(AssetVocabularyModelImpl.ENTITY_CACHE_ENABLED,
606 AssetVocabularyModelImpl.FINDER_CACHE_ENABLED,
607 AssetVocabularyImpl.class, FINDER_CLASS_NAME_ENTITY,
608 "fetchByUUID_G",
609 new String[] { String.class.getName(), Long.class.getName() },
610 AssetVocabularyModelImpl.UUID_COLUMN_BITMASK |
611 AssetVocabularyModelImpl.GROUPID_COLUMN_BITMASK);
612 public static final FinderPath FINDER_PATH_COUNT_BY_UUID_G = new FinderPath(AssetVocabularyModelImpl.ENTITY_CACHE_ENABLED,
613 AssetVocabularyModelImpl.FINDER_CACHE_ENABLED, Long.class,
614 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUUID_G",
615 new String[] { String.class.getName(), Long.class.getName() });
616
617
626 public AssetVocabulary findByUUID_G(String uuid, long groupId)
627 throws NoSuchVocabularyException, SystemException {
628 AssetVocabulary assetVocabulary = fetchByUUID_G(uuid, groupId);
629
630 if (assetVocabulary == null) {
631 StringBundler msg = new StringBundler(6);
632
633 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
634
635 msg.append("uuid=");
636 msg.append(uuid);
637
638 msg.append(", groupId=");
639 msg.append(groupId);
640
641 msg.append(StringPool.CLOSE_CURLY_BRACE);
642
643 if (_log.isWarnEnabled()) {
644 _log.warn(msg.toString());
645 }
646
647 throw new NoSuchVocabularyException(msg.toString());
648 }
649
650 return assetVocabulary;
651 }
652
653
661 public AssetVocabulary fetchByUUID_G(String uuid, long groupId)
662 throws SystemException {
663 return fetchByUUID_G(uuid, groupId, true);
664 }
665
666
675 public AssetVocabulary fetchByUUID_G(String uuid, long groupId,
676 boolean retrieveFromCache) throws SystemException {
677 Object[] finderArgs = new Object[] { uuid, groupId };
678
679 Object result = null;
680
681 if (retrieveFromCache) {
682 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_UUID_G,
683 finderArgs, this);
684 }
685
686 if (result instanceof AssetVocabulary) {
687 AssetVocabulary assetVocabulary = (AssetVocabulary)result;
688
689 if (!Validator.equals(uuid, assetVocabulary.getUuid()) ||
690 (groupId != assetVocabulary.getGroupId())) {
691 result = null;
692 }
693 }
694
695 if (result == null) {
696 StringBundler query = new StringBundler(4);
697
698 query.append(_SQL_SELECT_ASSETVOCABULARY_WHERE);
699
700 if (uuid == null) {
701 query.append(_FINDER_COLUMN_UUID_G_UUID_1);
702 }
703 else {
704 if (uuid.equals(StringPool.BLANK)) {
705 query.append(_FINDER_COLUMN_UUID_G_UUID_3);
706 }
707 else {
708 query.append(_FINDER_COLUMN_UUID_G_UUID_2);
709 }
710 }
711
712 query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
713
714 String sql = query.toString();
715
716 Session session = null;
717
718 try {
719 session = openSession();
720
721 Query q = session.createQuery(sql);
722
723 QueryPos qPos = QueryPos.getInstance(q);
724
725 if (uuid != null) {
726 qPos.add(uuid);
727 }
728
729 qPos.add(groupId);
730
731 List<AssetVocabulary> list = q.list();
732
733 if (list.isEmpty()) {
734 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
735 finderArgs, list);
736 }
737 else {
738 AssetVocabulary assetVocabulary = list.get(0);
739
740 result = assetVocabulary;
741
742 cacheResult(assetVocabulary);
743
744 if ((assetVocabulary.getUuid() == null) ||
745 !assetVocabulary.getUuid().equals(uuid) ||
746 (assetVocabulary.getGroupId() != groupId)) {
747 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
748 finderArgs, assetVocabulary);
749 }
750 }
751 }
752 catch (Exception e) {
753 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
754 finderArgs);
755
756 throw processException(e);
757 }
758 finally {
759 closeSession(session);
760 }
761 }
762
763 if (result instanceof List<?>) {
764 return null;
765 }
766 else {
767 return (AssetVocabulary)result;
768 }
769 }
770
771
779 public AssetVocabulary removeByUUID_G(String uuid, long groupId)
780 throws NoSuchVocabularyException, SystemException {
781 AssetVocabulary assetVocabulary = findByUUID_G(uuid, groupId);
782
783 return remove(assetVocabulary);
784 }
785
786
794 public int countByUUID_G(String uuid, long groupId)
795 throws SystemException {
796 FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID_G;
797
798 Object[] finderArgs = new Object[] { uuid, groupId };
799
800 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
801 this);
802
803 if (count == null) {
804 StringBundler query = new StringBundler(3);
805
806 query.append(_SQL_COUNT_ASSETVOCABULARY_WHERE);
807
808 if (uuid == null) {
809 query.append(_FINDER_COLUMN_UUID_G_UUID_1);
810 }
811 else {
812 if (uuid.equals(StringPool.BLANK)) {
813 query.append(_FINDER_COLUMN_UUID_G_UUID_3);
814 }
815 else {
816 query.append(_FINDER_COLUMN_UUID_G_UUID_2);
817 }
818 }
819
820 query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
821
822 String sql = query.toString();
823
824 Session session = null;
825
826 try {
827 session = openSession();
828
829 Query q = session.createQuery(sql);
830
831 QueryPos qPos = QueryPos.getInstance(q);
832
833 if (uuid != null) {
834 qPos.add(uuid);
835 }
836
837 qPos.add(groupId);
838
839 count = (Long)q.uniqueResult();
840
841 FinderCacheUtil.putResult(finderPath, finderArgs, count);
842 }
843 catch (Exception e) {
844 FinderCacheUtil.removeResult(finderPath, finderArgs);
845
846 throw processException(e);
847 }
848 finally {
849 closeSession(session);
850 }
851 }
852
853 return count.intValue();
854 }
855
856 private static final String _FINDER_COLUMN_UUID_G_UUID_1 = "assetVocabulary.uuid IS NULL AND ";
857 private static final String _FINDER_COLUMN_UUID_G_UUID_2 = "assetVocabulary.uuid = ? AND ";
858 private static final String _FINDER_COLUMN_UUID_G_UUID_3 = "(assetVocabulary.uuid IS NULL OR assetVocabulary.uuid = ?) AND ";
859 private static final String _FINDER_COLUMN_UUID_G_GROUPID_2 = "assetVocabulary.groupId = ?";
860 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID_C = new FinderPath(AssetVocabularyModelImpl.ENTITY_CACHE_ENABLED,
861 AssetVocabularyModelImpl.FINDER_CACHE_ENABLED,
862 AssetVocabularyImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
863 "findByUuid_C",
864 new String[] {
865 String.class.getName(), Long.class.getName(),
866
867 Integer.class.getName(), Integer.class.getName(),
868 OrderByComparator.class.getName()
869 });
870 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C =
871 new FinderPath(AssetVocabularyModelImpl.ENTITY_CACHE_ENABLED,
872 AssetVocabularyModelImpl.FINDER_CACHE_ENABLED,
873 AssetVocabularyImpl.class,
874 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid_C",
875 new String[] { String.class.getName(), Long.class.getName() },
876 AssetVocabularyModelImpl.UUID_COLUMN_BITMASK |
877 AssetVocabularyModelImpl.COMPANYID_COLUMN_BITMASK |
878 AssetVocabularyModelImpl.NAME_COLUMN_BITMASK);
879 public static final FinderPath FINDER_PATH_COUNT_BY_UUID_C = new FinderPath(AssetVocabularyModelImpl.ENTITY_CACHE_ENABLED,
880 AssetVocabularyModelImpl.FINDER_CACHE_ENABLED, Long.class,
881 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid_C",
882 new String[] { String.class.getName(), Long.class.getName() });
883
884
892 public List<AssetVocabulary> findByUuid_C(String uuid, long companyId)
893 throws SystemException {
894 return findByUuid_C(uuid, companyId, QueryUtil.ALL_POS,
895 QueryUtil.ALL_POS, null);
896 }
897
898
912 public List<AssetVocabulary> findByUuid_C(String uuid, long companyId,
913 int start, int end) throws SystemException {
914 return findByUuid_C(uuid, companyId, start, end, null);
915 }
916
917
932 public List<AssetVocabulary> findByUuid_C(String uuid, long companyId,
933 int start, int end, OrderByComparator orderByComparator)
934 throws SystemException {
935 boolean pagination = true;
936 FinderPath finderPath = null;
937 Object[] finderArgs = null;
938
939 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
940 (orderByComparator == null)) {
941 pagination = false;
942 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C;
943 finderArgs = new Object[] { uuid, companyId };
944 }
945 else {
946 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID_C;
947 finderArgs = new Object[] {
948 uuid, companyId,
949
950 start, end, orderByComparator
951 };
952 }
953
954 List<AssetVocabulary> list = (List<AssetVocabulary>)FinderCacheUtil.getResult(finderPath,
955 finderArgs, this);
956
957 if ((list != null) && !list.isEmpty()) {
958 for (AssetVocabulary assetVocabulary : list) {
959 if (!Validator.equals(uuid, assetVocabulary.getUuid()) ||
960 (companyId != assetVocabulary.getCompanyId())) {
961 list = null;
962
963 break;
964 }
965 }
966 }
967
968 if (list == null) {
969 StringBundler query = null;
970
971 if (orderByComparator != null) {
972 query = new StringBundler(4 +
973 (orderByComparator.getOrderByFields().length * 3));
974 }
975 else {
976 query = new StringBundler(4);
977 }
978
979 query.append(_SQL_SELECT_ASSETVOCABULARY_WHERE);
980
981 if (uuid == null) {
982 query.append(_FINDER_COLUMN_UUID_C_UUID_1);
983 }
984 else {
985 if (uuid.equals(StringPool.BLANK)) {
986 query.append(_FINDER_COLUMN_UUID_C_UUID_3);
987 }
988 else {
989 query.append(_FINDER_COLUMN_UUID_C_UUID_2);
990 }
991 }
992
993 query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
994
995 if (orderByComparator != null) {
996 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
997 orderByComparator);
998 }
999 else
1000 if (pagination) {
1001 query.append(AssetVocabularyModelImpl.ORDER_BY_JPQL);
1002 }
1003
1004 String sql = query.toString();
1005
1006 Session session = null;
1007
1008 try {
1009 session = openSession();
1010
1011 Query q = session.createQuery(sql);
1012
1013 QueryPos qPos = QueryPos.getInstance(q);
1014
1015 if (uuid != null) {
1016 qPos.add(uuid);
1017 }
1018
1019 qPos.add(companyId);
1020
1021 if (!pagination) {
1022 list = (List<AssetVocabulary>)QueryUtil.list(q,
1023 getDialect(), start, end, false);
1024
1025 Collections.sort(list);
1026
1027 list = new UnmodifiableList<AssetVocabulary>(list);
1028 }
1029 else {
1030 list = (List<AssetVocabulary>)QueryUtil.list(q,
1031 getDialect(), start, end);
1032 }
1033
1034 cacheResult(list);
1035
1036 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1037 }
1038 catch (Exception e) {
1039 FinderCacheUtil.removeResult(finderPath, finderArgs);
1040
1041 throw processException(e);
1042 }
1043 finally {
1044 closeSession(session);
1045 }
1046 }
1047
1048 return list;
1049 }
1050
1051
1061 public AssetVocabulary findByUuid_C_First(String uuid, long companyId,
1062 OrderByComparator orderByComparator)
1063 throws NoSuchVocabularyException, SystemException {
1064 AssetVocabulary assetVocabulary = fetchByUuid_C_First(uuid, companyId,
1065 orderByComparator);
1066
1067 if (assetVocabulary != null) {
1068 return assetVocabulary;
1069 }
1070
1071 StringBundler msg = new StringBundler(6);
1072
1073 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1074
1075 msg.append("uuid=");
1076 msg.append(uuid);
1077
1078 msg.append(", companyId=");
1079 msg.append(companyId);
1080
1081 msg.append(StringPool.CLOSE_CURLY_BRACE);
1082
1083 throw new NoSuchVocabularyException(msg.toString());
1084 }
1085
1086
1095 public AssetVocabulary fetchByUuid_C_First(String uuid, long companyId,
1096 OrderByComparator orderByComparator) throws SystemException {
1097 List<AssetVocabulary> list = findByUuid_C(uuid, companyId, 0, 1,
1098 orderByComparator);
1099
1100 if (!list.isEmpty()) {
1101 return list.get(0);
1102 }
1103
1104 return null;
1105 }
1106
1107
1117 public AssetVocabulary findByUuid_C_Last(String uuid, long companyId,
1118 OrderByComparator orderByComparator)
1119 throws NoSuchVocabularyException, SystemException {
1120 AssetVocabulary assetVocabulary = fetchByUuid_C_Last(uuid, companyId,
1121 orderByComparator);
1122
1123 if (assetVocabulary != null) {
1124 return assetVocabulary;
1125 }
1126
1127 StringBundler msg = new StringBundler(6);
1128
1129 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1130
1131 msg.append("uuid=");
1132 msg.append(uuid);
1133
1134 msg.append(", companyId=");
1135 msg.append(companyId);
1136
1137 msg.append(StringPool.CLOSE_CURLY_BRACE);
1138
1139 throw new NoSuchVocabularyException(msg.toString());
1140 }
1141
1142
1151 public AssetVocabulary fetchByUuid_C_Last(String uuid, long companyId,
1152 OrderByComparator orderByComparator) throws SystemException {
1153 int count = countByUuid_C(uuid, companyId);
1154
1155 List<AssetVocabulary> list = findByUuid_C(uuid, companyId, count - 1,
1156 count, orderByComparator);
1157
1158 if (!list.isEmpty()) {
1159 return list.get(0);
1160 }
1161
1162 return null;
1163 }
1164
1165
1176 public AssetVocabulary[] findByUuid_C_PrevAndNext(long vocabularyId,
1177 String uuid, long companyId, OrderByComparator orderByComparator)
1178 throws NoSuchVocabularyException, SystemException {
1179 AssetVocabulary assetVocabulary = findByPrimaryKey(vocabularyId);
1180
1181 Session session = null;
1182
1183 try {
1184 session = openSession();
1185
1186 AssetVocabulary[] array = new AssetVocabularyImpl[3];
1187
1188 array[0] = getByUuid_C_PrevAndNext(session, assetVocabulary, uuid,
1189 companyId, orderByComparator, true);
1190
1191 array[1] = assetVocabulary;
1192
1193 array[2] = getByUuid_C_PrevAndNext(session, assetVocabulary, uuid,
1194 companyId, orderByComparator, false);
1195
1196 return array;
1197 }
1198 catch (Exception e) {
1199 throw processException(e);
1200 }
1201 finally {
1202 closeSession(session);
1203 }
1204 }
1205
1206 protected AssetVocabulary getByUuid_C_PrevAndNext(Session session,
1207 AssetVocabulary assetVocabulary, String uuid, long companyId,
1208 OrderByComparator orderByComparator, boolean previous) {
1209 StringBundler query = null;
1210
1211 if (orderByComparator != null) {
1212 query = new StringBundler(6 +
1213 (orderByComparator.getOrderByFields().length * 6));
1214 }
1215 else {
1216 query = new StringBundler(3);
1217 }
1218
1219 query.append(_SQL_SELECT_ASSETVOCABULARY_WHERE);
1220
1221 if (uuid == null) {
1222 query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1223 }
1224 else {
1225 if (uuid.equals(StringPool.BLANK)) {
1226 query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1227 }
1228 else {
1229 query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1230 }
1231 }
1232
1233 query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1234
1235 if (orderByComparator != null) {
1236 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1237
1238 if (orderByConditionFields.length > 0) {
1239 query.append(WHERE_AND);
1240 }
1241
1242 for (int i = 0; i < orderByConditionFields.length; i++) {
1243 query.append(_ORDER_BY_ENTITY_ALIAS);
1244 query.append(orderByConditionFields[i]);
1245
1246 if ((i + 1) < orderByConditionFields.length) {
1247 if (orderByComparator.isAscending() ^ previous) {
1248 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1249 }
1250 else {
1251 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1252 }
1253 }
1254 else {
1255 if (orderByComparator.isAscending() ^ previous) {
1256 query.append(WHERE_GREATER_THAN);
1257 }
1258 else {
1259 query.append(WHERE_LESSER_THAN);
1260 }
1261 }
1262 }
1263
1264 query.append(ORDER_BY_CLAUSE);
1265
1266 String[] orderByFields = orderByComparator.getOrderByFields();
1267
1268 for (int i = 0; i < orderByFields.length; i++) {
1269 query.append(_ORDER_BY_ENTITY_ALIAS);
1270 query.append(orderByFields[i]);
1271
1272 if ((i + 1) < orderByFields.length) {
1273 if (orderByComparator.isAscending() ^ previous) {
1274 query.append(ORDER_BY_ASC_HAS_NEXT);
1275 }
1276 else {
1277 query.append(ORDER_BY_DESC_HAS_NEXT);
1278 }
1279 }
1280 else {
1281 if (orderByComparator.isAscending() ^ previous) {
1282 query.append(ORDER_BY_ASC);
1283 }
1284 else {
1285 query.append(ORDER_BY_DESC);
1286 }
1287 }
1288 }
1289 }
1290 else {
1291 query.append(AssetVocabularyModelImpl.ORDER_BY_JPQL);
1292 }
1293
1294 String sql = query.toString();
1295
1296 Query q = session.createQuery(sql);
1297
1298 q.setFirstResult(0);
1299 q.setMaxResults(2);
1300
1301 QueryPos qPos = QueryPos.getInstance(q);
1302
1303 if (uuid != null) {
1304 qPos.add(uuid);
1305 }
1306
1307 qPos.add(companyId);
1308
1309 if (orderByComparator != null) {
1310 Object[] values = orderByComparator.getOrderByConditionValues(assetVocabulary);
1311
1312 for (Object value : values) {
1313 qPos.add(value);
1314 }
1315 }
1316
1317 List<AssetVocabulary> list = q.list();
1318
1319 if (list.size() == 2) {
1320 return list.get(1);
1321 }
1322 else {
1323 return null;
1324 }
1325 }
1326
1327
1334 public void removeByUuid_C(String uuid, long companyId)
1335 throws SystemException {
1336 for (AssetVocabulary assetVocabulary : findByUuid_C(uuid, companyId,
1337 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
1338 remove(assetVocabulary);
1339 }
1340 }
1341
1342
1350 public int countByUuid_C(String uuid, long companyId)
1351 throws SystemException {
1352 FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID_C;
1353
1354 Object[] finderArgs = new Object[] { uuid, companyId };
1355
1356 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
1357 this);
1358
1359 if (count == null) {
1360 StringBundler query = new StringBundler(3);
1361
1362 query.append(_SQL_COUNT_ASSETVOCABULARY_WHERE);
1363
1364 if (uuid == null) {
1365 query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1366 }
1367 else {
1368 if (uuid.equals(StringPool.BLANK)) {
1369 query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1370 }
1371 else {
1372 query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1373 }
1374 }
1375
1376 query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1377
1378 String sql = query.toString();
1379
1380 Session session = null;
1381
1382 try {
1383 session = openSession();
1384
1385 Query q = session.createQuery(sql);
1386
1387 QueryPos qPos = QueryPos.getInstance(q);
1388
1389 if (uuid != null) {
1390 qPos.add(uuid);
1391 }
1392
1393 qPos.add(companyId);
1394
1395 count = (Long)q.uniqueResult();
1396
1397 FinderCacheUtil.putResult(finderPath, finderArgs, count);
1398 }
1399 catch (Exception e) {
1400 FinderCacheUtil.removeResult(finderPath, finderArgs);
1401
1402 throw processException(e);
1403 }
1404 finally {
1405 closeSession(session);
1406 }
1407 }
1408
1409 return count.intValue();
1410 }
1411
1412 private static final String _FINDER_COLUMN_UUID_C_UUID_1 = "assetVocabulary.uuid IS NULL AND ";
1413 private static final String _FINDER_COLUMN_UUID_C_UUID_2 = "assetVocabulary.uuid = ? AND ";
1414 private static final String _FINDER_COLUMN_UUID_C_UUID_3 = "(assetVocabulary.uuid IS NULL OR assetVocabulary.uuid = ?) AND ";
1415 private static final String _FINDER_COLUMN_UUID_C_COMPANYID_2 = "assetVocabulary.companyId = ?";
1416 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID = new FinderPath(AssetVocabularyModelImpl.ENTITY_CACHE_ENABLED,
1417 AssetVocabularyModelImpl.FINDER_CACHE_ENABLED,
1418 AssetVocabularyImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
1419 "findByGroupId",
1420 new String[] {
1421 Long.class.getName(),
1422
1423 Integer.class.getName(), Integer.class.getName(),
1424 OrderByComparator.class.getName()
1425 });
1426 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID =
1427 new FinderPath(AssetVocabularyModelImpl.ENTITY_CACHE_ENABLED,
1428 AssetVocabularyModelImpl.FINDER_CACHE_ENABLED,
1429 AssetVocabularyImpl.class,
1430 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByGroupId",
1431 new String[] { Long.class.getName() },
1432 AssetVocabularyModelImpl.GROUPID_COLUMN_BITMASK |
1433 AssetVocabularyModelImpl.NAME_COLUMN_BITMASK);
1434 public static final FinderPath FINDER_PATH_COUNT_BY_GROUPID = new FinderPath(AssetVocabularyModelImpl.ENTITY_CACHE_ENABLED,
1435 AssetVocabularyModelImpl.FINDER_CACHE_ENABLED, Long.class,
1436 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByGroupId",
1437 new String[] { Long.class.getName() });
1438
1439
1446 public List<AssetVocabulary> findByGroupId(long groupId)
1447 throws SystemException {
1448 return findByGroupId(groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1449 }
1450
1451
1464 public List<AssetVocabulary> findByGroupId(long groupId, int start, int end)
1465 throws SystemException {
1466 return findByGroupId(groupId, start, end, null);
1467 }
1468
1469
1483 public List<AssetVocabulary> findByGroupId(long groupId, int start,
1484 int end, OrderByComparator orderByComparator) throws SystemException {
1485 boolean pagination = true;
1486 FinderPath finderPath = null;
1487 Object[] finderArgs = null;
1488
1489 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1490 (orderByComparator == null)) {
1491 pagination = false;
1492 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID;
1493 finderArgs = new Object[] { groupId };
1494 }
1495 else {
1496 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID;
1497 finderArgs = new Object[] { groupId, start, end, orderByComparator };
1498 }
1499
1500 List<AssetVocabulary> list = (List<AssetVocabulary>)FinderCacheUtil.getResult(finderPath,
1501 finderArgs, this);
1502
1503 if ((list != null) && !list.isEmpty()) {
1504 for (AssetVocabulary assetVocabulary : list) {
1505 if ((groupId != assetVocabulary.getGroupId())) {
1506 list = null;
1507
1508 break;
1509 }
1510 }
1511 }
1512
1513 if (list == null) {
1514 StringBundler query = null;
1515
1516 if (orderByComparator != null) {
1517 query = new StringBundler(3 +
1518 (orderByComparator.getOrderByFields().length * 3));
1519 }
1520 else {
1521 query = new StringBundler(3);
1522 }
1523
1524 query.append(_SQL_SELECT_ASSETVOCABULARY_WHERE);
1525
1526 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1527
1528 if (orderByComparator != null) {
1529 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1530 orderByComparator);
1531 }
1532 else
1533 if (pagination) {
1534 query.append(AssetVocabularyModelImpl.ORDER_BY_JPQL);
1535 }
1536
1537 String sql = query.toString();
1538
1539 Session session = null;
1540
1541 try {
1542 session = openSession();
1543
1544 Query q = session.createQuery(sql);
1545
1546 QueryPos qPos = QueryPos.getInstance(q);
1547
1548 qPos.add(groupId);
1549
1550 if (!pagination) {
1551 list = (List<AssetVocabulary>)QueryUtil.list(q,
1552 getDialect(), start, end, false);
1553
1554 Collections.sort(list);
1555
1556 list = new UnmodifiableList<AssetVocabulary>(list);
1557 }
1558 else {
1559 list = (List<AssetVocabulary>)QueryUtil.list(q,
1560 getDialect(), start, end);
1561 }
1562
1563 cacheResult(list);
1564
1565 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1566 }
1567 catch (Exception e) {
1568 FinderCacheUtil.removeResult(finderPath, finderArgs);
1569
1570 throw processException(e);
1571 }
1572 finally {
1573 closeSession(session);
1574 }
1575 }
1576
1577 return list;
1578 }
1579
1580
1589 public AssetVocabulary findByGroupId_First(long groupId,
1590 OrderByComparator orderByComparator)
1591 throws NoSuchVocabularyException, SystemException {
1592 AssetVocabulary assetVocabulary = fetchByGroupId_First(groupId,
1593 orderByComparator);
1594
1595 if (assetVocabulary != null) {
1596 return assetVocabulary;
1597 }
1598
1599 StringBundler msg = new StringBundler(4);
1600
1601 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1602
1603 msg.append("groupId=");
1604 msg.append(groupId);
1605
1606 msg.append(StringPool.CLOSE_CURLY_BRACE);
1607
1608 throw new NoSuchVocabularyException(msg.toString());
1609 }
1610
1611
1619 public AssetVocabulary fetchByGroupId_First(long groupId,
1620 OrderByComparator orderByComparator) throws SystemException {
1621 List<AssetVocabulary> list = findByGroupId(groupId, 0, 1,
1622 orderByComparator);
1623
1624 if (!list.isEmpty()) {
1625 return list.get(0);
1626 }
1627
1628 return null;
1629 }
1630
1631
1640 public AssetVocabulary findByGroupId_Last(long groupId,
1641 OrderByComparator orderByComparator)
1642 throws NoSuchVocabularyException, SystemException {
1643 AssetVocabulary assetVocabulary = fetchByGroupId_Last(groupId,
1644 orderByComparator);
1645
1646 if (assetVocabulary != null) {
1647 return assetVocabulary;
1648 }
1649
1650 StringBundler msg = new StringBundler(4);
1651
1652 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1653
1654 msg.append("groupId=");
1655 msg.append(groupId);
1656
1657 msg.append(StringPool.CLOSE_CURLY_BRACE);
1658
1659 throw new NoSuchVocabularyException(msg.toString());
1660 }
1661
1662
1670 public AssetVocabulary fetchByGroupId_Last(long groupId,
1671 OrderByComparator orderByComparator) throws SystemException {
1672 int count = countByGroupId(groupId);
1673
1674 List<AssetVocabulary> list = findByGroupId(groupId, count - 1, count,
1675 orderByComparator);
1676
1677 if (!list.isEmpty()) {
1678 return list.get(0);
1679 }
1680
1681 return null;
1682 }
1683
1684
1694 public AssetVocabulary[] findByGroupId_PrevAndNext(long vocabularyId,
1695 long groupId, OrderByComparator orderByComparator)
1696 throws NoSuchVocabularyException, SystemException {
1697 AssetVocabulary assetVocabulary = findByPrimaryKey(vocabularyId);
1698
1699 Session session = null;
1700
1701 try {
1702 session = openSession();
1703
1704 AssetVocabulary[] array = new AssetVocabularyImpl[3];
1705
1706 array[0] = getByGroupId_PrevAndNext(session, assetVocabulary,
1707 groupId, orderByComparator, true);
1708
1709 array[1] = assetVocabulary;
1710
1711 array[2] = getByGroupId_PrevAndNext(session, assetVocabulary,
1712 groupId, orderByComparator, false);
1713
1714 return array;
1715 }
1716 catch (Exception e) {
1717 throw processException(e);
1718 }
1719 finally {
1720 closeSession(session);
1721 }
1722 }
1723
1724 protected AssetVocabulary getByGroupId_PrevAndNext(Session session,
1725 AssetVocabulary assetVocabulary, long groupId,
1726 OrderByComparator orderByComparator, boolean previous) {
1727 StringBundler query = null;
1728
1729 if (orderByComparator != null) {
1730 query = new StringBundler(6 +
1731 (orderByComparator.getOrderByFields().length * 6));
1732 }
1733 else {
1734 query = new StringBundler(3);
1735 }
1736
1737 query.append(_SQL_SELECT_ASSETVOCABULARY_WHERE);
1738
1739 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1740
1741 if (orderByComparator != null) {
1742 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1743
1744 if (orderByConditionFields.length > 0) {
1745 query.append(WHERE_AND);
1746 }
1747
1748 for (int i = 0; i < orderByConditionFields.length; i++) {
1749 query.append(_ORDER_BY_ENTITY_ALIAS);
1750 query.append(orderByConditionFields[i]);
1751
1752 if ((i + 1) < orderByConditionFields.length) {
1753 if (orderByComparator.isAscending() ^ previous) {
1754 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1755 }
1756 else {
1757 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1758 }
1759 }
1760 else {
1761 if (orderByComparator.isAscending() ^ previous) {
1762 query.append(WHERE_GREATER_THAN);
1763 }
1764 else {
1765 query.append(WHERE_LESSER_THAN);
1766 }
1767 }
1768 }
1769
1770 query.append(ORDER_BY_CLAUSE);
1771
1772 String[] orderByFields = orderByComparator.getOrderByFields();
1773
1774 for (int i = 0; i < orderByFields.length; i++) {
1775 query.append(_ORDER_BY_ENTITY_ALIAS);
1776 query.append(orderByFields[i]);
1777
1778 if ((i + 1) < orderByFields.length) {
1779 if (orderByComparator.isAscending() ^ previous) {
1780 query.append(ORDER_BY_ASC_HAS_NEXT);
1781 }
1782 else {
1783 query.append(ORDER_BY_DESC_HAS_NEXT);
1784 }
1785 }
1786 else {
1787 if (orderByComparator.isAscending() ^ previous) {
1788 query.append(ORDER_BY_ASC);
1789 }
1790 else {
1791 query.append(ORDER_BY_DESC);
1792 }
1793 }
1794 }
1795 }
1796 else {
1797 query.append(AssetVocabularyModelImpl.ORDER_BY_JPQL);
1798 }
1799
1800 String sql = query.toString();
1801
1802 Query q = session.createQuery(sql);
1803
1804 q.setFirstResult(0);
1805 q.setMaxResults(2);
1806
1807 QueryPos qPos = QueryPos.getInstance(q);
1808
1809 qPos.add(groupId);
1810
1811 if (orderByComparator != null) {
1812 Object[] values = orderByComparator.getOrderByConditionValues(assetVocabulary);
1813
1814 for (Object value : values) {
1815 qPos.add(value);
1816 }
1817 }
1818
1819 List<AssetVocabulary> list = q.list();
1820
1821 if (list.size() == 2) {
1822 return list.get(1);
1823 }
1824 else {
1825 return null;
1826 }
1827 }
1828
1829
1836 public List<AssetVocabulary> filterFindByGroupId(long groupId)
1837 throws SystemException {
1838 return filterFindByGroupId(groupId, QueryUtil.ALL_POS,
1839 QueryUtil.ALL_POS, null);
1840 }
1841
1842
1855 public List<AssetVocabulary> filterFindByGroupId(long groupId, int start,
1856 int end) throws SystemException {
1857 return filterFindByGroupId(groupId, start, end, null);
1858 }
1859
1860
1874 public List<AssetVocabulary> filterFindByGroupId(long groupId, int start,
1875 int end, OrderByComparator orderByComparator) throws SystemException {
1876 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
1877 return findByGroupId(groupId, start, end, orderByComparator);
1878 }
1879
1880 StringBundler query = null;
1881
1882 if (orderByComparator != null) {
1883 query = new StringBundler(3 +
1884 (orderByComparator.getOrderByFields().length * 3));
1885 }
1886 else {
1887 query = new StringBundler(3);
1888 }
1889
1890 if (getDB().isSupportsInlineDistinct()) {
1891 query.append(_FILTER_SQL_SELECT_ASSETVOCABULARY_WHERE);
1892 }
1893 else {
1894 query.append(_FILTER_SQL_SELECT_ASSETVOCABULARY_NO_INLINE_DISTINCT_WHERE_1);
1895 }
1896
1897 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1898
1899 if (!getDB().isSupportsInlineDistinct()) {
1900 query.append(_FILTER_SQL_SELECT_ASSETVOCABULARY_NO_INLINE_DISTINCT_WHERE_2);
1901 }
1902
1903 if (orderByComparator != null) {
1904 if (getDB().isSupportsInlineDistinct()) {
1905 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1906 orderByComparator);
1907 }
1908 else {
1909 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
1910 orderByComparator);
1911 }
1912 }
1913 else {
1914 if (getDB().isSupportsInlineDistinct()) {
1915 query.append(AssetVocabularyModelImpl.ORDER_BY_JPQL);
1916 }
1917 else {
1918 query.append(AssetVocabularyModelImpl.ORDER_BY_SQL);
1919 }
1920 }
1921
1922 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1923 AssetVocabulary.class.getName(),
1924 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
1925
1926 Session session = null;
1927
1928 try {
1929 session = openSession();
1930
1931 SQLQuery q = session.createSQLQuery(sql);
1932
1933 if (getDB().isSupportsInlineDistinct()) {
1934 q.addEntity(_FILTER_ENTITY_ALIAS, AssetVocabularyImpl.class);
1935 }
1936 else {
1937 q.addEntity(_FILTER_ENTITY_TABLE, AssetVocabularyImpl.class);
1938 }
1939
1940 QueryPos qPos = QueryPos.getInstance(q);
1941
1942 qPos.add(groupId);
1943
1944 return (List<AssetVocabulary>)QueryUtil.list(q, getDialect(),
1945 start, end);
1946 }
1947 catch (Exception e) {
1948 throw processException(e);
1949 }
1950 finally {
1951 closeSession(session);
1952 }
1953 }
1954
1955
1965 public AssetVocabulary[] filterFindByGroupId_PrevAndNext(
1966 long vocabularyId, long groupId, OrderByComparator orderByComparator)
1967 throws NoSuchVocabularyException, SystemException {
1968 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
1969 return findByGroupId_PrevAndNext(vocabularyId, groupId,
1970 orderByComparator);
1971 }
1972
1973 AssetVocabulary assetVocabulary = findByPrimaryKey(vocabularyId);
1974
1975 Session session = null;
1976
1977 try {
1978 session = openSession();
1979
1980 AssetVocabulary[] array = new AssetVocabularyImpl[3];
1981
1982 array[0] = filterGetByGroupId_PrevAndNext(session, assetVocabulary,
1983 groupId, orderByComparator, true);
1984
1985 array[1] = assetVocabulary;
1986
1987 array[2] = filterGetByGroupId_PrevAndNext(session, assetVocabulary,
1988 groupId, orderByComparator, false);
1989
1990 return array;
1991 }
1992 catch (Exception e) {
1993 throw processException(e);
1994 }
1995 finally {
1996 closeSession(session);
1997 }
1998 }
1999
2000 protected AssetVocabulary filterGetByGroupId_PrevAndNext(Session session,
2001 AssetVocabulary assetVocabulary, long groupId,
2002 OrderByComparator orderByComparator, boolean previous) {
2003 StringBundler query = null;
2004
2005 if (orderByComparator != null) {
2006 query = new StringBundler(6 +
2007 (orderByComparator.getOrderByFields().length * 6));
2008 }
2009 else {
2010 query = new StringBundler(3);
2011 }
2012
2013 if (getDB().isSupportsInlineDistinct()) {
2014 query.append(_FILTER_SQL_SELECT_ASSETVOCABULARY_WHERE);
2015 }
2016 else {
2017 query.append(_FILTER_SQL_SELECT_ASSETVOCABULARY_NO_INLINE_DISTINCT_WHERE_1);
2018 }
2019
2020 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2021
2022 if (!getDB().isSupportsInlineDistinct()) {
2023 query.append(_FILTER_SQL_SELECT_ASSETVOCABULARY_NO_INLINE_DISTINCT_WHERE_2);
2024 }
2025
2026 if (orderByComparator != null) {
2027 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2028
2029 if (orderByConditionFields.length > 0) {
2030 query.append(WHERE_AND);
2031 }
2032
2033 for (int i = 0; i < orderByConditionFields.length; i++) {
2034 if (getDB().isSupportsInlineDistinct()) {
2035 query.append(_ORDER_BY_ENTITY_ALIAS);
2036 }
2037 else {
2038 query.append(_ORDER_BY_ENTITY_TABLE);
2039 }
2040
2041 query.append(orderByConditionFields[i]);
2042
2043 if ((i + 1) < orderByConditionFields.length) {
2044 if (orderByComparator.isAscending() ^ previous) {
2045 query.append(WHERE_GREATER_THAN_HAS_NEXT);
2046 }
2047 else {
2048 query.append(WHERE_LESSER_THAN_HAS_NEXT);
2049 }
2050 }
2051 else {
2052 if (orderByComparator.isAscending() ^ previous) {
2053 query.append(WHERE_GREATER_THAN);
2054 }
2055 else {
2056 query.append(WHERE_LESSER_THAN);
2057 }
2058 }
2059 }
2060
2061 query.append(ORDER_BY_CLAUSE);
2062
2063 String[] orderByFields = orderByComparator.getOrderByFields();
2064
2065 for (int i = 0; i < orderByFields.length; i++) {
2066 if (getDB().isSupportsInlineDistinct()) {
2067 query.append(_ORDER_BY_ENTITY_ALIAS);
2068 }
2069 else {
2070 query.append(_ORDER_BY_ENTITY_TABLE);
2071 }
2072
2073 query.append(orderByFields[i]);
2074
2075 if ((i + 1) < orderByFields.length) {
2076 if (orderByComparator.isAscending() ^ previous) {
2077 query.append(ORDER_BY_ASC_HAS_NEXT);
2078 }
2079 else {
2080 query.append(ORDER_BY_DESC_HAS_NEXT);
2081 }
2082 }
2083 else {
2084 if (orderByComparator.isAscending() ^ previous) {
2085 query.append(ORDER_BY_ASC);
2086 }
2087 else {
2088 query.append(ORDER_BY_DESC);
2089 }
2090 }
2091 }
2092 }
2093 else {
2094 if (getDB().isSupportsInlineDistinct()) {
2095 query.append(AssetVocabularyModelImpl.ORDER_BY_JPQL);
2096 }
2097 else {
2098 query.append(AssetVocabularyModelImpl.ORDER_BY_SQL);
2099 }
2100 }
2101
2102 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2103 AssetVocabulary.class.getName(),
2104 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2105
2106 SQLQuery q = session.createSQLQuery(sql);
2107
2108 q.setFirstResult(0);
2109 q.setMaxResults(2);
2110
2111 if (getDB().isSupportsInlineDistinct()) {
2112 q.addEntity(_FILTER_ENTITY_ALIAS, AssetVocabularyImpl.class);
2113 }
2114 else {
2115 q.addEntity(_FILTER_ENTITY_TABLE, AssetVocabularyImpl.class);
2116 }
2117
2118 QueryPos qPos = QueryPos.getInstance(q);
2119
2120 qPos.add(groupId);
2121
2122 if (orderByComparator != null) {
2123 Object[] values = orderByComparator.getOrderByConditionValues(assetVocabulary);
2124
2125 for (Object value : values) {
2126 qPos.add(value);
2127 }
2128 }
2129
2130 List<AssetVocabulary> list = q.list();
2131
2132 if (list.size() == 2) {
2133 return list.get(1);
2134 }
2135 else {
2136 return null;
2137 }
2138 }
2139
2140
2146 public void removeByGroupId(long groupId) throws SystemException {
2147 for (AssetVocabulary assetVocabulary : findByGroupId(groupId,
2148 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
2149 remove(assetVocabulary);
2150 }
2151 }
2152
2153
2160 public int countByGroupId(long groupId) throws SystemException {
2161 FinderPath finderPath = FINDER_PATH_COUNT_BY_GROUPID;
2162
2163 Object[] finderArgs = new Object[] { groupId };
2164
2165 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
2166 this);
2167
2168 if (count == null) {
2169 StringBundler query = new StringBundler(2);
2170
2171 query.append(_SQL_COUNT_ASSETVOCABULARY_WHERE);
2172
2173 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2174
2175 String sql = query.toString();
2176
2177 Session session = null;
2178
2179 try {
2180 session = openSession();
2181
2182 Query q = session.createQuery(sql);
2183
2184 QueryPos qPos = QueryPos.getInstance(q);
2185
2186 qPos.add(groupId);
2187
2188 count = (Long)q.uniqueResult();
2189
2190 FinderCacheUtil.putResult(finderPath, finderArgs, count);
2191 }
2192 catch (Exception e) {
2193 FinderCacheUtil.removeResult(finderPath, finderArgs);
2194
2195 throw processException(e);
2196 }
2197 finally {
2198 closeSession(session);
2199 }
2200 }
2201
2202 return count.intValue();
2203 }
2204
2205
2212 public int filterCountByGroupId(long groupId) throws SystemException {
2213 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2214 return countByGroupId(groupId);
2215 }
2216
2217 StringBundler query = new StringBundler(2);
2218
2219 query.append(_FILTER_SQL_COUNT_ASSETVOCABULARY_WHERE);
2220
2221 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2222
2223 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2224 AssetVocabulary.class.getName(),
2225 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2226
2227 Session session = null;
2228
2229 try {
2230 session = openSession();
2231
2232 SQLQuery q = session.createSQLQuery(sql);
2233
2234 q.addScalar(COUNT_COLUMN_NAME,
2235 com.liferay.portal.kernel.dao.orm.Type.LONG);
2236
2237 QueryPos qPos = QueryPos.getInstance(q);
2238
2239 qPos.add(groupId);
2240
2241 Long count = (Long)q.uniqueResult();
2242
2243 return count.intValue();
2244 }
2245 catch (Exception e) {
2246 throw processException(e);
2247 }
2248 finally {
2249 closeSession(session);
2250 }
2251 }
2252
2253 private static final String _FINDER_COLUMN_GROUPID_GROUPID_2 = "assetVocabulary.groupId = ?";
2254 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID =
2255 new FinderPath(AssetVocabularyModelImpl.ENTITY_CACHE_ENABLED,
2256 AssetVocabularyModelImpl.FINDER_CACHE_ENABLED,
2257 AssetVocabularyImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
2258 "findByCompanyId",
2259 new String[] {
2260 Long.class.getName(),
2261
2262 Integer.class.getName(), Integer.class.getName(),
2263 OrderByComparator.class.getName()
2264 });
2265 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID =
2266 new FinderPath(AssetVocabularyModelImpl.ENTITY_CACHE_ENABLED,
2267 AssetVocabularyModelImpl.FINDER_CACHE_ENABLED,
2268 AssetVocabularyImpl.class,
2269 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByCompanyId",
2270 new String[] { Long.class.getName() },
2271 AssetVocabularyModelImpl.COMPANYID_COLUMN_BITMASK |
2272 AssetVocabularyModelImpl.NAME_COLUMN_BITMASK);
2273 public static final FinderPath FINDER_PATH_COUNT_BY_COMPANYID = new FinderPath(AssetVocabularyModelImpl.ENTITY_CACHE_ENABLED,
2274 AssetVocabularyModelImpl.FINDER_CACHE_ENABLED, Long.class,
2275 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByCompanyId",
2276 new String[] { Long.class.getName() });
2277
2278
2285 public List<AssetVocabulary> findByCompanyId(long companyId)
2286 throws SystemException {
2287 return findByCompanyId(companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
2288 null);
2289 }
2290
2291
2304 public List<AssetVocabulary> findByCompanyId(long companyId, int start,
2305 int end) throws SystemException {
2306 return findByCompanyId(companyId, start, end, null);
2307 }
2308
2309
2323 public List<AssetVocabulary> findByCompanyId(long companyId, int start,
2324 int end, OrderByComparator orderByComparator) throws SystemException {
2325 boolean pagination = true;
2326 FinderPath finderPath = null;
2327 Object[] finderArgs = null;
2328
2329 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2330 (orderByComparator == null)) {
2331 pagination = false;
2332 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID;
2333 finderArgs = new Object[] { companyId };
2334 }
2335 else {
2336 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID;
2337 finderArgs = new Object[] { companyId, start, end, orderByComparator };
2338 }
2339
2340 List<AssetVocabulary> list = (List<AssetVocabulary>)FinderCacheUtil.getResult(finderPath,
2341 finderArgs, this);
2342
2343 if ((list != null) && !list.isEmpty()) {
2344 for (AssetVocabulary assetVocabulary : list) {
2345 if ((companyId != assetVocabulary.getCompanyId())) {
2346 list = null;
2347
2348 break;
2349 }
2350 }
2351 }
2352
2353 if (list == null) {
2354 StringBundler query = null;
2355
2356 if (orderByComparator != null) {
2357 query = new StringBundler(3 +
2358 (orderByComparator.getOrderByFields().length * 3));
2359 }
2360 else {
2361 query = new StringBundler(3);
2362 }
2363
2364 query.append(_SQL_SELECT_ASSETVOCABULARY_WHERE);
2365
2366 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
2367
2368 if (orderByComparator != null) {
2369 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2370 orderByComparator);
2371 }
2372 else
2373 if (pagination) {
2374 query.append(AssetVocabularyModelImpl.ORDER_BY_JPQL);
2375 }
2376
2377 String sql = query.toString();
2378
2379 Session session = null;
2380
2381 try {
2382 session = openSession();
2383
2384 Query q = session.createQuery(sql);
2385
2386 QueryPos qPos = QueryPos.getInstance(q);
2387
2388 qPos.add(companyId);
2389
2390 if (!pagination) {
2391 list = (List<AssetVocabulary>)QueryUtil.list(q,
2392 getDialect(), start, end, false);
2393
2394 Collections.sort(list);
2395
2396 list = new UnmodifiableList<AssetVocabulary>(list);
2397 }
2398 else {
2399 list = (List<AssetVocabulary>)QueryUtil.list(q,
2400 getDialect(), start, end);
2401 }
2402
2403 cacheResult(list);
2404
2405 FinderCacheUtil.putResult(finderPath, finderArgs, list);
2406 }
2407 catch (Exception e) {
2408 FinderCacheUtil.removeResult(finderPath, finderArgs);
2409
2410 throw processException(e);
2411 }
2412 finally {
2413 closeSession(session);
2414 }
2415 }
2416
2417 return list;
2418 }
2419
2420
2429 public AssetVocabulary findByCompanyId_First(long companyId,
2430 OrderByComparator orderByComparator)
2431 throws NoSuchVocabularyException, SystemException {
2432 AssetVocabulary assetVocabulary = fetchByCompanyId_First(companyId,
2433 orderByComparator);
2434
2435 if (assetVocabulary != null) {
2436 return assetVocabulary;
2437 }
2438
2439 StringBundler msg = new StringBundler(4);
2440
2441 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2442
2443 msg.append("companyId=");
2444 msg.append(companyId);
2445
2446 msg.append(StringPool.CLOSE_CURLY_BRACE);
2447
2448 throw new NoSuchVocabularyException(msg.toString());
2449 }
2450
2451
2459 public AssetVocabulary fetchByCompanyId_First(long companyId,
2460 OrderByComparator orderByComparator) throws SystemException {
2461 List<AssetVocabulary> list = findByCompanyId(companyId, 0, 1,
2462 orderByComparator);
2463
2464 if (!list.isEmpty()) {
2465 return list.get(0);
2466 }
2467
2468 return null;
2469 }
2470
2471
2480 public AssetVocabulary findByCompanyId_Last(long companyId,
2481 OrderByComparator orderByComparator)
2482 throws NoSuchVocabularyException, SystemException {
2483 AssetVocabulary assetVocabulary = fetchByCompanyId_Last(companyId,
2484 orderByComparator);
2485
2486 if (assetVocabulary != null) {
2487 return assetVocabulary;
2488 }
2489
2490 StringBundler msg = new StringBundler(4);
2491
2492 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2493
2494 msg.append("companyId=");
2495 msg.append(companyId);
2496
2497 msg.append(StringPool.CLOSE_CURLY_BRACE);
2498
2499 throw new NoSuchVocabularyException(msg.toString());
2500 }
2501
2502
2510 public AssetVocabulary fetchByCompanyId_Last(long companyId,
2511 OrderByComparator orderByComparator) throws SystemException {
2512 int count = countByCompanyId(companyId);
2513
2514 List<AssetVocabulary> list = findByCompanyId(companyId, count - 1,
2515 count, orderByComparator);
2516
2517 if (!list.isEmpty()) {
2518 return list.get(0);
2519 }
2520
2521 return null;
2522 }
2523
2524
2534 public AssetVocabulary[] findByCompanyId_PrevAndNext(long vocabularyId,
2535 long companyId, OrderByComparator orderByComparator)
2536 throws NoSuchVocabularyException, SystemException {
2537 AssetVocabulary assetVocabulary = findByPrimaryKey(vocabularyId);
2538
2539 Session session = null;
2540
2541 try {
2542 session = openSession();
2543
2544 AssetVocabulary[] array = new AssetVocabularyImpl[3];
2545
2546 array[0] = getByCompanyId_PrevAndNext(session, assetVocabulary,
2547 companyId, orderByComparator, true);
2548
2549 array[1] = assetVocabulary;
2550
2551 array[2] = getByCompanyId_PrevAndNext(session, assetVocabulary,
2552 companyId, orderByComparator, false);
2553
2554 return array;
2555 }
2556 catch (Exception e) {
2557 throw processException(e);
2558 }
2559 finally {
2560 closeSession(session);
2561 }
2562 }
2563
2564 protected AssetVocabulary getByCompanyId_PrevAndNext(Session session,
2565 AssetVocabulary assetVocabulary, long companyId,
2566 OrderByComparator orderByComparator, boolean previous) {
2567 StringBundler query = null;
2568
2569 if (orderByComparator != null) {
2570 query = new StringBundler(6 +
2571 (orderByComparator.getOrderByFields().length * 6));
2572 }
2573 else {
2574 query = new StringBundler(3);
2575 }
2576
2577 query.append(_SQL_SELECT_ASSETVOCABULARY_WHERE);
2578
2579 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
2580
2581 if (orderByComparator != null) {
2582 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2583
2584 if (orderByConditionFields.length > 0) {
2585 query.append(WHERE_AND);
2586 }
2587
2588 for (int i = 0; i < orderByConditionFields.length; i++) {
2589 query.append(_ORDER_BY_ENTITY_ALIAS);
2590 query.append(orderByConditionFields[i]);
2591
2592 if ((i + 1) < orderByConditionFields.length) {
2593 if (orderByComparator.isAscending() ^ previous) {
2594 query.append(WHERE_GREATER_THAN_HAS_NEXT);
2595 }
2596 else {
2597 query.append(WHERE_LESSER_THAN_HAS_NEXT);
2598 }
2599 }
2600 else {
2601 if (orderByComparator.isAscending() ^ previous) {
2602 query.append(WHERE_GREATER_THAN);
2603 }
2604 else {
2605 query.append(WHERE_LESSER_THAN);
2606 }
2607 }
2608 }
2609
2610 query.append(ORDER_BY_CLAUSE);
2611
2612 String[] orderByFields = orderByComparator.getOrderByFields();
2613
2614 for (int i = 0; i < orderByFields.length; i++) {
2615 query.append(_ORDER_BY_ENTITY_ALIAS);
2616 query.append(orderByFields[i]);
2617
2618 if ((i + 1) < orderByFields.length) {
2619 if (orderByComparator.isAscending() ^ previous) {
2620 query.append(ORDER_BY_ASC_HAS_NEXT);
2621 }
2622 else {
2623 query.append(ORDER_BY_DESC_HAS_NEXT);
2624 }
2625 }
2626 else {
2627 if (orderByComparator.isAscending() ^ previous) {
2628 query.append(ORDER_BY_ASC);
2629 }
2630 else {
2631 query.append(ORDER_BY_DESC);
2632 }
2633 }
2634 }
2635 }
2636 else {
2637 query.append(AssetVocabularyModelImpl.ORDER_BY_JPQL);
2638 }
2639
2640 String sql = query.toString();
2641
2642 Query q = session.createQuery(sql);
2643
2644 q.setFirstResult(0);
2645 q.setMaxResults(2);
2646
2647 QueryPos qPos = QueryPos.getInstance(q);
2648
2649 qPos.add(companyId);
2650
2651 if (orderByComparator != null) {
2652 Object[] values = orderByComparator.getOrderByConditionValues(assetVocabulary);
2653
2654 for (Object value : values) {
2655 qPos.add(value);
2656 }
2657 }
2658
2659 List<AssetVocabulary> list = q.list();
2660
2661 if (list.size() == 2) {
2662 return list.get(1);
2663 }
2664 else {
2665 return null;
2666 }
2667 }
2668
2669
2675 public void removeByCompanyId(long companyId) throws SystemException {
2676 for (AssetVocabulary assetVocabulary : findByCompanyId(companyId,
2677 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
2678 remove(assetVocabulary);
2679 }
2680 }
2681
2682
2689 public int countByCompanyId(long companyId) throws SystemException {
2690 FinderPath finderPath = FINDER_PATH_COUNT_BY_COMPANYID;
2691
2692 Object[] finderArgs = new Object[] { companyId };
2693
2694 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
2695 this);
2696
2697 if (count == null) {
2698 StringBundler query = new StringBundler(2);
2699
2700 query.append(_SQL_COUNT_ASSETVOCABULARY_WHERE);
2701
2702 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
2703
2704 String sql = query.toString();
2705
2706 Session session = null;
2707
2708 try {
2709 session = openSession();
2710
2711 Query q = session.createQuery(sql);
2712
2713 QueryPos qPos = QueryPos.getInstance(q);
2714
2715 qPos.add(companyId);
2716
2717 count = (Long)q.uniqueResult();
2718
2719 FinderCacheUtil.putResult(finderPath, finderArgs, count);
2720 }
2721 catch (Exception e) {
2722 FinderCacheUtil.removeResult(finderPath, finderArgs);
2723
2724 throw processException(e);
2725 }
2726 finally {
2727 closeSession(session);
2728 }
2729 }
2730
2731 return count.intValue();
2732 }
2733
2734 private static final String _FINDER_COLUMN_COMPANYID_COMPANYID_2 = "assetVocabulary.companyId = ?";
2735 public static final FinderPath FINDER_PATH_FETCH_BY_G_N = new FinderPath(AssetVocabularyModelImpl.ENTITY_CACHE_ENABLED,
2736 AssetVocabularyModelImpl.FINDER_CACHE_ENABLED,
2737 AssetVocabularyImpl.class, FINDER_CLASS_NAME_ENTITY, "fetchByG_N",
2738 new String[] { Long.class.getName(), String.class.getName() },
2739 AssetVocabularyModelImpl.GROUPID_COLUMN_BITMASK |
2740 AssetVocabularyModelImpl.NAME_COLUMN_BITMASK);
2741 public static final FinderPath FINDER_PATH_COUNT_BY_G_N = new FinderPath(AssetVocabularyModelImpl.ENTITY_CACHE_ENABLED,
2742 AssetVocabularyModelImpl.FINDER_CACHE_ENABLED, Long.class,
2743 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_N",
2744 new String[] { Long.class.getName(), String.class.getName() });
2745
2746
2755 public AssetVocabulary findByG_N(long groupId, String name)
2756 throws NoSuchVocabularyException, SystemException {
2757 AssetVocabulary assetVocabulary = fetchByG_N(groupId, name);
2758
2759 if (assetVocabulary == null) {
2760 StringBundler msg = new StringBundler(6);
2761
2762 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2763
2764 msg.append("groupId=");
2765 msg.append(groupId);
2766
2767 msg.append(", name=");
2768 msg.append(name);
2769
2770 msg.append(StringPool.CLOSE_CURLY_BRACE);
2771
2772 if (_log.isWarnEnabled()) {
2773 _log.warn(msg.toString());
2774 }
2775
2776 throw new NoSuchVocabularyException(msg.toString());
2777 }
2778
2779 return assetVocabulary;
2780 }
2781
2782
2790 public AssetVocabulary fetchByG_N(long groupId, String name)
2791 throws SystemException {
2792 return fetchByG_N(groupId, name, true);
2793 }
2794
2795
2804 public AssetVocabulary fetchByG_N(long groupId, String name,
2805 boolean retrieveFromCache) throws SystemException {
2806 Object[] finderArgs = new Object[] { groupId, name };
2807
2808 Object result = null;
2809
2810 if (retrieveFromCache) {
2811 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_G_N,
2812 finderArgs, this);
2813 }
2814
2815 if (result instanceof AssetVocabulary) {
2816 AssetVocabulary assetVocabulary = (AssetVocabulary)result;
2817
2818 if ((groupId != assetVocabulary.getGroupId()) ||
2819 !Validator.equals(name, assetVocabulary.getName())) {
2820 result = null;
2821 }
2822 }
2823
2824 if (result == null) {
2825 StringBundler query = new StringBundler(4);
2826
2827 query.append(_SQL_SELECT_ASSETVOCABULARY_WHERE);
2828
2829 query.append(_FINDER_COLUMN_G_N_GROUPID_2);
2830
2831 if (name == null) {
2832 query.append(_FINDER_COLUMN_G_N_NAME_1);
2833 }
2834 else {
2835 if (name.equals(StringPool.BLANK)) {
2836 query.append(_FINDER_COLUMN_G_N_NAME_3);
2837 }
2838 else {
2839 query.append(_FINDER_COLUMN_G_N_NAME_2);
2840 }
2841 }
2842
2843 String sql = query.toString();
2844
2845 Session session = null;
2846
2847 try {
2848 session = openSession();
2849
2850 Query q = session.createQuery(sql);
2851
2852 QueryPos qPos = QueryPos.getInstance(q);
2853
2854 qPos.add(groupId);
2855
2856 if (name != null) {
2857 qPos.add(name);
2858 }
2859
2860 List<AssetVocabulary> list = q.list();
2861
2862 if (list.isEmpty()) {
2863 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_N,
2864 finderArgs, list);
2865 }
2866 else {
2867 AssetVocabulary assetVocabulary = list.get(0);
2868
2869 result = assetVocabulary;
2870
2871 cacheResult(assetVocabulary);
2872
2873 if ((assetVocabulary.getGroupId() != groupId) ||
2874 (assetVocabulary.getName() == null) ||
2875 !assetVocabulary.getName().equals(name)) {
2876 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_N,
2877 finderArgs, assetVocabulary);
2878 }
2879 }
2880 }
2881 catch (Exception e) {
2882 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_N,
2883 finderArgs);
2884
2885 throw processException(e);
2886 }
2887 finally {
2888 closeSession(session);
2889 }
2890 }
2891
2892 if (result instanceof List<?>) {
2893 return null;
2894 }
2895 else {
2896 return (AssetVocabulary)result;
2897 }
2898 }
2899
2900
2908 public AssetVocabulary removeByG_N(long groupId, String name)
2909 throws NoSuchVocabularyException, SystemException {
2910 AssetVocabulary assetVocabulary = findByG_N(groupId, name);
2911
2912 return remove(assetVocabulary);
2913 }
2914
2915
2923 public int countByG_N(long groupId, String name) throws SystemException {
2924 FinderPath finderPath = FINDER_PATH_COUNT_BY_G_N;
2925
2926 Object[] finderArgs = new Object[] { groupId, name };
2927
2928 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
2929 this);
2930
2931 if (count == null) {
2932 StringBundler query = new StringBundler(3);
2933
2934 query.append(_SQL_COUNT_ASSETVOCABULARY_WHERE);
2935
2936 query.append(_FINDER_COLUMN_G_N_GROUPID_2);
2937
2938 if (name == null) {
2939 query.append(_FINDER_COLUMN_G_N_NAME_1);
2940 }
2941 else {
2942 if (name.equals(StringPool.BLANK)) {
2943 query.append(_FINDER_COLUMN_G_N_NAME_3);
2944 }
2945 else {
2946 query.append(_FINDER_COLUMN_G_N_NAME_2);
2947 }
2948 }
2949
2950 String sql = query.toString();
2951
2952 Session session = null;
2953
2954 try {
2955 session = openSession();
2956
2957 Query q = session.createQuery(sql);
2958
2959 QueryPos qPos = QueryPos.getInstance(q);
2960
2961 qPos.add(groupId);
2962
2963 if (name != null) {
2964 qPos.add(name);
2965 }
2966
2967 count = (Long)q.uniqueResult();
2968
2969 FinderCacheUtil.putResult(finderPath, finderArgs, count);
2970 }
2971 catch (Exception e) {
2972 FinderCacheUtil.removeResult(finderPath, finderArgs);
2973
2974 throw processException(e);
2975 }
2976 finally {
2977 closeSession(session);
2978 }
2979 }
2980
2981 return count.intValue();
2982 }
2983
2984 private static final String _FINDER_COLUMN_G_N_GROUPID_2 = "assetVocabulary.groupId = ? AND ";
2985 private static final String _FINDER_COLUMN_G_N_NAME_1 = "assetVocabulary.name IS NULL";
2986 private static final String _FINDER_COLUMN_G_N_NAME_2 = "assetVocabulary.name = ?";
2987 private static final String _FINDER_COLUMN_G_N_NAME_3 = "(assetVocabulary.name IS NULL OR assetVocabulary.name = ?)";
2988
2989
2994 public void cacheResult(AssetVocabulary assetVocabulary) {
2995 EntityCacheUtil.putResult(AssetVocabularyModelImpl.ENTITY_CACHE_ENABLED,
2996 AssetVocabularyImpl.class, assetVocabulary.getPrimaryKey(),
2997 assetVocabulary);
2998
2999 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
3000 new Object[] {
3001 assetVocabulary.getUuid(),
3002 Long.valueOf(assetVocabulary.getGroupId())
3003 }, assetVocabulary);
3004
3005 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_N,
3006 new Object[] {
3007 Long.valueOf(assetVocabulary.getGroupId()),
3008
3009 assetVocabulary.getName()
3010 }, assetVocabulary);
3011
3012 assetVocabulary.resetOriginalValues();
3013 }
3014
3015
3020 public void cacheResult(List<AssetVocabulary> assetVocabularies) {
3021 for (AssetVocabulary assetVocabulary : assetVocabularies) {
3022 if (EntityCacheUtil.getResult(
3023 AssetVocabularyModelImpl.ENTITY_CACHE_ENABLED,
3024 AssetVocabularyImpl.class,
3025 assetVocabulary.getPrimaryKey()) == null) {
3026 cacheResult(assetVocabulary);
3027 }
3028 else {
3029 assetVocabulary.resetOriginalValues();
3030 }
3031 }
3032 }
3033
3034
3041 @Override
3042 public void clearCache() {
3043 if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
3044 CacheRegistryUtil.clear(AssetVocabularyImpl.class.getName());
3045 }
3046
3047 EntityCacheUtil.clearCache(AssetVocabularyImpl.class.getName());
3048
3049 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
3050 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
3051 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
3052 }
3053
3054
3061 @Override
3062 public void clearCache(AssetVocabulary assetVocabulary) {
3063 EntityCacheUtil.removeResult(AssetVocabularyModelImpl.ENTITY_CACHE_ENABLED,
3064 AssetVocabularyImpl.class, assetVocabulary.getPrimaryKey());
3065
3066 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
3067 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
3068
3069 clearUniqueFindersCache(assetVocabulary);
3070 }
3071
3072 @Override
3073 public void clearCache(List<AssetVocabulary> assetVocabularies) {
3074 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
3075 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
3076
3077 for (AssetVocabulary assetVocabulary : assetVocabularies) {
3078 EntityCacheUtil.removeResult(AssetVocabularyModelImpl.ENTITY_CACHE_ENABLED,
3079 AssetVocabularyImpl.class, assetVocabulary.getPrimaryKey());
3080
3081 clearUniqueFindersCache(assetVocabulary);
3082 }
3083 }
3084
3085 protected void cacheUniqueFindersCache(AssetVocabulary assetVocabulary) {
3086 if (assetVocabulary.isNew()) {
3087 Object[] args = new Object[] {
3088 assetVocabulary.getUuid(),
3089 Long.valueOf(assetVocabulary.getGroupId())
3090 };
3091
3092 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G, args,
3093 Long.valueOf(1));
3094 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G, args,
3095 assetVocabulary);
3096
3097 args = new Object[] {
3098 Long.valueOf(assetVocabulary.getGroupId()),
3099
3100 assetVocabulary.getName()
3101 };
3102
3103 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_N, args,
3104 Long.valueOf(1));
3105 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_N, args,
3106 assetVocabulary);
3107 }
3108 else {
3109 AssetVocabularyModelImpl assetVocabularyModelImpl = (AssetVocabularyModelImpl)assetVocabulary;
3110
3111 if ((assetVocabularyModelImpl.getColumnBitmask() &
3112 FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) {
3113 Object[] args = new Object[] {
3114 assetVocabulary.getUuid(),
3115 Long.valueOf(assetVocabulary.getGroupId())
3116 };
3117
3118 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G, args,
3119 Long.valueOf(1));
3120 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G, args,
3121 assetVocabulary);
3122 }
3123
3124 if ((assetVocabularyModelImpl.getColumnBitmask() &
3125 FINDER_PATH_FETCH_BY_G_N.getColumnBitmask()) != 0) {
3126 Object[] args = new Object[] {
3127 Long.valueOf(assetVocabulary.getGroupId()),
3128
3129 assetVocabulary.getName()
3130 };
3131
3132 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_N, args,
3133 Long.valueOf(1));
3134 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_N, args,
3135 assetVocabulary);
3136 }
3137 }
3138 }
3139
3140 protected void clearUniqueFindersCache(AssetVocabulary assetVocabulary) {
3141 AssetVocabularyModelImpl assetVocabularyModelImpl = (AssetVocabularyModelImpl)assetVocabulary;
3142
3143 Object[] args = new Object[] {
3144 assetVocabulary.getUuid(),
3145 Long.valueOf(assetVocabulary.getGroupId())
3146 };
3147
3148 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args);
3149 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args);
3150
3151 if ((assetVocabularyModelImpl.getColumnBitmask() &
3152 FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) {
3153 args = new Object[] {
3154 assetVocabularyModelImpl.getOriginalUuid(),
3155 Long.valueOf(assetVocabularyModelImpl.getOriginalGroupId())
3156 };
3157
3158 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args);
3159 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args);
3160 }
3161
3162 args = new Object[] {
3163 Long.valueOf(assetVocabulary.getGroupId()),
3164
3165 assetVocabulary.getName()
3166 };
3167
3168 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_N, args);
3169 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_N, args);
3170
3171 if ((assetVocabularyModelImpl.getColumnBitmask() &
3172 FINDER_PATH_FETCH_BY_G_N.getColumnBitmask()) != 0) {
3173 args = new Object[] {
3174 Long.valueOf(assetVocabularyModelImpl.getOriginalGroupId()),
3175
3176 assetVocabularyModelImpl.getOriginalName()
3177 };
3178
3179 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_N, args);
3180 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_N, args);
3181 }
3182 }
3183
3184
3190 public AssetVocabulary create(long vocabularyId) {
3191 AssetVocabulary assetVocabulary = new AssetVocabularyImpl();
3192
3193 assetVocabulary.setNew(true);
3194 assetVocabulary.setPrimaryKey(vocabularyId);
3195
3196 String uuid = PortalUUIDUtil.generate();
3197
3198 assetVocabulary.setUuid(uuid);
3199
3200 return assetVocabulary;
3201 }
3202
3203
3211 public AssetVocabulary remove(long vocabularyId)
3212 throws NoSuchVocabularyException, SystemException {
3213 return remove(Long.valueOf(vocabularyId));
3214 }
3215
3216
3224 @Override
3225 public AssetVocabulary remove(Serializable primaryKey)
3226 throws NoSuchVocabularyException, SystemException {
3227 Session session = null;
3228
3229 try {
3230 session = openSession();
3231
3232 AssetVocabulary assetVocabulary = (AssetVocabulary)session.get(AssetVocabularyImpl.class,
3233 primaryKey);
3234
3235 if (assetVocabulary == null) {
3236 if (_log.isWarnEnabled()) {
3237 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
3238 }
3239
3240 throw new NoSuchVocabularyException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
3241 primaryKey);
3242 }
3243
3244 return remove(assetVocabulary);
3245 }
3246 catch (NoSuchVocabularyException nsee) {
3247 throw nsee;
3248 }
3249 catch (Exception e) {
3250 throw processException(e);
3251 }
3252 finally {
3253 closeSession(session);
3254 }
3255 }
3256
3257 @Override
3258 protected AssetVocabulary removeImpl(AssetVocabulary assetVocabulary)
3259 throws SystemException {
3260 assetVocabulary = toUnwrappedModel(assetVocabulary);
3261
3262 Session session = null;
3263
3264 try {
3265 session = openSession();
3266
3267 if (!session.contains(assetVocabulary)) {
3268 assetVocabulary = (AssetVocabulary)session.get(AssetVocabularyImpl.class,
3269 assetVocabulary.getPrimaryKeyObj());
3270 }
3271
3272 if (assetVocabulary != null) {
3273 session.delete(assetVocabulary);
3274 }
3275 }
3276 catch (Exception e) {
3277 throw processException(e);
3278 }
3279 finally {
3280 closeSession(session);
3281 }
3282
3283 if (assetVocabulary != null) {
3284 clearCache(assetVocabulary);
3285 }
3286
3287 return assetVocabulary;
3288 }
3289
3290 @Override
3291 public AssetVocabulary updateImpl(
3292 com.liferay.portlet.asset.model.AssetVocabulary assetVocabulary)
3293 throws SystemException {
3294 assetVocabulary = toUnwrappedModel(assetVocabulary);
3295
3296 boolean isNew = assetVocabulary.isNew();
3297
3298 AssetVocabularyModelImpl assetVocabularyModelImpl = (AssetVocabularyModelImpl)assetVocabulary;
3299
3300 if (Validator.isNull(assetVocabulary.getUuid())) {
3301 String uuid = PortalUUIDUtil.generate();
3302
3303 assetVocabulary.setUuid(uuid);
3304 }
3305
3306 Session session = null;
3307
3308 try {
3309 session = openSession();
3310
3311 if (assetVocabulary.isNew()) {
3312 session.save(assetVocabulary);
3313
3314 assetVocabulary.setNew(false);
3315 }
3316 else {
3317 session.merge(assetVocabulary);
3318 }
3319 }
3320 catch (Exception e) {
3321 throw processException(e);
3322 }
3323 finally {
3324 closeSession(session);
3325 }
3326
3327 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
3328
3329 if (isNew || !AssetVocabularyModelImpl.COLUMN_BITMASK_ENABLED) {
3330 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
3331 }
3332
3333 else {
3334 if ((assetVocabularyModelImpl.getColumnBitmask() &
3335 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID.getColumnBitmask()) != 0) {
3336 Object[] args = new Object[] {
3337 assetVocabularyModelImpl.getOriginalUuid()
3338 };
3339
3340 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
3341 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
3342 args);
3343
3344 args = new Object[] { assetVocabularyModelImpl.getUuid() };
3345
3346 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
3347 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
3348 args);
3349 }
3350
3351 if ((assetVocabularyModelImpl.getColumnBitmask() &
3352 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C.getColumnBitmask()) != 0) {
3353 Object[] args = new Object[] {
3354 assetVocabularyModelImpl.getOriginalUuid(),
3355 Long.valueOf(assetVocabularyModelImpl.getOriginalCompanyId())
3356 };
3357
3358 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args);
3359 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C,
3360 args);
3361
3362 args = new Object[] {
3363 assetVocabularyModelImpl.getUuid(),
3364 Long.valueOf(assetVocabularyModelImpl.getCompanyId())
3365 };
3366
3367 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args);
3368 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C,
3369 args);
3370 }
3371
3372 if ((assetVocabularyModelImpl.getColumnBitmask() &
3373 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID.getColumnBitmask()) != 0) {
3374 Object[] args = new Object[] {
3375 Long.valueOf(assetVocabularyModelImpl.getOriginalGroupId())
3376 };
3377
3378 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
3379 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
3380 args);
3381
3382 args = new Object[] {
3383 Long.valueOf(assetVocabularyModelImpl.getGroupId())
3384 };
3385
3386 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
3387 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
3388 args);
3389 }
3390
3391 if ((assetVocabularyModelImpl.getColumnBitmask() &
3392 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID.getColumnBitmask()) != 0) {
3393 Object[] args = new Object[] {
3394 Long.valueOf(assetVocabularyModelImpl.getOriginalCompanyId())
3395 };
3396
3397 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_COMPANYID,
3398 args);
3399 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
3400 args);
3401
3402 args = new Object[] {
3403 Long.valueOf(assetVocabularyModelImpl.getCompanyId())
3404 };
3405
3406 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_COMPANYID,
3407 args);
3408 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
3409 args);
3410 }
3411 }
3412
3413 EntityCacheUtil.putResult(AssetVocabularyModelImpl.ENTITY_CACHE_ENABLED,
3414 AssetVocabularyImpl.class, assetVocabulary.getPrimaryKey(),
3415 assetVocabulary);
3416
3417 clearUniqueFindersCache(assetVocabulary);
3418 cacheUniqueFindersCache(assetVocabulary);
3419
3420 return assetVocabulary;
3421 }
3422
3423 protected AssetVocabulary toUnwrappedModel(AssetVocabulary assetVocabulary) {
3424 if (assetVocabulary instanceof AssetVocabularyImpl) {
3425 return assetVocabulary;
3426 }
3427
3428 AssetVocabularyImpl assetVocabularyImpl = new AssetVocabularyImpl();
3429
3430 assetVocabularyImpl.setNew(assetVocabulary.isNew());
3431 assetVocabularyImpl.setPrimaryKey(assetVocabulary.getPrimaryKey());
3432
3433 assetVocabularyImpl.setUuid(assetVocabulary.getUuid());
3434 assetVocabularyImpl.setVocabularyId(assetVocabulary.getVocabularyId());
3435 assetVocabularyImpl.setGroupId(assetVocabulary.getGroupId());
3436 assetVocabularyImpl.setCompanyId(assetVocabulary.getCompanyId());
3437 assetVocabularyImpl.setUserId(assetVocabulary.getUserId());
3438 assetVocabularyImpl.setUserName(assetVocabulary.getUserName());
3439 assetVocabularyImpl.setCreateDate(assetVocabulary.getCreateDate());
3440 assetVocabularyImpl.setModifiedDate(assetVocabulary.getModifiedDate());
3441 assetVocabularyImpl.setName(assetVocabulary.getName());
3442 assetVocabularyImpl.setTitle(assetVocabulary.getTitle());
3443 assetVocabularyImpl.setDescription(assetVocabulary.getDescription());
3444 assetVocabularyImpl.setSettings(assetVocabulary.getSettings());
3445
3446 return assetVocabularyImpl;
3447 }
3448
3449
3457 @Override
3458 public AssetVocabulary findByPrimaryKey(Serializable primaryKey)
3459 throws NoSuchModelException, SystemException {
3460 return findByPrimaryKey(((Long)primaryKey).longValue());
3461 }
3462
3463
3471 public AssetVocabulary findByPrimaryKey(long vocabularyId)
3472 throws NoSuchVocabularyException, SystemException {
3473 AssetVocabulary assetVocabulary = fetchByPrimaryKey(vocabularyId);
3474
3475 if (assetVocabulary == null) {
3476 if (_log.isWarnEnabled()) {
3477 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + vocabularyId);
3478 }
3479
3480 throw new NoSuchVocabularyException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
3481 vocabularyId);
3482 }
3483
3484 return assetVocabulary;
3485 }
3486
3487
3494 @Override
3495 public AssetVocabulary fetchByPrimaryKey(Serializable primaryKey)
3496 throws SystemException {
3497 return fetchByPrimaryKey(((Long)primaryKey).longValue());
3498 }
3499
3500
3507 public AssetVocabulary fetchByPrimaryKey(long vocabularyId)
3508 throws SystemException {
3509 AssetVocabulary assetVocabulary = (AssetVocabulary)EntityCacheUtil.getResult(AssetVocabularyModelImpl.ENTITY_CACHE_ENABLED,
3510 AssetVocabularyImpl.class, vocabularyId);
3511
3512 if (assetVocabulary == _nullAssetVocabulary) {
3513 return null;
3514 }
3515
3516 if (assetVocabulary == null) {
3517 Session session = null;
3518
3519 try {
3520 session = openSession();
3521
3522 assetVocabulary = (AssetVocabulary)session.get(AssetVocabularyImpl.class,
3523 Long.valueOf(vocabularyId));
3524
3525 if (assetVocabulary != null) {
3526 cacheResult(assetVocabulary);
3527 }
3528 else {
3529 EntityCacheUtil.putResult(AssetVocabularyModelImpl.ENTITY_CACHE_ENABLED,
3530 AssetVocabularyImpl.class, vocabularyId,
3531 _nullAssetVocabulary);
3532 }
3533 }
3534 catch (Exception e) {
3535 EntityCacheUtil.removeResult(AssetVocabularyModelImpl.ENTITY_CACHE_ENABLED,
3536 AssetVocabularyImpl.class, vocabularyId);
3537
3538 throw processException(e);
3539 }
3540 finally {
3541 closeSession(session);
3542 }
3543 }
3544
3545 return assetVocabulary;
3546 }
3547
3548
3554 public List<AssetVocabulary> findAll() throws SystemException {
3555 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
3556 }
3557
3558
3570 public List<AssetVocabulary> findAll(int start, int end)
3571 throws SystemException {
3572 return findAll(start, end, null);
3573 }
3574
3575
3588 public List<AssetVocabulary> findAll(int start, int end,
3589 OrderByComparator orderByComparator) throws SystemException {
3590 boolean pagination = true;
3591 FinderPath finderPath = null;
3592 Object[] finderArgs = null;
3593
3594 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
3595 (orderByComparator == null)) {
3596 pagination = false;
3597 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
3598 finderArgs = FINDER_ARGS_EMPTY;
3599 }
3600 else {
3601 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
3602 finderArgs = new Object[] { start, end, orderByComparator };
3603 }
3604
3605 List<AssetVocabulary> list = (List<AssetVocabulary>)FinderCacheUtil.getResult(finderPath,
3606 finderArgs, this);
3607
3608 if (list == null) {
3609 StringBundler query = null;
3610 String sql = null;
3611
3612 if (orderByComparator != null) {
3613 query = new StringBundler(2 +
3614 (orderByComparator.getOrderByFields().length * 3));
3615
3616 query.append(_SQL_SELECT_ASSETVOCABULARY);
3617
3618 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3619 orderByComparator);
3620
3621 sql = query.toString();
3622 }
3623 else {
3624 sql = _SQL_SELECT_ASSETVOCABULARY;
3625
3626 if (pagination) {
3627 sql = sql.concat(AssetVocabularyModelImpl.ORDER_BY_JPQL);
3628 }
3629 }
3630
3631 Session session = null;
3632
3633 try {
3634 session = openSession();
3635
3636 Query q = session.createQuery(sql);
3637
3638 if (!pagination) {
3639 list = (List<AssetVocabulary>)QueryUtil.list(q,
3640 getDialect(), start, end, false);
3641
3642 Collections.sort(list);
3643
3644 list = new UnmodifiableList<AssetVocabulary>(list);
3645 }
3646 else {
3647 list = (List<AssetVocabulary>)QueryUtil.list(q,
3648 getDialect(), start, end);
3649 }
3650
3651 cacheResult(list);
3652
3653 FinderCacheUtil.putResult(finderPath, finderArgs, list);
3654 }
3655 catch (Exception e) {
3656 FinderCacheUtil.removeResult(finderPath, finderArgs);
3657
3658 throw processException(e);
3659 }
3660 finally {
3661 closeSession(session);
3662 }
3663 }
3664
3665 return list;
3666 }
3667
3668
3673 public void removeAll() throws SystemException {
3674 for (AssetVocabulary assetVocabulary : findAll()) {
3675 remove(assetVocabulary);
3676 }
3677 }
3678
3679
3685 public int countAll() throws SystemException {
3686 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
3687 FINDER_ARGS_EMPTY, this);
3688
3689 if (count == null) {
3690 Session session = null;
3691
3692 try {
3693 session = openSession();
3694
3695 Query q = session.createQuery(_SQL_COUNT_ASSETVOCABULARY);
3696
3697 count = (Long)q.uniqueResult();
3698
3699 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
3700 FINDER_ARGS_EMPTY, count);
3701 }
3702 catch (Exception e) {
3703 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_ALL,
3704 FINDER_ARGS_EMPTY);
3705
3706 throw processException(e);
3707 }
3708 finally {
3709 closeSession(session);
3710 }
3711 }
3712
3713 return count.intValue();
3714 }
3715
3716
3719 public void afterPropertiesSet() {
3720 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
3721 com.liferay.portal.util.PropsUtil.get(
3722 "value.object.listener.com.liferay.portlet.asset.model.AssetVocabulary")));
3723
3724 if (listenerClassNames.length > 0) {
3725 try {
3726 List<ModelListener<AssetVocabulary>> listenersList = new ArrayList<ModelListener<AssetVocabulary>>();
3727
3728 for (String listenerClassName : listenerClassNames) {
3729 listenersList.add((ModelListener<AssetVocabulary>)InstanceFactory.newInstance(
3730 listenerClassName));
3731 }
3732
3733 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
3734 }
3735 catch (Exception e) {
3736 _log.error(e);
3737 }
3738 }
3739 }
3740
3741 public void destroy() {
3742 EntityCacheUtil.removeCache(AssetVocabularyImpl.class.getName());
3743 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
3744 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
3745 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
3746 }
3747
3748 private static final String _SQL_SELECT_ASSETVOCABULARY = "SELECT assetVocabulary FROM AssetVocabulary assetVocabulary";
3749 private static final String _SQL_SELECT_ASSETVOCABULARY_WHERE = "SELECT assetVocabulary FROM AssetVocabulary assetVocabulary WHERE ";
3750 private static final String _SQL_COUNT_ASSETVOCABULARY = "SELECT COUNT(assetVocabulary) FROM AssetVocabulary assetVocabulary";
3751 private static final String _SQL_COUNT_ASSETVOCABULARY_WHERE = "SELECT COUNT(assetVocabulary) FROM AssetVocabulary assetVocabulary WHERE ";
3752 private static final String _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN = "assetVocabulary.vocabularyId";
3753 private static final String _FILTER_SQL_SELECT_ASSETVOCABULARY_WHERE = "SELECT DISTINCT {assetVocabulary.*} FROM AssetVocabulary assetVocabulary WHERE ";
3754 private static final String _FILTER_SQL_SELECT_ASSETVOCABULARY_NO_INLINE_DISTINCT_WHERE_1 =
3755 "SELECT {AssetVocabulary.*} FROM (SELECT DISTINCT assetVocabulary.vocabularyId FROM AssetVocabulary assetVocabulary WHERE ";
3756 private static final String _FILTER_SQL_SELECT_ASSETVOCABULARY_NO_INLINE_DISTINCT_WHERE_2 =
3757 ") TEMP_TABLE INNER JOIN AssetVocabulary ON TEMP_TABLE.vocabularyId = AssetVocabulary.vocabularyId";
3758 private static final String _FILTER_SQL_COUNT_ASSETVOCABULARY_WHERE = "SELECT COUNT(DISTINCT assetVocabulary.vocabularyId) AS COUNT_VALUE FROM AssetVocabulary assetVocabulary WHERE ";
3759 private static final String _FILTER_ENTITY_ALIAS = "assetVocabulary";
3760 private static final String _FILTER_ENTITY_TABLE = "AssetVocabulary";
3761 private static final String _ORDER_BY_ENTITY_ALIAS = "assetVocabulary.";
3762 private static final String _ORDER_BY_ENTITY_TABLE = "AssetVocabulary.";
3763 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No AssetVocabulary exists with the primary key ";
3764 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No AssetVocabulary exists with the key {";
3765 private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
3766 private static Log _log = LogFactoryUtil.getLog(AssetVocabularyPersistenceImpl.class);
3767 private static AssetVocabulary _nullAssetVocabulary = new AssetVocabularyImpl() {
3768 @Override
3769 public Object clone() {
3770 return this;
3771 }
3772
3773 @Override
3774 public CacheModel<AssetVocabulary> toCacheModel() {
3775 return _nullAssetVocabularyCacheModel;
3776 }
3777 };
3778
3779 private static CacheModel<AssetVocabulary> _nullAssetVocabularyCacheModel = new CacheModel<AssetVocabulary>() {
3780 public AssetVocabulary toEntityModel() {
3781 return _nullAssetVocabulary;
3782 }
3783 };
3784 }