001
014
015 package com.liferay.portlet.asset.service.persistence;
016
017 import com.liferay.portal.NoSuchModelException;
018 import com.liferay.portal.kernel.bean.BeanReference;
019 import com.liferay.portal.kernel.cache.CacheRegistryUtil;
020 import com.liferay.portal.kernel.dao.jdbc.MappingSqlQuery;
021 import com.liferay.portal.kernel.dao.jdbc.MappingSqlQueryFactoryUtil;
022 import com.liferay.portal.kernel.dao.jdbc.RowMapper;
023 import com.liferay.portal.kernel.dao.jdbc.SqlUpdate;
024 import com.liferay.portal.kernel.dao.jdbc.SqlUpdateFactoryUtil;
025 import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
026 import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
027 import com.liferay.portal.kernel.dao.orm.FinderPath;
028 import com.liferay.portal.kernel.dao.orm.Query;
029 import com.liferay.portal.kernel.dao.orm.QueryPos;
030 import com.liferay.portal.kernel.dao.orm.QueryUtil;
031 import com.liferay.portal.kernel.dao.orm.SQLQuery;
032 import com.liferay.portal.kernel.dao.orm.Session;
033 import com.liferay.portal.kernel.exception.SystemException;
034 import com.liferay.portal.kernel.log.Log;
035 import com.liferay.portal.kernel.log.LogFactoryUtil;
036 import com.liferay.portal.kernel.util.GetterUtil;
037 import com.liferay.portal.kernel.util.InstanceFactory;
038 import com.liferay.portal.kernel.util.OrderByComparator;
039 import com.liferay.portal.kernel.util.SetUtil;
040 import com.liferay.portal.kernel.util.StringBundler;
041 import com.liferay.portal.kernel.util.StringPool;
042 import com.liferay.portal.kernel.util.StringUtil;
043 import com.liferay.portal.kernel.util.Validator;
044 import com.liferay.portal.kernel.uuid.PortalUUIDUtil;
045 import com.liferay.portal.model.CacheModel;
046 import com.liferay.portal.model.ModelListener;
047 import com.liferay.portal.security.permission.InlineSQLHelperUtil;
048 import com.liferay.portal.service.persistence.BatchSessionUtil;
049 import com.liferay.portal.service.persistence.ResourcePersistence;
050 import com.liferay.portal.service.persistence.UserPersistence;
051 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
052
053 import com.liferay.portlet.asset.NoSuchCategoryException;
054 import com.liferay.portlet.asset.model.AssetCategory;
055 import com.liferay.portlet.asset.model.impl.AssetCategoryImpl;
056 import com.liferay.portlet.asset.model.impl.AssetCategoryModelImpl;
057
058 import java.io.Serializable;
059
060 import java.util.ArrayList;
061 import java.util.Collections;
062 import java.util.List;
063 import java.util.Set;
064
065
077 public class AssetCategoryPersistenceImpl extends BasePersistenceImpl<AssetCategory>
078 implements AssetCategoryPersistence {
079
084 public static final String FINDER_CLASS_NAME_ENTITY = AssetCategoryImpl.class.getName();
085 public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
086 ".List1";
087 public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
088 ".List2";
089 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
090 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
091 AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
092 "findByUuid",
093 new String[] {
094 String.class.getName(),
095
096 "java.lang.Integer", "java.lang.Integer",
097 "com.liferay.portal.kernel.util.OrderByComparator"
098 });
099 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
100 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
101 AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
102 "findByUuid", new String[] { String.class.getName() },
103 AssetCategoryModelImpl.UUID_COLUMN_BITMASK);
104 public static final FinderPath FINDER_PATH_COUNT_BY_UUID = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
105 AssetCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class,
106 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid",
107 new String[] { String.class.getName() });
108 public static final FinderPath FINDER_PATH_FETCH_BY_UUID_G = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
109 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
110 AssetCategoryImpl.class, FINDER_CLASS_NAME_ENTITY, "fetchByUUID_G",
111 new String[] { String.class.getName(), Long.class.getName() },
112 AssetCategoryModelImpl.UUID_COLUMN_BITMASK |
113 AssetCategoryModelImpl.GROUPID_COLUMN_BITMASK);
114 public static final FinderPath FINDER_PATH_COUNT_BY_UUID_G = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
115 AssetCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class,
116 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUUID_G",
117 new String[] { String.class.getName(), Long.class.getName() });
118 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
119 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
120 AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
121 "findByGroupId",
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_WITHOUT_PAGINATION_FIND_BY_GROUPID =
129 new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
130 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
131 AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
132 "findByGroupId", new String[] { Long.class.getName() },
133 AssetCategoryModelImpl.GROUPID_COLUMN_BITMASK);
134 public static final FinderPath FINDER_PATH_COUNT_BY_GROUPID = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
135 AssetCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class,
136 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByGroupId",
137 new String[] { Long.class.getName() });
138 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_PARENTCATEGORYID =
139 new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
140 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
141 AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
142 "findByParentCategoryId",
143 new String[] {
144 Long.class.getName(),
145
146 "java.lang.Integer", "java.lang.Integer",
147 "com.liferay.portal.kernel.util.OrderByComparator"
148 });
149 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_PARENTCATEGORYID =
150 new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
151 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
152 AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
153 "findByParentCategoryId", new String[] { Long.class.getName() },
154 AssetCategoryModelImpl.PARENTCATEGORYID_COLUMN_BITMASK);
155 public static final FinderPath FINDER_PATH_COUNT_BY_PARENTCATEGORYID = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
156 AssetCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class,
157 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
158 "countByParentCategoryId", new String[] { Long.class.getName() });
159 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_VOCABULARYID =
160 new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
161 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
162 AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
163 "findByVocabularyId",
164 new String[] {
165 Long.class.getName(),
166
167 "java.lang.Integer", "java.lang.Integer",
168 "com.liferay.portal.kernel.util.OrderByComparator"
169 });
170 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_VOCABULARYID =
171 new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
172 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
173 AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
174 "findByVocabularyId", new String[] { Long.class.getName() },
175 AssetCategoryModelImpl.VOCABULARYID_COLUMN_BITMASK);
176 public static final FinderPath FINDER_PATH_COUNT_BY_VOCABULARYID = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
177 AssetCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class,
178 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByVocabularyId",
179 new String[] { Long.class.getName() });
180 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
181 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
182 AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
183 "findByG_V",
184 new String[] {
185 Long.class.getName(), Long.class.getName(),
186
187 "java.lang.Integer", "java.lang.Integer",
188 "com.liferay.portal.kernel.util.OrderByComparator"
189 });
190 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
191 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
192 AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
193 "findByG_V",
194 new String[] { Long.class.getName(), Long.class.getName() },
195 AssetCategoryModelImpl.GROUPID_COLUMN_BITMASK |
196 AssetCategoryModelImpl.VOCABULARYID_COLUMN_BITMASK);
197 public static final FinderPath FINDER_PATH_COUNT_BY_G_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
198 AssetCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class,
199 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_V",
200 new String[] { Long.class.getName(), Long.class.getName() });
201 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_P_N = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
202 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
203 AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
204 "findByP_N",
205 new String[] {
206 Long.class.getName(), String.class.getName(),
207
208 "java.lang.Integer", "java.lang.Integer",
209 "com.liferay.portal.kernel.util.OrderByComparator"
210 });
211 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_P_N = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
212 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
213 AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
214 "findByP_N",
215 new String[] { Long.class.getName(), String.class.getName() },
216 AssetCategoryModelImpl.PARENTCATEGORYID_COLUMN_BITMASK |
217 AssetCategoryModelImpl.NAME_COLUMN_BITMASK);
218 public static final FinderPath FINDER_PATH_COUNT_BY_P_N = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
219 AssetCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class,
220 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByP_N",
221 new String[] { Long.class.getName(), String.class.getName() });
222 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_P_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
223 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
224 AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
225 "findByP_V",
226 new String[] {
227 Long.class.getName(), Long.class.getName(),
228
229 "java.lang.Integer", "java.lang.Integer",
230 "com.liferay.portal.kernel.util.OrderByComparator"
231 });
232 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_P_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
233 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
234 AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
235 "findByP_V",
236 new String[] { Long.class.getName(), Long.class.getName() },
237 AssetCategoryModelImpl.PARENTCATEGORYID_COLUMN_BITMASK |
238 AssetCategoryModelImpl.VOCABULARYID_COLUMN_BITMASK);
239 public static final FinderPath FINDER_PATH_COUNT_BY_P_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
240 AssetCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class,
241 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByP_V",
242 new String[] { Long.class.getName(), Long.class.getName() });
243 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_N_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
244 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
245 AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
246 "findByN_V",
247 new String[] {
248 String.class.getName(), Long.class.getName(),
249
250 "java.lang.Integer", "java.lang.Integer",
251 "com.liferay.portal.kernel.util.OrderByComparator"
252 });
253 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
254 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
255 AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
256 "findByN_V",
257 new String[] { String.class.getName(), Long.class.getName() },
258 AssetCategoryModelImpl.NAME_COLUMN_BITMASK |
259 AssetCategoryModelImpl.VOCABULARYID_COLUMN_BITMASK);
260 public static final FinderPath FINDER_PATH_COUNT_BY_N_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
261 AssetCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class,
262 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByN_V",
263 new String[] { String.class.getName(), Long.class.getName() });
264 public static final FinderPath FINDER_PATH_FETCH_BY_P_N_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
265 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
266 AssetCategoryImpl.class, FINDER_CLASS_NAME_ENTITY, "fetchByP_N_V",
267 new String[] {
268 Long.class.getName(), String.class.getName(),
269 Long.class.getName()
270 },
271 AssetCategoryModelImpl.PARENTCATEGORYID_COLUMN_BITMASK |
272 AssetCategoryModelImpl.NAME_COLUMN_BITMASK |
273 AssetCategoryModelImpl.VOCABULARYID_COLUMN_BITMASK);
274 public static final FinderPath FINDER_PATH_COUNT_BY_P_N_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
275 AssetCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class,
276 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByP_N_V",
277 new String[] {
278 Long.class.getName(), String.class.getName(),
279 Long.class.getName()
280 });
281 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
282 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
283 AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
284 "findAll", new String[0]);
285 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
286 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
287 AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
288 "findAll", new String[0]);
289 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
290 AssetCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class,
291 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
292
293
298 public void cacheResult(AssetCategory assetCategory) {
299 EntityCacheUtil.putResult(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
300 AssetCategoryImpl.class, assetCategory.getPrimaryKey(),
301 assetCategory);
302
303 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
304 new Object[] {
305 assetCategory.getUuid(),
306 Long.valueOf(assetCategory.getGroupId())
307 }, assetCategory);
308
309 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_P_N_V,
310 new Object[] {
311 Long.valueOf(assetCategory.getParentCategoryId()),
312
313 assetCategory.getName(),
314 Long.valueOf(assetCategory.getVocabularyId())
315 }, assetCategory);
316
317 assetCategory.resetOriginalValues();
318 }
319
320
325 public void cacheResult(List<AssetCategory> assetCategories) {
326 for (AssetCategory assetCategory : assetCategories) {
327 if (EntityCacheUtil.getResult(
328 AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
329 AssetCategoryImpl.class, assetCategory.getPrimaryKey()) == null) {
330 cacheResult(assetCategory);
331 }
332 else {
333 assetCategory.resetOriginalValues();
334 }
335 }
336 }
337
338
345 @Override
346 public void clearCache() {
347 if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
348 CacheRegistryUtil.clear(AssetCategoryImpl.class.getName());
349 }
350
351 EntityCacheUtil.clearCache(AssetCategoryImpl.class.getName());
352
353 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
354 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
355 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
356 }
357
358
365 @Override
366 public void clearCache(AssetCategory assetCategory) {
367 EntityCacheUtil.removeResult(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
368 AssetCategoryImpl.class, assetCategory.getPrimaryKey());
369
370 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
371 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
372
373 clearUniqueFindersCache(assetCategory);
374 }
375
376 @Override
377 public void clearCache(List<AssetCategory> assetCategories) {
378 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
379 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
380
381 for (AssetCategory assetCategory : assetCategories) {
382 EntityCacheUtil.removeResult(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
383 AssetCategoryImpl.class, assetCategory.getPrimaryKey());
384
385 clearUniqueFindersCache(assetCategory);
386 }
387 }
388
389 protected void clearUniqueFindersCache(AssetCategory assetCategory) {
390 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
391 new Object[] {
392 assetCategory.getUuid(),
393 Long.valueOf(assetCategory.getGroupId())
394 });
395
396 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_P_N_V,
397 new Object[] {
398 Long.valueOf(assetCategory.getParentCategoryId()),
399
400 assetCategory.getName(),
401 Long.valueOf(assetCategory.getVocabularyId())
402 });
403 }
404
405
411 public AssetCategory create(long categoryId) {
412 AssetCategory assetCategory = new AssetCategoryImpl();
413
414 assetCategory.setNew(true);
415 assetCategory.setPrimaryKey(categoryId);
416
417 String uuid = PortalUUIDUtil.generate();
418
419 assetCategory.setUuid(uuid);
420
421 return assetCategory;
422 }
423
424
432 public AssetCategory remove(long categoryId)
433 throws NoSuchCategoryException, SystemException {
434 return remove(Long.valueOf(categoryId));
435 }
436
437
445 @Override
446 public AssetCategory remove(Serializable primaryKey)
447 throws NoSuchCategoryException, SystemException {
448 Session session = null;
449
450 try {
451 session = openSession();
452
453 AssetCategory assetCategory = (AssetCategory)session.get(AssetCategoryImpl.class,
454 primaryKey);
455
456 if (assetCategory == null) {
457 if (_log.isWarnEnabled()) {
458 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
459 }
460
461 throw new NoSuchCategoryException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
462 primaryKey);
463 }
464
465 return remove(assetCategory);
466 }
467 catch (NoSuchCategoryException nsee) {
468 throw nsee;
469 }
470 catch (Exception e) {
471 throw processException(e);
472 }
473 finally {
474 closeSession(session);
475 }
476 }
477
478 @Override
479 protected AssetCategory removeImpl(AssetCategory assetCategory)
480 throws SystemException {
481 assetCategory = toUnwrappedModel(assetCategory);
482
483 try {
484 clearAssetEntries.clear(assetCategory.getPrimaryKey());
485 }
486 catch (Exception e) {
487 throw processException(e);
488 }
489 finally {
490 FinderCacheUtil.clearCache(AssetCategoryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
491 }
492
493 shrinkTree(assetCategory);
494
495 Session session = null;
496
497 try {
498 session = openSession();
499
500 BatchSessionUtil.delete(session, assetCategory);
501 }
502 catch (Exception e) {
503 throw processException(e);
504 }
505 finally {
506 closeSession(session);
507 }
508
509 clearCache(assetCategory);
510
511 return assetCategory;
512 }
513
514 @Override
515 public AssetCategory updateImpl(
516 com.liferay.portlet.asset.model.AssetCategory assetCategory,
517 boolean merge) throws SystemException {
518 assetCategory = toUnwrappedModel(assetCategory);
519
520 boolean isNew = assetCategory.isNew();
521
522 AssetCategoryModelImpl assetCategoryModelImpl = (AssetCategoryModelImpl)assetCategory;
523
524 if (Validator.isNull(assetCategory.getUuid())) {
525 String uuid = PortalUUIDUtil.generate();
526
527 assetCategory.setUuid(uuid);
528 }
529
530 if (isNew) {
531 expandTree(assetCategory, null);
532 }
533 else {
534 if (assetCategory.getParentCategoryId() != assetCategoryModelImpl.getOriginalParentCategoryId()) {
535 List<Long> childrenCategoryIds = getChildrenTreeCategoryIds(assetCategory);
536
537 shrinkTree(assetCategory);
538 expandTree(assetCategory, childrenCategoryIds);
539 }
540 }
541
542 Session session = null;
543
544 try {
545 session = openSession();
546
547 BatchSessionUtil.update(session, assetCategory, merge);
548
549 assetCategory.setNew(false);
550 }
551 catch (Exception e) {
552 throw processException(e);
553 }
554 finally {
555 closeSession(session);
556 }
557
558 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
559
560 if (isNew || !AssetCategoryModelImpl.COLUMN_BITMASK_ENABLED) {
561 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
562 }
563
564 else {
565 if ((assetCategoryModelImpl.getColumnBitmask() &
566 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID.getColumnBitmask()) != 0) {
567 Object[] args = new Object[] {
568 assetCategoryModelImpl.getOriginalUuid()
569 };
570
571 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
572 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
573 args);
574
575 args = new Object[] { assetCategoryModelImpl.getUuid() };
576
577 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
578 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
579 args);
580 }
581
582 if ((assetCategoryModelImpl.getColumnBitmask() &
583 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID.getColumnBitmask()) != 0) {
584 Object[] args = new Object[] {
585 Long.valueOf(assetCategoryModelImpl.getOriginalGroupId())
586 };
587
588 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
589 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
590 args);
591
592 args = new Object[] {
593 Long.valueOf(assetCategoryModelImpl.getGroupId())
594 };
595
596 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
597 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
598 args);
599 }
600
601 if ((assetCategoryModelImpl.getColumnBitmask() &
602 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_PARENTCATEGORYID.getColumnBitmask()) != 0) {
603 Object[] args = new Object[] {
604 Long.valueOf(assetCategoryModelImpl.getOriginalParentCategoryId())
605 };
606
607 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_PARENTCATEGORYID,
608 args);
609 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_PARENTCATEGORYID,
610 args);
611
612 args = new Object[] {
613 Long.valueOf(assetCategoryModelImpl.getParentCategoryId())
614 };
615
616 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_PARENTCATEGORYID,
617 args);
618 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_PARENTCATEGORYID,
619 args);
620 }
621
622 if ((assetCategoryModelImpl.getColumnBitmask() &
623 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_VOCABULARYID.getColumnBitmask()) != 0) {
624 Object[] args = new Object[] {
625 Long.valueOf(assetCategoryModelImpl.getOriginalVocabularyId())
626 };
627
628 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_VOCABULARYID,
629 args);
630 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_VOCABULARYID,
631 args);
632
633 args = new Object[] {
634 Long.valueOf(assetCategoryModelImpl.getVocabularyId())
635 };
636
637 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_VOCABULARYID,
638 args);
639 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_VOCABULARYID,
640 args);
641 }
642
643 if ((assetCategoryModelImpl.getColumnBitmask() &
644 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_V.getColumnBitmask()) != 0) {
645 Object[] args = new Object[] {
646 Long.valueOf(assetCategoryModelImpl.getOriginalGroupId()),
647 Long.valueOf(assetCategoryModelImpl.getOriginalVocabularyId())
648 };
649
650 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_V, args);
651 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_V,
652 args);
653
654 args = new Object[] {
655 Long.valueOf(assetCategoryModelImpl.getGroupId()),
656 Long.valueOf(assetCategoryModelImpl.getVocabularyId())
657 };
658
659 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_V, args);
660 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_V,
661 args);
662 }
663
664 if ((assetCategoryModelImpl.getColumnBitmask() &
665 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_P_N.getColumnBitmask()) != 0) {
666 Object[] args = new Object[] {
667 Long.valueOf(assetCategoryModelImpl.getOriginalParentCategoryId()),
668
669 assetCategoryModelImpl.getOriginalName()
670 };
671
672 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_P_N, args);
673 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_P_N,
674 args);
675
676 args = new Object[] {
677 Long.valueOf(assetCategoryModelImpl.getParentCategoryId()),
678
679 assetCategoryModelImpl.getName()
680 };
681
682 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_P_N, args);
683 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_P_N,
684 args);
685 }
686
687 if ((assetCategoryModelImpl.getColumnBitmask() &
688 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_P_V.getColumnBitmask()) != 0) {
689 Object[] args = new Object[] {
690 Long.valueOf(assetCategoryModelImpl.getOriginalParentCategoryId()),
691 Long.valueOf(assetCategoryModelImpl.getOriginalVocabularyId())
692 };
693
694 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_P_V, args);
695 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_P_V,
696 args);
697
698 args = new Object[] {
699 Long.valueOf(assetCategoryModelImpl.getParentCategoryId()),
700 Long.valueOf(assetCategoryModelImpl.getVocabularyId())
701 };
702
703 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_P_V, args);
704 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_P_V,
705 args);
706 }
707
708 if ((assetCategoryModelImpl.getColumnBitmask() &
709 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_V.getColumnBitmask()) != 0) {
710 Object[] args = new Object[] {
711 assetCategoryModelImpl.getOriginalName(),
712 Long.valueOf(assetCategoryModelImpl.getOriginalVocabularyId())
713 };
714
715 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_N_V, args);
716 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_V,
717 args);
718
719 args = new Object[] {
720 assetCategoryModelImpl.getName(),
721 Long.valueOf(assetCategoryModelImpl.getVocabularyId())
722 };
723
724 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_N_V, args);
725 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_V,
726 args);
727 }
728 }
729
730 EntityCacheUtil.putResult(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
731 AssetCategoryImpl.class, assetCategory.getPrimaryKey(),
732 assetCategory);
733
734 if (isNew) {
735 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
736 new Object[] {
737 assetCategory.getUuid(),
738 Long.valueOf(assetCategory.getGroupId())
739 }, assetCategory);
740
741 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_P_N_V,
742 new Object[] {
743 Long.valueOf(assetCategory.getParentCategoryId()),
744
745 assetCategory.getName(),
746 Long.valueOf(assetCategory.getVocabularyId())
747 }, assetCategory);
748 }
749 else {
750 if ((assetCategoryModelImpl.getColumnBitmask() &
751 FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) {
752 Object[] args = new Object[] {
753 assetCategoryModelImpl.getOriginalUuid(),
754 Long.valueOf(assetCategoryModelImpl.getOriginalGroupId())
755 };
756
757 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args);
758 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args);
759
760 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
761 new Object[] {
762 assetCategory.getUuid(),
763 Long.valueOf(assetCategory.getGroupId())
764 }, assetCategory);
765 }
766
767 if ((assetCategoryModelImpl.getColumnBitmask() &
768 FINDER_PATH_FETCH_BY_P_N_V.getColumnBitmask()) != 0) {
769 Object[] args = new Object[] {
770 Long.valueOf(assetCategoryModelImpl.getOriginalParentCategoryId()),
771
772 assetCategoryModelImpl.getOriginalName(),
773 Long.valueOf(assetCategoryModelImpl.getOriginalVocabularyId())
774 };
775
776 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_P_N_V, args);
777 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_P_N_V, args);
778
779 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_P_N_V,
780 new Object[] {
781 Long.valueOf(assetCategory.getParentCategoryId()),
782
783 assetCategory.getName(),
784 Long.valueOf(assetCategory.getVocabularyId())
785 }, assetCategory);
786 }
787 }
788
789 return assetCategory;
790 }
791
792 protected AssetCategory toUnwrappedModel(AssetCategory assetCategory) {
793 if (assetCategory instanceof AssetCategoryImpl) {
794 return assetCategory;
795 }
796
797 AssetCategoryImpl assetCategoryImpl = new AssetCategoryImpl();
798
799 assetCategoryImpl.setNew(assetCategory.isNew());
800 assetCategoryImpl.setPrimaryKey(assetCategory.getPrimaryKey());
801
802 assetCategoryImpl.setUuid(assetCategory.getUuid());
803 assetCategoryImpl.setCategoryId(assetCategory.getCategoryId());
804 assetCategoryImpl.setGroupId(assetCategory.getGroupId());
805 assetCategoryImpl.setCompanyId(assetCategory.getCompanyId());
806 assetCategoryImpl.setUserId(assetCategory.getUserId());
807 assetCategoryImpl.setUserName(assetCategory.getUserName());
808 assetCategoryImpl.setCreateDate(assetCategory.getCreateDate());
809 assetCategoryImpl.setModifiedDate(assetCategory.getModifiedDate());
810 assetCategoryImpl.setParentCategoryId(assetCategory.getParentCategoryId());
811 assetCategoryImpl.setLeftCategoryId(assetCategory.getLeftCategoryId());
812 assetCategoryImpl.setRightCategoryId(assetCategory.getRightCategoryId());
813 assetCategoryImpl.setName(assetCategory.getName());
814 assetCategoryImpl.setTitle(assetCategory.getTitle());
815 assetCategoryImpl.setDescription(assetCategory.getDescription());
816 assetCategoryImpl.setVocabularyId(assetCategory.getVocabularyId());
817
818 return assetCategoryImpl;
819 }
820
821
829 @Override
830 public AssetCategory findByPrimaryKey(Serializable primaryKey)
831 throws NoSuchModelException, SystemException {
832 return findByPrimaryKey(((Long)primaryKey).longValue());
833 }
834
835
843 public AssetCategory findByPrimaryKey(long categoryId)
844 throws NoSuchCategoryException, SystemException {
845 AssetCategory assetCategory = fetchByPrimaryKey(categoryId);
846
847 if (assetCategory == null) {
848 if (_log.isWarnEnabled()) {
849 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + categoryId);
850 }
851
852 throw new NoSuchCategoryException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
853 categoryId);
854 }
855
856 return assetCategory;
857 }
858
859
866 @Override
867 public AssetCategory fetchByPrimaryKey(Serializable primaryKey)
868 throws SystemException {
869 return fetchByPrimaryKey(((Long)primaryKey).longValue());
870 }
871
872
879 public AssetCategory fetchByPrimaryKey(long categoryId)
880 throws SystemException {
881 AssetCategory assetCategory = (AssetCategory)EntityCacheUtil.getResult(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
882 AssetCategoryImpl.class, categoryId);
883
884 if (assetCategory == _nullAssetCategory) {
885 return null;
886 }
887
888 if (assetCategory == null) {
889 Session session = null;
890
891 boolean hasException = false;
892
893 try {
894 session = openSession();
895
896 assetCategory = (AssetCategory)session.get(AssetCategoryImpl.class,
897 Long.valueOf(categoryId));
898 }
899 catch (Exception e) {
900 hasException = true;
901
902 throw processException(e);
903 }
904 finally {
905 if (assetCategory != null) {
906 cacheResult(assetCategory);
907 }
908 else if (!hasException) {
909 EntityCacheUtil.putResult(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
910 AssetCategoryImpl.class, categoryId, _nullAssetCategory);
911 }
912
913 closeSession(session);
914 }
915 }
916
917 return assetCategory;
918 }
919
920
927 public List<AssetCategory> findByUuid(String uuid)
928 throws SystemException {
929 return findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
930 }
931
932
945 public List<AssetCategory> findByUuid(String uuid, int start, int end)
946 throws SystemException {
947 return findByUuid(uuid, start, end, null);
948 }
949
950
964 public List<AssetCategory> findByUuid(String uuid, int start, int end,
965 OrderByComparator orderByComparator) throws SystemException {
966 FinderPath finderPath = null;
967 Object[] finderArgs = null;
968
969 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
970 (orderByComparator == null)) {
971 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID;
972 finderArgs = new Object[] { uuid };
973 }
974 else {
975 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID;
976 finderArgs = new Object[] { uuid, start, end, orderByComparator };
977 }
978
979 List<AssetCategory> list = (List<AssetCategory>)FinderCacheUtil.getResult(finderPath,
980 finderArgs, this);
981
982 if (list == null) {
983 StringBundler query = null;
984
985 if (orderByComparator != null) {
986 query = new StringBundler(3 +
987 (orderByComparator.getOrderByFields().length * 3));
988 }
989 else {
990 query = new StringBundler(3);
991 }
992
993 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
994
995 if (uuid == null) {
996 query.append(_FINDER_COLUMN_UUID_UUID_1);
997 }
998 else {
999 if (uuid.equals(StringPool.BLANK)) {
1000 query.append(_FINDER_COLUMN_UUID_UUID_3);
1001 }
1002 else {
1003 query.append(_FINDER_COLUMN_UUID_UUID_2);
1004 }
1005 }
1006
1007 if (orderByComparator != null) {
1008 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1009 orderByComparator);
1010 }
1011
1012 else {
1013 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
1014 }
1015
1016 String sql = query.toString();
1017
1018 Session session = null;
1019
1020 try {
1021 session = openSession();
1022
1023 Query q = session.createQuery(sql);
1024
1025 QueryPos qPos = QueryPos.getInstance(q);
1026
1027 if (uuid != null) {
1028 qPos.add(uuid);
1029 }
1030
1031 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
1032 start, end);
1033 }
1034 catch (Exception e) {
1035 throw processException(e);
1036 }
1037 finally {
1038 if (list == null) {
1039 FinderCacheUtil.removeResult(finderPath, finderArgs);
1040 }
1041 else {
1042 cacheResult(list);
1043
1044 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1045 }
1046
1047 closeSession(session);
1048 }
1049 }
1050
1051 return list;
1052 }
1053
1054
1067 public AssetCategory findByUuid_First(String uuid,
1068 OrderByComparator orderByComparator)
1069 throws NoSuchCategoryException, SystemException {
1070 List<AssetCategory> list = findByUuid(uuid, 0, 1, orderByComparator);
1071
1072 if (list.isEmpty()) {
1073 StringBundler msg = new StringBundler(4);
1074
1075 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1076
1077 msg.append("uuid=");
1078 msg.append(uuid);
1079
1080 msg.append(StringPool.CLOSE_CURLY_BRACE);
1081
1082 throw new NoSuchCategoryException(msg.toString());
1083 }
1084 else {
1085 return list.get(0);
1086 }
1087 }
1088
1089
1102 public AssetCategory findByUuid_Last(String uuid,
1103 OrderByComparator orderByComparator)
1104 throws NoSuchCategoryException, SystemException {
1105 int count = countByUuid(uuid);
1106
1107 List<AssetCategory> list = findByUuid(uuid, count - 1, count,
1108 orderByComparator);
1109
1110 if (list.isEmpty()) {
1111 StringBundler msg = new StringBundler(4);
1112
1113 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1114
1115 msg.append("uuid=");
1116 msg.append(uuid);
1117
1118 msg.append(StringPool.CLOSE_CURLY_BRACE);
1119
1120 throw new NoSuchCategoryException(msg.toString());
1121 }
1122 else {
1123 return list.get(0);
1124 }
1125 }
1126
1127
1141 public AssetCategory[] findByUuid_PrevAndNext(long categoryId, String uuid,
1142 OrderByComparator orderByComparator)
1143 throws NoSuchCategoryException, SystemException {
1144 AssetCategory assetCategory = findByPrimaryKey(categoryId);
1145
1146 Session session = null;
1147
1148 try {
1149 session = openSession();
1150
1151 AssetCategory[] array = new AssetCategoryImpl[3];
1152
1153 array[0] = getByUuid_PrevAndNext(session, assetCategory, uuid,
1154 orderByComparator, true);
1155
1156 array[1] = assetCategory;
1157
1158 array[2] = getByUuid_PrevAndNext(session, assetCategory, uuid,
1159 orderByComparator, false);
1160
1161 return array;
1162 }
1163 catch (Exception e) {
1164 throw processException(e);
1165 }
1166 finally {
1167 closeSession(session);
1168 }
1169 }
1170
1171 protected AssetCategory getByUuid_PrevAndNext(Session session,
1172 AssetCategory assetCategory, String uuid,
1173 OrderByComparator orderByComparator, boolean previous) {
1174 StringBundler query = null;
1175
1176 if (orderByComparator != null) {
1177 query = new StringBundler(6 +
1178 (orderByComparator.getOrderByFields().length * 6));
1179 }
1180 else {
1181 query = new StringBundler(3);
1182 }
1183
1184 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
1185
1186 if (uuid == null) {
1187 query.append(_FINDER_COLUMN_UUID_UUID_1);
1188 }
1189 else {
1190 if (uuid.equals(StringPool.BLANK)) {
1191 query.append(_FINDER_COLUMN_UUID_UUID_3);
1192 }
1193 else {
1194 query.append(_FINDER_COLUMN_UUID_UUID_2);
1195 }
1196 }
1197
1198 if (orderByComparator != null) {
1199 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1200
1201 if (orderByConditionFields.length > 0) {
1202 query.append(WHERE_AND);
1203 }
1204
1205 for (int i = 0; i < orderByConditionFields.length; i++) {
1206 query.append(_ORDER_BY_ENTITY_ALIAS);
1207 query.append(orderByConditionFields[i]);
1208
1209 if ((i + 1) < orderByConditionFields.length) {
1210 if (orderByComparator.isAscending() ^ previous) {
1211 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1212 }
1213 else {
1214 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1215 }
1216 }
1217 else {
1218 if (orderByComparator.isAscending() ^ previous) {
1219 query.append(WHERE_GREATER_THAN);
1220 }
1221 else {
1222 query.append(WHERE_LESSER_THAN);
1223 }
1224 }
1225 }
1226
1227 query.append(ORDER_BY_CLAUSE);
1228
1229 String[] orderByFields = orderByComparator.getOrderByFields();
1230
1231 for (int i = 0; i < orderByFields.length; i++) {
1232 query.append(_ORDER_BY_ENTITY_ALIAS);
1233 query.append(orderByFields[i]);
1234
1235 if ((i + 1) < orderByFields.length) {
1236 if (orderByComparator.isAscending() ^ previous) {
1237 query.append(ORDER_BY_ASC_HAS_NEXT);
1238 }
1239 else {
1240 query.append(ORDER_BY_DESC_HAS_NEXT);
1241 }
1242 }
1243 else {
1244 if (orderByComparator.isAscending() ^ previous) {
1245 query.append(ORDER_BY_ASC);
1246 }
1247 else {
1248 query.append(ORDER_BY_DESC);
1249 }
1250 }
1251 }
1252 }
1253
1254 else {
1255 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
1256 }
1257
1258 String sql = query.toString();
1259
1260 Query q = session.createQuery(sql);
1261
1262 q.setFirstResult(0);
1263 q.setMaxResults(2);
1264
1265 QueryPos qPos = QueryPos.getInstance(q);
1266
1267 if (uuid != null) {
1268 qPos.add(uuid);
1269 }
1270
1271 if (orderByComparator != null) {
1272 Object[] values = orderByComparator.getOrderByConditionValues(assetCategory);
1273
1274 for (Object value : values) {
1275 qPos.add(value);
1276 }
1277 }
1278
1279 List<AssetCategory> list = q.list();
1280
1281 if (list.size() == 2) {
1282 return list.get(1);
1283 }
1284 else {
1285 return null;
1286 }
1287 }
1288
1289
1298 public AssetCategory findByUUID_G(String uuid, long groupId)
1299 throws NoSuchCategoryException, SystemException {
1300 AssetCategory assetCategory = fetchByUUID_G(uuid, groupId);
1301
1302 if (assetCategory == null) {
1303 StringBundler msg = new StringBundler(6);
1304
1305 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1306
1307 msg.append("uuid=");
1308 msg.append(uuid);
1309
1310 msg.append(", groupId=");
1311 msg.append(groupId);
1312
1313 msg.append(StringPool.CLOSE_CURLY_BRACE);
1314
1315 if (_log.isWarnEnabled()) {
1316 _log.warn(msg.toString());
1317 }
1318
1319 throw new NoSuchCategoryException(msg.toString());
1320 }
1321
1322 return assetCategory;
1323 }
1324
1325
1333 public AssetCategory fetchByUUID_G(String uuid, long groupId)
1334 throws SystemException {
1335 return fetchByUUID_G(uuid, groupId, true);
1336 }
1337
1338
1347 public AssetCategory fetchByUUID_G(String uuid, long groupId,
1348 boolean retrieveFromCache) throws SystemException {
1349 Object[] finderArgs = new Object[] { uuid, groupId };
1350
1351 Object result = null;
1352
1353 if (retrieveFromCache) {
1354 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_UUID_G,
1355 finderArgs, this);
1356 }
1357
1358 if (result == null) {
1359 StringBundler query = new StringBundler(4);
1360
1361 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
1362
1363 if (uuid == null) {
1364 query.append(_FINDER_COLUMN_UUID_G_UUID_1);
1365 }
1366 else {
1367 if (uuid.equals(StringPool.BLANK)) {
1368 query.append(_FINDER_COLUMN_UUID_G_UUID_3);
1369 }
1370 else {
1371 query.append(_FINDER_COLUMN_UUID_G_UUID_2);
1372 }
1373 }
1374
1375 query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
1376
1377 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
1378
1379 String sql = query.toString();
1380
1381 Session session = null;
1382
1383 try {
1384 session = openSession();
1385
1386 Query q = session.createQuery(sql);
1387
1388 QueryPos qPos = QueryPos.getInstance(q);
1389
1390 if (uuid != null) {
1391 qPos.add(uuid);
1392 }
1393
1394 qPos.add(groupId);
1395
1396 List<AssetCategory> list = q.list();
1397
1398 result = list;
1399
1400 AssetCategory assetCategory = null;
1401
1402 if (list.isEmpty()) {
1403 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
1404 finderArgs, list);
1405 }
1406 else {
1407 assetCategory = list.get(0);
1408
1409 cacheResult(assetCategory);
1410
1411 if ((assetCategory.getUuid() == null) ||
1412 !assetCategory.getUuid().equals(uuid) ||
1413 (assetCategory.getGroupId() != groupId)) {
1414 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
1415 finderArgs, assetCategory);
1416 }
1417 }
1418
1419 return assetCategory;
1420 }
1421 catch (Exception e) {
1422 throw processException(e);
1423 }
1424 finally {
1425 if (result == null) {
1426 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
1427 finderArgs);
1428 }
1429
1430 closeSession(session);
1431 }
1432 }
1433 else {
1434 if (result instanceof List<?>) {
1435 return null;
1436 }
1437 else {
1438 return (AssetCategory)result;
1439 }
1440 }
1441 }
1442
1443
1450 public List<AssetCategory> findByGroupId(long groupId)
1451 throws SystemException {
1452 return findByGroupId(groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1453 }
1454
1455
1468 public List<AssetCategory> findByGroupId(long groupId, int start, int end)
1469 throws SystemException {
1470 return findByGroupId(groupId, start, end, null);
1471 }
1472
1473
1487 public List<AssetCategory> findByGroupId(long groupId, int start, int end,
1488 OrderByComparator orderByComparator) throws SystemException {
1489 FinderPath finderPath = null;
1490 Object[] finderArgs = null;
1491
1492 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1493 (orderByComparator == null)) {
1494 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID;
1495 finderArgs = new Object[] { groupId };
1496 }
1497 else {
1498 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID;
1499 finderArgs = new Object[] { groupId, start, end, orderByComparator };
1500 }
1501
1502 List<AssetCategory> list = (List<AssetCategory>)FinderCacheUtil.getResult(finderPath,
1503 finderArgs, this);
1504
1505 if (list == null) {
1506 StringBundler query = null;
1507
1508 if (orderByComparator != null) {
1509 query = new StringBundler(3 +
1510 (orderByComparator.getOrderByFields().length * 3));
1511 }
1512 else {
1513 query = new StringBundler(3);
1514 }
1515
1516 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
1517
1518 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1519
1520 if (orderByComparator != null) {
1521 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1522 orderByComparator);
1523 }
1524
1525 else {
1526 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
1527 }
1528
1529 String sql = query.toString();
1530
1531 Session session = null;
1532
1533 try {
1534 session = openSession();
1535
1536 Query q = session.createQuery(sql);
1537
1538 QueryPos qPos = QueryPos.getInstance(q);
1539
1540 qPos.add(groupId);
1541
1542 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
1543 start, end);
1544 }
1545 catch (Exception e) {
1546 throw processException(e);
1547 }
1548 finally {
1549 if (list == null) {
1550 FinderCacheUtil.removeResult(finderPath, finderArgs);
1551 }
1552 else {
1553 cacheResult(list);
1554
1555 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1556 }
1557
1558 closeSession(session);
1559 }
1560 }
1561
1562 return list;
1563 }
1564
1565
1578 public AssetCategory findByGroupId_First(long groupId,
1579 OrderByComparator orderByComparator)
1580 throws NoSuchCategoryException, SystemException {
1581 List<AssetCategory> list = findByGroupId(groupId, 0, 1,
1582 orderByComparator);
1583
1584 if (list.isEmpty()) {
1585 StringBundler msg = new StringBundler(4);
1586
1587 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1588
1589 msg.append("groupId=");
1590 msg.append(groupId);
1591
1592 msg.append(StringPool.CLOSE_CURLY_BRACE);
1593
1594 throw new NoSuchCategoryException(msg.toString());
1595 }
1596 else {
1597 return list.get(0);
1598 }
1599 }
1600
1601
1614 public AssetCategory findByGroupId_Last(long groupId,
1615 OrderByComparator orderByComparator)
1616 throws NoSuchCategoryException, SystemException {
1617 int count = countByGroupId(groupId);
1618
1619 List<AssetCategory> list = findByGroupId(groupId, count - 1, count,
1620 orderByComparator);
1621
1622 if (list.isEmpty()) {
1623 StringBundler msg = new StringBundler(4);
1624
1625 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1626
1627 msg.append("groupId=");
1628 msg.append(groupId);
1629
1630 msg.append(StringPool.CLOSE_CURLY_BRACE);
1631
1632 throw new NoSuchCategoryException(msg.toString());
1633 }
1634 else {
1635 return list.get(0);
1636 }
1637 }
1638
1639
1653 public AssetCategory[] findByGroupId_PrevAndNext(long categoryId,
1654 long groupId, OrderByComparator orderByComparator)
1655 throws NoSuchCategoryException, SystemException {
1656 AssetCategory assetCategory = findByPrimaryKey(categoryId);
1657
1658 Session session = null;
1659
1660 try {
1661 session = openSession();
1662
1663 AssetCategory[] array = new AssetCategoryImpl[3];
1664
1665 array[0] = getByGroupId_PrevAndNext(session, assetCategory,
1666 groupId, orderByComparator, true);
1667
1668 array[1] = assetCategory;
1669
1670 array[2] = getByGroupId_PrevAndNext(session, assetCategory,
1671 groupId, orderByComparator, false);
1672
1673 return array;
1674 }
1675 catch (Exception e) {
1676 throw processException(e);
1677 }
1678 finally {
1679 closeSession(session);
1680 }
1681 }
1682
1683 protected AssetCategory getByGroupId_PrevAndNext(Session session,
1684 AssetCategory assetCategory, long groupId,
1685 OrderByComparator orderByComparator, boolean previous) {
1686 StringBundler query = null;
1687
1688 if (orderByComparator != null) {
1689 query = new StringBundler(6 +
1690 (orderByComparator.getOrderByFields().length * 6));
1691 }
1692 else {
1693 query = new StringBundler(3);
1694 }
1695
1696 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
1697
1698 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1699
1700 if (orderByComparator != null) {
1701 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1702
1703 if (orderByConditionFields.length > 0) {
1704 query.append(WHERE_AND);
1705 }
1706
1707 for (int i = 0; i < orderByConditionFields.length; i++) {
1708 query.append(_ORDER_BY_ENTITY_ALIAS);
1709 query.append(orderByConditionFields[i]);
1710
1711 if ((i + 1) < orderByConditionFields.length) {
1712 if (orderByComparator.isAscending() ^ previous) {
1713 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1714 }
1715 else {
1716 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1717 }
1718 }
1719 else {
1720 if (orderByComparator.isAscending() ^ previous) {
1721 query.append(WHERE_GREATER_THAN);
1722 }
1723 else {
1724 query.append(WHERE_LESSER_THAN);
1725 }
1726 }
1727 }
1728
1729 query.append(ORDER_BY_CLAUSE);
1730
1731 String[] orderByFields = orderByComparator.getOrderByFields();
1732
1733 for (int i = 0; i < orderByFields.length; i++) {
1734 query.append(_ORDER_BY_ENTITY_ALIAS);
1735 query.append(orderByFields[i]);
1736
1737 if ((i + 1) < orderByFields.length) {
1738 if (orderByComparator.isAscending() ^ previous) {
1739 query.append(ORDER_BY_ASC_HAS_NEXT);
1740 }
1741 else {
1742 query.append(ORDER_BY_DESC_HAS_NEXT);
1743 }
1744 }
1745 else {
1746 if (orderByComparator.isAscending() ^ previous) {
1747 query.append(ORDER_BY_ASC);
1748 }
1749 else {
1750 query.append(ORDER_BY_DESC);
1751 }
1752 }
1753 }
1754 }
1755
1756 else {
1757 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
1758 }
1759
1760 String sql = query.toString();
1761
1762 Query q = session.createQuery(sql);
1763
1764 q.setFirstResult(0);
1765 q.setMaxResults(2);
1766
1767 QueryPos qPos = QueryPos.getInstance(q);
1768
1769 qPos.add(groupId);
1770
1771 if (orderByComparator != null) {
1772 Object[] values = orderByComparator.getOrderByConditionValues(assetCategory);
1773
1774 for (Object value : values) {
1775 qPos.add(value);
1776 }
1777 }
1778
1779 List<AssetCategory> list = q.list();
1780
1781 if (list.size() == 2) {
1782 return list.get(1);
1783 }
1784 else {
1785 return null;
1786 }
1787 }
1788
1789
1796 public List<AssetCategory> filterFindByGroupId(long groupId)
1797 throws SystemException {
1798 return filterFindByGroupId(groupId, QueryUtil.ALL_POS,
1799 QueryUtil.ALL_POS, null);
1800 }
1801
1802
1815 public List<AssetCategory> filterFindByGroupId(long groupId, int start,
1816 int end) throws SystemException {
1817 return filterFindByGroupId(groupId, start, end, null);
1818 }
1819
1820
1834 public List<AssetCategory> filterFindByGroupId(long groupId, int start,
1835 int end, OrderByComparator orderByComparator) throws SystemException {
1836 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
1837 return findByGroupId(groupId, start, end, orderByComparator);
1838 }
1839
1840 StringBundler query = null;
1841
1842 if (orderByComparator != null) {
1843 query = new StringBundler(3 +
1844 (orderByComparator.getOrderByFields().length * 3));
1845 }
1846 else {
1847 query = new StringBundler(3);
1848 }
1849
1850 if (getDB().isSupportsInlineDistinct()) {
1851 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_WHERE);
1852 }
1853 else {
1854 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_1);
1855 }
1856
1857 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1858
1859 if (!getDB().isSupportsInlineDistinct()) {
1860 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_2);
1861 }
1862
1863 if (orderByComparator != null) {
1864 if (getDB().isSupportsInlineDistinct()) {
1865 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1866 orderByComparator);
1867 }
1868 else {
1869 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
1870 orderByComparator);
1871 }
1872 }
1873
1874 else {
1875 if (getDB().isSupportsInlineDistinct()) {
1876 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
1877 }
1878 else {
1879 query.append(AssetCategoryModelImpl.ORDER_BY_SQL);
1880 }
1881 }
1882
1883 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1884 AssetCategory.class.getName(),
1885 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
1886
1887 Session session = null;
1888
1889 try {
1890 session = openSession();
1891
1892 SQLQuery q = session.createSQLQuery(sql);
1893
1894 if (getDB().isSupportsInlineDistinct()) {
1895 q.addEntity(_FILTER_ENTITY_ALIAS, AssetCategoryImpl.class);
1896 }
1897 else {
1898 q.addEntity(_FILTER_ENTITY_TABLE, AssetCategoryImpl.class);
1899 }
1900
1901 QueryPos qPos = QueryPos.getInstance(q);
1902
1903 qPos.add(groupId);
1904
1905 return (List<AssetCategory>)QueryUtil.list(q, getDialect(), start,
1906 end);
1907 }
1908 catch (Exception e) {
1909 throw processException(e);
1910 }
1911 finally {
1912 closeSession(session);
1913 }
1914 }
1915
1916
1926 public AssetCategory[] filterFindByGroupId_PrevAndNext(long categoryId,
1927 long groupId, OrderByComparator orderByComparator)
1928 throws NoSuchCategoryException, SystemException {
1929 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
1930 return findByGroupId_PrevAndNext(categoryId, groupId,
1931 orderByComparator);
1932 }
1933
1934 AssetCategory assetCategory = findByPrimaryKey(categoryId);
1935
1936 Session session = null;
1937
1938 try {
1939 session = openSession();
1940
1941 AssetCategory[] array = new AssetCategoryImpl[3];
1942
1943 array[0] = filterGetByGroupId_PrevAndNext(session, assetCategory,
1944 groupId, orderByComparator, true);
1945
1946 array[1] = assetCategory;
1947
1948 array[2] = filterGetByGroupId_PrevAndNext(session, assetCategory,
1949 groupId, orderByComparator, false);
1950
1951 return array;
1952 }
1953 catch (Exception e) {
1954 throw processException(e);
1955 }
1956 finally {
1957 closeSession(session);
1958 }
1959 }
1960
1961 protected AssetCategory filterGetByGroupId_PrevAndNext(Session session,
1962 AssetCategory assetCategory, long groupId,
1963 OrderByComparator orderByComparator, boolean previous) {
1964 StringBundler query = null;
1965
1966 if (orderByComparator != null) {
1967 query = new StringBundler(6 +
1968 (orderByComparator.getOrderByFields().length * 6));
1969 }
1970 else {
1971 query = new StringBundler(3);
1972 }
1973
1974 if (getDB().isSupportsInlineDistinct()) {
1975 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_WHERE);
1976 }
1977 else {
1978 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_1);
1979 }
1980
1981 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1982
1983 if (!getDB().isSupportsInlineDistinct()) {
1984 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_2);
1985 }
1986
1987 if (orderByComparator != null) {
1988 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1989
1990 if (orderByConditionFields.length > 0) {
1991 query.append(WHERE_AND);
1992 }
1993
1994 for (int i = 0; i < orderByConditionFields.length; i++) {
1995 if (getDB().isSupportsInlineDistinct()) {
1996 query.append(_ORDER_BY_ENTITY_ALIAS);
1997 }
1998 else {
1999 query.append(_ORDER_BY_ENTITY_TABLE);
2000 }
2001
2002 query.append(orderByConditionFields[i]);
2003
2004 if ((i + 1) < orderByConditionFields.length) {
2005 if (orderByComparator.isAscending() ^ previous) {
2006 query.append(WHERE_GREATER_THAN_HAS_NEXT);
2007 }
2008 else {
2009 query.append(WHERE_LESSER_THAN_HAS_NEXT);
2010 }
2011 }
2012 else {
2013 if (orderByComparator.isAscending() ^ previous) {
2014 query.append(WHERE_GREATER_THAN);
2015 }
2016 else {
2017 query.append(WHERE_LESSER_THAN);
2018 }
2019 }
2020 }
2021
2022 query.append(ORDER_BY_CLAUSE);
2023
2024 String[] orderByFields = orderByComparator.getOrderByFields();
2025
2026 for (int i = 0; i < orderByFields.length; i++) {
2027 if (getDB().isSupportsInlineDistinct()) {
2028 query.append(_ORDER_BY_ENTITY_ALIAS);
2029 }
2030 else {
2031 query.append(_ORDER_BY_ENTITY_TABLE);
2032 }
2033
2034 query.append(orderByFields[i]);
2035
2036 if ((i + 1) < orderByFields.length) {
2037 if (orderByComparator.isAscending() ^ previous) {
2038 query.append(ORDER_BY_ASC_HAS_NEXT);
2039 }
2040 else {
2041 query.append(ORDER_BY_DESC_HAS_NEXT);
2042 }
2043 }
2044 else {
2045 if (orderByComparator.isAscending() ^ previous) {
2046 query.append(ORDER_BY_ASC);
2047 }
2048 else {
2049 query.append(ORDER_BY_DESC);
2050 }
2051 }
2052 }
2053 }
2054
2055 else {
2056 if (getDB().isSupportsInlineDistinct()) {
2057 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
2058 }
2059 else {
2060 query.append(AssetCategoryModelImpl.ORDER_BY_SQL);
2061 }
2062 }
2063
2064 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2065 AssetCategory.class.getName(),
2066 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2067
2068 SQLQuery q = session.createSQLQuery(sql);
2069
2070 q.setFirstResult(0);
2071 q.setMaxResults(2);
2072
2073 if (getDB().isSupportsInlineDistinct()) {
2074 q.addEntity(_FILTER_ENTITY_ALIAS, AssetCategoryImpl.class);
2075 }
2076 else {
2077 q.addEntity(_FILTER_ENTITY_TABLE, AssetCategoryImpl.class);
2078 }
2079
2080 QueryPos qPos = QueryPos.getInstance(q);
2081
2082 qPos.add(groupId);
2083
2084 if (orderByComparator != null) {
2085 Object[] values = orderByComparator.getOrderByConditionValues(assetCategory);
2086
2087 for (Object value : values) {
2088 qPos.add(value);
2089 }
2090 }
2091
2092 List<AssetCategory> list = q.list();
2093
2094 if (list.size() == 2) {
2095 return list.get(1);
2096 }
2097 else {
2098 return null;
2099 }
2100 }
2101
2102
2109 public List<AssetCategory> findByParentCategoryId(long parentCategoryId)
2110 throws SystemException {
2111 return findByParentCategoryId(parentCategoryId, QueryUtil.ALL_POS,
2112 QueryUtil.ALL_POS, null);
2113 }
2114
2115
2128 public List<AssetCategory> findByParentCategoryId(long parentCategoryId,
2129 int start, int end) throws SystemException {
2130 return findByParentCategoryId(parentCategoryId, start, end, null);
2131 }
2132
2133
2147 public List<AssetCategory> findByParentCategoryId(long parentCategoryId,
2148 int start, int end, OrderByComparator orderByComparator)
2149 throws SystemException {
2150 FinderPath finderPath = null;
2151 Object[] finderArgs = null;
2152
2153 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2154 (orderByComparator == null)) {
2155 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_PARENTCATEGORYID;
2156 finderArgs = new Object[] { parentCategoryId };
2157 }
2158 else {
2159 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_PARENTCATEGORYID;
2160 finderArgs = new Object[] {
2161 parentCategoryId,
2162
2163 start, end, orderByComparator
2164 };
2165 }
2166
2167 List<AssetCategory> list = (List<AssetCategory>)FinderCacheUtil.getResult(finderPath,
2168 finderArgs, this);
2169
2170 if (list == null) {
2171 StringBundler query = null;
2172
2173 if (orderByComparator != null) {
2174 query = new StringBundler(3 +
2175 (orderByComparator.getOrderByFields().length * 3));
2176 }
2177 else {
2178 query = new StringBundler(3);
2179 }
2180
2181 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
2182
2183 query.append(_FINDER_COLUMN_PARENTCATEGORYID_PARENTCATEGORYID_2);
2184
2185 if (orderByComparator != null) {
2186 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2187 orderByComparator);
2188 }
2189
2190 else {
2191 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
2192 }
2193
2194 String sql = query.toString();
2195
2196 Session session = null;
2197
2198 try {
2199 session = openSession();
2200
2201 Query q = session.createQuery(sql);
2202
2203 QueryPos qPos = QueryPos.getInstance(q);
2204
2205 qPos.add(parentCategoryId);
2206
2207 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
2208 start, end);
2209 }
2210 catch (Exception e) {
2211 throw processException(e);
2212 }
2213 finally {
2214 if (list == null) {
2215 FinderCacheUtil.removeResult(finderPath, finderArgs);
2216 }
2217 else {
2218 cacheResult(list);
2219
2220 FinderCacheUtil.putResult(finderPath, finderArgs, list);
2221 }
2222
2223 closeSession(session);
2224 }
2225 }
2226
2227 return list;
2228 }
2229
2230
2243 public AssetCategory findByParentCategoryId_First(long parentCategoryId,
2244 OrderByComparator orderByComparator)
2245 throws NoSuchCategoryException, SystemException {
2246 List<AssetCategory> list = findByParentCategoryId(parentCategoryId, 0,
2247 1, orderByComparator);
2248
2249 if (list.isEmpty()) {
2250 StringBundler msg = new StringBundler(4);
2251
2252 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2253
2254 msg.append("parentCategoryId=");
2255 msg.append(parentCategoryId);
2256
2257 msg.append(StringPool.CLOSE_CURLY_BRACE);
2258
2259 throw new NoSuchCategoryException(msg.toString());
2260 }
2261 else {
2262 return list.get(0);
2263 }
2264 }
2265
2266
2279 public AssetCategory findByParentCategoryId_Last(long parentCategoryId,
2280 OrderByComparator orderByComparator)
2281 throws NoSuchCategoryException, SystemException {
2282 int count = countByParentCategoryId(parentCategoryId);
2283
2284 List<AssetCategory> list = findByParentCategoryId(parentCategoryId,
2285 count - 1, count, orderByComparator);
2286
2287 if (list.isEmpty()) {
2288 StringBundler msg = new StringBundler(4);
2289
2290 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2291
2292 msg.append("parentCategoryId=");
2293 msg.append(parentCategoryId);
2294
2295 msg.append(StringPool.CLOSE_CURLY_BRACE);
2296
2297 throw new NoSuchCategoryException(msg.toString());
2298 }
2299 else {
2300 return list.get(0);
2301 }
2302 }
2303
2304
2318 public AssetCategory[] findByParentCategoryId_PrevAndNext(long categoryId,
2319 long parentCategoryId, OrderByComparator orderByComparator)
2320 throws NoSuchCategoryException, SystemException {
2321 AssetCategory assetCategory = findByPrimaryKey(categoryId);
2322
2323 Session session = null;
2324
2325 try {
2326 session = openSession();
2327
2328 AssetCategory[] array = new AssetCategoryImpl[3];
2329
2330 array[0] = getByParentCategoryId_PrevAndNext(session,
2331 assetCategory, parentCategoryId, orderByComparator, true);
2332
2333 array[1] = assetCategory;
2334
2335 array[2] = getByParentCategoryId_PrevAndNext(session,
2336 assetCategory, parentCategoryId, orderByComparator, false);
2337
2338 return array;
2339 }
2340 catch (Exception e) {
2341 throw processException(e);
2342 }
2343 finally {
2344 closeSession(session);
2345 }
2346 }
2347
2348 protected AssetCategory getByParentCategoryId_PrevAndNext(Session session,
2349 AssetCategory assetCategory, long parentCategoryId,
2350 OrderByComparator orderByComparator, boolean previous) {
2351 StringBundler query = null;
2352
2353 if (orderByComparator != null) {
2354 query = new StringBundler(6 +
2355 (orderByComparator.getOrderByFields().length * 6));
2356 }
2357 else {
2358 query = new StringBundler(3);
2359 }
2360
2361 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
2362
2363 query.append(_FINDER_COLUMN_PARENTCATEGORYID_PARENTCATEGORYID_2);
2364
2365 if (orderByComparator != null) {
2366 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2367
2368 if (orderByConditionFields.length > 0) {
2369 query.append(WHERE_AND);
2370 }
2371
2372 for (int i = 0; i < orderByConditionFields.length; i++) {
2373 query.append(_ORDER_BY_ENTITY_ALIAS);
2374 query.append(orderByConditionFields[i]);
2375
2376 if ((i + 1) < orderByConditionFields.length) {
2377 if (orderByComparator.isAscending() ^ previous) {
2378 query.append(WHERE_GREATER_THAN_HAS_NEXT);
2379 }
2380 else {
2381 query.append(WHERE_LESSER_THAN_HAS_NEXT);
2382 }
2383 }
2384 else {
2385 if (orderByComparator.isAscending() ^ previous) {
2386 query.append(WHERE_GREATER_THAN);
2387 }
2388 else {
2389 query.append(WHERE_LESSER_THAN);
2390 }
2391 }
2392 }
2393
2394 query.append(ORDER_BY_CLAUSE);
2395
2396 String[] orderByFields = orderByComparator.getOrderByFields();
2397
2398 for (int i = 0; i < orderByFields.length; i++) {
2399 query.append(_ORDER_BY_ENTITY_ALIAS);
2400 query.append(orderByFields[i]);
2401
2402 if ((i + 1) < orderByFields.length) {
2403 if (orderByComparator.isAscending() ^ previous) {
2404 query.append(ORDER_BY_ASC_HAS_NEXT);
2405 }
2406 else {
2407 query.append(ORDER_BY_DESC_HAS_NEXT);
2408 }
2409 }
2410 else {
2411 if (orderByComparator.isAscending() ^ previous) {
2412 query.append(ORDER_BY_ASC);
2413 }
2414 else {
2415 query.append(ORDER_BY_DESC);
2416 }
2417 }
2418 }
2419 }
2420
2421 else {
2422 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
2423 }
2424
2425 String sql = query.toString();
2426
2427 Query q = session.createQuery(sql);
2428
2429 q.setFirstResult(0);
2430 q.setMaxResults(2);
2431
2432 QueryPos qPos = QueryPos.getInstance(q);
2433
2434 qPos.add(parentCategoryId);
2435
2436 if (orderByComparator != null) {
2437 Object[] values = orderByComparator.getOrderByConditionValues(assetCategory);
2438
2439 for (Object value : values) {
2440 qPos.add(value);
2441 }
2442 }
2443
2444 List<AssetCategory> list = q.list();
2445
2446 if (list.size() == 2) {
2447 return list.get(1);
2448 }
2449 else {
2450 return null;
2451 }
2452 }
2453
2454
2461 public List<AssetCategory> findByVocabularyId(long vocabularyId)
2462 throws SystemException {
2463 return findByVocabularyId(vocabularyId, QueryUtil.ALL_POS,
2464 QueryUtil.ALL_POS, null);
2465 }
2466
2467
2480 public List<AssetCategory> findByVocabularyId(long vocabularyId, int start,
2481 int end) throws SystemException {
2482 return findByVocabularyId(vocabularyId, start, end, null);
2483 }
2484
2485
2499 public List<AssetCategory> findByVocabularyId(long vocabularyId, int start,
2500 int end, OrderByComparator orderByComparator) throws SystemException {
2501 FinderPath finderPath = null;
2502 Object[] finderArgs = null;
2503
2504 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2505 (orderByComparator == null)) {
2506 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_VOCABULARYID;
2507 finderArgs = new Object[] { vocabularyId };
2508 }
2509 else {
2510 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_VOCABULARYID;
2511 finderArgs = new Object[] {
2512 vocabularyId,
2513
2514 start, end, orderByComparator
2515 };
2516 }
2517
2518 List<AssetCategory> list = (List<AssetCategory>)FinderCacheUtil.getResult(finderPath,
2519 finderArgs, this);
2520
2521 if (list == null) {
2522 StringBundler query = null;
2523
2524 if (orderByComparator != null) {
2525 query = new StringBundler(3 +
2526 (orderByComparator.getOrderByFields().length * 3));
2527 }
2528 else {
2529 query = new StringBundler(3);
2530 }
2531
2532 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
2533
2534 query.append(_FINDER_COLUMN_VOCABULARYID_VOCABULARYID_2);
2535
2536 if (orderByComparator != null) {
2537 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2538 orderByComparator);
2539 }
2540
2541 else {
2542 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
2543 }
2544
2545 String sql = query.toString();
2546
2547 Session session = null;
2548
2549 try {
2550 session = openSession();
2551
2552 Query q = session.createQuery(sql);
2553
2554 QueryPos qPos = QueryPos.getInstance(q);
2555
2556 qPos.add(vocabularyId);
2557
2558 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
2559 start, end);
2560 }
2561 catch (Exception e) {
2562 throw processException(e);
2563 }
2564 finally {
2565 if (list == null) {
2566 FinderCacheUtil.removeResult(finderPath, finderArgs);
2567 }
2568 else {
2569 cacheResult(list);
2570
2571 FinderCacheUtil.putResult(finderPath, finderArgs, list);
2572 }
2573
2574 closeSession(session);
2575 }
2576 }
2577
2578 return list;
2579 }
2580
2581
2594 public AssetCategory findByVocabularyId_First(long vocabularyId,
2595 OrderByComparator orderByComparator)
2596 throws NoSuchCategoryException, SystemException {
2597 List<AssetCategory> list = findByVocabularyId(vocabularyId, 0, 1,
2598 orderByComparator);
2599
2600 if (list.isEmpty()) {
2601 StringBundler msg = new StringBundler(4);
2602
2603 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2604
2605 msg.append("vocabularyId=");
2606 msg.append(vocabularyId);
2607
2608 msg.append(StringPool.CLOSE_CURLY_BRACE);
2609
2610 throw new NoSuchCategoryException(msg.toString());
2611 }
2612 else {
2613 return list.get(0);
2614 }
2615 }
2616
2617
2630 public AssetCategory findByVocabularyId_Last(long vocabularyId,
2631 OrderByComparator orderByComparator)
2632 throws NoSuchCategoryException, SystemException {
2633 int count = countByVocabularyId(vocabularyId);
2634
2635 List<AssetCategory> list = findByVocabularyId(vocabularyId, count - 1,
2636 count, orderByComparator);
2637
2638 if (list.isEmpty()) {
2639 StringBundler msg = new StringBundler(4);
2640
2641 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2642
2643 msg.append("vocabularyId=");
2644 msg.append(vocabularyId);
2645
2646 msg.append(StringPool.CLOSE_CURLY_BRACE);
2647
2648 throw new NoSuchCategoryException(msg.toString());
2649 }
2650 else {
2651 return list.get(0);
2652 }
2653 }
2654
2655
2669 public AssetCategory[] findByVocabularyId_PrevAndNext(long categoryId,
2670 long vocabularyId, OrderByComparator orderByComparator)
2671 throws NoSuchCategoryException, SystemException {
2672 AssetCategory assetCategory = findByPrimaryKey(categoryId);
2673
2674 Session session = null;
2675
2676 try {
2677 session = openSession();
2678
2679 AssetCategory[] array = new AssetCategoryImpl[3];
2680
2681 array[0] = getByVocabularyId_PrevAndNext(session, assetCategory,
2682 vocabularyId, orderByComparator, true);
2683
2684 array[1] = assetCategory;
2685
2686 array[2] = getByVocabularyId_PrevAndNext(session, assetCategory,
2687 vocabularyId, orderByComparator, false);
2688
2689 return array;
2690 }
2691 catch (Exception e) {
2692 throw processException(e);
2693 }
2694 finally {
2695 closeSession(session);
2696 }
2697 }
2698
2699 protected AssetCategory getByVocabularyId_PrevAndNext(Session session,
2700 AssetCategory assetCategory, long vocabularyId,
2701 OrderByComparator orderByComparator, boolean previous) {
2702 StringBundler query = null;
2703
2704 if (orderByComparator != null) {
2705 query = new StringBundler(6 +
2706 (orderByComparator.getOrderByFields().length * 6));
2707 }
2708 else {
2709 query = new StringBundler(3);
2710 }
2711
2712 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
2713
2714 query.append(_FINDER_COLUMN_VOCABULARYID_VOCABULARYID_2);
2715
2716 if (orderByComparator != null) {
2717 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2718
2719 if (orderByConditionFields.length > 0) {
2720 query.append(WHERE_AND);
2721 }
2722
2723 for (int i = 0; i < orderByConditionFields.length; i++) {
2724 query.append(_ORDER_BY_ENTITY_ALIAS);
2725 query.append(orderByConditionFields[i]);
2726
2727 if ((i + 1) < orderByConditionFields.length) {
2728 if (orderByComparator.isAscending() ^ previous) {
2729 query.append(WHERE_GREATER_THAN_HAS_NEXT);
2730 }
2731 else {
2732 query.append(WHERE_LESSER_THAN_HAS_NEXT);
2733 }
2734 }
2735 else {
2736 if (orderByComparator.isAscending() ^ previous) {
2737 query.append(WHERE_GREATER_THAN);
2738 }
2739 else {
2740 query.append(WHERE_LESSER_THAN);
2741 }
2742 }
2743 }
2744
2745 query.append(ORDER_BY_CLAUSE);
2746
2747 String[] orderByFields = orderByComparator.getOrderByFields();
2748
2749 for (int i = 0; i < orderByFields.length; i++) {
2750 query.append(_ORDER_BY_ENTITY_ALIAS);
2751 query.append(orderByFields[i]);
2752
2753 if ((i + 1) < orderByFields.length) {
2754 if (orderByComparator.isAscending() ^ previous) {
2755 query.append(ORDER_BY_ASC_HAS_NEXT);
2756 }
2757 else {
2758 query.append(ORDER_BY_DESC_HAS_NEXT);
2759 }
2760 }
2761 else {
2762 if (orderByComparator.isAscending() ^ previous) {
2763 query.append(ORDER_BY_ASC);
2764 }
2765 else {
2766 query.append(ORDER_BY_DESC);
2767 }
2768 }
2769 }
2770 }
2771
2772 else {
2773 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
2774 }
2775
2776 String sql = query.toString();
2777
2778 Query q = session.createQuery(sql);
2779
2780 q.setFirstResult(0);
2781 q.setMaxResults(2);
2782
2783 QueryPos qPos = QueryPos.getInstance(q);
2784
2785 qPos.add(vocabularyId);
2786
2787 if (orderByComparator != null) {
2788 Object[] values = orderByComparator.getOrderByConditionValues(assetCategory);
2789
2790 for (Object value : values) {
2791 qPos.add(value);
2792 }
2793 }
2794
2795 List<AssetCategory> list = q.list();
2796
2797 if (list.size() == 2) {
2798 return list.get(1);
2799 }
2800 else {
2801 return null;
2802 }
2803 }
2804
2805
2813 public List<AssetCategory> findByG_V(long groupId, long vocabularyId)
2814 throws SystemException {
2815 return findByG_V(groupId, vocabularyId, QueryUtil.ALL_POS,
2816 QueryUtil.ALL_POS, null);
2817 }
2818
2819
2833 public List<AssetCategory> findByG_V(long groupId, long vocabularyId,
2834 int start, int end) throws SystemException {
2835 return findByG_V(groupId, vocabularyId, start, end, null);
2836 }
2837
2838
2853 public List<AssetCategory> findByG_V(long groupId, long vocabularyId,
2854 int start, int end, OrderByComparator orderByComparator)
2855 throws SystemException {
2856 FinderPath finderPath = null;
2857 Object[] finderArgs = null;
2858
2859 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2860 (orderByComparator == null)) {
2861 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_V;
2862 finderArgs = new Object[] { groupId, vocabularyId };
2863 }
2864 else {
2865 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_V;
2866 finderArgs = new Object[] {
2867 groupId, vocabularyId,
2868
2869 start, end, orderByComparator
2870 };
2871 }
2872
2873 List<AssetCategory> list = (List<AssetCategory>)FinderCacheUtil.getResult(finderPath,
2874 finderArgs, this);
2875
2876 if (list == null) {
2877 StringBundler query = null;
2878
2879 if (orderByComparator != null) {
2880 query = new StringBundler(4 +
2881 (orderByComparator.getOrderByFields().length * 3));
2882 }
2883 else {
2884 query = new StringBundler(4);
2885 }
2886
2887 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
2888
2889 query.append(_FINDER_COLUMN_G_V_GROUPID_2);
2890
2891 query.append(_FINDER_COLUMN_G_V_VOCABULARYID_2);
2892
2893 if (orderByComparator != null) {
2894 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2895 orderByComparator);
2896 }
2897
2898 else {
2899 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
2900 }
2901
2902 String sql = query.toString();
2903
2904 Session session = null;
2905
2906 try {
2907 session = openSession();
2908
2909 Query q = session.createQuery(sql);
2910
2911 QueryPos qPos = QueryPos.getInstance(q);
2912
2913 qPos.add(groupId);
2914
2915 qPos.add(vocabularyId);
2916
2917 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
2918 start, end);
2919 }
2920 catch (Exception e) {
2921 throw processException(e);
2922 }
2923 finally {
2924 if (list == null) {
2925 FinderCacheUtil.removeResult(finderPath, finderArgs);
2926 }
2927 else {
2928 cacheResult(list);
2929
2930 FinderCacheUtil.putResult(finderPath, finderArgs, list);
2931 }
2932
2933 closeSession(session);
2934 }
2935 }
2936
2937 return list;
2938 }
2939
2940
2954 public AssetCategory findByG_V_First(long groupId, long vocabularyId,
2955 OrderByComparator orderByComparator)
2956 throws NoSuchCategoryException, SystemException {
2957 List<AssetCategory> list = findByG_V(groupId, vocabularyId, 0, 1,
2958 orderByComparator);
2959
2960 if (list.isEmpty()) {
2961 StringBundler msg = new StringBundler(6);
2962
2963 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2964
2965 msg.append("groupId=");
2966 msg.append(groupId);
2967
2968 msg.append(", vocabularyId=");
2969 msg.append(vocabularyId);
2970
2971 msg.append(StringPool.CLOSE_CURLY_BRACE);
2972
2973 throw new NoSuchCategoryException(msg.toString());
2974 }
2975 else {
2976 return list.get(0);
2977 }
2978 }
2979
2980
2994 public AssetCategory findByG_V_Last(long groupId, long vocabularyId,
2995 OrderByComparator orderByComparator)
2996 throws NoSuchCategoryException, SystemException {
2997 int count = countByG_V(groupId, vocabularyId);
2998
2999 List<AssetCategory> list = findByG_V(groupId, vocabularyId, count - 1,
3000 count, orderByComparator);
3001
3002 if (list.isEmpty()) {
3003 StringBundler msg = new StringBundler(6);
3004
3005 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3006
3007 msg.append("groupId=");
3008 msg.append(groupId);
3009
3010 msg.append(", vocabularyId=");
3011 msg.append(vocabularyId);
3012
3013 msg.append(StringPool.CLOSE_CURLY_BRACE);
3014
3015 throw new NoSuchCategoryException(msg.toString());
3016 }
3017 else {
3018 return list.get(0);
3019 }
3020 }
3021
3022
3037 public AssetCategory[] findByG_V_PrevAndNext(long categoryId, long groupId,
3038 long vocabularyId, OrderByComparator orderByComparator)
3039 throws NoSuchCategoryException, SystemException {
3040 AssetCategory assetCategory = findByPrimaryKey(categoryId);
3041
3042 Session session = null;
3043
3044 try {
3045 session = openSession();
3046
3047 AssetCategory[] array = new AssetCategoryImpl[3];
3048
3049 array[0] = getByG_V_PrevAndNext(session, assetCategory, groupId,
3050 vocabularyId, orderByComparator, true);
3051
3052 array[1] = assetCategory;
3053
3054 array[2] = getByG_V_PrevAndNext(session, assetCategory, groupId,
3055 vocabularyId, orderByComparator, false);
3056
3057 return array;
3058 }
3059 catch (Exception e) {
3060 throw processException(e);
3061 }
3062 finally {
3063 closeSession(session);
3064 }
3065 }
3066
3067 protected AssetCategory getByG_V_PrevAndNext(Session session,
3068 AssetCategory assetCategory, long groupId, long vocabularyId,
3069 OrderByComparator orderByComparator, boolean previous) {
3070 StringBundler query = null;
3071
3072 if (orderByComparator != null) {
3073 query = new StringBundler(6 +
3074 (orderByComparator.getOrderByFields().length * 6));
3075 }
3076 else {
3077 query = new StringBundler(3);
3078 }
3079
3080 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
3081
3082 query.append(_FINDER_COLUMN_G_V_GROUPID_2);
3083
3084 query.append(_FINDER_COLUMN_G_V_VOCABULARYID_2);
3085
3086 if (orderByComparator != null) {
3087 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3088
3089 if (orderByConditionFields.length > 0) {
3090 query.append(WHERE_AND);
3091 }
3092
3093 for (int i = 0; i < orderByConditionFields.length; i++) {
3094 query.append(_ORDER_BY_ENTITY_ALIAS);
3095 query.append(orderByConditionFields[i]);
3096
3097 if ((i + 1) < orderByConditionFields.length) {
3098 if (orderByComparator.isAscending() ^ previous) {
3099 query.append(WHERE_GREATER_THAN_HAS_NEXT);
3100 }
3101 else {
3102 query.append(WHERE_LESSER_THAN_HAS_NEXT);
3103 }
3104 }
3105 else {
3106 if (orderByComparator.isAscending() ^ previous) {
3107 query.append(WHERE_GREATER_THAN);
3108 }
3109 else {
3110 query.append(WHERE_LESSER_THAN);
3111 }
3112 }
3113 }
3114
3115 query.append(ORDER_BY_CLAUSE);
3116
3117 String[] orderByFields = orderByComparator.getOrderByFields();
3118
3119 for (int i = 0; i < orderByFields.length; i++) {
3120 query.append(_ORDER_BY_ENTITY_ALIAS);
3121 query.append(orderByFields[i]);
3122
3123 if ((i + 1) < orderByFields.length) {
3124 if (orderByComparator.isAscending() ^ previous) {
3125 query.append(ORDER_BY_ASC_HAS_NEXT);
3126 }
3127 else {
3128 query.append(ORDER_BY_DESC_HAS_NEXT);
3129 }
3130 }
3131 else {
3132 if (orderByComparator.isAscending() ^ previous) {
3133 query.append(ORDER_BY_ASC);
3134 }
3135 else {
3136 query.append(ORDER_BY_DESC);
3137 }
3138 }
3139 }
3140 }
3141
3142 else {
3143 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
3144 }
3145
3146 String sql = query.toString();
3147
3148 Query q = session.createQuery(sql);
3149
3150 q.setFirstResult(0);
3151 q.setMaxResults(2);
3152
3153 QueryPos qPos = QueryPos.getInstance(q);
3154
3155 qPos.add(groupId);
3156
3157 qPos.add(vocabularyId);
3158
3159 if (orderByComparator != null) {
3160 Object[] values = orderByComparator.getOrderByConditionValues(assetCategory);
3161
3162 for (Object value : values) {
3163 qPos.add(value);
3164 }
3165 }
3166
3167 List<AssetCategory> list = q.list();
3168
3169 if (list.size() == 2) {
3170 return list.get(1);
3171 }
3172 else {
3173 return null;
3174 }
3175 }
3176
3177
3185 public List<AssetCategory> filterFindByG_V(long groupId, long vocabularyId)
3186 throws SystemException {
3187 return filterFindByG_V(groupId, vocabularyId, QueryUtil.ALL_POS,
3188 QueryUtil.ALL_POS, null);
3189 }
3190
3191
3205 public List<AssetCategory> filterFindByG_V(long groupId, long vocabularyId,
3206 int start, int end) throws SystemException {
3207 return filterFindByG_V(groupId, vocabularyId, start, end, null);
3208 }
3209
3210
3225 public List<AssetCategory> filterFindByG_V(long groupId, long vocabularyId,
3226 int start, int end, OrderByComparator orderByComparator)
3227 throws SystemException {
3228 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
3229 return findByG_V(groupId, vocabularyId, start, end,
3230 orderByComparator);
3231 }
3232
3233 StringBundler query = null;
3234
3235 if (orderByComparator != null) {
3236 query = new StringBundler(4 +
3237 (orderByComparator.getOrderByFields().length * 3));
3238 }
3239 else {
3240 query = new StringBundler(4);
3241 }
3242
3243 if (getDB().isSupportsInlineDistinct()) {
3244 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_WHERE);
3245 }
3246 else {
3247 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_1);
3248 }
3249
3250 query.append(_FINDER_COLUMN_G_V_GROUPID_2);
3251
3252 query.append(_FINDER_COLUMN_G_V_VOCABULARYID_2);
3253
3254 if (!getDB().isSupportsInlineDistinct()) {
3255 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_2);
3256 }
3257
3258 if (orderByComparator != null) {
3259 if (getDB().isSupportsInlineDistinct()) {
3260 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3261 orderByComparator);
3262 }
3263 else {
3264 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
3265 orderByComparator);
3266 }
3267 }
3268
3269 else {
3270 if (getDB().isSupportsInlineDistinct()) {
3271 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
3272 }
3273 else {
3274 query.append(AssetCategoryModelImpl.ORDER_BY_SQL);
3275 }
3276 }
3277
3278 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
3279 AssetCategory.class.getName(),
3280 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
3281
3282 Session session = null;
3283
3284 try {
3285 session = openSession();
3286
3287 SQLQuery q = session.createSQLQuery(sql);
3288
3289 if (getDB().isSupportsInlineDistinct()) {
3290 q.addEntity(_FILTER_ENTITY_ALIAS, AssetCategoryImpl.class);
3291 }
3292 else {
3293 q.addEntity(_FILTER_ENTITY_TABLE, AssetCategoryImpl.class);
3294 }
3295
3296 QueryPos qPos = QueryPos.getInstance(q);
3297
3298 qPos.add(groupId);
3299
3300 qPos.add(vocabularyId);
3301
3302 return (List<AssetCategory>)QueryUtil.list(q, getDialect(), start,
3303 end);
3304 }
3305 catch (Exception e) {
3306 throw processException(e);
3307 }
3308 finally {
3309 closeSession(session);
3310 }
3311 }
3312
3313
3324 public AssetCategory[] filterFindByG_V_PrevAndNext(long categoryId,
3325 long groupId, long vocabularyId, OrderByComparator orderByComparator)
3326 throws NoSuchCategoryException, SystemException {
3327 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
3328 return findByG_V_PrevAndNext(categoryId, groupId, vocabularyId,
3329 orderByComparator);
3330 }
3331
3332 AssetCategory assetCategory = findByPrimaryKey(categoryId);
3333
3334 Session session = null;
3335
3336 try {
3337 session = openSession();
3338
3339 AssetCategory[] array = new AssetCategoryImpl[3];
3340
3341 array[0] = filterGetByG_V_PrevAndNext(session, assetCategory,
3342 groupId, vocabularyId, orderByComparator, true);
3343
3344 array[1] = assetCategory;
3345
3346 array[2] = filterGetByG_V_PrevAndNext(session, assetCategory,
3347 groupId, vocabularyId, orderByComparator, false);
3348
3349 return array;
3350 }
3351 catch (Exception e) {
3352 throw processException(e);
3353 }
3354 finally {
3355 closeSession(session);
3356 }
3357 }
3358
3359 protected AssetCategory filterGetByG_V_PrevAndNext(Session session,
3360 AssetCategory assetCategory, long groupId, long vocabularyId,
3361 OrderByComparator orderByComparator, boolean previous) {
3362 StringBundler query = null;
3363
3364 if (orderByComparator != null) {
3365 query = new StringBundler(6 +
3366 (orderByComparator.getOrderByFields().length * 6));
3367 }
3368 else {
3369 query = new StringBundler(3);
3370 }
3371
3372 if (getDB().isSupportsInlineDistinct()) {
3373 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_WHERE);
3374 }
3375 else {
3376 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_1);
3377 }
3378
3379 query.append(_FINDER_COLUMN_G_V_GROUPID_2);
3380
3381 query.append(_FINDER_COLUMN_G_V_VOCABULARYID_2);
3382
3383 if (!getDB().isSupportsInlineDistinct()) {
3384 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_2);
3385 }
3386
3387 if (orderByComparator != null) {
3388 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3389
3390 if (orderByConditionFields.length > 0) {
3391 query.append(WHERE_AND);
3392 }
3393
3394 for (int i = 0; i < orderByConditionFields.length; i++) {
3395 if (getDB().isSupportsInlineDistinct()) {
3396 query.append(_ORDER_BY_ENTITY_ALIAS);
3397 }
3398 else {
3399 query.append(_ORDER_BY_ENTITY_TABLE);
3400 }
3401
3402 query.append(orderByConditionFields[i]);
3403
3404 if ((i + 1) < orderByConditionFields.length) {
3405 if (orderByComparator.isAscending() ^ previous) {
3406 query.append(WHERE_GREATER_THAN_HAS_NEXT);
3407 }
3408 else {
3409 query.append(WHERE_LESSER_THAN_HAS_NEXT);
3410 }
3411 }
3412 else {
3413 if (orderByComparator.isAscending() ^ previous) {
3414 query.append(WHERE_GREATER_THAN);
3415 }
3416 else {
3417 query.append(WHERE_LESSER_THAN);
3418 }
3419 }
3420 }
3421
3422 query.append(ORDER_BY_CLAUSE);
3423
3424 String[] orderByFields = orderByComparator.getOrderByFields();
3425
3426 for (int i = 0; i < orderByFields.length; i++) {
3427 if (getDB().isSupportsInlineDistinct()) {
3428 query.append(_ORDER_BY_ENTITY_ALIAS);
3429 }
3430 else {
3431 query.append(_ORDER_BY_ENTITY_TABLE);
3432 }
3433
3434 query.append(orderByFields[i]);
3435
3436 if ((i + 1) < orderByFields.length) {
3437 if (orderByComparator.isAscending() ^ previous) {
3438 query.append(ORDER_BY_ASC_HAS_NEXT);
3439 }
3440 else {
3441 query.append(ORDER_BY_DESC_HAS_NEXT);
3442 }
3443 }
3444 else {
3445 if (orderByComparator.isAscending() ^ previous) {
3446 query.append(ORDER_BY_ASC);
3447 }
3448 else {
3449 query.append(ORDER_BY_DESC);
3450 }
3451 }
3452 }
3453 }
3454
3455 else {
3456 if (getDB().isSupportsInlineDistinct()) {
3457 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
3458 }
3459 else {
3460 query.append(AssetCategoryModelImpl.ORDER_BY_SQL);
3461 }
3462 }
3463
3464 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
3465 AssetCategory.class.getName(),
3466 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
3467
3468 SQLQuery q = session.createSQLQuery(sql);
3469
3470 q.setFirstResult(0);
3471 q.setMaxResults(2);
3472
3473 if (getDB().isSupportsInlineDistinct()) {
3474 q.addEntity(_FILTER_ENTITY_ALIAS, AssetCategoryImpl.class);
3475 }
3476 else {
3477 q.addEntity(_FILTER_ENTITY_TABLE, AssetCategoryImpl.class);
3478 }
3479
3480 QueryPos qPos = QueryPos.getInstance(q);
3481
3482 qPos.add(groupId);
3483
3484 qPos.add(vocabularyId);
3485
3486 if (orderByComparator != null) {
3487 Object[] values = orderByComparator.getOrderByConditionValues(assetCategory);
3488
3489 for (Object value : values) {
3490 qPos.add(value);
3491 }
3492 }
3493
3494 List<AssetCategory> list = q.list();
3495
3496 if (list.size() == 2) {
3497 return list.get(1);
3498 }
3499 else {
3500 return null;
3501 }
3502 }
3503
3504
3512 public List<AssetCategory> findByP_N(long parentCategoryId, String name)
3513 throws SystemException {
3514 return findByP_N(parentCategoryId, name, QueryUtil.ALL_POS,
3515 QueryUtil.ALL_POS, null);
3516 }
3517
3518
3532 public List<AssetCategory> findByP_N(long parentCategoryId, String name,
3533 int start, int end) throws SystemException {
3534 return findByP_N(parentCategoryId, name, start, end, null);
3535 }
3536
3537
3552 public List<AssetCategory> findByP_N(long parentCategoryId, String name,
3553 int start, int end, OrderByComparator orderByComparator)
3554 throws SystemException {
3555 FinderPath finderPath = null;
3556 Object[] finderArgs = null;
3557
3558 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
3559 (orderByComparator == null)) {
3560 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_P_N;
3561 finderArgs = new Object[] { parentCategoryId, name };
3562 }
3563 else {
3564 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_P_N;
3565 finderArgs = new Object[] {
3566 parentCategoryId, name,
3567
3568 start, end, orderByComparator
3569 };
3570 }
3571
3572 List<AssetCategory> list = (List<AssetCategory>)FinderCacheUtil.getResult(finderPath,
3573 finderArgs, this);
3574
3575 if (list == null) {
3576 StringBundler query = null;
3577
3578 if (orderByComparator != null) {
3579 query = new StringBundler(4 +
3580 (orderByComparator.getOrderByFields().length * 3));
3581 }
3582 else {
3583 query = new StringBundler(4);
3584 }
3585
3586 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
3587
3588 query.append(_FINDER_COLUMN_P_N_PARENTCATEGORYID_2);
3589
3590 if (name == null) {
3591 query.append(_FINDER_COLUMN_P_N_NAME_1);
3592 }
3593 else {
3594 if (name.equals(StringPool.BLANK)) {
3595 query.append(_FINDER_COLUMN_P_N_NAME_3);
3596 }
3597 else {
3598 query.append(_FINDER_COLUMN_P_N_NAME_2);
3599 }
3600 }
3601
3602 if (orderByComparator != null) {
3603 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3604 orderByComparator);
3605 }
3606
3607 else {
3608 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
3609 }
3610
3611 String sql = query.toString();
3612
3613 Session session = null;
3614
3615 try {
3616 session = openSession();
3617
3618 Query q = session.createQuery(sql);
3619
3620 QueryPos qPos = QueryPos.getInstance(q);
3621
3622 qPos.add(parentCategoryId);
3623
3624 if (name != null) {
3625 qPos.add(name);
3626 }
3627
3628 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
3629 start, end);
3630 }
3631 catch (Exception e) {
3632 throw processException(e);
3633 }
3634 finally {
3635 if (list == null) {
3636 FinderCacheUtil.removeResult(finderPath, finderArgs);
3637 }
3638 else {
3639 cacheResult(list);
3640
3641 FinderCacheUtil.putResult(finderPath, finderArgs, list);
3642 }
3643
3644 closeSession(session);
3645 }
3646 }
3647
3648 return list;
3649 }
3650
3651
3665 public AssetCategory findByP_N_First(long parentCategoryId, String name,
3666 OrderByComparator orderByComparator)
3667 throws NoSuchCategoryException, SystemException {
3668 List<AssetCategory> list = findByP_N(parentCategoryId, name, 0, 1,
3669 orderByComparator);
3670
3671 if (list.isEmpty()) {
3672 StringBundler msg = new StringBundler(6);
3673
3674 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3675
3676 msg.append("parentCategoryId=");
3677 msg.append(parentCategoryId);
3678
3679 msg.append(", name=");
3680 msg.append(name);
3681
3682 msg.append(StringPool.CLOSE_CURLY_BRACE);
3683
3684 throw new NoSuchCategoryException(msg.toString());
3685 }
3686 else {
3687 return list.get(0);
3688 }
3689 }
3690
3691
3705 public AssetCategory findByP_N_Last(long parentCategoryId, String name,
3706 OrderByComparator orderByComparator)
3707 throws NoSuchCategoryException, SystemException {
3708 int count = countByP_N(parentCategoryId, name);
3709
3710 List<AssetCategory> list = findByP_N(parentCategoryId, name, count - 1,
3711 count, orderByComparator);
3712
3713 if (list.isEmpty()) {
3714 StringBundler msg = new StringBundler(6);
3715
3716 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3717
3718 msg.append("parentCategoryId=");
3719 msg.append(parentCategoryId);
3720
3721 msg.append(", name=");
3722 msg.append(name);
3723
3724 msg.append(StringPool.CLOSE_CURLY_BRACE);
3725
3726 throw new NoSuchCategoryException(msg.toString());
3727 }
3728 else {
3729 return list.get(0);
3730 }
3731 }
3732
3733
3748 public AssetCategory[] findByP_N_PrevAndNext(long categoryId,
3749 long parentCategoryId, String name, OrderByComparator orderByComparator)
3750 throws NoSuchCategoryException, SystemException {
3751 AssetCategory assetCategory = findByPrimaryKey(categoryId);
3752
3753 Session session = null;
3754
3755 try {
3756 session = openSession();
3757
3758 AssetCategory[] array = new AssetCategoryImpl[3];
3759
3760 array[0] = getByP_N_PrevAndNext(session, assetCategory,
3761 parentCategoryId, name, orderByComparator, true);
3762
3763 array[1] = assetCategory;
3764
3765 array[2] = getByP_N_PrevAndNext(session, assetCategory,
3766 parentCategoryId, name, orderByComparator, false);
3767
3768 return array;
3769 }
3770 catch (Exception e) {
3771 throw processException(e);
3772 }
3773 finally {
3774 closeSession(session);
3775 }
3776 }
3777
3778 protected AssetCategory getByP_N_PrevAndNext(Session session,
3779 AssetCategory assetCategory, long parentCategoryId, String name,
3780 OrderByComparator orderByComparator, boolean previous) {
3781 StringBundler query = null;
3782
3783 if (orderByComparator != null) {
3784 query = new StringBundler(6 +
3785 (orderByComparator.getOrderByFields().length * 6));
3786 }
3787 else {
3788 query = new StringBundler(3);
3789 }
3790
3791 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
3792
3793 query.append(_FINDER_COLUMN_P_N_PARENTCATEGORYID_2);
3794
3795 if (name == null) {
3796 query.append(_FINDER_COLUMN_P_N_NAME_1);
3797 }
3798 else {
3799 if (name.equals(StringPool.BLANK)) {
3800 query.append(_FINDER_COLUMN_P_N_NAME_3);
3801 }
3802 else {
3803 query.append(_FINDER_COLUMN_P_N_NAME_2);
3804 }
3805 }
3806
3807 if (orderByComparator != null) {
3808 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3809
3810 if (orderByConditionFields.length > 0) {
3811 query.append(WHERE_AND);
3812 }
3813
3814 for (int i = 0; i < orderByConditionFields.length; i++) {
3815 query.append(_ORDER_BY_ENTITY_ALIAS);
3816 query.append(orderByConditionFields[i]);
3817
3818 if ((i + 1) < orderByConditionFields.length) {
3819 if (orderByComparator.isAscending() ^ previous) {
3820 query.append(WHERE_GREATER_THAN_HAS_NEXT);
3821 }
3822 else {
3823 query.append(WHERE_LESSER_THAN_HAS_NEXT);
3824 }
3825 }
3826 else {
3827 if (orderByComparator.isAscending() ^ previous) {
3828 query.append(WHERE_GREATER_THAN);
3829 }
3830 else {
3831 query.append(WHERE_LESSER_THAN);
3832 }
3833 }
3834 }
3835
3836 query.append(ORDER_BY_CLAUSE);
3837
3838 String[] orderByFields = orderByComparator.getOrderByFields();
3839
3840 for (int i = 0; i < orderByFields.length; i++) {
3841 query.append(_ORDER_BY_ENTITY_ALIAS);
3842 query.append(orderByFields[i]);
3843
3844 if ((i + 1) < orderByFields.length) {
3845 if (orderByComparator.isAscending() ^ previous) {
3846 query.append(ORDER_BY_ASC_HAS_NEXT);
3847 }
3848 else {
3849 query.append(ORDER_BY_DESC_HAS_NEXT);
3850 }
3851 }
3852 else {
3853 if (orderByComparator.isAscending() ^ previous) {
3854 query.append(ORDER_BY_ASC);
3855 }
3856 else {
3857 query.append(ORDER_BY_DESC);
3858 }
3859 }
3860 }
3861 }
3862
3863 else {
3864 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
3865 }
3866
3867 String sql = query.toString();
3868
3869 Query q = session.createQuery(sql);
3870
3871 q.setFirstResult(0);
3872 q.setMaxResults(2);
3873
3874 QueryPos qPos = QueryPos.getInstance(q);
3875
3876 qPos.add(parentCategoryId);
3877
3878 if (name != null) {
3879 qPos.add(name);
3880 }
3881
3882 if (orderByComparator != null) {
3883 Object[] values = orderByComparator.getOrderByConditionValues(assetCategory);
3884
3885 for (Object value : values) {
3886 qPos.add(value);
3887 }
3888 }
3889
3890 List<AssetCategory> list = q.list();
3891
3892 if (list.size() == 2) {
3893 return list.get(1);
3894 }
3895 else {
3896 return null;
3897 }
3898 }
3899
3900
3908 public List<AssetCategory> findByP_V(long parentCategoryId,
3909 long vocabularyId) throws SystemException {
3910 return findByP_V(parentCategoryId, vocabularyId, QueryUtil.ALL_POS,
3911 QueryUtil.ALL_POS, null);
3912 }
3913
3914
3928 public List<AssetCategory> findByP_V(long parentCategoryId,
3929 long vocabularyId, int start, int end) throws SystemException {
3930 return findByP_V(parentCategoryId, vocabularyId, start, end, null);
3931 }
3932
3933
3948 public List<AssetCategory> findByP_V(long parentCategoryId,
3949 long vocabularyId, int start, int end,
3950 OrderByComparator orderByComparator) throws SystemException {
3951 FinderPath finderPath = null;
3952 Object[] finderArgs = null;
3953
3954 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
3955 (orderByComparator == null)) {
3956 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_P_V;
3957 finderArgs = new Object[] { parentCategoryId, vocabularyId };
3958 }
3959 else {
3960 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_P_V;
3961 finderArgs = new Object[] {
3962 parentCategoryId, vocabularyId,
3963
3964 start, end, orderByComparator
3965 };
3966 }
3967
3968 List<AssetCategory> list = (List<AssetCategory>)FinderCacheUtil.getResult(finderPath,
3969 finderArgs, this);
3970
3971 if (list == null) {
3972 StringBundler query = null;
3973
3974 if (orderByComparator != null) {
3975 query = new StringBundler(4 +
3976 (orderByComparator.getOrderByFields().length * 3));
3977 }
3978 else {
3979 query = new StringBundler(4);
3980 }
3981
3982 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
3983
3984 query.append(_FINDER_COLUMN_P_V_PARENTCATEGORYID_2);
3985
3986 query.append(_FINDER_COLUMN_P_V_VOCABULARYID_2);
3987
3988 if (orderByComparator != null) {
3989 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3990 orderByComparator);
3991 }
3992
3993 else {
3994 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
3995 }
3996
3997 String sql = query.toString();
3998
3999 Session session = null;
4000
4001 try {
4002 session = openSession();
4003
4004 Query q = session.createQuery(sql);
4005
4006 QueryPos qPos = QueryPos.getInstance(q);
4007
4008 qPos.add(parentCategoryId);
4009
4010 qPos.add(vocabularyId);
4011
4012 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
4013 start, end);
4014 }
4015 catch (Exception e) {
4016 throw processException(e);
4017 }
4018 finally {
4019 if (list == null) {
4020 FinderCacheUtil.removeResult(finderPath, finderArgs);
4021 }
4022 else {
4023 cacheResult(list);
4024
4025 FinderCacheUtil.putResult(finderPath, finderArgs, list);
4026 }
4027
4028 closeSession(session);
4029 }
4030 }
4031
4032 return list;
4033 }
4034
4035
4049 public AssetCategory findByP_V_First(long parentCategoryId,
4050 long vocabularyId, OrderByComparator orderByComparator)
4051 throws NoSuchCategoryException, SystemException {
4052 List<AssetCategory> list = findByP_V(parentCategoryId, vocabularyId, 0,
4053 1, orderByComparator);
4054
4055 if (list.isEmpty()) {
4056 StringBundler msg = new StringBundler(6);
4057
4058 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4059
4060 msg.append("parentCategoryId=");
4061 msg.append(parentCategoryId);
4062
4063 msg.append(", vocabularyId=");
4064 msg.append(vocabularyId);
4065
4066 msg.append(StringPool.CLOSE_CURLY_BRACE);
4067
4068 throw new NoSuchCategoryException(msg.toString());
4069 }
4070 else {
4071 return list.get(0);
4072 }
4073 }
4074
4075
4089 public AssetCategory findByP_V_Last(long parentCategoryId,
4090 long vocabularyId, OrderByComparator orderByComparator)
4091 throws NoSuchCategoryException, SystemException {
4092 int count = countByP_V(parentCategoryId, vocabularyId);
4093
4094 List<AssetCategory> list = findByP_V(parentCategoryId, vocabularyId,
4095 count - 1, count, orderByComparator);
4096
4097 if (list.isEmpty()) {
4098 StringBundler msg = new StringBundler(6);
4099
4100 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4101
4102 msg.append("parentCategoryId=");
4103 msg.append(parentCategoryId);
4104
4105 msg.append(", vocabularyId=");
4106 msg.append(vocabularyId);
4107
4108 msg.append(StringPool.CLOSE_CURLY_BRACE);
4109
4110 throw new NoSuchCategoryException(msg.toString());
4111 }
4112 else {
4113 return list.get(0);
4114 }
4115 }
4116
4117
4132 public AssetCategory[] findByP_V_PrevAndNext(long categoryId,
4133 long parentCategoryId, long vocabularyId,
4134 OrderByComparator orderByComparator)
4135 throws NoSuchCategoryException, SystemException {
4136 AssetCategory assetCategory = findByPrimaryKey(categoryId);
4137
4138 Session session = null;
4139
4140 try {
4141 session = openSession();
4142
4143 AssetCategory[] array = new AssetCategoryImpl[3];
4144
4145 array[0] = getByP_V_PrevAndNext(session, assetCategory,
4146 parentCategoryId, vocabularyId, orderByComparator, true);
4147
4148 array[1] = assetCategory;
4149
4150 array[2] = getByP_V_PrevAndNext(session, assetCategory,
4151 parentCategoryId, vocabularyId, orderByComparator, false);
4152
4153 return array;
4154 }
4155 catch (Exception e) {
4156 throw processException(e);
4157 }
4158 finally {
4159 closeSession(session);
4160 }
4161 }
4162
4163 protected AssetCategory getByP_V_PrevAndNext(Session session,
4164 AssetCategory assetCategory, long parentCategoryId, long vocabularyId,
4165 OrderByComparator orderByComparator, boolean previous) {
4166 StringBundler query = null;
4167
4168 if (orderByComparator != null) {
4169 query = new StringBundler(6 +
4170 (orderByComparator.getOrderByFields().length * 6));
4171 }
4172 else {
4173 query = new StringBundler(3);
4174 }
4175
4176 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
4177
4178 query.append(_FINDER_COLUMN_P_V_PARENTCATEGORYID_2);
4179
4180 query.append(_FINDER_COLUMN_P_V_VOCABULARYID_2);
4181
4182 if (orderByComparator != null) {
4183 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
4184
4185 if (orderByConditionFields.length > 0) {
4186 query.append(WHERE_AND);
4187 }
4188
4189 for (int i = 0; i < orderByConditionFields.length; i++) {
4190 query.append(_ORDER_BY_ENTITY_ALIAS);
4191 query.append(orderByConditionFields[i]);
4192
4193 if ((i + 1) < orderByConditionFields.length) {
4194 if (orderByComparator.isAscending() ^ previous) {
4195 query.append(WHERE_GREATER_THAN_HAS_NEXT);
4196 }
4197 else {
4198 query.append(WHERE_LESSER_THAN_HAS_NEXT);
4199 }
4200 }
4201 else {
4202 if (orderByComparator.isAscending() ^ previous) {
4203 query.append(WHERE_GREATER_THAN);
4204 }
4205 else {
4206 query.append(WHERE_LESSER_THAN);
4207 }
4208 }
4209 }
4210
4211 query.append(ORDER_BY_CLAUSE);
4212
4213 String[] orderByFields = orderByComparator.getOrderByFields();
4214
4215 for (int i = 0; i < orderByFields.length; i++) {
4216 query.append(_ORDER_BY_ENTITY_ALIAS);
4217 query.append(orderByFields[i]);
4218
4219 if ((i + 1) < orderByFields.length) {
4220 if (orderByComparator.isAscending() ^ previous) {
4221 query.append(ORDER_BY_ASC_HAS_NEXT);
4222 }
4223 else {
4224 query.append(ORDER_BY_DESC_HAS_NEXT);
4225 }
4226 }
4227 else {
4228 if (orderByComparator.isAscending() ^ previous) {
4229 query.append(ORDER_BY_ASC);
4230 }
4231 else {
4232 query.append(ORDER_BY_DESC);
4233 }
4234 }
4235 }
4236 }
4237
4238 else {
4239 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
4240 }
4241
4242 String sql = query.toString();
4243
4244 Query q = session.createQuery(sql);
4245
4246 q.setFirstResult(0);
4247 q.setMaxResults(2);
4248
4249 QueryPos qPos = QueryPos.getInstance(q);
4250
4251 qPos.add(parentCategoryId);
4252
4253 qPos.add(vocabularyId);
4254
4255 if (orderByComparator != null) {
4256 Object[] values = orderByComparator.getOrderByConditionValues(assetCategory);
4257
4258 for (Object value : values) {
4259 qPos.add(value);
4260 }
4261 }
4262
4263 List<AssetCategory> list = q.list();
4264
4265 if (list.size() == 2) {
4266 return list.get(1);
4267 }
4268 else {
4269 return null;
4270 }
4271 }
4272
4273
4281 public List<AssetCategory> findByN_V(String name, long vocabularyId)
4282 throws SystemException {
4283 return findByN_V(name, vocabularyId, QueryUtil.ALL_POS,
4284 QueryUtil.ALL_POS, null);
4285 }
4286
4287
4301 public List<AssetCategory> findByN_V(String name, long vocabularyId,
4302 int start, int end) throws SystemException {
4303 return findByN_V(name, vocabularyId, start, end, null);
4304 }
4305
4306
4321 public List<AssetCategory> findByN_V(String name, long vocabularyId,
4322 int start, int end, OrderByComparator orderByComparator)
4323 throws SystemException {
4324 FinderPath finderPath = null;
4325 Object[] finderArgs = null;
4326
4327 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
4328 (orderByComparator == null)) {
4329 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_V;
4330 finderArgs = new Object[] { name, vocabularyId };
4331 }
4332 else {
4333 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_N_V;
4334 finderArgs = new Object[] {
4335 name, vocabularyId,
4336
4337 start, end, orderByComparator
4338 };
4339 }
4340
4341 List<AssetCategory> list = (List<AssetCategory>)FinderCacheUtil.getResult(finderPath,
4342 finderArgs, this);
4343
4344 if (list == null) {
4345 StringBundler query = null;
4346
4347 if (orderByComparator != null) {
4348 query = new StringBundler(4 +
4349 (orderByComparator.getOrderByFields().length * 3));
4350 }
4351 else {
4352 query = new StringBundler(4);
4353 }
4354
4355 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
4356
4357 if (name == null) {
4358 query.append(_FINDER_COLUMN_N_V_NAME_1);
4359 }
4360 else {
4361 if (name.equals(StringPool.BLANK)) {
4362 query.append(_FINDER_COLUMN_N_V_NAME_3);
4363 }
4364 else {
4365 query.append(_FINDER_COLUMN_N_V_NAME_2);
4366 }
4367 }
4368
4369 query.append(_FINDER_COLUMN_N_V_VOCABULARYID_2);
4370
4371 if (orderByComparator != null) {
4372 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4373 orderByComparator);
4374 }
4375
4376 else {
4377 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
4378 }
4379
4380 String sql = query.toString();
4381
4382 Session session = null;
4383
4384 try {
4385 session = openSession();
4386
4387 Query q = session.createQuery(sql);
4388
4389 QueryPos qPos = QueryPos.getInstance(q);
4390
4391 if (name != null) {
4392 qPos.add(name);
4393 }
4394
4395 qPos.add(vocabularyId);
4396
4397 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
4398 start, end);
4399 }
4400 catch (Exception e) {
4401 throw processException(e);
4402 }
4403 finally {
4404 if (list == null) {
4405 FinderCacheUtil.removeResult(finderPath, finderArgs);
4406 }
4407 else {
4408 cacheResult(list);
4409
4410 FinderCacheUtil.putResult(finderPath, finderArgs, list);
4411 }
4412
4413 closeSession(session);
4414 }
4415 }
4416
4417 return list;
4418 }
4419
4420
4434 public AssetCategory findByN_V_First(String name, long vocabularyId,
4435 OrderByComparator orderByComparator)
4436 throws NoSuchCategoryException, SystemException {
4437 List<AssetCategory> list = findByN_V(name, vocabularyId, 0, 1,
4438 orderByComparator);
4439
4440 if (list.isEmpty()) {
4441 StringBundler msg = new StringBundler(6);
4442
4443 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4444
4445 msg.append("name=");
4446 msg.append(name);
4447
4448 msg.append(", vocabularyId=");
4449 msg.append(vocabularyId);
4450
4451 msg.append(StringPool.CLOSE_CURLY_BRACE);
4452
4453 throw new NoSuchCategoryException(msg.toString());
4454 }
4455 else {
4456 return list.get(0);
4457 }
4458 }
4459
4460
4474 public AssetCategory findByN_V_Last(String name, long vocabularyId,
4475 OrderByComparator orderByComparator)
4476 throws NoSuchCategoryException, SystemException {
4477 int count = countByN_V(name, vocabularyId);
4478
4479 List<AssetCategory> list = findByN_V(name, vocabularyId, count - 1,
4480 count, orderByComparator);
4481
4482 if (list.isEmpty()) {
4483 StringBundler msg = new StringBundler(6);
4484
4485 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4486
4487 msg.append("name=");
4488 msg.append(name);
4489
4490 msg.append(", vocabularyId=");
4491 msg.append(vocabularyId);
4492
4493 msg.append(StringPool.CLOSE_CURLY_BRACE);
4494
4495 throw new NoSuchCategoryException(msg.toString());
4496 }
4497 else {
4498 return list.get(0);
4499 }
4500 }
4501
4502
4517 public AssetCategory[] findByN_V_PrevAndNext(long categoryId, String name,
4518 long vocabularyId, OrderByComparator orderByComparator)
4519 throws NoSuchCategoryException, SystemException {
4520 AssetCategory assetCategory = findByPrimaryKey(categoryId);
4521
4522 Session session = null;
4523
4524 try {
4525 session = openSession();
4526
4527 AssetCategory[] array = new AssetCategoryImpl[3];
4528
4529 array[0] = getByN_V_PrevAndNext(session, assetCategory, name,
4530 vocabularyId, orderByComparator, true);
4531
4532 array[1] = assetCategory;
4533
4534 array[2] = getByN_V_PrevAndNext(session, assetCategory, name,
4535 vocabularyId, orderByComparator, false);
4536
4537 return array;
4538 }
4539 catch (Exception e) {
4540 throw processException(e);
4541 }
4542 finally {
4543 closeSession(session);
4544 }
4545 }
4546
4547 protected AssetCategory getByN_V_PrevAndNext(Session session,
4548 AssetCategory assetCategory, String name, long vocabularyId,
4549 OrderByComparator orderByComparator, boolean previous) {
4550 StringBundler query = null;
4551
4552 if (orderByComparator != null) {
4553 query = new StringBundler(6 +
4554 (orderByComparator.getOrderByFields().length * 6));
4555 }
4556 else {
4557 query = new StringBundler(3);
4558 }
4559
4560 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
4561
4562 if (name == null) {
4563 query.append(_FINDER_COLUMN_N_V_NAME_1);
4564 }
4565 else {
4566 if (name.equals(StringPool.BLANK)) {
4567 query.append(_FINDER_COLUMN_N_V_NAME_3);
4568 }
4569 else {
4570 query.append(_FINDER_COLUMN_N_V_NAME_2);
4571 }
4572 }
4573
4574 query.append(_FINDER_COLUMN_N_V_VOCABULARYID_2);
4575
4576 if (orderByComparator != null) {
4577 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
4578
4579 if (orderByConditionFields.length > 0) {
4580 query.append(WHERE_AND);
4581 }
4582
4583 for (int i = 0; i < orderByConditionFields.length; i++) {
4584 query.append(_ORDER_BY_ENTITY_ALIAS);
4585 query.append(orderByConditionFields[i]);
4586
4587 if ((i + 1) < orderByConditionFields.length) {
4588 if (orderByComparator.isAscending() ^ previous) {
4589 query.append(WHERE_GREATER_THAN_HAS_NEXT);
4590 }
4591 else {
4592 query.append(WHERE_LESSER_THAN_HAS_NEXT);
4593 }
4594 }
4595 else {
4596 if (orderByComparator.isAscending() ^ previous) {
4597 query.append(WHERE_GREATER_THAN);
4598 }
4599 else {
4600 query.append(WHERE_LESSER_THAN);
4601 }
4602 }
4603 }
4604
4605 query.append(ORDER_BY_CLAUSE);
4606
4607 String[] orderByFields = orderByComparator.getOrderByFields();
4608
4609 for (int i = 0; i < orderByFields.length; i++) {
4610 query.append(_ORDER_BY_ENTITY_ALIAS);
4611 query.append(orderByFields[i]);
4612
4613 if ((i + 1) < orderByFields.length) {
4614 if (orderByComparator.isAscending() ^ previous) {
4615 query.append(ORDER_BY_ASC_HAS_NEXT);
4616 }
4617 else {
4618 query.append(ORDER_BY_DESC_HAS_NEXT);
4619 }
4620 }
4621 else {
4622 if (orderByComparator.isAscending() ^ previous) {
4623 query.append(ORDER_BY_ASC);
4624 }
4625 else {
4626 query.append(ORDER_BY_DESC);
4627 }
4628 }
4629 }
4630 }
4631
4632 else {
4633 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
4634 }
4635
4636 String sql = query.toString();
4637
4638 Query q = session.createQuery(sql);
4639
4640 q.setFirstResult(0);
4641 q.setMaxResults(2);
4642
4643 QueryPos qPos = QueryPos.getInstance(q);
4644
4645 if (name != null) {
4646 qPos.add(name);
4647 }
4648
4649 qPos.add(vocabularyId);
4650
4651 if (orderByComparator != null) {
4652 Object[] values = orderByComparator.getOrderByConditionValues(assetCategory);
4653
4654 for (Object value : values) {
4655 qPos.add(value);
4656 }
4657 }
4658
4659 List<AssetCategory> list = q.list();
4660
4661 if (list.size() == 2) {
4662 return list.get(1);
4663 }
4664 else {
4665 return null;
4666 }
4667 }
4668
4669
4679 public AssetCategory findByP_N_V(long parentCategoryId, String name,
4680 long vocabularyId) throws NoSuchCategoryException, SystemException {
4681 AssetCategory assetCategory = fetchByP_N_V(parentCategoryId, name,
4682 vocabularyId);
4683
4684 if (assetCategory == null) {
4685 StringBundler msg = new StringBundler(8);
4686
4687 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4688
4689 msg.append("parentCategoryId=");
4690 msg.append(parentCategoryId);
4691
4692 msg.append(", name=");
4693 msg.append(name);
4694
4695 msg.append(", vocabularyId=");
4696 msg.append(vocabularyId);
4697
4698 msg.append(StringPool.CLOSE_CURLY_BRACE);
4699
4700 if (_log.isWarnEnabled()) {
4701 _log.warn(msg.toString());
4702 }
4703
4704 throw new NoSuchCategoryException(msg.toString());
4705 }
4706
4707 return assetCategory;
4708 }
4709
4710
4719 public AssetCategory fetchByP_N_V(long parentCategoryId, String name,
4720 long vocabularyId) throws SystemException {
4721 return fetchByP_N_V(parentCategoryId, name, vocabularyId, true);
4722 }
4723
4724
4734 public AssetCategory fetchByP_N_V(long parentCategoryId, String name,
4735 long vocabularyId, boolean retrieveFromCache) throws SystemException {
4736 Object[] finderArgs = new Object[] { parentCategoryId, name, vocabularyId };
4737
4738 Object result = null;
4739
4740 if (retrieveFromCache) {
4741 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_P_N_V,
4742 finderArgs, this);
4743 }
4744
4745 if (result == null) {
4746 StringBundler query = new StringBundler(5);
4747
4748 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
4749
4750 query.append(_FINDER_COLUMN_P_N_V_PARENTCATEGORYID_2);
4751
4752 if (name == null) {
4753 query.append(_FINDER_COLUMN_P_N_V_NAME_1);
4754 }
4755 else {
4756 if (name.equals(StringPool.BLANK)) {
4757 query.append(_FINDER_COLUMN_P_N_V_NAME_3);
4758 }
4759 else {
4760 query.append(_FINDER_COLUMN_P_N_V_NAME_2);
4761 }
4762 }
4763
4764 query.append(_FINDER_COLUMN_P_N_V_VOCABULARYID_2);
4765
4766 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
4767
4768 String sql = query.toString();
4769
4770 Session session = null;
4771
4772 try {
4773 session = openSession();
4774
4775 Query q = session.createQuery(sql);
4776
4777 QueryPos qPos = QueryPos.getInstance(q);
4778
4779 qPos.add(parentCategoryId);
4780
4781 if (name != null) {
4782 qPos.add(name);
4783 }
4784
4785 qPos.add(vocabularyId);
4786
4787 List<AssetCategory> list = q.list();
4788
4789 result = list;
4790
4791 AssetCategory assetCategory = null;
4792
4793 if (list.isEmpty()) {
4794 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_P_N_V,
4795 finderArgs, list);
4796 }
4797 else {
4798 assetCategory = list.get(0);
4799
4800 cacheResult(assetCategory);
4801
4802 if ((assetCategory.getParentCategoryId() != parentCategoryId) ||
4803 (assetCategory.getName() == null) ||
4804 !assetCategory.getName().equals(name) ||
4805 (assetCategory.getVocabularyId() != vocabularyId)) {
4806 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_P_N_V,
4807 finderArgs, assetCategory);
4808 }
4809 }
4810
4811 return assetCategory;
4812 }
4813 catch (Exception e) {
4814 throw processException(e);
4815 }
4816 finally {
4817 if (result == null) {
4818 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_P_N_V,
4819 finderArgs);
4820 }
4821
4822 closeSession(session);
4823 }
4824 }
4825 else {
4826 if (result instanceof List<?>) {
4827 return null;
4828 }
4829 else {
4830 return (AssetCategory)result;
4831 }
4832 }
4833 }
4834
4835
4841 public List<AssetCategory> findAll() throws SystemException {
4842 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
4843 }
4844
4845
4857 public List<AssetCategory> findAll(int start, int end)
4858 throws SystemException {
4859 return findAll(start, end, null);
4860 }
4861
4862
4875 public List<AssetCategory> findAll(int start, int end,
4876 OrderByComparator orderByComparator) throws SystemException {
4877 FinderPath finderPath = null;
4878 Object[] finderArgs = new Object[] { start, end, orderByComparator };
4879
4880 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
4881 (orderByComparator == null)) {
4882 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
4883 finderArgs = FINDER_ARGS_EMPTY;
4884 }
4885 else {
4886 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
4887 finderArgs = new Object[] { start, end, orderByComparator };
4888 }
4889
4890 List<AssetCategory> list = (List<AssetCategory>)FinderCacheUtil.getResult(finderPath,
4891 finderArgs, this);
4892
4893 if (list == null) {
4894 StringBundler query = null;
4895 String sql = null;
4896
4897 if (orderByComparator != null) {
4898 query = new StringBundler(2 +
4899 (orderByComparator.getOrderByFields().length * 3));
4900
4901 query.append(_SQL_SELECT_ASSETCATEGORY);
4902
4903 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4904 orderByComparator);
4905
4906 sql = query.toString();
4907 }
4908 else {
4909 sql = _SQL_SELECT_ASSETCATEGORY.concat(AssetCategoryModelImpl.ORDER_BY_JPQL);
4910 }
4911
4912 Session session = null;
4913
4914 try {
4915 session = openSession();
4916
4917 Query q = session.createQuery(sql);
4918
4919 if (orderByComparator == null) {
4920 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
4921 start, end, false);
4922
4923 Collections.sort(list);
4924 }
4925 else {
4926 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
4927 start, end);
4928 }
4929 }
4930 catch (Exception e) {
4931 throw processException(e);
4932 }
4933 finally {
4934 if (list == null) {
4935 FinderCacheUtil.removeResult(finderPath, finderArgs);
4936 }
4937 else {
4938 cacheResult(list);
4939
4940 FinderCacheUtil.putResult(finderPath, finderArgs, list);
4941 }
4942
4943 closeSession(session);
4944 }
4945 }
4946
4947 return list;
4948 }
4949
4950
4956 public void removeByUuid(String uuid) throws SystemException {
4957 for (AssetCategory assetCategory : findByUuid(uuid)) {
4958 remove(assetCategory);
4959 }
4960 }
4961
4962
4969 public void removeByUUID_G(String uuid, long groupId)
4970 throws NoSuchCategoryException, SystemException {
4971 AssetCategory assetCategory = findByUUID_G(uuid, groupId);
4972
4973 remove(assetCategory);
4974 }
4975
4976
4982 public void removeByGroupId(long groupId) throws SystemException {
4983 for (AssetCategory assetCategory : findByGroupId(groupId)) {
4984 remove(assetCategory);
4985 }
4986 }
4987
4988
4994 public void removeByParentCategoryId(long parentCategoryId)
4995 throws SystemException {
4996 for (AssetCategory assetCategory : findByParentCategoryId(
4997 parentCategoryId)) {
4998 remove(assetCategory);
4999 }
5000 }
5001
5002
5008 public void removeByVocabularyId(long vocabularyId)
5009 throws SystemException {
5010 for (AssetCategory assetCategory : findByVocabularyId(vocabularyId)) {
5011 remove(assetCategory);
5012 }
5013 }
5014
5015
5022 public void removeByG_V(long groupId, long vocabularyId)
5023 throws SystemException {
5024 for (AssetCategory assetCategory : findByG_V(groupId, vocabularyId)) {
5025 remove(assetCategory);
5026 }
5027 }
5028
5029
5036 public void removeByP_N(long parentCategoryId, String name)
5037 throws SystemException {
5038 for (AssetCategory assetCategory : findByP_N(parentCategoryId, name)) {
5039 remove(assetCategory);
5040 }
5041 }
5042
5043
5050 public void removeByP_V(long parentCategoryId, long vocabularyId)
5051 throws SystemException {
5052 for (AssetCategory assetCategory : findByP_V(parentCategoryId,
5053 vocabularyId)) {
5054 remove(assetCategory);
5055 }
5056 }
5057
5058
5065 public void removeByN_V(String name, long vocabularyId)
5066 throws SystemException {
5067 for (AssetCategory assetCategory : findByN_V(name, vocabularyId)) {
5068 remove(assetCategory);
5069 }
5070 }
5071
5072
5080 public void removeByP_N_V(long parentCategoryId, String name,
5081 long vocabularyId) throws NoSuchCategoryException, SystemException {
5082 AssetCategory assetCategory = findByP_N_V(parentCategoryId, name,
5083 vocabularyId);
5084
5085 remove(assetCategory);
5086 }
5087
5088
5093 public void removeAll() throws SystemException {
5094 for (AssetCategory assetCategory : findAll()) {
5095 remove(assetCategory);
5096 }
5097 }
5098
5099
5106 public int countByUuid(String uuid) throws SystemException {
5107 Object[] finderArgs = new Object[] { uuid };
5108
5109 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID,
5110 finderArgs, this);
5111
5112 if (count == null) {
5113 StringBundler query = new StringBundler(2);
5114
5115 query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
5116
5117 if (uuid == null) {
5118 query.append(_FINDER_COLUMN_UUID_UUID_1);
5119 }
5120 else {
5121 if (uuid.equals(StringPool.BLANK)) {
5122 query.append(_FINDER_COLUMN_UUID_UUID_3);
5123 }
5124 else {
5125 query.append(_FINDER_COLUMN_UUID_UUID_2);
5126 }
5127 }
5128
5129 String sql = query.toString();
5130
5131 Session session = null;
5132
5133 try {
5134 session = openSession();
5135
5136 Query q = session.createQuery(sql);
5137
5138 QueryPos qPos = QueryPos.getInstance(q);
5139
5140 if (uuid != null) {
5141 qPos.add(uuid);
5142 }
5143
5144 count = (Long)q.uniqueResult();
5145 }
5146 catch (Exception e) {
5147 throw processException(e);
5148 }
5149 finally {
5150 if (count == null) {
5151 count = Long.valueOf(0);
5152 }
5153
5154 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID,
5155 finderArgs, count);
5156
5157 closeSession(session);
5158 }
5159 }
5160
5161 return count.intValue();
5162 }
5163
5164
5172 public int countByUUID_G(String uuid, long groupId)
5173 throws SystemException {
5174 Object[] finderArgs = new Object[] { uuid, groupId };
5175
5176 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID_G,
5177 finderArgs, this);
5178
5179 if (count == null) {
5180 StringBundler query = new StringBundler(3);
5181
5182 query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
5183
5184 if (uuid == null) {
5185 query.append(_FINDER_COLUMN_UUID_G_UUID_1);
5186 }
5187 else {
5188 if (uuid.equals(StringPool.BLANK)) {
5189 query.append(_FINDER_COLUMN_UUID_G_UUID_3);
5190 }
5191 else {
5192 query.append(_FINDER_COLUMN_UUID_G_UUID_2);
5193 }
5194 }
5195
5196 query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
5197
5198 String sql = query.toString();
5199
5200 Session session = null;
5201
5202 try {
5203 session = openSession();
5204
5205 Query q = session.createQuery(sql);
5206
5207 QueryPos qPos = QueryPos.getInstance(q);
5208
5209 if (uuid != null) {
5210 qPos.add(uuid);
5211 }
5212
5213 qPos.add(groupId);
5214
5215 count = (Long)q.uniqueResult();
5216 }
5217 catch (Exception e) {
5218 throw processException(e);
5219 }
5220 finally {
5221 if (count == null) {
5222 count = Long.valueOf(0);
5223 }
5224
5225 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G,
5226 finderArgs, count);
5227
5228 closeSession(session);
5229 }
5230 }
5231
5232 return count.intValue();
5233 }
5234
5235
5242 public int countByGroupId(long groupId) throws SystemException {
5243 Object[] finderArgs = new Object[] { groupId };
5244
5245 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_GROUPID,
5246 finderArgs, this);
5247
5248 if (count == null) {
5249 StringBundler query = new StringBundler(2);
5250
5251 query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
5252
5253 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
5254
5255 String sql = query.toString();
5256
5257 Session session = null;
5258
5259 try {
5260 session = openSession();
5261
5262 Query q = session.createQuery(sql);
5263
5264 QueryPos qPos = QueryPos.getInstance(q);
5265
5266 qPos.add(groupId);
5267
5268 count = (Long)q.uniqueResult();
5269 }
5270 catch (Exception e) {
5271 throw processException(e);
5272 }
5273 finally {
5274 if (count == null) {
5275 count = Long.valueOf(0);
5276 }
5277
5278 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_GROUPID,
5279 finderArgs, count);
5280
5281 closeSession(session);
5282 }
5283 }
5284
5285 return count.intValue();
5286 }
5287
5288
5295 public int filterCountByGroupId(long groupId) throws SystemException {
5296 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
5297 return countByGroupId(groupId);
5298 }
5299
5300 StringBundler query = new StringBundler(2);
5301
5302 query.append(_FILTER_SQL_COUNT_ASSETCATEGORY_WHERE);
5303
5304 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
5305
5306 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
5307 AssetCategory.class.getName(),
5308 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
5309
5310 Session session = null;
5311
5312 try {
5313 session = openSession();
5314
5315 SQLQuery q = session.createSQLQuery(sql);
5316
5317 q.addScalar(COUNT_COLUMN_NAME,
5318 com.liferay.portal.kernel.dao.orm.Type.LONG);
5319
5320 QueryPos qPos = QueryPos.getInstance(q);
5321
5322 qPos.add(groupId);
5323
5324 Long count = (Long)q.uniqueResult();
5325
5326 return count.intValue();
5327 }
5328 catch (Exception e) {
5329 throw processException(e);
5330 }
5331 finally {
5332 closeSession(session);
5333 }
5334 }
5335
5336
5343 public int countByParentCategoryId(long parentCategoryId)
5344 throws SystemException {
5345 Object[] finderArgs = new Object[] { parentCategoryId };
5346
5347 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_PARENTCATEGORYID,
5348 finderArgs, this);
5349
5350 if (count == null) {
5351 StringBundler query = new StringBundler(2);
5352
5353 query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
5354
5355 query.append(_FINDER_COLUMN_PARENTCATEGORYID_PARENTCATEGORYID_2);
5356
5357 String sql = query.toString();
5358
5359 Session session = null;
5360
5361 try {
5362 session = openSession();
5363
5364 Query q = session.createQuery(sql);
5365
5366 QueryPos qPos = QueryPos.getInstance(q);
5367
5368 qPos.add(parentCategoryId);
5369
5370 count = (Long)q.uniqueResult();
5371 }
5372 catch (Exception e) {
5373 throw processException(e);
5374 }
5375 finally {
5376 if (count == null) {
5377 count = Long.valueOf(0);
5378 }
5379
5380 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_PARENTCATEGORYID,
5381 finderArgs, count);
5382
5383 closeSession(session);
5384 }
5385 }
5386
5387 return count.intValue();
5388 }
5389
5390
5397 public int countByVocabularyId(long vocabularyId) throws SystemException {
5398 Object[] finderArgs = new Object[] { vocabularyId };
5399
5400 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_VOCABULARYID,
5401 finderArgs, this);
5402
5403 if (count == null) {
5404 StringBundler query = new StringBundler(2);
5405
5406 query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
5407
5408 query.append(_FINDER_COLUMN_VOCABULARYID_VOCABULARYID_2);
5409
5410 String sql = query.toString();
5411
5412 Session session = null;
5413
5414 try {
5415 session = openSession();
5416
5417 Query q = session.createQuery(sql);
5418
5419 QueryPos qPos = QueryPos.getInstance(q);
5420
5421 qPos.add(vocabularyId);
5422
5423 count = (Long)q.uniqueResult();
5424 }
5425 catch (Exception e) {
5426 throw processException(e);
5427 }
5428 finally {
5429 if (count == null) {
5430 count = Long.valueOf(0);
5431 }
5432
5433 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_VOCABULARYID,
5434 finderArgs, count);
5435
5436 closeSession(session);
5437 }
5438 }
5439
5440 return count.intValue();
5441 }
5442
5443
5451 public int countByG_V(long groupId, long vocabularyId)
5452 throws SystemException {
5453 Object[] finderArgs = new Object[] { groupId, vocabularyId };
5454
5455 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_V,
5456 finderArgs, this);
5457
5458 if (count == null) {
5459 StringBundler query = new StringBundler(3);
5460
5461 query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
5462
5463 query.append(_FINDER_COLUMN_G_V_GROUPID_2);
5464
5465 query.append(_FINDER_COLUMN_G_V_VOCABULARYID_2);
5466
5467 String sql = query.toString();
5468
5469 Session session = null;
5470
5471 try {
5472 session = openSession();
5473
5474 Query q = session.createQuery(sql);
5475
5476 QueryPos qPos = QueryPos.getInstance(q);
5477
5478 qPos.add(groupId);
5479
5480 qPos.add(vocabularyId);
5481
5482 count = (Long)q.uniqueResult();
5483 }
5484 catch (Exception e) {
5485 throw processException(e);
5486 }
5487 finally {
5488 if (count == null) {
5489 count = Long.valueOf(0);
5490 }
5491
5492 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_V, finderArgs,
5493 count);
5494
5495 closeSession(session);
5496 }
5497 }
5498
5499 return count.intValue();
5500 }
5501
5502
5510 public int filterCountByG_V(long groupId, long vocabularyId)
5511 throws SystemException {
5512 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
5513 return countByG_V(groupId, vocabularyId);
5514 }
5515
5516 StringBundler query = new StringBundler(3);
5517
5518 query.append(_FILTER_SQL_COUNT_ASSETCATEGORY_WHERE);
5519
5520 query.append(_FINDER_COLUMN_G_V_GROUPID_2);
5521
5522 query.append(_FINDER_COLUMN_G_V_VOCABULARYID_2);
5523
5524 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
5525 AssetCategory.class.getName(),
5526 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
5527
5528 Session session = null;
5529
5530 try {
5531 session = openSession();
5532
5533 SQLQuery q = session.createSQLQuery(sql);
5534
5535 q.addScalar(COUNT_COLUMN_NAME,
5536 com.liferay.portal.kernel.dao.orm.Type.LONG);
5537
5538 QueryPos qPos = QueryPos.getInstance(q);
5539
5540 qPos.add(groupId);
5541
5542 qPos.add(vocabularyId);
5543
5544 Long count = (Long)q.uniqueResult();
5545
5546 return count.intValue();
5547 }
5548 catch (Exception e) {
5549 throw processException(e);
5550 }
5551 finally {
5552 closeSession(session);
5553 }
5554 }
5555
5556
5564 public int countByP_N(long parentCategoryId, String name)
5565 throws SystemException {
5566 Object[] finderArgs = new Object[] { parentCategoryId, name };
5567
5568 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_P_N,
5569 finderArgs, this);
5570
5571 if (count == null) {
5572 StringBundler query = new StringBundler(3);
5573
5574 query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
5575
5576 query.append(_FINDER_COLUMN_P_N_PARENTCATEGORYID_2);
5577
5578 if (name == null) {
5579 query.append(_FINDER_COLUMN_P_N_NAME_1);
5580 }
5581 else {
5582 if (name.equals(StringPool.BLANK)) {
5583 query.append(_FINDER_COLUMN_P_N_NAME_3);
5584 }
5585 else {
5586 query.append(_FINDER_COLUMN_P_N_NAME_2);
5587 }
5588 }
5589
5590 String sql = query.toString();
5591
5592 Session session = null;
5593
5594 try {
5595 session = openSession();
5596
5597 Query q = session.createQuery(sql);
5598
5599 QueryPos qPos = QueryPos.getInstance(q);
5600
5601 qPos.add(parentCategoryId);
5602
5603 if (name != null) {
5604 qPos.add(name);
5605 }
5606
5607 count = (Long)q.uniqueResult();
5608 }
5609 catch (Exception e) {
5610 throw processException(e);
5611 }
5612 finally {
5613 if (count == null) {
5614 count = Long.valueOf(0);
5615 }
5616
5617 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_P_N, finderArgs,
5618 count);
5619
5620 closeSession(session);
5621 }
5622 }
5623
5624 return count.intValue();
5625 }
5626
5627
5635 public int countByP_V(long parentCategoryId, long vocabularyId)
5636 throws SystemException {
5637 Object[] finderArgs = new Object[] { parentCategoryId, vocabularyId };
5638
5639 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_P_V,
5640 finderArgs, this);
5641
5642 if (count == null) {
5643 StringBundler query = new StringBundler(3);
5644
5645 query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
5646
5647 query.append(_FINDER_COLUMN_P_V_PARENTCATEGORYID_2);
5648
5649 query.append(_FINDER_COLUMN_P_V_VOCABULARYID_2);
5650
5651 String sql = query.toString();
5652
5653 Session session = null;
5654
5655 try {
5656 session = openSession();
5657
5658 Query q = session.createQuery(sql);
5659
5660 QueryPos qPos = QueryPos.getInstance(q);
5661
5662 qPos.add(parentCategoryId);
5663
5664 qPos.add(vocabularyId);
5665
5666 count = (Long)q.uniqueResult();
5667 }
5668 catch (Exception e) {
5669 throw processException(e);
5670 }
5671 finally {
5672 if (count == null) {
5673 count = Long.valueOf(0);
5674 }
5675
5676 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_P_V, finderArgs,
5677 count);
5678
5679 closeSession(session);
5680 }
5681 }
5682
5683 return count.intValue();
5684 }
5685
5686
5694 public int countByN_V(String name, long vocabularyId)
5695 throws SystemException {
5696 Object[] finderArgs = new Object[] { name, vocabularyId };
5697
5698 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_N_V,
5699 finderArgs, this);
5700
5701 if (count == null) {
5702 StringBundler query = new StringBundler(3);
5703
5704 query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
5705
5706 if (name == null) {
5707 query.append(_FINDER_COLUMN_N_V_NAME_1);
5708 }
5709 else {
5710 if (name.equals(StringPool.BLANK)) {
5711 query.append(_FINDER_COLUMN_N_V_NAME_3);
5712 }
5713 else {
5714 query.append(_FINDER_COLUMN_N_V_NAME_2);
5715 }
5716 }
5717
5718 query.append(_FINDER_COLUMN_N_V_VOCABULARYID_2);
5719
5720 String sql = query.toString();
5721
5722 Session session = null;
5723
5724 try {
5725 session = openSession();
5726
5727 Query q = session.createQuery(sql);
5728
5729 QueryPos qPos = QueryPos.getInstance(q);
5730
5731 if (name != null) {
5732 qPos.add(name);
5733 }
5734
5735 qPos.add(vocabularyId);
5736
5737 count = (Long)q.uniqueResult();
5738 }
5739 catch (Exception e) {
5740 throw processException(e);
5741 }
5742 finally {
5743 if (count == null) {
5744 count = Long.valueOf(0);
5745 }
5746
5747 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_N_V, finderArgs,
5748 count);
5749
5750 closeSession(session);
5751 }
5752 }
5753
5754 return count.intValue();
5755 }
5756
5757
5766 public int countByP_N_V(long parentCategoryId, String name,
5767 long vocabularyId) throws SystemException {
5768 Object[] finderArgs = new Object[] { parentCategoryId, name, vocabularyId };
5769
5770 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_P_N_V,
5771 finderArgs, this);
5772
5773 if (count == null) {
5774 StringBundler query = new StringBundler(4);
5775
5776 query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
5777
5778 query.append(_FINDER_COLUMN_P_N_V_PARENTCATEGORYID_2);
5779
5780 if (name == null) {
5781 query.append(_FINDER_COLUMN_P_N_V_NAME_1);
5782 }
5783 else {
5784 if (name.equals(StringPool.BLANK)) {
5785 query.append(_FINDER_COLUMN_P_N_V_NAME_3);
5786 }
5787 else {
5788 query.append(_FINDER_COLUMN_P_N_V_NAME_2);
5789 }
5790 }
5791
5792 query.append(_FINDER_COLUMN_P_N_V_VOCABULARYID_2);
5793
5794 String sql = query.toString();
5795
5796 Session session = null;
5797
5798 try {
5799 session = openSession();
5800
5801 Query q = session.createQuery(sql);
5802
5803 QueryPos qPos = QueryPos.getInstance(q);
5804
5805 qPos.add(parentCategoryId);
5806
5807 if (name != null) {
5808 qPos.add(name);
5809 }
5810
5811 qPos.add(vocabularyId);
5812
5813 count = (Long)q.uniqueResult();
5814 }
5815 catch (Exception e) {
5816 throw processException(e);
5817 }
5818 finally {
5819 if (count == null) {
5820 count = Long.valueOf(0);
5821 }
5822
5823 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_P_N_V,
5824 finderArgs, count);
5825
5826 closeSession(session);
5827 }
5828 }
5829
5830 return count.intValue();
5831 }
5832
5833
5839 public int countAll() throws SystemException {
5840 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
5841 FINDER_ARGS_EMPTY, this);
5842
5843 if (count == null) {
5844 Session session = null;
5845
5846 try {
5847 session = openSession();
5848
5849 Query q = session.createQuery(_SQL_COUNT_ASSETCATEGORY);
5850
5851 count = (Long)q.uniqueResult();
5852 }
5853 catch (Exception e) {
5854 throw processException(e);
5855 }
5856 finally {
5857 if (count == null) {
5858 count = Long.valueOf(0);
5859 }
5860
5861 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
5862 FINDER_ARGS_EMPTY, count);
5863
5864 closeSession(session);
5865 }
5866 }
5867
5868 return count.intValue();
5869 }
5870
5871
5878 public List<com.liferay.portlet.asset.model.AssetEntry> getAssetEntries(
5879 long pk) throws SystemException {
5880 return getAssetEntries(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
5881 }
5882
5883
5896 public List<com.liferay.portlet.asset.model.AssetEntry> getAssetEntries(
5897 long pk, int start, int end) throws SystemException {
5898 return getAssetEntries(pk, start, end, null);
5899 }
5900
5901 public static final FinderPath FINDER_PATH_GET_ASSETENTRIES = new FinderPath(com.liferay.portlet.asset.model.impl.AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
5902 AssetCategoryModelImpl.FINDER_CACHE_ENABLED_ASSETENTRIES_ASSETCATEGORIES,
5903 com.liferay.portlet.asset.model.impl.AssetEntryImpl.class,
5904 AssetCategoryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME,
5905 "getAssetEntries",
5906 new String[] {
5907 Long.class.getName(), "java.lang.Integer", "java.lang.Integer",
5908 "com.liferay.portal.kernel.util.OrderByComparator"
5909 });
5910
5911
5925 public List<com.liferay.portlet.asset.model.AssetEntry> getAssetEntries(
5926 long pk, int start, int end, OrderByComparator orderByComparator)
5927 throws SystemException {
5928 Object[] finderArgs = new Object[] { pk, start, end, orderByComparator };
5929
5930 List<com.liferay.portlet.asset.model.AssetEntry> list = (List<com.liferay.portlet.asset.model.AssetEntry>)FinderCacheUtil.getResult(FINDER_PATH_GET_ASSETENTRIES,
5931 finderArgs, this);
5932
5933 if (list == null) {
5934 Session session = null;
5935
5936 try {
5937 session = openSession();
5938
5939 String sql = null;
5940
5941 if (orderByComparator != null) {
5942 sql = _SQL_GETASSETENTRIES.concat(ORDER_BY_CLAUSE)
5943 .concat(orderByComparator.getOrderBy());
5944 }
5945 else {
5946 sql = _SQL_GETASSETENTRIES;
5947 }
5948
5949 SQLQuery q = session.createSQLQuery(sql);
5950
5951 q.addEntity("AssetEntry",
5952 com.liferay.portlet.asset.model.impl.AssetEntryImpl.class);
5953
5954 QueryPos qPos = QueryPos.getInstance(q);
5955
5956 qPos.add(pk);
5957
5958 list = (List<com.liferay.portlet.asset.model.AssetEntry>)QueryUtil.list(q,
5959 getDialect(), start, end);
5960 }
5961 catch (Exception e) {
5962 throw processException(e);
5963 }
5964 finally {
5965 if (list == null) {
5966 FinderCacheUtil.removeResult(FINDER_PATH_GET_ASSETENTRIES,
5967 finderArgs);
5968 }
5969 else {
5970 assetEntryPersistence.cacheResult(list);
5971
5972 FinderCacheUtil.putResult(FINDER_PATH_GET_ASSETENTRIES,
5973 finderArgs, list);
5974 }
5975
5976 closeSession(session);
5977 }
5978 }
5979
5980 return list;
5981 }
5982
5983 public static final FinderPath FINDER_PATH_GET_ASSETENTRIES_SIZE = new FinderPath(com.liferay.portlet.asset.model.impl.AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
5984 AssetCategoryModelImpl.FINDER_CACHE_ENABLED_ASSETENTRIES_ASSETCATEGORIES,
5985 Long.class,
5986 AssetCategoryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME,
5987 "getAssetEntriesSize", new String[] { Long.class.getName() });
5988
5989
5996 public int getAssetEntriesSize(long pk) throws SystemException {
5997 Object[] finderArgs = new Object[] { pk };
5998
5999 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_GET_ASSETENTRIES_SIZE,
6000 finderArgs, this);
6001
6002 if (count == null) {
6003 Session session = null;
6004
6005 try {
6006 session = openSession();
6007
6008 SQLQuery q = session.createSQLQuery(_SQL_GETASSETENTRIESSIZE);
6009
6010 q.addScalar(COUNT_COLUMN_NAME,
6011 com.liferay.portal.kernel.dao.orm.Type.LONG);
6012
6013 QueryPos qPos = QueryPos.getInstance(q);
6014
6015 qPos.add(pk);
6016
6017 count = (Long)q.uniqueResult();
6018 }
6019 catch (Exception e) {
6020 throw processException(e);
6021 }
6022 finally {
6023 if (count == null) {
6024 count = Long.valueOf(0);
6025 }
6026
6027 FinderCacheUtil.putResult(FINDER_PATH_GET_ASSETENTRIES_SIZE,
6028 finderArgs, count);
6029
6030 closeSession(session);
6031 }
6032 }
6033
6034 return count.intValue();
6035 }
6036
6037 public static final FinderPath FINDER_PATH_CONTAINS_ASSETENTRY = new FinderPath(com.liferay.portlet.asset.model.impl.AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
6038 AssetCategoryModelImpl.FINDER_CACHE_ENABLED_ASSETENTRIES_ASSETCATEGORIES,
6039 Boolean.class,
6040 AssetCategoryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME,
6041 "containsAssetEntry",
6042 new String[] { Long.class.getName(), Long.class.getName() });
6043
6044
6052 public boolean containsAssetEntry(long pk, long assetEntryPK)
6053 throws SystemException {
6054 Object[] finderArgs = new Object[] { pk, assetEntryPK };
6055
6056 Boolean value = (Boolean)FinderCacheUtil.getResult(FINDER_PATH_CONTAINS_ASSETENTRY,
6057 finderArgs, this);
6058
6059 if (value == null) {
6060 try {
6061 value = Boolean.valueOf(containsAssetEntry.contains(pk,
6062 assetEntryPK));
6063 }
6064 catch (Exception e) {
6065 throw processException(e);
6066 }
6067 finally {
6068 if (value == null) {
6069 value = Boolean.FALSE;
6070 }
6071
6072 FinderCacheUtil.putResult(FINDER_PATH_CONTAINS_ASSETENTRY,
6073 finderArgs, value);
6074 }
6075 }
6076
6077 return value.booleanValue();
6078 }
6079
6080
6087 public boolean containsAssetEntries(long pk) throws SystemException {
6088 if (getAssetEntriesSize(pk) > 0) {
6089 return true;
6090 }
6091 else {
6092 return false;
6093 }
6094 }
6095
6096
6103 public void addAssetEntry(long pk, long assetEntryPK)
6104 throws SystemException {
6105 try {
6106 addAssetEntry.add(pk, assetEntryPK);
6107 }
6108 catch (Exception e) {
6109 throw processException(e);
6110 }
6111 finally {
6112 FinderCacheUtil.clearCache(AssetCategoryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
6113 }
6114 }
6115
6116
6123 public void addAssetEntry(long pk,
6124 com.liferay.portlet.asset.model.AssetEntry assetEntry)
6125 throws SystemException {
6126 try {
6127 addAssetEntry.add(pk, assetEntry.getPrimaryKey());
6128 }
6129 catch (Exception e) {
6130 throw processException(e);
6131 }
6132 finally {
6133 FinderCacheUtil.clearCache(AssetCategoryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
6134 }
6135 }
6136
6137
6144 public void addAssetEntries(long pk, long[] assetEntryPKs)
6145 throws SystemException {
6146 try {
6147 for (long assetEntryPK : assetEntryPKs) {
6148 addAssetEntry.add(pk, assetEntryPK);
6149 }
6150 }
6151 catch (Exception e) {
6152 throw processException(e);
6153 }
6154 finally {
6155 FinderCacheUtil.clearCache(AssetCategoryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
6156 }
6157 }
6158
6159
6166 public void addAssetEntries(long pk,
6167 List<com.liferay.portlet.asset.model.AssetEntry> assetEntries)
6168 throws SystemException {
6169 try {
6170 for (com.liferay.portlet.asset.model.AssetEntry assetEntry : assetEntries) {
6171 addAssetEntry.add(pk, assetEntry.getPrimaryKey());
6172 }
6173 }
6174 catch (Exception e) {
6175 throw processException(e);
6176 }
6177 finally {
6178 FinderCacheUtil.clearCache(AssetCategoryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
6179 }
6180 }
6181
6182
6188 public void clearAssetEntries(long pk) throws SystemException {
6189 try {
6190 clearAssetEntries.clear(pk);
6191 }
6192 catch (Exception e) {
6193 throw processException(e);
6194 }
6195 finally {
6196 FinderCacheUtil.clearCache(AssetCategoryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
6197 }
6198 }
6199
6200
6207 public void removeAssetEntry(long pk, long assetEntryPK)
6208 throws SystemException {
6209 try {
6210 removeAssetEntry.remove(pk, assetEntryPK);
6211 }
6212 catch (Exception e) {
6213 throw processException(e);
6214 }
6215 finally {
6216 FinderCacheUtil.clearCache(AssetCategoryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
6217 }
6218 }
6219
6220
6227 public void removeAssetEntry(long pk,
6228 com.liferay.portlet.asset.model.AssetEntry assetEntry)
6229 throws SystemException {
6230 try {
6231 removeAssetEntry.remove(pk, assetEntry.getPrimaryKey());
6232 }
6233 catch (Exception e) {
6234 throw processException(e);
6235 }
6236 finally {
6237 FinderCacheUtil.clearCache(AssetCategoryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
6238 }
6239 }
6240
6241
6248 public void removeAssetEntries(long pk, long[] assetEntryPKs)
6249 throws SystemException {
6250 try {
6251 for (long assetEntryPK : assetEntryPKs) {
6252 removeAssetEntry.remove(pk, assetEntryPK);
6253 }
6254 }
6255 catch (Exception e) {
6256 throw processException(e);
6257 }
6258 finally {
6259 FinderCacheUtil.clearCache(AssetCategoryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
6260 }
6261 }
6262
6263
6270 public void removeAssetEntries(long pk,
6271 List<com.liferay.portlet.asset.model.AssetEntry> assetEntries)
6272 throws SystemException {
6273 try {
6274 for (com.liferay.portlet.asset.model.AssetEntry assetEntry : assetEntries) {
6275 removeAssetEntry.remove(pk, assetEntry.getPrimaryKey());
6276 }
6277 }
6278 catch (Exception e) {
6279 throw processException(e);
6280 }
6281 finally {
6282 FinderCacheUtil.clearCache(AssetCategoryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
6283 }
6284 }
6285
6286
6293 public void setAssetEntries(long pk, long[] assetEntryPKs)
6294 throws SystemException {
6295 try {
6296 Set<Long> assetEntryPKSet = SetUtil.fromArray(assetEntryPKs);
6297
6298 List<com.liferay.portlet.asset.model.AssetEntry> assetEntries = getAssetEntries(pk);
6299
6300 for (com.liferay.portlet.asset.model.AssetEntry assetEntry : assetEntries) {
6301 if (!assetEntryPKSet.remove(assetEntry.getPrimaryKey())) {
6302 removeAssetEntry.remove(pk, assetEntry.getPrimaryKey());
6303 }
6304 }
6305
6306 for (Long assetEntryPK : assetEntryPKSet) {
6307 addAssetEntry.add(pk, assetEntryPK);
6308 }
6309 }
6310 catch (Exception e) {
6311 throw processException(e);
6312 }
6313 finally {
6314 FinderCacheUtil.clearCache(AssetCategoryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
6315 }
6316 }
6317
6318
6325 public void setAssetEntries(long pk,
6326 List<com.liferay.portlet.asset.model.AssetEntry> assetEntries)
6327 throws SystemException {
6328 try {
6329 long[] assetEntryPKs = new long[assetEntries.size()];
6330
6331 for (int i = 0; i < assetEntries.size(); i++) {
6332 com.liferay.portlet.asset.model.AssetEntry assetEntry = assetEntries.get(i);
6333
6334 assetEntryPKs[i] = assetEntry.getPrimaryKey();
6335 }
6336
6337 setAssetEntries(pk, assetEntryPKs);
6338 }
6339 catch (Exception e) {
6340 throw processException(e);
6341 }
6342 finally {
6343 FinderCacheUtil.clearCache(AssetCategoryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
6344 }
6345 }
6346
6347
6357 public void rebuildTree(long groupId, boolean force)
6358 throws SystemException {
6359 if (!rebuildTreeEnabled) {
6360 return;
6361 }
6362
6363 if (force || (countOrphanTreeNodes(groupId) > 0)) {
6364 rebuildTree(groupId, 0, 1);
6365
6366 CacheRegistryUtil.clear(AssetCategoryImpl.class.getName());
6367 EntityCacheUtil.clearCache(AssetCategoryImpl.class.getName());
6368 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
6369 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
6370 }
6371 }
6372
6373 public void setRebuildTreeEnabled(boolean rebuildTreeEnabled) {
6374 this.rebuildTreeEnabled = rebuildTreeEnabled;
6375 }
6376
6377 protected long countOrphanTreeNodes(long groupId) throws SystemException {
6378 Session session = null;
6379
6380 try {
6381 session = openSession();
6382
6383 SQLQuery q = session.createSQLQuery(
6384 "SELECT COUNT(*) AS COUNT_VALUE FROM AssetCategory WHERE groupId = ? AND (leftCategoryId = 0 OR leftCategoryId IS NULL OR rightCategoryId = 0 OR rightCategoryId IS NULL)");
6385
6386 q.addScalar(COUNT_COLUMN_NAME,
6387 com.liferay.portal.kernel.dao.orm.Type.LONG);
6388
6389 QueryPos qPos = QueryPos.getInstance(q);
6390
6391 qPos.add(groupId);
6392
6393 return (Long)q.uniqueResult();
6394 }
6395 catch (Exception e) {
6396 throw processException(e);
6397 }
6398 finally {
6399 closeSession(session);
6400 }
6401 }
6402
6403 protected void expandNoChildrenLeftCategoryId(long groupId,
6404 long leftCategoryId, List<Long> childrenCategoryIds, long delta) {
6405 String sql = "UPDATE AssetCategory SET leftcategoryId = (leftcategoryId + ?) WHERE (groupId = ?) AND (leftcategoryId > ?) AND (categoryId NOT IN (" +
6406 StringUtil.merge(childrenCategoryIds) + "))";
6407
6408 SqlUpdate _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
6409 sql,
6410 new int[] {
6411 java.sql.Types.BIGINT, java.sql.Types.BIGINT,
6412 java.sql.Types.BIGINT
6413 });
6414
6415 _sqlUpdate.update(new Object[] { delta, groupId, leftCategoryId });
6416 }
6417
6418 protected void expandNoChildrenRightCategoryId(long groupId,
6419 long rightCategoryId, List<Long> childrenCategoryIds, long delta) {
6420 String sql = "UPDATE AssetCategory SET rightcategoryId = (rightcategoryId + ?) WHERE (groupId = ?) AND (rightcategoryId > ?) AND (categoryId NOT IN (" +
6421 StringUtil.merge(childrenCategoryIds) + "))";
6422
6423 SqlUpdate _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
6424 sql,
6425 new int[] {
6426 java.sql.Types.BIGINT, java.sql.Types.BIGINT,
6427 java.sql.Types.BIGINT
6428 });
6429
6430 _sqlUpdate.update(new Object[] { delta, groupId, rightCategoryId });
6431 }
6432
6433 protected void expandTree(AssetCategory assetCategory,
6434 List<Long> childrenCategoryIds) throws SystemException {
6435 if (!rebuildTreeEnabled) {
6436 return;
6437 }
6438
6439 long groupId = assetCategory.getGroupId();
6440
6441 long lastRightCategoryId = getLastRightCategoryId(groupId,
6442 assetCategory.getParentCategoryId());
6443
6444 long leftCategoryId = 2;
6445 long rightCategoryId = 3;
6446
6447 if (lastRightCategoryId > 0) {
6448 leftCategoryId = lastRightCategoryId + 1;
6449
6450 long childrenDistance = assetCategory.getRightCategoryId() -
6451 assetCategory.getLeftCategoryId();
6452
6453 if (childrenDistance > 1) {
6454 rightCategoryId = leftCategoryId + childrenDistance;
6455
6456 updateChildrenTree(groupId, childrenCategoryIds,
6457 leftCategoryId - assetCategory.getLeftCategoryId());
6458
6459 expandNoChildrenLeftCategoryId(groupId, lastRightCategoryId,
6460 childrenCategoryIds, childrenDistance + 1);
6461 expandNoChildrenRightCategoryId(groupId, lastRightCategoryId,
6462 childrenCategoryIds, childrenDistance + 1);
6463 }
6464 else {
6465 rightCategoryId = lastRightCategoryId + 2;
6466
6467 expandTreeLeftCategoryId.expand(groupId, lastRightCategoryId);
6468 expandTreeRightCategoryId.expand(groupId, lastRightCategoryId);
6469 }
6470
6471 CacheRegistryUtil.clear(AssetCategoryImpl.class.getName());
6472 EntityCacheUtil.clearCache(AssetCategoryImpl.class.getName());
6473 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
6474 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
6475 }
6476
6477 assetCategory.setLeftCategoryId(leftCategoryId);
6478 assetCategory.setRightCategoryId(rightCategoryId);
6479 }
6480
6481 protected List<Long> getChildrenTreeCategoryIds(
6482 AssetCategory parentAssetCategory) throws SystemException {
6483 Session session = null;
6484
6485 try {
6486 session = openSession();
6487
6488 SQLQuery q = session.createSQLQuery(
6489 "SELECT categoryId FROM AssetCategory WHERE (groupId = ?) AND (leftcategoryId BETWEEN ? AND ?)");
6490
6491 q.addScalar("CategoryId",
6492 com.liferay.portal.kernel.dao.orm.Type.LONG);
6493
6494 QueryPos qPos = QueryPos.getInstance(q);
6495
6496 qPos.add(parentAssetCategory.getGroupId());
6497 qPos.add(parentAssetCategory.getLeftCategoryId() + 1);
6498 qPos.add(parentAssetCategory.getRightCategoryId());
6499
6500 return q.list();
6501 }
6502 catch (Exception e) {
6503 throw processException(e);
6504 }
6505 finally {
6506 closeSession(session);
6507 }
6508 }
6509
6510 protected long getLastRightCategoryId(long groupId, long parentCategoryId)
6511 throws SystemException {
6512 Session session = null;
6513
6514 try {
6515 session = openSession();
6516
6517 SQLQuery q = session.createSQLQuery(
6518 "SELECT rightCategoryId FROM AssetCategory WHERE (groupId = ?) AND (parentCategoryId = ?) ORDER BY rightCategoryId DESC");
6519
6520 q.addScalar("rightCategoryId",
6521 com.liferay.portal.kernel.dao.orm.Type.LONG);
6522
6523 QueryPos qPos = QueryPos.getInstance(q);
6524
6525 qPos.add(groupId);
6526 qPos.add(parentCategoryId);
6527
6528 List<Long> list = (List<Long>)QueryUtil.list(q, getDialect(), 0, 1);
6529
6530 if (list.isEmpty()) {
6531 if (parentCategoryId > 0) {
6532 session.clear();
6533
6534 AssetCategory parentAssetCategory = findByPrimaryKey(parentCategoryId);
6535
6536 return parentAssetCategory.getLeftCategoryId();
6537 }
6538
6539 return 0;
6540 }
6541 else {
6542 return list.get(0);
6543 }
6544 }
6545 catch (Exception e) {
6546 throw processException(e);
6547 }
6548 finally {
6549 closeSession(session);
6550 }
6551 }
6552
6553 protected long rebuildTree(long groupId, long parentCategoryId,
6554 long leftCategoryId) throws SystemException {
6555 if (!rebuildTreeEnabled) {
6556 return 0;
6557 }
6558
6559 List<Long> categoryIds = null;
6560
6561 Session session = null;
6562
6563 try {
6564 session = openSession();
6565
6566 SQLQuery q = session.createSQLQuery(
6567 "SELECT categoryId FROM AssetCategory WHERE groupId = ? AND parentCategoryId = ? ORDER BY categoryId ASC");
6568
6569 q.addScalar("categoryId",
6570 com.liferay.portal.kernel.dao.orm.Type.LONG);
6571
6572 QueryPos qPos = QueryPos.getInstance(q);
6573
6574 qPos.add(groupId);
6575 qPos.add(parentCategoryId);
6576
6577 categoryIds = q.list();
6578 }
6579 catch (Exception e) {
6580 throw processException(e);
6581 }
6582 finally {
6583 closeSession(session);
6584 }
6585
6586 long rightCategoryId = leftCategoryId + 1;
6587
6588 for (long categoryId : categoryIds) {
6589 rightCategoryId = rebuildTree(groupId, categoryId, rightCategoryId);
6590 }
6591
6592 if (parentCategoryId > 0) {
6593 updateTree.update(parentCategoryId, leftCategoryId, rightCategoryId);
6594 }
6595
6596 return rightCategoryId + 1;
6597 }
6598
6599 protected void shrinkTree(AssetCategory assetCategory) {
6600 if (!rebuildTreeEnabled) {
6601 return;
6602 }
6603
6604 long groupId = assetCategory.getGroupId();
6605
6606 long leftCategoryId = assetCategory.getLeftCategoryId();
6607 long rightCategoryId = assetCategory.getRightCategoryId();
6608
6609 long delta = (rightCategoryId - leftCategoryId) + 1;
6610
6611 shrinkTreeLeftCategoryId.shrink(groupId, rightCategoryId, delta);
6612 shrinkTreeRightCategoryId.shrink(groupId, rightCategoryId, delta);
6613
6614 CacheRegistryUtil.clear(AssetCategoryImpl.class.getName());
6615 EntityCacheUtil.clearCache(AssetCategoryImpl.class.getName());
6616 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
6617 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
6618 }
6619
6620 protected void updateChildrenTree(long groupId,
6621 List<Long> childrenCategoryIds, long delta) {
6622 String sql = "UPDATE AssetCategory SET leftcategoryId = (leftcategoryId + ?), rightcategoryId = (rightcategoryId + ?) WHERE (groupId = ?) AND (categoryId IN (" +
6623 StringUtil.merge(childrenCategoryIds) + "))";
6624
6625 SqlUpdate _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
6626 sql,
6627 new int[] {
6628 java.sql.Types.BIGINT, java.sql.Types.BIGINT,
6629 java.sql.Types.BIGINT
6630 });
6631
6632 _sqlUpdate.update(new Object[] { delta, delta, groupId });
6633 }
6634
6635
6638 public void afterPropertiesSet() {
6639 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
6640 com.liferay.portal.util.PropsUtil.get(
6641 "value.object.listener.com.liferay.portlet.asset.model.AssetCategory")));
6642
6643 if (listenerClassNames.length > 0) {
6644 try {
6645 List<ModelListener<AssetCategory>> listenersList = new ArrayList<ModelListener<AssetCategory>>();
6646
6647 for (String listenerClassName : listenerClassNames) {
6648 listenersList.add((ModelListener<AssetCategory>)InstanceFactory.newInstance(
6649 listenerClassName));
6650 }
6651
6652 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
6653 }
6654 catch (Exception e) {
6655 _log.error(e);
6656 }
6657 }
6658
6659 containsAssetEntry = new ContainsAssetEntry();
6660
6661 addAssetEntry = new AddAssetEntry();
6662 clearAssetEntries = new ClearAssetEntries();
6663 removeAssetEntry = new RemoveAssetEntry();
6664
6665 expandTreeLeftCategoryId = new ExpandTreeLeftCategoryId();
6666 expandTreeRightCategoryId = new ExpandTreeRightCategoryId();
6667 shrinkTreeLeftCategoryId = new ShrinkTreeLeftCategoryId();
6668 shrinkTreeRightCategoryId = new ShrinkTreeRightCategoryId();
6669 updateTree = new UpdateTree();
6670 }
6671
6672 public void destroy() {
6673 EntityCacheUtil.removeCache(AssetCategoryImpl.class.getName());
6674 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
6675 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
6676 }
6677
6678 @BeanReference(type = AssetCategoryPersistence.class)
6679 protected AssetCategoryPersistence assetCategoryPersistence;
6680 @BeanReference(type = AssetCategoryPropertyPersistence.class)
6681 protected AssetCategoryPropertyPersistence assetCategoryPropertyPersistence;
6682 @BeanReference(type = AssetEntryPersistence.class)
6683 protected AssetEntryPersistence assetEntryPersistence;
6684 @BeanReference(type = AssetLinkPersistence.class)
6685 protected AssetLinkPersistence assetLinkPersistence;
6686 @BeanReference(type = AssetTagPersistence.class)
6687 protected AssetTagPersistence assetTagPersistence;
6688 @BeanReference(type = AssetTagPropertyPersistence.class)
6689 protected AssetTagPropertyPersistence assetTagPropertyPersistence;
6690 @BeanReference(type = AssetTagStatsPersistence.class)
6691 protected AssetTagStatsPersistence assetTagStatsPersistence;
6692 @BeanReference(type = AssetVocabularyPersistence.class)
6693 protected AssetVocabularyPersistence assetVocabularyPersistence;
6694 @BeanReference(type = ResourcePersistence.class)
6695 protected ResourcePersistence resourcePersistence;
6696 @BeanReference(type = UserPersistence.class)
6697 protected UserPersistence userPersistence;
6698 protected ContainsAssetEntry containsAssetEntry;
6699 protected AddAssetEntry addAssetEntry;
6700 protected ClearAssetEntries clearAssetEntries;
6701 protected RemoveAssetEntry removeAssetEntry;
6702
6703 protected class ContainsAssetEntry {
6704 protected ContainsAssetEntry() {
6705 _mappingSqlQuery = MappingSqlQueryFactoryUtil.getMappingSqlQuery(getDataSource(),
6706 _SQL_CONTAINSASSETENTRY,
6707 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT },
6708 RowMapper.COUNT);
6709 }
6710
6711 protected boolean contains(long categoryId, long entryId) {
6712 List<Integer> results = _mappingSqlQuery.execute(new Object[] {
6713 new Long(categoryId), new Long(entryId)
6714 });
6715
6716 if (results.size() > 0) {
6717 Integer count = results.get(0);
6718
6719 if (count.intValue() > 0) {
6720 return true;
6721 }
6722 }
6723
6724 return false;
6725 }
6726
6727 private MappingSqlQuery<Integer> _mappingSqlQuery;
6728 }
6729
6730 protected class AddAssetEntry {
6731 protected AddAssetEntry() {
6732 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
6733 "INSERT INTO AssetEntries_AssetCategories (categoryId, entryId) VALUES (?, ?)",
6734 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
6735 }
6736
6737 protected void add(long categoryId, long entryId)
6738 throws SystemException {
6739 if (!containsAssetEntry.contains(categoryId, entryId)) {
6740 ModelListener<com.liferay.portlet.asset.model.AssetEntry>[] assetEntryListeners =
6741 assetEntryPersistence.getListeners();
6742
6743 for (ModelListener<AssetCategory> listener : listeners) {
6744 listener.onBeforeAddAssociation(categoryId,
6745 com.liferay.portlet.asset.model.AssetEntry.class.getName(),
6746 entryId);
6747 }
6748
6749 for (ModelListener<com.liferay.portlet.asset.model.AssetEntry> listener : assetEntryListeners) {
6750 listener.onBeforeAddAssociation(entryId,
6751 AssetCategory.class.getName(), categoryId);
6752 }
6753
6754 _sqlUpdate.update(new Object[] {
6755 new Long(categoryId), new Long(entryId)
6756 });
6757
6758 for (ModelListener<AssetCategory> listener : listeners) {
6759 listener.onAfterAddAssociation(categoryId,
6760 com.liferay.portlet.asset.model.AssetEntry.class.getName(),
6761 entryId);
6762 }
6763
6764 for (ModelListener<com.liferay.portlet.asset.model.AssetEntry> listener : assetEntryListeners) {
6765 listener.onAfterAddAssociation(entryId,
6766 AssetCategory.class.getName(), categoryId);
6767 }
6768 }
6769 }
6770
6771 private SqlUpdate _sqlUpdate;
6772 }
6773
6774 protected class ClearAssetEntries {
6775 protected ClearAssetEntries() {
6776 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
6777 "DELETE FROM AssetEntries_AssetCategories WHERE categoryId = ?",
6778 new int[] { java.sql.Types.BIGINT });
6779 }
6780
6781 protected void clear(long categoryId) throws SystemException {
6782 ModelListener<com.liferay.portlet.asset.model.AssetEntry>[] assetEntryListeners =
6783 assetEntryPersistence.getListeners();
6784
6785 List<com.liferay.portlet.asset.model.AssetEntry> assetEntries = null;
6786
6787 if ((listeners.length > 0) || (assetEntryListeners.length > 0)) {
6788 assetEntries = getAssetEntries(categoryId);
6789
6790 for (com.liferay.portlet.asset.model.AssetEntry assetEntry : assetEntries) {
6791 for (ModelListener<AssetCategory> listener : listeners) {
6792 listener.onBeforeRemoveAssociation(categoryId,
6793 com.liferay.portlet.asset.model.AssetEntry.class.getName(),
6794 assetEntry.getPrimaryKey());
6795 }
6796
6797 for (ModelListener<com.liferay.portlet.asset.model.AssetEntry> listener : assetEntryListeners) {
6798 listener.onBeforeRemoveAssociation(assetEntry.getPrimaryKey(),
6799 AssetCategory.class.getName(), categoryId);
6800 }
6801 }
6802 }
6803
6804 _sqlUpdate.update(new Object[] { new Long(categoryId) });
6805
6806 if ((listeners.length > 0) || (assetEntryListeners.length > 0)) {
6807 for (com.liferay.portlet.asset.model.AssetEntry assetEntry : assetEntries) {
6808 for (ModelListener<AssetCategory> listener : listeners) {
6809 listener.onAfterRemoveAssociation(categoryId,
6810 com.liferay.portlet.asset.model.AssetEntry.class.getName(),
6811 assetEntry.getPrimaryKey());
6812 }
6813
6814 for (ModelListener<com.liferay.portlet.asset.model.AssetEntry> listener : assetEntryListeners) {
6815 listener.onAfterRemoveAssociation(assetEntry.getPrimaryKey(),
6816 AssetCategory.class.getName(), categoryId);
6817 }
6818 }
6819 }
6820 }
6821
6822 private SqlUpdate _sqlUpdate;
6823 }
6824
6825 protected class RemoveAssetEntry {
6826 protected RemoveAssetEntry() {
6827 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
6828 "DELETE FROM AssetEntries_AssetCategories WHERE categoryId = ? AND entryId = ?",
6829 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
6830 }
6831
6832 protected void remove(long categoryId, long entryId)
6833 throws SystemException {
6834 if (containsAssetEntry.contains(categoryId, entryId)) {
6835 ModelListener<com.liferay.portlet.asset.model.AssetEntry>[] assetEntryListeners =
6836 assetEntryPersistence.getListeners();
6837
6838 for (ModelListener<AssetCategory> listener : listeners) {
6839 listener.onBeforeRemoveAssociation(categoryId,
6840 com.liferay.portlet.asset.model.AssetEntry.class.getName(),
6841 entryId);
6842 }
6843
6844 for (ModelListener<com.liferay.portlet.asset.model.AssetEntry> listener : assetEntryListeners) {
6845 listener.onBeforeRemoveAssociation(entryId,
6846 AssetCategory.class.getName(), categoryId);
6847 }
6848
6849 _sqlUpdate.update(new Object[] {
6850 new Long(categoryId), new Long(entryId)
6851 });
6852
6853 for (ModelListener<AssetCategory> listener : listeners) {
6854 listener.onAfterRemoveAssociation(categoryId,
6855 com.liferay.portlet.asset.model.AssetEntry.class.getName(),
6856 entryId);
6857 }
6858
6859 for (ModelListener<com.liferay.portlet.asset.model.AssetEntry> listener : assetEntryListeners) {
6860 listener.onAfterRemoveAssociation(entryId,
6861 AssetCategory.class.getName(), categoryId);
6862 }
6863 }
6864 }
6865
6866 private SqlUpdate _sqlUpdate;
6867 }
6868
6869 protected boolean rebuildTreeEnabled = true;
6870 protected ExpandTreeLeftCategoryId expandTreeLeftCategoryId;
6871 protected ExpandTreeRightCategoryId expandTreeRightCategoryId;
6872 protected ShrinkTreeLeftCategoryId shrinkTreeLeftCategoryId;
6873 protected ShrinkTreeRightCategoryId shrinkTreeRightCategoryId;
6874 protected UpdateTree updateTree;
6875
6876 protected class ExpandTreeLeftCategoryId {
6877 protected ExpandTreeLeftCategoryId() {
6878 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
6879 "UPDATE AssetCategory SET leftCategoryId = (leftCategoryId + 2) WHERE (groupId = ?) AND (leftCategoryId > ?)",
6880 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
6881 }
6882
6883 protected void expand(long groupId, long leftCategoryId) {
6884 _sqlUpdate.update(new Object[] { groupId, leftCategoryId });
6885 }
6886
6887 private SqlUpdate _sqlUpdate;
6888 }
6889
6890 protected class ExpandTreeRightCategoryId {
6891 protected ExpandTreeRightCategoryId() {
6892 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
6893 "UPDATE AssetCategory SET rightCategoryId = (rightCategoryId + 2) WHERE (groupId = ?) AND (rightCategoryId > ?)",
6894 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
6895 }
6896
6897 protected void expand(long groupId, long rightCategoryId) {
6898 _sqlUpdate.update(new Object[] { groupId, rightCategoryId });
6899 }
6900
6901 private SqlUpdate _sqlUpdate;
6902 }
6903
6904 protected class ShrinkTreeLeftCategoryId {
6905 protected ShrinkTreeLeftCategoryId() {
6906 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
6907 "UPDATE AssetCategory SET leftCategoryId = (leftCategoryId - ?) WHERE (groupId = ?) AND (leftCategoryId > ?)",
6908 new int[] {
6909 java.sql.Types.BIGINT, java.sql.Types.BIGINT,
6910 java.sql.Types.BIGINT
6911 });
6912 }
6913
6914 protected void shrink(long groupId, long leftCategoryId, long delta) {
6915 _sqlUpdate.update(new Object[] { delta, groupId, leftCategoryId });
6916 }
6917
6918 private SqlUpdate _sqlUpdate;
6919 }
6920
6921 protected class ShrinkTreeRightCategoryId {
6922 protected ShrinkTreeRightCategoryId() {
6923 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
6924 "UPDATE AssetCategory SET rightCategoryId = (rightCategoryId - ?) WHERE (groupId = ?) AND (rightCategoryId > ?)",
6925 new int[] {
6926 java.sql.Types.BIGINT, java.sql.Types.BIGINT,
6927 java.sql.Types.BIGINT
6928 });
6929 }
6930
6931 protected void shrink(long groupId, long rightCategoryId, long delta) {
6932 _sqlUpdate.update(new Object[] { delta, groupId, rightCategoryId });
6933 }
6934
6935 private SqlUpdate _sqlUpdate;
6936 }
6937
6938 protected class UpdateTree {
6939 protected UpdateTree() {
6940 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
6941 "UPDATE AssetCategory SET leftCategoryId = ?, rightCategoryId = ? WHERE categoryId = ?",
6942 new int[] {
6943 java.sql.Types.BIGINT, java.sql.Types.BIGINT,
6944 java.sql.Types.BIGINT
6945 });
6946 }
6947
6948 protected void update(long categoryId, long leftCategoryId,
6949 long rightCategoryId) {
6950 _sqlUpdate.update(new Object[] {
6951 leftCategoryId, rightCategoryId, categoryId
6952 });
6953 }
6954
6955 private SqlUpdate _sqlUpdate;
6956 }
6957
6958 private static final String _SQL_SELECT_ASSETCATEGORY = "SELECT assetCategory FROM AssetCategory assetCategory";
6959 private static final String _SQL_SELECT_ASSETCATEGORY_WHERE = "SELECT assetCategory FROM AssetCategory assetCategory WHERE ";
6960 private static final String _SQL_COUNT_ASSETCATEGORY = "SELECT COUNT(assetCategory) FROM AssetCategory assetCategory";
6961 private static final String _SQL_COUNT_ASSETCATEGORY_WHERE = "SELECT COUNT(assetCategory) FROM AssetCategory assetCategory WHERE ";
6962 private static final String _SQL_GETASSETENTRIES = "SELECT {AssetEntry.*} FROM AssetEntry INNER JOIN AssetEntries_AssetCategories ON (AssetEntries_AssetCategories.entryId = AssetEntry.entryId) WHERE (AssetEntries_AssetCategories.categoryId = ?)";
6963 private static final String _SQL_GETASSETENTRIESSIZE = "SELECT COUNT(*) AS COUNT_VALUE FROM AssetEntries_AssetCategories WHERE categoryId = ?";
6964 private static final String _SQL_CONTAINSASSETENTRY = "SELECT COUNT(*) AS COUNT_VALUE FROM AssetEntries_AssetCategories WHERE categoryId = ? AND entryId = ?";
6965 private static final String _FINDER_COLUMN_UUID_UUID_1 = "assetCategory.uuid IS NULL";
6966 private static final String _FINDER_COLUMN_UUID_UUID_2 = "assetCategory.uuid = ?";
6967 private static final String _FINDER_COLUMN_UUID_UUID_3 = "(assetCategory.uuid IS NULL OR assetCategory.uuid = ?)";
6968 private static final String _FINDER_COLUMN_UUID_G_UUID_1 = "assetCategory.uuid IS NULL AND ";
6969 private static final String _FINDER_COLUMN_UUID_G_UUID_2 = "assetCategory.uuid = ? AND ";
6970 private static final String _FINDER_COLUMN_UUID_G_UUID_3 = "(assetCategory.uuid IS NULL OR assetCategory.uuid = ?) AND ";
6971 private static final String _FINDER_COLUMN_UUID_G_GROUPID_2 = "assetCategory.groupId = ?";
6972 private static final String _FINDER_COLUMN_GROUPID_GROUPID_2 = "assetCategory.groupId = ?";
6973 private static final String _FINDER_COLUMN_PARENTCATEGORYID_PARENTCATEGORYID_2 =
6974 "assetCategory.parentCategoryId = ?";
6975 private static final String _FINDER_COLUMN_VOCABULARYID_VOCABULARYID_2 = "assetCategory.vocabularyId = ?";
6976 private static final String _FINDER_COLUMN_G_V_GROUPID_2 = "assetCategory.groupId = ? AND ";
6977 private static final String _FINDER_COLUMN_G_V_VOCABULARYID_2 = "assetCategory.vocabularyId = ?";
6978 private static final String _FINDER_COLUMN_P_N_PARENTCATEGORYID_2 = "assetCategory.parentCategoryId = ? AND ";
6979 private static final String _FINDER_COLUMN_P_N_NAME_1 = "assetCategory.name IS NULL";
6980 private static final String _FINDER_COLUMN_P_N_NAME_2 = "assetCategory.name = ?";
6981 private static final String _FINDER_COLUMN_P_N_NAME_3 = "(assetCategory.name IS NULL OR assetCategory.name = ?)";
6982 private static final String _FINDER_COLUMN_P_V_PARENTCATEGORYID_2 = "assetCategory.parentCategoryId = ? AND ";
6983 private static final String _FINDER_COLUMN_P_V_VOCABULARYID_2 = "assetCategory.vocabularyId = ?";
6984 private static final String _FINDER_COLUMN_N_V_NAME_1 = "assetCategory.name IS NULL AND ";
6985 private static final String _FINDER_COLUMN_N_V_NAME_2 = "assetCategory.name = ? AND ";
6986 private static final String _FINDER_COLUMN_N_V_NAME_3 = "(assetCategory.name IS NULL OR assetCategory.name = ?) AND ";
6987 private static final String _FINDER_COLUMN_N_V_VOCABULARYID_2 = "assetCategory.vocabularyId = ?";
6988 private static final String _FINDER_COLUMN_P_N_V_PARENTCATEGORYID_2 = "assetCategory.parentCategoryId = ? AND ";
6989 private static final String _FINDER_COLUMN_P_N_V_NAME_1 = "assetCategory.name IS NULL AND ";
6990 private static final String _FINDER_COLUMN_P_N_V_NAME_2 = "assetCategory.name = ? AND ";
6991 private static final String _FINDER_COLUMN_P_N_V_NAME_3 = "(assetCategory.name IS NULL OR assetCategory.name = ?) AND ";
6992 private static final String _FINDER_COLUMN_P_N_V_VOCABULARYID_2 = "assetCategory.vocabularyId = ?";
6993 private static final String _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN = "assetCategory.categoryId";
6994 private static final String _FILTER_SQL_SELECT_ASSETCATEGORY_WHERE = "SELECT DISTINCT {assetCategory.*} FROM AssetCategory assetCategory WHERE ";
6995 private static final String _FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_1 =
6996 "SELECT {AssetCategory.*} FROM (SELECT DISTINCT assetCategory.categoryId FROM AssetCategory assetCategory WHERE ";
6997 private static final String _FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_2 =
6998 ") TEMP_TABLE INNER JOIN AssetCategory ON TEMP_TABLE.categoryId = AssetCategory.categoryId";
6999 private static final String _FILTER_SQL_COUNT_ASSETCATEGORY_WHERE = "SELECT COUNT(DISTINCT assetCategory.categoryId) AS COUNT_VALUE FROM AssetCategory assetCategory WHERE ";
7000 private static final String _FILTER_ENTITY_ALIAS = "assetCategory";
7001 private static final String _FILTER_ENTITY_TABLE = "AssetCategory";
7002 private static final String _ORDER_BY_ENTITY_ALIAS = "assetCategory.";
7003 private static final String _ORDER_BY_ENTITY_TABLE = "AssetCategory.";
7004 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No AssetCategory exists with the primary key ";
7005 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No AssetCategory exists with the key {";
7006 private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
7007 private static Log _log = LogFactoryUtil.getLog(AssetCategoryPersistenceImpl.class);
7008 private static AssetCategory _nullAssetCategory = new AssetCategoryImpl() {
7009 @Override
7010 public Object clone() {
7011 return this;
7012 }
7013
7014 @Override
7015 public CacheModel<AssetCategory> toCacheModel() {
7016 return _nullAssetCategoryCacheModel;
7017 }
7018 };
7019
7020 private static CacheModel<AssetCategory> _nullAssetCategoryCacheModel = new CacheModel<AssetCategory>() {
7021 public AssetCategory toEntityModel() {
7022 return _nullAssetCategory;
7023 }
7024 };
7025 }