001
014
015 package com.liferay.portlet.asset.service.persistence;
016
017 import com.liferay.portal.kernel.bean.BeanReference;
018 import com.liferay.portal.kernel.cache.CacheRegistryUtil;
019 import com.liferay.portal.kernel.dao.jdbc.MappingSqlQuery;
020 import com.liferay.portal.kernel.dao.jdbc.MappingSqlQueryFactoryUtil;
021 import com.liferay.portal.kernel.dao.jdbc.RowMapper;
022 import com.liferay.portal.kernel.dao.jdbc.SqlUpdate;
023 import com.liferay.portal.kernel.dao.jdbc.SqlUpdateFactoryUtil;
024 import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
025 import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
026 import com.liferay.portal.kernel.dao.orm.FinderPath;
027 import com.liferay.portal.kernel.dao.orm.Query;
028 import com.liferay.portal.kernel.dao.orm.QueryPos;
029 import com.liferay.portal.kernel.dao.orm.QueryUtil;
030 import com.liferay.portal.kernel.dao.orm.SQLQuery;
031 import com.liferay.portal.kernel.dao.orm.Session;
032 import com.liferay.portal.kernel.exception.SystemException;
033 import com.liferay.portal.kernel.log.Log;
034 import com.liferay.portal.kernel.log.LogFactoryUtil;
035 import com.liferay.portal.kernel.util.ArrayUtil;
036 import com.liferay.portal.kernel.util.GetterUtil;
037 import com.liferay.portal.kernel.util.InstanceFactory;
038 import com.liferay.portal.kernel.util.OrderByComparator;
039 import com.liferay.portal.kernel.util.SetUtil;
040 import com.liferay.portal.kernel.util.StringBundler;
041 import com.liferay.portal.kernel.util.StringPool;
042 import com.liferay.portal.kernel.util.StringUtil;
043 import com.liferay.portal.kernel.util.UnmodifiableList;
044 import com.liferay.portal.kernel.util.Validator;
045 import com.liferay.portal.kernel.uuid.PortalUUIDUtil;
046 import com.liferay.portal.model.CacheModel;
047 import com.liferay.portal.model.ModelListener;
048 import com.liferay.portal.security.permission.InlineSQLHelperUtil;
049 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
050
051 import com.liferay.portlet.asset.NoSuchCategoryException;
052 import com.liferay.portlet.asset.model.AssetCategory;
053 import com.liferay.portlet.asset.model.impl.AssetCategoryImpl;
054 import com.liferay.portlet.asset.model.impl.AssetCategoryModelImpl;
055
056 import java.io.Serializable;
057
058 import java.util.ArrayList;
059 import java.util.Collections;
060 import java.util.List;
061 import java.util.Set;
062
063
075 public class AssetCategoryPersistenceImpl extends BasePersistenceImpl<AssetCategory>
076 implements AssetCategoryPersistence {
077
082 public static final String FINDER_CLASS_NAME_ENTITY = AssetCategoryImpl.class.getName();
083 public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
084 ".List1";
085 public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
086 ".List2";
087 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
088 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
089 AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
090 "findAll", new String[0]);
091 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
092 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
093 AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
094 "findAll", new String[0]);
095 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
096 AssetCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class,
097 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
098 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
099 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
100 AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
101 "findByUuid",
102 new String[] {
103 String.class.getName(),
104
105 Integer.class.getName(), Integer.class.getName(),
106 OrderByComparator.class.getName()
107 });
108 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
109 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
110 AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
111 "findByUuid", new String[] { String.class.getName() },
112 AssetCategoryModelImpl.UUID_COLUMN_BITMASK |
113 AssetCategoryModelImpl.NAME_COLUMN_BITMASK);
114 public static final FinderPath FINDER_PATH_COUNT_BY_UUID = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
115 AssetCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class,
116 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid",
117 new String[] { String.class.getName() });
118
119
126 public List<AssetCategory> findByUuid(String uuid)
127 throws SystemException {
128 return findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
129 }
130
131
144 public List<AssetCategory> findByUuid(String uuid, int start, int end)
145 throws SystemException {
146 return findByUuid(uuid, start, end, null);
147 }
148
149
163 public List<AssetCategory> findByUuid(String uuid, int start, int end,
164 OrderByComparator orderByComparator) throws SystemException {
165 boolean pagination = true;
166 FinderPath finderPath = null;
167 Object[] finderArgs = null;
168
169 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
170 (orderByComparator == null)) {
171 pagination = false;
172 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID;
173 finderArgs = new Object[] { uuid };
174 }
175 else {
176 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID;
177 finderArgs = new Object[] { uuid, start, end, orderByComparator };
178 }
179
180 List<AssetCategory> list = (List<AssetCategory>)FinderCacheUtil.getResult(finderPath,
181 finderArgs, this);
182
183 if ((list != null) && !list.isEmpty()) {
184 for (AssetCategory assetCategory : list) {
185 if (!Validator.equals(uuid, assetCategory.getUuid())) {
186 list = null;
187
188 break;
189 }
190 }
191 }
192
193 if (list == null) {
194 StringBundler query = null;
195
196 if (orderByComparator != null) {
197 query = new StringBundler(3 +
198 (orderByComparator.getOrderByFields().length * 3));
199 }
200 else {
201 query = new StringBundler(3);
202 }
203
204 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
205
206 boolean bindUuid = false;
207
208 if (uuid == null) {
209 query.append(_FINDER_COLUMN_UUID_UUID_1);
210 }
211 else if (uuid.equals(StringPool.BLANK)) {
212 query.append(_FINDER_COLUMN_UUID_UUID_3);
213 }
214 else {
215 bindUuid = true;
216
217 query.append(_FINDER_COLUMN_UUID_UUID_2);
218 }
219
220 if (orderByComparator != null) {
221 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
222 orderByComparator);
223 }
224 else
225 if (pagination) {
226 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
227 }
228
229 String sql = query.toString();
230
231 Session session = null;
232
233 try {
234 session = openSession();
235
236 Query q = session.createQuery(sql);
237
238 QueryPos qPos = QueryPos.getInstance(q);
239
240 if (bindUuid) {
241 qPos.add(uuid);
242 }
243
244 if (!pagination) {
245 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
246 start, end, false);
247
248 Collections.sort(list);
249
250 list = new UnmodifiableList<AssetCategory>(list);
251 }
252 else {
253 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
254 start, end);
255 }
256
257 cacheResult(list);
258
259 FinderCacheUtil.putResult(finderPath, finderArgs, list);
260 }
261 catch (Exception e) {
262 FinderCacheUtil.removeResult(finderPath, finderArgs);
263
264 throw processException(e);
265 }
266 finally {
267 closeSession(session);
268 }
269 }
270
271 return list;
272 }
273
274
283 public AssetCategory findByUuid_First(String uuid,
284 OrderByComparator orderByComparator)
285 throws NoSuchCategoryException, SystemException {
286 AssetCategory assetCategory = fetchByUuid_First(uuid, orderByComparator);
287
288 if (assetCategory != null) {
289 return assetCategory;
290 }
291
292 StringBundler msg = new StringBundler(4);
293
294 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
295
296 msg.append("uuid=");
297 msg.append(uuid);
298
299 msg.append(StringPool.CLOSE_CURLY_BRACE);
300
301 throw new NoSuchCategoryException(msg.toString());
302 }
303
304
312 public AssetCategory fetchByUuid_First(String uuid,
313 OrderByComparator orderByComparator) throws SystemException {
314 List<AssetCategory> list = findByUuid(uuid, 0, 1, orderByComparator);
315
316 if (!list.isEmpty()) {
317 return list.get(0);
318 }
319
320 return null;
321 }
322
323
332 public AssetCategory findByUuid_Last(String uuid,
333 OrderByComparator orderByComparator)
334 throws NoSuchCategoryException, SystemException {
335 AssetCategory assetCategory = fetchByUuid_Last(uuid, orderByComparator);
336
337 if (assetCategory != null) {
338 return assetCategory;
339 }
340
341 StringBundler msg = new StringBundler(4);
342
343 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
344
345 msg.append("uuid=");
346 msg.append(uuid);
347
348 msg.append(StringPool.CLOSE_CURLY_BRACE);
349
350 throw new NoSuchCategoryException(msg.toString());
351 }
352
353
361 public AssetCategory fetchByUuid_Last(String uuid,
362 OrderByComparator orderByComparator) throws SystemException {
363 int count = countByUuid(uuid);
364
365 List<AssetCategory> list = findByUuid(uuid, count - 1, count,
366 orderByComparator);
367
368 if (!list.isEmpty()) {
369 return list.get(0);
370 }
371
372 return null;
373 }
374
375
385 public AssetCategory[] findByUuid_PrevAndNext(long categoryId, String uuid,
386 OrderByComparator orderByComparator)
387 throws NoSuchCategoryException, SystemException {
388 AssetCategory assetCategory = findByPrimaryKey(categoryId);
389
390 Session session = null;
391
392 try {
393 session = openSession();
394
395 AssetCategory[] array = new AssetCategoryImpl[3];
396
397 array[0] = getByUuid_PrevAndNext(session, assetCategory, uuid,
398 orderByComparator, true);
399
400 array[1] = assetCategory;
401
402 array[2] = getByUuid_PrevAndNext(session, assetCategory, uuid,
403 orderByComparator, false);
404
405 return array;
406 }
407 catch (Exception e) {
408 throw processException(e);
409 }
410 finally {
411 closeSession(session);
412 }
413 }
414
415 protected AssetCategory getByUuid_PrevAndNext(Session session,
416 AssetCategory assetCategory, String uuid,
417 OrderByComparator orderByComparator, boolean previous) {
418 StringBundler query = null;
419
420 if (orderByComparator != null) {
421 query = new StringBundler(6 +
422 (orderByComparator.getOrderByFields().length * 6));
423 }
424 else {
425 query = new StringBundler(3);
426 }
427
428 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
429
430 boolean bindUuid = false;
431
432 if (uuid == null) {
433 query.append(_FINDER_COLUMN_UUID_UUID_1);
434 }
435 else if (uuid.equals(StringPool.BLANK)) {
436 query.append(_FINDER_COLUMN_UUID_UUID_3);
437 }
438 else {
439 bindUuid = true;
440
441 query.append(_FINDER_COLUMN_UUID_UUID_2);
442 }
443
444 if (orderByComparator != null) {
445 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
446
447 if (orderByConditionFields.length > 0) {
448 query.append(WHERE_AND);
449 }
450
451 for (int i = 0; i < orderByConditionFields.length; i++) {
452 query.append(_ORDER_BY_ENTITY_ALIAS);
453 query.append(orderByConditionFields[i]);
454
455 if ((i + 1) < orderByConditionFields.length) {
456 if (orderByComparator.isAscending() ^ previous) {
457 query.append(WHERE_GREATER_THAN_HAS_NEXT);
458 }
459 else {
460 query.append(WHERE_LESSER_THAN_HAS_NEXT);
461 }
462 }
463 else {
464 if (orderByComparator.isAscending() ^ previous) {
465 query.append(WHERE_GREATER_THAN);
466 }
467 else {
468 query.append(WHERE_LESSER_THAN);
469 }
470 }
471 }
472
473 query.append(ORDER_BY_CLAUSE);
474
475 String[] orderByFields = orderByComparator.getOrderByFields();
476
477 for (int i = 0; i < orderByFields.length; i++) {
478 query.append(_ORDER_BY_ENTITY_ALIAS);
479 query.append(orderByFields[i]);
480
481 if ((i + 1) < orderByFields.length) {
482 if (orderByComparator.isAscending() ^ previous) {
483 query.append(ORDER_BY_ASC_HAS_NEXT);
484 }
485 else {
486 query.append(ORDER_BY_DESC_HAS_NEXT);
487 }
488 }
489 else {
490 if (orderByComparator.isAscending() ^ previous) {
491 query.append(ORDER_BY_ASC);
492 }
493 else {
494 query.append(ORDER_BY_DESC);
495 }
496 }
497 }
498 }
499 else {
500 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
501 }
502
503 String sql = query.toString();
504
505 Query q = session.createQuery(sql);
506
507 q.setFirstResult(0);
508 q.setMaxResults(2);
509
510 QueryPos qPos = QueryPos.getInstance(q);
511
512 if (bindUuid) {
513 qPos.add(uuid);
514 }
515
516 if (orderByComparator != null) {
517 Object[] values = orderByComparator.getOrderByConditionValues(assetCategory);
518
519 for (Object value : values) {
520 qPos.add(value);
521 }
522 }
523
524 List<AssetCategory> list = q.list();
525
526 if (list.size() == 2) {
527 return list.get(1);
528 }
529 else {
530 return null;
531 }
532 }
533
534
540 public void removeByUuid(String uuid) throws SystemException {
541 for (AssetCategory assetCategory : findByUuid(uuid, QueryUtil.ALL_POS,
542 QueryUtil.ALL_POS, null)) {
543 remove(assetCategory);
544 }
545 }
546
547
554 public int countByUuid(String uuid) throws SystemException {
555 FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID;
556
557 Object[] finderArgs = new Object[] { uuid };
558
559 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
560 this);
561
562 if (count == null) {
563 StringBundler query = new StringBundler(2);
564
565 query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
566
567 boolean bindUuid = false;
568
569 if (uuid == null) {
570 query.append(_FINDER_COLUMN_UUID_UUID_1);
571 }
572 else if (uuid.equals(StringPool.BLANK)) {
573 query.append(_FINDER_COLUMN_UUID_UUID_3);
574 }
575 else {
576 bindUuid = true;
577
578 query.append(_FINDER_COLUMN_UUID_UUID_2);
579 }
580
581 String sql = query.toString();
582
583 Session session = null;
584
585 try {
586 session = openSession();
587
588 Query q = session.createQuery(sql);
589
590 QueryPos qPos = QueryPos.getInstance(q);
591
592 if (bindUuid) {
593 qPos.add(uuid);
594 }
595
596 count = (Long)q.uniqueResult();
597
598 FinderCacheUtil.putResult(finderPath, finderArgs, count);
599 }
600 catch (Exception e) {
601 FinderCacheUtil.removeResult(finderPath, finderArgs);
602
603 throw processException(e);
604 }
605 finally {
606 closeSession(session);
607 }
608 }
609
610 return count.intValue();
611 }
612
613 private static final String _FINDER_COLUMN_UUID_UUID_1 = "assetCategory.uuid IS NULL";
614 private static final String _FINDER_COLUMN_UUID_UUID_2 = "assetCategory.uuid = ?";
615 private static final String _FINDER_COLUMN_UUID_UUID_3 = "(assetCategory.uuid IS NULL OR assetCategory.uuid = '')";
616 public static final FinderPath FINDER_PATH_FETCH_BY_UUID_G = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
617 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
618 AssetCategoryImpl.class, FINDER_CLASS_NAME_ENTITY, "fetchByUUID_G",
619 new String[] { String.class.getName(), Long.class.getName() },
620 AssetCategoryModelImpl.UUID_COLUMN_BITMASK |
621 AssetCategoryModelImpl.GROUPID_COLUMN_BITMASK);
622 public static final FinderPath FINDER_PATH_COUNT_BY_UUID_G = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
623 AssetCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class,
624 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUUID_G",
625 new String[] { String.class.getName(), Long.class.getName() });
626
627
636 public AssetCategory findByUUID_G(String uuid, long groupId)
637 throws NoSuchCategoryException, SystemException {
638 AssetCategory assetCategory = fetchByUUID_G(uuid, groupId);
639
640 if (assetCategory == null) {
641 StringBundler msg = new StringBundler(6);
642
643 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
644
645 msg.append("uuid=");
646 msg.append(uuid);
647
648 msg.append(", groupId=");
649 msg.append(groupId);
650
651 msg.append(StringPool.CLOSE_CURLY_BRACE);
652
653 if (_log.isWarnEnabled()) {
654 _log.warn(msg.toString());
655 }
656
657 throw new NoSuchCategoryException(msg.toString());
658 }
659
660 return assetCategory;
661 }
662
663
671 public AssetCategory fetchByUUID_G(String uuid, long groupId)
672 throws SystemException {
673 return fetchByUUID_G(uuid, groupId, true);
674 }
675
676
685 public AssetCategory fetchByUUID_G(String uuid, long groupId,
686 boolean retrieveFromCache) throws SystemException {
687 Object[] finderArgs = new Object[] { uuid, groupId };
688
689 Object result = null;
690
691 if (retrieveFromCache) {
692 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_UUID_G,
693 finderArgs, this);
694 }
695
696 if (result instanceof AssetCategory) {
697 AssetCategory assetCategory = (AssetCategory)result;
698
699 if (!Validator.equals(uuid, assetCategory.getUuid()) ||
700 (groupId != assetCategory.getGroupId())) {
701 result = null;
702 }
703 }
704
705 if (result == null) {
706 StringBundler query = new StringBundler(4);
707
708 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
709
710 boolean bindUuid = false;
711
712 if (uuid == null) {
713 query.append(_FINDER_COLUMN_UUID_G_UUID_1);
714 }
715 else if (uuid.equals(StringPool.BLANK)) {
716 query.append(_FINDER_COLUMN_UUID_G_UUID_3);
717 }
718 else {
719 bindUuid = true;
720
721 query.append(_FINDER_COLUMN_UUID_G_UUID_2);
722 }
723
724 query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
725
726 String sql = query.toString();
727
728 Session session = null;
729
730 try {
731 session = openSession();
732
733 Query q = session.createQuery(sql);
734
735 QueryPos qPos = QueryPos.getInstance(q);
736
737 if (bindUuid) {
738 qPos.add(uuid);
739 }
740
741 qPos.add(groupId);
742
743 List<AssetCategory> list = q.list();
744
745 if (list.isEmpty()) {
746 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
747 finderArgs, list);
748 }
749 else {
750 AssetCategory assetCategory = list.get(0);
751
752 result = assetCategory;
753
754 cacheResult(assetCategory);
755
756 if ((assetCategory.getUuid() == null) ||
757 !assetCategory.getUuid().equals(uuid) ||
758 (assetCategory.getGroupId() != groupId)) {
759 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
760 finderArgs, assetCategory);
761 }
762 }
763 }
764 catch (Exception e) {
765 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
766 finderArgs);
767
768 throw processException(e);
769 }
770 finally {
771 closeSession(session);
772 }
773 }
774
775 if (result instanceof List<?>) {
776 return null;
777 }
778 else {
779 return (AssetCategory)result;
780 }
781 }
782
783
791 public AssetCategory removeByUUID_G(String uuid, long groupId)
792 throws NoSuchCategoryException, SystemException {
793 AssetCategory assetCategory = findByUUID_G(uuid, groupId);
794
795 return remove(assetCategory);
796 }
797
798
806 public int countByUUID_G(String uuid, long groupId)
807 throws SystemException {
808 FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID_G;
809
810 Object[] finderArgs = new Object[] { uuid, groupId };
811
812 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
813 this);
814
815 if (count == null) {
816 StringBundler query = new StringBundler(3);
817
818 query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
819
820 boolean bindUuid = false;
821
822 if (uuid == null) {
823 query.append(_FINDER_COLUMN_UUID_G_UUID_1);
824 }
825 else if (uuid.equals(StringPool.BLANK)) {
826 query.append(_FINDER_COLUMN_UUID_G_UUID_3);
827 }
828 else {
829 bindUuid = true;
830
831 query.append(_FINDER_COLUMN_UUID_G_UUID_2);
832 }
833
834 query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
835
836 String sql = query.toString();
837
838 Session session = null;
839
840 try {
841 session = openSession();
842
843 Query q = session.createQuery(sql);
844
845 QueryPos qPos = QueryPos.getInstance(q);
846
847 if (bindUuid) {
848 qPos.add(uuid);
849 }
850
851 qPos.add(groupId);
852
853 count = (Long)q.uniqueResult();
854
855 FinderCacheUtil.putResult(finderPath, finderArgs, count);
856 }
857 catch (Exception e) {
858 FinderCacheUtil.removeResult(finderPath, finderArgs);
859
860 throw processException(e);
861 }
862 finally {
863 closeSession(session);
864 }
865 }
866
867 return count.intValue();
868 }
869
870 private static final String _FINDER_COLUMN_UUID_G_UUID_1 = "assetCategory.uuid IS NULL AND ";
871 private static final String _FINDER_COLUMN_UUID_G_UUID_2 = "assetCategory.uuid = ? AND ";
872 private static final String _FINDER_COLUMN_UUID_G_UUID_3 = "(assetCategory.uuid IS NULL OR assetCategory.uuid = '') AND ";
873 private static final String _FINDER_COLUMN_UUID_G_GROUPID_2 = "assetCategory.groupId = ?";
874 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID_C = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
875 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
876 AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
877 "findByUuid_C",
878 new String[] {
879 String.class.getName(), Long.class.getName(),
880
881 Integer.class.getName(), Integer.class.getName(),
882 OrderByComparator.class.getName()
883 });
884 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C =
885 new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
886 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
887 AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
888 "findByUuid_C",
889 new String[] { String.class.getName(), Long.class.getName() },
890 AssetCategoryModelImpl.UUID_COLUMN_BITMASK |
891 AssetCategoryModelImpl.COMPANYID_COLUMN_BITMASK |
892 AssetCategoryModelImpl.NAME_COLUMN_BITMASK);
893 public static final FinderPath FINDER_PATH_COUNT_BY_UUID_C = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
894 AssetCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class,
895 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid_C",
896 new String[] { String.class.getName(), Long.class.getName() });
897
898
906 public List<AssetCategory> findByUuid_C(String uuid, long companyId)
907 throws SystemException {
908 return findByUuid_C(uuid, companyId, QueryUtil.ALL_POS,
909 QueryUtil.ALL_POS, null);
910 }
911
912
926 public List<AssetCategory> findByUuid_C(String uuid, long companyId,
927 int start, int end) throws SystemException {
928 return findByUuid_C(uuid, companyId, start, end, null);
929 }
930
931
946 public List<AssetCategory> findByUuid_C(String uuid, long companyId,
947 int start, int end, OrderByComparator orderByComparator)
948 throws SystemException {
949 boolean pagination = true;
950 FinderPath finderPath = null;
951 Object[] finderArgs = null;
952
953 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
954 (orderByComparator == null)) {
955 pagination = false;
956 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C;
957 finderArgs = new Object[] { uuid, companyId };
958 }
959 else {
960 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID_C;
961 finderArgs = new Object[] {
962 uuid, companyId,
963
964 start, end, orderByComparator
965 };
966 }
967
968 List<AssetCategory> list = (List<AssetCategory>)FinderCacheUtil.getResult(finderPath,
969 finderArgs, this);
970
971 if ((list != null) && !list.isEmpty()) {
972 for (AssetCategory assetCategory : list) {
973 if (!Validator.equals(uuid, assetCategory.getUuid()) ||
974 (companyId != assetCategory.getCompanyId())) {
975 list = null;
976
977 break;
978 }
979 }
980 }
981
982 if (list == null) {
983 StringBundler query = null;
984
985 if (orderByComparator != null) {
986 query = new StringBundler(4 +
987 (orderByComparator.getOrderByFields().length * 3));
988 }
989 else {
990 query = new StringBundler(4);
991 }
992
993 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
994
995 boolean bindUuid = false;
996
997 if (uuid == null) {
998 query.append(_FINDER_COLUMN_UUID_C_UUID_1);
999 }
1000 else if (uuid.equals(StringPool.BLANK)) {
1001 query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1002 }
1003 else {
1004 bindUuid = true;
1005
1006 query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1007 }
1008
1009 query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1010
1011 if (orderByComparator != null) {
1012 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1013 orderByComparator);
1014 }
1015 else
1016 if (pagination) {
1017 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
1018 }
1019
1020 String sql = query.toString();
1021
1022 Session session = null;
1023
1024 try {
1025 session = openSession();
1026
1027 Query q = session.createQuery(sql);
1028
1029 QueryPos qPos = QueryPos.getInstance(q);
1030
1031 if (bindUuid) {
1032 qPos.add(uuid);
1033 }
1034
1035 qPos.add(companyId);
1036
1037 if (!pagination) {
1038 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
1039 start, end, false);
1040
1041 Collections.sort(list);
1042
1043 list = new UnmodifiableList<AssetCategory>(list);
1044 }
1045 else {
1046 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
1047 start, end);
1048 }
1049
1050 cacheResult(list);
1051
1052 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1053 }
1054 catch (Exception e) {
1055 FinderCacheUtil.removeResult(finderPath, finderArgs);
1056
1057 throw processException(e);
1058 }
1059 finally {
1060 closeSession(session);
1061 }
1062 }
1063
1064 return list;
1065 }
1066
1067
1077 public AssetCategory findByUuid_C_First(String uuid, long companyId,
1078 OrderByComparator orderByComparator)
1079 throws NoSuchCategoryException, SystemException {
1080 AssetCategory assetCategory = fetchByUuid_C_First(uuid, companyId,
1081 orderByComparator);
1082
1083 if (assetCategory != null) {
1084 return assetCategory;
1085 }
1086
1087 StringBundler msg = new StringBundler(6);
1088
1089 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1090
1091 msg.append("uuid=");
1092 msg.append(uuid);
1093
1094 msg.append(", companyId=");
1095 msg.append(companyId);
1096
1097 msg.append(StringPool.CLOSE_CURLY_BRACE);
1098
1099 throw new NoSuchCategoryException(msg.toString());
1100 }
1101
1102
1111 public AssetCategory fetchByUuid_C_First(String uuid, long companyId,
1112 OrderByComparator orderByComparator) throws SystemException {
1113 List<AssetCategory> list = findByUuid_C(uuid, companyId, 0, 1,
1114 orderByComparator);
1115
1116 if (!list.isEmpty()) {
1117 return list.get(0);
1118 }
1119
1120 return null;
1121 }
1122
1123
1133 public AssetCategory findByUuid_C_Last(String uuid, long companyId,
1134 OrderByComparator orderByComparator)
1135 throws NoSuchCategoryException, SystemException {
1136 AssetCategory assetCategory = fetchByUuid_C_Last(uuid, companyId,
1137 orderByComparator);
1138
1139 if (assetCategory != null) {
1140 return assetCategory;
1141 }
1142
1143 StringBundler msg = new StringBundler(6);
1144
1145 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1146
1147 msg.append("uuid=");
1148 msg.append(uuid);
1149
1150 msg.append(", companyId=");
1151 msg.append(companyId);
1152
1153 msg.append(StringPool.CLOSE_CURLY_BRACE);
1154
1155 throw new NoSuchCategoryException(msg.toString());
1156 }
1157
1158
1167 public AssetCategory fetchByUuid_C_Last(String uuid, long companyId,
1168 OrderByComparator orderByComparator) throws SystemException {
1169 int count = countByUuid_C(uuid, companyId);
1170
1171 List<AssetCategory> list = findByUuid_C(uuid, companyId, count - 1,
1172 count, orderByComparator);
1173
1174 if (!list.isEmpty()) {
1175 return list.get(0);
1176 }
1177
1178 return null;
1179 }
1180
1181
1192 public AssetCategory[] findByUuid_C_PrevAndNext(long categoryId,
1193 String uuid, long companyId, OrderByComparator orderByComparator)
1194 throws NoSuchCategoryException, SystemException {
1195 AssetCategory assetCategory = findByPrimaryKey(categoryId);
1196
1197 Session session = null;
1198
1199 try {
1200 session = openSession();
1201
1202 AssetCategory[] array = new AssetCategoryImpl[3];
1203
1204 array[0] = getByUuid_C_PrevAndNext(session, assetCategory, uuid,
1205 companyId, orderByComparator, true);
1206
1207 array[1] = assetCategory;
1208
1209 array[2] = getByUuid_C_PrevAndNext(session, assetCategory, uuid,
1210 companyId, orderByComparator, false);
1211
1212 return array;
1213 }
1214 catch (Exception e) {
1215 throw processException(e);
1216 }
1217 finally {
1218 closeSession(session);
1219 }
1220 }
1221
1222 protected AssetCategory getByUuid_C_PrevAndNext(Session session,
1223 AssetCategory assetCategory, String uuid, long companyId,
1224 OrderByComparator orderByComparator, boolean previous) {
1225 StringBundler query = null;
1226
1227 if (orderByComparator != null) {
1228 query = new StringBundler(6 +
1229 (orderByComparator.getOrderByFields().length * 6));
1230 }
1231 else {
1232 query = new StringBundler(3);
1233 }
1234
1235 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
1236
1237 boolean bindUuid = false;
1238
1239 if (uuid == null) {
1240 query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1241 }
1242 else if (uuid.equals(StringPool.BLANK)) {
1243 query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1244 }
1245 else {
1246 bindUuid = true;
1247
1248 query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1249 }
1250
1251 query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1252
1253 if (orderByComparator != null) {
1254 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1255
1256 if (orderByConditionFields.length > 0) {
1257 query.append(WHERE_AND);
1258 }
1259
1260 for (int i = 0; i < orderByConditionFields.length; i++) {
1261 query.append(_ORDER_BY_ENTITY_ALIAS);
1262 query.append(orderByConditionFields[i]);
1263
1264 if ((i + 1) < orderByConditionFields.length) {
1265 if (orderByComparator.isAscending() ^ previous) {
1266 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1267 }
1268 else {
1269 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1270 }
1271 }
1272 else {
1273 if (orderByComparator.isAscending() ^ previous) {
1274 query.append(WHERE_GREATER_THAN);
1275 }
1276 else {
1277 query.append(WHERE_LESSER_THAN);
1278 }
1279 }
1280 }
1281
1282 query.append(ORDER_BY_CLAUSE);
1283
1284 String[] orderByFields = orderByComparator.getOrderByFields();
1285
1286 for (int i = 0; i < orderByFields.length; i++) {
1287 query.append(_ORDER_BY_ENTITY_ALIAS);
1288 query.append(orderByFields[i]);
1289
1290 if ((i + 1) < orderByFields.length) {
1291 if (orderByComparator.isAscending() ^ previous) {
1292 query.append(ORDER_BY_ASC_HAS_NEXT);
1293 }
1294 else {
1295 query.append(ORDER_BY_DESC_HAS_NEXT);
1296 }
1297 }
1298 else {
1299 if (orderByComparator.isAscending() ^ previous) {
1300 query.append(ORDER_BY_ASC);
1301 }
1302 else {
1303 query.append(ORDER_BY_DESC);
1304 }
1305 }
1306 }
1307 }
1308 else {
1309 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
1310 }
1311
1312 String sql = query.toString();
1313
1314 Query q = session.createQuery(sql);
1315
1316 q.setFirstResult(0);
1317 q.setMaxResults(2);
1318
1319 QueryPos qPos = QueryPos.getInstance(q);
1320
1321 if (bindUuid) {
1322 qPos.add(uuid);
1323 }
1324
1325 qPos.add(companyId);
1326
1327 if (orderByComparator != null) {
1328 Object[] values = orderByComparator.getOrderByConditionValues(assetCategory);
1329
1330 for (Object value : values) {
1331 qPos.add(value);
1332 }
1333 }
1334
1335 List<AssetCategory> list = q.list();
1336
1337 if (list.size() == 2) {
1338 return list.get(1);
1339 }
1340 else {
1341 return null;
1342 }
1343 }
1344
1345
1352 public void removeByUuid_C(String uuid, long companyId)
1353 throws SystemException {
1354 for (AssetCategory assetCategory : findByUuid_C(uuid, companyId,
1355 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
1356 remove(assetCategory);
1357 }
1358 }
1359
1360
1368 public int countByUuid_C(String uuid, long companyId)
1369 throws SystemException {
1370 FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID_C;
1371
1372 Object[] finderArgs = new Object[] { uuid, companyId };
1373
1374 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
1375 this);
1376
1377 if (count == null) {
1378 StringBundler query = new StringBundler(3);
1379
1380 query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
1381
1382 boolean bindUuid = false;
1383
1384 if (uuid == null) {
1385 query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1386 }
1387 else if (uuid.equals(StringPool.BLANK)) {
1388 query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1389 }
1390 else {
1391 bindUuid = true;
1392
1393 query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1394 }
1395
1396 query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1397
1398 String sql = query.toString();
1399
1400 Session session = null;
1401
1402 try {
1403 session = openSession();
1404
1405 Query q = session.createQuery(sql);
1406
1407 QueryPos qPos = QueryPos.getInstance(q);
1408
1409 if (bindUuid) {
1410 qPos.add(uuid);
1411 }
1412
1413 qPos.add(companyId);
1414
1415 count = (Long)q.uniqueResult();
1416
1417 FinderCacheUtil.putResult(finderPath, finderArgs, count);
1418 }
1419 catch (Exception e) {
1420 FinderCacheUtil.removeResult(finderPath, finderArgs);
1421
1422 throw processException(e);
1423 }
1424 finally {
1425 closeSession(session);
1426 }
1427 }
1428
1429 return count.intValue();
1430 }
1431
1432 private static final String _FINDER_COLUMN_UUID_C_UUID_1 = "assetCategory.uuid IS NULL AND ";
1433 private static final String _FINDER_COLUMN_UUID_C_UUID_2 = "assetCategory.uuid = ? AND ";
1434 private static final String _FINDER_COLUMN_UUID_C_UUID_3 = "(assetCategory.uuid IS NULL OR assetCategory.uuid = '') AND ";
1435 private static final String _FINDER_COLUMN_UUID_C_COMPANYID_2 = "assetCategory.companyId = ?";
1436 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
1437 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
1438 AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
1439 "findByGroupId",
1440 new String[] {
1441 Long.class.getName(),
1442
1443 Integer.class.getName(), Integer.class.getName(),
1444 OrderByComparator.class.getName()
1445 });
1446 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID =
1447 new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
1448 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
1449 AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
1450 "findByGroupId", new String[] { Long.class.getName() },
1451 AssetCategoryModelImpl.GROUPID_COLUMN_BITMASK |
1452 AssetCategoryModelImpl.NAME_COLUMN_BITMASK);
1453 public static final FinderPath FINDER_PATH_COUNT_BY_GROUPID = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
1454 AssetCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class,
1455 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByGroupId",
1456 new String[] { Long.class.getName() });
1457
1458
1465 public List<AssetCategory> findByGroupId(long groupId)
1466 throws SystemException {
1467 return findByGroupId(groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1468 }
1469
1470
1483 public List<AssetCategory> findByGroupId(long groupId, int start, int end)
1484 throws SystemException {
1485 return findByGroupId(groupId, start, end, null);
1486 }
1487
1488
1502 public List<AssetCategory> findByGroupId(long groupId, int start, int end,
1503 OrderByComparator orderByComparator) throws SystemException {
1504 boolean pagination = true;
1505 FinderPath finderPath = null;
1506 Object[] finderArgs = null;
1507
1508 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1509 (orderByComparator == null)) {
1510 pagination = false;
1511 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID;
1512 finderArgs = new Object[] { groupId };
1513 }
1514 else {
1515 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID;
1516 finderArgs = new Object[] { groupId, start, end, orderByComparator };
1517 }
1518
1519 List<AssetCategory> list = (List<AssetCategory>)FinderCacheUtil.getResult(finderPath,
1520 finderArgs, this);
1521
1522 if ((list != null) && !list.isEmpty()) {
1523 for (AssetCategory assetCategory : list) {
1524 if ((groupId != assetCategory.getGroupId())) {
1525 list = null;
1526
1527 break;
1528 }
1529 }
1530 }
1531
1532 if (list == null) {
1533 StringBundler query = null;
1534
1535 if (orderByComparator != null) {
1536 query = new StringBundler(3 +
1537 (orderByComparator.getOrderByFields().length * 3));
1538 }
1539 else {
1540 query = new StringBundler(3);
1541 }
1542
1543 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
1544
1545 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1546
1547 if (orderByComparator != null) {
1548 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1549 orderByComparator);
1550 }
1551 else
1552 if (pagination) {
1553 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
1554 }
1555
1556 String sql = query.toString();
1557
1558 Session session = null;
1559
1560 try {
1561 session = openSession();
1562
1563 Query q = session.createQuery(sql);
1564
1565 QueryPos qPos = QueryPos.getInstance(q);
1566
1567 qPos.add(groupId);
1568
1569 if (!pagination) {
1570 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
1571 start, end, false);
1572
1573 Collections.sort(list);
1574
1575 list = new UnmodifiableList<AssetCategory>(list);
1576 }
1577 else {
1578 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
1579 start, end);
1580 }
1581
1582 cacheResult(list);
1583
1584 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1585 }
1586 catch (Exception e) {
1587 FinderCacheUtil.removeResult(finderPath, finderArgs);
1588
1589 throw processException(e);
1590 }
1591 finally {
1592 closeSession(session);
1593 }
1594 }
1595
1596 return list;
1597 }
1598
1599
1608 public AssetCategory findByGroupId_First(long groupId,
1609 OrderByComparator orderByComparator)
1610 throws NoSuchCategoryException, SystemException {
1611 AssetCategory assetCategory = fetchByGroupId_First(groupId,
1612 orderByComparator);
1613
1614 if (assetCategory != null) {
1615 return assetCategory;
1616 }
1617
1618 StringBundler msg = new StringBundler(4);
1619
1620 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1621
1622 msg.append("groupId=");
1623 msg.append(groupId);
1624
1625 msg.append(StringPool.CLOSE_CURLY_BRACE);
1626
1627 throw new NoSuchCategoryException(msg.toString());
1628 }
1629
1630
1638 public AssetCategory fetchByGroupId_First(long groupId,
1639 OrderByComparator orderByComparator) throws SystemException {
1640 List<AssetCategory> list = findByGroupId(groupId, 0, 1,
1641 orderByComparator);
1642
1643 if (!list.isEmpty()) {
1644 return list.get(0);
1645 }
1646
1647 return null;
1648 }
1649
1650
1659 public AssetCategory findByGroupId_Last(long groupId,
1660 OrderByComparator orderByComparator)
1661 throws NoSuchCategoryException, SystemException {
1662 AssetCategory assetCategory = fetchByGroupId_Last(groupId,
1663 orderByComparator);
1664
1665 if (assetCategory != null) {
1666 return assetCategory;
1667 }
1668
1669 StringBundler msg = new StringBundler(4);
1670
1671 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1672
1673 msg.append("groupId=");
1674 msg.append(groupId);
1675
1676 msg.append(StringPool.CLOSE_CURLY_BRACE);
1677
1678 throw new NoSuchCategoryException(msg.toString());
1679 }
1680
1681
1689 public AssetCategory fetchByGroupId_Last(long groupId,
1690 OrderByComparator orderByComparator) throws SystemException {
1691 int count = countByGroupId(groupId);
1692
1693 List<AssetCategory> list = findByGroupId(groupId, count - 1, count,
1694 orderByComparator);
1695
1696 if (!list.isEmpty()) {
1697 return list.get(0);
1698 }
1699
1700 return null;
1701 }
1702
1703
1713 public AssetCategory[] findByGroupId_PrevAndNext(long categoryId,
1714 long groupId, OrderByComparator orderByComparator)
1715 throws NoSuchCategoryException, SystemException {
1716 AssetCategory assetCategory = findByPrimaryKey(categoryId);
1717
1718 Session session = null;
1719
1720 try {
1721 session = openSession();
1722
1723 AssetCategory[] array = new AssetCategoryImpl[3];
1724
1725 array[0] = getByGroupId_PrevAndNext(session, assetCategory,
1726 groupId, orderByComparator, true);
1727
1728 array[1] = assetCategory;
1729
1730 array[2] = getByGroupId_PrevAndNext(session, assetCategory,
1731 groupId, orderByComparator, false);
1732
1733 return array;
1734 }
1735 catch (Exception e) {
1736 throw processException(e);
1737 }
1738 finally {
1739 closeSession(session);
1740 }
1741 }
1742
1743 protected AssetCategory getByGroupId_PrevAndNext(Session session,
1744 AssetCategory assetCategory, long groupId,
1745 OrderByComparator orderByComparator, boolean previous) {
1746 StringBundler query = null;
1747
1748 if (orderByComparator != null) {
1749 query = new StringBundler(6 +
1750 (orderByComparator.getOrderByFields().length * 6));
1751 }
1752 else {
1753 query = new StringBundler(3);
1754 }
1755
1756 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
1757
1758 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1759
1760 if (orderByComparator != null) {
1761 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1762
1763 if (orderByConditionFields.length > 0) {
1764 query.append(WHERE_AND);
1765 }
1766
1767 for (int i = 0; i < orderByConditionFields.length; i++) {
1768 query.append(_ORDER_BY_ENTITY_ALIAS);
1769 query.append(orderByConditionFields[i]);
1770
1771 if ((i + 1) < orderByConditionFields.length) {
1772 if (orderByComparator.isAscending() ^ previous) {
1773 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1774 }
1775 else {
1776 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1777 }
1778 }
1779 else {
1780 if (orderByComparator.isAscending() ^ previous) {
1781 query.append(WHERE_GREATER_THAN);
1782 }
1783 else {
1784 query.append(WHERE_LESSER_THAN);
1785 }
1786 }
1787 }
1788
1789 query.append(ORDER_BY_CLAUSE);
1790
1791 String[] orderByFields = orderByComparator.getOrderByFields();
1792
1793 for (int i = 0; i < orderByFields.length; i++) {
1794 query.append(_ORDER_BY_ENTITY_ALIAS);
1795 query.append(orderByFields[i]);
1796
1797 if ((i + 1) < orderByFields.length) {
1798 if (orderByComparator.isAscending() ^ previous) {
1799 query.append(ORDER_BY_ASC_HAS_NEXT);
1800 }
1801 else {
1802 query.append(ORDER_BY_DESC_HAS_NEXT);
1803 }
1804 }
1805 else {
1806 if (orderByComparator.isAscending() ^ previous) {
1807 query.append(ORDER_BY_ASC);
1808 }
1809 else {
1810 query.append(ORDER_BY_DESC);
1811 }
1812 }
1813 }
1814 }
1815 else {
1816 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
1817 }
1818
1819 String sql = query.toString();
1820
1821 Query q = session.createQuery(sql);
1822
1823 q.setFirstResult(0);
1824 q.setMaxResults(2);
1825
1826 QueryPos qPos = QueryPos.getInstance(q);
1827
1828 qPos.add(groupId);
1829
1830 if (orderByComparator != null) {
1831 Object[] values = orderByComparator.getOrderByConditionValues(assetCategory);
1832
1833 for (Object value : values) {
1834 qPos.add(value);
1835 }
1836 }
1837
1838 List<AssetCategory> list = q.list();
1839
1840 if (list.size() == 2) {
1841 return list.get(1);
1842 }
1843 else {
1844 return null;
1845 }
1846 }
1847
1848
1855 public List<AssetCategory> filterFindByGroupId(long groupId)
1856 throws SystemException {
1857 return filterFindByGroupId(groupId, QueryUtil.ALL_POS,
1858 QueryUtil.ALL_POS, null);
1859 }
1860
1861
1874 public List<AssetCategory> filterFindByGroupId(long groupId, int start,
1875 int end) throws SystemException {
1876 return filterFindByGroupId(groupId, start, end, null);
1877 }
1878
1879
1893 public List<AssetCategory> filterFindByGroupId(long groupId, int start,
1894 int end, OrderByComparator orderByComparator) throws SystemException {
1895 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
1896 return findByGroupId(groupId, start, end, orderByComparator);
1897 }
1898
1899 StringBundler query = null;
1900
1901 if (orderByComparator != null) {
1902 query = new StringBundler(3 +
1903 (orderByComparator.getOrderByFields().length * 3));
1904 }
1905 else {
1906 query = new StringBundler(3);
1907 }
1908
1909 if (getDB().isSupportsInlineDistinct()) {
1910 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_WHERE);
1911 }
1912 else {
1913 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_1);
1914 }
1915
1916 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1917
1918 if (!getDB().isSupportsInlineDistinct()) {
1919 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_2);
1920 }
1921
1922 if (orderByComparator != null) {
1923 if (getDB().isSupportsInlineDistinct()) {
1924 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1925 orderByComparator, true);
1926 }
1927 else {
1928 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
1929 orderByComparator, true);
1930 }
1931 }
1932 else {
1933 if (getDB().isSupportsInlineDistinct()) {
1934 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
1935 }
1936 else {
1937 query.append(AssetCategoryModelImpl.ORDER_BY_SQL);
1938 }
1939 }
1940
1941 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1942 AssetCategory.class.getName(),
1943 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
1944
1945 Session session = null;
1946
1947 try {
1948 session = openSession();
1949
1950 SQLQuery q = session.createSQLQuery(sql);
1951
1952 if (getDB().isSupportsInlineDistinct()) {
1953 q.addEntity(_FILTER_ENTITY_ALIAS, AssetCategoryImpl.class);
1954 }
1955 else {
1956 q.addEntity(_FILTER_ENTITY_TABLE, AssetCategoryImpl.class);
1957 }
1958
1959 QueryPos qPos = QueryPos.getInstance(q);
1960
1961 qPos.add(groupId);
1962
1963 return (List<AssetCategory>)QueryUtil.list(q, getDialect(), start,
1964 end);
1965 }
1966 catch (Exception e) {
1967 throw processException(e);
1968 }
1969 finally {
1970 closeSession(session);
1971 }
1972 }
1973
1974
1984 public AssetCategory[] filterFindByGroupId_PrevAndNext(long categoryId,
1985 long groupId, OrderByComparator orderByComparator)
1986 throws NoSuchCategoryException, SystemException {
1987 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
1988 return findByGroupId_PrevAndNext(categoryId, groupId,
1989 orderByComparator);
1990 }
1991
1992 AssetCategory assetCategory = findByPrimaryKey(categoryId);
1993
1994 Session session = null;
1995
1996 try {
1997 session = openSession();
1998
1999 AssetCategory[] array = new AssetCategoryImpl[3];
2000
2001 array[0] = filterGetByGroupId_PrevAndNext(session, assetCategory,
2002 groupId, orderByComparator, true);
2003
2004 array[1] = assetCategory;
2005
2006 array[2] = filterGetByGroupId_PrevAndNext(session, assetCategory,
2007 groupId, orderByComparator, false);
2008
2009 return array;
2010 }
2011 catch (Exception e) {
2012 throw processException(e);
2013 }
2014 finally {
2015 closeSession(session);
2016 }
2017 }
2018
2019 protected AssetCategory filterGetByGroupId_PrevAndNext(Session session,
2020 AssetCategory assetCategory, long groupId,
2021 OrderByComparator orderByComparator, boolean previous) {
2022 StringBundler query = null;
2023
2024 if (orderByComparator != null) {
2025 query = new StringBundler(6 +
2026 (orderByComparator.getOrderByFields().length * 6));
2027 }
2028 else {
2029 query = new StringBundler(3);
2030 }
2031
2032 if (getDB().isSupportsInlineDistinct()) {
2033 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_WHERE);
2034 }
2035 else {
2036 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_1);
2037 }
2038
2039 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2040
2041 if (!getDB().isSupportsInlineDistinct()) {
2042 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_2);
2043 }
2044
2045 if (orderByComparator != null) {
2046 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2047
2048 if (orderByConditionFields.length > 0) {
2049 query.append(WHERE_AND);
2050 }
2051
2052 for (int i = 0; i < orderByConditionFields.length; i++) {
2053 if (getDB().isSupportsInlineDistinct()) {
2054 query.append(_ORDER_BY_ENTITY_ALIAS);
2055 }
2056 else {
2057 query.append(_ORDER_BY_ENTITY_TABLE);
2058 }
2059
2060 query.append(orderByConditionFields[i]);
2061
2062 if ((i + 1) < orderByConditionFields.length) {
2063 if (orderByComparator.isAscending() ^ previous) {
2064 query.append(WHERE_GREATER_THAN_HAS_NEXT);
2065 }
2066 else {
2067 query.append(WHERE_LESSER_THAN_HAS_NEXT);
2068 }
2069 }
2070 else {
2071 if (orderByComparator.isAscending() ^ previous) {
2072 query.append(WHERE_GREATER_THAN);
2073 }
2074 else {
2075 query.append(WHERE_LESSER_THAN);
2076 }
2077 }
2078 }
2079
2080 query.append(ORDER_BY_CLAUSE);
2081
2082 String[] orderByFields = orderByComparator.getOrderByFields();
2083
2084 for (int i = 0; i < orderByFields.length; i++) {
2085 if (getDB().isSupportsInlineDistinct()) {
2086 query.append(_ORDER_BY_ENTITY_ALIAS);
2087 }
2088 else {
2089 query.append(_ORDER_BY_ENTITY_TABLE);
2090 }
2091
2092 query.append(orderByFields[i]);
2093
2094 if ((i + 1) < orderByFields.length) {
2095 if (orderByComparator.isAscending() ^ previous) {
2096 query.append(ORDER_BY_ASC_HAS_NEXT);
2097 }
2098 else {
2099 query.append(ORDER_BY_DESC_HAS_NEXT);
2100 }
2101 }
2102 else {
2103 if (orderByComparator.isAscending() ^ previous) {
2104 query.append(ORDER_BY_ASC);
2105 }
2106 else {
2107 query.append(ORDER_BY_DESC);
2108 }
2109 }
2110 }
2111 }
2112 else {
2113 if (getDB().isSupportsInlineDistinct()) {
2114 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
2115 }
2116 else {
2117 query.append(AssetCategoryModelImpl.ORDER_BY_SQL);
2118 }
2119 }
2120
2121 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2122 AssetCategory.class.getName(),
2123 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2124
2125 SQLQuery q = session.createSQLQuery(sql);
2126
2127 q.setFirstResult(0);
2128 q.setMaxResults(2);
2129
2130 if (getDB().isSupportsInlineDistinct()) {
2131 q.addEntity(_FILTER_ENTITY_ALIAS, AssetCategoryImpl.class);
2132 }
2133 else {
2134 q.addEntity(_FILTER_ENTITY_TABLE, AssetCategoryImpl.class);
2135 }
2136
2137 QueryPos qPos = QueryPos.getInstance(q);
2138
2139 qPos.add(groupId);
2140
2141 if (orderByComparator != null) {
2142 Object[] values = orderByComparator.getOrderByConditionValues(assetCategory);
2143
2144 for (Object value : values) {
2145 qPos.add(value);
2146 }
2147 }
2148
2149 List<AssetCategory> list = q.list();
2150
2151 if (list.size() == 2) {
2152 return list.get(1);
2153 }
2154 else {
2155 return null;
2156 }
2157 }
2158
2159
2165 public void removeByGroupId(long groupId) throws SystemException {
2166 for (AssetCategory assetCategory : findByGroupId(groupId,
2167 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
2168 remove(assetCategory);
2169 }
2170 }
2171
2172
2179 public int countByGroupId(long groupId) throws SystemException {
2180 FinderPath finderPath = FINDER_PATH_COUNT_BY_GROUPID;
2181
2182 Object[] finderArgs = new Object[] { groupId };
2183
2184 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
2185 this);
2186
2187 if (count == null) {
2188 StringBundler query = new StringBundler(2);
2189
2190 query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
2191
2192 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2193
2194 String sql = query.toString();
2195
2196 Session session = null;
2197
2198 try {
2199 session = openSession();
2200
2201 Query q = session.createQuery(sql);
2202
2203 QueryPos qPos = QueryPos.getInstance(q);
2204
2205 qPos.add(groupId);
2206
2207 count = (Long)q.uniqueResult();
2208
2209 FinderCacheUtil.putResult(finderPath, finderArgs, count);
2210 }
2211 catch (Exception e) {
2212 FinderCacheUtil.removeResult(finderPath, finderArgs);
2213
2214 throw processException(e);
2215 }
2216 finally {
2217 closeSession(session);
2218 }
2219 }
2220
2221 return count.intValue();
2222 }
2223
2224
2231 public int filterCountByGroupId(long groupId) throws SystemException {
2232 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2233 return countByGroupId(groupId);
2234 }
2235
2236 StringBundler query = new StringBundler(2);
2237
2238 query.append(_FILTER_SQL_COUNT_ASSETCATEGORY_WHERE);
2239
2240 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2241
2242 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2243 AssetCategory.class.getName(),
2244 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2245
2246 Session session = null;
2247
2248 try {
2249 session = openSession();
2250
2251 SQLQuery q = session.createSQLQuery(sql);
2252
2253 q.addScalar(COUNT_COLUMN_NAME,
2254 com.liferay.portal.kernel.dao.orm.Type.LONG);
2255
2256 QueryPos qPos = QueryPos.getInstance(q);
2257
2258 qPos.add(groupId);
2259
2260 Long count = (Long)q.uniqueResult();
2261
2262 return count.intValue();
2263 }
2264 catch (Exception e) {
2265 throw processException(e);
2266 }
2267 finally {
2268 closeSession(session);
2269 }
2270 }
2271
2272 private static final String _FINDER_COLUMN_GROUPID_GROUPID_2 = "assetCategory.groupId = ?";
2273 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_PARENTCATEGORYID =
2274 new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
2275 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
2276 AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
2277 "findByParentCategoryId",
2278 new String[] {
2279 Long.class.getName(),
2280
2281 Integer.class.getName(), Integer.class.getName(),
2282 OrderByComparator.class.getName()
2283 });
2284 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_PARENTCATEGORYID =
2285 new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
2286 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
2287 AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
2288 "findByParentCategoryId", new String[] { Long.class.getName() },
2289 AssetCategoryModelImpl.PARENTCATEGORYID_COLUMN_BITMASK |
2290 AssetCategoryModelImpl.NAME_COLUMN_BITMASK);
2291 public static final FinderPath FINDER_PATH_COUNT_BY_PARENTCATEGORYID = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
2292 AssetCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class,
2293 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
2294 "countByParentCategoryId", new String[] { Long.class.getName() });
2295
2296
2303 public List<AssetCategory> findByParentCategoryId(long parentCategoryId)
2304 throws SystemException {
2305 return findByParentCategoryId(parentCategoryId, QueryUtil.ALL_POS,
2306 QueryUtil.ALL_POS, null);
2307 }
2308
2309
2322 public List<AssetCategory> findByParentCategoryId(long parentCategoryId,
2323 int start, int end) throws SystemException {
2324 return findByParentCategoryId(parentCategoryId, start, end, null);
2325 }
2326
2327
2341 public List<AssetCategory> findByParentCategoryId(long parentCategoryId,
2342 int start, int end, OrderByComparator orderByComparator)
2343 throws SystemException {
2344 boolean pagination = true;
2345 FinderPath finderPath = null;
2346 Object[] finderArgs = null;
2347
2348 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2349 (orderByComparator == null)) {
2350 pagination = false;
2351 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_PARENTCATEGORYID;
2352 finderArgs = new Object[] { parentCategoryId };
2353 }
2354 else {
2355 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_PARENTCATEGORYID;
2356 finderArgs = new Object[] {
2357 parentCategoryId,
2358
2359 start, end, orderByComparator
2360 };
2361 }
2362
2363 List<AssetCategory> list = (List<AssetCategory>)FinderCacheUtil.getResult(finderPath,
2364 finderArgs, this);
2365
2366 if ((list != null) && !list.isEmpty()) {
2367 for (AssetCategory assetCategory : list) {
2368 if ((parentCategoryId != assetCategory.getParentCategoryId())) {
2369 list = null;
2370
2371 break;
2372 }
2373 }
2374 }
2375
2376 if (list == null) {
2377 StringBundler query = null;
2378
2379 if (orderByComparator != null) {
2380 query = new StringBundler(3 +
2381 (orderByComparator.getOrderByFields().length * 3));
2382 }
2383 else {
2384 query = new StringBundler(3);
2385 }
2386
2387 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
2388
2389 query.append(_FINDER_COLUMN_PARENTCATEGORYID_PARENTCATEGORYID_2);
2390
2391 if (orderByComparator != null) {
2392 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2393 orderByComparator);
2394 }
2395 else
2396 if (pagination) {
2397 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
2398 }
2399
2400 String sql = query.toString();
2401
2402 Session session = null;
2403
2404 try {
2405 session = openSession();
2406
2407 Query q = session.createQuery(sql);
2408
2409 QueryPos qPos = QueryPos.getInstance(q);
2410
2411 qPos.add(parentCategoryId);
2412
2413 if (!pagination) {
2414 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
2415 start, end, false);
2416
2417 Collections.sort(list);
2418
2419 list = new UnmodifiableList<AssetCategory>(list);
2420 }
2421 else {
2422 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
2423 start, end);
2424 }
2425
2426 cacheResult(list);
2427
2428 FinderCacheUtil.putResult(finderPath, finderArgs, list);
2429 }
2430 catch (Exception e) {
2431 FinderCacheUtil.removeResult(finderPath, finderArgs);
2432
2433 throw processException(e);
2434 }
2435 finally {
2436 closeSession(session);
2437 }
2438 }
2439
2440 return list;
2441 }
2442
2443
2452 public AssetCategory findByParentCategoryId_First(long parentCategoryId,
2453 OrderByComparator orderByComparator)
2454 throws NoSuchCategoryException, SystemException {
2455 AssetCategory assetCategory = fetchByParentCategoryId_First(parentCategoryId,
2456 orderByComparator);
2457
2458 if (assetCategory != null) {
2459 return assetCategory;
2460 }
2461
2462 StringBundler msg = new StringBundler(4);
2463
2464 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2465
2466 msg.append("parentCategoryId=");
2467 msg.append(parentCategoryId);
2468
2469 msg.append(StringPool.CLOSE_CURLY_BRACE);
2470
2471 throw new NoSuchCategoryException(msg.toString());
2472 }
2473
2474
2482 public AssetCategory fetchByParentCategoryId_First(long parentCategoryId,
2483 OrderByComparator orderByComparator) throws SystemException {
2484 List<AssetCategory> list = findByParentCategoryId(parentCategoryId, 0,
2485 1, orderByComparator);
2486
2487 if (!list.isEmpty()) {
2488 return list.get(0);
2489 }
2490
2491 return null;
2492 }
2493
2494
2503 public AssetCategory findByParentCategoryId_Last(long parentCategoryId,
2504 OrderByComparator orderByComparator)
2505 throws NoSuchCategoryException, SystemException {
2506 AssetCategory assetCategory = fetchByParentCategoryId_Last(parentCategoryId,
2507 orderByComparator);
2508
2509 if (assetCategory != null) {
2510 return assetCategory;
2511 }
2512
2513 StringBundler msg = new StringBundler(4);
2514
2515 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2516
2517 msg.append("parentCategoryId=");
2518 msg.append(parentCategoryId);
2519
2520 msg.append(StringPool.CLOSE_CURLY_BRACE);
2521
2522 throw new NoSuchCategoryException(msg.toString());
2523 }
2524
2525
2533 public AssetCategory fetchByParentCategoryId_Last(long parentCategoryId,
2534 OrderByComparator orderByComparator) throws SystemException {
2535 int count = countByParentCategoryId(parentCategoryId);
2536
2537 List<AssetCategory> list = findByParentCategoryId(parentCategoryId,
2538 count - 1, count, orderByComparator);
2539
2540 if (!list.isEmpty()) {
2541 return list.get(0);
2542 }
2543
2544 return null;
2545 }
2546
2547
2557 public AssetCategory[] findByParentCategoryId_PrevAndNext(long categoryId,
2558 long parentCategoryId, OrderByComparator orderByComparator)
2559 throws NoSuchCategoryException, SystemException {
2560 AssetCategory assetCategory = findByPrimaryKey(categoryId);
2561
2562 Session session = null;
2563
2564 try {
2565 session = openSession();
2566
2567 AssetCategory[] array = new AssetCategoryImpl[3];
2568
2569 array[0] = getByParentCategoryId_PrevAndNext(session,
2570 assetCategory, parentCategoryId, orderByComparator, true);
2571
2572 array[1] = assetCategory;
2573
2574 array[2] = getByParentCategoryId_PrevAndNext(session,
2575 assetCategory, parentCategoryId, orderByComparator, false);
2576
2577 return array;
2578 }
2579 catch (Exception e) {
2580 throw processException(e);
2581 }
2582 finally {
2583 closeSession(session);
2584 }
2585 }
2586
2587 protected AssetCategory getByParentCategoryId_PrevAndNext(Session session,
2588 AssetCategory assetCategory, long parentCategoryId,
2589 OrderByComparator orderByComparator, boolean previous) {
2590 StringBundler query = null;
2591
2592 if (orderByComparator != null) {
2593 query = new StringBundler(6 +
2594 (orderByComparator.getOrderByFields().length * 6));
2595 }
2596 else {
2597 query = new StringBundler(3);
2598 }
2599
2600 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
2601
2602 query.append(_FINDER_COLUMN_PARENTCATEGORYID_PARENTCATEGORYID_2);
2603
2604 if (orderByComparator != null) {
2605 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2606
2607 if (orderByConditionFields.length > 0) {
2608 query.append(WHERE_AND);
2609 }
2610
2611 for (int i = 0; i < orderByConditionFields.length; i++) {
2612 query.append(_ORDER_BY_ENTITY_ALIAS);
2613 query.append(orderByConditionFields[i]);
2614
2615 if ((i + 1) < orderByConditionFields.length) {
2616 if (orderByComparator.isAscending() ^ previous) {
2617 query.append(WHERE_GREATER_THAN_HAS_NEXT);
2618 }
2619 else {
2620 query.append(WHERE_LESSER_THAN_HAS_NEXT);
2621 }
2622 }
2623 else {
2624 if (orderByComparator.isAscending() ^ previous) {
2625 query.append(WHERE_GREATER_THAN);
2626 }
2627 else {
2628 query.append(WHERE_LESSER_THAN);
2629 }
2630 }
2631 }
2632
2633 query.append(ORDER_BY_CLAUSE);
2634
2635 String[] orderByFields = orderByComparator.getOrderByFields();
2636
2637 for (int i = 0; i < orderByFields.length; i++) {
2638 query.append(_ORDER_BY_ENTITY_ALIAS);
2639 query.append(orderByFields[i]);
2640
2641 if ((i + 1) < orderByFields.length) {
2642 if (orderByComparator.isAscending() ^ previous) {
2643 query.append(ORDER_BY_ASC_HAS_NEXT);
2644 }
2645 else {
2646 query.append(ORDER_BY_DESC_HAS_NEXT);
2647 }
2648 }
2649 else {
2650 if (orderByComparator.isAscending() ^ previous) {
2651 query.append(ORDER_BY_ASC);
2652 }
2653 else {
2654 query.append(ORDER_BY_DESC);
2655 }
2656 }
2657 }
2658 }
2659 else {
2660 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
2661 }
2662
2663 String sql = query.toString();
2664
2665 Query q = session.createQuery(sql);
2666
2667 q.setFirstResult(0);
2668 q.setMaxResults(2);
2669
2670 QueryPos qPos = QueryPos.getInstance(q);
2671
2672 qPos.add(parentCategoryId);
2673
2674 if (orderByComparator != null) {
2675 Object[] values = orderByComparator.getOrderByConditionValues(assetCategory);
2676
2677 for (Object value : values) {
2678 qPos.add(value);
2679 }
2680 }
2681
2682 List<AssetCategory> list = q.list();
2683
2684 if (list.size() == 2) {
2685 return list.get(1);
2686 }
2687 else {
2688 return null;
2689 }
2690 }
2691
2692
2698 public void removeByParentCategoryId(long parentCategoryId)
2699 throws SystemException {
2700 for (AssetCategory assetCategory : findByParentCategoryId(
2701 parentCategoryId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
2702 remove(assetCategory);
2703 }
2704 }
2705
2706
2713 public int countByParentCategoryId(long parentCategoryId)
2714 throws SystemException {
2715 FinderPath finderPath = FINDER_PATH_COUNT_BY_PARENTCATEGORYID;
2716
2717 Object[] finderArgs = new Object[] { parentCategoryId };
2718
2719 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
2720 this);
2721
2722 if (count == null) {
2723 StringBundler query = new StringBundler(2);
2724
2725 query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
2726
2727 query.append(_FINDER_COLUMN_PARENTCATEGORYID_PARENTCATEGORYID_2);
2728
2729 String sql = query.toString();
2730
2731 Session session = null;
2732
2733 try {
2734 session = openSession();
2735
2736 Query q = session.createQuery(sql);
2737
2738 QueryPos qPos = QueryPos.getInstance(q);
2739
2740 qPos.add(parentCategoryId);
2741
2742 count = (Long)q.uniqueResult();
2743
2744 FinderCacheUtil.putResult(finderPath, finderArgs, count);
2745 }
2746 catch (Exception e) {
2747 FinderCacheUtil.removeResult(finderPath, finderArgs);
2748
2749 throw processException(e);
2750 }
2751 finally {
2752 closeSession(session);
2753 }
2754 }
2755
2756 return count.intValue();
2757 }
2758
2759 private static final String _FINDER_COLUMN_PARENTCATEGORYID_PARENTCATEGORYID_2 =
2760 "assetCategory.parentCategoryId = ?";
2761 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_VOCABULARYID =
2762 new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
2763 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
2764 AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
2765 "findByVocabularyId",
2766 new String[] {
2767 Long.class.getName(),
2768
2769 Integer.class.getName(), Integer.class.getName(),
2770 OrderByComparator.class.getName()
2771 });
2772 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_VOCABULARYID =
2773 new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
2774 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
2775 AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
2776 "findByVocabularyId", new String[] { Long.class.getName() },
2777 AssetCategoryModelImpl.VOCABULARYID_COLUMN_BITMASK |
2778 AssetCategoryModelImpl.NAME_COLUMN_BITMASK);
2779 public static final FinderPath FINDER_PATH_COUNT_BY_VOCABULARYID = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
2780 AssetCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class,
2781 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByVocabularyId",
2782 new String[] { Long.class.getName() });
2783
2784
2791 public List<AssetCategory> findByVocabularyId(long vocabularyId)
2792 throws SystemException {
2793 return findByVocabularyId(vocabularyId, QueryUtil.ALL_POS,
2794 QueryUtil.ALL_POS, null);
2795 }
2796
2797
2810 public List<AssetCategory> findByVocabularyId(long vocabularyId, int start,
2811 int end) throws SystemException {
2812 return findByVocabularyId(vocabularyId, start, end, null);
2813 }
2814
2815
2829 public List<AssetCategory> findByVocabularyId(long vocabularyId, int start,
2830 int end, OrderByComparator orderByComparator) throws SystemException {
2831 boolean pagination = true;
2832 FinderPath finderPath = null;
2833 Object[] finderArgs = null;
2834
2835 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2836 (orderByComparator == null)) {
2837 pagination = false;
2838 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_VOCABULARYID;
2839 finderArgs = new Object[] { vocabularyId };
2840 }
2841 else {
2842 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_VOCABULARYID;
2843 finderArgs = new Object[] {
2844 vocabularyId,
2845
2846 start, end, orderByComparator
2847 };
2848 }
2849
2850 List<AssetCategory> list = (List<AssetCategory>)FinderCacheUtil.getResult(finderPath,
2851 finderArgs, this);
2852
2853 if ((list != null) && !list.isEmpty()) {
2854 for (AssetCategory assetCategory : list) {
2855 if ((vocabularyId != assetCategory.getVocabularyId())) {
2856 list = null;
2857
2858 break;
2859 }
2860 }
2861 }
2862
2863 if (list == null) {
2864 StringBundler query = null;
2865
2866 if (orderByComparator != null) {
2867 query = new StringBundler(3 +
2868 (orderByComparator.getOrderByFields().length * 3));
2869 }
2870 else {
2871 query = new StringBundler(3);
2872 }
2873
2874 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
2875
2876 query.append(_FINDER_COLUMN_VOCABULARYID_VOCABULARYID_2);
2877
2878 if (orderByComparator != null) {
2879 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2880 orderByComparator);
2881 }
2882 else
2883 if (pagination) {
2884 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
2885 }
2886
2887 String sql = query.toString();
2888
2889 Session session = null;
2890
2891 try {
2892 session = openSession();
2893
2894 Query q = session.createQuery(sql);
2895
2896 QueryPos qPos = QueryPos.getInstance(q);
2897
2898 qPos.add(vocabularyId);
2899
2900 if (!pagination) {
2901 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
2902 start, end, false);
2903
2904 Collections.sort(list);
2905
2906 list = new UnmodifiableList<AssetCategory>(list);
2907 }
2908 else {
2909 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
2910 start, end);
2911 }
2912
2913 cacheResult(list);
2914
2915 FinderCacheUtil.putResult(finderPath, finderArgs, list);
2916 }
2917 catch (Exception e) {
2918 FinderCacheUtil.removeResult(finderPath, finderArgs);
2919
2920 throw processException(e);
2921 }
2922 finally {
2923 closeSession(session);
2924 }
2925 }
2926
2927 return list;
2928 }
2929
2930
2939 public AssetCategory findByVocabularyId_First(long vocabularyId,
2940 OrderByComparator orderByComparator)
2941 throws NoSuchCategoryException, SystemException {
2942 AssetCategory assetCategory = fetchByVocabularyId_First(vocabularyId,
2943 orderByComparator);
2944
2945 if (assetCategory != null) {
2946 return assetCategory;
2947 }
2948
2949 StringBundler msg = new StringBundler(4);
2950
2951 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2952
2953 msg.append("vocabularyId=");
2954 msg.append(vocabularyId);
2955
2956 msg.append(StringPool.CLOSE_CURLY_BRACE);
2957
2958 throw new NoSuchCategoryException(msg.toString());
2959 }
2960
2961
2969 public AssetCategory fetchByVocabularyId_First(long vocabularyId,
2970 OrderByComparator orderByComparator) throws SystemException {
2971 List<AssetCategory> list = findByVocabularyId(vocabularyId, 0, 1,
2972 orderByComparator);
2973
2974 if (!list.isEmpty()) {
2975 return list.get(0);
2976 }
2977
2978 return null;
2979 }
2980
2981
2990 public AssetCategory findByVocabularyId_Last(long vocabularyId,
2991 OrderByComparator orderByComparator)
2992 throws NoSuchCategoryException, SystemException {
2993 AssetCategory assetCategory = fetchByVocabularyId_Last(vocabularyId,
2994 orderByComparator);
2995
2996 if (assetCategory != null) {
2997 return assetCategory;
2998 }
2999
3000 StringBundler msg = new StringBundler(4);
3001
3002 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3003
3004 msg.append("vocabularyId=");
3005 msg.append(vocabularyId);
3006
3007 msg.append(StringPool.CLOSE_CURLY_BRACE);
3008
3009 throw new NoSuchCategoryException(msg.toString());
3010 }
3011
3012
3020 public AssetCategory fetchByVocabularyId_Last(long vocabularyId,
3021 OrderByComparator orderByComparator) throws SystemException {
3022 int count = countByVocabularyId(vocabularyId);
3023
3024 List<AssetCategory> list = findByVocabularyId(vocabularyId, count - 1,
3025 count, orderByComparator);
3026
3027 if (!list.isEmpty()) {
3028 return list.get(0);
3029 }
3030
3031 return null;
3032 }
3033
3034
3044 public AssetCategory[] findByVocabularyId_PrevAndNext(long categoryId,
3045 long vocabularyId, OrderByComparator orderByComparator)
3046 throws NoSuchCategoryException, SystemException {
3047 AssetCategory assetCategory = findByPrimaryKey(categoryId);
3048
3049 Session session = null;
3050
3051 try {
3052 session = openSession();
3053
3054 AssetCategory[] array = new AssetCategoryImpl[3];
3055
3056 array[0] = getByVocabularyId_PrevAndNext(session, assetCategory,
3057 vocabularyId, orderByComparator, true);
3058
3059 array[1] = assetCategory;
3060
3061 array[2] = getByVocabularyId_PrevAndNext(session, assetCategory,
3062 vocabularyId, orderByComparator, false);
3063
3064 return array;
3065 }
3066 catch (Exception e) {
3067 throw processException(e);
3068 }
3069 finally {
3070 closeSession(session);
3071 }
3072 }
3073
3074 protected AssetCategory getByVocabularyId_PrevAndNext(Session session,
3075 AssetCategory assetCategory, long vocabularyId,
3076 OrderByComparator orderByComparator, boolean previous) {
3077 StringBundler query = null;
3078
3079 if (orderByComparator != null) {
3080 query = new StringBundler(6 +
3081 (orderByComparator.getOrderByFields().length * 6));
3082 }
3083 else {
3084 query = new StringBundler(3);
3085 }
3086
3087 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
3088
3089 query.append(_FINDER_COLUMN_VOCABULARYID_VOCABULARYID_2);
3090
3091 if (orderByComparator != null) {
3092 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3093
3094 if (orderByConditionFields.length > 0) {
3095 query.append(WHERE_AND);
3096 }
3097
3098 for (int i = 0; i < orderByConditionFields.length; i++) {
3099 query.append(_ORDER_BY_ENTITY_ALIAS);
3100 query.append(orderByConditionFields[i]);
3101
3102 if ((i + 1) < orderByConditionFields.length) {
3103 if (orderByComparator.isAscending() ^ previous) {
3104 query.append(WHERE_GREATER_THAN_HAS_NEXT);
3105 }
3106 else {
3107 query.append(WHERE_LESSER_THAN_HAS_NEXT);
3108 }
3109 }
3110 else {
3111 if (orderByComparator.isAscending() ^ previous) {
3112 query.append(WHERE_GREATER_THAN);
3113 }
3114 else {
3115 query.append(WHERE_LESSER_THAN);
3116 }
3117 }
3118 }
3119
3120 query.append(ORDER_BY_CLAUSE);
3121
3122 String[] orderByFields = orderByComparator.getOrderByFields();
3123
3124 for (int i = 0; i < orderByFields.length; i++) {
3125 query.append(_ORDER_BY_ENTITY_ALIAS);
3126 query.append(orderByFields[i]);
3127
3128 if ((i + 1) < orderByFields.length) {
3129 if (orderByComparator.isAscending() ^ previous) {
3130 query.append(ORDER_BY_ASC_HAS_NEXT);
3131 }
3132 else {
3133 query.append(ORDER_BY_DESC_HAS_NEXT);
3134 }
3135 }
3136 else {
3137 if (orderByComparator.isAscending() ^ previous) {
3138 query.append(ORDER_BY_ASC);
3139 }
3140 else {
3141 query.append(ORDER_BY_DESC);
3142 }
3143 }
3144 }
3145 }
3146 else {
3147 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
3148 }
3149
3150 String sql = query.toString();
3151
3152 Query q = session.createQuery(sql);
3153
3154 q.setFirstResult(0);
3155 q.setMaxResults(2);
3156
3157 QueryPos qPos = QueryPos.getInstance(q);
3158
3159 qPos.add(vocabularyId);
3160
3161 if (orderByComparator != null) {
3162 Object[] values = orderByComparator.getOrderByConditionValues(assetCategory);
3163
3164 for (Object value : values) {
3165 qPos.add(value);
3166 }
3167 }
3168
3169 List<AssetCategory> list = q.list();
3170
3171 if (list.size() == 2) {
3172 return list.get(1);
3173 }
3174 else {
3175 return null;
3176 }
3177 }
3178
3179
3185 public void removeByVocabularyId(long vocabularyId)
3186 throws SystemException {
3187 for (AssetCategory assetCategory : findByVocabularyId(vocabularyId,
3188 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
3189 remove(assetCategory);
3190 }
3191 }
3192
3193
3200 public int countByVocabularyId(long vocabularyId) throws SystemException {
3201 FinderPath finderPath = FINDER_PATH_COUNT_BY_VOCABULARYID;
3202
3203 Object[] finderArgs = new Object[] { vocabularyId };
3204
3205 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
3206 this);
3207
3208 if (count == null) {
3209 StringBundler query = new StringBundler(2);
3210
3211 query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
3212
3213 query.append(_FINDER_COLUMN_VOCABULARYID_VOCABULARYID_2);
3214
3215 String sql = query.toString();
3216
3217 Session session = null;
3218
3219 try {
3220 session = openSession();
3221
3222 Query q = session.createQuery(sql);
3223
3224 QueryPos qPos = QueryPos.getInstance(q);
3225
3226 qPos.add(vocabularyId);
3227
3228 count = (Long)q.uniqueResult();
3229
3230 FinderCacheUtil.putResult(finderPath, finderArgs, count);
3231 }
3232 catch (Exception e) {
3233 FinderCacheUtil.removeResult(finderPath, finderArgs);
3234
3235 throw processException(e);
3236 }
3237 finally {
3238 closeSession(session);
3239 }
3240 }
3241
3242 return count.intValue();
3243 }
3244
3245 private static final String _FINDER_COLUMN_VOCABULARYID_VOCABULARYID_2 = "assetCategory.vocabularyId = ?";
3246 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
3247 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
3248 AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
3249 "findByG_V",
3250 new String[] {
3251 Long.class.getName(), Long.class.getName(),
3252
3253 Integer.class.getName(), Integer.class.getName(),
3254 OrderByComparator.class.getName()
3255 });
3256 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
3257 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
3258 AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
3259 "findByG_V",
3260 new String[] { Long.class.getName(), Long.class.getName() },
3261 AssetCategoryModelImpl.GROUPID_COLUMN_BITMASK |
3262 AssetCategoryModelImpl.VOCABULARYID_COLUMN_BITMASK |
3263 AssetCategoryModelImpl.NAME_COLUMN_BITMASK);
3264 public static final FinderPath FINDER_PATH_COUNT_BY_G_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
3265 AssetCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class,
3266 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_V",
3267 new String[] { Long.class.getName(), Long.class.getName() });
3268 public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
3269 AssetCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class,
3270 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_V",
3271 new String[] { Long.class.getName(), Long.class.getName() });
3272
3273
3281 public List<AssetCategory> findByG_V(long groupId, long vocabularyId)
3282 throws SystemException {
3283 return findByG_V(groupId, vocabularyId, QueryUtil.ALL_POS,
3284 QueryUtil.ALL_POS, null);
3285 }
3286
3287
3301 public List<AssetCategory> findByG_V(long groupId, long vocabularyId,
3302 int start, int end) throws SystemException {
3303 return findByG_V(groupId, vocabularyId, start, end, null);
3304 }
3305
3306
3321 public List<AssetCategory> findByG_V(long groupId, long vocabularyId,
3322 int start, int end, OrderByComparator orderByComparator)
3323 throws SystemException {
3324 boolean pagination = true;
3325 FinderPath finderPath = null;
3326 Object[] finderArgs = null;
3327
3328 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
3329 (orderByComparator == null)) {
3330 pagination = false;
3331 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_V;
3332 finderArgs = new Object[] { groupId, vocabularyId };
3333 }
3334 else {
3335 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_V;
3336 finderArgs = new Object[] {
3337 groupId, vocabularyId,
3338
3339 start, end, orderByComparator
3340 };
3341 }
3342
3343 List<AssetCategory> list = (List<AssetCategory>)FinderCacheUtil.getResult(finderPath,
3344 finderArgs, this);
3345
3346 if ((list != null) && !list.isEmpty()) {
3347 for (AssetCategory assetCategory : list) {
3348 if ((groupId != assetCategory.getGroupId()) ||
3349 (vocabularyId != assetCategory.getVocabularyId())) {
3350 list = null;
3351
3352 break;
3353 }
3354 }
3355 }
3356
3357 if (list == null) {
3358 StringBundler query = null;
3359
3360 if (orderByComparator != null) {
3361 query = new StringBundler(4 +
3362 (orderByComparator.getOrderByFields().length * 3));
3363 }
3364 else {
3365 query = new StringBundler(4);
3366 }
3367
3368 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
3369
3370 query.append(_FINDER_COLUMN_G_V_GROUPID_2);
3371
3372 query.append(_FINDER_COLUMN_G_V_VOCABULARYID_2);
3373
3374 if (orderByComparator != null) {
3375 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3376 orderByComparator);
3377 }
3378 else
3379 if (pagination) {
3380 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
3381 }
3382
3383 String sql = query.toString();
3384
3385 Session session = null;
3386
3387 try {
3388 session = openSession();
3389
3390 Query q = session.createQuery(sql);
3391
3392 QueryPos qPos = QueryPos.getInstance(q);
3393
3394 qPos.add(groupId);
3395
3396 qPos.add(vocabularyId);
3397
3398 if (!pagination) {
3399 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
3400 start, end, false);
3401
3402 Collections.sort(list);
3403
3404 list = new UnmodifiableList<AssetCategory>(list);
3405 }
3406 else {
3407 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
3408 start, end);
3409 }
3410
3411 cacheResult(list);
3412
3413 FinderCacheUtil.putResult(finderPath, finderArgs, list);
3414 }
3415 catch (Exception e) {
3416 FinderCacheUtil.removeResult(finderPath, finderArgs);
3417
3418 throw processException(e);
3419 }
3420 finally {
3421 closeSession(session);
3422 }
3423 }
3424
3425 return list;
3426 }
3427
3428
3438 public AssetCategory findByG_V_First(long groupId, long vocabularyId,
3439 OrderByComparator orderByComparator)
3440 throws NoSuchCategoryException, SystemException {
3441 AssetCategory assetCategory = fetchByG_V_First(groupId, vocabularyId,
3442 orderByComparator);
3443
3444 if (assetCategory != null) {
3445 return assetCategory;
3446 }
3447
3448 StringBundler msg = new StringBundler(6);
3449
3450 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3451
3452 msg.append("groupId=");
3453 msg.append(groupId);
3454
3455 msg.append(", vocabularyId=");
3456 msg.append(vocabularyId);
3457
3458 msg.append(StringPool.CLOSE_CURLY_BRACE);
3459
3460 throw new NoSuchCategoryException(msg.toString());
3461 }
3462
3463
3472 public AssetCategory fetchByG_V_First(long groupId, long vocabularyId,
3473 OrderByComparator orderByComparator) throws SystemException {
3474 List<AssetCategory> list = findByG_V(groupId, vocabularyId, 0, 1,
3475 orderByComparator);
3476
3477 if (!list.isEmpty()) {
3478 return list.get(0);
3479 }
3480
3481 return null;
3482 }
3483
3484
3494 public AssetCategory findByG_V_Last(long groupId, long vocabularyId,
3495 OrderByComparator orderByComparator)
3496 throws NoSuchCategoryException, SystemException {
3497 AssetCategory assetCategory = fetchByG_V_Last(groupId, vocabularyId,
3498 orderByComparator);
3499
3500 if (assetCategory != null) {
3501 return assetCategory;
3502 }
3503
3504 StringBundler msg = new StringBundler(6);
3505
3506 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3507
3508 msg.append("groupId=");
3509 msg.append(groupId);
3510
3511 msg.append(", vocabularyId=");
3512 msg.append(vocabularyId);
3513
3514 msg.append(StringPool.CLOSE_CURLY_BRACE);
3515
3516 throw new NoSuchCategoryException(msg.toString());
3517 }
3518
3519
3528 public AssetCategory fetchByG_V_Last(long groupId, long vocabularyId,
3529 OrderByComparator orderByComparator) throws SystemException {
3530 int count = countByG_V(groupId, vocabularyId);
3531
3532 List<AssetCategory> list = findByG_V(groupId, vocabularyId, count - 1,
3533 count, orderByComparator);
3534
3535 if (!list.isEmpty()) {
3536 return list.get(0);
3537 }
3538
3539 return null;
3540 }
3541
3542
3553 public AssetCategory[] findByG_V_PrevAndNext(long categoryId, long groupId,
3554 long vocabularyId, OrderByComparator orderByComparator)
3555 throws NoSuchCategoryException, SystemException {
3556 AssetCategory assetCategory = findByPrimaryKey(categoryId);
3557
3558 Session session = null;
3559
3560 try {
3561 session = openSession();
3562
3563 AssetCategory[] array = new AssetCategoryImpl[3];
3564
3565 array[0] = getByG_V_PrevAndNext(session, assetCategory, groupId,
3566 vocabularyId, orderByComparator, true);
3567
3568 array[1] = assetCategory;
3569
3570 array[2] = getByG_V_PrevAndNext(session, assetCategory, groupId,
3571 vocabularyId, orderByComparator, false);
3572
3573 return array;
3574 }
3575 catch (Exception e) {
3576 throw processException(e);
3577 }
3578 finally {
3579 closeSession(session);
3580 }
3581 }
3582
3583 protected AssetCategory getByG_V_PrevAndNext(Session session,
3584 AssetCategory assetCategory, long groupId, long vocabularyId,
3585 OrderByComparator orderByComparator, boolean previous) {
3586 StringBundler query = null;
3587
3588 if (orderByComparator != null) {
3589 query = new StringBundler(6 +
3590 (orderByComparator.getOrderByFields().length * 6));
3591 }
3592 else {
3593 query = new StringBundler(3);
3594 }
3595
3596 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
3597
3598 query.append(_FINDER_COLUMN_G_V_GROUPID_2);
3599
3600 query.append(_FINDER_COLUMN_G_V_VOCABULARYID_2);
3601
3602 if (orderByComparator != null) {
3603 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3604
3605 if (orderByConditionFields.length > 0) {
3606 query.append(WHERE_AND);
3607 }
3608
3609 for (int i = 0; i < orderByConditionFields.length; i++) {
3610 query.append(_ORDER_BY_ENTITY_ALIAS);
3611 query.append(orderByConditionFields[i]);
3612
3613 if ((i + 1) < orderByConditionFields.length) {
3614 if (orderByComparator.isAscending() ^ previous) {
3615 query.append(WHERE_GREATER_THAN_HAS_NEXT);
3616 }
3617 else {
3618 query.append(WHERE_LESSER_THAN_HAS_NEXT);
3619 }
3620 }
3621 else {
3622 if (orderByComparator.isAscending() ^ previous) {
3623 query.append(WHERE_GREATER_THAN);
3624 }
3625 else {
3626 query.append(WHERE_LESSER_THAN);
3627 }
3628 }
3629 }
3630
3631 query.append(ORDER_BY_CLAUSE);
3632
3633 String[] orderByFields = orderByComparator.getOrderByFields();
3634
3635 for (int i = 0; i < orderByFields.length; i++) {
3636 query.append(_ORDER_BY_ENTITY_ALIAS);
3637 query.append(orderByFields[i]);
3638
3639 if ((i + 1) < orderByFields.length) {
3640 if (orderByComparator.isAscending() ^ previous) {
3641 query.append(ORDER_BY_ASC_HAS_NEXT);
3642 }
3643 else {
3644 query.append(ORDER_BY_DESC_HAS_NEXT);
3645 }
3646 }
3647 else {
3648 if (orderByComparator.isAscending() ^ previous) {
3649 query.append(ORDER_BY_ASC);
3650 }
3651 else {
3652 query.append(ORDER_BY_DESC);
3653 }
3654 }
3655 }
3656 }
3657 else {
3658 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
3659 }
3660
3661 String sql = query.toString();
3662
3663 Query q = session.createQuery(sql);
3664
3665 q.setFirstResult(0);
3666 q.setMaxResults(2);
3667
3668 QueryPos qPos = QueryPos.getInstance(q);
3669
3670 qPos.add(groupId);
3671
3672 qPos.add(vocabularyId);
3673
3674 if (orderByComparator != null) {
3675 Object[] values = orderByComparator.getOrderByConditionValues(assetCategory);
3676
3677 for (Object value : values) {
3678 qPos.add(value);
3679 }
3680 }
3681
3682 List<AssetCategory> list = q.list();
3683
3684 if (list.size() == 2) {
3685 return list.get(1);
3686 }
3687 else {
3688 return null;
3689 }
3690 }
3691
3692
3700 public List<AssetCategory> filterFindByG_V(long groupId, long vocabularyId)
3701 throws SystemException {
3702 return filterFindByG_V(groupId, vocabularyId, QueryUtil.ALL_POS,
3703 QueryUtil.ALL_POS, null);
3704 }
3705
3706
3720 public List<AssetCategory> filterFindByG_V(long groupId, long vocabularyId,
3721 int start, int end) throws SystemException {
3722 return filterFindByG_V(groupId, vocabularyId, start, end, null);
3723 }
3724
3725
3740 public List<AssetCategory> filterFindByG_V(long groupId, long vocabularyId,
3741 int start, int end, OrderByComparator orderByComparator)
3742 throws SystemException {
3743 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
3744 return findByG_V(groupId, vocabularyId, start, end,
3745 orderByComparator);
3746 }
3747
3748 StringBundler query = null;
3749
3750 if (orderByComparator != null) {
3751 query = new StringBundler(4 +
3752 (orderByComparator.getOrderByFields().length * 3));
3753 }
3754 else {
3755 query = new StringBundler(4);
3756 }
3757
3758 if (getDB().isSupportsInlineDistinct()) {
3759 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_WHERE);
3760 }
3761 else {
3762 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_1);
3763 }
3764
3765 query.append(_FINDER_COLUMN_G_V_GROUPID_2);
3766
3767 query.append(_FINDER_COLUMN_G_V_VOCABULARYID_2);
3768
3769 if (!getDB().isSupportsInlineDistinct()) {
3770 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_2);
3771 }
3772
3773 if (orderByComparator != null) {
3774 if (getDB().isSupportsInlineDistinct()) {
3775 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3776 orderByComparator, true);
3777 }
3778 else {
3779 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
3780 orderByComparator, true);
3781 }
3782 }
3783 else {
3784 if (getDB().isSupportsInlineDistinct()) {
3785 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
3786 }
3787 else {
3788 query.append(AssetCategoryModelImpl.ORDER_BY_SQL);
3789 }
3790 }
3791
3792 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
3793 AssetCategory.class.getName(),
3794 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
3795
3796 Session session = null;
3797
3798 try {
3799 session = openSession();
3800
3801 SQLQuery q = session.createSQLQuery(sql);
3802
3803 if (getDB().isSupportsInlineDistinct()) {
3804 q.addEntity(_FILTER_ENTITY_ALIAS, AssetCategoryImpl.class);
3805 }
3806 else {
3807 q.addEntity(_FILTER_ENTITY_TABLE, AssetCategoryImpl.class);
3808 }
3809
3810 QueryPos qPos = QueryPos.getInstance(q);
3811
3812 qPos.add(groupId);
3813
3814 qPos.add(vocabularyId);
3815
3816 return (List<AssetCategory>)QueryUtil.list(q, getDialect(), start,
3817 end);
3818 }
3819 catch (Exception e) {
3820 throw processException(e);
3821 }
3822 finally {
3823 closeSession(session);
3824 }
3825 }
3826
3827
3838 public AssetCategory[] filterFindByG_V_PrevAndNext(long categoryId,
3839 long groupId, long vocabularyId, OrderByComparator orderByComparator)
3840 throws NoSuchCategoryException, SystemException {
3841 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
3842 return findByG_V_PrevAndNext(categoryId, groupId, vocabularyId,
3843 orderByComparator);
3844 }
3845
3846 AssetCategory assetCategory = findByPrimaryKey(categoryId);
3847
3848 Session session = null;
3849
3850 try {
3851 session = openSession();
3852
3853 AssetCategory[] array = new AssetCategoryImpl[3];
3854
3855 array[0] = filterGetByG_V_PrevAndNext(session, assetCategory,
3856 groupId, vocabularyId, orderByComparator, true);
3857
3858 array[1] = assetCategory;
3859
3860 array[2] = filterGetByG_V_PrevAndNext(session, assetCategory,
3861 groupId, vocabularyId, orderByComparator, false);
3862
3863 return array;
3864 }
3865 catch (Exception e) {
3866 throw processException(e);
3867 }
3868 finally {
3869 closeSession(session);
3870 }
3871 }
3872
3873 protected AssetCategory filterGetByG_V_PrevAndNext(Session session,
3874 AssetCategory assetCategory, long groupId, long vocabularyId,
3875 OrderByComparator orderByComparator, boolean previous) {
3876 StringBundler query = null;
3877
3878 if (orderByComparator != null) {
3879 query = new StringBundler(6 +
3880 (orderByComparator.getOrderByFields().length * 6));
3881 }
3882 else {
3883 query = new StringBundler(3);
3884 }
3885
3886 if (getDB().isSupportsInlineDistinct()) {
3887 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_WHERE);
3888 }
3889 else {
3890 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_1);
3891 }
3892
3893 query.append(_FINDER_COLUMN_G_V_GROUPID_2);
3894
3895 query.append(_FINDER_COLUMN_G_V_VOCABULARYID_2);
3896
3897 if (!getDB().isSupportsInlineDistinct()) {
3898 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_2);
3899 }
3900
3901 if (orderByComparator != null) {
3902 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3903
3904 if (orderByConditionFields.length > 0) {
3905 query.append(WHERE_AND);
3906 }
3907
3908 for (int i = 0; i < orderByConditionFields.length; i++) {
3909 if (getDB().isSupportsInlineDistinct()) {
3910 query.append(_ORDER_BY_ENTITY_ALIAS);
3911 }
3912 else {
3913 query.append(_ORDER_BY_ENTITY_TABLE);
3914 }
3915
3916 query.append(orderByConditionFields[i]);
3917
3918 if ((i + 1) < orderByConditionFields.length) {
3919 if (orderByComparator.isAscending() ^ previous) {
3920 query.append(WHERE_GREATER_THAN_HAS_NEXT);
3921 }
3922 else {
3923 query.append(WHERE_LESSER_THAN_HAS_NEXT);
3924 }
3925 }
3926 else {
3927 if (orderByComparator.isAscending() ^ previous) {
3928 query.append(WHERE_GREATER_THAN);
3929 }
3930 else {
3931 query.append(WHERE_LESSER_THAN);
3932 }
3933 }
3934 }
3935
3936 query.append(ORDER_BY_CLAUSE);
3937
3938 String[] orderByFields = orderByComparator.getOrderByFields();
3939
3940 for (int i = 0; i < orderByFields.length; i++) {
3941 if (getDB().isSupportsInlineDistinct()) {
3942 query.append(_ORDER_BY_ENTITY_ALIAS);
3943 }
3944 else {
3945 query.append(_ORDER_BY_ENTITY_TABLE);
3946 }
3947
3948 query.append(orderByFields[i]);
3949
3950 if ((i + 1) < orderByFields.length) {
3951 if (orderByComparator.isAscending() ^ previous) {
3952 query.append(ORDER_BY_ASC_HAS_NEXT);
3953 }
3954 else {
3955 query.append(ORDER_BY_DESC_HAS_NEXT);
3956 }
3957 }
3958 else {
3959 if (orderByComparator.isAscending() ^ previous) {
3960 query.append(ORDER_BY_ASC);
3961 }
3962 else {
3963 query.append(ORDER_BY_DESC);
3964 }
3965 }
3966 }
3967 }
3968 else {
3969 if (getDB().isSupportsInlineDistinct()) {
3970 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
3971 }
3972 else {
3973 query.append(AssetCategoryModelImpl.ORDER_BY_SQL);
3974 }
3975 }
3976
3977 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
3978 AssetCategory.class.getName(),
3979 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
3980
3981 SQLQuery q = session.createSQLQuery(sql);
3982
3983 q.setFirstResult(0);
3984 q.setMaxResults(2);
3985
3986 if (getDB().isSupportsInlineDistinct()) {
3987 q.addEntity(_FILTER_ENTITY_ALIAS, AssetCategoryImpl.class);
3988 }
3989 else {
3990 q.addEntity(_FILTER_ENTITY_TABLE, AssetCategoryImpl.class);
3991 }
3992
3993 QueryPos qPos = QueryPos.getInstance(q);
3994
3995 qPos.add(groupId);
3996
3997 qPos.add(vocabularyId);
3998
3999 if (orderByComparator != null) {
4000 Object[] values = orderByComparator.getOrderByConditionValues(assetCategory);
4001
4002 for (Object value : values) {
4003 qPos.add(value);
4004 }
4005 }
4006
4007 List<AssetCategory> list = q.list();
4008
4009 if (list.size() == 2) {
4010 return list.get(1);
4011 }
4012 else {
4013 return null;
4014 }
4015 }
4016
4017
4025 public List<AssetCategory> filterFindByG_V(long groupId,
4026 long[] vocabularyIds) throws SystemException {
4027 return filterFindByG_V(groupId, vocabularyIds, QueryUtil.ALL_POS,
4028 QueryUtil.ALL_POS, null);
4029 }
4030
4031
4045 public List<AssetCategory> filterFindByG_V(long groupId,
4046 long[] vocabularyIds, int start, int end) throws SystemException {
4047 return filterFindByG_V(groupId, vocabularyIds, start, end, null);
4048 }
4049
4050
4065 public List<AssetCategory> filterFindByG_V(long groupId,
4066 long[] vocabularyIds, int start, int end,
4067 OrderByComparator orderByComparator) throws SystemException {
4068 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
4069 return findByG_V(groupId, vocabularyIds, start, end,
4070 orderByComparator);
4071 }
4072
4073 StringBundler query = new StringBundler();
4074
4075 if (getDB().isSupportsInlineDistinct()) {
4076 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_WHERE);
4077 }
4078 else {
4079 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_1);
4080 }
4081
4082 boolean conjunctionable = false;
4083
4084 if (conjunctionable) {
4085 query.append(WHERE_AND);
4086 }
4087
4088 query.append(_FINDER_COLUMN_G_V_GROUPID_5);
4089
4090 conjunctionable = true;
4091
4092 if ((vocabularyIds == null) || (vocabularyIds.length > 0)) {
4093 if (conjunctionable) {
4094 query.append(WHERE_AND);
4095 }
4096
4097 query.append(StringPool.OPEN_PARENTHESIS);
4098
4099 for (int i = 0; i < vocabularyIds.length; i++) {
4100 query.append(_FINDER_COLUMN_G_V_VOCABULARYID_5);
4101
4102 if ((i + 1) < vocabularyIds.length) {
4103 query.append(WHERE_OR);
4104 }
4105 }
4106
4107 query.append(StringPool.CLOSE_PARENTHESIS);
4108
4109 conjunctionable = true;
4110 }
4111
4112 if (!getDB().isSupportsInlineDistinct()) {
4113 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_2);
4114 }
4115
4116 if (orderByComparator != null) {
4117 if (getDB().isSupportsInlineDistinct()) {
4118 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4119 orderByComparator, true);
4120 }
4121 else {
4122 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
4123 orderByComparator, true);
4124 }
4125 }
4126 else {
4127 if (getDB().isSupportsInlineDistinct()) {
4128 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
4129 }
4130 else {
4131 query.append(AssetCategoryModelImpl.ORDER_BY_SQL);
4132 }
4133 }
4134
4135 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
4136 AssetCategory.class.getName(),
4137 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
4138
4139 Session session = null;
4140
4141 try {
4142 session = openSession();
4143
4144 SQLQuery q = session.createSQLQuery(sql);
4145
4146 if (getDB().isSupportsInlineDistinct()) {
4147 q.addEntity(_FILTER_ENTITY_ALIAS, AssetCategoryImpl.class);
4148 }
4149 else {
4150 q.addEntity(_FILTER_ENTITY_TABLE, AssetCategoryImpl.class);
4151 }
4152
4153 QueryPos qPos = QueryPos.getInstance(q);
4154
4155 qPos.add(groupId);
4156
4157 if (vocabularyIds != null) {
4158 qPos.add(vocabularyIds);
4159 }
4160
4161 return (List<AssetCategory>)QueryUtil.list(q, getDialect(), start,
4162 end);
4163 }
4164 catch (Exception e) {
4165 throw processException(e);
4166 }
4167 finally {
4168 closeSession(session);
4169 }
4170 }
4171
4172
4184 public List<AssetCategory> findByG_V(long groupId, long[] vocabularyIds)
4185 throws SystemException {
4186 return findByG_V(groupId, vocabularyIds, QueryUtil.ALL_POS,
4187 QueryUtil.ALL_POS, null);
4188 }
4189
4190
4204 public List<AssetCategory> findByG_V(long groupId, long[] vocabularyIds,
4205 int start, int end) throws SystemException {
4206 return findByG_V(groupId, vocabularyIds, start, end, null);
4207 }
4208
4209
4224 public List<AssetCategory> findByG_V(long groupId, long[] vocabularyIds,
4225 int start, int end, OrderByComparator orderByComparator)
4226 throws SystemException {
4227 if ((vocabularyIds != null) && (vocabularyIds.length == 1)) {
4228 return findByG_V(groupId, vocabularyIds[0], start, end,
4229 orderByComparator);
4230 }
4231
4232 boolean pagination = true;
4233 Object[] finderArgs = null;
4234
4235 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
4236 (orderByComparator == null)) {
4237 pagination = false;
4238 finderArgs = new Object[] { groupId, StringUtil.merge(vocabularyIds) };
4239 }
4240 else {
4241 finderArgs = new Object[] {
4242 groupId, StringUtil.merge(vocabularyIds),
4243
4244 start, end, orderByComparator
4245 };
4246 }
4247
4248 List<AssetCategory> list = (List<AssetCategory>)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_V,
4249 finderArgs, this);
4250
4251 if ((list != null) && !list.isEmpty()) {
4252 for (AssetCategory assetCategory : list) {
4253 if ((groupId != assetCategory.getGroupId()) ||
4254 !ArrayUtil.contains(vocabularyIds,
4255 assetCategory.getVocabularyId())) {
4256 list = null;
4257
4258 break;
4259 }
4260 }
4261 }
4262
4263 if (list == null) {
4264 StringBundler query = new StringBundler();
4265
4266 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
4267
4268 boolean conjunctionable = false;
4269
4270 if (conjunctionable) {
4271 query.append(WHERE_AND);
4272 }
4273
4274 query.append(_FINDER_COLUMN_G_V_GROUPID_5);
4275
4276 conjunctionable = true;
4277
4278 if ((vocabularyIds == null) || (vocabularyIds.length > 0)) {
4279 if (conjunctionable) {
4280 query.append(WHERE_AND);
4281 }
4282
4283 query.append(StringPool.OPEN_PARENTHESIS);
4284
4285 for (int i = 0; i < vocabularyIds.length; i++) {
4286 query.append(_FINDER_COLUMN_G_V_VOCABULARYID_5);
4287
4288 if ((i + 1) < vocabularyIds.length) {
4289 query.append(WHERE_OR);
4290 }
4291 }
4292
4293 query.append(StringPool.CLOSE_PARENTHESIS);
4294
4295 conjunctionable = true;
4296 }
4297
4298 if (orderByComparator != null) {
4299 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4300 orderByComparator);
4301 }
4302 else
4303 if (pagination) {
4304 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
4305 }
4306
4307 String sql = query.toString();
4308
4309 Session session = null;
4310
4311 try {
4312 session = openSession();
4313
4314 Query q = session.createQuery(sql);
4315
4316 QueryPos qPos = QueryPos.getInstance(q);
4317
4318 qPos.add(groupId);
4319
4320 if (vocabularyIds != null) {
4321 qPos.add(vocabularyIds);
4322 }
4323
4324 if (!pagination) {
4325 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
4326 start, end, false);
4327
4328 Collections.sort(list);
4329
4330 list = new UnmodifiableList<AssetCategory>(list);
4331 }
4332 else {
4333 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
4334 start, end);
4335 }
4336
4337 cacheResult(list);
4338
4339 FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_V,
4340 finderArgs, list);
4341 }
4342 catch (Exception e) {
4343 FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_V,
4344 finderArgs);
4345
4346 throw processException(e);
4347 }
4348 finally {
4349 closeSession(session);
4350 }
4351 }
4352
4353 return list;
4354 }
4355
4356
4363 public void removeByG_V(long groupId, long vocabularyId)
4364 throws SystemException {
4365 for (AssetCategory assetCategory : findByG_V(groupId, vocabularyId,
4366 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
4367 remove(assetCategory);
4368 }
4369 }
4370
4371
4379 public int countByG_V(long groupId, long vocabularyId)
4380 throws SystemException {
4381 FinderPath finderPath = FINDER_PATH_COUNT_BY_G_V;
4382
4383 Object[] finderArgs = new Object[] { groupId, vocabularyId };
4384
4385 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
4386 this);
4387
4388 if (count == null) {
4389 StringBundler query = new StringBundler(3);
4390
4391 query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
4392
4393 query.append(_FINDER_COLUMN_G_V_GROUPID_2);
4394
4395 query.append(_FINDER_COLUMN_G_V_VOCABULARYID_2);
4396
4397 String sql = query.toString();
4398
4399 Session session = null;
4400
4401 try {
4402 session = openSession();
4403
4404 Query q = session.createQuery(sql);
4405
4406 QueryPos qPos = QueryPos.getInstance(q);
4407
4408 qPos.add(groupId);
4409
4410 qPos.add(vocabularyId);
4411
4412 count = (Long)q.uniqueResult();
4413
4414 FinderCacheUtil.putResult(finderPath, finderArgs, count);
4415 }
4416 catch (Exception e) {
4417 FinderCacheUtil.removeResult(finderPath, finderArgs);
4418
4419 throw processException(e);
4420 }
4421 finally {
4422 closeSession(session);
4423 }
4424 }
4425
4426 return count.intValue();
4427 }
4428
4429
4437 public int countByG_V(long groupId, long[] vocabularyIds)
4438 throws SystemException {
4439 Object[] finderArgs = new Object[] {
4440 groupId, StringUtil.merge(vocabularyIds)
4441 };
4442
4443 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_V,
4444 finderArgs, this);
4445
4446 if (count == null) {
4447 StringBundler query = new StringBundler();
4448
4449 query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
4450
4451 boolean conjunctionable = false;
4452
4453 if (conjunctionable) {
4454 query.append(WHERE_AND);
4455 }
4456
4457 query.append(_FINDER_COLUMN_G_V_GROUPID_5);
4458
4459 conjunctionable = true;
4460
4461 if ((vocabularyIds == null) || (vocabularyIds.length > 0)) {
4462 if (conjunctionable) {
4463 query.append(WHERE_AND);
4464 }
4465
4466 query.append(StringPool.OPEN_PARENTHESIS);
4467
4468 for (int i = 0; i < vocabularyIds.length; i++) {
4469 query.append(_FINDER_COLUMN_G_V_VOCABULARYID_5);
4470
4471 if ((i + 1) < vocabularyIds.length) {
4472 query.append(WHERE_OR);
4473 }
4474 }
4475
4476 query.append(StringPool.CLOSE_PARENTHESIS);
4477
4478 conjunctionable = true;
4479 }
4480
4481 String sql = query.toString();
4482
4483 Session session = null;
4484
4485 try {
4486 session = openSession();
4487
4488 Query q = session.createQuery(sql);
4489
4490 QueryPos qPos = QueryPos.getInstance(q);
4491
4492 qPos.add(groupId);
4493
4494 if (vocabularyIds != null) {
4495 qPos.add(vocabularyIds);
4496 }
4497
4498 count = (Long)q.uniqueResult();
4499
4500 FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_V,
4501 finderArgs, count);
4502 }
4503 catch (Exception e) {
4504 FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_V,
4505 finderArgs);
4506
4507 throw processException(e);
4508 }
4509 finally {
4510 closeSession(session);
4511 }
4512 }
4513
4514 return count.intValue();
4515 }
4516
4517
4525 public int filterCountByG_V(long groupId, long vocabularyId)
4526 throws SystemException {
4527 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
4528 return countByG_V(groupId, vocabularyId);
4529 }
4530
4531 StringBundler query = new StringBundler(3);
4532
4533 query.append(_FILTER_SQL_COUNT_ASSETCATEGORY_WHERE);
4534
4535 query.append(_FINDER_COLUMN_G_V_GROUPID_2);
4536
4537 query.append(_FINDER_COLUMN_G_V_VOCABULARYID_2);
4538
4539 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
4540 AssetCategory.class.getName(),
4541 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
4542
4543 Session session = null;
4544
4545 try {
4546 session = openSession();
4547
4548 SQLQuery q = session.createSQLQuery(sql);
4549
4550 q.addScalar(COUNT_COLUMN_NAME,
4551 com.liferay.portal.kernel.dao.orm.Type.LONG);
4552
4553 QueryPos qPos = QueryPos.getInstance(q);
4554
4555 qPos.add(groupId);
4556
4557 qPos.add(vocabularyId);
4558
4559 Long count = (Long)q.uniqueResult();
4560
4561 return count.intValue();
4562 }
4563 catch (Exception e) {
4564 throw processException(e);
4565 }
4566 finally {
4567 closeSession(session);
4568 }
4569 }
4570
4571
4579 public int filterCountByG_V(long groupId, long[] vocabularyIds)
4580 throws SystemException {
4581 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
4582 return countByG_V(groupId, vocabularyIds);
4583 }
4584
4585 StringBundler query = new StringBundler();
4586
4587 query.append(_FILTER_SQL_COUNT_ASSETCATEGORY_WHERE);
4588
4589 boolean conjunctionable = false;
4590
4591 if (conjunctionable) {
4592 query.append(WHERE_AND);
4593 }
4594
4595 query.append(_FINDER_COLUMN_G_V_GROUPID_5);
4596
4597 conjunctionable = true;
4598
4599 if ((vocabularyIds == null) || (vocabularyIds.length > 0)) {
4600 if (conjunctionable) {
4601 query.append(WHERE_AND);
4602 }
4603
4604 query.append(StringPool.OPEN_PARENTHESIS);
4605
4606 for (int i = 0; i < vocabularyIds.length; i++) {
4607 query.append(_FINDER_COLUMN_G_V_VOCABULARYID_5);
4608
4609 if ((i + 1) < vocabularyIds.length) {
4610 query.append(WHERE_OR);
4611 }
4612 }
4613
4614 query.append(StringPool.CLOSE_PARENTHESIS);
4615
4616 conjunctionable = true;
4617 }
4618
4619 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
4620 AssetCategory.class.getName(),
4621 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
4622
4623 Session session = null;
4624
4625 try {
4626 session = openSession();
4627
4628 SQLQuery q = session.createSQLQuery(sql);
4629
4630 q.addScalar(COUNT_COLUMN_NAME,
4631 com.liferay.portal.kernel.dao.orm.Type.LONG);
4632
4633 QueryPos qPos = QueryPos.getInstance(q);
4634
4635 qPos.add(groupId);
4636
4637 if (vocabularyIds != null) {
4638 qPos.add(vocabularyIds);
4639 }
4640
4641 Long count = (Long)q.uniqueResult();
4642
4643 return count.intValue();
4644 }
4645 catch (Exception e) {
4646 throw processException(e);
4647 }
4648 finally {
4649 closeSession(session);
4650 }
4651 }
4652
4653 private static final String _FINDER_COLUMN_G_V_GROUPID_2 = "assetCategory.groupId = ? AND ";
4654 private static final String _FINDER_COLUMN_G_V_GROUPID_5 = "(" +
4655 removeConjunction(_FINDER_COLUMN_G_V_GROUPID_2) + ")";
4656 private static final String _FINDER_COLUMN_G_V_VOCABULARYID_2 = "assetCategory.vocabularyId = ?";
4657 private static final String _FINDER_COLUMN_G_V_VOCABULARYID_5 = "(" +
4658 removeConjunction(_FINDER_COLUMN_G_V_VOCABULARYID_2) + ")";
4659 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_P_N = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
4660 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
4661 AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
4662 "findByP_N",
4663 new String[] {
4664 Long.class.getName(), String.class.getName(),
4665
4666 Integer.class.getName(), Integer.class.getName(),
4667 OrderByComparator.class.getName()
4668 });
4669 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_P_N = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
4670 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
4671 AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
4672 "findByP_N",
4673 new String[] { Long.class.getName(), String.class.getName() },
4674 AssetCategoryModelImpl.PARENTCATEGORYID_COLUMN_BITMASK |
4675 AssetCategoryModelImpl.NAME_COLUMN_BITMASK);
4676 public static final FinderPath FINDER_PATH_COUNT_BY_P_N = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
4677 AssetCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class,
4678 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByP_N",
4679 new String[] { Long.class.getName(), String.class.getName() });
4680
4681
4689 public List<AssetCategory> findByP_N(long parentCategoryId, String name)
4690 throws SystemException {
4691 return findByP_N(parentCategoryId, name, QueryUtil.ALL_POS,
4692 QueryUtil.ALL_POS, null);
4693 }
4694
4695
4709 public List<AssetCategory> findByP_N(long parentCategoryId, String name,
4710 int start, int end) throws SystemException {
4711 return findByP_N(parentCategoryId, name, start, end, null);
4712 }
4713
4714
4729 public List<AssetCategory> findByP_N(long parentCategoryId, String name,
4730 int start, int end, OrderByComparator orderByComparator)
4731 throws SystemException {
4732 boolean pagination = true;
4733 FinderPath finderPath = null;
4734 Object[] finderArgs = null;
4735
4736 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
4737 (orderByComparator == null)) {
4738 pagination = false;
4739 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_P_N;
4740 finderArgs = new Object[] { parentCategoryId, name };
4741 }
4742 else {
4743 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_P_N;
4744 finderArgs = new Object[] {
4745 parentCategoryId, name,
4746
4747 start, end, orderByComparator
4748 };
4749 }
4750
4751 List<AssetCategory> list = (List<AssetCategory>)FinderCacheUtil.getResult(finderPath,
4752 finderArgs, this);
4753
4754 if ((list != null) && !list.isEmpty()) {
4755 for (AssetCategory assetCategory : list) {
4756 if ((parentCategoryId != assetCategory.getParentCategoryId()) ||
4757 !Validator.equals(name, assetCategory.getName())) {
4758 list = null;
4759
4760 break;
4761 }
4762 }
4763 }
4764
4765 if (list == null) {
4766 StringBundler query = null;
4767
4768 if (orderByComparator != null) {
4769 query = new StringBundler(4 +
4770 (orderByComparator.getOrderByFields().length * 3));
4771 }
4772 else {
4773 query = new StringBundler(4);
4774 }
4775
4776 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
4777
4778 query.append(_FINDER_COLUMN_P_N_PARENTCATEGORYID_2);
4779
4780 boolean bindName = false;
4781
4782 if (name == null) {
4783 query.append(_FINDER_COLUMN_P_N_NAME_1);
4784 }
4785 else if (name.equals(StringPool.BLANK)) {
4786 query.append(_FINDER_COLUMN_P_N_NAME_3);
4787 }
4788 else {
4789 bindName = true;
4790
4791 query.append(_FINDER_COLUMN_P_N_NAME_2);
4792 }
4793
4794 if (orderByComparator != null) {
4795 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4796 orderByComparator);
4797 }
4798 else
4799 if (pagination) {
4800 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
4801 }
4802
4803 String sql = query.toString();
4804
4805 Session session = null;
4806
4807 try {
4808 session = openSession();
4809
4810 Query q = session.createQuery(sql);
4811
4812 QueryPos qPos = QueryPos.getInstance(q);
4813
4814 qPos.add(parentCategoryId);
4815
4816 if (bindName) {
4817 qPos.add(name);
4818 }
4819
4820 if (!pagination) {
4821 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
4822 start, end, false);
4823
4824 Collections.sort(list);
4825
4826 list = new UnmodifiableList<AssetCategory>(list);
4827 }
4828 else {
4829 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
4830 start, end);
4831 }
4832
4833 cacheResult(list);
4834
4835 FinderCacheUtil.putResult(finderPath, finderArgs, list);
4836 }
4837 catch (Exception e) {
4838 FinderCacheUtil.removeResult(finderPath, finderArgs);
4839
4840 throw processException(e);
4841 }
4842 finally {
4843 closeSession(session);
4844 }
4845 }
4846
4847 return list;
4848 }
4849
4850
4860 public AssetCategory findByP_N_First(long parentCategoryId, String name,
4861 OrderByComparator orderByComparator)
4862 throws NoSuchCategoryException, SystemException {
4863 AssetCategory assetCategory = fetchByP_N_First(parentCategoryId, name,
4864 orderByComparator);
4865
4866 if (assetCategory != null) {
4867 return assetCategory;
4868 }
4869
4870 StringBundler msg = new StringBundler(6);
4871
4872 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4873
4874 msg.append("parentCategoryId=");
4875 msg.append(parentCategoryId);
4876
4877 msg.append(", name=");
4878 msg.append(name);
4879
4880 msg.append(StringPool.CLOSE_CURLY_BRACE);
4881
4882 throw new NoSuchCategoryException(msg.toString());
4883 }
4884
4885
4894 public AssetCategory fetchByP_N_First(long parentCategoryId, String name,
4895 OrderByComparator orderByComparator) throws SystemException {
4896 List<AssetCategory> list = findByP_N(parentCategoryId, name, 0, 1,
4897 orderByComparator);
4898
4899 if (!list.isEmpty()) {
4900 return list.get(0);
4901 }
4902
4903 return null;
4904 }
4905
4906
4916 public AssetCategory findByP_N_Last(long parentCategoryId, String name,
4917 OrderByComparator orderByComparator)
4918 throws NoSuchCategoryException, SystemException {
4919 AssetCategory assetCategory = fetchByP_N_Last(parentCategoryId, name,
4920 orderByComparator);
4921
4922 if (assetCategory != null) {
4923 return assetCategory;
4924 }
4925
4926 StringBundler msg = new StringBundler(6);
4927
4928 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4929
4930 msg.append("parentCategoryId=");
4931 msg.append(parentCategoryId);
4932
4933 msg.append(", name=");
4934 msg.append(name);
4935
4936 msg.append(StringPool.CLOSE_CURLY_BRACE);
4937
4938 throw new NoSuchCategoryException(msg.toString());
4939 }
4940
4941
4950 public AssetCategory fetchByP_N_Last(long parentCategoryId, String name,
4951 OrderByComparator orderByComparator) throws SystemException {
4952 int count = countByP_N(parentCategoryId, name);
4953
4954 List<AssetCategory> list = findByP_N(parentCategoryId, name, count - 1,
4955 count, orderByComparator);
4956
4957 if (!list.isEmpty()) {
4958 return list.get(0);
4959 }
4960
4961 return null;
4962 }
4963
4964
4975 public AssetCategory[] findByP_N_PrevAndNext(long categoryId,
4976 long parentCategoryId, String name, OrderByComparator orderByComparator)
4977 throws NoSuchCategoryException, SystemException {
4978 AssetCategory assetCategory = findByPrimaryKey(categoryId);
4979
4980 Session session = null;
4981
4982 try {
4983 session = openSession();
4984
4985 AssetCategory[] array = new AssetCategoryImpl[3];
4986
4987 array[0] = getByP_N_PrevAndNext(session, assetCategory,
4988 parentCategoryId, name, orderByComparator, true);
4989
4990 array[1] = assetCategory;
4991
4992 array[2] = getByP_N_PrevAndNext(session, assetCategory,
4993 parentCategoryId, name, orderByComparator, false);
4994
4995 return array;
4996 }
4997 catch (Exception e) {
4998 throw processException(e);
4999 }
5000 finally {
5001 closeSession(session);
5002 }
5003 }
5004
5005 protected AssetCategory getByP_N_PrevAndNext(Session session,
5006 AssetCategory assetCategory, long parentCategoryId, String name,
5007 OrderByComparator orderByComparator, boolean previous) {
5008 StringBundler query = null;
5009
5010 if (orderByComparator != null) {
5011 query = new StringBundler(6 +
5012 (orderByComparator.getOrderByFields().length * 6));
5013 }
5014 else {
5015 query = new StringBundler(3);
5016 }
5017
5018 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
5019
5020 query.append(_FINDER_COLUMN_P_N_PARENTCATEGORYID_2);
5021
5022 boolean bindName = false;
5023
5024 if (name == null) {
5025 query.append(_FINDER_COLUMN_P_N_NAME_1);
5026 }
5027 else if (name.equals(StringPool.BLANK)) {
5028 query.append(_FINDER_COLUMN_P_N_NAME_3);
5029 }
5030 else {
5031 bindName = true;
5032
5033 query.append(_FINDER_COLUMN_P_N_NAME_2);
5034 }
5035
5036 if (orderByComparator != null) {
5037 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
5038
5039 if (orderByConditionFields.length > 0) {
5040 query.append(WHERE_AND);
5041 }
5042
5043 for (int i = 0; i < orderByConditionFields.length; i++) {
5044 query.append(_ORDER_BY_ENTITY_ALIAS);
5045 query.append(orderByConditionFields[i]);
5046
5047 if ((i + 1) < orderByConditionFields.length) {
5048 if (orderByComparator.isAscending() ^ previous) {
5049 query.append(WHERE_GREATER_THAN_HAS_NEXT);
5050 }
5051 else {
5052 query.append(WHERE_LESSER_THAN_HAS_NEXT);
5053 }
5054 }
5055 else {
5056 if (orderByComparator.isAscending() ^ previous) {
5057 query.append(WHERE_GREATER_THAN);
5058 }
5059 else {
5060 query.append(WHERE_LESSER_THAN);
5061 }
5062 }
5063 }
5064
5065 query.append(ORDER_BY_CLAUSE);
5066
5067 String[] orderByFields = orderByComparator.getOrderByFields();
5068
5069 for (int i = 0; i < orderByFields.length; i++) {
5070 query.append(_ORDER_BY_ENTITY_ALIAS);
5071 query.append(orderByFields[i]);
5072
5073 if ((i + 1) < orderByFields.length) {
5074 if (orderByComparator.isAscending() ^ previous) {
5075 query.append(ORDER_BY_ASC_HAS_NEXT);
5076 }
5077 else {
5078 query.append(ORDER_BY_DESC_HAS_NEXT);
5079 }
5080 }
5081 else {
5082 if (orderByComparator.isAscending() ^ previous) {
5083 query.append(ORDER_BY_ASC);
5084 }
5085 else {
5086 query.append(ORDER_BY_DESC);
5087 }
5088 }
5089 }
5090 }
5091 else {
5092 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
5093 }
5094
5095 String sql = query.toString();
5096
5097 Query q = session.createQuery(sql);
5098
5099 q.setFirstResult(0);
5100 q.setMaxResults(2);
5101
5102 QueryPos qPos = QueryPos.getInstance(q);
5103
5104 qPos.add(parentCategoryId);
5105
5106 if (bindName) {
5107 qPos.add(name);
5108 }
5109
5110 if (orderByComparator != null) {
5111 Object[] values = orderByComparator.getOrderByConditionValues(assetCategory);
5112
5113 for (Object value : values) {
5114 qPos.add(value);
5115 }
5116 }
5117
5118 List<AssetCategory> list = q.list();
5119
5120 if (list.size() == 2) {
5121 return list.get(1);
5122 }
5123 else {
5124 return null;
5125 }
5126 }
5127
5128
5135 public void removeByP_N(long parentCategoryId, String name)
5136 throws SystemException {
5137 for (AssetCategory assetCategory : findByP_N(parentCategoryId, name,
5138 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
5139 remove(assetCategory);
5140 }
5141 }
5142
5143
5151 public int countByP_N(long parentCategoryId, String name)
5152 throws SystemException {
5153 FinderPath finderPath = FINDER_PATH_COUNT_BY_P_N;
5154
5155 Object[] finderArgs = new Object[] { parentCategoryId, name };
5156
5157 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
5158 this);
5159
5160 if (count == null) {
5161 StringBundler query = new StringBundler(3);
5162
5163 query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
5164
5165 query.append(_FINDER_COLUMN_P_N_PARENTCATEGORYID_2);
5166
5167 boolean bindName = false;
5168
5169 if (name == null) {
5170 query.append(_FINDER_COLUMN_P_N_NAME_1);
5171 }
5172 else if (name.equals(StringPool.BLANK)) {
5173 query.append(_FINDER_COLUMN_P_N_NAME_3);
5174 }
5175 else {
5176 bindName = true;
5177
5178 query.append(_FINDER_COLUMN_P_N_NAME_2);
5179 }
5180
5181 String sql = query.toString();
5182
5183 Session session = null;
5184
5185 try {
5186 session = openSession();
5187
5188 Query q = session.createQuery(sql);
5189
5190 QueryPos qPos = QueryPos.getInstance(q);
5191
5192 qPos.add(parentCategoryId);
5193
5194 if (bindName) {
5195 qPos.add(name);
5196 }
5197
5198 count = (Long)q.uniqueResult();
5199
5200 FinderCacheUtil.putResult(finderPath, finderArgs, count);
5201 }
5202 catch (Exception e) {
5203 FinderCacheUtil.removeResult(finderPath, finderArgs);
5204
5205 throw processException(e);
5206 }
5207 finally {
5208 closeSession(session);
5209 }
5210 }
5211
5212 return count.intValue();
5213 }
5214
5215 private static final String _FINDER_COLUMN_P_N_PARENTCATEGORYID_2 = "assetCategory.parentCategoryId = ? AND ";
5216 private static final String _FINDER_COLUMN_P_N_NAME_1 = "assetCategory.name IS NULL";
5217 private static final String _FINDER_COLUMN_P_N_NAME_2 = "assetCategory.name = ?";
5218 private static final String _FINDER_COLUMN_P_N_NAME_3 = "(assetCategory.name IS NULL OR assetCategory.name = '')";
5219 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_P_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
5220 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
5221 AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
5222 "findByP_V",
5223 new String[] {
5224 Long.class.getName(), Long.class.getName(),
5225
5226 Integer.class.getName(), Integer.class.getName(),
5227 OrderByComparator.class.getName()
5228 });
5229 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_P_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
5230 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
5231 AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
5232 "findByP_V",
5233 new String[] { Long.class.getName(), Long.class.getName() },
5234 AssetCategoryModelImpl.PARENTCATEGORYID_COLUMN_BITMASK |
5235 AssetCategoryModelImpl.VOCABULARYID_COLUMN_BITMASK |
5236 AssetCategoryModelImpl.NAME_COLUMN_BITMASK);
5237 public static final FinderPath FINDER_PATH_COUNT_BY_P_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
5238 AssetCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class,
5239 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByP_V",
5240 new String[] { Long.class.getName(), Long.class.getName() });
5241
5242
5250 public List<AssetCategory> findByP_V(long parentCategoryId,
5251 long vocabularyId) throws SystemException {
5252 return findByP_V(parentCategoryId, vocabularyId, QueryUtil.ALL_POS,
5253 QueryUtil.ALL_POS, null);
5254 }
5255
5256
5270 public List<AssetCategory> findByP_V(long parentCategoryId,
5271 long vocabularyId, int start, int end) throws SystemException {
5272 return findByP_V(parentCategoryId, vocabularyId, start, end, null);
5273 }
5274
5275
5290 public List<AssetCategory> findByP_V(long parentCategoryId,
5291 long vocabularyId, int start, int end,
5292 OrderByComparator orderByComparator) throws SystemException {
5293 boolean pagination = true;
5294 FinderPath finderPath = null;
5295 Object[] finderArgs = null;
5296
5297 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
5298 (orderByComparator == null)) {
5299 pagination = false;
5300 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_P_V;
5301 finderArgs = new Object[] { parentCategoryId, vocabularyId };
5302 }
5303 else {
5304 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_P_V;
5305 finderArgs = new Object[] {
5306 parentCategoryId, vocabularyId,
5307
5308 start, end, orderByComparator
5309 };
5310 }
5311
5312 List<AssetCategory> list = (List<AssetCategory>)FinderCacheUtil.getResult(finderPath,
5313 finderArgs, this);
5314
5315 if ((list != null) && !list.isEmpty()) {
5316 for (AssetCategory assetCategory : list) {
5317 if ((parentCategoryId != assetCategory.getParentCategoryId()) ||
5318 (vocabularyId != assetCategory.getVocabularyId())) {
5319 list = null;
5320
5321 break;
5322 }
5323 }
5324 }
5325
5326 if (list == null) {
5327 StringBundler query = null;
5328
5329 if (orderByComparator != null) {
5330 query = new StringBundler(4 +
5331 (orderByComparator.getOrderByFields().length * 3));
5332 }
5333 else {
5334 query = new StringBundler(4);
5335 }
5336
5337 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
5338
5339 query.append(_FINDER_COLUMN_P_V_PARENTCATEGORYID_2);
5340
5341 query.append(_FINDER_COLUMN_P_V_VOCABULARYID_2);
5342
5343 if (orderByComparator != null) {
5344 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
5345 orderByComparator);
5346 }
5347 else
5348 if (pagination) {
5349 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
5350 }
5351
5352 String sql = query.toString();
5353
5354 Session session = null;
5355
5356 try {
5357 session = openSession();
5358
5359 Query q = session.createQuery(sql);
5360
5361 QueryPos qPos = QueryPos.getInstance(q);
5362
5363 qPos.add(parentCategoryId);
5364
5365 qPos.add(vocabularyId);
5366
5367 if (!pagination) {
5368 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
5369 start, end, false);
5370
5371 Collections.sort(list);
5372
5373 list = new UnmodifiableList<AssetCategory>(list);
5374 }
5375 else {
5376 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
5377 start, end);
5378 }
5379
5380 cacheResult(list);
5381
5382 FinderCacheUtil.putResult(finderPath, finderArgs, list);
5383 }
5384 catch (Exception e) {
5385 FinderCacheUtil.removeResult(finderPath, finderArgs);
5386
5387 throw processException(e);
5388 }
5389 finally {
5390 closeSession(session);
5391 }
5392 }
5393
5394 return list;
5395 }
5396
5397
5407 public AssetCategory findByP_V_First(long parentCategoryId,
5408 long vocabularyId, OrderByComparator orderByComparator)
5409 throws NoSuchCategoryException, SystemException {
5410 AssetCategory assetCategory = fetchByP_V_First(parentCategoryId,
5411 vocabularyId, orderByComparator);
5412
5413 if (assetCategory != null) {
5414 return assetCategory;
5415 }
5416
5417 StringBundler msg = new StringBundler(6);
5418
5419 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5420
5421 msg.append("parentCategoryId=");
5422 msg.append(parentCategoryId);
5423
5424 msg.append(", vocabularyId=");
5425 msg.append(vocabularyId);
5426
5427 msg.append(StringPool.CLOSE_CURLY_BRACE);
5428
5429 throw new NoSuchCategoryException(msg.toString());
5430 }
5431
5432
5441 public AssetCategory fetchByP_V_First(long parentCategoryId,
5442 long vocabularyId, OrderByComparator orderByComparator)
5443 throws SystemException {
5444 List<AssetCategory> list = findByP_V(parentCategoryId, vocabularyId, 0,
5445 1, orderByComparator);
5446
5447 if (!list.isEmpty()) {
5448 return list.get(0);
5449 }
5450
5451 return null;
5452 }
5453
5454
5464 public AssetCategory findByP_V_Last(long parentCategoryId,
5465 long vocabularyId, OrderByComparator orderByComparator)
5466 throws NoSuchCategoryException, SystemException {
5467 AssetCategory assetCategory = fetchByP_V_Last(parentCategoryId,
5468 vocabularyId, orderByComparator);
5469
5470 if (assetCategory != null) {
5471 return assetCategory;
5472 }
5473
5474 StringBundler msg = new StringBundler(6);
5475
5476 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5477
5478 msg.append("parentCategoryId=");
5479 msg.append(parentCategoryId);
5480
5481 msg.append(", vocabularyId=");
5482 msg.append(vocabularyId);
5483
5484 msg.append(StringPool.CLOSE_CURLY_BRACE);
5485
5486 throw new NoSuchCategoryException(msg.toString());
5487 }
5488
5489
5498 public AssetCategory fetchByP_V_Last(long parentCategoryId,
5499 long vocabularyId, OrderByComparator orderByComparator)
5500 throws SystemException {
5501 int count = countByP_V(parentCategoryId, vocabularyId);
5502
5503 List<AssetCategory> list = findByP_V(parentCategoryId, vocabularyId,
5504 count - 1, count, orderByComparator);
5505
5506 if (!list.isEmpty()) {
5507 return list.get(0);
5508 }
5509
5510 return null;
5511 }
5512
5513
5524 public AssetCategory[] findByP_V_PrevAndNext(long categoryId,
5525 long parentCategoryId, long vocabularyId,
5526 OrderByComparator orderByComparator)
5527 throws NoSuchCategoryException, SystemException {
5528 AssetCategory assetCategory = findByPrimaryKey(categoryId);
5529
5530 Session session = null;
5531
5532 try {
5533 session = openSession();
5534
5535 AssetCategory[] array = new AssetCategoryImpl[3];
5536
5537 array[0] = getByP_V_PrevAndNext(session, assetCategory,
5538 parentCategoryId, vocabularyId, orderByComparator, true);
5539
5540 array[1] = assetCategory;
5541
5542 array[2] = getByP_V_PrevAndNext(session, assetCategory,
5543 parentCategoryId, vocabularyId, orderByComparator, false);
5544
5545 return array;
5546 }
5547 catch (Exception e) {
5548 throw processException(e);
5549 }
5550 finally {
5551 closeSession(session);
5552 }
5553 }
5554
5555 protected AssetCategory getByP_V_PrevAndNext(Session session,
5556 AssetCategory assetCategory, long parentCategoryId, long vocabularyId,
5557 OrderByComparator orderByComparator, boolean previous) {
5558 StringBundler query = null;
5559
5560 if (orderByComparator != null) {
5561 query = new StringBundler(6 +
5562 (orderByComparator.getOrderByFields().length * 6));
5563 }
5564 else {
5565 query = new StringBundler(3);
5566 }
5567
5568 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
5569
5570 query.append(_FINDER_COLUMN_P_V_PARENTCATEGORYID_2);
5571
5572 query.append(_FINDER_COLUMN_P_V_VOCABULARYID_2);
5573
5574 if (orderByComparator != null) {
5575 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
5576
5577 if (orderByConditionFields.length > 0) {
5578 query.append(WHERE_AND);
5579 }
5580
5581 for (int i = 0; i < orderByConditionFields.length; i++) {
5582 query.append(_ORDER_BY_ENTITY_ALIAS);
5583 query.append(orderByConditionFields[i]);
5584
5585 if ((i + 1) < orderByConditionFields.length) {
5586 if (orderByComparator.isAscending() ^ previous) {
5587 query.append(WHERE_GREATER_THAN_HAS_NEXT);
5588 }
5589 else {
5590 query.append(WHERE_LESSER_THAN_HAS_NEXT);
5591 }
5592 }
5593 else {
5594 if (orderByComparator.isAscending() ^ previous) {
5595 query.append(WHERE_GREATER_THAN);
5596 }
5597 else {
5598 query.append(WHERE_LESSER_THAN);
5599 }
5600 }
5601 }
5602
5603 query.append(ORDER_BY_CLAUSE);
5604
5605 String[] orderByFields = orderByComparator.getOrderByFields();
5606
5607 for (int i = 0; i < orderByFields.length; i++) {
5608 query.append(_ORDER_BY_ENTITY_ALIAS);
5609 query.append(orderByFields[i]);
5610
5611 if ((i + 1) < orderByFields.length) {
5612 if (orderByComparator.isAscending() ^ previous) {
5613 query.append(ORDER_BY_ASC_HAS_NEXT);
5614 }
5615 else {
5616 query.append(ORDER_BY_DESC_HAS_NEXT);
5617 }
5618 }
5619 else {
5620 if (orderByComparator.isAscending() ^ previous) {
5621 query.append(ORDER_BY_ASC);
5622 }
5623 else {
5624 query.append(ORDER_BY_DESC);
5625 }
5626 }
5627 }
5628 }
5629 else {
5630 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
5631 }
5632
5633 String sql = query.toString();
5634
5635 Query q = session.createQuery(sql);
5636
5637 q.setFirstResult(0);
5638 q.setMaxResults(2);
5639
5640 QueryPos qPos = QueryPos.getInstance(q);
5641
5642 qPos.add(parentCategoryId);
5643
5644 qPos.add(vocabularyId);
5645
5646 if (orderByComparator != null) {
5647 Object[] values = orderByComparator.getOrderByConditionValues(assetCategory);
5648
5649 for (Object value : values) {
5650 qPos.add(value);
5651 }
5652 }
5653
5654 List<AssetCategory> list = q.list();
5655
5656 if (list.size() == 2) {
5657 return list.get(1);
5658 }
5659 else {
5660 return null;
5661 }
5662 }
5663
5664
5671 public void removeByP_V(long parentCategoryId, long vocabularyId)
5672 throws SystemException {
5673 for (AssetCategory assetCategory : findByP_V(parentCategoryId,
5674 vocabularyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
5675 remove(assetCategory);
5676 }
5677 }
5678
5679
5687 public int countByP_V(long parentCategoryId, long vocabularyId)
5688 throws SystemException {
5689 FinderPath finderPath = FINDER_PATH_COUNT_BY_P_V;
5690
5691 Object[] finderArgs = new Object[] { parentCategoryId, vocabularyId };
5692
5693 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
5694 this);
5695
5696 if (count == null) {
5697 StringBundler query = new StringBundler(3);
5698
5699 query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
5700
5701 query.append(_FINDER_COLUMN_P_V_PARENTCATEGORYID_2);
5702
5703 query.append(_FINDER_COLUMN_P_V_VOCABULARYID_2);
5704
5705 String sql = query.toString();
5706
5707 Session session = null;
5708
5709 try {
5710 session = openSession();
5711
5712 Query q = session.createQuery(sql);
5713
5714 QueryPos qPos = QueryPos.getInstance(q);
5715
5716 qPos.add(parentCategoryId);
5717
5718 qPos.add(vocabularyId);
5719
5720 count = (Long)q.uniqueResult();
5721
5722 FinderCacheUtil.putResult(finderPath, finderArgs, count);
5723 }
5724 catch (Exception e) {
5725 FinderCacheUtil.removeResult(finderPath, finderArgs);
5726
5727 throw processException(e);
5728 }
5729 finally {
5730 closeSession(session);
5731 }
5732 }
5733
5734 return count.intValue();
5735 }
5736
5737 private static final String _FINDER_COLUMN_P_V_PARENTCATEGORYID_2 = "assetCategory.parentCategoryId = ? AND ";
5738 private static final String _FINDER_COLUMN_P_V_VOCABULARYID_2 = "assetCategory.vocabularyId = ?";
5739 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_N_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
5740 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
5741 AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
5742 "findByN_V",
5743 new String[] {
5744 String.class.getName(), Long.class.getName(),
5745
5746 Integer.class.getName(), Integer.class.getName(),
5747 OrderByComparator.class.getName()
5748 });
5749 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
5750 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
5751 AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
5752 "findByN_V",
5753 new String[] { String.class.getName(), Long.class.getName() },
5754 AssetCategoryModelImpl.NAME_COLUMN_BITMASK |
5755 AssetCategoryModelImpl.VOCABULARYID_COLUMN_BITMASK);
5756 public static final FinderPath FINDER_PATH_COUNT_BY_N_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
5757 AssetCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class,
5758 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByN_V",
5759 new String[] { String.class.getName(), Long.class.getName() });
5760
5761
5769 public List<AssetCategory> findByN_V(String name, long vocabularyId)
5770 throws SystemException {
5771 return findByN_V(name, vocabularyId, QueryUtil.ALL_POS,
5772 QueryUtil.ALL_POS, null);
5773 }
5774
5775
5789 public List<AssetCategory> findByN_V(String name, long vocabularyId,
5790 int start, int end) throws SystemException {
5791 return findByN_V(name, vocabularyId, start, end, null);
5792 }
5793
5794
5809 public List<AssetCategory> findByN_V(String name, long vocabularyId,
5810 int start, int end, OrderByComparator orderByComparator)
5811 throws SystemException {
5812 boolean pagination = true;
5813 FinderPath finderPath = null;
5814 Object[] finderArgs = null;
5815
5816 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
5817 (orderByComparator == null)) {
5818 pagination = false;
5819 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_V;
5820 finderArgs = new Object[] { name, vocabularyId };
5821 }
5822 else {
5823 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_N_V;
5824 finderArgs = new Object[] {
5825 name, vocabularyId,
5826
5827 start, end, orderByComparator
5828 };
5829 }
5830
5831 List<AssetCategory> list = (List<AssetCategory>)FinderCacheUtil.getResult(finderPath,
5832 finderArgs, this);
5833
5834 if ((list != null) && !list.isEmpty()) {
5835 for (AssetCategory assetCategory : list) {
5836 if (!Validator.equals(name, assetCategory.getName()) ||
5837 (vocabularyId != assetCategory.getVocabularyId())) {
5838 list = null;
5839
5840 break;
5841 }
5842 }
5843 }
5844
5845 if (list == null) {
5846 StringBundler query = null;
5847
5848 if (orderByComparator != null) {
5849 query = new StringBundler(4 +
5850 (orderByComparator.getOrderByFields().length * 3));
5851 }
5852 else {
5853 query = new StringBundler(4);
5854 }
5855
5856 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
5857
5858 boolean bindName = false;
5859
5860 if (name == null) {
5861 query.append(_FINDER_COLUMN_N_V_NAME_1);
5862 }
5863 else if (name.equals(StringPool.BLANK)) {
5864 query.append(_FINDER_COLUMN_N_V_NAME_3);
5865 }
5866 else {
5867 bindName = true;
5868
5869 query.append(_FINDER_COLUMN_N_V_NAME_2);
5870 }
5871
5872 query.append(_FINDER_COLUMN_N_V_VOCABULARYID_2);
5873
5874 if (orderByComparator != null) {
5875 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
5876 orderByComparator);
5877 }
5878 else
5879 if (pagination) {
5880 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
5881 }
5882
5883 String sql = query.toString();
5884
5885 Session session = null;
5886
5887 try {
5888 session = openSession();
5889
5890 Query q = session.createQuery(sql);
5891
5892 QueryPos qPos = QueryPos.getInstance(q);
5893
5894 if (bindName) {
5895 qPos.add(name);
5896 }
5897
5898 qPos.add(vocabularyId);
5899
5900 if (!pagination) {
5901 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
5902 start, end, false);
5903
5904 Collections.sort(list);
5905
5906 list = new UnmodifiableList<AssetCategory>(list);
5907 }
5908 else {
5909 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
5910 start, end);
5911 }
5912
5913 cacheResult(list);
5914
5915 FinderCacheUtil.putResult(finderPath, finderArgs, list);
5916 }
5917 catch (Exception e) {
5918 FinderCacheUtil.removeResult(finderPath, finderArgs);
5919
5920 throw processException(e);
5921 }
5922 finally {
5923 closeSession(session);
5924 }
5925 }
5926
5927 return list;
5928 }
5929
5930
5940 public AssetCategory findByN_V_First(String name, long vocabularyId,
5941 OrderByComparator orderByComparator)
5942 throws NoSuchCategoryException, SystemException {
5943 AssetCategory assetCategory = fetchByN_V_First(name, vocabularyId,
5944 orderByComparator);
5945
5946 if (assetCategory != null) {
5947 return assetCategory;
5948 }
5949
5950 StringBundler msg = new StringBundler(6);
5951
5952 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5953
5954 msg.append("name=");
5955 msg.append(name);
5956
5957 msg.append(", vocabularyId=");
5958 msg.append(vocabularyId);
5959
5960 msg.append(StringPool.CLOSE_CURLY_BRACE);
5961
5962 throw new NoSuchCategoryException(msg.toString());
5963 }
5964
5965
5974 public AssetCategory fetchByN_V_First(String name, long vocabularyId,
5975 OrderByComparator orderByComparator) throws SystemException {
5976 List<AssetCategory> list = findByN_V(name, vocabularyId, 0, 1,
5977 orderByComparator);
5978
5979 if (!list.isEmpty()) {
5980 return list.get(0);
5981 }
5982
5983 return null;
5984 }
5985
5986
5996 public AssetCategory findByN_V_Last(String name, long vocabularyId,
5997 OrderByComparator orderByComparator)
5998 throws NoSuchCategoryException, SystemException {
5999 AssetCategory assetCategory = fetchByN_V_Last(name, vocabularyId,
6000 orderByComparator);
6001
6002 if (assetCategory != null) {
6003 return assetCategory;
6004 }
6005
6006 StringBundler msg = new StringBundler(6);
6007
6008 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
6009
6010 msg.append("name=");
6011 msg.append(name);
6012
6013 msg.append(", vocabularyId=");
6014 msg.append(vocabularyId);
6015
6016 msg.append(StringPool.CLOSE_CURLY_BRACE);
6017
6018 throw new NoSuchCategoryException(msg.toString());
6019 }
6020
6021
6030 public AssetCategory fetchByN_V_Last(String name, long vocabularyId,
6031 OrderByComparator orderByComparator) throws SystemException {
6032 int count = countByN_V(name, vocabularyId);
6033
6034 List<AssetCategory> list = findByN_V(name, vocabularyId, count - 1,
6035 count, orderByComparator);
6036
6037 if (!list.isEmpty()) {
6038 return list.get(0);
6039 }
6040
6041 return null;
6042 }
6043
6044
6055 public AssetCategory[] findByN_V_PrevAndNext(long categoryId, String name,
6056 long vocabularyId, OrderByComparator orderByComparator)
6057 throws NoSuchCategoryException, SystemException {
6058 AssetCategory assetCategory = findByPrimaryKey(categoryId);
6059
6060 Session session = null;
6061
6062 try {
6063 session = openSession();
6064
6065 AssetCategory[] array = new AssetCategoryImpl[3];
6066
6067 array[0] = getByN_V_PrevAndNext(session, assetCategory, name,
6068 vocabularyId, orderByComparator, true);
6069
6070 array[1] = assetCategory;
6071
6072 array[2] = getByN_V_PrevAndNext(session, assetCategory, name,
6073 vocabularyId, orderByComparator, false);
6074
6075 return array;
6076 }
6077 catch (Exception e) {
6078 throw processException(e);
6079 }
6080 finally {
6081 closeSession(session);
6082 }
6083 }
6084
6085 protected AssetCategory getByN_V_PrevAndNext(Session session,
6086 AssetCategory assetCategory, String name, long vocabularyId,
6087 OrderByComparator orderByComparator, boolean previous) {
6088 StringBundler query = null;
6089
6090 if (orderByComparator != null) {
6091 query = new StringBundler(6 +
6092 (orderByComparator.getOrderByFields().length * 6));
6093 }
6094 else {
6095 query = new StringBundler(3);
6096 }
6097
6098 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
6099
6100 boolean bindName = false;
6101
6102 if (name == null) {
6103 query.append(_FINDER_COLUMN_N_V_NAME_1);
6104 }
6105 else if (name.equals(StringPool.BLANK)) {
6106 query.append(_FINDER_COLUMN_N_V_NAME_3);
6107 }
6108 else {
6109 bindName = true;
6110
6111 query.append(_FINDER_COLUMN_N_V_NAME_2);
6112 }
6113
6114 query.append(_FINDER_COLUMN_N_V_VOCABULARYID_2);
6115
6116 if (orderByComparator != null) {
6117 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
6118
6119 if (orderByConditionFields.length > 0) {
6120 query.append(WHERE_AND);
6121 }
6122
6123 for (int i = 0; i < orderByConditionFields.length; i++) {
6124 query.append(_ORDER_BY_ENTITY_ALIAS);
6125 query.append(orderByConditionFields[i]);
6126
6127 if ((i + 1) < orderByConditionFields.length) {
6128 if (orderByComparator.isAscending() ^ previous) {
6129 query.append(WHERE_GREATER_THAN_HAS_NEXT);
6130 }
6131 else {
6132 query.append(WHERE_LESSER_THAN_HAS_NEXT);
6133 }
6134 }
6135 else {
6136 if (orderByComparator.isAscending() ^ previous) {
6137 query.append(WHERE_GREATER_THAN);
6138 }
6139 else {
6140 query.append(WHERE_LESSER_THAN);
6141 }
6142 }
6143 }
6144
6145 query.append(ORDER_BY_CLAUSE);
6146
6147 String[] orderByFields = orderByComparator.getOrderByFields();
6148
6149 for (int i = 0; i < orderByFields.length; i++) {
6150 query.append(_ORDER_BY_ENTITY_ALIAS);
6151 query.append(orderByFields[i]);
6152
6153 if ((i + 1) < orderByFields.length) {
6154 if (orderByComparator.isAscending() ^ previous) {
6155 query.append(ORDER_BY_ASC_HAS_NEXT);
6156 }
6157 else {
6158 query.append(ORDER_BY_DESC_HAS_NEXT);
6159 }
6160 }
6161 else {
6162 if (orderByComparator.isAscending() ^ previous) {
6163 query.append(ORDER_BY_ASC);
6164 }
6165 else {
6166 query.append(ORDER_BY_DESC);
6167 }
6168 }
6169 }
6170 }
6171 else {
6172 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
6173 }
6174
6175 String sql = query.toString();
6176
6177 Query q = session.createQuery(sql);
6178
6179 q.setFirstResult(0);
6180 q.setMaxResults(2);
6181
6182 QueryPos qPos = QueryPos.getInstance(q);
6183
6184 if (bindName) {
6185 qPos.add(name);
6186 }
6187
6188 qPos.add(vocabularyId);
6189
6190 if (orderByComparator != null) {
6191 Object[] values = orderByComparator.getOrderByConditionValues(assetCategory);
6192
6193 for (Object value : values) {
6194 qPos.add(value);
6195 }
6196 }
6197
6198 List<AssetCategory> list = q.list();
6199
6200 if (list.size() == 2) {
6201 return list.get(1);
6202 }
6203 else {
6204 return null;
6205 }
6206 }
6207
6208
6215 public void removeByN_V(String name, long vocabularyId)
6216 throws SystemException {
6217 for (AssetCategory assetCategory : findByN_V(name, vocabularyId,
6218 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
6219 remove(assetCategory);
6220 }
6221 }
6222
6223
6231 public int countByN_V(String name, long vocabularyId)
6232 throws SystemException {
6233 FinderPath finderPath = FINDER_PATH_COUNT_BY_N_V;
6234
6235 Object[] finderArgs = new Object[] { name, vocabularyId };
6236
6237 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
6238 this);
6239
6240 if (count == null) {
6241 StringBundler query = new StringBundler(3);
6242
6243 query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
6244
6245 boolean bindName = false;
6246
6247 if (name == null) {
6248 query.append(_FINDER_COLUMN_N_V_NAME_1);
6249 }
6250 else if (name.equals(StringPool.BLANK)) {
6251 query.append(_FINDER_COLUMN_N_V_NAME_3);
6252 }
6253 else {
6254 bindName = true;
6255
6256 query.append(_FINDER_COLUMN_N_V_NAME_2);
6257 }
6258
6259 query.append(_FINDER_COLUMN_N_V_VOCABULARYID_2);
6260
6261 String sql = query.toString();
6262
6263 Session session = null;
6264
6265 try {
6266 session = openSession();
6267
6268 Query q = session.createQuery(sql);
6269
6270 QueryPos qPos = QueryPos.getInstance(q);
6271
6272 if (bindName) {
6273 qPos.add(name);
6274 }
6275
6276 qPos.add(vocabularyId);
6277
6278 count = (Long)q.uniqueResult();
6279
6280 FinderCacheUtil.putResult(finderPath, finderArgs, count);
6281 }
6282 catch (Exception e) {
6283 FinderCacheUtil.removeResult(finderPath, finderArgs);
6284
6285 throw processException(e);
6286 }
6287 finally {
6288 closeSession(session);
6289 }
6290 }
6291
6292 return count.intValue();
6293 }
6294
6295 private static final String _FINDER_COLUMN_N_V_NAME_1 = "assetCategory.name IS NULL AND ";
6296 private static final String _FINDER_COLUMN_N_V_NAME_2 = "assetCategory.name = ? AND ";
6297 private static final String _FINDER_COLUMN_N_V_NAME_3 = "(assetCategory.name IS NULL OR assetCategory.name = '') AND ";
6298 private static final String _FINDER_COLUMN_N_V_VOCABULARYID_2 = "assetCategory.vocabularyId = ?";
6299 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_P_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
6300 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
6301 AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
6302 "findByG_P_V",
6303 new String[] {
6304 Long.class.getName(), Long.class.getName(), Long.class.getName(),
6305
6306 Integer.class.getName(), Integer.class.getName(),
6307 OrderByComparator.class.getName()
6308 });
6309 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
6310 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
6311 AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
6312 "findByG_P_V",
6313 new String[] {
6314 Long.class.getName(), Long.class.getName(), Long.class.getName()
6315 },
6316 AssetCategoryModelImpl.GROUPID_COLUMN_BITMASK |
6317 AssetCategoryModelImpl.PARENTCATEGORYID_COLUMN_BITMASK |
6318 AssetCategoryModelImpl.VOCABULARYID_COLUMN_BITMASK |
6319 AssetCategoryModelImpl.NAME_COLUMN_BITMASK);
6320 public static final FinderPath FINDER_PATH_COUNT_BY_G_P_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
6321 AssetCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class,
6322 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_P_V",
6323 new String[] {
6324 Long.class.getName(), Long.class.getName(), Long.class.getName()
6325 });
6326
6327
6336 public List<AssetCategory> findByG_P_V(long groupId, long parentCategoryId,
6337 long vocabularyId) throws SystemException {
6338 return findByG_P_V(groupId, parentCategoryId, vocabularyId,
6339 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
6340 }
6341
6342
6357 public List<AssetCategory> findByG_P_V(long groupId, long parentCategoryId,
6358 long vocabularyId, int start, int end) throws SystemException {
6359 return findByG_P_V(groupId, parentCategoryId, vocabularyId, start, end,
6360 null);
6361 }
6362
6363
6379 public List<AssetCategory> findByG_P_V(long groupId, long parentCategoryId,
6380 long vocabularyId, int start, int end,
6381 OrderByComparator orderByComparator) throws SystemException {
6382 boolean pagination = true;
6383 FinderPath finderPath = null;
6384 Object[] finderArgs = null;
6385
6386 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
6387 (orderByComparator == null)) {
6388 pagination = false;
6389 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_V;
6390 finderArgs = new Object[] { groupId, parentCategoryId, vocabularyId };
6391 }
6392 else {
6393 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_P_V;
6394 finderArgs = new Object[] {
6395 groupId, parentCategoryId, vocabularyId,
6396
6397 start, end, orderByComparator
6398 };
6399 }
6400
6401 List<AssetCategory> list = (List<AssetCategory>)FinderCacheUtil.getResult(finderPath,
6402 finderArgs, this);
6403
6404 if ((list != null) && !list.isEmpty()) {
6405 for (AssetCategory assetCategory : list) {
6406 if ((groupId != assetCategory.getGroupId()) ||
6407 (parentCategoryId != assetCategory.getParentCategoryId()) ||
6408 (vocabularyId != assetCategory.getVocabularyId())) {
6409 list = null;
6410
6411 break;
6412 }
6413 }
6414 }
6415
6416 if (list == null) {
6417 StringBundler query = null;
6418
6419 if (orderByComparator != null) {
6420 query = new StringBundler(5 +
6421 (orderByComparator.getOrderByFields().length * 3));
6422 }
6423 else {
6424 query = new StringBundler(5);
6425 }
6426
6427 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
6428
6429 query.append(_FINDER_COLUMN_G_P_V_GROUPID_2);
6430
6431 query.append(_FINDER_COLUMN_G_P_V_PARENTCATEGORYID_2);
6432
6433 query.append(_FINDER_COLUMN_G_P_V_VOCABULARYID_2);
6434
6435 if (orderByComparator != null) {
6436 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
6437 orderByComparator);
6438 }
6439 else
6440 if (pagination) {
6441 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
6442 }
6443
6444 String sql = query.toString();
6445
6446 Session session = null;
6447
6448 try {
6449 session = openSession();
6450
6451 Query q = session.createQuery(sql);
6452
6453 QueryPos qPos = QueryPos.getInstance(q);
6454
6455 qPos.add(groupId);
6456
6457 qPos.add(parentCategoryId);
6458
6459 qPos.add(vocabularyId);
6460
6461 if (!pagination) {
6462 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
6463 start, end, false);
6464
6465 Collections.sort(list);
6466
6467 list = new UnmodifiableList<AssetCategory>(list);
6468 }
6469 else {
6470 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
6471 start, end);
6472 }
6473
6474 cacheResult(list);
6475
6476 FinderCacheUtil.putResult(finderPath, finderArgs, list);
6477 }
6478 catch (Exception e) {
6479 FinderCacheUtil.removeResult(finderPath, finderArgs);
6480
6481 throw processException(e);
6482 }
6483 finally {
6484 closeSession(session);
6485 }
6486 }
6487
6488 return list;
6489 }
6490
6491
6502 public AssetCategory findByG_P_V_First(long groupId, long parentCategoryId,
6503 long vocabularyId, OrderByComparator orderByComparator)
6504 throws NoSuchCategoryException, SystemException {
6505 AssetCategory assetCategory = fetchByG_P_V_First(groupId,
6506 parentCategoryId, vocabularyId, orderByComparator);
6507
6508 if (assetCategory != null) {
6509 return assetCategory;
6510 }
6511
6512 StringBundler msg = new StringBundler(8);
6513
6514 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
6515
6516 msg.append("groupId=");
6517 msg.append(groupId);
6518
6519 msg.append(", parentCategoryId=");
6520 msg.append(parentCategoryId);
6521
6522 msg.append(", vocabularyId=");
6523 msg.append(vocabularyId);
6524
6525 msg.append(StringPool.CLOSE_CURLY_BRACE);
6526
6527 throw new NoSuchCategoryException(msg.toString());
6528 }
6529
6530
6540 public AssetCategory fetchByG_P_V_First(long groupId,
6541 long parentCategoryId, long vocabularyId,
6542 OrderByComparator orderByComparator) throws SystemException {
6543 List<AssetCategory> list = findByG_P_V(groupId, parentCategoryId,
6544 vocabularyId, 0, 1, orderByComparator);
6545
6546 if (!list.isEmpty()) {
6547 return list.get(0);
6548 }
6549
6550 return null;
6551 }
6552
6553
6564 public AssetCategory findByG_P_V_Last(long groupId, long parentCategoryId,
6565 long vocabularyId, OrderByComparator orderByComparator)
6566 throws NoSuchCategoryException, SystemException {
6567 AssetCategory assetCategory = fetchByG_P_V_Last(groupId,
6568 parentCategoryId, vocabularyId, orderByComparator);
6569
6570 if (assetCategory != null) {
6571 return assetCategory;
6572 }
6573
6574 StringBundler msg = new StringBundler(8);
6575
6576 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
6577
6578 msg.append("groupId=");
6579 msg.append(groupId);
6580
6581 msg.append(", parentCategoryId=");
6582 msg.append(parentCategoryId);
6583
6584 msg.append(", vocabularyId=");
6585 msg.append(vocabularyId);
6586
6587 msg.append(StringPool.CLOSE_CURLY_BRACE);
6588
6589 throw new NoSuchCategoryException(msg.toString());
6590 }
6591
6592
6602 public AssetCategory fetchByG_P_V_Last(long groupId, long parentCategoryId,
6603 long vocabularyId, OrderByComparator orderByComparator)
6604 throws SystemException {
6605 int count = countByG_P_V(groupId, parentCategoryId, vocabularyId);
6606
6607 List<AssetCategory> list = findByG_P_V(groupId, parentCategoryId,
6608 vocabularyId, count - 1, count, orderByComparator);
6609
6610 if (!list.isEmpty()) {
6611 return list.get(0);
6612 }
6613
6614 return null;
6615 }
6616
6617
6629 public AssetCategory[] findByG_P_V_PrevAndNext(long categoryId,
6630 long groupId, long parentCategoryId, long vocabularyId,
6631 OrderByComparator orderByComparator)
6632 throws NoSuchCategoryException, SystemException {
6633 AssetCategory assetCategory = findByPrimaryKey(categoryId);
6634
6635 Session session = null;
6636
6637 try {
6638 session = openSession();
6639
6640 AssetCategory[] array = new AssetCategoryImpl[3];
6641
6642 array[0] = getByG_P_V_PrevAndNext(session, assetCategory, groupId,
6643 parentCategoryId, vocabularyId, orderByComparator, true);
6644
6645 array[1] = assetCategory;
6646
6647 array[2] = getByG_P_V_PrevAndNext(session, assetCategory, groupId,
6648 parentCategoryId, vocabularyId, orderByComparator, false);
6649
6650 return array;
6651 }
6652 catch (Exception e) {
6653 throw processException(e);
6654 }
6655 finally {
6656 closeSession(session);
6657 }
6658 }
6659
6660 protected AssetCategory getByG_P_V_PrevAndNext(Session session,
6661 AssetCategory assetCategory, long groupId, long parentCategoryId,
6662 long vocabularyId, OrderByComparator orderByComparator, boolean previous) {
6663 StringBundler query = null;
6664
6665 if (orderByComparator != null) {
6666 query = new StringBundler(6 +
6667 (orderByComparator.getOrderByFields().length * 6));
6668 }
6669 else {
6670 query = new StringBundler(3);
6671 }
6672
6673 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
6674
6675 query.append(_FINDER_COLUMN_G_P_V_GROUPID_2);
6676
6677 query.append(_FINDER_COLUMN_G_P_V_PARENTCATEGORYID_2);
6678
6679 query.append(_FINDER_COLUMN_G_P_V_VOCABULARYID_2);
6680
6681 if (orderByComparator != null) {
6682 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
6683
6684 if (orderByConditionFields.length > 0) {
6685 query.append(WHERE_AND);
6686 }
6687
6688 for (int i = 0; i < orderByConditionFields.length; i++) {
6689 query.append(_ORDER_BY_ENTITY_ALIAS);
6690 query.append(orderByConditionFields[i]);
6691
6692 if ((i + 1) < orderByConditionFields.length) {
6693 if (orderByComparator.isAscending() ^ previous) {
6694 query.append(WHERE_GREATER_THAN_HAS_NEXT);
6695 }
6696 else {
6697 query.append(WHERE_LESSER_THAN_HAS_NEXT);
6698 }
6699 }
6700 else {
6701 if (orderByComparator.isAscending() ^ previous) {
6702 query.append(WHERE_GREATER_THAN);
6703 }
6704 else {
6705 query.append(WHERE_LESSER_THAN);
6706 }
6707 }
6708 }
6709
6710 query.append(ORDER_BY_CLAUSE);
6711
6712 String[] orderByFields = orderByComparator.getOrderByFields();
6713
6714 for (int i = 0; i < orderByFields.length; i++) {
6715 query.append(_ORDER_BY_ENTITY_ALIAS);
6716 query.append(orderByFields[i]);
6717
6718 if ((i + 1) < orderByFields.length) {
6719 if (orderByComparator.isAscending() ^ previous) {
6720 query.append(ORDER_BY_ASC_HAS_NEXT);
6721 }
6722 else {
6723 query.append(ORDER_BY_DESC_HAS_NEXT);
6724 }
6725 }
6726 else {
6727 if (orderByComparator.isAscending() ^ previous) {
6728 query.append(ORDER_BY_ASC);
6729 }
6730 else {
6731 query.append(ORDER_BY_DESC);
6732 }
6733 }
6734 }
6735 }
6736 else {
6737 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
6738 }
6739
6740 String sql = query.toString();
6741
6742 Query q = session.createQuery(sql);
6743
6744 q.setFirstResult(0);
6745 q.setMaxResults(2);
6746
6747 QueryPos qPos = QueryPos.getInstance(q);
6748
6749 qPos.add(groupId);
6750
6751 qPos.add(parentCategoryId);
6752
6753 qPos.add(vocabularyId);
6754
6755 if (orderByComparator != null) {
6756 Object[] values = orderByComparator.getOrderByConditionValues(assetCategory);
6757
6758 for (Object value : values) {
6759 qPos.add(value);
6760 }
6761 }
6762
6763 List<AssetCategory> list = q.list();
6764
6765 if (list.size() == 2) {
6766 return list.get(1);
6767 }
6768 else {
6769 return null;
6770 }
6771 }
6772
6773
6782 public List<AssetCategory> filterFindByG_P_V(long groupId,
6783 long parentCategoryId, long vocabularyId) throws SystemException {
6784 return filterFindByG_P_V(groupId, parentCategoryId, vocabularyId,
6785 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
6786 }
6787
6788
6803 public List<AssetCategory> filterFindByG_P_V(long groupId,
6804 long parentCategoryId, long vocabularyId, int start, int end)
6805 throws SystemException {
6806 return filterFindByG_P_V(groupId, parentCategoryId, vocabularyId,
6807 start, end, null);
6808 }
6809
6810
6826 public List<AssetCategory> filterFindByG_P_V(long groupId,
6827 long parentCategoryId, long vocabularyId, int start, int end,
6828 OrderByComparator orderByComparator) throws SystemException {
6829 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
6830 return findByG_P_V(groupId, parentCategoryId, vocabularyId, start,
6831 end, orderByComparator);
6832 }
6833
6834 StringBundler query = null;
6835
6836 if (orderByComparator != null) {
6837 query = new StringBundler(5 +
6838 (orderByComparator.getOrderByFields().length * 3));
6839 }
6840 else {
6841 query = new StringBundler(5);
6842 }
6843
6844 if (getDB().isSupportsInlineDistinct()) {
6845 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_WHERE);
6846 }
6847 else {
6848 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_1);
6849 }
6850
6851 query.append(_FINDER_COLUMN_G_P_V_GROUPID_2);
6852
6853 query.append(_FINDER_COLUMN_G_P_V_PARENTCATEGORYID_2);
6854
6855 query.append(_FINDER_COLUMN_G_P_V_VOCABULARYID_2);
6856
6857 if (!getDB().isSupportsInlineDistinct()) {
6858 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_2);
6859 }
6860
6861 if (orderByComparator != null) {
6862 if (getDB().isSupportsInlineDistinct()) {
6863 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
6864 orderByComparator, true);
6865 }
6866 else {
6867 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
6868 orderByComparator, true);
6869 }
6870 }
6871 else {
6872 if (getDB().isSupportsInlineDistinct()) {
6873 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
6874 }
6875 else {
6876 query.append(AssetCategoryModelImpl.ORDER_BY_SQL);
6877 }
6878 }
6879
6880 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
6881 AssetCategory.class.getName(),
6882 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
6883
6884 Session session = null;
6885
6886 try {
6887 session = openSession();
6888
6889 SQLQuery q = session.createSQLQuery(sql);
6890
6891 if (getDB().isSupportsInlineDistinct()) {
6892 q.addEntity(_FILTER_ENTITY_ALIAS, AssetCategoryImpl.class);
6893 }
6894 else {
6895 q.addEntity(_FILTER_ENTITY_TABLE, AssetCategoryImpl.class);
6896 }
6897
6898 QueryPos qPos = QueryPos.getInstance(q);
6899
6900 qPos.add(groupId);
6901
6902 qPos.add(parentCategoryId);
6903
6904 qPos.add(vocabularyId);
6905
6906 return (List<AssetCategory>)QueryUtil.list(q, getDialect(), start,
6907 end);
6908 }
6909 catch (Exception e) {
6910 throw processException(e);
6911 }
6912 finally {
6913 closeSession(session);
6914 }
6915 }
6916
6917
6929 public AssetCategory[] filterFindByG_P_V_PrevAndNext(long categoryId,
6930 long groupId, long parentCategoryId, long vocabularyId,
6931 OrderByComparator orderByComparator)
6932 throws NoSuchCategoryException, SystemException {
6933 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
6934 return findByG_P_V_PrevAndNext(categoryId, groupId,
6935 parentCategoryId, vocabularyId, orderByComparator);
6936 }
6937
6938 AssetCategory assetCategory = findByPrimaryKey(categoryId);
6939
6940 Session session = null;
6941
6942 try {
6943 session = openSession();
6944
6945 AssetCategory[] array = new AssetCategoryImpl[3];
6946
6947 array[0] = filterGetByG_P_V_PrevAndNext(session, assetCategory,
6948 groupId, parentCategoryId, vocabularyId, orderByComparator,
6949 true);
6950
6951 array[1] = assetCategory;
6952
6953 array[2] = filterGetByG_P_V_PrevAndNext(session, assetCategory,
6954 groupId, parentCategoryId, vocabularyId, orderByComparator,
6955 false);
6956
6957 return array;
6958 }
6959 catch (Exception e) {
6960 throw processException(e);
6961 }
6962 finally {
6963 closeSession(session);
6964 }
6965 }
6966
6967 protected AssetCategory filterGetByG_P_V_PrevAndNext(Session session,
6968 AssetCategory assetCategory, long groupId, long parentCategoryId,
6969 long vocabularyId, OrderByComparator orderByComparator, boolean previous) {
6970 StringBundler query = null;
6971
6972 if (orderByComparator != null) {
6973 query = new StringBundler(6 +
6974 (orderByComparator.getOrderByFields().length * 6));
6975 }
6976 else {
6977 query = new StringBundler(3);
6978 }
6979
6980 if (getDB().isSupportsInlineDistinct()) {
6981 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_WHERE);
6982 }
6983 else {
6984 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_1);
6985 }
6986
6987 query.append(_FINDER_COLUMN_G_P_V_GROUPID_2);
6988
6989 query.append(_FINDER_COLUMN_G_P_V_PARENTCATEGORYID_2);
6990
6991 query.append(_FINDER_COLUMN_G_P_V_VOCABULARYID_2);
6992
6993 if (!getDB().isSupportsInlineDistinct()) {
6994 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_2);
6995 }
6996
6997 if (orderByComparator != null) {
6998 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
6999
7000 if (orderByConditionFields.length > 0) {
7001 query.append(WHERE_AND);
7002 }
7003
7004 for (int i = 0; i < orderByConditionFields.length; i++) {
7005 if (getDB().isSupportsInlineDistinct()) {
7006 query.append(_ORDER_BY_ENTITY_ALIAS);
7007 }
7008 else {
7009 query.append(_ORDER_BY_ENTITY_TABLE);
7010 }
7011
7012 query.append(orderByConditionFields[i]);
7013
7014 if ((i + 1) < orderByConditionFields.length) {
7015 if (orderByComparator.isAscending() ^ previous) {
7016 query.append(WHERE_GREATER_THAN_HAS_NEXT);
7017 }
7018 else {
7019 query.append(WHERE_LESSER_THAN_HAS_NEXT);
7020 }
7021 }
7022 else {
7023 if (orderByComparator.isAscending() ^ previous) {
7024 query.append(WHERE_GREATER_THAN);
7025 }
7026 else {
7027 query.append(WHERE_LESSER_THAN);
7028 }
7029 }
7030 }
7031
7032 query.append(ORDER_BY_CLAUSE);
7033
7034 String[] orderByFields = orderByComparator.getOrderByFields();
7035
7036 for (int i = 0; i < orderByFields.length; i++) {
7037 if (getDB().isSupportsInlineDistinct()) {
7038 query.append(_ORDER_BY_ENTITY_ALIAS);
7039 }
7040 else {
7041 query.append(_ORDER_BY_ENTITY_TABLE);
7042 }
7043
7044 query.append(orderByFields[i]);
7045
7046 if ((i + 1) < orderByFields.length) {
7047 if (orderByComparator.isAscending() ^ previous) {
7048 query.append(ORDER_BY_ASC_HAS_NEXT);
7049 }
7050 else {
7051 query.append(ORDER_BY_DESC_HAS_NEXT);
7052 }
7053 }
7054 else {
7055 if (orderByComparator.isAscending() ^ previous) {
7056 query.append(ORDER_BY_ASC);
7057 }
7058 else {
7059 query.append(ORDER_BY_DESC);
7060 }
7061 }
7062 }
7063 }
7064 else {
7065 if (getDB().isSupportsInlineDistinct()) {
7066 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
7067 }
7068 else {
7069 query.append(AssetCategoryModelImpl.ORDER_BY_SQL);
7070 }
7071 }
7072
7073 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
7074 AssetCategory.class.getName(),
7075 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
7076
7077 SQLQuery q = session.createSQLQuery(sql);
7078
7079 q.setFirstResult(0);
7080 q.setMaxResults(2);
7081
7082 if (getDB().isSupportsInlineDistinct()) {
7083 q.addEntity(_FILTER_ENTITY_ALIAS, AssetCategoryImpl.class);
7084 }
7085 else {
7086 q.addEntity(_FILTER_ENTITY_TABLE, AssetCategoryImpl.class);
7087 }
7088
7089 QueryPos qPos = QueryPos.getInstance(q);
7090
7091 qPos.add(groupId);
7092
7093 qPos.add(parentCategoryId);
7094
7095 qPos.add(vocabularyId);
7096
7097 if (orderByComparator != null) {
7098 Object[] values = orderByComparator.getOrderByConditionValues(assetCategory);
7099
7100 for (Object value : values) {
7101 qPos.add(value);
7102 }
7103 }
7104
7105 List<AssetCategory> list = q.list();
7106
7107 if (list.size() == 2) {
7108 return list.get(1);
7109 }
7110 else {
7111 return null;
7112 }
7113 }
7114
7115
7123 public void removeByG_P_V(long groupId, long parentCategoryId,
7124 long vocabularyId) throws SystemException {
7125 for (AssetCategory assetCategory : findByG_P_V(groupId,
7126 parentCategoryId, vocabularyId, QueryUtil.ALL_POS,
7127 QueryUtil.ALL_POS, null)) {
7128 remove(assetCategory);
7129 }
7130 }
7131
7132
7141 public int countByG_P_V(long groupId, long parentCategoryId,
7142 long vocabularyId) throws SystemException {
7143 FinderPath finderPath = FINDER_PATH_COUNT_BY_G_P_V;
7144
7145 Object[] finderArgs = new Object[] {
7146 groupId, parentCategoryId, vocabularyId
7147 };
7148
7149 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
7150 this);
7151
7152 if (count == null) {
7153 StringBundler query = new StringBundler(4);
7154
7155 query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
7156
7157 query.append(_FINDER_COLUMN_G_P_V_GROUPID_2);
7158
7159 query.append(_FINDER_COLUMN_G_P_V_PARENTCATEGORYID_2);
7160
7161 query.append(_FINDER_COLUMN_G_P_V_VOCABULARYID_2);
7162
7163 String sql = query.toString();
7164
7165 Session session = null;
7166
7167 try {
7168 session = openSession();
7169
7170 Query q = session.createQuery(sql);
7171
7172 QueryPos qPos = QueryPos.getInstance(q);
7173
7174 qPos.add(groupId);
7175
7176 qPos.add(parentCategoryId);
7177
7178 qPos.add(vocabularyId);
7179
7180 count = (Long)q.uniqueResult();
7181
7182 FinderCacheUtil.putResult(finderPath, finderArgs, count);
7183 }
7184 catch (Exception e) {
7185 FinderCacheUtil.removeResult(finderPath, finderArgs);
7186
7187 throw processException(e);
7188 }
7189 finally {
7190 closeSession(session);
7191 }
7192 }
7193
7194 return count.intValue();
7195 }
7196
7197
7206 public int filterCountByG_P_V(long groupId, long parentCategoryId,
7207 long vocabularyId) throws SystemException {
7208 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
7209 return countByG_P_V(groupId, parentCategoryId, vocabularyId);
7210 }
7211
7212 StringBundler query = new StringBundler(4);
7213
7214 query.append(_FILTER_SQL_COUNT_ASSETCATEGORY_WHERE);
7215
7216 query.append(_FINDER_COLUMN_G_P_V_GROUPID_2);
7217
7218 query.append(_FINDER_COLUMN_G_P_V_PARENTCATEGORYID_2);
7219
7220 query.append(_FINDER_COLUMN_G_P_V_VOCABULARYID_2);
7221
7222 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
7223 AssetCategory.class.getName(),
7224 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
7225
7226 Session session = null;
7227
7228 try {
7229 session = openSession();
7230
7231 SQLQuery q = session.createSQLQuery(sql);
7232
7233 q.addScalar(COUNT_COLUMN_NAME,
7234 com.liferay.portal.kernel.dao.orm.Type.LONG);
7235
7236 QueryPos qPos = QueryPos.getInstance(q);
7237
7238 qPos.add(groupId);
7239
7240 qPos.add(parentCategoryId);
7241
7242 qPos.add(vocabularyId);
7243
7244 Long count = (Long)q.uniqueResult();
7245
7246 return count.intValue();
7247 }
7248 catch (Exception e) {
7249 throw processException(e);
7250 }
7251 finally {
7252 closeSession(session);
7253 }
7254 }
7255
7256 private static final String _FINDER_COLUMN_G_P_V_GROUPID_2 = "assetCategory.groupId = ? AND ";
7257 private static final String _FINDER_COLUMN_G_P_V_PARENTCATEGORYID_2 = "assetCategory.parentCategoryId = ? AND ";
7258 private static final String _FINDER_COLUMN_G_P_V_VOCABULARYID_2 = "assetCategory.vocabularyId = ?";
7259 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_LIKEN_V =
7260 new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
7261 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
7262 AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
7263 "findByG_LikeN_V",
7264 new String[] {
7265 Long.class.getName(), String.class.getName(),
7266 Long.class.getName(),
7267
7268 Integer.class.getName(), Integer.class.getName(),
7269 OrderByComparator.class.getName()
7270 });
7271 public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_LIKEN_V =
7272 new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
7273 AssetCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class,
7274 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_LikeN_V",
7275 new String[] {
7276 Long.class.getName(), String.class.getName(),
7277 Long.class.getName()
7278 });
7279
7280
7289 public List<AssetCategory> findByG_LikeN_V(long groupId, String name,
7290 long vocabularyId) throws SystemException {
7291 return findByG_LikeN_V(groupId, name, vocabularyId, QueryUtil.ALL_POS,
7292 QueryUtil.ALL_POS, null);
7293 }
7294
7295
7310 public List<AssetCategory> findByG_LikeN_V(long groupId, String name,
7311 long vocabularyId, int start, int end) throws SystemException {
7312 return findByG_LikeN_V(groupId, name, vocabularyId, start, end, null);
7313 }
7314
7315
7331 public List<AssetCategory> findByG_LikeN_V(long groupId, String name,
7332 long vocabularyId, int start, int end,
7333 OrderByComparator orderByComparator) throws SystemException {
7334 boolean pagination = true;
7335 FinderPath finderPath = null;
7336 Object[] finderArgs = null;
7337
7338 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_LIKEN_V;
7339 finderArgs = new Object[] {
7340 groupId, name, vocabularyId,
7341
7342 start, end, orderByComparator
7343 };
7344
7345 List<AssetCategory> list = (List<AssetCategory>)FinderCacheUtil.getResult(finderPath,
7346 finderArgs, this);
7347
7348 if ((list != null) && !list.isEmpty()) {
7349 for (AssetCategory assetCategory : list) {
7350 if ((groupId != assetCategory.getGroupId()) ||
7351 !Validator.equals(name, assetCategory.getName()) ||
7352 (vocabularyId != assetCategory.getVocabularyId())) {
7353 list = null;
7354
7355 break;
7356 }
7357 }
7358 }
7359
7360 if (list == null) {
7361 StringBundler query = null;
7362
7363 if (orderByComparator != null) {
7364 query = new StringBundler(5 +
7365 (orderByComparator.getOrderByFields().length * 3));
7366 }
7367 else {
7368 query = new StringBundler(5);
7369 }
7370
7371 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
7372
7373 query.append(_FINDER_COLUMN_G_LIKEN_V_GROUPID_2);
7374
7375 boolean bindName = false;
7376
7377 if (name == null) {
7378 query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_1);
7379 }
7380 else if (name.equals(StringPool.BLANK)) {
7381 query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_3);
7382 }
7383 else {
7384 bindName = true;
7385
7386 query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_2);
7387 }
7388
7389 query.append(_FINDER_COLUMN_G_LIKEN_V_VOCABULARYID_2);
7390
7391 if (orderByComparator != null) {
7392 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
7393 orderByComparator);
7394 }
7395 else
7396 if (pagination) {
7397 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
7398 }
7399
7400 String sql = query.toString();
7401
7402 Session session = null;
7403
7404 try {
7405 session = openSession();
7406
7407 Query q = session.createQuery(sql);
7408
7409 QueryPos qPos = QueryPos.getInstance(q);
7410
7411 qPos.add(groupId);
7412
7413 if (bindName) {
7414 qPos.add(name);
7415 }
7416
7417 qPos.add(vocabularyId);
7418
7419 if (!pagination) {
7420 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
7421 start, end, false);
7422
7423 Collections.sort(list);
7424
7425 list = new UnmodifiableList<AssetCategory>(list);
7426 }
7427 else {
7428 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
7429 start, end);
7430 }
7431
7432 cacheResult(list);
7433
7434 FinderCacheUtil.putResult(finderPath, finderArgs, list);
7435 }
7436 catch (Exception e) {
7437 FinderCacheUtil.removeResult(finderPath, finderArgs);
7438
7439 throw processException(e);
7440 }
7441 finally {
7442 closeSession(session);
7443 }
7444 }
7445
7446 return list;
7447 }
7448
7449
7460 public AssetCategory findByG_LikeN_V_First(long groupId, String name,
7461 long vocabularyId, OrderByComparator orderByComparator)
7462 throws NoSuchCategoryException, SystemException {
7463 AssetCategory assetCategory = fetchByG_LikeN_V_First(groupId, name,
7464 vocabularyId, orderByComparator);
7465
7466 if (assetCategory != null) {
7467 return assetCategory;
7468 }
7469
7470 StringBundler msg = new StringBundler(8);
7471
7472 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
7473
7474 msg.append("groupId=");
7475 msg.append(groupId);
7476
7477 msg.append(", name=");
7478 msg.append(name);
7479
7480 msg.append(", vocabularyId=");
7481 msg.append(vocabularyId);
7482
7483 msg.append(StringPool.CLOSE_CURLY_BRACE);
7484
7485 throw new NoSuchCategoryException(msg.toString());
7486 }
7487
7488
7498 public AssetCategory fetchByG_LikeN_V_First(long groupId, String name,
7499 long vocabularyId, OrderByComparator orderByComparator)
7500 throws SystemException {
7501 List<AssetCategory> list = findByG_LikeN_V(groupId, name, vocabularyId,
7502 0, 1, orderByComparator);
7503
7504 if (!list.isEmpty()) {
7505 return list.get(0);
7506 }
7507
7508 return null;
7509 }
7510
7511
7522 public AssetCategory findByG_LikeN_V_Last(long groupId, String name,
7523 long vocabularyId, OrderByComparator orderByComparator)
7524 throws NoSuchCategoryException, SystemException {
7525 AssetCategory assetCategory = fetchByG_LikeN_V_Last(groupId, name,
7526 vocabularyId, orderByComparator);
7527
7528 if (assetCategory != null) {
7529 return assetCategory;
7530 }
7531
7532 StringBundler msg = new StringBundler(8);
7533
7534 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
7535
7536 msg.append("groupId=");
7537 msg.append(groupId);
7538
7539 msg.append(", name=");
7540 msg.append(name);
7541
7542 msg.append(", vocabularyId=");
7543 msg.append(vocabularyId);
7544
7545 msg.append(StringPool.CLOSE_CURLY_BRACE);
7546
7547 throw new NoSuchCategoryException(msg.toString());
7548 }
7549
7550
7560 public AssetCategory fetchByG_LikeN_V_Last(long groupId, String name,
7561 long vocabularyId, OrderByComparator orderByComparator)
7562 throws SystemException {
7563 int count = countByG_LikeN_V(groupId, name, vocabularyId);
7564
7565 List<AssetCategory> list = findByG_LikeN_V(groupId, name, vocabularyId,
7566 count - 1, count, orderByComparator);
7567
7568 if (!list.isEmpty()) {
7569 return list.get(0);
7570 }
7571
7572 return null;
7573 }
7574
7575
7587 public AssetCategory[] findByG_LikeN_V_PrevAndNext(long categoryId,
7588 long groupId, String name, long vocabularyId,
7589 OrderByComparator orderByComparator)
7590 throws NoSuchCategoryException, SystemException {
7591 AssetCategory assetCategory = findByPrimaryKey(categoryId);
7592
7593 Session session = null;
7594
7595 try {
7596 session = openSession();
7597
7598 AssetCategory[] array = new AssetCategoryImpl[3];
7599
7600 array[0] = getByG_LikeN_V_PrevAndNext(session, assetCategory,
7601 groupId, name, vocabularyId, orderByComparator, true);
7602
7603 array[1] = assetCategory;
7604
7605 array[2] = getByG_LikeN_V_PrevAndNext(session, assetCategory,
7606 groupId, name, vocabularyId, orderByComparator, false);
7607
7608 return array;
7609 }
7610 catch (Exception e) {
7611 throw processException(e);
7612 }
7613 finally {
7614 closeSession(session);
7615 }
7616 }
7617
7618 protected AssetCategory getByG_LikeN_V_PrevAndNext(Session session,
7619 AssetCategory assetCategory, long groupId, String name,
7620 long vocabularyId, OrderByComparator orderByComparator, boolean previous) {
7621 StringBundler query = null;
7622
7623 if (orderByComparator != null) {
7624 query = new StringBundler(6 +
7625 (orderByComparator.getOrderByFields().length * 6));
7626 }
7627 else {
7628 query = new StringBundler(3);
7629 }
7630
7631 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
7632
7633 query.append(_FINDER_COLUMN_G_LIKEN_V_GROUPID_2);
7634
7635 boolean bindName = false;
7636
7637 if (name == null) {
7638 query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_1);
7639 }
7640 else if (name.equals(StringPool.BLANK)) {
7641 query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_3);
7642 }
7643 else {
7644 bindName = true;
7645
7646 query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_2);
7647 }
7648
7649 query.append(_FINDER_COLUMN_G_LIKEN_V_VOCABULARYID_2);
7650
7651 if (orderByComparator != null) {
7652 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
7653
7654 if (orderByConditionFields.length > 0) {
7655 query.append(WHERE_AND);
7656 }
7657
7658 for (int i = 0; i < orderByConditionFields.length; i++) {
7659 query.append(_ORDER_BY_ENTITY_ALIAS);
7660 query.append(orderByConditionFields[i]);
7661
7662 if ((i + 1) < orderByConditionFields.length) {
7663 if (orderByComparator.isAscending() ^ previous) {
7664 query.append(WHERE_GREATER_THAN_HAS_NEXT);
7665 }
7666 else {
7667 query.append(WHERE_LESSER_THAN_HAS_NEXT);
7668 }
7669 }
7670 else {
7671 if (orderByComparator.isAscending() ^ previous) {
7672 query.append(WHERE_GREATER_THAN);
7673 }
7674 else {
7675 query.append(WHERE_LESSER_THAN);
7676 }
7677 }
7678 }
7679
7680 query.append(ORDER_BY_CLAUSE);
7681
7682 String[] orderByFields = orderByComparator.getOrderByFields();
7683
7684 for (int i = 0; i < orderByFields.length; i++) {
7685 query.append(_ORDER_BY_ENTITY_ALIAS);
7686 query.append(orderByFields[i]);
7687
7688 if ((i + 1) < orderByFields.length) {
7689 if (orderByComparator.isAscending() ^ previous) {
7690 query.append(ORDER_BY_ASC_HAS_NEXT);
7691 }
7692 else {
7693 query.append(ORDER_BY_DESC_HAS_NEXT);
7694 }
7695 }
7696 else {
7697 if (orderByComparator.isAscending() ^ previous) {
7698 query.append(ORDER_BY_ASC);
7699 }
7700 else {
7701 query.append(ORDER_BY_DESC);
7702 }
7703 }
7704 }
7705 }
7706 else {
7707 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
7708 }
7709
7710 String sql = query.toString();
7711
7712 Query q = session.createQuery(sql);
7713
7714 q.setFirstResult(0);
7715 q.setMaxResults(2);
7716
7717 QueryPos qPos = QueryPos.getInstance(q);
7718
7719 qPos.add(groupId);
7720
7721 if (bindName) {
7722 qPos.add(name);
7723 }
7724
7725 qPos.add(vocabularyId);
7726
7727 if (orderByComparator != null) {
7728 Object[] values = orderByComparator.getOrderByConditionValues(assetCategory);
7729
7730 for (Object value : values) {
7731 qPos.add(value);
7732 }
7733 }
7734
7735 List<AssetCategory> list = q.list();
7736
7737 if (list.size() == 2) {
7738 return list.get(1);
7739 }
7740 else {
7741 return null;
7742 }
7743 }
7744
7745
7754 public List<AssetCategory> filterFindByG_LikeN_V(long groupId, String name,
7755 long vocabularyId) throws SystemException {
7756 return filterFindByG_LikeN_V(groupId, name, vocabularyId,
7757 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
7758 }
7759
7760
7775 public List<AssetCategory> filterFindByG_LikeN_V(long groupId, String name,
7776 long vocabularyId, int start, int end) throws SystemException {
7777 return filterFindByG_LikeN_V(groupId, name, vocabularyId, start, end,
7778 null);
7779 }
7780
7781
7797 public List<AssetCategory> filterFindByG_LikeN_V(long groupId, String name,
7798 long vocabularyId, int start, int end,
7799 OrderByComparator orderByComparator) throws SystemException {
7800 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
7801 return findByG_LikeN_V(groupId, name, vocabularyId, start, end,
7802 orderByComparator);
7803 }
7804
7805 StringBundler query = null;
7806
7807 if (orderByComparator != null) {
7808 query = new StringBundler(5 +
7809 (orderByComparator.getOrderByFields().length * 3));
7810 }
7811 else {
7812 query = new StringBundler(5);
7813 }
7814
7815 if (getDB().isSupportsInlineDistinct()) {
7816 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_WHERE);
7817 }
7818 else {
7819 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_1);
7820 }
7821
7822 query.append(_FINDER_COLUMN_G_LIKEN_V_GROUPID_2);
7823
7824 boolean bindName = false;
7825
7826 if (name == null) {
7827 query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_1);
7828 }
7829 else if (name.equals(StringPool.BLANK)) {
7830 query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_3);
7831 }
7832 else {
7833 bindName = true;
7834
7835 query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_2);
7836 }
7837
7838 query.append(_FINDER_COLUMN_G_LIKEN_V_VOCABULARYID_2);
7839
7840 if (!getDB().isSupportsInlineDistinct()) {
7841 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_2);
7842 }
7843
7844 if (orderByComparator != null) {
7845 if (getDB().isSupportsInlineDistinct()) {
7846 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
7847 orderByComparator, true);
7848 }
7849 else {
7850 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
7851 orderByComparator, true);
7852 }
7853 }
7854 else {
7855 if (getDB().isSupportsInlineDistinct()) {
7856 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
7857 }
7858 else {
7859 query.append(AssetCategoryModelImpl.ORDER_BY_SQL);
7860 }
7861 }
7862
7863 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
7864 AssetCategory.class.getName(),
7865 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
7866
7867 Session session = null;
7868
7869 try {
7870 session = openSession();
7871
7872 SQLQuery q = session.createSQLQuery(sql);
7873
7874 if (getDB().isSupportsInlineDistinct()) {
7875 q.addEntity(_FILTER_ENTITY_ALIAS, AssetCategoryImpl.class);
7876 }
7877 else {
7878 q.addEntity(_FILTER_ENTITY_TABLE, AssetCategoryImpl.class);
7879 }
7880
7881 QueryPos qPos = QueryPos.getInstance(q);
7882
7883 qPos.add(groupId);
7884
7885 if (bindName) {
7886 qPos.add(name);
7887 }
7888
7889 qPos.add(vocabularyId);
7890
7891 return (List<AssetCategory>)QueryUtil.list(q, getDialect(), start,
7892 end);
7893 }
7894 catch (Exception e) {
7895 throw processException(e);
7896 }
7897 finally {
7898 closeSession(session);
7899 }
7900 }
7901
7902
7914 public AssetCategory[] filterFindByG_LikeN_V_PrevAndNext(long categoryId,
7915 long groupId, String name, long vocabularyId,
7916 OrderByComparator orderByComparator)
7917 throws NoSuchCategoryException, SystemException {
7918 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
7919 return findByG_LikeN_V_PrevAndNext(categoryId, groupId, name,
7920 vocabularyId, orderByComparator);
7921 }
7922
7923 AssetCategory assetCategory = findByPrimaryKey(categoryId);
7924
7925 Session session = null;
7926
7927 try {
7928 session = openSession();
7929
7930 AssetCategory[] array = new AssetCategoryImpl[3];
7931
7932 array[0] = filterGetByG_LikeN_V_PrevAndNext(session, assetCategory,
7933 groupId, name, vocabularyId, orderByComparator, true);
7934
7935 array[1] = assetCategory;
7936
7937 array[2] = filterGetByG_LikeN_V_PrevAndNext(session, assetCategory,
7938 groupId, name, vocabularyId, orderByComparator, false);
7939
7940 return array;
7941 }
7942 catch (Exception e) {
7943 throw processException(e);
7944 }
7945 finally {
7946 closeSession(session);
7947 }
7948 }
7949
7950 protected AssetCategory filterGetByG_LikeN_V_PrevAndNext(Session session,
7951 AssetCategory assetCategory, long groupId, String name,
7952 long vocabularyId, OrderByComparator orderByComparator, 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.createSQLQuery(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(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
8121 public List<AssetCategory> filterFindByG_LikeN_V(long groupId, String name,
8122 long[] vocabularyIds) throws SystemException {
8123 return filterFindByG_LikeN_V(groupId, name, vocabularyIds,
8124 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
8125 }
8126
8127
8142 public List<AssetCategory> filterFindByG_LikeN_V(long groupId, String name,
8143 long[] vocabularyIds, int start, int end) throws SystemException {
8144 return filterFindByG_LikeN_V(groupId, name, vocabularyIds, start, end,
8145 null);
8146 }
8147
8148
8164 public List<AssetCategory> filterFindByG_LikeN_V(long groupId, String name,
8165 long[] vocabularyIds, int start, int end,
8166 OrderByComparator orderByComparator) throws SystemException {
8167 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
8168 return findByG_LikeN_V(groupId, name, vocabularyIds, start, end,
8169 orderByComparator);
8170 }
8171
8172 StringBundler query = new StringBundler();
8173
8174 if (getDB().isSupportsInlineDistinct()) {
8175 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_WHERE);
8176 }
8177 else {
8178 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_1);
8179 }
8180
8181 boolean conjunctionable = false;
8182
8183 if (conjunctionable) {
8184 query.append(WHERE_AND);
8185 }
8186
8187 query.append(_FINDER_COLUMN_G_LIKEN_V_GROUPID_5);
8188
8189 conjunctionable = true;
8190
8191 if (conjunctionable) {
8192 query.append(WHERE_AND);
8193 }
8194
8195 if (name == null) {
8196 query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_4);
8197 }
8198 else if (name.equals(StringPool.BLANK)) {
8199 query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_6);
8200 }
8201 else {
8202 query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_5);
8203 }
8204
8205 conjunctionable = true;
8206
8207 if ((vocabularyIds == null) || (vocabularyIds.length > 0)) {
8208 if (conjunctionable) {
8209 query.append(WHERE_AND);
8210 }
8211
8212 query.append(StringPool.OPEN_PARENTHESIS);
8213
8214 for (int i = 0; i < vocabularyIds.length; i++) {
8215 query.append(_FINDER_COLUMN_G_LIKEN_V_VOCABULARYID_5);
8216
8217 if ((i + 1) < vocabularyIds.length) {
8218 query.append(WHERE_OR);
8219 }
8220 }
8221
8222 query.append(StringPool.CLOSE_PARENTHESIS);
8223
8224 conjunctionable = true;
8225 }
8226
8227 if (!getDB().isSupportsInlineDistinct()) {
8228 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_2);
8229 }
8230
8231 if (orderByComparator != null) {
8232 if (getDB().isSupportsInlineDistinct()) {
8233 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
8234 orderByComparator, true);
8235 }
8236 else {
8237 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
8238 orderByComparator, true);
8239 }
8240 }
8241 else {
8242 if (getDB().isSupportsInlineDistinct()) {
8243 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
8244 }
8245 else {
8246 query.append(AssetCategoryModelImpl.ORDER_BY_SQL);
8247 }
8248 }
8249
8250 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
8251 AssetCategory.class.getName(),
8252 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
8253
8254 Session session = null;
8255
8256 try {
8257 session = openSession();
8258
8259 SQLQuery q = session.createSQLQuery(sql);
8260
8261 if (getDB().isSupportsInlineDistinct()) {
8262 q.addEntity(_FILTER_ENTITY_ALIAS, AssetCategoryImpl.class);
8263 }
8264 else {
8265 q.addEntity(_FILTER_ENTITY_TABLE, AssetCategoryImpl.class);
8266 }
8267
8268 QueryPos qPos = QueryPos.getInstance(q);
8269
8270 qPos.add(groupId);
8271
8272 if (name != null) {
8273 qPos.add(name);
8274 }
8275
8276 if (vocabularyIds != null) {
8277 qPos.add(vocabularyIds);
8278 }
8279
8280 return (List<AssetCategory>)QueryUtil.list(q, getDialect(), start,
8281 end);
8282 }
8283 catch (Exception e) {
8284 throw processException(e);
8285 }
8286 finally {
8287 closeSession(session);
8288 }
8289 }
8290
8291
8304 public List<AssetCategory> findByG_LikeN_V(long groupId, String name,
8305 long[] vocabularyIds) throws SystemException {
8306 return findByG_LikeN_V(groupId, name, vocabularyIds, QueryUtil.ALL_POS,
8307 QueryUtil.ALL_POS, null);
8308 }
8309
8310
8325 public List<AssetCategory> findByG_LikeN_V(long groupId, String name,
8326 long[] vocabularyIds, int start, int end) throws SystemException {
8327 return findByG_LikeN_V(groupId, name, vocabularyIds, start, end, null);
8328 }
8329
8330
8346 public List<AssetCategory> findByG_LikeN_V(long groupId, String name,
8347 long[] vocabularyIds, int start, int end,
8348 OrderByComparator orderByComparator) throws SystemException {
8349 if ((vocabularyIds != null) && (vocabularyIds.length == 1)) {
8350 return findByG_LikeN_V(groupId, name, vocabularyIds[0], start, end,
8351 orderByComparator);
8352 }
8353
8354 boolean pagination = true;
8355 Object[] finderArgs = null;
8356
8357 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
8358 (orderByComparator == null)) {
8359 pagination = false;
8360 finderArgs = new Object[] {
8361 groupId, name, StringUtil.merge(vocabularyIds)
8362 };
8363 }
8364 else {
8365 finderArgs = new Object[] {
8366 groupId, name, StringUtil.merge(vocabularyIds),
8367
8368 start, end, orderByComparator
8369 };
8370 }
8371
8372 List<AssetCategory> list = (List<AssetCategory>)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_LIKEN_V,
8373 finderArgs, this);
8374
8375 if ((list != null) && !list.isEmpty()) {
8376 for (AssetCategory assetCategory : list) {
8377 if ((groupId != assetCategory.getGroupId()) ||
8378 !Validator.equals(name, assetCategory.getName()) ||
8379 !ArrayUtil.contains(vocabularyIds,
8380 assetCategory.getVocabularyId())) {
8381 list = null;
8382
8383 break;
8384 }
8385 }
8386 }
8387
8388 if (list == null) {
8389 StringBundler query = new StringBundler();
8390
8391 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
8392
8393 boolean conjunctionable = false;
8394
8395 if (conjunctionable) {
8396 query.append(WHERE_AND);
8397 }
8398
8399 query.append(_FINDER_COLUMN_G_LIKEN_V_GROUPID_5);
8400
8401 conjunctionable = true;
8402
8403 if (conjunctionable) {
8404 query.append(WHERE_AND);
8405 }
8406
8407 if (name == null) {
8408 query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_4);
8409 }
8410 else if (name.equals(StringPool.BLANK)) {
8411 query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_6);
8412 }
8413 else {
8414 query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_5);
8415 }
8416
8417 conjunctionable = true;
8418
8419 if ((vocabularyIds == null) || (vocabularyIds.length > 0)) {
8420 if (conjunctionable) {
8421 query.append(WHERE_AND);
8422 }
8423
8424 query.append(StringPool.OPEN_PARENTHESIS);
8425
8426 for (int i = 0; i < vocabularyIds.length; i++) {
8427 query.append(_FINDER_COLUMN_G_LIKEN_V_VOCABULARYID_5);
8428
8429 if ((i + 1) < vocabularyIds.length) {
8430 query.append(WHERE_OR);
8431 }
8432 }
8433
8434 query.append(StringPool.CLOSE_PARENTHESIS);
8435
8436 conjunctionable = true;
8437 }
8438
8439 if (orderByComparator != null) {
8440 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
8441 orderByComparator);
8442 }
8443 else
8444 if (pagination) {
8445 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
8446 }
8447
8448 String sql = query.toString();
8449
8450 Session session = null;
8451
8452 try {
8453 session = openSession();
8454
8455 Query q = session.createQuery(sql);
8456
8457 QueryPos qPos = QueryPos.getInstance(q);
8458
8459 qPos.add(groupId);
8460
8461 if (name != null) {
8462 qPos.add(name);
8463 }
8464
8465 if (vocabularyIds != null) {
8466 qPos.add(vocabularyIds);
8467 }
8468
8469 if (!pagination) {
8470 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
8471 start, end, false);
8472
8473 Collections.sort(list);
8474
8475 list = new UnmodifiableList<AssetCategory>(list);
8476 }
8477 else {
8478 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
8479 start, end);
8480 }
8481
8482 cacheResult(list);
8483
8484 FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_LIKEN_V,
8485 finderArgs, list);
8486 }
8487 catch (Exception e) {
8488 FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_LIKEN_V,
8489 finderArgs);
8490
8491 throw processException(e);
8492 }
8493 finally {
8494 closeSession(session);
8495 }
8496 }
8497
8498 return list;
8499 }
8500
8501
8509 public void removeByG_LikeN_V(long groupId, String name, long vocabularyId)
8510 throws SystemException {
8511 for (AssetCategory assetCategory : findByG_LikeN_V(groupId, name,
8512 vocabularyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
8513 remove(assetCategory);
8514 }
8515 }
8516
8517
8526 public int countByG_LikeN_V(long groupId, String name, long vocabularyId)
8527 throws SystemException {
8528 FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_LIKEN_V;
8529
8530 Object[] finderArgs = new Object[] { groupId, name, vocabularyId };
8531
8532 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
8533 this);
8534
8535 if (count == null) {
8536 StringBundler query = new StringBundler(4);
8537
8538 query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
8539
8540 query.append(_FINDER_COLUMN_G_LIKEN_V_GROUPID_2);
8541
8542 boolean bindName = false;
8543
8544 if (name == null) {
8545 query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_1);
8546 }
8547 else if (name.equals(StringPool.BLANK)) {
8548 query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_3);
8549 }
8550 else {
8551 bindName = true;
8552
8553 query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_2);
8554 }
8555
8556 query.append(_FINDER_COLUMN_G_LIKEN_V_VOCABULARYID_2);
8557
8558 String sql = query.toString();
8559
8560 Session session = null;
8561
8562 try {
8563 session = openSession();
8564
8565 Query q = session.createQuery(sql);
8566
8567 QueryPos qPos = QueryPos.getInstance(q);
8568
8569 qPos.add(groupId);
8570
8571 if (bindName) {
8572 qPos.add(name);
8573 }
8574
8575 qPos.add(vocabularyId);
8576
8577 count = (Long)q.uniqueResult();
8578
8579 FinderCacheUtil.putResult(finderPath, finderArgs, count);
8580 }
8581 catch (Exception e) {
8582 FinderCacheUtil.removeResult(finderPath, finderArgs);
8583
8584 throw processException(e);
8585 }
8586 finally {
8587 closeSession(session);
8588 }
8589 }
8590
8591 return count.intValue();
8592 }
8593
8594
8603 public int countByG_LikeN_V(long groupId, String name, long[] vocabularyIds)
8604 throws SystemException {
8605 Object[] finderArgs = new Object[] {
8606 groupId, name, StringUtil.merge(vocabularyIds)
8607 };
8608
8609 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_LIKEN_V,
8610 finderArgs, this);
8611
8612 if (count == null) {
8613 StringBundler query = new StringBundler();
8614
8615 query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
8616
8617 boolean conjunctionable = false;
8618
8619 if (conjunctionable) {
8620 query.append(WHERE_AND);
8621 }
8622
8623 query.append(_FINDER_COLUMN_G_LIKEN_V_GROUPID_5);
8624
8625 conjunctionable = true;
8626
8627 if (conjunctionable) {
8628 query.append(WHERE_AND);
8629 }
8630
8631 if (name == null) {
8632 query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_4);
8633 }
8634 else if (name.equals(StringPool.BLANK)) {
8635 query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_6);
8636 }
8637 else {
8638 query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_5);
8639 }
8640
8641 conjunctionable = true;
8642
8643 if ((vocabularyIds == null) || (vocabularyIds.length > 0)) {
8644 if (conjunctionable) {
8645 query.append(WHERE_AND);
8646 }
8647
8648 query.append(StringPool.OPEN_PARENTHESIS);
8649
8650 for (int i = 0; i < vocabularyIds.length; i++) {
8651 query.append(_FINDER_COLUMN_G_LIKEN_V_VOCABULARYID_5);
8652
8653 if ((i + 1) < vocabularyIds.length) {
8654 query.append(WHERE_OR);
8655 }
8656 }
8657
8658 query.append(StringPool.CLOSE_PARENTHESIS);
8659
8660 conjunctionable = true;
8661 }
8662
8663 String sql = query.toString();
8664
8665 Session session = null;
8666
8667 try {
8668 session = openSession();
8669
8670 Query q = session.createQuery(sql);
8671
8672 QueryPos qPos = QueryPos.getInstance(q);
8673
8674 qPos.add(groupId);
8675
8676 if (name != null) {
8677 qPos.add(name);
8678 }
8679
8680 if (vocabularyIds != null) {
8681 qPos.add(vocabularyIds);
8682 }
8683
8684 count = (Long)q.uniqueResult();
8685
8686 FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_LIKEN_V,
8687 finderArgs, count);
8688 }
8689 catch (Exception e) {
8690 FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_LIKEN_V,
8691 finderArgs);
8692
8693 throw processException(e);
8694 }
8695 finally {
8696 closeSession(session);
8697 }
8698 }
8699
8700 return count.intValue();
8701 }
8702
8703
8712 public int filterCountByG_LikeN_V(long groupId, String name,
8713 long vocabularyId) throws SystemException {
8714 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
8715 return countByG_LikeN_V(groupId, name, vocabularyId);
8716 }
8717
8718 StringBundler query = new StringBundler(4);
8719
8720 query.append(_FILTER_SQL_COUNT_ASSETCATEGORY_WHERE);
8721
8722 query.append(_FINDER_COLUMN_G_LIKEN_V_GROUPID_2);
8723
8724 boolean bindName = false;
8725
8726 if (name == null) {
8727 query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_1);
8728 }
8729 else if (name.equals(StringPool.BLANK)) {
8730 query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_3);
8731 }
8732 else {
8733 bindName = true;
8734
8735 query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_2);
8736 }
8737
8738 query.append(_FINDER_COLUMN_G_LIKEN_V_VOCABULARYID_2);
8739
8740 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
8741 AssetCategory.class.getName(),
8742 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
8743
8744 Session session = null;
8745
8746 try {
8747 session = openSession();
8748
8749 SQLQuery q = session.createSQLQuery(sql);
8750
8751 q.addScalar(COUNT_COLUMN_NAME,
8752 com.liferay.portal.kernel.dao.orm.Type.LONG);
8753
8754 QueryPos qPos = QueryPos.getInstance(q);
8755
8756 qPos.add(groupId);
8757
8758 if (bindName) {
8759 qPos.add(name);
8760 }
8761
8762 qPos.add(vocabularyId);
8763
8764 Long count = (Long)q.uniqueResult();
8765
8766 return count.intValue();
8767 }
8768 catch (Exception e) {
8769 throw processException(e);
8770 }
8771 finally {
8772 closeSession(session);
8773 }
8774 }
8775
8776
8785 public int filterCountByG_LikeN_V(long groupId, String name,
8786 long[] vocabularyIds) throws SystemException {
8787 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
8788 return countByG_LikeN_V(groupId, name, vocabularyIds);
8789 }
8790
8791 StringBundler query = new StringBundler();
8792
8793 query.append(_FILTER_SQL_COUNT_ASSETCATEGORY_WHERE);
8794
8795 boolean conjunctionable = false;
8796
8797 if (conjunctionable) {
8798 query.append(WHERE_AND);
8799 }
8800
8801 query.append(_FINDER_COLUMN_G_LIKEN_V_GROUPID_5);
8802
8803 conjunctionable = true;
8804
8805 if (conjunctionable) {
8806 query.append(WHERE_AND);
8807 }
8808
8809 if (name == null) {
8810 query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_4);
8811 }
8812 else if (name.equals(StringPool.BLANK)) {
8813 query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_6);
8814 }
8815 else {
8816 query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_5);
8817 }
8818
8819 conjunctionable = true;
8820
8821 if ((vocabularyIds == null) || (vocabularyIds.length > 0)) {
8822 if (conjunctionable) {
8823 query.append(WHERE_AND);
8824 }
8825
8826 query.append(StringPool.OPEN_PARENTHESIS);
8827
8828 for (int i = 0; i < vocabularyIds.length; i++) {
8829 query.append(_FINDER_COLUMN_G_LIKEN_V_VOCABULARYID_5);
8830
8831 if ((i + 1) < vocabularyIds.length) {
8832 query.append(WHERE_OR);
8833 }
8834 }
8835
8836 query.append(StringPool.CLOSE_PARENTHESIS);
8837
8838 conjunctionable = true;
8839 }
8840
8841 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
8842 AssetCategory.class.getName(),
8843 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
8844
8845 Session session = null;
8846
8847 try {
8848 session = openSession();
8849
8850 SQLQuery q = session.createSQLQuery(sql);
8851
8852 q.addScalar(COUNT_COLUMN_NAME,
8853 com.liferay.portal.kernel.dao.orm.Type.LONG);
8854
8855 QueryPos qPos = QueryPos.getInstance(q);
8856
8857 qPos.add(groupId);
8858
8859 if (name != null) {
8860 qPos.add(name);
8861 }
8862
8863 if (vocabularyIds != null) {
8864 qPos.add(vocabularyIds);
8865 }
8866
8867 Long count = (Long)q.uniqueResult();
8868
8869 return count.intValue();
8870 }
8871 catch (Exception e) {
8872 throw processException(e);
8873 }
8874 finally {
8875 closeSession(session);
8876 }
8877 }
8878
8879 private static final String _FINDER_COLUMN_G_LIKEN_V_GROUPID_2 = "assetCategory.groupId = ? AND ";
8880 private static final String _FINDER_COLUMN_G_LIKEN_V_GROUPID_5 = "(" +
8881 removeConjunction(_FINDER_COLUMN_G_LIKEN_V_GROUPID_2) + ")";
8882 private static final String _FINDER_COLUMN_G_LIKEN_V_NAME_1 = "assetCategory.name LIKE NULL AND ";
8883 private static final String _FINDER_COLUMN_G_LIKEN_V_NAME_2 = "assetCategory.name LIKE ? AND ";
8884 private static final String _FINDER_COLUMN_G_LIKEN_V_NAME_3 = "(assetCategory.name IS NULL OR assetCategory.name LIKE '') AND ";
8885 private static final String _FINDER_COLUMN_G_LIKEN_V_NAME_4 = "(" +
8886 removeConjunction(_FINDER_COLUMN_G_LIKEN_V_NAME_1) + ")";
8887 private static final String _FINDER_COLUMN_G_LIKEN_V_NAME_5 = "(" +
8888 removeConjunction(_FINDER_COLUMN_G_LIKEN_V_NAME_2) + ")";
8889 private static final String _FINDER_COLUMN_G_LIKEN_V_NAME_6 = "(" +
8890 removeConjunction(_FINDER_COLUMN_G_LIKEN_V_NAME_3) + ")";
8891 private static final String _FINDER_COLUMN_G_LIKEN_V_VOCABULARYID_2 = "assetCategory.vocabularyId = ?";
8892 private static final String _FINDER_COLUMN_G_LIKEN_V_VOCABULARYID_5 = "(" +
8893 removeConjunction(_FINDER_COLUMN_G_LIKEN_V_VOCABULARYID_2) + ")";
8894 public static final FinderPath FINDER_PATH_FETCH_BY_P_N_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
8895 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
8896 AssetCategoryImpl.class, FINDER_CLASS_NAME_ENTITY, "fetchByP_N_V",
8897 new String[] {
8898 Long.class.getName(), String.class.getName(),
8899 Long.class.getName()
8900 },
8901 AssetCategoryModelImpl.PARENTCATEGORYID_COLUMN_BITMASK |
8902 AssetCategoryModelImpl.NAME_COLUMN_BITMASK |
8903 AssetCategoryModelImpl.VOCABULARYID_COLUMN_BITMASK);
8904 public static final FinderPath FINDER_PATH_COUNT_BY_P_N_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
8905 AssetCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class,
8906 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByP_N_V",
8907 new String[] {
8908 Long.class.getName(), String.class.getName(),
8909 Long.class.getName()
8910 });
8911
8912
8922 public AssetCategory findByP_N_V(long parentCategoryId, String name,
8923 long vocabularyId) throws NoSuchCategoryException, SystemException {
8924 AssetCategory assetCategory = fetchByP_N_V(parentCategoryId, name,
8925 vocabularyId);
8926
8927 if (assetCategory == null) {
8928 StringBundler msg = new StringBundler(8);
8929
8930 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
8931
8932 msg.append("parentCategoryId=");
8933 msg.append(parentCategoryId);
8934
8935 msg.append(", name=");
8936 msg.append(name);
8937
8938 msg.append(", vocabularyId=");
8939 msg.append(vocabularyId);
8940
8941 msg.append(StringPool.CLOSE_CURLY_BRACE);
8942
8943 if (_log.isWarnEnabled()) {
8944 _log.warn(msg.toString());
8945 }
8946
8947 throw new NoSuchCategoryException(msg.toString());
8948 }
8949
8950 return assetCategory;
8951 }
8952
8953
8962 public AssetCategory fetchByP_N_V(long parentCategoryId, String name,
8963 long vocabularyId) throws SystemException {
8964 return fetchByP_N_V(parentCategoryId, name, vocabularyId, true);
8965 }
8966
8967
8977 public AssetCategory fetchByP_N_V(long parentCategoryId, String name,
8978 long vocabularyId, boolean retrieveFromCache) throws SystemException {
8979 Object[] finderArgs = new Object[] { parentCategoryId, name, vocabularyId };
8980
8981 Object result = null;
8982
8983 if (retrieveFromCache) {
8984 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_P_N_V,
8985 finderArgs, this);
8986 }
8987
8988 if (result instanceof AssetCategory) {
8989 AssetCategory assetCategory = (AssetCategory)result;
8990
8991 if ((parentCategoryId != assetCategory.getParentCategoryId()) ||
8992 !Validator.equals(name, assetCategory.getName()) ||
8993 (vocabularyId != assetCategory.getVocabularyId())) {
8994 result = null;
8995 }
8996 }
8997
8998 if (result == null) {
8999 StringBundler query = new StringBundler(5);
9000
9001 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
9002
9003 query.append(_FINDER_COLUMN_P_N_V_PARENTCATEGORYID_2);
9004
9005 boolean bindName = false;
9006
9007 if (name == null) {
9008 query.append(_FINDER_COLUMN_P_N_V_NAME_1);
9009 }
9010 else if (name.equals(StringPool.BLANK)) {
9011 query.append(_FINDER_COLUMN_P_N_V_NAME_3);
9012 }
9013 else {
9014 bindName = true;
9015
9016 query.append(_FINDER_COLUMN_P_N_V_NAME_2);
9017 }
9018
9019 query.append(_FINDER_COLUMN_P_N_V_VOCABULARYID_2);
9020
9021 String sql = query.toString();
9022
9023 Session session = null;
9024
9025 try {
9026 session = openSession();
9027
9028 Query q = session.createQuery(sql);
9029
9030 QueryPos qPos = QueryPos.getInstance(q);
9031
9032 qPos.add(parentCategoryId);
9033
9034 if (bindName) {
9035 qPos.add(name);
9036 }
9037
9038 qPos.add(vocabularyId);
9039
9040 List<AssetCategory> list = q.list();
9041
9042 if (list.isEmpty()) {
9043 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_P_N_V,
9044 finderArgs, list);
9045 }
9046 else {
9047 AssetCategory assetCategory = list.get(0);
9048
9049 result = assetCategory;
9050
9051 cacheResult(assetCategory);
9052
9053 if ((assetCategory.getParentCategoryId() != parentCategoryId) ||
9054 (assetCategory.getName() == null) ||
9055 !assetCategory.getName().equals(name) ||
9056 (assetCategory.getVocabularyId() != vocabularyId)) {
9057 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_P_N_V,
9058 finderArgs, assetCategory);
9059 }
9060 }
9061 }
9062 catch (Exception e) {
9063 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_P_N_V,
9064 finderArgs);
9065
9066 throw processException(e);
9067 }
9068 finally {
9069 closeSession(session);
9070 }
9071 }
9072
9073 if (result instanceof List<?>) {
9074 return null;
9075 }
9076 else {
9077 return (AssetCategory)result;
9078 }
9079 }
9080
9081
9090 public AssetCategory removeByP_N_V(long parentCategoryId, String name,
9091 long vocabularyId) throws NoSuchCategoryException, SystemException {
9092 AssetCategory assetCategory = findByP_N_V(parentCategoryId, name,
9093 vocabularyId);
9094
9095 return remove(assetCategory);
9096 }
9097
9098
9107 public int countByP_N_V(long parentCategoryId, String name,
9108 long vocabularyId) throws SystemException {
9109 FinderPath finderPath = FINDER_PATH_COUNT_BY_P_N_V;
9110
9111 Object[] finderArgs = new Object[] { parentCategoryId, name, vocabularyId };
9112
9113 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
9114 this);
9115
9116 if (count == null) {
9117 StringBundler query = new StringBundler(4);
9118
9119 query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
9120
9121 query.append(_FINDER_COLUMN_P_N_V_PARENTCATEGORYID_2);
9122
9123 boolean bindName = false;
9124
9125 if (name == null) {
9126 query.append(_FINDER_COLUMN_P_N_V_NAME_1);
9127 }
9128 else if (name.equals(StringPool.BLANK)) {
9129 query.append(_FINDER_COLUMN_P_N_V_NAME_3);
9130 }
9131 else {
9132 bindName = true;
9133
9134 query.append(_FINDER_COLUMN_P_N_V_NAME_2);
9135 }
9136
9137 query.append(_FINDER_COLUMN_P_N_V_VOCABULARYID_2);
9138
9139 String sql = query.toString();
9140
9141 Session session = null;
9142
9143 try {
9144 session = openSession();
9145
9146 Query q = session.createQuery(sql);
9147
9148 QueryPos qPos = QueryPos.getInstance(q);
9149
9150 qPos.add(parentCategoryId);
9151
9152 if (bindName) {
9153 qPos.add(name);
9154 }
9155
9156 qPos.add(vocabularyId);
9157
9158 count = (Long)q.uniqueResult();
9159
9160 FinderCacheUtil.putResult(finderPath, finderArgs, count);
9161 }
9162 catch (Exception e) {
9163 FinderCacheUtil.removeResult(finderPath, finderArgs);
9164
9165 throw processException(e);
9166 }
9167 finally {
9168 closeSession(session);
9169 }
9170 }
9171
9172 return count.intValue();
9173 }
9174
9175 private static final String _FINDER_COLUMN_P_N_V_PARENTCATEGORYID_2 = "assetCategory.parentCategoryId = ? AND ";
9176 private static final String _FINDER_COLUMN_P_N_V_NAME_1 = "assetCategory.name IS NULL AND ";
9177 private static final String _FINDER_COLUMN_P_N_V_NAME_2 = "assetCategory.name = ? AND ";
9178 private static final String _FINDER_COLUMN_P_N_V_NAME_3 = "(assetCategory.name IS NULL OR assetCategory.name = '') AND ";
9179 private static final String _FINDER_COLUMN_P_N_V_VOCABULARYID_2 = "assetCategory.vocabularyId = ?";
9180 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_P_N_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
9181 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
9182 AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
9183 "findByG_P_N_V",
9184 new String[] {
9185 Long.class.getName(), Long.class.getName(),
9186 String.class.getName(), Long.class.getName(),
9187
9188 Integer.class.getName(), Integer.class.getName(),
9189 OrderByComparator.class.getName()
9190 });
9191 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_N_V =
9192 new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
9193 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
9194 AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
9195 "findByG_P_N_V",
9196 new String[] {
9197 Long.class.getName(), Long.class.getName(),
9198 String.class.getName(), Long.class.getName()
9199 },
9200 AssetCategoryModelImpl.GROUPID_COLUMN_BITMASK |
9201 AssetCategoryModelImpl.PARENTCATEGORYID_COLUMN_BITMASK |
9202 AssetCategoryModelImpl.NAME_COLUMN_BITMASK |
9203 AssetCategoryModelImpl.VOCABULARYID_COLUMN_BITMASK);
9204 public static final FinderPath FINDER_PATH_COUNT_BY_G_P_N_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
9205 AssetCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class,
9206 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_P_N_V",
9207 new String[] {
9208 Long.class.getName(), Long.class.getName(),
9209 String.class.getName(), Long.class.getName()
9210 });
9211
9212
9222 public List<AssetCategory> findByG_P_N_V(long groupId,
9223 long parentCategoryId, String name, long vocabularyId)
9224 throws SystemException {
9225 return findByG_P_N_V(groupId, parentCategoryId, name, vocabularyId,
9226 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
9227 }
9228
9229
9245 public List<AssetCategory> findByG_P_N_V(long groupId,
9246 long parentCategoryId, String name, long vocabularyId, int start,
9247 int end) throws SystemException {
9248 return findByG_P_N_V(groupId, parentCategoryId, name, vocabularyId,
9249 start, end, null);
9250 }
9251
9252
9269 public List<AssetCategory> findByG_P_N_V(long groupId,
9270 long parentCategoryId, String name, long vocabularyId, int start,
9271 int end, OrderByComparator orderByComparator) throws SystemException {
9272 boolean pagination = true;
9273 FinderPath finderPath = null;
9274 Object[] finderArgs = null;
9275
9276 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
9277 (orderByComparator == null)) {
9278 pagination = false;
9279 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_N_V;
9280 finderArgs = new Object[] {
9281 groupId, parentCategoryId, name, vocabularyId
9282 };
9283 }
9284 else {
9285 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_P_N_V;
9286 finderArgs = new Object[] {
9287 groupId, parentCategoryId, name, vocabularyId,
9288
9289 start, end, orderByComparator
9290 };
9291 }
9292
9293 List<AssetCategory> list = (List<AssetCategory>)FinderCacheUtil.getResult(finderPath,
9294 finderArgs, this);
9295
9296 if ((list != null) && !list.isEmpty()) {
9297 for (AssetCategory assetCategory : list) {
9298 if ((groupId != assetCategory.getGroupId()) ||
9299 (parentCategoryId != assetCategory.getParentCategoryId()) ||
9300 !Validator.equals(name, assetCategory.getName()) ||
9301 (vocabularyId != assetCategory.getVocabularyId())) {
9302 list = null;
9303
9304 break;
9305 }
9306 }
9307 }
9308
9309 if (list == null) {
9310 StringBundler query = null;
9311
9312 if (orderByComparator != null) {
9313 query = new StringBundler(6 +
9314 (orderByComparator.getOrderByFields().length * 3));
9315 }
9316 else {
9317 query = new StringBundler(6);
9318 }
9319
9320 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
9321
9322 query.append(_FINDER_COLUMN_G_P_N_V_GROUPID_2);
9323
9324 query.append(_FINDER_COLUMN_G_P_N_V_PARENTCATEGORYID_2);
9325
9326 boolean bindName = false;
9327
9328 if (name == null) {
9329 query.append(_FINDER_COLUMN_G_P_N_V_NAME_1);
9330 }
9331 else if (name.equals(StringPool.BLANK)) {
9332 query.append(_FINDER_COLUMN_G_P_N_V_NAME_3);
9333 }
9334 else {
9335 bindName = true;
9336
9337 query.append(_FINDER_COLUMN_G_P_N_V_NAME_2);
9338 }
9339
9340 query.append(_FINDER_COLUMN_G_P_N_V_VOCABULARYID_2);
9341
9342 if (orderByComparator != null) {
9343 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
9344 orderByComparator);
9345 }
9346 else
9347 if (pagination) {
9348 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
9349 }
9350
9351 String sql = query.toString();
9352
9353 Session session = null;
9354
9355 try {
9356 session = openSession();
9357
9358 Query q = session.createQuery(sql);
9359
9360 QueryPos qPos = QueryPos.getInstance(q);
9361
9362 qPos.add(groupId);
9363
9364 qPos.add(parentCategoryId);
9365
9366 if (bindName) {
9367 qPos.add(name);
9368 }
9369
9370 qPos.add(vocabularyId);
9371
9372 if (!pagination) {
9373 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
9374 start, end, false);
9375
9376 Collections.sort(list);
9377
9378 list = new UnmodifiableList<AssetCategory>(list);
9379 }
9380 else {
9381 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
9382 start, end);
9383 }
9384
9385 cacheResult(list);
9386
9387 FinderCacheUtil.putResult(finderPath, finderArgs, list);
9388 }
9389 catch (Exception e) {
9390 FinderCacheUtil.removeResult(finderPath, finderArgs);
9391
9392 throw processException(e);
9393 }
9394 finally {
9395 closeSession(session);
9396 }
9397 }
9398
9399 return list;
9400 }
9401
9402
9414 public AssetCategory findByG_P_N_V_First(long groupId,
9415 long parentCategoryId, String name, long vocabularyId,
9416 OrderByComparator orderByComparator)
9417 throws NoSuchCategoryException, SystemException {
9418 AssetCategory assetCategory = fetchByG_P_N_V_First(groupId,
9419 parentCategoryId, name, vocabularyId, orderByComparator);
9420
9421 if (assetCategory != null) {
9422 return assetCategory;
9423 }
9424
9425 StringBundler msg = new StringBundler(10);
9426
9427 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
9428
9429 msg.append("groupId=");
9430 msg.append(groupId);
9431
9432 msg.append(", parentCategoryId=");
9433 msg.append(parentCategoryId);
9434
9435 msg.append(", name=");
9436 msg.append(name);
9437
9438 msg.append(", vocabularyId=");
9439 msg.append(vocabularyId);
9440
9441 msg.append(StringPool.CLOSE_CURLY_BRACE);
9442
9443 throw new NoSuchCategoryException(msg.toString());
9444 }
9445
9446
9457 public AssetCategory fetchByG_P_N_V_First(long groupId,
9458 long parentCategoryId, String name, long vocabularyId,
9459 OrderByComparator orderByComparator) throws SystemException {
9460 List<AssetCategory> list = findByG_P_N_V(groupId, parentCategoryId,
9461 name, vocabularyId, 0, 1, orderByComparator);
9462
9463 if (!list.isEmpty()) {
9464 return list.get(0);
9465 }
9466
9467 return null;
9468 }
9469
9470
9482 public AssetCategory findByG_P_N_V_Last(long groupId,
9483 long parentCategoryId, String name, long vocabularyId,
9484 OrderByComparator orderByComparator)
9485 throws NoSuchCategoryException, SystemException {
9486 AssetCategory assetCategory = fetchByG_P_N_V_Last(groupId,
9487 parentCategoryId, name, vocabularyId, orderByComparator);
9488
9489 if (assetCategory != null) {
9490 return assetCategory;
9491 }
9492
9493 StringBundler msg = new StringBundler(10);
9494
9495 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
9496
9497 msg.append("groupId=");
9498 msg.append(groupId);
9499
9500 msg.append(", parentCategoryId=");
9501 msg.append(parentCategoryId);
9502
9503 msg.append(", name=");
9504 msg.append(name);
9505
9506 msg.append(", vocabularyId=");
9507 msg.append(vocabularyId);
9508
9509 msg.append(StringPool.CLOSE_CURLY_BRACE);
9510
9511 throw new NoSuchCategoryException(msg.toString());
9512 }
9513
9514
9525 public AssetCategory fetchByG_P_N_V_Last(long groupId,
9526 long parentCategoryId, String name, long vocabularyId,
9527 OrderByComparator orderByComparator) throws SystemException {
9528 int count = countByG_P_N_V(groupId, parentCategoryId, name, vocabularyId);
9529
9530 List<AssetCategory> list = findByG_P_N_V(groupId, parentCategoryId,
9531 name, vocabularyId, count - 1, count, orderByComparator);
9532
9533 if (!list.isEmpty()) {
9534 return list.get(0);
9535 }
9536
9537 return null;
9538 }
9539
9540
9553 public AssetCategory[] findByG_P_N_V_PrevAndNext(long categoryId,
9554 long groupId, long parentCategoryId, String name, long vocabularyId,
9555 OrderByComparator orderByComparator)
9556 throws NoSuchCategoryException, SystemException {
9557 AssetCategory assetCategory = findByPrimaryKey(categoryId);
9558
9559 Session session = null;
9560
9561 try {
9562 session = openSession();
9563
9564 AssetCategory[] array = new AssetCategoryImpl[3];
9565
9566 array[0] = getByG_P_N_V_PrevAndNext(session, assetCategory,
9567 groupId, parentCategoryId, name, vocabularyId,
9568 orderByComparator, true);
9569
9570 array[1] = assetCategory;
9571
9572 array[2] = getByG_P_N_V_PrevAndNext(session, assetCategory,
9573 groupId, parentCategoryId, name, vocabularyId,
9574 orderByComparator, false);
9575
9576 return array;
9577 }
9578 catch (Exception e) {
9579 throw processException(e);
9580 }
9581 finally {
9582 closeSession(session);
9583 }
9584 }
9585
9586 protected AssetCategory getByG_P_N_V_PrevAndNext(Session session,
9587 AssetCategory assetCategory, long groupId, long parentCategoryId,
9588 String name, long vocabularyId, OrderByComparator orderByComparator,
9589 boolean previous) {
9590 StringBundler query = null;
9591
9592 if (orderByComparator != null) {
9593 query = new StringBundler(6 +
9594 (orderByComparator.getOrderByFields().length * 6));
9595 }
9596 else {
9597 query = new StringBundler(3);
9598 }
9599
9600 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
9601
9602 query.append(_FINDER_COLUMN_G_P_N_V_GROUPID_2);
9603
9604 query.append(_FINDER_COLUMN_G_P_N_V_PARENTCATEGORYID_2);
9605
9606 boolean bindName = false;
9607
9608 if (name == null) {
9609 query.append(_FINDER_COLUMN_G_P_N_V_NAME_1);
9610 }
9611 else if (name.equals(StringPool.BLANK)) {
9612 query.append(_FINDER_COLUMN_G_P_N_V_NAME_3);
9613 }
9614 else {
9615 bindName = true;
9616
9617 query.append(_FINDER_COLUMN_G_P_N_V_NAME_2);
9618 }
9619
9620 query.append(_FINDER_COLUMN_G_P_N_V_VOCABULARYID_2);
9621
9622 if (orderByComparator != null) {
9623 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
9624
9625 if (orderByConditionFields.length > 0) {
9626 query.append(WHERE_AND);
9627 }
9628
9629 for (int i = 0; i < orderByConditionFields.length; i++) {
9630 query.append(_ORDER_BY_ENTITY_ALIAS);
9631 query.append(orderByConditionFields[i]);
9632
9633 if ((i + 1) < orderByConditionFields.length) {
9634 if (orderByComparator.isAscending() ^ previous) {
9635 query.append(WHERE_GREATER_THAN_HAS_NEXT);
9636 }
9637 else {
9638 query.append(WHERE_LESSER_THAN_HAS_NEXT);
9639 }
9640 }
9641 else {
9642 if (orderByComparator.isAscending() ^ previous) {
9643 query.append(WHERE_GREATER_THAN);
9644 }
9645 else {
9646 query.append(WHERE_LESSER_THAN);
9647 }
9648 }
9649 }
9650
9651 query.append(ORDER_BY_CLAUSE);
9652
9653 String[] orderByFields = orderByComparator.getOrderByFields();
9654
9655 for (int i = 0; i < orderByFields.length; i++) {
9656 query.append(_ORDER_BY_ENTITY_ALIAS);
9657 query.append(orderByFields[i]);
9658
9659 if ((i + 1) < orderByFields.length) {
9660 if (orderByComparator.isAscending() ^ previous) {
9661 query.append(ORDER_BY_ASC_HAS_NEXT);
9662 }
9663 else {
9664 query.append(ORDER_BY_DESC_HAS_NEXT);
9665 }
9666 }
9667 else {
9668 if (orderByComparator.isAscending() ^ previous) {
9669 query.append(ORDER_BY_ASC);
9670 }
9671 else {
9672 query.append(ORDER_BY_DESC);
9673 }
9674 }
9675 }
9676 }
9677 else {
9678 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
9679 }
9680
9681 String sql = query.toString();
9682
9683 Query q = session.createQuery(sql);
9684
9685 q.setFirstResult(0);
9686 q.setMaxResults(2);
9687
9688 QueryPos qPos = QueryPos.getInstance(q);
9689
9690 qPos.add(groupId);
9691
9692 qPos.add(parentCategoryId);
9693
9694 if (bindName) {
9695 qPos.add(name);
9696 }
9697
9698 qPos.add(vocabularyId);
9699
9700 if (orderByComparator != null) {
9701 Object[] values = orderByComparator.getOrderByConditionValues(assetCategory);
9702
9703 for (Object value : values) {
9704 qPos.add(value);
9705 }
9706 }
9707
9708 List<AssetCategory> list = q.list();
9709
9710 if (list.size() == 2) {
9711 return list.get(1);
9712 }
9713 else {
9714 return null;
9715 }
9716 }
9717
9718
9728 public List<AssetCategory> filterFindByG_P_N_V(long groupId,
9729 long parentCategoryId, String name, long vocabularyId)
9730 throws SystemException {
9731 return filterFindByG_P_N_V(groupId, parentCategoryId, name,
9732 vocabularyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
9733 }
9734
9735
9751 public List<AssetCategory> filterFindByG_P_N_V(long groupId,
9752 long parentCategoryId, String name, long vocabularyId, int start,
9753 int end) throws SystemException {
9754 return filterFindByG_P_N_V(groupId, parentCategoryId, name,
9755 vocabularyId, start, end, null);
9756 }
9757
9758
9775 public List<AssetCategory> filterFindByG_P_N_V(long groupId,
9776 long parentCategoryId, String name, long vocabularyId, int start,
9777 int end, OrderByComparator orderByComparator) throws SystemException {
9778 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
9779 return findByG_P_N_V(groupId, parentCategoryId, name, vocabularyId,
9780 start, end, orderByComparator);
9781 }
9782
9783 StringBundler query = null;
9784
9785 if (orderByComparator != null) {
9786 query = new StringBundler(6 +
9787 (orderByComparator.getOrderByFields().length * 3));
9788 }
9789 else {
9790 query = new StringBundler(6);
9791 }
9792
9793 if (getDB().isSupportsInlineDistinct()) {
9794 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_WHERE);
9795 }
9796 else {
9797 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_1);
9798 }
9799
9800 query.append(_FINDER_COLUMN_G_P_N_V_GROUPID_2);
9801
9802 query.append(_FINDER_COLUMN_G_P_N_V_PARENTCATEGORYID_2);
9803
9804 boolean bindName = false;
9805
9806 if (name == null) {
9807 query.append(_FINDER_COLUMN_G_P_N_V_NAME_1);
9808 }
9809 else if (name.equals(StringPool.BLANK)) {
9810 query.append(_FINDER_COLUMN_G_P_N_V_NAME_3);
9811 }
9812 else {
9813 bindName = true;
9814
9815 query.append(_FINDER_COLUMN_G_P_N_V_NAME_2);
9816 }
9817
9818 query.append(_FINDER_COLUMN_G_P_N_V_VOCABULARYID_2);
9819
9820 if (!getDB().isSupportsInlineDistinct()) {
9821 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_2);
9822 }
9823
9824 if (orderByComparator != null) {
9825 if (getDB().isSupportsInlineDistinct()) {
9826 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
9827 orderByComparator, true);
9828 }
9829 else {
9830 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
9831 orderByComparator, true);
9832 }
9833 }
9834 else {
9835 if (getDB().isSupportsInlineDistinct()) {
9836 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
9837 }
9838 else {
9839 query.append(AssetCategoryModelImpl.ORDER_BY_SQL);
9840 }
9841 }
9842
9843 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
9844 AssetCategory.class.getName(),
9845 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
9846
9847 Session session = null;
9848
9849 try {
9850 session = openSession();
9851
9852 SQLQuery q = session.createSQLQuery(sql);
9853
9854 if (getDB().isSupportsInlineDistinct()) {
9855 q.addEntity(_FILTER_ENTITY_ALIAS, AssetCategoryImpl.class);
9856 }
9857 else {
9858 q.addEntity(_FILTER_ENTITY_TABLE, AssetCategoryImpl.class);
9859 }
9860
9861 QueryPos qPos = QueryPos.getInstance(q);
9862
9863 qPos.add(groupId);
9864
9865 qPos.add(parentCategoryId);
9866
9867 if (bindName) {
9868 qPos.add(name);
9869 }
9870
9871 qPos.add(vocabularyId);
9872
9873 return (List<AssetCategory>)QueryUtil.list(q, getDialect(), start,
9874 end);
9875 }
9876 catch (Exception e) {
9877 throw processException(e);
9878 }
9879 finally {
9880 closeSession(session);
9881 }
9882 }
9883
9884
9897 public AssetCategory[] filterFindByG_P_N_V_PrevAndNext(long categoryId,
9898 long groupId, long parentCategoryId, String name, long vocabularyId,
9899 OrderByComparator orderByComparator)
9900 throws NoSuchCategoryException, SystemException {
9901 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
9902 return findByG_P_N_V_PrevAndNext(categoryId, groupId,
9903 parentCategoryId, name, vocabularyId, orderByComparator);
9904 }
9905
9906 AssetCategory assetCategory = findByPrimaryKey(categoryId);
9907
9908 Session session = null;
9909
9910 try {
9911 session = openSession();
9912
9913 AssetCategory[] array = new AssetCategoryImpl[3];
9914
9915 array[0] = filterGetByG_P_N_V_PrevAndNext(session, assetCategory,
9916 groupId, parentCategoryId, name, vocabularyId,
9917 orderByComparator, true);
9918
9919 array[1] = assetCategory;
9920
9921 array[2] = filterGetByG_P_N_V_PrevAndNext(session, assetCategory,
9922 groupId, parentCategoryId, name, vocabularyId,
9923 orderByComparator, false);
9924
9925 return array;
9926 }
9927 catch (Exception e) {
9928 throw processException(e);
9929 }
9930 finally {
9931 closeSession(session);
9932 }
9933 }
9934
9935 protected AssetCategory filterGetByG_P_N_V_PrevAndNext(Session session,
9936 AssetCategory assetCategory, long groupId, long parentCategoryId,
9937 String name, long vocabularyId, OrderByComparator orderByComparator,
9938 boolean previous) {
9939 StringBundler query = null;
9940
9941 if (orderByComparator != null) {
9942 query = new StringBundler(6 +
9943 (orderByComparator.getOrderByFields().length * 6));
9944 }
9945 else {
9946 query = new StringBundler(3);
9947 }
9948
9949 if (getDB().isSupportsInlineDistinct()) {
9950 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_WHERE);
9951 }
9952 else {
9953 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_1);
9954 }
9955
9956 query.append(_FINDER_COLUMN_G_P_N_V_GROUPID_2);
9957
9958 query.append(_FINDER_COLUMN_G_P_N_V_PARENTCATEGORYID_2);
9959
9960 boolean bindName = false;
9961
9962 if (name == null) {
9963 query.append(_FINDER_COLUMN_G_P_N_V_NAME_1);
9964 }
9965 else if (name.equals(StringPool.BLANK)) {
9966 query.append(_FINDER_COLUMN_G_P_N_V_NAME_3);
9967 }
9968 else {
9969 bindName = true;
9970
9971 query.append(_FINDER_COLUMN_G_P_N_V_NAME_2);
9972 }
9973
9974 query.append(_FINDER_COLUMN_G_P_N_V_VOCABULARYID_2);
9975
9976 if (!getDB().isSupportsInlineDistinct()) {
9977 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_2);
9978 }
9979
9980 if (orderByComparator != null) {
9981 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
9982
9983 if (orderByConditionFields.length > 0) {
9984 query.append(WHERE_AND);
9985 }
9986
9987 for (int i = 0; i < orderByConditionFields.length; i++) {
9988 if (getDB().isSupportsInlineDistinct()) {
9989 query.append(_ORDER_BY_ENTITY_ALIAS);
9990 }
9991 else {
9992 query.append(_ORDER_BY_ENTITY_TABLE);
9993 }
9994
9995 query.append(orderByConditionFields[i]);
9996
9997 if ((i + 1) < orderByConditionFields.length) {
9998 if (orderByComparator.isAscending() ^ previous) {
9999 query.append(WHERE_GREATER_THAN_HAS_NEXT);
10000 }
10001 else {
10002 query.append(WHERE_LESSER_THAN_HAS_NEXT);
10003 }
10004 }
10005 else {
10006 if (orderByComparator.isAscending() ^ previous) {
10007 query.append(WHERE_GREATER_THAN);
10008 }
10009 else {
10010 query.append(WHERE_LESSER_THAN);
10011 }
10012 }
10013 }
10014
10015 query.append(ORDER_BY_CLAUSE);
10016
10017 String[] orderByFields = orderByComparator.getOrderByFields();
10018
10019 for (int i = 0; i < orderByFields.length; i++) {
10020 if (getDB().isSupportsInlineDistinct()) {
10021 query.append(_ORDER_BY_ENTITY_ALIAS);
10022 }
10023 else {
10024 query.append(_ORDER_BY_ENTITY_TABLE);
10025 }
10026
10027 query.append(orderByFields[i]);
10028
10029 if ((i + 1) < orderByFields.length) {
10030 if (orderByComparator.isAscending() ^ previous) {
10031 query.append(ORDER_BY_ASC_HAS_NEXT);
10032 }
10033 else {
10034 query.append(ORDER_BY_DESC_HAS_NEXT);
10035 }
10036 }
10037 else {
10038 if (orderByComparator.isAscending() ^ previous) {
10039 query.append(ORDER_BY_ASC);
10040 }
10041 else {
10042 query.append(ORDER_BY_DESC);
10043 }
10044 }
10045 }
10046 }
10047 else {
10048 if (getDB().isSupportsInlineDistinct()) {
10049 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
10050 }
10051 else {
10052 query.append(AssetCategoryModelImpl.ORDER_BY_SQL);
10053 }
10054 }
10055
10056 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
10057 AssetCategory.class.getName(),
10058 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
10059
10060 SQLQuery q = session.createSQLQuery(sql);
10061
10062 q.setFirstResult(0);
10063 q.setMaxResults(2);
10064
10065 if (getDB().isSupportsInlineDistinct()) {
10066 q.addEntity(_FILTER_ENTITY_ALIAS, AssetCategoryImpl.class);
10067 }
10068 else {
10069 q.addEntity(_FILTER_ENTITY_TABLE, AssetCategoryImpl.class);
10070 }
10071
10072 QueryPos qPos = QueryPos.getInstance(q);
10073
10074 qPos.add(groupId);
10075
10076 qPos.add(parentCategoryId);
10077
10078 if (bindName) {
10079 qPos.add(name);
10080 }
10081
10082 qPos.add(vocabularyId);
10083
10084 if (orderByComparator != null) {
10085 Object[] values = orderByComparator.getOrderByConditionValues(assetCategory);
10086
10087 for (Object value : values) {
10088 qPos.add(value);
10089 }
10090 }
10091
10092 List<AssetCategory> list = q.list();
10093
10094 if (list.size() == 2) {
10095 return list.get(1);
10096 }
10097 else {
10098 return null;
10099 }
10100 }
10101
10102
10111 public void removeByG_P_N_V(long groupId, long parentCategoryId,
10112 String name, long vocabularyId) throws SystemException {
10113 for (AssetCategory assetCategory : findByG_P_N_V(groupId,
10114 parentCategoryId, name, vocabularyId, QueryUtil.ALL_POS,
10115 QueryUtil.ALL_POS, null)) {
10116 remove(assetCategory);
10117 }
10118 }
10119
10120
10130 public int countByG_P_N_V(long groupId, long parentCategoryId, String name,
10131 long vocabularyId) throws SystemException {
10132 FinderPath finderPath = FINDER_PATH_COUNT_BY_G_P_N_V;
10133
10134 Object[] finderArgs = new Object[] {
10135 groupId, parentCategoryId, name, vocabularyId
10136 };
10137
10138 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
10139 this);
10140
10141 if (count == null) {
10142 StringBundler query = new StringBundler(5);
10143
10144 query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
10145
10146 query.append(_FINDER_COLUMN_G_P_N_V_GROUPID_2);
10147
10148 query.append(_FINDER_COLUMN_G_P_N_V_PARENTCATEGORYID_2);
10149
10150 boolean bindName = false;
10151
10152 if (name == null) {
10153 query.append(_FINDER_COLUMN_G_P_N_V_NAME_1);
10154 }
10155 else if (name.equals(StringPool.BLANK)) {
10156 query.append(_FINDER_COLUMN_G_P_N_V_NAME_3);
10157 }
10158 else {
10159 bindName = true;
10160
10161 query.append(_FINDER_COLUMN_G_P_N_V_NAME_2);
10162 }
10163
10164 query.append(_FINDER_COLUMN_G_P_N_V_VOCABULARYID_2);
10165
10166 String sql = query.toString();
10167
10168 Session session = null;
10169
10170 try {
10171 session = openSession();
10172
10173 Query q = session.createQuery(sql);
10174
10175 QueryPos qPos = QueryPos.getInstance(q);
10176
10177 qPos.add(groupId);
10178
10179 qPos.add(parentCategoryId);
10180
10181 if (bindName) {
10182 qPos.add(name);
10183 }
10184
10185 qPos.add(vocabularyId);
10186
10187 count = (Long)q.uniqueResult();
10188
10189 FinderCacheUtil.putResult(finderPath, finderArgs, count);
10190 }
10191 catch (Exception e) {
10192 FinderCacheUtil.removeResult(finderPath, finderArgs);
10193
10194 throw processException(e);
10195 }
10196 finally {
10197 closeSession(session);
10198 }
10199 }
10200
10201 return count.intValue();
10202 }
10203
10204
10214 public int filterCountByG_P_N_V(long groupId, long parentCategoryId,
10215 String name, long vocabularyId) throws SystemException {
10216 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
10217 return countByG_P_N_V(groupId, parentCategoryId, name, vocabularyId);
10218 }
10219
10220 StringBundler query = new StringBundler(5);
10221
10222 query.append(_FILTER_SQL_COUNT_ASSETCATEGORY_WHERE);
10223
10224 query.append(_FINDER_COLUMN_G_P_N_V_GROUPID_2);
10225
10226 query.append(_FINDER_COLUMN_G_P_N_V_PARENTCATEGORYID_2);
10227
10228 boolean bindName = false;
10229
10230 if (name == null) {
10231 query.append(_FINDER_COLUMN_G_P_N_V_NAME_1);
10232 }
10233 else if (name.equals(StringPool.BLANK)) {
10234 query.append(_FINDER_COLUMN_G_P_N_V_NAME_3);
10235 }
10236 else {
10237 bindName = true;
10238
10239 query.append(_FINDER_COLUMN_G_P_N_V_NAME_2);
10240 }
10241
10242 query.append(_FINDER_COLUMN_G_P_N_V_VOCABULARYID_2);
10243
10244 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
10245 AssetCategory.class.getName(),
10246 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
10247
10248 Session session = null;
10249
10250 try {
10251 session = openSession();
10252
10253 SQLQuery q = session.createSQLQuery(sql);
10254
10255 q.addScalar(COUNT_COLUMN_NAME,
10256 com.liferay.portal.kernel.dao.orm.Type.LONG);
10257
10258 QueryPos qPos = QueryPos.getInstance(q);
10259
10260 qPos.add(groupId);
10261
10262 qPos.add(parentCategoryId);
10263
10264 if (bindName) {
10265 qPos.add(name);
10266 }
10267
10268 qPos.add(vocabularyId);
10269
10270 Long count = (Long)q.uniqueResult();
10271
10272 return count.intValue();
10273 }
10274 catch (Exception e) {
10275 throw processException(e);
10276 }
10277 finally {
10278 closeSession(session);
10279 }
10280 }
10281
10282 private static final String _FINDER_COLUMN_G_P_N_V_GROUPID_2 = "assetCategory.groupId = ? AND ";
10283 private static final String _FINDER_COLUMN_G_P_N_V_PARENTCATEGORYID_2 = "assetCategory.parentCategoryId = ? AND ";
10284 private static final String _FINDER_COLUMN_G_P_N_V_NAME_1 = "assetCategory.name IS NULL AND ";
10285 private static final String _FINDER_COLUMN_G_P_N_V_NAME_2 = "assetCategory.name = ? AND ";
10286 private static final String _FINDER_COLUMN_G_P_N_V_NAME_3 = "(assetCategory.name IS NULL OR assetCategory.name = '') AND ";
10287 private static final String _FINDER_COLUMN_G_P_N_V_VOCABULARYID_2 = "assetCategory.vocabularyId = ?";
10288
10289
10294 public void cacheResult(AssetCategory assetCategory) {
10295 EntityCacheUtil.putResult(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
10296 AssetCategoryImpl.class, assetCategory.getPrimaryKey(),
10297 assetCategory);
10298
10299 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
10300 new Object[] { assetCategory.getUuid(), assetCategory.getGroupId() },
10301 assetCategory);
10302
10303 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_P_N_V,
10304 new Object[] {
10305 assetCategory.getParentCategoryId(), assetCategory.getName(),
10306 assetCategory.getVocabularyId()
10307 }, assetCategory);
10308
10309 assetCategory.resetOriginalValues();
10310 }
10311
10312
10317 public void cacheResult(List<AssetCategory> assetCategories) {
10318 for (AssetCategory assetCategory : assetCategories) {
10319 if (EntityCacheUtil.getResult(
10320 AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
10321 AssetCategoryImpl.class, assetCategory.getPrimaryKey()) == null) {
10322 cacheResult(assetCategory);
10323 }
10324 else {
10325 assetCategory.resetOriginalValues();
10326 }
10327 }
10328 }
10329
10330
10337 @Override
10338 public void clearCache() {
10339 if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
10340 CacheRegistryUtil.clear(AssetCategoryImpl.class.getName());
10341 }
10342
10343 EntityCacheUtil.clearCache(AssetCategoryImpl.class.getName());
10344
10345 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
10346 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
10347 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
10348 }
10349
10350
10357 @Override
10358 public void clearCache(AssetCategory assetCategory) {
10359 EntityCacheUtil.removeResult(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
10360 AssetCategoryImpl.class, assetCategory.getPrimaryKey());
10361
10362 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
10363 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
10364
10365 clearUniqueFindersCache(assetCategory);
10366 }
10367
10368 @Override
10369 public void clearCache(List<AssetCategory> assetCategories) {
10370 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
10371 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
10372
10373 for (AssetCategory assetCategory : assetCategories) {
10374 EntityCacheUtil.removeResult(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
10375 AssetCategoryImpl.class, assetCategory.getPrimaryKey());
10376
10377 clearUniqueFindersCache(assetCategory);
10378 }
10379 }
10380
10381 protected void cacheUniqueFindersCache(AssetCategory assetCategory) {
10382 if (assetCategory.isNew()) {
10383 Object[] args = new Object[] {
10384 assetCategory.getUuid(), assetCategory.getGroupId()
10385 };
10386
10387 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G, args,
10388 Long.valueOf(1));
10389 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G, args,
10390 assetCategory);
10391
10392 args = new Object[] {
10393 assetCategory.getParentCategoryId(), assetCategory.getName(),
10394 assetCategory.getVocabularyId()
10395 };
10396
10397 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_P_N_V, args,
10398 Long.valueOf(1));
10399 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_P_N_V, args,
10400 assetCategory);
10401 }
10402 else {
10403 AssetCategoryModelImpl assetCategoryModelImpl = (AssetCategoryModelImpl)assetCategory;
10404
10405 if ((assetCategoryModelImpl.getColumnBitmask() &
10406 FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) {
10407 Object[] args = new Object[] {
10408 assetCategory.getUuid(), assetCategory.getGroupId()
10409 };
10410
10411 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G, args,
10412 Long.valueOf(1));
10413 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G, args,
10414 assetCategory);
10415 }
10416
10417 if ((assetCategoryModelImpl.getColumnBitmask() &
10418 FINDER_PATH_FETCH_BY_P_N_V.getColumnBitmask()) != 0) {
10419 Object[] args = new Object[] {
10420 assetCategory.getParentCategoryId(),
10421 assetCategory.getName(), assetCategory.getVocabularyId()
10422 };
10423
10424 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_P_N_V, args,
10425 Long.valueOf(1));
10426 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_P_N_V, args,
10427 assetCategory);
10428 }
10429 }
10430 }
10431
10432 protected void clearUniqueFindersCache(AssetCategory assetCategory) {
10433 AssetCategoryModelImpl assetCategoryModelImpl = (AssetCategoryModelImpl)assetCategory;
10434
10435 Object[] args = new Object[] {
10436 assetCategory.getUuid(), assetCategory.getGroupId()
10437 };
10438
10439 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args);
10440 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args);
10441
10442 if ((assetCategoryModelImpl.getColumnBitmask() &
10443 FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) {
10444 args = new Object[] {
10445 assetCategoryModelImpl.getOriginalUuid(),
10446 assetCategoryModelImpl.getOriginalGroupId()
10447 };
10448
10449 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args);
10450 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args);
10451 }
10452
10453 args = new Object[] {
10454 assetCategory.getParentCategoryId(), assetCategory.getName(),
10455 assetCategory.getVocabularyId()
10456 };
10457
10458 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_P_N_V, args);
10459 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_P_N_V, args);
10460
10461 if ((assetCategoryModelImpl.getColumnBitmask() &
10462 FINDER_PATH_FETCH_BY_P_N_V.getColumnBitmask()) != 0) {
10463 args = new Object[] {
10464 assetCategoryModelImpl.getOriginalParentCategoryId(),
10465 assetCategoryModelImpl.getOriginalName(),
10466 assetCategoryModelImpl.getOriginalVocabularyId()
10467 };
10468
10469 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_P_N_V, args);
10470 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_P_N_V, args);
10471 }
10472 }
10473
10474
10480 public AssetCategory create(long categoryId) {
10481 AssetCategory assetCategory = new AssetCategoryImpl();
10482
10483 assetCategory.setNew(true);
10484 assetCategory.setPrimaryKey(categoryId);
10485
10486 String uuid = PortalUUIDUtil.generate();
10487
10488 assetCategory.setUuid(uuid);
10489
10490 return assetCategory;
10491 }
10492
10493
10501 public AssetCategory remove(long categoryId)
10502 throws NoSuchCategoryException, SystemException {
10503 return remove((Serializable)categoryId);
10504 }
10505
10506
10514 @Override
10515 public AssetCategory remove(Serializable primaryKey)
10516 throws NoSuchCategoryException, SystemException {
10517 Session session = null;
10518
10519 try {
10520 session = openSession();
10521
10522 AssetCategory assetCategory = (AssetCategory)session.get(AssetCategoryImpl.class,
10523 primaryKey);
10524
10525 if (assetCategory == null) {
10526 if (_log.isWarnEnabled()) {
10527 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
10528 }
10529
10530 throw new NoSuchCategoryException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
10531 primaryKey);
10532 }
10533
10534 return remove(assetCategory);
10535 }
10536 catch (NoSuchCategoryException nsee) {
10537 throw nsee;
10538 }
10539 catch (Exception e) {
10540 throw processException(e);
10541 }
10542 finally {
10543 closeSession(session);
10544 }
10545 }
10546
10547 @Override
10548 protected AssetCategory removeImpl(AssetCategory assetCategory)
10549 throws SystemException {
10550 assetCategory = toUnwrappedModel(assetCategory);
10551
10552 try {
10553 clearAssetEntries.clear(assetCategory.getPrimaryKey());
10554 }
10555 catch (Exception e) {
10556 throw processException(e);
10557 }
10558 finally {
10559 FinderCacheUtil.clearCache(AssetCategoryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
10560 }
10561
10562 shrinkTree(assetCategory);
10563
10564 Session session = null;
10565
10566 try {
10567 session = openSession();
10568
10569 if (!session.contains(assetCategory)) {
10570 assetCategory = (AssetCategory)session.get(AssetCategoryImpl.class,
10571 assetCategory.getPrimaryKeyObj());
10572 }
10573
10574 if (assetCategory != null) {
10575 session.delete(assetCategory);
10576 }
10577 }
10578 catch (Exception e) {
10579 throw processException(e);
10580 }
10581 finally {
10582 closeSession(session);
10583 }
10584
10585 if (assetCategory != null) {
10586 clearCache(assetCategory);
10587 }
10588
10589 return assetCategory;
10590 }
10591
10592 @Override
10593 public AssetCategory updateImpl(
10594 com.liferay.portlet.asset.model.AssetCategory assetCategory)
10595 throws SystemException {
10596 assetCategory = toUnwrappedModel(assetCategory);
10597
10598 boolean isNew = assetCategory.isNew();
10599
10600 AssetCategoryModelImpl assetCategoryModelImpl = (AssetCategoryModelImpl)assetCategory;
10601
10602 if (Validator.isNull(assetCategory.getUuid())) {
10603 String uuid = PortalUUIDUtil.generate();
10604
10605 assetCategory.setUuid(uuid);
10606 }
10607
10608 if (isNew) {
10609 expandTree(assetCategory, null);
10610 }
10611 else {
10612 if (assetCategory.getParentCategoryId() != assetCategoryModelImpl.getOriginalParentCategoryId()) {
10613 List<Long> childrenCategoryIds = getChildrenTreeCategoryIds(assetCategory);
10614
10615 shrinkTree(assetCategory);
10616 expandTree(assetCategory, childrenCategoryIds);
10617 }
10618 }
10619
10620 Session session = null;
10621
10622 try {
10623 session = openSession();
10624
10625 if (assetCategory.isNew()) {
10626 session.save(assetCategory);
10627
10628 assetCategory.setNew(false);
10629 }
10630 else {
10631 session.merge(assetCategory);
10632 }
10633 }
10634 catch (Exception e) {
10635 throw processException(e);
10636 }
10637 finally {
10638 closeSession(session);
10639 }
10640
10641 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
10642
10643 if (isNew || !AssetCategoryModelImpl.COLUMN_BITMASK_ENABLED) {
10644 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
10645 }
10646
10647 else {
10648 if ((assetCategoryModelImpl.getColumnBitmask() &
10649 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID.getColumnBitmask()) != 0) {
10650 Object[] args = new Object[] {
10651 assetCategoryModelImpl.getOriginalUuid()
10652 };
10653
10654 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
10655 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
10656 args);
10657
10658 args = new Object[] { assetCategoryModelImpl.getUuid() };
10659
10660 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
10661 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
10662 args);
10663 }
10664
10665 if ((assetCategoryModelImpl.getColumnBitmask() &
10666 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C.getColumnBitmask()) != 0) {
10667 Object[] args = new Object[] {
10668 assetCategoryModelImpl.getOriginalUuid(),
10669 assetCategoryModelImpl.getOriginalCompanyId()
10670 };
10671
10672 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args);
10673 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C,
10674 args);
10675
10676 args = new Object[] {
10677 assetCategoryModelImpl.getUuid(),
10678 assetCategoryModelImpl.getCompanyId()
10679 };
10680
10681 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args);
10682 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C,
10683 args);
10684 }
10685
10686 if ((assetCategoryModelImpl.getColumnBitmask() &
10687 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID.getColumnBitmask()) != 0) {
10688 Object[] args = new Object[] {
10689 assetCategoryModelImpl.getOriginalGroupId()
10690 };
10691
10692 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
10693 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
10694 args);
10695
10696 args = new Object[] { assetCategoryModelImpl.getGroupId() };
10697
10698 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
10699 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
10700 args);
10701 }
10702
10703 if ((assetCategoryModelImpl.getColumnBitmask() &
10704 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_PARENTCATEGORYID.getColumnBitmask()) != 0) {
10705 Object[] args = new Object[] {
10706 assetCategoryModelImpl.getOriginalParentCategoryId()
10707 };
10708
10709 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_PARENTCATEGORYID,
10710 args);
10711 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_PARENTCATEGORYID,
10712 args);
10713
10714 args = new Object[] { assetCategoryModelImpl.getParentCategoryId() };
10715
10716 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_PARENTCATEGORYID,
10717 args);
10718 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_PARENTCATEGORYID,
10719 args);
10720 }
10721
10722 if ((assetCategoryModelImpl.getColumnBitmask() &
10723 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_VOCABULARYID.getColumnBitmask()) != 0) {
10724 Object[] args = new Object[] {
10725 assetCategoryModelImpl.getOriginalVocabularyId()
10726 };
10727
10728 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_VOCABULARYID,
10729 args);
10730 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_VOCABULARYID,
10731 args);
10732
10733 args = new Object[] { assetCategoryModelImpl.getVocabularyId() };
10734
10735 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_VOCABULARYID,
10736 args);
10737 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_VOCABULARYID,
10738 args);
10739 }
10740
10741 if ((assetCategoryModelImpl.getColumnBitmask() &
10742 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_V.getColumnBitmask()) != 0) {
10743 Object[] args = new Object[] {
10744 assetCategoryModelImpl.getOriginalGroupId(),
10745 assetCategoryModelImpl.getOriginalVocabularyId()
10746 };
10747
10748 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_V, args);
10749 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_V,
10750 args);
10751
10752 args = new Object[] {
10753 assetCategoryModelImpl.getGroupId(),
10754 assetCategoryModelImpl.getVocabularyId()
10755 };
10756
10757 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_V, args);
10758 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_V,
10759 args);
10760 }
10761
10762 if ((assetCategoryModelImpl.getColumnBitmask() &
10763 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_P_N.getColumnBitmask()) != 0) {
10764 Object[] args = new Object[] {
10765 assetCategoryModelImpl.getOriginalParentCategoryId(),
10766 assetCategoryModelImpl.getOriginalName()
10767 };
10768
10769 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_P_N, args);
10770 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_P_N,
10771 args);
10772
10773 args = new Object[] {
10774 assetCategoryModelImpl.getParentCategoryId(),
10775 assetCategoryModelImpl.getName()
10776 };
10777
10778 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_P_N, args);
10779 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_P_N,
10780 args);
10781 }
10782
10783 if ((assetCategoryModelImpl.getColumnBitmask() &
10784 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_P_V.getColumnBitmask()) != 0) {
10785 Object[] args = new Object[] {
10786 assetCategoryModelImpl.getOriginalParentCategoryId(),
10787 assetCategoryModelImpl.getOriginalVocabularyId()
10788 };
10789
10790 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_P_V, args);
10791 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_P_V,
10792 args);
10793
10794 args = new Object[] {
10795 assetCategoryModelImpl.getParentCategoryId(),
10796 assetCategoryModelImpl.getVocabularyId()
10797 };
10798
10799 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_P_V, args);
10800 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_P_V,
10801 args);
10802 }
10803
10804 if ((assetCategoryModelImpl.getColumnBitmask() &
10805 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_V.getColumnBitmask()) != 0) {
10806 Object[] args = new Object[] {
10807 assetCategoryModelImpl.getOriginalName(),
10808 assetCategoryModelImpl.getOriginalVocabularyId()
10809 };
10810
10811 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_N_V, args);
10812 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_V,
10813 args);
10814
10815 args = new Object[] {
10816 assetCategoryModelImpl.getName(),
10817 assetCategoryModelImpl.getVocabularyId()
10818 };
10819
10820 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_N_V, args);
10821 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_V,
10822 args);
10823 }
10824
10825 if ((assetCategoryModelImpl.getColumnBitmask() &
10826 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_V.getColumnBitmask()) != 0) {
10827 Object[] args = new Object[] {
10828 assetCategoryModelImpl.getOriginalGroupId(),
10829 assetCategoryModelImpl.getOriginalParentCategoryId(),
10830 assetCategoryModelImpl.getOriginalVocabularyId()
10831 };
10832
10833 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_P_V, args);
10834 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_V,
10835 args);
10836
10837 args = new Object[] {
10838 assetCategoryModelImpl.getGroupId(),
10839 assetCategoryModelImpl.getParentCategoryId(),
10840 assetCategoryModelImpl.getVocabularyId()
10841 };
10842
10843 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_P_V, args);
10844 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_V,
10845 args);
10846 }
10847
10848 if ((assetCategoryModelImpl.getColumnBitmask() &
10849 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_N_V.getColumnBitmask()) != 0) {
10850 Object[] args = new Object[] {
10851 assetCategoryModelImpl.getOriginalGroupId(),
10852 assetCategoryModelImpl.getOriginalParentCategoryId(),
10853 assetCategoryModelImpl.getOriginalName(),
10854 assetCategoryModelImpl.getOriginalVocabularyId()
10855 };
10856
10857 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_P_N_V, args);
10858 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_N_V,
10859 args);
10860
10861 args = new Object[] {
10862 assetCategoryModelImpl.getGroupId(),
10863 assetCategoryModelImpl.getParentCategoryId(),
10864 assetCategoryModelImpl.getName(),
10865 assetCategoryModelImpl.getVocabularyId()
10866 };
10867
10868 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_P_N_V, args);
10869 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_N_V,
10870 args);
10871 }
10872 }
10873
10874 EntityCacheUtil.putResult(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
10875 AssetCategoryImpl.class, assetCategory.getPrimaryKey(),
10876 assetCategory);
10877
10878 clearUniqueFindersCache(assetCategory);
10879 cacheUniqueFindersCache(assetCategory);
10880
10881 return assetCategory;
10882 }
10883
10884 protected AssetCategory toUnwrappedModel(AssetCategory assetCategory) {
10885 if (assetCategory instanceof AssetCategoryImpl) {
10886 return assetCategory;
10887 }
10888
10889 AssetCategoryImpl assetCategoryImpl = new AssetCategoryImpl();
10890
10891 assetCategoryImpl.setNew(assetCategory.isNew());
10892 assetCategoryImpl.setPrimaryKey(assetCategory.getPrimaryKey());
10893
10894 assetCategoryImpl.setUuid(assetCategory.getUuid());
10895 assetCategoryImpl.setCategoryId(assetCategory.getCategoryId());
10896 assetCategoryImpl.setGroupId(assetCategory.getGroupId());
10897 assetCategoryImpl.setCompanyId(assetCategory.getCompanyId());
10898 assetCategoryImpl.setUserId(assetCategory.getUserId());
10899 assetCategoryImpl.setUserName(assetCategory.getUserName());
10900 assetCategoryImpl.setCreateDate(assetCategory.getCreateDate());
10901 assetCategoryImpl.setModifiedDate(assetCategory.getModifiedDate());
10902 assetCategoryImpl.setParentCategoryId(assetCategory.getParentCategoryId());
10903 assetCategoryImpl.setLeftCategoryId(assetCategory.getLeftCategoryId());
10904 assetCategoryImpl.setRightCategoryId(assetCategory.getRightCategoryId());
10905 assetCategoryImpl.setName(assetCategory.getName());
10906 assetCategoryImpl.setTitle(assetCategory.getTitle());
10907 assetCategoryImpl.setDescription(assetCategory.getDescription());
10908 assetCategoryImpl.setVocabularyId(assetCategory.getVocabularyId());
10909
10910 return assetCategoryImpl;
10911 }
10912
10913
10921 @Override
10922 public AssetCategory findByPrimaryKey(Serializable primaryKey)
10923 throws NoSuchCategoryException, SystemException {
10924 AssetCategory assetCategory = fetchByPrimaryKey(primaryKey);
10925
10926 if (assetCategory == null) {
10927 if (_log.isWarnEnabled()) {
10928 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
10929 }
10930
10931 throw new NoSuchCategoryException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
10932 primaryKey);
10933 }
10934
10935 return assetCategory;
10936 }
10937
10938
10946 public AssetCategory findByPrimaryKey(long categoryId)
10947 throws NoSuchCategoryException, SystemException {
10948 return findByPrimaryKey((Serializable)categoryId);
10949 }
10950
10951
10958 @Override
10959 public AssetCategory fetchByPrimaryKey(Serializable primaryKey)
10960 throws SystemException {
10961 AssetCategory assetCategory = (AssetCategory)EntityCacheUtil.getResult(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
10962 AssetCategoryImpl.class, primaryKey);
10963
10964 if (assetCategory == _nullAssetCategory) {
10965 return null;
10966 }
10967
10968 if (assetCategory == null) {
10969 Session session = null;
10970
10971 try {
10972 session = openSession();
10973
10974 assetCategory = (AssetCategory)session.get(AssetCategoryImpl.class,
10975 primaryKey);
10976
10977 if (assetCategory != null) {
10978 cacheResult(assetCategory);
10979 }
10980 else {
10981 EntityCacheUtil.putResult(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
10982 AssetCategoryImpl.class, primaryKey, _nullAssetCategory);
10983 }
10984 }
10985 catch (Exception e) {
10986 EntityCacheUtil.removeResult(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
10987 AssetCategoryImpl.class, primaryKey);
10988
10989 throw processException(e);
10990 }
10991 finally {
10992 closeSession(session);
10993 }
10994 }
10995
10996 return assetCategory;
10997 }
10998
10999
11006 public AssetCategory fetchByPrimaryKey(long categoryId)
11007 throws SystemException {
11008 return fetchByPrimaryKey((Serializable)categoryId);
11009 }
11010
11011
11017 public List<AssetCategory> findAll() throws SystemException {
11018 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
11019 }
11020
11021
11033 public List<AssetCategory> findAll(int start, int end)
11034 throws SystemException {
11035 return findAll(start, end, null);
11036 }
11037
11038
11051 public List<AssetCategory> findAll(int start, int end,
11052 OrderByComparator orderByComparator) throws SystemException {
11053 boolean pagination = true;
11054 FinderPath finderPath = null;
11055 Object[] finderArgs = null;
11056
11057 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
11058 (orderByComparator == null)) {
11059 pagination = false;
11060 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
11061 finderArgs = FINDER_ARGS_EMPTY;
11062 }
11063 else {
11064 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
11065 finderArgs = new Object[] { start, end, orderByComparator };
11066 }
11067
11068 List<AssetCategory> list = (List<AssetCategory>)FinderCacheUtil.getResult(finderPath,
11069 finderArgs, this);
11070
11071 if (list == null) {
11072 StringBundler query = null;
11073 String sql = null;
11074
11075 if (orderByComparator != null) {
11076 query = new StringBundler(2 +
11077 (orderByComparator.getOrderByFields().length * 3));
11078
11079 query.append(_SQL_SELECT_ASSETCATEGORY);
11080
11081 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
11082 orderByComparator);
11083
11084 sql = query.toString();
11085 }
11086 else {
11087 sql = _SQL_SELECT_ASSETCATEGORY;
11088
11089 if (pagination) {
11090 sql = sql.concat(AssetCategoryModelImpl.ORDER_BY_JPQL);
11091 }
11092 }
11093
11094 Session session = null;
11095
11096 try {
11097 session = openSession();
11098
11099 Query q = session.createQuery(sql);
11100
11101 if (!pagination) {
11102 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
11103 start, end, false);
11104
11105 Collections.sort(list);
11106
11107 list = new UnmodifiableList<AssetCategory>(list);
11108 }
11109 else {
11110 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
11111 start, end);
11112 }
11113
11114 cacheResult(list);
11115
11116 FinderCacheUtil.putResult(finderPath, finderArgs, list);
11117 }
11118 catch (Exception e) {
11119 FinderCacheUtil.removeResult(finderPath, finderArgs);
11120
11121 throw processException(e);
11122 }
11123 finally {
11124 closeSession(session);
11125 }
11126 }
11127
11128 return list;
11129 }
11130
11131
11136 public void removeAll() throws SystemException {
11137 for (AssetCategory assetCategory : findAll()) {
11138 remove(assetCategory);
11139 }
11140 }
11141
11142
11148 public int countAll() throws SystemException {
11149 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
11150 FINDER_ARGS_EMPTY, this);
11151
11152 if (count == null) {
11153 Session session = null;
11154
11155 try {
11156 session = openSession();
11157
11158 Query q = session.createQuery(_SQL_COUNT_ASSETCATEGORY);
11159
11160 count = (Long)q.uniqueResult();
11161
11162 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
11163 FINDER_ARGS_EMPTY, count);
11164 }
11165 catch (Exception e) {
11166 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_ALL,
11167 FINDER_ARGS_EMPTY);
11168
11169 throw processException(e);
11170 }
11171 finally {
11172 closeSession(session);
11173 }
11174 }
11175
11176 return count.intValue();
11177 }
11178
11179
11186 public List<com.liferay.portlet.asset.model.AssetEntry> getAssetEntries(
11187 long pk) throws SystemException {
11188 return getAssetEntries(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
11189 }
11190
11191
11204 public List<com.liferay.portlet.asset.model.AssetEntry> getAssetEntries(
11205 long pk, int start, int end) throws SystemException {
11206 return getAssetEntries(pk, start, end, null);
11207 }
11208
11209 public static final FinderPath FINDER_PATH_GET_ASSETENTRIES = new FinderPath(com.liferay.portlet.asset.model.impl.AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
11210 AssetCategoryModelImpl.FINDER_CACHE_ENABLED_ASSETENTRIES_ASSETCATEGORIES,
11211 com.liferay.portlet.asset.model.impl.AssetEntryImpl.class,
11212 AssetCategoryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME,
11213 "getAssetEntries",
11214 new String[] {
11215 Long.class.getName(), Integer.class.getName(),
11216 Integer.class.getName(), OrderByComparator.class.getName()
11217 });
11218
11219 static {
11220 FINDER_PATH_GET_ASSETENTRIES.setCacheKeyGeneratorCacheName(null);
11221 }
11222
11223
11237 public List<com.liferay.portlet.asset.model.AssetEntry> getAssetEntries(
11238 long pk, int start, int end, OrderByComparator orderByComparator)
11239 throws SystemException {
11240 boolean pagination = true;
11241 Object[] finderArgs = null;
11242
11243 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
11244 (orderByComparator == null)) {
11245 pagination = false;
11246 finderArgs = new Object[] { pk };
11247 }
11248 else {
11249 finderArgs = new Object[] { pk, start, end, orderByComparator };
11250 }
11251
11252 List<com.liferay.portlet.asset.model.AssetEntry> list = (List<com.liferay.portlet.asset.model.AssetEntry>)FinderCacheUtil.getResult(FINDER_PATH_GET_ASSETENTRIES,
11253 finderArgs, this);
11254
11255 if (list == null) {
11256 Session session = null;
11257
11258 try {
11259 session = openSession();
11260
11261 String sql = null;
11262
11263 if (orderByComparator != null) {
11264 sql = _SQL_GETASSETENTRIES.concat(ORDER_BY_CLAUSE)
11265 .concat(orderByComparator.getOrderBy());
11266 }
11267 else {
11268 sql = _SQL_GETASSETENTRIES;
11269
11270 if (pagination) {
11271 sql = sql.concat(com.liferay.portlet.asset.model.impl.AssetEntryModelImpl.ORDER_BY_SQL);
11272 }
11273 }
11274
11275 SQLQuery q = session.createSQLQuery(sql);
11276
11277 q.addEntity("AssetEntry",
11278 com.liferay.portlet.asset.model.impl.AssetEntryImpl.class);
11279
11280 QueryPos qPos = QueryPos.getInstance(q);
11281
11282 qPos.add(pk);
11283
11284 if (!pagination) {
11285 list = (List<com.liferay.portlet.asset.model.AssetEntry>)QueryUtil.list(q,
11286 getDialect(), start, end, false);
11287
11288 Collections.sort(list);
11289
11290 list = new UnmodifiableList<com.liferay.portlet.asset.model.AssetEntry>(list);
11291 }
11292 else {
11293 list = (List<com.liferay.portlet.asset.model.AssetEntry>)QueryUtil.list(q,
11294 getDialect(), start, end);
11295 }
11296
11297 assetEntryPersistence.cacheResult(list);
11298
11299 FinderCacheUtil.putResult(FINDER_PATH_GET_ASSETENTRIES,
11300 finderArgs, list);
11301 }
11302 catch (Exception e) {
11303 FinderCacheUtil.removeResult(FINDER_PATH_GET_ASSETENTRIES,
11304 finderArgs);
11305
11306 throw processException(e);
11307 }
11308 finally {
11309 closeSession(session);
11310 }
11311 }
11312
11313 return list;
11314 }
11315
11316 public static final FinderPath FINDER_PATH_GET_ASSETENTRIES_SIZE = new FinderPath(com.liferay.portlet.asset.model.impl.AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
11317 AssetCategoryModelImpl.FINDER_CACHE_ENABLED_ASSETENTRIES_ASSETCATEGORIES,
11318 Long.class,
11319 AssetCategoryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME,
11320 "getAssetEntriesSize", new String[] { Long.class.getName() });
11321
11322 static {
11323 FINDER_PATH_GET_ASSETENTRIES_SIZE.setCacheKeyGeneratorCacheName(null);
11324 }
11325
11326
11333 public int getAssetEntriesSize(long pk) throws SystemException {
11334 Object[] finderArgs = new Object[] { pk };
11335
11336 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_GET_ASSETENTRIES_SIZE,
11337 finderArgs, this);
11338
11339 if (count == null) {
11340 Session session = null;
11341
11342 try {
11343 session = openSession();
11344
11345 SQLQuery q = session.createSQLQuery(_SQL_GETASSETENTRIESSIZE);
11346
11347 q.addScalar(COUNT_COLUMN_NAME,
11348 com.liferay.portal.kernel.dao.orm.Type.LONG);
11349
11350 QueryPos qPos = QueryPos.getInstance(q);
11351
11352 qPos.add(pk);
11353
11354 count = (Long)q.uniqueResult();
11355
11356 FinderCacheUtil.putResult(FINDER_PATH_GET_ASSETENTRIES_SIZE,
11357 finderArgs, count);
11358 }
11359 catch (Exception e) {
11360 FinderCacheUtil.removeResult(FINDER_PATH_GET_ASSETENTRIES_SIZE,
11361 finderArgs);
11362
11363 throw processException(e);
11364 }
11365 finally {
11366 closeSession(session);
11367 }
11368 }
11369
11370 return count.intValue();
11371 }
11372
11373 public static final FinderPath FINDER_PATH_CONTAINS_ASSETENTRY = new FinderPath(com.liferay.portlet.asset.model.impl.AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
11374 AssetCategoryModelImpl.FINDER_CACHE_ENABLED_ASSETENTRIES_ASSETCATEGORIES,
11375 Boolean.class,
11376 AssetCategoryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME,
11377 "containsAssetEntry",
11378 new String[] { Long.class.getName(), Long.class.getName() });
11379
11380
11388 public boolean containsAssetEntry(long pk, long assetEntryPK)
11389 throws SystemException {
11390 Object[] finderArgs = new Object[] { pk, assetEntryPK };
11391
11392 Boolean value = (Boolean)FinderCacheUtil.getResult(FINDER_PATH_CONTAINS_ASSETENTRY,
11393 finderArgs, this);
11394
11395 if (value == null) {
11396 try {
11397 value = Boolean.valueOf(containsAssetEntry.contains(pk,
11398 assetEntryPK));
11399
11400 FinderCacheUtil.putResult(FINDER_PATH_CONTAINS_ASSETENTRY,
11401 finderArgs, value);
11402 }
11403 catch (Exception e) {
11404 FinderCacheUtil.removeResult(FINDER_PATH_CONTAINS_ASSETENTRY,
11405 finderArgs);
11406
11407 throw processException(e);
11408 }
11409 }
11410
11411 return value.booleanValue();
11412 }
11413
11414
11421 public boolean containsAssetEntries(long pk) throws SystemException {
11422 if (getAssetEntriesSize(pk) > 0) {
11423 return true;
11424 }
11425 else {
11426 return false;
11427 }
11428 }
11429
11430
11437 public void addAssetEntry(long pk, long assetEntryPK)
11438 throws SystemException {
11439 try {
11440 addAssetEntry.add(pk, assetEntryPK);
11441 }
11442 catch (Exception e) {
11443 throw processException(e);
11444 }
11445 finally {
11446 FinderCacheUtil.clearCache(AssetCategoryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
11447 }
11448 }
11449
11450
11457 public void addAssetEntry(long pk,
11458 com.liferay.portlet.asset.model.AssetEntry assetEntry)
11459 throws SystemException {
11460 try {
11461 addAssetEntry.add(pk, assetEntry.getPrimaryKey());
11462 }
11463 catch (Exception e) {
11464 throw processException(e);
11465 }
11466 finally {
11467 FinderCacheUtil.clearCache(AssetCategoryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
11468 }
11469 }
11470
11471
11478 public void addAssetEntries(long pk, long[] assetEntryPKs)
11479 throws SystemException {
11480 try {
11481 for (long assetEntryPK : assetEntryPKs) {
11482 addAssetEntry.add(pk, assetEntryPK);
11483 }
11484 }
11485 catch (Exception e) {
11486 throw processException(e);
11487 }
11488 finally {
11489 FinderCacheUtil.clearCache(AssetCategoryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
11490 }
11491 }
11492
11493
11500 public void addAssetEntries(long pk,
11501 List<com.liferay.portlet.asset.model.AssetEntry> assetEntries)
11502 throws SystemException {
11503 try {
11504 for (com.liferay.portlet.asset.model.AssetEntry assetEntry : assetEntries) {
11505 addAssetEntry.add(pk, assetEntry.getPrimaryKey());
11506 }
11507 }
11508 catch (Exception e) {
11509 throw processException(e);
11510 }
11511 finally {
11512 FinderCacheUtil.clearCache(AssetCategoryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
11513 }
11514 }
11515
11516
11522 public void clearAssetEntries(long pk) throws SystemException {
11523 try {
11524 clearAssetEntries.clear(pk);
11525 }
11526 catch (Exception e) {
11527 throw processException(e);
11528 }
11529 finally {
11530 FinderCacheUtil.clearCache(AssetCategoryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
11531 }
11532 }
11533
11534
11541 public void removeAssetEntry(long pk, long assetEntryPK)
11542 throws SystemException {
11543 try {
11544 removeAssetEntry.remove(pk, assetEntryPK);
11545 }
11546 catch (Exception e) {
11547 throw processException(e);
11548 }
11549 finally {
11550 FinderCacheUtil.clearCache(AssetCategoryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
11551 }
11552 }
11553
11554
11561 public void removeAssetEntry(long pk,
11562 com.liferay.portlet.asset.model.AssetEntry assetEntry)
11563 throws SystemException {
11564 try {
11565 removeAssetEntry.remove(pk, assetEntry.getPrimaryKey());
11566 }
11567 catch (Exception e) {
11568 throw processException(e);
11569 }
11570 finally {
11571 FinderCacheUtil.clearCache(AssetCategoryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
11572 }
11573 }
11574
11575
11582 public void removeAssetEntries(long pk, long[] assetEntryPKs)
11583 throws SystemException {
11584 try {
11585 for (long assetEntryPK : assetEntryPKs) {
11586 removeAssetEntry.remove(pk, assetEntryPK);
11587 }
11588 }
11589 catch (Exception e) {
11590 throw processException(e);
11591 }
11592 finally {
11593 FinderCacheUtil.clearCache(AssetCategoryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
11594 }
11595 }
11596
11597
11604 public void removeAssetEntries(long pk,
11605 List<com.liferay.portlet.asset.model.AssetEntry> assetEntries)
11606 throws SystemException {
11607 try {
11608 for (com.liferay.portlet.asset.model.AssetEntry assetEntry : assetEntries) {
11609 removeAssetEntry.remove(pk, assetEntry.getPrimaryKey());
11610 }
11611 }
11612 catch (Exception e) {
11613 throw processException(e);
11614 }
11615 finally {
11616 FinderCacheUtil.clearCache(AssetCategoryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
11617 }
11618 }
11619
11620
11627 public void setAssetEntries(long pk, long[] assetEntryPKs)
11628 throws SystemException {
11629 try {
11630 Set<Long> assetEntryPKSet = SetUtil.fromArray(assetEntryPKs);
11631
11632 List<com.liferay.portlet.asset.model.AssetEntry> assetEntries = getAssetEntries(pk);
11633
11634 for (com.liferay.portlet.asset.model.AssetEntry assetEntry : assetEntries) {
11635 if (!assetEntryPKSet.remove(assetEntry.getPrimaryKey())) {
11636 removeAssetEntry.remove(pk, assetEntry.getPrimaryKey());
11637 }
11638 }
11639
11640 for (Long assetEntryPK : assetEntryPKSet) {
11641 addAssetEntry.add(pk, assetEntryPK);
11642 }
11643 }
11644 catch (Exception e) {
11645 throw processException(e);
11646 }
11647 finally {
11648 FinderCacheUtil.clearCache(AssetCategoryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
11649 }
11650 }
11651
11652
11659 public void setAssetEntries(long pk,
11660 List<com.liferay.portlet.asset.model.AssetEntry> assetEntries)
11661 throws SystemException {
11662 try {
11663 long[] assetEntryPKs = new long[assetEntries.size()];
11664
11665 for (int i = 0; i < assetEntries.size(); i++) {
11666 com.liferay.portlet.asset.model.AssetEntry assetEntry = assetEntries.get(i);
11667
11668 assetEntryPKs[i] = assetEntry.getPrimaryKey();
11669 }
11670
11671 setAssetEntries(pk, assetEntryPKs);
11672 }
11673 catch (Exception e) {
11674 throw processException(e);
11675 }
11676 finally {
11677 FinderCacheUtil.clearCache(AssetCategoryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
11678 }
11679 }
11680
11681 @Override
11682 protected Set<String> getBadColumnNames() {
11683 return _badColumnNames;
11684 }
11685
11686
11696 public void rebuildTree(long groupId, boolean force)
11697 throws SystemException {
11698 if (!rebuildTreeEnabled) {
11699 return;
11700 }
11701
11702 if (force || (countOrphanTreeNodes(groupId) > 0)) {
11703 rebuildTree(groupId, 0, 1);
11704
11705 CacheRegistryUtil.clear(AssetCategoryImpl.class.getName());
11706 EntityCacheUtil.clearCache(AssetCategoryImpl.class.getName());
11707 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
11708 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
11709 }
11710 }
11711
11712 public void setRebuildTreeEnabled(boolean rebuildTreeEnabled) {
11713 this.rebuildTreeEnabled = rebuildTreeEnabled;
11714 }
11715
11716 protected long countOrphanTreeNodes(long groupId) throws SystemException {
11717 Session session = null;
11718
11719 try {
11720 session = openSession();
11721
11722 SQLQuery q = session.createSQLQuery(
11723 "SELECT COUNT(*) AS COUNT_VALUE FROM AssetCategory WHERE groupId = ? AND (leftCategoryId = 0 OR leftCategoryId IS NULL OR rightCategoryId = 0 OR rightCategoryId IS NULL)");
11724
11725 q.addScalar(COUNT_COLUMN_NAME,
11726 com.liferay.portal.kernel.dao.orm.Type.LONG);
11727
11728 QueryPos qPos = QueryPos.getInstance(q);
11729
11730 qPos.add(groupId);
11731
11732 return (Long)q.uniqueResult();
11733 }
11734 catch (Exception e) {
11735 throw processException(e);
11736 }
11737 finally {
11738 closeSession(session);
11739 }
11740 }
11741
11742 protected void expandNoChildrenLeftCategoryId(long groupId,
11743 long leftCategoryId, List<Long> childrenCategoryIds, long delta) {
11744 String sql = "UPDATE AssetCategory SET leftcategoryId = (leftcategoryId + ?) WHERE (groupId = ?) AND (leftcategoryId > ?) AND (categoryId NOT IN (" +
11745 StringUtil.merge(childrenCategoryIds) + "))";
11746
11747 SqlUpdate _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
11748 sql,
11749 new int[] {
11750 java.sql.Types.BIGINT, java.sql.Types.BIGINT,
11751 java.sql.Types.BIGINT
11752 });
11753
11754 _sqlUpdate.update(new Object[] { delta, groupId, leftCategoryId });
11755 }
11756
11757 protected void expandNoChildrenRightCategoryId(long groupId,
11758 long rightCategoryId, List<Long> childrenCategoryIds, long delta) {
11759 String sql = "UPDATE AssetCategory SET rightcategoryId = (rightcategoryId + ?) WHERE (groupId = ?) AND (rightcategoryId > ?) AND (categoryId NOT IN (" +
11760 StringUtil.merge(childrenCategoryIds) + "))";
11761
11762 SqlUpdate _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
11763 sql,
11764 new int[] {
11765 java.sql.Types.BIGINT, java.sql.Types.BIGINT,
11766 java.sql.Types.BIGINT
11767 });
11768
11769 _sqlUpdate.update(new Object[] { delta, groupId, rightCategoryId });
11770 }
11771
11772 protected void expandTree(AssetCategory assetCategory,
11773 List<Long> childrenCategoryIds) throws SystemException {
11774 if (!rebuildTreeEnabled) {
11775 return;
11776 }
11777
11778 long groupId = assetCategory.getGroupId();
11779
11780 long lastRightCategoryId = getLastRightCategoryId(groupId,
11781 assetCategory.getParentCategoryId());
11782
11783 long leftCategoryId = 2;
11784 long rightCategoryId = 3;
11785
11786 if (lastRightCategoryId > 0) {
11787 leftCategoryId = lastRightCategoryId + 1;
11788
11789 long childrenDistance = assetCategory.getRightCategoryId() -
11790 assetCategory.getLeftCategoryId();
11791
11792 if (childrenDistance > 1) {
11793 rightCategoryId = leftCategoryId + childrenDistance;
11794
11795 updateChildrenTree(groupId, childrenCategoryIds,
11796 leftCategoryId - assetCategory.getLeftCategoryId());
11797
11798 expandNoChildrenLeftCategoryId(groupId, lastRightCategoryId,
11799 childrenCategoryIds, childrenDistance + 1);
11800 expandNoChildrenRightCategoryId(groupId, lastRightCategoryId,
11801 childrenCategoryIds, childrenDistance + 1);
11802 }
11803 else {
11804 rightCategoryId = lastRightCategoryId + 2;
11805
11806 expandTreeLeftCategoryId.expand(groupId, lastRightCategoryId);
11807 expandTreeRightCategoryId.expand(groupId, lastRightCategoryId);
11808 }
11809
11810 CacheRegistryUtil.clear(AssetCategoryImpl.class.getName());
11811 EntityCacheUtil.clearCache(AssetCategoryImpl.class.getName());
11812 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
11813 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
11814 }
11815
11816 assetCategory.setLeftCategoryId(leftCategoryId);
11817 assetCategory.setRightCategoryId(rightCategoryId);
11818 }
11819
11820 protected List<Long> getChildrenTreeCategoryIds(
11821 AssetCategory parentAssetCategory) throws SystemException {
11822 Session session = null;
11823
11824 try {
11825 session = openSession();
11826
11827 SQLQuery q = session.createSQLQuery(
11828 "SELECT categoryId FROM AssetCategory WHERE (groupId = ?) AND (leftcategoryId BETWEEN ? AND ?)");
11829
11830 q.addScalar("CategoryId",
11831 com.liferay.portal.kernel.dao.orm.Type.LONG);
11832
11833 QueryPos qPos = QueryPos.getInstance(q);
11834
11835 qPos.add(parentAssetCategory.getGroupId());
11836 qPos.add(parentAssetCategory.getLeftCategoryId() + 1);
11837 qPos.add(parentAssetCategory.getRightCategoryId());
11838
11839 return q.list();
11840 }
11841 catch (Exception e) {
11842 throw processException(e);
11843 }
11844 finally {
11845 closeSession(session);
11846 }
11847 }
11848
11849 protected long getLastRightCategoryId(long groupId, long parentCategoryId)
11850 throws SystemException {
11851 Session session = null;
11852
11853 try {
11854 session = openSession();
11855
11856 SQLQuery q = session.createSQLQuery(
11857 "SELECT rightCategoryId FROM AssetCategory WHERE (groupId = ?) AND (parentCategoryId = ?) ORDER BY rightCategoryId DESC");
11858
11859 q.addScalar("rightCategoryId",
11860 com.liferay.portal.kernel.dao.orm.Type.LONG);
11861
11862 QueryPos qPos = QueryPos.getInstance(q);
11863
11864 qPos.add(groupId);
11865 qPos.add(parentCategoryId);
11866
11867 List<Long> list = (List<Long>)QueryUtil.list(q, getDialect(), 0, 1);
11868
11869 if (list.isEmpty()) {
11870 if (parentCategoryId > 0) {
11871 session.clear();
11872
11873 AssetCategory parentAssetCategory = findByPrimaryKey(parentCategoryId);
11874
11875 return parentAssetCategory.getLeftCategoryId();
11876 }
11877
11878 return 0;
11879 }
11880 else {
11881 return list.get(0);
11882 }
11883 }
11884 catch (Exception e) {
11885 throw processException(e);
11886 }
11887 finally {
11888 closeSession(session);
11889 }
11890 }
11891
11892 protected long rebuildTree(long groupId, long parentCategoryId,
11893 long leftCategoryId) throws SystemException {
11894 if (!rebuildTreeEnabled) {
11895 return 0;
11896 }
11897
11898 List<Long> categoryIds = null;
11899
11900 Session session = null;
11901
11902 try {
11903 session = openSession();
11904
11905 SQLQuery q = session.createSQLQuery(
11906 "SELECT categoryId FROM AssetCategory WHERE groupId = ? AND parentCategoryId = ? ORDER BY categoryId ASC");
11907
11908 q.addScalar("categoryId",
11909 com.liferay.portal.kernel.dao.orm.Type.LONG);
11910
11911 QueryPos qPos = QueryPos.getInstance(q);
11912
11913 qPos.add(groupId);
11914 qPos.add(parentCategoryId);
11915
11916 categoryIds = q.list();
11917 }
11918 catch (Exception e) {
11919 throw processException(e);
11920 }
11921 finally {
11922 closeSession(session);
11923 }
11924
11925 long rightCategoryId = leftCategoryId + 1;
11926
11927 for (long categoryId : categoryIds) {
11928 rightCategoryId = rebuildTree(groupId, categoryId, rightCategoryId);
11929 }
11930
11931 if (parentCategoryId > 0) {
11932 updateTree.update(parentCategoryId, leftCategoryId, rightCategoryId);
11933 }
11934
11935 return rightCategoryId + 1;
11936 }
11937
11938 protected void shrinkTree(AssetCategory assetCategory) {
11939 if (!rebuildTreeEnabled) {
11940 return;
11941 }
11942
11943 long groupId = assetCategory.getGroupId();
11944
11945 long leftCategoryId = assetCategory.getLeftCategoryId();
11946 long rightCategoryId = assetCategory.getRightCategoryId();
11947
11948 long delta = (rightCategoryId - leftCategoryId) + 1;
11949
11950 shrinkTreeLeftCategoryId.shrink(groupId, rightCategoryId, delta);
11951 shrinkTreeRightCategoryId.shrink(groupId, rightCategoryId, delta);
11952
11953 CacheRegistryUtil.clear(AssetCategoryImpl.class.getName());
11954 EntityCacheUtil.clearCache(AssetCategoryImpl.class.getName());
11955 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
11956 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
11957 }
11958
11959 protected void updateChildrenTree(long groupId,
11960 List<Long> childrenCategoryIds, long delta) {
11961 String sql = "UPDATE AssetCategory SET leftcategoryId = (leftcategoryId + ?), rightcategoryId = (rightcategoryId + ?) WHERE (groupId = ?) AND (categoryId IN (" +
11962 StringUtil.merge(childrenCategoryIds) + "))";
11963
11964 SqlUpdate _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
11965 sql,
11966 new int[] {
11967 java.sql.Types.BIGINT, java.sql.Types.BIGINT,
11968 java.sql.Types.BIGINT
11969 });
11970
11971 _sqlUpdate.update(new Object[] { delta, delta, groupId });
11972 }
11973
11974
11977 public void afterPropertiesSet() {
11978 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
11979 com.liferay.portal.util.PropsUtil.get(
11980 "value.object.listener.com.liferay.portlet.asset.model.AssetCategory")));
11981
11982 if (listenerClassNames.length > 0) {
11983 try {
11984 List<ModelListener<AssetCategory>> listenersList = new ArrayList<ModelListener<AssetCategory>>();
11985
11986 for (String listenerClassName : listenerClassNames) {
11987 listenersList.add((ModelListener<AssetCategory>)InstanceFactory.newInstance(
11988 getClassLoader(), listenerClassName));
11989 }
11990
11991 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
11992 }
11993 catch (Exception e) {
11994 _log.error(e);
11995 }
11996 }
11997
11998 containsAssetEntry = new ContainsAssetEntry();
11999
12000 addAssetEntry = new AddAssetEntry();
12001 clearAssetEntries = new ClearAssetEntries();
12002 removeAssetEntry = new RemoveAssetEntry();
12003
12004 expandTreeLeftCategoryId = new ExpandTreeLeftCategoryId();
12005 expandTreeRightCategoryId = new ExpandTreeRightCategoryId();
12006 shrinkTreeLeftCategoryId = new ShrinkTreeLeftCategoryId();
12007 shrinkTreeRightCategoryId = new ShrinkTreeRightCategoryId();
12008 updateTree = new UpdateTree();
12009 }
12010
12011 public void destroy() {
12012 EntityCacheUtil.removeCache(AssetCategoryImpl.class.getName());
12013 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
12014 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
12015 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
12016 }
12017
12018 @BeanReference(type = AssetEntryPersistence.class)
12019 protected AssetEntryPersistence assetEntryPersistence;
12020 protected ContainsAssetEntry containsAssetEntry;
12021 protected AddAssetEntry addAssetEntry;
12022 protected ClearAssetEntries clearAssetEntries;
12023 protected RemoveAssetEntry removeAssetEntry;
12024
12025 protected class ContainsAssetEntry {
12026 protected ContainsAssetEntry() {
12027 _mappingSqlQuery = MappingSqlQueryFactoryUtil.getMappingSqlQuery(getDataSource(),
12028 "SELECT COUNT(*) AS COUNT_VALUE FROM AssetEntries_AssetCategories WHERE categoryId = ? AND entryId = ?",
12029 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT },
12030 RowMapper.COUNT);
12031 }
12032
12033 protected boolean contains(long categoryId, long entryId) {
12034 List<Integer> results = _mappingSqlQuery.execute(new Object[] {
12035 new Long(categoryId), new Long(entryId)
12036 });
12037
12038 if (results.size() > 0) {
12039 Integer count = results.get(0);
12040
12041 if (count.intValue() > 0) {
12042 return true;
12043 }
12044 }
12045
12046 return false;
12047 }
12048
12049 private MappingSqlQuery<Integer> _mappingSqlQuery;
12050 }
12051
12052 protected class AddAssetEntry {
12053 protected AddAssetEntry() {
12054 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
12055 "INSERT INTO AssetEntries_AssetCategories (categoryId, entryId) VALUES (?, ?)",
12056 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
12057 }
12058
12059 protected void add(long categoryId, long entryId)
12060 throws SystemException {
12061 if (!containsAssetEntry.contains(categoryId, entryId)) {
12062 ModelListener<com.liferay.portlet.asset.model.AssetEntry>[] assetEntryListeners =
12063 assetEntryPersistence.getListeners();
12064
12065 for (ModelListener<AssetCategory> listener : listeners) {
12066 listener.onBeforeAddAssociation(categoryId,
12067 com.liferay.portlet.asset.model.AssetEntry.class.getName(),
12068 entryId);
12069 }
12070
12071 for (ModelListener<com.liferay.portlet.asset.model.AssetEntry> listener : assetEntryListeners) {
12072 listener.onBeforeAddAssociation(entryId,
12073 AssetCategory.class.getName(), categoryId);
12074 }
12075
12076 _sqlUpdate.update(new Object[] {
12077 new Long(categoryId), new Long(entryId)
12078 });
12079
12080 for (ModelListener<AssetCategory> listener : listeners) {
12081 listener.onAfterAddAssociation(categoryId,
12082 com.liferay.portlet.asset.model.AssetEntry.class.getName(),
12083 entryId);
12084 }
12085
12086 for (ModelListener<com.liferay.portlet.asset.model.AssetEntry> listener : assetEntryListeners) {
12087 listener.onAfterAddAssociation(entryId,
12088 AssetCategory.class.getName(), categoryId);
12089 }
12090 }
12091 }
12092
12093 private SqlUpdate _sqlUpdate;
12094 }
12095
12096 protected class ClearAssetEntries {
12097 protected ClearAssetEntries() {
12098 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
12099 "DELETE FROM AssetEntries_AssetCategories WHERE categoryId = ?",
12100 new int[] { java.sql.Types.BIGINT });
12101 }
12102
12103 protected void clear(long categoryId) throws SystemException {
12104 ModelListener<com.liferay.portlet.asset.model.AssetEntry>[] assetEntryListeners =
12105 assetEntryPersistence.getListeners();
12106
12107 List<com.liferay.portlet.asset.model.AssetEntry> assetEntries = null;
12108
12109 if ((listeners.length > 0) || (assetEntryListeners.length > 0)) {
12110 assetEntries = getAssetEntries(categoryId);
12111
12112 for (com.liferay.portlet.asset.model.AssetEntry assetEntry : assetEntries) {
12113 for (ModelListener<AssetCategory> listener : listeners) {
12114 listener.onBeforeRemoveAssociation(categoryId,
12115 com.liferay.portlet.asset.model.AssetEntry.class.getName(),
12116 assetEntry.getPrimaryKey());
12117 }
12118
12119 for (ModelListener<com.liferay.portlet.asset.model.AssetEntry> listener : assetEntryListeners) {
12120 listener.onBeforeRemoveAssociation(assetEntry.getPrimaryKey(),
12121 AssetCategory.class.getName(), categoryId);
12122 }
12123 }
12124 }
12125
12126 _sqlUpdate.update(new Object[] { new Long(categoryId) });
12127
12128 if ((listeners.length > 0) || (assetEntryListeners.length > 0)) {
12129 for (com.liferay.portlet.asset.model.AssetEntry assetEntry : assetEntries) {
12130 for (ModelListener<AssetCategory> listener : listeners) {
12131 listener.onAfterRemoveAssociation(categoryId,
12132 com.liferay.portlet.asset.model.AssetEntry.class.getName(),
12133 assetEntry.getPrimaryKey());
12134 }
12135
12136 for (ModelListener<com.liferay.portlet.asset.model.AssetEntry> listener : assetEntryListeners) {
12137 listener.onAfterRemoveAssociation(assetEntry.getPrimaryKey(),
12138 AssetCategory.class.getName(), categoryId);
12139 }
12140 }
12141 }
12142 }
12143
12144 private SqlUpdate _sqlUpdate;
12145 }
12146
12147 protected class RemoveAssetEntry {
12148 protected RemoveAssetEntry() {
12149 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
12150 "DELETE FROM AssetEntries_AssetCategories WHERE categoryId = ? AND entryId = ?",
12151 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
12152 }
12153
12154 protected void remove(long categoryId, long entryId)
12155 throws SystemException {
12156 if (containsAssetEntry.contains(categoryId, entryId)) {
12157 ModelListener<com.liferay.portlet.asset.model.AssetEntry>[] assetEntryListeners =
12158 assetEntryPersistence.getListeners();
12159
12160 for (ModelListener<AssetCategory> listener : listeners) {
12161 listener.onBeforeRemoveAssociation(categoryId,
12162 com.liferay.portlet.asset.model.AssetEntry.class.getName(),
12163 entryId);
12164 }
12165
12166 for (ModelListener<com.liferay.portlet.asset.model.AssetEntry> listener : assetEntryListeners) {
12167 listener.onBeforeRemoveAssociation(entryId,
12168 AssetCategory.class.getName(), categoryId);
12169 }
12170
12171 _sqlUpdate.update(new Object[] {
12172 new Long(categoryId), new Long(entryId)
12173 });
12174
12175 for (ModelListener<AssetCategory> listener : listeners) {
12176 listener.onAfterRemoveAssociation(categoryId,
12177 com.liferay.portlet.asset.model.AssetEntry.class.getName(),
12178 entryId);
12179 }
12180
12181 for (ModelListener<com.liferay.portlet.asset.model.AssetEntry> listener : assetEntryListeners) {
12182 listener.onAfterRemoveAssociation(entryId,
12183 AssetCategory.class.getName(), categoryId);
12184 }
12185 }
12186 }
12187
12188 private SqlUpdate _sqlUpdate;
12189 }
12190
12191 protected boolean rebuildTreeEnabled = true;
12192 protected ExpandTreeLeftCategoryId expandTreeLeftCategoryId;
12193 protected ExpandTreeRightCategoryId expandTreeRightCategoryId;
12194 protected ShrinkTreeLeftCategoryId shrinkTreeLeftCategoryId;
12195 protected ShrinkTreeRightCategoryId shrinkTreeRightCategoryId;
12196 protected UpdateTree updateTree;
12197
12198 protected class ExpandTreeLeftCategoryId {
12199 protected ExpandTreeLeftCategoryId() {
12200 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
12201 "UPDATE AssetCategory SET leftCategoryId = (leftCategoryId + 2) WHERE (groupId = ?) AND (leftCategoryId > ?)",
12202 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
12203 }
12204
12205 protected void expand(long groupId, long leftCategoryId) {
12206 _sqlUpdate.update(new Object[] { groupId, leftCategoryId });
12207 }
12208
12209 private SqlUpdate _sqlUpdate;
12210 }
12211
12212 protected class ExpandTreeRightCategoryId {
12213 protected ExpandTreeRightCategoryId() {
12214 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
12215 "UPDATE AssetCategory SET rightCategoryId = (rightCategoryId + 2) WHERE (groupId = ?) AND (rightCategoryId > ?)",
12216 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
12217 }
12218
12219 protected void expand(long groupId, long rightCategoryId) {
12220 _sqlUpdate.update(new Object[] { groupId, rightCategoryId });
12221 }
12222
12223 private SqlUpdate _sqlUpdate;
12224 }
12225
12226 protected class ShrinkTreeLeftCategoryId {
12227 protected ShrinkTreeLeftCategoryId() {
12228 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
12229 "UPDATE AssetCategory SET leftCategoryId = (leftCategoryId - ?) WHERE (groupId = ?) AND (leftCategoryId > ?)",
12230 new int[] {
12231 java.sql.Types.BIGINT, java.sql.Types.BIGINT,
12232 java.sql.Types.BIGINT
12233 });
12234 }
12235
12236 protected void shrink(long groupId, long rightCategoryId, long delta) {
12237 _sqlUpdate.update(new Object[] { delta, groupId, rightCategoryId });
12238 }
12239
12240 private SqlUpdate _sqlUpdate;
12241 }
12242
12243 protected class ShrinkTreeRightCategoryId {
12244 protected ShrinkTreeRightCategoryId() {
12245 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
12246 "UPDATE AssetCategory SET rightCategoryId = (rightCategoryId - ?) WHERE (groupId = ?) AND (rightCategoryId > ?)",
12247 new int[] {
12248 java.sql.Types.BIGINT, java.sql.Types.BIGINT,
12249 java.sql.Types.BIGINT
12250 });
12251 }
12252
12253 protected void shrink(long groupId, long rightCategoryId, long delta) {
12254 _sqlUpdate.update(new Object[] { delta, groupId, rightCategoryId });
12255 }
12256
12257 private SqlUpdate _sqlUpdate;
12258 }
12259
12260 protected class UpdateTree {
12261 protected UpdateTree() {
12262 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
12263 "UPDATE AssetCategory SET leftCategoryId = ?, rightCategoryId = ? WHERE categoryId = ?",
12264 new int[] {
12265 java.sql.Types.BIGINT, java.sql.Types.BIGINT,
12266 java.sql.Types.BIGINT
12267 });
12268 }
12269
12270 protected void update(long categoryId, long leftCategoryId,
12271 long rightCategoryId) {
12272 _sqlUpdate.update(new Object[] {
12273 leftCategoryId, rightCategoryId, categoryId
12274 });
12275 }
12276
12277 private SqlUpdate _sqlUpdate;
12278 }
12279
12280 private static final String _SQL_SELECT_ASSETCATEGORY = "SELECT assetCategory FROM AssetCategory assetCategory";
12281 private static final String _SQL_SELECT_ASSETCATEGORY_WHERE = "SELECT assetCategory FROM AssetCategory assetCategory WHERE ";
12282 private static final String _SQL_COUNT_ASSETCATEGORY = "SELECT COUNT(assetCategory) FROM AssetCategory assetCategory";
12283 private static final String _SQL_COUNT_ASSETCATEGORY_WHERE = "SELECT COUNT(assetCategory) FROM AssetCategory assetCategory WHERE ";
12284 private static final String _SQL_GETASSETENTRIES = "SELECT {AssetEntry.*} FROM AssetEntry INNER JOIN AssetEntries_AssetCategories ON (AssetEntries_AssetCategories.entryId = AssetEntry.entryId) WHERE (AssetEntries_AssetCategories.categoryId = ?)";
12285 private static final String _SQL_GETASSETENTRIESSIZE = "SELECT COUNT(*) AS COUNT_VALUE FROM AssetEntries_AssetCategories WHERE categoryId = ?";
12286 private static final String _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN = "assetCategory.categoryId";
12287 private static final String _FILTER_SQL_SELECT_ASSETCATEGORY_WHERE = "SELECT DISTINCT {assetCategory.*} FROM AssetCategory assetCategory WHERE ";
12288 private static final String _FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_1 =
12289 "SELECT {AssetCategory.*} FROM (SELECT DISTINCT assetCategory.categoryId FROM AssetCategory assetCategory WHERE ";
12290 private static final String _FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_2 =
12291 ") TEMP_TABLE INNER JOIN AssetCategory ON TEMP_TABLE.categoryId = AssetCategory.categoryId";
12292 private static final String _FILTER_SQL_COUNT_ASSETCATEGORY_WHERE = "SELECT COUNT(DISTINCT assetCategory.categoryId) AS COUNT_VALUE FROM AssetCategory assetCategory WHERE ";
12293 private static final String _FILTER_ENTITY_ALIAS = "assetCategory";
12294 private static final String _FILTER_ENTITY_TABLE = "AssetCategory";
12295 private static final String _ORDER_BY_ENTITY_ALIAS = "assetCategory.";
12296 private static final String _ORDER_BY_ENTITY_TABLE = "AssetCategory.";
12297 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No AssetCategory exists with the primary key ";
12298 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No AssetCategory exists with the key {";
12299 private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
12300 private static Log _log = LogFactoryUtil.getLog(AssetCategoryPersistenceImpl.class);
12301 private static Set<String> _badColumnNames = SetUtil.fromArray(new String[] {
12302 "uuid"
12303 });
12304 private static AssetCategory _nullAssetCategory = new AssetCategoryImpl() {
12305 @Override
12306 public Object clone() {
12307 return this;
12308 }
12309
12310 @Override
12311 public CacheModel<AssetCategory> toCacheModel() {
12312 return _nullAssetCategoryCacheModel;
12313 }
12314 };
12315
12316 private static CacheModel<AssetCategory> _nullAssetCategoryCacheModel = new CacheModel<AssetCategory>() {
12317 public AssetCategory toEntityModel() {
12318 return _nullAssetCategory;
12319 }
12320 };
12321 }