001
014
015 package com.liferay.portlet.asset.service.persistence;
016
017 import com.liferay.portal.kernel.bean.BeanReference;
018 import com.liferay.portal.kernel.cache.CacheRegistryUtil;
019 import com.liferay.portal.kernel.dao.jdbc.SqlUpdate;
020 import com.liferay.portal.kernel.dao.jdbc.SqlUpdateFactoryUtil;
021 import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
022 import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
023 import com.liferay.portal.kernel.dao.orm.FinderPath;
024 import com.liferay.portal.kernel.dao.orm.Query;
025 import com.liferay.portal.kernel.dao.orm.QueryPos;
026 import com.liferay.portal.kernel.dao.orm.QueryUtil;
027 import com.liferay.portal.kernel.dao.orm.SQLQuery;
028 import com.liferay.portal.kernel.dao.orm.Session;
029 import com.liferay.portal.kernel.exception.SystemException;
030 import com.liferay.portal.kernel.log.Log;
031 import com.liferay.portal.kernel.log.LogFactoryUtil;
032 import com.liferay.portal.kernel.util.ArrayUtil;
033 import com.liferay.portal.kernel.util.GetterUtil;
034 import com.liferay.portal.kernel.util.InstanceFactory;
035 import com.liferay.portal.kernel.util.OrderByComparator;
036 import com.liferay.portal.kernel.util.SetUtil;
037 import com.liferay.portal.kernel.util.StringBundler;
038 import com.liferay.portal.kernel.util.StringPool;
039 import com.liferay.portal.kernel.util.StringUtil;
040 import com.liferay.portal.kernel.util.UnmodifiableList;
041 import com.liferay.portal.kernel.util.Validator;
042 import com.liferay.portal.kernel.uuid.PortalUUIDUtil;
043 import com.liferay.portal.model.CacheModel;
044 import com.liferay.portal.model.ModelListener;
045 import com.liferay.portal.security.permission.InlineSQLHelperUtil;
046 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
047 import com.liferay.portal.service.persistence.impl.TableMapper;
048 import com.liferay.portal.service.persistence.impl.TableMapperFactory;
049
050 import com.liferay.portlet.asset.NoSuchCategoryException;
051 import com.liferay.portlet.asset.model.AssetCategory;
052 import com.liferay.portlet.asset.model.impl.AssetCategoryImpl;
053 import com.liferay.portlet.asset.model.impl.AssetCategoryModelImpl;
054
055 import java.io.Serializable;
056
057 import java.util.ArrayList;
058 import java.util.Collections;
059 import java.util.List;
060 import java.util.Set;
061
062
074 public class AssetCategoryPersistenceImpl extends BasePersistenceImpl<AssetCategory>
075 implements AssetCategoryPersistence {
076
081 public static final String FINDER_CLASS_NAME_ENTITY = AssetCategoryImpl.class.getName();
082 public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
083 ".List1";
084 public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
085 ".List2";
086 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
087 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
088 AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
089 "findAll", new String[0]);
090 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
091 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
092 AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
093 "findAll", new String[0]);
094 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
095 AssetCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class,
096 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
097 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
098 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
099 AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
100 "findByUuid",
101 new String[] {
102 String.class.getName(),
103
104 Integer.class.getName(), Integer.class.getName(),
105 OrderByComparator.class.getName()
106 });
107 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
108 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
109 AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
110 "findByUuid", new String[] { String.class.getName() },
111 AssetCategoryModelImpl.UUID_COLUMN_BITMASK |
112 AssetCategoryModelImpl.NAME_COLUMN_BITMASK);
113 public static final FinderPath FINDER_PATH_COUNT_BY_UUID = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
114 AssetCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class,
115 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid",
116 new String[] { String.class.getName() });
117
118
125 @Override
126 public List<AssetCategory> findByUuid(String uuid)
127 throws SystemException {
128 return findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
129 }
130
131
144 @Override
145 public List<AssetCategory> findByUuid(String uuid, int start, int end)
146 throws SystemException {
147 return findByUuid(uuid, start, end, null);
148 }
149
150
164 @Override
165 public List<AssetCategory> findByUuid(String uuid, int start, int end,
166 OrderByComparator orderByComparator) throws SystemException {
167 boolean pagination = true;
168 FinderPath finderPath = null;
169 Object[] finderArgs = null;
170
171 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
172 (orderByComparator == null)) {
173 pagination = false;
174 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID;
175 finderArgs = new Object[] { uuid };
176 }
177 else {
178 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID;
179 finderArgs = new Object[] { uuid, start, end, orderByComparator };
180 }
181
182 List<AssetCategory> list = (List<AssetCategory>)FinderCacheUtil.getResult(finderPath,
183 finderArgs, this);
184
185 if ((list != null) && !list.isEmpty()) {
186 for (AssetCategory assetCategory : list) {
187 if (!Validator.equals(uuid, assetCategory.getUuid())) {
188 list = null;
189
190 break;
191 }
192 }
193 }
194
195 if (list == null) {
196 StringBundler query = null;
197
198 if (orderByComparator != null) {
199 query = new StringBundler(3 +
200 (orderByComparator.getOrderByFields().length * 3));
201 }
202 else {
203 query = new StringBundler(3);
204 }
205
206 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
207
208 boolean bindUuid = false;
209
210 if (uuid == null) {
211 query.append(_FINDER_COLUMN_UUID_UUID_1);
212 }
213 else if (uuid.equals(StringPool.BLANK)) {
214 query.append(_FINDER_COLUMN_UUID_UUID_3);
215 }
216 else {
217 bindUuid = true;
218
219 query.append(_FINDER_COLUMN_UUID_UUID_2);
220 }
221
222 if (orderByComparator != null) {
223 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
224 orderByComparator);
225 }
226 else
227 if (pagination) {
228 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
229 }
230
231 String sql = query.toString();
232
233 Session session = null;
234
235 try {
236 session = openSession();
237
238 Query q = session.createQuery(sql);
239
240 QueryPos qPos = QueryPos.getInstance(q);
241
242 if (bindUuid) {
243 qPos.add(uuid);
244 }
245
246 if (!pagination) {
247 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
248 start, end, false);
249
250 Collections.sort(list);
251
252 list = new UnmodifiableList<AssetCategory>(list);
253 }
254 else {
255 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
256 start, end);
257 }
258
259 cacheResult(list);
260
261 FinderCacheUtil.putResult(finderPath, finderArgs, list);
262 }
263 catch (Exception e) {
264 FinderCacheUtil.removeResult(finderPath, finderArgs);
265
266 throw processException(e);
267 }
268 finally {
269 closeSession(session);
270 }
271 }
272
273 return list;
274 }
275
276
285 @Override
286 public AssetCategory findByUuid_First(String uuid,
287 OrderByComparator orderByComparator)
288 throws NoSuchCategoryException, SystemException {
289 AssetCategory assetCategory = fetchByUuid_First(uuid, orderByComparator);
290
291 if (assetCategory != null) {
292 return assetCategory;
293 }
294
295 StringBundler msg = new StringBundler(4);
296
297 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
298
299 msg.append("uuid=");
300 msg.append(uuid);
301
302 msg.append(StringPool.CLOSE_CURLY_BRACE);
303
304 throw new NoSuchCategoryException(msg.toString());
305 }
306
307
315 @Override
316 public AssetCategory fetchByUuid_First(String uuid,
317 OrderByComparator orderByComparator) throws SystemException {
318 List<AssetCategory> list = findByUuid(uuid, 0, 1, orderByComparator);
319
320 if (!list.isEmpty()) {
321 return list.get(0);
322 }
323
324 return null;
325 }
326
327
336 @Override
337 public AssetCategory findByUuid_Last(String uuid,
338 OrderByComparator orderByComparator)
339 throws NoSuchCategoryException, SystemException {
340 AssetCategory assetCategory = fetchByUuid_Last(uuid, orderByComparator);
341
342 if (assetCategory != null) {
343 return assetCategory;
344 }
345
346 StringBundler msg = new StringBundler(4);
347
348 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
349
350 msg.append("uuid=");
351 msg.append(uuid);
352
353 msg.append(StringPool.CLOSE_CURLY_BRACE);
354
355 throw new NoSuchCategoryException(msg.toString());
356 }
357
358
366 @Override
367 public AssetCategory fetchByUuid_Last(String uuid,
368 OrderByComparator orderByComparator) throws SystemException {
369 int count = countByUuid(uuid);
370
371 if (count == 0) {
372 return null;
373 }
374
375 List<AssetCategory> list = findByUuid(uuid, count - 1, count,
376 orderByComparator);
377
378 if (!list.isEmpty()) {
379 return list.get(0);
380 }
381
382 return null;
383 }
384
385
395 @Override
396 public AssetCategory[] findByUuid_PrevAndNext(long categoryId, String uuid,
397 OrderByComparator orderByComparator)
398 throws NoSuchCategoryException, SystemException {
399 AssetCategory assetCategory = findByPrimaryKey(categoryId);
400
401 Session session = null;
402
403 try {
404 session = openSession();
405
406 AssetCategory[] array = new AssetCategoryImpl[3];
407
408 array[0] = getByUuid_PrevAndNext(session, assetCategory, uuid,
409 orderByComparator, true);
410
411 array[1] = assetCategory;
412
413 array[2] = getByUuid_PrevAndNext(session, assetCategory, uuid,
414 orderByComparator, false);
415
416 return array;
417 }
418 catch (Exception e) {
419 throw processException(e);
420 }
421 finally {
422 closeSession(session);
423 }
424 }
425
426 protected AssetCategory getByUuid_PrevAndNext(Session session,
427 AssetCategory assetCategory, String uuid,
428 OrderByComparator orderByComparator, boolean previous) {
429 StringBundler query = null;
430
431 if (orderByComparator != null) {
432 query = new StringBundler(6 +
433 (orderByComparator.getOrderByFields().length * 6));
434 }
435 else {
436 query = new StringBundler(3);
437 }
438
439 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
440
441 boolean bindUuid = false;
442
443 if (uuid == null) {
444 query.append(_FINDER_COLUMN_UUID_UUID_1);
445 }
446 else if (uuid.equals(StringPool.BLANK)) {
447 query.append(_FINDER_COLUMN_UUID_UUID_3);
448 }
449 else {
450 bindUuid = true;
451
452 query.append(_FINDER_COLUMN_UUID_UUID_2);
453 }
454
455 if (orderByComparator != null) {
456 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
457
458 if (orderByConditionFields.length > 0) {
459 query.append(WHERE_AND);
460 }
461
462 for (int i = 0; i < orderByConditionFields.length; i++) {
463 query.append(_ORDER_BY_ENTITY_ALIAS);
464 query.append(orderByConditionFields[i]);
465
466 if ((i + 1) < orderByConditionFields.length) {
467 if (orderByComparator.isAscending() ^ previous) {
468 query.append(WHERE_GREATER_THAN_HAS_NEXT);
469 }
470 else {
471 query.append(WHERE_LESSER_THAN_HAS_NEXT);
472 }
473 }
474 else {
475 if (orderByComparator.isAscending() ^ previous) {
476 query.append(WHERE_GREATER_THAN);
477 }
478 else {
479 query.append(WHERE_LESSER_THAN);
480 }
481 }
482 }
483
484 query.append(ORDER_BY_CLAUSE);
485
486 String[] orderByFields = orderByComparator.getOrderByFields();
487
488 for (int i = 0; i < orderByFields.length; i++) {
489 query.append(_ORDER_BY_ENTITY_ALIAS);
490 query.append(orderByFields[i]);
491
492 if ((i + 1) < orderByFields.length) {
493 if (orderByComparator.isAscending() ^ previous) {
494 query.append(ORDER_BY_ASC_HAS_NEXT);
495 }
496 else {
497 query.append(ORDER_BY_DESC_HAS_NEXT);
498 }
499 }
500 else {
501 if (orderByComparator.isAscending() ^ previous) {
502 query.append(ORDER_BY_ASC);
503 }
504 else {
505 query.append(ORDER_BY_DESC);
506 }
507 }
508 }
509 }
510 else {
511 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
512 }
513
514 String sql = query.toString();
515
516 Query q = session.createQuery(sql);
517
518 q.setFirstResult(0);
519 q.setMaxResults(2);
520
521 QueryPos qPos = QueryPos.getInstance(q);
522
523 if (bindUuid) {
524 qPos.add(uuid);
525 }
526
527 if (orderByComparator != null) {
528 Object[] values = orderByComparator.getOrderByConditionValues(assetCategory);
529
530 for (Object value : values) {
531 qPos.add(value);
532 }
533 }
534
535 List<AssetCategory> list = q.list();
536
537 if (list.size() == 2) {
538 return list.get(1);
539 }
540 else {
541 return null;
542 }
543 }
544
545
551 @Override
552 public void removeByUuid(String uuid) throws SystemException {
553 for (AssetCategory assetCategory : findByUuid(uuid, QueryUtil.ALL_POS,
554 QueryUtil.ALL_POS, null)) {
555 remove(assetCategory);
556 }
557 }
558
559
566 @Override
567 public int countByUuid(String uuid) throws SystemException {
568 FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID;
569
570 Object[] finderArgs = new Object[] { uuid };
571
572 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
573 this);
574
575 if (count == null) {
576 StringBundler query = new StringBundler(2);
577
578 query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
579
580 boolean bindUuid = false;
581
582 if (uuid == null) {
583 query.append(_FINDER_COLUMN_UUID_UUID_1);
584 }
585 else if (uuid.equals(StringPool.BLANK)) {
586 query.append(_FINDER_COLUMN_UUID_UUID_3);
587 }
588 else {
589 bindUuid = true;
590
591 query.append(_FINDER_COLUMN_UUID_UUID_2);
592 }
593
594 String sql = query.toString();
595
596 Session session = null;
597
598 try {
599 session = openSession();
600
601 Query q = session.createQuery(sql);
602
603 QueryPos qPos = QueryPos.getInstance(q);
604
605 if (bindUuid) {
606 qPos.add(uuid);
607 }
608
609 count = (Long)q.uniqueResult();
610
611 FinderCacheUtil.putResult(finderPath, finderArgs, count);
612 }
613 catch (Exception e) {
614 FinderCacheUtil.removeResult(finderPath, finderArgs);
615
616 throw processException(e);
617 }
618 finally {
619 closeSession(session);
620 }
621 }
622
623 return count.intValue();
624 }
625
626 private static final String _FINDER_COLUMN_UUID_UUID_1 = "assetCategory.uuid IS NULL";
627 private static final String _FINDER_COLUMN_UUID_UUID_2 = "assetCategory.uuid = ?";
628 private static final String _FINDER_COLUMN_UUID_UUID_3 = "(assetCategory.uuid IS NULL OR assetCategory.uuid = '')";
629 public static final FinderPath FINDER_PATH_FETCH_BY_UUID_G = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
630 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
631 AssetCategoryImpl.class, FINDER_CLASS_NAME_ENTITY, "fetchByUUID_G",
632 new String[] { String.class.getName(), Long.class.getName() },
633 AssetCategoryModelImpl.UUID_COLUMN_BITMASK |
634 AssetCategoryModelImpl.GROUPID_COLUMN_BITMASK);
635 public static final FinderPath FINDER_PATH_COUNT_BY_UUID_G = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
636 AssetCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class,
637 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUUID_G",
638 new String[] { String.class.getName(), Long.class.getName() });
639
640
649 @Override
650 public AssetCategory findByUUID_G(String uuid, long groupId)
651 throws NoSuchCategoryException, SystemException {
652 AssetCategory assetCategory = fetchByUUID_G(uuid, groupId);
653
654 if (assetCategory == null) {
655 StringBundler msg = new StringBundler(6);
656
657 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
658
659 msg.append("uuid=");
660 msg.append(uuid);
661
662 msg.append(", groupId=");
663 msg.append(groupId);
664
665 msg.append(StringPool.CLOSE_CURLY_BRACE);
666
667 if (_log.isWarnEnabled()) {
668 _log.warn(msg.toString());
669 }
670
671 throw new NoSuchCategoryException(msg.toString());
672 }
673
674 return assetCategory;
675 }
676
677
685 @Override
686 public AssetCategory fetchByUUID_G(String uuid, long groupId)
687 throws SystemException {
688 return fetchByUUID_G(uuid, groupId, true);
689 }
690
691
700 @Override
701 public AssetCategory fetchByUUID_G(String uuid, long groupId,
702 boolean retrieveFromCache) throws SystemException {
703 Object[] finderArgs = new Object[] { uuid, groupId };
704
705 Object result = null;
706
707 if (retrieveFromCache) {
708 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_UUID_G,
709 finderArgs, this);
710 }
711
712 if (result instanceof AssetCategory) {
713 AssetCategory assetCategory = (AssetCategory)result;
714
715 if (!Validator.equals(uuid, assetCategory.getUuid()) ||
716 (groupId != assetCategory.getGroupId())) {
717 result = null;
718 }
719 }
720
721 if (result == null) {
722 StringBundler query = new StringBundler(4);
723
724 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
725
726 boolean bindUuid = false;
727
728 if (uuid == null) {
729 query.append(_FINDER_COLUMN_UUID_G_UUID_1);
730 }
731 else if (uuid.equals(StringPool.BLANK)) {
732 query.append(_FINDER_COLUMN_UUID_G_UUID_3);
733 }
734 else {
735 bindUuid = true;
736
737 query.append(_FINDER_COLUMN_UUID_G_UUID_2);
738 }
739
740 query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
741
742 String sql = query.toString();
743
744 Session session = null;
745
746 try {
747 session = openSession();
748
749 Query q = session.createQuery(sql);
750
751 QueryPos qPos = QueryPos.getInstance(q);
752
753 if (bindUuid) {
754 qPos.add(uuid);
755 }
756
757 qPos.add(groupId);
758
759 List<AssetCategory> list = q.list();
760
761 if (list.isEmpty()) {
762 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
763 finderArgs, list);
764 }
765 else {
766 AssetCategory assetCategory = list.get(0);
767
768 result = assetCategory;
769
770 cacheResult(assetCategory);
771
772 if ((assetCategory.getUuid() == null) ||
773 !assetCategory.getUuid().equals(uuid) ||
774 (assetCategory.getGroupId() != groupId)) {
775 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
776 finderArgs, assetCategory);
777 }
778 }
779 }
780 catch (Exception e) {
781 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
782 finderArgs);
783
784 throw processException(e);
785 }
786 finally {
787 closeSession(session);
788 }
789 }
790
791 if (result instanceof List<?>) {
792 return null;
793 }
794 else {
795 return (AssetCategory)result;
796 }
797 }
798
799
807 @Override
808 public AssetCategory removeByUUID_G(String uuid, long groupId)
809 throws NoSuchCategoryException, SystemException {
810 AssetCategory assetCategory = findByUUID_G(uuid, groupId);
811
812 return remove(assetCategory);
813 }
814
815
823 @Override
824 public int countByUUID_G(String uuid, long groupId)
825 throws SystemException {
826 FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID_G;
827
828 Object[] finderArgs = new Object[] { uuid, groupId };
829
830 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
831 this);
832
833 if (count == null) {
834 StringBundler query = new StringBundler(3);
835
836 query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
837
838 boolean bindUuid = false;
839
840 if (uuid == null) {
841 query.append(_FINDER_COLUMN_UUID_G_UUID_1);
842 }
843 else if (uuid.equals(StringPool.BLANK)) {
844 query.append(_FINDER_COLUMN_UUID_G_UUID_3);
845 }
846 else {
847 bindUuid = true;
848
849 query.append(_FINDER_COLUMN_UUID_G_UUID_2);
850 }
851
852 query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
853
854 String sql = query.toString();
855
856 Session session = null;
857
858 try {
859 session = openSession();
860
861 Query q = session.createQuery(sql);
862
863 QueryPos qPos = QueryPos.getInstance(q);
864
865 if (bindUuid) {
866 qPos.add(uuid);
867 }
868
869 qPos.add(groupId);
870
871 count = (Long)q.uniqueResult();
872
873 FinderCacheUtil.putResult(finderPath, finderArgs, count);
874 }
875 catch (Exception e) {
876 FinderCacheUtil.removeResult(finderPath, finderArgs);
877
878 throw processException(e);
879 }
880 finally {
881 closeSession(session);
882 }
883 }
884
885 return count.intValue();
886 }
887
888 private static final String _FINDER_COLUMN_UUID_G_UUID_1 = "assetCategory.uuid IS NULL AND ";
889 private static final String _FINDER_COLUMN_UUID_G_UUID_2 = "assetCategory.uuid = ? AND ";
890 private static final String _FINDER_COLUMN_UUID_G_UUID_3 = "(assetCategory.uuid IS NULL OR assetCategory.uuid = '') AND ";
891 private static final String _FINDER_COLUMN_UUID_G_GROUPID_2 = "assetCategory.groupId = ?";
892 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID_C = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
893 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
894 AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
895 "findByUuid_C",
896 new String[] {
897 String.class.getName(), Long.class.getName(),
898
899 Integer.class.getName(), Integer.class.getName(),
900 OrderByComparator.class.getName()
901 });
902 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C =
903 new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
904 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
905 AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
906 "findByUuid_C",
907 new String[] { String.class.getName(), Long.class.getName() },
908 AssetCategoryModelImpl.UUID_COLUMN_BITMASK |
909 AssetCategoryModelImpl.COMPANYID_COLUMN_BITMASK |
910 AssetCategoryModelImpl.NAME_COLUMN_BITMASK);
911 public static final FinderPath FINDER_PATH_COUNT_BY_UUID_C = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
912 AssetCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class,
913 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid_C",
914 new String[] { String.class.getName(), Long.class.getName() });
915
916
924 @Override
925 public List<AssetCategory> findByUuid_C(String uuid, long companyId)
926 throws SystemException {
927 return findByUuid_C(uuid, companyId, QueryUtil.ALL_POS,
928 QueryUtil.ALL_POS, null);
929 }
930
931
945 @Override
946 public List<AssetCategory> findByUuid_C(String uuid, long companyId,
947 int start, int end) throws SystemException {
948 return findByUuid_C(uuid, companyId, start, end, null);
949 }
950
951
966 @Override
967 public List<AssetCategory> findByUuid_C(String uuid, long companyId,
968 int start, int end, OrderByComparator orderByComparator)
969 throws SystemException {
970 boolean pagination = true;
971 FinderPath finderPath = null;
972 Object[] finderArgs = null;
973
974 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
975 (orderByComparator == null)) {
976 pagination = false;
977 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C;
978 finderArgs = new Object[] { uuid, companyId };
979 }
980 else {
981 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID_C;
982 finderArgs = new Object[] {
983 uuid, companyId,
984
985 start, end, orderByComparator
986 };
987 }
988
989 List<AssetCategory> list = (List<AssetCategory>)FinderCacheUtil.getResult(finderPath,
990 finderArgs, this);
991
992 if ((list != null) && !list.isEmpty()) {
993 for (AssetCategory assetCategory : list) {
994 if (!Validator.equals(uuid, assetCategory.getUuid()) ||
995 (companyId != assetCategory.getCompanyId())) {
996 list = null;
997
998 break;
999 }
1000 }
1001 }
1002
1003 if (list == null) {
1004 StringBundler query = null;
1005
1006 if (orderByComparator != null) {
1007 query = new StringBundler(4 +
1008 (orderByComparator.getOrderByFields().length * 3));
1009 }
1010 else {
1011 query = new StringBundler(4);
1012 }
1013
1014 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
1015
1016 boolean bindUuid = false;
1017
1018 if (uuid == null) {
1019 query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1020 }
1021 else if (uuid.equals(StringPool.BLANK)) {
1022 query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1023 }
1024 else {
1025 bindUuid = true;
1026
1027 query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1028 }
1029
1030 query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1031
1032 if (orderByComparator != null) {
1033 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1034 orderByComparator);
1035 }
1036 else
1037 if (pagination) {
1038 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
1039 }
1040
1041 String sql = query.toString();
1042
1043 Session session = null;
1044
1045 try {
1046 session = openSession();
1047
1048 Query q = session.createQuery(sql);
1049
1050 QueryPos qPos = QueryPos.getInstance(q);
1051
1052 if (bindUuid) {
1053 qPos.add(uuid);
1054 }
1055
1056 qPos.add(companyId);
1057
1058 if (!pagination) {
1059 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
1060 start, end, false);
1061
1062 Collections.sort(list);
1063
1064 list = new UnmodifiableList<AssetCategory>(list);
1065 }
1066 else {
1067 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
1068 start, end);
1069 }
1070
1071 cacheResult(list);
1072
1073 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1074 }
1075 catch (Exception e) {
1076 FinderCacheUtil.removeResult(finderPath, finderArgs);
1077
1078 throw processException(e);
1079 }
1080 finally {
1081 closeSession(session);
1082 }
1083 }
1084
1085 return list;
1086 }
1087
1088
1098 @Override
1099 public AssetCategory findByUuid_C_First(String uuid, long companyId,
1100 OrderByComparator orderByComparator)
1101 throws NoSuchCategoryException, SystemException {
1102 AssetCategory assetCategory = fetchByUuid_C_First(uuid, companyId,
1103 orderByComparator);
1104
1105 if (assetCategory != null) {
1106 return assetCategory;
1107 }
1108
1109 StringBundler msg = new StringBundler(6);
1110
1111 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1112
1113 msg.append("uuid=");
1114 msg.append(uuid);
1115
1116 msg.append(", companyId=");
1117 msg.append(companyId);
1118
1119 msg.append(StringPool.CLOSE_CURLY_BRACE);
1120
1121 throw new NoSuchCategoryException(msg.toString());
1122 }
1123
1124
1133 @Override
1134 public AssetCategory fetchByUuid_C_First(String uuid, long companyId,
1135 OrderByComparator orderByComparator) throws SystemException {
1136 List<AssetCategory> list = findByUuid_C(uuid, companyId, 0, 1,
1137 orderByComparator);
1138
1139 if (!list.isEmpty()) {
1140 return list.get(0);
1141 }
1142
1143 return null;
1144 }
1145
1146
1156 @Override
1157 public AssetCategory findByUuid_C_Last(String uuid, long companyId,
1158 OrderByComparator orderByComparator)
1159 throws NoSuchCategoryException, SystemException {
1160 AssetCategory assetCategory = fetchByUuid_C_Last(uuid, companyId,
1161 orderByComparator);
1162
1163 if (assetCategory != null) {
1164 return assetCategory;
1165 }
1166
1167 StringBundler msg = new StringBundler(6);
1168
1169 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1170
1171 msg.append("uuid=");
1172 msg.append(uuid);
1173
1174 msg.append(", companyId=");
1175 msg.append(companyId);
1176
1177 msg.append(StringPool.CLOSE_CURLY_BRACE);
1178
1179 throw new NoSuchCategoryException(msg.toString());
1180 }
1181
1182
1191 @Override
1192 public AssetCategory fetchByUuid_C_Last(String uuid, long companyId,
1193 OrderByComparator orderByComparator) throws SystemException {
1194 int count = countByUuid_C(uuid, companyId);
1195
1196 if (count == 0) {
1197 return null;
1198 }
1199
1200 List<AssetCategory> list = findByUuid_C(uuid, companyId, count - 1,
1201 count, orderByComparator);
1202
1203 if (!list.isEmpty()) {
1204 return list.get(0);
1205 }
1206
1207 return null;
1208 }
1209
1210
1221 @Override
1222 public AssetCategory[] findByUuid_C_PrevAndNext(long categoryId,
1223 String uuid, long companyId, OrderByComparator orderByComparator)
1224 throws NoSuchCategoryException, SystemException {
1225 AssetCategory assetCategory = findByPrimaryKey(categoryId);
1226
1227 Session session = null;
1228
1229 try {
1230 session = openSession();
1231
1232 AssetCategory[] array = new AssetCategoryImpl[3];
1233
1234 array[0] = getByUuid_C_PrevAndNext(session, assetCategory, uuid,
1235 companyId, orderByComparator, true);
1236
1237 array[1] = assetCategory;
1238
1239 array[2] = getByUuid_C_PrevAndNext(session, assetCategory, uuid,
1240 companyId, orderByComparator, false);
1241
1242 return array;
1243 }
1244 catch (Exception e) {
1245 throw processException(e);
1246 }
1247 finally {
1248 closeSession(session);
1249 }
1250 }
1251
1252 protected AssetCategory getByUuid_C_PrevAndNext(Session session,
1253 AssetCategory assetCategory, String uuid, long companyId,
1254 OrderByComparator orderByComparator, boolean previous) {
1255 StringBundler query = null;
1256
1257 if (orderByComparator != null) {
1258 query = new StringBundler(6 +
1259 (orderByComparator.getOrderByFields().length * 6));
1260 }
1261 else {
1262 query = new StringBundler(3);
1263 }
1264
1265 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
1266
1267 boolean bindUuid = false;
1268
1269 if (uuid == null) {
1270 query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1271 }
1272 else if (uuid.equals(StringPool.BLANK)) {
1273 query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1274 }
1275 else {
1276 bindUuid = true;
1277
1278 query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1279 }
1280
1281 query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1282
1283 if (orderByComparator != null) {
1284 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1285
1286 if (orderByConditionFields.length > 0) {
1287 query.append(WHERE_AND);
1288 }
1289
1290 for (int i = 0; i < orderByConditionFields.length; i++) {
1291 query.append(_ORDER_BY_ENTITY_ALIAS);
1292 query.append(orderByConditionFields[i]);
1293
1294 if ((i + 1) < orderByConditionFields.length) {
1295 if (orderByComparator.isAscending() ^ previous) {
1296 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1297 }
1298 else {
1299 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1300 }
1301 }
1302 else {
1303 if (orderByComparator.isAscending() ^ previous) {
1304 query.append(WHERE_GREATER_THAN);
1305 }
1306 else {
1307 query.append(WHERE_LESSER_THAN);
1308 }
1309 }
1310 }
1311
1312 query.append(ORDER_BY_CLAUSE);
1313
1314 String[] orderByFields = orderByComparator.getOrderByFields();
1315
1316 for (int i = 0; i < orderByFields.length; i++) {
1317 query.append(_ORDER_BY_ENTITY_ALIAS);
1318 query.append(orderByFields[i]);
1319
1320 if ((i + 1) < orderByFields.length) {
1321 if (orderByComparator.isAscending() ^ previous) {
1322 query.append(ORDER_BY_ASC_HAS_NEXT);
1323 }
1324 else {
1325 query.append(ORDER_BY_DESC_HAS_NEXT);
1326 }
1327 }
1328 else {
1329 if (orderByComparator.isAscending() ^ previous) {
1330 query.append(ORDER_BY_ASC);
1331 }
1332 else {
1333 query.append(ORDER_BY_DESC);
1334 }
1335 }
1336 }
1337 }
1338 else {
1339 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
1340 }
1341
1342 String sql = query.toString();
1343
1344 Query q = session.createQuery(sql);
1345
1346 q.setFirstResult(0);
1347 q.setMaxResults(2);
1348
1349 QueryPos qPos = QueryPos.getInstance(q);
1350
1351 if (bindUuid) {
1352 qPos.add(uuid);
1353 }
1354
1355 qPos.add(companyId);
1356
1357 if (orderByComparator != null) {
1358 Object[] values = orderByComparator.getOrderByConditionValues(assetCategory);
1359
1360 for (Object value : values) {
1361 qPos.add(value);
1362 }
1363 }
1364
1365 List<AssetCategory> list = q.list();
1366
1367 if (list.size() == 2) {
1368 return list.get(1);
1369 }
1370 else {
1371 return null;
1372 }
1373 }
1374
1375
1382 @Override
1383 public void removeByUuid_C(String uuid, long companyId)
1384 throws SystemException {
1385 for (AssetCategory assetCategory : findByUuid_C(uuid, companyId,
1386 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
1387 remove(assetCategory);
1388 }
1389 }
1390
1391
1399 @Override
1400 public int countByUuid_C(String uuid, long companyId)
1401 throws SystemException {
1402 FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID_C;
1403
1404 Object[] finderArgs = new Object[] { uuid, companyId };
1405
1406 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
1407 this);
1408
1409 if (count == null) {
1410 StringBundler query = new StringBundler(3);
1411
1412 query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
1413
1414 boolean bindUuid = false;
1415
1416 if (uuid == null) {
1417 query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1418 }
1419 else if (uuid.equals(StringPool.BLANK)) {
1420 query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1421 }
1422 else {
1423 bindUuid = true;
1424
1425 query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1426 }
1427
1428 query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1429
1430 String sql = query.toString();
1431
1432 Session session = null;
1433
1434 try {
1435 session = openSession();
1436
1437 Query q = session.createQuery(sql);
1438
1439 QueryPos qPos = QueryPos.getInstance(q);
1440
1441 if (bindUuid) {
1442 qPos.add(uuid);
1443 }
1444
1445 qPos.add(companyId);
1446
1447 count = (Long)q.uniqueResult();
1448
1449 FinderCacheUtil.putResult(finderPath, finderArgs, count);
1450 }
1451 catch (Exception e) {
1452 FinderCacheUtil.removeResult(finderPath, finderArgs);
1453
1454 throw processException(e);
1455 }
1456 finally {
1457 closeSession(session);
1458 }
1459 }
1460
1461 return count.intValue();
1462 }
1463
1464 private static final String _FINDER_COLUMN_UUID_C_UUID_1 = "assetCategory.uuid IS NULL AND ";
1465 private static final String _FINDER_COLUMN_UUID_C_UUID_2 = "assetCategory.uuid = ? AND ";
1466 private static final String _FINDER_COLUMN_UUID_C_UUID_3 = "(assetCategory.uuid IS NULL OR assetCategory.uuid = '') AND ";
1467 private static final String _FINDER_COLUMN_UUID_C_COMPANYID_2 = "assetCategory.companyId = ?";
1468 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
1469 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
1470 AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
1471 "findByGroupId",
1472 new String[] {
1473 Long.class.getName(),
1474
1475 Integer.class.getName(), Integer.class.getName(),
1476 OrderByComparator.class.getName()
1477 });
1478 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID =
1479 new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
1480 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
1481 AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
1482 "findByGroupId", new String[] { Long.class.getName() },
1483 AssetCategoryModelImpl.GROUPID_COLUMN_BITMASK |
1484 AssetCategoryModelImpl.NAME_COLUMN_BITMASK);
1485 public static final FinderPath FINDER_PATH_COUNT_BY_GROUPID = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
1486 AssetCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class,
1487 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByGroupId",
1488 new String[] { Long.class.getName() });
1489
1490
1497 @Override
1498 public List<AssetCategory> findByGroupId(long groupId)
1499 throws SystemException {
1500 return findByGroupId(groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1501 }
1502
1503
1516 @Override
1517 public List<AssetCategory> findByGroupId(long groupId, int start, int end)
1518 throws SystemException {
1519 return findByGroupId(groupId, start, end, null);
1520 }
1521
1522
1536 @Override
1537 public List<AssetCategory> findByGroupId(long groupId, int start, int end,
1538 OrderByComparator orderByComparator) throws SystemException {
1539 boolean pagination = true;
1540 FinderPath finderPath = null;
1541 Object[] finderArgs = null;
1542
1543 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1544 (orderByComparator == null)) {
1545 pagination = false;
1546 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID;
1547 finderArgs = new Object[] { groupId };
1548 }
1549 else {
1550 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID;
1551 finderArgs = new Object[] { groupId, start, end, orderByComparator };
1552 }
1553
1554 List<AssetCategory> list = (List<AssetCategory>)FinderCacheUtil.getResult(finderPath,
1555 finderArgs, this);
1556
1557 if ((list != null) && !list.isEmpty()) {
1558 for (AssetCategory assetCategory : list) {
1559 if ((groupId != assetCategory.getGroupId())) {
1560 list = null;
1561
1562 break;
1563 }
1564 }
1565 }
1566
1567 if (list == null) {
1568 StringBundler query = null;
1569
1570 if (orderByComparator != null) {
1571 query = new StringBundler(3 +
1572 (orderByComparator.getOrderByFields().length * 3));
1573 }
1574 else {
1575 query = new StringBundler(3);
1576 }
1577
1578 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
1579
1580 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1581
1582 if (orderByComparator != null) {
1583 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1584 orderByComparator);
1585 }
1586 else
1587 if (pagination) {
1588 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
1589 }
1590
1591 String sql = query.toString();
1592
1593 Session session = null;
1594
1595 try {
1596 session = openSession();
1597
1598 Query q = session.createQuery(sql);
1599
1600 QueryPos qPos = QueryPos.getInstance(q);
1601
1602 qPos.add(groupId);
1603
1604 if (!pagination) {
1605 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
1606 start, end, false);
1607
1608 Collections.sort(list);
1609
1610 list = new UnmodifiableList<AssetCategory>(list);
1611 }
1612 else {
1613 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
1614 start, end);
1615 }
1616
1617 cacheResult(list);
1618
1619 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1620 }
1621 catch (Exception e) {
1622 FinderCacheUtil.removeResult(finderPath, finderArgs);
1623
1624 throw processException(e);
1625 }
1626 finally {
1627 closeSession(session);
1628 }
1629 }
1630
1631 return list;
1632 }
1633
1634
1643 @Override
1644 public AssetCategory findByGroupId_First(long groupId,
1645 OrderByComparator orderByComparator)
1646 throws NoSuchCategoryException, SystemException {
1647 AssetCategory assetCategory = fetchByGroupId_First(groupId,
1648 orderByComparator);
1649
1650 if (assetCategory != null) {
1651 return assetCategory;
1652 }
1653
1654 StringBundler msg = new StringBundler(4);
1655
1656 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1657
1658 msg.append("groupId=");
1659 msg.append(groupId);
1660
1661 msg.append(StringPool.CLOSE_CURLY_BRACE);
1662
1663 throw new NoSuchCategoryException(msg.toString());
1664 }
1665
1666
1674 @Override
1675 public AssetCategory fetchByGroupId_First(long groupId,
1676 OrderByComparator orderByComparator) throws SystemException {
1677 List<AssetCategory> list = findByGroupId(groupId, 0, 1,
1678 orderByComparator);
1679
1680 if (!list.isEmpty()) {
1681 return list.get(0);
1682 }
1683
1684 return null;
1685 }
1686
1687
1696 @Override
1697 public AssetCategory findByGroupId_Last(long groupId,
1698 OrderByComparator orderByComparator)
1699 throws NoSuchCategoryException, SystemException {
1700 AssetCategory assetCategory = fetchByGroupId_Last(groupId,
1701 orderByComparator);
1702
1703 if (assetCategory != null) {
1704 return assetCategory;
1705 }
1706
1707 StringBundler msg = new StringBundler(4);
1708
1709 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1710
1711 msg.append("groupId=");
1712 msg.append(groupId);
1713
1714 msg.append(StringPool.CLOSE_CURLY_BRACE);
1715
1716 throw new NoSuchCategoryException(msg.toString());
1717 }
1718
1719
1727 @Override
1728 public AssetCategory fetchByGroupId_Last(long groupId,
1729 OrderByComparator orderByComparator) throws SystemException {
1730 int count = countByGroupId(groupId);
1731
1732 if (count == 0) {
1733 return null;
1734 }
1735
1736 List<AssetCategory> list = findByGroupId(groupId, count - 1, count,
1737 orderByComparator);
1738
1739 if (!list.isEmpty()) {
1740 return list.get(0);
1741 }
1742
1743 return null;
1744 }
1745
1746
1756 @Override
1757 public AssetCategory[] findByGroupId_PrevAndNext(long categoryId,
1758 long groupId, OrderByComparator orderByComparator)
1759 throws NoSuchCategoryException, SystemException {
1760 AssetCategory assetCategory = findByPrimaryKey(categoryId);
1761
1762 Session session = null;
1763
1764 try {
1765 session = openSession();
1766
1767 AssetCategory[] array = new AssetCategoryImpl[3];
1768
1769 array[0] = getByGroupId_PrevAndNext(session, assetCategory,
1770 groupId, orderByComparator, true);
1771
1772 array[1] = assetCategory;
1773
1774 array[2] = getByGroupId_PrevAndNext(session, assetCategory,
1775 groupId, orderByComparator, false);
1776
1777 return array;
1778 }
1779 catch (Exception e) {
1780 throw processException(e);
1781 }
1782 finally {
1783 closeSession(session);
1784 }
1785 }
1786
1787 protected AssetCategory getByGroupId_PrevAndNext(Session session,
1788 AssetCategory assetCategory, long groupId,
1789 OrderByComparator orderByComparator, boolean previous) {
1790 StringBundler query = null;
1791
1792 if (orderByComparator != null) {
1793 query = new StringBundler(6 +
1794 (orderByComparator.getOrderByFields().length * 6));
1795 }
1796 else {
1797 query = new StringBundler(3);
1798 }
1799
1800 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
1801
1802 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1803
1804 if (orderByComparator != null) {
1805 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1806
1807 if (orderByConditionFields.length > 0) {
1808 query.append(WHERE_AND);
1809 }
1810
1811 for (int i = 0; i < orderByConditionFields.length; i++) {
1812 query.append(_ORDER_BY_ENTITY_ALIAS);
1813 query.append(orderByConditionFields[i]);
1814
1815 if ((i + 1) < orderByConditionFields.length) {
1816 if (orderByComparator.isAscending() ^ previous) {
1817 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1818 }
1819 else {
1820 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1821 }
1822 }
1823 else {
1824 if (orderByComparator.isAscending() ^ previous) {
1825 query.append(WHERE_GREATER_THAN);
1826 }
1827 else {
1828 query.append(WHERE_LESSER_THAN);
1829 }
1830 }
1831 }
1832
1833 query.append(ORDER_BY_CLAUSE);
1834
1835 String[] orderByFields = orderByComparator.getOrderByFields();
1836
1837 for (int i = 0; i < orderByFields.length; i++) {
1838 query.append(_ORDER_BY_ENTITY_ALIAS);
1839 query.append(orderByFields[i]);
1840
1841 if ((i + 1) < orderByFields.length) {
1842 if (orderByComparator.isAscending() ^ previous) {
1843 query.append(ORDER_BY_ASC_HAS_NEXT);
1844 }
1845 else {
1846 query.append(ORDER_BY_DESC_HAS_NEXT);
1847 }
1848 }
1849 else {
1850 if (orderByComparator.isAscending() ^ previous) {
1851 query.append(ORDER_BY_ASC);
1852 }
1853 else {
1854 query.append(ORDER_BY_DESC);
1855 }
1856 }
1857 }
1858 }
1859 else {
1860 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
1861 }
1862
1863 String sql = query.toString();
1864
1865 Query q = session.createQuery(sql);
1866
1867 q.setFirstResult(0);
1868 q.setMaxResults(2);
1869
1870 QueryPos qPos = QueryPos.getInstance(q);
1871
1872 qPos.add(groupId);
1873
1874 if (orderByComparator != null) {
1875 Object[] values = orderByComparator.getOrderByConditionValues(assetCategory);
1876
1877 for (Object value : values) {
1878 qPos.add(value);
1879 }
1880 }
1881
1882 List<AssetCategory> list = q.list();
1883
1884 if (list.size() == 2) {
1885 return list.get(1);
1886 }
1887 else {
1888 return null;
1889 }
1890 }
1891
1892
1899 @Override
1900 public List<AssetCategory> filterFindByGroupId(long groupId)
1901 throws SystemException {
1902 return filterFindByGroupId(groupId, QueryUtil.ALL_POS,
1903 QueryUtil.ALL_POS, null);
1904 }
1905
1906
1919 @Override
1920 public List<AssetCategory> filterFindByGroupId(long groupId, int start,
1921 int end) throws SystemException {
1922 return filterFindByGroupId(groupId, start, end, null);
1923 }
1924
1925
1939 @Override
1940 public List<AssetCategory> filterFindByGroupId(long groupId, int start,
1941 int end, OrderByComparator orderByComparator) throws SystemException {
1942 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
1943 return findByGroupId(groupId, start, end, orderByComparator);
1944 }
1945
1946 StringBundler query = null;
1947
1948 if (orderByComparator != null) {
1949 query = new StringBundler(3 +
1950 (orderByComparator.getOrderByFields().length * 3));
1951 }
1952 else {
1953 query = new StringBundler(3);
1954 }
1955
1956 if (getDB().isSupportsInlineDistinct()) {
1957 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_WHERE);
1958 }
1959 else {
1960 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_1);
1961 }
1962
1963 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1964
1965 if (!getDB().isSupportsInlineDistinct()) {
1966 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_2);
1967 }
1968
1969 if (orderByComparator != null) {
1970 if (getDB().isSupportsInlineDistinct()) {
1971 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1972 orderByComparator, true);
1973 }
1974 else {
1975 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
1976 orderByComparator, true);
1977 }
1978 }
1979 else {
1980 if (getDB().isSupportsInlineDistinct()) {
1981 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
1982 }
1983 else {
1984 query.append(AssetCategoryModelImpl.ORDER_BY_SQL);
1985 }
1986 }
1987
1988 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1989 AssetCategory.class.getName(),
1990 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
1991
1992 Session session = null;
1993
1994 try {
1995 session = openSession();
1996
1997 SQLQuery q = session.createSQLQuery(sql);
1998
1999 if (getDB().isSupportsInlineDistinct()) {
2000 q.addEntity(_FILTER_ENTITY_ALIAS, AssetCategoryImpl.class);
2001 }
2002 else {
2003 q.addEntity(_FILTER_ENTITY_TABLE, AssetCategoryImpl.class);
2004 }
2005
2006 QueryPos qPos = QueryPos.getInstance(q);
2007
2008 qPos.add(groupId);
2009
2010 return (List<AssetCategory>)QueryUtil.list(q, getDialect(), start,
2011 end);
2012 }
2013 catch (Exception e) {
2014 throw processException(e);
2015 }
2016 finally {
2017 closeSession(session);
2018 }
2019 }
2020
2021
2031 @Override
2032 public AssetCategory[] filterFindByGroupId_PrevAndNext(long categoryId,
2033 long groupId, OrderByComparator orderByComparator)
2034 throws NoSuchCategoryException, SystemException {
2035 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2036 return findByGroupId_PrevAndNext(categoryId, groupId,
2037 orderByComparator);
2038 }
2039
2040 AssetCategory assetCategory = findByPrimaryKey(categoryId);
2041
2042 Session session = null;
2043
2044 try {
2045 session = openSession();
2046
2047 AssetCategory[] array = new AssetCategoryImpl[3];
2048
2049 array[0] = filterGetByGroupId_PrevAndNext(session, assetCategory,
2050 groupId, orderByComparator, true);
2051
2052 array[1] = assetCategory;
2053
2054 array[2] = filterGetByGroupId_PrevAndNext(session, assetCategory,
2055 groupId, orderByComparator, false);
2056
2057 return array;
2058 }
2059 catch (Exception e) {
2060 throw processException(e);
2061 }
2062 finally {
2063 closeSession(session);
2064 }
2065 }
2066
2067 protected AssetCategory filterGetByGroupId_PrevAndNext(Session session,
2068 AssetCategory assetCategory, long groupId,
2069 OrderByComparator orderByComparator, boolean previous) {
2070 StringBundler query = null;
2071
2072 if (orderByComparator != null) {
2073 query = new StringBundler(6 +
2074 (orderByComparator.getOrderByFields().length * 6));
2075 }
2076 else {
2077 query = new StringBundler(3);
2078 }
2079
2080 if (getDB().isSupportsInlineDistinct()) {
2081 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_WHERE);
2082 }
2083 else {
2084 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_1);
2085 }
2086
2087 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2088
2089 if (!getDB().isSupportsInlineDistinct()) {
2090 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_2);
2091 }
2092
2093 if (orderByComparator != null) {
2094 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2095
2096 if (orderByConditionFields.length > 0) {
2097 query.append(WHERE_AND);
2098 }
2099
2100 for (int i = 0; i < orderByConditionFields.length; i++) {
2101 if (getDB().isSupportsInlineDistinct()) {
2102 query.append(_ORDER_BY_ENTITY_ALIAS);
2103 }
2104 else {
2105 query.append(_ORDER_BY_ENTITY_TABLE);
2106 }
2107
2108 query.append(orderByConditionFields[i]);
2109
2110 if ((i + 1) < orderByConditionFields.length) {
2111 if (orderByComparator.isAscending() ^ previous) {
2112 query.append(WHERE_GREATER_THAN_HAS_NEXT);
2113 }
2114 else {
2115 query.append(WHERE_LESSER_THAN_HAS_NEXT);
2116 }
2117 }
2118 else {
2119 if (orderByComparator.isAscending() ^ previous) {
2120 query.append(WHERE_GREATER_THAN);
2121 }
2122 else {
2123 query.append(WHERE_LESSER_THAN);
2124 }
2125 }
2126 }
2127
2128 query.append(ORDER_BY_CLAUSE);
2129
2130 String[] orderByFields = orderByComparator.getOrderByFields();
2131
2132 for (int i = 0; i < orderByFields.length; i++) {
2133 if (getDB().isSupportsInlineDistinct()) {
2134 query.append(_ORDER_BY_ENTITY_ALIAS);
2135 }
2136 else {
2137 query.append(_ORDER_BY_ENTITY_TABLE);
2138 }
2139
2140 query.append(orderByFields[i]);
2141
2142 if ((i + 1) < orderByFields.length) {
2143 if (orderByComparator.isAscending() ^ previous) {
2144 query.append(ORDER_BY_ASC_HAS_NEXT);
2145 }
2146 else {
2147 query.append(ORDER_BY_DESC_HAS_NEXT);
2148 }
2149 }
2150 else {
2151 if (orderByComparator.isAscending() ^ previous) {
2152 query.append(ORDER_BY_ASC);
2153 }
2154 else {
2155 query.append(ORDER_BY_DESC);
2156 }
2157 }
2158 }
2159 }
2160 else {
2161 if (getDB().isSupportsInlineDistinct()) {
2162 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
2163 }
2164 else {
2165 query.append(AssetCategoryModelImpl.ORDER_BY_SQL);
2166 }
2167 }
2168
2169 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2170 AssetCategory.class.getName(),
2171 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2172
2173 SQLQuery q = session.createSQLQuery(sql);
2174
2175 q.setFirstResult(0);
2176 q.setMaxResults(2);
2177
2178 if (getDB().isSupportsInlineDistinct()) {
2179 q.addEntity(_FILTER_ENTITY_ALIAS, AssetCategoryImpl.class);
2180 }
2181 else {
2182 q.addEntity(_FILTER_ENTITY_TABLE, AssetCategoryImpl.class);
2183 }
2184
2185 QueryPos qPos = QueryPos.getInstance(q);
2186
2187 qPos.add(groupId);
2188
2189 if (orderByComparator != null) {
2190 Object[] values = orderByComparator.getOrderByConditionValues(assetCategory);
2191
2192 for (Object value : values) {
2193 qPos.add(value);
2194 }
2195 }
2196
2197 List<AssetCategory> list = q.list();
2198
2199 if (list.size() == 2) {
2200 return list.get(1);
2201 }
2202 else {
2203 return null;
2204 }
2205 }
2206
2207
2213 @Override
2214 public void removeByGroupId(long groupId) throws SystemException {
2215 for (AssetCategory assetCategory : findByGroupId(groupId,
2216 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
2217 remove(assetCategory);
2218 }
2219 }
2220
2221
2228 @Override
2229 public int countByGroupId(long groupId) throws SystemException {
2230 FinderPath finderPath = FINDER_PATH_COUNT_BY_GROUPID;
2231
2232 Object[] finderArgs = new Object[] { groupId };
2233
2234 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
2235 this);
2236
2237 if (count == null) {
2238 StringBundler query = new StringBundler(2);
2239
2240 query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
2241
2242 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2243
2244 String sql = query.toString();
2245
2246 Session session = null;
2247
2248 try {
2249 session = openSession();
2250
2251 Query q = session.createQuery(sql);
2252
2253 QueryPos qPos = QueryPos.getInstance(q);
2254
2255 qPos.add(groupId);
2256
2257 count = (Long)q.uniqueResult();
2258
2259 FinderCacheUtil.putResult(finderPath, finderArgs, count);
2260 }
2261 catch (Exception e) {
2262 FinderCacheUtil.removeResult(finderPath, finderArgs);
2263
2264 throw processException(e);
2265 }
2266 finally {
2267 closeSession(session);
2268 }
2269 }
2270
2271 return count.intValue();
2272 }
2273
2274
2281 @Override
2282 public int filterCountByGroupId(long groupId) throws SystemException {
2283 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2284 return countByGroupId(groupId);
2285 }
2286
2287 StringBundler query = new StringBundler(2);
2288
2289 query.append(_FILTER_SQL_COUNT_ASSETCATEGORY_WHERE);
2290
2291 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2292
2293 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2294 AssetCategory.class.getName(),
2295 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2296
2297 Session session = null;
2298
2299 try {
2300 session = openSession();
2301
2302 SQLQuery q = session.createSQLQuery(sql);
2303
2304 q.addScalar(COUNT_COLUMN_NAME,
2305 com.liferay.portal.kernel.dao.orm.Type.LONG);
2306
2307 QueryPos qPos = QueryPos.getInstance(q);
2308
2309 qPos.add(groupId);
2310
2311 Long count = (Long)q.uniqueResult();
2312
2313 return count.intValue();
2314 }
2315 catch (Exception e) {
2316 throw processException(e);
2317 }
2318 finally {
2319 closeSession(session);
2320 }
2321 }
2322
2323 private static final String _FINDER_COLUMN_GROUPID_GROUPID_2 = "assetCategory.groupId = ?";
2324 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_PARENTCATEGORYID =
2325 new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
2326 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
2327 AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
2328 "findByParentCategoryId",
2329 new String[] {
2330 Long.class.getName(),
2331
2332 Integer.class.getName(), Integer.class.getName(),
2333 OrderByComparator.class.getName()
2334 });
2335 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_PARENTCATEGORYID =
2336 new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
2337 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
2338 AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
2339 "findByParentCategoryId", new String[] { Long.class.getName() },
2340 AssetCategoryModelImpl.PARENTCATEGORYID_COLUMN_BITMASK |
2341 AssetCategoryModelImpl.NAME_COLUMN_BITMASK);
2342 public static final FinderPath FINDER_PATH_COUNT_BY_PARENTCATEGORYID = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
2343 AssetCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class,
2344 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
2345 "countByParentCategoryId", new String[] { Long.class.getName() });
2346
2347
2354 @Override
2355 public List<AssetCategory> findByParentCategoryId(long parentCategoryId)
2356 throws SystemException {
2357 return findByParentCategoryId(parentCategoryId, QueryUtil.ALL_POS,
2358 QueryUtil.ALL_POS, null);
2359 }
2360
2361
2374 @Override
2375 public List<AssetCategory> findByParentCategoryId(long parentCategoryId,
2376 int start, int end) throws SystemException {
2377 return findByParentCategoryId(parentCategoryId, start, end, null);
2378 }
2379
2380
2394 @Override
2395 public List<AssetCategory> findByParentCategoryId(long parentCategoryId,
2396 int start, int end, OrderByComparator orderByComparator)
2397 throws SystemException {
2398 boolean pagination = true;
2399 FinderPath finderPath = null;
2400 Object[] finderArgs = null;
2401
2402 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2403 (orderByComparator == null)) {
2404 pagination = false;
2405 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_PARENTCATEGORYID;
2406 finderArgs = new Object[] { parentCategoryId };
2407 }
2408 else {
2409 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_PARENTCATEGORYID;
2410 finderArgs = new Object[] {
2411 parentCategoryId,
2412
2413 start, end, orderByComparator
2414 };
2415 }
2416
2417 List<AssetCategory> list = (List<AssetCategory>)FinderCacheUtil.getResult(finderPath,
2418 finderArgs, this);
2419
2420 if ((list != null) && !list.isEmpty()) {
2421 for (AssetCategory assetCategory : list) {
2422 if ((parentCategoryId != assetCategory.getParentCategoryId())) {
2423 list = null;
2424
2425 break;
2426 }
2427 }
2428 }
2429
2430 if (list == null) {
2431 StringBundler query = null;
2432
2433 if (orderByComparator != null) {
2434 query = new StringBundler(3 +
2435 (orderByComparator.getOrderByFields().length * 3));
2436 }
2437 else {
2438 query = new StringBundler(3);
2439 }
2440
2441 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
2442
2443 query.append(_FINDER_COLUMN_PARENTCATEGORYID_PARENTCATEGORYID_2);
2444
2445 if (orderByComparator != null) {
2446 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2447 orderByComparator);
2448 }
2449 else
2450 if (pagination) {
2451 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
2452 }
2453
2454 String sql = query.toString();
2455
2456 Session session = null;
2457
2458 try {
2459 session = openSession();
2460
2461 Query q = session.createQuery(sql);
2462
2463 QueryPos qPos = QueryPos.getInstance(q);
2464
2465 qPos.add(parentCategoryId);
2466
2467 if (!pagination) {
2468 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
2469 start, end, false);
2470
2471 Collections.sort(list);
2472
2473 list = new UnmodifiableList<AssetCategory>(list);
2474 }
2475 else {
2476 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
2477 start, end);
2478 }
2479
2480 cacheResult(list);
2481
2482 FinderCacheUtil.putResult(finderPath, finderArgs, list);
2483 }
2484 catch (Exception e) {
2485 FinderCacheUtil.removeResult(finderPath, finderArgs);
2486
2487 throw processException(e);
2488 }
2489 finally {
2490 closeSession(session);
2491 }
2492 }
2493
2494 return list;
2495 }
2496
2497
2506 @Override
2507 public AssetCategory findByParentCategoryId_First(long parentCategoryId,
2508 OrderByComparator orderByComparator)
2509 throws NoSuchCategoryException, SystemException {
2510 AssetCategory assetCategory = fetchByParentCategoryId_First(parentCategoryId,
2511 orderByComparator);
2512
2513 if (assetCategory != null) {
2514 return assetCategory;
2515 }
2516
2517 StringBundler msg = new StringBundler(4);
2518
2519 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2520
2521 msg.append("parentCategoryId=");
2522 msg.append(parentCategoryId);
2523
2524 msg.append(StringPool.CLOSE_CURLY_BRACE);
2525
2526 throw new NoSuchCategoryException(msg.toString());
2527 }
2528
2529
2537 @Override
2538 public AssetCategory fetchByParentCategoryId_First(long parentCategoryId,
2539 OrderByComparator orderByComparator) throws SystemException {
2540 List<AssetCategory> list = findByParentCategoryId(parentCategoryId, 0,
2541 1, orderByComparator);
2542
2543 if (!list.isEmpty()) {
2544 return list.get(0);
2545 }
2546
2547 return null;
2548 }
2549
2550
2559 @Override
2560 public AssetCategory findByParentCategoryId_Last(long parentCategoryId,
2561 OrderByComparator orderByComparator)
2562 throws NoSuchCategoryException, SystemException {
2563 AssetCategory assetCategory = fetchByParentCategoryId_Last(parentCategoryId,
2564 orderByComparator);
2565
2566 if (assetCategory != null) {
2567 return assetCategory;
2568 }
2569
2570 StringBundler msg = new StringBundler(4);
2571
2572 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2573
2574 msg.append("parentCategoryId=");
2575 msg.append(parentCategoryId);
2576
2577 msg.append(StringPool.CLOSE_CURLY_BRACE);
2578
2579 throw new NoSuchCategoryException(msg.toString());
2580 }
2581
2582
2590 @Override
2591 public AssetCategory fetchByParentCategoryId_Last(long parentCategoryId,
2592 OrderByComparator orderByComparator) throws SystemException {
2593 int count = countByParentCategoryId(parentCategoryId);
2594
2595 if (count == 0) {
2596 return null;
2597 }
2598
2599 List<AssetCategory> list = findByParentCategoryId(parentCategoryId,
2600 count - 1, count, orderByComparator);
2601
2602 if (!list.isEmpty()) {
2603 return list.get(0);
2604 }
2605
2606 return null;
2607 }
2608
2609
2619 @Override
2620 public AssetCategory[] findByParentCategoryId_PrevAndNext(long categoryId,
2621 long parentCategoryId, OrderByComparator orderByComparator)
2622 throws NoSuchCategoryException, SystemException {
2623 AssetCategory assetCategory = findByPrimaryKey(categoryId);
2624
2625 Session session = null;
2626
2627 try {
2628 session = openSession();
2629
2630 AssetCategory[] array = new AssetCategoryImpl[3];
2631
2632 array[0] = getByParentCategoryId_PrevAndNext(session,
2633 assetCategory, parentCategoryId, orderByComparator, true);
2634
2635 array[1] = assetCategory;
2636
2637 array[2] = getByParentCategoryId_PrevAndNext(session,
2638 assetCategory, parentCategoryId, orderByComparator, false);
2639
2640 return array;
2641 }
2642 catch (Exception e) {
2643 throw processException(e);
2644 }
2645 finally {
2646 closeSession(session);
2647 }
2648 }
2649
2650 protected AssetCategory getByParentCategoryId_PrevAndNext(Session session,
2651 AssetCategory assetCategory, long parentCategoryId,
2652 OrderByComparator orderByComparator, boolean previous) {
2653 StringBundler query = null;
2654
2655 if (orderByComparator != null) {
2656 query = new StringBundler(6 +
2657 (orderByComparator.getOrderByFields().length * 6));
2658 }
2659 else {
2660 query = new StringBundler(3);
2661 }
2662
2663 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
2664
2665 query.append(_FINDER_COLUMN_PARENTCATEGORYID_PARENTCATEGORYID_2);
2666
2667 if (orderByComparator != null) {
2668 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2669
2670 if (orderByConditionFields.length > 0) {
2671 query.append(WHERE_AND);
2672 }
2673
2674 for (int i = 0; i < orderByConditionFields.length; i++) {
2675 query.append(_ORDER_BY_ENTITY_ALIAS);
2676 query.append(orderByConditionFields[i]);
2677
2678 if ((i + 1) < orderByConditionFields.length) {
2679 if (orderByComparator.isAscending() ^ previous) {
2680 query.append(WHERE_GREATER_THAN_HAS_NEXT);
2681 }
2682 else {
2683 query.append(WHERE_LESSER_THAN_HAS_NEXT);
2684 }
2685 }
2686 else {
2687 if (orderByComparator.isAscending() ^ previous) {
2688 query.append(WHERE_GREATER_THAN);
2689 }
2690 else {
2691 query.append(WHERE_LESSER_THAN);
2692 }
2693 }
2694 }
2695
2696 query.append(ORDER_BY_CLAUSE);
2697
2698 String[] orderByFields = orderByComparator.getOrderByFields();
2699
2700 for (int i = 0; i < orderByFields.length; i++) {
2701 query.append(_ORDER_BY_ENTITY_ALIAS);
2702 query.append(orderByFields[i]);
2703
2704 if ((i + 1) < orderByFields.length) {
2705 if (orderByComparator.isAscending() ^ previous) {
2706 query.append(ORDER_BY_ASC_HAS_NEXT);
2707 }
2708 else {
2709 query.append(ORDER_BY_DESC_HAS_NEXT);
2710 }
2711 }
2712 else {
2713 if (orderByComparator.isAscending() ^ previous) {
2714 query.append(ORDER_BY_ASC);
2715 }
2716 else {
2717 query.append(ORDER_BY_DESC);
2718 }
2719 }
2720 }
2721 }
2722 else {
2723 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
2724 }
2725
2726 String sql = query.toString();
2727
2728 Query q = session.createQuery(sql);
2729
2730 q.setFirstResult(0);
2731 q.setMaxResults(2);
2732
2733 QueryPos qPos = QueryPos.getInstance(q);
2734
2735 qPos.add(parentCategoryId);
2736
2737 if (orderByComparator != null) {
2738 Object[] values = orderByComparator.getOrderByConditionValues(assetCategory);
2739
2740 for (Object value : values) {
2741 qPos.add(value);
2742 }
2743 }
2744
2745 List<AssetCategory> list = q.list();
2746
2747 if (list.size() == 2) {
2748 return list.get(1);
2749 }
2750 else {
2751 return null;
2752 }
2753 }
2754
2755
2761 @Override
2762 public void removeByParentCategoryId(long parentCategoryId)
2763 throws SystemException {
2764 for (AssetCategory assetCategory : findByParentCategoryId(
2765 parentCategoryId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
2766 remove(assetCategory);
2767 }
2768 }
2769
2770
2777 @Override
2778 public int countByParentCategoryId(long parentCategoryId)
2779 throws SystemException {
2780 FinderPath finderPath = FINDER_PATH_COUNT_BY_PARENTCATEGORYID;
2781
2782 Object[] finderArgs = new Object[] { parentCategoryId };
2783
2784 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
2785 this);
2786
2787 if (count == null) {
2788 StringBundler query = new StringBundler(2);
2789
2790 query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
2791
2792 query.append(_FINDER_COLUMN_PARENTCATEGORYID_PARENTCATEGORYID_2);
2793
2794 String sql = query.toString();
2795
2796 Session session = null;
2797
2798 try {
2799 session = openSession();
2800
2801 Query q = session.createQuery(sql);
2802
2803 QueryPos qPos = QueryPos.getInstance(q);
2804
2805 qPos.add(parentCategoryId);
2806
2807 count = (Long)q.uniqueResult();
2808
2809 FinderCacheUtil.putResult(finderPath, finderArgs, count);
2810 }
2811 catch (Exception e) {
2812 FinderCacheUtil.removeResult(finderPath, finderArgs);
2813
2814 throw processException(e);
2815 }
2816 finally {
2817 closeSession(session);
2818 }
2819 }
2820
2821 return count.intValue();
2822 }
2823
2824 private static final String _FINDER_COLUMN_PARENTCATEGORYID_PARENTCATEGORYID_2 =
2825 "assetCategory.parentCategoryId = ?";
2826 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_VOCABULARYID =
2827 new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
2828 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
2829 AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
2830 "findByVocabularyId",
2831 new String[] {
2832 Long.class.getName(),
2833
2834 Integer.class.getName(), Integer.class.getName(),
2835 OrderByComparator.class.getName()
2836 });
2837 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_VOCABULARYID =
2838 new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
2839 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
2840 AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
2841 "findByVocabularyId", new String[] { Long.class.getName() },
2842 AssetCategoryModelImpl.VOCABULARYID_COLUMN_BITMASK |
2843 AssetCategoryModelImpl.NAME_COLUMN_BITMASK);
2844 public static final FinderPath FINDER_PATH_COUNT_BY_VOCABULARYID = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
2845 AssetCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class,
2846 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByVocabularyId",
2847 new String[] { Long.class.getName() });
2848
2849
2856 @Override
2857 public List<AssetCategory> findByVocabularyId(long vocabularyId)
2858 throws SystemException {
2859 return findByVocabularyId(vocabularyId, QueryUtil.ALL_POS,
2860 QueryUtil.ALL_POS, null);
2861 }
2862
2863
2876 @Override
2877 public List<AssetCategory> findByVocabularyId(long vocabularyId, int start,
2878 int end) throws SystemException {
2879 return findByVocabularyId(vocabularyId, start, end, null);
2880 }
2881
2882
2896 @Override
2897 public List<AssetCategory> findByVocabularyId(long vocabularyId, int start,
2898 int end, OrderByComparator orderByComparator) throws SystemException {
2899 boolean pagination = true;
2900 FinderPath finderPath = null;
2901 Object[] finderArgs = null;
2902
2903 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2904 (orderByComparator == null)) {
2905 pagination = false;
2906 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_VOCABULARYID;
2907 finderArgs = new Object[] { vocabularyId };
2908 }
2909 else {
2910 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_VOCABULARYID;
2911 finderArgs = new Object[] {
2912 vocabularyId,
2913
2914 start, end, orderByComparator
2915 };
2916 }
2917
2918 List<AssetCategory> list = (List<AssetCategory>)FinderCacheUtil.getResult(finderPath,
2919 finderArgs, this);
2920
2921 if ((list != null) && !list.isEmpty()) {
2922 for (AssetCategory assetCategory : list) {
2923 if ((vocabularyId != assetCategory.getVocabularyId())) {
2924 list = null;
2925
2926 break;
2927 }
2928 }
2929 }
2930
2931 if (list == null) {
2932 StringBundler query = null;
2933
2934 if (orderByComparator != null) {
2935 query = new StringBundler(3 +
2936 (orderByComparator.getOrderByFields().length * 3));
2937 }
2938 else {
2939 query = new StringBundler(3);
2940 }
2941
2942 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
2943
2944 query.append(_FINDER_COLUMN_VOCABULARYID_VOCABULARYID_2);
2945
2946 if (orderByComparator != null) {
2947 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2948 orderByComparator);
2949 }
2950 else
2951 if (pagination) {
2952 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
2953 }
2954
2955 String sql = query.toString();
2956
2957 Session session = null;
2958
2959 try {
2960 session = openSession();
2961
2962 Query q = session.createQuery(sql);
2963
2964 QueryPos qPos = QueryPos.getInstance(q);
2965
2966 qPos.add(vocabularyId);
2967
2968 if (!pagination) {
2969 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
2970 start, end, false);
2971
2972 Collections.sort(list);
2973
2974 list = new UnmodifiableList<AssetCategory>(list);
2975 }
2976 else {
2977 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
2978 start, end);
2979 }
2980
2981 cacheResult(list);
2982
2983 FinderCacheUtil.putResult(finderPath, finderArgs, list);
2984 }
2985 catch (Exception e) {
2986 FinderCacheUtil.removeResult(finderPath, finderArgs);
2987
2988 throw processException(e);
2989 }
2990 finally {
2991 closeSession(session);
2992 }
2993 }
2994
2995 return list;
2996 }
2997
2998
3007 @Override
3008 public AssetCategory findByVocabularyId_First(long vocabularyId,
3009 OrderByComparator orderByComparator)
3010 throws NoSuchCategoryException, SystemException {
3011 AssetCategory assetCategory = fetchByVocabularyId_First(vocabularyId,
3012 orderByComparator);
3013
3014 if (assetCategory != null) {
3015 return assetCategory;
3016 }
3017
3018 StringBundler msg = new StringBundler(4);
3019
3020 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3021
3022 msg.append("vocabularyId=");
3023 msg.append(vocabularyId);
3024
3025 msg.append(StringPool.CLOSE_CURLY_BRACE);
3026
3027 throw new NoSuchCategoryException(msg.toString());
3028 }
3029
3030
3038 @Override
3039 public AssetCategory fetchByVocabularyId_First(long vocabularyId,
3040 OrderByComparator orderByComparator) throws SystemException {
3041 List<AssetCategory> list = findByVocabularyId(vocabularyId, 0, 1,
3042 orderByComparator);
3043
3044 if (!list.isEmpty()) {
3045 return list.get(0);
3046 }
3047
3048 return null;
3049 }
3050
3051
3060 @Override
3061 public AssetCategory findByVocabularyId_Last(long vocabularyId,
3062 OrderByComparator orderByComparator)
3063 throws NoSuchCategoryException, SystemException {
3064 AssetCategory assetCategory = fetchByVocabularyId_Last(vocabularyId,
3065 orderByComparator);
3066
3067 if (assetCategory != null) {
3068 return assetCategory;
3069 }
3070
3071 StringBundler msg = new StringBundler(4);
3072
3073 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3074
3075 msg.append("vocabularyId=");
3076 msg.append(vocabularyId);
3077
3078 msg.append(StringPool.CLOSE_CURLY_BRACE);
3079
3080 throw new NoSuchCategoryException(msg.toString());
3081 }
3082
3083
3091 @Override
3092 public AssetCategory fetchByVocabularyId_Last(long vocabularyId,
3093 OrderByComparator orderByComparator) throws SystemException {
3094 int count = countByVocabularyId(vocabularyId);
3095
3096 if (count == 0) {
3097 return null;
3098 }
3099
3100 List<AssetCategory> list = findByVocabularyId(vocabularyId, count - 1,
3101 count, orderByComparator);
3102
3103 if (!list.isEmpty()) {
3104 return list.get(0);
3105 }
3106
3107 return null;
3108 }
3109
3110
3120 @Override
3121 public AssetCategory[] findByVocabularyId_PrevAndNext(long categoryId,
3122 long vocabularyId, OrderByComparator orderByComparator)
3123 throws NoSuchCategoryException, SystemException {
3124 AssetCategory assetCategory = findByPrimaryKey(categoryId);
3125
3126 Session session = null;
3127
3128 try {
3129 session = openSession();
3130
3131 AssetCategory[] array = new AssetCategoryImpl[3];
3132
3133 array[0] = getByVocabularyId_PrevAndNext(session, assetCategory,
3134 vocabularyId, orderByComparator, true);
3135
3136 array[1] = assetCategory;
3137
3138 array[2] = getByVocabularyId_PrevAndNext(session, assetCategory,
3139 vocabularyId, orderByComparator, false);
3140
3141 return array;
3142 }
3143 catch (Exception e) {
3144 throw processException(e);
3145 }
3146 finally {
3147 closeSession(session);
3148 }
3149 }
3150
3151 protected AssetCategory getByVocabularyId_PrevAndNext(Session session,
3152 AssetCategory assetCategory, long vocabularyId,
3153 OrderByComparator orderByComparator, boolean previous) {
3154 StringBundler query = null;
3155
3156 if (orderByComparator != null) {
3157 query = new StringBundler(6 +
3158 (orderByComparator.getOrderByFields().length * 6));
3159 }
3160 else {
3161 query = new StringBundler(3);
3162 }
3163
3164 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
3165
3166 query.append(_FINDER_COLUMN_VOCABULARYID_VOCABULARYID_2);
3167
3168 if (orderByComparator != null) {
3169 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3170
3171 if (orderByConditionFields.length > 0) {
3172 query.append(WHERE_AND);
3173 }
3174
3175 for (int i = 0; i < orderByConditionFields.length; i++) {
3176 query.append(_ORDER_BY_ENTITY_ALIAS);
3177 query.append(orderByConditionFields[i]);
3178
3179 if ((i + 1) < orderByConditionFields.length) {
3180 if (orderByComparator.isAscending() ^ previous) {
3181 query.append(WHERE_GREATER_THAN_HAS_NEXT);
3182 }
3183 else {
3184 query.append(WHERE_LESSER_THAN_HAS_NEXT);
3185 }
3186 }
3187 else {
3188 if (orderByComparator.isAscending() ^ previous) {
3189 query.append(WHERE_GREATER_THAN);
3190 }
3191 else {
3192 query.append(WHERE_LESSER_THAN);
3193 }
3194 }
3195 }
3196
3197 query.append(ORDER_BY_CLAUSE);
3198
3199 String[] orderByFields = orderByComparator.getOrderByFields();
3200
3201 for (int i = 0; i < orderByFields.length; i++) {
3202 query.append(_ORDER_BY_ENTITY_ALIAS);
3203 query.append(orderByFields[i]);
3204
3205 if ((i + 1) < orderByFields.length) {
3206 if (orderByComparator.isAscending() ^ previous) {
3207 query.append(ORDER_BY_ASC_HAS_NEXT);
3208 }
3209 else {
3210 query.append(ORDER_BY_DESC_HAS_NEXT);
3211 }
3212 }
3213 else {
3214 if (orderByComparator.isAscending() ^ previous) {
3215 query.append(ORDER_BY_ASC);
3216 }
3217 else {
3218 query.append(ORDER_BY_DESC);
3219 }
3220 }
3221 }
3222 }
3223 else {
3224 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
3225 }
3226
3227 String sql = query.toString();
3228
3229 Query q = session.createQuery(sql);
3230
3231 q.setFirstResult(0);
3232 q.setMaxResults(2);
3233
3234 QueryPos qPos = QueryPos.getInstance(q);
3235
3236 qPos.add(vocabularyId);
3237
3238 if (orderByComparator != null) {
3239 Object[] values = orderByComparator.getOrderByConditionValues(assetCategory);
3240
3241 for (Object value : values) {
3242 qPos.add(value);
3243 }
3244 }
3245
3246 List<AssetCategory> list = q.list();
3247
3248 if (list.size() == 2) {
3249 return list.get(1);
3250 }
3251 else {
3252 return null;
3253 }
3254 }
3255
3256
3262 @Override
3263 public void removeByVocabularyId(long vocabularyId)
3264 throws SystemException {
3265 for (AssetCategory assetCategory : findByVocabularyId(vocabularyId,
3266 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
3267 remove(assetCategory);
3268 }
3269 }
3270
3271
3278 @Override
3279 public int countByVocabularyId(long vocabularyId) throws SystemException {
3280 FinderPath finderPath = FINDER_PATH_COUNT_BY_VOCABULARYID;
3281
3282 Object[] finderArgs = new Object[] { vocabularyId };
3283
3284 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
3285 this);
3286
3287 if (count == null) {
3288 StringBundler query = new StringBundler(2);
3289
3290 query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
3291
3292 query.append(_FINDER_COLUMN_VOCABULARYID_VOCABULARYID_2);
3293
3294 String sql = query.toString();
3295
3296 Session session = null;
3297
3298 try {
3299 session = openSession();
3300
3301 Query q = session.createQuery(sql);
3302
3303 QueryPos qPos = QueryPos.getInstance(q);
3304
3305 qPos.add(vocabularyId);
3306
3307 count = (Long)q.uniqueResult();
3308
3309 FinderCacheUtil.putResult(finderPath, finderArgs, count);
3310 }
3311 catch (Exception e) {
3312 FinderCacheUtil.removeResult(finderPath, finderArgs);
3313
3314 throw processException(e);
3315 }
3316 finally {
3317 closeSession(session);
3318 }
3319 }
3320
3321 return count.intValue();
3322 }
3323
3324 private static final String _FINDER_COLUMN_VOCABULARYID_VOCABULARYID_2 = "assetCategory.vocabularyId = ?";
3325 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
3326 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
3327 AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
3328 "findByG_V",
3329 new String[] {
3330 Long.class.getName(), Long.class.getName(),
3331
3332 Integer.class.getName(), Integer.class.getName(),
3333 OrderByComparator.class.getName()
3334 });
3335 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
3336 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
3337 AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
3338 "findByG_V",
3339 new String[] { Long.class.getName(), Long.class.getName() },
3340 AssetCategoryModelImpl.GROUPID_COLUMN_BITMASK |
3341 AssetCategoryModelImpl.VOCABULARYID_COLUMN_BITMASK |
3342 AssetCategoryModelImpl.NAME_COLUMN_BITMASK);
3343 public static final FinderPath FINDER_PATH_COUNT_BY_G_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
3344 AssetCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class,
3345 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_V",
3346 new String[] { Long.class.getName(), Long.class.getName() });
3347 public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
3348 AssetCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class,
3349 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_V",
3350 new String[] { Long.class.getName(), Long.class.getName() });
3351
3352
3360 @Override
3361 public List<AssetCategory> findByG_V(long groupId, long vocabularyId)
3362 throws SystemException {
3363 return findByG_V(groupId, vocabularyId, QueryUtil.ALL_POS,
3364 QueryUtil.ALL_POS, null);
3365 }
3366
3367
3381 @Override
3382 public List<AssetCategory> findByG_V(long groupId, long vocabularyId,
3383 int start, int end) throws SystemException {
3384 return findByG_V(groupId, vocabularyId, start, end, null);
3385 }
3386
3387
3402 @Override
3403 public List<AssetCategory> findByG_V(long groupId, long vocabularyId,
3404 int start, int end, OrderByComparator orderByComparator)
3405 throws SystemException {
3406 boolean pagination = true;
3407 FinderPath finderPath = null;
3408 Object[] finderArgs = null;
3409
3410 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
3411 (orderByComparator == null)) {
3412 pagination = false;
3413 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_V;
3414 finderArgs = new Object[] { groupId, vocabularyId };
3415 }
3416 else {
3417 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_V;
3418 finderArgs = new Object[] {
3419 groupId, vocabularyId,
3420
3421 start, end, orderByComparator
3422 };
3423 }
3424
3425 List<AssetCategory> list = (List<AssetCategory>)FinderCacheUtil.getResult(finderPath,
3426 finderArgs, this);
3427
3428 if ((list != null) && !list.isEmpty()) {
3429 for (AssetCategory assetCategory : list) {
3430 if ((groupId != assetCategory.getGroupId()) ||
3431 (vocabularyId != assetCategory.getVocabularyId())) {
3432 list = null;
3433
3434 break;
3435 }
3436 }
3437 }
3438
3439 if (list == null) {
3440 StringBundler query = null;
3441
3442 if (orderByComparator != null) {
3443 query = new StringBundler(4 +
3444 (orderByComparator.getOrderByFields().length * 3));
3445 }
3446 else {
3447 query = new StringBundler(4);
3448 }
3449
3450 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
3451
3452 query.append(_FINDER_COLUMN_G_V_GROUPID_2);
3453
3454 query.append(_FINDER_COLUMN_G_V_VOCABULARYID_2);
3455
3456 if (orderByComparator != null) {
3457 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3458 orderByComparator);
3459 }
3460 else
3461 if (pagination) {
3462 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
3463 }
3464
3465 String sql = query.toString();
3466
3467 Session session = null;
3468
3469 try {
3470 session = openSession();
3471
3472 Query q = session.createQuery(sql);
3473
3474 QueryPos qPos = QueryPos.getInstance(q);
3475
3476 qPos.add(groupId);
3477
3478 qPos.add(vocabularyId);
3479
3480 if (!pagination) {
3481 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
3482 start, end, false);
3483
3484 Collections.sort(list);
3485
3486 list = new UnmodifiableList<AssetCategory>(list);
3487 }
3488 else {
3489 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
3490 start, end);
3491 }
3492
3493 cacheResult(list);
3494
3495 FinderCacheUtil.putResult(finderPath, finderArgs, list);
3496 }
3497 catch (Exception e) {
3498 FinderCacheUtil.removeResult(finderPath, finderArgs);
3499
3500 throw processException(e);
3501 }
3502 finally {
3503 closeSession(session);
3504 }
3505 }
3506
3507 return list;
3508 }
3509
3510
3520 @Override
3521 public AssetCategory findByG_V_First(long groupId, long vocabularyId,
3522 OrderByComparator orderByComparator)
3523 throws NoSuchCategoryException, SystemException {
3524 AssetCategory assetCategory = fetchByG_V_First(groupId, vocabularyId,
3525 orderByComparator);
3526
3527 if (assetCategory != null) {
3528 return assetCategory;
3529 }
3530
3531 StringBundler msg = new StringBundler(6);
3532
3533 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3534
3535 msg.append("groupId=");
3536 msg.append(groupId);
3537
3538 msg.append(", vocabularyId=");
3539 msg.append(vocabularyId);
3540
3541 msg.append(StringPool.CLOSE_CURLY_BRACE);
3542
3543 throw new NoSuchCategoryException(msg.toString());
3544 }
3545
3546
3555 @Override
3556 public AssetCategory fetchByG_V_First(long groupId, long vocabularyId,
3557 OrderByComparator orderByComparator) throws SystemException {
3558 List<AssetCategory> list = findByG_V(groupId, vocabularyId, 0, 1,
3559 orderByComparator);
3560
3561 if (!list.isEmpty()) {
3562 return list.get(0);
3563 }
3564
3565 return null;
3566 }
3567
3568
3578 @Override
3579 public AssetCategory findByG_V_Last(long groupId, long vocabularyId,
3580 OrderByComparator orderByComparator)
3581 throws NoSuchCategoryException, SystemException {
3582 AssetCategory assetCategory = fetchByG_V_Last(groupId, vocabularyId,
3583 orderByComparator);
3584
3585 if (assetCategory != null) {
3586 return assetCategory;
3587 }
3588
3589 StringBundler msg = new StringBundler(6);
3590
3591 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3592
3593 msg.append("groupId=");
3594 msg.append(groupId);
3595
3596 msg.append(", vocabularyId=");
3597 msg.append(vocabularyId);
3598
3599 msg.append(StringPool.CLOSE_CURLY_BRACE);
3600
3601 throw new NoSuchCategoryException(msg.toString());
3602 }
3603
3604
3613 @Override
3614 public AssetCategory fetchByG_V_Last(long groupId, long vocabularyId,
3615 OrderByComparator orderByComparator) throws SystemException {
3616 int count = countByG_V(groupId, vocabularyId);
3617
3618 if (count == 0) {
3619 return null;
3620 }
3621
3622 List<AssetCategory> list = findByG_V(groupId, vocabularyId, count - 1,
3623 count, orderByComparator);
3624
3625 if (!list.isEmpty()) {
3626 return list.get(0);
3627 }
3628
3629 return null;
3630 }
3631
3632
3643 @Override
3644 public AssetCategory[] findByG_V_PrevAndNext(long categoryId, long groupId,
3645 long vocabularyId, OrderByComparator orderByComparator)
3646 throws NoSuchCategoryException, SystemException {
3647 AssetCategory assetCategory = findByPrimaryKey(categoryId);
3648
3649 Session session = null;
3650
3651 try {
3652 session = openSession();
3653
3654 AssetCategory[] array = new AssetCategoryImpl[3];
3655
3656 array[0] = getByG_V_PrevAndNext(session, assetCategory, groupId,
3657 vocabularyId, orderByComparator, true);
3658
3659 array[1] = assetCategory;
3660
3661 array[2] = getByG_V_PrevAndNext(session, assetCategory, groupId,
3662 vocabularyId, orderByComparator, false);
3663
3664 return array;
3665 }
3666 catch (Exception e) {
3667 throw processException(e);
3668 }
3669 finally {
3670 closeSession(session);
3671 }
3672 }
3673
3674 protected AssetCategory getByG_V_PrevAndNext(Session session,
3675 AssetCategory assetCategory, long groupId, long vocabularyId,
3676 OrderByComparator orderByComparator, boolean previous) {
3677 StringBundler query = null;
3678
3679 if (orderByComparator != null) {
3680 query = new StringBundler(6 +
3681 (orderByComparator.getOrderByFields().length * 6));
3682 }
3683 else {
3684 query = new StringBundler(3);
3685 }
3686
3687 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
3688
3689 query.append(_FINDER_COLUMN_G_V_GROUPID_2);
3690
3691 query.append(_FINDER_COLUMN_G_V_VOCABULARYID_2);
3692
3693 if (orderByComparator != null) {
3694 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3695
3696 if (orderByConditionFields.length > 0) {
3697 query.append(WHERE_AND);
3698 }
3699
3700 for (int i = 0; i < orderByConditionFields.length; i++) {
3701 query.append(_ORDER_BY_ENTITY_ALIAS);
3702 query.append(orderByConditionFields[i]);
3703
3704 if ((i + 1) < orderByConditionFields.length) {
3705 if (orderByComparator.isAscending() ^ previous) {
3706 query.append(WHERE_GREATER_THAN_HAS_NEXT);
3707 }
3708 else {
3709 query.append(WHERE_LESSER_THAN_HAS_NEXT);
3710 }
3711 }
3712 else {
3713 if (orderByComparator.isAscending() ^ previous) {
3714 query.append(WHERE_GREATER_THAN);
3715 }
3716 else {
3717 query.append(WHERE_LESSER_THAN);
3718 }
3719 }
3720 }
3721
3722 query.append(ORDER_BY_CLAUSE);
3723
3724 String[] orderByFields = orderByComparator.getOrderByFields();
3725
3726 for (int i = 0; i < orderByFields.length; i++) {
3727 query.append(_ORDER_BY_ENTITY_ALIAS);
3728 query.append(orderByFields[i]);
3729
3730 if ((i + 1) < orderByFields.length) {
3731 if (orderByComparator.isAscending() ^ previous) {
3732 query.append(ORDER_BY_ASC_HAS_NEXT);
3733 }
3734 else {
3735 query.append(ORDER_BY_DESC_HAS_NEXT);
3736 }
3737 }
3738 else {
3739 if (orderByComparator.isAscending() ^ previous) {
3740 query.append(ORDER_BY_ASC);
3741 }
3742 else {
3743 query.append(ORDER_BY_DESC);
3744 }
3745 }
3746 }
3747 }
3748 else {
3749 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
3750 }
3751
3752 String sql = query.toString();
3753
3754 Query q = session.createQuery(sql);
3755
3756 q.setFirstResult(0);
3757 q.setMaxResults(2);
3758
3759 QueryPos qPos = QueryPos.getInstance(q);
3760
3761 qPos.add(groupId);
3762
3763 qPos.add(vocabularyId);
3764
3765 if (orderByComparator != null) {
3766 Object[] values = orderByComparator.getOrderByConditionValues(assetCategory);
3767
3768 for (Object value : values) {
3769 qPos.add(value);
3770 }
3771 }
3772
3773 List<AssetCategory> list = q.list();
3774
3775 if (list.size() == 2) {
3776 return list.get(1);
3777 }
3778 else {
3779 return null;
3780 }
3781 }
3782
3783
3791 @Override
3792 public List<AssetCategory> filterFindByG_V(long groupId, long vocabularyId)
3793 throws SystemException {
3794 return filterFindByG_V(groupId, vocabularyId, QueryUtil.ALL_POS,
3795 QueryUtil.ALL_POS, null);
3796 }
3797
3798
3812 @Override
3813 public List<AssetCategory> filterFindByG_V(long groupId, long vocabularyId,
3814 int start, int end) throws SystemException {
3815 return filterFindByG_V(groupId, vocabularyId, start, end, null);
3816 }
3817
3818
3833 @Override
3834 public List<AssetCategory> filterFindByG_V(long groupId, long vocabularyId,
3835 int start, int end, OrderByComparator orderByComparator)
3836 throws SystemException {
3837 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
3838 return findByG_V(groupId, vocabularyId, start, end,
3839 orderByComparator);
3840 }
3841
3842 StringBundler query = null;
3843
3844 if (orderByComparator != null) {
3845 query = new StringBundler(4 +
3846 (orderByComparator.getOrderByFields().length * 3));
3847 }
3848 else {
3849 query = new StringBundler(4);
3850 }
3851
3852 if (getDB().isSupportsInlineDistinct()) {
3853 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_WHERE);
3854 }
3855 else {
3856 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_1);
3857 }
3858
3859 query.append(_FINDER_COLUMN_G_V_GROUPID_2);
3860
3861 query.append(_FINDER_COLUMN_G_V_VOCABULARYID_2);
3862
3863 if (!getDB().isSupportsInlineDistinct()) {
3864 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_2);
3865 }
3866
3867 if (orderByComparator != null) {
3868 if (getDB().isSupportsInlineDistinct()) {
3869 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3870 orderByComparator, true);
3871 }
3872 else {
3873 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
3874 orderByComparator, true);
3875 }
3876 }
3877 else {
3878 if (getDB().isSupportsInlineDistinct()) {
3879 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
3880 }
3881 else {
3882 query.append(AssetCategoryModelImpl.ORDER_BY_SQL);
3883 }
3884 }
3885
3886 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
3887 AssetCategory.class.getName(),
3888 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
3889
3890 Session session = null;
3891
3892 try {
3893 session = openSession();
3894
3895 SQLQuery q = session.createSQLQuery(sql);
3896
3897 if (getDB().isSupportsInlineDistinct()) {
3898 q.addEntity(_FILTER_ENTITY_ALIAS, AssetCategoryImpl.class);
3899 }
3900 else {
3901 q.addEntity(_FILTER_ENTITY_TABLE, AssetCategoryImpl.class);
3902 }
3903
3904 QueryPos qPos = QueryPos.getInstance(q);
3905
3906 qPos.add(groupId);
3907
3908 qPos.add(vocabularyId);
3909
3910 return (List<AssetCategory>)QueryUtil.list(q, getDialect(), start,
3911 end);
3912 }
3913 catch (Exception e) {
3914 throw processException(e);
3915 }
3916 finally {
3917 closeSession(session);
3918 }
3919 }
3920
3921
3932 @Override
3933 public AssetCategory[] filterFindByG_V_PrevAndNext(long categoryId,
3934 long groupId, long vocabularyId, OrderByComparator orderByComparator)
3935 throws NoSuchCategoryException, SystemException {
3936 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
3937 return findByG_V_PrevAndNext(categoryId, groupId, vocabularyId,
3938 orderByComparator);
3939 }
3940
3941 AssetCategory assetCategory = findByPrimaryKey(categoryId);
3942
3943 Session session = null;
3944
3945 try {
3946 session = openSession();
3947
3948 AssetCategory[] array = new AssetCategoryImpl[3];
3949
3950 array[0] = filterGetByG_V_PrevAndNext(session, assetCategory,
3951 groupId, vocabularyId, orderByComparator, true);
3952
3953 array[1] = assetCategory;
3954
3955 array[2] = filterGetByG_V_PrevAndNext(session, assetCategory,
3956 groupId, vocabularyId, orderByComparator, false);
3957
3958 return array;
3959 }
3960 catch (Exception e) {
3961 throw processException(e);
3962 }
3963 finally {
3964 closeSession(session);
3965 }
3966 }
3967
3968 protected AssetCategory filterGetByG_V_PrevAndNext(Session session,
3969 AssetCategory assetCategory, long groupId, long vocabularyId,
3970 OrderByComparator orderByComparator, boolean previous) {
3971 StringBundler query = null;
3972
3973 if (orderByComparator != null) {
3974 query = new StringBundler(6 +
3975 (orderByComparator.getOrderByFields().length * 6));
3976 }
3977 else {
3978 query = new StringBundler(3);
3979 }
3980
3981 if (getDB().isSupportsInlineDistinct()) {
3982 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_WHERE);
3983 }
3984 else {
3985 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_1);
3986 }
3987
3988 query.append(_FINDER_COLUMN_G_V_GROUPID_2);
3989
3990 query.append(_FINDER_COLUMN_G_V_VOCABULARYID_2);
3991
3992 if (!getDB().isSupportsInlineDistinct()) {
3993 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_2);
3994 }
3995
3996 if (orderByComparator != null) {
3997 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3998
3999 if (orderByConditionFields.length > 0) {
4000 query.append(WHERE_AND);
4001 }
4002
4003 for (int i = 0; i < orderByConditionFields.length; i++) {
4004 if (getDB().isSupportsInlineDistinct()) {
4005 query.append(_ORDER_BY_ENTITY_ALIAS);
4006 }
4007 else {
4008 query.append(_ORDER_BY_ENTITY_TABLE);
4009 }
4010
4011 query.append(orderByConditionFields[i]);
4012
4013 if ((i + 1) < orderByConditionFields.length) {
4014 if (orderByComparator.isAscending() ^ previous) {
4015 query.append(WHERE_GREATER_THAN_HAS_NEXT);
4016 }
4017 else {
4018 query.append(WHERE_LESSER_THAN_HAS_NEXT);
4019 }
4020 }
4021 else {
4022 if (orderByComparator.isAscending() ^ previous) {
4023 query.append(WHERE_GREATER_THAN);
4024 }
4025 else {
4026 query.append(WHERE_LESSER_THAN);
4027 }
4028 }
4029 }
4030
4031 query.append(ORDER_BY_CLAUSE);
4032
4033 String[] orderByFields = orderByComparator.getOrderByFields();
4034
4035 for (int i = 0; i < orderByFields.length; i++) {
4036 if (getDB().isSupportsInlineDistinct()) {
4037 query.append(_ORDER_BY_ENTITY_ALIAS);
4038 }
4039 else {
4040 query.append(_ORDER_BY_ENTITY_TABLE);
4041 }
4042
4043 query.append(orderByFields[i]);
4044
4045 if ((i + 1) < orderByFields.length) {
4046 if (orderByComparator.isAscending() ^ previous) {
4047 query.append(ORDER_BY_ASC_HAS_NEXT);
4048 }
4049 else {
4050 query.append(ORDER_BY_DESC_HAS_NEXT);
4051 }
4052 }
4053 else {
4054 if (orderByComparator.isAscending() ^ previous) {
4055 query.append(ORDER_BY_ASC);
4056 }
4057 else {
4058 query.append(ORDER_BY_DESC);
4059 }
4060 }
4061 }
4062 }
4063 else {
4064 if (getDB().isSupportsInlineDistinct()) {
4065 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
4066 }
4067 else {
4068 query.append(AssetCategoryModelImpl.ORDER_BY_SQL);
4069 }
4070 }
4071
4072 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
4073 AssetCategory.class.getName(),
4074 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
4075
4076 SQLQuery q = session.createSQLQuery(sql);
4077
4078 q.setFirstResult(0);
4079 q.setMaxResults(2);
4080
4081 if (getDB().isSupportsInlineDistinct()) {
4082 q.addEntity(_FILTER_ENTITY_ALIAS, AssetCategoryImpl.class);
4083 }
4084 else {
4085 q.addEntity(_FILTER_ENTITY_TABLE, AssetCategoryImpl.class);
4086 }
4087
4088 QueryPos qPos = QueryPos.getInstance(q);
4089
4090 qPos.add(groupId);
4091
4092 qPos.add(vocabularyId);
4093
4094 if (orderByComparator != null) {
4095 Object[] values = orderByComparator.getOrderByConditionValues(assetCategory);
4096
4097 for (Object value : values) {
4098 qPos.add(value);
4099 }
4100 }
4101
4102 List<AssetCategory> list = q.list();
4103
4104 if (list.size() == 2) {
4105 return list.get(1);
4106 }
4107 else {
4108 return null;
4109 }
4110 }
4111
4112
4120 @Override
4121 public List<AssetCategory> filterFindByG_V(long groupId,
4122 long[] vocabularyIds) throws SystemException {
4123 return filterFindByG_V(groupId, vocabularyIds, QueryUtil.ALL_POS,
4124 QueryUtil.ALL_POS, null);
4125 }
4126
4127
4141 @Override
4142 public List<AssetCategory> filterFindByG_V(long groupId,
4143 long[] vocabularyIds, int start, int end) throws SystemException {
4144 return filterFindByG_V(groupId, vocabularyIds, start, end, null);
4145 }
4146
4147
4162 @Override
4163 public List<AssetCategory> filterFindByG_V(long groupId,
4164 long[] vocabularyIds, int start, int end,
4165 OrderByComparator orderByComparator) throws SystemException {
4166 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
4167 return findByG_V(groupId, vocabularyIds, start, end,
4168 orderByComparator);
4169 }
4170
4171 StringBundler query = new StringBundler();
4172
4173 if (getDB().isSupportsInlineDistinct()) {
4174 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_WHERE);
4175 }
4176 else {
4177 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_1);
4178 }
4179
4180 boolean conjunctionable = false;
4181
4182 if (conjunctionable) {
4183 query.append(WHERE_AND);
4184 }
4185
4186 query.append(_FINDER_COLUMN_G_V_GROUPID_5);
4187
4188 conjunctionable = true;
4189
4190 if ((vocabularyIds == null) || (vocabularyIds.length > 0)) {
4191 if (conjunctionable) {
4192 query.append(WHERE_AND);
4193 }
4194
4195 query.append(StringPool.OPEN_PARENTHESIS);
4196
4197 for (int i = 0; i < vocabularyIds.length; i++) {
4198 query.append(_FINDER_COLUMN_G_V_VOCABULARYID_5);
4199
4200 if ((i + 1) < vocabularyIds.length) {
4201 query.append(WHERE_OR);
4202 }
4203 }
4204
4205 query.append(StringPool.CLOSE_PARENTHESIS);
4206
4207 conjunctionable = true;
4208 }
4209
4210 if (!getDB().isSupportsInlineDistinct()) {
4211 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_2);
4212 }
4213
4214 if (orderByComparator != null) {
4215 if (getDB().isSupportsInlineDistinct()) {
4216 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4217 orderByComparator, true);
4218 }
4219 else {
4220 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
4221 orderByComparator, true);
4222 }
4223 }
4224 else {
4225 if (getDB().isSupportsInlineDistinct()) {
4226 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
4227 }
4228 else {
4229 query.append(AssetCategoryModelImpl.ORDER_BY_SQL);
4230 }
4231 }
4232
4233 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
4234 AssetCategory.class.getName(),
4235 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
4236
4237 Session session = null;
4238
4239 try {
4240 session = openSession();
4241
4242 SQLQuery q = session.createSQLQuery(sql);
4243
4244 if (getDB().isSupportsInlineDistinct()) {
4245 q.addEntity(_FILTER_ENTITY_ALIAS, AssetCategoryImpl.class);
4246 }
4247 else {
4248 q.addEntity(_FILTER_ENTITY_TABLE, AssetCategoryImpl.class);
4249 }
4250
4251 QueryPos qPos = QueryPos.getInstance(q);
4252
4253 qPos.add(groupId);
4254
4255 if (vocabularyIds != null) {
4256 qPos.add(vocabularyIds);
4257 }
4258
4259 return (List<AssetCategory>)QueryUtil.list(q, getDialect(), start,
4260 end);
4261 }
4262 catch (Exception e) {
4263 throw processException(e);
4264 }
4265 finally {
4266 closeSession(session);
4267 }
4268 }
4269
4270
4282 @Override
4283 public List<AssetCategory> findByG_V(long groupId, long[] vocabularyIds)
4284 throws SystemException {
4285 return findByG_V(groupId, vocabularyIds, QueryUtil.ALL_POS,
4286 QueryUtil.ALL_POS, null);
4287 }
4288
4289
4303 @Override
4304 public List<AssetCategory> findByG_V(long groupId, long[] vocabularyIds,
4305 int start, int end) throws SystemException {
4306 return findByG_V(groupId, vocabularyIds, start, end, null);
4307 }
4308
4309
4324 @Override
4325 public List<AssetCategory> findByG_V(long groupId, long[] vocabularyIds,
4326 int start, int end, OrderByComparator orderByComparator)
4327 throws SystemException {
4328 if ((vocabularyIds != null) && (vocabularyIds.length == 1)) {
4329 return findByG_V(groupId, vocabularyIds[0], start, end,
4330 orderByComparator);
4331 }
4332
4333 boolean pagination = true;
4334 Object[] finderArgs = null;
4335
4336 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
4337 (orderByComparator == null)) {
4338 pagination = false;
4339 finderArgs = new Object[] { groupId, StringUtil.merge(vocabularyIds) };
4340 }
4341 else {
4342 finderArgs = new Object[] {
4343 groupId, StringUtil.merge(vocabularyIds),
4344
4345 start, end, orderByComparator
4346 };
4347 }
4348
4349 List<AssetCategory> list = (List<AssetCategory>)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_V,
4350 finderArgs, this);
4351
4352 if ((list != null) && !list.isEmpty()) {
4353 for (AssetCategory assetCategory : list) {
4354 if ((groupId != assetCategory.getGroupId()) ||
4355 !ArrayUtil.contains(vocabularyIds,
4356 assetCategory.getVocabularyId())) {
4357 list = null;
4358
4359 break;
4360 }
4361 }
4362 }
4363
4364 if (list == null) {
4365 StringBundler query = new StringBundler();
4366
4367 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
4368
4369 boolean conjunctionable = false;
4370
4371 if (conjunctionable) {
4372 query.append(WHERE_AND);
4373 }
4374
4375 query.append(_FINDER_COLUMN_G_V_GROUPID_5);
4376
4377 conjunctionable = true;
4378
4379 if ((vocabularyIds == null) || (vocabularyIds.length > 0)) {
4380 if (conjunctionable) {
4381 query.append(WHERE_AND);
4382 }
4383
4384 query.append(StringPool.OPEN_PARENTHESIS);
4385
4386 for (int i = 0; i < vocabularyIds.length; i++) {
4387 query.append(_FINDER_COLUMN_G_V_VOCABULARYID_5);
4388
4389 if ((i + 1) < vocabularyIds.length) {
4390 query.append(WHERE_OR);
4391 }
4392 }
4393
4394 query.append(StringPool.CLOSE_PARENTHESIS);
4395
4396 conjunctionable = true;
4397 }
4398
4399 if (orderByComparator != null) {
4400 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4401 orderByComparator);
4402 }
4403 else
4404 if (pagination) {
4405 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
4406 }
4407
4408 String sql = query.toString();
4409
4410 Session session = null;
4411
4412 try {
4413 session = openSession();
4414
4415 Query q = session.createQuery(sql);
4416
4417 QueryPos qPos = QueryPos.getInstance(q);
4418
4419 qPos.add(groupId);
4420
4421 if (vocabularyIds != null) {
4422 qPos.add(vocabularyIds);
4423 }
4424
4425 if (!pagination) {
4426 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
4427 start, end, false);
4428
4429 Collections.sort(list);
4430
4431 list = new UnmodifiableList<AssetCategory>(list);
4432 }
4433 else {
4434 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
4435 start, end);
4436 }
4437
4438 cacheResult(list);
4439
4440 FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_V,
4441 finderArgs, list);
4442 }
4443 catch (Exception e) {
4444 FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_V,
4445 finderArgs);
4446
4447 throw processException(e);
4448 }
4449 finally {
4450 closeSession(session);
4451 }
4452 }
4453
4454 return list;
4455 }
4456
4457
4464 @Override
4465 public void removeByG_V(long groupId, long vocabularyId)
4466 throws SystemException {
4467 for (AssetCategory assetCategory : findByG_V(groupId, vocabularyId,
4468 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
4469 remove(assetCategory);
4470 }
4471 }
4472
4473
4481 @Override
4482 public int countByG_V(long groupId, long vocabularyId)
4483 throws SystemException {
4484 FinderPath finderPath = FINDER_PATH_COUNT_BY_G_V;
4485
4486 Object[] finderArgs = new Object[] { groupId, vocabularyId };
4487
4488 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
4489 this);
4490
4491 if (count == null) {
4492 StringBundler query = new StringBundler(3);
4493
4494 query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
4495
4496 query.append(_FINDER_COLUMN_G_V_GROUPID_2);
4497
4498 query.append(_FINDER_COLUMN_G_V_VOCABULARYID_2);
4499
4500 String sql = query.toString();
4501
4502 Session session = null;
4503
4504 try {
4505 session = openSession();
4506
4507 Query q = session.createQuery(sql);
4508
4509 QueryPos qPos = QueryPos.getInstance(q);
4510
4511 qPos.add(groupId);
4512
4513 qPos.add(vocabularyId);
4514
4515 count = (Long)q.uniqueResult();
4516
4517 FinderCacheUtil.putResult(finderPath, finderArgs, count);
4518 }
4519 catch (Exception e) {
4520 FinderCacheUtil.removeResult(finderPath, finderArgs);
4521
4522 throw processException(e);
4523 }
4524 finally {
4525 closeSession(session);
4526 }
4527 }
4528
4529 return count.intValue();
4530 }
4531
4532
4540 @Override
4541 public int countByG_V(long groupId, long[] vocabularyIds)
4542 throws SystemException {
4543 Object[] finderArgs = new Object[] {
4544 groupId, StringUtil.merge(vocabularyIds)
4545 };
4546
4547 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_V,
4548 finderArgs, this);
4549
4550 if (count == null) {
4551 StringBundler query = new StringBundler();
4552
4553 query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
4554
4555 boolean conjunctionable = false;
4556
4557 if (conjunctionable) {
4558 query.append(WHERE_AND);
4559 }
4560
4561 query.append(_FINDER_COLUMN_G_V_GROUPID_5);
4562
4563 conjunctionable = true;
4564
4565 if ((vocabularyIds == null) || (vocabularyIds.length > 0)) {
4566 if (conjunctionable) {
4567 query.append(WHERE_AND);
4568 }
4569
4570 query.append(StringPool.OPEN_PARENTHESIS);
4571
4572 for (int i = 0; i < vocabularyIds.length; i++) {
4573 query.append(_FINDER_COLUMN_G_V_VOCABULARYID_5);
4574
4575 if ((i + 1) < vocabularyIds.length) {
4576 query.append(WHERE_OR);
4577 }
4578 }
4579
4580 query.append(StringPool.CLOSE_PARENTHESIS);
4581
4582 conjunctionable = true;
4583 }
4584
4585 String sql = query.toString();
4586
4587 Session session = null;
4588
4589 try {
4590 session = openSession();
4591
4592 Query q = session.createQuery(sql);
4593
4594 QueryPos qPos = QueryPos.getInstance(q);
4595
4596 qPos.add(groupId);
4597
4598 if (vocabularyIds != null) {
4599 qPos.add(vocabularyIds);
4600 }
4601
4602 count = (Long)q.uniqueResult();
4603
4604 FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_V,
4605 finderArgs, count);
4606 }
4607 catch (Exception e) {
4608 FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_V,
4609 finderArgs);
4610
4611 throw processException(e);
4612 }
4613 finally {
4614 closeSession(session);
4615 }
4616 }
4617
4618 return count.intValue();
4619 }
4620
4621
4629 @Override
4630 public int filterCountByG_V(long groupId, long vocabularyId)
4631 throws SystemException {
4632 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
4633 return countByG_V(groupId, vocabularyId);
4634 }
4635
4636 StringBundler query = new StringBundler(3);
4637
4638 query.append(_FILTER_SQL_COUNT_ASSETCATEGORY_WHERE);
4639
4640 query.append(_FINDER_COLUMN_G_V_GROUPID_2);
4641
4642 query.append(_FINDER_COLUMN_G_V_VOCABULARYID_2);
4643
4644 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
4645 AssetCategory.class.getName(),
4646 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
4647
4648 Session session = null;
4649
4650 try {
4651 session = openSession();
4652
4653 SQLQuery q = session.createSQLQuery(sql);
4654
4655 q.addScalar(COUNT_COLUMN_NAME,
4656 com.liferay.portal.kernel.dao.orm.Type.LONG);
4657
4658 QueryPos qPos = QueryPos.getInstance(q);
4659
4660 qPos.add(groupId);
4661
4662 qPos.add(vocabularyId);
4663
4664 Long count = (Long)q.uniqueResult();
4665
4666 return count.intValue();
4667 }
4668 catch (Exception e) {
4669 throw processException(e);
4670 }
4671 finally {
4672 closeSession(session);
4673 }
4674 }
4675
4676
4684 @Override
4685 public int filterCountByG_V(long groupId, long[] vocabularyIds)
4686 throws SystemException {
4687 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
4688 return countByG_V(groupId, vocabularyIds);
4689 }
4690
4691 StringBundler query = new StringBundler();
4692
4693 query.append(_FILTER_SQL_COUNT_ASSETCATEGORY_WHERE);
4694
4695 boolean conjunctionable = false;
4696
4697 if (conjunctionable) {
4698 query.append(WHERE_AND);
4699 }
4700
4701 query.append(_FINDER_COLUMN_G_V_GROUPID_5);
4702
4703 conjunctionable = true;
4704
4705 if ((vocabularyIds == null) || (vocabularyIds.length > 0)) {
4706 if (conjunctionable) {
4707 query.append(WHERE_AND);
4708 }
4709
4710 query.append(StringPool.OPEN_PARENTHESIS);
4711
4712 for (int i = 0; i < vocabularyIds.length; i++) {
4713 query.append(_FINDER_COLUMN_G_V_VOCABULARYID_5);
4714
4715 if ((i + 1) < vocabularyIds.length) {
4716 query.append(WHERE_OR);
4717 }
4718 }
4719
4720 query.append(StringPool.CLOSE_PARENTHESIS);
4721
4722 conjunctionable = true;
4723 }
4724
4725 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
4726 AssetCategory.class.getName(),
4727 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
4728
4729 Session session = null;
4730
4731 try {
4732 session = openSession();
4733
4734 SQLQuery q = session.createSQLQuery(sql);
4735
4736 q.addScalar(COUNT_COLUMN_NAME,
4737 com.liferay.portal.kernel.dao.orm.Type.LONG);
4738
4739 QueryPos qPos = QueryPos.getInstance(q);
4740
4741 qPos.add(groupId);
4742
4743 if (vocabularyIds != null) {
4744 qPos.add(vocabularyIds);
4745 }
4746
4747 Long count = (Long)q.uniqueResult();
4748
4749 return count.intValue();
4750 }
4751 catch (Exception e) {
4752 throw processException(e);
4753 }
4754 finally {
4755 closeSession(session);
4756 }
4757 }
4758
4759 private static final String _FINDER_COLUMN_G_V_GROUPID_2 = "assetCategory.groupId = ? AND ";
4760 private static final String _FINDER_COLUMN_G_V_GROUPID_5 = "(" +
4761 removeConjunction(_FINDER_COLUMN_G_V_GROUPID_2) + ")";
4762 private static final String _FINDER_COLUMN_G_V_VOCABULARYID_2 = "assetCategory.vocabularyId = ?";
4763 private static final String _FINDER_COLUMN_G_V_VOCABULARYID_5 = "(" +
4764 removeConjunction(_FINDER_COLUMN_G_V_VOCABULARYID_2) + ")";
4765 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_P_N = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
4766 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
4767 AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
4768 "findByP_N",
4769 new String[] {
4770 Long.class.getName(), String.class.getName(),
4771
4772 Integer.class.getName(), Integer.class.getName(),
4773 OrderByComparator.class.getName()
4774 });
4775 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_P_N = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
4776 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
4777 AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
4778 "findByP_N",
4779 new String[] { Long.class.getName(), String.class.getName() },
4780 AssetCategoryModelImpl.PARENTCATEGORYID_COLUMN_BITMASK |
4781 AssetCategoryModelImpl.NAME_COLUMN_BITMASK);
4782 public static final FinderPath FINDER_PATH_COUNT_BY_P_N = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
4783 AssetCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class,
4784 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByP_N",
4785 new String[] { Long.class.getName(), String.class.getName() });
4786
4787
4795 @Override
4796 public List<AssetCategory> findByP_N(long parentCategoryId, String name)
4797 throws SystemException {
4798 return findByP_N(parentCategoryId, name, QueryUtil.ALL_POS,
4799 QueryUtil.ALL_POS, null);
4800 }
4801
4802
4816 @Override
4817 public List<AssetCategory> findByP_N(long parentCategoryId, String name,
4818 int start, int end) throws SystemException {
4819 return findByP_N(parentCategoryId, name, start, end, null);
4820 }
4821
4822
4837 @Override
4838 public List<AssetCategory> findByP_N(long parentCategoryId, String name,
4839 int start, int end, OrderByComparator orderByComparator)
4840 throws SystemException {
4841 boolean pagination = true;
4842 FinderPath finderPath = null;
4843 Object[] finderArgs = null;
4844
4845 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
4846 (orderByComparator == null)) {
4847 pagination = false;
4848 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_P_N;
4849 finderArgs = new Object[] { parentCategoryId, name };
4850 }
4851 else {
4852 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_P_N;
4853 finderArgs = new Object[] {
4854 parentCategoryId, name,
4855
4856 start, end, orderByComparator
4857 };
4858 }
4859
4860 List<AssetCategory> list = (List<AssetCategory>)FinderCacheUtil.getResult(finderPath,
4861 finderArgs, this);
4862
4863 if ((list != null) && !list.isEmpty()) {
4864 for (AssetCategory assetCategory : list) {
4865 if ((parentCategoryId != assetCategory.getParentCategoryId()) ||
4866 !Validator.equals(name, assetCategory.getName())) {
4867 list = null;
4868
4869 break;
4870 }
4871 }
4872 }
4873
4874 if (list == null) {
4875 StringBundler query = null;
4876
4877 if (orderByComparator != null) {
4878 query = new StringBundler(4 +
4879 (orderByComparator.getOrderByFields().length * 3));
4880 }
4881 else {
4882 query = new StringBundler(4);
4883 }
4884
4885 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
4886
4887 query.append(_FINDER_COLUMN_P_N_PARENTCATEGORYID_2);
4888
4889 boolean bindName = false;
4890
4891 if (name == null) {
4892 query.append(_FINDER_COLUMN_P_N_NAME_1);
4893 }
4894 else if (name.equals(StringPool.BLANK)) {
4895 query.append(_FINDER_COLUMN_P_N_NAME_3);
4896 }
4897 else {
4898 bindName = true;
4899
4900 query.append(_FINDER_COLUMN_P_N_NAME_2);
4901 }
4902
4903 if (orderByComparator != null) {
4904 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4905 orderByComparator);
4906 }
4907 else
4908 if (pagination) {
4909 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
4910 }
4911
4912 String sql = query.toString();
4913
4914 Session session = null;
4915
4916 try {
4917 session = openSession();
4918
4919 Query q = session.createQuery(sql);
4920
4921 QueryPos qPos = QueryPos.getInstance(q);
4922
4923 qPos.add(parentCategoryId);
4924
4925 if (bindName) {
4926 qPos.add(name);
4927 }
4928
4929 if (!pagination) {
4930 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
4931 start, end, false);
4932
4933 Collections.sort(list);
4934
4935 list = new UnmodifiableList<AssetCategory>(list);
4936 }
4937 else {
4938 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
4939 start, end);
4940 }
4941
4942 cacheResult(list);
4943
4944 FinderCacheUtil.putResult(finderPath, finderArgs, list);
4945 }
4946 catch (Exception e) {
4947 FinderCacheUtil.removeResult(finderPath, finderArgs);
4948
4949 throw processException(e);
4950 }
4951 finally {
4952 closeSession(session);
4953 }
4954 }
4955
4956 return list;
4957 }
4958
4959
4969 @Override
4970 public AssetCategory findByP_N_First(long parentCategoryId, String name,
4971 OrderByComparator orderByComparator)
4972 throws NoSuchCategoryException, SystemException {
4973 AssetCategory assetCategory = fetchByP_N_First(parentCategoryId, name,
4974 orderByComparator);
4975
4976 if (assetCategory != null) {
4977 return assetCategory;
4978 }
4979
4980 StringBundler msg = new StringBundler(6);
4981
4982 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4983
4984 msg.append("parentCategoryId=");
4985 msg.append(parentCategoryId);
4986
4987 msg.append(", name=");
4988 msg.append(name);
4989
4990 msg.append(StringPool.CLOSE_CURLY_BRACE);
4991
4992 throw new NoSuchCategoryException(msg.toString());
4993 }
4994
4995
5004 @Override
5005 public AssetCategory fetchByP_N_First(long parentCategoryId, String name,
5006 OrderByComparator orderByComparator) throws SystemException {
5007 List<AssetCategory> list = findByP_N(parentCategoryId, name, 0, 1,
5008 orderByComparator);
5009
5010 if (!list.isEmpty()) {
5011 return list.get(0);
5012 }
5013
5014 return null;
5015 }
5016
5017
5027 @Override
5028 public AssetCategory findByP_N_Last(long parentCategoryId, String name,
5029 OrderByComparator orderByComparator)
5030 throws NoSuchCategoryException, SystemException {
5031 AssetCategory assetCategory = fetchByP_N_Last(parentCategoryId, name,
5032 orderByComparator);
5033
5034 if (assetCategory != null) {
5035 return assetCategory;
5036 }
5037
5038 StringBundler msg = new StringBundler(6);
5039
5040 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5041
5042 msg.append("parentCategoryId=");
5043 msg.append(parentCategoryId);
5044
5045 msg.append(", name=");
5046 msg.append(name);
5047
5048 msg.append(StringPool.CLOSE_CURLY_BRACE);
5049
5050 throw new NoSuchCategoryException(msg.toString());
5051 }
5052
5053
5062 @Override
5063 public AssetCategory fetchByP_N_Last(long parentCategoryId, String name,
5064 OrderByComparator orderByComparator) throws SystemException {
5065 int count = countByP_N(parentCategoryId, name);
5066
5067 if (count == 0) {
5068 return null;
5069 }
5070
5071 List<AssetCategory> list = findByP_N(parentCategoryId, name, count - 1,
5072 count, orderByComparator);
5073
5074 if (!list.isEmpty()) {
5075 return list.get(0);
5076 }
5077
5078 return null;
5079 }
5080
5081
5092 @Override
5093 public AssetCategory[] findByP_N_PrevAndNext(long categoryId,
5094 long parentCategoryId, String name, OrderByComparator orderByComparator)
5095 throws NoSuchCategoryException, SystemException {
5096 AssetCategory assetCategory = findByPrimaryKey(categoryId);
5097
5098 Session session = null;
5099
5100 try {
5101 session = openSession();
5102
5103 AssetCategory[] array = new AssetCategoryImpl[3];
5104
5105 array[0] = getByP_N_PrevAndNext(session, assetCategory,
5106 parentCategoryId, name, orderByComparator, true);
5107
5108 array[1] = assetCategory;
5109
5110 array[2] = getByP_N_PrevAndNext(session, assetCategory,
5111 parentCategoryId, name, orderByComparator, false);
5112
5113 return array;
5114 }
5115 catch (Exception e) {
5116 throw processException(e);
5117 }
5118 finally {
5119 closeSession(session);
5120 }
5121 }
5122
5123 protected AssetCategory getByP_N_PrevAndNext(Session session,
5124 AssetCategory assetCategory, long parentCategoryId, String name,
5125 OrderByComparator orderByComparator, boolean previous) {
5126 StringBundler query = null;
5127
5128 if (orderByComparator != null) {
5129 query = new StringBundler(6 +
5130 (orderByComparator.getOrderByFields().length * 6));
5131 }
5132 else {
5133 query = new StringBundler(3);
5134 }
5135
5136 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
5137
5138 query.append(_FINDER_COLUMN_P_N_PARENTCATEGORYID_2);
5139
5140 boolean bindName = false;
5141
5142 if (name == null) {
5143 query.append(_FINDER_COLUMN_P_N_NAME_1);
5144 }
5145 else if (name.equals(StringPool.BLANK)) {
5146 query.append(_FINDER_COLUMN_P_N_NAME_3);
5147 }
5148 else {
5149 bindName = true;
5150
5151 query.append(_FINDER_COLUMN_P_N_NAME_2);
5152 }
5153
5154 if (orderByComparator != null) {
5155 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
5156
5157 if (orderByConditionFields.length > 0) {
5158 query.append(WHERE_AND);
5159 }
5160
5161 for (int i = 0; i < orderByConditionFields.length; i++) {
5162 query.append(_ORDER_BY_ENTITY_ALIAS);
5163 query.append(orderByConditionFields[i]);
5164
5165 if ((i + 1) < orderByConditionFields.length) {
5166 if (orderByComparator.isAscending() ^ previous) {
5167 query.append(WHERE_GREATER_THAN_HAS_NEXT);
5168 }
5169 else {
5170 query.append(WHERE_LESSER_THAN_HAS_NEXT);
5171 }
5172 }
5173 else {
5174 if (orderByComparator.isAscending() ^ previous) {
5175 query.append(WHERE_GREATER_THAN);
5176 }
5177 else {
5178 query.append(WHERE_LESSER_THAN);
5179 }
5180 }
5181 }
5182
5183 query.append(ORDER_BY_CLAUSE);
5184
5185 String[] orderByFields = orderByComparator.getOrderByFields();
5186
5187 for (int i = 0; i < orderByFields.length; i++) {
5188 query.append(_ORDER_BY_ENTITY_ALIAS);
5189 query.append(orderByFields[i]);
5190
5191 if ((i + 1) < orderByFields.length) {
5192 if (orderByComparator.isAscending() ^ previous) {
5193 query.append(ORDER_BY_ASC_HAS_NEXT);
5194 }
5195 else {
5196 query.append(ORDER_BY_DESC_HAS_NEXT);
5197 }
5198 }
5199 else {
5200 if (orderByComparator.isAscending() ^ previous) {
5201 query.append(ORDER_BY_ASC);
5202 }
5203 else {
5204 query.append(ORDER_BY_DESC);
5205 }
5206 }
5207 }
5208 }
5209 else {
5210 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
5211 }
5212
5213 String sql = query.toString();
5214
5215 Query q = session.createQuery(sql);
5216
5217 q.setFirstResult(0);
5218 q.setMaxResults(2);
5219
5220 QueryPos qPos = QueryPos.getInstance(q);
5221
5222 qPos.add(parentCategoryId);
5223
5224 if (bindName) {
5225 qPos.add(name);
5226 }
5227
5228 if (orderByComparator != null) {
5229 Object[] values = orderByComparator.getOrderByConditionValues(assetCategory);
5230
5231 for (Object value : values) {
5232 qPos.add(value);
5233 }
5234 }
5235
5236 List<AssetCategory> list = q.list();
5237
5238 if (list.size() == 2) {
5239 return list.get(1);
5240 }
5241 else {
5242 return null;
5243 }
5244 }
5245
5246
5253 @Override
5254 public void removeByP_N(long parentCategoryId, String name)
5255 throws SystemException {
5256 for (AssetCategory assetCategory : findByP_N(parentCategoryId, name,
5257 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
5258 remove(assetCategory);
5259 }
5260 }
5261
5262
5270 @Override
5271 public int countByP_N(long parentCategoryId, String name)
5272 throws SystemException {
5273 FinderPath finderPath = FINDER_PATH_COUNT_BY_P_N;
5274
5275 Object[] finderArgs = new Object[] { parentCategoryId, name };
5276
5277 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
5278 this);
5279
5280 if (count == null) {
5281 StringBundler query = new StringBundler(3);
5282
5283 query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
5284
5285 query.append(_FINDER_COLUMN_P_N_PARENTCATEGORYID_2);
5286
5287 boolean bindName = false;
5288
5289 if (name == null) {
5290 query.append(_FINDER_COLUMN_P_N_NAME_1);
5291 }
5292 else if (name.equals(StringPool.BLANK)) {
5293 query.append(_FINDER_COLUMN_P_N_NAME_3);
5294 }
5295 else {
5296 bindName = true;
5297
5298 query.append(_FINDER_COLUMN_P_N_NAME_2);
5299 }
5300
5301 String sql = query.toString();
5302
5303 Session session = null;
5304
5305 try {
5306 session = openSession();
5307
5308 Query q = session.createQuery(sql);
5309
5310 QueryPos qPos = QueryPos.getInstance(q);
5311
5312 qPos.add(parentCategoryId);
5313
5314 if (bindName) {
5315 qPos.add(name);
5316 }
5317
5318 count = (Long)q.uniqueResult();
5319
5320 FinderCacheUtil.putResult(finderPath, finderArgs, count);
5321 }
5322 catch (Exception e) {
5323 FinderCacheUtil.removeResult(finderPath, finderArgs);
5324
5325 throw processException(e);
5326 }
5327 finally {
5328 closeSession(session);
5329 }
5330 }
5331
5332 return count.intValue();
5333 }
5334
5335 private static final String _FINDER_COLUMN_P_N_PARENTCATEGORYID_2 = "assetCategory.parentCategoryId = ? AND ";
5336 private static final String _FINDER_COLUMN_P_N_NAME_1 = "assetCategory.name IS NULL";
5337 private static final String _FINDER_COLUMN_P_N_NAME_2 = "assetCategory.name = ?";
5338 private static final String _FINDER_COLUMN_P_N_NAME_3 = "(assetCategory.name IS NULL OR assetCategory.name = '')";
5339 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_P_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
5340 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
5341 AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
5342 "findByP_V",
5343 new String[] {
5344 Long.class.getName(), Long.class.getName(),
5345
5346 Integer.class.getName(), Integer.class.getName(),
5347 OrderByComparator.class.getName()
5348 });
5349 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_P_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
5350 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
5351 AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
5352 "findByP_V",
5353 new String[] { Long.class.getName(), Long.class.getName() },
5354 AssetCategoryModelImpl.PARENTCATEGORYID_COLUMN_BITMASK |
5355 AssetCategoryModelImpl.VOCABULARYID_COLUMN_BITMASK |
5356 AssetCategoryModelImpl.NAME_COLUMN_BITMASK);
5357 public static final FinderPath FINDER_PATH_COUNT_BY_P_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
5358 AssetCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class,
5359 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByP_V",
5360 new String[] { Long.class.getName(), Long.class.getName() });
5361
5362
5370 @Override
5371 public List<AssetCategory> findByP_V(long parentCategoryId,
5372 long vocabularyId) throws SystemException {
5373 return findByP_V(parentCategoryId, vocabularyId, QueryUtil.ALL_POS,
5374 QueryUtil.ALL_POS, null);
5375 }
5376
5377
5391 @Override
5392 public List<AssetCategory> findByP_V(long parentCategoryId,
5393 long vocabularyId, int start, int end) throws SystemException {
5394 return findByP_V(parentCategoryId, vocabularyId, start, end, null);
5395 }
5396
5397
5412 @Override
5413 public List<AssetCategory> findByP_V(long parentCategoryId,
5414 long vocabularyId, int start, int end,
5415 OrderByComparator orderByComparator) throws SystemException {
5416 boolean pagination = true;
5417 FinderPath finderPath = null;
5418 Object[] finderArgs = null;
5419
5420 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
5421 (orderByComparator == null)) {
5422 pagination = false;
5423 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_P_V;
5424 finderArgs = new Object[] { parentCategoryId, vocabularyId };
5425 }
5426 else {
5427 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_P_V;
5428 finderArgs = new Object[] {
5429 parentCategoryId, vocabularyId,
5430
5431 start, end, orderByComparator
5432 };
5433 }
5434
5435 List<AssetCategory> list = (List<AssetCategory>)FinderCacheUtil.getResult(finderPath,
5436 finderArgs, this);
5437
5438 if ((list != null) && !list.isEmpty()) {
5439 for (AssetCategory assetCategory : list) {
5440 if ((parentCategoryId != assetCategory.getParentCategoryId()) ||
5441 (vocabularyId != assetCategory.getVocabularyId())) {
5442 list = null;
5443
5444 break;
5445 }
5446 }
5447 }
5448
5449 if (list == null) {
5450 StringBundler query = null;
5451
5452 if (orderByComparator != null) {
5453 query = new StringBundler(4 +
5454 (orderByComparator.getOrderByFields().length * 3));
5455 }
5456 else {
5457 query = new StringBundler(4);
5458 }
5459
5460 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
5461
5462 query.append(_FINDER_COLUMN_P_V_PARENTCATEGORYID_2);
5463
5464 query.append(_FINDER_COLUMN_P_V_VOCABULARYID_2);
5465
5466 if (orderByComparator != null) {
5467 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
5468 orderByComparator);
5469 }
5470 else
5471 if (pagination) {
5472 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
5473 }
5474
5475 String sql = query.toString();
5476
5477 Session session = null;
5478
5479 try {
5480 session = openSession();
5481
5482 Query q = session.createQuery(sql);
5483
5484 QueryPos qPos = QueryPos.getInstance(q);
5485
5486 qPos.add(parentCategoryId);
5487
5488 qPos.add(vocabularyId);
5489
5490 if (!pagination) {
5491 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
5492 start, end, false);
5493
5494 Collections.sort(list);
5495
5496 list = new UnmodifiableList<AssetCategory>(list);
5497 }
5498 else {
5499 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
5500 start, end);
5501 }
5502
5503 cacheResult(list);
5504
5505 FinderCacheUtil.putResult(finderPath, finderArgs, list);
5506 }
5507 catch (Exception e) {
5508 FinderCacheUtil.removeResult(finderPath, finderArgs);
5509
5510 throw processException(e);
5511 }
5512 finally {
5513 closeSession(session);
5514 }
5515 }
5516
5517 return list;
5518 }
5519
5520
5530 @Override
5531 public AssetCategory findByP_V_First(long parentCategoryId,
5532 long vocabularyId, OrderByComparator orderByComparator)
5533 throws NoSuchCategoryException, SystemException {
5534 AssetCategory assetCategory = fetchByP_V_First(parentCategoryId,
5535 vocabularyId, orderByComparator);
5536
5537 if (assetCategory != null) {
5538 return assetCategory;
5539 }
5540
5541 StringBundler msg = new StringBundler(6);
5542
5543 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5544
5545 msg.append("parentCategoryId=");
5546 msg.append(parentCategoryId);
5547
5548 msg.append(", vocabularyId=");
5549 msg.append(vocabularyId);
5550
5551 msg.append(StringPool.CLOSE_CURLY_BRACE);
5552
5553 throw new NoSuchCategoryException(msg.toString());
5554 }
5555
5556
5565 @Override
5566 public AssetCategory fetchByP_V_First(long parentCategoryId,
5567 long vocabularyId, OrderByComparator orderByComparator)
5568 throws SystemException {
5569 List<AssetCategory> list = findByP_V(parentCategoryId, vocabularyId, 0,
5570 1, orderByComparator);
5571
5572 if (!list.isEmpty()) {
5573 return list.get(0);
5574 }
5575
5576 return null;
5577 }
5578
5579
5589 @Override
5590 public AssetCategory findByP_V_Last(long parentCategoryId,
5591 long vocabularyId, OrderByComparator orderByComparator)
5592 throws NoSuchCategoryException, SystemException {
5593 AssetCategory assetCategory = fetchByP_V_Last(parentCategoryId,
5594 vocabularyId, orderByComparator);
5595
5596 if (assetCategory != null) {
5597 return assetCategory;
5598 }
5599
5600 StringBundler msg = new StringBundler(6);
5601
5602 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5603
5604 msg.append("parentCategoryId=");
5605 msg.append(parentCategoryId);
5606
5607 msg.append(", vocabularyId=");
5608 msg.append(vocabularyId);
5609
5610 msg.append(StringPool.CLOSE_CURLY_BRACE);
5611
5612 throw new NoSuchCategoryException(msg.toString());
5613 }
5614
5615
5624 @Override
5625 public AssetCategory fetchByP_V_Last(long parentCategoryId,
5626 long vocabularyId, OrderByComparator orderByComparator)
5627 throws SystemException {
5628 int count = countByP_V(parentCategoryId, vocabularyId);
5629
5630 if (count == 0) {
5631 return null;
5632 }
5633
5634 List<AssetCategory> list = findByP_V(parentCategoryId, vocabularyId,
5635 count - 1, count, orderByComparator);
5636
5637 if (!list.isEmpty()) {
5638 return list.get(0);
5639 }
5640
5641 return null;
5642 }
5643
5644
5655 @Override
5656 public AssetCategory[] findByP_V_PrevAndNext(long categoryId,
5657 long parentCategoryId, long vocabularyId,
5658 OrderByComparator orderByComparator)
5659 throws NoSuchCategoryException, SystemException {
5660 AssetCategory assetCategory = findByPrimaryKey(categoryId);
5661
5662 Session session = null;
5663
5664 try {
5665 session = openSession();
5666
5667 AssetCategory[] array = new AssetCategoryImpl[3];
5668
5669 array[0] = getByP_V_PrevAndNext(session, assetCategory,
5670 parentCategoryId, vocabularyId, orderByComparator, true);
5671
5672 array[1] = assetCategory;
5673
5674 array[2] = getByP_V_PrevAndNext(session, assetCategory,
5675 parentCategoryId, vocabularyId, orderByComparator, false);
5676
5677 return array;
5678 }
5679 catch (Exception e) {
5680 throw processException(e);
5681 }
5682 finally {
5683 closeSession(session);
5684 }
5685 }
5686
5687 protected AssetCategory getByP_V_PrevAndNext(Session session,
5688 AssetCategory assetCategory, long parentCategoryId, long vocabularyId,
5689 OrderByComparator orderByComparator, boolean previous) {
5690 StringBundler query = null;
5691
5692 if (orderByComparator != null) {
5693 query = new StringBundler(6 +
5694 (orderByComparator.getOrderByFields().length * 6));
5695 }
5696 else {
5697 query = new StringBundler(3);
5698 }
5699
5700 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
5701
5702 query.append(_FINDER_COLUMN_P_V_PARENTCATEGORYID_2);
5703
5704 query.append(_FINDER_COLUMN_P_V_VOCABULARYID_2);
5705
5706 if (orderByComparator != null) {
5707 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
5708
5709 if (orderByConditionFields.length > 0) {
5710 query.append(WHERE_AND);
5711 }
5712
5713 for (int i = 0; i < orderByConditionFields.length; i++) {
5714 query.append(_ORDER_BY_ENTITY_ALIAS);
5715 query.append(orderByConditionFields[i]);
5716
5717 if ((i + 1) < orderByConditionFields.length) {
5718 if (orderByComparator.isAscending() ^ previous) {
5719 query.append(WHERE_GREATER_THAN_HAS_NEXT);
5720 }
5721 else {
5722 query.append(WHERE_LESSER_THAN_HAS_NEXT);
5723 }
5724 }
5725 else {
5726 if (orderByComparator.isAscending() ^ previous) {
5727 query.append(WHERE_GREATER_THAN);
5728 }
5729 else {
5730 query.append(WHERE_LESSER_THAN);
5731 }
5732 }
5733 }
5734
5735 query.append(ORDER_BY_CLAUSE);
5736
5737 String[] orderByFields = orderByComparator.getOrderByFields();
5738
5739 for (int i = 0; i < orderByFields.length; i++) {
5740 query.append(_ORDER_BY_ENTITY_ALIAS);
5741 query.append(orderByFields[i]);
5742
5743 if ((i + 1) < orderByFields.length) {
5744 if (orderByComparator.isAscending() ^ previous) {
5745 query.append(ORDER_BY_ASC_HAS_NEXT);
5746 }
5747 else {
5748 query.append(ORDER_BY_DESC_HAS_NEXT);
5749 }
5750 }
5751 else {
5752 if (orderByComparator.isAscending() ^ previous) {
5753 query.append(ORDER_BY_ASC);
5754 }
5755 else {
5756 query.append(ORDER_BY_DESC);
5757 }
5758 }
5759 }
5760 }
5761 else {
5762 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
5763 }
5764
5765 String sql = query.toString();
5766
5767 Query q = session.createQuery(sql);
5768
5769 q.setFirstResult(0);
5770 q.setMaxResults(2);
5771
5772 QueryPos qPos = QueryPos.getInstance(q);
5773
5774 qPos.add(parentCategoryId);
5775
5776 qPos.add(vocabularyId);
5777
5778 if (orderByComparator != null) {
5779 Object[] values = orderByComparator.getOrderByConditionValues(assetCategory);
5780
5781 for (Object value : values) {
5782 qPos.add(value);
5783 }
5784 }
5785
5786 List<AssetCategory> list = q.list();
5787
5788 if (list.size() == 2) {
5789 return list.get(1);
5790 }
5791 else {
5792 return null;
5793 }
5794 }
5795
5796
5803 @Override
5804 public void removeByP_V(long parentCategoryId, long vocabularyId)
5805 throws SystemException {
5806 for (AssetCategory assetCategory : findByP_V(parentCategoryId,
5807 vocabularyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
5808 remove(assetCategory);
5809 }
5810 }
5811
5812
5820 @Override
5821 public int countByP_V(long parentCategoryId, long vocabularyId)
5822 throws SystemException {
5823 FinderPath finderPath = FINDER_PATH_COUNT_BY_P_V;
5824
5825 Object[] finderArgs = new Object[] { parentCategoryId, vocabularyId };
5826
5827 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
5828 this);
5829
5830 if (count == null) {
5831 StringBundler query = new StringBundler(3);
5832
5833 query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
5834
5835 query.append(_FINDER_COLUMN_P_V_PARENTCATEGORYID_2);
5836
5837 query.append(_FINDER_COLUMN_P_V_VOCABULARYID_2);
5838
5839 String sql = query.toString();
5840
5841 Session session = null;
5842
5843 try {
5844 session = openSession();
5845
5846 Query q = session.createQuery(sql);
5847
5848 QueryPos qPos = QueryPos.getInstance(q);
5849
5850 qPos.add(parentCategoryId);
5851
5852 qPos.add(vocabularyId);
5853
5854 count = (Long)q.uniqueResult();
5855
5856 FinderCacheUtil.putResult(finderPath, finderArgs, count);
5857 }
5858 catch (Exception e) {
5859 FinderCacheUtil.removeResult(finderPath, finderArgs);
5860
5861 throw processException(e);
5862 }
5863 finally {
5864 closeSession(session);
5865 }
5866 }
5867
5868 return count.intValue();
5869 }
5870
5871 private static final String _FINDER_COLUMN_P_V_PARENTCATEGORYID_2 = "assetCategory.parentCategoryId = ? AND ";
5872 private static final String _FINDER_COLUMN_P_V_VOCABULARYID_2 = "assetCategory.vocabularyId = ?";
5873 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_N_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
5874 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
5875 AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
5876 "findByN_V",
5877 new String[] {
5878 String.class.getName(), Long.class.getName(),
5879
5880 Integer.class.getName(), Integer.class.getName(),
5881 OrderByComparator.class.getName()
5882 });
5883 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
5884 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
5885 AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
5886 "findByN_V",
5887 new String[] { String.class.getName(), Long.class.getName() },
5888 AssetCategoryModelImpl.NAME_COLUMN_BITMASK |
5889 AssetCategoryModelImpl.VOCABULARYID_COLUMN_BITMASK);
5890 public static final FinderPath FINDER_PATH_COUNT_BY_N_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
5891 AssetCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class,
5892 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByN_V",
5893 new String[] { String.class.getName(), Long.class.getName() });
5894
5895
5903 @Override
5904 public List<AssetCategory> findByN_V(String name, long vocabularyId)
5905 throws SystemException {
5906 return findByN_V(name, vocabularyId, QueryUtil.ALL_POS,
5907 QueryUtil.ALL_POS, null);
5908 }
5909
5910
5924 @Override
5925 public List<AssetCategory> findByN_V(String name, long vocabularyId,
5926 int start, int end) throws SystemException {
5927 return findByN_V(name, vocabularyId, start, end, null);
5928 }
5929
5930
5945 @Override
5946 public List<AssetCategory> findByN_V(String name, long vocabularyId,
5947 int start, int end, OrderByComparator orderByComparator)
5948 throws SystemException {
5949 boolean pagination = true;
5950 FinderPath finderPath = null;
5951 Object[] finderArgs = null;
5952
5953 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
5954 (orderByComparator == null)) {
5955 pagination = false;
5956 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_V;
5957 finderArgs = new Object[] { name, vocabularyId };
5958 }
5959 else {
5960 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_N_V;
5961 finderArgs = new Object[] {
5962 name, vocabularyId,
5963
5964 start, end, orderByComparator
5965 };
5966 }
5967
5968 List<AssetCategory> list = (List<AssetCategory>)FinderCacheUtil.getResult(finderPath,
5969 finderArgs, this);
5970
5971 if ((list != null) && !list.isEmpty()) {
5972 for (AssetCategory assetCategory : list) {
5973 if (!Validator.equals(name, assetCategory.getName()) ||
5974 (vocabularyId != assetCategory.getVocabularyId())) {
5975 list = null;
5976
5977 break;
5978 }
5979 }
5980 }
5981
5982 if (list == null) {
5983 StringBundler query = null;
5984
5985 if (orderByComparator != null) {
5986 query = new StringBundler(4 +
5987 (orderByComparator.getOrderByFields().length * 3));
5988 }
5989 else {
5990 query = new StringBundler(4);
5991 }
5992
5993 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
5994
5995 boolean bindName = false;
5996
5997 if (name == null) {
5998 query.append(_FINDER_COLUMN_N_V_NAME_1);
5999 }
6000 else if (name.equals(StringPool.BLANK)) {
6001 query.append(_FINDER_COLUMN_N_V_NAME_3);
6002 }
6003 else {
6004 bindName = true;
6005
6006 query.append(_FINDER_COLUMN_N_V_NAME_2);
6007 }
6008
6009 query.append(_FINDER_COLUMN_N_V_VOCABULARYID_2);
6010
6011 if (orderByComparator != null) {
6012 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
6013 orderByComparator);
6014 }
6015 else
6016 if (pagination) {
6017 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
6018 }
6019
6020 String sql = query.toString();
6021
6022 Session session = null;
6023
6024 try {
6025 session = openSession();
6026
6027 Query q = session.createQuery(sql);
6028
6029 QueryPos qPos = QueryPos.getInstance(q);
6030
6031 if (bindName) {
6032 qPos.add(name);
6033 }
6034
6035 qPos.add(vocabularyId);
6036
6037 if (!pagination) {
6038 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
6039 start, end, false);
6040
6041 Collections.sort(list);
6042
6043 list = new UnmodifiableList<AssetCategory>(list);
6044 }
6045 else {
6046 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
6047 start, end);
6048 }
6049
6050 cacheResult(list);
6051
6052 FinderCacheUtil.putResult(finderPath, finderArgs, list);
6053 }
6054 catch (Exception e) {
6055 FinderCacheUtil.removeResult(finderPath, finderArgs);
6056
6057 throw processException(e);
6058 }
6059 finally {
6060 closeSession(session);
6061 }
6062 }
6063
6064 return list;
6065 }
6066
6067
6077 @Override
6078 public AssetCategory findByN_V_First(String name, long vocabularyId,
6079 OrderByComparator orderByComparator)
6080 throws NoSuchCategoryException, SystemException {
6081 AssetCategory assetCategory = fetchByN_V_First(name, vocabularyId,
6082 orderByComparator);
6083
6084 if (assetCategory != null) {
6085 return assetCategory;
6086 }
6087
6088 StringBundler msg = new StringBundler(6);
6089
6090 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
6091
6092 msg.append("name=");
6093 msg.append(name);
6094
6095 msg.append(", vocabularyId=");
6096 msg.append(vocabularyId);
6097
6098 msg.append(StringPool.CLOSE_CURLY_BRACE);
6099
6100 throw new NoSuchCategoryException(msg.toString());
6101 }
6102
6103
6112 @Override
6113 public AssetCategory fetchByN_V_First(String name, long vocabularyId,
6114 OrderByComparator orderByComparator) throws SystemException {
6115 List<AssetCategory> list = findByN_V(name, vocabularyId, 0, 1,
6116 orderByComparator);
6117
6118 if (!list.isEmpty()) {
6119 return list.get(0);
6120 }
6121
6122 return null;
6123 }
6124
6125
6135 @Override
6136 public AssetCategory findByN_V_Last(String name, long vocabularyId,
6137 OrderByComparator orderByComparator)
6138 throws NoSuchCategoryException, SystemException {
6139 AssetCategory assetCategory = fetchByN_V_Last(name, vocabularyId,
6140 orderByComparator);
6141
6142 if (assetCategory != null) {
6143 return assetCategory;
6144 }
6145
6146 StringBundler msg = new StringBundler(6);
6147
6148 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
6149
6150 msg.append("name=");
6151 msg.append(name);
6152
6153 msg.append(", vocabularyId=");
6154 msg.append(vocabularyId);
6155
6156 msg.append(StringPool.CLOSE_CURLY_BRACE);
6157
6158 throw new NoSuchCategoryException(msg.toString());
6159 }
6160
6161
6170 @Override
6171 public AssetCategory fetchByN_V_Last(String name, long vocabularyId,
6172 OrderByComparator orderByComparator) throws SystemException {
6173 int count = countByN_V(name, vocabularyId);
6174
6175 if (count == 0) {
6176 return null;
6177 }
6178
6179 List<AssetCategory> list = findByN_V(name, vocabularyId, count - 1,
6180 count, orderByComparator);
6181
6182 if (!list.isEmpty()) {
6183 return list.get(0);
6184 }
6185
6186 return null;
6187 }
6188
6189
6200 @Override
6201 public AssetCategory[] findByN_V_PrevAndNext(long categoryId, String name,
6202 long vocabularyId, OrderByComparator orderByComparator)
6203 throws NoSuchCategoryException, SystemException {
6204 AssetCategory assetCategory = findByPrimaryKey(categoryId);
6205
6206 Session session = null;
6207
6208 try {
6209 session = openSession();
6210
6211 AssetCategory[] array = new AssetCategoryImpl[3];
6212
6213 array[0] = getByN_V_PrevAndNext(session, assetCategory, name,
6214 vocabularyId, orderByComparator, true);
6215
6216 array[1] = assetCategory;
6217
6218 array[2] = getByN_V_PrevAndNext(session, assetCategory, name,
6219 vocabularyId, orderByComparator, false);
6220
6221 return array;
6222 }
6223 catch (Exception e) {
6224 throw processException(e);
6225 }
6226 finally {
6227 closeSession(session);
6228 }
6229 }
6230
6231 protected AssetCategory getByN_V_PrevAndNext(Session session,
6232 AssetCategory assetCategory, String name, long vocabularyId,
6233 OrderByComparator orderByComparator, boolean previous) {
6234 StringBundler query = null;
6235
6236 if (orderByComparator != null) {
6237 query = new StringBundler(6 +
6238 (orderByComparator.getOrderByFields().length * 6));
6239 }
6240 else {
6241 query = new StringBundler(3);
6242 }
6243
6244 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
6245
6246 boolean bindName = false;
6247
6248 if (name == null) {
6249 query.append(_FINDER_COLUMN_N_V_NAME_1);
6250 }
6251 else if (name.equals(StringPool.BLANK)) {
6252 query.append(_FINDER_COLUMN_N_V_NAME_3);
6253 }
6254 else {
6255 bindName = true;
6256
6257 query.append(_FINDER_COLUMN_N_V_NAME_2);
6258 }
6259
6260 query.append(_FINDER_COLUMN_N_V_VOCABULARYID_2);
6261
6262 if (orderByComparator != null) {
6263 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
6264
6265 if (orderByConditionFields.length > 0) {
6266 query.append(WHERE_AND);
6267 }
6268
6269 for (int i = 0; i < orderByConditionFields.length; i++) {
6270 query.append(_ORDER_BY_ENTITY_ALIAS);
6271 query.append(orderByConditionFields[i]);
6272
6273 if ((i + 1) < orderByConditionFields.length) {
6274 if (orderByComparator.isAscending() ^ previous) {
6275 query.append(WHERE_GREATER_THAN_HAS_NEXT);
6276 }
6277 else {
6278 query.append(WHERE_LESSER_THAN_HAS_NEXT);
6279 }
6280 }
6281 else {
6282 if (orderByComparator.isAscending() ^ previous) {
6283 query.append(WHERE_GREATER_THAN);
6284 }
6285 else {
6286 query.append(WHERE_LESSER_THAN);
6287 }
6288 }
6289 }
6290
6291 query.append(ORDER_BY_CLAUSE);
6292
6293 String[] orderByFields = orderByComparator.getOrderByFields();
6294
6295 for (int i = 0; i < orderByFields.length; i++) {
6296 query.append(_ORDER_BY_ENTITY_ALIAS);
6297 query.append(orderByFields[i]);
6298
6299 if ((i + 1) < orderByFields.length) {
6300 if (orderByComparator.isAscending() ^ previous) {
6301 query.append(ORDER_BY_ASC_HAS_NEXT);
6302 }
6303 else {
6304 query.append(ORDER_BY_DESC_HAS_NEXT);
6305 }
6306 }
6307 else {
6308 if (orderByComparator.isAscending() ^ previous) {
6309 query.append(ORDER_BY_ASC);
6310 }
6311 else {
6312 query.append(ORDER_BY_DESC);
6313 }
6314 }
6315 }
6316 }
6317 else {
6318 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
6319 }
6320
6321 String sql = query.toString();
6322
6323 Query q = session.createQuery(sql);
6324
6325 q.setFirstResult(0);
6326 q.setMaxResults(2);
6327
6328 QueryPos qPos = QueryPos.getInstance(q);
6329
6330 if (bindName) {
6331 qPos.add(name);
6332 }
6333
6334 qPos.add(vocabularyId);
6335
6336 if (orderByComparator != null) {
6337 Object[] values = orderByComparator.getOrderByConditionValues(assetCategory);
6338
6339 for (Object value : values) {
6340 qPos.add(value);
6341 }
6342 }
6343
6344 List<AssetCategory> list = q.list();
6345
6346 if (list.size() == 2) {
6347 return list.get(1);
6348 }
6349 else {
6350 return null;
6351 }
6352 }
6353
6354
6361 @Override
6362 public void removeByN_V(String name, long vocabularyId)
6363 throws SystemException {
6364 for (AssetCategory assetCategory : findByN_V(name, vocabularyId,
6365 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
6366 remove(assetCategory);
6367 }
6368 }
6369
6370
6378 @Override
6379 public int countByN_V(String name, long vocabularyId)
6380 throws SystemException {
6381 FinderPath finderPath = FINDER_PATH_COUNT_BY_N_V;
6382
6383 Object[] finderArgs = new Object[] { name, vocabularyId };
6384
6385 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
6386 this);
6387
6388 if (count == null) {
6389 StringBundler query = new StringBundler(3);
6390
6391 query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
6392
6393 boolean bindName = false;
6394
6395 if (name == null) {
6396 query.append(_FINDER_COLUMN_N_V_NAME_1);
6397 }
6398 else if (name.equals(StringPool.BLANK)) {
6399 query.append(_FINDER_COLUMN_N_V_NAME_3);
6400 }
6401 else {
6402 bindName = true;
6403
6404 query.append(_FINDER_COLUMN_N_V_NAME_2);
6405 }
6406
6407 query.append(_FINDER_COLUMN_N_V_VOCABULARYID_2);
6408
6409 String sql = query.toString();
6410
6411 Session session = null;
6412
6413 try {
6414 session = openSession();
6415
6416 Query q = session.createQuery(sql);
6417
6418 QueryPos qPos = QueryPos.getInstance(q);
6419
6420 if (bindName) {
6421 qPos.add(name);
6422 }
6423
6424 qPos.add(vocabularyId);
6425
6426 count = (Long)q.uniqueResult();
6427
6428 FinderCacheUtil.putResult(finderPath, finderArgs, count);
6429 }
6430 catch (Exception e) {
6431 FinderCacheUtil.removeResult(finderPath, finderArgs);
6432
6433 throw processException(e);
6434 }
6435 finally {
6436 closeSession(session);
6437 }
6438 }
6439
6440 return count.intValue();
6441 }
6442
6443 private static final String _FINDER_COLUMN_N_V_NAME_1 = "assetCategory.name IS NULL AND ";
6444 private static final String _FINDER_COLUMN_N_V_NAME_2 = "assetCategory.name = ? AND ";
6445 private static final String _FINDER_COLUMN_N_V_NAME_3 = "(assetCategory.name IS NULL OR assetCategory.name = '') AND ";
6446 private static final String _FINDER_COLUMN_N_V_VOCABULARYID_2 = "assetCategory.vocabularyId = ?";
6447 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_P_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
6448 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
6449 AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
6450 "findByG_P_V",
6451 new String[] {
6452 Long.class.getName(), Long.class.getName(), Long.class.getName(),
6453
6454 Integer.class.getName(), Integer.class.getName(),
6455 OrderByComparator.class.getName()
6456 });
6457 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
6458 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
6459 AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
6460 "findByG_P_V",
6461 new String[] {
6462 Long.class.getName(), Long.class.getName(), Long.class.getName()
6463 },
6464 AssetCategoryModelImpl.GROUPID_COLUMN_BITMASK |
6465 AssetCategoryModelImpl.PARENTCATEGORYID_COLUMN_BITMASK |
6466 AssetCategoryModelImpl.VOCABULARYID_COLUMN_BITMASK |
6467 AssetCategoryModelImpl.NAME_COLUMN_BITMASK);
6468 public static final FinderPath FINDER_PATH_COUNT_BY_G_P_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
6469 AssetCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class,
6470 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_P_V",
6471 new String[] {
6472 Long.class.getName(), Long.class.getName(), Long.class.getName()
6473 });
6474
6475
6484 @Override
6485 public List<AssetCategory> findByG_P_V(long groupId, long parentCategoryId,
6486 long vocabularyId) throws SystemException {
6487 return findByG_P_V(groupId, parentCategoryId, vocabularyId,
6488 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
6489 }
6490
6491
6506 @Override
6507 public List<AssetCategory> findByG_P_V(long groupId, long parentCategoryId,
6508 long vocabularyId, int start, int end) throws SystemException {
6509 return findByG_P_V(groupId, parentCategoryId, vocabularyId, start, end,
6510 null);
6511 }
6512
6513
6529 @Override
6530 public List<AssetCategory> findByG_P_V(long groupId, long parentCategoryId,
6531 long vocabularyId, int start, int end,
6532 OrderByComparator orderByComparator) throws SystemException {
6533 boolean pagination = true;
6534 FinderPath finderPath = null;
6535 Object[] finderArgs = null;
6536
6537 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
6538 (orderByComparator == null)) {
6539 pagination = false;
6540 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_V;
6541 finderArgs = new Object[] { groupId, parentCategoryId, vocabularyId };
6542 }
6543 else {
6544 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_P_V;
6545 finderArgs = new Object[] {
6546 groupId, parentCategoryId, vocabularyId,
6547
6548 start, end, orderByComparator
6549 };
6550 }
6551
6552 List<AssetCategory> list = (List<AssetCategory>)FinderCacheUtil.getResult(finderPath,
6553 finderArgs, this);
6554
6555 if ((list != null) && !list.isEmpty()) {
6556 for (AssetCategory assetCategory : list) {
6557 if ((groupId != assetCategory.getGroupId()) ||
6558 (parentCategoryId != assetCategory.getParentCategoryId()) ||
6559 (vocabularyId != assetCategory.getVocabularyId())) {
6560 list = null;
6561
6562 break;
6563 }
6564 }
6565 }
6566
6567 if (list == null) {
6568 StringBundler query = null;
6569
6570 if (orderByComparator != null) {
6571 query = new StringBundler(5 +
6572 (orderByComparator.getOrderByFields().length * 3));
6573 }
6574 else {
6575 query = new StringBundler(5);
6576 }
6577
6578 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
6579
6580 query.append(_FINDER_COLUMN_G_P_V_GROUPID_2);
6581
6582 query.append(_FINDER_COLUMN_G_P_V_PARENTCATEGORYID_2);
6583
6584 query.append(_FINDER_COLUMN_G_P_V_VOCABULARYID_2);
6585
6586 if (orderByComparator != null) {
6587 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
6588 orderByComparator);
6589 }
6590 else
6591 if (pagination) {
6592 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
6593 }
6594
6595 String sql = query.toString();
6596
6597 Session session = null;
6598
6599 try {
6600 session = openSession();
6601
6602 Query q = session.createQuery(sql);
6603
6604 QueryPos qPos = QueryPos.getInstance(q);
6605
6606 qPos.add(groupId);
6607
6608 qPos.add(parentCategoryId);
6609
6610 qPos.add(vocabularyId);
6611
6612 if (!pagination) {
6613 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
6614 start, end, false);
6615
6616 Collections.sort(list);
6617
6618 list = new UnmodifiableList<AssetCategory>(list);
6619 }
6620 else {
6621 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
6622 start, end);
6623 }
6624
6625 cacheResult(list);
6626
6627 FinderCacheUtil.putResult(finderPath, finderArgs, list);
6628 }
6629 catch (Exception e) {
6630 FinderCacheUtil.removeResult(finderPath, finderArgs);
6631
6632 throw processException(e);
6633 }
6634 finally {
6635 closeSession(session);
6636 }
6637 }
6638
6639 return list;
6640 }
6641
6642
6653 @Override
6654 public AssetCategory findByG_P_V_First(long groupId, long parentCategoryId,
6655 long vocabularyId, OrderByComparator orderByComparator)
6656 throws NoSuchCategoryException, SystemException {
6657 AssetCategory assetCategory = fetchByG_P_V_First(groupId,
6658 parentCategoryId, vocabularyId, orderByComparator);
6659
6660 if (assetCategory != null) {
6661 return assetCategory;
6662 }
6663
6664 StringBundler msg = new StringBundler(8);
6665
6666 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
6667
6668 msg.append("groupId=");
6669 msg.append(groupId);
6670
6671 msg.append(", parentCategoryId=");
6672 msg.append(parentCategoryId);
6673
6674 msg.append(", vocabularyId=");
6675 msg.append(vocabularyId);
6676
6677 msg.append(StringPool.CLOSE_CURLY_BRACE);
6678
6679 throw new NoSuchCategoryException(msg.toString());
6680 }
6681
6682
6692 @Override
6693 public AssetCategory fetchByG_P_V_First(long groupId,
6694 long parentCategoryId, long vocabularyId,
6695 OrderByComparator orderByComparator) throws SystemException {
6696 List<AssetCategory> list = findByG_P_V(groupId, parentCategoryId,
6697 vocabularyId, 0, 1, orderByComparator);
6698
6699 if (!list.isEmpty()) {
6700 return list.get(0);
6701 }
6702
6703 return null;
6704 }
6705
6706
6717 @Override
6718 public AssetCategory findByG_P_V_Last(long groupId, long parentCategoryId,
6719 long vocabularyId, OrderByComparator orderByComparator)
6720 throws NoSuchCategoryException, SystemException {
6721 AssetCategory assetCategory = fetchByG_P_V_Last(groupId,
6722 parentCategoryId, vocabularyId, orderByComparator);
6723
6724 if (assetCategory != null) {
6725 return assetCategory;
6726 }
6727
6728 StringBundler msg = new StringBundler(8);
6729
6730 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
6731
6732 msg.append("groupId=");
6733 msg.append(groupId);
6734
6735 msg.append(", parentCategoryId=");
6736 msg.append(parentCategoryId);
6737
6738 msg.append(", vocabularyId=");
6739 msg.append(vocabularyId);
6740
6741 msg.append(StringPool.CLOSE_CURLY_BRACE);
6742
6743 throw new NoSuchCategoryException(msg.toString());
6744 }
6745
6746
6756 @Override
6757 public AssetCategory fetchByG_P_V_Last(long groupId, long parentCategoryId,
6758 long vocabularyId, OrderByComparator orderByComparator)
6759 throws SystemException {
6760 int count = countByG_P_V(groupId, parentCategoryId, vocabularyId);
6761
6762 if (count == 0) {
6763 return null;
6764 }
6765
6766 List<AssetCategory> list = findByG_P_V(groupId, parentCategoryId,
6767 vocabularyId, count - 1, count, orderByComparator);
6768
6769 if (!list.isEmpty()) {
6770 return list.get(0);
6771 }
6772
6773 return null;
6774 }
6775
6776
6788 @Override
6789 public AssetCategory[] findByG_P_V_PrevAndNext(long categoryId,
6790 long groupId, long parentCategoryId, long vocabularyId,
6791 OrderByComparator orderByComparator)
6792 throws NoSuchCategoryException, SystemException {
6793 AssetCategory assetCategory = findByPrimaryKey(categoryId);
6794
6795 Session session = null;
6796
6797 try {
6798 session = openSession();
6799
6800 AssetCategory[] array = new AssetCategoryImpl[3];
6801
6802 array[0] = getByG_P_V_PrevAndNext(session, assetCategory, groupId,
6803 parentCategoryId, vocabularyId, orderByComparator, true);
6804
6805 array[1] = assetCategory;
6806
6807 array[2] = getByG_P_V_PrevAndNext(session, assetCategory, groupId,
6808 parentCategoryId, vocabularyId, orderByComparator, false);
6809
6810 return array;
6811 }
6812 catch (Exception e) {
6813 throw processException(e);
6814 }
6815 finally {
6816 closeSession(session);
6817 }
6818 }
6819
6820 protected AssetCategory getByG_P_V_PrevAndNext(Session session,
6821 AssetCategory assetCategory, long groupId, long parentCategoryId,
6822 long vocabularyId, OrderByComparator orderByComparator, boolean previous) {
6823 StringBundler query = null;
6824
6825 if (orderByComparator != null) {
6826 query = new StringBundler(6 +
6827 (orderByComparator.getOrderByFields().length * 6));
6828 }
6829 else {
6830 query = new StringBundler(3);
6831 }
6832
6833 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
6834
6835 query.append(_FINDER_COLUMN_G_P_V_GROUPID_2);
6836
6837 query.append(_FINDER_COLUMN_G_P_V_PARENTCATEGORYID_2);
6838
6839 query.append(_FINDER_COLUMN_G_P_V_VOCABULARYID_2);
6840
6841 if (orderByComparator != null) {
6842 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
6843
6844 if (orderByConditionFields.length > 0) {
6845 query.append(WHERE_AND);
6846 }
6847
6848 for (int i = 0; i < orderByConditionFields.length; i++) {
6849 query.append(_ORDER_BY_ENTITY_ALIAS);
6850 query.append(orderByConditionFields[i]);
6851
6852 if ((i + 1) < orderByConditionFields.length) {
6853 if (orderByComparator.isAscending() ^ previous) {
6854 query.append(WHERE_GREATER_THAN_HAS_NEXT);
6855 }
6856 else {
6857 query.append(WHERE_LESSER_THAN_HAS_NEXT);
6858 }
6859 }
6860 else {
6861 if (orderByComparator.isAscending() ^ previous) {
6862 query.append(WHERE_GREATER_THAN);
6863 }
6864 else {
6865 query.append(WHERE_LESSER_THAN);
6866 }
6867 }
6868 }
6869
6870 query.append(ORDER_BY_CLAUSE);
6871
6872 String[] orderByFields = orderByComparator.getOrderByFields();
6873
6874 for (int i = 0; i < orderByFields.length; i++) {
6875 query.append(_ORDER_BY_ENTITY_ALIAS);
6876 query.append(orderByFields[i]);
6877
6878 if ((i + 1) < orderByFields.length) {
6879 if (orderByComparator.isAscending() ^ previous) {
6880 query.append(ORDER_BY_ASC_HAS_NEXT);
6881 }
6882 else {
6883 query.append(ORDER_BY_DESC_HAS_NEXT);
6884 }
6885 }
6886 else {
6887 if (orderByComparator.isAscending() ^ previous) {
6888 query.append(ORDER_BY_ASC);
6889 }
6890 else {
6891 query.append(ORDER_BY_DESC);
6892 }
6893 }
6894 }
6895 }
6896 else {
6897 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
6898 }
6899
6900 String sql = query.toString();
6901
6902 Query q = session.createQuery(sql);
6903
6904 q.setFirstResult(0);
6905 q.setMaxResults(2);
6906
6907 QueryPos qPos = QueryPos.getInstance(q);
6908
6909 qPos.add(groupId);
6910
6911 qPos.add(parentCategoryId);
6912
6913 qPos.add(vocabularyId);
6914
6915 if (orderByComparator != null) {
6916 Object[] values = orderByComparator.getOrderByConditionValues(assetCategory);
6917
6918 for (Object value : values) {
6919 qPos.add(value);
6920 }
6921 }
6922
6923 List<AssetCategory> list = q.list();
6924
6925 if (list.size() == 2) {
6926 return list.get(1);
6927 }
6928 else {
6929 return null;
6930 }
6931 }
6932
6933
6942 @Override
6943 public List<AssetCategory> filterFindByG_P_V(long groupId,
6944 long parentCategoryId, long vocabularyId) throws SystemException {
6945 return filterFindByG_P_V(groupId, parentCategoryId, vocabularyId,
6946 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
6947 }
6948
6949
6964 @Override
6965 public List<AssetCategory> filterFindByG_P_V(long groupId,
6966 long parentCategoryId, long vocabularyId, int start, int end)
6967 throws SystemException {
6968 return filterFindByG_P_V(groupId, parentCategoryId, vocabularyId,
6969 start, end, null);
6970 }
6971
6972
6988 @Override
6989 public List<AssetCategory> filterFindByG_P_V(long groupId,
6990 long parentCategoryId, long vocabularyId, int start, int end,
6991 OrderByComparator orderByComparator) throws SystemException {
6992 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
6993 return findByG_P_V(groupId, parentCategoryId, vocabularyId, start,
6994 end, orderByComparator);
6995 }
6996
6997 StringBundler query = null;
6998
6999 if (orderByComparator != null) {
7000 query = new StringBundler(5 +
7001 (orderByComparator.getOrderByFields().length * 3));
7002 }
7003 else {
7004 query = new StringBundler(5);
7005 }
7006
7007 if (getDB().isSupportsInlineDistinct()) {
7008 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_WHERE);
7009 }
7010 else {
7011 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_1);
7012 }
7013
7014 query.append(_FINDER_COLUMN_G_P_V_GROUPID_2);
7015
7016 query.append(_FINDER_COLUMN_G_P_V_PARENTCATEGORYID_2);
7017
7018 query.append(_FINDER_COLUMN_G_P_V_VOCABULARYID_2);
7019
7020 if (!getDB().isSupportsInlineDistinct()) {
7021 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_2);
7022 }
7023
7024 if (orderByComparator != null) {
7025 if (getDB().isSupportsInlineDistinct()) {
7026 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
7027 orderByComparator, true);
7028 }
7029 else {
7030 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
7031 orderByComparator, true);
7032 }
7033 }
7034 else {
7035 if (getDB().isSupportsInlineDistinct()) {
7036 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
7037 }
7038 else {
7039 query.append(AssetCategoryModelImpl.ORDER_BY_SQL);
7040 }
7041 }
7042
7043 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
7044 AssetCategory.class.getName(),
7045 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
7046
7047 Session session = null;
7048
7049 try {
7050 session = openSession();
7051
7052 SQLQuery q = session.createSQLQuery(sql);
7053
7054 if (getDB().isSupportsInlineDistinct()) {
7055 q.addEntity(_FILTER_ENTITY_ALIAS, AssetCategoryImpl.class);
7056 }
7057 else {
7058 q.addEntity(_FILTER_ENTITY_TABLE, AssetCategoryImpl.class);
7059 }
7060
7061 QueryPos qPos = QueryPos.getInstance(q);
7062
7063 qPos.add(groupId);
7064
7065 qPos.add(parentCategoryId);
7066
7067 qPos.add(vocabularyId);
7068
7069 return (List<AssetCategory>)QueryUtil.list(q, getDialect(), start,
7070 end);
7071 }
7072 catch (Exception e) {
7073 throw processException(e);
7074 }
7075 finally {
7076 closeSession(session);
7077 }
7078 }
7079
7080
7092 @Override
7093 public AssetCategory[] filterFindByG_P_V_PrevAndNext(long categoryId,
7094 long groupId, long parentCategoryId, long vocabularyId,
7095 OrderByComparator orderByComparator)
7096 throws NoSuchCategoryException, SystemException {
7097 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
7098 return findByG_P_V_PrevAndNext(categoryId, groupId,
7099 parentCategoryId, vocabularyId, orderByComparator);
7100 }
7101
7102 AssetCategory assetCategory = findByPrimaryKey(categoryId);
7103
7104 Session session = null;
7105
7106 try {
7107 session = openSession();
7108
7109 AssetCategory[] array = new AssetCategoryImpl[3];
7110
7111 array[0] = filterGetByG_P_V_PrevAndNext(session, assetCategory,
7112 groupId, parentCategoryId, vocabularyId, orderByComparator,
7113 true);
7114
7115 array[1] = assetCategory;
7116
7117 array[2] = filterGetByG_P_V_PrevAndNext(session, assetCategory,
7118 groupId, parentCategoryId, vocabularyId, orderByComparator,
7119 false);
7120
7121 return array;
7122 }
7123 catch (Exception e) {
7124 throw processException(e);
7125 }
7126 finally {
7127 closeSession(session);
7128 }
7129 }
7130
7131 protected AssetCategory filterGetByG_P_V_PrevAndNext(Session session,
7132 AssetCategory assetCategory, long groupId, long parentCategoryId,
7133 long vocabularyId, OrderByComparator orderByComparator, boolean previous) {
7134 StringBundler query = null;
7135
7136 if (orderByComparator != null) {
7137 query = new StringBundler(6 +
7138 (orderByComparator.getOrderByFields().length * 6));
7139 }
7140 else {
7141 query = new StringBundler(3);
7142 }
7143
7144 if (getDB().isSupportsInlineDistinct()) {
7145 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_WHERE);
7146 }
7147 else {
7148 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_1);
7149 }
7150
7151 query.append(_FINDER_COLUMN_G_P_V_GROUPID_2);
7152
7153 query.append(_FINDER_COLUMN_G_P_V_PARENTCATEGORYID_2);
7154
7155 query.append(_FINDER_COLUMN_G_P_V_VOCABULARYID_2);
7156
7157 if (!getDB().isSupportsInlineDistinct()) {
7158 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_2);
7159 }
7160
7161 if (orderByComparator != null) {
7162 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
7163
7164 if (orderByConditionFields.length > 0) {
7165 query.append(WHERE_AND);
7166 }
7167
7168 for (int i = 0; i < orderByConditionFields.length; i++) {
7169 if (getDB().isSupportsInlineDistinct()) {
7170 query.append(_ORDER_BY_ENTITY_ALIAS);
7171 }
7172 else {
7173 query.append(_ORDER_BY_ENTITY_TABLE);
7174 }
7175
7176 query.append(orderByConditionFields[i]);
7177
7178 if ((i + 1) < orderByConditionFields.length) {
7179 if (orderByComparator.isAscending() ^ previous) {
7180 query.append(WHERE_GREATER_THAN_HAS_NEXT);
7181 }
7182 else {
7183 query.append(WHERE_LESSER_THAN_HAS_NEXT);
7184 }
7185 }
7186 else {
7187 if (orderByComparator.isAscending() ^ previous) {
7188 query.append(WHERE_GREATER_THAN);
7189 }
7190 else {
7191 query.append(WHERE_LESSER_THAN);
7192 }
7193 }
7194 }
7195
7196 query.append(ORDER_BY_CLAUSE);
7197
7198 String[] orderByFields = orderByComparator.getOrderByFields();
7199
7200 for (int i = 0; i < orderByFields.length; i++) {
7201 if (getDB().isSupportsInlineDistinct()) {
7202 query.append(_ORDER_BY_ENTITY_ALIAS);
7203 }
7204 else {
7205 query.append(_ORDER_BY_ENTITY_TABLE);
7206 }
7207
7208 query.append(orderByFields[i]);
7209
7210 if ((i + 1) < orderByFields.length) {
7211 if (orderByComparator.isAscending() ^ previous) {
7212 query.append(ORDER_BY_ASC_HAS_NEXT);
7213 }
7214 else {
7215 query.append(ORDER_BY_DESC_HAS_NEXT);
7216 }
7217 }
7218 else {
7219 if (orderByComparator.isAscending() ^ previous) {
7220 query.append(ORDER_BY_ASC);
7221 }
7222 else {
7223 query.append(ORDER_BY_DESC);
7224 }
7225 }
7226 }
7227 }
7228 else {
7229 if (getDB().isSupportsInlineDistinct()) {
7230 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
7231 }
7232 else {
7233 query.append(AssetCategoryModelImpl.ORDER_BY_SQL);
7234 }
7235 }
7236
7237 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
7238 AssetCategory.class.getName(),
7239 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
7240
7241 SQLQuery q = session.createSQLQuery(sql);
7242
7243 q.setFirstResult(0);
7244 q.setMaxResults(2);
7245
7246 if (getDB().isSupportsInlineDistinct()) {
7247 q.addEntity(_FILTER_ENTITY_ALIAS, AssetCategoryImpl.class);
7248 }
7249 else {
7250 q.addEntity(_FILTER_ENTITY_TABLE, AssetCategoryImpl.class);
7251 }
7252
7253 QueryPos qPos = QueryPos.getInstance(q);
7254
7255 qPos.add(groupId);
7256
7257 qPos.add(parentCategoryId);
7258
7259 qPos.add(vocabularyId);
7260
7261 if (orderByComparator != null) {
7262 Object[] values = orderByComparator.getOrderByConditionValues(assetCategory);
7263
7264 for (Object value : values) {
7265 qPos.add(value);
7266 }
7267 }
7268
7269 List<AssetCategory> list = q.list();
7270
7271 if (list.size() == 2) {
7272 return list.get(1);
7273 }
7274 else {
7275 return null;
7276 }
7277 }
7278
7279
7287 @Override
7288 public void removeByG_P_V(long groupId, long parentCategoryId,
7289 long vocabularyId) throws SystemException {
7290 for (AssetCategory assetCategory : findByG_P_V(groupId,
7291 parentCategoryId, vocabularyId, QueryUtil.ALL_POS,
7292 QueryUtil.ALL_POS, null)) {
7293 remove(assetCategory);
7294 }
7295 }
7296
7297
7306 @Override
7307 public int countByG_P_V(long groupId, long parentCategoryId,
7308 long vocabularyId) throws SystemException {
7309 FinderPath finderPath = FINDER_PATH_COUNT_BY_G_P_V;
7310
7311 Object[] finderArgs = new Object[] {
7312 groupId, parentCategoryId, vocabularyId
7313 };
7314
7315 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
7316 this);
7317
7318 if (count == null) {
7319 StringBundler query = new StringBundler(4);
7320
7321 query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
7322
7323 query.append(_FINDER_COLUMN_G_P_V_GROUPID_2);
7324
7325 query.append(_FINDER_COLUMN_G_P_V_PARENTCATEGORYID_2);
7326
7327 query.append(_FINDER_COLUMN_G_P_V_VOCABULARYID_2);
7328
7329 String sql = query.toString();
7330
7331 Session session = null;
7332
7333 try {
7334 session = openSession();
7335
7336 Query q = session.createQuery(sql);
7337
7338 QueryPos qPos = QueryPos.getInstance(q);
7339
7340 qPos.add(groupId);
7341
7342 qPos.add(parentCategoryId);
7343
7344 qPos.add(vocabularyId);
7345
7346 count = (Long)q.uniqueResult();
7347
7348 FinderCacheUtil.putResult(finderPath, finderArgs, count);
7349 }
7350 catch (Exception e) {
7351 FinderCacheUtil.removeResult(finderPath, finderArgs);
7352
7353 throw processException(e);
7354 }
7355 finally {
7356 closeSession(session);
7357 }
7358 }
7359
7360 return count.intValue();
7361 }
7362
7363
7372 @Override
7373 public int filterCountByG_P_V(long groupId, long parentCategoryId,
7374 long vocabularyId) throws SystemException {
7375 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
7376 return countByG_P_V(groupId, parentCategoryId, vocabularyId);
7377 }
7378
7379 StringBundler query = new StringBundler(4);
7380
7381 query.append(_FILTER_SQL_COUNT_ASSETCATEGORY_WHERE);
7382
7383 query.append(_FINDER_COLUMN_G_P_V_GROUPID_2);
7384
7385 query.append(_FINDER_COLUMN_G_P_V_PARENTCATEGORYID_2);
7386
7387 query.append(_FINDER_COLUMN_G_P_V_VOCABULARYID_2);
7388
7389 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
7390 AssetCategory.class.getName(),
7391 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
7392
7393 Session session = null;
7394
7395 try {
7396 session = openSession();
7397
7398 SQLQuery q = session.createSQLQuery(sql);
7399
7400 q.addScalar(COUNT_COLUMN_NAME,
7401 com.liferay.portal.kernel.dao.orm.Type.LONG);
7402
7403 QueryPos qPos = QueryPos.getInstance(q);
7404
7405 qPos.add(groupId);
7406
7407 qPos.add(parentCategoryId);
7408
7409 qPos.add(vocabularyId);
7410
7411 Long count = (Long)q.uniqueResult();
7412
7413 return count.intValue();
7414 }
7415 catch (Exception e) {
7416 throw processException(e);
7417 }
7418 finally {
7419 closeSession(session);
7420 }
7421 }
7422
7423 private static final String _FINDER_COLUMN_G_P_V_GROUPID_2 = "assetCategory.groupId = ? AND ";
7424 private static final String _FINDER_COLUMN_G_P_V_PARENTCATEGORYID_2 = "assetCategory.parentCategoryId = ? AND ";
7425 private static final String _FINDER_COLUMN_G_P_V_VOCABULARYID_2 = "assetCategory.vocabularyId = ?";
7426 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_LIKEN_V =
7427 new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
7428 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
7429 AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
7430 "findByG_LikeN_V",
7431 new String[] {
7432 Long.class.getName(), String.class.getName(),
7433 Long.class.getName(),
7434
7435 Integer.class.getName(), Integer.class.getName(),
7436 OrderByComparator.class.getName()
7437 });
7438 public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_LIKEN_V =
7439 new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
7440 AssetCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class,
7441 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_LikeN_V",
7442 new String[] {
7443 Long.class.getName(), String.class.getName(),
7444 Long.class.getName()
7445 });
7446
7447
7456 @Override
7457 public List<AssetCategory> findByG_LikeN_V(long groupId, String name,
7458 long vocabularyId) throws SystemException {
7459 return findByG_LikeN_V(groupId, name, vocabularyId, QueryUtil.ALL_POS,
7460 QueryUtil.ALL_POS, null);
7461 }
7462
7463
7478 @Override
7479 public List<AssetCategory> findByG_LikeN_V(long groupId, String name,
7480 long vocabularyId, int start, int end) throws SystemException {
7481 return findByG_LikeN_V(groupId, name, vocabularyId, start, end, null);
7482 }
7483
7484
7500 @Override
7501 public List<AssetCategory> findByG_LikeN_V(long groupId, String name,
7502 long vocabularyId, int start, int end,
7503 OrderByComparator orderByComparator) throws SystemException {
7504 boolean pagination = true;
7505 FinderPath finderPath = null;
7506 Object[] finderArgs = null;
7507
7508 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_LIKEN_V;
7509 finderArgs = new Object[] {
7510 groupId, name, vocabularyId,
7511
7512 start, end, orderByComparator
7513 };
7514
7515 List<AssetCategory> list = (List<AssetCategory>)FinderCacheUtil.getResult(finderPath,
7516 finderArgs, this);
7517
7518 if ((list != null) && !list.isEmpty()) {
7519 for (AssetCategory assetCategory : list) {
7520 if ((groupId != assetCategory.getGroupId()) ||
7521 !Validator.equals(name, assetCategory.getName()) ||
7522 (vocabularyId != assetCategory.getVocabularyId())) {
7523 list = null;
7524
7525 break;
7526 }
7527 }
7528 }
7529
7530 if (list == null) {
7531 StringBundler query = null;
7532
7533 if (orderByComparator != null) {
7534 query = new StringBundler(5 +
7535 (orderByComparator.getOrderByFields().length * 3));
7536 }
7537 else {
7538 query = new StringBundler(5);
7539 }
7540
7541 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
7542
7543 query.append(_FINDER_COLUMN_G_LIKEN_V_GROUPID_2);
7544
7545 boolean bindName = false;
7546
7547 if (name == null) {
7548 query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_1);
7549 }
7550 else if (name.equals(StringPool.BLANK)) {
7551 query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_3);
7552 }
7553 else {
7554 bindName = true;
7555
7556 query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_2);
7557 }
7558
7559 query.append(_FINDER_COLUMN_G_LIKEN_V_VOCABULARYID_2);
7560
7561 if (orderByComparator != null) {
7562 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
7563 orderByComparator);
7564 }
7565 else
7566 if (pagination) {
7567 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
7568 }
7569
7570 String sql = query.toString();
7571
7572 Session session = null;
7573
7574 try {
7575 session = openSession();
7576
7577 Query q = session.createQuery(sql);
7578
7579 QueryPos qPos = QueryPos.getInstance(q);
7580
7581 qPos.add(groupId);
7582
7583 if (bindName) {
7584 qPos.add(name);
7585 }
7586
7587 qPos.add(vocabularyId);
7588
7589 if (!pagination) {
7590 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
7591 start, end, false);
7592
7593 Collections.sort(list);
7594
7595 list = new UnmodifiableList<AssetCategory>(list);
7596 }
7597 else {
7598 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
7599 start, end);
7600 }
7601
7602 cacheResult(list);
7603
7604 FinderCacheUtil.putResult(finderPath, finderArgs, list);
7605 }
7606 catch (Exception e) {
7607 FinderCacheUtil.removeResult(finderPath, finderArgs);
7608
7609 throw processException(e);
7610 }
7611 finally {
7612 closeSession(session);
7613 }
7614 }
7615
7616 return list;
7617 }
7618
7619
7630 @Override
7631 public AssetCategory findByG_LikeN_V_First(long groupId, String name,
7632 long vocabularyId, OrderByComparator orderByComparator)
7633 throws NoSuchCategoryException, SystemException {
7634 AssetCategory assetCategory = fetchByG_LikeN_V_First(groupId, name,
7635 vocabularyId, orderByComparator);
7636
7637 if (assetCategory != null) {
7638 return assetCategory;
7639 }
7640
7641 StringBundler msg = new StringBundler(8);
7642
7643 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
7644
7645 msg.append("groupId=");
7646 msg.append(groupId);
7647
7648 msg.append(", name=");
7649 msg.append(name);
7650
7651 msg.append(", vocabularyId=");
7652 msg.append(vocabularyId);
7653
7654 msg.append(StringPool.CLOSE_CURLY_BRACE);
7655
7656 throw new NoSuchCategoryException(msg.toString());
7657 }
7658
7659
7669 @Override
7670 public AssetCategory fetchByG_LikeN_V_First(long groupId, String name,
7671 long vocabularyId, OrderByComparator orderByComparator)
7672 throws SystemException {
7673 List<AssetCategory> list = findByG_LikeN_V(groupId, name, vocabularyId,
7674 0, 1, orderByComparator);
7675
7676 if (!list.isEmpty()) {
7677 return list.get(0);
7678 }
7679
7680 return null;
7681 }
7682
7683
7694 @Override
7695 public AssetCategory findByG_LikeN_V_Last(long groupId, String name,
7696 long vocabularyId, OrderByComparator orderByComparator)
7697 throws NoSuchCategoryException, SystemException {
7698 AssetCategory assetCategory = fetchByG_LikeN_V_Last(groupId, name,
7699 vocabularyId, orderByComparator);
7700
7701 if (assetCategory != null) {
7702 return assetCategory;
7703 }
7704
7705 StringBundler msg = new StringBundler(8);
7706
7707 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
7708
7709 msg.append("groupId=");
7710 msg.append(groupId);
7711
7712 msg.append(", name=");
7713 msg.append(name);
7714
7715 msg.append(", vocabularyId=");
7716 msg.append(vocabularyId);
7717
7718 msg.append(StringPool.CLOSE_CURLY_BRACE);
7719
7720 throw new NoSuchCategoryException(msg.toString());
7721 }
7722
7723
7733 @Override
7734 public AssetCategory fetchByG_LikeN_V_Last(long groupId, String name,
7735 long vocabularyId, OrderByComparator orderByComparator)
7736 throws SystemException {
7737 int count = countByG_LikeN_V(groupId, name, vocabularyId);
7738
7739 if (count == 0) {
7740 return null;
7741 }
7742
7743 List<AssetCategory> list = findByG_LikeN_V(groupId, name, vocabularyId,
7744 count - 1, count, orderByComparator);
7745
7746 if (!list.isEmpty()) {
7747 return list.get(0);
7748 }
7749
7750 return null;
7751 }
7752
7753
7765 @Override
7766 public AssetCategory[] findByG_LikeN_V_PrevAndNext(long categoryId,
7767 long groupId, String name, long vocabularyId,
7768 OrderByComparator orderByComparator)
7769 throws NoSuchCategoryException, SystemException {
7770 AssetCategory assetCategory = findByPrimaryKey(categoryId);
7771
7772 Session session = null;
7773
7774 try {
7775 session = openSession();
7776
7777 AssetCategory[] array = new AssetCategoryImpl[3];
7778
7779 array[0] = getByG_LikeN_V_PrevAndNext(session, assetCategory,
7780 groupId, name, vocabularyId, orderByComparator, true);
7781
7782 array[1] = assetCategory;
7783
7784 array[2] = getByG_LikeN_V_PrevAndNext(session, assetCategory,
7785 groupId, name, vocabularyId, orderByComparator, false);
7786
7787 return array;
7788 }
7789 catch (Exception e) {
7790 throw processException(e);
7791 }
7792 finally {
7793 closeSession(session);
7794 }
7795 }
7796
7797 protected AssetCategory getByG_LikeN_V_PrevAndNext(Session session,
7798 AssetCategory assetCategory, long groupId, String name,
7799 long vocabularyId, OrderByComparator orderByComparator, boolean previous) {
7800 StringBundler query = null;
7801
7802 if (orderByComparator != null) {
7803 query = new StringBundler(6 +
7804 (orderByComparator.getOrderByFields().length * 6));
7805 }
7806 else {
7807 query = new StringBundler(3);
7808 }
7809
7810 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
7811
7812 query.append(_FINDER_COLUMN_G_LIKEN_V_GROUPID_2);
7813
7814 boolean bindName = false;
7815
7816 if (name == null) {
7817 query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_1);
7818 }
7819 else if (name.equals(StringPool.BLANK)) {
7820 query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_3);
7821 }
7822 else {
7823 bindName = true;
7824
7825 query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_2);
7826 }
7827
7828 query.append(_FINDER_COLUMN_G_LIKEN_V_VOCABULARYID_2);
7829
7830 if (orderByComparator != null) {
7831 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
7832
7833 if (orderByConditionFields.length > 0) {
7834 query.append(WHERE_AND);
7835 }
7836
7837 for (int i = 0; i < orderByConditionFields.length; i++) {
7838 query.append(_ORDER_BY_ENTITY_ALIAS);
7839 query.append(orderByConditionFields[i]);
7840
7841 if ((i + 1) < orderByConditionFields.length) {
7842 if (orderByComparator.isAscending() ^ previous) {
7843 query.append(WHERE_GREATER_THAN_HAS_NEXT);
7844 }
7845 else {
7846 query.append(WHERE_LESSER_THAN_HAS_NEXT);
7847 }
7848 }
7849 else {
7850 if (orderByComparator.isAscending() ^ previous) {
7851 query.append(WHERE_GREATER_THAN);
7852 }
7853 else {
7854 query.append(WHERE_LESSER_THAN);
7855 }
7856 }
7857 }
7858
7859 query.append(ORDER_BY_CLAUSE);
7860
7861 String[] orderByFields = orderByComparator.getOrderByFields();
7862
7863 for (int i = 0; i < orderByFields.length; i++) {
7864 query.append(_ORDER_BY_ENTITY_ALIAS);
7865 query.append(orderByFields[i]);
7866
7867 if ((i + 1) < orderByFields.length) {
7868 if (orderByComparator.isAscending() ^ previous) {
7869 query.append(ORDER_BY_ASC_HAS_NEXT);
7870 }
7871 else {
7872 query.append(ORDER_BY_DESC_HAS_NEXT);
7873 }
7874 }
7875 else {
7876 if (orderByComparator.isAscending() ^ previous) {
7877 query.append(ORDER_BY_ASC);
7878 }
7879 else {
7880 query.append(ORDER_BY_DESC);
7881 }
7882 }
7883 }
7884 }
7885 else {
7886 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
7887 }
7888
7889 String sql = query.toString();
7890
7891 Query q = session.createQuery(sql);
7892
7893 q.setFirstResult(0);
7894 q.setMaxResults(2);
7895
7896 QueryPos qPos = QueryPos.getInstance(q);
7897
7898 qPos.add(groupId);
7899
7900 if (bindName) {
7901 qPos.add(name);
7902 }
7903
7904 qPos.add(vocabularyId);
7905
7906 if (orderByComparator != null) {
7907 Object[] values = orderByComparator.getOrderByConditionValues(assetCategory);
7908
7909 for (Object value : values) {
7910 qPos.add(value);
7911 }
7912 }
7913
7914 List<AssetCategory> list = q.list();
7915
7916 if (list.size() == 2) {
7917 return list.get(1);
7918 }
7919 else {
7920 return null;
7921 }
7922 }
7923
7924
7933 @Override
7934 public List<AssetCategory> filterFindByG_LikeN_V(long groupId, String name,
7935 long vocabularyId) throws SystemException {
7936 return filterFindByG_LikeN_V(groupId, name, vocabularyId,
7937 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
7938 }
7939
7940
7955 @Override
7956 public List<AssetCategory> filterFindByG_LikeN_V(long groupId, String name,
7957 long vocabularyId, int start, int end) throws SystemException {
7958 return filterFindByG_LikeN_V(groupId, name, vocabularyId, start, end,
7959 null);
7960 }
7961
7962
7978 @Override
7979 public List<AssetCategory> filterFindByG_LikeN_V(long groupId, String name,
7980 long vocabularyId, int start, int end,
7981 OrderByComparator orderByComparator) throws SystemException {
7982 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
7983 return findByG_LikeN_V(groupId, name, vocabularyId, start, end,
7984 orderByComparator);
7985 }
7986
7987 StringBundler query = null;
7988
7989 if (orderByComparator != null) {
7990 query = new StringBundler(5 +
7991 (orderByComparator.getOrderByFields().length * 3));
7992 }
7993 else {
7994 query = new StringBundler(5);
7995 }
7996
7997 if (getDB().isSupportsInlineDistinct()) {
7998 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_WHERE);
7999 }
8000 else {
8001 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_1);
8002 }
8003
8004 query.append(_FINDER_COLUMN_G_LIKEN_V_GROUPID_2);
8005
8006 boolean bindName = false;
8007
8008 if (name == null) {
8009 query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_1);
8010 }
8011 else if (name.equals(StringPool.BLANK)) {
8012 query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_3);
8013 }
8014 else {
8015 bindName = true;
8016
8017 query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_2);
8018 }
8019
8020 query.append(_FINDER_COLUMN_G_LIKEN_V_VOCABULARYID_2);
8021
8022 if (!getDB().isSupportsInlineDistinct()) {
8023 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_2);
8024 }
8025
8026 if (orderByComparator != null) {
8027 if (getDB().isSupportsInlineDistinct()) {
8028 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
8029 orderByComparator, true);
8030 }
8031 else {
8032 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
8033 orderByComparator, true);
8034 }
8035 }
8036 else {
8037 if (getDB().isSupportsInlineDistinct()) {
8038 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
8039 }
8040 else {
8041 query.append(AssetCategoryModelImpl.ORDER_BY_SQL);
8042 }
8043 }
8044
8045 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
8046 AssetCategory.class.getName(),
8047 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
8048
8049 Session session = null;
8050
8051 try {
8052 session = openSession();
8053
8054 SQLQuery q = session.createSQLQuery(sql);
8055
8056 if (getDB().isSupportsInlineDistinct()) {
8057 q.addEntity(_FILTER_ENTITY_ALIAS, AssetCategoryImpl.class);
8058 }
8059 else {
8060 q.addEntity(_FILTER_ENTITY_TABLE, AssetCategoryImpl.class);
8061 }
8062
8063 QueryPos qPos = QueryPos.getInstance(q);
8064
8065 qPos.add(groupId);
8066
8067 if (bindName) {
8068 qPos.add(name);
8069 }
8070
8071 qPos.add(vocabularyId);
8072
8073 return (List<AssetCategory>)QueryUtil.list(q, getDialect(), start,
8074 end);
8075 }
8076 catch (Exception e) {
8077 throw processException(e);
8078 }
8079 finally {
8080 closeSession(session);
8081 }
8082 }
8083
8084
8096 @Override
8097 public AssetCategory[] filterFindByG_LikeN_V_PrevAndNext(long categoryId,
8098 long groupId, String name, long vocabularyId,
8099 OrderByComparator orderByComparator)
8100 throws NoSuchCategoryException, SystemException {
8101 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
8102 return findByG_LikeN_V_PrevAndNext(categoryId, groupId, name,
8103 vocabularyId, orderByComparator);
8104 }
8105
8106 AssetCategory assetCategory = findByPrimaryKey(categoryId);
8107
8108 Session session = null;
8109
8110 try {
8111 session = openSession();
8112
8113 AssetCategory[] array = new AssetCategoryImpl[3];
8114
8115 array[0] = filterGetByG_LikeN_V_PrevAndNext(session, assetCategory,
8116 groupId, name, vocabularyId, orderByComparator, true);
8117
8118 array[1] = assetCategory;
8119
8120 array[2] = filterGetByG_LikeN_V_PrevAndNext(session, assetCategory,
8121 groupId, name, vocabularyId, orderByComparator, false);
8122
8123 return array;
8124 }
8125 catch (Exception e) {
8126 throw processException(e);
8127 }
8128 finally {
8129 closeSession(session);
8130 }
8131 }
8132
8133 protected AssetCategory filterGetByG_LikeN_V_PrevAndNext(Session session,
8134 AssetCategory assetCategory, long groupId, String name,
8135 long vocabularyId, OrderByComparator orderByComparator, boolean previous) {
8136 StringBundler query = null;
8137
8138 if (orderByComparator != null) {
8139 query = new StringBundler(6 +
8140 (orderByComparator.getOrderByFields().length * 6));
8141 }
8142 else {
8143 query = new StringBundler(3);
8144 }
8145
8146 if (getDB().isSupportsInlineDistinct()) {
8147 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_WHERE);
8148 }
8149 else {
8150 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_1);
8151 }
8152
8153 query.append(_FINDER_COLUMN_G_LIKEN_V_GROUPID_2);
8154
8155 boolean bindName = false;
8156
8157 if (name == null) {
8158 query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_1);
8159 }
8160 else if (name.equals(StringPool.BLANK)) {
8161 query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_3);
8162 }
8163 else {
8164 bindName = true;
8165
8166 query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_2);
8167 }
8168
8169 query.append(_FINDER_COLUMN_G_LIKEN_V_VOCABULARYID_2);
8170
8171 if (!getDB().isSupportsInlineDistinct()) {
8172 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_2);
8173 }
8174
8175 if (orderByComparator != null) {
8176 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
8177
8178 if (orderByConditionFields.length > 0) {
8179 query.append(WHERE_AND);
8180 }
8181
8182 for (int i = 0; i < orderByConditionFields.length; i++) {
8183 if (getDB().isSupportsInlineDistinct()) {
8184 query.append(_ORDER_BY_ENTITY_ALIAS);
8185 }
8186 else {
8187 query.append(_ORDER_BY_ENTITY_TABLE);
8188 }
8189
8190 query.append(orderByConditionFields[i]);
8191
8192 if ((i + 1) < orderByConditionFields.length) {
8193 if (orderByComparator.isAscending() ^ previous) {
8194 query.append(WHERE_GREATER_THAN_HAS_NEXT);
8195 }
8196 else {
8197 query.append(WHERE_LESSER_THAN_HAS_NEXT);
8198 }
8199 }
8200 else {
8201 if (orderByComparator.isAscending() ^ previous) {
8202 query.append(WHERE_GREATER_THAN);
8203 }
8204 else {
8205 query.append(WHERE_LESSER_THAN);
8206 }
8207 }
8208 }
8209
8210 query.append(ORDER_BY_CLAUSE);
8211
8212 String[] orderByFields = orderByComparator.getOrderByFields();
8213
8214 for (int i = 0; i < orderByFields.length; i++) {
8215 if (getDB().isSupportsInlineDistinct()) {
8216 query.append(_ORDER_BY_ENTITY_ALIAS);
8217 }
8218 else {
8219 query.append(_ORDER_BY_ENTITY_TABLE);
8220 }
8221
8222 query.append(orderByFields[i]);
8223
8224 if ((i + 1) < orderByFields.length) {
8225 if (orderByComparator.isAscending() ^ previous) {
8226 query.append(ORDER_BY_ASC_HAS_NEXT);
8227 }
8228 else {
8229 query.append(ORDER_BY_DESC_HAS_NEXT);
8230 }
8231 }
8232 else {
8233 if (orderByComparator.isAscending() ^ previous) {
8234 query.append(ORDER_BY_ASC);
8235 }
8236 else {
8237 query.append(ORDER_BY_DESC);
8238 }
8239 }
8240 }
8241 }
8242 else {
8243 if (getDB().isSupportsInlineDistinct()) {
8244 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
8245 }
8246 else {
8247 query.append(AssetCategoryModelImpl.ORDER_BY_SQL);
8248 }
8249 }
8250
8251 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
8252 AssetCategory.class.getName(),
8253 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
8254
8255 SQLQuery q = session.createSQLQuery(sql);
8256
8257 q.setFirstResult(0);
8258 q.setMaxResults(2);
8259
8260 if (getDB().isSupportsInlineDistinct()) {
8261 q.addEntity(_FILTER_ENTITY_ALIAS, AssetCategoryImpl.class);
8262 }
8263 else {
8264 q.addEntity(_FILTER_ENTITY_TABLE, AssetCategoryImpl.class);
8265 }
8266
8267 QueryPos qPos = QueryPos.getInstance(q);
8268
8269 qPos.add(groupId);
8270
8271 if (bindName) {
8272 qPos.add(name);
8273 }
8274
8275 qPos.add(vocabularyId);
8276
8277 if (orderByComparator != null) {
8278 Object[] values = orderByComparator.getOrderByConditionValues(assetCategory);
8279
8280 for (Object value : values) {
8281 qPos.add(value);
8282 }
8283 }
8284
8285 List<AssetCategory> list = q.list();
8286
8287 if (list.size() == 2) {
8288 return list.get(1);
8289 }
8290 else {
8291 return null;
8292 }
8293 }
8294
8295
8304 @Override
8305 public List<AssetCategory> filterFindByG_LikeN_V(long groupId, String name,
8306 long[] vocabularyIds) throws SystemException {
8307 return filterFindByG_LikeN_V(groupId, name, vocabularyIds,
8308 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
8309 }
8310
8311
8326 @Override
8327 public List<AssetCategory> filterFindByG_LikeN_V(long groupId, String name,
8328 long[] vocabularyIds, int start, int end) throws SystemException {
8329 return filterFindByG_LikeN_V(groupId, name, vocabularyIds, start, end,
8330 null);
8331 }
8332
8333
8349 @Override
8350 public List<AssetCategory> filterFindByG_LikeN_V(long groupId, String name,
8351 long[] vocabularyIds, int start, int end,
8352 OrderByComparator orderByComparator) throws SystemException {
8353 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
8354 return findByG_LikeN_V(groupId, name, vocabularyIds, start, end,
8355 orderByComparator);
8356 }
8357
8358 StringBundler query = new StringBundler();
8359
8360 if (getDB().isSupportsInlineDistinct()) {
8361 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_WHERE);
8362 }
8363 else {
8364 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_1);
8365 }
8366
8367 boolean conjunctionable = false;
8368
8369 if (conjunctionable) {
8370 query.append(WHERE_AND);
8371 }
8372
8373 query.append(_FINDER_COLUMN_G_LIKEN_V_GROUPID_5);
8374
8375 conjunctionable = true;
8376
8377 if (conjunctionable) {
8378 query.append(WHERE_AND);
8379 }
8380
8381 if (name == null) {
8382 query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_4);
8383 }
8384 else if (name.equals(StringPool.BLANK)) {
8385 query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_6);
8386 }
8387 else {
8388 query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_5);
8389 }
8390
8391 conjunctionable = true;
8392
8393 if ((vocabularyIds == null) || (vocabularyIds.length > 0)) {
8394 if (conjunctionable) {
8395 query.append(WHERE_AND);
8396 }
8397
8398 query.append(StringPool.OPEN_PARENTHESIS);
8399
8400 for (int i = 0; i < vocabularyIds.length; i++) {
8401 query.append(_FINDER_COLUMN_G_LIKEN_V_VOCABULARYID_5);
8402
8403 if ((i + 1) < vocabularyIds.length) {
8404 query.append(WHERE_OR);
8405 }
8406 }
8407
8408 query.append(StringPool.CLOSE_PARENTHESIS);
8409
8410 conjunctionable = true;
8411 }
8412
8413 if (!getDB().isSupportsInlineDistinct()) {
8414 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_2);
8415 }
8416
8417 if (orderByComparator != null) {
8418 if (getDB().isSupportsInlineDistinct()) {
8419 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
8420 orderByComparator, true);
8421 }
8422 else {
8423 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
8424 orderByComparator, true);
8425 }
8426 }
8427 else {
8428 if (getDB().isSupportsInlineDistinct()) {
8429 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
8430 }
8431 else {
8432 query.append(AssetCategoryModelImpl.ORDER_BY_SQL);
8433 }
8434 }
8435
8436 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
8437 AssetCategory.class.getName(),
8438 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
8439
8440 Session session = null;
8441
8442 try {
8443 session = openSession();
8444
8445 SQLQuery q = session.createSQLQuery(sql);
8446
8447 if (getDB().isSupportsInlineDistinct()) {
8448 q.addEntity(_FILTER_ENTITY_ALIAS, AssetCategoryImpl.class);
8449 }
8450 else {
8451 q.addEntity(_FILTER_ENTITY_TABLE, AssetCategoryImpl.class);
8452 }
8453
8454 QueryPos qPos = QueryPos.getInstance(q);
8455
8456 qPos.add(groupId);
8457
8458 if (name != null) {
8459 qPos.add(name);
8460 }
8461
8462 if (vocabularyIds != null) {
8463 qPos.add(vocabularyIds);
8464 }
8465
8466 return (List<AssetCategory>)QueryUtil.list(q, getDialect(), start,
8467 end);
8468 }
8469 catch (Exception e) {
8470 throw processException(e);
8471 }
8472 finally {
8473 closeSession(session);
8474 }
8475 }
8476
8477
8490 @Override
8491 public List<AssetCategory> findByG_LikeN_V(long groupId, String name,
8492 long[] vocabularyIds) throws SystemException {
8493 return findByG_LikeN_V(groupId, name, vocabularyIds, QueryUtil.ALL_POS,
8494 QueryUtil.ALL_POS, null);
8495 }
8496
8497
8512 @Override
8513 public List<AssetCategory> findByG_LikeN_V(long groupId, String name,
8514 long[] vocabularyIds, int start, int end) throws SystemException {
8515 return findByG_LikeN_V(groupId, name, vocabularyIds, start, end, null);
8516 }
8517
8518
8534 @Override
8535 public List<AssetCategory> findByG_LikeN_V(long groupId, String name,
8536 long[] vocabularyIds, int start, int end,
8537 OrderByComparator orderByComparator) throws SystemException {
8538 if ((vocabularyIds != null) && (vocabularyIds.length == 1)) {
8539 return findByG_LikeN_V(groupId, name, vocabularyIds[0], start, end,
8540 orderByComparator);
8541 }
8542
8543 boolean pagination = true;
8544 Object[] finderArgs = null;
8545
8546 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
8547 (orderByComparator == null)) {
8548 pagination = false;
8549 finderArgs = new Object[] {
8550 groupId, name, StringUtil.merge(vocabularyIds)
8551 };
8552 }
8553 else {
8554 finderArgs = new Object[] {
8555 groupId, name, StringUtil.merge(vocabularyIds),
8556
8557 start, end, orderByComparator
8558 };
8559 }
8560
8561 List<AssetCategory> list = (List<AssetCategory>)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_LIKEN_V,
8562 finderArgs, this);
8563
8564 if ((list != null) && !list.isEmpty()) {
8565 for (AssetCategory assetCategory : list) {
8566 if ((groupId != assetCategory.getGroupId()) ||
8567 !Validator.equals(name, assetCategory.getName()) ||
8568 !ArrayUtil.contains(vocabularyIds,
8569 assetCategory.getVocabularyId())) {
8570 list = null;
8571
8572 break;
8573 }
8574 }
8575 }
8576
8577 if (list == null) {
8578 StringBundler query = new StringBundler();
8579
8580 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
8581
8582 boolean conjunctionable = false;
8583
8584 if (conjunctionable) {
8585 query.append(WHERE_AND);
8586 }
8587
8588 query.append(_FINDER_COLUMN_G_LIKEN_V_GROUPID_5);
8589
8590 conjunctionable = true;
8591
8592 if (conjunctionable) {
8593 query.append(WHERE_AND);
8594 }
8595
8596 if (name == null) {
8597 query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_4);
8598 }
8599 else if (name.equals(StringPool.BLANK)) {
8600 query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_6);
8601 }
8602 else {
8603 query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_5);
8604 }
8605
8606 conjunctionable = true;
8607
8608 if ((vocabularyIds == null) || (vocabularyIds.length > 0)) {
8609 if (conjunctionable) {
8610 query.append(WHERE_AND);
8611 }
8612
8613 query.append(StringPool.OPEN_PARENTHESIS);
8614
8615 for (int i = 0; i < vocabularyIds.length; i++) {
8616 query.append(_FINDER_COLUMN_G_LIKEN_V_VOCABULARYID_5);
8617
8618 if ((i + 1) < vocabularyIds.length) {
8619 query.append(WHERE_OR);
8620 }
8621 }
8622
8623 query.append(StringPool.CLOSE_PARENTHESIS);
8624
8625 conjunctionable = true;
8626 }
8627
8628 if (orderByComparator != null) {
8629 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
8630 orderByComparator);
8631 }
8632 else
8633 if (pagination) {
8634 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
8635 }
8636
8637 String sql = query.toString();
8638
8639 Session session = null;
8640
8641 try {
8642 session = openSession();
8643
8644 Query q = session.createQuery(sql);
8645
8646 QueryPos qPos = QueryPos.getInstance(q);
8647
8648 qPos.add(groupId);
8649
8650 if (name != null) {
8651 qPos.add(name);
8652 }
8653
8654 if (vocabularyIds != null) {
8655 qPos.add(vocabularyIds);
8656 }
8657
8658 if (!pagination) {
8659 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
8660 start, end, false);
8661
8662 Collections.sort(list);
8663
8664 list = new UnmodifiableList<AssetCategory>(list);
8665 }
8666 else {
8667 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
8668 start, end);
8669 }
8670
8671 cacheResult(list);
8672
8673 FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_LIKEN_V,
8674 finderArgs, list);
8675 }
8676 catch (Exception e) {
8677 FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_LIKEN_V,
8678 finderArgs);
8679
8680 throw processException(e);
8681 }
8682 finally {
8683 closeSession(session);
8684 }
8685 }
8686
8687 return list;
8688 }
8689
8690
8698 @Override
8699 public void removeByG_LikeN_V(long groupId, String name, long vocabularyId)
8700 throws SystemException {
8701 for (AssetCategory assetCategory : findByG_LikeN_V(groupId, name,
8702 vocabularyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
8703 remove(assetCategory);
8704 }
8705 }
8706
8707
8716 @Override
8717 public int countByG_LikeN_V(long groupId, String name, long vocabularyId)
8718 throws SystemException {
8719 FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_LIKEN_V;
8720
8721 Object[] finderArgs = new Object[] { groupId, name, vocabularyId };
8722
8723 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
8724 this);
8725
8726 if (count == null) {
8727 StringBundler query = new StringBundler(4);
8728
8729 query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
8730
8731 query.append(_FINDER_COLUMN_G_LIKEN_V_GROUPID_2);
8732
8733 boolean bindName = false;
8734
8735 if (name == null) {
8736 query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_1);
8737 }
8738 else if (name.equals(StringPool.BLANK)) {
8739 query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_3);
8740 }
8741 else {
8742 bindName = true;
8743
8744 query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_2);
8745 }
8746
8747 query.append(_FINDER_COLUMN_G_LIKEN_V_VOCABULARYID_2);
8748
8749 String sql = query.toString();
8750
8751 Session session = null;
8752
8753 try {
8754 session = openSession();
8755
8756 Query q = session.createQuery(sql);
8757
8758 QueryPos qPos = QueryPos.getInstance(q);
8759
8760 qPos.add(groupId);
8761
8762 if (bindName) {
8763 qPos.add(name);
8764 }
8765
8766 qPos.add(vocabularyId);
8767
8768 count = (Long)q.uniqueResult();
8769
8770 FinderCacheUtil.putResult(finderPath, finderArgs, count);
8771 }
8772 catch (Exception e) {
8773 FinderCacheUtil.removeResult(finderPath, finderArgs);
8774
8775 throw processException(e);
8776 }
8777 finally {
8778 closeSession(session);
8779 }
8780 }
8781
8782 return count.intValue();
8783 }
8784
8785
8794 @Override
8795 public int countByG_LikeN_V(long groupId, String name, long[] vocabularyIds)
8796 throws SystemException {
8797 Object[] finderArgs = new Object[] {
8798 groupId, name, StringUtil.merge(vocabularyIds)
8799 };
8800
8801 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_LIKEN_V,
8802 finderArgs, this);
8803
8804 if (count == null) {
8805 StringBundler query = new StringBundler();
8806
8807 query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
8808
8809 boolean conjunctionable = false;
8810
8811 if (conjunctionable) {
8812 query.append(WHERE_AND);
8813 }
8814
8815 query.append(_FINDER_COLUMN_G_LIKEN_V_GROUPID_5);
8816
8817 conjunctionable = true;
8818
8819 if (conjunctionable) {
8820 query.append(WHERE_AND);
8821 }
8822
8823 if (name == null) {
8824 query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_4);
8825 }
8826 else if (name.equals(StringPool.BLANK)) {
8827 query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_6);
8828 }
8829 else {
8830 query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_5);
8831 }
8832
8833 conjunctionable = true;
8834
8835 if ((vocabularyIds == null) || (vocabularyIds.length > 0)) {
8836 if (conjunctionable) {
8837 query.append(WHERE_AND);
8838 }
8839
8840 query.append(StringPool.OPEN_PARENTHESIS);
8841
8842 for (int i = 0; i < vocabularyIds.length; i++) {
8843 query.append(_FINDER_COLUMN_G_LIKEN_V_VOCABULARYID_5);
8844
8845 if ((i + 1) < vocabularyIds.length) {
8846 query.append(WHERE_OR);
8847 }
8848 }
8849
8850 query.append(StringPool.CLOSE_PARENTHESIS);
8851
8852 conjunctionable = true;
8853 }
8854
8855 String sql = query.toString();
8856
8857 Session session = null;
8858
8859 try {
8860 session = openSession();
8861
8862 Query q = session.createQuery(sql);
8863
8864 QueryPos qPos = QueryPos.getInstance(q);
8865
8866 qPos.add(groupId);
8867
8868 if (name != null) {
8869 qPos.add(name);
8870 }
8871
8872 if (vocabularyIds != null) {
8873 qPos.add(vocabularyIds);
8874 }
8875
8876 count = (Long)q.uniqueResult();
8877
8878 FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_LIKEN_V,
8879 finderArgs, count);
8880 }
8881 catch (Exception e) {
8882 FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_LIKEN_V,
8883 finderArgs);
8884
8885 throw processException(e);
8886 }
8887 finally {
8888 closeSession(session);
8889 }
8890 }
8891
8892 return count.intValue();
8893 }
8894
8895
8904 @Override
8905 public int filterCountByG_LikeN_V(long groupId, String name,
8906 long vocabularyId) throws SystemException {
8907 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
8908 return countByG_LikeN_V(groupId, name, vocabularyId);
8909 }
8910
8911 StringBundler query = new StringBundler(4);
8912
8913 query.append(_FILTER_SQL_COUNT_ASSETCATEGORY_WHERE);
8914
8915 query.append(_FINDER_COLUMN_G_LIKEN_V_GROUPID_2);
8916
8917 boolean bindName = false;
8918
8919 if (name == null) {
8920 query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_1);
8921 }
8922 else if (name.equals(StringPool.BLANK)) {
8923 query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_3);
8924 }
8925 else {
8926 bindName = true;
8927
8928 query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_2);
8929 }
8930
8931 query.append(_FINDER_COLUMN_G_LIKEN_V_VOCABULARYID_2);
8932
8933 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
8934 AssetCategory.class.getName(),
8935 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
8936
8937 Session session = null;
8938
8939 try {
8940 session = openSession();
8941
8942 SQLQuery q = session.createSQLQuery(sql);
8943
8944 q.addScalar(COUNT_COLUMN_NAME,
8945 com.liferay.portal.kernel.dao.orm.Type.LONG);
8946
8947 QueryPos qPos = QueryPos.getInstance(q);
8948
8949 qPos.add(groupId);
8950
8951 if (bindName) {
8952 qPos.add(name);
8953 }
8954
8955 qPos.add(vocabularyId);
8956
8957 Long count = (Long)q.uniqueResult();
8958
8959 return count.intValue();
8960 }
8961 catch (Exception e) {
8962 throw processException(e);
8963 }
8964 finally {
8965 closeSession(session);
8966 }
8967 }
8968
8969
8978 @Override
8979 public int filterCountByG_LikeN_V(long groupId, String name,
8980 long[] vocabularyIds) throws SystemException {
8981 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
8982 return countByG_LikeN_V(groupId, name, vocabularyIds);
8983 }
8984
8985 StringBundler query = new StringBundler();
8986
8987 query.append(_FILTER_SQL_COUNT_ASSETCATEGORY_WHERE);
8988
8989 boolean conjunctionable = false;
8990
8991 if (conjunctionable) {
8992 query.append(WHERE_AND);
8993 }
8994
8995 query.append(_FINDER_COLUMN_G_LIKEN_V_GROUPID_5);
8996
8997 conjunctionable = true;
8998
8999 if (conjunctionable) {
9000 query.append(WHERE_AND);
9001 }
9002
9003 if (name == null) {
9004 query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_4);
9005 }
9006 else if (name.equals(StringPool.BLANK)) {
9007 query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_6);
9008 }
9009 else {
9010 query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_5);
9011 }
9012
9013 conjunctionable = true;
9014
9015 if ((vocabularyIds == null) || (vocabularyIds.length > 0)) {
9016 if (conjunctionable) {
9017 query.append(WHERE_AND);
9018 }
9019
9020 query.append(StringPool.OPEN_PARENTHESIS);
9021
9022 for (int i = 0; i < vocabularyIds.length; i++) {
9023 query.append(_FINDER_COLUMN_G_LIKEN_V_VOCABULARYID_5);
9024
9025 if ((i + 1) < vocabularyIds.length) {
9026 query.append(WHERE_OR);
9027 }
9028 }
9029
9030 query.append(StringPool.CLOSE_PARENTHESIS);
9031
9032 conjunctionable = true;
9033 }
9034
9035 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
9036 AssetCategory.class.getName(),
9037 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
9038
9039 Session session = null;
9040
9041 try {
9042 session = openSession();
9043
9044 SQLQuery q = session.createSQLQuery(sql);
9045
9046 q.addScalar(COUNT_COLUMN_NAME,
9047 com.liferay.portal.kernel.dao.orm.Type.LONG);
9048
9049 QueryPos qPos = QueryPos.getInstance(q);
9050
9051 qPos.add(groupId);
9052
9053 if (name != null) {
9054 qPos.add(name);
9055 }
9056
9057 if (vocabularyIds != null) {
9058 qPos.add(vocabularyIds);
9059 }
9060
9061 Long count = (Long)q.uniqueResult();
9062
9063 return count.intValue();
9064 }
9065 catch (Exception e) {
9066 throw processException(e);
9067 }
9068 finally {
9069 closeSession(session);
9070 }
9071 }
9072
9073 private static final String _FINDER_COLUMN_G_LIKEN_V_GROUPID_2 = "assetCategory.groupId = ? AND ";
9074 private static final String _FINDER_COLUMN_G_LIKEN_V_GROUPID_5 = "(" +
9075 removeConjunction(_FINDER_COLUMN_G_LIKEN_V_GROUPID_2) + ")";
9076 private static final String _FINDER_COLUMN_G_LIKEN_V_NAME_1 = "assetCategory.name LIKE NULL AND ";
9077 private static final String _FINDER_COLUMN_G_LIKEN_V_NAME_2 = "assetCategory.name LIKE ? AND ";
9078 private static final String _FINDER_COLUMN_G_LIKEN_V_NAME_3 = "(assetCategory.name IS NULL OR assetCategory.name LIKE '') AND ";
9079 private static final String _FINDER_COLUMN_G_LIKEN_V_NAME_4 = "(" +
9080 removeConjunction(_FINDER_COLUMN_G_LIKEN_V_NAME_1) + ")";
9081 private static final String _FINDER_COLUMN_G_LIKEN_V_NAME_5 = "(" +
9082 removeConjunction(_FINDER_COLUMN_G_LIKEN_V_NAME_2) + ")";
9083 private static final String _FINDER_COLUMN_G_LIKEN_V_NAME_6 = "(" +
9084 removeConjunction(_FINDER_COLUMN_G_LIKEN_V_NAME_3) + ")";
9085 private static final String _FINDER_COLUMN_G_LIKEN_V_VOCABULARYID_2 = "assetCategory.vocabularyId = ?";
9086 private static final String _FINDER_COLUMN_G_LIKEN_V_VOCABULARYID_5 = "(" +
9087 removeConjunction(_FINDER_COLUMN_G_LIKEN_V_VOCABULARYID_2) + ")";
9088 public static final FinderPath FINDER_PATH_FETCH_BY_P_N_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
9089 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
9090 AssetCategoryImpl.class, FINDER_CLASS_NAME_ENTITY, "fetchByP_N_V",
9091 new String[] {
9092 Long.class.getName(), String.class.getName(),
9093 Long.class.getName()
9094 },
9095 AssetCategoryModelImpl.PARENTCATEGORYID_COLUMN_BITMASK |
9096 AssetCategoryModelImpl.NAME_COLUMN_BITMASK |
9097 AssetCategoryModelImpl.VOCABULARYID_COLUMN_BITMASK);
9098 public static final FinderPath FINDER_PATH_COUNT_BY_P_N_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
9099 AssetCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class,
9100 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByP_N_V",
9101 new String[] {
9102 Long.class.getName(), String.class.getName(),
9103 Long.class.getName()
9104 });
9105
9106
9116 @Override
9117 public AssetCategory findByP_N_V(long parentCategoryId, String name,
9118 long vocabularyId) throws NoSuchCategoryException, SystemException {
9119 AssetCategory assetCategory = fetchByP_N_V(parentCategoryId, name,
9120 vocabularyId);
9121
9122 if (assetCategory == null) {
9123 StringBundler msg = new StringBundler(8);
9124
9125 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
9126
9127 msg.append("parentCategoryId=");
9128 msg.append(parentCategoryId);
9129
9130 msg.append(", name=");
9131 msg.append(name);
9132
9133 msg.append(", vocabularyId=");
9134 msg.append(vocabularyId);
9135
9136 msg.append(StringPool.CLOSE_CURLY_BRACE);
9137
9138 if (_log.isWarnEnabled()) {
9139 _log.warn(msg.toString());
9140 }
9141
9142 throw new NoSuchCategoryException(msg.toString());
9143 }
9144
9145 return assetCategory;
9146 }
9147
9148
9157 @Override
9158 public AssetCategory fetchByP_N_V(long parentCategoryId, String name,
9159 long vocabularyId) throws SystemException {
9160 return fetchByP_N_V(parentCategoryId, name, vocabularyId, true);
9161 }
9162
9163
9173 @Override
9174 public AssetCategory fetchByP_N_V(long parentCategoryId, String name,
9175 long vocabularyId, boolean retrieveFromCache) throws SystemException {
9176 Object[] finderArgs = new Object[] { parentCategoryId, name, vocabularyId };
9177
9178 Object result = null;
9179
9180 if (retrieveFromCache) {
9181 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_P_N_V,
9182 finderArgs, this);
9183 }
9184
9185 if (result instanceof AssetCategory) {
9186 AssetCategory assetCategory = (AssetCategory)result;
9187
9188 if ((parentCategoryId != assetCategory.getParentCategoryId()) ||
9189 !Validator.equals(name, assetCategory.getName()) ||
9190 (vocabularyId != assetCategory.getVocabularyId())) {
9191 result = null;
9192 }
9193 }
9194
9195 if (result == null) {
9196 StringBundler query = new StringBundler(5);
9197
9198 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
9199
9200 query.append(_FINDER_COLUMN_P_N_V_PARENTCATEGORYID_2);
9201
9202 boolean bindName = false;
9203
9204 if (name == null) {
9205 query.append(_FINDER_COLUMN_P_N_V_NAME_1);
9206 }
9207 else if (name.equals(StringPool.BLANK)) {
9208 query.append(_FINDER_COLUMN_P_N_V_NAME_3);
9209 }
9210 else {
9211 bindName = true;
9212
9213 query.append(_FINDER_COLUMN_P_N_V_NAME_2);
9214 }
9215
9216 query.append(_FINDER_COLUMN_P_N_V_VOCABULARYID_2);
9217
9218 String sql = query.toString();
9219
9220 Session session = null;
9221
9222 try {
9223 session = openSession();
9224
9225 Query q = session.createQuery(sql);
9226
9227 QueryPos qPos = QueryPos.getInstance(q);
9228
9229 qPos.add(parentCategoryId);
9230
9231 if (bindName) {
9232 qPos.add(name);
9233 }
9234
9235 qPos.add(vocabularyId);
9236
9237 List<AssetCategory> list = q.list();
9238
9239 if (list.isEmpty()) {
9240 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_P_N_V,
9241 finderArgs, list);
9242 }
9243 else {
9244 AssetCategory assetCategory = list.get(0);
9245
9246 result = assetCategory;
9247
9248 cacheResult(assetCategory);
9249
9250 if ((assetCategory.getParentCategoryId() != parentCategoryId) ||
9251 (assetCategory.getName() == null) ||
9252 !assetCategory.getName().equals(name) ||
9253 (assetCategory.getVocabularyId() != vocabularyId)) {
9254 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_P_N_V,
9255 finderArgs, assetCategory);
9256 }
9257 }
9258 }
9259 catch (Exception e) {
9260 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_P_N_V,
9261 finderArgs);
9262
9263 throw processException(e);
9264 }
9265 finally {
9266 closeSession(session);
9267 }
9268 }
9269
9270 if (result instanceof List<?>) {
9271 return null;
9272 }
9273 else {
9274 return (AssetCategory)result;
9275 }
9276 }
9277
9278
9287 @Override
9288 public AssetCategory removeByP_N_V(long parentCategoryId, String name,
9289 long vocabularyId) throws NoSuchCategoryException, SystemException {
9290 AssetCategory assetCategory = findByP_N_V(parentCategoryId, name,
9291 vocabularyId);
9292
9293 return remove(assetCategory);
9294 }
9295
9296
9305 @Override
9306 public int countByP_N_V(long parentCategoryId, String name,
9307 long vocabularyId) throws SystemException {
9308 FinderPath finderPath = FINDER_PATH_COUNT_BY_P_N_V;
9309
9310 Object[] finderArgs = new Object[] { parentCategoryId, name, vocabularyId };
9311
9312 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
9313 this);
9314
9315 if (count == null) {
9316 StringBundler query = new StringBundler(4);
9317
9318 query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
9319
9320 query.append(_FINDER_COLUMN_P_N_V_PARENTCATEGORYID_2);
9321
9322 boolean bindName = false;
9323
9324 if (name == null) {
9325 query.append(_FINDER_COLUMN_P_N_V_NAME_1);
9326 }
9327 else if (name.equals(StringPool.BLANK)) {
9328 query.append(_FINDER_COLUMN_P_N_V_NAME_3);
9329 }
9330 else {
9331 bindName = true;
9332
9333 query.append(_FINDER_COLUMN_P_N_V_NAME_2);
9334 }
9335
9336 query.append(_FINDER_COLUMN_P_N_V_VOCABULARYID_2);
9337
9338 String sql = query.toString();
9339
9340 Session session = null;
9341
9342 try {
9343 session = openSession();
9344
9345 Query q = session.createQuery(sql);
9346
9347 QueryPos qPos = QueryPos.getInstance(q);
9348
9349 qPos.add(parentCategoryId);
9350
9351 if (bindName) {
9352 qPos.add(name);
9353 }
9354
9355 qPos.add(vocabularyId);
9356
9357 count = (Long)q.uniqueResult();
9358
9359 FinderCacheUtil.putResult(finderPath, finderArgs, count);
9360 }
9361 catch (Exception e) {
9362 FinderCacheUtil.removeResult(finderPath, finderArgs);
9363
9364 throw processException(e);
9365 }
9366 finally {
9367 closeSession(session);
9368 }
9369 }
9370
9371 return count.intValue();
9372 }
9373
9374 private static final String _FINDER_COLUMN_P_N_V_PARENTCATEGORYID_2 = "assetCategory.parentCategoryId = ? AND ";
9375 private static final String _FINDER_COLUMN_P_N_V_NAME_1 = "assetCategory.name IS NULL AND ";
9376 private static final String _FINDER_COLUMN_P_N_V_NAME_2 = "assetCategory.name = ? AND ";
9377 private static final String _FINDER_COLUMN_P_N_V_NAME_3 = "(assetCategory.name IS NULL OR assetCategory.name = '') AND ";
9378 private static final String _FINDER_COLUMN_P_N_V_VOCABULARYID_2 = "assetCategory.vocabularyId = ?";
9379 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_P_N_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
9380 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
9381 AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
9382 "findByG_P_N_V",
9383 new String[] {
9384 Long.class.getName(), Long.class.getName(),
9385 String.class.getName(), Long.class.getName(),
9386
9387 Integer.class.getName(), Integer.class.getName(),
9388 OrderByComparator.class.getName()
9389 });
9390 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_N_V =
9391 new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
9392 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
9393 AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
9394 "findByG_P_N_V",
9395 new String[] {
9396 Long.class.getName(), Long.class.getName(),
9397 String.class.getName(), Long.class.getName()
9398 },
9399 AssetCategoryModelImpl.GROUPID_COLUMN_BITMASK |
9400 AssetCategoryModelImpl.PARENTCATEGORYID_COLUMN_BITMASK |
9401 AssetCategoryModelImpl.NAME_COLUMN_BITMASK |
9402 AssetCategoryModelImpl.VOCABULARYID_COLUMN_BITMASK);
9403 public static final FinderPath FINDER_PATH_COUNT_BY_G_P_N_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
9404 AssetCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class,
9405 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_P_N_V",
9406 new String[] {
9407 Long.class.getName(), Long.class.getName(),
9408 String.class.getName(), Long.class.getName()
9409 });
9410
9411
9421 @Override
9422 public List<AssetCategory> findByG_P_N_V(long groupId,
9423 long parentCategoryId, String name, long vocabularyId)
9424 throws SystemException {
9425 return findByG_P_N_V(groupId, parentCategoryId, name, vocabularyId,
9426 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
9427 }
9428
9429
9445 @Override
9446 public List<AssetCategory> findByG_P_N_V(long groupId,
9447 long parentCategoryId, String name, long vocabularyId, int start,
9448 int end) throws SystemException {
9449 return findByG_P_N_V(groupId, parentCategoryId, name, vocabularyId,
9450 start, end, null);
9451 }
9452
9453
9470 @Override
9471 public List<AssetCategory> findByG_P_N_V(long groupId,
9472 long parentCategoryId, String name, long vocabularyId, int start,
9473 int end, OrderByComparator orderByComparator) throws SystemException {
9474 boolean pagination = true;
9475 FinderPath finderPath = null;
9476 Object[] finderArgs = null;
9477
9478 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
9479 (orderByComparator == null)) {
9480 pagination = false;
9481 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_N_V;
9482 finderArgs = new Object[] {
9483 groupId, parentCategoryId, name, vocabularyId
9484 };
9485 }
9486 else {
9487 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_P_N_V;
9488 finderArgs = new Object[] {
9489 groupId, parentCategoryId, name, vocabularyId,
9490
9491 start, end, orderByComparator
9492 };
9493 }
9494
9495 List<AssetCategory> list = (List<AssetCategory>)FinderCacheUtil.getResult(finderPath,
9496 finderArgs, this);
9497
9498 if ((list != null) && !list.isEmpty()) {
9499 for (AssetCategory assetCategory : list) {
9500 if ((groupId != assetCategory.getGroupId()) ||
9501 (parentCategoryId != assetCategory.getParentCategoryId()) ||
9502 !Validator.equals(name, assetCategory.getName()) ||
9503 (vocabularyId != assetCategory.getVocabularyId())) {
9504 list = null;
9505
9506 break;
9507 }
9508 }
9509 }
9510
9511 if (list == null) {
9512 StringBundler query = null;
9513
9514 if (orderByComparator != null) {
9515 query = new StringBundler(6 +
9516 (orderByComparator.getOrderByFields().length * 3));
9517 }
9518 else {
9519 query = new StringBundler(6);
9520 }
9521
9522 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
9523
9524 query.append(_FINDER_COLUMN_G_P_N_V_GROUPID_2);
9525
9526 query.append(_FINDER_COLUMN_G_P_N_V_PARENTCATEGORYID_2);
9527
9528 boolean bindName = false;
9529
9530 if (name == null) {
9531 query.append(_FINDER_COLUMN_G_P_N_V_NAME_1);
9532 }
9533 else if (name.equals(StringPool.BLANK)) {
9534 query.append(_FINDER_COLUMN_G_P_N_V_NAME_3);
9535 }
9536 else {
9537 bindName = true;
9538
9539 query.append(_FINDER_COLUMN_G_P_N_V_NAME_2);
9540 }
9541
9542 query.append(_FINDER_COLUMN_G_P_N_V_VOCABULARYID_2);
9543
9544 if (orderByComparator != null) {
9545 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
9546 orderByComparator);
9547 }
9548 else
9549 if (pagination) {
9550 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
9551 }
9552
9553 String sql = query.toString();
9554
9555 Session session = null;
9556
9557 try {
9558 session = openSession();
9559
9560 Query q = session.createQuery(sql);
9561
9562 QueryPos qPos = QueryPos.getInstance(q);
9563
9564 qPos.add(groupId);
9565
9566 qPos.add(parentCategoryId);
9567
9568 if (bindName) {
9569 qPos.add(name);
9570 }
9571
9572 qPos.add(vocabularyId);
9573
9574 if (!pagination) {
9575 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
9576 start, end, false);
9577
9578 Collections.sort(list);
9579
9580 list = new UnmodifiableList<AssetCategory>(list);
9581 }
9582 else {
9583 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
9584 start, end);
9585 }
9586
9587 cacheResult(list);
9588
9589 FinderCacheUtil.putResult(finderPath, finderArgs, list);
9590 }
9591 catch (Exception e) {
9592 FinderCacheUtil.removeResult(finderPath, finderArgs);
9593
9594 throw processException(e);
9595 }
9596 finally {
9597 closeSession(session);
9598 }
9599 }
9600
9601 return list;
9602 }
9603
9604
9616 @Override
9617 public AssetCategory findByG_P_N_V_First(long groupId,
9618 long parentCategoryId, String name, long vocabularyId,
9619 OrderByComparator orderByComparator)
9620 throws NoSuchCategoryException, SystemException {
9621 AssetCategory assetCategory = fetchByG_P_N_V_First(groupId,
9622 parentCategoryId, name, vocabularyId, orderByComparator);
9623
9624 if (assetCategory != null) {
9625 return assetCategory;
9626 }
9627
9628 StringBundler msg = new StringBundler(10);
9629
9630 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
9631
9632 msg.append("groupId=");
9633 msg.append(groupId);
9634
9635 msg.append(", parentCategoryId=");
9636 msg.append(parentCategoryId);
9637
9638 msg.append(", name=");
9639 msg.append(name);
9640
9641 msg.append(", vocabularyId=");
9642 msg.append(vocabularyId);
9643
9644 msg.append(StringPool.CLOSE_CURLY_BRACE);
9645
9646 throw new NoSuchCategoryException(msg.toString());
9647 }
9648
9649
9660 @Override
9661 public AssetCategory fetchByG_P_N_V_First(long groupId,
9662 long parentCategoryId, String name, long vocabularyId,
9663 OrderByComparator orderByComparator) throws SystemException {
9664 List<AssetCategory> list = findByG_P_N_V(groupId, parentCategoryId,
9665 name, vocabularyId, 0, 1, orderByComparator);
9666
9667 if (!list.isEmpty()) {
9668 return list.get(0);
9669 }
9670
9671 return null;
9672 }
9673
9674
9686 @Override
9687 public AssetCategory findByG_P_N_V_Last(long groupId,
9688 long parentCategoryId, String name, long vocabularyId,
9689 OrderByComparator orderByComparator)
9690 throws NoSuchCategoryException, SystemException {
9691 AssetCategory assetCategory = fetchByG_P_N_V_Last(groupId,
9692 parentCategoryId, name, vocabularyId, orderByComparator);
9693
9694 if (assetCategory != null) {
9695 return assetCategory;
9696 }
9697
9698 StringBundler msg = new StringBundler(10);
9699
9700 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
9701
9702 msg.append("groupId=");
9703 msg.append(groupId);
9704
9705 msg.append(", parentCategoryId=");
9706 msg.append(parentCategoryId);
9707
9708 msg.append(", name=");
9709 msg.append(name);
9710
9711 msg.append(", vocabularyId=");
9712 msg.append(vocabularyId);
9713
9714 msg.append(StringPool.CLOSE_CURLY_BRACE);
9715
9716 throw new NoSuchCategoryException(msg.toString());
9717 }
9718
9719
9730 @Override
9731 public AssetCategory fetchByG_P_N_V_Last(long groupId,
9732 long parentCategoryId, String name, long vocabularyId,
9733 OrderByComparator orderByComparator) throws SystemException {
9734 int count = countByG_P_N_V(groupId, parentCategoryId, name, vocabularyId);
9735
9736 if (count == 0) {
9737 return null;
9738 }
9739
9740 List<AssetCategory> list = findByG_P_N_V(groupId, parentCategoryId,
9741 name, vocabularyId, count - 1, count, orderByComparator);
9742
9743 if (!list.isEmpty()) {
9744 return list.get(0);
9745 }
9746
9747 return null;
9748 }
9749
9750
9763 @Override
9764 public AssetCategory[] findByG_P_N_V_PrevAndNext(long categoryId,
9765 long groupId, long parentCategoryId, String name, long vocabularyId,
9766 OrderByComparator orderByComparator)
9767 throws NoSuchCategoryException, SystemException {
9768 AssetCategory assetCategory = findByPrimaryKey(categoryId);
9769
9770 Session session = null;
9771
9772 try {
9773 session = openSession();
9774
9775 AssetCategory[] array = new AssetCategoryImpl[3];
9776
9777 array[0] = getByG_P_N_V_PrevAndNext(session, assetCategory,
9778 groupId, parentCategoryId, name, vocabularyId,
9779 orderByComparator, true);
9780
9781 array[1] = assetCategory;
9782
9783 array[2] = getByG_P_N_V_PrevAndNext(session, assetCategory,
9784 groupId, parentCategoryId, name, vocabularyId,
9785 orderByComparator, false);
9786
9787 return array;
9788 }
9789 catch (Exception e) {
9790 throw processException(e);
9791 }
9792 finally {
9793 closeSession(session);
9794 }
9795 }
9796
9797 protected AssetCategory getByG_P_N_V_PrevAndNext(Session session,
9798 AssetCategory assetCategory, long groupId, long parentCategoryId,
9799 String name, long vocabularyId, OrderByComparator orderByComparator,
9800 boolean previous) {
9801 StringBundler query = null;
9802
9803 if (orderByComparator != null) {
9804 query = new StringBundler(6 +
9805 (orderByComparator.getOrderByFields().length * 6));
9806 }
9807 else {
9808 query = new StringBundler(3);
9809 }
9810
9811 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
9812
9813 query.append(_FINDER_COLUMN_G_P_N_V_GROUPID_2);
9814
9815 query.append(_FINDER_COLUMN_G_P_N_V_PARENTCATEGORYID_2);
9816
9817 boolean bindName = false;
9818
9819 if (name == null) {
9820 query.append(_FINDER_COLUMN_G_P_N_V_NAME_1);
9821 }
9822 else if (name.equals(StringPool.BLANK)) {
9823 query.append(_FINDER_COLUMN_G_P_N_V_NAME_3);
9824 }
9825 else {
9826 bindName = true;
9827
9828 query.append(_FINDER_COLUMN_G_P_N_V_NAME_2);
9829 }
9830
9831 query.append(_FINDER_COLUMN_G_P_N_V_VOCABULARYID_2);
9832
9833 if (orderByComparator != null) {
9834 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
9835
9836 if (orderByConditionFields.length > 0) {
9837 query.append(WHERE_AND);
9838 }
9839
9840 for (int i = 0; i < orderByConditionFields.length; i++) {
9841 query.append(_ORDER_BY_ENTITY_ALIAS);
9842 query.append(orderByConditionFields[i]);
9843
9844 if ((i + 1) < orderByConditionFields.length) {
9845 if (orderByComparator.isAscending() ^ previous) {
9846 query.append(WHERE_GREATER_THAN_HAS_NEXT);
9847 }
9848 else {
9849 query.append(WHERE_LESSER_THAN_HAS_NEXT);
9850 }
9851 }
9852 else {
9853 if (orderByComparator.isAscending() ^ previous) {
9854 query.append(WHERE_GREATER_THAN);
9855 }
9856 else {
9857 query.append(WHERE_LESSER_THAN);
9858 }
9859 }
9860 }
9861
9862 query.append(ORDER_BY_CLAUSE);
9863
9864 String[] orderByFields = orderByComparator.getOrderByFields();
9865
9866 for (int i = 0; i < orderByFields.length; i++) {
9867 query.append(_ORDER_BY_ENTITY_ALIAS);
9868 query.append(orderByFields[i]);
9869
9870 if ((i + 1) < orderByFields.length) {
9871 if (orderByComparator.isAscending() ^ previous) {
9872 query.append(ORDER_BY_ASC_HAS_NEXT);
9873 }
9874 else {
9875 query.append(ORDER_BY_DESC_HAS_NEXT);
9876 }
9877 }
9878 else {
9879 if (orderByComparator.isAscending() ^ previous) {
9880 query.append(ORDER_BY_ASC);
9881 }
9882 else {
9883 query.append(ORDER_BY_DESC);
9884 }
9885 }
9886 }
9887 }
9888 else {
9889 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
9890 }
9891
9892 String sql = query.toString();
9893
9894 Query q = session.createQuery(sql);
9895
9896 q.setFirstResult(0);
9897 q.setMaxResults(2);
9898
9899 QueryPos qPos = QueryPos.getInstance(q);
9900
9901 qPos.add(groupId);
9902
9903 qPos.add(parentCategoryId);
9904
9905 if (bindName) {
9906 qPos.add(name);
9907 }
9908
9909 qPos.add(vocabularyId);
9910
9911 if (orderByComparator != null) {
9912 Object[] values = orderByComparator.getOrderByConditionValues(assetCategory);
9913
9914 for (Object value : values) {
9915 qPos.add(value);
9916 }
9917 }
9918
9919 List<AssetCategory> list = q.list();
9920
9921 if (list.size() == 2) {
9922 return list.get(1);
9923 }
9924 else {
9925 return null;
9926 }
9927 }
9928
9929
9939 @Override
9940 public List<AssetCategory> filterFindByG_P_N_V(long groupId,
9941 long parentCategoryId, String name, long vocabularyId)
9942 throws SystemException {
9943 return filterFindByG_P_N_V(groupId, parentCategoryId, name,
9944 vocabularyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
9945 }
9946
9947
9963 @Override
9964 public List<AssetCategory> filterFindByG_P_N_V(long groupId,
9965 long parentCategoryId, String name, long vocabularyId, int start,
9966 int end) throws SystemException {
9967 return filterFindByG_P_N_V(groupId, parentCategoryId, name,
9968 vocabularyId, start, end, null);
9969 }
9970
9971
9988 @Override
9989 public List<AssetCategory> filterFindByG_P_N_V(long groupId,
9990 long parentCategoryId, String name, long vocabularyId, int start,
9991 int end, OrderByComparator orderByComparator) throws SystemException {
9992 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
9993 return findByG_P_N_V(groupId, parentCategoryId, name, vocabularyId,
9994 start, end, orderByComparator);
9995 }
9996
9997 StringBundler query = null;
9998
9999 if (orderByComparator != null) {
10000 query = new StringBundler(6 +
10001 (orderByComparator.getOrderByFields().length * 3));
10002 }
10003 else {
10004 query = new StringBundler(6);
10005 }
10006
10007 if (getDB().isSupportsInlineDistinct()) {
10008 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_WHERE);
10009 }
10010 else {
10011 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_1);
10012 }
10013
10014 query.append(_FINDER_COLUMN_G_P_N_V_GROUPID_2);
10015
10016 query.append(_FINDER_COLUMN_G_P_N_V_PARENTCATEGORYID_2);
10017
10018 boolean bindName = false;
10019
10020 if (name == null) {
10021 query.append(_FINDER_COLUMN_G_P_N_V_NAME_1);
10022 }
10023 else if (name.equals(StringPool.BLANK)) {
10024 query.append(_FINDER_COLUMN_G_P_N_V_NAME_3);
10025 }
10026 else {
10027 bindName = true;
10028
10029 query.append(_FINDER_COLUMN_G_P_N_V_NAME_2);
10030 }
10031
10032 query.append(_FINDER_COLUMN_G_P_N_V_VOCABULARYID_2);
10033
10034 if (!getDB().isSupportsInlineDistinct()) {
10035 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_2);
10036 }
10037
10038 if (orderByComparator != null) {
10039 if (getDB().isSupportsInlineDistinct()) {
10040 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
10041 orderByComparator, true);
10042 }
10043 else {
10044 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
10045 orderByComparator, true);
10046 }
10047 }
10048 else {
10049 if (getDB().isSupportsInlineDistinct()) {
10050 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
10051 }
10052 else {
10053 query.append(AssetCategoryModelImpl.ORDER_BY_SQL);
10054 }
10055 }
10056
10057 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
10058 AssetCategory.class.getName(),
10059 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
10060
10061 Session session = null;
10062
10063 try {
10064 session = openSession();
10065
10066 SQLQuery q = session.createSQLQuery(sql);
10067
10068 if (getDB().isSupportsInlineDistinct()) {
10069 q.addEntity(_FILTER_ENTITY_ALIAS, AssetCategoryImpl.class);
10070 }
10071 else {
10072 q.addEntity(_FILTER_ENTITY_TABLE, AssetCategoryImpl.class);
10073 }
10074
10075 QueryPos qPos = QueryPos.getInstance(q);
10076
10077 qPos.add(groupId);
10078
10079 qPos.add(parentCategoryId);
10080
10081 if (bindName) {
10082 qPos.add(name);
10083 }
10084
10085 qPos.add(vocabularyId);
10086
10087 return (List<AssetCategory>)QueryUtil.list(q, getDialect(), start,
10088 end);
10089 }
10090 catch (Exception e) {
10091 throw processException(e);
10092 }
10093 finally {
10094 closeSession(session);
10095 }
10096 }
10097
10098
10111 @Override
10112 public AssetCategory[] filterFindByG_P_N_V_PrevAndNext(long categoryId,
10113 long groupId, long parentCategoryId, String name, long vocabularyId,
10114 OrderByComparator orderByComparator)
10115 throws NoSuchCategoryException, SystemException {
10116 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
10117 return findByG_P_N_V_PrevAndNext(categoryId, groupId,
10118 parentCategoryId, name, vocabularyId, orderByComparator);
10119 }
10120
10121 AssetCategory assetCategory = findByPrimaryKey(categoryId);
10122
10123 Session session = null;
10124
10125 try {
10126 session = openSession();
10127
10128 AssetCategory[] array = new AssetCategoryImpl[3];
10129
10130 array[0] = filterGetByG_P_N_V_PrevAndNext(session, assetCategory,
10131 groupId, parentCategoryId, name, vocabularyId,
10132 orderByComparator, true);
10133
10134 array[1] = assetCategory;
10135
10136 array[2] = filterGetByG_P_N_V_PrevAndNext(session, assetCategory,
10137 groupId, parentCategoryId, name, vocabularyId,
10138 orderByComparator, false);
10139
10140 return array;
10141 }
10142 catch (Exception e) {
10143 throw processException(e);
10144 }
10145 finally {
10146 closeSession(session);
10147 }
10148 }
10149
10150 protected AssetCategory filterGetByG_P_N_V_PrevAndNext(Session session,
10151 AssetCategory assetCategory, long groupId, long parentCategoryId,
10152 String name, long vocabularyId, OrderByComparator orderByComparator,
10153 boolean previous) {
10154 StringBundler query = null;
10155
10156 if (orderByComparator != null) {
10157 query = new StringBundler(6 +
10158 (orderByComparator.getOrderByFields().length * 6));
10159 }
10160 else {
10161 query = new StringBundler(3);
10162 }
10163
10164 if (getDB().isSupportsInlineDistinct()) {
10165 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_WHERE);
10166 }
10167 else {
10168 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_1);
10169 }
10170
10171 query.append(_FINDER_COLUMN_G_P_N_V_GROUPID_2);
10172
10173 query.append(_FINDER_COLUMN_G_P_N_V_PARENTCATEGORYID_2);
10174
10175 boolean bindName = false;
10176
10177 if (name == null) {
10178 query.append(_FINDER_COLUMN_G_P_N_V_NAME_1);
10179 }
10180 else if (name.equals(StringPool.BLANK)) {
10181 query.append(_FINDER_COLUMN_G_P_N_V_NAME_3);
10182 }
10183 else {
10184 bindName = true;
10185
10186 query.append(_FINDER_COLUMN_G_P_N_V_NAME_2);
10187 }
10188
10189 query.append(_FINDER_COLUMN_G_P_N_V_VOCABULARYID_2);
10190
10191 if (!getDB().isSupportsInlineDistinct()) {
10192 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_2);
10193 }
10194
10195 if (orderByComparator != null) {
10196 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
10197
10198 if (orderByConditionFields.length > 0) {
10199 query.append(WHERE_AND);
10200 }
10201
10202 for (int i = 0; i < orderByConditionFields.length; i++) {
10203 if (getDB().isSupportsInlineDistinct()) {
10204 query.append(_ORDER_BY_ENTITY_ALIAS);
10205 }
10206 else {
10207 query.append(_ORDER_BY_ENTITY_TABLE);
10208 }
10209
10210 query.append(orderByConditionFields[i]);
10211
10212 if ((i + 1) < orderByConditionFields.length) {
10213 if (orderByComparator.isAscending() ^ previous) {
10214 query.append(WHERE_GREATER_THAN_HAS_NEXT);
10215 }
10216 else {
10217 query.append(WHERE_LESSER_THAN_HAS_NEXT);
10218 }
10219 }
10220 else {
10221 if (orderByComparator.isAscending() ^ previous) {
10222 query.append(WHERE_GREATER_THAN);
10223 }
10224 else {
10225 query.append(WHERE_LESSER_THAN);
10226 }
10227 }
10228 }
10229
10230 query.append(ORDER_BY_CLAUSE);
10231
10232 String[] orderByFields = orderByComparator.getOrderByFields();
10233
10234 for (int i = 0; i < orderByFields.length; i++) {
10235 if (getDB().isSupportsInlineDistinct()) {
10236 query.append(_ORDER_BY_ENTITY_ALIAS);
10237 }
10238 else {
10239 query.append(_ORDER_BY_ENTITY_TABLE);
10240 }
10241
10242 query.append(orderByFields[i]);
10243
10244 if ((i + 1) < orderByFields.length) {
10245 if (orderByComparator.isAscending() ^ previous) {
10246 query.append(ORDER_BY_ASC_HAS_NEXT);
10247 }
10248 else {
10249 query.append(ORDER_BY_DESC_HAS_NEXT);
10250 }
10251 }
10252 else {
10253 if (orderByComparator.isAscending() ^ previous) {
10254 query.append(ORDER_BY_ASC);
10255 }
10256 else {
10257 query.append(ORDER_BY_DESC);
10258 }
10259 }
10260 }
10261 }
10262 else {
10263 if (getDB().isSupportsInlineDistinct()) {
10264 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
10265 }
10266 else {
10267 query.append(AssetCategoryModelImpl.ORDER_BY_SQL);
10268 }
10269 }
10270
10271 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
10272 AssetCategory.class.getName(),
10273 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
10274
10275 SQLQuery q = session.createSQLQuery(sql);
10276
10277 q.setFirstResult(0);
10278 q.setMaxResults(2);
10279
10280 if (getDB().isSupportsInlineDistinct()) {
10281 q.addEntity(_FILTER_ENTITY_ALIAS, AssetCategoryImpl.class);
10282 }
10283 else {
10284 q.addEntity(_FILTER_ENTITY_TABLE, AssetCategoryImpl.class);
10285 }
10286
10287 QueryPos qPos = QueryPos.getInstance(q);
10288
10289 qPos.add(groupId);
10290
10291 qPos.add(parentCategoryId);
10292
10293 if (bindName) {
10294 qPos.add(name);
10295 }
10296
10297 qPos.add(vocabularyId);
10298
10299 if (orderByComparator != null) {
10300 Object[] values = orderByComparator.getOrderByConditionValues(assetCategory);
10301
10302 for (Object value : values) {
10303 qPos.add(value);
10304 }
10305 }
10306
10307 List<AssetCategory> list = q.list();
10308
10309 if (list.size() == 2) {
10310 return list.get(1);
10311 }
10312 else {
10313 return null;
10314 }
10315 }
10316
10317
10326 @Override
10327 public void removeByG_P_N_V(long groupId, long parentCategoryId,
10328 String name, long vocabularyId) throws SystemException {
10329 for (AssetCategory assetCategory : findByG_P_N_V(groupId,
10330 parentCategoryId, name, vocabularyId, QueryUtil.ALL_POS,
10331 QueryUtil.ALL_POS, null)) {
10332 remove(assetCategory);
10333 }
10334 }
10335
10336
10346 @Override
10347 public int countByG_P_N_V(long groupId, long parentCategoryId, String name,
10348 long vocabularyId) throws SystemException {
10349 FinderPath finderPath = FINDER_PATH_COUNT_BY_G_P_N_V;
10350
10351 Object[] finderArgs = new Object[] {
10352 groupId, parentCategoryId, name, vocabularyId
10353 };
10354
10355 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
10356 this);
10357
10358 if (count == null) {
10359 StringBundler query = new StringBundler(5);
10360
10361 query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
10362
10363 query.append(_FINDER_COLUMN_G_P_N_V_GROUPID_2);
10364
10365 query.append(_FINDER_COLUMN_G_P_N_V_PARENTCATEGORYID_2);
10366
10367 boolean bindName = false;
10368
10369 if (name == null) {
10370 query.append(_FINDER_COLUMN_G_P_N_V_NAME_1);
10371 }
10372 else if (name.equals(StringPool.BLANK)) {
10373 query.append(_FINDER_COLUMN_G_P_N_V_NAME_3);
10374 }
10375 else {
10376 bindName = true;
10377
10378 query.append(_FINDER_COLUMN_G_P_N_V_NAME_2);
10379 }
10380
10381 query.append(_FINDER_COLUMN_G_P_N_V_VOCABULARYID_2);
10382
10383 String sql = query.toString();
10384
10385 Session session = null;
10386
10387 try {
10388 session = openSession();
10389
10390 Query q = session.createQuery(sql);
10391
10392 QueryPos qPos = QueryPos.getInstance(q);
10393
10394 qPos.add(groupId);
10395
10396 qPos.add(parentCategoryId);
10397
10398 if (bindName) {
10399 qPos.add(name);
10400 }
10401
10402 qPos.add(vocabularyId);
10403
10404 count = (Long)q.uniqueResult();
10405
10406 FinderCacheUtil.putResult(finderPath, finderArgs, count);
10407 }
10408 catch (Exception e) {
10409 FinderCacheUtil.removeResult(finderPath, finderArgs);
10410
10411 throw processException(e);
10412 }
10413 finally {
10414 closeSession(session);
10415 }
10416 }
10417
10418 return count.intValue();
10419 }
10420
10421
10431 @Override
10432 public int filterCountByG_P_N_V(long groupId, long parentCategoryId,
10433 String name, long vocabularyId) throws SystemException {
10434 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
10435 return countByG_P_N_V(groupId, parentCategoryId, name, vocabularyId);
10436 }
10437
10438 StringBundler query = new StringBundler(5);
10439
10440 query.append(_FILTER_SQL_COUNT_ASSETCATEGORY_WHERE);
10441
10442 query.append(_FINDER_COLUMN_G_P_N_V_GROUPID_2);
10443
10444 query.append(_FINDER_COLUMN_G_P_N_V_PARENTCATEGORYID_2);
10445
10446 boolean bindName = false;
10447
10448 if (name == null) {
10449 query.append(_FINDER_COLUMN_G_P_N_V_NAME_1);
10450 }
10451 else if (name.equals(StringPool.BLANK)) {
10452 query.append(_FINDER_COLUMN_G_P_N_V_NAME_3);
10453 }
10454 else {
10455 bindName = true;
10456
10457 query.append(_FINDER_COLUMN_G_P_N_V_NAME_2);
10458 }
10459
10460 query.append(_FINDER_COLUMN_G_P_N_V_VOCABULARYID_2);
10461
10462 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
10463 AssetCategory.class.getName(),
10464 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
10465
10466 Session session = null;
10467
10468 try {
10469 session = openSession();
10470
10471 SQLQuery q = session.createSQLQuery(sql);
10472
10473 q.addScalar(COUNT_COLUMN_NAME,
10474 com.liferay.portal.kernel.dao.orm.Type.LONG);
10475
10476 QueryPos qPos = QueryPos.getInstance(q);
10477
10478 qPos.add(groupId);
10479
10480 qPos.add(parentCategoryId);
10481
10482 if (bindName) {
10483 qPos.add(name);
10484 }
10485
10486 qPos.add(vocabularyId);
10487
10488 Long count = (Long)q.uniqueResult();
10489
10490 return count.intValue();
10491 }
10492 catch (Exception e) {
10493 throw processException(e);
10494 }
10495 finally {
10496 closeSession(session);
10497 }
10498 }
10499
10500 private static final String _FINDER_COLUMN_G_P_N_V_GROUPID_2 = "assetCategory.groupId = ? AND ";
10501 private static final String _FINDER_COLUMN_G_P_N_V_PARENTCATEGORYID_2 = "assetCategory.parentCategoryId = ? AND ";
10502 private static final String _FINDER_COLUMN_G_P_N_V_NAME_1 = "assetCategory.name IS NULL AND ";
10503 private static final String _FINDER_COLUMN_G_P_N_V_NAME_2 = "assetCategory.name = ? AND ";
10504 private static final String _FINDER_COLUMN_G_P_N_V_NAME_3 = "(assetCategory.name IS NULL OR assetCategory.name = '') AND ";
10505 private static final String _FINDER_COLUMN_G_P_N_V_VOCABULARYID_2 = "assetCategory.vocabularyId = ?";
10506
10507 public AssetCategoryPersistenceImpl() {
10508 setModelClass(AssetCategory.class);
10509 }
10510
10511
10516 @Override
10517 public void cacheResult(AssetCategory assetCategory) {
10518 EntityCacheUtil.putResult(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
10519 AssetCategoryImpl.class, assetCategory.getPrimaryKey(),
10520 assetCategory);
10521
10522 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
10523 new Object[] { assetCategory.getUuid(), assetCategory.getGroupId() },
10524 assetCategory);
10525
10526 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_P_N_V,
10527 new Object[] {
10528 assetCategory.getParentCategoryId(), assetCategory.getName(),
10529 assetCategory.getVocabularyId()
10530 }, assetCategory);
10531
10532 assetCategory.resetOriginalValues();
10533 }
10534
10535
10540 @Override
10541 public void cacheResult(List<AssetCategory> assetCategories) {
10542 for (AssetCategory assetCategory : assetCategories) {
10543 if (EntityCacheUtil.getResult(
10544 AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
10545 AssetCategoryImpl.class, assetCategory.getPrimaryKey()) == null) {
10546 cacheResult(assetCategory);
10547 }
10548 else {
10549 assetCategory.resetOriginalValues();
10550 }
10551 }
10552 }
10553
10554
10561 @Override
10562 public void clearCache() {
10563 if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
10564 CacheRegistryUtil.clear(AssetCategoryImpl.class.getName());
10565 }
10566
10567 EntityCacheUtil.clearCache(AssetCategoryImpl.class.getName());
10568
10569 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
10570 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
10571 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
10572 }
10573
10574
10581 @Override
10582 public void clearCache(AssetCategory assetCategory) {
10583 EntityCacheUtil.removeResult(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
10584 AssetCategoryImpl.class, assetCategory.getPrimaryKey());
10585
10586 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
10587 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
10588
10589 clearUniqueFindersCache(assetCategory);
10590 }
10591
10592 @Override
10593 public void clearCache(List<AssetCategory> assetCategories) {
10594 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
10595 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
10596
10597 for (AssetCategory assetCategory : assetCategories) {
10598 EntityCacheUtil.removeResult(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
10599 AssetCategoryImpl.class, assetCategory.getPrimaryKey());
10600
10601 clearUniqueFindersCache(assetCategory);
10602 }
10603 }
10604
10605 protected void cacheUniqueFindersCache(AssetCategory assetCategory) {
10606 if (assetCategory.isNew()) {
10607 Object[] args = new Object[] {
10608 assetCategory.getUuid(), assetCategory.getGroupId()
10609 };
10610
10611 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G, args,
10612 Long.valueOf(1));
10613 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G, args,
10614 assetCategory);
10615
10616 args = new Object[] {
10617 assetCategory.getParentCategoryId(), assetCategory.getName(),
10618 assetCategory.getVocabularyId()
10619 };
10620
10621 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_P_N_V, args,
10622 Long.valueOf(1));
10623 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_P_N_V, args,
10624 assetCategory);
10625 }
10626 else {
10627 AssetCategoryModelImpl assetCategoryModelImpl = (AssetCategoryModelImpl)assetCategory;
10628
10629 if ((assetCategoryModelImpl.getColumnBitmask() &
10630 FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) {
10631 Object[] args = new Object[] {
10632 assetCategory.getUuid(), assetCategory.getGroupId()
10633 };
10634
10635 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G, args,
10636 Long.valueOf(1));
10637 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G, args,
10638 assetCategory);
10639 }
10640
10641 if ((assetCategoryModelImpl.getColumnBitmask() &
10642 FINDER_PATH_FETCH_BY_P_N_V.getColumnBitmask()) != 0) {
10643 Object[] args = new Object[] {
10644 assetCategory.getParentCategoryId(),
10645 assetCategory.getName(), assetCategory.getVocabularyId()
10646 };
10647
10648 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_P_N_V, args,
10649 Long.valueOf(1));
10650 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_P_N_V, args,
10651 assetCategory);
10652 }
10653 }
10654 }
10655
10656 protected void clearUniqueFindersCache(AssetCategory assetCategory) {
10657 AssetCategoryModelImpl assetCategoryModelImpl = (AssetCategoryModelImpl)assetCategory;
10658
10659 Object[] args = new Object[] {
10660 assetCategory.getUuid(), assetCategory.getGroupId()
10661 };
10662
10663 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args);
10664 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args);
10665
10666 if ((assetCategoryModelImpl.getColumnBitmask() &
10667 FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) {
10668 args = new Object[] {
10669 assetCategoryModelImpl.getOriginalUuid(),
10670 assetCategoryModelImpl.getOriginalGroupId()
10671 };
10672
10673 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args);
10674 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args);
10675 }
10676
10677 args = new Object[] {
10678 assetCategory.getParentCategoryId(), assetCategory.getName(),
10679 assetCategory.getVocabularyId()
10680 };
10681
10682 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_P_N_V, args);
10683 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_P_N_V, args);
10684
10685 if ((assetCategoryModelImpl.getColumnBitmask() &
10686 FINDER_PATH_FETCH_BY_P_N_V.getColumnBitmask()) != 0) {
10687 args = new Object[] {
10688 assetCategoryModelImpl.getOriginalParentCategoryId(),
10689 assetCategoryModelImpl.getOriginalName(),
10690 assetCategoryModelImpl.getOriginalVocabularyId()
10691 };
10692
10693 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_P_N_V, args);
10694 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_P_N_V, args);
10695 }
10696 }
10697
10698
10704 @Override
10705 public AssetCategory create(long categoryId) {
10706 AssetCategory assetCategory = new AssetCategoryImpl();
10707
10708 assetCategory.setNew(true);
10709 assetCategory.setPrimaryKey(categoryId);
10710
10711 String uuid = PortalUUIDUtil.generate();
10712
10713 assetCategory.setUuid(uuid);
10714
10715 return assetCategory;
10716 }
10717
10718
10726 @Override
10727 public AssetCategory remove(long categoryId)
10728 throws NoSuchCategoryException, SystemException {
10729 return remove((Serializable)categoryId);
10730 }
10731
10732
10740 @Override
10741 public AssetCategory remove(Serializable primaryKey)
10742 throws NoSuchCategoryException, SystemException {
10743 Session session = null;
10744
10745 try {
10746 session = openSession();
10747
10748 AssetCategory assetCategory = (AssetCategory)session.get(AssetCategoryImpl.class,
10749 primaryKey);
10750
10751 if (assetCategory == null) {
10752 if (_log.isWarnEnabled()) {
10753 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
10754 }
10755
10756 throw new NoSuchCategoryException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
10757 primaryKey);
10758 }
10759
10760 return remove(assetCategory);
10761 }
10762 catch (NoSuchCategoryException nsee) {
10763 throw nsee;
10764 }
10765 catch (Exception e) {
10766 throw processException(e);
10767 }
10768 finally {
10769 closeSession(session);
10770 }
10771 }
10772
10773 @Override
10774 protected AssetCategory removeImpl(AssetCategory assetCategory)
10775 throws SystemException {
10776 assetCategory = toUnwrappedModel(assetCategory);
10777
10778 assetCategoryToAssetEntryTableMapper.deleteLeftPrimaryKeyTableMappings(assetCategory.getPrimaryKey());
10779
10780 shrinkTree(assetCategory);
10781
10782 Session session = null;
10783
10784 try {
10785 session = openSession();
10786
10787 if (!session.contains(assetCategory)) {
10788 assetCategory = (AssetCategory)session.get(AssetCategoryImpl.class,
10789 assetCategory.getPrimaryKeyObj());
10790 }
10791
10792 if (assetCategory != null) {
10793 session.delete(assetCategory);
10794 }
10795 }
10796 catch (Exception e) {
10797 throw processException(e);
10798 }
10799 finally {
10800 closeSession(session);
10801 }
10802
10803 if (assetCategory != null) {
10804 clearCache(assetCategory);
10805 }
10806
10807 return assetCategory;
10808 }
10809
10810 @Override
10811 public AssetCategory updateImpl(
10812 com.liferay.portlet.asset.model.AssetCategory assetCategory)
10813 throws SystemException {
10814 assetCategory = toUnwrappedModel(assetCategory);
10815
10816 boolean isNew = assetCategory.isNew();
10817
10818 AssetCategoryModelImpl assetCategoryModelImpl = (AssetCategoryModelImpl)assetCategory;
10819
10820 if (Validator.isNull(assetCategory.getUuid())) {
10821 String uuid = PortalUUIDUtil.generate();
10822
10823 assetCategory.setUuid(uuid);
10824 }
10825
10826 if (isNew) {
10827 expandTree(assetCategory, null);
10828 }
10829 else {
10830 if (assetCategory.getParentCategoryId() != assetCategoryModelImpl.getOriginalParentCategoryId()) {
10831 List<Long> childrenCategoryIds = getChildrenTreeCategoryIds(assetCategory);
10832
10833 shrinkTree(assetCategory);
10834 expandTree(assetCategory, childrenCategoryIds);
10835 }
10836 }
10837
10838 Session session = null;
10839
10840 try {
10841 session = openSession();
10842
10843 if (assetCategory.isNew()) {
10844 session.save(assetCategory);
10845
10846 assetCategory.setNew(false);
10847 }
10848 else {
10849 session.merge(assetCategory);
10850 }
10851 }
10852 catch (Exception e) {
10853 throw processException(e);
10854 }
10855 finally {
10856 closeSession(session);
10857 }
10858
10859 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
10860
10861 if (isNew || !AssetCategoryModelImpl.COLUMN_BITMASK_ENABLED) {
10862 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
10863 }
10864
10865 else {
10866 if ((assetCategoryModelImpl.getColumnBitmask() &
10867 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID.getColumnBitmask()) != 0) {
10868 Object[] args = new Object[] {
10869 assetCategoryModelImpl.getOriginalUuid()
10870 };
10871
10872 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
10873 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
10874 args);
10875
10876 args = new Object[] { assetCategoryModelImpl.getUuid() };
10877
10878 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
10879 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
10880 args);
10881 }
10882
10883 if ((assetCategoryModelImpl.getColumnBitmask() &
10884 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C.getColumnBitmask()) != 0) {
10885 Object[] args = new Object[] {
10886 assetCategoryModelImpl.getOriginalUuid(),
10887 assetCategoryModelImpl.getOriginalCompanyId()
10888 };
10889
10890 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args);
10891 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C,
10892 args);
10893
10894 args = new Object[] {
10895 assetCategoryModelImpl.getUuid(),
10896 assetCategoryModelImpl.getCompanyId()
10897 };
10898
10899 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args);
10900 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C,
10901 args);
10902 }
10903
10904 if ((assetCategoryModelImpl.getColumnBitmask() &
10905 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID.getColumnBitmask()) != 0) {
10906 Object[] args = new Object[] {
10907 assetCategoryModelImpl.getOriginalGroupId()
10908 };
10909
10910 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
10911 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
10912 args);
10913
10914 args = new Object[] { assetCategoryModelImpl.getGroupId() };
10915
10916 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
10917 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
10918 args);
10919 }
10920
10921 if ((assetCategoryModelImpl.getColumnBitmask() &
10922 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_PARENTCATEGORYID.getColumnBitmask()) != 0) {
10923 Object[] args = new Object[] {
10924 assetCategoryModelImpl.getOriginalParentCategoryId()
10925 };
10926
10927 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_PARENTCATEGORYID,
10928 args);
10929 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_PARENTCATEGORYID,
10930 args);
10931
10932 args = new Object[] { assetCategoryModelImpl.getParentCategoryId() };
10933
10934 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_PARENTCATEGORYID,
10935 args);
10936 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_PARENTCATEGORYID,
10937 args);
10938 }
10939
10940 if ((assetCategoryModelImpl.getColumnBitmask() &
10941 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_VOCABULARYID.getColumnBitmask()) != 0) {
10942 Object[] args = new Object[] {
10943 assetCategoryModelImpl.getOriginalVocabularyId()
10944 };
10945
10946 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_VOCABULARYID,
10947 args);
10948 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_VOCABULARYID,
10949 args);
10950
10951 args = new Object[] { assetCategoryModelImpl.getVocabularyId() };
10952
10953 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_VOCABULARYID,
10954 args);
10955 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_VOCABULARYID,
10956 args);
10957 }
10958
10959 if ((assetCategoryModelImpl.getColumnBitmask() &
10960 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_V.getColumnBitmask()) != 0) {
10961 Object[] args = new Object[] {
10962 assetCategoryModelImpl.getOriginalGroupId(),
10963 assetCategoryModelImpl.getOriginalVocabularyId()
10964 };
10965
10966 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_V, args);
10967 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_V,
10968 args);
10969
10970 args = new Object[] {
10971 assetCategoryModelImpl.getGroupId(),
10972 assetCategoryModelImpl.getVocabularyId()
10973 };
10974
10975 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_V, args);
10976 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_V,
10977 args);
10978 }
10979
10980 if ((assetCategoryModelImpl.getColumnBitmask() &
10981 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_P_N.getColumnBitmask()) != 0) {
10982 Object[] args = new Object[] {
10983 assetCategoryModelImpl.getOriginalParentCategoryId(),
10984 assetCategoryModelImpl.getOriginalName()
10985 };
10986
10987 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_P_N, args);
10988 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_P_N,
10989 args);
10990
10991 args = new Object[] {
10992 assetCategoryModelImpl.getParentCategoryId(),
10993 assetCategoryModelImpl.getName()
10994 };
10995
10996 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_P_N, args);
10997 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_P_N,
10998 args);
10999 }
11000
11001 if ((assetCategoryModelImpl.getColumnBitmask() &
11002 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_P_V.getColumnBitmask()) != 0) {
11003 Object[] args = new Object[] {
11004 assetCategoryModelImpl.getOriginalParentCategoryId(),
11005 assetCategoryModelImpl.getOriginalVocabularyId()
11006 };
11007
11008 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_P_V, args);
11009 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_P_V,
11010 args);
11011
11012 args = new Object[] {
11013 assetCategoryModelImpl.getParentCategoryId(),
11014 assetCategoryModelImpl.getVocabularyId()
11015 };
11016
11017 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_P_V, args);
11018 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_P_V,
11019 args);
11020 }
11021
11022 if ((assetCategoryModelImpl.getColumnBitmask() &
11023 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_V.getColumnBitmask()) != 0) {
11024 Object[] args = new Object[] {
11025 assetCategoryModelImpl.getOriginalName(),
11026 assetCategoryModelImpl.getOriginalVocabularyId()
11027 };
11028
11029 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_N_V, args);
11030 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_V,
11031 args);
11032
11033 args = new Object[] {
11034 assetCategoryModelImpl.getName(),
11035 assetCategoryModelImpl.getVocabularyId()
11036 };
11037
11038 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_N_V, args);
11039 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_V,
11040 args);
11041 }
11042
11043 if ((assetCategoryModelImpl.getColumnBitmask() &
11044 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_V.getColumnBitmask()) != 0) {
11045 Object[] args = new Object[] {
11046 assetCategoryModelImpl.getOriginalGroupId(),
11047 assetCategoryModelImpl.getOriginalParentCategoryId(),
11048 assetCategoryModelImpl.getOriginalVocabularyId()
11049 };
11050
11051 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_P_V, args);
11052 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_V,
11053 args);
11054
11055 args = new Object[] {
11056 assetCategoryModelImpl.getGroupId(),
11057 assetCategoryModelImpl.getParentCategoryId(),
11058 assetCategoryModelImpl.getVocabularyId()
11059 };
11060
11061 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_P_V, args);
11062 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_V,
11063 args);
11064 }
11065
11066 if ((assetCategoryModelImpl.getColumnBitmask() &
11067 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_N_V.getColumnBitmask()) != 0) {
11068 Object[] args = new Object[] {
11069 assetCategoryModelImpl.getOriginalGroupId(),
11070 assetCategoryModelImpl.getOriginalParentCategoryId(),
11071 assetCategoryModelImpl.getOriginalName(),
11072 assetCategoryModelImpl.getOriginalVocabularyId()
11073 };
11074
11075 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_P_N_V, args);
11076 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_N_V,
11077 args);
11078
11079 args = new Object[] {
11080 assetCategoryModelImpl.getGroupId(),
11081 assetCategoryModelImpl.getParentCategoryId(),
11082 assetCategoryModelImpl.getName(),
11083 assetCategoryModelImpl.getVocabularyId()
11084 };
11085
11086 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_P_N_V, args);
11087 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_N_V,
11088 args);
11089 }
11090 }
11091
11092 EntityCacheUtil.putResult(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
11093 AssetCategoryImpl.class, assetCategory.getPrimaryKey(),
11094 assetCategory);
11095
11096 clearUniqueFindersCache(assetCategory);
11097 cacheUniqueFindersCache(assetCategory);
11098
11099 return assetCategory;
11100 }
11101
11102 protected AssetCategory toUnwrappedModel(AssetCategory assetCategory) {
11103 if (assetCategory instanceof AssetCategoryImpl) {
11104 return assetCategory;
11105 }
11106
11107 AssetCategoryImpl assetCategoryImpl = new AssetCategoryImpl();
11108
11109 assetCategoryImpl.setNew(assetCategory.isNew());
11110 assetCategoryImpl.setPrimaryKey(assetCategory.getPrimaryKey());
11111
11112 assetCategoryImpl.setUuid(assetCategory.getUuid());
11113 assetCategoryImpl.setCategoryId(assetCategory.getCategoryId());
11114 assetCategoryImpl.setGroupId(assetCategory.getGroupId());
11115 assetCategoryImpl.setCompanyId(assetCategory.getCompanyId());
11116 assetCategoryImpl.setUserId(assetCategory.getUserId());
11117 assetCategoryImpl.setUserName(assetCategory.getUserName());
11118 assetCategoryImpl.setCreateDate(assetCategory.getCreateDate());
11119 assetCategoryImpl.setModifiedDate(assetCategory.getModifiedDate());
11120 assetCategoryImpl.setParentCategoryId(assetCategory.getParentCategoryId());
11121 assetCategoryImpl.setLeftCategoryId(assetCategory.getLeftCategoryId());
11122 assetCategoryImpl.setRightCategoryId(assetCategory.getRightCategoryId());
11123 assetCategoryImpl.setName(assetCategory.getName());
11124 assetCategoryImpl.setTitle(assetCategory.getTitle());
11125 assetCategoryImpl.setDescription(assetCategory.getDescription());
11126 assetCategoryImpl.setVocabularyId(assetCategory.getVocabularyId());
11127
11128 return assetCategoryImpl;
11129 }
11130
11131
11139 @Override
11140 public AssetCategory findByPrimaryKey(Serializable primaryKey)
11141 throws NoSuchCategoryException, SystemException {
11142 AssetCategory assetCategory = fetchByPrimaryKey(primaryKey);
11143
11144 if (assetCategory == null) {
11145 if (_log.isWarnEnabled()) {
11146 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
11147 }
11148
11149 throw new NoSuchCategoryException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
11150 primaryKey);
11151 }
11152
11153 return assetCategory;
11154 }
11155
11156
11164 @Override
11165 public AssetCategory findByPrimaryKey(long categoryId)
11166 throws NoSuchCategoryException, SystemException {
11167 return findByPrimaryKey((Serializable)categoryId);
11168 }
11169
11170
11177 @Override
11178 public AssetCategory fetchByPrimaryKey(Serializable primaryKey)
11179 throws SystemException {
11180 AssetCategory assetCategory = (AssetCategory)EntityCacheUtil.getResult(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
11181 AssetCategoryImpl.class, primaryKey);
11182
11183 if (assetCategory == _nullAssetCategory) {
11184 return null;
11185 }
11186
11187 if (assetCategory == null) {
11188 Session session = null;
11189
11190 try {
11191 session = openSession();
11192
11193 assetCategory = (AssetCategory)session.get(AssetCategoryImpl.class,
11194 primaryKey);
11195
11196 if (assetCategory != null) {
11197 cacheResult(assetCategory);
11198 }
11199 else {
11200 EntityCacheUtil.putResult(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
11201 AssetCategoryImpl.class, primaryKey, _nullAssetCategory);
11202 }
11203 }
11204 catch (Exception e) {
11205 EntityCacheUtil.removeResult(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
11206 AssetCategoryImpl.class, primaryKey);
11207
11208 throw processException(e);
11209 }
11210 finally {
11211 closeSession(session);
11212 }
11213 }
11214
11215 return assetCategory;
11216 }
11217
11218
11225 @Override
11226 public AssetCategory fetchByPrimaryKey(long categoryId)
11227 throws SystemException {
11228 return fetchByPrimaryKey((Serializable)categoryId);
11229 }
11230
11231
11237 @Override
11238 public List<AssetCategory> findAll() throws SystemException {
11239 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
11240 }
11241
11242
11254 @Override
11255 public List<AssetCategory> findAll(int start, int end)
11256 throws SystemException {
11257 return findAll(start, end, null);
11258 }
11259
11260
11273 @Override
11274 public List<AssetCategory> findAll(int start, int end,
11275 OrderByComparator orderByComparator) throws SystemException {
11276 boolean pagination = true;
11277 FinderPath finderPath = null;
11278 Object[] finderArgs = null;
11279
11280 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
11281 (orderByComparator == null)) {
11282 pagination = false;
11283 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
11284 finderArgs = FINDER_ARGS_EMPTY;
11285 }
11286 else {
11287 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
11288 finderArgs = new Object[] { start, end, orderByComparator };
11289 }
11290
11291 List<AssetCategory> list = (List<AssetCategory>)FinderCacheUtil.getResult(finderPath,
11292 finderArgs, this);
11293
11294 if (list == null) {
11295 StringBundler query = null;
11296 String sql = null;
11297
11298 if (orderByComparator != null) {
11299 query = new StringBundler(2 +
11300 (orderByComparator.getOrderByFields().length * 3));
11301
11302 query.append(_SQL_SELECT_ASSETCATEGORY);
11303
11304 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
11305 orderByComparator);
11306
11307 sql = query.toString();
11308 }
11309 else {
11310 sql = _SQL_SELECT_ASSETCATEGORY;
11311
11312 if (pagination) {
11313 sql = sql.concat(AssetCategoryModelImpl.ORDER_BY_JPQL);
11314 }
11315 }
11316
11317 Session session = null;
11318
11319 try {
11320 session = openSession();
11321
11322 Query q = session.createQuery(sql);
11323
11324 if (!pagination) {
11325 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
11326 start, end, false);
11327
11328 Collections.sort(list);
11329
11330 list = new UnmodifiableList<AssetCategory>(list);
11331 }
11332 else {
11333 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
11334 start, end);
11335 }
11336
11337 cacheResult(list);
11338
11339 FinderCacheUtil.putResult(finderPath, finderArgs, list);
11340 }
11341 catch (Exception e) {
11342 FinderCacheUtil.removeResult(finderPath, finderArgs);
11343
11344 throw processException(e);
11345 }
11346 finally {
11347 closeSession(session);
11348 }
11349 }
11350
11351 return list;
11352 }
11353
11354
11359 @Override
11360 public void removeAll() throws SystemException {
11361 for (AssetCategory assetCategory : findAll()) {
11362 remove(assetCategory);
11363 }
11364 }
11365
11366
11372 @Override
11373 public int countAll() throws SystemException {
11374 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
11375 FINDER_ARGS_EMPTY, this);
11376
11377 if (count == null) {
11378 Session session = null;
11379
11380 try {
11381 session = openSession();
11382
11383 Query q = session.createQuery(_SQL_COUNT_ASSETCATEGORY);
11384
11385 count = (Long)q.uniqueResult();
11386
11387 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
11388 FINDER_ARGS_EMPTY, count);
11389 }
11390 catch (Exception e) {
11391 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_ALL,
11392 FINDER_ARGS_EMPTY);
11393
11394 throw processException(e);
11395 }
11396 finally {
11397 closeSession(session);
11398 }
11399 }
11400
11401 return count.intValue();
11402 }
11403
11404
11411 @Override
11412 public List<com.liferay.portlet.asset.model.AssetEntry> getAssetEntries(
11413 long pk) throws SystemException {
11414 return getAssetEntries(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
11415 }
11416
11417
11430 @Override
11431 public List<com.liferay.portlet.asset.model.AssetEntry> getAssetEntries(
11432 long pk, int start, int end) throws SystemException {
11433 return getAssetEntries(pk, start, end, null);
11434 }
11435
11436
11450 @Override
11451 public List<com.liferay.portlet.asset.model.AssetEntry> getAssetEntries(
11452 long pk, int start, int end, OrderByComparator orderByComparator)
11453 throws SystemException {
11454 return assetCategoryToAssetEntryTableMapper.getRightBaseModels(pk,
11455 start, end, orderByComparator);
11456 }
11457
11458
11465 @Override
11466 public int getAssetEntriesSize(long pk) throws SystemException {
11467 long[] pks = assetCategoryToAssetEntryTableMapper.getRightPrimaryKeys(pk);
11468
11469 return pks.length;
11470 }
11471
11472
11480 @Override
11481 public boolean containsAssetEntry(long pk, long assetEntryPK)
11482 throws SystemException {
11483 return assetCategoryToAssetEntryTableMapper.containsTableMapping(pk,
11484 assetEntryPK);
11485 }
11486
11487
11494 @Override
11495 public boolean containsAssetEntries(long pk) throws SystemException {
11496 if (getAssetEntriesSize(pk) > 0) {
11497 return true;
11498 }
11499 else {
11500 return false;
11501 }
11502 }
11503
11504
11511 @Override
11512 public void addAssetEntry(long pk, long assetEntryPK)
11513 throws SystemException {
11514 assetCategoryToAssetEntryTableMapper.addTableMapping(pk, assetEntryPK);
11515 }
11516
11517
11524 @Override
11525 public void addAssetEntry(long pk,
11526 com.liferay.portlet.asset.model.AssetEntry assetEntry)
11527 throws SystemException {
11528 assetCategoryToAssetEntryTableMapper.addTableMapping(pk,
11529 assetEntry.getPrimaryKey());
11530 }
11531
11532
11539 @Override
11540 public void addAssetEntries(long pk, long[] assetEntryPKs)
11541 throws SystemException {
11542 for (long assetEntryPK : assetEntryPKs) {
11543 assetCategoryToAssetEntryTableMapper.addTableMapping(pk,
11544 assetEntryPK);
11545 }
11546 }
11547
11548
11555 @Override
11556 public void addAssetEntries(long pk,
11557 List<com.liferay.portlet.asset.model.AssetEntry> assetEntries)
11558 throws SystemException {
11559 for (com.liferay.portlet.asset.model.AssetEntry assetEntry : assetEntries) {
11560 assetCategoryToAssetEntryTableMapper.addTableMapping(pk,
11561 assetEntry.getPrimaryKey());
11562 }
11563 }
11564
11565
11571 @Override
11572 public void clearAssetEntries(long pk) throws SystemException {
11573 assetCategoryToAssetEntryTableMapper.deleteLeftPrimaryKeyTableMappings(pk);
11574 }
11575
11576
11583 @Override
11584 public void removeAssetEntry(long pk, long assetEntryPK)
11585 throws SystemException {
11586 assetCategoryToAssetEntryTableMapper.deleteTableMapping(pk, assetEntryPK);
11587 }
11588
11589
11596 @Override
11597 public void removeAssetEntry(long pk,
11598 com.liferay.portlet.asset.model.AssetEntry assetEntry)
11599 throws SystemException {
11600 assetCategoryToAssetEntryTableMapper.deleteTableMapping(pk,
11601 assetEntry.getPrimaryKey());
11602 }
11603
11604
11611 @Override
11612 public void removeAssetEntries(long pk, long[] assetEntryPKs)
11613 throws SystemException {
11614 for (long assetEntryPK : assetEntryPKs) {
11615 assetCategoryToAssetEntryTableMapper.deleteTableMapping(pk,
11616 assetEntryPK);
11617 }
11618 }
11619
11620
11627 @Override
11628 public void removeAssetEntries(long pk,
11629 List<com.liferay.portlet.asset.model.AssetEntry> assetEntries)
11630 throws SystemException {
11631 for (com.liferay.portlet.asset.model.AssetEntry assetEntry : assetEntries) {
11632 assetCategoryToAssetEntryTableMapper.deleteTableMapping(pk,
11633 assetEntry.getPrimaryKey());
11634 }
11635 }
11636
11637
11644 @Override
11645 public void setAssetEntries(long pk, long[] assetEntryPKs)
11646 throws SystemException {
11647 assetCategoryToAssetEntryTableMapper.deleteLeftPrimaryKeyTableMappings(pk);
11648
11649 for (Long assetEntryPK : assetEntryPKs) {
11650 assetCategoryToAssetEntryTableMapper.addTableMapping(pk,
11651 assetEntryPK);
11652 }
11653 }
11654
11655
11662 @Override
11663 public void setAssetEntries(long pk,
11664 List<com.liferay.portlet.asset.model.AssetEntry> assetEntries)
11665 throws SystemException {
11666 try {
11667 long[] assetEntryPKs = new long[assetEntries.size()];
11668
11669 for (int i = 0; i < assetEntries.size(); i++) {
11670 com.liferay.portlet.asset.model.AssetEntry assetEntry = assetEntries.get(i);
11671
11672 assetEntryPKs[i] = assetEntry.getPrimaryKey();
11673 }
11674
11675 setAssetEntries(pk, assetEntryPKs);
11676 }
11677 catch (Exception e) {
11678 throw processException(e);
11679 }
11680 finally {
11681 FinderCacheUtil.clearCache(AssetCategoryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
11682 }
11683 }
11684
11685 @Override
11686 protected Set<String> getBadColumnNames() {
11687 return _badColumnNames;
11688 }
11689
11690
11700 @Override
11701 public void rebuildTree(long groupId, boolean force)
11702 throws SystemException {
11703 if (!rebuildTreeEnabled) {
11704 return;
11705 }
11706
11707 if (force || (countOrphanTreeNodes(groupId) > 0)) {
11708 rebuildTree(groupId, 0, 1);
11709
11710 if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
11711 CacheRegistryUtil.clear(AssetCategoryImpl.class.getName());
11712 }
11713
11714 EntityCacheUtil.clearCache(AssetCategoryImpl.class.getName());
11715 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
11716 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
11717 }
11718 }
11719
11720 @Override
11721 public void setRebuildTreeEnabled(boolean rebuildTreeEnabled) {
11722 this.rebuildTreeEnabled = rebuildTreeEnabled;
11723 }
11724
11725 protected long countOrphanTreeNodes(long groupId) throws SystemException {
11726 Session session = null;
11727
11728 try {
11729 session = openSession();
11730
11731 SQLQuery q = session.createSQLQuery(
11732 "SELECT COUNT(*) AS COUNT_VALUE FROM AssetCategory WHERE groupId = ? AND (leftCategoryId = 0 OR leftCategoryId IS NULL OR rightCategoryId = 0 OR rightCategoryId IS NULL)");
11733
11734 q.addScalar(COUNT_COLUMN_NAME,
11735 com.liferay.portal.kernel.dao.orm.Type.LONG);
11736
11737 QueryPos qPos = QueryPos.getInstance(q);
11738
11739 qPos.add(groupId);
11740
11741 return (Long)q.uniqueResult();
11742 }
11743 catch (Exception e) {
11744 throw processException(e);
11745 }
11746 finally {
11747 closeSession(session);
11748 }
11749 }
11750
11751 protected void expandNoChildrenLeftCategoryId(long groupId,
11752 long leftCategoryId, List<Long> childrenCategoryIds, long delta) {
11753 String sql = "UPDATE AssetCategory SET leftcategoryId = (leftcategoryId + ?) WHERE (groupId = ?) AND (leftcategoryId > ?) AND (categoryId NOT IN (" +
11754 StringUtil.merge(childrenCategoryIds) + "))";
11755
11756 SqlUpdate _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
11757 sql,
11758 new int[] {
11759 java.sql.Types.BIGINT, java.sql.Types.BIGINT,
11760 java.sql.Types.BIGINT
11761 });
11762
11763 _sqlUpdate.update(new Object[] { delta, groupId, leftCategoryId });
11764 }
11765
11766 protected void expandNoChildrenRightCategoryId(long groupId,
11767 long rightCategoryId, List<Long> childrenCategoryIds, long delta) {
11768 String sql = "UPDATE AssetCategory SET rightcategoryId = (rightcategoryId + ?) WHERE (groupId = ?) AND (rightcategoryId > ?) AND (categoryId NOT IN (" +
11769 StringUtil.merge(childrenCategoryIds) + "))";
11770
11771 SqlUpdate _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
11772 sql,
11773 new int[] {
11774 java.sql.Types.BIGINT, java.sql.Types.BIGINT,
11775 java.sql.Types.BIGINT
11776 });
11777
11778 _sqlUpdate.update(new Object[] { delta, groupId, rightCategoryId });
11779 }
11780
11781 protected void expandTree(AssetCategory assetCategory,
11782 List<Long> childrenCategoryIds) throws SystemException {
11783 if (!rebuildTreeEnabled) {
11784 return;
11785 }
11786
11787 long groupId = assetCategory.getGroupId();
11788
11789 long lastRightCategoryId = getLastRightCategoryId(groupId,
11790 assetCategory.getParentCategoryId());
11791
11792 long leftCategoryId = 2;
11793 long rightCategoryId = 3;
11794
11795 if (lastRightCategoryId > 0) {
11796 leftCategoryId = lastRightCategoryId + 1;
11797
11798 long childrenDistance = assetCategory.getRightCategoryId() -
11799 assetCategory.getLeftCategoryId();
11800
11801 if (childrenDistance > 1) {
11802 rightCategoryId = leftCategoryId + childrenDistance;
11803
11804 updateChildrenTree(groupId, childrenCategoryIds,
11805 leftCategoryId - assetCategory.getLeftCategoryId());
11806
11807 expandNoChildrenLeftCategoryId(groupId, lastRightCategoryId,
11808 childrenCategoryIds, childrenDistance + 1);
11809 expandNoChildrenRightCategoryId(groupId, lastRightCategoryId,
11810 childrenCategoryIds, childrenDistance + 1);
11811 }
11812 else {
11813 rightCategoryId = lastRightCategoryId + 2;
11814
11815 expandTreeLeftCategoryId.expand(groupId, lastRightCategoryId);
11816 expandTreeRightCategoryId.expand(groupId, lastRightCategoryId);
11817 }
11818
11819 if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
11820 CacheRegistryUtil.clear(AssetCategoryImpl.class.getName());
11821 }
11822
11823 EntityCacheUtil.clearCache(AssetCategoryImpl.class.getName());
11824 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
11825 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
11826 }
11827
11828 assetCategory.setLeftCategoryId(leftCategoryId);
11829 assetCategory.setRightCategoryId(rightCategoryId);
11830 }
11831
11832 protected List<Long> getChildrenTreeCategoryIds(
11833 AssetCategory parentAssetCategory) throws SystemException {
11834 Session session = null;
11835
11836 try {
11837 session = openSession();
11838
11839 SQLQuery q = session.createSQLQuery(
11840 "SELECT categoryId FROM AssetCategory WHERE (groupId = ?) AND (leftcategoryId BETWEEN ? AND ?)");
11841
11842 q.addScalar("CategoryId",
11843 com.liferay.portal.kernel.dao.orm.Type.LONG);
11844
11845 QueryPos qPos = QueryPos.getInstance(q);
11846
11847 qPos.add(parentAssetCategory.getGroupId());
11848 qPos.add(parentAssetCategory.getLeftCategoryId() + 1);
11849 qPos.add(parentAssetCategory.getRightCategoryId());
11850
11851 return q.list();
11852 }
11853 catch (Exception e) {
11854 throw processException(e);
11855 }
11856 finally {
11857 closeSession(session);
11858 }
11859 }
11860
11861 protected long getLastRightCategoryId(long groupId, long parentCategoryId)
11862 throws SystemException {
11863 Session session = null;
11864
11865 try {
11866 session = openSession();
11867
11868 SQLQuery q = session.createSQLQuery(
11869 "SELECT rightCategoryId FROM AssetCategory WHERE (groupId = ?) AND (parentCategoryId = ?) ORDER BY rightCategoryId DESC");
11870
11871 q.addScalar("rightCategoryId",
11872 com.liferay.portal.kernel.dao.orm.Type.LONG);
11873
11874 QueryPos qPos = QueryPos.getInstance(q);
11875
11876 qPos.add(groupId);
11877 qPos.add(parentCategoryId);
11878
11879 List<Long> list = (List<Long>)QueryUtil.list(q, getDialect(), 0, 1);
11880
11881 if (list.isEmpty()) {
11882 if (parentCategoryId > 0) {
11883 session.clear();
11884
11885 AssetCategory parentAssetCategory = findByPrimaryKey(parentCategoryId);
11886
11887 return parentAssetCategory.getLeftCategoryId();
11888 }
11889
11890 return 0;
11891 }
11892 else {
11893 return list.get(0);
11894 }
11895 }
11896 catch (Exception e) {
11897 throw processException(e);
11898 }
11899 finally {
11900 closeSession(session);
11901 }
11902 }
11903
11904 protected long rebuildTree(long groupId, long parentCategoryId,
11905 long leftCategoryId) throws SystemException {
11906 if (!rebuildTreeEnabled) {
11907 return 0;
11908 }
11909
11910 List<Long> categoryIds = null;
11911
11912 Session session = null;
11913
11914 try {
11915 session = openSession();
11916
11917 SQLQuery q = session.createSQLQuery(
11918 "SELECT categoryId FROM AssetCategory WHERE groupId = ? AND parentCategoryId = ? ORDER BY categoryId ASC");
11919
11920 q.addScalar("categoryId",
11921 com.liferay.portal.kernel.dao.orm.Type.LONG);
11922
11923 QueryPos qPos = QueryPos.getInstance(q);
11924
11925 qPos.add(groupId);
11926 qPos.add(parentCategoryId);
11927
11928 categoryIds = q.list();
11929 }
11930 catch (Exception e) {
11931 throw processException(e);
11932 }
11933 finally {
11934 closeSession(session);
11935 }
11936
11937 long rightCategoryId = leftCategoryId + 1;
11938
11939 for (long categoryId : categoryIds) {
11940 rightCategoryId = rebuildTree(groupId, categoryId, rightCategoryId);
11941 }
11942
11943 if (parentCategoryId > 0) {
11944 updateTree.update(parentCategoryId, leftCategoryId, rightCategoryId);
11945 }
11946
11947 return rightCategoryId + 1;
11948 }
11949
11950 protected void shrinkTree(AssetCategory assetCategory) {
11951 if (!rebuildTreeEnabled) {
11952 return;
11953 }
11954
11955 long groupId = assetCategory.getGroupId();
11956
11957 long leftCategoryId = assetCategory.getLeftCategoryId();
11958 long rightCategoryId = assetCategory.getRightCategoryId();
11959
11960 long delta = (rightCategoryId - leftCategoryId) + 1;
11961
11962 shrinkTreeLeftCategoryId.shrink(groupId, rightCategoryId, delta);
11963 shrinkTreeRightCategoryId.shrink(groupId, rightCategoryId, delta);
11964
11965 if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
11966 CacheRegistryUtil.clear(AssetCategoryImpl.class.getName());
11967 }
11968
11969 EntityCacheUtil.clearCache(AssetCategoryImpl.class.getName());
11970 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
11971 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
11972 }
11973
11974 protected void updateChildrenTree(long groupId,
11975 List<Long> childrenCategoryIds, long delta) {
11976 String sql = "UPDATE AssetCategory SET leftcategoryId = (leftcategoryId + ?), rightcategoryId = (rightcategoryId + ?) WHERE (groupId = ?) AND (categoryId IN (" +
11977 StringUtil.merge(childrenCategoryIds) + "))";
11978
11979 SqlUpdate _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
11980 sql,
11981 new int[] {
11982 java.sql.Types.BIGINT, java.sql.Types.BIGINT,
11983 java.sql.Types.BIGINT
11984 });
11985
11986 _sqlUpdate.update(new Object[] { delta, delta, groupId });
11987 }
11988
11989
11992 public void afterPropertiesSet() {
11993 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
11994 com.liferay.portal.util.PropsUtil.get(
11995 "value.object.listener.com.liferay.portlet.asset.model.AssetCategory")));
11996
11997 if (listenerClassNames.length > 0) {
11998 try {
11999 List<ModelListener<AssetCategory>> listenersList = new ArrayList<ModelListener<AssetCategory>>();
12000
12001 for (String listenerClassName : listenerClassNames) {
12002 listenersList.add((ModelListener<AssetCategory>)InstanceFactory.newInstance(
12003 getClassLoader(), listenerClassName));
12004 }
12005
12006 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
12007 }
12008 catch (Exception e) {
12009 _log.error(e);
12010 }
12011 }
12012
12013 assetCategoryToAssetEntryTableMapper = TableMapperFactory.getTableMapper("AssetEntries_AssetCategories",
12014 "categoryId", "entryId", this, assetEntryPersistence);
12015
12016 expandTreeLeftCategoryId = new ExpandTreeLeftCategoryId();
12017 expandTreeRightCategoryId = new ExpandTreeRightCategoryId();
12018 shrinkTreeLeftCategoryId = new ShrinkTreeLeftCategoryId();
12019 shrinkTreeRightCategoryId = new ShrinkTreeRightCategoryId();
12020 updateTree = new UpdateTree();
12021 }
12022
12023 public void destroy() {
12024 EntityCacheUtil.removeCache(AssetCategoryImpl.class.getName());
12025 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
12026 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
12027 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
12028 }
12029
12030 @BeanReference(type = AssetEntryPersistence.class)
12031 protected AssetEntryPersistence assetEntryPersistence;
12032 protected TableMapper<AssetCategory, com.liferay.portlet.asset.model.AssetEntry> assetCategoryToAssetEntryTableMapper;
12033 protected boolean rebuildTreeEnabled = true;
12034 protected ExpandTreeLeftCategoryId expandTreeLeftCategoryId;
12035 protected ExpandTreeRightCategoryId expandTreeRightCategoryId;
12036 protected ShrinkTreeLeftCategoryId shrinkTreeLeftCategoryId;
12037 protected ShrinkTreeRightCategoryId shrinkTreeRightCategoryId;
12038 protected UpdateTree updateTree;
12039
12040 protected class ExpandTreeLeftCategoryId {
12041 protected ExpandTreeLeftCategoryId() {
12042 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
12043 "UPDATE AssetCategory SET leftCategoryId = (leftCategoryId + 2) WHERE (groupId = ?) AND (leftCategoryId > ?)",
12044 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
12045 }
12046
12047 protected void expand(long groupId, long leftCategoryId) {
12048 _sqlUpdate.update(new Object[] { groupId, leftCategoryId });
12049 }
12050
12051 private SqlUpdate _sqlUpdate;
12052 }
12053
12054 protected class ExpandTreeRightCategoryId {
12055 protected ExpandTreeRightCategoryId() {
12056 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
12057 "UPDATE AssetCategory SET rightCategoryId = (rightCategoryId + 2) WHERE (groupId = ?) AND (rightCategoryId > ?)",
12058 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
12059 }
12060
12061 protected void expand(long groupId, long rightCategoryId) {
12062 _sqlUpdate.update(new Object[] { groupId, rightCategoryId });
12063 }
12064
12065 private SqlUpdate _sqlUpdate;
12066 }
12067
12068 protected class ShrinkTreeLeftCategoryId {
12069 protected ShrinkTreeLeftCategoryId() {
12070 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
12071 "UPDATE AssetCategory SET leftCategoryId = (leftCategoryId - ?) WHERE (groupId = ?) AND (leftCategoryId > ?)",
12072 new int[] {
12073 java.sql.Types.BIGINT, java.sql.Types.BIGINT,
12074 java.sql.Types.BIGINT
12075 });
12076 }
12077
12078 protected void shrink(long groupId, long rightCategoryId, long delta) {
12079 _sqlUpdate.update(new Object[] { delta, groupId, rightCategoryId });
12080 }
12081
12082 private SqlUpdate _sqlUpdate;
12083 }
12084
12085 protected class ShrinkTreeRightCategoryId {
12086 protected ShrinkTreeRightCategoryId() {
12087 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
12088 "UPDATE AssetCategory SET rightCategoryId = (rightCategoryId - ?) WHERE (groupId = ?) AND (rightCategoryId > ?)",
12089 new int[] {
12090 java.sql.Types.BIGINT, java.sql.Types.BIGINT,
12091 java.sql.Types.BIGINT
12092 });
12093 }
12094
12095 protected void shrink(long groupId, long rightCategoryId, long delta) {
12096 _sqlUpdate.update(new Object[] { delta, groupId, rightCategoryId });
12097 }
12098
12099 private SqlUpdate _sqlUpdate;
12100 }
12101
12102 protected class UpdateTree {
12103 protected UpdateTree() {
12104 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
12105 "UPDATE AssetCategory SET leftCategoryId = ?, rightCategoryId = ? WHERE categoryId = ?",
12106 new int[] {
12107 java.sql.Types.BIGINT, java.sql.Types.BIGINT,
12108 java.sql.Types.BIGINT
12109 });
12110 }
12111
12112 protected void update(long categoryId, long leftCategoryId,
12113 long rightCategoryId) {
12114 _sqlUpdate.update(new Object[] {
12115 leftCategoryId, rightCategoryId, categoryId
12116 });
12117 }
12118
12119 private SqlUpdate _sqlUpdate;
12120 }
12121
12122 private static final String _SQL_SELECT_ASSETCATEGORY = "SELECT assetCategory FROM AssetCategory assetCategory";
12123 private static final String _SQL_SELECT_ASSETCATEGORY_WHERE = "SELECT assetCategory FROM AssetCategory assetCategory WHERE ";
12124 private static final String _SQL_COUNT_ASSETCATEGORY = "SELECT COUNT(assetCategory) FROM AssetCategory assetCategory";
12125 private static final String _SQL_COUNT_ASSETCATEGORY_WHERE = "SELECT COUNT(assetCategory) FROM AssetCategory assetCategory WHERE ";
12126 private static final String _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN = "assetCategory.categoryId";
12127 private static final String _FILTER_SQL_SELECT_ASSETCATEGORY_WHERE = "SELECT DISTINCT {assetCategory.*} FROM AssetCategory assetCategory WHERE ";
12128 private static final String _FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_1 =
12129 "SELECT {AssetCategory.*} FROM (SELECT DISTINCT assetCategory.categoryId FROM AssetCategory assetCategory WHERE ";
12130 private static final String _FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_2 =
12131 ") TEMP_TABLE INNER JOIN AssetCategory ON TEMP_TABLE.categoryId = AssetCategory.categoryId";
12132 private static final String _FILTER_SQL_COUNT_ASSETCATEGORY_WHERE = "SELECT COUNT(DISTINCT assetCategory.categoryId) AS COUNT_VALUE FROM AssetCategory assetCategory WHERE ";
12133 private static final String _FILTER_ENTITY_ALIAS = "assetCategory";
12134 private static final String _FILTER_ENTITY_TABLE = "AssetCategory";
12135 private static final String _ORDER_BY_ENTITY_ALIAS = "assetCategory.";
12136 private static final String _ORDER_BY_ENTITY_TABLE = "AssetCategory.";
12137 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No AssetCategory exists with the primary key ";
12138 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No AssetCategory exists with the key {";
12139 private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
12140 private static Log _log = LogFactoryUtil.getLog(AssetCategoryPersistenceImpl.class);
12141 private static Set<String> _badColumnNames = SetUtil.fromArray(new String[] {
12142 "uuid"
12143 });
12144 private static AssetCategory _nullAssetCategory = new AssetCategoryImpl() {
12145 @Override
12146 public Object clone() {
12147 return this;
12148 }
12149
12150 @Override
12151 public CacheModel<AssetCategory> toCacheModel() {
12152 return _nullAssetCategoryCacheModel;
12153 }
12154 };
12155
12156 private static CacheModel<AssetCategory> _nullAssetCategoryCacheModel = new CacheModel<AssetCategory>() {
12157 @Override
12158 public AssetCategory toEntityModel() {
12159 return _nullAssetCategory;
12160 }
12161 };
12162 }