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.model.CacheModel;
045 import com.liferay.portal.model.ModelListener;
046 import com.liferay.portal.service.persistence.BatchSessionUtil;
047 import com.liferay.portal.service.persistence.CompanyPersistence;
048 import com.liferay.portal.service.persistence.GroupPersistence;
049 import com.liferay.portal.service.persistence.ResourcePersistence;
050 import com.liferay.portal.service.persistence.UserPersistence;
051 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
052
053 import com.liferay.portlet.asset.NoSuchEntryException;
054 import com.liferay.portlet.asset.model.AssetEntry;
055 import com.liferay.portlet.asset.model.impl.AssetEntryImpl;
056 import com.liferay.portlet.asset.model.impl.AssetEntryModelImpl;
057 import com.liferay.portlet.blogs.service.persistence.BlogsEntryPersistence;
058 import com.liferay.portlet.bookmarks.service.persistence.BookmarksEntryPersistence;
059 import com.liferay.portlet.documentlibrary.service.persistence.DLFileEntryPersistence;
060 import com.liferay.portlet.documentlibrary.service.persistence.DLFolderPersistence;
061 import com.liferay.portlet.journal.service.persistence.JournalArticlePersistence;
062 import com.liferay.portlet.journal.service.persistence.JournalArticleResourcePersistence;
063 import com.liferay.portlet.messageboards.service.persistence.MBMessagePersistence;
064 import com.liferay.portlet.social.service.persistence.SocialActivityPersistence;
065 import com.liferay.portlet.wiki.service.persistence.WikiPagePersistence;
066 import com.liferay.portlet.wiki.service.persistence.WikiPageResourcePersistence;
067
068 import java.io.Serializable;
069
070 import java.util.ArrayList;
071 import java.util.Collections;
072 import java.util.Date;
073 import java.util.List;
074 import java.util.Set;
075
076
088 public class AssetEntryPersistenceImpl extends BasePersistenceImpl<AssetEntry>
089 implements AssetEntryPersistence {
090
095 public static final String FINDER_CLASS_NAME_ENTITY = AssetEntryImpl.class.getName();
096 public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
097 ".List1";
098 public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
099 ".List2";
100 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID =
101 new FinderPath(AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
102 AssetEntryModelImpl.FINDER_CACHE_ENABLED, AssetEntryImpl.class,
103 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByCompanyId",
104 new String[] {
105 Long.class.getName(),
106
107 "java.lang.Integer", "java.lang.Integer",
108 "com.liferay.portal.kernel.util.OrderByComparator"
109 });
110 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID =
111 new FinderPath(AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
112 AssetEntryModelImpl.FINDER_CACHE_ENABLED, AssetEntryImpl.class,
113 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByCompanyId",
114 new String[] { Long.class.getName() },
115 AssetEntryModelImpl.COMPANYID_COLUMN_BITMASK);
116 public static final FinderPath FINDER_PATH_COUNT_BY_COMPANYID = new FinderPath(AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
117 AssetEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
118 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByCompanyId",
119 new String[] { Long.class.getName() });
120 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_VISIBLE = new FinderPath(AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
121 AssetEntryModelImpl.FINDER_CACHE_ENABLED, AssetEntryImpl.class,
122 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByVisible",
123 new String[] {
124 Boolean.class.getName(),
125
126 "java.lang.Integer", "java.lang.Integer",
127 "com.liferay.portal.kernel.util.OrderByComparator"
128 });
129 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_VISIBLE =
130 new FinderPath(AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
131 AssetEntryModelImpl.FINDER_CACHE_ENABLED, AssetEntryImpl.class,
132 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByVisible",
133 new String[] { Boolean.class.getName() },
134 AssetEntryModelImpl.VISIBLE_COLUMN_BITMASK);
135 public static final FinderPath FINDER_PATH_COUNT_BY_VISIBLE = new FinderPath(AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
136 AssetEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
137 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByVisible",
138 new String[] { Boolean.class.getName() });
139 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_PUBLISHDATE =
140 new FinderPath(AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
141 AssetEntryModelImpl.FINDER_CACHE_ENABLED, AssetEntryImpl.class,
142 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByPublishDate",
143 new String[] {
144 Date.class.getName(),
145
146 "java.lang.Integer", "java.lang.Integer",
147 "com.liferay.portal.kernel.util.OrderByComparator"
148 });
149 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_PUBLISHDATE =
150 new FinderPath(AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
151 AssetEntryModelImpl.FINDER_CACHE_ENABLED, AssetEntryImpl.class,
152 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByPublishDate",
153 new String[] { Date.class.getName() },
154 AssetEntryModelImpl.PUBLISHDATE_COLUMN_BITMASK);
155 public static final FinderPath FINDER_PATH_COUNT_BY_PUBLISHDATE = new FinderPath(AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
156 AssetEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
157 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByPublishDate",
158 new String[] { Date.class.getName() });
159 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_EXPIRATIONDATE =
160 new FinderPath(AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
161 AssetEntryModelImpl.FINDER_CACHE_ENABLED, AssetEntryImpl.class,
162 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByExpirationDate",
163 new String[] {
164 Date.class.getName(),
165
166 "java.lang.Integer", "java.lang.Integer",
167 "com.liferay.portal.kernel.util.OrderByComparator"
168 });
169 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_EXPIRATIONDATE =
170 new FinderPath(AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
171 AssetEntryModelImpl.FINDER_CACHE_ENABLED, AssetEntryImpl.class,
172 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByExpirationDate",
173 new String[] { Date.class.getName() },
174 AssetEntryModelImpl.EXPIRATIONDATE_COLUMN_BITMASK);
175 public static final FinderPath FINDER_PATH_COUNT_BY_EXPIRATIONDATE = new FinderPath(AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
176 AssetEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
177 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByExpirationDate",
178 new String[] { Date.class.getName() });
179 public static final FinderPath FINDER_PATH_FETCH_BY_G_CU = new FinderPath(AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
180 AssetEntryModelImpl.FINDER_CACHE_ENABLED, AssetEntryImpl.class,
181 FINDER_CLASS_NAME_ENTITY, "fetchByG_CU",
182 new String[] { Long.class.getName(), String.class.getName() },
183 AssetEntryModelImpl.GROUPID_COLUMN_BITMASK |
184 AssetEntryModelImpl.CLASSUUID_COLUMN_BITMASK);
185 public static final FinderPath FINDER_PATH_COUNT_BY_G_CU = new FinderPath(AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
186 AssetEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
187 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_CU",
188 new String[] { Long.class.getName(), String.class.getName() });
189 public static final FinderPath FINDER_PATH_FETCH_BY_C_C = new FinderPath(AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
190 AssetEntryModelImpl.FINDER_CACHE_ENABLED, AssetEntryImpl.class,
191 FINDER_CLASS_NAME_ENTITY, "fetchByC_C",
192 new String[] { Long.class.getName(), Long.class.getName() },
193 AssetEntryModelImpl.CLASSNAMEID_COLUMN_BITMASK |
194 AssetEntryModelImpl.CLASSPK_COLUMN_BITMASK);
195 public static final FinderPath FINDER_PATH_COUNT_BY_C_C = new FinderPath(AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
196 AssetEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
197 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_C",
198 new String[] { Long.class.getName(), Long.class.getName() });
199 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
200 AssetEntryModelImpl.FINDER_CACHE_ENABLED, AssetEntryImpl.class,
201 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
202 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
203 AssetEntryModelImpl.FINDER_CACHE_ENABLED, AssetEntryImpl.class,
204 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0]);
205 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
206 AssetEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
207 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
208
209
214 public void cacheResult(AssetEntry assetEntry) {
215 EntityCacheUtil.putResult(AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
216 AssetEntryImpl.class, assetEntry.getPrimaryKey(), assetEntry);
217
218 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_CU,
219 new Object[] {
220 Long.valueOf(assetEntry.getGroupId()),
221
222 assetEntry.getClassUuid()
223 }, assetEntry);
224
225 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C,
226 new Object[] {
227 Long.valueOf(assetEntry.getClassNameId()),
228 Long.valueOf(assetEntry.getClassPK())
229 }, assetEntry);
230
231 assetEntry.resetOriginalValues();
232 }
233
234
239 public void cacheResult(List<AssetEntry> assetEntries) {
240 for (AssetEntry assetEntry : assetEntries) {
241 if (EntityCacheUtil.getResult(
242 AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
243 AssetEntryImpl.class, assetEntry.getPrimaryKey()) == null) {
244 cacheResult(assetEntry);
245 }
246 else {
247 assetEntry.resetOriginalValues();
248 }
249 }
250 }
251
252
259 @Override
260 public void clearCache() {
261 if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
262 CacheRegistryUtil.clear(AssetEntryImpl.class.getName());
263 }
264
265 EntityCacheUtil.clearCache(AssetEntryImpl.class.getName());
266
267 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
268 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
269 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
270 }
271
272
279 @Override
280 public void clearCache(AssetEntry assetEntry) {
281 EntityCacheUtil.removeResult(AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
282 AssetEntryImpl.class, assetEntry.getPrimaryKey());
283
284 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
285 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
286
287 clearUniqueFindersCache(assetEntry);
288 }
289
290 @Override
291 public void clearCache(List<AssetEntry> assetEntries) {
292 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
293 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
294
295 for (AssetEntry assetEntry : assetEntries) {
296 EntityCacheUtil.removeResult(AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
297 AssetEntryImpl.class, assetEntry.getPrimaryKey());
298
299 clearUniqueFindersCache(assetEntry);
300 }
301 }
302
303 protected void clearUniqueFindersCache(AssetEntry assetEntry) {
304 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_CU,
305 new Object[] {
306 Long.valueOf(assetEntry.getGroupId()),
307
308 assetEntry.getClassUuid()
309 });
310
311 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_C,
312 new Object[] {
313 Long.valueOf(assetEntry.getClassNameId()),
314 Long.valueOf(assetEntry.getClassPK())
315 });
316 }
317
318
324 public AssetEntry create(long entryId) {
325 AssetEntry assetEntry = new AssetEntryImpl();
326
327 assetEntry.setNew(true);
328 assetEntry.setPrimaryKey(entryId);
329
330 return assetEntry;
331 }
332
333
341 public AssetEntry remove(long entryId)
342 throws NoSuchEntryException, SystemException {
343 return remove(Long.valueOf(entryId));
344 }
345
346
354 @Override
355 public AssetEntry remove(Serializable primaryKey)
356 throws NoSuchEntryException, SystemException {
357 Session session = null;
358
359 try {
360 session = openSession();
361
362 AssetEntry assetEntry = (AssetEntry)session.get(AssetEntryImpl.class,
363 primaryKey);
364
365 if (assetEntry == null) {
366 if (_log.isWarnEnabled()) {
367 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
368 }
369
370 throw new NoSuchEntryException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
371 primaryKey);
372 }
373
374 return remove(assetEntry);
375 }
376 catch (NoSuchEntryException nsee) {
377 throw nsee;
378 }
379 catch (Exception e) {
380 throw processException(e);
381 }
382 finally {
383 closeSession(session);
384 }
385 }
386
387 @Override
388 protected AssetEntry removeImpl(AssetEntry assetEntry)
389 throws SystemException {
390 assetEntry = toUnwrappedModel(assetEntry);
391
392 try {
393 clearAssetCategories.clear(assetEntry.getPrimaryKey());
394 }
395 catch (Exception e) {
396 throw processException(e);
397 }
398 finally {
399 FinderCacheUtil.clearCache(AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
400 }
401
402 try {
403 clearAssetTags.clear(assetEntry.getPrimaryKey());
404 }
405 catch (Exception e) {
406 throw processException(e);
407 }
408 finally {
409 FinderCacheUtil.clearCache(AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETTAGS_NAME);
410 }
411
412 Session session = null;
413
414 try {
415 session = openSession();
416
417 BatchSessionUtil.delete(session, assetEntry);
418 }
419 catch (Exception e) {
420 throw processException(e);
421 }
422 finally {
423 closeSession(session);
424 }
425
426 clearCache(assetEntry);
427
428 return assetEntry;
429 }
430
431 @Override
432 public AssetEntry updateImpl(
433 com.liferay.portlet.asset.model.AssetEntry assetEntry, boolean merge)
434 throws SystemException {
435 assetEntry = toUnwrappedModel(assetEntry);
436
437 boolean isNew = assetEntry.isNew();
438
439 AssetEntryModelImpl assetEntryModelImpl = (AssetEntryModelImpl)assetEntry;
440
441 Session session = null;
442
443 try {
444 session = openSession();
445
446 BatchSessionUtil.update(session, assetEntry, merge);
447
448 assetEntry.setNew(false);
449 }
450 catch (Exception e) {
451 throw processException(e);
452 }
453 finally {
454 closeSession(session);
455 }
456
457 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
458
459 if (isNew || !AssetEntryModelImpl.COLUMN_BITMASK_ENABLED) {
460 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
461 }
462
463 else {
464 if ((assetEntryModelImpl.getColumnBitmask() &
465 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID.getColumnBitmask()) != 0) {
466 Object[] args = new Object[] {
467 Long.valueOf(assetEntryModelImpl.getOriginalCompanyId())
468 };
469
470 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_COMPANYID,
471 args);
472 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
473 args);
474
475 args = new Object[] {
476 Long.valueOf(assetEntryModelImpl.getCompanyId())
477 };
478
479 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_COMPANYID,
480 args);
481 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
482 args);
483 }
484
485 if ((assetEntryModelImpl.getColumnBitmask() &
486 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_VISIBLE.getColumnBitmask()) != 0) {
487 Object[] args = new Object[] {
488 Boolean.valueOf(assetEntryModelImpl.getOriginalVisible())
489 };
490
491 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_VISIBLE, args);
492 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_VISIBLE,
493 args);
494
495 args = new Object[] {
496 Boolean.valueOf(assetEntryModelImpl.getVisible())
497 };
498
499 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_VISIBLE, args);
500 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_VISIBLE,
501 args);
502 }
503
504 if ((assetEntryModelImpl.getColumnBitmask() &
505 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_PUBLISHDATE.getColumnBitmask()) != 0) {
506 Object[] args = new Object[] {
507 assetEntryModelImpl.getOriginalPublishDate()
508 };
509
510 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_PUBLISHDATE,
511 args);
512 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_PUBLISHDATE,
513 args);
514
515 args = new Object[] { assetEntryModelImpl.getPublishDate() };
516
517 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_PUBLISHDATE,
518 args);
519 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_PUBLISHDATE,
520 args);
521 }
522
523 if ((assetEntryModelImpl.getColumnBitmask() &
524 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_EXPIRATIONDATE.getColumnBitmask()) != 0) {
525 Object[] args = new Object[] {
526 assetEntryModelImpl.getOriginalExpirationDate()
527 };
528
529 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_EXPIRATIONDATE,
530 args);
531 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_EXPIRATIONDATE,
532 args);
533
534 args = new Object[] { assetEntryModelImpl.getExpirationDate() };
535
536 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_EXPIRATIONDATE,
537 args);
538 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_EXPIRATIONDATE,
539 args);
540 }
541 }
542
543 EntityCacheUtil.putResult(AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
544 AssetEntryImpl.class, assetEntry.getPrimaryKey(), assetEntry);
545
546 if (isNew) {
547 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_CU,
548 new Object[] {
549 Long.valueOf(assetEntry.getGroupId()),
550
551 assetEntry.getClassUuid()
552 }, assetEntry);
553
554 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C,
555 new Object[] {
556 Long.valueOf(assetEntry.getClassNameId()),
557 Long.valueOf(assetEntry.getClassPK())
558 }, assetEntry);
559 }
560 else {
561 if ((assetEntryModelImpl.getColumnBitmask() &
562 FINDER_PATH_FETCH_BY_G_CU.getColumnBitmask()) != 0) {
563 Object[] args = new Object[] {
564 Long.valueOf(assetEntryModelImpl.getOriginalGroupId()),
565
566 assetEntryModelImpl.getOriginalClassUuid()
567 };
568
569 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_CU, args);
570 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_CU, args);
571
572 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_CU,
573 new Object[] {
574 Long.valueOf(assetEntry.getGroupId()),
575
576 assetEntry.getClassUuid()
577 }, assetEntry);
578 }
579
580 if ((assetEntryModelImpl.getColumnBitmask() &
581 FINDER_PATH_FETCH_BY_C_C.getColumnBitmask()) != 0) {
582 Object[] args = new Object[] {
583 Long.valueOf(assetEntryModelImpl.getOriginalClassNameId()),
584 Long.valueOf(assetEntryModelImpl.getOriginalClassPK())
585 };
586
587 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_C, args);
588 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_C, args);
589
590 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C,
591 new Object[] {
592 Long.valueOf(assetEntry.getClassNameId()),
593 Long.valueOf(assetEntry.getClassPK())
594 }, assetEntry);
595 }
596 }
597
598 return assetEntry;
599 }
600
601 protected AssetEntry toUnwrappedModel(AssetEntry assetEntry) {
602 if (assetEntry instanceof AssetEntryImpl) {
603 return assetEntry;
604 }
605
606 AssetEntryImpl assetEntryImpl = new AssetEntryImpl();
607
608 assetEntryImpl.setNew(assetEntry.isNew());
609 assetEntryImpl.setPrimaryKey(assetEntry.getPrimaryKey());
610
611 assetEntryImpl.setEntryId(assetEntry.getEntryId());
612 assetEntryImpl.setGroupId(assetEntry.getGroupId());
613 assetEntryImpl.setCompanyId(assetEntry.getCompanyId());
614 assetEntryImpl.setUserId(assetEntry.getUserId());
615 assetEntryImpl.setUserName(assetEntry.getUserName());
616 assetEntryImpl.setCreateDate(assetEntry.getCreateDate());
617 assetEntryImpl.setModifiedDate(assetEntry.getModifiedDate());
618 assetEntryImpl.setClassNameId(assetEntry.getClassNameId());
619 assetEntryImpl.setClassPK(assetEntry.getClassPK());
620 assetEntryImpl.setClassUuid(assetEntry.getClassUuid());
621 assetEntryImpl.setClassTypeId(assetEntry.getClassTypeId());
622 assetEntryImpl.setVisible(assetEntry.isVisible());
623 assetEntryImpl.setStartDate(assetEntry.getStartDate());
624 assetEntryImpl.setEndDate(assetEntry.getEndDate());
625 assetEntryImpl.setPublishDate(assetEntry.getPublishDate());
626 assetEntryImpl.setExpirationDate(assetEntry.getExpirationDate());
627 assetEntryImpl.setMimeType(assetEntry.getMimeType());
628 assetEntryImpl.setTitle(assetEntry.getTitle());
629 assetEntryImpl.setDescription(assetEntry.getDescription());
630 assetEntryImpl.setSummary(assetEntry.getSummary());
631 assetEntryImpl.setUrl(assetEntry.getUrl());
632 assetEntryImpl.setLayoutUuid(assetEntry.getLayoutUuid());
633 assetEntryImpl.setHeight(assetEntry.getHeight());
634 assetEntryImpl.setWidth(assetEntry.getWidth());
635 assetEntryImpl.setPriority(assetEntry.getPriority());
636 assetEntryImpl.setViewCount(assetEntry.getViewCount());
637
638 return assetEntryImpl;
639 }
640
641
649 @Override
650 public AssetEntry findByPrimaryKey(Serializable primaryKey)
651 throws NoSuchModelException, SystemException {
652 return findByPrimaryKey(((Long)primaryKey).longValue());
653 }
654
655
663 public AssetEntry findByPrimaryKey(long entryId)
664 throws NoSuchEntryException, SystemException {
665 AssetEntry assetEntry = fetchByPrimaryKey(entryId);
666
667 if (assetEntry == null) {
668 if (_log.isWarnEnabled()) {
669 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + entryId);
670 }
671
672 throw new NoSuchEntryException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
673 entryId);
674 }
675
676 return assetEntry;
677 }
678
679
686 @Override
687 public AssetEntry fetchByPrimaryKey(Serializable primaryKey)
688 throws SystemException {
689 return fetchByPrimaryKey(((Long)primaryKey).longValue());
690 }
691
692
699 public AssetEntry fetchByPrimaryKey(long entryId) throws SystemException {
700 AssetEntry assetEntry = (AssetEntry)EntityCacheUtil.getResult(AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
701 AssetEntryImpl.class, entryId);
702
703 if (assetEntry == _nullAssetEntry) {
704 return null;
705 }
706
707 if (assetEntry == null) {
708 Session session = null;
709
710 boolean hasException = false;
711
712 try {
713 session = openSession();
714
715 assetEntry = (AssetEntry)session.get(AssetEntryImpl.class,
716 Long.valueOf(entryId));
717 }
718 catch (Exception e) {
719 hasException = true;
720
721 throw processException(e);
722 }
723 finally {
724 if (assetEntry != null) {
725 cacheResult(assetEntry);
726 }
727 else if (!hasException) {
728 EntityCacheUtil.putResult(AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
729 AssetEntryImpl.class, entryId, _nullAssetEntry);
730 }
731
732 closeSession(session);
733 }
734 }
735
736 return assetEntry;
737 }
738
739
746 public List<AssetEntry> findByCompanyId(long companyId)
747 throws SystemException {
748 return findByCompanyId(companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
749 null);
750 }
751
752
765 public List<AssetEntry> findByCompanyId(long companyId, int start, int end)
766 throws SystemException {
767 return findByCompanyId(companyId, start, end, null);
768 }
769
770
784 public List<AssetEntry> findByCompanyId(long companyId, int start, int end,
785 OrderByComparator orderByComparator) throws SystemException {
786 FinderPath finderPath = null;
787 Object[] finderArgs = null;
788
789 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
790 (orderByComparator == null)) {
791 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID;
792 finderArgs = new Object[] { companyId };
793 }
794 else {
795 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID;
796 finderArgs = new Object[] { companyId, start, end, orderByComparator };
797 }
798
799 List<AssetEntry> list = (List<AssetEntry>)FinderCacheUtil.getResult(finderPath,
800 finderArgs, this);
801
802 if (list == null) {
803 StringBundler query = null;
804
805 if (orderByComparator != null) {
806 query = new StringBundler(3 +
807 (orderByComparator.getOrderByFields().length * 3));
808 }
809 else {
810 query = new StringBundler(2);
811 }
812
813 query.append(_SQL_SELECT_ASSETENTRY_WHERE);
814
815 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
816
817 if (orderByComparator != null) {
818 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
819 orderByComparator);
820 }
821
822 String sql = query.toString();
823
824 Session session = null;
825
826 try {
827 session = openSession();
828
829 Query q = session.createQuery(sql);
830
831 QueryPos qPos = QueryPos.getInstance(q);
832
833 qPos.add(companyId);
834
835 list = (List<AssetEntry>)QueryUtil.list(q, getDialect(), start,
836 end);
837 }
838 catch (Exception e) {
839 throw processException(e);
840 }
841 finally {
842 if (list == null) {
843 FinderCacheUtil.removeResult(finderPath, finderArgs);
844 }
845 else {
846 cacheResult(list);
847
848 FinderCacheUtil.putResult(finderPath, finderArgs, list);
849 }
850
851 closeSession(session);
852 }
853 }
854
855 return list;
856 }
857
858
871 public AssetEntry findByCompanyId_First(long companyId,
872 OrderByComparator orderByComparator)
873 throws NoSuchEntryException, SystemException {
874 List<AssetEntry> list = findByCompanyId(companyId, 0, 1,
875 orderByComparator);
876
877 if (list.isEmpty()) {
878 StringBundler msg = new StringBundler(4);
879
880 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
881
882 msg.append("companyId=");
883 msg.append(companyId);
884
885 msg.append(StringPool.CLOSE_CURLY_BRACE);
886
887 throw new NoSuchEntryException(msg.toString());
888 }
889 else {
890 return list.get(0);
891 }
892 }
893
894
907 public AssetEntry findByCompanyId_Last(long companyId,
908 OrderByComparator orderByComparator)
909 throws NoSuchEntryException, SystemException {
910 int count = countByCompanyId(companyId);
911
912 List<AssetEntry> list = findByCompanyId(companyId, count - 1, count,
913 orderByComparator);
914
915 if (list.isEmpty()) {
916 StringBundler msg = new StringBundler(4);
917
918 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
919
920 msg.append("companyId=");
921 msg.append(companyId);
922
923 msg.append(StringPool.CLOSE_CURLY_BRACE);
924
925 throw new NoSuchEntryException(msg.toString());
926 }
927 else {
928 return list.get(0);
929 }
930 }
931
932
946 public AssetEntry[] findByCompanyId_PrevAndNext(long entryId,
947 long companyId, OrderByComparator orderByComparator)
948 throws NoSuchEntryException, SystemException {
949 AssetEntry assetEntry = findByPrimaryKey(entryId);
950
951 Session session = null;
952
953 try {
954 session = openSession();
955
956 AssetEntry[] array = new AssetEntryImpl[3];
957
958 array[0] = getByCompanyId_PrevAndNext(session, assetEntry,
959 companyId, orderByComparator, true);
960
961 array[1] = assetEntry;
962
963 array[2] = getByCompanyId_PrevAndNext(session, assetEntry,
964 companyId, orderByComparator, false);
965
966 return array;
967 }
968 catch (Exception e) {
969 throw processException(e);
970 }
971 finally {
972 closeSession(session);
973 }
974 }
975
976 protected AssetEntry getByCompanyId_PrevAndNext(Session session,
977 AssetEntry assetEntry, long companyId,
978 OrderByComparator orderByComparator, boolean previous) {
979 StringBundler query = null;
980
981 if (orderByComparator != null) {
982 query = new StringBundler(6 +
983 (orderByComparator.getOrderByFields().length * 6));
984 }
985 else {
986 query = new StringBundler(3);
987 }
988
989 query.append(_SQL_SELECT_ASSETENTRY_WHERE);
990
991 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
992
993 if (orderByComparator != null) {
994 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
995
996 if (orderByConditionFields.length > 0) {
997 query.append(WHERE_AND);
998 }
999
1000 for (int i = 0; i < orderByConditionFields.length; i++) {
1001 query.append(_ORDER_BY_ENTITY_ALIAS);
1002 query.append(orderByConditionFields[i]);
1003
1004 if ((i + 1) < orderByConditionFields.length) {
1005 if (orderByComparator.isAscending() ^ previous) {
1006 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1007 }
1008 else {
1009 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1010 }
1011 }
1012 else {
1013 if (orderByComparator.isAscending() ^ previous) {
1014 query.append(WHERE_GREATER_THAN);
1015 }
1016 else {
1017 query.append(WHERE_LESSER_THAN);
1018 }
1019 }
1020 }
1021
1022 query.append(ORDER_BY_CLAUSE);
1023
1024 String[] orderByFields = orderByComparator.getOrderByFields();
1025
1026 for (int i = 0; i < orderByFields.length; i++) {
1027 query.append(_ORDER_BY_ENTITY_ALIAS);
1028 query.append(orderByFields[i]);
1029
1030 if ((i + 1) < orderByFields.length) {
1031 if (orderByComparator.isAscending() ^ previous) {
1032 query.append(ORDER_BY_ASC_HAS_NEXT);
1033 }
1034 else {
1035 query.append(ORDER_BY_DESC_HAS_NEXT);
1036 }
1037 }
1038 else {
1039 if (orderByComparator.isAscending() ^ previous) {
1040 query.append(ORDER_BY_ASC);
1041 }
1042 else {
1043 query.append(ORDER_BY_DESC);
1044 }
1045 }
1046 }
1047 }
1048
1049 String sql = query.toString();
1050
1051 Query q = session.createQuery(sql);
1052
1053 q.setFirstResult(0);
1054 q.setMaxResults(2);
1055
1056 QueryPos qPos = QueryPos.getInstance(q);
1057
1058 qPos.add(companyId);
1059
1060 if (orderByComparator != null) {
1061 Object[] values = orderByComparator.getOrderByConditionValues(assetEntry);
1062
1063 for (Object value : values) {
1064 qPos.add(value);
1065 }
1066 }
1067
1068 List<AssetEntry> list = q.list();
1069
1070 if (list.size() == 2) {
1071 return list.get(1);
1072 }
1073 else {
1074 return null;
1075 }
1076 }
1077
1078
1085 public List<AssetEntry> findByVisible(boolean visible)
1086 throws SystemException {
1087 return findByVisible(visible, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1088 }
1089
1090
1103 public List<AssetEntry> findByVisible(boolean visible, int start, int end)
1104 throws SystemException {
1105 return findByVisible(visible, start, end, null);
1106 }
1107
1108
1122 public List<AssetEntry> findByVisible(boolean visible, int start, int end,
1123 OrderByComparator orderByComparator) throws SystemException {
1124 FinderPath finderPath = null;
1125 Object[] finderArgs = null;
1126
1127 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1128 (orderByComparator == null)) {
1129 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_VISIBLE;
1130 finderArgs = new Object[] { visible };
1131 }
1132 else {
1133 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_VISIBLE;
1134 finderArgs = new Object[] { visible, start, end, orderByComparator };
1135 }
1136
1137 List<AssetEntry> list = (List<AssetEntry>)FinderCacheUtil.getResult(finderPath,
1138 finderArgs, this);
1139
1140 if (list == null) {
1141 StringBundler query = null;
1142
1143 if (orderByComparator != null) {
1144 query = new StringBundler(3 +
1145 (orderByComparator.getOrderByFields().length * 3));
1146 }
1147 else {
1148 query = new StringBundler(2);
1149 }
1150
1151 query.append(_SQL_SELECT_ASSETENTRY_WHERE);
1152
1153 query.append(_FINDER_COLUMN_VISIBLE_VISIBLE_2);
1154
1155 if (orderByComparator != null) {
1156 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1157 orderByComparator);
1158 }
1159
1160 String sql = query.toString();
1161
1162 Session session = null;
1163
1164 try {
1165 session = openSession();
1166
1167 Query q = session.createQuery(sql);
1168
1169 QueryPos qPos = QueryPos.getInstance(q);
1170
1171 qPos.add(visible);
1172
1173 list = (List<AssetEntry>)QueryUtil.list(q, getDialect(), start,
1174 end);
1175 }
1176 catch (Exception e) {
1177 throw processException(e);
1178 }
1179 finally {
1180 if (list == null) {
1181 FinderCacheUtil.removeResult(finderPath, finderArgs);
1182 }
1183 else {
1184 cacheResult(list);
1185
1186 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1187 }
1188
1189 closeSession(session);
1190 }
1191 }
1192
1193 return list;
1194 }
1195
1196
1209 public AssetEntry findByVisible_First(boolean visible,
1210 OrderByComparator orderByComparator)
1211 throws NoSuchEntryException, SystemException {
1212 List<AssetEntry> list = findByVisible(visible, 0, 1, orderByComparator);
1213
1214 if (list.isEmpty()) {
1215 StringBundler msg = new StringBundler(4);
1216
1217 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1218
1219 msg.append("visible=");
1220 msg.append(visible);
1221
1222 msg.append(StringPool.CLOSE_CURLY_BRACE);
1223
1224 throw new NoSuchEntryException(msg.toString());
1225 }
1226 else {
1227 return list.get(0);
1228 }
1229 }
1230
1231
1244 public AssetEntry findByVisible_Last(boolean visible,
1245 OrderByComparator orderByComparator)
1246 throws NoSuchEntryException, SystemException {
1247 int count = countByVisible(visible);
1248
1249 List<AssetEntry> list = findByVisible(visible, count - 1, count,
1250 orderByComparator);
1251
1252 if (list.isEmpty()) {
1253 StringBundler msg = new StringBundler(4);
1254
1255 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1256
1257 msg.append("visible=");
1258 msg.append(visible);
1259
1260 msg.append(StringPool.CLOSE_CURLY_BRACE);
1261
1262 throw new NoSuchEntryException(msg.toString());
1263 }
1264 else {
1265 return list.get(0);
1266 }
1267 }
1268
1269
1283 public AssetEntry[] findByVisible_PrevAndNext(long entryId,
1284 boolean visible, OrderByComparator orderByComparator)
1285 throws NoSuchEntryException, SystemException {
1286 AssetEntry assetEntry = findByPrimaryKey(entryId);
1287
1288 Session session = null;
1289
1290 try {
1291 session = openSession();
1292
1293 AssetEntry[] array = new AssetEntryImpl[3];
1294
1295 array[0] = getByVisible_PrevAndNext(session, assetEntry, visible,
1296 orderByComparator, true);
1297
1298 array[1] = assetEntry;
1299
1300 array[2] = getByVisible_PrevAndNext(session, assetEntry, visible,
1301 orderByComparator, false);
1302
1303 return array;
1304 }
1305 catch (Exception e) {
1306 throw processException(e);
1307 }
1308 finally {
1309 closeSession(session);
1310 }
1311 }
1312
1313 protected AssetEntry getByVisible_PrevAndNext(Session session,
1314 AssetEntry assetEntry, boolean visible,
1315 OrderByComparator orderByComparator, boolean previous) {
1316 StringBundler query = null;
1317
1318 if (orderByComparator != null) {
1319 query = new StringBundler(6 +
1320 (orderByComparator.getOrderByFields().length * 6));
1321 }
1322 else {
1323 query = new StringBundler(3);
1324 }
1325
1326 query.append(_SQL_SELECT_ASSETENTRY_WHERE);
1327
1328 query.append(_FINDER_COLUMN_VISIBLE_VISIBLE_2);
1329
1330 if (orderByComparator != null) {
1331 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1332
1333 if (orderByConditionFields.length > 0) {
1334 query.append(WHERE_AND);
1335 }
1336
1337 for (int i = 0; i < orderByConditionFields.length; i++) {
1338 query.append(_ORDER_BY_ENTITY_ALIAS);
1339 query.append(orderByConditionFields[i]);
1340
1341 if ((i + 1) < orderByConditionFields.length) {
1342 if (orderByComparator.isAscending() ^ previous) {
1343 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1344 }
1345 else {
1346 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1347 }
1348 }
1349 else {
1350 if (orderByComparator.isAscending() ^ previous) {
1351 query.append(WHERE_GREATER_THAN);
1352 }
1353 else {
1354 query.append(WHERE_LESSER_THAN);
1355 }
1356 }
1357 }
1358
1359 query.append(ORDER_BY_CLAUSE);
1360
1361 String[] orderByFields = orderByComparator.getOrderByFields();
1362
1363 for (int i = 0; i < orderByFields.length; i++) {
1364 query.append(_ORDER_BY_ENTITY_ALIAS);
1365 query.append(orderByFields[i]);
1366
1367 if ((i + 1) < orderByFields.length) {
1368 if (orderByComparator.isAscending() ^ previous) {
1369 query.append(ORDER_BY_ASC_HAS_NEXT);
1370 }
1371 else {
1372 query.append(ORDER_BY_DESC_HAS_NEXT);
1373 }
1374 }
1375 else {
1376 if (orderByComparator.isAscending() ^ previous) {
1377 query.append(ORDER_BY_ASC);
1378 }
1379 else {
1380 query.append(ORDER_BY_DESC);
1381 }
1382 }
1383 }
1384 }
1385
1386 String sql = query.toString();
1387
1388 Query q = session.createQuery(sql);
1389
1390 q.setFirstResult(0);
1391 q.setMaxResults(2);
1392
1393 QueryPos qPos = QueryPos.getInstance(q);
1394
1395 qPos.add(visible);
1396
1397 if (orderByComparator != null) {
1398 Object[] values = orderByComparator.getOrderByConditionValues(assetEntry);
1399
1400 for (Object value : values) {
1401 qPos.add(value);
1402 }
1403 }
1404
1405 List<AssetEntry> list = q.list();
1406
1407 if (list.size() == 2) {
1408 return list.get(1);
1409 }
1410 else {
1411 return null;
1412 }
1413 }
1414
1415
1422 public List<AssetEntry> findByPublishDate(Date publishDate)
1423 throws SystemException {
1424 return findByPublishDate(publishDate, QueryUtil.ALL_POS,
1425 QueryUtil.ALL_POS, null);
1426 }
1427
1428
1441 public List<AssetEntry> findByPublishDate(Date publishDate, int start,
1442 int end) throws SystemException {
1443 return findByPublishDate(publishDate, start, end, null);
1444 }
1445
1446
1460 public List<AssetEntry> findByPublishDate(Date publishDate, int start,
1461 int end, OrderByComparator orderByComparator) throws SystemException {
1462 FinderPath finderPath = null;
1463 Object[] finderArgs = null;
1464
1465 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1466 (orderByComparator == null)) {
1467 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_PUBLISHDATE;
1468 finderArgs = new Object[] { publishDate };
1469 }
1470 else {
1471 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_PUBLISHDATE;
1472 finderArgs = new Object[] { publishDate, start, end, orderByComparator };
1473 }
1474
1475 List<AssetEntry> list = (List<AssetEntry>)FinderCacheUtil.getResult(finderPath,
1476 finderArgs, this);
1477
1478 if (list == null) {
1479 StringBundler query = null;
1480
1481 if (orderByComparator != null) {
1482 query = new StringBundler(3 +
1483 (orderByComparator.getOrderByFields().length * 3));
1484 }
1485 else {
1486 query = new StringBundler(2);
1487 }
1488
1489 query.append(_SQL_SELECT_ASSETENTRY_WHERE);
1490
1491 if (publishDate == null) {
1492 query.append(_FINDER_COLUMN_PUBLISHDATE_PUBLISHDATE_1);
1493 }
1494 else {
1495 query.append(_FINDER_COLUMN_PUBLISHDATE_PUBLISHDATE_2);
1496 }
1497
1498 if (orderByComparator != null) {
1499 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1500 orderByComparator);
1501 }
1502
1503 String sql = query.toString();
1504
1505 Session session = null;
1506
1507 try {
1508 session = openSession();
1509
1510 Query q = session.createQuery(sql);
1511
1512 QueryPos qPos = QueryPos.getInstance(q);
1513
1514 if (publishDate != null) {
1515 qPos.add(CalendarUtil.getTimestamp(publishDate));
1516 }
1517
1518 list = (List<AssetEntry>)QueryUtil.list(q, getDialect(), start,
1519 end);
1520 }
1521 catch (Exception e) {
1522 throw processException(e);
1523 }
1524 finally {
1525 if (list == null) {
1526 FinderCacheUtil.removeResult(finderPath, finderArgs);
1527 }
1528 else {
1529 cacheResult(list);
1530
1531 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1532 }
1533
1534 closeSession(session);
1535 }
1536 }
1537
1538 return list;
1539 }
1540
1541
1554 public AssetEntry findByPublishDate_First(Date publishDate,
1555 OrderByComparator orderByComparator)
1556 throws NoSuchEntryException, SystemException {
1557 List<AssetEntry> list = findByPublishDate(publishDate, 0, 1,
1558 orderByComparator);
1559
1560 if (list.isEmpty()) {
1561 StringBundler msg = new StringBundler(4);
1562
1563 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1564
1565 msg.append("publishDate=");
1566 msg.append(publishDate);
1567
1568 msg.append(StringPool.CLOSE_CURLY_BRACE);
1569
1570 throw new NoSuchEntryException(msg.toString());
1571 }
1572 else {
1573 return list.get(0);
1574 }
1575 }
1576
1577
1590 public AssetEntry findByPublishDate_Last(Date publishDate,
1591 OrderByComparator orderByComparator)
1592 throws NoSuchEntryException, SystemException {
1593 int count = countByPublishDate(publishDate);
1594
1595 List<AssetEntry> list = findByPublishDate(publishDate, count - 1,
1596 count, orderByComparator);
1597
1598 if (list.isEmpty()) {
1599 StringBundler msg = new StringBundler(4);
1600
1601 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1602
1603 msg.append("publishDate=");
1604 msg.append(publishDate);
1605
1606 msg.append(StringPool.CLOSE_CURLY_BRACE);
1607
1608 throw new NoSuchEntryException(msg.toString());
1609 }
1610 else {
1611 return list.get(0);
1612 }
1613 }
1614
1615
1629 public AssetEntry[] findByPublishDate_PrevAndNext(long entryId,
1630 Date publishDate, OrderByComparator orderByComparator)
1631 throws NoSuchEntryException, SystemException {
1632 AssetEntry assetEntry = findByPrimaryKey(entryId);
1633
1634 Session session = null;
1635
1636 try {
1637 session = openSession();
1638
1639 AssetEntry[] array = new AssetEntryImpl[3];
1640
1641 array[0] = getByPublishDate_PrevAndNext(session, assetEntry,
1642 publishDate, orderByComparator, true);
1643
1644 array[1] = assetEntry;
1645
1646 array[2] = getByPublishDate_PrevAndNext(session, assetEntry,
1647 publishDate, orderByComparator, false);
1648
1649 return array;
1650 }
1651 catch (Exception e) {
1652 throw processException(e);
1653 }
1654 finally {
1655 closeSession(session);
1656 }
1657 }
1658
1659 protected AssetEntry getByPublishDate_PrevAndNext(Session session,
1660 AssetEntry assetEntry, Date publishDate,
1661 OrderByComparator orderByComparator, boolean previous) {
1662 StringBundler query = null;
1663
1664 if (orderByComparator != null) {
1665 query = new StringBundler(6 +
1666 (orderByComparator.getOrderByFields().length * 6));
1667 }
1668 else {
1669 query = new StringBundler(3);
1670 }
1671
1672 query.append(_SQL_SELECT_ASSETENTRY_WHERE);
1673
1674 if (publishDate == null) {
1675 query.append(_FINDER_COLUMN_PUBLISHDATE_PUBLISHDATE_1);
1676 }
1677 else {
1678 query.append(_FINDER_COLUMN_PUBLISHDATE_PUBLISHDATE_2);
1679 }
1680
1681 if (orderByComparator != null) {
1682 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1683
1684 if (orderByConditionFields.length > 0) {
1685 query.append(WHERE_AND);
1686 }
1687
1688 for (int i = 0; i < orderByConditionFields.length; i++) {
1689 query.append(_ORDER_BY_ENTITY_ALIAS);
1690 query.append(orderByConditionFields[i]);
1691
1692 if ((i + 1) < orderByConditionFields.length) {
1693 if (orderByComparator.isAscending() ^ previous) {
1694 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1695 }
1696 else {
1697 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1698 }
1699 }
1700 else {
1701 if (orderByComparator.isAscending() ^ previous) {
1702 query.append(WHERE_GREATER_THAN);
1703 }
1704 else {
1705 query.append(WHERE_LESSER_THAN);
1706 }
1707 }
1708 }
1709
1710 query.append(ORDER_BY_CLAUSE);
1711
1712 String[] orderByFields = orderByComparator.getOrderByFields();
1713
1714 for (int i = 0; i < orderByFields.length; i++) {
1715 query.append(_ORDER_BY_ENTITY_ALIAS);
1716 query.append(orderByFields[i]);
1717
1718 if ((i + 1) < orderByFields.length) {
1719 if (orderByComparator.isAscending() ^ previous) {
1720 query.append(ORDER_BY_ASC_HAS_NEXT);
1721 }
1722 else {
1723 query.append(ORDER_BY_DESC_HAS_NEXT);
1724 }
1725 }
1726 else {
1727 if (orderByComparator.isAscending() ^ previous) {
1728 query.append(ORDER_BY_ASC);
1729 }
1730 else {
1731 query.append(ORDER_BY_DESC);
1732 }
1733 }
1734 }
1735 }
1736
1737 String sql = query.toString();
1738
1739 Query q = session.createQuery(sql);
1740
1741 q.setFirstResult(0);
1742 q.setMaxResults(2);
1743
1744 QueryPos qPos = QueryPos.getInstance(q);
1745
1746 if (publishDate != null) {
1747 qPos.add(CalendarUtil.getTimestamp(publishDate));
1748 }
1749
1750 if (orderByComparator != null) {
1751 Object[] values = orderByComparator.getOrderByConditionValues(assetEntry);
1752
1753 for (Object value : values) {
1754 qPos.add(value);
1755 }
1756 }
1757
1758 List<AssetEntry> list = q.list();
1759
1760 if (list.size() == 2) {
1761 return list.get(1);
1762 }
1763 else {
1764 return null;
1765 }
1766 }
1767
1768
1775 public List<AssetEntry> findByExpirationDate(Date expirationDate)
1776 throws SystemException {
1777 return findByExpirationDate(expirationDate, QueryUtil.ALL_POS,
1778 QueryUtil.ALL_POS, null);
1779 }
1780
1781
1794 public List<AssetEntry> findByExpirationDate(Date expirationDate,
1795 int start, int end) throws SystemException {
1796 return findByExpirationDate(expirationDate, start, end, null);
1797 }
1798
1799
1813 public List<AssetEntry> findByExpirationDate(Date expirationDate,
1814 int start, int end, OrderByComparator orderByComparator)
1815 throws SystemException {
1816 FinderPath finderPath = null;
1817 Object[] finderArgs = null;
1818
1819 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1820 (orderByComparator == null)) {
1821 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_EXPIRATIONDATE;
1822 finderArgs = new Object[] { expirationDate };
1823 }
1824 else {
1825 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_EXPIRATIONDATE;
1826 finderArgs = new Object[] {
1827 expirationDate,
1828
1829 start, end, orderByComparator
1830 };
1831 }
1832
1833 List<AssetEntry> list = (List<AssetEntry>)FinderCacheUtil.getResult(finderPath,
1834 finderArgs, this);
1835
1836 if (list == null) {
1837 StringBundler query = null;
1838
1839 if (orderByComparator != null) {
1840 query = new StringBundler(3 +
1841 (orderByComparator.getOrderByFields().length * 3));
1842 }
1843 else {
1844 query = new StringBundler(2);
1845 }
1846
1847 query.append(_SQL_SELECT_ASSETENTRY_WHERE);
1848
1849 if (expirationDate == null) {
1850 query.append(_FINDER_COLUMN_EXPIRATIONDATE_EXPIRATIONDATE_1);
1851 }
1852 else {
1853 query.append(_FINDER_COLUMN_EXPIRATIONDATE_EXPIRATIONDATE_2);
1854 }
1855
1856 if (orderByComparator != null) {
1857 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1858 orderByComparator);
1859 }
1860
1861 String sql = query.toString();
1862
1863 Session session = null;
1864
1865 try {
1866 session = openSession();
1867
1868 Query q = session.createQuery(sql);
1869
1870 QueryPos qPos = QueryPos.getInstance(q);
1871
1872 if (expirationDate != null) {
1873 qPos.add(CalendarUtil.getTimestamp(expirationDate));
1874 }
1875
1876 list = (List<AssetEntry>)QueryUtil.list(q, getDialect(), start,
1877 end);
1878 }
1879 catch (Exception e) {
1880 throw processException(e);
1881 }
1882 finally {
1883 if (list == null) {
1884 FinderCacheUtil.removeResult(finderPath, finderArgs);
1885 }
1886 else {
1887 cacheResult(list);
1888
1889 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1890 }
1891
1892 closeSession(session);
1893 }
1894 }
1895
1896 return list;
1897 }
1898
1899
1912 public AssetEntry findByExpirationDate_First(Date expirationDate,
1913 OrderByComparator orderByComparator)
1914 throws NoSuchEntryException, SystemException {
1915 List<AssetEntry> list = findByExpirationDate(expirationDate, 0, 1,
1916 orderByComparator);
1917
1918 if (list.isEmpty()) {
1919 StringBundler msg = new StringBundler(4);
1920
1921 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1922
1923 msg.append("expirationDate=");
1924 msg.append(expirationDate);
1925
1926 msg.append(StringPool.CLOSE_CURLY_BRACE);
1927
1928 throw new NoSuchEntryException(msg.toString());
1929 }
1930 else {
1931 return list.get(0);
1932 }
1933 }
1934
1935
1948 public AssetEntry findByExpirationDate_Last(Date expirationDate,
1949 OrderByComparator orderByComparator)
1950 throws NoSuchEntryException, SystemException {
1951 int count = countByExpirationDate(expirationDate);
1952
1953 List<AssetEntry> list = findByExpirationDate(expirationDate, count - 1,
1954 count, orderByComparator);
1955
1956 if (list.isEmpty()) {
1957 StringBundler msg = new StringBundler(4);
1958
1959 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1960
1961 msg.append("expirationDate=");
1962 msg.append(expirationDate);
1963
1964 msg.append(StringPool.CLOSE_CURLY_BRACE);
1965
1966 throw new NoSuchEntryException(msg.toString());
1967 }
1968 else {
1969 return list.get(0);
1970 }
1971 }
1972
1973
1987 public AssetEntry[] findByExpirationDate_PrevAndNext(long entryId,
1988 Date expirationDate, OrderByComparator orderByComparator)
1989 throws NoSuchEntryException, SystemException {
1990 AssetEntry assetEntry = findByPrimaryKey(entryId);
1991
1992 Session session = null;
1993
1994 try {
1995 session = openSession();
1996
1997 AssetEntry[] array = new AssetEntryImpl[3];
1998
1999 array[0] = getByExpirationDate_PrevAndNext(session, assetEntry,
2000 expirationDate, orderByComparator, true);
2001
2002 array[1] = assetEntry;
2003
2004 array[2] = getByExpirationDate_PrevAndNext(session, assetEntry,
2005 expirationDate, orderByComparator, false);
2006
2007 return array;
2008 }
2009 catch (Exception e) {
2010 throw processException(e);
2011 }
2012 finally {
2013 closeSession(session);
2014 }
2015 }
2016
2017 protected AssetEntry getByExpirationDate_PrevAndNext(Session session,
2018 AssetEntry assetEntry, Date expirationDate,
2019 OrderByComparator orderByComparator, boolean previous) {
2020 StringBundler query = null;
2021
2022 if (orderByComparator != null) {
2023 query = new StringBundler(6 +
2024 (orderByComparator.getOrderByFields().length * 6));
2025 }
2026 else {
2027 query = new StringBundler(3);
2028 }
2029
2030 query.append(_SQL_SELECT_ASSETENTRY_WHERE);
2031
2032 if (expirationDate == null) {
2033 query.append(_FINDER_COLUMN_EXPIRATIONDATE_EXPIRATIONDATE_1);
2034 }
2035 else {
2036 query.append(_FINDER_COLUMN_EXPIRATIONDATE_EXPIRATIONDATE_2);
2037 }
2038
2039 if (orderByComparator != null) {
2040 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2041
2042 if (orderByConditionFields.length > 0) {
2043 query.append(WHERE_AND);
2044 }
2045
2046 for (int i = 0; i < orderByConditionFields.length; i++) {
2047 query.append(_ORDER_BY_ENTITY_ALIAS);
2048 query.append(orderByConditionFields[i]);
2049
2050 if ((i + 1) < orderByConditionFields.length) {
2051 if (orderByComparator.isAscending() ^ previous) {
2052 query.append(WHERE_GREATER_THAN_HAS_NEXT);
2053 }
2054 else {
2055 query.append(WHERE_LESSER_THAN_HAS_NEXT);
2056 }
2057 }
2058 else {
2059 if (orderByComparator.isAscending() ^ previous) {
2060 query.append(WHERE_GREATER_THAN);
2061 }
2062 else {
2063 query.append(WHERE_LESSER_THAN);
2064 }
2065 }
2066 }
2067
2068 query.append(ORDER_BY_CLAUSE);
2069
2070 String[] orderByFields = orderByComparator.getOrderByFields();
2071
2072 for (int i = 0; i < orderByFields.length; i++) {
2073 query.append(_ORDER_BY_ENTITY_ALIAS);
2074 query.append(orderByFields[i]);
2075
2076 if ((i + 1) < orderByFields.length) {
2077 if (orderByComparator.isAscending() ^ previous) {
2078 query.append(ORDER_BY_ASC_HAS_NEXT);
2079 }
2080 else {
2081 query.append(ORDER_BY_DESC_HAS_NEXT);
2082 }
2083 }
2084 else {
2085 if (orderByComparator.isAscending() ^ previous) {
2086 query.append(ORDER_BY_ASC);
2087 }
2088 else {
2089 query.append(ORDER_BY_DESC);
2090 }
2091 }
2092 }
2093 }
2094
2095 String sql = query.toString();
2096
2097 Query q = session.createQuery(sql);
2098
2099 q.setFirstResult(0);
2100 q.setMaxResults(2);
2101
2102 QueryPos qPos = QueryPos.getInstance(q);
2103
2104 if (expirationDate != null) {
2105 qPos.add(CalendarUtil.getTimestamp(expirationDate));
2106 }
2107
2108 if (orderByComparator != null) {
2109 Object[] values = orderByComparator.getOrderByConditionValues(assetEntry);
2110
2111 for (Object value : values) {
2112 qPos.add(value);
2113 }
2114 }
2115
2116 List<AssetEntry> list = q.list();
2117
2118 if (list.size() == 2) {
2119 return list.get(1);
2120 }
2121 else {
2122 return null;
2123 }
2124 }
2125
2126
2135 public AssetEntry findByG_CU(long groupId, String classUuid)
2136 throws NoSuchEntryException, SystemException {
2137 AssetEntry assetEntry = fetchByG_CU(groupId, classUuid);
2138
2139 if (assetEntry == null) {
2140 StringBundler msg = new StringBundler(6);
2141
2142 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2143
2144 msg.append("groupId=");
2145 msg.append(groupId);
2146
2147 msg.append(", classUuid=");
2148 msg.append(classUuid);
2149
2150 msg.append(StringPool.CLOSE_CURLY_BRACE);
2151
2152 if (_log.isWarnEnabled()) {
2153 _log.warn(msg.toString());
2154 }
2155
2156 throw new NoSuchEntryException(msg.toString());
2157 }
2158
2159 return assetEntry;
2160 }
2161
2162
2170 public AssetEntry fetchByG_CU(long groupId, String classUuid)
2171 throws SystemException {
2172 return fetchByG_CU(groupId, classUuid, true);
2173 }
2174
2175
2184 public AssetEntry fetchByG_CU(long groupId, String classUuid,
2185 boolean retrieveFromCache) throws SystemException {
2186 Object[] finderArgs = new Object[] { groupId, classUuid };
2187
2188 Object result = null;
2189
2190 if (retrieveFromCache) {
2191 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_G_CU,
2192 finderArgs, this);
2193 }
2194
2195 if (result == null) {
2196 StringBundler query = new StringBundler(3);
2197
2198 query.append(_SQL_SELECT_ASSETENTRY_WHERE);
2199
2200 query.append(_FINDER_COLUMN_G_CU_GROUPID_2);
2201
2202 if (classUuid == null) {
2203 query.append(_FINDER_COLUMN_G_CU_CLASSUUID_1);
2204 }
2205 else {
2206 if (classUuid.equals(StringPool.BLANK)) {
2207 query.append(_FINDER_COLUMN_G_CU_CLASSUUID_3);
2208 }
2209 else {
2210 query.append(_FINDER_COLUMN_G_CU_CLASSUUID_2);
2211 }
2212 }
2213
2214 String sql = query.toString();
2215
2216 Session session = null;
2217
2218 try {
2219 session = openSession();
2220
2221 Query q = session.createQuery(sql);
2222
2223 QueryPos qPos = QueryPos.getInstance(q);
2224
2225 qPos.add(groupId);
2226
2227 if (classUuid != null) {
2228 qPos.add(classUuid);
2229 }
2230
2231 List<AssetEntry> list = q.list();
2232
2233 result = list;
2234
2235 AssetEntry assetEntry = null;
2236
2237 if (list.isEmpty()) {
2238 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_CU,
2239 finderArgs, list);
2240 }
2241 else {
2242 assetEntry = list.get(0);
2243
2244 cacheResult(assetEntry);
2245
2246 if ((assetEntry.getGroupId() != groupId) ||
2247 (assetEntry.getClassUuid() == null) ||
2248 !assetEntry.getClassUuid().equals(classUuid)) {
2249 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_CU,
2250 finderArgs, assetEntry);
2251 }
2252 }
2253
2254 return assetEntry;
2255 }
2256 catch (Exception e) {
2257 throw processException(e);
2258 }
2259 finally {
2260 if (result == null) {
2261 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_CU,
2262 finderArgs);
2263 }
2264
2265 closeSession(session);
2266 }
2267 }
2268 else {
2269 if (result instanceof List<?>) {
2270 return null;
2271 }
2272 else {
2273 return (AssetEntry)result;
2274 }
2275 }
2276 }
2277
2278
2287 public AssetEntry findByC_C(long classNameId, long classPK)
2288 throws NoSuchEntryException, SystemException {
2289 AssetEntry assetEntry = fetchByC_C(classNameId, classPK);
2290
2291 if (assetEntry == null) {
2292 StringBundler msg = new StringBundler(6);
2293
2294 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2295
2296 msg.append("classNameId=");
2297 msg.append(classNameId);
2298
2299 msg.append(", classPK=");
2300 msg.append(classPK);
2301
2302 msg.append(StringPool.CLOSE_CURLY_BRACE);
2303
2304 if (_log.isWarnEnabled()) {
2305 _log.warn(msg.toString());
2306 }
2307
2308 throw new NoSuchEntryException(msg.toString());
2309 }
2310
2311 return assetEntry;
2312 }
2313
2314
2322 public AssetEntry fetchByC_C(long classNameId, long classPK)
2323 throws SystemException {
2324 return fetchByC_C(classNameId, classPK, true);
2325 }
2326
2327
2336 public AssetEntry fetchByC_C(long classNameId, long classPK,
2337 boolean retrieveFromCache) throws SystemException {
2338 Object[] finderArgs = new Object[] { classNameId, classPK };
2339
2340 Object result = null;
2341
2342 if (retrieveFromCache) {
2343 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_C_C,
2344 finderArgs, this);
2345 }
2346
2347 if (result == null) {
2348 StringBundler query = new StringBundler(3);
2349
2350 query.append(_SQL_SELECT_ASSETENTRY_WHERE);
2351
2352 query.append(_FINDER_COLUMN_C_C_CLASSNAMEID_2);
2353
2354 query.append(_FINDER_COLUMN_C_C_CLASSPK_2);
2355
2356 String sql = query.toString();
2357
2358 Session session = null;
2359
2360 try {
2361 session = openSession();
2362
2363 Query q = session.createQuery(sql);
2364
2365 QueryPos qPos = QueryPos.getInstance(q);
2366
2367 qPos.add(classNameId);
2368
2369 qPos.add(classPK);
2370
2371 List<AssetEntry> list = q.list();
2372
2373 result = list;
2374
2375 AssetEntry assetEntry = null;
2376
2377 if (list.isEmpty()) {
2378 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C,
2379 finderArgs, list);
2380 }
2381 else {
2382 assetEntry = list.get(0);
2383
2384 cacheResult(assetEntry);
2385
2386 if ((assetEntry.getClassNameId() != classNameId) ||
2387 (assetEntry.getClassPK() != classPK)) {
2388 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C,
2389 finderArgs, assetEntry);
2390 }
2391 }
2392
2393 return assetEntry;
2394 }
2395 catch (Exception e) {
2396 throw processException(e);
2397 }
2398 finally {
2399 if (result == null) {
2400 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_C,
2401 finderArgs);
2402 }
2403
2404 closeSession(session);
2405 }
2406 }
2407 else {
2408 if (result instanceof List<?>) {
2409 return null;
2410 }
2411 else {
2412 return (AssetEntry)result;
2413 }
2414 }
2415 }
2416
2417
2423 public List<AssetEntry> findAll() throws SystemException {
2424 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
2425 }
2426
2427
2439 public List<AssetEntry> findAll(int start, int end)
2440 throws SystemException {
2441 return findAll(start, end, null);
2442 }
2443
2444
2457 public List<AssetEntry> findAll(int start, int end,
2458 OrderByComparator orderByComparator) throws SystemException {
2459 FinderPath finderPath = null;
2460 Object[] finderArgs = new Object[] { start, end, orderByComparator };
2461
2462 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2463 (orderByComparator == null)) {
2464 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
2465 finderArgs = FINDER_ARGS_EMPTY;
2466 }
2467 else {
2468 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
2469 finderArgs = new Object[] { start, end, orderByComparator };
2470 }
2471
2472 List<AssetEntry> list = (List<AssetEntry>)FinderCacheUtil.getResult(finderPath,
2473 finderArgs, this);
2474
2475 if (list == null) {
2476 StringBundler query = null;
2477 String sql = null;
2478
2479 if (orderByComparator != null) {
2480 query = new StringBundler(2 +
2481 (orderByComparator.getOrderByFields().length * 3));
2482
2483 query.append(_SQL_SELECT_ASSETENTRY);
2484
2485 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2486 orderByComparator);
2487
2488 sql = query.toString();
2489 }
2490 else {
2491 sql = _SQL_SELECT_ASSETENTRY;
2492 }
2493
2494 Session session = null;
2495
2496 try {
2497 session = openSession();
2498
2499 Query q = session.createQuery(sql);
2500
2501 if (orderByComparator == null) {
2502 list = (List<AssetEntry>)QueryUtil.list(q, getDialect(),
2503 start, end, false);
2504
2505 Collections.sort(list);
2506 }
2507 else {
2508 list = (List<AssetEntry>)QueryUtil.list(q, getDialect(),
2509 start, end);
2510 }
2511 }
2512 catch (Exception e) {
2513 throw processException(e);
2514 }
2515 finally {
2516 if (list == null) {
2517 FinderCacheUtil.removeResult(finderPath, finderArgs);
2518 }
2519 else {
2520 cacheResult(list);
2521
2522 FinderCacheUtil.putResult(finderPath, finderArgs, list);
2523 }
2524
2525 closeSession(session);
2526 }
2527 }
2528
2529 return list;
2530 }
2531
2532
2538 public void removeByCompanyId(long companyId) throws SystemException {
2539 for (AssetEntry assetEntry : findByCompanyId(companyId)) {
2540 remove(assetEntry);
2541 }
2542 }
2543
2544
2550 public void removeByVisible(boolean visible) throws SystemException {
2551 for (AssetEntry assetEntry : findByVisible(visible)) {
2552 remove(assetEntry);
2553 }
2554 }
2555
2556
2562 public void removeByPublishDate(Date publishDate) throws SystemException {
2563 for (AssetEntry assetEntry : findByPublishDate(publishDate)) {
2564 remove(assetEntry);
2565 }
2566 }
2567
2568
2574 public void removeByExpirationDate(Date expirationDate)
2575 throws SystemException {
2576 for (AssetEntry assetEntry : findByExpirationDate(expirationDate)) {
2577 remove(assetEntry);
2578 }
2579 }
2580
2581
2588 public void removeByG_CU(long groupId, String classUuid)
2589 throws NoSuchEntryException, SystemException {
2590 AssetEntry assetEntry = findByG_CU(groupId, classUuid);
2591
2592 remove(assetEntry);
2593 }
2594
2595
2602 public void removeByC_C(long classNameId, long classPK)
2603 throws NoSuchEntryException, SystemException {
2604 AssetEntry assetEntry = findByC_C(classNameId, classPK);
2605
2606 remove(assetEntry);
2607 }
2608
2609
2614 public void removeAll() throws SystemException {
2615 for (AssetEntry assetEntry : findAll()) {
2616 remove(assetEntry);
2617 }
2618 }
2619
2620
2627 public int countByCompanyId(long companyId) throws SystemException {
2628 Object[] finderArgs = new Object[] { companyId };
2629
2630 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_COMPANYID,
2631 finderArgs, this);
2632
2633 if (count == null) {
2634 StringBundler query = new StringBundler(2);
2635
2636 query.append(_SQL_COUNT_ASSETENTRY_WHERE);
2637
2638 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
2639
2640 String sql = query.toString();
2641
2642 Session session = null;
2643
2644 try {
2645 session = openSession();
2646
2647 Query q = session.createQuery(sql);
2648
2649 QueryPos qPos = QueryPos.getInstance(q);
2650
2651 qPos.add(companyId);
2652
2653 count = (Long)q.uniqueResult();
2654 }
2655 catch (Exception e) {
2656 throw processException(e);
2657 }
2658 finally {
2659 if (count == null) {
2660 count = Long.valueOf(0);
2661 }
2662
2663 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_COMPANYID,
2664 finderArgs, count);
2665
2666 closeSession(session);
2667 }
2668 }
2669
2670 return count.intValue();
2671 }
2672
2673
2680 public int countByVisible(boolean visible) throws SystemException {
2681 Object[] finderArgs = new Object[] { visible };
2682
2683 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_VISIBLE,
2684 finderArgs, this);
2685
2686 if (count == null) {
2687 StringBundler query = new StringBundler(2);
2688
2689 query.append(_SQL_COUNT_ASSETENTRY_WHERE);
2690
2691 query.append(_FINDER_COLUMN_VISIBLE_VISIBLE_2);
2692
2693 String sql = query.toString();
2694
2695 Session session = null;
2696
2697 try {
2698 session = openSession();
2699
2700 Query q = session.createQuery(sql);
2701
2702 QueryPos qPos = QueryPos.getInstance(q);
2703
2704 qPos.add(visible);
2705
2706 count = (Long)q.uniqueResult();
2707 }
2708 catch (Exception e) {
2709 throw processException(e);
2710 }
2711 finally {
2712 if (count == null) {
2713 count = Long.valueOf(0);
2714 }
2715
2716 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_VISIBLE,
2717 finderArgs, count);
2718
2719 closeSession(session);
2720 }
2721 }
2722
2723 return count.intValue();
2724 }
2725
2726
2733 public int countByPublishDate(Date publishDate) throws SystemException {
2734 Object[] finderArgs = new Object[] { publishDate };
2735
2736 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_PUBLISHDATE,
2737 finderArgs, this);
2738
2739 if (count == null) {
2740 StringBundler query = new StringBundler(2);
2741
2742 query.append(_SQL_COUNT_ASSETENTRY_WHERE);
2743
2744 if (publishDate == null) {
2745 query.append(_FINDER_COLUMN_PUBLISHDATE_PUBLISHDATE_1);
2746 }
2747 else {
2748 query.append(_FINDER_COLUMN_PUBLISHDATE_PUBLISHDATE_2);
2749 }
2750
2751 String sql = query.toString();
2752
2753 Session session = null;
2754
2755 try {
2756 session = openSession();
2757
2758 Query q = session.createQuery(sql);
2759
2760 QueryPos qPos = QueryPos.getInstance(q);
2761
2762 if (publishDate != null) {
2763 qPos.add(CalendarUtil.getTimestamp(publishDate));
2764 }
2765
2766 count = (Long)q.uniqueResult();
2767 }
2768 catch (Exception e) {
2769 throw processException(e);
2770 }
2771 finally {
2772 if (count == null) {
2773 count = Long.valueOf(0);
2774 }
2775
2776 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_PUBLISHDATE,
2777 finderArgs, count);
2778
2779 closeSession(session);
2780 }
2781 }
2782
2783 return count.intValue();
2784 }
2785
2786
2793 public int countByExpirationDate(Date expirationDate)
2794 throws SystemException {
2795 Object[] finderArgs = new Object[] { expirationDate };
2796
2797 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_EXPIRATIONDATE,
2798 finderArgs, this);
2799
2800 if (count == null) {
2801 StringBundler query = new StringBundler(2);
2802
2803 query.append(_SQL_COUNT_ASSETENTRY_WHERE);
2804
2805 if (expirationDate == null) {
2806 query.append(_FINDER_COLUMN_EXPIRATIONDATE_EXPIRATIONDATE_1);
2807 }
2808 else {
2809 query.append(_FINDER_COLUMN_EXPIRATIONDATE_EXPIRATIONDATE_2);
2810 }
2811
2812 String sql = query.toString();
2813
2814 Session session = null;
2815
2816 try {
2817 session = openSession();
2818
2819 Query q = session.createQuery(sql);
2820
2821 QueryPos qPos = QueryPos.getInstance(q);
2822
2823 if (expirationDate != null) {
2824 qPos.add(CalendarUtil.getTimestamp(expirationDate));
2825 }
2826
2827 count = (Long)q.uniqueResult();
2828 }
2829 catch (Exception e) {
2830 throw processException(e);
2831 }
2832 finally {
2833 if (count == null) {
2834 count = Long.valueOf(0);
2835 }
2836
2837 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_EXPIRATIONDATE,
2838 finderArgs, count);
2839
2840 closeSession(session);
2841 }
2842 }
2843
2844 return count.intValue();
2845 }
2846
2847
2855 public int countByG_CU(long groupId, String classUuid)
2856 throws SystemException {
2857 Object[] finderArgs = new Object[] { groupId, classUuid };
2858
2859 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_CU,
2860 finderArgs, this);
2861
2862 if (count == null) {
2863 StringBundler query = new StringBundler(3);
2864
2865 query.append(_SQL_COUNT_ASSETENTRY_WHERE);
2866
2867 query.append(_FINDER_COLUMN_G_CU_GROUPID_2);
2868
2869 if (classUuid == null) {
2870 query.append(_FINDER_COLUMN_G_CU_CLASSUUID_1);
2871 }
2872 else {
2873 if (classUuid.equals(StringPool.BLANK)) {
2874 query.append(_FINDER_COLUMN_G_CU_CLASSUUID_3);
2875 }
2876 else {
2877 query.append(_FINDER_COLUMN_G_CU_CLASSUUID_2);
2878 }
2879 }
2880
2881 String sql = query.toString();
2882
2883 Session session = null;
2884
2885 try {
2886 session = openSession();
2887
2888 Query q = session.createQuery(sql);
2889
2890 QueryPos qPos = QueryPos.getInstance(q);
2891
2892 qPos.add(groupId);
2893
2894 if (classUuid != null) {
2895 qPos.add(classUuid);
2896 }
2897
2898 count = (Long)q.uniqueResult();
2899 }
2900 catch (Exception e) {
2901 throw processException(e);
2902 }
2903 finally {
2904 if (count == null) {
2905 count = Long.valueOf(0);
2906 }
2907
2908 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_CU,
2909 finderArgs, count);
2910
2911 closeSession(session);
2912 }
2913 }
2914
2915 return count.intValue();
2916 }
2917
2918
2926 public int countByC_C(long classNameId, long classPK)
2927 throws SystemException {
2928 Object[] finderArgs = new Object[] { classNameId, classPK };
2929
2930 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_C,
2931 finderArgs, this);
2932
2933 if (count == null) {
2934 StringBundler query = new StringBundler(3);
2935
2936 query.append(_SQL_COUNT_ASSETENTRY_WHERE);
2937
2938 query.append(_FINDER_COLUMN_C_C_CLASSNAMEID_2);
2939
2940 query.append(_FINDER_COLUMN_C_C_CLASSPK_2);
2941
2942 String sql = query.toString();
2943
2944 Session session = null;
2945
2946 try {
2947 session = openSession();
2948
2949 Query q = session.createQuery(sql);
2950
2951 QueryPos qPos = QueryPos.getInstance(q);
2952
2953 qPos.add(classNameId);
2954
2955 qPos.add(classPK);
2956
2957 count = (Long)q.uniqueResult();
2958 }
2959 catch (Exception e) {
2960 throw processException(e);
2961 }
2962 finally {
2963 if (count == null) {
2964 count = Long.valueOf(0);
2965 }
2966
2967 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_C, finderArgs,
2968 count);
2969
2970 closeSession(session);
2971 }
2972 }
2973
2974 return count.intValue();
2975 }
2976
2977
2983 public int countAll() throws SystemException {
2984 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
2985 FINDER_ARGS_EMPTY, this);
2986
2987 if (count == null) {
2988 Session session = null;
2989
2990 try {
2991 session = openSession();
2992
2993 Query q = session.createQuery(_SQL_COUNT_ASSETENTRY);
2994
2995 count = (Long)q.uniqueResult();
2996 }
2997 catch (Exception e) {
2998 throw processException(e);
2999 }
3000 finally {
3001 if (count == null) {
3002 count = Long.valueOf(0);
3003 }
3004
3005 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
3006 FINDER_ARGS_EMPTY, count);
3007
3008 closeSession(session);
3009 }
3010 }
3011
3012 return count.intValue();
3013 }
3014
3015
3022 public List<com.liferay.portlet.asset.model.AssetCategory> getAssetCategories(
3023 long pk) throws SystemException {
3024 return getAssetCategories(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
3025 }
3026
3027
3040 public List<com.liferay.portlet.asset.model.AssetCategory> getAssetCategories(
3041 long pk, int start, int end) throws SystemException {
3042 return getAssetCategories(pk, start, end, null);
3043 }
3044
3045 public static final FinderPath FINDER_PATH_GET_ASSETCATEGORIES = new FinderPath(com.liferay.portlet.asset.model.impl.AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
3046 AssetEntryModelImpl.FINDER_CACHE_ENABLED_ASSETENTRIES_ASSETCATEGORIES,
3047 com.liferay.portlet.asset.model.impl.AssetCategoryImpl.class,
3048 AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME,
3049 "getAssetCategories",
3050 new String[] {
3051 Long.class.getName(), "java.lang.Integer", "java.lang.Integer",
3052 "com.liferay.portal.kernel.util.OrderByComparator"
3053 });
3054
3055
3069 public List<com.liferay.portlet.asset.model.AssetCategory> getAssetCategories(
3070 long pk, int start, int end, OrderByComparator orderByComparator)
3071 throws SystemException {
3072 Object[] finderArgs = new Object[] { pk, start, end, orderByComparator };
3073
3074 List<com.liferay.portlet.asset.model.AssetCategory> list = (List<com.liferay.portlet.asset.model.AssetCategory>)FinderCacheUtil.getResult(FINDER_PATH_GET_ASSETCATEGORIES,
3075 finderArgs, this);
3076
3077 if (list == null) {
3078 Session session = null;
3079
3080 try {
3081 session = openSession();
3082
3083 String sql = null;
3084
3085 if (orderByComparator != null) {
3086 sql = _SQL_GETASSETCATEGORIES.concat(ORDER_BY_CLAUSE)
3087 .concat(orderByComparator.getOrderBy());
3088 }
3089 else {
3090 sql = _SQL_GETASSETCATEGORIES.concat(com.liferay.portlet.asset.model.impl.AssetCategoryModelImpl.ORDER_BY_SQL);
3091 }
3092
3093 SQLQuery q = session.createSQLQuery(sql);
3094
3095 q.addEntity("AssetCategory",
3096 com.liferay.portlet.asset.model.impl.AssetCategoryImpl.class);
3097
3098 QueryPos qPos = QueryPos.getInstance(q);
3099
3100 qPos.add(pk);
3101
3102 list = (List<com.liferay.portlet.asset.model.AssetCategory>)QueryUtil.list(q,
3103 getDialect(), start, end);
3104 }
3105 catch (Exception e) {
3106 throw processException(e);
3107 }
3108 finally {
3109 if (list == null) {
3110 FinderCacheUtil.removeResult(FINDER_PATH_GET_ASSETCATEGORIES,
3111 finderArgs);
3112 }
3113 else {
3114 assetCategoryPersistence.cacheResult(list);
3115
3116 FinderCacheUtil.putResult(FINDER_PATH_GET_ASSETCATEGORIES,
3117 finderArgs, list);
3118 }
3119
3120 closeSession(session);
3121 }
3122 }
3123
3124 return list;
3125 }
3126
3127 public static final FinderPath FINDER_PATH_GET_ASSETCATEGORIES_SIZE = new FinderPath(com.liferay.portlet.asset.model.impl.AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
3128 AssetEntryModelImpl.FINDER_CACHE_ENABLED_ASSETENTRIES_ASSETCATEGORIES,
3129 Long.class,
3130 AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME,
3131 "getAssetCategoriesSize", new String[] { Long.class.getName() });
3132
3133
3140 public int getAssetCategoriesSize(long pk) throws SystemException {
3141 Object[] finderArgs = new Object[] { pk };
3142
3143 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_GET_ASSETCATEGORIES_SIZE,
3144 finderArgs, this);
3145
3146 if (count == null) {
3147 Session session = null;
3148
3149 try {
3150 session = openSession();
3151
3152 SQLQuery q = session.createSQLQuery(_SQL_GETASSETCATEGORIESSIZE);
3153
3154 q.addScalar(COUNT_COLUMN_NAME,
3155 com.liferay.portal.kernel.dao.orm.Type.LONG);
3156
3157 QueryPos qPos = QueryPos.getInstance(q);
3158
3159 qPos.add(pk);
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_GET_ASSETCATEGORIES_SIZE,
3172 finderArgs, count);
3173
3174 closeSession(session);
3175 }
3176 }
3177
3178 return count.intValue();
3179 }
3180
3181 public static final FinderPath FINDER_PATH_CONTAINS_ASSETCATEGORY = new FinderPath(com.liferay.portlet.asset.model.impl.AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
3182 AssetEntryModelImpl.FINDER_CACHE_ENABLED_ASSETENTRIES_ASSETCATEGORIES,
3183 Boolean.class,
3184 AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME,
3185 "containsAssetCategory",
3186 new String[] { Long.class.getName(), Long.class.getName() });
3187
3188
3196 public boolean containsAssetCategory(long pk, long assetCategoryPK)
3197 throws SystemException {
3198 Object[] finderArgs = new Object[] { pk, assetCategoryPK };
3199
3200 Boolean value = (Boolean)FinderCacheUtil.getResult(FINDER_PATH_CONTAINS_ASSETCATEGORY,
3201 finderArgs, this);
3202
3203 if (value == null) {
3204 try {
3205 value = Boolean.valueOf(containsAssetCategory.contains(pk,
3206 assetCategoryPK));
3207 }
3208 catch (Exception e) {
3209 throw processException(e);
3210 }
3211 finally {
3212 if (value == null) {
3213 value = Boolean.FALSE;
3214 }
3215
3216 FinderCacheUtil.putResult(FINDER_PATH_CONTAINS_ASSETCATEGORY,
3217 finderArgs, value);
3218 }
3219 }
3220
3221 return value.booleanValue();
3222 }
3223
3224
3231 public boolean containsAssetCategories(long pk) throws SystemException {
3232 if (getAssetCategoriesSize(pk) > 0) {
3233 return true;
3234 }
3235 else {
3236 return false;
3237 }
3238 }
3239
3240
3247 public void addAssetCategory(long pk, long assetCategoryPK)
3248 throws SystemException {
3249 try {
3250 addAssetCategory.add(pk, assetCategoryPK);
3251 }
3252 catch (Exception e) {
3253 throw processException(e);
3254 }
3255 finally {
3256 FinderCacheUtil.clearCache(AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
3257 }
3258 }
3259
3260
3267 public void addAssetCategory(long pk,
3268 com.liferay.portlet.asset.model.AssetCategory assetCategory)
3269 throws SystemException {
3270 try {
3271 addAssetCategory.add(pk, assetCategory.getPrimaryKey());
3272 }
3273 catch (Exception e) {
3274 throw processException(e);
3275 }
3276 finally {
3277 FinderCacheUtil.clearCache(AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
3278 }
3279 }
3280
3281
3288 public void addAssetCategories(long pk, long[] assetCategoryPKs)
3289 throws SystemException {
3290 try {
3291 for (long assetCategoryPK : assetCategoryPKs) {
3292 addAssetCategory.add(pk, assetCategoryPK);
3293 }
3294 }
3295 catch (Exception e) {
3296 throw processException(e);
3297 }
3298 finally {
3299 FinderCacheUtil.clearCache(AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
3300 }
3301 }
3302
3303
3310 public void addAssetCategories(long pk,
3311 List<com.liferay.portlet.asset.model.AssetCategory> assetCategories)
3312 throws SystemException {
3313 try {
3314 for (com.liferay.portlet.asset.model.AssetCategory assetCategory : assetCategories) {
3315 addAssetCategory.add(pk, assetCategory.getPrimaryKey());
3316 }
3317 }
3318 catch (Exception e) {
3319 throw processException(e);
3320 }
3321 finally {
3322 FinderCacheUtil.clearCache(AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
3323 }
3324 }
3325
3326
3332 public void clearAssetCategories(long pk) throws SystemException {
3333 try {
3334 clearAssetCategories.clear(pk);
3335 }
3336 catch (Exception e) {
3337 throw processException(e);
3338 }
3339 finally {
3340 FinderCacheUtil.clearCache(AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
3341 }
3342 }
3343
3344
3351 public void removeAssetCategory(long pk, long assetCategoryPK)
3352 throws SystemException {
3353 try {
3354 removeAssetCategory.remove(pk, assetCategoryPK);
3355 }
3356 catch (Exception e) {
3357 throw processException(e);
3358 }
3359 finally {
3360 FinderCacheUtil.clearCache(AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
3361 }
3362 }
3363
3364
3371 public void removeAssetCategory(long pk,
3372 com.liferay.portlet.asset.model.AssetCategory assetCategory)
3373 throws SystemException {
3374 try {
3375 removeAssetCategory.remove(pk, assetCategory.getPrimaryKey());
3376 }
3377 catch (Exception e) {
3378 throw processException(e);
3379 }
3380 finally {
3381 FinderCacheUtil.clearCache(AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
3382 }
3383 }
3384
3385
3392 public void removeAssetCategories(long pk, long[] assetCategoryPKs)
3393 throws SystemException {
3394 try {
3395 for (long assetCategoryPK : assetCategoryPKs) {
3396 removeAssetCategory.remove(pk, assetCategoryPK);
3397 }
3398 }
3399 catch (Exception e) {
3400 throw processException(e);
3401 }
3402 finally {
3403 FinderCacheUtil.clearCache(AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
3404 }
3405 }
3406
3407
3414 public void removeAssetCategories(long pk,
3415 List<com.liferay.portlet.asset.model.AssetCategory> assetCategories)
3416 throws SystemException {
3417 try {
3418 for (com.liferay.portlet.asset.model.AssetCategory assetCategory : assetCategories) {
3419 removeAssetCategory.remove(pk, assetCategory.getPrimaryKey());
3420 }
3421 }
3422 catch (Exception e) {
3423 throw processException(e);
3424 }
3425 finally {
3426 FinderCacheUtil.clearCache(AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
3427 }
3428 }
3429
3430
3437 public void setAssetCategories(long pk, long[] assetCategoryPKs)
3438 throws SystemException {
3439 try {
3440 Set<Long> assetCategoryPKSet = SetUtil.fromArray(assetCategoryPKs);
3441
3442 List<com.liferay.portlet.asset.model.AssetCategory> assetCategories = getAssetCategories(pk);
3443
3444 for (com.liferay.portlet.asset.model.AssetCategory assetCategory : assetCategories) {
3445 if (!assetCategoryPKSet.remove(assetCategory.getPrimaryKey())) {
3446 removeAssetCategory.remove(pk, assetCategory.getPrimaryKey());
3447 }
3448 }
3449
3450 for (Long assetCategoryPK : assetCategoryPKSet) {
3451 addAssetCategory.add(pk, assetCategoryPK);
3452 }
3453 }
3454 catch (Exception e) {
3455 throw processException(e);
3456 }
3457 finally {
3458 FinderCacheUtil.clearCache(AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
3459 }
3460 }
3461
3462
3469 public void setAssetCategories(long pk,
3470 List<com.liferay.portlet.asset.model.AssetCategory> assetCategories)
3471 throws SystemException {
3472 try {
3473 long[] assetCategoryPKs = new long[assetCategories.size()];
3474
3475 for (int i = 0; i < assetCategories.size(); i++) {
3476 com.liferay.portlet.asset.model.AssetCategory assetCategory = assetCategories.get(i);
3477
3478 assetCategoryPKs[i] = assetCategory.getPrimaryKey();
3479 }
3480
3481 setAssetCategories(pk, assetCategoryPKs);
3482 }
3483 catch (Exception e) {
3484 throw processException(e);
3485 }
3486 finally {
3487 FinderCacheUtil.clearCache(AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
3488 }
3489 }
3490
3491
3498 public List<com.liferay.portlet.asset.model.AssetTag> getAssetTags(long pk)
3499 throws SystemException {
3500 return getAssetTags(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
3501 }
3502
3503
3516 public List<com.liferay.portlet.asset.model.AssetTag> getAssetTags(
3517 long pk, int start, int end) throws SystemException {
3518 return getAssetTags(pk, start, end, null);
3519 }
3520
3521 public static final FinderPath FINDER_PATH_GET_ASSETTAGS = new FinderPath(com.liferay.portlet.asset.model.impl.AssetTagModelImpl.ENTITY_CACHE_ENABLED,
3522 AssetEntryModelImpl.FINDER_CACHE_ENABLED_ASSETENTRIES_ASSETTAGS,
3523 com.liferay.portlet.asset.model.impl.AssetTagImpl.class,
3524 AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETTAGS_NAME,
3525 "getAssetTags",
3526 new String[] {
3527 Long.class.getName(), "java.lang.Integer", "java.lang.Integer",
3528 "com.liferay.portal.kernel.util.OrderByComparator"
3529 });
3530
3531
3545 public List<com.liferay.portlet.asset.model.AssetTag> getAssetTags(
3546 long pk, int start, int end, OrderByComparator orderByComparator)
3547 throws SystemException {
3548 Object[] finderArgs = new Object[] { pk, start, end, orderByComparator };
3549
3550 List<com.liferay.portlet.asset.model.AssetTag> list = (List<com.liferay.portlet.asset.model.AssetTag>)FinderCacheUtil.getResult(FINDER_PATH_GET_ASSETTAGS,
3551 finderArgs, this);
3552
3553 if (list == null) {
3554 Session session = null;
3555
3556 try {
3557 session = openSession();
3558
3559 String sql = null;
3560
3561 if (orderByComparator != null) {
3562 sql = _SQL_GETASSETTAGS.concat(ORDER_BY_CLAUSE)
3563 .concat(orderByComparator.getOrderBy());
3564 }
3565 else {
3566 sql = _SQL_GETASSETTAGS.concat(com.liferay.portlet.asset.model.impl.AssetTagModelImpl.ORDER_BY_SQL);
3567 }
3568
3569 SQLQuery q = session.createSQLQuery(sql);
3570
3571 q.addEntity("AssetTag",
3572 com.liferay.portlet.asset.model.impl.AssetTagImpl.class);
3573
3574 QueryPos qPos = QueryPos.getInstance(q);
3575
3576 qPos.add(pk);
3577
3578 list = (List<com.liferay.portlet.asset.model.AssetTag>)QueryUtil.list(q,
3579 getDialect(), start, end);
3580 }
3581 catch (Exception e) {
3582 throw processException(e);
3583 }
3584 finally {
3585 if (list == null) {
3586 FinderCacheUtil.removeResult(FINDER_PATH_GET_ASSETTAGS,
3587 finderArgs);
3588 }
3589 else {
3590 assetTagPersistence.cacheResult(list);
3591
3592 FinderCacheUtil.putResult(FINDER_PATH_GET_ASSETTAGS,
3593 finderArgs, list);
3594 }
3595
3596 closeSession(session);
3597 }
3598 }
3599
3600 return list;
3601 }
3602
3603 public static final FinderPath FINDER_PATH_GET_ASSETTAGS_SIZE = new FinderPath(com.liferay.portlet.asset.model.impl.AssetTagModelImpl.ENTITY_CACHE_ENABLED,
3604 AssetEntryModelImpl.FINDER_CACHE_ENABLED_ASSETENTRIES_ASSETTAGS,
3605 Long.class,
3606 AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETTAGS_NAME,
3607 "getAssetTagsSize", new String[] { Long.class.getName() });
3608
3609
3616 public int getAssetTagsSize(long pk) throws SystemException {
3617 Object[] finderArgs = new Object[] { pk };
3618
3619 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_GET_ASSETTAGS_SIZE,
3620 finderArgs, this);
3621
3622 if (count == null) {
3623 Session session = null;
3624
3625 try {
3626 session = openSession();
3627
3628 SQLQuery q = session.createSQLQuery(_SQL_GETASSETTAGSSIZE);
3629
3630 q.addScalar(COUNT_COLUMN_NAME,
3631 com.liferay.portal.kernel.dao.orm.Type.LONG);
3632
3633 QueryPos qPos = QueryPos.getInstance(q);
3634
3635 qPos.add(pk);
3636
3637 count = (Long)q.uniqueResult();
3638 }
3639 catch (Exception e) {
3640 throw processException(e);
3641 }
3642 finally {
3643 if (count == null) {
3644 count = Long.valueOf(0);
3645 }
3646
3647 FinderCacheUtil.putResult(FINDER_PATH_GET_ASSETTAGS_SIZE,
3648 finderArgs, count);
3649
3650 closeSession(session);
3651 }
3652 }
3653
3654 return count.intValue();
3655 }
3656
3657 public static final FinderPath FINDER_PATH_CONTAINS_ASSETTAG = new FinderPath(com.liferay.portlet.asset.model.impl.AssetTagModelImpl.ENTITY_CACHE_ENABLED,
3658 AssetEntryModelImpl.FINDER_CACHE_ENABLED_ASSETENTRIES_ASSETTAGS,
3659 Boolean.class,
3660 AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETTAGS_NAME,
3661 "containsAssetTag",
3662 new String[] { Long.class.getName(), Long.class.getName() });
3663
3664
3672 public boolean containsAssetTag(long pk, long assetTagPK)
3673 throws SystemException {
3674 Object[] finderArgs = new Object[] { pk, assetTagPK };
3675
3676 Boolean value = (Boolean)FinderCacheUtil.getResult(FINDER_PATH_CONTAINS_ASSETTAG,
3677 finderArgs, this);
3678
3679 if (value == null) {
3680 try {
3681 value = Boolean.valueOf(containsAssetTag.contains(pk, assetTagPK));
3682 }
3683 catch (Exception e) {
3684 throw processException(e);
3685 }
3686 finally {
3687 if (value == null) {
3688 value = Boolean.FALSE;
3689 }
3690
3691 FinderCacheUtil.putResult(FINDER_PATH_CONTAINS_ASSETTAG,
3692 finderArgs, value);
3693 }
3694 }
3695
3696 return value.booleanValue();
3697 }
3698
3699
3706 public boolean containsAssetTags(long pk) throws SystemException {
3707 if (getAssetTagsSize(pk) > 0) {
3708 return true;
3709 }
3710 else {
3711 return false;
3712 }
3713 }
3714
3715
3722 public void addAssetTag(long pk, long assetTagPK) throws SystemException {
3723 try {
3724 addAssetTag.add(pk, assetTagPK);
3725 }
3726 catch (Exception e) {
3727 throw processException(e);
3728 }
3729 finally {
3730 FinderCacheUtil.clearCache(AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETTAGS_NAME);
3731 }
3732 }
3733
3734
3741 public void addAssetTag(long pk,
3742 com.liferay.portlet.asset.model.AssetTag assetTag)
3743 throws SystemException {
3744 try {
3745 addAssetTag.add(pk, assetTag.getPrimaryKey());
3746 }
3747 catch (Exception e) {
3748 throw processException(e);
3749 }
3750 finally {
3751 FinderCacheUtil.clearCache(AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETTAGS_NAME);
3752 }
3753 }
3754
3755
3762 public void addAssetTags(long pk, long[] assetTagPKs)
3763 throws SystemException {
3764 try {
3765 for (long assetTagPK : assetTagPKs) {
3766 addAssetTag.add(pk, assetTagPK);
3767 }
3768 }
3769 catch (Exception e) {
3770 throw processException(e);
3771 }
3772 finally {
3773 FinderCacheUtil.clearCache(AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETTAGS_NAME);
3774 }
3775 }
3776
3777
3784 public void addAssetTags(long pk,
3785 List<com.liferay.portlet.asset.model.AssetTag> assetTags)
3786 throws SystemException {
3787 try {
3788 for (com.liferay.portlet.asset.model.AssetTag assetTag : assetTags) {
3789 addAssetTag.add(pk, assetTag.getPrimaryKey());
3790 }
3791 }
3792 catch (Exception e) {
3793 throw processException(e);
3794 }
3795 finally {
3796 FinderCacheUtil.clearCache(AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETTAGS_NAME);
3797 }
3798 }
3799
3800
3806 public void clearAssetTags(long pk) throws SystemException {
3807 try {
3808 clearAssetTags.clear(pk);
3809 }
3810 catch (Exception e) {
3811 throw processException(e);
3812 }
3813 finally {
3814 FinderCacheUtil.clearCache(AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETTAGS_NAME);
3815 }
3816 }
3817
3818
3825 public void removeAssetTag(long pk, long assetTagPK)
3826 throws SystemException {
3827 try {
3828 removeAssetTag.remove(pk, assetTagPK);
3829 }
3830 catch (Exception e) {
3831 throw processException(e);
3832 }
3833 finally {
3834 FinderCacheUtil.clearCache(AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETTAGS_NAME);
3835 }
3836 }
3837
3838
3845 public void removeAssetTag(long pk,
3846 com.liferay.portlet.asset.model.AssetTag assetTag)
3847 throws SystemException {
3848 try {
3849 removeAssetTag.remove(pk, assetTag.getPrimaryKey());
3850 }
3851 catch (Exception e) {
3852 throw processException(e);
3853 }
3854 finally {
3855 FinderCacheUtil.clearCache(AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETTAGS_NAME);
3856 }
3857 }
3858
3859
3866 public void removeAssetTags(long pk, long[] assetTagPKs)
3867 throws SystemException {
3868 try {
3869 for (long assetTagPK : assetTagPKs) {
3870 removeAssetTag.remove(pk, assetTagPK);
3871 }
3872 }
3873 catch (Exception e) {
3874 throw processException(e);
3875 }
3876 finally {
3877 FinderCacheUtil.clearCache(AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETTAGS_NAME);
3878 }
3879 }
3880
3881
3888 public void removeAssetTags(long pk,
3889 List<com.liferay.portlet.asset.model.AssetTag> assetTags)
3890 throws SystemException {
3891 try {
3892 for (com.liferay.portlet.asset.model.AssetTag assetTag : assetTags) {
3893 removeAssetTag.remove(pk, assetTag.getPrimaryKey());
3894 }
3895 }
3896 catch (Exception e) {
3897 throw processException(e);
3898 }
3899 finally {
3900 FinderCacheUtil.clearCache(AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETTAGS_NAME);
3901 }
3902 }
3903
3904
3911 public void setAssetTags(long pk, long[] assetTagPKs)
3912 throws SystemException {
3913 try {
3914 Set<Long> assetTagPKSet = SetUtil.fromArray(assetTagPKs);
3915
3916 List<com.liferay.portlet.asset.model.AssetTag> assetTags = getAssetTags(pk);
3917
3918 for (com.liferay.portlet.asset.model.AssetTag assetTag : assetTags) {
3919 if (!assetTagPKSet.remove(assetTag.getPrimaryKey())) {
3920 removeAssetTag.remove(pk, assetTag.getPrimaryKey());
3921 }
3922 }
3923
3924 for (Long assetTagPK : assetTagPKSet) {
3925 addAssetTag.add(pk, assetTagPK);
3926 }
3927 }
3928 catch (Exception e) {
3929 throw processException(e);
3930 }
3931 finally {
3932 FinderCacheUtil.clearCache(AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETTAGS_NAME);
3933 }
3934 }
3935
3936
3943 public void setAssetTags(long pk,
3944 List<com.liferay.portlet.asset.model.AssetTag> assetTags)
3945 throws SystemException {
3946 try {
3947 long[] assetTagPKs = new long[assetTags.size()];
3948
3949 for (int i = 0; i < assetTags.size(); i++) {
3950 com.liferay.portlet.asset.model.AssetTag assetTag = assetTags.get(i);
3951
3952 assetTagPKs[i] = assetTag.getPrimaryKey();
3953 }
3954
3955 setAssetTags(pk, assetTagPKs);
3956 }
3957 catch (Exception e) {
3958 throw processException(e);
3959 }
3960 finally {
3961 FinderCacheUtil.clearCache(AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETTAGS_NAME);
3962 }
3963 }
3964
3965
3968 public void afterPropertiesSet() {
3969 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
3970 com.liferay.portal.util.PropsUtil.get(
3971 "value.object.listener.com.liferay.portlet.asset.model.AssetEntry")));
3972
3973 if (listenerClassNames.length > 0) {
3974 try {
3975 List<ModelListener<AssetEntry>> listenersList = new ArrayList<ModelListener<AssetEntry>>();
3976
3977 for (String listenerClassName : listenerClassNames) {
3978 listenersList.add((ModelListener<AssetEntry>)InstanceFactory.newInstance(
3979 listenerClassName));
3980 }
3981
3982 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
3983 }
3984 catch (Exception e) {
3985 _log.error(e);
3986 }
3987 }
3988
3989 containsAssetCategory = new ContainsAssetCategory();
3990
3991 addAssetCategory = new AddAssetCategory();
3992 clearAssetCategories = new ClearAssetCategories();
3993 removeAssetCategory = new RemoveAssetCategory();
3994
3995 containsAssetTag = new ContainsAssetTag();
3996
3997 addAssetTag = new AddAssetTag();
3998 clearAssetTags = new ClearAssetTags();
3999 removeAssetTag = new RemoveAssetTag();
4000 }
4001
4002 public void destroy() {
4003 EntityCacheUtil.removeCache(AssetEntryImpl.class.getName());
4004 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
4005 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
4006 }
4007
4008 @BeanReference(type = AssetCategoryPersistence.class)
4009 protected AssetCategoryPersistence assetCategoryPersistence;
4010 @BeanReference(type = AssetCategoryPropertyPersistence.class)
4011 protected AssetCategoryPropertyPersistence assetCategoryPropertyPersistence;
4012 @BeanReference(type = AssetEntryPersistence.class)
4013 protected AssetEntryPersistence assetEntryPersistence;
4014 @BeanReference(type = AssetLinkPersistence.class)
4015 protected AssetLinkPersistence assetLinkPersistence;
4016 @BeanReference(type = AssetTagPersistence.class)
4017 protected AssetTagPersistence assetTagPersistence;
4018 @BeanReference(type = AssetTagPropertyPersistence.class)
4019 protected AssetTagPropertyPersistence assetTagPropertyPersistence;
4020 @BeanReference(type = AssetTagStatsPersistence.class)
4021 protected AssetTagStatsPersistence assetTagStatsPersistence;
4022 @BeanReference(type = AssetVocabularyPersistence.class)
4023 protected AssetVocabularyPersistence assetVocabularyPersistence;
4024 @BeanReference(type = CompanyPersistence.class)
4025 protected CompanyPersistence companyPersistence;
4026 @BeanReference(type = GroupPersistence.class)
4027 protected GroupPersistence groupPersistence;
4028 @BeanReference(type = ResourcePersistence.class)
4029 protected ResourcePersistence resourcePersistence;
4030 @BeanReference(type = UserPersistence.class)
4031 protected UserPersistence userPersistence;
4032 @BeanReference(type = BlogsEntryPersistence.class)
4033 protected BlogsEntryPersistence blogsEntryPersistence;
4034 @BeanReference(type = BookmarksEntryPersistence.class)
4035 protected BookmarksEntryPersistence bookmarksEntryPersistence;
4036 @BeanReference(type = DLFileEntryPersistence.class)
4037 protected DLFileEntryPersistence dlFileEntryPersistence;
4038 @BeanReference(type = DLFolderPersistence.class)
4039 protected DLFolderPersistence dlFolderPersistence;
4040 @BeanReference(type = JournalArticlePersistence.class)
4041 protected JournalArticlePersistence journalArticlePersistence;
4042 @BeanReference(type = JournalArticleResourcePersistence.class)
4043 protected JournalArticleResourcePersistence journalArticleResourcePersistence;
4044 @BeanReference(type = MBMessagePersistence.class)
4045 protected MBMessagePersistence mbMessagePersistence;
4046 @BeanReference(type = SocialActivityPersistence.class)
4047 protected SocialActivityPersistence socialActivityPersistence;
4048 @BeanReference(type = WikiPagePersistence.class)
4049 protected WikiPagePersistence wikiPagePersistence;
4050 @BeanReference(type = WikiPageResourcePersistence.class)
4051 protected WikiPageResourcePersistence wikiPageResourcePersistence;
4052 protected ContainsAssetCategory containsAssetCategory;
4053 protected AddAssetCategory addAssetCategory;
4054 protected ClearAssetCategories clearAssetCategories;
4055 protected RemoveAssetCategory removeAssetCategory;
4056 protected ContainsAssetTag containsAssetTag;
4057 protected AddAssetTag addAssetTag;
4058 protected ClearAssetTags clearAssetTags;
4059 protected RemoveAssetTag removeAssetTag;
4060
4061 protected class ContainsAssetCategory {
4062 protected ContainsAssetCategory() {
4063 _mappingSqlQuery = MappingSqlQueryFactoryUtil.getMappingSqlQuery(getDataSource(),
4064 _SQL_CONTAINSASSETCATEGORY,
4065 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT },
4066 RowMapper.COUNT);
4067 }
4068
4069 protected boolean contains(long entryId, long categoryId) {
4070 List<Integer> results = _mappingSqlQuery.execute(new Object[] {
4071 new Long(entryId), new Long(categoryId)
4072 });
4073
4074 if (results.size() > 0) {
4075 Integer count = results.get(0);
4076
4077 if (count.intValue() > 0) {
4078 return true;
4079 }
4080 }
4081
4082 return false;
4083 }
4084
4085 private MappingSqlQuery<Integer> _mappingSqlQuery;
4086 }
4087
4088 protected class AddAssetCategory {
4089 protected AddAssetCategory() {
4090 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
4091 "INSERT INTO AssetEntries_AssetCategories (entryId, categoryId) VALUES (?, ?)",
4092 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
4093 }
4094
4095 protected void add(long entryId, long categoryId)
4096 throws SystemException {
4097 if (!containsAssetCategory.contains(entryId, categoryId)) {
4098 ModelListener<com.liferay.portlet.asset.model.AssetCategory>[] assetCategoryListeners =
4099 assetCategoryPersistence.getListeners();
4100
4101 for (ModelListener<AssetEntry> listener : listeners) {
4102 listener.onBeforeAddAssociation(entryId,
4103 com.liferay.portlet.asset.model.AssetCategory.class.getName(),
4104 categoryId);
4105 }
4106
4107 for (ModelListener<com.liferay.portlet.asset.model.AssetCategory> listener : assetCategoryListeners) {
4108 listener.onBeforeAddAssociation(categoryId,
4109 AssetEntry.class.getName(), entryId);
4110 }
4111
4112 _sqlUpdate.update(new Object[] {
4113 new Long(entryId), new Long(categoryId)
4114 });
4115
4116 for (ModelListener<AssetEntry> listener : listeners) {
4117 listener.onAfterAddAssociation(entryId,
4118 com.liferay.portlet.asset.model.AssetCategory.class.getName(),
4119 categoryId);
4120 }
4121
4122 for (ModelListener<com.liferay.portlet.asset.model.AssetCategory> listener : assetCategoryListeners) {
4123 listener.onAfterAddAssociation(categoryId,
4124 AssetEntry.class.getName(), entryId);
4125 }
4126 }
4127 }
4128
4129 private SqlUpdate _sqlUpdate;
4130 }
4131
4132 protected class ClearAssetCategories {
4133 protected ClearAssetCategories() {
4134 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
4135 "DELETE FROM AssetEntries_AssetCategories WHERE entryId = ?",
4136 new int[] { java.sql.Types.BIGINT });
4137 }
4138
4139 protected void clear(long entryId) throws SystemException {
4140 ModelListener<com.liferay.portlet.asset.model.AssetCategory>[] assetCategoryListeners =
4141 assetCategoryPersistence.getListeners();
4142
4143 List<com.liferay.portlet.asset.model.AssetCategory> assetCategories = null;
4144
4145 if ((listeners.length > 0) || (assetCategoryListeners.length > 0)) {
4146 assetCategories = getAssetCategories(entryId);
4147
4148 for (com.liferay.portlet.asset.model.AssetCategory assetCategory : assetCategories) {
4149 for (ModelListener<AssetEntry> listener : listeners) {
4150 listener.onBeforeRemoveAssociation(entryId,
4151 com.liferay.portlet.asset.model.AssetCategory.class.getName(),
4152 assetCategory.getPrimaryKey());
4153 }
4154
4155 for (ModelListener<com.liferay.portlet.asset.model.AssetCategory> listener : assetCategoryListeners) {
4156 listener.onBeforeRemoveAssociation(assetCategory.getPrimaryKey(),
4157 AssetEntry.class.getName(), entryId);
4158 }
4159 }
4160 }
4161
4162 _sqlUpdate.update(new Object[] { new Long(entryId) });
4163
4164 if ((listeners.length > 0) || (assetCategoryListeners.length > 0)) {
4165 for (com.liferay.portlet.asset.model.AssetCategory assetCategory : assetCategories) {
4166 for (ModelListener<AssetEntry> listener : listeners) {
4167 listener.onAfterRemoveAssociation(entryId,
4168 com.liferay.portlet.asset.model.AssetCategory.class.getName(),
4169 assetCategory.getPrimaryKey());
4170 }
4171
4172 for (ModelListener<com.liferay.portlet.asset.model.AssetCategory> listener : assetCategoryListeners) {
4173 listener.onAfterRemoveAssociation(assetCategory.getPrimaryKey(),
4174 AssetEntry.class.getName(), entryId);
4175 }
4176 }
4177 }
4178 }
4179
4180 private SqlUpdate _sqlUpdate;
4181 }
4182
4183 protected class RemoveAssetCategory {
4184 protected RemoveAssetCategory() {
4185 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
4186 "DELETE FROM AssetEntries_AssetCategories WHERE entryId = ? AND categoryId = ?",
4187 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
4188 }
4189
4190 protected void remove(long entryId, long categoryId)
4191 throws SystemException {
4192 if (containsAssetCategory.contains(entryId, categoryId)) {
4193 ModelListener<com.liferay.portlet.asset.model.AssetCategory>[] assetCategoryListeners =
4194 assetCategoryPersistence.getListeners();
4195
4196 for (ModelListener<AssetEntry> listener : listeners) {
4197 listener.onBeforeRemoveAssociation(entryId,
4198 com.liferay.portlet.asset.model.AssetCategory.class.getName(),
4199 categoryId);
4200 }
4201
4202 for (ModelListener<com.liferay.portlet.asset.model.AssetCategory> listener : assetCategoryListeners) {
4203 listener.onBeforeRemoveAssociation(categoryId,
4204 AssetEntry.class.getName(), entryId);
4205 }
4206
4207 _sqlUpdate.update(new Object[] {
4208 new Long(entryId), new Long(categoryId)
4209 });
4210
4211 for (ModelListener<AssetEntry> listener : listeners) {
4212 listener.onAfterRemoveAssociation(entryId,
4213 com.liferay.portlet.asset.model.AssetCategory.class.getName(),
4214 categoryId);
4215 }
4216
4217 for (ModelListener<com.liferay.portlet.asset.model.AssetCategory> listener : assetCategoryListeners) {
4218 listener.onAfterRemoveAssociation(categoryId,
4219 AssetEntry.class.getName(), entryId);
4220 }
4221 }
4222 }
4223
4224 private SqlUpdate _sqlUpdate;
4225 }
4226
4227 protected class ContainsAssetTag {
4228 protected ContainsAssetTag() {
4229 _mappingSqlQuery = MappingSqlQueryFactoryUtil.getMappingSqlQuery(getDataSource(),
4230 _SQL_CONTAINSASSETTAG,
4231 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT },
4232 RowMapper.COUNT);
4233 }
4234
4235 protected boolean contains(long entryId, long tagId) {
4236 List<Integer> results = _mappingSqlQuery.execute(new Object[] {
4237 new Long(entryId), new Long(tagId)
4238 });
4239
4240 if (results.size() > 0) {
4241 Integer count = results.get(0);
4242
4243 if (count.intValue() > 0) {
4244 return true;
4245 }
4246 }
4247
4248 return false;
4249 }
4250
4251 private MappingSqlQuery<Integer> _mappingSqlQuery;
4252 }
4253
4254 protected class AddAssetTag {
4255 protected AddAssetTag() {
4256 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
4257 "INSERT INTO AssetEntries_AssetTags (entryId, tagId) VALUES (?, ?)",
4258 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
4259 }
4260
4261 protected void add(long entryId, long tagId) throws SystemException {
4262 if (!containsAssetTag.contains(entryId, tagId)) {
4263 ModelListener<com.liferay.portlet.asset.model.AssetTag>[] assetTagListeners =
4264 assetTagPersistence.getListeners();
4265
4266 for (ModelListener<AssetEntry> listener : listeners) {
4267 listener.onBeforeAddAssociation(entryId,
4268 com.liferay.portlet.asset.model.AssetTag.class.getName(),
4269 tagId);
4270 }
4271
4272 for (ModelListener<com.liferay.portlet.asset.model.AssetTag> listener : assetTagListeners) {
4273 listener.onBeforeAddAssociation(tagId,
4274 AssetEntry.class.getName(), entryId);
4275 }
4276
4277 _sqlUpdate.update(new Object[] {
4278 new Long(entryId), new Long(tagId)
4279 });
4280
4281 for (ModelListener<AssetEntry> listener : listeners) {
4282 listener.onAfterAddAssociation(entryId,
4283 com.liferay.portlet.asset.model.AssetTag.class.getName(),
4284 tagId);
4285 }
4286
4287 for (ModelListener<com.liferay.portlet.asset.model.AssetTag> listener : assetTagListeners) {
4288 listener.onAfterAddAssociation(tagId,
4289 AssetEntry.class.getName(), entryId);
4290 }
4291 }
4292 }
4293
4294 private SqlUpdate _sqlUpdate;
4295 }
4296
4297 protected class ClearAssetTags {
4298 protected ClearAssetTags() {
4299 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
4300 "DELETE FROM AssetEntries_AssetTags WHERE entryId = ?",
4301 new int[] { java.sql.Types.BIGINT });
4302 }
4303
4304 protected void clear(long entryId) throws SystemException {
4305 ModelListener<com.liferay.portlet.asset.model.AssetTag>[] assetTagListeners =
4306 assetTagPersistence.getListeners();
4307
4308 List<com.liferay.portlet.asset.model.AssetTag> assetTags = null;
4309
4310 if ((listeners.length > 0) || (assetTagListeners.length > 0)) {
4311 assetTags = getAssetTags(entryId);
4312
4313 for (com.liferay.portlet.asset.model.AssetTag assetTag : assetTags) {
4314 for (ModelListener<AssetEntry> listener : listeners) {
4315 listener.onBeforeRemoveAssociation(entryId,
4316 com.liferay.portlet.asset.model.AssetTag.class.getName(),
4317 assetTag.getPrimaryKey());
4318 }
4319
4320 for (ModelListener<com.liferay.portlet.asset.model.AssetTag> listener : assetTagListeners) {
4321 listener.onBeforeRemoveAssociation(assetTag.getPrimaryKey(),
4322 AssetEntry.class.getName(), entryId);
4323 }
4324 }
4325 }
4326
4327 _sqlUpdate.update(new Object[] { new Long(entryId) });
4328
4329 if ((listeners.length > 0) || (assetTagListeners.length > 0)) {
4330 for (com.liferay.portlet.asset.model.AssetTag assetTag : assetTags) {
4331 for (ModelListener<AssetEntry> listener : listeners) {
4332 listener.onAfterRemoveAssociation(entryId,
4333 com.liferay.portlet.asset.model.AssetTag.class.getName(),
4334 assetTag.getPrimaryKey());
4335 }
4336
4337 for (ModelListener<com.liferay.portlet.asset.model.AssetTag> listener : assetTagListeners) {
4338 listener.onAfterRemoveAssociation(assetTag.getPrimaryKey(),
4339 AssetEntry.class.getName(), entryId);
4340 }
4341 }
4342 }
4343 }
4344
4345 private SqlUpdate _sqlUpdate;
4346 }
4347
4348 protected class RemoveAssetTag {
4349 protected RemoveAssetTag() {
4350 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
4351 "DELETE FROM AssetEntries_AssetTags WHERE entryId = ? AND tagId = ?",
4352 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
4353 }
4354
4355 protected void remove(long entryId, long tagId)
4356 throws SystemException {
4357 if (containsAssetTag.contains(entryId, tagId)) {
4358 ModelListener<com.liferay.portlet.asset.model.AssetTag>[] assetTagListeners =
4359 assetTagPersistence.getListeners();
4360
4361 for (ModelListener<AssetEntry> listener : listeners) {
4362 listener.onBeforeRemoveAssociation(entryId,
4363 com.liferay.portlet.asset.model.AssetTag.class.getName(),
4364 tagId);
4365 }
4366
4367 for (ModelListener<com.liferay.portlet.asset.model.AssetTag> listener : assetTagListeners) {
4368 listener.onBeforeRemoveAssociation(tagId,
4369 AssetEntry.class.getName(), entryId);
4370 }
4371
4372 _sqlUpdate.update(new Object[] {
4373 new Long(entryId), new Long(tagId)
4374 });
4375
4376 for (ModelListener<AssetEntry> listener : listeners) {
4377 listener.onAfterRemoveAssociation(entryId,
4378 com.liferay.portlet.asset.model.AssetTag.class.getName(),
4379 tagId);
4380 }
4381
4382 for (ModelListener<com.liferay.portlet.asset.model.AssetTag> listener : assetTagListeners) {
4383 listener.onAfterRemoveAssociation(tagId,
4384 AssetEntry.class.getName(), entryId);
4385 }
4386 }
4387 }
4388
4389 private SqlUpdate _sqlUpdate;
4390 }
4391
4392 private static final String _SQL_SELECT_ASSETENTRY = "SELECT assetEntry FROM AssetEntry assetEntry";
4393 private static final String _SQL_SELECT_ASSETENTRY_WHERE = "SELECT assetEntry FROM AssetEntry assetEntry WHERE ";
4394 private static final String _SQL_COUNT_ASSETENTRY = "SELECT COUNT(assetEntry) FROM AssetEntry assetEntry";
4395 private static final String _SQL_COUNT_ASSETENTRY_WHERE = "SELECT COUNT(assetEntry) FROM AssetEntry assetEntry WHERE ";
4396 private static final String _SQL_GETASSETCATEGORIES = "SELECT {AssetCategory.*} FROM AssetCategory INNER JOIN AssetEntries_AssetCategories ON (AssetEntries_AssetCategories.categoryId = AssetCategory.categoryId) WHERE (AssetEntries_AssetCategories.entryId = ?)";
4397 private static final String _SQL_GETASSETCATEGORIESSIZE = "SELECT COUNT(*) AS COUNT_VALUE FROM AssetEntries_AssetCategories WHERE entryId = ?";
4398 private static final String _SQL_CONTAINSASSETCATEGORY = "SELECT COUNT(*) AS COUNT_VALUE FROM AssetEntries_AssetCategories WHERE entryId = ? AND categoryId = ?";
4399 private static final String _SQL_GETASSETTAGS = "SELECT {AssetTag.*} FROM AssetTag INNER JOIN AssetEntries_AssetTags ON (AssetEntries_AssetTags.tagId = AssetTag.tagId) WHERE (AssetEntries_AssetTags.entryId = ?)";
4400 private static final String _SQL_GETASSETTAGSSIZE = "SELECT COUNT(*) AS COUNT_VALUE FROM AssetEntries_AssetTags WHERE entryId = ?";
4401 private static final String _SQL_CONTAINSASSETTAG = "SELECT COUNT(*) AS COUNT_VALUE FROM AssetEntries_AssetTags WHERE entryId = ? AND tagId = ?";
4402 private static final String _FINDER_COLUMN_COMPANYID_COMPANYID_2 = "assetEntry.companyId = ?";
4403 private static final String _FINDER_COLUMN_VISIBLE_VISIBLE_2 = "assetEntry.visible = ?";
4404 private static final String _FINDER_COLUMN_PUBLISHDATE_PUBLISHDATE_1 = "assetEntry.publishDate IS NULL";
4405 private static final String _FINDER_COLUMN_PUBLISHDATE_PUBLISHDATE_2 = "assetEntry.publishDate = ?";
4406 private static final String _FINDER_COLUMN_EXPIRATIONDATE_EXPIRATIONDATE_1 = "assetEntry.expirationDate IS NULL";
4407 private static final String _FINDER_COLUMN_EXPIRATIONDATE_EXPIRATIONDATE_2 = "assetEntry.expirationDate = ?";
4408 private static final String _FINDER_COLUMN_G_CU_GROUPID_2 = "assetEntry.groupId = ? AND ";
4409 private static final String _FINDER_COLUMN_G_CU_CLASSUUID_1 = "assetEntry.classUuid IS NULL";
4410 private static final String _FINDER_COLUMN_G_CU_CLASSUUID_2 = "assetEntry.classUuid = ?";
4411 private static final String _FINDER_COLUMN_G_CU_CLASSUUID_3 = "(assetEntry.classUuid IS NULL OR assetEntry.classUuid = ?)";
4412 private static final String _FINDER_COLUMN_C_C_CLASSNAMEID_2 = "assetEntry.classNameId = ? AND ";
4413 private static final String _FINDER_COLUMN_C_C_CLASSPK_2 = "assetEntry.classPK = ?";
4414 private static final String _ORDER_BY_ENTITY_ALIAS = "assetEntry.";
4415 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No AssetEntry exists with the primary key ";
4416 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No AssetEntry exists with the key {";
4417 private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
4418 private static Log _log = LogFactoryUtil.getLog(AssetEntryPersistenceImpl.class);
4419 private static AssetEntry _nullAssetEntry = new AssetEntryImpl() {
4420 @Override
4421 public Object clone() {
4422 return this;
4423 }
4424
4425 @Override
4426 public CacheModel<AssetEntry> toCacheModel() {
4427 return _nullAssetEntryCacheModel;
4428 }
4429 };
4430
4431 private static CacheModel<AssetEntry> _nullAssetEntryCacheModel = new CacheModel<AssetEntry>() {
4432 public AssetEntry toEntityModel() {
4433 return _nullAssetEntry;
4434 }
4435 };
4436 }