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.CalendarUtil;
037 import com.liferay.portal.kernel.util.GetterUtil;
038 import com.liferay.portal.kernel.util.InstanceFactory;
039 import com.liferay.portal.kernel.util.OrderByComparator;
040 import com.liferay.portal.kernel.util.SetUtil;
041 import com.liferay.portal.kernel.util.StringBundler;
042 import com.liferay.portal.kernel.util.StringPool;
043 import com.liferay.portal.kernel.util.StringUtil;
044 import com.liferay.portal.kernel.util.Validator;
045 import com.liferay.portal.model.CacheModel;
046 import com.liferay.portal.model.ModelListener;
047 import com.liferay.portal.service.persistence.BatchSessionUtil;
048 import com.liferay.portal.service.persistence.CompanyPersistence;
049 import com.liferay.portal.service.persistence.GroupPersistence;
050 import com.liferay.portal.service.persistence.ResourcePersistence;
051 import com.liferay.portal.service.persistence.UserPersistence;
052 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
053
054 import com.liferay.portlet.asset.NoSuchEntryException;
055 import com.liferay.portlet.asset.model.AssetEntry;
056 import com.liferay.portlet.asset.model.impl.AssetEntryImpl;
057 import com.liferay.portlet.asset.model.impl.AssetEntryModelImpl;
058 import com.liferay.portlet.blogs.service.persistence.BlogsEntryPersistence;
059 import com.liferay.portlet.bookmarks.service.persistence.BookmarksEntryPersistence;
060 import com.liferay.portlet.documentlibrary.service.persistence.DLFileEntryPersistence;
061 import com.liferay.portlet.documentlibrary.service.persistence.DLFolderPersistence;
062 import com.liferay.portlet.journal.service.persistence.JournalArticlePersistence;
063 import com.liferay.portlet.journal.service.persistence.JournalArticleResourcePersistence;
064 import com.liferay.portlet.messageboards.service.persistence.MBMessagePersistence;
065 import com.liferay.portlet.social.service.persistence.SocialActivityPersistence;
066 import com.liferay.portlet.wiki.service.persistence.WikiPagePersistence;
067 import com.liferay.portlet.wiki.service.persistence.WikiPageResourcePersistence;
068
069 import java.io.Serializable;
070
071 import java.util.ArrayList;
072 import java.util.Collections;
073 import java.util.Date;
074 import java.util.List;
075 import java.util.Set;
076
077
089 public class AssetEntryPersistenceImpl extends BasePersistenceImpl<AssetEntry>
090 implements AssetEntryPersistence {
091
096 public static final String FINDER_CLASS_NAME_ENTITY = AssetEntryImpl.class.getName();
097 public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
098 ".List1";
099 public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
100 ".List2";
101 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID =
102 new FinderPath(AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
103 AssetEntryModelImpl.FINDER_CACHE_ENABLED, AssetEntryImpl.class,
104 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByCompanyId",
105 new String[] {
106 Long.class.getName(),
107
108 "java.lang.Integer", "java.lang.Integer",
109 "com.liferay.portal.kernel.util.OrderByComparator"
110 });
111 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID =
112 new FinderPath(AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
113 AssetEntryModelImpl.FINDER_CACHE_ENABLED, AssetEntryImpl.class,
114 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByCompanyId",
115 new String[] { Long.class.getName() },
116 AssetEntryModelImpl.COMPANYID_COLUMN_BITMASK);
117 public static final FinderPath FINDER_PATH_COUNT_BY_COMPANYID = new FinderPath(AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
118 AssetEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
119 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByCompanyId",
120 new String[] { Long.class.getName() });
121 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_VISIBLE = new FinderPath(AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
122 AssetEntryModelImpl.FINDER_CACHE_ENABLED, AssetEntryImpl.class,
123 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByVisible",
124 new String[] {
125 Boolean.class.getName(),
126
127 "java.lang.Integer", "java.lang.Integer",
128 "com.liferay.portal.kernel.util.OrderByComparator"
129 });
130 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_VISIBLE =
131 new FinderPath(AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
132 AssetEntryModelImpl.FINDER_CACHE_ENABLED, AssetEntryImpl.class,
133 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByVisible",
134 new String[] { Boolean.class.getName() },
135 AssetEntryModelImpl.VISIBLE_COLUMN_BITMASK);
136 public static final FinderPath FINDER_PATH_COUNT_BY_VISIBLE = new FinderPath(AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
137 AssetEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
138 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByVisible",
139 new String[] { Boolean.class.getName() });
140 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_PUBLISHDATE =
141 new FinderPath(AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
142 AssetEntryModelImpl.FINDER_CACHE_ENABLED, AssetEntryImpl.class,
143 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByPublishDate",
144 new String[] {
145 Date.class.getName(),
146
147 "java.lang.Integer", "java.lang.Integer",
148 "com.liferay.portal.kernel.util.OrderByComparator"
149 });
150 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_PUBLISHDATE =
151 new FinderPath(AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
152 AssetEntryModelImpl.FINDER_CACHE_ENABLED, AssetEntryImpl.class,
153 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByPublishDate",
154 new String[] { Date.class.getName() },
155 AssetEntryModelImpl.PUBLISHDATE_COLUMN_BITMASK);
156 public static final FinderPath FINDER_PATH_COUNT_BY_PUBLISHDATE = new FinderPath(AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
157 AssetEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
158 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByPublishDate",
159 new String[] { Date.class.getName() });
160 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_EXPIRATIONDATE =
161 new FinderPath(AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
162 AssetEntryModelImpl.FINDER_CACHE_ENABLED, AssetEntryImpl.class,
163 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByExpirationDate",
164 new String[] {
165 Date.class.getName(),
166
167 "java.lang.Integer", "java.lang.Integer",
168 "com.liferay.portal.kernel.util.OrderByComparator"
169 });
170 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_EXPIRATIONDATE =
171 new FinderPath(AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
172 AssetEntryModelImpl.FINDER_CACHE_ENABLED, AssetEntryImpl.class,
173 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByExpirationDate",
174 new String[] { Date.class.getName() },
175 AssetEntryModelImpl.EXPIRATIONDATE_COLUMN_BITMASK);
176 public static final FinderPath FINDER_PATH_COUNT_BY_EXPIRATIONDATE = new FinderPath(AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
177 AssetEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
178 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByExpirationDate",
179 new String[] { Date.class.getName() });
180 public static final FinderPath FINDER_PATH_FETCH_BY_G_CU = new FinderPath(AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
181 AssetEntryModelImpl.FINDER_CACHE_ENABLED, AssetEntryImpl.class,
182 FINDER_CLASS_NAME_ENTITY, "fetchByG_CU",
183 new String[] { Long.class.getName(), String.class.getName() },
184 AssetEntryModelImpl.GROUPID_COLUMN_BITMASK |
185 AssetEntryModelImpl.CLASSUUID_COLUMN_BITMASK);
186 public static final FinderPath FINDER_PATH_COUNT_BY_G_CU = new FinderPath(AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
187 AssetEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
188 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_CU",
189 new String[] { Long.class.getName(), String.class.getName() });
190 public static final FinderPath FINDER_PATH_FETCH_BY_C_C = new FinderPath(AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
191 AssetEntryModelImpl.FINDER_CACHE_ENABLED, AssetEntryImpl.class,
192 FINDER_CLASS_NAME_ENTITY, "fetchByC_C",
193 new String[] { Long.class.getName(), Long.class.getName() },
194 AssetEntryModelImpl.CLASSNAMEID_COLUMN_BITMASK |
195 AssetEntryModelImpl.CLASSPK_COLUMN_BITMASK);
196 public static final FinderPath FINDER_PATH_COUNT_BY_C_C = new FinderPath(AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
197 AssetEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
198 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_C",
199 new String[] { Long.class.getName(), Long.class.getName() });
200 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
201 AssetEntryModelImpl.FINDER_CACHE_ENABLED, AssetEntryImpl.class,
202 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0]);
203 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
204 AssetEntryModelImpl.FINDER_CACHE_ENABLED, AssetEntryImpl.class,
205 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
206 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
207 AssetEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
208 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
209
210
215 public void cacheResult(AssetEntry assetEntry) {
216 EntityCacheUtil.putResult(AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
217 AssetEntryImpl.class, assetEntry.getPrimaryKey(), assetEntry);
218
219 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_CU,
220 new Object[] {
221 Long.valueOf(assetEntry.getGroupId()),
222
223 assetEntry.getClassUuid()
224 }, assetEntry);
225
226 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C,
227 new Object[] {
228 Long.valueOf(assetEntry.getClassNameId()),
229 Long.valueOf(assetEntry.getClassPK())
230 }, assetEntry);
231
232 assetEntry.resetOriginalValues();
233 }
234
235
240 public void cacheResult(List<AssetEntry> assetEntries) {
241 for (AssetEntry assetEntry : assetEntries) {
242 if (EntityCacheUtil.getResult(
243 AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
244 AssetEntryImpl.class, assetEntry.getPrimaryKey()) == null) {
245 cacheResult(assetEntry);
246 }
247 else {
248 assetEntry.resetOriginalValues();
249 }
250 }
251 }
252
253
260 @Override
261 public void clearCache() {
262 if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
263 CacheRegistryUtil.clear(AssetEntryImpl.class.getName());
264 }
265
266 EntityCacheUtil.clearCache(AssetEntryImpl.class.getName());
267
268 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
269 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
270 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
271 }
272
273
280 @Override
281 public void clearCache(AssetEntry assetEntry) {
282 EntityCacheUtil.removeResult(AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
283 AssetEntryImpl.class, assetEntry.getPrimaryKey());
284
285 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
286 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
287
288 clearUniqueFindersCache(assetEntry);
289 }
290
291 @Override
292 public void clearCache(List<AssetEntry> assetEntries) {
293 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
294 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
295
296 for (AssetEntry assetEntry : assetEntries) {
297 EntityCacheUtil.removeResult(AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
298 AssetEntryImpl.class, assetEntry.getPrimaryKey());
299
300 clearUniqueFindersCache(assetEntry);
301 }
302 }
303
304 protected void clearUniqueFindersCache(AssetEntry assetEntry) {
305 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_CU,
306 new Object[] {
307 Long.valueOf(assetEntry.getGroupId()),
308
309 assetEntry.getClassUuid()
310 });
311
312 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_C,
313 new Object[] {
314 Long.valueOf(assetEntry.getClassNameId()),
315 Long.valueOf(assetEntry.getClassPK())
316 });
317 }
318
319
325 public AssetEntry create(long entryId) {
326 AssetEntry assetEntry = new AssetEntryImpl();
327
328 assetEntry.setNew(true);
329 assetEntry.setPrimaryKey(entryId);
330
331 return assetEntry;
332 }
333
334
342 public AssetEntry remove(long entryId)
343 throws NoSuchEntryException, SystemException {
344 return remove(Long.valueOf(entryId));
345 }
346
347
355 @Override
356 public AssetEntry remove(Serializable primaryKey)
357 throws NoSuchEntryException, SystemException {
358 Session session = null;
359
360 try {
361 session = openSession();
362
363 AssetEntry assetEntry = (AssetEntry)session.get(AssetEntryImpl.class,
364 primaryKey);
365
366 if (assetEntry == null) {
367 if (_log.isWarnEnabled()) {
368 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
369 }
370
371 throw new NoSuchEntryException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
372 primaryKey);
373 }
374
375 return remove(assetEntry);
376 }
377 catch (NoSuchEntryException nsee) {
378 throw nsee;
379 }
380 catch (Exception e) {
381 throw processException(e);
382 }
383 finally {
384 closeSession(session);
385 }
386 }
387
388 @Override
389 protected AssetEntry removeImpl(AssetEntry assetEntry)
390 throws SystemException {
391 assetEntry = toUnwrappedModel(assetEntry);
392
393 try {
394 clearAssetCategories.clear(assetEntry.getPrimaryKey());
395 }
396 catch (Exception e) {
397 throw processException(e);
398 }
399 finally {
400 FinderCacheUtil.clearCache(AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
401 }
402
403 try {
404 clearAssetTags.clear(assetEntry.getPrimaryKey());
405 }
406 catch (Exception e) {
407 throw processException(e);
408 }
409 finally {
410 FinderCacheUtil.clearCache(AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETTAGS_NAME);
411 }
412
413 Session session = null;
414
415 try {
416 session = openSession();
417
418 BatchSessionUtil.delete(session, assetEntry);
419 }
420 catch (Exception e) {
421 throw processException(e);
422 }
423 finally {
424 closeSession(session);
425 }
426
427 clearCache(assetEntry);
428
429 return assetEntry;
430 }
431
432 @Override
433 public AssetEntry updateImpl(
434 com.liferay.portlet.asset.model.AssetEntry assetEntry, boolean merge)
435 throws SystemException {
436 assetEntry = toUnwrappedModel(assetEntry);
437
438 boolean isNew = assetEntry.isNew();
439
440 AssetEntryModelImpl assetEntryModelImpl = (AssetEntryModelImpl)assetEntry;
441
442 Session session = null;
443
444 try {
445 session = openSession();
446
447 BatchSessionUtil.update(session, assetEntry, merge);
448
449 assetEntry.setNew(false);
450 }
451 catch (Exception e) {
452 throw processException(e);
453 }
454 finally {
455 closeSession(session);
456 }
457
458 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
459
460 if (isNew || !AssetEntryModelImpl.COLUMN_BITMASK_ENABLED) {
461 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
462 }
463
464 else {
465 if ((assetEntryModelImpl.getColumnBitmask() &
466 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID.getColumnBitmask()) != 0) {
467 Object[] args = new Object[] {
468 Long.valueOf(assetEntryModelImpl.getOriginalCompanyId())
469 };
470
471 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_COMPANYID,
472 args);
473 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
474 args);
475
476 args = new Object[] {
477 Long.valueOf(assetEntryModelImpl.getCompanyId())
478 };
479
480 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_COMPANYID,
481 args);
482 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
483 args);
484 }
485
486 if ((assetEntryModelImpl.getColumnBitmask() &
487 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_VISIBLE.getColumnBitmask()) != 0) {
488 Object[] args = new Object[] {
489 Boolean.valueOf(assetEntryModelImpl.getOriginalVisible())
490 };
491
492 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_VISIBLE, args);
493 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_VISIBLE,
494 args);
495
496 args = new Object[] {
497 Boolean.valueOf(assetEntryModelImpl.getVisible())
498 };
499
500 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_VISIBLE, args);
501 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_VISIBLE,
502 args);
503 }
504
505 if ((assetEntryModelImpl.getColumnBitmask() &
506 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_PUBLISHDATE.getColumnBitmask()) != 0) {
507 Object[] args = new Object[] {
508 assetEntryModelImpl.getOriginalPublishDate()
509 };
510
511 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_PUBLISHDATE,
512 args);
513 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_PUBLISHDATE,
514 args);
515
516 args = new Object[] { assetEntryModelImpl.getPublishDate() };
517
518 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_PUBLISHDATE,
519 args);
520 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_PUBLISHDATE,
521 args);
522 }
523
524 if ((assetEntryModelImpl.getColumnBitmask() &
525 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_EXPIRATIONDATE.getColumnBitmask()) != 0) {
526 Object[] args = new Object[] {
527 assetEntryModelImpl.getOriginalExpirationDate()
528 };
529
530 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_EXPIRATIONDATE,
531 args);
532 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_EXPIRATIONDATE,
533 args);
534
535 args = new Object[] { assetEntryModelImpl.getExpirationDate() };
536
537 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_EXPIRATIONDATE,
538 args);
539 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_EXPIRATIONDATE,
540 args);
541 }
542 }
543
544 EntityCacheUtil.putResult(AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
545 AssetEntryImpl.class, assetEntry.getPrimaryKey(), assetEntry);
546
547 if (isNew) {
548 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_CU,
549 new Object[] {
550 Long.valueOf(assetEntry.getGroupId()),
551
552 assetEntry.getClassUuid()
553 }, assetEntry);
554
555 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C,
556 new Object[] {
557 Long.valueOf(assetEntry.getClassNameId()),
558 Long.valueOf(assetEntry.getClassPK())
559 }, assetEntry);
560 }
561 else {
562 if ((assetEntryModelImpl.getColumnBitmask() &
563 FINDER_PATH_FETCH_BY_G_CU.getColumnBitmask()) != 0) {
564 Object[] args = new Object[] {
565 Long.valueOf(assetEntryModelImpl.getOriginalGroupId()),
566
567 assetEntryModelImpl.getOriginalClassUuid()
568 };
569
570 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_CU, args);
571
572 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_CU, args);
573
574 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_CU,
575 new Object[] {
576 Long.valueOf(assetEntry.getGroupId()),
577
578 assetEntry.getClassUuid()
579 }, assetEntry);
580 }
581
582 if ((assetEntryModelImpl.getColumnBitmask() &
583 FINDER_PATH_FETCH_BY_C_C.getColumnBitmask()) != 0) {
584 Object[] args = new Object[] {
585 Long.valueOf(assetEntryModelImpl.getOriginalClassNameId()),
586 Long.valueOf(assetEntryModelImpl.getOriginalClassPK())
587 };
588
589 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_C, args);
590
591 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_C, args);
592
593 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C,
594 new Object[] {
595 Long.valueOf(assetEntry.getClassNameId()),
596 Long.valueOf(assetEntry.getClassPK())
597 }, assetEntry);
598 }
599 }
600
601 return assetEntry;
602 }
603
604 protected AssetEntry toUnwrappedModel(AssetEntry assetEntry) {
605 if (assetEntry instanceof AssetEntryImpl) {
606 return assetEntry;
607 }
608
609 AssetEntryImpl assetEntryImpl = new AssetEntryImpl();
610
611 assetEntryImpl.setNew(assetEntry.isNew());
612 assetEntryImpl.setPrimaryKey(assetEntry.getPrimaryKey());
613
614 assetEntryImpl.setEntryId(assetEntry.getEntryId());
615 assetEntryImpl.setGroupId(assetEntry.getGroupId());
616 assetEntryImpl.setCompanyId(assetEntry.getCompanyId());
617 assetEntryImpl.setUserId(assetEntry.getUserId());
618 assetEntryImpl.setUserName(assetEntry.getUserName());
619 assetEntryImpl.setCreateDate(assetEntry.getCreateDate());
620 assetEntryImpl.setModifiedDate(assetEntry.getModifiedDate());
621 assetEntryImpl.setClassNameId(assetEntry.getClassNameId());
622 assetEntryImpl.setClassPK(assetEntry.getClassPK());
623 assetEntryImpl.setClassUuid(assetEntry.getClassUuid());
624 assetEntryImpl.setClassTypeId(assetEntry.getClassTypeId());
625 assetEntryImpl.setVisible(assetEntry.isVisible());
626 assetEntryImpl.setStartDate(assetEntry.getStartDate());
627 assetEntryImpl.setEndDate(assetEntry.getEndDate());
628 assetEntryImpl.setPublishDate(assetEntry.getPublishDate());
629 assetEntryImpl.setExpirationDate(assetEntry.getExpirationDate());
630 assetEntryImpl.setMimeType(assetEntry.getMimeType());
631 assetEntryImpl.setTitle(assetEntry.getTitle());
632 assetEntryImpl.setDescription(assetEntry.getDescription());
633 assetEntryImpl.setSummary(assetEntry.getSummary());
634 assetEntryImpl.setUrl(assetEntry.getUrl());
635 assetEntryImpl.setLayoutUuid(assetEntry.getLayoutUuid());
636 assetEntryImpl.setHeight(assetEntry.getHeight());
637 assetEntryImpl.setWidth(assetEntry.getWidth());
638 assetEntryImpl.setPriority(assetEntry.getPriority());
639 assetEntryImpl.setViewCount(assetEntry.getViewCount());
640
641 return assetEntryImpl;
642 }
643
644
652 @Override
653 public AssetEntry findByPrimaryKey(Serializable primaryKey)
654 throws NoSuchModelException, SystemException {
655 return findByPrimaryKey(((Long)primaryKey).longValue());
656 }
657
658
666 public AssetEntry findByPrimaryKey(long entryId)
667 throws NoSuchEntryException, SystemException {
668 AssetEntry assetEntry = fetchByPrimaryKey(entryId);
669
670 if (assetEntry == null) {
671 if (_log.isWarnEnabled()) {
672 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + entryId);
673 }
674
675 throw new NoSuchEntryException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
676 entryId);
677 }
678
679 return assetEntry;
680 }
681
682
689 @Override
690 public AssetEntry fetchByPrimaryKey(Serializable primaryKey)
691 throws SystemException {
692 return fetchByPrimaryKey(((Long)primaryKey).longValue());
693 }
694
695
702 public AssetEntry fetchByPrimaryKey(long entryId) throws SystemException {
703 AssetEntry assetEntry = (AssetEntry)EntityCacheUtil.getResult(AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
704 AssetEntryImpl.class, entryId);
705
706 if (assetEntry == _nullAssetEntry) {
707 return null;
708 }
709
710 if (assetEntry == null) {
711 Session session = null;
712
713 boolean hasException = false;
714
715 try {
716 session = openSession();
717
718 assetEntry = (AssetEntry)session.get(AssetEntryImpl.class,
719 Long.valueOf(entryId));
720 }
721 catch (Exception e) {
722 hasException = true;
723
724 throw processException(e);
725 }
726 finally {
727 if (assetEntry != null) {
728 cacheResult(assetEntry);
729 }
730 else if (!hasException) {
731 EntityCacheUtil.putResult(AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
732 AssetEntryImpl.class, entryId, _nullAssetEntry);
733 }
734
735 closeSession(session);
736 }
737 }
738
739 return assetEntry;
740 }
741
742
749 public List<AssetEntry> findByCompanyId(long companyId)
750 throws SystemException {
751 return findByCompanyId(companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
752 null);
753 }
754
755
768 public List<AssetEntry> findByCompanyId(long companyId, int start, int end)
769 throws SystemException {
770 return findByCompanyId(companyId, start, end, null);
771 }
772
773
787 public List<AssetEntry> findByCompanyId(long companyId, int start, int end,
788 OrderByComparator orderByComparator) throws SystemException {
789 FinderPath finderPath = null;
790 Object[] finderArgs = null;
791
792 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
793 (orderByComparator == null)) {
794 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID;
795 finderArgs = new Object[] { companyId };
796 }
797 else {
798 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID;
799 finderArgs = new Object[] { companyId, start, end, orderByComparator };
800 }
801
802 List<AssetEntry> list = (List<AssetEntry>)FinderCacheUtil.getResult(finderPath,
803 finderArgs, this);
804
805 if ((list != null) && !list.isEmpty()) {
806 for (AssetEntry assetEntry : list) {
807 if ((companyId != assetEntry.getCompanyId())) {
808 list = null;
809
810 break;
811 }
812 }
813 }
814
815 if (list == null) {
816 StringBundler query = null;
817
818 if (orderByComparator != null) {
819 query = new StringBundler(3 +
820 (orderByComparator.getOrderByFields().length * 3));
821 }
822 else {
823 query = new StringBundler(2);
824 }
825
826 query.append(_SQL_SELECT_ASSETENTRY_WHERE);
827
828 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
829
830 if (orderByComparator != null) {
831 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
832 orderByComparator);
833 }
834
835 String sql = query.toString();
836
837 Session session = null;
838
839 try {
840 session = openSession();
841
842 Query q = session.createQuery(sql);
843
844 QueryPos qPos = QueryPos.getInstance(q);
845
846 qPos.add(companyId);
847
848 list = (List<AssetEntry>)QueryUtil.list(q, getDialect(), start,
849 end);
850 }
851 catch (Exception e) {
852 throw processException(e);
853 }
854 finally {
855 if (list == null) {
856 FinderCacheUtil.removeResult(finderPath, finderArgs);
857 }
858 else {
859 cacheResult(list);
860
861 FinderCacheUtil.putResult(finderPath, finderArgs, list);
862 }
863
864 closeSession(session);
865 }
866 }
867
868 return list;
869 }
870
871
880 public AssetEntry findByCompanyId_First(long companyId,
881 OrderByComparator orderByComparator)
882 throws NoSuchEntryException, SystemException {
883 AssetEntry assetEntry = fetchByCompanyId_First(companyId,
884 orderByComparator);
885
886 if (assetEntry != null) {
887 return assetEntry;
888 }
889
890 StringBundler msg = new StringBundler(4);
891
892 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
893
894 msg.append("companyId=");
895 msg.append(companyId);
896
897 msg.append(StringPool.CLOSE_CURLY_BRACE);
898
899 throw new NoSuchEntryException(msg.toString());
900 }
901
902
910 public AssetEntry fetchByCompanyId_First(long companyId,
911 OrderByComparator orderByComparator) throws SystemException {
912 List<AssetEntry> list = findByCompanyId(companyId, 0, 1,
913 orderByComparator);
914
915 if (!list.isEmpty()) {
916 return list.get(0);
917 }
918
919 return null;
920 }
921
922
931 public AssetEntry findByCompanyId_Last(long companyId,
932 OrderByComparator orderByComparator)
933 throws NoSuchEntryException, SystemException {
934 AssetEntry assetEntry = fetchByCompanyId_Last(companyId,
935 orderByComparator);
936
937 if (assetEntry != null) {
938 return assetEntry;
939 }
940
941 StringBundler msg = new StringBundler(4);
942
943 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
944
945 msg.append("companyId=");
946 msg.append(companyId);
947
948 msg.append(StringPool.CLOSE_CURLY_BRACE);
949
950 throw new NoSuchEntryException(msg.toString());
951 }
952
953
961 public AssetEntry fetchByCompanyId_Last(long companyId,
962 OrderByComparator orderByComparator) throws SystemException {
963 int count = countByCompanyId(companyId);
964
965 List<AssetEntry> list = findByCompanyId(companyId, count - 1, count,
966 orderByComparator);
967
968 if (!list.isEmpty()) {
969 return list.get(0);
970 }
971
972 return null;
973 }
974
975
985 public AssetEntry[] findByCompanyId_PrevAndNext(long entryId,
986 long companyId, OrderByComparator orderByComparator)
987 throws NoSuchEntryException, SystemException {
988 AssetEntry assetEntry = findByPrimaryKey(entryId);
989
990 Session session = null;
991
992 try {
993 session = openSession();
994
995 AssetEntry[] array = new AssetEntryImpl[3];
996
997 array[0] = getByCompanyId_PrevAndNext(session, assetEntry,
998 companyId, orderByComparator, true);
999
1000 array[1] = assetEntry;
1001
1002 array[2] = getByCompanyId_PrevAndNext(session, assetEntry,
1003 companyId, orderByComparator, false);
1004
1005 return array;
1006 }
1007 catch (Exception e) {
1008 throw processException(e);
1009 }
1010 finally {
1011 closeSession(session);
1012 }
1013 }
1014
1015 protected AssetEntry getByCompanyId_PrevAndNext(Session session,
1016 AssetEntry assetEntry, long companyId,
1017 OrderByComparator orderByComparator, boolean previous) {
1018 StringBundler query = null;
1019
1020 if (orderByComparator != null) {
1021 query = new StringBundler(6 +
1022 (orderByComparator.getOrderByFields().length * 6));
1023 }
1024 else {
1025 query = new StringBundler(3);
1026 }
1027
1028 query.append(_SQL_SELECT_ASSETENTRY_WHERE);
1029
1030 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
1031
1032 if (orderByComparator != null) {
1033 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1034
1035 if (orderByConditionFields.length > 0) {
1036 query.append(WHERE_AND);
1037 }
1038
1039 for (int i = 0; i < orderByConditionFields.length; i++) {
1040 query.append(_ORDER_BY_ENTITY_ALIAS);
1041 query.append(orderByConditionFields[i]);
1042
1043 if ((i + 1) < orderByConditionFields.length) {
1044 if (orderByComparator.isAscending() ^ previous) {
1045 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1046 }
1047 else {
1048 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1049 }
1050 }
1051 else {
1052 if (orderByComparator.isAscending() ^ previous) {
1053 query.append(WHERE_GREATER_THAN);
1054 }
1055 else {
1056 query.append(WHERE_LESSER_THAN);
1057 }
1058 }
1059 }
1060
1061 query.append(ORDER_BY_CLAUSE);
1062
1063 String[] orderByFields = orderByComparator.getOrderByFields();
1064
1065 for (int i = 0; i < orderByFields.length; i++) {
1066 query.append(_ORDER_BY_ENTITY_ALIAS);
1067 query.append(orderByFields[i]);
1068
1069 if ((i + 1) < orderByFields.length) {
1070 if (orderByComparator.isAscending() ^ previous) {
1071 query.append(ORDER_BY_ASC_HAS_NEXT);
1072 }
1073 else {
1074 query.append(ORDER_BY_DESC_HAS_NEXT);
1075 }
1076 }
1077 else {
1078 if (orderByComparator.isAscending() ^ previous) {
1079 query.append(ORDER_BY_ASC);
1080 }
1081 else {
1082 query.append(ORDER_BY_DESC);
1083 }
1084 }
1085 }
1086 }
1087
1088 String sql = query.toString();
1089
1090 Query q = session.createQuery(sql);
1091
1092 q.setFirstResult(0);
1093 q.setMaxResults(2);
1094
1095 QueryPos qPos = QueryPos.getInstance(q);
1096
1097 qPos.add(companyId);
1098
1099 if (orderByComparator != null) {
1100 Object[] values = orderByComparator.getOrderByConditionValues(assetEntry);
1101
1102 for (Object value : values) {
1103 qPos.add(value);
1104 }
1105 }
1106
1107 List<AssetEntry> list = q.list();
1108
1109 if (list.size() == 2) {
1110 return list.get(1);
1111 }
1112 else {
1113 return null;
1114 }
1115 }
1116
1117
1124 public List<AssetEntry> findByVisible(boolean visible)
1125 throws SystemException {
1126 return findByVisible(visible, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1127 }
1128
1129
1142 public List<AssetEntry> findByVisible(boolean visible, int start, int end)
1143 throws SystemException {
1144 return findByVisible(visible, start, end, null);
1145 }
1146
1147
1161 public List<AssetEntry> findByVisible(boolean visible, int start, int end,
1162 OrderByComparator orderByComparator) throws SystemException {
1163 FinderPath finderPath = null;
1164 Object[] finderArgs = null;
1165
1166 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1167 (orderByComparator == null)) {
1168 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_VISIBLE;
1169 finderArgs = new Object[] { visible };
1170 }
1171 else {
1172 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_VISIBLE;
1173 finderArgs = new Object[] { visible, start, end, orderByComparator };
1174 }
1175
1176 List<AssetEntry> list = (List<AssetEntry>)FinderCacheUtil.getResult(finderPath,
1177 finderArgs, this);
1178
1179 if ((list != null) && !list.isEmpty()) {
1180 for (AssetEntry assetEntry : list) {
1181 if ((visible != assetEntry.getVisible())) {
1182 list = null;
1183
1184 break;
1185 }
1186 }
1187 }
1188
1189 if (list == null) {
1190 StringBundler query = null;
1191
1192 if (orderByComparator != null) {
1193 query = new StringBundler(3 +
1194 (orderByComparator.getOrderByFields().length * 3));
1195 }
1196 else {
1197 query = new StringBundler(2);
1198 }
1199
1200 query.append(_SQL_SELECT_ASSETENTRY_WHERE);
1201
1202 query.append(_FINDER_COLUMN_VISIBLE_VISIBLE_2);
1203
1204 if (orderByComparator != null) {
1205 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1206 orderByComparator);
1207 }
1208
1209 String sql = query.toString();
1210
1211 Session session = null;
1212
1213 try {
1214 session = openSession();
1215
1216 Query q = session.createQuery(sql);
1217
1218 QueryPos qPos = QueryPos.getInstance(q);
1219
1220 qPos.add(visible);
1221
1222 list = (List<AssetEntry>)QueryUtil.list(q, getDialect(), start,
1223 end);
1224 }
1225 catch (Exception e) {
1226 throw processException(e);
1227 }
1228 finally {
1229 if (list == null) {
1230 FinderCacheUtil.removeResult(finderPath, finderArgs);
1231 }
1232 else {
1233 cacheResult(list);
1234
1235 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1236 }
1237
1238 closeSession(session);
1239 }
1240 }
1241
1242 return list;
1243 }
1244
1245
1254 public AssetEntry findByVisible_First(boolean visible,
1255 OrderByComparator orderByComparator)
1256 throws NoSuchEntryException, SystemException {
1257 AssetEntry assetEntry = fetchByVisible_First(visible, orderByComparator);
1258
1259 if (assetEntry != null) {
1260 return assetEntry;
1261 }
1262
1263 StringBundler msg = new StringBundler(4);
1264
1265 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1266
1267 msg.append("visible=");
1268 msg.append(visible);
1269
1270 msg.append(StringPool.CLOSE_CURLY_BRACE);
1271
1272 throw new NoSuchEntryException(msg.toString());
1273 }
1274
1275
1283 public AssetEntry fetchByVisible_First(boolean visible,
1284 OrderByComparator orderByComparator) throws SystemException {
1285 List<AssetEntry> list = findByVisible(visible, 0, 1, orderByComparator);
1286
1287 if (!list.isEmpty()) {
1288 return list.get(0);
1289 }
1290
1291 return null;
1292 }
1293
1294
1303 public AssetEntry findByVisible_Last(boolean visible,
1304 OrderByComparator orderByComparator)
1305 throws NoSuchEntryException, SystemException {
1306 AssetEntry assetEntry = fetchByVisible_Last(visible, orderByComparator);
1307
1308 if (assetEntry != null) {
1309 return assetEntry;
1310 }
1311
1312 StringBundler msg = new StringBundler(4);
1313
1314 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1315
1316 msg.append("visible=");
1317 msg.append(visible);
1318
1319 msg.append(StringPool.CLOSE_CURLY_BRACE);
1320
1321 throw new NoSuchEntryException(msg.toString());
1322 }
1323
1324
1332 public AssetEntry fetchByVisible_Last(boolean visible,
1333 OrderByComparator orderByComparator) throws SystemException {
1334 int count = countByVisible(visible);
1335
1336 List<AssetEntry> list = findByVisible(visible, count - 1, count,
1337 orderByComparator);
1338
1339 if (!list.isEmpty()) {
1340 return list.get(0);
1341 }
1342
1343 return null;
1344 }
1345
1346
1356 public AssetEntry[] findByVisible_PrevAndNext(long entryId,
1357 boolean visible, OrderByComparator orderByComparator)
1358 throws NoSuchEntryException, SystemException {
1359 AssetEntry assetEntry = findByPrimaryKey(entryId);
1360
1361 Session session = null;
1362
1363 try {
1364 session = openSession();
1365
1366 AssetEntry[] array = new AssetEntryImpl[3];
1367
1368 array[0] = getByVisible_PrevAndNext(session, assetEntry, visible,
1369 orderByComparator, true);
1370
1371 array[1] = assetEntry;
1372
1373 array[2] = getByVisible_PrevAndNext(session, assetEntry, visible,
1374 orderByComparator, false);
1375
1376 return array;
1377 }
1378 catch (Exception e) {
1379 throw processException(e);
1380 }
1381 finally {
1382 closeSession(session);
1383 }
1384 }
1385
1386 protected AssetEntry getByVisible_PrevAndNext(Session session,
1387 AssetEntry assetEntry, boolean visible,
1388 OrderByComparator orderByComparator, boolean previous) {
1389 StringBundler query = null;
1390
1391 if (orderByComparator != null) {
1392 query = new StringBundler(6 +
1393 (orderByComparator.getOrderByFields().length * 6));
1394 }
1395 else {
1396 query = new StringBundler(3);
1397 }
1398
1399 query.append(_SQL_SELECT_ASSETENTRY_WHERE);
1400
1401 query.append(_FINDER_COLUMN_VISIBLE_VISIBLE_2);
1402
1403 if (orderByComparator != null) {
1404 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1405
1406 if (orderByConditionFields.length > 0) {
1407 query.append(WHERE_AND);
1408 }
1409
1410 for (int i = 0; i < orderByConditionFields.length; i++) {
1411 query.append(_ORDER_BY_ENTITY_ALIAS);
1412 query.append(orderByConditionFields[i]);
1413
1414 if ((i + 1) < orderByConditionFields.length) {
1415 if (orderByComparator.isAscending() ^ previous) {
1416 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1417 }
1418 else {
1419 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1420 }
1421 }
1422 else {
1423 if (orderByComparator.isAscending() ^ previous) {
1424 query.append(WHERE_GREATER_THAN);
1425 }
1426 else {
1427 query.append(WHERE_LESSER_THAN);
1428 }
1429 }
1430 }
1431
1432 query.append(ORDER_BY_CLAUSE);
1433
1434 String[] orderByFields = orderByComparator.getOrderByFields();
1435
1436 for (int i = 0; i < orderByFields.length; i++) {
1437 query.append(_ORDER_BY_ENTITY_ALIAS);
1438 query.append(orderByFields[i]);
1439
1440 if ((i + 1) < orderByFields.length) {
1441 if (orderByComparator.isAscending() ^ previous) {
1442 query.append(ORDER_BY_ASC_HAS_NEXT);
1443 }
1444 else {
1445 query.append(ORDER_BY_DESC_HAS_NEXT);
1446 }
1447 }
1448 else {
1449 if (orderByComparator.isAscending() ^ previous) {
1450 query.append(ORDER_BY_ASC);
1451 }
1452 else {
1453 query.append(ORDER_BY_DESC);
1454 }
1455 }
1456 }
1457 }
1458
1459 String sql = query.toString();
1460
1461 Query q = session.createQuery(sql);
1462
1463 q.setFirstResult(0);
1464 q.setMaxResults(2);
1465
1466 QueryPos qPos = QueryPos.getInstance(q);
1467
1468 qPos.add(visible);
1469
1470 if (orderByComparator != null) {
1471 Object[] values = orderByComparator.getOrderByConditionValues(assetEntry);
1472
1473 for (Object value : values) {
1474 qPos.add(value);
1475 }
1476 }
1477
1478 List<AssetEntry> list = q.list();
1479
1480 if (list.size() == 2) {
1481 return list.get(1);
1482 }
1483 else {
1484 return null;
1485 }
1486 }
1487
1488
1495 public List<AssetEntry> findByPublishDate(Date publishDate)
1496 throws SystemException {
1497 return findByPublishDate(publishDate, QueryUtil.ALL_POS,
1498 QueryUtil.ALL_POS, null);
1499 }
1500
1501
1514 public List<AssetEntry> findByPublishDate(Date publishDate, int start,
1515 int end) throws SystemException {
1516 return findByPublishDate(publishDate, start, end, null);
1517 }
1518
1519
1533 public List<AssetEntry> findByPublishDate(Date publishDate, int start,
1534 int end, OrderByComparator orderByComparator) throws SystemException {
1535 FinderPath finderPath = null;
1536 Object[] finderArgs = null;
1537
1538 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1539 (orderByComparator == null)) {
1540 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_PUBLISHDATE;
1541 finderArgs = new Object[] { publishDate };
1542 }
1543 else {
1544 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_PUBLISHDATE;
1545 finderArgs = new Object[] { publishDate, start, end, orderByComparator };
1546 }
1547
1548 List<AssetEntry> list = (List<AssetEntry>)FinderCacheUtil.getResult(finderPath,
1549 finderArgs, this);
1550
1551 if ((list != null) && !list.isEmpty()) {
1552 for (AssetEntry assetEntry : list) {
1553 if (!Validator.equals(publishDate, assetEntry.getPublishDate())) {
1554 list = null;
1555
1556 break;
1557 }
1558 }
1559 }
1560
1561 if (list == null) {
1562 StringBundler query = null;
1563
1564 if (orderByComparator != null) {
1565 query = new StringBundler(3 +
1566 (orderByComparator.getOrderByFields().length * 3));
1567 }
1568 else {
1569 query = new StringBundler(2);
1570 }
1571
1572 query.append(_SQL_SELECT_ASSETENTRY_WHERE);
1573
1574 if (publishDate == null) {
1575 query.append(_FINDER_COLUMN_PUBLISHDATE_PUBLISHDATE_1);
1576 }
1577 else {
1578 query.append(_FINDER_COLUMN_PUBLISHDATE_PUBLISHDATE_2);
1579 }
1580
1581 if (orderByComparator != null) {
1582 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1583 orderByComparator);
1584 }
1585
1586 String sql = query.toString();
1587
1588 Session session = null;
1589
1590 try {
1591 session = openSession();
1592
1593 Query q = session.createQuery(sql);
1594
1595 QueryPos qPos = QueryPos.getInstance(q);
1596
1597 if (publishDate != null) {
1598 qPos.add(CalendarUtil.getTimestamp(publishDate));
1599 }
1600
1601 list = (List<AssetEntry>)QueryUtil.list(q, getDialect(), start,
1602 end);
1603 }
1604 catch (Exception e) {
1605 throw processException(e);
1606 }
1607 finally {
1608 if (list == null) {
1609 FinderCacheUtil.removeResult(finderPath, finderArgs);
1610 }
1611 else {
1612 cacheResult(list);
1613
1614 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1615 }
1616
1617 closeSession(session);
1618 }
1619 }
1620
1621 return list;
1622 }
1623
1624
1633 public AssetEntry findByPublishDate_First(Date publishDate,
1634 OrderByComparator orderByComparator)
1635 throws NoSuchEntryException, SystemException {
1636 AssetEntry assetEntry = fetchByPublishDate_First(publishDate,
1637 orderByComparator);
1638
1639 if (assetEntry != null) {
1640 return assetEntry;
1641 }
1642
1643 StringBundler msg = new StringBundler(4);
1644
1645 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1646
1647 msg.append("publishDate=");
1648 msg.append(publishDate);
1649
1650 msg.append(StringPool.CLOSE_CURLY_BRACE);
1651
1652 throw new NoSuchEntryException(msg.toString());
1653 }
1654
1655
1663 public AssetEntry fetchByPublishDate_First(Date publishDate,
1664 OrderByComparator orderByComparator) throws SystemException {
1665 List<AssetEntry> list = findByPublishDate(publishDate, 0, 1,
1666 orderByComparator);
1667
1668 if (!list.isEmpty()) {
1669 return list.get(0);
1670 }
1671
1672 return null;
1673 }
1674
1675
1684 public AssetEntry findByPublishDate_Last(Date publishDate,
1685 OrderByComparator orderByComparator)
1686 throws NoSuchEntryException, SystemException {
1687 AssetEntry assetEntry = fetchByPublishDate_Last(publishDate,
1688 orderByComparator);
1689
1690 if (assetEntry != null) {
1691 return assetEntry;
1692 }
1693
1694 StringBundler msg = new StringBundler(4);
1695
1696 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1697
1698 msg.append("publishDate=");
1699 msg.append(publishDate);
1700
1701 msg.append(StringPool.CLOSE_CURLY_BRACE);
1702
1703 throw new NoSuchEntryException(msg.toString());
1704 }
1705
1706
1714 public AssetEntry fetchByPublishDate_Last(Date publishDate,
1715 OrderByComparator orderByComparator) throws SystemException {
1716 int count = countByPublishDate(publishDate);
1717
1718 List<AssetEntry> list = findByPublishDate(publishDate, count - 1,
1719 count, orderByComparator);
1720
1721 if (!list.isEmpty()) {
1722 return list.get(0);
1723 }
1724
1725 return null;
1726 }
1727
1728
1738 public AssetEntry[] findByPublishDate_PrevAndNext(long entryId,
1739 Date publishDate, OrderByComparator orderByComparator)
1740 throws NoSuchEntryException, SystemException {
1741 AssetEntry assetEntry = findByPrimaryKey(entryId);
1742
1743 Session session = null;
1744
1745 try {
1746 session = openSession();
1747
1748 AssetEntry[] array = new AssetEntryImpl[3];
1749
1750 array[0] = getByPublishDate_PrevAndNext(session, assetEntry,
1751 publishDate, orderByComparator, true);
1752
1753 array[1] = assetEntry;
1754
1755 array[2] = getByPublishDate_PrevAndNext(session, assetEntry,
1756 publishDate, orderByComparator, false);
1757
1758 return array;
1759 }
1760 catch (Exception e) {
1761 throw processException(e);
1762 }
1763 finally {
1764 closeSession(session);
1765 }
1766 }
1767
1768 protected AssetEntry getByPublishDate_PrevAndNext(Session session,
1769 AssetEntry assetEntry, Date publishDate,
1770 OrderByComparator orderByComparator, boolean previous) {
1771 StringBundler query = null;
1772
1773 if (orderByComparator != null) {
1774 query = new StringBundler(6 +
1775 (orderByComparator.getOrderByFields().length * 6));
1776 }
1777 else {
1778 query = new StringBundler(3);
1779 }
1780
1781 query.append(_SQL_SELECT_ASSETENTRY_WHERE);
1782
1783 if (publishDate == null) {
1784 query.append(_FINDER_COLUMN_PUBLISHDATE_PUBLISHDATE_1);
1785 }
1786 else {
1787 query.append(_FINDER_COLUMN_PUBLISHDATE_PUBLISHDATE_2);
1788 }
1789
1790 if (orderByComparator != null) {
1791 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1792
1793 if (orderByConditionFields.length > 0) {
1794 query.append(WHERE_AND);
1795 }
1796
1797 for (int i = 0; i < orderByConditionFields.length; i++) {
1798 query.append(_ORDER_BY_ENTITY_ALIAS);
1799 query.append(orderByConditionFields[i]);
1800
1801 if ((i + 1) < orderByConditionFields.length) {
1802 if (orderByComparator.isAscending() ^ previous) {
1803 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1804 }
1805 else {
1806 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1807 }
1808 }
1809 else {
1810 if (orderByComparator.isAscending() ^ previous) {
1811 query.append(WHERE_GREATER_THAN);
1812 }
1813 else {
1814 query.append(WHERE_LESSER_THAN);
1815 }
1816 }
1817 }
1818
1819 query.append(ORDER_BY_CLAUSE);
1820
1821 String[] orderByFields = orderByComparator.getOrderByFields();
1822
1823 for (int i = 0; i < orderByFields.length; i++) {
1824 query.append(_ORDER_BY_ENTITY_ALIAS);
1825 query.append(orderByFields[i]);
1826
1827 if ((i + 1) < orderByFields.length) {
1828 if (orderByComparator.isAscending() ^ previous) {
1829 query.append(ORDER_BY_ASC_HAS_NEXT);
1830 }
1831 else {
1832 query.append(ORDER_BY_DESC_HAS_NEXT);
1833 }
1834 }
1835 else {
1836 if (orderByComparator.isAscending() ^ previous) {
1837 query.append(ORDER_BY_ASC);
1838 }
1839 else {
1840 query.append(ORDER_BY_DESC);
1841 }
1842 }
1843 }
1844 }
1845
1846 String sql = query.toString();
1847
1848 Query q = session.createQuery(sql);
1849
1850 q.setFirstResult(0);
1851 q.setMaxResults(2);
1852
1853 QueryPos qPos = QueryPos.getInstance(q);
1854
1855 if (publishDate != null) {
1856 qPos.add(CalendarUtil.getTimestamp(publishDate));
1857 }
1858
1859 if (orderByComparator != null) {
1860 Object[] values = orderByComparator.getOrderByConditionValues(assetEntry);
1861
1862 for (Object value : values) {
1863 qPos.add(value);
1864 }
1865 }
1866
1867 List<AssetEntry> list = q.list();
1868
1869 if (list.size() == 2) {
1870 return list.get(1);
1871 }
1872 else {
1873 return null;
1874 }
1875 }
1876
1877
1884 public List<AssetEntry> findByExpirationDate(Date expirationDate)
1885 throws SystemException {
1886 return findByExpirationDate(expirationDate, QueryUtil.ALL_POS,
1887 QueryUtil.ALL_POS, null);
1888 }
1889
1890
1903 public List<AssetEntry> findByExpirationDate(Date expirationDate,
1904 int start, int end) throws SystemException {
1905 return findByExpirationDate(expirationDate, start, end, null);
1906 }
1907
1908
1922 public List<AssetEntry> findByExpirationDate(Date expirationDate,
1923 int start, int end, OrderByComparator orderByComparator)
1924 throws SystemException {
1925 FinderPath finderPath = null;
1926 Object[] finderArgs = null;
1927
1928 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1929 (orderByComparator == null)) {
1930 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_EXPIRATIONDATE;
1931 finderArgs = new Object[] { expirationDate };
1932 }
1933 else {
1934 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_EXPIRATIONDATE;
1935 finderArgs = new Object[] {
1936 expirationDate,
1937
1938 start, end, orderByComparator
1939 };
1940 }
1941
1942 List<AssetEntry> list = (List<AssetEntry>)FinderCacheUtil.getResult(finderPath,
1943 finderArgs, this);
1944
1945 if ((list != null) && !list.isEmpty()) {
1946 for (AssetEntry assetEntry : list) {
1947 if (!Validator.equals(expirationDate,
1948 assetEntry.getExpirationDate())) {
1949 list = null;
1950
1951 break;
1952 }
1953 }
1954 }
1955
1956 if (list == null) {
1957 StringBundler query = null;
1958
1959 if (orderByComparator != null) {
1960 query = new StringBundler(3 +
1961 (orderByComparator.getOrderByFields().length * 3));
1962 }
1963 else {
1964 query = new StringBundler(2);
1965 }
1966
1967 query.append(_SQL_SELECT_ASSETENTRY_WHERE);
1968
1969 if (expirationDate == null) {
1970 query.append(_FINDER_COLUMN_EXPIRATIONDATE_EXPIRATIONDATE_1);
1971 }
1972 else {
1973 query.append(_FINDER_COLUMN_EXPIRATIONDATE_EXPIRATIONDATE_2);
1974 }
1975
1976 if (orderByComparator != null) {
1977 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1978 orderByComparator);
1979 }
1980
1981 String sql = query.toString();
1982
1983 Session session = null;
1984
1985 try {
1986 session = openSession();
1987
1988 Query q = session.createQuery(sql);
1989
1990 QueryPos qPos = QueryPos.getInstance(q);
1991
1992 if (expirationDate != null) {
1993 qPos.add(CalendarUtil.getTimestamp(expirationDate));
1994 }
1995
1996 list = (List<AssetEntry>)QueryUtil.list(q, getDialect(), start,
1997 end);
1998 }
1999 catch (Exception e) {
2000 throw processException(e);
2001 }
2002 finally {
2003 if (list == null) {
2004 FinderCacheUtil.removeResult(finderPath, finderArgs);
2005 }
2006 else {
2007 cacheResult(list);
2008
2009 FinderCacheUtil.putResult(finderPath, finderArgs, list);
2010 }
2011
2012 closeSession(session);
2013 }
2014 }
2015
2016 return list;
2017 }
2018
2019
2028 public AssetEntry findByExpirationDate_First(Date expirationDate,
2029 OrderByComparator orderByComparator)
2030 throws NoSuchEntryException, SystemException {
2031 AssetEntry assetEntry = fetchByExpirationDate_First(expirationDate,
2032 orderByComparator);
2033
2034 if (assetEntry != null) {
2035 return assetEntry;
2036 }
2037
2038 StringBundler msg = new StringBundler(4);
2039
2040 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2041
2042 msg.append("expirationDate=");
2043 msg.append(expirationDate);
2044
2045 msg.append(StringPool.CLOSE_CURLY_BRACE);
2046
2047 throw new NoSuchEntryException(msg.toString());
2048 }
2049
2050
2058 public AssetEntry fetchByExpirationDate_First(Date expirationDate,
2059 OrderByComparator orderByComparator) throws SystemException {
2060 List<AssetEntry> list = findByExpirationDate(expirationDate, 0, 1,
2061 orderByComparator);
2062
2063 if (!list.isEmpty()) {
2064 return list.get(0);
2065 }
2066
2067 return null;
2068 }
2069
2070
2079 public AssetEntry findByExpirationDate_Last(Date expirationDate,
2080 OrderByComparator orderByComparator)
2081 throws NoSuchEntryException, SystemException {
2082 AssetEntry assetEntry = fetchByExpirationDate_Last(expirationDate,
2083 orderByComparator);
2084
2085 if (assetEntry != null) {
2086 return assetEntry;
2087 }
2088
2089 StringBundler msg = new StringBundler(4);
2090
2091 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2092
2093 msg.append("expirationDate=");
2094 msg.append(expirationDate);
2095
2096 msg.append(StringPool.CLOSE_CURLY_BRACE);
2097
2098 throw new NoSuchEntryException(msg.toString());
2099 }
2100
2101
2109 public AssetEntry fetchByExpirationDate_Last(Date expirationDate,
2110 OrderByComparator orderByComparator) throws SystemException {
2111 int count = countByExpirationDate(expirationDate);
2112
2113 List<AssetEntry> list = findByExpirationDate(expirationDate, count - 1,
2114 count, orderByComparator);
2115
2116 if (!list.isEmpty()) {
2117 return list.get(0);
2118 }
2119
2120 return null;
2121 }
2122
2123
2133 public AssetEntry[] findByExpirationDate_PrevAndNext(long entryId,
2134 Date expirationDate, OrderByComparator orderByComparator)
2135 throws NoSuchEntryException, SystemException {
2136 AssetEntry assetEntry = findByPrimaryKey(entryId);
2137
2138 Session session = null;
2139
2140 try {
2141 session = openSession();
2142
2143 AssetEntry[] array = new AssetEntryImpl[3];
2144
2145 array[0] = getByExpirationDate_PrevAndNext(session, assetEntry,
2146 expirationDate, orderByComparator, true);
2147
2148 array[1] = assetEntry;
2149
2150 array[2] = getByExpirationDate_PrevAndNext(session, assetEntry,
2151 expirationDate, orderByComparator, false);
2152
2153 return array;
2154 }
2155 catch (Exception e) {
2156 throw processException(e);
2157 }
2158 finally {
2159 closeSession(session);
2160 }
2161 }
2162
2163 protected AssetEntry getByExpirationDate_PrevAndNext(Session session,
2164 AssetEntry assetEntry, Date expirationDate,
2165 OrderByComparator orderByComparator, boolean previous) {
2166 StringBundler query = null;
2167
2168 if (orderByComparator != null) {
2169 query = new StringBundler(6 +
2170 (orderByComparator.getOrderByFields().length * 6));
2171 }
2172 else {
2173 query = new StringBundler(3);
2174 }
2175
2176 query.append(_SQL_SELECT_ASSETENTRY_WHERE);
2177
2178 if (expirationDate == null) {
2179 query.append(_FINDER_COLUMN_EXPIRATIONDATE_EXPIRATIONDATE_1);
2180 }
2181 else {
2182 query.append(_FINDER_COLUMN_EXPIRATIONDATE_EXPIRATIONDATE_2);
2183 }
2184
2185 if (orderByComparator != null) {
2186 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2187
2188 if (orderByConditionFields.length > 0) {
2189 query.append(WHERE_AND);
2190 }
2191
2192 for (int i = 0; i < orderByConditionFields.length; i++) {
2193 query.append(_ORDER_BY_ENTITY_ALIAS);
2194 query.append(orderByConditionFields[i]);
2195
2196 if ((i + 1) < orderByConditionFields.length) {
2197 if (orderByComparator.isAscending() ^ previous) {
2198 query.append(WHERE_GREATER_THAN_HAS_NEXT);
2199 }
2200 else {
2201 query.append(WHERE_LESSER_THAN_HAS_NEXT);
2202 }
2203 }
2204 else {
2205 if (orderByComparator.isAscending() ^ previous) {
2206 query.append(WHERE_GREATER_THAN);
2207 }
2208 else {
2209 query.append(WHERE_LESSER_THAN);
2210 }
2211 }
2212 }
2213
2214 query.append(ORDER_BY_CLAUSE);
2215
2216 String[] orderByFields = orderByComparator.getOrderByFields();
2217
2218 for (int i = 0; i < orderByFields.length; i++) {
2219 query.append(_ORDER_BY_ENTITY_ALIAS);
2220 query.append(orderByFields[i]);
2221
2222 if ((i + 1) < orderByFields.length) {
2223 if (orderByComparator.isAscending() ^ previous) {
2224 query.append(ORDER_BY_ASC_HAS_NEXT);
2225 }
2226 else {
2227 query.append(ORDER_BY_DESC_HAS_NEXT);
2228 }
2229 }
2230 else {
2231 if (orderByComparator.isAscending() ^ previous) {
2232 query.append(ORDER_BY_ASC);
2233 }
2234 else {
2235 query.append(ORDER_BY_DESC);
2236 }
2237 }
2238 }
2239 }
2240
2241 String sql = query.toString();
2242
2243 Query q = session.createQuery(sql);
2244
2245 q.setFirstResult(0);
2246 q.setMaxResults(2);
2247
2248 QueryPos qPos = QueryPos.getInstance(q);
2249
2250 if (expirationDate != null) {
2251 qPos.add(CalendarUtil.getTimestamp(expirationDate));
2252 }
2253
2254 if (orderByComparator != null) {
2255 Object[] values = orderByComparator.getOrderByConditionValues(assetEntry);
2256
2257 for (Object value : values) {
2258 qPos.add(value);
2259 }
2260 }
2261
2262 List<AssetEntry> list = q.list();
2263
2264 if (list.size() == 2) {
2265 return list.get(1);
2266 }
2267 else {
2268 return null;
2269 }
2270 }
2271
2272
2281 public AssetEntry findByG_CU(long groupId, String classUuid)
2282 throws NoSuchEntryException, SystemException {
2283 AssetEntry assetEntry = fetchByG_CU(groupId, classUuid);
2284
2285 if (assetEntry == null) {
2286 StringBundler msg = new StringBundler(6);
2287
2288 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2289
2290 msg.append("groupId=");
2291 msg.append(groupId);
2292
2293 msg.append(", classUuid=");
2294 msg.append(classUuid);
2295
2296 msg.append(StringPool.CLOSE_CURLY_BRACE);
2297
2298 if (_log.isWarnEnabled()) {
2299 _log.warn(msg.toString());
2300 }
2301
2302 throw new NoSuchEntryException(msg.toString());
2303 }
2304
2305 return assetEntry;
2306 }
2307
2308
2316 public AssetEntry fetchByG_CU(long groupId, String classUuid)
2317 throws SystemException {
2318 return fetchByG_CU(groupId, classUuid, true);
2319 }
2320
2321
2330 public AssetEntry fetchByG_CU(long groupId, String classUuid,
2331 boolean retrieveFromCache) throws SystemException {
2332 Object[] finderArgs = new Object[] { groupId, classUuid };
2333
2334 Object result = null;
2335
2336 if (retrieveFromCache) {
2337 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_G_CU,
2338 finderArgs, this);
2339 }
2340
2341 if (result instanceof AssetEntry) {
2342 AssetEntry assetEntry = (AssetEntry)result;
2343
2344 if ((groupId != assetEntry.getGroupId()) ||
2345 !Validator.equals(classUuid, assetEntry.getClassUuid())) {
2346 result = null;
2347 }
2348 }
2349
2350 if (result == null) {
2351 StringBundler query = new StringBundler(3);
2352
2353 query.append(_SQL_SELECT_ASSETENTRY_WHERE);
2354
2355 query.append(_FINDER_COLUMN_G_CU_GROUPID_2);
2356
2357 if (classUuid == null) {
2358 query.append(_FINDER_COLUMN_G_CU_CLASSUUID_1);
2359 }
2360 else {
2361 if (classUuid.equals(StringPool.BLANK)) {
2362 query.append(_FINDER_COLUMN_G_CU_CLASSUUID_3);
2363 }
2364 else {
2365 query.append(_FINDER_COLUMN_G_CU_CLASSUUID_2);
2366 }
2367 }
2368
2369 String sql = query.toString();
2370
2371 Session session = null;
2372
2373 try {
2374 session = openSession();
2375
2376 Query q = session.createQuery(sql);
2377
2378 QueryPos qPos = QueryPos.getInstance(q);
2379
2380 qPos.add(groupId);
2381
2382 if (classUuid != null) {
2383 qPos.add(classUuid);
2384 }
2385
2386 List<AssetEntry> list = q.list();
2387
2388 result = list;
2389
2390 AssetEntry assetEntry = null;
2391
2392 if (list.isEmpty()) {
2393 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_CU,
2394 finderArgs, list);
2395 }
2396 else {
2397 assetEntry = list.get(0);
2398
2399 cacheResult(assetEntry);
2400
2401 if ((assetEntry.getGroupId() != groupId) ||
2402 (assetEntry.getClassUuid() == null) ||
2403 !assetEntry.getClassUuid().equals(classUuid)) {
2404 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_CU,
2405 finderArgs, assetEntry);
2406 }
2407 }
2408
2409 return assetEntry;
2410 }
2411 catch (Exception e) {
2412 throw processException(e);
2413 }
2414 finally {
2415 if (result == null) {
2416 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_CU,
2417 finderArgs);
2418 }
2419
2420 closeSession(session);
2421 }
2422 }
2423 else {
2424 if (result instanceof List<?>) {
2425 return null;
2426 }
2427 else {
2428 return (AssetEntry)result;
2429 }
2430 }
2431 }
2432
2433
2442 public AssetEntry findByC_C(long classNameId, long classPK)
2443 throws NoSuchEntryException, SystemException {
2444 AssetEntry assetEntry = fetchByC_C(classNameId, classPK);
2445
2446 if (assetEntry == null) {
2447 StringBundler msg = new StringBundler(6);
2448
2449 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2450
2451 msg.append("classNameId=");
2452 msg.append(classNameId);
2453
2454 msg.append(", classPK=");
2455 msg.append(classPK);
2456
2457 msg.append(StringPool.CLOSE_CURLY_BRACE);
2458
2459 if (_log.isWarnEnabled()) {
2460 _log.warn(msg.toString());
2461 }
2462
2463 throw new NoSuchEntryException(msg.toString());
2464 }
2465
2466 return assetEntry;
2467 }
2468
2469
2477 public AssetEntry fetchByC_C(long classNameId, long classPK)
2478 throws SystemException {
2479 return fetchByC_C(classNameId, classPK, true);
2480 }
2481
2482
2491 public AssetEntry fetchByC_C(long classNameId, long classPK,
2492 boolean retrieveFromCache) throws SystemException {
2493 Object[] finderArgs = new Object[] { classNameId, classPK };
2494
2495 Object result = null;
2496
2497 if (retrieveFromCache) {
2498 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_C_C,
2499 finderArgs, this);
2500 }
2501
2502 if (result instanceof AssetEntry) {
2503 AssetEntry assetEntry = (AssetEntry)result;
2504
2505 if ((classNameId != assetEntry.getClassNameId()) ||
2506 (classPK != assetEntry.getClassPK())) {
2507 result = null;
2508 }
2509 }
2510
2511 if (result == null) {
2512 StringBundler query = new StringBundler(3);
2513
2514 query.append(_SQL_SELECT_ASSETENTRY_WHERE);
2515
2516 query.append(_FINDER_COLUMN_C_C_CLASSNAMEID_2);
2517
2518 query.append(_FINDER_COLUMN_C_C_CLASSPK_2);
2519
2520 String sql = query.toString();
2521
2522 Session session = null;
2523
2524 try {
2525 session = openSession();
2526
2527 Query q = session.createQuery(sql);
2528
2529 QueryPos qPos = QueryPos.getInstance(q);
2530
2531 qPos.add(classNameId);
2532
2533 qPos.add(classPK);
2534
2535 List<AssetEntry> list = q.list();
2536
2537 result = list;
2538
2539 AssetEntry assetEntry = null;
2540
2541 if (list.isEmpty()) {
2542 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C,
2543 finderArgs, list);
2544 }
2545 else {
2546 assetEntry = list.get(0);
2547
2548 cacheResult(assetEntry);
2549
2550 if ((assetEntry.getClassNameId() != classNameId) ||
2551 (assetEntry.getClassPK() != classPK)) {
2552 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C,
2553 finderArgs, assetEntry);
2554 }
2555 }
2556
2557 return assetEntry;
2558 }
2559 catch (Exception e) {
2560 throw processException(e);
2561 }
2562 finally {
2563 if (result == null) {
2564 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_C,
2565 finderArgs);
2566 }
2567
2568 closeSession(session);
2569 }
2570 }
2571 else {
2572 if (result instanceof List<?>) {
2573 return null;
2574 }
2575 else {
2576 return (AssetEntry)result;
2577 }
2578 }
2579 }
2580
2581
2587 public List<AssetEntry> findAll() throws SystemException {
2588 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
2589 }
2590
2591
2603 public List<AssetEntry> findAll(int start, int end)
2604 throws SystemException {
2605 return findAll(start, end, null);
2606 }
2607
2608
2621 public List<AssetEntry> findAll(int start, int end,
2622 OrderByComparator orderByComparator) throws SystemException {
2623 FinderPath finderPath = null;
2624 Object[] finderArgs = new Object[] { start, end, orderByComparator };
2625
2626 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2627 (orderByComparator == null)) {
2628 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
2629 finderArgs = FINDER_ARGS_EMPTY;
2630 }
2631 else {
2632 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
2633 finderArgs = new Object[] { start, end, orderByComparator };
2634 }
2635
2636 List<AssetEntry> list = (List<AssetEntry>)FinderCacheUtil.getResult(finderPath,
2637 finderArgs, this);
2638
2639 if (list == null) {
2640 StringBundler query = null;
2641 String sql = null;
2642
2643 if (orderByComparator != null) {
2644 query = new StringBundler(2 +
2645 (orderByComparator.getOrderByFields().length * 3));
2646
2647 query.append(_SQL_SELECT_ASSETENTRY);
2648
2649 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2650 orderByComparator);
2651
2652 sql = query.toString();
2653 }
2654 else {
2655 sql = _SQL_SELECT_ASSETENTRY;
2656 }
2657
2658 Session session = null;
2659
2660 try {
2661 session = openSession();
2662
2663 Query q = session.createQuery(sql);
2664
2665 if (orderByComparator == null) {
2666 list = (List<AssetEntry>)QueryUtil.list(q, getDialect(),
2667 start, end, false);
2668
2669 Collections.sort(list);
2670 }
2671 else {
2672 list = (List<AssetEntry>)QueryUtil.list(q, getDialect(),
2673 start, end);
2674 }
2675 }
2676 catch (Exception e) {
2677 throw processException(e);
2678 }
2679 finally {
2680 if (list == null) {
2681 FinderCacheUtil.removeResult(finderPath, finderArgs);
2682 }
2683 else {
2684 cacheResult(list);
2685
2686 FinderCacheUtil.putResult(finderPath, finderArgs, list);
2687 }
2688
2689 closeSession(session);
2690 }
2691 }
2692
2693 return list;
2694 }
2695
2696
2702 public void removeByCompanyId(long companyId) throws SystemException {
2703 for (AssetEntry assetEntry : findByCompanyId(companyId)) {
2704 remove(assetEntry);
2705 }
2706 }
2707
2708
2714 public void removeByVisible(boolean visible) throws SystemException {
2715 for (AssetEntry assetEntry : findByVisible(visible)) {
2716 remove(assetEntry);
2717 }
2718 }
2719
2720
2726 public void removeByPublishDate(Date publishDate) throws SystemException {
2727 for (AssetEntry assetEntry : findByPublishDate(publishDate)) {
2728 remove(assetEntry);
2729 }
2730 }
2731
2732
2738 public void removeByExpirationDate(Date expirationDate)
2739 throws SystemException {
2740 for (AssetEntry assetEntry : findByExpirationDate(expirationDate)) {
2741 remove(assetEntry);
2742 }
2743 }
2744
2745
2753 public AssetEntry removeByG_CU(long groupId, String classUuid)
2754 throws NoSuchEntryException, SystemException {
2755 AssetEntry assetEntry = findByG_CU(groupId, classUuid);
2756
2757 return remove(assetEntry);
2758 }
2759
2760
2768 public AssetEntry removeByC_C(long classNameId, long classPK)
2769 throws NoSuchEntryException, SystemException {
2770 AssetEntry assetEntry = findByC_C(classNameId, classPK);
2771
2772 return remove(assetEntry);
2773 }
2774
2775
2780 public void removeAll() throws SystemException {
2781 for (AssetEntry assetEntry : findAll()) {
2782 remove(assetEntry);
2783 }
2784 }
2785
2786
2793 public int countByCompanyId(long companyId) throws SystemException {
2794 Object[] finderArgs = new Object[] { companyId };
2795
2796 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_COMPANYID,
2797 finderArgs, this);
2798
2799 if (count == null) {
2800 StringBundler query = new StringBundler(2);
2801
2802 query.append(_SQL_COUNT_ASSETENTRY_WHERE);
2803
2804 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
2805
2806 String sql = query.toString();
2807
2808 Session session = null;
2809
2810 try {
2811 session = openSession();
2812
2813 Query q = session.createQuery(sql);
2814
2815 QueryPos qPos = QueryPos.getInstance(q);
2816
2817 qPos.add(companyId);
2818
2819 count = (Long)q.uniqueResult();
2820 }
2821 catch (Exception e) {
2822 throw processException(e);
2823 }
2824 finally {
2825 if (count == null) {
2826 count = Long.valueOf(0);
2827 }
2828
2829 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_COMPANYID,
2830 finderArgs, count);
2831
2832 closeSession(session);
2833 }
2834 }
2835
2836 return count.intValue();
2837 }
2838
2839
2846 public int countByVisible(boolean visible) throws SystemException {
2847 Object[] finderArgs = new Object[] { visible };
2848
2849 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_VISIBLE,
2850 finderArgs, this);
2851
2852 if (count == null) {
2853 StringBundler query = new StringBundler(2);
2854
2855 query.append(_SQL_COUNT_ASSETENTRY_WHERE);
2856
2857 query.append(_FINDER_COLUMN_VISIBLE_VISIBLE_2);
2858
2859 String sql = query.toString();
2860
2861 Session session = null;
2862
2863 try {
2864 session = openSession();
2865
2866 Query q = session.createQuery(sql);
2867
2868 QueryPos qPos = QueryPos.getInstance(q);
2869
2870 qPos.add(visible);
2871
2872 count = (Long)q.uniqueResult();
2873 }
2874 catch (Exception e) {
2875 throw processException(e);
2876 }
2877 finally {
2878 if (count == null) {
2879 count = Long.valueOf(0);
2880 }
2881
2882 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_VISIBLE,
2883 finderArgs, count);
2884
2885 closeSession(session);
2886 }
2887 }
2888
2889 return count.intValue();
2890 }
2891
2892
2899 public int countByPublishDate(Date publishDate) throws SystemException {
2900 Object[] finderArgs = new Object[] { publishDate };
2901
2902 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_PUBLISHDATE,
2903 finderArgs, this);
2904
2905 if (count == null) {
2906 StringBundler query = new StringBundler(2);
2907
2908 query.append(_SQL_COUNT_ASSETENTRY_WHERE);
2909
2910 if (publishDate == null) {
2911 query.append(_FINDER_COLUMN_PUBLISHDATE_PUBLISHDATE_1);
2912 }
2913 else {
2914 query.append(_FINDER_COLUMN_PUBLISHDATE_PUBLISHDATE_2);
2915 }
2916
2917 String sql = query.toString();
2918
2919 Session session = null;
2920
2921 try {
2922 session = openSession();
2923
2924 Query q = session.createQuery(sql);
2925
2926 QueryPos qPos = QueryPos.getInstance(q);
2927
2928 if (publishDate != null) {
2929 qPos.add(CalendarUtil.getTimestamp(publishDate));
2930 }
2931
2932 count = (Long)q.uniqueResult();
2933 }
2934 catch (Exception e) {
2935 throw processException(e);
2936 }
2937 finally {
2938 if (count == null) {
2939 count = Long.valueOf(0);
2940 }
2941
2942 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_PUBLISHDATE,
2943 finderArgs, count);
2944
2945 closeSession(session);
2946 }
2947 }
2948
2949 return count.intValue();
2950 }
2951
2952
2959 public int countByExpirationDate(Date expirationDate)
2960 throws SystemException {
2961 Object[] finderArgs = new Object[] { expirationDate };
2962
2963 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_EXPIRATIONDATE,
2964 finderArgs, this);
2965
2966 if (count == null) {
2967 StringBundler query = new StringBundler(2);
2968
2969 query.append(_SQL_COUNT_ASSETENTRY_WHERE);
2970
2971 if (expirationDate == null) {
2972 query.append(_FINDER_COLUMN_EXPIRATIONDATE_EXPIRATIONDATE_1);
2973 }
2974 else {
2975 query.append(_FINDER_COLUMN_EXPIRATIONDATE_EXPIRATIONDATE_2);
2976 }
2977
2978 String sql = query.toString();
2979
2980 Session session = null;
2981
2982 try {
2983 session = openSession();
2984
2985 Query q = session.createQuery(sql);
2986
2987 QueryPos qPos = QueryPos.getInstance(q);
2988
2989 if (expirationDate != null) {
2990 qPos.add(CalendarUtil.getTimestamp(expirationDate));
2991 }
2992
2993 count = (Long)q.uniqueResult();
2994 }
2995 catch (Exception e) {
2996 throw processException(e);
2997 }
2998 finally {
2999 if (count == null) {
3000 count = Long.valueOf(0);
3001 }
3002
3003 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_EXPIRATIONDATE,
3004 finderArgs, count);
3005
3006 closeSession(session);
3007 }
3008 }
3009
3010 return count.intValue();
3011 }
3012
3013
3021 public int countByG_CU(long groupId, String classUuid)
3022 throws SystemException {
3023 Object[] finderArgs = new Object[] { groupId, classUuid };
3024
3025 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_CU,
3026 finderArgs, this);
3027
3028 if (count == null) {
3029 StringBundler query = new StringBundler(3);
3030
3031 query.append(_SQL_COUNT_ASSETENTRY_WHERE);
3032
3033 query.append(_FINDER_COLUMN_G_CU_GROUPID_2);
3034
3035 if (classUuid == null) {
3036 query.append(_FINDER_COLUMN_G_CU_CLASSUUID_1);
3037 }
3038 else {
3039 if (classUuid.equals(StringPool.BLANK)) {
3040 query.append(_FINDER_COLUMN_G_CU_CLASSUUID_3);
3041 }
3042 else {
3043 query.append(_FINDER_COLUMN_G_CU_CLASSUUID_2);
3044 }
3045 }
3046
3047 String sql = query.toString();
3048
3049 Session session = null;
3050
3051 try {
3052 session = openSession();
3053
3054 Query q = session.createQuery(sql);
3055
3056 QueryPos qPos = QueryPos.getInstance(q);
3057
3058 qPos.add(groupId);
3059
3060 if (classUuid != null) {
3061 qPos.add(classUuid);
3062 }
3063
3064 count = (Long)q.uniqueResult();
3065 }
3066 catch (Exception e) {
3067 throw processException(e);
3068 }
3069 finally {
3070 if (count == null) {
3071 count = Long.valueOf(0);
3072 }
3073
3074 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_CU,
3075 finderArgs, count);
3076
3077 closeSession(session);
3078 }
3079 }
3080
3081 return count.intValue();
3082 }
3083
3084
3092 public int countByC_C(long classNameId, long classPK)
3093 throws SystemException {
3094 Object[] finderArgs = new Object[] { classNameId, classPK };
3095
3096 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_C,
3097 finderArgs, this);
3098
3099 if (count == null) {
3100 StringBundler query = new StringBundler(3);
3101
3102 query.append(_SQL_COUNT_ASSETENTRY_WHERE);
3103
3104 query.append(_FINDER_COLUMN_C_C_CLASSNAMEID_2);
3105
3106 query.append(_FINDER_COLUMN_C_C_CLASSPK_2);
3107
3108 String sql = query.toString();
3109
3110 Session session = null;
3111
3112 try {
3113 session = openSession();
3114
3115 Query q = session.createQuery(sql);
3116
3117 QueryPos qPos = QueryPos.getInstance(q);
3118
3119 qPos.add(classNameId);
3120
3121 qPos.add(classPK);
3122
3123 count = (Long)q.uniqueResult();
3124 }
3125 catch (Exception e) {
3126 throw processException(e);
3127 }
3128 finally {
3129 if (count == null) {
3130 count = Long.valueOf(0);
3131 }
3132
3133 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_C, finderArgs,
3134 count);
3135
3136 closeSession(session);
3137 }
3138 }
3139
3140 return count.intValue();
3141 }
3142
3143
3149 public int countAll() throws SystemException {
3150 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
3151 FINDER_ARGS_EMPTY, this);
3152
3153 if (count == null) {
3154 Session session = null;
3155
3156 try {
3157 session = openSession();
3158
3159 Query q = session.createQuery(_SQL_COUNT_ASSETENTRY);
3160
3161 count = (Long)q.uniqueResult();
3162 }
3163 catch (Exception e) {
3164 throw processException(e);
3165 }
3166 finally {
3167 if (count == null) {
3168 count = Long.valueOf(0);
3169 }
3170
3171 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
3172 FINDER_ARGS_EMPTY, count);
3173
3174 closeSession(session);
3175 }
3176 }
3177
3178 return count.intValue();
3179 }
3180
3181
3188 public List<com.liferay.portlet.asset.model.AssetCategory> getAssetCategories(
3189 long pk) throws SystemException {
3190 return getAssetCategories(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
3191 }
3192
3193
3206 public List<com.liferay.portlet.asset.model.AssetCategory> getAssetCategories(
3207 long pk, int start, int end) throws SystemException {
3208 return getAssetCategories(pk, start, end, null);
3209 }
3210
3211 public static final FinderPath FINDER_PATH_GET_ASSETCATEGORIES = new FinderPath(com.liferay.portlet.asset.model.impl.AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
3212 AssetEntryModelImpl.FINDER_CACHE_ENABLED_ASSETENTRIES_ASSETCATEGORIES,
3213 com.liferay.portlet.asset.model.impl.AssetCategoryImpl.class,
3214 AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME,
3215 "getAssetCategories",
3216 new String[] {
3217 Long.class.getName(), "java.lang.Integer", "java.lang.Integer",
3218 "com.liferay.portal.kernel.util.OrderByComparator"
3219 });
3220
3221 static {
3222 FINDER_PATH_GET_ASSETCATEGORIES.setCacheKeyGeneratorCacheName(null);
3223 }
3224
3225
3239 public List<com.liferay.portlet.asset.model.AssetCategory> getAssetCategories(
3240 long pk, int start, int end, OrderByComparator orderByComparator)
3241 throws SystemException {
3242 Object[] finderArgs = new Object[] { pk, start, end, orderByComparator };
3243
3244 List<com.liferay.portlet.asset.model.AssetCategory> list = (List<com.liferay.portlet.asset.model.AssetCategory>)FinderCacheUtil.getResult(FINDER_PATH_GET_ASSETCATEGORIES,
3245 finderArgs, this);
3246
3247 if (list == null) {
3248 Session session = null;
3249
3250 try {
3251 session = openSession();
3252
3253 String sql = null;
3254
3255 if (orderByComparator != null) {
3256 sql = _SQL_GETASSETCATEGORIES.concat(ORDER_BY_CLAUSE)
3257 .concat(orderByComparator.getOrderBy());
3258 }
3259 else {
3260 sql = _SQL_GETASSETCATEGORIES.concat(com.liferay.portlet.asset.model.impl.AssetCategoryModelImpl.ORDER_BY_SQL);
3261 }
3262
3263 SQLQuery q = session.createSQLQuery(sql);
3264
3265 q.addEntity("AssetCategory",
3266 com.liferay.portlet.asset.model.impl.AssetCategoryImpl.class);
3267
3268 QueryPos qPos = QueryPos.getInstance(q);
3269
3270 qPos.add(pk);
3271
3272 list = (List<com.liferay.portlet.asset.model.AssetCategory>)QueryUtil.list(q,
3273 getDialect(), start, end);
3274 }
3275 catch (Exception e) {
3276 throw processException(e);
3277 }
3278 finally {
3279 if (list == null) {
3280 FinderCacheUtil.removeResult(FINDER_PATH_GET_ASSETCATEGORIES,
3281 finderArgs);
3282 }
3283 else {
3284 assetCategoryPersistence.cacheResult(list);
3285
3286 FinderCacheUtil.putResult(FINDER_PATH_GET_ASSETCATEGORIES,
3287 finderArgs, list);
3288 }
3289
3290 closeSession(session);
3291 }
3292 }
3293
3294 return list;
3295 }
3296
3297 public static final FinderPath FINDER_PATH_GET_ASSETCATEGORIES_SIZE = new FinderPath(com.liferay.portlet.asset.model.impl.AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
3298 AssetEntryModelImpl.FINDER_CACHE_ENABLED_ASSETENTRIES_ASSETCATEGORIES,
3299 Long.class,
3300 AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME,
3301 "getAssetCategoriesSize", new String[] { Long.class.getName() });
3302
3303 static {
3304 FINDER_PATH_GET_ASSETCATEGORIES_SIZE.setCacheKeyGeneratorCacheName(null);
3305 }
3306
3307
3314 public int getAssetCategoriesSize(long pk) throws SystemException {
3315 Object[] finderArgs = new Object[] { pk };
3316
3317 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_GET_ASSETCATEGORIES_SIZE,
3318 finderArgs, this);
3319
3320 if (count == null) {
3321 Session session = null;
3322
3323 try {
3324 session = openSession();
3325
3326 SQLQuery q = session.createSQLQuery(_SQL_GETASSETCATEGORIESSIZE);
3327
3328 q.addScalar(COUNT_COLUMN_NAME,
3329 com.liferay.portal.kernel.dao.orm.Type.LONG);
3330
3331 QueryPos qPos = QueryPos.getInstance(q);
3332
3333 qPos.add(pk);
3334
3335 count = (Long)q.uniqueResult();
3336 }
3337 catch (Exception e) {
3338 throw processException(e);
3339 }
3340 finally {
3341 if (count == null) {
3342 count = Long.valueOf(0);
3343 }
3344
3345 FinderCacheUtil.putResult(FINDER_PATH_GET_ASSETCATEGORIES_SIZE,
3346 finderArgs, count);
3347
3348 closeSession(session);
3349 }
3350 }
3351
3352 return count.intValue();
3353 }
3354
3355 public static final FinderPath FINDER_PATH_CONTAINS_ASSETCATEGORY = new FinderPath(com.liferay.portlet.asset.model.impl.AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
3356 AssetEntryModelImpl.FINDER_CACHE_ENABLED_ASSETENTRIES_ASSETCATEGORIES,
3357 Boolean.class,
3358 AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME,
3359 "containsAssetCategory",
3360 new String[] { Long.class.getName(), Long.class.getName() });
3361
3362
3370 public boolean containsAssetCategory(long pk, long assetCategoryPK)
3371 throws SystemException {
3372 Object[] finderArgs = new Object[] { pk, assetCategoryPK };
3373
3374 Boolean value = (Boolean)FinderCacheUtil.getResult(FINDER_PATH_CONTAINS_ASSETCATEGORY,
3375 finderArgs, this);
3376
3377 if (value == null) {
3378 try {
3379 value = Boolean.valueOf(containsAssetCategory.contains(pk,
3380 assetCategoryPK));
3381 }
3382 catch (Exception e) {
3383 throw processException(e);
3384 }
3385 finally {
3386 if (value == null) {
3387 value = Boolean.FALSE;
3388 }
3389
3390 FinderCacheUtil.putResult(FINDER_PATH_CONTAINS_ASSETCATEGORY,
3391 finderArgs, value);
3392 }
3393 }
3394
3395 return value.booleanValue();
3396 }
3397
3398
3405 public boolean containsAssetCategories(long pk) throws SystemException {
3406 if (getAssetCategoriesSize(pk) > 0) {
3407 return true;
3408 }
3409 else {
3410 return false;
3411 }
3412 }
3413
3414
3421 public void addAssetCategory(long pk, long assetCategoryPK)
3422 throws SystemException {
3423 try {
3424 addAssetCategory.add(pk, assetCategoryPK);
3425 }
3426 catch (Exception e) {
3427 throw processException(e);
3428 }
3429 finally {
3430 FinderCacheUtil.clearCache(AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
3431 }
3432 }
3433
3434
3441 public void addAssetCategory(long pk,
3442 com.liferay.portlet.asset.model.AssetCategory assetCategory)
3443 throws SystemException {
3444 try {
3445 addAssetCategory.add(pk, assetCategory.getPrimaryKey());
3446 }
3447 catch (Exception e) {
3448 throw processException(e);
3449 }
3450 finally {
3451 FinderCacheUtil.clearCache(AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
3452 }
3453 }
3454
3455
3462 public void addAssetCategories(long pk, long[] assetCategoryPKs)
3463 throws SystemException {
3464 try {
3465 for (long assetCategoryPK : assetCategoryPKs) {
3466 addAssetCategory.add(pk, assetCategoryPK);
3467 }
3468 }
3469 catch (Exception e) {
3470 throw processException(e);
3471 }
3472 finally {
3473 FinderCacheUtil.clearCache(AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
3474 }
3475 }
3476
3477
3484 public void addAssetCategories(long pk,
3485 List<com.liferay.portlet.asset.model.AssetCategory> assetCategories)
3486 throws SystemException {
3487 try {
3488 for (com.liferay.portlet.asset.model.AssetCategory assetCategory : assetCategories) {
3489 addAssetCategory.add(pk, assetCategory.getPrimaryKey());
3490 }
3491 }
3492 catch (Exception e) {
3493 throw processException(e);
3494 }
3495 finally {
3496 FinderCacheUtil.clearCache(AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
3497 }
3498 }
3499
3500
3506 public void clearAssetCategories(long pk) throws SystemException {
3507 try {
3508 clearAssetCategories.clear(pk);
3509 }
3510 catch (Exception e) {
3511 throw processException(e);
3512 }
3513 finally {
3514 FinderCacheUtil.clearCache(AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
3515 }
3516 }
3517
3518
3525 public void removeAssetCategory(long pk, long assetCategoryPK)
3526 throws SystemException {
3527 try {
3528 removeAssetCategory.remove(pk, assetCategoryPK);
3529 }
3530 catch (Exception e) {
3531 throw processException(e);
3532 }
3533 finally {
3534 FinderCacheUtil.clearCache(AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
3535 }
3536 }
3537
3538
3545 public void removeAssetCategory(long pk,
3546 com.liferay.portlet.asset.model.AssetCategory assetCategory)
3547 throws SystemException {
3548 try {
3549 removeAssetCategory.remove(pk, assetCategory.getPrimaryKey());
3550 }
3551 catch (Exception e) {
3552 throw processException(e);
3553 }
3554 finally {
3555 FinderCacheUtil.clearCache(AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
3556 }
3557 }
3558
3559
3566 public void removeAssetCategories(long pk, long[] assetCategoryPKs)
3567 throws SystemException {
3568 try {
3569 for (long assetCategoryPK : assetCategoryPKs) {
3570 removeAssetCategory.remove(pk, assetCategoryPK);
3571 }
3572 }
3573 catch (Exception e) {
3574 throw processException(e);
3575 }
3576 finally {
3577 FinderCacheUtil.clearCache(AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
3578 }
3579 }
3580
3581
3588 public void removeAssetCategories(long pk,
3589 List<com.liferay.portlet.asset.model.AssetCategory> assetCategories)
3590 throws SystemException {
3591 try {
3592 for (com.liferay.portlet.asset.model.AssetCategory assetCategory : assetCategories) {
3593 removeAssetCategory.remove(pk, assetCategory.getPrimaryKey());
3594 }
3595 }
3596 catch (Exception e) {
3597 throw processException(e);
3598 }
3599 finally {
3600 FinderCacheUtil.clearCache(AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
3601 }
3602 }
3603
3604
3611 public void setAssetCategories(long pk, long[] assetCategoryPKs)
3612 throws SystemException {
3613 try {
3614 Set<Long> assetCategoryPKSet = SetUtil.fromArray(assetCategoryPKs);
3615
3616 List<com.liferay.portlet.asset.model.AssetCategory> assetCategories = getAssetCategories(pk);
3617
3618 for (com.liferay.portlet.asset.model.AssetCategory assetCategory : assetCategories) {
3619 if (!assetCategoryPKSet.remove(assetCategory.getPrimaryKey())) {
3620 removeAssetCategory.remove(pk, assetCategory.getPrimaryKey());
3621 }
3622 }
3623
3624 for (Long assetCategoryPK : assetCategoryPKSet) {
3625 addAssetCategory.add(pk, assetCategoryPK);
3626 }
3627 }
3628 catch (Exception e) {
3629 throw processException(e);
3630 }
3631 finally {
3632 FinderCacheUtil.clearCache(AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
3633 }
3634 }
3635
3636
3643 public void setAssetCategories(long pk,
3644 List<com.liferay.portlet.asset.model.AssetCategory> assetCategories)
3645 throws SystemException {
3646 try {
3647 long[] assetCategoryPKs = new long[assetCategories.size()];
3648
3649 for (int i = 0; i < assetCategories.size(); i++) {
3650 com.liferay.portlet.asset.model.AssetCategory assetCategory = assetCategories.get(i);
3651
3652 assetCategoryPKs[i] = assetCategory.getPrimaryKey();
3653 }
3654
3655 setAssetCategories(pk, assetCategoryPKs);
3656 }
3657 catch (Exception e) {
3658 throw processException(e);
3659 }
3660 finally {
3661 FinderCacheUtil.clearCache(AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
3662 }
3663 }
3664
3665
3672 public List<com.liferay.portlet.asset.model.AssetTag> getAssetTags(long pk)
3673 throws SystemException {
3674 return getAssetTags(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
3675 }
3676
3677
3690 public List<com.liferay.portlet.asset.model.AssetTag> getAssetTags(
3691 long pk, int start, int end) throws SystemException {
3692 return getAssetTags(pk, start, end, null);
3693 }
3694
3695 public static final FinderPath FINDER_PATH_GET_ASSETTAGS = new FinderPath(com.liferay.portlet.asset.model.impl.AssetTagModelImpl.ENTITY_CACHE_ENABLED,
3696 AssetEntryModelImpl.FINDER_CACHE_ENABLED_ASSETENTRIES_ASSETTAGS,
3697 com.liferay.portlet.asset.model.impl.AssetTagImpl.class,
3698 AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETTAGS_NAME,
3699 "getAssetTags",
3700 new String[] {
3701 Long.class.getName(), "java.lang.Integer", "java.lang.Integer",
3702 "com.liferay.portal.kernel.util.OrderByComparator"
3703 });
3704
3705 static {
3706 FINDER_PATH_GET_ASSETTAGS.setCacheKeyGeneratorCacheName(null);
3707 }
3708
3709
3723 public List<com.liferay.portlet.asset.model.AssetTag> getAssetTags(
3724 long pk, int start, int end, OrderByComparator orderByComparator)
3725 throws SystemException {
3726 Object[] finderArgs = new Object[] { pk, start, end, orderByComparator };
3727
3728 List<com.liferay.portlet.asset.model.AssetTag> list = (List<com.liferay.portlet.asset.model.AssetTag>)FinderCacheUtil.getResult(FINDER_PATH_GET_ASSETTAGS,
3729 finderArgs, this);
3730
3731 if (list == null) {
3732 Session session = null;
3733
3734 try {
3735 session = openSession();
3736
3737 String sql = null;
3738
3739 if (orderByComparator != null) {
3740 sql = _SQL_GETASSETTAGS.concat(ORDER_BY_CLAUSE)
3741 .concat(orderByComparator.getOrderBy());
3742 }
3743 else {
3744 sql = _SQL_GETASSETTAGS.concat(com.liferay.portlet.asset.model.impl.AssetTagModelImpl.ORDER_BY_SQL);
3745 }
3746
3747 SQLQuery q = session.createSQLQuery(sql);
3748
3749 q.addEntity("AssetTag",
3750 com.liferay.portlet.asset.model.impl.AssetTagImpl.class);
3751
3752 QueryPos qPos = QueryPos.getInstance(q);
3753
3754 qPos.add(pk);
3755
3756 list = (List<com.liferay.portlet.asset.model.AssetTag>)QueryUtil.list(q,
3757 getDialect(), start, end);
3758 }
3759 catch (Exception e) {
3760 throw processException(e);
3761 }
3762 finally {
3763 if (list == null) {
3764 FinderCacheUtil.removeResult(FINDER_PATH_GET_ASSETTAGS,
3765 finderArgs);
3766 }
3767 else {
3768 assetTagPersistence.cacheResult(list);
3769
3770 FinderCacheUtil.putResult(FINDER_PATH_GET_ASSETTAGS,
3771 finderArgs, list);
3772 }
3773
3774 closeSession(session);
3775 }
3776 }
3777
3778 return list;
3779 }
3780
3781 public static final FinderPath FINDER_PATH_GET_ASSETTAGS_SIZE = new FinderPath(com.liferay.portlet.asset.model.impl.AssetTagModelImpl.ENTITY_CACHE_ENABLED,
3782 AssetEntryModelImpl.FINDER_CACHE_ENABLED_ASSETENTRIES_ASSETTAGS,
3783 Long.class,
3784 AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETTAGS_NAME,
3785 "getAssetTagsSize", new String[] { Long.class.getName() });
3786
3787 static {
3788 FINDER_PATH_GET_ASSETTAGS_SIZE.setCacheKeyGeneratorCacheName(null);
3789 }
3790
3791
3798 public int getAssetTagsSize(long pk) throws SystemException {
3799 Object[] finderArgs = new Object[] { pk };
3800
3801 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_GET_ASSETTAGS_SIZE,
3802 finderArgs, this);
3803
3804 if (count == null) {
3805 Session session = null;
3806
3807 try {
3808 session = openSession();
3809
3810 SQLQuery q = session.createSQLQuery(_SQL_GETASSETTAGSSIZE);
3811
3812 q.addScalar(COUNT_COLUMN_NAME,
3813 com.liferay.portal.kernel.dao.orm.Type.LONG);
3814
3815 QueryPos qPos = QueryPos.getInstance(q);
3816
3817 qPos.add(pk);
3818
3819 count = (Long)q.uniqueResult();
3820 }
3821 catch (Exception e) {
3822 throw processException(e);
3823 }
3824 finally {
3825 if (count == null) {
3826 count = Long.valueOf(0);
3827 }
3828
3829 FinderCacheUtil.putResult(FINDER_PATH_GET_ASSETTAGS_SIZE,
3830 finderArgs, count);
3831
3832 closeSession(session);
3833 }
3834 }
3835
3836 return count.intValue();
3837 }
3838
3839 public static final FinderPath FINDER_PATH_CONTAINS_ASSETTAG = new FinderPath(com.liferay.portlet.asset.model.impl.AssetTagModelImpl.ENTITY_CACHE_ENABLED,
3840 AssetEntryModelImpl.FINDER_CACHE_ENABLED_ASSETENTRIES_ASSETTAGS,
3841 Boolean.class,
3842 AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETTAGS_NAME,
3843 "containsAssetTag",
3844 new String[] { Long.class.getName(), Long.class.getName() });
3845
3846
3854 public boolean containsAssetTag(long pk, long assetTagPK)
3855 throws SystemException {
3856 Object[] finderArgs = new Object[] { pk, assetTagPK };
3857
3858 Boolean value = (Boolean)FinderCacheUtil.getResult(FINDER_PATH_CONTAINS_ASSETTAG,
3859 finderArgs, this);
3860
3861 if (value == null) {
3862 try {
3863 value = Boolean.valueOf(containsAssetTag.contains(pk, assetTagPK));
3864 }
3865 catch (Exception e) {
3866 throw processException(e);
3867 }
3868 finally {
3869 if (value == null) {
3870 value = Boolean.FALSE;
3871 }
3872
3873 FinderCacheUtil.putResult(FINDER_PATH_CONTAINS_ASSETTAG,
3874 finderArgs, value);
3875 }
3876 }
3877
3878 return value.booleanValue();
3879 }
3880
3881
3888 public boolean containsAssetTags(long pk) throws SystemException {
3889 if (getAssetTagsSize(pk) > 0) {
3890 return true;
3891 }
3892 else {
3893 return false;
3894 }
3895 }
3896
3897
3904 public void addAssetTag(long pk, long assetTagPK) throws SystemException {
3905 try {
3906 addAssetTag.add(pk, assetTagPK);
3907 }
3908 catch (Exception e) {
3909 throw processException(e);
3910 }
3911 finally {
3912 FinderCacheUtil.clearCache(AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETTAGS_NAME);
3913 }
3914 }
3915
3916
3923 public void addAssetTag(long pk,
3924 com.liferay.portlet.asset.model.AssetTag assetTag)
3925 throws SystemException {
3926 try {
3927 addAssetTag.add(pk, assetTag.getPrimaryKey());
3928 }
3929 catch (Exception e) {
3930 throw processException(e);
3931 }
3932 finally {
3933 FinderCacheUtil.clearCache(AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETTAGS_NAME);
3934 }
3935 }
3936
3937
3944 public void addAssetTags(long pk, long[] assetTagPKs)
3945 throws SystemException {
3946 try {
3947 for (long assetTagPK : assetTagPKs) {
3948 addAssetTag.add(pk, assetTagPK);
3949 }
3950 }
3951 catch (Exception e) {
3952 throw processException(e);
3953 }
3954 finally {
3955 FinderCacheUtil.clearCache(AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETTAGS_NAME);
3956 }
3957 }
3958
3959
3966 public void addAssetTags(long pk,
3967 List<com.liferay.portlet.asset.model.AssetTag> assetTags)
3968 throws SystemException {
3969 try {
3970 for (com.liferay.portlet.asset.model.AssetTag assetTag : assetTags) {
3971 addAssetTag.add(pk, assetTag.getPrimaryKey());
3972 }
3973 }
3974 catch (Exception e) {
3975 throw processException(e);
3976 }
3977 finally {
3978 FinderCacheUtil.clearCache(AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETTAGS_NAME);
3979 }
3980 }
3981
3982
3988 public void clearAssetTags(long pk) throws SystemException {
3989 try {
3990 clearAssetTags.clear(pk);
3991 }
3992 catch (Exception e) {
3993 throw processException(e);
3994 }
3995 finally {
3996 FinderCacheUtil.clearCache(AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETTAGS_NAME);
3997 }
3998 }
3999
4000
4007 public void removeAssetTag(long pk, long assetTagPK)
4008 throws SystemException {
4009 try {
4010 removeAssetTag.remove(pk, assetTagPK);
4011 }
4012 catch (Exception e) {
4013 throw processException(e);
4014 }
4015 finally {
4016 FinderCacheUtil.clearCache(AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETTAGS_NAME);
4017 }
4018 }
4019
4020
4027 public void removeAssetTag(long pk,
4028 com.liferay.portlet.asset.model.AssetTag assetTag)
4029 throws SystemException {
4030 try {
4031 removeAssetTag.remove(pk, assetTag.getPrimaryKey());
4032 }
4033 catch (Exception e) {
4034 throw processException(e);
4035 }
4036 finally {
4037 FinderCacheUtil.clearCache(AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETTAGS_NAME);
4038 }
4039 }
4040
4041
4048 public void removeAssetTags(long pk, long[] assetTagPKs)
4049 throws SystemException {
4050 try {
4051 for (long assetTagPK : assetTagPKs) {
4052 removeAssetTag.remove(pk, assetTagPK);
4053 }
4054 }
4055 catch (Exception e) {
4056 throw processException(e);
4057 }
4058 finally {
4059 FinderCacheUtil.clearCache(AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETTAGS_NAME);
4060 }
4061 }
4062
4063
4070 public void removeAssetTags(long pk,
4071 List<com.liferay.portlet.asset.model.AssetTag> assetTags)
4072 throws SystemException {
4073 try {
4074 for (com.liferay.portlet.asset.model.AssetTag assetTag : assetTags) {
4075 removeAssetTag.remove(pk, assetTag.getPrimaryKey());
4076 }
4077 }
4078 catch (Exception e) {
4079 throw processException(e);
4080 }
4081 finally {
4082 FinderCacheUtil.clearCache(AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETTAGS_NAME);
4083 }
4084 }
4085
4086
4093 public void setAssetTags(long pk, long[] assetTagPKs)
4094 throws SystemException {
4095 try {
4096 Set<Long> assetTagPKSet = SetUtil.fromArray(assetTagPKs);
4097
4098 List<com.liferay.portlet.asset.model.AssetTag> assetTags = getAssetTags(pk);
4099
4100 for (com.liferay.portlet.asset.model.AssetTag assetTag : assetTags) {
4101 if (!assetTagPKSet.remove(assetTag.getPrimaryKey())) {
4102 removeAssetTag.remove(pk, assetTag.getPrimaryKey());
4103 }
4104 }
4105
4106 for (Long assetTagPK : assetTagPKSet) {
4107 addAssetTag.add(pk, assetTagPK);
4108 }
4109 }
4110 catch (Exception e) {
4111 throw processException(e);
4112 }
4113 finally {
4114 FinderCacheUtil.clearCache(AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETTAGS_NAME);
4115 }
4116 }
4117
4118
4125 public void setAssetTags(long pk,
4126 List<com.liferay.portlet.asset.model.AssetTag> assetTags)
4127 throws SystemException {
4128 try {
4129 long[] assetTagPKs = new long[assetTags.size()];
4130
4131 for (int i = 0; i < assetTags.size(); i++) {
4132 com.liferay.portlet.asset.model.AssetTag assetTag = assetTags.get(i);
4133
4134 assetTagPKs[i] = assetTag.getPrimaryKey();
4135 }
4136
4137 setAssetTags(pk, assetTagPKs);
4138 }
4139 catch (Exception e) {
4140 throw processException(e);
4141 }
4142 finally {
4143 FinderCacheUtil.clearCache(AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETTAGS_NAME);
4144 }
4145 }
4146
4147
4150 public void afterPropertiesSet() {
4151 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
4152 com.liferay.portal.util.PropsUtil.get(
4153 "value.object.listener.com.liferay.portlet.asset.model.AssetEntry")));
4154
4155 if (listenerClassNames.length > 0) {
4156 try {
4157 List<ModelListener<AssetEntry>> listenersList = new ArrayList<ModelListener<AssetEntry>>();
4158
4159 for (String listenerClassName : listenerClassNames) {
4160 listenersList.add((ModelListener<AssetEntry>)InstanceFactory.newInstance(
4161 listenerClassName));
4162 }
4163
4164 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
4165 }
4166 catch (Exception e) {
4167 _log.error(e);
4168 }
4169 }
4170
4171 containsAssetCategory = new ContainsAssetCategory();
4172
4173 addAssetCategory = new AddAssetCategory();
4174 clearAssetCategories = new ClearAssetCategories();
4175 removeAssetCategory = new RemoveAssetCategory();
4176
4177 containsAssetTag = new ContainsAssetTag();
4178
4179 addAssetTag = new AddAssetTag();
4180 clearAssetTags = new ClearAssetTags();
4181 removeAssetTag = new RemoveAssetTag();
4182 }
4183
4184 public void destroy() {
4185 EntityCacheUtil.removeCache(AssetEntryImpl.class.getName());
4186 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
4187 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
4188 }
4189
4190 @BeanReference(type = AssetCategoryPersistence.class)
4191 protected AssetCategoryPersistence assetCategoryPersistence;
4192 @BeanReference(type = AssetCategoryPropertyPersistence.class)
4193 protected AssetCategoryPropertyPersistence assetCategoryPropertyPersistence;
4194 @BeanReference(type = AssetEntryPersistence.class)
4195 protected AssetEntryPersistence assetEntryPersistence;
4196 @BeanReference(type = AssetLinkPersistence.class)
4197 protected AssetLinkPersistence assetLinkPersistence;
4198 @BeanReference(type = AssetTagPersistence.class)
4199 protected AssetTagPersistence assetTagPersistence;
4200 @BeanReference(type = AssetTagPropertyPersistence.class)
4201 protected AssetTagPropertyPersistence assetTagPropertyPersistence;
4202 @BeanReference(type = AssetTagStatsPersistence.class)
4203 protected AssetTagStatsPersistence assetTagStatsPersistence;
4204 @BeanReference(type = AssetVocabularyPersistence.class)
4205 protected AssetVocabularyPersistence assetVocabularyPersistence;
4206 @BeanReference(type = CompanyPersistence.class)
4207 protected CompanyPersistence companyPersistence;
4208 @BeanReference(type = GroupPersistence.class)
4209 protected GroupPersistence groupPersistence;
4210 @BeanReference(type = ResourcePersistence.class)
4211 protected ResourcePersistence resourcePersistence;
4212 @BeanReference(type = UserPersistence.class)
4213 protected UserPersistence userPersistence;
4214 @BeanReference(type = BlogsEntryPersistence.class)
4215 protected BlogsEntryPersistence blogsEntryPersistence;
4216 @BeanReference(type = BookmarksEntryPersistence.class)
4217 protected BookmarksEntryPersistence bookmarksEntryPersistence;
4218 @BeanReference(type = DLFileEntryPersistence.class)
4219 protected DLFileEntryPersistence dlFileEntryPersistence;
4220 @BeanReference(type = DLFolderPersistence.class)
4221 protected DLFolderPersistence dlFolderPersistence;
4222 @BeanReference(type = JournalArticlePersistence.class)
4223 protected JournalArticlePersistence journalArticlePersistence;
4224 @BeanReference(type = JournalArticleResourcePersistence.class)
4225 protected JournalArticleResourcePersistence journalArticleResourcePersistence;
4226 @BeanReference(type = MBMessagePersistence.class)
4227 protected MBMessagePersistence mbMessagePersistence;
4228 @BeanReference(type = SocialActivityPersistence.class)
4229 protected SocialActivityPersistence socialActivityPersistence;
4230 @BeanReference(type = WikiPagePersistence.class)
4231 protected WikiPagePersistence wikiPagePersistence;
4232 @BeanReference(type = WikiPageResourcePersistence.class)
4233 protected WikiPageResourcePersistence wikiPageResourcePersistence;
4234 protected ContainsAssetCategory containsAssetCategory;
4235 protected AddAssetCategory addAssetCategory;
4236 protected ClearAssetCategories clearAssetCategories;
4237 protected RemoveAssetCategory removeAssetCategory;
4238 protected ContainsAssetTag containsAssetTag;
4239 protected AddAssetTag addAssetTag;
4240 protected ClearAssetTags clearAssetTags;
4241 protected RemoveAssetTag removeAssetTag;
4242
4243 protected class ContainsAssetCategory {
4244 protected ContainsAssetCategory() {
4245 _mappingSqlQuery = MappingSqlQueryFactoryUtil.getMappingSqlQuery(getDataSource(),
4246 _SQL_CONTAINSASSETCATEGORY,
4247 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT },
4248 RowMapper.COUNT);
4249 }
4250
4251 protected boolean contains(long entryId, long categoryId) {
4252 List<Integer> results = _mappingSqlQuery.execute(new Object[] {
4253 new Long(entryId), new Long(categoryId)
4254 });
4255
4256 if (results.size() > 0) {
4257 Integer count = results.get(0);
4258
4259 if (count.intValue() > 0) {
4260 return true;
4261 }
4262 }
4263
4264 return false;
4265 }
4266
4267 private MappingSqlQuery<Integer> _mappingSqlQuery;
4268 }
4269
4270 protected class AddAssetCategory {
4271 protected AddAssetCategory() {
4272 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
4273 "INSERT INTO AssetEntries_AssetCategories (entryId, categoryId) VALUES (?, ?)",
4274 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
4275 }
4276
4277 protected void add(long entryId, long categoryId)
4278 throws SystemException {
4279 if (!containsAssetCategory.contains(entryId, categoryId)) {
4280 ModelListener<com.liferay.portlet.asset.model.AssetCategory>[] assetCategoryListeners =
4281 assetCategoryPersistence.getListeners();
4282
4283 for (ModelListener<AssetEntry> listener : listeners) {
4284 listener.onBeforeAddAssociation(entryId,
4285 com.liferay.portlet.asset.model.AssetCategory.class.getName(),
4286 categoryId);
4287 }
4288
4289 for (ModelListener<com.liferay.portlet.asset.model.AssetCategory> listener : assetCategoryListeners) {
4290 listener.onBeforeAddAssociation(categoryId,
4291 AssetEntry.class.getName(), entryId);
4292 }
4293
4294 _sqlUpdate.update(new Object[] {
4295 new Long(entryId), new Long(categoryId)
4296 });
4297
4298 for (ModelListener<AssetEntry> listener : listeners) {
4299 listener.onAfterAddAssociation(entryId,
4300 com.liferay.portlet.asset.model.AssetCategory.class.getName(),
4301 categoryId);
4302 }
4303
4304 for (ModelListener<com.liferay.portlet.asset.model.AssetCategory> listener : assetCategoryListeners) {
4305 listener.onAfterAddAssociation(categoryId,
4306 AssetEntry.class.getName(), entryId);
4307 }
4308 }
4309 }
4310
4311 private SqlUpdate _sqlUpdate;
4312 }
4313
4314 protected class ClearAssetCategories {
4315 protected ClearAssetCategories() {
4316 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
4317 "DELETE FROM AssetEntries_AssetCategories WHERE entryId = ?",
4318 new int[] { java.sql.Types.BIGINT });
4319 }
4320
4321 protected void clear(long entryId) throws SystemException {
4322 ModelListener<com.liferay.portlet.asset.model.AssetCategory>[] assetCategoryListeners =
4323 assetCategoryPersistence.getListeners();
4324
4325 List<com.liferay.portlet.asset.model.AssetCategory> assetCategories = null;
4326
4327 if ((listeners.length > 0) || (assetCategoryListeners.length > 0)) {
4328 assetCategories = getAssetCategories(entryId);
4329
4330 for (com.liferay.portlet.asset.model.AssetCategory assetCategory : assetCategories) {
4331 for (ModelListener<AssetEntry> listener : listeners) {
4332 listener.onBeforeRemoveAssociation(entryId,
4333 com.liferay.portlet.asset.model.AssetCategory.class.getName(),
4334 assetCategory.getPrimaryKey());
4335 }
4336
4337 for (ModelListener<com.liferay.portlet.asset.model.AssetCategory> listener : assetCategoryListeners) {
4338 listener.onBeforeRemoveAssociation(assetCategory.getPrimaryKey(),
4339 AssetEntry.class.getName(), entryId);
4340 }
4341 }
4342 }
4343
4344 _sqlUpdate.update(new Object[] { new Long(entryId) });
4345
4346 if ((listeners.length > 0) || (assetCategoryListeners.length > 0)) {
4347 for (com.liferay.portlet.asset.model.AssetCategory assetCategory : assetCategories) {
4348 for (ModelListener<AssetEntry> listener : listeners) {
4349 listener.onAfterRemoveAssociation(entryId,
4350 com.liferay.portlet.asset.model.AssetCategory.class.getName(),
4351 assetCategory.getPrimaryKey());
4352 }
4353
4354 for (ModelListener<com.liferay.portlet.asset.model.AssetCategory> listener : assetCategoryListeners) {
4355 listener.onAfterRemoveAssociation(assetCategory.getPrimaryKey(),
4356 AssetEntry.class.getName(), entryId);
4357 }
4358 }
4359 }
4360 }
4361
4362 private SqlUpdate _sqlUpdate;
4363 }
4364
4365 protected class RemoveAssetCategory {
4366 protected RemoveAssetCategory() {
4367 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
4368 "DELETE FROM AssetEntries_AssetCategories WHERE entryId = ? AND categoryId = ?",
4369 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
4370 }
4371
4372 protected void remove(long entryId, long categoryId)
4373 throws SystemException {
4374 if (containsAssetCategory.contains(entryId, categoryId)) {
4375 ModelListener<com.liferay.portlet.asset.model.AssetCategory>[] assetCategoryListeners =
4376 assetCategoryPersistence.getListeners();
4377
4378 for (ModelListener<AssetEntry> listener : listeners) {
4379 listener.onBeforeRemoveAssociation(entryId,
4380 com.liferay.portlet.asset.model.AssetCategory.class.getName(),
4381 categoryId);
4382 }
4383
4384 for (ModelListener<com.liferay.portlet.asset.model.AssetCategory> listener : assetCategoryListeners) {
4385 listener.onBeforeRemoveAssociation(categoryId,
4386 AssetEntry.class.getName(), entryId);
4387 }
4388
4389 _sqlUpdate.update(new Object[] {
4390 new Long(entryId), new Long(categoryId)
4391 });
4392
4393 for (ModelListener<AssetEntry> listener : listeners) {
4394 listener.onAfterRemoveAssociation(entryId,
4395 com.liferay.portlet.asset.model.AssetCategory.class.getName(),
4396 categoryId);
4397 }
4398
4399 for (ModelListener<com.liferay.portlet.asset.model.AssetCategory> listener : assetCategoryListeners) {
4400 listener.onAfterRemoveAssociation(categoryId,
4401 AssetEntry.class.getName(), entryId);
4402 }
4403 }
4404 }
4405
4406 private SqlUpdate _sqlUpdate;
4407 }
4408
4409 protected class ContainsAssetTag {
4410 protected ContainsAssetTag() {
4411 _mappingSqlQuery = MappingSqlQueryFactoryUtil.getMappingSqlQuery(getDataSource(),
4412 _SQL_CONTAINSASSETTAG,
4413 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT },
4414 RowMapper.COUNT);
4415 }
4416
4417 protected boolean contains(long entryId, long tagId) {
4418 List<Integer> results = _mappingSqlQuery.execute(new Object[] {
4419 new Long(entryId), new Long(tagId)
4420 });
4421
4422 if (results.size() > 0) {
4423 Integer count = results.get(0);
4424
4425 if (count.intValue() > 0) {
4426 return true;
4427 }
4428 }
4429
4430 return false;
4431 }
4432
4433 private MappingSqlQuery<Integer> _mappingSqlQuery;
4434 }
4435
4436 protected class AddAssetTag {
4437 protected AddAssetTag() {
4438 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
4439 "INSERT INTO AssetEntries_AssetTags (entryId, tagId) VALUES (?, ?)",
4440 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
4441 }
4442
4443 protected void add(long entryId, long tagId) throws SystemException {
4444 if (!containsAssetTag.contains(entryId, tagId)) {
4445 ModelListener<com.liferay.portlet.asset.model.AssetTag>[] assetTagListeners =
4446 assetTagPersistence.getListeners();
4447
4448 for (ModelListener<AssetEntry> listener : listeners) {
4449 listener.onBeforeAddAssociation(entryId,
4450 com.liferay.portlet.asset.model.AssetTag.class.getName(),
4451 tagId);
4452 }
4453
4454 for (ModelListener<com.liferay.portlet.asset.model.AssetTag> listener : assetTagListeners) {
4455 listener.onBeforeAddAssociation(tagId,
4456 AssetEntry.class.getName(), entryId);
4457 }
4458
4459 _sqlUpdate.update(new Object[] {
4460 new Long(entryId), new Long(tagId)
4461 });
4462
4463 for (ModelListener<AssetEntry> listener : listeners) {
4464 listener.onAfterAddAssociation(entryId,
4465 com.liferay.portlet.asset.model.AssetTag.class.getName(),
4466 tagId);
4467 }
4468
4469 for (ModelListener<com.liferay.portlet.asset.model.AssetTag> listener : assetTagListeners) {
4470 listener.onAfterAddAssociation(tagId,
4471 AssetEntry.class.getName(), entryId);
4472 }
4473 }
4474 }
4475
4476 private SqlUpdate _sqlUpdate;
4477 }
4478
4479 protected class ClearAssetTags {
4480 protected ClearAssetTags() {
4481 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
4482 "DELETE FROM AssetEntries_AssetTags WHERE entryId = ?",
4483 new int[] { java.sql.Types.BIGINT });
4484 }
4485
4486 protected void clear(long entryId) throws SystemException {
4487 ModelListener<com.liferay.portlet.asset.model.AssetTag>[] assetTagListeners =
4488 assetTagPersistence.getListeners();
4489
4490 List<com.liferay.portlet.asset.model.AssetTag> assetTags = null;
4491
4492 if ((listeners.length > 0) || (assetTagListeners.length > 0)) {
4493 assetTags = getAssetTags(entryId);
4494
4495 for (com.liferay.portlet.asset.model.AssetTag assetTag : assetTags) {
4496 for (ModelListener<AssetEntry> listener : listeners) {
4497 listener.onBeforeRemoveAssociation(entryId,
4498 com.liferay.portlet.asset.model.AssetTag.class.getName(),
4499 assetTag.getPrimaryKey());
4500 }
4501
4502 for (ModelListener<com.liferay.portlet.asset.model.AssetTag> listener : assetTagListeners) {
4503 listener.onBeforeRemoveAssociation(assetTag.getPrimaryKey(),
4504 AssetEntry.class.getName(), entryId);
4505 }
4506 }
4507 }
4508
4509 _sqlUpdate.update(new Object[] { new Long(entryId) });
4510
4511 if ((listeners.length > 0) || (assetTagListeners.length > 0)) {
4512 for (com.liferay.portlet.asset.model.AssetTag assetTag : assetTags) {
4513 for (ModelListener<AssetEntry> listener : listeners) {
4514 listener.onAfterRemoveAssociation(entryId,
4515 com.liferay.portlet.asset.model.AssetTag.class.getName(),
4516 assetTag.getPrimaryKey());
4517 }
4518
4519 for (ModelListener<com.liferay.portlet.asset.model.AssetTag> listener : assetTagListeners) {
4520 listener.onAfterRemoveAssociation(assetTag.getPrimaryKey(),
4521 AssetEntry.class.getName(), entryId);
4522 }
4523 }
4524 }
4525 }
4526
4527 private SqlUpdate _sqlUpdate;
4528 }
4529
4530 protected class RemoveAssetTag {
4531 protected RemoveAssetTag() {
4532 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
4533 "DELETE FROM AssetEntries_AssetTags WHERE entryId = ? AND tagId = ?",
4534 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
4535 }
4536
4537 protected void remove(long entryId, long tagId)
4538 throws SystemException {
4539 if (containsAssetTag.contains(entryId, tagId)) {
4540 ModelListener<com.liferay.portlet.asset.model.AssetTag>[] assetTagListeners =
4541 assetTagPersistence.getListeners();
4542
4543 for (ModelListener<AssetEntry> listener : listeners) {
4544 listener.onBeforeRemoveAssociation(entryId,
4545 com.liferay.portlet.asset.model.AssetTag.class.getName(),
4546 tagId);
4547 }
4548
4549 for (ModelListener<com.liferay.portlet.asset.model.AssetTag> listener : assetTagListeners) {
4550 listener.onBeforeRemoveAssociation(tagId,
4551 AssetEntry.class.getName(), entryId);
4552 }
4553
4554 _sqlUpdate.update(new Object[] {
4555 new Long(entryId), new Long(tagId)
4556 });
4557
4558 for (ModelListener<AssetEntry> listener : listeners) {
4559 listener.onAfterRemoveAssociation(entryId,
4560 com.liferay.portlet.asset.model.AssetTag.class.getName(),
4561 tagId);
4562 }
4563
4564 for (ModelListener<com.liferay.portlet.asset.model.AssetTag> listener : assetTagListeners) {
4565 listener.onAfterRemoveAssociation(tagId,
4566 AssetEntry.class.getName(), entryId);
4567 }
4568 }
4569 }
4570
4571 private SqlUpdate _sqlUpdate;
4572 }
4573
4574 private static final String _SQL_SELECT_ASSETENTRY = "SELECT assetEntry FROM AssetEntry assetEntry";
4575 private static final String _SQL_SELECT_ASSETENTRY_WHERE = "SELECT assetEntry FROM AssetEntry assetEntry WHERE ";
4576 private static final String _SQL_COUNT_ASSETENTRY = "SELECT COUNT(assetEntry) FROM AssetEntry assetEntry";
4577 private static final String _SQL_COUNT_ASSETENTRY_WHERE = "SELECT COUNT(assetEntry) FROM AssetEntry assetEntry WHERE ";
4578 private static final String _SQL_GETASSETCATEGORIES = "SELECT {AssetCategory.*} FROM AssetCategory INNER JOIN AssetEntries_AssetCategories ON (AssetEntries_AssetCategories.categoryId = AssetCategory.categoryId) WHERE (AssetEntries_AssetCategories.entryId = ?)";
4579 private static final String _SQL_GETASSETCATEGORIESSIZE = "SELECT COUNT(*) AS COUNT_VALUE FROM AssetEntries_AssetCategories WHERE entryId = ?";
4580 private static final String _SQL_CONTAINSASSETCATEGORY = "SELECT COUNT(*) AS COUNT_VALUE FROM AssetEntries_AssetCategories WHERE entryId = ? AND categoryId = ?";
4581 private static final String _SQL_GETASSETTAGS = "SELECT {AssetTag.*} FROM AssetTag INNER JOIN AssetEntries_AssetTags ON (AssetEntries_AssetTags.tagId = AssetTag.tagId) WHERE (AssetEntries_AssetTags.entryId = ?)";
4582 private static final String _SQL_GETASSETTAGSSIZE = "SELECT COUNT(*) AS COUNT_VALUE FROM AssetEntries_AssetTags WHERE entryId = ?";
4583 private static final String _SQL_CONTAINSASSETTAG = "SELECT COUNT(*) AS COUNT_VALUE FROM AssetEntries_AssetTags WHERE entryId = ? AND tagId = ?";
4584 private static final String _FINDER_COLUMN_COMPANYID_COMPANYID_2 = "assetEntry.companyId = ?";
4585 private static final String _FINDER_COLUMN_VISIBLE_VISIBLE_2 = "assetEntry.visible = ?";
4586 private static final String _FINDER_COLUMN_PUBLISHDATE_PUBLISHDATE_1 = "assetEntry.publishDate IS NULL";
4587 private static final String _FINDER_COLUMN_PUBLISHDATE_PUBLISHDATE_2 = "assetEntry.publishDate = ?";
4588 private static final String _FINDER_COLUMN_EXPIRATIONDATE_EXPIRATIONDATE_1 = "assetEntry.expirationDate IS NULL";
4589 private static final String _FINDER_COLUMN_EXPIRATIONDATE_EXPIRATIONDATE_2 = "assetEntry.expirationDate = ?";
4590 private static final String _FINDER_COLUMN_G_CU_GROUPID_2 = "assetEntry.groupId = ? AND ";
4591 private static final String _FINDER_COLUMN_G_CU_CLASSUUID_1 = "assetEntry.classUuid IS NULL";
4592 private static final String _FINDER_COLUMN_G_CU_CLASSUUID_2 = "assetEntry.classUuid = ?";
4593 private static final String _FINDER_COLUMN_G_CU_CLASSUUID_3 = "(assetEntry.classUuid IS NULL OR assetEntry.classUuid = ?)";
4594 private static final String _FINDER_COLUMN_C_C_CLASSNAMEID_2 = "assetEntry.classNameId = ? AND ";
4595 private static final String _FINDER_COLUMN_C_C_CLASSPK_2 = "assetEntry.classPK = ?";
4596 private static final String _ORDER_BY_ENTITY_ALIAS = "assetEntry.";
4597 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No AssetEntry exists with the primary key ";
4598 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No AssetEntry exists with the key {";
4599 private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
4600 private static Log _log = LogFactoryUtil.getLog(AssetEntryPersistenceImpl.class);
4601 private static AssetEntry _nullAssetEntry = new AssetEntryImpl() {
4602 @Override
4603 public Object clone() {
4604 return this;
4605 }
4606
4607 @Override
4608 public CacheModel<AssetEntry> toCacheModel() {
4609 return _nullAssetEntryCacheModel;
4610 }
4611 };
4612
4613 private static CacheModel<AssetEntry> _nullAssetEntryCacheModel = new CacheModel<AssetEntry>() {
4614 public AssetEntry toEntityModel() {
4615 return _nullAssetEntry;
4616 }
4617 };
4618 }