001
014
015 package com.liferay.portlet.asset.service.persistence.impl;
016
017 import aQute.bnd.annotation.ProviderType;
018
019 import com.liferay.portal.kernel.bean.BeanReference;
020 import com.liferay.portal.kernel.cache.CacheRegistryUtil;
021 import com.liferay.portal.kernel.dao.jdbc.SqlUpdate;
022 import com.liferay.portal.kernel.dao.jdbc.SqlUpdateFactoryUtil;
023 import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
024 import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
025 import com.liferay.portal.kernel.dao.orm.FinderPath;
026 import com.liferay.portal.kernel.dao.orm.Query;
027 import com.liferay.portal.kernel.dao.orm.QueryPos;
028 import com.liferay.portal.kernel.dao.orm.QueryUtil;
029 import com.liferay.portal.kernel.dao.orm.SQLQuery;
030 import com.liferay.portal.kernel.dao.orm.Session;
031 import com.liferay.portal.kernel.exception.SystemException;
032 import com.liferay.portal.kernel.log.Log;
033 import com.liferay.portal.kernel.log.LogFactoryUtil;
034 import com.liferay.portal.kernel.util.ArrayUtil;
035 import com.liferay.portal.kernel.util.CharPool;
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.Validator;
042 import com.liferay.portal.kernel.uuid.PortalUUIDUtil;
043 import com.liferay.portal.model.CacheModel;
044 import com.liferay.portal.security.permission.InlineSQLHelperUtil;
045 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
046 import com.liferay.portal.service.persistence.impl.NestedSetsTreeManager;
047 import com.liferay.portal.service.persistence.impl.PersistenceNestedSetsTreeManager;
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 import com.liferay.portlet.asset.service.persistence.AssetCategoryPersistence;
056 import com.liferay.portlet.asset.service.persistence.AssetEntryPersistence;
057
058 import java.io.Serializable;
059
060 import java.util.Collections;
061 import java.util.HashMap;
062 import java.util.HashSet;
063 import java.util.Iterator;
064 import java.util.List;
065 import java.util.Map;
066 import java.util.Set;
067
068
080 @ProviderType
081 public class AssetCategoryPersistenceImpl extends BasePersistenceImpl<AssetCategory>
082 implements AssetCategoryPersistence {
083
088 public static final String FINDER_CLASS_NAME_ENTITY = AssetCategoryImpl.class.getName();
089 public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
090 ".List1";
091 public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
092 ".List2";
093 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
094 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
095 AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
096 "findAll", new String[0]);
097 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
098 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
099 AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
100 "findAll", new String[0]);
101 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
102 AssetCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class,
103 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
104 public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_ANCESTORS = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
105 AssetCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class,
106 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countAncestors",
107 new String[] {
108 Long.class.getName(), Long.class.getName(), Long.class.getName()
109 });
110 public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_DESCENDANTS =
111 new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
112 AssetCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class,
113 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countDescendants",
114 new String[] {
115 Long.class.getName(), Long.class.getName(), Long.class.getName()
116 });
117 public static final FinderPath FINDER_PATH_WITH_PAGINATION_GET_ANCESTORS = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
118 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
119 AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
120 "getAncestors",
121 new String[] {
122 Long.class.getName(), Long.class.getName(), Long.class.getName()
123 });
124 public static final FinderPath FINDER_PATH_WITH_PAGINATION_GET_DESCENDANTS = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
125 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
126 AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
127 "getDescendants",
128 new String[] {
129 Long.class.getName(), Long.class.getName(), Long.class.getName()
130 });
131 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
132 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
133 AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
134 "findByUuid",
135 new String[] {
136 String.class.getName(),
137
138 Integer.class.getName(), Integer.class.getName(),
139 OrderByComparator.class.getName()
140 });
141 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
142 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
143 AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
144 "findByUuid", new String[] { String.class.getName() },
145 AssetCategoryModelImpl.UUID_COLUMN_BITMASK |
146 AssetCategoryModelImpl.NAME_COLUMN_BITMASK);
147 public static final FinderPath FINDER_PATH_COUNT_BY_UUID = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
148 AssetCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class,
149 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid",
150 new String[] { String.class.getName() });
151
152
158 @Override
159 public List<AssetCategory> findByUuid(String uuid) {
160 return findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
161 }
162
163
175 @Override
176 public List<AssetCategory> findByUuid(String uuid, int start, int end) {
177 return findByUuid(uuid, start, end, null);
178 }
179
180
193 @Override
194 public List<AssetCategory> findByUuid(String uuid, int start, int end,
195 OrderByComparator<AssetCategory> orderByComparator) {
196 boolean pagination = true;
197 FinderPath finderPath = null;
198 Object[] finderArgs = null;
199
200 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
201 (orderByComparator == null)) {
202 pagination = false;
203 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID;
204 finderArgs = new Object[] { uuid };
205 }
206 else {
207 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID;
208 finderArgs = new Object[] { uuid, start, end, orderByComparator };
209 }
210
211 List<AssetCategory> list = (List<AssetCategory>)FinderCacheUtil.getResult(finderPath,
212 finderArgs, this);
213
214 if ((list != null) && !list.isEmpty()) {
215 for (AssetCategory assetCategory : list) {
216 if (!Validator.equals(uuid, assetCategory.getUuid())) {
217 list = null;
218
219 break;
220 }
221 }
222 }
223
224 if (list == null) {
225 StringBundler query = null;
226
227 if (orderByComparator != null) {
228 query = new StringBundler(3 +
229 (orderByComparator.getOrderByFields().length * 3));
230 }
231 else {
232 query = new StringBundler(3);
233 }
234
235 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
236
237 boolean bindUuid = false;
238
239 if (uuid == null) {
240 query.append(_FINDER_COLUMN_UUID_UUID_1);
241 }
242 else if (uuid.equals(StringPool.BLANK)) {
243 query.append(_FINDER_COLUMN_UUID_UUID_3);
244 }
245 else {
246 bindUuid = true;
247
248 query.append(_FINDER_COLUMN_UUID_UUID_2);
249 }
250
251 if (orderByComparator != null) {
252 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
253 orderByComparator);
254 }
255 else
256 if (pagination) {
257 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
258 }
259
260 String sql = query.toString();
261
262 Session session = null;
263
264 try {
265 session = openSession();
266
267 Query q = session.createQuery(sql);
268
269 QueryPos qPos = QueryPos.getInstance(q);
270
271 if (bindUuid) {
272 qPos.add(uuid);
273 }
274
275 if (!pagination) {
276 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
277 start, end, false);
278
279 Collections.sort(list);
280
281 list = Collections.unmodifiableList(list);
282 }
283 else {
284 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
285 start, end);
286 }
287
288 cacheResult(list);
289
290 FinderCacheUtil.putResult(finderPath, finderArgs, list);
291 }
292 catch (Exception e) {
293 FinderCacheUtil.removeResult(finderPath, finderArgs);
294
295 throw processException(e);
296 }
297 finally {
298 closeSession(session);
299 }
300 }
301
302 return list;
303 }
304
305
313 @Override
314 public AssetCategory findByUuid_First(String uuid,
315 OrderByComparator<AssetCategory> orderByComparator)
316 throws NoSuchCategoryException {
317 AssetCategory assetCategory = fetchByUuid_First(uuid, orderByComparator);
318
319 if (assetCategory != null) {
320 return assetCategory;
321 }
322
323 StringBundler msg = new StringBundler(4);
324
325 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
326
327 msg.append("uuid=");
328 msg.append(uuid);
329
330 msg.append(StringPool.CLOSE_CURLY_BRACE);
331
332 throw new NoSuchCategoryException(msg.toString());
333 }
334
335
342 @Override
343 public AssetCategory fetchByUuid_First(String uuid,
344 OrderByComparator<AssetCategory> orderByComparator) {
345 List<AssetCategory> list = findByUuid(uuid, 0, 1, orderByComparator);
346
347 if (!list.isEmpty()) {
348 return list.get(0);
349 }
350
351 return null;
352 }
353
354
362 @Override
363 public AssetCategory findByUuid_Last(String uuid,
364 OrderByComparator<AssetCategory> orderByComparator)
365 throws NoSuchCategoryException {
366 AssetCategory assetCategory = fetchByUuid_Last(uuid, orderByComparator);
367
368 if (assetCategory != null) {
369 return assetCategory;
370 }
371
372 StringBundler msg = new StringBundler(4);
373
374 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
375
376 msg.append("uuid=");
377 msg.append(uuid);
378
379 msg.append(StringPool.CLOSE_CURLY_BRACE);
380
381 throw new NoSuchCategoryException(msg.toString());
382 }
383
384
391 @Override
392 public AssetCategory fetchByUuid_Last(String uuid,
393 OrderByComparator<AssetCategory> orderByComparator) {
394 int count = countByUuid(uuid);
395
396 if (count == 0) {
397 return null;
398 }
399
400 List<AssetCategory> list = findByUuid(uuid, count - 1, count,
401 orderByComparator);
402
403 if (!list.isEmpty()) {
404 return list.get(0);
405 }
406
407 return null;
408 }
409
410
419 @Override
420 public AssetCategory[] findByUuid_PrevAndNext(long categoryId, String uuid,
421 OrderByComparator<AssetCategory> orderByComparator)
422 throws NoSuchCategoryException {
423 AssetCategory assetCategory = findByPrimaryKey(categoryId);
424
425 Session session = null;
426
427 try {
428 session = openSession();
429
430 AssetCategory[] array = new AssetCategoryImpl[3];
431
432 array[0] = getByUuid_PrevAndNext(session, assetCategory, uuid,
433 orderByComparator, true);
434
435 array[1] = assetCategory;
436
437 array[2] = getByUuid_PrevAndNext(session, assetCategory, uuid,
438 orderByComparator, false);
439
440 return array;
441 }
442 catch (Exception e) {
443 throw processException(e);
444 }
445 finally {
446 closeSession(session);
447 }
448 }
449
450 protected AssetCategory getByUuid_PrevAndNext(Session session,
451 AssetCategory assetCategory, String uuid,
452 OrderByComparator<AssetCategory> orderByComparator, boolean previous) {
453 StringBundler query = null;
454
455 if (orderByComparator != null) {
456 query = new StringBundler(6 +
457 (orderByComparator.getOrderByFields().length * 6));
458 }
459 else {
460 query = new StringBundler(3);
461 }
462
463 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
464
465 boolean bindUuid = false;
466
467 if (uuid == null) {
468 query.append(_FINDER_COLUMN_UUID_UUID_1);
469 }
470 else if (uuid.equals(StringPool.BLANK)) {
471 query.append(_FINDER_COLUMN_UUID_UUID_3);
472 }
473 else {
474 bindUuid = true;
475
476 query.append(_FINDER_COLUMN_UUID_UUID_2);
477 }
478
479 if (orderByComparator != null) {
480 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
481
482 if (orderByConditionFields.length > 0) {
483 query.append(WHERE_AND);
484 }
485
486 for (int i = 0; i < orderByConditionFields.length; i++) {
487 query.append(_ORDER_BY_ENTITY_ALIAS);
488 query.append(orderByConditionFields[i]);
489
490 if ((i + 1) < orderByConditionFields.length) {
491 if (orderByComparator.isAscending() ^ previous) {
492 query.append(WHERE_GREATER_THAN_HAS_NEXT);
493 }
494 else {
495 query.append(WHERE_LESSER_THAN_HAS_NEXT);
496 }
497 }
498 else {
499 if (orderByComparator.isAscending() ^ previous) {
500 query.append(WHERE_GREATER_THAN);
501 }
502 else {
503 query.append(WHERE_LESSER_THAN);
504 }
505 }
506 }
507
508 query.append(ORDER_BY_CLAUSE);
509
510 String[] orderByFields = orderByComparator.getOrderByFields();
511
512 for (int i = 0; i < orderByFields.length; i++) {
513 query.append(_ORDER_BY_ENTITY_ALIAS);
514 query.append(orderByFields[i]);
515
516 if ((i + 1) < orderByFields.length) {
517 if (orderByComparator.isAscending() ^ previous) {
518 query.append(ORDER_BY_ASC_HAS_NEXT);
519 }
520 else {
521 query.append(ORDER_BY_DESC_HAS_NEXT);
522 }
523 }
524 else {
525 if (orderByComparator.isAscending() ^ previous) {
526 query.append(ORDER_BY_ASC);
527 }
528 else {
529 query.append(ORDER_BY_DESC);
530 }
531 }
532 }
533 }
534 else {
535 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
536 }
537
538 String sql = query.toString();
539
540 Query q = session.createQuery(sql);
541
542 q.setFirstResult(0);
543 q.setMaxResults(2);
544
545 QueryPos qPos = QueryPos.getInstance(q);
546
547 if (bindUuid) {
548 qPos.add(uuid);
549 }
550
551 if (orderByComparator != null) {
552 Object[] values = orderByComparator.getOrderByConditionValues(assetCategory);
553
554 for (Object value : values) {
555 qPos.add(value);
556 }
557 }
558
559 List<AssetCategory> list = q.list();
560
561 if (list.size() == 2) {
562 return list.get(1);
563 }
564 else {
565 return null;
566 }
567 }
568
569
574 @Override
575 public void removeByUuid(String uuid) {
576 for (AssetCategory assetCategory : findByUuid(uuid, QueryUtil.ALL_POS,
577 QueryUtil.ALL_POS, null)) {
578 remove(assetCategory);
579 }
580 }
581
582
588 @Override
589 public int countByUuid(String uuid) {
590 FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID;
591
592 Object[] finderArgs = new Object[] { uuid };
593
594 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
595 this);
596
597 if (count == null) {
598 StringBundler query = new StringBundler(2);
599
600 query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
601
602 boolean bindUuid = false;
603
604 if (uuid == null) {
605 query.append(_FINDER_COLUMN_UUID_UUID_1);
606 }
607 else if (uuid.equals(StringPool.BLANK)) {
608 query.append(_FINDER_COLUMN_UUID_UUID_3);
609 }
610 else {
611 bindUuid = true;
612
613 query.append(_FINDER_COLUMN_UUID_UUID_2);
614 }
615
616 String sql = query.toString();
617
618 Session session = null;
619
620 try {
621 session = openSession();
622
623 Query q = session.createQuery(sql);
624
625 QueryPos qPos = QueryPos.getInstance(q);
626
627 if (bindUuid) {
628 qPos.add(uuid);
629 }
630
631 count = (Long)q.uniqueResult();
632
633 FinderCacheUtil.putResult(finderPath, finderArgs, count);
634 }
635 catch (Exception e) {
636 FinderCacheUtil.removeResult(finderPath, finderArgs);
637
638 throw processException(e);
639 }
640 finally {
641 closeSession(session);
642 }
643 }
644
645 return count.intValue();
646 }
647
648 private static final String _FINDER_COLUMN_UUID_UUID_1 = "assetCategory.uuid IS NULL";
649 private static final String _FINDER_COLUMN_UUID_UUID_2 = "assetCategory.uuid = ?";
650 private static final String _FINDER_COLUMN_UUID_UUID_3 = "(assetCategory.uuid IS NULL OR assetCategory.uuid = '')";
651 public static final FinderPath FINDER_PATH_FETCH_BY_UUID_G = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
652 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
653 AssetCategoryImpl.class, FINDER_CLASS_NAME_ENTITY, "fetchByUUID_G",
654 new String[] { String.class.getName(), Long.class.getName() },
655 AssetCategoryModelImpl.UUID_COLUMN_BITMASK |
656 AssetCategoryModelImpl.GROUPID_COLUMN_BITMASK);
657 public static final FinderPath FINDER_PATH_COUNT_BY_UUID_G = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
658 AssetCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class,
659 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUUID_G",
660 new String[] { String.class.getName(), Long.class.getName() });
661
662
670 @Override
671 public AssetCategory findByUUID_G(String uuid, long groupId)
672 throws NoSuchCategoryException {
673 AssetCategory assetCategory = fetchByUUID_G(uuid, groupId);
674
675 if (assetCategory == null) {
676 StringBundler msg = new StringBundler(6);
677
678 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
679
680 msg.append("uuid=");
681 msg.append(uuid);
682
683 msg.append(", groupId=");
684 msg.append(groupId);
685
686 msg.append(StringPool.CLOSE_CURLY_BRACE);
687
688 if (_log.isWarnEnabled()) {
689 _log.warn(msg.toString());
690 }
691
692 throw new NoSuchCategoryException(msg.toString());
693 }
694
695 return assetCategory;
696 }
697
698
705 @Override
706 public AssetCategory fetchByUUID_G(String uuid, long groupId) {
707 return fetchByUUID_G(uuid, groupId, true);
708 }
709
710
718 @Override
719 public AssetCategory fetchByUUID_G(String uuid, long groupId,
720 boolean retrieveFromCache) {
721 Object[] finderArgs = new Object[] { uuid, groupId };
722
723 Object result = null;
724
725 if (retrieveFromCache) {
726 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_UUID_G,
727 finderArgs, this);
728 }
729
730 if (result instanceof AssetCategory) {
731 AssetCategory assetCategory = (AssetCategory)result;
732
733 if (!Validator.equals(uuid, assetCategory.getUuid()) ||
734 (groupId != assetCategory.getGroupId())) {
735 result = null;
736 }
737 }
738
739 if (result == null) {
740 StringBundler query = new StringBundler(4);
741
742 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
743
744 boolean bindUuid = false;
745
746 if (uuid == null) {
747 query.append(_FINDER_COLUMN_UUID_G_UUID_1);
748 }
749 else if (uuid.equals(StringPool.BLANK)) {
750 query.append(_FINDER_COLUMN_UUID_G_UUID_3);
751 }
752 else {
753 bindUuid = true;
754
755 query.append(_FINDER_COLUMN_UUID_G_UUID_2);
756 }
757
758 query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
759
760 String sql = query.toString();
761
762 Session session = null;
763
764 try {
765 session = openSession();
766
767 Query q = session.createQuery(sql);
768
769 QueryPos qPos = QueryPos.getInstance(q);
770
771 if (bindUuid) {
772 qPos.add(uuid);
773 }
774
775 qPos.add(groupId);
776
777 List<AssetCategory> list = q.list();
778
779 if (list.isEmpty()) {
780 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
781 finderArgs, list);
782 }
783 else {
784 AssetCategory assetCategory = list.get(0);
785
786 result = assetCategory;
787
788 cacheResult(assetCategory);
789
790 if ((assetCategory.getUuid() == null) ||
791 !assetCategory.getUuid().equals(uuid) ||
792 (assetCategory.getGroupId() != groupId)) {
793 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
794 finderArgs, assetCategory);
795 }
796 }
797 }
798 catch (Exception e) {
799 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
800 finderArgs);
801
802 throw processException(e);
803 }
804 finally {
805 closeSession(session);
806 }
807 }
808
809 if (result instanceof List<?>) {
810 return null;
811 }
812 else {
813 return (AssetCategory)result;
814 }
815 }
816
817
824 @Override
825 public AssetCategory removeByUUID_G(String uuid, long groupId)
826 throws NoSuchCategoryException {
827 AssetCategory assetCategory = findByUUID_G(uuid, groupId);
828
829 return remove(assetCategory);
830 }
831
832
839 @Override
840 public int countByUUID_G(String uuid, long groupId) {
841 FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID_G;
842
843 Object[] finderArgs = new Object[] { uuid, groupId };
844
845 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
846 this);
847
848 if (count == null) {
849 StringBundler query = new StringBundler(3);
850
851 query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
852
853 boolean bindUuid = false;
854
855 if (uuid == null) {
856 query.append(_FINDER_COLUMN_UUID_G_UUID_1);
857 }
858 else if (uuid.equals(StringPool.BLANK)) {
859 query.append(_FINDER_COLUMN_UUID_G_UUID_3);
860 }
861 else {
862 bindUuid = true;
863
864 query.append(_FINDER_COLUMN_UUID_G_UUID_2);
865 }
866
867 query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
868
869 String sql = query.toString();
870
871 Session session = null;
872
873 try {
874 session = openSession();
875
876 Query q = session.createQuery(sql);
877
878 QueryPos qPos = QueryPos.getInstance(q);
879
880 if (bindUuid) {
881 qPos.add(uuid);
882 }
883
884 qPos.add(groupId);
885
886 count = (Long)q.uniqueResult();
887
888 FinderCacheUtil.putResult(finderPath, finderArgs, count);
889 }
890 catch (Exception e) {
891 FinderCacheUtil.removeResult(finderPath, finderArgs);
892
893 throw processException(e);
894 }
895 finally {
896 closeSession(session);
897 }
898 }
899
900 return count.intValue();
901 }
902
903 private static final String _FINDER_COLUMN_UUID_G_UUID_1 = "assetCategory.uuid IS NULL AND ";
904 private static final String _FINDER_COLUMN_UUID_G_UUID_2 = "assetCategory.uuid = ? AND ";
905 private static final String _FINDER_COLUMN_UUID_G_UUID_3 = "(assetCategory.uuid IS NULL OR assetCategory.uuid = '') AND ";
906 private static final String _FINDER_COLUMN_UUID_G_GROUPID_2 = "assetCategory.groupId = ?";
907 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID_C = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
908 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
909 AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
910 "findByUuid_C",
911 new String[] {
912 String.class.getName(), Long.class.getName(),
913
914 Integer.class.getName(), Integer.class.getName(),
915 OrderByComparator.class.getName()
916 });
917 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C =
918 new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
919 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
920 AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
921 "findByUuid_C",
922 new String[] { String.class.getName(), Long.class.getName() },
923 AssetCategoryModelImpl.UUID_COLUMN_BITMASK |
924 AssetCategoryModelImpl.COMPANYID_COLUMN_BITMASK |
925 AssetCategoryModelImpl.NAME_COLUMN_BITMASK);
926 public static final FinderPath FINDER_PATH_COUNT_BY_UUID_C = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
927 AssetCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class,
928 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid_C",
929 new String[] { String.class.getName(), Long.class.getName() });
930
931
938 @Override
939 public List<AssetCategory> findByUuid_C(String uuid, long companyId) {
940 return findByUuid_C(uuid, companyId, QueryUtil.ALL_POS,
941 QueryUtil.ALL_POS, null);
942 }
943
944
957 @Override
958 public List<AssetCategory> findByUuid_C(String uuid, long companyId,
959 int start, int end) {
960 return findByUuid_C(uuid, companyId, start, end, null);
961 }
962
963
977 @Override
978 public List<AssetCategory> findByUuid_C(String uuid, long companyId,
979 int start, int end, OrderByComparator<AssetCategory> orderByComparator) {
980 boolean pagination = true;
981 FinderPath finderPath = null;
982 Object[] finderArgs = null;
983
984 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
985 (orderByComparator == null)) {
986 pagination = false;
987 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C;
988 finderArgs = new Object[] { uuid, companyId };
989 }
990 else {
991 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID_C;
992 finderArgs = new Object[] {
993 uuid, companyId,
994
995 start, end, orderByComparator
996 };
997 }
998
999 List<AssetCategory> list = (List<AssetCategory>)FinderCacheUtil.getResult(finderPath,
1000 finderArgs, this);
1001
1002 if ((list != null) && !list.isEmpty()) {
1003 for (AssetCategory assetCategory : list) {
1004 if (!Validator.equals(uuid, assetCategory.getUuid()) ||
1005 (companyId != assetCategory.getCompanyId())) {
1006 list = null;
1007
1008 break;
1009 }
1010 }
1011 }
1012
1013 if (list == null) {
1014 StringBundler query = null;
1015
1016 if (orderByComparator != null) {
1017 query = new StringBundler(4 +
1018 (orderByComparator.getOrderByFields().length * 3));
1019 }
1020 else {
1021 query = new StringBundler(4);
1022 }
1023
1024 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
1025
1026 boolean bindUuid = false;
1027
1028 if (uuid == null) {
1029 query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1030 }
1031 else if (uuid.equals(StringPool.BLANK)) {
1032 query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1033 }
1034 else {
1035 bindUuid = true;
1036
1037 query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1038 }
1039
1040 query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1041
1042 if (orderByComparator != null) {
1043 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1044 orderByComparator);
1045 }
1046 else
1047 if (pagination) {
1048 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
1049 }
1050
1051 String sql = query.toString();
1052
1053 Session session = null;
1054
1055 try {
1056 session = openSession();
1057
1058 Query q = session.createQuery(sql);
1059
1060 QueryPos qPos = QueryPos.getInstance(q);
1061
1062 if (bindUuid) {
1063 qPos.add(uuid);
1064 }
1065
1066 qPos.add(companyId);
1067
1068 if (!pagination) {
1069 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
1070 start, end, false);
1071
1072 Collections.sort(list);
1073
1074 list = Collections.unmodifiableList(list);
1075 }
1076 else {
1077 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
1078 start, end);
1079 }
1080
1081 cacheResult(list);
1082
1083 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1084 }
1085 catch (Exception e) {
1086 FinderCacheUtil.removeResult(finderPath, finderArgs);
1087
1088 throw processException(e);
1089 }
1090 finally {
1091 closeSession(session);
1092 }
1093 }
1094
1095 return list;
1096 }
1097
1098
1107 @Override
1108 public AssetCategory findByUuid_C_First(String uuid, long companyId,
1109 OrderByComparator<AssetCategory> orderByComparator)
1110 throws NoSuchCategoryException {
1111 AssetCategory assetCategory = fetchByUuid_C_First(uuid, companyId,
1112 orderByComparator);
1113
1114 if (assetCategory != null) {
1115 return assetCategory;
1116 }
1117
1118 StringBundler msg = new StringBundler(6);
1119
1120 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1121
1122 msg.append("uuid=");
1123 msg.append(uuid);
1124
1125 msg.append(", companyId=");
1126 msg.append(companyId);
1127
1128 msg.append(StringPool.CLOSE_CURLY_BRACE);
1129
1130 throw new NoSuchCategoryException(msg.toString());
1131 }
1132
1133
1141 @Override
1142 public AssetCategory fetchByUuid_C_First(String uuid, long companyId,
1143 OrderByComparator<AssetCategory> orderByComparator) {
1144 List<AssetCategory> list = findByUuid_C(uuid, companyId, 0, 1,
1145 orderByComparator);
1146
1147 if (!list.isEmpty()) {
1148 return list.get(0);
1149 }
1150
1151 return null;
1152 }
1153
1154
1163 @Override
1164 public AssetCategory findByUuid_C_Last(String uuid, long companyId,
1165 OrderByComparator<AssetCategory> orderByComparator)
1166 throws NoSuchCategoryException {
1167 AssetCategory assetCategory = fetchByUuid_C_Last(uuid, companyId,
1168 orderByComparator);
1169
1170 if (assetCategory != null) {
1171 return assetCategory;
1172 }
1173
1174 StringBundler msg = new StringBundler(6);
1175
1176 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1177
1178 msg.append("uuid=");
1179 msg.append(uuid);
1180
1181 msg.append(", companyId=");
1182 msg.append(companyId);
1183
1184 msg.append(StringPool.CLOSE_CURLY_BRACE);
1185
1186 throw new NoSuchCategoryException(msg.toString());
1187 }
1188
1189
1197 @Override
1198 public AssetCategory fetchByUuid_C_Last(String uuid, long companyId,
1199 OrderByComparator<AssetCategory> orderByComparator) {
1200 int count = countByUuid_C(uuid, companyId);
1201
1202 if (count == 0) {
1203 return null;
1204 }
1205
1206 List<AssetCategory> list = findByUuid_C(uuid, companyId, count - 1,
1207 count, orderByComparator);
1208
1209 if (!list.isEmpty()) {
1210 return list.get(0);
1211 }
1212
1213 return null;
1214 }
1215
1216
1226 @Override
1227 public AssetCategory[] findByUuid_C_PrevAndNext(long categoryId,
1228 String uuid, long companyId,
1229 OrderByComparator<AssetCategory> orderByComparator)
1230 throws NoSuchCategoryException {
1231 AssetCategory assetCategory = findByPrimaryKey(categoryId);
1232
1233 Session session = null;
1234
1235 try {
1236 session = openSession();
1237
1238 AssetCategory[] array = new AssetCategoryImpl[3];
1239
1240 array[0] = getByUuid_C_PrevAndNext(session, assetCategory, uuid,
1241 companyId, orderByComparator, true);
1242
1243 array[1] = assetCategory;
1244
1245 array[2] = getByUuid_C_PrevAndNext(session, assetCategory, uuid,
1246 companyId, orderByComparator, false);
1247
1248 return array;
1249 }
1250 catch (Exception e) {
1251 throw processException(e);
1252 }
1253 finally {
1254 closeSession(session);
1255 }
1256 }
1257
1258 protected AssetCategory getByUuid_C_PrevAndNext(Session session,
1259 AssetCategory assetCategory, String uuid, long companyId,
1260 OrderByComparator<AssetCategory> orderByComparator, boolean previous) {
1261 StringBundler query = null;
1262
1263 if (orderByComparator != null) {
1264 query = new StringBundler(6 +
1265 (orderByComparator.getOrderByFields().length * 6));
1266 }
1267 else {
1268 query = new StringBundler(3);
1269 }
1270
1271 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
1272
1273 boolean bindUuid = false;
1274
1275 if (uuid == null) {
1276 query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1277 }
1278 else if (uuid.equals(StringPool.BLANK)) {
1279 query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1280 }
1281 else {
1282 bindUuid = true;
1283
1284 query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1285 }
1286
1287 query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1288
1289 if (orderByComparator != null) {
1290 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1291
1292 if (orderByConditionFields.length > 0) {
1293 query.append(WHERE_AND);
1294 }
1295
1296 for (int i = 0; i < orderByConditionFields.length; i++) {
1297 query.append(_ORDER_BY_ENTITY_ALIAS);
1298 query.append(orderByConditionFields[i]);
1299
1300 if ((i + 1) < orderByConditionFields.length) {
1301 if (orderByComparator.isAscending() ^ previous) {
1302 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1303 }
1304 else {
1305 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1306 }
1307 }
1308 else {
1309 if (orderByComparator.isAscending() ^ previous) {
1310 query.append(WHERE_GREATER_THAN);
1311 }
1312 else {
1313 query.append(WHERE_LESSER_THAN);
1314 }
1315 }
1316 }
1317
1318 query.append(ORDER_BY_CLAUSE);
1319
1320 String[] orderByFields = orderByComparator.getOrderByFields();
1321
1322 for (int i = 0; i < orderByFields.length; i++) {
1323 query.append(_ORDER_BY_ENTITY_ALIAS);
1324 query.append(orderByFields[i]);
1325
1326 if ((i + 1) < orderByFields.length) {
1327 if (orderByComparator.isAscending() ^ previous) {
1328 query.append(ORDER_BY_ASC_HAS_NEXT);
1329 }
1330 else {
1331 query.append(ORDER_BY_DESC_HAS_NEXT);
1332 }
1333 }
1334 else {
1335 if (orderByComparator.isAscending() ^ previous) {
1336 query.append(ORDER_BY_ASC);
1337 }
1338 else {
1339 query.append(ORDER_BY_DESC);
1340 }
1341 }
1342 }
1343 }
1344 else {
1345 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
1346 }
1347
1348 String sql = query.toString();
1349
1350 Query q = session.createQuery(sql);
1351
1352 q.setFirstResult(0);
1353 q.setMaxResults(2);
1354
1355 QueryPos qPos = QueryPos.getInstance(q);
1356
1357 if (bindUuid) {
1358 qPos.add(uuid);
1359 }
1360
1361 qPos.add(companyId);
1362
1363 if (orderByComparator != null) {
1364 Object[] values = orderByComparator.getOrderByConditionValues(assetCategory);
1365
1366 for (Object value : values) {
1367 qPos.add(value);
1368 }
1369 }
1370
1371 List<AssetCategory> list = q.list();
1372
1373 if (list.size() == 2) {
1374 return list.get(1);
1375 }
1376 else {
1377 return null;
1378 }
1379 }
1380
1381
1387 @Override
1388 public void removeByUuid_C(String uuid, long companyId) {
1389 for (AssetCategory assetCategory : findByUuid_C(uuid, companyId,
1390 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
1391 remove(assetCategory);
1392 }
1393 }
1394
1395
1402 @Override
1403 public int countByUuid_C(String uuid, long companyId) {
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
1498 @Override
1499 public List<AssetCategory> findByGroupId(long groupId) {
1500 return findByGroupId(groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1501 }
1502
1503
1515 @Override
1516 public List<AssetCategory> findByGroupId(long groupId, int start, int end) {
1517 return findByGroupId(groupId, start, end, null);
1518 }
1519
1520
1533 @Override
1534 public List<AssetCategory> findByGroupId(long groupId, int start, int end,
1535 OrderByComparator<AssetCategory> orderByComparator) {
1536 boolean pagination = true;
1537 FinderPath finderPath = null;
1538 Object[] finderArgs = null;
1539
1540 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1541 (orderByComparator == null)) {
1542 pagination = false;
1543 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID;
1544 finderArgs = new Object[] { groupId };
1545 }
1546 else {
1547 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID;
1548 finderArgs = new Object[] { groupId, start, end, orderByComparator };
1549 }
1550
1551 List<AssetCategory> list = (List<AssetCategory>)FinderCacheUtil.getResult(finderPath,
1552 finderArgs, this);
1553
1554 if ((list != null) && !list.isEmpty()) {
1555 for (AssetCategory assetCategory : list) {
1556 if ((groupId != assetCategory.getGroupId())) {
1557 list = null;
1558
1559 break;
1560 }
1561 }
1562 }
1563
1564 if (list == null) {
1565 StringBundler query = null;
1566
1567 if (orderByComparator != null) {
1568 query = new StringBundler(3 +
1569 (orderByComparator.getOrderByFields().length * 3));
1570 }
1571 else {
1572 query = new StringBundler(3);
1573 }
1574
1575 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
1576
1577 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1578
1579 if (orderByComparator != null) {
1580 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1581 orderByComparator);
1582 }
1583 else
1584 if (pagination) {
1585 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
1586 }
1587
1588 String sql = query.toString();
1589
1590 Session session = null;
1591
1592 try {
1593 session = openSession();
1594
1595 Query q = session.createQuery(sql);
1596
1597 QueryPos qPos = QueryPos.getInstance(q);
1598
1599 qPos.add(groupId);
1600
1601 if (!pagination) {
1602 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
1603 start, end, false);
1604
1605 Collections.sort(list);
1606
1607 list = Collections.unmodifiableList(list);
1608 }
1609 else {
1610 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
1611 start, end);
1612 }
1613
1614 cacheResult(list);
1615
1616 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1617 }
1618 catch (Exception e) {
1619 FinderCacheUtil.removeResult(finderPath, finderArgs);
1620
1621 throw processException(e);
1622 }
1623 finally {
1624 closeSession(session);
1625 }
1626 }
1627
1628 return list;
1629 }
1630
1631
1639 @Override
1640 public AssetCategory findByGroupId_First(long groupId,
1641 OrderByComparator<AssetCategory> orderByComparator)
1642 throws NoSuchCategoryException {
1643 AssetCategory assetCategory = fetchByGroupId_First(groupId,
1644 orderByComparator);
1645
1646 if (assetCategory != null) {
1647 return assetCategory;
1648 }
1649
1650 StringBundler msg = new StringBundler(4);
1651
1652 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1653
1654 msg.append("groupId=");
1655 msg.append(groupId);
1656
1657 msg.append(StringPool.CLOSE_CURLY_BRACE);
1658
1659 throw new NoSuchCategoryException(msg.toString());
1660 }
1661
1662
1669 @Override
1670 public AssetCategory fetchByGroupId_First(long groupId,
1671 OrderByComparator<AssetCategory> orderByComparator) {
1672 List<AssetCategory> list = findByGroupId(groupId, 0, 1,
1673 orderByComparator);
1674
1675 if (!list.isEmpty()) {
1676 return list.get(0);
1677 }
1678
1679 return null;
1680 }
1681
1682
1690 @Override
1691 public AssetCategory findByGroupId_Last(long groupId,
1692 OrderByComparator<AssetCategory> orderByComparator)
1693 throws NoSuchCategoryException {
1694 AssetCategory assetCategory = fetchByGroupId_Last(groupId,
1695 orderByComparator);
1696
1697 if (assetCategory != null) {
1698 return assetCategory;
1699 }
1700
1701 StringBundler msg = new StringBundler(4);
1702
1703 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1704
1705 msg.append("groupId=");
1706 msg.append(groupId);
1707
1708 msg.append(StringPool.CLOSE_CURLY_BRACE);
1709
1710 throw new NoSuchCategoryException(msg.toString());
1711 }
1712
1713
1720 @Override
1721 public AssetCategory fetchByGroupId_Last(long groupId,
1722 OrderByComparator<AssetCategory> orderByComparator) {
1723 int count = countByGroupId(groupId);
1724
1725 if (count == 0) {
1726 return null;
1727 }
1728
1729 List<AssetCategory> list = findByGroupId(groupId, count - 1, count,
1730 orderByComparator);
1731
1732 if (!list.isEmpty()) {
1733 return list.get(0);
1734 }
1735
1736 return null;
1737 }
1738
1739
1748 @Override
1749 public AssetCategory[] findByGroupId_PrevAndNext(long categoryId,
1750 long groupId, OrderByComparator<AssetCategory> orderByComparator)
1751 throws NoSuchCategoryException {
1752 AssetCategory assetCategory = findByPrimaryKey(categoryId);
1753
1754 Session session = null;
1755
1756 try {
1757 session = openSession();
1758
1759 AssetCategory[] array = new AssetCategoryImpl[3];
1760
1761 array[0] = getByGroupId_PrevAndNext(session, assetCategory,
1762 groupId, orderByComparator, true);
1763
1764 array[1] = assetCategory;
1765
1766 array[2] = getByGroupId_PrevAndNext(session, assetCategory,
1767 groupId, orderByComparator, false);
1768
1769 return array;
1770 }
1771 catch (Exception e) {
1772 throw processException(e);
1773 }
1774 finally {
1775 closeSession(session);
1776 }
1777 }
1778
1779 protected AssetCategory getByGroupId_PrevAndNext(Session session,
1780 AssetCategory assetCategory, long groupId,
1781 OrderByComparator<AssetCategory> orderByComparator, boolean previous) {
1782 StringBundler query = null;
1783
1784 if (orderByComparator != null) {
1785 query = new StringBundler(6 +
1786 (orderByComparator.getOrderByFields().length * 6));
1787 }
1788 else {
1789 query = new StringBundler(3);
1790 }
1791
1792 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
1793
1794 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1795
1796 if (orderByComparator != null) {
1797 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1798
1799 if (orderByConditionFields.length > 0) {
1800 query.append(WHERE_AND);
1801 }
1802
1803 for (int i = 0; i < orderByConditionFields.length; i++) {
1804 query.append(_ORDER_BY_ENTITY_ALIAS);
1805 query.append(orderByConditionFields[i]);
1806
1807 if ((i + 1) < orderByConditionFields.length) {
1808 if (orderByComparator.isAscending() ^ previous) {
1809 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1810 }
1811 else {
1812 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1813 }
1814 }
1815 else {
1816 if (orderByComparator.isAscending() ^ previous) {
1817 query.append(WHERE_GREATER_THAN);
1818 }
1819 else {
1820 query.append(WHERE_LESSER_THAN);
1821 }
1822 }
1823 }
1824
1825 query.append(ORDER_BY_CLAUSE);
1826
1827 String[] orderByFields = orderByComparator.getOrderByFields();
1828
1829 for (int i = 0; i < orderByFields.length; i++) {
1830 query.append(_ORDER_BY_ENTITY_ALIAS);
1831 query.append(orderByFields[i]);
1832
1833 if ((i + 1) < orderByFields.length) {
1834 if (orderByComparator.isAscending() ^ previous) {
1835 query.append(ORDER_BY_ASC_HAS_NEXT);
1836 }
1837 else {
1838 query.append(ORDER_BY_DESC_HAS_NEXT);
1839 }
1840 }
1841 else {
1842 if (orderByComparator.isAscending() ^ previous) {
1843 query.append(ORDER_BY_ASC);
1844 }
1845 else {
1846 query.append(ORDER_BY_DESC);
1847 }
1848 }
1849 }
1850 }
1851 else {
1852 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
1853 }
1854
1855 String sql = query.toString();
1856
1857 Query q = session.createQuery(sql);
1858
1859 q.setFirstResult(0);
1860 q.setMaxResults(2);
1861
1862 QueryPos qPos = QueryPos.getInstance(q);
1863
1864 qPos.add(groupId);
1865
1866 if (orderByComparator != null) {
1867 Object[] values = orderByComparator.getOrderByConditionValues(assetCategory);
1868
1869 for (Object value : values) {
1870 qPos.add(value);
1871 }
1872 }
1873
1874 List<AssetCategory> list = q.list();
1875
1876 if (list.size() == 2) {
1877 return list.get(1);
1878 }
1879 else {
1880 return null;
1881 }
1882 }
1883
1884
1890 @Override
1891 public List<AssetCategory> filterFindByGroupId(long groupId) {
1892 return filterFindByGroupId(groupId, QueryUtil.ALL_POS,
1893 QueryUtil.ALL_POS, null);
1894 }
1895
1896
1908 @Override
1909 public List<AssetCategory> filterFindByGroupId(long groupId, int start,
1910 int end) {
1911 return filterFindByGroupId(groupId, start, end, null);
1912 }
1913
1914
1927 @Override
1928 public List<AssetCategory> filterFindByGroupId(long groupId, int start,
1929 int end, OrderByComparator<AssetCategory> orderByComparator) {
1930 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
1931 return findByGroupId(groupId, start, end, orderByComparator);
1932 }
1933
1934 StringBundler query = null;
1935
1936 if (orderByComparator != null) {
1937 query = new StringBundler(3 +
1938 (orderByComparator.getOrderByFields().length * 3));
1939 }
1940 else {
1941 query = new StringBundler(3);
1942 }
1943
1944 if (getDB().isSupportsInlineDistinct()) {
1945 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_WHERE);
1946 }
1947 else {
1948 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_1);
1949 }
1950
1951 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1952
1953 if (!getDB().isSupportsInlineDistinct()) {
1954 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_2);
1955 }
1956
1957 if (orderByComparator != null) {
1958 if (getDB().isSupportsInlineDistinct()) {
1959 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1960 orderByComparator, true);
1961 }
1962 else {
1963 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
1964 orderByComparator, true);
1965 }
1966 }
1967 else {
1968 if (getDB().isSupportsInlineDistinct()) {
1969 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
1970 }
1971 else {
1972 query.append(AssetCategoryModelImpl.ORDER_BY_SQL);
1973 }
1974 }
1975
1976 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1977 AssetCategory.class.getName(),
1978 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
1979
1980 Session session = null;
1981
1982 try {
1983 session = openSession();
1984
1985 SQLQuery q = session.createSynchronizedSQLQuery(sql);
1986
1987 if (getDB().isSupportsInlineDistinct()) {
1988 q.addEntity(_FILTER_ENTITY_ALIAS, AssetCategoryImpl.class);
1989 }
1990 else {
1991 q.addEntity(_FILTER_ENTITY_TABLE, AssetCategoryImpl.class);
1992 }
1993
1994 QueryPos qPos = QueryPos.getInstance(q);
1995
1996 qPos.add(groupId);
1997
1998 return (List<AssetCategory>)QueryUtil.list(q, getDialect(), start,
1999 end);
2000 }
2001 catch (Exception e) {
2002 throw processException(e);
2003 }
2004 finally {
2005 closeSession(session);
2006 }
2007 }
2008
2009
2018 @Override
2019 public AssetCategory[] filterFindByGroupId_PrevAndNext(long categoryId,
2020 long groupId, OrderByComparator<AssetCategory> orderByComparator)
2021 throws NoSuchCategoryException {
2022 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2023 return findByGroupId_PrevAndNext(categoryId, groupId,
2024 orderByComparator);
2025 }
2026
2027 AssetCategory assetCategory = findByPrimaryKey(categoryId);
2028
2029 Session session = null;
2030
2031 try {
2032 session = openSession();
2033
2034 AssetCategory[] array = new AssetCategoryImpl[3];
2035
2036 array[0] = filterGetByGroupId_PrevAndNext(session, assetCategory,
2037 groupId, orderByComparator, true);
2038
2039 array[1] = assetCategory;
2040
2041 array[2] = filterGetByGroupId_PrevAndNext(session, assetCategory,
2042 groupId, orderByComparator, false);
2043
2044 return array;
2045 }
2046 catch (Exception e) {
2047 throw processException(e);
2048 }
2049 finally {
2050 closeSession(session);
2051 }
2052 }
2053
2054 protected AssetCategory filterGetByGroupId_PrevAndNext(Session session,
2055 AssetCategory assetCategory, long groupId,
2056 OrderByComparator<AssetCategory> orderByComparator, boolean previous) {
2057 StringBundler query = null;
2058
2059 if (orderByComparator != null) {
2060 query = new StringBundler(6 +
2061 (orderByComparator.getOrderByFields().length * 6));
2062 }
2063 else {
2064 query = new StringBundler(3);
2065 }
2066
2067 if (getDB().isSupportsInlineDistinct()) {
2068 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_WHERE);
2069 }
2070 else {
2071 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_1);
2072 }
2073
2074 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2075
2076 if (!getDB().isSupportsInlineDistinct()) {
2077 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_2);
2078 }
2079
2080 if (orderByComparator != null) {
2081 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2082
2083 if (orderByConditionFields.length > 0) {
2084 query.append(WHERE_AND);
2085 }
2086
2087 for (int i = 0; i < orderByConditionFields.length; i++) {
2088 if (getDB().isSupportsInlineDistinct()) {
2089 query.append(_ORDER_BY_ENTITY_ALIAS);
2090 }
2091 else {
2092 query.append(_ORDER_BY_ENTITY_TABLE);
2093 }
2094
2095 query.append(orderByConditionFields[i]);
2096
2097 if ((i + 1) < orderByConditionFields.length) {
2098 if (orderByComparator.isAscending() ^ previous) {
2099 query.append(WHERE_GREATER_THAN_HAS_NEXT);
2100 }
2101 else {
2102 query.append(WHERE_LESSER_THAN_HAS_NEXT);
2103 }
2104 }
2105 else {
2106 if (orderByComparator.isAscending() ^ previous) {
2107 query.append(WHERE_GREATER_THAN);
2108 }
2109 else {
2110 query.append(WHERE_LESSER_THAN);
2111 }
2112 }
2113 }
2114
2115 query.append(ORDER_BY_CLAUSE);
2116
2117 String[] orderByFields = orderByComparator.getOrderByFields();
2118
2119 for (int i = 0; i < orderByFields.length; i++) {
2120 if (getDB().isSupportsInlineDistinct()) {
2121 query.append(_ORDER_BY_ENTITY_ALIAS);
2122 }
2123 else {
2124 query.append(_ORDER_BY_ENTITY_TABLE);
2125 }
2126
2127 query.append(orderByFields[i]);
2128
2129 if ((i + 1) < orderByFields.length) {
2130 if (orderByComparator.isAscending() ^ previous) {
2131 query.append(ORDER_BY_ASC_HAS_NEXT);
2132 }
2133 else {
2134 query.append(ORDER_BY_DESC_HAS_NEXT);
2135 }
2136 }
2137 else {
2138 if (orderByComparator.isAscending() ^ previous) {
2139 query.append(ORDER_BY_ASC);
2140 }
2141 else {
2142 query.append(ORDER_BY_DESC);
2143 }
2144 }
2145 }
2146 }
2147 else {
2148 if (getDB().isSupportsInlineDistinct()) {
2149 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
2150 }
2151 else {
2152 query.append(AssetCategoryModelImpl.ORDER_BY_SQL);
2153 }
2154 }
2155
2156 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2157 AssetCategory.class.getName(),
2158 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2159
2160 SQLQuery q = session.createSynchronizedSQLQuery(sql);
2161
2162 q.setFirstResult(0);
2163 q.setMaxResults(2);
2164
2165 if (getDB().isSupportsInlineDistinct()) {
2166 q.addEntity(_FILTER_ENTITY_ALIAS, AssetCategoryImpl.class);
2167 }
2168 else {
2169 q.addEntity(_FILTER_ENTITY_TABLE, AssetCategoryImpl.class);
2170 }
2171
2172 QueryPos qPos = QueryPos.getInstance(q);
2173
2174 qPos.add(groupId);
2175
2176 if (orderByComparator != null) {
2177 Object[] values = orderByComparator.getOrderByConditionValues(assetCategory);
2178
2179 for (Object value : values) {
2180 qPos.add(value);
2181 }
2182 }
2183
2184 List<AssetCategory> list = q.list();
2185
2186 if (list.size() == 2) {
2187 return list.get(1);
2188 }
2189 else {
2190 return null;
2191 }
2192 }
2193
2194
2199 @Override
2200 public void removeByGroupId(long groupId) {
2201 for (AssetCategory assetCategory : findByGroupId(groupId,
2202 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
2203 remove(assetCategory);
2204 }
2205 }
2206
2207
2213 @Override
2214 public int countByGroupId(long groupId) {
2215 FinderPath finderPath = FINDER_PATH_COUNT_BY_GROUPID;
2216
2217 Object[] finderArgs = new Object[] { groupId };
2218
2219 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
2220 this);
2221
2222 if (count == null) {
2223 StringBundler query = new StringBundler(2);
2224
2225 query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
2226
2227 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2228
2229 String sql = query.toString();
2230
2231 Session session = null;
2232
2233 try {
2234 session = openSession();
2235
2236 Query q = session.createQuery(sql);
2237
2238 QueryPos qPos = QueryPos.getInstance(q);
2239
2240 qPos.add(groupId);
2241
2242 count = (Long)q.uniqueResult();
2243
2244 FinderCacheUtil.putResult(finderPath, finderArgs, count);
2245 }
2246 catch (Exception e) {
2247 FinderCacheUtil.removeResult(finderPath, finderArgs);
2248
2249 throw processException(e);
2250 }
2251 finally {
2252 closeSession(session);
2253 }
2254 }
2255
2256 return count.intValue();
2257 }
2258
2259
2265 @Override
2266 public int filterCountByGroupId(long groupId) {
2267 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2268 return countByGroupId(groupId);
2269 }
2270
2271 StringBundler query = new StringBundler(2);
2272
2273 query.append(_FILTER_SQL_COUNT_ASSETCATEGORY_WHERE);
2274
2275 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2276
2277 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2278 AssetCategory.class.getName(),
2279 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2280
2281 Session session = null;
2282
2283 try {
2284 session = openSession();
2285
2286 SQLQuery q = session.createSynchronizedSQLQuery(sql);
2287
2288 q.addScalar(COUNT_COLUMN_NAME,
2289 com.liferay.portal.kernel.dao.orm.Type.LONG);
2290
2291 QueryPos qPos = QueryPos.getInstance(q);
2292
2293 qPos.add(groupId);
2294
2295 Long count = (Long)q.uniqueResult();
2296
2297 return count.intValue();
2298 }
2299 catch (Exception e) {
2300 throw processException(e);
2301 }
2302 finally {
2303 closeSession(session);
2304 }
2305 }
2306
2307 private static final String _FINDER_COLUMN_GROUPID_GROUPID_2 = "assetCategory.groupId = ?";
2308 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_PARENTCATEGORYID =
2309 new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
2310 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
2311 AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
2312 "findByParentCategoryId",
2313 new String[] {
2314 Long.class.getName(),
2315
2316 Integer.class.getName(), Integer.class.getName(),
2317 OrderByComparator.class.getName()
2318 });
2319 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_PARENTCATEGORYID =
2320 new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
2321 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
2322 AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
2323 "findByParentCategoryId", new String[] { Long.class.getName() },
2324 AssetCategoryModelImpl.PARENTCATEGORYID_COLUMN_BITMASK |
2325 AssetCategoryModelImpl.NAME_COLUMN_BITMASK);
2326 public static final FinderPath FINDER_PATH_COUNT_BY_PARENTCATEGORYID = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
2327 AssetCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class,
2328 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
2329 "countByParentCategoryId", new String[] { Long.class.getName() });
2330
2331
2337 @Override
2338 public List<AssetCategory> findByParentCategoryId(long parentCategoryId) {
2339 return findByParentCategoryId(parentCategoryId, QueryUtil.ALL_POS,
2340 QueryUtil.ALL_POS, null);
2341 }
2342
2343
2355 @Override
2356 public List<AssetCategory> findByParentCategoryId(long parentCategoryId,
2357 int start, int end) {
2358 return findByParentCategoryId(parentCategoryId, start, end, null);
2359 }
2360
2361
2374 @Override
2375 public List<AssetCategory> findByParentCategoryId(long parentCategoryId,
2376 int start, int end, OrderByComparator<AssetCategory> orderByComparator) {
2377 boolean pagination = true;
2378 FinderPath finderPath = null;
2379 Object[] finderArgs = null;
2380
2381 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2382 (orderByComparator == null)) {
2383 pagination = false;
2384 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_PARENTCATEGORYID;
2385 finderArgs = new Object[] { parentCategoryId };
2386 }
2387 else {
2388 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_PARENTCATEGORYID;
2389 finderArgs = new Object[] {
2390 parentCategoryId,
2391
2392 start, end, orderByComparator
2393 };
2394 }
2395
2396 List<AssetCategory> list = (List<AssetCategory>)FinderCacheUtil.getResult(finderPath,
2397 finderArgs, this);
2398
2399 if ((list != null) && !list.isEmpty()) {
2400 for (AssetCategory assetCategory : list) {
2401 if ((parentCategoryId != assetCategory.getParentCategoryId())) {
2402 list = null;
2403
2404 break;
2405 }
2406 }
2407 }
2408
2409 if (list == null) {
2410 StringBundler query = null;
2411
2412 if (orderByComparator != null) {
2413 query = new StringBundler(3 +
2414 (orderByComparator.getOrderByFields().length * 3));
2415 }
2416 else {
2417 query = new StringBundler(3);
2418 }
2419
2420 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
2421
2422 query.append(_FINDER_COLUMN_PARENTCATEGORYID_PARENTCATEGORYID_2);
2423
2424 if (orderByComparator != null) {
2425 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2426 orderByComparator);
2427 }
2428 else
2429 if (pagination) {
2430 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
2431 }
2432
2433 String sql = query.toString();
2434
2435 Session session = null;
2436
2437 try {
2438 session = openSession();
2439
2440 Query q = session.createQuery(sql);
2441
2442 QueryPos qPos = QueryPos.getInstance(q);
2443
2444 qPos.add(parentCategoryId);
2445
2446 if (!pagination) {
2447 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
2448 start, end, false);
2449
2450 Collections.sort(list);
2451
2452 list = Collections.unmodifiableList(list);
2453 }
2454 else {
2455 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
2456 start, end);
2457 }
2458
2459 cacheResult(list);
2460
2461 FinderCacheUtil.putResult(finderPath, finderArgs, list);
2462 }
2463 catch (Exception e) {
2464 FinderCacheUtil.removeResult(finderPath, finderArgs);
2465
2466 throw processException(e);
2467 }
2468 finally {
2469 closeSession(session);
2470 }
2471 }
2472
2473 return list;
2474 }
2475
2476
2484 @Override
2485 public AssetCategory findByParentCategoryId_First(long parentCategoryId,
2486 OrderByComparator<AssetCategory> orderByComparator)
2487 throws NoSuchCategoryException {
2488 AssetCategory assetCategory = fetchByParentCategoryId_First(parentCategoryId,
2489 orderByComparator);
2490
2491 if (assetCategory != null) {
2492 return assetCategory;
2493 }
2494
2495 StringBundler msg = new StringBundler(4);
2496
2497 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2498
2499 msg.append("parentCategoryId=");
2500 msg.append(parentCategoryId);
2501
2502 msg.append(StringPool.CLOSE_CURLY_BRACE);
2503
2504 throw new NoSuchCategoryException(msg.toString());
2505 }
2506
2507
2514 @Override
2515 public AssetCategory fetchByParentCategoryId_First(long parentCategoryId,
2516 OrderByComparator<AssetCategory> orderByComparator) {
2517 List<AssetCategory> list = findByParentCategoryId(parentCategoryId, 0,
2518 1, orderByComparator);
2519
2520 if (!list.isEmpty()) {
2521 return list.get(0);
2522 }
2523
2524 return null;
2525 }
2526
2527
2535 @Override
2536 public AssetCategory findByParentCategoryId_Last(long parentCategoryId,
2537 OrderByComparator<AssetCategory> orderByComparator)
2538 throws NoSuchCategoryException {
2539 AssetCategory assetCategory = fetchByParentCategoryId_Last(parentCategoryId,
2540 orderByComparator);
2541
2542 if (assetCategory != null) {
2543 return assetCategory;
2544 }
2545
2546 StringBundler msg = new StringBundler(4);
2547
2548 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2549
2550 msg.append("parentCategoryId=");
2551 msg.append(parentCategoryId);
2552
2553 msg.append(StringPool.CLOSE_CURLY_BRACE);
2554
2555 throw new NoSuchCategoryException(msg.toString());
2556 }
2557
2558
2565 @Override
2566 public AssetCategory fetchByParentCategoryId_Last(long parentCategoryId,
2567 OrderByComparator<AssetCategory> orderByComparator) {
2568 int count = countByParentCategoryId(parentCategoryId);
2569
2570 if (count == 0) {
2571 return null;
2572 }
2573
2574 List<AssetCategory> list = findByParentCategoryId(parentCategoryId,
2575 count - 1, count, orderByComparator);
2576
2577 if (!list.isEmpty()) {
2578 return list.get(0);
2579 }
2580
2581 return null;
2582 }
2583
2584
2593 @Override
2594 public AssetCategory[] findByParentCategoryId_PrevAndNext(long categoryId,
2595 long parentCategoryId,
2596 OrderByComparator<AssetCategory> orderByComparator)
2597 throws NoSuchCategoryException {
2598 AssetCategory assetCategory = findByPrimaryKey(categoryId);
2599
2600 Session session = null;
2601
2602 try {
2603 session = openSession();
2604
2605 AssetCategory[] array = new AssetCategoryImpl[3];
2606
2607 array[0] = getByParentCategoryId_PrevAndNext(session,
2608 assetCategory, parentCategoryId, orderByComparator, true);
2609
2610 array[1] = assetCategory;
2611
2612 array[2] = getByParentCategoryId_PrevAndNext(session,
2613 assetCategory, parentCategoryId, orderByComparator, false);
2614
2615 return array;
2616 }
2617 catch (Exception e) {
2618 throw processException(e);
2619 }
2620 finally {
2621 closeSession(session);
2622 }
2623 }
2624
2625 protected AssetCategory getByParentCategoryId_PrevAndNext(Session session,
2626 AssetCategory assetCategory, long parentCategoryId,
2627 OrderByComparator<AssetCategory> orderByComparator, boolean previous) {
2628 StringBundler query = null;
2629
2630 if (orderByComparator != null) {
2631 query = new StringBundler(6 +
2632 (orderByComparator.getOrderByFields().length * 6));
2633 }
2634 else {
2635 query = new StringBundler(3);
2636 }
2637
2638 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
2639
2640 query.append(_FINDER_COLUMN_PARENTCATEGORYID_PARENTCATEGORYID_2);
2641
2642 if (orderByComparator != null) {
2643 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2644
2645 if (orderByConditionFields.length > 0) {
2646 query.append(WHERE_AND);
2647 }
2648
2649 for (int i = 0; i < orderByConditionFields.length; i++) {
2650 query.append(_ORDER_BY_ENTITY_ALIAS);
2651 query.append(orderByConditionFields[i]);
2652
2653 if ((i + 1) < orderByConditionFields.length) {
2654 if (orderByComparator.isAscending() ^ previous) {
2655 query.append(WHERE_GREATER_THAN_HAS_NEXT);
2656 }
2657 else {
2658 query.append(WHERE_LESSER_THAN_HAS_NEXT);
2659 }
2660 }
2661 else {
2662 if (orderByComparator.isAscending() ^ previous) {
2663 query.append(WHERE_GREATER_THAN);
2664 }
2665 else {
2666 query.append(WHERE_LESSER_THAN);
2667 }
2668 }
2669 }
2670
2671 query.append(ORDER_BY_CLAUSE);
2672
2673 String[] orderByFields = orderByComparator.getOrderByFields();
2674
2675 for (int i = 0; i < orderByFields.length; i++) {
2676 query.append(_ORDER_BY_ENTITY_ALIAS);
2677 query.append(orderByFields[i]);
2678
2679 if ((i + 1) < orderByFields.length) {
2680 if (orderByComparator.isAscending() ^ previous) {
2681 query.append(ORDER_BY_ASC_HAS_NEXT);
2682 }
2683 else {
2684 query.append(ORDER_BY_DESC_HAS_NEXT);
2685 }
2686 }
2687 else {
2688 if (orderByComparator.isAscending() ^ previous) {
2689 query.append(ORDER_BY_ASC);
2690 }
2691 else {
2692 query.append(ORDER_BY_DESC);
2693 }
2694 }
2695 }
2696 }
2697 else {
2698 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
2699 }
2700
2701 String sql = query.toString();
2702
2703 Query q = session.createQuery(sql);
2704
2705 q.setFirstResult(0);
2706 q.setMaxResults(2);
2707
2708 QueryPos qPos = QueryPos.getInstance(q);
2709
2710 qPos.add(parentCategoryId);
2711
2712 if (orderByComparator != null) {
2713 Object[] values = orderByComparator.getOrderByConditionValues(assetCategory);
2714
2715 for (Object value : values) {
2716 qPos.add(value);
2717 }
2718 }
2719
2720 List<AssetCategory> list = q.list();
2721
2722 if (list.size() == 2) {
2723 return list.get(1);
2724 }
2725 else {
2726 return null;
2727 }
2728 }
2729
2730
2735 @Override
2736 public void removeByParentCategoryId(long parentCategoryId) {
2737 for (AssetCategory assetCategory : findByParentCategoryId(
2738 parentCategoryId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
2739 remove(assetCategory);
2740 }
2741 }
2742
2743
2749 @Override
2750 public int countByParentCategoryId(long parentCategoryId) {
2751 FinderPath finderPath = FINDER_PATH_COUNT_BY_PARENTCATEGORYID;
2752
2753 Object[] finderArgs = new Object[] { parentCategoryId };
2754
2755 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
2756 this);
2757
2758 if (count == null) {
2759 StringBundler query = new StringBundler(2);
2760
2761 query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
2762
2763 query.append(_FINDER_COLUMN_PARENTCATEGORYID_PARENTCATEGORYID_2);
2764
2765 String sql = query.toString();
2766
2767 Session session = null;
2768
2769 try {
2770 session = openSession();
2771
2772 Query q = session.createQuery(sql);
2773
2774 QueryPos qPos = QueryPos.getInstance(q);
2775
2776 qPos.add(parentCategoryId);
2777
2778 count = (Long)q.uniqueResult();
2779
2780 FinderCacheUtil.putResult(finderPath, finderArgs, count);
2781 }
2782 catch (Exception e) {
2783 FinderCacheUtil.removeResult(finderPath, finderArgs);
2784
2785 throw processException(e);
2786 }
2787 finally {
2788 closeSession(session);
2789 }
2790 }
2791
2792 return count.intValue();
2793 }
2794
2795 private static final String _FINDER_COLUMN_PARENTCATEGORYID_PARENTCATEGORYID_2 =
2796 "assetCategory.parentCategoryId = ?";
2797 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_VOCABULARYID =
2798 new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
2799 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
2800 AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
2801 "findByVocabularyId",
2802 new String[] {
2803 Long.class.getName(),
2804
2805 Integer.class.getName(), Integer.class.getName(),
2806 OrderByComparator.class.getName()
2807 });
2808 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_VOCABULARYID =
2809 new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
2810 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
2811 AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
2812 "findByVocabularyId", new String[] { Long.class.getName() },
2813 AssetCategoryModelImpl.VOCABULARYID_COLUMN_BITMASK |
2814 AssetCategoryModelImpl.NAME_COLUMN_BITMASK);
2815 public static final FinderPath FINDER_PATH_COUNT_BY_VOCABULARYID = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
2816 AssetCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class,
2817 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByVocabularyId",
2818 new String[] { Long.class.getName() });
2819
2820
2826 @Override
2827 public List<AssetCategory> findByVocabularyId(long vocabularyId) {
2828 return findByVocabularyId(vocabularyId, QueryUtil.ALL_POS,
2829 QueryUtil.ALL_POS, null);
2830 }
2831
2832
2844 @Override
2845 public List<AssetCategory> findByVocabularyId(long vocabularyId, int start,
2846 int end) {
2847 return findByVocabularyId(vocabularyId, start, end, null);
2848 }
2849
2850
2863 @Override
2864 public List<AssetCategory> findByVocabularyId(long vocabularyId, int start,
2865 int end, OrderByComparator<AssetCategory> orderByComparator) {
2866 boolean pagination = true;
2867 FinderPath finderPath = null;
2868 Object[] finderArgs = null;
2869
2870 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2871 (orderByComparator == null)) {
2872 pagination = false;
2873 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_VOCABULARYID;
2874 finderArgs = new Object[] { vocabularyId };
2875 }
2876 else {
2877 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_VOCABULARYID;
2878 finderArgs = new Object[] {
2879 vocabularyId,
2880
2881 start, end, orderByComparator
2882 };
2883 }
2884
2885 List<AssetCategory> list = (List<AssetCategory>)FinderCacheUtil.getResult(finderPath,
2886 finderArgs, this);
2887
2888 if ((list != null) && !list.isEmpty()) {
2889 for (AssetCategory assetCategory : list) {
2890 if ((vocabularyId != assetCategory.getVocabularyId())) {
2891 list = null;
2892
2893 break;
2894 }
2895 }
2896 }
2897
2898 if (list == null) {
2899 StringBundler query = null;
2900
2901 if (orderByComparator != null) {
2902 query = new StringBundler(3 +
2903 (orderByComparator.getOrderByFields().length * 3));
2904 }
2905 else {
2906 query = new StringBundler(3);
2907 }
2908
2909 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
2910
2911 query.append(_FINDER_COLUMN_VOCABULARYID_VOCABULARYID_2);
2912
2913 if (orderByComparator != null) {
2914 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2915 orderByComparator);
2916 }
2917 else
2918 if (pagination) {
2919 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
2920 }
2921
2922 String sql = query.toString();
2923
2924 Session session = null;
2925
2926 try {
2927 session = openSession();
2928
2929 Query q = session.createQuery(sql);
2930
2931 QueryPos qPos = QueryPos.getInstance(q);
2932
2933 qPos.add(vocabularyId);
2934
2935 if (!pagination) {
2936 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
2937 start, end, false);
2938
2939 Collections.sort(list);
2940
2941 list = Collections.unmodifiableList(list);
2942 }
2943 else {
2944 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
2945 start, end);
2946 }
2947
2948 cacheResult(list);
2949
2950 FinderCacheUtil.putResult(finderPath, finderArgs, list);
2951 }
2952 catch (Exception e) {
2953 FinderCacheUtil.removeResult(finderPath, finderArgs);
2954
2955 throw processException(e);
2956 }
2957 finally {
2958 closeSession(session);
2959 }
2960 }
2961
2962 return list;
2963 }
2964
2965
2973 @Override
2974 public AssetCategory findByVocabularyId_First(long vocabularyId,
2975 OrderByComparator<AssetCategory> orderByComparator)
2976 throws NoSuchCategoryException {
2977 AssetCategory assetCategory = fetchByVocabularyId_First(vocabularyId,
2978 orderByComparator);
2979
2980 if (assetCategory != null) {
2981 return assetCategory;
2982 }
2983
2984 StringBundler msg = new StringBundler(4);
2985
2986 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2987
2988 msg.append("vocabularyId=");
2989 msg.append(vocabularyId);
2990
2991 msg.append(StringPool.CLOSE_CURLY_BRACE);
2992
2993 throw new NoSuchCategoryException(msg.toString());
2994 }
2995
2996
3003 @Override
3004 public AssetCategory fetchByVocabularyId_First(long vocabularyId,
3005 OrderByComparator<AssetCategory> orderByComparator) {
3006 List<AssetCategory> list = findByVocabularyId(vocabularyId, 0, 1,
3007 orderByComparator);
3008
3009 if (!list.isEmpty()) {
3010 return list.get(0);
3011 }
3012
3013 return null;
3014 }
3015
3016
3024 @Override
3025 public AssetCategory findByVocabularyId_Last(long vocabularyId,
3026 OrderByComparator<AssetCategory> orderByComparator)
3027 throws NoSuchCategoryException {
3028 AssetCategory assetCategory = fetchByVocabularyId_Last(vocabularyId,
3029 orderByComparator);
3030
3031 if (assetCategory != null) {
3032 return assetCategory;
3033 }
3034
3035 StringBundler msg = new StringBundler(4);
3036
3037 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3038
3039 msg.append("vocabularyId=");
3040 msg.append(vocabularyId);
3041
3042 msg.append(StringPool.CLOSE_CURLY_BRACE);
3043
3044 throw new NoSuchCategoryException(msg.toString());
3045 }
3046
3047
3054 @Override
3055 public AssetCategory fetchByVocabularyId_Last(long vocabularyId,
3056 OrderByComparator<AssetCategory> orderByComparator) {
3057 int count = countByVocabularyId(vocabularyId);
3058
3059 if (count == 0) {
3060 return null;
3061 }
3062
3063 List<AssetCategory> list = findByVocabularyId(vocabularyId, count - 1,
3064 count, orderByComparator);
3065
3066 if (!list.isEmpty()) {
3067 return list.get(0);
3068 }
3069
3070 return null;
3071 }
3072
3073
3082 @Override
3083 public AssetCategory[] findByVocabularyId_PrevAndNext(long categoryId,
3084 long vocabularyId, OrderByComparator<AssetCategory> orderByComparator)
3085 throws NoSuchCategoryException {
3086 AssetCategory assetCategory = findByPrimaryKey(categoryId);
3087
3088 Session session = null;
3089
3090 try {
3091 session = openSession();
3092
3093 AssetCategory[] array = new AssetCategoryImpl[3];
3094
3095 array[0] = getByVocabularyId_PrevAndNext(session, assetCategory,
3096 vocabularyId, orderByComparator, true);
3097
3098 array[1] = assetCategory;
3099
3100 array[2] = getByVocabularyId_PrevAndNext(session, assetCategory,
3101 vocabularyId, orderByComparator, false);
3102
3103 return array;
3104 }
3105 catch (Exception e) {
3106 throw processException(e);
3107 }
3108 finally {
3109 closeSession(session);
3110 }
3111 }
3112
3113 protected AssetCategory getByVocabularyId_PrevAndNext(Session session,
3114 AssetCategory assetCategory, long vocabularyId,
3115 OrderByComparator<AssetCategory> orderByComparator, boolean previous) {
3116 StringBundler query = null;
3117
3118 if (orderByComparator != null) {
3119 query = new StringBundler(6 +
3120 (orderByComparator.getOrderByFields().length * 6));
3121 }
3122 else {
3123 query = new StringBundler(3);
3124 }
3125
3126 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
3127
3128 query.append(_FINDER_COLUMN_VOCABULARYID_VOCABULARYID_2);
3129
3130 if (orderByComparator != null) {
3131 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3132
3133 if (orderByConditionFields.length > 0) {
3134 query.append(WHERE_AND);
3135 }
3136
3137 for (int i = 0; i < orderByConditionFields.length; i++) {
3138 query.append(_ORDER_BY_ENTITY_ALIAS);
3139 query.append(orderByConditionFields[i]);
3140
3141 if ((i + 1) < orderByConditionFields.length) {
3142 if (orderByComparator.isAscending() ^ previous) {
3143 query.append(WHERE_GREATER_THAN_HAS_NEXT);
3144 }
3145 else {
3146 query.append(WHERE_LESSER_THAN_HAS_NEXT);
3147 }
3148 }
3149 else {
3150 if (orderByComparator.isAscending() ^ previous) {
3151 query.append(WHERE_GREATER_THAN);
3152 }
3153 else {
3154 query.append(WHERE_LESSER_THAN);
3155 }
3156 }
3157 }
3158
3159 query.append(ORDER_BY_CLAUSE);
3160
3161 String[] orderByFields = orderByComparator.getOrderByFields();
3162
3163 for (int i = 0; i < orderByFields.length; i++) {
3164 query.append(_ORDER_BY_ENTITY_ALIAS);
3165 query.append(orderByFields[i]);
3166
3167 if ((i + 1) < orderByFields.length) {
3168 if (orderByComparator.isAscending() ^ previous) {
3169 query.append(ORDER_BY_ASC_HAS_NEXT);
3170 }
3171 else {
3172 query.append(ORDER_BY_DESC_HAS_NEXT);
3173 }
3174 }
3175 else {
3176 if (orderByComparator.isAscending() ^ previous) {
3177 query.append(ORDER_BY_ASC);
3178 }
3179 else {
3180 query.append(ORDER_BY_DESC);
3181 }
3182 }
3183 }
3184 }
3185 else {
3186 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
3187 }
3188
3189 String sql = query.toString();
3190
3191 Query q = session.createQuery(sql);
3192
3193 q.setFirstResult(0);
3194 q.setMaxResults(2);
3195
3196 QueryPos qPos = QueryPos.getInstance(q);
3197
3198 qPos.add(vocabularyId);
3199
3200 if (orderByComparator != null) {
3201 Object[] values = orderByComparator.getOrderByConditionValues(assetCategory);
3202
3203 for (Object value : values) {
3204 qPos.add(value);
3205 }
3206 }
3207
3208 List<AssetCategory> list = q.list();
3209
3210 if (list.size() == 2) {
3211 return list.get(1);
3212 }
3213 else {
3214 return null;
3215 }
3216 }
3217
3218
3223 @Override
3224 public void removeByVocabularyId(long vocabularyId) {
3225 for (AssetCategory assetCategory : findByVocabularyId(vocabularyId,
3226 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
3227 remove(assetCategory);
3228 }
3229 }
3230
3231
3237 @Override
3238 public int countByVocabularyId(long vocabularyId) {
3239 FinderPath finderPath = FINDER_PATH_COUNT_BY_VOCABULARYID;
3240
3241 Object[] finderArgs = new Object[] { vocabularyId };
3242
3243 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
3244 this);
3245
3246 if (count == null) {
3247 StringBundler query = new StringBundler(2);
3248
3249 query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
3250
3251 query.append(_FINDER_COLUMN_VOCABULARYID_VOCABULARYID_2);
3252
3253 String sql = query.toString();
3254
3255 Session session = null;
3256
3257 try {
3258 session = openSession();
3259
3260 Query q = session.createQuery(sql);
3261
3262 QueryPos qPos = QueryPos.getInstance(q);
3263
3264 qPos.add(vocabularyId);
3265
3266 count = (Long)q.uniqueResult();
3267
3268 FinderCacheUtil.putResult(finderPath, finderArgs, count);
3269 }
3270 catch (Exception e) {
3271 FinderCacheUtil.removeResult(finderPath, finderArgs);
3272
3273 throw processException(e);
3274 }
3275 finally {
3276 closeSession(session);
3277 }
3278 }
3279
3280 return count.intValue();
3281 }
3282
3283 private static final String _FINDER_COLUMN_VOCABULARYID_VOCABULARYID_2 = "assetCategory.vocabularyId = ?";
3284 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
3285 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
3286 AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
3287 "findByG_V",
3288 new String[] {
3289 Long.class.getName(), Long.class.getName(),
3290
3291 Integer.class.getName(), Integer.class.getName(),
3292 OrderByComparator.class.getName()
3293 });
3294 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
3295 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
3296 AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
3297 "findByG_V",
3298 new String[] { Long.class.getName(), Long.class.getName() },
3299 AssetCategoryModelImpl.GROUPID_COLUMN_BITMASK |
3300 AssetCategoryModelImpl.VOCABULARYID_COLUMN_BITMASK |
3301 AssetCategoryModelImpl.NAME_COLUMN_BITMASK);
3302 public static final FinderPath FINDER_PATH_COUNT_BY_G_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
3303 AssetCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class,
3304 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_V",
3305 new String[] { Long.class.getName(), Long.class.getName() });
3306 public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
3307 AssetCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class,
3308 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_V",
3309 new String[] { Long.class.getName(), Long.class.getName() });
3310
3311
3318 @Override
3319 public List<AssetCategory> findByG_V(long groupId, long vocabularyId) {
3320 return findByG_V(groupId, vocabularyId, QueryUtil.ALL_POS,
3321 QueryUtil.ALL_POS, null);
3322 }
3323
3324
3337 @Override
3338 public List<AssetCategory> findByG_V(long groupId, long vocabularyId,
3339 int start, int end) {
3340 return findByG_V(groupId, vocabularyId, start, end, null);
3341 }
3342
3343
3357 @Override
3358 public List<AssetCategory> findByG_V(long groupId, long vocabularyId,
3359 int start, int end, OrderByComparator<AssetCategory> orderByComparator) {
3360 boolean pagination = true;
3361 FinderPath finderPath = null;
3362 Object[] finderArgs = null;
3363
3364 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
3365 (orderByComparator == null)) {
3366 pagination = false;
3367 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_V;
3368 finderArgs = new Object[] { groupId, vocabularyId };
3369 }
3370 else {
3371 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_V;
3372 finderArgs = new Object[] {
3373 groupId, vocabularyId,
3374
3375 start, end, orderByComparator
3376 };
3377 }
3378
3379 List<AssetCategory> list = (List<AssetCategory>)FinderCacheUtil.getResult(finderPath,
3380 finderArgs, this);
3381
3382 if ((list != null) && !list.isEmpty()) {
3383 for (AssetCategory assetCategory : list) {
3384 if ((groupId != assetCategory.getGroupId()) ||
3385 (vocabularyId != assetCategory.getVocabularyId())) {
3386 list = null;
3387
3388 break;
3389 }
3390 }
3391 }
3392
3393 if (list == null) {
3394 StringBundler query = null;
3395
3396 if (orderByComparator != null) {
3397 query = new StringBundler(4 +
3398 (orderByComparator.getOrderByFields().length * 3));
3399 }
3400 else {
3401 query = new StringBundler(4);
3402 }
3403
3404 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
3405
3406 query.append(_FINDER_COLUMN_G_V_GROUPID_2);
3407
3408 query.append(_FINDER_COLUMN_G_V_VOCABULARYID_2);
3409
3410 if (orderByComparator != null) {
3411 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3412 orderByComparator);
3413 }
3414 else
3415 if (pagination) {
3416 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
3417 }
3418
3419 String sql = query.toString();
3420
3421 Session session = null;
3422
3423 try {
3424 session = openSession();
3425
3426 Query q = session.createQuery(sql);
3427
3428 QueryPos qPos = QueryPos.getInstance(q);
3429
3430 qPos.add(groupId);
3431
3432 qPos.add(vocabularyId);
3433
3434 if (!pagination) {
3435 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
3436 start, end, false);
3437
3438 Collections.sort(list);
3439
3440 list = Collections.unmodifiableList(list);
3441 }
3442 else {
3443 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
3444 start, end);
3445 }
3446
3447 cacheResult(list);
3448
3449 FinderCacheUtil.putResult(finderPath, finderArgs, list);
3450 }
3451 catch (Exception e) {
3452 FinderCacheUtil.removeResult(finderPath, finderArgs);
3453
3454 throw processException(e);
3455 }
3456 finally {
3457 closeSession(session);
3458 }
3459 }
3460
3461 return list;
3462 }
3463
3464
3473 @Override
3474 public AssetCategory findByG_V_First(long groupId, long vocabularyId,
3475 OrderByComparator<AssetCategory> orderByComparator)
3476 throws NoSuchCategoryException {
3477 AssetCategory assetCategory = fetchByG_V_First(groupId, vocabularyId,
3478 orderByComparator);
3479
3480 if (assetCategory != null) {
3481 return assetCategory;
3482 }
3483
3484 StringBundler msg = new StringBundler(6);
3485
3486 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3487
3488 msg.append("groupId=");
3489 msg.append(groupId);
3490
3491 msg.append(", vocabularyId=");
3492 msg.append(vocabularyId);
3493
3494 msg.append(StringPool.CLOSE_CURLY_BRACE);
3495
3496 throw new NoSuchCategoryException(msg.toString());
3497 }
3498
3499
3507 @Override
3508 public AssetCategory fetchByG_V_First(long groupId, long vocabularyId,
3509 OrderByComparator<AssetCategory> orderByComparator) {
3510 List<AssetCategory> list = findByG_V(groupId, vocabularyId, 0, 1,
3511 orderByComparator);
3512
3513 if (!list.isEmpty()) {
3514 return list.get(0);
3515 }
3516
3517 return null;
3518 }
3519
3520
3529 @Override
3530 public AssetCategory findByG_V_Last(long groupId, long vocabularyId,
3531 OrderByComparator<AssetCategory> orderByComparator)
3532 throws NoSuchCategoryException {
3533 AssetCategory assetCategory = fetchByG_V_Last(groupId, vocabularyId,
3534 orderByComparator);
3535
3536 if (assetCategory != null) {
3537 return assetCategory;
3538 }
3539
3540 StringBundler msg = new StringBundler(6);
3541
3542 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3543
3544 msg.append("groupId=");
3545 msg.append(groupId);
3546
3547 msg.append(", vocabularyId=");
3548 msg.append(vocabularyId);
3549
3550 msg.append(StringPool.CLOSE_CURLY_BRACE);
3551
3552 throw new NoSuchCategoryException(msg.toString());
3553 }
3554
3555
3563 @Override
3564 public AssetCategory fetchByG_V_Last(long groupId, long vocabularyId,
3565 OrderByComparator<AssetCategory> orderByComparator) {
3566 int count = countByG_V(groupId, vocabularyId);
3567
3568 if (count == 0) {
3569 return null;
3570 }
3571
3572 List<AssetCategory> list = findByG_V(groupId, vocabularyId, count - 1,
3573 count, orderByComparator);
3574
3575 if (!list.isEmpty()) {
3576 return list.get(0);
3577 }
3578
3579 return null;
3580 }
3581
3582
3592 @Override
3593 public AssetCategory[] findByG_V_PrevAndNext(long categoryId, long groupId,
3594 long vocabularyId, OrderByComparator<AssetCategory> orderByComparator)
3595 throws NoSuchCategoryException {
3596 AssetCategory assetCategory = findByPrimaryKey(categoryId);
3597
3598 Session session = null;
3599
3600 try {
3601 session = openSession();
3602
3603 AssetCategory[] array = new AssetCategoryImpl[3];
3604
3605 array[0] = getByG_V_PrevAndNext(session, assetCategory, groupId,
3606 vocabularyId, orderByComparator, true);
3607
3608 array[1] = assetCategory;
3609
3610 array[2] = getByG_V_PrevAndNext(session, assetCategory, groupId,
3611 vocabularyId, orderByComparator, false);
3612
3613 return array;
3614 }
3615 catch (Exception e) {
3616 throw processException(e);
3617 }
3618 finally {
3619 closeSession(session);
3620 }
3621 }
3622
3623 protected AssetCategory getByG_V_PrevAndNext(Session session,
3624 AssetCategory assetCategory, long groupId, long vocabularyId,
3625 OrderByComparator<AssetCategory> orderByComparator, boolean previous) {
3626 StringBundler query = null;
3627
3628 if (orderByComparator != null) {
3629 query = new StringBundler(6 +
3630 (orderByComparator.getOrderByFields().length * 6));
3631 }
3632 else {
3633 query = new StringBundler(3);
3634 }
3635
3636 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
3637
3638 query.append(_FINDER_COLUMN_G_V_GROUPID_2);
3639
3640 query.append(_FINDER_COLUMN_G_V_VOCABULARYID_2);
3641
3642 if (orderByComparator != null) {
3643 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3644
3645 if (orderByConditionFields.length > 0) {
3646 query.append(WHERE_AND);
3647 }
3648
3649 for (int i = 0; i < orderByConditionFields.length; i++) {
3650 query.append(_ORDER_BY_ENTITY_ALIAS);
3651 query.append(orderByConditionFields[i]);
3652
3653 if ((i + 1) < orderByConditionFields.length) {
3654 if (orderByComparator.isAscending() ^ previous) {
3655 query.append(WHERE_GREATER_THAN_HAS_NEXT);
3656 }
3657 else {
3658 query.append(WHERE_LESSER_THAN_HAS_NEXT);
3659 }
3660 }
3661 else {
3662 if (orderByComparator.isAscending() ^ previous) {
3663 query.append(WHERE_GREATER_THAN);
3664 }
3665 else {
3666 query.append(WHERE_LESSER_THAN);
3667 }
3668 }
3669 }
3670
3671 query.append(ORDER_BY_CLAUSE);
3672
3673 String[] orderByFields = orderByComparator.getOrderByFields();
3674
3675 for (int i = 0; i < orderByFields.length; i++) {
3676 query.append(_ORDER_BY_ENTITY_ALIAS);
3677 query.append(orderByFields[i]);
3678
3679 if ((i + 1) < orderByFields.length) {
3680 if (orderByComparator.isAscending() ^ previous) {
3681 query.append(ORDER_BY_ASC_HAS_NEXT);
3682 }
3683 else {
3684 query.append(ORDER_BY_DESC_HAS_NEXT);
3685 }
3686 }
3687 else {
3688 if (orderByComparator.isAscending() ^ previous) {
3689 query.append(ORDER_BY_ASC);
3690 }
3691 else {
3692 query.append(ORDER_BY_DESC);
3693 }
3694 }
3695 }
3696 }
3697 else {
3698 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
3699 }
3700
3701 String sql = query.toString();
3702
3703 Query q = session.createQuery(sql);
3704
3705 q.setFirstResult(0);
3706 q.setMaxResults(2);
3707
3708 QueryPos qPos = QueryPos.getInstance(q);
3709
3710 qPos.add(groupId);
3711
3712 qPos.add(vocabularyId);
3713
3714 if (orderByComparator != null) {
3715 Object[] values = orderByComparator.getOrderByConditionValues(assetCategory);
3716
3717 for (Object value : values) {
3718 qPos.add(value);
3719 }
3720 }
3721
3722 List<AssetCategory> list = q.list();
3723
3724 if (list.size() == 2) {
3725 return list.get(1);
3726 }
3727 else {
3728 return null;
3729 }
3730 }
3731
3732
3739 @Override
3740 public List<AssetCategory> filterFindByG_V(long groupId, long vocabularyId) {
3741 return filterFindByG_V(groupId, vocabularyId, QueryUtil.ALL_POS,
3742 QueryUtil.ALL_POS, null);
3743 }
3744
3745
3758 @Override
3759 public List<AssetCategory> filterFindByG_V(long groupId, long vocabularyId,
3760 int start, int end) {
3761 return filterFindByG_V(groupId, vocabularyId, start, end, null);
3762 }
3763
3764
3778 @Override
3779 public List<AssetCategory> filterFindByG_V(long groupId, long vocabularyId,
3780 int start, int end, OrderByComparator<AssetCategory> orderByComparator) {
3781 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
3782 return findByG_V(groupId, vocabularyId, start, end,
3783 orderByComparator);
3784 }
3785
3786 StringBundler query = null;
3787
3788 if (orderByComparator != null) {
3789 query = new StringBundler(4 +
3790 (orderByComparator.getOrderByFields().length * 3));
3791 }
3792 else {
3793 query = new StringBundler(4);
3794 }
3795
3796 if (getDB().isSupportsInlineDistinct()) {
3797 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_WHERE);
3798 }
3799 else {
3800 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_1);
3801 }
3802
3803 query.append(_FINDER_COLUMN_G_V_GROUPID_2);
3804
3805 query.append(_FINDER_COLUMN_G_V_VOCABULARYID_2);
3806
3807 if (!getDB().isSupportsInlineDistinct()) {
3808 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_2);
3809 }
3810
3811 if (orderByComparator != null) {
3812 if (getDB().isSupportsInlineDistinct()) {
3813 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3814 orderByComparator, true);
3815 }
3816 else {
3817 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
3818 orderByComparator, true);
3819 }
3820 }
3821 else {
3822 if (getDB().isSupportsInlineDistinct()) {
3823 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
3824 }
3825 else {
3826 query.append(AssetCategoryModelImpl.ORDER_BY_SQL);
3827 }
3828 }
3829
3830 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
3831 AssetCategory.class.getName(),
3832 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
3833
3834 Session session = null;
3835
3836 try {
3837 session = openSession();
3838
3839 SQLQuery q = session.createSynchronizedSQLQuery(sql);
3840
3841 if (getDB().isSupportsInlineDistinct()) {
3842 q.addEntity(_FILTER_ENTITY_ALIAS, AssetCategoryImpl.class);
3843 }
3844 else {
3845 q.addEntity(_FILTER_ENTITY_TABLE, AssetCategoryImpl.class);
3846 }
3847
3848 QueryPos qPos = QueryPos.getInstance(q);
3849
3850 qPos.add(groupId);
3851
3852 qPos.add(vocabularyId);
3853
3854 return (List<AssetCategory>)QueryUtil.list(q, getDialect(), start,
3855 end);
3856 }
3857 catch (Exception e) {
3858 throw processException(e);
3859 }
3860 finally {
3861 closeSession(session);
3862 }
3863 }
3864
3865
3875 @Override
3876 public AssetCategory[] filterFindByG_V_PrevAndNext(long categoryId,
3877 long groupId, long vocabularyId,
3878 OrderByComparator<AssetCategory> orderByComparator)
3879 throws NoSuchCategoryException {
3880 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
3881 return findByG_V_PrevAndNext(categoryId, groupId, vocabularyId,
3882 orderByComparator);
3883 }
3884
3885 AssetCategory assetCategory = findByPrimaryKey(categoryId);
3886
3887 Session session = null;
3888
3889 try {
3890 session = openSession();
3891
3892 AssetCategory[] array = new AssetCategoryImpl[3];
3893
3894 array[0] = filterGetByG_V_PrevAndNext(session, assetCategory,
3895 groupId, vocabularyId, orderByComparator, true);
3896
3897 array[1] = assetCategory;
3898
3899 array[2] = filterGetByG_V_PrevAndNext(session, assetCategory,
3900 groupId, vocabularyId, orderByComparator, false);
3901
3902 return array;
3903 }
3904 catch (Exception e) {
3905 throw processException(e);
3906 }
3907 finally {
3908 closeSession(session);
3909 }
3910 }
3911
3912 protected AssetCategory filterGetByG_V_PrevAndNext(Session session,
3913 AssetCategory assetCategory, long groupId, long vocabularyId,
3914 OrderByComparator<AssetCategory> orderByComparator, boolean previous) {
3915 StringBundler query = null;
3916
3917 if (orderByComparator != null) {
3918 query = new StringBundler(6 +
3919 (orderByComparator.getOrderByFields().length * 6));
3920 }
3921 else {
3922 query = new StringBundler(3);
3923 }
3924
3925 if (getDB().isSupportsInlineDistinct()) {
3926 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_WHERE);
3927 }
3928 else {
3929 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_1);
3930 }
3931
3932 query.append(_FINDER_COLUMN_G_V_GROUPID_2);
3933
3934 query.append(_FINDER_COLUMN_G_V_VOCABULARYID_2);
3935
3936 if (!getDB().isSupportsInlineDistinct()) {
3937 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_2);
3938 }
3939
3940 if (orderByComparator != null) {
3941 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3942
3943 if (orderByConditionFields.length > 0) {
3944 query.append(WHERE_AND);
3945 }
3946
3947 for (int i = 0; i < orderByConditionFields.length; i++) {
3948 if (getDB().isSupportsInlineDistinct()) {
3949 query.append(_ORDER_BY_ENTITY_ALIAS);
3950 }
3951 else {
3952 query.append(_ORDER_BY_ENTITY_TABLE);
3953 }
3954
3955 query.append(orderByConditionFields[i]);
3956
3957 if ((i + 1) < orderByConditionFields.length) {
3958 if (orderByComparator.isAscending() ^ previous) {
3959 query.append(WHERE_GREATER_THAN_HAS_NEXT);
3960 }
3961 else {
3962 query.append(WHERE_LESSER_THAN_HAS_NEXT);
3963 }
3964 }
3965 else {
3966 if (orderByComparator.isAscending() ^ previous) {
3967 query.append(WHERE_GREATER_THAN);
3968 }
3969 else {
3970 query.append(WHERE_LESSER_THAN);
3971 }
3972 }
3973 }
3974
3975 query.append(ORDER_BY_CLAUSE);
3976
3977 String[] orderByFields = orderByComparator.getOrderByFields();
3978
3979 for (int i = 0; i < orderByFields.length; i++) {
3980 if (getDB().isSupportsInlineDistinct()) {
3981 query.append(_ORDER_BY_ENTITY_ALIAS);
3982 }
3983 else {
3984 query.append(_ORDER_BY_ENTITY_TABLE);
3985 }
3986
3987 query.append(orderByFields[i]);
3988
3989 if ((i + 1) < orderByFields.length) {
3990 if (orderByComparator.isAscending() ^ previous) {
3991 query.append(ORDER_BY_ASC_HAS_NEXT);
3992 }
3993 else {
3994 query.append(ORDER_BY_DESC_HAS_NEXT);
3995 }
3996 }
3997 else {
3998 if (orderByComparator.isAscending() ^ previous) {
3999 query.append(ORDER_BY_ASC);
4000 }
4001 else {
4002 query.append(ORDER_BY_DESC);
4003 }
4004 }
4005 }
4006 }
4007 else {
4008 if (getDB().isSupportsInlineDistinct()) {
4009 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
4010 }
4011 else {
4012 query.append(AssetCategoryModelImpl.ORDER_BY_SQL);
4013 }
4014 }
4015
4016 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
4017 AssetCategory.class.getName(),
4018 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
4019
4020 SQLQuery q = session.createSynchronizedSQLQuery(sql);
4021
4022 q.setFirstResult(0);
4023 q.setMaxResults(2);
4024
4025 if (getDB().isSupportsInlineDistinct()) {
4026 q.addEntity(_FILTER_ENTITY_ALIAS, AssetCategoryImpl.class);
4027 }
4028 else {
4029 q.addEntity(_FILTER_ENTITY_TABLE, AssetCategoryImpl.class);
4030 }
4031
4032 QueryPos qPos = QueryPos.getInstance(q);
4033
4034 qPos.add(groupId);
4035
4036 qPos.add(vocabularyId);
4037
4038 if (orderByComparator != null) {
4039 Object[] values = orderByComparator.getOrderByConditionValues(assetCategory);
4040
4041 for (Object value : values) {
4042 qPos.add(value);
4043 }
4044 }
4045
4046 List<AssetCategory> list = q.list();
4047
4048 if (list.size() == 2) {
4049 return list.get(1);
4050 }
4051 else {
4052 return null;
4053 }
4054 }
4055
4056
4063 @Override
4064 public List<AssetCategory> filterFindByG_V(long groupId,
4065 long[] vocabularyIds) {
4066 return filterFindByG_V(groupId, vocabularyIds, QueryUtil.ALL_POS,
4067 QueryUtil.ALL_POS, null);
4068 }
4069
4070
4083 @Override
4084 public List<AssetCategory> filterFindByG_V(long groupId,
4085 long[] vocabularyIds, int start, int end) {
4086 return filterFindByG_V(groupId, vocabularyIds, start, end, null);
4087 }
4088
4089
4103 @Override
4104 public List<AssetCategory> filterFindByG_V(long groupId,
4105 long[] vocabularyIds, int start, int end,
4106 OrderByComparator<AssetCategory> orderByComparator) {
4107 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
4108 return findByG_V(groupId, vocabularyIds, start, end,
4109 orderByComparator);
4110 }
4111
4112 if (vocabularyIds == null) {
4113 vocabularyIds = new long[0];
4114 }
4115 else {
4116 vocabularyIds = ArrayUtil.unique(vocabularyIds);
4117 }
4118
4119 StringBundler query = new StringBundler();
4120
4121 if (getDB().isSupportsInlineDistinct()) {
4122 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_WHERE);
4123 }
4124 else {
4125 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_1);
4126 }
4127
4128 query.append(_FINDER_COLUMN_G_V_GROUPID_2);
4129
4130 if (vocabularyIds.length > 0) {
4131 query.append(StringPool.OPEN_PARENTHESIS);
4132
4133 query.append(_FINDER_COLUMN_G_V_VOCABULARYID_7);
4134
4135 query.append(StringUtil.merge(vocabularyIds));
4136
4137 query.append(StringPool.CLOSE_PARENTHESIS);
4138
4139 query.append(StringPool.CLOSE_PARENTHESIS);
4140 }
4141
4142 query.setStringAt(removeConjunction(query.stringAt(query.index() - 1)),
4143 query.index() - 1);
4144
4145 if (!getDB().isSupportsInlineDistinct()) {
4146 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_2);
4147 }
4148
4149 if (orderByComparator != null) {
4150 if (getDB().isSupportsInlineDistinct()) {
4151 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4152 orderByComparator, true);
4153 }
4154 else {
4155 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
4156 orderByComparator, true);
4157 }
4158 }
4159 else {
4160 if (getDB().isSupportsInlineDistinct()) {
4161 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
4162 }
4163 else {
4164 query.append(AssetCategoryModelImpl.ORDER_BY_SQL);
4165 }
4166 }
4167
4168 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
4169 AssetCategory.class.getName(),
4170 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
4171
4172 Session session = null;
4173
4174 try {
4175 session = openSession();
4176
4177 SQLQuery q = session.createSynchronizedSQLQuery(sql);
4178
4179 if (getDB().isSupportsInlineDistinct()) {
4180 q.addEntity(_FILTER_ENTITY_ALIAS, AssetCategoryImpl.class);
4181 }
4182 else {
4183 q.addEntity(_FILTER_ENTITY_TABLE, AssetCategoryImpl.class);
4184 }
4185
4186 QueryPos qPos = QueryPos.getInstance(q);
4187
4188 qPos.add(groupId);
4189
4190 return (List<AssetCategory>)QueryUtil.list(q, getDialect(), start,
4191 end);
4192 }
4193 catch (Exception e) {
4194 throw processException(e);
4195 }
4196 finally {
4197 closeSession(session);
4198 }
4199 }
4200
4201
4212 @Override
4213 public List<AssetCategory> findByG_V(long groupId, long[] vocabularyIds) {
4214 return findByG_V(groupId, vocabularyIds, QueryUtil.ALL_POS,
4215 QueryUtil.ALL_POS, null);
4216 }
4217
4218
4231 @Override
4232 public List<AssetCategory> findByG_V(long groupId, long[] vocabularyIds,
4233 int start, int end) {
4234 return findByG_V(groupId, vocabularyIds, start, end, null);
4235 }
4236
4237
4251 @Override
4252 public List<AssetCategory> findByG_V(long groupId, long[] vocabularyIds,
4253 int start, int end, OrderByComparator<AssetCategory> orderByComparator) {
4254 if (vocabularyIds == null) {
4255 vocabularyIds = new long[0];
4256 }
4257 else {
4258 vocabularyIds = ArrayUtil.unique(vocabularyIds);
4259 }
4260
4261 if (vocabularyIds.length == 1) {
4262 return findByG_V(groupId, vocabularyIds[0], start, end,
4263 orderByComparator);
4264 }
4265
4266 boolean pagination = true;
4267 Object[] finderArgs = null;
4268
4269 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
4270 (orderByComparator == null)) {
4271 pagination = false;
4272 finderArgs = new Object[] { groupId, StringUtil.merge(vocabularyIds) };
4273 }
4274 else {
4275 finderArgs = new Object[] {
4276 groupId, StringUtil.merge(vocabularyIds),
4277
4278 start, end, orderByComparator
4279 };
4280 }
4281
4282 List<AssetCategory> list = (List<AssetCategory>)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_V,
4283 finderArgs, this);
4284
4285 if ((list != null) && !list.isEmpty()) {
4286 for (AssetCategory assetCategory : list) {
4287 if ((groupId != assetCategory.getGroupId()) ||
4288 !ArrayUtil.contains(vocabularyIds,
4289 assetCategory.getVocabularyId())) {
4290 list = null;
4291
4292 break;
4293 }
4294 }
4295 }
4296
4297 if (list == null) {
4298 StringBundler query = new StringBundler();
4299
4300 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
4301
4302 query.append(_FINDER_COLUMN_G_V_GROUPID_2);
4303
4304 if (vocabularyIds.length > 0) {
4305 query.append(StringPool.OPEN_PARENTHESIS);
4306
4307 query.append(_FINDER_COLUMN_G_V_VOCABULARYID_7);
4308
4309 query.append(StringUtil.merge(vocabularyIds));
4310
4311 query.append(StringPool.CLOSE_PARENTHESIS);
4312
4313 query.append(StringPool.CLOSE_PARENTHESIS);
4314 }
4315
4316 query.setStringAt(removeConjunction(query.stringAt(query.index() -
4317 1)), query.index() - 1);
4318
4319 if (orderByComparator != null) {
4320 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4321 orderByComparator);
4322 }
4323 else
4324 if (pagination) {
4325 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
4326 }
4327
4328 String sql = query.toString();
4329
4330 Session session = null;
4331
4332 try {
4333 session = openSession();
4334
4335 Query q = session.createQuery(sql);
4336
4337 QueryPos qPos = QueryPos.getInstance(q);
4338
4339 qPos.add(groupId);
4340
4341 if (!pagination) {
4342 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
4343 start, end, false);
4344
4345 Collections.sort(list);
4346
4347 list = Collections.unmodifiableList(list);
4348 }
4349 else {
4350 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
4351 start, end);
4352 }
4353
4354 cacheResult(list);
4355
4356 FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_V,
4357 finderArgs, list);
4358 }
4359 catch (Exception e) {
4360 FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_V,
4361 finderArgs);
4362
4363 throw processException(e);
4364 }
4365 finally {
4366 closeSession(session);
4367 }
4368 }
4369
4370 return list;
4371 }
4372
4373
4379 @Override
4380 public void removeByG_V(long groupId, long vocabularyId) {
4381 for (AssetCategory assetCategory : findByG_V(groupId, vocabularyId,
4382 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
4383 remove(assetCategory);
4384 }
4385 }
4386
4387
4394 @Override
4395 public int countByG_V(long groupId, long vocabularyId) {
4396 FinderPath finderPath = FINDER_PATH_COUNT_BY_G_V;
4397
4398 Object[] finderArgs = new Object[] { groupId, vocabularyId };
4399
4400 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
4401 this);
4402
4403 if (count == null) {
4404 StringBundler query = new StringBundler(3);
4405
4406 query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
4407
4408 query.append(_FINDER_COLUMN_G_V_GROUPID_2);
4409
4410 query.append(_FINDER_COLUMN_G_V_VOCABULARYID_2);
4411
4412 String sql = query.toString();
4413
4414 Session session = null;
4415
4416 try {
4417 session = openSession();
4418
4419 Query q = session.createQuery(sql);
4420
4421 QueryPos qPos = QueryPos.getInstance(q);
4422
4423 qPos.add(groupId);
4424
4425 qPos.add(vocabularyId);
4426
4427 count = (Long)q.uniqueResult();
4428
4429 FinderCacheUtil.putResult(finderPath, finderArgs, count);
4430 }
4431 catch (Exception e) {
4432 FinderCacheUtil.removeResult(finderPath, finderArgs);
4433
4434 throw processException(e);
4435 }
4436 finally {
4437 closeSession(session);
4438 }
4439 }
4440
4441 return count.intValue();
4442 }
4443
4444
4451 @Override
4452 public int countByG_V(long groupId, long[] vocabularyIds) {
4453 if (vocabularyIds == null) {
4454 vocabularyIds = new long[0];
4455 }
4456 else {
4457 vocabularyIds = ArrayUtil.unique(vocabularyIds);
4458 }
4459
4460 Object[] finderArgs = new Object[] {
4461 groupId, StringUtil.merge(vocabularyIds)
4462 };
4463
4464 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_V,
4465 finderArgs, this);
4466
4467 if (count == null) {
4468 StringBundler query = new StringBundler();
4469
4470 query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
4471
4472 query.append(_FINDER_COLUMN_G_V_GROUPID_2);
4473
4474 if (vocabularyIds.length > 0) {
4475 query.append(StringPool.OPEN_PARENTHESIS);
4476
4477 query.append(_FINDER_COLUMN_G_V_VOCABULARYID_7);
4478
4479 query.append(StringUtil.merge(vocabularyIds));
4480
4481 query.append(StringPool.CLOSE_PARENTHESIS);
4482
4483 query.append(StringPool.CLOSE_PARENTHESIS);
4484 }
4485
4486 query.setStringAt(removeConjunction(query.stringAt(query.index() -
4487 1)), query.index() - 1);
4488
4489 String sql = query.toString();
4490
4491 Session session = null;
4492
4493 try {
4494 session = openSession();
4495
4496 Query q = session.createQuery(sql);
4497
4498 QueryPos qPos = QueryPos.getInstance(q);
4499
4500 qPos.add(groupId);
4501
4502 count = (Long)q.uniqueResult();
4503
4504 FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_V,
4505 finderArgs, count);
4506 }
4507 catch (Exception e) {
4508 FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_V,
4509 finderArgs);
4510
4511 throw processException(e);
4512 }
4513 finally {
4514 closeSession(session);
4515 }
4516 }
4517
4518 return count.intValue();
4519 }
4520
4521
4528 @Override
4529 public int filterCountByG_V(long groupId, long vocabularyId) {
4530 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
4531 return countByG_V(groupId, vocabularyId);
4532 }
4533
4534 StringBundler query = new StringBundler(3);
4535
4536 query.append(_FILTER_SQL_COUNT_ASSETCATEGORY_WHERE);
4537
4538 query.append(_FINDER_COLUMN_G_V_GROUPID_2);
4539
4540 query.append(_FINDER_COLUMN_G_V_VOCABULARYID_2);
4541
4542 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
4543 AssetCategory.class.getName(),
4544 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
4545
4546 Session session = null;
4547
4548 try {
4549 session = openSession();
4550
4551 SQLQuery q = session.createSynchronizedSQLQuery(sql);
4552
4553 q.addScalar(COUNT_COLUMN_NAME,
4554 com.liferay.portal.kernel.dao.orm.Type.LONG);
4555
4556 QueryPos qPos = QueryPos.getInstance(q);
4557
4558 qPos.add(groupId);
4559
4560 qPos.add(vocabularyId);
4561
4562 Long count = (Long)q.uniqueResult();
4563
4564 return count.intValue();
4565 }
4566 catch (Exception e) {
4567 throw processException(e);
4568 }
4569 finally {
4570 closeSession(session);
4571 }
4572 }
4573
4574
4581 @Override
4582 public int filterCountByG_V(long groupId, long[] vocabularyIds) {
4583 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
4584 return countByG_V(groupId, vocabularyIds);
4585 }
4586
4587 if (vocabularyIds == null) {
4588 vocabularyIds = new long[0];
4589 }
4590 else {
4591 vocabularyIds = ArrayUtil.unique(vocabularyIds);
4592 }
4593
4594 StringBundler query = new StringBundler();
4595
4596 query.append(_FILTER_SQL_COUNT_ASSETCATEGORY_WHERE);
4597
4598 query.append(_FINDER_COLUMN_G_V_GROUPID_2);
4599
4600 if (vocabularyIds.length > 0) {
4601 query.append(StringPool.OPEN_PARENTHESIS);
4602
4603 query.append(_FINDER_COLUMN_G_V_VOCABULARYID_7);
4604
4605 query.append(StringUtil.merge(vocabularyIds));
4606
4607 query.append(StringPool.CLOSE_PARENTHESIS);
4608
4609 query.append(StringPool.CLOSE_PARENTHESIS);
4610 }
4611
4612 query.setStringAt(removeConjunction(query.stringAt(query.index() - 1)),
4613 query.index() - 1);
4614
4615 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
4616 AssetCategory.class.getName(),
4617 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
4618
4619 Session session = null;
4620
4621 try {
4622 session = openSession();
4623
4624 SQLQuery q = session.createSynchronizedSQLQuery(sql);
4625
4626 q.addScalar(COUNT_COLUMN_NAME,
4627 com.liferay.portal.kernel.dao.orm.Type.LONG);
4628
4629 QueryPos qPos = QueryPos.getInstance(q);
4630
4631 qPos.add(groupId);
4632
4633 Long count = (Long)q.uniqueResult();
4634
4635 return count.intValue();
4636 }
4637 catch (Exception e) {
4638 throw processException(e);
4639 }
4640 finally {
4641 closeSession(session);
4642 }
4643 }
4644
4645 private static final String _FINDER_COLUMN_G_V_GROUPID_2 = "assetCategory.groupId = ? AND ";
4646 private static final String _FINDER_COLUMN_G_V_VOCABULARYID_2 = "assetCategory.vocabularyId = ?";
4647 private static final String _FINDER_COLUMN_G_V_VOCABULARYID_7 = "assetCategory.vocabularyId IN (";
4648 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_P_N = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
4649 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
4650 AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
4651 "findByP_N",
4652 new String[] {
4653 Long.class.getName(), String.class.getName(),
4654
4655 Integer.class.getName(), Integer.class.getName(),
4656 OrderByComparator.class.getName()
4657 });
4658 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_P_N = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
4659 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
4660 AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
4661 "findByP_N",
4662 new String[] { Long.class.getName(), String.class.getName() },
4663 AssetCategoryModelImpl.PARENTCATEGORYID_COLUMN_BITMASK |
4664 AssetCategoryModelImpl.NAME_COLUMN_BITMASK);
4665 public static final FinderPath FINDER_PATH_COUNT_BY_P_N = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
4666 AssetCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class,
4667 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByP_N",
4668 new String[] { Long.class.getName(), String.class.getName() });
4669
4670
4677 @Override
4678 public List<AssetCategory> findByP_N(long parentCategoryId, String name) {
4679 return findByP_N(parentCategoryId, name, QueryUtil.ALL_POS,
4680 QueryUtil.ALL_POS, null);
4681 }
4682
4683
4696 @Override
4697 public List<AssetCategory> findByP_N(long parentCategoryId, String name,
4698 int start, int end) {
4699 return findByP_N(parentCategoryId, name, start, end, null);
4700 }
4701
4702
4716 @Override
4717 public List<AssetCategory> findByP_N(long parentCategoryId, String name,
4718 int start, int end, OrderByComparator<AssetCategory> orderByComparator) {
4719 boolean pagination = true;
4720 FinderPath finderPath = null;
4721 Object[] finderArgs = null;
4722
4723 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
4724 (orderByComparator == null)) {
4725 pagination = false;
4726 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_P_N;
4727 finderArgs = new Object[] { parentCategoryId, name };
4728 }
4729 else {
4730 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_P_N;
4731 finderArgs = new Object[] {
4732 parentCategoryId, name,
4733
4734 start, end, orderByComparator
4735 };
4736 }
4737
4738 List<AssetCategory> list = (List<AssetCategory>)FinderCacheUtil.getResult(finderPath,
4739 finderArgs, this);
4740
4741 if ((list != null) && !list.isEmpty()) {
4742 for (AssetCategory assetCategory : list) {
4743 if ((parentCategoryId != assetCategory.getParentCategoryId()) ||
4744 !Validator.equals(name, assetCategory.getName())) {
4745 list = null;
4746
4747 break;
4748 }
4749 }
4750 }
4751
4752 if (list == null) {
4753 StringBundler query = null;
4754
4755 if (orderByComparator != null) {
4756 query = new StringBundler(4 +
4757 (orderByComparator.getOrderByFields().length * 3));
4758 }
4759 else {
4760 query = new StringBundler(4);
4761 }
4762
4763 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
4764
4765 query.append(_FINDER_COLUMN_P_N_PARENTCATEGORYID_2);
4766
4767 boolean bindName = false;
4768
4769 if (name == null) {
4770 query.append(_FINDER_COLUMN_P_N_NAME_1);
4771 }
4772 else if (name.equals(StringPool.BLANK)) {
4773 query.append(_FINDER_COLUMN_P_N_NAME_3);
4774 }
4775 else {
4776 bindName = true;
4777
4778 query.append(_FINDER_COLUMN_P_N_NAME_2);
4779 }
4780
4781 if (orderByComparator != null) {
4782 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4783 orderByComparator);
4784 }
4785 else
4786 if (pagination) {
4787 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
4788 }
4789
4790 String sql = query.toString();
4791
4792 Session session = null;
4793
4794 try {
4795 session = openSession();
4796
4797 Query q = session.createQuery(sql);
4798
4799 QueryPos qPos = QueryPos.getInstance(q);
4800
4801 qPos.add(parentCategoryId);
4802
4803 if (bindName) {
4804 qPos.add(name);
4805 }
4806
4807 if (!pagination) {
4808 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
4809 start, end, false);
4810
4811 Collections.sort(list);
4812
4813 list = Collections.unmodifiableList(list);
4814 }
4815 else {
4816 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
4817 start, end);
4818 }
4819
4820 cacheResult(list);
4821
4822 FinderCacheUtil.putResult(finderPath, finderArgs, list);
4823 }
4824 catch (Exception e) {
4825 FinderCacheUtil.removeResult(finderPath, finderArgs);
4826
4827 throw processException(e);
4828 }
4829 finally {
4830 closeSession(session);
4831 }
4832 }
4833
4834 return list;
4835 }
4836
4837
4846 @Override
4847 public AssetCategory findByP_N_First(long parentCategoryId, String name,
4848 OrderByComparator<AssetCategory> orderByComparator)
4849 throws NoSuchCategoryException {
4850 AssetCategory assetCategory = fetchByP_N_First(parentCategoryId, name,
4851 orderByComparator);
4852
4853 if (assetCategory != null) {
4854 return assetCategory;
4855 }
4856
4857 StringBundler msg = new StringBundler(6);
4858
4859 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4860
4861 msg.append("parentCategoryId=");
4862 msg.append(parentCategoryId);
4863
4864 msg.append(", name=");
4865 msg.append(name);
4866
4867 msg.append(StringPool.CLOSE_CURLY_BRACE);
4868
4869 throw new NoSuchCategoryException(msg.toString());
4870 }
4871
4872
4880 @Override
4881 public AssetCategory fetchByP_N_First(long parentCategoryId, String name,
4882 OrderByComparator<AssetCategory> orderByComparator) {
4883 List<AssetCategory> list = findByP_N(parentCategoryId, name, 0, 1,
4884 orderByComparator);
4885
4886 if (!list.isEmpty()) {
4887 return list.get(0);
4888 }
4889
4890 return null;
4891 }
4892
4893
4902 @Override
4903 public AssetCategory findByP_N_Last(long parentCategoryId, String name,
4904 OrderByComparator<AssetCategory> orderByComparator)
4905 throws NoSuchCategoryException {
4906 AssetCategory assetCategory = fetchByP_N_Last(parentCategoryId, name,
4907 orderByComparator);
4908
4909 if (assetCategory != null) {
4910 return assetCategory;
4911 }
4912
4913 StringBundler msg = new StringBundler(6);
4914
4915 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4916
4917 msg.append("parentCategoryId=");
4918 msg.append(parentCategoryId);
4919
4920 msg.append(", name=");
4921 msg.append(name);
4922
4923 msg.append(StringPool.CLOSE_CURLY_BRACE);
4924
4925 throw new NoSuchCategoryException(msg.toString());
4926 }
4927
4928
4936 @Override
4937 public AssetCategory fetchByP_N_Last(long parentCategoryId, String name,
4938 OrderByComparator<AssetCategory> orderByComparator) {
4939 int count = countByP_N(parentCategoryId, name);
4940
4941 if (count == 0) {
4942 return null;
4943 }
4944
4945 List<AssetCategory> list = findByP_N(parentCategoryId, name, count - 1,
4946 count, orderByComparator);
4947
4948 if (!list.isEmpty()) {
4949 return list.get(0);
4950 }
4951
4952 return null;
4953 }
4954
4955
4965 @Override
4966 public AssetCategory[] findByP_N_PrevAndNext(long categoryId,
4967 long parentCategoryId, String name,
4968 OrderByComparator<AssetCategory> orderByComparator)
4969 throws NoSuchCategoryException {
4970 AssetCategory assetCategory = findByPrimaryKey(categoryId);
4971
4972 Session session = null;
4973
4974 try {
4975 session = openSession();
4976
4977 AssetCategory[] array = new AssetCategoryImpl[3];
4978
4979 array[0] = getByP_N_PrevAndNext(session, assetCategory,
4980 parentCategoryId, name, orderByComparator, true);
4981
4982 array[1] = assetCategory;
4983
4984 array[2] = getByP_N_PrevAndNext(session, assetCategory,
4985 parentCategoryId, name, orderByComparator, false);
4986
4987 return array;
4988 }
4989 catch (Exception e) {
4990 throw processException(e);
4991 }
4992 finally {
4993 closeSession(session);
4994 }
4995 }
4996
4997 protected AssetCategory getByP_N_PrevAndNext(Session session,
4998 AssetCategory assetCategory, long parentCategoryId, String name,
4999 OrderByComparator<AssetCategory> orderByComparator, boolean previous) {
5000 StringBundler query = null;
5001
5002 if (orderByComparator != null) {
5003 query = new StringBundler(6 +
5004 (orderByComparator.getOrderByFields().length * 6));
5005 }
5006 else {
5007 query = new StringBundler(3);
5008 }
5009
5010 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
5011
5012 query.append(_FINDER_COLUMN_P_N_PARENTCATEGORYID_2);
5013
5014 boolean bindName = false;
5015
5016 if (name == null) {
5017 query.append(_FINDER_COLUMN_P_N_NAME_1);
5018 }
5019 else if (name.equals(StringPool.BLANK)) {
5020 query.append(_FINDER_COLUMN_P_N_NAME_3);
5021 }
5022 else {
5023 bindName = true;
5024
5025 query.append(_FINDER_COLUMN_P_N_NAME_2);
5026 }
5027
5028 if (orderByComparator != null) {
5029 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
5030
5031 if (orderByConditionFields.length > 0) {
5032 query.append(WHERE_AND);
5033 }
5034
5035 for (int i = 0; i < orderByConditionFields.length; i++) {
5036 query.append(_ORDER_BY_ENTITY_ALIAS);
5037 query.append(orderByConditionFields[i]);
5038
5039 if ((i + 1) < orderByConditionFields.length) {
5040 if (orderByComparator.isAscending() ^ previous) {
5041 query.append(WHERE_GREATER_THAN_HAS_NEXT);
5042 }
5043 else {
5044 query.append(WHERE_LESSER_THAN_HAS_NEXT);
5045 }
5046 }
5047 else {
5048 if (orderByComparator.isAscending() ^ previous) {
5049 query.append(WHERE_GREATER_THAN);
5050 }
5051 else {
5052 query.append(WHERE_LESSER_THAN);
5053 }
5054 }
5055 }
5056
5057 query.append(ORDER_BY_CLAUSE);
5058
5059 String[] orderByFields = orderByComparator.getOrderByFields();
5060
5061 for (int i = 0; i < orderByFields.length; i++) {
5062 query.append(_ORDER_BY_ENTITY_ALIAS);
5063 query.append(orderByFields[i]);
5064
5065 if ((i + 1) < orderByFields.length) {
5066 if (orderByComparator.isAscending() ^ previous) {
5067 query.append(ORDER_BY_ASC_HAS_NEXT);
5068 }
5069 else {
5070 query.append(ORDER_BY_DESC_HAS_NEXT);
5071 }
5072 }
5073 else {
5074 if (orderByComparator.isAscending() ^ previous) {
5075 query.append(ORDER_BY_ASC);
5076 }
5077 else {
5078 query.append(ORDER_BY_DESC);
5079 }
5080 }
5081 }
5082 }
5083 else {
5084 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
5085 }
5086
5087 String sql = query.toString();
5088
5089 Query q = session.createQuery(sql);
5090
5091 q.setFirstResult(0);
5092 q.setMaxResults(2);
5093
5094 QueryPos qPos = QueryPos.getInstance(q);
5095
5096 qPos.add(parentCategoryId);
5097
5098 if (bindName) {
5099 qPos.add(name);
5100 }
5101
5102 if (orderByComparator != null) {
5103 Object[] values = orderByComparator.getOrderByConditionValues(assetCategory);
5104
5105 for (Object value : values) {
5106 qPos.add(value);
5107 }
5108 }
5109
5110 List<AssetCategory> list = q.list();
5111
5112 if (list.size() == 2) {
5113 return list.get(1);
5114 }
5115 else {
5116 return null;
5117 }
5118 }
5119
5120
5126 @Override
5127 public void removeByP_N(long parentCategoryId, String name) {
5128 for (AssetCategory assetCategory : findByP_N(parentCategoryId, name,
5129 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
5130 remove(assetCategory);
5131 }
5132 }
5133
5134
5141 @Override
5142 public int countByP_N(long parentCategoryId, String name) {
5143 FinderPath finderPath = FINDER_PATH_COUNT_BY_P_N;
5144
5145 Object[] finderArgs = new Object[] { parentCategoryId, name };
5146
5147 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
5148 this);
5149
5150 if (count == null) {
5151 StringBundler query = new StringBundler(3);
5152
5153 query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
5154
5155 query.append(_FINDER_COLUMN_P_N_PARENTCATEGORYID_2);
5156
5157 boolean bindName = false;
5158
5159 if (name == null) {
5160 query.append(_FINDER_COLUMN_P_N_NAME_1);
5161 }
5162 else if (name.equals(StringPool.BLANK)) {
5163 query.append(_FINDER_COLUMN_P_N_NAME_3);
5164 }
5165 else {
5166 bindName = true;
5167
5168 query.append(_FINDER_COLUMN_P_N_NAME_2);
5169 }
5170
5171 String sql = query.toString();
5172
5173 Session session = null;
5174
5175 try {
5176 session = openSession();
5177
5178 Query q = session.createQuery(sql);
5179
5180 QueryPos qPos = QueryPos.getInstance(q);
5181
5182 qPos.add(parentCategoryId);
5183
5184 if (bindName) {
5185 qPos.add(name);
5186 }
5187
5188 count = (Long)q.uniqueResult();
5189
5190 FinderCacheUtil.putResult(finderPath, finderArgs, count);
5191 }
5192 catch (Exception e) {
5193 FinderCacheUtil.removeResult(finderPath, finderArgs);
5194
5195 throw processException(e);
5196 }
5197 finally {
5198 closeSession(session);
5199 }
5200 }
5201
5202 return count.intValue();
5203 }
5204
5205 private static final String _FINDER_COLUMN_P_N_PARENTCATEGORYID_2 = "assetCategory.parentCategoryId = ? AND ";
5206 private static final String _FINDER_COLUMN_P_N_NAME_1 = "assetCategory.name IS NULL";
5207 private static final String _FINDER_COLUMN_P_N_NAME_2 = "assetCategory.name = ?";
5208 private static final String _FINDER_COLUMN_P_N_NAME_3 = "(assetCategory.name IS NULL OR assetCategory.name = '')";
5209 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_P_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
5210 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
5211 AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
5212 "findByP_V",
5213 new String[] {
5214 Long.class.getName(), Long.class.getName(),
5215
5216 Integer.class.getName(), Integer.class.getName(),
5217 OrderByComparator.class.getName()
5218 });
5219 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_P_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
5220 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
5221 AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
5222 "findByP_V",
5223 new String[] { Long.class.getName(), Long.class.getName() },
5224 AssetCategoryModelImpl.PARENTCATEGORYID_COLUMN_BITMASK |
5225 AssetCategoryModelImpl.VOCABULARYID_COLUMN_BITMASK |
5226 AssetCategoryModelImpl.NAME_COLUMN_BITMASK);
5227 public static final FinderPath FINDER_PATH_COUNT_BY_P_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
5228 AssetCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class,
5229 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByP_V",
5230 new String[] { Long.class.getName(), Long.class.getName() });
5231
5232
5239 @Override
5240 public List<AssetCategory> findByP_V(long parentCategoryId,
5241 long vocabularyId) {
5242 return findByP_V(parentCategoryId, vocabularyId, QueryUtil.ALL_POS,
5243 QueryUtil.ALL_POS, null);
5244 }
5245
5246
5259 @Override
5260 public List<AssetCategory> findByP_V(long parentCategoryId,
5261 long vocabularyId, int start, int end) {
5262 return findByP_V(parentCategoryId, vocabularyId, start, end, null);
5263 }
5264
5265
5279 @Override
5280 public List<AssetCategory> findByP_V(long parentCategoryId,
5281 long vocabularyId, int start, int end,
5282 OrderByComparator<AssetCategory> orderByComparator) {
5283 boolean pagination = true;
5284 FinderPath finderPath = null;
5285 Object[] finderArgs = null;
5286
5287 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
5288 (orderByComparator == null)) {
5289 pagination = false;
5290 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_P_V;
5291 finderArgs = new Object[] { parentCategoryId, vocabularyId };
5292 }
5293 else {
5294 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_P_V;
5295 finderArgs = new Object[] {
5296 parentCategoryId, vocabularyId,
5297
5298 start, end, orderByComparator
5299 };
5300 }
5301
5302 List<AssetCategory> list = (List<AssetCategory>)FinderCacheUtil.getResult(finderPath,
5303 finderArgs, this);
5304
5305 if ((list != null) && !list.isEmpty()) {
5306 for (AssetCategory assetCategory : list) {
5307 if ((parentCategoryId != assetCategory.getParentCategoryId()) ||
5308 (vocabularyId != assetCategory.getVocabularyId())) {
5309 list = null;
5310
5311 break;
5312 }
5313 }
5314 }
5315
5316 if (list == null) {
5317 StringBundler query = null;
5318
5319 if (orderByComparator != null) {
5320 query = new StringBundler(4 +
5321 (orderByComparator.getOrderByFields().length * 3));
5322 }
5323 else {
5324 query = new StringBundler(4);
5325 }
5326
5327 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
5328
5329 query.append(_FINDER_COLUMN_P_V_PARENTCATEGORYID_2);
5330
5331 query.append(_FINDER_COLUMN_P_V_VOCABULARYID_2);
5332
5333 if (orderByComparator != null) {
5334 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
5335 orderByComparator);
5336 }
5337 else
5338 if (pagination) {
5339 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
5340 }
5341
5342 String sql = query.toString();
5343
5344 Session session = null;
5345
5346 try {
5347 session = openSession();
5348
5349 Query q = session.createQuery(sql);
5350
5351 QueryPos qPos = QueryPos.getInstance(q);
5352
5353 qPos.add(parentCategoryId);
5354
5355 qPos.add(vocabularyId);
5356
5357 if (!pagination) {
5358 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
5359 start, end, false);
5360
5361 Collections.sort(list);
5362
5363 list = Collections.unmodifiableList(list);
5364 }
5365 else {
5366 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
5367 start, end);
5368 }
5369
5370 cacheResult(list);
5371
5372 FinderCacheUtil.putResult(finderPath, finderArgs, list);
5373 }
5374 catch (Exception e) {
5375 FinderCacheUtil.removeResult(finderPath, finderArgs);
5376
5377 throw processException(e);
5378 }
5379 finally {
5380 closeSession(session);
5381 }
5382 }
5383
5384 return list;
5385 }
5386
5387
5396 @Override
5397 public AssetCategory findByP_V_First(long parentCategoryId,
5398 long vocabularyId, OrderByComparator<AssetCategory> orderByComparator)
5399 throws NoSuchCategoryException {
5400 AssetCategory assetCategory = fetchByP_V_First(parentCategoryId,
5401 vocabularyId, orderByComparator);
5402
5403 if (assetCategory != null) {
5404 return assetCategory;
5405 }
5406
5407 StringBundler msg = new StringBundler(6);
5408
5409 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5410
5411 msg.append("parentCategoryId=");
5412 msg.append(parentCategoryId);
5413
5414 msg.append(", vocabularyId=");
5415 msg.append(vocabularyId);
5416
5417 msg.append(StringPool.CLOSE_CURLY_BRACE);
5418
5419 throw new NoSuchCategoryException(msg.toString());
5420 }
5421
5422
5430 @Override
5431 public AssetCategory fetchByP_V_First(long parentCategoryId,
5432 long vocabularyId, OrderByComparator<AssetCategory> orderByComparator) {
5433 List<AssetCategory> list = findByP_V(parentCategoryId, vocabularyId, 0,
5434 1, orderByComparator);
5435
5436 if (!list.isEmpty()) {
5437 return list.get(0);
5438 }
5439
5440 return null;
5441 }
5442
5443
5452 @Override
5453 public AssetCategory findByP_V_Last(long parentCategoryId,
5454 long vocabularyId, OrderByComparator<AssetCategory> orderByComparator)
5455 throws NoSuchCategoryException {
5456 AssetCategory assetCategory = fetchByP_V_Last(parentCategoryId,
5457 vocabularyId, orderByComparator);
5458
5459 if (assetCategory != null) {
5460 return assetCategory;
5461 }
5462
5463 StringBundler msg = new StringBundler(6);
5464
5465 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5466
5467 msg.append("parentCategoryId=");
5468 msg.append(parentCategoryId);
5469
5470 msg.append(", vocabularyId=");
5471 msg.append(vocabularyId);
5472
5473 msg.append(StringPool.CLOSE_CURLY_BRACE);
5474
5475 throw new NoSuchCategoryException(msg.toString());
5476 }
5477
5478
5486 @Override
5487 public AssetCategory fetchByP_V_Last(long parentCategoryId,
5488 long vocabularyId, OrderByComparator<AssetCategory> orderByComparator) {
5489 int count = countByP_V(parentCategoryId, vocabularyId);
5490
5491 if (count == 0) {
5492 return null;
5493 }
5494
5495 List<AssetCategory> list = findByP_V(parentCategoryId, vocabularyId,
5496 count - 1, count, orderByComparator);
5497
5498 if (!list.isEmpty()) {
5499 return list.get(0);
5500 }
5501
5502 return null;
5503 }
5504
5505
5515 @Override
5516 public AssetCategory[] findByP_V_PrevAndNext(long categoryId,
5517 long parentCategoryId, long vocabularyId,
5518 OrderByComparator<AssetCategory> orderByComparator)
5519 throws NoSuchCategoryException {
5520 AssetCategory assetCategory = findByPrimaryKey(categoryId);
5521
5522 Session session = null;
5523
5524 try {
5525 session = openSession();
5526
5527 AssetCategory[] array = new AssetCategoryImpl[3];
5528
5529 array[0] = getByP_V_PrevAndNext(session, assetCategory,
5530 parentCategoryId, vocabularyId, orderByComparator, true);
5531
5532 array[1] = assetCategory;
5533
5534 array[2] = getByP_V_PrevAndNext(session, assetCategory,
5535 parentCategoryId, vocabularyId, orderByComparator, false);
5536
5537 return array;
5538 }
5539 catch (Exception e) {
5540 throw processException(e);
5541 }
5542 finally {
5543 closeSession(session);
5544 }
5545 }
5546
5547 protected AssetCategory getByP_V_PrevAndNext(Session session,
5548 AssetCategory assetCategory, long parentCategoryId, long vocabularyId,
5549 OrderByComparator<AssetCategory> orderByComparator, boolean previous) {
5550 StringBundler query = null;
5551
5552 if (orderByComparator != null) {
5553 query = new StringBundler(6 +
5554 (orderByComparator.getOrderByFields().length * 6));
5555 }
5556 else {
5557 query = new StringBundler(3);
5558 }
5559
5560 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
5561
5562 query.append(_FINDER_COLUMN_P_V_PARENTCATEGORYID_2);
5563
5564 query.append(_FINDER_COLUMN_P_V_VOCABULARYID_2);
5565
5566 if (orderByComparator != null) {
5567 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
5568
5569 if (orderByConditionFields.length > 0) {
5570 query.append(WHERE_AND);
5571 }
5572
5573 for (int i = 0; i < orderByConditionFields.length; i++) {
5574 query.append(_ORDER_BY_ENTITY_ALIAS);
5575 query.append(orderByConditionFields[i]);
5576
5577 if ((i + 1) < orderByConditionFields.length) {
5578 if (orderByComparator.isAscending() ^ previous) {
5579 query.append(WHERE_GREATER_THAN_HAS_NEXT);
5580 }
5581 else {
5582 query.append(WHERE_LESSER_THAN_HAS_NEXT);
5583 }
5584 }
5585 else {
5586 if (orderByComparator.isAscending() ^ previous) {
5587 query.append(WHERE_GREATER_THAN);
5588 }
5589 else {
5590 query.append(WHERE_LESSER_THAN);
5591 }
5592 }
5593 }
5594
5595 query.append(ORDER_BY_CLAUSE);
5596
5597 String[] orderByFields = orderByComparator.getOrderByFields();
5598
5599 for (int i = 0; i < orderByFields.length; i++) {
5600 query.append(_ORDER_BY_ENTITY_ALIAS);
5601 query.append(orderByFields[i]);
5602
5603 if ((i + 1) < orderByFields.length) {
5604 if (orderByComparator.isAscending() ^ previous) {
5605 query.append(ORDER_BY_ASC_HAS_NEXT);
5606 }
5607 else {
5608 query.append(ORDER_BY_DESC_HAS_NEXT);
5609 }
5610 }
5611 else {
5612 if (orderByComparator.isAscending() ^ previous) {
5613 query.append(ORDER_BY_ASC);
5614 }
5615 else {
5616 query.append(ORDER_BY_DESC);
5617 }
5618 }
5619 }
5620 }
5621 else {
5622 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
5623 }
5624
5625 String sql = query.toString();
5626
5627 Query q = session.createQuery(sql);
5628
5629 q.setFirstResult(0);
5630 q.setMaxResults(2);
5631
5632 QueryPos qPos = QueryPos.getInstance(q);
5633
5634 qPos.add(parentCategoryId);
5635
5636 qPos.add(vocabularyId);
5637
5638 if (orderByComparator != null) {
5639 Object[] values = orderByComparator.getOrderByConditionValues(assetCategory);
5640
5641 for (Object value : values) {
5642 qPos.add(value);
5643 }
5644 }
5645
5646 List<AssetCategory> list = q.list();
5647
5648 if (list.size() == 2) {
5649 return list.get(1);
5650 }
5651 else {
5652 return null;
5653 }
5654 }
5655
5656
5662 @Override
5663 public void removeByP_V(long parentCategoryId, long vocabularyId) {
5664 for (AssetCategory assetCategory : findByP_V(parentCategoryId,
5665 vocabularyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
5666 remove(assetCategory);
5667 }
5668 }
5669
5670
5677 @Override
5678 public int countByP_V(long parentCategoryId, long vocabularyId) {
5679 FinderPath finderPath = FINDER_PATH_COUNT_BY_P_V;
5680
5681 Object[] finderArgs = new Object[] { parentCategoryId, vocabularyId };
5682
5683 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
5684 this);
5685
5686 if (count == null) {
5687 StringBundler query = new StringBundler(3);
5688
5689 query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
5690
5691 query.append(_FINDER_COLUMN_P_V_PARENTCATEGORYID_2);
5692
5693 query.append(_FINDER_COLUMN_P_V_VOCABULARYID_2);
5694
5695 String sql = query.toString();
5696
5697 Session session = null;
5698
5699 try {
5700 session = openSession();
5701
5702 Query q = session.createQuery(sql);
5703
5704 QueryPos qPos = QueryPos.getInstance(q);
5705
5706 qPos.add(parentCategoryId);
5707
5708 qPos.add(vocabularyId);
5709
5710 count = (Long)q.uniqueResult();
5711
5712 FinderCacheUtil.putResult(finderPath, finderArgs, count);
5713 }
5714 catch (Exception e) {
5715 FinderCacheUtil.removeResult(finderPath, finderArgs);
5716
5717 throw processException(e);
5718 }
5719 finally {
5720 closeSession(session);
5721 }
5722 }
5723
5724 return count.intValue();
5725 }
5726
5727 private static final String _FINDER_COLUMN_P_V_PARENTCATEGORYID_2 = "assetCategory.parentCategoryId = ? AND ";
5728 private static final String _FINDER_COLUMN_P_V_VOCABULARYID_2 = "assetCategory.vocabularyId = ?";
5729 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_N_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
5730 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
5731 AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
5732 "findByN_V",
5733 new String[] {
5734 String.class.getName(), Long.class.getName(),
5735
5736 Integer.class.getName(), Integer.class.getName(),
5737 OrderByComparator.class.getName()
5738 });
5739 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
5740 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
5741 AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
5742 "findByN_V",
5743 new String[] { String.class.getName(), Long.class.getName() },
5744 AssetCategoryModelImpl.NAME_COLUMN_BITMASK |
5745 AssetCategoryModelImpl.VOCABULARYID_COLUMN_BITMASK);
5746 public static final FinderPath FINDER_PATH_COUNT_BY_N_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
5747 AssetCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class,
5748 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByN_V",
5749 new String[] { String.class.getName(), Long.class.getName() });
5750
5751
5758 @Override
5759 public List<AssetCategory> findByN_V(String name, long vocabularyId) {
5760 return findByN_V(name, vocabularyId, QueryUtil.ALL_POS,
5761 QueryUtil.ALL_POS, null);
5762 }
5763
5764
5777 @Override
5778 public List<AssetCategory> findByN_V(String name, long vocabularyId,
5779 int start, int end) {
5780 return findByN_V(name, vocabularyId, start, end, null);
5781 }
5782
5783
5797 @Override
5798 public List<AssetCategory> findByN_V(String name, long vocabularyId,
5799 int start, int end, OrderByComparator<AssetCategory> orderByComparator) {
5800 boolean pagination = true;
5801 FinderPath finderPath = null;
5802 Object[] finderArgs = null;
5803
5804 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
5805 (orderByComparator == null)) {
5806 pagination = false;
5807 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_V;
5808 finderArgs = new Object[] { name, vocabularyId };
5809 }
5810 else {
5811 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_N_V;
5812 finderArgs = new Object[] {
5813 name, vocabularyId,
5814
5815 start, end, orderByComparator
5816 };
5817 }
5818
5819 List<AssetCategory> list = (List<AssetCategory>)FinderCacheUtil.getResult(finderPath,
5820 finderArgs, this);
5821
5822 if ((list != null) && !list.isEmpty()) {
5823 for (AssetCategory assetCategory : list) {
5824 if (!Validator.equals(name, assetCategory.getName()) ||
5825 (vocabularyId != assetCategory.getVocabularyId())) {
5826 list = null;
5827
5828 break;
5829 }
5830 }
5831 }
5832
5833 if (list == null) {
5834 StringBundler query = null;
5835
5836 if (orderByComparator != null) {
5837 query = new StringBundler(4 +
5838 (orderByComparator.getOrderByFields().length * 3));
5839 }
5840 else {
5841 query = new StringBundler(4);
5842 }
5843
5844 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
5845
5846 boolean bindName = false;
5847
5848 if (name == null) {
5849 query.append(_FINDER_COLUMN_N_V_NAME_1);
5850 }
5851 else if (name.equals(StringPool.BLANK)) {
5852 query.append(_FINDER_COLUMN_N_V_NAME_3);
5853 }
5854 else {
5855 bindName = true;
5856
5857 query.append(_FINDER_COLUMN_N_V_NAME_2);
5858 }
5859
5860 query.append(_FINDER_COLUMN_N_V_VOCABULARYID_2);
5861
5862 if (orderByComparator != null) {
5863 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
5864 orderByComparator);
5865 }
5866 else
5867 if (pagination) {
5868 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
5869 }
5870
5871 String sql = query.toString();
5872
5873 Session session = null;
5874
5875 try {
5876 session = openSession();
5877
5878 Query q = session.createQuery(sql);
5879
5880 QueryPos qPos = QueryPos.getInstance(q);
5881
5882 if (bindName) {
5883 qPos.add(name);
5884 }
5885
5886 qPos.add(vocabularyId);
5887
5888 if (!pagination) {
5889 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
5890 start, end, false);
5891
5892 Collections.sort(list);
5893
5894 list = Collections.unmodifiableList(list);
5895 }
5896 else {
5897 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
5898 start, end);
5899 }
5900
5901 cacheResult(list);
5902
5903 FinderCacheUtil.putResult(finderPath, finderArgs, list);
5904 }
5905 catch (Exception e) {
5906 FinderCacheUtil.removeResult(finderPath, finderArgs);
5907
5908 throw processException(e);
5909 }
5910 finally {
5911 closeSession(session);
5912 }
5913 }
5914
5915 return list;
5916 }
5917
5918
5927 @Override
5928 public AssetCategory findByN_V_First(String name, long vocabularyId,
5929 OrderByComparator<AssetCategory> orderByComparator)
5930 throws NoSuchCategoryException {
5931 AssetCategory assetCategory = fetchByN_V_First(name, vocabularyId,
5932 orderByComparator);
5933
5934 if (assetCategory != null) {
5935 return assetCategory;
5936 }
5937
5938 StringBundler msg = new StringBundler(6);
5939
5940 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5941
5942 msg.append("name=");
5943 msg.append(name);
5944
5945 msg.append(", vocabularyId=");
5946 msg.append(vocabularyId);
5947
5948 msg.append(StringPool.CLOSE_CURLY_BRACE);
5949
5950 throw new NoSuchCategoryException(msg.toString());
5951 }
5952
5953
5961 @Override
5962 public AssetCategory fetchByN_V_First(String name, long vocabularyId,
5963 OrderByComparator<AssetCategory> orderByComparator) {
5964 List<AssetCategory> list = findByN_V(name, vocabularyId, 0, 1,
5965 orderByComparator);
5966
5967 if (!list.isEmpty()) {
5968 return list.get(0);
5969 }
5970
5971 return null;
5972 }
5973
5974
5983 @Override
5984 public AssetCategory findByN_V_Last(String name, long vocabularyId,
5985 OrderByComparator<AssetCategory> orderByComparator)
5986 throws NoSuchCategoryException {
5987 AssetCategory assetCategory = fetchByN_V_Last(name, vocabularyId,
5988 orderByComparator);
5989
5990 if (assetCategory != null) {
5991 return assetCategory;
5992 }
5993
5994 StringBundler msg = new StringBundler(6);
5995
5996 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5997
5998 msg.append("name=");
5999 msg.append(name);
6000
6001 msg.append(", vocabularyId=");
6002 msg.append(vocabularyId);
6003
6004 msg.append(StringPool.CLOSE_CURLY_BRACE);
6005
6006 throw new NoSuchCategoryException(msg.toString());
6007 }
6008
6009
6017 @Override
6018 public AssetCategory fetchByN_V_Last(String name, long vocabularyId,
6019 OrderByComparator<AssetCategory> orderByComparator) {
6020 int count = countByN_V(name, vocabularyId);
6021
6022 if (count == 0) {
6023 return null;
6024 }
6025
6026 List<AssetCategory> list = findByN_V(name, vocabularyId, count - 1,
6027 count, orderByComparator);
6028
6029 if (!list.isEmpty()) {
6030 return list.get(0);
6031 }
6032
6033 return null;
6034 }
6035
6036
6046 @Override
6047 public AssetCategory[] findByN_V_PrevAndNext(long categoryId, String name,
6048 long vocabularyId, OrderByComparator<AssetCategory> orderByComparator)
6049 throws NoSuchCategoryException {
6050 AssetCategory assetCategory = findByPrimaryKey(categoryId);
6051
6052 Session session = null;
6053
6054 try {
6055 session = openSession();
6056
6057 AssetCategory[] array = new AssetCategoryImpl[3];
6058
6059 array[0] = getByN_V_PrevAndNext(session, assetCategory, name,
6060 vocabularyId, orderByComparator, true);
6061
6062 array[1] = assetCategory;
6063
6064 array[2] = getByN_V_PrevAndNext(session, assetCategory, name,
6065 vocabularyId, orderByComparator, false);
6066
6067 return array;
6068 }
6069 catch (Exception e) {
6070 throw processException(e);
6071 }
6072 finally {
6073 closeSession(session);
6074 }
6075 }
6076
6077 protected AssetCategory getByN_V_PrevAndNext(Session session,
6078 AssetCategory assetCategory, String name, long vocabularyId,
6079 OrderByComparator<AssetCategory> orderByComparator, boolean previous) {
6080 StringBundler query = null;
6081
6082 if (orderByComparator != null) {
6083 query = new StringBundler(6 +
6084 (orderByComparator.getOrderByFields().length * 6));
6085 }
6086 else {
6087 query = new StringBundler(3);
6088 }
6089
6090 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
6091
6092 boolean bindName = false;
6093
6094 if (name == null) {
6095 query.append(_FINDER_COLUMN_N_V_NAME_1);
6096 }
6097 else if (name.equals(StringPool.BLANK)) {
6098 query.append(_FINDER_COLUMN_N_V_NAME_3);
6099 }
6100 else {
6101 bindName = true;
6102
6103 query.append(_FINDER_COLUMN_N_V_NAME_2);
6104 }
6105
6106 query.append(_FINDER_COLUMN_N_V_VOCABULARYID_2);
6107
6108 if (orderByComparator != null) {
6109 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
6110
6111 if (orderByConditionFields.length > 0) {
6112 query.append(WHERE_AND);
6113 }
6114
6115 for (int i = 0; i < orderByConditionFields.length; i++) {
6116 query.append(_ORDER_BY_ENTITY_ALIAS);
6117 query.append(orderByConditionFields[i]);
6118
6119 if ((i + 1) < orderByConditionFields.length) {
6120 if (orderByComparator.isAscending() ^ previous) {
6121 query.append(WHERE_GREATER_THAN_HAS_NEXT);
6122 }
6123 else {
6124 query.append(WHERE_LESSER_THAN_HAS_NEXT);
6125 }
6126 }
6127 else {
6128 if (orderByComparator.isAscending() ^ previous) {
6129 query.append(WHERE_GREATER_THAN);
6130 }
6131 else {
6132 query.append(WHERE_LESSER_THAN);
6133 }
6134 }
6135 }
6136
6137 query.append(ORDER_BY_CLAUSE);
6138
6139 String[] orderByFields = orderByComparator.getOrderByFields();
6140
6141 for (int i = 0; i < orderByFields.length; i++) {
6142 query.append(_ORDER_BY_ENTITY_ALIAS);
6143 query.append(orderByFields[i]);
6144
6145 if ((i + 1) < orderByFields.length) {
6146 if (orderByComparator.isAscending() ^ previous) {
6147 query.append(ORDER_BY_ASC_HAS_NEXT);
6148 }
6149 else {
6150 query.append(ORDER_BY_DESC_HAS_NEXT);
6151 }
6152 }
6153 else {
6154 if (orderByComparator.isAscending() ^ previous) {
6155 query.append(ORDER_BY_ASC);
6156 }
6157 else {
6158 query.append(ORDER_BY_DESC);
6159 }
6160 }
6161 }
6162 }
6163 else {
6164 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
6165 }
6166
6167 String sql = query.toString();
6168
6169 Query q = session.createQuery(sql);
6170
6171 q.setFirstResult(0);
6172 q.setMaxResults(2);
6173
6174 QueryPos qPos = QueryPos.getInstance(q);
6175
6176 if (bindName) {
6177 qPos.add(name);
6178 }
6179
6180 qPos.add(vocabularyId);
6181
6182 if (orderByComparator != null) {
6183 Object[] values = orderByComparator.getOrderByConditionValues(assetCategory);
6184
6185 for (Object value : values) {
6186 qPos.add(value);
6187 }
6188 }
6189
6190 List<AssetCategory> list = q.list();
6191
6192 if (list.size() == 2) {
6193 return list.get(1);
6194 }
6195 else {
6196 return null;
6197 }
6198 }
6199
6200
6206 @Override
6207 public void removeByN_V(String name, long vocabularyId) {
6208 for (AssetCategory assetCategory : findByN_V(name, vocabularyId,
6209 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
6210 remove(assetCategory);
6211 }
6212 }
6213
6214
6221 @Override
6222 public int countByN_V(String name, long vocabularyId) {
6223 FinderPath finderPath = FINDER_PATH_COUNT_BY_N_V;
6224
6225 Object[] finderArgs = new Object[] { name, vocabularyId };
6226
6227 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
6228 this);
6229
6230 if (count == null) {
6231 StringBundler query = new StringBundler(3);
6232
6233 query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
6234
6235 boolean bindName = false;
6236
6237 if (name == null) {
6238 query.append(_FINDER_COLUMN_N_V_NAME_1);
6239 }
6240 else if (name.equals(StringPool.BLANK)) {
6241 query.append(_FINDER_COLUMN_N_V_NAME_3);
6242 }
6243 else {
6244 bindName = true;
6245
6246 query.append(_FINDER_COLUMN_N_V_NAME_2);
6247 }
6248
6249 query.append(_FINDER_COLUMN_N_V_VOCABULARYID_2);
6250
6251 String sql = query.toString();
6252
6253 Session session = null;
6254
6255 try {
6256 session = openSession();
6257
6258 Query q = session.createQuery(sql);
6259
6260 QueryPos qPos = QueryPos.getInstance(q);
6261
6262 if (bindName) {
6263 qPos.add(name);
6264 }
6265
6266 qPos.add(vocabularyId);
6267
6268 count = (Long)q.uniqueResult();
6269
6270 FinderCacheUtil.putResult(finderPath, finderArgs, count);
6271 }
6272 catch (Exception e) {
6273 FinderCacheUtil.removeResult(finderPath, finderArgs);
6274
6275 throw processException(e);
6276 }
6277 finally {
6278 closeSession(session);
6279 }
6280 }
6281
6282 return count.intValue();
6283 }
6284
6285 private static final String _FINDER_COLUMN_N_V_NAME_1 = "assetCategory.name IS NULL AND ";
6286 private static final String _FINDER_COLUMN_N_V_NAME_2 = "assetCategory.name = ? AND ";
6287 private static final String _FINDER_COLUMN_N_V_NAME_3 = "(assetCategory.name IS NULL OR assetCategory.name = '') AND ";
6288 private static final String _FINDER_COLUMN_N_V_VOCABULARYID_2 = "assetCategory.vocabularyId = ?";
6289 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_P_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
6290 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
6291 AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
6292 "findByG_P_V",
6293 new String[] {
6294 Long.class.getName(), Long.class.getName(), Long.class.getName(),
6295
6296 Integer.class.getName(), Integer.class.getName(),
6297 OrderByComparator.class.getName()
6298 });
6299 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
6300 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
6301 AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
6302 "findByG_P_V",
6303 new String[] {
6304 Long.class.getName(), Long.class.getName(), Long.class.getName()
6305 },
6306 AssetCategoryModelImpl.GROUPID_COLUMN_BITMASK |
6307 AssetCategoryModelImpl.PARENTCATEGORYID_COLUMN_BITMASK |
6308 AssetCategoryModelImpl.VOCABULARYID_COLUMN_BITMASK |
6309 AssetCategoryModelImpl.NAME_COLUMN_BITMASK);
6310 public static final FinderPath FINDER_PATH_COUNT_BY_G_P_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
6311 AssetCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class,
6312 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_P_V",
6313 new String[] {
6314 Long.class.getName(), Long.class.getName(), Long.class.getName()
6315 });
6316
6317
6325 @Override
6326 public List<AssetCategory> findByG_P_V(long groupId, long parentCategoryId,
6327 long vocabularyId) {
6328 return findByG_P_V(groupId, parentCategoryId, vocabularyId,
6329 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
6330 }
6331
6332
6346 @Override
6347 public List<AssetCategory> findByG_P_V(long groupId, long parentCategoryId,
6348 long vocabularyId, int start, int end) {
6349 return findByG_P_V(groupId, parentCategoryId, vocabularyId, start, end,
6350 null);
6351 }
6352
6353
6368 @Override
6369 public List<AssetCategory> findByG_P_V(long groupId, long parentCategoryId,
6370 long vocabularyId, int start, int end,
6371 OrderByComparator<AssetCategory> orderByComparator) {
6372 boolean pagination = true;
6373 FinderPath finderPath = null;
6374 Object[] finderArgs = null;
6375
6376 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
6377 (orderByComparator == null)) {
6378 pagination = false;
6379 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_V;
6380 finderArgs = new Object[] { groupId, parentCategoryId, vocabularyId };
6381 }
6382 else {
6383 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_P_V;
6384 finderArgs = new Object[] {
6385 groupId, parentCategoryId, vocabularyId,
6386
6387 start, end, orderByComparator
6388 };
6389 }
6390
6391 List<AssetCategory> list = (List<AssetCategory>)FinderCacheUtil.getResult(finderPath,
6392 finderArgs, this);
6393
6394 if ((list != null) && !list.isEmpty()) {
6395 for (AssetCategory assetCategory : list) {
6396 if ((groupId != assetCategory.getGroupId()) ||
6397 (parentCategoryId != assetCategory.getParentCategoryId()) ||
6398 (vocabularyId != assetCategory.getVocabularyId())) {
6399 list = null;
6400
6401 break;
6402 }
6403 }
6404 }
6405
6406 if (list == null) {
6407 StringBundler query = null;
6408
6409 if (orderByComparator != null) {
6410 query = new StringBundler(5 +
6411 (orderByComparator.getOrderByFields().length * 3));
6412 }
6413 else {
6414 query = new StringBundler(5);
6415 }
6416
6417 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
6418
6419 query.append(_FINDER_COLUMN_G_P_V_GROUPID_2);
6420
6421 query.append(_FINDER_COLUMN_G_P_V_PARENTCATEGORYID_2);
6422
6423 query.append(_FINDER_COLUMN_G_P_V_VOCABULARYID_2);
6424
6425 if (orderByComparator != null) {
6426 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
6427 orderByComparator);
6428 }
6429 else
6430 if (pagination) {
6431 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
6432 }
6433
6434 String sql = query.toString();
6435
6436 Session session = null;
6437
6438 try {
6439 session = openSession();
6440
6441 Query q = session.createQuery(sql);
6442
6443 QueryPos qPos = QueryPos.getInstance(q);
6444
6445 qPos.add(groupId);
6446
6447 qPos.add(parentCategoryId);
6448
6449 qPos.add(vocabularyId);
6450
6451 if (!pagination) {
6452 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
6453 start, end, false);
6454
6455 Collections.sort(list);
6456
6457 list = Collections.unmodifiableList(list);
6458 }
6459 else {
6460 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
6461 start, end);
6462 }
6463
6464 cacheResult(list);
6465
6466 FinderCacheUtil.putResult(finderPath, finderArgs, list);
6467 }
6468 catch (Exception e) {
6469 FinderCacheUtil.removeResult(finderPath, finderArgs);
6470
6471 throw processException(e);
6472 }
6473 finally {
6474 closeSession(session);
6475 }
6476 }
6477
6478 return list;
6479 }
6480
6481
6491 @Override
6492 public AssetCategory findByG_P_V_First(long groupId, long parentCategoryId,
6493 long vocabularyId, OrderByComparator<AssetCategory> orderByComparator)
6494 throws NoSuchCategoryException {
6495 AssetCategory assetCategory = fetchByG_P_V_First(groupId,
6496 parentCategoryId, vocabularyId, orderByComparator);
6497
6498 if (assetCategory != null) {
6499 return assetCategory;
6500 }
6501
6502 StringBundler msg = new StringBundler(8);
6503
6504 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
6505
6506 msg.append("groupId=");
6507 msg.append(groupId);
6508
6509 msg.append(", parentCategoryId=");
6510 msg.append(parentCategoryId);
6511
6512 msg.append(", vocabularyId=");
6513 msg.append(vocabularyId);
6514
6515 msg.append(StringPool.CLOSE_CURLY_BRACE);
6516
6517 throw new NoSuchCategoryException(msg.toString());
6518 }
6519
6520
6529 @Override
6530 public AssetCategory fetchByG_P_V_First(long groupId,
6531 long parentCategoryId, long vocabularyId,
6532 OrderByComparator<AssetCategory> orderByComparator) {
6533 List<AssetCategory> list = findByG_P_V(groupId, parentCategoryId,
6534 vocabularyId, 0, 1, orderByComparator);
6535
6536 if (!list.isEmpty()) {
6537 return list.get(0);
6538 }
6539
6540 return null;
6541 }
6542
6543
6553 @Override
6554 public AssetCategory findByG_P_V_Last(long groupId, long parentCategoryId,
6555 long vocabularyId, OrderByComparator<AssetCategory> orderByComparator)
6556 throws NoSuchCategoryException {
6557 AssetCategory assetCategory = fetchByG_P_V_Last(groupId,
6558 parentCategoryId, vocabularyId, orderByComparator);
6559
6560 if (assetCategory != null) {
6561 return assetCategory;
6562 }
6563
6564 StringBundler msg = new StringBundler(8);
6565
6566 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
6567
6568 msg.append("groupId=");
6569 msg.append(groupId);
6570
6571 msg.append(", parentCategoryId=");
6572 msg.append(parentCategoryId);
6573
6574 msg.append(", vocabularyId=");
6575 msg.append(vocabularyId);
6576
6577 msg.append(StringPool.CLOSE_CURLY_BRACE);
6578
6579 throw new NoSuchCategoryException(msg.toString());
6580 }
6581
6582
6591 @Override
6592 public AssetCategory fetchByG_P_V_Last(long groupId, long parentCategoryId,
6593 long vocabularyId, OrderByComparator<AssetCategory> orderByComparator) {
6594 int count = countByG_P_V(groupId, parentCategoryId, vocabularyId);
6595
6596 if (count == 0) {
6597 return null;
6598 }
6599
6600 List<AssetCategory> list = findByG_P_V(groupId, parentCategoryId,
6601 vocabularyId, count - 1, count, orderByComparator);
6602
6603 if (!list.isEmpty()) {
6604 return list.get(0);
6605 }
6606
6607 return null;
6608 }
6609
6610
6621 @Override
6622 public AssetCategory[] findByG_P_V_PrevAndNext(long categoryId,
6623 long groupId, long parentCategoryId, long vocabularyId,
6624 OrderByComparator<AssetCategory> orderByComparator)
6625 throws NoSuchCategoryException {
6626 AssetCategory assetCategory = findByPrimaryKey(categoryId);
6627
6628 Session session = null;
6629
6630 try {
6631 session = openSession();
6632
6633 AssetCategory[] array = new AssetCategoryImpl[3];
6634
6635 array[0] = getByG_P_V_PrevAndNext(session, assetCategory, groupId,
6636 parentCategoryId, vocabularyId, orderByComparator, true);
6637
6638 array[1] = assetCategory;
6639
6640 array[2] = getByG_P_V_PrevAndNext(session, assetCategory, groupId,
6641 parentCategoryId, vocabularyId, orderByComparator, false);
6642
6643 return array;
6644 }
6645 catch (Exception e) {
6646 throw processException(e);
6647 }
6648 finally {
6649 closeSession(session);
6650 }
6651 }
6652
6653 protected AssetCategory getByG_P_V_PrevAndNext(Session session,
6654 AssetCategory assetCategory, long groupId, long parentCategoryId,
6655 long vocabularyId, OrderByComparator<AssetCategory> orderByComparator,
6656 boolean previous) {
6657 StringBundler query = null;
6658
6659 if (orderByComparator != null) {
6660 query = new StringBundler(6 +
6661 (orderByComparator.getOrderByFields().length * 6));
6662 }
6663 else {
6664 query = new StringBundler(3);
6665 }
6666
6667 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
6668
6669 query.append(_FINDER_COLUMN_G_P_V_GROUPID_2);
6670
6671 query.append(_FINDER_COLUMN_G_P_V_PARENTCATEGORYID_2);
6672
6673 query.append(_FINDER_COLUMN_G_P_V_VOCABULARYID_2);
6674
6675 if (orderByComparator != null) {
6676 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
6677
6678 if (orderByConditionFields.length > 0) {
6679 query.append(WHERE_AND);
6680 }
6681
6682 for (int i = 0; i < orderByConditionFields.length; i++) {
6683 query.append(_ORDER_BY_ENTITY_ALIAS);
6684 query.append(orderByConditionFields[i]);
6685
6686 if ((i + 1) < orderByConditionFields.length) {
6687 if (orderByComparator.isAscending() ^ previous) {
6688 query.append(WHERE_GREATER_THAN_HAS_NEXT);
6689 }
6690 else {
6691 query.append(WHERE_LESSER_THAN_HAS_NEXT);
6692 }
6693 }
6694 else {
6695 if (orderByComparator.isAscending() ^ previous) {
6696 query.append(WHERE_GREATER_THAN);
6697 }
6698 else {
6699 query.append(WHERE_LESSER_THAN);
6700 }
6701 }
6702 }
6703
6704 query.append(ORDER_BY_CLAUSE);
6705
6706 String[] orderByFields = orderByComparator.getOrderByFields();
6707
6708 for (int i = 0; i < orderByFields.length; i++) {
6709 query.append(_ORDER_BY_ENTITY_ALIAS);
6710 query.append(orderByFields[i]);
6711
6712 if ((i + 1) < orderByFields.length) {
6713 if (orderByComparator.isAscending() ^ previous) {
6714 query.append(ORDER_BY_ASC_HAS_NEXT);
6715 }
6716 else {
6717 query.append(ORDER_BY_DESC_HAS_NEXT);
6718 }
6719 }
6720 else {
6721 if (orderByComparator.isAscending() ^ previous) {
6722 query.append(ORDER_BY_ASC);
6723 }
6724 else {
6725 query.append(ORDER_BY_DESC);
6726 }
6727 }
6728 }
6729 }
6730 else {
6731 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
6732 }
6733
6734 String sql = query.toString();
6735
6736 Query q = session.createQuery(sql);
6737
6738 q.setFirstResult(0);
6739 q.setMaxResults(2);
6740
6741 QueryPos qPos = QueryPos.getInstance(q);
6742
6743 qPos.add(groupId);
6744
6745 qPos.add(parentCategoryId);
6746
6747 qPos.add(vocabularyId);
6748
6749 if (orderByComparator != null) {
6750 Object[] values = orderByComparator.getOrderByConditionValues(assetCategory);
6751
6752 for (Object value : values) {
6753 qPos.add(value);
6754 }
6755 }
6756
6757 List<AssetCategory> list = q.list();
6758
6759 if (list.size() == 2) {
6760 return list.get(1);
6761 }
6762 else {
6763 return null;
6764 }
6765 }
6766
6767
6775 @Override
6776 public List<AssetCategory> filterFindByG_P_V(long groupId,
6777 long parentCategoryId, long vocabularyId) {
6778 return filterFindByG_P_V(groupId, parentCategoryId, vocabularyId,
6779 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
6780 }
6781
6782
6796 @Override
6797 public List<AssetCategory> filterFindByG_P_V(long groupId,
6798 long parentCategoryId, long vocabularyId, int start, int end) {
6799 return filterFindByG_P_V(groupId, parentCategoryId, vocabularyId,
6800 start, end, null);
6801 }
6802
6803
6818 @Override
6819 public List<AssetCategory> filterFindByG_P_V(long groupId,
6820 long parentCategoryId, long vocabularyId, int start, int end,
6821 OrderByComparator<AssetCategory> orderByComparator) {
6822 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
6823 return findByG_P_V(groupId, parentCategoryId, vocabularyId, start,
6824 end, orderByComparator);
6825 }
6826
6827 StringBundler query = null;
6828
6829 if (orderByComparator != null) {
6830 query = new StringBundler(5 +
6831 (orderByComparator.getOrderByFields().length * 3));
6832 }
6833 else {
6834 query = new StringBundler(5);
6835 }
6836
6837 if (getDB().isSupportsInlineDistinct()) {
6838 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_WHERE);
6839 }
6840 else {
6841 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_1);
6842 }
6843
6844 query.append(_FINDER_COLUMN_G_P_V_GROUPID_2);
6845
6846 query.append(_FINDER_COLUMN_G_P_V_PARENTCATEGORYID_2);
6847
6848 query.append(_FINDER_COLUMN_G_P_V_VOCABULARYID_2);
6849
6850 if (!getDB().isSupportsInlineDistinct()) {
6851 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_2);
6852 }
6853
6854 if (orderByComparator != null) {
6855 if (getDB().isSupportsInlineDistinct()) {
6856 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
6857 orderByComparator, true);
6858 }
6859 else {
6860 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
6861 orderByComparator, true);
6862 }
6863 }
6864 else {
6865 if (getDB().isSupportsInlineDistinct()) {
6866 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
6867 }
6868 else {
6869 query.append(AssetCategoryModelImpl.ORDER_BY_SQL);
6870 }
6871 }
6872
6873 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
6874 AssetCategory.class.getName(),
6875 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
6876
6877 Session session = null;
6878
6879 try {
6880 session = openSession();
6881
6882 SQLQuery q = session.createSynchronizedSQLQuery(sql);
6883
6884 if (getDB().isSupportsInlineDistinct()) {
6885 q.addEntity(_FILTER_ENTITY_ALIAS, AssetCategoryImpl.class);
6886 }
6887 else {
6888 q.addEntity(_FILTER_ENTITY_TABLE, AssetCategoryImpl.class);
6889 }
6890
6891 QueryPos qPos = QueryPos.getInstance(q);
6892
6893 qPos.add(groupId);
6894
6895 qPos.add(parentCategoryId);
6896
6897 qPos.add(vocabularyId);
6898
6899 return (List<AssetCategory>)QueryUtil.list(q, getDialect(), start,
6900 end);
6901 }
6902 catch (Exception e) {
6903 throw processException(e);
6904 }
6905 finally {
6906 closeSession(session);
6907 }
6908 }
6909
6910
6921 @Override
6922 public AssetCategory[] filterFindByG_P_V_PrevAndNext(long categoryId,
6923 long groupId, long parentCategoryId, long vocabularyId,
6924 OrderByComparator<AssetCategory> orderByComparator)
6925 throws NoSuchCategoryException {
6926 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
6927 return findByG_P_V_PrevAndNext(categoryId, groupId,
6928 parentCategoryId, vocabularyId, orderByComparator);
6929 }
6930
6931 AssetCategory assetCategory = findByPrimaryKey(categoryId);
6932
6933 Session session = null;
6934
6935 try {
6936 session = openSession();
6937
6938 AssetCategory[] array = new AssetCategoryImpl[3];
6939
6940 array[0] = filterGetByG_P_V_PrevAndNext(session, assetCategory,
6941 groupId, parentCategoryId, vocabularyId, orderByComparator,
6942 true);
6943
6944 array[1] = assetCategory;
6945
6946 array[2] = filterGetByG_P_V_PrevAndNext(session, assetCategory,
6947 groupId, parentCategoryId, vocabularyId, orderByComparator,
6948 false);
6949
6950 return array;
6951 }
6952 catch (Exception e) {
6953 throw processException(e);
6954 }
6955 finally {
6956 closeSession(session);
6957 }
6958 }
6959
6960 protected AssetCategory filterGetByG_P_V_PrevAndNext(Session session,
6961 AssetCategory assetCategory, long groupId, long parentCategoryId,
6962 long vocabularyId, OrderByComparator<AssetCategory> orderByComparator,
6963 boolean previous) {
6964 StringBundler query = null;
6965
6966 if (orderByComparator != null) {
6967 query = new StringBundler(6 +
6968 (orderByComparator.getOrderByFields().length * 6));
6969 }
6970 else {
6971 query = new StringBundler(3);
6972 }
6973
6974 if (getDB().isSupportsInlineDistinct()) {
6975 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_WHERE);
6976 }
6977 else {
6978 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_1);
6979 }
6980
6981 query.append(_FINDER_COLUMN_G_P_V_GROUPID_2);
6982
6983 query.append(_FINDER_COLUMN_G_P_V_PARENTCATEGORYID_2);
6984
6985 query.append(_FINDER_COLUMN_G_P_V_VOCABULARYID_2);
6986
6987 if (!getDB().isSupportsInlineDistinct()) {
6988 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_2);
6989 }
6990
6991 if (orderByComparator != null) {
6992 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
6993
6994 if (orderByConditionFields.length > 0) {
6995 query.append(WHERE_AND);
6996 }
6997
6998 for (int i = 0; i < orderByConditionFields.length; i++) {
6999 if (getDB().isSupportsInlineDistinct()) {
7000 query.append(_ORDER_BY_ENTITY_ALIAS);
7001 }
7002 else {
7003 query.append(_ORDER_BY_ENTITY_TABLE);
7004 }
7005
7006 query.append(orderByConditionFields[i]);
7007
7008 if ((i + 1) < orderByConditionFields.length) {
7009 if (orderByComparator.isAscending() ^ previous) {
7010 query.append(WHERE_GREATER_THAN_HAS_NEXT);
7011 }
7012 else {
7013 query.append(WHERE_LESSER_THAN_HAS_NEXT);
7014 }
7015 }
7016 else {
7017 if (orderByComparator.isAscending() ^ previous) {
7018 query.append(WHERE_GREATER_THAN);
7019 }
7020 else {
7021 query.append(WHERE_LESSER_THAN);
7022 }
7023 }
7024 }
7025
7026 query.append(ORDER_BY_CLAUSE);
7027
7028 String[] orderByFields = orderByComparator.getOrderByFields();
7029
7030 for (int i = 0; i < orderByFields.length; i++) {
7031 if (getDB().isSupportsInlineDistinct()) {
7032 query.append(_ORDER_BY_ENTITY_ALIAS);
7033 }
7034 else {
7035 query.append(_ORDER_BY_ENTITY_TABLE);
7036 }
7037
7038 query.append(orderByFields[i]);
7039
7040 if ((i + 1) < orderByFields.length) {
7041 if (orderByComparator.isAscending() ^ previous) {
7042 query.append(ORDER_BY_ASC_HAS_NEXT);
7043 }
7044 else {
7045 query.append(ORDER_BY_DESC_HAS_NEXT);
7046 }
7047 }
7048 else {
7049 if (orderByComparator.isAscending() ^ previous) {
7050 query.append(ORDER_BY_ASC);
7051 }
7052 else {
7053 query.append(ORDER_BY_DESC);
7054 }
7055 }
7056 }
7057 }
7058 else {
7059 if (getDB().isSupportsInlineDistinct()) {
7060 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
7061 }
7062 else {
7063 query.append(AssetCategoryModelImpl.ORDER_BY_SQL);
7064 }
7065 }
7066
7067 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
7068 AssetCategory.class.getName(),
7069 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
7070
7071 SQLQuery q = session.createSynchronizedSQLQuery(sql);
7072
7073 q.setFirstResult(0);
7074 q.setMaxResults(2);
7075
7076 if (getDB().isSupportsInlineDistinct()) {
7077 q.addEntity(_FILTER_ENTITY_ALIAS, AssetCategoryImpl.class);
7078 }
7079 else {
7080 q.addEntity(_FILTER_ENTITY_TABLE, AssetCategoryImpl.class);
7081 }
7082
7083 QueryPos qPos = QueryPos.getInstance(q);
7084
7085 qPos.add(groupId);
7086
7087 qPos.add(parentCategoryId);
7088
7089 qPos.add(vocabularyId);
7090
7091 if (orderByComparator != null) {
7092 Object[] values = orderByComparator.getOrderByConditionValues(assetCategory);
7093
7094 for (Object value : values) {
7095 qPos.add(value);
7096 }
7097 }
7098
7099 List<AssetCategory> list = q.list();
7100
7101 if (list.size() == 2) {
7102 return list.get(1);
7103 }
7104 else {
7105 return null;
7106 }
7107 }
7108
7109
7116 @Override
7117 public void removeByG_P_V(long groupId, long parentCategoryId,
7118 long vocabularyId) {
7119 for (AssetCategory assetCategory : findByG_P_V(groupId,
7120 parentCategoryId, vocabularyId, QueryUtil.ALL_POS,
7121 QueryUtil.ALL_POS, null)) {
7122 remove(assetCategory);
7123 }
7124 }
7125
7126
7134 @Override
7135 public int countByG_P_V(long groupId, long parentCategoryId,
7136 long vocabularyId) {
7137 FinderPath finderPath = FINDER_PATH_COUNT_BY_G_P_V;
7138
7139 Object[] finderArgs = new Object[] {
7140 groupId, parentCategoryId, vocabularyId
7141 };
7142
7143 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
7144 this);
7145
7146 if (count == null) {
7147 StringBundler query = new StringBundler(4);
7148
7149 query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
7150
7151 query.append(_FINDER_COLUMN_G_P_V_GROUPID_2);
7152
7153 query.append(_FINDER_COLUMN_G_P_V_PARENTCATEGORYID_2);
7154
7155 query.append(_FINDER_COLUMN_G_P_V_VOCABULARYID_2);
7156
7157 String sql = query.toString();
7158
7159 Session session = null;
7160
7161 try {
7162 session = openSession();
7163
7164 Query q = session.createQuery(sql);
7165
7166 QueryPos qPos = QueryPos.getInstance(q);
7167
7168 qPos.add(groupId);
7169
7170 qPos.add(parentCategoryId);
7171
7172 qPos.add(vocabularyId);
7173
7174 count = (Long)q.uniqueResult();
7175
7176 FinderCacheUtil.putResult(finderPath, finderArgs, count);
7177 }
7178 catch (Exception e) {
7179 FinderCacheUtil.removeResult(finderPath, finderArgs);
7180
7181 throw processException(e);
7182 }
7183 finally {
7184 closeSession(session);
7185 }
7186 }
7187
7188 return count.intValue();
7189 }
7190
7191
7199 @Override
7200 public int filterCountByG_P_V(long groupId, long parentCategoryId,
7201 long vocabularyId) {
7202 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
7203 return countByG_P_V(groupId, parentCategoryId, vocabularyId);
7204 }
7205
7206 StringBundler query = new StringBundler(4);
7207
7208 query.append(_FILTER_SQL_COUNT_ASSETCATEGORY_WHERE);
7209
7210 query.append(_FINDER_COLUMN_G_P_V_GROUPID_2);
7211
7212 query.append(_FINDER_COLUMN_G_P_V_PARENTCATEGORYID_2);
7213
7214 query.append(_FINDER_COLUMN_G_P_V_VOCABULARYID_2);
7215
7216 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
7217 AssetCategory.class.getName(),
7218 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
7219
7220 Session session = null;
7221
7222 try {
7223 session = openSession();
7224
7225 SQLQuery q = session.createSynchronizedSQLQuery(sql);
7226
7227 q.addScalar(COUNT_COLUMN_NAME,
7228 com.liferay.portal.kernel.dao.orm.Type.LONG);
7229
7230 QueryPos qPos = QueryPos.getInstance(q);
7231
7232 qPos.add(groupId);
7233
7234 qPos.add(parentCategoryId);
7235
7236 qPos.add(vocabularyId);
7237
7238 Long count = (Long)q.uniqueResult();
7239
7240 return count.intValue();
7241 }
7242 catch (Exception e) {
7243 throw processException(e);
7244 }
7245 finally {
7246 closeSession(session);
7247 }
7248 }
7249
7250 private static final String _FINDER_COLUMN_G_P_V_GROUPID_2 = "assetCategory.groupId = ? AND ";
7251 private static final String _FINDER_COLUMN_G_P_V_PARENTCATEGORYID_2 = "assetCategory.parentCategoryId = ? AND ";
7252 private static final String _FINDER_COLUMN_G_P_V_VOCABULARYID_2 = "assetCategory.vocabularyId = ?";
7253 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_LIKEN_V =
7254 new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
7255 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
7256 AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
7257 "findByG_LikeN_V",
7258 new String[] {
7259 Long.class.getName(), String.class.getName(),
7260 Long.class.getName(),
7261
7262 Integer.class.getName(), Integer.class.getName(),
7263 OrderByComparator.class.getName()
7264 });
7265 public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_LIKEN_V =
7266 new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
7267 AssetCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class,
7268 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_LikeN_V",
7269 new String[] {
7270 Long.class.getName(), String.class.getName(),
7271 Long.class.getName()
7272 });
7273
7274
7282 @Override
7283 public List<AssetCategory> findByG_LikeN_V(long groupId, String name,
7284 long vocabularyId) {
7285 return findByG_LikeN_V(groupId, name, vocabularyId, QueryUtil.ALL_POS,
7286 QueryUtil.ALL_POS, null);
7287 }
7288
7289
7303 @Override
7304 public List<AssetCategory> findByG_LikeN_V(long groupId, String name,
7305 long vocabularyId, int start, int end) {
7306 return findByG_LikeN_V(groupId, name, vocabularyId, start, end, null);
7307 }
7308
7309
7324 @Override
7325 public List<AssetCategory> findByG_LikeN_V(long groupId, String name,
7326 long vocabularyId, int start, int end,
7327 OrderByComparator<AssetCategory> orderByComparator) {
7328 boolean pagination = true;
7329 FinderPath finderPath = null;
7330 Object[] finderArgs = null;
7331
7332 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_LIKEN_V;
7333 finderArgs = new Object[] {
7334 groupId, name, vocabularyId,
7335
7336 start, end, orderByComparator
7337 };
7338
7339 List<AssetCategory> list = (List<AssetCategory>)FinderCacheUtil.getResult(finderPath,
7340 finderArgs, this);
7341
7342 if ((list != null) && !list.isEmpty()) {
7343 for (AssetCategory assetCategory : list) {
7344 if ((groupId != assetCategory.getGroupId()) ||
7345 !StringUtil.wildcardMatches(assetCategory.getName(),
7346 name, CharPool.UNDERLINE, CharPool.PERCENT,
7347 CharPool.BACK_SLASH, false) ||
7348 (vocabularyId != assetCategory.getVocabularyId())) {
7349 list = null;
7350
7351 break;
7352 }
7353 }
7354 }
7355
7356 if (list == null) {
7357 StringBundler query = null;
7358
7359 if (orderByComparator != null) {
7360 query = new StringBundler(5 +
7361 (orderByComparator.getOrderByFields().length * 3));
7362 }
7363 else {
7364 query = new StringBundler(5);
7365 }
7366
7367 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
7368
7369 query.append(_FINDER_COLUMN_G_LIKEN_V_GROUPID_2);
7370
7371 boolean bindName = false;
7372
7373 if (name == null) {
7374 query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_1);
7375 }
7376 else if (name.equals(StringPool.BLANK)) {
7377 query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_3);
7378 }
7379 else {
7380 bindName = true;
7381
7382 query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_2);
7383 }
7384
7385 query.append(_FINDER_COLUMN_G_LIKEN_V_VOCABULARYID_2);
7386
7387 if (orderByComparator != null) {
7388 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
7389 orderByComparator);
7390 }
7391 else
7392 if (pagination) {
7393 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
7394 }
7395
7396 String sql = query.toString();
7397
7398 Session session = null;
7399
7400 try {
7401 session = openSession();
7402
7403 Query q = session.createQuery(sql);
7404
7405 QueryPos qPos = QueryPos.getInstance(q);
7406
7407 qPos.add(groupId);
7408
7409 if (bindName) {
7410 qPos.add(StringUtil.toLowerCase(name));
7411 }
7412
7413 qPos.add(vocabularyId);
7414
7415 if (!pagination) {
7416 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
7417 start, end, false);
7418
7419 Collections.sort(list);
7420
7421 list = Collections.unmodifiableList(list);
7422 }
7423 else {
7424 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
7425 start, end);
7426 }
7427
7428 cacheResult(list);
7429
7430 FinderCacheUtil.putResult(finderPath, finderArgs, list);
7431 }
7432 catch (Exception e) {
7433 FinderCacheUtil.removeResult(finderPath, finderArgs);
7434
7435 throw processException(e);
7436 }
7437 finally {
7438 closeSession(session);
7439 }
7440 }
7441
7442 return list;
7443 }
7444
7445
7455 @Override
7456 public AssetCategory findByG_LikeN_V_First(long groupId, String name,
7457 long vocabularyId, OrderByComparator<AssetCategory> orderByComparator)
7458 throws NoSuchCategoryException {
7459 AssetCategory assetCategory = fetchByG_LikeN_V_First(groupId, name,
7460 vocabularyId, orderByComparator);
7461
7462 if (assetCategory != null) {
7463 return assetCategory;
7464 }
7465
7466 StringBundler msg = new StringBundler(8);
7467
7468 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
7469
7470 msg.append("groupId=");
7471 msg.append(groupId);
7472
7473 msg.append(", name=");
7474 msg.append(name);
7475
7476 msg.append(", vocabularyId=");
7477 msg.append(vocabularyId);
7478
7479 msg.append(StringPool.CLOSE_CURLY_BRACE);
7480
7481 throw new NoSuchCategoryException(msg.toString());
7482 }
7483
7484
7493 @Override
7494 public AssetCategory fetchByG_LikeN_V_First(long groupId, String name,
7495 long vocabularyId, OrderByComparator<AssetCategory> orderByComparator) {
7496 List<AssetCategory> list = findByG_LikeN_V(groupId, name, vocabularyId,
7497 0, 1, orderByComparator);
7498
7499 if (!list.isEmpty()) {
7500 return list.get(0);
7501 }
7502
7503 return null;
7504 }
7505
7506
7516 @Override
7517 public AssetCategory findByG_LikeN_V_Last(long groupId, String name,
7518 long vocabularyId, OrderByComparator<AssetCategory> orderByComparator)
7519 throws NoSuchCategoryException {
7520 AssetCategory assetCategory = fetchByG_LikeN_V_Last(groupId, name,
7521 vocabularyId, orderByComparator);
7522
7523 if (assetCategory != null) {
7524 return assetCategory;
7525 }
7526
7527 StringBundler msg = new StringBundler(8);
7528
7529 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
7530
7531 msg.append("groupId=");
7532 msg.append(groupId);
7533
7534 msg.append(", name=");
7535 msg.append(name);
7536
7537 msg.append(", vocabularyId=");
7538 msg.append(vocabularyId);
7539
7540 msg.append(StringPool.CLOSE_CURLY_BRACE);
7541
7542 throw new NoSuchCategoryException(msg.toString());
7543 }
7544
7545
7554 @Override
7555 public AssetCategory fetchByG_LikeN_V_Last(long groupId, String name,
7556 long vocabularyId, OrderByComparator<AssetCategory> orderByComparator) {
7557 int count = countByG_LikeN_V(groupId, name, vocabularyId);
7558
7559 if (count == 0) {
7560 return null;
7561 }
7562
7563 List<AssetCategory> list = findByG_LikeN_V(groupId, name, vocabularyId,
7564 count - 1, count, orderByComparator);
7565
7566 if (!list.isEmpty()) {
7567 return list.get(0);
7568 }
7569
7570 return null;
7571 }
7572
7573
7584 @Override
7585 public AssetCategory[] findByG_LikeN_V_PrevAndNext(long categoryId,
7586 long groupId, String name, long vocabularyId,
7587 OrderByComparator<AssetCategory> orderByComparator)
7588 throws NoSuchCategoryException {
7589 AssetCategory assetCategory = findByPrimaryKey(categoryId);
7590
7591 Session session = null;
7592
7593 try {
7594 session = openSession();
7595
7596 AssetCategory[] array = new AssetCategoryImpl[3];
7597
7598 array[0] = getByG_LikeN_V_PrevAndNext(session, assetCategory,
7599 groupId, name, vocabularyId, orderByComparator, true);
7600
7601 array[1] = assetCategory;
7602
7603 array[2] = getByG_LikeN_V_PrevAndNext(session, assetCategory,
7604 groupId, name, vocabularyId, orderByComparator, false);
7605
7606 return array;
7607 }
7608 catch (Exception e) {
7609 throw processException(e);
7610 }
7611 finally {
7612 closeSession(session);
7613 }
7614 }
7615
7616 protected AssetCategory getByG_LikeN_V_PrevAndNext(Session session,
7617 AssetCategory assetCategory, long groupId, String name,
7618 long vocabularyId, OrderByComparator<AssetCategory> orderByComparator,
7619 boolean previous) {
7620 StringBundler query = null;
7621
7622 if (orderByComparator != null) {
7623 query = new StringBundler(6 +
7624 (orderByComparator.getOrderByFields().length * 6));
7625 }
7626 else {
7627 query = new StringBundler(3);
7628 }
7629
7630 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
7631
7632 query.append(_FINDER_COLUMN_G_LIKEN_V_GROUPID_2);
7633
7634 boolean bindName = false;
7635
7636 if (name == null) {
7637 query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_1);
7638 }
7639 else if (name.equals(StringPool.BLANK)) {
7640 query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_3);
7641 }
7642 else {
7643 bindName = true;
7644
7645 query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_2);
7646 }
7647
7648 query.append(_FINDER_COLUMN_G_LIKEN_V_VOCABULARYID_2);
7649
7650 if (orderByComparator != null) {
7651 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
7652
7653 if (orderByConditionFields.length > 0) {
7654 query.append(WHERE_AND);
7655 }
7656
7657 for (int i = 0; i < orderByConditionFields.length; i++) {
7658 query.append(_ORDER_BY_ENTITY_ALIAS);
7659 query.append(orderByConditionFields[i]);
7660
7661 if ((i + 1) < orderByConditionFields.length) {
7662 if (orderByComparator.isAscending() ^ previous) {
7663 query.append(WHERE_GREATER_THAN_HAS_NEXT);
7664 }
7665 else {
7666 query.append(WHERE_LESSER_THAN_HAS_NEXT);
7667 }
7668 }
7669 else {
7670 if (orderByComparator.isAscending() ^ previous) {
7671 query.append(WHERE_GREATER_THAN);
7672 }
7673 else {
7674 query.append(WHERE_LESSER_THAN);
7675 }
7676 }
7677 }
7678
7679 query.append(ORDER_BY_CLAUSE);
7680
7681 String[] orderByFields = orderByComparator.getOrderByFields();
7682
7683 for (int i = 0; i < orderByFields.length; i++) {
7684 query.append(_ORDER_BY_ENTITY_ALIAS);
7685 query.append(orderByFields[i]);
7686
7687 if ((i + 1) < orderByFields.length) {
7688 if (orderByComparator.isAscending() ^ previous) {
7689 query.append(ORDER_BY_ASC_HAS_NEXT);
7690 }
7691 else {
7692 query.append(ORDER_BY_DESC_HAS_NEXT);
7693 }
7694 }
7695 else {
7696 if (orderByComparator.isAscending() ^ previous) {
7697 query.append(ORDER_BY_ASC);
7698 }
7699 else {
7700 query.append(ORDER_BY_DESC);
7701 }
7702 }
7703 }
7704 }
7705 else {
7706 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
7707 }
7708
7709 String sql = query.toString();
7710
7711 Query q = session.createQuery(sql);
7712
7713 q.setFirstResult(0);
7714 q.setMaxResults(2);
7715
7716 QueryPos qPos = QueryPos.getInstance(q);
7717
7718 qPos.add(groupId);
7719
7720 if (bindName) {
7721 qPos.add(StringUtil.toLowerCase(name));
7722 }
7723
7724 qPos.add(vocabularyId);
7725
7726 if (orderByComparator != null) {
7727 Object[] values = orderByComparator.getOrderByConditionValues(assetCategory);
7728
7729 for (Object value : values) {
7730 qPos.add(value);
7731 }
7732 }
7733
7734 List<AssetCategory> list = q.list();
7735
7736 if (list.size() == 2) {
7737 return list.get(1);
7738 }
7739 else {
7740 return null;
7741 }
7742 }
7743
7744
7752 @Override
7753 public List<AssetCategory> filterFindByG_LikeN_V(long groupId, String name,
7754 long vocabularyId) {
7755 return filterFindByG_LikeN_V(groupId, name, vocabularyId,
7756 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
7757 }
7758
7759
7773 @Override
7774 public List<AssetCategory> filterFindByG_LikeN_V(long groupId, String name,
7775 long vocabularyId, int start, int end) {
7776 return filterFindByG_LikeN_V(groupId, name, vocabularyId, start, end,
7777 null);
7778 }
7779
7780
7795 @Override
7796 public List<AssetCategory> filterFindByG_LikeN_V(long groupId, String name,
7797 long vocabularyId, int start, int end,
7798 OrderByComparator<AssetCategory> orderByComparator) {
7799 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
7800 return findByG_LikeN_V(groupId, name, vocabularyId, start, end,
7801 orderByComparator);
7802 }
7803
7804 StringBundler query = null;
7805
7806 if (orderByComparator != null) {
7807 query = new StringBundler(5 +
7808 (orderByComparator.getOrderByFields().length * 3));
7809 }
7810 else {
7811 query = new StringBundler(5);
7812 }
7813
7814 if (getDB().isSupportsInlineDistinct()) {
7815 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_WHERE);
7816 }
7817 else {
7818 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_1);
7819 }
7820
7821 query.append(_FINDER_COLUMN_G_LIKEN_V_GROUPID_2);
7822
7823 boolean bindName = false;
7824
7825 if (name == null) {
7826 query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_1);
7827 }
7828 else if (name.equals(StringPool.BLANK)) {
7829 query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_3);
7830 }
7831 else {
7832 bindName = true;
7833
7834 query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_2);
7835 }
7836
7837 query.append(_FINDER_COLUMN_G_LIKEN_V_VOCABULARYID_2);
7838
7839 if (!getDB().isSupportsInlineDistinct()) {
7840 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_2);
7841 }
7842
7843 if (orderByComparator != null) {
7844 if (getDB().isSupportsInlineDistinct()) {
7845 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
7846 orderByComparator, true);
7847 }
7848 else {
7849 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
7850 orderByComparator, true);
7851 }
7852 }
7853 else {
7854 if (getDB().isSupportsInlineDistinct()) {
7855 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
7856 }
7857 else {
7858 query.append(AssetCategoryModelImpl.ORDER_BY_SQL);
7859 }
7860 }
7861
7862 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
7863 AssetCategory.class.getName(),
7864 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
7865
7866 Session session = null;
7867
7868 try {
7869 session = openSession();
7870
7871 SQLQuery q = session.createSynchronizedSQLQuery(sql);
7872
7873 if (getDB().isSupportsInlineDistinct()) {
7874 q.addEntity(_FILTER_ENTITY_ALIAS, AssetCategoryImpl.class);
7875 }
7876 else {
7877 q.addEntity(_FILTER_ENTITY_TABLE, AssetCategoryImpl.class);
7878 }
7879
7880 QueryPos qPos = QueryPos.getInstance(q);
7881
7882 qPos.add(groupId);
7883
7884 if (bindName) {
7885 qPos.add(StringUtil.toLowerCase(name));
7886 }
7887
7888 qPos.add(vocabularyId);
7889
7890 return (List<AssetCategory>)QueryUtil.list(q, getDialect(), start,
7891 end);
7892 }
7893 catch (Exception e) {
7894 throw processException(e);
7895 }
7896 finally {
7897 closeSession(session);
7898 }
7899 }
7900
7901
7912 @Override
7913 public AssetCategory[] filterFindByG_LikeN_V_PrevAndNext(long categoryId,
7914 long groupId, String name, long vocabularyId,
7915 OrderByComparator<AssetCategory> orderByComparator)
7916 throws NoSuchCategoryException {
7917 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
7918 return findByG_LikeN_V_PrevAndNext(categoryId, groupId, name,
7919 vocabularyId, orderByComparator);
7920 }
7921
7922 AssetCategory assetCategory = findByPrimaryKey(categoryId);
7923
7924 Session session = null;
7925
7926 try {
7927 session = openSession();
7928
7929 AssetCategory[] array = new AssetCategoryImpl[3];
7930
7931 array[0] = filterGetByG_LikeN_V_PrevAndNext(session, assetCategory,
7932 groupId, name, vocabularyId, orderByComparator, true);
7933
7934 array[1] = assetCategory;
7935
7936 array[2] = filterGetByG_LikeN_V_PrevAndNext(session, assetCategory,
7937 groupId, name, vocabularyId, orderByComparator, false);
7938
7939 return array;
7940 }
7941 catch (Exception e) {
7942 throw processException(e);
7943 }
7944 finally {
7945 closeSession(session);
7946 }
7947 }
7948
7949 protected AssetCategory filterGetByG_LikeN_V_PrevAndNext(Session session,
7950 AssetCategory assetCategory, long groupId, String name,
7951 long vocabularyId, OrderByComparator<AssetCategory> orderByComparator,
7952 boolean previous) {
7953 StringBundler query = null;
7954
7955 if (orderByComparator != null) {
7956 query = new StringBundler(6 +
7957 (orderByComparator.getOrderByFields().length * 6));
7958 }
7959 else {
7960 query = new StringBundler(3);
7961 }
7962
7963 if (getDB().isSupportsInlineDistinct()) {
7964 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_WHERE);
7965 }
7966 else {
7967 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_1);
7968 }
7969
7970 query.append(_FINDER_COLUMN_G_LIKEN_V_GROUPID_2);
7971
7972 boolean bindName = false;
7973
7974 if (name == null) {
7975 query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_1);
7976 }
7977 else if (name.equals(StringPool.BLANK)) {
7978 query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_3);
7979 }
7980 else {
7981 bindName = true;
7982
7983 query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_2);
7984 }
7985
7986 query.append(_FINDER_COLUMN_G_LIKEN_V_VOCABULARYID_2);
7987
7988 if (!getDB().isSupportsInlineDistinct()) {
7989 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_2);
7990 }
7991
7992 if (orderByComparator != null) {
7993 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
7994
7995 if (orderByConditionFields.length > 0) {
7996 query.append(WHERE_AND);
7997 }
7998
7999 for (int i = 0; i < orderByConditionFields.length; i++) {
8000 if (getDB().isSupportsInlineDistinct()) {
8001 query.append(_ORDER_BY_ENTITY_ALIAS);
8002 }
8003 else {
8004 query.append(_ORDER_BY_ENTITY_TABLE);
8005 }
8006
8007 query.append(orderByConditionFields[i]);
8008
8009 if ((i + 1) < orderByConditionFields.length) {
8010 if (orderByComparator.isAscending() ^ previous) {
8011 query.append(WHERE_GREATER_THAN_HAS_NEXT);
8012 }
8013 else {
8014 query.append(WHERE_LESSER_THAN_HAS_NEXT);
8015 }
8016 }
8017 else {
8018 if (orderByComparator.isAscending() ^ previous) {
8019 query.append(WHERE_GREATER_THAN);
8020 }
8021 else {
8022 query.append(WHERE_LESSER_THAN);
8023 }
8024 }
8025 }
8026
8027 query.append(ORDER_BY_CLAUSE);
8028
8029 String[] orderByFields = orderByComparator.getOrderByFields();
8030
8031 for (int i = 0; i < orderByFields.length; i++) {
8032 if (getDB().isSupportsInlineDistinct()) {
8033 query.append(_ORDER_BY_ENTITY_ALIAS);
8034 }
8035 else {
8036 query.append(_ORDER_BY_ENTITY_TABLE);
8037 }
8038
8039 query.append(orderByFields[i]);
8040
8041 if ((i + 1) < orderByFields.length) {
8042 if (orderByComparator.isAscending() ^ previous) {
8043 query.append(ORDER_BY_ASC_HAS_NEXT);
8044 }
8045 else {
8046 query.append(ORDER_BY_DESC_HAS_NEXT);
8047 }
8048 }
8049 else {
8050 if (orderByComparator.isAscending() ^ previous) {
8051 query.append(ORDER_BY_ASC);
8052 }
8053 else {
8054 query.append(ORDER_BY_DESC);
8055 }
8056 }
8057 }
8058 }
8059 else {
8060 if (getDB().isSupportsInlineDistinct()) {
8061 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
8062 }
8063 else {
8064 query.append(AssetCategoryModelImpl.ORDER_BY_SQL);
8065 }
8066 }
8067
8068 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
8069 AssetCategory.class.getName(),
8070 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
8071
8072 SQLQuery q = session.createSynchronizedSQLQuery(sql);
8073
8074 q.setFirstResult(0);
8075 q.setMaxResults(2);
8076
8077 if (getDB().isSupportsInlineDistinct()) {
8078 q.addEntity(_FILTER_ENTITY_ALIAS, AssetCategoryImpl.class);
8079 }
8080 else {
8081 q.addEntity(_FILTER_ENTITY_TABLE, AssetCategoryImpl.class);
8082 }
8083
8084 QueryPos qPos = QueryPos.getInstance(q);
8085
8086 qPos.add(groupId);
8087
8088 if (bindName) {
8089 qPos.add(StringUtil.toLowerCase(name));
8090 }
8091
8092 qPos.add(vocabularyId);
8093
8094 if (orderByComparator != null) {
8095 Object[] values = orderByComparator.getOrderByConditionValues(assetCategory);
8096
8097 for (Object value : values) {
8098 qPos.add(value);
8099 }
8100 }
8101
8102 List<AssetCategory> list = q.list();
8103
8104 if (list.size() == 2) {
8105 return list.get(1);
8106 }
8107 else {
8108 return null;
8109 }
8110 }
8111
8112
8120 @Override
8121 public List<AssetCategory> filterFindByG_LikeN_V(long groupId, String name,
8122 long[] vocabularyIds) {
8123 return filterFindByG_LikeN_V(groupId, name, vocabularyIds,
8124 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
8125 }
8126
8127
8141 @Override
8142 public List<AssetCategory> filterFindByG_LikeN_V(long groupId, String name,
8143 long[] vocabularyIds, int start, int end) {
8144 return filterFindByG_LikeN_V(groupId, name, vocabularyIds, start, end,
8145 null);
8146 }
8147
8148
8163 @Override
8164 public List<AssetCategory> filterFindByG_LikeN_V(long groupId, String name,
8165 long[] vocabularyIds, int start, int end,
8166 OrderByComparator<AssetCategory> orderByComparator) {
8167 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
8168 return findByG_LikeN_V(groupId, name, vocabularyIds, start, end,
8169 orderByComparator);
8170 }
8171
8172 if (vocabularyIds == null) {
8173 vocabularyIds = new long[0];
8174 }
8175 else {
8176 vocabularyIds = ArrayUtil.unique(vocabularyIds);
8177 }
8178
8179 StringBundler query = new StringBundler();
8180
8181 if (getDB().isSupportsInlineDistinct()) {
8182 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_WHERE);
8183 }
8184 else {
8185 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_1);
8186 }
8187
8188 query.append(_FINDER_COLUMN_G_LIKEN_V_GROUPID_2);
8189
8190 boolean bindName = false;
8191
8192 if (name == null) {
8193 query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_1);
8194 }
8195 else if (name.equals(StringPool.BLANK)) {
8196 query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_3);
8197 }
8198 else {
8199 bindName = true;
8200
8201 query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_2);
8202 }
8203
8204 if (vocabularyIds.length > 0) {
8205 query.append(StringPool.OPEN_PARENTHESIS);
8206
8207 query.append(_FINDER_COLUMN_G_LIKEN_V_VOCABULARYID_7);
8208
8209 query.append(StringUtil.merge(vocabularyIds));
8210
8211 query.append(StringPool.CLOSE_PARENTHESIS);
8212
8213 query.append(StringPool.CLOSE_PARENTHESIS);
8214 }
8215
8216 query.setStringAt(removeConjunction(query.stringAt(query.index() - 1)),
8217 query.index() - 1);
8218
8219 if (!getDB().isSupportsInlineDistinct()) {
8220 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_2);
8221 }
8222
8223 if (orderByComparator != null) {
8224 if (getDB().isSupportsInlineDistinct()) {
8225 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
8226 orderByComparator, true);
8227 }
8228 else {
8229 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
8230 orderByComparator, true);
8231 }
8232 }
8233 else {
8234 if (getDB().isSupportsInlineDistinct()) {
8235 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
8236 }
8237 else {
8238 query.append(AssetCategoryModelImpl.ORDER_BY_SQL);
8239 }
8240 }
8241
8242 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
8243 AssetCategory.class.getName(),
8244 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
8245
8246 Session session = null;
8247
8248 try {
8249 session = openSession();
8250
8251 SQLQuery q = session.createSynchronizedSQLQuery(sql);
8252
8253 if (getDB().isSupportsInlineDistinct()) {
8254 q.addEntity(_FILTER_ENTITY_ALIAS, AssetCategoryImpl.class);
8255 }
8256 else {
8257 q.addEntity(_FILTER_ENTITY_TABLE, AssetCategoryImpl.class);
8258 }
8259
8260 QueryPos qPos = QueryPos.getInstance(q);
8261
8262 qPos.add(groupId);
8263
8264 if (bindName) {
8265 qPos.add(StringUtil.toLowerCase(name));
8266 }
8267
8268 return (List<AssetCategory>)QueryUtil.list(q, getDialect(), start,
8269 end);
8270 }
8271 catch (Exception e) {
8272 throw processException(e);
8273 }
8274 finally {
8275 closeSession(session);
8276 }
8277 }
8278
8279
8291 @Override
8292 public List<AssetCategory> findByG_LikeN_V(long groupId, String name,
8293 long[] vocabularyIds) {
8294 return findByG_LikeN_V(groupId, name, vocabularyIds, QueryUtil.ALL_POS,
8295 QueryUtil.ALL_POS, null);
8296 }
8297
8298
8312 @Override
8313 public List<AssetCategory> findByG_LikeN_V(long groupId, String name,
8314 long[] vocabularyIds, int start, int end) {
8315 return findByG_LikeN_V(groupId, name, vocabularyIds, start, end, null);
8316 }
8317
8318
8333 @Override
8334 public List<AssetCategory> findByG_LikeN_V(long groupId, String name,
8335 long[] vocabularyIds, int start, int end,
8336 OrderByComparator<AssetCategory> orderByComparator) {
8337 if (vocabularyIds == null) {
8338 vocabularyIds = new long[0];
8339 }
8340 else {
8341 vocabularyIds = ArrayUtil.unique(vocabularyIds);
8342 }
8343
8344 if (vocabularyIds.length == 1) {
8345 return findByG_LikeN_V(groupId, name, vocabularyIds[0], start, end,
8346 orderByComparator);
8347 }
8348
8349 boolean pagination = true;
8350 Object[] finderArgs = null;
8351
8352 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
8353 (orderByComparator == null)) {
8354 pagination = false;
8355 finderArgs = new Object[] {
8356 groupId, name, StringUtil.merge(vocabularyIds)
8357 };
8358 }
8359 else {
8360 finderArgs = new Object[] {
8361 groupId, name, StringUtil.merge(vocabularyIds),
8362
8363 start, end, orderByComparator
8364 };
8365 }
8366
8367 List<AssetCategory> list = (List<AssetCategory>)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_LIKEN_V,
8368 finderArgs, this);
8369
8370 if ((list != null) && !list.isEmpty()) {
8371 for (AssetCategory assetCategory : list) {
8372 if ((groupId != assetCategory.getGroupId()) ||
8373 !Validator.equals(name, assetCategory.getName()) ||
8374 !ArrayUtil.contains(vocabularyIds,
8375 assetCategory.getVocabularyId())) {
8376 list = null;
8377
8378 break;
8379 }
8380 }
8381 }
8382
8383 if (list == null) {
8384 StringBundler query = new StringBundler();
8385
8386 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
8387
8388 query.append(_FINDER_COLUMN_G_LIKEN_V_GROUPID_2);
8389
8390 boolean bindName = false;
8391
8392 if (name == null) {
8393 query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_1);
8394 }
8395 else if (name.equals(StringPool.BLANK)) {
8396 query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_3);
8397 }
8398 else {
8399 bindName = true;
8400
8401 query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_2);
8402 }
8403
8404 if (vocabularyIds.length > 0) {
8405 query.append(StringPool.OPEN_PARENTHESIS);
8406
8407 query.append(_FINDER_COLUMN_G_LIKEN_V_VOCABULARYID_7);
8408
8409 query.append(StringUtil.merge(vocabularyIds));
8410
8411 query.append(StringPool.CLOSE_PARENTHESIS);
8412
8413 query.append(StringPool.CLOSE_PARENTHESIS);
8414 }
8415
8416 query.setStringAt(removeConjunction(query.stringAt(query.index() -
8417 1)), query.index() - 1);
8418
8419 if (orderByComparator != null) {
8420 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
8421 orderByComparator);
8422 }
8423 else
8424 if (pagination) {
8425 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
8426 }
8427
8428 String sql = query.toString();
8429
8430 Session session = null;
8431
8432 try {
8433 session = openSession();
8434
8435 Query q = session.createQuery(sql);
8436
8437 QueryPos qPos = QueryPos.getInstance(q);
8438
8439 qPos.add(groupId);
8440
8441 if (bindName) {
8442 qPos.add(StringUtil.toLowerCase(name));
8443 }
8444
8445 if (!pagination) {
8446 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
8447 start, end, false);
8448
8449 Collections.sort(list);
8450
8451 list = Collections.unmodifiableList(list);
8452 }
8453 else {
8454 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
8455 start, end);
8456 }
8457
8458 cacheResult(list);
8459
8460 FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_LIKEN_V,
8461 finderArgs, list);
8462 }
8463 catch (Exception e) {
8464 FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_LIKEN_V,
8465 finderArgs);
8466
8467 throw processException(e);
8468 }
8469 finally {
8470 closeSession(session);
8471 }
8472 }
8473
8474 return list;
8475 }
8476
8477
8484 @Override
8485 public void removeByG_LikeN_V(long groupId, String name, long vocabularyId) {
8486 for (AssetCategory assetCategory : findByG_LikeN_V(groupId, name,
8487 vocabularyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
8488 remove(assetCategory);
8489 }
8490 }
8491
8492
8500 @Override
8501 public int countByG_LikeN_V(long groupId, String name, long vocabularyId) {
8502 FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_LIKEN_V;
8503
8504 Object[] finderArgs = new Object[] { groupId, name, vocabularyId };
8505
8506 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
8507 this);
8508
8509 if (count == null) {
8510 StringBundler query = new StringBundler(4);
8511
8512 query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
8513
8514 query.append(_FINDER_COLUMN_G_LIKEN_V_GROUPID_2);
8515
8516 boolean bindName = false;
8517
8518 if (name == null) {
8519 query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_1);
8520 }
8521 else if (name.equals(StringPool.BLANK)) {
8522 query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_3);
8523 }
8524 else {
8525 bindName = true;
8526
8527 query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_2);
8528 }
8529
8530 query.append(_FINDER_COLUMN_G_LIKEN_V_VOCABULARYID_2);
8531
8532 String sql = query.toString();
8533
8534 Session session = null;
8535
8536 try {
8537 session = openSession();
8538
8539 Query q = session.createQuery(sql);
8540
8541 QueryPos qPos = QueryPos.getInstance(q);
8542
8543 qPos.add(groupId);
8544
8545 if (bindName) {
8546 qPos.add(StringUtil.toLowerCase(name));
8547 }
8548
8549 qPos.add(vocabularyId);
8550
8551 count = (Long)q.uniqueResult();
8552
8553 FinderCacheUtil.putResult(finderPath, finderArgs, count);
8554 }
8555 catch (Exception e) {
8556 FinderCacheUtil.removeResult(finderPath, finderArgs);
8557
8558 throw processException(e);
8559 }
8560 finally {
8561 closeSession(session);
8562 }
8563 }
8564
8565 return count.intValue();
8566 }
8567
8568
8576 @Override
8577 public int countByG_LikeN_V(long groupId, String name, long[] vocabularyIds) {
8578 if (vocabularyIds == null) {
8579 vocabularyIds = new long[0];
8580 }
8581 else {
8582 vocabularyIds = ArrayUtil.unique(vocabularyIds);
8583 }
8584
8585 Object[] finderArgs = new Object[] {
8586 groupId, name, StringUtil.merge(vocabularyIds)
8587 };
8588
8589 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_LIKEN_V,
8590 finderArgs, this);
8591
8592 if (count == null) {
8593 StringBundler query = new StringBundler();
8594
8595 query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
8596
8597 query.append(_FINDER_COLUMN_G_LIKEN_V_GROUPID_2);
8598
8599 boolean bindName = false;
8600
8601 if (name == null) {
8602 query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_1);
8603 }
8604 else if (name.equals(StringPool.BLANK)) {
8605 query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_3);
8606 }
8607 else {
8608 bindName = true;
8609
8610 query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_2);
8611 }
8612
8613 if (vocabularyIds.length > 0) {
8614 query.append(StringPool.OPEN_PARENTHESIS);
8615
8616 query.append(_FINDER_COLUMN_G_LIKEN_V_VOCABULARYID_7);
8617
8618 query.append(StringUtil.merge(vocabularyIds));
8619
8620 query.append(StringPool.CLOSE_PARENTHESIS);
8621
8622 query.append(StringPool.CLOSE_PARENTHESIS);
8623 }
8624
8625 query.setStringAt(removeConjunction(query.stringAt(query.index() -
8626 1)), query.index() - 1);
8627
8628 String sql = query.toString();
8629
8630 Session session = null;
8631
8632 try {
8633 session = openSession();
8634
8635 Query q = session.createQuery(sql);
8636
8637 QueryPos qPos = QueryPos.getInstance(q);
8638
8639 qPos.add(groupId);
8640
8641 if (bindName) {
8642 qPos.add(StringUtil.toLowerCase(name));
8643 }
8644
8645 count = (Long)q.uniqueResult();
8646
8647 FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_LIKEN_V,
8648 finderArgs, count);
8649 }
8650 catch (Exception e) {
8651 FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_LIKEN_V,
8652 finderArgs);
8653
8654 throw processException(e);
8655 }
8656 finally {
8657 closeSession(session);
8658 }
8659 }
8660
8661 return count.intValue();
8662 }
8663
8664
8672 @Override
8673 public int filterCountByG_LikeN_V(long groupId, String name,
8674 long vocabularyId) {
8675 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
8676 return countByG_LikeN_V(groupId, name, vocabularyId);
8677 }
8678
8679 StringBundler query = new StringBundler(4);
8680
8681 query.append(_FILTER_SQL_COUNT_ASSETCATEGORY_WHERE);
8682
8683 query.append(_FINDER_COLUMN_G_LIKEN_V_GROUPID_2);
8684
8685 boolean bindName = false;
8686
8687 if (name == null) {
8688 query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_1);
8689 }
8690 else if (name.equals(StringPool.BLANK)) {
8691 query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_3);
8692 }
8693 else {
8694 bindName = true;
8695
8696 query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_2);
8697 }
8698
8699 query.append(_FINDER_COLUMN_G_LIKEN_V_VOCABULARYID_2);
8700
8701 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
8702 AssetCategory.class.getName(),
8703 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
8704
8705 Session session = null;
8706
8707 try {
8708 session = openSession();
8709
8710 SQLQuery q = session.createSynchronizedSQLQuery(sql);
8711
8712 q.addScalar(COUNT_COLUMN_NAME,
8713 com.liferay.portal.kernel.dao.orm.Type.LONG);
8714
8715 QueryPos qPos = QueryPos.getInstance(q);
8716
8717 qPos.add(groupId);
8718
8719 if (bindName) {
8720 qPos.add(StringUtil.toLowerCase(name));
8721 }
8722
8723 qPos.add(vocabularyId);
8724
8725 Long count = (Long)q.uniqueResult();
8726
8727 return count.intValue();
8728 }
8729 catch (Exception e) {
8730 throw processException(e);
8731 }
8732 finally {
8733 closeSession(session);
8734 }
8735 }
8736
8737
8745 @Override
8746 public int filterCountByG_LikeN_V(long groupId, String name,
8747 long[] vocabularyIds) {
8748 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
8749 return countByG_LikeN_V(groupId, name, vocabularyIds);
8750 }
8751
8752 if (vocabularyIds == null) {
8753 vocabularyIds = new long[0];
8754 }
8755 else {
8756 vocabularyIds = ArrayUtil.unique(vocabularyIds);
8757 }
8758
8759 StringBundler query = new StringBundler();
8760
8761 query.append(_FILTER_SQL_COUNT_ASSETCATEGORY_WHERE);
8762
8763 query.append(_FINDER_COLUMN_G_LIKEN_V_GROUPID_2);
8764
8765 boolean bindName = false;
8766
8767 if (name == null) {
8768 query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_1);
8769 }
8770 else if (name.equals(StringPool.BLANK)) {
8771 query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_3);
8772 }
8773 else {
8774 bindName = true;
8775
8776 query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_2);
8777 }
8778
8779 if (vocabularyIds.length > 0) {
8780 query.append(StringPool.OPEN_PARENTHESIS);
8781
8782 query.append(_FINDER_COLUMN_G_LIKEN_V_VOCABULARYID_7);
8783
8784 query.append(StringUtil.merge(vocabularyIds));
8785
8786 query.append(StringPool.CLOSE_PARENTHESIS);
8787
8788 query.append(StringPool.CLOSE_PARENTHESIS);
8789 }
8790
8791 query.setStringAt(removeConjunction(query.stringAt(query.index() - 1)),
8792 query.index() - 1);
8793
8794 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
8795 AssetCategory.class.getName(),
8796 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
8797
8798 Session session = null;
8799
8800 try {
8801 session = openSession();
8802
8803 SQLQuery q = session.createSynchronizedSQLQuery(sql);
8804
8805 q.addScalar(COUNT_COLUMN_NAME,
8806 com.liferay.portal.kernel.dao.orm.Type.LONG);
8807
8808 QueryPos qPos = QueryPos.getInstance(q);
8809
8810 qPos.add(groupId);
8811
8812 if (bindName) {
8813 qPos.add(StringUtil.toLowerCase(name));
8814 }
8815
8816 Long count = (Long)q.uniqueResult();
8817
8818 return count.intValue();
8819 }
8820 catch (Exception e) {
8821 throw processException(e);
8822 }
8823 finally {
8824 closeSession(session);
8825 }
8826 }
8827
8828 private static final String _FINDER_COLUMN_G_LIKEN_V_GROUPID_2 = "assetCategory.groupId = ? AND ";
8829 private static final String _FINDER_COLUMN_G_LIKEN_V_NAME_1 = "assetCategory.name LIKE NULL AND ";
8830 private static final String _FINDER_COLUMN_G_LIKEN_V_NAME_2 = "lower(assetCategory.name) LIKE ? AND ";
8831 private static final String _FINDER_COLUMN_G_LIKEN_V_NAME_3 = "(assetCategory.name IS NULL OR assetCategory.name LIKE '') AND ";
8832 private static final String _FINDER_COLUMN_G_LIKEN_V_VOCABULARYID_2 = "assetCategory.vocabularyId = ?";
8833 private static final String _FINDER_COLUMN_G_LIKEN_V_VOCABULARYID_7 = "assetCategory.vocabularyId IN (";
8834 public static final FinderPath FINDER_PATH_FETCH_BY_P_N_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
8835 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
8836 AssetCategoryImpl.class, FINDER_CLASS_NAME_ENTITY, "fetchByP_N_V",
8837 new String[] {
8838 Long.class.getName(), String.class.getName(),
8839 Long.class.getName()
8840 },
8841 AssetCategoryModelImpl.PARENTCATEGORYID_COLUMN_BITMASK |
8842 AssetCategoryModelImpl.NAME_COLUMN_BITMASK |
8843 AssetCategoryModelImpl.VOCABULARYID_COLUMN_BITMASK);
8844 public static final FinderPath FINDER_PATH_COUNT_BY_P_N_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
8845 AssetCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class,
8846 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByP_N_V",
8847 new String[] {
8848 Long.class.getName(), String.class.getName(),
8849 Long.class.getName()
8850 });
8851
8852
8861 @Override
8862 public AssetCategory findByP_N_V(long parentCategoryId, String name,
8863 long vocabularyId) throws NoSuchCategoryException {
8864 AssetCategory assetCategory = fetchByP_N_V(parentCategoryId, name,
8865 vocabularyId);
8866
8867 if (assetCategory == null) {
8868 StringBundler msg = new StringBundler(8);
8869
8870 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
8871
8872 msg.append("parentCategoryId=");
8873 msg.append(parentCategoryId);
8874
8875 msg.append(", name=");
8876 msg.append(name);
8877
8878 msg.append(", vocabularyId=");
8879 msg.append(vocabularyId);
8880
8881 msg.append(StringPool.CLOSE_CURLY_BRACE);
8882
8883 if (_log.isWarnEnabled()) {
8884 _log.warn(msg.toString());
8885 }
8886
8887 throw new NoSuchCategoryException(msg.toString());
8888 }
8889
8890 return assetCategory;
8891 }
8892
8893
8901 @Override
8902 public AssetCategory fetchByP_N_V(long parentCategoryId, String name,
8903 long vocabularyId) {
8904 return fetchByP_N_V(parentCategoryId, name, vocabularyId, true);
8905 }
8906
8907
8916 @Override
8917 public AssetCategory fetchByP_N_V(long parentCategoryId, String name,
8918 long vocabularyId, boolean retrieveFromCache) {
8919 Object[] finderArgs = new Object[] { parentCategoryId, name, vocabularyId };
8920
8921 Object result = null;
8922
8923 if (retrieveFromCache) {
8924 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_P_N_V,
8925 finderArgs, this);
8926 }
8927
8928 if (result instanceof AssetCategory) {
8929 AssetCategory assetCategory = (AssetCategory)result;
8930
8931 if ((parentCategoryId != assetCategory.getParentCategoryId()) ||
8932 !Validator.equals(name, assetCategory.getName()) ||
8933 (vocabularyId != assetCategory.getVocabularyId())) {
8934 result = null;
8935 }
8936 }
8937
8938 if (result == null) {
8939 StringBundler query = new StringBundler(5);
8940
8941 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
8942
8943 query.append(_FINDER_COLUMN_P_N_V_PARENTCATEGORYID_2);
8944
8945 boolean bindName = false;
8946
8947 if (name == null) {
8948 query.append(_FINDER_COLUMN_P_N_V_NAME_1);
8949 }
8950 else if (name.equals(StringPool.BLANK)) {
8951 query.append(_FINDER_COLUMN_P_N_V_NAME_3);
8952 }
8953 else {
8954 bindName = true;
8955
8956 query.append(_FINDER_COLUMN_P_N_V_NAME_2);
8957 }
8958
8959 query.append(_FINDER_COLUMN_P_N_V_VOCABULARYID_2);
8960
8961 String sql = query.toString();
8962
8963 Session session = null;
8964
8965 try {
8966 session = openSession();
8967
8968 Query q = session.createQuery(sql);
8969
8970 QueryPos qPos = QueryPos.getInstance(q);
8971
8972 qPos.add(parentCategoryId);
8973
8974 if (bindName) {
8975 qPos.add(name);
8976 }
8977
8978 qPos.add(vocabularyId);
8979
8980 List<AssetCategory> list = q.list();
8981
8982 if (list.isEmpty()) {
8983 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_P_N_V,
8984 finderArgs, list);
8985 }
8986 else {
8987 AssetCategory assetCategory = list.get(0);
8988
8989 result = assetCategory;
8990
8991 cacheResult(assetCategory);
8992
8993 if ((assetCategory.getParentCategoryId() != parentCategoryId) ||
8994 (assetCategory.getName() == null) ||
8995 !assetCategory.getName().equals(name) ||
8996 (assetCategory.getVocabularyId() != vocabularyId)) {
8997 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_P_N_V,
8998 finderArgs, assetCategory);
8999 }
9000 }
9001 }
9002 catch (Exception e) {
9003 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_P_N_V,
9004 finderArgs);
9005
9006 throw processException(e);
9007 }
9008 finally {
9009 closeSession(session);
9010 }
9011 }
9012
9013 if (result instanceof List<?>) {
9014 return null;
9015 }
9016 else {
9017 return (AssetCategory)result;
9018 }
9019 }
9020
9021
9029 @Override
9030 public AssetCategory removeByP_N_V(long parentCategoryId, String name,
9031 long vocabularyId) throws NoSuchCategoryException {
9032 AssetCategory assetCategory = findByP_N_V(parentCategoryId, name,
9033 vocabularyId);
9034
9035 return remove(assetCategory);
9036 }
9037
9038
9046 @Override
9047 public int countByP_N_V(long parentCategoryId, String name,
9048 long vocabularyId) {
9049 FinderPath finderPath = FINDER_PATH_COUNT_BY_P_N_V;
9050
9051 Object[] finderArgs = new Object[] { parentCategoryId, name, vocabularyId };
9052
9053 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
9054 this);
9055
9056 if (count == null) {
9057 StringBundler query = new StringBundler(4);
9058
9059 query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
9060
9061 query.append(_FINDER_COLUMN_P_N_V_PARENTCATEGORYID_2);
9062
9063 boolean bindName = false;
9064
9065 if (name == null) {
9066 query.append(_FINDER_COLUMN_P_N_V_NAME_1);
9067 }
9068 else if (name.equals(StringPool.BLANK)) {
9069 query.append(_FINDER_COLUMN_P_N_V_NAME_3);
9070 }
9071 else {
9072 bindName = true;
9073
9074 query.append(_FINDER_COLUMN_P_N_V_NAME_2);
9075 }
9076
9077 query.append(_FINDER_COLUMN_P_N_V_VOCABULARYID_2);
9078
9079 String sql = query.toString();
9080
9081 Session session = null;
9082
9083 try {
9084 session = openSession();
9085
9086 Query q = session.createQuery(sql);
9087
9088 QueryPos qPos = QueryPos.getInstance(q);
9089
9090 qPos.add(parentCategoryId);
9091
9092 if (bindName) {
9093 qPos.add(name);
9094 }
9095
9096 qPos.add(vocabularyId);
9097
9098 count = (Long)q.uniqueResult();
9099
9100 FinderCacheUtil.putResult(finderPath, finderArgs, count);
9101 }
9102 catch (Exception e) {
9103 FinderCacheUtil.removeResult(finderPath, finderArgs);
9104
9105 throw processException(e);
9106 }
9107 finally {
9108 closeSession(session);
9109 }
9110 }
9111
9112 return count.intValue();
9113 }
9114
9115 private static final String _FINDER_COLUMN_P_N_V_PARENTCATEGORYID_2 = "assetCategory.parentCategoryId = ? AND ";
9116 private static final String _FINDER_COLUMN_P_N_V_NAME_1 = "assetCategory.name IS NULL AND ";
9117 private static final String _FINDER_COLUMN_P_N_V_NAME_2 = "assetCategory.name = ? AND ";
9118 private static final String _FINDER_COLUMN_P_N_V_NAME_3 = "(assetCategory.name IS NULL OR assetCategory.name = '') AND ";
9119 private static final String _FINDER_COLUMN_P_N_V_VOCABULARYID_2 = "assetCategory.vocabularyId = ?";
9120 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_P_N_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
9121 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
9122 AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
9123 "findByG_P_N_V",
9124 new String[] {
9125 Long.class.getName(), Long.class.getName(),
9126 String.class.getName(), Long.class.getName(),
9127
9128 Integer.class.getName(), Integer.class.getName(),
9129 OrderByComparator.class.getName()
9130 });
9131 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_N_V =
9132 new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
9133 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
9134 AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
9135 "findByG_P_N_V",
9136 new String[] {
9137 Long.class.getName(), Long.class.getName(),
9138 String.class.getName(), Long.class.getName()
9139 },
9140 AssetCategoryModelImpl.GROUPID_COLUMN_BITMASK |
9141 AssetCategoryModelImpl.PARENTCATEGORYID_COLUMN_BITMASK |
9142 AssetCategoryModelImpl.NAME_COLUMN_BITMASK |
9143 AssetCategoryModelImpl.VOCABULARYID_COLUMN_BITMASK);
9144 public static final FinderPath FINDER_PATH_COUNT_BY_G_P_N_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
9145 AssetCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class,
9146 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_P_N_V",
9147 new String[] {
9148 Long.class.getName(), Long.class.getName(),
9149 String.class.getName(), Long.class.getName()
9150 });
9151
9152
9161 @Override
9162 public List<AssetCategory> findByG_P_N_V(long groupId,
9163 long parentCategoryId, String name, long vocabularyId) {
9164 return findByG_P_N_V(groupId, parentCategoryId, name, vocabularyId,
9165 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
9166 }
9167
9168
9183 @Override
9184 public List<AssetCategory> findByG_P_N_V(long groupId,
9185 long parentCategoryId, String name, long vocabularyId, int start,
9186 int end) {
9187 return findByG_P_N_V(groupId, parentCategoryId, name, vocabularyId,
9188 start, end, null);
9189 }
9190
9191
9207 @Override
9208 public List<AssetCategory> findByG_P_N_V(long groupId,
9209 long parentCategoryId, String name, long vocabularyId, int start,
9210 int end, OrderByComparator<AssetCategory> orderByComparator) {
9211 boolean pagination = true;
9212 FinderPath finderPath = null;
9213 Object[] finderArgs = null;
9214
9215 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
9216 (orderByComparator == null)) {
9217 pagination = false;
9218 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_N_V;
9219 finderArgs = new Object[] {
9220 groupId, parentCategoryId, name, vocabularyId
9221 };
9222 }
9223 else {
9224 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_P_N_V;
9225 finderArgs = new Object[] {
9226 groupId, parentCategoryId, name, vocabularyId,
9227
9228 start, end, orderByComparator
9229 };
9230 }
9231
9232 List<AssetCategory> list = (List<AssetCategory>)FinderCacheUtil.getResult(finderPath,
9233 finderArgs, this);
9234
9235 if ((list != null) && !list.isEmpty()) {
9236 for (AssetCategory assetCategory : list) {
9237 if ((groupId != assetCategory.getGroupId()) ||
9238 (parentCategoryId != assetCategory.getParentCategoryId()) ||
9239 !Validator.equals(name, assetCategory.getName()) ||
9240 (vocabularyId != assetCategory.getVocabularyId())) {
9241 list = null;
9242
9243 break;
9244 }
9245 }
9246 }
9247
9248 if (list == null) {
9249 StringBundler query = null;
9250
9251 if (orderByComparator != null) {
9252 query = new StringBundler(6 +
9253 (orderByComparator.getOrderByFields().length * 3));
9254 }
9255 else {
9256 query = new StringBundler(6);
9257 }
9258
9259 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
9260
9261 query.append(_FINDER_COLUMN_G_P_N_V_GROUPID_2);
9262
9263 query.append(_FINDER_COLUMN_G_P_N_V_PARENTCATEGORYID_2);
9264
9265 boolean bindName = false;
9266
9267 if (name == null) {
9268 query.append(_FINDER_COLUMN_G_P_N_V_NAME_1);
9269 }
9270 else if (name.equals(StringPool.BLANK)) {
9271 query.append(_FINDER_COLUMN_G_P_N_V_NAME_3);
9272 }
9273 else {
9274 bindName = true;
9275
9276 query.append(_FINDER_COLUMN_G_P_N_V_NAME_2);
9277 }
9278
9279 query.append(_FINDER_COLUMN_G_P_N_V_VOCABULARYID_2);
9280
9281 if (orderByComparator != null) {
9282 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
9283 orderByComparator);
9284 }
9285 else
9286 if (pagination) {
9287 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
9288 }
9289
9290 String sql = query.toString();
9291
9292 Session session = null;
9293
9294 try {
9295 session = openSession();
9296
9297 Query q = session.createQuery(sql);
9298
9299 QueryPos qPos = QueryPos.getInstance(q);
9300
9301 qPos.add(groupId);
9302
9303 qPos.add(parentCategoryId);
9304
9305 if (bindName) {
9306 qPos.add(name);
9307 }
9308
9309 qPos.add(vocabularyId);
9310
9311 if (!pagination) {
9312 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
9313 start, end, false);
9314
9315 Collections.sort(list);
9316
9317 list = Collections.unmodifiableList(list);
9318 }
9319 else {
9320 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
9321 start, end);
9322 }
9323
9324 cacheResult(list);
9325
9326 FinderCacheUtil.putResult(finderPath, finderArgs, list);
9327 }
9328 catch (Exception e) {
9329 FinderCacheUtil.removeResult(finderPath, finderArgs);
9330
9331 throw processException(e);
9332 }
9333 finally {
9334 closeSession(session);
9335 }
9336 }
9337
9338 return list;
9339 }
9340
9341
9352 @Override
9353 public AssetCategory findByG_P_N_V_First(long groupId,
9354 long parentCategoryId, String name, long vocabularyId,
9355 OrderByComparator<AssetCategory> orderByComparator)
9356 throws NoSuchCategoryException {
9357 AssetCategory assetCategory = fetchByG_P_N_V_First(groupId,
9358 parentCategoryId, name, vocabularyId, orderByComparator);
9359
9360 if (assetCategory != null) {
9361 return assetCategory;
9362 }
9363
9364 StringBundler msg = new StringBundler(10);
9365
9366 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
9367
9368 msg.append("groupId=");
9369 msg.append(groupId);
9370
9371 msg.append(", parentCategoryId=");
9372 msg.append(parentCategoryId);
9373
9374 msg.append(", name=");
9375 msg.append(name);
9376
9377 msg.append(", vocabularyId=");
9378 msg.append(vocabularyId);
9379
9380 msg.append(StringPool.CLOSE_CURLY_BRACE);
9381
9382 throw new NoSuchCategoryException(msg.toString());
9383 }
9384
9385
9395 @Override
9396 public AssetCategory fetchByG_P_N_V_First(long groupId,
9397 long parentCategoryId, String name, long vocabularyId,
9398 OrderByComparator<AssetCategory> orderByComparator) {
9399 List<AssetCategory> list = findByG_P_N_V(groupId, parentCategoryId,
9400 name, vocabularyId, 0, 1, orderByComparator);
9401
9402 if (!list.isEmpty()) {
9403 return list.get(0);
9404 }
9405
9406 return null;
9407 }
9408
9409
9420 @Override
9421 public AssetCategory findByG_P_N_V_Last(long groupId,
9422 long parentCategoryId, String name, long vocabularyId,
9423 OrderByComparator<AssetCategory> orderByComparator)
9424 throws NoSuchCategoryException {
9425 AssetCategory assetCategory = fetchByG_P_N_V_Last(groupId,
9426 parentCategoryId, name, vocabularyId, orderByComparator);
9427
9428 if (assetCategory != null) {
9429 return assetCategory;
9430 }
9431
9432 StringBundler msg = new StringBundler(10);
9433
9434 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
9435
9436 msg.append("groupId=");
9437 msg.append(groupId);
9438
9439 msg.append(", parentCategoryId=");
9440 msg.append(parentCategoryId);
9441
9442 msg.append(", name=");
9443 msg.append(name);
9444
9445 msg.append(", vocabularyId=");
9446 msg.append(vocabularyId);
9447
9448 msg.append(StringPool.CLOSE_CURLY_BRACE);
9449
9450 throw new NoSuchCategoryException(msg.toString());
9451 }
9452
9453
9463 @Override
9464 public AssetCategory fetchByG_P_N_V_Last(long groupId,
9465 long parentCategoryId, String name, long vocabularyId,
9466 OrderByComparator<AssetCategory> orderByComparator) {
9467 int count = countByG_P_N_V(groupId, parentCategoryId, name, vocabularyId);
9468
9469 if (count == 0) {
9470 return null;
9471 }
9472
9473 List<AssetCategory> list = findByG_P_N_V(groupId, parentCategoryId,
9474 name, vocabularyId, count - 1, count, orderByComparator);
9475
9476 if (!list.isEmpty()) {
9477 return list.get(0);
9478 }
9479
9480 return null;
9481 }
9482
9483
9495 @Override
9496 public AssetCategory[] findByG_P_N_V_PrevAndNext(long categoryId,
9497 long groupId, long parentCategoryId, String name, long vocabularyId,
9498 OrderByComparator<AssetCategory> orderByComparator)
9499 throws NoSuchCategoryException {
9500 AssetCategory assetCategory = findByPrimaryKey(categoryId);
9501
9502 Session session = null;
9503
9504 try {
9505 session = openSession();
9506
9507 AssetCategory[] array = new AssetCategoryImpl[3];
9508
9509 array[0] = getByG_P_N_V_PrevAndNext(session, assetCategory,
9510 groupId, parentCategoryId, name, vocabularyId,
9511 orderByComparator, true);
9512
9513 array[1] = assetCategory;
9514
9515 array[2] = getByG_P_N_V_PrevAndNext(session, assetCategory,
9516 groupId, parentCategoryId, name, vocabularyId,
9517 orderByComparator, false);
9518
9519 return array;
9520 }
9521 catch (Exception e) {
9522 throw processException(e);
9523 }
9524 finally {
9525 closeSession(session);
9526 }
9527 }
9528
9529 protected AssetCategory getByG_P_N_V_PrevAndNext(Session session,
9530 AssetCategory assetCategory, long groupId, long parentCategoryId,
9531 String name, long vocabularyId,
9532 OrderByComparator<AssetCategory> orderByComparator, boolean previous) {
9533 StringBundler query = null;
9534
9535 if (orderByComparator != null) {
9536 query = new StringBundler(6 +
9537 (orderByComparator.getOrderByFields().length * 6));
9538 }
9539 else {
9540 query = new StringBundler(3);
9541 }
9542
9543 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
9544
9545 query.append(_FINDER_COLUMN_G_P_N_V_GROUPID_2);
9546
9547 query.append(_FINDER_COLUMN_G_P_N_V_PARENTCATEGORYID_2);
9548
9549 boolean bindName = false;
9550
9551 if (name == null) {
9552 query.append(_FINDER_COLUMN_G_P_N_V_NAME_1);
9553 }
9554 else if (name.equals(StringPool.BLANK)) {
9555 query.append(_FINDER_COLUMN_G_P_N_V_NAME_3);
9556 }
9557 else {
9558 bindName = true;
9559
9560 query.append(_FINDER_COLUMN_G_P_N_V_NAME_2);
9561 }
9562
9563 query.append(_FINDER_COLUMN_G_P_N_V_VOCABULARYID_2);
9564
9565 if (orderByComparator != null) {
9566 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
9567
9568 if (orderByConditionFields.length > 0) {
9569 query.append(WHERE_AND);
9570 }
9571
9572 for (int i = 0; i < orderByConditionFields.length; i++) {
9573 query.append(_ORDER_BY_ENTITY_ALIAS);
9574 query.append(orderByConditionFields[i]);
9575
9576 if ((i + 1) < orderByConditionFields.length) {
9577 if (orderByComparator.isAscending() ^ previous) {
9578 query.append(WHERE_GREATER_THAN_HAS_NEXT);
9579 }
9580 else {
9581 query.append(WHERE_LESSER_THAN_HAS_NEXT);
9582 }
9583 }
9584 else {
9585 if (orderByComparator.isAscending() ^ previous) {
9586 query.append(WHERE_GREATER_THAN);
9587 }
9588 else {
9589 query.append(WHERE_LESSER_THAN);
9590 }
9591 }
9592 }
9593
9594 query.append(ORDER_BY_CLAUSE);
9595
9596 String[] orderByFields = orderByComparator.getOrderByFields();
9597
9598 for (int i = 0; i < orderByFields.length; i++) {
9599 query.append(_ORDER_BY_ENTITY_ALIAS);
9600 query.append(orderByFields[i]);
9601
9602 if ((i + 1) < orderByFields.length) {
9603 if (orderByComparator.isAscending() ^ previous) {
9604 query.append(ORDER_BY_ASC_HAS_NEXT);
9605 }
9606 else {
9607 query.append(ORDER_BY_DESC_HAS_NEXT);
9608 }
9609 }
9610 else {
9611 if (orderByComparator.isAscending() ^ previous) {
9612 query.append(ORDER_BY_ASC);
9613 }
9614 else {
9615 query.append(ORDER_BY_DESC);
9616 }
9617 }
9618 }
9619 }
9620 else {
9621 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
9622 }
9623
9624 String sql = query.toString();
9625
9626 Query q = session.createQuery(sql);
9627
9628 q.setFirstResult(0);
9629 q.setMaxResults(2);
9630
9631 QueryPos qPos = QueryPos.getInstance(q);
9632
9633 qPos.add(groupId);
9634
9635 qPos.add(parentCategoryId);
9636
9637 if (bindName) {
9638 qPos.add(name);
9639 }
9640
9641 qPos.add(vocabularyId);
9642
9643 if (orderByComparator != null) {
9644 Object[] values = orderByComparator.getOrderByConditionValues(assetCategory);
9645
9646 for (Object value : values) {
9647 qPos.add(value);
9648 }
9649 }
9650
9651 List<AssetCategory> list = q.list();
9652
9653 if (list.size() == 2) {
9654 return list.get(1);
9655 }
9656 else {
9657 return null;
9658 }
9659 }
9660
9661
9670 @Override
9671 public List<AssetCategory> filterFindByG_P_N_V(long groupId,
9672 long parentCategoryId, String name, long vocabularyId) {
9673 return filterFindByG_P_N_V(groupId, parentCategoryId, name,
9674 vocabularyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
9675 }
9676
9677
9692 @Override
9693 public List<AssetCategory> filterFindByG_P_N_V(long groupId,
9694 long parentCategoryId, String name, long vocabularyId, int start,
9695 int end) {
9696 return filterFindByG_P_N_V(groupId, parentCategoryId, name,
9697 vocabularyId, start, end, null);
9698 }
9699
9700
9716 @Override
9717 public List<AssetCategory> filterFindByG_P_N_V(long groupId,
9718 long parentCategoryId, String name, long vocabularyId, int start,
9719 int end, OrderByComparator<AssetCategory> orderByComparator) {
9720 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
9721 return findByG_P_N_V(groupId, parentCategoryId, name, vocabularyId,
9722 start, end, orderByComparator);
9723 }
9724
9725 StringBundler query = null;
9726
9727 if (orderByComparator != null) {
9728 query = new StringBundler(6 +
9729 (orderByComparator.getOrderByFields().length * 3));
9730 }
9731 else {
9732 query = new StringBundler(6);
9733 }
9734
9735 if (getDB().isSupportsInlineDistinct()) {
9736 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_WHERE);
9737 }
9738 else {
9739 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_1);
9740 }
9741
9742 query.append(_FINDER_COLUMN_G_P_N_V_GROUPID_2);
9743
9744 query.append(_FINDER_COLUMN_G_P_N_V_PARENTCATEGORYID_2);
9745
9746 boolean bindName = false;
9747
9748 if (name == null) {
9749 query.append(_FINDER_COLUMN_G_P_N_V_NAME_1);
9750 }
9751 else if (name.equals(StringPool.BLANK)) {
9752 query.append(_FINDER_COLUMN_G_P_N_V_NAME_3);
9753 }
9754 else {
9755 bindName = true;
9756
9757 query.append(_FINDER_COLUMN_G_P_N_V_NAME_2);
9758 }
9759
9760 query.append(_FINDER_COLUMN_G_P_N_V_VOCABULARYID_2);
9761
9762 if (!getDB().isSupportsInlineDistinct()) {
9763 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_2);
9764 }
9765
9766 if (orderByComparator != null) {
9767 if (getDB().isSupportsInlineDistinct()) {
9768 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
9769 orderByComparator, true);
9770 }
9771 else {
9772 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
9773 orderByComparator, true);
9774 }
9775 }
9776 else {
9777 if (getDB().isSupportsInlineDistinct()) {
9778 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
9779 }
9780 else {
9781 query.append(AssetCategoryModelImpl.ORDER_BY_SQL);
9782 }
9783 }
9784
9785 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
9786 AssetCategory.class.getName(),
9787 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
9788
9789 Session session = null;
9790
9791 try {
9792 session = openSession();
9793
9794 SQLQuery q = session.createSynchronizedSQLQuery(sql);
9795
9796 if (getDB().isSupportsInlineDistinct()) {
9797 q.addEntity(_FILTER_ENTITY_ALIAS, AssetCategoryImpl.class);
9798 }
9799 else {
9800 q.addEntity(_FILTER_ENTITY_TABLE, AssetCategoryImpl.class);
9801 }
9802
9803 QueryPos qPos = QueryPos.getInstance(q);
9804
9805 qPos.add(groupId);
9806
9807 qPos.add(parentCategoryId);
9808
9809 if (bindName) {
9810 qPos.add(name);
9811 }
9812
9813 qPos.add(vocabularyId);
9814
9815 return (List<AssetCategory>)QueryUtil.list(q, getDialect(), start,
9816 end);
9817 }
9818 catch (Exception e) {
9819 throw processException(e);
9820 }
9821 finally {
9822 closeSession(session);
9823 }
9824 }
9825
9826
9838 @Override
9839 public AssetCategory[] filterFindByG_P_N_V_PrevAndNext(long categoryId,
9840 long groupId, long parentCategoryId, String name, long vocabularyId,
9841 OrderByComparator<AssetCategory> orderByComparator)
9842 throws NoSuchCategoryException {
9843 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
9844 return findByG_P_N_V_PrevAndNext(categoryId, groupId,
9845 parentCategoryId, name, vocabularyId, orderByComparator);
9846 }
9847
9848 AssetCategory assetCategory = findByPrimaryKey(categoryId);
9849
9850 Session session = null;
9851
9852 try {
9853 session = openSession();
9854
9855 AssetCategory[] array = new AssetCategoryImpl[3];
9856
9857 array[0] = filterGetByG_P_N_V_PrevAndNext(session, assetCategory,
9858 groupId, parentCategoryId, name, vocabularyId,
9859 orderByComparator, true);
9860
9861 array[1] = assetCategory;
9862
9863 array[2] = filterGetByG_P_N_V_PrevAndNext(session, assetCategory,
9864 groupId, parentCategoryId, name, vocabularyId,
9865 orderByComparator, false);
9866
9867 return array;
9868 }
9869 catch (Exception e) {
9870 throw processException(e);
9871 }
9872 finally {
9873 closeSession(session);
9874 }
9875 }
9876
9877 protected AssetCategory filterGetByG_P_N_V_PrevAndNext(Session session,
9878 AssetCategory assetCategory, long groupId, long parentCategoryId,
9879 String name, long vocabularyId,
9880 OrderByComparator<AssetCategory> orderByComparator, boolean previous) {
9881 StringBundler query = null;
9882
9883 if (orderByComparator != null) {
9884 query = new StringBundler(6 +
9885 (orderByComparator.getOrderByFields().length * 6));
9886 }
9887 else {
9888 query = new StringBundler(3);
9889 }
9890
9891 if (getDB().isSupportsInlineDistinct()) {
9892 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_WHERE);
9893 }
9894 else {
9895 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_1);
9896 }
9897
9898 query.append(_FINDER_COLUMN_G_P_N_V_GROUPID_2);
9899
9900 query.append(_FINDER_COLUMN_G_P_N_V_PARENTCATEGORYID_2);
9901
9902 boolean bindName = false;
9903
9904 if (name == null) {
9905 query.append(_FINDER_COLUMN_G_P_N_V_NAME_1);
9906 }
9907 else if (name.equals(StringPool.BLANK)) {
9908 query.append(_FINDER_COLUMN_G_P_N_V_NAME_3);
9909 }
9910 else {
9911 bindName = true;
9912
9913 query.append(_FINDER_COLUMN_G_P_N_V_NAME_2);
9914 }
9915
9916 query.append(_FINDER_COLUMN_G_P_N_V_VOCABULARYID_2);
9917
9918 if (!getDB().isSupportsInlineDistinct()) {
9919 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_2);
9920 }
9921
9922 if (orderByComparator != null) {
9923 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
9924
9925 if (orderByConditionFields.length > 0) {
9926 query.append(WHERE_AND);
9927 }
9928
9929 for (int i = 0; i < orderByConditionFields.length; i++) {
9930 if (getDB().isSupportsInlineDistinct()) {
9931 query.append(_ORDER_BY_ENTITY_ALIAS);
9932 }
9933 else {
9934 query.append(_ORDER_BY_ENTITY_TABLE);
9935 }
9936
9937 query.append(orderByConditionFields[i]);
9938
9939 if ((i + 1) < orderByConditionFields.length) {
9940 if (orderByComparator.isAscending() ^ previous) {
9941 query.append(WHERE_GREATER_THAN_HAS_NEXT);
9942 }
9943 else {
9944 query.append(WHERE_LESSER_THAN_HAS_NEXT);
9945 }
9946 }
9947 else {
9948 if (orderByComparator.isAscending() ^ previous) {
9949 query.append(WHERE_GREATER_THAN);
9950 }
9951 else {
9952 query.append(WHERE_LESSER_THAN);
9953 }
9954 }
9955 }
9956
9957 query.append(ORDER_BY_CLAUSE);
9958
9959 String[] orderByFields = orderByComparator.getOrderByFields();
9960
9961 for (int i = 0; i < orderByFields.length; i++) {
9962 if (getDB().isSupportsInlineDistinct()) {
9963 query.append(_ORDER_BY_ENTITY_ALIAS);
9964 }
9965 else {
9966 query.append(_ORDER_BY_ENTITY_TABLE);
9967 }
9968
9969 query.append(orderByFields[i]);
9970
9971 if ((i + 1) < orderByFields.length) {
9972 if (orderByComparator.isAscending() ^ previous) {
9973 query.append(ORDER_BY_ASC_HAS_NEXT);
9974 }
9975 else {
9976 query.append(ORDER_BY_DESC_HAS_NEXT);
9977 }
9978 }
9979 else {
9980 if (orderByComparator.isAscending() ^ previous) {
9981 query.append(ORDER_BY_ASC);
9982 }
9983 else {
9984 query.append(ORDER_BY_DESC);
9985 }
9986 }
9987 }
9988 }
9989 else {
9990 if (getDB().isSupportsInlineDistinct()) {
9991 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
9992 }
9993 else {
9994 query.append(AssetCategoryModelImpl.ORDER_BY_SQL);
9995 }
9996 }
9997
9998 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
9999 AssetCategory.class.getName(),
10000 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
10001
10002 SQLQuery q = session.createSynchronizedSQLQuery(sql);
10003
10004 q.setFirstResult(0);
10005 q.setMaxResults(2);
10006
10007 if (getDB().isSupportsInlineDistinct()) {
10008 q.addEntity(_FILTER_ENTITY_ALIAS, AssetCategoryImpl.class);
10009 }
10010 else {
10011 q.addEntity(_FILTER_ENTITY_TABLE, AssetCategoryImpl.class);
10012 }
10013
10014 QueryPos qPos = QueryPos.getInstance(q);
10015
10016 qPos.add(groupId);
10017
10018 qPos.add(parentCategoryId);
10019
10020 if (bindName) {
10021 qPos.add(name);
10022 }
10023
10024 qPos.add(vocabularyId);
10025
10026 if (orderByComparator != null) {
10027 Object[] values = orderByComparator.getOrderByConditionValues(assetCategory);
10028
10029 for (Object value : values) {
10030 qPos.add(value);
10031 }
10032 }
10033
10034 List<AssetCategory> list = q.list();
10035
10036 if (list.size() == 2) {
10037 return list.get(1);
10038 }
10039 else {
10040 return null;
10041 }
10042 }
10043
10044
10052 @Override
10053 public void removeByG_P_N_V(long groupId, long parentCategoryId,
10054 String name, long vocabularyId) {
10055 for (AssetCategory assetCategory : findByG_P_N_V(groupId,
10056 parentCategoryId, name, vocabularyId, QueryUtil.ALL_POS,
10057 QueryUtil.ALL_POS, null)) {
10058 remove(assetCategory);
10059 }
10060 }
10061
10062
10071 @Override
10072 public int countByG_P_N_V(long groupId, long parentCategoryId, String name,
10073 long vocabularyId) {
10074 FinderPath finderPath = FINDER_PATH_COUNT_BY_G_P_N_V;
10075
10076 Object[] finderArgs = new Object[] {
10077 groupId, parentCategoryId, name, vocabularyId
10078 };
10079
10080 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
10081 this);
10082
10083 if (count == null) {
10084 StringBundler query = new StringBundler(5);
10085
10086 query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
10087
10088 query.append(_FINDER_COLUMN_G_P_N_V_GROUPID_2);
10089
10090 query.append(_FINDER_COLUMN_G_P_N_V_PARENTCATEGORYID_2);
10091
10092 boolean bindName = false;
10093
10094 if (name == null) {
10095 query.append(_FINDER_COLUMN_G_P_N_V_NAME_1);
10096 }
10097 else if (name.equals(StringPool.BLANK)) {
10098 query.append(_FINDER_COLUMN_G_P_N_V_NAME_3);
10099 }
10100 else {
10101 bindName = true;
10102
10103 query.append(_FINDER_COLUMN_G_P_N_V_NAME_2);
10104 }
10105
10106 query.append(_FINDER_COLUMN_G_P_N_V_VOCABULARYID_2);
10107
10108 String sql = query.toString();
10109
10110 Session session = null;
10111
10112 try {
10113 session = openSession();
10114
10115 Query q = session.createQuery(sql);
10116
10117 QueryPos qPos = QueryPos.getInstance(q);
10118
10119 qPos.add(groupId);
10120
10121 qPos.add(parentCategoryId);
10122
10123 if (bindName) {
10124 qPos.add(name);
10125 }
10126
10127 qPos.add(vocabularyId);
10128
10129 count = (Long)q.uniqueResult();
10130
10131 FinderCacheUtil.putResult(finderPath, finderArgs, count);
10132 }
10133 catch (Exception e) {
10134 FinderCacheUtil.removeResult(finderPath, finderArgs);
10135
10136 throw processException(e);
10137 }
10138 finally {
10139 closeSession(session);
10140 }
10141 }
10142
10143 return count.intValue();
10144 }
10145
10146
10155 @Override
10156 public int filterCountByG_P_N_V(long groupId, long parentCategoryId,
10157 String name, long vocabularyId) {
10158 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
10159 return countByG_P_N_V(groupId, parentCategoryId, name, vocabularyId);
10160 }
10161
10162 StringBundler query = new StringBundler(5);
10163
10164 query.append(_FILTER_SQL_COUNT_ASSETCATEGORY_WHERE);
10165
10166 query.append(_FINDER_COLUMN_G_P_N_V_GROUPID_2);
10167
10168 query.append(_FINDER_COLUMN_G_P_N_V_PARENTCATEGORYID_2);
10169
10170 boolean bindName = false;
10171
10172 if (name == null) {
10173 query.append(_FINDER_COLUMN_G_P_N_V_NAME_1);
10174 }
10175 else if (name.equals(StringPool.BLANK)) {
10176 query.append(_FINDER_COLUMN_G_P_N_V_NAME_3);
10177 }
10178 else {
10179 bindName = true;
10180
10181 query.append(_FINDER_COLUMN_G_P_N_V_NAME_2);
10182 }
10183
10184 query.append(_FINDER_COLUMN_G_P_N_V_VOCABULARYID_2);
10185
10186 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
10187 AssetCategory.class.getName(),
10188 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
10189
10190 Session session = null;
10191
10192 try {
10193 session = openSession();
10194
10195 SQLQuery q = session.createSynchronizedSQLQuery(sql);
10196
10197 q.addScalar(COUNT_COLUMN_NAME,
10198 com.liferay.portal.kernel.dao.orm.Type.LONG);
10199
10200 QueryPos qPos = QueryPos.getInstance(q);
10201
10202 qPos.add(groupId);
10203
10204 qPos.add(parentCategoryId);
10205
10206 if (bindName) {
10207 qPos.add(name);
10208 }
10209
10210 qPos.add(vocabularyId);
10211
10212 Long count = (Long)q.uniqueResult();
10213
10214 return count.intValue();
10215 }
10216 catch (Exception e) {
10217 throw processException(e);
10218 }
10219 finally {
10220 closeSession(session);
10221 }
10222 }
10223
10224 private static final String _FINDER_COLUMN_G_P_N_V_GROUPID_2 = "assetCategory.groupId = ? AND ";
10225 private static final String _FINDER_COLUMN_G_P_N_V_PARENTCATEGORYID_2 = "assetCategory.parentCategoryId = ? AND ";
10226 private static final String _FINDER_COLUMN_G_P_N_V_NAME_1 = "assetCategory.name IS NULL AND ";
10227 private static final String _FINDER_COLUMN_G_P_N_V_NAME_2 = "assetCategory.name = ? AND ";
10228 private static final String _FINDER_COLUMN_G_P_N_V_NAME_3 = "(assetCategory.name IS NULL OR assetCategory.name = '') AND ";
10229 private static final String _FINDER_COLUMN_G_P_N_V_VOCABULARYID_2 = "assetCategory.vocabularyId = ?";
10230
10231 public AssetCategoryPersistenceImpl() {
10232 setModelClass(AssetCategory.class);
10233 }
10234
10235
10240 @Override
10241 public void cacheResult(AssetCategory assetCategory) {
10242 EntityCacheUtil.putResult(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
10243 AssetCategoryImpl.class, assetCategory.getPrimaryKey(),
10244 assetCategory);
10245
10246 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
10247 new Object[] { assetCategory.getUuid(), assetCategory.getGroupId() },
10248 assetCategory);
10249
10250 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_P_N_V,
10251 new Object[] {
10252 assetCategory.getParentCategoryId(), assetCategory.getName(),
10253 assetCategory.getVocabularyId()
10254 }, assetCategory);
10255
10256 assetCategory.resetOriginalValues();
10257 }
10258
10259
10264 @Override
10265 public void cacheResult(List<AssetCategory> assetCategories) {
10266 for (AssetCategory assetCategory : assetCategories) {
10267 if (EntityCacheUtil.getResult(
10268 AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
10269 AssetCategoryImpl.class, assetCategory.getPrimaryKey()) == null) {
10270 cacheResult(assetCategory);
10271 }
10272 else {
10273 assetCategory.resetOriginalValues();
10274 }
10275 }
10276 }
10277
10278
10285 @Override
10286 public void clearCache() {
10287 if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
10288 CacheRegistryUtil.clear(AssetCategoryImpl.class.getName());
10289 }
10290
10291 EntityCacheUtil.clearCache(AssetCategoryImpl.class);
10292
10293 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
10294 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
10295 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
10296 }
10297
10298
10305 @Override
10306 public void clearCache(AssetCategory assetCategory) {
10307 EntityCacheUtil.removeResult(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
10308 AssetCategoryImpl.class, assetCategory.getPrimaryKey());
10309
10310 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
10311 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
10312
10313 clearUniqueFindersCache(assetCategory);
10314 }
10315
10316 @Override
10317 public void clearCache(List<AssetCategory> assetCategories) {
10318 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
10319 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
10320
10321 for (AssetCategory assetCategory : assetCategories) {
10322 EntityCacheUtil.removeResult(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
10323 AssetCategoryImpl.class, assetCategory.getPrimaryKey());
10324
10325 clearUniqueFindersCache(assetCategory);
10326 }
10327 }
10328
10329 protected void cacheUniqueFindersCache(AssetCategory assetCategory) {
10330 if (assetCategory.isNew()) {
10331 Object[] args = new Object[] {
10332 assetCategory.getUuid(), assetCategory.getGroupId()
10333 };
10334
10335 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G, args,
10336 Long.valueOf(1));
10337 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G, args,
10338 assetCategory);
10339
10340 args = new Object[] {
10341 assetCategory.getParentCategoryId(), assetCategory.getName(),
10342 assetCategory.getVocabularyId()
10343 };
10344
10345 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_P_N_V, args,
10346 Long.valueOf(1));
10347 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_P_N_V, args,
10348 assetCategory);
10349 }
10350 else {
10351 AssetCategoryModelImpl assetCategoryModelImpl = (AssetCategoryModelImpl)assetCategory;
10352
10353 if ((assetCategoryModelImpl.getColumnBitmask() &
10354 FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) {
10355 Object[] args = new Object[] {
10356 assetCategory.getUuid(), assetCategory.getGroupId()
10357 };
10358
10359 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G, args,
10360 Long.valueOf(1));
10361 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G, args,
10362 assetCategory);
10363 }
10364
10365 if ((assetCategoryModelImpl.getColumnBitmask() &
10366 FINDER_PATH_FETCH_BY_P_N_V.getColumnBitmask()) != 0) {
10367 Object[] args = new Object[] {
10368 assetCategory.getParentCategoryId(),
10369 assetCategory.getName(), assetCategory.getVocabularyId()
10370 };
10371
10372 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_P_N_V, args,
10373 Long.valueOf(1));
10374 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_P_N_V, args,
10375 assetCategory);
10376 }
10377 }
10378 }
10379
10380 protected void clearUniqueFindersCache(AssetCategory assetCategory) {
10381 AssetCategoryModelImpl assetCategoryModelImpl = (AssetCategoryModelImpl)assetCategory;
10382
10383 Object[] args = new Object[] {
10384 assetCategory.getUuid(), assetCategory.getGroupId()
10385 };
10386
10387 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args);
10388 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args);
10389
10390 if ((assetCategoryModelImpl.getColumnBitmask() &
10391 FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) {
10392 args = new Object[] {
10393 assetCategoryModelImpl.getOriginalUuid(),
10394 assetCategoryModelImpl.getOriginalGroupId()
10395 };
10396
10397 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args);
10398 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args);
10399 }
10400
10401 args = new Object[] {
10402 assetCategory.getParentCategoryId(), assetCategory.getName(),
10403 assetCategory.getVocabularyId()
10404 };
10405
10406 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_P_N_V, args);
10407 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_P_N_V, args);
10408
10409 if ((assetCategoryModelImpl.getColumnBitmask() &
10410 FINDER_PATH_FETCH_BY_P_N_V.getColumnBitmask()) != 0) {
10411 args = new Object[] {
10412 assetCategoryModelImpl.getOriginalParentCategoryId(),
10413 assetCategoryModelImpl.getOriginalName(),
10414 assetCategoryModelImpl.getOriginalVocabularyId()
10415 };
10416
10417 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_P_N_V, args);
10418 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_P_N_V, args);
10419 }
10420 }
10421
10422
10428 @Override
10429 public AssetCategory create(long categoryId) {
10430 AssetCategory assetCategory = new AssetCategoryImpl();
10431
10432 assetCategory.setNew(true);
10433 assetCategory.setPrimaryKey(categoryId);
10434
10435 String uuid = PortalUUIDUtil.generate();
10436
10437 assetCategory.setUuid(uuid);
10438
10439 return assetCategory;
10440 }
10441
10442
10449 @Override
10450 public AssetCategory remove(long categoryId) throws NoSuchCategoryException {
10451 return remove((Serializable)categoryId);
10452 }
10453
10454
10461 @Override
10462 public AssetCategory remove(Serializable primaryKey)
10463 throws NoSuchCategoryException {
10464 Session session = null;
10465
10466 try {
10467 session = openSession();
10468
10469 AssetCategory assetCategory = (AssetCategory)session.get(AssetCategoryImpl.class,
10470 primaryKey);
10471
10472 if (assetCategory == null) {
10473 if (_log.isWarnEnabled()) {
10474 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
10475 }
10476
10477 throw new NoSuchCategoryException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
10478 primaryKey);
10479 }
10480
10481 return remove(assetCategory);
10482 }
10483 catch (NoSuchCategoryException nsee) {
10484 throw nsee;
10485 }
10486 catch (Exception e) {
10487 throw processException(e);
10488 }
10489 finally {
10490 closeSession(session);
10491 }
10492 }
10493
10494 @Override
10495 protected AssetCategory removeImpl(AssetCategory assetCategory) {
10496 assetCategory = toUnwrappedModel(assetCategory);
10497
10498 assetCategoryToAssetEntryTableMapper.deleteLeftPrimaryKeyTableMappings(assetCategory.getPrimaryKey());
10499
10500 Session session = null;
10501
10502 try {
10503 session = openSession();
10504
10505 if (rebuildTreeEnabled) {
10506 if (session.isDirty()) {
10507 session.flush();
10508 }
10509
10510 nestedSetsTreeManager.delete(assetCategory);
10511
10512 clearCache();
10513
10514 session.clear();
10515 }
10516
10517 if (!session.contains(assetCategory)) {
10518 assetCategory = (AssetCategory)session.get(AssetCategoryImpl.class,
10519 assetCategory.getPrimaryKeyObj());
10520 }
10521
10522 if (assetCategory != null) {
10523 session.delete(assetCategory);
10524 }
10525 }
10526 catch (Exception e) {
10527 throw processException(e);
10528 }
10529 finally {
10530 closeSession(session);
10531 }
10532
10533 if (assetCategory != null) {
10534 clearCache(assetCategory);
10535 }
10536
10537 return assetCategory;
10538 }
10539
10540 @Override
10541 public AssetCategory updateImpl(
10542 com.liferay.portlet.asset.model.AssetCategory assetCategory) {
10543 assetCategory = toUnwrappedModel(assetCategory);
10544
10545 boolean isNew = assetCategory.isNew();
10546
10547 AssetCategoryModelImpl assetCategoryModelImpl = (AssetCategoryModelImpl)assetCategory;
10548
10549 if (Validator.isNull(assetCategory.getUuid())) {
10550 String uuid = PortalUUIDUtil.generate();
10551
10552 assetCategory.setUuid(uuid);
10553 }
10554
10555 Session session = null;
10556
10557 try {
10558 session = openSession();
10559
10560 if (rebuildTreeEnabled) {
10561 if (session.isDirty()) {
10562 session.flush();
10563 }
10564
10565 if (isNew) {
10566 nestedSetsTreeManager.insert(assetCategory,
10567 fetchByPrimaryKey(assetCategory.getParentCategoryId()));
10568 }
10569 else if (assetCategory.getParentCategoryId() != assetCategoryModelImpl.getOriginalParentCategoryId()) {
10570 nestedSetsTreeManager.move(assetCategory,
10571 fetchByPrimaryKey(
10572 assetCategoryModelImpl.getOriginalParentCategoryId()),
10573 fetchByPrimaryKey(assetCategory.getParentCategoryId()));
10574 }
10575
10576 clearCache();
10577
10578 session.clear();
10579 }
10580
10581 if (assetCategory.isNew()) {
10582 session.save(assetCategory);
10583
10584 assetCategory.setNew(false);
10585 }
10586 else {
10587 session.merge(assetCategory);
10588 }
10589 }
10590 catch (Exception e) {
10591 throw processException(e);
10592 }
10593 finally {
10594 closeSession(session);
10595 }
10596
10597 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
10598
10599 if (isNew || !AssetCategoryModelImpl.COLUMN_BITMASK_ENABLED) {
10600 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
10601 }
10602
10603 else {
10604 if ((assetCategoryModelImpl.getColumnBitmask() &
10605 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID.getColumnBitmask()) != 0) {
10606 Object[] args = new Object[] {
10607 assetCategoryModelImpl.getOriginalUuid()
10608 };
10609
10610 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
10611 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
10612 args);
10613
10614 args = new Object[] { assetCategoryModelImpl.getUuid() };
10615
10616 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
10617 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
10618 args);
10619 }
10620
10621 if ((assetCategoryModelImpl.getColumnBitmask() &
10622 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C.getColumnBitmask()) != 0) {
10623 Object[] args = new Object[] {
10624 assetCategoryModelImpl.getOriginalUuid(),
10625 assetCategoryModelImpl.getOriginalCompanyId()
10626 };
10627
10628 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args);
10629 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C,
10630 args);
10631
10632 args = new Object[] {
10633 assetCategoryModelImpl.getUuid(),
10634 assetCategoryModelImpl.getCompanyId()
10635 };
10636
10637 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args);
10638 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C,
10639 args);
10640 }
10641
10642 if ((assetCategoryModelImpl.getColumnBitmask() &
10643 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID.getColumnBitmask()) != 0) {
10644 Object[] args = new Object[] {
10645 assetCategoryModelImpl.getOriginalGroupId()
10646 };
10647
10648 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
10649 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
10650 args);
10651
10652 args = new Object[] { assetCategoryModelImpl.getGroupId() };
10653
10654 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
10655 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
10656 args);
10657 }
10658
10659 if ((assetCategoryModelImpl.getColumnBitmask() &
10660 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_PARENTCATEGORYID.getColumnBitmask()) != 0) {
10661 Object[] args = new Object[] {
10662 assetCategoryModelImpl.getOriginalParentCategoryId()
10663 };
10664
10665 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_PARENTCATEGORYID,
10666 args);
10667 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_PARENTCATEGORYID,
10668 args);
10669
10670 args = new Object[] { assetCategoryModelImpl.getParentCategoryId() };
10671
10672 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_PARENTCATEGORYID,
10673 args);
10674 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_PARENTCATEGORYID,
10675 args);
10676 }
10677
10678 if ((assetCategoryModelImpl.getColumnBitmask() &
10679 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_VOCABULARYID.getColumnBitmask()) != 0) {
10680 Object[] args = new Object[] {
10681 assetCategoryModelImpl.getOriginalVocabularyId()
10682 };
10683
10684 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_VOCABULARYID,
10685 args);
10686 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_VOCABULARYID,
10687 args);
10688
10689 args = new Object[] { assetCategoryModelImpl.getVocabularyId() };
10690
10691 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_VOCABULARYID,
10692 args);
10693 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_VOCABULARYID,
10694 args);
10695 }
10696
10697 if ((assetCategoryModelImpl.getColumnBitmask() &
10698 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_V.getColumnBitmask()) != 0) {
10699 Object[] args = new Object[] {
10700 assetCategoryModelImpl.getOriginalGroupId(),
10701 assetCategoryModelImpl.getOriginalVocabularyId()
10702 };
10703
10704 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_V, args);
10705 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_V,
10706 args);
10707
10708 args = new Object[] {
10709 assetCategoryModelImpl.getGroupId(),
10710 assetCategoryModelImpl.getVocabularyId()
10711 };
10712
10713 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_V, args);
10714 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_V,
10715 args);
10716 }
10717
10718 if ((assetCategoryModelImpl.getColumnBitmask() &
10719 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_P_N.getColumnBitmask()) != 0) {
10720 Object[] args = new Object[] {
10721 assetCategoryModelImpl.getOriginalParentCategoryId(),
10722 assetCategoryModelImpl.getOriginalName()
10723 };
10724
10725 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_P_N, args);
10726 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_P_N,
10727 args);
10728
10729 args = new Object[] {
10730 assetCategoryModelImpl.getParentCategoryId(),
10731 assetCategoryModelImpl.getName()
10732 };
10733
10734 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_P_N, args);
10735 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_P_N,
10736 args);
10737 }
10738
10739 if ((assetCategoryModelImpl.getColumnBitmask() &
10740 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_P_V.getColumnBitmask()) != 0) {
10741 Object[] args = new Object[] {
10742 assetCategoryModelImpl.getOriginalParentCategoryId(),
10743 assetCategoryModelImpl.getOriginalVocabularyId()
10744 };
10745
10746 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_P_V, args);
10747 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_P_V,
10748 args);
10749
10750 args = new Object[] {
10751 assetCategoryModelImpl.getParentCategoryId(),
10752 assetCategoryModelImpl.getVocabularyId()
10753 };
10754
10755 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_P_V, args);
10756 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_P_V,
10757 args);
10758 }
10759
10760 if ((assetCategoryModelImpl.getColumnBitmask() &
10761 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_V.getColumnBitmask()) != 0) {
10762 Object[] args = new Object[] {
10763 assetCategoryModelImpl.getOriginalName(),
10764 assetCategoryModelImpl.getOriginalVocabularyId()
10765 };
10766
10767 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_N_V, args);
10768 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_V,
10769 args);
10770
10771 args = new Object[] {
10772 assetCategoryModelImpl.getName(),
10773 assetCategoryModelImpl.getVocabularyId()
10774 };
10775
10776 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_N_V, args);
10777 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_V,
10778 args);
10779 }
10780
10781 if ((assetCategoryModelImpl.getColumnBitmask() &
10782 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_V.getColumnBitmask()) != 0) {
10783 Object[] args = new Object[] {
10784 assetCategoryModelImpl.getOriginalGroupId(),
10785 assetCategoryModelImpl.getOriginalParentCategoryId(),
10786 assetCategoryModelImpl.getOriginalVocabularyId()
10787 };
10788
10789 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_P_V, args);
10790 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_V,
10791 args);
10792
10793 args = new Object[] {
10794 assetCategoryModelImpl.getGroupId(),
10795 assetCategoryModelImpl.getParentCategoryId(),
10796 assetCategoryModelImpl.getVocabularyId()
10797 };
10798
10799 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_P_V, args);
10800 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_V,
10801 args);
10802 }
10803
10804 if ((assetCategoryModelImpl.getColumnBitmask() &
10805 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_N_V.getColumnBitmask()) != 0) {
10806 Object[] args = new Object[] {
10807 assetCategoryModelImpl.getOriginalGroupId(),
10808 assetCategoryModelImpl.getOriginalParentCategoryId(),
10809 assetCategoryModelImpl.getOriginalName(),
10810 assetCategoryModelImpl.getOriginalVocabularyId()
10811 };
10812
10813 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_P_N_V, args);
10814 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_N_V,
10815 args);
10816
10817 args = new Object[] {
10818 assetCategoryModelImpl.getGroupId(),
10819 assetCategoryModelImpl.getParentCategoryId(),
10820 assetCategoryModelImpl.getName(),
10821 assetCategoryModelImpl.getVocabularyId()
10822 };
10823
10824 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_P_N_V, args);
10825 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_N_V,
10826 args);
10827 }
10828 }
10829
10830 EntityCacheUtil.putResult(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
10831 AssetCategoryImpl.class, assetCategory.getPrimaryKey(),
10832 assetCategory, false);
10833
10834 clearUniqueFindersCache(assetCategory);
10835 cacheUniqueFindersCache(assetCategory);
10836
10837 assetCategory.resetOriginalValues();
10838
10839 return assetCategory;
10840 }
10841
10842 protected AssetCategory toUnwrappedModel(AssetCategory assetCategory) {
10843 if (assetCategory instanceof AssetCategoryImpl) {
10844 return assetCategory;
10845 }
10846
10847 AssetCategoryImpl assetCategoryImpl = new AssetCategoryImpl();
10848
10849 assetCategoryImpl.setNew(assetCategory.isNew());
10850 assetCategoryImpl.setPrimaryKey(assetCategory.getPrimaryKey());
10851
10852 assetCategoryImpl.setUuid(assetCategory.getUuid());
10853 assetCategoryImpl.setCategoryId(assetCategory.getCategoryId());
10854 assetCategoryImpl.setGroupId(assetCategory.getGroupId());
10855 assetCategoryImpl.setCompanyId(assetCategory.getCompanyId());
10856 assetCategoryImpl.setUserId(assetCategory.getUserId());
10857 assetCategoryImpl.setUserName(assetCategory.getUserName());
10858 assetCategoryImpl.setCreateDate(assetCategory.getCreateDate());
10859 assetCategoryImpl.setModifiedDate(assetCategory.getModifiedDate());
10860 assetCategoryImpl.setParentCategoryId(assetCategory.getParentCategoryId());
10861 assetCategoryImpl.setLeftCategoryId(assetCategory.getLeftCategoryId());
10862 assetCategoryImpl.setRightCategoryId(assetCategory.getRightCategoryId());
10863 assetCategoryImpl.setName(assetCategory.getName());
10864 assetCategoryImpl.setTitle(assetCategory.getTitle());
10865 assetCategoryImpl.setDescription(assetCategory.getDescription());
10866 assetCategoryImpl.setVocabularyId(assetCategory.getVocabularyId());
10867
10868 return assetCategoryImpl;
10869 }
10870
10871
10878 @Override
10879 public AssetCategory findByPrimaryKey(Serializable primaryKey)
10880 throws NoSuchCategoryException {
10881 AssetCategory assetCategory = fetchByPrimaryKey(primaryKey);
10882
10883 if (assetCategory == null) {
10884 if (_log.isWarnEnabled()) {
10885 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
10886 }
10887
10888 throw new NoSuchCategoryException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
10889 primaryKey);
10890 }
10891
10892 return assetCategory;
10893 }
10894
10895
10902 @Override
10903 public AssetCategory findByPrimaryKey(long categoryId)
10904 throws NoSuchCategoryException {
10905 return findByPrimaryKey((Serializable)categoryId);
10906 }
10907
10908
10914 @Override
10915 public AssetCategory fetchByPrimaryKey(Serializable primaryKey) {
10916 AssetCategory assetCategory = (AssetCategory)EntityCacheUtil.getResult(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
10917 AssetCategoryImpl.class, primaryKey);
10918
10919 if (assetCategory == _nullAssetCategory) {
10920 return null;
10921 }
10922
10923 if (assetCategory == null) {
10924 Session session = null;
10925
10926 try {
10927 session = openSession();
10928
10929 assetCategory = (AssetCategory)session.get(AssetCategoryImpl.class,
10930 primaryKey);
10931
10932 if (assetCategory != null) {
10933 cacheResult(assetCategory);
10934 }
10935 else {
10936 EntityCacheUtil.putResult(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
10937 AssetCategoryImpl.class, primaryKey, _nullAssetCategory);
10938 }
10939 }
10940 catch (Exception e) {
10941 EntityCacheUtil.removeResult(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
10942 AssetCategoryImpl.class, primaryKey);
10943
10944 throw processException(e);
10945 }
10946 finally {
10947 closeSession(session);
10948 }
10949 }
10950
10951 return assetCategory;
10952 }
10953
10954
10960 @Override
10961 public AssetCategory fetchByPrimaryKey(long categoryId) {
10962 return fetchByPrimaryKey((Serializable)categoryId);
10963 }
10964
10965 @Override
10966 public Map<Serializable, AssetCategory> fetchByPrimaryKeys(
10967 Set<Serializable> primaryKeys) {
10968 if (primaryKeys.isEmpty()) {
10969 return Collections.emptyMap();
10970 }
10971
10972 Map<Serializable, AssetCategory> map = new HashMap<Serializable, AssetCategory>();
10973
10974 if (primaryKeys.size() == 1) {
10975 Iterator<Serializable> iterator = primaryKeys.iterator();
10976
10977 Serializable primaryKey = iterator.next();
10978
10979 AssetCategory assetCategory = fetchByPrimaryKey(primaryKey);
10980
10981 if (assetCategory != null) {
10982 map.put(primaryKey, assetCategory);
10983 }
10984
10985 return map;
10986 }
10987
10988 Set<Serializable> uncachedPrimaryKeys = null;
10989
10990 for (Serializable primaryKey : primaryKeys) {
10991 AssetCategory assetCategory = (AssetCategory)EntityCacheUtil.getResult(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
10992 AssetCategoryImpl.class, primaryKey);
10993
10994 if (assetCategory == null) {
10995 if (uncachedPrimaryKeys == null) {
10996 uncachedPrimaryKeys = new HashSet<Serializable>();
10997 }
10998
10999 uncachedPrimaryKeys.add(primaryKey);
11000 }
11001 else {
11002 map.put(primaryKey, assetCategory);
11003 }
11004 }
11005
11006 if (uncachedPrimaryKeys == null) {
11007 return map;
11008 }
11009
11010 StringBundler query = new StringBundler((uncachedPrimaryKeys.size() * 2) +
11011 1);
11012
11013 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE_PKS_IN);
11014
11015 for (Serializable primaryKey : uncachedPrimaryKeys) {
11016 query.append(String.valueOf(primaryKey));
11017
11018 query.append(StringPool.COMMA);
11019 }
11020
11021 query.setIndex(query.index() - 1);
11022
11023 query.append(StringPool.CLOSE_PARENTHESIS);
11024
11025 String sql = query.toString();
11026
11027 Session session = null;
11028
11029 try {
11030 session = openSession();
11031
11032 Query q = session.createQuery(sql);
11033
11034 for (AssetCategory assetCategory : (List<AssetCategory>)q.list()) {
11035 map.put(assetCategory.getPrimaryKeyObj(), assetCategory);
11036
11037 cacheResult(assetCategory);
11038
11039 uncachedPrimaryKeys.remove(assetCategory.getPrimaryKeyObj());
11040 }
11041
11042 for (Serializable primaryKey : uncachedPrimaryKeys) {
11043 EntityCacheUtil.putResult(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
11044 AssetCategoryImpl.class, primaryKey, _nullAssetCategory);
11045 }
11046 }
11047 catch (Exception e) {
11048 throw processException(e);
11049 }
11050 finally {
11051 closeSession(session);
11052 }
11053
11054 return map;
11055 }
11056
11057
11062 @Override
11063 public List<AssetCategory> findAll() {
11064 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
11065 }
11066
11067
11078 @Override
11079 public List<AssetCategory> findAll(int start, int end) {
11080 return findAll(start, end, null);
11081 }
11082
11083
11095 @Override
11096 public List<AssetCategory> findAll(int start, int end,
11097 OrderByComparator<AssetCategory> orderByComparator) {
11098 boolean pagination = true;
11099 FinderPath finderPath = null;
11100 Object[] finderArgs = null;
11101
11102 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
11103 (orderByComparator == null)) {
11104 pagination = false;
11105 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
11106 finderArgs = FINDER_ARGS_EMPTY;
11107 }
11108 else {
11109 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
11110 finderArgs = new Object[] { start, end, orderByComparator };
11111 }
11112
11113 List<AssetCategory> list = (List<AssetCategory>)FinderCacheUtil.getResult(finderPath,
11114 finderArgs, this);
11115
11116 if (list == null) {
11117 StringBundler query = null;
11118 String sql = null;
11119
11120 if (orderByComparator != null) {
11121 query = new StringBundler(2 +
11122 (orderByComparator.getOrderByFields().length * 3));
11123
11124 query.append(_SQL_SELECT_ASSETCATEGORY);
11125
11126 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
11127 orderByComparator);
11128
11129 sql = query.toString();
11130 }
11131 else {
11132 sql = _SQL_SELECT_ASSETCATEGORY;
11133
11134 if (pagination) {
11135 sql = sql.concat(AssetCategoryModelImpl.ORDER_BY_JPQL);
11136 }
11137 }
11138
11139 Session session = null;
11140
11141 try {
11142 session = openSession();
11143
11144 Query q = session.createQuery(sql);
11145
11146 if (!pagination) {
11147 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
11148 start, end, false);
11149
11150 Collections.sort(list);
11151
11152 list = Collections.unmodifiableList(list);
11153 }
11154 else {
11155 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
11156 start, end);
11157 }
11158
11159 cacheResult(list);
11160
11161 FinderCacheUtil.putResult(finderPath, finderArgs, list);
11162 }
11163 catch (Exception e) {
11164 FinderCacheUtil.removeResult(finderPath, finderArgs);
11165
11166 throw processException(e);
11167 }
11168 finally {
11169 closeSession(session);
11170 }
11171 }
11172
11173 return list;
11174 }
11175
11176
11180 @Override
11181 public void removeAll() {
11182 for (AssetCategory assetCategory : findAll()) {
11183 remove(assetCategory);
11184 }
11185 }
11186
11187
11192 @Override
11193 public int countAll() {
11194 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
11195 FINDER_ARGS_EMPTY, this);
11196
11197 if (count == null) {
11198 Session session = null;
11199
11200 try {
11201 session = openSession();
11202
11203 Query q = session.createQuery(_SQL_COUNT_ASSETCATEGORY);
11204
11205 count = (Long)q.uniqueResult();
11206
11207 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
11208 FINDER_ARGS_EMPTY, count);
11209 }
11210 catch (Exception e) {
11211 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_ALL,
11212 FINDER_ARGS_EMPTY);
11213
11214 throw processException(e);
11215 }
11216 finally {
11217 closeSession(session);
11218 }
11219 }
11220
11221 return count.intValue();
11222 }
11223
11224
11230 @Override
11231 public long[] getAssetEntryPrimaryKeys(long pk) {
11232 long[] pks = assetCategoryToAssetEntryTableMapper.getRightPrimaryKeys(pk);
11233
11234 return pks.clone();
11235 }
11236
11237
11243 @Override
11244 public List<com.liferay.portlet.asset.model.AssetEntry> getAssetEntries(
11245 long pk) {
11246 return getAssetEntries(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
11247 }
11248
11249
11261 @Override
11262 public List<com.liferay.portlet.asset.model.AssetEntry> getAssetEntries(
11263 long pk, int start, int end) {
11264 return getAssetEntries(pk, start, end, null);
11265 }
11266
11267
11280 @Override
11281 public List<com.liferay.portlet.asset.model.AssetEntry> getAssetEntries(
11282 long pk, int start, int end,
11283 OrderByComparator<com.liferay.portlet.asset.model.AssetEntry> orderByComparator) {
11284 return assetCategoryToAssetEntryTableMapper.getRightBaseModels(pk,
11285 start, end, orderByComparator);
11286 }
11287
11288
11294 @Override
11295 public int getAssetEntriesSize(long pk) {
11296 long[] pks = assetCategoryToAssetEntryTableMapper.getRightPrimaryKeys(pk);
11297
11298 return pks.length;
11299 }
11300
11301
11308 @Override
11309 public boolean containsAssetEntry(long pk, long assetEntryPK) {
11310 return assetCategoryToAssetEntryTableMapper.containsTableMapping(pk,
11311 assetEntryPK);
11312 }
11313
11314
11320 @Override
11321 public boolean containsAssetEntries(long pk) {
11322 if (getAssetEntriesSize(pk) > 0) {
11323 return true;
11324 }
11325 else {
11326 return false;
11327 }
11328 }
11329
11330
11336 @Override
11337 public void addAssetEntry(long pk, long assetEntryPK) {
11338 assetCategoryToAssetEntryTableMapper.addTableMapping(pk, assetEntryPK);
11339 }
11340
11341
11347 @Override
11348 public void addAssetEntry(long pk,
11349 com.liferay.portlet.asset.model.AssetEntry assetEntry) {
11350 assetCategoryToAssetEntryTableMapper.addTableMapping(pk,
11351 assetEntry.getPrimaryKey());
11352 }
11353
11354
11360 @Override
11361 public void addAssetEntries(long pk, long[] assetEntryPKs) {
11362 for (long assetEntryPK : assetEntryPKs) {
11363 assetCategoryToAssetEntryTableMapper.addTableMapping(pk,
11364 assetEntryPK);
11365 }
11366 }
11367
11368
11374 @Override
11375 public void addAssetEntries(long pk,
11376 List<com.liferay.portlet.asset.model.AssetEntry> assetEntries) {
11377 for (com.liferay.portlet.asset.model.AssetEntry assetEntry : assetEntries) {
11378 assetCategoryToAssetEntryTableMapper.addTableMapping(pk,
11379 assetEntry.getPrimaryKey());
11380 }
11381 }
11382
11383
11388 @Override
11389 public void clearAssetEntries(long pk) {
11390 assetCategoryToAssetEntryTableMapper.deleteLeftPrimaryKeyTableMappings(pk);
11391 }
11392
11393
11399 @Override
11400 public void removeAssetEntry(long pk, long assetEntryPK) {
11401 assetCategoryToAssetEntryTableMapper.deleteTableMapping(pk, assetEntryPK);
11402 }
11403
11404
11410 @Override
11411 public void removeAssetEntry(long pk,
11412 com.liferay.portlet.asset.model.AssetEntry assetEntry) {
11413 assetCategoryToAssetEntryTableMapper.deleteTableMapping(pk,
11414 assetEntry.getPrimaryKey());
11415 }
11416
11417
11423 @Override
11424 public void removeAssetEntries(long pk, long[] assetEntryPKs) {
11425 for (long assetEntryPK : assetEntryPKs) {
11426 assetCategoryToAssetEntryTableMapper.deleteTableMapping(pk,
11427 assetEntryPK);
11428 }
11429 }
11430
11431
11437 @Override
11438 public void removeAssetEntries(long pk,
11439 List<com.liferay.portlet.asset.model.AssetEntry> assetEntries) {
11440 for (com.liferay.portlet.asset.model.AssetEntry assetEntry : assetEntries) {
11441 assetCategoryToAssetEntryTableMapper.deleteTableMapping(pk,
11442 assetEntry.getPrimaryKey());
11443 }
11444 }
11445
11446
11452 @Override
11453 public void setAssetEntries(long pk, long[] assetEntryPKs) {
11454 Set<Long> newAssetEntryPKsSet = SetUtil.fromArray(assetEntryPKs);
11455 Set<Long> oldAssetEntryPKsSet = SetUtil.fromArray(assetCategoryToAssetEntryTableMapper.getRightPrimaryKeys(
11456 pk));
11457
11458 Set<Long> removeAssetEntryPKsSet = new HashSet<Long>(oldAssetEntryPKsSet);
11459
11460 removeAssetEntryPKsSet.removeAll(newAssetEntryPKsSet);
11461
11462 for (long removeAssetEntryPK : removeAssetEntryPKsSet) {
11463 assetCategoryToAssetEntryTableMapper.deleteTableMapping(pk,
11464 removeAssetEntryPK);
11465 }
11466
11467 newAssetEntryPKsSet.removeAll(oldAssetEntryPKsSet);
11468
11469 for (long newAssetEntryPK : newAssetEntryPKsSet) {
11470 assetCategoryToAssetEntryTableMapper.addTableMapping(pk,
11471 newAssetEntryPK);
11472 }
11473 }
11474
11475
11481 @Override
11482 public void setAssetEntries(long pk,
11483 List<com.liferay.portlet.asset.model.AssetEntry> assetEntries) {
11484 try {
11485 long[] assetEntryPKs = new long[assetEntries.size()];
11486
11487 for (int i = 0; i < assetEntries.size(); i++) {
11488 com.liferay.portlet.asset.model.AssetEntry assetEntry = assetEntries.get(i);
11489
11490 assetEntryPKs[i] = assetEntry.getPrimaryKey();
11491 }
11492
11493 setAssetEntries(pk, assetEntryPKs);
11494 }
11495 catch (Exception e) {
11496 throw processException(e);
11497 }
11498 }
11499
11500 @Override
11501 protected Set<String> getBadColumnNames() {
11502 return _badColumnNames;
11503 }
11504
11505 @Override
11506 public long countAncestors(AssetCategory assetCategory) {
11507 Object[] finderArgs = new Object[] {
11508 assetCategory.getGroupId(), assetCategory.getLeftCategoryId(),
11509 assetCategory.getRightCategoryId()
11510 };
11511
11512 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_ANCESTORS,
11513 finderArgs, this);
11514
11515 if (count == null) {
11516 try {
11517 count = nestedSetsTreeManager.countAncestors(assetCategory);
11518
11519 FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_ANCESTORS,
11520 finderArgs, count);
11521 }
11522 catch (SystemException se) {
11523 FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_COUNT_ANCESTORS,
11524 finderArgs);
11525
11526 throw se;
11527 }
11528 }
11529
11530 return count.intValue();
11531 }
11532
11533 @Override
11534 public long countDescendants(AssetCategory assetCategory) {
11535 Object[] finderArgs = new Object[] {
11536 assetCategory.getGroupId(), assetCategory.getLeftCategoryId(),
11537 assetCategory.getRightCategoryId()
11538 };
11539
11540 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_DESCENDANTS,
11541 finderArgs, this);
11542
11543 if (count == null) {
11544 try {
11545 count = nestedSetsTreeManager.countDescendants(assetCategory);
11546
11547 FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_DESCENDANTS,
11548 finderArgs, count);
11549 }
11550 catch (SystemException se) {
11551 FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_COUNT_DESCENDANTS,
11552 finderArgs);
11553
11554 throw se;
11555 }
11556 }
11557
11558 return count.intValue();
11559 }
11560
11561 @Override
11562 public List<AssetCategory> getAncestors(AssetCategory assetCategory) {
11563 Object[] finderArgs = new Object[] {
11564 assetCategory.getGroupId(), assetCategory.getLeftCategoryId(),
11565 assetCategory.getRightCategoryId()
11566 };
11567
11568 List<AssetCategory> list = (List<AssetCategory>)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_GET_ANCESTORS,
11569 finderArgs, this);
11570
11571 if ((list != null) && !list.isEmpty()) {
11572 for (AssetCategory tempAssetCategory : list) {
11573 if ((assetCategory.getLeftCategoryId() < tempAssetCategory.getLeftCategoryId()) ||
11574 (assetCategory.getRightCategoryId() > tempAssetCategory.getRightCategoryId())) {
11575 list = null;
11576
11577 break;
11578 }
11579 }
11580 }
11581
11582 if (list == null) {
11583 try {
11584 list = nestedSetsTreeManager.getAncestors(assetCategory);
11585
11586 cacheResult(list);
11587
11588 FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_GET_ANCESTORS,
11589 finderArgs, list);
11590 }
11591 catch (SystemException se) {
11592 FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_GET_ANCESTORS,
11593 finderArgs);
11594
11595 throw se;
11596 }
11597 }
11598
11599 return list;
11600 }
11601
11602 @Override
11603 public List<AssetCategory> getDescendants(AssetCategory assetCategory) {
11604 Object[] finderArgs = new Object[] {
11605 assetCategory.getGroupId(), assetCategory.getLeftCategoryId(),
11606 assetCategory.getRightCategoryId()
11607 };
11608
11609 List<AssetCategory> list = (List<AssetCategory>)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_GET_DESCENDANTS,
11610 finderArgs, this);
11611
11612 if ((list != null) && !list.isEmpty()) {
11613 for (AssetCategory tempAssetCategory : list) {
11614 if ((assetCategory.getLeftCategoryId() > tempAssetCategory.getLeftCategoryId()) ||
11615 (assetCategory.getRightCategoryId() < tempAssetCategory.getRightCategoryId())) {
11616 list = null;
11617
11618 break;
11619 }
11620 }
11621 }
11622
11623 if (list == null) {
11624 try {
11625 list = nestedSetsTreeManager.getDescendants(assetCategory);
11626
11627 cacheResult(list);
11628
11629 FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_GET_DESCENDANTS,
11630 finderArgs, list);
11631 }
11632 catch (SystemException se) {
11633 FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_GET_DESCENDANTS,
11634 finderArgs);
11635
11636 throw se;
11637 }
11638 }
11639
11640 return list;
11641 }
11642
11643
11653 @Override
11654 public void rebuildTree(long groupId, boolean force) {
11655 if (!rebuildTreeEnabled) {
11656 return;
11657 }
11658
11659 if (force || (countOrphanTreeNodes(groupId) > 0)) {
11660 Session session = null;
11661
11662 try {
11663 session = openSession();
11664
11665 if (session.isDirty()) {
11666 session.flush();
11667 }
11668
11669 SQLQuery selectQuery = session.createSQLQuery(
11670 "SELECT categoryId FROM AssetCategory WHERE groupId = ? AND parentCategoryId = ? ORDER BY categoryId ASC");
11671
11672 selectQuery.addScalar("categoryId",
11673 com.liferay.portal.kernel.dao.orm.Type.LONG);
11674
11675 SQLQuery updateQuery = session.createSQLQuery(
11676 "UPDATE AssetCategory SET leftCategoryId = ?, rightCategoryId = ? WHERE categoryId = ?");
11677
11678 rebuildTree(session, selectQuery, updateQuery, groupId, 0, 0);
11679 }
11680 catch (Exception e) {
11681 throw processException(e);
11682 }
11683 finally {
11684 closeSession(session);
11685 }
11686
11687 clearCache();
11688 }
11689 }
11690
11691 @Override
11692 public void setRebuildTreeEnabled(boolean rebuildTreeEnabled) {
11693 this.rebuildTreeEnabled = rebuildTreeEnabled;
11694 }
11695
11696 protected long countOrphanTreeNodes(long groupId) {
11697 Session session = null;
11698
11699 try {
11700 session = openSession();
11701
11702 SQLQuery q = session.createSynchronizedSQLQuery(
11703 "SELECT COUNT(*) AS COUNT_VALUE FROM AssetCategory WHERE groupId = ? AND (leftCategoryId = 0 OR leftCategoryId IS NULL OR rightCategoryId = 0 OR rightCategoryId IS NULL)");
11704
11705 q.addScalar(COUNT_COLUMN_NAME,
11706 com.liferay.portal.kernel.dao.orm.Type.LONG);
11707
11708 QueryPos qPos = QueryPos.getInstance(q);
11709
11710 qPos.add(groupId);
11711
11712 return (Long)q.uniqueResult();
11713 }
11714 catch (Exception e) {
11715 throw processException(e);
11716 }
11717 finally {
11718 closeSession(session);
11719 }
11720 }
11721
11722 protected long rebuildTree(Session session, SQLQuery selectQuery,
11723 SQLQuery updateQuery, long groupId, long parentCategoryId,
11724 long leftCategoryId) {
11725 long rightCategoryId = leftCategoryId + 1;
11726
11727 QueryPos qPos = QueryPos.getInstance(selectQuery);
11728
11729 qPos.add(groupId);
11730 qPos.add(parentCategoryId);
11731
11732 List<Long> categoryIds = selectQuery.list();
11733
11734 for (long categoryId : categoryIds) {
11735 rightCategoryId = rebuildTree(session, selectQuery, updateQuery,
11736 groupId, categoryId, rightCategoryId);
11737 }
11738
11739 if (parentCategoryId > 0) {
11740 qPos = QueryPos.getInstance(updateQuery);
11741
11742 qPos.add(leftCategoryId);
11743 qPos.add(rightCategoryId);
11744 qPos.add(parentCategoryId);
11745
11746 updateQuery.executeUpdate();
11747 }
11748
11749 return rightCategoryId + 1;
11750 }
11751
11752
11755 public void afterPropertiesSet() {
11756 assetCategoryToAssetEntryTableMapper = TableMapperFactory.getTableMapper("AssetEntries_AssetCategories",
11757 "categoryId", "entryId", this, assetEntryPersistence);
11758
11759 updateTree = new UpdateTree();
11760 }
11761
11762 public void destroy() {
11763 EntityCacheUtil.removeCache(AssetCategoryImpl.class.getName());
11764 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
11765 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
11766 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
11767
11768 TableMapperFactory.removeTableMapper("AssetEntries_AssetCategories");
11769 }
11770
11771 @BeanReference(type = AssetEntryPersistence.class)
11772 protected AssetEntryPersistence assetEntryPersistence;
11773 protected TableMapper<AssetCategory, com.liferay.portlet.asset.model.AssetEntry> assetCategoryToAssetEntryTableMapper;
11774 protected NestedSetsTreeManager<AssetCategory> nestedSetsTreeManager = new PersistenceNestedSetsTreeManager<AssetCategory>(this,
11775 "AssetCategory", "AssetCategory", AssetCategoryImpl.class,
11776 "categoryId", "groupId", "leftCategoryId", "rightCategoryId");
11777 protected boolean rebuildTreeEnabled = true;
11778 protected UpdateTree updateTree;
11779
11780 protected class UpdateTree {
11781 protected UpdateTree() {
11782 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
11783 "UPDATE AssetCategory SET leftCategoryId = ?, rightCategoryId = ? WHERE categoryId = ?",
11784 new int[] {
11785 java.sql.Types.BIGINT, java.sql.Types.BIGINT,
11786 java.sql.Types.BIGINT
11787 });
11788 }
11789
11790 protected void update(long categoryId, long leftCategoryId,
11791 long rightCategoryId) {
11792 _sqlUpdate.update(new Object[] {
11793 leftCategoryId, rightCategoryId, categoryId
11794 });
11795 }
11796
11797 private SqlUpdate _sqlUpdate;
11798 }
11799
11800 private static final String _SQL_SELECT_ASSETCATEGORY = "SELECT assetCategory FROM AssetCategory assetCategory";
11801 private static final String _SQL_SELECT_ASSETCATEGORY_WHERE_PKS_IN = "SELECT assetCategory FROM AssetCategory assetCategory WHERE categoryId IN (";
11802 private static final String _SQL_SELECT_ASSETCATEGORY_WHERE = "SELECT assetCategory FROM AssetCategory assetCategory WHERE ";
11803 private static final String _SQL_COUNT_ASSETCATEGORY = "SELECT COUNT(assetCategory) FROM AssetCategory assetCategory";
11804 private static final String _SQL_COUNT_ASSETCATEGORY_WHERE = "SELECT COUNT(assetCategory) FROM AssetCategory assetCategory WHERE ";
11805 private static final String _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN = "assetCategory.categoryId";
11806 private static final String _FILTER_SQL_SELECT_ASSETCATEGORY_WHERE = "SELECT DISTINCT {assetCategory.*} FROM AssetCategory assetCategory WHERE ";
11807 private static final String _FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_1 =
11808 "SELECT {AssetCategory.*} FROM (SELECT DISTINCT assetCategory.categoryId FROM AssetCategory assetCategory WHERE ";
11809 private static final String _FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_2 =
11810 ") TEMP_TABLE INNER JOIN AssetCategory ON TEMP_TABLE.categoryId = AssetCategory.categoryId";
11811 private static final String _FILTER_SQL_COUNT_ASSETCATEGORY_WHERE = "SELECT COUNT(DISTINCT assetCategory.categoryId) AS COUNT_VALUE FROM AssetCategory assetCategory WHERE ";
11812 private static final String _FILTER_ENTITY_ALIAS = "assetCategory";
11813 private static final String _FILTER_ENTITY_TABLE = "AssetCategory";
11814 private static final String _ORDER_BY_ENTITY_ALIAS = "assetCategory.";
11815 private static final String _ORDER_BY_ENTITY_TABLE = "AssetCategory.";
11816 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No AssetCategory exists with the primary key ";
11817 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No AssetCategory exists with the key {";
11818 private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
11819 private static final Log _log = LogFactoryUtil.getLog(AssetCategoryPersistenceImpl.class);
11820 private static final Set<String> _badColumnNames = SetUtil.fromArray(new String[] {
11821 "uuid"
11822 });
11823 private static final AssetCategory _nullAssetCategory = new AssetCategoryImpl() {
11824 @Override
11825 public Object clone() {
11826 return this;
11827 }
11828
11829 @Override
11830 public CacheModel<AssetCategory> toCacheModel() {
11831 return _nullAssetCategoryCacheModel;
11832 }
11833 };
11834
11835 private static final CacheModel<AssetCategory> _nullAssetCategoryCacheModel = new CacheModel<AssetCategory>() {
11836 @Override
11837 public AssetCategory toEntityModel() {
11838 return _nullAssetCategory;
11839 }
11840 };
11841 }