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 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
374 new Object[] {
375 assetCategory.getUuid(),
376 Long.valueOf(assetCategory.getGroupId())
377 });
378
379 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_P_N_V,
380 new Object[] {
381 Long.valueOf(assetCategory.getParentCategoryId()),
382
383 assetCategory.getName(),
384 Long.valueOf(assetCategory.getVocabularyId())
385 });
386 }
387
388
394 public AssetCategory create(long categoryId) {
395 AssetCategory assetCategory = new AssetCategoryImpl();
396
397 assetCategory.setNew(true);
398 assetCategory.setPrimaryKey(categoryId);
399
400 String uuid = PortalUUIDUtil.generate();
401
402 assetCategory.setUuid(uuid);
403
404 return assetCategory;
405 }
406
407
415 @Override
416 public AssetCategory remove(Serializable primaryKey)
417 throws NoSuchModelException, SystemException {
418 return remove(((Long)primaryKey).longValue());
419 }
420
421
429 public AssetCategory remove(long categoryId)
430 throws NoSuchCategoryException, SystemException {
431 Session session = null;
432
433 try {
434 session = openSession();
435
436 AssetCategory assetCategory = (AssetCategory)session.get(AssetCategoryImpl.class,
437 Long.valueOf(categoryId));
438
439 if (assetCategory == null) {
440 if (_log.isWarnEnabled()) {
441 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + categoryId);
442 }
443
444 throw new NoSuchCategoryException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
445 categoryId);
446 }
447
448 return assetCategoryPersistence.remove(assetCategory);
449 }
450 catch (NoSuchCategoryException nsee) {
451 throw nsee;
452 }
453 catch (Exception e) {
454 throw processException(e);
455 }
456 finally {
457 closeSession(session);
458 }
459 }
460
461
468 @Override
469 public AssetCategory remove(AssetCategory assetCategory)
470 throws SystemException {
471 return super.remove(assetCategory);
472 }
473
474 @Override
475 protected AssetCategory removeImpl(AssetCategory assetCategory)
476 throws SystemException {
477 assetCategory = toUnwrappedModel(assetCategory);
478
479 try {
480 clearAssetEntries.clear(assetCategory.getPrimaryKey());
481 }
482 catch (Exception e) {
483 throw processException(e);
484 }
485 finally {
486 FinderCacheUtil.clearCache(AssetCategoryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
487 }
488
489 shrinkTree(assetCategory);
490
491 Session session = null;
492
493 try {
494 session = openSession();
495
496 BatchSessionUtil.delete(session, assetCategory);
497 }
498 catch (Exception e) {
499 throw processException(e);
500 }
501 finally {
502 closeSession(session);
503 }
504
505 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
506 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
507
508 AssetCategoryModelImpl assetCategoryModelImpl = (AssetCategoryModelImpl)assetCategory;
509
510 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
511 new Object[] {
512 assetCategoryModelImpl.getUuid(),
513 Long.valueOf(assetCategoryModelImpl.getGroupId())
514 });
515
516 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_P_N_V,
517 new Object[] {
518 Long.valueOf(assetCategoryModelImpl.getParentCategoryId()),
519
520 assetCategoryModelImpl.getName(),
521 Long.valueOf(assetCategoryModelImpl.getVocabularyId())
522 });
523
524 EntityCacheUtil.removeResult(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
525 AssetCategoryImpl.class, assetCategory.getPrimaryKey());
526
527 return assetCategory;
528 }
529
530 @Override
531 public AssetCategory updateImpl(
532 com.liferay.portlet.asset.model.AssetCategory assetCategory,
533 boolean merge) throws SystemException {
534 assetCategory = toUnwrappedModel(assetCategory);
535
536 boolean isNew = assetCategory.isNew();
537
538 AssetCategoryModelImpl assetCategoryModelImpl = (AssetCategoryModelImpl)assetCategory;
539
540 if (Validator.isNull(assetCategory.getUuid())) {
541 String uuid = PortalUUIDUtil.generate();
542
543 assetCategory.setUuid(uuid);
544 }
545
546 if (isNew) {
547 expandTree(assetCategory);
548 }
549 else {
550 if (assetCategory.getParentCategoryId() != assetCategoryModelImpl.getOriginalParentCategoryId()) {
551 shrinkTree(assetCategory);
552 expandTree(assetCategory);
553 }
554 }
555
556 Session session = null;
557
558 try {
559 session = openSession();
560
561 BatchSessionUtil.update(session, assetCategory, merge);
562
563 assetCategory.setNew(false);
564 }
565 catch (Exception e) {
566 throw processException(e);
567 }
568 finally {
569 closeSession(session);
570 }
571
572 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
573
574 if (isNew || !AssetCategoryModelImpl.COLUMN_BITMASK_ENABLED) {
575 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
576 }
577
578 else {
579 if ((assetCategoryModelImpl.getColumnBitmask() &
580 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID.getColumnBitmask()) != 0) {
581 Object[] args = new Object[] {
582 assetCategoryModelImpl.getOriginalUuid()
583 };
584
585 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
586 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
587 args);
588
589 args = new Object[] { assetCategoryModelImpl.getUuid() };
590
591 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
592 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
593 args);
594 }
595
596 if ((assetCategoryModelImpl.getColumnBitmask() &
597 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID.getColumnBitmask()) != 0) {
598 Object[] args = new Object[] {
599 Long.valueOf(assetCategoryModelImpl.getOriginalGroupId())
600 };
601
602 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
603 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
604 args);
605
606 args = new Object[] {
607 Long.valueOf(assetCategoryModelImpl.getGroupId())
608 };
609
610 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
611 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
612 args);
613 }
614
615 if ((assetCategoryModelImpl.getColumnBitmask() &
616 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_PARENTCATEGORYID.getColumnBitmask()) != 0) {
617 Object[] args = new Object[] {
618 Long.valueOf(assetCategoryModelImpl.getOriginalParentCategoryId())
619 };
620
621 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_PARENTCATEGORYID,
622 args);
623 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_PARENTCATEGORYID,
624 args);
625
626 args = new Object[] {
627 Long.valueOf(assetCategoryModelImpl.getParentCategoryId())
628 };
629
630 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_PARENTCATEGORYID,
631 args);
632 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_PARENTCATEGORYID,
633 args);
634 }
635
636 if ((assetCategoryModelImpl.getColumnBitmask() &
637 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_VOCABULARYID.getColumnBitmask()) != 0) {
638 Object[] args = new Object[] {
639 Long.valueOf(assetCategoryModelImpl.getOriginalVocabularyId())
640 };
641
642 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_VOCABULARYID,
643 args);
644 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_VOCABULARYID,
645 args);
646
647 args = new Object[] {
648 Long.valueOf(assetCategoryModelImpl.getVocabularyId())
649 };
650
651 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_VOCABULARYID,
652 args);
653 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_VOCABULARYID,
654 args);
655 }
656
657 if ((assetCategoryModelImpl.getColumnBitmask() &
658 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_V.getColumnBitmask()) != 0) {
659 Object[] args = new Object[] {
660 Long.valueOf(assetCategoryModelImpl.getOriginalGroupId()),
661 Long.valueOf(assetCategoryModelImpl.getOriginalVocabularyId())
662 };
663
664 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_V, args);
665 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_V,
666 args);
667
668 args = new Object[] {
669 Long.valueOf(assetCategoryModelImpl.getGroupId()),
670 Long.valueOf(assetCategoryModelImpl.getVocabularyId())
671 };
672
673 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_V, args);
674 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_V,
675 args);
676 }
677
678 if ((assetCategoryModelImpl.getColumnBitmask() &
679 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_P_N.getColumnBitmask()) != 0) {
680 Object[] args = new Object[] {
681 Long.valueOf(assetCategoryModelImpl.getOriginalParentCategoryId()),
682
683 assetCategoryModelImpl.getOriginalName()
684 };
685
686 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_P_N, args);
687 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_P_N,
688 args);
689
690 args = new Object[] {
691 Long.valueOf(assetCategoryModelImpl.getParentCategoryId()),
692
693 assetCategoryModelImpl.getName()
694 };
695
696 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_P_N, args);
697 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_P_N,
698 args);
699 }
700
701 if ((assetCategoryModelImpl.getColumnBitmask() &
702 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_P_V.getColumnBitmask()) != 0) {
703 Object[] args = new Object[] {
704 Long.valueOf(assetCategoryModelImpl.getOriginalParentCategoryId()),
705 Long.valueOf(assetCategoryModelImpl.getOriginalVocabularyId())
706 };
707
708 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_P_V, args);
709 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_P_V,
710 args);
711
712 args = new Object[] {
713 Long.valueOf(assetCategoryModelImpl.getParentCategoryId()),
714 Long.valueOf(assetCategoryModelImpl.getVocabularyId())
715 };
716
717 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_P_V, args);
718 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_P_V,
719 args);
720 }
721
722 if ((assetCategoryModelImpl.getColumnBitmask() &
723 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_V.getColumnBitmask()) != 0) {
724 Object[] args = new Object[] {
725 assetCategoryModelImpl.getOriginalName(),
726 Long.valueOf(assetCategoryModelImpl.getOriginalVocabularyId())
727 };
728
729 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_N_V, args);
730 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_V,
731 args);
732
733 args = new Object[] {
734 assetCategoryModelImpl.getName(),
735 Long.valueOf(assetCategoryModelImpl.getVocabularyId())
736 };
737
738 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_N_V, args);
739 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_V,
740 args);
741 }
742 }
743
744 EntityCacheUtil.putResult(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
745 AssetCategoryImpl.class, assetCategory.getPrimaryKey(),
746 assetCategory);
747
748 if (isNew) {
749 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
750 new Object[] {
751 assetCategory.getUuid(),
752 Long.valueOf(assetCategory.getGroupId())
753 }, assetCategory);
754
755 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_P_N_V,
756 new Object[] {
757 Long.valueOf(assetCategory.getParentCategoryId()),
758
759 assetCategory.getName(),
760 Long.valueOf(assetCategory.getVocabularyId())
761 }, assetCategory);
762 }
763 else {
764 if ((assetCategoryModelImpl.getColumnBitmask() &
765 FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) {
766 Object[] args = new Object[] {
767 assetCategoryModelImpl.getOriginalUuid(),
768 Long.valueOf(assetCategoryModelImpl.getOriginalGroupId())
769 };
770
771 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args);
772 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args);
773
774 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
775 new Object[] {
776 assetCategory.getUuid(),
777 Long.valueOf(assetCategory.getGroupId())
778 }, assetCategory);
779 }
780
781 if ((assetCategoryModelImpl.getColumnBitmask() &
782 FINDER_PATH_FETCH_BY_P_N_V.getColumnBitmask()) != 0) {
783 Object[] args = new Object[] {
784 Long.valueOf(assetCategoryModelImpl.getOriginalParentCategoryId()),
785
786 assetCategoryModelImpl.getOriginalName(),
787 Long.valueOf(assetCategoryModelImpl.getOriginalVocabularyId())
788 };
789
790 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_P_N_V, args);
791 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_P_N_V, args);
792
793 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_P_N_V,
794 new Object[] {
795 Long.valueOf(assetCategory.getParentCategoryId()),
796
797 assetCategory.getName(),
798 Long.valueOf(assetCategory.getVocabularyId())
799 }, assetCategory);
800 }
801 }
802
803 return assetCategory;
804 }
805
806 protected AssetCategory toUnwrappedModel(AssetCategory assetCategory) {
807 if (assetCategory instanceof AssetCategoryImpl) {
808 return assetCategory;
809 }
810
811 AssetCategoryImpl assetCategoryImpl = new AssetCategoryImpl();
812
813 assetCategoryImpl.setNew(assetCategory.isNew());
814 assetCategoryImpl.setPrimaryKey(assetCategory.getPrimaryKey());
815
816 assetCategoryImpl.setUuid(assetCategory.getUuid());
817 assetCategoryImpl.setCategoryId(assetCategory.getCategoryId());
818 assetCategoryImpl.setGroupId(assetCategory.getGroupId());
819 assetCategoryImpl.setCompanyId(assetCategory.getCompanyId());
820 assetCategoryImpl.setUserId(assetCategory.getUserId());
821 assetCategoryImpl.setUserName(assetCategory.getUserName());
822 assetCategoryImpl.setCreateDate(assetCategory.getCreateDate());
823 assetCategoryImpl.setModifiedDate(assetCategory.getModifiedDate());
824 assetCategoryImpl.setParentCategoryId(assetCategory.getParentCategoryId());
825 assetCategoryImpl.setLeftCategoryId(assetCategory.getLeftCategoryId());
826 assetCategoryImpl.setRightCategoryId(assetCategory.getRightCategoryId());
827 assetCategoryImpl.setName(assetCategory.getName());
828 assetCategoryImpl.setTitle(assetCategory.getTitle());
829 assetCategoryImpl.setDescription(assetCategory.getDescription());
830 assetCategoryImpl.setVocabularyId(assetCategory.getVocabularyId());
831
832 return assetCategoryImpl;
833 }
834
835
843 @Override
844 public AssetCategory findByPrimaryKey(Serializable primaryKey)
845 throws NoSuchModelException, SystemException {
846 return findByPrimaryKey(((Long)primaryKey).longValue());
847 }
848
849
857 public AssetCategory findByPrimaryKey(long categoryId)
858 throws NoSuchCategoryException, SystemException {
859 AssetCategory assetCategory = fetchByPrimaryKey(categoryId);
860
861 if (assetCategory == null) {
862 if (_log.isWarnEnabled()) {
863 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + categoryId);
864 }
865
866 throw new NoSuchCategoryException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
867 categoryId);
868 }
869
870 return assetCategory;
871 }
872
873
880 @Override
881 public AssetCategory fetchByPrimaryKey(Serializable primaryKey)
882 throws SystemException {
883 return fetchByPrimaryKey(((Long)primaryKey).longValue());
884 }
885
886
893 public AssetCategory fetchByPrimaryKey(long categoryId)
894 throws SystemException {
895 AssetCategory assetCategory = (AssetCategory)EntityCacheUtil.getResult(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
896 AssetCategoryImpl.class, categoryId);
897
898 if (assetCategory == _nullAssetCategory) {
899 return null;
900 }
901
902 if (assetCategory == null) {
903 Session session = null;
904
905 boolean hasException = false;
906
907 try {
908 session = openSession();
909
910 assetCategory = (AssetCategory)session.get(AssetCategoryImpl.class,
911 Long.valueOf(categoryId));
912 }
913 catch (Exception e) {
914 hasException = true;
915
916 throw processException(e);
917 }
918 finally {
919 if (assetCategory != null) {
920 cacheResult(assetCategory);
921 }
922 else if (!hasException) {
923 EntityCacheUtil.putResult(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
924 AssetCategoryImpl.class, categoryId, _nullAssetCategory);
925 }
926
927 closeSession(session);
928 }
929 }
930
931 return assetCategory;
932 }
933
934
941 public List<AssetCategory> findByUuid(String uuid)
942 throws SystemException {
943 return findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
944 }
945
946
959 public List<AssetCategory> findByUuid(String uuid, int start, int end)
960 throws SystemException {
961 return findByUuid(uuid, start, end, null);
962 }
963
964
978 public List<AssetCategory> findByUuid(String uuid, int start, int end,
979 OrderByComparator orderByComparator) throws SystemException {
980 FinderPath finderPath = null;
981 Object[] finderArgs = null;
982
983 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
984 (orderByComparator == null)) {
985 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID;
986 finderArgs = new Object[] { uuid };
987 }
988 else {
989 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID;
990 finderArgs = new Object[] { uuid, start, end, orderByComparator };
991 }
992
993 List<AssetCategory> list = (List<AssetCategory>)FinderCacheUtil.getResult(finderPath,
994 finderArgs, this);
995
996 if (list == null) {
997 StringBundler query = null;
998
999 if (orderByComparator != null) {
1000 query = new StringBundler(3 +
1001 (orderByComparator.getOrderByFields().length * 3));
1002 }
1003 else {
1004 query = new StringBundler(3);
1005 }
1006
1007 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
1008
1009 if (uuid == null) {
1010 query.append(_FINDER_COLUMN_UUID_UUID_1);
1011 }
1012 else {
1013 if (uuid.equals(StringPool.BLANK)) {
1014 query.append(_FINDER_COLUMN_UUID_UUID_3);
1015 }
1016 else {
1017 query.append(_FINDER_COLUMN_UUID_UUID_2);
1018 }
1019 }
1020
1021 if (orderByComparator != null) {
1022 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1023 orderByComparator);
1024 }
1025
1026 else {
1027 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
1028 }
1029
1030 String sql = query.toString();
1031
1032 Session session = null;
1033
1034 try {
1035 session = openSession();
1036
1037 Query q = session.createQuery(sql);
1038
1039 QueryPos qPos = QueryPos.getInstance(q);
1040
1041 if (uuid != null) {
1042 qPos.add(uuid);
1043 }
1044
1045 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
1046 start, end);
1047 }
1048 catch (Exception e) {
1049 throw processException(e);
1050 }
1051 finally {
1052 if (list == null) {
1053 FinderCacheUtil.removeResult(finderPath, finderArgs);
1054 }
1055 else {
1056 cacheResult(list);
1057
1058 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1059 }
1060
1061 closeSession(session);
1062 }
1063 }
1064
1065 return list;
1066 }
1067
1068
1081 public AssetCategory findByUuid_First(String uuid,
1082 OrderByComparator orderByComparator)
1083 throws NoSuchCategoryException, SystemException {
1084 List<AssetCategory> list = findByUuid(uuid, 0, 1, orderByComparator);
1085
1086 if (list.isEmpty()) {
1087 StringBundler msg = new StringBundler(4);
1088
1089 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1090
1091 msg.append("uuid=");
1092 msg.append(uuid);
1093
1094 msg.append(StringPool.CLOSE_CURLY_BRACE);
1095
1096 throw new NoSuchCategoryException(msg.toString());
1097 }
1098 else {
1099 return list.get(0);
1100 }
1101 }
1102
1103
1116 public AssetCategory findByUuid_Last(String uuid,
1117 OrderByComparator orderByComparator)
1118 throws NoSuchCategoryException, SystemException {
1119 int count = countByUuid(uuid);
1120
1121 List<AssetCategory> list = findByUuid(uuid, count - 1, count,
1122 orderByComparator);
1123
1124 if (list.isEmpty()) {
1125 StringBundler msg = new StringBundler(4);
1126
1127 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1128
1129 msg.append("uuid=");
1130 msg.append(uuid);
1131
1132 msg.append(StringPool.CLOSE_CURLY_BRACE);
1133
1134 throw new NoSuchCategoryException(msg.toString());
1135 }
1136 else {
1137 return list.get(0);
1138 }
1139 }
1140
1141
1155 public AssetCategory[] findByUuid_PrevAndNext(long categoryId, String uuid,
1156 OrderByComparator orderByComparator)
1157 throws NoSuchCategoryException, SystemException {
1158 AssetCategory assetCategory = findByPrimaryKey(categoryId);
1159
1160 Session session = null;
1161
1162 try {
1163 session = openSession();
1164
1165 AssetCategory[] array = new AssetCategoryImpl[3];
1166
1167 array[0] = getByUuid_PrevAndNext(session, assetCategory, uuid,
1168 orderByComparator, true);
1169
1170 array[1] = assetCategory;
1171
1172 array[2] = getByUuid_PrevAndNext(session, assetCategory, uuid,
1173 orderByComparator, false);
1174
1175 return array;
1176 }
1177 catch (Exception e) {
1178 throw processException(e);
1179 }
1180 finally {
1181 closeSession(session);
1182 }
1183 }
1184
1185 protected AssetCategory getByUuid_PrevAndNext(Session session,
1186 AssetCategory assetCategory, String uuid,
1187 OrderByComparator orderByComparator, boolean previous) {
1188 StringBundler query = null;
1189
1190 if (orderByComparator != null) {
1191 query = new StringBundler(6 +
1192 (orderByComparator.getOrderByFields().length * 6));
1193 }
1194 else {
1195 query = new StringBundler(3);
1196 }
1197
1198 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
1199
1200 if (uuid == null) {
1201 query.append(_FINDER_COLUMN_UUID_UUID_1);
1202 }
1203 else {
1204 if (uuid.equals(StringPool.BLANK)) {
1205 query.append(_FINDER_COLUMN_UUID_UUID_3);
1206 }
1207 else {
1208 query.append(_FINDER_COLUMN_UUID_UUID_2);
1209 }
1210 }
1211
1212 if (orderByComparator != null) {
1213 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1214
1215 if (orderByConditionFields.length > 0) {
1216 query.append(WHERE_AND);
1217 }
1218
1219 for (int i = 0; i < orderByConditionFields.length; i++) {
1220 query.append(_ORDER_BY_ENTITY_ALIAS);
1221 query.append(orderByConditionFields[i]);
1222
1223 if ((i + 1) < orderByConditionFields.length) {
1224 if (orderByComparator.isAscending() ^ previous) {
1225 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1226 }
1227 else {
1228 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1229 }
1230 }
1231 else {
1232 if (orderByComparator.isAscending() ^ previous) {
1233 query.append(WHERE_GREATER_THAN);
1234 }
1235 else {
1236 query.append(WHERE_LESSER_THAN);
1237 }
1238 }
1239 }
1240
1241 query.append(ORDER_BY_CLAUSE);
1242
1243 String[] orderByFields = orderByComparator.getOrderByFields();
1244
1245 for (int i = 0; i < orderByFields.length; i++) {
1246 query.append(_ORDER_BY_ENTITY_ALIAS);
1247 query.append(orderByFields[i]);
1248
1249 if ((i + 1) < orderByFields.length) {
1250 if (orderByComparator.isAscending() ^ previous) {
1251 query.append(ORDER_BY_ASC_HAS_NEXT);
1252 }
1253 else {
1254 query.append(ORDER_BY_DESC_HAS_NEXT);
1255 }
1256 }
1257 else {
1258 if (orderByComparator.isAscending() ^ previous) {
1259 query.append(ORDER_BY_ASC);
1260 }
1261 else {
1262 query.append(ORDER_BY_DESC);
1263 }
1264 }
1265 }
1266 }
1267
1268 else {
1269 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
1270 }
1271
1272 String sql = query.toString();
1273
1274 Query q = session.createQuery(sql);
1275
1276 q.setFirstResult(0);
1277 q.setMaxResults(2);
1278
1279 QueryPos qPos = QueryPos.getInstance(q);
1280
1281 if (uuid != null) {
1282 qPos.add(uuid);
1283 }
1284
1285 if (orderByComparator != null) {
1286 Object[] values = orderByComparator.getOrderByConditionValues(assetCategory);
1287
1288 for (Object value : values) {
1289 qPos.add(value);
1290 }
1291 }
1292
1293 List<AssetCategory> list = q.list();
1294
1295 if (list.size() == 2) {
1296 return list.get(1);
1297 }
1298 else {
1299 return null;
1300 }
1301 }
1302
1303
1312 public AssetCategory findByUUID_G(String uuid, long groupId)
1313 throws NoSuchCategoryException, SystemException {
1314 AssetCategory assetCategory = fetchByUUID_G(uuid, groupId);
1315
1316 if (assetCategory == null) {
1317 StringBundler msg = new StringBundler(6);
1318
1319 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1320
1321 msg.append("uuid=");
1322 msg.append(uuid);
1323
1324 msg.append(", groupId=");
1325 msg.append(groupId);
1326
1327 msg.append(StringPool.CLOSE_CURLY_BRACE);
1328
1329 if (_log.isWarnEnabled()) {
1330 _log.warn(msg.toString());
1331 }
1332
1333 throw new NoSuchCategoryException(msg.toString());
1334 }
1335
1336 return assetCategory;
1337 }
1338
1339
1347 public AssetCategory fetchByUUID_G(String uuid, long groupId)
1348 throws SystemException {
1349 return fetchByUUID_G(uuid, groupId, true);
1350 }
1351
1352
1361 public AssetCategory fetchByUUID_G(String uuid, long groupId,
1362 boolean retrieveFromCache) throws SystemException {
1363 Object[] finderArgs = new Object[] { uuid, groupId };
1364
1365 Object result = null;
1366
1367 if (retrieveFromCache) {
1368 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_UUID_G,
1369 finderArgs, this);
1370 }
1371
1372 if (result == null) {
1373 StringBundler query = new StringBundler(4);
1374
1375 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
1376
1377 if (uuid == null) {
1378 query.append(_FINDER_COLUMN_UUID_G_UUID_1);
1379 }
1380 else {
1381 if (uuid.equals(StringPool.BLANK)) {
1382 query.append(_FINDER_COLUMN_UUID_G_UUID_3);
1383 }
1384 else {
1385 query.append(_FINDER_COLUMN_UUID_G_UUID_2);
1386 }
1387 }
1388
1389 query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
1390
1391 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
1392
1393 String sql = query.toString();
1394
1395 Session session = null;
1396
1397 try {
1398 session = openSession();
1399
1400 Query q = session.createQuery(sql);
1401
1402 QueryPos qPos = QueryPos.getInstance(q);
1403
1404 if (uuid != null) {
1405 qPos.add(uuid);
1406 }
1407
1408 qPos.add(groupId);
1409
1410 List<AssetCategory> list = q.list();
1411
1412 result = list;
1413
1414 AssetCategory assetCategory = null;
1415
1416 if (list.isEmpty()) {
1417 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
1418 finderArgs, list);
1419 }
1420 else {
1421 assetCategory = list.get(0);
1422
1423 cacheResult(assetCategory);
1424
1425 if ((assetCategory.getUuid() == null) ||
1426 !assetCategory.getUuid().equals(uuid) ||
1427 (assetCategory.getGroupId() != groupId)) {
1428 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
1429 finderArgs, assetCategory);
1430 }
1431 }
1432
1433 return assetCategory;
1434 }
1435 catch (Exception e) {
1436 throw processException(e);
1437 }
1438 finally {
1439 if (result == null) {
1440 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
1441 finderArgs);
1442 }
1443
1444 closeSession(session);
1445 }
1446 }
1447 else {
1448 if (result instanceof List<?>) {
1449 return null;
1450 }
1451 else {
1452 return (AssetCategory)result;
1453 }
1454 }
1455 }
1456
1457
1464 public List<AssetCategory> findByGroupId(long groupId)
1465 throws SystemException {
1466 return findByGroupId(groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1467 }
1468
1469
1482 public List<AssetCategory> findByGroupId(long groupId, int start, int end)
1483 throws SystemException {
1484 return findByGroupId(groupId, start, end, null);
1485 }
1486
1487
1501 public List<AssetCategory> findByGroupId(long groupId, int start, int end,
1502 OrderByComparator orderByComparator) throws SystemException {
1503 FinderPath finderPath = null;
1504 Object[] finderArgs = null;
1505
1506 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1507 (orderByComparator == null)) {
1508 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID;
1509 finderArgs = new Object[] { groupId };
1510 }
1511 else {
1512 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID;
1513 finderArgs = new Object[] { groupId, start, end, orderByComparator };
1514 }
1515
1516 List<AssetCategory> list = (List<AssetCategory>)FinderCacheUtil.getResult(finderPath,
1517 finderArgs, this);
1518
1519 if (list == null) {
1520 StringBundler query = null;
1521
1522 if (orderByComparator != null) {
1523 query = new StringBundler(3 +
1524 (orderByComparator.getOrderByFields().length * 3));
1525 }
1526 else {
1527 query = new StringBundler(3);
1528 }
1529
1530 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
1531
1532 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1533
1534 if (orderByComparator != null) {
1535 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1536 orderByComparator);
1537 }
1538
1539 else {
1540 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
1541 }
1542
1543 String sql = query.toString();
1544
1545 Session session = null;
1546
1547 try {
1548 session = openSession();
1549
1550 Query q = session.createQuery(sql);
1551
1552 QueryPos qPos = QueryPos.getInstance(q);
1553
1554 qPos.add(groupId);
1555
1556 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
1557 start, end);
1558 }
1559 catch (Exception e) {
1560 throw processException(e);
1561 }
1562 finally {
1563 if (list == null) {
1564 FinderCacheUtil.removeResult(finderPath, finderArgs);
1565 }
1566 else {
1567 cacheResult(list);
1568
1569 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1570 }
1571
1572 closeSession(session);
1573 }
1574 }
1575
1576 return list;
1577 }
1578
1579
1592 public AssetCategory findByGroupId_First(long groupId,
1593 OrderByComparator orderByComparator)
1594 throws NoSuchCategoryException, SystemException {
1595 List<AssetCategory> list = findByGroupId(groupId, 0, 1,
1596 orderByComparator);
1597
1598 if (list.isEmpty()) {
1599 StringBundler msg = new StringBundler(4);
1600
1601 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1602
1603 msg.append("groupId=");
1604 msg.append(groupId);
1605
1606 msg.append(StringPool.CLOSE_CURLY_BRACE);
1607
1608 throw new NoSuchCategoryException(msg.toString());
1609 }
1610 else {
1611 return list.get(0);
1612 }
1613 }
1614
1615
1628 public AssetCategory findByGroupId_Last(long groupId,
1629 OrderByComparator orderByComparator)
1630 throws NoSuchCategoryException, SystemException {
1631 int count = countByGroupId(groupId);
1632
1633 List<AssetCategory> list = findByGroupId(groupId, count - 1, count,
1634 orderByComparator);
1635
1636 if (list.isEmpty()) {
1637 StringBundler msg = new StringBundler(4);
1638
1639 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1640
1641 msg.append("groupId=");
1642 msg.append(groupId);
1643
1644 msg.append(StringPool.CLOSE_CURLY_BRACE);
1645
1646 throw new NoSuchCategoryException(msg.toString());
1647 }
1648 else {
1649 return list.get(0);
1650 }
1651 }
1652
1653
1667 public AssetCategory[] findByGroupId_PrevAndNext(long categoryId,
1668 long groupId, OrderByComparator orderByComparator)
1669 throws NoSuchCategoryException, SystemException {
1670 AssetCategory assetCategory = findByPrimaryKey(categoryId);
1671
1672 Session session = null;
1673
1674 try {
1675 session = openSession();
1676
1677 AssetCategory[] array = new AssetCategoryImpl[3];
1678
1679 array[0] = getByGroupId_PrevAndNext(session, assetCategory,
1680 groupId, orderByComparator, true);
1681
1682 array[1] = assetCategory;
1683
1684 array[2] = getByGroupId_PrevAndNext(session, assetCategory,
1685 groupId, orderByComparator, false);
1686
1687 return array;
1688 }
1689 catch (Exception e) {
1690 throw processException(e);
1691 }
1692 finally {
1693 closeSession(session);
1694 }
1695 }
1696
1697 protected AssetCategory getByGroupId_PrevAndNext(Session session,
1698 AssetCategory assetCategory, long groupId,
1699 OrderByComparator orderByComparator, boolean previous) {
1700 StringBundler query = null;
1701
1702 if (orderByComparator != null) {
1703 query = new StringBundler(6 +
1704 (orderByComparator.getOrderByFields().length * 6));
1705 }
1706 else {
1707 query = new StringBundler(3);
1708 }
1709
1710 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
1711
1712 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1713
1714 if (orderByComparator != null) {
1715 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1716
1717 if (orderByConditionFields.length > 0) {
1718 query.append(WHERE_AND);
1719 }
1720
1721 for (int i = 0; i < orderByConditionFields.length; i++) {
1722 query.append(_ORDER_BY_ENTITY_ALIAS);
1723 query.append(orderByConditionFields[i]);
1724
1725 if ((i + 1) < orderByConditionFields.length) {
1726 if (orderByComparator.isAscending() ^ previous) {
1727 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1728 }
1729 else {
1730 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1731 }
1732 }
1733 else {
1734 if (orderByComparator.isAscending() ^ previous) {
1735 query.append(WHERE_GREATER_THAN);
1736 }
1737 else {
1738 query.append(WHERE_LESSER_THAN);
1739 }
1740 }
1741 }
1742
1743 query.append(ORDER_BY_CLAUSE);
1744
1745 String[] orderByFields = orderByComparator.getOrderByFields();
1746
1747 for (int i = 0; i < orderByFields.length; i++) {
1748 query.append(_ORDER_BY_ENTITY_ALIAS);
1749 query.append(orderByFields[i]);
1750
1751 if ((i + 1) < orderByFields.length) {
1752 if (orderByComparator.isAscending() ^ previous) {
1753 query.append(ORDER_BY_ASC_HAS_NEXT);
1754 }
1755 else {
1756 query.append(ORDER_BY_DESC_HAS_NEXT);
1757 }
1758 }
1759 else {
1760 if (orderByComparator.isAscending() ^ previous) {
1761 query.append(ORDER_BY_ASC);
1762 }
1763 else {
1764 query.append(ORDER_BY_DESC);
1765 }
1766 }
1767 }
1768 }
1769
1770 else {
1771 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
1772 }
1773
1774 String sql = query.toString();
1775
1776 Query q = session.createQuery(sql);
1777
1778 q.setFirstResult(0);
1779 q.setMaxResults(2);
1780
1781 QueryPos qPos = QueryPos.getInstance(q);
1782
1783 qPos.add(groupId);
1784
1785 if (orderByComparator != null) {
1786 Object[] values = orderByComparator.getOrderByConditionValues(assetCategory);
1787
1788 for (Object value : values) {
1789 qPos.add(value);
1790 }
1791 }
1792
1793 List<AssetCategory> list = q.list();
1794
1795 if (list.size() == 2) {
1796 return list.get(1);
1797 }
1798 else {
1799 return null;
1800 }
1801 }
1802
1803
1810 public List<AssetCategory> filterFindByGroupId(long groupId)
1811 throws SystemException {
1812 return filterFindByGroupId(groupId, QueryUtil.ALL_POS,
1813 QueryUtil.ALL_POS, null);
1814 }
1815
1816
1829 public List<AssetCategory> filterFindByGroupId(long groupId, int start,
1830 int end) throws SystemException {
1831 return filterFindByGroupId(groupId, start, end, null);
1832 }
1833
1834
1848 public List<AssetCategory> filterFindByGroupId(long groupId, int start,
1849 int end, OrderByComparator orderByComparator) throws SystemException {
1850 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
1851 return findByGroupId(groupId, start, end, orderByComparator);
1852 }
1853
1854 StringBundler query = null;
1855
1856 if (orderByComparator != null) {
1857 query = new StringBundler(3 +
1858 (orderByComparator.getOrderByFields().length * 3));
1859 }
1860 else {
1861 query = new StringBundler(3);
1862 }
1863
1864 if (getDB().isSupportsInlineDistinct()) {
1865 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_WHERE);
1866 }
1867 else {
1868 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_1);
1869 }
1870
1871 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1872
1873 if (!getDB().isSupportsInlineDistinct()) {
1874 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_2);
1875 }
1876
1877 if (orderByComparator != null) {
1878 if (getDB().isSupportsInlineDistinct()) {
1879 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1880 orderByComparator);
1881 }
1882 else {
1883 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
1884 orderByComparator);
1885 }
1886 }
1887
1888 else {
1889 if (getDB().isSupportsInlineDistinct()) {
1890 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
1891 }
1892 else {
1893 query.append(AssetCategoryModelImpl.ORDER_BY_SQL);
1894 }
1895 }
1896
1897 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1898 AssetCategory.class.getName(),
1899 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
1900
1901 Session session = null;
1902
1903 try {
1904 session = openSession();
1905
1906 SQLQuery q = session.createSQLQuery(sql);
1907
1908 if (getDB().isSupportsInlineDistinct()) {
1909 q.addEntity(_FILTER_ENTITY_ALIAS, AssetCategoryImpl.class);
1910 }
1911 else {
1912 q.addEntity(_FILTER_ENTITY_TABLE, AssetCategoryImpl.class);
1913 }
1914
1915 QueryPos qPos = QueryPos.getInstance(q);
1916
1917 qPos.add(groupId);
1918
1919 return (List<AssetCategory>)QueryUtil.list(q, getDialect(), start,
1920 end);
1921 }
1922 catch (Exception e) {
1923 throw processException(e);
1924 }
1925 finally {
1926 closeSession(session);
1927 }
1928 }
1929
1930
1940 public AssetCategory[] filterFindByGroupId_PrevAndNext(long categoryId,
1941 long groupId, OrderByComparator orderByComparator)
1942 throws NoSuchCategoryException, SystemException {
1943 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
1944 return findByGroupId_PrevAndNext(categoryId, groupId,
1945 orderByComparator);
1946 }
1947
1948 AssetCategory assetCategory = findByPrimaryKey(categoryId);
1949
1950 Session session = null;
1951
1952 try {
1953 session = openSession();
1954
1955 AssetCategory[] array = new AssetCategoryImpl[3];
1956
1957 array[0] = filterGetByGroupId_PrevAndNext(session, assetCategory,
1958 groupId, orderByComparator, true);
1959
1960 array[1] = assetCategory;
1961
1962 array[2] = filterGetByGroupId_PrevAndNext(session, assetCategory,
1963 groupId, orderByComparator, false);
1964
1965 return array;
1966 }
1967 catch (Exception e) {
1968 throw processException(e);
1969 }
1970 finally {
1971 closeSession(session);
1972 }
1973 }
1974
1975 protected AssetCategory filterGetByGroupId_PrevAndNext(Session session,
1976 AssetCategory assetCategory, long groupId,
1977 OrderByComparator orderByComparator, boolean previous) {
1978 StringBundler query = null;
1979
1980 if (orderByComparator != null) {
1981 query = new StringBundler(6 +
1982 (orderByComparator.getOrderByFields().length * 6));
1983 }
1984 else {
1985 query = new StringBundler(3);
1986 }
1987
1988 if (getDB().isSupportsInlineDistinct()) {
1989 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_WHERE);
1990 }
1991 else {
1992 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_1);
1993 }
1994
1995 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1996
1997 if (!getDB().isSupportsInlineDistinct()) {
1998 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_2);
1999 }
2000
2001 if (orderByComparator != null) {
2002 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2003
2004 if (orderByConditionFields.length > 0) {
2005 query.append(WHERE_AND);
2006 }
2007
2008 for (int i = 0; i < orderByConditionFields.length; i++) {
2009 if (getDB().isSupportsInlineDistinct()) {
2010 query.append(_ORDER_BY_ENTITY_ALIAS);
2011 }
2012 else {
2013 query.append(_ORDER_BY_ENTITY_TABLE);
2014 }
2015
2016 query.append(orderByConditionFields[i]);
2017
2018 if ((i + 1) < orderByConditionFields.length) {
2019 if (orderByComparator.isAscending() ^ previous) {
2020 query.append(WHERE_GREATER_THAN_HAS_NEXT);
2021 }
2022 else {
2023 query.append(WHERE_LESSER_THAN_HAS_NEXT);
2024 }
2025 }
2026 else {
2027 if (orderByComparator.isAscending() ^ previous) {
2028 query.append(WHERE_GREATER_THAN);
2029 }
2030 else {
2031 query.append(WHERE_LESSER_THAN);
2032 }
2033 }
2034 }
2035
2036 query.append(ORDER_BY_CLAUSE);
2037
2038 String[] orderByFields = orderByComparator.getOrderByFields();
2039
2040 for (int i = 0; i < orderByFields.length; i++) {
2041 if (getDB().isSupportsInlineDistinct()) {
2042 query.append(_ORDER_BY_ENTITY_ALIAS);
2043 }
2044 else {
2045 query.append(_ORDER_BY_ENTITY_TABLE);
2046 }
2047
2048 query.append(orderByFields[i]);
2049
2050 if ((i + 1) < orderByFields.length) {
2051 if (orderByComparator.isAscending() ^ previous) {
2052 query.append(ORDER_BY_ASC_HAS_NEXT);
2053 }
2054 else {
2055 query.append(ORDER_BY_DESC_HAS_NEXT);
2056 }
2057 }
2058 else {
2059 if (orderByComparator.isAscending() ^ previous) {
2060 query.append(ORDER_BY_ASC);
2061 }
2062 else {
2063 query.append(ORDER_BY_DESC);
2064 }
2065 }
2066 }
2067 }
2068
2069 else {
2070 if (getDB().isSupportsInlineDistinct()) {
2071 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
2072 }
2073 else {
2074 query.append(AssetCategoryModelImpl.ORDER_BY_SQL);
2075 }
2076 }
2077
2078 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2079 AssetCategory.class.getName(),
2080 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2081
2082 SQLQuery q = session.createSQLQuery(sql);
2083
2084 q.setFirstResult(0);
2085 q.setMaxResults(2);
2086
2087 if (getDB().isSupportsInlineDistinct()) {
2088 q.addEntity(_FILTER_ENTITY_ALIAS, AssetCategoryImpl.class);
2089 }
2090 else {
2091 q.addEntity(_FILTER_ENTITY_TABLE, AssetCategoryImpl.class);
2092 }
2093
2094 QueryPos qPos = QueryPos.getInstance(q);
2095
2096 qPos.add(groupId);
2097
2098 if (orderByComparator != null) {
2099 Object[] values = orderByComparator.getOrderByConditionValues(assetCategory);
2100
2101 for (Object value : values) {
2102 qPos.add(value);
2103 }
2104 }
2105
2106 List<AssetCategory> list = q.list();
2107
2108 if (list.size() == 2) {
2109 return list.get(1);
2110 }
2111 else {
2112 return null;
2113 }
2114 }
2115
2116
2123 public List<AssetCategory> findByParentCategoryId(long parentCategoryId)
2124 throws SystemException {
2125 return findByParentCategoryId(parentCategoryId, QueryUtil.ALL_POS,
2126 QueryUtil.ALL_POS, null);
2127 }
2128
2129
2142 public List<AssetCategory> findByParentCategoryId(long parentCategoryId,
2143 int start, int end) throws SystemException {
2144 return findByParentCategoryId(parentCategoryId, start, end, null);
2145 }
2146
2147
2161 public List<AssetCategory> findByParentCategoryId(long parentCategoryId,
2162 int start, int end, OrderByComparator orderByComparator)
2163 throws SystemException {
2164 FinderPath finderPath = null;
2165 Object[] finderArgs = null;
2166
2167 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2168 (orderByComparator == null)) {
2169 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_PARENTCATEGORYID;
2170 finderArgs = new Object[] { parentCategoryId };
2171 }
2172 else {
2173 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_PARENTCATEGORYID;
2174 finderArgs = new Object[] {
2175 parentCategoryId,
2176
2177 start, end, orderByComparator
2178 };
2179 }
2180
2181 List<AssetCategory> list = (List<AssetCategory>)FinderCacheUtil.getResult(finderPath,
2182 finderArgs, this);
2183
2184 if (list == null) {
2185 StringBundler query = null;
2186
2187 if (orderByComparator != null) {
2188 query = new StringBundler(3 +
2189 (orderByComparator.getOrderByFields().length * 3));
2190 }
2191 else {
2192 query = new StringBundler(3);
2193 }
2194
2195 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
2196
2197 query.append(_FINDER_COLUMN_PARENTCATEGORYID_PARENTCATEGORYID_2);
2198
2199 if (orderByComparator != null) {
2200 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2201 orderByComparator);
2202 }
2203
2204 else {
2205 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
2206 }
2207
2208 String sql = query.toString();
2209
2210 Session session = null;
2211
2212 try {
2213 session = openSession();
2214
2215 Query q = session.createQuery(sql);
2216
2217 QueryPos qPos = QueryPos.getInstance(q);
2218
2219 qPos.add(parentCategoryId);
2220
2221 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
2222 start, end);
2223 }
2224 catch (Exception e) {
2225 throw processException(e);
2226 }
2227 finally {
2228 if (list == null) {
2229 FinderCacheUtil.removeResult(finderPath, finderArgs);
2230 }
2231 else {
2232 cacheResult(list);
2233
2234 FinderCacheUtil.putResult(finderPath, finderArgs, list);
2235 }
2236
2237 closeSession(session);
2238 }
2239 }
2240
2241 return list;
2242 }
2243
2244
2257 public AssetCategory findByParentCategoryId_First(long parentCategoryId,
2258 OrderByComparator orderByComparator)
2259 throws NoSuchCategoryException, SystemException {
2260 List<AssetCategory> list = findByParentCategoryId(parentCategoryId, 0,
2261 1, orderByComparator);
2262
2263 if (list.isEmpty()) {
2264 StringBundler msg = new StringBundler(4);
2265
2266 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2267
2268 msg.append("parentCategoryId=");
2269 msg.append(parentCategoryId);
2270
2271 msg.append(StringPool.CLOSE_CURLY_BRACE);
2272
2273 throw new NoSuchCategoryException(msg.toString());
2274 }
2275 else {
2276 return list.get(0);
2277 }
2278 }
2279
2280
2293 public AssetCategory findByParentCategoryId_Last(long parentCategoryId,
2294 OrderByComparator orderByComparator)
2295 throws NoSuchCategoryException, SystemException {
2296 int count = countByParentCategoryId(parentCategoryId);
2297
2298 List<AssetCategory> list = findByParentCategoryId(parentCategoryId,
2299 count - 1, count, orderByComparator);
2300
2301 if (list.isEmpty()) {
2302 StringBundler msg = new StringBundler(4);
2303
2304 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2305
2306 msg.append("parentCategoryId=");
2307 msg.append(parentCategoryId);
2308
2309 msg.append(StringPool.CLOSE_CURLY_BRACE);
2310
2311 throw new NoSuchCategoryException(msg.toString());
2312 }
2313 else {
2314 return list.get(0);
2315 }
2316 }
2317
2318
2332 public AssetCategory[] findByParentCategoryId_PrevAndNext(long categoryId,
2333 long parentCategoryId, OrderByComparator orderByComparator)
2334 throws NoSuchCategoryException, SystemException {
2335 AssetCategory assetCategory = findByPrimaryKey(categoryId);
2336
2337 Session session = null;
2338
2339 try {
2340 session = openSession();
2341
2342 AssetCategory[] array = new AssetCategoryImpl[3];
2343
2344 array[0] = getByParentCategoryId_PrevAndNext(session,
2345 assetCategory, parentCategoryId, orderByComparator, true);
2346
2347 array[1] = assetCategory;
2348
2349 array[2] = getByParentCategoryId_PrevAndNext(session,
2350 assetCategory, parentCategoryId, orderByComparator, false);
2351
2352 return array;
2353 }
2354 catch (Exception e) {
2355 throw processException(e);
2356 }
2357 finally {
2358 closeSession(session);
2359 }
2360 }
2361
2362 protected AssetCategory getByParentCategoryId_PrevAndNext(Session session,
2363 AssetCategory assetCategory, long parentCategoryId,
2364 OrderByComparator orderByComparator, boolean previous) {
2365 StringBundler query = null;
2366
2367 if (orderByComparator != null) {
2368 query = new StringBundler(6 +
2369 (orderByComparator.getOrderByFields().length * 6));
2370 }
2371 else {
2372 query = new StringBundler(3);
2373 }
2374
2375 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
2376
2377 query.append(_FINDER_COLUMN_PARENTCATEGORYID_PARENTCATEGORYID_2);
2378
2379 if (orderByComparator != null) {
2380 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2381
2382 if (orderByConditionFields.length > 0) {
2383 query.append(WHERE_AND);
2384 }
2385
2386 for (int i = 0; i < orderByConditionFields.length; i++) {
2387 query.append(_ORDER_BY_ENTITY_ALIAS);
2388 query.append(orderByConditionFields[i]);
2389
2390 if ((i + 1) < orderByConditionFields.length) {
2391 if (orderByComparator.isAscending() ^ previous) {
2392 query.append(WHERE_GREATER_THAN_HAS_NEXT);
2393 }
2394 else {
2395 query.append(WHERE_LESSER_THAN_HAS_NEXT);
2396 }
2397 }
2398 else {
2399 if (orderByComparator.isAscending() ^ previous) {
2400 query.append(WHERE_GREATER_THAN);
2401 }
2402 else {
2403 query.append(WHERE_LESSER_THAN);
2404 }
2405 }
2406 }
2407
2408 query.append(ORDER_BY_CLAUSE);
2409
2410 String[] orderByFields = orderByComparator.getOrderByFields();
2411
2412 for (int i = 0; i < orderByFields.length; i++) {
2413 query.append(_ORDER_BY_ENTITY_ALIAS);
2414 query.append(orderByFields[i]);
2415
2416 if ((i + 1) < orderByFields.length) {
2417 if (orderByComparator.isAscending() ^ previous) {
2418 query.append(ORDER_BY_ASC_HAS_NEXT);
2419 }
2420 else {
2421 query.append(ORDER_BY_DESC_HAS_NEXT);
2422 }
2423 }
2424 else {
2425 if (orderByComparator.isAscending() ^ previous) {
2426 query.append(ORDER_BY_ASC);
2427 }
2428 else {
2429 query.append(ORDER_BY_DESC);
2430 }
2431 }
2432 }
2433 }
2434
2435 else {
2436 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
2437 }
2438
2439 String sql = query.toString();
2440
2441 Query q = session.createQuery(sql);
2442
2443 q.setFirstResult(0);
2444 q.setMaxResults(2);
2445
2446 QueryPos qPos = QueryPos.getInstance(q);
2447
2448 qPos.add(parentCategoryId);
2449
2450 if (orderByComparator != null) {
2451 Object[] values = orderByComparator.getOrderByConditionValues(assetCategory);
2452
2453 for (Object value : values) {
2454 qPos.add(value);
2455 }
2456 }
2457
2458 List<AssetCategory> list = q.list();
2459
2460 if (list.size() == 2) {
2461 return list.get(1);
2462 }
2463 else {
2464 return null;
2465 }
2466 }
2467
2468
2475 public List<AssetCategory> findByVocabularyId(long vocabularyId)
2476 throws SystemException {
2477 return findByVocabularyId(vocabularyId, QueryUtil.ALL_POS,
2478 QueryUtil.ALL_POS, null);
2479 }
2480
2481
2494 public List<AssetCategory> findByVocabularyId(long vocabularyId, int start,
2495 int end) throws SystemException {
2496 return findByVocabularyId(vocabularyId, start, end, null);
2497 }
2498
2499
2513 public List<AssetCategory> findByVocabularyId(long vocabularyId, int start,
2514 int end, OrderByComparator orderByComparator) throws SystemException {
2515 FinderPath finderPath = null;
2516 Object[] finderArgs = null;
2517
2518 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2519 (orderByComparator == null)) {
2520 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_VOCABULARYID;
2521 finderArgs = new Object[] { vocabularyId };
2522 }
2523 else {
2524 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_VOCABULARYID;
2525 finderArgs = new Object[] {
2526 vocabularyId,
2527
2528 start, end, orderByComparator
2529 };
2530 }
2531
2532 List<AssetCategory> list = (List<AssetCategory>)FinderCacheUtil.getResult(finderPath,
2533 finderArgs, this);
2534
2535 if (list == null) {
2536 StringBundler query = null;
2537
2538 if (orderByComparator != null) {
2539 query = new StringBundler(3 +
2540 (orderByComparator.getOrderByFields().length * 3));
2541 }
2542 else {
2543 query = new StringBundler(3);
2544 }
2545
2546 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
2547
2548 query.append(_FINDER_COLUMN_VOCABULARYID_VOCABULARYID_2);
2549
2550 if (orderByComparator != null) {
2551 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2552 orderByComparator);
2553 }
2554
2555 else {
2556 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
2557 }
2558
2559 String sql = query.toString();
2560
2561 Session session = null;
2562
2563 try {
2564 session = openSession();
2565
2566 Query q = session.createQuery(sql);
2567
2568 QueryPos qPos = QueryPos.getInstance(q);
2569
2570 qPos.add(vocabularyId);
2571
2572 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
2573 start, end);
2574 }
2575 catch (Exception e) {
2576 throw processException(e);
2577 }
2578 finally {
2579 if (list == null) {
2580 FinderCacheUtil.removeResult(finderPath, finderArgs);
2581 }
2582 else {
2583 cacheResult(list);
2584
2585 FinderCacheUtil.putResult(finderPath, finderArgs, list);
2586 }
2587
2588 closeSession(session);
2589 }
2590 }
2591
2592 return list;
2593 }
2594
2595
2608 public AssetCategory findByVocabularyId_First(long vocabularyId,
2609 OrderByComparator orderByComparator)
2610 throws NoSuchCategoryException, SystemException {
2611 List<AssetCategory> list = findByVocabularyId(vocabularyId, 0, 1,
2612 orderByComparator);
2613
2614 if (list.isEmpty()) {
2615 StringBundler msg = new StringBundler(4);
2616
2617 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2618
2619 msg.append("vocabularyId=");
2620 msg.append(vocabularyId);
2621
2622 msg.append(StringPool.CLOSE_CURLY_BRACE);
2623
2624 throw new NoSuchCategoryException(msg.toString());
2625 }
2626 else {
2627 return list.get(0);
2628 }
2629 }
2630
2631
2644 public AssetCategory findByVocabularyId_Last(long vocabularyId,
2645 OrderByComparator orderByComparator)
2646 throws NoSuchCategoryException, SystemException {
2647 int count = countByVocabularyId(vocabularyId);
2648
2649 List<AssetCategory> list = findByVocabularyId(vocabularyId, count - 1,
2650 count, orderByComparator);
2651
2652 if (list.isEmpty()) {
2653 StringBundler msg = new StringBundler(4);
2654
2655 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2656
2657 msg.append("vocabularyId=");
2658 msg.append(vocabularyId);
2659
2660 msg.append(StringPool.CLOSE_CURLY_BRACE);
2661
2662 throw new NoSuchCategoryException(msg.toString());
2663 }
2664 else {
2665 return list.get(0);
2666 }
2667 }
2668
2669
2683 public AssetCategory[] findByVocabularyId_PrevAndNext(long categoryId,
2684 long vocabularyId, OrderByComparator orderByComparator)
2685 throws NoSuchCategoryException, SystemException {
2686 AssetCategory assetCategory = findByPrimaryKey(categoryId);
2687
2688 Session session = null;
2689
2690 try {
2691 session = openSession();
2692
2693 AssetCategory[] array = new AssetCategoryImpl[3];
2694
2695 array[0] = getByVocabularyId_PrevAndNext(session, assetCategory,
2696 vocabularyId, orderByComparator, true);
2697
2698 array[1] = assetCategory;
2699
2700 array[2] = getByVocabularyId_PrevAndNext(session, assetCategory,
2701 vocabularyId, orderByComparator, false);
2702
2703 return array;
2704 }
2705 catch (Exception e) {
2706 throw processException(e);
2707 }
2708 finally {
2709 closeSession(session);
2710 }
2711 }
2712
2713 protected AssetCategory getByVocabularyId_PrevAndNext(Session session,
2714 AssetCategory assetCategory, long vocabularyId,
2715 OrderByComparator orderByComparator, boolean previous) {
2716 StringBundler query = null;
2717
2718 if (orderByComparator != null) {
2719 query = new StringBundler(6 +
2720 (orderByComparator.getOrderByFields().length * 6));
2721 }
2722 else {
2723 query = new StringBundler(3);
2724 }
2725
2726 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
2727
2728 query.append(_FINDER_COLUMN_VOCABULARYID_VOCABULARYID_2);
2729
2730 if (orderByComparator != null) {
2731 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2732
2733 if (orderByConditionFields.length > 0) {
2734 query.append(WHERE_AND);
2735 }
2736
2737 for (int i = 0; i < orderByConditionFields.length; i++) {
2738 query.append(_ORDER_BY_ENTITY_ALIAS);
2739 query.append(orderByConditionFields[i]);
2740
2741 if ((i + 1) < orderByConditionFields.length) {
2742 if (orderByComparator.isAscending() ^ previous) {
2743 query.append(WHERE_GREATER_THAN_HAS_NEXT);
2744 }
2745 else {
2746 query.append(WHERE_LESSER_THAN_HAS_NEXT);
2747 }
2748 }
2749 else {
2750 if (orderByComparator.isAscending() ^ previous) {
2751 query.append(WHERE_GREATER_THAN);
2752 }
2753 else {
2754 query.append(WHERE_LESSER_THAN);
2755 }
2756 }
2757 }
2758
2759 query.append(ORDER_BY_CLAUSE);
2760
2761 String[] orderByFields = orderByComparator.getOrderByFields();
2762
2763 for (int i = 0; i < orderByFields.length; i++) {
2764 query.append(_ORDER_BY_ENTITY_ALIAS);
2765 query.append(orderByFields[i]);
2766
2767 if ((i + 1) < orderByFields.length) {
2768 if (orderByComparator.isAscending() ^ previous) {
2769 query.append(ORDER_BY_ASC_HAS_NEXT);
2770 }
2771 else {
2772 query.append(ORDER_BY_DESC_HAS_NEXT);
2773 }
2774 }
2775 else {
2776 if (orderByComparator.isAscending() ^ previous) {
2777 query.append(ORDER_BY_ASC);
2778 }
2779 else {
2780 query.append(ORDER_BY_DESC);
2781 }
2782 }
2783 }
2784 }
2785
2786 else {
2787 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
2788 }
2789
2790 String sql = query.toString();
2791
2792 Query q = session.createQuery(sql);
2793
2794 q.setFirstResult(0);
2795 q.setMaxResults(2);
2796
2797 QueryPos qPos = QueryPos.getInstance(q);
2798
2799 qPos.add(vocabularyId);
2800
2801 if (orderByComparator != null) {
2802 Object[] values = orderByComparator.getOrderByConditionValues(assetCategory);
2803
2804 for (Object value : values) {
2805 qPos.add(value);
2806 }
2807 }
2808
2809 List<AssetCategory> list = q.list();
2810
2811 if (list.size() == 2) {
2812 return list.get(1);
2813 }
2814 else {
2815 return null;
2816 }
2817 }
2818
2819
2827 public List<AssetCategory> findByG_V(long groupId, long vocabularyId)
2828 throws SystemException {
2829 return findByG_V(groupId, vocabularyId, QueryUtil.ALL_POS,
2830 QueryUtil.ALL_POS, null);
2831 }
2832
2833
2847 public List<AssetCategory> findByG_V(long groupId, long vocabularyId,
2848 int start, int end) throws SystemException {
2849 return findByG_V(groupId, vocabularyId, start, end, null);
2850 }
2851
2852
2867 public List<AssetCategory> findByG_V(long groupId, long vocabularyId,
2868 int start, int end, OrderByComparator orderByComparator)
2869 throws SystemException {
2870 FinderPath finderPath = null;
2871 Object[] finderArgs = null;
2872
2873 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2874 (orderByComparator == null)) {
2875 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_V;
2876 finderArgs = new Object[] { groupId, vocabularyId };
2877 }
2878 else {
2879 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_V;
2880 finderArgs = new Object[] {
2881 groupId, vocabularyId,
2882
2883 start, end, orderByComparator
2884 };
2885 }
2886
2887 List<AssetCategory> list = (List<AssetCategory>)FinderCacheUtil.getResult(finderPath,
2888 finderArgs, this);
2889
2890 if (list == null) {
2891 StringBundler query = null;
2892
2893 if (orderByComparator != null) {
2894 query = new StringBundler(4 +
2895 (orderByComparator.getOrderByFields().length * 3));
2896 }
2897 else {
2898 query = new StringBundler(4);
2899 }
2900
2901 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
2902
2903 query.append(_FINDER_COLUMN_G_V_GROUPID_2);
2904
2905 query.append(_FINDER_COLUMN_G_V_VOCABULARYID_2);
2906
2907 if (orderByComparator != null) {
2908 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2909 orderByComparator);
2910 }
2911
2912 else {
2913 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
2914 }
2915
2916 String sql = query.toString();
2917
2918 Session session = null;
2919
2920 try {
2921 session = openSession();
2922
2923 Query q = session.createQuery(sql);
2924
2925 QueryPos qPos = QueryPos.getInstance(q);
2926
2927 qPos.add(groupId);
2928
2929 qPos.add(vocabularyId);
2930
2931 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
2932 start, end);
2933 }
2934 catch (Exception e) {
2935 throw processException(e);
2936 }
2937 finally {
2938 if (list == null) {
2939 FinderCacheUtil.removeResult(finderPath, finderArgs);
2940 }
2941 else {
2942 cacheResult(list);
2943
2944 FinderCacheUtil.putResult(finderPath, finderArgs, list);
2945 }
2946
2947 closeSession(session);
2948 }
2949 }
2950
2951 return list;
2952 }
2953
2954
2968 public AssetCategory findByG_V_First(long groupId, long vocabularyId,
2969 OrderByComparator orderByComparator)
2970 throws NoSuchCategoryException, SystemException {
2971 List<AssetCategory> list = findByG_V(groupId, vocabularyId, 0, 1,
2972 orderByComparator);
2973
2974 if (list.isEmpty()) {
2975 StringBundler msg = new StringBundler(6);
2976
2977 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2978
2979 msg.append("groupId=");
2980 msg.append(groupId);
2981
2982 msg.append(", vocabularyId=");
2983 msg.append(vocabularyId);
2984
2985 msg.append(StringPool.CLOSE_CURLY_BRACE);
2986
2987 throw new NoSuchCategoryException(msg.toString());
2988 }
2989 else {
2990 return list.get(0);
2991 }
2992 }
2993
2994
3008 public AssetCategory findByG_V_Last(long groupId, long vocabularyId,
3009 OrderByComparator orderByComparator)
3010 throws NoSuchCategoryException, SystemException {
3011 int count = countByG_V(groupId, vocabularyId);
3012
3013 List<AssetCategory> list = findByG_V(groupId, vocabularyId, count - 1,
3014 count, orderByComparator);
3015
3016 if (list.isEmpty()) {
3017 StringBundler msg = new StringBundler(6);
3018
3019 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3020
3021 msg.append("groupId=");
3022 msg.append(groupId);
3023
3024 msg.append(", vocabularyId=");
3025 msg.append(vocabularyId);
3026
3027 msg.append(StringPool.CLOSE_CURLY_BRACE);
3028
3029 throw new NoSuchCategoryException(msg.toString());
3030 }
3031 else {
3032 return list.get(0);
3033 }
3034 }
3035
3036
3051 public AssetCategory[] findByG_V_PrevAndNext(long categoryId, long groupId,
3052 long vocabularyId, OrderByComparator orderByComparator)
3053 throws NoSuchCategoryException, SystemException {
3054 AssetCategory assetCategory = findByPrimaryKey(categoryId);
3055
3056 Session session = null;
3057
3058 try {
3059 session = openSession();
3060
3061 AssetCategory[] array = new AssetCategoryImpl[3];
3062
3063 array[0] = getByG_V_PrevAndNext(session, assetCategory, groupId,
3064 vocabularyId, orderByComparator, true);
3065
3066 array[1] = assetCategory;
3067
3068 array[2] = getByG_V_PrevAndNext(session, assetCategory, groupId,
3069 vocabularyId, orderByComparator, false);
3070
3071 return array;
3072 }
3073 catch (Exception e) {
3074 throw processException(e);
3075 }
3076 finally {
3077 closeSession(session);
3078 }
3079 }
3080
3081 protected AssetCategory getByG_V_PrevAndNext(Session session,
3082 AssetCategory assetCategory, long groupId, long vocabularyId,
3083 OrderByComparator orderByComparator, boolean previous) {
3084 StringBundler query = null;
3085
3086 if (orderByComparator != null) {
3087 query = new StringBundler(6 +
3088 (orderByComparator.getOrderByFields().length * 6));
3089 }
3090 else {
3091 query = new StringBundler(3);
3092 }
3093
3094 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
3095
3096 query.append(_FINDER_COLUMN_G_V_GROUPID_2);
3097
3098 query.append(_FINDER_COLUMN_G_V_VOCABULARYID_2);
3099
3100 if (orderByComparator != null) {
3101 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3102
3103 if (orderByConditionFields.length > 0) {
3104 query.append(WHERE_AND);
3105 }
3106
3107 for (int i = 0; i < orderByConditionFields.length; i++) {
3108 query.append(_ORDER_BY_ENTITY_ALIAS);
3109 query.append(orderByConditionFields[i]);
3110
3111 if ((i + 1) < orderByConditionFields.length) {
3112 if (orderByComparator.isAscending() ^ previous) {
3113 query.append(WHERE_GREATER_THAN_HAS_NEXT);
3114 }
3115 else {
3116 query.append(WHERE_LESSER_THAN_HAS_NEXT);
3117 }
3118 }
3119 else {
3120 if (orderByComparator.isAscending() ^ previous) {
3121 query.append(WHERE_GREATER_THAN);
3122 }
3123 else {
3124 query.append(WHERE_LESSER_THAN);
3125 }
3126 }
3127 }
3128
3129 query.append(ORDER_BY_CLAUSE);
3130
3131 String[] orderByFields = orderByComparator.getOrderByFields();
3132
3133 for (int i = 0; i < orderByFields.length; i++) {
3134 query.append(_ORDER_BY_ENTITY_ALIAS);
3135 query.append(orderByFields[i]);
3136
3137 if ((i + 1) < orderByFields.length) {
3138 if (orderByComparator.isAscending() ^ previous) {
3139 query.append(ORDER_BY_ASC_HAS_NEXT);
3140 }
3141 else {
3142 query.append(ORDER_BY_DESC_HAS_NEXT);
3143 }
3144 }
3145 else {
3146 if (orderByComparator.isAscending() ^ previous) {
3147 query.append(ORDER_BY_ASC);
3148 }
3149 else {
3150 query.append(ORDER_BY_DESC);
3151 }
3152 }
3153 }
3154 }
3155
3156 else {
3157 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
3158 }
3159
3160 String sql = query.toString();
3161
3162 Query q = session.createQuery(sql);
3163
3164 q.setFirstResult(0);
3165 q.setMaxResults(2);
3166
3167 QueryPos qPos = QueryPos.getInstance(q);
3168
3169 qPos.add(groupId);
3170
3171 qPos.add(vocabularyId);
3172
3173 if (orderByComparator != null) {
3174 Object[] values = orderByComparator.getOrderByConditionValues(assetCategory);
3175
3176 for (Object value : values) {
3177 qPos.add(value);
3178 }
3179 }
3180
3181 List<AssetCategory> list = q.list();
3182
3183 if (list.size() == 2) {
3184 return list.get(1);
3185 }
3186 else {
3187 return null;
3188 }
3189 }
3190
3191
3199 public List<AssetCategory> filterFindByG_V(long groupId, long vocabularyId)
3200 throws SystemException {
3201 return filterFindByG_V(groupId, vocabularyId, QueryUtil.ALL_POS,
3202 QueryUtil.ALL_POS, null);
3203 }
3204
3205
3219 public List<AssetCategory> filterFindByG_V(long groupId, long vocabularyId,
3220 int start, int end) throws SystemException {
3221 return filterFindByG_V(groupId, vocabularyId, start, end, null);
3222 }
3223
3224
3239 public List<AssetCategory> filterFindByG_V(long groupId, long vocabularyId,
3240 int start, int end, OrderByComparator orderByComparator)
3241 throws SystemException {
3242 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
3243 return findByG_V(groupId, vocabularyId, start, end,
3244 orderByComparator);
3245 }
3246
3247 StringBundler query = null;
3248
3249 if (orderByComparator != null) {
3250 query = new StringBundler(4 +
3251 (orderByComparator.getOrderByFields().length * 3));
3252 }
3253 else {
3254 query = new StringBundler(4);
3255 }
3256
3257 if (getDB().isSupportsInlineDistinct()) {
3258 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_WHERE);
3259 }
3260 else {
3261 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_1);
3262 }
3263
3264 query.append(_FINDER_COLUMN_G_V_GROUPID_2);
3265
3266 query.append(_FINDER_COLUMN_G_V_VOCABULARYID_2);
3267
3268 if (!getDB().isSupportsInlineDistinct()) {
3269 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_2);
3270 }
3271
3272 if (orderByComparator != null) {
3273 if (getDB().isSupportsInlineDistinct()) {
3274 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3275 orderByComparator);
3276 }
3277 else {
3278 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
3279 orderByComparator);
3280 }
3281 }
3282
3283 else {
3284 if (getDB().isSupportsInlineDistinct()) {
3285 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
3286 }
3287 else {
3288 query.append(AssetCategoryModelImpl.ORDER_BY_SQL);
3289 }
3290 }
3291
3292 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
3293 AssetCategory.class.getName(),
3294 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
3295
3296 Session session = null;
3297
3298 try {
3299 session = openSession();
3300
3301 SQLQuery q = session.createSQLQuery(sql);
3302
3303 if (getDB().isSupportsInlineDistinct()) {
3304 q.addEntity(_FILTER_ENTITY_ALIAS, AssetCategoryImpl.class);
3305 }
3306 else {
3307 q.addEntity(_FILTER_ENTITY_TABLE, AssetCategoryImpl.class);
3308 }
3309
3310 QueryPos qPos = QueryPos.getInstance(q);
3311
3312 qPos.add(groupId);
3313
3314 qPos.add(vocabularyId);
3315
3316 return (List<AssetCategory>)QueryUtil.list(q, getDialect(), start,
3317 end);
3318 }
3319 catch (Exception e) {
3320 throw processException(e);
3321 }
3322 finally {
3323 closeSession(session);
3324 }
3325 }
3326
3327
3338 public AssetCategory[] filterFindByG_V_PrevAndNext(long categoryId,
3339 long groupId, long vocabularyId, OrderByComparator orderByComparator)
3340 throws NoSuchCategoryException, SystemException {
3341 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
3342 return findByG_V_PrevAndNext(categoryId, groupId, vocabularyId,
3343 orderByComparator);
3344 }
3345
3346 AssetCategory assetCategory = findByPrimaryKey(categoryId);
3347
3348 Session session = null;
3349
3350 try {
3351 session = openSession();
3352
3353 AssetCategory[] array = new AssetCategoryImpl[3];
3354
3355 array[0] = filterGetByG_V_PrevAndNext(session, assetCategory,
3356 groupId, vocabularyId, orderByComparator, true);
3357
3358 array[1] = assetCategory;
3359
3360 array[2] = filterGetByG_V_PrevAndNext(session, assetCategory,
3361 groupId, vocabularyId, orderByComparator, false);
3362
3363 return array;
3364 }
3365 catch (Exception e) {
3366 throw processException(e);
3367 }
3368 finally {
3369 closeSession(session);
3370 }
3371 }
3372
3373 protected AssetCategory filterGetByG_V_PrevAndNext(Session session,
3374 AssetCategory assetCategory, long groupId, long vocabularyId,
3375 OrderByComparator orderByComparator, boolean previous) {
3376 StringBundler query = null;
3377
3378 if (orderByComparator != null) {
3379 query = new StringBundler(6 +
3380 (orderByComparator.getOrderByFields().length * 6));
3381 }
3382 else {
3383 query = new StringBundler(3);
3384 }
3385
3386 if (getDB().isSupportsInlineDistinct()) {
3387 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_WHERE);
3388 }
3389 else {
3390 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_1);
3391 }
3392
3393 query.append(_FINDER_COLUMN_G_V_GROUPID_2);
3394
3395 query.append(_FINDER_COLUMN_G_V_VOCABULARYID_2);
3396
3397 if (!getDB().isSupportsInlineDistinct()) {
3398 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_2);
3399 }
3400
3401 if (orderByComparator != null) {
3402 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3403
3404 if (orderByConditionFields.length > 0) {
3405 query.append(WHERE_AND);
3406 }
3407
3408 for (int i = 0; i < orderByConditionFields.length; i++) {
3409 if (getDB().isSupportsInlineDistinct()) {
3410 query.append(_ORDER_BY_ENTITY_ALIAS);
3411 }
3412 else {
3413 query.append(_ORDER_BY_ENTITY_TABLE);
3414 }
3415
3416 query.append(orderByConditionFields[i]);
3417
3418 if ((i + 1) < orderByConditionFields.length) {
3419 if (orderByComparator.isAscending() ^ previous) {
3420 query.append(WHERE_GREATER_THAN_HAS_NEXT);
3421 }
3422 else {
3423 query.append(WHERE_LESSER_THAN_HAS_NEXT);
3424 }
3425 }
3426 else {
3427 if (orderByComparator.isAscending() ^ previous) {
3428 query.append(WHERE_GREATER_THAN);
3429 }
3430 else {
3431 query.append(WHERE_LESSER_THAN);
3432 }
3433 }
3434 }
3435
3436 query.append(ORDER_BY_CLAUSE);
3437
3438 String[] orderByFields = orderByComparator.getOrderByFields();
3439
3440 for (int i = 0; i < orderByFields.length; i++) {
3441 if (getDB().isSupportsInlineDistinct()) {
3442 query.append(_ORDER_BY_ENTITY_ALIAS);
3443 }
3444 else {
3445 query.append(_ORDER_BY_ENTITY_TABLE);
3446 }
3447
3448 query.append(orderByFields[i]);
3449
3450 if ((i + 1) < orderByFields.length) {
3451 if (orderByComparator.isAscending() ^ previous) {
3452 query.append(ORDER_BY_ASC_HAS_NEXT);
3453 }
3454 else {
3455 query.append(ORDER_BY_DESC_HAS_NEXT);
3456 }
3457 }
3458 else {
3459 if (orderByComparator.isAscending() ^ previous) {
3460 query.append(ORDER_BY_ASC);
3461 }
3462 else {
3463 query.append(ORDER_BY_DESC);
3464 }
3465 }
3466 }
3467 }
3468
3469 else {
3470 if (getDB().isSupportsInlineDistinct()) {
3471 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
3472 }
3473 else {
3474 query.append(AssetCategoryModelImpl.ORDER_BY_SQL);
3475 }
3476 }
3477
3478 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
3479 AssetCategory.class.getName(),
3480 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
3481
3482 SQLQuery q = session.createSQLQuery(sql);
3483
3484 q.setFirstResult(0);
3485 q.setMaxResults(2);
3486
3487 if (getDB().isSupportsInlineDistinct()) {
3488 q.addEntity(_FILTER_ENTITY_ALIAS, AssetCategoryImpl.class);
3489 }
3490 else {
3491 q.addEntity(_FILTER_ENTITY_TABLE, AssetCategoryImpl.class);
3492 }
3493
3494 QueryPos qPos = QueryPos.getInstance(q);
3495
3496 qPos.add(groupId);
3497
3498 qPos.add(vocabularyId);
3499
3500 if (orderByComparator != null) {
3501 Object[] values = orderByComparator.getOrderByConditionValues(assetCategory);
3502
3503 for (Object value : values) {
3504 qPos.add(value);
3505 }
3506 }
3507
3508 List<AssetCategory> list = q.list();
3509
3510 if (list.size() == 2) {
3511 return list.get(1);
3512 }
3513 else {
3514 return null;
3515 }
3516 }
3517
3518
3526 public List<AssetCategory> findByP_N(long parentCategoryId, String name)
3527 throws SystemException {
3528 return findByP_N(parentCategoryId, name, QueryUtil.ALL_POS,
3529 QueryUtil.ALL_POS, null);
3530 }
3531
3532
3546 public List<AssetCategory> findByP_N(long parentCategoryId, String name,
3547 int start, int end) throws SystemException {
3548 return findByP_N(parentCategoryId, name, start, end, null);
3549 }
3550
3551
3566 public List<AssetCategory> findByP_N(long parentCategoryId, String name,
3567 int start, int end, OrderByComparator orderByComparator)
3568 throws SystemException {
3569 FinderPath finderPath = null;
3570 Object[] finderArgs = null;
3571
3572 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
3573 (orderByComparator == null)) {
3574 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_P_N;
3575 finderArgs = new Object[] { parentCategoryId, name };
3576 }
3577 else {
3578 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_P_N;
3579 finderArgs = new Object[] {
3580 parentCategoryId, name,
3581
3582 start, end, orderByComparator
3583 };
3584 }
3585
3586 List<AssetCategory> list = (List<AssetCategory>)FinderCacheUtil.getResult(finderPath,
3587 finderArgs, this);
3588
3589 if (list == null) {
3590 StringBundler query = null;
3591
3592 if (orderByComparator != null) {
3593 query = new StringBundler(4 +
3594 (orderByComparator.getOrderByFields().length * 3));
3595 }
3596 else {
3597 query = new StringBundler(4);
3598 }
3599
3600 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
3601
3602 query.append(_FINDER_COLUMN_P_N_PARENTCATEGORYID_2);
3603
3604 if (name == null) {
3605 query.append(_FINDER_COLUMN_P_N_NAME_1);
3606 }
3607 else {
3608 if (name.equals(StringPool.BLANK)) {
3609 query.append(_FINDER_COLUMN_P_N_NAME_3);
3610 }
3611 else {
3612 query.append(_FINDER_COLUMN_P_N_NAME_2);
3613 }
3614 }
3615
3616 if (orderByComparator != null) {
3617 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3618 orderByComparator);
3619 }
3620
3621 else {
3622 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
3623 }
3624
3625 String sql = query.toString();
3626
3627 Session session = null;
3628
3629 try {
3630 session = openSession();
3631
3632 Query q = session.createQuery(sql);
3633
3634 QueryPos qPos = QueryPos.getInstance(q);
3635
3636 qPos.add(parentCategoryId);
3637
3638 if (name != null) {
3639 qPos.add(name);
3640 }
3641
3642 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
3643 start, end);
3644 }
3645 catch (Exception e) {
3646 throw processException(e);
3647 }
3648 finally {
3649 if (list == null) {
3650 FinderCacheUtil.removeResult(finderPath, finderArgs);
3651 }
3652 else {
3653 cacheResult(list);
3654
3655 FinderCacheUtil.putResult(finderPath, finderArgs, list);
3656 }
3657
3658 closeSession(session);
3659 }
3660 }
3661
3662 return list;
3663 }
3664
3665
3679 public AssetCategory findByP_N_First(long parentCategoryId, String name,
3680 OrderByComparator orderByComparator)
3681 throws NoSuchCategoryException, SystemException {
3682 List<AssetCategory> list = findByP_N(parentCategoryId, name, 0, 1,
3683 orderByComparator);
3684
3685 if (list.isEmpty()) {
3686 StringBundler msg = new StringBundler(6);
3687
3688 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3689
3690 msg.append("parentCategoryId=");
3691 msg.append(parentCategoryId);
3692
3693 msg.append(", name=");
3694 msg.append(name);
3695
3696 msg.append(StringPool.CLOSE_CURLY_BRACE);
3697
3698 throw new NoSuchCategoryException(msg.toString());
3699 }
3700 else {
3701 return list.get(0);
3702 }
3703 }
3704
3705
3719 public AssetCategory findByP_N_Last(long parentCategoryId, String name,
3720 OrderByComparator orderByComparator)
3721 throws NoSuchCategoryException, SystemException {
3722 int count = countByP_N(parentCategoryId, name);
3723
3724 List<AssetCategory> list = findByP_N(parentCategoryId, name, count - 1,
3725 count, orderByComparator);
3726
3727 if (list.isEmpty()) {
3728 StringBundler msg = new StringBundler(6);
3729
3730 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3731
3732 msg.append("parentCategoryId=");
3733 msg.append(parentCategoryId);
3734
3735 msg.append(", name=");
3736 msg.append(name);
3737
3738 msg.append(StringPool.CLOSE_CURLY_BRACE);
3739
3740 throw new NoSuchCategoryException(msg.toString());
3741 }
3742 else {
3743 return list.get(0);
3744 }
3745 }
3746
3747
3762 public AssetCategory[] findByP_N_PrevAndNext(long categoryId,
3763 long parentCategoryId, String name, OrderByComparator orderByComparator)
3764 throws NoSuchCategoryException, SystemException {
3765 AssetCategory assetCategory = findByPrimaryKey(categoryId);
3766
3767 Session session = null;
3768
3769 try {
3770 session = openSession();
3771
3772 AssetCategory[] array = new AssetCategoryImpl[3];
3773
3774 array[0] = getByP_N_PrevAndNext(session, assetCategory,
3775 parentCategoryId, name, orderByComparator, true);
3776
3777 array[1] = assetCategory;
3778
3779 array[2] = getByP_N_PrevAndNext(session, assetCategory,
3780 parentCategoryId, name, orderByComparator, false);
3781
3782 return array;
3783 }
3784 catch (Exception e) {
3785 throw processException(e);
3786 }
3787 finally {
3788 closeSession(session);
3789 }
3790 }
3791
3792 protected AssetCategory getByP_N_PrevAndNext(Session session,
3793 AssetCategory assetCategory, long parentCategoryId, String name,
3794 OrderByComparator orderByComparator, boolean previous) {
3795 StringBundler query = null;
3796
3797 if (orderByComparator != null) {
3798 query = new StringBundler(6 +
3799 (orderByComparator.getOrderByFields().length * 6));
3800 }
3801 else {
3802 query = new StringBundler(3);
3803 }
3804
3805 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
3806
3807 query.append(_FINDER_COLUMN_P_N_PARENTCATEGORYID_2);
3808
3809 if (name == null) {
3810 query.append(_FINDER_COLUMN_P_N_NAME_1);
3811 }
3812 else {
3813 if (name.equals(StringPool.BLANK)) {
3814 query.append(_FINDER_COLUMN_P_N_NAME_3);
3815 }
3816 else {
3817 query.append(_FINDER_COLUMN_P_N_NAME_2);
3818 }
3819 }
3820
3821 if (orderByComparator != null) {
3822 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3823
3824 if (orderByConditionFields.length > 0) {
3825 query.append(WHERE_AND);
3826 }
3827
3828 for (int i = 0; i < orderByConditionFields.length; i++) {
3829 query.append(_ORDER_BY_ENTITY_ALIAS);
3830 query.append(orderByConditionFields[i]);
3831
3832 if ((i + 1) < orderByConditionFields.length) {
3833 if (orderByComparator.isAscending() ^ previous) {
3834 query.append(WHERE_GREATER_THAN_HAS_NEXT);
3835 }
3836 else {
3837 query.append(WHERE_LESSER_THAN_HAS_NEXT);
3838 }
3839 }
3840 else {
3841 if (orderByComparator.isAscending() ^ previous) {
3842 query.append(WHERE_GREATER_THAN);
3843 }
3844 else {
3845 query.append(WHERE_LESSER_THAN);
3846 }
3847 }
3848 }
3849
3850 query.append(ORDER_BY_CLAUSE);
3851
3852 String[] orderByFields = orderByComparator.getOrderByFields();
3853
3854 for (int i = 0; i < orderByFields.length; i++) {
3855 query.append(_ORDER_BY_ENTITY_ALIAS);
3856 query.append(orderByFields[i]);
3857
3858 if ((i + 1) < orderByFields.length) {
3859 if (orderByComparator.isAscending() ^ previous) {
3860 query.append(ORDER_BY_ASC_HAS_NEXT);
3861 }
3862 else {
3863 query.append(ORDER_BY_DESC_HAS_NEXT);
3864 }
3865 }
3866 else {
3867 if (orderByComparator.isAscending() ^ previous) {
3868 query.append(ORDER_BY_ASC);
3869 }
3870 else {
3871 query.append(ORDER_BY_DESC);
3872 }
3873 }
3874 }
3875 }
3876
3877 else {
3878 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
3879 }
3880
3881 String sql = query.toString();
3882
3883 Query q = session.createQuery(sql);
3884
3885 q.setFirstResult(0);
3886 q.setMaxResults(2);
3887
3888 QueryPos qPos = QueryPos.getInstance(q);
3889
3890 qPos.add(parentCategoryId);
3891
3892 if (name != null) {
3893 qPos.add(name);
3894 }
3895
3896 if (orderByComparator != null) {
3897 Object[] values = orderByComparator.getOrderByConditionValues(assetCategory);
3898
3899 for (Object value : values) {
3900 qPos.add(value);
3901 }
3902 }
3903
3904 List<AssetCategory> list = q.list();
3905
3906 if (list.size() == 2) {
3907 return list.get(1);
3908 }
3909 else {
3910 return null;
3911 }
3912 }
3913
3914
3922 public List<AssetCategory> findByP_V(long parentCategoryId,
3923 long vocabularyId) throws SystemException {
3924 return findByP_V(parentCategoryId, vocabularyId, QueryUtil.ALL_POS,
3925 QueryUtil.ALL_POS, null);
3926 }
3927
3928
3942 public List<AssetCategory> findByP_V(long parentCategoryId,
3943 long vocabularyId, int start, int end) throws SystemException {
3944 return findByP_V(parentCategoryId, vocabularyId, start, end, null);
3945 }
3946
3947
3962 public List<AssetCategory> findByP_V(long parentCategoryId,
3963 long vocabularyId, int start, int end,
3964 OrderByComparator orderByComparator) throws SystemException {
3965 FinderPath finderPath = null;
3966 Object[] finderArgs = null;
3967
3968 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
3969 (orderByComparator == null)) {
3970 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_P_V;
3971 finderArgs = new Object[] { parentCategoryId, vocabularyId };
3972 }
3973 else {
3974 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_P_V;
3975 finderArgs = new Object[] {
3976 parentCategoryId, vocabularyId,
3977
3978 start, end, orderByComparator
3979 };
3980 }
3981
3982 List<AssetCategory> list = (List<AssetCategory>)FinderCacheUtil.getResult(finderPath,
3983 finderArgs, this);
3984
3985 if (list == null) {
3986 StringBundler query = null;
3987
3988 if (orderByComparator != null) {
3989 query = new StringBundler(4 +
3990 (orderByComparator.getOrderByFields().length * 3));
3991 }
3992 else {
3993 query = new StringBundler(4);
3994 }
3995
3996 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
3997
3998 query.append(_FINDER_COLUMN_P_V_PARENTCATEGORYID_2);
3999
4000 query.append(_FINDER_COLUMN_P_V_VOCABULARYID_2);
4001
4002 if (orderByComparator != null) {
4003 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4004 orderByComparator);
4005 }
4006
4007 else {
4008 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
4009 }
4010
4011 String sql = query.toString();
4012
4013 Session session = null;
4014
4015 try {
4016 session = openSession();
4017
4018 Query q = session.createQuery(sql);
4019
4020 QueryPos qPos = QueryPos.getInstance(q);
4021
4022 qPos.add(parentCategoryId);
4023
4024 qPos.add(vocabularyId);
4025
4026 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
4027 start, end);
4028 }
4029 catch (Exception e) {
4030 throw processException(e);
4031 }
4032 finally {
4033 if (list == null) {
4034 FinderCacheUtil.removeResult(finderPath, finderArgs);
4035 }
4036 else {
4037 cacheResult(list);
4038
4039 FinderCacheUtil.putResult(finderPath, finderArgs, list);
4040 }
4041
4042 closeSession(session);
4043 }
4044 }
4045
4046 return list;
4047 }
4048
4049
4063 public AssetCategory findByP_V_First(long parentCategoryId,
4064 long vocabularyId, OrderByComparator orderByComparator)
4065 throws NoSuchCategoryException, SystemException {
4066 List<AssetCategory> list = findByP_V(parentCategoryId, vocabularyId, 0,
4067 1, orderByComparator);
4068
4069 if (list.isEmpty()) {
4070 StringBundler msg = new StringBundler(6);
4071
4072 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4073
4074 msg.append("parentCategoryId=");
4075 msg.append(parentCategoryId);
4076
4077 msg.append(", vocabularyId=");
4078 msg.append(vocabularyId);
4079
4080 msg.append(StringPool.CLOSE_CURLY_BRACE);
4081
4082 throw new NoSuchCategoryException(msg.toString());
4083 }
4084 else {
4085 return list.get(0);
4086 }
4087 }
4088
4089
4103 public AssetCategory findByP_V_Last(long parentCategoryId,
4104 long vocabularyId, OrderByComparator orderByComparator)
4105 throws NoSuchCategoryException, SystemException {
4106 int count = countByP_V(parentCategoryId, vocabularyId);
4107
4108 List<AssetCategory> list = findByP_V(parentCategoryId, vocabularyId,
4109 count - 1, count, orderByComparator);
4110
4111 if (list.isEmpty()) {
4112 StringBundler msg = new StringBundler(6);
4113
4114 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4115
4116 msg.append("parentCategoryId=");
4117 msg.append(parentCategoryId);
4118
4119 msg.append(", vocabularyId=");
4120 msg.append(vocabularyId);
4121
4122 msg.append(StringPool.CLOSE_CURLY_BRACE);
4123
4124 throw new NoSuchCategoryException(msg.toString());
4125 }
4126 else {
4127 return list.get(0);
4128 }
4129 }
4130
4131
4146 public AssetCategory[] findByP_V_PrevAndNext(long categoryId,
4147 long parentCategoryId, long vocabularyId,
4148 OrderByComparator orderByComparator)
4149 throws NoSuchCategoryException, SystemException {
4150 AssetCategory assetCategory = findByPrimaryKey(categoryId);
4151
4152 Session session = null;
4153
4154 try {
4155 session = openSession();
4156
4157 AssetCategory[] array = new AssetCategoryImpl[3];
4158
4159 array[0] = getByP_V_PrevAndNext(session, assetCategory,
4160 parentCategoryId, vocabularyId, orderByComparator, true);
4161
4162 array[1] = assetCategory;
4163
4164 array[2] = getByP_V_PrevAndNext(session, assetCategory,
4165 parentCategoryId, vocabularyId, orderByComparator, false);
4166
4167 return array;
4168 }
4169 catch (Exception e) {
4170 throw processException(e);
4171 }
4172 finally {
4173 closeSession(session);
4174 }
4175 }
4176
4177 protected AssetCategory getByP_V_PrevAndNext(Session session,
4178 AssetCategory assetCategory, long parentCategoryId, long vocabularyId,
4179 OrderByComparator orderByComparator, boolean previous) {
4180 StringBundler query = null;
4181
4182 if (orderByComparator != null) {
4183 query = new StringBundler(6 +
4184 (orderByComparator.getOrderByFields().length * 6));
4185 }
4186 else {
4187 query = new StringBundler(3);
4188 }
4189
4190 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
4191
4192 query.append(_FINDER_COLUMN_P_V_PARENTCATEGORYID_2);
4193
4194 query.append(_FINDER_COLUMN_P_V_VOCABULARYID_2);
4195
4196 if (orderByComparator != null) {
4197 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
4198
4199 if (orderByConditionFields.length > 0) {
4200 query.append(WHERE_AND);
4201 }
4202
4203 for (int i = 0; i < orderByConditionFields.length; i++) {
4204 query.append(_ORDER_BY_ENTITY_ALIAS);
4205 query.append(orderByConditionFields[i]);
4206
4207 if ((i + 1) < orderByConditionFields.length) {
4208 if (orderByComparator.isAscending() ^ previous) {
4209 query.append(WHERE_GREATER_THAN_HAS_NEXT);
4210 }
4211 else {
4212 query.append(WHERE_LESSER_THAN_HAS_NEXT);
4213 }
4214 }
4215 else {
4216 if (orderByComparator.isAscending() ^ previous) {
4217 query.append(WHERE_GREATER_THAN);
4218 }
4219 else {
4220 query.append(WHERE_LESSER_THAN);
4221 }
4222 }
4223 }
4224
4225 query.append(ORDER_BY_CLAUSE);
4226
4227 String[] orderByFields = orderByComparator.getOrderByFields();
4228
4229 for (int i = 0; i < orderByFields.length; i++) {
4230 query.append(_ORDER_BY_ENTITY_ALIAS);
4231 query.append(orderByFields[i]);
4232
4233 if ((i + 1) < orderByFields.length) {
4234 if (orderByComparator.isAscending() ^ previous) {
4235 query.append(ORDER_BY_ASC_HAS_NEXT);
4236 }
4237 else {
4238 query.append(ORDER_BY_DESC_HAS_NEXT);
4239 }
4240 }
4241 else {
4242 if (orderByComparator.isAscending() ^ previous) {
4243 query.append(ORDER_BY_ASC);
4244 }
4245 else {
4246 query.append(ORDER_BY_DESC);
4247 }
4248 }
4249 }
4250 }
4251
4252 else {
4253 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
4254 }
4255
4256 String sql = query.toString();
4257
4258 Query q = session.createQuery(sql);
4259
4260 q.setFirstResult(0);
4261 q.setMaxResults(2);
4262
4263 QueryPos qPos = QueryPos.getInstance(q);
4264
4265 qPos.add(parentCategoryId);
4266
4267 qPos.add(vocabularyId);
4268
4269 if (orderByComparator != null) {
4270 Object[] values = orderByComparator.getOrderByConditionValues(assetCategory);
4271
4272 for (Object value : values) {
4273 qPos.add(value);
4274 }
4275 }
4276
4277 List<AssetCategory> list = q.list();
4278
4279 if (list.size() == 2) {
4280 return list.get(1);
4281 }
4282 else {
4283 return null;
4284 }
4285 }
4286
4287
4295 public List<AssetCategory> findByN_V(String name, long vocabularyId)
4296 throws SystemException {
4297 return findByN_V(name, vocabularyId, QueryUtil.ALL_POS,
4298 QueryUtil.ALL_POS, null);
4299 }
4300
4301
4315 public List<AssetCategory> findByN_V(String name, long vocabularyId,
4316 int start, int end) throws SystemException {
4317 return findByN_V(name, vocabularyId, start, end, null);
4318 }
4319
4320
4335 public List<AssetCategory> findByN_V(String name, long vocabularyId,
4336 int start, int end, OrderByComparator orderByComparator)
4337 throws SystemException {
4338 FinderPath finderPath = null;
4339 Object[] finderArgs = null;
4340
4341 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
4342 (orderByComparator == null)) {
4343 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_V;
4344 finderArgs = new Object[] { name, vocabularyId };
4345 }
4346 else {
4347 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_N_V;
4348 finderArgs = new Object[] {
4349 name, vocabularyId,
4350
4351 start, end, orderByComparator
4352 };
4353 }
4354
4355 List<AssetCategory> list = (List<AssetCategory>)FinderCacheUtil.getResult(finderPath,
4356 finderArgs, this);
4357
4358 if (list == null) {
4359 StringBundler query = null;
4360
4361 if (orderByComparator != null) {
4362 query = new StringBundler(4 +
4363 (orderByComparator.getOrderByFields().length * 3));
4364 }
4365 else {
4366 query = new StringBundler(4);
4367 }
4368
4369 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
4370
4371 if (name == null) {
4372 query.append(_FINDER_COLUMN_N_V_NAME_1);
4373 }
4374 else {
4375 if (name.equals(StringPool.BLANK)) {
4376 query.append(_FINDER_COLUMN_N_V_NAME_3);
4377 }
4378 else {
4379 query.append(_FINDER_COLUMN_N_V_NAME_2);
4380 }
4381 }
4382
4383 query.append(_FINDER_COLUMN_N_V_VOCABULARYID_2);
4384
4385 if (orderByComparator != null) {
4386 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4387 orderByComparator);
4388 }
4389
4390 else {
4391 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
4392 }
4393
4394 String sql = query.toString();
4395
4396 Session session = null;
4397
4398 try {
4399 session = openSession();
4400
4401 Query q = session.createQuery(sql);
4402
4403 QueryPos qPos = QueryPos.getInstance(q);
4404
4405 if (name != null) {
4406 qPos.add(name);
4407 }
4408
4409 qPos.add(vocabularyId);
4410
4411 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
4412 start, end);
4413 }
4414 catch (Exception e) {
4415 throw processException(e);
4416 }
4417 finally {
4418 if (list == null) {
4419 FinderCacheUtil.removeResult(finderPath, finderArgs);
4420 }
4421 else {
4422 cacheResult(list);
4423
4424 FinderCacheUtil.putResult(finderPath, finderArgs, list);
4425 }
4426
4427 closeSession(session);
4428 }
4429 }
4430
4431 return list;
4432 }
4433
4434
4448 public AssetCategory findByN_V_First(String name, long vocabularyId,
4449 OrderByComparator orderByComparator)
4450 throws NoSuchCategoryException, SystemException {
4451 List<AssetCategory> list = findByN_V(name, vocabularyId, 0, 1,
4452 orderByComparator);
4453
4454 if (list.isEmpty()) {
4455 StringBundler msg = new StringBundler(6);
4456
4457 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4458
4459 msg.append("name=");
4460 msg.append(name);
4461
4462 msg.append(", vocabularyId=");
4463 msg.append(vocabularyId);
4464
4465 msg.append(StringPool.CLOSE_CURLY_BRACE);
4466
4467 throw new NoSuchCategoryException(msg.toString());
4468 }
4469 else {
4470 return list.get(0);
4471 }
4472 }
4473
4474
4488 public AssetCategory findByN_V_Last(String name, long vocabularyId,
4489 OrderByComparator orderByComparator)
4490 throws NoSuchCategoryException, SystemException {
4491 int count = countByN_V(name, vocabularyId);
4492
4493 List<AssetCategory> list = findByN_V(name, vocabularyId, count - 1,
4494 count, orderByComparator);
4495
4496 if (list.isEmpty()) {
4497 StringBundler msg = new StringBundler(6);
4498
4499 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4500
4501 msg.append("name=");
4502 msg.append(name);
4503
4504 msg.append(", vocabularyId=");
4505 msg.append(vocabularyId);
4506
4507 msg.append(StringPool.CLOSE_CURLY_BRACE);
4508
4509 throw new NoSuchCategoryException(msg.toString());
4510 }
4511 else {
4512 return list.get(0);
4513 }
4514 }
4515
4516
4531 public AssetCategory[] findByN_V_PrevAndNext(long categoryId, String name,
4532 long vocabularyId, OrderByComparator orderByComparator)
4533 throws NoSuchCategoryException, SystemException {
4534 AssetCategory assetCategory = findByPrimaryKey(categoryId);
4535
4536 Session session = null;
4537
4538 try {
4539 session = openSession();
4540
4541 AssetCategory[] array = new AssetCategoryImpl[3];
4542
4543 array[0] = getByN_V_PrevAndNext(session, assetCategory, name,
4544 vocabularyId, orderByComparator, true);
4545
4546 array[1] = assetCategory;
4547
4548 array[2] = getByN_V_PrevAndNext(session, assetCategory, name,
4549 vocabularyId, orderByComparator, false);
4550
4551 return array;
4552 }
4553 catch (Exception e) {
4554 throw processException(e);
4555 }
4556 finally {
4557 closeSession(session);
4558 }
4559 }
4560
4561 protected AssetCategory getByN_V_PrevAndNext(Session session,
4562 AssetCategory assetCategory, String name, long vocabularyId,
4563 OrderByComparator orderByComparator, boolean previous) {
4564 StringBundler query = null;
4565
4566 if (orderByComparator != null) {
4567 query = new StringBundler(6 +
4568 (orderByComparator.getOrderByFields().length * 6));
4569 }
4570 else {
4571 query = new StringBundler(3);
4572 }
4573
4574 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
4575
4576 if (name == null) {
4577 query.append(_FINDER_COLUMN_N_V_NAME_1);
4578 }
4579 else {
4580 if (name.equals(StringPool.BLANK)) {
4581 query.append(_FINDER_COLUMN_N_V_NAME_3);
4582 }
4583 else {
4584 query.append(_FINDER_COLUMN_N_V_NAME_2);
4585 }
4586 }
4587
4588 query.append(_FINDER_COLUMN_N_V_VOCABULARYID_2);
4589
4590 if (orderByComparator != null) {
4591 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
4592
4593 if (orderByConditionFields.length > 0) {
4594 query.append(WHERE_AND);
4595 }
4596
4597 for (int i = 0; i < orderByConditionFields.length; i++) {
4598 query.append(_ORDER_BY_ENTITY_ALIAS);
4599 query.append(orderByConditionFields[i]);
4600
4601 if ((i + 1) < orderByConditionFields.length) {
4602 if (orderByComparator.isAscending() ^ previous) {
4603 query.append(WHERE_GREATER_THAN_HAS_NEXT);
4604 }
4605 else {
4606 query.append(WHERE_LESSER_THAN_HAS_NEXT);
4607 }
4608 }
4609 else {
4610 if (orderByComparator.isAscending() ^ previous) {
4611 query.append(WHERE_GREATER_THAN);
4612 }
4613 else {
4614 query.append(WHERE_LESSER_THAN);
4615 }
4616 }
4617 }
4618
4619 query.append(ORDER_BY_CLAUSE);
4620
4621 String[] orderByFields = orderByComparator.getOrderByFields();
4622
4623 for (int i = 0; i < orderByFields.length; i++) {
4624 query.append(_ORDER_BY_ENTITY_ALIAS);
4625 query.append(orderByFields[i]);
4626
4627 if ((i + 1) < orderByFields.length) {
4628 if (orderByComparator.isAscending() ^ previous) {
4629 query.append(ORDER_BY_ASC_HAS_NEXT);
4630 }
4631 else {
4632 query.append(ORDER_BY_DESC_HAS_NEXT);
4633 }
4634 }
4635 else {
4636 if (orderByComparator.isAscending() ^ previous) {
4637 query.append(ORDER_BY_ASC);
4638 }
4639 else {
4640 query.append(ORDER_BY_DESC);
4641 }
4642 }
4643 }
4644 }
4645
4646 else {
4647 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
4648 }
4649
4650 String sql = query.toString();
4651
4652 Query q = session.createQuery(sql);
4653
4654 q.setFirstResult(0);
4655 q.setMaxResults(2);
4656
4657 QueryPos qPos = QueryPos.getInstance(q);
4658
4659 if (name != null) {
4660 qPos.add(name);
4661 }
4662
4663 qPos.add(vocabularyId);
4664
4665 if (orderByComparator != null) {
4666 Object[] values = orderByComparator.getOrderByConditionValues(assetCategory);
4667
4668 for (Object value : values) {
4669 qPos.add(value);
4670 }
4671 }
4672
4673 List<AssetCategory> list = q.list();
4674
4675 if (list.size() == 2) {
4676 return list.get(1);
4677 }
4678 else {
4679 return null;
4680 }
4681 }
4682
4683
4693 public AssetCategory findByP_N_V(long parentCategoryId, String name,
4694 long vocabularyId) throws NoSuchCategoryException, SystemException {
4695 AssetCategory assetCategory = fetchByP_N_V(parentCategoryId, name,
4696 vocabularyId);
4697
4698 if (assetCategory == null) {
4699 StringBundler msg = new StringBundler(8);
4700
4701 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4702
4703 msg.append("parentCategoryId=");
4704 msg.append(parentCategoryId);
4705
4706 msg.append(", name=");
4707 msg.append(name);
4708
4709 msg.append(", vocabularyId=");
4710 msg.append(vocabularyId);
4711
4712 msg.append(StringPool.CLOSE_CURLY_BRACE);
4713
4714 if (_log.isWarnEnabled()) {
4715 _log.warn(msg.toString());
4716 }
4717
4718 throw new NoSuchCategoryException(msg.toString());
4719 }
4720
4721 return assetCategory;
4722 }
4723
4724
4733 public AssetCategory fetchByP_N_V(long parentCategoryId, String name,
4734 long vocabularyId) throws SystemException {
4735 return fetchByP_N_V(parentCategoryId, name, vocabularyId, true);
4736 }
4737
4738
4748 public AssetCategory fetchByP_N_V(long parentCategoryId, String name,
4749 long vocabularyId, boolean retrieveFromCache) throws SystemException {
4750 Object[] finderArgs = new Object[] { parentCategoryId, name, vocabularyId };
4751
4752 Object result = null;
4753
4754 if (retrieveFromCache) {
4755 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_P_N_V,
4756 finderArgs, this);
4757 }
4758
4759 if (result == null) {
4760 StringBundler query = new StringBundler(5);
4761
4762 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
4763
4764 query.append(_FINDER_COLUMN_P_N_V_PARENTCATEGORYID_2);
4765
4766 if (name == null) {
4767 query.append(_FINDER_COLUMN_P_N_V_NAME_1);
4768 }
4769 else {
4770 if (name.equals(StringPool.BLANK)) {
4771 query.append(_FINDER_COLUMN_P_N_V_NAME_3);
4772 }
4773 else {
4774 query.append(_FINDER_COLUMN_P_N_V_NAME_2);
4775 }
4776 }
4777
4778 query.append(_FINDER_COLUMN_P_N_V_VOCABULARYID_2);
4779
4780 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
4781
4782 String sql = query.toString();
4783
4784 Session session = null;
4785
4786 try {
4787 session = openSession();
4788
4789 Query q = session.createQuery(sql);
4790
4791 QueryPos qPos = QueryPos.getInstance(q);
4792
4793 qPos.add(parentCategoryId);
4794
4795 if (name != null) {
4796 qPos.add(name);
4797 }
4798
4799 qPos.add(vocabularyId);
4800
4801 List<AssetCategory> list = q.list();
4802
4803 result = list;
4804
4805 AssetCategory assetCategory = null;
4806
4807 if (list.isEmpty()) {
4808 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_P_N_V,
4809 finderArgs, list);
4810 }
4811 else {
4812 assetCategory = list.get(0);
4813
4814 cacheResult(assetCategory);
4815
4816 if ((assetCategory.getParentCategoryId() != parentCategoryId) ||
4817 (assetCategory.getName() == null) ||
4818 !assetCategory.getName().equals(name) ||
4819 (assetCategory.getVocabularyId() != vocabularyId)) {
4820 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_P_N_V,
4821 finderArgs, assetCategory);
4822 }
4823 }
4824
4825 return assetCategory;
4826 }
4827 catch (Exception e) {
4828 throw processException(e);
4829 }
4830 finally {
4831 if (result == null) {
4832 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_P_N_V,
4833 finderArgs);
4834 }
4835
4836 closeSession(session);
4837 }
4838 }
4839 else {
4840 if (result instanceof List<?>) {
4841 return null;
4842 }
4843 else {
4844 return (AssetCategory)result;
4845 }
4846 }
4847 }
4848
4849
4855 public List<AssetCategory> findAll() throws SystemException {
4856 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
4857 }
4858
4859
4871 public List<AssetCategory> findAll(int start, int end)
4872 throws SystemException {
4873 return findAll(start, end, null);
4874 }
4875
4876
4889 public List<AssetCategory> findAll(int start, int end,
4890 OrderByComparator orderByComparator) throws SystemException {
4891 FinderPath finderPath = null;
4892 Object[] finderArgs = new Object[] { start, end, orderByComparator };
4893
4894 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
4895 (orderByComparator == null)) {
4896 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
4897 finderArgs = FINDER_ARGS_EMPTY;
4898 }
4899 else {
4900 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
4901 finderArgs = new Object[] { start, end, orderByComparator };
4902 }
4903
4904 List<AssetCategory> list = (List<AssetCategory>)FinderCacheUtil.getResult(finderPath,
4905 finderArgs, this);
4906
4907 if (list == null) {
4908 StringBundler query = null;
4909 String sql = null;
4910
4911 if (orderByComparator != null) {
4912 query = new StringBundler(2 +
4913 (orderByComparator.getOrderByFields().length * 3));
4914
4915 query.append(_SQL_SELECT_ASSETCATEGORY);
4916
4917 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4918 orderByComparator);
4919
4920 sql = query.toString();
4921 }
4922 else {
4923 sql = _SQL_SELECT_ASSETCATEGORY.concat(AssetCategoryModelImpl.ORDER_BY_JPQL);
4924 }
4925
4926 Session session = null;
4927
4928 try {
4929 session = openSession();
4930
4931 Query q = session.createQuery(sql);
4932
4933 if (orderByComparator == null) {
4934 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
4935 start, end, false);
4936
4937 Collections.sort(list);
4938 }
4939 else {
4940 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
4941 start, end);
4942 }
4943 }
4944 catch (Exception e) {
4945 throw processException(e);
4946 }
4947 finally {
4948 if (list == null) {
4949 FinderCacheUtil.removeResult(finderPath, finderArgs);
4950 }
4951 else {
4952 cacheResult(list);
4953
4954 FinderCacheUtil.putResult(finderPath, finderArgs, list);
4955 }
4956
4957 closeSession(session);
4958 }
4959 }
4960
4961 return list;
4962 }
4963
4964
4970 public void removeByUuid(String uuid) throws SystemException {
4971 for (AssetCategory assetCategory : findByUuid(uuid)) {
4972 assetCategoryPersistence.remove(assetCategory);
4973 }
4974 }
4975
4976
4983 public void removeByUUID_G(String uuid, long groupId)
4984 throws NoSuchCategoryException, SystemException {
4985 AssetCategory assetCategory = findByUUID_G(uuid, groupId);
4986
4987 assetCategoryPersistence.remove(assetCategory);
4988 }
4989
4990
4996 public void removeByGroupId(long groupId) throws SystemException {
4997 for (AssetCategory assetCategory : findByGroupId(groupId)) {
4998 assetCategoryPersistence.remove(assetCategory);
4999 }
5000 }
5001
5002
5008 public void removeByParentCategoryId(long parentCategoryId)
5009 throws SystemException {
5010 for (AssetCategory assetCategory : findByParentCategoryId(
5011 parentCategoryId)) {
5012 assetCategoryPersistence.remove(assetCategory);
5013 }
5014 }
5015
5016
5022 public void removeByVocabularyId(long vocabularyId)
5023 throws SystemException {
5024 for (AssetCategory assetCategory : findByVocabularyId(vocabularyId)) {
5025 assetCategoryPersistence.remove(assetCategory);
5026 }
5027 }
5028
5029
5036 public void removeByG_V(long groupId, long vocabularyId)
5037 throws SystemException {
5038 for (AssetCategory assetCategory : findByG_V(groupId, vocabularyId)) {
5039 assetCategoryPersistence.remove(assetCategory);
5040 }
5041 }
5042
5043
5050 public void removeByP_N(long parentCategoryId, String name)
5051 throws SystemException {
5052 for (AssetCategory assetCategory : findByP_N(parentCategoryId, name)) {
5053 assetCategoryPersistence.remove(assetCategory);
5054 }
5055 }
5056
5057
5064 public void removeByP_V(long parentCategoryId, long vocabularyId)
5065 throws SystemException {
5066 for (AssetCategory assetCategory : findByP_V(parentCategoryId,
5067 vocabularyId)) {
5068 assetCategoryPersistence.remove(assetCategory);
5069 }
5070 }
5071
5072
5079 public void removeByN_V(String name, long vocabularyId)
5080 throws SystemException {
5081 for (AssetCategory assetCategory : findByN_V(name, vocabularyId)) {
5082 assetCategoryPersistence.remove(assetCategory);
5083 }
5084 }
5085
5086
5094 public void removeByP_N_V(long parentCategoryId, String name,
5095 long vocabularyId) throws NoSuchCategoryException, SystemException {
5096 AssetCategory assetCategory = findByP_N_V(parentCategoryId, name,
5097 vocabularyId);
5098
5099 assetCategoryPersistence.remove(assetCategory);
5100 }
5101
5102
5107 public void removeAll() throws SystemException {
5108 for (AssetCategory assetCategory : findAll()) {
5109 assetCategoryPersistence.remove(assetCategory);
5110 }
5111 }
5112
5113
5120 public int countByUuid(String uuid) throws SystemException {
5121 Object[] finderArgs = new Object[] { uuid };
5122
5123 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID,
5124 finderArgs, this);
5125
5126 if (count == null) {
5127 StringBundler query = new StringBundler(2);
5128
5129 query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
5130
5131 if (uuid == null) {
5132 query.append(_FINDER_COLUMN_UUID_UUID_1);
5133 }
5134 else {
5135 if (uuid.equals(StringPool.BLANK)) {
5136 query.append(_FINDER_COLUMN_UUID_UUID_3);
5137 }
5138 else {
5139 query.append(_FINDER_COLUMN_UUID_UUID_2);
5140 }
5141 }
5142
5143 String sql = query.toString();
5144
5145 Session session = null;
5146
5147 try {
5148 session = openSession();
5149
5150 Query q = session.createQuery(sql);
5151
5152 QueryPos qPos = QueryPos.getInstance(q);
5153
5154 if (uuid != null) {
5155 qPos.add(uuid);
5156 }
5157
5158 count = (Long)q.uniqueResult();
5159 }
5160 catch (Exception e) {
5161 throw processException(e);
5162 }
5163 finally {
5164 if (count == null) {
5165 count = Long.valueOf(0);
5166 }
5167
5168 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID,
5169 finderArgs, count);
5170
5171 closeSession(session);
5172 }
5173 }
5174
5175 return count.intValue();
5176 }
5177
5178
5186 public int countByUUID_G(String uuid, long groupId)
5187 throws SystemException {
5188 Object[] finderArgs = new Object[] { uuid, groupId };
5189
5190 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID_G,
5191 finderArgs, this);
5192
5193 if (count == null) {
5194 StringBundler query = new StringBundler(3);
5195
5196 query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
5197
5198 if (uuid == null) {
5199 query.append(_FINDER_COLUMN_UUID_G_UUID_1);
5200 }
5201 else {
5202 if (uuid.equals(StringPool.BLANK)) {
5203 query.append(_FINDER_COLUMN_UUID_G_UUID_3);
5204 }
5205 else {
5206 query.append(_FINDER_COLUMN_UUID_G_UUID_2);
5207 }
5208 }
5209
5210 query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
5211
5212 String sql = query.toString();
5213
5214 Session session = null;
5215
5216 try {
5217 session = openSession();
5218
5219 Query q = session.createQuery(sql);
5220
5221 QueryPos qPos = QueryPos.getInstance(q);
5222
5223 if (uuid != null) {
5224 qPos.add(uuid);
5225 }
5226
5227 qPos.add(groupId);
5228
5229 count = (Long)q.uniqueResult();
5230 }
5231 catch (Exception e) {
5232 throw processException(e);
5233 }
5234 finally {
5235 if (count == null) {
5236 count = Long.valueOf(0);
5237 }
5238
5239 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G,
5240 finderArgs, count);
5241
5242 closeSession(session);
5243 }
5244 }
5245
5246 return count.intValue();
5247 }
5248
5249
5256 public int countByGroupId(long groupId) throws SystemException {
5257 Object[] finderArgs = new Object[] { groupId };
5258
5259 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_GROUPID,
5260 finderArgs, this);
5261
5262 if (count == null) {
5263 StringBundler query = new StringBundler(2);
5264
5265 query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
5266
5267 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
5268
5269 String sql = query.toString();
5270
5271 Session session = null;
5272
5273 try {
5274 session = openSession();
5275
5276 Query q = session.createQuery(sql);
5277
5278 QueryPos qPos = QueryPos.getInstance(q);
5279
5280 qPos.add(groupId);
5281
5282 count = (Long)q.uniqueResult();
5283 }
5284 catch (Exception e) {
5285 throw processException(e);
5286 }
5287 finally {
5288 if (count == null) {
5289 count = Long.valueOf(0);
5290 }
5291
5292 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_GROUPID,
5293 finderArgs, count);
5294
5295 closeSession(session);
5296 }
5297 }
5298
5299 return count.intValue();
5300 }
5301
5302
5309 public int filterCountByGroupId(long groupId) throws SystemException {
5310 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
5311 return countByGroupId(groupId);
5312 }
5313
5314 StringBundler query = new StringBundler(2);
5315
5316 query.append(_FILTER_SQL_COUNT_ASSETCATEGORY_WHERE);
5317
5318 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
5319
5320 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
5321 AssetCategory.class.getName(),
5322 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
5323
5324 Session session = null;
5325
5326 try {
5327 session = openSession();
5328
5329 SQLQuery q = session.createSQLQuery(sql);
5330
5331 q.addScalar(COUNT_COLUMN_NAME,
5332 com.liferay.portal.kernel.dao.orm.Type.LONG);
5333
5334 QueryPos qPos = QueryPos.getInstance(q);
5335
5336 qPos.add(groupId);
5337
5338 Long count = (Long)q.uniqueResult();
5339
5340 return count.intValue();
5341 }
5342 catch (Exception e) {
5343 throw processException(e);
5344 }
5345 finally {
5346 closeSession(session);
5347 }
5348 }
5349
5350
5357 public int countByParentCategoryId(long parentCategoryId)
5358 throws SystemException {
5359 Object[] finderArgs = new Object[] { parentCategoryId };
5360
5361 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_PARENTCATEGORYID,
5362 finderArgs, this);
5363
5364 if (count == null) {
5365 StringBundler query = new StringBundler(2);
5366
5367 query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
5368
5369 query.append(_FINDER_COLUMN_PARENTCATEGORYID_PARENTCATEGORYID_2);
5370
5371 String sql = query.toString();
5372
5373 Session session = null;
5374
5375 try {
5376 session = openSession();
5377
5378 Query q = session.createQuery(sql);
5379
5380 QueryPos qPos = QueryPos.getInstance(q);
5381
5382 qPos.add(parentCategoryId);
5383
5384 count = (Long)q.uniqueResult();
5385 }
5386 catch (Exception e) {
5387 throw processException(e);
5388 }
5389 finally {
5390 if (count == null) {
5391 count = Long.valueOf(0);
5392 }
5393
5394 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_PARENTCATEGORYID,
5395 finderArgs, count);
5396
5397 closeSession(session);
5398 }
5399 }
5400
5401 return count.intValue();
5402 }
5403
5404
5411 public int countByVocabularyId(long vocabularyId) throws SystemException {
5412 Object[] finderArgs = new Object[] { vocabularyId };
5413
5414 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_VOCABULARYID,
5415 finderArgs, this);
5416
5417 if (count == null) {
5418 StringBundler query = new StringBundler(2);
5419
5420 query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
5421
5422 query.append(_FINDER_COLUMN_VOCABULARYID_VOCABULARYID_2);
5423
5424 String sql = query.toString();
5425
5426 Session session = null;
5427
5428 try {
5429 session = openSession();
5430
5431 Query q = session.createQuery(sql);
5432
5433 QueryPos qPos = QueryPos.getInstance(q);
5434
5435 qPos.add(vocabularyId);
5436
5437 count = (Long)q.uniqueResult();
5438 }
5439 catch (Exception e) {
5440 throw processException(e);
5441 }
5442 finally {
5443 if (count == null) {
5444 count = Long.valueOf(0);
5445 }
5446
5447 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_VOCABULARYID,
5448 finderArgs, count);
5449
5450 closeSession(session);
5451 }
5452 }
5453
5454 return count.intValue();
5455 }
5456
5457
5465 public int countByG_V(long groupId, long vocabularyId)
5466 throws SystemException {
5467 Object[] finderArgs = new Object[] { groupId, vocabularyId };
5468
5469 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_V,
5470 finderArgs, this);
5471
5472 if (count == null) {
5473 StringBundler query = new StringBundler(3);
5474
5475 query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
5476
5477 query.append(_FINDER_COLUMN_G_V_GROUPID_2);
5478
5479 query.append(_FINDER_COLUMN_G_V_VOCABULARYID_2);
5480
5481 String sql = query.toString();
5482
5483 Session session = null;
5484
5485 try {
5486 session = openSession();
5487
5488 Query q = session.createQuery(sql);
5489
5490 QueryPos qPos = QueryPos.getInstance(q);
5491
5492 qPos.add(groupId);
5493
5494 qPos.add(vocabularyId);
5495
5496 count = (Long)q.uniqueResult();
5497 }
5498 catch (Exception e) {
5499 throw processException(e);
5500 }
5501 finally {
5502 if (count == null) {
5503 count = Long.valueOf(0);
5504 }
5505
5506 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_V, finderArgs,
5507 count);
5508
5509 closeSession(session);
5510 }
5511 }
5512
5513 return count.intValue();
5514 }
5515
5516
5524 public int filterCountByG_V(long groupId, long vocabularyId)
5525 throws SystemException {
5526 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
5527 return countByG_V(groupId, vocabularyId);
5528 }
5529
5530 StringBundler query = new StringBundler(3);
5531
5532 query.append(_FILTER_SQL_COUNT_ASSETCATEGORY_WHERE);
5533
5534 query.append(_FINDER_COLUMN_G_V_GROUPID_2);
5535
5536 query.append(_FINDER_COLUMN_G_V_VOCABULARYID_2);
5537
5538 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
5539 AssetCategory.class.getName(),
5540 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
5541
5542 Session session = null;
5543
5544 try {
5545 session = openSession();
5546
5547 SQLQuery q = session.createSQLQuery(sql);
5548
5549 q.addScalar(COUNT_COLUMN_NAME,
5550 com.liferay.portal.kernel.dao.orm.Type.LONG);
5551
5552 QueryPos qPos = QueryPos.getInstance(q);
5553
5554 qPos.add(groupId);
5555
5556 qPos.add(vocabularyId);
5557
5558 Long count = (Long)q.uniqueResult();
5559
5560 return count.intValue();
5561 }
5562 catch (Exception e) {
5563 throw processException(e);
5564 }
5565 finally {
5566 closeSession(session);
5567 }
5568 }
5569
5570
5578 public int countByP_N(long parentCategoryId, String name)
5579 throws SystemException {
5580 Object[] finderArgs = new Object[] { parentCategoryId, name };
5581
5582 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_P_N,
5583 finderArgs, this);
5584
5585 if (count == null) {
5586 StringBundler query = new StringBundler(3);
5587
5588 query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
5589
5590 query.append(_FINDER_COLUMN_P_N_PARENTCATEGORYID_2);
5591
5592 if (name == null) {
5593 query.append(_FINDER_COLUMN_P_N_NAME_1);
5594 }
5595 else {
5596 if (name.equals(StringPool.BLANK)) {
5597 query.append(_FINDER_COLUMN_P_N_NAME_3);
5598 }
5599 else {
5600 query.append(_FINDER_COLUMN_P_N_NAME_2);
5601 }
5602 }
5603
5604 String sql = query.toString();
5605
5606 Session session = null;
5607
5608 try {
5609 session = openSession();
5610
5611 Query q = session.createQuery(sql);
5612
5613 QueryPos qPos = QueryPos.getInstance(q);
5614
5615 qPos.add(parentCategoryId);
5616
5617 if (name != null) {
5618 qPos.add(name);
5619 }
5620
5621 count = (Long)q.uniqueResult();
5622 }
5623 catch (Exception e) {
5624 throw processException(e);
5625 }
5626 finally {
5627 if (count == null) {
5628 count = Long.valueOf(0);
5629 }
5630
5631 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_P_N, finderArgs,
5632 count);
5633
5634 closeSession(session);
5635 }
5636 }
5637
5638 return count.intValue();
5639 }
5640
5641
5649 public int countByP_V(long parentCategoryId, long vocabularyId)
5650 throws SystemException {
5651 Object[] finderArgs = new Object[] { parentCategoryId, vocabularyId };
5652
5653 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_P_V,
5654 finderArgs, this);
5655
5656 if (count == null) {
5657 StringBundler query = new StringBundler(3);
5658
5659 query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
5660
5661 query.append(_FINDER_COLUMN_P_V_PARENTCATEGORYID_2);
5662
5663 query.append(_FINDER_COLUMN_P_V_VOCABULARYID_2);
5664
5665 String sql = query.toString();
5666
5667 Session session = null;
5668
5669 try {
5670 session = openSession();
5671
5672 Query q = session.createQuery(sql);
5673
5674 QueryPos qPos = QueryPos.getInstance(q);
5675
5676 qPos.add(parentCategoryId);
5677
5678 qPos.add(vocabularyId);
5679
5680 count = (Long)q.uniqueResult();
5681 }
5682 catch (Exception e) {
5683 throw processException(e);
5684 }
5685 finally {
5686 if (count == null) {
5687 count = Long.valueOf(0);
5688 }
5689
5690 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_P_V, finderArgs,
5691 count);
5692
5693 closeSession(session);
5694 }
5695 }
5696
5697 return count.intValue();
5698 }
5699
5700
5708 public int countByN_V(String name, long vocabularyId)
5709 throws SystemException {
5710 Object[] finderArgs = new Object[] { name, vocabularyId };
5711
5712 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_N_V,
5713 finderArgs, this);
5714
5715 if (count == null) {
5716 StringBundler query = new StringBundler(3);
5717
5718 query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
5719
5720 if (name == null) {
5721 query.append(_FINDER_COLUMN_N_V_NAME_1);
5722 }
5723 else {
5724 if (name.equals(StringPool.BLANK)) {
5725 query.append(_FINDER_COLUMN_N_V_NAME_3);
5726 }
5727 else {
5728 query.append(_FINDER_COLUMN_N_V_NAME_2);
5729 }
5730 }
5731
5732 query.append(_FINDER_COLUMN_N_V_VOCABULARYID_2);
5733
5734 String sql = query.toString();
5735
5736 Session session = null;
5737
5738 try {
5739 session = openSession();
5740
5741 Query q = session.createQuery(sql);
5742
5743 QueryPos qPos = QueryPos.getInstance(q);
5744
5745 if (name != null) {
5746 qPos.add(name);
5747 }
5748
5749 qPos.add(vocabularyId);
5750
5751 count = (Long)q.uniqueResult();
5752 }
5753 catch (Exception e) {
5754 throw processException(e);
5755 }
5756 finally {
5757 if (count == null) {
5758 count = Long.valueOf(0);
5759 }
5760
5761 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_N_V, finderArgs,
5762 count);
5763
5764 closeSession(session);
5765 }
5766 }
5767
5768 return count.intValue();
5769 }
5770
5771
5780 public int countByP_N_V(long parentCategoryId, String name,
5781 long vocabularyId) throws SystemException {
5782 Object[] finderArgs = new Object[] { parentCategoryId, name, vocabularyId };
5783
5784 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_P_N_V,
5785 finderArgs, this);
5786
5787 if (count == null) {
5788 StringBundler query = new StringBundler(4);
5789
5790 query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
5791
5792 query.append(_FINDER_COLUMN_P_N_V_PARENTCATEGORYID_2);
5793
5794 if (name == null) {
5795 query.append(_FINDER_COLUMN_P_N_V_NAME_1);
5796 }
5797 else {
5798 if (name.equals(StringPool.BLANK)) {
5799 query.append(_FINDER_COLUMN_P_N_V_NAME_3);
5800 }
5801 else {
5802 query.append(_FINDER_COLUMN_P_N_V_NAME_2);
5803 }
5804 }
5805
5806 query.append(_FINDER_COLUMN_P_N_V_VOCABULARYID_2);
5807
5808 String sql = query.toString();
5809
5810 Session session = null;
5811
5812 try {
5813 session = openSession();
5814
5815 Query q = session.createQuery(sql);
5816
5817 QueryPos qPos = QueryPos.getInstance(q);
5818
5819 qPos.add(parentCategoryId);
5820
5821 if (name != null) {
5822 qPos.add(name);
5823 }
5824
5825 qPos.add(vocabularyId);
5826
5827 count = (Long)q.uniqueResult();
5828 }
5829 catch (Exception e) {
5830 throw processException(e);
5831 }
5832 finally {
5833 if (count == null) {
5834 count = Long.valueOf(0);
5835 }
5836
5837 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_P_N_V,
5838 finderArgs, count);
5839
5840 closeSession(session);
5841 }
5842 }
5843
5844 return count.intValue();
5845 }
5846
5847
5853 public int countAll() throws SystemException {
5854 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
5855 FINDER_ARGS_EMPTY, this);
5856
5857 if (count == null) {
5858 Session session = null;
5859
5860 try {
5861 session = openSession();
5862
5863 Query q = session.createQuery(_SQL_COUNT_ASSETCATEGORY);
5864
5865 count = (Long)q.uniqueResult();
5866 }
5867 catch (Exception e) {
5868 throw processException(e);
5869 }
5870 finally {
5871 if (count == null) {
5872 count = Long.valueOf(0);
5873 }
5874
5875 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
5876 FINDER_ARGS_EMPTY, count);
5877
5878 closeSession(session);
5879 }
5880 }
5881
5882 return count.intValue();
5883 }
5884
5885
5892 public List<com.liferay.portlet.asset.model.AssetEntry> getAssetEntries(
5893 long pk) throws SystemException {
5894 return getAssetEntries(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
5895 }
5896
5897
5910 public List<com.liferay.portlet.asset.model.AssetEntry> getAssetEntries(
5911 long pk, int start, int end) throws SystemException {
5912 return getAssetEntries(pk, start, end, null);
5913 }
5914
5915 public static final FinderPath FINDER_PATH_GET_ASSETENTRIES = new FinderPath(com.liferay.portlet.asset.model.impl.AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
5916 AssetCategoryModelImpl.FINDER_CACHE_ENABLED_ASSETENTRIES_ASSETCATEGORIES,
5917 com.liferay.portlet.asset.model.impl.AssetEntryImpl.class,
5918 AssetCategoryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME,
5919 "getAssetEntries",
5920 new String[] {
5921 Long.class.getName(), "java.lang.Integer", "java.lang.Integer",
5922 "com.liferay.portal.kernel.util.OrderByComparator"
5923 });
5924
5925
5939 public List<com.liferay.portlet.asset.model.AssetEntry> getAssetEntries(
5940 long pk, int start, int end, OrderByComparator orderByComparator)
5941 throws SystemException {
5942 Object[] finderArgs = new Object[] { pk, start, end, orderByComparator };
5943
5944 List<com.liferay.portlet.asset.model.AssetEntry> list = (List<com.liferay.portlet.asset.model.AssetEntry>)FinderCacheUtil.getResult(FINDER_PATH_GET_ASSETENTRIES,
5945 finderArgs, this);
5946
5947 if (list == null) {
5948 Session session = null;
5949
5950 try {
5951 session = openSession();
5952
5953 String sql = null;
5954
5955 if (orderByComparator != null) {
5956 sql = _SQL_GETASSETENTRIES.concat(ORDER_BY_CLAUSE)
5957 .concat(orderByComparator.getOrderBy());
5958 }
5959 else {
5960 sql = _SQL_GETASSETENTRIES;
5961 }
5962
5963 SQLQuery q = session.createSQLQuery(sql);
5964
5965 q.addEntity("AssetEntry",
5966 com.liferay.portlet.asset.model.impl.AssetEntryImpl.class);
5967
5968 QueryPos qPos = QueryPos.getInstance(q);
5969
5970 qPos.add(pk);
5971
5972 list = (List<com.liferay.portlet.asset.model.AssetEntry>)QueryUtil.list(q,
5973 getDialect(), start, end);
5974 }
5975 catch (Exception e) {
5976 throw processException(e);
5977 }
5978 finally {
5979 if (list == null) {
5980 FinderCacheUtil.removeResult(FINDER_PATH_GET_ASSETENTRIES,
5981 finderArgs);
5982 }
5983 else {
5984 assetEntryPersistence.cacheResult(list);
5985
5986 FinderCacheUtil.putResult(FINDER_PATH_GET_ASSETENTRIES,
5987 finderArgs, list);
5988 }
5989
5990 closeSession(session);
5991 }
5992 }
5993
5994 return list;
5995 }
5996
5997 public static final FinderPath FINDER_PATH_GET_ASSETENTRIES_SIZE = new FinderPath(com.liferay.portlet.asset.model.impl.AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
5998 AssetCategoryModelImpl.FINDER_CACHE_ENABLED_ASSETENTRIES_ASSETCATEGORIES,
5999 Long.class,
6000 AssetCategoryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME,
6001 "getAssetEntriesSize", new String[] { Long.class.getName() });
6002
6003
6010 public int getAssetEntriesSize(long pk) throws SystemException {
6011 Object[] finderArgs = new Object[] { pk };
6012
6013 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_GET_ASSETENTRIES_SIZE,
6014 finderArgs, this);
6015
6016 if (count == null) {
6017 Session session = null;
6018
6019 try {
6020 session = openSession();
6021
6022 SQLQuery q = session.createSQLQuery(_SQL_GETASSETENTRIESSIZE);
6023
6024 q.addScalar(COUNT_COLUMN_NAME,
6025 com.liferay.portal.kernel.dao.orm.Type.LONG);
6026
6027 QueryPos qPos = QueryPos.getInstance(q);
6028
6029 qPos.add(pk);
6030
6031 count = (Long)q.uniqueResult();
6032 }
6033 catch (Exception e) {
6034 throw processException(e);
6035 }
6036 finally {
6037 if (count == null) {
6038 count = Long.valueOf(0);
6039 }
6040
6041 FinderCacheUtil.putResult(FINDER_PATH_GET_ASSETENTRIES_SIZE,
6042 finderArgs, count);
6043
6044 closeSession(session);
6045 }
6046 }
6047
6048 return count.intValue();
6049 }
6050
6051 public static final FinderPath FINDER_PATH_CONTAINS_ASSETENTRY = new FinderPath(com.liferay.portlet.asset.model.impl.AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
6052 AssetCategoryModelImpl.FINDER_CACHE_ENABLED_ASSETENTRIES_ASSETCATEGORIES,
6053 Boolean.class,
6054 AssetCategoryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME,
6055 "containsAssetEntry",
6056 new String[] { Long.class.getName(), Long.class.getName() });
6057
6058
6066 public boolean containsAssetEntry(long pk, long assetEntryPK)
6067 throws SystemException {
6068 Object[] finderArgs = new Object[] { pk, assetEntryPK };
6069
6070 Boolean value = (Boolean)FinderCacheUtil.getResult(FINDER_PATH_CONTAINS_ASSETENTRY,
6071 finderArgs, this);
6072
6073 if (value == null) {
6074 try {
6075 value = Boolean.valueOf(containsAssetEntry.contains(pk,
6076 assetEntryPK));
6077 }
6078 catch (Exception e) {
6079 throw processException(e);
6080 }
6081 finally {
6082 if (value == null) {
6083 value = Boolean.FALSE;
6084 }
6085
6086 FinderCacheUtil.putResult(FINDER_PATH_CONTAINS_ASSETENTRY,
6087 finderArgs, value);
6088 }
6089 }
6090
6091 return value.booleanValue();
6092 }
6093
6094
6101 public boolean containsAssetEntries(long pk) throws SystemException {
6102 if (getAssetEntriesSize(pk) > 0) {
6103 return true;
6104 }
6105 else {
6106 return false;
6107 }
6108 }
6109
6110
6117 public void addAssetEntry(long pk, long assetEntryPK)
6118 throws SystemException {
6119 try {
6120 addAssetEntry.add(pk, assetEntryPK);
6121 }
6122 catch (Exception e) {
6123 throw processException(e);
6124 }
6125 finally {
6126 FinderCacheUtil.clearCache(AssetCategoryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
6127 }
6128 }
6129
6130
6137 public void addAssetEntry(long pk,
6138 com.liferay.portlet.asset.model.AssetEntry assetEntry)
6139 throws SystemException {
6140 try {
6141 addAssetEntry.add(pk, assetEntry.getPrimaryKey());
6142 }
6143 catch (Exception e) {
6144 throw processException(e);
6145 }
6146 finally {
6147 FinderCacheUtil.clearCache(AssetCategoryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
6148 }
6149 }
6150
6151
6158 public void addAssetEntries(long pk, long[] assetEntryPKs)
6159 throws SystemException {
6160 try {
6161 for (long assetEntryPK : assetEntryPKs) {
6162 addAssetEntry.add(pk, assetEntryPK);
6163 }
6164 }
6165 catch (Exception e) {
6166 throw processException(e);
6167 }
6168 finally {
6169 FinderCacheUtil.clearCache(AssetCategoryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
6170 }
6171 }
6172
6173
6180 public void addAssetEntries(long pk,
6181 List<com.liferay.portlet.asset.model.AssetEntry> assetEntries)
6182 throws SystemException {
6183 try {
6184 for (com.liferay.portlet.asset.model.AssetEntry assetEntry : assetEntries) {
6185 addAssetEntry.add(pk, assetEntry.getPrimaryKey());
6186 }
6187 }
6188 catch (Exception e) {
6189 throw processException(e);
6190 }
6191 finally {
6192 FinderCacheUtil.clearCache(AssetCategoryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
6193 }
6194 }
6195
6196
6202 public void clearAssetEntries(long pk) throws SystemException {
6203 try {
6204 clearAssetEntries.clear(pk);
6205 }
6206 catch (Exception e) {
6207 throw processException(e);
6208 }
6209 finally {
6210 FinderCacheUtil.clearCache(AssetCategoryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
6211 }
6212 }
6213
6214
6221 public void removeAssetEntry(long pk, long assetEntryPK)
6222 throws SystemException {
6223 try {
6224 removeAssetEntry.remove(pk, assetEntryPK);
6225 }
6226 catch (Exception e) {
6227 throw processException(e);
6228 }
6229 finally {
6230 FinderCacheUtil.clearCache(AssetCategoryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
6231 }
6232 }
6233
6234
6241 public void removeAssetEntry(long pk,
6242 com.liferay.portlet.asset.model.AssetEntry assetEntry)
6243 throws SystemException {
6244 try {
6245 removeAssetEntry.remove(pk, assetEntry.getPrimaryKey());
6246 }
6247 catch (Exception e) {
6248 throw processException(e);
6249 }
6250 finally {
6251 FinderCacheUtil.clearCache(AssetCategoryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
6252 }
6253 }
6254
6255
6262 public void removeAssetEntries(long pk, long[] assetEntryPKs)
6263 throws SystemException {
6264 try {
6265 for (long assetEntryPK : assetEntryPKs) {
6266 removeAssetEntry.remove(pk, assetEntryPK);
6267 }
6268 }
6269 catch (Exception e) {
6270 throw processException(e);
6271 }
6272 finally {
6273 FinderCacheUtil.clearCache(AssetCategoryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
6274 }
6275 }
6276
6277
6284 public void removeAssetEntries(long pk,
6285 List<com.liferay.portlet.asset.model.AssetEntry> assetEntries)
6286 throws SystemException {
6287 try {
6288 for (com.liferay.portlet.asset.model.AssetEntry assetEntry : assetEntries) {
6289 removeAssetEntry.remove(pk, assetEntry.getPrimaryKey());
6290 }
6291 }
6292 catch (Exception e) {
6293 throw processException(e);
6294 }
6295 finally {
6296 FinderCacheUtil.clearCache(AssetCategoryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
6297 }
6298 }
6299
6300
6307 public void setAssetEntries(long pk, long[] assetEntryPKs)
6308 throws SystemException {
6309 try {
6310 Set<Long> assetEntryPKSet = SetUtil.fromArray(assetEntryPKs);
6311
6312 List<com.liferay.portlet.asset.model.AssetEntry> assetEntries = getAssetEntries(pk);
6313
6314 for (com.liferay.portlet.asset.model.AssetEntry assetEntry : assetEntries) {
6315 if (!assetEntryPKSet.remove(assetEntry.getPrimaryKey())) {
6316 removeAssetEntry.remove(pk, assetEntry.getPrimaryKey());
6317 }
6318 }
6319
6320 for (Long assetEntryPK : assetEntryPKSet) {
6321 addAssetEntry.add(pk, assetEntryPK);
6322 }
6323 }
6324 catch (Exception e) {
6325 throw processException(e);
6326 }
6327 finally {
6328 FinderCacheUtil.clearCache(AssetCategoryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
6329 }
6330 }
6331
6332
6339 public void setAssetEntries(long pk,
6340 List<com.liferay.portlet.asset.model.AssetEntry> assetEntries)
6341 throws SystemException {
6342 try {
6343 long[] assetEntryPKs = new long[assetEntries.size()];
6344
6345 for (int i = 0; i < assetEntries.size(); i++) {
6346 com.liferay.portlet.asset.model.AssetEntry assetEntry = assetEntries.get(i);
6347
6348 assetEntryPKs[i] = assetEntry.getPrimaryKey();
6349 }
6350
6351 setAssetEntries(pk, assetEntryPKs);
6352 }
6353 catch (Exception e) {
6354 throw processException(e);
6355 }
6356 finally {
6357 FinderCacheUtil.clearCache(AssetCategoryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
6358 }
6359 }
6360
6361
6371 public void rebuildTree(long groupId, boolean force)
6372 throws SystemException {
6373 if (!rebuildTreeEnabled) {
6374 return;
6375 }
6376
6377 if (force || (countOrphanTreeNodes(groupId) > 0)) {
6378 rebuildTree(groupId, 0, 1);
6379
6380 CacheRegistryUtil.clear(AssetCategoryImpl.class.getName());
6381 EntityCacheUtil.clearCache(AssetCategoryImpl.class.getName());
6382 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
6383 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
6384 }
6385 }
6386
6387 public void setRebuildTreeEnabled(boolean rebuildTreeEnabled) {
6388 this.rebuildTreeEnabled = rebuildTreeEnabled;
6389 }
6390
6391 protected long countOrphanTreeNodes(long groupId) throws SystemException {
6392 Session session = null;
6393
6394 try {
6395 session = openSession();
6396
6397 SQLQuery q = session.createSQLQuery(
6398 "SELECT COUNT(*) AS COUNT_VALUE FROM AssetCategory WHERE groupId = ? AND (leftCategoryId = 0 OR leftCategoryId IS NULL OR rightCategoryId = 0 OR rightCategoryId IS NULL)");
6399
6400 q.addScalar(COUNT_COLUMN_NAME,
6401 com.liferay.portal.kernel.dao.orm.Type.LONG);
6402
6403 QueryPos qPos = QueryPos.getInstance(q);
6404
6405 qPos.add(groupId);
6406
6407 return (Long)q.uniqueResult();
6408 }
6409 catch (Exception e) {
6410 throw processException(e);
6411 }
6412 finally {
6413 closeSession(session);
6414 }
6415 }
6416
6417 protected void expandTree(AssetCategory assetCategory)
6418 throws SystemException {
6419 if (!rebuildTreeEnabled) {
6420 return;
6421 }
6422
6423 long groupId = assetCategory.getGroupId();
6424
6425 long lastRightCategoryId = getLastRightCategoryId(groupId,
6426 assetCategory.getParentCategoryId());
6427
6428 long leftCategoryId = 2;
6429 long rightCategoryId = 3;
6430
6431 if (lastRightCategoryId > 0) {
6432 leftCategoryId = lastRightCategoryId + 1;
6433 rightCategoryId = lastRightCategoryId + 2;
6434
6435 expandTreeLeftCategoryId.expand(groupId, lastRightCategoryId);
6436 expandTreeRightCategoryId.expand(groupId, lastRightCategoryId);
6437
6438 CacheRegistryUtil.clear(AssetCategoryImpl.class.getName());
6439 EntityCacheUtil.clearCache(AssetCategoryImpl.class.getName());
6440 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
6441 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
6442 }
6443
6444 assetCategory.setLeftCategoryId(leftCategoryId);
6445 assetCategory.setRightCategoryId(rightCategoryId);
6446 }
6447
6448 protected long getLastRightCategoryId(long groupId, long parentCategoryId)
6449 throws SystemException {
6450 Session session = null;
6451
6452 try {
6453 session = openSession();
6454
6455 SQLQuery q = session.createSQLQuery(
6456 "SELECT rightCategoryId FROM AssetCategory WHERE (groupId = ?) AND (parentCategoryId = ?) ORDER BY rightCategoryId DESC");
6457
6458 q.addScalar("rightCategoryId",
6459 com.liferay.portal.kernel.dao.orm.Type.LONG);
6460
6461 QueryPos qPos = QueryPos.getInstance(q);
6462
6463 qPos.add(groupId);
6464 qPos.add(parentCategoryId);
6465
6466 List<Long> list = (List<Long>)QueryUtil.list(q, getDialect(), 0, 1);
6467
6468 if (list.isEmpty()) {
6469 if (parentCategoryId > 0) {
6470 session.clear();
6471
6472 AssetCategory parentAssetCategory = findByPrimaryKey(parentCategoryId);
6473
6474 return parentAssetCategory.getLeftCategoryId();
6475 }
6476
6477 return 0;
6478 }
6479 else {
6480 return list.get(0);
6481 }
6482 }
6483 catch (Exception e) {
6484 throw processException(e);
6485 }
6486 finally {
6487 closeSession(session);
6488 }
6489 }
6490
6491 protected long rebuildTree(long groupId, long parentCategoryId,
6492 long leftCategoryId) throws SystemException {
6493 if (!rebuildTreeEnabled) {
6494 return 0;
6495 }
6496
6497 List<Long> categoryIds = null;
6498
6499 Session session = null;
6500
6501 try {
6502 session = openSession();
6503
6504 SQLQuery q = session.createSQLQuery(
6505 "SELECT categoryId FROM AssetCategory WHERE groupId = ? AND parentCategoryId = ? ORDER BY categoryId ASC");
6506
6507 q.addScalar("categoryId",
6508 com.liferay.portal.kernel.dao.orm.Type.LONG);
6509
6510 QueryPos qPos = QueryPos.getInstance(q);
6511
6512 qPos.add(groupId);
6513 qPos.add(parentCategoryId);
6514
6515 categoryIds = q.list();
6516 }
6517 catch (Exception e) {
6518 throw processException(e);
6519 }
6520 finally {
6521 closeSession(session);
6522 }
6523
6524 long rightCategoryId = leftCategoryId + 1;
6525
6526 for (long categoryId : categoryIds) {
6527 rightCategoryId = rebuildTree(groupId, categoryId, rightCategoryId);
6528 }
6529
6530 if (parentCategoryId > 0) {
6531 updateTree.update(parentCategoryId, leftCategoryId, rightCategoryId);
6532 }
6533
6534 return rightCategoryId + 1;
6535 }
6536
6537 protected void shrinkTree(AssetCategory assetCategory) {
6538 if (!rebuildTreeEnabled) {
6539 return;
6540 }
6541
6542 long groupId = assetCategory.getGroupId();
6543
6544 long leftCategoryId = assetCategory.getLeftCategoryId();
6545 long rightCategoryId = assetCategory.getRightCategoryId();
6546
6547 long delta = (rightCategoryId - leftCategoryId) + 1;
6548
6549 shrinkTreeLeftCategoryId.shrink(groupId, rightCategoryId, delta);
6550 shrinkTreeRightCategoryId.shrink(groupId, rightCategoryId, delta);
6551
6552 CacheRegistryUtil.clear(AssetCategoryImpl.class.getName());
6553 EntityCacheUtil.clearCache(AssetCategoryImpl.class.getName());
6554 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
6555 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
6556 }
6557
6558
6561 public void afterPropertiesSet() {
6562 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
6563 com.liferay.portal.util.PropsUtil.get(
6564 "value.object.listener.com.liferay.portlet.asset.model.AssetCategory")));
6565
6566 if (listenerClassNames.length > 0) {
6567 try {
6568 List<ModelListener<AssetCategory>> listenersList = new ArrayList<ModelListener<AssetCategory>>();
6569
6570 for (String listenerClassName : listenerClassNames) {
6571 listenersList.add((ModelListener<AssetCategory>)InstanceFactory.newInstance(
6572 listenerClassName));
6573 }
6574
6575 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
6576 }
6577 catch (Exception e) {
6578 _log.error(e);
6579 }
6580 }
6581
6582 containsAssetEntry = new ContainsAssetEntry(this);
6583
6584 addAssetEntry = new AddAssetEntry(this);
6585 clearAssetEntries = new ClearAssetEntries(this);
6586 removeAssetEntry = new RemoveAssetEntry(this);
6587
6588 expandTreeLeftCategoryId = new ExpandTreeLeftCategoryId();
6589 expandTreeRightCategoryId = new ExpandTreeRightCategoryId();
6590 shrinkTreeLeftCategoryId = new ShrinkTreeLeftCategoryId();
6591 shrinkTreeRightCategoryId = new ShrinkTreeRightCategoryId();
6592 updateTree = new UpdateTree();
6593 }
6594
6595 public void destroy() {
6596 EntityCacheUtil.removeCache(AssetCategoryImpl.class.getName());
6597 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
6598 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
6599 }
6600
6601 @BeanReference(type = AssetCategoryPersistence.class)
6602 protected AssetCategoryPersistence assetCategoryPersistence;
6603 @BeanReference(type = AssetCategoryPropertyPersistence.class)
6604 protected AssetCategoryPropertyPersistence assetCategoryPropertyPersistence;
6605 @BeanReference(type = AssetEntryPersistence.class)
6606 protected AssetEntryPersistence assetEntryPersistence;
6607 @BeanReference(type = AssetLinkPersistence.class)
6608 protected AssetLinkPersistence assetLinkPersistence;
6609 @BeanReference(type = AssetTagPersistence.class)
6610 protected AssetTagPersistence assetTagPersistence;
6611 @BeanReference(type = AssetTagPropertyPersistence.class)
6612 protected AssetTagPropertyPersistence assetTagPropertyPersistence;
6613 @BeanReference(type = AssetTagStatsPersistence.class)
6614 protected AssetTagStatsPersistence assetTagStatsPersistence;
6615 @BeanReference(type = AssetVocabularyPersistence.class)
6616 protected AssetVocabularyPersistence assetVocabularyPersistence;
6617 @BeanReference(type = ResourcePersistence.class)
6618 protected ResourcePersistence resourcePersistence;
6619 @BeanReference(type = UserPersistence.class)
6620 protected UserPersistence userPersistence;
6621 protected ContainsAssetEntry containsAssetEntry;
6622 protected AddAssetEntry addAssetEntry;
6623 protected ClearAssetEntries clearAssetEntries;
6624 protected RemoveAssetEntry removeAssetEntry;
6625
6626 protected class ContainsAssetEntry {
6627 protected ContainsAssetEntry(
6628 AssetCategoryPersistenceImpl persistenceImpl) {
6629 super();
6630
6631 _mappingSqlQuery = MappingSqlQueryFactoryUtil.getMappingSqlQuery(getDataSource(),
6632 _SQL_CONTAINSASSETENTRY,
6633 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT },
6634 RowMapper.COUNT);
6635 }
6636
6637 protected boolean contains(long categoryId, long entryId) {
6638 List<Integer> results = _mappingSqlQuery.execute(new Object[] {
6639 new Long(categoryId), new Long(entryId)
6640 });
6641
6642 if (results.size() > 0) {
6643 Integer count = results.get(0);
6644
6645 if (count.intValue() > 0) {
6646 return true;
6647 }
6648 }
6649
6650 return false;
6651 }
6652
6653 private MappingSqlQuery<Integer> _mappingSqlQuery;
6654 }
6655
6656 protected class AddAssetEntry {
6657 protected AddAssetEntry(AssetCategoryPersistenceImpl persistenceImpl) {
6658 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
6659 "INSERT INTO AssetEntries_AssetCategories (categoryId, entryId) VALUES (?, ?)",
6660 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
6661 _persistenceImpl = persistenceImpl;
6662 }
6663
6664 protected void add(long categoryId, long entryId)
6665 throws SystemException {
6666 if (!_persistenceImpl.containsAssetEntry.contains(categoryId,
6667 entryId)) {
6668 ModelListener<com.liferay.portlet.asset.model.AssetEntry>[] assetEntryListeners =
6669 assetEntryPersistence.getListeners();
6670
6671 for (ModelListener<AssetCategory> listener : listeners) {
6672 listener.onBeforeAddAssociation(categoryId,
6673 com.liferay.portlet.asset.model.AssetEntry.class.getName(),
6674 entryId);
6675 }
6676
6677 for (ModelListener<com.liferay.portlet.asset.model.AssetEntry> listener : assetEntryListeners) {
6678 listener.onBeforeAddAssociation(entryId,
6679 AssetCategory.class.getName(), categoryId);
6680 }
6681
6682 _sqlUpdate.update(new Object[] {
6683 new Long(categoryId), new Long(entryId)
6684 });
6685
6686 for (ModelListener<AssetCategory> listener : listeners) {
6687 listener.onAfterAddAssociation(categoryId,
6688 com.liferay.portlet.asset.model.AssetEntry.class.getName(),
6689 entryId);
6690 }
6691
6692 for (ModelListener<com.liferay.portlet.asset.model.AssetEntry> listener : assetEntryListeners) {
6693 listener.onAfterAddAssociation(entryId,
6694 AssetCategory.class.getName(), categoryId);
6695 }
6696 }
6697 }
6698
6699 private SqlUpdate _sqlUpdate;
6700 private AssetCategoryPersistenceImpl _persistenceImpl;
6701 }
6702
6703 protected class ClearAssetEntries {
6704 protected ClearAssetEntries(
6705 AssetCategoryPersistenceImpl persistenceImpl) {
6706 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
6707 "DELETE FROM AssetEntries_AssetCategories WHERE categoryId = ?",
6708 new int[] { java.sql.Types.BIGINT });
6709 }
6710
6711 protected void clear(long categoryId) throws SystemException {
6712 ModelListener<com.liferay.portlet.asset.model.AssetEntry>[] assetEntryListeners =
6713 assetEntryPersistence.getListeners();
6714
6715 List<com.liferay.portlet.asset.model.AssetEntry> assetEntries = null;
6716
6717 if ((listeners.length > 0) || (assetEntryListeners.length > 0)) {
6718 assetEntries = getAssetEntries(categoryId);
6719
6720 for (com.liferay.portlet.asset.model.AssetEntry assetEntry : assetEntries) {
6721 for (ModelListener<AssetCategory> listener : listeners) {
6722 listener.onBeforeRemoveAssociation(categoryId,
6723 com.liferay.portlet.asset.model.AssetEntry.class.getName(),
6724 assetEntry.getPrimaryKey());
6725 }
6726
6727 for (ModelListener<com.liferay.portlet.asset.model.AssetEntry> listener : assetEntryListeners) {
6728 listener.onBeforeRemoveAssociation(assetEntry.getPrimaryKey(),
6729 AssetCategory.class.getName(), categoryId);
6730 }
6731 }
6732 }
6733
6734 _sqlUpdate.update(new Object[] { new Long(categoryId) });
6735
6736 if ((listeners.length > 0) || (assetEntryListeners.length > 0)) {
6737 for (com.liferay.portlet.asset.model.AssetEntry assetEntry : assetEntries) {
6738 for (ModelListener<AssetCategory> listener : listeners) {
6739 listener.onAfterRemoveAssociation(categoryId,
6740 com.liferay.portlet.asset.model.AssetEntry.class.getName(),
6741 assetEntry.getPrimaryKey());
6742 }
6743
6744 for (ModelListener<com.liferay.portlet.asset.model.AssetEntry> listener : assetEntryListeners) {
6745 listener.onAfterRemoveAssociation(assetEntry.getPrimaryKey(),
6746 AssetCategory.class.getName(), categoryId);
6747 }
6748 }
6749 }
6750 }
6751
6752 private SqlUpdate _sqlUpdate;
6753 }
6754
6755 protected class RemoveAssetEntry {
6756 protected RemoveAssetEntry(AssetCategoryPersistenceImpl persistenceImpl) {
6757 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
6758 "DELETE FROM AssetEntries_AssetCategories WHERE categoryId = ? AND entryId = ?",
6759 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
6760 _persistenceImpl = persistenceImpl;
6761 }
6762
6763 protected void remove(long categoryId, long entryId)
6764 throws SystemException {
6765 if (_persistenceImpl.containsAssetEntry.contains(categoryId, entryId)) {
6766 ModelListener<com.liferay.portlet.asset.model.AssetEntry>[] assetEntryListeners =
6767 assetEntryPersistence.getListeners();
6768
6769 for (ModelListener<AssetCategory> listener : listeners) {
6770 listener.onBeforeRemoveAssociation(categoryId,
6771 com.liferay.portlet.asset.model.AssetEntry.class.getName(),
6772 entryId);
6773 }
6774
6775 for (ModelListener<com.liferay.portlet.asset.model.AssetEntry> listener : assetEntryListeners) {
6776 listener.onBeforeRemoveAssociation(entryId,
6777 AssetCategory.class.getName(), categoryId);
6778 }
6779
6780 _sqlUpdate.update(new Object[] {
6781 new Long(categoryId), new Long(entryId)
6782 });
6783
6784 for (ModelListener<AssetCategory> listener : listeners) {
6785 listener.onAfterRemoveAssociation(categoryId,
6786 com.liferay.portlet.asset.model.AssetEntry.class.getName(),
6787 entryId);
6788 }
6789
6790 for (ModelListener<com.liferay.portlet.asset.model.AssetEntry> listener : assetEntryListeners) {
6791 listener.onAfterRemoveAssociation(entryId,
6792 AssetCategory.class.getName(), categoryId);
6793 }
6794 }
6795 }
6796
6797 private SqlUpdate _sqlUpdate;
6798 private AssetCategoryPersistenceImpl _persistenceImpl;
6799 }
6800
6801 protected boolean rebuildTreeEnabled = true;
6802 protected ExpandTreeLeftCategoryId expandTreeLeftCategoryId;
6803 protected ExpandTreeRightCategoryId expandTreeRightCategoryId;
6804 protected ShrinkTreeLeftCategoryId shrinkTreeLeftCategoryId;
6805 protected ShrinkTreeRightCategoryId shrinkTreeRightCategoryId;
6806 protected UpdateTree updateTree;
6807
6808 protected class ExpandTreeLeftCategoryId {
6809 protected ExpandTreeLeftCategoryId() {
6810 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
6811 "UPDATE AssetCategory SET leftCategoryId = (leftCategoryId + 2) WHERE (groupId = ?) AND (leftCategoryId > ?)",
6812 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
6813 }
6814
6815 protected void expand(long groupId, long leftCategoryId) {
6816 _sqlUpdate.update(new Object[] { groupId, leftCategoryId });
6817 }
6818
6819 private SqlUpdate _sqlUpdate;
6820 }
6821
6822 protected class ExpandTreeRightCategoryId {
6823 protected ExpandTreeRightCategoryId() {
6824 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
6825 "UPDATE AssetCategory SET rightCategoryId = (rightCategoryId + 2) WHERE (groupId = ?) AND (rightCategoryId > ?)",
6826 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
6827 }
6828
6829 protected void expand(long groupId, long rightCategoryId) {
6830 _sqlUpdate.update(new Object[] { groupId, rightCategoryId });
6831 }
6832
6833 private SqlUpdate _sqlUpdate;
6834 }
6835
6836 protected class ShrinkTreeLeftCategoryId {
6837 protected ShrinkTreeLeftCategoryId() {
6838 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
6839 "UPDATE AssetCategory SET leftCategoryId = (leftCategoryId - ?) WHERE (groupId = ?) AND (leftCategoryId > ?)",
6840 new int[] {
6841 java.sql.Types.BIGINT, java.sql.Types.BIGINT,
6842 java.sql.Types.BIGINT
6843 });
6844 }
6845
6846 protected void shrink(long groupId, long leftCategoryId, long delta) {
6847 _sqlUpdate.update(new Object[] { delta, groupId, leftCategoryId });
6848 }
6849
6850 private SqlUpdate _sqlUpdate;
6851 }
6852
6853 protected class ShrinkTreeRightCategoryId {
6854 protected ShrinkTreeRightCategoryId() {
6855 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
6856 "UPDATE AssetCategory SET rightCategoryId = (rightCategoryId - ?) WHERE (groupId = ?) AND (rightCategoryId > ?)",
6857 new int[] {
6858 java.sql.Types.BIGINT, java.sql.Types.BIGINT,
6859 java.sql.Types.BIGINT
6860 });
6861 }
6862
6863 protected void shrink(long groupId, long rightCategoryId, long delta) {
6864 _sqlUpdate.update(new Object[] { delta, groupId, rightCategoryId });
6865 }
6866
6867 private SqlUpdate _sqlUpdate;
6868 }
6869
6870 protected class UpdateTree {
6871 protected UpdateTree() {
6872 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
6873 "UPDATE AssetCategory SET leftCategoryId = ?, rightCategoryId = ? WHERE categoryId = ?",
6874 new int[] {
6875 java.sql.Types.BIGINT, java.sql.Types.BIGINT,
6876 java.sql.Types.BIGINT
6877 });
6878 }
6879
6880 protected void update(long categoryId, long leftCategoryId,
6881 long rightCategoryId) {
6882 _sqlUpdate.update(new Object[] {
6883 leftCategoryId, rightCategoryId, categoryId
6884 });
6885 }
6886
6887 private SqlUpdate _sqlUpdate;
6888 }
6889
6890 private static final String _SQL_SELECT_ASSETCATEGORY = "SELECT assetCategory FROM AssetCategory assetCategory";
6891 private static final String _SQL_SELECT_ASSETCATEGORY_WHERE = "SELECT assetCategory FROM AssetCategory assetCategory WHERE ";
6892 private static final String _SQL_COUNT_ASSETCATEGORY = "SELECT COUNT(assetCategory) FROM AssetCategory assetCategory";
6893 private static final String _SQL_COUNT_ASSETCATEGORY_WHERE = "SELECT COUNT(assetCategory) FROM AssetCategory assetCategory WHERE ";
6894 private static final String _SQL_GETASSETENTRIES = "SELECT {AssetEntry.*} FROM AssetEntry INNER JOIN AssetEntries_AssetCategories ON (AssetEntries_AssetCategories.entryId = AssetEntry.entryId) WHERE (AssetEntries_AssetCategories.categoryId = ?)";
6895 private static final String _SQL_GETASSETENTRIESSIZE = "SELECT COUNT(*) AS COUNT_VALUE FROM AssetEntries_AssetCategories WHERE categoryId = ?";
6896 private static final String _SQL_CONTAINSASSETENTRY = "SELECT COUNT(*) AS COUNT_VALUE FROM AssetEntries_AssetCategories WHERE categoryId = ? AND entryId = ?";
6897 private static final String _FINDER_COLUMN_UUID_UUID_1 = "assetCategory.uuid IS NULL";
6898 private static final String _FINDER_COLUMN_UUID_UUID_2 = "assetCategory.uuid = ?";
6899 private static final String _FINDER_COLUMN_UUID_UUID_3 = "(assetCategory.uuid IS NULL OR assetCategory.uuid = ?)";
6900 private static final String _FINDER_COLUMN_UUID_G_UUID_1 = "assetCategory.uuid IS NULL AND ";
6901 private static final String _FINDER_COLUMN_UUID_G_UUID_2 = "assetCategory.uuid = ? AND ";
6902 private static final String _FINDER_COLUMN_UUID_G_UUID_3 = "(assetCategory.uuid IS NULL OR assetCategory.uuid = ?) AND ";
6903 private static final String _FINDER_COLUMN_UUID_G_GROUPID_2 = "assetCategory.groupId = ?";
6904 private static final String _FINDER_COLUMN_GROUPID_GROUPID_2 = "assetCategory.groupId = ?";
6905 private static final String _FINDER_COLUMN_PARENTCATEGORYID_PARENTCATEGORYID_2 =
6906 "assetCategory.parentCategoryId = ?";
6907 private static final String _FINDER_COLUMN_VOCABULARYID_VOCABULARYID_2 = "assetCategory.vocabularyId = ?";
6908 private static final String _FINDER_COLUMN_G_V_GROUPID_2 = "assetCategory.groupId = ? AND ";
6909 private static final String _FINDER_COLUMN_G_V_VOCABULARYID_2 = "assetCategory.vocabularyId = ?";
6910 private static final String _FINDER_COLUMN_P_N_PARENTCATEGORYID_2 = "assetCategory.parentCategoryId = ? AND ";
6911 private static final String _FINDER_COLUMN_P_N_NAME_1 = "assetCategory.name IS NULL";
6912 private static final String _FINDER_COLUMN_P_N_NAME_2 = "assetCategory.name = ?";
6913 private static final String _FINDER_COLUMN_P_N_NAME_3 = "(assetCategory.name IS NULL OR assetCategory.name = ?)";
6914 private static final String _FINDER_COLUMN_P_V_PARENTCATEGORYID_2 = "assetCategory.parentCategoryId = ? AND ";
6915 private static final String _FINDER_COLUMN_P_V_VOCABULARYID_2 = "assetCategory.vocabularyId = ?";
6916 private static final String _FINDER_COLUMN_N_V_NAME_1 = "assetCategory.name IS NULL AND ";
6917 private static final String _FINDER_COLUMN_N_V_NAME_2 = "assetCategory.name = ? AND ";
6918 private static final String _FINDER_COLUMN_N_V_NAME_3 = "(assetCategory.name IS NULL OR assetCategory.name = ?) AND ";
6919 private static final String _FINDER_COLUMN_N_V_VOCABULARYID_2 = "assetCategory.vocabularyId = ?";
6920 private static final String _FINDER_COLUMN_P_N_V_PARENTCATEGORYID_2 = "assetCategory.parentCategoryId = ? AND ";
6921 private static final String _FINDER_COLUMN_P_N_V_NAME_1 = "assetCategory.name IS NULL AND ";
6922 private static final String _FINDER_COLUMN_P_N_V_NAME_2 = "assetCategory.name = ? AND ";
6923 private static final String _FINDER_COLUMN_P_N_V_NAME_3 = "(assetCategory.name IS NULL OR assetCategory.name = ?) AND ";
6924 private static final String _FINDER_COLUMN_P_N_V_VOCABULARYID_2 = "assetCategory.vocabularyId = ?";
6925 private static final String _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN = "assetCategory.categoryId";
6926 private static final String _FILTER_SQL_SELECT_ASSETCATEGORY_WHERE = "SELECT DISTINCT {assetCategory.*} FROM AssetCategory assetCategory WHERE ";
6927 private static final String _FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_1 =
6928 "SELECT {AssetCategory.*} FROM (SELECT DISTINCT assetCategory.categoryId FROM AssetCategory assetCategory WHERE ";
6929 private static final String _FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_2 =
6930 ") TEMP_TABLE INNER JOIN AssetCategory ON TEMP_TABLE.categoryId = AssetCategory.categoryId";
6931 private static final String _FILTER_SQL_COUNT_ASSETCATEGORY_WHERE = "SELECT COUNT(DISTINCT assetCategory.categoryId) AS COUNT_VALUE FROM AssetCategory assetCategory WHERE ";
6932 private static final String _FILTER_ENTITY_ALIAS = "assetCategory";
6933 private static final String _FILTER_ENTITY_TABLE = "AssetCategory";
6934 private static final String _ORDER_BY_ENTITY_ALIAS = "assetCategory.";
6935 private static final String _ORDER_BY_ENTITY_TABLE = "AssetCategory.";
6936 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No AssetCategory exists with the primary key ";
6937 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No AssetCategory exists with the key {";
6938 private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
6939 private static Log _log = LogFactoryUtil.getLog(AssetCategoryPersistenceImpl.class);
6940 private static AssetCategory _nullAssetCategory = new AssetCategoryImpl() {
6941 @Override
6942 public Object clone() {
6943 return this;
6944 }
6945
6946 @Override
6947 public CacheModel<AssetCategory> toCacheModel() {
6948 return _nullAssetCategoryCacheModel;
6949 }
6950 };
6951
6952 private static CacheModel<AssetCategory> _nullAssetCategoryCacheModel = new CacheModel<AssetCategory>() {
6953 public AssetCategory toEntityModel() {
6954 return _nullAssetCategory;
6955 }
6956 };
6957 }