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.UserPersistence;
049 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
050
051 import com.liferay.portlet.asset.NoSuchCategoryException;
052 import com.liferay.portlet.asset.model.AssetCategory;
053 import com.liferay.portlet.asset.model.impl.AssetCategoryImpl;
054 import com.liferay.portlet.asset.model.impl.AssetCategoryModelImpl;
055
056 import java.io.Serializable;
057
058 import java.util.ArrayList;
059 import java.util.Collections;
060 import java.util.List;
061 import java.util.Set;
062
063
075 public class AssetCategoryPersistenceImpl extends BasePersistenceImpl<AssetCategory>
076 implements AssetCategoryPersistence {
077
082 public static final String FINDER_CLASS_NAME_ENTITY = AssetCategoryImpl.class.getName();
083 public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
084 ".List1";
085 public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
086 ".List2";
087 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
088 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
089 AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
090 "findByUuid",
091 new String[] {
092 String.class.getName(),
093
094 "java.lang.Integer", "java.lang.Integer",
095 "com.liferay.portal.kernel.util.OrderByComparator"
096 });
097 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
098 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
099 AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
100 "findByUuid", new String[] { String.class.getName() },
101 AssetCategoryModelImpl.UUID_COLUMN_BITMASK);
102 public static final FinderPath FINDER_PATH_COUNT_BY_UUID = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
103 AssetCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class,
104 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid",
105 new String[] { String.class.getName() });
106 public static final FinderPath FINDER_PATH_FETCH_BY_UUID_G = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
107 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
108 AssetCategoryImpl.class, FINDER_CLASS_NAME_ENTITY, "fetchByUUID_G",
109 new String[] { String.class.getName(), Long.class.getName() },
110 AssetCategoryModelImpl.UUID_COLUMN_BITMASK |
111 AssetCategoryModelImpl.GROUPID_COLUMN_BITMASK);
112 public static final FinderPath FINDER_PATH_COUNT_BY_UUID_G = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
113 AssetCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class,
114 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUUID_G",
115 new String[] { String.class.getName(), Long.class.getName() });
116 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID_C = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
117 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
118 AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
119 "findByUuid_C",
120 new String[] {
121 String.class.getName(), Long.class.getName(),
122
123 "java.lang.Integer", "java.lang.Integer",
124 "com.liferay.portal.kernel.util.OrderByComparator"
125 });
126 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C =
127 new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
128 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
129 AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
130 "findByUuid_C",
131 new String[] { String.class.getName(), Long.class.getName() },
132 AssetCategoryModelImpl.UUID_COLUMN_BITMASK |
133 AssetCategoryModelImpl.COMPANYID_COLUMN_BITMASK);
134 public static final FinderPath FINDER_PATH_COUNT_BY_UUID_C = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
135 AssetCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class,
136 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid_C",
137 new String[] { String.class.getName(), Long.class.getName() });
138 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
139 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
140 AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
141 "findByGroupId",
142 new String[] {
143 Long.class.getName(),
144
145 "java.lang.Integer", "java.lang.Integer",
146 "com.liferay.portal.kernel.util.OrderByComparator"
147 });
148 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID =
149 new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
150 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
151 AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
152 "findByGroupId", new String[] { Long.class.getName() },
153 AssetCategoryModelImpl.GROUPID_COLUMN_BITMASK);
154 public static final FinderPath FINDER_PATH_COUNT_BY_GROUPID = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
155 AssetCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class,
156 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByGroupId",
157 new String[] { Long.class.getName() });
158 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_PARENTCATEGORYID =
159 new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
160 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
161 AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
162 "findByParentCategoryId",
163 new String[] {
164 Long.class.getName(),
165
166 "java.lang.Integer", "java.lang.Integer",
167 "com.liferay.portal.kernel.util.OrderByComparator"
168 });
169 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_PARENTCATEGORYID =
170 new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
171 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
172 AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
173 "findByParentCategoryId", new String[] { Long.class.getName() },
174 AssetCategoryModelImpl.PARENTCATEGORYID_COLUMN_BITMASK);
175 public static final FinderPath FINDER_PATH_COUNT_BY_PARENTCATEGORYID = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
176 AssetCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class,
177 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
178 "countByParentCategoryId", new String[] { Long.class.getName() });
179 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_VOCABULARYID =
180 new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
181 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
182 AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
183 "findByVocabularyId",
184 new String[] {
185 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_VOCABULARYID =
191 new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
192 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
193 AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
194 "findByVocabularyId", new String[] { Long.class.getName() },
195 AssetCategoryModelImpl.VOCABULARYID_COLUMN_BITMASK);
196 public static final FinderPath FINDER_PATH_COUNT_BY_VOCABULARYID = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
197 AssetCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class,
198 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByVocabularyId",
199 new String[] { Long.class.getName() });
200 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
201 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
202 AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
203 "findByG_V",
204 new String[] {
205 Long.class.getName(), Long.class.getName(),
206
207 "java.lang.Integer", "java.lang.Integer",
208 "com.liferay.portal.kernel.util.OrderByComparator"
209 });
210 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
211 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
212 AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
213 "findByG_V",
214 new String[] { Long.class.getName(), Long.class.getName() },
215 AssetCategoryModelImpl.GROUPID_COLUMN_BITMASK |
216 AssetCategoryModelImpl.VOCABULARYID_COLUMN_BITMASK);
217 public static final FinderPath FINDER_PATH_COUNT_BY_G_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
218 AssetCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class,
219 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_V",
220 new String[] { Long.class.getName(), Long.class.getName() });
221 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_P_N = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
222 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
223 AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
224 "findByP_N",
225 new String[] {
226 Long.class.getName(), String.class.getName(),
227
228 "java.lang.Integer", "java.lang.Integer",
229 "com.liferay.portal.kernel.util.OrderByComparator"
230 });
231 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_P_N = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
232 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
233 AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
234 "findByP_N",
235 new String[] { Long.class.getName(), String.class.getName() },
236 AssetCategoryModelImpl.PARENTCATEGORYID_COLUMN_BITMASK |
237 AssetCategoryModelImpl.NAME_COLUMN_BITMASK);
238 public static final FinderPath FINDER_PATH_COUNT_BY_P_N = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
239 AssetCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class,
240 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByP_N",
241 new String[] { Long.class.getName(), String.class.getName() });
242 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_P_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
243 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
244 AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
245 "findByP_V",
246 new String[] {
247 Long.class.getName(), Long.class.getName(),
248
249 "java.lang.Integer", "java.lang.Integer",
250 "com.liferay.portal.kernel.util.OrderByComparator"
251 });
252 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_P_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
253 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
254 AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
255 "findByP_V",
256 new String[] { Long.class.getName(), Long.class.getName() },
257 AssetCategoryModelImpl.PARENTCATEGORYID_COLUMN_BITMASK |
258 AssetCategoryModelImpl.VOCABULARYID_COLUMN_BITMASK);
259 public static final FinderPath FINDER_PATH_COUNT_BY_P_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
260 AssetCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class,
261 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByP_V",
262 new String[] { Long.class.getName(), Long.class.getName() });
263 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_N_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
264 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
265 AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
266 "findByN_V",
267 new String[] {
268 String.class.getName(), Long.class.getName(),
269
270 "java.lang.Integer", "java.lang.Integer",
271 "com.liferay.portal.kernel.util.OrderByComparator"
272 });
273 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
274 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
275 AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
276 "findByN_V",
277 new String[] { String.class.getName(), Long.class.getName() },
278 AssetCategoryModelImpl.NAME_COLUMN_BITMASK |
279 AssetCategoryModelImpl.VOCABULARYID_COLUMN_BITMASK);
280 public static final FinderPath FINDER_PATH_COUNT_BY_N_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
281 AssetCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class,
282 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByN_V",
283 new String[] { String.class.getName(), Long.class.getName() });
284 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_P_N = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
285 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
286 AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
287 "findByG_P_N",
288 new String[] {
289 Long.class.getName(), Long.class.getName(),
290 String.class.getName(),
291
292 "java.lang.Integer", "java.lang.Integer",
293 "com.liferay.portal.kernel.util.OrderByComparator"
294 });
295 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_N = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
296 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
297 AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
298 "findByG_P_N",
299 new String[] {
300 Long.class.getName(), Long.class.getName(),
301 String.class.getName()
302 },
303 AssetCategoryModelImpl.GROUPID_COLUMN_BITMASK |
304 AssetCategoryModelImpl.PARENTCATEGORYID_COLUMN_BITMASK |
305 AssetCategoryModelImpl.NAME_COLUMN_BITMASK);
306 public static final FinderPath FINDER_PATH_COUNT_BY_G_P_N = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
307 AssetCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class,
308 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_P_N",
309 new String[] {
310 Long.class.getName(), Long.class.getName(),
311 String.class.getName()
312 });
313 public static final FinderPath FINDER_PATH_FETCH_BY_P_N_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
314 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
315 AssetCategoryImpl.class, FINDER_CLASS_NAME_ENTITY, "fetchByP_N_V",
316 new String[] {
317 Long.class.getName(), String.class.getName(),
318 Long.class.getName()
319 },
320 AssetCategoryModelImpl.PARENTCATEGORYID_COLUMN_BITMASK |
321 AssetCategoryModelImpl.NAME_COLUMN_BITMASK |
322 AssetCategoryModelImpl.VOCABULARYID_COLUMN_BITMASK);
323 public static final FinderPath FINDER_PATH_COUNT_BY_P_N_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
324 AssetCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class,
325 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByP_N_V",
326 new String[] {
327 Long.class.getName(), String.class.getName(),
328 Long.class.getName()
329 });
330 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
331 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
332 AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
333 "findAll", new String[0]);
334 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
335 AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
336 AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
337 "findAll", new String[0]);
338 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
339 AssetCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class,
340 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
341
342
347 public void cacheResult(AssetCategory assetCategory) {
348 EntityCacheUtil.putResult(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
349 AssetCategoryImpl.class, assetCategory.getPrimaryKey(),
350 assetCategory);
351
352 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
353 new Object[] {
354 assetCategory.getUuid(),
355 Long.valueOf(assetCategory.getGroupId())
356 }, assetCategory);
357
358 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_P_N_V,
359 new Object[] {
360 Long.valueOf(assetCategory.getParentCategoryId()),
361
362 assetCategory.getName(),
363 Long.valueOf(assetCategory.getVocabularyId())
364 }, assetCategory);
365
366 assetCategory.resetOriginalValues();
367 }
368
369
374 public void cacheResult(List<AssetCategory> assetCategories) {
375 for (AssetCategory assetCategory : assetCategories) {
376 if (EntityCacheUtil.getResult(
377 AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
378 AssetCategoryImpl.class, assetCategory.getPrimaryKey()) == null) {
379 cacheResult(assetCategory);
380 }
381 else {
382 assetCategory.resetOriginalValues();
383 }
384 }
385 }
386
387
394 @Override
395 public void clearCache() {
396 if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
397 CacheRegistryUtil.clear(AssetCategoryImpl.class.getName());
398 }
399
400 EntityCacheUtil.clearCache(AssetCategoryImpl.class.getName());
401
402 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
403 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
404 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
405 }
406
407
414 @Override
415 public void clearCache(AssetCategory assetCategory) {
416 EntityCacheUtil.removeResult(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
417 AssetCategoryImpl.class, assetCategory.getPrimaryKey());
418
419 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
420 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
421
422 clearUniqueFindersCache(assetCategory);
423 }
424
425 @Override
426 public void clearCache(List<AssetCategory> assetCategories) {
427 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
428 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
429
430 for (AssetCategory assetCategory : assetCategories) {
431 EntityCacheUtil.removeResult(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
432 AssetCategoryImpl.class, assetCategory.getPrimaryKey());
433
434 clearUniqueFindersCache(assetCategory);
435 }
436 }
437
438 protected void clearUniqueFindersCache(AssetCategory assetCategory) {
439 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
440 new Object[] {
441 assetCategory.getUuid(),
442 Long.valueOf(assetCategory.getGroupId())
443 });
444
445 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_P_N_V,
446 new Object[] {
447 Long.valueOf(assetCategory.getParentCategoryId()),
448
449 assetCategory.getName(),
450 Long.valueOf(assetCategory.getVocabularyId())
451 });
452 }
453
454
460 public AssetCategory create(long categoryId) {
461 AssetCategory assetCategory = new AssetCategoryImpl();
462
463 assetCategory.setNew(true);
464 assetCategory.setPrimaryKey(categoryId);
465
466 String uuid = PortalUUIDUtil.generate();
467
468 assetCategory.setUuid(uuid);
469
470 return assetCategory;
471 }
472
473
481 public AssetCategory remove(long categoryId)
482 throws NoSuchCategoryException, SystemException {
483 return remove(Long.valueOf(categoryId));
484 }
485
486
494 @Override
495 public AssetCategory remove(Serializable primaryKey)
496 throws NoSuchCategoryException, SystemException {
497 Session session = null;
498
499 try {
500 session = openSession();
501
502 AssetCategory assetCategory = (AssetCategory)session.get(AssetCategoryImpl.class,
503 primaryKey);
504
505 if (assetCategory == null) {
506 if (_log.isWarnEnabled()) {
507 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
508 }
509
510 throw new NoSuchCategoryException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
511 primaryKey);
512 }
513
514 return remove(assetCategory);
515 }
516 catch (NoSuchCategoryException nsee) {
517 throw nsee;
518 }
519 catch (Exception e) {
520 throw processException(e);
521 }
522 finally {
523 closeSession(session);
524 }
525 }
526
527 @Override
528 protected AssetCategory removeImpl(AssetCategory assetCategory)
529 throws SystemException {
530 assetCategory = toUnwrappedModel(assetCategory);
531
532 try {
533 clearAssetEntries.clear(assetCategory.getPrimaryKey());
534 }
535 catch (Exception e) {
536 throw processException(e);
537 }
538 finally {
539 FinderCacheUtil.clearCache(AssetCategoryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
540 }
541
542 shrinkTree(assetCategory);
543
544 Session session = null;
545
546 try {
547 session = openSession();
548
549 if (assetCategory.isCachedModel()) {
550 assetCategory = (AssetCategory)session.get(AssetCategoryImpl.class,
551 assetCategory.getPrimaryKeyObj());
552 }
553
554 session.delete(assetCategory);
555 }
556 catch (Exception e) {
557 throw processException(e);
558 }
559 finally {
560 closeSession(session);
561 }
562
563 clearCache(assetCategory);
564
565 return assetCategory;
566 }
567
568 @Override
569 public AssetCategory updateImpl(
570 com.liferay.portlet.asset.model.AssetCategory assetCategory)
571 throws SystemException {
572 assetCategory = toUnwrappedModel(assetCategory);
573
574 boolean isNew = assetCategory.isNew();
575
576 AssetCategoryModelImpl assetCategoryModelImpl = (AssetCategoryModelImpl)assetCategory;
577
578 if (Validator.isNull(assetCategory.getUuid())) {
579 String uuid = PortalUUIDUtil.generate();
580
581 assetCategory.setUuid(uuid);
582 }
583
584 if (isNew) {
585 expandTree(assetCategory, null);
586 }
587 else {
588 if (assetCategory.getParentCategoryId() != assetCategoryModelImpl.getOriginalParentCategoryId()) {
589 List<Long> childrenCategoryIds = getChildrenTreeCategoryIds(assetCategory);
590
591 shrinkTree(assetCategory);
592 expandTree(assetCategory, childrenCategoryIds);
593 }
594 }
595
596 Session session = null;
597
598 try {
599 session = openSession();
600
601 if (assetCategory.isNew()) {
602 session.save(assetCategory);
603
604 assetCategory.setNew(false);
605 }
606 else {
607 session.merge(assetCategory);
608 }
609 }
610 catch (Exception e) {
611 throw processException(e);
612 }
613 finally {
614 closeSession(session);
615 }
616
617 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
618
619 if (isNew || !AssetCategoryModelImpl.COLUMN_BITMASK_ENABLED) {
620 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
621 }
622
623 else {
624 if ((assetCategoryModelImpl.getColumnBitmask() &
625 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID.getColumnBitmask()) != 0) {
626 Object[] args = new Object[] {
627 assetCategoryModelImpl.getOriginalUuid()
628 };
629
630 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
631 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
632 args);
633
634 args = new Object[] { assetCategoryModelImpl.getUuid() };
635
636 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
637 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
638 args);
639 }
640
641 if ((assetCategoryModelImpl.getColumnBitmask() &
642 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C.getColumnBitmask()) != 0) {
643 Object[] args = new Object[] {
644 assetCategoryModelImpl.getOriginalUuid(),
645 Long.valueOf(assetCategoryModelImpl.getOriginalCompanyId())
646 };
647
648 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args);
649 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C,
650 args);
651
652 args = new Object[] {
653 assetCategoryModelImpl.getUuid(),
654 Long.valueOf(assetCategoryModelImpl.getCompanyId())
655 };
656
657 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args);
658 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C,
659 args);
660 }
661
662 if ((assetCategoryModelImpl.getColumnBitmask() &
663 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID.getColumnBitmask()) != 0) {
664 Object[] args = new Object[] {
665 Long.valueOf(assetCategoryModelImpl.getOriginalGroupId())
666 };
667
668 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
669 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
670 args);
671
672 args = new Object[] {
673 Long.valueOf(assetCategoryModelImpl.getGroupId())
674 };
675
676 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
677 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
678 args);
679 }
680
681 if ((assetCategoryModelImpl.getColumnBitmask() &
682 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_PARENTCATEGORYID.getColumnBitmask()) != 0) {
683 Object[] args = new Object[] {
684 Long.valueOf(assetCategoryModelImpl.getOriginalParentCategoryId())
685 };
686
687 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_PARENTCATEGORYID,
688 args);
689 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_PARENTCATEGORYID,
690 args);
691
692 args = new Object[] {
693 Long.valueOf(assetCategoryModelImpl.getParentCategoryId())
694 };
695
696 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_PARENTCATEGORYID,
697 args);
698 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_PARENTCATEGORYID,
699 args);
700 }
701
702 if ((assetCategoryModelImpl.getColumnBitmask() &
703 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_VOCABULARYID.getColumnBitmask()) != 0) {
704 Object[] args = new Object[] {
705 Long.valueOf(assetCategoryModelImpl.getOriginalVocabularyId())
706 };
707
708 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_VOCABULARYID,
709 args);
710 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_VOCABULARYID,
711 args);
712
713 args = new Object[] {
714 Long.valueOf(assetCategoryModelImpl.getVocabularyId())
715 };
716
717 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_VOCABULARYID,
718 args);
719 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_VOCABULARYID,
720 args);
721 }
722
723 if ((assetCategoryModelImpl.getColumnBitmask() &
724 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_V.getColumnBitmask()) != 0) {
725 Object[] args = new Object[] {
726 Long.valueOf(assetCategoryModelImpl.getOriginalGroupId()),
727 Long.valueOf(assetCategoryModelImpl.getOriginalVocabularyId())
728 };
729
730 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_V, args);
731 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_V,
732 args);
733
734 args = new Object[] {
735 Long.valueOf(assetCategoryModelImpl.getGroupId()),
736 Long.valueOf(assetCategoryModelImpl.getVocabularyId())
737 };
738
739 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_V, args);
740 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_V,
741 args);
742 }
743
744 if ((assetCategoryModelImpl.getColumnBitmask() &
745 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_P_N.getColumnBitmask()) != 0) {
746 Object[] args = new Object[] {
747 Long.valueOf(assetCategoryModelImpl.getOriginalParentCategoryId()),
748
749 assetCategoryModelImpl.getOriginalName()
750 };
751
752 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_P_N, args);
753 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_P_N,
754 args);
755
756 args = new Object[] {
757 Long.valueOf(assetCategoryModelImpl.getParentCategoryId()),
758
759 assetCategoryModelImpl.getName()
760 };
761
762 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_P_N, args);
763 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_P_N,
764 args);
765 }
766
767 if ((assetCategoryModelImpl.getColumnBitmask() &
768 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_P_V.getColumnBitmask()) != 0) {
769 Object[] args = new Object[] {
770 Long.valueOf(assetCategoryModelImpl.getOriginalParentCategoryId()),
771 Long.valueOf(assetCategoryModelImpl.getOriginalVocabularyId())
772 };
773
774 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_P_V, args);
775 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_P_V,
776 args);
777
778 args = new Object[] {
779 Long.valueOf(assetCategoryModelImpl.getParentCategoryId()),
780 Long.valueOf(assetCategoryModelImpl.getVocabularyId())
781 };
782
783 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_P_V, args);
784 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_P_V,
785 args);
786 }
787
788 if ((assetCategoryModelImpl.getColumnBitmask() &
789 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_V.getColumnBitmask()) != 0) {
790 Object[] args = new Object[] {
791 assetCategoryModelImpl.getOriginalName(),
792 Long.valueOf(assetCategoryModelImpl.getOriginalVocabularyId())
793 };
794
795 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_N_V, args);
796 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_V,
797 args);
798
799 args = new Object[] {
800 assetCategoryModelImpl.getName(),
801 Long.valueOf(assetCategoryModelImpl.getVocabularyId())
802 };
803
804 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_N_V, args);
805 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_V,
806 args);
807 }
808
809 if ((assetCategoryModelImpl.getColumnBitmask() &
810 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_N.getColumnBitmask()) != 0) {
811 Object[] args = new Object[] {
812 Long.valueOf(assetCategoryModelImpl.getOriginalGroupId()),
813 Long.valueOf(assetCategoryModelImpl.getOriginalParentCategoryId()),
814
815 assetCategoryModelImpl.getOriginalName()
816 };
817
818 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_P_N, args);
819 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_N,
820 args);
821
822 args = new Object[] {
823 Long.valueOf(assetCategoryModelImpl.getGroupId()),
824 Long.valueOf(assetCategoryModelImpl.getParentCategoryId()),
825
826 assetCategoryModelImpl.getName()
827 };
828
829 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_P_N, args);
830 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_N,
831 args);
832 }
833 }
834
835 EntityCacheUtil.putResult(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
836 AssetCategoryImpl.class, assetCategory.getPrimaryKey(),
837 assetCategory);
838
839 if (isNew) {
840 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
841 new Object[] {
842 assetCategory.getUuid(),
843 Long.valueOf(assetCategory.getGroupId())
844 }, assetCategory);
845
846 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_P_N_V,
847 new Object[] {
848 Long.valueOf(assetCategory.getParentCategoryId()),
849
850 assetCategory.getName(),
851 Long.valueOf(assetCategory.getVocabularyId())
852 }, assetCategory);
853 }
854 else {
855 if ((assetCategoryModelImpl.getColumnBitmask() &
856 FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) {
857 Object[] args = new Object[] {
858 assetCategoryModelImpl.getOriginalUuid(),
859 Long.valueOf(assetCategoryModelImpl.getOriginalGroupId())
860 };
861
862 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args);
863
864 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args);
865
866 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
867 new Object[] {
868 assetCategory.getUuid(),
869 Long.valueOf(assetCategory.getGroupId())
870 }, assetCategory);
871 }
872
873 if ((assetCategoryModelImpl.getColumnBitmask() &
874 FINDER_PATH_FETCH_BY_P_N_V.getColumnBitmask()) != 0) {
875 Object[] args = new Object[] {
876 Long.valueOf(assetCategoryModelImpl.getOriginalParentCategoryId()),
877
878 assetCategoryModelImpl.getOriginalName(),
879 Long.valueOf(assetCategoryModelImpl.getOriginalVocabularyId())
880 };
881
882 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_P_N_V, args);
883
884 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_P_N_V, args);
885
886 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_P_N_V,
887 new Object[] {
888 Long.valueOf(assetCategory.getParentCategoryId()),
889
890 assetCategory.getName(),
891 Long.valueOf(assetCategory.getVocabularyId())
892 }, assetCategory);
893 }
894 }
895
896 return assetCategory;
897 }
898
899 protected AssetCategory toUnwrappedModel(AssetCategory assetCategory) {
900 if (assetCategory instanceof AssetCategoryImpl) {
901 return assetCategory;
902 }
903
904 AssetCategoryImpl assetCategoryImpl = new AssetCategoryImpl();
905
906 assetCategoryImpl.setNew(assetCategory.isNew());
907 assetCategoryImpl.setPrimaryKey(assetCategory.getPrimaryKey());
908
909 assetCategoryImpl.setUuid(assetCategory.getUuid());
910 assetCategoryImpl.setCategoryId(assetCategory.getCategoryId());
911 assetCategoryImpl.setGroupId(assetCategory.getGroupId());
912 assetCategoryImpl.setCompanyId(assetCategory.getCompanyId());
913 assetCategoryImpl.setUserId(assetCategory.getUserId());
914 assetCategoryImpl.setUserName(assetCategory.getUserName());
915 assetCategoryImpl.setCreateDate(assetCategory.getCreateDate());
916 assetCategoryImpl.setModifiedDate(assetCategory.getModifiedDate());
917 assetCategoryImpl.setParentCategoryId(assetCategory.getParentCategoryId());
918 assetCategoryImpl.setLeftCategoryId(assetCategory.getLeftCategoryId());
919 assetCategoryImpl.setRightCategoryId(assetCategory.getRightCategoryId());
920 assetCategoryImpl.setName(assetCategory.getName());
921 assetCategoryImpl.setTitle(assetCategory.getTitle());
922 assetCategoryImpl.setDescription(assetCategory.getDescription());
923 assetCategoryImpl.setVocabularyId(assetCategory.getVocabularyId());
924
925 return assetCategoryImpl;
926 }
927
928
936 @Override
937 public AssetCategory findByPrimaryKey(Serializable primaryKey)
938 throws NoSuchModelException, SystemException {
939 return findByPrimaryKey(((Long)primaryKey).longValue());
940 }
941
942
950 public AssetCategory findByPrimaryKey(long categoryId)
951 throws NoSuchCategoryException, SystemException {
952 AssetCategory assetCategory = fetchByPrimaryKey(categoryId);
953
954 if (assetCategory == null) {
955 if (_log.isWarnEnabled()) {
956 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + categoryId);
957 }
958
959 throw new NoSuchCategoryException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
960 categoryId);
961 }
962
963 return assetCategory;
964 }
965
966
973 @Override
974 public AssetCategory fetchByPrimaryKey(Serializable primaryKey)
975 throws SystemException {
976 return fetchByPrimaryKey(((Long)primaryKey).longValue());
977 }
978
979
986 public AssetCategory fetchByPrimaryKey(long categoryId)
987 throws SystemException {
988 AssetCategory assetCategory = (AssetCategory)EntityCacheUtil.getResult(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
989 AssetCategoryImpl.class, categoryId);
990
991 if (assetCategory == _nullAssetCategory) {
992 return null;
993 }
994
995 if (assetCategory == null) {
996 Session session = null;
997
998 boolean hasException = false;
999
1000 try {
1001 session = openSession();
1002
1003 assetCategory = (AssetCategory)session.get(AssetCategoryImpl.class,
1004 Long.valueOf(categoryId));
1005 }
1006 catch (Exception e) {
1007 hasException = true;
1008
1009 throw processException(e);
1010 }
1011 finally {
1012 if (assetCategory != null) {
1013 cacheResult(assetCategory);
1014 }
1015 else if (!hasException) {
1016 EntityCacheUtil.putResult(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
1017 AssetCategoryImpl.class, categoryId, _nullAssetCategory);
1018 }
1019
1020 closeSession(session);
1021 }
1022 }
1023
1024 return assetCategory;
1025 }
1026
1027
1034 public List<AssetCategory> findByUuid(String uuid)
1035 throws SystemException {
1036 return findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1037 }
1038
1039
1052 public List<AssetCategory> findByUuid(String uuid, int start, int end)
1053 throws SystemException {
1054 return findByUuid(uuid, start, end, null);
1055 }
1056
1057
1071 public List<AssetCategory> findByUuid(String uuid, int start, int end,
1072 OrderByComparator orderByComparator) throws SystemException {
1073 FinderPath finderPath = null;
1074 Object[] finderArgs = null;
1075
1076 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1077 (orderByComparator == null)) {
1078 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID;
1079 finderArgs = new Object[] { uuid };
1080 }
1081 else {
1082 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID;
1083 finderArgs = new Object[] { uuid, start, end, orderByComparator };
1084 }
1085
1086 List<AssetCategory> list = (List<AssetCategory>)FinderCacheUtil.getResult(finderPath,
1087 finderArgs, this);
1088
1089 if ((list != null) && !list.isEmpty()) {
1090 for (AssetCategory assetCategory : list) {
1091 if (!Validator.equals(uuid, assetCategory.getUuid())) {
1092 list = null;
1093
1094 break;
1095 }
1096 }
1097 }
1098
1099 if (list == null) {
1100 StringBundler query = null;
1101
1102 if (orderByComparator != null) {
1103 query = new StringBundler(3 +
1104 (orderByComparator.getOrderByFields().length * 3));
1105 }
1106 else {
1107 query = new StringBundler(3);
1108 }
1109
1110 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
1111
1112 if (uuid == null) {
1113 query.append(_FINDER_COLUMN_UUID_UUID_1);
1114 }
1115 else {
1116 if (uuid.equals(StringPool.BLANK)) {
1117 query.append(_FINDER_COLUMN_UUID_UUID_3);
1118 }
1119 else {
1120 query.append(_FINDER_COLUMN_UUID_UUID_2);
1121 }
1122 }
1123
1124 if (orderByComparator != null) {
1125 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1126 orderByComparator);
1127 }
1128
1129 else {
1130 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
1131 }
1132
1133 String sql = query.toString();
1134
1135 Session session = null;
1136
1137 try {
1138 session = openSession();
1139
1140 Query q = session.createQuery(sql);
1141
1142 QueryPos qPos = QueryPos.getInstance(q);
1143
1144 if (uuid != null) {
1145 qPos.add(uuid);
1146 }
1147
1148 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
1149 start, end);
1150 }
1151 catch (Exception e) {
1152 throw processException(e);
1153 }
1154 finally {
1155 if (list == null) {
1156 FinderCacheUtil.removeResult(finderPath, finderArgs);
1157 }
1158 else {
1159 cacheResult(list);
1160
1161 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1162 }
1163
1164 closeSession(session);
1165 }
1166 }
1167
1168 return list;
1169 }
1170
1171
1180 public AssetCategory findByUuid_First(String uuid,
1181 OrderByComparator orderByComparator)
1182 throws NoSuchCategoryException, SystemException {
1183 AssetCategory assetCategory = fetchByUuid_First(uuid, orderByComparator);
1184
1185 if (assetCategory != null) {
1186 return assetCategory;
1187 }
1188
1189 StringBundler msg = new StringBundler(4);
1190
1191 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1192
1193 msg.append("uuid=");
1194 msg.append(uuid);
1195
1196 msg.append(StringPool.CLOSE_CURLY_BRACE);
1197
1198 throw new NoSuchCategoryException(msg.toString());
1199 }
1200
1201
1209 public AssetCategory fetchByUuid_First(String uuid,
1210 OrderByComparator orderByComparator) throws SystemException {
1211 List<AssetCategory> list = findByUuid(uuid, 0, 1, orderByComparator);
1212
1213 if (!list.isEmpty()) {
1214 return list.get(0);
1215 }
1216
1217 return null;
1218 }
1219
1220
1229 public AssetCategory findByUuid_Last(String uuid,
1230 OrderByComparator orderByComparator)
1231 throws NoSuchCategoryException, SystemException {
1232 AssetCategory assetCategory = fetchByUuid_Last(uuid, orderByComparator);
1233
1234 if (assetCategory != null) {
1235 return assetCategory;
1236 }
1237
1238 StringBundler msg = new StringBundler(4);
1239
1240 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1241
1242 msg.append("uuid=");
1243 msg.append(uuid);
1244
1245 msg.append(StringPool.CLOSE_CURLY_BRACE);
1246
1247 throw new NoSuchCategoryException(msg.toString());
1248 }
1249
1250
1258 public AssetCategory fetchByUuid_Last(String uuid,
1259 OrderByComparator orderByComparator) throws SystemException {
1260 int count = countByUuid(uuid);
1261
1262 List<AssetCategory> list = findByUuid(uuid, count - 1, count,
1263 orderByComparator);
1264
1265 if (!list.isEmpty()) {
1266 return list.get(0);
1267 }
1268
1269 return null;
1270 }
1271
1272
1282 public AssetCategory[] findByUuid_PrevAndNext(long categoryId, String uuid,
1283 OrderByComparator orderByComparator)
1284 throws NoSuchCategoryException, SystemException {
1285 AssetCategory assetCategory = findByPrimaryKey(categoryId);
1286
1287 Session session = null;
1288
1289 try {
1290 session = openSession();
1291
1292 AssetCategory[] array = new AssetCategoryImpl[3];
1293
1294 array[0] = getByUuid_PrevAndNext(session, assetCategory, uuid,
1295 orderByComparator, true);
1296
1297 array[1] = assetCategory;
1298
1299 array[2] = getByUuid_PrevAndNext(session, assetCategory, uuid,
1300 orderByComparator, false);
1301
1302 return array;
1303 }
1304 catch (Exception e) {
1305 throw processException(e);
1306 }
1307 finally {
1308 closeSession(session);
1309 }
1310 }
1311
1312 protected AssetCategory getByUuid_PrevAndNext(Session session,
1313 AssetCategory assetCategory, String uuid,
1314 OrderByComparator orderByComparator, boolean previous) {
1315 StringBundler query = null;
1316
1317 if (orderByComparator != null) {
1318 query = new StringBundler(6 +
1319 (orderByComparator.getOrderByFields().length * 6));
1320 }
1321 else {
1322 query = new StringBundler(3);
1323 }
1324
1325 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
1326
1327 if (uuid == null) {
1328 query.append(_FINDER_COLUMN_UUID_UUID_1);
1329 }
1330 else {
1331 if (uuid.equals(StringPool.BLANK)) {
1332 query.append(_FINDER_COLUMN_UUID_UUID_3);
1333 }
1334 else {
1335 query.append(_FINDER_COLUMN_UUID_UUID_2);
1336 }
1337 }
1338
1339 if (orderByComparator != null) {
1340 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1341
1342 if (orderByConditionFields.length > 0) {
1343 query.append(WHERE_AND);
1344 }
1345
1346 for (int i = 0; i < orderByConditionFields.length; i++) {
1347 query.append(_ORDER_BY_ENTITY_ALIAS);
1348 query.append(orderByConditionFields[i]);
1349
1350 if ((i + 1) < orderByConditionFields.length) {
1351 if (orderByComparator.isAscending() ^ previous) {
1352 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1353 }
1354 else {
1355 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1356 }
1357 }
1358 else {
1359 if (orderByComparator.isAscending() ^ previous) {
1360 query.append(WHERE_GREATER_THAN);
1361 }
1362 else {
1363 query.append(WHERE_LESSER_THAN);
1364 }
1365 }
1366 }
1367
1368 query.append(ORDER_BY_CLAUSE);
1369
1370 String[] orderByFields = orderByComparator.getOrderByFields();
1371
1372 for (int i = 0; i < orderByFields.length; i++) {
1373 query.append(_ORDER_BY_ENTITY_ALIAS);
1374 query.append(orderByFields[i]);
1375
1376 if ((i + 1) < orderByFields.length) {
1377 if (orderByComparator.isAscending() ^ previous) {
1378 query.append(ORDER_BY_ASC_HAS_NEXT);
1379 }
1380 else {
1381 query.append(ORDER_BY_DESC_HAS_NEXT);
1382 }
1383 }
1384 else {
1385 if (orderByComparator.isAscending() ^ previous) {
1386 query.append(ORDER_BY_ASC);
1387 }
1388 else {
1389 query.append(ORDER_BY_DESC);
1390 }
1391 }
1392 }
1393 }
1394
1395 else {
1396 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
1397 }
1398
1399 String sql = query.toString();
1400
1401 Query q = session.createQuery(sql);
1402
1403 q.setFirstResult(0);
1404 q.setMaxResults(2);
1405
1406 QueryPos qPos = QueryPos.getInstance(q);
1407
1408 if (uuid != null) {
1409 qPos.add(uuid);
1410 }
1411
1412 if (orderByComparator != null) {
1413 Object[] values = orderByComparator.getOrderByConditionValues(assetCategory);
1414
1415 for (Object value : values) {
1416 qPos.add(value);
1417 }
1418 }
1419
1420 List<AssetCategory> list = q.list();
1421
1422 if (list.size() == 2) {
1423 return list.get(1);
1424 }
1425 else {
1426 return null;
1427 }
1428 }
1429
1430
1439 public AssetCategory findByUUID_G(String uuid, long groupId)
1440 throws NoSuchCategoryException, SystemException {
1441 AssetCategory assetCategory = fetchByUUID_G(uuid, groupId);
1442
1443 if (assetCategory == null) {
1444 StringBundler msg = new StringBundler(6);
1445
1446 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1447
1448 msg.append("uuid=");
1449 msg.append(uuid);
1450
1451 msg.append(", groupId=");
1452 msg.append(groupId);
1453
1454 msg.append(StringPool.CLOSE_CURLY_BRACE);
1455
1456 if (_log.isWarnEnabled()) {
1457 _log.warn(msg.toString());
1458 }
1459
1460 throw new NoSuchCategoryException(msg.toString());
1461 }
1462
1463 return assetCategory;
1464 }
1465
1466
1474 public AssetCategory fetchByUUID_G(String uuid, long groupId)
1475 throws SystemException {
1476 return fetchByUUID_G(uuid, groupId, true);
1477 }
1478
1479
1488 public AssetCategory fetchByUUID_G(String uuid, long groupId,
1489 boolean retrieveFromCache) throws SystemException {
1490 Object[] finderArgs = new Object[] { uuid, groupId };
1491
1492 Object result = null;
1493
1494 if (retrieveFromCache) {
1495 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_UUID_G,
1496 finderArgs, this);
1497 }
1498
1499 if (result instanceof AssetCategory) {
1500 AssetCategory assetCategory = (AssetCategory)result;
1501
1502 if (!Validator.equals(uuid, assetCategory.getUuid()) ||
1503 (groupId != assetCategory.getGroupId())) {
1504 result = null;
1505 }
1506 }
1507
1508 if (result == null) {
1509 StringBundler query = new StringBundler(4);
1510
1511 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
1512
1513 if (uuid == null) {
1514 query.append(_FINDER_COLUMN_UUID_G_UUID_1);
1515 }
1516 else {
1517 if (uuid.equals(StringPool.BLANK)) {
1518 query.append(_FINDER_COLUMN_UUID_G_UUID_3);
1519 }
1520 else {
1521 query.append(_FINDER_COLUMN_UUID_G_UUID_2);
1522 }
1523 }
1524
1525 query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
1526
1527 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
1528
1529 String sql = query.toString();
1530
1531 Session session = null;
1532
1533 try {
1534 session = openSession();
1535
1536 Query q = session.createQuery(sql);
1537
1538 QueryPos qPos = QueryPos.getInstance(q);
1539
1540 if (uuid != null) {
1541 qPos.add(uuid);
1542 }
1543
1544 qPos.add(groupId);
1545
1546 List<AssetCategory> list = q.list();
1547
1548 result = list;
1549
1550 AssetCategory assetCategory = null;
1551
1552 if (list.isEmpty()) {
1553 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
1554 finderArgs, list);
1555 }
1556 else {
1557 assetCategory = list.get(0);
1558
1559 cacheResult(assetCategory);
1560
1561 if ((assetCategory.getUuid() == null) ||
1562 !assetCategory.getUuid().equals(uuid) ||
1563 (assetCategory.getGroupId() != groupId)) {
1564 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
1565 finderArgs, assetCategory);
1566 }
1567 }
1568
1569 return assetCategory;
1570 }
1571 catch (Exception e) {
1572 throw processException(e);
1573 }
1574 finally {
1575 if (result == null) {
1576 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
1577 finderArgs);
1578 }
1579
1580 closeSession(session);
1581 }
1582 }
1583 else {
1584 if (result instanceof List<?>) {
1585 return null;
1586 }
1587 else {
1588 return (AssetCategory)result;
1589 }
1590 }
1591 }
1592
1593
1601 public List<AssetCategory> findByUuid_C(String uuid, long companyId)
1602 throws SystemException {
1603 return findByUuid_C(uuid, companyId, QueryUtil.ALL_POS,
1604 QueryUtil.ALL_POS, null);
1605 }
1606
1607
1621 public List<AssetCategory> findByUuid_C(String uuid, long companyId,
1622 int start, int end) throws SystemException {
1623 return findByUuid_C(uuid, companyId, start, end, null);
1624 }
1625
1626
1641 public List<AssetCategory> findByUuid_C(String uuid, long companyId,
1642 int start, int end, OrderByComparator orderByComparator)
1643 throws SystemException {
1644 FinderPath finderPath = null;
1645 Object[] finderArgs = null;
1646
1647 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1648 (orderByComparator == null)) {
1649 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C;
1650 finderArgs = new Object[] { uuid, companyId };
1651 }
1652 else {
1653 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID_C;
1654 finderArgs = new Object[] {
1655 uuid, companyId,
1656
1657 start, end, orderByComparator
1658 };
1659 }
1660
1661 List<AssetCategory> list = (List<AssetCategory>)FinderCacheUtil.getResult(finderPath,
1662 finderArgs, this);
1663
1664 if ((list != null) && !list.isEmpty()) {
1665 for (AssetCategory assetCategory : list) {
1666 if (!Validator.equals(uuid, assetCategory.getUuid()) ||
1667 (companyId != assetCategory.getCompanyId())) {
1668 list = null;
1669
1670 break;
1671 }
1672 }
1673 }
1674
1675 if (list == null) {
1676 StringBundler query = null;
1677
1678 if (orderByComparator != null) {
1679 query = new StringBundler(4 +
1680 (orderByComparator.getOrderByFields().length * 3));
1681 }
1682 else {
1683 query = new StringBundler(4);
1684 }
1685
1686 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
1687
1688 if (uuid == null) {
1689 query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1690 }
1691 else {
1692 if (uuid.equals(StringPool.BLANK)) {
1693 query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1694 }
1695 else {
1696 query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1697 }
1698 }
1699
1700 query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1701
1702 if (orderByComparator != null) {
1703 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1704 orderByComparator);
1705 }
1706
1707 else {
1708 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
1709 }
1710
1711 String sql = query.toString();
1712
1713 Session session = null;
1714
1715 try {
1716 session = openSession();
1717
1718 Query q = session.createQuery(sql);
1719
1720 QueryPos qPos = QueryPos.getInstance(q);
1721
1722 if (uuid != null) {
1723 qPos.add(uuid);
1724 }
1725
1726 qPos.add(companyId);
1727
1728 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
1729 start, end);
1730 }
1731 catch (Exception e) {
1732 throw processException(e);
1733 }
1734 finally {
1735 if (list == null) {
1736 FinderCacheUtil.removeResult(finderPath, finderArgs);
1737 }
1738 else {
1739 cacheResult(list);
1740
1741 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1742 }
1743
1744 closeSession(session);
1745 }
1746 }
1747
1748 return list;
1749 }
1750
1751
1761 public AssetCategory findByUuid_C_First(String uuid, long companyId,
1762 OrderByComparator orderByComparator)
1763 throws NoSuchCategoryException, SystemException {
1764 AssetCategory assetCategory = fetchByUuid_C_First(uuid, companyId,
1765 orderByComparator);
1766
1767 if (assetCategory != null) {
1768 return assetCategory;
1769 }
1770
1771 StringBundler msg = new StringBundler(6);
1772
1773 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1774
1775 msg.append("uuid=");
1776 msg.append(uuid);
1777
1778 msg.append(", companyId=");
1779 msg.append(companyId);
1780
1781 msg.append(StringPool.CLOSE_CURLY_BRACE);
1782
1783 throw new NoSuchCategoryException(msg.toString());
1784 }
1785
1786
1795 public AssetCategory fetchByUuid_C_First(String uuid, long companyId,
1796 OrderByComparator orderByComparator) throws SystemException {
1797 List<AssetCategory> list = findByUuid_C(uuid, companyId, 0, 1,
1798 orderByComparator);
1799
1800 if (!list.isEmpty()) {
1801 return list.get(0);
1802 }
1803
1804 return null;
1805 }
1806
1807
1817 public AssetCategory findByUuid_C_Last(String uuid, long companyId,
1818 OrderByComparator orderByComparator)
1819 throws NoSuchCategoryException, SystemException {
1820 AssetCategory assetCategory = fetchByUuid_C_Last(uuid, companyId,
1821 orderByComparator);
1822
1823 if (assetCategory != null) {
1824 return assetCategory;
1825 }
1826
1827 StringBundler msg = new StringBundler(6);
1828
1829 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1830
1831 msg.append("uuid=");
1832 msg.append(uuid);
1833
1834 msg.append(", companyId=");
1835 msg.append(companyId);
1836
1837 msg.append(StringPool.CLOSE_CURLY_BRACE);
1838
1839 throw new NoSuchCategoryException(msg.toString());
1840 }
1841
1842
1851 public AssetCategory fetchByUuid_C_Last(String uuid, long companyId,
1852 OrderByComparator orderByComparator) throws SystemException {
1853 int count = countByUuid_C(uuid, companyId);
1854
1855 List<AssetCategory> list = findByUuid_C(uuid, companyId, count - 1,
1856 count, orderByComparator);
1857
1858 if (!list.isEmpty()) {
1859 return list.get(0);
1860 }
1861
1862 return null;
1863 }
1864
1865
1876 public AssetCategory[] findByUuid_C_PrevAndNext(long categoryId,
1877 String uuid, long companyId, OrderByComparator orderByComparator)
1878 throws NoSuchCategoryException, SystemException {
1879 AssetCategory assetCategory = findByPrimaryKey(categoryId);
1880
1881 Session session = null;
1882
1883 try {
1884 session = openSession();
1885
1886 AssetCategory[] array = new AssetCategoryImpl[3];
1887
1888 array[0] = getByUuid_C_PrevAndNext(session, assetCategory, uuid,
1889 companyId, orderByComparator, true);
1890
1891 array[1] = assetCategory;
1892
1893 array[2] = getByUuid_C_PrevAndNext(session, assetCategory, uuid,
1894 companyId, orderByComparator, false);
1895
1896 return array;
1897 }
1898 catch (Exception e) {
1899 throw processException(e);
1900 }
1901 finally {
1902 closeSession(session);
1903 }
1904 }
1905
1906 protected AssetCategory getByUuid_C_PrevAndNext(Session session,
1907 AssetCategory assetCategory, String uuid, long companyId,
1908 OrderByComparator orderByComparator, boolean previous) {
1909 StringBundler query = null;
1910
1911 if (orderByComparator != null) {
1912 query = new StringBundler(6 +
1913 (orderByComparator.getOrderByFields().length * 6));
1914 }
1915 else {
1916 query = new StringBundler(3);
1917 }
1918
1919 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
1920
1921 if (uuid == null) {
1922 query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1923 }
1924 else {
1925 if (uuid.equals(StringPool.BLANK)) {
1926 query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1927 }
1928 else {
1929 query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1930 }
1931 }
1932
1933 query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1934
1935 if (orderByComparator != null) {
1936 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1937
1938 if (orderByConditionFields.length > 0) {
1939 query.append(WHERE_AND);
1940 }
1941
1942 for (int i = 0; i < orderByConditionFields.length; i++) {
1943 query.append(_ORDER_BY_ENTITY_ALIAS);
1944 query.append(orderByConditionFields[i]);
1945
1946 if ((i + 1) < orderByConditionFields.length) {
1947 if (orderByComparator.isAscending() ^ previous) {
1948 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1949 }
1950 else {
1951 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1952 }
1953 }
1954 else {
1955 if (orderByComparator.isAscending() ^ previous) {
1956 query.append(WHERE_GREATER_THAN);
1957 }
1958 else {
1959 query.append(WHERE_LESSER_THAN);
1960 }
1961 }
1962 }
1963
1964 query.append(ORDER_BY_CLAUSE);
1965
1966 String[] orderByFields = orderByComparator.getOrderByFields();
1967
1968 for (int i = 0; i < orderByFields.length; i++) {
1969 query.append(_ORDER_BY_ENTITY_ALIAS);
1970 query.append(orderByFields[i]);
1971
1972 if ((i + 1) < orderByFields.length) {
1973 if (orderByComparator.isAscending() ^ previous) {
1974 query.append(ORDER_BY_ASC_HAS_NEXT);
1975 }
1976 else {
1977 query.append(ORDER_BY_DESC_HAS_NEXT);
1978 }
1979 }
1980 else {
1981 if (orderByComparator.isAscending() ^ previous) {
1982 query.append(ORDER_BY_ASC);
1983 }
1984 else {
1985 query.append(ORDER_BY_DESC);
1986 }
1987 }
1988 }
1989 }
1990
1991 else {
1992 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
1993 }
1994
1995 String sql = query.toString();
1996
1997 Query q = session.createQuery(sql);
1998
1999 q.setFirstResult(0);
2000 q.setMaxResults(2);
2001
2002 QueryPos qPos = QueryPos.getInstance(q);
2003
2004 if (uuid != null) {
2005 qPos.add(uuid);
2006 }
2007
2008 qPos.add(companyId);
2009
2010 if (orderByComparator != null) {
2011 Object[] values = orderByComparator.getOrderByConditionValues(assetCategory);
2012
2013 for (Object value : values) {
2014 qPos.add(value);
2015 }
2016 }
2017
2018 List<AssetCategory> list = q.list();
2019
2020 if (list.size() == 2) {
2021 return list.get(1);
2022 }
2023 else {
2024 return null;
2025 }
2026 }
2027
2028
2035 public List<AssetCategory> findByGroupId(long groupId)
2036 throws SystemException {
2037 return findByGroupId(groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
2038 }
2039
2040
2053 public List<AssetCategory> findByGroupId(long groupId, int start, int end)
2054 throws SystemException {
2055 return findByGroupId(groupId, start, end, null);
2056 }
2057
2058
2072 public List<AssetCategory> findByGroupId(long groupId, int start, int end,
2073 OrderByComparator orderByComparator) throws SystemException {
2074 FinderPath finderPath = null;
2075 Object[] finderArgs = null;
2076
2077 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2078 (orderByComparator == null)) {
2079 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID;
2080 finderArgs = new Object[] { groupId };
2081 }
2082 else {
2083 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID;
2084 finderArgs = new Object[] { groupId, start, end, orderByComparator };
2085 }
2086
2087 List<AssetCategory> list = (List<AssetCategory>)FinderCacheUtil.getResult(finderPath,
2088 finderArgs, this);
2089
2090 if ((list != null) && !list.isEmpty()) {
2091 for (AssetCategory assetCategory : list) {
2092 if ((groupId != assetCategory.getGroupId())) {
2093 list = null;
2094
2095 break;
2096 }
2097 }
2098 }
2099
2100 if (list == null) {
2101 StringBundler query = null;
2102
2103 if (orderByComparator != null) {
2104 query = new StringBundler(3 +
2105 (orderByComparator.getOrderByFields().length * 3));
2106 }
2107 else {
2108 query = new StringBundler(3);
2109 }
2110
2111 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
2112
2113 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2114
2115 if (orderByComparator != null) {
2116 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2117 orderByComparator);
2118 }
2119
2120 else {
2121 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
2122 }
2123
2124 String sql = query.toString();
2125
2126 Session session = null;
2127
2128 try {
2129 session = openSession();
2130
2131 Query q = session.createQuery(sql);
2132
2133 QueryPos qPos = QueryPos.getInstance(q);
2134
2135 qPos.add(groupId);
2136
2137 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
2138 start, end);
2139 }
2140 catch (Exception e) {
2141 throw processException(e);
2142 }
2143 finally {
2144 if (list == null) {
2145 FinderCacheUtil.removeResult(finderPath, finderArgs);
2146 }
2147 else {
2148 cacheResult(list);
2149
2150 FinderCacheUtil.putResult(finderPath, finderArgs, list);
2151 }
2152
2153 closeSession(session);
2154 }
2155 }
2156
2157 return list;
2158 }
2159
2160
2169 public AssetCategory findByGroupId_First(long groupId,
2170 OrderByComparator orderByComparator)
2171 throws NoSuchCategoryException, SystemException {
2172 AssetCategory assetCategory = fetchByGroupId_First(groupId,
2173 orderByComparator);
2174
2175 if (assetCategory != null) {
2176 return assetCategory;
2177 }
2178
2179 StringBundler msg = new StringBundler(4);
2180
2181 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2182
2183 msg.append("groupId=");
2184 msg.append(groupId);
2185
2186 msg.append(StringPool.CLOSE_CURLY_BRACE);
2187
2188 throw new NoSuchCategoryException(msg.toString());
2189 }
2190
2191
2199 public AssetCategory fetchByGroupId_First(long groupId,
2200 OrderByComparator orderByComparator) throws SystemException {
2201 List<AssetCategory> list = findByGroupId(groupId, 0, 1,
2202 orderByComparator);
2203
2204 if (!list.isEmpty()) {
2205 return list.get(0);
2206 }
2207
2208 return null;
2209 }
2210
2211
2220 public AssetCategory findByGroupId_Last(long groupId,
2221 OrderByComparator orderByComparator)
2222 throws NoSuchCategoryException, SystemException {
2223 AssetCategory assetCategory = fetchByGroupId_Last(groupId,
2224 orderByComparator);
2225
2226 if (assetCategory != null) {
2227 return assetCategory;
2228 }
2229
2230 StringBundler msg = new StringBundler(4);
2231
2232 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2233
2234 msg.append("groupId=");
2235 msg.append(groupId);
2236
2237 msg.append(StringPool.CLOSE_CURLY_BRACE);
2238
2239 throw new NoSuchCategoryException(msg.toString());
2240 }
2241
2242
2250 public AssetCategory fetchByGroupId_Last(long groupId,
2251 OrderByComparator orderByComparator) throws SystemException {
2252 int count = countByGroupId(groupId);
2253
2254 List<AssetCategory> list = findByGroupId(groupId, count - 1, count,
2255 orderByComparator);
2256
2257 if (!list.isEmpty()) {
2258 return list.get(0);
2259 }
2260
2261 return null;
2262 }
2263
2264
2274 public AssetCategory[] findByGroupId_PrevAndNext(long categoryId,
2275 long groupId, OrderByComparator orderByComparator)
2276 throws NoSuchCategoryException, SystemException {
2277 AssetCategory assetCategory = findByPrimaryKey(categoryId);
2278
2279 Session session = null;
2280
2281 try {
2282 session = openSession();
2283
2284 AssetCategory[] array = new AssetCategoryImpl[3];
2285
2286 array[0] = getByGroupId_PrevAndNext(session, assetCategory,
2287 groupId, orderByComparator, true);
2288
2289 array[1] = assetCategory;
2290
2291 array[2] = getByGroupId_PrevAndNext(session, assetCategory,
2292 groupId, orderByComparator, false);
2293
2294 return array;
2295 }
2296 catch (Exception e) {
2297 throw processException(e);
2298 }
2299 finally {
2300 closeSession(session);
2301 }
2302 }
2303
2304 protected AssetCategory getByGroupId_PrevAndNext(Session session,
2305 AssetCategory assetCategory, long groupId,
2306 OrderByComparator orderByComparator, boolean previous) {
2307 StringBundler query = null;
2308
2309 if (orderByComparator != null) {
2310 query = new StringBundler(6 +
2311 (orderByComparator.getOrderByFields().length * 6));
2312 }
2313 else {
2314 query = new StringBundler(3);
2315 }
2316
2317 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
2318
2319 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2320
2321 if (orderByComparator != null) {
2322 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2323
2324 if (orderByConditionFields.length > 0) {
2325 query.append(WHERE_AND);
2326 }
2327
2328 for (int i = 0; i < orderByConditionFields.length; i++) {
2329 query.append(_ORDER_BY_ENTITY_ALIAS);
2330 query.append(orderByConditionFields[i]);
2331
2332 if ((i + 1) < orderByConditionFields.length) {
2333 if (orderByComparator.isAscending() ^ previous) {
2334 query.append(WHERE_GREATER_THAN_HAS_NEXT);
2335 }
2336 else {
2337 query.append(WHERE_LESSER_THAN_HAS_NEXT);
2338 }
2339 }
2340 else {
2341 if (orderByComparator.isAscending() ^ previous) {
2342 query.append(WHERE_GREATER_THAN);
2343 }
2344 else {
2345 query.append(WHERE_LESSER_THAN);
2346 }
2347 }
2348 }
2349
2350 query.append(ORDER_BY_CLAUSE);
2351
2352 String[] orderByFields = orderByComparator.getOrderByFields();
2353
2354 for (int i = 0; i < orderByFields.length; i++) {
2355 query.append(_ORDER_BY_ENTITY_ALIAS);
2356 query.append(orderByFields[i]);
2357
2358 if ((i + 1) < orderByFields.length) {
2359 if (orderByComparator.isAscending() ^ previous) {
2360 query.append(ORDER_BY_ASC_HAS_NEXT);
2361 }
2362 else {
2363 query.append(ORDER_BY_DESC_HAS_NEXT);
2364 }
2365 }
2366 else {
2367 if (orderByComparator.isAscending() ^ previous) {
2368 query.append(ORDER_BY_ASC);
2369 }
2370 else {
2371 query.append(ORDER_BY_DESC);
2372 }
2373 }
2374 }
2375 }
2376
2377 else {
2378 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
2379 }
2380
2381 String sql = query.toString();
2382
2383 Query q = session.createQuery(sql);
2384
2385 q.setFirstResult(0);
2386 q.setMaxResults(2);
2387
2388 QueryPos qPos = QueryPos.getInstance(q);
2389
2390 qPos.add(groupId);
2391
2392 if (orderByComparator != null) {
2393 Object[] values = orderByComparator.getOrderByConditionValues(assetCategory);
2394
2395 for (Object value : values) {
2396 qPos.add(value);
2397 }
2398 }
2399
2400 List<AssetCategory> list = q.list();
2401
2402 if (list.size() == 2) {
2403 return list.get(1);
2404 }
2405 else {
2406 return null;
2407 }
2408 }
2409
2410
2417 public List<AssetCategory> filterFindByGroupId(long groupId)
2418 throws SystemException {
2419 return filterFindByGroupId(groupId, QueryUtil.ALL_POS,
2420 QueryUtil.ALL_POS, null);
2421 }
2422
2423
2436 public List<AssetCategory> filterFindByGroupId(long groupId, int start,
2437 int end) throws SystemException {
2438 return filterFindByGroupId(groupId, start, end, null);
2439 }
2440
2441
2455 public List<AssetCategory> filterFindByGroupId(long groupId, int start,
2456 int end, OrderByComparator orderByComparator) throws SystemException {
2457 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2458 return findByGroupId(groupId, start, end, orderByComparator);
2459 }
2460
2461 StringBundler query = null;
2462
2463 if (orderByComparator != null) {
2464 query = new StringBundler(3 +
2465 (orderByComparator.getOrderByFields().length * 3));
2466 }
2467 else {
2468 query = new StringBundler(3);
2469 }
2470
2471 if (getDB().isSupportsInlineDistinct()) {
2472 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_WHERE);
2473 }
2474 else {
2475 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_1);
2476 }
2477
2478 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2479
2480 if (!getDB().isSupportsInlineDistinct()) {
2481 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_2);
2482 }
2483
2484 if (orderByComparator != null) {
2485 if (getDB().isSupportsInlineDistinct()) {
2486 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2487 orderByComparator);
2488 }
2489 else {
2490 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
2491 orderByComparator);
2492 }
2493 }
2494
2495 else {
2496 if (getDB().isSupportsInlineDistinct()) {
2497 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
2498 }
2499 else {
2500 query.append(AssetCategoryModelImpl.ORDER_BY_SQL);
2501 }
2502 }
2503
2504 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2505 AssetCategory.class.getName(),
2506 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2507
2508 Session session = null;
2509
2510 try {
2511 session = openSession();
2512
2513 SQLQuery q = session.createSQLQuery(sql);
2514
2515 if (getDB().isSupportsInlineDistinct()) {
2516 q.addEntity(_FILTER_ENTITY_ALIAS, AssetCategoryImpl.class);
2517 }
2518 else {
2519 q.addEntity(_FILTER_ENTITY_TABLE, AssetCategoryImpl.class);
2520 }
2521
2522 QueryPos qPos = QueryPos.getInstance(q);
2523
2524 qPos.add(groupId);
2525
2526 return (List<AssetCategory>)QueryUtil.list(q, getDialect(), start,
2527 end);
2528 }
2529 catch (Exception e) {
2530 throw processException(e);
2531 }
2532 finally {
2533 closeSession(session);
2534 }
2535 }
2536
2537
2547 public AssetCategory[] filterFindByGroupId_PrevAndNext(long categoryId,
2548 long groupId, OrderByComparator orderByComparator)
2549 throws NoSuchCategoryException, SystemException {
2550 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2551 return findByGroupId_PrevAndNext(categoryId, groupId,
2552 orderByComparator);
2553 }
2554
2555 AssetCategory assetCategory = findByPrimaryKey(categoryId);
2556
2557 Session session = null;
2558
2559 try {
2560 session = openSession();
2561
2562 AssetCategory[] array = new AssetCategoryImpl[3];
2563
2564 array[0] = filterGetByGroupId_PrevAndNext(session, assetCategory,
2565 groupId, orderByComparator, true);
2566
2567 array[1] = assetCategory;
2568
2569 array[2] = filterGetByGroupId_PrevAndNext(session, assetCategory,
2570 groupId, orderByComparator, false);
2571
2572 return array;
2573 }
2574 catch (Exception e) {
2575 throw processException(e);
2576 }
2577 finally {
2578 closeSession(session);
2579 }
2580 }
2581
2582 protected AssetCategory filterGetByGroupId_PrevAndNext(Session session,
2583 AssetCategory assetCategory, long groupId,
2584 OrderByComparator orderByComparator, boolean previous) {
2585 StringBundler query = null;
2586
2587 if (orderByComparator != null) {
2588 query = new StringBundler(6 +
2589 (orderByComparator.getOrderByFields().length * 6));
2590 }
2591 else {
2592 query = new StringBundler(3);
2593 }
2594
2595 if (getDB().isSupportsInlineDistinct()) {
2596 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_WHERE);
2597 }
2598 else {
2599 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_1);
2600 }
2601
2602 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2603
2604 if (!getDB().isSupportsInlineDistinct()) {
2605 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_2);
2606 }
2607
2608 if (orderByComparator != null) {
2609 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2610
2611 if (orderByConditionFields.length > 0) {
2612 query.append(WHERE_AND);
2613 }
2614
2615 for (int i = 0; i < orderByConditionFields.length; i++) {
2616 if (getDB().isSupportsInlineDistinct()) {
2617 query.append(_ORDER_BY_ENTITY_ALIAS);
2618 }
2619 else {
2620 query.append(_ORDER_BY_ENTITY_TABLE);
2621 }
2622
2623 query.append(orderByConditionFields[i]);
2624
2625 if ((i + 1) < orderByConditionFields.length) {
2626 if (orderByComparator.isAscending() ^ previous) {
2627 query.append(WHERE_GREATER_THAN_HAS_NEXT);
2628 }
2629 else {
2630 query.append(WHERE_LESSER_THAN_HAS_NEXT);
2631 }
2632 }
2633 else {
2634 if (orderByComparator.isAscending() ^ previous) {
2635 query.append(WHERE_GREATER_THAN);
2636 }
2637 else {
2638 query.append(WHERE_LESSER_THAN);
2639 }
2640 }
2641 }
2642
2643 query.append(ORDER_BY_CLAUSE);
2644
2645 String[] orderByFields = orderByComparator.getOrderByFields();
2646
2647 for (int i = 0; i < orderByFields.length; i++) {
2648 if (getDB().isSupportsInlineDistinct()) {
2649 query.append(_ORDER_BY_ENTITY_ALIAS);
2650 }
2651 else {
2652 query.append(_ORDER_BY_ENTITY_TABLE);
2653 }
2654
2655 query.append(orderByFields[i]);
2656
2657 if ((i + 1) < orderByFields.length) {
2658 if (orderByComparator.isAscending() ^ previous) {
2659 query.append(ORDER_BY_ASC_HAS_NEXT);
2660 }
2661 else {
2662 query.append(ORDER_BY_DESC_HAS_NEXT);
2663 }
2664 }
2665 else {
2666 if (orderByComparator.isAscending() ^ previous) {
2667 query.append(ORDER_BY_ASC);
2668 }
2669 else {
2670 query.append(ORDER_BY_DESC);
2671 }
2672 }
2673 }
2674 }
2675
2676 else {
2677 if (getDB().isSupportsInlineDistinct()) {
2678 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
2679 }
2680 else {
2681 query.append(AssetCategoryModelImpl.ORDER_BY_SQL);
2682 }
2683 }
2684
2685 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2686 AssetCategory.class.getName(),
2687 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2688
2689 SQLQuery q = session.createSQLQuery(sql);
2690
2691 q.setFirstResult(0);
2692 q.setMaxResults(2);
2693
2694 if (getDB().isSupportsInlineDistinct()) {
2695 q.addEntity(_FILTER_ENTITY_ALIAS, AssetCategoryImpl.class);
2696 }
2697 else {
2698 q.addEntity(_FILTER_ENTITY_TABLE, AssetCategoryImpl.class);
2699 }
2700
2701 QueryPos qPos = QueryPos.getInstance(q);
2702
2703 qPos.add(groupId);
2704
2705 if (orderByComparator != null) {
2706 Object[] values = orderByComparator.getOrderByConditionValues(assetCategory);
2707
2708 for (Object value : values) {
2709 qPos.add(value);
2710 }
2711 }
2712
2713 List<AssetCategory> list = q.list();
2714
2715 if (list.size() == 2) {
2716 return list.get(1);
2717 }
2718 else {
2719 return null;
2720 }
2721 }
2722
2723
2730 public List<AssetCategory> findByParentCategoryId(long parentCategoryId)
2731 throws SystemException {
2732 return findByParentCategoryId(parentCategoryId, QueryUtil.ALL_POS,
2733 QueryUtil.ALL_POS, null);
2734 }
2735
2736
2749 public List<AssetCategory> findByParentCategoryId(long parentCategoryId,
2750 int start, int end) throws SystemException {
2751 return findByParentCategoryId(parentCategoryId, start, end, null);
2752 }
2753
2754
2768 public List<AssetCategory> findByParentCategoryId(long parentCategoryId,
2769 int start, int end, OrderByComparator orderByComparator)
2770 throws SystemException {
2771 FinderPath finderPath = null;
2772 Object[] finderArgs = null;
2773
2774 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2775 (orderByComparator == null)) {
2776 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_PARENTCATEGORYID;
2777 finderArgs = new Object[] { parentCategoryId };
2778 }
2779 else {
2780 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_PARENTCATEGORYID;
2781 finderArgs = new Object[] {
2782 parentCategoryId,
2783
2784 start, end, orderByComparator
2785 };
2786 }
2787
2788 List<AssetCategory> list = (List<AssetCategory>)FinderCacheUtil.getResult(finderPath,
2789 finderArgs, this);
2790
2791 if ((list != null) && !list.isEmpty()) {
2792 for (AssetCategory assetCategory : list) {
2793 if ((parentCategoryId != assetCategory.getParentCategoryId())) {
2794 list = null;
2795
2796 break;
2797 }
2798 }
2799 }
2800
2801 if (list == null) {
2802 StringBundler query = null;
2803
2804 if (orderByComparator != null) {
2805 query = new StringBundler(3 +
2806 (orderByComparator.getOrderByFields().length * 3));
2807 }
2808 else {
2809 query = new StringBundler(3);
2810 }
2811
2812 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
2813
2814 query.append(_FINDER_COLUMN_PARENTCATEGORYID_PARENTCATEGORYID_2);
2815
2816 if (orderByComparator != null) {
2817 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2818 orderByComparator);
2819 }
2820
2821 else {
2822 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
2823 }
2824
2825 String sql = query.toString();
2826
2827 Session session = null;
2828
2829 try {
2830 session = openSession();
2831
2832 Query q = session.createQuery(sql);
2833
2834 QueryPos qPos = QueryPos.getInstance(q);
2835
2836 qPos.add(parentCategoryId);
2837
2838 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
2839 start, end);
2840 }
2841 catch (Exception e) {
2842 throw processException(e);
2843 }
2844 finally {
2845 if (list == null) {
2846 FinderCacheUtil.removeResult(finderPath, finderArgs);
2847 }
2848 else {
2849 cacheResult(list);
2850
2851 FinderCacheUtil.putResult(finderPath, finderArgs, list);
2852 }
2853
2854 closeSession(session);
2855 }
2856 }
2857
2858 return list;
2859 }
2860
2861
2870 public AssetCategory findByParentCategoryId_First(long parentCategoryId,
2871 OrderByComparator orderByComparator)
2872 throws NoSuchCategoryException, SystemException {
2873 AssetCategory assetCategory = fetchByParentCategoryId_First(parentCategoryId,
2874 orderByComparator);
2875
2876 if (assetCategory != null) {
2877 return assetCategory;
2878 }
2879
2880 StringBundler msg = new StringBundler(4);
2881
2882 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2883
2884 msg.append("parentCategoryId=");
2885 msg.append(parentCategoryId);
2886
2887 msg.append(StringPool.CLOSE_CURLY_BRACE);
2888
2889 throw new NoSuchCategoryException(msg.toString());
2890 }
2891
2892
2900 public AssetCategory fetchByParentCategoryId_First(long parentCategoryId,
2901 OrderByComparator orderByComparator) throws SystemException {
2902 List<AssetCategory> list = findByParentCategoryId(parentCategoryId, 0,
2903 1, orderByComparator);
2904
2905 if (!list.isEmpty()) {
2906 return list.get(0);
2907 }
2908
2909 return null;
2910 }
2911
2912
2921 public AssetCategory findByParentCategoryId_Last(long parentCategoryId,
2922 OrderByComparator orderByComparator)
2923 throws NoSuchCategoryException, SystemException {
2924 AssetCategory assetCategory = fetchByParentCategoryId_Last(parentCategoryId,
2925 orderByComparator);
2926
2927 if (assetCategory != null) {
2928 return assetCategory;
2929 }
2930
2931 StringBundler msg = new StringBundler(4);
2932
2933 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2934
2935 msg.append("parentCategoryId=");
2936 msg.append(parentCategoryId);
2937
2938 msg.append(StringPool.CLOSE_CURLY_BRACE);
2939
2940 throw new NoSuchCategoryException(msg.toString());
2941 }
2942
2943
2951 public AssetCategory fetchByParentCategoryId_Last(long parentCategoryId,
2952 OrderByComparator orderByComparator) throws SystemException {
2953 int count = countByParentCategoryId(parentCategoryId);
2954
2955 List<AssetCategory> list = findByParentCategoryId(parentCategoryId,
2956 count - 1, count, orderByComparator);
2957
2958 if (!list.isEmpty()) {
2959 return list.get(0);
2960 }
2961
2962 return null;
2963 }
2964
2965
2975 public AssetCategory[] findByParentCategoryId_PrevAndNext(long categoryId,
2976 long parentCategoryId, OrderByComparator orderByComparator)
2977 throws NoSuchCategoryException, SystemException {
2978 AssetCategory assetCategory = findByPrimaryKey(categoryId);
2979
2980 Session session = null;
2981
2982 try {
2983 session = openSession();
2984
2985 AssetCategory[] array = new AssetCategoryImpl[3];
2986
2987 array[0] = getByParentCategoryId_PrevAndNext(session,
2988 assetCategory, parentCategoryId, orderByComparator, true);
2989
2990 array[1] = assetCategory;
2991
2992 array[2] = getByParentCategoryId_PrevAndNext(session,
2993 assetCategory, parentCategoryId, orderByComparator, false);
2994
2995 return array;
2996 }
2997 catch (Exception e) {
2998 throw processException(e);
2999 }
3000 finally {
3001 closeSession(session);
3002 }
3003 }
3004
3005 protected AssetCategory getByParentCategoryId_PrevAndNext(Session session,
3006 AssetCategory assetCategory, long parentCategoryId,
3007 OrderByComparator orderByComparator, boolean previous) {
3008 StringBundler query = null;
3009
3010 if (orderByComparator != null) {
3011 query = new StringBundler(6 +
3012 (orderByComparator.getOrderByFields().length * 6));
3013 }
3014 else {
3015 query = new StringBundler(3);
3016 }
3017
3018 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
3019
3020 query.append(_FINDER_COLUMN_PARENTCATEGORYID_PARENTCATEGORYID_2);
3021
3022 if (orderByComparator != null) {
3023 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3024
3025 if (orderByConditionFields.length > 0) {
3026 query.append(WHERE_AND);
3027 }
3028
3029 for (int i = 0; i < orderByConditionFields.length; i++) {
3030 query.append(_ORDER_BY_ENTITY_ALIAS);
3031 query.append(orderByConditionFields[i]);
3032
3033 if ((i + 1) < orderByConditionFields.length) {
3034 if (orderByComparator.isAscending() ^ previous) {
3035 query.append(WHERE_GREATER_THAN_HAS_NEXT);
3036 }
3037 else {
3038 query.append(WHERE_LESSER_THAN_HAS_NEXT);
3039 }
3040 }
3041 else {
3042 if (orderByComparator.isAscending() ^ previous) {
3043 query.append(WHERE_GREATER_THAN);
3044 }
3045 else {
3046 query.append(WHERE_LESSER_THAN);
3047 }
3048 }
3049 }
3050
3051 query.append(ORDER_BY_CLAUSE);
3052
3053 String[] orderByFields = orderByComparator.getOrderByFields();
3054
3055 for (int i = 0; i < orderByFields.length; i++) {
3056 query.append(_ORDER_BY_ENTITY_ALIAS);
3057 query.append(orderByFields[i]);
3058
3059 if ((i + 1) < orderByFields.length) {
3060 if (orderByComparator.isAscending() ^ previous) {
3061 query.append(ORDER_BY_ASC_HAS_NEXT);
3062 }
3063 else {
3064 query.append(ORDER_BY_DESC_HAS_NEXT);
3065 }
3066 }
3067 else {
3068 if (orderByComparator.isAscending() ^ previous) {
3069 query.append(ORDER_BY_ASC);
3070 }
3071 else {
3072 query.append(ORDER_BY_DESC);
3073 }
3074 }
3075 }
3076 }
3077
3078 else {
3079 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
3080 }
3081
3082 String sql = query.toString();
3083
3084 Query q = session.createQuery(sql);
3085
3086 q.setFirstResult(0);
3087 q.setMaxResults(2);
3088
3089 QueryPos qPos = QueryPos.getInstance(q);
3090
3091 qPos.add(parentCategoryId);
3092
3093 if (orderByComparator != null) {
3094 Object[] values = orderByComparator.getOrderByConditionValues(assetCategory);
3095
3096 for (Object value : values) {
3097 qPos.add(value);
3098 }
3099 }
3100
3101 List<AssetCategory> list = q.list();
3102
3103 if (list.size() == 2) {
3104 return list.get(1);
3105 }
3106 else {
3107 return null;
3108 }
3109 }
3110
3111
3118 public List<AssetCategory> findByVocabularyId(long vocabularyId)
3119 throws SystemException {
3120 return findByVocabularyId(vocabularyId, QueryUtil.ALL_POS,
3121 QueryUtil.ALL_POS, null);
3122 }
3123
3124
3137 public List<AssetCategory> findByVocabularyId(long vocabularyId, int start,
3138 int end) throws SystemException {
3139 return findByVocabularyId(vocabularyId, start, end, null);
3140 }
3141
3142
3156 public List<AssetCategory> findByVocabularyId(long vocabularyId, int start,
3157 int end, OrderByComparator orderByComparator) throws SystemException {
3158 FinderPath finderPath = null;
3159 Object[] finderArgs = null;
3160
3161 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
3162 (orderByComparator == null)) {
3163 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_VOCABULARYID;
3164 finderArgs = new Object[] { vocabularyId };
3165 }
3166 else {
3167 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_VOCABULARYID;
3168 finderArgs = new Object[] {
3169 vocabularyId,
3170
3171 start, end, orderByComparator
3172 };
3173 }
3174
3175 List<AssetCategory> list = (List<AssetCategory>)FinderCacheUtil.getResult(finderPath,
3176 finderArgs, this);
3177
3178 if ((list != null) && !list.isEmpty()) {
3179 for (AssetCategory assetCategory : list) {
3180 if ((vocabularyId != assetCategory.getVocabularyId())) {
3181 list = null;
3182
3183 break;
3184 }
3185 }
3186 }
3187
3188 if (list == null) {
3189 StringBundler query = null;
3190
3191 if (orderByComparator != null) {
3192 query = new StringBundler(3 +
3193 (orderByComparator.getOrderByFields().length * 3));
3194 }
3195 else {
3196 query = new StringBundler(3);
3197 }
3198
3199 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
3200
3201 query.append(_FINDER_COLUMN_VOCABULARYID_VOCABULARYID_2);
3202
3203 if (orderByComparator != null) {
3204 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3205 orderByComparator);
3206 }
3207
3208 else {
3209 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
3210 }
3211
3212 String sql = query.toString();
3213
3214 Session session = null;
3215
3216 try {
3217 session = openSession();
3218
3219 Query q = session.createQuery(sql);
3220
3221 QueryPos qPos = QueryPos.getInstance(q);
3222
3223 qPos.add(vocabularyId);
3224
3225 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
3226 start, end);
3227 }
3228 catch (Exception e) {
3229 throw processException(e);
3230 }
3231 finally {
3232 if (list == null) {
3233 FinderCacheUtil.removeResult(finderPath, finderArgs);
3234 }
3235 else {
3236 cacheResult(list);
3237
3238 FinderCacheUtil.putResult(finderPath, finderArgs, list);
3239 }
3240
3241 closeSession(session);
3242 }
3243 }
3244
3245 return list;
3246 }
3247
3248
3257 public AssetCategory findByVocabularyId_First(long vocabularyId,
3258 OrderByComparator orderByComparator)
3259 throws NoSuchCategoryException, SystemException {
3260 AssetCategory assetCategory = fetchByVocabularyId_First(vocabularyId,
3261 orderByComparator);
3262
3263 if (assetCategory != null) {
3264 return assetCategory;
3265 }
3266
3267 StringBundler msg = new StringBundler(4);
3268
3269 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3270
3271 msg.append("vocabularyId=");
3272 msg.append(vocabularyId);
3273
3274 msg.append(StringPool.CLOSE_CURLY_BRACE);
3275
3276 throw new NoSuchCategoryException(msg.toString());
3277 }
3278
3279
3287 public AssetCategory fetchByVocabularyId_First(long vocabularyId,
3288 OrderByComparator orderByComparator) throws SystemException {
3289 List<AssetCategory> list = findByVocabularyId(vocabularyId, 0, 1,
3290 orderByComparator);
3291
3292 if (!list.isEmpty()) {
3293 return list.get(0);
3294 }
3295
3296 return null;
3297 }
3298
3299
3308 public AssetCategory findByVocabularyId_Last(long vocabularyId,
3309 OrderByComparator orderByComparator)
3310 throws NoSuchCategoryException, SystemException {
3311 AssetCategory assetCategory = fetchByVocabularyId_Last(vocabularyId,
3312 orderByComparator);
3313
3314 if (assetCategory != null) {
3315 return assetCategory;
3316 }
3317
3318 StringBundler msg = new StringBundler(4);
3319
3320 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3321
3322 msg.append("vocabularyId=");
3323 msg.append(vocabularyId);
3324
3325 msg.append(StringPool.CLOSE_CURLY_BRACE);
3326
3327 throw new NoSuchCategoryException(msg.toString());
3328 }
3329
3330
3338 public AssetCategory fetchByVocabularyId_Last(long vocabularyId,
3339 OrderByComparator orderByComparator) throws SystemException {
3340 int count = countByVocabularyId(vocabularyId);
3341
3342 List<AssetCategory> list = findByVocabularyId(vocabularyId, count - 1,
3343 count, orderByComparator);
3344
3345 if (!list.isEmpty()) {
3346 return list.get(0);
3347 }
3348
3349 return null;
3350 }
3351
3352
3362 public AssetCategory[] findByVocabularyId_PrevAndNext(long categoryId,
3363 long vocabularyId, OrderByComparator orderByComparator)
3364 throws NoSuchCategoryException, SystemException {
3365 AssetCategory assetCategory = findByPrimaryKey(categoryId);
3366
3367 Session session = null;
3368
3369 try {
3370 session = openSession();
3371
3372 AssetCategory[] array = new AssetCategoryImpl[3];
3373
3374 array[0] = getByVocabularyId_PrevAndNext(session, assetCategory,
3375 vocabularyId, orderByComparator, true);
3376
3377 array[1] = assetCategory;
3378
3379 array[2] = getByVocabularyId_PrevAndNext(session, assetCategory,
3380 vocabularyId, orderByComparator, false);
3381
3382 return array;
3383 }
3384 catch (Exception e) {
3385 throw processException(e);
3386 }
3387 finally {
3388 closeSession(session);
3389 }
3390 }
3391
3392 protected AssetCategory getByVocabularyId_PrevAndNext(Session session,
3393 AssetCategory assetCategory, long vocabularyId,
3394 OrderByComparator orderByComparator, boolean previous) {
3395 StringBundler query = null;
3396
3397 if (orderByComparator != null) {
3398 query = new StringBundler(6 +
3399 (orderByComparator.getOrderByFields().length * 6));
3400 }
3401 else {
3402 query = new StringBundler(3);
3403 }
3404
3405 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
3406
3407 query.append(_FINDER_COLUMN_VOCABULARYID_VOCABULARYID_2);
3408
3409 if (orderByComparator != null) {
3410 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3411
3412 if (orderByConditionFields.length > 0) {
3413 query.append(WHERE_AND);
3414 }
3415
3416 for (int i = 0; i < orderByConditionFields.length; i++) {
3417 query.append(_ORDER_BY_ENTITY_ALIAS);
3418 query.append(orderByConditionFields[i]);
3419
3420 if ((i + 1) < orderByConditionFields.length) {
3421 if (orderByComparator.isAscending() ^ previous) {
3422 query.append(WHERE_GREATER_THAN_HAS_NEXT);
3423 }
3424 else {
3425 query.append(WHERE_LESSER_THAN_HAS_NEXT);
3426 }
3427 }
3428 else {
3429 if (orderByComparator.isAscending() ^ previous) {
3430 query.append(WHERE_GREATER_THAN);
3431 }
3432 else {
3433 query.append(WHERE_LESSER_THAN);
3434 }
3435 }
3436 }
3437
3438 query.append(ORDER_BY_CLAUSE);
3439
3440 String[] orderByFields = orderByComparator.getOrderByFields();
3441
3442 for (int i = 0; i < orderByFields.length; i++) {
3443 query.append(_ORDER_BY_ENTITY_ALIAS);
3444 query.append(orderByFields[i]);
3445
3446 if ((i + 1) < orderByFields.length) {
3447 if (orderByComparator.isAscending() ^ previous) {
3448 query.append(ORDER_BY_ASC_HAS_NEXT);
3449 }
3450 else {
3451 query.append(ORDER_BY_DESC_HAS_NEXT);
3452 }
3453 }
3454 else {
3455 if (orderByComparator.isAscending() ^ previous) {
3456 query.append(ORDER_BY_ASC);
3457 }
3458 else {
3459 query.append(ORDER_BY_DESC);
3460 }
3461 }
3462 }
3463 }
3464
3465 else {
3466 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
3467 }
3468
3469 String sql = query.toString();
3470
3471 Query q = session.createQuery(sql);
3472
3473 q.setFirstResult(0);
3474 q.setMaxResults(2);
3475
3476 QueryPos qPos = QueryPos.getInstance(q);
3477
3478 qPos.add(vocabularyId);
3479
3480 if (orderByComparator != null) {
3481 Object[] values = orderByComparator.getOrderByConditionValues(assetCategory);
3482
3483 for (Object value : values) {
3484 qPos.add(value);
3485 }
3486 }
3487
3488 List<AssetCategory> list = q.list();
3489
3490 if (list.size() == 2) {
3491 return list.get(1);
3492 }
3493 else {
3494 return null;
3495 }
3496 }
3497
3498
3506 public List<AssetCategory> findByG_V(long groupId, long vocabularyId)
3507 throws SystemException {
3508 return findByG_V(groupId, vocabularyId, QueryUtil.ALL_POS,
3509 QueryUtil.ALL_POS, null);
3510 }
3511
3512
3526 public List<AssetCategory> findByG_V(long groupId, long vocabularyId,
3527 int start, int end) throws SystemException {
3528 return findByG_V(groupId, vocabularyId, start, end, null);
3529 }
3530
3531
3546 public List<AssetCategory> findByG_V(long groupId, long vocabularyId,
3547 int start, int end, OrderByComparator orderByComparator)
3548 throws SystemException {
3549 FinderPath finderPath = null;
3550 Object[] finderArgs = null;
3551
3552 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
3553 (orderByComparator == null)) {
3554 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_V;
3555 finderArgs = new Object[] { groupId, vocabularyId };
3556 }
3557 else {
3558 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_V;
3559 finderArgs = new Object[] {
3560 groupId, vocabularyId,
3561
3562 start, end, orderByComparator
3563 };
3564 }
3565
3566 List<AssetCategory> list = (List<AssetCategory>)FinderCacheUtil.getResult(finderPath,
3567 finderArgs, this);
3568
3569 if ((list != null) && !list.isEmpty()) {
3570 for (AssetCategory assetCategory : list) {
3571 if ((groupId != assetCategory.getGroupId()) ||
3572 (vocabularyId != assetCategory.getVocabularyId())) {
3573 list = null;
3574
3575 break;
3576 }
3577 }
3578 }
3579
3580 if (list == null) {
3581 StringBundler query = null;
3582
3583 if (orderByComparator != null) {
3584 query = new StringBundler(4 +
3585 (orderByComparator.getOrderByFields().length * 3));
3586 }
3587 else {
3588 query = new StringBundler(4);
3589 }
3590
3591 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
3592
3593 query.append(_FINDER_COLUMN_G_V_GROUPID_2);
3594
3595 query.append(_FINDER_COLUMN_G_V_VOCABULARYID_2);
3596
3597 if (orderByComparator != null) {
3598 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3599 orderByComparator);
3600 }
3601
3602 else {
3603 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
3604 }
3605
3606 String sql = query.toString();
3607
3608 Session session = null;
3609
3610 try {
3611 session = openSession();
3612
3613 Query q = session.createQuery(sql);
3614
3615 QueryPos qPos = QueryPos.getInstance(q);
3616
3617 qPos.add(groupId);
3618
3619 qPos.add(vocabularyId);
3620
3621 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
3622 start, end);
3623 }
3624 catch (Exception e) {
3625 throw processException(e);
3626 }
3627 finally {
3628 if (list == null) {
3629 FinderCacheUtil.removeResult(finderPath, finderArgs);
3630 }
3631 else {
3632 cacheResult(list);
3633
3634 FinderCacheUtil.putResult(finderPath, finderArgs, list);
3635 }
3636
3637 closeSession(session);
3638 }
3639 }
3640
3641 return list;
3642 }
3643
3644
3654 public AssetCategory findByG_V_First(long groupId, long vocabularyId,
3655 OrderByComparator orderByComparator)
3656 throws NoSuchCategoryException, SystemException {
3657 AssetCategory assetCategory = fetchByG_V_First(groupId, vocabularyId,
3658 orderByComparator);
3659
3660 if (assetCategory != null) {
3661 return assetCategory;
3662 }
3663
3664 StringBundler msg = new StringBundler(6);
3665
3666 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3667
3668 msg.append("groupId=");
3669 msg.append(groupId);
3670
3671 msg.append(", vocabularyId=");
3672 msg.append(vocabularyId);
3673
3674 msg.append(StringPool.CLOSE_CURLY_BRACE);
3675
3676 throw new NoSuchCategoryException(msg.toString());
3677 }
3678
3679
3688 public AssetCategory fetchByG_V_First(long groupId, long vocabularyId,
3689 OrderByComparator orderByComparator) throws SystemException {
3690 List<AssetCategory> list = findByG_V(groupId, vocabularyId, 0, 1,
3691 orderByComparator);
3692
3693 if (!list.isEmpty()) {
3694 return list.get(0);
3695 }
3696
3697 return null;
3698 }
3699
3700
3710 public AssetCategory findByG_V_Last(long groupId, long vocabularyId,
3711 OrderByComparator orderByComparator)
3712 throws NoSuchCategoryException, SystemException {
3713 AssetCategory assetCategory = fetchByG_V_Last(groupId, vocabularyId,
3714 orderByComparator);
3715
3716 if (assetCategory != null) {
3717 return assetCategory;
3718 }
3719
3720 StringBundler msg = new StringBundler(6);
3721
3722 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3723
3724 msg.append("groupId=");
3725 msg.append(groupId);
3726
3727 msg.append(", vocabularyId=");
3728 msg.append(vocabularyId);
3729
3730 msg.append(StringPool.CLOSE_CURLY_BRACE);
3731
3732 throw new NoSuchCategoryException(msg.toString());
3733 }
3734
3735
3744 public AssetCategory fetchByG_V_Last(long groupId, long vocabularyId,
3745 OrderByComparator orderByComparator) throws SystemException {
3746 int count = countByG_V(groupId, vocabularyId);
3747
3748 List<AssetCategory> list = findByG_V(groupId, vocabularyId, count - 1,
3749 count, orderByComparator);
3750
3751 if (!list.isEmpty()) {
3752 return list.get(0);
3753 }
3754
3755 return null;
3756 }
3757
3758
3769 public AssetCategory[] findByG_V_PrevAndNext(long categoryId, long groupId,
3770 long vocabularyId, OrderByComparator orderByComparator)
3771 throws NoSuchCategoryException, SystemException {
3772 AssetCategory assetCategory = findByPrimaryKey(categoryId);
3773
3774 Session session = null;
3775
3776 try {
3777 session = openSession();
3778
3779 AssetCategory[] array = new AssetCategoryImpl[3];
3780
3781 array[0] = getByG_V_PrevAndNext(session, assetCategory, groupId,
3782 vocabularyId, orderByComparator, true);
3783
3784 array[1] = assetCategory;
3785
3786 array[2] = getByG_V_PrevAndNext(session, assetCategory, groupId,
3787 vocabularyId, orderByComparator, false);
3788
3789 return array;
3790 }
3791 catch (Exception e) {
3792 throw processException(e);
3793 }
3794 finally {
3795 closeSession(session);
3796 }
3797 }
3798
3799 protected AssetCategory getByG_V_PrevAndNext(Session session,
3800 AssetCategory assetCategory, long groupId, long vocabularyId,
3801 OrderByComparator orderByComparator, boolean previous) {
3802 StringBundler query = null;
3803
3804 if (orderByComparator != null) {
3805 query = new StringBundler(6 +
3806 (orderByComparator.getOrderByFields().length * 6));
3807 }
3808 else {
3809 query = new StringBundler(3);
3810 }
3811
3812 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
3813
3814 query.append(_FINDER_COLUMN_G_V_GROUPID_2);
3815
3816 query.append(_FINDER_COLUMN_G_V_VOCABULARYID_2);
3817
3818 if (orderByComparator != null) {
3819 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3820
3821 if (orderByConditionFields.length > 0) {
3822 query.append(WHERE_AND);
3823 }
3824
3825 for (int i = 0; i < orderByConditionFields.length; i++) {
3826 query.append(_ORDER_BY_ENTITY_ALIAS);
3827 query.append(orderByConditionFields[i]);
3828
3829 if ((i + 1) < orderByConditionFields.length) {
3830 if (orderByComparator.isAscending() ^ previous) {
3831 query.append(WHERE_GREATER_THAN_HAS_NEXT);
3832 }
3833 else {
3834 query.append(WHERE_LESSER_THAN_HAS_NEXT);
3835 }
3836 }
3837 else {
3838 if (orderByComparator.isAscending() ^ previous) {
3839 query.append(WHERE_GREATER_THAN);
3840 }
3841 else {
3842 query.append(WHERE_LESSER_THAN);
3843 }
3844 }
3845 }
3846
3847 query.append(ORDER_BY_CLAUSE);
3848
3849 String[] orderByFields = orderByComparator.getOrderByFields();
3850
3851 for (int i = 0; i < orderByFields.length; i++) {
3852 query.append(_ORDER_BY_ENTITY_ALIAS);
3853 query.append(orderByFields[i]);
3854
3855 if ((i + 1) < orderByFields.length) {
3856 if (orderByComparator.isAscending() ^ previous) {
3857 query.append(ORDER_BY_ASC_HAS_NEXT);
3858 }
3859 else {
3860 query.append(ORDER_BY_DESC_HAS_NEXT);
3861 }
3862 }
3863 else {
3864 if (orderByComparator.isAscending() ^ previous) {
3865 query.append(ORDER_BY_ASC);
3866 }
3867 else {
3868 query.append(ORDER_BY_DESC);
3869 }
3870 }
3871 }
3872 }
3873
3874 else {
3875 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
3876 }
3877
3878 String sql = query.toString();
3879
3880 Query q = session.createQuery(sql);
3881
3882 q.setFirstResult(0);
3883 q.setMaxResults(2);
3884
3885 QueryPos qPos = QueryPos.getInstance(q);
3886
3887 qPos.add(groupId);
3888
3889 qPos.add(vocabularyId);
3890
3891 if (orderByComparator != null) {
3892 Object[] values = orderByComparator.getOrderByConditionValues(assetCategory);
3893
3894 for (Object value : values) {
3895 qPos.add(value);
3896 }
3897 }
3898
3899 List<AssetCategory> list = q.list();
3900
3901 if (list.size() == 2) {
3902 return list.get(1);
3903 }
3904 else {
3905 return null;
3906 }
3907 }
3908
3909
3917 public List<AssetCategory> filterFindByG_V(long groupId, long vocabularyId)
3918 throws SystemException {
3919 return filterFindByG_V(groupId, vocabularyId, QueryUtil.ALL_POS,
3920 QueryUtil.ALL_POS, null);
3921 }
3922
3923
3937 public List<AssetCategory> filterFindByG_V(long groupId, long vocabularyId,
3938 int start, int end) throws SystemException {
3939 return filterFindByG_V(groupId, vocabularyId, start, end, null);
3940 }
3941
3942
3957 public List<AssetCategory> filterFindByG_V(long groupId, long vocabularyId,
3958 int start, int end, OrderByComparator orderByComparator)
3959 throws SystemException {
3960 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
3961 return findByG_V(groupId, vocabularyId, start, end,
3962 orderByComparator);
3963 }
3964
3965 StringBundler query = null;
3966
3967 if (orderByComparator != null) {
3968 query = new StringBundler(4 +
3969 (orderByComparator.getOrderByFields().length * 3));
3970 }
3971 else {
3972 query = new StringBundler(4);
3973 }
3974
3975 if (getDB().isSupportsInlineDistinct()) {
3976 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_WHERE);
3977 }
3978 else {
3979 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_1);
3980 }
3981
3982 query.append(_FINDER_COLUMN_G_V_GROUPID_2);
3983
3984 query.append(_FINDER_COLUMN_G_V_VOCABULARYID_2);
3985
3986 if (!getDB().isSupportsInlineDistinct()) {
3987 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_2);
3988 }
3989
3990 if (orderByComparator != null) {
3991 if (getDB().isSupportsInlineDistinct()) {
3992 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3993 orderByComparator);
3994 }
3995 else {
3996 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
3997 orderByComparator);
3998 }
3999 }
4000
4001 else {
4002 if (getDB().isSupportsInlineDistinct()) {
4003 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
4004 }
4005 else {
4006 query.append(AssetCategoryModelImpl.ORDER_BY_SQL);
4007 }
4008 }
4009
4010 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
4011 AssetCategory.class.getName(),
4012 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
4013
4014 Session session = null;
4015
4016 try {
4017 session = openSession();
4018
4019 SQLQuery q = session.createSQLQuery(sql);
4020
4021 if (getDB().isSupportsInlineDistinct()) {
4022 q.addEntity(_FILTER_ENTITY_ALIAS, AssetCategoryImpl.class);
4023 }
4024 else {
4025 q.addEntity(_FILTER_ENTITY_TABLE, AssetCategoryImpl.class);
4026 }
4027
4028 QueryPos qPos = QueryPos.getInstance(q);
4029
4030 qPos.add(groupId);
4031
4032 qPos.add(vocabularyId);
4033
4034 return (List<AssetCategory>)QueryUtil.list(q, getDialect(), start,
4035 end);
4036 }
4037 catch (Exception e) {
4038 throw processException(e);
4039 }
4040 finally {
4041 closeSession(session);
4042 }
4043 }
4044
4045
4056 public AssetCategory[] filterFindByG_V_PrevAndNext(long categoryId,
4057 long groupId, long vocabularyId, OrderByComparator orderByComparator)
4058 throws NoSuchCategoryException, SystemException {
4059 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
4060 return findByG_V_PrevAndNext(categoryId, groupId, vocabularyId,
4061 orderByComparator);
4062 }
4063
4064 AssetCategory assetCategory = findByPrimaryKey(categoryId);
4065
4066 Session session = null;
4067
4068 try {
4069 session = openSession();
4070
4071 AssetCategory[] array = new AssetCategoryImpl[3];
4072
4073 array[0] = filterGetByG_V_PrevAndNext(session, assetCategory,
4074 groupId, vocabularyId, orderByComparator, true);
4075
4076 array[1] = assetCategory;
4077
4078 array[2] = filterGetByG_V_PrevAndNext(session, assetCategory,
4079 groupId, vocabularyId, orderByComparator, false);
4080
4081 return array;
4082 }
4083 catch (Exception e) {
4084 throw processException(e);
4085 }
4086 finally {
4087 closeSession(session);
4088 }
4089 }
4090
4091 protected AssetCategory filterGetByG_V_PrevAndNext(Session session,
4092 AssetCategory assetCategory, long groupId, long vocabularyId,
4093 OrderByComparator orderByComparator, boolean previous) {
4094 StringBundler query = null;
4095
4096 if (orderByComparator != null) {
4097 query = new StringBundler(6 +
4098 (orderByComparator.getOrderByFields().length * 6));
4099 }
4100 else {
4101 query = new StringBundler(3);
4102 }
4103
4104 if (getDB().isSupportsInlineDistinct()) {
4105 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_WHERE);
4106 }
4107 else {
4108 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_1);
4109 }
4110
4111 query.append(_FINDER_COLUMN_G_V_GROUPID_2);
4112
4113 query.append(_FINDER_COLUMN_G_V_VOCABULARYID_2);
4114
4115 if (!getDB().isSupportsInlineDistinct()) {
4116 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_2);
4117 }
4118
4119 if (orderByComparator != null) {
4120 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
4121
4122 if (orderByConditionFields.length > 0) {
4123 query.append(WHERE_AND);
4124 }
4125
4126 for (int i = 0; i < orderByConditionFields.length; i++) {
4127 if (getDB().isSupportsInlineDistinct()) {
4128 query.append(_ORDER_BY_ENTITY_ALIAS);
4129 }
4130 else {
4131 query.append(_ORDER_BY_ENTITY_TABLE);
4132 }
4133
4134 query.append(orderByConditionFields[i]);
4135
4136 if ((i + 1) < orderByConditionFields.length) {
4137 if (orderByComparator.isAscending() ^ previous) {
4138 query.append(WHERE_GREATER_THAN_HAS_NEXT);
4139 }
4140 else {
4141 query.append(WHERE_LESSER_THAN_HAS_NEXT);
4142 }
4143 }
4144 else {
4145 if (orderByComparator.isAscending() ^ previous) {
4146 query.append(WHERE_GREATER_THAN);
4147 }
4148 else {
4149 query.append(WHERE_LESSER_THAN);
4150 }
4151 }
4152 }
4153
4154 query.append(ORDER_BY_CLAUSE);
4155
4156 String[] orderByFields = orderByComparator.getOrderByFields();
4157
4158 for (int i = 0; i < orderByFields.length; i++) {
4159 if (getDB().isSupportsInlineDistinct()) {
4160 query.append(_ORDER_BY_ENTITY_ALIAS);
4161 }
4162 else {
4163 query.append(_ORDER_BY_ENTITY_TABLE);
4164 }
4165
4166 query.append(orderByFields[i]);
4167
4168 if ((i + 1) < orderByFields.length) {
4169 if (orderByComparator.isAscending() ^ previous) {
4170 query.append(ORDER_BY_ASC_HAS_NEXT);
4171 }
4172 else {
4173 query.append(ORDER_BY_DESC_HAS_NEXT);
4174 }
4175 }
4176 else {
4177 if (orderByComparator.isAscending() ^ previous) {
4178 query.append(ORDER_BY_ASC);
4179 }
4180 else {
4181 query.append(ORDER_BY_DESC);
4182 }
4183 }
4184 }
4185 }
4186
4187 else {
4188 if (getDB().isSupportsInlineDistinct()) {
4189 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
4190 }
4191 else {
4192 query.append(AssetCategoryModelImpl.ORDER_BY_SQL);
4193 }
4194 }
4195
4196 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
4197 AssetCategory.class.getName(),
4198 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
4199
4200 SQLQuery q = session.createSQLQuery(sql);
4201
4202 q.setFirstResult(0);
4203 q.setMaxResults(2);
4204
4205 if (getDB().isSupportsInlineDistinct()) {
4206 q.addEntity(_FILTER_ENTITY_ALIAS, AssetCategoryImpl.class);
4207 }
4208 else {
4209 q.addEntity(_FILTER_ENTITY_TABLE, AssetCategoryImpl.class);
4210 }
4211
4212 QueryPos qPos = QueryPos.getInstance(q);
4213
4214 qPos.add(groupId);
4215
4216 qPos.add(vocabularyId);
4217
4218 if (orderByComparator != null) {
4219 Object[] values = orderByComparator.getOrderByConditionValues(assetCategory);
4220
4221 for (Object value : values) {
4222 qPos.add(value);
4223 }
4224 }
4225
4226 List<AssetCategory> list = q.list();
4227
4228 if (list.size() == 2) {
4229 return list.get(1);
4230 }
4231 else {
4232 return null;
4233 }
4234 }
4235
4236
4244 public List<AssetCategory> findByP_N(long parentCategoryId, String name)
4245 throws SystemException {
4246 return findByP_N(parentCategoryId, name, QueryUtil.ALL_POS,
4247 QueryUtil.ALL_POS, null);
4248 }
4249
4250
4264 public List<AssetCategory> findByP_N(long parentCategoryId, String name,
4265 int start, int end) throws SystemException {
4266 return findByP_N(parentCategoryId, name, start, end, null);
4267 }
4268
4269
4284 public List<AssetCategory> findByP_N(long parentCategoryId, String name,
4285 int start, int end, OrderByComparator orderByComparator)
4286 throws SystemException {
4287 FinderPath finderPath = null;
4288 Object[] finderArgs = null;
4289
4290 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
4291 (orderByComparator == null)) {
4292 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_P_N;
4293 finderArgs = new Object[] { parentCategoryId, name };
4294 }
4295 else {
4296 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_P_N;
4297 finderArgs = new Object[] {
4298 parentCategoryId, name,
4299
4300 start, end, orderByComparator
4301 };
4302 }
4303
4304 List<AssetCategory> list = (List<AssetCategory>)FinderCacheUtil.getResult(finderPath,
4305 finderArgs, this);
4306
4307 if ((list != null) && !list.isEmpty()) {
4308 for (AssetCategory assetCategory : list) {
4309 if ((parentCategoryId != assetCategory.getParentCategoryId()) ||
4310 !Validator.equals(name, assetCategory.getName())) {
4311 list = null;
4312
4313 break;
4314 }
4315 }
4316 }
4317
4318 if (list == null) {
4319 StringBundler query = null;
4320
4321 if (orderByComparator != null) {
4322 query = new StringBundler(4 +
4323 (orderByComparator.getOrderByFields().length * 3));
4324 }
4325 else {
4326 query = new StringBundler(4);
4327 }
4328
4329 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
4330
4331 query.append(_FINDER_COLUMN_P_N_PARENTCATEGORYID_2);
4332
4333 if (name == null) {
4334 query.append(_FINDER_COLUMN_P_N_NAME_1);
4335 }
4336 else {
4337 if (name.equals(StringPool.BLANK)) {
4338 query.append(_FINDER_COLUMN_P_N_NAME_3);
4339 }
4340 else {
4341 query.append(_FINDER_COLUMN_P_N_NAME_2);
4342 }
4343 }
4344
4345 if (orderByComparator != null) {
4346 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4347 orderByComparator);
4348 }
4349
4350 else {
4351 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
4352 }
4353
4354 String sql = query.toString();
4355
4356 Session session = null;
4357
4358 try {
4359 session = openSession();
4360
4361 Query q = session.createQuery(sql);
4362
4363 QueryPos qPos = QueryPos.getInstance(q);
4364
4365 qPos.add(parentCategoryId);
4366
4367 if (name != null) {
4368 qPos.add(name);
4369 }
4370
4371 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
4372 start, end);
4373 }
4374 catch (Exception e) {
4375 throw processException(e);
4376 }
4377 finally {
4378 if (list == null) {
4379 FinderCacheUtil.removeResult(finderPath, finderArgs);
4380 }
4381 else {
4382 cacheResult(list);
4383
4384 FinderCacheUtil.putResult(finderPath, finderArgs, list);
4385 }
4386
4387 closeSession(session);
4388 }
4389 }
4390
4391 return list;
4392 }
4393
4394
4404 public AssetCategory findByP_N_First(long parentCategoryId, String name,
4405 OrderByComparator orderByComparator)
4406 throws NoSuchCategoryException, SystemException {
4407 AssetCategory assetCategory = fetchByP_N_First(parentCategoryId, name,
4408 orderByComparator);
4409
4410 if (assetCategory != null) {
4411 return assetCategory;
4412 }
4413
4414 StringBundler msg = new StringBundler(6);
4415
4416 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4417
4418 msg.append("parentCategoryId=");
4419 msg.append(parentCategoryId);
4420
4421 msg.append(", name=");
4422 msg.append(name);
4423
4424 msg.append(StringPool.CLOSE_CURLY_BRACE);
4425
4426 throw new NoSuchCategoryException(msg.toString());
4427 }
4428
4429
4438 public AssetCategory fetchByP_N_First(long parentCategoryId, String name,
4439 OrderByComparator orderByComparator) throws SystemException {
4440 List<AssetCategory> list = findByP_N(parentCategoryId, name, 0, 1,
4441 orderByComparator);
4442
4443 if (!list.isEmpty()) {
4444 return list.get(0);
4445 }
4446
4447 return null;
4448 }
4449
4450
4460 public AssetCategory findByP_N_Last(long parentCategoryId, String name,
4461 OrderByComparator orderByComparator)
4462 throws NoSuchCategoryException, SystemException {
4463 AssetCategory assetCategory = fetchByP_N_Last(parentCategoryId, name,
4464 orderByComparator);
4465
4466 if (assetCategory != null) {
4467 return assetCategory;
4468 }
4469
4470 StringBundler msg = new StringBundler(6);
4471
4472 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4473
4474 msg.append("parentCategoryId=");
4475 msg.append(parentCategoryId);
4476
4477 msg.append(", name=");
4478 msg.append(name);
4479
4480 msg.append(StringPool.CLOSE_CURLY_BRACE);
4481
4482 throw new NoSuchCategoryException(msg.toString());
4483 }
4484
4485
4494 public AssetCategory fetchByP_N_Last(long parentCategoryId, String name,
4495 OrderByComparator orderByComparator) throws SystemException {
4496 int count = countByP_N(parentCategoryId, name);
4497
4498 List<AssetCategory> list = findByP_N(parentCategoryId, name, count - 1,
4499 count, orderByComparator);
4500
4501 if (!list.isEmpty()) {
4502 return list.get(0);
4503 }
4504
4505 return null;
4506 }
4507
4508
4519 public AssetCategory[] findByP_N_PrevAndNext(long categoryId,
4520 long parentCategoryId, String name, OrderByComparator orderByComparator)
4521 throws NoSuchCategoryException, SystemException {
4522 AssetCategory assetCategory = findByPrimaryKey(categoryId);
4523
4524 Session session = null;
4525
4526 try {
4527 session = openSession();
4528
4529 AssetCategory[] array = new AssetCategoryImpl[3];
4530
4531 array[0] = getByP_N_PrevAndNext(session, assetCategory,
4532 parentCategoryId, name, orderByComparator, true);
4533
4534 array[1] = assetCategory;
4535
4536 array[2] = getByP_N_PrevAndNext(session, assetCategory,
4537 parentCategoryId, name, orderByComparator, false);
4538
4539 return array;
4540 }
4541 catch (Exception e) {
4542 throw processException(e);
4543 }
4544 finally {
4545 closeSession(session);
4546 }
4547 }
4548
4549 protected AssetCategory getByP_N_PrevAndNext(Session session,
4550 AssetCategory assetCategory, long parentCategoryId, String name,
4551 OrderByComparator orderByComparator, boolean previous) {
4552 StringBundler query = null;
4553
4554 if (orderByComparator != null) {
4555 query = new StringBundler(6 +
4556 (orderByComparator.getOrderByFields().length * 6));
4557 }
4558 else {
4559 query = new StringBundler(3);
4560 }
4561
4562 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
4563
4564 query.append(_FINDER_COLUMN_P_N_PARENTCATEGORYID_2);
4565
4566 if (name == null) {
4567 query.append(_FINDER_COLUMN_P_N_NAME_1);
4568 }
4569 else {
4570 if (name.equals(StringPool.BLANK)) {
4571 query.append(_FINDER_COLUMN_P_N_NAME_3);
4572 }
4573 else {
4574 query.append(_FINDER_COLUMN_P_N_NAME_2);
4575 }
4576 }
4577
4578 if (orderByComparator != null) {
4579 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
4580
4581 if (orderByConditionFields.length > 0) {
4582 query.append(WHERE_AND);
4583 }
4584
4585 for (int i = 0; i < orderByConditionFields.length; i++) {
4586 query.append(_ORDER_BY_ENTITY_ALIAS);
4587 query.append(orderByConditionFields[i]);
4588
4589 if ((i + 1) < orderByConditionFields.length) {
4590 if (orderByComparator.isAscending() ^ previous) {
4591 query.append(WHERE_GREATER_THAN_HAS_NEXT);
4592 }
4593 else {
4594 query.append(WHERE_LESSER_THAN_HAS_NEXT);
4595 }
4596 }
4597 else {
4598 if (orderByComparator.isAscending() ^ previous) {
4599 query.append(WHERE_GREATER_THAN);
4600 }
4601 else {
4602 query.append(WHERE_LESSER_THAN);
4603 }
4604 }
4605 }
4606
4607 query.append(ORDER_BY_CLAUSE);
4608
4609 String[] orderByFields = orderByComparator.getOrderByFields();
4610
4611 for (int i = 0; i < orderByFields.length; i++) {
4612 query.append(_ORDER_BY_ENTITY_ALIAS);
4613 query.append(orderByFields[i]);
4614
4615 if ((i + 1) < orderByFields.length) {
4616 if (orderByComparator.isAscending() ^ previous) {
4617 query.append(ORDER_BY_ASC_HAS_NEXT);
4618 }
4619 else {
4620 query.append(ORDER_BY_DESC_HAS_NEXT);
4621 }
4622 }
4623 else {
4624 if (orderByComparator.isAscending() ^ previous) {
4625 query.append(ORDER_BY_ASC);
4626 }
4627 else {
4628 query.append(ORDER_BY_DESC);
4629 }
4630 }
4631 }
4632 }
4633
4634 else {
4635 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
4636 }
4637
4638 String sql = query.toString();
4639
4640 Query q = session.createQuery(sql);
4641
4642 q.setFirstResult(0);
4643 q.setMaxResults(2);
4644
4645 QueryPos qPos = QueryPos.getInstance(q);
4646
4647 qPos.add(parentCategoryId);
4648
4649 if (name != null) {
4650 qPos.add(name);
4651 }
4652
4653 if (orderByComparator != null) {
4654 Object[] values = orderByComparator.getOrderByConditionValues(assetCategory);
4655
4656 for (Object value : values) {
4657 qPos.add(value);
4658 }
4659 }
4660
4661 List<AssetCategory> list = q.list();
4662
4663 if (list.size() == 2) {
4664 return list.get(1);
4665 }
4666 else {
4667 return null;
4668 }
4669 }
4670
4671
4679 public List<AssetCategory> findByP_V(long parentCategoryId,
4680 long vocabularyId) throws SystemException {
4681 return findByP_V(parentCategoryId, vocabularyId, QueryUtil.ALL_POS,
4682 QueryUtil.ALL_POS, null);
4683 }
4684
4685
4699 public List<AssetCategory> findByP_V(long parentCategoryId,
4700 long vocabularyId, int start, int end) throws SystemException {
4701 return findByP_V(parentCategoryId, vocabularyId, start, end, null);
4702 }
4703
4704
4719 public List<AssetCategory> findByP_V(long parentCategoryId,
4720 long vocabularyId, int start, int end,
4721 OrderByComparator orderByComparator) throws SystemException {
4722 FinderPath finderPath = null;
4723 Object[] finderArgs = null;
4724
4725 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
4726 (orderByComparator == null)) {
4727 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_P_V;
4728 finderArgs = new Object[] { parentCategoryId, vocabularyId };
4729 }
4730 else {
4731 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_P_V;
4732 finderArgs = new Object[] {
4733 parentCategoryId, vocabularyId,
4734
4735 start, end, orderByComparator
4736 };
4737 }
4738
4739 List<AssetCategory> list = (List<AssetCategory>)FinderCacheUtil.getResult(finderPath,
4740 finderArgs, this);
4741
4742 if ((list != null) && !list.isEmpty()) {
4743 for (AssetCategory assetCategory : list) {
4744 if ((parentCategoryId != assetCategory.getParentCategoryId()) ||
4745 (vocabularyId != assetCategory.getVocabularyId())) {
4746 list = null;
4747
4748 break;
4749 }
4750 }
4751 }
4752
4753 if (list == null) {
4754 StringBundler query = null;
4755
4756 if (orderByComparator != null) {
4757 query = new StringBundler(4 +
4758 (orderByComparator.getOrderByFields().length * 3));
4759 }
4760 else {
4761 query = new StringBundler(4);
4762 }
4763
4764 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
4765
4766 query.append(_FINDER_COLUMN_P_V_PARENTCATEGORYID_2);
4767
4768 query.append(_FINDER_COLUMN_P_V_VOCABULARYID_2);
4769
4770 if (orderByComparator != null) {
4771 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4772 orderByComparator);
4773 }
4774
4775 else {
4776 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
4777 }
4778
4779 String sql = query.toString();
4780
4781 Session session = null;
4782
4783 try {
4784 session = openSession();
4785
4786 Query q = session.createQuery(sql);
4787
4788 QueryPos qPos = QueryPos.getInstance(q);
4789
4790 qPos.add(parentCategoryId);
4791
4792 qPos.add(vocabularyId);
4793
4794 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
4795 start, end);
4796 }
4797 catch (Exception e) {
4798 throw processException(e);
4799 }
4800 finally {
4801 if (list == null) {
4802 FinderCacheUtil.removeResult(finderPath, finderArgs);
4803 }
4804 else {
4805 cacheResult(list);
4806
4807 FinderCacheUtil.putResult(finderPath, finderArgs, list);
4808 }
4809
4810 closeSession(session);
4811 }
4812 }
4813
4814 return list;
4815 }
4816
4817
4827 public AssetCategory findByP_V_First(long parentCategoryId,
4828 long vocabularyId, OrderByComparator orderByComparator)
4829 throws NoSuchCategoryException, SystemException {
4830 AssetCategory assetCategory = fetchByP_V_First(parentCategoryId,
4831 vocabularyId, orderByComparator);
4832
4833 if (assetCategory != null) {
4834 return assetCategory;
4835 }
4836
4837 StringBundler msg = new StringBundler(6);
4838
4839 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4840
4841 msg.append("parentCategoryId=");
4842 msg.append(parentCategoryId);
4843
4844 msg.append(", vocabularyId=");
4845 msg.append(vocabularyId);
4846
4847 msg.append(StringPool.CLOSE_CURLY_BRACE);
4848
4849 throw new NoSuchCategoryException(msg.toString());
4850 }
4851
4852
4861 public AssetCategory fetchByP_V_First(long parentCategoryId,
4862 long vocabularyId, OrderByComparator orderByComparator)
4863 throws SystemException {
4864 List<AssetCategory> list = findByP_V(parentCategoryId, vocabularyId, 0,
4865 1, orderByComparator);
4866
4867 if (!list.isEmpty()) {
4868 return list.get(0);
4869 }
4870
4871 return null;
4872 }
4873
4874
4884 public AssetCategory findByP_V_Last(long parentCategoryId,
4885 long vocabularyId, OrderByComparator orderByComparator)
4886 throws NoSuchCategoryException, SystemException {
4887 AssetCategory assetCategory = fetchByP_V_Last(parentCategoryId,
4888 vocabularyId, orderByComparator);
4889
4890 if (assetCategory != null) {
4891 return assetCategory;
4892 }
4893
4894 StringBundler msg = new StringBundler(6);
4895
4896 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4897
4898 msg.append("parentCategoryId=");
4899 msg.append(parentCategoryId);
4900
4901 msg.append(", vocabularyId=");
4902 msg.append(vocabularyId);
4903
4904 msg.append(StringPool.CLOSE_CURLY_BRACE);
4905
4906 throw new NoSuchCategoryException(msg.toString());
4907 }
4908
4909
4918 public AssetCategory fetchByP_V_Last(long parentCategoryId,
4919 long vocabularyId, OrderByComparator orderByComparator)
4920 throws SystemException {
4921 int count = countByP_V(parentCategoryId, vocabularyId);
4922
4923 List<AssetCategory> list = findByP_V(parentCategoryId, vocabularyId,
4924 count - 1, count, orderByComparator);
4925
4926 if (!list.isEmpty()) {
4927 return list.get(0);
4928 }
4929
4930 return null;
4931 }
4932
4933
4944 public AssetCategory[] findByP_V_PrevAndNext(long categoryId,
4945 long parentCategoryId, long vocabularyId,
4946 OrderByComparator orderByComparator)
4947 throws NoSuchCategoryException, SystemException {
4948 AssetCategory assetCategory = findByPrimaryKey(categoryId);
4949
4950 Session session = null;
4951
4952 try {
4953 session = openSession();
4954
4955 AssetCategory[] array = new AssetCategoryImpl[3];
4956
4957 array[0] = getByP_V_PrevAndNext(session, assetCategory,
4958 parentCategoryId, vocabularyId, orderByComparator, true);
4959
4960 array[1] = assetCategory;
4961
4962 array[2] = getByP_V_PrevAndNext(session, assetCategory,
4963 parentCategoryId, vocabularyId, orderByComparator, false);
4964
4965 return array;
4966 }
4967 catch (Exception e) {
4968 throw processException(e);
4969 }
4970 finally {
4971 closeSession(session);
4972 }
4973 }
4974
4975 protected AssetCategory getByP_V_PrevAndNext(Session session,
4976 AssetCategory assetCategory, long parentCategoryId, long vocabularyId,
4977 OrderByComparator orderByComparator, boolean previous) {
4978 StringBundler query = null;
4979
4980 if (orderByComparator != null) {
4981 query = new StringBundler(6 +
4982 (orderByComparator.getOrderByFields().length * 6));
4983 }
4984 else {
4985 query = new StringBundler(3);
4986 }
4987
4988 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
4989
4990 query.append(_FINDER_COLUMN_P_V_PARENTCATEGORYID_2);
4991
4992 query.append(_FINDER_COLUMN_P_V_VOCABULARYID_2);
4993
4994 if (orderByComparator != null) {
4995 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
4996
4997 if (orderByConditionFields.length > 0) {
4998 query.append(WHERE_AND);
4999 }
5000
5001 for (int i = 0; i < orderByConditionFields.length; i++) {
5002 query.append(_ORDER_BY_ENTITY_ALIAS);
5003 query.append(orderByConditionFields[i]);
5004
5005 if ((i + 1) < orderByConditionFields.length) {
5006 if (orderByComparator.isAscending() ^ previous) {
5007 query.append(WHERE_GREATER_THAN_HAS_NEXT);
5008 }
5009 else {
5010 query.append(WHERE_LESSER_THAN_HAS_NEXT);
5011 }
5012 }
5013 else {
5014 if (orderByComparator.isAscending() ^ previous) {
5015 query.append(WHERE_GREATER_THAN);
5016 }
5017 else {
5018 query.append(WHERE_LESSER_THAN);
5019 }
5020 }
5021 }
5022
5023 query.append(ORDER_BY_CLAUSE);
5024
5025 String[] orderByFields = orderByComparator.getOrderByFields();
5026
5027 for (int i = 0; i < orderByFields.length; i++) {
5028 query.append(_ORDER_BY_ENTITY_ALIAS);
5029 query.append(orderByFields[i]);
5030
5031 if ((i + 1) < orderByFields.length) {
5032 if (orderByComparator.isAscending() ^ previous) {
5033 query.append(ORDER_BY_ASC_HAS_NEXT);
5034 }
5035 else {
5036 query.append(ORDER_BY_DESC_HAS_NEXT);
5037 }
5038 }
5039 else {
5040 if (orderByComparator.isAscending() ^ previous) {
5041 query.append(ORDER_BY_ASC);
5042 }
5043 else {
5044 query.append(ORDER_BY_DESC);
5045 }
5046 }
5047 }
5048 }
5049
5050 else {
5051 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
5052 }
5053
5054 String sql = query.toString();
5055
5056 Query q = session.createQuery(sql);
5057
5058 q.setFirstResult(0);
5059 q.setMaxResults(2);
5060
5061 QueryPos qPos = QueryPos.getInstance(q);
5062
5063 qPos.add(parentCategoryId);
5064
5065 qPos.add(vocabularyId);
5066
5067 if (orderByComparator != null) {
5068 Object[] values = orderByComparator.getOrderByConditionValues(assetCategory);
5069
5070 for (Object value : values) {
5071 qPos.add(value);
5072 }
5073 }
5074
5075 List<AssetCategory> list = q.list();
5076
5077 if (list.size() == 2) {
5078 return list.get(1);
5079 }
5080 else {
5081 return null;
5082 }
5083 }
5084
5085
5093 public List<AssetCategory> findByN_V(String name, long vocabularyId)
5094 throws SystemException {
5095 return findByN_V(name, vocabularyId, QueryUtil.ALL_POS,
5096 QueryUtil.ALL_POS, null);
5097 }
5098
5099
5113 public List<AssetCategory> findByN_V(String name, long vocabularyId,
5114 int start, int end) throws SystemException {
5115 return findByN_V(name, vocabularyId, start, end, null);
5116 }
5117
5118
5133 public List<AssetCategory> findByN_V(String name, long vocabularyId,
5134 int start, int end, OrderByComparator orderByComparator)
5135 throws SystemException {
5136 FinderPath finderPath = null;
5137 Object[] finderArgs = null;
5138
5139 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
5140 (orderByComparator == null)) {
5141 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_V;
5142 finderArgs = new Object[] { name, vocabularyId };
5143 }
5144 else {
5145 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_N_V;
5146 finderArgs = new Object[] {
5147 name, vocabularyId,
5148
5149 start, end, orderByComparator
5150 };
5151 }
5152
5153 List<AssetCategory> list = (List<AssetCategory>)FinderCacheUtil.getResult(finderPath,
5154 finderArgs, this);
5155
5156 if ((list != null) && !list.isEmpty()) {
5157 for (AssetCategory assetCategory : list) {
5158 if (!Validator.equals(name, assetCategory.getName()) ||
5159 (vocabularyId != assetCategory.getVocabularyId())) {
5160 list = null;
5161
5162 break;
5163 }
5164 }
5165 }
5166
5167 if (list == null) {
5168 StringBundler query = null;
5169
5170 if (orderByComparator != null) {
5171 query = new StringBundler(4 +
5172 (orderByComparator.getOrderByFields().length * 3));
5173 }
5174 else {
5175 query = new StringBundler(4);
5176 }
5177
5178 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
5179
5180 if (name == null) {
5181 query.append(_FINDER_COLUMN_N_V_NAME_1);
5182 }
5183 else {
5184 if (name.equals(StringPool.BLANK)) {
5185 query.append(_FINDER_COLUMN_N_V_NAME_3);
5186 }
5187 else {
5188 query.append(_FINDER_COLUMN_N_V_NAME_2);
5189 }
5190 }
5191
5192 query.append(_FINDER_COLUMN_N_V_VOCABULARYID_2);
5193
5194 if (orderByComparator != null) {
5195 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
5196 orderByComparator);
5197 }
5198
5199 else {
5200 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
5201 }
5202
5203 String sql = query.toString();
5204
5205 Session session = null;
5206
5207 try {
5208 session = openSession();
5209
5210 Query q = session.createQuery(sql);
5211
5212 QueryPos qPos = QueryPos.getInstance(q);
5213
5214 if (name != null) {
5215 qPos.add(name);
5216 }
5217
5218 qPos.add(vocabularyId);
5219
5220 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
5221 start, end);
5222 }
5223 catch (Exception e) {
5224 throw processException(e);
5225 }
5226 finally {
5227 if (list == null) {
5228 FinderCacheUtil.removeResult(finderPath, finderArgs);
5229 }
5230 else {
5231 cacheResult(list);
5232
5233 FinderCacheUtil.putResult(finderPath, finderArgs, list);
5234 }
5235
5236 closeSession(session);
5237 }
5238 }
5239
5240 return list;
5241 }
5242
5243
5253 public AssetCategory findByN_V_First(String name, long vocabularyId,
5254 OrderByComparator orderByComparator)
5255 throws NoSuchCategoryException, SystemException {
5256 AssetCategory assetCategory = fetchByN_V_First(name, vocabularyId,
5257 orderByComparator);
5258
5259 if (assetCategory != null) {
5260 return assetCategory;
5261 }
5262
5263 StringBundler msg = new StringBundler(6);
5264
5265 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5266
5267 msg.append("name=");
5268 msg.append(name);
5269
5270 msg.append(", vocabularyId=");
5271 msg.append(vocabularyId);
5272
5273 msg.append(StringPool.CLOSE_CURLY_BRACE);
5274
5275 throw new NoSuchCategoryException(msg.toString());
5276 }
5277
5278
5287 public AssetCategory fetchByN_V_First(String name, long vocabularyId,
5288 OrderByComparator orderByComparator) throws SystemException {
5289 List<AssetCategory> list = findByN_V(name, vocabularyId, 0, 1,
5290 orderByComparator);
5291
5292 if (!list.isEmpty()) {
5293 return list.get(0);
5294 }
5295
5296 return null;
5297 }
5298
5299
5309 public AssetCategory findByN_V_Last(String name, long vocabularyId,
5310 OrderByComparator orderByComparator)
5311 throws NoSuchCategoryException, SystemException {
5312 AssetCategory assetCategory = fetchByN_V_Last(name, vocabularyId,
5313 orderByComparator);
5314
5315 if (assetCategory != null) {
5316 return assetCategory;
5317 }
5318
5319 StringBundler msg = new StringBundler(6);
5320
5321 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5322
5323 msg.append("name=");
5324 msg.append(name);
5325
5326 msg.append(", vocabularyId=");
5327 msg.append(vocabularyId);
5328
5329 msg.append(StringPool.CLOSE_CURLY_BRACE);
5330
5331 throw new NoSuchCategoryException(msg.toString());
5332 }
5333
5334
5343 public AssetCategory fetchByN_V_Last(String name, long vocabularyId,
5344 OrderByComparator orderByComparator) throws SystemException {
5345 int count = countByN_V(name, vocabularyId);
5346
5347 List<AssetCategory> list = findByN_V(name, vocabularyId, count - 1,
5348 count, orderByComparator);
5349
5350 if (!list.isEmpty()) {
5351 return list.get(0);
5352 }
5353
5354 return null;
5355 }
5356
5357
5368 public AssetCategory[] findByN_V_PrevAndNext(long categoryId, String name,
5369 long vocabularyId, OrderByComparator orderByComparator)
5370 throws NoSuchCategoryException, SystemException {
5371 AssetCategory assetCategory = findByPrimaryKey(categoryId);
5372
5373 Session session = null;
5374
5375 try {
5376 session = openSession();
5377
5378 AssetCategory[] array = new AssetCategoryImpl[3];
5379
5380 array[0] = getByN_V_PrevAndNext(session, assetCategory, name,
5381 vocabularyId, orderByComparator, true);
5382
5383 array[1] = assetCategory;
5384
5385 array[2] = getByN_V_PrevAndNext(session, assetCategory, name,
5386 vocabularyId, orderByComparator, false);
5387
5388 return array;
5389 }
5390 catch (Exception e) {
5391 throw processException(e);
5392 }
5393 finally {
5394 closeSession(session);
5395 }
5396 }
5397
5398 protected AssetCategory getByN_V_PrevAndNext(Session session,
5399 AssetCategory assetCategory, String name, long vocabularyId,
5400 OrderByComparator orderByComparator, boolean previous) {
5401 StringBundler query = null;
5402
5403 if (orderByComparator != null) {
5404 query = new StringBundler(6 +
5405 (orderByComparator.getOrderByFields().length * 6));
5406 }
5407 else {
5408 query = new StringBundler(3);
5409 }
5410
5411 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
5412
5413 if (name == null) {
5414 query.append(_FINDER_COLUMN_N_V_NAME_1);
5415 }
5416 else {
5417 if (name.equals(StringPool.BLANK)) {
5418 query.append(_FINDER_COLUMN_N_V_NAME_3);
5419 }
5420 else {
5421 query.append(_FINDER_COLUMN_N_V_NAME_2);
5422 }
5423 }
5424
5425 query.append(_FINDER_COLUMN_N_V_VOCABULARYID_2);
5426
5427 if (orderByComparator != null) {
5428 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
5429
5430 if (orderByConditionFields.length > 0) {
5431 query.append(WHERE_AND);
5432 }
5433
5434 for (int i = 0; i < orderByConditionFields.length; i++) {
5435 query.append(_ORDER_BY_ENTITY_ALIAS);
5436 query.append(orderByConditionFields[i]);
5437
5438 if ((i + 1) < orderByConditionFields.length) {
5439 if (orderByComparator.isAscending() ^ previous) {
5440 query.append(WHERE_GREATER_THAN_HAS_NEXT);
5441 }
5442 else {
5443 query.append(WHERE_LESSER_THAN_HAS_NEXT);
5444 }
5445 }
5446 else {
5447 if (orderByComparator.isAscending() ^ previous) {
5448 query.append(WHERE_GREATER_THAN);
5449 }
5450 else {
5451 query.append(WHERE_LESSER_THAN);
5452 }
5453 }
5454 }
5455
5456 query.append(ORDER_BY_CLAUSE);
5457
5458 String[] orderByFields = orderByComparator.getOrderByFields();
5459
5460 for (int i = 0; i < orderByFields.length; i++) {
5461 query.append(_ORDER_BY_ENTITY_ALIAS);
5462 query.append(orderByFields[i]);
5463
5464 if ((i + 1) < orderByFields.length) {
5465 if (orderByComparator.isAscending() ^ previous) {
5466 query.append(ORDER_BY_ASC_HAS_NEXT);
5467 }
5468 else {
5469 query.append(ORDER_BY_DESC_HAS_NEXT);
5470 }
5471 }
5472 else {
5473 if (orderByComparator.isAscending() ^ previous) {
5474 query.append(ORDER_BY_ASC);
5475 }
5476 else {
5477 query.append(ORDER_BY_DESC);
5478 }
5479 }
5480 }
5481 }
5482
5483 else {
5484 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
5485 }
5486
5487 String sql = query.toString();
5488
5489 Query q = session.createQuery(sql);
5490
5491 q.setFirstResult(0);
5492 q.setMaxResults(2);
5493
5494 QueryPos qPos = QueryPos.getInstance(q);
5495
5496 if (name != null) {
5497 qPos.add(name);
5498 }
5499
5500 qPos.add(vocabularyId);
5501
5502 if (orderByComparator != null) {
5503 Object[] values = orderByComparator.getOrderByConditionValues(assetCategory);
5504
5505 for (Object value : values) {
5506 qPos.add(value);
5507 }
5508 }
5509
5510 List<AssetCategory> list = q.list();
5511
5512 if (list.size() == 2) {
5513 return list.get(1);
5514 }
5515 else {
5516 return null;
5517 }
5518 }
5519
5520
5529 public List<AssetCategory> findByG_P_N(long groupId, long parentCategoryId,
5530 String name) throws SystemException {
5531 return findByG_P_N(groupId, parentCategoryId, name, QueryUtil.ALL_POS,
5532 QueryUtil.ALL_POS, null);
5533 }
5534
5535
5550 public List<AssetCategory> findByG_P_N(long groupId, long parentCategoryId,
5551 String name, int start, int end) throws SystemException {
5552 return findByG_P_N(groupId, parentCategoryId, name, start, end, null);
5553 }
5554
5555
5571 public List<AssetCategory> findByG_P_N(long groupId, long parentCategoryId,
5572 String name, int start, int end, OrderByComparator orderByComparator)
5573 throws SystemException {
5574 FinderPath finderPath = null;
5575 Object[] finderArgs = null;
5576
5577 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
5578 (orderByComparator == null)) {
5579 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_N;
5580 finderArgs = new Object[] { groupId, parentCategoryId, name };
5581 }
5582 else {
5583 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_P_N;
5584 finderArgs = new Object[] {
5585 groupId, parentCategoryId, name,
5586
5587 start, end, orderByComparator
5588 };
5589 }
5590
5591 List<AssetCategory> list = (List<AssetCategory>)FinderCacheUtil.getResult(finderPath,
5592 finderArgs, this);
5593
5594 if ((list != null) && !list.isEmpty()) {
5595 for (AssetCategory assetCategory : list) {
5596 if ((groupId != assetCategory.getGroupId()) ||
5597 (parentCategoryId != assetCategory.getParentCategoryId()) ||
5598 !Validator.equals(name, assetCategory.getName())) {
5599 list = null;
5600
5601 break;
5602 }
5603 }
5604 }
5605
5606 if (list == null) {
5607 StringBundler query = null;
5608
5609 if (orderByComparator != null) {
5610 query = new StringBundler(5 +
5611 (orderByComparator.getOrderByFields().length * 3));
5612 }
5613 else {
5614 query = new StringBundler(5);
5615 }
5616
5617 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
5618
5619 query.append(_FINDER_COLUMN_G_P_N_GROUPID_2);
5620
5621 query.append(_FINDER_COLUMN_G_P_N_PARENTCATEGORYID_2);
5622
5623 if (name == null) {
5624 query.append(_FINDER_COLUMN_G_P_N_NAME_1);
5625 }
5626 else {
5627 if (name.equals(StringPool.BLANK)) {
5628 query.append(_FINDER_COLUMN_G_P_N_NAME_3);
5629 }
5630 else {
5631 query.append(_FINDER_COLUMN_G_P_N_NAME_2);
5632 }
5633 }
5634
5635 if (orderByComparator != null) {
5636 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
5637 orderByComparator);
5638 }
5639
5640 else {
5641 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
5642 }
5643
5644 String sql = query.toString();
5645
5646 Session session = null;
5647
5648 try {
5649 session = openSession();
5650
5651 Query q = session.createQuery(sql);
5652
5653 QueryPos qPos = QueryPos.getInstance(q);
5654
5655 qPos.add(groupId);
5656
5657 qPos.add(parentCategoryId);
5658
5659 if (name != null) {
5660 qPos.add(name);
5661 }
5662
5663 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
5664 start, end);
5665 }
5666 catch (Exception e) {
5667 throw processException(e);
5668 }
5669 finally {
5670 if (list == null) {
5671 FinderCacheUtil.removeResult(finderPath, finderArgs);
5672 }
5673 else {
5674 cacheResult(list);
5675
5676 FinderCacheUtil.putResult(finderPath, finderArgs, list);
5677 }
5678
5679 closeSession(session);
5680 }
5681 }
5682
5683 return list;
5684 }
5685
5686
5697 public AssetCategory findByG_P_N_First(long groupId, long parentCategoryId,
5698 String name, OrderByComparator orderByComparator)
5699 throws NoSuchCategoryException, SystemException {
5700 AssetCategory assetCategory = fetchByG_P_N_First(groupId,
5701 parentCategoryId, name, orderByComparator);
5702
5703 if (assetCategory != null) {
5704 return assetCategory;
5705 }
5706
5707 StringBundler msg = new StringBundler(8);
5708
5709 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5710
5711 msg.append("groupId=");
5712 msg.append(groupId);
5713
5714 msg.append(", parentCategoryId=");
5715 msg.append(parentCategoryId);
5716
5717 msg.append(", name=");
5718 msg.append(name);
5719
5720 msg.append(StringPool.CLOSE_CURLY_BRACE);
5721
5722 throw new NoSuchCategoryException(msg.toString());
5723 }
5724
5725
5735 public AssetCategory fetchByG_P_N_First(long groupId,
5736 long parentCategoryId, String name, OrderByComparator orderByComparator)
5737 throws SystemException {
5738 List<AssetCategory> list = findByG_P_N(groupId, parentCategoryId, name,
5739 0, 1, orderByComparator);
5740
5741 if (!list.isEmpty()) {
5742 return list.get(0);
5743 }
5744
5745 return null;
5746 }
5747
5748
5759 public AssetCategory findByG_P_N_Last(long groupId, long parentCategoryId,
5760 String name, OrderByComparator orderByComparator)
5761 throws NoSuchCategoryException, SystemException {
5762 AssetCategory assetCategory = fetchByG_P_N_Last(groupId,
5763 parentCategoryId, name, orderByComparator);
5764
5765 if (assetCategory != null) {
5766 return assetCategory;
5767 }
5768
5769 StringBundler msg = new StringBundler(8);
5770
5771 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5772
5773 msg.append("groupId=");
5774 msg.append(groupId);
5775
5776 msg.append(", parentCategoryId=");
5777 msg.append(parentCategoryId);
5778
5779 msg.append(", name=");
5780 msg.append(name);
5781
5782 msg.append(StringPool.CLOSE_CURLY_BRACE);
5783
5784 throw new NoSuchCategoryException(msg.toString());
5785 }
5786
5787
5797 public AssetCategory fetchByG_P_N_Last(long groupId, long parentCategoryId,
5798 String name, OrderByComparator orderByComparator)
5799 throws SystemException {
5800 int count = countByG_P_N(groupId, parentCategoryId, name);
5801
5802 List<AssetCategory> list = findByG_P_N(groupId, parentCategoryId, name,
5803 count - 1, count, orderByComparator);
5804
5805 if (!list.isEmpty()) {
5806 return list.get(0);
5807 }
5808
5809 return null;
5810 }
5811
5812
5824 public AssetCategory[] findByG_P_N_PrevAndNext(long categoryId,
5825 long groupId, long parentCategoryId, String name,
5826 OrderByComparator orderByComparator)
5827 throws NoSuchCategoryException, SystemException {
5828 AssetCategory assetCategory = findByPrimaryKey(categoryId);
5829
5830 Session session = null;
5831
5832 try {
5833 session = openSession();
5834
5835 AssetCategory[] array = new AssetCategoryImpl[3];
5836
5837 array[0] = getByG_P_N_PrevAndNext(session, assetCategory, groupId,
5838 parentCategoryId, name, orderByComparator, true);
5839
5840 array[1] = assetCategory;
5841
5842 array[2] = getByG_P_N_PrevAndNext(session, assetCategory, groupId,
5843 parentCategoryId, name, orderByComparator, false);
5844
5845 return array;
5846 }
5847 catch (Exception e) {
5848 throw processException(e);
5849 }
5850 finally {
5851 closeSession(session);
5852 }
5853 }
5854
5855 protected AssetCategory getByG_P_N_PrevAndNext(Session session,
5856 AssetCategory assetCategory, long groupId, long parentCategoryId,
5857 String name, OrderByComparator orderByComparator, boolean previous) {
5858 StringBundler query = null;
5859
5860 if (orderByComparator != null) {
5861 query = new StringBundler(6 +
5862 (orderByComparator.getOrderByFields().length * 6));
5863 }
5864 else {
5865 query = new StringBundler(3);
5866 }
5867
5868 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
5869
5870 query.append(_FINDER_COLUMN_G_P_N_GROUPID_2);
5871
5872 query.append(_FINDER_COLUMN_G_P_N_PARENTCATEGORYID_2);
5873
5874 if (name == null) {
5875 query.append(_FINDER_COLUMN_G_P_N_NAME_1);
5876 }
5877 else {
5878 if (name.equals(StringPool.BLANK)) {
5879 query.append(_FINDER_COLUMN_G_P_N_NAME_3);
5880 }
5881 else {
5882 query.append(_FINDER_COLUMN_G_P_N_NAME_2);
5883 }
5884 }
5885
5886 if (orderByComparator != null) {
5887 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
5888
5889 if (orderByConditionFields.length > 0) {
5890 query.append(WHERE_AND);
5891 }
5892
5893 for (int i = 0; i < orderByConditionFields.length; i++) {
5894 query.append(_ORDER_BY_ENTITY_ALIAS);
5895 query.append(orderByConditionFields[i]);
5896
5897 if ((i + 1) < orderByConditionFields.length) {
5898 if (orderByComparator.isAscending() ^ previous) {
5899 query.append(WHERE_GREATER_THAN_HAS_NEXT);
5900 }
5901 else {
5902 query.append(WHERE_LESSER_THAN_HAS_NEXT);
5903 }
5904 }
5905 else {
5906 if (orderByComparator.isAscending() ^ previous) {
5907 query.append(WHERE_GREATER_THAN);
5908 }
5909 else {
5910 query.append(WHERE_LESSER_THAN);
5911 }
5912 }
5913 }
5914
5915 query.append(ORDER_BY_CLAUSE);
5916
5917 String[] orderByFields = orderByComparator.getOrderByFields();
5918
5919 for (int i = 0; i < orderByFields.length; i++) {
5920 query.append(_ORDER_BY_ENTITY_ALIAS);
5921 query.append(orderByFields[i]);
5922
5923 if ((i + 1) < orderByFields.length) {
5924 if (orderByComparator.isAscending() ^ previous) {
5925 query.append(ORDER_BY_ASC_HAS_NEXT);
5926 }
5927 else {
5928 query.append(ORDER_BY_DESC_HAS_NEXT);
5929 }
5930 }
5931 else {
5932 if (orderByComparator.isAscending() ^ previous) {
5933 query.append(ORDER_BY_ASC);
5934 }
5935 else {
5936 query.append(ORDER_BY_DESC);
5937 }
5938 }
5939 }
5940 }
5941
5942 else {
5943 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
5944 }
5945
5946 String sql = query.toString();
5947
5948 Query q = session.createQuery(sql);
5949
5950 q.setFirstResult(0);
5951 q.setMaxResults(2);
5952
5953 QueryPos qPos = QueryPos.getInstance(q);
5954
5955 qPos.add(groupId);
5956
5957 qPos.add(parentCategoryId);
5958
5959 if (name != null) {
5960 qPos.add(name);
5961 }
5962
5963 if (orderByComparator != null) {
5964 Object[] values = orderByComparator.getOrderByConditionValues(assetCategory);
5965
5966 for (Object value : values) {
5967 qPos.add(value);
5968 }
5969 }
5970
5971 List<AssetCategory> list = q.list();
5972
5973 if (list.size() == 2) {
5974 return list.get(1);
5975 }
5976 else {
5977 return null;
5978 }
5979 }
5980
5981
5990 public List<AssetCategory> filterFindByG_P_N(long groupId,
5991 long parentCategoryId, String name) throws SystemException {
5992 return filterFindByG_P_N(groupId, parentCategoryId, name,
5993 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
5994 }
5995
5996
6011 public List<AssetCategory> filterFindByG_P_N(long groupId,
6012 long parentCategoryId, String name, int start, int end)
6013 throws SystemException {
6014 return filterFindByG_P_N(groupId, parentCategoryId, name, start, end,
6015 null);
6016 }
6017
6018
6034 public List<AssetCategory> filterFindByG_P_N(long groupId,
6035 long parentCategoryId, String name, int start, int end,
6036 OrderByComparator orderByComparator) throws SystemException {
6037 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
6038 return findByG_P_N(groupId, parentCategoryId, name, start, end,
6039 orderByComparator);
6040 }
6041
6042 StringBundler query = null;
6043
6044 if (orderByComparator != null) {
6045 query = new StringBundler(5 +
6046 (orderByComparator.getOrderByFields().length * 3));
6047 }
6048 else {
6049 query = new StringBundler(5);
6050 }
6051
6052 if (getDB().isSupportsInlineDistinct()) {
6053 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_WHERE);
6054 }
6055 else {
6056 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_1);
6057 }
6058
6059 query.append(_FINDER_COLUMN_G_P_N_GROUPID_2);
6060
6061 query.append(_FINDER_COLUMN_G_P_N_PARENTCATEGORYID_2);
6062
6063 if (name == null) {
6064 query.append(_FINDER_COLUMN_G_P_N_NAME_1);
6065 }
6066 else {
6067 if (name.equals(StringPool.BLANK)) {
6068 query.append(_FINDER_COLUMN_G_P_N_NAME_3);
6069 }
6070 else {
6071 query.append(_FINDER_COLUMN_G_P_N_NAME_2);
6072 }
6073 }
6074
6075 if (!getDB().isSupportsInlineDistinct()) {
6076 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_2);
6077 }
6078
6079 if (orderByComparator != null) {
6080 if (getDB().isSupportsInlineDistinct()) {
6081 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
6082 orderByComparator);
6083 }
6084 else {
6085 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
6086 orderByComparator);
6087 }
6088 }
6089
6090 else {
6091 if (getDB().isSupportsInlineDistinct()) {
6092 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
6093 }
6094 else {
6095 query.append(AssetCategoryModelImpl.ORDER_BY_SQL);
6096 }
6097 }
6098
6099 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
6100 AssetCategory.class.getName(),
6101 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
6102
6103 Session session = null;
6104
6105 try {
6106 session = openSession();
6107
6108 SQLQuery q = session.createSQLQuery(sql);
6109
6110 if (getDB().isSupportsInlineDistinct()) {
6111 q.addEntity(_FILTER_ENTITY_ALIAS, AssetCategoryImpl.class);
6112 }
6113 else {
6114 q.addEntity(_FILTER_ENTITY_TABLE, AssetCategoryImpl.class);
6115 }
6116
6117 QueryPos qPos = QueryPos.getInstance(q);
6118
6119 qPos.add(groupId);
6120
6121 qPos.add(parentCategoryId);
6122
6123 if (name != null) {
6124 qPos.add(name);
6125 }
6126
6127 return (List<AssetCategory>)QueryUtil.list(q, getDialect(), start,
6128 end);
6129 }
6130 catch (Exception e) {
6131 throw processException(e);
6132 }
6133 finally {
6134 closeSession(session);
6135 }
6136 }
6137
6138
6150 public AssetCategory[] filterFindByG_P_N_PrevAndNext(long categoryId,
6151 long groupId, long parentCategoryId, String name,
6152 OrderByComparator orderByComparator)
6153 throws NoSuchCategoryException, SystemException {
6154 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
6155 return findByG_P_N_PrevAndNext(categoryId, groupId,
6156 parentCategoryId, name, orderByComparator);
6157 }
6158
6159 AssetCategory assetCategory = findByPrimaryKey(categoryId);
6160
6161 Session session = null;
6162
6163 try {
6164 session = openSession();
6165
6166 AssetCategory[] array = new AssetCategoryImpl[3];
6167
6168 array[0] = filterGetByG_P_N_PrevAndNext(session, assetCategory,
6169 groupId, parentCategoryId, name, orderByComparator, true);
6170
6171 array[1] = assetCategory;
6172
6173 array[2] = filterGetByG_P_N_PrevAndNext(session, assetCategory,
6174 groupId, parentCategoryId, name, orderByComparator, false);
6175
6176 return array;
6177 }
6178 catch (Exception e) {
6179 throw processException(e);
6180 }
6181 finally {
6182 closeSession(session);
6183 }
6184 }
6185
6186 protected AssetCategory filterGetByG_P_N_PrevAndNext(Session session,
6187 AssetCategory assetCategory, long groupId, long parentCategoryId,
6188 String name, OrderByComparator orderByComparator, boolean previous) {
6189 StringBundler query = null;
6190
6191 if (orderByComparator != null) {
6192 query = new StringBundler(6 +
6193 (orderByComparator.getOrderByFields().length * 6));
6194 }
6195 else {
6196 query = new StringBundler(3);
6197 }
6198
6199 if (getDB().isSupportsInlineDistinct()) {
6200 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_WHERE);
6201 }
6202 else {
6203 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_1);
6204 }
6205
6206 query.append(_FINDER_COLUMN_G_P_N_GROUPID_2);
6207
6208 query.append(_FINDER_COLUMN_G_P_N_PARENTCATEGORYID_2);
6209
6210 if (name == null) {
6211 query.append(_FINDER_COLUMN_G_P_N_NAME_1);
6212 }
6213 else {
6214 if (name.equals(StringPool.BLANK)) {
6215 query.append(_FINDER_COLUMN_G_P_N_NAME_3);
6216 }
6217 else {
6218 query.append(_FINDER_COLUMN_G_P_N_NAME_2);
6219 }
6220 }
6221
6222 if (!getDB().isSupportsInlineDistinct()) {
6223 query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_2);
6224 }
6225
6226 if (orderByComparator != null) {
6227 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
6228
6229 if (orderByConditionFields.length > 0) {
6230 query.append(WHERE_AND);
6231 }
6232
6233 for (int i = 0; i < orderByConditionFields.length; i++) {
6234 if (getDB().isSupportsInlineDistinct()) {
6235 query.append(_ORDER_BY_ENTITY_ALIAS);
6236 }
6237 else {
6238 query.append(_ORDER_BY_ENTITY_TABLE);
6239 }
6240
6241 query.append(orderByConditionFields[i]);
6242
6243 if ((i + 1) < orderByConditionFields.length) {
6244 if (orderByComparator.isAscending() ^ previous) {
6245 query.append(WHERE_GREATER_THAN_HAS_NEXT);
6246 }
6247 else {
6248 query.append(WHERE_LESSER_THAN_HAS_NEXT);
6249 }
6250 }
6251 else {
6252 if (orderByComparator.isAscending() ^ previous) {
6253 query.append(WHERE_GREATER_THAN);
6254 }
6255 else {
6256 query.append(WHERE_LESSER_THAN);
6257 }
6258 }
6259 }
6260
6261 query.append(ORDER_BY_CLAUSE);
6262
6263 String[] orderByFields = orderByComparator.getOrderByFields();
6264
6265 for (int i = 0; i < orderByFields.length; i++) {
6266 if (getDB().isSupportsInlineDistinct()) {
6267 query.append(_ORDER_BY_ENTITY_ALIAS);
6268 }
6269 else {
6270 query.append(_ORDER_BY_ENTITY_TABLE);
6271 }
6272
6273 query.append(orderByFields[i]);
6274
6275 if ((i + 1) < orderByFields.length) {
6276 if (orderByComparator.isAscending() ^ previous) {
6277 query.append(ORDER_BY_ASC_HAS_NEXT);
6278 }
6279 else {
6280 query.append(ORDER_BY_DESC_HAS_NEXT);
6281 }
6282 }
6283 else {
6284 if (orderByComparator.isAscending() ^ previous) {
6285 query.append(ORDER_BY_ASC);
6286 }
6287 else {
6288 query.append(ORDER_BY_DESC);
6289 }
6290 }
6291 }
6292 }
6293
6294 else {
6295 if (getDB().isSupportsInlineDistinct()) {
6296 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
6297 }
6298 else {
6299 query.append(AssetCategoryModelImpl.ORDER_BY_SQL);
6300 }
6301 }
6302
6303 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
6304 AssetCategory.class.getName(),
6305 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
6306
6307 SQLQuery q = session.createSQLQuery(sql);
6308
6309 q.setFirstResult(0);
6310 q.setMaxResults(2);
6311
6312 if (getDB().isSupportsInlineDistinct()) {
6313 q.addEntity(_FILTER_ENTITY_ALIAS, AssetCategoryImpl.class);
6314 }
6315 else {
6316 q.addEntity(_FILTER_ENTITY_TABLE, AssetCategoryImpl.class);
6317 }
6318
6319 QueryPos qPos = QueryPos.getInstance(q);
6320
6321 qPos.add(groupId);
6322
6323 qPos.add(parentCategoryId);
6324
6325 if (name != null) {
6326 qPos.add(name);
6327 }
6328
6329 if (orderByComparator != null) {
6330 Object[] values = orderByComparator.getOrderByConditionValues(assetCategory);
6331
6332 for (Object value : values) {
6333 qPos.add(value);
6334 }
6335 }
6336
6337 List<AssetCategory> list = q.list();
6338
6339 if (list.size() == 2) {
6340 return list.get(1);
6341 }
6342 else {
6343 return null;
6344 }
6345 }
6346
6347
6357 public AssetCategory findByP_N_V(long parentCategoryId, String name,
6358 long vocabularyId) throws NoSuchCategoryException, SystemException {
6359 AssetCategory assetCategory = fetchByP_N_V(parentCategoryId, name,
6360 vocabularyId);
6361
6362 if (assetCategory == null) {
6363 StringBundler msg = new StringBundler(8);
6364
6365 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
6366
6367 msg.append("parentCategoryId=");
6368 msg.append(parentCategoryId);
6369
6370 msg.append(", name=");
6371 msg.append(name);
6372
6373 msg.append(", vocabularyId=");
6374 msg.append(vocabularyId);
6375
6376 msg.append(StringPool.CLOSE_CURLY_BRACE);
6377
6378 if (_log.isWarnEnabled()) {
6379 _log.warn(msg.toString());
6380 }
6381
6382 throw new NoSuchCategoryException(msg.toString());
6383 }
6384
6385 return assetCategory;
6386 }
6387
6388
6397 public AssetCategory fetchByP_N_V(long parentCategoryId, String name,
6398 long vocabularyId) throws SystemException {
6399 return fetchByP_N_V(parentCategoryId, name, vocabularyId, true);
6400 }
6401
6402
6412 public AssetCategory fetchByP_N_V(long parentCategoryId, String name,
6413 long vocabularyId, boolean retrieveFromCache) throws SystemException {
6414 Object[] finderArgs = new Object[] { parentCategoryId, name, vocabularyId };
6415
6416 Object result = null;
6417
6418 if (retrieveFromCache) {
6419 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_P_N_V,
6420 finderArgs, this);
6421 }
6422
6423 if (result instanceof AssetCategory) {
6424 AssetCategory assetCategory = (AssetCategory)result;
6425
6426 if ((parentCategoryId != assetCategory.getParentCategoryId()) ||
6427 !Validator.equals(name, assetCategory.getName()) ||
6428 (vocabularyId != assetCategory.getVocabularyId())) {
6429 result = null;
6430 }
6431 }
6432
6433 if (result == null) {
6434 StringBundler query = new StringBundler(5);
6435
6436 query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
6437
6438 query.append(_FINDER_COLUMN_P_N_V_PARENTCATEGORYID_2);
6439
6440 if (name == null) {
6441 query.append(_FINDER_COLUMN_P_N_V_NAME_1);
6442 }
6443 else {
6444 if (name.equals(StringPool.BLANK)) {
6445 query.append(_FINDER_COLUMN_P_N_V_NAME_3);
6446 }
6447 else {
6448 query.append(_FINDER_COLUMN_P_N_V_NAME_2);
6449 }
6450 }
6451
6452 query.append(_FINDER_COLUMN_P_N_V_VOCABULARYID_2);
6453
6454 query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
6455
6456 String sql = query.toString();
6457
6458 Session session = null;
6459
6460 try {
6461 session = openSession();
6462
6463 Query q = session.createQuery(sql);
6464
6465 QueryPos qPos = QueryPos.getInstance(q);
6466
6467 qPos.add(parentCategoryId);
6468
6469 if (name != null) {
6470 qPos.add(name);
6471 }
6472
6473 qPos.add(vocabularyId);
6474
6475 List<AssetCategory> list = q.list();
6476
6477 result = list;
6478
6479 AssetCategory assetCategory = null;
6480
6481 if (list.isEmpty()) {
6482 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_P_N_V,
6483 finderArgs, list);
6484 }
6485 else {
6486 assetCategory = list.get(0);
6487
6488 cacheResult(assetCategory);
6489
6490 if ((assetCategory.getParentCategoryId() != parentCategoryId) ||
6491 (assetCategory.getName() == null) ||
6492 !assetCategory.getName().equals(name) ||
6493 (assetCategory.getVocabularyId() != vocabularyId)) {
6494 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_P_N_V,
6495 finderArgs, assetCategory);
6496 }
6497 }
6498
6499 return assetCategory;
6500 }
6501 catch (Exception e) {
6502 throw processException(e);
6503 }
6504 finally {
6505 if (result == null) {
6506 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_P_N_V,
6507 finderArgs);
6508 }
6509
6510 closeSession(session);
6511 }
6512 }
6513 else {
6514 if (result instanceof List<?>) {
6515 return null;
6516 }
6517 else {
6518 return (AssetCategory)result;
6519 }
6520 }
6521 }
6522
6523
6529 public List<AssetCategory> findAll() throws SystemException {
6530 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
6531 }
6532
6533
6545 public List<AssetCategory> findAll(int start, int end)
6546 throws SystemException {
6547 return findAll(start, end, null);
6548 }
6549
6550
6563 public List<AssetCategory> findAll(int start, int end,
6564 OrderByComparator orderByComparator) throws SystemException {
6565 FinderPath finderPath = null;
6566 Object[] finderArgs = new Object[] { start, end, orderByComparator };
6567
6568 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
6569 (orderByComparator == null)) {
6570 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
6571 finderArgs = FINDER_ARGS_EMPTY;
6572 }
6573 else {
6574 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
6575 finderArgs = new Object[] { start, end, orderByComparator };
6576 }
6577
6578 List<AssetCategory> list = (List<AssetCategory>)FinderCacheUtil.getResult(finderPath,
6579 finderArgs, this);
6580
6581 if (list == null) {
6582 StringBundler query = null;
6583 String sql = null;
6584
6585 if (orderByComparator != null) {
6586 query = new StringBundler(2 +
6587 (orderByComparator.getOrderByFields().length * 3));
6588
6589 query.append(_SQL_SELECT_ASSETCATEGORY);
6590
6591 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
6592 orderByComparator);
6593
6594 sql = query.toString();
6595 }
6596 else {
6597 sql = _SQL_SELECT_ASSETCATEGORY.concat(AssetCategoryModelImpl.ORDER_BY_JPQL);
6598 }
6599
6600 Session session = null;
6601
6602 try {
6603 session = openSession();
6604
6605 Query q = session.createQuery(sql);
6606
6607 if (orderByComparator == null) {
6608 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
6609 start, end, false);
6610
6611 Collections.sort(list);
6612 }
6613 else {
6614 list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
6615 start, end);
6616 }
6617 }
6618 catch (Exception e) {
6619 throw processException(e);
6620 }
6621 finally {
6622 if (list == null) {
6623 FinderCacheUtil.removeResult(finderPath, finderArgs);
6624 }
6625 else {
6626 cacheResult(list);
6627
6628 FinderCacheUtil.putResult(finderPath, finderArgs, list);
6629 }
6630
6631 closeSession(session);
6632 }
6633 }
6634
6635 return list;
6636 }
6637
6638
6644 public void removeByUuid(String uuid) throws SystemException {
6645 for (AssetCategory assetCategory : findByUuid(uuid)) {
6646 remove(assetCategory);
6647 }
6648 }
6649
6650
6658 public AssetCategory removeByUUID_G(String uuid, long groupId)
6659 throws NoSuchCategoryException, SystemException {
6660 AssetCategory assetCategory = findByUUID_G(uuid, groupId);
6661
6662 return remove(assetCategory);
6663 }
6664
6665
6672 public void removeByUuid_C(String uuid, long companyId)
6673 throws SystemException {
6674 for (AssetCategory assetCategory : findByUuid_C(uuid, companyId)) {
6675 remove(assetCategory);
6676 }
6677 }
6678
6679
6685 public void removeByGroupId(long groupId) throws SystemException {
6686 for (AssetCategory assetCategory : findByGroupId(groupId)) {
6687 remove(assetCategory);
6688 }
6689 }
6690
6691
6697 public void removeByParentCategoryId(long parentCategoryId)
6698 throws SystemException {
6699 for (AssetCategory assetCategory : findByParentCategoryId(
6700 parentCategoryId)) {
6701 remove(assetCategory);
6702 }
6703 }
6704
6705
6711 public void removeByVocabularyId(long vocabularyId)
6712 throws SystemException {
6713 for (AssetCategory assetCategory : findByVocabularyId(vocabularyId)) {
6714 remove(assetCategory);
6715 }
6716 }
6717
6718
6725 public void removeByG_V(long groupId, long vocabularyId)
6726 throws SystemException {
6727 for (AssetCategory assetCategory : findByG_V(groupId, vocabularyId)) {
6728 remove(assetCategory);
6729 }
6730 }
6731
6732
6739 public void removeByP_N(long parentCategoryId, String name)
6740 throws SystemException {
6741 for (AssetCategory assetCategory : findByP_N(parentCategoryId, name)) {
6742 remove(assetCategory);
6743 }
6744 }
6745
6746
6753 public void removeByP_V(long parentCategoryId, long vocabularyId)
6754 throws SystemException {
6755 for (AssetCategory assetCategory : findByP_V(parentCategoryId,
6756 vocabularyId)) {
6757 remove(assetCategory);
6758 }
6759 }
6760
6761
6768 public void removeByN_V(String name, long vocabularyId)
6769 throws SystemException {
6770 for (AssetCategory assetCategory : findByN_V(name, vocabularyId)) {
6771 remove(assetCategory);
6772 }
6773 }
6774
6775
6783 public void removeByG_P_N(long groupId, long parentCategoryId, String name)
6784 throws SystemException {
6785 for (AssetCategory assetCategory : findByG_P_N(groupId,
6786 parentCategoryId, name)) {
6787 remove(assetCategory);
6788 }
6789 }
6790
6791
6800 public AssetCategory removeByP_N_V(long parentCategoryId, String name,
6801 long vocabularyId) throws NoSuchCategoryException, SystemException {
6802 AssetCategory assetCategory = findByP_N_V(parentCategoryId, name,
6803 vocabularyId);
6804
6805 return remove(assetCategory);
6806 }
6807
6808
6813 public void removeAll() throws SystemException {
6814 for (AssetCategory assetCategory : findAll()) {
6815 remove(assetCategory);
6816 }
6817 }
6818
6819
6826 public int countByUuid(String uuid) throws SystemException {
6827 Object[] finderArgs = new Object[] { uuid };
6828
6829 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID,
6830 finderArgs, this);
6831
6832 if (count == null) {
6833 StringBundler query = new StringBundler(2);
6834
6835 query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
6836
6837 if (uuid == null) {
6838 query.append(_FINDER_COLUMN_UUID_UUID_1);
6839 }
6840 else {
6841 if (uuid.equals(StringPool.BLANK)) {
6842 query.append(_FINDER_COLUMN_UUID_UUID_3);
6843 }
6844 else {
6845 query.append(_FINDER_COLUMN_UUID_UUID_2);
6846 }
6847 }
6848
6849 String sql = query.toString();
6850
6851 Session session = null;
6852
6853 try {
6854 session = openSession();
6855
6856 Query q = session.createQuery(sql);
6857
6858 QueryPos qPos = QueryPos.getInstance(q);
6859
6860 if (uuid != null) {
6861 qPos.add(uuid);
6862 }
6863
6864 count = (Long)q.uniqueResult();
6865 }
6866 catch (Exception e) {
6867 throw processException(e);
6868 }
6869 finally {
6870 if (count == null) {
6871 count = Long.valueOf(0);
6872 }
6873
6874 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID,
6875 finderArgs, count);
6876
6877 closeSession(session);
6878 }
6879 }
6880
6881 return count.intValue();
6882 }
6883
6884
6892 public int countByUUID_G(String uuid, long groupId)
6893 throws SystemException {
6894 Object[] finderArgs = new Object[] { uuid, groupId };
6895
6896 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID_G,
6897 finderArgs, this);
6898
6899 if (count == null) {
6900 StringBundler query = new StringBundler(3);
6901
6902 query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
6903
6904 if (uuid == null) {
6905 query.append(_FINDER_COLUMN_UUID_G_UUID_1);
6906 }
6907 else {
6908 if (uuid.equals(StringPool.BLANK)) {
6909 query.append(_FINDER_COLUMN_UUID_G_UUID_3);
6910 }
6911 else {
6912 query.append(_FINDER_COLUMN_UUID_G_UUID_2);
6913 }
6914 }
6915
6916 query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
6917
6918 String sql = query.toString();
6919
6920 Session session = null;
6921
6922 try {
6923 session = openSession();
6924
6925 Query q = session.createQuery(sql);
6926
6927 QueryPos qPos = QueryPos.getInstance(q);
6928
6929 if (uuid != null) {
6930 qPos.add(uuid);
6931 }
6932
6933 qPos.add(groupId);
6934
6935 count = (Long)q.uniqueResult();
6936 }
6937 catch (Exception e) {
6938 throw processException(e);
6939 }
6940 finally {
6941 if (count == null) {
6942 count = Long.valueOf(0);
6943 }
6944
6945 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G,
6946 finderArgs, count);
6947
6948 closeSession(session);
6949 }
6950 }
6951
6952 return count.intValue();
6953 }
6954
6955
6963 public int countByUuid_C(String uuid, long companyId)
6964 throws SystemException {
6965 Object[] finderArgs = new Object[] { uuid, companyId };
6966
6967 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID_C,
6968 finderArgs, this);
6969
6970 if (count == null) {
6971 StringBundler query = new StringBundler(3);
6972
6973 query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
6974
6975 if (uuid == null) {
6976 query.append(_FINDER_COLUMN_UUID_C_UUID_1);
6977 }
6978 else {
6979 if (uuid.equals(StringPool.BLANK)) {
6980 query.append(_FINDER_COLUMN_UUID_C_UUID_3);
6981 }
6982 else {
6983 query.append(_FINDER_COLUMN_UUID_C_UUID_2);
6984 }
6985 }
6986
6987 query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
6988
6989 String sql = query.toString();
6990
6991 Session session = null;
6992
6993 try {
6994 session = openSession();
6995
6996 Query q = session.createQuery(sql);
6997
6998 QueryPos qPos = QueryPos.getInstance(q);
6999
7000 if (uuid != null) {
7001 qPos.add(uuid);
7002 }
7003
7004 qPos.add(companyId);
7005
7006 count = (Long)q.uniqueResult();
7007 }
7008 catch (Exception e) {
7009 throw processException(e);
7010 }
7011 finally {
7012 if (count == null) {
7013 count = Long.valueOf(0);
7014 }
7015
7016 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_C,
7017 finderArgs, count);
7018
7019 closeSession(session);
7020 }
7021 }
7022
7023 return count.intValue();
7024 }
7025
7026
7033 public int countByGroupId(long groupId) throws SystemException {
7034 Object[] finderArgs = new Object[] { groupId };
7035
7036 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_GROUPID,
7037 finderArgs, this);
7038
7039 if (count == null) {
7040 StringBundler query = new StringBundler(2);
7041
7042 query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
7043
7044 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
7045
7046 String sql = query.toString();
7047
7048 Session session = null;
7049
7050 try {
7051 session = openSession();
7052
7053 Query q = session.createQuery(sql);
7054
7055 QueryPos qPos = QueryPos.getInstance(q);
7056
7057 qPos.add(groupId);
7058
7059 count = (Long)q.uniqueResult();
7060 }
7061 catch (Exception e) {
7062 throw processException(e);
7063 }
7064 finally {
7065 if (count == null) {
7066 count = Long.valueOf(0);
7067 }
7068
7069 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_GROUPID,
7070 finderArgs, count);
7071
7072 closeSession(session);
7073 }
7074 }
7075
7076 return count.intValue();
7077 }
7078
7079
7086 public int filterCountByGroupId(long groupId) throws SystemException {
7087 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
7088 return countByGroupId(groupId);
7089 }
7090
7091 StringBundler query = new StringBundler(2);
7092
7093 query.append(_FILTER_SQL_COUNT_ASSETCATEGORY_WHERE);
7094
7095 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
7096
7097 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
7098 AssetCategory.class.getName(),
7099 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
7100
7101 Session session = null;
7102
7103 try {
7104 session = openSession();
7105
7106 SQLQuery q = session.createSQLQuery(sql);
7107
7108 q.addScalar(COUNT_COLUMN_NAME,
7109 com.liferay.portal.kernel.dao.orm.Type.LONG);
7110
7111 QueryPos qPos = QueryPos.getInstance(q);
7112
7113 qPos.add(groupId);
7114
7115 Long count = (Long)q.uniqueResult();
7116
7117 return count.intValue();
7118 }
7119 catch (Exception e) {
7120 throw processException(e);
7121 }
7122 finally {
7123 closeSession(session);
7124 }
7125 }
7126
7127
7134 public int countByParentCategoryId(long parentCategoryId)
7135 throws SystemException {
7136 Object[] finderArgs = new Object[] { parentCategoryId };
7137
7138 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_PARENTCATEGORYID,
7139 finderArgs, this);
7140
7141 if (count == null) {
7142 StringBundler query = new StringBundler(2);
7143
7144 query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
7145
7146 query.append(_FINDER_COLUMN_PARENTCATEGORYID_PARENTCATEGORYID_2);
7147
7148 String sql = query.toString();
7149
7150 Session session = null;
7151
7152 try {
7153 session = openSession();
7154
7155 Query q = session.createQuery(sql);
7156
7157 QueryPos qPos = QueryPos.getInstance(q);
7158
7159 qPos.add(parentCategoryId);
7160
7161 count = (Long)q.uniqueResult();
7162 }
7163 catch (Exception e) {
7164 throw processException(e);
7165 }
7166 finally {
7167 if (count == null) {
7168 count = Long.valueOf(0);
7169 }
7170
7171 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_PARENTCATEGORYID,
7172 finderArgs, count);
7173
7174 closeSession(session);
7175 }
7176 }
7177
7178 return count.intValue();
7179 }
7180
7181
7188 public int countByVocabularyId(long vocabularyId) throws SystemException {
7189 Object[] finderArgs = new Object[] { vocabularyId };
7190
7191 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_VOCABULARYID,
7192 finderArgs, this);
7193
7194 if (count == null) {
7195 StringBundler query = new StringBundler(2);
7196
7197 query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
7198
7199 query.append(_FINDER_COLUMN_VOCABULARYID_VOCABULARYID_2);
7200
7201 String sql = query.toString();
7202
7203 Session session = null;
7204
7205 try {
7206 session = openSession();
7207
7208 Query q = session.createQuery(sql);
7209
7210 QueryPos qPos = QueryPos.getInstance(q);
7211
7212 qPos.add(vocabularyId);
7213
7214 count = (Long)q.uniqueResult();
7215 }
7216 catch (Exception e) {
7217 throw processException(e);
7218 }
7219 finally {
7220 if (count == null) {
7221 count = Long.valueOf(0);
7222 }
7223
7224 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_VOCABULARYID,
7225 finderArgs, count);
7226
7227 closeSession(session);
7228 }
7229 }
7230
7231 return count.intValue();
7232 }
7233
7234
7242 public int countByG_V(long groupId, long vocabularyId)
7243 throws SystemException {
7244 Object[] finderArgs = new Object[] { groupId, vocabularyId };
7245
7246 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_V,
7247 finderArgs, this);
7248
7249 if (count == null) {
7250 StringBundler query = new StringBundler(3);
7251
7252 query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
7253
7254 query.append(_FINDER_COLUMN_G_V_GROUPID_2);
7255
7256 query.append(_FINDER_COLUMN_G_V_VOCABULARYID_2);
7257
7258 String sql = query.toString();
7259
7260 Session session = null;
7261
7262 try {
7263 session = openSession();
7264
7265 Query q = session.createQuery(sql);
7266
7267 QueryPos qPos = QueryPos.getInstance(q);
7268
7269 qPos.add(groupId);
7270
7271 qPos.add(vocabularyId);
7272
7273 count = (Long)q.uniqueResult();
7274 }
7275 catch (Exception e) {
7276 throw processException(e);
7277 }
7278 finally {
7279 if (count == null) {
7280 count = Long.valueOf(0);
7281 }
7282
7283 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_V, finderArgs,
7284 count);
7285
7286 closeSession(session);
7287 }
7288 }
7289
7290 return count.intValue();
7291 }
7292
7293
7301 public int filterCountByG_V(long groupId, long vocabularyId)
7302 throws SystemException {
7303 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
7304 return countByG_V(groupId, vocabularyId);
7305 }
7306
7307 StringBundler query = new StringBundler(3);
7308
7309 query.append(_FILTER_SQL_COUNT_ASSETCATEGORY_WHERE);
7310
7311 query.append(_FINDER_COLUMN_G_V_GROUPID_2);
7312
7313 query.append(_FINDER_COLUMN_G_V_VOCABULARYID_2);
7314
7315 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
7316 AssetCategory.class.getName(),
7317 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
7318
7319 Session session = null;
7320
7321 try {
7322 session = openSession();
7323
7324 SQLQuery q = session.createSQLQuery(sql);
7325
7326 q.addScalar(COUNT_COLUMN_NAME,
7327 com.liferay.portal.kernel.dao.orm.Type.LONG);
7328
7329 QueryPos qPos = QueryPos.getInstance(q);
7330
7331 qPos.add(groupId);
7332
7333 qPos.add(vocabularyId);
7334
7335 Long count = (Long)q.uniqueResult();
7336
7337 return count.intValue();
7338 }
7339 catch (Exception e) {
7340 throw processException(e);
7341 }
7342 finally {
7343 closeSession(session);
7344 }
7345 }
7346
7347
7355 public int countByP_N(long parentCategoryId, String name)
7356 throws SystemException {
7357 Object[] finderArgs = new Object[] { parentCategoryId, name };
7358
7359 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_P_N,
7360 finderArgs, this);
7361
7362 if (count == null) {
7363 StringBundler query = new StringBundler(3);
7364
7365 query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
7366
7367 query.append(_FINDER_COLUMN_P_N_PARENTCATEGORYID_2);
7368
7369 if (name == null) {
7370 query.append(_FINDER_COLUMN_P_N_NAME_1);
7371 }
7372 else {
7373 if (name.equals(StringPool.BLANK)) {
7374 query.append(_FINDER_COLUMN_P_N_NAME_3);
7375 }
7376 else {
7377 query.append(_FINDER_COLUMN_P_N_NAME_2);
7378 }
7379 }
7380
7381 String sql = query.toString();
7382
7383 Session session = null;
7384
7385 try {
7386 session = openSession();
7387
7388 Query q = session.createQuery(sql);
7389
7390 QueryPos qPos = QueryPos.getInstance(q);
7391
7392 qPos.add(parentCategoryId);
7393
7394 if (name != null) {
7395 qPos.add(name);
7396 }
7397
7398 count = (Long)q.uniqueResult();
7399 }
7400 catch (Exception e) {
7401 throw processException(e);
7402 }
7403 finally {
7404 if (count == null) {
7405 count = Long.valueOf(0);
7406 }
7407
7408 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_P_N, finderArgs,
7409 count);
7410
7411 closeSession(session);
7412 }
7413 }
7414
7415 return count.intValue();
7416 }
7417
7418
7426 public int countByP_V(long parentCategoryId, long vocabularyId)
7427 throws SystemException {
7428 Object[] finderArgs = new Object[] { parentCategoryId, vocabularyId };
7429
7430 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_P_V,
7431 finderArgs, this);
7432
7433 if (count == null) {
7434 StringBundler query = new StringBundler(3);
7435
7436 query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
7437
7438 query.append(_FINDER_COLUMN_P_V_PARENTCATEGORYID_2);
7439
7440 query.append(_FINDER_COLUMN_P_V_VOCABULARYID_2);
7441
7442 String sql = query.toString();
7443
7444 Session session = null;
7445
7446 try {
7447 session = openSession();
7448
7449 Query q = session.createQuery(sql);
7450
7451 QueryPos qPos = QueryPos.getInstance(q);
7452
7453 qPos.add(parentCategoryId);
7454
7455 qPos.add(vocabularyId);
7456
7457 count = (Long)q.uniqueResult();
7458 }
7459 catch (Exception e) {
7460 throw processException(e);
7461 }
7462 finally {
7463 if (count == null) {
7464 count = Long.valueOf(0);
7465 }
7466
7467 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_P_V, finderArgs,
7468 count);
7469
7470 closeSession(session);
7471 }
7472 }
7473
7474 return count.intValue();
7475 }
7476
7477
7485 public int countByN_V(String name, long vocabularyId)
7486 throws SystemException {
7487 Object[] finderArgs = new Object[] { name, vocabularyId };
7488
7489 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_N_V,
7490 finderArgs, this);
7491
7492 if (count == null) {
7493 StringBundler query = new StringBundler(3);
7494
7495 query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
7496
7497 if (name == null) {
7498 query.append(_FINDER_COLUMN_N_V_NAME_1);
7499 }
7500 else {
7501 if (name.equals(StringPool.BLANK)) {
7502 query.append(_FINDER_COLUMN_N_V_NAME_3);
7503 }
7504 else {
7505 query.append(_FINDER_COLUMN_N_V_NAME_2);
7506 }
7507 }
7508
7509 query.append(_FINDER_COLUMN_N_V_VOCABULARYID_2);
7510
7511 String sql = query.toString();
7512
7513 Session session = null;
7514
7515 try {
7516 session = openSession();
7517
7518 Query q = session.createQuery(sql);
7519
7520 QueryPos qPos = QueryPos.getInstance(q);
7521
7522 if (name != null) {
7523 qPos.add(name);
7524 }
7525
7526 qPos.add(vocabularyId);
7527
7528 count = (Long)q.uniqueResult();
7529 }
7530 catch (Exception e) {
7531 throw processException(e);
7532 }
7533 finally {
7534 if (count == null) {
7535 count = Long.valueOf(0);
7536 }
7537
7538 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_N_V, finderArgs,
7539 count);
7540
7541 closeSession(session);
7542 }
7543 }
7544
7545 return count.intValue();
7546 }
7547
7548
7557 public int countByG_P_N(long groupId, long parentCategoryId, String name)
7558 throws SystemException {
7559 Object[] finderArgs = new Object[] { groupId, parentCategoryId, name };
7560
7561 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_P_N,
7562 finderArgs, this);
7563
7564 if (count == null) {
7565 StringBundler query = new StringBundler(4);
7566
7567 query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
7568
7569 query.append(_FINDER_COLUMN_G_P_N_GROUPID_2);
7570
7571 query.append(_FINDER_COLUMN_G_P_N_PARENTCATEGORYID_2);
7572
7573 if (name == null) {
7574 query.append(_FINDER_COLUMN_G_P_N_NAME_1);
7575 }
7576 else {
7577 if (name.equals(StringPool.BLANK)) {
7578 query.append(_FINDER_COLUMN_G_P_N_NAME_3);
7579 }
7580 else {
7581 query.append(_FINDER_COLUMN_G_P_N_NAME_2);
7582 }
7583 }
7584
7585 String sql = query.toString();
7586
7587 Session session = null;
7588
7589 try {
7590 session = openSession();
7591
7592 Query q = session.createQuery(sql);
7593
7594 QueryPos qPos = QueryPos.getInstance(q);
7595
7596 qPos.add(groupId);
7597
7598 qPos.add(parentCategoryId);
7599
7600 if (name != null) {
7601 qPos.add(name);
7602 }
7603
7604 count = (Long)q.uniqueResult();
7605 }
7606 catch (Exception e) {
7607 throw processException(e);
7608 }
7609 finally {
7610 if (count == null) {
7611 count = Long.valueOf(0);
7612 }
7613
7614 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_P_N,
7615 finderArgs, count);
7616
7617 closeSession(session);
7618 }
7619 }
7620
7621 return count.intValue();
7622 }
7623
7624
7633 public int filterCountByG_P_N(long groupId, long parentCategoryId,
7634 String name) throws SystemException {
7635 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
7636 return countByG_P_N(groupId, parentCategoryId, name);
7637 }
7638
7639 StringBundler query = new StringBundler(4);
7640
7641 query.append(_FILTER_SQL_COUNT_ASSETCATEGORY_WHERE);
7642
7643 query.append(_FINDER_COLUMN_G_P_N_GROUPID_2);
7644
7645 query.append(_FINDER_COLUMN_G_P_N_PARENTCATEGORYID_2);
7646
7647 if (name == null) {
7648 query.append(_FINDER_COLUMN_G_P_N_NAME_1);
7649 }
7650 else {
7651 if (name.equals(StringPool.BLANK)) {
7652 query.append(_FINDER_COLUMN_G_P_N_NAME_3);
7653 }
7654 else {
7655 query.append(_FINDER_COLUMN_G_P_N_NAME_2);
7656 }
7657 }
7658
7659 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
7660 AssetCategory.class.getName(),
7661 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
7662
7663 Session session = null;
7664
7665 try {
7666 session = openSession();
7667
7668 SQLQuery q = session.createSQLQuery(sql);
7669
7670 q.addScalar(COUNT_COLUMN_NAME,
7671 com.liferay.portal.kernel.dao.orm.Type.LONG);
7672
7673 QueryPos qPos = QueryPos.getInstance(q);
7674
7675 qPos.add(groupId);
7676
7677 qPos.add(parentCategoryId);
7678
7679 if (name != null) {
7680 qPos.add(name);
7681 }
7682
7683 Long count = (Long)q.uniqueResult();
7684
7685 return count.intValue();
7686 }
7687 catch (Exception e) {
7688 throw processException(e);
7689 }
7690 finally {
7691 closeSession(session);
7692 }
7693 }
7694
7695
7704 public int countByP_N_V(long parentCategoryId, String name,
7705 long vocabularyId) throws SystemException {
7706 Object[] finderArgs = new Object[] { parentCategoryId, name, vocabularyId };
7707
7708 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_P_N_V,
7709 finderArgs, this);
7710
7711 if (count == null) {
7712 StringBundler query = new StringBundler(4);
7713
7714 query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
7715
7716 query.append(_FINDER_COLUMN_P_N_V_PARENTCATEGORYID_2);
7717
7718 if (name == null) {
7719 query.append(_FINDER_COLUMN_P_N_V_NAME_1);
7720 }
7721 else {
7722 if (name.equals(StringPool.BLANK)) {
7723 query.append(_FINDER_COLUMN_P_N_V_NAME_3);
7724 }
7725 else {
7726 query.append(_FINDER_COLUMN_P_N_V_NAME_2);
7727 }
7728 }
7729
7730 query.append(_FINDER_COLUMN_P_N_V_VOCABULARYID_2);
7731
7732 String sql = query.toString();
7733
7734 Session session = null;
7735
7736 try {
7737 session = openSession();
7738
7739 Query q = session.createQuery(sql);
7740
7741 QueryPos qPos = QueryPos.getInstance(q);
7742
7743 qPos.add(parentCategoryId);
7744
7745 if (name != null) {
7746 qPos.add(name);
7747 }
7748
7749 qPos.add(vocabularyId);
7750
7751 count = (Long)q.uniqueResult();
7752 }
7753 catch (Exception e) {
7754 throw processException(e);
7755 }
7756 finally {
7757 if (count == null) {
7758 count = Long.valueOf(0);
7759 }
7760
7761 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_P_N_V,
7762 finderArgs, count);
7763
7764 closeSession(session);
7765 }
7766 }
7767
7768 return count.intValue();
7769 }
7770
7771
7777 public int countAll() throws SystemException {
7778 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
7779 FINDER_ARGS_EMPTY, this);
7780
7781 if (count == null) {
7782 Session session = null;
7783
7784 try {
7785 session = openSession();
7786
7787 Query q = session.createQuery(_SQL_COUNT_ASSETCATEGORY);
7788
7789 count = (Long)q.uniqueResult();
7790 }
7791 catch (Exception e) {
7792 throw processException(e);
7793 }
7794 finally {
7795 if (count == null) {
7796 count = Long.valueOf(0);
7797 }
7798
7799 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
7800 FINDER_ARGS_EMPTY, count);
7801
7802 closeSession(session);
7803 }
7804 }
7805
7806 return count.intValue();
7807 }
7808
7809
7816 public List<com.liferay.portlet.asset.model.AssetEntry> getAssetEntries(
7817 long pk) throws SystemException {
7818 return getAssetEntries(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
7819 }
7820
7821
7834 public List<com.liferay.portlet.asset.model.AssetEntry> getAssetEntries(
7835 long pk, int start, int end) throws SystemException {
7836 return getAssetEntries(pk, start, end, null);
7837 }
7838
7839 public static final FinderPath FINDER_PATH_GET_ASSETENTRIES = new FinderPath(com.liferay.portlet.asset.model.impl.AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
7840 AssetCategoryModelImpl.FINDER_CACHE_ENABLED_ASSETENTRIES_ASSETCATEGORIES,
7841 com.liferay.portlet.asset.model.impl.AssetEntryImpl.class,
7842 AssetCategoryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME,
7843 "getAssetEntries",
7844 new String[] {
7845 Long.class.getName(), "java.lang.Integer", "java.lang.Integer",
7846 "com.liferay.portal.kernel.util.OrderByComparator"
7847 });
7848
7849 static {
7850 FINDER_PATH_GET_ASSETENTRIES.setCacheKeyGeneratorCacheName(null);
7851 }
7852
7853
7867 public List<com.liferay.portlet.asset.model.AssetEntry> getAssetEntries(
7868 long pk, int start, int end, OrderByComparator orderByComparator)
7869 throws SystemException {
7870 Object[] finderArgs = new Object[] { pk, start, end, orderByComparator };
7871
7872 List<com.liferay.portlet.asset.model.AssetEntry> list = (List<com.liferay.portlet.asset.model.AssetEntry>)FinderCacheUtil.getResult(FINDER_PATH_GET_ASSETENTRIES,
7873 finderArgs, this);
7874
7875 if (list == null) {
7876 Session session = null;
7877
7878 try {
7879 session = openSession();
7880
7881 String sql = null;
7882
7883 if (orderByComparator != null) {
7884 sql = _SQL_GETASSETENTRIES.concat(ORDER_BY_CLAUSE)
7885 .concat(orderByComparator.getOrderBy());
7886 }
7887 else {
7888 sql = _SQL_GETASSETENTRIES;
7889 }
7890
7891 SQLQuery q = session.createSQLQuery(sql);
7892
7893 q.addEntity("AssetEntry",
7894 com.liferay.portlet.asset.model.impl.AssetEntryImpl.class);
7895
7896 QueryPos qPos = QueryPos.getInstance(q);
7897
7898 qPos.add(pk);
7899
7900 list = (List<com.liferay.portlet.asset.model.AssetEntry>)QueryUtil.list(q,
7901 getDialect(), start, end);
7902 }
7903 catch (Exception e) {
7904 throw processException(e);
7905 }
7906 finally {
7907 if (list == null) {
7908 FinderCacheUtil.removeResult(FINDER_PATH_GET_ASSETENTRIES,
7909 finderArgs);
7910 }
7911 else {
7912 assetEntryPersistence.cacheResult(list);
7913
7914 FinderCacheUtil.putResult(FINDER_PATH_GET_ASSETENTRIES,
7915 finderArgs, list);
7916 }
7917
7918 closeSession(session);
7919 }
7920 }
7921
7922 return list;
7923 }
7924
7925 public static final FinderPath FINDER_PATH_GET_ASSETENTRIES_SIZE = new FinderPath(com.liferay.portlet.asset.model.impl.AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
7926 AssetCategoryModelImpl.FINDER_CACHE_ENABLED_ASSETENTRIES_ASSETCATEGORIES,
7927 Long.class,
7928 AssetCategoryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME,
7929 "getAssetEntriesSize", new String[] { Long.class.getName() });
7930
7931 static {
7932 FINDER_PATH_GET_ASSETENTRIES_SIZE.setCacheKeyGeneratorCacheName(null);
7933 }
7934
7935
7942 public int getAssetEntriesSize(long pk) throws SystemException {
7943 Object[] finderArgs = new Object[] { pk };
7944
7945 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_GET_ASSETENTRIES_SIZE,
7946 finderArgs, this);
7947
7948 if (count == null) {
7949 Session session = null;
7950
7951 try {
7952 session = openSession();
7953
7954 SQLQuery q = session.createSQLQuery(_SQL_GETASSETENTRIESSIZE);
7955
7956 q.addScalar(COUNT_COLUMN_NAME,
7957 com.liferay.portal.kernel.dao.orm.Type.LONG);
7958
7959 QueryPos qPos = QueryPos.getInstance(q);
7960
7961 qPos.add(pk);
7962
7963 count = (Long)q.uniqueResult();
7964 }
7965 catch (Exception e) {
7966 throw processException(e);
7967 }
7968 finally {
7969 if (count == null) {
7970 count = Long.valueOf(0);
7971 }
7972
7973 FinderCacheUtil.putResult(FINDER_PATH_GET_ASSETENTRIES_SIZE,
7974 finderArgs, count);
7975
7976 closeSession(session);
7977 }
7978 }
7979
7980 return count.intValue();
7981 }
7982
7983 public static final FinderPath FINDER_PATH_CONTAINS_ASSETENTRY = new FinderPath(com.liferay.portlet.asset.model.impl.AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
7984 AssetCategoryModelImpl.FINDER_CACHE_ENABLED_ASSETENTRIES_ASSETCATEGORIES,
7985 Boolean.class,
7986 AssetCategoryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME,
7987 "containsAssetEntry",
7988 new String[] { Long.class.getName(), Long.class.getName() });
7989
7990
7998 public boolean containsAssetEntry(long pk, long assetEntryPK)
7999 throws SystemException {
8000 Object[] finderArgs = new Object[] { pk, assetEntryPK };
8001
8002 Boolean value = (Boolean)FinderCacheUtil.getResult(FINDER_PATH_CONTAINS_ASSETENTRY,
8003 finderArgs, this);
8004
8005 if (value == null) {
8006 try {
8007 value = Boolean.valueOf(containsAssetEntry.contains(pk,
8008 assetEntryPK));
8009 }
8010 catch (Exception e) {
8011 throw processException(e);
8012 }
8013 finally {
8014 if (value == null) {
8015 value = Boolean.FALSE;
8016 }
8017
8018 FinderCacheUtil.putResult(FINDER_PATH_CONTAINS_ASSETENTRY,
8019 finderArgs, value);
8020 }
8021 }
8022
8023 return value.booleanValue();
8024 }
8025
8026
8033 public boolean containsAssetEntries(long pk) throws SystemException {
8034 if (getAssetEntriesSize(pk) > 0) {
8035 return true;
8036 }
8037 else {
8038 return false;
8039 }
8040 }
8041
8042
8049 public void addAssetEntry(long pk, long assetEntryPK)
8050 throws SystemException {
8051 try {
8052 addAssetEntry.add(pk, assetEntryPK);
8053 }
8054 catch (Exception e) {
8055 throw processException(e);
8056 }
8057 finally {
8058 FinderCacheUtil.clearCache(AssetCategoryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
8059 }
8060 }
8061
8062
8069 public void addAssetEntry(long pk,
8070 com.liferay.portlet.asset.model.AssetEntry assetEntry)
8071 throws SystemException {
8072 try {
8073 addAssetEntry.add(pk, assetEntry.getPrimaryKey());
8074 }
8075 catch (Exception e) {
8076 throw processException(e);
8077 }
8078 finally {
8079 FinderCacheUtil.clearCache(AssetCategoryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
8080 }
8081 }
8082
8083
8090 public void addAssetEntries(long pk, long[] assetEntryPKs)
8091 throws SystemException {
8092 try {
8093 for (long assetEntryPK : assetEntryPKs) {
8094 addAssetEntry.add(pk, assetEntryPK);
8095 }
8096 }
8097 catch (Exception e) {
8098 throw processException(e);
8099 }
8100 finally {
8101 FinderCacheUtil.clearCache(AssetCategoryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
8102 }
8103 }
8104
8105
8112 public void addAssetEntries(long pk,
8113 List<com.liferay.portlet.asset.model.AssetEntry> assetEntries)
8114 throws SystemException {
8115 try {
8116 for (com.liferay.portlet.asset.model.AssetEntry assetEntry : assetEntries) {
8117 addAssetEntry.add(pk, assetEntry.getPrimaryKey());
8118 }
8119 }
8120 catch (Exception e) {
8121 throw processException(e);
8122 }
8123 finally {
8124 FinderCacheUtil.clearCache(AssetCategoryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
8125 }
8126 }
8127
8128
8134 public void clearAssetEntries(long pk) throws SystemException {
8135 try {
8136 clearAssetEntries.clear(pk);
8137 }
8138 catch (Exception e) {
8139 throw processException(e);
8140 }
8141 finally {
8142 FinderCacheUtil.clearCache(AssetCategoryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
8143 }
8144 }
8145
8146
8153 public void removeAssetEntry(long pk, long assetEntryPK)
8154 throws SystemException {
8155 try {
8156 removeAssetEntry.remove(pk, assetEntryPK);
8157 }
8158 catch (Exception e) {
8159 throw processException(e);
8160 }
8161 finally {
8162 FinderCacheUtil.clearCache(AssetCategoryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
8163 }
8164 }
8165
8166
8173 public void removeAssetEntry(long pk,
8174 com.liferay.portlet.asset.model.AssetEntry assetEntry)
8175 throws SystemException {
8176 try {
8177 removeAssetEntry.remove(pk, assetEntry.getPrimaryKey());
8178 }
8179 catch (Exception e) {
8180 throw processException(e);
8181 }
8182 finally {
8183 FinderCacheUtil.clearCache(AssetCategoryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
8184 }
8185 }
8186
8187
8194 public void removeAssetEntries(long pk, long[] assetEntryPKs)
8195 throws SystemException {
8196 try {
8197 for (long assetEntryPK : assetEntryPKs) {
8198 removeAssetEntry.remove(pk, assetEntryPK);
8199 }
8200 }
8201 catch (Exception e) {
8202 throw processException(e);
8203 }
8204 finally {
8205 FinderCacheUtil.clearCache(AssetCategoryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
8206 }
8207 }
8208
8209
8216 public void removeAssetEntries(long pk,
8217 List<com.liferay.portlet.asset.model.AssetEntry> assetEntries)
8218 throws SystemException {
8219 try {
8220 for (com.liferay.portlet.asset.model.AssetEntry assetEntry : assetEntries) {
8221 removeAssetEntry.remove(pk, assetEntry.getPrimaryKey());
8222 }
8223 }
8224 catch (Exception e) {
8225 throw processException(e);
8226 }
8227 finally {
8228 FinderCacheUtil.clearCache(AssetCategoryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
8229 }
8230 }
8231
8232
8239 public void setAssetEntries(long pk, long[] assetEntryPKs)
8240 throws SystemException {
8241 try {
8242 Set<Long> assetEntryPKSet = SetUtil.fromArray(assetEntryPKs);
8243
8244 List<com.liferay.portlet.asset.model.AssetEntry> assetEntries = getAssetEntries(pk);
8245
8246 for (com.liferay.portlet.asset.model.AssetEntry assetEntry : assetEntries) {
8247 if (!assetEntryPKSet.remove(assetEntry.getPrimaryKey())) {
8248 removeAssetEntry.remove(pk, assetEntry.getPrimaryKey());
8249 }
8250 }
8251
8252 for (Long assetEntryPK : assetEntryPKSet) {
8253 addAssetEntry.add(pk, assetEntryPK);
8254 }
8255 }
8256 catch (Exception e) {
8257 throw processException(e);
8258 }
8259 finally {
8260 FinderCacheUtil.clearCache(AssetCategoryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
8261 }
8262 }
8263
8264
8271 public void setAssetEntries(long pk,
8272 List<com.liferay.portlet.asset.model.AssetEntry> assetEntries)
8273 throws SystemException {
8274 try {
8275 long[] assetEntryPKs = new long[assetEntries.size()];
8276
8277 for (int i = 0; i < assetEntries.size(); i++) {
8278 com.liferay.portlet.asset.model.AssetEntry assetEntry = assetEntries.get(i);
8279
8280 assetEntryPKs[i] = assetEntry.getPrimaryKey();
8281 }
8282
8283 setAssetEntries(pk, assetEntryPKs);
8284 }
8285 catch (Exception e) {
8286 throw processException(e);
8287 }
8288 finally {
8289 FinderCacheUtil.clearCache(AssetCategoryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
8290 }
8291 }
8292
8293
8303 public void rebuildTree(long groupId, boolean force)
8304 throws SystemException {
8305 if (!rebuildTreeEnabled) {
8306 return;
8307 }
8308
8309 if (force || (countOrphanTreeNodes(groupId) > 0)) {
8310 rebuildTree(groupId, 0, 1);
8311
8312 CacheRegistryUtil.clear(AssetCategoryImpl.class.getName());
8313 EntityCacheUtil.clearCache(AssetCategoryImpl.class.getName());
8314 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
8315 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
8316 }
8317 }
8318
8319 public void setRebuildTreeEnabled(boolean rebuildTreeEnabled) {
8320 this.rebuildTreeEnabled = rebuildTreeEnabled;
8321 }
8322
8323 protected long countOrphanTreeNodes(long groupId) throws SystemException {
8324 Session session = null;
8325
8326 try {
8327 session = openSession();
8328
8329 SQLQuery q = session.createSQLQuery(
8330 "SELECT COUNT(*) AS COUNT_VALUE FROM AssetCategory WHERE groupId = ? AND (leftCategoryId = 0 OR leftCategoryId IS NULL OR rightCategoryId = 0 OR rightCategoryId IS NULL)");
8331
8332 q.addScalar(COUNT_COLUMN_NAME,
8333 com.liferay.portal.kernel.dao.orm.Type.LONG);
8334
8335 QueryPos qPos = QueryPos.getInstance(q);
8336
8337 qPos.add(groupId);
8338
8339 return (Long)q.uniqueResult();
8340 }
8341 catch (Exception e) {
8342 throw processException(e);
8343 }
8344 finally {
8345 closeSession(session);
8346 }
8347 }
8348
8349 protected void expandNoChildrenLeftCategoryId(long groupId,
8350 long leftCategoryId, List<Long> childrenCategoryIds, long delta) {
8351 String sql = "UPDATE AssetCategory SET leftcategoryId = (leftcategoryId + ?) WHERE (groupId = ?) AND (leftcategoryId > ?) AND (categoryId NOT IN (" +
8352 StringUtil.merge(childrenCategoryIds) + "))";
8353
8354 SqlUpdate _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
8355 sql,
8356 new int[] {
8357 java.sql.Types.BIGINT, java.sql.Types.BIGINT,
8358 java.sql.Types.BIGINT
8359 });
8360
8361 _sqlUpdate.update(new Object[] { delta, groupId, leftCategoryId });
8362 }
8363
8364 protected void expandNoChildrenRightCategoryId(long groupId,
8365 long rightCategoryId, List<Long> childrenCategoryIds, long delta) {
8366 String sql = "UPDATE AssetCategory SET rightcategoryId = (rightcategoryId + ?) WHERE (groupId = ?) AND (rightcategoryId > ?) AND (categoryId NOT IN (" +
8367 StringUtil.merge(childrenCategoryIds) + "))";
8368
8369 SqlUpdate _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
8370 sql,
8371 new int[] {
8372 java.sql.Types.BIGINT, java.sql.Types.BIGINT,
8373 java.sql.Types.BIGINT
8374 });
8375
8376 _sqlUpdate.update(new Object[] { delta, groupId, rightCategoryId });
8377 }
8378
8379 protected void expandTree(AssetCategory assetCategory,
8380 List<Long> childrenCategoryIds) throws SystemException {
8381 if (!rebuildTreeEnabled) {
8382 return;
8383 }
8384
8385 long groupId = assetCategory.getGroupId();
8386
8387 long lastRightCategoryId = getLastRightCategoryId(groupId,
8388 assetCategory.getParentCategoryId());
8389
8390 long leftCategoryId = 2;
8391 long rightCategoryId = 3;
8392
8393 if (lastRightCategoryId > 0) {
8394 leftCategoryId = lastRightCategoryId + 1;
8395
8396 long childrenDistance = assetCategory.getRightCategoryId() -
8397 assetCategory.getLeftCategoryId();
8398
8399 if (childrenDistance > 1) {
8400 rightCategoryId = leftCategoryId + childrenDistance;
8401
8402 updateChildrenTree(groupId, childrenCategoryIds,
8403 leftCategoryId - assetCategory.getLeftCategoryId());
8404
8405 expandNoChildrenLeftCategoryId(groupId, lastRightCategoryId,
8406 childrenCategoryIds, childrenDistance + 1);
8407 expandNoChildrenRightCategoryId(groupId, lastRightCategoryId,
8408 childrenCategoryIds, childrenDistance + 1);
8409 }
8410 else {
8411 rightCategoryId = lastRightCategoryId + 2;
8412
8413 expandTreeLeftCategoryId.expand(groupId, lastRightCategoryId);
8414 expandTreeRightCategoryId.expand(groupId, lastRightCategoryId);
8415 }
8416
8417 CacheRegistryUtil.clear(AssetCategoryImpl.class.getName());
8418 EntityCacheUtil.clearCache(AssetCategoryImpl.class.getName());
8419 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
8420 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
8421 }
8422
8423 assetCategory.setLeftCategoryId(leftCategoryId);
8424 assetCategory.setRightCategoryId(rightCategoryId);
8425 }
8426
8427 protected List<Long> getChildrenTreeCategoryIds(
8428 AssetCategory parentAssetCategory) throws SystemException {
8429 Session session = null;
8430
8431 try {
8432 session = openSession();
8433
8434 SQLQuery q = session.createSQLQuery(
8435 "SELECT categoryId FROM AssetCategory WHERE (groupId = ?) AND (leftcategoryId BETWEEN ? AND ?)");
8436
8437 q.addScalar("CategoryId",
8438 com.liferay.portal.kernel.dao.orm.Type.LONG);
8439
8440 QueryPos qPos = QueryPos.getInstance(q);
8441
8442 qPos.add(parentAssetCategory.getGroupId());
8443 qPos.add(parentAssetCategory.getLeftCategoryId() + 1);
8444 qPos.add(parentAssetCategory.getRightCategoryId());
8445
8446 return q.list();
8447 }
8448 catch (Exception e) {
8449 throw processException(e);
8450 }
8451 finally {
8452 closeSession(session);
8453 }
8454 }
8455
8456 protected long getLastRightCategoryId(long groupId, long parentCategoryId)
8457 throws SystemException {
8458 Session session = null;
8459
8460 try {
8461 session = openSession();
8462
8463 SQLQuery q = session.createSQLQuery(
8464 "SELECT rightCategoryId FROM AssetCategory WHERE (groupId = ?) AND (parentCategoryId = ?) ORDER BY rightCategoryId DESC");
8465
8466 q.addScalar("rightCategoryId",
8467 com.liferay.portal.kernel.dao.orm.Type.LONG);
8468
8469 QueryPos qPos = QueryPos.getInstance(q);
8470
8471 qPos.add(groupId);
8472 qPos.add(parentCategoryId);
8473
8474 List<Long> list = (List<Long>)QueryUtil.list(q, getDialect(), 0, 1);
8475
8476 if (list.isEmpty()) {
8477 if (parentCategoryId > 0) {
8478 session.clear();
8479
8480 AssetCategory parentAssetCategory = findByPrimaryKey(parentCategoryId);
8481
8482 return parentAssetCategory.getLeftCategoryId();
8483 }
8484
8485 return 0;
8486 }
8487 else {
8488 return list.get(0);
8489 }
8490 }
8491 catch (Exception e) {
8492 throw processException(e);
8493 }
8494 finally {
8495 closeSession(session);
8496 }
8497 }
8498
8499 protected long rebuildTree(long groupId, long parentCategoryId,
8500 long leftCategoryId) throws SystemException {
8501 if (!rebuildTreeEnabled) {
8502 return 0;
8503 }
8504
8505 List<Long> categoryIds = null;
8506
8507 Session session = null;
8508
8509 try {
8510 session = openSession();
8511
8512 SQLQuery q = session.createSQLQuery(
8513 "SELECT categoryId FROM AssetCategory WHERE groupId = ? AND parentCategoryId = ? ORDER BY categoryId ASC");
8514
8515 q.addScalar("categoryId",
8516 com.liferay.portal.kernel.dao.orm.Type.LONG);
8517
8518 QueryPos qPos = QueryPos.getInstance(q);
8519
8520 qPos.add(groupId);
8521 qPos.add(parentCategoryId);
8522
8523 categoryIds = q.list();
8524 }
8525 catch (Exception e) {
8526 throw processException(e);
8527 }
8528 finally {
8529 closeSession(session);
8530 }
8531
8532 long rightCategoryId = leftCategoryId + 1;
8533
8534 for (long categoryId : categoryIds) {
8535 rightCategoryId = rebuildTree(groupId, categoryId, rightCategoryId);
8536 }
8537
8538 if (parentCategoryId > 0) {
8539 updateTree.update(parentCategoryId, leftCategoryId, rightCategoryId);
8540 }
8541
8542 return rightCategoryId + 1;
8543 }
8544
8545 protected void shrinkTree(AssetCategory assetCategory) {
8546 if (!rebuildTreeEnabled) {
8547 return;
8548 }
8549
8550 long groupId = assetCategory.getGroupId();
8551
8552 long leftCategoryId = assetCategory.getLeftCategoryId();
8553 long rightCategoryId = assetCategory.getRightCategoryId();
8554
8555 long delta = (rightCategoryId - leftCategoryId) + 1;
8556
8557 shrinkTreeLeftCategoryId.shrink(groupId, rightCategoryId, delta);
8558 shrinkTreeRightCategoryId.shrink(groupId, rightCategoryId, delta);
8559
8560 CacheRegistryUtil.clear(AssetCategoryImpl.class.getName());
8561 EntityCacheUtil.clearCache(AssetCategoryImpl.class.getName());
8562 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
8563 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
8564 }
8565
8566 protected void updateChildrenTree(long groupId,
8567 List<Long> childrenCategoryIds, long delta) {
8568 String sql = "UPDATE AssetCategory SET leftcategoryId = (leftcategoryId + ?), rightcategoryId = (rightcategoryId + ?) WHERE (groupId = ?) AND (categoryId IN (" +
8569 StringUtil.merge(childrenCategoryIds) + "))";
8570
8571 SqlUpdate _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
8572 sql,
8573 new int[] {
8574 java.sql.Types.BIGINT, java.sql.Types.BIGINT,
8575 java.sql.Types.BIGINT
8576 });
8577
8578 _sqlUpdate.update(new Object[] { delta, delta, groupId });
8579 }
8580
8581
8584 public void afterPropertiesSet() {
8585 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
8586 com.liferay.portal.util.PropsUtil.get(
8587 "value.object.listener.com.liferay.portlet.asset.model.AssetCategory")));
8588
8589 if (listenerClassNames.length > 0) {
8590 try {
8591 List<ModelListener<AssetCategory>> listenersList = new ArrayList<ModelListener<AssetCategory>>();
8592
8593 for (String listenerClassName : listenerClassNames) {
8594 listenersList.add((ModelListener<AssetCategory>)InstanceFactory.newInstance(
8595 listenerClassName));
8596 }
8597
8598 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
8599 }
8600 catch (Exception e) {
8601 _log.error(e);
8602 }
8603 }
8604
8605 containsAssetEntry = new ContainsAssetEntry();
8606
8607 addAssetEntry = new AddAssetEntry();
8608 clearAssetEntries = new ClearAssetEntries();
8609 removeAssetEntry = new RemoveAssetEntry();
8610
8611 expandTreeLeftCategoryId = new ExpandTreeLeftCategoryId();
8612 expandTreeRightCategoryId = new ExpandTreeRightCategoryId();
8613 shrinkTreeLeftCategoryId = new ShrinkTreeLeftCategoryId();
8614 shrinkTreeRightCategoryId = new ShrinkTreeRightCategoryId();
8615 updateTree = new UpdateTree();
8616 }
8617
8618 public void destroy() {
8619 EntityCacheUtil.removeCache(AssetCategoryImpl.class.getName());
8620 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
8621 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
8622 }
8623
8624 @BeanReference(type = AssetCategoryPersistence.class)
8625 protected AssetCategoryPersistence assetCategoryPersistence;
8626 @BeanReference(type = AssetCategoryPropertyPersistence.class)
8627 protected AssetCategoryPropertyPersistence assetCategoryPropertyPersistence;
8628 @BeanReference(type = AssetEntryPersistence.class)
8629 protected AssetEntryPersistence assetEntryPersistence;
8630 @BeanReference(type = AssetLinkPersistence.class)
8631 protected AssetLinkPersistence assetLinkPersistence;
8632 @BeanReference(type = AssetTagPersistence.class)
8633 protected AssetTagPersistence assetTagPersistence;
8634 @BeanReference(type = AssetTagPropertyPersistence.class)
8635 protected AssetTagPropertyPersistence assetTagPropertyPersistence;
8636 @BeanReference(type = AssetTagStatsPersistence.class)
8637 protected AssetTagStatsPersistence assetTagStatsPersistence;
8638 @BeanReference(type = AssetVocabularyPersistence.class)
8639 protected AssetVocabularyPersistence assetVocabularyPersistence;
8640 @BeanReference(type = UserPersistence.class)
8641 protected UserPersistence userPersistence;
8642 protected ContainsAssetEntry containsAssetEntry;
8643 protected AddAssetEntry addAssetEntry;
8644 protected ClearAssetEntries clearAssetEntries;
8645 protected RemoveAssetEntry removeAssetEntry;
8646
8647 protected class ContainsAssetEntry {
8648 protected ContainsAssetEntry() {
8649 _mappingSqlQuery = MappingSqlQueryFactoryUtil.getMappingSqlQuery(getDataSource(),
8650 _SQL_CONTAINSASSETENTRY,
8651 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT },
8652 RowMapper.COUNT);
8653 }
8654
8655 protected boolean contains(long categoryId, long entryId) {
8656 List<Integer> results = _mappingSqlQuery.execute(new Object[] {
8657 new Long(categoryId), new Long(entryId)
8658 });
8659
8660 if (results.size() > 0) {
8661 Integer count = results.get(0);
8662
8663 if (count.intValue() > 0) {
8664 return true;
8665 }
8666 }
8667
8668 return false;
8669 }
8670
8671 private MappingSqlQuery<Integer> _mappingSqlQuery;
8672 }
8673
8674 protected class AddAssetEntry {
8675 protected AddAssetEntry() {
8676 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
8677 "INSERT INTO AssetEntries_AssetCategories (categoryId, entryId) VALUES (?, ?)",
8678 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
8679 }
8680
8681 protected void add(long categoryId, long entryId)
8682 throws SystemException {
8683 if (!containsAssetEntry.contains(categoryId, entryId)) {
8684 ModelListener<com.liferay.portlet.asset.model.AssetEntry>[] assetEntryListeners =
8685 assetEntryPersistence.getListeners();
8686
8687 for (ModelListener<AssetCategory> listener : listeners) {
8688 listener.onBeforeAddAssociation(categoryId,
8689 com.liferay.portlet.asset.model.AssetEntry.class.getName(),
8690 entryId);
8691 }
8692
8693 for (ModelListener<com.liferay.portlet.asset.model.AssetEntry> listener : assetEntryListeners) {
8694 listener.onBeforeAddAssociation(entryId,
8695 AssetCategory.class.getName(), categoryId);
8696 }
8697
8698 _sqlUpdate.update(new Object[] {
8699 new Long(categoryId), new Long(entryId)
8700 });
8701
8702 for (ModelListener<AssetCategory> listener : listeners) {
8703 listener.onAfterAddAssociation(categoryId,
8704 com.liferay.portlet.asset.model.AssetEntry.class.getName(),
8705 entryId);
8706 }
8707
8708 for (ModelListener<com.liferay.portlet.asset.model.AssetEntry> listener : assetEntryListeners) {
8709 listener.onAfterAddAssociation(entryId,
8710 AssetCategory.class.getName(), categoryId);
8711 }
8712 }
8713 }
8714
8715 private SqlUpdate _sqlUpdate;
8716 }
8717
8718 protected class ClearAssetEntries {
8719 protected ClearAssetEntries() {
8720 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
8721 "DELETE FROM AssetEntries_AssetCategories WHERE categoryId = ?",
8722 new int[] { java.sql.Types.BIGINT });
8723 }
8724
8725 protected void clear(long categoryId) throws SystemException {
8726 ModelListener<com.liferay.portlet.asset.model.AssetEntry>[] assetEntryListeners =
8727 assetEntryPersistence.getListeners();
8728
8729 List<com.liferay.portlet.asset.model.AssetEntry> assetEntries = null;
8730
8731 if ((listeners.length > 0) || (assetEntryListeners.length > 0)) {
8732 assetEntries = getAssetEntries(categoryId);
8733
8734 for (com.liferay.portlet.asset.model.AssetEntry assetEntry : assetEntries) {
8735 for (ModelListener<AssetCategory> listener : listeners) {
8736 listener.onBeforeRemoveAssociation(categoryId,
8737 com.liferay.portlet.asset.model.AssetEntry.class.getName(),
8738 assetEntry.getPrimaryKey());
8739 }
8740
8741 for (ModelListener<com.liferay.portlet.asset.model.AssetEntry> listener : assetEntryListeners) {
8742 listener.onBeforeRemoveAssociation(assetEntry.getPrimaryKey(),
8743 AssetCategory.class.getName(), categoryId);
8744 }
8745 }
8746 }
8747
8748 _sqlUpdate.update(new Object[] { new Long(categoryId) });
8749
8750 if ((listeners.length > 0) || (assetEntryListeners.length > 0)) {
8751 for (com.liferay.portlet.asset.model.AssetEntry assetEntry : assetEntries) {
8752 for (ModelListener<AssetCategory> listener : listeners) {
8753 listener.onAfterRemoveAssociation(categoryId,
8754 com.liferay.portlet.asset.model.AssetEntry.class.getName(),
8755 assetEntry.getPrimaryKey());
8756 }
8757
8758 for (ModelListener<com.liferay.portlet.asset.model.AssetEntry> listener : assetEntryListeners) {
8759 listener.onAfterRemoveAssociation(assetEntry.getPrimaryKey(),
8760 AssetCategory.class.getName(), categoryId);
8761 }
8762 }
8763 }
8764 }
8765
8766 private SqlUpdate _sqlUpdate;
8767 }
8768
8769 protected class RemoveAssetEntry {
8770 protected RemoveAssetEntry() {
8771 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
8772 "DELETE FROM AssetEntries_AssetCategories WHERE categoryId = ? AND entryId = ?",
8773 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
8774 }
8775
8776 protected void remove(long categoryId, long entryId)
8777 throws SystemException {
8778 if (containsAssetEntry.contains(categoryId, entryId)) {
8779 ModelListener<com.liferay.portlet.asset.model.AssetEntry>[] assetEntryListeners =
8780 assetEntryPersistence.getListeners();
8781
8782 for (ModelListener<AssetCategory> listener : listeners) {
8783 listener.onBeforeRemoveAssociation(categoryId,
8784 com.liferay.portlet.asset.model.AssetEntry.class.getName(),
8785 entryId);
8786 }
8787
8788 for (ModelListener<com.liferay.portlet.asset.model.AssetEntry> listener : assetEntryListeners) {
8789 listener.onBeforeRemoveAssociation(entryId,
8790 AssetCategory.class.getName(), categoryId);
8791 }
8792
8793 _sqlUpdate.update(new Object[] {
8794 new Long(categoryId), new Long(entryId)
8795 });
8796
8797 for (ModelListener<AssetCategory> listener : listeners) {
8798 listener.onAfterRemoveAssociation(categoryId,
8799 com.liferay.portlet.asset.model.AssetEntry.class.getName(),
8800 entryId);
8801 }
8802
8803 for (ModelListener<com.liferay.portlet.asset.model.AssetEntry> listener : assetEntryListeners) {
8804 listener.onAfterRemoveAssociation(entryId,
8805 AssetCategory.class.getName(), categoryId);
8806 }
8807 }
8808 }
8809
8810 private SqlUpdate _sqlUpdate;
8811 }
8812
8813 protected boolean rebuildTreeEnabled = true;
8814 protected ExpandTreeLeftCategoryId expandTreeLeftCategoryId;
8815 protected ExpandTreeRightCategoryId expandTreeRightCategoryId;
8816 protected ShrinkTreeLeftCategoryId shrinkTreeLeftCategoryId;
8817 protected ShrinkTreeRightCategoryId shrinkTreeRightCategoryId;
8818 protected UpdateTree updateTree;
8819
8820 protected class ExpandTreeLeftCategoryId {
8821 protected ExpandTreeLeftCategoryId() {
8822 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
8823 "UPDATE AssetCategory SET leftCategoryId = (leftCategoryId + 2) WHERE (groupId = ?) AND (leftCategoryId > ?)",
8824 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
8825 }
8826
8827 protected void expand(long groupId, long leftCategoryId) {
8828 _sqlUpdate.update(new Object[] { groupId, leftCategoryId });
8829 }
8830
8831 private SqlUpdate _sqlUpdate;
8832 }
8833
8834 protected class ExpandTreeRightCategoryId {
8835 protected ExpandTreeRightCategoryId() {
8836 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
8837 "UPDATE AssetCategory SET rightCategoryId = (rightCategoryId + 2) WHERE (groupId = ?) AND (rightCategoryId > ?)",
8838 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
8839 }
8840
8841 protected void expand(long groupId, long rightCategoryId) {
8842 _sqlUpdate.update(new Object[] { groupId, rightCategoryId });
8843 }
8844
8845 private SqlUpdate _sqlUpdate;
8846 }
8847
8848 protected class ShrinkTreeLeftCategoryId {
8849 protected ShrinkTreeLeftCategoryId() {
8850 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
8851 "UPDATE AssetCategory SET leftCategoryId = (leftCategoryId - ?) WHERE (groupId = ?) AND (leftCategoryId > ?)",
8852 new int[] {
8853 java.sql.Types.BIGINT, java.sql.Types.BIGINT,
8854 java.sql.Types.BIGINT
8855 });
8856 }
8857
8858 protected void shrink(long groupId, long leftCategoryId, long delta) {
8859 _sqlUpdate.update(new Object[] { delta, groupId, leftCategoryId });
8860 }
8861
8862 private SqlUpdate _sqlUpdate;
8863 }
8864
8865 protected class ShrinkTreeRightCategoryId {
8866 protected ShrinkTreeRightCategoryId() {
8867 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
8868 "UPDATE AssetCategory SET rightCategoryId = (rightCategoryId - ?) WHERE (groupId = ?) AND (rightCategoryId > ?)",
8869 new int[] {
8870 java.sql.Types.BIGINT, java.sql.Types.BIGINT,
8871 java.sql.Types.BIGINT
8872 });
8873 }
8874
8875 protected void shrink(long groupId, long rightCategoryId, long delta) {
8876 _sqlUpdate.update(new Object[] { delta, groupId, rightCategoryId });
8877 }
8878
8879 private SqlUpdate _sqlUpdate;
8880 }
8881
8882 protected class UpdateTree {
8883 protected UpdateTree() {
8884 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
8885 "UPDATE AssetCategory SET leftCategoryId = ?, rightCategoryId = ? WHERE categoryId = ?",
8886 new int[] {
8887 java.sql.Types.BIGINT, java.sql.Types.BIGINT,
8888 java.sql.Types.BIGINT
8889 });
8890 }
8891
8892 protected void update(long categoryId, long leftCategoryId,
8893 long rightCategoryId) {
8894 _sqlUpdate.update(new Object[] {
8895 leftCategoryId, rightCategoryId, categoryId
8896 });
8897 }
8898
8899 private SqlUpdate _sqlUpdate;
8900 }
8901
8902 private static final String _SQL_SELECT_ASSETCATEGORY = "SELECT assetCategory FROM AssetCategory assetCategory";
8903 private static final String _SQL_SELECT_ASSETCATEGORY_WHERE = "SELECT assetCategory FROM AssetCategory assetCategory WHERE ";
8904 private static final String _SQL_COUNT_ASSETCATEGORY = "SELECT COUNT(assetCategory) FROM AssetCategory assetCategory";
8905 private static final String _SQL_COUNT_ASSETCATEGORY_WHERE = "SELECT COUNT(assetCategory) FROM AssetCategory assetCategory WHERE ";
8906 private static final String _SQL_GETASSETENTRIES = "SELECT {AssetEntry.*} FROM AssetEntry INNER JOIN AssetEntries_AssetCategories ON (AssetEntries_AssetCategories.entryId = AssetEntry.entryId) WHERE (AssetEntries_AssetCategories.categoryId = ?)";
8907 private static final String _SQL_GETASSETENTRIESSIZE = "SELECT COUNT(*) AS COUNT_VALUE FROM AssetEntries_AssetCategories WHERE categoryId = ?";
8908 private static final String _SQL_CONTAINSASSETENTRY = "SELECT COUNT(*) AS COUNT_VALUE FROM AssetEntries_AssetCategories WHERE categoryId = ? AND entryId = ?";
8909 private static final String _FINDER_COLUMN_UUID_UUID_1 = "assetCategory.uuid IS NULL";
8910 private static final String _FINDER_COLUMN_UUID_UUID_2 = "assetCategory.uuid = ?";
8911 private static final String _FINDER_COLUMN_UUID_UUID_3 = "(assetCategory.uuid IS NULL OR assetCategory.uuid = ?)";
8912 private static final String _FINDER_COLUMN_UUID_G_UUID_1 = "assetCategory.uuid IS NULL AND ";
8913 private static final String _FINDER_COLUMN_UUID_G_UUID_2 = "assetCategory.uuid = ? AND ";
8914 private static final String _FINDER_COLUMN_UUID_G_UUID_3 = "(assetCategory.uuid IS NULL OR assetCategory.uuid = ?) AND ";
8915 private static final String _FINDER_COLUMN_UUID_G_GROUPID_2 = "assetCategory.groupId = ?";
8916 private static final String _FINDER_COLUMN_UUID_C_UUID_1 = "assetCategory.uuid IS NULL AND ";
8917 private static final String _FINDER_COLUMN_UUID_C_UUID_2 = "assetCategory.uuid = ? AND ";
8918 private static final String _FINDER_COLUMN_UUID_C_UUID_3 = "(assetCategory.uuid IS NULL OR assetCategory.uuid = ?) AND ";
8919 private static final String _FINDER_COLUMN_UUID_C_COMPANYID_2 = "assetCategory.companyId = ?";
8920 private static final String _FINDER_COLUMN_GROUPID_GROUPID_2 = "assetCategory.groupId = ?";
8921 private static final String _FINDER_COLUMN_PARENTCATEGORYID_PARENTCATEGORYID_2 =
8922 "assetCategory.parentCategoryId = ?";
8923 private static final String _FINDER_COLUMN_VOCABULARYID_VOCABULARYID_2 = "assetCategory.vocabularyId = ?";
8924 private static final String _FINDER_COLUMN_G_V_GROUPID_2 = "assetCategory.groupId = ? AND ";
8925 private static final String _FINDER_COLUMN_G_V_VOCABULARYID_2 = "assetCategory.vocabularyId = ?";
8926 private static final String _FINDER_COLUMN_P_N_PARENTCATEGORYID_2 = "assetCategory.parentCategoryId = ? AND ";
8927 private static final String _FINDER_COLUMN_P_N_NAME_1 = "assetCategory.name IS NULL";
8928 private static final String _FINDER_COLUMN_P_N_NAME_2 = "assetCategory.name = ?";
8929 private static final String _FINDER_COLUMN_P_N_NAME_3 = "(assetCategory.name IS NULL OR assetCategory.name = ?)";
8930 private static final String _FINDER_COLUMN_P_V_PARENTCATEGORYID_2 = "assetCategory.parentCategoryId = ? AND ";
8931 private static final String _FINDER_COLUMN_P_V_VOCABULARYID_2 = "assetCategory.vocabularyId = ?";
8932 private static final String _FINDER_COLUMN_N_V_NAME_1 = "assetCategory.name IS NULL AND ";
8933 private static final String _FINDER_COLUMN_N_V_NAME_2 = "assetCategory.name = ? AND ";
8934 private static final String _FINDER_COLUMN_N_V_NAME_3 = "(assetCategory.name IS NULL OR assetCategory.name = ?) AND ";
8935 private static final String _FINDER_COLUMN_N_V_VOCABULARYID_2 = "assetCategory.vocabularyId = ?";
8936 private static final String _FINDER_COLUMN_G_P_N_GROUPID_2 = "assetCategory.groupId = ? AND ";
8937 private static final String _FINDER_COLUMN_G_P_N_PARENTCATEGORYID_2 = "assetCategory.parentCategoryId = ? AND ";
8938 private static final String _FINDER_COLUMN_G_P_N_NAME_1 = "assetCategory.name IS NULL";
8939 private static final String _FINDER_COLUMN_G_P_N_NAME_2 = "assetCategory.name = ?";
8940 private static final String _FINDER_COLUMN_G_P_N_NAME_3 = "(assetCategory.name IS NULL OR assetCategory.name = ?)";
8941 private static final String _FINDER_COLUMN_P_N_V_PARENTCATEGORYID_2 = "assetCategory.parentCategoryId = ? AND ";
8942 private static final String _FINDER_COLUMN_P_N_V_NAME_1 = "assetCategory.name IS NULL AND ";
8943 private static final String _FINDER_COLUMN_P_N_V_NAME_2 = "assetCategory.name = ? AND ";
8944 private static final String _FINDER_COLUMN_P_N_V_NAME_3 = "(assetCategory.name IS NULL OR assetCategory.name = ?) AND ";
8945 private static final String _FINDER_COLUMN_P_N_V_VOCABULARYID_2 = "assetCategory.vocabularyId = ?";
8946 private static final String _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN = "assetCategory.categoryId";
8947 private static final String _FILTER_SQL_SELECT_ASSETCATEGORY_WHERE = "SELECT DISTINCT {assetCategory.*} FROM AssetCategory assetCategory WHERE ";
8948 private static final String _FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_1 =
8949 "SELECT {AssetCategory.*} FROM (SELECT DISTINCT assetCategory.categoryId FROM AssetCategory assetCategory WHERE ";
8950 private static final String _FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_2 =
8951 ") TEMP_TABLE INNER JOIN AssetCategory ON TEMP_TABLE.categoryId = AssetCategory.categoryId";
8952 private static final String _FILTER_SQL_COUNT_ASSETCATEGORY_WHERE = "SELECT COUNT(DISTINCT assetCategory.categoryId) AS COUNT_VALUE FROM AssetCategory assetCategory WHERE ";
8953 private static final String _FILTER_ENTITY_ALIAS = "assetCategory";
8954 private static final String _FILTER_ENTITY_TABLE = "AssetCategory";
8955 private static final String _ORDER_BY_ENTITY_ALIAS = "assetCategory.";
8956 private static final String _ORDER_BY_ENTITY_TABLE = "AssetCategory.";
8957 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No AssetCategory exists with the primary key ";
8958 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No AssetCategory exists with the key {";
8959 private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
8960 private static Log _log = LogFactoryUtil.getLog(AssetCategoryPersistenceImpl.class);
8961 private static AssetCategory _nullAssetCategory = new AssetCategoryImpl() {
8962 @Override
8963 public Object clone() {
8964 return this;
8965 }
8966
8967 @Override
8968 public CacheModel<AssetCategory> toCacheModel() {
8969 return _nullAssetCategoryCacheModel;
8970 }
8971 };
8972
8973 private static CacheModel<AssetCategory> _nullAssetCategoryCacheModel = new CacheModel<AssetCategory>() {
8974 public AssetCategory toEntityModel() {
8975 return _nullAssetCategory;
8976 }
8977 };
8978 }