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 boolean bindName = false;
8386
8387 if (name == null) {
8388 query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_4);
8389 }
8390 else if (name.equals(StringPool.BLANK)) {
8391 query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_6);
8392 }
8393 else {
8394 bindName = true;
8395
8396 query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_5);
8397 }
8398
8399 conjunctionable = true;
8400
8401 if ((vocabularyIds == null) || (vocabularyIds.length > 0)) {
8402 if (conjunctionable) {
8403 query.append(WHERE_AND);
8404 }
8405
8406 query.append(StringPool.OPEN_PARENTHESIS);
8407
8408 for (int i = 0; i < vocabularyIds.length; i++) {
8409 query.append(_FINDER_COLUMN_G_LIKEN_V_VOCABULARYID_5);
8410
8411 if ((i + 1) < vocabularyIds.length) {
8412 query.append(WHERE_OR);
8413 }
8414 }
8415
8416 query.append(StringPool.CLOSE_PARENTHESIS);
8417
8418 conjunctionable = true;
8419 }
8420
8421 if (!getDB().isSupportsInlineDistinct()) {
8422 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_2);
8423 }
8424
8425 if (orderByComparator != null) {
8426 if (getDB().isSupportsInlineDistinct()) {
8427 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
8428 orderByComparator, true);
8429 }
8430 else {
8431 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
8432 orderByComparator, true);
8433 }
8434 }
8435 else {
8436 if (getDB().isSupportsInlineDistinct()) {
8437 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
8438 }
8439 else {
8440 query.append(AssetCategoryModelImpl.ORDER_BY_SQL);
8441 }
8442 }
8443
8444 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
8445 AssetCategory.class.getName(),
8446 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
8447
8448 Session session = null;
8449
8450 try {
8451 session = openSession();
8452
8453 SQLQuery q = session.createSQLQuery(sql);
8454
8455 if (getDB().isSupportsInlineDistinct()) {
8456 q.addEntity(_FILTER_ENTITY_ALIAS, AssetCategoryImpl.class);
8457 }
8458 else {
8459 q.addEntity(_FILTER_ENTITY_TABLE, AssetCategoryImpl.class);
8460 }
8461
8462 QueryPos qPos = QueryPos.getInstance(q);
8463
8464 qPos.add(groupId);
8465
8466 if (bindName) {
8467 qPos.add(name);
8468 }
8469
8470 if (vocabularyIds != null) {
8471 qPos.add(vocabularyIds);
8472 }
8473
8474 return (List<AssetCategory>)QueryUtil.list(q, getDialect(), start,
8475 end);
8476 }
8477 catch (Exception e) {
8478 throw processException(e);
8479 }
8480 finally {
8481 closeSession(session);
8482 }
8483 }
8484
8485
8498 @Override
8499 public List<AssetCategory> findByG_LikeN_V(long groupId, String name,
8500 long[] vocabularyIds) throws SystemException {
8501 return findByG_LikeN_V(groupId, name, vocabularyIds, QueryUtil.ALL_POS,
8502 QueryUtil.ALL_POS, null);
8503 }
8504
8505
8520 @Override
8521 public List<AssetCategory> findByG_LikeN_V(long groupId, String name,
8522 long[] vocabularyIds, int start, int end) throws SystemException {
8523 return findByG_LikeN_V(groupId, name, vocabularyIds, start, end, null);
8524 }
8525
8526
8542 @Override
8543 public List<AssetCategory> findByG_LikeN_V(long groupId, String name,
8544 long[] vocabularyIds, int start, int end,
8545 OrderByComparator orderByComparator) throws SystemException {
8546 if ((vocabularyIds != null) && (vocabularyIds.length == 1)) {
8547 return findByG_LikeN_V(groupId, name, vocabularyIds[0], start, end,
8548 orderByComparator);
8549 }
8550
8551 boolean pagination = true;
8552 Object[] finderArgs = null;
8553
8554 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
8555 (orderByComparator == null)) {
8556 pagination = false;
8557 finderArgs = new Object[] {
8558 groupId, name, StringUtil.merge(vocabularyIds)
8559 };
8560 }
8561 else {
8562 finderArgs = new Object[] {
8563 groupId, name, StringUtil.merge(vocabularyIds),
8564
8565 start, end, orderByComparator
8566 };
8567 }
8568
8569 List<AssetCategory> list = (List<AssetCategory>)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_LIKEN_V,
8570 finderArgs, this);
8571
8572 if ((list != null) && !list.isEmpty()) {
8573 for (AssetCategory assetCategory : list) {
8574 if ((groupId != assetCategory.getGroupId()) ||
8575 !StringUtil.wildcardMatches(assetCategory.getName(),
8576 name, CharPool.UNDERLINE, CharPool.PERCENT,
8577 CharPool.BACK_SLASH, false) ||
8578 !ArrayUtil.contains(vocabularyIds,
8579 assetCategory.getVocabularyId())) {
8580 list = null;
8581
8582 break;
8583 }
8584 }
8585 }
8586
8587 if (list == null) {
8588 StringBundler query = new StringBundler();
8589
8590 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
8591
8592 boolean conjunctionable = false;
8593
8594 if (conjunctionable) {
8595 query.append(WHERE_AND);
8596 }
8597
8598 query.append(_FINDER_COLUMN_G_LIKEN_V_GROUPID_5);
8599
8600 conjunctionable = true;
8601
8602 if (conjunctionable) {
8603 query.append(WHERE_AND);
8604 }
8605
8606 boolean bindName = false;
8607
8608 if (name == null) {
8609 query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_4);
8610 }
8611 else if (name.equals(StringPool.BLANK)) {
8612 query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_6);
8613 }
8614 else {
8615 bindName = true;
8616
8617 query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_5);
8618 }
8619
8620 conjunctionable = true;
8621
8622 if ((vocabularyIds == null) || (vocabularyIds.length > 0)) {
8623 if (conjunctionable) {
8624 query.append(WHERE_AND);
8625 }
8626
8627 query.append(StringPool.OPEN_PARENTHESIS);
8628
8629 for (int i = 0; i < vocabularyIds.length; i++) {
8630 query.append(_FINDER_COLUMN_G_LIKEN_V_VOCABULARYID_5);
8631
8632 if ((i + 1) < vocabularyIds.length) {
8633 query.append(WHERE_OR);
8634 }
8635 }
8636
8637 query.append(StringPool.CLOSE_PARENTHESIS);
8638
8639 conjunctionable = true;
8640 }
8641
8642 if (orderByComparator != null) {
8643 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
8644 orderByComparator);
8645 }
8646 else
8647 if (pagination) {
8648 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
8649 }
8650
8651 String sql = query.toString();
8652
8653 Session session = null;
8654
8655 try {
8656 session = openSession();
8657
8658 Query q = session.createQuery(sql);
8659
8660 QueryPos qPos = QueryPos.getInstance(q);
8661
8662 qPos.add(groupId);
8663
8664 if (bindName) {
8665 qPos.add(name);
8666 }
8667
8668 if (vocabularyIds != null) {
8669 qPos.add(vocabularyIds);
8670 }
8671
8672 if (!pagination) {
8673 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
8674 start, end, false);
8675
8676 Collections.sort(list);
8677
8678 list = new UnmodifiableList<AssetCategory>(list);
8679 }
8680 else {
8681 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
8682 start, end);
8683 }
8684
8685 cacheResult(list);
8686
8687 FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_LIKEN_V,
8688 finderArgs, list);
8689 }
8690 catch (Exception e) {
8691 FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_LIKEN_V,
8692 finderArgs);
8693
8694 throw processException(e);
8695 }
8696 finally {
8697 closeSession(session);
8698 }
8699 }
8700
8701 return list;
8702 }
8703
8704
8712 @Override
8713 public void removeByG_LikeN_V(long groupId, String name, long vocabularyId)
8714 throws SystemException {
8715 for (AssetCategory assetCategory : findByG_LikeN_V(groupId, name,
8716 vocabularyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
8717 remove(assetCategory);
8718 }
8719 }
8720
8721
8730 @Override
8731 public int countByG_LikeN_V(long groupId, String name, long vocabularyId)
8732 throws SystemException {
8733 FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_LIKEN_V;
8734
8735 Object[] finderArgs = new Object[] { groupId, name, vocabularyId };
8736
8737 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
8738 this);
8739
8740 if (count == null) {
8741 StringBundler query = new StringBundler(4);
8742
8743 query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
8744
8745 query.append(_FINDER_COLUMN_G_LIKEN_V_GROUPID_2);
8746
8747 boolean bindName = false;
8748
8749 if (name == null) {
8750 query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_1);
8751 }
8752 else if (name.equals(StringPool.BLANK)) {
8753 query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_3);
8754 }
8755 else {
8756 bindName = true;
8757
8758 query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_2);
8759 }
8760
8761 query.append(_FINDER_COLUMN_G_LIKEN_V_VOCABULARYID_2);
8762
8763 String sql = query.toString();
8764
8765 Session session = null;
8766
8767 try {
8768 session = openSession();
8769
8770 Query q = session.createQuery(sql);
8771
8772 QueryPos qPos = QueryPos.getInstance(q);
8773
8774 qPos.add(groupId);
8775
8776 if (bindName) {
8777 qPos.add(name.toLowerCase());
8778 }
8779
8780 qPos.add(vocabularyId);
8781
8782 count = (Long)q.uniqueResult();
8783
8784 FinderCacheUtil.putResult(finderPath, finderArgs, count);
8785 }
8786 catch (Exception e) {
8787 FinderCacheUtil.removeResult(finderPath, finderArgs);
8788
8789 throw processException(e);
8790 }
8791 finally {
8792 closeSession(session);
8793 }
8794 }
8795
8796 return count.intValue();
8797 }
8798
8799
8808 @Override
8809 public int countByG_LikeN_V(long groupId, String name, long[] vocabularyIds)
8810 throws SystemException {
8811 Object[] finderArgs = new Object[] {
8812 groupId, name, StringUtil.merge(vocabularyIds)
8813 };
8814
8815 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_LIKEN_V,
8816 finderArgs, this);
8817
8818 if (count == null) {
8819 StringBundler query = new StringBundler();
8820
8821 query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
8822
8823 boolean conjunctionable = false;
8824
8825 if (conjunctionable) {
8826 query.append(WHERE_AND);
8827 }
8828
8829 query.append(_FINDER_COLUMN_G_LIKEN_V_GROUPID_5);
8830
8831 conjunctionable = true;
8832
8833 if (conjunctionable) {
8834 query.append(WHERE_AND);
8835 }
8836
8837 boolean bindName = false;
8838
8839 if (name == null) {
8840 query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_4);
8841 }
8842 else if (name.equals(StringPool.BLANK)) {
8843 query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_6);
8844 }
8845 else {
8846 bindName = true;
8847
8848 query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_5);
8849 }
8850
8851 conjunctionable = true;
8852
8853 if ((vocabularyIds == null) || (vocabularyIds.length > 0)) {
8854 if (conjunctionable) {
8855 query.append(WHERE_AND);
8856 }
8857
8858 query.append(StringPool.OPEN_PARENTHESIS);
8859
8860 for (int i = 0; i < vocabularyIds.length; i++) {
8861 query.append(_FINDER_COLUMN_G_LIKEN_V_VOCABULARYID_5);
8862
8863 if ((i + 1) < vocabularyIds.length) {
8864 query.append(WHERE_OR);
8865 }
8866 }
8867
8868 query.append(StringPool.CLOSE_PARENTHESIS);
8869
8870 conjunctionable = true;
8871 }
8872
8873 String sql = query.toString();
8874
8875 Session session = null;
8876
8877 try {
8878 session = openSession();
8879
8880 Query q = session.createQuery(sql);
8881
8882 QueryPos qPos = QueryPos.getInstance(q);
8883
8884 qPos.add(groupId);
8885
8886 if (bindName) {
8887 qPos.add(name);
8888 }
8889
8890 if (vocabularyIds != null) {
8891 qPos.add(vocabularyIds);
8892 }
8893
8894 count = (Long)q.uniqueResult();
8895
8896 FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_LIKEN_V,
8897 finderArgs, count);
8898 }
8899 catch (Exception e) {
8900 FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_LIKEN_V,
8901 finderArgs);
8902
8903 throw processException(e);
8904 }
8905 finally {
8906 closeSession(session);
8907 }
8908 }
8909
8910 return count.intValue();
8911 }
8912
8913
8922 @Override
8923 public int filterCountByG_LikeN_V(long groupId, String name,
8924 long vocabularyId) throws SystemException {
8925 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
8926 return countByG_LikeN_V(groupId, name, vocabularyId);
8927 }
8928
8929 StringBundler query = new StringBundler(4);
8930
8931 query.append(_FILTER_SQL_COUNT_ASSETCATEGORY_WHERE);
8932
8933 query.append(_FINDER_COLUMN_G_LIKEN_V_GROUPID_2);
8934
8935 boolean bindName = false;
8936
8937 if (name == null) {
8938 query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_1);
8939 }
8940 else if (name.equals(StringPool.BLANK)) {
8941 query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_3);
8942 }
8943 else {
8944 bindName = true;
8945
8946 query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_2);
8947 }
8948
8949 query.append(_FINDER_COLUMN_G_LIKEN_V_VOCABULARYID_2);
8950
8951 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
8952 AssetCategory.class.getName(),
8953 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
8954
8955 Session session = null;
8956
8957 try {
8958 session = openSession();
8959
8960 SQLQuery q = session.createSQLQuery(sql);
8961
8962 q.addScalar(COUNT_COLUMN_NAME,
8963 com.liferay.portal.kernel.dao.orm.Type.LONG);
8964
8965 QueryPos qPos = QueryPos.getInstance(q);
8966
8967 qPos.add(groupId);
8968
8969 if (bindName) {
8970 qPos.add(name.toLowerCase());
8971 }
8972
8973 qPos.add(vocabularyId);
8974
8975 Long count = (Long)q.uniqueResult();
8976
8977 return count.intValue();
8978 }
8979 catch (Exception e) {
8980 throw processException(e);
8981 }
8982 finally {
8983 closeSession(session);
8984 }
8985 }
8986
8987
8996 @Override
8997 public int filterCountByG_LikeN_V(long groupId, String name,
8998 long[] vocabularyIds) throws SystemException {
8999 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
9000 return countByG_LikeN_V(groupId, name, vocabularyIds);
9001 }
9002
9003 StringBundler query = new StringBundler();
9004
9005 query.append(_FILTER_SQL_COUNT_ASSETCATEGORY_WHERE);
9006
9007 boolean conjunctionable = false;
9008
9009 if (conjunctionable) {
9010 query.append(WHERE_AND);
9011 }
9012
9013 query.append(_FINDER_COLUMN_G_LIKEN_V_GROUPID_5);
9014
9015 conjunctionable = true;
9016
9017 if (conjunctionable) {
9018 query.append(WHERE_AND);
9019 }
9020
9021 boolean bindName = false;
9022
9023 if (name == null) {
9024 query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_4);
9025 }
9026 else if (name.equals(StringPool.BLANK)) {
9027 query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_6);
9028 }
9029 else {
9030 bindName = true;
9031
9032 query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_5);
9033 }
9034
9035 conjunctionable = true;
9036
9037 if ((vocabularyIds == null) || (vocabularyIds.length > 0)) {
9038 if (conjunctionable) {
9039 query.append(WHERE_AND);
9040 }
9041
9042 query.append(StringPool.OPEN_PARENTHESIS);
9043
9044 for (int i = 0; i < vocabularyIds.length; i++) {
9045 query.append(_FINDER_COLUMN_G_LIKEN_V_VOCABULARYID_5);
9046
9047 if ((i + 1) < vocabularyIds.length) {
9048 query.append(WHERE_OR);
9049 }
9050 }
9051
9052 query.append(StringPool.CLOSE_PARENTHESIS);
9053
9054 conjunctionable = true;
9055 }
9056
9057 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
9058 AssetCategory.class.getName(),
9059 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
9060
9061 Session session = null;
9062
9063 try {
9064 session = openSession();
9065
9066 SQLQuery q = session.createSQLQuery(sql);
9067
9068 q.addScalar(COUNT_COLUMN_NAME,
9069 com.liferay.portal.kernel.dao.orm.Type.LONG);
9070
9071 QueryPos qPos = QueryPos.getInstance(q);
9072
9073 qPos.add(groupId);
9074
9075 if (bindName) {
9076 qPos.add(name);
9077 }
9078
9079 if (vocabularyIds != null) {
9080 qPos.add(vocabularyIds);
9081 }
9082
9083 Long count = (Long)q.uniqueResult();
9084
9085 return count.intValue();
9086 }
9087 catch (Exception e) {
9088 throw processException(e);
9089 }
9090 finally {
9091 closeSession(session);
9092 }
9093 }
9094
9095 private static final String _FINDER_COLUMN_G_LIKEN_V_GROUPID_2 = "assetCategory.groupId = ? AND ";
9096 private static final String _FINDER_COLUMN_G_LIKEN_V_GROUPID_5 = "(" +
9097 removeConjunction(_FINDER_COLUMN_G_LIKEN_V_GROUPID_2) + ")";
9098 private static final String _FINDER_COLUMN_G_LIKEN_V_NAME_1 = "assetCategory.name LIKE NULL AND ";
9099 private static final String _FINDER_COLUMN_G_LIKEN_V_NAME_2 = "lower(assetCategory.name) LIKE ? AND ";
9100 private static final String _FINDER_COLUMN_G_LIKEN_V_NAME_3 = "(assetCategory.name IS NULL OR assetCategory.name LIKE '') AND ";
9101 private static final String _FINDER_COLUMN_G_LIKEN_V_NAME_4 = "(" +
9102 removeConjunction(_FINDER_COLUMN_G_LIKEN_V_NAME_1) + ")";
9103 private static final String _FINDER_COLUMN_G_LIKEN_V_NAME_5 = "(" +
9104 removeConjunction(_FINDER_COLUMN_G_LIKEN_V_NAME_2) + ")";
9105 private static final String _FINDER_COLUMN_G_LIKEN_V_NAME_6 = "(" +
9106 removeConjunction(_FINDER_COLUMN_G_LIKEN_V_NAME_3) + ")";
9107 private static final String _FINDER_COLUMN_G_LIKEN_V_VOCABULARYID_2 = "assetCategory.vocabularyId = ?";
9108 private static final String _FINDER_COLUMN_G_LIKEN_V_VOCABULARYID_5 = "(" +
9109 removeConjunction(_FINDER_COLUMN_G_LIKEN_V_VOCABULARYID_2) + ")";
9110 public static final FinderPath FINDER_PATH_FETCH_BY_P_N_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
9111 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
9112 AssetCategoryImpl.class, FINDER_CLASS_NAME_ENTITY, "fetchByP_N_V",
9113 new String[] {
9114 Long.class.getName(), String.class.getName(),
9115 Long.class.getName()
9116 },
9117 AssetCategoryModelImpl.PARENTCATEGORYID_COLUMN_BITMASK |
9118 AssetCategoryModelImpl.NAME_COLUMN_BITMASK |
9119 AssetCategoryModelImpl.VOCABULARYID_COLUMN_BITMASK);
9120 public static final FinderPath FINDER_PATH_COUNT_BY_P_N_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
9121 AssetCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class,
9122 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByP_N_V",
9123 new String[] {
9124 Long.class.getName(), String.class.getName(),
9125 Long.class.getName()
9126 });
9127
9128
9138 @Override
9139 public AssetCategory findByP_N_V(long parentCategoryId, String name,
9140 long vocabularyId) throws NoSuchCategoryException, SystemException {
9141 AssetCategory assetCategory = fetchByP_N_V(parentCategoryId, name,
9142 vocabularyId);
9143
9144 if (assetCategory == null) {
9145 StringBundler msg = new StringBundler(8);
9146
9147 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
9148
9149 msg.append("parentCategoryId=");
9150 msg.append(parentCategoryId);
9151
9152 msg.append(", name=");
9153 msg.append(name);
9154
9155 msg.append(", vocabularyId=");
9156 msg.append(vocabularyId);
9157
9158 msg.append(StringPool.CLOSE_CURLY_BRACE);
9159
9160 if (_log.isWarnEnabled()) {
9161 _log.warn(msg.toString());
9162 }
9163
9164 throw new NoSuchCategoryException(msg.toString());
9165 }
9166
9167 return assetCategory;
9168 }
9169
9170
9179 @Override
9180 public AssetCategory fetchByP_N_V(long parentCategoryId, String name,
9181 long vocabularyId) throws SystemException {
9182 return fetchByP_N_V(parentCategoryId, name, vocabularyId, true);
9183 }
9184
9185
9195 @Override
9196 public AssetCategory fetchByP_N_V(long parentCategoryId, String name,
9197 long vocabularyId, boolean retrieveFromCache) throws SystemException {
9198 Object[] finderArgs = new Object[] { parentCategoryId, name, vocabularyId };
9199
9200 Object result = null;
9201
9202 if (retrieveFromCache) {
9203 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_P_N_V,
9204 finderArgs, this);
9205 }
9206
9207 if (result instanceof AssetCategory) {
9208 AssetCategory assetCategory = (AssetCategory)result;
9209
9210 if ((parentCategoryId != assetCategory.getParentCategoryId()) ||
9211 !Validator.equals(name, assetCategory.getName()) ||
9212 (vocabularyId != assetCategory.getVocabularyId())) {
9213 result = null;
9214 }
9215 }
9216
9217 if (result == null) {
9218 StringBundler query = new StringBundler(5);
9219
9220 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
9221
9222 query.append(_FINDER_COLUMN_P_N_V_PARENTCATEGORYID_2);
9223
9224 boolean bindName = false;
9225
9226 if (name == null) {
9227 query.append(_FINDER_COLUMN_P_N_V_NAME_1);
9228 }
9229 else if (name.equals(StringPool.BLANK)) {
9230 query.append(_FINDER_COLUMN_P_N_V_NAME_3);
9231 }
9232 else {
9233 bindName = true;
9234
9235 query.append(_FINDER_COLUMN_P_N_V_NAME_2);
9236 }
9237
9238 query.append(_FINDER_COLUMN_P_N_V_VOCABULARYID_2);
9239
9240 String sql = query.toString();
9241
9242 Session session = null;
9243
9244 try {
9245 session = openSession();
9246
9247 Query q = session.createQuery(sql);
9248
9249 QueryPos qPos = QueryPos.getInstance(q);
9250
9251 qPos.add(parentCategoryId);
9252
9253 if (bindName) {
9254 qPos.add(name);
9255 }
9256
9257 qPos.add(vocabularyId);
9258
9259 List<AssetCategory> list = q.list();
9260
9261 if (list.isEmpty()) {
9262 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_P_N_V,
9263 finderArgs, list);
9264 }
9265 else {
9266 AssetCategory assetCategory = list.get(0);
9267
9268 result = assetCategory;
9269
9270 cacheResult(assetCategory);
9271
9272 if ((assetCategory.getParentCategoryId() != parentCategoryId) ||
9273 (assetCategory.getName() == null) ||
9274 !assetCategory.getName().equals(name) ||
9275 (assetCategory.getVocabularyId() != vocabularyId)) {
9276 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_P_N_V,
9277 finderArgs, assetCategory);
9278 }
9279 }
9280 }
9281 catch (Exception e) {
9282 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_P_N_V,
9283 finderArgs);
9284
9285 throw processException(e);
9286 }
9287 finally {
9288 closeSession(session);
9289 }
9290 }
9291
9292 if (result instanceof List<?>) {
9293 return null;
9294 }
9295 else {
9296 return (AssetCategory)result;
9297 }
9298 }
9299
9300
9309 @Override
9310 public AssetCategory removeByP_N_V(long parentCategoryId, String name,
9311 long vocabularyId) throws NoSuchCategoryException, SystemException {
9312 AssetCategory assetCategory = findByP_N_V(parentCategoryId, name,
9313 vocabularyId);
9314
9315 return remove(assetCategory);
9316 }
9317
9318
9327 @Override
9328 public int countByP_N_V(long parentCategoryId, String name,
9329 long vocabularyId) throws SystemException {
9330 FinderPath finderPath = FINDER_PATH_COUNT_BY_P_N_V;
9331
9332 Object[] finderArgs = new Object[] { parentCategoryId, name, vocabularyId };
9333
9334 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
9335 this);
9336
9337 if (count == null) {
9338 StringBundler query = new StringBundler(4);
9339
9340 query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
9341
9342 query.append(_FINDER_COLUMN_P_N_V_PARENTCATEGORYID_2);
9343
9344 boolean bindName = false;
9345
9346 if (name == null) {
9347 query.append(_FINDER_COLUMN_P_N_V_NAME_1);
9348 }
9349 else if (name.equals(StringPool.BLANK)) {
9350 query.append(_FINDER_COLUMN_P_N_V_NAME_3);
9351 }
9352 else {
9353 bindName = true;
9354
9355 query.append(_FINDER_COLUMN_P_N_V_NAME_2);
9356 }
9357
9358 query.append(_FINDER_COLUMN_P_N_V_VOCABULARYID_2);
9359
9360 String sql = query.toString();
9361
9362 Session session = null;
9363
9364 try {
9365 session = openSession();
9366
9367 Query q = session.createQuery(sql);
9368
9369 QueryPos qPos = QueryPos.getInstance(q);
9370
9371 qPos.add(parentCategoryId);
9372
9373 if (bindName) {
9374 qPos.add(name);
9375 }
9376
9377 qPos.add(vocabularyId);
9378
9379 count = (Long)q.uniqueResult();
9380
9381 FinderCacheUtil.putResult(finderPath, finderArgs, count);
9382 }
9383 catch (Exception e) {
9384 FinderCacheUtil.removeResult(finderPath, finderArgs);
9385
9386 throw processException(e);
9387 }
9388 finally {
9389 closeSession(session);
9390 }
9391 }
9392
9393 return count.intValue();
9394 }
9395
9396 private static final String _FINDER_COLUMN_P_N_V_PARENTCATEGORYID_2 = "assetCategory.parentCategoryId = ? AND ";
9397 private static final String _FINDER_COLUMN_P_N_V_NAME_1 = "assetCategory.name IS NULL AND ";
9398 private static final String _FINDER_COLUMN_P_N_V_NAME_2 = "assetCategory.name = ? AND ";
9399 private static final String _FINDER_COLUMN_P_N_V_NAME_3 = "(assetCategory.name IS NULL OR assetCategory.name = '') AND ";
9400 private static final String _FINDER_COLUMN_P_N_V_VOCABULARYID_2 = "assetCategory.vocabularyId = ?";
9401 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_P_N_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
9402 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
9403 AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
9404 "findByG_P_N_V",
9405 new String[] {
9406 Long.class.getName(), Long.class.getName(),
9407 String.class.getName(), Long.class.getName(),
9408
9409 Integer.class.getName(), Integer.class.getName(),
9410 OrderByComparator.class.getName()
9411 });
9412 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_N_V =
9413 new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
9414 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
9415 AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
9416 "findByG_P_N_V",
9417 new String[] {
9418 Long.class.getName(), Long.class.getName(),
9419 String.class.getName(), Long.class.getName()
9420 },
9421 AssetCategoryModelImpl.GROUPID_COLUMN_BITMASK |
9422 AssetCategoryModelImpl.PARENTCATEGORYID_COLUMN_BITMASK |
9423 AssetCategoryModelImpl.NAME_COLUMN_BITMASK |
9424 AssetCategoryModelImpl.VOCABULARYID_COLUMN_BITMASK);
9425 public static final FinderPath FINDER_PATH_COUNT_BY_G_P_N_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
9426 AssetCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class,
9427 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_P_N_V",
9428 new String[] {
9429 Long.class.getName(), Long.class.getName(),
9430 String.class.getName(), Long.class.getName()
9431 });
9432
9433
9443 @Override
9444 public List<AssetCategory> findByG_P_N_V(long groupId,
9445 long parentCategoryId, String name, long vocabularyId)
9446 throws SystemException {
9447 return findByG_P_N_V(groupId, parentCategoryId, name, vocabularyId,
9448 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
9449 }
9450
9451
9467 @Override
9468 public List<AssetCategory> findByG_P_N_V(long groupId,
9469 long parentCategoryId, String name, long vocabularyId, int start,
9470 int end) throws SystemException {
9471 return findByG_P_N_V(groupId, parentCategoryId, name, vocabularyId,
9472 start, end, null);
9473 }
9474
9475
9492 @Override
9493 public List<AssetCategory> findByG_P_N_V(long groupId,
9494 long parentCategoryId, String name, long vocabularyId, int start,
9495 int end, OrderByComparator orderByComparator) throws SystemException {
9496 boolean pagination = true;
9497 FinderPath finderPath = null;
9498 Object[] finderArgs = null;
9499
9500 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
9501 (orderByComparator == null)) {
9502 pagination = false;
9503 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_N_V;
9504 finderArgs = new Object[] {
9505 groupId, parentCategoryId, name, vocabularyId
9506 };
9507 }
9508 else {
9509 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_P_N_V;
9510 finderArgs = new Object[] {
9511 groupId, parentCategoryId, name, vocabularyId,
9512
9513 start, end, orderByComparator
9514 };
9515 }
9516
9517 List<AssetCategory> list = (List<AssetCategory>)FinderCacheUtil.getResult(finderPath,
9518 finderArgs, this);
9519
9520 if ((list != null) && !list.isEmpty()) {
9521 for (AssetCategory assetCategory : list) {
9522 if ((groupId != assetCategory.getGroupId()) ||
9523 (parentCategoryId != assetCategory.getParentCategoryId()) ||
9524 !Validator.equals(name, assetCategory.getName()) ||
9525 (vocabularyId != assetCategory.getVocabularyId())) {
9526 list = null;
9527
9528 break;
9529 }
9530 }
9531 }
9532
9533 if (list == null) {
9534 StringBundler query = null;
9535
9536 if (orderByComparator != null) {
9537 query = new StringBundler(6 +
9538 (orderByComparator.getOrderByFields().length * 3));
9539 }
9540 else {
9541 query = new StringBundler(6);
9542 }
9543
9544 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
9545
9546 query.append(_FINDER_COLUMN_G_P_N_V_GROUPID_2);
9547
9548 query.append(_FINDER_COLUMN_G_P_N_V_PARENTCATEGORYID_2);
9549
9550 boolean bindName = false;
9551
9552 if (name == null) {
9553 query.append(_FINDER_COLUMN_G_P_N_V_NAME_1);
9554 }
9555 else if (name.equals(StringPool.BLANK)) {
9556 query.append(_FINDER_COLUMN_G_P_N_V_NAME_3);
9557 }
9558 else {
9559 bindName = true;
9560
9561 query.append(_FINDER_COLUMN_G_P_N_V_NAME_2);
9562 }
9563
9564 query.append(_FINDER_COLUMN_G_P_N_V_VOCABULARYID_2);
9565
9566 if (orderByComparator != null) {
9567 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
9568 orderByComparator);
9569 }
9570 else
9571 if (pagination) {
9572 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
9573 }
9574
9575 String sql = query.toString();
9576
9577 Session session = null;
9578
9579 try {
9580 session = openSession();
9581
9582 Query q = session.createQuery(sql);
9583
9584 QueryPos qPos = QueryPos.getInstance(q);
9585
9586 qPos.add(groupId);
9587
9588 qPos.add(parentCategoryId);
9589
9590 if (bindName) {
9591 qPos.add(name);
9592 }
9593
9594 qPos.add(vocabularyId);
9595
9596 if (!pagination) {
9597 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
9598 start, end, false);
9599
9600 Collections.sort(list);
9601
9602 list = new UnmodifiableList<AssetCategory>(list);
9603 }
9604 else {
9605 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
9606 start, end);
9607 }
9608
9609 cacheResult(list);
9610
9611 FinderCacheUtil.putResult(finderPath, finderArgs, list);
9612 }
9613 catch (Exception e) {
9614 FinderCacheUtil.removeResult(finderPath, finderArgs);
9615
9616 throw processException(e);
9617 }
9618 finally {
9619 closeSession(session);
9620 }
9621 }
9622
9623 return list;
9624 }
9625
9626
9638 @Override
9639 public AssetCategory findByG_P_N_V_First(long groupId,
9640 long parentCategoryId, String name, long vocabularyId,
9641 OrderByComparator orderByComparator)
9642 throws NoSuchCategoryException, SystemException {
9643 AssetCategory assetCategory = fetchByG_P_N_V_First(groupId,
9644 parentCategoryId, name, vocabularyId, orderByComparator);
9645
9646 if (assetCategory != null) {
9647 return assetCategory;
9648 }
9649
9650 StringBundler msg = new StringBundler(10);
9651
9652 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
9653
9654 msg.append("groupId=");
9655 msg.append(groupId);
9656
9657 msg.append(", parentCategoryId=");
9658 msg.append(parentCategoryId);
9659
9660 msg.append(", name=");
9661 msg.append(name);
9662
9663 msg.append(", vocabularyId=");
9664 msg.append(vocabularyId);
9665
9666 msg.append(StringPool.CLOSE_CURLY_BRACE);
9667
9668 throw new NoSuchCategoryException(msg.toString());
9669 }
9670
9671
9682 @Override
9683 public AssetCategory fetchByG_P_N_V_First(long groupId,
9684 long parentCategoryId, String name, long vocabularyId,
9685 OrderByComparator orderByComparator) throws SystemException {
9686 List<AssetCategory> list = findByG_P_N_V(groupId, parentCategoryId,
9687 name, vocabularyId, 0, 1, orderByComparator);
9688
9689 if (!list.isEmpty()) {
9690 return list.get(0);
9691 }
9692
9693 return null;
9694 }
9695
9696
9708 @Override
9709 public AssetCategory findByG_P_N_V_Last(long groupId,
9710 long parentCategoryId, String name, long vocabularyId,
9711 OrderByComparator orderByComparator)
9712 throws NoSuchCategoryException, SystemException {
9713 AssetCategory assetCategory = fetchByG_P_N_V_Last(groupId,
9714 parentCategoryId, name, vocabularyId, orderByComparator);
9715
9716 if (assetCategory != null) {
9717 return assetCategory;
9718 }
9719
9720 StringBundler msg = new StringBundler(10);
9721
9722 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
9723
9724 msg.append("groupId=");
9725 msg.append(groupId);
9726
9727 msg.append(", parentCategoryId=");
9728 msg.append(parentCategoryId);
9729
9730 msg.append(", name=");
9731 msg.append(name);
9732
9733 msg.append(", vocabularyId=");
9734 msg.append(vocabularyId);
9735
9736 msg.append(StringPool.CLOSE_CURLY_BRACE);
9737
9738 throw new NoSuchCategoryException(msg.toString());
9739 }
9740
9741
9752 @Override
9753 public AssetCategory fetchByG_P_N_V_Last(long groupId,
9754 long parentCategoryId, String name, long vocabularyId,
9755 OrderByComparator orderByComparator) throws SystemException {
9756 int count = countByG_P_N_V(groupId, parentCategoryId, name, vocabularyId);
9757
9758 if (count == 0) {
9759 return null;
9760 }
9761
9762 List<AssetCategory> list = findByG_P_N_V(groupId, parentCategoryId,
9763 name, vocabularyId, count - 1, count, orderByComparator);
9764
9765 if (!list.isEmpty()) {
9766 return list.get(0);
9767 }
9768
9769 return null;
9770 }
9771
9772
9785 @Override
9786 public AssetCategory[] findByG_P_N_V_PrevAndNext(long categoryId,
9787 long groupId, long parentCategoryId, String name, long vocabularyId,
9788 OrderByComparator orderByComparator)
9789 throws NoSuchCategoryException, SystemException {
9790 AssetCategory assetCategory = findByPrimaryKey(categoryId);
9791
9792 Session session = null;
9793
9794 try {
9795 session = openSession();
9796
9797 AssetCategory[] array = new AssetCategoryImpl[3];
9798
9799 array[0] = getByG_P_N_V_PrevAndNext(session, assetCategory,
9800 groupId, parentCategoryId, name, vocabularyId,
9801 orderByComparator, true);
9802
9803 array[1] = assetCategory;
9804
9805 array[2] = getByG_P_N_V_PrevAndNext(session, assetCategory,
9806 groupId, parentCategoryId, name, vocabularyId,
9807 orderByComparator, false);
9808
9809 return array;
9810 }
9811 catch (Exception e) {
9812 throw processException(e);
9813 }
9814 finally {
9815 closeSession(session);
9816 }
9817 }
9818
9819 protected AssetCategory getByG_P_N_V_PrevAndNext(Session session,
9820 AssetCategory assetCategory, long groupId, long parentCategoryId,
9821 String name, long vocabularyId, OrderByComparator orderByComparator,
9822 boolean previous) {
9823 StringBundler query = null;
9824
9825 if (orderByComparator != null) {
9826 query = new StringBundler(6 +
9827 (orderByComparator.getOrderByFields().length * 6));
9828 }
9829 else {
9830 query = new StringBundler(3);
9831 }
9832
9833 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
9834
9835 query.append(_FINDER_COLUMN_G_P_N_V_GROUPID_2);
9836
9837 query.append(_FINDER_COLUMN_G_P_N_V_PARENTCATEGORYID_2);
9838
9839 boolean bindName = false;
9840
9841 if (name == null) {
9842 query.append(_FINDER_COLUMN_G_P_N_V_NAME_1);
9843 }
9844 else if (name.equals(StringPool.BLANK)) {
9845 query.append(_FINDER_COLUMN_G_P_N_V_NAME_3);
9846 }
9847 else {
9848 bindName = true;
9849
9850 query.append(_FINDER_COLUMN_G_P_N_V_NAME_2);
9851 }
9852
9853 query.append(_FINDER_COLUMN_G_P_N_V_VOCABULARYID_2);
9854
9855 if (orderByComparator != null) {
9856 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
9857
9858 if (orderByConditionFields.length > 0) {
9859 query.append(WHERE_AND);
9860 }
9861
9862 for (int i = 0; i < orderByConditionFields.length; i++) {
9863 query.append(_ORDER_BY_ENTITY_ALIAS);
9864 query.append(orderByConditionFields[i]);
9865
9866 if ((i + 1) < orderByConditionFields.length) {
9867 if (orderByComparator.isAscending() ^ previous) {
9868 query.append(WHERE_GREATER_THAN_HAS_NEXT);
9869 }
9870 else {
9871 query.append(WHERE_LESSER_THAN_HAS_NEXT);
9872 }
9873 }
9874 else {
9875 if (orderByComparator.isAscending() ^ previous) {
9876 query.append(WHERE_GREATER_THAN);
9877 }
9878 else {
9879 query.append(WHERE_LESSER_THAN);
9880 }
9881 }
9882 }
9883
9884 query.append(ORDER_BY_CLAUSE);
9885
9886 String[] orderByFields = orderByComparator.getOrderByFields();
9887
9888 for (int i = 0; i < orderByFields.length; i++) {
9889 query.append(_ORDER_BY_ENTITY_ALIAS);
9890 query.append(orderByFields[i]);
9891
9892 if ((i + 1) < orderByFields.length) {
9893 if (orderByComparator.isAscending() ^ previous) {
9894 query.append(ORDER_BY_ASC_HAS_NEXT);
9895 }
9896 else {
9897 query.append(ORDER_BY_DESC_HAS_NEXT);
9898 }
9899 }
9900 else {
9901 if (orderByComparator.isAscending() ^ previous) {
9902 query.append(ORDER_BY_ASC);
9903 }
9904 else {
9905 query.append(ORDER_BY_DESC);
9906 }
9907 }
9908 }
9909 }
9910 else {
9911 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
9912 }
9913
9914 String sql = query.toString();
9915
9916 Query q = session.createQuery(sql);
9917
9918 q.setFirstResult(0);
9919 q.setMaxResults(2);
9920
9921 QueryPos qPos = QueryPos.getInstance(q);
9922
9923 qPos.add(groupId);
9924
9925 qPos.add(parentCategoryId);
9926
9927 if (bindName) {
9928 qPos.add(name);
9929 }
9930
9931 qPos.add(vocabularyId);
9932
9933 if (orderByComparator != null) {
9934 Object[] values = orderByComparator.getOrderByConditionValues(assetCategory);
9935
9936 for (Object value : values) {
9937 qPos.add(value);
9938 }
9939 }
9940
9941 List<AssetCategory> list = q.list();
9942
9943 if (list.size() == 2) {
9944 return list.get(1);
9945 }
9946 else {
9947 return null;
9948 }
9949 }
9950
9951
9961 @Override
9962 public List<AssetCategory> filterFindByG_P_N_V(long groupId,
9963 long parentCategoryId, String name, long vocabularyId)
9964 throws SystemException {
9965 return filterFindByG_P_N_V(groupId, parentCategoryId, name,
9966 vocabularyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
9967 }
9968
9969
9985 @Override
9986 public List<AssetCategory> filterFindByG_P_N_V(long groupId,
9987 long parentCategoryId, String name, long vocabularyId, int start,
9988 int end) throws SystemException {
9989 return filterFindByG_P_N_V(groupId, parentCategoryId, name,
9990 vocabularyId, start, end, null);
9991 }
9992
9993
10010 @Override
10011 public List<AssetCategory> filterFindByG_P_N_V(long groupId,
10012 long parentCategoryId, String name, long vocabularyId, int start,
10013 int end, OrderByComparator orderByComparator) throws SystemException {
10014 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
10015 return findByG_P_N_V(groupId, parentCategoryId, name, vocabularyId,
10016 start, end, orderByComparator);
10017 }
10018
10019 StringBundler query = null;
10020
10021 if (orderByComparator != null) {
10022 query = new StringBundler(6 +
10023 (orderByComparator.getOrderByFields().length * 3));
10024 }
10025 else {
10026 query = new StringBundler(6);
10027 }
10028
10029 if (getDB().isSupportsInlineDistinct()) {
10030 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_WHERE);
10031 }
10032 else {
10033 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_1);
10034 }
10035
10036 query.append(_FINDER_COLUMN_G_P_N_V_GROUPID_2);
10037
10038 query.append(_FINDER_COLUMN_G_P_N_V_PARENTCATEGORYID_2);
10039
10040 boolean bindName = false;
10041
10042 if (name == null) {
10043 query.append(_FINDER_COLUMN_G_P_N_V_NAME_1);
10044 }
10045 else if (name.equals(StringPool.BLANK)) {
10046 query.append(_FINDER_COLUMN_G_P_N_V_NAME_3);
10047 }
10048 else {
10049 bindName = true;
10050
10051 query.append(_FINDER_COLUMN_G_P_N_V_NAME_2);
10052 }
10053
10054 query.append(_FINDER_COLUMN_G_P_N_V_VOCABULARYID_2);
10055
10056 if (!getDB().isSupportsInlineDistinct()) {
10057 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_2);
10058 }
10059
10060 if (orderByComparator != null) {
10061 if (getDB().isSupportsInlineDistinct()) {
10062 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
10063 orderByComparator, true);
10064 }
10065 else {
10066 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
10067 orderByComparator, true);
10068 }
10069 }
10070 else {
10071 if (getDB().isSupportsInlineDistinct()) {
10072 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
10073 }
10074 else {
10075 query.append(AssetCategoryModelImpl.ORDER_BY_SQL);
10076 }
10077 }
10078
10079 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
10080 AssetCategory.class.getName(),
10081 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
10082
10083 Session session = null;
10084
10085 try {
10086 session = openSession();
10087
10088 SQLQuery q = session.createSQLQuery(sql);
10089
10090 if (getDB().isSupportsInlineDistinct()) {
10091 q.addEntity(_FILTER_ENTITY_ALIAS, AssetCategoryImpl.class);
10092 }
10093 else {
10094 q.addEntity(_FILTER_ENTITY_TABLE, AssetCategoryImpl.class);
10095 }
10096
10097 QueryPos qPos = QueryPos.getInstance(q);
10098
10099 qPos.add(groupId);
10100
10101 qPos.add(parentCategoryId);
10102
10103 if (bindName) {
10104 qPos.add(name);
10105 }
10106
10107 qPos.add(vocabularyId);
10108
10109 return (List<AssetCategory>)QueryUtil.list(q, getDialect(), start,
10110 end);
10111 }
10112 catch (Exception e) {
10113 throw processException(e);
10114 }
10115 finally {
10116 closeSession(session);
10117 }
10118 }
10119
10120
10133 @Override
10134 public AssetCategory[] filterFindByG_P_N_V_PrevAndNext(long categoryId,
10135 long groupId, long parentCategoryId, String name, long vocabularyId,
10136 OrderByComparator orderByComparator)
10137 throws NoSuchCategoryException, SystemException {
10138 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
10139 return findByG_P_N_V_PrevAndNext(categoryId, groupId,
10140 parentCategoryId, name, vocabularyId, orderByComparator);
10141 }
10142
10143 AssetCategory assetCategory = findByPrimaryKey(categoryId);
10144
10145 Session session = null;
10146
10147 try {
10148 session = openSession();
10149
10150 AssetCategory[] array = new AssetCategoryImpl[3];
10151
10152 array[0] = filterGetByG_P_N_V_PrevAndNext(session, assetCategory,
10153 groupId, parentCategoryId, name, vocabularyId,
10154 orderByComparator, true);
10155
10156 array[1] = assetCategory;
10157
10158 array[2] = filterGetByG_P_N_V_PrevAndNext(session, assetCategory,
10159 groupId, parentCategoryId, name, vocabularyId,
10160 orderByComparator, false);
10161
10162 return array;
10163 }
10164 catch (Exception e) {
10165 throw processException(e);
10166 }
10167 finally {
10168 closeSession(session);
10169 }
10170 }
10171
10172 protected AssetCategory filterGetByG_P_N_V_PrevAndNext(Session session,
10173 AssetCategory assetCategory, long groupId, long parentCategoryId,
10174 String name, long vocabularyId, OrderByComparator orderByComparator,
10175 boolean previous) {
10176 StringBundler query = null;
10177
10178 if (orderByComparator != null) {
10179 query = new StringBundler(6 +
10180 (orderByComparator.getOrderByFields().length * 6));
10181 }
10182 else {
10183 query = new StringBundler(3);
10184 }
10185
10186 if (getDB().isSupportsInlineDistinct()) {
10187 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_WHERE);
10188 }
10189 else {
10190 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_1);
10191 }
10192
10193 query.append(_FINDER_COLUMN_G_P_N_V_GROUPID_2);
10194
10195 query.append(_FINDER_COLUMN_G_P_N_V_PARENTCATEGORYID_2);
10196
10197 boolean bindName = false;
10198
10199 if (name == null) {
10200 query.append(_FINDER_COLUMN_G_P_N_V_NAME_1);
10201 }
10202 else if (name.equals(StringPool.BLANK)) {
10203 query.append(_FINDER_COLUMN_G_P_N_V_NAME_3);
10204 }
10205 else {
10206 bindName = true;
10207
10208 query.append(_FINDER_COLUMN_G_P_N_V_NAME_2);
10209 }
10210
10211 query.append(_FINDER_COLUMN_G_P_N_V_VOCABULARYID_2);
10212
10213 if (!getDB().isSupportsInlineDistinct()) {
10214 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_2);
10215 }
10216
10217 if (orderByComparator != null) {
10218 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
10219
10220 if (orderByConditionFields.length > 0) {
10221 query.append(WHERE_AND);
10222 }
10223
10224 for (int i = 0; i < orderByConditionFields.length; i++) {
10225 if (getDB().isSupportsInlineDistinct()) {
10226 query.append(_ORDER_BY_ENTITY_ALIAS);
10227 }
10228 else {
10229 query.append(_ORDER_BY_ENTITY_TABLE);
10230 }
10231
10232 query.append(orderByConditionFields[i]);
10233
10234 if ((i + 1) < orderByConditionFields.length) {
10235 if (orderByComparator.isAscending() ^ previous) {
10236 query.append(WHERE_GREATER_THAN_HAS_NEXT);
10237 }
10238 else {
10239 query.append(WHERE_LESSER_THAN_HAS_NEXT);
10240 }
10241 }
10242 else {
10243 if (orderByComparator.isAscending() ^ previous) {
10244 query.append(WHERE_GREATER_THAN);
10245 }
10246 else {
10247 query.append(WHERE_LESSER_THAN);
10248 }
10249 }
10250 }
10251
10252 query.append(ORDER_BY_CLAUSE);
10253
10254 String[] orderByFields = orderByComparator.getOrderByFields();
10255
10256 for (int i = 0; i < orderByFields.length; i++) {
10257 if (getDB().isSupportsInlineDistinct()) {
10258 query.append(_ORDER_BY_ENTITY_ALIAS);
10259 }
10260 else {
10261 query.append(_ORDER_BY_ENTITY_TABLE);
10262 }
10263
10264 query.append(orderByFields[i]);
10265
10266 if ((i + 1) < orderByFields.length) {
10267 if (orderByComparator.isAscending() ^ previous) {
10268 query.append(ORDER_BY_ASC_HAS_NEXT);
10269 }
10270 else {
10271 query.append(ORDER_BY_DESC_HAS_NEXT);
10272 }
10273 }
10274 else {
10275 if (orderByComparator.isAscending() ^ previous) {
10276 query.append(ORDER_BY_ASC);
10277 }
10278 else {
10279 query.append(ORDER_BY_DESC);
10280 }
10281 }
10282 }
10283 }
10284 else {
10285 if (getDB().isSupportsInlineDistinct()) {
10286 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
10287 }
10288 else {
10289 query.append(AssetCategoryModelImpl.ORDER_BY_SQL);
10290 }
10291 }
10292
10293 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
10294 AssetCategory.class.getName(),
10295 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
10296
10297 SQLQuery q = session.createSQLQuery(sql);
10298
10299 q.setFirstResult(0);
10300 q.setMaxResults(2);
10301
10302 if (getDB().isSupportsInlineDistinct()) {
10303 q.addEntity(_FILTER_ENTITY_ALIAS, AssetCategoryImpl.class);
10304 }
10305 else {
10306 q.addEntity(_FILTER_ENTITY_TABLE, AssetCategoryImpl.class);
10307 }
10308
10309 QueryPos qPos = QueryPos.getInstance(q);
10310
10311 qPos.add(groupId);
10312
10313 qPos.add(parentCategoryId);
10314
10315 if (bindName) {
10316 qPos.add(name);
10317 }
10318
10319 qPos.add(vocabularyId);
10320
10321 if (orderByComparator != null) {
10322 Object[] values = orderByComparator.getOrderByConditionValues(assetCategory);
10323
10324 for (Object value : values) {
10325 qPos.add(value);
10326 }
10327 }
10328
10329 List<AssetCategory> list = q.list();
10330
10331 if (list.size() == 2) {
10332 return list.get(1);
10333 }
10334 else {
10335 return null;
10336 }
10337 }
10338
10339
10348 @Override
10349 public void removeByG_P_N_V(long groupId, long parentCategoryId,
10350 String name, long vocabularyId) throws SystemException {
10351 for (AssetCategory assetCategory : findByG_P_N_V(groupId,
10352 parentCategoryId, name, vocabularyId, QueryUtil.ALL_POS,
10353 QueryUtil.ALL_POS, null)) {
10354 remove(assetCategory);
10355 }
10356 }
10357
10358
10368 @Override
10369 public int countByG_P_N_V(long groupId, long parentCategoryId, String name,
10370 long vocabularyId) throws SystemException {
10371 FinderPath finderPath = FINDER_PATH_COUNT_BY_G_P_N_V;
10372
10373 Object[] finderArgs = new Object[] {
10374 groupId, parentCategoryId, name, vocabularyId
10375 };
10376
10377 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
10378 this);
10379
10380 if (count == null) {
10381 StringBundler query = new StringBundler(5);
10382
10383 query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
10384
10385 query.append(_FINDER_COLUMN_G_P_N_V_GROUPID_2);
10386
10387 query.append(_FINDER_COLUMN_G_P_N_V_PARENTCATEGORYID_2);
10388
10389 boolean bindName = false;
10390
10391 if (name == null) {
10392 query.append(_FINDER_COLUMN_G_P_N_V_NAME_1);
10393 }
10394 else if (name.equals(StringPool.BLANK)) {
10395 query.append(_FINDER_COLUMN_G_P_N_V_NAME_3);
10396 }
10397 else {
10398 bindName = true;
10399
10400 query.append(_FINDER_COLUMN_G_P_N_V_NAME_2);
10401 }
10402
10403 query.append(_FINDER_COLUMN_G_P_N_V_VOCABULARYID_2);
10404
10405 String sql = query.toString();
10406
10407 Session session = null;
10408
10409 try {
10410 session = openSession();
10411
10412 Query q = session.createQuery(sql);
10413
10414 QueryPos qPos = QueryPos.getInstance(q);
10415
10416 qPos.add(groupId);
10417
10418 qPos.add(parentCategoryId);
10419
10420 if (bindName) {
10421 qPos.add(name);
10422 }
10423
10424 qPos.add(vocabularyId);
10425
10426 count = (Long)q.uniqueResult();
10427
10428 FinderCacheUtil.putResult(finderPath, finderArgs, count);
10429 }
10430 catch (Exception e) {
10431 FinderCacheUtil.removeResult(finderPath, finderArgs);
10432
10433 throw processException(e);
10434 }
10435 finally {
10436 closeSession(session);
10437 }
10438 }
10439
10440 return count.intValue();
10441 }
10442
10443
10453 @Override
10454 public int filterCountByG_P_N_V(long groupId, long parentCategoryId,
10455 String name, long vocabularyId) throws SystemException {
10456 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
10457 return countByG_P_N_V(groupId, parentCategoryId, name, vocabularyId);
10458 }
10459
10460 StringBundler query = new StringBundler(5);
10461
10462 query.append(_FILTER_SQL_COUNT_ASSETCATEGORY_WHERE);
10463
10464 query.append(_FINDER_COLUMN_G_P_N_V_GROUPID_2);
10465
10466 query.append(_FINDER_COLUMN_G_P_N_V_PARENTCATEGORYID_2);
10467
10468 boolean bindName = false;
10469
10470 if (name == null) {
10471 query.append(_FINDER_COLUMN_G_P_N_V_NAME_1);
10472 }
10473 else if (name.equals(StringPool.BLANK)) {
10474 query.append(_FINDER_COLUMN_G_P_N_V_NAME_3);
10475 }
10476 else {
10477 bindName = true;
10478
10479 query.append(_FINDER_COLUMN_G_P_N_V_NAME_2);
10480 }
10481
10482 query.append(_FINDER_COLUMN_G_P_N_V_VOCABULARYID_2);
10483
10484 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
10485 AssetCategory.class.getName(),
10486 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
10487
10488 Session session = null;
10489
10490 try {
10491 session = openSession();
10492
10493 SQLQuery q = session.createSQLQuery(sql);
10494
10495 q.addScalar(COUNT_COLUMN_NAME,
10496 com.liferay.portal.kernel.dao.orm.Type.LONG);
10497
10498 QueryPos qPos = QueryPos.getInstance(q);
10499
10500 qPos.add(groupId);
10501
10502 qPos.add(parentCategoryId);
10503
10504 if (bindName) {
10505 qPos.add(name);
10506 }
10507
10508 qPos.add(vocabularyId);
10509
10510 Long count = (Long)q.uniqueResult();
10511
10512 return count.intValue();
10513 }
10514 catch (Exception e) {
10515 throw processException(e);
10516 }
10517 finally {
10518 closeSession(session);
10519 }
10520 }
10521
10522 private static final String _FINDER_COLUMN_G_P_N_V_GROUPID_2 = "assetCategory.groupId = ? AND ";
10523 private static final String _FINDER_COLUMN_G_P_N_V_PARENTCATEGORYID_2 = "assetCategory.parentCategoryId = ? AND ";
10524 private static final String _FINDER_COLUMN_G_P_N_V_NAME_1 = "assetCategory.name IS NULL AND ";
10525 private static final String _FINDER_COLUMN_G_P_N_V_NAME_2 = "assetCategory.name = ? AND ";
10526 private static final String _FINDER_COLUMN_G_P_N_V_NAME_3 = "(assetCategory.name IS NULL OR assetCategory.name = '') AND ";
10527 private static final String _FINDER_COLUMN_G_P_N_V_VOCABULARYID_2 = "assetCategory.vocabularyId = ?";
10528
10529 public AssetCategoryPersistenceImpl() {
10530 setModelClass(AssetCategory.class);
10531 }
10532
10533
10538 @Override
10539 public void cacheResult(AssetCategory assetCategory) {
10540 EntityCacheUtil.putResult(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
10541 AssetCategoryImpl.class, assetCategory.getPrimaryKey(),
10542 assetCategory);
10543
10544 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
10545 new Object[] { assetCategory.getUuid(), assetCategory.getGroupId() },
10546 assetCategory);
10547
10548 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_P_N_V,
10549 new Object[] {
10550 assetCategory.getParentCategoryId(), assetCategory.getName(),
10551 assetCategory.getVocabularyId()
10552 }, assetCategory);
10553
10554 assetCategory.resetOriginalValues();
10555 }
10556
10557
10562 @Override
10563 public void cacheResult(List<AssetCategory> assetCategories) {
10564 for (AssetCategory assetCategory : assetCategories) {
10565 if (EntityCacheUtil.getResult(
10566 AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
10567 AssetCategoryImpl.class, assetCategory.getPrimaryKey()) == null) {
10568 cacheResult(assetCategory);
10569 }
10570 else {
10571 assetCategory.resetOriginalValues();
10572 }
10573 }
10574 }
10575
10576
10583 @Override
10584 public void clearCache() {
10585 if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
10586 CacheRegistryUtil.clear(AssetCategoryImpl.class.getName());
10587 }
10588
10589 EntityCacheUtil.clearCache(AssetCategoryImpl.class.getName());
10590
10591 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
10592 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
10593 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
10594 }
10595
10596
10603 @Override
10604 public void clearCache(AssetCategory assetCategory) {
10605 EntityCacheUtil.removeResult(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
10606 AssetCategoryImpl.class, assetCategory.getPrimaryKey());
10607
10608 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
10609 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
10610
10611 clearUniqueFindersCache(assetCategory);
10612 }
10613
10614 @Override
10615 public void clearCache(List<AssetCategory> assetCategories) {
10616 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
10617 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
10618
10619 for (AssetCategory assetCategory : assetCategories) {
10620 EntityCacheUtil.removeResult(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
10621 AssetCategoryImpl.class, assetCategory.getPrimaryKey());
10622
10623 clearUniqueFindersCache(assetCategory);
10624 }
10625 }
10626
10627 protected void cacheUniqueFindersCache(AssetCategory assetCategory) {
10628 if (assetCategory.isNew()) {
10629 Object[] args = new Object[] {
10630 assetCategory.getUuid(), assetCategory.getGroupId()
10631 };
10632
10633 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G, args,
10634 Long.valueOf(1));
10635 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G, args,
10636 assetCategory);
10637
10638 args = new Object[] {
10639 assetCategory.getParentCategoryId(), assetCategory.getName(),
10640 assetCategory.getVocabularyId()
10641 };
10642
10643 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_P_N_V, args,
10644 Long.valueOf(1));
10645 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_P_N_V, args,
10646 assetCategory);
10647 }
10648 else {
10649 AssetCategoryModelImpl assetCategoryModelImpl = (AssetCategoryModelImpl)assetCategory;
10650
10651 if ((assetCategoryModelImpl.getColumnBitmask() &
10652 FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) {
10653 Object[] args = new Object[] {
10654 assetCategory.getUuid(), assetCategory.getGroupId()
10655 };
10656
10657 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G, args,
10658 Long.valueOf(1));
10659 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G, args,
10660 assetCategory);
10661 }
10662
10663 if ((assetCategoryModelImpl.getColumnBitmask() &
10664 FINDER_PATH_FETCH_BY_P_N_V.getColumnBitmask()) != 0) {
10665 Object[] args = new Object[] {
10666 assetCategory.getParentCategoryId(),
10667 assetCategory.getName(), assetCategory.getVocabularyId()
10668 };
10669
10670 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_P_N_V, args,
10671 Long.valueOf(1));
10672 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_P_N_V, args,
10673 assetCategory);
10674 }
10675 }
10676 }
10677
10678 protected void clearUniqueFindersCache(AssetCategory assetCategory) {
10679 AssetCategoryModelImpl assetCategoryModelImpl = (AssetCategoryModelImpl)assetCategory;
10680
10681 Object[] args = new Object[] {
10682 assetCategory.getUuid(), assetCategory.getGroupId()
10683 };
10684
10685 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args);
10686 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args);
10687
10688 if ((assetCategoryModelImpl.getColumnBitmask() &
10689 FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) {
10690 args = new Object[] {
10691 assetCategoryModelImpl.getOriginalUuid(),
10692 assetCategoryModelImpl.getOriginalGroupId()
10693 };
10694
10695 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args);
10696 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args);
10697 }
10698
10699 args = new Object[] {
10700 assetCategory.getParentCategoryId(), assetCategory.getName(),
10701 assetCategory.getVocabularyId()
10702 };
10703
10704 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_P_N_V, args);
10705 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_P_N_V, args);
10706
10707 if ((assetCategoryModelImpl.getColumnBitmask() &
10708 FINDER_PATH_FETCH_BY_P_N_V.getColumnBitmask()) != 0) {
10709 args = new Object[] {
10710 assetCategoryModelImpl.getOriginalParentCategoryId(),
10711 assetCategoryModelImpl.getOriginalName(),
10712 assetCategoryModelImpl.getOriginalVocabularyId()
10713 };
10714
10715 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_P_N_V, args);
10716 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_P_N_V, args);
10717 }
10718 }
10719
10720
10726 @Override
10727 public AssetCategory create(long categoryId) {
10728 AssetCategory assetCategory = new AssetCategoryImpl();
10729
10730 assetCategory.setNew(true);
10731 assetCategory.setPrimaryKey(categoryId);
10732
10733 String uuid = PortalUUIDUtil.generate();
10734
10735 assetCategory.setUuid(uuid);
10736
10737 return assetCategory;
10738 }
10739
10740
10748 @Override
10749 public AssetCategory remove(long categoryId)
10750 throws NoSuchCategoryException, SystemException {
10751 return remove((Serializable)categoryId);
10752 }
10753
10754
10762 @Override
10763 public AssetCategory remove(Serializable primaryKey)
10764 throws NoSuchCategoryException, SystemException {
10765 Session session = null;
10766
10767 try {
10768 session = openSession();
10769
10770 AssetCategory assetCategory = (AssetCategory)session.get(AssetCategoryImpl.class,
10771 primaryKey);
10772
10773 if (assetCategory == null) {
10774 if (_log.isWarnEnabled()) {
10775 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
10776 }
10777
10778 throw new NoSuchCategoryException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
10779 primaryKey);
10780 }
10781
10782 return remove(assetCategory);
10783 }
10784 catch (NoSuchCategoryException nsee) {
10785 throw nsee;
10786 }
10787 catch (Exception e) {
10788 throw processException(e);
10789 }
10790 finally {
10791 closeSession(session);
10792 }
10793 }
10794
10795 @Override
10796 protected AssetCategory removeImpl(AssetCategory assetCategory)
10797 throws SystemException {
10798 assetCategory = toUnwrappedModel(assetCategory);
10799
10800 assetCategoryToAssetEntryTableMapper.deleteLeftPrimaryKeyTableMappings(assetCategory.getPrimaryKey());
10801
10802 Session session = null;
10803
10804 try {
10805 session = openSession();
10806
10807 if (rebuildTreeEnabled) {
10808 session.flush();
10809
10810 shrinkTree(assetCategory);
10811
10812 clearCache();
10813
10814 session.clear();
10815 }
10816
10817 if (!session.contains(assetCategory)) {
10818 assetCategory = (AssetCategory)session.get(AssetCategoryImpl.class,
10819 assetCategory.getPrimaryKeyObj());
10820 }
10821
10822 if (assetCategory != null) {
10823 session.delete(assetCategory);
10824 }
10825 }
10826 catch (Exception e) {
10827 throw processException(e);
10828 }
10829 finally {
10830 closeSession(session);
10831 }
10832
10833 if (assetCategory != null) {
10834 clearCache(assetCategory);
10835 }
10836
10837 return assetCategory;
10838 }
10839
10840 @Override
10841 public AssetCategory updateImpl(
10842 com.liferay.portlet.asset.model.AssetCategory assetCategory)
10843 throws SystemException {
10844 assetCategory = toUnwrappedModel(assetCategory);
10845
10846 boolean isNew = assetCategory.isNew();
10847
10848 AssetCategoryModelImpl assetCategoryModelImpl = (AssetCategoryModelImpl)assetCategory;
10849
10850 if (Validator.isNull(assetCategory.getUuid())) {
10851 String uuid = PortalUUIDUtil.generate();
10852
10853 assetCategory.setUuid(uuid);
10854 }
10855
10856 Session session = null;
10857
10858 try {
10859 session = openSession();
10860
10861 if (rebuildTreeEnabled) {
10862 session.flush();
10863
10864 if (isNew) {
10865 expandTree(assetCategory, null);
10866 }
10867 else {
10868 if (assetCategory.getParentCategoryId() != assetCategoryModelImpl.getOriginalParentCategoryId()) {
10869 List<Long> childrenCategoryIds = getChildrenTreeCategoryIds(assetCategory);
10870
10871 shrinkTree(assetCategory);
10872
10873 if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
10874 CacheRegistryUtil.clear(AssetCategoryImpl.class.getName());
10875 }
10876
10877 EntityCacheUtil.clearCache(AssetCategoryImpl.class.getName());
10878
10879 expandTree(assetCategory, childrenCategoryIds);
10880 }
10881 }
10882
10883 clearCache();
10884
10885 session.clear();
10886 }
10887
10888 if (assetCategory.isNew()) {
10889 session.save(assetCategory);
10890
10891 assetCategory.setNew(false);
10892 }
10893 else {
10894 session.merge(assetCategory);
10895 }
10896 }
10897 catch (Exception e) {
10898 throw processException(e);
10899 }
10900 finally {
10901 closeSession(session);
10902 }
10903
10904 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
10905
10906 if (isNew || !AssetCategoryModelImpl.COLUMN_BITMASK_ENABLED) {
10907 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
10908 }
10909
10910 else {
10911 if ((assetCategoryModelImpl.getColumnBitmask() &
10912 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID.getColumnBitmask()) != 0) {
10913 Object[] args = new Object[] {
10914 assetCategoryModelImpl.getOriginalUuid()
10915 };
10916
10917 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
10918 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
10919 args);
10920
10921 args = new Object[] { assetCategoryModelImpl.getUuid() };
10922
10923 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
10924 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
10925 args);
10926 }
10927
10928 if ((assetCategoryModelImpl.getColumnBitmask() &
10929 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C.getColumnBitmask()) != 0) {
10930 Object[] args = new Object[] {
10931 assetCategoryModelImpl.getOriginalUuid(),
10932 assetCategoryModelImpl.getOriginalCompanyId()
10933 };
10934
10935 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args);
10936 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C,
10937 args);
10938
10939 args = new Object[] {
10940 assetCategoryModelImpl.getUuid(),
10941 assetCategoryModelImpl.getCompanyId()
10942 };
10943
10944 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args);
10945 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C,
10946 args);
10947 }
10948
10949 if ((assetCategoryModelImpl.getColumnBitmask() &
10950 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID.getColumnBitmask()) != 0) {
10951 Object[] args = new Object[] {
10952 assetCategoryModelImpl.getOriginalGroupId()
10953 };
10954
10955 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
10956 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
10957 args);
10958
10959 args = new Object[] { assetCategoryModelImpl.getGroupId() };
10960
10961 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
10962 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
10963 args);
10964 }
10965
10966 if ((assetCategoryModelImpl.getColumnBitmask() &
10967 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_PARENTCATEGORYID.getColumnBitmask()) != 0) {
10968 Object[] args = new Object[] {
10969 assetCategoryModelImpl.getOriginalParentCategoryId()
10970 };
10971
10972 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_PARENTCATEGORYID,
10973 args);
10974 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_PARENTCATEGORYID,
10975 args);
10976
10977 args = new Object[] { assetCategoryModelImpl.getParentCategoryId() };
10978
10979 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_PARENTCATEGORYID,
10980 args);
10981 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_PARENTCATEGORYID,
10982 args);
10983 }
10984
10985 if ((assetCategoryModelImpl.getColumnBitmask() &
10986 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_VOCABULARYID.getColumnBitmask()) != 0) {
10987 Object[] args = new Object[] {
10988 assetCategoryModelImpl.getOriginalVocabularyId()
10989 };
10990
10991 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_VOCABULARYID,
10992 args);
10993 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_VOCABULARYID,
10994 args);
10995
10996 args = new Object[] { assetCategoryModelImpl.getVocabularyId() };
10997
10998 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_VOCABULARYID,
10999 args);
11000 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_VOCABULARYID,
11001 args);
11002 }
11003
11004 if ((assetCategoryModelImpl.getColumnBitmask() &
11005 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_V.getColumnBitmask()) != 0) {
11006 Object[] args = new Object[] {
11007 assetCategoryModelImpl.getOriginalGroupId(),
11008 assetCategoryModelImpl.getOriginalVocabularyId()
11009 };
11010
11011 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_V, args);
11012 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_V,
11013 args);
11014
11015 args = new Object[] {
11016 assetCategoryModelImpl.getGroupId(),
11017 assetCategoryModelImpl.getVocabularyId()
11018 };
11019
11020 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_V, args);
11021 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_V,
11022 args);
11023 }
11024
11025 if ((assetCategoryModelImpl.getColumnBitmask() &
11026 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_P_N.getColumnBitmask()) != 0) {
11027 Object[] args = new Object[] {
11028 assetCategoryModelImpl.getOriginalParentCategoryId(),
11029 assetCategoryModelImpl.getOriginalName()
11030 };
11031
11032 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_P_N, args);
11033 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_P_N,
11034 args);
11035
11036 args = new Object[] {
11037 assetCategoryModelImpl.getParentCategoryId(),
11038 assetCategoryModelImpl.getName()
11039 };
11040
11041 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_P_N, args);
11042 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_P_N,
11043 args);
11044 }
11045
11046 if ((assetCategoryModelImpl.getColumnBitmask() &
11047 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_P_V.getColumnBitmask()) != 0) {
11048 Object[] args = new Object[] {
11049 assetCategoryModelImpl.getOriginalParentCategoryId(),
11050 assetCategoryModelImpl.getOriginalVocabularyId()
11051 };
11052
11053 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_P_V, args);
11054 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_P_V,
11055 args);
11056
11057 args = new Object[] {
11058 assetCategoryModelImpl.getParentCategoryId(),
11059 assetCategoryModelImpl.getVocabularyId()
11060 };
11061
11062 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_P_V, args);
11063 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_P_V,
11064 args);
11065 }
11066
11067 if ((assetCategoryModelImpl.getColumnBitmask() &
11068 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_V.getColumnBitmask()) != 0) {
11069 Object[] args = new Object[] {
11070 assetCategoryModelImpl.getOriginalName(),
11071 assetCategoryModelImpl.getOriginalVocabularyId()
11072 };
11073
11074 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_N_V, args);
11075 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_V,
11076 args);
11077
11078 args = new Object[] {
11079 assetCategoryModelImpl.getName(),
11080 assetCategoryModelImpl.getVocabularyId()
11081 };
11082
11083 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_N_V, args);
11084 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_V,
11085 args);
11086 }
11087
11088 if ((assetCategoryModelImpl.getColumnBitmask() &
11089 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_V.getColumnBitmask()) != 0) {
11090 Object[] args = new Object[] {
11091 assetCategoryModelImpl.getOriginalGroupId(),
11092 assetCategoryModelImpl.getOriginalParentCategoryId(),
11093 assetCategoryModelImpl.getOriginalVocabularyId()
11094 };
11095
11096 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_P_V, args);
11097 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_V,
11098 args);
11099
11100 args = new Object[] {
11101 assetCategoryModelImpl.getGroupId(),
11102 assetCategoryModelImpl.getParentCategoryId(),
11103 assetCategoryModelImpl.getVocabularyId()
11104 };
11105
11106 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_P_V, args);
11107 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_V,
11108 args);
11109 }
11110
11111 if ((assetCategoryModelImpl.getColumnBitmask() &
11112 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_N_V.getColumnBitmask()) != 0) {
11113 Object[] args = new Object[] {
11114 assetCategoryModelImpl.getOriginalGroupId(),
11115 assetCategoryModelImpl.getOriginalParentCategoryId(),
11116 assetCategoryModelImpl.getOriginalName(),
11117 assetCategoryModelImpl.getOriginalVocabularyId()
11118 };
11119
11120 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_P_N_V, args);
11121 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_N_V,
11122 args);
11123
11124 args = new Object[] {
11125 assetCategoryModelImpl.getGroupId(),
11126 assetCategoryModelImpl.getParentCategoryId(),
11127 assetCategoryModelImpl.getName(),
11128 assetCategoryModelImpl.getVocabularyId()
11129 };
11130
11131 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_P_N_V, args);
11132 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_N_V,
11133 args);
11134 }
11135 }
11136
11137 EntityCacheUtil.putResult(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
11138 AssetCategoryImpl.class, assetCategory.getPrimaryKey(),
11139 assetCategory);
11140
11141 clearUniqueFindersCache(assetCategory);
11142 cacheUniqueFindersCache(assetCategory);
11143
11144 return assetCategory;
11145 }
11146
11147 protected AssetCategory toUnwrappedModel(AssetCategory assetCategory) {
11148 if (assetCategory instanceof AssetCategoryImpl) {
11149 return assetCategory;
11150 }
11151
11152 AssetCategoryImpl assetCategoryImpl = new AssetCategoryImpl();
11153
11154 assetCategoryImpl.setNew(assetCategory.isNew());
11155 assetCategoryImpl.setPrimaryKey(assetCategory.getPrimaryKey());
11156
11157 assetCategoryImpl.setUuid(assetCategory.getUuid());
11158 assetCategoryImpl.setCategoryId(assetCategory.getCategoryId());
11159 assetCategoryImpl.setGroupId(assetCategory.getGroupId());
11160 assetCategoryImpl.setCompanyId(assetCategory.getCompanyId());
11161 assetCategoryImpl.setUserId(assetCategory.getUserId());
11162 assetCategoryImpl.setUserName(assetCategory.getUserName());
11163 assetCategoryImpl.setCreateDate(assetCategory.getCreateDate());
11164 assetCategoryImpl.setModifiedDate(assetCategory.getModifiedDate());
11165 assetCategoryImpl.setParentCategoryId(assetCategory.getParentCategoryId());
11166 assetCategoryImpl.setLeftCategoryId(assetCategory.getLeftCategoryId());
11167 assetCategoryImpl.setRightCategoryId(assetCategory.getRightCategoryId());
11168 assetCategoryImpl.setName(assetCategory.getName());
11169 assetCategoryImpl.setTitle(assetCategory.getTitle());
11170 assetCategoryImpl.setDescription(assetCategory.getDescription());
11171 assetCategoryImpl.setVocabularyId(assetCategory.getVocabularyId());
11172
11173 return assetCategoryImpl;
11174 }
11175
11176
11184 @Override
11185 public AssetCategory findByPrimaryKey(Serializable primaryKey)
11186 throws NoSuchCategoryException, SystemException {
11187 AssetCategory assetCategory = fetchByPrimaryKey(primaryKey);
11188
11189 if (assetCategory == null) {
11190 if (_log.isWarnEnabled()) {
11191 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
11192 }
11193
11194 throw new NoSuchCategoryException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
11195 primaryKey);
11196 }
11197
11198 return assetCategory;
11199 }
11200
11201
11209 @Override
11210 public AssetCategory findByPrimaryKey(long categoryId)
11211 throws NoSuchCategoryException, SystemException {
11212 return findByPrimaryKey((Serializable)categoryId);
11213 }
11214
11215
11222 @Override
11223 public AssetCategory fetchByPrimaryKey(Serializable primaryKey)
11224 throws SystemException {
11225 AssetCategory assetCategory = (AssetCategory)EntityCacheUtil.getResult(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
11226 AssetCategoryImpl.class, primaryKey);
11227
11228 if (assetCategory == _nullAssetCategory) {
11229 return null;
11230 }
11231
11232 if (assetCategory == null) {
11233 Session session = null;
11234
11235 try {
11236 session = openSession();
11237
11238 assetCategory = (AssetCategory)session.get(AssetCategoryImpl.class,
11239 primaryKey);
11240
11241 if (assetCategory != null) {
11242 cacheResult(assetCategory);
11243 }
11244 else {
11245 EntityCacheUtil.putResult(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
11246 AssetCategoryImpl.class, primaryKey, _nullAssetCategory);
11247 }
11248 }
11249 catch (Exception e) {
11250 EntityCacheUtil.removeResult(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
11251 AssetCategoryImpl.class, primaryKey);
11252
11253 throw processException(e);
11254 }
11255 finally {
11256 closeSession(session);
11257 }
11258 }
11259
11260 return assetCategory;
11261 }
11262
11263
11270 @Override
11271 public AssetCategory fetchByPrimaryKey(long categoryId)
11272 throws SystemException {
11273 return fetchByPrimaryKey((Serializable)categoryId);
11274 }
11275
11276
11282 @Override
11283 public List<AssetCategory> findAll() throws SystemException {
11284 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
11285 }
11286
11287
11299 @Override
11300 public List<AssetCategory> findAll(int start, int end)
11301 throws SystemException {
11302 return findAll(start, end, null);
11303 }
11304
11305
11318 @Override
11319 public List<AssetCategory> findAll(int start, int end,
11320 OrderByComparator orderByComparator) throws SystemException {
11321 boolean pagination = true;
11322 FinderPath finderPath = null;
11323 Object[] finderArgs = null;
11324
11325 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
11326 (orderByComparator == null)) {
11327 pagination = false;
11328 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
11329 finderArgs = FINDER_ARGS_EMPTY;
11330 }
11331 else {
11332 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
11333 finderArgs = new Object[] { start, end, orderByComparator };
11334 }
11335
11336 List<AssetCategory> list = (List<AssetCategory>)FinderCacheUtil.getResult(finderPath,
11337 finderArgs, this);
11338
11339 if (list == null) {
11340 StringBundler query = null;
11341 String sql = null;
11342
11343 if (orderByComparator != null) {
11344 query = new StringBundler(2 +
11345 (orderByComparator.getOrderByFields().length * 3));
11346
11347 query.append(_SQL_SELECT_ASSETCATEGORY);
11348
11349 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
11350 orderByComparator);
11351
11352 sql = query.toString();
11353 }
11354 else {
11355 sql = _SQL_SELECT_ASSETCATEGORY;
11356
11357 if (pagination) {
11358 sql = sql.concat(AssetCategoryModelImpl.ORDER_BY_JPQL);
11359 }
11360 }
11361
11362 Session session = null;
11363
11364 try {
11365 session = openSession();
11366
11367 Query q = session.createQuery(sql);
11368
11369 if (!pagination) {
11370 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
11371 start, end, false);
11372
11373 Collections.sort(list);
11374
11375 list = new UnmodifiableList<AssetCategory>(list);
11376 }
11377 else {
11378 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
11379 start, end);
11380 }
11381
11382 cacheResult(list);
11383
11384 FinderCacheUtil.putResult(finderPath, finderArgs, list);
11385 }
11386 catch (Exception e) {
11387 FinderCacheUtil.removeResult(finderPath, finderArgs);
11388
11389 throw processException(e);
11390 }
11391 finally {
11392 closeSession(session);
11393 }
11394 }
11395
11396 return list;
11397 }
11398
11399
11404 @Override
11405 public void removeAll() throws SystemException {
11406 for (AssetCategory assetCategory : findAll()) {
11407 remove(assetCategory);
11408 }
11409 }
11410
11411
11417 @Override
11418 public int countAll() throws SystemException {
11419 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
11420 FINDER_ARGS_EMPTY, this);
11421
11422 if (count == null) {
11423 Session session = null;
11424
11425 try {
11426 session = openSession();
11427
11428 Query q = session.createQuery(_SQL_COUNT_ASSETCATEGORY);
11429
11430 count = (Long)q.uniqueResult();
11431
11432 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
11433 FINDER_ARGS_EMPTY, count);
11434 }
11435 catch (Exception e) {
11436 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_ALL,
11437 FINDER_ARGS_EMPTY);
11438
11439 throw processException(e);
11440 }
11441 finally {
11442 closeSession(session);
11443 }
11444 }
11445
11446 return count.intValue();
11447 }
11448
11449
11456 @Override
11457 public List<com.liferay.portlet.asset.model.AssetEntry> getAssetEntries(
11458 long pk) throws SystemException {
11459 return getAssetEntries(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
11460 }
11461
11462
11475 @Override
11476 public List<com.liferay.portlet.asset.model.AssetEntry> getAssetEntries(
11477 long pk, int start, int end) throws SystemException {
11478 return getAssetEntries(pk, start, end, null);
11479 }
11480
11481
11495 @Override
11496 public List<com.liferay.portlet.asset.model.AssetEntry> getAssetEntries(
11497 long pk, int start, int end, OrderByComparator orderByComparator)
11498 throws SystemException {
11499 return assetCategoryToAssetEntryTableMapper.getRightBaseModels(pk,
11500 start, end, orderByComparator);
11501 }
11502
11503
11510 @Override
11511 public int getAssetEntriesSize(long pk) throws SystemException {
11512 long[] pks = assetCategoryToAssetEntryTableMapper.getRightPrimaryKeys(pk);
11513
11514 return pks.length;
11515 }
11516
11517
11525 @Override
11526 public boolean containsAssetEntry(long pk, long assetEntryPK)
11527 throws SystemException {
11528 return assetCategoryToAssetEntryTableMapper.containsTableMapping(pk,
11529 assetEntryPK);
11530 }
11531
11532
11539 @Override
11540 public boolean containsAssetEntries(long pk) throws SystemException {
11541 if (getAssetEntriesSize(pk) > 0) {
11542 return true;
11543 }
11544 else {
11545 return false;
11546 }
11547 }
11548
11549
11556 @Override
11557 public void addAssetEntry(long pk, long assetEntryPK)
11558 throws SystemException {
11559 assetCategoryToAssetEntryTableMapper.addTableMapping(pk, assetEntryPK);
11560 }
11561
11562
11569 @Override
11570 public void addAssetEntry(long pk,
11571 com.liferay.portlet.asset.model.AssetEntry assetEntry)
11572 throws SystemException {
11573 assetCategoryToAssetEntryTableMapper.addTableMapping(pk,
11574 assetEntry.getPrimaryKey());
11575 }
11576
11577
11584 @Override
11585 public void addAssetEntries(long pk, long[] assetEntryPKs)
11586 throws SystemException {
11587 for (long assetEntryPK : assetEntryPKs) {
11588 assetCategoryToAssetEntryTableMapper.addTableMapping(pk,
11589 assetEntryPK);
11590 }
11591 }
11592
11593
11600 @Override
11601 public void addAssetEntries(long pk,
11602 List<com.liferay.portlet.asset.model.AssetEntry> assetEntries)
11603 throws SystemException {
11604 for (com.liferay.portlet.asset.model.AssetEntry assetEntry : assetEntries) {
11605 assetCategoryToAssetEntryTableMapper.addTableMapping(pk,
11606 assetEntry.getPrimaryKey());
11607 }
11608 }
11609
11610
11616 @Override
11617 public void clearAssetEntries(long pk) throws SystemException {
11618 assetCategoryToAssetEntryTableMapper.deleteLeftPrimaryKeyTableMappings(pk);
11619 }
11620
11621
11628 @Override
11629 public void removeAssetEntry(long pk, long assetEntryPK)
11630 throws SystemException {
11631 assetCategoryToAssetEntryTableMapper.deleteTableMapping(pk, assetEntryPK);
11632 }
11633
11634
11641 @Override
11642 public void removeAssetEntry(long pk,
11643 com.liferay.portlet.asset.model.AssetEntry assetEntry)
11644 throws SystemException {
11645 assetCategoryToAssetEntryTableMapper.deleteTableMapping(pk,
11646 assetEntry.getPrimaryKey());
11647 }
11648
11649
11656 @Override
11657 public void removeAssetEntries(long pk, long[] assetEntryPKs)
11658 throws SystemException {
11659 for (long assetEntryPK : assetEntryPKs) {
11660 assetCategoryToAssetEntryTableMapper.deleteTableMapping(pk,
11661 assetEntryPK);
11662 }
11663 }
11664
11665
11672 @Override
11673 public void removeAssetEntries(long pk,
11674 List<com.liferay.portlet.asset.model.AssetEntry> assetEntries)
11675 throws SystemException {
11676 for (com.liferay.portlet.asset.model.AssetEntry assetEntry : assetEntries) {
11677 assetCategoryToAssetEntryTableMapper.deleteTableMapping(pk,
11678 assetEntry.getPrimaryKey());
11679 }
11680 }
11681
11682
11689 @Override
11690 public void setAssetEntries(long pk, long[] assetEntryPKs)
11691 throws SystemException {
11692 Set<Long> newAssetEntryPKsSet = SetUtil.fromArray(assetEntryPKs);
11693 Set<Long> oldAssetEntryPKsSet = SetUtil.fromArray(assetCategoryToAssetEntryTableMapper.getRightPrimaryKeys(
11694 pk));
11695
11696 Set<Long> removeAssetEntryPKsSet = new HashSet<Long>(oldAssetEntryPKsSet);
11697
11698 removeAssetEntryPKsSet.removeAll(newAssetEntryPKsSet);
11699
11700 for (long removeAssetEntryPK : removeAssetEntryPKsSet) {
11701 assetCategoryToAssetEntryTableMapper.deleteTableMapping(pk,
11702 removeAssetEntryPK);
11703 }
11704
11705 newAssetEntryPKsSet.removeAll(oldAssetEntryPKsSet);
11706
11707 for (long newAssetEntryPK : newAssetEntryPKsSet) {
11708 assetCategoryToAssetEntryTableMapper.addTableMapping(pk,
11709 newAssetEntryPK);
11710 }
11711 }
11712
11713
11720 @Override
11721 public void setAssetEntries(long pk,
11722 List<com.liferay.portlet.asset.model.AssetEntry> assetEntries)
11723 throws SystemException {
11724 try {
11725 long[] assetEntryPKs = new long[assetEntries.size()];
11726
11727 for (int i = 0; i < assetEntries.size(); i++) {
11728 com.liferay.portlet.asset.model.AssetEntry assetEntry = assetEntries.get(i);
11729
11730 assetEntryPKs[i] = assetEntry.getPrimaryKey();
11731 }
11732
11733 setAssetEntries(pk, assetEntryPKs);
11734 }
11735 catch (Exception e) {
11736 throw processException(e);
11737 }
11738 finally {
11739 FinderCacheUtil.clearCache(AssetCategoryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
11740 }
11741 }
11742
11743 @Override
11744 protected Set<String> getBadColumnNames() {
11745 return _badColumnNames;
11746 }
11747
11748
11758 @Override
11759 public void rebuildTree(long groupId, boolean force)
11760 throws SystemException {
11761 if (!rebuildTreeEnabled) {
11762 return;
11763 }
11764
11765 if (force || (countOrphanTreeNodes(groupId) > 0)) {
11766 rebuildTree(groupId, 0, 1);
11767
11768 if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
11769 CacheRegistryUtil.clear(AssetCategoryImpl.class.getName());
11770 }
11771
11772 EntityCacheUtil.clearCache(AssetCategoryImpl.class.getName());
11773 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
11774 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
11775 }
11776 }
11777
11778 @Override
11779 public void setRebuildTreeEnabled(boolean rebuildTreeEnabled) {
11780 this.rebuildTreeEnabled = rebuildTreeEnabled;
11781 }
11782
11783 protected long countOrphanTreeNodes(long groupId) throws SystemException {
11784 Session session = null;
11785
11786 try {
11787 session = openSession();
11788
11789 SQLQuery q = session.createSQLQuery(
11790 "SELECT COUNT(*) AS COUNT_VALUE FROM AssetCategory WHERE groupId = ? AND (leftCategoryId = 0 OR leftCategoryId IS NULL OR rightCategoryId = 0 OR rightCategoryId IS NULL)");
11791
11792 q.addScalar(COUNT_COLUMN_NAME,
11793 com.liferay.portal.kernel.dao.orm.Type.LONG);
11794
11795 QueryPos qPos = QueryPos.getInstance(q);
11796
11797 qPos.add(groupId);
11798
11799 return (Long)q.uniqueResult();
11800 }
11801 catch (Exception e) {
11802 throw processException(e);
11803 }
11804 finally {
11805 closeSession(session);
11806 }
11807 }
11808
11809 protected void expandNoChildrenLeftCategoryId(long groupId,
11810 long leftCategoryId, List<Long> childrenCategoryIds, long delta) {
11811 String sql = "UPDATE AssetCategory SET leftcategoryId = (leftcategoryId + ?) WHERE (groupId = ?) AND (leftcategoryId > ?) AND (categoryId NOT IN (" +
11812 StringUtil.merge(childrenCategoryIds) + "))";
11813
11814 SqlUpdate _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
11815 sql,
11816 new int[] {
11817 java.sql.Types.BIGINT, java.sql.Types.BIGINT,
11818 java.sql.Types.BIGINT
11819 });
11820
11821 _sqlUpdate.update(new Object[] { delta, groupId, leftCategoryId });
11822 }
11823
11824 protected void expandNoChildrenRightCategoryId(long groupId,
11825 long rightCategoryId, List<Long> childrenCategoryIds, long delta) {
11826 String sql = "UPDATE AssetCategory SET rightcategoryId = (rightcategoryId + ?) WHERE (groupId = ?) AND (rightcategoryId > ?) AND (categoryId NOT IN (" +
11827 StringUtil.merge(childrenCategoryIds) + "))";
11828
11829 SqlUpdate _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
11830 sql,
11831 new int[] {
11832 java.sql.Types.BIGINT, java.sql.Types.BIGINT,
11833 java.sql.Types.BIGINT
11834 });
11835
11836 _sqlUpdate.update(new Object[] { delta, groupId, rightCategoryId });
11837 }
11838
11839 protected void expandTree(AssetCategory assetCategory,
11840 List<Long> childrenCategoryIds) throws SystemException {
11841 if (!rebuildTreeEnabled) {
11842 return;
11843 }
11844
11845 long groupId = assetCategory.getGroupId();
11846
11847 long lastRightCategoryId = getLastRightCategoryId(groupId,
11848 assetCategory.getParentCategoryId());
11849
11850 long leftCategoryId = 2;
11851 long rightCategoryId = 3;
11852
11853 if (lastRightCategoryId > 0) {
11854 leftCategoryId = lastRightCategoryId + 1;
11855
11856 long childrenDistance = assetCategory.getRightCategoryId() -
11857 assetCategory.getLeftCategoryId();
11858
11859 if (childrenDistance > 1) {
11860 rightCategoryId = leftCategoryId + childrenDistance;
11861
11862 updateChildrenTree(groupId, childrenCategoryIds,
11863 leftCategoryId - assetCategory.getLeftCategoryId());
11864
11865 expandNoChildrenLeftCategoryId(groupId, lastRightCategoryId,
11866 childrenCategoryIds, childrenDistance + 1);
11867 expandNoChildrenRightCategoryId(groupId, lastRightCategoryId,
11868 childrenCategoryIds, childrenDistance + 1);
11869 }
11870 else {
11871 rightCategoryId = lastRightCategoryId + 2;
11872
11873 expandTreeLeftCategoryId.expand(groupId, lastRightCategoryId);
11874 expandTreeRightCategoryId.expand(groupId, lastRightCategoryId);
11875 }
11876 }
11877
11878 assetCategory.setLeftCategoryId(leftCategoryId);
11879 assetCategory.setRightCategoryId(rightCategoryId);
11880 }
11881
11882 protected List<Long> getChildrenTreeCategoryIds(
11883 AssetCategory parentAssetCategory) throws SystemException {
11884 Session session = null;
11885
11886 try {
11887 session = openSession();
11888
11889 SQLQuery q = session.createSQLQuery(
11890 "SELECT categoryId FROM AssetCategory WHERE (groupId = ?) AND (leftcategoryId BETWEEN ? AND ?)");
11891
11892 q.addScalar("CategoryId",
11893 com.liferay.portal.kernel.dao.orm.Type.LONG);
11894
11895 QueryPos qPos = QueryPos.getInstance(q);
11896
11897 qPos.add(parentAssetCategory.getGroupId());
11898 qPos.add(parentAssetCategory.getLeftCategoryId() + 1);
11899 qPos.add(parentAssetCategory.getRightCategoryId());
11900
11901 return q.list();
11902 }
11903 catch (Exception e) {
11904 throw processException(e);
11905 }
11906 finally {
11907 closeSession(session);
11908 }
11909 }
11910
11911 protected long getLastRightCategoryId(long groupId, long parentCategoryId)
11912 throws SystemException {
11913 Session session = null;
11914
11915 try {
11916 session = openSession();
11917
11918 SQLQuery q = session.createSQLQuery(
11919 "SELECT rightCategoryId FROM AssetCategory WHERE (groupId = ?) AND (parentCategoryId = ?) ORDER BY rightCategoryId DESC");
11920
11921 q.addScalar("rightCategoryId",
11922 com.liferay.portal.kernel.dao.orm.Type.LONG);
11923
11924 QueryPos qPos = QueryPos.getInstance(q);
11925
11926 qPos.add(groupId);
11927 qPos.add(parentCategoryId);
11928
11929 List<Long> list = (List<Long>)QueryUtil.list(q, getDialect(), 0, 1);
11930
11931 if (list.isEmpty()) {
11932 if (parentCategoryId > 0) {
11933 session.clear();
11934
11935 AssetCategory parentAssetCategory = findByPrimaryKey(parentCategoryId);
11936
11937 return parentAssetCategory.getLeftCategoryId();
11938 }
11939
11940 return 0;
11941 }
11942 else {
11943 return list.get(0);
11944 }
11945 }
11946 catch (Exception e) {
11947 throw processException(e);
11948 }
11949 finally {
11950 closeSession(session);
11951 }
11952 }
11953
11954 protected long rebuildTree(long groupId, long parentCategoryId,
11955 long leftCategoryId) throws SystemException {
11956 if (!rebuildTreeEnabled) {
11957 return 0;
11958 }
11959
11960 List<Long> categoryIds = null;
11961
11962 Session session = null;
11963
11964 try {
11965 session = openSession();
11966
11967 SQLQuery q = session.createSQLQuery(
11968 "SELECT categoryId FROM AssetCategory WHERE groupId = ? AND parentCategoryId = ? ORDER BY categoryId ASC");
11969
11970 q.addScalar("categoryId",
11971 com.liferay.portal.kernel.dao.orm.Type.LONG);
11972
11973 QueryPos qPos = QueryPos.getInstance(q);
11974
11975 qPos.add(groupId);
11976 qPos.add(parentCategoryId);
11977
11978 categoryIds = q.list();
11979 }
11980 catch (Exception e) {
11981 throw processException(e);
11982 }
11983 finally {
11984 closeSession(session);
11985 }
11986
11987 long rightCategoryId = leftCategoryId + 1;
11988
11989 for (long categoryId : categoryIds) {
11990 rightCategoryId = rebuildTree(groupId, categoryId, rightCategoryId);
11991 }
11992
11993 if (parentCategoryId > 0) {
11994 updateTree.update(parentCategoryId, leftCategoryId, rightCategoryId);
11995 }
11996
11997 return rightCategoryId + 1;
11998 }
11999
12000 protected void shrinkTree(AssetCategory assetCategory) {
12001 if (!rebuildTreeEnabled) {
12002 return;
12003 }
12004
12005 long groupId = assetCategory.getGroupId();
12006
12007 long leftCategoryId = assetCategory.getLeftCategoryId();
12008 long rightCategoryId = assetCategory.getRightCategoryId();
12009
12010 long delta = (rightCategoryId - leftCategoryId) + 1;
12011
12012 shrinkTreeLeftCategoryId.shrink(groupId, rightCategoryId, delta);
12013 shrinkTreeRightCategoryId.shrink(groupId, rightCategoryId, delta);
12014 }
12015
12016 protected void updateChildrenTree(long groupId,
12017 List<Long> childrenCategoryIds, long delta) {
12018 String sql = "UPDATE AssetCategory SET leftcategoryId = (leftcategoryId + ?), rightcategoryId = (rightcategoryId + ?) WHERE (groupId = ?) AND (categoryId IN (" +
12019 StringUtil.merge(childrenCategoryIds) + "))";
12020
12021 SqlUpdate _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
12022 sql,
12023 new int[] {
12024 java.sql.Types.BIGINT, java.sql.Types.BIGINT,
12025 java.sql.Types.BIGINT
12026 });
12027
12028 _sqlUpdate.update(new Object[] { delta, delta, groupId });
12029 }
12030
12031
12034 public void afterPropertiesSet() {
12035 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
12036 com.liferay.portal.util.PropsUtil.get(
12037 "value.object.listener.com.liferay.portlet.asset.model.AssetCategory")));
12038
12039 if (listenerClassNames.length > 0) {
12040 try {
12041 List<ModelListener<AssetCategory>> listenersList = new ArrayList<ModelListener<AssetCategory>>();
12042
12043 for (String listenerClassName : listenerClassNames) {
12044 listenersList.add((ModelListener<AssetCategory>)InstanceFactory.newInstance(
12045 getClassLoader(), listenerClassName));
12046 }
12047
12048 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
12049 }
12050 catch (Exception e) {
12051 _log.error(e);
12052 }
12053 }
12054
12055 assetCategoryToAssetEntryTableMapper = TableMapperFactory.getTableMapper("AssetEntries_AssetCategories",
12056 "categoryId", "entryId", this, assetEntryPersistence);
12057
12058 expandTreeLeftCategoryId = new ExpandTreeLeftCategoryId();
12059 expandTreeRightCategoryId = new ExpandTreeRightCategoryId();
12060 shrinkTreeLeftCategoryId = new ShrinkTreeLeftCategoryId();
12061 shrinkTreeRightCategoryId = new ShrinkTreeRightCategoryId();
12062 updateTree = new UpdateTree();
12063 }
12064
12065 public void destroy() {
12066 EntityCacheUtil.removeCache(AssetCategoryImpl.class.getName());
12067 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
12068 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
12069 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
12070
12071 TableMapperFactory.removeTableMapper("AssetEntries_AssetCategories");
12072 }
12073
12074 @BeanReference(type = AssetEntryPersistence.class)
12075 protected AssetEntryPersistence assetEntryPersistence;
12076 protected TableMapper<AssetCategory, com.liferay.portlet.asset.model.AssetEntry> assetCategoryToAssetEntryTableMapper;
12077 protected boolean rebuildTreeEnabled = true;
12078 protected ExpandTreeLeftCategoryId expandTreeLeftCategoryId;
12079 protected ExpandTreeRightCategoryId expandTreeRightCategoryId;
12080 protected ShrinkTreeLeftCategoryId shrinkTreeLeftCategoryId;
12081 protected ShrinkTreeRightCategoryId shrinkTreeRightCategoryId;
12082 protected UpdateTree updateTree;
12083
12084 protected class ExpandTreeLeftCategoryId {
12085 protected ExpandTreeLeftCategoryId() {
12086 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
12087 "UPDATE AssetCategory SET leftCategoryId = (leftCategoryId + 2) WHERE (groupId = ?) AND (leftCategoryId > ?)",
12088 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
12089 }
12090
12091 protected void expand(long groupId, long leftCategoryId) {
12092 _sqlUpdate.update(new Object[] { groupId, leftCategoryId });
12093 }
12094
12095 private SqlUpdate _sqlUpdate;
12096 }
12097
12098 protected class ExpandTreeRightCategoryId {
12099 protected ExpandTreeRightCategoryId() {
12100 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
12101 "UPDATE AssetCategory SET rightCategoryId = (rightCategoryId + 2) WHERE (groupId = ?) AND (rightCategoryId > ?)",
12102 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
12103 }
12104
12105 protected void expand(long groupId, long rightCategoryId) {
12106 _sqlUpdate.update(new Object[] { groupId, rightCategoryId });
12107 }
12108
12109 private SqlUpdate _sqlUpdate;
12110 }
12111
12112 protected class ShrinkTreeLeftCategoryId {
12113 protected ShrinkTreeLeftCategoryId() {
12114 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
12115 "UPDATE AssetCategory SET leftCategoryId = (leftCategoryId - ?) WHERE (groupId = ?) AND (leftCategoryId > ?)",
12116 new int[] {
12117 java.sql.Types.BIGINT, java.sql.Types.BIGINT,
12118 java.sql.Types.BIGINT
12119 });
12120 }
12121
12122 protected void shrink(long groupId, long rightCategoryId, long delta) {
12123 _sqlUpdate.update(new Object[] { delta, groupId, rightCategoryId });
12124 }
12125
12126 private SqlUpdate _sqlUpdate;
12127 }
12128
12129 protected class ShrinkTreeRightCategoryId {
12130 protected ShrinkTreeRightCategoryId() {
12131 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
12132 "UPDATE AssetCategory SET rightCategoryId = (rightCategoryId - ?) WHERE (groupId = ?) AND (rightCategoryId > ?)",
12133 new int[] {
12134 java.sql.Types.BIGINT, java.sql.Types.BIGINT,
12135 java.sql.Types.BIGINT
12136 });
12137 }
12138
12139 protected void shrink(long groupId, long rightCategoryId, long delta) {
12140 _sqlUpdate.update(new Object[] { delta, groupId, rightCategoryId });
12141 }
12142
12143 private SqlUpdate _sqlUpdate;
12144 }
12145
12146 protected class UpdateTree {
12147 protected UpdateTree() {
12148 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
12149 "UPDATE AssetCategory SET leftCategoryId = ?, rightCategoryId = ? WHERE categoryId = ?",
12150 new int[] {
12151 java.sql.Types.BIGINT, java.sql.Types.BIGINT,
12152 java.sql.Types.BIGINT
12153 });
12154 }
12155
12156 protected void update(long categoryId, long leftCategoryId,
12157 long rightCategoryId) {
12158 _sqlUpdate.update(new Object[] {
12159 leftCategoryId, rightCategoryId, categoryId
12160 });
12161 }
12162
12163 private SqlUpdate _sqlUpdate;
12164 }
12165
12166 private static final String _SQL_SELECT_ASSETCATEGORY = "SELECT assetCategory FROM AssetCategory assetCategory";
12167 private static final String _SQL_SELECT_ASSETCATEGORY_WHERE = "SELECT assetCategory FROM AssetCategory assetCategory WHERE ";
12168 private static final String _SQL_COUNT_ASSETCATEGORY = "SELECT COUNT(assetCategory) FROM AssetCategory assetCategory";
12169 private static final String _SQL_COUNT_ASSETCATEGORY_WHERE = "SELECT COUNT(assetCategory) FROM AssetCategory assetCategory WHERE ";
12170 private static final String _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN = "assetCategory.categoryId";
12171 private static final String _FILTER_SQL_SELECT_ASSETCATEGORY_WHERE = "SELECT DISTINCT {assetCategory.*} FROM AssetCategory assetCategory WHERE ";
12172 private static final String _FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_1 =
12173 "SELECT {AssetCategory.*} FROM (SELECT DISTINCT assetCategory.categoryId FROM AssetCategory assetCategory WHERE ";
12174 private static final String _FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_2 =
12175 ") TEMP_TABLE INNER JOIN AssetCategory ON TEMP_TABLE.categoryId = AssetCategory.categoryId";
12176 private static final String _FILTER_SQL_COUNT_ASSETCATEGORY_WHERE = "SELECT COUNT(DISTINCT assetCategory.categoryId) AS COUNT_VALUE FROM AssetCategory assetCategory WHERE ";
12177 private static final String _FILTER_ENTITY_ALIAS = "assetCategory";
12178 private static final String _FILTER_ENTITY_TABLE = "AssetCategory";
12179 private static final String _ORDER_BY_ENTITY_ALIAS = "assetCategory.";
12180 private static final String _ORDER_BY_ENTITY_TABLE = "AssetCategory.";
12181 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No AssetCategory exists with the primary key ";
12182 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No AssetCategory exists with the key {";
12183 private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
12184 private static Log _log = LogFactoryUtil.getLog(AssetCategoryPersistenceImpl.class);
12185 private static Set<String> _badColumnNames = SetUtil.fromArray(new String[] {
12186 "uuid"
12187 });
12188 private static AssetCategory _nullAssetCategory = new AssetCategoryImpl() {
12189 @Override
12190 public Object clone() {
12191 return this;
12192 }
12193
12194 @Override
12195 public CacheModel<AssetCategory> toCacheModel() {
12196 return _nullAssetCategoryCacheModel;
12197 }
12198 };
12199
12200 private static CacheModel<AssetCategory> _nullAssetCategoryCacheModel = new CacheModel<AssetCategory>() {
12201 @Override
12202 public AssetCategory toEntityModel() {
12203 return _nullAssetCategory;
12204 }
12205 };
12206 }