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