001
014
015 package com.liferay.portlet.asset.service.persistence;
016
017 import com.liferay.portal.kernel.cache.CacheRegistryUtil;
018 import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
019 import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
020 import com.liferay.portal.kernel.dao.orm.FinderPath;
021 import com.liferay.portal.kernel.dao.orm.Query;
022 import com.liferay.portal.kernel.dao.orm.QueryPos;
023 import com.liferay.portal.kernel.dao.orm.QueryUtil;
024 import com.liferay.portal.kernel.dao.orm.SQLQuery;
025 import com.liferay.portal.kernel.dao.orm.Session;
026 import com.liferay.portal.kernel.exception.SystemException;
027 import com.liferay.portal.kernel.log.Log;
028 import com.liferay.portal.kernel.log.LogFactoryUtil;
029 import com.liferay.portal.kernel.util.GetterUtil;
030 import com.liferay.portal.kernel.util.InstanceFactory;
031 import com.liferay.portal.kernel.util.OrderByComparator;
032 import com.liferay.portal.kernel.util.StringBundler;
033 import com.liferay.portal.kernel.util.StringPool;
034 import com.liferay.portal.kernel.util.StringUtil;
035 import com.liferay.portal.kernel.util.UnmodifiableList;
036 import com.liferay.portal.kernel.util.Validator;
037 import com.liferay.portal.kernel.uuid.PortalUUIDUtil;
038 import com.liferay.portal.model.CacheModel;
039 import com.liferay.portal.model.ModelListener;
040 import com.liferay.portal.security.permission.InlineSQLHelperUtil;
041 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
042
043 import com.liferay.portlet.asset.NoSuchVocabularyException;
044 import com.liferay.portlet.asset.model.AssetVocabulary;
045 import com.liferay.portlet.asset.model.impl.AssetVocabularyImpl;
046 import com.liferay.portlet.asset.model.impl.AssetVocabularyModelImpl;
047
048 import java.io.Serializable;
049
050 import java.util.ArrayList;
051 import java.util.Collections;
052 import java.util.List;
053
054
066 public class AssetVocabularyPersistenceImpl extends BasePersistenceImpl<AssetVocabulary>
067 implements AssetVocabularyPersistence {
068
073 public static final String FINDER_CLASS_NAME_ENTITY = AssetVocabularyImpl.class.getName();
074 public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
075 ".List1";
076 public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
077 ".List2";
078 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(AssetVocabularyModelImpl.ENTITY_CACHE_ENABLED,
079 AssetVocabularyModelImpl.FINDER_CACHE_ENABLED,
080 AssetVocabularyImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
081 "findAll", new String[0]);
082 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(AssetVocabularyModelImpl.ENTITY_CACHE_ENABLED,
083 AssetVocabularyModelImpl.FINDER_CACHE_ENABLED,
084 AssetVocabularyImpl.class,
085 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
086 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(AssetVocabularyModelImpl.ENTITY_CACHE_ENABLED,
087 AssetVocabularyModelImpl.FINDER_CACHE_ENABLED, Long.class,
088 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
089 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID = new FinderPath(AssetVocabularyModelImpl.ENTITY_CACHE_ENABLED,
090 AssetVocabularyModelImpl.FINDER_CACHE_ENABLED,
091 AssetVocabularyImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
092 "findByUuid",
093 new String[] {
094 String.class.getName(),
095
096 Integer.class.getName(), Integer.class.getName(),
097 OrderByComparator.class.getName()
098 });
099 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID = new FinderPath(AssetVocabularyModelImpl.ENTITY_CACHE_ENABLED,
100 AssetVocabularyModelImpl.FINDER_CACHE_ENABLED,
101 AssetVocabularyImpl.class,
102 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid",
103 new String[] { String.class.getName() },
104 AssetVocabularyModelImpl.UUID_COLUMN_BITMASK |
105 AssetVocabularyModelImpl.NAME_COLUMN_BITMASK);
106 public static final FinderPath FINDER_PATH_COUNT_BY_UUID = new FinderPath(AssetVocabularyModelImpl.ENTITY_CACHE_ENABLED,
107 AssetVocabularyModelImpl.FINDER_CACHE_ENABLED, Long.class,
108 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid",
109 new String[] { String.class.getName() });
110
111
118 public List<AssetVocabulary> findByUuid(String uuid)
119 throws SystemException {
120 return findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
121 }
122
123
136 public List<AssetVocabulary> findByUuid(String uuid, int start, int end)
137 throws SystemException {
138 return findByUuid(uuid, start, end, null);
139 }
140
141
155 public List<AssetVocabulary> findByUuid(String uuid, int start, int end,
156 OrderByComparator orderByComparator) throws SystemException {
157 boolean pagination = true;
158 FinderPath finderPath = null;
159 Object[] finderArgs = null;
160
161 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
162 (orderByComparator == null)) {
163 pagination = false;
164 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID;
165 finderArgs = new Object[] { uuid };
166 }
167 else {
168 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID;
169 finderArgs = new Object[] { uuid, start, end, orderByComparator };
170 }
171
172 List<AssetVocabulary> list = (List<AssetVocabulary>)FinderCacheUtil.getResult(finderPath,
173 finderArgs, this);
174
175 if ((list != null) && !list.isEmpty()) {
176 for (AssetVocabulary assetVocabulary : list) {
177 if (!Validator.equals(uuid, assetVocabulary.getUuid())) {
178 list = null;
179
180 break;
181 }
182 }
183 }
184
185 if (list == null) {
186 StringBundler query = null;
187
188 if (orderByComparator != null) {
189 query = new StringBundler(3 +
190 (orderByComparator.getOrderByFields().length * 3));
191 }
192 else {
193 query = new StringBundler(3);
194 }
195
196 query.append(_SQL_SELECT_ASSETVOCABULARY_WHERE);
197
198 boolean bindUuid = false;
199
200 if (uuid == null) {
201 query.append(_FINDER_COLUMN_UUID_UUID_1);
202 }
203 else if (uuid.equals(StringPool.BLANK)) {
204 query.append(_FINDER_COLUMN_UUID_UUID_3);
205 }
206 else {
207 bindUuid = true;
208
209 query.append(_FINDER_COLUMN_UUID_UUID_2);
210 }
211
212 if (orderByComparator != null) {
213 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
214 orderByComparator);
215 }
216 else
217 if (pagination) {
218 query.append(AssetVocabularyModelImpl.ORDER_BY_JPQL);
219 }
220
221 String sql = query.toString();
222
223 Session session = null;
224
225 try {
226 session = openSession();
227
228 Query q = session.createQuery(sql);
229
230 QueryPos qPos = QueryPos.getInstance(q);
231
232 if (bindUuid) {
233 qPos.add(uuid);
234 }
235
236 if (!pagination) {
237 list = (List<AssetVocabulary>)QueryUtil.list(q,
238 getDialect(), start, end, false);
239
240 Collections.sort(list);
241
242 list = new UnmodifiableList<AssetVocabulary>(list);
243 }
244 else {
245 list = (List<AssetVocabulary>)QueryUtil.list(q,
246 getDialect(), start, end);
247 }
248
249 cacheResult(list);
250
251 FinderCacheUtil.putResult(finderPath, finderArgs, list);
252 }
253 catch (Exception e) {
254 FinderCacheUtil.removeResult(finderPath, finderArgs);
255
256 throw processException(e);
257 }
258 finally {
259 closeSession(session);
260 }
261 }
262
263 return list;
264 }
265
266
275 public AssetVocabulary findByUuid_First(String uuid,
276 OrderByComparator orderByComparator)
277 throws NoSuchVocabularyException, SystemException {
278 AssetVocabulary assetVocabulary = fetchByUuid_First(uuid,
279 orderByComparator);
280
281 if (assetVocabulary != null) {
282 return assetVocabulary;
283 }
284
285 StringBundler msg = new StringBundler(4);
286
287 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
288
289 msg.append("uuid=");
290 msg.append(uuid);
291
292 msg.append(StringPool.CLOSE_CURLY_BRACE);
293
294 throw new NoSuchVocabularyException(msg.toString());
295 }
296
297
305 public AssetVocabulary fetchByUuid_First(String uuid,
306 OrderByComparator orderByComparator) throws SystemException {
307 List<AssetVocabulary> list = findByUuid(uuid, 0, 1, orderByComparator);
308
309 if (!list.isEmpty()) {
310 return list.get(0);
311 }
312
313 return null;
314 }
315
316
325 public AssetVocabulary findByUuid_Last(String uuid,
326 OrderByComparator orderByComparator)
327 throws NoSuchVocabularyException, SystemException {
328 AssetVocabulary assetVocabulary = fetchByUuid_Last(uuid,
329 orderByComparator);
330
331 if (assetVocabulary != null) {
332 return assetVocabulary;
333 }
334
335 StringBundler msg = new StringBundler(4);
336
337 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
338
339 msg.append("uuid=");
340 msg.append(uuid);
341
342 msg.append(StringPool.CLOSE_CURLY_BRACE);
343
344 throw new NoSuchVocabularyException(msg.toString());
345 }
346
347
355 public AssetVocabulary fetchByUuid_Last(String uuid,
356 OrderByComparator orderByComparator) throws SystemException {
357 int count = countByUuid(uuid);
358
359 List<AssetVocabulary> list = findByUuid(uuid, count - 1, count,
360 orderByComparator);
361
362 if (!list.isEmpty()) {
363 return list.get(0);
364 }
365
366 return null;
367 }
368
369
379 public AssetVocabulary[] findByUuid_PrevAndNext(long vocabularyId,
380 String uuid, OrderByComparator orderByComparator)
381 throws NoSuchVocabularyException, SystemException {
382 AssetVocabulary assetVocabulary = findByPrimaryKey(vocabularyId);
383
384 Session session = null;
385
386 try {
387 session = openSession();
388
389 AssetVocabulary[] array = new AssetVocabularyImpl[3];
390
391 array[0] = getByUuid_PrevAndNext(session, assetVocabulary, uuid,
392 orderByComparator, true);
393
394 array[1] = assetVocabulary;
395
396 array[2] = getByUuid_PrevAndNext(session, assetVocabulary, uuid,
397 orderByComparator, false);
398
399 return array;
400 }
401 catch (Exception e) {
402 throw processException(e);
403 }
404 finally {
405 closeSession(session);
406 }
407 }
408
409 protected AssetVocabulary getByUuid_PrevAndNext(Session session,
410 AssetVocabulary assetVocabulary, String uuid,
411 OrderByComparator orderByComparator, boolean previous) {
412 StringBundler query = null;
413
414 if (orderByComparator != null) {
415 query = new StringBundler(6 +
416 (orderByComparator.getOrderByFields().length * 6));
417 }
418 else {
419 query = new StringBundler(3);
420 }
421
422 query.append(_SQL_SELECT_ASSETVOCABULARY_WHERE);
423
424 boolean bindUuid = false;
425
426 if (uuid == null) {
427 query.append(_FINDER_COLUMN_UUID_UUID_1);
428 }
429 else if (uuid.equals(StringPool.BLANK)) {
430 query.append(_FINDER_COLUMN_UUID_UUID_3);
431 }
432 else {
433 bindUuid = true;
434
435 query.append(_FINDER_COLUMN_UUID_UUID_2);
436 }
437
438 if (orderByComparator != null) {
439 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
440
441 if (orderByConditionFields.length > 0) {
442 query.append(WHERE_AND);
443 }
444
445 for (int i = 0; i < orderByConditionFields.length; i++) {
446 query.append(_ORDER_BY_ENTITY_ALIAS);
447 query.append(orderByConditionFields[i]);
448
449 if ((i + 1) < orderByConditionFields.length) {
450 if (orderByComparator.isAscending() ^ previous) {
451 query.append(WHERE_GREATER_THAN_HAS_NEXT);
452 }
453 else {
454 query.append(WHERE_LESSER_THAN_HAS_NEXT);
455 }
456 }
457 else {
458 if (orderByComparator.isAscending() ^ previous) {
459 query.append(WHERE_GREATER_THAN);
460 }
461 else {
462 query.append(WHERE_LESSER_THAN);
463 }
464 }
465 }
466
467 query.append(ORDER_BY_CLAUSE);
468
469 String[] orderByFields = orderByComparator.getOrderByFields();
470
471 for (int i = 0; i < orderByFields.length; i++) {
472 query.append(_ORDER_BY_ENTITY_ALIAS);
473 query.append(orderByFields[i]);
474
475 if ((i + 1) < orderByFields.length) {
476 if (orderByComparator.isAscending() ^ previous) {
477 query.append(ORDER_BY_ASC_HAS_NEXT);
478 }
479 else {
480 query.append(ORDER_BY_DESC_HAS_NEXT);
481 }
482 }
483 else {
484 if (orderByComparator.isAscending() ^ previous) {
485 query.append(ORDER_BY_ASC);
486 }
487 else {
488 query.append(ORDER_BY_DESC);
489 }
490 }
491 }
492 }
493 else {
494 query.append(AssetVocabularyModelImpl.ORDER_BY_JPQL);
495 }
496
497 String sql = query.toString();
498
499 Query q = session.createQuery(sql);
500
501 q.setFirstResult(0);
502 q.setMaxResults(2);
503
504 QueryPos qPos = QueryPos.getInstance(q);
505
506 if (bindUuid) {
507 qPos.add(uuid);
508 }
509
510 if (orderByComparator != null) {
511 Object[] values = orderByComparator.getOrderByConditionValues(assetVocabulary);
512
513 for (Object value : values) {
514 qPos.add(value);
515 }
516 }
517
518 List<AssetVocabulary> list = q.list();
519
520 if (list.size() == 2) {
521 return list.get(1);
522 }
523 else {
524 return null;
525 }
526 }
527
528
534 public void removeByUuid(String uuid) throws SystemException {
535 for (AssetVocabulary assetVocabulary : findByUuid(uuid,
536 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
537 remove(assetVocabulary);
538 }
539 }
540
541
548 public int countByUuid(String uuid) throws SystemException {
549 FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID;
550
551 Object[] finderArgs = new Object[] { uuid };
552
553 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
554 this);
555
556 if (count == null) {
557 StringBundler query = new StringBundler(2);
558
559 query.append(_SQL_COUNT_ASSETVOCABULARY_WHERE);
560
561 boolean bindUuid = false;
562
563 if (uuid == null) {
564 query.append(_FINDER_COLUMN_UUID_UUID_1);
565 }
566 else if (uuid.equals(StringPool.BLANK)) {
567 query.append(_FINDER_COLUMN_UUID_UUID_3);
568 }
569 else {
570 bindUuid = true;
571
572 query.append(_FINDER_COLUMN_UUID_UUID_2);
573 }
574
575 String sql = query.toString();
576
577 Session session = null;
578
579 try {
580 session = openSession();
581
582 Query q = session.createQuery(sql);
583
584 QueryPos qPos = QueryPos.getInstance(q);
585
586 if (bindUuid) {
587 qPos.add(uuid);
588 }
589
590 count = (Long)q.uniqueResult();
591
592 FinderCacheUtil.putResult(finderPath, finderArgs, count);
593 }
594 catch (Exception e) {
595 FinderCacheUtil.removeResult(finderPath, finderArgs);
596
597 throw processException(e);
598 }
599 finally {
600 closeSession(session);
601 }
602 }
603
604 return count.intValue();
605 }
606
607 private static final String _FINDER_COLUMN_UUID_UUID_1 = "assetVocabulary.uuid IS NULL";
608 private static final String _FINDER_COLUMN_UUID_UUID_2 = "assetVocabulary.uuid = ?";
609 private static final String _FINDER_COLUMN_UUID_UUID_3 = "(assetVocabulary.uuid IS NULL OR assetVocabulary.uuid = '')";
610 public static final FinderPath FINDER_PATH_FETCH_BY_UUID_G = new FinderPath(AssetVocabularyModelImpl.ENTITY_CACHE_ENABLED,
611 AssetVocabularyModelImpl.FINDER_CACHE_ENABLED,
612 AssetVocabularyImpl.class, FINDER_CLASS_NAME_ENTITY,
613 "fetchByUUID_G",
614 new String[] { String.class.getName(), Long.class.getName() },
615 AssetVocabularyModelImpl.UUID_COLUMN_BITMASK |
616 AssetVocabularyModelImpl.GROUPID_COLUMN_BITMASK);
617 public static final FinderPath FINDER_PATH_COUNT_BY_UUID_G = new FinderPath(AssetVocabularyModelImpl.ENTITY_CACHE_ENABLED,
618 AssetVocabularyModelImpl.FINDER_CACHE_ENABLED, Long.class,
619 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUUID_G",
620 new String[] { String.class.getName(), Long.class.getName() });
621
622
631 public AssetVocabulary findByUUID_G(String uuid, long groupId)
632 throws NoSuchVocabularyException, SystemException {
633 AssetVocabulary assetVocabulary = fetchByUUID_G(uuid, groupId);
634
635 if (assetVocabulary == null) {
636 StringBundler msg = new StringBundler(6);
637
638 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
639
640 msg.append("uuid=");
641 msg.append(uuid);
642
643 msg.append(", groupId=");
644 msg.append(groupId);
645
646 msg.append(StringPool.CLOSE_CURLY_BRACE);
647
648 if (_log.isWarnEnabled()) {
649 _log.warn(msg.toString());
650 }
651
652 throw new NoSuchVocabularyException(msg.toString());
653 }
654
655 return assetVocabulary;
656 }
657
658
666 public AssetVocabulary fetchByUUID_G(String uuid, long groupId)
667 throws SystemException {
668 return fetchByUUID_G(uuid, groupId, true);
669 }
670
671
680 public AssetVocabulary fetchByUUID_G(String uuid, long groupId,
681 boolean retrieveFromCache) throws SystemException {
682 Object[] finderArgs = new Object[] { uuid, groupId };
683
684 Object result = null;
685
686 if (retrieveFromCache) {
687 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_UUID_G,
688 finderArgs, this);
689 }
690
691 if (result instanceof AssetVocabulary) {
692 AssetVocabulary assetVocabulary = (AssetVocabulary)result;
693
694 if (!Validator.equals(uuid, assetVocabulary.getUuid()) ||
695 (groupId != assetVocabulary.getGroupId())) {
696 result = null;
697 }
698 }
699
700 if (result == null) {
701 StringBundler query = new StringBundler(4);
702
703 query.append(_SQL_SELECT_ASSETVOCABULARY_WHERE);
704
705 boolean bindUuid = false;
706
707 if (uuid == null) {
708 query.append(_FINDER_COLUMN_UUID_G_UUID_1);
709 }
710 else if (uuid.equals(StringPool.BLANK)) {
711 query.append(_FINDER_COLUMN_UUID_G_UUID_3);
712 }
713 else {
714 bindUuid = true;
715
716 query.append(_FINDER_COLUMN_UUID_G_UUID_2);
717 }
718
719 query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
720
721 String sql = query.toString();
722
723 Session session = null;
724
725 try {
726 session = openSession();
727
728 Query q = session.createQuery(sql);
729
730 QueryPos qPos = QueryPos.getInstance(q);
731
732 if (bindUuid) {
733 qPos.add(uuid);
734 }
735
736 qPos.add(groupId);
737
738 List<AssetVocabulary> list = q.list();
739
740 if (list.isEmpty()) {
741 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
742 finderArgs, list);
743 }
744 else {
745 AssetVocabulary assetVocabulary = list.get(0);
746
747 result = assetVocabulary;
748
749 cacheResult(assetVocabulary);
750
751 if ((assetVocabulary.getUuid() == null) ||
752 !assetVocabulary.getUuid().equals(uuid) ||
753 (assetVocabulary.getGroupId() != groupId)) {
754 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
755 finderArgs, assetVocabulary);
756 }
757 }
758 }
759 catch (Exception e) {
760 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
761 finderArgs);
762
763 throw processException(e);
764 }
765 finally {
766 closeSession(session);
767 }
768 }
769
770 if (result instanceof List<?>) {
771 return null;
772 }
773 else {
774 return (AssetVocabulary)result;
775 }
776 }
777
778
786 public AssetVocabulary removeByUUID_G(String uuid, long groupId)
787 throws NoSuchVocabularyException, SystemException {
788 AssetVocabulary assetVocabulary = findByUUID_G(uuid, groupId);
789
790 return remove(assetVocabulary);
791 }
792
793
801 public int countByUUID_G(String uuid, long groupId)
802 throws SystemException {
803 FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID_G;
804
805 Object[] finderArgs = new Object[] { uuid, groupId };
806
807 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
808 this);
809
810 if (count == null) {
811 StringBundler query = new StringBundler(3);
812
813 query.append(_SQL_COUNT_ASSETVOCABULARY_WHERE);
814
815 boolean bindUuid = false;
816
817 if (uuid == null) {
818 query.append(_FINDER_COLUMN_UUID_G_UUID_1);
819 }
820 else if (uuid.equals(StringPool.BLANK)) {
821 query.append(_FINDER_COLUMN_UUID_G_UUID_3);
822 }
823 else {
824 bindUuid = true;
825
826 query.append(_FINDER_COLUMN_UUID_G_UUID_2);
827 }
828
829 query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
830
831 String sql = query.toString();
832
833 Session session = null;
834
835 try {
836 session = openSession();
837
838 Query q = session.createQuery(sql);
839
840 QueryPos qPos = QueryPos.getInstance(q);
841
842 if (bindUuid) {
843 qPos.add(uuid);
844 }
845
846 qPos.add(groupId);
847
848 count = (Long)q.uniqueResult();
849
850 FinderCacheUtil.putResult(finderPath, finderArgs, count);
851 }
852 catch (Exception e) {
853 FinderCacheUtil.removeResult(finderPath, finderArgs);
854
855 throw processException(e);
856 }
857 finally {
858 closeSession(session);
859 }
860 }
861
862 return count.intValue();
863 }
864
865 private static final String _FINDER_COLUMN_UUID_G_UUID_1 = "assetVocabulary.uuid IS NULL AND ";
866 private static final String _FINDER_COLUMN_UUID_G_UUID_2 = "assetVocabulary.uuid = ? AND ";
867 private static final String _FINDER_COLUMN_UUID_G_UUID_3 = "(assetVocabulary.uuid IS NULL OR assetVocabulary.uuid = '') AND ";
868 private static final String _FINDER_COLUMN_UUID_G_GROUPID_2 = "assetVocabulary.groupId = ?";
869 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID_C = new FinderPath(AssetVocabularyModelImpl.ENTITY_CACHE_ENABLED,
870 AssetVocabularyModelImpl.FINDER_CACHE_ENABLED,
871 AssetVocabularyImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
872 "findByUuid_C",
873 new String[] {
874 String.class.getName(), Long.class.getName(),
875
876 Integer.class.getName(), Integer.class.getName(),
877 OrderByComparator.class.getName()
878 });
879 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C =
880 new FinderPath(AssetVocabularyModelImpl.ENTITY_CACHE_ENABLED,
881 AssetVocabularyModelImpl.FINDER_CACHE_ENABLED,
882 AssetVocabularyImpl.class,
883 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid_C",
884 new String[] { String.class.getName(), Long.class.getName() },
885 AssetVocabularyModelImpl.UUID_COLUMN_BITMASK |
886 AssetVocabularyModelImpl.COMPANYID_COLUMN_BITMASK |
887 AssetVocabularyModelImpl.NAME_COLUMN_BITMASK);
888 public static final FinderPath FINDER_PATH_COUNT_BY_UUID_C = new FinderPath(AssetVocabularyModelImpl.ENTITY_CACHE_ENABLED,
889 AssetVocabularyModelImpl.FINDER_CACHE_ENABLED, Long.class,
890 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid_C",
891 new String[] { String.class.getName(), Long.class.getName() });
892
893
901 public List<AssetVocabulary> findByUuid_C(String uuid, long companyId)
902 throws SystemException {
903 return findByUuid_C(uuid, companyId, QueryUtil.ALL_POS,
904 QueryUtil.ALL_POS, null);
905 }
906
907
921 public List<AssetVocabulary> findByUuid_C(String uuid, long companyId,
922 int start, int end) throws SystemException {
923 return findByUuid_C(uuid, companyId, start, end, null);
924 }
925
926
941 public List<AssetVocabulary> findByUuid_C(String uuid, long companyId,
942 int start, int end, OrderByComparator orderByComparator)
943 throws SystemException {
944 boolean pagination = true;
945 FinderPath finderPath = null;
946 Object[] finderArgs = null;
947
948 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
949 (orderByComparator == null)) {
950 pagination = false;
951 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C;
952 finderArgs = new Object[] { uuid, companyId };
953 }
954 else {
955 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID_C;
956 finderArgs = new Object[] {
957 uuid, companyId,
958
959 start, end, orderByComparator
960 };
961 }
962
963 List<AssetVocabulary> list = (List<AssetVocabulary>)FinderCacheUtil.getResult(finderPath,
964 finderArgs, this);
965
966 if ((list != null) && !list.isEmpty()) {
967 for (AssetVocabulary assetVocabulary : list) {
968 if (!Validator.equals(uuid, assetVocabulary.getUuid()) ||
969 (companyId != assetVocabulary.getCompanyId())) {
970 list = null;
971
972 break;
973 }
974 }
975 }
976
977 if (list == null) {
978 StringBundler query = null;
979
980 if (orderByComparator != null) {
981 query = new StringBundler(4 +
982 (orderByComparator.getOrderByFields().length * 3));
983 }
984 else {
985 query = new StringBundler(4);
986 }
987
988 query.append(_SQL_SELECT_ASSETVOCABULARY_WHERE);
989
990 boolean bindUuid = false;
991
992 if (uuid == null) {
993 query.append(_FINDER_COLUMN_UUID_C_UUID_1);
994 }
995 else if (uuid.equals(StringPool.BLANK)) {
996 query.append(_FINDER_COLUMN_UUID_C_UUID_3);
997 }
998 else {
999 bindUuid = true;
1000
1001 query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1002 }
1003
1004 query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1005
1006 if (orderByComparator != null) {
1007 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1008 orderByComparator);
1009 }
1010 else
1011 if (pagination) {
1012 query.append(AssetVocabularyModelImpl.ORDER_BY_JPQL);
1013 }
1014
1015 String sql = query.toString();
1016
1017 Session session = null;
1018
1019 try {
1020 session = openSession();
1021
1022 Query q = session.createQuery(sql);
1023
1024 QueryPos qPos = QueryPos.getInstance(q);
1025
1026 if (bindUuid) {
1027 qPos.add(uuid);
1028 }
1029
1030 qPos.add(companyId);
1031
1032 if (!pagination) {
1033 list = (List<AssetVocabulary>)QueryUtil.list(q,
1034 getDialect(), start, end, false);
1035
1036 Collections.sort(list);
1037
1038 list = new UnmodifiableList<AssetVocabulary>(list);
1039 }
1040 else {
1041 list = (List<AssetVocabulary>)QueryUtil.list(q,
1042 getDialect(), start, end);
1043 }
1044
1045 cacheResult(list);
1046
1047 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1048 }
1049 catch (Exception e) {
1050 FinderCacheUtil.removeResult(finderPath, finderArgs);
1051
1052 throw processException(e);
1053 }
1054 finally {
1055 closeSession(session);
1056 }
1057 }
1058
1059 return list;
1060 }
1061
1062
1072 public AssetVocabulary findByUuid_C_First(String uuid, long companyId,
1073 OrderByComparator orderByComparator)
1074 throws NoSuchVocabularyException, SystemException {
1075 AssetVocabulary assetVocabulary = fetchByUuid_C_First(uuid, companyId,
1076 orderByComparator);
1077
1078 if (assetVocabulary != null) {
1079 return assetVocabulary;
1080 }
1081
1082 StringBundler msg = new StringBundler(6);
1083
1084 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1085
1086 msg.append("uuid=");
1087 msg.append(uuid);
1088
1089 msg.append(", companyId=");
1090 msg.append(companyId);
1091
1092 msg.append(StringPool.CLOSE_CURLY_BRACE);
1093
1094 throw new NoSuchVocabularyException(msg.toString());
1095 }
1096
1097
1106 public AssetVocabulary fetchByUuid_C_First(String uuid, long companyId,
1107 OrderByComparator orderByComparator) throws SystemException {
1108 List<AssetVocabulary> list = findByUuid_C(uuid, companyId, 0, 1,
1109 orderByComparator);
1110
1111 if (!list.isEmpty()) {
1112 return list.get(0);
1113 }
1114
1115 return null;
1116 }
1117
1118
1128 public AssetVocabulary findByUuid_C_Last(String uuid, long companyId,
1129 OrderByComparator orderByComparator)
1130 throws NoSuchVocabularyException, SystemException {
1131 AssetVocabulary assetVocabulary = fetchByUuid_C_Last(uuid, companyId,
1132 orderByComparator);
1133
1134 if (assetVocabulary != null) {
1135 return assetVocabulary;
1136 }
1137
1138 StringBundler msg = new StringBundler(6);
1139
1140 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1141
1142 msg.append("uuid=");
1143 msg.append(uuid);
1144
1145 msg.append(", companyId=");
1146 msg.append(companyId);
1147
1148 msg.append(StringPool.CLOSE_CURLY_BRACE);
1149
1150 throw new NoSuchVocabularyException(msg.toString());
1151 }
1152
1153
1162 public AssetVocabulary fetchByUuid_C_Last(String uuid, long companyId,
1163 OrderByComparator orderByComparator) throws SystemException {
1164 int count = countByUuid_C(uuid, companyId);
1165
1166 List<AssetVocabulary> list = findByUuid_C(uuid, companyId, count - 1,
1167 count, orderByComparator);
1168
1169 if (!list.isEmpty()) {
1170 return list.get(0);
1171 }
1172
1173 return null;
1174 }
1175
1176
1187 public AssetVocabulary[] findByUuid_C_PrevAndNext(long vocabularyId,
1188 String uuid, long companyId, OrderByComparator orderByComparator)
1189 throws NoSuchVocabularyException, SystemException {
1190 AssetVocabulary assetVocabulary = findByPrimaryKey(vocabularyId);
1191
1192 Session session = null;
1193
1194 try {
1195 session = openSession();
1196
1197 AssetVocabulary[] array = new AssetVocabularyImpl[3];
1198
1199 array[0] = getByUuid_C_PrevAndNext(session, assetVocabulary, uuid,
1200 companyId, orderByComparator, true);
1201
1202 array[1] = assetVocabulary;
1203
1204 array[2] = getByUuid_C_PrevAndNext(session, assetVocabulary, uuid,
1205 companyId, orderByComparator, false);
1206
1207 return array;
1208 }
1209 catch (Exception e) {
1210 throw processException(e);
1211 }
1212 finally {
1213 closeSession(session);
1214 }
1215 }
1216
1217 protected AssetVocabulary getByUuid_C_PrevAndNext(Session session,
1218 AssetVocabulary assetVocabulary, String uuid, long companyId,
1219 OrderByComparator orderByComparator, boolean previous) {
1220 StringBundler query = null;
1221
1222 if (orderByComparator != null) {
1223 query = new StringBundler(6 +
1224 (orderByComparator.getOrderByFields().length * 6));
1225 }
1226 else {
1227 query = new StringBundler(3);
1228 }
1229
1230 query.append(_SQL_SELECT_ASSETVOCABULARY_WHERE);
1231
1232 boolean bindUuid = false;
1233
1234 if (uuid == null) {
1235 query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1236 }
1237 else if (uuid.equals(StringPool.BLANK)) {
1238 query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1239 }
1240 else {
1241 bindUuid = true;
1242
1243 query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1244 }
1245
1246 query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1247
1248 if (orderByComparator != null) {
1249 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1250
1251 if (orderByConditionFields.length > 0) {
1252 query.append(WHERE_AND);
1253 }
1254
1255 for (int i = 0; i < orderByConditionFields.length; i++) {
1256 query.append(_ORDER_BY_ENTITY_ALIAS);
1257 query.append(orderByConditionFields[i]);
1258
1259 if ((i + 1) < orderByConditionFields.length) {
1260 if (orderByComparator.isAscending() ^ previous) {
1261 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1262 }
1263 else {
1264 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1265 }
1266 }
1267 else {
1268 if (orderByComparator.isAscending() ^ previous) {
1269 query.append(WHERE_GREATER_THAN);
1270 }
1271 else {
1272 query.append(WHERE_LESSER_THAN);
1273 }
1274 }
1275 }
1276
1277 query.append(ORDER_BY_CLAUSE);
1278
1279 String[] orderByFields = orderByComparator.getOrderByFields();
1280
1281 for (int i = 0; i < orderByFields.length; i++) {
1282 query.append(_ORDER_BY_ENTITY_ALIAS);
1283 query.append(orderByFields[i]);
1284
1285 if ((i + 1) < orderByFields.length) {
1286 if (orderByComparator.isAscending() ^ previous) {
1287 query.append(ORDER_BY_ASC_HAS_NEXT);
1288 }
1289 else {
1290 query.append(ORDER_BY_DESC_HAS_NEXT);
1291 }
1292 }
1293 else {
1294 if (orderByComparator.isAscending() ^ previous) {
1295 query.append(ORDER_BY_ASC);
1296 }
1297 else {
1298 query.append(ORDER_BY_DESC);
1299 }
1300 }
1301 }
1302 }
1303 else {
1304 query.append(AssetVocabularyModelImpl.ORDER_BY_JPQL);
1305 }
1306
1307 String sql = query.toString();
1308
1309 Query q = session.createQuery(sql);
1310
1311 q.setFirstResult(0);
1312 q.setMaxResults(2);
1313
1314 QueryPos qPos = QueryPos.getInstance(q);
1315
1316 if (bindUuid) {
1317 qPos.add(uuid);
1318 }
1319
1320 qPos.add(companyId);
1321
1322 if (orderByComparator != null) {
1323 Object[] values = orderByComparator.getOrderByConditionValues(assetVocabulary);
1324
1325 for (Object value : values) {
1326 qPos.add(value);
1327 }
1328 }
1329
1330 List<AssetVocabulary> list = q.list();
1331
1332 if (list.size() == 2) {
1333 return list.get(1);
1334 }
1335 else {
1336 return null;
1337 }
1338 }
1339
1340
1347 public void removeByUuid_C(String uuid, long companyId)
1348 throws SystemException {
1349 for (AssetVocabulary assetVocabulary : findByUuid_C(uuid, companyId,
1350 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
1351 remove(assetVocabulary);
1352 }
1353 }
1354
1355
1363 public int countByUuid_C(String uuid, long companyId)
1364 throws SystemException {
1365 FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID_C;
1366
1367 Object[] finderArgs = new Object[] { uuid, companyId };
1368
1369 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
1370 this);
1371
1372 if (count == null) {
1373 StringBundler query = new StringBundler(3);
1374
1375 query.append(_SQL_COUNT_ASSETVOCABULARY_WHERE);
1376
1377 boolean bindUuid = false;
1378
1379 if (uuid == null) {
1380 query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1381 }
1382 else if (uuid.equals(StringPool.BLANK)) {
1383 query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1384 }
1385 else {
1386 bindUuid = true;
1387
1388 query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1389 }
1390
1391 query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1392
1393 String sql = query.toString();
1394
1395 Session session = null;
1396
1397 try {
1398 session = openSession();
1399
1400 Query q = session.createQuery(sql);
1401
1402 QueryPos qPos = QueryPos.getInstance(q);
1403
1404 if (bindUuid) {
1405 qPos.add(uuid);
1406 }
1407
1408 qPos.add(companyId);
1409
1410 count = (Long)q.uniqueResult();
1411
1412 FinderCacheUtil.putResult(finderPath, finderArgs, count);
1413 }
1414 catch (Exception e) {
1415 FinderCacheUtil.removeResult(finderPath, finderArgs);
1416
1417 throw processException(e);
1418 }
1419 finally {
1420 closeSession(session);
1421 }
1422 }
1423
1424 return count.intValue();
1425 }
1426
1427 private static final String _FINDER_COLUMN_UUID_C_UUID_1 = "assetVocabulary.uuid IS NULL AND ";
1428 private static final String _FINDER_COLUMN_UUID_C_UUID_2 = "assetVocabulary.uuid = ? AND ";
1429 private static final String _FINDER_COLUMN_UUID_C_UUID_3 = "(assetVocabulary.uuid IS NULL OR assetVocabulary.uuid = '') AND ";
1430 private static final String _FINDER_COLUMN_UUID_C_COMPANYID_2 = "assetVocabulary.companyId = ?";
1431 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID = new FinderPath(AssetVocabularyModelImpl.ENTITY_CACHE_ENABLED,
1432 AssetVocabularyModelImpl.FINDER_CACHE_ENABLED,
1433 AssetVocabularyImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
1434 "findByGroupId",
1435 new String[] {
1436 Long.class.getName(),
1437
1438 Integer.class.getName(), Integer.class.getName(),
1439 OrderByComparator.class.getName()
1440 });
1441 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID =
1442 new FinderPath(AssetVocabularyModelImpl.ENTITY_CACHE_ENABLED,
1443 AssetVocabularyModelImpl.FINDER_CACHE_ENABLED,
1444 AssetVocabularyImpl.class,
1445 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByGroupId",
1446 new String[] { Long.class.getName() },
1447 AssetVocabularyModelImpl.GROUPID_COLUMN_BITMASK |
1448 AssetVocabularyModelImpl.NAME_COLUMN_BITMASK);
1449 public static final FinderPath FINDER_PATH_COUNT_BY_GROUPID = new FinderPath(AssetVocabularyModelImpl.ENTITY_CACHE_ENABLED,
1450 AssetVocabularyModelImpl.FINDER_CACHE_ENABLED, Long.class,
1451 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByGroupId",
1452 new String[] { Long.class.getName() });
1453
1454
1461 public List<AssetVocabulary> findByGroupId(long groupId)
1462 throws SystemException {
1463 return findByGroupId(groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1464 }
1465
1466
1479 public List<AssetVocabulary> findByGroupId(long groupId, int start, int end)
1480 throws SystemException {
1481 return findByGroupId(groupId, start, end, null);
1482 }
1483
1484
1498 public List<AssetVocabulary> findByGroupId(long groupId, int start,
1499 int end, OrderByComparator orderByComparator) throws SystemException {
1500 boolean pagination = true;
1501 FinderPath finderPath = null;
1502 Object[] finderArgs = null;
1503
1504 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1505 (orderByComparator == null)) {
1506 pagination = false;
1507 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID;
1508 finderArgs = new Object[] { groupId };
1509 }
1510 else {
1511 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID;
1512 finderArgs = new Object[] { groupId, start, end, orderByComparator };
1513 }
1514
1515 List<AssetVocabulary> list = (List<AssetVocabulary>)FinderCacheUtil.getResult(finderPath,
1516 finderArgs, this);
1517
1518 if ((list != null) && !list.isEmpty()) {
1519 for (AssetVocabulary assetVocabulary : list) {
1520 if ((groupId != assetVocabulary.getGroupId())) {
1521 list = null;
1522
1523 break;
1524 }
1525 }
1526 }
1527
1528 if (list == null) {
1529 StringBundler query = null;
1530
1531 if (orderByComparator != null) {
1532 query = new StringBundler(3 +
1533 (orderByComparator.getOrderByFields().length * 3));
1534 }
1535 else {
1536 query = new StringBundler(3);
1537 }
1538
1539 query.append(_SQL_SELECT_ASSETVOCABULARY_WHERE);
1540
1541 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1542
1543 if (orderByComparator != null) {
1544 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1545 orderByComparator);
1546 }
1547 else
1548 if (pagination) {
1549 query.append(AssetVocabularyModelImpl.ORDER_BY_JPQL);
1550 }
1551
1552 String sql = query.toString();
1553
1554 Session session = null;
1555
1556 try {
1557 session = openSession();
1558
1559 Query q = session.createQuery(sql);
1560
1561 QueryPos qPos = QueryPos.getInstance(q);
1562
1563 qPos.add(groupId);
1564
1565 if (!pagination) {
1566 list = (List<AssetVocabulary>)QueryUtil.list(q,
1567 getDialect(), start, end, false);
1568
1569 Collections.sort(list);
1570
1571 list = new UnmodifiableList<AssetVocabulary>(list);
1572 }
1573 else {
1574 list = (List<AssetVocabulary>)QueryUtil.list(q,
1575 getDialect(), start, end);
1576 }
1577
1578 cacheResult(list);
1579
1580 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1581 }
1582 catch (Exception e) {
1583 FinderCacheUtil.removeResult(finderPath, finderArgs);
1584
1585 throw processException(e);
1586 }
1587 finally {
1588 closeSession(session);
1589 }
1590 }
1591
1592 return list;
1593 }
1594
1595
1604 public AssetVocabulary findByGroupId_First(long groupId,
1605 OrderByComparator orderByComparator)
1606 throws NoSuchVocabularyException, SystemException {
1607 AssetVocabulary assetVocabulary = fetchByGroupId_First(groupId,
1608 orderByComparator);
1609
1610 if (assetVocabulary != null) {
1611 return assetVocabulary;
1612 }
1613
1614 StringBundler msg = new StringBundler(4);
1615
1616 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1617
1618 msg.append("groupId=");
1619 msg.append(groupId);
1620
1621 msg.append(StringPool.CLOSE_CURLY_BRACE);
1622
1623 throw new NoSuchVocabularyException(msg.toString());
1624 }
1625
1626
1634 public AssetVocabulary fetchByGroupId_First(long groupId,
1635 OrderByComparator orderByComparator) throws SystemException {
1636 List<AssetVocabulary> list = findByGroupId(groupId, 0, 1,
1637 orderByComparator);
1638
1639 if (!list.isEmpty()) {
1640 return list.get(0);
1641 }
1642
1643 return null;
1644 }
1645
1646
1655 public AssetVocabulary findByGroupId_Last(long groupId,
1656 OrderByComparator orderByComparator)
1657 throws NoSuchVocabularyException, SystemException {
1658 AssetVocabulary assetVocabulary = fetchByGroupId_Last(groupId,
1659 orderByComparator);
1660
1661 if (assetVocabulary != null) {
1662 return assetVocabulary;
1663 }
1664
1665 StringBundler msg = new StringBundler(4);
1666
1667 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1668
1669 msg.append("groupId=");
1670 msg.append(groupId);
1671
1672 msg.append(StringPool.CLOSE_CURLY_BRACE);
1673
1674 throw new NoSuchVocabularyException(msg.toString());
1675 }
1676
1677
1685 public AssetVocabulary fetchByGroupId_Last(long groupId,
1686 OrderByComparator orderByComparator) throws SystemException {
1687 int count = countByGroupId(groupId);
1688
1689 List<AssetVocabulary> list = findByGroupId(groupId, count - 1, count,
1690 orderByComparator);
1691
1692 if (!list.isEmpty()) {
1693 return list.get(0);
1694 }
1695
1696 return null;
1697 }
1698
1699
1709 public AssetVocabulary[] findByGroupId_PrevAndNext(long vocabularyId,
1710 long groupId, OrderByComparator orderByComparator)
1711 throws NoSuchVocabularyException, SystemException {
1712 AssetVocabulary assetVocabulary = findByPrimaryKey(vocabularyId);
1713
1714 Session session = null;
1715
1716 try {
1717 session = openSession();
1718
1719 AssetVocabulary[] array = new AssetVocabularyImpl[3];
1720
1721 array[0] = getByGroupId_PrevAndNext(session, assetVocabulary,
1722 groupId, orderByComparator, true);
1723
1724 array[1] = assetVocabulary;
1725
1726 array[2] = getByGroupId_PrevAndNext(session, assetVocabulary,
1727 groupId, orderByComparator, false);
1728
1729 return array;
1730 }
1731 catch (Exception e) {
1732 throw processException(e);
1733 }
1734 finally {
1735 closeSession(session);
1736 }
1737 }
1738
1739 protected AssetVocabulary getByGroupId_PrevAndNext(Session session,
1740 AssetVocabulary assetVocabulary, long groupId,
1741 OrderByComparator orderByComparator, boolean previous) {
1742 StringBundler query = null;
1743
1744 if (orderByComparator != null) {
1745 query = new StringBundler(6 +
1746 (orderByComparator.getOrderByFields().length * 6));
1747 }
1748 else {
1749 query = new StringBundler(3);
1750 }
1751
1752 query.append(_SQL_SELECT_ASSETVOCABULARY_WHERE);
1753
1754 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1755
1756 if (orderByComparator != null) {
1757 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1758
1759 if (orderByConditionFields.length > 0) {
1760 query.append(WHERE_AND);
1761 }
1762
1763 for (int i = 0; i < orderByConditionFields.length; i++) {
1764 query.append(_ORDER_BY_ENTITY_ALIAS);
1765 query.append(orderByConditionFields[i]);
1766
1767 if ((i + 1) < orderByConditionFields.length) {
1768 if (orderByComparator.isAscending() ^ previous) {
1769 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1770 }
1771 else {
1772 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1773 }
1774 }
1775 else {
1776 if (orderByComparator.isAscending() ^ previous) {
1777 query.append(WHERE_GREATER_THAN);
1778 }
1779 else {
1780 query.append(WHERE_LESSER_THAN);
1781 }
1782 }
1783 }
1784
1785 query.append(ORDER_BY_CLAUSE);
1786
1787 String[] orderByFields = orderByComparator.getOrderByFields();
1788
1789 for (int i = 0; i < orderByFields.length; i++) {
1790 query.append(_ORDER_BY_ENTITY_ALIAS);
1791 query.append(orderByFields[i]);
1792
1793 if ((i + 1) < orderByFields.length) {
1794 if (orderByComparator.isAscending() ^ previous) {
1795 query.append(ORDER_BY_ASC_HAS_NEXT);
1796 }
1797 else {
1798 query.append(ORDER_BY_DESC_HAS_NEXT);
1799 }
1800 }
1801 else {
1802 if (orderByComparator.isAscending() ^ previous) {
1803 query.append(ORDER_BY_ASC);
1804 }
1805 else {
1806 query.append(ORDER_BY_DESC);
1807 }
1808 }
1809 }
1810 }
1811 else {
1812 query.append(AssetVocabularyModelImpl.ORDER_BY_JPQL);
1813 }
1814
1815 String sql = query.toString();
1816
1817 Query q = session.createQuery(sql);
1818
1819 q.setFirstResult(0);
1820 q.setMaxResults(2);
1821
1822 QueryPos qPos = QueryPos.getInstance(q);
1823
1824 qPos.add(groupId);
1825
1826 if (orderByComparator != null) {
1827 Object[] values = orderByComparator.getOrderByConditionValues(assetVocabulary);
1828
1829 for (Object value : values) {
1830 qPos.add(value);
1831 }
1832 }
1833
1834 List<AssetVocabulary> list = q.list();
1835
1836 if (list.size() == 2) {
1837 return list.get(1);
1838 }
1839 else {
1840 return null;
1841 }
1842 }
1843
1844
1851 public List<AssetVocabulary> filterFindByGroupId(long groupId)
1852 throws SystemException {
1853 return filterFindByGroupId(groupId, QueryUtil.ALL_POS,
1854 QueryUtil.ALL_POS, null);
1855 }
1856
1857
1870 public List<AssetVocabulary> filterFindByGroupId(long groupId, int start,
1871 int end) throws SystemException {
1872 return filterFindByGroupId(groupId, start, end, null);
1873 }
1874
1875
1889 public List<AssetVocabulary> filterFindByGroupId(long groupId, int start,
1890 int end, OrderByComparator orderByComparator) throws SystemException {
1891 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
1892 return findByGroupId(groupId, start, end, orderByComparator);
1893 }
1894
1895 StringBundler query = null;
1896
1897 if (orderByComparator != null) {
1898 query = new StringBundler(3 +
1899 (orderByComparator.getOrderByFields().length * 3));
1900 }
1901 else {
1902 query = new StringBundler(3);
1903 }
1904
1905 if (getDB().isSupportsInlineDistinct()) {
1906 query.append(_FILTER_SQL_SELECT_ASSETVOCABULARY_WHERE);
1907 }
1908 else {
1909 query.append(_FILTER_SQL_SELECT_ASSETVOCABULARY_NO_INLINE_DISTINCT_WHERE_1);
1910 }
1911
1912 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1913
1914 if (!getDB().isSupportsInlineDistinct()) {
1915 query.append(_FILTER_SQL_SELECT_ASSETVOCABULARY_NO_INLINE_DISTINCT_WHERE_2);
1916 }
1917
1918 if (orderByComparator != null) {
1919 if (getDB().isSupportsInlineDistinct()) {
1920 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1921 orderByComparator);
1922 }
1923 else {
1924 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
1925 orderByComparator);
1926 }
1927 }
1928 else {
1929 if (getDB().isSupportsInlineDistinct()) {
1930 query.append(AssetVocabularyModelImpl.ORDER_BY_JPQL);
1931 }
1932 else {
1933 query.append(AssetVocabularyModelImpl.ORDER_BY_SQL);
1934 }
1935 }
1936
1937 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1938 AssetVocabulary.class.getName(),
1939 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
1940
1941 Session session = null;
1942
1943 try {
1944 session = openSession();
1945
1946 SQLQuery q = session.createSQLQuery(sql);
1947
1948 if (getDB().isSupportsInlineDistinct()) {
1949 q.addEntity(_FILTER_ENTITY_ALIAS, AssetVocabularyImpl.class);
1950 }
1951 else {
1952 q.addEntity(_FILTER_ENTITY_TABLE, AssetVocabularyImpl.class);
1953 }
1954
1955 QueryPos qPos = QueryPos.getInstance(q);
1956
1957 qPos.add(groupId);
1958
1959 return (List<AssetVocabulary>)QueryUtil.list(q, getDialect(),
1960 start, end);
1961 }
1962 catch (Exception e) {
1963 throw processException(e);
1964 }
1965 finally {
1966 closeSession(session);
1967 }
1968 }
1969
1970
1980 public AssetVocabulary[] filterFindByGroupId_PrevAndNext(
1981 long vocabularyId, long groupId, OrderByComparator orderByComparator)
1982 throws NoSuchVocabularyException, SystemException {
1983 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
1984 return findByGroupId_PrevAndNext(vocabularyId, groupId,
1985 orderByComparator);
1986 }
1987
1988 AssetVocabulary assetVocabulary = findByPrimaryKey(vocabularyId);
1989
1990 Session session = null;
1991
1992 try {
1993 session = openSession();
1994
1995 AssetVocabulary[] array = new AssetVocabularyImpl[3];
1996
1997 array[0] = filterGetByGroupId_PrevAndNext(session, assetVocabulary,
1998 groupId, orderByComparator, true);
1999
2000 array[1] = assetVocabulary;
2001
2002 array[2] = filterGetByGroupId_PrevAndNext(session, assetVocabulary,
2003 groupId, orderByComparator, false);
2004
2005 return array;
2006 }
2007 catch (Exception e) {
2008 throw processException(e);
2009 }
2010 finally {
2011 closeSession(session);
2012 }
2013 }
2014
2015 protected AssetVocabulary filterGetByGroupId_PrevAndNext(Session session,
2016 AssetVocabulary assetVocabulary, long groupId,
2017 OrderByComparator orderByComparator, boolean previous) {
2018 StringBundler query = null;
2019
2020 if (orderByComparator != null) {
2021 query = new StringBundler(6 +
2022 (orderByComparator.getOrderByFields().length * 6));
2023 }
2024 else {
2025 query = new StringBundler(3);
2026 }
2027
2028 if (getDB().isSupportsInlineDistinct()) {
2029 query.append(_FILTER_SQL_SELECT_ASSETVOCABULARY_WHERE);
2030 }
2031 else {
2032 query.append(_FILTER_SQL_SELECT_ASSETVOCABULARY_NO_INLINE_DISTINCT_WHERE_1);
2033 }
2034
2035 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2036
2037 if (!getDB().isSupportsInlineDistinct()) {
2038 query.append(_FILTER_SQL_SELECT_ASSETVOCABULARY_NO_INLINE_DISTINCT_WHERE_2);
2039 }
2040
2041 if (orderByComparator != null) {
2042 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2043
2044 if (orderByConditionFields.length > 0) {
2045 query.append(WHERE_AND);
2046 }
2047
2048 for (int i = 0; i < orderByConditionFields.length; i++) {
2049 if (getDB().isSupportsInlineDistinct()) {
2050 query.append(_ORDER_BY_ENTITY_ALIAS);
2051 }
2052 else {
2053 query.append(_ORDER_BY_ENTITY_TABLE);
2054 }
2055
2056 query.append(orderByConditionFields[i]);
2057
2058 if ((i + 1) < orderByConditionFields.length) {
2059 if (orderByComparator.isAscending() ^ previous) {
2060 query.append(WHERE_GREATER_THAN_HAS_NEXT);
2061 }
2062 else {
2063 query.append(WHERE_LESSER_THAN_HAS_NEXT);
2064 }
2065 }
2066 else {
2067 if (orderByComparator.isAscending() ^ previous) {
2068 query.append(WHERE_GREATER_THAN);
2069 }
2070 else {
2071 query.append(WHERE_LESSER_THAN);
2072 }
2073 }
2074 }
2075
2076 query.append(ORDER_BY_CLAUSE);
2077
2078 String[] orderByFields = orderByComparator.getOrderByFields();
2079
2080 for (int i = 0; i < orderByFields.length; i++) {
2081 if (getDB().isSupportsInlineDistinct()) {
2082 query.append(_ORDER_BY_ENTITY_ALIAS);
2083 }
2084 else {
2085 query.append(_ORDER_BY_ENTITY_TABLE);
2086 }
2087
2088 query.append(orderByFields[i]);
2089
2090 if ((i + 1) < orderByFields.length) {
2091 if (orderByComparator.isAscending() ^ previous) {
2092 query.append(ORDER_BY_ASC_HAS_NEXT);
2093 }
2094 else {
2095 query.append(ORDER_BY_DESC_HAS_NEXT);
2096 }
2097 }
2098 else {
2099 if (orderByComparator.isAscending() ^ previous) {
2100 query.append(ORDER_BY_ASC);
2101 }
2102 else {
2103 query.append(ORDER_BY_DESC);
2104 }
2105 }
2106 }
2107 }
2108 else {
2109 if (getDB().isSupportsInlineDistinct()) {
2110 query.append(AssetVocabularyModelImpl.ORDER_BY_JPQL);
2111 }
2112 else {
2113 query.append(AssetVocabularyModelImpl.ORDER_BY_SQL);
2114 }
2115 }
2116
2117 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2118 AssetVocabulary.class.getName(),
2119 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2120
2121 SQLQuery q = session.createSQLQuery(sql);
2122
2123 q.setFirstResult(0);
2124 q.setMaxResults(2);
2125
2126 if (getDB().isSupportsInlineDistinct()) {
2127 q.addEntity(_FILTER_ENTITY_ALIAS, AssetVocabularyImpl.class);
2128 }
2129 else {
2130 q.addEntity(_FILTER_ENTITY_TABLE, AssetVocabularyImpl.class);
2131 }
2132
2133 QueryPos qPos = QueryPos.getInstance(q);
2134
2135 qPos.add(groupId);
2136
2137 if (orderByComparator != null) {
2138 Object[] values = orderByComparator.getOrderByConditionValues(assetVocabulary);
2139
2140 for (Object value : values) {
2141 qPos.add(value);
2142 }
2143 }
2144
2145 List<AssetVocabulary> list = q.list();
2146
2147 if (list.size() == 2) {
2148 return list.get(1);
2149 }
2150 else {
2151 return null;
2152 }
2153 }
2154
2155
2161 public void removeByGroupId(long groupId) throws SystemException {
2162 for (AssetVocabulary assetVocabulary : findByGroupId(groupId,
2163 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
2164 remove(assetVocabulary);
2165 }
2166 }
2167
2168
2175 public int countByGroupId(long groupId) throws SystemException {
2176 FinderPath finderPath = FINDER_PATH_COUNT_BY_GROUPID;
2177
2178 Object[] finderArgs = new Object[] { groupId };
2179
2180 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
2181 this);
2182
2183 if (count == null) {
2184 StringBundler query = new StringBundler(2);
2185
2186 query.append(_SQL_COUNT_ASSETVOCABULARY_WHERE);
2187
2188 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2189
2190 String sql = query.toString();
2191
2192 Session session = null;
2193
2194 try {
2195 session = openSession();
2196
2197 Query q = session.createQuery(sql);
2198
2199 QueryPos qPos = QueryPos.getInstance(q);
2200
2201 qPos.add(groupId);
2202
2203 count = (Long)q.uniqueResult();
2204
2205 FinderCacheUtil.putResult(finderPath, finderArgs, count);
2206 }
2207 catch (Exception e) {
2208 FinderCacheUtil.removeResult(finderPath, finderArgs);
2209
2210 throw processException(e);
2211 }
2212 finally {
2213 closeSession(session);
2214 }
2215 }
2216
2217 return count.intValue();
2218 }
2219
2220
2227 public int filterCountByGroupId(long groupId) throws SystemException {
2228 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2229 return countByGroupId(groupId);
2230 }
2231
2232 StringBundler query = new StringBundler(2);
2233
2234 query.append(_FILTER_SQL_COUNT_ASSETVOCABULARY_WHERE);
2235
2236 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2237
2238 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2239 AssetVocabulary.class.getName(),
2240 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2241
2242 Session session = null;
2243
2244 try {
2245 session = openSession();
2246
2247 SQLQuery q = session.createSQLQuery(sql);
2248
2249 q.addScalar(COUNT_COLUMN_NAME,
2250 com.liferay.portal.kernel.dao.orm.Type.LONG);
2251
2252 QueryPos qPos = QueryPos.getInstance(q);
2253
2254 qPos.add(groupId);
2255
2256 Long count = (Long)q.uniqueResult();
2257
2258 return count.intValue();
2259 }
2260 catch (Exception e) {
2261 throw processException(e);
2262 }
2263 finally {
2264 closeSession(session);
2265 }
2266 }
2267
2268 private static final String _FINDER_COLUMN_GROUPID_GROUPID_2 = "assetVocabulary.groupId = ?";
2269 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID =
2270 new FinderPath(AssetVocabularyModelImpl.ENTITY_CACHE_ENABLED,
2271 AssetVocabularyModelImpl.FINDER_CACHE_ENABLED,
2272 AssetVocabularyImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
2273 "findByCompanyId",
2274 new String[] {
2275 Long.class.getName(),
2276
2277 Integer.class.getName(), Integer.class.getName(),
2278 OrderByComparator.class.getName()
2279 });
2280 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID =
2281 new FinderPath(AssetVocabularyModelImpl.ENTITY_CACHE_ENABLED,
2282 AssetVocabularyModelImpl.FINDER_CACHE_ENABLED,
2283 AssetVocabularyImpl.class,
2284 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByCompanyId",
2285 new String[] { Long.class.getName() },
2286 AssetVocabularyModelImpl.COMPANYID_COLUMN_BITMASK |
2287 AssetVocabularyModelImpl.NAME_COLUMN_BITMASK);
2288 public static final FinderPath FINDER_PATH_COUNT_BY_COMPANYID = new FinderPath(AssetVocabularyModelImpl.ENTITY_CACHE_ENABLED,
2289 AssetVocabularyModelImpl.FINDER_CACHE_ENABLED, Long.class,
2290 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByCompanyId",
2291 new String[] { Long.class.getName() });
2292
2293
2300 public List<AssetVocabulary> findByCompanyId(long companyId)
2301 throws SystemException {
2302 return findByCompanyId(companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
2303 null);
2304 }
2305
2306
2319 public List<AssetVocabulary> findByCompanyId(long companyId, int start,
2320 int end) throws SystemException {
2321 return findByCompanyId(companyId, start, end, null);
2322 }
2323
2324
2338 public List<AssetVocabulary> findByCompanyId(long companyId, int start,
2339 int end, OrderByComparator orderByComparator) throws SystemException {
2340 boolean pagination = true;
2341 FinderPath finderPath = null;
2342 Object[] finderArgs = null;
2343
2344 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2345 (orderByComparator == null)) {
2346 pagination = false;
2347 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID;
2348 finderArgs = new Object[] { companyId };
2349 }
2350 else {
2351 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID;
2352 finderArgs = new Object[] { companyId, start, end, orderByComparator };
2353 }
2354
2355 List<AssetVocabulary> list = (List<AssetVocabulary>)FinderCacheUtil.getResult(finderPath,
2356 finderArgs, this);
2357
2358 if ((list != null) && !list.isEmpty()) {
2359 for (AssetVocabulary assetVocabulary : list) {
2360 if ((companyId != assetVocabulary.getCompanyId())) {
2361 list = null;
2362
2363 break;
2364 }
2365 }
2366 }
2367
2368 if (list == null) {
2369 StringBundler query = null;
2370
2371 if (orderByComparator != null) {
2372 query = new StringBundler(3 +
2373 (orderByComparator.getOrderByFields().length * 3));
2374 }
2375 else {
2376 query = new StringBundler(3);
2377 }
2378
2379 query.append(_SQL_SELECT_ASSETVOCABULARY_WHERE);
2380
2381 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
2382
2383 if (orderByComparator != null) {
2384 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2385 orderByComparator);
2386 }
2387 else
2388 if (pagination) {
2389 query.append(AssetVocabularyModelImpl.ORDER_BY_JPQL);
2390 }
2391
2392 String sql = query.toString();
2393
2394 Session session = null;
2395
2396 try {
2397 session = openSession();
2398
2399 Query q = session.createQuery(sql);
2400
2401 QueryPos qPos = QueryPos.getInstance(q);
2402
2403 qPos.add(companyId);
2404
2405 if (!pagination) {
2406 list = (List<AssetVocabulary>)QueryUtil.list(q,
2407 getDialect(), start, end, false);
2408
2409 Collections.sort(list);
2410
2411 list = new UnmodifiableList<AssetVocabulary>(list);
2412 }
2413 else {
2414 list = (List<AssetVocabulary>)QueryUtil.list(q,
2415 getDialect(), start, end);
2416 }
2417
2418 cacheResult(list);
2419
2420 FinderCacheUtil.putResult(finderPath, finderArgs, list);
2421 }
2422 catch (Exception e) {
2423 FinderCacheUtil.removeResult(finderPath, finderArgs);
2424
2425 throw processException(e);
2426 }
2427 finally {
2428 closeSession(session);
2429 }
2430 }
2431
2432 return list;
2433 }
2434
2435
2444 public AssetVocabulary findByCompanyId_First(long companyId,
2445 OrderByComparator orderByComparator)
2446 throws NoSuchVocabularyException, SystemException {
2447 AssetVocabulary assetVocabulary = fetchByCompanyId_First(companyId,
2448 orderByComparator);
2449
2450 if (assetVocabulary != null) {
2451 return assetVocabulary;
2452 }
2453
2454 StringBundler msg = new StringBundler(4);
2455
2456 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2457
2458 msg.append("companyId=");
2459 msg.append(companyId);
2460
2461 msg.append(StringPool.CLOSE_CURLY_BRACE);
2462
2463 throw new NoSuchVocabularyException(msg.toString());
2464 }
2465
2466
2474 public AssetVocabulary fetchByCompanyId_First(long companyId,
2475 OrderByComparator orderByComparator) throws SystemException {
2476 List<AssetVocabulary> list = findByCompanyId(companyId, 0, 1,
2477 orderByComparator);
2478
2479 if (!list.isEmpty()) {
2480 return list.get(0);
2481 }
2482
2483 return null;
2484 }
2485
2486
2495 public AssetVocabulary findByCompanyId_Last(long companyId,
2496 OrderByComparator orderByComparator)
2497 throws NoSuchVocabularyException, SystemException {
2498 AssetVocabulary assetVocabulary = fetchByCompanyId_Last(companyId,
2499 orderByComparator);
2500
2501 if (assetVocabulary != null) {
2502 return assetVocabulary;
2503 }
2504
2505 StringBundler msg = new StringBundler(4);
2506
2507 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2508
2509 msg.append("companyId=");
2510 msg.append(companyId);
2511
2512 msg.append(StringPool.CLOSE_CURLY_BRACE);
2513
2514 throw new NoSuchVocabularyException(msg.toString());
2515 }
2516
2517
2525 public AssetVocabulary fetchByCompanyId_Last(long companyId,
2526 OrderByComparator orderByComparator) throws SystemException {
2527 int count = countByCompanyId(companyId);
2528
2529 List<AssetVocabulary> list = findByCompanyId(companyId, count - 1,
2530 count, orderByComparator);
2531
2532 if (!list.isEmpty()) {
2533 return list.get(0);
2534 }
2535
2536 return null;
2537 }
2538
2539
2549 public AssetVocabulary[] findByCompanyId_PrevAndNext(long vocabularyId,
2550 long companyId, OrderByComparator orderByComparator)
2551 throws NoSuchVocabularyException, SystemException {
2552 AssetVocabulary assetVocabulary = findByPrimaryKey(vocabularyId);
2553
2554 Session session = null;
2555
2556 try {
2557 session = openSession();
2558
2559 AssetVocabulary[] array = new AssetVocabularyImpl[3];
2560
2561 array[0] = getByCompanyId_PrevAndNext(session, assetVocabulary,
2562 companyId, orderByComparator, true);
2563
2564 array[1] = assetVocabulary;
2565
2566 array[2] = getByCompanyId_PrevAndNext(session, assetVocabulary,
2567 companyId, orderByComparator, false);
2568
2569 return array;
2570 }
2571 catch (Exception e) {
2572 throw processException(e);
2573 }
2574 finally {
2575 closeSession(session);
2576 }
2577 }
2578
2579 protected AssetVocabulary getByCompanyId_PrevAndNext(Session session,
2580 AssetVocabulary assetVocabulary, long companyId,
2581 OrderByComparator orderByComparator, boolean previous) {
2582 StringBundler query = null;
2583
2584 if (orderByComparator != null) {
2585 query = new StringBundler(6 +
2586 (orderByComparator.getOrderByFields().length * 6));
2587 }
2588 else {
2589 query = new StringBundler(3);
2590 }
2591
2592 query.append(_SQL_SELECT_ASSETVOCABULARY_WHERE);
2593
2594 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
2595
2596 if (orderByComparator != null) {
2597 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2598
2599 if (orderByConditionFields.length > 0) {
2600 query.append(WHERE_AND);
2601 }
2602
2603 for (int i = 0; i < orderByConditionFields.length; i++) {
2604 query.append(_ORDER_BY_ENTITY_ALIAS);
2605 query.append(orderByConditionFields[i]);
2606
2607 if ((i + 1) < orderByConditionFields.length) {
2608 if (orderByComparator.isAscending() ^ previous) {
2609 query.append(WHERE_GREATER_THAN_HAS_NEXT);
2610 }
2611 else {
2612 query.append(WHERE_LESSER_THAN_HAS_NEXT);
2613 }
2614 }
2615 else {
2616 if (orderByComparator.isAscending() ^ previous) {
2617 query.append(WHERE_GREATER_THAN);
2618 }
2619 else {
2620 query.append(WHERE_LESSER_THAN);
2621 }
2622 }
2623 }
2624
2625 query.append(ORDER_BY_CLAUSE);
2626
2627 String[] orderByFields = orderByComparator.getOrderByFields();
2628
2629 for (int i = 0; i < orderByFields.length; i++) {
2630 query.append(_ORDER_BY_ENTITY_ALIAS);
2631 query.append(orderByFields[i]);
2632
2633 if ((i + 1) < orderByFields.length) {
2634 if (orderByComparator.isAscending() ^ previous) {
2635 query.append(ORDER_BY_ASC_HAS_NEXT);
2636 }
2637 else {
2638 query.append(ORDER_BY_DESC_HAS_NEXT);
2639 }
2640 }
2641 else {
2642 if (orderByComparator.isAscending() ^ previous) {
2643 query.append(ORDER_BY_ASC);
2644 }
2645 else {
2646 query.append(ORDER_BY_DESC);
2647 }
2648 }
2649 }
2650 }
2651 else {
2652 query.append(AssetVocabularyModelImpl.ORDER_BY_JPQL);
2653 }
2654
2655 String sql = query.toString();
2656
2657 Query q = session.createQuery(sql);
2658
2659 q.setFirstResult(0);
2660 q.setMaxResults(2);
2661
2662 QueryPos qPos = QueryPos.getInstance(q);
2663
2664 qPos.add(companyId);
2665
2666 if (orderByComparator != null) {
2667 Object[] values = orderByComparator.getOrderByConditionValues(assetVocabulary);
2668
2669 for (Object value : values) {
2670 qPos.add(value);
2671 }
2672 }
2673
2674 List<AssetVocabulary> list = q.list();
2675
2676 if (list.size() == 2) {
2677 return list.get(1);
2678 }
2679 else {
2680 return null;
2681 }
2682 }
2683
2684
2690 public void removeByCompanyId(long companyId) throws SystemException {
2691 for (AssetVocabulary assetVocabulary : findByCompanyId(companyId,
2692 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
2693 remove(assetVocabulary);
2694 }
2695 }
2696
2697
2704 public int countByCompanyId(long companyId) throws SystemException {
2705 FinderPath finderPath = FINDER_PATH_COUNT_BY_COMPANYID;
2706
2707 Object[] finderArgs = new Object[] { companyId };
2708
2709 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
2710 this);
2711
2712 if (count == null) {
2713 StringBundler query = new StringBundler(2);
2714
2715 query.append(_SQL_COUNT_ASSETVOCABULARY_WHERE);
2716
2717 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
2718
2719 String sql = query.toString();
2720
2721 Session session = null;
2722
2723 try {
2724 session = openSession();
2725
2726 Query q = session.createQuery(sql);
2727
2728 QueryPos qPos = QueryPos.getInstance(q);
2729
2730 qPos.add(companyId);
2731
2732 count = (Long)q.uniqueResult();
2733
2734 FinderCacheUtil.putResult(finderPath, finderArgs, count);
2735 }
2736 catch (Exception e) {
2737 FinderCacheUtil.removeResult(finderPath, finderArgs);
2738
2739 throw processException(e);
2740 }
2741 finally {
2742 closeSession(session);
2743 }
2744 }
2745
2746 return count.intValue();
2747 }
2748
2749 private static final String _FINDER_COLUMN_COMPANYID_COMPANYID_2 = "assetVocabulary.companyId = ?";
2750 public static final FinderPath FINDER_PATH_FETCH_BY_G_N = new FinderPath(AssetVocabularyModelImpl.ENTITY_CACHE_ENABLED,
2751 AssetVocabularyModelImpl.FINDER_CACHE_ENABLED,
2752 AssetVocabularyImpl.class, FINDER_CLASS_NAME_ENTITY, "fetchByG_N",
2753 new String[] { Long.class.getName(), String.class.getName() },
2754 AssetVocabularyModelImpl.GROUPID_COLUMN_BITMASK |
2755 AssetVocabularyModelImpl.NAME_COLUMN_BITMASK);
2756 public static final FinderPath FINDER_PATH_COUNT_BY_G_N = new FinderPath(AssetVocabularyModelImpl.ENTITY_CACHE_ENABLED,
2757 AssetVocabularyModelImpl.FINDER_CACHE_ENABLED, Long.class,
2758 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_N",
2759 new String[] { Long.class.getName(), String.class.getName() });
2760
2761
2770 public AssetVocabulary findByG_N(long groupId, String name)
2771 throws NoSuchVocabularyException, SystemException {
2772 AssetVocabulary assetVocabulary = fetchByG_N(groupId, name);
2773
2774 if (assetVocabulary == null) {
2775 StringBundler msg = new StringBundler(6);
2776
2777 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2778
2779 msg.append("groupId=");
2780 msg.append(groupId);
2781
2782 msg.append(", name=");
2783 msg.append(name);
2784
2785 msg.append(StringPool.CLOSE_CURLY_BRACE);
2786
2787 if (_log.isWarnEnabled()) {
2788 _log.warn(msg.toString());
2789 }
2790
2791 throw new NoSuchVocabularyException(msg.toString());
2792 }
2793
2794 return assetVocabulary;
2795 }
2796
2797
2805 public AssetVocabulary fetchByG_N(long groupId, String name)
2806 throws SystemException {
2807 return fetchByG_N(groupId, name, true);
2808 }
2809
2810
2819 public AssetVocabulary fetchByG_N(long groupId, String name,
2820 boolean retrieveFromCache) throws SystemException {
2821 Object[] finderArgs = new Object[] { groupId, name };
2822
2823 Object result = null;
2824
2825 if (retrieveFromCache) {
2826 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_G_N,
2827 finderArgs, this);
2828 }
2829
2830 if (result instanceof AssetVocabulary) {
2831 AssetVocabulary assetVocabulary = (AssetVocabulary)result;
2832
2833 if ((groupId != assetVocabulary.getGroupId()) ||
2834 !Validator.equals(name, assetVocabulary.getName())) {
2835 result = null;
2836 }
2837 }
2838
2839 if (result == null) {
2840 StringBundler query = new StringBundler(4);
2841
2842 query.append(_SQL_SELECT_ASSETVOCABULARY_WHERE);
2843
2844 query.append(_FINDER_COLUMN_G_N_GROUPID_2);
2845
2846 boolean bindName = false;
2847
2848 if (name == null) {
2849 query.append(_FINDER_COLUMN_G_N_NAME_1);
2850 }
2851 else if (name.equals(StringPool.BLANK)) {
2852 query.append(_FINDER_COLUMN_G_N_NAME_3);
2853 }
2854 else {
2855 bindName = true;
2856
2857 query.append(_FINDER_COLUMN_G_N_NAME_2);
2858 }
2859
2860 String sql = query.toString();
2861
2862 Session session = null;
2863
2864 try {
2865 session = openSession();
2866
2867 Query q = session.createQuery(sql);
2868
2869 QueryPos qPos = QueryPos.getInstance(q);
2870
2871 qPos.add(groupId);
2872
2873 if (bindName) {
2874 qPos.add(name);
2875 }
2876
2877 List<AssetVocabulary> list = q.list();
2878
2879 if (list.isEmpty()) {
2880 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_N,
2881 finderArgs, list);
2882 }
2883 else {
2884 AssetVocabulary assetVocabulary = list.get(0);
2885
2886 result = assetVocabulary;
2887
2888 cacheResult(assetVocabulary);
2889
2890 if ((assetVocabulary.getGroupId() != groupId) ||
2891 (assetVocabulary.getName() == null) ||
2892 !assetVocabulary.getName().equals(name)) {
2893 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_N,
2894 finderArgs, assetVocabulary);
2895 }
2896 }
2897 }
2898 catch (Exception e) {
2899 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_N,
2900 finderArgs);
2901
2902 throw processException(e);
2903 }
2904 finally {
2905 closeSession(session);
2906 }
2907 }
2908
2909 if (result instanceof List<?>) {
2910 return null;
2911 }
2912 else {
2913 return (AssetVocabulary)result;
2914 }
2915 }
2916
2917
2925 public AssetVocabulary removeByG_N(long groupId, String name)
2926 throws NoSuchVocabularyException, SystemException {
2927 AssetVocabulary assetVocabulary = findByG_N(groupId, name);
2928
2929 return remove(assetVocabulary);
2930 }
2931
2932
2940 public int countByG_N(long groupId, String name) throws SystemException {
2941 FinderPath finderPath = FINDER_PATH_COUNT_BY_G_N;
2942
2943 Object[] finderArgs = new Object[] { groupId, name };
2944
2945 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
2946 this);
2947
2948 if (count == null) {
2949 StringBundler query = new StringBundler(3);
2950
2951 query.append(_SQL_COUNT_ASSETVOCABULARY_WHERE);
2952
2953 query.append(_FINDER_COLUMN_G_N_GROUPID_2);
2954
2955 boolean bindName = false;
2956
2957 if (name == null) {
2958 query.append(_FINDER_COLUMN_G_N_NAME_1);
2959 }
2960 else if (name.equals(StringPool.BLANK)) {
2961 query.append(_FINDER_COLUMN_G_N_NAME_3);
2962 }
2963 else {
2964 bindName = true;
2965
2966 query.append(_FINDER_COLUMN_G_N_NAME_2);
2967 }
2968
2969 String sql = query.toString();
2970
2971 Session session = null;
2972
2973 try {
2974 session = openSession();
2975
2976 Query q = session.createQuery(sql);
2977
2978 QueryPos qPos = QueryPos.getInstance(q);
2979
2980 qPos.add(groupId);
2981
2982 if (bindName) {
2983 qPos.add(name);
2984 }
2985
2986 count = (Long)q.uniqueResult();
2987
2988 FinderCacheUtil.putResult(finderPath, finderArgs, count);
2989 }
2990 catch (Exception e) {
2991 FinderCacheUtil.removeResult(finderPath, finderArgs);
2992
2993 throw processException(e);
2994 }
2995 finally {
2996 closeSession(session);
2997 }
2998 }
2999
3000 return count.intValue();
3001 }
3002
3003 private static final String _FINDER_COLUMN_G_N_GROUPID_2 = "assetVocabulary.groupId = ? AND ";
3004 private static final String _FINDER_COLUMN_G_N_NAME_1 = "assetVocabulary.name IS NULL";
3005 private static final String _FINDER_COLUMN_G_N_NAME_2 = "assetVocabulary.name = ?";
3006 private static final String _FINDER_COLUMN_G_N_NAME_3 = "(assetVocabulary.name IS NULL OR assetVocabulary.name = '')";
3007
3008
3013 public void cacheResult(AssetVocabulary assetVocabulary) {
3014 EntityCacheUtil.putResult(AssetVocabularyModelImpl.ENTITY_CACHE_ENABLED,
3015 AssetVocabularyImpl.class, assetVocabulary.getPrimaryKey(),
3016 assetVocabulary);
3017
3018 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
3019 new Object[] { assetVocabulary.getUuid(), assetVocabulary.getGroupId() },
3020 assetVocabulary);
3021
3022 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_N,
3023 new Object[] { assetVocabulary.getGroupId(), assetVocabulary.getName() },
3024 assetVocabulary);
3025
3026 assetVocabulary.resetOriginalValues();
3027 }
3028
3029
3034 public void cacheResult(List<AssetVocabulary> assetVocabularies) {
3035 for (AssetVocabulary assetVocabulary : assetVocabularies) {
3036 if (EntityCacheUtil.getResult(
3037 AssetVocabularyModelImpl.ENTITY_CACHE_ENABLED,
3038 AssetVocabularyImpl.class,
3039 assetVocabulary.getPrimaryKey()) == null) {
3040 cacheResult(assetVocabulary);
3041 }
3042 else {
3043 assetVocabulary.resetOriginalValues();
3044 }
3045 }
3046 }
3047
3048
3055 @Override
3056 public void clearCache() {
3057 if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
3058 CacheRegistryUtil.clear(AssetVocabularyImpl.class.getName());
3059 }
3060
3061 EntityCacheUtil.clearCache(AssetVocabularyImpl.class.getName());
3062
3063 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
3064 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
3065 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
3066 }
3067
3068
3075 @Override
3076 public void clearCache(AssetVocabulary assetVocabulary) {
3077 EntityCacheUtil.removeResult(AssetVocabularyModelImpl.ENTITY_CACHE_ENABLED,
3078 AssetVocabularyImpl.class, assetVocabulary.getPrimaryKey());
3079
3080 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
3081 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
3082
3083 clearUniqueFindersCache(assetVocabulary);
3084 }
3085
3086 @Override
3087 public void clearCache(List<AssetVocabulary> assetVocabularies) {
3088 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
3089 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
3090
3091 for (AssetVocabulary assetVocabulary : assetVocabularies) {
3092 EntityCacheUtil.removeResult(AssetVocabularyModelImpl.ENTITY_CACHE_ENABLED,
3093 AssetVocabularyImpl.class, assetVocabulary.getPrimaryKey());
3094
3095 clearUniqueFindersCache(assetVocabulary);
3096 }
3097 }
3098
3099 protected void cacheUniqueFindersCache(AssetVocabulary assetVocabulary) {
3100 if (assetVocabulary.isNew()) {
3101 Object[] args = new Object[] {
3102 assetVocabulary.getUuid(), assetVocabulary.getGroupId()
3103 };
3104
3105 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G, args,
3106 Long.valueOf(1));
3107 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G, args,
3108 assetVocabulary);
3109
3110 args = new Object[] {
3111 assetVocabulary.getGroupId(), assetVocabulary.getName()
3112 };
3113
3114 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_N, args,
3115 Long.valueOf(1));
3116 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_N, args,
3117 assetVocabulary);
3118 }
3119 else {
3120 AssetVocabularyModelImpl assetVocabularyModelImpl = (AssetVocabularyModelImpl)assetVocabulary;
3121
3122 if ((assetVocabularyModelImpl.getColumnBitmask() &
3123 FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) {
3124 Object[] args = new Object[] {
3125 assetVocabulary.getUuid(), assetVocabulary.getGroupId()
3126 };
3127
3128 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G, args,
3129 Long.valueOf(1));
3130 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G, args,
3131 assetVocabulary);
3132 }
3133
3134 if ((assetVocabularyModelImpl.getColumnBitmask() &
3135 FINDER_PATH_FETCH_BY_G_N.getColumnBitmask()) != 0) {
3136 Object[] args = new Object[] {
3137 assetVocabulary.getGroupId(), assetVocabulary.getName()
3138 };
3139
3140 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_N, args,
3141 Long.valueOf(1));
3142 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_N, args,
3143 assetVocabulary);
3144 }
3145 }
3146 }
3147
3148 protected void clearUniqueFindersCache(AssetVocabulary assetVocabulary) {
3149 AssetVocabularyModelImpl assetVocabularyModelImpl = (AssetVocabularyModelImpl)assetVocabulary;
3150
3151 Object[] args = new Object[] {
3152 assetVocabulary.getUuid(), assetVocabulary.getGroupId()
3153 };
3154
3155 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args);
3156 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args);
3157
3158 if ((assetVocabularyModelImpl.getColumnBitmask() &
3159 FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) {
3160 args = new Object[] {
3161 assetVocabularyModelImpl.getOriginalUuid(),
3162 assetVocabularyModelImpl.getOriginalGroupId()
3163 };
3164
3165 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args);
3166 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args);
3167 }
3168
3169 args = new Object[] {
3170 assetVocabulary.getGroupId(), assetVocabulary.getName()
3171 };
3172
3173 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_N, args);
3174 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_N, args);
3175
3176 if ((assetVocabularyModelImpl.getColumnBitmask() &
3177 FINDER_PATH_FETCH_BY_G_N.getColumnBitmask()) != 0) {
3178 args = new Object[] {
3179 assetVocabularyModelImpl.getOriginalGroupId(),
3180 assetVocabularyModelImpl.getOriginalName()
3181 };
3182
3183 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_N, args);
3184 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_N, args);
3185 }
3186 }
3187
3188
3194 public AssetVocabulary create(long vocabularyId) {
3195 AssetVocabulary assetVocabulary = new AssetVocabularyImpl();
3196
3197 assetVocabulary.setNew(true);
3198 assetVocabulary.setPrimaryKey(vocabularyId);
3199
3200 String uuid = PortalUUIDUtil.generate();
3201
3202 assetVocabulary.setUuid(uuid);
3203
3204 return assetVocabulary;
3205 }
3206
3207
3215 public AssetVocabulary remove(long vocabularyId)
3216 throws NoSuchVocabularyException, SystemException {
3217 return remove((Serializable)vocabularyId);
3218 }
3219
3220
3228 @Override
3229 public AssetVocabulary remove(Serializable primaryKey)
3230 throws NoSuchVocabularyException, SystemException {
3231 Session session = null;
3232
3233 try {
3234 session = openSession();
3235
3236 AssetVocabulary assetVocabulary = (AssetVocabulary)session.get(AssetVocabularyImpl.class,
3237 primaryKey);
3238
3239 if (assetVocabulary == null) {
3240 if (_log.isWarnEnabled()) {
3241 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
3242 }
3243
3244 throw new NoSuchVocabularyException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
3245 primaryKey);
3246 }
3247
3248 return remove(assetVocabulary);
3249 }
3250 catch (NoSuchVocabularyException nsee) {
3251 throw nsee;
3252 }
3253 catch (Exception e) {
3254 throw processException(e);
3255 }
3256 finally {
3257 closeSession(session);
3258 }
3259 }
3260
3261 @Override
3262 protected AssetVocabulary removeImpl(AssetVocabulary assetVocabulary)
3263 throws SystemException {
3264 assetVocabulary = toUnwrappedModel(assetVocabulary);
3265
3266 Session session = null;
3267
3268 try {
3269 session = openSession();
3270
3271 if (!session.contains(assetVocabulary)) {
3272 assetVocabulary = (AssetVocabulary)session.get(AssetVocabularyImpl.class,
3273 assetVocabulary.getPrimaryKeyObj());
3274 }
3275
3276 if (assetVocabulary != null) {
3277 session.delete(assetVocabulary);
3278 }
3279 }
3280 catch (Exception e) {
3281 throw processException(e);
3282 }
3283 finally {
3284 closeSession(session);
3285 }
3286
3287 if (assetVocabulary != null) {
3288 clearCache(assetVocabulary);
3289 }
3290
3291 return assetVocabulary;
3292 }
3293
3294 @Override
3295 public AssetVocabulary updateImpl(
3296 com.liferay.portlet.asset.model.AssetVocabulary assetVocabulary)
3297 throws SystemException {
3298 assetVocabulary = toUnwrappedModel(assetVocabulary);
3299
3300 boolean isNew = assetVocabulary.isNew();
3301
3302 AssetVocabularyModelImpl assetVocabularyModelImpl = (AssetVocabularyModelImpl)assetVocabulary;
3303
3304 if (Validator.isNull(assetVocabulary.getUuid())) {
3305 String uuid = PortalUUIDUtil.generate();
3306
3307 assetVocabulary.setUuid(uuid);
3308 }
3309
3310 Session session = null;
3311
3312 try {
3313 session = openSession();
3314
3315 if (assetVocabulary.isNew()) {
3316 session.save(assetVocabulary);
3317
3318 assetVocabulary.setNew(false);
3319 }
3320 else {
3321 session.merge(assetVocabulary);
3322 }
3323 }
3324 catch (Exception e) {
3325 throw processException(e);
3326 }
3327 finally {
3328 closeSession(session);
3329 }
3330
3331 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
3332
3333 if (isNew || !AssetVocabularyModelImpl.COLUMN_BITMASK_ENABLED) {
3334 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
3335 }
3336
3337 else {
3338 if ((assetVocabularyModelImpl.getColumnBitmask() &
3339 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID.getColumnBitmask()) != 0) {
3340 Object[] args = new Object[] {
3341 assetVocabularyModelImpl.getOriginalUuid()
3342 };
3343
3344 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
3345 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
3346 args);
3347
3348 args = new Object[] { assetVocabularyModelImpl.getUuid() };
3349
3350 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
3351 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
3352 args);
3353 }
3354
3355 if ((assetVocabularyModelImpl.getColumnBitmask() &
3356 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C.getColumnBitmask()) != 0) {
3357 Object[] args = new Object[] {
3358 assetVocabularyModelImpl.getOriginalUuid(),
3359 assetVocabularyModelImpl.getOriginalCompanyId()
3360 };
3361
3362 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args);
3363 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C,
3364 args);
3365
3366 args = new Object[] {
3367 assetVocabularyModelImpl.getUuid(),
3368 assetVocabularyModelImpl.getCompanyId()
3369 };
3370
3371 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args);
3372 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C,
3373 args);
3374 }
3375
3376 if ((assetVocabularyModelImpl.getColumnBitmask() &
3377 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID.getColumnBitmask()) != 0) {
3378 Object[] args = new Object[] {
3379 assetVocabularyModelImpl.getOriginalGroupId()
3380 };
3381
3382 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
3383 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
3384 args);
3385
3386 args = new Object[] { assetVocabularyModelImpl.getGroupId() };
3387
3388 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
3389 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
3390 args);
3391 }
3392
3393 if ((assetVocabularyModelImpl.getColumnBitmask() &
3394 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID.getColumnBitmask()) != 0) {
3395 Object[] args = new Object[] {
3396 assetVocabularyModelImpl.getOriginalCompanyId()
3397 };
3398
3399 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_COMPANYID,
3400 args);
3401 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
3402 args);
3403
3404 args = new Object[] { assetVocabularyModelImpl.getCompanyId() };
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 NoSuchVocabularyException, SystemException {
3460 AssetVocabulary assetVocabulary = fetchByPrimaryKey(primaryKey);
3461
3462 if (assetVocabulary == null) {
3463 if (_log.isWarnEnabled()) {
3464 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
3465 }
3466
3467 throw new NoSuchVocabularyException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
3468 primaryKey);
3469 }
3470
3471 return assetVocabulary;
3472 }
3473
3474
3482 public AssetVocabulary findByPrimaryKey(long vocabularyId)
3483 throws NoSuchVocabularyException, SystemException {
3484 return findByPrimaryKey((Serializable)vocabularyId);
3485 }
3486
3487
3494 @Override
3495 public AssetVocabulary fetchByPrimaryKey(Serializable primaryKey)
3496 throws SystemException {
3497 AssetVocabulary assetVocabulary = (AssetVocabulary)EntityCacheUtil.getResult(AssetVocabularyModelImpl.ENTITY_CACHE_ENABLED,
3498 AssetVocabularyImpl.class, primaryKey);
3499
3500 if (assetVocabulary == _nullAssetVocabulary) {
3501 return null;
3502 }
3503
3504 if (assetVocabulary == null) {
3505 Session session = null;
3506
3507 try {
3508 session = openSession();
3509
3510 assetVocabulary = (AssetVocabulary)session.get(AssetVocabularyImpl.class,
3511 primaryKey);
3512
3513 if (assetVocabulary != null) {
3514 cacheResult(assetVocabulary);
3515 }
3516 else {
3517 EntityCacheUtil.putResult(AssetVocabularyModelImpl.ENTITY_CACHE_ENABLED,
3518 AssetVocabularyImpl.class, primaryKey,
3519 _nullAssetVocabulary);
3520 }
3521 }
3522 catch (Exception e) {
3523 EntityCacheUtil.removeResult(AssetVocabularyModelImpl.ENTITY_CACHE_ENABLED,
3524 AssetVocabularyImpl.class, primaryKey);
3525
3526 throw processException(e);
3527 }
3528 finally {
3529 closeSession(session);
3530 }
3531 }
3532
3533 return assetVocabulary;
3534 }
3535
3536
3543 public AssetVocabulary fetchByPrimaryKey(long vocabularyId)
3544 throws SystemException {
3545 return fetchByPrimaryKey((Serializable)vocabularyId);
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 }