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_WITH_PAGINATION_FIND_BY_G_P_N = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
265 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
266 AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
267 "findByG_P_N",
268 new String[] {
269 Long.class.getName(), Long.class.getName(),
270 String.class.getName(),
271
272 "java.lang.Integer", "java.lang.Integer",
273 "com.liferay.portal.kernel.util.OrderByComparator"
274 });
275 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_N = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
276 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
277 AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
278 "findByG_P_N",
279 new String[] {
280 Long.class.getName(), Long.class.getName(),
281 String.class.getName()
282 },
283 AssetCategoryModelImpl.GROUPID_COLUMN_BITMASK |
284 AssetCategoryModelImpl.PARENTCATEGORYID_COLUMN_BITMASK |
285 AssetCategoryModelImpl.NAME_COLUMN_BITMASK);
286 public static final FinderPath FINDER_PATH_COUNT_BY_G_P_N = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
287 AssetCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class,
288 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_P_N",
289 new String[] {
290 Long.class.getName(), Long.class.getName(),
291 String.class.getName()
292 });
293 public static final FinderPath FINDER_PATH_FETCH_BY_P_N_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
294 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
295 AssetCategoryImpl.class, FINDER_CLASS_NAME_ENTITY, "fetchByP_N_V",
296 new String[] {
297 Long.class.getName(), String.class.getName(),
298 Long.class.getName()
299 },
300 AssetCategoryModelImpl.PARENTCATEGORYID_COLUMN_BITMASK |
301 AssetCategoryModelImpl.NAME_COLUMN_BITMASK |
302 AssetCategoryModelImpl.VOCABULARYID_COLUMN_BITMASK);
303 public static final FinderPath FINDER_PATH_COUNT_BY_P_N_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
304 AssetCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class,
305 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByP_N_V",
306 new String[] {
307 Long.class.getName(), String.class.getName(),
308 Long.class.getName()
309 });
310 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
311 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
312 AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
313 "findAll", new String[0]);
314 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
315 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
316 AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
317 "findAll", new String[0]);
318 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
319 AssetCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class,
320 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
321
322
327 public void cacheResult(AssetCategory assetCategory) {
328 EntityCacheUtil.putResult(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
329 AssetCategoryImpl.class, assetCategory.getPrimaryKey(),
330 assetCategory);
331
332 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
333 new Object[] {
334 assetCategory.getUuid(),
335 Long.valueOf(assetCategory.getGroupId())
336 }, assetCategory);
337
338 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_P_N_V,
339 new Object[] {
340 Long.valueOf(assetCategory.getParentCategoryId()),
341
342 assetCategory.getName(),
343 Long.valueOf(assetCategory.getVocabularyId())
344 }, assetCategory);
345
346 assetCategory.resetOriginalValues();
347 }
348
349
354 public void cacheResult(List<AssetCategory> assetCategories) {
355 for (AssetCategory assetCategory : assetCategories) {
356 if (EntityCacheUtil.getResult(
357 AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
358 AssetCategoryImpl.class, assetCategory.getPrimaryKey()) == null) {
359 cacheResult(assetCategory);
360 }
361 else {
362 assetCategory.resetOriginalValues();
363 }
364 }
365 }
366
367
374 @Override
375 public void clearCache() {
376 if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
377 CacheRegistryUtil.clear(AssetCategoryImpl.class.getName());
378 }
379
380 EntityCacheUtil.clearCache(AssetCategoryImpl.class.getName());
381
382 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
383 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
384 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
385 }
386
387
394 @Override
395 public void clearCache(AssetCategory assetCategory) {
396 EntityCacheUtil.removeResult(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
397 AssetCategoryImpl.class, assetCategory.getPrimaryKey());
398
399 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
400 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
401
402 clearUniqueFindersCache(assetCategory);
403 }
404
405 @Override
406 public void clearCache(List<AssetCategory> assetCategories) {
407 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
408 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
409
410 for (AssetCategory assetCategory : assetCategories) {
411 EntityCacheUtil.removeResult(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
412 AssetCategoryImpl.class, assetCategory.getPrimaryKey());
413
414 clearUniqueFindersCache(assetCategory);
415 }
416 }
417
418 protected void clearUniqueFindersCache(AssetCategory assetCategory) {
419 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
420 new Object[] {
421 assetCategory.getUuid(),
422 Long.valueOf(assetCategory.getGroupId())
423 });
424
425 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_P_N_V,
426 new Object[] {
427 Long.valueOf(assetCategory.getParentCategoryId()),
428
429 assetCategory.getName(),
430 Long.valueOf(assetCategory.getVocabularyId())
431 });
432 }
433
434
440 public AssetCategory create(long categoryId) {
441 AssetCategory assetCategory = new AssetCategoryImpl();
442
443 assetCategory.setNew(true);
444 assetCategory.setPrimaryKey(categoryId);
445
446 String uuid = PortalUUIDUtil.generate();
447
448 assetCategory.setUuid(uuid);
449
450 return assetCategory;
451 }
452
453
461 public AssetCategory remove(long categoryId)
462 throws NoSuchCategoryException, SystemException {
463 return remove(Long.valueOf(categoryId));
464 }
465
466
474 @Override
475 public AssetCategory remove(Serializable primaryKey)
476 throws NoSuchCategoryException, SystemException {
477 Session session = null;
478
479 try {
480 session = openSession();
481
482 AssetCategory assetCategory = (AssetCategory)session.get(AssetCategoryImpl.class,
483 primaryKey);
484
485 if (assetCategory == null) {
486 if (_log.isWarnEnabled()) {
487 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
488 }
489
490 throw new NoSuchCategoryException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
491 primaryKey);
492 }
493
494 return remove(assetCategory);
495 }
496 catch (NoSuchCategoryException nsee) {
497 throw nsee;
498 }
499 catch (Exception e) {
500 throw processException(e);
501 }
502 finally {
503 closeSession(session);
504 }
505 }
506
507 @Override
508 protected AssetCategory removeImpl(AssetCategory assetCategory)
509 throws SystemException {
510 assetCategory = toUnwrappedModel(assetCategory);
511
512 try {
513 clearAssetEntries.clear(assetCategory.getPrimaryKey());
514 }
515 catch (Exception e) {
516 throw processException(e);
517 }
518 finally {
519 FinderCacheUtil.clearCache(AssetCategoryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
520 }
521
522 shrinkTree(assetCategory);
523
524 Session session = null;
525
526 try {
527 session = openSession();
528
529 BatchSessionUtil.delete(session, assetCategory);
530 }
531 catch (Exception e) {
532 throw processException(e);
533 }
534 finally {
535 closeSession(session);
536 }
537
538 clearCache(assetCategory);
539
540 return assetCategory;
541 }
542
543 @Override
544 public AssetCategory updateImpl(
545 com.liferay.portlet.asset.model.AssetCategory assetCategory,
546 boolean merge) throws SystemException {
547 assetCategory = toUnwrappedModel(assetCategory);
548
549 boolean isNew = assetCategory.isNew();
550
551 AssetCategoryModelImpl assetCategoryModelImpl = (AssetCategoryModelImpl)assetCategory;
552
553 if (Validator.isNull(assetCategory.getUuid())) {
554 String uuid = PortalUUIDUtil.generate();
555
556 assetCategory.setUuid(uuid);
557 }
558
559 if (isNew) {
560 expandTree(assetCategory, null);
561 }
562 else {
563 if (assetCategory.getParentCategoryId() != assetCategoryModelImpl.getOriginalParentCategoryId()) {
564 List<Long> childrenCategoryIds = getChildrenTreeCategoryIds(assetCategory);
565
566 shrinkTree(assetCategory);
567 expandTree(assetCategory, childrenCategoryIds);
568 }
569 }
570
571 Session session = null;
572
573 try {
574 session = openSession();
575
576 BatchSessionUtil.update(session, assetCategory, merge);
577
578 assetCategory.setNew(false);
579 }
580 catch (Exception e) {
581 throw processException(e);
582 }
583 finally {
584 closeSession(session);
585 }
586
587 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
588
589 if (isNew || !AssetCategoryModelImpl.COLUMN_BITMASK_ENABLED) {
590 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
591 }
592
593 else {
594 if ((assetCategoryModelImpl.getColumnBitmask() &
595 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID.getColumnBitmask()) != 0) {
596 Object[] args = new Object[] {
597 assetCategoryModelImpl.getOriginalUuid()
598 };
599
600 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
601 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
602 args);
603
604 args = new Object[] { assetCategoryModelImpl.getUuid() };
605
606 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
607 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
608 args);
609 }
610
611 if ((assetCategoryModelImpl.getColumnBitmask() &
612 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID.getColumnBitmask()) != 0) {
613 Object[] args = new Object[] {
614 Long.valueOf(assetCategoryModelImpl.getOriginalGroupId())
615 };
616
617 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
618 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
619 args);
620
621 args = new Object[] {
622 Long.valueOf(assetCategoryModelImpl.getGroupId())
623 };
624
625 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
626 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
627 args);
628 }
629
630 if ((assetCategoryModelImpl.getColumnBitmask() &
631 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_PARENTCATEGORYID.getColumnBitmask()) != 0) {
632 Object[] args = new Object[] {
633 Long.valueOf(assetCategoryModelImpl.getOriginalParentCategoryId())
634 };
635
636 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_PARENTCATEGORYID,
637 args);
638 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_PARENTCATEGORYID,
639 args);
640
641 args = new Object[] {
642 Long.valueOf(assetCategoryModelImpl.getParentCategoryId())
643 };
644
645 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_PARENTCATEGORYID,
646 args);
647 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_PARENTCATEGORYID,
648 args);
649 }
650
651 if ((assetCategoryModelImpl.getColumnBitmask() &
652 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_VOCABULARYID.getColumnBitmask()) != 0) {
653 Object[] args = new Object[] {
654 Long.valueOf(assetCategoryModelImpl.getOriginalVocabularyId())
655 };
656
657 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_VOCABULARYID,
658 args);
659 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_VOCABULARYID,
660 args);
661
662 args = new Object[] {
663 Long.valueOf(assetCategoryModelImpl.getVocabularyId())
664 };
665
666 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_VOCABULARYID,
667 args);
668 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_VOCABULARYID,
669 args);
670 }
671
672 if ((assetCategoryModelImpl.getColumnBitmask() &
673 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_V.getColumnBitmask()) != 0) {
674 Object[] args = new Object[] {
675 Long.valueOf(assetCategoryModelImpl.getOriginalGroupId()),
676 Long.valueOf(assetCategoryModelImpl.getOriginalVocabularyId())
677 };
678
679 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_V, args);
680 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_V,
681 args);
682
683 args = new Object[] {
684 Long.valueOf(assetCategoryModelImpl.getGroupId()),
685 Long.valueOf(assetCategoryModelImpl.getVocabularyId())
686 };
687
688 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_V, args);
689 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_V,
690 args);
691 }
692
693 if ((assetCategoryModelImpl.getColumnBitmask() &
694 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_P_N.getColumnBitmask()) != 0) {
695 Object[] args = new Object[] {
696 Long.valueOf(assetCategoryModelImpl.getOriginalParentCategoryId()),
697
698 assetCategoryModelImpl.getOriginalName()
699 };
700
701 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_P_N, args);
702 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_P_N,
703 args);
704
705 args = new Object[] {
706 Long.valueOf(assetCategoryModelImpl.getParentCategoryId()),
707
708 assetCategoryModelImpl.getName()
709 };
710
711 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_P_N, args);
712 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_P_N,
713 args);
714 }
715
716 if ((assetCategoryModelImpl.getColumnBitmask() &
717 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_P_V.getColumnBitmask()) != 0) {
718 Object[] args = new Object[] {
719 Long.valueOf(assetCategoryModelImpl.getOriginalParentCategoryId()),
720 Long.valueOf(assetCategoryModelImpl.getOriginalVocabularyId())
721 };
722
723 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_P_V, args);
724 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_P_V,
725 args);
726
727 args = new Object[] {
728 Long.valueOf(assetCategoryModelImpl.getParentCategoryId()),
729 Long.valueOf(assetCategoryModelImpl.getVocabularyId())
730 };
731
732 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_P_V, args);
733 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_P_V,
734 args);
735 }
736
737 if ((assetCategoryModelImpl.getColumnBitmask() &
738 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_V.getColumnBitmask()) != 0) {
739 Object[] args = new Object[] {
740 assetCategoryModelImpl.getOriginalName(),
741 Long.valueOf(assetCategoryModelImpl.getOriginalVocabularyId())
742 };
743
744 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_N_V, args);
745 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_V,
746 args);
747
748 args = new Object[] {
749 assetCategoryModelImpl.getName(),
750 Long.valueOf(assetCategoryModelImpl.getVocabularyId())
751 };
752
753 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_N_V, args);
754 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_V,
755 args);
756 }
757
758 if ((assetCategoryModelImpl.getColumnBitmask() &
759 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_N.getColumnBitmask()) != 0) {
760 Object[] args = new Object[] {
761 Long.valueOf(assetCategoryModelImpl.getOriginalGroupId()),
762 Long.valueOf(assetCategoryModelImpl.getOriginalParentCategoryId()),
763
764 assetCategoryModelImpl.getOriginalName()
765 };
766
767 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_P_N, args);
768 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_N,
769 args);
770
771 args = new Object[] {
772 Long.valueOf(assetCategoryModelImpl.getGroupId()),
773 Long.valueOf(assetCategoryModelImpl.getParentCategoryId()),
774
775 assetCategoryModelImpl.getName()
776 };
777
778 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_P_N, args);
779 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_N,
780 args);
781 }
782 }
783
784 EntityCacheUtil.putResult(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
785 AssetCategoryImpl.class, assetCategory.getPrimaryKey(),
786 assetCategory);
787
788 if (isNew) {
789 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
790 new Object[] {
791 assetCategory.getUuid(),
792 Long.valueOf(assetCategory.getGroupId())
793 }, assetCategory);
794
795 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_P_N_V,
796 new Object[] {
797 Long.valueOf(assetCategory.getParentCategoryId()),
798
799 assetCategory.getName(),
800 Long.valueOf(assetCategory.getVocabularyId())
801 }, assetCategory);
802 }
803 else {
804 if ((assetCategoryModelImpl.getColumnBitmask() &
805 FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) {
806 Object[] args = new Object[] {
807 assetCategoryModelImpl.getOriginalUuid(),
808 Long.valueOf(assetCategoryModelImpl.getOriginalGroupId())
809 };
810
811 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args);
812
813 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args);
814
815 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
816 new Object[] {
817 assetCategory.getUuid(),
818 Long.valueOf(assetCategory.getGroupId())
819 }, assetCategory);
820 }
821
822 if ((assetCategoryModelImpl.getColumnBitmask() &
823 FINDER_PATH_FETCH_BY_P_N_V.getColumnBitmask()) != 0) {
824 Object[] args = new Object[] {
825 Long.valueOf(assetCategoryModelImpl.getOriginalParentCategoryId()),
826
827 assetCategoryModelImpl.getOriginalName(),
828 Long.valueOf(assetCategoryModelImpl.getOriginalVocabularyId())
829 };
830
831 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_P_N_V, args);
832
833 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_P_N_V, args);
834
835 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_P_N_V,
836 new Object[] {
837 Long.valueOf(assetCategory.getParentCategoryId()),
838
839 assetCategory.getName(),
840 Long.valueOf(assetCategory.getVocabularyId())
841 }, assetCategory);
842 }
843 }
844
845 return assetCategory;
846 }
847
848 protected AssetCategory toUnwrappedModel(AssetCategory assetCategory) {
849 if (assetCategory instanceof AssetCategoryImpl) {
850 return assetCategory;
851 }
852
853 AssetCategoryImpl assetCategoryImpl = new AssetCategoryImpl();
854
855 assetCategoryImpl.setNew(assetCategory.isNew());
856 assetCategoryImpl.setPrimaryKey(assetCategory.getPrimaryKey());
857
858 assetCategoryImpl.setUuid(assetCategory.getUuid());
859 assetCategoryImpl.setCategoryId(assetCategory.getCategoryId());
860 assetCategoryImpl.setGroupId(assetCategory.getGroupId());
861 assetCategoryImpl.setCompanyId(assetCategory.getCompanyId());
862 assetCategoryImpl.setUserId(assetCategory.getUserId());
863 assetCategoryImpl.setUserName(assetCategory.getUserName());
864 assetCategoryImpl.setCreateDate(assetCategory.getCreateDate());
865 assetCategoryImpl.setModifiedDate(assetCategory.getModifiedDate());
866 assetCategoryImpl.setParentCategoryId(assetCategory.getParentCategoryId());
867 assetCategoryImpl.setLeftCategoryId(assetCategory.getLeftCategoryId());
868 assetCategoryImpl.setRightCategoryId(assetCategory.getRightCategoryId());
869 assetCategoryImpl.setName(assetCategory.getName());
870 assetCategoryImpl.setTitle(assetCategory.getTitle());
871 assetCategoryImpl.setDescription(assetCategory.getDescription());
872 assetCategoryImpl.setVocabularyId(assetCategory.getVocabularyId());
873
874 return assetCategoryImpl;
875 }
876
877
885 @Override
886 public AssetCategory findByPrimaryKey(Serializable primaryKey)
887 throws NoSuchModelException, SystemException {
888 return findByPrimaryKey(((Long)primaryKey).longValue());
889 }
890
891
899 public AssetCategory findByPrimaryKey(long categoryId)
900 throws NoSuchCategoryException, SystemException {
901 AssetCategory assetCategory = fetchByPrimaryKey(categoryId);
902
903 if (assetCategory == null) {
904 if (_log.isWarnEnabled()) {
905 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + categoryId);
906 }
907
908 throw new NoSuchCategoryException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
909 categoryId);
910 }
911
912 return assetCategory;
913 }
914
915
922 @Override
923 public AssetCategory fetchByPrimaryKey(Serializable primaryKey)
924 throws SystemException {
925 return fetchByPrimaryKey(((Long)primaryKey).longValue());
926 }
927
928
935 public AssetCategory fetchByPrimaryKey(long categoryId)
936 throws SystemException {
937 AssetCategory assetCategory = (AssetCategory)EntityCacheUtil.getResult(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
938 AssetCategoryImpl.class, categoryId);
939
940 if (assetCategory == _nullAssetCategory) {
941 return null;
942 }
943
944 if (assetCategory == null) {
945 Session session = null;
946
947 boolean hasException = false;
948
949 try {
950 session = openSession();
951
952 assetCategory = (AssetCategory)session.get(AssetCategoryImpl.class,
953 Long.valueOf(categoryId));
954 }
955 catch (Exception e) {
956 hasException = true;
957
958 throw processException(e);
959 }
960 finally {
961 if (assetCategory != null) {
962 cacheResult(assetCategory);
963 }
964 else if (!hasException) {
965 EntityCacheUtil.putResult(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
966 AssetCategoryImpl.class, categoryId, _nullAssetCategory);
967 }
968
969 closeSession(session);
970 }
971 }
972
973 return assetCategory;
974 }
975
976
983 public List<AssetCategory> findByUuid(String uuid)
984 throws SystemException {
985 return findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
986 }
987
988
1001 public List<AssetCategory> findByUuid(String uuid, int start, int end)
1002 throws SystemException {
1003 return findByUuid(uuid, start, end, null);
1004 }
1005
1006
1020 public List<AssetCategory> findByUuid(String uuid, int start, int end,
1021 OrderByComparator orderByComparator) throws SystemException {
1022 FinderPath finderPath = null;
1023 Object[] finderArgs = null;
1024
1025 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1026 (orderByComparator == null)) {
1027 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID;
1028 finderArgs = new Object[] { uuid };
1029 }
1030 else {
1031 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID;
1032 finderArgs = new Object[] { uuid, start, end, orderByComparator };
1033 }
1034
1035 List<AssetCategory> list = (List<AssetCategory>)FinderCacheUtil.getResult(finderPath,
1036 finderArgs, this);
1037
1038 if ((list != null) && !list.isEmpty()) {
1039 for (AssetCategory assetCategory : list) {
1040 if (!Validator.equals(uuid, assetCategory.getUuid())) {
1041 list = null;
1042
1043 break;
1044 }
1045 }
1046 }
1047
1048 if (list == null) {
1049 StringBundler query = null;
1050
1051 if (orderByComparator != null) {
1052 query = new StringBundler(3 +
1053 (orderByComparator.getOrderByFields().length * 3));
1054 }
1055 else {
1056 query = new StringBundler(3);
1057 }
1058
1059 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
1060
1061 if (uuid == null) {
1062 query.append(_FINDER_COLUMN_UUID_UUID_1);
1063 }
1064 else {
1065 if (uuid.equals(StringPool.BLANK)) {
1066 query.append(_FINDER_COLUMN_UUID_UUID_3);
1067 }
1068 else {
1069 query.append(_FINDER_COLUMN_UUID_UUID_2);
1070 }
1071 }
1072
1073 if (orderByComparator != null) {
1074 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1075 orderByComparator);
1076 }
1077
1078 else {
1079 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
1080 }
1081
1082 String sql = query.toString();
1083
1084 Session session = null;
1085
1086 try {
1087 session = openSession();
1088
1089 Query q = session.createQuery(sql);
1090
1091 QueryPos qPos = QueryPos.getInstance(q);
1092
1093 if (uuid != null) {
1094 qPos.add(uuid);
1095 }
1096
1097 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
1098 start, end);
1099 }
1100 catch (Exception e) {
1101 throw processException(e);
1102 }
1103 finally {
1104 if (list == null) {
1105 FinderCacheUtil.removeResult(finderPath, finderArgs);
1106 }
1107 else {
1108 cacheResult(list);
1109
1110 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1111 }
1112
1113 closeSession(session);
1114 }
1115 }
1116
1117 return list;
1118 }
1119
1120
1129 public AssetCategory findByUuid_First(String uuid,
1130 OrderByComparator orderByComparator)
1131 throws NoSuchCategoryException, SystemException {
1132 AssetCategory assetCategory = fetchByUuid_First(uuid, orderByComparator);
1133
1134 if (assetCategory != null) {
1135 return assetCategory;
1136 }
1137
1138 StringBundler msg = new StringBundler(4);
1139
1140 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1141
1142 msg.append("uuid=");
1143 msg.append(uuid);
1144
1145 msg.append(StringPool.CLOSE_CURLY_BRACE);
1146
1147 throw new NoSuchCategoryException(msg.toString());
1148 }
1149
1150
1158 public AssetCategory fetchByUuid_First(String uuid,
1159 OrderByComparator orderByComparator) throws SystemException {
1160 List<AssetCategory> list = findByUuid(uuid, 0, 1, orderByComparator);
1161
1162 if (!list.isEmpty()) {
1163 return list.get(0);
1164 }
1165
1166 return null;
1167 }
1168
1169
1178 public AssetCategory findByUuid_Last(String uuid,
1179 OrderByComparator orderByComparator)
1180 throws NoSuchCategoryException, SystemException {
1181 AssetCategory assetCategory = fetchByUuid_Last(uuid, orderByComparator);
1182
1183 if (assetCategory != null) {
1184 return assetCategory;
1185 }
1186
1187 StringBundler msg = new StringBundler(4);
1188
1189 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1190
1191 msg.append("uuid=");
1192 msg.append(uuid);
1193
1194 msg.append(StringPool.CLOSE_CURLY_BRACE);
1195
1196 throw new NoSuchCategoryException(msg.toString());
1197 }
1198
1199
1207 public AssetCategory fetchByUuid_Last(String uuid,
1208 OrderByComparator orderByComparator) throws SystemException {
1209 int count = countByUuid(uuid);
1210
1211 List<AssetCategory> list = findByUuid(uuid, count - 1, count,
1212 orderByComparator);
1213
1214 if (!list.isEmpty()) {
1215 return list.get(0);
1216 }
1217
1218 return null;
1219 }
1220
1221
1231 public AssetCategory[] findByUuid_PrevAndNext(long categoryId, String uuid,
1232 OrderByComparator orderByComparator)
1233 throws NoSuchCategoryException, SystemException {
1234 AssetCategory assetCategory = findByPrimaryKey(categoryId);
1235
1236 Session session = null;
1237
1238 try {
1239 session = openSession();
1240
1241 AssetCategory[] array = new AssetCategoryImpl[3];
1242
1243 array[0] = getByUuid_PrevAndNext(session, assetCategory, uuid,
1244 orderByComparator, true);
1245
1246 array[1] = assetCategory;
1247
1248 array[2] = getByUuid_PrevAndNext(session, assetCategory, uuid,
1249 orderByComparator, false);
1250
1251 return array;
1252 }
1253 catch (Exception e) {
1254 throw processException(e);
1255 }
1256 finally {
1257 closeSession(session);
1258 }
1259 }
1260
1261 protected AssetCategory getByUuid_PrevAndNext(Session session,
1262 AssetCategory assetCategory, String uuid,
1263 OrderByComparator orderByComparator, boolean previous) {
1264 StringBundler query = null;
1265
1266 if (orderByComparator != null) {
1267 query = new StringBundler(6 +
1268 (orderByComparator.getOrderByFields().length * 6));
1269 }
1270 else {
1271 query = new StringBundler(3);
1272 }
1273
1274 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
1275
1276 if (uuid == null) {
1277 query.append(_FINDER_COLUMN_UUID_UUID_1);
1278 }
1279 else {
1280 if (uuid.equals(StringPool.BLANK)) {
1281 query.append(_FINDER_COLUMN_UUID_UUID_3);
1282 }
1283 else {
1284 query.append(_FINDER_COLUMN_UUID_UUID_2);
1285 }
1286 }
1287
1288 if (orderByComparator != null) {
1289 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1290
1291 if (orderByConditionFields.length > 0) {
1292 query.append(WHERE_AND);
1293 }
1294
1295 for (int i = 0; i < orderByConditionFields.length; i++) {
1296 query.append(_ORDER_BY_ENTITY_ALIAS);
1297 query.append(orderByConditionFields[i]);
1298
1299 if ((i + 1) < orderByConditionFields.length) {
1300 if (orderByComparator.isAscending() ^ previous) {
1301 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1302 }
1303 else {
1304 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1305 }
1306 }
1307 else {
1308 if (orderByComparator.isAscending() ^ previous) {
1309 query.append(WHERE_GREATER_THAN);
1310 }
1311 else {
1312 query.append(WHERE_LESSER_THAN);
1313 }
1314 }
1315 }
1316
1317 query.append(ORDER_BY_CLAUSE);
1318
1319 String[] orderByFields = orderByComparator.getOrderByFields();
1320
1321 for (int i = 0; i < orderByFields.length; i++) {
1322 query.append(_ORDER_BY_ENTITY_ALIAS);
1323 query.append(orderByFields[i]);
1324
1325 if ((i + 1) < orderByFields.length) {
1326 if (orderByComparator.isAscending() ^ previous) {
1327 query.append(ORDER_BY_ASC_HAS_NEXT);
1328 }
1329 else {
1330 query.append(ORDER_BY_DESC_HAS_NEXT);
1331 }
1332 }
1333 else {
1334 if (orderByComparator.isAscending() ^ previous) {
1335 query.append(ORDER_BY_ASC);
1336 }
1337 else {
1338 query.append(ORDER_BY_DESC);
1339 }
1340 }
1341 }
1342 }
1343
1344 else {
1345 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
1346 }
1347
1348 String sql = query.toString();
1349
1350 Query q = session.createQuery(sql);
1351
1352 q.setFirstResult(0);
1353 q.setMaxResults(2);
1354
1355 QueryPos qPos = QueryPos.getInstance(q);
1356
1357 if (uuid != null) {
1358 qPos.add(uuid);
1359 }
1360
1361 if (orderByComparator != null) {
1362 Object[] values = orderByComparator.getOrderByConditionValues(assetCategory);
1363
1364 for (Object value : values) {
1365 qPos.add(value);
1366 }
1367 }
1368
1369 List<AssetCategory> list = q.list();
1370
1371 if (list.size() == 2) {
1372 return list.get(1);
1373 }
1374 else {
1375 return null;
1376 }
1377 }
1378
1379
1388 public AssetCategory findByUUID_G(String uuid, long groupId)
1389 throws NoSuchCategoryException, SystemException {
1390 AssetCategory assetCategory = fetchByUUID_G(uuid, groupId);
1391
1392 if (assetCategory == null) {
1393 StringBundler msg = new StringBundler(6);
1394
1395 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1396
1397 msg.append("uuid=");
1398 msg.append(uuid);
1399
1400 msg.append(", groupId=");
1401 msg.append(groupId);
1402
1403 msg.append(StringPool.CLOSE_CURLY_BRACE);
1404
1405 if (_log.isWarnEnabled()) {
1406 _log.warn(msg.toString());
1407 }
1408
1409 throw new NoSuchCategoryException(msg.toString());
1410 }
1411
1412 return assetCategory;
1413 }
1414
1415
1423 public AssetCategory fetchByUUID_G(String uuid, long groupId)
1424 throws SystemException {
1425 return fetchByUUID_G(uuid, groupId, true);
1426 }
1427
1428
1437 public AssetCategory fetchByUUID_G(String uuid, long groupId,
1438 boolean retrieveFromCache) throws SystemException {
1439 Object[] finderArgs = new Object[] { uuid, groupId };
1440
1441 Object result = null;
1442
1443 if (retrieveFromCache) {
1444 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_UUID_G,
1445 finderArgs, this);
1446 }
1447
1448 if (result instanceof AssetCategory) {
1449 AssetCategory assetCategory = (AssetCategory)result;
1450
1451 if (!Validator.equals(uuid, assetCategory.getUuid()) ||
1452 (groupId != assetCategory.getGroupId())) {
1453 result = null;
1454 }
1455 }
1456
1457 if (result == null) {
1458 StringBundler query = new StringBundler(4);
1459
1460 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
1461
1462 if (uuid == null) {
1463 query.append(_FINDER_COLUMN_UUID_G_UUID_1);
1464 }
1465 else {
1466 if (uuid.equals(StringPool.BLANK)) {
1467 query.append(_FINDER_COLUMN_UUID_G_UUID_3);
1468 }
1469 else {
1470 query.append(_FINDER_COLUMN_UUID_G_UUID_2);
1471 }
1472 }
1473
1474 query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
1475
1476 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
1477
1478 String sql = query.toString();
1479
1480 Session session = null;
1481
1482 try {
1483 session = openSession();
1484
1485 Query q = session.createQuery(sql);
1486
1487 QueryPos qPos = QueryPos.getInstance(q);
1488
1489 if (uuid != null) {
1490 qPos.add(uuid);
1491 }
1492
1493 qPos.add(groupId);
1494
1495 List<AssetCategory> list = q.list();
1496
1497 result = list;
1498
1499 AssetCategory assetCategory = null;
1500
1501 if (list.isEmpty()) {
1502 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
1503 finderArgs, list);
1504 }
1505 else {
1506 assetCategory = list.get(0);
1507
1508 cacheResult(assetCategory);
1509
1510 if ((assetCategory.getUuid() == null) ||
1511 !assetCategory.getUuid().equals(uuid) ||
1512 (assetCategory.getGroupId() != groupId)) {
1513 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
1514 finderArgs, assetCategory);
1515 }
1516 }
1517
1518 return assetCategory;
1519 }
1520 catch (Exception e) {
1521 throw processException(e);
1522 }
1523 finally {
1524 if (result == null) {
1525 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
1526 finderArgs);
1527 }
1528
1529 closeSession(session);
1530 }
1531 }
1532 else {
1533 if (result instanceof List<?>) {
1534 return null;
1535 }
1536 else {
1537 return (AssetCategory)result;
1538 }
1539 }
1540 }
1541
1542
1549 public List<AssetCategory> findByGroupId(long groupId)
1550 throws SystemException {
1551 return findByGroupId(groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1552 }
1553
1554
1567 public List<AssetCategory> findByGroupId(long groupId, int start, int end)
1568 throws SystemException {
1569 return findByGroupId(groupId, start, end, null);
1570 }
1571
1572
1586 public List<AssetCategory> findByGroupId(long groupId, int start, int end,
1587 OrderByComparator orderByComparator) throws SystemException {
1588 FinderPath finderPath = null;
1589 Object[] finderArgs = null;
1590
1591 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1592 (orderByComparator == null)) {
1593 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID;
1594 finderArgs = new Object[] { groupId };
1595 }
1596 else {
1597 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID;
1598 finderArgs = new Object[] { groupId, start, end, orderByComparator };
1599 }
1600
1601 List<AssetCategory> list = (List<AssetCategory>)FinderCacheUtil.getResult(finderPath,
1602 finderArgs, this);
1603
1604 if ((list != null) && !list.isEmpty()) {
1605 for (AssetCategory assetCategory : list) {
1606 if ((groupId != assetCategory.getGroupId())) {
1607 list = null;
1608
1609 break;
1610 }
1611 }
1612 }
1613
1614 if (list == null) {
1615 StringBundler query = null;
1616
1617 if (orderByComparator != null) {
1618 query = new StringBundler(3 +
1619 (orderByComparator.getOrderByFields().length * 3));
1620 }
1621 else {
1622 query = new StringBundler(3);
1623 }
1624
1625 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
1626
1627 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1628
1629 if (orderByComparator != null) {
1630 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1631 orderByComparator);
1632 }
1633
1634 else {
1635 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
1636 }
1637
1638 String sql = query.toString();
1639
1640 Session session = null;
1641
1642 try {
1643 session = openSession();
1644
1645 Query q = session.createQuery(sql);
1646
1647 QueryPos qPos = QueryPos.getInstance(q);
1648
1649 qPos.add(groupId);
1650
1651 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
1652 start, end);
1653 }
1654 catch (Exception e) {
1655 throw processException(e);
1656 }
1657 finally {
1658 if (list == null) {
1659 FinderCacheUtil.removeResult(finderPath, finderArgs);
1660 }
1661 else {
1662 cacheResult(list);
1663
1664 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1665 }
1666
1667 closeSession(session);
1668 }
1669 }
1670
1671 return list;
1672 }
1673
1674
1683 public AssetCategory findByGroupId_First(long groupId,
1684 OrderByComparator orderByComparator)
1685 throws NoSuchCategoryException, SystemException {
1686 AssetCategory assetCategory = fetchByGroupId_First(groupId,
1687 orderByComparator);
1688
1689 if (assetCategory != null) {
1690 return assetCategory;
1691 }
1692
1693 StringBundler msg = new StringBundler(4);
1694
1695 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1696
1697 msg.append("groupId=");
1698 msg.append(groupId);
1699
1700 msg.append(StringPool.CLOSE_CURLY_BRACE);
1701
1702 throw new NoSuchCategoryException(msg.toString());
1703 }
1704
1705
1713 public AssetCategory fetchByGroupId_First(long groupId,
1714 OrderByComparator orderByComparator) throws SystemException {
1715 List<AssetCategory> list = findByGroupId(groupId, 0, 1,
1716 orderByComparator);
1717
1718 if (!list.isEmpty()) {
1719 return list.get(0);
1720 }
1721
1722 return null;
1723 }
1724
1725
1734 public AssetCategory findByGroupId_Last(long groupId,
1735 OrderByComparator orderByComparator)
1736 throws NoSuchCategoryException, SystemException {
1737 AssetCategory assetCategory = fetchByGroupId_Last(groupId,
1738 orderByComparator);
1739
1740 if (assetCategory != null) {
1741 return assetCategory;
1742 }
1743
1744 StringBundler msg = new StringBundler(4);
1745
1746 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1747
1748 msg.append("groupId=");
1749 msg.append(groupId);
1750
1751 msg.append(StringPool.CLOSE_CURLY_BRACE);
1752
1753 throw new NoSuchCategoryException(msg.toString());
1754 }
1755
1756
1764 public AssetCategory fetchByGroupId_Last(long groupId,
1765 OrderByComparator orderByComparator) throws SystemException {
1766 int count = countByGroupId(groupId);
1767
1768 List<AssetCategory> list = findByGroupId(groupId, count - 1, count,
1769 orderByComparator);
1770
1771 if (!list.isEmpty()) {
1772 return list.get(0);
1773 }
1774
1775 return null;
1776 }
1777
1778
1788 public AssetCategory[] findByGroupId_PrevAndNext(long categoryId,
1789 long groupId, OrderByComparator orderByComparator)
1790 throws NoSuchCategoryException, SystemException {
1791 AssetCategory assetCategory = findByPrimaryKey(categoryId);
1792
1793 Session session = null;
1794
1795 try {
1796 session = openSession();
1797
1798 AssetCategory[] array = new AssetCategoryImpl[3];
1799
1800 array[0] = getByGroupId_PrevAndNext(session, assetCategory,
1801 groupId, orderByComparator, true);
1802
1803 array[1] = assetCategory;
1804
1805 array[2] = getByGroupId_PrevAndNext(session, assetCategory,
1806 groupId, orderByComparator, false);
1807
1808 return array;
1809 }
1810 catch (Exception e) {
1811 throw processException(e);
1812 }
1813 finally {
1814 closeSession(session);
1815 }
1816 }
1817
1818 protected AssetCategory getByGroupId_PrevAndNext(Session session,
1819 AssetCategory assetCategory, long groupId,
1820 OrderByComparator orderByComparator, boolean previous) {
1821 StringBundler query = null;
1822
1823 if (orderByComparator != null) {
1824 query = new StringBundler(6 +
1825 (orderByComparator.getOrderByFields().length * 6));
1826 }
1827 else {
1828 query = new StringBundler(3);
1829 }
1830
1831 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
1832
1833 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1834
1835 if (orderByComparator != null) {
1836 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1837
1838 if (orderByConditionFields.length > 0) {
1839 query.append(WHERE_AND);
1840 }
1841
1842 for (int i = 0; i < orderByConditionFields.length; i++) {
1843 query.append(_ORDER_BY_ENTITY_ALIAS);
1844 query.append(orderByConditionFields[i]);
1845
1846 if ((i + 1) < orderByConditionFields.length) {
1847 if (orderByComparator.isAscending() ^ previous) {
1848 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1849 }
1850 else {
1851 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1852 }
1853 }
1854 else {
1855 if (orderByComparator.isAscending() ^ previous) {
1856 query.append(WHERE_GREATER_THAN);
1857 }
1858 else {
1859 query.append(WHERE_LESSER_THAN);
1860 }
1861 }
1862 }
1863
1864 query.append(ORDER_BY_CLAUSE);
1865
1866 String[] orderByFields = orderByComparator.getOrderByFields();
1867
1868 for (int i = 0; i < orderByFields.length; i++) {
1869 query.append(_ORDER_BY_ENTITY_ALIAS);
1870 query.append(orderByFields[i]);
1871
1872 if ((i + 1) < orderByFields.length) {
1873 if (orderByComparator.isAscending() ^ previous) {
1874 query.append(ORDER_BY_ASC_HAS_NEXT);
1875 }
1876 else {
1877 query.append(ORDER_BY_DESC_HAS_NEXT);
1878 }
1879 }
1880 else {
1881 if (orderByComparator.isAscending() ^ previous) {
1882 query.append(ORDER_BY_ASC);
1883 }
1884 else {
1885 query.append(ORDER_BY_DESC);
1886 }
1887 }
1888 }
1889 }
1890
1891 else {
1892 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
1893 }
1894
1895 String sql = query.toString();
1896
1897 Query q = session.createQuery(sql);
1898
1899 q.setFirstResult(0);
1900 q.setMaxResults(2);
1901
1902 QueryPos qPos = QueryPos.getInstance(q);
1903
1904 qPos.add(groupId);
1905
1906 if (orderByComparator != null) {
1907 Object[] values = orderByComparator.getOrderByConditionValues(assetCategory);
1908
1909 for (Object value : values) {
1910 qPos.add(value);
1911 }
1912 }
1913
1914 List<AssetCategory> list = q.list();
1915
1916 if (list.size() == 2) {
1917 return list.get(1);
1918 }
1919 else {
1920 return null;
1921 }
1922 }
1923
1924
1931 public List<AssetCategory> filterFindByGroupId(long groupId)
1932 throws SystemException {
1933 return filterFindByGroupId(groupId, QueryUtil.ALL_POS,
1934 QueryUtil.ALL_POS, null);
1935 }
1936
1937
1950 public List<AssetCategory> filterFindByGroupId(long groupId, int start,
1951 int end) throws SystemException {
1952 return filterFindByGroupId(groupId, start, end, null);
1953 }
1954
1955
1969 public List<AssetCategory> filterFindByGroupId(long groupId, int start,
1970 int end, OrderByComparator orderByComparator) throws SystemException {
1971 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
1972 return findByGroupId(groupId, start, end, orderByComparator);
1973 }
1974
1975 StringBundler query = null;
1976
1977 if (orderByComparator != null) {
1978 query = new StringBundler(3 +
1979 (orderByComparator.getOrderByFields().length * 3));
1980 }
1981 else {
1982 query = new StringBundler(3);
1983 }
1984
1985 if (getDB().isSupportsInlineDistinct()) {
1986 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_WHERE);
1987 }
1988 else {
1989 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_1);
1990 }
1991
1992 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1993
1994 if (!getDB().isSupportsInlineDistinct()) {
1995 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_2);
1996 }
1997
1998 if (orderByComparator != null) {
1999 if (getDB().isSupportsInlineDistinct()) {
2000 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2001 orderByComparator);
2002 }
2003 else {
2004 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
2005 orderByComparator);
2006 }
2007 }
2008
2009 else {
2010 if (getDB().isSupportsInlineDistinct()) {
2011 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
2012 }
2013 else {
2014 query.append(AssetCategoryModelImpl.ORDER_BY_SQL);
2015 }
2016 }
2017
2018 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2019 AssetCategory.class.getName(),
2020 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2021
2022 Session session = null;
2023
2024 try {
2025 session = openSession();
2026
2027 SQLQuery q = session.createSQLQuery(sql);
2028
2029 if (getDB().isSupportsInlineDistinct()) {
2030 q.addEntity(_FILTER_ENTITY_ALIAS, AssetCategoryImpl.class);
2031 }
2032 else {
2033 q.addEntity(_FILTER_ENTITY_TABLE, AssetCategoryImpl.class);
2034 }
2035
2036 QueryPos qPos = QueryPos.getInstance(q);
2037
2038 qPos.add(groupId);
2039
2040 return (List<AssetCategory>)QueryUtil.list(q, getDialect(), start,
2041 end);
2042 }
2043 catch (Exception e) {
2044 throw processException(e);
2045 }
2046 finally {
2047 closeSession(session);
2048 }
2049 }
2050
2051
2061 public AssetCategory[] filterFindByGroupId_PrevAndNext(long categoryId,
2062 long groupId, OrderByComparator orderByComparator)
2063 throws NoSuchCategoryException, SystemException {
2064 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2065 return findByGroupId_PrevAndNext(categoryId, groupId,
2066 orderByComparator);
2067 }
2068
2069 AssetCategory assetCategory = findByPrimaryKey(categoryId);
2070
2071 Session session = null;
2072
2073 try {
2074 session = openSession();
2075
2076 AssetCategory[] array = new AssetCategoryImpl[3];
2077
2078 array[0] = filterGetByGroupId_PrevAndNext(session, assetCategory,
2079 groupId, orderByComparator, true);
2080
2081 array[1] = assetCategory;
2082
2083 array[2] = filterGetByGroupId_PrevAndNext(session, assetCategory,
2084 groupId, orderByComparator, false);
2085
2086 return array;
2087 }
2088 catch (Exception e) {
2089 throw processException(e);
2090 }
2091 finally {
2092 closeSession(session);
2093 }
2094 }
2095
2096 protected AssetCategory filterGetByGroupId_PrevAndNext(Session session,
2097 AssetCategory assetCategory, long groupId,
2098 OrderByComparator orderByComparator, boolean previous) {
2099 StringBundler query = null;
2100
2101 if (orderByComparator != null) {
2102 query = new StringBundler(6 +
2103 (orderByComparator.getOrderByFields().length * 6));
2104 }
2105 else {
2106 query = new StringBundler(3);
2107 }
2108
2109 if (getDB().isSupportsInlineDistinct()) {
2110 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_WHERE);
2111 }
2112 else {
2113 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_1);
2114 }
2115
2116 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2117
2118 if (!getDB().isSupportsInlineDistinct()) {
2119 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_2);
2120 }
2121
2122 if (orderByComparator != null) {
2123 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2124
2125 if (orderByConditionFields.length > 0) {
2126 query.append(WHERE_AND);
2127 }
2128
2129 for (int i = 0; i < orderByConditionFields.length; i++) {
2130 if (getDB().isSupportsInlineDistinct()) {
2131 query.append(_ORDER_BY_ENTITY_ALIAS);
2132 }
2133 else {
2134 query.append(_ORDER_BY_ENTITY_TABLE);
2135 }
2136
2137 query.append(orderByConditionFields[i]);
2138
2139 if ((i + 1) < orderByConditionFields.length) {
2140 if (orderByComparator.isAscending() ^ previous) {
2141 query.append(WHERE_GREATER_THAN_HAS_NEXT);
2142 }
2143 else {
2144 query.append(WHERE_LESSER_THAN_HAS_NEXT);
2145 }
2146 }
2147 else {
2148 if (orderByComparator.isAscending() ^ previous) {
2149 query.append(WHERE_GREATER_THAN);
2150 }
2151 else {
2152 query.append(WHERE_LESSER_THAN);
2153 }
2154 }
2155 }
2156
2157 query.append(ORDER_BY_CLAUSE);
2158
2159 String[] orderByFields = orderByComparator.getOrderByFields();
2160
2161 for (int i = 0; i < orderByFields.length; i++) {
2162 if (getDB().isSupportsInlineDistinct()) {
2163 query.append(_ORDER_BY_ENTITY_ALIAS);
2164 }
2165 else {
2166 query.append(_ORDER_BY_ENTITY_TABLE);
2167 }
2168
2169 query.append(orderByFields[i]);
2170
2171 if ((i + 1) < orderByFields.length) {
2172 if (orderByComparator.isAscending() ^ previous) {
2173 query.append(ORDER_BY_ASC_HAS_NEXT);
2174 }
2175 else {
2176 query.append(ORDER_BY_DESC_HAS_NEXT);
2177 }
2178 }
2179 else {
2180 if (orderByComparator.isAscending() ^ previous) {
2181 query.append(ORDER_BY_ASC);
2182 }
2183 else {
2184 query.append(ORDER_BY_DESC);
2185 }
2186 }
2187 }
2188 }
2189
2190 else {
2191 if (getDB().isSupportsInlineDistinct()) {
2192 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
2193 }
2194 else {
2195 query.append(AssetCategoryModelImpl.ORDER_BY_SQL);
2196 }
2197 }
2198
2199 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2200 AssetCategory.class.getName(),
2201 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2202
2203 SQLQuery q = session.createSQLQuery(sql);
2204
2205 q.setFirstResult(0);
2206 q.setMaxResults(2);
2207
2208 if (getDB().isSupportsInlineDistinct()) {
2209 q.addEntity(_FILTER_ENTITY_ALIAS, AssetCategoryImpl.class);
2210 }
2211 else {
2212 q.addEntity(_FILTER_ENTITY_TABLE, AssetCategoryImpl.class);
2213 }
2214
2215 QueryPos qPos = QueryPos.getInstance(q);
2216
2217 qPos.add(groupId);
2218
2219 if (orderByComparator != null) {
2220 Object[] values = orderByComparator.getOrderByConditionValues(assetCategory);
2221
2222 for (Object value : values) {
2223 qPos.add(value);
2224 }
2225 }
2226
2227 List<AssetCategory> list = q.list();
2228
2229 if (list.size() == 2) {
2230 return list.get(1);
2231 }
2232 else {
2233 return null;
2234 }
2235 }
2236
2237
2244 public List<AssetCategory> findByParentCategoryId(long parentCategoryId)
2245 throws SystemException {
2246 return findByParentCategoryId(parentCategoryId, QueryUtil.ALL_POS,
2247 QueryUtil.ALL_POS, null);
2248 }
2249
2250
2263 public List<AssetCategory> findByParentCategoryId(long parentCategoryId,
2264 int start, int end) throws SystemException {
2265 return findByParentCategoryId(parentCategoryId, start, end, null);
2266 }
2267
2268
2282 public List<AssetCategory> findByParentCategoryId(long parentCategoryId,
2283 int start, int end, OrderByComparator orderByComparator)
2284 throws SystemException {
2285 FinderPath finderPath = null;
2286 Object[] finderArgs = null;
2287
2288 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2289 (orderByComparator == null)) {
2290 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_PARENTCATEGORYID;
2291 finderArgs = new Object[] { parentCategoryId };
2292 }
2293 else {
2294 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_PARENTCATEGORYID;
2295 finderArgs = new Object[] {
2296 parentCategoryId,
2297
2298 start, end, orderByComparator
2299 };
2300 }
2301
2302 List<AssetCategory> list = (List<AssetCategory>)FinderCacheUtil.getResult(finderPath,
2303 finderArgs, this);
2304
2305 if ((list != null) && !list.isEmpty()) {
2306 for (AssetCategory assetCategory : list) {
2307 if ((parentCategoryId != assetCategory.getParentCategoryId())) {
2308 list = null;
2309
2310 break;
2311 }
2312 }
2313 }
2314
2315 if (list == null) {
2316 StringBundler query = null;
2317
2318 if (orderByComparator != null) {
2319 query = new StringBundler(3 +
2320 (orderByComparator.getOrderByFields().length * 3));
2321 }
2322 else {
2323 query = new StringBundler(3);
2324 }
2325
2326 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
2327
2328 query.append(_FINDER_COLUMN_PARENTCATEGORYID_PARENTCATEGORYID_2);
2329
2330 if (orderByComparator != null) {
2331 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2332 orderByComparator);
2333 }
2334
2335 else {
2336 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
2337 }
2338
2339 String sql = query.toString();
2340
2341 Session session = null;
2342
2343 try {
2344 session = openSession();
2345
2346 Query q = session.createQuery(sql);
2347
2348 QueryPos qPos = QueryPos.getInstance(q);
2349
2350 qPos.add(parentCategoryId);
2351
2352 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
2353 start, end);
2354 }
2355 catch (Exception e) {
2356 throw processException(e);
2357 }
2358 finally {
2359 if (list == null) {
2360 FinderCacheUtil.removeResult(finderPath, finderArgs);
2361 }
2362 else {
2363 cacheResult(list);
2364
2365 FinderCacheUtil.putResult(finderPath, finderArgs, list);
2366 }
2367
2368 closeSession(session);
2369 }
2370 }
2371
2372 return list;
2373 }
2374
2375
2384 public AssetCategory findByParentCategoryId_First(long parentCategoryId,
2385 OrderByComparator orderByComparator)
2386 throws NoSuchCategoryException, SystemException {
2387 AssetCategory assetCategory = fetchByParentCategoryId_First(parentCategoryId,
2388 orderByComparator);
2389
2390 if (assetCategory != null) {
2391 return assetCategory;
2392 }
2393
2394 StringBundler msg = new StringBundler(4);
2395
2396 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2397
2398 msg.append("parentCategoryId=");
2399 msg.append(parentCategoryId);
2400
2401 msg.append(StringPool.CLOSE_CURLY_BRACE);
2402
2403 throw new NoSuchCategoryException(msg.toString());
2404 }
2405
2406
2414 public AssetCategory fetchByParentCategoryId_First(long parentCategoryId,
2415 OrderByComparator orderByComparator) throws SystemException {
2416 List<AssetCategory> list = findByParentCategoryId(parentCategoryId, 0,
2417 1, orderByComparator);
2418
2419 if (!list.isEmpty()) {
2420 return list.get(0);
2421 }
2422
2423 return null;
2424 }
2425
2426
2435 public AssetCategory findByParentCategoryId_Last(long parentCategoryId,
2436 OrderByComparator orderByComparator)
2437 throws NoSuchCategoryException, SystemException {
2438 AssetCategory assetCategory = fetchByParentCategoryId_Last(parentCategoryId,
2439 orderByComparator);
2440
2441 if (assetCategory != null) {
2442 return assetCategory;
2443 }
2444
2445 StringBundler msg = new StringBundler(4);
2446
2447 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2448
2449 msg.append("parentCategoryId=");
2450 msg.append(parentCategoryId);
2451
2452 msg.append(StringPool.CLOSE_CURLY_BRACE);
2453
2454 throw new NoSuchCategoryException(msg.toString());
2455 }
2456
2457
2465 public AssetCategory fetchByParentCategoryId_Last(long parentCategoryId,
2466 OrderByComparator orderByComparator) throws SystemException {
2467 int count = countByParentCategoryId(parentCategoryId);
2468
2469 List<AssetCategory> list = findByParentCategoryId(parentCategoryId,
2470 count - 1, count, orderByComparator);
2471
2472 if (!list.isEmpty()) {
2473 return list.get(0);
2474 }
2475
2476 return null;
2477 }
2478
2479
2489 public AssetCategory[] findByParentCategoryId_PrevAndNext(long categoryId,
2490 long parentCategoryId, OrderByComparator orderByComparator)
2491 throws NoSuchCategoryException, SystemException {
2492 AssetCategory assetCategory = findByPrimaryKey(categoryId);
2493
2494 Session session = null;
2495
2496 try {
2497 session = openSession();
2498
2499 AssetCategory[] array = new AssetCategoryImpl[3];
2500
2501 array[0] = getByParentCategoryId_PrevAndNext(session,
2502 assetCategory, parentCategoryId, orderByComparator, true);
2503
2504 array[1] = assetCategory;
2505
2506 array[2] = getByParentCategoryId_PrevAndNext(session,
2507 assetCategory, parentCategoryId, orderByComparator, false);
2508
2509 return array;
2510 }
2511 catch (Exception e) {
2512 throw processException(e);
2513 }
2514 finally {
2515 closeSession(session);
2516 }
2517 }
2518
2519 protected AssetCategory getByParentCategoryId_PrevAndNext(Session session,
2520 AssetCategory assetCategory, long parentCategoryId,
2521 OrderByComparator orderByComparator, boolean previous) {
2522 StringBundler query = null;
2523
2524 if (orderByComparator != null) {
2525 query = new StringBundler(6 +
2526 (orderByComparator.getOrderByFields().length * 6));
2527 }
2528 else {
2529 query = new StringBundler(3);
2530 }
2531
2532 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
2533
2534 query.append(_FINDER_COLUMN_PARENTCATEGORYID_PARENTCATEGORYID_2);
2535
2536 if (orderByComparator != null) {
2537 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2538
2539 if (orderByConditionFields.length > 0) {
2540 query.append(WHERE_AND);
2541 }
2542
2543 for (int i = 0; i < orderByConditionFields.length; i++) {
2544 query.append(_ORDER_BY_ENTITY_ALIAS);
2545 query.append(orderByConditionFields[i]);
2546
2547 if ((i + 1) < orderByConditionFields.length) {
2548 if (orderByComparator.isAscending() ^ previous) {
2549 query.append(WHERE_GREATER_THAN_HAS_NEXT);
2550 }
2551 else {
2552 query.append(WHERE_LESSER_THAN_HAS_NEXT);
2553 }
2554 }
2555 else {
2556 if (orderByComparator.isAscending() ^ previous) {
2557 query.append(WHERE_GREATER_THAN);
2558 }
2559 else {
2560 query.append(WHERE_LESSER_THAN);
2561 }
2562 }
2563 }
2564
2565 query.append(ORDER_BY_CLAUSE);
2566
2567 String[] orderByFields = orderByComparator.getOrderByFields();
2568
2569 for (int i = 0; i < orderByFields.length; i++) {
2570 query.append(_ORDER_BY_ENTITY_ALIAS);
2571 query.append(orderByFields[i]);
2572
2573 if ((i + 1) < orderByFields.length) {
2574 if (orderByComparator.isAscending() ^ previous) {
2575 query.append(ORDER_BY_ASC_HAS_NEXT);
2576 }
2577 else {
2578 query.append(ORDER_BY_DESC_HAS_NEXT);
2579 }
2580 }
2581 else {
2582 if (orderByComparator.isAscending() ^ previous) {
2583 query.append(ORDER_BY_ASC);
2584 }
2585 else {
2586 query.append(ORDER_BY_DESC);
2587 }
2588 }
2589 }
2590 }
2591
2592 else {
2593 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
2594 }
2595
2596 String sql = query.toString();
2597
2598 Query q = session.createQuery(sql);
2599
2600 q.setFirstResult(0);
2601 q.setMaxResults(2);
2602
2603 QueryPos qPos = QueryPos.getInstance(q);
2604
2605 qPos.add(parentCategoryId);
2606
2607 if (orderByComparator != null) {
2608 Object[] values = orderByComparator.getOrderByConditionValues(assetCategory);
2609
2610 for (Object value : values) {
2611 qPos.add(value);
2612 }
2613 }
2614
2615 List<AssetCategory> list = q.list();
2616
2617 if (list.size() == 2) {
2618 return list.get(1);
2619 }
2620 else {
2621 return null;
2622 }
2623 }
2624
2625
2632 public List<AssetCategory> findByVocabularyId(long vocabularyId)
2633 throws SystemException {
2634 return findByVocabularyId(vocabularyId, QueryUtil.ALL_POS,
2635 QueryUtil.ALL_POS, null);
2636 }
2637
2638
2651 public List<AssetCategory> findByVocabularyId(long vocabularyId, int start,
2652 int end) throws SystemException {
2653 return findByVocabularyId(vocabularyId, start, end, null);
2654 }
2655
2656
2670 public List<AssetCategory> findByVocabularyId(long vocabularyId, int start,
2671 int end, OrderByComparator orderByComparator) throws SystemException {
2672 FinderPath finderPath = null;
2673 Object[] finderArgs = null;
2674
2675 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2676 (orderByComparator == null)) {
2677 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_VOCABULARYID;
2678 finderArgs = new Object[] { vocabularyId };
2679 }
2680 else {
2681 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_VOCABULARYID;
2682 finderArgs = new Object[] {
2683 vocabularyId,
2684
2685 start, end, orderByComparator
2686 };
2687 }
2688
2689 List<AssetCategory> list = (List<AssetCategory>)FinderCacheUtil.getResult(finderPath,
2690 finderArgs, this);
2691
2692 if ((list != null) && !list.isEmpty()) {
2693 for (AssetCategory assetCategory : list) {
2694 if ((vocabularyId != assetCategory.getVocabularyId())) {
2695 list = null;
2696
2697 break;
2698 }
2699 }
2700 }
2701
2702 if (list == null) {
2703 StringBundler query = null;
2704
2705 if (orderByComparator != null) {
2706 query = new StringBundler(3 +
2707 (orderByComparator.getOrderByFields().length * 3));
2708 }
2709 else {
2710 query = new StringBundler(3);
2711 }
2712
2713 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
2714
2715 query.append(_FINDER_COLUMN_VOCABULARYID_VOCABULARYID_2);
2716
2717 if (orderByComparator != null) {
2718 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2719 orderByComparator);
2720 }
2721
2722 else {
2723 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
2724 }
2725
2726 String sql = query.toString();
2727
2728 Session session = null;
2729
2730 try {
2731 session = openSession();
2732
2733 Query q = session.createQuery(sql);
2734
2735 QueryPos qPos = QueryPos.getInstance(q);
2736
2737 qPos.add(vocabularyId);
2738
2739 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
2740 start, end);
2741 }
2742 catch (Exception e) {
2743 throw processException(e);
2744 }
2745 finally {
2746 if (list == null) {
2747 FinderCacheUtil.removeResult(finderPath, finderArgs);
2748 }
2749 else {
2750 cacheResult(list);
2751
2752 FinderCacheUtil.putResult(finderPath, finderArgs, list);
2753 }
2754
2755 closeSession(session);
2756 }
2757 }
2758
2759 return list;
2760 }
2761
2762
2771 public AssetCategory findByVocabularyId_First(long vocabularyId,
2772 OrderByComparator orderByComparator)
2773 throws NoSuchCategoryException, SystemException {
2774 AssetCategory assetCategory = fetchByVocabularyId_First(vocabularyId,
2775 orderByComparator);
2776
2777 if (assetCategory != null) {
2778 return assetCategory;
2779 }
2780
2781 StringBundler msg = new StringBundler(4);
2782
2783 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2784
2785 msg.append("vocabularyId=");
2786 msg.append(vocabularyId);
2787
2788 msg.append(StringPool.CLOSE_CURLY_BRACE);
2789
2790 throw new NoSuchCategoryException(msg.toString());
2791 }
2792
2793
2801 public AssetCategory fetchByVocabularyId_First(long vocabularyId,
2802 OrderByComparator orderByComparator) throws SystemException {
2803 List<AssetCategory> list = findByVocabularyId(vocabularyId, 0, 1,
2804 orderByComparator);
2805
2806 if (!list.isEmpty()) {
2807 return list.get(0);
2808 }
2809
2810 return null;
2811 }
2812
2813
2822 public AssetCategory findByVocabularyId_Last(long vocabularyId,
2823 OrderByComparator orderByComparator)
2824 throws NoSuchCategoryException, SystemException {
2825 AssetCategory assetCategory = fetchByVocabularyId_Last(vocabularyId,
2826 orderByComparator);
2827
2828 if (assetCategory != null) {
2829 return assetCategory;
2830 }
2831
2832 StringBundler msg = new StringBundler(4);
2833
2834 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2835
2836 msg.append("vocabularyId=");
2837 msg.append(vocabularyId);
2838
2839 msg.append(StringPool.CLOSE_CURLY_BRACE);
2840
2841 throw new NoSuchCategoryException(msg.toString());
2842 }
2843
2844
2852 public AssetCategory fetchByVocabularyId_Last(long vocabularyId,
2853 OrderByComparator orderByComparator) throws SystemException {
2854 int count = countByVocabularyId(vocabularyId);
2855
2856 List<AssetCategory> list = findByVocabularyId(vocabularyId, count - 1,
2857 count, orderByComparator);
2858
2859 if (!list.isEmpty()) {
2860 return list.get(0);
2861 }
2862
2863 return null;
2864 }
2865
2866
2876 public AssetCategory[] findByVocabularyId_PrevAndNext(long categoryId,
2877 long vocabularyId, OrderByComparator orderByComparator)
2878 throws NoSuchCategoryException, SystemException {
2879 AssetCategory assetCategory = findByPrimaryKey(categoryId);
2880
2881 Session session = null;
2882
2883 try {
2884 session = openSession();
2885
2886 AssetCategory[] array = new AssetCategoryImpl[3];
2887
2888 array[0] = getByVocabularyId_PrevAndNext(session, assetCategory,
2889 vocabularyId, orderByComparator, true);
2890
2891 array[1] = assetCategory;
2892
2893 array[2] = getByVocabularyId_PrevAndNext(session, assetCategory,
2894 vocabularyId, orderByComparator, false);
2895
2896 return array;
2897 }
2898 catch (Exception e) {
2899 throw processException(e);
2900 }
2901 finally {
2902 closeSession(session);
2903 }
2904 }
2905
2906 protected AssetCategory getByVocabularyId_PrevAndNext(Session session,
2907 AssetCategory assetCategory, long vocabularyId,
2908 OrderByComparator orderByComparator, boolean previous) {
2909 StringBundler query = null;
2910
2911 if (orderByComparator != null) {
2912 query = new StringBundler(6 +
2913 (orderByComparator.getOrderByFields().length * 6));
2914 }
2915 else {
2916 query = new StringBundler(3);
2917 }
2918
2919 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
2920
2921 query.append(_FINDER_COLUMN_VOCABULARYID_VOCABULARYID_2);
2922
2923 if (orderByComparator != null) {
2924 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2925
2926 if (orderByConditionFields.length > 0) {
2927 query.append(WHERE_AND);
2928 }
2929
2930 for (int i = 0; i < orderByConditionFields.length; i++) {
2931 query.append(_ORDER_BY_ENTITY_ALIAS);
2932 query.append(orderByConditionFields[i]);
2933
2934 if ((i + 1) < orderByConditionFields.length) {
2935 if (orderByComparator.isAscending() ^ previous) {
2936 query.append(WHERE_GREATER_THAN_HAS_NEXT);
2937 }
2938 else {
2939 query.append(WHERE_LESSER_THAN_HAS_NEXT);
2940 }
2941 }
2942 else {
2943 if (orderByComparator.isAscending() ^ previous) {
2944 query.append(WHERE_GREATER_THAN);
2945 }
2946 else {
2947 query.append(WHERE_LESSER_THAN);
2948 }
2949 }
2950 }
2951
2952 query.append(ORDER_BY_CLAUSE);
2953
2954 String[] orderByFields = orderByComparator.getOrderByFields();
2955
2956 for (int i = 0; i < orderByFields.length; i++) {
2957 query.append(_ORDER_BY_ENTITY_ALIAS);
2958 query.append(orderByFields[i]);
2959
2960 if ((i + 1) < orderByFields.length) {
2961 if (orderByComparator.isAscending() ^ previous) {
2962 query.append(ORDER_BY_ASC_HAS_NEXT);
2963 }
2964 else {
2965 query.append(ORDER_BY_DESC_HAS_NEXT);
2966 }
2967 }
2968 else {
2969 if (orderByComparator.isAscending() ^ previous) {
2970 query.append(ORDER_BY_ASC);
2971 }
2972 else {
2973 query.append(ORDER_BY_DESC);
2974 }
2975 }
2976 }
2977 }
2978
2979 else {
2980 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
2981 }
2982
2983 String sql = query.toString();
2984
2985 Query q = session.createQuery(sql);
2986
2987 q.setFirstResult(0);
2988 q.setMaxResults(2);
2989
2990 QueryPos qPos = QueryPos.getInstance(q);
2991
2992 qPos.add(vocabularyId);
2993
2994 if (orderByComparator != null) {
2995 Object[] values = orderByComparator.getOrderByConditionValues(assetCategory);
2996
2997 for (Object value : values) {
2998 qPos.add(value);
2999 }
3000 }
3001
3002 List<AssetCategory> list = q.list();
3003
3004 if (list.size() == 2) {
3005 return list.get(1);
3006 }
3007 else {
3008 return null;
3009 }
3010 }
3011
3012
3020 public List<AssetCategory> findByG_V(long groupId, long vocabularyId)
3021 throws SystemException {
3022 return findByG_V(groupId, vocabularyId, QueryUtil.ALL_POS,
3023 QueryUtil.ALL_POS, null);
3024 }
3025
3026
3040 public List<AssetCategory> findByG_V(long groupId, long vocabularyId,
3041 int start, int end) throws SystemException {
3042 return findByG_V(groupId, vocabularyId, start, end, null);
3043 }
3044
3045
3060 public List<AssetCategory> findByG_V(long groupId, long vocabularyId,
3061 int start, int end, OrderByComparator orderByComparator)
3062 throws SystemException {
3063 FinderPath finderPath = null;
3064 Object[] finderArgs = null;
3065
3066 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
3067 (orderByComparator == null)) {
3068 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_V;
3069 finderArgs = new Object[] { groupId, vocabularyId };
3070 }
3071 else {
3072 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_V;
3073 finderArgs = new Object[] {
3074 groupId, vocabularyId,
3075
3076 start, end, orderByComparator
3077 };
3078 }
3079
3080 List<AssetCategory> list = (List<AssetCategory>)FinderCacheUtil.getResult(finderPath,
3081 finderArgs, this);
3082
3083 if ((list != null) && !list.isEmpty()) {
3084 for (AssetCategory assetCategory : list) {
3085 if ((groupId != assetCategory.getGroupId()) ||
3086 (vocabularyId != assetCategory.getVocabularyId())) {
3087 list = null;
3088
3089 break;
3090 }
3091 }
3092 }
3093
3094 if (list == null) {
3095 StringBundler query = null;
3096
3097 if (orderByComparator != null) {
3098 query = new StringBundler(4 +
3099 (orderByComparator.getOrderByFields().length * 3));
3100 }
3101 else {
3102 query = new StringBundler(4);
3103 }
3104
3105 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
3106
3107 query.append(_FINDER_COLUMN_G_V_GROUPID_2);
3108
3109 query.append(_FINDER_COLUMN_G_V_VOCABULARYID_2);
3110
3111 if (orderByComparator != null) {
3112 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3113 orderByComparator);
3114 }
3115
3116 else {
3117 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
3118 }
3119
3120 String sql = query.toString();
3121
3122 Session session = null;
3123
3124 try {
3125 session = openSession();
3126
3127 Query q = session.createQuery(sql);
3128
3129 QueryPos qPos = QueryPos.getInstance(q);
3130
3131 qPos.add(groupId);
3132
3133 qPos.add(vocabularyId);
3134
3135 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
3136 start, end);
3137 }
3138 catch (Exception e) {
3139 throw processException(e);
3140 }
3141 finally {
3142 if (list == null) {
3143 FinderCacheUtil.removeResult(finderPath, finderArgs);
3144 }
3145 else {
3146 cacheResult(list);
3147
3148 FinderCacheUtil.putResult(finderPath, finderArgs, list);
3149 }
3150
3151 closeSession(session);
3152 }
3153 }
3154
3155 return list;
3156 }
3157
3158
3168 public AssetCategory findByG_V_First(long groupId, long vocabularyId,
3169 OrderByComparator orderByComparator)
3170 throws NoSuchCategoryException, SystemException {
3171 AssetCategory assetCategory = fetchByG_V_First(groupId, vocabularyId,
3172 orderByComparator);
3173
3174 if (assetCategory != null) {
3175 return assetCategory;
3176 }
3177
3178 StringBundler msg = new StringBundler(6);
3179
3180 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3181
3182 msg.append("groupId=");
3183 msg.append(groupId);
3184
3185 msg.append(", vocabularyId=");
3186 msg.append(vocabularyId);
3187
3188 msg.append(StringPool.CLOSE_CURLY_BRACE);
3189
3190 throw new NoSuchCategoryException(msg.toString());
3191 }
3192
3193
3202 public AssetCategory fetchByG_V_First(long groupId, long vocabularyId,
3203 OrderByComparator orderByComparator) throws SystemException {
3204 List<AssetCategory> list = findByG_V(groupId, vocabularyId, 0, 1,
3205 orderByComparator);
3206
3207 if (!list.isEmpty()) {
3208 return list.get(0);
3209 }
3210
3211 return null;
3212 }
3213
3214
3224 public AssetCategory findByG_V_Last(long groupId, long vocabularyId,
3225 OrderByComparator orderByComparator)
3226 throws NoSuchCategoryException, SystemException {
3227 AssetCategory assetCategory = fetchByG_V_Last(groupId, vocabularyId,
3228 orderByComparator);
3229
3230 if (assetCategory != null) {
3231 return assetCategory;
3232 }
3233
3234 StringBundler msg = new StringBundler(6);
3235
3236 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3237
3238 msg.append("groupId=");
3239 msg.append(groupId);
3240
3241 msg.append(", vocabularyId=");
3242 msg.append(vocabularyId);
3243
3244 msg.append(StringPool.CLOSE_CURLY_BRACE);
3245
3246 throw new NoSuchCategoryException(msg.toString());
3247 }
3248
3249
3258 public AssetCategory fetchByG_V_Last(long groupId, long vocabularyId,
3259 OrderByComparator orderByComparator) throws SystemException {
3260 int count = countByG_V(groupId, vocabularyId);
3261
3262 List<AssetCategory> list = findByG_V(groupId, vocabularyId, count - 1,
3263 count, orderByComparator);
3264
3265 if (!list.isEmpty()) {
3266 return list.get(0);
3267 }
3268
3269 return null;
3270 }
3271
3272
3283 public AssetCategory[] findByG_V_PrevAndNext(long categoryId, long groupId,
3284 long vocabularyId, OrderByComparator orderByComparator)
3285 throws NoSuchCategoryException, SystemException {
3286 AssetCategory assetCategory = findByPrimaryKey(categoryId);
3287
3288 Session session = null;
3289
3290 try {
3291 session = openSession();
3292
3293 AssetCategory[] array = new AssetCategoryImpl[3];
3294
3295 array[0] = getByG_V_PrevAndNext(session, assetCategory, groupId,
3296 vocabularyId, orderByComparator, true);
3297
3298 array[1] = assetCategory;
3299
3300 array[2] = getByG_V_PrevAndNext(session, assetCategory, groupId,
3301 vocabularyId, orderByComparator, false);
3302
3303 return array;
3304 }
3305 catch (Exception e) {
3306 throw processException(e);
3307 }
3308 finally {
3309 closeSession(session);
3310 }
3311 }
3312
3313 protected AssetCategory getByG_V_PrevAndNext(Session session,
3314 AssetCategory assetCategory, long groupId, long vocabularyId,
3315 OrderByComparator orderByComparator, boolean previous) {
3316 StringBundler query = null;
3317
3318 if (orderByComparator != null) {
3319 query = new StringBundler(6 +
3320 (orderByComparator.getOrderByFields().length * 6));
3321 }
3322 else {
3323 query = new StringBundler(3);
3324 }
3325
3326 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
3327
3328 query.append(_FINDER_COLUMN_G_V_GROUPID_2);
3329
3330 query.append(_FINDER_COLUMN_G_V_VOCABULARYID_2);
3331
3332 if (orderByComparator != null) {
3333 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3334
3335 if (orderByConditionFields.length > 0) {
3336 query.append(WHERE_AND);
3337 }
3338
3339 for (int i = 0; i < orderByConditionFields.length; i++) {
3340 query.append(_ORDER_BY_ENTITY_ALIAS);
3341 query.append(orderByConditionFields[i]);
3342
3343 if ((i + 1) < orderByConditionFields.length) {
3344 if (orderByComparator.isAscending() ^ previous) {
3345 query.append(WHERE_GREATER_THAN_HAS_NEXT);
3346 }
3347 else {
3348 query.append(WHERE_LESSER_THAN_HAS_NEXT);
3349 }
3350 }
3351 else {
3352 if (orderByComparator.isAscending() ^ previous) {
3353 query.append(WHERE_GREATER_THAN);
3354 }
3355 else {
3356 query.append(WHERE_LESSER_THAN);
3357 }
3358 }
3359 }
3360
3361 query.append(ORDER_BY_CLAUSE);
3362
3363 String[] orderByFields = orderByComparator.getOrderByFields();
3364
3365 for (int i = 0; i < orderByFields.length; i++) {
3366 query.append(_ORDER_BY_ENTITY_ALIAS);
3367 query.append(orderByFields[i]);
3368
3369 if ((i + 1) < orderByFields.length) {
3370 if (orderByComparator.isAscending() ^ previous) {
3371 query.append(ORDER_BY_ASC_HAS_NEXT);
3372 }
3373 else {
3374 query.append(ORDER_BY_DESC_HAS_NEXT);
3375 }
3376 }
3377 else {
3378 if (orderByComparator.isAscending() ^ previous) {
3379 query.append(ORDER_BY_ASC);
3380 }
3381 else {
3382 query.append(ORDER_BY_DESC);
3383 }
3384 }
3385 }
3386 }
3387
3388 else {
3389 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
3390 }
3391
3392 String sql = query.toString();
3393
3394 Query q = session.createQuery(sql);
3395
3396 q.setFirstResult(0);
3397 q.setMaxResults(2);
3398
3399 QueryPos qPos = QueryPos.getInstance(q);
3400
3401 qPos.add(groupId);
3402
3403 qPos.add(vocabularyId);
3404
3405 if (orderByComparator != null) {
3406 Object[] values = orderByComparator.getOrderByConditionValues(assetCategory);
3407
3408 for (Object value : values) {
3409 qPos.add(value);
3410 }
3411 }
3412
3413 List<AssetCategory> list = q.list();
3414
3415 if (list.size() == 2) {
3416 return list.get(1);
3417 }
3418 else {
3419 return null;
3420 }
3421 }
3422
3423
3431 public List<AssetCategory> filterFindByG_V(long groupId, long vocabularyId)
3432 throws SystemException {
3433 return filterFindByG_V(groupId, vocabularyId, QueryUtil.ALL_POS,
3434 QueryUtil.ALL_POS, null);
3435 }
3436
3437
3451 public List<AssetCategory> filterFindByG_V(long groupId, long vocabularyId,
3452 int start, int end) throws SystemException {
3453 return filterFindByG_V(groupId, vocabularyId, start, end, null);
3454 }
3455
3456
3471 public List<AssetCategory> filterFindByG_V(long groupId, long vocabularyId,
3472 int start, int end, OrderByComparator orderByComparator)
3473 throws SystemException {
3474 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
3475 return findByG_V(groupId, vocabularyId, start, end,
3476 orderByComparator);
3477 }
3478
3479 StringBundler query = null;
3480
3481 if (orderByComparator != null) {
3482 query = new StringBundler(4 +
3483 (orderByComparator.getOrderByFields().length * 3));
3484 }
3485 else {
3486 query = new StringBundler(4);
3487 }
3488
3489 if (getDB().isSupportsInlineDistinct()) {
3490 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_WHERE);
3491 }
3492 else {
3493 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_1);
3494 }
3495
3496 query.append(_FINDER_COLUMN_G_V_GROUPID_2);
3497
3498 query.append(_FINDER_COLUMN_G_V_VOCABULARYID_2);
3499
3500 if (!getDB().isSupportsInlineDistinct()) {
3501 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_2);
3502 }
3503
3504 if (orderByComparator != null) {
3505 if (getDB().isSupportsInlineDistinct()) {
3506 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3507 orderByComparator);
3508 }
3509 else {
3510 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
3511 orderByComparator);
3512 }
3513 }
3514
3515 else {
3516 if (getDB().isSupportsInlineDistinct()) {
3517 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
3518 }
3519 else {
3520 query.append(AssetCategoryModelImpl.ORDER_BY_SQL);
3521 }
3522 }
3523
3524 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
3525 AssetCategory.class.getName(),
3526 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
3527
3528 Session session = null;
3529
3530 try {
3531 session = openSession();
3532
3533 SQLQuery q = session.createSQLQuery(sql);
3534
3535 if (getDB().isSupportsInlineDistinct()) {
3536 q.addEntity(_FILTER_ENTITY_ALIAS, AssetCategoryImpl.class);
3537 }
3538 else {
3539 q.addEntity(_FILTER_ENTITY_TABLE, AssetCategoryImpl.class);
3540 }
3541
3542 QueryPos qPos = QueryPos.getInstance(q);
3543
3544 qPos.add(groupId);
3545
3546 qPos.add(vocabularyId);
3547
3548 return (List<AssetCategory>)QueryUtil.list(q, getDialect(), start,
3549 end);
3550 }
3551 catch (Exception e) {
3552 throw processException(e);
3553 }
3554 finally {
3555 closeSession(session);
3556 }
3557 }
3558
3559
3570 public AssetCategory[] filterFindByG_V_PrevAndNext(long categoryId,
3571 long groupId, long vocabularyId, OrderByComparator orderByComparator)
3572 throws NoSuchCategoryException, SystemException {
3573 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
3574 return findByG_V_PrevAndNext(categoryId, groupId, vocabularyId,
3575 orderByComparator);
3576 }
3577
3578 AssetCategory assetCategory = findByPrimaryKey(categoryId);
3579
3580 Session session = null;
3581
3582 try {
3583 session = openSession();
3584
3585 AssetCategory[] array = new AssetCategoryImpl[3];
3586
3587 array[0] = filterGetByG_V_PrevAndNext(session, assetCategory,
3588 groupId, vocabularyId, orderByComparator, true);
3589
3590 array[1] = assetCategory;
3591
3592 array[2] = filterGetByG_V_PrevAndNext(session, assetCategory,
3593 groupId, vocabularyId, orderByComparator, false);
3594
3595 return array;
3596 }
3597 catch (Exception e) {
3598 throw processException(e);
3599 }
3600 finally {
3601 closeSession(session);
3602 }
3603 }
3604
3605 protected AssetCategory filterGetByG_V_PrevAndNext(Session session,
3606 AssetCategory assetCategory, long groupId, long vocabularyId,
3607 OrderByComparator orderByComparator, boolean previous) {
3608 StringBundler query = null;
3609
3610 if (orderByComparator != null) {
3611 query = new StringBundler(6 +
3612 (orderByComparator.getOrderByFields().length * 6));
3613 }
3614 else {
3615 query = new StringBundler(3);
3616 }
3617
3618 if (getDB().isSupportsInlineDistinct()) {
3619 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_WHERE);
3620 }
3621 else {
3622 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_1);
3623 }
3624
3625 query.append(_FINDER_COLUMN_G_V_GROUPID_2);
3626
3627 query.append(_FINDER_COLUMN_G_V_VOCABULARYID_2);
3628
3629 if (!getDB().isSupportsInlineDistinct()) {
3630 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_2);
3631 }
3632
3633 if (orderByComparator != null) {
3634 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3635
3636 if (orderByConditionFields.length > 0) {
3637 query.append(WHERE_AND);
3638 }
3639
3640 for (int i = 0; i < orderByConditionFields.length; i++) {
3641 if (getDB().isSupportsInlineDistinct()) {
3642 query.append(_ORDER_BY_ENTITY_ALIAS);
3643 }
3644 else {
3645 query.append(_ORDER_BY_ENTITY_TABLE);
3646 }
3647
3648 query.append(orderByConditionFields[i]);
3649
3650 if ((i + 1) < orderByConditionFields.length) {
3651 if (orderByComparator.isAscending() ^ previous) {
3652 query.append(WHERE_GREATER_THAN_HAS_NEXT);
3653 }
3654 else {
3655 query.append(WHERE_LESSER_THAN_HAS_NEXT);
3656 }
3657 }
3658 else {
3659 if (orderByComparator.isAscending() ^ previous) {
3660 query.append(WHERE_GREATER_THAN);
3661 }
3662 else {
3663 query.append(WHERE_LESSER_THAN);
3664 }
3665 }
3666 }
3667
3668 query.append(ORDER_BY_CLAUSE);
3669
3670 String[] orderByFields = orderByComparator.getOrderByFields();
3671
3672 for (int i = 0; i < orderByFields.length; i++) {
3673 if (getDB().isSupportsInlineDistinct()) {
3674 query.append(_ORDER_BY_ENTITY_ALIAS);
3675 }
3676 else {
3677 query.append(_ORDER_BY_ENTITY_TABLE);
3678 }
3679
3680 query.append(orderByFields[i]);
3681
3682 if ((i + 1) < orderByFields.length) {
3683 if (orderByComparator.isAscending() ^ previous) {
3684 query.append(ORDER_BY_ASC_HAS_NEXT);
3685 }
3686 else {
3687 query.append(ORDER_BY_DESC_HAS_NEXT);
3688 }
3689 }
3690 else {
3691 if (orderByComparator.isAscending() ^ previous) {
3692 query.append(ORDER_BY_ASC);
3693 }
3694 else {
3695 query.append(ORDER_BY_DESC);
3696 }
3697 }
3698 }
3699 }
3700
3701 else {
3702 if (getDB().isSupportsInlineDistinct()) {
3703 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
3704 }
3705 else {
3706 query.append(AssetCategoryModelImpl.ORDER_BY_SQL);
3707 }
3708 }
3709
3710 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
3711 AssetCategory.class.getName(),
3712 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
3713
3714 SQLQuery q = session.createSQLQuery(sql);
3715
3716 q.setFirstResult(0);
3717 q.setMaxResults(2);
3718
3719 if (getDB().isSupportsInlineDistinct()) {
3720 q.addEntity(_FILTER_ENTITY_ALIAS, AssetCategoryImpl.class);
3721 }
3722 else {
3723 q.addEntity(_FILTER_ENTITY_TABLE, AssetCategoryImpl.class);
3724 }
3725
3726 QueryPos qPos = QueryPos.getInstance(q);
3727
3728 qPos.add(groupId);
3729
3730 qPos.add(vocabularyId);
3731
3732 if (orderByComparator != null) {
3733 Object[] values = orderByComparator.getOrderByConditionValues(assetCategory);
3734
3735 for (Object value : values) {
3736 qPos.add(value);
3737 }
3738 }
3739
3740 List<AssetCategory> list = q.list();
3741
3742 if (list.size() == 2) {
3743 return list.get(1);
3744 }
3745 else {
3746 return null;
3747 }
3748 }
3749
3750
3758 public List<AssetCategory> findByP_N(long parentCategoryId, String name)
3759 throws SystemException {
3760 return findByP_N(parentCategoryId, name, QueryUtil.ALL_POS,
3761 QueryUtil.ALL_POS, null);
3762 }
3763
3764
3778 public List<AssetCategory> findByP_N(long parentCategoryId, String name,
3779 int start, int end) throws SystemException {
3780 return findByP_N(parentCategoryId, name, start, end, null);
3781 }
3782
3783
3798 public List<AssetCategory> findByP_N(long parentCategoryId, String name,
3799 int start, int end, OrderByComparator orderByComparator)
3800 throws SystemException {
3801 FinderPath finderPath = null;
3802 Object[] finderArgs = null;
3803
3804 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
3805 (orderByComparator == null)) {
3806 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_P_N;
3807 finderArgs = new Object[] { parentCategoryId, name };
3808 }
3809 else {
3810 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_P_N;
3811 finderArgs = new Object[] {
3812 parentCategoryId, name,
3813
3814 start, end, orderByComparator
3815 };
3816 }
3817
3818 List<AssetCategory> list = (List<AssetCategory>)FinderCacheUtil.getResult(finderPath,
3819 finderArgs, this);
3820
3821 if ((list != null) && !list.isEmpty()) {
3822 for (AssetCategory assetCategory : list) {
3823 if ((parentCategoryId != assetCategory.getParentCategoryId()) ||
3824 !Validator.equals(name, assetCategory.getName())) {
3825 list = null;
3826
3827 break;
3828 }
3829 }
3830 }
3831
3832 if (list == null) {
3833 StringBundler query = null;
3834
3835 if (orderByComparator != null) {
3836 query = new StringBundler(4 +
3837 (orderByComparator.getOrderByFields().length * 3));
3838 }
3839 else {
3840 query = new StringBundler(4);
3841 }
3842
3843 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
3844
3845 query.append(_FINDER_COLUMN_P_N_PARENTCATEGORYID_2);
3846
3847 if (name == null) {
3848 query.append(_FINDER_COLUMN_P_N_NAME_1);
3849 }
3850 else {
3851 if (name.equals(StringPool.BLANK)) {
3852 query.append(_FINDER_COLUMN_P_N_NAME_3);
3853 }
3854 else {
3855 query.append(_FINDER_COLUMN_P_N_NAME_2);
3856 }
3857 }
3858
3859 if (orderByComparator != null) {
3860 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3861 orderByComparator);
3862 }
3863
3864 else {
3865 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
3866 }
3867
3868 String sql = query.toString();
3869
3870 Session session = null;
3871
3872 try {
3873 session = openSession();
3874
3875 Query q = session.createQuery(sql);
3876
3877 QueryPos qPos = QueryPos.getInstance(q);
3878
3879 qPos.add(parentCategoryId);
3880
3881 if (name != null) {
3882 qPos.add(name);
3883 }
3884
3885 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
3886 start, end);
3887 }
3888 catch (Exception e) {
3889 throw processException(e);
3890 }
3891 finally {
3892 if (list == null) {
3893 FinderCacheUtil.removeResult(finderPath, finderArgs);
3894 }
3895 else {
3896 cacheResult(list);
3897
3898 FinderCacheUtil.putResult(finderPath, finderArgs, list);
3899 }
3900
3901 closeSession(session);
3902 }
3903 }
3904
3905 return list;
3906 }
3907
3908
3918 public AssetCategory findByP_N_First(long parentCategoryId, String name,
3919 OrderByComparator orderByComparator)
3920 throws NoSuchCategoryException, SystemException {
3921 AssetCategory assetCategory = fetchByP_N_First(parentCategoryId, name,
3922 orderByComparator);
3923
3924 if (assetCategory != null) {
3925 return assetCategory;
3926 }
3927
3928 StringBundler msg = new StringBundler(6);
3929
3930 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3931
3932 msg.append("parentCategoryId=");
3933 msg.append(parentCategoryId);
3934
3935 msg.append(", name=");
3936 msg.append(name);
3937
3938 msg.append(StringPool.CLOSE_CURLY_BRACE);
3939
3940 throw new NoSuchCategoryException(msg.toString());
3941 }
3942
3943
3952 public AssetCategory fetchByP_N_First(long parentCategoryId, String name,
3953 OrderByComparator orderByComparator) throws SystemException {
3954 List<AssetCategory> list = findByP_N(parentCategoryId, name, 0, 1,
3955 orderByComparator);
3956
3957 if (!list.isEmpty()) {
3958 return list.get(0);
3959 }
3960
3961 return null;
3962 }
3963
3964
3974 public AssetCategory findByP_N_Last(long parentCategoryId, String name,
3975 OrderByComparator orderByComparator)
3976 throws NoSuchCategoryException, SystemException {
3977 AssetCategory assetCategory = fetchByP_N_Last(parentCategoryId, name,
3978 orderByComparator);
3979
3980 if (assetCategory != null) {
3981 return assetCategory;
3982 }
3983
3984 StringBundler msg = new StringBundler(6);
3985
3986 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3987
3988 msg.append("parentCategoryId=");
3989 msg.append(parentCategoryId);
3990
3991 msg.append(", name=");
3992 msg.append(name);
3993
3994 msg.append(StringPool.CLOSE_CURLY_BRACE);
3995
3996 throw new NoSuchCategoryException(msg.toString());
3997 }
3998
3999
4008 public AssetCategory fetchByP_N_Last(long parentCategoryId, String name,
4009 OrderByComparator orderByComparator) throws SystemException {
4010 int count = countByP_N(parentCategoryId, name);
4011
4012 List<AssetCategory> list = findByP_N(parentCategoryId, name, count - 1,
4013 count, orderByComparator);
4014
4015 if (!list.isEmpty()) {
4016 return list.get(0);
4017 }
4018
4019 return null;
4020 }
4021
4022
4033 public AssetCategory[] findByP_N_PrevAndNext(long categoryId,
4034 long parentCategoryId, String name, OrderByComparator orderByComparator)
4035 throws NoSuchCategoryException, SystemException {
4036 AssetCategory assetCategory = findByPrimaryKey(categoryId);
4037
4038 Session session = null;
4039
4040 try {
4041 session = openSession();
4042
4043 AssetCategory[] array = new AssetCategoryImpl[3];
4044
4045 array[0] = getByP_N_PrevAndNext(session, assetCategory,
4046 parentCategoryId, name, orderByComparator, true);
4047
4048 array[1] = assetCategory;
4049
4050 array[2] = getByP_N_PrevAndNext(session, assetCategory,
4051 parentCategoryId, name, orderByComparator, false);
4052
4053 return array;
4054 }
4055 catch (Exception e) {
4056 throw processException(e);
4057 }
4058 finally {
4059 closeSession(session);
4060 }
4061 }
4062
4063 protected AssetCategory getByP_N_PrevAndNext(Session session,
4064 AssetCategory assetCategory, long parentCategoryId, String name,
4065 OrderByComparator orderByComparator, boolean previous) {
4066 StringBundler query = null;
4067
4068 if (orderByComparator != null) {
4069 query = new StringBundler(6 +
4070 (orderByComparator.getOrderByFields().length * 6));
4071 }
4072 else {
4073 query = new StringBundler(3);
4074 }
4075
4076 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
4077
4078 query.append(_FINDER_COLUMN_P_N_PARENTCATEGORYID_2);
4079
4080 if (name == null) {
4081 query.append(_FINDER_COLUMN_P_N_NAME_1);
4082 }
4083 else {
4084 if (name.equals(StringPool.BLANK)) {
4085 query.append(_FINDER_COLUMN_P_N_NAME_3);
4086 }
4087 else {
4088 query.append(_FINDER_COLUMN_P_N_NAME_2);
4089 }
4090 }
4091
4092 if (orderByComparator != null) {
4093 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
4094
4095 if (orderByConditionFields.length > 0) {
4096 query.append(WHERE_AND);
4097 }
4098
4099 for (int i = 0; i < orderByConditionFields.length; i++) {
4100 query.append(_ORDER_BY_ENTITY_ALIAS);
4101 query.append(orderByConditionFields[i]);
4102
4103 if ((i + 1) < orderByConditionFields.length) {
4104 if (orderByComparator.isAscending() ^ previous) {
4105 query.append(WHERE_GREATER_THAN_HAS_NEXT);
4106 }
4107 else {
4108 query.append(WHERE_LESSER_THAN_HAS_NEXT);
4109 }
4110 }
4111 else {
4112 if (orderByComparator.isAscending() ^ previous) {
4113 query.append(WHERE_GREATER_THAN);
4114 }
4115 else {
4116 query.append(WHERE_LESSER_THAN);
4117 }
4118 }
4119 }
4120
4121 query.append(ORDER_BY_CLAUSE);
4122
4123 String[] orderByFields = orderByComparator.getOrderByFields();
4124
4125 for (int i = 0; i < orderByFields.length; i++) {
4126 query.append(_ORDER_BY_ENTITY_ALIAS);
4127 query.append(orderByFields[i]);
4128
4129 if ((i + 1) < orderByFields.length) {
4130 if (orderByComparator.isAscending() ^ previous) {
4131 query.append(ORDER_BY_ASC_HAS_NEXT);
4132 }
4133 else {
4134 query.append(ORDER_BY_DESC_HAS_NEXT);
4135 }
4136 }
4137 else {
4138 if (orderByComparator.isAscending() ^ previous) {
4139 query.append(ORDER_BY_ASC);
4140 }
4141 else {
4142 query.append(ORDER_BY_DESC);
4143 }
4144 }
4145 }
4146 }
4147
4148 else {
4149 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
4150 }
4151
4152 String sql = query.toString();
4153
4154 Query q = session.createQuery(sql);
4155
4156 q.setFirstResult(0);
4157 q.setMaxResults(2);
4158
4159 QueryPos qPos = QueryPos.getInstance(q);
4160
4161 qPos.add(parentCategoryId);
4162
4163 if (name != null) {
4164 qPos.add(name);
4165 }
4166
4167 if (orderByComparator != null) {
4168 Object[] values = orderByComparator.getOrderByConditionValues(assetCategory);
4169
4170 for (Object value : values) {
4171 qPos.add(value);
4172 }
4173 }
4174
4175 List<AssetCategory> list = q.list();
4176
4177 if (list.size() == 2) {
4178 return list.get(1);
4179 }
4180 else {
4181 return null;
4182 }
4183 }
4184
4185
4193 public List<AssetCategory> findByP_V(long parentCategoryId,
4194 long vocabularyId) throws SystemException {
4195 return findByP_V(parentCategoryId, vocabularyId, QueryUtil.ALL_POS,
4196 QueryUtil.ALL_POS, null);
4197 }
4198
4199
4213 public List<AssetCategory> findByP_V(long parentCategoryId,
4214 long vocabularyId, int start, int end) throws SystemException {
4215 return findByP_V(parentCategoryId, vocabularyId, start, end, null);
4216 }
4217
4218
4233 public List<AssetCategory> findByP_V(long parentCategoryId,
4234 long vocabularyId, int start, int end,
4235 OrderByComparator orderByComparator) throws SystemException {
4236 FinderPath finderPath = null;
4237 Object[] finderArgs = null;
4238
4239 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
4240 (orderByComparator == null)) {
4241 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_P_V;
4242 finderArgs = new Object[] { parentCategoryId, vocabularyId };
4243 }
4244 else {
4245 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_P_V;
4246 finderArgs = new Object[] {
4247 parentCategoryId, vocabularyId,
4248
4249 start, end, orderByComparator
4250 };
4251 }
4252
4253 List<AssetCategory> list = (List<AssetCategory>)FinderCacheUtil.getResult(finderPath,
4254 finderArgs, this);
4255
4256 if ((list != null) && !list.isEmpty()) {
4257 for (AssetCategory assetCategory : list) {
4258 if ((parentCategoryId != assetCategory.getParentCategoryId()) ||
4259 (vocabularyId != assetCategory.getVocabularyId())) {
4260 list = null;
4261
4262 break;
4263 }
4264 }
4265 }
4266
4267 if (list == null) {
4268 StringBundler query = null;
4269
4270 if (orderByComparator != null) {
4271 query = new StringBundler(4 +
4272 (orderByComparator.getOrderByFields().length * 3));
4273 }
4274 else {
4275 query = new StringBundler(4);
4276 }
4277
4278 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
4279
4280 query.append(_FINDER_COLUMN_P_V_PARENTCATEGORYID_2);
4281
4282 query.append(_FINDER_COLUMN_P_V_VOCABULARYID_2);
4283
4284 if (orderByComparator != null) {
4285 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4286 orderByComparator);
4287 }
4288
4289 else {
4290 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
4291 }
4292
4293 String sql = query.toString();
4294
4295 Session session = null;
4296
4297 try {
4298 session = openSession();
4299
4300 Query q = session.createQuery(sql);
4301
4302 QueryPos qPos = QueryPos.getInstance(q);
4303
4304 qPos.add(parentCategoryId);
4305
4306 qPos.add(vocabularyId);
4307
4308 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
4309 start, end);
4310 }
4311 catch (Exception e) {
4312 throw processException(e);
4313 }
4314 finally {
4315 if (list == null) {
4316 FinderCacheUtil.removeResult(finderPath, finderArgs);
4317 }
4318 else {
4319 cacheResult(list);
4320
4321 FinderCacheUtil.putResult(finderPath, finderArgs, list);
4322 }
4323
4324 closeSession(session);
4325 }
4326 }
4327
4328 return list;
4329 }
4330
4331
4341 public AssetCategory findByP_V_First(long parentCategoryId,
4342 long vocabularyId, OrderByComparator orderByComparator)
4343 throws NoSuchCategoryException, SystemException {
4344 AssetCategory assetCategory = fetchByP_V_First(parentCategoryId,
4345 vocabularyId, orderByComparator);
4346
4347 if (assetCategory != null) {
4348 return assetCategory;
4349 }
4350
4351 StringBundler msg = new StringBundler(6);
4352
4353 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4354
4355 msg.append("parentCategoryId=");
4356 msg.append(parentCategoryId);
4357
4358 msg.append(", vocabularyId=");
4359 msg.append(vocabularyId);
4360
4361 msg.append(StringPool.CLOSE_CURLY_BRACE);
4362
4363 throw new NoSuchCategoryException(msg.toString());
4364 }
4365
4366
4375 public AssetCategory fetchByP_V_First(long parentCategoryId,
4376 long vocabularyId, OrderByComparator orderByComparator)
4377 throws SystemException {
4378 List<AssetCategory> list = findByP_V(parentCategoryId, vocabularyId, 0,
4379 1, orderByComparator);
4380
4381 if (!list.isEmpty()) {
4382 return list.get(0);
4383 }
4384
4385 return null;
4386 }
4387
4388
4398 public AssetCategory findByP_V_Last(long parentCategoryId,
4399 long vocabularyId, OrderByComparator orderByComparator)
4400 throws NoSuchCategoryException, SystemException {
4401 AssetCategory assetCategory = fetchByP_V_Last(parentCategoryId,
4402 vocabularyId, orderByComparator);
4403
4404 if (assetCategory != null) {
4405 return assetCategory;
4406 }
4407
4408 StringBundler msg = new StringBundler(6);
4409
4410 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4411
4412 msg.append("parentCategoryId=");
4413 msg.append(parentCategoryId);
4414
4415 msg.append(", vocabularyId=");
4416 msg.append(vocabularyId);
4417
4418 msg.append(StringPool.CLOSE_CURLY_BRACE);
4419
4420 throw new NoSuchCategoryException(msg.toString());
4421 }
4422
4423
4432 public AssetCategory fetchByP_V_Last(long parentCategoryId,
4433 long vocabularyId, OrderByComparator orderByComparator)
4434 throws SystemException {
4435 int count = countByP_V(parentCategoryId, vocabularyId);
4436
4437 List<AssetCategory> list = findByP_V(parentCategoryId, vocabularyId,
4438 count - 1, count, orderByComparator);
4439
4440 if (!list.isEmpty()) {
4441 return list.get(0);
4442 }
4443
4444 return null;
4445 }
4446
4447
4458 public AssetCategory[] findByP_V_PrevAndNext(long categoryId,
4459 long parentCategoryId, long vocabularyId,
4460 OrderByComparator orderByComparator)
4461 throws NoSuchCategoryException, SystemException {
4462 AssetCategory assetCategory = findByPrimaryKey(categoryId);
4463
4464 Session session = null;
4465
4466 try {
4467 session = openSession();
4468
4469 AssetCategory[] array = new AssetCategoryImpl[3];
4470
4471 array[0] = getByP_V_PrevAndNext(session, assetCategory,
4472 parentCategoryId, vocabularyId, orderByComparator, true);
4473
4474 array[1] = assetCategory;
4475
4476 array[2] = getByP_V_PrevAndNext(session, assetCategory,
4477 parentCategoryId, vocabularyId, orderByComparator, false);
4478
4479 return array;
4480 }
4481 catch (Exception e) {
4482 throw processException(e);
4483 }
4484 finally {
4485 closeSession(session);
4486 }
4487 }
4488
4489 protected AssetCategory getByP_V_PrevAndNext(Session session,
4490 AssetCategory assetCategory, long parentCategoryId, long vocabularyId,
4491 OrderByComparator orderByComparator, boolean previous) {
4492 StringBundler query = null;
4493
4494 if (orderByComparator != null) {
4495 query = new StringBundler(6 +
4496 (orderByComparator.getOrderByFields().length * 6));
4497 }
4498 else {
4499 query = new StringBundler(3);
4500 }
4501
4502 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
4503
4504 query.append(_FINDER_COLUMN_P_V_PARENTCATEGORYID_2);
4505
4506 query.append(_FINDER_COLUMN_P_V_VOCABULARYID_2);
4507
4508 if (orderByComparator != null) {
4509 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
4510
4511 if (orderByConditionFields.length > 0) {
4512 query.append(WHERE_AND);
4513 }
4514
4515 for (int i = 0; i < orderByConditionFields.length; i++) {
4516 query.append(_ORDER_BY_ENTITY_ALIAS);
4517 query.append(orderByConditionFields[i]);
4518
4519 if ((i + 1) < orderByConditionFields.length) {
4520 if (orderByComparator.isAscending() ^ previous) {
4521 query.append(WHERE_GREATER_THAN_HAS_NEXT);
4522 }
4523 else {
4524 query.append(WHERE_LESSER_THAN_HAS_NEXT);
4525 }
4526 }
4527 else {
4528 if (orderByComparator.isAscending() ^ previous) {
4529 query.append(WHERE_GREATER_THAN);
4530 }
4531 else {
4532 query.append(WHERE_LESSER_THAN);
4533 }
4534 }
4535 }
4536
4537 query.append(ORDER_BY_CLAUSE);
4538
4539 String[] orderByFields = orderByComparator.getOrderByFields();
4540
4541 for (int i = 0; i < orderByFields.length; i++) {
4542 query.append(_ORDER_BY_ENTITY_ALIAS);
4543 query.append(orderByFields[i]);
4544
4545 if ((i + 1) < orderByFields.length) {
4546 if (orderByComparator.isAscending() ^ previous) {
4547 query.append(ORDER_BY_ASC_HAS_NEXT);
4548 }
4549 else {
4550 query.append(ORDER_BY_DESC_HAS_NEXT);
4551 }
4552 }
4553 else {
4554 if (orderByComparator.isAscending() ^ previous) {
4555 query.append(ORDER_BY_ASC);
4556 }
4557 else {
4558 query.append(ORDER_BY_DESC);
4559 }
4560 }
4561 }
4562 }
4563
4564 else {
4565 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
4566 }
4567
4568 String sql = query.toString();
4569
4570 Query q = session.createQuery(sql);
4571
4572 q.setFirstResult(0);
4573 q.setMaxResults(2);
4574
4575 QueryPos qPos = QueryPos.getInstance(q);
4576
4577 qPos.add(parentCategoryId);
4578
4579 qPos.add(vocabularyId);
4580
4581 if (orderByComparator != null) {
4582 Object[] values = orderByComparator.getOrderByConditionValues(assetCategory);
4583
4584 for (Object value : values) {
4585 qPos.add(value);
4586 }
4587 }
4588
4589 List<AssetCategory> list = q.list();
4590
4591 if (list.size() == 2) {
4592 return list.get(1);
4593 }
4594 else {
4595 return null;
4596 }
4597 }
4598
4599
4607 public List<AssetCategory> findByN_V(String name, long vocabularyId)
4608 throws SystemException {
4609 return findByN_V(name, vocabularyId, QueryUtil.ALL_POS,
4610 QueryUtil.ALL_POS, null);
4611 }
4612
4613
4627 public List<AssetCategory> findByN_V(String name, long vocabularyId,
4628 int start, int end) throws SystemException {
4629 return findByN_V(name, vocabularyId, start, end, null);
4630 }
4631
4632
4647 public List<AssetCategory> findByN_V(String name, long vocabularyId,
4648 int start, int end, OrderByComparator orderByComparator)
4649 throws SystemException {
4650 FinderPath finderPath = null;
4651 Object[] finderArgs = null;
4652
4653 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
4654 (orderByComparator == null)) {
4655 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_V;
4656 finderArgs = new Object[] { name, vocabularyId };
4657 }
4658 else {
4659 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_N_V;
4660 finderArgs = new Object[] {
4661 name, vocabularyId,
4662
4663 start, end, orderByComparator
4664 };
4665 }
4666
4667 List<AssetCategory> list = (List<AssetCategory>)FinderCacheUtil.getResult(finderPath,
4668 finderArgs, this);
4669
4670 if ((list != null) && !list.isEmpty()) {
4671 for (AssetCategory assetCategory : list) {
4672 if (!Validator.equals(name, assetCategory.getName()) ||
4673 (vocabularyId != assetCategory.getVocabularyId())) {
4674 list = null;
4675
4676 break;
4677 }
4678 }
4679 }
4680
4681 if (list == null) {
4682 StringBundler query = null;
4683
4684 if (orderByComparator != null) {
4685 query = new StringBundler(4 +
4686 (orderByComparator.getOrderByFields().length * 3));
4687 }
4688 else {
4689 query = new StringBundler(4);
4690 }
4691
4692 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
4693
4694 if (name == null) {
4695 query.append(_FINDER_COLUMN_N_V_NAME_1);
4696 }
4697 else {
4698 if (name.equals(StringPool.BLANK)) {
4699 query.append(_FINDER_COLUMN_N_V_NAME_3);
4700 }
4701 else {
4702 query.append(_FINDER_COLUMN_N_V_NAME_2);
4703 }
4704 }
4705
4706 query.append(_FINDER_COLUMN_N_V_VOCABULARYID_2);
4707
4708 if (orderByComparator != null) {
4709 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4710 orderByComparator);
4711 }
4712
4713 else {
4714 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
4715 }
4716
4717 String sql = query.toString();
4718
4719 Session session = null;
4720
4721 try {
4722 session = openSession();
4723
4724 Query q = session.createQuery(sql);
4725
4726 QueryPos qPos = QueryPos.getInstance(q);
4727
4728 if (name != null) {
4729 qPos.add(name);
4730 }
4731
4732 qPos.add(vocabularyId);
4733
4734 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
4735 start, end);
4736 }
4737 catch (Exception e) {
4738 throw processException(e);
4739 }
4740 finally {
4741 if (list == null) {
4742 FinderCacheUtil.removeResult(finderPath, finderArgs);
4743 }
4744 else {
4745 cacheResult(list);
4746
4747 FinderCacheUtil.putResult(finderPath, finderArgs, list);
4748 }
4749
4750 closeSession(session);
4751 }
4752 }
4753
4754 return list;
4755 }
4756
4757
4767 public AssetCategory findByN_V_First(String name, long vocabularyId,
4768 OrderByComparator orderByComparator)
4769 throws NoSuchCategoryException, SystemException {
4770 AssetCategory assetCategory = fetchByN_V_First(name, vocabularyId,
4771 orderByComparator);
4772
4773 if (assetCategory != null) {
4774 return assetCategory;
4775 }
4776
4777 StringBundler msg = new StringBundler(6);
4778
4779 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4780
4781 msg.append("name=");
4782 msg.append(name);
4783
4784 msg.append(", vocabularyId=");
4785 msg.append(vocabularyId);
4786
4787 msg.append(StringPool.CLOSE_CURLY_BRACE);
4788
4789 throw new NoSuchCategoryException(msg.toString());
4790 }
4791
4792
4801 public AssetCategory fetchByN_V_First(String name, long vocabularyId,
4802 OrderByComparator orderByComparator) throws SystemException {
4803 List<AssetCategory> list = findByN_V(name, vocabularyId, 0, 1,
4804 orderByComparator);
4805
4806 if (!list.isEmpty()) {
4807 return list.get(0);
4808 }
4809
4810 return null;
4811 }
4812
4813
4823 public AssetCategory findByN_V_Last(String name, long vocabularyId,
4824 OrderByComparator orderByComparator)
4825 throws NoSuchCategoryException, SystemException {
4826 AssetCategory assetCategory = fetchByN_V_Last(name, vocabularyId,
4827 orderByComparator);
4828
4829 if (assetCategory != null) {
4830 return assetCategory;
4831 }
4832
4833 StringBundler msg = new StringBundler(6);
4834
4835 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4836
4837 msg.append("name=");
4838 msg.append(name);
4839
4840 msg.append(", vocabularyId=");
4841 msg.append(vocabularyId);
4842
4843 msg.append(StringPool.CLOSE_CURLY_BRACE);
4844
4845 throw new NoSuchCategoryException(msg.toString());
4846 }
4847
4848
4857 public AssetCategory fetchByN_V_Last(String name, long vocabularyId,
4858 OrderByComparator orderByComparator) throws SystemException {
4859 int count = countByN_V(name, vocabularyId);
4860
4861 List<AssetCategory> list = findByN_V(name, vocabularyId, count - 1,
4862 count, orderByComparator);
4863
4864 if (!list.isEmpty()) {
4865 return list.get(0);
4866 }
4867
4868 return null;
4869 }
4870
4871
4882 public AssetCategory[] findByN_V_PrevAndNext(long categoryId, String name,
4883 long vocabularyId, OrderByComparator orderByComparator)
4884 throws NoSuchCategoryException, SystemException {
4885 AssetCategory assetCategory = findByPrimaryKey(categoryId);
4886
4887 Session session = null;
4888
4889 try {
4890 session = openSession();
4891
4892 AssetCategory[] array = new AssetCategoryImpl[3];
4893
4894 array[0] = getByN_V_PrevAndNext(session, assetCategory, name,
4895 vocabularyId, orderByComparator, true);
4896
4897 array[1] = assetCategory;
4898
4899 array[2] = getByN_V_PrevAndNext(session, assetCategory, name,
4900 vocabularyId, orderByComparator, false);
4901
4902 return array;
4903 }
4904 catch (Exception e) {
4905 throw processException(e);
4906 }
4907 finally {
4908 closeSession(session);
4909 }
4910 }
4911
4912 protected AssetCategory getByN_V_PrevAndNext(Session session,
4913 AssetCategory assetCategory, String name, long vocabularyId,
4914 OrderByComparator orderByComparator, boolean previous) {
4915 StringBundler query = null;
4916
4917 if (orderByComparator != null) {
4918 query = new StringBundler(6 +
4919 (orderByComparator.getOrderByFields().length * 6));
4920 }
4921 else {
4922 query = new StringBundler(3);
4923 }
4924
4925 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
4926
4927 if (name == null) {
4928 query.append(_FINDER_COLUMN_N_V_NAME_1);
4929 }
4930 else {
4931 if (name.equals(StringPool.BLANK)) {
4932 query.append(_FINDER_COLUMN_N_V_NAME_3);
4933 }
4934 else {
4935 query.append(_FINDER_COLUMN_N_V_NAME_2);
4936 }
4937 }
4938
4939 query.append(_FINDER_COLUMN_N_V_VOCABULARYID_2);
4940
4941 if (orderByComparator != null) {
4942 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
4943
4944 if (orderByConditionFields.length > 0) {
4945 query.append(WHERE_AND);
4946 }
4947
4948 for (int i = 0; i < orderByConditionFields.length; i++) {
4949 query.append(_ORDER_BY_ENTITY_ALIAS);
4950 query.append(orderByConditionFields[i]);
4951
4952 if ((i + 1) < orderByConditionFields.length) {
4953 if (orderByComparator.isAscending() ^ previous) {
4954 query.append(WHERE_GREATER_THAN_HAS_NEXT);
4955 }
4956 else {
4957 query.append(WHERE_LESSER_THAN_HAS_NEXT);
4958 }
4959 }
4960 else {
4961 if (orderByComparator.isAscending() ^ previous) {
4962 query.append(WHERE_GREATER_THAN);
4963 }
4964 else {
4965 query.append(WHERE_LESSER_THAN);
4966 }
4967 }
4968 }
4969
4970 query.append(ORDER_BY_CLAUSE);
4971
4972 String[] orderByFields = orderByComparator.getOrderByFields();
4973
4974 for (int i = 0; i < orderByFields.length; i++) {
4975 query.append(_ORDER_BY_ENTITY_ALIAS);
4976 query.append(orderByFields[i]);
4977
4978 if ((i + 1) < orderByFields.length) {
4979 if (orderByComparator.isAscending() ^ previous) {
4980 query.append(ORDER_BY_ASC_HAS_NEXT);
4981 }
4982 else {
4983 query.append(ORDER_BY_DESC_HAS_NEXT);
4984 }
4985 }
4986 else {
4987 if (orderByComparator.isAscending() ^ previous) {
4988 query.append(ORDER_BY_ASC);
4989 }
4990 else {
4991 query.append(ORDER_BY_DESC);
4992 }
4993 }
4994 }
4995 }
4996
4997 else {
4998 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
4999 }
5000
5001 String sql = query.toString();
5002
5003 Query q = session.createQuery(sql);
5004
5005 q.setFirstResult(0);
5006 q.setMaxResults(2);
5007
5008 QueryPos qPos = QueryPos.getInstance(q);
5009
5010 if (name != null) {
5011 qPos.add(name);
5012 }
5013
5014 qPos.add(vocabularyId);
5015
5016 if (orderByComparator != null) {
5017 Object[] values = orderByComparator.getOrderByConditionValues(assetCategory);
5018
5019 for (Object value : values) {
5020 qPos.add(value);
5021 }
5022 }
5023
5024 List<AssetCategory> list = q.list();
5025
5026 if (list.size() == 2) {
5027 return list.get(1);
5028 }
5029 else {
5030 return null;
5031 }
5032 }
5033
5034
5043 public List<AssetCategory> findByG_P_N(long groupId, long parentCategoryId,
5044 String name) throws SystemException {
5045 return findByG_P_N(groupId, parentCategoryId, name, QueryUtil.ALL_POS,
5046 QueryUtil.ALL_POS, null);
5047 }
5048
5049
5064 public List<AssetCategory> findByG_P_N(long groupId, long parentCategoryId,
5065 String name, int start, int end) throws SystemException {
5066 return findByG_P_N(groupId, parentCategoryId, name, start, end, null);
5067 }
5068
5069
5085 public List<AssetCategory> findByG_P_N(long groupId, long parentCategoryId,
5086 String name, int start, int end, OrderByComparator orderByComparator)
5087 throws SystemException {
5088 FinderPath finderPath = null;
5089 Object[] finderArgs = null;
5090
5091 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
5092 (orderByComparator == null)) {
5093 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_N;
5094 finderArgs = new Object[] { groupId, parentCategoryId, name };
5095 }
5096 else {
5097 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_P_N;
5098 finderArgs = new Object[] {
5099 groupId, parentCategoryId, name,
5100
5101 start, end, orderByComparator
5102 };
5103 }
5104
5105 List<AssetCategory> list = (List<AssetCategory>)FinderCacheUtil.getResult(finderPath,
5106 finderArgs, this);
5107
5108 if ((list != null) && !list.isEmpty()) {
5109 for (AssetCategory assetCategory : list) {
5110 if ((groupId != assetCategory.getGroupId()) ||
5111 (parentCategoryId != assetCategory.getParentCategoryId()) ||
5112 !Validator.equals(name, assetCategory.getName())) {
5113 list = null;
5114
5115 break;
5116 }
5117 }
5118 }
5119
5120 if (list == null) {
5121 StringBundler query = null;
5122
5123 if (orderByComparator != null) {
5124 query = new StringBundler(5 +
5125 (orderByComparator.getOrderByFields().length * 3));
5126 }
5127 else {
5128 query = new StringBundler(5);
5129 }
5130
5131 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
5132
5133 query.append(_FINDER_COLUMN_G_P_N_GROUPID_2);
5134
5135 query.append(_FINDER_COLUMN_G_P_N_PARENTCATEGORYID_2);
5136
5137 if (name == null) {
5138 query.append(_FINDER_COLUMN_G_P_N_NAME_1);
5139 }
5140 else {
5141 if (name.equals(StringPool.BLANK)) {
5142 query.append(_FINDER_COLUMN_G_P_N_NAME_3);
5143 }
5144 else {
5145 query.append(_FINDER_COLUMN_G_P_N_NAME_2);
5146 }
5147 }
5148
5149 if (orderByComparator != null) {
5150 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
5151 orderByComparator);
5152 }
5153
5154 else {
5155 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
5156 }
5157
5158 String sql = query.toString();
5159
5160 Session session = null;
5161
5162 try {
5163 session = openSession();
5164
5165 Query q = session.createQuery(sql);
5166
5167 QueryPos qPos = QueryPos.getInstance(q);
5168
5169 qPos.add(groupId);
5170
5171 qPos.add(parentCategoryId);
5172
5173 if (name != null) {
5174 qPos.add(name);
5175 }
5176
5177 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
5178 start, end);
5179 }
5180 catch (Exception e) {
5181 throw processException(e);
5182 }
5183 finally {
5184 if (list == null) {
5185 FinderCacheUtil.removeResult(finderPath, finderArgs);
5186 }
5187 else {
5188 cacheResult(list);
5189
5190 FinderCacheUtil.putResult(finderPath, finderArgs, list);
5191 }
5192
5193 closeSession(session);
5194 }
5195 }
5196
5197 return list;
5198 }
5199
5200
5211 public AssetCategory findByG_P_N_First(long groupId, long parentCategoryId,
5212 String name, OrderByComparator orderByComparator)
5213 throws NoSuchCategoryException, SystemException {
5214 AssetCategory assetCategory = fetchByG_P_N_First(groupId,
5215 parentCategoryId, name, orderByComparator);
5216
5217 if (assetCategory != null) {
5218 return assetCategory;
5219 }
5220
5221 StringBundler msg = new StringBundler(8);
5222
5223 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5224
5225 msg.append("groupId=");
5226 msg.append(groupId);
5227
5228 msg.append(", parentCategoryId=");
5229 msg.append(parentCategoryId);
5230
5231 msg.append(", name=");
5232 msg.append(name);
5233
5234 msg.append(StringPool.CLOSE_CURLY_BRACE);
5235
5236 throw new NoSuchCategoryException(msg.toString());
5237 }
5238
5239
5249 public AssetCategory fetchByG_P_N_First(long groupId,
5250 long parentCategoryId, String name, OrderByComparator orderByComparator)
5251 throws SystemException {
5252 List<AssetCategory> list = findByG_P_N(groupId, parentCategoryId, name,
5253 0, 1, orderByComparator);
5254
5255 if (!list.isEmpty()) {
5256 return list.get(0);
5257 }
5258
5259 return null;
5260 }
5261
5262
5273 public AssetCategory findByG_P_N_Last(long groupId, long parentCategoryId,
5274 String name, OrderByComparator orderByComparator)
5275 throws NoSuchCategoryException, SystemException {
5276 AssetCategory assetCategory = fetchByG_P_N_Last(groupId,
5277 parentCategoryId, name, orderByComparator);
5278
5279 if (assetCategory != null) {
5280 return assetCategory;
5281 }
5282
5283 StringBundler msg = new StringBundler(8);
5284
5285 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5286
5287 msg.append("groupId=");
5288 msg.append(groupId);
5289
5290 msg.append(", parentCategoryId=");
5291 msg.append(parentCategoryId);
5292
5293 msg.append(", name=");
5294 msg.append(name);
5295
5296 msg.append(StringPool.CLOSE_CURLY_BRACE);
5297
5298 throw new NoSuchCategoryException(msg.toString());
5299 }
5300
5301
5311 public AssetCategory fetchByG_P_N_Last(long groupId, long parentCategoryId,
5312 String name, OrderByComparator orderByComparator)
5313 throws SystemException {
5314 int count = countByG_P_N(groupId, parentCategoryId, name);
5315
5316 List<AssetCategory> list = findByG_P_N(groupId, parentCategoryId, name,
5317 count - 1, count, orderByComparator);
5318
5319 if (!list.isEmpty()) {
5320 return list.get(0);
5321 }
5322
5323 return null;
5324 }
5325
5326
5338 public AssetCategory[] findByG_P_N_PrevAndNext(long categoryId,
5339 long groupId, long parentCategoryId, String name,
5340 OrderByComparator orderByComparator)
5341 throws NoSuchCategoryException, SystemException {
5342 AssetCategory assetCategory = findByPrimaryKey(categoryId);
5343
5344 Session session = null;
5345
5346 try {
5347 session = openSession();
5348
5349 AssetCategory[] array = new AssetCategoryImpl[3];
5350
5351 array[0] = getByG_P_N_PrevAndNext(session, assetCategory, groupId,
5352 parentCategoryId, name, orderByComparator, true);
5353
5354 array[1] = assetCategory;
5355
5356 array[2] = getByG_P_N_PrevAndNext(session, assetCategory, groupId,
5357 parentCategoryId, name, orderByComparator, false);
5358
5359 return array;
5360 }
5361 catch (Exception e) {
5362 throw processException(e);
5363 }
5364 finally {
5365 closeSession(session);
5366 }
5367 }
5368
5369 protected AssetCategory getByG_P_N_PrevAndNext(Session session,
5370 AssetCategory assetCategory, long groupId, long parentCategoryId,
5371 String name, OrderByComparator orderByComparator, boolean previous) {
5372 StringBundler query = null;
5373
5374 if (orderByComparator != null) {
5375 query = new StringBundler(6 +
5376 (orderByComparator.getOrderByFields().length * 6));
5377 }
5378 else {
5379 query = new StringBundler(3);
5380 }
5381
5382 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
5383
5384 query.append(_FINDER_COLUMN_G_P_N_GROUPID_2);
5385
5386 query.append(_FINDER_COLUMN_G_P_N_PARENTCATEGORYID_2);
5387
5388 if (name == null) {
5389 query.append(_FINDER_COLUMN_G_P_N_NAME_1);
5390 }
5391 else {
5392 if (name.equals(StringPool.BLANK)) {
5393 query.append(_FINDER_COLUMN_G_P_N_NAME_3);
5394 }
5395 else {
5396 query.append(_FINDER_COLUMN_G_P_N_NAME_2);
5397 }
5398 }
5399
5400 if (orderByComparator != null) {
5401 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
5402
5403 if (orderByConditionFields.length > 0) {
5404 query.append(WHERE_AND);
5405 }
5406
5407 for (int i = 0; i < orderByConditionFields.length; i++) {
5408 query.append(_ORDER_BY_ENTITY_ALIAS);
5409 query.append(orderByConditionFields[i]);
5410
5411 if ((i + 1) < orderByConditionFields.length) {
5412 if (orderByComparator.isAscending() ^ previous) {
5413 query.append(WHERE_GREATER_THAN_HAS_NEXT);
5414 }
5415 else {
5416 query.append(WHERE_LESSER_THAN_HAS_NEXT);
5417 }
5418 }
5419 else {
5420 if (orderByComparator.isAscending() ^ previous) {
5421 query.append(WHERE_GREATER_THAN);
5422 }
5423 else {
5424 query.append(WHERE_LESSER_THAN);
5425 }
5426 }
5427 }
5428
5429 query.append(ORDER_BY_CLAUSE);
5430
5431 String[] orderByFields = orderByComparator.getOrderByFields();
5432
5433 for (int i = 0; i < orderByFields.length; i++) {
5434 query.append(_ORDER_BY_ENTITY_ALIAS);
5435 query.append(orderByFields[i]);
5436
5437 if ((i + 1) < orderByFields.length) {
5438 if (orderByComparator.isAscending() ^ previous) {
5439 query.append(ORDER_BY_ASC_HAS_NEXT);
5440 }
5441 else {
5442 query.append(ORDER_BY_DESC_HAS_NEXT);
5443 }
5444 }
5445 else {
5446 if (orderByComparator.isAscending() ^ previous) {
5447 query.append(ORDER_BY_ASC);
5448 }
5449 else {
5450 query.append(ORDER_BY_DESC);
5451 }
5452 }
5453 }
5454 }
5455
5456 else {
5457 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
5458 }
5459
5460 String sql = query.toString();
5461
5462 Query q = session.createQuery(sql);
5463
5464 q.setFirstResult(0);
5465 q.setMaxResults(2);
5466
5467 QueryPos qPos = QueryPos.getInstance(q);
5468
5469 qPos.add(groupId);
5470
5471 qPos.add(parentCategoryId);
5472
5473 if (name != null) {
5474 qPos.add(name);
5475 }
5476
5477 if (orderByComparator != null) {
5478 Object[] values = orderByComparator.getOrderByConditionValues(assetCategory);
5479
5480 for (Object value : values) {
5481 qPos.add(value);
5482 }
5483 }
5484
5485 List<AssetCategory> list = q.list();
5486
5487 if (list.size() == 2) {
5488 return list.get(1);
5489 }
5490 else {
5491 return null;
5492 }
5493 }
5494
5495
5504 public List<AssetCategory> filterFindByG_P_N(long groupId,
5505 long parentCategoryId, String name) throws SystemException {
5506 return filterFindByG_P_N(groupId, parentCategoryId, name,
5507 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
5508 }
5509
5510
5525 public List<AssetCategory> filterFindByG_P_N(long groupId,
5526 long parentCategoryId, String name, int start, int end)
5527 throws SystemException {
5528 return filterFindByG_P_N(groupId, parentCategoryId, name, start, end,
5529 null);
5530 }
5531
5532
5548 public List<AssetCategory> filterFindByG_P_N(long groupId,
5549 long parentCategoryId, String name, int start, int end,
5550 OrderByComparator orderByComparator) throws SystemException {
5551 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
5552 return findByG_P_N(groupId, parentCategoryId, name, start, end,
5553 orderByComparator);
5554 }
5555
5556 StringBundler query = null;
5557
5558 if (orderByComparator != null) {
5559 query = new StringBundler(5 +
5560 (orderByComparator.getOrderByFields().length * 3));
5561 }
5562 else {
5563 query = new StringBundler(5);
5564 }
5565
5566 if (getDB().isSupportsInlineDistinct()) {
5567 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_WHERE);
5568 }
5569 else {
5570 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_1);
5571 }
5572
5573 query.append(_FINDER_COLUMN_G_P_N_GROUPID_2);
5574
5575 query.append(_FINDER_COLUMN_G_P_N_PARENTCATEGORYID_2);
5576
5577 if (name == null) {
5578 query.append(_FINDER_COLUMN_G_P_N_NAME_1);
5579 }
5580 else {
5581 if (name.equals(StringPool.BLANK)) {
5582 query.append(_FINDER_COLUMN_G_P_N_NAME_3);
5583 }
5584 else {
5585 query.append(_FINDER_COLUMN_G_P_N_NAME_2);
5586 }
5587 }
5588
5589 if (!getDB().isSupportsInlineDistinct()) {
5590 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_2);
5591 }
5592
5593 if (orderByComparator != null) {
5594 if (getDB().isSupportsInlineDistinct()) {
5595 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
5596 orderByComparator);
5597 }
5598 else {
5599 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
5600 orderByComparator);
5601 }
5602 }
5603
5604 else {
5605 if (getDB().isSupportsInlineDistinct()) {
5606 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
5607 }
5608 else {
5609 query.append(AssetCategoryModelImpl.ORDER_BY_SQL);
5610 }
5611 }
5612
5613 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
5614 AssetCategory.class.getName(),
5615 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
5616
5617 Session session = null;
5618
5619 try {
5620 session = openSession();
5621
5622 SQLQuery q = session.createSQLQuery(sql);
5623
5624 if (getDB().isSupportsInlineDistinct()) {
5625 q.addEntity(_FILTER_ENTITY_ALIAS, AssetCategoryImpl.class);
5626 }
5627 else {
5628 q.addEntity(_FILTER_ENTITY_TABLE, AssetCategoryImpl.class);
5629 }
5630
5631 QueryPos qPos = QueryPos.getInstance(q);
5632
5633 qPos.add(groupId);
5634
5635 qPos.add(parentCategoryId);
5636
5637 if (name != null) {
5638 qPos.add(name);
5639 }
5640
5641 return (List<AssetCategory>)QueryUtil.list(q, getDialect(), start,
5642 end);
5643 }
5644 catch (Exception e) {
5645 throw processException(e);
5646 }
5647 finally {
5648 closeSession(session);
5649 }
5650 }
5651
5652
5664 public AssetCategory[] filterFindByG_P_N_PrevAndNext(long categoryId,
5665 long groupId, long parentCategoryId, String name,
5666 OrderByComparator orderByComparator)
5667 throws NoSuchCategoryException, SystemException {
5668 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
5669 return findByG_P_N_PrevAndNext(categoryId, groupId,
5670 parentCategoryId, name, orderByComparator);
5671 }
5672
5673 AssetCategory assetCategory = findByPrimaryKey(categoryId);
5674
5675 Session session = null;
5676
5677 try {
5678 session = openSession();
5679
5680 AssetCategory[] array = new AssetCategoryImpl[3];
5681
5682 array[0] = filterGetByG_P_N_PrevAndNext(session, assetCategory,
5683 groupId, parentCategoryId, name, orderByComparator, true);
5684
5685 array[1] = assetCategory;
5686
5687 array[2] = filterGetByG_P_N_PrevAndNext(session, assetCategory,
5688 groupId, parentCategoryId, name, orderByComparator, false);
5689
5690 return array;
5691 }
5692 catch (Exception e) {
5693 throw processException(e);
5694 }
5695 finally {
5696 closeSession(session);
5697 }
5698 }
5699
5700 protected AssetCategory filterGetByG_P_N_PrevAndNext(Session session,
5701 AssetCategory assetCategory, long groupId, long parentCategoryId,
5702 String name, OrderByComparator orderByComparator, boolean previous) {
5703 StringBundler query = null;
5704
5705 if (orderByComparator != null) {
5706 query = new StringBundler(6 +
5707 (orderByComparator.getOrderByFields().length * 6));
5708 }
5709 else {
5710 query = new StringBundler(3);
5711 }
5712
5713 if (getDB().isSupportsInlineDistinct()) {
5714 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_WHERE);
5715 }
5716 else {
5717 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_1);
5718 }
5719
5720 query.append(_FINDER_COLUMN_G_P_N_GROUPID_2);
5721
5722 query.append(_FINDER_COLUMN_G_P_N_PARENTCATEGORYID_2);
5723
5724 if (name == null) {
5725 query.append(_FINDER_COLUMN_G_P_N_NAME_1);
5726 }
5727 else {
5728 if (name.equals(StringPool.BLANK)) {
5729 query.append(_FINDER_COLUMN_G_P_N_NAME_3);
5730 }
5731 else {
5732 query.append(_FINDER_COLUMN_G_P_N_NAME_2);
5733 }
5734 }
5735
5736 if (!getDB().isSupportsInlineDistinct()) {
5737 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_2);
5738 }
5739
5740 if (orderByComparator != null) {
5741 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
5742
5743 if (orderByConditionFields.length > 0) {
5744 query.append(WHERE_AND);
5745 }
5746
5747 for (int i = 0; i < orderByConditionFields.length; i++) {
5748 if (getDB().isSupportsInlineDistinct()) {
5749 query.append(_ORDER_BY_ENTITY_ALIAS);
5750 }
5751 else {
5752 query.append(_ORDER_BY_ENTITY_TABLE);
5753 }
5754
5755 query.append(orderByConditionFields[i]);
5756
5757 if ((i + 1) < orderByConditionFields.length) {
5758 if (orderByComparator.isAscending() ^ previous) {
5759 query.append(WHERE_GREATER_THAN_HAS_NEXT);
5760 }
5761 else {
5762 query.append(WHERE_LESSER_THAN_HAS_NEXT);
5763 }
5764 }
5765 else {
5766 if (orderByComparator.isAscending() ^ previous) {
5767 query.append(WHERE_GREATER_THAN);
5768 }
5769 else {
5770 query.append(WHERE_LESSER_THAN);
5771 }
5772 }
5773 }
5774
5775 query.append(ORDER_BY_CLAUSE);
5776
5777 String[] orderByFields = orderByComparator.getOrderByFields();
5778
5779 for (int i = 0; i < orderByFields.length; i++) {
5780 if (getDB().isSupportsInlineDistinct()) {
5781 query.append(_ORDER_BY_ENTITY_ALIAS);
5782 }
5783 else {
5784 query.append(_ORDER_BY_ENTITY_TABLE);
5785 }
5786
5787 query.append(orderByFields[i]);
5788
5789 if ((i + 1) < orderByFields.length) {
5790 if (orderByComparator.isAscending() ^ previous) {
5791 query.append(ORDER_BY_ASC_HAS_NEXT);
5792 }
5793 else {
5794 query.append(ORDER_BY_DESC_HAS_NEXT);
5795 }
5796 }
5797 else {
5798 if (orderByComparator.isAscending() ^ previous) {
5799 query.append(ORDER_BY_ASC);
5800 }
5801 else {
5802 query.append(ORDER_BY_DESC);
5803 }
5804 }
5805 }
5806 }
5807
5808 else {
5809 if (getDB().isSupportsInlineDistinct()) {
5810 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
5811 }
5812 else {
5813 query.append(AssetCategoryModelImpl.ORDER_BY_SQL);
5814 }
5815 }
5816
5817 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
5818 AssetCategory.class.getName(),
5819 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
5820
5821 SQLQuery q = session.createSQLQuery(sql);
5822
5823 q.setFirstResult(0);
5824 q.setMaxResults(2);
5825
5826 if (getDB().isSupportsInlineDistinct()) {
5827 q.addEntity(_FILTER_ENTITY_ALIAS, AssetCategoryImpl.class);
5828 }
5829 else {
5830 q.addEntity(_FILTER_ENTITY_TABLE, AssetCategoryImpl.class);
5831 }
5832
5833 QueryPos qPos = QueryPos.getInstance(q);
5834
5835 qPos.add(groupId);
5836
5837 qPos.add(parentCategoryId);
5838
5839 if (name != null) {
5840 qPos.add(name);
5841 }
5842
5843 if (orderByComparator != null) {
5844 Object[] values = orderByComparator.getOrderByConditionValues(assetCategory);
5845
5846 for (Object value : values) {
5847 qPos.add(value);
5848 }
5849 }
5850
5851 List<AssetCategory> list = q.list();
5852
5853 if (list.size() == 2) {
5854 return list.get(1);
5855 }
5856 else {
5857 return null;
5858 }
5859 }
5860
5861
5871 public AssetCategory findByP_N_V(long parentCategoryId, String name,
5872 long vocabularyId) throws NoSuchCategoryException, SystemException {
5873 AssetCategory assetCategory = fetchByP_N_V(parentCategoryId, name,
5874 vocabularyId);
5875
5876 if (assetCategory == null) {
5877 StringBundler msg = new StringBundler(8);
5878
5879 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5880
5881 msg.append("parentCategoryId=");
5882 msg.append(parentCategoryId);
5883
5884 msg.append(", name=");
5885 msg.append(name);
5886
5887 msg.append(", vocabularyId=");
5888 msg.append(vocabularyId);
5889
5890 msg.append(StringPool.CLOSE_CURLY_BRACE);
5891
5892 if (_log.isWarnEnabled()) {
5893 _log.warn(msg.toString());
5894 }
5895
5896 throw new NoSuchCategoryException(msg.toString());
5897 }
5898
5899 return assetCategory;
5900 }
5901
5902
5911 public AssetCategory fetchByP_N_V(long parentCategoryId, String name,
5912 long vocabularyId) throws SystemException {
5913 return fetchByP_N_V(parentCategoryId, name, vocabularyId, true);
5914 }
5915
5916
5926 public AssetCategory fetchByP_N_V(long parentCategoryId, String name,
5927 long vocabularyId, boolean retrieveFromCache) throws SystemException {
5928 Object[] finderArgs = new Object[] { parentCategoryId, name, vocabularyId };
5929
5930 Object result = null;
5931
5932 if (retrieveFromCache) {
5933 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_P_N_V,
5934 finderArgs, this);
5935 }
5936
5937 if (result instanceof AssetCategory) {
5938 AssetCategory assetCategory = (AssetCategory)result;
5939
5940 if ((parentCategoryId != assetCategory.getParentCategoryId()) ||
5941 !Validator.equals(name, assetCategory.getName()) ||
5942 (vocabularyId != assetCategory.getVocabularyId())) {
5943 result = null;
5944 }
5945 }
5946
5947 if (result == null) {
5948 StringBundler query = new StringBundler(5);
5949
5950 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
5951
5952 query.append(_FINDER_COLUMN_P_N_V_PARENTCATEGORYID_2);
5953
5954 if (name == null) {
5955 query.append(_FINDER_COLUMN_P_N_V_NAME_1);
5956 }
5957 else {
5958 if (name.equals(StringPool.BLANK)) {
5959 query.append(_FINDER_COLUMN_P_N_V_NAME_3);
5960 }
5961 else {
5962 query.append(_FINDER_COLUMN_P_N_V_NAME_2);
5963 }
5964 }
5965
5966 query.append(_FINDER_COLUMN_P_N_V_VOCABULARYID_2);
5967
5968 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
5969
5970 String sql = query.toString();
5971
5972 Session session = null;
5973
5974 try {
5975 session = openSession();
5976
5977 Query q = session.createQuery(sql);
5978
5979 QueryPos qPos = QueryPos.getInstance(q);
5980
5981 qPos.add(parentCategoryId);
5982
5983 if (name != null) {
5984 qPos.add(name);
5985 }
5986
5987 qPos.add(vocabularyId);
5988
5989 List<AssetCategory> list = q.list();
5990
5991 result = list;
5992
5993 AssetCategory assetCategory = null;
5994
5995 if (list.isEmpty()) {
5996 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_P_N_V,
5997 finderArgs, list);
5998 }
5999 else {
6000 assetCategory = list.get(0);
6001
6002 cacheResult(assetCategory);
6003
6004 if ((assetCategory.getParentCategoryId() != parentCategoryId) ||
6005 (assetCategory.getName() == null) ||
6006 !assetCategory.getName().equals(name) ||
6007 (assetCategory.getVocabularyId() != vocabularyId)) {
6008 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_P_N_V,
6009 finderArgs, assetCategory);
6010 }
6011 }
6012
6013 return assetCategory;
6014 }
6015 catch (Exception e) {
6016 throw processException(e);
6017 }
6018 finally {
6019 if (result == null) {
6020 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_P_N_V,
6021 finderArgs);
6022 }
6023
6024 closeSession(session);
6025 }
6026 }
6027 else {
6028 if (result instanceof List<?>) {
6029 return null;
6030 }
6031 else {
6032 return (AssetCategory)result;
6033 }
6034 }
6035 }
6036
6037
6043 public List<AssetCategory> findAll() throws SystemException {
6044 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
6045 }
6046
6047
6059 public List<AssetCategory> findAll(int start, int end)
6060 throws SystemException {
6061 return findAll(start, end, null);
6062 }
6063
6064
6077 public List<AssetCategory> findAll(int start, int end,
6078 OrderByComparator orderByComparator) throws SystemException {
6079 FinderPath finderPath = null;
6080 Object[] finderArgs = new Object[] { start, end, orderByComparator };
6081
6082 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
6083 (orderByComparator == null)) {
6084 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
6085 finderArgs = FINDER_ARGS_EMPTY;
6086 }
6087 else {
6088 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
6089 finderArgs = new Object[] { start, end, orderByComparator };
6090 }
6091
6092 List<AssetCategory> list = (List<AssetCategory>)FinderCacheUtil.getResult(finderPath,
6093 finderArgs, this);
6094
6095 if (list == null) {
6096 StringBundler query = null;
6097 String sql = null;
6098
6099 if (orderByComparator != null) {
6100 query = new StringBundler(2 +
6101 (orderByComparator.getOrderByFields().length * 3));
6102
6103 query.append(_SQL_SELECT_ASSETCATEGORY);
6104
6105 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
6106 orderByComparator);
6107
6108 sql = query.toString();
6109 }
6110 else {
6111 sql = _SQL_SELECT_ASSETCATEGORY.concat(AssetCategoryModelImpl.ORDER_BY_JPQL);
6112 }
6113
6114 Session session = null;
6115
6116 try {
6117 session = openSession();
6118
6119 Query q = session.createQuery(sql);
6120
6121 if (orderByComparator == null) {
6122 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
6123 start, end, false);
6124
6125 Collections.sort(list);
6126 }
6127 else {
6128 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
6129 start, end);
6130 }
6131 }
6132 catch (Exception e) {
6133 throw processException(e);
6134 }
6135 finally {
6136 if (list == null) {
6137 FinderCacheUtil.removeResult(finderPath, finderArgs);
6138 }
6139 else {
6140 cacheResult(list);
6141
6142 FinderCacheUtil.putResult(finderPath, finderArgs, list);
6143 }
6144
6145 closeSession(session);
6146 }
6147 }
6148
6149 return list;
6150 }
6151
6152
6158 public void removeByUuid(String uuid) throws SystemException {
6159 for (AssetCategory assetCategory : findByUuid(uuid)) {
6160 remove(assetCategory);
6161 }
6162 }
6163
6164
6172 public AssetCategory removeByUUID_G(String uuid, long groupId)
6173 throws NoSuchCategoryException, SystemException {
6174 AssetCategory assetCategory = findByUUID_G(uuid, groupId);
6175
6176 return remove(assetCategory);
6177 }
6178
6179
6185 public void removeByGroupId(long groupId) throws SystemException {
6186 for (AssetCategory assetCategory : findByGroupId(groupId)) {
6187 remove(assetCategory);
6188 }
6189 }
6190
6191
6197 public void removeByParentCategoryId(long parentCategoryId)
6198 throws SystemException {
6199 for (AssetCategory assetCategory : findByParentCategoryId(
6200 parentCategoryId)) {
6201 remove(assetCategory);
6202 }
6203 }
6204
6205
6211 public void removeByVocabularyId(long vocabularyId)
6212 throws SystemException {
6213 for (AssetCategory assetCategory : findByVocabularyId(vocabularyId)) {
6214 remove(assetCategory);
6215 }
6216 }
6217
6218
6225 public void removeByG_V(long groupId, long vocabularyId)
6226 throws SystemException {
6227 for (AssetCategory assetCategory : findByG_V(groupId, vocabularyId)) {
6228 remove(assetCategory);
6229 }
6230 }
6231
6232
6239 public void removeByP_N(long parentCategoryId, String name)
6240 throws SystemException {
6241 for (AssetCategory assetCategory : findByP_N(parentCategoryId, name)) {
6242 remove(assetCategory);
6243 }
6244 }
6245
6246
6253 public void removeByP_V(long parentCategoryId, long vocabularyId)
6254 throws SystemException {
6255 for (AssetCategory assetCategory : findByP_V(parentCategoryId,
6256 vocabularyId)) {
6257 remove(assetCategory);
6258 }
6259 }
6260
6261
6268 public void removeByN_V(String name, long vocabularyId)
6269 throws SystemException {
6270 for (AssetCategory assetCategory : findByN_V(name, vocabularyId)) {
6271 remove(assetCategory);
6272 }
6273 }
6274
6275
6283 public void removeByG_P_N(long groupId, long parentCategoryId, String name)
6284 throws SystemException {
6285 for (AssetCategory assetCategory : findByG_P_N(groupId,
6286 parentCategoryId, name)) {
6287 remove(assetCategory);
6288 }
6289 }
6290
6291
6300 public AssetCategory removeByP_N_V(long parentCategoryId, String name,
6301 long vocabularyId) throws NoSuchCategoryException, SystemException {
6302 AssetCategory assetCategory = findByP_N_V(parentCategoryId, name,
6303 vocabularyId);
6304
6305 return remove(assetCategory);
6306 }
6307
6308
6313 public void removeAll() throws SystemException {
6314 for (AssetCategory assetCategory : findAll()) {
6315 remove(assetCategory);
6316 }
6317 }
6318
6319
6326 public int countByUuid(String uuid) throws SystemException {
6327 Object[] finderArgs = new Object[] { uuid };
6328
6329 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID,
6330 finderArgs, this);
6331
6332 if (count == null) {
6333 StringBundler query = new StringBundler(2);
6334
6335 query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
6336
6337 if (uuid == null) {
6338 query.append(_FINDER_COLUMN_UUID_UUID_1);
6339 }
6340 else {
6341 if (uuid.equals(StringPool.BLANK)) {
6342 query.append(_FINDER_COLUMN_UUID_UUID_3);
6343 }
6344 else {
6345 query.append(_FINDER_COLUMN_UUID_UUID_2);
6346 }
6347 }
6348
6349 String sql = query.toString();
6350
6351 Session session = null;
6352
6353 try {
6354 session = openSession();
6355
6356 Query q = session.createQuery(sql);
6357
6358 QueryPos qPos = QueryPos.getInstance(q);
6359
6360 if (uuid != null) {
6361 qPos.add(uuid);
6362 }
6363
6364 count = (Long)q.uniqueResult();
6365 }
6366 catch (Exception e) {
6367 throw processException(e);
6368 }
6369 finally {
6370 if (count == null) {
6371 count = Long.valueOf(0);
6372 }
6373
6374 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID,
6375 finderArgs, count);
6376
6377 closeSession(session);
6378 }
6379 }
6380
6381 return count.intValue();
6382 }
6383
6384
6392 public int countByUUID_G(String uuid, long groupId)
6393 throws SystemException {
6394 Object[] finderArgs = new Object[] { uuid, groupId };
6395
6396 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID_G,
6397 finderArgs, this);
6398
6399 if (count == null) {
6400 StringBundler query = new StringBundler(3);
6401
6402 query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
6403
6404 if (uuid == null) {
6405 query.append(_FINDER_COLUMN_UUID_G_UUID_1);
6406 }
6407 else {
6408 if (uuid.equals(StringPool.BLANK)) {
6409 query.append(_FINDER_COLUMN_UUID_G_UUID_3);
6410 }
6411 else {
6412 query.append(_FINDER_COLUMN_UUID_G_UUID_2);
6413 }
6414 }
6415
6416 query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
6417
6418 String sql = query.toString();
6419
6420 Session session = null;
6421
6422 try {
6423 session = openSession();
6424
6425 Query q = session.createQuery(sql);
6426
6427 QueryPos qPos = QueryPos.getInstance(q);
6428
6429 if (uuid != null) {
6430 qPos.add(uuid);
6431 }
6432
6433 qPos.add(groupId);
6434
6435 count = (Long)q.uniqueResult();
6436 }
6437 catch (Exception e) {
6438 throw processException(e);
6439 }
6440 finally {
6441 if (count == null) {
6442 count = Long.valueOf(0);
6443 }
6444
6445 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G,
6446 finderArgs, count);
6447
6448 closeSession(session);
6449 }
6450 }
6451
6452 return count.intValue();
6453 }
6454
6455
6462 public int countByGroupId(long groupId) throws SystemException {
6463 Object[] finderArgs = new Object[] { groupId };
6464
6465 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_GROUPID,
6466 finderArgs, this);
6467
6468 if (count == null) {
6469 StringBundler query = new StringBundler(2);
6470
6471 query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
6472
6473 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
6474
6475 String sql = query.toString();
6476
6477 Session session = null;
6478
6479 try {
6480 session = openSession();
6481
6482 Query q = session.createQuery(sql);
6483
6484 QueryPos qPos = QueryPos.getInstance(q);
6485
6486 qPos.add(groupId);
6487
6488 count = (Long)q.uniqueResult();
6489 }
6490 catch (Exception e) {
6491 throw processException(e);
6492 }
6493 finally {
6494 if (count == null) {
6495 count = Long.valueOf(0);
6496 }
6497
6498 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_GROUPID,
6499 finderArgs, count);
6500
6501 closeSession(session);
6502 }
6503 }
6504
6505 return count.intValue();
6506 }
6507
6508
6515 public int filterCountByGroupId(long groupId) throws SystemException {
6516 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
6517 return countByGroupId(groupId);
6518 }
6519
6520 StringBundler query = new StringBundler(2);
6521
6522 query.append(_FILTER_SQL_COUNT_ASSETCATEGORY_WHERE);
6523
6524 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
6525
6526 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
6527 AssetCategory.class.getName(),
6528 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
6529
6530 Session session = null;
6531
6532 try {
6533 session = openSession();
6534
6535 SQLQuery q = session.createSQLQuery(sql);
6536
6537 q.addScalar(COUNT_COLUMN_NAME,
6538 com.liferay.portal.kernel.dao.orm.Type.LONG);
6539
6540 QueryPos qPos = QueryPos.getInstance(q);
6541
6542 qPos.add(groupId);
6543
6544 Long count = (Long)q.uniqueResult();
6545
6546 return count.intValue();
6547 }
6548 catch (Exception e) {
6549 throw processException(e);
6550 }
6551 finally {
6552 closeSession(session);
6553 }
6554 }
6555
6556
6563 public int countByParentCategoryId(long parentCategoryId)
6564 throws SystemException {
6565 Object[] finderArgs = new Object[] { parentCategoryId };
6566
6567 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_PARENTCATEGORYID,
6568 finderArgs, this);
6569
6570 if (count == null) {
6571 StringBundler query = new StringBundler(2);
6572
6573 query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
6574
6575 query.append(_FINDER_COLUMN_PARENTCATEGORYID_PARENTCATEGORYID_2);
6576
6577 String sql = query.toString();
6578
6579 Session session = null;
6580
6581 try {
6582 session = openSession();
6583
6584 Query q = session.createQuery(sql);
6585
6586 QueryPos qPos = QueryPos.getInstance(q);
6587
6588 qPos.add(parentCategoryId);
6589
6590 count = (Long)q.uniqueResult();
6591 }
6592 catch (Exception e) {
6593 throw processException(e);
6594 }
6595 finally {
6596 if (count == null) {
6597 count = Long.valueOf(0);
6598 }
6599
6600 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_PARENTCATEGORYID,
6601 finderArgs, count);
6602
6603 closeSession(session);
6604 }
6605 }
6606
6607 return count.intValue();
6608 }
6609
6610
6617 public int countByVocabularyId(long vocabularyId) throws SystemException {
6618 Object[] finderArgs = new Object[] { vocabularyId };
6619
6620 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_VOCABULARYID,
6621 finderArgs, this);
6622
6623 if (count == null) {
6624 StringBundler query = new StringBundler(2);
6625
6626 query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
6627
6628 query.append(_FINDER_COLUMN_VOCABULARYID_VOCABULARYID_2);
6629
6630 String sql = query.toString();
6631
6632 Session session = null;
6633
6634 try {
6635 session = openSession();
6636
6637 Query q = session.createQuery(sql);
6638
6639 QueryPos qPos = QueryPos.getInstance(q);
6640
6641 qPos.add(vocabularyId);
6642
6643 count = (Long)q.uniqueResult();
6644 }
6645 catch (Exception e) {
6646 throw processException(e);
6647 }
6648 finally {
6649 if (count == null) {
6650 count = Long.valueOf(0);
6651 }
6652
6653 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_VOCABULARYID,
6654 finderArgs, count);
6655
6656 closeSession(session);
6657 }
6658 }
6659
6660 return count.intValue();
6661 }
6662
6663
6671 public int countByG_V(long groupId, long vocabularyId)
6672 throws SystemException {
6673 Object[] finderArgs = new Object[] { groupId, vocabularyId };
6674
6675 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_V,
6676 finderArgs, this);
6677
6678 if (count == null) {
6679 StringBundler query = new StringBundler(3);
6680
6681 query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
6682
6683 query.append(_FINDER_COLUMN_G_V_GROUPID_2);
6684
6685 query.append(_FINDER_COLUMN_G_V_VOCABULARYID_2);
6686
6687 String sql = query.toString();
6688
6689 Session session = null;
6690
6691 try {
6692 session = openSession();
6693
6694 Query q = session.createQuery(sql);
6695
6696 QueryPos qPos = QueryPos.getInstance(q);
6697
6698 qPos.add(groupId);
6699
6700 qPos.add(vocabularyId);
6701
6702 count = (Long)q.uniqueResult();
6703 }
6704 catch (Exception e) {
6705 throw processException(e);
6706 }
6707 finally {
6708 if (count == null) {
6709 count = Long.valueOf(0);
6710 }
6711
6712 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_V, finderArgs,
6713 count);
6714
6715 closeSession(session);
6716 }
6717 }
6718
6719 return count.intValue();
6720 }
6721
6722
6730 public int filterCountByG_V(long groupId, long vocabularyId)
6731 throws SystemException {
6732 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
6733 return countByG_V(groupId, vocabularyId);
6734 }
6735
6736 StringBundler query = new StringBundler(3);
6737
6738 query.append(_FILTER_SQL_COUNT_ASSETCATEGORY_WHERE);
6739
6740 query.append(_FINDER_COLUMN_G_V_GROUPID_2);
6741
6742 query.append(_FINDER_COLUMN_G_V_VOCABULARYID_2);
6743
6744 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
6745 AssetCategory.class.getName(),
6746 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
6747
6748 Session session = null;
6749
6750 try {
6751 session = openSession();
6752
6753 SQLQuery q = session.createSQLQuery(sql);
6754
6755 q.addScalar(COUNT_COLUMN_NAME,
6756 com.liferay.portal.kernel.dao.orm.Type.LONG);
6757
6758 QueryPos qPos = QueryPos.getInstance(q);
6759
6760 qPos.add(groupId);
6761
6762 qPos.add(vocabularyId);
6763
6764 Long count = (Long)q.uniqueResult();
6765
6766 return count.intValue();
6767 }
6768 catch (Exception e) {
6769 throw processException(e);
6770 }
6771 finally {
6772 closeSession(session);
6773 }
6774 }
6775
6776
6784 public int countByP_N(long parentCategoryId, String name)
6785 throws SystemException {
6786 Object[] finderArgs = new Object[] { parentCategoryId, name };
6787
6788 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_P_N,
6789 finderArgs, this);
6790
6791 if (count == null) {
6792 StringBundler query = new StringBundler(3);
6793
6794 query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
6795
6796 query.append(_FINDER_COLUMN_P_N_PARENTCATEGORYID_2);
6797
6798 if (name == null) {
6799 query.append(_FINDER_COLUMN_P_N_NAME_1);
6800 }
6801 else {
6802 if (name.equals(StringPool.BLANK)) {
6803 query.append(_FINDER_COLUMN_P_N_NAME_3);
6804 }
6805 else {
6806 query.append(_FINDER_COLUMN_P_N_NAME_2);
6807 }
6808 }
6809
6810 String sql = query.toString();
6811
6812 Session session = null;
6813
6814 try {
6815 session = openSession();
6816
6817 Query q = session.createQuery(sql);
6818
6819 QueryPos qPos = QueryPos.getInstance(q);
6820
6821 qPos.add(parentCategoryId);
6822
6823 if (name != null) {
6824 qPos.add(name);
6825 }
6826
6827 count = (Long)q.uniqueResult();
6828 }
6829 catch (Exception e) {
6830 throw processException(e);
6831 }
6832 finally {
6833 if (count == null) {
6834 count = Long.valueOf(0);
6835 }
6836
6837 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_P_N, finderArgs,
6838 count);
6839
6840 closeSession(session);
6841 }
6842 }
6843
6844 return count.intValue();
6845 }
6846
6847
6855 public int countByP_V(long parentCategoryId, long vocabularyId)
6856 throws SystemException {
6857 Object[] finderArgs = new Object[] { parentCategoryId, vocabularyId };
6858
6859 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_P_V,
6860 finderArgs, this);
6861
6862 if (count == null) {
6863 StringBundler query = new StringBundler(3);
6864
6865 query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
6866
6867 query.append(_FINDER_COLUMN_P_V_PARENTCATEGORYID_2);
6868
6869 query.append(_FINDER_COLUMN_P_V_VOCABULARYID_2);
6870
6871 String sql = query.toString();
6872
6873 Session session = null;
6874
6875 try {
6876 session = openSession();
6877
6878 Query q = session.createQuery(sql);
6879
6880 QueryPos qPos = QueryPos.getInstance(q);
6881
6882 qPos.add(parentCategoryId);
6883
6884 qPos.add(vocabularyId);
6885
6886 count = (Long)q.uniqueResult();
6887 }
6888 catch (Exception e) {
6889 throw processException(e);
6890 }
6891 finally {
6892 if (count == null) {
6893 count = Long.valueOf(0);
6894 }
6895
6896 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_P_V, finderArgs,
6897 count);
6898
6899 closeSession(session);
6900 }
6901 }
6902
6903 return count.intValue();
6904 }
6905
6906
6914 public int countByN_V(String name, long vocabularyId)
6915 throws SystemException {
6916 Object[] finderArgs = new Object[] { name, vocabularyId };
6917
6918 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_N_V,
6919 finderArgs, this);
6920
6921 if (count == null) {
6922 StringBundler query = new StringBundler(3);
6923
6924 query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
6925
6926 if (name == null) {
6927 query.append(_FINDER_COLUMN_N_V_NAME_1);
6928 }
6929 else {
6930 if (name.equals(StringPool.BLANK)) {
6931 query.append(_FINDER_COLUMN_N_V_NAME_3);
6932 }
6933 else {
6934 query.append(_FINDER_COLUMN_N_V_NAME_2);
6935 }
6936 }
6937
6938 query.append(_FINDER_COLUMN_N_V_VOCABULARYID_2);
6939
6940 String sql = query.toString();
6941
6942 Session session = null;
6943
6944 try {
6945 session = openSession();
6946
6947 Query q = session.createQuery(sql);
6948
6949 QueryPos qPos = QueryPos.getInstance(q);
6950
6951 if (name != null) {
6952 qPos.add(name);
6953 }
6954
6955 qPos.add(vocabularyId);
6956
6957 count = (Long)q.uniqueResult();
6958 }
6959 catch (Exception e) {
6960 throw processException(e);
6961 }
6962 finally {
6963 if (count == null) {
6964 count = Long.valueOf(0);
6965 }
6966
6967 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_N_V, finderArgs,
6968 count);
6969
6970 closeSession(session);
6971 }
6972 }
6973
6974 return count.intValue();
6975 }
6976
6977
6986 public int countByG_P_N(long groupId, long parentCategoryId, String name)
6987 throws SystemException {
6988 Object[] finderArgs = new Object[] { groupId, parentCategoryId, name };
6989
6990 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_P_N,
6991 finderArgs, this);
6992
6993 if (count == null) {
6994 StringBundler query = new StringBundler(4);
6995
6996 query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
6997
6998 query.append(_FINDER_COLUMN_G_P_N_GROUPID_2);
6999
7000 query.append(_FINDER_COLUMN_G_P_N_PARENTCATEGORYID_2);
7001
7002 if (name == null) {
7003 query.append(_FINDER_COLUMN_G_P_N_NAME_1);
7004 }
7005 else {
7006 if (name.equals(StringPool.BLANK)) {
7007 query.append(_FINDER_COLUMN_G_P_N_NAME_3);
7008 }
7009 else {
7010 query.append(_FINDER_COLUMN_G_P_N_NAME_2);
7011 }
7012 }
7013
7014 String sql = query.toString();
7015
7016 Session session = null;
7017
7018 try {
7019 session = openSession();
7020
7021 Query q = session.createQuery(sql);
7022
7023 QueryPos qPos = QueryPos.getInstance(q);
7024
7025 qPos.add(groupId);
7026
7027 qPos.add(parentCategoryId);
7028
7029 if (name != null) {
7030 qPos.add(name);
7031 }
7032
7033 count = (Long)q.uniqueResult();
7034 }
7035 catch (Exception e) {
7036 throw processException(e);
7037 }
7038 finally {
7039 if (count == null) {
7040 count = Long.valueOf(0);
7041 }
7042
7043 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_P_N,
7044 finderArgs, count);
7045
7046 closeSession(session);
7047 }
7048 }
7049
7050 return count.intValue();
7051 }
7052
7053
7062 public int filterCountByG_P_N(long groupId, long parentCategoryId,
7063 String name) throws SystemException {
7064 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
7065 return countByG_P_N(groupId, parentCategoryId, name);
7066 }
7067
7068 StringBundler query = new StringBundler(4);
7069
7070 query.append(_FILTER_SQL_COUNT_ASSETCATEGORY_WHERE);
7071
7072 query.append(_FINDER_COLUMN_G_P_N_GROUPID_2);
7073
7074 query.append(_FINDER_COLUMN_G_P_N_PARENTCATEGORYID_2);
7075
7076 if (name == null) {
7077 query.append(_FINDER_COLUMN_G_P_N_NAME_1);
7078 }
7079 else {
7080 if (name.equals(StringPool.BLANK)) {
7081 query.append(_FINDER_COLUMN_G_P_N_NAME_3);
7082 }
7083 else {
7084 query.append(_FINDER_COLUMN_G_P_N_NAME_2);
7085 }
7086 }
7087
7088 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
7089 AssetCategory.class.getName(),
7090 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
7091
7092 Session session = null;
7093
7094 try {
7095 session = openSession();
7096
7097 SQLQuery q = session.createSQLQuery(sql);
7098
7099 q.addScalar(COUNT_COLUMN_NAME,
7100 com.liferay.portal.kernel.dao.orm.Type.LONG);
7101
7102 QueryPos qPos = QueryPos.getInstance(q);
7103
7104 qPos.add(groupId);
7105
7106 qPos.add(parentCategoryId);
7107
7108 if (name != null) {
7109 qPos.add(name);
7110 }
7111
7112 Long count = (Long)q.uniqueResult();
7113
7114 return count.intValue();
7115 }
7116 catch (Exception e) {
7117 throw processException(e);
7118 }
7119 finally {
7120 closeSession(session);
7121 }
7122 }
7123
7124
7133 public int countByP_N_V(long parentCategoryId, String name,
7134 long vocabularyId) throws SystemException {
7135 Object[] finderArgs = new Object[] { parentCategoryId, name, vocabularyId };
7136
7137 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_P_N_V,
7138 finderArgs, this);
7139
7140 if (count == null) {
7141 StringBundler query = new StringBundler(4);
7142
7143 query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
7144
7145 query.append(_FINDER_COLUMN_P_N_V_PARENTCATEGORYID_2);
7146
7147 if (name == null) {
7148 query.append(_FINDER_COLUMN_P_N_V_NAME_1);
7149 }
7150 else {
7151 if (name.equals(StringPool.BLANK)) {
7152 query.append(_FINDER_COLUMN_P_N_V_NAME_3);
7153 }
7154 else {
7155 query.append(_FINDER_COLUMN_P_N_V_NAME_2);
7156 }
7157 }
7158
7159 query.append(_FINDER_COLUMN_P_N_V_VOCABULARYID_2);
7160
7161 String sql = query.toString();
7162
7163 Session session = null;
7164
7165 try {
7166 session = openSession();
7167
7168 Query q = session.createQuery(sql);
7169
7170 QueryPos qPos = QueryPos.getInstance(q);
7171
7172 qPos.add(parentCategoryId);
7173
7174 if (name != null) {
7175 qPos.add(name);
7176 }
7177
7178 qPos.add(vocabularyId);
7179
7180 count = (Long)q.uniqueResult();
7181 }
7182 catch (Exception e) {
7183 throw processException(e);
7184 }
7185 finally {
7186 if (count == null) {
7187 count = Long.valueOf(0);
7188 }
7189
7190 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_P_N_V,
7191 finderArgs, count);
7192
7193 closeSession(session);
7194 }
7195 }
7196
7197 return count.intValue();
7198 }
7199
7200
7206 public int countAll() throws SystemException {
7207 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
7208 FINDER_ARGS_EMPTY, this);
7209
7210 if (count == null) {
7211 Session session = null;
7212
7213 try {
7214 session = openSession();
7215
7216 Query q = session.createQuery(_SQL_COUNT_ASSETCATEGORY);
7217
7218 count = (Long)q.uniqueResult();
7219 }
7220 catch (Exception e) {
7221 throw processException(e);
7222 }
7223 finally {
7224 if (count == null) {
7225 count = Long.valueOf(0);
7226 }
7227
7228 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
7229 FINDER_ARGS_EMPTY, count);
7230
7231 closeSession(session);
7232 }
7233 }
7234
7235 return count.intValue();
7236 }
7237
7238
7245 public List<com.liferay.portlet.asset.model.AssetEntry> getAssetEntries(
7246 long pk) throws SystemException {
7247 return getAssetEntries(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
7248 }
7249
7250
7263 public List<com.liferay.portlet.asset.model.AssetEntry> getAssetEntries(
7264 long pk, int start, int end) throws SystemException {
7265 return getAssetEntries(pk, start, end, null);
7266 }
7267
7268 public static final FinderPath FINDER_PATH_GET_ASSETENTRIES = new FinderPath(com.liferay.portlet.asset.model.impl.AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
7269 AssetCategoryModelImpl.FINDER_CACHE_ENABLED_ASSETENTRIES_ASSETCATEGORIES,
7270 com.liferay.portlet.asset.model.impl.AssetEntryImpl.class,
7271 AssetCategoryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME,
7272 "getAssetEntries",
7273 new String[] {
7274 Long.class.getName(), "java.lang.Integer", "java.lang.Integer",
7275 "com.liferay.portal.kernel.util.OrderByComparator"
7276 });
7277
7278 static {
7279 FINDER_PATH_GET_ASSETENTRIES.setCacheKeyGeneratorCacheName(null);
7280 }
7281
7282
7296 public List<com.liferay.portlet.asset.model.AssetEntry> getAssetEntries(
7297 long pk, int start, int end, OrderByComparator orderByComparator)
7298 throws SystemException {
7299 Object[] finderArgs = new Object[] { pk, start, end, orderByComparator };
7300
7301 List<com.liferay.portlet.asset.model.AssetEntry> list = (List<com.liferay.portlet.asset.model.AssetEntry>)FinderCacheUtil.getResult(FINDER_PATH_GET_ASSETENTRIES,
7302 finderArgs, this);
7303
7304 if (list == null) {
7305 Session session = null;
7306
7307 try {
7308 session = openSession();
7309
7310 String sql = null;
7311
7312 if (orderByComparator != null) {
7313 sql = _SQL_GETASSETENTRIES.concat(ORDER_BY_CLAUSE)
7314 .concat(orderByComparator.getOrderBy());
7315 }
7316 else {
7317 sql = _SQL_GETASSETENTRIES;
7318 }
7319
7320 SQLQuery q = session.createSQLQuery(sql);
7321
7322 q.addEntity("AssetEntry",
7323 com.liferay.portlet.asset.model.impl.AssetEntryImpl.class);
7324
7325 QueryPos qPos = QueryPos.getInstance(q);
7326
7327 qPos.add(pk);
7328
7329 list = (List<com.liferay.portlet.asset.model.AssetEntry>)QueryUtil.list(q,
7330 getDialect(), start, end);
7331 }
7332 catch (Exception e) {
7333 throw processException(e);
7334 }
7335 finally {
7336 if (list == null) {
7337 FinderCacheUtil.removeResult(FINDER_PATH_GET_ASSETENTRIES,
7338 finderArgs);
7339 }
7340 else {
7341 assetEntryPersistence.cacheResult(list);
7342
7343 FinderCacheUtil.putResult(FINDER_PATH_GET_ASSETENTRIES,
7344 finderArgs, list);
7345 }
7346
7347 closeSession(session);
7348 }
7349 }
7350
7351 return list;
7352 }
7353
7354 public static final FinderPath FINDER_PATH_GET_ASSETENTRIES_SIZE = new FinderPath(com.liferay.portlet.asset.model.impl.AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
7355 AssetCategoryModelImpl.FINDER_CACHE_ENABLED_ASSETENTRIES_ASSETCATEGORIES,
7356 Long.class,
7357 AssetCategoryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME,
7358 "getAssetEntriesSize", new String[] { Long.class.getName() });
7359
7360 static {
7361 FINDER_PATH_GET_ASSETENTRIES_SIZE.setCacheKeyGeneratorCacheName(null);
7362 }
7363
7364
7371 public int getAssetEntriesSize(long pk) throws SystemException {
7372 Object[] finderArgs = new Object[] { pk };
7373
7374 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_GET_ASSETENTRIES_SIZE,
7375 finderArgs, this);
7376
7377 if (count == null) {
7378 Session session = null;
7379
7380 try {
7381 session = openSession();
7382
7383 SQLQuery q = session.createSQLQuery(_SQL_GETASSETENTRIESSIZE);
7384
7385 q.addScalar(COUNT_COLUMN_NAME,
7386 com.liferay.portal.kernel.dao.orm.Type.LONG);
7387
7388 QueryPos qPos = QueryPos.getInstance(q);
7389
7390 qPos.add(pk);
7391
7392 count = (Long)q.uniqueResult();
7393 }
7394 catch (Exception e) {
7395 throw processException(e);
7396 }
7397 finally {
7398 if (count == null) {
7399 count = Long.valueOf(0);
7400 }
7401
7402 FinderCacheUtil.putResult(FINDER_PATH_GET_ASSETENTRIES_SIZE,
7403 finderArgs, count);
7404
7405 closeSession(session);
7406 }
7407 }
7408
7409 return count.intValue();
7410 }
7411
7412 public static final FinderPath FINDER_PATH_CONTAINS_ASSETENTRY = new FinderPath(com.liferay.portlet.asset.model.impl.AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
7413 AssetCategoryModelImpl.FINDER_CACHE_ENABLED_ASSETENTRIES_ASSETCATEGORIES,
7414 Boolean.class,
7415 AssetCategoryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME,
7416 "containsAssetEntry",
7417 new String[] { Long.class.getName(), Long.class.getName() });
7418
7419
7427 public boolean containsAssetEntry(long pk, long assetEntryPK)
7428 throws SystemException {
7429 Object[] finderArgs = new Object[] { pk, assetEntryPK };
7430
7431 Boolean value = (Boolean)FinderCacheUtil.getResult(FINDER_PATH_CONTAINS_ASSETENTRY,
7432 finderArgs, this);
7433
7434 if (value == null) {
7435 try {
7436 value = Boolean.valueOf(containsAssetEntry.contains(pk,
7437 assetEntryPK));
7438 }
7439 catch (Exception e) {
7440 throw processException(e);
7441 }
7442 finally {
7443 if (value == null) {
7444 value = Boolean.FALSE;
7445 }
7446
7447 FinderCacheUtil.putResult(FINDER_PATH_CONTAINS_ASSETENTRY,
7448 finderArgs, value);
7449 }
7450 }
7451
7452 return value.booleanValue();
7453 }
7454
7455
7462 public boolean containsAssetEntries(long pk) throws SystemException {
7463 if (getAssetEntriesSize(pk) > 0) {
7464 return true;
7465 }
7466 else {
7467 return false;
7468 }
7469 }
7470
7471
7478 public void addAssetEntry(long pk, long assetEntryPK)
7479 throws SystemException {
7480 try {
7481 addAssetEntry.add(pk, assetEntryPK);
7482 }
7483 catch (Exception e) {
7484 throw processException(e);
7485 }
7486 finally {
7487 FinderCacheUtil.clearCache(AssetCategoryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
7488 }
7489 }
7490
7491
7498 public void addAssetEntry(long pk,
7499 com.liferay.portlet.asset.model.AssetEntry assetEntry)
7500 throws SystemException {
7501 try {
7502 addAssetEntry.add(pk, assetEntry.getPrimaryKey());
7503 }
7504 catch (Exception e) {
7505 throw processException(e);
7506 }
7507 finally {
7508 FinderCacheUtil.clearCache(AssetCategoryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
7509 }
7510 }
7511
7512
7519 public void addAssetEntries(long pk, long[] assetEntryPKs)
7520 throws SystemException {
7521 try {
7522 for (long assetEntryPK : assetEntryPKs) {
7523 addAssetEntry.add(pk, assetEntryPK);
7524 }
7525 }
7526 catch (Exception e) {
7527 throw processException(e);
7528 }
7529 finally {
7530 FinderCacheUtil.clearCache(AssetCategoryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
7531 }
7532 }
7533
7534
7541 public void addAssetEntries(long pk,
7542 List<com.liferay.portlet.asset.model.AssetEntry> assetEntries)
7543 throws SystemException {
7544 try {
7545 for (com.liferay.portlet.asset.model.AssetEntry assetEntry : assetEntries) {
7546 addAssetEntry.add(pk, assetEntry.getPrimaryKey());
7547 }
7548 }
7549 catch (Exception e) {
7550 throw processException(e);
7551 }
7552 finally {
7553 FinderCacheUtil.clearCache(AssetCategoryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
7554 }
7555 }
7556
7557
7563 public void clearAssetEntries(long pk) throws SystemException {
7564 try {
7565 clearAssetEntries.clear(pk);
7566 }
7567 catch (Exception e) {
7568 throw processException(e);
7569 }
7570 finally {
7571 FinderCacheUtil.clearCache(AssetCategoryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
7572 }
7573 }
7574
7575
7582 public void removeAssetEntry(long pk, long assetEntryPK)
7583 throws SystemException {
7584 try {
7585 removeAssetEntry.remove(pk, assetEntryPK);
7586 }
7587 catch (Exception e) {
7588 throw processException(e);
7589 }
7590 finally {
7591 FinderCacheUtil.clearCache(AssetCategoryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
7592 }
7593 }
7594
7595
7602 public void removeAssetEntry(long pk,
7603 com.liferay.portlet.asset.model.AssetEntry assetEntry)
7604 throws SystemException {
7605 try {
7606 removeAssetEntry.remove(pk, assetEntry.getPrimaryKey());
7607 }
7608 catch (Exception e) {
7609 throw processException(e);
7610 }
7611 finally {
7612 FinderCacheUtil.clearCache(AssetCategoryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
7613 }
7614 }
7615
7616
7623 public void removeAssetEntries(long pk, long[] assetEntryPKs)
7624 throws SystemException {
7625 try {
7626 for (long assetEntryPK : assetEntryPKs) {
7627 removeAssetEntry.remove(pk, assetEntryPK);
7628 }
7629 }
7630 catch (Exception e) {
7631 throw processException(e);
7632 }
7633 finally {
7634 FinderCacheUtil.clearCache(AssetCategoryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
7635 }
7636 }
7637
7638
7645 public void removeAssetEntries(long pk,
7646 List<com.liferay.portlet.asset.model.AssetEntry> assetEntries)
7647 throws SystemException {
7648 try {
7649 for (com.liferay.portlet.asset.model.AssetEntry assetEntry : assetEntries) {
7650 removeAssetEntry.remove(pk, assetEntry.getPrimaryKey());
7651 }
7652 }
7653 catch (Exception e) {
7654 throw processException(e);
7655 }
7656 finally {
7657 FinderCacheUtil.clearCache(AssetCategoryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
7658 }
7659 }
7660
7661
7668 public void setAssetEntries(long pk, long[] assetEntryPKs)
7669 throws SystemException {
7670 try {
7671 Set<Long> assetEntryPKSet = SetUtil.fromArray(assetEntryPKs);
7672
7673 List<com.liferay.portlet.asset.model.AssetEntry> assetEntries = getAssetEntries(pk);
7674
7675 for (com.liferay.portlet.asset.model.AssetEntry assetEntry : assetEntries) {
7676 if (!assetEntryPKSet.remove(assetEntry.getPrimaryKey())) {
7677 removeAssetEntry.remove(pk, assetEntry.getPrimaryKey());
7678 }
7679 }
7680
7681 for (Long assetEntryPK : assetEntryPKSet) {
7682 addAssetEntry.add(pk, assetEntryPK);
7683 }
7684 }
7685 catch (Exception e) {
7686 throw processException(e);
7687 }
7688 finally {
7689 FinderCacheUtil.clearCache(AssetCategoryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
7690 }
7691 }
7692
7693
7700 public void setAssetEntries(long pk,
7701 List<com.liferay.portlet.asset.model.AssetEntry> assetEntries)
7702 throws SystemException {
7703 try {
7704 long[] assetEntryPKs = new long[assetEntries.size()];
7705
7706 for (int i = 0; i < assetEntries.size(); i++) {
7707 com.liferay.portlet.asset.model.AssetEntry assetEntry = assetEntries.get(i);
7708
7709 assetEntryPKs[i] = assetEntry.getPrimaryKey();
7710 }
7711
7712 setAssetEntries(pk, assetEntryPKs);
7713 }
7714 catch (Exception e) {
7715 throw processException(e);
7716 }
7717 finally {
7718 FinderCacheUtil.clearCache(AssetCategoryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
7719 }
7720 }
7721
7722
7732 public void rebuildTree(long groupId, boolean force)
7733 throws SystemException {
7734 if (!rebuildTreeEnabled) {
7735 return;
7736 }
7737
7738 if (force || (countOrphanTreeNodes(groupId) > 0)) {
7739 rebuildTree(groupId, 0, 1);
7740
7741 CacheRegistryUtil.clear(AssetCategoryImpl.class.getName());
7742 EntityCacheUtil.clearCache(AssetCategoryImpl.class.getName());
7743 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
7744 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
7745 }
7746 }
7747
7748 public void setRebuildTreeEnabled(boolean rebuildTreeEnabled) {
7749 this.rebuildTreeEnabled = rebuildTreeEnabled;
7750 }
7751
7752 protected long countOrphanTreeNodes(long groupId) throws SystemException {
7753 Session session = null;
7754
7755 try {
7756 session = openSession();
7757
7758 SQLQuery q = session.createSQLQuery(
7759 "SELECT COUNT(*) AS COUNT_VALUE FROM AssetCategory WHERE groupId = ? AND (leftCategoryId = 0 OR leftCategoryId IS NULL OR rightCategoryId = 0 OR rightCategoryId IS NULL)");
7760
7761 q.addScalar(COUNT_COLUMN_NAME,
7762 com.liferay.portal.kernel.dao.orm.Type.LONG);
7763
7764 QueryPos qPos = QueryPos.getInstance(q);
7765
7766 qPos.add(groupId);
7767
7768 return (Long)q.uniqueResult();
7769 }
7770 catch (Exception e) {
7771 throw processException(e);
7772 }
7773 finally {
7774 closeSession(session);
7775 }
7776 }
7777
7778 protected void expandNoChildrenLeftCategoryId(long groupId,
7779 long leftCategoryId, List<Long> childrenCategoryIds, long delta) {
7780 String sql = "UPDATE AssetCategory SET leftcategoryId = (leftcategoryId + ?) WHERE (groupId = ?) AND (leftcategoryId > ?) AND (categoryId NOT IN (" +
7781 StringUtil.merge(childrenCategoryIds) + "))";
7782
7783 SqlUpdate _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
7784 sql,
7785 new int[] {
7786 java.sql.Types.BIGINT, java.sql.Types.BIGINT,
7787 java.sql.Types.BIGINT
7788 });
7789
7790 _sqlUpdate.update(new Object[] { delta, groupId, leftCategoryId });
7791 }
7792
7793 protected void expandNoChildrenRightCategoryId(long groupId,
7794 long rightCategoryId, List<Long> childrenCategoryIds, long delta) {
7795 String sql = "UPDATE AssetCategory SET rightcategoryId = (rightcategoryId + ?) WHERE (groupId = ?) AND (rightcategoryId > ?) AND (categoryId NOT IN (" +
7796 StringUtil.merge(childrenCategoryIds) + "))";
7797
7798 SqlUpdate _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
7799 sql,
7800 new int[] {
7801 java.sql.Types.BIGINT, java.sql.Types.BIGINT,
7802 java.sql.Types.BIGINT
7803 });
7804
7805 _sqlUpdate.update(new Object[] { delta, groupId, rightCategoryId });
7806 }
7807
7808 protected void expandTree(AssetCategory assetCategory,
7809 List<Long> childrenCategoryIds) throws SystemException {
7810 if (!rebuildTreeEnabled) {
7811 return;
7812 }
7813
7814 long groupId = assetCategory.getGroupId();
7815
7816 long lastRightCategoryId = getLastRightCategoryId(groupId,
7817 assetCategory.getParentCategoryId());
7818
7819 long leftCategoryId = 2;
7820 long rightCategoryId = 3;
7821
7822 if (lastRightCategoryId > 0) {
7823 leftCategoryId = lastRightCategoryId + 1;
7824
7825 long childrenDistance = assetCategory.getRightCategoryId() -
7826 assetCategory.getLeftCategoryId();
7827
7828 if (childrenDistance > 1) {
7829 rightCategoryId = leftCategoryId + childrenDistance;
7830
7831 updateChildrenTree(groupId, childrenCategoryIds,
7832 leftCategoryId - assetCategory.getLeftCategoryId());
7833
7834 expandNoChildrenLeftCategoryId(groupId, lastRightCategoryId,
7835 childrenCategoryIds, childrenDistance + 1);
7836 expandNoChildrenRightCategoryId(groupId, lastRightCategoryId,
7837 childrenCategoryIds, childrenDistance + 1);
7838 }
7839 else {
7840 rightCategoryId = lastRightCategoryId + 2;
7841
7842 expandTreeLeftCategoryId.expand(groupId, lastRightCategoryId);
7843 expandTreeRightCategoryId.expand(groupId, lastRightCategoryId);
7844 }
7845
7846 CacheRegistryUtil.clear(AssetCategoryImpl.class.getName());
7847 EntityCacheUtil.clearCache(AssetCategoryImpl.class.getName());
7848 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
7849 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
7850 }
7851
7852 assetCategory.setLeftCategoryId(leftCategoryId);
7853 assetCategory.setRightCategoryId(rightCategoryId);
7854 }
7855
7856 protected List<Long> getChildrenTreeCategoryIds(
7857 AssetCategory parentAssetCategory) throws SystemException {
7858 Session session = null;
7859
7860 try {
7861 session = openSession();
7862
7863 SQLQuery q = session.createSQLQuery(
7864 "SELECT categoryId FROM AssetCategory WHERE (groupId = ?) AND (leftcategoryId BETWEEN ? AND ?)");
7865
7866 q.addScalar("CategoryId",
7867 com.liferay.portal.kernel.dao.orm.Type.LONG);
7868
7869 QueryPos qPos = QueryPos.getInstance(q);
7870
7871 qPos.add(parentAssetCategory.getGroupId());
7872 qPos.add(parentAssetCategory.getLeftCategoryId() + 1);
7873 qPos.add(parentAssetCategory.getRightCategoryId());
7874
7875 return q.list();
7876 }
7877 catch (Exception e) {
7878 throw processException(e);
7879 }
7880 finally {
7881 closeSession(session);
7882 }
7883 }
7884
7885 protected long getLastRightCategoryId(long groupId, long parentCategoryId)
7886 throws SystemException {
7887 Session session = null;
7888
7889 try {
7890 session = openSession();
7891
7892 SQLQuery q = session.createSQLQuery(
7893 "SELECT rightCategoryId FROM AssetCategory WHERE (groupId = ?) AND (parentCategoryId = ?) ORDER BY rightCategoryId DESC");
7894
7895 q.addScalar("rightCategoryId",
7896 com.liferay.portal.kernel.dao.orm.Type.LONG);
7897
7898 QueryPos qPos = QueryPos.getInstance(q);
7899
7900 qPos.add(groupId);
7901 qPos.add(parentCategoryId);
7902
7903 List<Long> list = (List<Long>)QueryUtil.list(q, getDialect(), 0, 1);
7904
7905 if (list.isEmpty()) {
7906 if (parentCategoryId > 0) {
7907 session.clear();
7908
7909 AssetCategory parentAssetCategory = findByPrimaryKey(parentCategoryId);
7910
7911 return parentAssetCategory.getLeftCategoryId();
7912 }
7913
7914 return 0;
7915 }
7916 else {
7917 return list.get(0);
7918 }
7919 }
7920 catch (Exception e) {
7921 throw processException(e);
7922 }
7923 finally {
7924 closeSession(session);
7925 }
7926 }
7927
7928 protected long rebuildTree(long groupId, long parentCategoryId,
7929 long leftCategoryId) throws SystemException {
7930 if (!rebuildTreeEnabled) {
7931 return 0;
7932 }
7933
7934 List<Long> categoryIds = null;
7935
7936 Session session = null;
7937
7938 try {
7939 session = openSession();
7940
7941 SQLQuery q = session.createSQLQuery(
7942 "SELECT categoryId FROM AssetCategory WHERE groupId = ? AND parentCategoryId = ? ORDER BY categoryId ASC");
7943
7944 q.addScalar("categoryId",
7945 com.liferay.portal.kernel.dao.orm.Type.LONG);
7946
7947 QueryPos qPos = QueryPos.getInstance(q);
7948
7949 qPos.add(groupId);
7950 qPos.add(parentCategoryId);
7951
7952 categoryIds = q.list();
7953 }
7954 catch (Exception e) {
7955 throw processException(e);
7956 }
7957 finally {
7958 closeSession(session);
7959 }
7960
7961 long rightCategoryId = leftCategoryId + 1;
7962
7963 for (long categoryId : categoryIds) {
7964 rightCategoryId = rebuildTree(groupId, categoryId, rightCategoryId);
7965 }
7966
7967 if (parentCategoryId > 0) {
7968 updateTree.update(parentCategoryId, leftCategoryId, rightCategoryId);
7969 }
7970
7971 return rightCategoryId + 1;
7972 }
7973
7974 protected void shrinkTree(AssetCategory assetCategory) {
7975 if (!rebuildTreeEnabled) {
7976 return;
7977 }
7978
7979 long groupId = assetCategory.getGroupId();
7980
7981 long leftCategoryId = assetCategory.getLeftCategoryId();
7982 long rightCategoryId = assetCategory.getRightCategoryId();
7983
7984 long delta = (rightCategoryId - leftCategoryId) + 1;
7985
7986 shrinkTreeLeftCategoryId.shrink(groupId, rightCategoryId, delta);
7987 shrinkTreeRightCategoryId.shrink(groupId, rightCategoryId, delta);
7988
7989 CacheRegistryUtil.clear(AssetCategoryImpl.class.getName());
7990 EntityCacheUtil.clearCache(AssetCategoryImpl.class.getName());
7991 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
7992 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
7993 }
7994
7995 protected void updateChildrenTree(long groupId,
7996 List<Long> childrenCategoryIds, long delta) {
7997 String sql = "UPDATE AssetCategory SET leftcategoryId = (leftcategoryId + ?), rightcategoryId = (rightcategoryId + ?) WHERE (groupId = ?) AND (categoryId IN (" +
7998 StringUtil.merge(childrenCategoryIds) + "))";
7999
8000 SqlUpdate _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
8001 sql,
8002 new int[] {
8003 java.sql.Types.BIGINT, java.sql.Types.BIGINT,
8004 java.sql.Types.BIGINT
8005 });
8006
8007 _sqlUpdate.update(new Object[] { delta, delta, groupId });
8008 }
8009
8010
8013 public void afterPropertiesSet() {
8014 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
8015 com.liferay.portal.util.PropsUtil.get(
8016 "value.object.listener.com.liferay.portlet.asset.model.AssetCategory")));
8017
8018 if (listenerClassNames.length > 0) {
8019 try {
8020 List<ModelListener<AssetCategory>> listenersList = new ArrayList<ModelListener<AssetCategory>>();
8021
8022 for (String listenerClassName : listenerClassNames) {
8023 listenersList.add((ModelListener<AssetCategory>)InstanceFactory.newInstance(
8024 listenerClassName));
8025 }
8026
8027 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
8028 }
8029 catch (Exception e) {
8030 _log.error(e);
8031 }
8032 }
8033
8034 containsAssetEntry = new ContainsAssetEntry();
8035
8036 addAssetEntry = new AddAssetEntry();
8037 clearAssetEntries = new ClearAssetEntries();
8038 removeAssetEntry = new RemoveAssetEntry();
8039
8040 expandTreeLeftCategoryId = new ExpandTreeLeftCategoryId();
8041 expandTreeRightCategoryId = new ExpandTreeRightCategoryId();
8042 shrinkTreeLeftCategoryId = new ShrinkTreeLeftCategoryId();
8043 shrinkTreeRightCategoryId = new ShrinkTreeRightCategoryId();
8044 updateTree = new UpdateTree();
8045 }
8046
8047 public void destroy() {
8048 EntityCacheUtil.removeCache(AssetCategoryImpl.class.getName());
8049 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
8050 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
8051 }
8052
8053 @BeanReference(type = AssetCategoryPersistence.class)
8054 protected AssetCategoryPersistence assetCategoryPersistence;
8055 @BeanReference(type = AssetCategoryPropertyPersistence.class)
8056 protected AssetCategoryPropertyPersistence assetCategoryPropertyPersistence;
8057 @BeanReference(type = AssetEntryPersistence.class)
8058 protected AssetEntryPersistence assetEntryPersistence;
8059 @BeanReference(type = AssetLinkPersistence.class)
8060 protected AssetLinkPersistence assetLinkPersistence;
8061 @BeanReference(type = AssetTagPersistence.class)
8062 protected AssetTagPersistence assetTagPersistence;
8063 @BeanReference(type = AssetTagPropertyPersistence.class)
8064 protected AssetTagPropertyPersistence assetTagPropertyPersistence;
8065 @BeanReference(type = AssetTagStatsPersistence.class)
8066 protected AssetTagStatsPersistence assetTagStatsPersistence;
8067 @BeanReference(type = AssetVocabularyPersistence.class)
8068 protected AssetVocabularyPersistence assetVocabularyPersistence;
8069 @BeanReference(type = ResourcePersistence.class)
8070 protected ResourcePersistence resourcePersistence;
8071 @BeanReference(type = UserPersistence.class)
8072 protected UserPersistence userPersistence;
8073 protected ContainsAssetEntry containsAssetEntry;
8074 protected AddAssetEntry addAssetEntry;
8075 protected ClearAssetEntries clearAssetEntries;
8076 protected RemoveAssetEntry removeAssetEntry;
8077
8078 protected class ContainsAssetEntry {
8079 protected ContainsAssetEntry() {
8080 _mappingSqlQuery = MappingSqlQueryFactoryUtil.getMappingSqlQuery(getDataSource(),
8081 _SQL_CONTAINSASSETENTRY,
8082 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT },
8083 RowMapper.COUNT);
8084 }
8085
8086 protected boolean contains(long categoryId, long entryId) {
8087 List<Integer> results = _mappingSqlQuery.execute(new Object[] {
8088 new Long(categoryId), new Long(entryId)
8089 });
8090
8091 if (results.size() > 0) {
8092 Integer count = results.get(0);
8093
8094 if (count.intValue() > 0) {
8095 return true;
8096 }
8097 }
8098
8099 return false;
8100 }
8101
8102 private MappingSqlQuery<Integer> _mappingSqlQuery;
8103 }
8104
8105 protected class AddAssetEntry {
8106 protected AddAssetEntry() {
8107 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
8108 "INSERT INTO AssetEntries_AssetCategories (categoryId, entryId) VALUES (?, ?)",
8109 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
8110 }
8111
8112 protected void add(long categoryId, long entryId)
8113 throws SystemException {
8114 if (!containsAssetEntry.contains(categoryId, entryId)) {
8115 ModelListener<com.liferay.portlet.asset.model.AssetEntry>[] assetEntryListeners =
8116 assetEntryPersistence.getListeners();
8117
8118 for (ModelListener<AssetCategory> listener : listeners) {
8119 listener.onBeforeAddAssociation(categoryId,
8120 com.liferay.portlet.asset.model.AssetEntry.class.getName(),
8121 entryId);
8122 }
8123
8124 for (ModelListener<com.liferay.portlet.asset.model.AssetEntry> listener : assetEntryListeners) {
8125 listener.onBeforeAddAssociation(entryId,
8126 AssetCategory.class.getName(), categoryId);
8127 }
8128
8129 _sqlUpdate.update(new Object[] {
8130 new Long(categoryId), new Long(entryId)
8131 });
8132
8133 for (ModelListener<AssetCategory> listener : listeners) {
8134 listener.onAfterAddAssociation(categoryId,
8135 com.liferay.portlet.asset.model.AssetEntry.class.getName(),
8136 entryId);
8137 }
8138
8139 for (ModelListener<com.liferay.portlet.asset.model.AssetEntry> listener : assetEntryListeners) {
8140 listener.onAfterAddAssociation(entryId,
8141 AssetCategory.class.getName(), categoryId);
8142 }
8143 }
8144 }
8145
8146 private SqlUpdate _sqlUpdate;
8147 }
8148
8149 protected class ClearAssetEntries {
8150 protected ClearAssetEntries() {
8151 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
8152 "DELETE FROM AssetEntries_AssetCategories WHERE categoryId = ?",
8153 new int[] { java.sql.Types.BIGINT });
8154 }
8155
8156 protected void clear(long categoryId) throws SystemException {
8157 ModelListener<com.liferay.portlet.asset.model.AssetEntry>[] assetEntryListeners =
8158 assetEntryPersistence.getListeners();
8159
8160 List<com.liferay.portlet.asset.model.AssetEntry> assetEntries = null;
8161
8162 if ((listeners.length > 0) || (assetEntryListeners.length > 0)) {
8163 assetEntries = getAssetEntries(categoryId);
8164
8165 for (com.liferay.portlet.asset.model.AssetEntry assetEntry : assetEntries) {
8166 for (ModelListener<AssetCategory> listener : listeners) {
8167 listener.onBeforeRemoveAssociation(categoryId,
8168 com.liferay.portlet.asset.model.AssetEntry.class.getName(),
8169 assetEntry.getPrimaryKey());
8170 }
8171
8172 for (ModelListener<com.liferay.portlet.asset.model.AssetEntry> listener : assetEntryListeners) {
8173 listener.onBeforeRemoveAssociation(assetEntry.getPrimaryKey(),
8174 AssetCategory.class.getName(), categoryId);
8175 }
8176 }
8177 }
8178
8179 _sqlUpdate.update(new Object[] { new Long(categoryId) });
8180
8181 if ((listeners.length > 0) || (assetEntryListeners.length > 0)) {
8182 for (com.liferay.portlet.asset.model.AssetEntry assetEntry : assetEntries) {
8183 for (ModelListener<AssetCategory> listener : listeners) {
8184 listener.onAfterRemoveAssociation(categoryId,
8185 com.liferay.portlet.asset.model.AssetEntry.class.getName(),
8186 assetEntry.getPrimaryKey());
8187 }
8188
8189 for (ModelListener<com.liferay.portlet.asset.model.AssetEntry> listener : assetEntryListeners) {
8190 listener.onAfterRemoveAssociation(assetEntry.getPrimaryKey(),
8191 AssetCategory.class.getName(), categoryId);
8192 }
8193 }
8194 }
8195 }
8196
8197 private SqlUpdate _sqlUpdate;
8198 }
8199
8200 protected class RemoveAssetEntry {
8201 protected RemoveAssetEntry() {
8202 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
8203 "DELETE FROM AssetEntries_AssetCategories WHERE categoryId = ? AND entryId = ?",
8204 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
8205 }
8206
8207 protected void remove(long categoryId, long entryId)
8208 throws SystemException {
8209 if (containsAssetEntry.contains(categoryId, entryId)) {
8210 ModelListener<com.liferay.portlet.asset.model.AssetEntry>[] assetEntryListeners =
8211 assetEntryPersistence.getListeners();
8212
8213 for (ModelListener<AssetCategory> listener : listeners) {
8214 listener.onBeforeRemoveAssociation(categoryId,
8215 com.liferay.portlet.asset.model.AssetEntry.class.getName(),
8216 entryId);
8217 }
8218
8219 for (ModelListener<com.liferay.portlet.asset.model.AssetEntry> listener : assetEntryListeners) {
8220 listener.onBeforeRemoveAssociation(entryId,
8221 AssetCategory.class.getName(), categoryId);
8222 }
8223
8224 _sqlUpdate.update(new Object[] {
8225 new Long(categoryId), new Long(entryId)
8226 });
8227
8228 for (ModelListener<AssetCategory> listener : listeners) {
8229 listener.onAfterRemoveAssociation(categoryId,
8230 com.liferay.portlet.asset.model.AssetEntry.class.getName(),
8231 entryId);
8232 }
8233
8234 for (ModelListener<com.liferay.portlet.asset.model.AssetEntry> listener : assetEntryListeners) {
8235 listener.onAfterRemoveAssociation(entryId,
8236 AssetCategory.class.getName(), categoryId);
8237 }
8238 }
8239 }
8240
8241 private SqlUpdate _sqlUpdate;
8242 }
8243
8244 protected boolean rebuildTreeEnabled = true;
8245 protected ExpandTreeLeftCategoryId expandTreeLeftCategoryId;
8246 protected ExpandTreeRightCategoryId expandTreeRightCategoryId;
8247 protected ShrinkTreeLeftCategoryId shrinkTreeLeftCategoryId;
8248 protected ShrinkTreeRightCategoryId shrinkTreeRightCategoryId;
8249 protected UpdateTree updateTree;
8250
8251 protected class ExpandTreeLeftCategoryId {
8252 protected ExpandTreeLeftCategoryId() {
8253 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
8254 "UPDATE AssetCategory SET leftCategoryId = (leftCategoryId + 2) WHERE (groupId = ?) AND (leftCategoryId > ?)",
8255 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
8256 }
8257
8258 protected void expand(long groupId, long leftCategoryId) {
8259 _sqlUpdate.update(new Object[] { groupId, leftCategoryId });
8260 }
8261
8262 private SqlUpdate _sqlUpdate;
8263 }
8264
8265 protected class ExpandTreeRightCategoryId {
8266 protected ExpandTreeRightCategoryId() {
8267 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
8268 "UPDATE AssetCategory SET rightCategoryId = (rightCategoryId + 2) WHERE (groupId = ?) AND (rightCategoryId > ?)",
8269 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
8270 }
8271
8272 protected void expand(long groupId, long rightCategoryId) {
8273 _sqlUpdate.update(new Object[] { groupId, rightCategoryId });
8274 }
8275
8276 private SqlUpdate _sqlUpdate;
8277 }
8278
8279 protected class ShrinkTreeLeftCategoryId {
8280 protected ShrinkTreeLeftCategoryId() {
8281 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
8282 "UPDATE AssetCategory SET leftCategoryId = (leftCategoryId - ?) WHERE (groupId = ?) AND (leftCategoryId > ?)",
8283 new int[] {
8284 java.sql.Types.BIGINT, java.sql.Types.BIGINT,
8285 java.sql.Types.BIGINT
8286 });
8287 }
8288
8289 protected void shrink(long groupId, long leftCategoryId, long delta) {
8290 _sqlUpdate.update(new Object[] { delta, groupId, leftCategoryId });
8291 }
8292
8293 private SqlUpdate _sqlUpdate;
8294 }
8295
8296 protected class ShrinkTreeRightCategoryId {
8297 protected ShrinkTreeRightCategoryId() {
8298 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
8299 "UPDATE AssetCategory SET rightCategoryId = (rightCategoryId - ?) WHERE (groupId = ?) AND (rightCategoryId > ?)",
8300 new int[] {
8301 java.sql.Types.BIGINT, java.sql.Types.BIGINT,
8302 java.sql.Types.BIGINT
8303 });
8304 }
8305
8306 protected void shrink(long groupId, long rightCategoryId, long delta) {
8307 _sqlUpdate.update(new Object[] { delta, groupId, rightCategoryId });
8308 }
8309
8310 private SqlUpdate _sqlUpdate;
8311 }
8312
8313 protected class UpdateTree {
8314 protected UpdateTree() {
8315 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
8316 "UPDATE AssetCategory SET leftCategoryId = ?, rightCategoryId = ? WHERE categoryId = ?",
8317 new int[] {
8318 java.sql.Types.BIGINT, java.sql.Types.BIGINT,
8319 java.sql.Types.BIGINT
8320 });
8321 }
8322
8323 protected void update(long categoryId, long leftCategoryId,
8324 long rightCategoryId) {
8325 _sqlUpdate.update(new Object[] {
8326 leftCategoryId, rightCategoryId, categoryId
8327 });
8328 }
8329
8330 private SqlUpdate _sqlUpdate;
8331 }
8332
8333 private static final String _SQL_SELECT_ASSETCATEGORY = "SELECT assetCategory FROM AssetCategory assetCategory";
8334 private static final String _SQL_SELECT_ASSETCATEGORY_WHERE = "SELECT assetCategory FROM AssetCategory assetCategory WHERE ";
8335 private static final String _SQL_COUNT_ASSETCATEGORY = "SELECT COUNT(assetCategory) FROM AssetCategory assetCategory";
8336 private static final String _SQL_COUNT_ASSETCATEGORY_WHERE = "SELECT COUNT(assetCategory) FROM AssetCategory assetCategory WHERE ";
8337 private static final String _SQL_GETASSETENTRIES = "SELECT {AssetEntry.*} FROM AssetEntry INNER JOIN AssetEntries_AssetCategories ON (AssetEntries_AssetCategories.entryId = AssetEntry.entryId) WHERE (AssetEntries_AssetCategories.categoryId = ?)";
8338 private static final String _SQL_GETASSETENTRIESSIZE = "SELECT COUNT(*) AS COUNT_VALUE FROM AssetEntries_AssetCategories WHERE categoryId = ?";
8339 private static final String _SQL_CONTAINSASSETENTRY = "SELECT COUNT(*) AS COUNT_VALUE FROM AssetEntries_AssetCategories WHERE categoryId = ? AND entryId = ?";
8340 private static final String _FINDER_COLUMN_UUID_UUID_1 = "assetCategory.uuid IS NULL";
8341 private static final String _FINDER_COLUMN_UUID_UUID_2 = "assetCategory.uuid = ?";
8342 private static final String _FINDER_COLUMN_UUID_UUID_3 = "(assetCategory.uuid IS NULL OR assetCategory.uuid = ?)";
8343 private static final String _FINDER_COLUMN_UUID_G_UUID_1 = "assetCategory.uuid IS NULL AND ";
8344 private static final String _FINDER_COLUMN_UUID_G_UUID_2 = "assetCategory.uuid = ? AND ";
8345 private static final String _FINDER_COLUMN_UUID_G_UUID_3 = "(assetCategory.uuid IS NULL OR assetCategory.uuid = ?) AND ";
8346 private static final String _FINDER_COLUMN_UUID_G_GROUPID_2 = "assetCategory.groupId = ?";
8347 private static final String _FINDER_COLUMN_GROUPID_GROUPID_2 = "assetCategory.groupId = ?";
8348 private static final String _FINDER_COLUMN_PARENTCATEGORYID_PARENTCATEGORYID_2 =
8349 "assetCategory.parentCategoryId = ?";
8350 private static final String _FINDER_COLUMN_VOCABULARYID_VOCABULARYID_2 = "assetCategory.vocabularyId = ?";
8351 private static final String _FINDER_COLUMN_G_V_GROUPID_2 = "assetCategory.groupId = ? AND ";
8352 private static final String _FINDER_COLUMN_G_V_VOCABULARYID_2 = "assetCategory.vocabularyId = ?";
8353 private static final String _FINDER_COLUMN_P_N_PARENTCATEGORYID_2 = "assetCategory.parentCategoryId = ? AND ";
8354 private static final String _FINDER_COLUMN_P_N_NAME_1 = "assetCategory.name IS NULL";
8355 private static final String _FINDER_COLUMN_P_N_NAME_2 = "assetCategory.name = ?";
8356 private static final String _FINDER_COLUMN_P_N_NAME_3 = "(assetCategory.name IS NULL OR assetCategory.name = ?)";
8357 private static final String _FINDER_COLUMN_P_V_PARENTCATEGORYID_2 = "assetCategory.parentCategoryId = ? AND ";
8358 private static final String _FINDER_COLUMN_P_V_VOCABULARYID_2 = "assetCategory.vocabularyId = ?";
8359 private static final String _FINDER_COLUMN_N_V_NAME_1 = "assetCategory.name IS NULL AND ";
8360 private static final String _FINDER_COLUMN_N_V_NAME_2 = "assetCategory.name = ? AND ";
8361 private static final String _FINDER_COLUMN_N_V_NAME_3 = "(assetCategory.name IS NULL OR assetCategory.name = ?) AND ";
8362 private static final String _FINDER_COLUMN_N_V_VOCABULARYID_2 = "assetCategory.vocabularyId = ?";
8363 private static final String _FINDER_COLUMN_G_P_N_GROUPID_2 = "assetCategory.groupId = ? AND ";
8364 private static final String _FINDER_COLUMN_G_P_N_PARENTCATEGORYID_2 = "assetCategory.parentCategoryId = ? AND ";
8365 private static final String _FINDER_COLUMN_G_P_N_NAME_1 = "assetCategory.name IS NULL";
8366 private static final String _FINDER_COLUMN_G_P_N_NAME_2 = "assetCategory.name = ?";
8367 private static final String _FINDER_COLUMN_G_P_N_NAME_3 = "(assetCategory.name IS NULL OR assetCategory.name = ?)";
8368 private static final String _FINDER_COLUMN_P_N_V_PARENTCATEGORYID_2 = "assetCategory.parentCategoryId = ? AND ";
8369 private static final String _FINDER_COLUMN_P_N_V_NAME_1 = "assetCategory.name IS NULL AND ";
8370 private static final String _FINDER_COLUMN_P_N_V_NAME_2 = "assetCategory.name = ? AND ";
8371 private static final String _FINDER_COLUMN_P_N_V_NAME_3 = "(assetCategory.name IS NULL OR assetCategory.name = ?) AND ";
8372 private static final String _FINDER_COLUMN_P_N_V_VOCABULARYID_2 = "assetCategory.vocabularyId = ?";
8373 private static final String _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN = "assetCategory.categoryId";
8374 private static final String _FILTER_SQL_SELECT_ASSETCATEGORY_WHERE = "SELECT DISTINCT {assetCategory.*} FROM AssetCategory assetCategory WHERE ";
8375 private static final String _FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_1 =
8376 "SELECT {AssetCategory.*} FROM (SELECT DISTINCT assetCategory.categoryId FROM AssetCategory assetCategory WHERE ";
8377 private static final String _FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_2 =
8378 ") TEMP_TABLE INNER JOIN AssetCategory ON TEMP_TABLE.categoryId = AssetCategory.categoryId";
8379 private static final String _FILTER_SQL_COUNT_ASSETCATEGORY_WHERE = "SELECT COUNT(DISTINCT assetCategory.categoryId) AS COUNT_VALUE FROM AssetCategory assetCategory WHERE ";
8380 private static final String _FILTER_ENTITY_ALIAS = "assetCategory";
8381 private static final String _FILTER_ENTITY_TABLE = "AssetCategory";
8382 private static final String _ORDER_BY_ENTITY_ALIAS = "assetCategory.";
8383 private static final String _ORDER_BY_ENTITY_TABLE = "AssetCategory.";
8384 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No AssetCategory exists with the primary key ";
8385 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No AssetCategory exists with the key {";
8386 private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
8387 private static Log _log = LogFactoryUtil.getLog(AssetCategoryPersistenceImpl.class);
8388 private static AssetCategory _nullAssetCategory = new AssetCategoryImpl() {
8389 @Override
8390 public Object clone() {
8391 return this;
8392 }
8393
8394 @Override
8395 public CacheModel<AssetCategory> toCacheModel() {
8396 return _nullAssetCategoryCacheModel;
8397 }
8398 };
8399
8400 private static CacheModel<AssetCategory> _nullAssetCategoryCacheModel = new CacheModel<AssetCategory>() {
8401 public AssetCategory toEntityModel() {
8402 return _nullAssetCategory;
8403 }
8404 };
8405 }