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.getOriginalUuid(),
391 new Long(assetCategoryModelImpl.getOriginalGroupId())
392 });
393
394 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_P_N_V,
395 new Object[] {
396 new Long(assetCategoryModelImpl.getOriginalParentCategoryId()),
397
398 assetCategoryModelImpl.getOriginalName(),
399 new Long(assetCategoryModelImpl.getOriginalVocabularyId())
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 Session session = null;
679
680 try {
681 session = openSession();
682
683 StringBundler query = null;
684
685 if (orderByComparator != null) {
686 query = new StringBundler(3 +
687 (orderByComparator.getOrderByFields().length * 3));
688 }
689 else {
690 query = new StringBundler(3);
691 }
692
693 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
694
695 if (uuid == null) {
696 query.append(_FINDER_COLUMN_UUID_UUID_1);
697 }
698 else {
699 if (uuid.equals(StringPool.BLANK)) {
700 query.append(_FINDER_COLUMN_UUID_UUID_3);
701 }
702 else {
703 query.append(_FINDER_COLUMN_UUID_UUID_2);
704 }
705 }
706
707 if (orderByComparator != null) {
708 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
709 orderByComparator);
710 }
711
712 else {
713 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
714 }
715
716 String sql = query.toString();
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 list = new ArrayList<AssetCategory>();
735 }
736
737 cacheResult(list);
738
739 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_UUID, finderArgs,
740 list);
741
742 closeSession(session);
743 }
744 }
745
746 return list;
747 }
748
749
762 public AssetCategory findByUuid_First(String uuid,
763 OrderByComparator orderByComparator)
764 throws NoSuchCategoryException, SystemException {
765 List<AssetCategory> list = findByUuid(uuid, 0, 1, orderByComparator);
766
767 if (list.isEmpty()) {
768 StringBundler msg = new StringBundler(4);
769
770 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
771
772 msg.append("uuid=");
773 msg.append(uuid);
774
775 msg.append(StringPool.CLOSE_CURLY_BRACE);
776
777 throw new NoSuchCategoryException(msg.toString());
778 }
779 else {
780 return list.get(0);
781 }
782 }
783
784
797 public AssetCategory findByUuid_Last(String uuid,
798 OrderByComparator orderByComparator)
799 throws NoSuchCategoryException, SystemException {
800 int count = countByUuid(uuid);
801
802 List<AssetCategory> list = findByUuid(uuid, count - 1, count,
803 orderByComparator);
804
805 if (list.isEmpty()) {
806 StringBundler msg = new StringBundler(4);
807
808 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
809
810 msg.append("uuid=");
811 msg.append(uuid);
812
813 msg.append(StringPool.CLOSE_CURLY_BRACE);
814
815 throw new NoSuchCategoryException(msg.toString());
816 }
817 else {
818 return list.get(0);
819 }
820 }
821
822
836 public AssetCategory[] findByUuid_PrevAndNext(long categoryId, String uuid,
837 OrderByComparator orderByComparator)
838 throws NoSuchCategoryException, SystemException {
839 AssetCategory assetCategory = findByPrimaryKey(categoryId);
840
841 Session session = null;
842
843 try {
844 session = openSession();
845
846 AssetCategory[] array = new AssetCategoryImpl[3];
847
848 array[0] = getByUuid_PrevAndNext(session, assetCategory, uuid,
849 orderByComparator, true);
850
851 array[1] = assetCategory;
852
853 array[2] = getByUuid_PrevAndNext(session, assetCategory, uuid,
854 orderByComparator, false);
855
856 return array;
857 }
858 catch (Exception e) {
859 throw processException(e);
860 }
861 finally {
862 closeSession(session);
863 }
864 }
865
866 protected AssetCategory getByUuid_PrevAndNext(Session session,
867 AssetCategory assetCategory, String uuid,
868 OrderByComparator orderByComparator, boolean previous) {
869 StringBundler query = null;
870
871 if (orderByComparator != null) {
872 query = new StringBundler(6 +
873 (orderByComparator.getOrderByFields().length * 6));
874 }
875 else {
876 query = new StringBundler(3);
877 }
878
879 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
880
881 if (uuid == null) {
882 query.append(_FINDER_COLUMN_UUID_UUID_1);
883 }
884 else {
885 if (uuid.equals(StringPool.BLANK)) {
886 query.append(_FINDER_COLUMN_UUID_UUID_3);
887 }
888 else {
889 query.append(_FINDER_COLUMN_UUID_UUID_2);
890 }
891 }
892
893 if (orderByComparator != null) {
894 String[] orderByFields = orderByComparator.getOrderByFields();
895
896 if (orderByFields.length > 0) {
897 query.append(WHERE_AND);
898 }
899
900 for (int i = 0; i < orderByFields.length; i++) {
901 query.append(_ORDER_BY_ENTITY_ALIAS);
902 query.append(orderByFields[i]);
903
904 if ((i + 1) < orderByFields.length) {
905 if (orderByComparator.isAscending() ^ previous) {
906 query.append(WHERE_GREATER_THAN_HAS_NEXT);
907 }
908 else {
909 query.append(WHERE_LESSER_THAN_HAS_NEXT);
910 }
911 }
912 else {
913 if (orderByComparator.isAscending() ^ previous) {
914 query.append(WHERE_GREATER_THAN);
915 }
916 else {
917 query.append(WHERE_LESSER_THAN);
918 }
919 }
920 }
921
922 query.append(ORDER_BY_CLAUSE);
923
924 for (int i = 0; i < orderByFields.length; i++) {
925 query.append(_ORDER_BY_ENTITY_ALIAS);
926 query.append(orderByFields[i]);
927
928 if ((i + 1) < orderByFields.length) {
929 if (orderByComparator.isAscending() ^ previous) {
930 query.append(ORDER_BY_ASC_HAS_NEXT);
931 }
932 else {
933 query.append(ORDER_BY_DESC_HAS_NEXT);
934 }
935 }
936 else {
937 if (orderByComparator.isAscending() ^ previous) {
938 query.append(ORDER_BY_ASC);
939 }
940 else {
941 query.append(ORDER_BY_DESC);
942 }
943 }
944 }
945 }
946
947 else {
948 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
949 }
950
951 String sql = query.toString();
952
953 Query q = session.createQuery(sql);
954
955 q.setFirstResult(0);
956 q.setMaxResults(2);
957
958 QueryPos qPos = QueryPos.getInstance(q);
959
960 if (uuid != null) {
961 qPos.add(uuid);
962 }
963
964 if (orderByComparator != null) {
965 Object[] values = orderByComparator.getOrderByValues(assetCategory);
966
967 for (Object value : values) {
968 qPos.add(value);
969 }
970 }
971
972 List<AssetCategory> list = q.list();
973
974 if (list.size() == 2) {
975 return list.get(1);
976 }
977 else {
978 return null;
979 }
980 }
981
982
991 public AssetCategory findByUUID_G(String uuid, long groupId)
992 throws NoSuchCategoryException, SystemException {
993 AssetCategory assetCategory = fetchByUUID_G(uuid, groupId);
994
995 if (assetCategory == null) {
996 StringBundler msg = new StringBundler(6);
997
998 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
999
1000 msg.append("uuid=");
1001 msg.append(uuid);
1002
1003 msg.append(", groupId=");
1004 msg.append(groupId);
1005
1006 msg.append(StringPool.CLOSE_CURLY_BRACE);
1007
1008 if (_log.isWarnEnabled()) {
1009 _log.warn(msg.toString());
1010 }
1011
1012 throw new NoSuchCategoryException(msg.toString());
1013 }
1014
1015 return assetCategory;
1016 }
1017
1018
1026 public AssetCategory fetchByUUID_G(String uuid, long groupId)
1027 throws SystemException {
1028 return fetchByUUID_G(uuid, groupId, true);
1029 }
1030
1031
1039 public AssetCategory fetchByUUID_G(String uuid, long groupId,
1040 boolean retrieveFromCache) throws SystemException {
1041 Object[] finderArgs = new Object[] { uuid, groupId };
1042
1043 Object result = null;
1044
1045 if (retrieveFromCache) {
1046 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_UUID_G,
1047 finderArgs, this);
1048 }
1049
1050 if (result == null) {
1051 Session session = null;
1052
1053 try {
1054 session = openSession();
1055
1056 StringBundler query = new StringBundler(4);
1057
1058 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
1059
1060 if (uuid == null) {
1061 query.append(_FINDER_COLUMN_UUID_G_UUID_1);
1062 }
1063 else {
1064 if (uuid.equals(StringPool.BLANK)) {
1065 query.append(_FINDER_COLUMN_UUID_G_UUID_3);
1066 }
1067 else {
1068 query.append(_FINDER_COLUMN_UUID_G_UUID_2);
1069 }
1070 }
1071
1072 query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
1073
1074 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
1075
1076 String sql = query.toString();
1077
1078 Query q = session.createQuery(sql);
1079
1080 QueryPos qPos = QueryPos.getInstance(q);
1081
1082 if (uuid != null) {
1083 qPos.add(uuid);
1084 }
1085
1086 qPos.add(groupId);
1087
1088 List<AssetCategory> list = q.list();
1089
1090 result = list;
1091
1092 AssetCategory assetCategory = null;
1093
1094 if (list.isEmpty()) {
1095 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
1096 finderArgs, list);
1097 }
1098 else {
1099 assetCategory = list.get(0);
1100
1101 cacheResult(assetCategory);
1102
1103 if ((assetCategory.getUuid() == null) ||
1104 !assetCategory.getUuid().equals(uuid) ||
1105 (assetCategory.getGroupId() != groupId)) {
1106 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
1107 finderArgs, assetCategory);
1108 }
1109 }
1110
1111 return assetCategory;
1112 }
1113 catch (Exception e) {
1114 throw processException(e);
1115 }
1116 finally {
1117 if (result == null) {
1118 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
1119 finderArgs, new ArrayList<AssetCategory>());
1120 }
1121
1122 closeSession(session);
1123 }
1124 }
1125 else {
1126 if (result instanceof List<?>) {
1127 return null;
1128 }
1129 else {
1130 return (AssetCategory)result;
1131 }
1132 }
1133 }
1134
1135
1142 public List<AssetCategory> findByGroupId(long groupId)
1143 throws SystemException {
1144 return findByGroupId(groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1145 }
1146
1147
1160 public List<AssetCategory> findByGroupId(long groupId, int start, int end)
1161 throws SystemException {
1162 return findByGroupId(groupId, start, end, null);
1163 }
1164
1165
1179 public List<AssetCategory> findByGroupId(long groupId, int start, int end,
1180 OrderByComparator orderByComparator) throws SystemException {
1181 Object[] finderArgs = new Object[] {
1182 groupId,
1183
1184 String.valueOf(start), String.valueOf(end),
1185 String.valueOf(orderByComparator)
1186 };
1187
1188 List<AssetCategory> list = (List<AssetCategory>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_GROUPID,
1189 finderArgs, this);
1190
1191 if (list == null) {
1192 Session session = null;
1193
1194 try {
1195 session = openSession();
1196
1197 StringBundler query = null;
1198
1199 if (orderByComparator != null) {
1200 query = new StringBundler(3 +
1201 (orderByComparator.getOrderByFields().length * 3));
1202 }
1203 else {
1204 query = new StringBundler(3);
1205 }
1206
1207 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
1208
1209 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1210
1211 if (orderByComparator != null) {
1212 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1213 orderByComparator);
1214 }
1215
1216 else {
1217 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
1218 }
1219
1220 String sql = query.toString();
1221
1222 Query q = session.createQuery(sql);
1223
1224 QueryPos qPos = QueryPos.getInstance(q);
1225
1226 qPos.add(groupId);
1227
1228 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
1229 start, end);
1230 }
1231 catch (Exception e) {
1232 throw processException(e);
1233 }
1234 finally {
1235 if (list == null) {
1236 list = new ArrayList<AssetCategory>();
1237 }
1238
1239 cacheResult(list);
1240
1241 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_GROUPID,
1242 finderArgs, list);
1243
1244 closeSession(session);
1245 }
1246 }
1247
1248 return list;
1249 }
1250
1251
1264 public AssetCategory findByGroupId_First(long groupId,
1265 OrderByComparator orderByComparator)
1266 throws NoSuchCategoryException, SystemException {
1267 List<AssetCategory> list = findByGroupId(groupId, 0, 1,
1268 orderByComparator);
1269
1270 if (list.isEmpty()) {
1271 StringBundler msg = new StringBundler(4);
1272
1273 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1274
1275 msg.append("groupId=");
1276 msg.append(groupId);
1277
1278 msg.append(StringPool.CLOSE_CURLY_BRACE);
1279
1280 throw new NoSuchCategoryException(msg.toString());
1281 }
1282 else {
1283 return list.get(0);
1284 }
1285 }
1286
1287
1300 public AssetCategory findByGroupId_Last(long groupId,
1301 OrderByComparator orderByComparator)
1302 throws NoSuchCategoryException, SystemException {
1303 int count = countByGroupId(groupId);
1304
1305 List<AssetCategory> list = findByGroupId(groupId, count - 1, count,
1306 orderByComparator);
1307
1308 if (list.isEmpty()) {
1309 StringBundler msg = new StringBundler(4);
1310
1311 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1312
1313 msg.append("groupId=");
1314 msg.append(groupId);
1315
1316 msg.append(StringPool.CLOSE_CURLY_BRACE);
1317
1318 throw new NoSuchCategoryException(msg.toString());
1319 }
1320 else {
1321 return list.get(0);
1322 }
1323 }
1324
1325
1339 public AssetCategory[] findByGroupId_PrevAndNext(long categoryId,
1340 long groupId, OrderByComparator orderByComparator)
1341 throws NoSuchCategoryException, SystemException {
1342 AssetCategory assetCategory = findByPrimaryKey(categoryId);
1343
1344 Session session = null;
1345
1346 try {
1347 session = openSession();
1348
1349 AssetCategory[] array = new AssetCategoryImpl[3];
1350
1351 array[0] = getByGroupId_PrevAndNext(session, assetCategory,
1352 groupId, orderByComparator, true);
1353
1354 array[1] = assetCategory;
1355
1356 array[2] = getByGroupId_PrevAndNext(session, assetCategory,
1357 groupId, orderByComparator, false);
1358
1359 return array;
1360 }
1361 catch (Exception e) {
1362 throw processException(e);
1363 }
1364 finally {
1365 closeSession(session);
1366 }
1367 }
1368
1369 protected AssetCategory getByGroupId_PrevAndNext(Session session,
1370 AssetCategory assetCategory, long groupId,
1371 OrderByComparator orderByComparator, boolean previous) {
1372 StringBundler query = null;
1373
1374 if (orderByComparator != null) {
1375 query = new StringBundler(6 +
1376 (orderByComparator.getOrderByFields().length * 6));
1377 }
1378 else {
1379 query = new StringBundler(3);
1380 }
1381
1382 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
1383
1384 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1385
1386 if (orderByComparator != null) {
1387 String[] orderByFields = orderByComparator.getOrderByFields();
1388
1389 if (orderByFields.length > 0) {
1390 query.append(WHERE_AND);
1391 }
1392
1393 for (int i = 0; i < orderByFields.length; i++) {
1394 query.append(_ORDER_BY_ENTITY_ALIAS);
1395 query.append(orderByFields[i]);
1396
1397 if ((i + 1) < orderByFields.length) {
1398 if (orderByComparator.isAscending() ^ previous) {
1399 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1400 }
1401 else {
1402 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1403 }
1404 }
1405 else {
1406 if (orderByComparator.isAscending() ^ previous) {
1407 query.append(WHERE_GREATER_THAN);
1408 }
1409 else {
1410 query.append(WHERE_LESSER_THAN);
1411 }
1412 }
1413 }
1414
1415 query.append(ORDER_BY_CLAUSE);
1416
1417 for (int i = 0; i < orderByFields.length; i++) {
1418 query.append(_ORDER_BY_ENTITY_ALIAS);
1419 query.append(orderByFields[i]);
1420
1421 if ((i + 1) < orderByFields.length) {
1422 if (orderByComparator.isAscending() ^ previous) {
1423 query.append(ORDER_BY_ASC_HAS_NEXT);
1424 }
1425 else {
1426 query.append(ORDER_BY_DESC_HAS_NEXT);
1427 }
1428 }
1429 else {
1430 if (orderByComparator.isAscending() ^ previous) {
1431 query.append(ORDER_BY_ASC);
1432 }
1433 else {
1434 query.append(ORDER_BY_DESC);
1435 }
1436 }
1437 }
1438 }
1439
1440 else {
1441 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
1442 }
1443
1444 String sql = query.toString();
1445
1446 Query q = session.createQuery(sql);
1447
1448 q.setFirstResult(0);
1449 q.setMaxResults(2);
1450
1451 QueryPos qPos = QueryPos.getInstance(q);
1452
1453 qPos.add(groupId);
1454
1455 if (orderByComparator != null) {
1456 Object[] values = orderByComparator.getOrderByValues(assetCategory);
1457
1458 for (Object value : values) {
1459 qPos.add(value);
1460 }
1461 }
1462
1463 List<AssetCategory> list = q.list();
1464
1465 if (list.size() == 2) {
1466 return list.get(1);
1467 }
1468 else {
1469 return null;
1470 }
1471 }
1472
1473
1480 public List<AssetCategory> filterFindByGroupId(long groupId)
1481 throws SystemException {
1482 return filterFindByGroupId(groupId, QueryUtil.ALL_POS,
1483 QueryUtil.ALL_POS, null);
1484 }
1485
1486
1499 public List<AssetCategory> filterFindByGroupId(long groupId, int start,
1500 int end) throws SystemException {
1501 return filterFindByGroupId(groupId, start, end, null);
1502 }
1503
1504
1518 public List<AssetCategory> filterFindByGroupId(long groupId, int start,
1519 int end, OrderByComparator orderByComparator) throws SystemException {
1520 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
1521 return findByGroupId(groupId, start, end, orderByComparator);
1522 }
1523
1524 Session session = null;
1525
1526 try {
1527 session = openSession();
1528
1529 StringBundler query = null;
1530
1531 if (orderByComparator != null) {
1532 query = new StringBundler(3 +
1533 (orderByComparator.getOrderByFields().length * 3));
1534 }
1535 else {
1536 query = new StringBundler(3);
1537 }
1538
1539 if (getDB().isSupportsInlineDistinct()) {
1540 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_WHERE);
1541 }
1542 else {
1543 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE);
1544 }
1545
1546 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1547
1548 if (orderByComparator != null) {
1549 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1550 orderByComparator);
1551 }
1552
1553 else {
1554 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
1555 }
1556
1557 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1558 AssetCategory.class.getName(), _FILTER_COLUMN_PK,
1559 _FILTER_COLUMN_USERID, groupId);
1560
1561 SQLQuery q = session.createSQLQuery(sql);
1562
1563 q.addEntity(_FILTER_ENTITY_ALIAS, AssetCategoryImpl.class);
1564
1565 QueryPos qPos = QueryPos.getInstance(q);
1566
1567 qPos.add(groupId);
1568
1569 return (List<AssetCategory>)QueryUtil.list(q, getDialect(), start,
1570 end);
1571 }
1572 catch (Exception e) {
1573 throw processException(e);
1574 }
1575 finally {
1576 closeSession(session);
1577 }
1578 }
1579
1580
1587 public List<AssetCategory> findByParentCategoryId(long parentCategoryId)
1588 throws SystemException {
1589 return findByParentCategoryId(parentCategoryId, QueryUtil.ALL_POS,
1590 QueryUtil.ALL_POS, null);
1591 }
1592
1593
1606 public List<AssetCategory> findByParentCategoryId(long parentCategoryId,
1607 int start, int end) throws SystemException {
1608 return findByParentCategoryId(parentCategoryId, start, end, null);
1609 }
1610
1611
1625 public List<AssetCategory> findByParentCategoryId(long parentCategoryId,
1626 int start, int end, OrderByComparator orderByComparator)
1627 throws SystemException {
1628 Object[] finderArgs = new Object[] {
1629 parentCategoryId,
1630
1631 String.valueOf(start), String.valueOf(end),
1632 String.valueOf(orderByComparator)
1633 };
1634
1635 List<AssetCategory> list = (List<AssetCategory>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_PARENTCATEGORYID,
1636 finderArgs, this);
1637
1638 if (list == null) {
1639 Session session = null;
1640
1641 try {
1642 session = openSession();
1643
1644 StringBundler query = null;
1645
1646 if (orderByComparator != null) {
1647 query = new StringBundler(3 +
1648 (orderByComparator.getOrderByFields().length * 3));
1649 }
1650 else {
1651 query = new StringBundler(3);
1652 }
1653
1654 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
1655
1656 query.append(_FINDER_COLUMN_PARENTCATEGORYID_PARENTCATEGORYID_2);
1657
1658 if (orderByComparator != null) {
1659 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1660 orderByComparator);
1661 }
1662
1663 else {
1664 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
1665 }
1666
1667 String sql = query.toString();
1668
1669 Query q = session.createQuery(sql);
1670
1671 QueryPos qPos = QueryPos.getInstance(q);
1672
1673 qPos.add(parentCategoryId);
1674
1675 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
1676 start, end);
1677 }
1678 catch (Exception e) {
1679 throw processException(e);
1680 }
1681 finally {
1682 if (list == null) {
1683 list = new ArrayList<AssetCategory>();
1684 }
1685
1686 cacheResult(list);
1687
1688 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_PARENTCATEGORYID,
1689 finderArgs, list);
1690
1691 closeSession(session);
1692 }
1693 }
1694
1695 return list;
1696 }
1697
1698
1711 public AssetCategory findByParentCategoryId_First(long parentCategoryId,
1712 OrderByComparator orderByComparator)
1713 throws NoSuchCategoryException, SystemException {
1714 List<AssetCategory> list = findByParentCategoryId(parentCategoryId, 0,
1715 1, orderByComparator);
1716
1717 if (list.isEmpty()) {
1718 StringBundler msg = new StringBundler(4);
1719
1720 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1721
1722 msg.append("parentCategoryId=");
1723 msg.append(parentCategoryId);
1724
1725 msg.append(StringPool.CLOSE_CURLY_BRACE);
1726
1727 throw new NoSuchCategoryException(msg.toString());
1728 }
1729 else {
1730 return list.get(0);
1731 }
1732 }
1733
1734
1747 public AssetCategory findByParentCategoryId_Last(long parentCategoryId,
1748 OrderByComparator orderByComparator)
1749 throws NoSuchCategoryException, SystemException {
1750 int count = countByParentCategoryId(parentCategoryId);
1751
1752 List<AssetCategory> list = findByParentCategoryId(parentCategoryId,
1753 count - 1, count, orderByComparator);
1754
1755 if (list.isEmpty()) {
1756 StringBundler msg = new StringBundler(4);
1757
1758 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1759
1760 msg.append("parentCategoryId=");
1761 msg.append(parentCategoryId);
1762
1763 msg.append(StringPool.CLOSE_CURLY_BRACE);
1764
1765 throw new NoSuchCategoryException(msg.toString());
1766 }
1767 else {
1768 return list.get(0);
1769 }
1770 }
1771
1772
1786 public AssetCategory[] findByParentCategoryId_PrevAndNext(long categoryId,
1787 long parentCategoryId, OrderByComparator orderByComparator)
1788 throws NoSuchCategoryException, SystemException {
1789 AssetCategory assetCategory = findByPrimaryKey(categoryId);
1790
1791 Session session = null;
1792
1793 try {
1794 session = openSession();
1795
1796 AssetCategory[] array = new AssetCategoryImpl[3];
1797
1798 array[0] = getByParentCategoryId_PrevAndNext(session,
1799 assetCategory, parentCategoryId, orderByComparator, true);
1800
1801 array[1] = assetCategory;
1802
1803 array[2] = getByParentCategoryId_PrevAndNext(session,
1804 assetCategory, parentCategoryId, orderByComparator, false);
1805
1806 return array;
1807 }
1808 catch (Exception e) {
1809 throw processException(e);
1810 }
1811 finally {
1812 closeSession(session);
1813 }
1814 }
1815
1816 protected AssetCategory getByParentCategoryId_PrevAndNext(Session session,
1817 AssetCategory assetCategory, long parentCategoryId,
1818 OrderByComparator orderByComparator, boolean previous) {
1819 StringBundler query = null;
1820
1821 if (orderByComparator != null) {
1822 query = new StringBundler(6 +
1823 (orderByComparator.getOrderByFields().length * 6));
1824 }
1825 else {
1826 query = new StringBundler(3);
1827 }
1828
1829 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
1830
1831 query.append(_FINDER_COLUMN_PARENTCATEGORYID_PARENTCATEGORYID_2);
1832
1833 if (orderByComparator != null) {
1834 String[] orderByFields = orderByComparator.getOrderByFields();
1835
1836 if (orderByFields.length > 0) {
1837 query.append(WHERE_AND);
1838 }
1839
1840 for (int i = 0; i < orderByFields.length; i++) {
1841 query.append(_ORDER_BY_ENTITY_ALIAS);
1842 query.append(orderByFields[i]);
1843
1844 if ((i + 1) < orderByFields.length) {
1845 if (orderByComparator.isAscending() ^ previous) {
1846 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1847 }
1848 else {
1849 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1850 }
1851 }
1852 else {
1853 if (orderByComparator.isAscending() ^ previous) {
1854 query.append(WHERE_GREATER_THAN);
1855 }
1856 else {
1857 query.append(WHERE_LESSER_THAN);
1858 }
1859 }
1860 }
1861
1862 query.append(ORDER_BY_CLAUSE);
1863
1864 for (int i = 0; i < orderByFields.length; i++) {
1865 query.append(_ORDER_BY_ENTITY_ALIAS);
1866 query.append(orderByFields[i]);
1867
1868 if ((i + 1) < orderByFields.length) {
1869 if (orderByComparator.isAscending() ^ previous) {
1870 query.append(ORDER_BY_ASC_HAS_NEXT);
1871 }
1872 else {
1873 query.append(ORDER_BY_DESC_HAS_NEXT);
1874 }
1875 }
1876 else {
1877 if (orderByComparator.isAscending() ^ previous) {
1878 query.append(ORDER_BY_ASC);
1879 }
1880 else {
1881 query.append(ORDER_BY_DESC);
1882 }
1883 }
1884 }
1885 }
1886
1887 else {
1888 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
1889 }
1890
1891 String sql = query.toString();
1892
1893 Query q = session.createQuery(sql);
1894
1895 q.setFirstResult(0);
1896 q.setMaxResults(2);
1897
1898 QueryPos qPos = QueryPos.getInstance(q);
1899
1900 qPos.add(parentCategoryId);
1901
1902 if (orderByComparator != null) {
1903 Object[] values = orderByComparator.getOrderByValues(assetCategory);
1904
1905 for (Object value : values) {
1906 qPos.add(value);
1907 }
1908 }
1909
1910 List<AssetCategory> list = q.list();
1911
1912 if (list.size() == 2) {
1913 return list.get(1);
1914 }
1915 else {
1916 return null;
1917 }
1918 }
1919
1920
1927 public List<AssetCategory> findByVocabularyId(long vocabularyId)
1928 throws SystemException {
1929 return findByVocabularyId(vocabularyId, QueryUtil.ALL_POS,
1930 QueryUtil.ALL_POS, null);
1931 }
1932
1933
1946 public List<AssetCategory> findByVocabularyId(long vocabularyId, int start,
1947 int end) throws SystemException {
1948 return findByVocabularyId(vocabularyId, start, end, null);
1949 }
1950
1951
1965 public List<AssetCategory> findByVocabularyId(long vocabularyId, int start,
1966 int end, OrderByComparator orderByComparator) throws SystemException {
1967 Object[] finderArgs = new Object[] {
1968 vocabularyId,
1969
1970 String.valueOf(start), String.valueOf(end),
1971 String.valueOf(orderByComparator)
1972 };
1973
1974 List<AssetCategory> list = (List<AssetCategory>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_VOCABULARYID,
1975 finderArgs, this);
1976
1977 if (list == null) {
1978 Session session = null;
1979
1980 try {
1981 session = openSession();
1982
1983 StringBundler query = null;
1984
1985 if (orderByComparator != null) {
1986 query = new StringBundler(3 +
1987 (orderByComparator.getOrderByFields().length * 3));
1988 }
1989 else {
1990 query = new StringBundler(3);
1991 }
1992
1993 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
1994
1995 query.append(_FINDER_COLUMN_VOCABULARYID_VOCABULARYID_2);
1996
1997 if (orderByComparator != null) {
1998 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1999 orderByComparator);
2000 }
2001
2002 else {
2003 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
2004 }
2005
2006 String sql = query.toString();
2007
2008 Query q = session.createQuery(sql);
2009
2010 QueryPos qPos = QueryPos.getInstance(q);
2011
2012 qPos.add(vocabularyId);
2013
2014 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
2015 start, end);
2016 }
2017 catch (Exception e) {
2018 throw processException(e);
2019 }
2020 finally {
2021 if (list == null) {
2022 list = new ArrayList<AssetCategory>();
2023 }
2024
2025 cacheResult(list);
2026
2027 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_VOCABULARYID,
2028 finderArgs, list);
2029
2030 closeSession(session);
2031 }
2032 }
2033
2034 return list;
2035 }
2036
2037
2050 public AssetCategory findByVocabularyId_First(long vocabularyId,
2051 OrderByComparator orderByComparator)
2052 throws NoSuchCategoryException, SystemException {
2053 List<AssetCategory> list = findByVocabularyId(vocabularyId, 0, 1,
2054 orderByComparator);
2055
2056 if (list.isEmpty()) {
2057 StringBundler msg = new StringBundler(4);
2058
2059 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2060
2061 msg.append("vocabularyId=");
2062 msg.append(vocabularyId);
2063
2064 msg.append(StringPool.CLOSE_CURLY_BRACE);
2065
2066 throw new NoSuchCategoryException(msg.toString());
2067 }
2068 else {
2069 return list.get(0);
2070 }
2071 }
2072
2073
2086 public AssetCategory findByVocabularyId_Last(long vocabularyId,
2087 OrderByComparator orderByComparator)
2088 throws NoSuchCategoryException, SystemException {
2089 int count = countByVocabularyId(vocabularyId);
2090
2091 List<AssetCategory> list = findByVocabularyId(vocabularyId, count - 1,
2092 count, orderByComparator);
2093
2094 if (list.isEmpty()) {
2095 StringBundler msg = new StringBundler(4);
2096
2097 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2098
2099 msg.append("vocabularyId=");
2100 msg.append(vocabularyId);
2101
2102 msg.append(StringPool.CLOSE_CURLY_BRACE);
2103
2104 throw new NoSuchCategoryException(msg.toString());
2105 }
2106 else {
2107 return list.get(0);
2108 }
2109 }
2110
2111
2125 public AssetCategory[] findByVocabularyId_PrevAndNext(long categoryId,
2126 long vocabularyId, OrderByComparator orderByComparator)
2127 throws NoSuchCategoryException, SystemException {
2128 AssetCategory assetCategory = findByPrimaryKey(categoryId);
2129
2130 Session session = null;
2131
2132 try {
2133 session = openSession();
2134
2135 AssetCategory[] array = new AssetCategoryImpl[3];
2136
2137 array[0] = getByVocabularyId_PrevAndNext(session, assetCategory,
2138 vocabularyId, orderByComparator, true);
2139
2140 array[1] = assetCategory;
2141
2142 array[2] = getByVocabularyId_PrevAndNext(session, assetCategory,
2143 vocabularyId, orderByComparator, false);
2144
2145 return array;
2146 }
2147 catch (Exception e) {
2148 throw processException(e);
2149 }
2150 finally {
2151 closeSession(session);
2152 }
2153 }
2154
2155 protected AssetCategory getByVocabularyId_PrevAndNext(Session session,
2156 AssetCategory assetCategory, long vocabularyId,
2157 OrderByComparator orderByComparator, boolean previous) {
2158 StringBundler query = null;
2159
2160 if (orderByComparator != null) {
2161 query = new StringBundler(6 +
2162 (orderByComparator.getOrderByFields().length * 6));
2163 }
2164 else {
2165 query = new StringBundler(3);
2166 }
2167
2168 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
2169
2170 query.append(_FINDER_COLUMN_VOCABULARYID_VOCABULARYID_2);
2171
2172 if (orderByComparator != null) {
2173 String[] orderByFields = orderByComparator.getOrderByFields();
2174
2175 if (orderByFields.length > 0) {
2176 query.append(WHERE_AND);
2177 }
2178
2179 for (int i = 0; i < orderByFields.length; i++) {
2180 query.append(_ORDER_BY_ENTITY_ALIAS);
2181 query.append(orderByFields[i]);
2182
2183 if ((i + 1) < orderByFields.length) {
2184 if (orderByComparator.isAscending() ^ previous) {
2185 query.append(WHERE_GREATER_THAN_HAS_NEXT);
2186 }
2187 else {
2188 query.append(WHERE_LESSER_THAN_HAS_NEXT);
2189 }
2190 }
2191 else {
2192 if (orderByComparator.isAscending() ^ previous) {
2193 query.append(WHERE_GREATER_THAN);
2194 }
2195 else {
2196 query.append(WHERE_LESSER_THAN);
2197 }
2198 }
2199 }
2200
2201 query.append(ORDER_BY_CLAUSE);
2202
2203 for (int i = 0; i < orderByFields.length; i++) {
2204 query.append(_ORDER_BY_ENTITY_ALIAS);
2205 query.append(orderByFields[i]);
2206
2207 if ((i + 1) < orderByFields.length) {
2208 if (orderByComparator.isAscending() ^ previous) {
2209 query.append(ORDER_BY_ASC_HAS_NEXT);
2210 }
2211 else {
2212 query.append(ORDER_BY_DESC_HAS_NEXT);
2213 }
2214 }
2215 else {
2216 if (orderByComparator.isAscending() ^ previous) {
2217 query.append(ORDER_BY_ASC);
2218 }
2219 else {
2220 query.append(ORDER_BY_DESC);
2221 }
2222 }
2223 }
2224 }
2225
2226 else {
2227 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
2228 }
2229
2230 String sql = query.toString();
2231
2232 Query q = session.createQuery(sql);
2233
2234 q.setFirstResult(0);
2235 q.setMaxResults(2);
2236
2237 QueryPos qPos = QueryPos.getInstance(q);
2238
2239 qPos.add(vocabularyId);
2240
2241 if (orderByComparator != null) {
2242 Object[] values = orderByComparator.getOrderByValues(assetCategory);
2243
2244 for (Object value : values) {
2245 qPos.add(value);
2246 }
2247 }
2248
2249 List<AssetCategory> list = q.list();
2250
2251 if (list.size() == 2) {
2252 return list.get(1);
2253 }
2254 else {
2255 return null;
2256 }
2257 }
2258
2259
2267 public List<AssetCategory> findByP_N(long parentCategoryId, String name)
2268 throws SystemException {
2269 return findByP_N(parentCategoryId, name, QueryUtil.ALL_POS,
2270 QueryUtil.ALL_POS, null);
2271 }
2272
2273
2287 public List<AssetCategory> findByP_N(long parentCategoryId, String name,
2288 int start, int end) throws SystemException {
2289 return findByP_N(parentCategoryId, name, start, end, null);
2290 }
2291
2292
2307 public List<AssetCategory> findByP_N(long parentCategoryId, String name,
2308 int start, int end, OrderByComparator orderByComparator)
2309 throws SystemException {
2310 Object[] finderArgs = new Object[] {
2311 parentCategoryId, name,
2312
2313 String.valueOf(start), String.valueOf(end),
2314 String.valueOf(orderByComparator)
2315 };
2316
2317 List<AssetCategory> list = (List<AssetCategory>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_P_N,
2318 finderArgs, this);
2319
2320 if (list == null) {
2321 Session session = null;
2322
2323 try {
2324 session = openSession();
2325
2326 StringBundler query = null;
2327
2328 if (orderByComparator != null) {
2329 query = new StringBundler(4 +
2330 (orderByComparator.getOrderByFields().length * 3));
2331 }
2332 else {
2333 query = new StringBundler(4);
2334 }
2335
2336 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
2337
2338 query.append(_FINDER_COLUMN_P_N_PARENTCATEGORYID_2);
2339
2340 if (name == null) {
2341 query.append(_FINDER_COLUMN_P_N_NAME_1);
2342 }
2343 else {
2344 if (name.equals(StringPool.BLANK)) {
2345 query.append(_FINDER_COLUMN_P_N_NAME_3);
2346 }
2347 else {
2348 query.append(_FINDER_COLUMN_P_N_NAME_2);
2349 }
2350 }
2351
2352 if (orderByComparator != null) {
2353 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2354 orderByComparator);
2355 }
2356
2357 else {
2358 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
2359 }
2360
2361 String sql = query.toString();
2362
2363 Query q = session.createQuery(sql);
2364
2365 QueryPos qPos = QueryPos.getInstance(q);
2366
2367 qPos.add(parentCategoryId);
2368
2369 if (name != null) {
2370 qPos.add(name);
2371 }
2372
2373 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
2374 start, end);
2375 }
2376 catch (Exception e) {
2377 throw processException(e);
2378 }
2379 finally {
2380 if (list == null) {
2381 list = new ArrayList<AssetCategory>();
2382 }
2383
2384 cacheResult(list);
2385
2386 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_P_N, finderArgs,
2387 list);
2388
2389 closeSession(session);
2390 }
2391 }
2392
2393 return list;
2394 }
2395
2396
2410 public AssetCategory findByP_N_First(long parentCategoryId, String name,
2411 OrderByComparator orderByComparator)
2412 throws NoSuchCategoryException, SystemException {
2413 List<AssetCategory> list = findByP_N(parentCategoryId, name, 0, 1,
2414 orderByComparator);
2415
2416 if (list.isEmpty()) {
2417 StringBundler msg = new StringBundler(6);
2418
2419 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2420
2421 msg.append("parentCategoryId=");
2422 msg.append(parentCategoryId);
2423
2424 msg.append(", name=");
2425 msg.append(name);
2426
2427 msg.append(StringPool.CLOSE_CURLY_BRACE);
2428
2429 throw new NoSuchCategoryException(msg.toString());
2430 }
2431 else {
2432 return list.get(0);
2433 }
2434 }
2435
2436
2450 public AssetCategory findByP_N_Last(long parentCategoryId, String name,
2451 OrderByComparator orderByComparator)
2452 throws NoSuchCategoryException, SystemException {
2453 int count = countByP_N(parentCategoryId, name);
2454
2455 List<AssetCategory> list = findByP_N(parentCategoryId, name, count - 1,
2456 count, orderByComparator);
2457
2458 if (list.isEmpty()) {
2459 StringBundler msg = new StringBundler(6);
2460
2461 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2462
2463 msg.append("parentCategoryId=");
2464 msg.append(parentCategoryId);
2465
2466 msg.append(", name=");
2467 msg.append(name);
2468
2469 msg.append(StringPool.CLOSE_CURLY_BRACE);
2470
2471 throw new NoSuchCategoryException(msg.toString());
2472 }
2473 else {
2474 return list.get(0);
2475 }
2476 }
2477
2478
2493 public AssetCategory[] findByP_N_PrevAndNext(long categoryId,
2494 long parentCategoryId, String name, OrderByComparator orderByComparator)
2495 throws NoSuchCategoryException, SystemException {
2496 AssetCategory assetCategory = findByPrimaryKey(categoryId);
2497
2498 Session session = null;
2499
2500 try {
2501 session = openSession();
2502
2503 AssetCategory[] array = new AssetCategoryImpl[3];
2504
2505 array[0] = getByP_N_PrevAndNext(session, assetCategory,
2506 parentCategoryId, name, orderByComparator, true);
2507
2508 array[1] = assetCategory;
2509
2510 array[2] = getByP_N_PrevAndNext(session, assetCategory,
2511 parentCategoryId, name, orderByComparator, false);
2512
2513 return array;
2514 }
2515 catch (Exception e) {
2516 throw processException(e);
2517 }
2518 finally {
2519 closeSession(session);
2520 }
2521 }
2522
2523 protected AssetCategory getByP_N_PrevAndNext(Session session,
2524 AssetCategory assetCategory, long parentCategoryId, String name,
2525 OrderByComparator orderByComparator, boolean previous) {
2526 StringBundler query = null;
2527
2528 if (orderByComparator != null) {
2529 query = new StringBundler(6 +
2530 (orderByComparator.getOrderByFields().length * 6));
2531 }
2532 else {
2533 query = new StringBundler(3);
2534 }
2535
2536 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
2537
2538 query.append(_FINDER_COLUMN_P_N_PARENTCATEGORYID_2);
2539
2540 if (name == null) {
2541 query.append(_FINDER_COLUMN_P_N_NAME_1);
2542 }
2543 else {
2544 if (name.equals(StringPool.BLANK)) {
2545 query.append(_FINDER_COLUMN_P_N_NAME_3);
2546 }
2547 else {
2548 query.append(_FINDER_COLUMN_P_N_NAME_2);
2549 }
2550 }
2551
2552 if (orderByComparator != null) {
2553 String[] orderByFields = orderByComparator.getOrderByFields();
2554
2555 if (orderByFields.length > 0) {
2556 query.append(WHERE_AND);
2557 }
2558
2559 for (int i = 0; i < orderByFields.length; i++) {
2560 query.append(_ORDER_BY_ENTITY_ALIAS);
2561 query.append(orderByFields[i]);
2562
2563 if ((i + 1) < orderByFields.length) {
2564 if (orderByComparator.isAscending() ^ previous) {
2565 query.append(WHERE_GREATER_THAN_HAS_NEXT);
2566 }
2567 else {
2568 query.append(WHERE_LESSER_THAN_HAS_NEXT);
2569 }
2570 }
2571 else {
2572 if (orderByComparator.isAscending() ^ previous) {
2573 query.append(WHERE_GREATER_THAN);
2574 }
2575 else {
2576 query.append(WHERE_LESSER_THAN);
2577 }
2578 }
2579 }
2580
2581 query.append(ORDER_BY_CLAUSE);
2582
2583 for (int i = 0; i < orderByFields.length; i++) {
2584 query.append(_ORDER_BY_ENTITY_ALIAS);
2585 query.append(orderByFields[i]);
2586
2587 if ((i + 1) < orderByFields.length) {
2588 if (orderByComparator.isAscending() ^ previous) {
2589 query.append(ORDER_BY_ASC_HAS_NEXT);
2590 }
2591 else {
2592 query.append(ORDER_BY_DESC_HAS_NEXT);
2593 }
2594 }
2595 else {
2596 if (orderByComparator.isAscending() ^ previous) {
2597 query.append(ORDER_BY_ASC);
2598 }
2599 else {
2600 query.append(ORDER_BY_DESC);
2601 }
2602 }
2603 }
2604 }
2605
2606 else {
2607 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
2608 }
2609
2610 String sql = query.toString();
2611
2612 Query q = session.createQuery(sql);
2613
2614 q.setFirstResult(0);
2615 q.setMaxResults(2);
2616
2617 QueryPos qPos = QueryPos.getInstance(q);
2618
2619 qPos.add(parentCategoryId);
2620
2621 if (name != null) {
2622 qPos.add(name);
2623 }
2624
2625 if (orderByComparator != null) {
2626 Object[] values = orderByComparator.getOrderByValues(assetCategory);
2627
2628 for (Object value : values) {
2629 qPos.add(value);
2630 }
2631 }
2632
2633 List<AssetCategory> list = q.list();
2634
2635 if (list.size() == 2) {
2636 return list.get(1);
2637 }
2638 else {
2639 return null;
2640 }
2641 }
2642
2643
2651 public List<AssetCategory> findByP_V(long parentCategoryId,
2652 long vocabularyId) throws SystemException {
2653 return findByP_V(parentCategoryId, vocabularyId, QueryUtil.ALL_POS,
2654 QueryUtil.ALL_POS, null);
2655 }
2656
2657
2671 public List<AssetCategory> findByP_V(long parentCategoryId,
2672 long vocabularyId, int start, int end) throws SystemException {
2673 return findByP_V(parentCategoryId, vocabularyId, start, end, null);
2674 }
2675
2676
2691 public List<AssetCategory> findByP_V(long parentCategoryId,
2692 long vocabularyId, int start, int end,
2693 OrderByComparator orderByComparator) throws SystemException {
2694 Object[] finderArgs = new Object[] {
2695 parentCategoryId, vocabularyId,
2696
2697 String.valueOf(start), String.valueOf(end),
2698 String.valueOf(orderByComparator)
2699 };
2700
2701 List<AssetCategory> list = (List<AssetCategory>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_P_V,
2702 finderArgs, this);
2703
2704 if (list == null) {
2705 Session session = null;
2706
2707 try {
2708 session = openSession();
2709
2710 StringBundler query = null;
2711
2712 if (orderByComparator != null) {
2713 query = new StringBundler(4 +
2714 (orderByComparator.getOrderByFields().length * 3));
2715 }
2716 else {
2717 query = new StringBundler(4);
2718 }
2719
2720 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
2721
2722 query.append(_FINDER_COLUMN_P_V_PARENTCATEGORYID_2);
2723
2724 query.append(_FINDER_COLUMN_P_V_VOCABULARYID_2);
2725
2726 if (orderByComparator != null) {
2727 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2728 orderByComparator);
2729 }
2730
2731 else {
2732 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
2733 }
2734
2735 String sql = query.toString();
2736
2737 Query q = session.createQuery(sql);
2738
2739 QueryPos qPos = QueryPos.getInstance(q);
2740
2741 qPos.add(parentCategoryId);
2742
2743 qPos.add(vocabularyId);
2744
2745 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
2746 start, end);
2747 }
2748 catch (Exception e) {
2749 throw processException(e);
2750 }
2751 finally {
2752 if (list == null) {
2753 list = new ArrayList<AssetCategory>();
2754 }
2755
2756 cacheResult(list);
2757
2758 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_P_V, finderArgs,
2759 list);
2760
2761 closeSession(session);
2762 }
2763 }
2764
2765 return list;
2766 }
2767
2768
2782 public AssetCategory findByP_V_First(long parentCategoryId,
2783 long vocabularyId, OrderByComparator orderByComparator)
2784 throws NoSuchCategoryException, SystemException {
2785 List<AssetCategory> list = findByP_V(parentCategoryId, vocabularyId, 0,
2786 1, orderByComparator);
2787
2788 if (list.isEmpty()) {
2789 StringBundler msg = new StringBundler(6);
2790
2791 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2792
2793 msg.append("parentCategoryId=");
2794 msg.append(parentCategoryId);
2795
2796 msg.append(", vocabularyId=");
2797 msg.append(vocabularyId);
2798
2799 msg.append(StringPool.CLOSE_CURLY_BRACE);
2800
2801 throw new NoSuchCategoryException(msg.toString());
2802 }
2803 else {
2804 return list.get(0);
2805 }
2806 }
2807
2808
2822 public AssetCategory findByP_V_Last(long parentCategoryId,
2823 long vocabularyId, OrderByComparator orderByComparator)
2824 throws NoSuchCategoryException, SystemException {
2825 int count = countByP_V(parentCategoryId, vocabularyId);
2826
2827 List<AssetCategory> list = findByP_V(parentCategoryId, vocabularyId,
2828 count - 1, count, orderByComparator);
2829
2830 if (list.isEmpty()) {
2831 StringBundler msg = new StringBundler(6);
2832
2833 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2834
2835 msg.append("parentCategoryId=");
2836 msg.append(parentCategoryId);
2837
2838 msg.append(", vocabularyId=");
2839 msg.append(vocabularyId);
2840
2841 msg.append(StringPool.CLOSE_CURLY_BRACE);
2842
2843 throw new NoSuchCategoryException(msg.toString());
2844 }
2845 else {
2846 return list.get(0);
2847 }
2848 }
2849
2850
2865 public AssetCategory[] findByP_V_PrevAndNext(long categoryId,
2866 long parentCategoryId, long vocabularyId,
2867 OrderByComparator orderByComparator)
2868 throws NoSuchCategoryException, SystemException {
2869 AssetCategory assetCategory = findByPrimaryKey(categoryId);
2870
2871 Session session = null;
2872
2873 try {
2874 session = openSession();
2875
2876 AssetCategory[] array = new AssetCategoryImpl[3];
2877
2878 array[0] = getByP_V_PrevAndNext(session, assetCategory,
2879 parentCategoryId, vocabularyId, orderByComparator, true);
2880
2881 array[1] = assetCategory;
2882
2883 array[2] = getByP_V_PrevAndNext(session, assetCategory,
2884 parentCategoryId, vocabularyId, orderByComparator, false);
2885
2886 return array;
2887 }
2888 catch (Exception e) {
2889 throw processException(e);
2890 }
2891 finally {
2892 closeSession(session);
2893 }
2894 }
2895
2896 protected AssetCategory getByP_V_PrevAndNext(Session session,
2897 AssetCategory assetCategory, long parentCategoryId, long vocabularyId,
2898 OrderByComparator orderByComparator, boolean previous) {
2899 StringBundler query = null;
2900
2901 if (orderByComparator != null) {
2902 query = new StringBundler(6 +
2903 (orderByComparator.getOrderByFields().length * 6));
2904 }
2905 else {
2906 query = new StringBundler(3);
2907 }
2908
2909 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
2910
2911 query.append(_FINDER_COLUMN_P_V_PARENTCATEGORYID_2);
2912
2913 query.append(_FINDER_COLUMN_P_V_VOCABULARYID_2);
2914
2915 if (orderByComparator != null) {
2916 String[] orderByFields = orderByComparator.getOrderByFields();
2917
2918 if (orderByFields.length > 0) {
2919 query.append(WHERE_AND);
2920 }
2921
2922 for (int i = 0; i < orderByFields.length; i++) {
2923 query.append(_ORDER_BY_ENTITY_ALIAS);
2924 query.append(orderByFields[i]);
2925
2926 if ((i + 1) < orderByFields.length) {
2927 if (orderByComparator.isAscending() ^ previous) {
2928 query.append(WHERE_GREATER_THAN_HAS_NEXT);
2929 }
2930 else {
2931 query.append(WHERE_LESSER_THAN_HAS_NEXT);
2932 }
2933 }
2934 else {
2935 if (orderByComparator.isAscending() ^ previous) {
2936 query.append(WHERE_GREATER_THAN);
2937 }
2938 else {
2939 query.append(WHERE_LESSER_THAN);
2940 }
2941 }
2942 }
2943
2944 query.append(ORDER_BY_CLAUSE);
2945
2946 for (int i = 0; i < orderByFields.length; i++) {
2947 query.append(_ORDER_BY_ENTITY_ALIAS);
2948 query.append(orderByFields[i]);
2949
2950 if ((i + 1) < orderByFields.length) {
2951 if (orderByComparator.isAscending() ^ previous) {
2952 query.append(ORDER_BY_ASC_HAS_NEXT);
2953 }
2954 else {
2955 query.append(ORDER_BY_DESC_HAS_NEXT);
2956 }
2957 }
2958 else {
2959 if (orderByComparator.isAscending() ^ previous) {
2960 query.append(ORDER_BY_ASC);
2961 }
2962 else {
2963 query.append(ORDER_BY_DESC);
2964 }
2965 }
2966 }
2967 }
2968
2969 else {
2970 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
2971 }
2972
2973 String sql = query.toString();
2974
2975 Query q = session.createQuery(sql);
2976
2977 q.setFirstResult(0);
2978 q.setMaxResults(2);
2979
2980 QueryPos qPos = QueryPos.getInstance(q);
2981
2982 qPos.add(parentCategoryId);
2983
2984 qPos.add(vocabularyId);
2985
2986 if (orderByComparator != null) {
2987 Object[] values = orderByComparator.getOrderByValues(assetCategory);
2988
2989 for (Object value : values) {
2990 qPos.add(value);
2991 }
2992 }
2993
2994 List<AssetCategory> list = q.list();
2995
2996 if (list.size() == 2) {
2997 return list.get(1);
2998 }
2999 else {
3000 return null;
3001 }
3002 }
3003
3004
3012 public List<AssetCategory> findByN_V(String name, long vocabularyId)
3013 throws SystemException {
3014 return findByN_V(name, vocabularyId, QueryUtil.ALL_POS,
3015 QueryUtil.ALL_POS, null);
3016 }
3017
3018
3032 public List<AssetCategory> findByN_V(String name, long vocabularyId,
3033 int start, int end) throws SystemException {
3034 return findByN_V(name, vocabularyId, start, end, null);
3035 }
3036
3037
3052 public List<AssetCategory> findByN_V(String name, long vocabularyId,
3053 int start, int end, OrderByComparator orderByComparator)
3054 throws SystemException {
3055 Object[] finderArgs = new Object[] {
3056 name, vocabularyId,
3057
3058 String.valueOf(start), String.valueOf(end),
3059 String.valueOf(orderByComparator)
3060 };
3061
3062 List<AssetCategory> list = (List<AssetCategory>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_N_V,
3063 finderArgs, this);
3064
3065 if (list == null) {
3066 Session session = null;
3067
3068 try {
3069 session = openSession();
3070
3071 StringBundler query = null;
3072
3073 if (orderByComparator != null) {
3074 query = new StringBundler(4 +
3075 (orderByComparator.getOrderByFields().length * 3));
3076 }
3077 else {
3078 query = new StringBundler(4);
3079 }
3080
3081 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
3082
3083 if (name == null) {
3084 query.append(_FINDER_COLUMN_N_V_NAME_1);
3085 }
3086 else {
3087 if (name.equals(StringPool.BLANK)) {
3088 query.append(_FINDER_COLUMN_N_V_NAME_3);
3089 }
3090 else {
3091 query.append(_FINDER_COLUMN_N_V_NAME_2);
3092 }
3093 }
3094
3095 query.append(_FINDER_COLUMN_N_V_VOCABULARYID_2);
3096
3097 if (orderByComparator != null) {
3098 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3099 orderByComparator);
3100 }
3101
3102 else {
3103 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
3104 }
3105
3106 String sql = query.toString();
3107
3108 Query q = session.createQuery(sql);
3109
3110 QueryPos qPos = QueryPos.getInstance(q);
3111
3112 if (name != null) {
3113 qPos.add(name);
3114 }
3115
3116 qPos.add(vocabularyId);
3117
3118 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
3119 start, end);
3120 }
3121 catch (Exception e) {
3122 throw processException(e);
3123 }
3124 finally {
3125 if (list == null) {
3126 list = new ArrayList<AssetCategory>();
3127 }
3128
3129 cacheResult(list);
3130
3131 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_N_V, finderArgs,
3132 list);
3133
3134 closeSession(session);
3135 }
3136 }
3137
3138 return list;
3139 }
3140
3141
3155 public AssetCategory findByN_V_First(String name, long vocabularyId,
3156 OrderByComparator orderByComparator)
3157 throws NoSuchCategoryException, SystemException {
3158 List<AssetCategory> list = findByN_V(name, vocabularyId, 0, 1,
3159 orderByComparator);
3160
3161 if (list.isEmpty()) {
3162 StringBundler msg = new StringBundler(6);
3163
3164 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3165
3166 msg.append("name=");
3167 msg.append(name);
3168
3169 msg.append(", vocabularyId=");
3170 msg.append(vocabularyId);
3171
3172 msg.append(StringPool.CLOSE_CURLY_BRACE);
3173
3174 throw new NoSuchCategoryException(msg.toString());
3175 }
3176 else {
3177 return list.get(0);
3178 }
3179 }
3180
3181
3195 public AssetCategory findByN_V_Last(String name, long vocabularyId,
3196 OrderByComparator orderByComparator)
3197 throws NoSuchCategoryException, SystemException {
3198 int count = countByN_V(name, vocabularyId);
3199
3200 List<AssetCategory> list = findByN_V(name, vocabularyId, count - 1,
3201 count, orderByComparator);
3202
3203 if (list.isEmpty()) {
3204 StringBundler msg = new StringBundler(6);
3205
3206 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3207
3208 msg.append("name=");
3209 msg.append(name);
3210
3211 msg.append(", vocabularyId=");
3212 msg.append(vocabularyId);
3213
3214 msg.append(StringPool.CLOSE_CURLY_BRACE);
3215
3216 throw new NoSuchCategoryException(msg.toString());
3217 }
3218 else {
3219 return list.get(0);
3220 }
3221 }
3222
3223
3238 public AssetCategory[] findByN_V_PrevAndNext(long categoryId, String name,
3239 long vocabularyId, OrderByComparator orderByComparator)
3240 throws NoSuchCategoryException, SystemException {
3241 AssetCategory assetCategory = findByPrimaryKey(categoryId);
3242
3243 Session session = null;
3244
3245 try {
3246 session = openSession();
3247
3248 AssetCategory[] array = new AssetCategoryImpl[3];
3249
3250 array[0] = getByN_V_PrevAndNext(session, assetCategory, name,
3251 vocabularyId, orderByComparator, true);
3252
3253 array[1] = assetCategory;
3254
3255 array[2] = getByN_V_PrevAndNext(session, assetCategory, name,
3256 vocabularyId, orderByComparator, false);
3257
3258 return array;
3259 }
3260 catch (Exception e) {
3261 throw processException(e);
3262 }
3263 finally {
3264 closeSession(session);
3265 }
3266 }
3267
3268 protected AssetCategory getByN_V_PrevAndNext(Session session,
3269 AssetCategory assetCategory, String name, long vocabularyId,
3270 OrderByComparator orderByComparator, boolean previous) {
3271 StringBundler query = null;
3272
3273 if (orderByComparator != null) {
3274 query = new StringBundler(6 +
3275 (orderByComparator.getOrderByFields().length * 6));
3276 }
3277 else {
3278 query = new StringBundler(3);
3279 }
3280
3281 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
3282
3283 if (name == null) {
3284 query.append(_FINDER_COLUMN_N_V_NAME_1);
3285 }
3286 else {
3287 if (name.equals(StringPool.BLANK)) {
3288 query.append(_FINDER_COLUMN_N_V_NAME_3);
3289 }
3290 else {
3291 query.append(_FINDER_COLUMN_N_V_NAME_2);
3292 }
3293 }
3294
3295 query.append(_FINDER_COLUMN_N_V_VOCABULARYID_2);
3296
3297 if (orderByComparator != null) {
3298 String[] orderByFields = orderByComparator.getOrderByFields();
3299
3300 if (orderByFields.length > 0) {
3301 query.append(WHERE_AND);
3302 }
3303
3304 for (int i = 0; i < orderByFields.length; i++) {
3305 query.append(_ORDER_BY_ENTITY_ALIAS);
3306 query.append(orderByFields[i]);
3307
3308 if ((i + 1) < orderByFields.length) {
3309 if (orderByComparator.isAscending() ^ previous) {
3310 query.append(WHERE_GREATER_THAN_HAS_NEXT);
3311 }
3312 else {
3313 query.append(WHERE_LESSER_THAN_HAS_NEXT);
3314 }
3315 }
3316 else {
3317 if (orderByComparator.isAscending() ^ previous) {
3318 query.append(WHERE_GREATER_THAN);
3319 }
3320 else {
3321 query.append(WHERE_LESSER_THAN);
3322 }
3323 }
3324 }
3325
3326 query.append(ORDER_BY_CLAUSE);
3327
3328 for (int i = 0; i < orderByFields.length; i++) {
3329 query.append(_ORDER_BY_ENTITY_ALIAS);
3330 query.append(orderByFields[i]);
3331
3332 if ((i + 1) < orderByFields.length) {
3333 if (orderByComparator.isAscending() ^ previous) {
3334 query.append(ORDER_BY_ASC_HAS_NEXT);
3335 }
3336 else {
3337 query.append(ORDER_BY_DESC_HAS_NEXT);
3338 }
3339 }
3340 else {
3341 if (orderByComparator.isAscending() ^ previous) {
3342 query.append(ORDER_BY_ASC);
3343 }
3344 else {
3345 query.append(ORDER_BY_DESC);
3346 }
3347 }
3348 }
3349 }
3350
3351 else {
3352 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
3353 }
3354
3355 String sql = query.toString();
3356
3357 Query q = session.createQuery(sql);
3358
3359 q.setFirstResult(0);
3360 q.setMaxResults(2);
3361
3362 QueryPos qPos = QueryPos.getInstance(q);
3363
3364 if (name != null) {
3365 qPos.add(name);
3366 }
3367
3368 qPos.add(vocabularyId);
3369
3370 if (orderByComparator != null) {
3371 Object[] values = orderByComparator.getOrderByValues(assetCategory);
3372
3373 for (Object value : values) {
3374 qPos.add(value);
3375 }
3376 }
3377
3378 List<AssetCategory> list = q.list();
3379
3380 if (list.size() == 2) {
3381 return list.get(1);
3382 }
3383 else {
3384 return null;
3385 }
3386 }
3387
3388
3398 public AssetCategory findByP_N_V(long parentCategoryId, String name,
3399 long vocabularyId) throws NoSuchCategoryException, SystemException {
3400 AssetCategory assetCategory = fetchByP_N_V(parentCategoryId, name,
3401 vocabularyId);
3402
3403 if (assetCategory == null) {
3404 StringBundler msg = new StringBundler(8);
3405
3406 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3407
3408 msg.append("parentCategoryId=");
3409 msg.append(parentCategoryId);
3410
3411 msg.append(", name=");
3412 msg.append(name);
3413
3414 msg.append(", vocabularyId=");
3415 msg.append(vocabularyId);
3416
3417 msg.append(StringPool.CLOSE_CURLY_BRACE);
3418
3419 if (_log.isWarnEnabled()) {
3420 _log.warn(msg.toString());
3421 }
3422
3423 throw new NoSuchCategoryException(msg.toString());
3424 }
3425
3426 return assetCategory;
3427 }
3428
3429
3438 public AssetCategory fetchByP_N_V(long parentCategoryId, String name,
3439 long vocabularyId) throws SystemException {
3440 return fetchByP_N_V(parentCategoryId, name, vocabularyId, true);
3441 }
3442
3443
3452 public AssetCategory fetchByP_N_V(long parentCategoryId, String name,
3453 long vocabularyId, boolean retrieveFromCache) throws SystemException {
3454 Object[] finderArgs = new Object[] { parentCategoryId, name, vocabularyId };
3455
3456 Object result = null;
3457
3458 if (retrieveFromCache) {
3459 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_P_N_V,
3460 finderArgs, this);
3461 }
3462
3463 if (result == null) {
3464 Session session = null;
3465
3466 try {
3467 session = openSession();
3468
3469 StringBundler query = new StringBundler(5);
3470
3471 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
3472
3473 query.append(_FINDER_COLUMN_P_N_V_PARENTCATEGORYID_2);
3474
3475 if (name == null) {
3476 query.append(_FINDER_COLUMN_P_N_V_NAME_1);
3477 }
3478 else {
3479 if (name.equals(StringPool.BLANK)) {
3480 query.append(_FINDER_COLUMN_P_N_V_NAME_3);
3481 }
3482 else {
3483 query.append(_FINDER_COLUMN_P_N_V_NAME_2);
3484 }
3485 }
3486
3487 query.append(_FINDER_COLUMN_P_N_V_VOCABULARYID_2);
3488
3489 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
3490
3491 String sql = query.toString();
3492
3493 Query q = session.createQuery(sql);
3494
3495 QueryPos qPos = QueryPos.getInstance(q);
3496
3497 qPos.add(parentCategoryId);
3498
3499 if (name != null) {
3500 qPos.add(name);
3501 }
3502
3503 qPos.add(vocabularyId);
3504
3505 List<AssetCategory> list = q.list();
3506
3507 result = list;
3508
3509 AssetCategory assetCategory = null;
3510
3511 if (list.isEmpty()) {
3512 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_P_N_V,
3513 finderArgs, list);
3514 }
3515 else {
3516 assetCategory = list.get(0);
3517
3518 cacheResult(assetCategory);
3519
3520 if ((assetCategory.getParentCategoryId() != parentCategoryId) ||
3521 (assetCategory.getName() == null) ||
3522 !assetCategory.getName().equals(name) ||
3523 (assetCategory.getVocabularyId() != vocabularyId)) {
3524 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_P_N_V,
3525 finderArgs, assetCategory);
3526 }
3527 }
3528
3529 return assetCategory;
3530 }
3531 catch (Exception e) {
3532 throw processException(e);
3533 }
3534 finally {
3535 if (result == null) {
3536 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_P_N_V,
3537 finderArgs, new ArrayList<AssetCategory>());
3538 }
3539
3540 closeSession(session);
3541 }
3542 }
3543 else {
3544 if (result instanceof List<?>) {
3545 return null;
3546 }
3547 else {
3548 return (AssetCategory)result;
3549 }
3550 }
3551 }
3552
3553
3559 public List<AssetCategory> findAll() throws SystemException {
3560 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
3561 }
3562
3563
3575 public List<AssetCategory> findAll(int start, int end)
3576 throws SystemException {
3577 return findAll(start, end, null);
3578 }
3579
3580
3593 public List<AssetCategory> findAll(int start, int end,
3594 OrderByComparator orderByComparator) throws SystemException {
3595 Object[] finderArgs = new Object[] {
3596 String.valueOf(start), String.valueOf(end),
3597 String.valueOf(orderByComparator)
3598 };
3599
3600 List<AssetCategory> list = (List<AssetCategory>)FinderCacheUtil.getResult(FINDER_PATH_FIND_ALL,
3601 finderArgs, this);
3602
3603 if (list == null) {
3604 Session session = null;
3605
3606 try {
3607 session = openSession();
3608
3609 StringBundler query = null;
3610 String sql = null;
3611
3612 if (orderByComparator != null) {
3613 query = new StringBundler(2 +
3614 (orderByComparator.getOrderByFields().length * 3));
3615
3616 query.append(_SQL_SELECT_ASSETCATEGORY);
3617
3618 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3619 orderByComparator);
3620
3621 sql = query.toString();
3622 }
3623 else {
3624 sql = _SQL_SELECT_ASSETCATEGORY.concat(AssetCategoryModelImpl.ORDER_BY_JPQL);
3625 }
3626
3627 Query q = session.createQuery(sql);
3628
3629 if (orderByComparator == null) {
3630 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
3631 start, end, false);
3632
3633 Collections.sort(list);
3634 }
3635 else {
3636 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
3637 start, end);
3638 }
3639 }
3640 catch (Exception e) {
3641 throw processException(e);
3642 }
3643 finally {
3644 if (list == null) {
3645 list = new ArrayList<AssetCategory>();
3646 }
3647
3648 cacheResult(list);
3649
3650 FinderCacheUtil.putResult(FINDER_PATH_FIND_ALL, finderArgs, list);
3651
3652 closeSession(session);
3653 }
3654 }
3655
3656 return list;
3657 }
3658
3659
3665 public void removeByUuid(String uuid) throws SystemException {
3666 for (AssetCategory assetCategory : findByUuid(uuid)) {
3667 remove(assetCategory);
3668 }
3669 }
3670
3671
3678 public void removeByUUID_G(String uuid, long groupId)
3679 throws NoSuchCategoryException, SystemException {
3680 AssetCategory assetCategory = findByUUID_G(uuid, groupId);
3681
3682 remove(assetCategory);
3683 }
3684
3685
3691 public void removeByGroupId(long groupId) throws SystemException {
3692 for (AssetCategory assetCategory : findByGroupId(groupId)) {
3693 remove(assetCategory);
3694 }
3695 }
3696
3697
3703 public void removeByParentCategoryId(long parentCategoryId)
3704 throws SystemException {
3705 for (AssetCategory assetCategory : findByParentCategoryId(
3706 parentCategoryId)) {
3707 remove(assetCategory);
3708 }
3709 }
3710
3711
3717 public void removeByVocabularyId(long vocabularyId)
3718 throws SystemException {
3719 for (AssetCategory assetCategory : findByVocabularyId(vocabularyId)) {
3720 remove(assetCategory);
3721 }
3722 }
3723
3724
3731 public void removeByP_N(long parentCategoryId, String name)
3732 throws SystemException {
3733 for (AssetCategory assetCategory : findByP_N(parentCategoryId, name)) {
3734 remove(assetCategory);
3735 }
3736 }
3737
3738
3745 public void removeByP_V(long parentCategoryId, long vocabularyId)
3746 throws SystemException {
3747 for (AssetCategory assetCategory : findByP_V(parentCategoryId,
3748 vocabularyId)) {
3749 remove(assetCategory);
3750 }
3751 }
3752
3753
3760 public void removeByN_V(String name, long vocabularyId)
3761 throws SystemException {
3762 for (AssetCategory assetCategory : findByN_V(name, vocabularyId)) {
3763 remove(assetCategory);
3764 }
3765 }
3766
3767
3775 public void removeByP_N_V(long parentCategoryId, String name,
3776 long vocabularyId) throws NoSuchCategoryException, SystemException {
3777 AssetCategory assetCategory = findByP_N_V(parentCategoryId, name,
3778 vocabularyId);
3779
3780 remove(assetCategory);
3781 }
3782
3783
3788 public void removeAll() throws SystemException {
3789 for (AssetCategory assetCategory : findAll()) {
3790 remove(assetCategory);
3791 }
3792 }
3793
3794
3801 public int countByUuid(String uuid) throws SystemException {
3802 Object[] finderArgs = new Object[] { uuid };
3803
3804 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID,
3805 finderArgs, this);
3806
3807 if (count == null) {
3808 Session session = null;
3809
3810 try {
3811 session = openSession();
3812
3813 StringBundler query = new StringBundler(2);
3814
3815 query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
3816
3817 if (uuid == null) {
3818 query.append(_FINDER_COLUMN_UUID_UUID_1);
3819 }
3820 else {
3821 if (uuid.equals(StringPool.BLANK)) {
3822 query.append(_FINDER_COLUMN_UUID_UUID_3);
3823 }
3824 else {
3825 query.append(_FINDER_COLUMN_UUID_UUID_2);
3826 }
3827 }
3828
3829 String sql = query.toString();
3830
3831 Query q = session.createQuery(sql);
3832
3833 QueryPos qPos = QueryPos.getInstance(q);
3834
3835 if (uuid != null) {
3836 qPos.add(uuid);
3837 }
3838
3839 count = (Long)q.uniqueResult();
3840 }
3841 catch (Exception e) {
3842 throw processException(e);
3843 }
3844 finally {
3845 if (count == null) {
3846 count = Long.valueOf(0);
3847 }
3848
3849 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID,
3850 finderArgs, count);
3851
3852 closeSession(session);
3853 }
3854 }
3855
3856 return count.intValue();
3857 }
3858
3859
3867 public int countByUUID_G(String uuid, long groupId)
3868 throws SystemException {
3869 Object[] finderArgs = new Object[] { uuid, groupId };
3870
3871 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID_G,
3872 finderArgs, this);
3873
3874 if (count == null) {
3875 Session session = null;
3876
3877 try {
3878 session = openSession();
3879
3880 StringBundler query = new StringBundler(3);
3881
3882 query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
3883
3884 if (uuid == null) {
3885 query.append(_FINDER_COLUMN_UUID_G_UUID_1);
3886 }
3887 else {
3888 if (uuid.equals(StringPool.BLANK)) {
3889 query.append(_FINDER_COLUMN_UUID_G_UUID_3);
3890 }
3891 else {
3892 query.append(_FINDER_COLUMN_UUID_G_UUID_2);
3893 }
3894 }
3895
3896 query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
3897
3898 String sql = query.toString();
3899
3900 Query q = session.createQuery(sql);
3901
3902 QueryPos qPos = QueryPos.getInstance(q);
3903
3904 if (uuid != null) {
3905 qPos.add(uuid);
3906 }
3907
3908 qPos.add(groupId);
3909
3910 count = (Long)q.uniqueResult();
3911 }
3912 catch (Exception e) {
3913 throw processException(e);
3914 }
3915 finally {
3916 if (count == null) {
3917 count = Long.valueOf(0);
3918 }
3919
3920 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G,
3921 finderArgs, count);
3922
3923 closeSession(session);
3924 }
3925 }
3926
3927 return count.intValue();
3928 }
3929
3930
3937 public int countByGroupId(long groupId) throws SystemException {
3938 Object[] finderArgs = new Object[] { groupId };
3939
3940 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_GROUPID,
3941 finderArgs, this);
3942
3943 if (count == null) {
3944 Session session = null;
3945
3946 try {
3947 session = openSession();
3948
3949 StringBundler query = new StringBundler(2);
3950
3951 query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
3952
3953 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
3954
3955 String sql = query.toString();
3956
3957 Query q = session.createQuery(sql);
3958
3959 QueryPos qPos = QueryPos.getInstance(q);
3960
3961 qPos.add(groupId);
3962
3963 count = (Long)q.uniqueResult();
3964 }
3965 catch (Exception e) {
3966 throw processException(e);
3967 }
3968 finally {
3969 if (count == null) {
3970 count = Long.valueOf(0);
3971 }
3972
3973 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_GROUPID,
3974 finderArgs, count);
3975
3976 closeSession(session);
3977 }
3978 }
3979
3980 return count.intValue();
3981 }
3982
3983
3990 public int filterCountByGroupId(long groupId) throws SystemException {
3991 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
3992 return countByGroupId(groupId);
3993 }
3994
3995 Session session = null;
3996
3997 try {
3998 session = openSession();
3999
4000 StringBundler query = new StringBundler(2);
4001
4002 query.append(_FILTER_SQL_COUNT_ASSETCATEGORY_WHERE);
4003
4004 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
4005
4006 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
4007 AssetCategory.class.getName(), _FILTER_COLUMN_PK,
4008 _FILTER_COLUMN_USERID, groupId);
4009
4010 SQLQuery q = session.createSQLQuery(sql);
4011
4012 q.addScalar(COUNT_COLUMN_NAME,
4013 com.liferay.portal.kernel.dao.orm.Type.LONG);
4014
4015 QueryPos qPos = QueryPos.getInstance(q);
4016
4017 qPos.add(groupId);
4018
4019 Long count = (Long)q.uniqueResult();
4020
4021 return count.intValue();
4022 }
4023 catch (Exception e) {
4024 throw processException(e);
4025 }
4026 finally {
4027 closeSession(session);
4028 }
4029 }
4030
4031
4038 public int countByParentCategoryId(long parentCategoryId)
4039 throws SystemException {
4040 Object[] finderArgs = new Object[] { parentCategoryId };
4041
4042 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_PARENTCATEGORYID,
4043 finderArgs, this);
4044
4045 if (count == null) {
4046 Session session = null;
4047
4048 try {
4049 session = openSession();
4050
4051 StringBundler query = new StringBundler(2);
4052
4053 query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
4054
4055 query.append(_FINDER_COLUMN_PARENTCATEGORYID_PARENTCATEGORYID_2);
4056
4057 String sql = query.toString();
4058
4059 Query q = session.createQuery(sql);
4060
4061 QueryPos qPos = QueryPos.getInstance(q);
4062
4063 qPos.add(parentCategoryId);
4064
4065 count = (Long)q.uniqueResult();
4066 }
4067 catch (Exception e) {
4068 throw processException(e);
4069 }
4070 finally {
4071 if (count == null) {
4072 count = Long.valueOf(0);
4073 }
4074
4075 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_PARENTCATEGORYID,
4076 finderArgs, count);
4077
4078 closeSession(session);
4079 }
4080 }
4081
4082 return count.intValue();
4083 }
4084
4085
4092 public int countByVocabularyId(long vocabularyId) throws SystemException {
4093 Object[] finderArgs = new Object[] { vocabularyId };
4094
4095 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_VOCABULARYID,
4096 finderArgs, this);
4097
4098 if (count == null) {
4099 Session session = null;
4100
4101 try {
4102 session = openSession();
4103
4104 StringBundler query = new StringBundler(2);
4105
4106 query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
4107
4108 query.append(_FINDER_COLUMN_VOCABULARYID_VOCABULARYID_2);
4109
4110 String sql = query.toString();
4111
4112 Query q = session.createQuery(sql);
4113
4114 QueryPos qPos = QueryPos.getInstance(q);
4115
4116 qPos.add(vocabularyId);
4117
4118 count = (Long)q.uniqueResult();
4119 }
4120 catch (Exception e) {
4121 throw processException(e);
4122 }
4123 finally {
4124 if (count == null) {
4125 count = Long.valueOf(0);
4126 }
4127
4128 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_VOCABULARYID,
4129 finderArgs, count);
4130
4131 closeSession(session);
4132 }
4133 }
4134
4135 return count.intValue();
4136 }
4137
4138
4146 public int countByP_N(long parentCategoryId, String name)
4147 throws SystemException {
4148 Object[] finderArgs = new Object[] { parentCategoryId, name };
4149
4150 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_P_N,
4151 finderArgs, this);
4152
4153 if (count == null) {
4154 Session session = null;
4155
4156 try {
4157 session = openSession();
4158
4159 StringBundler query = new StringBundler(3);
4160
4161 query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
4162
4163 query.append(_FINDER_COLUMN_P_N_PARENTCATEGORYID_2);
4164
4165 if (name == null) {
4166 query.append(_FINDER_COLUMN_P_N_NAME_1);
4167 }
4168 else {
4169 if (name.equals(StringPool.BLANK)) {
4170 query.append(_FINDER_COLUMN_P_N_NAME_3);
4171 }
4172 else {
4173 query.append(_FINDER_COLUMN_P_N_NAME_2);
4174 }
4175 }
4176
4177 String sql = query.toString();
4178
4179 Query q = session.createQuery(sql);
4180
4181 QueryPos qPos = QueryPos.getInstance(q);
4182
4183 qPos.add(parentCategoryId);
4184
4185 if (name != null) {
4186 qPos.add(name);
4187 }
4188
4189 count = (Long)q.uniqueResult();
4190 }
4191 catch (Exception e) {
4192 throw processException(e);
4193 }
4194 finally {
4195 if (count == null) {
4196 count = Long.valueOf(0);
4197 }
4198
4199 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_P_N, finderArgs,
4200 count);
4201
4202 closeSession(session);
4203 }
4204 }
4205
4206 return count.intValue();
4207 }
4208
4209
4217 public int countByP_V(long parentCategoryId, long vocabularyId)
4218 throws SystemException {
4219 Object[] finderArgs = new Object[] { parentCategoryId, vocabularyId };
4220
4221 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_P_V,
4222 finderArgs, this);
4223
4224 if (count == null) {
4225 Session session = null;
4226
4227 try {
4228 session = openSession();
4229
4230 StringBundler query = new StringBundler(3);
4231
4232 query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
4233
4234 query.append(_FINDER_COLUMN_P_V_PARENTCATEGORYID_2);
4235
4236 query.append(_FINDER_COLUMN_P_V_VOCABULARYID_2);
4237
4238 String sql = query.toString();
4239
4240 Query q = session.createQuery(sql);
4241
4242 QueryPos qPos = QueryPos.getInstance(q);
4243
4244 qPos.add(parentCategoryId);
4245
4246 qPos.add(vocabularyId);
4247
4248 count = (Long)q.uniqueResult();
4249 }
4250 catch (Exception e) {
4251 throw processException(e);
4252 }
4253 finally {
4254 if (count == null) {
4255 count = Long.valueOf(0);
4256 }
4257
4258 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_P_V, finderArgs,
4259 count);
4260
4261 closeSession(session);
4262 }
4263 }
4264
4265 return count.intValue();
4266 }
4267
4268
4276 public int countByN_V(String name, long vocabularyId)
4277 throws SystemException {
4278 Object[] finderArgs = new Object[] { name, vocabularyId };
4279
4280 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_N_V,
4281 finderArgs, this);
4282
4283 if (count == null) {
4284 Session session = null;
4285
4286 try {
4287 session = openSession();
4288
4289 StringBundler query = new StringBundler(3);
4290
4291 query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
4292
4293 if (name == null) {
4294 query.append(_FINDER_COLUMN_N_V_NAME_1);
4295 }
4296 else {
4297 if (name.equals(StringPool.BLANK)) {
4298 query.append(_FINDER_COLUMN_N_V_NAME_3);
4299 }
4300 else {
4301 query.append(_FINDER_COLUMN_N_V_NAME_2);
4302 }
4303 }
4304
4305 query.append(_FINDER_COLUMN_N_V_VOCABULARYID_2);
4306
4307 String sql = query.toString();
4308
4309 Query q = session.createQuery(sql);
4310
4311 QueryPos qPos = QueryPos.getInstance(q);
4312
4313 if (name != null) {
4314 qPos.add(name);
4315 }
4316
4317 qPos.add(vocabularyId);
4318
4319 count = (Long)q.uniqueResult();
4320 }
4321 catch (Exception e) {
4322 throw processException(e);
4323 }
4324 finally {
4325 if (count == null) {
4326 count = Long.valueOf(0);
4327 }
4328
4329 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_N_V, finderArgs,
4330 count);
4331
4332 closeSession(session);
4333 }
4334 }
4335
4336 return count.intValue();
4337 }
4338
4339
4348 public int countByP_N_V(long parentCategoryId, String name,
4349 long vocabularyId) throws SystemException {
4350 Object[] finderArgs = new Object[] { parentCategoryId, name, vocabularyId };
4351
4352 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_P_N_V,
4353 finderArgs, this);
4354
4355 if (count == null) {
4356 Session session = null;
4357
4358 try {
4359 session = openSession();
4360
4361 StringBundler query = new StringBundler(4);
4362
4363 query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
4364
4365 query.append(_FINDER_COLUMN_P_N_V_PARENTCATEGORYID_2);
4366
4367 if (name == null) {
4368 query.append(_FINDER_COLUMN_P_N_V_NAME_1);
4369 }
4370 else {
4371 if (name.equals(StringPool.BLANK)) {
4372 query.append(_FINDER_COLUMN_P_N_V_NAME_3);
4373 }
4374 else {
4375 query.append(_FINDER_COLUMN_P_N_V_NAME_2);
4376 }
4377 }
4378
4379 query.append(_FINDER_COLUMN_P_N_V_VOCABULARYID_2);
4380
4381 String sql = query.toString();
4382
4383 Query q = session.createQuery(sql);
4384
4385 QueryPos qPos = QueryPos.getInstance(q);
4386
4387 qPos.add(parentCategoryId);
4388
4389 if (name != null) {
4390 qPos.add(name);
4391 }
4392
4393 qPos.add(vocabularyId);
4394
4395 count = (Long)q.uniqueResult();
4396 }
4397 catch (Exception e) {
4398 throw processException(e);
4399 }
4400 finally {
4401 if (count == null) {
4402 count = Long.valueOf(0);
4403 }
4404
4405 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_P_N_V,
4406 finderArgs, count);
4407
4408 closeSession(session);
4409 }
4410 }
4411
4412 return count.intValue();
4413 }
4414
4415
4421 public int countAll() throws SystemException {
4422 Object[] finderArgs = new Object[0];
4423
4424 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
4425 finderArgs, this);
4426
4427 if (count == null) {
4428 Session session = null;
4429
4430 try {
4431 session = openSession();
4432
4433 Query q = session.createQuery(_SQL_COUNT_ASSETCATEGORY);
4434
4435 count = (Long)q.uniqueResult();
4436 }
4437 catch (Exception e) {
4438 throw processException(e);
4439 }
4440 finally {
4441 if (count == null) {
4442 count = Long.valueOf(0);
4443 }
4444
4445 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL, finderArgs,
4446 count);
4447
4448 closeSession(session);
4449 }
4450 }
4451
4452 return count.intValue();
4453 }
4454
4455
4462 public List<com.liferay.portlet.asset.model.AssetEntry> getAssetEntries(
4463 long pk) throws SystemException {
4464 return getAssetEntries(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
4465 }
4466
4467
4480 public List<com.liferay.portlet.asset.model.AssetEntry> getAssetEntries(
4481 long pk, int start, int end) throws SystemException {
4482 return getAssetEntries(pk, start, end, null);
4483 }
4484
4485 public static final FinderPath FINDER_PATH_GET_ASSETENTRIES = new FinderPath(com.liferay.portlet.asset.model.impl.AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
4486 AssetCategoryModelImpl.FINDER_CACHE_ENABLED_ASSETENTRIES_ASSETCATEGORIES,
4487 AssetCategoryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME,
4488 "getAssetEntries",
4489 new String[] {
4490 Long.class.getName(), "java.lang.Integer", "java.lang.Integer",
4491 "com.liferay.portal.kernel.util.OrderByComparator"
4492 });
4493
4494
4508 public List<com.liferay.portlet.asset.model.AssetEntry> getAssetEntries(
4509 long pk, int start, int end, OrderByComparator orderByComparator)
4510 throws SystemException {
4511 Object[] finderArgs = new Object[] {
4512 pk, String.valueOf(start), String.valueOf(end),
4513 String.valueOf(orderByComparator)
4514 };
4515
4516 List<com.liferay.portlet.asset.model.AssetEntry> list = (List<com.liferay.portlet.asset.model.AssetEntry>)FinderCacheUtil.getResult(FINDER_PATH_GET_ASSETENTRIES,
4517 finderArgs, this);
4518
4519 if (list == null) {
4520 Session session = null;
4521
4522 try {
4523 session = openSession();
4524
4525 String sql = null;
4526
4527 if (orderByComparator != null) {
4528 sql = _SQL_GETASSETENTRIES.concat(ORDER_BY_CLAUSE)
4529 .concat(orderByComparator.getOrderBy());
4530 }
4531 else {
4532 sql = _SQL_GETASSETENTRIES;
4533 }
4534
4535 SQLQuery q = session.createSQLQuery(sql);
4536
4537 q.addEntity("AssetEntry",
4538 com.liferay.portlet.asset.model.impl.AssetEntryImpl.class);
4539
4540 QueryPos qPos = QueryPos.getInstance(q);
4541
4542 qPos.add(pk);
4543
4544 list = (List<com.liferay.portlet.asset.model.AssetEntry>)QueryUtil.list(q,
4545 getDialect(), start, end);
4546 }
4547 catch (Exception e) {
4548 throw processException(e);
4549 }
4550 finally {
4551 if (list == null) {
4552 list = new ArrayList<com.liferay.portlet.asset.model.AssetEntry>();
4553 }
4554
4555 assetEntryPersistence.cacheResult(list);
4556
4557 FinderCacheUtil.putResult(FINDER_PATH_GET_ASSETENTRIES,
4558 finderArgs, list);
4559
4560 closeSession(session);
4561 }
4562 }
4563
4564 return list;
4565 }
4566
4567 public static final FinderPath FINDER_PATH_GET_ASSETENTRIES_SIZE = new FinderPath(com.liferay.portlet.asset.model.impl.AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
4568 AssetCategoryModelImpl.FINDER_CACHE_ENABLED_ASSETENTRIES_ASSETCATEGORIES,
4569 AssetCategoryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME,
4570 "getAssetEntriesSize", new String[] { Long.class.getName() });
4571
4572
4579 public int getAssetEntriesSize(long pk) throws SystemException {
4580 Object[] finderArgs = new Object[] { pk };
4581
4582 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_GET_ASSETENTRIES_SIZE,
4583 finderArgs, this);
4584
4585 if (count == null) {
4586 Session session = null;
4587
4588 try {
4589 session = openSession();
4590
4591 SQLQuery q = session.createSQLQuery(_SQL_GETASSETENTRIESSIZE);
4592
4593 q.addScalar(COUNT_COLUMN_NAME,
4594 com.liferay.portal.kernel.dao.orm.Type.LONG);
4595
4596 QueryPos qPos = QueryPos.getInstance(q);
4597
4598 qPos.add(pk);
4599
4600 count = (Long)q.uniqueResult();
4601 }
4602 catch (Exception e) {
4603 throw processException(e);
4604 }
4605 finally {
4606 if (count == null) {
4607 count = Long.valueOf(0);
4608 }
4609
4610 FinderCacheUtil.putResult(FINDER_PATH_GET_ASSETENTRIES_SIZE,
4611 finderArgs, count);
4612
4613 closeSession(session);
4614 }
4615 }
4616
4617 return count.intValue();
4618 }
4619
4620 public static final FinderPath FINDER_PATH_CONTAINS_ASSETENTRY = new FinderPath(com.liferay.portlet.asset.model.impl.AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
4621 AssetCategoryModelImpl.FINDER_CACHE_ENABLED_ASSETENTRIES_ASSETCATEGORIES,
4622 AssetCategoryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME,
4623 "containsAssetEntry",
4624 new String[] { Long.class.getName(), Long.class.getName() });
4625
4626
4634 public boolean containsAssetEntry(long pk, long assetEntryPK)
4635 throws SystemException {
4636 Object[] finderArgs = new Object[] { pk, assetEntryPK };
4637
4638 Boolean value = (Boolean)FinderCacheUtil.getResult(FINDER_PATH_CONTAINS_ASSETENTRY,
4639 finderArgs, this);
4640
4641 if (value == null) {
4642 try {
4643 value = Boolean.valueOf(containsAssetEntry.contains(pk,
4644 assetEntryPK));
4645 }
4646 catch (Exception e) {
4647 throw processException(e);
4648 }
4649 finally {
4650 if (value == null) {
4651 value = Boolean.FALSE;
4652 }
4653
4654 FinderCacheUtil.putResult(FINDER_PATH_CONTAINS_ASSETENTRY,
4655 finderArgs, value);
4656 }
4657 }
4658
4659 return value.booleanValue();
4660 }
4661
4662
4669 public boolean containsAssetEntries(long pk) throws SystemException {
4670 if (getAssetEntriesSize(pk) > 0) {
4671 return true;
4672 }
4673 else {
4674 return false;
4675 }
4676 }
4677
4678
4685 public void addAssetEntry(long pk, long assetEntryPK)
4686 throws SystemException {
4687 try {
4688 addAssetEntry.add(pk, assetEntryPK);
4689 }
4690 catch (Exception e) {
4691 throw processException(e);
4692 }
4693 finally {
4694 FinderCacheUtil.clearCache(AssetCategoryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
4695 }
4696 }
4697
4698
4705 public void addAssetEntry(long pk,
4706 com.liferay.portlet.asset.model.AssetEntry assetEntry)
4707 throws SystemException {
4708 try {
4709 addAssetEntry.add(pk, assetEntry.getPrimaryKey());
4710 }
4711 catch (Exception e) {
4712 throw processException(e);
4713 }
4714 finally {
4715 FinderCacheUtil.clearCache(AssetCategoryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
4716 }
4717 }
4718
4719
4726 public void addAssetEntries(long pk, long[] assetEntryPKs)
4727 throws SystemException {
4728 try {
4729 for (long assetEntryPK : assetEntryPKs) {
4730 addAssetEntry.add(pk, assetEntryPK);
4731 }
4732 }
4733 catch (Exception e) {
4734 throw processException(e);
4735 }
4736 finally {
4737 FinderCacheUtil.clearCache(AssetCategoryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
4738 }
4739 }
4740
4741
4748 public void addAssetEntries(long pk,
4749 List<com.liferay.portlet.asset.model.AssetEntry> assetEntries)
4750 throws SystemException {
4751 try {
4752 for (com.liferay.portlet.asset.model.AssetEntry assetEntry : assetEntries) {
4753 addAssetEntry.add(pk, assetEntry.getPrimaryKey());
4754 }
4755 }
4756 catch (Exception e) {
4757 throw processException(e);
4758 }
4759 finally {
4760 FinderCacheUtil.clearCache(AssetCategoryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
4761 }
4762 }
4763
4764
4770 public void clearAssetEntries(long pk) throws SystemException {
4771 try {
4772 clearAssetEntries.clear(pk);
4773 }
4774 catch (Exception e) {
4775 throw processException(e);
4776 }
4777 finally {
4778 FinderCacheUtil.clearCache(AssetCategoryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
4779 }
4780 }
4781
4782
4789 public void removeAssetEntry(long pk, long assetEntryPK)
4790 throws SystemException {
4791 try {
4792 removeAssetEntry.remove(pk, assetEntryPK);
4793 }
4794 catch (Exception e) {
4795 throw processException(e);
4796 }
4797 finally {
4798 FinderCacheUtil.clearCache(AssetCategoryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
4799 }
4800 }
4801
4802
4809 public void removeAssetEntry(long pk,
4810 com.liferay.portlet.asset.model.AssetEntry assetEntry)
4811 throws SystemException {
4812 try {
4813 removeAssetEntry.remove(pk, assetEntry.getPrimaryKey());
4814 }
4815 catch (Exception e) {
4816 throw processException(e);
4817 }
4818 finally {
4819 FinderCacheUtil.clearCache(AssetCategoryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
4820 }
4821 }
4822
4823
4830 public void removeAssetEntries(long pk, long[] assetEntryPKs)
4831 throws SystemException {
4832 try {
4833 for (long assetEntryPK : assetEntryPKs) {
4834 removeAssetEntry.remove(pk, assetEntryPK);
4835 }
4836 }
4837 catch (Exception e) {
4838 throw processException(e);
4839 }
4840 finally {
4841 FinderCacheUtil.clearCache(AssetCategoryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
4842 }
4843 }
4844
4845
4852 public void removeAssetEntries(long pk,
4853 List<com.liferay.portlet.asset.model.AssetEntry> assetEntries)
4854 throws SystemException {
4855 try {
4856 for (com.liferay.portlet.asset.model.AssetEntry assetEntry : assetEntries) {
4857 removeAssetEntry.remove(pk, assetEntry.getPrimaryKey());
4858 }
4859 }
4860 catch (Exception e) {
4861 throw processException(e);
4862 }
4863 finally {
4864 FinderCacheUtil.clearCache(AssetCategoryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
4865 }
4866 }
4867
4868
4875 public void setAssetEntries(long pk, long[] assetEntryPKs)
4876 throws SystemException {
4877 try {
4878 Set<Long> assetEntryPKSet = SetUtil.fromArray(assetEntryPKs);
4879
4880 List<com.liferay.portlet.asset.model.AssetEntry> assetEntries = getAssetEntries(pk);
4881
4882 for (com.liferay.portlet.asset.model.AssetEntry assetEntry : assetEntries) {
4883 if (!assetEntryPKSet.remove(assetEntry.getPrimaryKey())) {
4884 removeAssetEntry.remove(pk, assetEntry.getPrimaryKey());
4885 }
4886 }
4887
4888 for (Long assetEntryPK : assetEntryPKSet) {
4889 addAssetEntry.add(pk, assetEntryPK);
4890 }
4891 }
4892 catch (Exception e) {
4893 throw processException(e);
4894 }
4895 finally {
4896 FinderCacheUtil.clearCache(AssetCategoryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
4897 }
4898 }
4899
4900
4907 public void setAssetEntries(long pk,
4908 List<com.liferay.portlet.asset.model.AssetEntry> assetEntries)
4909 throws SystemException {
4910 try {
4911 long[] assetEntryPKs = new long[assetEntries.size()];
4912
4913 for (int i = 0; i < assetEntries.size(); i++) {
4914 com.liferay.portlet.asset.model.AssetEntry assetEntry = assetEntries.get(i);
4915
4916 assetEntryPKs[i] = assetEntry.getPrimaryKey();
4917 }
4918
4919 setAssetEntries(pk, assetEntryPKs);
4920 }
4921 catch (Exception e) {
4922 throw processException(e);
4923 }
4924 finally {
4925 FinderCacheUtil.clearCache(AssetCategoryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
4926 }
4927 }
4928
4929
4939 public void rebuildTree(long groupId, boolean force)
4940 throws SystemException {
4941 if (force || (countOrphanTreeNodes(groupId) > 0)) {
4942 rebuildTree(groupId, 0, 1);
4943
4944 CacheRegistryUtil.clear(AssetCategoryImpl.class.getName());
4945 EntityCacheUtil.clearCache(AssetCategoryImpl.class.getName());
4946 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
4947 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
4948 }
4949 }
4950
4951 protected long countOrphanTreeNodes(long groupId) throws SystemException {
4952 Session session = null;
4953
4954 try {
4955 session = openSession();
4956
4957 SQLQuery q = session.createSQLQuery(
4958 "SELECT COUNT(*) AS COUNT_VALUE FROM AssetCategory WHERE groupId = ? AND (leftCategoryId = 0 OR leftCategoryId IS NULL OR rightCategoryId = 0 OR rightCategoryId IS NULL)");
4959
4960 q.addScalar(COUNT_COLUMN_NAME,
4961 com.liferay.portal.kernel.dao.orm.Type.LONG);
4962
4963 QueryPos qPos = QueryPos.getInstance(q);
4964
4965 qPos.add(groupId);
4966
4967 return (Long)q.uniqueResult();
4968 }
4969 catch (Exception e) {
4970 throw processException(e);
4971 }
4972 finally {
4973 closeSession(session);
4974 }
4975 }
4976
4977 protected void expandTree(AssetCategory assetCategory)
4978 throws SystemException {
4979 long groupId = assetCategory.getGroupId();
4980
4981 long lastRightCategoryId = getLastRightCategoryId(groupId,
4982 assetCategory.getParentCategoryId());
4983
4984 long leftCategoryId = 2;
4985 long rightCategoryId = 3;
4986
4987 if (lastRightCategoryId > 0) {
4988 leftCategoryId = lastRightCategoryId + 1;
4989 rightCategoryId = lastRightCategoryId + 2;
4990
4991 expandTreeLeftCategoryId.expand(groupId, lastRightCategoryId);
4992 expandTreeRightCategoryId.expand(groupId, lastRightCategoryId);
4993
4994 CacheRegistryUtil.clear(AssetCategoryImpl.class.getName());
4995 EntityCacheUtil.clearCache(AssetCategoryImpl.class.getName());
4996 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
4997 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
4998 }
4999
5000 assetCategory.setLeftCategoryId(leftCategoryId);
5001 assetCategory.setRightCategoryId(rightCategoryId);
5002 }
5003
5004 protected long getLastRightCategoryId(long groupId, long parentCategoryId)
5005 throws SystemException {
5006 Session session = null;
5007
5008 try {
5009 session = openSession();
5010
5011 SQLQuery q = session.createSQLQuery(
5012 "SELECT rightCategoryId FROM AssetCategory WHERE (groupId = ?) AND (parentCategoryId = ?) ORDER BY rightCategoryId DESC");
5013
5014 q.addScalar("rightCategoryId",
5015 com.liferay.portal.kernel.dao.orm.Type.LONG);
5016
5017 QueryPos qPos = QueryPos.getInstance(q);
5018
5019 qPos.add(groupId);
5020 qPos.add(parentCategoryId);
5021
5022 List<Long> list = (List<Long>)QueryUtil.list(q, getDialect(), 0, 1);
5023
5024 if (list.isEmpty()) {
5025 if (parentCategoryId > 0) {
5026 AssetCategory parentAssetCategory = findByPrimaryKey(parentCategoryId);
5027
5028 return parentAssetCategory.getLeftCategoryId();
5029 }
5030
5031 return 0;
5032 }
5033 else {
5034 return list.get(0);
5035 }
5036 }
5037 catch (Exception e) {
5038 throw processException(e);
5039 }
5040 finally {
5041 closeSession(session);
5042 }
5043 }
5044
5045 protected long rebuildTree(long groupId, long parentCategoryId,
5046 long leftCategoryId) throws SystemException {
5047 List<Long> categoryIds = null;
5048
5049 Session session = null;
5050
5051 try {
5052 session = openSession();
5053
5054 SQLQuery q = session.createSQLQuery(
5055 "SELECT categoryId FROM AssetCategory WHERE groupId = ? AND parentCategoryId = ? ORDER BY categoryId ASC");
5056
5057 q.addScalar("categoryId",
5058 com.liferay.portal.kernel.dao.orm.Type.LONG);
5059
5060 QueryPos qPos = QueryPos.getInstance(q);
5061
5062 qPos.add(groupId);
5063 qPos.add(parentCategoryId);
5064
5065 categoryIds = q.list();
5066 }
5067 catch (Exception e) {
5068 throw processException(e);
5069 }
5070 finally {
5071 closeSession(session);
5072 }
5073
5074 long rightCategoryId = leftCategoryId + 1;
5075
5076 for (long categoryId : categoryIds) {
5077 rightCategoryId = rebuildTree(groupId, categoryId, rightCategoryId);
5078 }
5079
5080 if (parentCategoryId > 0) {
5081 updateTree.update(parentCategoryId, leftCategoryId, rightCategoryId);
5082 }
5083
5084 return rightCategoryId + 1;
5085 }
5086
5087 protected void shrinkTree(AssetCategory assetCategory) {
5088 long groupId = assetCategory.getGroupId();
5089
5090 long leftCategoryId = assetCategory.getLeftCategoryId();
5091 long rightCategoryId = assetCategory.getRightCategoryId();
5092
5093 long delta = (rightCategoryId - leftCategoryId) + 1;
5094
5095 shrinkTreeLeftCategoryId.shrink(groupId, rightCategoryId, delta);
5096 shrinkTreeRightCategoryId.shrink(groupId, rightCategoryId, delta);
5097
5098 CacheRegistryUtil.clear(AssetCategoryImpl.class.getName());
5099 EntityCacheUtil.clearCache(AssetCategoryImpl.class.getName());
5100 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
5101 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
5102 }
5103
5104
5107 public void afterPropertiesSet() {
5108 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
5109 com.liferay.portal.util.PropsUtil.get(
5110 "value.object.listener.com.liferay.portlet.asset.model.AssetCategory")));
5111
5112 if (listenerClassNames.length > 0) {
5113 try {
5114 List<ModelListener<AssetCategory>> listenersList = new ArrayList<ModelListener<AssetCategory>>();
5115
5116 for (String listenerClassName : listenerClassNames) {
5117 listenersList.add((ModelListener<AssetCategory>)InstanceFactory.newInstance(
5118 listenerClassName));
5119 }
5120
5121 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
5122 }
5123 catch (Exception e) {
5124 _log.error(e);
5125 }
5126 }
5127
5128 containsAssetEntry = new ContainsAssetEntry(this);
5129
5130 addAssetEntry = new AddAssetEntry(this);
5131 clearAssetEntries = new ClearAssetEntries(this);
5132 removeAssetEntry = new RemoveAssetEntry(this);
5133
5134 expandTreeLeftCategoryId = new ExpandTreeLeftCategoryId();
5135 expandTreeRightCategoryId = new ExpandTreeRightCategoryId();
5136 shrinkTreeLeftCategoryId = new ShrinkTreeLeftCategoryId();
5137 shrinkTreeRightCategoryId = new ShrinkTreeRightCategoryId();
5138 updateTree = new UpdateTree();
5139 }
5140
5141 public void destroy() {
5142 EntityCacheUtil.removeCache(AssetCategoryImpl.class.getName());
5143 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
5144 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST);
5145 }
5146
5147 @BeanReference(type = AssetCategoryPersistence.class)
5148 protected AssetCategoryPersistence assetCategoryPersistence;
5149 @BeanReference(type = AssetCategoryPropertyPersistence.class)
5150 protected AssetCategoryPropertyPersistence assetCategoryPropertyPersistence;
5151 @BeanReference(type = AssetEntryPersistence.class)
5152 protected AssetEntryPersistence assetEntryPersistence;
5153 @BeanReference(type = AssetLinkPersistence.class)
5154 protected AssetLinkPersistence assetLinkPersistence;
5155 @BeanReference(type = AssetTagPersistence.class)
5156 protected AssetTagPersistence assetTagPersistence;
5157 @BeanReference(type = AssetTagPropertyPersistence.class)
5158 protected AssetTagPropertyPersistence assetTagPropertyPersistence;
5159 @BeanReference(type = AssetTagStatsPersistence.class)
5160 protected AssetTagStatsPersistence assetTagStatsPersistence;
5161 @BeanReference(type = AssetVocabularyPersistence.class)
5162 protected AssetVocabularyPersistence assetVocabularyPersistence;
5163 @BeanReference(type = ResourcePersistence.class)
5164 protected ResourcePersistence resourcePersistence;
5165 @BeanReference(type = UserPersistence.class)
5166 protected UserPersistence userPersistence;
5167 protected ContainsAssetEntry containsAssetEntry;
5168 protected AddAssetEntry addAssetEntry;
5169 protected ClearAssetEntries clearAssetEntries;
5170 protected RemoveAssetEntry removeAssetEntry;
5171
5172 protected class ContainsAssetEntry {
5173 protected ContainsAssetEntry(
5174 AssetCategoryPersistenceImpl persistenceImpl) {
5175 super();
5176
5177 _mappingSqlQuery = MappingSqlQueryFactoryUtil.getMappingSqlQuery(getDataSource(),
5178 _SQL_CONTAINSASSETENTRY,
5179 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT },
5180 RowMapper.COUNT);
5181 }
5182
5183 protected boolean contains(long categoryId, long entryId) {
5184 List<Integer> results = _mappingSqlQuery.execute(new Object[] {
5185 new Long(categoryId), new Long(entryId)
5186 });
5187
5188 if (results.size() > 0) {
5189 Integer count = results.get(0);
5190
5191 if (count.intValue() > 0) {
5192 return true;
5193 }
5194 }
5195
5196 return false;
5197 }
5198
5199 private MappingSqlQuery<Integer> _mappingSqlQuery;
5200 }
5201
5202 protected class AddAssetEntry {
5203 protected AddAssetEntry(AssetCategoryPersistenceImpl persistenceImpl) {
5204 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
5205 "INSERT INTO AssetEntries_AssetCategories (categoryId, entryId) VALUES (?, ?)",
5206 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
5207 _persistenceImpl = persistenceImpl;
5208 }
5209
5210 protected void add(long categoryId, long entryId)
5211 throws SystemException {
5212 if (!_persistenceImpl.containsAssetEntry.contains(categoryId,
5213 entryId)) {
5214 ModelListener<com.liferay.portlet.asset.model.AssetEntry>[] assetEntryListeners =
5215 assetEntryPersistence.getListeners();
5216
5217 for (ModelListener<AssetCategory> listener : listeners) {
5218 listener.onBeforeAddAssociation(categoryId,
5219 com.liferay.portlet.asset.model.AssetEntry.class.getName(),
5220 entryId);
5221 }
5222
5223 for (ModelListener<com.liferay.portlet.asset.model.AssetEntry> listener : assetEntryListeners) {
5224 listener.onBeforeAddAssociation(entryId,
5225 AssetCategory.class.getName(), categoryId);
5226 }
5227
5228 _sqlUpdate.update(new Object[] {
5229 new Long(categoryId), new Long(entryId)
5230 });
5231
5232 for (ModelListener<AssetCategory> listener : listeners) {
5233 listener.onAfterAddAssociation(categoryId,
5234 com.liferay.portlet.asset.model.AssetEntry.class.getName(),
5235 entryId);
5236 }
5237
5238 for (ModelListener<com.liferay.portlet.asset.model.AssetEntry> listener : assetEntryListeners) {
5239 listener.onAfterAddAssociation(entryId,
5240 AssetCategory.class.getName(), categoryId);
5241 }
5242 }
5243 }
5244
5245 private SqlUpdate _sqlUpdate;
5246 private AssetCategoryPersistenceImpl _persistenceImpl;
5247 }
5248
5249 protected class ClearAssetEntries {
5250 protected ClearAssetEntries(
5251 AssetCategoryPersistenceImpl persistenceImpl) {
5252 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
5253 "DELETE FROM AssetEntries_AssetCategories WHERE categoryId = ?",
5254 new int[] { java.sql.Types.BIGINT });
5255 }
5256
5257 protected void clear(long categoryId) throws SystemException {
5258 ModelListener<com.liferay.portlet.asset.model.AssetEntry>[] assetEntryListeners =
5259 assetEntryPersistence.getListeners();
5260
5261 List<com.liferay.portlet.asset.model.AssetEntry> assetEntries = null;
5262
5263 if ((listeners.length > 0) || (assetEntryListeners.length > 0)) {
5264 assetEntries = getAssetEntries(categoryId);
5265
5266 for (com.liferay.portlet.asset.model.AssetEntry assetEntry : assetEntries) {
5267 for (ModelListener<AssetCategory> listener : listeners) {
5268 listener.onBeforeRemoveAssociation(categoryId,
5269 com.liferay.portlet.asset.model.AssetEntry.class.getName(),
5270 assetEntry.getPrimaryKey());
5271 }
5272
5273 for (ModelListener<com.liferay.portlet.asset.model.AssetEntry> listener : assetEntryListeners) {
5274 listener.onBeforeRemoveAssociation(assetEntry.getPrimaryKey(),
5275 AssetCategory.class.getName(), categoryId);
5276 }
5277 }
5278 }
5279
5280 _sqlUpdate.update(new Object[] { new Long(categoryId) });
5281
5282 if ((listeners.length > 0) || (assetEntryListeners.length > 0)) {
5283 for (com.liferay.portlet.asset.model.AssetEntry assetEntry : assetEntries) {
5284 for (ModelListener<AssetCategory> listener : listeners) {
5285 listener.onAfterRemoveAssociation(categoryId,
5286 com.liferay.portlet.asset.model.AssetEntry.class.getName(),
5287 assetEntry.getPrimaryKey());
5288 }
5289
5290 for (ModelListener<com.liferay.portlet.asset.model.AssetEntry> listener : assetEntryListeners) {
5291 listener.onAfterRemoveAssociation(assetEntry.getPrimaryKey(),
5292 AssetCategory.class.getName(), categoryId);
5293 }
5294 }
5295 }
5296 }
5297
5298 private SqlUpdate _sqlUpdate;
5299 }
5300
5301 protected class RemoveAssetEntry {
5302 protected RemoveAssetEntry(AssetCategoryPersistenceImpl persistenceImpl) {
5303 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
5304 "DELETE FROM AssetEntries_AssetCategories WHERE categoryId = ? AND entryId = ?",
5305 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
5306 _persistenceImpl = persistenceImpl;
5307 }
5308
5309 protected void remove(long categoryId, long entryId)
5310 throws SystemException {
5311 if (_persistenceImpl.containsAssetEntry.contains(categoryId, entryId)) {
5312 ModelListener<com.liferay.portlet.asset.model.AssetEntry>[] assetEntryListeners =
5313 assetEntryPersistence.getListeners();
5314
5315 for (ModelListener<AssetCategory> listener : listeners) {
5316 listener.onBeforeRemoveAssociation(categoryId,
5317 com.liferay.portlet.asset.model.AssetEntry.class.getName(),
5318 entryId);
5319 }
5320
5321 for (ModelListener<com.liferay.portlet.asset.model.AssetEntry> listener : assetEntryListeners) {
5322 listener.onBeforeRemoveAssociation(entryId,
5323 AssetCategory.class.getName(), categoryId);
5324 }
5325
5326 _sqlUpdate.update(new Object[] {
5327 new Long(categoryId), new Long(entryId)
5328 });
5329
5330 for (ModelListener<AssetCategory> listener : listeners) {
5331 listener.onAfterRemoveAssociation(categoryId,
5332 com.liferay.portlet.asset.model.AssetEntry.class.getName(),
5333 entryId);
5334 }
5335
5336 for (ModelListener<com.liferay.portlet.asset.model.AssetEntry> listener : assetEntryListeners) {
5337 listener.onAfterRemoveAssociation(entryId,
5338 AssetCategory.class.getName(), categoryId);
5339 }
5340 }
5341 }
5342
5343 private SqlUpdate _sqlUpdate;
5344 private AssetCategoryPersistenceImpl _persistenceImpl;
5345 }
5346
5347 protected ExpandTreeLeftCategoryId expandTreeLeftCategoryId;
5348 protected ExpandTreeRightCategoryId expandTreeRightCategoryId;
5349 protected ShrinkTreeLeftCategoryId shrinkTreeLeftCategoryId;
5350 protected ShrinkTreeRightCategoryId shrinkTreeRightCategoryId;
5351 protected UpdateTree updateTree;
5352
5353 protected class ExpandTreeLeftCategoryId {
5354 protected ExpandTreeLeftCategoryId() {
5355 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
5356 "UPDATE AssetCategory SET leftCategoryId = (leftCategoryId + 2) WHERE (groupId = ?) AND (leftCategoryId > ?)",
5357 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
5358 }
5359
5360 protected void expand(long groupId, long leftCategoryId) {
5361 _sqlUpdate.update(new Object[] { groupId, leftCategoryId });
5362 }
5363
5364 private SqlUpdate _sqlUpdate;
5365 }
5366
5367 protected class ExpandTreeRightCategoryId {
5368 protected ExpandTreeRightCategoryId() {
5369 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
5370 "UPDATE AssetCategory SET rightCategoryId = (rightCategoryId + 2) WHERE (groupId = ?) AND (rightCategoryId > ?)",
5371 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
5372 }
5373
5374 protected void expand(long groupId, long rightCategoryId) {
5375 _sqlUpdate.update(new Object[] { groupId, rightCategoryId });
5376 }
5377
5378 private SqlUpdate _sqlUpdate;
5379 }
5380
5381 protected class ShrinkTreeLeftCategoryId {
5382 protected ShrinkTreeLeftCategoryId() {
5383 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
5384 "UPDATE AssetCategory SET leftCategoryId = (leftCategoryId - ?) WHERE (groupId = ?) AND (leftCategoryId > ?)",
5385 new int[] {
5386 java.sql.Types.BIGINT, java.sql.Types.BIGINT,
5387 java.sql.Types.BIGINT
5388 });
5389 }
5390
5391 protected void shrink(long groupId, long leftCategoryId, long delta) {
5392 _sqlUpdate.update(new Object[] { delta, groupId, leftCategoryId });
5393 }
5394
5395 private SqlUpdate _sqlUpdate;
5396 }
5397
5398 protected class ShrinkTreeRightCategoryId {
5399 protected ShrinkTreeRightCategoryId() {
5400 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
5401 "UPDATE AssetCategory SET rightCategoryId = (rightCategoryId - ?) WHERE (groupId = ?) AND (rightCategoryId > ?)",
5402 new int[] {
5403 java.sql.Types.BIGINT, java.sql.Types.BIGINT,
5404 java.sql.Types.BIGINT
5405 });
5406 }
5407
5408 protected void shrink(long groupId, long rightCategoryId, long delta) {
5409 _sqlUpdate.update(new Object[] { delta, groupId, rightCategoryId });
5410 }
5411
5412 private SqlUpdate _sqlUpdate;
5413 }
5414
5415 protected class UpdateTree {
5416 protected UpdateTree() {
5417 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
5418 "UPDATE AssetCategory SET leftCategoryId = ?, rightCategoryId = ? WHERE categoryId = ?",
5419 new int[] {
5420 java.sql.Types.BIGINT, java.sql.Types.BIGINT,
5421 java.sql.Types.BIGINT
5422 });
5423 }
5424
5425 protected void update(long categoryId, long leftCategoryId,
5426 long rightCategoryId) {
5427 _sqlUpdate.update(new Object[] {
5428 leftCategoryId, rightCategoryId, categoryId
5429 });
5430 }
5431
5432 private SqlUpdate _sqlUpdate;
5433 }
5434
5435 private static final String _SQL_SELECT_ASSETCATEGORY = "SELECT assetCategory FROM AssetCategory assetCategory";
5436 private static final String _SQL_SELECT_ASSETCATEGORY_WHERE = "SELECT assetCategory FROM AssetCategory assetCategory WHERE ";
5437 private static final String _SQL_COUNT_ASSETCATEGORY = "SELECT COUNT(assetCategory) FROM AssetCategory assetCategory";
5438 private static final String _SQL_COUNT_ASSETCATEGORY_WHERE = "SELECT COUNT(assetCategory) FROM AssetCategory assetCategory WHERE ";
5439 private static final String _SQL_GETASSETENTRIES = "SELECT {AssetEntry.*} FROM AssetEntry INNER JOIN AssetEntries_AssetCategories ON (AssetEntries_AssetCategories.entryId = AssetEntry.entryId) WHERE (AssetEntries_AssetCategories.categoryId = ?)";
5440 private static final String _SQL_GETASSETENTRIESSIZE = "SELECT COUNT(*) AS COUNT_VALUE FROM AssetEntries_AssetCategories WHERE categoryId = ?";
5441 private static final String _SQL_CONTAINSASSETENTRY = "SELECT COUNT(*) AS COUNT_VALUE FROM AssetEntries_AssetCategories WHERE categoryId = ? AND entryId = ?";
5442 private static final String _FINDER_COLUMN_UUID_UUID_1 = "assetCategory.uuid IS NULL";
5443 private static final String _FINDER_COLUMN_UUID_UUID_2 = "assetCategory.uuid = ?";
5444 private static final String _FINDER_COLUMN_UUID_UUID_3 = "(assetCategory.uuid IS NULL OR assetCategory.uuid = ?)";
5445 private static final String _FINDER_COLUMN_UUID_G_UUID_1 = "assetCategory.uuid IS NULL AND ";
5446 private static final String _FINDER_COLUMN_UUID_G_UUID_2 = "assetCategory.uuid = ? AND ";
5447 private static final String _FINDER_COLUMN_UUID_G_UUID_3 = "(assetCategory.uuid IS NULL OR assetCategory.uuid = ?) AND ";
5448 private static final String _FINDER_COLUMN_UUID_G_GROUPID_2 = "assetCategory.groupId = ?";
5449 private static final String _FINDER_COLUMN_GROUPID_GROUPID_2 = "assetCategory.groupId = ?";
5450 private static final String _FINDER_COLUMN_PARENTCATEGORYID_PARENTCATEGORYID_2 =
5451 "assetCategory.parentCategoryId = ?";
5452 private static final String _FINDER_COLUMN_VOCABULARYID_VOCABULARYID_2 = "assetCategory.vocabularyId = ?";
5453 private static final String _FINDER_COLUMN_P_N_PARENTCATEGORYID_2 = "assetCategory.parentCategoryId = ? AND ";
5454 private static final String _FINDER_COLUMN_P_N_NAME_1 = "assetCategory.name IS NULL";
5455 private static final String _FINDER_COLUMN_P_N_NAME_2 = "assetCategory.name = ?";
5456 private static final String _FINDER_COLUMN_P_N_NAME_3 = "(assetCategory.name IS NULL OR assetCategory.name = ?)";
5457 private static final String _FINDER_COLUMN_P_V_PARENTCATEGORYID_2 = "assetCategory.parentCategoryId = ? AND ";
5458 private static final String _FINDER_COLUMN_P_V_VOCABULARYID_2 = "assetCategory.vocabularyId = ?";
5459 private static final String _FINDER_COLUMN_N_V_NAME_1 = "assetCategory.name IS NULL AND ";
5460 private static final String _FINDER_COLUMN_N_V_NAME_2 = "assetCategory.name = ? AND ";
5461 private static final String _FINDER_COLUMN_N_V_NAME_3 = "(assetCategory.name IS NULL OR assetCategory.name = ?) AND ";
5462 private static final String _FINDER_COLUMN_N_V_VOCABULARYID_2 = "assetCategory.vocabularyId = ?";
5463 private static final String _FINDER_COLUMN_P_N_V_PARENTCATEGORYID_2 = "assetCategory.parentCategoryId = ? AND ";
5464 private static final String _FINDER_COLUMN_P_N_V_NAME_1 = "assetCategory.name IS NULL AND ";
5465 private static final String _FINDER_COLUMN_P_N_V_NAME_2 = "assetCategory.name = ? AND ";
5466 private static final String _FINDER_COLUMN_P_N_V_NAME_3 = "(assetCategory.name IS NULL OR assetCategory.name = ?) AND ";
5467 private static final String _FINDER_COLUMN_P_N_V_VOCABULARYID_2 = "assetCategory.vocabularyId = ?";
5468 private static final String _FILTER_SQL_SELECT_ASSETCATEGORY_WHERE = "SELECT DISTINCT {assetCategory.*} FROM AssetCategory assetCategory WHERE ";
5469 private static final String _FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE =
5470 "SELECT {assetCategory.*} FROM (SELECT DISTINCT categoryId FROM AssetCategory) assetCategory2 INNER JOIN AssetCategory assetCategory ON (assetCategory2.categoryId = assetCategory.categoryId) WHERE ";
5471 private static final String _FILTER_SQL_COUNT_ASSETCATEGORY_WHERE = "SELECT COUNT(DISTINCT assetCategory.categoryId) AS COUNT_VALUE FROM AssetCategory assetCategory WHERE ";
5472 private static final String _FILTER_COLUMN_PK = "assetCategory.categoryId";
5473 private static final String _FILTER_COLUMN_USERID = "assetCategory.userId";
5474 private static final String _FILTER_ENTITY_ALIAS = "assetCategory";
5475 private static final String _ORDER_BY_ENTITY_ALIAS = "assetCategory.";
5476 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No AssetCategory exists with the primary key ";
5477 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No AssetCategory exists with the key {";
5478 private static Log _log = LogFactoryUtil.getLog(AssetCategoryPersistenceImpl.class);
5479 }