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