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