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
070 public class AssetCategoryPersistenceImpl extends BasePersistenceImpl<AssetCategory>
071 implements AssetCategoryPersistence {
072 public static final String FINDER_CLASS_NAME_ENTITY = AssetCategoryImpl.class.getName();
073 public static final String FINDER_CLASS_NAME_LIST = FINDER_CLASS_NAME_ENTITY +
074 ".List";
075 public static final FinderPath FINDER_PATH_FIND_BY_UUID = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
076 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
077 FINDER_CLASS_NAME_LIST, "findByUuid",
078 new String[] {
079 String.class.getName(),
080
081 "java.lang.Integer", "java.lang.Integer",
082 "com.liferay.portal.kernel.util.OrderByComparator"
083 });
084 public static final FinderPath FINDER_PATH_COUNT_BY_UUID = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
085 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
086 FINDER_CLASS_NAME_LIST, "countByUuid",
087 new String[] { String.class.getName() });
088 public static final FinderPath FINDER_PATH_FETCH_BY_UUID_G = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
089 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
090 FINDER_CLASS_NAME_ENTITY, "fetchByUUID_G",
091 new String[] { String.class.getName(), Long.class.getName() });
092 public static final FinderPath FINDER_PATH_COUNT_BY_UUID_G = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
093 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
094 FINDER_CLASS_NAME_LIST, "countByUUID_G",
095 new String[] { String.class.getName(), Long.class.getName() });
096 public static final FinderPath FINDER_PATH_FIND_BY_GROUPID = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
097 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
098 FINDER_CLASS_NAME_LIST, "findByGroupId",
099 new String[] {
100 Long.class.getName(),
101
102 "java.lang.Integer", "java.lang.Integer",
103 "com.liferay.portal.kernel.util.OrderByComparator"
104 });
105 public static final FinderPath FINDER_PATH_COUNT_BY_GROUPID = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
106 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
107 FINDER_CLASS_NAME_LIST, "countByGroupId",
108 new String[] { Long.class.getName() });
109 public static final FinderPath FINDER_PATH_FIND_BY_PARENTCATEGORYID = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
110 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
111 FINDER_CLASS_NAME_LIST, "findByParentCategoryId",
112 new String[] {
113 Long.class.getName(),
114
115 "java.lang.Integer", "java.lang.Integer",
116 "com.liferay.portal.kernel.util.OrderByComparator"
117 });
118 public static final FinderPath FINDER_PATH_COUNT_BY_PARENTCATEGORYID = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
119 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
120 FINDER_CLASS_NAME_LIST, "countByParentCategoryId",
121 new String[] { Long.class.getName() });
122 public static final FinderPath FINDER_PATH_FIND_BY_VOCABULARYID = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
123 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
124 FINDER_CLASS_NAME_LIST, "findByVocabularyId",
125 new String[] {
126 Long.class.getName(),
127
128 "java.lang.Integer", "java.lang.Integer",
129 "com.liferay.portal.kernel.util.OrderByComparator"
130 });
131 public static final FinderPath FINDER_PATH_COUNT_BY_VOCABULARYID = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
132 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
133 FINDER_CLASS_NAME_LIST, "countByVocabularyId",
134 new String[] { Long.class.getName() });
135 public static final FinderPath FINDER_PATH_FIND_BY_P_N = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
136 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
137 FINDER_CLASS_NAME_LIST, "findByP_N",
138 new String[] {
139 Long.class.getName(), String.class.getName(),
140
141 "java.lang.Integer", "java.lang.Integer",
142 "com.liferay.portal.kernel.util.OrderByComparator"
143 });
144 public static final FinderPath FINDER_PATH_COUNT_BY_P_N = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
145 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
146 FINDER_CLASS_NAME_LIST, "countByP_N",
147 new String[] { Long.class.getName(), String.class.getName() });
148 public static final FinderPath FINDER_PATH_FIND_BY_P_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
149 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
150 FINDER_CLASS_NAME_LIST, "findByP_V",
151 new String[] {
152 Long.class.getName(), Long.class.getName(),
153
154 "java.lang.Integer", "java.lang.Integer",
155 "com.liferay.portal.kernel.util.OrderByComparator"
156 });
157 public static final FinderPath FINDER_PATH_COUNT_BY_P_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
158 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
159 FINDER_CLASS_NAME_LIST, "countByP_V",
160 new String[] { Long.class.getName(), Long.class.getName() });
161 public static final FinderPath FINDER_PATH_FIND_BY_N_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
162 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
163 FINDER_CLASS_NAME_LIST, "findByN_V",
164 new String[] {
165 String.class.getName(), Long.class.getName(),
166
167 "java.lang.Integer", "java.lang.Integer",
168 "com.liferay.portal.kernel.util.OrderByComparator"
169 });
170 public static final FinderPath FINDER_PATH_COUNT_BY_N_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
171 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
172 FINDER_CLASS_NAME_LIST, "countByN_V",
173 new String[] { String.class.getName(), Long.class.getName() });
174 public static final FinderPath FINDER_PATH_FETCH_BY_P_N_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
175 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
176 FINDER_CLASS_NAME_ENTITY, "fetchByP_N_V",
177 new String[] {
178 Long.class.getName(), String.class.getName(),
179 Long.class.getName()
180 });
181 public static final FinderPath FINDER_PATH_COUNT_BY_P_N_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
182 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
183 FINDER_CLASS_NAME_LIST, "countByP_N_V",
184 new String[] {
185 Long.class.getName(), String.class.getName(),
186 Long.class.getName()
187 });
188 public static final FinderPath FINDER_PATH_FIND_ALL = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
189 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
190 FINDER_CLASS_NAME_LIST, "findAll", new String[0]);
191 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
192 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
193 FINDER_CLASS_NAME_LIST, "countAll", new String[0]);
194
195 public void cacheResult(AssetCategory assetCategory) {
196 EntityCacheUtil.putResult(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
197 AssetCategoryImpl.class, assetCategory.getPrimaryKey(),
198 assetCategory);
199
200 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
201 new Object[] {
202 assetCategory.getUuid(), new Long(assetCategory.getGroupId())
203 }, assetCategory);
204
205 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_P_N_V,
206 new Object[] {
207 new Long(assetCategory.getParentCategoryId()),
208
209 assetCategory.getName(), new Long(assetCategory.getVocabularyId())
210 }, assetCategory);
211 }
212
213 public void cacheResult(List<AssetCategory> assetCategories) {
214 for (AssetCategory assetCategory : assetCategories) {
215 if (EntityCacheUtil.getResult(
216 AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
217 AssetCategoryImpl.class, assetCategory.getPrimaryKey(),
218 this) == null) {
219 cacheResult(assetCategory);
220 }
221 }
222 }
223
224 public void clearCache() {
225 CacheRegistryUtil.clear(AssetCategoryImpl.class.getName());
226 EntityCacheUtil.clearCache(AssetCategoryImpl.class.getName());
227 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
228 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
229 }
230
231 public void clearCache(AssetCategory assetCategory) {
232 EntityCacheUtil.removeResult(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
233 AssetCategoryImpl.class, assetCategory.getPrimaryKey());
234
235 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
236 new Object[] {
237 assetCategory.getUuid(), new Long(assetCategory.getGroupId())
238 });
239
240 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_P_N_V,
241 new Object[] {
242 new Long(assetCategory.getParentCategoryId()),
243
244 assetCategory.getName(), new Long(assetCategory.getVocabularyId())
245 });
246 }
247
248 public AssetCategory create(long categoryId) {
249 AssetCategory assetCategory = new AssetCategoryImpl();
250
251 assetCategory.setNew(true);
252 assetCategory.setPrimaryKey(categoryId);
253
254 String uuid = PortalUUIDUtil.generate();
255
256 assetCategory.setUuid(uuid);
257
258 return assetCategory;
259 }
260
261 public AssetCategory remove(Serializable primaryKey)
262 throws NoSuchModelException, SystemException {
263 return remove(((Long)primaryKey).longValue());
264 }
265
266 public AssetCategory remove(long categoryId)
267 throws NoSuchCategoryException, SystemException {
268 Session session = null;
269
270 try {
271 session = openSession();
272
273 AssetCategory assetCategory = (AssetCategory)session.get(AssetCategoryImpl.class,
274 new Long(categoryId));
275
276 if (assetCategory == null) {
277 if (_log.isWarnEnabled()) {
278 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + categoryId);
279 }
280
281 throw new NoSuchCategoryException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
282 categoryId);
283 }
284
285 return remove(assetCategory);
286 }
287 catch (NoSuchCategoryException nsee) {
288 throw nsee;
289 }
290 catch (Exception e) {
291 throw processException(e);
292 }
293 finally {
294 closeSession(session);
295 }
296 }
297
298 protected AssetCategory removeImpl(AssetCategory assetCategory)
299 throws SystemException {
300 assetCategory = toUnwrappedModel(assetCategory);
301
302 try {
303 clearAssetEntries.clear(assetCategory.getPrimaryKey());
304 }
305 catch (Exception e) {
306 throw processException(e);
307 }
308 finally {
309 FinderCacheUtil.clearCache(AssetCategoryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
310 }
311
312 shrinkTree(assetCategory);
313
314 Session session = null;
315
316 try {
317 session = openSession();
318
319 if (assetCategory.isCachedModel() || BatchSessionUtil.isEnabled()) {
320 Object staleObject = session.get(AssetCategoryImpl.class,
321 assetCategory.getPrimaryKeyObj());
322
323 if (staleObject != null) {
324 session.evict(staleObject);
325 }
326 }
327
328 session.delete(assetCategory);
329
330 session.flush();
331 }
332 catch (Exception e) {
333 throw processException(e);
334 }
335 finally {
336 closeSession(session);
337 }
338
339 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
340
341 AssetCategoryModelImpl assetCategoryModelImpl = (AssetCategoryModelImpl)assetCategory;
342
343 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
344 new Object[] {
345 assetCategoryModelImpl.getOriginalUuid(),
346 new Long(assetCategoryModelImpl.getOriginalGroupId())
347 });
348
349 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_P_N_V,
350 new Object[] {
351 new Long(assetCategoryModelImpl.getOriginalParentCategoryId()),
352
353 assetCategoryModelImpl.getOriginalName(),
354 new Long(assetCategoryModelImpl.getOriginalVocabularyId())
355 });
356
357 EntityCacheUtil.removeResult(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
358 AssetCategoryImpl.class, assetCategory.getPrimaryKey());
359
360 return assetCategory;
361 }
362
363 public AssetCategory updateImpl(
364 com.liferay.portlet.asset.model.AssetCategory assetCategory,
365 boolean merge) throws SystemException {
366 assetCategory = toUnwrappedModel(assetCategory);
367
368 boolean isNew = assetCategory.isNew();
369
370 AssetCategoryModelImpl assetCategoryModelImpl = (AssetCategoryModelImpl)assetCategory;
371
372 if (Validator.isNull(assetCategory.getUuid())) {
373 String uuid = PortalUUIDUtil.generate();
374
375 assetCategory.setUuid(uuid);
376 }
377
378 if (isNew) {
379 expandTree(assetCategory);
380 }
381 else {
382 if (assetCategory.getParentCategoryId() != assetCategoryModelImpl.getOriginalParentCategoryId()) {
383 shrinkTree(assetCategory);
384 expandTree(assetCategory);
385 }
386 }
387
388 Session session = null;
389
390 try {
391 session = openSession();
392
393 BatchSessionUtil.update(session, assetCategory, merge);
394
395 assetCategory.setNew(false);
396 }
397 catch (Exception e) {
398 throw processException(e);
399 }
400 finally {
401 closeSession(session);
402 }
403
404 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
405
406 EntityCacheUtil.putResult(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
407 AssetCategoryImpl.class, assetCategory.getPrimaryKey(),
408 assetCategory);
409
410 if (!isNew &&
411 (!Validator.equals(assetCategory.getUuid(),
412 assetCategoryModelImpl.getOriginalUuid()) ||
413 (assetCategory.getGroupId() != assetCategoryModelImpl.getOriginalGroupId()))) {
414 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
415 new Object[] {
416 assetCategoryModelImpl.getOriginalUuid(),
417 new Long(assetCategoryModelImpl.getOriginalGroupId())
418 });
419 }
420
421 if (isNew ||
422 (!Validator.equals(assetCategory.getUuid(),
423 assetCategoryModelImpl.getOriginalUuid()) ||
424 (assetCategory.getGroupId() != assetCategoryModelImpl.getOriginalGroupId()))) {
425 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
426 new Object[] {
427 assetCategory.getUuid(),
428 new Long(assetCategory.getGroupId())
429 }, assetCategory);
430 }
431
432 if (!isNew &&
433 ((assetCategory.getParentCategoryId() != assetCategoryModelImpl.getOriginalParentCategoryId()) ||
434 !Validator.equals(assetCategory.getName(),
435 assetCategoryModelImpl.getOriginalName()) ||
436 (assetCategory.getVocabularyId() != assetCategoryModelImpl.getOriginalVocabularyId()))) {
437 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_P_N_V,
438 new Object[] {
439 new Long(assetCategoryModelImpl.getOriginalParentCategoryId()),
440
441 assetCategoryModelImpl.getOriginalName(),
442 new Long(assetCategoryModelImpl.getOriginalVocabularyId())
443 });
444 }
445
446 if (isNew ||
447 ((assetCategory.getParentCategoryId() != assetCategoryModelImpl.getOriginalParentCategoryId()) ||
448 !Validator.equals(assetCategory.getName(),
449 assetCategoryModelImpl.getOriginalName()) ||
450 (assetCategory.getVocabularyId() != assetCategoryModelImpl.getOriginalVocabularyId()))) {
451 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_P_N_V,
452 new Object[] {
453 new Long(assetCategory.getParentCategoryId()),
454
455 assetCategory.getName(),
456 new Long(assetCategory.getVocabularyId())
457 }, assetCategory);
458 }
459
460 return assetCategory;
461 }
462
463 protected AssetCategory toUnwrappedModel(AssetCategory assetCategory) {
464 if (assetCategory instanceof AssetCategoryImpl) {
465 return assetCategory;
466 }
467
468 AssetCategoryImpl assetCategoryImpl = new AssetCategoryImpl();
469
470 assetCategoryImpl.setNew(assetCategory.isNew());
471 assetCategoryImpl.setPrimaryKey(assetCategory.getPrimaryKey());
472
473 assetCategoryImpl.setUuid(assetCategory.getUuid());
474 assetCategoryImpl.setCategoryId(assetCategory.getCategoryId());
475 assetCategoryImpl.setGroupId(assetCategory.getGroupId());
476 assetCategoryImpl.setCompanyId(assetCategory.getCompanyId());
477 assetCategoryImpl.setUserId(assetCategory.getUserId());
478 assetCategoryImpl.setUserName(assetCategory.getUserName());
479 assetCategoryImpl.setCreateDate(assetCategory.getCreateDate());
480 assetCategoryImpl.setModifiedDate(assetCategory.getModifiedDate());
481 assetCategoryImpl.setParentCategoryId(assetCategory.getParentCategoryId());
482 assetCategoryImpl.setLeftCategoryId(assetCategory.getLeftCategoryId());
483 assetCategoryImpl.setRightCategoryId(assetCategory.getRightCategoryId());
484 assetCategoryImpl.setName(assetCategory.getName());
485 assetCategoryImpl.setTitle(assetCategory.getTitle());
486 assetCategoryImpl.setVocabularyId(assetCategory.getVocabularyId());
487
488 return assetCategoryImpl;
489 }
490
491 public AssetCategory findByPrimaryKey(Serializable primaryKey)
492 throws NoSuchModelException, SystemException {
493 return findByPrimaryKey(((Long)primaryKey).longValue());
494 }
495
496 public AssetCategory findByPrimaryKey(long categoryId)
497 throws NoSuchCategoryException, SystemException {
498 AssetCategory assetCategory = fetchByPrimaryKey(categoryId);
499
500 if (assetCategory == null) {
501 if (_log.isWarnEnabled()) {
502 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + categoryId);
503 }
504
505 throw new NoSuchCategoryException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
506 categoryId);
507 }
508
509 return assetCategory;
510 }
511
512 public AssetCategory fetchByPrimaryKey(Serializable primaryKey)
513 throws SystemException {
514 return fetchByPrimaryKey(((Long)primaryKey).longValue());
515 }
516
517 public AssetCategory fetchByPrimaryKey(long categoryId)
518 throws SystemException {
519 AssetCategory assetCategory = (AssetCategory)EntityCacheUtil.getResult(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
520 AssetCategoryImpl.class, categoryId, this);
521
522 if (assetCategory == null) {
523 Session session = null;
524
525 try {
526 session = openSession();
527
528 assetCategory = (AssetCategory)session.get(AssetCategoryImpl.class,
529 new Long(categoryId));
530 }
531 catch (Exception e) {
532 throw processException(e);
533 }
534 finally {
535 if (assetCategory != null) {
536 cacheResult(assetCategory);
537 }
538
539 closeSession(session);
540 }
541 }
542
543 return assetCategory;
544 }
545
546 public List<AssetCategory> findByUuid(String uuid)
547 throws SystemException {
548 return findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
549 }
550
551 public List<AssetCategory> findByUuid(String uuid, int start, int end)
552 throws SystemException {
553 return findByUuid(uuid, start, end, null);
554 }
555
556 public List<AssetCategory> findByUuid(String uuid, int start, int end,
557 OrderByComparator orderByComparator) throws SystemException {
558 Object[] finderArgs = new Object[] {
559 uuid,
560
561 String.valueOf(start), String.valueOf(end),
562 String.valueOf(orderByComparator)
563 };
564
565 List<AssetCategory> list = (List<AssetCategory>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_UUID,
566 finderArgs, this);
567
568 if (list == null) {
569 Session session = null;
570
571 try {
572 session = openSession();
573
574 StringBundler query = null;
575
576 if (orderByComparator != null) {
577 query = new StringBundler(3 +
578 (orderByComparator.getOrderByFields().length * 3));
579 }
580 else {
581 query = new StringBundler(3);
582 }
583
584 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
585
586 if (uuid == null) {
587 query.append(_FINDER_COLUMN_UUID_UUID_1);
588 }
589 else {
590 if (uuid.equals(StringPool.BLANK)) {
591 query.append(_FINDER_COLUMN_UUID_UUID_3);
592 }
593 else {
594 query.append(_FINDER_COLUMN_UUID_UUID_2);
595 }
596 }
597
598 if (orderByComparator != null) {
599 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
600 orderByComparator);
601 }
602
603 else {
604 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
605 }
606
607 String sql = query.toString();
608
609 Query q = session.createQuery(sql);
610
611 QueryPos qPos = QueryPos.getInstance(q);
612
613 if (uuid != null) {
614 qPos.add(uuid);
615 }
616
617 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
618 start, end);
619 }
620 catch (Exception e) {
621 throw processException(e);
622 }
623 finally {
624 if (list == null) {
625 list = new ArrayList<AssetCategory>();
626 }
627
628 cacheResult(list);
629
630 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_UUID, finderArgs,
631 list);
632
633 closeSession(session);
634 }
635 }
636
637 return list;
638 }
639
640 public AssetCategory findByUuid_First(String uuid,
641 OrderByComparator orderByComparator)
642 throws NoSuchCategoryException, SystemException {
643 List<AssetCategory> list = findByUuid(uuid, 0, 1, orderByComparator);
644
645 if (list.isEmpty()) {
646 StringBundler msg = new StringBundler(4);
647
648 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
649
650 msg.append("uuid=");
651 msg.append(uuid);
652
653 msg.append(StringPool.CLOSE_CURLY_BRACE);
654
655 throw new NoSuchCategoryException(msg.toString());
656 }
657 else {
658 return list.get(0);
659 }
660 }
661
662 public AssetCategory findByUuid_Last(String uuid,
663 OrderByComparator orderByComparator)
664 throws NoSuchCategoryException, SystemException {
665 int count = countByUuid(uuid);
666
667 List<AssetCategory> list = findByUuid(uuid, count - 1, count,
668 orderByComparator);
669
670 if (list.isEmpty()) {
671 StringBundler msg = new StringBundler(4);
672
673 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
674
675 msg.append("uuid=");
676 msg.append(uuid);
677
678 msg.append(StringPool.CLOSE_CURLY_BRACE);
679
680 throw new NoSuchCategoryException(msg.toString());
681 }
682 else {
683 return list.get(0);
684 }
685 }
686
687 public AssetCategory[] findByUuid_PrevAndNext(long categoryId, String uuid,
688 OrderByComparator orderByComparator)
689 throws NoSuchCategoryException, SystemException {
690 AssetCategory assetCategory = findByPrimaryKey(categoryId);
691
692 Session session = null;
693
694 try {
695 session = openSession();
696
697 AssetCategory[] array = new AssetCategoryImpl[3];
698
699 array[0] = getByUuid_PrevAndNext(session, assetCategory, uuid,
700 orderByComparator, true);
701
702 array[1] = assetCategory;
703
704 array[2] = getByUuid_PrevAndNext(session, assetCategory, uuid,
705 orderByComparator, false);
706
707 return array;
708 }
709 catch (Exception e) {
710 throw processException(e);
711 }
712 finally {
713 closeSession(session);
714 }
715 }
716
717 protected AssetCategory getByUuid_PrevAndNext(Session session,
718 AssetCategory assetCategory, String uuid,
719 OrderByComparator orderByComparator, boolean previous) {
720 StringBundler query = null;
721
722 if (orderByComparator != null) {
723 query = new StringBundler(6 +
724 (orderByComparator.getOrderByFields().length * 6));
725 }
726 else {
727 query = new StringBundler(3);
728 }
729
730 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
731
732 if (uuid == null) {
733 query.append(_FINDER_COLUMN_UUID_UUID_1);
734 }
735 else {
736 if (uuid.equals(StringPool.BLANK)) {
737 query.append(_FINDER_COLUMN_UUID_UUID_3);
738 }
739 else {
740 query.append(_FINDER_COLUMN_UUID_UUID_2);
741 }
742 }
743
744 if (orderByComparator != null) {
745 String[] orderByFields = orderByComparator.getOrderByFields();
746
747 if (orderByFields.length > 0) {
748 query.append(WHERE_AND);
749 }
750
751 for (int i = 0; i < orderByFields.length; i++) {
752 query.append(_ORDER_BY_ENTITY_ALIAS);
753 query.append(orderByFields[i]);
754
755 if ((i + 1) < orderByFields.length) {
756 if (orderByComparator.isAscending() ^ previous) {
757 query.append(WHERE_GREATER_THAN_HAS_NEXT);
758 }
759 else {
760 query.append(WHERE_LESSER_THAN_HAS_NEXT);
761 }
762 }
763 else {
764 if (orderByComparator.isAscending() ^ previous) {
765 query.append(WHERE_GREATER_THAN);
766 }
767 else {
768 query.append(WHERE_LESSER_THAN);
769 }
770 }
771 }
772
773 query.append(ORDER_BY_CLAUSE);
774
775 for (int i = 0; i < orderByFields.length; i++) {
776 query.append(_ORDER_BY_ENTITY_ALIAS);
777 query.append(orderByFields[i]);
778
779 if ((i + 1) < orderByFields.length) {
780 if (orderByComparator.isAscending() ^ previous) {
781 query.append(ORDER_BY_ASC_HAS_NEXT);
782 }
783 else {
784 query.append(ORDER_BY_DESC_HAS_NEXT);
785 }
786 }
787 else {
788 if (orderByComparator.isAscending() ^ previous) {
789 query.append(ORDER_BY_ASC);
790 }
791 else {
792 query.append(ORDER_BY_DESC);
793 }
794 }
795 }
796 }
797
798 else {
799 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
800 }
801
802 String sql = query.toString();
803
804 Query q = session.createQuery(sql);
805
806 q.setFirstResult(0);
807 q.setMaxResults(2);
808
809 QueryPos qPos = QueryPos.getInstance(q);
810
811 if (uuid != null) {
812 qPos.add(uuid);
813 }
814
815 if (orderByComparator != null) {
816 Object[] values = orderByComparator.getOrderByValues(assetCategory);
817
818 for (Object value : values) {
819 qPos.add(value);
820 }
821 }
822
823 List<AssetCategory> list = q.list();
824
825 if (list.size() == 2) {
826 return list.get(1);
827 }
828 else {
829 return null;
830 }
831 }
832
833 public AssetCategory findByUUID_G(String uuid, long groupId)
834 throws NoSuchCategoryException, SystemException {
835 AssetCategory assetCategory = fetchByUUID_G(uuid, groupId);
836
837 if (assetCategory == null) {
838 StringBundler msg = new StringBundler(6);
839
840 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
841
842 msg.append("uuid=");
843 msg.append(uuid);
844
845 msg.append(", groupId=");
846 msg.append(groupId);
847
848 msg.append(StringPool.CLOSE_CURLY_BRACE);
849
850 if (_log.isWarnEnabled()) {
851 _log.warn(msg.toString());
852 }
853
854 throw new NoSuchCategoryException(msg.toString());
855 }
856
857 return assetCategory;
858 }
859
860 public AssetCategory fetchByUUID_G(String uuid, long groupId)
861 throws SystemException {
862 return fetchByUUID_G(uuid, groupId, true);
863 }
864
865 public AssetCategory fetchByUUID_G(String uuid, long groupId,
866 boolean retrieveFromCache) throws SystemException {
867 Object[] finderArgs = new Object[] { uuid, groupId };
868
869 Object result = null;
870
871 if (retrieveFromCache) {
872 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_UUID_G,
873 finderArgs, this);
874 }
875
876 if (result == null) {
877 Session session = null;
878
879 try {
880 session = openSession();
881
882 StringBundler query = new StringBundler(4);
883
884 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
885
886 if (uuid == null) {
887 query.append(_FINDER_COLUMN_UUID_G_UUID_1);
888 }
889 else {
890 if (uuid.equals(StringPool.BLANK)) {
891 query.append(_FINDER_COLUMN_UUID_G_UUID_3);
892 }
893 else {
894 query.append(_FINDER_COLUMN_UUID_G_UUID_2);
895 }
896 }
897
898 query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
899
900 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
901
902 String sql = query.toString();
903
904 Query q = session.createQuery(sql);
905
906 QueryPos qPos = QueryPos.getInstance(q);
907
908 if (uuid != null) {
909 qPos.add(uuid);
910 }
911
912 qPos.add(groupId);
913
914 List<AssetCategory> list = q.list();
915
916 result = list;
917
918 AssetCategory assetCategory = null;
919
920 if (list.isEmpty()) {
921 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
922 finderArgs, list);
923 }
924 else {
925 assetCategory = list.get(0);
926
927 cacheResult(assetCategory);
928
929 if ((assetCategory.getUuid() == null) ||
930 !assetCategory.getUuid().equals(uuid) ||
931 (assetCategory.getGroupId() != groupId)) {
932 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
933 finderArgs, assetCategory);
934 }
935 }
936
937 return assetCategory;
938 }
939 catch (Exception e) {
940 throw processException(e);
941 }
942 finally {
943 if (result == null) {
944 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
945 finderArgs, new ArrayList<AssetCategory>());
946 }
947
948 closeSession(session);
949 }
950 }
951 else {
952 if (result instanceof List<?>) {
953 return null;
954 }
955 else {
956 return (AssetCategory)result;
957 }
958 }
959 }
960
961 public List<AssetCategory> findByGroupId(long groupId)
962 throws SystemException {
963 return findByGroupId(groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
964 }
965
966 public List<AssetCategory> findByGroupId(long groupId, int start, int end)
967 throws SystemException {
968 return findByGroupId(groupId, start, end, null);
969 }
970
971 public List<AssetCategory> findByGroupId(long groupId, int start, int end,
972 OrderByComparator orderByComparator) throws SystemException {
973 Object[] finderArgs = new Object[] {
974 groupId,
975
976 String.valueOf(start), String.valueOf(end),
977 String.valueOf(orderByComparator)
978 };
979
980 List<AssetCategory> list = (List<AssetCategory>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_GROUPID,
981 finderArgs, this);
982
983 if (list == null) {
984 Session session = null;
985
986 try {
987 session = openSession();
988
989 StringBundler query = null;
990
991 if (orderByComparator != null) {
992 query = new StringBundler(3 +
993 (orderByComparator.getOrderByFields().length * 3));
994 }
995 else {
996 query = new StringBundler(3);
997 }
998
999 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
1000
1001 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1002
1003 if (orderByComparator != null) {
1004 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1005 orderByComparator);
1006 }
1007
1008 else {
1009 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
1010 }
1011
1012 String sql = query.toString();
1013
1014 Query q = session.createQuery(sql);
1015
1016 QueryPos qPos = QueryPos.getInstance(q);
1017
1018 qPos.add(groupId);
1019
1020 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
1021 start, end);
1022 }
1023 catch (Exception e) {
1024 throw processException(e);
1025 }
1026 finally {
1027 if (list == null) {
1028 list = new ArrayList<AssetCategory>();
1029 }
1030
1031 cacheResult(list);
1032
1033 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_GROUPID,
1034 finderArgs, list);
1035
1036 closeSession(session);
1037 }
1038 }
1039
1040 return list;
1041 }
1042
1043 public AssetCategory findByGroupId_First(long groupId,
1044 OrderByComparator orderByComparator)
1045 throws NoSuchCategoryException, SystemException {
1046 List<AssetCategory> list = findByGroupId(groupId, 0, 1,
1047 orderByComparator);
1048
1049 if (list.isEmpty()) {
1050 StringBundler msg = new StringBundler(4);
1051
1052 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1053
1054 msg.append("groupId=");
1055 msg.append(groupId);
1056
1057 msg.append(StringPool.CLOSE_CURLY_BRACE);
1058
1059 throw new NoSuchCategoryException(msg.toString());
1060 }
1061 else {
1062 return list.get(0);
1063 }
1064 }
1065
1066 public AssetCategory findByGroupId_Last(long groupId,
1067 OrderByComparator orderByComparator)
1068 throws NoSuchCategoryException, SystemException {
1069 int count = countByGroupId(groupId);
1070
1071 List<AssetCategory> list = findByGroupId(groupId, count - 1, count,
1072 orderByComparator);
1073
1074 if (list.isEmpty()) {
1075 StringBundler msg = new StringBundler(4);
1076
1077 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1078
1079 msg.append("groupId=");
1080 msg.append(groupId);
1081
1082 msg.append(StringPool.CLOSE_CURLY_BRACE);
1083
1084 throw new NoSuchCategoryException(msg.toString());
1085 }
1086 else {
1087 return list.get(0);
1088 }
1089 }
1090
1091 public AssetCategory[] findByGroupId_PrevAndNext(long categoryId,
1092 long groupId, OrderByComparator orderByComparator)
1093 throws NoSuchCategoryException, SystemException {
1094 AssetCategory assetCategory = findByPrimaryKey(categoryId);
1095
1096 Session session = null;
1097
1098 try {
1099 session = openSession();
1100
1101 AssetCategory[] array = new AssetCategoryImpl[3];
1102
1103 array[0] = getByGroupId_PrevAndNext(session, assetCategory,
1104 groupId, orderByComparator, true);
1105
1106 array[1] = assetCategory;
1107
1108 array[2] = getByGroupId_PrevAndNext(session, assetCategory,
1109 groupId, orderByComparator, false);
1110
1111 return array;
1112 }
1113 catch (Exception e) {
1114 throw processException(e);
1115 }
1116 finally {
1117 closeSession(session);
1118 }
1119 }
1120
1121 protected AssetCategory getByGroupId_PrevAndNext(Session session,
1122 AssetCategory assetCategory, long groupId,
1123 OrderByComparator orderByComparator, boolean previous) {
1124 StringBundler query = null;
1125
1126 if (orderByComparator != null) {
1127 query = new StringBundler(6 +
1128 (orderByComparator.getOrderByFields().length * 6));
1129 }
1130 else {
1131 query = new StringBundler(3);
1132 }
1133
1134 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
1135
1136 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1137
1138 if (orderByComparator != null) {
1139 String[] orderByFields = orderByComparator.getOrderByFields();
1140
1141 if (orderByFields.length > 0) {
1142 query.append(WHERE_AND);
1143 }
1144
1145 for (int i = 0; i < orderByFields.length; i++) {
1146 query.append(_ORDER_BY_ENTITY_ALIAS);
1147 query.append(orderByFields[i]);
1148
1149 if ((i + 1) < orderByFields.length) {
1150 if (orderByComparator.isAscending() ^ previous) {
1151 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1152 }
1153 else {
1154 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1155 }
1156 }
1157 else {
1158 if (orderByComparator.isAscending() ^ previous) {
1159 query.append(WHERE_GREATER_THAN);
1160 }
1161 else {
1162 query.append(WHERE_LESSER_THAN);
1163 }
1164 }
1165 }
1166
1167 query.append(ORDER_BY_CLAUSE);
1168
1169 for (int i = 0; i < orderByFields.length; i++) {
1170 query.append(_ORDER_BY_ENTITY_ALIAS);
1171 query.append(orderByFields[i]);
1172
1173 if ((i + 1) < orderByFields.length) {
1174 if (orderByComparator.isAscending() ^ previous) {
1175 query.append(ORDER_BY_ASC_HAS_NEXT);
1176 }
1177 else {
1178 query.append(ORDER_BY_DESC_HAS_NEXT);
1179 }
1180 }
1181 else {
1182 if (orderByComparator.isAscending() ^ previous) {
1183 query.append(ORDER_BY_ASC);
1184 }
1185 else {
1186 query.append(ORDER_BY_DESC);
1187 }
1188 }
1189 }
1190 }
1191
1192 else {
1193 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
1194 }
1195
1196 String sql = query.toString();
1197
1198 Query q = session.createQuery(sql);
1199
1200 q.setFirstResult(0);
1201 q.setMaxResults(2);
1202
1203 QueryPos qPos = QueryPos.getInstance(q);
1204
1205 qPos.add(groupId);
1206
1207 if (orderByComparator != null) {
1208 Object[] values = orderByComparator.getOrderByValues(assetCategory);
1209
1210 for (Object value : values) {
1211 qPos.add(value);
1212 }
1213 }
1214
1215 List<AssetCategory> list = q.list();
1216
1217 if (list.size() == 2) {
1218 return list.get(1);
1219 }
1220 else {
1221 return null;
1222 }
1223 }
1224
1225 public List<AssetCategory> filterFindByGroupId(long groupId)
1226 throws SystemException {
1227 return filterFindByGroupId(groupId, QueryUtil.ALL_POS,
1228 QueryUtil.ALL_POS, null);
1229 }
1230
1231 public List<AssetCategory> filterFindByGroupId(long groupId, int start,
1232 int end) throws SystemException {
1233 return filterFindByGroupId(groupId, start, end, null);
1234 }
1235
1236 public List<AssetCategory> filterFindByGroupId(long groupId, int start,
1237 int end, OrderByComparator orderByComparator) throws SystemException {
1238 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
1239 return findByGroupId(groupId, start, end, orderByComparator);
1240 }
1241
1242 Session session = null;
1243
1244 try {
1245 session = openSession();
1246
1247 StringBundler query = null;
1248
1249 if (orderByComparator != null) {
1250 query = new StringBundler(3 +
1251 (orderByComparator.getOrderByFields().length * 3));
1252 }
1253 else {
1254 query = new StringBundler(3);
1255 }
1256
1257 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_WHERE);
1258
1259 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1260
1261 if (orderByComparator != null) {
1262 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1263 orderByComparator);
1264 }
1265
1266 else {
1267 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
1268 }
1269
1270 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1271 AssetCategory.class.getName(), _FILTER_COLUMN_PK,
1272 _FILTER_COLUMN_USERID, groupId);
1273
1274 SQLQuery q = session.createSQLQuery(sql);
1275
1276 q.addEntity(_FILTER_ENTITY_ALIAS, AssetCategoryImpl.class);
1277
1278 QueryPos qPos = QueryPos.getInstance(q);
1279
1280 qPos.add(groupId);
1281
1282 return (List<AssetCategory>)QueryUtil.list(q, getDialect(), start,
1283 end);
1284 }
1285 catch (Exception e) {
1286 throw processException(e);
1287 }
1288 finally {
1289 closeSession(session);
1290 }
1291 }
1292
1293 public List<AssetCategory> findByParentCategoryId(long parentCategoryId)
1294 throws SystemException {
1295 return findByParentCategoryId(parentCategoryId, QueryUtil.ALL_POS,
1296 QueryUtil.ALL_POS, null);
1297 }
1298
1299 public List<AssetCategory> findByParentCategoryId(long parentCategoryId,
1300 int start, int end) throws SystemException {
1301 return findByParentCategoryId(parentCategoryId, start, end, null);
1302 }
1303
1304 public List<AssetCategory> findByParentCategoryId(long parentCategoryId,
1305 int start, int end, OrderByComparator orderByComparator)
1306 throws SystemException {
1307 Object[] finderArgs = new Object[] {
1308 parentCategoryId,
1309
1310 String.valueOf(start), String.valueOf(end),
1311 String.valueOf(orderByComparator)
1312 };
1313
1314 List<AssetCategory> list = (List<AssetCategory>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_PARENTCATEGORYID,
1315 finderArgs, this);
1316
1317 if (list == null) {
1318 Session session = null;
1319
1320 try {
1321 session = openSession();
1322
1323 StringBundler query = null;
1324
1325 if (orderByComparator != null) {
1326 query = new StringBundler(3 +
1327 (orderByComparator.getOrderByFields().length * 3));
1328 }
1329 else {
1330 query = new StringBundler(3);
1331 }
1332
1333 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
1334
1335 query.append(_FINDER_COLUMN_PARENTCATEGORYID_PARENTCATEGORYID_2);
1336
1337 if (orderByComparator != null) {
1338 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1339 orderByComparator);
1340 }
1341
1342 else {
1343 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
1344 }
1345
1346 String sql = query.toString();
1347
1348 Query q = session.createQuery(sql);
1349
1350 QueryPos qPos = QueryPos.getInstance(q);
1351
1352 qPos.add(parentCategoryId);
1353
1354 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
1355 start, end);
1356 }
1357 catch (Exception e) {
1358 throw processException(e);
1359 }
1360 finally {
1361 if (list == null) {
1362 list = new ArrayList<AssetCategory>();
1363 }
1364
1365 cacheResult(list);
1366
1367 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_PARENTCATEGORYID,
1368 finderArgs, list);
1369
1370 closeSession(session);
1371 }
1372 }
1373
1374 return list;
1375 }
1376
1377 public AssetCategory findByParentCategoryId_First(long parentCategoryId,
1378 OrderByComparator orderByComparator)
1379 throws NoSuchCategoryException, SystemException {
1380 List<AssetCategory> list = findByParentCategoryId(parentCategoryId, 0,
1381 1, orderByComparator);
1382
1383 if (list.isEmpty()) {
1384 StringBundler msg = new StringBundler(4);
1385
1386 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1387
1388 msg.append("parentCategoryId=");
1389 msg.append(parentCategoryId);
1390
1391 msg.append(StringPool.CLOSE_CURLY_BRACE);
1392
1393 throw new NoSuchCategoryException(msg.toString());
1394 }
1395 else {
1396 return list.get(0);
1397 }
1398 }
1399
1400 public AssetCategory findByParentCategoryId_Last(long parentCategoryId,
1401 OrderByComparator orderByComparator)
1402 throws NoSuchCategoryException, SystemException {
1403 int count = countByParentCategoryId(parentCategoryId);
1404
1405 List<AssetCategory> list = findByParentCategoryId(parentCategoryId,
1406 count - 1, count, orderByComparator);
1407
1408 if (list.isEmpty()) {
1409 StringBundler msg = new StringBundler(4);
1410
1411 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1412
1413 msg.append("parentCategoryId=");
1414 msg.append(parentCategoryId);
1415
1416 msg.append(StringPool.CLOSE_CURLY_BRACE);
1417
1418 throw new NoSuchCategoryException(msg.toString());
1419 }
1420 else {
1421 return list.get(0);
1422 }
1423 }
1424
1425 public AssetCategory[] findByParentCategoryId_PrevAndNext(long categoryId,
1426 long parentCategoryId, OrderByComparator orderByComparator)
1427 throws NoSuchCategoryException, SystemException {
1428 AssetCategory assetCategory = findByPrimaryKey(categoryId);
1429
1430 Session session = null;
1431
1432 try {
1433 session = openSession();
1434
1435 AssetCategory[] array = new AssetCategoryImpl[3];
1436
1437 array[0] = getByParentCategoryId_PrevAndNext(session,
1438 assetCategory, parentCategoryId, orderByComparator, true);
1439
1440 array[1] = assetCategory;
1441
1442 array[2] = getByParentCategoryId_PrevAndNext(session,
1443 assetCategory, parentCategoryId, orderByComparator, false);
1444
1445 return array;
1446 }
1447 catch (Exception e) {
1448 throw processException(e);
1449 }
1450 finally {
1451 closeSession(session);
1452 }
1453 }
1454
1455 protected AssetCategory getByParentCategoryId_PrevAndNext(Session session,
1456 AssetCategory assetCategory, long parentCategoryId,
1457 OrderByComparator orderByComparator, boolean previous) {
1458 StringBundler query = null;
1459
1460 if (orderByComparator != null) {
1461 query = new StringBundler(6 +
1462 (orderByComparator.getOrderByFields().length * 6));
1463 }
1464 else {
1465 query = new StringBundler(3);
1466 }
1467
1468 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
1469
1470 query.append(_FINDER_COLUMN_PARENTCATEGORYID_PARENTCATEGORYID_2);
1471
1472 if (orderByComparator != null) {
1473 String[] orderByFields = orderByComparator.getOrderByFields();
1474
1475 if (orderByFields.length > 0) {
1476 query.append(WHERE_AND);
1477 }
1478
1479 for (int i = 0; i < orderByFields.length; i++) {
1480 query.append(_ORDER_BY_ENTITY_ALIAS);
1481 query.append(orderByFields[i]);
1482
1483 if ((i + 1) < orderByFields.length) {
1484 if (orderByComparator.isAscending() ^ previous) {
1485 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1486 }
1487 else {
1488 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1489 }
1490 }
1491 else {
1492 if (orderByComparator.isAscending() ^ previous) {
1493 query.append(WHERE_GREATER_THAN);
1494 }
1495 else {
1496 query.append(WHERE_LESSER_THAN);
1497 }
1498 }
1499 }
1500
1501 query.append(ORDER_BY_CLAUSE);
1502
1503 for (int i = 0; i < orderByFields.length; i++) {
1504 query.append(_ORDER_BY_ENTITY_ALIAS);
1505 query.append(orderByFields[i]);
1506
1507 if ((i + 1) < orderByFields.length) {
1508 if (orderByComparator.isAscending() ^ previous) {
1509 query.append(ORDER_BY_ASC_HAS_NEXT);
1510 }
1511 else {
1512 query.append(ORDER_BY_DESC_HAS_NEXT);
1513 }
1514 }
1515 else {
1516 if (orderByComparator.isAscending() ^ previous) {
1517 query.append(ORDER_BY_ASC);
1518 }
1519 else {
1520 query.append(ORDER_BY_DESC);
1521 }
1522 }
1523 }
1524 }
1525
1526 else {
1527 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
1528 }
1529
1530 String sql = query.toString();
1531
1532 Query q = session.createQuery(sql);
1533
1534 q.setFirstResult(0);
1535 q.setMaxResults(2);
1536
1537 QueryPos qPos = QueryPos.getInstance(q);
1538
1539 qPos.add(parentCategoryId);
1540
1541 if (orderByComparator != null) {
1542 Object[] values = orderByComparator.getOrderByValues(assetCategory);
1543
1544 for (Object value : values) {
1545 qPos.add(value);
1546 }
1547 }
1548
1549 List<AssetCategory> list = q.list();
1550
1551 if (list.size() == 2) {
1552 return list.get(1);
1553 }
1554 else {
1555 return null;
1556 }
1557 }
1558
1559 public List<AssetCategory> findByVocabularyId(long vocabularyId)
1560 throws SystemException {
1561 return findByVocabularyId(vocabularyId, QueryUtil.ALL_POS,
1562 QueryUtil.ALL_POS, null);
1563 }
1564
1565 public List<AssetCategory> findByVocabularyId(long vocabularyId, int start,
1566 int end) throws SystemException {
1567 return findByVocabularyId(vocabularyId, start, end, null);
1568 }
1569
1570 public List<AssetCategory> findByVocabularyId(long vocabularyId, int start,
1571 int end, OrderByComparator orderByComparator) throws SystemException {
1572 Object[] finderArgs = new Object[] {
1573 vocabularyId,
1574
1575 String.valueOf(start), String.valueOf(end),
1576 String.valueOf(orderByComparator)
1577 };
1578
1579 List<AssetCategory> list = (List<AssetCategory>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_VOCABULARYID,
1580 finderArgs, this);
1581
1582 if (list == null) {
1583 Session session = null;
1584
1585 try {
1586 session = openSession();
1587
1588 StringBundler query = null;
1589
1590 if (orderByComparator != null) {
1591 query = new StringBundler(3 +
1592 (orderByComparator.getOrderByFields().length * 3));
1593 }
1594 else {
1595 query = new StringBundler(3);
1596 }
1597
1598 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
1599
1600 query.append(_FINDER_COLUMN_VOCABULARYID_VOCABULARYID_2);
1601
1602 if (orderByComparator != null) {
1603 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1604 orderByComparator);
1605 }
1606
1607 else {
1608 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
1609 }
1610
1611 String sql = query.toString();
1612
1613 Query q = session.createQuery(sql);
1614
1615 QueryPos qPos = QueryPos.getInstance(q);
1616
1617 qPos.add(vocabularyId);
1618
1619 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
1620 start, end);
1621 }
1622 catch (Exception e) {
1623 throw processException(e);
1624 }
1625 finally {
1626 if (list == null) {
1627 list = new ArrayList<AssetCategory>();
1628 }
1629
1630 cacheResult(list);
1631
1632 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_VOCABULARYID,
1633 finderArgs, list);
1634
1635 closeSession(session);
1636 }
1637 }
1638
1639 return list;
1640 }
1641
1642 public AssetCategory findByVocabularyId_First(long vocabularyId,
1643 OrderByComparator orderByComparator)
1644 throws NoSuchCategoryException, SystemException {
1645 List<AssetCategory> list = findByVocabularyId(vocabularyId, 0, 1,
1646 orderByComparator);
1647
1648 if (list.isEmpty()) {
1649 StringBundler msg = new StringBundler(4);
1650
1651 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1652
1653 msg.append("vocabularyId=");
1654 msg.append(vocabularyId);
1655
1656 msg.append(StringPool.CLOSE_CURLY_BRACE);
1657
1658 throw new NoSuchCategoryException(msg.toString());
1659 }
1660 else {
1661 return list.get(0);
1662 }
1663 }
1664
1665 public AssetCategory findByVocabularyId_Last(long vocabularyId,
1666 OrderByComparator orderByComparator)
1667 throws NoSuchCategoryException, SystemException {
1668 int count = countByVocabularyId(vocabularyId);
1669
1670 List<AssetCategory> list = findByVocabularyId(vocabularyId, count - 1,
1671 count, orderByComparator);
1672
1673 if (list.isEmpty()) {
1674 StringBundler msg = new StringBundler(4);
1675
1676 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1677
1678 msg.append("vocabularyId=");
1679 msg.append(vocabularyId);
1680
1681 msg.append(StringPool.CLOSE_CURLY_BRACE);
1682
1683 throw new NoSuchCategoryException(msg.toString());
1684 }
1685 else {
1686 return list.get(0);
1687 }
1688 }
1689
1690 public AssetCategory[] findByVocabularyId_PrevAndNext(long categoryId,
1691 long vocabularyId, OrderByComparator orderByComparator)
1692 throws NoSuchCategoryException, SystemException {
1693 AssetCategory assetCategory = findByPrimaryKey(categoryId);
1694
1695 Session session = null;
1696
1697 try {
1698 session = openSession();
1699
1700 AssetCategory[] array = new AssetCategoryImpl[3];
1701
1702 array[0] = getByVocabularyId_PrevAndNext(session, assetCategory,
1703 vocabularyId, orderByComparator, true);
1704
1705 array[1] = assetCategory;
1706
1707 array[2] = getByVocabularyId_PrevAndNext(session, assetCategory,
1708 vocabularyId, orderByComparator, false);
1709
1710 return array;
1711 }
1712 catch (Exception e) {
1713 throw processException(e);
1714 }
1715 finally {
1716 closeSession(session);
1717 }
1718 }
1719
1720 protected AssetCategory getByVocabularyId_PrevAndNext(Session session,
1721 AssetCategory assetCategory, long vocabularyId,
1722 OrderByComparator orderByComparator, boolean previous) {
1723 StringBundler query = null;
1724
1725 if (orderByComparator != null) {
1726 query = new StringBundler(6 +
1727 (orderByComparator.getOrderByFields().length * 6));
1728 }
1729 else {
1730 query = new StringBundler(3);
1731 }
1732
1733 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
1734
1735 query.append(_FINDER_COLUMN_VOCABULARYID_VOCABULARYID_2);
1736
1737 if (orderByComparator != null) {
1738 String[] orderByFields = orderByComparator.getOrderByFields();
1739
1740 if (orderByFields.length > 0) {
1741 query.append(WHERE_AND);
1742 }
1743
1744 for (int i = 0; i < orderByFields.length; i++) {
1745 query.append(_ORDER_BY_ENTITY_ALIAS);
1746 query.append(orderByFields[i]);
1747
1748 if ((i + 1) < orderByFields.length) {
1749 if (orderByComparator.isAscending() ^ previous) {
1750 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1751 }
1752 else {
1753 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1754 }
1755 }
1756 else {
1757 if (orderByComparator.isAscending() ^ previous) {
1758 query.append(WHERE_GREATER_THAN);
1759 }
1760 else {
1761 query.append(WHERE_LESSER_THAN);
1762 }
1763 }
1764 }
1765
1766 query.append(ORDER_BY_CLAUSE);
1767
1768 for (int i = 0; i < orderByFields.length; i++) {
1769 query.append(_ORDER_BY_ENTITY_ALIAS);
1770 query.append(orderByFields[i]);
1771
1772 if ((i + 1) < orderByFields.length) {
1773 if (orderByComparator.isAscending() ^ previous) {
1774 query.append(ORDER_BY_ASC_HAS_NEXT);
1775 }
1776 else {
1777 query.append(ORDER_BY_DESC_HAS_NEXT);
1778 }
1779 }
1780 else {
1781 if (orderByComparator.isAscending() ^ previous) {
1782 query.append(ORDER_BY_ASC);
1783 }
1784 else {
1785 query.append(ORDER_BY_DESC);
1786 }
1787 }
1788 }
1789 }
1790
1791 else {
1792 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
1793 }
1794
1795 String sql = query.toString();
1796
1797 Query q = session.createQuery(sql);
1798
1799 q.setFirstResult(0);
1800 q.setMaxResults(2);
1801
1802 QueryPos qPos = QueryPos.getInstance(q);
1803
1804 qPos.add(vocabularyId);
1805
1806 if (orderByComparator != null) {
1807 Object[] values = orderByComparator.getOrderByValues(assetCategory);
1808
1809 for (Object value : values) {
1810 qPos.add(value);
1811 }
1812 }
1813
1814 List<AssetCategory> list = q.list();
1815
1816 if (list.size() == 2) {
1817 return list.get(1);
1818 }
1819 else {
1820 return null;
1821 }
1822 }
1823
1824 public List<AssetCategory> findByP_N(long parentCategoryId, String name)
1825 throws SystemException {
1826 return findByP_N(parentCategoryId, name, QueryUtil.ALL_POS,
1827 QueryUtil.ALL_POS, null);
1828 }
1829
1830 public List<AssetCategory> findByP_N(long parentCategoryId, String name,
1831 int start, int end) throws SystemException {
1832 return findByP_N(parentCategoryId, name, start, end, null);
1833 }
1834
1835 public List<AssetCategory> findByP_N(long parentCategoryId, String name,
1836 int start, int end, OrderByComparator orderByComparator)
1837 throws SystemException {
1838 Object[] finderArgs = new Object[] {
1839 parentCategoryId, name,
1840
1841 String.valueOf(start), String.valueOf(end),
1842 String.valueOf(orderByComparator)
1843 };
1844
1845 List<AssetCategory> list = (List<AssetCategory>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_P_N,
1846 finderArgs, this);
1847
1848 if (list == null) {
1849 Session session = null;
1850
1851 try {
1852 session = openSession();
1853
1854 StringBundler query = null;
1855
1856 if (orderByComparator != null) {
1857 query = new StringBundler(4 +
1858 (orderByComparator.getOrderByFields().length * 3));
1859 }
1860 else {
1861 query = new StringBundler(4);
1862 }
1863
1864 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
1865
1866 query.append(_FINDER_COLUMN_P_N_PARENTCATEGORYID_2);
1867
1868 if (name == null) {
1869 query.append(_FINDER_COLUMN_P_N_NAME_1);
1870 }
1871 else {
1872 if (name.equals(StringPool.BLANK)) {
1873 query.append(_FINDER_COLUMN_P_N_NAME_3);
1874 }
1875 else {
1876 query.append(_FINDER_COLUMN_P_N_NAME_2);
1877 }
1878 }
1879
1880 if (orderByComparator != null) {
1881 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1882 orderByComparator);
1883 }
1884
1885 else {
1886 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
1887 }
1888
1889 String sql = query.toString();
1890
1891 Query q = session.createQuery(sql);
1892
1893 QueryPos qPos = QueryPos.getInstance(q);
1894
1895 qPos.add(parentCategoryId);
1896
1897 if (name != null) {
1898 qPos.add(name);
1899 }
1900
1901 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
1902 start, end);
1903 }
1904 catch (Exception e) {
1905 throw processException(e);
1906 }
1907 finally {
1908 if (list == null) {
1909 list = new ArrayList<AssetCategory>();
1910 }
1911
1912 cacheResult(list);
1913
1914 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_P_N, finderArgs,
1915 list);
1916
1917 closeSession(session);
1918 }
1919 }
1920
1921 return list;
1922 }
1923
1924 public AssetCategory findByP_N_First(long parentCategoryId, String name,
1925 OrderByComparator orderByComparator)
1926 throws NoSuchCategoryException, SystemException {
1927 List<AssetCategory> list = findByP_N(parentCategoryId, name, 0, 1,
1928 orderByComparator);
1929
1930 if (list.isEmpty()) {
1931 StringBundler msg = new StringBundler(6);
1932
1933 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1934
1935 msg.append("parentCategoryId=");
1936 msg.append(parentCategoryId);
1937
1938 msg.append(", name=");
1939 msg.append(name);
1940
1941 msg.append(StringPool.CLOSE_CURLY_BRACE);
1942
1943 throw new NoSuchCategoryException(msg.toString());
1944 }
1945 else {
1946 return list.get(0);
1947 }
1948 }
1949
1950 public AssetCategory findByP_N_Last(long parentCategoryId, String name,
1951 OrderByComparator orderByComparator)
1952 throws NoSuchCategoryException, SystemException {
1953 int count = countByP_N(parentCategoryId, name);
1954
1955 List<AssetCategory> list = findByP_N(parentCategoryId, name, count - 1,
1956 count, orderByComparator);
1957
1958 if (list.isEmpty()) {
1959 StringBundler msg = new StringBundler(6);
1960
1961 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1962
1963 msg.append("parentCategoryId=");
1964 msg.append(parentCategoryId);
1965
1966 msg.append(", name=");
1967 msg.append(name);
1968
1969 msg.append(StringPool.CLOSE_CURLY_BRACE);
1970
1971 throw new NoSuchCategoryException(msg.toString());
1972 }
1973 else {
1974 return list.get(0);
1975 }
1976 }
1977
1978 public AssetCategory[] findByP_N_PrevAndNext(long categoryId,
1979 long parentCategoryId, String name, OrderByComparator orderByComparator)
1980 throws NoSuchCategoryException, SystemException {
1981 AssetCategory assetCategory = findByPrimaryKey(categoryId);
1982
1983 Session session = null;
1984
1985 try {
1986 session = openSession();
1987
1988 AssetCategory[] array = new AssetCategoryImpl[3];
1989
1990 array[0] = getByP_N_PrevAndNext(session, assetCategory,
1991 parentCategoryId, name, orderByComparator, true);
1992
1993 array[1] = assetCategory;
1994
1995 array[2] = getByP_N_PrevAndNext(session, assetCategory,
1996 parentCategoryId, name, orderByComparator, false);
1997
1998 return array;
1999 }
2000 catch (Exception e) {
2001 throw processException(e);
2002 }
2003 finally {
2004 closeSession(session);
2005 }
2006 }
2007
2008 protected AssetCategory getByP_N_PrevAndNext(Session session,
2009 AssetCategory assetCategory, long parentCategoryId, String name,
2010 OrderByComparator orderByComparator, boolean previous) {
2011 StringBundler query = null;
2012
2013 if (orderByComparator != null) {
2014 query = new StringBundler(6 +
2015 (orderByComparator.getOrderByFields().length * 6));
2016 }
2017 else {
2018 query = new StringBundler(3);
2019 }
2020
2021 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
2022
2023 query.append(_FINDER_COLUMN_P_N_PARENTCATEGORYID_2);
2024
2025 if (name == null) {
2026 query.append(_FINDER_COLUMN_P_N_NAME_1);
2027 }
2028 else {
2029 if (name.equals(StringPool.BLANK)) {
2030 query.append(_FINDER_COLUMN_P_N_NAME_3);
2031 }
2032 else {
2033 query.append(_FINDER_COLUMN_P_N_NAME_2);
2034 }
2035 }
2036
2037 if (orderByComparator != null) {
2038 String[] orderByFields = orderByComparator.getOrderByFields();
2039
2040 if (orderByFields.length > 0) {
2041 query.append(WHERE_AND);
2042 }
2043
2044 for (int i = 0; i < orderByFields.length; i++) {
2045 query.append(_ORDER_BY_ENTITY_ALIAS);
2046 query.append(orderByFields[i]);
2047
2048 if ((i + 1) < orderByFields.length) {
2049 if (orderByComparator.isAscending() ^ previous) {
2050 query.append(WHERE_GREATER_THAN_HAS_NEXT);
2051 }
2052 else {
2053 query.append(WHERE_LESSER_THAN_HAS_NEXT);
2054 }
2055 }
2056 else {
2057 if (orderByComparator.isAscending() ^ previous) {
2058 query.append(WHERE_GREATER_THAN);
2059 }
2060 else {
2061 query.append(WHERE_LESSER_THAN);
2062 }
2063 }
2064 }
2065
2066 query.append(ORDER_BY_CLAUSE);
2067
2068 for (int i = 0; i < orderByFields.length; i++) {
2069 query.append(_ORDER_BY_ENTITY_ALIAS);
2070 query.append(orderByFields[i]);
2071
2072 if ((i + 1) < orderByFields.length) {
2073 if (orderByComparator.isAscending() ^ previous) {
2074 query.append(ORDER_BY_ASC_HAS_NEXT);
2075 }
2076 else {
2077 query.append(ORDER_BY_DESC_HAS_NEXT);
2078 }
2079 }
2080 else {
2081 if (orderByComparator.isAscending() ^ previous) {
2082 query.append(ORDER_BY_ASC);
2083 }
2084 else {
2085 query.append(ORDER_BY_DESC);
2086 }
2087 }
2088 }
2089 }
2090
2091 else {
2092 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
2093 }
2094
2095 String sql = query.toString();
2096
2097 Query q = session.createQuery(sql);
2098
2099 q.setFirstResult(0);
2100 q.setMaxResults(2);
2101
2102 QueryPos qPos = QueryPos.getInstance(q);
2103
2104 qPos.add(parentCategoryId);
2105
2106 if (name != null) {
2107 qPos.add(name);
2108 }
2109
2110 if (orderByComparator != null) {
2111 Object[] values = orderByComparator.getOrderByValues(assetCategory);
2112
2113 for (Object value : values) {
2114 qPos.add(value);
2115 }
2116 }
2117
2118 List<AssetCategory> list = q.list();
2119
2120 if (list.size() == 2) {
2121 return list.get(1);
2122 }
2123 else {
2124 return null;
2125 }
2126 }
2127
2128 public List<AssetCategory> findByP_V(long parentCategoryId,
2129 long vocabularyId) throws SystemException {
2130 return findByP_V(parentCategoryId, vocabularyId, QueryUtil.ALL_POS,
2131 QueryUtil.ALL_POS, null);
2132 }
2133
2134 public List<AssetCategory> findByP_V(long parentCategoryId,
2135 long vocabularyId, int start, int end) throws SystemException {
2136 return findByP_V(parentCategoryId, vocabularyId, start, end, null);
2137 }
2138
2139 public List<AssetCategory> findByP_V(long parentCategoryId,
2140 long vocabularyId, int start, int end,
2141 OrderByComparator orderByComparator) throws SystemException {
2142 Object[] finderArgs = new Object[] {
2143 parentCategoryId, vocabularyId,
2144
2145 String.valueOf(start), String.valueOf(end),
2146 String.valueOf(orderByComparator)
2147 };
2148
2149 List<AssetCategory> list = (List<AssetCategory>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_P_V,
2150 finderArgs, this);
2151
2152 if (list == null) {
2153 Session session = null;
2154
2155 try {
2156 session = openSession();
2157
2158 StringBundler query = null;
2159
2160 if (orderByComparator != null) {
2161 query = new StringBundler(4 +
2162 (orderByComparator.getOrderByFields().length * 3));
2163 }
2164 else {
2165 query = new StringBundler(4);
2166 }
2167
2168 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
2169
2170 query.append(_FINDER_COLUMN_P_V_PARENTCATEGORYID_2);
2171
2172 query.append(_FINDER_COLUMN_P_V_VOCABULARYID_2);
2173
2174 if (orderByComparator != null) {
2175 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2176 orderByComparator);
2177 }
2178
2179 else {
2180 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
2181 }
2182
2183 String sql = query.toString();
2184
2185 Query q = session.createQuery(sql);
2186
2187 QueryPos qPos = QueryPos.getInstance(q);
2188
2189 qPos.add(parentCategoryId);
2190
2191 qPos.add(vocabularyId);
2192
2193 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
2194 start, end);
2195 }
2196 catch (Exception e) {
2197 throw processException(e);
2198 }
2199 finally {
2200 if (list == null) {
2201 list = new ArrayList<AssetCategory>();
2202 }
2203
2204 cacheResult(list);
2205
2206 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_P_V, finderArgs,
2207 list);
2208
2209 closeSession(session);
2210 }
2211 }
2212
2213 return list;
2214 }
2215
2216 public AssetCategory findByP_V_First(long parentCategoryId,
2217 long vocabularyId, OrderByComparator orderByComparator)
2218 throws NoSuchCategoryException, SystemException {
2219 List<AssetCategory> list = findByP_V(parentCategoryId, vocabularyId, 0,
2220 1, orderByComparator);
2221
2222 if (list.isEmpty()) {
2223 StringBundler msg = new StringBundler(6);
2224
2225 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2226
2227 msg.append("parentCategoryId=");
2228 msg.append(parentCategoryId);
2229
2230 msg.append(", vocabularyId=");
2231 msg.append(vocabularyId);
2232
2233 msg.append(StringPool.CLOSE_CURLY_BRACE);
2234
2235 throw new NoSuchCategoryException(msg.toString());
2236 }
2237 else {
2238 return list.get(0);
2239 }
2240 }
2241
2242 public AssetCategory findByP_V_Last(long parentCategoryId,
2243 long vocabularyId, OrderByComparator orderByComparator)
2244 throws NoSuchCategoryException, SystemException {
2245 int count = countByP_V(parentCategoryId, vocabularyId);
2246
2247 List<AssetCategory> list = findByP_V(parentCategoryId, vocabularyId,
2248 count - 1, count, orderByComparator);
2249
2250 if (list.isEmpty()) {
2251 StringBundler msg = new StringBundler(6);
2252
2253 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2254
2255 msg.append("parentCategoryId=");
2256 msg.append(parentCategoryId);
2257
2258 msg.append(", vocabularyId=");
2259 msg.append(vocabularyId);
2260
2261 msg.append(StringPool.CLOSE_CURLY_BRACE);
2262
2263 throw new NoSuchCategoryException(msg.toString());
2264 }
2265 else {
2266 return list.get(0);
2267 }
2268 }
2269
2270 public AssetCategory[] findByP_V_PrevAndNext(long categoryId,
2271 long parentCategoryId, long vocabularyId,
2272 OrderByComparator orderByComparator)
2273 throws NoSuchCategoryException, SystemException {
2274 AssetCategory assetCategory = findByPrimaryKey(categoryId);
2275
2276 Session session = null;
2277
2278 try {
2279 session = openSession();
2280
2281 AssetCategory[] array = new AssetCategoryImpl[3];
2282
2283 array[0] = getByP_V_PrevAndNext(session, assetCategory,
2284 parentCategoryId, vocabularyId, orderByComparator, true);
2285
2286 array[1] = assetCategory;
2287
2288 array[2] = getByP_V_PrevAndNext(session, assetCategory,
2289 parentCategoryId, vocabularyId, orderByComparator, false);
2290
2291 return array;
2292 }
2293 catch (Exception e) {
2294 throw processException(e);
2295 }
2296 finally {
2297 closeSession(session);
2298 }
2299 }
2300
2301 protected AssetCategory getByP_V_PrevAndNext(Session session,
2302 AssetCategory assetCategory, long parentCategoryId, long vocabularyId,
2303 OrderByComparator orderByComparator, boolean previous) {
2304 StringBundler query = null;
2305
2306 if (orderByComparator != null) {
2307 query = new StringBundler(6 +
2308 (orderByComparator.getOrderByFields().length * 6));
2309 }
2310 else {
2311 query = new StringBundler(3);
2312 }
2313
2314 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
2315
2316 query.append(_FINDER_COLUMN_P_V_PARENTCATEGORYID_2);
2317
2318 query.append(_FINDER_COLUMN_P_V_VOCABULARYID_2);
2319
2320 if (orderByComparator != null) {
2321 String[] orderByFields = orderByComparator.getOrderByFields();
2322
2323 if (orderByFields.length > 0) {
2324 query.append(WHERE_AND);
2325 }
2326
2327 for (int i = 0; i < orderByFields.length; i++) {
2328 query.append(_ORDER_BY_ENTITY_ALIAS);
2329 query.append(orderByFields[i]);
2330
2331 if ((i + 1) < orderByFields.length) {
2332 if (orderByComparator.isAscending() ^ previous) {
2333 query.append(WHERE_GREATER_THAN_HAS_NEXT);
2334 }
2335 else {
2336 query.append(WHERE_LESSER_THAN_HAS_NEXT);
2337 }
2338 }
2339 else {
2340 if (orderByComparator.isAscending() ^ previous) {
2341 query.append(WHERE_GREATER_THAN);
2342 }
2343 else {
2344 query.append(WHERE_LESSER_THAN);
2345 }
2346 }
2347 }
2348
2349 query.append(ORDER_BY_CLAUSE);
2350
2351 for (int i = 0; i < orderByFields.length; i++) {
2352 query.append(_ORDER_BY_ENTITY_ALIAS);
2353 query.append(orderByFields[i]);
2354
2355 if ((i + 1) < orderByFields.length) {
2356 if (orderByComparator.isAscending() ^ previous) {
2357 query.append(ORDER_BY_ASC_HAS_NEXT);
2358 }
2359 else {
2360 query.append(ORDER_BY_DESC_HAS_NEXT);
2361 }
2362 }
2363 else {
2364 if (orderByComparator.isAscending() ^ previous) {
2365 query.append(ORDER_BY_ASC);
2366 }
2367 else {
2368 query.append(ORDER_BY_DESC);
2369 }
2370 }
2371 }
2372 }
2373
2374 else {
2375 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
2376 }
2377
2378 String sql = query.toString();
2379
2380 Query q = session.createQuery(sql);
2381
2382 q.setFirstResult(0);
2383 q.setMaxResults(2);
2384
2385 QueryPos qPos = QueryPos.getInstance(q);
2386
2387 qPos.add(parentCategoryId);
2388
2389 qPos.add(vocabularyId);
2390
2391 if (orderByComparator != null) {
2392 Object[] values = orderByComparator.getOrderByValues(assetCategory);
2393
2394 for (Object value : values) {
2395 qPos.add(value);
2396 }
2397 }
2398
2399 List<AssetCategory> list = q.list();
2400
2401 if (list.size() == 2) {
2402 return list.get(1);
2403 }
2404 else {
2405 return null;
2406 }
2407 }
2408
2409 public List<AssetCategory> findByN_V(String name, long vocabularyId)
2410 throws SystemException {
2411 return findByN_V(name, vocabularyId, QueryUtil.ALL_POS,
2412 QueryUtil.ALL_POS, null);
2413 }
2414
2415 public List<AssetCategory> findByN_V(String name, long vocabularyId,
2416 int start, int end) throws SystemException {
2417 return findByN_V(name, vocabularyId, start, end, null);
2418 }
2419
2420 public List<AssetCategory> findByN_V(String name, long vocabularyId,
2421 int start, int end, OrderByComparator orderByComparator)
2422 throws SystemException {
2423 Object[] finderArgs = new Object[] {
2424 name, vocabularyId,
2425
2426 String.valueOf(start), String.valueOf(end),
2427 String.valueOf(orderByComparator)
2428 };
2429
2430 List<AssetCategory> list = (List<AssetCategory>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_N_V,
2431 finderArgs, this);
2432
2433 if (list == null) {
2434 Session session = null;
2435
2436 try {
2437 session = openSession();
2438
2439 StringBundler query = null;
2440
2441 if (orderByComparator != null) {
2442 query = new StringBundler(4 +
2443 (orderByComparator.getOrderByFields().length * 3));
2444 }
2445 else {
2446 query = new StringBundler(4);
2447 }
2448
2449 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
2450
2451 if (name == null) {
2452 query.append(_FINDER_COLUMN_N_V_NAME_1);
2453 }
2454 else {
2455 if (name.equals(StringPool.BLANK)) {
2456 query.append(_FINDER_COLUMN_N_V_NAME_3);
2457 }
2458 else {
2459 query.append(_FINDER_COLUMN_N_V_NAME_2);
2460 }
2461 }
2462
2463 query.append(_FINDER_COLUMN_N_V_VOCABULARYID_2);
2464
2465 if (orderByComparator != null) {
2466 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2467 orderByComparator);
2468 }
2469
2470 else {
2471 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
2472 }
2473
2474 String sql = query.toString();
2475
2476 Query q = session.createQuery(sql);
2477
2478 QueryPos qPos = QueryPos.getInstance(q);
2479
2480 if (name != null) {
2481 qPos.add(name);
2482 }
2483
2484 qPos.add(vocabularyId);
2485
2486 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
2487 start, end);
2488 }
2489 catch (Exception e) {
2490 throw processException(e);
2491 }
2492 finally {
2493 if (list == null) {
2494 list = new ArrayList<AssetCategory>();
2495 }
2496
2497 cacheResult(list);
2498
2499 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_N_V, finderArgs,
2500 list);
2501
2502 closeSession(session);
2503 }
2504 }
2505
2506 return list;
2507 }
2508
2509 public AssetCategory findByN_V_First(String name, long vocabularyId,
2510 OrderByComparator orderByComparator)
2511 throws NoSuchCategoryException, SystemException {
2512 List<AssetCategory> list = findByN_V(name, vocabularyId, 0, 1,
2513 orderByComparator);
2514
2515 if (list.isEmpty()) {
2516 StringBundler msg = new StringBundler(6);
2517
2518 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2519
2520 msg.append("name=");
2521 msg.append(name);
2522
2523 msg.append(", vocabularyId=");
2524 msg.append(vocabularyId);
2525
2526 msg.append(StringPool.CLOSE_CURLY_BRACE);
2527
2528 throw new NoSuchCategoryException(msg.toString());
2529 }
2530 else {
2531 return list.get(0);
2532 }
2533 }
2534
2535 public AssetCategory findByN_V_Last(String name, long vocabularyId,
2536 OrderByComparator orderByComparator)
2537 throws NoSuchCategoryException, SystemException {
2538 int count = countByN_V(name, vocabularyId);
2539
2540 List<AssetCategory> list = findByN_V(name, vocabularyId, count - 1,
2541 count, orderByComparator);
2542
2543 if (list.isEmpty()) {
2544 StringBundler msg = new StringBundler(6);
2545
2546 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2547
2548 msg.append("name=");
2549 msg.append(name);
2550
2551 msg.append(", vocabularyId=");
2552 msg.append(vocabularyId);
2553
2554 msg.append(StringPool.CLOSE_CURLY_BRACE);
2555
2556 throw new NoSuchCategoryException(msg.toString());
2557 }
2558 else {
2559 return list.get(0);
2560 }
2561 }
2562
2563 public AssetCategory[] findByN_V_PrevAndNext(long categoryId, String name,
2564 long vocabularyId, OrderByComparator orderByComparator)
2565 throws NoSuchCategoryException, SystemException {
2566 AssetCategory assetCategory = findByPrimaryKey(categoryId);
2567
2568 Session session = null;
2569
2570 try {
2571 session = openSession();
2572
2573 AssetCategory[] array = new AssetCategoryImpl[3];
2574
2575 array[0] = getByN_V_PrevAndNext(session, assetCategory, name,
2576 vocabularyId, orderByComparator, true);
2577
2578 array[1] = assetCategory;
2579
2580 array[2] = getByN_V_PrevAndNext(session, assetCategory, name,
2581 vocabularyId, orderByComparator, false);
2582
2583 return array;
2584 }
2585 catch (Exception e) {
2586 throw processException(e);
2587 }
2588 finally {
2589 closeSession(session);
2590 }
2591 }
2592
2593 protected AssetCategory getByN_V_PrevAndNext(Session session,
2594 AssetCategory assetCategory, String name, long vocabularyId,
2595 OrderByComparator orderByComparator, boolean previous) {
2596 StringBundler query = null;
2597
2598 if (orderByComparator != null) {
2599 query = new StringBundler(6 +
2600 (orderByComparator.getOrderByFields().length * 6));
2601 }
2602 else {
2603 query = new StringBundler(3);
2604 }
2605
2606 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
2607
2608 if (name == null) {
2609 query.append(_FINDER_COLUMN_N_V_NAME_1);
2610 }
2611 else {
2612 if (name.equals(StringPool.BLANK)) {
2613 query.append(_FINDER_COLUMN_N_V_NAME_3);
2614 }
2615 else {
2616 query.append(_FINDER_COLUMN_N_V_NAME_2);
2617 }
2618 }
2619
2620 query.append(_FINDER_COLUMN_N_V_VOCABULARYID_2);
2621
2622 if (orderByComparator != null) {
2623 String[] orderByFields = orderByComparator.getOrderByFields();
2624
2625 if (orderByFields.length > 0) {
2626 query.append(WHERE_AND);
2627 }
2628
2629 for (int i = 0; i < orderByFields.length; i++) {
2630 query.append(_ORDER_BY_ENTITY_ALIAS);
2631 query.append(orderByFields[i]);
2632
2633 if ((i + 1) < orderByFields.length) {
2634 if (orderByComparator.isAscending() ^ previous) {
2635 query.append(WHERE_GREATER_THAN_HAS_NEXT);
2636 }
2637 else {
2638 query.append(WHERE_LESSER_THAN_HAS_NEXT);
2639 }
2640 }
2641 else {
2642 if (orderByComparator.isAscending() ^ previous) {
2643 query.append(WHERE_GREATER_THAN);
2644 }
2645 else {
2646 query.append(WHERE_LESSER_THAN);
2647 }
2648 }
2649 }
2650
2651 query.append(ORDER_BY_CLAUSE);
2652
2653 for (int i = 0; i < orderByFields.length; i++) {
2654 query.append(_ORDER_BY_ENTITY_ALIAS);
2655 query.append(orderByFields[i]);
2656
2657 if ((i + 1) < orderByFields.length) {
2658 if (orderByComparator.isAscending() ^ previous) {
2659 query.append(ORDER_BY_ASC_HAS_NEXT);
2660 }
2661 else {
2662 query.append(ORDER_BY_DESC_HAS_NEXT);
2663 }
2664 }
2665 else {
2666 if (orderByComparator.isAscending() ^ previous) {
2667 query.append(ORDER_BY_ASC);
2668 }
2669 else {
2670 query.append(ORDER_BY_DESC);
2671 }
2672 }
2673 }
2674 }
2675
2676 else {
2677 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
2678 }
2679
2680 String sql = query.toString();
2681
2682 Query q = session.createQuery(sql);
2683
2684 q.setFirstResult(0);
2685 q.setMaxResults(2);
2686
2687 QueryPos qPos = QueryPos.getInstance(q);
2688
2689 if (name != null) {
2690 qPos.add(name);
2691 }
2692
2693 qPos.add(vocabularyId);
2694
2695 if (orderByComparator != null) {
2696 Object[] values = orderByComparator.getOrderByValues(assetCategory);
2697
2698 for (Object value : values) {
2699 qPos.add(value);
2700 }
2701 }
2702
2703 List<AssetCategory> list = q.list();
2704
2705 if (list.size() == 2) {
2706 return list.get(1);
2707 }
2708 else {
2709 return null;
2710 }
2711 }
2712
2713 public AssetCategory findByP_N_V(long parentCategoryId, String name,
2714 long vocabularyId) throws NoSuchCategoryException, SystemException {
2715 AssetCategory assetCategory = fetchByP_N_V(parentCategoryId, name,
2716 vocabularyId);
2717
2718 if (assetCategory == null) {
2719 StringBundler msg = new StringBundler(8);
2720
2721 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2722
2723 msg.append("parentCategoryId=");
2724 msg.append(parentCategoryId);
2725
2726 msg.append(", name=");
2727 msg.append(name);
2728
2729 msg.append(", vocabularyId=");
2730 msg.append(vocabularyId);
2731
2732 msg.append(StringPool.CLOSE_CURLY_BRACE);
2733
2734 if (_log.isWarnEnabled()) {
2735 _log.warn(msg.toString());
2736 }
2737
2738 throw new NoSuchCategoryException(msg.toString());
2739 }
2740
2741 return assetCategory;
2742 }
2743
2744 public AssetCategory fetchByP_N_V(long parentCategoryId, String name,
2745 long vocabularyId) throws SystemException {
2746 return fetchByP_N_V(parentCategoryId, name, vocabularyId, true);
2747 }
2748
2749 public AssetCategory fetchByP_N_V(long parentCategoryId, String name,
2750 long vocabularyId, boolean retrieveFromCache) throws SystemException {
2751 Object[] finderArgs = new Object[] { parentCategoryId, name, vocabularyId };
2752
2753 Object result = null;
2754
2755 if (retrieveFromCache) {
2756 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_P_N_V,
2757 finderArgs, this);
2758 }
2759
2760 if (result == null) {
2761 Session session = null;
2762
2763 try {
2764 session = openSession();
2765
2766 StringBundler query = new StringBundler(5);
2767
2768 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
2769
2770 query.append(_FINDER_COLUMN_P_N_V_PARENTCATEGORYID_2);
2771
2772 if (name == null) {
2773 query.append(_FINDER_COLUMN_P_N_V_NAME_1);
2774 }
2775 else {
2776 if (name.equals(StringPool.BLANK)) {
2777 query.append(_FINDER_COLUMN_P_N_V_NAME_3);
2778 }
2779 else {
2780 query.append(_FINDER_COLUMN_P_N_V_NAME_2);
2781 }
2782 }
2783
2784 query.append(_FINDER_COLUMN_P_N_V_VOCABULARYID_2);
2785
2786 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
2787
2788 String sql = query.toString();
2789
2790 Query q = session.createQuery(sql);
2791
2792 QueryPos qPos = QueryPos.getInstance(q);
2793
2794 qPos.add(parentCategoryId);
2795
2796 if (name != null) {
2797 qPos.add(name);
2798 }
2799
2800 qPos.add(vocabularyId);
2801
2802 List<AssetCategory> list = q.list();
2803
2804 result = list;
2805
2806 AssetCategory assetCategory = null;
2807
2808 if (list.isEmpty()) {
2809 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_P_N_V,
2810 finderArgs, list);
2811 }
2812 else {
2813 assetCategory = list.get(0);
2814
2815 cacheResult(assetCategory);
2816
2817 if ((assetCategory.getParentCategoryId() != parentCategoryId) ||
2818 (assetCategory.getName() == null) ||
2819 !assetCategory.getName().equals(name) ||
2820 (assetCategory.getVocabularyId() != vocabularyId)) {
2821 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_P_N_V,
2822 finderArgs, assetCategory);
2823 }
2824 }
2825
2826 return assetCategory;
2827 }
2828 catch (Exception e) {
2829 throw processException(e);
2830 }
2831 finally {
2832 if (result == null) {
2833 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_P_N_V,
2834 finderArgs, new ArrayList<AssetCategory>());
2835 }
2836
2837 closeSession(session);
2838 }
2839 }
2840 else {
2841 if (result instanceof List<?>) {
2842 return null;
2843 }
2844 else {
2845 return (AssetCategory)result;
2846 }
2847 }
2848 }
2849
2850 public List<AssetCategory> findAll() throws SystemException {
2851 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
2852 }
2853
2854 public List<AssetCategory> findAll(int start, int end)
2855 throws SystemException {
2856 return findAll(start, end, null);
2857 }
2858
2859 public List<AssetCategory> findAll(int start, int end,
2860 OrderByComparator orderByComparator) throws SystemException {
2861 Object[] finderArgs = new Object[] {
2862 String.valueOf(start), String.valueOf(end),
2863 String.valueOf(orderByComparator)
2864 };
2865
2866 List<AssetCategory> list = (List<AssetCategory>)FinderCacheUtil.getResult(FINDER_PATH_FIND_ALL,
2867 finderArgs, this);
2868
2869 if (list == null) {
2870 Session session = null;
2871
2872 try {
2873 session = openSession();
2874
2875 StringBundler query = null;
2876 String sql = null;
2877
2878 if (orderByComparator != null) {
2879 query = new StringBundler(2 +
2880 (orderByComparator.getOrderByFields().length * 3));
2881
2882 query.append(_SQL_SELECT_ASSETCATEGORY);
2883
2884 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2885 orderByComparator);
2886
2887 sql = query.toString();
2888 }
2889 else {
2890 sql = _SQL_SELECT_ASSETCATEGORY.concat(AssetCategoryModelImpl.ORDER_BY_JPQL);
2891 }
2892
2893 Query q = session.createQuery(sql);
2894
2895 if (orderByComparator == null) {
2896 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
2897 start, end, false);
2898
2899 Collections.sort(list);
2900 }
2901 else {
2902 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
2903 start, end);
2904 }
2905 }
2906 catch (Exception e) {
2907 throw processException(e);
2908 }
2909 finally {
2910 if (list == null) {
2911 list = new ArrayList<AssetCategory>();
2912 }
2913
2914 cacheResult(list);
2915
2916 FinderCacheUtil.putResult(FINDER_PATH_FIND_ALL, finderArgs, list);
2917
2918 closeSession(session);
2919 }
2920 }
2921
2922 return list;
2923 }
2924
2925 public void removeByUuid(String uuid) throws SystemException {
2926 for (AssetCategory assetCategory : findByUuid(uuid)) {
2927 remove(assetCategory);
2928 }
2929 }
2930
2931 public void removeByUUID_G(String uuid, long groupId)
2932 throws NoSuchCategoryException, SystemException {
2933 AssetCategory assetCategory = findByUUID_G(uuid, groupId);
2934
2935 remove(assetCategory);
2936 }
2937
2938 public void removeByGroupId(long groupId) throws SystemException {
2939 for (AssetCategory assetCategory : findByGroupId(groupId)) {
2940 remove(assetCategory);
2941 }
2942 }
2943
2944 public void removeByParentCategoryId(long parentCategoryId)
2945 throws SystemException {
2946 for (AssetCategory assetCategory : findByParentCategoryId(
2947 parentCategoryId)) {
2948 remove(assetCategory);
2949 }
2950 }
2951
2952 public void removeByVocabularyId(long vocabularyId)
2953 throws SystemException {
2954 for (AssetCategory assetCategory : findByVocabularyId(vocabularyId)) {
2955 remove(assetCategory);
2956 }
2957 }
2958
2959 public void removeByP_N(long parentCategoryId, String name)
2960 throws SystemException {
2961 for (AssetCategory assetCategory : findByP_N(parentCategoryId, name)) {
2962 remove(assetCategory);
2963 }
2964 }
2965
2966 public void removeByP_V(long parentCategoryId, long vocabularyId)
2967 throws SystemException {
2968 for (AssetCategory assetCategory : findByP_V(parentCategoryId,
2969 vocabularyId)) {
2970 remove(assetCategory);
2971 }
2972 }
2973
2974 public void removeByN_V(String name, long vocabularyId)
2975 throws SystemException {
2976 for (AssetCategory assetCategory : findByN_V(name, vocabularyId)) {
2977 remove(assetCategory);
2978 }
2979 }
2980
2981 public void removeByP_N_V(long parentCategoryId, String name,
2982 long vocabularyId) throws NoSuchCategoryException, SystemException {
2983 AssetCategory assetCategory = findByP_N_V(parentCategoryId, name,
2984 vocabularyId);
2985
2986 remove(assetCategory);
2987 }
2988
2989 public void removeAll() throws SystemException {
2990 for (AssetCategory assetCategory : findAll()) {
2991 remove(assetCategory);
2992 }
2993 }
2994
2995 public int countByUuid(String uuid) throws SystemException {
2996 Object[] finderArgs = new Object[] { uuid };
2997
2998 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID,
2999 finderArgs, this);
3000
3001 if (count == null) {
3002 Session session = null;
3003
3004 try {
3005 session = openSession();
3006
3007 StringBundler query = new StringBundler(2);
3008
3009 query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
3010
3011 if (uuid == null) {
3012 query.append(_FINDER_COLUMN_UUID_UUID_1);
3013 }
3014 else {
3015 if (uuid.equals(StringPool.BLANK)) {
3016 query.append(_FINDER_COLUMN_UUID_UUID_3);
3017 }
3018 else {
3019 query.append(_FINDER_COLUMN_UUID_UUID_2);
3020 }
3021 }
3022
3023 String sql = query.toString();
3024
3025 Query q = session.createQuery(sql);
3026
3027 QueryPos qPos = QueryPos.getInstance(q);
3028
3029 if (uuid != null) {
3030 qPos.add(uuid);
3031 }
3032
3033 count = (Long)q.uniqueResult();
3034 }
3035 catch (Exception e) {
3036 throw processException(e);
3037 }
3038 finally {
3039 if (count == null) {
3040 count = Long.valueOf(0);
3041 }
3042
3043 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID,
3044 finderArgs, count);
3045
3046 closeSession(session);
3047 }
3048 }
3049
3050 return count.intValue();
3051 }
3052
3053 public int countByUUID_G(String uuid, long groupId)
3054 throws SystemException {
3055 Object[] finderArgs = new Object[] { uuid, groupId };
3056
3057 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID_G,
3058 finderArgs, this);
3059
3060 if (count == null) {
3061 Session session = null;
3062
3063 try {
3064 session = openSession();
3065
3066 StringBundler query = new StringBundler(3);
3067
3068 query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
3069
3070 if (uuid == null) {
3071 query.append(_FINDER_COLUMN_UUID_G_UUID_1);
3072 }
3073 else {
3074 if (uuid.equals(StringPool.BLANK)) {
3075 query.append(_FINDER_COLUMN_UUID_G_UUID_3);
3076 }
3077 else {
3078 query.append(_FINDER_COLUMN_UUID_G_UUID_2);
3079 }
3080 }
3081
3082 query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
3083
3084 String sql = query.toString();
3085
3086 Query q = session.createQuery(sql);
3087
3088 QueryPos qPos = QueryPos.getInstance(q);
3089
3090 if (uuid != null) {
3091 qPos.add(uuid);
3092 }
3093
3094 qPos.add(groupId);
3095
3096 count = (Long)q.uniqueResult();
3097 }
3098 catch (Exception e) {
3099 throw processException(e);
3100 }
3101 finally {
3102 if (count == null) {
3103 count = Long.valueOf(0);
3104 }
3105
3106 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G,
3107 finderArgs, count);
3108
3109 closeSession(session);
3110 }
3111 }
3112
3113 return count.intValue();
3114 }
3115
3116 public int countByGroupId(long groupId) throws SystemException {
3117 Object[] finderArgs = new Object[] { groupId };
3118
3119 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_GROUPID,
3120 finderArgs, this);
3121
3122 if (count == null) {
3123 Session session = null;
3124
3125 try {
3126 session = openSession();
3127
3128 StringBundler query = new StringBundler(2);
3129
3130 query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
3131
3132 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
3133
3134 String sql = query.toString();
3135
3136 Query q = session.createQuery(sql);
3137
3138 QueryPos qPos = QueryPos.getInstance(q);
3139
3140 qPos.add(groupId);
3141
3142 count = (Long)q.uniqueResult();
3143 }
3144 catch (Exception e) {
3145 throw processException(e);
3146 }
3147 finally {
3148 if (count == null) {
3149 count = Long.valueOf(0);
3150 }
3151
3152 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_GROUPID,
3153 finderArgs, count);
3154
3155 closeSession(session);
3156 }
3157 }
3158
3159 return count.intValue();
3160 }
3161
3162 public int filterCountByGroupId(long groupId) throws SystemException {
3163 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
3164 return countByGroupId(groupId);
3165 }
3166
3167 Session session = null;
3168
3169 try {
3170 session = openSession();
3171
3172 StringBundler query = new StringBundler(2);
3173
3174 query.append(_FILTER_SQL_COUNT_ASSETCATEGORY_WHERE);
3175
3176 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
3177
3178 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
3179 AssetCategory.class.getName(), _FILTER_COLUMN_PK,
3180 _FILTER_COLUMN_USERID, groupId);
3181
3182 SQLQuery q = session.createSQLQuery(sql);
3183
3184 q.addScalar(COUNT_COLUMN_NAME,
3185 com.liferay.portal.kernel.dao.orm.Type.LONG);
3186
3187 QueryPos qPos = QueryPos.getInstance(q);
3188
3189 qPos.add(groupId);
3190
3191 Long count = (Long)q.uniqueResult();
3192
3193 return count.intValue();
3194 }
3195 catch (Exception e) {
3196 throw processException(e);
3197 }
3198 finally {
3199 closeSession(session);
3200 }
3201 }
3202
3203 public int countByParentCategoryId(long parentCategoryId)
3204 throws SystemException {
3205 Object[] finderArgs = new Object[] { parentCategoryId };
3206
3207 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_PARENTCATEGORYID,
3208 finderArgs, this);
3209
3210 if (count == null) {
3211 Session session = null;
3212
3213 try {
3214 session = openSession();
3215
3216 StringBundler query = new StringBundler(2);
3217
3218 query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
3219
3220 query.append(_FINDER_COLUMN_PARENTCATEGORYID_PARENTCATEGORYID_2);
3221
3222 String sql = query.toString();
3223
3224 Query q = session.createQuery(sql);
3225
3226 QueryPos qPos = QueryPos.getInstance(q);
3227
3228 qPos.add(parentCategoryId);
3229
3230 count = (Long)q.uniqueResult();
3231 }
3232 catch (Exception e) {
3233 throw processException(e);
3234 }
3235 finally {
3236 if (count == null) {
3237 count = Long.valueOf(0);
3238 }
3239
3240 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_PARENTCATEGORYID,
3241 finderArgs, count);
3242
3243 closeSession(session);
3244 }
3245 }
3246
3247 return count.intValue();
3248 }
3249
3250 public int countByVocabularyId(long vocabularyId) throws SystemException {
3251 Object[] finderArgs = new Object[] { vocabularyId };
3252
3253 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_VOCABULARYID,
3254 finderArgs, this);
3255
3256 if (count == null) {
3257 Session session = null;
3258
3259 try {
3260 session = openSession();
3261
3262 StringBundler query = new StringBundler(2);
3263
3264 query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
3265
3266 query.append(_FINDER_COLUMN_VOCABULARYID_VOCABULARYID_2);
3267
3268 String sql = query.toString();
3269
3270 Query q = session.createQuery(sql);
3271
3272 QueryPos qPos = QueryPos.getInstance(q);
3273
3274 qPos.add(vocabularyId);
3275
3276 count = (Long)q.uniqueResult();
3277 }
3278 catch (Exception e) {
3279 throw processException(e);
3280 }
3281 finally {
3282 if (count == null) {
3283 count = Long.valueOf(0);
3284 }
3285
3286 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_VOCABULARYID,
3287 finderArgs, count);
3288
3289 closeSession(session);
3290 }
3291 }
3292
3293 return count.intValue();
3294 }
3295
3296 public int countByP_N(long parentCategoryId, String name)
3297 throws SystemException {
3298 Object[] finderArgs = new Object[] { parentCategoryId, name };
3299
3300 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_P_N,
3301 finderArgs, this);
3302
3303 if (count == null) {
3304 Session session = null;
3305
3306 try {
3307 session = openSession();
3308
3309 StringBundler query = new StringBundler(3);
3310
3311 query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
3312
3313 query.append(_FINDER_COLUMN_P_N_PARENTCATEGORYID_2);
3314
3315 if (name == null) {
3316 query.append(_FINDER_COLUMN_P_N_NAME_1);
3317 }
3318 else {
3319 if (name.equals(StringPool.BLANK)) {
3320 query.append(_FINDER_COLUMN_P_N_NAME_3);
3321 }
3322 else {
3323 query.append(_FINDER_COLUMN_P_N_NAME_2);
3324 }
3325 }
3326
3327 String sql = query.toString();
3328
3329 Query q = session.createQuery(sql);
3330
3331 QueryPos qPos = QueryPos.getInstance(q);
3332
3333 qPos.add(parentCategoryId);
3334
3335 if (name != null) {
3336 qPos.add(name);
3337 }
3338
3339 count = (Long)q.uniqueResult();
3340 }
3341 catch (Exception e) {
3342 throw processException(e);
3343 }
3344 finally {
3345 if (count == null) {
3346 count = Long.valueOf(0);
3347 }
3348
3349 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_P_N, finderArgs,
3350 count);
3351
3352 closeSession(session);
3353 }
3354 }
3355
3356 return count.intValue();
3357 }
3358
3359 public int countByP_V(long parentCategoryId, long vocabularyId)
3360 throws SystemException {
3361 Object[] finderArgs = new Object[] { parentCategoryId, vocabularyId };
3362
3363 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_P_V,
3364 finderArgs, this);
3365
3366 if (count == null) {
3367 Session session = null;
3368
3369 try {
3370 session = openSession();
3371
3372 StringBundler query = new StringBundler(3);
3373
3374 query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
3375
3376 query.append(_FINDER_COLUMN_P_V_PARENTCATEGORYID_2);
3377
3378 query.append(_FINDER_COLUMN_P_V_VOCABULARYID_2);
3379
3380 String sql = query.toString();
3381
3382 Query q = session.createQuery(sql);
3383
3384 QueryPos qPos = QueryPos.getInstance(q);
3385
3386 qPos.add(parentCategoryId);
3387
3388 qPos.add(vocabularyId);
3389
3390 count = (Long)q.uniqueResult();
3391 }
3392 catch (Exception e) {
3393 throw processException(e);
3394 }
3395 finally {
3396 if (count == null) {
3397 count = Long.valueOf(0);
3398 }
3399
3400 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_P_V, finderArgs,
3401 count);
3402
3403 closeSession(session);
3404 }
3405 }
3406
3407 return count.intValue();
3408 }
3409
3410 public int countByN_V(String name, long vocabularyId)
3411 throws SystemException {
3412 Object[] finderArgs = new Object[] { name, vocabularyId };
3413
3414 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_N_V,
3415 finderArgs, this);
3416
3417 if (count == null) {
3418 Session session = null;
3419
3420 try {
3421 session = openSession();
3422
3423 StringBundler query = new StringBundler(3);
3424
3425 query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
3426
3427 if (name == null) {
3428 query.append(_FINDER_COLUMN_N_V_NAME_1);
3429 }
3430 else {
3431 if (name.equals(StringPool.BLANK)) {
3432 query.append(_FINDER_COLUMN_N_V_NAME_3);
3433 }
3434 else {
3435 query.append(_FINDER_COLUMN_N_V_NAME_2);
3436 }
3437 }
3438
3439 query.append(_FINDER_COLUMN_N_V_VOCABULARYID_2);
3440
3441 String sql = query.toString();
3442
3443 Query q = session.createQuery(sql);
3444
3445 QueryPos qPos = QueryPos.getInstance(q);
3446
3447 if (name != null) {
3448 qPos.add(name);
3449 }
3450
3451 qPos.add(vocabularyId);
3452
3453 count = (Long)q.uniqueResult();
3454 }
3455 catch (Exception e) {
3456 throw processException(e);
3457 }
3458 finally {
3459 if (count == null) {
3460 count = Long.valueOf(0);
3461 }
3462
3463 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_N_V, finderArgs,
3464 count);
3465
3466 closeSession(session);
3467 }
3468 }
3469
3470 return count.intValue();
3471 }
3472
3473 public int countByP_N_V(long parentCategoryId, String name,
3474 long vocabularyId) throws SystemException {
3475 Object[] finderArgs = new Object[] { parentCategoryId, name, vocabularyId };
3476
3477 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_P_N_V,
3478 finderArgs, this);
3479
3480 if (count == null) {
3481 Session session = null;
3482
3483 try {
3484 session = openSession();
3485
3486 StringBundler query = new StringBundler(4);
3487
3488 query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
3489
3490 query.append(_FINDER_COLUMN_P_N_V_PARENTCATEGORYID_2);
3491
3492 if (name == null) {
3493 query.append(_FINDER_COLUMN_P_N_V_NAME_1);
3494 }
3495 else {
3496 if (name.equals(StringPool.BLANK)) {
3497 query.append(_FINDER_COLUMN_P_N_V_NAME_3);
3498 }
3499 else {
3500 query.append(_FINDER_COLUMN_P_N_V_NAME_2);
3501 }
3502 }
3503
3504 query.append(_FINDER_COLUMN_P_N_V_VOCABULARYID_2);
3505
3506 String sql = query.toString();
3507
3508 Query q = session.createQuery(sql);
3509
3510 QueryPos qPos = QueryPos.getInstance(q);
3511
3512 qPos.add(parentCategoryId);
3513
3514 if (name != null) {
3515 qPos.add(name);
3516 }
3517
3518 qPos.add(vocabularyId);
3519
3520 count = (Long)q.uniqueResult();
3521 }
3522 catch (Exception e) {
3523 throw processException(e);
3524 }
3525 finally {
3526 if (count == null) {
3527 count = Long.valueOf(0);
3528 }
3529
3530 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_P_N_V,
3531 finderArgs, count);
3532
3533 closeSession(session);
3534 }
3535 }
3536
3537 return count.intValue();
3538 }
3539
3540 public int countAll() throws SystemException {
3541 Object[] finderArgs = new Object[0];
3542
3543 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
3544 finderArgs, this);
3545
3546 if (count == null) {
3547 Session session = null;
3548
3549 try {
3550 session = openSession();
3551
3552 Query q = session.createQuery(_SQL_COUNT_ASSETCATEGORY);
3553
3554 count = (Long)q.uniqueResult();
3555 }
3556 catch (Exception e) {
3557 throw processException(e);
3558 }
3559 finally {
3560 if (count == null) {
3561 count = Long.valueOf(0);
3562 }
3563
3564 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL, finderArgs,
3565 count);
3566
3567 closeSession(session);
3568 }
3569 }
3570
3571 return count.intValue();
3572 }
3573
3574 public List<com.liferay.portlet.asset.model.AssetEntry> getAssetEntries(
3575 long pk) throws SystemException {
3576 return getAssetEntries(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
3577 }
3578
3579 public List<com.liferay.portlet.asset.model.AssetEntry> getAssetEntries(
3580 long pk, int start, int end) throws SystemException {
3581 return getAssetEntries(pk, start, end, null);
3582 }
3583
3584 public static final FinderPath FINDER_PATH_GET_ASSETENTRIES = new FinderPath(com.liferay.portlet.asset.model.impl.AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
3585 AssetCategoryModelImpl.FINDER_CACHE_ENABLED_ASSETENTRIES_ASSETCATEGORIES,
3586 AssetCategoryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME,
3587 "getAssetEntries",
3588 new String[] {
3589 Long.class.getName(), "java.lang.Integer", "java.lang.Integer",
3590 "com.liferay.portal.kernel.util.OrderByComparator"
3591 });
3592
3593 public List<com.liferay.portlet.asset.model.AssetEntry> getAssetEntries(
3594 long pk, int start, int end, OrderByComparator orderByComparator)
3595 throws SystemException {
3596 Object[] finderArgs = new Object[] {
3597 pk, String.valueOf(start), String.valueOf(end),
3598 String.valueOf(orderByComparator)
3599 };
3600
3601 List<com.liferay.portlet.asset.model.AssetEntry> list = (List<com.liferay.portlet.asset.model.AssetEntry>)FinderCacheUtil.getResult(FINDER_PATH_GET_ASSETENTRIES,
3602 finderArgs, this);
3603
3604 if (list == null) {
3605 Session session = null;
3606
3607 try {
3608 session = openSession();
3609
3610 String sql = null;
3611
3612 if (orderByComparator != null) {
3613 sql = _SQL_GETASSETENTRIES.concat(ORDER_BY_CLAUSE)
3614 .concat(orderByComparator.getOrderBy());
3615 }
3616 else {
3617 sql = _SQL_GETASSETENTRIES;
3618 }
3619
3620 SQLQuery q = session.createSQLQuery(sql);
3621
3622 q.addEntity("AssetEntry",
3623 com.liferay.portlet.asset.model.impl.AssetEntryImpl.class);
3624
3625 QueryPos qPos = QueryPos.getInstance(q);
3626
3627 qPos.add(pk);
3628
3629 list = (List<com.liferay.portlet.asset.model.AssetEntry>)QueryUtil.list(q,
3630 getDialect(), start, end);
3631 }
3632 catch (Exception e) {
3633 throw processException(e);
3634 }
3635 finally {
3636 if (list == null) {
3637 list = new ArrayList<com.liferay.portlet.asset.model.AssetEntry>();
3638 }
3639
3640 assetEntryPersistence.cacheResult(list);
3641
3642 FinderCacheUtil.putResult(FINDER_PATH_GET_ASSETENTRIES,
3643 finderArgs, list);
3644
3645 closeSession(session);
3646 }
3647 }
3648
3649 return list;
3650 }
3651
3652 public static final FinderPath FINDER_PATH_GET_ASSETENTRIES_SIZE = new FinderPath(com.liferay.portlet.asset.model.impl.AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
3653 AssetCategoryModelImpl.FINDER_CACHE_ENABLED_ASSETENTRIES_ASSETCATEGORIES,
3654 AssetCategoryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME,
3655 "getAssetEntriesSize", new String[] { Long.class.getName() });
3656
3657 public int getAssetEntriesSize(long pk) throws SystemException {
3658 Object[] finderArgs = new Object[] { pk };
3659
3660 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_GET_ASSETENTRIES_SIZE,
3661 finderArgs, this);
3662
3663 if (count == null) {
3664 Session session = null;
3665
3666 try {
3667 session = openSession();
3668
3669 SQLQuery q = session.createSQLQuery(_SQL_GETASSETENTRIESSIZE);
3670
3671 q.addScalar(COUNT_COLUMN_NAME,
3672 com.liferay.portal.kernel.dao.orm.Type.LONG);
3673
3674 QueryPos qPos = QueryPos.getInstance(q);
3675
3676 qPos.add(pk);
3677
3678 count = (Long)q.uniqueResult();
3679 }
3680 catch (Exception e) {
3681 throw processException(e);
3682 }
3683 finally {
3684 if (count == null) {
3685 count = Long.valueOf(0);
3686 }
3687
3688 FinderCacheUtil.putResult(FINDER_PATH_GET_ASSETENTRIES_SIZE,
3689 finderArgs, count);
3690
3691 closeSession(session);
3692 }
3693 }
3694
3695 return count.intValue();
3696 }
3697
3698 public static final FinderPath FINDER_PATH_CONTAINS_ASSETENTRY = new FinderPath(com.liferay.portlet.asset.model.impl.AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
3699 AssetCategoryModelImpl.FINDER_CACHE_ENABLED_ASSETENTRIES_ASSETCATEGORIES,
3700 AssetCategoryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME,
3701 "containsAssetEntry",
3702 new String[] { Long.class.getName(), Long.class.getName() });
3703
3704 public boolean containsAssetEntry(long pk, long assetEntryPK)
3705 throws SystemException {
3706 Object[] finderArgs = new Object[] { pk, assetEntryPK };
3707
3708 Boolean value = (Boolean)FinderCacheUtil.getResult(FINDER_PATH_CONTAINS_ASSETENTRY,
3709 finderArgs, this);
3710
3711 if (value == null) {
3712 try {
3713 value = Boolean.valueOf(containsAssetEntry.contains(pk,
3714 assetEntryPK));
3715 }
3716 catch (Exception e) {
3717 throw processException(e);
3718 }
3719 finally {
3720 if (value == null) {
3721 value = Boolean.FALSE;
3722 }
3723
3724 FinderCacheUtil.putResult(FINDER_PATH_CONTAINS_ASSETENTRY,
3725 finderArgs, value);
3726 }
3727 }
3728
3729 return value.booleanValue();
3730 }
3731
3732 public boolean containsAssetEntries(long pk) throws SystemException {
3733 if (getAssetEntriesSize(pk) > 0) {
3734 return true;
3735 }
3736 else {
3737 return false;
3738 }
3739 }
3740
3741 public void addAssetEntry(long pk, long assetEntryPK)
3742 throws SystemException {
3743 try {
3744 addAssetEntry.add(pk, assetEntryPK);
3745 }
3746 catch (Exception e) {
3747 throw processException(e);
3748 }
3749 finally {
3750 FinderCacheUtil.clearCache(AssetCategoryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
3751 }
3752 }
3753
3754 public void addAssetEntry(long pk,
3755 com.liferay.portlet.asset.model.AssetEntry assetEntry)
3756 throws SystemException {
3757 try {
3758 addAssetEntry.add(pk, assetEntry.getPrimaryKey());
3759 }
3760 catch (Exception e) {
3761 throw processException(e);
3762 }
3763 finally {
3764 FinderCacheUtil.clearCache(AssetCategoryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
3765 }
3766 }
3767
3768 public void addAssetEntries(long pk, long[] assetEntryPKs)
3769 throws SystemException {
3770 try {
3771 for (long assetEntryPK : assetEntryPKs) {
3772 addAssetEntry.add(pk, assetEntryPK);
3773 }
3774 }
3775 catch (Exception e) {
3776 throw processException(e);
3777 }
3778 finally {
3779 FinderCacheUtil.clearCache(AssetCategoryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
3780 }
3781 }
3782
3783 public void addAssetEntries(long pk,
3784 List<com.liferay.portlet.asset.model.AssetEntry> assetEntries)
3785 throws SystemException {
3786 try {
3787 for (com.liferay.portlet.asset.model.AssetEntry assetEntry : assetEntries) {
3788 addAssetEntry.add(pk, assetEntry.getPrimaryKey());
3789 }
3790 }
3791 catch (Exception e) {
3792 throw processException(e);
3793 }
3794 finally {
3795 FinderCacheUtil.clearCache(AssetCategoryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
3796 }
3797 }
3798
3799 public void clearAssetEntries(long pk) throws SystemException {
3800 try {
3801 clearAssetEntries.clear(pk);
3802 }
3803 catch (Exception e) {
3804 throw processException(e);
3805 }
3806 finally {
3807 FinderCacheUtil.clearCache(AssetCategoryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
3808 }
3809 }
3810
3811 public void removeAssetEntry(long pk, long assetEntryPK)
3812 throws SystemException {
3813 try {
3814 removeAssetEntry.remove(pk, assetEntryPK);
3815 }
3816 catch (Exception e) {
3817 throw processException(e);
3818 }
3819 finally {
3820 FinderCacheUtil.clearCache(AssetCategoryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
3821 }
3822 }
3823
3824 public void removeAssetEntry(long pk,
3825 com.liferay.portlet.asset.model.AssetEntry assetEntry)
3826 throws SystemException {
3827 try {
3828 removeAssetEntry.remove(pk, assetEntry.getPrimaryKey());
3829 }
3830 catch (Exception e) {
3831 throw processException(e);
3832 }
3833 finally {
3834 FinderCacheUtil.clearCache(AssetCategoryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
3835 }
3836 }
3837
3838 public void removeAssetEntries(long pk, long[] assetEntryPKs)
3839 throws SystemException {
3840 try {
3841 for (long assetEntryPK : assetEntryPKs) {
3842 removeAssetEntry.remove(pk, assetEntryPK);
3843 }
3844 }
3845 catch (Exception e) {
3846 throw processException(e);
3847 }
3848 finally {
3849 FinderCacheUtil.clearCache(AssetCategoryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
3850 }
3851 }
3852
3853 public void removeAssetEntries(long pk,
3854 List<com.liferay.portlet.asset.model.AssetEntry> assetEntries)
3855 throws SystemException {
3856 try {
3857 for (com.liferay.portlet.asset.model.AssetEntry assetEntry : assetEntries) {
3858 removeAssetEntry.remove(pk, assetEntry.getPrimaryKey());
3859 }
3860 }
3861 catch (Exception e) {
3862 throw processException(e);
3863 }
3864 finally {
3865 FinderCacheUtil.clearCache(AssetCategoryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
3866 }
3867 }
3868
3869 public void setAssetEntries(long pk, long[] assetEntryPKs)
3870 throws SystemException {
3871 try {
3872 Set<Long> assetEntryPKSet = SetUtil.fromArray(assetEntryPKs);
3873
3874 List<com.liferay.portlet.asset.model.AssetEntry> assetEntries = getAssetEntries(pk);
3875
3876 for (com.liferay.portlet.asset.model.AssetEntry assetEntry : assetEntries) {
3877 if (!assetEntryPKSet.contains(assetEntry.getPrimaryKey())) {
3878 removeAssetEntry.remove(pk, assetEntry.getPrimaryKey());
3879 }
3880 else {
3881 assetEntryPKSet.remove(assetEntry.getPrimaryKey());
3882 }
3883 }
3884
3885 for (Long assetEntryPK : assetEntryPKSet) {
3886 addAssetEntry.add(pk, assetEntryPK);
3887 }
3888 }
3889 catch (Exception e) {
3890 throw processException(e);
3891 }
3892 finally {
3893 FinderCacheUtil.clearCache(AssetCategoryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
3894 }
3895 }
3896
3897 public void setAssetEntries(long pk,
3898 List<com.liferay.portlet.asset.model.AssetEntry> assetEntries)
3899 throws SystemException {
3900 try {
3901 long[] assetEntryPKs = new long[assetEntries.size()];
3902
3903 for (int i = 0; i < assetEntries.size(); i++) {
3904 com.liferay.portlet.asset.model.AssetEntry assetEntry = assetEntries.get(i);
3905
3906 assetEntryPKs[i] = assetEntry.getPrimaryKey();
3907 }
3908
3909 setAssetEntries(pk, assetEntryPKs);
3910 }
3911 catch (Exception e) {
3912 throw processException(e);
3913 }
3914 finally {
3915 FinderCacheUtil.clearCache(AssetCategoryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
3916 }
3917 }
3918
3919 public void rebuildTree(long groupId, boolean force)
3920 throws SystemException {
3921 if (force || (countOrphanTreeNodes(groupId) > 0)) {
3922 rebuildTree(groupId, 0, 1);
3923
3924 CacheRegistryUtil.clear(AssetCategoryImpl.class.getName());
3925 EntityCacheUtil.clearCache(AssetCategoryImpl.class.getName());
3926 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
3927 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
3928 }
3929 }
3930
3931 protected long countOrphanTreeNodes(long groupId) throws SystemException {
3932 Session session = null;
3933
3934 try {
3935 session = openSession();
3936
3937 SQLQuery q = session.createSQLQuery(
3938 "SELECT COUNT(*) AS COUNT_VALUE FROM AssetCategory WHERE groupId = ? AND (leftCategoryId = 0 OR leftCategoryId IS NULL OR rightCategoryId = 0 OR rightCategoryId IS NULL)");
3939
3940 q.addScalar(COUNT_COLUMN_NAME,
3941 com.liferay.portal.kernel.dao.orm.Type.LONG);
3942
3943 QueryPos qPos = QueryPos.getInstance(q);
3944
3945 qPos.add(groupId);
3946
3947 return (Long)q.uniqueResult();
3948 }
3949 catch (Exception e) {
3950 throw processException(e);
3951 }
3952 finally {
3953 closeSession(session);
3954 }
3955 }
3956
3957 protected void expandTree(AssetCategory assetCategory)
3958 throws SystemException {
3959 long groupId = assetCategory.getGroupId();
3960
3961 long lastRightCategoryId = getLastRightCategoryId(groupId,
3962 assetCategory.getParentCategoryId());
3963
3964 long leftCategoryId = 2;
3965 long rightCategoryId = 3;
3966
3967 if (lastRightCategoryId > 0) {
3968 leftCategoryId = lastRightCategoryId + 1;
3969 rightCategoryId = lastRightCategoryId + 2;
3970
3971 expandTreeLeftCategoryId.expand(groupId, lastRightCategoryId);
3972 expandTreeRightCategoryId.expand(groupId, lastRightCategoryId);
3973
3974 CacheRegistryUtil.clear(AssetCategoryImpl.class.getName());
3975 EntityCacheUtil.clearCache(AssetCategoryImpl.class.getName());
3976 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
3977 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
3978 }
3979
3980 assetCategory.setLeftCategoryId(leftCategoryId);
3981 assetCategory.setRightCategoryId(rightCategoryId);
3982 }
3983
3984 protected long getLastRightCategoryId(long groupId, long parentCategoryId)
3985 throws SystemException {
3986 Session session = null;
3987
3988 try {
3989 session = openSession();
3990
3991 SQLQuery q = session.createSQLQuery(
3992 "SELECT rightCategoryId FROM AssetCategory WHERE (groupId = ?) AND (parentCategoryId = ?) ORDER BY rightCategoryId DESC");
3993
3994 q.addScalar("rightCategoryId",
3995 com.liferay.portal.kernel.dao.orm.Type.LONG);
3996
3997 QueryPos qPos = QueryPos.getInstance(q);
3998
3999 qPos.add(groupId);
4000 qPos.add(parentCategoryId);
4001
4002 List<Long> list = (List<Long>)QueryUtil.list(q, getDialect(), 0, 1);
4003
4004 if (list.isEmpty()) {
4005 if (parentCategoryId > 0) {
4006 AssetCategory parentAssetCategory = findByPrimaryKey(parentCategoryId);
4007
4008 return parentAssetCategory.getLeftCategoryId();
4009 }
4010
4011 return 0;
4012 }
4013 else {
4014 return list.get(0);
4015 }
4016 }
4017 catch (Exception e) {
4018 throw processException(e);
4019 }
4020 finally {
4021 closeSession(session);
4022 }
4023 }
4024
4025 protected long rebuildTree(long groupId, long parentCategoryId,
4026 long leftCategoryId) throws SystemException {
4027 List<Long> categoryIds = null;
4028
4029 Session session = null;
4030
4031 try {
4032 session = openSession();
4033
4034 SQLQuery q = session.createSQLQuery(
4035 "SELECT categoryId FROM AssetCategory WHERE groupId = ? AND parentCategoryId = ? ORDER BY categoryId ASC");
4036
4037 q.addScalar("categoryId",
4038 com.liferay.portal.kernel.dao.orm.Type.LONG);
4039
4040 QueryPos qPos = QueryPos.getInstance(q);
4041
4042 qPos.add(groupId);
4043 qPos.add(parentCategoryId);
4044
4045 categoryIds = q.list();
4046 }
4047 catch (Exception e) {
4048 throw processException(e);
4049 }
4050 finally {
4051 closeSession(session);
4052 }
4053
4054 long rightCategoryId = leftCategoryId + 1;
4055
4056 for (long categoryId : categoryIds) {
4057 rightCategoryId = rebuildTree(groupId, categoryId, rightCategoryId);
4058 }
4059
4060 if (parentCategoryId > 0) {
4061 updateTree.update(parentCategoryId, leftCategoryId, rightCategoryId);
4062 }
4063
4064 return rightCategoryId + 1;
4065 }
4066
4067 protected void shrinkTree(AssetCategory assetCategory) {
4068 long groupId = assetCategory.getGroupId();
4069
4070 long leftCategoryId = assetCategory.getLeftCategoryId();
4071 long rightCategoryId = assetCategory.getRightCategoryId();
4072
4073 long delta = (rightCategoryId - leftCategoryId) + 1;
4074
4075 shrinkTreeLeftCategoryId.shrink(groupId, rightCategoryId, delta);
4076 shrinkTreeRightCategoryId.shrink(groupId, rightCategoryId, delta);
4077
4078 CacheRegistryUtil.clear(AssetCategoryImpl.class.getName());
4079 EntityCacheUtil.clearCache(AssetCategoryImpl.class.getName());
4080 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
4081 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
4082 }
4083
4084 public void afterPropertiesSet() {
4085 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
4086 com.liferay.portal.util.PropsUtil.get(
4087 "value.object.listener.com.liferay.portlet.asset.model.AssetCategory")));
4088
4089 if (listenerClassNames.length > 0) {
4090 try {
4091 List<ModelListener<AssetCategory>> listenersList = new ArrayList<ModelListener<AssetCategory>>();
4092
4093 for (String listenerClassName : listenerClassNames) {
4094 listenersList.add((ModelListener<AssetCategory>)InstanceFactory.newInstance(
4095 listenerClassName));
4096 }
4097
4098 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
4099 }
4100 catch (Exception e) {
4101 _log.error(e);
4102 }
4103 }
4104
4105 containsAssetEntry = new ContainsAssetEntry(this);
4106
4107 addAssetEntry = new AddAssetEntry(this);
4108 clearAssetEntries = new ClearAssetEntries(this);
4109 removeAssetEntry = new RemoveAssetEntry(this);
4110
4111 expandTreeLeftCategoryId = new ExpandTreeLeftCategoryId();
4112 expandTreeRightCategoryId = new ExpandTreeRightCategoryId();
4113 shrinkTreeLeftCategoryId = new ShrinkTreeLeftCategoryId();
4114 shrinkTreeRightCategoryId = new ShrinkTreeRightCategoryId();
4115 updateTree = new UpdateTree();
4116 }
4117
4118 @BeanReference(type = AssetCategoryPersistence.class)
4119 protected AssetCategoryPersistence assetCategoryPersistence;
4120 @BeanReference(type = AssetCategoryPropertyPersistence.class)
4121 protected AssetCategoryPropertyPersistence assetCategoryPropertyPersistence;
4122 @BeanReference(type = AssetEntryPersistence.class)
4123 protected AssetEntryPersistence assetEntryPersistence;
4124 @BeanReference(type = AssetLinkPersistence.class)
4125 protected AssetLinkPersistence assetLinkPersistence;
4126 @BeanReference(type = AssetTagPersistence.class)
4127 protected AssetTagPersistence assetTagPersistence;
4128 @BeanReference(type = AssetTagPropertyPersistence.class)
4129 protected AssetTagPropertyPersistence assetTagPropertyPersistence;
4130 @BeanReference(type = AssetTagStatsPersistence.class)
4131 protected AssetTagStatsPersistence assetTagStatsPersistence;
4132 @BeanReference(type = AssetVocabularyPersistence.class)
4133 protected AssetVocabularyPersistence assetVocabularyPersistence;
4134 @BeanReference(type = ResourcePersistence.class)
4135 protected ResourcePersistence resourcePersistence;
4136 @BeanReference(type = UserPersistence.class)
4137 protected UserPersistence userPersistence;
4138 protected ContainsAssetEntry containsAssetEntry;
4139 protected AddAssetEntry addAssetEntry;
4140 protected ClearAssetEntries clearAssetEntries;
4141 protected RemoveAssetEntry removeAssetEntry;
4142
4143 protected class ContainsAssetEntry {
4144 protected ContainsAssetEntry(
4145 AssetCategoryPersistenceImpl persistenceImpl) {
4146 super();
4147
4148 _mappingSqlQuery = MappingSqlQueryFactoryUtil.getMappingSqlQuery(getDataSource(),
4149 _SQL_CONTAINSASSETENTRY,
4150 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT },
4151 RowMapper.COUNT);
4152 }
4153
4154 protected boolean contains(long categoryId, long entryId) {
4155 List<Integer> results = _mappingSqlQuery.execute(new Object[] {
4156 new Long(categoryId), new Long(entryId)
4157 });
4158
4159 if (results.size() > 0) {
4160 Integer count = results.get(0);
4161
4162 if (count.intValue() > 0) {
4163 return true;
4164 }
4165 }
4166
4167 return false;
4168 }
4169
4170 private MappingSqlQuery<Integer> _mappingSqlQuery;
4171 }
4172
4173 protected class AddAssetEntry {
4174 protected AddAssetEntry(AssetCategoryPersistenceImpl persistenceImpl) {
4175 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
4176 "INSERT INTO AssetEntries_AssetCategories (categoryId, entryId) VALUES (?, ?)",
4177 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
4178 _persistenceImpl = persistenceImpl;
4179 }
4180
4181 protected void add(long categoryId, long entryId)
4182 throws SystemException {
4183 if (!_persistenceImpl.containsAssetEntry.contains(categoryId,
4184 entryId)) {
4185 ModelListener<com.liferay.portlet.asset.model.AssetEntry>[] assetEntryListeners =
4186 assetEntryPersistence.getListeners();
4187
4188 for (ModelListener<AssetCategory> listener : listeners) {
4189 listener.onBeforeAddAssociation(categoryId,
4190 com.liferay.portlet.asset.model.AssetEntry.class.getName(),
4191 entryId);
4192 }
4193
4194 for (ModelListener<com.liferay.portlet.asset.model.AssetEntry> listener : assetEntryListeners) {
4195 listener.onBeforeAddAssociation(entryId,
4196 AssetCategory.class.getName(), categoryId);
4197 }
4198
4199 _sqlUpdate.update(new Object[] {
4200 new Long(categoryId), new Long(entryId)
4201 });
4202
4203 for (ModelListener<AssetCategory> listener : listeners) {
4204 listener.onAfterAddAssociation(categoryId,
4205 com.liferay.portlet.asset.model.AssetEntry.class.getName(),
4206 entryId);
4207 }
4208
4209 for (ModelListener<com.liferay.portlet.asset.model.AssetEntry> listener : assetEntryListeners) {
4210 listener.onAfterAddAssociation(entryId,
4211 AssetCategory.class.getName(), categoryId);
4212 }
4213 }
4214 }
4215
4216 private SqlUpdate _sqlUpdate;
4217 private AssetCategoryPersistenceImpl _persistenceImpl;
4218 }
4219
4220 protected class ClearAssetEntries {
4221 protected ClearAssetEntries(
4222 AssetCategoryPersistenceImpl persistenceImpl) {
4223 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
4224 "DELETE FROM AssetEntries_AssetCategories WHERE categoryId = ?",
4225 new int[] { java.sql.Types.BIGINT });
4226 }
4227
4228 protected void clear(long categoryId) throws SystemException {
4229 ModelListener<com.liferay.portlet.asset.model.AssetEntry>[] assetEntryListeners =
4230 assetEntryPersistence.getListeners();
4231
4232 List<com.liferay.portlet.asset.model.AssetEntry> assetEntries = null;
4233
4234 if ((listeners.length > 0) || (assetEntryListeners.length > 0)) {
4235 assetEntries = getAssetEntries(categoryId);
4236
4237 for (com.liferay.portlet.asset.model.AssetEntry assetEntry : assetEntries) {
4238 for (ModelListener<AssetCategory> listener : listeners) {
4239 listener.onBeforeRemoveAssociation(categoryId,
4240 com.liferay.portlet.asset.model.AssetEntry.class.getName(),
4241 assetEntry.getPrimaryKey());
4242 }
4243
4244 for (ModelListener<com.liferay.portlet.asset.model.AssetEntry> listener : assetEntryListeners) {
4245 listener.onBeforeRemoveAssociation(assetEntry.getPrimaryKey(),
4246 AssetCategory.class.getName(), categoryId);
4247 }
4248 }
4249 }
4250
4251 _sqlUpdate.update(new Object[] { new Long(categoryId) });
4252
4253 if ((listeners.length > 0) || (assetEntryListeners.length > 0)) {
4254 for (com.liferay.portlet.asset.model.AssetEntry assetEntry : assetEntries) {
4255 for (ModelListener<AssetCategory> listener : listeners) {
4256 listener.onAfterRemoveAssociation(categoryId,
4257 com.liferay.portlet.asset.model.AssetEntry.class.getName(),
4258 assetEntry.getPrimaryKey());
4259 }
4260
4261 for (ModelListener<com.liferay.portlet.asset.model.AssetEntry> listener : assetEntryListeners) {
4262 listener.onAfterRemoveAssociation(assetEntry.getPrimaryKey(),
4263 AssetCategory.class.getName(), categoryId);
4264 }
4265 }
4266 }
4267 }
4268
4269 private SqlUpdate _sqlUpdate;
4270 }
4271
4272 protected class RemoveAssetEntry {
4273 protected RemoveAssetEntry(AssetCategoryPersistenceImpl persistenceImpl) {
4274 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
4275 "DELETE FROM AssetEntries_AssetCategories WHERE categoryId = ? AND entryId = ?",
4276 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
4277 _persistenceImpl = persistenceImpl;
4278 }
4279
4280 protected void remove(long categoryId, long entryId)
4281 throws SystemException {
4282 if (_persistenceImpl.containsAssetEntry.contains(categoryId, entryId)) {
4283 ModelListener<com.liferay.portlet.asset.model.AssetEntry>[] assetEntryListeners =
4284 assetEntryPersistence.getListeners();
4285
4286 for (ModelListener<AssetCategory> listener : listeners) {
4287 listener.onBeforeRemoveAssociation(categoryId,
4288 com.liferay.portlet.asset.model.AssetEntry.class.getName(),
4289 entryId);
4290 }
4291
4292 for (ModelListener<com.liferay.portlet.asset.model.AssetEntry> listener : assetEntryListeners) {
4293 listener.onBeforeRemoveAssociation(entryId,
4294 AssetCategory.class.getName(), categoryId);
4295 }
4296
4297 _sqlUpdate.update(new Object[] {
4298 new Long(categoryId), new Long(entryId)
4299 });
4300
4301 for (ModelListener<AssetCategory> listener : listeners) {
4302 listener.onAfterRemoveAssociation(categoryId,
4303 com.liferay.portlet.asset.model.AssetEntry.class.getName(),
4304 entryId);
4305 }
4306
4307 for (ModelListener<com.liferay.portlet.asset.model.AssetEntry> listener : assetEntryListeners) {
4308 listener.onAfterRemoveAssociation(entryId,
4309 AssetCategory.class.getName(), categoryId);
4310 }
4311 }
4312 }
4313
4314 private SqlUpdate _sqlUpdate;
4315 private AssetCategoryPersistenceImpl _persistenceImpl;
4316 }
4317
4318 protected ExpandTreeLeftCategoryId expandTreeLeftCategoryId;
4319 protected ExpandTreeRightCategoryId expandTreeRightCategoryId;
4320 protected ShrinkTreeLeftCategoryId shrinkTreeLeftCategoryId;
4321 protected ShrinkTreeRightCategoryId shrinkTreeRightCategoryId;
4322 protected UpdateTree updateTree;
4323
4324 protected class ExpandTreeLeftCategoryId {
4325 protected ExpandTreeLeftCategoryId() {
4326 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
4327 "UPDATE AssetCategory SET leftCategoryId = (leftCategoryId + 2) WHERE (groupId = ?) AND (leftCategoryId > ?)",
4328 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
4329 }
4330
4331 protected void expand(long groupId, long leftCategoryId) {
4332 _sqlUpdate.update(new Object[] { groupId, leftCategoryId });
4333 }
4334
4335 private SqlUpdate _sqlUpdate;
4336 }
4337
4338 protected class ExpandTreeRightCategoryId {
4339 protected ExpandTreeRightCategoryId() {
4340 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
4341 "UPDATE AssetCategory SET rightCategoryId = (rightCategoryId + 2) WHERE (groupId = ?) AND (rightCategoryId > ?)",
4342 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
4343 }
4344
4345 protected void expand(long groupId, long rightCategoryId) {
4346 _sqlUpdate.update(new Object[] { groupId, rightCategoryId });
4347 }
4348
4349 private SqlUpdate _sqlUpdate;
4350 }
4351
4352 protected class ShrinkTreeLeftCategoryId {
4353 protected ShrinkTreeLeftCategoryId() {
4354 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
4355 "UPDATE AssetCategory SET leftCategoryId = (leftCategoryId - ?) WHERE (groupId = ?) AND (leftCategoryId > ?)",
4356 new int[] {
4357 java.sql.Types.BIGINT, java.sql.Types.BIGINT,
4358 java.sql.Types.BIGINT
4359 });
4360 }
4361
4362 protected void shrink(long groupId, long leftCategoryId, long delta) {
4363 _sqlUpdate.update(new Object[] { delta, groupId, leftCategoryId });
4364 }
4365
4366 private SqlUpdate _sqlUpdate;
4367 }
4368
4369 protected class ShrinkTreeRightCategoryId {
4370 protected ShrinkTreeRightCategoryId() {
4371 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
4372 "UPDATE AssetCategory SET rightCategoryId = (rightCategoryId - ?) WHERE (groupId = ?) AND (rightCategoryId > ?)",
4373 new int[] {
4374 java.sql.Types.BIGINT, java.sql.Types.BIGINT,
4375 java.sql.Types.BIGINT
4376 });
4377 }
4378
4379 protected void shrink(long groupId, long rightCategoryId, long delta) {
4380 _sqlUpdate.update(new Object[] { delta, groupId, rightCategoryId });
4381 }
4382
4383 private SqlUpdate _sqlUpdate;
4384 }
4385
4386 protected class UpdateTree {
4387 protected UpdateTree() {
4388 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
4389 "UPDATE AssetCategory SET leftCategoryId = ?, rightCategoryId = ? WHERE categoryId = ?",
4390 new int[] {
4391 java.sql.Types.BIGINT, java.sql.Types.BIGINT,
4392 java.sql.Types.BIGINT
4393 });
4394 }
4395
4396 protected void update(long categoryId, long leftCategoryId,
4397 long rightCategoryId) {
4398 _sqlUpdate.update(new Object[] {
4399 leftCategoryId, rightCategoryId, categoryId
4400 });
4401 }
4402
4403 private SqlUpdate _sqlUpdate;
4404 }
4405
4406 private static final String _SQL_SELECT_ASSETCATEGORY = "SELECT assetCategory FROM AssetCategory assetCategory";
4407 private static final String _SQL_SELECT_ASSETCATEGORY_WHERE = "SELECT assetCategory FROM AssetCategory assetCategory WHERE ";
4408 private static final String _SQL_COUNT_ASSETCATEGORY = "SELECT COUNT(assetCategory) FROM AssetCategory assetCategory";
4409 private static final String _SQL_COUNT_ASSETCATEGORY_WHERE = "SELECT COUNT(assetCategory) FROM AssetCategory assetCategory WHERE ";
4410 private static final String _SQL_GETASSETENTRIES = "SELECT {AssetEntry.*} FROM AssetEntry INNER JOIN AssetEntries_AssetCategories ON (AssetEntries_AssetCategories.entryId = AssetEntry.entryId) WHERE (AssetEntries_AssetCategories.categoryId = ?)";
4411 private static final String _SQL_GETASSETENTRIESSIZE = "SELECT COUNT(*) AS COUNT_VALUE FROM AssetEntries_AssetCategories WHERE categoryId = ?";
4412 private static final String _SQL_CONTAINSASSETENTRY = "SELECT COUNT(*) AS COUNT_VALUE FROM AssetEntries_AssetCategories WHERE categoryId = ? AND entryId = ?";
4413 private static final String _FINDER_COLUMN_UUID_UUID_1 = "assetCategory.uuid IS NULL";
4414 private static final String _FINDER_COLUMN_UUID_UUID_2 = "assetCategory.uuid = ?";
4415 private static final String _FINDER_COLUMN_UUID_UUID_3 = "(assetCategory.uuid IS NULL OR assetCategory.uuid = ?)";
4416 private static final String _FINDER_COLUMN_UUID_G_UUID_1 = "assetCategory.uuid IS NULL AND ";
4417 private static final String _FINDER_COLUMN_UUID_G_UUID_2 = "assetCategory.uuid = ? AND ";
4418 private static final String _FINDER_COLUMN_UUID_G_UUID_3 = "(assetCategory.uuid IS NULL OR assetCategory.uuid = ?) AND ";
4419 private static final String _FINDER_COLUMN_UUID_G_GROUPID_2 = "assetCategory.groupId = ?";
4420 private static final String _FINDER_COLUMN_GROUPID_GROUPID_2 = "assetCategory.groupId = ?";
4421 private static final String _FINDER_COLUMN_PARENTCATEGORYID_PARENTCATEGORYID_2 =
4422 "assetCategory.parentCategoryId = ?";
4423 private static final String _FINDER_COLUMN_VOCABULARYID_VOCABULARYID_2 = "assetCategory.vocabularyId = ?";
4424 private static final String _FINDER_COLUMN_P_N_PARENTCATEGORYID_2 = "assetCategory.parentCategoryId = ? AND ";
4425 private static final String _FINDER_COLUMN_P_N_NAME_1 = "assetCategory.name IS NULL";
4426 private static final String _FINDER_COLUMN_P_N_NAME_2 = "assetCategory.name = ?";
4427 private static final String _FINDER_COLUMN_P_N_NAME_3 = "(assetCategory.name IS NULL OR assetCategory.name = ?)";
4428 private static final String _FINDER_COLUMN_P_V_PARENTCATEGORYID_2 = "assetCategory.parentCategoryId = ? AND ";
4429 private static final String _FINDER_COLUMN_P_V_VOCABULARYID_2 = "assetCategory.vocabularyId = ?";
4430 private static final String _FINDER_COLUMN_N_V_NAME_1 = "assetCategory.name IS NULL AND ";
4431 private static final String _FINDER_COLUMN_N_V_NAME_2 = "assetCategory.name = ? AND ";
4432 private static final String _FINDER_COLUMN_N_V_NAME_3 = "(assetCategory.name IS NULL OR assetCategory.name = ?) AND ";
4433 private static final String _FINDER_COLUMN_N_V_VOCABULARYID_2 = "assetCategory.vocabularyId = ?";
4434 private static final String _FINDER_COLUMN_P_N_V_PARENTCATEGORYID_2 = "assetCategory.parentCategoryId = ? AND ";
4435 private static final String _FINDER_COLUMN_P_N_V_NAME_1 = "assetCategory.name IS NULL AND ";
4436 private static final String _FINDER_COLUMN_P_N_V_NAME_2 = "assetCategory.name = ? AND ";
4437 private static final String _FINDER_COLUMN_P_N_V_NAME_3 = "(assetCategory.name IS NULL OR assetCategory.name = ?) AND ";
4438 private static final String _FINDER_COLUMN_P_N_V_VOCABULARYID_2 = "assetCategory.vocabularyId = ?";
4439 private static final String _FILTER_SQL_SELECT_ASSETCATEGORY_WHERE = "SELECT DISTINCT {assetCategory.*} FROM AssetCategory assetCategory WHERE ";
4440 private static final String _FILTER_SQL_COUNT_ASSETCATEGORY_WHERE = "SELECT COUNT(DISTINCT assetCategory.categoryId) AS COUNT_VALUE FROM AssetCategory assetCategory WHERE ";
4441 private static final String _FILTER_COLUMN_PK = "assetCategory.categoryId";
4442 private static final String _FILTER_COLUMN_USERID = "assetCategory.userId";
4443 private static final String _FILTER_ENTITY_ALIAS = "assetCategory";
4444 private static final String _ORDER_BY_ENTITY_ALIAS = "assetCategory.";
4445 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No AssetCategory exists with the primary key ";
4446 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No AssetCategory exists with the key {";
4447 private static Log _log = LogFactoryUtil.getLog(AssetCategoryPersistenceImpl.class);
4448 }