001
014
015 package com.liferay.portlet.asset.service.persistence;
016
017 import com.liferay.portal.NoSuchModelException;
018 import com.liferay.portal.kernel.annotation.BeanReference;
019 import com.liferay.portal.kernel.cache.CacheRegistryUtil;
020 import com.liferay.portal.kernel.dao.jdbc.MappingSqlQuery;
021 import com.liferay.portal.kernel.dao.jdbc.MappingSqlQueryFactoryUtil;
022 import com.liferay.portal.kernel.dao.jdbc.RowMapper;
023 import com.liferay.portal.kernel.dao.jdbc.SqlUpdate;
024 import com.liferay.portal.kernel.dao.jdbc.SqlUpdateFactoryUtil;
025 import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
026 import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
027 import com.liferay.portal.kernel.dao.orm.FinderPath;
028 import com.liferay.portal.kernel.dao.orm.Query;
029 import com.liferay.portal.kernel.dao.orm.QueryPos;
030 import com.liferay.portal.kernel.dao.orm.QueryUtil;
031 import com.liferay.portal.kernel.dao.orm.SQLQuery;
032 import com.liferay.portal.kernel.dao.orm.Session;
033 import com.liferay.portal.kernel.exception.SystemException;
034 import com.liferay.portal.kernel.log.Log;
035 import com.liferay.portal.kernel.log.LogFactoryUtil;
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.Validator;
044 import com.liferay.portal.kernel.uuid.PortalUUIDUtil;
045 import com.liferay.portal.model.ModelListener;
046 import com.liferay.portal.security.permission.InlineSQLHelperUtil;
047 import com.liferay.portal.service.persistence.BatchSessionUtil;
048 import com.liferay.portal.service.persistence.ResourcePersistence;
049 import com.liferay.portal.service.persistence.UserPersistence;
050 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
051
052 import com.liferay.portlet.asset.NoSuchCategoryException;
053 import com.liferay.portlet.asset.model.AssetCategory;
054 import com.liferay.portlet.asset.model.impl.AssetCategoryImpl;
055 import com.liferay.portlet.asset.model.impl.AssetCategoryModelImpl;
056
057 import java.io.Serializable;
058
059 import java.util.ArrayList;
060 import java.util.Collections;
061 import java.util.List;
062 import java.util.Set;
063
064
080 public class AssetCategoryPersistenceImpl extends BasePersistenceImpl<AssetCategory>
081 implements AssetCategoryPersistence {
082 public static final String FINDER_CLASS_NAME_ENTITY = AssetCategoryImpl.class.getName();
083 public static final String FINDER_CLASS_NAME_LIST = FINDER_CLASS_NAME_ENTITY +
084 ".List";
085 public static final FinderPath FINDER_PATH_FIND_BY_UUID = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
086 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
087 FINDER_CLASS_NAME_LIST, "findByUuid",
088 new String[] {
089 String.class.getName(),
090
091 "java.lang.Integer", "java.lang.Integer",
092 "com.liferay.portal.kernel.util.OrderByComparator"
093 });
094 public static final FinderPath FINDER_PATH_COUNT_BY_UUID = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
095 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
096 FINDER_CLASS_NAME_LIST, "countByUuid",
097 new String[] { String.class.getName() });
098 public static final FinderPath FINDER_PATH_FETCH_BY_UUID_G = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
099 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
100 FINDER_CLASS_NAME_ENTITY, "fetchByUUID_G",
101 new String[] { String.class.getName(), Long.class.getName() });
102 public static final FinderPath FINDER_PATH_COUNT_BY_UUID_G = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
103 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
104 FINDER_CLASS_NAME_LIST, "countByUUID_G",
105 new String[] { String.class.getName(), Long.class.getName() });
106 public static final FinderPath FINDER_PATH_FIND_BY_GROUPID = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
107 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
108 FINDER_CLASS_NAME_LIST, "findByGroupId",
109 new String[] {
110 Long.class.getName(),
111
112 "java.lang.Integer", "java.lang.Integer",
113 "com.liferay.portal.kernel.util.OrderByComparator"
114 });
115 public static final FinderPath FINDER_PATH_COUNT_BY_GROUPID = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
116 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
117 FINDER_CLASS_NAME_LIST, "countByGroupId",
118 new String[] { Long.class.getName() });
119 public static final FinderPath FINDER_PATH_FIND_BY_PARENTCATEGORYID = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
120 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
121 FINDER_CLASS_NAME_LIST, "findByParentCategoryId",
122 new String[] {
123 Long.class.getName(),
124
125 "java.lang.Integer", "java.lang.Integer",
126 "com.liferay.portal.kernel.util.OrderByComparator"
127 });
128 public static final FinderPath FINDER_PATH_COUNT_BY_PARENTCATEGORYID = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
129 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
130 FINDER_CLASS_NAME_LIST, "countByParentCategoryId",
131 new String[] { Long.class.getName() });
132 public static final FinderPath FINDER_PATH_FIND_BY_VOCABULARYID = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
133 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
134 FINDER_CLASS_NAME_LIST, "findByVocabularyId",
135 new String[] {
136 Long.class.getName(),
137
138 "java.lang.Integer", "java.lang.Integer",
139 "com.liferay.portal.kernel.util.OrderByComparator"
140 });
141 public static final FinderPath FINDER_PATH_COUNT_BY_VOCABULARYID = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
142 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
143 FINDER_CLASS_NAME_LIST, "countByVocabularyId",
144 new String[] { Long.class.getName() });
145 public static final FinderPath FINDER_PATH_FIND_BY_P_N = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
146 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
147 FINDER_CLASS_NAME_LIST, "findByP_N",
148 new String[] {
149 Long.class.getName(), String.class.getName(),
150
151 "java.lang.Integer", "java.lang.Integer",
152 "com.liferay.portal.kernel.util.OrderByComparator"
153 });
154 public static final FinderPath FINDER_PATH_COUNT_BY_P_N = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
155 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
156 FINDER_CLASS_NAME_LIST, "countByP_N",
157 new String[] { Long.class.getName(), String.class.getName() });
158 public static final FinderPath FINDER_PATH_FIND_BY_P_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
159 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
160 FINDER_CLASS_NAME_LIST, "findByP_V",
161 new String[] {
162 Long.class.getName(), Long.class.getName(),
163
164 "java.lang.Integer", "java.lang.Integer",
165 "com.liferay.portal.kernel.util.OrderByComparator"
166 });
167 public static final FinderPath FINDER_PATH_COUNT_BY_P_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
168 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
169 FINDER_CLASS_NAME_LIST, "countByP_V",
170 new String[] { Long.class.getName(), Long.class.getName() });
171 public static final FinderPath FINDER_PATH_FIND_BY_N_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
172 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
173 FINDER_CLASS_NAME_LIST, "findByN_V",
174 new String[] {
175 String.class.getName(), Long.class.getName(),
176
177 "java.lang.Integer", "java.lang.Integer",
178 "com.liferay.portal.kernel.util.OrderByComparator"
179 });
180 public static final FinderPath FINDER_PATH_COUNT_BY_N_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
181 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
182 FINDER_CLASS_NAME_LIST, "countByN_V",
183 new String[] { String.class.getName(), Long.class.getName() });
184 public static final FinderPath FINDER_PATH_FETCH_BY_P_N_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
185 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
186 FINDER_CLASS_NAME_ENTITY, "fetchByP_N_V",
187 new String[] {
188 Long.class.getName(), String.class.getName(),
189 Long.class.getName()
190 });
191 public static final FinderPath FINDER_PATH_COUNT_BY_P_N_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
192 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
193 FINDER_CLASS_NAME_LIST, "countByP_N_V",
194 new String[] {
195 Long.class.getName(), String.class.getName(),
196 Long.class.getName()
197 });
198 public static final FinderPath FINDER_PATH_FIND_ALL = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
199 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
200 FINDER_CLASS_NAME_LIST, "findAll", new String[0]);
201 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
202 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
203 FINDER_CLASS_NAME_LIST, "countAll", new String[0]);
204
205
210 public void cacheResult(AssetCategory assetCategory) {
211 EntityCacheUtil.putResult(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
212 AssetCategoryImpl.class, assetCategory.getPrimaryKey(),
213 assetCategory);
214
215 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
216 new Object[] {
217 assetCategory.getUuid(), new Long(assetCategory.getGroupId())
218 }, assetCategory);
219
220 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_P_N_V,
221 new Object[] {
222 new Long(assetCategory.getParentCategoryId()),
223
224 assetCategory.getName(), new Long(assetCategory.getVocabularyId())
225 }, assetCategory);
226 }
227
228
233 public void cacheResult(List<AssetCategory> assetCategories) {
234 for (AssetCategory assetCategory : assetCategories) {
235 if (EntityCacheUtil.getResult(
236 AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
237 AssetCategoryImpl.class, assetCategory.getPrimaryKey(),
238 this) == null) {
239 cacheResult(assetCategory);
240 }
241 }
242 }
243
244
251 public void clearCache() {
252 CacheRegistryUtil.clear(AssetCategoryImpl.class.getName());
253 EntityCacheUtil.clearCache(AssetCategoryImpl.class.getName());
254 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
255 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
256 }
257
258
265 public void clearCache(AssetCategory assetCategory) {
266 EntityCacheUtil.removeResult(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
267 AssetCategoryImpl.class, assetCategory.getPrimaryKey());
268
269 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
270 new Object[] {
271 assetCategory.getUuid(), new Long(assetCategory.getGroupId())
272 });
273
274 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_P_N_V,
275 new Object[] {
276 new Long(assetCategory.getParentCategoryId()),
277
278 assetCategory.getName(), new Long(assetCategory.getVocabularyId())
279 });
280 }
281
282
288 public AssetCategory create(long categoryId) {
289 AssetCategory assetCategory = new AssetCategoryImpl();
290
291 assetCategory.setNew(true);
292 assetCategory.setPrimaryKey(categoryId);
293
294 String uuid = PortalUUIDUtil.generate();
295
296 assetCategory.setUuid(uuid);
297
298 return assetCategory;
299 }
300
301
309 public AssetCategory remove(Serializable primaryKey)
310 throws NoSuchModelException, SystemException {
311 return remove(((Long)primaryKey).longValue());
312 }
313
314
322 public AssetCategory remove(long categoryId)
323 throws NoSuchCategoryException, SystemException {
324 Session session = null;
325
326 try {
327 session = openSession();
328
329 AssetCategory assetCategory = (AssetCategory)session.get(AssetCategoryImpl.class,
330 new Long(categoryId));
331
332 if (assetCategory == null) {
333 if (_log.isWarnEnabled()) {
334 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + categoryId);
335 }
336
337 throw new NoSuchCategoryException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
338 categoryId);
339 }
340
341 return remove(assetCategory);
342 }
343 catch (NoSuchCategoryException nsee) {
344 throw nsee;
345 }
346 catch (Exception e) {
347 throw processException(e);
348 }
349 finally {
350 closeSession(session);
351 }
352 }
353
354 protected AssetCategory removeImpl(AssetCategory assetCategory)
355 throws SystemException {
356 assetCategory = toUnwrappedModel(assetCategory);
357
358 try {
359 clearAssetEntries.clear(assetCategory.getPrimaryKey());
360 }
361 catch (Exception e) {
362 throw processException(e);
363 }
364 finally {
365 FinderCacheUtil.clearCache(AssetCategoryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
366 }
367
368 shrinkTree(assetCategory);
369
370 Session session = null;
371
372 try {
373 session = openSession();
374
375 BatchSessionUtil.delete(session, assetCategory);
376 }
377 catch (Exception e) {
378 throw processException(e);
379 }
380 finally {
381 closeSession(session);
382 }
383
384 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
385
386 AssetCategoryModelImpl assetCategoryModelImpl = (AssetCategoryModelImpl)assetCategory;
387
388 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
389 new Object[] {
390 assetCategoryModelImpl.getUuid(),
391 new Long(assetCategoryModelImpl.getGroupId())
392 });
393
394 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_P_N_V,
395 new Object[] {
396 new Long(assetCategoryModelImpl.getParentCategoryId()),
397
398 assetCategoryModelImpl.getName(),
399 new Long(assetCategoryModelImpl.getVocabularyId())
400 });
401
402 EntityCacheUtil.removeResult(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
403 AssetCategoryImpl.class, assetCategory.getPrimaryKey());
404
405 return assetCategory;
406 }
407
408 public AssetCategory updateImpl(
409 com.liferay.portlet.asset.model.AssetCategory assetCategory,
410 boolean merge) throws SystemException {
411 assetCategory = toUnwrappedModel(assetCategory);
412
413 boolean isNew = assetCategory.isNew();
414
415 AssetCategoryModelImpl assetCategoryModelImpl = (AssetCategoryModelImpl)assetCategory;
416
417 if (Validator.isNull(assetCategory.getUuid())) {
418 String uuid = PortalUUIDUtil.generate();
419
420 assetCategory.setUuid(uuid);
421 }
422
423 if (isNew) {
424 expandTree(assetCategory);
425 }
426 else {
427 if (assetCategory.getParentCategoryId() != assetCategoryModelImpl.getOriginalParentCategoryId()) {
428 shrinkTree(assetCategory);
429 expandTree(assetCategory);
430 }
431 }
432
433 Session session = null;
434
435 try {
436 session = openSession();
437
438 BatchSessionUtil.update(session, assetCategory, merge);
439
440 assetCategory.setNew(false);
441 }
442 catch (Exception e) {
443 throw processException(e);
444 }
445 finally {
446 closeSession(session);
447 }
448
449 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
450
451 EntityCacheUtil.putResult(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
452 AssetCategoryImpl.class, assetCategory.getPrimaryKey(),
453 assetCategory);
454
455 if (!isNew &&
456 (!Validator.equals(assetCategory.getUuid(),
457 assetCategoryModelImpl.getOriginalUuid()) ||
458 (assetCategory.getGroupId() != assetCategoryModelImpl.getOriginalGroupId()))) {
459 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
460 new Object[] {
461 assetCategoryModelImpl.getOriginalUuid(),
462 new Long(assetCategoryModelImpl.getOriginalGroupId())
463 });
464 }
465
466 if (isNew ||
467 (!Validator.equals(assetCategory.getUuid(),
468 assetCategoryModelImpl.getOriginalUuid()) ||
469 (assetCategory.getGroupId() != assetCategoryModelImpl.getOriginalGroupId()))) {
470 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
471 new Object[] {
472 assetCategory.getUuid(),
473 new Long(assetCategory.getGroupId())
474 }, assetCategory);
475 }
476
477 if (!isNew &&
478 ((assetCategory.getParentCategoryId() != assetCategoryModelImpl.getOriginalParentCategoryId()) ||
479 !Validator.equals(assetCategory.getName(),
480 assetCategoryModelImpl.getOriginalName()) ||
481 (assetCategory.getVocabularyId() != assetCategoryModelImpl.getOriginalVocabularyId()))) {
482 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_P_N_V,
483 new Object[] {
484 new Long(assetCategoryModelImpl.getOriginalParentCategoryId()),
485
486 assetCategoryModelImpl.getOriginalName(),
487 new Long(assetCategoryModelImpl.getOriginalVocabularyId())
488 });
489 }
490
491 if (isNew ||
492 ((assetCategory.getParentCategoryId() != assetCategoryModelImpl.getOriginalParentCategoryId()) ||
493 !Validator.equals(assetCategory.getName(),
494 assetCategoryModelImpl.getOriginalName()) ||
495 (assetCategory.getVocabularyId() != assetCategoryModelImpl.getOriginalVocabularyId()))) {
496 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_P_N_V,
497 new Object[] {
498 new Long(assetCategory.getParentCategoryId()),
499
500 assetCategory.getName(),
501 new Long(assetCategory.getVocabularyId())
502 }, assetCategory);
503 }
504
505 return assetCategory;
506 }
507
508 protected AssetCategory toUnwrappedModel(AssetCategory assetCategory) {
509 if (assetCategory instanceof AssetCategoryImpl) {
510 return assetCategory;
511 }
512
513 AssetCategoryImpl assetCategoryImpl = new AssetCategoryImpl();
514
515 assetCategoryImpl.setNew(assetCategory.isNew());
516 assetCategoryImpl.setPrimaryKey(assetCategory.getPrimaryKey());
517
518 assetCategoryImpl.setUuid(assetCategory.getUuid());
519 assetCategoryImpl.setCategoryId(assetCategory.getCategoryId());
520 assetCategoryImpl.setGroupId(assetCategory.getGroupId());
521 assetCategoryImpl.setCompanyId(assetCategory.getCompanyId());
522 assetCategoryImpl.setUserId(assetCategory.getUserId());
523 assetCategoryImpl.setUserName(assetCategory.getUserName());
524 assetCategoryImpl.setCreateDate(assetCategory.getCreateDate());
525 assetCategoryImpl.setModifiedDate(assetCategory.getModifiedDate());
526 assetCategoryImpl.setParentCategoryId(assetCategory.getParentCategoryId());
527 assetCategoryImpl.setLeftCategoryId(assetCategory.getLeftCategoryId());
528 assetCategoryImpl.setRightCategoryId(assetCategory.getRightCategoryId());
529 assetCategoryImpl.setName(assetCategory.getName());
530 assetCategoryImpl.setTitle(assetCategory.getTitle());
531 assetCategoryImpl.setVocabularyId(assetCategory.getVocabularyId());
532
533 return assetCategoryImpl;
534 }
535
536
544 public AssetCategory findByPrimaryKey(Serializable primaryKey)
545 throws NoSuchModelException, SystemException {
546 return findByPrimaryKey(((Long)primaryKey).longValue());
547 }
548
549
557 public AssetCategory findByPrimaryKey(long categoryId)
558 throws NoSuchCategoryException, SystemException {
559 AssetCategory assetCategory = fetchByPrimaryKey(categoryId);
560
561 if (assetCategory == null) {
562 if (_log.isWarnEnabled()) {
563 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + categoryId);
564 }
565
566 throw new NoSuchCategoryException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
567 categoryId);
568 }
569
570 return assetCategory;
571 }
572
573
580 public AssetCategory fetchByPrimaryKey(Serializable primaryKey)
581 throws SystemException {
582 return fetchByPrimaryKey(((Long)primaryKey).longValue());
583 }
584
585
592 public AssetCategory fetchByPrimaryKey(long categoryId)
593 throws SystemException {
594 AssetCategory assetCategory = (AssetCategory)EntityCacheUtil.getResult(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
595 AssetCategoryImpl.class, categoryId, this);
596
597 if (assetCategory == null) {
598 Session session = null;
599
600 try {
601 session = openSession();
602
603 assetCategory = (AssetCategory)session.get(AssetCategoryImpl.class,
604 new Long(categoryId));
605 }
606 catch (Exception e) {
607 throw processException(e);
608 }
609 finally {
610 if (assetCategory != null) {
611 cacheResult(assetCategory);
612 }
613
614 closeSession(session);
615 }
616 }
617
618 return assetCategory;
619 }
620
621
628 public List<AssetCategory> findByUuid(String uuid)
629 throws SystemException {
630 return findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
631 }
632
633
646 public List<AssetCategory> findByUuid(String uuid, int start, int end)
647 throws SystemException {
648 return findByUuid(uuid, start, end, null);
649 }
650
651
665 public List<AssetCategory> findByUuid(String uuid, int start, int end,
666 OrderByComparator orderByComparator) throws SystemException {
667 Object[] finderArgs = new Object[] {
668 uuid,
669
670 String.valueOf(start), String.valueOf(end),
671 String.valueOf(orderByComparator)
672 };
673
674 List<AssetCategory> list = (List<AssetCategory>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_UUID,
675 finderArgs, this);
676
677 if (list == null) {
678 StringBundler query = null;
679
680 if (orderByComparator != null) {
681 query = new StringBundler(3 +
682 (orderByComparator.getOrderByFields().length * 3));
683 }
684 else {
685 query = new StringBundler(3);
686 }
687
688 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
689
690 if (uuid == null) {
691 query.append(_FINDER_COLUMN_UUID_UUID_1);
692 }
693 else {
694 if (uuid.equals(StringPool.BLANK)) {
695 query.append(_FINDER_COLUMN_UUID_UUID_3);
696 }
697 else {
698 query.append(_FINDER_COLUMN_UUID_UUID_2);
699 }
700 }
701
702 if (orderByComparator != null) {
703 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
704 orderByComparator);
705 }
706
707 else {
708 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
709 }
710
711 String sql = query.toString();
712
713 Session session = null;
714
715 try {
716 session = openSession();
717
718 Query q = session.createQuery(sql);
719
720 QueryPos qPos = QueryPos.getInstance(q);
721
722 if (uuid != null) {
723 qPos.add(uuid);
724 }
725
726 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
727 start, end);
728 }
729 catch (Exception e) {
730 throw processException(e);
731 }
732 finally {
733 if (list == null) {
734 FinderCacheUtil.removeResult(FINDER_PATH_FIND_BY_UUID,
735 finderArgs);
736 }
737 else {
738 cacheResult(list);
739
740 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_UUID,
741 finderArgs, list);
742 }
743
744 closeSession(session);
745 }
746 }
747
748 return list;
749 }
750
751
764 public AssetCategory findByUuid_First(String uuid,
765 OrderByComparator orderByComparator)
766 throws NoSuchCategoryException, SystemException {
767 List<AssetCategory> list = findByUuid(uuid, 0, 1, orderByComparator);
768
769 if (list.isEmpty()) {
770 StringBundler msg = new StringBundler(4);
771
772 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
773
774 msg.append("uuid=");
775 msg.append(uuid);
776
777 msg.append(StringPool.CLOSE_CURLY_BRACE);
778
779 throw new NoSuchCategoryException(msg.toString());
780 }
781 else {
782 return list.get(0);
783 }
784 }
785
786
799 public AssetCategory findByUuid_Last(String uuid,
800 OrderByComparator orderByComparator)
801 throws NoSuchCategoryException, SystemException {
802 int count = countByUuid(uuid);
803
804 List<AssetCategory> list = findByUuid(uuid, count - 1, count,
805 orderByComparator);
806
807 if (list.isEmpty()) {
808 StringBundler msg = new StringBundler(4);
809
810 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
811
812 msg.append("uuid=");
813 msg.append(uuid);
814
815 msg.append(StringPool.CLOSE_CURLY_BRACE);
816
817 throw new NoSuchCategoryException(msg.toString());
818 }
819 else {
820 return list.get(0);
821 }
822 }
823
824
838 public AssetCategory[] findByUuid_PrevAndNext(long categoryId, String uuid,
839 OrderByComparator orderByComparator)
840 throws NoSuchCategoryException, SystemException {
841 AssetCategory assetCategory = findByPrimaryKey(categoryId);
842
843 Session session = null;
844
845 try {
846 session = openSession();
847
848 AssetCategory[] array = new AssetCategoryImpl[3];
849
850 array[0] = getByUuid_PrevAndNext(session, assetCategory, uuid,
851 orderByComparator, true);
852
853 array[1] = assetCategory;
854
855 array[2] = getByUuid_PrevAndNext(session, assetCategory, uuid,
856 orderByComparator, false);
857
858 return array;
859 }
860 catch (Exception e) {
861 throw processException(e);
862 }
863 finally {
864 closeSession(session);
865 }
866 }
867
868 protected AssetCategory getByUuid_PrevAndNext(Session session,
869 AssetCategory assetCategory, String uuid,
870 OrderByComparator orderByComparator, boolean previous) {
871 StringBundler query = null;
872
873 if (orderByComparator != null) {
874 query = new StringBundler(6 +
875 (orderByComparator.getOrderByFields().length * 6));
876 }
877 else {
878 query = new StringBundler(3);
879 }
880
881 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
882
883 if (uuid == null) {
884 query.append(_FINDER_COLUMN_UUID_UUID_1);
885 }
886 else {
887 if (uuid.equals(StringPool.BLANK)) {
888 query.append(_FINDER_COLUMN_UUID_UUID_3);
889 }
890 else {
891 query.append(_FINDER_COLUMN_UUID_UUID_2);
892 }
893 }
894
895 if (orderByComparator != null) {
896 String[] orderByFields = orderByComparator.getOrderByFields();
897
898 if (orderByFields.length > 0) {
899 query.append(WHERE_AND);
900 }
901
902 for (int i = 0; i < orderByFields.length; i++) {
903 query.append(_ORDER_BY_ENTITY_ALIAS);
904 query.append(orderByFields[i]);
905
906 if ((i + 1) < orderByFields.length) {
907 if (orderByComparator.isAscending() ^ previous) {
908 query.append(WHERE_GREATER_THAN_HAS_NEXT);
909 }
910 else {
911 query.append(WHERE_LESSER_THAN_HAS_NEXT);
912 }
913 }
914 else {
915 if (orderByComparator.isAscending() ^ previous) {
916 query.append(WHERE_GREATER_THAN);
917 }
918 else {
919 query.append(WHERE_LESSER_THAN);
920 }
921 }
922 }
923
924 query.append(ORDER_BY_CLAUSE);
925
926 for (int i = 0; i < orderByFields.length; i++) {
927 query.append(_ORDER_BY_ENTITY_ALIAS);
928 query.append(orderByFields[i]);
929
930 if ((i + 1) < orderByFields.length) {
931 if (orderByComparator.isAscending() ^ previous) {
932 query.append(ORDER_BY_ASC_HAS_NEXT);
933 }
934 else {
935 query.append(ORDER_BY_DESC_HAS_NEXT);
936 }
937 }
938 else {
939 if (orderByComparator.isAscending() ^ previous) {
940 query.append(ORDER_BY_ASC);
941 }
942 else {
943 query.append(ORDER_BY_DESC);
944 }
945 }
946 }
947 }
948
949 else {
950 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
951 }
952
953 String sql = query.toString();
954
955 Query q = session.createQuery(sql);
956
957 q.setFirstResult(0);
958 q.setMaxResults(2);
959
960 QueryPos qPos = QueryPos.getInstance(q);
961
962 if (uuid != null) {
963 qPos.add(uuid);
964 }
965
966 if (orderByComparator != null) {
967 Object[] values = orderByComparator.getOrderByValues(assetCategory);
968
969 for (Object value : values) {
970 qPos.add(value);
971 }
972 }
973
974 List<AssetCategory> list = q.list();
975
976 if (list.size() == 2) {
977 return list.get(1);
978 }
979 else {
980 return null;
981 }
982 }
983
984
993 public AssetCategory findByUUID_G(String uuid, long groupId)
994 throws NoSuchCategoryException, SystemException {
995 AssetCategory assetCategory = fetchByUUID_G(uuid, groupId);
996
997 if (assetCategory == null) {
998 StringBundler msg = new StringBundler(6);
999
1000 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1001
1002 msg.append("uuid=");
1003 msg.append(uuid);
1004
1005 msg.append(", groupId=");
1006 msg.append(groupId);
1007
1008 msg.append(StringPool.CLOSE_CURLY_BRACE);
1009
1010 if (_log.isWarnEnabled()) {
1011 _log.warn(msg.toString());
1012 }
1013
1014 throw new NoSuchCategoryException(msg.toString());
1015 }
1016
1017 return assetCategory;
1018 }
1019
1020
1028 public AssetCategory fetchByUUID_G(String uuid, long groupId)
1029 throws SystemException {
1030 return fetchByUUID_G(uuid, groupId, true);
1031 }
1032
1033
1041 public AssetCategory fetchByUUID_G(String uuid, long groupId,
1042 boolean retrieveFromCache) throws SystemException {
1043 Object[] finderArgs = new Object[] { uuid, groupId };
1044
1045 Object result = null;
1046
1047 if (retrieveFromCache) {
1048 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_UUID_G,
1049 finderArgs, this);
1050 }
1051
1052 if (result == null) {
1053 StringBundler query = new StringBundler(4);
1054
1055 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
1056
1057 if (uuid == null) {
1058 query.append(_FINDER_COLUMN_UUID_G_UUID_1);
1059 }
1060 else {
1061 if (uuid.equals(StringPool.BLANK)) {
1062 query.append(_FINDER_COLUMN_UUID_G_UUID_3);
1063 }
1064 else {
1065 query.append(_FINDER_COLUMN_UUID_G_UUID_2);
1066 }
1067 }
1068
1069 query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
1070
1071 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
1072
1073 String sql = query.toString();
1074
1075 Session session = null;
1076
1077 try {
1078 session = openSession();
1079
1080 Query q = session.createQuery(sql);
1081
1082 QueryPos qPos = QueryPos.getInstance(q);
1083
1084 if (uuid != null) {
1085 qPos.add(uuid);
1086 }
1087
1088 qPos.add(groupId);
1089
1090 List<AssetCategory> list = q.list();
1091
1092 result = list;
1093
1094 AssetCategory assetCategory = null;
1095
1096 if (list.isEmpty()) {
1097 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
1098 finderArgs, list);
1099 }
1100 else {
1101 assetCategory = list.get(0);
1102
1103 cacheResult(assetCategory);
1104
1105 if ((assetCategory.getUuid() == null) ||
1106 !assetCategory.getUuid().equals(uuid) ||
1107 (assetCategory.getGroupId() != groupId)) {
1108 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
1109 finderArgs, assetCategory);
1110 }
1111 }
1112
1113 return assetCategory;
1114 }
1115 catch (Exception e) {
1116 throw processException(e);
1117 }
1118 finally {
1119 if (result == null) {
1120 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
1121 finderArgs);
1122 }
1123
1124 closeSession(session);
1125 }
1126 }
1127 else {
1128 if (result instanceof List<?>) {
1129 return null;
1130 }
1131 else {
1132 return (AssetCategory)result;
1133 }
1134 }
1135 }
1136
1137
1144 public List<AssetCategory> findByGroupId(long groupId)
1145 throws SystemException {
1146 return findByGroupId(groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1147 }
1148
1149
1162 public List<AssetCategory> findByGroupId(long groupId, int start, int end)
1163 throws SystemException {
1164 return findByGroupId(groupId, start, end, null);
1165 }
1166
1167
1181 public List<AssetCategory> findByGroupId(long groupId, int start, int end,
1182 OrderByComparator orderByComparator) throws SystemException {
1183 Object[] finderArgs = new Object[] {
1184 groupId,
1185
1186 String.valueOf(start), String.valueOf(end),
1187 String.valueOf(orderByComparator)
1188 };
1189
1190 List<AssetCategory> list = (List<AssetCategory>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_GROUPID,
1191 finderArgs, this);
1192
1193 if (list == null) {
1194 StringBundler query = null;
1195
1196 if (orderByComparator != null) {
1197 query = new StringBundler(3 +
1198 (orderByComparator.getOrderByFields().length * 3));
1199 }
1200 else {
1201 query = new StringBundler(3);
1202 }
1203
1204 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
1205
1206 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1207
1208 if (orderByComparator != null) {
1209 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1210 orderByComparator);
1211 }
1212
1213 else {
1214 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
1215 }
1216
1217 String sql = query.toString();
1218
1219 Session session = null;
1220
1221 try {
1222 session = openSession();
1223
1224 Query q = session.createQuery(sql);
1225
1226 QueryPos qPos = QueryPos.getInstance(q);
1227
1228 qPos.add(groupId);
1229
1230 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
1231 start, end);
1232 }
1233 catch (Exception e) {
1234 throw processException(e);
1235 }
1236 finally {
1237 if (list == null) {
1238 FinderCacheUtil.removeResult(FINDER_PATH_FIND_BY_GROUPID,
1239 finderArgs);
1240 }
1241 else {
1242 cacheResult(list);
1243
1244 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_GROUPID,
1245 finderArgs, list);
1246 }
1247
1248 closeSession(session);
1249 }
1250 }
1251
1252 return list;
1253 }
1254
1255
1268 public AssetCategory findByGroupId_First(long groupId,
1269 OrderByComparator orderByComparator)
1270 throws NoSuchCategoryException, SystemException {
1271 List<AssetCategory> list = findByGroupId(groupId, 0, 1,
1272 orderByComparator);
1273
1274 if (list.isEmpty()) {
1275 StringBundler msg = new StringBundler(4);
1276
1277 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1278
1279 msg.append("groupId=");
1280 msg.append(groupId);
1281
1282 msg.append(StringPool.CLOSE_CURLY_BRACE);
1283
1284 throw new NoSuchCategoryException(msg.toString());
1285 }
1286 else {
1287 return list.get(0);
1288 }
1289 }
1290
1291
1304 public AssetCategory findByGroupId_Last(long groupId,
1305 OrderByComparator orderByComparator)
1306 throws NoSuchCategoryException, SystemException {
1307 int count = countByGroupId(groupId);
1308
1309 List<AssetCategory> list = findByGroupId(groupId, count - 1, count,
1310 orderByComparator);
1311
1312 if (list.isEmpty()) {
1313 StringBundler msg = new StringBundler(4);
1314
1315 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1316
1317 msg.append("groupId=");
1318 msg.append(groupId);
1319
1320 msg.append(StringPool.CLOSE_CURLY_BRACE);
1321
1322 throw new NoSuchCategoryException(msg.toString());
1323 }
1324 else {
1325 return list.get(0);
1326 }
1327 }
1328
1329
1343 public AssetCategory[] findByGroupId_PrevAndNext(long categoryId,
1344 long groupId, OrderByComparator orderByComparator)
1345 throws NoSuchCategoryException, SystemException {
1346 AssetCategory assetCategory = findByPrimaryKey(categoryId);
1347
1348 Session session = null;
1349
1350 try {
1351 session = openSession();
1352
1353 AssetCategory[] array = new AssetCategoryImpl[3];
1354
1355 array[0] = getByGroupId_PrevAndNext(session, assetCategory,
1356 groupId, orderByComparator, true);
1357
1358 array[1] = assetCategory;
1359
1360 array[2] = getByGroupId_PrevAndNext(session, assetCategory,
1361 groupId, orderByComparator, false);
1362
1363 return array;
1364 }
1365 catch (Exception e) {
1366 throw processException(e);
1367 }
1368 finally {
1369 closeSession(session);
1370 }
1371 }
1372
1373 protected AssetCategory getByGroupId_PrevAndNext(Session session,
1374 AssetCategory assetCategory, long groupId,
1375 OrderByComparator orderByComparator, boolean previous) {
1376 StringBundler query = null;
1377
1378 if (orderByComparator != null) {
1379 query = new StringBundler(6 +
1380 (orderByComparator.getOrderByFields().length * 6));
1381 }
1382 else {
1383 query = new StringBundler(3);
1384 }
1385
1386 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
1387
1388 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1389
1390 if (orderByComparator != null) {
1391 String[] orderByFields = orderByComparator.getOrderByFields();
1392
1393 if (orderByFields.length > 0) {
1394 query.append(WHERE_AND);
1395 }
1396
1397 for (int i = 0; i < orderByFields.length; i++) {
1398 query.append(_ORDER_BY_ENTITY_ALIAS);
1399 query.append(orderByFields[i]);
1400
1401 if ((i + 1) < orderByFields.length) {
1402 if (orderByComparator.isAscending() ^ previous) {
1403 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1404 }
1405 else {
1406 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1407 }
1408 }
1409 else {
1410 if (orderByComparator.isAscending() ^ previous) {
1411 query.append(WHERE_GREATER_THAN);
1412 }
1413 else {
1414 query.append(WHERE_LESSER_THAN);
1415 }
1416 }
1417 }
1418
1419 query.append(ORDER_BY_CLAUSE);
1420
1421 for (int i = 0; i < orderByFields.length; i++) {
1422 query.append(_ORDER_BY_ENTITY_ALIAS);
1423 query.append(orderByFields[i]);
1424
1425 if ((i + 1) < orderByFields.length) {
1426 if (orderByComparator.isAscending() ^ previous) {
1427 query.append(ORDER_BY_ASC_HAS_NEXT);
1428 }
1429 else {
1430 query.append(ORDER_BY_DESC_HAS_NEXT);
1431 }
1432 }
1433 else {
1434 if (orderByComparator.isAscending() ^ previous) {
1435 query.append(ORDER_BY_ASC);
1436 }
1437 else {
1438 query.append(ORDER_BY_DESC);
1439 }
1440 }
1441 }
1442 }
1443
1444 else {
1445 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
1446 }
1447
1448 String sql = query.toString();
1449
1450 Query q = session.createQuery(sql);
1451
1452 q.setFirstResult(0);
1453 q.setMaxResults(2);
1454
1455 QueryPos qPos = QueryPos.getInstance(q);
1456
1457 qPos.add(groupId);
1458
1459 if (orderByComparator != null) {
1460 Object[] values = orderByComparator.getOrderByValues(assetCategory);
1461
1462 for (Object value : values) {
1463 qPos.add(value);
1464 }
1465 }
1466
1467 List<AssetCategory> list = q.list();
1468
1469 if (list.size() == 2) {
1470 return list.get(1);
1471 }
1472 else {
1473 return null;
1474 }
1475 }
1476
1477
1484 public List<AssetCategory> filterFindByGroupId(long groupId)
1485 throws SystemException {
1486 return filterFindByGroupId(groupId, QueryUtil.ALL_POS,
1487 QueryUtil.ALL_POS, null);
1488 }
1489
1490
1503 public List<AssetCategory> filterFindByGroupId(long groupId, int start,
1504 int end) throws SystemException {
1505 return filterFindByGroupId(groupId, start, end, null);
1506 }
1507
1508
1522 public List<AssetCategory> filterFindByGroupId(long groupId, int start,
1523 int end, OrderByComparator orderByComparator) throws SystemException {
1524 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
1525 return findByGroupId(groupId, start, end, orderByComparator);
1526 }
1527
1528 StringBundler query = null;
1529
1530 if (orderByComparator != null) {
1531 query = new StringBundler(3 +
1532 (orderByComparator.getOrderByFields().length * 3));
1533 }
1534 else {
1535 query = new StringBundler(3);
1536 }
1537
1538 if (getDB().isSupportsInlineDistinct()) {
1539 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_WHERE);
1540 }
1541 else {
1542 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_1);
1543 }
1544
1545 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1546
1547 if (!getDB().isSupportsInlineDistinct()) {
1548 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_2);
1549 }
1550
1551 if (orderByComparator != null) {
1552 if (getDB().isSupportsInlineDistinct()) {
1553 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1554 orderByComparator);
1555 }
1556 else {
1557 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
1558 orderByComparator);
1559 }
1560 }
1561
1562 else {
1563 if (getDB().isSupportsInlineDistinct()) {
1564 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
1565 }
1566 else {
1567 query.append(AssetCategoryModelImpl.ORDER_BY_SQL);
1568 }
1569 }
1570
1571 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1572 AssetCategory.class.getName(), _FILTER_COLUMN_PK,
1573 _FILTER_COLUMN_USERID, groupId);
1574
1575 Session session = null;
1576
1577 try {
1578 session = openSession();
1579
1580 SQLQuery q = session.createSQLQuery(sql);
1581
1582 if (getDB().isSupportsInlineDistinct()) {
1583 q.addEntity(_FILTER_ENTITY_ALIAS, AssetCategoryImpl.class);
1584 }
1585 else {
1586 q.addEntity(_FILTER_ENTITY_TABLE, AssetCategoryImpl.class);
1587 }
1588
1589 QueryPos qPos = QueryPos.getInstance(q);
1590
1591 qPos.add(groupId);
1592
1593 return (List<AssetCategory>)QueryUtil.list(q, getDialect(), start,
1594 end);
1595 }
1596 catch (Exception e) {
1597 throw processException(e);
1598 }
1599 finally {
1600 closeSession(session);
1601 }
1602 }
1603
1604
1611 public List<AssetCategory> findByParentCategoryId(long parentCategoryId)
1612 throws SystemException {
1613 return findByParentCategoryId(parentCategoryId, QueryUtil.ALL_POS,
1614 QueryUtil.ALL_POS, null);
1615 }
1616
1617
1630 public List<AssetCategory> findByParentCategoryId(long parentCategoryId,
1631 int start, int end) throws SystemException {
1632 return findByParentCategoryId(parentCategoryId, start, end, null);
1633 }
1634
1635
1649 public List<AssetCategory> findByParentCategoryId(long parentCategoryId,
1650 int start, int end, OrderByComparator orderByComparator)
1651 throws SystemException {
1652 Object[] finderArgs = new Object[] {
1653 parentCategoryId,
1654
1655 String.valueOf(start), String.valueOf(end),
1656 String.valueOf(orderByComparator)
1657 };
1658
1659 List<AssetCategory> list = (List<AssetCategory>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_PARENTCATEGORYID,
1660 finderArgs, this);
1661
1662 if (list == null) {
1663 StringBundler query = null;
1664
1665 if (orderByComparator != null) {
1666 query = new StringBundler(3 +
1667 (orderByComparator.getOrderByFields().length * 3));
1668 }
1669 else {
1670 query = new StringBundler(3);
1671 }
1672
1673 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
1674
1675 query.append(_FINDER_COLUMN_PARENTCATEGORYID_PARENTCATEGORYID_2);
1676
1677 if (orderByComparator != null) {
1678 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1679 orderByComparator);
1680 }
1681
1682 else {
1683 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
1684 }
1685
1686 String sql = query.toString();
1687
1688 Session session = null;
1689
1690 try {
1691 session = openSession();
1692
1693 Query q = session.createQuery(sql);
1694
1695 QueryPos qPos = QueryPos.getInstance(q);
1696
1697 qPos.add(parentCategoryId);
1698
1699 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
1700 start, end);
1701 }
1702 catch (Exception e) {
1703 throw processException(e);
1704 }
1705 finally {
1706 if (list == null) {
1707 FinderCacheUtil.removeResult(FINDER_PATH_FIND_BY_PARENTCATEGORYID,
1708 finderArgs);
1709 }
1710 else {
1711 cacheResult(list);
1712
1713 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_PARENTCATEGORYID,
1714 finderArgs, list);
1715 }
1716
1717 closeSession(session);
1718 }
1719 }
1720
1721 return list;
1722 }
1723
1724
1737 public AssetCategory findByParentCategoryId_First(long parentCategoryId,
1738 OrderByComparator orderByComparator)
1739 throws NoSuchCategoryException, SystemException {
1740 List<AssetCategory> list = findByParentCategoryId(parentCategoryId, 0,
1741 1, orderByComparator);
1742
1743 if (list.isEmpty()) {
1744 StringBundler msg = new StringBundler(4);
1745
1746 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1747
1748 msg.append("parentCategoryId=");
1749 msg.append(parentCategoryId);
1750
1751 msg.append(StringPool.CLOSE_CURLY_BRACE);
1752
1753 throw new NoSuchCategoryException(msg.toString());
1754 }
1755 else {
1756 return list.get(0);
1757 }
1758 }
1759
1760
1773 public AssetCategory findByParentCategoryId_Last(long parentCategoryId,
1774 OrderByComparator orderByComparator)
1775 throws NoSuchCategoryException, SystemException {
1776 int count = countByParentCategoryId(parentCategoryId);
1777
1778 List<AssetCategory> list = findByParentCategoryId(parentCategoryId,
1779 count - 1, count, orderByComparator);
1780
1781 if (list.isEmpty()) {
1782 StringBundler msg = new StringBundler(4);
1783
1784 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1785
1786 msg.append("parentCategoryId=");
1787 msg.append(parentCategoryId);
1788
1789 msg.append(StringPool.CLOSE_CURLY_BRACE);
1790
1791 throw new NoSuchCategoryException(msg.toString());
1792 }
1793 else {
1794 return list.get(0);
1795 }
1796 }
1797
1798
1812 public AssetCategory[] findByParentCategoryId_PrevAndNext(long categoryId,
1813 long parentCategoryId, OrderByComparator orderByComparator)
1814 throws NoSuchCategoryException, SystemException {
1815 AssetCategory assetCategory = findByPrimaryKey(categoryId);
1816
1817 Session session = null;
1818
1819 try {
1820 session = openSession();
1821
1822 AssetCategory[] array = new AssetCategoryImpl[3];
1823
1824 array[0] = getByParentCategoryId_PrevAndNext(session,
1825 assetCategory, parentCategoryId, orderByComparator, true);
1826
1827 array[1] = assetCategory;
1828
1829 array[2] = getByParentCategoryId_PrevAndNext(session,
1830 assetCategory, parentCategoryId, orderByComparator, false);
1831
1832 return array;
1833 }
1834 catch (Exception e) {
1835 throw processException(e);
1836 }
1837 finally {
1838 closeSession(session);
1839 }
1840 }
1841
1842 protected AssetCategory getByParentCategoryId_PrevAndNext(Session session,
1843 AssetCategory assetCategory, long parentCategoryId,
1844 OrderByComparator orderByComparator, boolean previous) {
1845 StringBundler query = null;
1846
1847 if (orderByComparator != null) {
1848 query = new StringBundler(6 +
1849 (orderByComparator.getOrderByFields().length * 6));
1850 }
1851 else {
1852 query = new StringBundler(3);
1853 }
1854
1855 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
1856
1857 query.append(_FINDER_COLUMN_PARENTCATEGORYID_PARENTCATEGORYID_2);
1858
1859 if (orderByComparator != null) {
1860 String[] orderByFields = orderByComparator.getOrderByFields();
1861
1862 if (orderByFields.length > 0) {
1863 query.append(WHERE_AND);
1864 }
1865
1866 for (int i = 0; i < orderByFields.length; i++) {
1867 query.append(_ORDER_BY_ENTITY_ALIAS);
1868 query.append(orderByFields[i]);
1869
1870 if ((i + 1) < orderByFields.length) {
1871 if (orderByComparator.isAscending() ^ previous) {
1872 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1873 }
1874 else {
1875 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1876 }
1877 }
1878 else {
1879 if (orderByComparator.isAscending() ^ previous) {
1880 query.append(WHERE_GREATER_THAN);
1881 }
1882 else {
1883 query.append(WHERE_LESSER_THAN);
1884 }
1885 }
1886 }
1887
1888 query.append(ORDER_BY_CLAUSE);
1889
1890 for (int i = 0; i < orderByFields.length; i++) {
1891 query.append(_ORDER_BY_ENTITY_ALIAS);
1892 query.append(orderByFields[i]);
1893
1894 if ((i + 1) < orderByFields.length) {
1895 if (orderByComparator.isAscending() ^ previous) {
1896 query.append(ORDER_BY_ASC_HAS_NEXT);
1897 }
1898 else {
1899 query.append(ORDER_BY_DESC_HAS_NEXT);
1900 }
1901 }
1902 else {
1903 if (orderByComparator.isAscending() ^ previous) {
1904 query.append(ORDER_BY_ASC);
1905 }
1906 else {
1907 query.append(ORDER_BY_DESC);
1908 }
1909 }
1910 }
1911 }
1912
1913 else {
1914 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
1915 }
1916
1917 String sql = query.toString();
1918
1919 Query q = session.createQuery(sql);
1920
1921 q.setFirstResult(0);
1922 q.setMaxResults(2);
1923
1924 QueryPos qPos = QueryPos.getInstance(q);
1925
1926 qPos.add(parentCategoryId);
1927
1928 if (orderByComparator != null) {
1929 Object[] values = orderByComparator.getOrderByValues(assetCategory);
1930
1931 for (Object value : values) {
1932 qPos.add(value);
1933 }
1934 }
1935
1936 List<AssetCategory> list = q.list();
1937
1938 if (list.size() == 2) {
1939 return list.get(1);
1940 }
1941 else {
1942 return null;
1943 }
1944 }
1945
1946
1953 public List<AssetCategory> findByVocabularyId(long vocabularyId)
1954 throws SystemException {
1955 return findByVocabularyId(vocabularyId, QueryUtil.ALL_POS,
1956 QueryUtil.ALL_POS, null);
1957 }
1958
1959
1972 public List<AssetCategory> findByVocabularyId(long vocabularyId, int start,
1973 int end) throws SystemException {
1974 return findByVocabularyId(vocabularyId, start, end, null);
1975 }
1976
1977
1991 public List<AssetCategory> findByVocabularyId(long vocabularyId, int start,
1992 int end, OrderByComparator orderByComparator) throws SystemException {
1993 Object[] finderArgs = new Object[] {
1994 vocabularyId,
1995
1996 String.valueOf(start), String.valueOf(end),
1997 String.valueOf(orderByComparator)
1998 };
1999
2000 List<AssetCategory> list = (List<AssetCategory>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_VOCABULARYID,
2001 finderArgs, this);
2002
2003 if (list == null) {
2004 StringBundler query = null;
2005
2006 if (orderByComparator != null) {
2007 query = new StringBundler(3 +
2008 (orderByComparator.getOrderByFields().length * 3));
2009 }
2010 else {
2011 query = new StringBundler(3);
2012 }
2013
2014 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
2015
2016 query.append(_FINDER_COLUMN_VOCABULARYID_VOCABULARYID_2);
2017
2018 if (orderByComparator != null) {
2019 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2020 orderByComparator);
2021 }
2022
2023 else {
2024 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
2025 }
2026
2027 String sql = query.toString();
2028
2029 Session session = null;
2030
2031 try {
2032 session = openSession();
2033
2034 Query q = session.createQuery(sql);
2035
2036 QueryPos qPos = QueryPos.getInstance(q);
2037
2038 qPos.add(vocabularyId);
2039
2040 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
2041 start, end);
2042 }
2043 catch (Exception e) {
2044 throw processException(e);
2045 }
2046 finally {
2047 if (list == null) {
2048 FinderCacheUtil.removeResult(FINDER_PATH_FIND_BY_VOCABULARYID,
2049 finderArgs);
2050 }
2051 else {
2052 cacheResult(list);
2053
2054 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_VOCABULARYID,
2055 finderArgs, list);
2056 }
2057
2058 closeSession(session);
2059 }
2060 }
2061
2062 return list;
2063 }
2064
2065
2078 public AssetCategory findByVocabularyId_First(long vocabularyId,
2079 OrderByComparator orderByComparator)
2080 throws NoSuchCategoryException, SystemException {
2081 List<AssetCategory> list = findByVocabularyId(vocabularyId, 0, 1,
2082 orderByComparator);
2083
2084 if (list.isEmpty()) {
2085 StringBundler msg = new StringBundler(4);
2086
2087 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2088
2089 msg.append("vocabularyId=");
2090 msg.append(vocabularyId);
2091
2092 msg.append(StringPool.CLOSE_CURLY_BRACE);
2093
2094 throw new NoSuchCategoryException(msg.toString());
2095 }
2096 else {
2097 return list.get(0);
2098 }
2099 }
2100
2101
2114 public AssetCategory findByVocabularyId_Last(long vocabularyId,
2115 OrderByComparator orderByComparator)
2116 throws NoSuchCategoryException, SystemException {
2117 int count = countByVocabularyId(vocabularyId);
2118
2119 List<AssetCategory> list = findByVocabularyId(vocabularyId, count - 1,
2120 count, orderByComparator);
2121
2122 if (list.isEmpty()) {
2123 StringBundler msg = new StringBundler(4);
2124
2125 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2126
2127 msg.append("vocabularyId=");
2128 msg.append(vocabularyId);
2129
2130 msg.append(StringPool.CLOSE_CURLY_BRACE);
2131
2132 throw new NoSuchCategoryException(msg.toString());
2133 }
2134 else {
2135 return list.get(0);
2136 }
2137 }
2138
2139
2153 public AssetCategory[] findByVocabularyId_PrevAndNext(long categoryId,
2154 long vocabularyId, OrderByComparator orderByComparator)
2155 throws NoSuchCategoryException, SystemException {
2156 AssetCategory assetCategory = findByPrimaryKey(categoryId);
2157
2158 Session session = null;
2159
2160 try {
2161 session = openSession();
2162
2163 AssetCategory[] array = new AssetCategoryImpl[3];
2164
2165 array[0] = getByVocabularyId_PrevAndNext(session, assetCategory,
2166 vocabularyId, orderByComparator, true);
2167
2168 array[1] = assetCategory;
2169
2170 array[2] = getByVocabularyId_PrevAndNext(session, assetCategory,
2171 vocabularyId, orderByComparator, false);
2172
2173 return array;
2174 }
2175 catch (Exception e) {
2176 throw processException(e);
2177 }
2178 finally {
2179 closeSession(session);
2180 }
2181 }
2182
2183 protected AssetCategory getByVocabularyId_PrevAndNext(Session session,
2184 AssetCategory assetCategory, long vocabularyId,
2185 OrderByComparator orderByComparator, boolean previous) {
2186 StringBundler query = null;
2187
2188 if (orderByComparator != null) {
2189 query = new StringBundler(6 +
2190 (orderByComparator.getOrderByFields().length * 6));
2191 }
2192 else {
2193 query = new StringBundler(3);
2194 }
2195
2196 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
2197
2198 query.append(_FINDER_COLUMN_VOCABULARYID_VOCABULARYID_2);
2199
2200 if (orderByComparator != null) {
2201 String[] orderByFields = orderByComparator.getOrderByFields();
2202
2203 if (orderByFields.length > 0) {
2204 query.append(WHERE_AND);
2205 }
2206
2207 for (int i = 0; i < orderByFields.length; i++) {
2208 query.append(_ORDER_BY_ENTITY_ALIAS);
2209 query.append(orderByFields[i]);
2210
2211 if ((i + 1) < orderByFields.length) {
2212 if (orderByComparator.isAscending() ^ previous) {
2213 query.append(WHERE_GREATER_THAN_HAS_NEXT);
2214 }
2215 else {
2216 query.append(WHERE_LESSER_THAN_HAS_NEXT);
2217 }
2218 }
2219 else {
2220 if (orderByComparator.isAscending() ^ previous) {
2221 query.append(WHERE_GREATER_THAN);
2222 }
2223 else {
2224 query.append(WHERE_LESSER_THAN);
2225 }
2226 }
2227 }
2228
2229 query.append(ORDER_BY_CLAUSE);
2230
2231 for (int i = 0; i < orderByFields.length; i++) {
2232 query.append(_ORDER_BY_ENTITY_ALIAS);
2233 query.append(orderByFields[i]);
2234
2235 if ((i + 1) < orderByFields.length) {
2236 if (orderByComparator.isAscending() ^ previous) {
2237 query.append(ORDER_BY_ASC_HAS_NEXT);
2238 }
2239 else {
2240 query.append(ORDER_BY_DESC_HAS_NEXT);
2241 }
2242 }
2243 else {
2244 if (orderByComparator.isAscending() ^ previous) {
2245 query.append(ORDER_BY_ASC);
2246 }
2247 else {
2248 query.append(ORDER_BY_DESC);
2249 }
2250 }
2251 }
2252 }
2253
2254 else {
2255 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
2256 }
2257
2258 String sql = query.toString();
2259
2260 Query q = session.createQuery(sql);
2261
2262 q.setFirstResult(0);
2263 q.setMaxResults(2);
2264
2265 QueryPos qPos = QueryPos.getInstance(q);
2266
2267 qPos.add(vocabularyId);
2268
2269 if (orderByComparator != null) {
2270 Object[] values = orderByComparator.getOrderByValues(assetCategory);
2271
2272 for (Object value : values) {
2273 qPos.add(value);
2274 }
2275 }
2276
2277 List<AssetCategory> list = q.list();
2278
2279 if (list.size() == 2) {
2280 return list.get(1);
2281 }
2282 else {
2283 return null;
2284 }
2285 }
2286
2287
2295 public List<AssetCategory> findByP_N(long parentCategoryId, String name)
2296 throws SystemException {
2297 return findByP_N(parentCategoryId, name, QueryUtil.ALL_POS,
2298 QueryUtil.ALL_POS, null);
2299 }
2300
2301
2315 public List<AssetCategory> findByP_N(long parentCategoryId, String name,
2316 int start, int end) throws SystemException {
2317 return findByP_N(parentCategoryId, name, start, end, null);
2318 }
2319
2320
2335 public List<AssetCategory> findByP_N(long parentCategoryId, String name,
2336 int start, int end, OrderByComparator orderByComparator)
2337 throws SystemException {
2338 Object[] finderArgs = new Object[] {
2339 parentCategoryId, name,
2340
2341 String.valueOf(start), String.valueOf(end),
2342 String.valueOf(orderByComparator)
2343 };
2344
2345 List<AssetCategory> list = (List<AssetCategory>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_P_N,
2346 finderArgs, this);
2347
2348 if (list == null) {
2349 StringBundler query = null;
2350
2351 if (orderByComparator != null) {
2352 query = new StringBundler(4 +
2353 (orderByComparator.getOrderByFields().length * 3));
2354 }
2355 else {
2356 query = new StringBundler(4);
2357 }
2358
2359 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
2360
2361 query.append(_FINDER_COLUMN_P_N_PARENTCATEGORYID_2);
2362
2363 if (name == null) {
2364 query.append(_FINDER_COLUMN_P_N_NAME_1);
2365 }
2366 else {
2367 if (name.equals(StringPool.BLANK)) {
2368 query.append(_FINDER_COLUMN_P_N_NAME_3);
2369 }
2370 else {
2371 query.append(_FINDER_COLUMN_P_N_NAME_2);
2372 }
2373 }
2374
2375 if (orderByComparator != null) {
2376 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2377 orderByComparator);
2378 }
2379
2380 else {
2381 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
2382 }
2383
2384 String sql = query.toString();
2385
2386 Session session = null;
2387
2388 try {
2389 session = openSession();
2390
2391 Query q = session.createQuery(sql);
2392
2393 QueryPos qPos = QueryPos.getInstance(q);
2394
2395 qPos.add(parentCategoryId);
2396
2397 if (name != null) {
2398 qPos.add(name);
2399 }
2400
2401 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
2402 start, end);
2403 }
2404 catch (Exception e) {
2405 throw processException(e);
2406 }
2407 finally {
2408 if (list == null) {
2409 FinderCacheUtil.removeResult(FINDER_PATH_FIND_BY_P_N,
2410 finderArgs);
2411 }
2412 else {
2413 cacheResult(list);
2414
2415 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_P_N,
2416 finderArgs, list);
2417 }
2418
2419 closeSession(session);
2420 }
2421 }
2422
2423 return list;
2424 }
2425
2426
2440 public AssetCategory findByP_N_First(long parentCategoryId, String name,
2441 OrderByComparator orderByComparator)
2442 throws NoSuchCategoryException, SystemException {
2443 List<AssetCategory> list = findByP_N(parentCategoryId, name, 0, 1,
2444 orderByComparator);
2445
2446 if (list.isEmpty()) {
2447 StringBundler msg = new StringBundler(6);
2448
2449 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2450
2451 msg.append("parentCategoryId=");
2452 msg.append(parentCategoryId);
2453
2454 msg.append(", name=");
2455 msg.append(name);
2456
2457 msg.append(StringPool.CLOSE_CURLY_BRACE);
2458
2459 throw new NoSuchCategoryException(msg.toString());
2460 }
2461 else {
2462 return list.get(0);
2463 }
2464 }
2465
2466
2480 public AssetCategory findByP_N_Last(long parentCategoryId, String name,
2481 OrderByComparator orderByComparator)
2482 throws NoSuchCategoryException, SystemException {
2483 int count = countByP_N(parentCategoryId, name);
2484
2485 List<AssetCategory> list = findByP_N(parentCategoryId, name, count - 1,
2486 count, orderByComparator);
2487
2488 if (list.isEmpty()) {
2489 StringBundler msg = new StringBundler(6);
2490
2491 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2492
2493 msg.append("parentCategoryId=");
2494 msg.append(parentCategoryId);
2495
2496 msg.append(", name=");
2497 msg.append(name);
2498
2499 msg.append(StringPool.CLOSE_CURLY_BRACE);
2500
2501 throw new NoSuchCategoryException(msg.toString());
2502 }
2503 else {
2504 return list.get(0);
2505 }
2506 }
2507
2508
2523 public AssetCategory[] findByP_N_PrevAndNext(long categoryId,
2524 long parentCategoryId, String name, OrderByComparator orderByComparator)
2525 throws NoSuchCategoryException, SystemException {
2526 AssetCategory assetCategory = findByPrimaryKey(categoryId);
2527
2528 Session session = null;
2529
2530 try {
2531 session = openSession();
2532
2533 AssetCategory[] array = new AssetCategoryImpl[3];
2534
2535 array[0] = getByP_N_PrevAndNext(session, assetCategory,
2536 parentCategoryId, name, orderByComparator, true);
2537
2538 array[1] = assetCategory;
2539
2540 array[2] = getByP_N_PrevAndNext(session, assetCategory,
2541 parentCategoryId, name, orderByComparator, false);
2542
2543 return array;
2544 }
2545 catch (Exception e) {
2546 throw processException(e);
2547 }
2548 finally {
2549 closeSession(session);
2550 }
2551 }
2552
2553 protected AssetCategory getByP_N_PrevAndNext(Session session,
2554 AssetCategory assetCategory, long parentCategoryId, String name,
2555 OrderByComparator orderByComparator, boolean previous) {
2556 StringBundler query = null;
2557
2558 if (orderByComparator != null) {
2559 query = new StringBundler(6 +
2560 (orderByComparator.getOrderByFields().length * 6));
2561 }
2562 else {
2563 query = new StringBundler(3);
2564 }
2565
2566 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
2567
2568 query.append(_FINDER_COLUMN_P_N_PARENTCATEGORYID_2);
2569
2570 if (name == null) {
2571 query.append(_FINDER_COLUMN_P_N_NAME_1);
2572 }
2573 else {
2574 if (name.equals(StringPool.BLANK)) {
2575 query.append(_FINDER_COLUMN_P_N_NAME_3);
2576 }
2577 else {
2578 query.append(_FINDER_COLUMN_P_N_NAME_2);
2579 }
2580 }
2581
2582 if (orderByComparator != null) {
2583 String[] orderByFields = orderByComparator.getOrderByFields();
2584
2585 if (orderByFields.length > 0) {
2586 query.append(WHERE_AND);
2587 }
2588
2589 for (int i = 0; i < orderByFields.length; i++) {
2590 query.append(_ORDER_BY_ENTITY_ALIAS);
2591 query.append(orderByFields[i]);
2592
2593 if ((i + 1) < orderByFields.length) {
2594 if (orderByComparator.isAscending() ^ previous) {
2595 query.append(WHERE_GREATER_THAN_HAS_NEXT);
2596 }
2597 else {
2598 query.append(WHERE_LESSER_THAN_HAS_NEXT);
2599 }
2600 }
2601 else {
2602 if (orderByComparator.isAscending() ^ previous) {
2603 query.append(WHERE_GREATER_THAN);
2604 }
2605 else {
2606 query.append(WHERE_LESSER_THAN);
2607 }
2608 }
2609 }
2610
2611 query.append(ORDER_BY_CLAUSE);
2612
2613 for (int i = 0; i < orderByFields.length; i++) {
2614 query.append(_ORDER_BY_ENTITY_ALIAS);
2615 query.append(orderByFields[i]);
2616
2617 if ((i + 1) < orderByFields.length) {
2618 if (orderByComparator.isAscending() ^ previous) {
2619 query.append(ORDER_BY_ASC_HAS_NEXT);
2620 }
2621 else {
2622 query.append(ORDER_BY_DESC_HAS_NEXT);
2623 }
2624 }
2625 else {
2626 if (orderByComparator.isAscending() ^ previous) {
2627 query.append(ORDER_BY_ASC);
2628 }
2629 else {
2630 query.append(ORDER_BY_DESC);
2631 }
2632 }
2633 }
2634 }
2635
2636 else {
2637 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
2638 }
2639
2640 String sql = query.toString();
2641
2642 Query q = session.createQuery(sql);
2643
2644 q.setFirstResult(0);
2645 q.setMaxResults(2);
2646
2647 QueryPos qPos = QueryPos.getInstance(q);
2648
2649 qPos.add(parentCategoryId);
2650
2651 if (name != null) {
2652 qPos.add(name);
2653 }
2654
2655 if (orderByComparator != null) {
2656 Object[] values = orderByComparator.getOrderByValues(assetCategory);
2657
2658 for (Object value : values) {
2659 qPos.add(value);
2660 }
2661 }
2662
2663 List<AssetCategory> list = q.list();
2664
2665 if (list.size() == 2) {
2666 return list.get(1);
2667 }
2668 else {
2669 return null;
2670 }
2671 }
2672
2673
2681 public List<AssetCategory> findByP_V(long parentCategoryId,
2682 long vocabularyId) throws SystemException {
2683 return findByP_V(parentCategoryId, vocabularyId, QueryUtil.ALL_POS,
2684 QueryUtil.ALL_POS, null);
2685 }
2686
2687
2701 public List<AssetCategory> findByP_V(long parentCategoryId,
2702 long vocabularyId, int start, int end) throws SystemException {
2703 return findByP_V(parentCategoryId, vocabularyId, start, end, null);
2704 }
2705
2706
2721 public List<AssetCategory> findByP_V(long parentCategoryId,
2722 long vocabularyId, int start, int end,
2723 OrderByComparator orderByComparator) throws SystemException {
2724 Object[] finderArgs = new Object[] {
2725 parentCategoryId, vocabularyId,
2726
2727 String.valueOf(start), String.valueOf(end),
2728 String.valueOf(orderByComparator)
2729 };
2730
2731 List<AssetCategory> list = (List<AssetCategory>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_P_V,
2732 finderArgs, this);
2733
2734 if (list == null) {
2735 StringBundler query = null;
2736
2737 if (orderByComparator != null) {
2738 query = new StringBundler(4 +
2739 (orderByComparator.getOrderByFields().length * 3));
2740 }
2741 else {
2742 query = new StringBundler(4);
2743 }
2744
2745 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
2746
2747 query.append(_FINDER_COLUMN_P_V_PARENTCATEGORYID_2);
2748
2749 query.append(_FINDER_COLUMN_P_V_VOCABULARYID_2);
2750
2751 if (orderByComparator != null) {
2752 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2753 orderByComparator);
2754 }
2755
2756 else {
2757 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
2758 }
2759
2760 String sql = query.toString();
2761
2762 Session session = null;
2763
2764 try {
2765 session = openSession();
2766
2767 Query q = session.createQuery(sql);
2768
2769 QueryPos qPos = QueryPos.getInstance(q);
2770
2771 qPos.add(parentCategoryId);
2772
2773 qPos.add(vocabularyId);
2774
2775 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
2776 start, end);
2777 }
2778 catch (Exception e) {
2779 throw processException(e);
2780 }
2781 finally {
2782 if (list == null) {
2783 FinderCacheUtil.removeResult(FINDER_PATH_FIND_BY_P_V,
2784 finderArgs);
2785 }
2786 else {
2787 cacheResult(list);
2788
2789 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_P_V,
2790 finderArgs, list);
2791 }
2792
2793 closeSession(session);
2794 }
2795 }
2796
2797 return list;
2798 }
2799
2800
2814 public AssetCategory findByP_V_First(long parentCategoryId,
2815 long vocabularyId, OrderByComparator orderByComparator)
2816 throws NoSuchCategoryException, SystemException {
2817 List<AssetCategory> list = findByP_V(parentCategoryId, vocabularyId, 0,
2818 1, orderByComparator);
2819
2820 if (list.isEmpty()) {
2821 StringBundler msg = new StringBundler(6);
2822
2823 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2824
2825 msg.append("parentCategoryId=");
2826 msg.append(parentCategoryId);
2827
2828 msg.append(", vocabularyId=");
2829 msg.append(vocabularyId);
2830
2831 msg.append(StringPool.CLOSE_CURLY_BRACE);
2832
2833 throw new NoSuchCategoryException(msg.toString());
2834 }
2835 else {
2836 return list.get(0);
2837 }
2838 }
2839
2840
2854 public AssetCategory findByP_V_Last(long parentCategoryId,
2855 long vocabularyId, OrderByComparator orderByComparator)
2856 throws NoSuchCategoryException, SystemException {
2857 int count = countByP_V(parentCategoryId, vocabularyId);
2858
2859 List<AssetCategory> list = findByP_V(parentCategoryId, vocabularyId,
2860 count - 1, count, orderByComparator);
2861
2862 if (list.isEmpty()) {
2863 StringBundler msg = new StringBundler(6);
2864
2865 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2866
2867 msg.append("parentCategoryId=");
2868 msg.append(parentCategoryId);
2869
2870 msg.append(", vocabularyId=");
2871 msg.append(vocabularyId);
2872
2873 msg.append(StringPool.CLOSE_CURLY_BRACE);
2874
2875 throw new NoSuchCategoryException(msg.toString());
2876 }
2877 else {
2878 return list.get(0);
2879 }
2880 }
2881
2882
2897 public AssetCategory[] findByP_V_PrevAndNext(long categoryId,
2898 long parentCategoryId, long vocabularyId,
2899 OrderByComparator orderByComparator)
2900 throws NoSuchCategoryException, SystemException {
2901 AssetCategory assetCategory = findByPrimaryKey(categoryId);
2902
2903 Session session = null;
2904
2905 try {
2906 session = openSession();
2907
2908 AssetCategory[] array = new AssetCategoryImpl[3];
2909
2910 array[0] = getByP_V_PrevAndNext(session, assetCategory,
2911 parentCategoryId, vocabularyId, orderByComparator, true);
2912
2913 array[1] = assetCategory;
2914
2915 array[2] = getByP_V_PrevAndNext(session, assetCategory,
2916 parentCategoryId, vocabularyId, orderByComparator, false);
2917
2918 return array;
2919 }
2920 catch (Exception e) {
2921 throw processException(e);
2922 }
2923 finally {
2924 closeSession(session);
2925 }
2926 }
2927
2928 protected AssetCategory getByP_V_PrevAndNext(Session session,
2929 AssetCategory assetCategory, long parentCategoryId, long vocabularyId,
2930 OrderByComparator orderByComparator, boolean previous) {
2931 StringBundler query = null;
2932
2933 if (orderByComparator != null) {
2934 query = new StringBundler(6 +
2935 (orderByComparator.getOrderByFields().length * 6));
2936 }
2937 else {
2938 query = new StringBundler(3);
2939 }
2940
2941 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
2942
2943 query.append(_FINDER_COLUMN_P_V_PARENTCATEGORYID_2);
2944
2945 query.append(_FINDER_COLUMN_P_V_VOCABULARYID_2);
2946
2947 if (orderByComparator != null) {
2948 String[] orderByFields = orderByComparator.getOrderByFields();
2949
2950 if (orderByFields.length > 0) {
2951 query.append(WHERE_AND);
2952 }
2953
2954 for (int i = 0; i < orderByFields.length; i++) {
2955 query.append(_ORDER_BY_ENTITY_ALIAS);
2956 query.append(orderByFields[i]);
2957
2958 if ((i + 1) < orderByFields.length) {
2959 if (orderByComparator.isAscending() ^ previous) {
2960 query.append(WHERE_GREATER_THAN_HAS_NEXT);
2961 }
2962 else {
2963 query.append(WHERE_LESSER_THAN_HAS_NEXT);
2964 }
2965 }
2966 else {
2967 if (orderByComparator.isAscending() ^ previous) {
2968 query.append(WHERE_GREATER_THAN);
2969 }
2970 else {
2971 query.append(WHERE_LESSER_THAN);
2972 }
2973 }
2974 }
2975
2976 query.append(ORDER_BY_CLAUSE);
2977
2978 for (int i = 0; i < orderByFields.length; i++) {
2979 query.append(_ORDER_BY_ENTITY_ALIAS);
2980 query.append(orderByFields[i]);
2981
2982 if ((i + 1) < orderByFields.length) {
2983 if (orderByComparator.isAscending() ^ previous) {
2984 query.append(ORDER_BY_ASC_HAS_NEXT);
2985 }
2986 else {
2987 query.append(ORDER_BY_DESC_HAS_NEXT);
2988 }
2989 }
2990 else {
2991 if (orderByComparator.isAscending() ^ previous) {
2992 query.append(ORDER_BY_ASC);
2993 }
2994 else {
2995 query.append(ORDER_BY_DESC);
2996 }
2997 }
2998 }
2999 }
3000
3001 else {
3002 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
3003 }
3004
3005 String sql = query.toString();
3006
3007 Query q = session.createQuery(sql);
3008
3009 q.setFirstResult(0);
3010 q.setMaxResults(2);
3011
3012 QueryPos qPos = QueryPos.getInstance(q);
3013
3014 qPos.add(parentCategoryId);
3015
3016 qPos.add(vocabularyId);
3017
3018 if (orderByComparator != null) {
3019 Object[] values = orderByComparator.getOrderByValues(assetCategory);
3020
3021 for (Object value : values) {
3022 qPos.add(value);
3023 }
3024 }
3025
3026 List<AssetCategory> list = q.list();
3027
3028 if (list.size() == 2) {
3029 return list.get(1);
3030 }
3031 else {
3032 return null;
3033 }
3034 }
3035
3036
3044 public List<AssetCategory> findByN_V(String name, long vocabularyId)
3045 throws SystemException {
3046 return findByN_V(name, vocabularyId, QueryUtil.ALL_POS,
3047 QueryUtil.ALL_POS, null);
3048 }
3049
3050
3064 public List<AssetCategory> findByN_V(String name, long vocabularyId,
3065 int start, int end) throws SystemException {
3066 return findByN_V(name, vocabularyId, start, end, null);
3067 }
3068
3069
3084 public List<AssetCategory> findByN_V(String name, long vocabularyId,
3085 int start, int end, OrderByComparator orderByComparator)
3086 throws SystemException {
3087 Object[] finderArgs = new Object[] {
3088 name, vocabularyId,
3089
3090 String.valueOf(start), String.valueOf(end),
3091 String.valueOf(orderByComparator)
3092 };
3093
3094 List<AssetCategory> list = (List<AssetCategory>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_N_V,
3095 finderArgs, this);
3096
3097 if (list == null) {
3098 StringBundler query = null;
3099
3100 if (orderByComparator != null) {
3101 query = new StringBundler(4 +
3102 (orderByComparator.getOrderByFields().length * 3));
3103 }
3104 else {
3105 query = new StringBundler(4);
3106 }
3107
3108 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
3109
3110 if (name == null) {
3111 query.append(_FINDER_COLUMN_N_V_NAME_1);
3112 }
3113 else {
3114 if (name.equals(StringPool.BLANK)) {
3115 query.append(_FINDER_COLUMN_N_V_NAME_3);
3116 }
3117 else {
3118 query.append(_FINDER_COLUMN_N_V_NAME_2);
3119 }
3120 }
3121
3122 query.append(_FINDER_COLUMN_N_V_VOCABULARYID_2);
3123
3124 if (orderByComparator != null) {
3125 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3126 orderByComparator);
3127 }
3128
3129 else {
3130 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
3131 }
3132
3133 String sql = query.toString();
3134
3135 Session session = null;
3136
3137 try {
3138 session = openSession();
3139
3140 Query q = session.createQuery(sql);
3141
3142 QueryPos qPos = QueryPos.getInstance(q);
3143
3144 if (name != null) {
3145 qPos.add(name);
3146 }
3147
3148 qPos.add(vocabularyId);
3149
3150 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
3151 start, end);
3152 }
3153 catch (Exception e) {
3154 throw processException(e);
3155 }
3156 finally {
3157 if (list == null) {
3158 FinderCacheUtil.removeResult(FINDER_PATH_FIND_BY_N_V,
3159 finderArgs);
3160 }
3161 else {
3162 cacheResult(list);
3163
3164 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_N_V,
3165 finderArgs, list);
3166 }
3167
3168 closeSession(session);
3169 }
3170 }
3171
3172 return list;
3173 }
3174
3175
3189 public AssetCategory findByN_V_First(String name, long vocabularyId,
3190 OrderByComparator orderByComparator)
3191 throws NoSuchCategoryException, SystemException {
3192 List<AssetCategory> list = findByN_V(name, vocabularyId, 0, 1,
3193 orderByComparator);
3194
3195 if (list.isEmpty()) {
3196 StringBundler msg = new StringBundler(6);
3197
3198 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3199
3200 msg.append("name=");
3201 msg.append(name);
3202
3203 msg.append(", vocabularyId=");
3204 msg.append(vocabularyId);
3205
3206 msg.append(StringPool.CLOSE_CURLY_BRACE);
3207
3208 throw new NoSuchCategoryException(msg.toString());
3209 }
3210 else {
3211 return list.get(0);
3212 }
3213 }
3214
3215
3229 public AssetCategory findByN_V_Last(String name, long vocabularyId,
3230 OrderByComparator orderByComparator)
3231 throws NoSuchCategoryException, SystemException {
3232 int count = countByN_V(name, vocabularyId);
3233
3234 List<AssetCategory> list = findByN_V(name, vocabularyId, count - 1,
3235 count, orderByComparator);
3236
3237 if (list.isEmpty()) {
3238 StringBundler msg = new StringBundler(6);
3239
3240 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3241
3242 msg.append("name=");
3243 msg.append(name);
3244
3245 msg.append(", vocabularyId=");
3246 msg.append(vocabularyId);
3247
3248 msg.append(StringPool.CLOSE_CURLY_BRACE);
3249
3250 throw new NoSuchCategoryException(msg.toString());
3251 }
3252 else {
3253 return list.get(0);
3254 }
3255 }
3256
3257
3272 public AssetCategory[] findByN_V_PrevAndNext(long categoryId, String name,
3273 long vocabularyId, OrderByComparator orderByComparator)
3274 throws NoSuchCategoryException, SystemException {
3275 AssetCategory assetCategory = findByPrimaryKey(categoryId);
3276
3277 Session session = null;
3278
3279 try {
3280 session = openSession();
3281
3282 AssetCategory[] array = new AssetCategoryImpl[3];
3283
3284 array[0] = getByN_V_PrevAndNext(session, assetCategory, name,
3285 vocabularyId, orderByComparator, true);
3286
3287 array[1] = assetCategory;
3288
3289 array[2] = getByN_V_PrevAndNext(session, assetCategory, name,
3290 vocabularyId, orderByComparator, false);
3291
3292 return array;
3293 }
3294 catch (Exception e) {
3295 throw processException(e);
3296 }
3297 finally {
3298 closeSession(session);
3299 }
3300 }
3301
3302 protected AssetCategory getByN_V_PrevAndNext(Session session,
3303 AssetCategory assetCategory, String name, long vocabularyId,
3304 OrderByComparator orderByComparator, boolean previous) {
3305 StringBundler query = null;
3306
3307 if (orderByComparator != null) {
3308 query = new StringBundler(6 +
3309 (orderByComparator.getOrderByFields().length * 6));
3310 }
3311 else {
3312 query = new StringBundler(3);
3313 }
3314
3315 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
3316
3317 if (name == null) {
3318 query.append(_FINDER_COLUMN_N_V_NAME_1);
3319 }
3320 else {
3321 if (name.equals(StringPool.BLANK)) {
3322 query.append(_FINDER_COLUMN_N_V_NAME_3);
3323 }
3324 else {
3325 query.append(_FINDER_COLUMN_N_V_NAME_2);
3326 }
3327 }
3328
3329 query.append(_FINDER_COLUMN_N_V_VOCABULARYID_2);
3330
3331 if (orderByComparator != null) {
3332 String[] orderByFields = orderByComparator.getOrderByFields();
3333
3334 if (orderByFields.length > 0) {
3335 query.append(WHERE_AND);
3336 }
3337
3338 for (int i = 0; i < orderByFields.length; i++) {
3339 query.append(_ORDER_BY_ENTITY_ALIAS);
3340 query.append(orderByFields[i]);
3341
3342 if ((i + 1) < orderByFields.length) {
3343 if (orderByComparator.isAscending() ^ previous) {
3344 query.append(WHERE_GREATER_THAN_HAS_NEXT);
3345 }
3346 else {
3347 query.append(WHERE_LESSER_THAN_HAS_NEXT);
3348 }
3349 }
3350 else {
3351 if (orderByComparator.isAscending() ^ previous) {
3352 query.append(WHERE_GREATER_THAN);
3353 }
3354 else {
3355 query.append(WHERE_LESSER_THAN);
3356 }
3357 }
3358 }
3359
3360 query.append(ORDER_BY_CLAUSE);
3361
3362 for (int i = 0; i < orderByFields.length; i++) {
3363 query.append(_ORDER_BY_ENTITY_ALIAS);
3364 query.append(orderByFields[i]);
3365
3366 if ((i + 1) < orderByFields.length) {
3367 if (orderByComparator.isAscending() ^ previous) {
3368 query.append(ORDER_BY_ASC_HAS_NEXT);
3369 }
3370 else {
3371 query.append(ORDER_BY_DESC_HAS_NEXT);
3372 }
3373 }
3374 else {
3375 if (orderByComparator.isAscending() ^ previous) {
3376 query.append(ORDER_BY_ASC);
3377 }
3378 else {
3379 query.append(ORDER_BY_DESC);
3380 }
3381 }
3382 }
3383 }
3384
3385 else {
3386 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
3387 }
3388
3389 String sql = query.toString();
3390
3391 Query q = session.createQuery(sql);
3392
3393 q.setFirstResult(0);
3394 q.setMaxResults(2);
3395
3396 QueryPos qPos = QueryPos.getInstance(q);
3397
3398 if (name != null) {
3399 qPos.add(name);
3400 }
3401
3402 qPos.add(vocabularyId);
3403
3404 if (orderByComparator != null) {
3405 Object[] values = orderByComparator.getOrderByValues(assetCategory);
3406
3407 for (Object value : values) {
3408 qPos.add(value);
3409 }
3410 }
3411
3412 List<AssetCategory> list = q.list();
3413
3414 if (list.size() == 2) {
3415 return list.get(1);
3416 }
3417 else {
3418 return null;
3419 }
3420 }
3421
3422
3432 public AssetCategory findByP_N_V(long parentCategoryId, String name,
3433 long vocabularyId) throws NoSuchCategoryException, SystemException {
3434 AssetCategory assetCategory = fetchByP_N_V(parentCategoryId, name,
3435 vocabularyId);
3436
3437 if (assetCategory == null) {
3438 StringBundler msg = new StringBundler(8);
3439
3440 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3441
3442 msg.append("parentCategoryId=");
3443 msg.append(parentCategoryId);
3444
3445 msg.append(", name=");
3446 msg.append(name);
3447
3448 msg.append(", vocabularyId=");
3449 msg.append(vocabularyId);
3450
3451 msg.append(StringPool.CLOSE_CURLY_BRACE);
3452
3453 if (_log.isWarnEnabled()) {
3454 _log.warn(msg.toString());
3455 }
3456
3457 throw new NoSuchCategoryException(msg.toString());
3458 }
3459
3460 return assetCategory;
3461 }
3462
3463
3472 public AssetCategory fetchByP_N_V(long parentCategoryId, String name,
3473 long vocabularyId) throws SystemException {
3474 return fetchByP_N_V(parentCategoryId, name, vocabularyId, true);
3475 }
3476
3477
3486 public AssetCategory fetchByP_N_V(long parentCategoryId, String name,
3487 long vocabularyId, boolean retrieveFromCache) throws SystemException {
3488 Object[] finderArgs = new Object[] { parentCategoryId, name, vocabularyId };
3489
3490 Object result = null;
3491
3492 if (retrieveFromCache) {
3493 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_P_N_V,
3494 finderArgs, this);
3495 }
3496
3497 if (result == null) {
3498 StringBundler query = new StringBundler(5);
3499
3500 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
3501
3502 query.append(_FINDER_COLUMN_P_N_V_PARENTCATEGORYID_2);
3503
3504 if (name == null) {
3505 query.append(_FINDER_COLUMN_P_N_V_NAME_1);
3506 }
3507 else {
3508 if (name.equals(StringPool.BLANK)) {
3509 query.append(_FINDER_COLUMN_P_N_V_NAME_3);
3510 }
3511 else {
3512 query.append(_FINDER_COLUMN_P_N_V_NAME_2);
3513 }
3514 }
3515
3516 query.append(_FINDER_COLUMN_P_N_V_VOCABULARYID_2);
3517
3518 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
3519
3520 String sql = query.toString();
3521
3522 Session session = null;
3523
3524 try {
3525 session = openSession();
3526
3527 Query q = session.createQuery(sql);
3528
3529 QueryPos qPos = QueryPos.getInstance(q);
3530
3531 qPos.add(parentCategoryId);
3532
3533 if (name != null) {
3534 qPos.add(name);
3535 }
3536
3537 qPos.add(vocabularyId);
3538
3539 List<AssetCategory> list = q.list();
3540
3541 result = list;
3542
3543 AssetCategory assetCategory = null;
3544
3545 if (list.isEmpty()) {
3546 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_P_N_V,
3547 finderArgs, list);
3548 }
3549 else {
3550 assetCategory = list.get(0);
3551
3552 cacheResult(assetCategory);
3553
3554 if ((assetCategory.getParentCategoryId() != parentCategoryId) ||
3555 (assetCategory.getName() == null) ||
3556 !assetCategory.getName().equals(name) ||
3557 (assetCategory.getVocabularyId() != vocabularyId)) {
3558 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_P_N_V,
3559 finderArgs, assetCategory);
3560 }
3561 }
3562
3563 return assetCategory;
3564 }
3565 catch (Exception e) {
3566 throw processException(e);
3567 }
3568 finally {
3569 if (result == null) {
3570 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_P_N_V,
3571 finderArgs);
3572 }
3573
3574 closeSession(session);
3575 }
3576 }
3577 else {
3578 if (result instanceof List<?>) {
3579 return null;
3580 }
3581 else {
3582 return (AssetCategory)result;
3583 }
3584 }
3585 }
3586
3587
3593 public List<AssetCategory> findAll() throws SystemException {
3594 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
3595 }
3596
3597
3609 public List<AssetCategory> findAll(int start, int end)
3610 throws SystemException {
3611 return findAll(start, end, null);
3612 }
3613
3614
3627 public List<AssetCategory> findAll(int start, int end,
3628 OrderByComparator orderByComparator) throws SystemException {
3629 Object[] finderArgs = new Object[] {
3630 String.valueOf(start), String.valueOf(end),
3631 String.valueOf(orderByComparator)
3632 };
3633
3634 List<AssetCategory> list = (List<AssetCategory>)FinderCacheUtil.getResult(FINDER_PATH_FIND_ALL,
3635 finderArgs, this);
3636
3637 if (list == null) {
3638 StringBundler query = null;
3639 String sql = null;
3640
3641 if (orderByComparator != null) {
3642 query = new StringBundler(2 +
3643 (orderByComparator.getOrderByFields().length * 3));
3644
3645 query.append(_SQL_SELECT_ASSETCATEGORY);
3646
3647 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3648 orderByComparator);
3649
3650 sql = query.toString();
3651 }
3652 else {
3653 sql = _SQL_SELECT_ASSETCATEGORY.concat(AssetCategoryModelImpl.ORDER_BY_JPQL);
3654 }
3655
3656 Session session = null;
3657
3658 try {
3659 session = openSession();
3660
3661 Query q = session.createQuery(sql);
3662
3663 if (orderByComparator == null) {
3664 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
3665 start, end, false);
3666
3667 Collections.sort(list);
3668 }
3669 else {
3670 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
3671 start, end);
3672 }
3673 }
3674 catch (Exception e) {
3675 throw processException(e);
3676 }
3677 finally {
3678 if (list == null) {
3679 FinderCacheUtil.removeResult(FINDER_PATH_FIND_ALL,
3680 finderArgs);
3681 }
3682 else {
3683 cacheResult(list);
3684
3685 FinderCacheUtil.putResult(FINDER_PATH_FIND_ALL, finderArgs,
3686 list);
3687 }
3688
3689 closeSession(session);
3690 }
3691 }
3692
3693 return list;
3694 }
3695
3696
3702 public void removeByUuid(String uuid) throws SystemException {
3703 for (AssetCategory assetCategory : findByUuid(uuid)) {
3704 remove(assetCategory);
3705 }
3706 }
3707
3708
3715 public void removeByUUID_G(String uuid, long groupId)
3716 throws NoSuchCategoryException, SystemException {
3717 AssetCategory assetCategory = findByUUID_G(uuid, groupId);
3718
3719 remove(assetCategory);
3720 }
3721
3722
3728 public void removeByGroupId(long groupId) throws SystemException {
3729 for (AssetCategory assetCategory : findByGroupId(groupId)) {
3730 remove(assetCategory);
3731 }
3732 }
3733
3734
3740 public void removeByParentCategoryId(long parentCategoryId)
3741 throws SystemException {
3742 for (AssetCategory assetCategory : findByParentCategoryId(
3743 parentCategoryId)) {
3744 remove(assetCategory);
3745 }
3746 }
3747
3748
3754 public void removeByVocabularyId(long vocabularyId)
3755 throws SystemException {
3756 for (AssetCategory assetCategory : findByVocabularyId(vocabularyId)) {
3757 remove(assetCategory);
3758 }
3759 }
3760
3761
3768 public void removeByP_N(long parentCategoryId, String name)
3769 throws SystemException {
3770 for (AssetCategory assetCategory : findByP_N(parentCategoryId, name)) {
3771 remove(assetCategory);
3772 }
3773 }
3774
3775
3782 public void removeByP_V(long parentCategoryId, long vocabularyId)
3783 throws SystemException {
3784 for (AssetCategory assetCategory : findByP_V(parentCategoryId,
3785 vocabularyId)) {
3786 remove(assetCategory);
3787 }
3788 }
3789
3790
3797 public void removeByN_V(String name, long vocabularyId)
3798 throws SystemException {
3799 for (AssetCategory assetCategory : findByN_V(name, vocabularyId)) {
3800 remove(assetCategory);
3801 }
3802 }
3803
3804
3812 public void removeByP_N_V(long parentCategoryId, String name,
3813 long vocabularyId) throws NoSuchCategoryException, SystemException {
3814 AssetCategory assetCategory = findByP_N_V(parentCategoryId, name,
3815 vocabularyId);
3816
3817 remove(assetCategory);
3818 }
3819
3820
3825 public void removeAll() throws SystemException {
3826 for (AssetCategory assetCategory : findAll()) {
3827 remove(assetCategory);
3828 }
3829 }
3830
3831
3838 public int countByUuid(String uuid) throws SystemException {
3839 Object[] finderArgs = new Object[] { uuid };
3840
3841 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID,
3842 finderArgs, this);
3843
3844 if (count == null) {
3845 StringBundler query = new StringBundler(2);
3846
3847 query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
3848
3849 if (uuid == null) {
3850 query.append(_FINDER_COLUMN_UUID_UUID_1);
3851 }
3852 else {
3853 if (uuid.equals(StringPool.BLANK)) {
3854 query.append(_FINDER_COLUMN_UUID_UUID_3);
3855 }
3856 else {
3857 query.append(_FINDER_COLUMN_UUID_UUID_2);
3858 }
3859 }
3860
3861 String sql = query.toString();
3862
3863 Session session = null;
3864
3865 try {
3866 session = openSession();
3867
3868 Query q = session.createQuery(sql);
3869
3870 QueryPos qPos = QueryPos.getInstance(q);
3871
3872 if (uuid != null) {
3873 qPos.add(uuid);
3874 }
3875
3876 count = (Long)q.uniqueResult();
3877 }
3878 catch (Exception e) {
3879 throw processException(e);
3880 }
3881 finally {
3882 if (count == null) {
3883 count = Long.valueOf(0);
3884 }
3885
3886 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID,
3887 finderArgs, count);
3888
3889 closeSession(session);
3890 }
3891 }
3892
3893 return count.intValue();
3894 }
3895
3896
3904 public int countByUUID_G(String uuid, long groupId)
3905 throws SystemException {
3906 Object[] finderArgs = new Object[] { uuid, groupId };
3907
3908 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID_G,
3909 finderArgs, this);
3910
3911 if (count == null) {
3912 StringBundler query = new StringBundler(3);
3913
3914 query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
3915
3916 if (uuid == null) {
3917 query.append(_FINDER_COLUMN_UUID_G_UUID_1);
3918 }
3919 else {
3920 if (uuid.equals(StringPool.BLANK)) {
3921 query.append(_FINDER_COLUMN_UUID_G_UUID_3);
3922 }
3923 else {
3924 query.append(_FINDER_COLUMN_UUID_G_UUID_2);
3925 }
3926 }
3927
3928 query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
3929
3930 String sql = query.toString();
3931
3932 Session session = null;
3933
3934 try {
3935 session = openSession();
3936
3937 Query q = session.createQuery(sql);
3938
3939 QueryPos qPos = QueryPos.getInstance(q);
3940
3941 if (uuid != null) {
3942 qPos.add(uuid);
3943 }
3944
3945 qPos.add(groupId);
3946
3947 count = (Long)q.uniqueResult();
3948 }
3949 catch (Exception e) {
3950 throw processException(e);
3951 }
3952 finally {
3953 if (count == null) {
3954 count = Long.valueOf(0);
3955 }
3956
3957 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G,
3958 finderArgs, count);
3959
3960 closeSession(session);
3961 }
3962 }
3963
3964 return count.intValue();
3965 }
3966
3967
3974 public int countByGroupId(long groupId) throws SystemException {
3975 Object[] finderArgs = new Object[] { groupId };
3976
3977 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_GROUPID,
3978 finderArgs, this);
3979
3980 if (count == null) {
3981 StringBundler query = new StringBundler(2);
3982
3983 query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
3984
3985 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
3986
3987 String sql = query.toString();
3988
3989 Session session = null;
3990
3991 try {
3992 session = openSession();
3993
3994 Query q = session.createQuery(sql);
3995
3996 QueryPos qPos = QueryPos.getInstance(q);
3997
3998 qPos.add(groupId);
3999
4000 count = (Long)q.uniqueResult();
4001 }
4002 catch (Exception e) {
4003 throw processException(e);
4004 }
4005 finally {
4006 if (count == null) {
4007 count = Long.valueOf(0);
4008 }
4009
4010 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_GROUPID,
4011 finderArgs, count);
4012
4013 closeSession(session);
4014 }
4015 }
4016
4017 return count.intValue();
4018 }
4019
4020
4027 public int filterCountByGroupId(long groupId) throws SystemException {
4028 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
4029 return countByGroupId(groupId);
4030 }
4031
4032 StringBundler query = new StringBundler(2);
4033
4034 query.append(_FILTER_SQL_COUNT_ASSETCATEGORY_WHERE);
4035
4036 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
4037
4038 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
4039 AssetCategory.class.getName(), _FILTER_COLUMN_PK,
4040 _FILTER_COLUMN_USERID, groupId);
4041
4042 Session session = null;
4043
4044 try {
4045 session = openSession();
4046
4047 SQLQuery q = session.createSQLQuery(sql);
4048
4049 q.addScalar(COUNT_COLUMN_NAME,
4050 com.liferay.portal.kernel.dao.orm.Type.LONG);
4051
4052 QueryPos qPos = QueryPos.getInstance(q);
4053
4054 qPos.add(groupId);
4055
4056 Long count = (Long)q.uniqueResult();
4057
4058 return count.intValue();
4059 }
4060 catch (Exception e) {
4061 throw processException(e);
4062 }
4063 finally {
4064 closeSession(session);
4065 }
4066 }
4067
4068
4075 public int countByParentCategoryId(long parentCategoryId)
4076 throws SystemException {
4077 Object[] finderArgs = new Object[] { parentCategoryId };
4078
4079 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_PARENTCATEGORYID,
4080 finderArgs, this);
4081
4082 if (count == null) {
4083 StringBundler query = new StringBundler(2);
4084
4085 query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
4086
4087 query.append(_FINDER_COLUMN_PARENTCATEGORYID_PARENTCATEGORYID_2);
4088
4089 String sql = query.toString();
4090
4091 Session session = null;
4092
4093 try {
4094 session = openSession();
4095
4096 Query q = session.createQuery(sql);
4097
4098 QueryPos qPos = QueryPos.getInstance(q);
4099
4100 qPos.add(parentCategoryId);
4101
4102 count = (Long)q.uniqueResult();
4103 }
4104 catch (Exception e) {
4105 throw processException(e);
4106 }
4107 finally {
4108 if (count == null) {
4109 count = Long.valueOf(0);
4110 }
4111
4112 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_PARENTCATEGORYID,
4113 finderArgs, count);
4114
4115 closeSession(session);
4116 }
4117 }
4118
4119 return count.intValue();
4120 }
4121
4122
4129 public int countByVocabularyId(long vocabularyId) throws SystemException {
4130 Object[] finderArgs = new Object[] { vocabularyId };
4131
4132 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_VOCABULARYID,
4133 finderArgs, this);
4134
4135 if (count == null) {
4136 StringBundler query = new StringBundler(2);
4137
4138 query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
4139
4140 query.append(_FINDER_COLUMN_VOCABULARYID_VOCABULARYID_2);
4141
4142 String sql = query.toString();
4143
4144 Session session = null;
4145
4146 try {
4147 session = openSession();
4148
4149 Query q = session.createQuery(sql);
4150
4151 QueryPos qPos = QueryPos.getInstance(q);
4152
4153 qPos.add(vocabularyId);
4154
4155 count = (Long)q.uniqueResult();
4156 }
4157 catch (Exception e) {
4158 throw processException(e);
4159 }
4160 finally {
4161 if (count == null) {
4162 count = Long.valueOf(0);
4163 }
4164
4165 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_VOCABULARYID,
4166 finderArgs, count);
4167
4168 closeSession(session);
4169 }
4170 }
4171
4172 return count.intValue();
4173 }
4174
4175
4183 public int countByP_N(long parentCategoryId, String name)
4184 throws SystemException {
4185 Object[] finderArgs = new Object[] { parentCategoryId, name };
4186
4187 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_P_N,
4188 finderArgs, this);
4189
4190 if (count == null) {
4191 StringBundler query = new StringBundler(3);
4192
4193 query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
4194
4195 query.append(_FINDER_COLUMN_P_N_PARENTCATEGORYID_2);
4196
4197 if (name == null) {
4198 query.append(_FINDER_COLUMN_P_N_NAME_1);
4199 }
4200 else {
4201 if (name.equals(StringPool.BLANK)) {
4202 query.append(_FINDER_COLUMN_P_N_NAME_3);
4203 }
4204 else {
4205 query.append(_FINDER_COLUMN_P_N_NAME_2);
4206 }
4207 }
4208
4209 String sql = query.toString();
4210
4211 Session session = null;
4212
4213 try {
4214 session = openSession();
4215
4216 Query q = session.createQuery(sql);
4217
4218 QueryPos qPos = QueryPos.getInstance(q);
4219
4220 qPos.add(parentCategoryId);
4221
4222 if (name != null) {
4223 qPos.add(name);
4224 }
4225
4226 count = (Long)q.uniqueResult();
4227 }
4228 catch (Exception e) {
4229 throw processException(e);
4230 }
4231 finally {
4232 if (count == null) {
4233 count = Long.valueOf(0);
4234 }
4235
4236 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_P_N, finderArgs,
4237 count);
4238
4239 closeSession(session);
4240 }
4241 }
4242
4243 return count.intValue();
4244 }
4245
4246
4254 public int countByP_V(long parentCategoryId, long vocabularyId)
4255 throws SystemException {
4256 Object[] finderArgs = new Object[] { parentCategoryId, vocabularyId };
4257
4258 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_P_V,
4259 finderArgs, this);
4260
4261 if (count == null) {
4262 StringBundler query = new StringBundler(3);
4263
4264 query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
4265
4266 query.append(_FINDER_COLUMN_P_V_PARENTCATEGORYID_2);
4267
4268 query.append(_FINDER_COLUMN_P_V_VOCABULARYID_2);
4269
4270 String sql = query.toString();
4271
4272 Session session = null;
4273
4274 try {
4275 session = openSession();
4276
4277 Query q = session.createQuery(sql);
4278
4279 QueryPos qPos = QueryPos.getInstance(q);
4280
4281 qPos.add(parentCategoryId);
4282
4283 qPos.add(vocabularyId);
4284
4285 count = (Long)q.uniqueResult();
4286 }
4287 catch (Exception e) {
4288 throw processException(e);
4289 }
4290 finally {
4291 if (count == null) {
4292 count = Long.valueOf(0);
4293 }
4294
4295 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_P_V, finderArgs,
4296 count);
4297
4298 closeSession(session);
4299 }
4300 }
4301
4302 return count.intValue();
4303 }
4304
4305
4313 public int countByN_V(String name, long vocabularyId)
4314 throws SystemException {
4315 Object[] finderArgs = new Object[] { name, vocabularyId };
4316
4317 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_N_V,
4318 finderArgs, this);
4319
4320 if (count == null) {
4321 StringBundler query = new StringBundler(3);
4322
4323 query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
4324
4325 if (name == null) {
4326 query.append(_FINDER_COLUMN_N_V_NAME_1);
4327 }
4328 else {
4329 if (name.equals(StringPool.BLANK)) {
4330 query.append(_FINDER_COLUMN_N_V_NAME_3);
4331 }
4332 else {
4333 query.append(_FINDER_COLUMN_N_V_NAME_2);
4334 }
4335 }
4336
4337 query.append(_FINDER_COLUMN_N_V_VOCABULARYID_2);
4338
4339 String sql = query.toString();
4340
4341 Session session = null;
4342
4343 try {
4344 session = openSession();
4345
4346 Query q = session.createQuery(sql);
4347
4348 QueryPos qPos = QueryPos.getInstance(q);
4349
4350 if (name != null) {
4351 qPos.add(name);
4352 }
4353
4354 qPos.add(vocabularyId);
4355
4356 count = (Long)q.uniqueResult();
4357 }
4358 catch (Exception e) {
4359 throw processException(e);
4360 }
4361 finally {
4362 if (count == null) {
4363 count = Long.valueOf(0);
4364 }
4365
4366 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_N_V, finderArgs,
4367 count);
4368
4369 closeSession(session);
4370 }
4371 }
4372
4373 return count.intValue();
4374 }
4375
4376
4385 public int countByP_N_V(long parentCategoryId, String name,
4386 long vocabularyId) throws SystemException {
4387 Object[] finderArgs = new Object[] { parentCategoryId, name, vocabularyId };
4388
4389 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_P_N_V,
4390 finderArgs, this);
4391
4392 if (count == null) {
4393 StringBundler query = new StringBundler(4);
4394
4395 query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
4396
4397 query.append(_FINDER_COLUMN_P_N_V_PARENTCATEGORYID_2);
4398
4399 if (name == null) {
4400 query.append(_FINDER_COLUMN_P_N_V_NAME_1);
4401 }
4402 else {
4403 if (name.equals(StringPool.BLANK)) {
4404 query.append(_FINDER_COLUMN_P_N_V_NAME_3);
4405 }
4406 else {
4407 query.append(_FINDER_COLUMN_P_N_V_NAME_2);
4408 }
4409 }
4410
4411 query.append(_FINDER_COLUMN_P_N_V_VOCABULARYID_2);
4412
4413 String sql = query.toString();
4414
4415 Session session = null;
4416
4417 try {
4418 session = openSession();
4419
4420 Query q = session.createQuery(sql);
4421
4422 QueryPos qPos = QueryPos.getInstance(q);
4423
4424 qPos.add(parentCategoryId);
4425
4426 if (name != null) {
4427 qPos.add(name);
4428 }
4429
4430 qPos.add(vocabularyId);
4431
4432 count = (Long)q.uniqueResult();
4433 }
4434 catch (Exception e) {
4435 throw processException(e);
4436 }
4437 finally {
4438 if (count == null) {
4439 count = Long.valueOf(0);
4440 }
4441
4442 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_P_N_V,
4443 finderArgs, count);
4444
4445 closeSession(session);
4446 }
4447 }
4448
4449 return count.intValue();
4450 }
4451
4452
4458 public int countAll() throws SystemException {
4459 Object[] finderArgs = new Object[0];
4460
4461 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
4462 finderArgs, this);
4463
4464 if (count == null) {
4465 Session session = null;
4466
4467 try {
4468 session = openSession();
4469
4470 Query q = session.createQuery(_SQL_COUNT_ASSETCATEGORY);
4471
4472 count = (Long)q.uniqueResult();
4473 }
4474 catch (Exception e) {
4475 throw processException(e);
4476 }
4477 finally {
4478 if (count == null) {
4479 count = Long.valueOf(0);
4480 }
4481
4482 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL, finderArgs,
4483 count);
4484
4485 closeSession(session);
4486 }
4487 }
4488
4489 return count.intValue();
4490 }
4491
4492
4499 public List<com.liferay.portlet.asset.model.AssetEntry> getAssetEntries(
4500 long pk) throws SystemException {
4501 return getAssetEntries(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
4502 }
4503
4504
4517 public List<com.liferay.portlet.asset.model.AssetEntry> getAssetEntries(
4518 long pk, int start, int end) throws SystemException {
4519 return getAssetEntries(pk, start, end, null);
4520 }
4521
4522 public static final FinderPath FINDER_PATH_GET_ASSETENTRIES = new FinderPath(com.liferay.portlet.asset.model.impl.AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
4523 AssetCategoryModelImpl.FINDER_CACHE_ENABLED_ASSETENTRIES_ASSETCATEGORIES,
4524 AssetCategoryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME,
4525 "getAssetEntries",
4526 new String[] {
4527 Long.class.getName(), "java.lang.Integer", "java.lang.Integer",
4528 "com.liferay.portal.kernel.util.OrderByComparator"
4529 });
4530
4531
4545 public List<com.liferay.portlet.asset.model.AssetEntry> getAssetEntries(
4546 long pk, int start, int end, OrderByComparator orderByComparator)
4547 throws SystemException {
4548 Object[] finderArgs = new Object[] {
4549 pk, String.valueOf(start), String.valueOf(end),
4550 String.valueOf(orderByComparator)
4551 };
4552
4553 List<com.liferay.portlet.asset.model.AssetEntry> list = (List<com.liferay.portlet.asset.model.AssetEntry>)FinderCacheUtil.getResult(FINDER_PATH_GET_ASSETENTRIES,
4554 finderArgs, this);
4555
4556 if (list == null) {
4557 Session session = null;
4558
4559 try {
4560 session = openSession();
4561
4562 String sql = null;
4563
4564 if (orderByComparator != null) {
4565 sql = _SQL_GETASSETENTRIES.concat(ORDER_BY_CLAUSE)
4566 .concat(orderByComparator.getOrderBy());
4567 }
4568 else {
4569 sql = _SQL_GETASSETENTRIES;
4570 }
4571
4572 SQLQuery q = session.createSQLQuery(sql);
4573
4574 q.addEntity("AssetEntry",
4575 com.liferay.portlet.asset.model.impl.AssetEntryImpl.class);
4576
4577 QueryPos qPos = QueryPos.getInstance(q);
4578
4579 qPos.add(pk);
4580
4581 list = (List<com.liferay.portlet.asset.model.AssetEntry>)QueryUtil.list(q,
4582 getDialect(), start, end);
4583 }
4584 catch (Exception e) {
4585 throw processException(e);
4586 }
4587 finally {
4588 if (list == null) {
4589 FinderCacheUtil.removeResult(FINDER_PATH_GET_ASSETENTRIES,
4590 finderArgs);
4591 }
4592 else {
4593 assetEntryPersistence.cacheResult(list);
4594
4595 FinderCacheUtil.putResult(FINDER_PATH_GET_ASSETENTRIES,
4596 finderArgs, list);
4597 }
4598
4599 closeSession(session);
4600 }
4601 }
4602
4603 return list;
4604 }
4605
4606 public static final FinderPath FINDER_PATH_GET_ASSETENTRIES_SIZE = new FinderPath(com.liferay.portlet.asset.model.impl.AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
4607 AssetCategoryModelImpl.FINDER_CACHE_ENABLED_ASSETENTRIES_ASSETCATEGORIES,
4608 AssetCategoryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME,
4609 "getAssetEntriesSize", new String[] { Long.class.getName() });
4610
4611
4618 public int getAssetEntriesSize(long pk) throws SystemException {
4619 Object[] finderArgs = new Object[] { pk };
4620
4621 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_GET_ASSETENTRIES_SIZE,
4622 finderArgs, this);
4623
4624 if (count == null) {
4625 Session session = null;
4626
4627 try {
4628 session = openSession();
4629
4630 SQLQuery q = session.createSQLQuery(_SQL_GETASSETENTRIESSIZE);
4631
4632 q.addScalar(COUNT_COLUMN_NAME,
4633 com.liferay.portal.kernel.dao.orm.Type.LONG);
4634
4635 QueryPos qPos = QueryPos.getInstance(q);
4636
4637 qPos.add(pk);
4638
4639 count = (Long)q.uniqueResult();
4640 }
4641 catch (Exception e) {
4642 throw processException(e);
4643 }
4644 finally {
4645 if (count == null) {
4646 count = Long.valueOf(0);
4647 }
4648
4649 FinderCacheUtil.putResult(FINDER_PATH_GET_ASSETENTRIES_SIZE,
4650 finderArgs, count);
4651
4652 closeSession(session);
4653 }
4654 }
4655
4656 return count.intValue();
4657 }
4658
4659 public static final FinderPath FINDER_PATH_CONTAINS_ASSETENTRY = new FinderPath(com.liferay.portlet.asset.model.impl.AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
4660 AssetCategoryModelImpl.FINDER_CACHE_ENABLED_ASSETENTRIES_ASSETCATEGORIES,
4661 AssetCategoryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME,
4662 "containsAssetEntry",
4663 new String[] { Long.class.getName(), Long.class.getName() });
4664
4665
4673 public boolean containsAssetEntry(long pk, long assetEntryPK)
4674 throws SystemException {
4675 Object[] finderArgs = new Object[] { pk, assetEntryPK };
4676
4677 Boolean value = (Boolean)FinderCacheUtil.getResult(FINDER_PATH_CONTAINS_ASSETENTRY,
4678 finderArgs, this);
4679
4680 if (value == null) {
4681 try {
4682 value = Boolean.valueOf(containsAssetEntry.contains(pk,
4683 assetEntryPK));
4684 }
4685 catch (Exception e) {
4686 throw processException(e);
4687 }
4688 finally {
4689 if (value == null) {
4690 value = Boolean.FALSE;
4691 }
4692
4693 FinderCacheUtil.putResult(FINDER_PATH_CONTAINS_ASSETENTRY,
4694 finderArgs, value);
4695 }
4696 }
4697
4698 return value.booleanValue();
4699 }
4700
4701
4708 public boolean containsAssetEntries(long pk) throws SystemException {
4709 if (getAssetEntriesSize(pk) > 0) {
4710 return true;
4711 }
4712 else {
4713 return false;
4714 }
4715 }
4716
4717
4724 public void addAssetEntry(long pk, long assetEntryPK)
4725 throws SystemException {
4726 try {
4727 addAssetEntry.add(pk, assetEntryPK);
4728 }
4729 catch (Exception e) {
4730 throw processException(e);
4731 }
4732 finally {
4733 FinderCacheUtil.clearCache(AssetCategoryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
4734 }
4735 }
4736
4737
4744 public void addAssetEntry(long pk,
4745 com.liferay.portlet.asset.model.AssetEntry assetEntry)
4746 throws SystemException {
4747 try {
4748 addAssetEntry.add(pk, assetEntry.getPrimaryKey());
4749 }
4750 catch (Exception e) {
4751 throw processException(e);
4752 }
4753 finally {
4754 FinderCacheUtil.clearCache(AssetCategoryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
4755 }
4756 }
4757
4758
4765 public void addAssetEntries(long pk, long[] assetEntryPKs)
4766 throws SystemException {
4767 try {
4768 for (long assetEntryPK : assetEntryPKs) {
4769 addAssetEntry.add(pk, assetEntryPK);
4770 }
4771 }
4772 catch (Exception e) {
4773 throw processException(e);
4774 }
4775 finally {
4776 FinderCacheUtil.clearCache(AssetCategoryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
4777 }
4778 }
4779
4780
4787 public void addAssetEntries(long pk,
4788 List<com.liferay.portlet.asset.model.AssetEntry> assetEntries)
4789 throws SystemException {
4790 try {
4791 for (com.liferay.portlet.asset.model.AssetEntry assetEntry : assetEntries) {
4792 addAssetEntry.add(pk, assetEntry.getPrimaryKey());
4793 }
4794 }
4795 catch (Exception e) {
4796 throw processException(e);
4797 }
4798 finally {
4799 FinderCacheUtil.clearCache(AssetCategoryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
4800 }
4801 }
4802
4803
4809 public void clearAssetEntries(long pk) throws SystemException {
4810 try {
4811 clearAssetEntries.clear(pk);
4812 }
4813 catch (Exception e) {
4814 throw processException(e);
4815 }
4816 finally {
4817 FinderCacheUtil.clearCache(AssetCategoryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
4818 }
4819 }
4820
4821
4828 public void removeAssetEntry(long pk, long assetEntryPK)
4829 throws SystemException {
4830 try {
4831 removeAssetEntry.remove(pk, assetEntryPK);
4832 }
4833 catch (Exception e) {
4834 throw processException(e);
4835 }
4836 finally {
4837 FinderCacheUtil.clearCache(AssetCategoryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
4838 }
4839 }
4840
4841
4848 public void removeAssetEntry(long pk,
4849 com.liferay.portlet.asset.model.AssetEntry assetEntry)
4850 throws SystemException {
4851 try {
4852 removeAssetEntry.remove(pk, assetEntry.getPrimaryKey());
4853 }
4854 catch (Exception e) {
4855 throw processException(e);
4856 }
4857 finally {
4858 FinderCacheUtil.clearCache(AssetCategoryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
4859 }
4860 }
4861
4862
4869 public void removeAssetEntries(long pk, long[] assetEntryPKs)
4870 throws SystemException {
4871 try {
4872 for (long assetEntryPK : assetEntryPKs) {
4873 removeAssetEntry.remove(pk, assetEntryPK);
4874 }
4875 }
4876 catch (Exception e) {
4877 throw processException(e);
4878 }
4879 finally {
4880 FinderCacheUtil.clearCache(AssetCategoryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
4881 }
4882 }
4883
4884
4891 public void removeAssetEntries(long pk,
4892 List<com.liferay.portlet.asset.model.AssetEntry> assetEntries)
4893 throws SystemException {
4894 try {
4895 for (com.liferay.portlet.asset.model.AssetEntry assetEntry : assetEntries) {
4896 removeAssetEntry.remove(pk, assetEntry.getPrimaryKey());
4897 }
4898 }
4899 catch (Exception e) {
4900 throw processException(e);
4901 }
4902 finally {
4903 FinderCacheUtil.clearCache(AssetCategoryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
4904 }
4905 }
4906
4907
4914 public void setAssetEntries(long pk, long[] assetEntryPKs)
4915 throws SystemException {
4916 try {
4917 Set<Long> assetEntryPKSet = SetUtil.fromArray(assetEntryPKs);
4918
4919 List<com.liferay.portlet.asset.model.AssetEntry> assetEntries = getAssetEntries(pk);
4920
4921 for (com.liferay.portlet.asset.model.AssetEntry assetEntry : assetEntries) {
4922 if (!assetEntryPKSet.remove(assetEntry.getPrimaryKey())) {
4923 removeAssetEntry.remove(pk, assetEntry.getPrimaryKey());
4924 }
4925 }
4926
4927 for (Long assetEntryPK : assetEntryPKSet) {
4928 addAssetEntry.add(pk, assetEntryPK);
4929 }
4930 }
4931 catch (Exception e) {
4932 throw processException(e);
4933 }
4934 finally {
4935 FinderCacheUtil.clearCache(AssetCategoryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
4936 }
4937 }
4938
4939
4946 public void setAssetEntries(long pk,
4947 List<com.liferay.portlet.asset.model.AssetEntry> assetEntries)
4948 throws SystemException {
4949 try {
4950 long[] assetEntryPKs = new long[assetEntries.size()];
4951
4952 for (int i = 0; i < assetEntries.size(); i++) {
4953 com.liferay.portlet.asset.model.AssetEntry assetEntry = assetEntries.get(i);
4954
4955 assetEntryPKs[i] = assetEntry.getPrimaryKey();
4956 }
4957
4958 setAssetEntries(pk, assetEntryPKs);
4959 }
4960 catch (Exception e) {
4961 throw processException(e);
4962 }
4963 finally {
4964 FinderCacheUtil.clearCache(AssetCategoryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
4965 }
4966 }
4967
4968
4978 public void rebuildTree(long groupId, boolean force)
4979 throws SystemException {
4980 if (force || (countOrphanTreeNodes(groupId) > 0)) {
4981 rebuildTree(groupId, 0, 1);
4982
4983 CacheRegistryUtil.clear(AssetCategoryImpl.class.getName());
4984 EntityCacheUtil.clearCache(AssetCategoryImpl.class.getName());
4985 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
4986 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
4987 }
4988 }
4989
4990 protected long countOrphanTreeNodes(long groupId) throws SystemException {
4991 Session session = null;
4992
4993 try {
4994 session = openSession();
4995
4996 SQLQuery q = session.createSQLQuery(
4997 "SELECT COUNT(*) AS COUNT_VALUE FROM AssetCategory WHERE groupId = ? AND (leftCategoryId = 0 OR leftCategoryId IS NULL OR rightCategoryId = 0 OR rightCategoryId IS NULL)");
4998
4999 q.addScalar(COUNT_COLUMN_NAME,
5000 com.liferay.portal.kernel.dao.orm.Type.LONG);
5001
5002 QueryPos qPos = QueryPos.getInstance(q);
5003
5004 qPos.add(groupId);
5005
5006 return (Long)q.uniqueResult();
5007 }
5008 catch (Exception e) {
5009 throw processException(e);
5010 }
5011 finally {
5012 closeSession(session);
5013 }
5014 }
5015
5016 protected void expandTree(AssetCategory assetCategory)
5017 throws SystemException {
5018 long groupId = assetCategory.getGroupId();
5019
5020 long lastRightCategoryId = getLastRightCategoryId(groupId,
5021 assetCategory.getParentCategoryId());
5022
5023 long leftCategoryId = 2;
5024 long rightCategoryId = 3;
5025
5026 if (lastRightCategoryId > 0) {
5027 leftCategoryId = lastRightCategoryId + 1;
5028 rightCategoryId = lastRightCategoryId + 2;
5029
5030 expandTreeLeftCategoryId.expand(groupId, lastRightCategoryId);
5031 expandTreeRightCategoryId.expand(groupId, lastRightCategoryId);
5032
5033 CacheRegistryUtil.clear(AssetCategoryImpl.class.getName());
5034 EntityCacheUtil.clearCache(AssetCategoryImpl.class.getName());
5035 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
5036 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
5037 }
5038
5039 assetCategory.setLeftCategoryId(leftCategoryId);
5040 assetCategory.setRightCategoryId(rightCategoryId);
5041 }
5042
5043 protected long getLastRightCategoryId(long groupId, long parentCategoryId)
5044 throws SystemException {
5045 Session session = null;
5046
5047 try {
5048 session = openSession();
5049
5050 SQLQuery q = session.createSQLQuery(
5051 "SELECT rightCategoryId FROM AssetCategory WHERE (groupId = ?) AND (parentCategoryId = ?) ORDER BY rightCategoryId DESC");
5052
5053 q.addScalar("rightCategoryId",
5054 com.liferay.portal.kernel.dao.orm.Type.LONG);
5055
5056 QueryPos qPos = QueryPos.getInstance(q);
5057
5058 qPos.add(groupId);
5059 qPos.add(parentCategoryId);
5060
5061 List<Long> list = (List<Long>)QueryUtil.list(q, getDialect(), 0, 1);
5062
5063 if (list.isEmpty()) {
5064 if (parentCategoryId > 0) {
5065 AssetCategory parentAssetCategory = findByPrimaryKey(parentCategoryId);
5066
5067 return parentAssetCategory.getLeftCategoryId();
5068 }
5069
5070 return 0;
5071 }
5072 else {
5073 return list.get(0);
5074 }
5075 }
5076 catch (Exception e) {
5077 throw processException(e);
5078 }
5079 finally {
5080 closeSession(session);
5081 }
5082 }
5083
5084 protected long rebuildTree(long groupId, long parentCategoryId,
5085 long leftCategoryId) throws SystemException {
5086 List<Long> categoryIds = null;
5087
5088 Session session = null;
5089
5090 try {
5091 session = openSession();
5092
5093 SQLQuery q = session.createSQLQuery(
5094 "SELECT categoryId FROM AssetCategory WHERE groupId = ? AND parentCategoryId = ? ORDER BY categoryId ASC");
5095
5096 q.addScalar("categoryId",
5097 com.liferay.portal.kernel.dao.orm.Type.LONG);
5098
5099 QueryPos qPos = QueryPos.getInstance(q);
5100
5101 qPos.add(groupId);
5102 qPos.add(parentCategoryId);
5103
5104 categoryIds = q.list();
5105 }
5106 catch (Exception e) {
5107 throw processException(e);
5108 }
5109 finally {
5110 closeSession(session);
5111 }
5112
5113 long rightCategoryId = leftCategoryId + 1;
5114
5115 for (long categoryId : categoryIds) {
5116 rightCategoryId = rebuildTree(groupId, categoryId, rightCategoryId);
5117 }
5118
5119 if (parentCategoryId > 0) {
5120 updateTree.update(parentCategoryId, leftCategoryId, rightCategoryId);
5121 }
5122
5123 return rightCategoryId + 1;
5124 }
5125
5126 protected void shrinkTree(AssetCategory assetCategory) {
5127 long groupId = assetCategory.getGroupId();
5128
5129 long leftCategoryId = assetCategory.getLeftCategoryId();
5130 long rightCategoryId = assetCategory.getRightCategoryId();
5131
5132 long delta = (rightCategoryId - leftCategoryId) + 1;
5133
5134 shrinkTreeLeftCategoryId.shrink(groupId, rightCategoryId, delta);
5135 shrinkTreeRightCategoryId.shrink(groupId, rightCategoryId, delta);
5136
5137 CacheRegistryUtil.clear(AssetCategoryImpl.class.getName());
5138 EntityCacheUtil.clearCache(AssetCategoryImpl.class.getName());
5139 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
5140 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
5141 }
5142
5143
5146 public void afterPropertiesSet() {
5147 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
5148 com.liferay.portal.util.PropsUtil.get(
5149 "value.object.listener.com.liferay.portlet.asset.model.AssetCategory")));
5150
5151 if (listenerClassNames.length > 0) {
5152 try {
5153 List<ModelListener<AssetCategory>> listenersList = new ArrayList<ModelListener<AssetCategory>>();
5154
5155 for (String listenerClassName : listenerClassNames) {
5156 listenersList.add((ModelListener<AssetCategory>)InstanceFactory.newInstance(
5157 listenerClassName));
5158 }
5159
5160 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
5161 }
5162 catch (Exception e) {
5163 _log.error(e);
5164 }
5165 }
5166
5167 containsAssetEntry = new ContainsAssetEntry(this);
5168
5169 addAssetEntry = new AddAssetEntry(this);
5170 clearAssetEntries = new ClearAssetEntries(this);
5171 removeAssetEntry = new RemoveAssetEntry(this);
5172
5173 expandTreeLeftCategoryId = new ExpandTreeLeftCategoryId();
5174 expandTreeRightCategoryId = new ExpandTreeRightCategoryId();
5175 shrinkTreeLeftCategoryId = new ShrinkTreeLeftCategoryId();
5176 shrinkTreeRightCategoryId = new ShrinkTreeRightCategoryId();
5177 updateTree = new UpdateTree();
5178 }
5179
5180 public void destroy() {
5181 EntityCacheUtil.removeCache(AssetCategoryImpl.class.getName());
5182 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
5183 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST);
5184 }
5185
5186 @BeanReference(type = AssetCategoryPersistence.class)
5187 protected AssetCategoryPersistence assetCategoryPersistence;
5188 @BeanReference(type = AssetCategoryPropertyPersistence.class)
5189 protected AssetCategoryPropertyPersistence assetCategoryPropertyPersistence;
5190 @BeanReference(type = AssetEntryPersistence.class)
5191 protected AssetEntryPersistence assetEntryPersistence;
5192 @BeanReference(type = AssetLinkPersistence.class)
5193 protected AssetLinkPersistence assetLinkPersistence;
5194 @BeanReference(type = AssetTagPersistence.class)
5195 protected AssetTagPersistence assetTagPersistence;
5196 @BeanReference(type = AssetTagPropertyPersistence.class)
5197 protected AssetTagPropertyPersistence assetTagPropertyPersistence;
5198 @BeanReference(type = AssetTagStatsPersistence.class)
5199 protected AssetTagStatsPersistence assetTagStatsPersistence;
5200 @BeanReference(type = AssetVocabularyPersistence.class)
5201 protected AssetVocabularyPersistence assetVocabularyPersistence;
5202 @BeanReference(type = ResourcePersistence.class)
5203 protected ResourcePersistence resourcePersistence;
5204 @BeanReference(type = UserPersistence.class)
5205 protected UserPersistence userPersistence;
5206 protected ContainsAssetEntry containsAssetEntry;
5207 protected AddAssetEntry addAssetEntry;
5208 protected ClearAssetEntries clearAssetEntries;
5209 protected RemoveAssetEntry removeAssetEntry;
5210
5211 protected class ContainsAssetEntry {
5212 protected ContainsAssetEntry(
5213 AssetCategoryPersistenceImpl persistenceImpl) {
5214 super();
5215
5216 _mappingSqlQuery = MappingSqlQueryFactoryUtil.getMappingSqlQuery(getDataSource(),
5217 _SQL_CONTAINSASSETENTRY,
5218 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT },
5219 RowMapper.COUNT);
5220 }
5221
5222 protected boolean contains(long categoryId, long entryId) {
5223 List<Integer> results = _mappingSqlQuery.execute(new Object[] {
5224 new Long(categoryId), new Long(entryId)
5225 });
5226
5227 if (results.size() > 0) {
5228 Integer count = results.get(0);
5229
5230 if (count.intValue() > 0) {
5231 return true;
5232 }
5233 }
5234
5235 return false;
5236 }
5237
5238 private MappingSqlQuery<Integer> _mappingSqlQuery;
5239 }
5240
5241 protected class AddAssetEntry {
5242 protected AddAssetEntry(AssetCategoryPersistenceImpl persistenceImpl) {
5243 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
5244 "INSERT INTO AssetEntries_AssetCategories (categoryId, entryId) VALUES (?, ?)",
5245 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
5246 _persistenceImpl = persistenceImpl;
5247 }
5248
5249 protected void add(long categoryId, long entryId)
5250 throws SystemException {
5251 if (!_persistenceImpl.containsAssetEntry.contains(categoryId,
5252 entryId)) {
5253 ModelListener<com.liferay.portlet.asset.model.AssetEntry>[] assetEntryListeners =
5254 assetEntryPersistence.getListeners();
5255
5256 for (ModelListener<AssetCategory> listener : listeners) {
5257 listener.onBeforeAddAssociation(categoryId,
5258 com.liferay.portlet.asset.model.AssetEntry.class.getName(),
5259 entryId);
5260 }
5261
5262 for (ModelListener<com.liferay.portlet.asset.model.AssetEntry> listener : assetEntryListeners) {
5263 listener.onBeforeAddAssociation(entryId,
5264 AssetCategory.class.getName(), categoryId);
5265 }
5266
5267 _sqlUpdate.update(new Object[] {
5268 new Long(categoryId), new Long(entryId)
5269 });
5270
5271 for (ModelListener<AssetCategory> listener : listeners) {
5272 listener.onAfterAddAssociation(categoryId,
5273 com.liferay.portlet.asset.model.AssetEntry.class.getName(),
5274 entryId);
5275 }
5276
5277 for (ModelListener<com.liferay.portlet.asset.model.AssetEntry> listener : assetEntryListeners) {
5278 listener.onAfterAddAssociation(entryId,
5279 AssetCategory.class.getName(), categoryId);
5280 }
5281 }
5282 }
5283
5284 private SqlUpdate _sqlUpdate;
5285 private AssetCategoryPersistenceImpl _persistenceImpl;
5286 }
5287
5288 protected class ClearAssetEntries {
5289 protected ClearAssetEntries(
5290 AssetCategoryPersistenceImpl persistenceImpl) {
5291 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
5292 "DELETE FROM AssetEntries_AssetCategories WHERE categoryId = ?",
5293 new int[] { java.sql.Types.BIGINT });
5294 }
5295
5296 protected void clear(long categoryId) throws SystemException {
5297 ModelListener<com.liferay.portlet.asset.model.AssetEntry>[] assetEntryListeners =
5298 assetEntryPersistence.getListeners();
5299
5300 List<com.liferay.portlet.asset.model.AssetEntry> assetEntries = null;
5301
5302 if ((listeners.length > 0) || (assetEntryListeners.length > 0)) {
5303 assetEntries = getAssetEntries(categoryId);
5304
5305 for (com.liferay.portlet.asset.model.AssetEntry assetEntry : assetEntries) {
5306 for (ModelListener<AssetCategory> listener : listeners) {
5307 listener.onBeforeRemoveAssociation(categoryId,
5308 com.liferay.portlet.asset.model.AssetEntry.class.getName(),
5309 assetEntry.getPrimaryKey());
5310 }
5311
5312 for (ModelListener<com.liferay.portlet.asset.model.AssetEntry> listener : assetEntryListeners) {
5313 listener.onBeforeRemoveAssociation(assetEntry.getPrimaryKey(),
5314 AssetCategory.class.getName(), categoryId);
5315 }
5316 }
5317 }
5318
5319 _sqlUpdate.update(new Object[] { new Long(categoryId) });
5320
5321 if ((listeners.length > 0) || (assetEntryListeners.length > 0)) {
5322 for (com.liferay.portlet.asset.model.AssetEntry assetEntry : assetEntries) {
5323 for (ModelListener<AssetCategory> listener : listeners) {
5324 listener.onAfterRemoveAssociation(categoryId,
5325 com.liferay.portlet.asset.model.AssetEntry.class.getName(),
5326 assetEntry.getPrimaryKey());
5327 }
5328
5329 for (ModelListener<com.liferay.portlet.asset.model.AssetEntry> listener : assetEntryListeners) {
5330 listener.onAfterRemoveAssociation(assetEntry.getPrimaryKey(),
5331 AssetCategory.class.getName(), categoryId);
5332 }
5333 }
5334 }
5335 }
5336
5337 private SqlUpdate _sqlUpdate;
5338 }
5339
5340 protected class RemoveAssetEntry {
5341 protected RemoveAssetEntry(AssetCategoryPersistenceImpl persistenceImpl) {
5342 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
5343 "DELETE FROM AssetEntries_AssetCategories WHERE categoryId = ? AND entryId = ?",
5344 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
5345 _persistenceImpl = persistenceImpl;
5346 }
5347
5348 protected void remove(long categoryId, long entryId)
5349 throws SystemException {
5350 if (_persistenceImpl.containsAssetEntry.contains(categoryId, entryId)) {
5351 ModelListener<com.liferay.portlet.asset.model.AssetEntry>[] assetEntryListeners =
5352 assetEntryPersistence.getListeners();
5353
5354 for (ModelListener<AssetCategory> listener : listeners) {
5355 listener.onBeforeRemoveAssociation(categoryId,
5356 com.liferay.portlet.asset.model.AssetEntry.class.getName(),
5357 entryId);
5358 }
5359
5360 for (ModelListener<com.liferay.portlet.asset.model.AssetEntry> listener : assetEntryListeners) {
5361 listener.onBeforeRemoveAssociation(entryId,
5362 AssetCategory.class.getName(), categoryId);
5363 }
5364
5365 _sqlUpdate.update(new Object[] {
5366 new Long(categoryId), new Long(entryId)
5367 });
5368
5369 for (ModelListener<AssetCategory> listener : listeners) {
5370 listener.onAfterRemoveAssociation(categoryId,
5371 com.liferay.portlet.asset.model.AssetEntry.class.getName(),
5372 entryId);
5373 }
5374
5375 for (ModelListener<com.liferay.portlet.asset.model.AssetEntry> listener : assetEntryListeners) {
5376 listener.onAfterRemoveAssociation(entryId,
5377 AssetCategory.class.getName(), categoryId);
5378 }
5379 }
5380 }
5381
5382 private SqlUpdate _sqlUpdate;
5383 private AssetCategoryPersistenceImpl _persistenceImpl;
5384 }
5385
5386 protected ExpandTreeLeftCategoryId expandTreeLeftCategoryId;
5387 protected ExpandTreeRightCategoryId expandTreeRightCategoryId;
5388 protected ShrinkTreeLeftCategoryId shrinkTreeLeftCategoryId;
5389 protected ShrinkTreeRightCategoryId shrinkTreeRightCategoryId;
5390 protected UpdateTree updateTree;
5391
5392 protected class ExpandTreeLeftCategoryId {
5393 protected ExpandTreeLeftCategoryId() {
5394 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
5395 "UPDATE AssetCategory SET leftCategoryId = (leftCategoryId + 2) WHERE (groupId = ?) AND (leftCategoryId > ?)",
5396 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
5397 }
5398
5399 protected void expand(long groupId, long leftCategoryId) {
5400 _sqlUpdate.update(new Object[] { groupId, leftCategoryId });
5401 }
5402
5403 private SqlUpdate _sqlUpdate;
5404 }
5405
5406 protected class ExpandTreeRightCategoryId {
5407 protected ExpandTreeRightCategoryId() {
5408 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
5409 "UPDATE AssetCategory SET rightCategoryId = (rightCategoryId + 2) WHERE (groupId = ?) AND (rightCategoryId > ?)",
5410 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
5411 }
5412
5413 protected void expand(long groupId, long rightCategoryId) {
5414 _sqlUpdate.update(new Object[] { groupId, rightCategoryId });
5415 }
5416
5417 private SqlUpdate _sqlUpdate;
5418 }
5419
5420 protected class ShrinkTreeLeftCategoryId {
5421 protected ShrinkTreeLeftCategoryId() {
5422 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
5423 "UPDATE AssetCategory SET leftCategoryId = (leftCategoryId - ?) WHERE (groupId = ?) AND (leftCategoryId > ?)",
5424 new int[] {
5425 java.sql.Types.BIGINT, java.sql.Types.BIGINT,
5426 java.sql.Types.BIGINT
5427 });
5428 }
5429
5430 protected void shrink(long groupId, long leftCategoryId, long delta) {
5431 _sqlUpdate.update(new Object[] { delta, groupId, leftCategoryId });
5432 }
5433
5434 private SqlUpdate _sqlUpdate;
5435 }
5436
5437 protected class ShrinkTreeRightCategoryId {
5438 protected ShrinkTreeRightCategoryId() {
5439 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
5440 "UPDATE AssetCategory SET rightCategoryId = (rightCategoryId - ?) WHERE (groupId = ?) AND (rightCategoryId > ?)",
5441 new int[] {
5442 java.sql.Types.BIGINT, java.sql.Types.BIGINT,
5443 java.sql.Types.BIGINT
5444 });
5445 }
5446
5447 protected void shrink(long groupId, long rightCategoryId, long delta) {
5448 _sqlUpdate.update(new Object[] { delta, groupId, rightCategoryId });
5449 }
5450
5451 private SqlUpdate _sqlUpdate;
5452 }
5453
5454 protected class UpdateTree {
5455 protected UpdateTree() {
5456 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
5457 "UPDATE AssetCategory SET leftCategoryId = ?, rightCategoryId = ? WHERE categoryId = ?",
5458 new int[] {
5459 java.sql.Types.BIGINT, java.sql.Types.BIGINT,
5460 java.sql.Types.BIGINT
5461 });
5462 }
5463
5464 protected void update(long categoryId, long leftCategoryId,
5465 long rightCategoryId) {
5466 _sqlUpdate.update(new Object[] {
5467 leftCategoryId, rightCategoryId, categoryId
5468 });
5469 }
5470
5471 private SqlUpdate _sqlUpdate;
5472 }
5473
5474 private static final String _SQL_SELECT_ASSETCATEGORY = "SELECT assetCategory FROM AssetCategory assetCategory";
5475 private static final String _SQL_SELECT_ASSETCATEGORY_WHERE = "SELECT assetCategory FROM AssetCategory assetCategory WHERE ";
5476 private static final String _SQL_COUNT_ASSETCATEGORY = "SELECT COUNT(assetCategory) FROM AssetCategory assetCategory";
5477 private static final String _SQL_COUNT_ASSETCATEGORY_WHERE = "SELECT COUNT(assetCategory) FROM AssetCategory assetCategory WHERE ";
5478 private static final String _SQL_GETASSETENTRIES = "SELECT {AssetEntry.*} FROM AssetEntry INNER JOIN AssetEntries_AssetCategories ON (AssetEntries_AssetCategories.entryId = AssetEntry.entryId) WHERE (AssetEntries_AssetCategories.categoryId = ?)";
5479 private static final String _SQL_GETASSETENTRIESSIZE = "SELECT COUNT(*) AS COUNT_VALUE FROM AssetEntries_AssetCategories WHERE categoryId = ?";
5480 private static final String _SQL_CONTAINSASSETENTRY = "SELECT COUNT(*) AS COUNT_VALUE FROM AssetEntries_AssetCategories WHERE categoryId = ? AND entryId = ?";
5481 private static final String _FINDER_COLUMN_UUID_UUID_1 = "assetCategory.uuid IS NULL";
5482 private static final String _FINDER_COLUMN_UUID_UUID_2 = "assetCategory.uuid = ?";
5483 private static final String _FINDER_COLUMN_UUID_UUID_3 = "(assetCategory.uuid IS NULL OR assetCategory.uuid = ?)";
5484 private static final String _FINDER_COLUMN_UUID_G_UUID_1 = "assetCategory.uuid IS NULL AND ";
5485 private static final String _FINDER_COLUMN_UUID_G_UUID_2 = "assetCategory.uuid = ? AND ";
5486 private static final String _FINDER_COLUMN_UUID_G_UUID_3 = "(assetCategory.uuid IS NULL OR assetCategory.uuid = ?) AND ";
5487 private static final String _FINDER_COLUMN_UUID_G_GROUPID_2 = "assetCategory.groupId = ?";
5488 private static final String _FINDER_COLUMN_GROUPID_GROUPID_2 = "assetCategory.groupId = ?";
5489 private static final String _FINDER_COLUMN_PARENTCATEGORYID_PARENTCATEGORYID_2 =
5490 "assetCategory.parentCategoryId = ?";
5491 private static final String _FINDER_COLUMN_VOCABULARYID_VOCABULARYID_2 = "assetCategory.vocabularyId = ?";
5492 private static final String _FINDER_COLUMN_P_N_PARENTCATEGORYID_2 = "assetCategory.parentCategoryId = ? AND ";
5493 private static final String _FINDER_COLUMN_P_N_NAME_1 = "assetCategory.name IS NULL";
5494 private static final String _FINDER_COLUMN_P_N_NAME_2 = "assetCategory.name = ?";
5495 private static final String _FINDER_COLUMN_P_N_NAME_3 = "(assetCategory.name IS NULL OR assetCategory.name = ?)";
5496 private static final String _FINDER_COLUMN_P_V_PARENTCATEGORYID_2 = "assetCategory.parentCategoryId = ? AND ";
5497 private static final String _FINDER_COLUMN_P_V_VOCABULARYID_2 = "assetCategory.vocabularyId = ?";
5498 private static final String _FINDER_COLUMN_N_V_NAME_1 = "assetCategory.name IS NULL AND ";
5499 private static final String _FINDER_COLUMN_N_V_NAME_2 = "assetCategory.name = ? AND ";
5500 private static final String _FINDER_COLUMN_N_V_NAME_3 = "(assetCategory.name IS NULL OR assetCategory.name = ?) AND ";
5501 private static final String _FINDER_COLUMN_N_V_VOCABULARYID_2 = "assetCategory.vocabularyId = ?";
5502 private static final String _FINDER_COLUMN_P_N_V_PARENTCATEGORYID_2 = "assetCategory.parentCategoryId = ? AND ";
5503 private static final String _FINDER_COLUMN_P_N_V_NAME_1 = "assetCategory.name IS NULL AND ";
5504 private static final String _FINDER_COLUMN_P_N_V_NAME_2 = "assetCategory.name = ? AND ";
5505 private static final String _FINDER_COLUMN_P_N_V_NAME_3 = "(assetCategory.name IS NULL OR assetCategory.name = ?) AND ";
5506 private static final String _FINDER_COLUMN_P_N_V_VOCABULARYID_2 = "assetCategory.vocabularyId = ?";
5507 private static final String _FILTER_SQL_SELECT_ASSETCATEGORY_WHERE = "SELECT DISTINCT {assetCategory.*} FROM AssetCategory assetCategory WHERE ";
5508 private static final String _FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_1 =
5509 "SELECT {AssetCategory.*} FROM (SELECT DISTINCT assetCategory.categoryId FROM AssetCategory assetCategory WHERE ";
5510 private static final String _FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_2 =
5511 ") TEMP_TABLE INNER JOIN AssetCategory ON TEMP_TABLE.categoryId = AssetCategory.categoryId";
5512 private static final String _FILTER_SQL_COUNT_ASSETCATEGORY_WHERE = "SELECT COUNT(DISTINCT assetCategory.categoryId) AS COUNT_VALUE FROM AssetCategory assetCategory WHERE ";
5513 private static final String _FILTER_COLUMN_PK = "assetCategory.categoryId";
5514 private static final String _FILTER_COLUMN_USERID = "assetCategory.userId";
5515 private static final String _FILTER_ENTITY_ALIAS = "assetCategory";
5516 private static final String _FILTER_ENTITY_TABLE = "AssetCategory";
5517 private static final String _ORDER_BY_ENTITY_ALIAS = "assetCategory.";
5518 private static final String _ORDER_BY_ENTITY_TABLE = "AssetCategory.";
5519 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No AssetCategory exists with the primary key ";
5520 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No AssetCategory exists with the key {";
5521 private static Log _log = LogFactoryUtil.getLog(AssetCategoryPersistenceImpl.class);
5522 }