001
014
015 package com.liferay.portlet.asset.service.persistence;
016
017 import com.liferay.portal.kernel.bean.BeanReference;
018 import com.liferay.portal.kernel.cache.CacheRegistryUtil;
019 import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
020 import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
021 import com.liferay.portal.kernel.dao.orm.FinderPath;
022 import com.liferay.portal.kernel.dao.orm.Query;
023 import com.liferay.portal.kernel.dao.orm.QueryPos;
024 import com.liferay.portal.kernel.dao.orm.QueryUtil;
025 import com.liferay.portal.kernel.dao.orm.Session;
026 import com.liferay.portal.kernel.exception.SystemException;
027 import com.liferay.portal.kernel.log.Log;
028 import com.liferay.portal.kernel.log.LogFactoryUtil;
029 import com.liferay.portal.kernel.util.CalendarUtil;
030 import com.liferay.portal.kernel.util.GetterUtil;
031 import com.liferay.portal.kernel.util.InstanceFactory;
032 import com.liferay.portal.kernel.util.OrderByComparator;
033 import com.liferay.portal.kernel.util.SetUtil;
034 import com.liferay.portal.kernel.util.StringBundler;
035 import com.liferay.portal.kernel.util.StringPool;
036 import com.liferay.portal.kernel.util.StringUtil;
037 import com.liferay.portal.kernel.util.UnmodifiableList;
038 import com.liferay.portal.kernel.util.Validator;
039 import com.liferay.portal.model.CacheModel;
040 import com.liferay.portal.model.ModelListener;
041 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
042 import com.liferay.portal.service.persistence.impl.TableMapper;
043 import com.liferay.portal.service.persistence.impl.TableMapperFactory;
044
045 import com.liferay.portlet.asset.NoSuchEntryException;
046 import com.liferay.portlet.asset.model.AssetEntry;
047 import com.liferay.portlet.asset.model.impl.AssetEntryImpl;
048 import com.liferay.portlet.asset.model.impl.AssetEntryModelImpl;
049
050 import java.io.Serializable;
051
052 import java.util.ArrayList;
053 import java.util.Collections;
054 import java.util.Date;
055 import java.util.HashSet;
056 import java.util.List;
057 import java.util.Set;
058
059
071 public class AssetEntryPersistenceImpl extends BasePersistenceImpl<AssetEntry>
072 implements AssetEntryPersistence {
073
078 public static final String FINDER_CLASS_NAME_ENTITY = AssetEntryImpl.class.getName();
079 public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
080 ".List1";
081 public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
082 ".List2";
083 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
084 AssetEntryModelImpl.FINDER_CACHE_ENABLED, AssetEntryImpl.class,
085 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0]);
086 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
087 AssetEntryModelImpl.FINDER_CACHE_ENABLED, AssetEntryImpl.class,
088 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
089 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
090 AssetEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
091 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
092 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID =
093 new FinderPath(AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
094 AssetEntryModelImpl.FINDER_CACHE_ENABLED, AssetEntryImpl.class,
095 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByCompanyId",
096 new String[] {
097 Long.class.getName(),
098
099 Integer.class.getName(), Integer.class.getName(),
100 OrderByComparator.class.getName()
101 });
102 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID =
103 new FinderPath(AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
104 AssetEntryModelImpl.FINDER_CACHE_ENABLED, AssetEntryImpl.class,
105 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByCompanyId",
106 new String[] { Long.class.getName() },
107 AssetEntryModelImpl.COMPANYID_COLUMN_BITMASK);
108 public static final FinderPath FINDER_PATH_COUNT_BY_COMPANYID = new FinderPath(AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
109 AssetEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
110 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByCompanyId",
111 new String[] { Long.class.getName() });
112
113
120 @Override
121 public List<AssetEntry> findByCompanyId(long companyId)
122 throws SystemException {
123 return findByCompanyId(companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
124 null);
125 }
126
127
140 @Override
141 public List<AssetEntry> findByCompanyId(long companyId, int start, int end)
142 throws SystemException {
143 return findByCompanyId(companyId, start, end, null);
144 }
145
146
160 @Override
161 public List<AssetEntry> findByCompanyId(long companyId, int start, int end,
162 OrderByComparator orderByComparator) throws SystemException {
163 boolean pagination = true;
164 FinderPath finderPath = null;
165 Object[] finderArgs = null;
166
167 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
168 (orderByComparator == null)) {
169 pagination = false;
170 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID;
171 finderArgs = new Object[] { companyId };
172 }
173 else {
174 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID;
175 finderArgs = new Object[] { companyId, start, end, orderByComparator };
176 }
177
178 List<AssetEntry> list = (List<AssetEntry>)FinderCacheUtil.getResult(finderPath,
179 finderArgs, this);
180
181 if ((list != null) && !list.isEmpty()) {
182 for (AssetEntry assetEntry : list) {
183 if ((companyId != assetEntry.getCompanyId())) {
184 list = null;
185
186 break;
187 }
188 }
189 }
190
191 if (list == null) {
192 StringBundler query = null;
193
194 if (orderByComparator != null) {
195 query = new StringBundler(3 +
196 (orderByComparator.getOrderByFields().length * 3));
197 }
198 else {
199 query = new StringBundler(3);
200 }
201
202 query.append(_SQL_SELECT_ASSETENTRY_WHERE);
203
204 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
205
206 if (orderByComparator != null) {
207 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
208 orderByComparator);
209 }
210 else
211 if (pagination) {
212 query.append(AssetEntryModelImpl.ORDER_BY_JPQL);
213 }
214
215 String sql = query.toString();
216
217 Session session = null;
218
219 try {
220 session = openSession();
221
222 Query q = session.createQuery(sql);
223
224 QueryPos qPos = QueryPos.getInstance(q);
225
226 qPos.add(companyId);
227
228 if (!pagination) {
229 list = (List<AssetEntry>)QueryUtil.list(q, getDialect(),
230 start, end, false);
231
232 Collections.sort(list);
233
234 list = new UnmodifiableList<AssetEntry>(list);
235 }
236 else {
237 list = (List<AssetEntry>)QueryUtil.list(q, getDialect(),
238 start, end);
239 }
240
241 cacheResult(list);
242
243 FinderCacheUtil.putResult(finderPath, finderArgs, list);
244 }
245 catch (Exception e) {
246 FinderCacheUtil.removeResult(finderPath, finderArgs);
247
248 throw processException(e);
249 }
250 finally {
251 closeSession(session);
252 }
253 }
254
255 return list;
256 }
257
258
267 @Override
268 public AssetEntry findByCompanyId_First(long companyId,
269 OrderByComparator orderByComparator)
270 throws NoSuchEntryException, SystemException {
271 AssetEntry assetEntry = fetchByCompanyId_First(companyId,
272 orderByComparator);
273
274 if (assetEntry != null) {
275 return assetEntry;
276 }
277
278 StringBundler msg = new StringBundler(4);
279
280 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
281
282 msg.append("companyId=");
283 msg.append(companyId);
284
285 msg.append(StringPool.CLOSE_CURLY_BRACE);
286
287 throw new NoSuchEntryException(msg.toString());
288 }
289
290
298 @Override
299 public AssetEntry fetchByCompanyId_First(long companyId,
300 OrderByComparator orderByComparator) throws SystemException {
301 List<AssetEntry> list = findByCompanyId(companyId, 0, 1,
302 orderByComparator);
303
304 if (!list.isEmpty()) {
305 return list.get(0);
306 }
307
308 return null;
309 }
310
311
320 @Override
321 public AssetEntry findByCompanyId_Last(long companyId,
322 OrderByComparator orderByComparator)
323 throws NoSuchEntryException, SystemException {
324 AssetEntry assetEntry = fetchByCompanyId_Last(companyId,
325 orderByComparator);
326
327 if (assetEntry != null) {
328 return assetEntry;
329 }
330
331 StringBundler msg = new StringBundler(4);
332
333 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
334
335 msg.append("companyId=");
336 msg.append(companyId);
337
338 msg.append(StringPool.CLOSE_CURLY_BRACE);
339
340 throw new NoSuchEntryException(msg.toString());
341 }
342
343
351 @Override
352 public AssetEntry fetchByCompanyId_Last(long companyId,
353 OrderByComparator orderByComparator) throws SystemException {
354 int count = countByCompanyId(companyId);
355
356 if (count == 0) {
357 return null;
358 }
359
360 List<AssetEntry> list = findByCompanyId(companyId, count - 1, count,
361 orderByComparator);
362
363 if (!list.isEmpty()) {
364 return list.get(0);
365 }
366
367 return null;
368 }
369
370
380 @Override
381 public AssetEntry[] findByCompanyId_PrevAndNext(long entryId,
382 long companyId, OrderByComparator orderByComparator)
383 throws NoSuchEntryException, SystemException {
384 AssetEntry assetEntry = findByPrimaryKey(entryId);
385
386 Session session = null;
387
388 try {
389 session = openSession();
390
391 AssetEntry[] array = new AssetEntryImpl[3];
392
393 array[0] = getByCompanyId_PrevAndNext(session, assetEntry,
394 companyId, orderByComparator, true);
395
396 array[1] = assetEntry;
397
398 array[2] = getByCompanyId_PrevAndNext(session, assetEntry,
399 companyId, orderByComparator, false);
400
401 return array;
402 }
403 catch (Exception e) {
404 throw processException(e);
405 }
406 finally {
407 closeSession(session);
408 }
409 }
410
411 protected AssetEntry getByCompanyId_PrevAndNext(Session session,
412 AssetEntry assetEntry, long companyId,
413 OrderByComparator orderByComparator, boolean previous) {
414 StringBundler query = null;
415
416 if (orderByComparator != null) {
417 query = new StringBundler(6 +
418 (orderByComparator.getOrderByFields().length * 6));
419 }
420 else {
421 query = new StringBundler(3);
422 }
423
424 query.append(_SQL_SELECT_ASSETENTRY_WHERE);
425
426 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
427
428 if (orderByComparator != null) {
429 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
430
431 if (orderByConditionFields.length > 0) {
432 query.append(WHERE_AND);
433 }
434
435 for (int i = 0; i < orderByConditionFields.length; i++) {
436 query.append(_ORDER_BY_ENTITY_ALIAS);
437 query.append(orderByConditionFields[i]);
438
439 if ((i + 1) < orderByConditionFields.length) {
440 if (orderByComparator.isAscending() ^ previous) {
441 query.append(WHERE_GREATER_THAN_HAS_NEXT);
442 }
443 else {
444 query.append(WHERE_LESSER_THAN_HAS_NEXT);
445 }
446 }
447 else {
448 if (orderByComparator.isAscending() ^ previous) {
449 query.append(WHERE_GREATER_THAN);
450 }
451 else {
452 query.append(WHERE_LESSER_THAN);
453 }
454 }
455 }
456
457 query.append(ORDER_BY_CLAUSE);
458
459 String[] orderByFields = orderByComparator.getOrderByFields();
460
461 for (int i = 0; i < orderByFields.length; i++) {
462 query.append(_ORDER_BY_ENTITY_ALIAS);
463 query.append(orderByFields[i]);
464
465 if ((i + 1) < orderByFields.length) {
466 if (orderByComparator.isAscending() ^ previous) {
467 query.append(ORDER_BY_ASC_HAS_NEXT);
468 }
469 else {
470 query.append(ORDER_BY_DESC_HAS_NEXT);
471 }
472 }
473 else {
474 if (orderByComparator.isAscending() ^ previous) {
475 query.append(ORDER_BY_ASC);
476 }
477 else {
478 query.append(ORDER_BY_DESC);
479 }
480 }
481 }
482 }
483 else {
484 query.append(AssetEntryModelImpl.ORDER_BY_JPQL);
485 }
486
487 String sql = query.toString();
488
489 Query q = session.createQuery(sql);
490
491 q.setFirstResult(0);
492 q.setMaxResults(2);
493
494 QueryPos qPos = QueryPos.getInstance(q);
495
496 qPos.add(companyId);
497
498 if (orderByComparator != null) {
499 Object[] values = orderByComparator.getOrderByConditionValues(assetEntry);
500
501 for (Object value : values) {
502 qPos.add(value);
503 }
504 }
505
506 List<AssetEntry> list = q.list();
507
508 if (list.size() == 2) {
509 return list.get(1);
510 }
511 else {
512 return null;
513 }
514 }
515
516
522 @Override
523 public void removeByCompanyId(long companyId) throws SystemException {
524 for (AssetEntry assetEntry : findByCompanyId(companyId,
525 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
526 remove(assetEntry);
527 }
528 }
529
530
537 @Override
538 public int countByCompanyId(long companyId) throws SystemException {
539 FinderPath finderPath = FINDER_PATH_COUNT_BY_COMPANYID;
540
541 Object[] finderArgs = new Object[] { companyId };
542
543 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
544 this);
545
546 if (count == null) {
547 StringBundler query = new StringBundler(2);
548
549 query.append(_SQL_COUNT_ASSETENTRY_WHERE);
550
551 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
552
553 String sql = query.toString();
554
555 Session session = null;
556
557 try {
558 session = openSession();
559
560 Query q = session.createQuery(sql);
561
562 QueryPos qPos = QueryPos.getInstance(q);
563
564 qPos.add(companyId);
565
566 count = (Long)q.uniqueResult();
567
568 FinderCacheUtil.putResult(finderPath, finderArgs, count);
569 }
570 catch (Exception e) {
571 FinderCacheUtil.removeResult(finderPath, finderArgs);
572
573 throw processException(e);
574 }
575 finally {
576 closeSession(session);
577 }
578 }
579
580 return count.intValue();
581 }
582
583 private static final String _FINDER_COLUMN_COMPANYID_COMPANYID_2 = "assetEntry.companyId = ?";
584 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_VISIBLE = new FinderPath(AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
585 AssetEntryModelImpl.FINDER_CACHE_ENABLED, AssetEntryImpl.class,
586 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByVisible",
587 new String[] {
588 Boolean.class.getName(),
589
590 Integer.class.getName(), Integer.class.getName(),
591 OrderByComparator.class.getName()
592 });
593 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_VISIBLE =
594 new FinderPath(AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
595 AssetEntryModelImpl.FINDER_CACHE_ENABLED, AssetEntryImpl.class,
596 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByVisible",
597 new String[] { Boolean.class.getName() },
598 AssetEntryModelImpl.VISIBLE_COLUMN_BITMASK);
599 public static final FinderPath FINDER_PATH_COUNT_BY_VISIBLE = new FinderPath(AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
600 AssetEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
601 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByVisible",
602 new String[] { Boolean.class.getName() });
603
604
611 @Override
612 public List<AssetEntry> findByVisible(boolean visible)
613 throws SystemException {
614 return findByVisible(visible, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
615 }
616
617
630 @Override
631 public List<AssetEntry> findByVisible(boolean visible, int start, int end)
632 throws SystemException {
633 return findByVisible(visible, start, end, null);
634 }
635
636
650 @Override
651 public List<AssetEntry> findByVisible(boolean visible, int start, int end,
652 OrderByComparator orderByComparator) throws SystemException {
653 boolean pagination = true;
654 FinderPath finderPath = null;
655 Object[] finderArgs = null;
656
657 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
658 (orderByComparator == null)) {
659 pagination = false;
660 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_VISIBLE;
661 finderArgs = new Object[] { visible };
662 }
663 else {
664 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_VISIBLE;
665 finderArgs = new Object[] { visible, start, end, orderByComparator };
666 }
667
668 List<AssetEntry> list = (List<AssetEntry>)FinderCacheUtil.getResult(finderPath,
669 finderArgs, this);
670
671 if ((list != null) && !list.isEmpty()) {
672 for (AssetEntry assetEntry : list) {
673 if ((visible != assetEntry.getVisible())) {
674 list = null;
675
676 break;
677 }
678 }
679 }
680
681 if (list == null) {
682 StringBundler query = null;
683
684 if (orderByComparator != null) {
685 query = new StringBundler(3 +
686 (orderByComparator.getOrderByFields().length * 3));
687 }
688 else {
689 query = new StringBundler(3);
690 }
691
692 query.append(_SQL_SELECT_ASSETENTRY_WHERE);
693
694 query.append(_FINDER_COLUMN_VISIBLE_VISIBLE_2);
695
696 if (orderByComparator != null) {
697 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
698 orderByComparator);
699 }
700 else
701 if (pagination) {
702 query.append(AssetEntryModelImpl.ORDER_BY_JPQL);
703 }
704
705 String sql = query.toString();
706
707 Session session = null;
708
709 try {
710 session = openSession();
711
712 Query q = session.createQuery(sql);
713
714 QueryPos qPos = QueryPos.getInstance(q);
715
716 qPos.add(visible);
717
718 if (!pagination) {
719 list = (List<AssetEntry>)QueryUtil.list(q, getDialect(),
720 start, end, false);
721
722 Collections.sort(list);
723
724 list = new UnmodifiableList<AssetEntry>(list);
725 }
726 else {
727 list = (List<AssetEntry>)QueryUtil.list(q, getDialect(),
728 start, end);
729 }
730
731 cacheResult(list);
732
733 FinderCacheUtil.putResult(finderPath, finderArgs, list);
734 }
735 catch (Exception e) {
736 FinderCacheUtil.removeResult(finderPath, finderArgs);
737
738 throw processException(e);
739 }
740 finally {
741 closeSession(session);
742 }
743 }
744
745 return list;
746 }
747
748
757 @Override
758 public AssetEntry findByVisible_First(boolean visible,
759 OrderByComparator orderByComparator)
760 throws NoSuchEntryException, SystemException {
761 AssetEntry assetEntry = fetchByVisible_First(visible, orderByComparator);
762
763 if (assetEntry != null) {
764 return assetEntry;
765 }
766
767 StringBundler msg = new StringBundler(4);
768
769 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
770
771 msg.append("visible=");
772 msg.append(visible);
773
774 msg.append(StringPool.CLOSE_CURLY_BRACE);
775
776 throw new NoSuchEntryException(msg.toString());
777 }
778
779
787 @Override
788 public AssetEntry fetchByVisible_First(boolean visible,
789 OrderByComparator orderByComparator) throws SystemException {
790 List<AssetEntry> list = findByVisible(visible, 0, 1, orderByComparator);
791
792 if (!list.isEmpty()) {
793 return list.get(0);
794 }
795
796 return null;
797 }
798
799
808 @Override
809 public AssetEntry findByVisible_Last(boolean visible,
810 OrderByComparator orderByComparator)
811 throws NoSuchEntryException, SystemException {
812 AssetEntry assetEntry = fetchByVisible_Last(visible, orderByComparator);
813
814 if (assetEntry != null) {
815 return assetEntry;
816 }
817
818 StringBundler msg = new StringBundler(4);
819
820 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
821
822 msg.append("visible=");
823 msg.append(visible);
824
825 msg.append(StringPool.CLOSE_CURLY_BRACE);
826
827 throw new NoSuchEntryException(msg.toString());
828 }
829
830
838 @Override
839 public AssetEntry fetchByVisible_Last(boolean visible,
840 OrderByComparator orderByComparator) throws SystemException {
841 int count = countByVisible(visible);
842
843 if (count == 0) {
844 return null;
845 }
846
847 List<AssetEntry> list = findByVisible(visible, count - 1, count,
848 orderByComparator);
849
850 if (!list.isEmpty()) {
851 return list.get(0);
852 }
853
854 return null;
855 }
856
857
867 @Override
868 public AssetEntry[] findByVisible_PrevAndNext(long entryId,
869 boolean visible, OrderByComparator orderByComparator)
870 throws NoSuchEntryException, SystemException {
871 AssetEntry assetEntry = findByPrimaryKey(entryId);
872
873 Session session = null;
874
875 try {
876 session = openSession();
877
878 AssetEntry[] array = new AssetEntryImpl[3];
879
880 array[0] = getByVisible_PrevAndNext(session, assetEntry, visible,
881 orderByComparator, true);
882
883 array[1] = assetEntry;
884
885 array[2] = getByVisible_PrevAndNext(session, assetEntry, visible,
886 orderByComparator, false);
887
888 return array;
889 }
890 catch (Exception e) {
891 throw processException(e);
892 }
893 finally {
894 closeSession(session);
895 }
896 }
897
898 protected AssetEntry getByVisible_PrevAndNext(Session session,
899 AssetEntry assetEntry, boolean visible,
900 OrderByComparator orderByComparator, boolean previous) {
901 StringBundler query = null;
902
903 if (orderByComparator != null) {
904 query = new StringBundler(6 +
905 (orderByComparator.getOrderByFields().length * 6));
906 }
907 else {
908 query = new StringBundler(3);
909 }
910
911 query.append(_SQL_SELECT_ASSETENTRY_WHERE);
912
913 query.append(_FINDER_COLUMN_VISIBLE_VISIBLE_2);
914
915 if (orderByComparator != null) {
916 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
917
918 if (orderByConditionFields.length > 0) {
919 query.append(WHERE_AND);
920 }
921
922 for (int i = 0; i < orderByConditionFields.length; i++) {
923 query.append(_ORDER_BY_ENTITY_ALIAS);
924 query.append(orderByConditionFields[i]);
925
926 if ((i + 1) < orderByConditionFields.length) {
927 if (orderByComparator.isAscending() ^ previous) {
928 query.append(WHERE_GREATER_THAN_HAS_NEXT);
929 }
930 else {
931 query.append(WHERE_LESSER_THAN_HAS_NEXT);
932 }
933 }
934 else {
935 if (orderByComparator.isAscending() ^ previous) {
936 query.append(WHERE_GREATER_THAN);
937 }
938 else {
939 query.append(WHERE_LESSER_THAN);
940 }
941 }
942 }
943
944 query.append(ORDER_BY_CLAUSE);
945
946 String[] orderByFields = orderByComparator.getOrderByFields();
947
948 for (int i = 0; i < orderByFields.length; i++) {
949 query.append(_ORDER_BY_ENTITY_ALIAS);
950 query.append(orderByFields[i]);
951
952 if ((i + 1) < orderByFields.length) {
953 if (orderByComparator.isAscending() ^ previous) {
954 query.append(ORDER_BY_ASC_HAS_NEXT);
955 }
956 else {
957 query.append(ORDER_BY_DESC_HAS_NEXT);
958 }
959 }
960 else {
961 if (orderByComparator.isAscending() ^ previous) {
962 query.append(ORDER_BY_ASC);
963 }
964 else {
965 query.append(ORDER_BY_DESC);
966 }
967 }
968 }
969 }
970 else {
971 query.append(AssetEntryModelImpl.ORDER_BY_JPQL);
972 }
973
974 String sql = query.toString();
975
976 Query q = session.createQuery(sql);
977
978 q.setFirstResult(0);
979 q.setMaxResults(2);
980
981 QueryPos qPos = QueryPos.getInstance(q);
982
983 qPos.add(visible);
984
985 if (orderByComparator != null) {
986 Object[] values = orderByComparator.getOrderByConditionValues(assetEntry);
987
988 for (Object value : values) {
989 qPos.add(value);
990 }
991 }
992
993 List<AssetEntry> list = q.list();
994
995 if (list.size() == 2) {
996 return list.get(1);
997 }
998 else {
999 return null;
1000 }
1001 }
1002
1003
1009 @Override
1010 public void removeByVisible(boolean visible) throws SystemException {
1011 for (AssetEntry assetEntry : findByVisible(visible, QueryUtil.ALL_POS,
1012 QueryUtil.ALL_POS, null)) {
1013 remove(assetEntry);
1014 }
1015 }
1016
1017
1024 @Override
1025 public int countByVisible(boolean visible) throws SystemException {
1026 FinderPath finderPath = FINDER_PATH_COUNT_BY_VISIBLE;
1027
1028 Object[] finderArgs = new Object[] { visible };
1029
1030 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
1031 this);
1032
1033 if (count == null) {
1034 StringBundler query = new StringBundler(2);
1035
1036 query.append(_SQL_COUNT_ASSETENTRY_WHERE);
1037
1038 query.append(_FINDER_COLUMN_VISIBLE_VISIBLE_2);
1039
1040 String sql = query.toString();
1041
1042 Session session = null;
1043
1044 try {
1045 session = openSession();
1046
1047 Query q = session.createQuery(sql);
1048
1049 QueryPos qPos = QueryPos.getInstance(q);
1050
1051 qPos.add(visible);
1052
1053 count = (Long)q.uniqueResult();
1054
1055 FinderCacheUtil.putResult(finderPath, finderArgs, count);
1056 }
1057 catch (Exception e) {
1058 FinderCacheUtil.removeResult(finderPath, finderArgs);
1059
1060 throw processException(e);
1061 }
1062 finally {
1063 closeSession(session);
1064 }
1065 }
1066
1067 return count.intValue();
1068 }
1069
1070 private static final String _FINDER_COLUMN_VISIBLE_VISIBLE_2 = "assetEntry.visible = ?";
1071 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_PUBLISHDATE =
1072 new FinderPath(AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
1073 AssetEntryModelImpl.FINDER_CACHE_ENABLED, AssetEntryImpl.class,
1074 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByPublishDate",
1075 new String[] {
1076 Date.class.getName(),
1077
1078 Integer.class.getName(), Integer.class.getName(),
1079 OrderByComparator.class.getName()
1080 });
1081 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_PUBLISHDATE =
1082 new FinderPath(AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
1083 AssetEntryModelImpl.FINDER_CACHE_ENABLED, AssetEntryImpl.class,
1084 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByPublishDate",
1085 new String[] { Date.class.getName() },
1086 AssetEntryModelImpl.PUBLISHDATE_COLUMN_BITMASK);
1087 public static final FinderPath FINDER_PATH_COUNT_BY_PUBLISHDATE = new FinderPath(AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
1088 AssetEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
1089 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByPublishDate",
1090 new String[] { Date.class.getName() });
1091
1092
1099 @Override
1100 public List<AssetEntry> findByPublishDate(Date publishDate)
1101 throws SystemException {
1102 return findByPublishDate(publishDate, QueryUtil.ALL_POS,
1103 QueryUtil.ALL_POS, null);
1104 }
1105
1106
1119 @Override
1120 public List<AssetEntry> findByPublishDate(Date publishDate, int start,
1121 int end) throws SystemException {
1122 return findByPublishDate(publishDate, start, end, null);
1123 }
1124
1125
1139 @Override
1140 public List<AssetEntry> findByPublishDate(Date publishDate, int start,
1141 int end, OrderByComparator orderByComparator) throws SystemException {
1142 boolean pagination = true;
1143 FinderPath finderPath = null;
1144 Object[] finderArgs = null;
1145
1146 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1147 (orderByComparator == null)) {
1148 pagination = false;
1149 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_PUBLISHDATE;
1150 finderArgs = new Object[] { publishDate };
1151 }
1152 else {
1153 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_PUBLISHDATE;
1154 finderArgs = new Object[] { publishDate, start, end, orderByComparator };
1155 }
1156
1157 List<AssetEntry> list = (List<AssetEntry>)FinderCacheUtil.getResult(finderPath,
1158 finderArgs, this);
1159
1160 if ((list != null) && !list.isEmpty()) {
1161 for (AssetEntry assetEntry : list) {
1162 if (!Validator.equals(publishDate, assetEntry.getPublishDate())) {
1163 list = null;
1164
1165 break;
1166 }
1167 }
1168 }
1169
1170 if (list == null) {
1171 StringBundler query = null;
1172
1173 if (orderByComparator != null) {
1174 query = new StringBundler(3 +
1175 (orderByComparator.getOrderByFields().length * 3));
1176 }
1177 else {
1178 query = new StringBundler(3);
1179 }
1180
1181 query.append(_SQL_SELECT_ASSETENTRY_WHERE);
1182
1183 boolean bindPublishDate = false;
1184
1185 if (publishDate == null) {
1186 query.append(_FINDER_COLUMN_PUBLISHDATE_PUBLISHDATE_1);
1187 }
1188 else {
1189 bindPublishDate = true;
1190
1191 query.append(_FINDER_COLUMN_PUBLISHDATE_PUBLISHDATE_2);
1192 }
1193
1194 if (orderByComparator != null) {
1195 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1196 orderByComparator);
1197 }
1198 else
1199 if (pagination) {
1200 query.append(AssetEntryModelImpl.ORDER_BY_JPQL);
1201 }
1202
1203 String sql = query.toString();
1204
1205 Session session = null;
1206
1207 try {
1208 session = openSession();
1209
1210 Query q = session.createQuery(sql);
1211
1212 QueryPos qPos = QueryPos.getInstance(q);
1213
1214 if (bindPublishDate) {
1215 qPos.add(CalendarUtil.getTimestamp(publishDate));
1216 }
1217
1218 if (!pagination) {
1219 list = (List<AssetEntry>)QueryUtil.list(q, getDialect(),
1220 start, end, false);
1221
1222 Collections.sort(list);
1223
1224 list = new UnmodifiableList<AssetEntry>(list);
1225 }
1226 else {
1227 list = (List<AssetEntry>)QueryUtil.list(q, getDialect(),
1228 start, end);
1229 }
1230
1231 cacheResult(list);
1232
1233 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1234 }
1235 catch (Exception e) {
1236 FinderCacheUtil.removeResult(finderPath, finderArgs);
1237
1238 throw processException(e);
1239 }
1240 finally {
1241 closeSession(session);
1242 }
1243 }
1244
1245 return list;
1246 }
1247
1248
1257 @Override
1258 public AssetEntry findByPublishDate_First(Date publishDate,
1259 OrderByComparator orderByComparator)
1260 throws NoSuchEntryException, SystemException {
1261 AssetEntry assetEntry = fetchByPublishDate_First(publishDate,
1262 orderByComparator);
1263
1264 if (assetEntry != null) {
1265 return assetEntry;
1266 }
1267
1268 StringBundler msg = new StringBundler(4);
1269
1270 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1271
1272 msg.append("publishDate=");
1273 msg.append(publishDate);
1274
1275 msg.append(StringPool.CLOSE_CURLY_BRACE);
1276
1277 throw new NoSuchEntryException(msg.toString());
1278 }
1279
1280
1288 @Override
1289 public AssetEntry fetchByPublishDate_First(Date publishDate,
1290 OrderByComparator orderByComparator) throws SystemException {
1291 List<AssetEntry> list = findByPublishDate(publishDate, 0, 1,
1292 orderByComparator);
1293
1294 if (!list.isEmpty()) {
1295 return list.get(0);
1296 }
1297
1298 return null;
1299 }
1300
1301
1310 @Override
1311 public AssetEntry findByPublishDate_Last(Date publishDate,
1312 OrderByComparator orderByComparator)
1313 throws NoSuchEntryException, SystemException {
1314 AssetEntry assetEntry = fetchByPublishDate_Last(publishDate,
1315 orderByComparator);
1316
1317 if (assetEntry != null) {
1318 return assetEntry;
1319 }
1320
1321 StringBundler msg = new StringBundler(4);
1322
1323 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1324
1325 msg.append("publishDate=");
1326 msg.append(publishDate);
1327
1328 msg.append(StringPool.CLOSE_CURLY_BRACE);
1329
1330 throw new NoSuchEntryException(msg.toString());
1331 }
1332
1333
1341 @Override
1342 public AssetEntry fetchByPublishDate_Last(Date publishDate,
1343 OrderByComparator orderByComparator) throws SystemException {
1344 int count = countByPublishDate(publishDate);
1345
1346 if (count == 0) {
1347 return null;
1348 }
1349
1350 List<AssetEntry> list = findByPublishDate(publishDate, count - 1,
1351 count, orderByComparator);
1352
1353 if (!list.isEmpty()) {
1354 return list.get(0);
1355 }
1356
1357 return null;
1358 }
1359
1360
1370 @Override
1371 public AssetEntry[] findByPublishDate_PrevAndNext(long entryId,
1372 Date publishDate, OrderByComparator orderByComparator)
1373 throws NoSuchEntryException, SystemException {
1374 AssetEntry assetEntry = findByPrimaryKey(entryId);
1375
1376 Session session = null;
1377
1378 try {
1379 session = openSession();
1380
1381 AssetEntry[] array = new AssetEntryImpl[3];
1382
1383 array[0] = getByPublishDate_PrevAndNext(session, assetEntry,
1384 publishDate, orderByComparator, true);
1385
1386 array[1] = assetEntry;
1387
1388 array[2] = getByPublishDate_PrevAndNext(session, assetEntry,
1389 publishDate, orderByComparator, false);
1390
1391 return array;
1392 }
1393 catch (Exception e) {
1394 throw processException(e);
1395 }
1396 finally {
1397 closeSession(session);
1398 }
1399 }
1400
1401 protected AssetEntry getByPublishDate_PrevAndNext(Session session,
1402 AssetEntry assetEntry, Date publishDate,
1403 OrderByComparator orderByComparator, boolean previous) {
1404 StringBundler query = null;
1405
1406 if (orderByComparator != null) {
1407 query = new StringBundler(6 +
1408 (orderByComparator.getOrderByFields().length * 6));
1409 }
1410 else {
1411 query = new StringBundler(3);
1412 }
1413
1414 query.append(_SQL_SELECT_ASSETENTRY_WHERE);
1415
1416 boolean bindPublishDate = false;
1417
1418 if (publishDate == null) {
1419 query.append(_FINDER_COLUMN_PUBLISHDATE_PUBLISHDATE_1);
1420 }
1421 else {
1422 bindPublishDate = true;
1423
1424 query.append(_FINDER_COLUMN_PUBLISHDATE_PUBLISHDATE_2);
1425 }
1426
1427 if (orderByComparator != null) {
1428 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1429
1430 if (orderByConditionFields.length > 0) {
1431 query.append(WHERE_AND);
1432 }
1433
1434 for (int i = 0; i < orderByConditionFields.length; i++) {
1435 query.append(_ORDER_BY_ENTITY_ALIAS);
1436 query.append(orderByConditionFields[i]);
1437
1438 if ((i + 1) < orderByConditionFields.length) {
1439 if (orderByComparator.isAscending() ^ previous) {
1440 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1441 }
1442 else {
1443 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1444 }
1445 }
1446 else {
1447 if (orderByComparator.isAscending() ^ previous) {
1448 query.append(WHERE_GREATER_THAN);
1449 }
1450 else {
1451 query.append(WHERE_LESSER_THAN);
1452 }
1453 }
1454 }
1455
1456 query.append(ORDER_BY_CLAUSE);
1457
1458 String[] orderByFields = orderByComparator.getOrderByFields();
1459
1460 for (int i = 0; i < orderByFields.length; i++) {
1461 query.append(_ORDER_BY_ENTITY_ALIAS);
1462 query.append(orderByFields[i]);
1463
1464 if ((i + 1) < orderByFields.length) {
1465 if (orderByComparator.isAscending() ^ previous) {
1466 query.append(ORDER_BY_ASC_HAS_NEXT);
1467 }
1468 else {
1469 query.append(ORDER_BY_DESC_HAS_NEXT);
1470 }
1471 }
1472 else {
1473 if (orderByComparator.isAscending() ^ previous) {
1474 query.append(ORDER_BY_ASC);
1475 }
1476 else {
1477 query.append(ORDER_BY_DESC);
1478 }
1479 }
1480 }
1481 }
1482 else {
1483 query.append(AssetEntryModelImpl.ORDER_BY_JPQL);
1484 }
1485
1486 String sql = query.toString();
1487
1488 Query q = session.createQuery(sql);
1489
1490 q.setFirstResult(0);
1491 q.setMaxResults(2);
1492
1493 QueryPos qPos = QueryPos.getInstance(q);
1494
1495 if (bindPublishDate) {
1496 qPos.add(CalendarUtil.getTimestamp(publishDate));
1497 }
1498
1499 if (orderByComparator != null) {
1500 Object[] values = orderByComparator.getOrderByConditionValues(assetEntry);
1501
1502 for (Object value : values) {
1503 qPos.add(value);
1504 }
1505 }
1506
1507 List<AssetEntry> list = q.list();
1508
1509 if (list.size() == 2) {
1510 return list.get(1);
1511 }
1512 else {
1513 return null;
1514 }
1515 }
1516
1517
1523 @Override
1524 public void removeByPublishDate(Date publishDate) throws SystemException {
1525 for (AssetEntry assetEntry : findByPublishDate(publishDate,
1526 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
1527 remove(assetEntry);
1528 }
1529 }
1530
1531
1538 @Override
1539 public int countByPublishDate(Date publishDate) throws SystemException {
1540 FinderPath finderPath = FINDER_PATH_COUNT_BY_PUBLISHDATE;
1541
1542 Object[] finderArgs = new Object[] { publishDate };
1543
1544 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
1545 this);
1546
1547 if (count == null) {
1548 StringBundler query = new StringBundler(2);
1549
1550 query.append(_SQL_COUNT_ASSETENTRY_WHERE);
1551
1552 boolean bindPublishDate = false;
1553
1554 if (publishDate == null) {
1555 query.append(_FINDER_COLUMN_PUBLISHDATE_PUBLISHDATE_1);
1556 }
1557 else {
1558 bindPublishDate = true;
1559
1560 query.append(_FINDER_COLUMN_PUBLISHDATE_PUBLISHDATE_2);
1561 }
1562
1563 String sql = query.toString();
1564
1565 Session session = null;
1566
1567 try {
1568 session = openSession();
1569
1570 Query q = session.createQuery(sql);
1571
1572 QueryPos qPos = QueryPos.getInstance(q);
1573
1574 if (bindPublishDate) {
1575 qPos.add(CalendarUtil.getTimestamp(publishDate));
1576 }
1577
1578 count = (Long)q.uniqueResult();
1579
1580 FinderCacheUtil.putResult(finderPath, finderArgs, count);
1581 }
1582 catch (Exception e) {
1583 FinderCacheUtil.removeResult(finderPath, finderArgs);
1584
1585 throw processException(e);
1586 }
1587 finally {
1588 closeSession(session);
1589 }
1590 }
1591
1592 return count.intValue();
1593 }
1594
1595 private static final String _FINDER_COLUMN_PUBLISHDATE_PUBLISHDATE_1 = "assetEntry.publishDate IS NULL";
1596 private static final String _FINDER_COLUMN_PUBLISHDATE_PUBLISHDATE_2 = "assetEntry.publishDate = ?";
1597 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_EXPIRATIONDATE =
1598 new FinderPath(AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
1599 AssetEntryModelImpl.FINDER_CACHE_ENABLED, AssetEntryImpl.class,
1600 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByExpirationDate",
1601 new String[] {
1602 Date.class.getName(),
1603
1604 Integer.class.getName(), Integer.class.getName(),
1605 OrderByComparator.class.getName()
1606 });
1607 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_EXPIRATIONDATE =
1608 new FinderPath(AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
1609 AssetEntryModelImpl.FINDER_CACHE_ENABLED, AssetEntryImpl.class,
1610 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByExpirationDate",
1611 new String[] { Date.class.getName() },
1612 AssetEntryModelImpl.EXPIRATIONDATE_COLUMN_BITMASK);
1613 public static final FinderPath FINDER_PATH_COUNT_BY_EXPIRATIONDATE = new FinderPath(AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
1614 AssetEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
1615 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByExpirationDate",
1616 new String[] { Date.class.getName() });
1617
1618
1625 @Override
1626 public List<AssetEntry> findByExpirationDate(Date expirationDate)
1627 throws SystemException {
1628 return findByExpirationDate(expirationDate, QueryUtil.ALL_POS,
1629 QueryUtil.ALL_POS, null);
1630 }
1631
1632
1645 @Override
1646 public List<AssetEntry> findByExpirationDate(Date expirationDate,
1647 int start, int end) throws SystemException {
1648 return findByExpirationDate(expirationDate, start, end, null);
1649 }
1650
1651
1665 @Override
1666 public List<AssetEntry> findByExpirationDate(Date expirationDate,
1667 int start, int end, OrderByComparator orderByComparator)
1668 throws SystemException {
1669 boolean pagination = true;
1670 FinderPath finderPath = null;
1671 Object[] finderArgs = null;
1672
1673 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1674 (orderByComparator == null)) {
1675 pagination = false;
1676 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_EXPIRATIONDATE;
1677 finderArgs = new Object[] { expirationDate };
1678 }
1679 else {
1680 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_EXPIRATIONDATE;
1681 finderArgs = new Object[] {
1682 expirationDate,
1683
1684 start, end, orderByComparator
1685 };
1686 }
1687
1688 List<AssetEntry> list = (List<AssetEntry>)FinderCacheUtil.getResult(finderPath,
1689 finderArgs, this);
1690
1691 if ((list != null) && !list.isEmpty()) {
1692 for (AssetEntry assetEntry : list) {
1693 if (!Validator.equals(expirationDate,
1694 assetEntry.getExpirationDate())) {
1695 list = null;
1696
1697 break;
1698 }
1699 }
1700 }
1701
1702 if (list == null) {
1703 StringBundler query = null;
1704
1705 if (orderByComparator != null) {
1706 query = new StringBundler(3 +
1707 (orderByComparator.getOrderByFields().length * 3));
1708 }
1709 else {
1710 query = new StringBundler(3);
1711 }
1712
1713 query.append(_SQL_SELECT_ASSETENTRY_WHERE);
1714
1715 boolean bindExpirationDate = false;
1716
1717 if (expirationDate == null) {
1718 query.append(_FINDER_COLUMN_EXPIRATIONDATE_EXPIRATIONDATE_1);
1719 }
1720 else {
1721 bindExpirationDate = true;
1722
1723 query.append(_FINDER_COLUMN_EXPIRATIONDATE_EXPIRATIONDATE_2);
1724 }
1725
1726 if (orderByComparator != null) {
1727 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1728 orderByComparator);
1729 }
1730 else
1731 if (pagination) {
1732 query.append(AssetEntryModelImpl.ORDER_BY_JPQL);
1733 }
1734
1735 String sql = query.toString();
1736
1737 Session session = null;
1738
1739 try {
1740 session = openSession();
1741
1742 Query q = session.createQuery(sql);
1743
1744 QueryPos qPos = QueryPos.getInstance(q);
1745
1746 if (bindExpirationDate) {
1747 qPos.add(CalendarUtil.getTimestamp(expirationDate));
1748 }
1749
1750 if (!pagination) {
1751 list = (List<AssetEntry>)QueryUtil.list(q, getDialect(),
1752 start, end, false);
1753
1754 Collections.sort(list);
1755
1756 list = new UnmodifiableList<AssetEntry>(list);
1757 }
1758 else {
1759 list = (List<AssetEntry>)QueryUtil.list(q, getDialect(),
1760 start, end);
1761 }
1762
1763 cacheResult(list);
1764
1765 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1766 }
1767 catch (Exception e) {
1768 FinderCacheUtil.removeResult(finderPath, finderArgs);
1769
1770 throw processException(e);
1771 }
1772 finally {
1773 closeSession(session);
1774 }
1775 }
1776
1777 return list;
1778 }
1779
1780
1789 @Override
1790 public AssetEntry findByExpirationDate_First(Date expirationDate,
1791 OrderByComparator orderByComparator)
1792 throws NoSuchEntryException, SystemException {
1793 AssetEntry assetEntry = fetchByExpirationDate_First(expirationDate,
1794 orderByComparator);
1795
1796 if (assetEntry != null) {
1797 return assetEntry;
1798 }
1799
1800 StringBundler msg = new StringBundler(4);
1801
1802 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1803
1804 msg.append("expirationDate=");
1805 msg.append(expirationDate);
1806
1807 msg.append(StringPool.CLOSE_CURLY_BRACE);
1808
1809 throw new NoSuchEntryException(msg.toString());
1810 }
1811
1812
1820 @Override
1821 public AssetEntry fetchByExpirationDate_First(Date expirationDate,
1822 OrderByComparator orderByComparator) throws SystemException {
1823 List<AssetEntry> list = findByExpirationDate(expirationDate, 0, 1,
1824 orderByComparator);
1825
1826 if (!list.isEmpty()) {
1827 return list.get(0);
1828 }
1829
1830 return null;
1831 }
1832
1833
1842 @Override
1843 public AssetEntry findByExpirationDate_Last(Date expirationDate,
1844 OrderByComparator orderByComparator)
1845 throws NoSuchEntryException, SystemException {
1846 AssetEntry assetEntry = fetchByExpirationDate_Last(expirationDate,
1847 orderByComparator);
1848
1849 if (assetEntry != null) {
1850 return assetEntry;
1851 }
1852
1853 StringBundler msg = new StringBundler(4);
1854
1855 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1856
1857 msg.append("expirationDate=");
1858 msg.append(expirationDate);
1859
1860 msg.append(StringPool.CLOSE_CURLY_BRACE);
1861
1862 throw new NoSuchEntryException(msg.toString());
1863 }
1864
1865
1873 @Override
1874 public AssetEntry fetchByExpirationDate_Last(Date expirationDate,
1875 OrderByComparator orderByComparator) throws SystemException {
1876 int count = countByExpirationDate(expirationDate);
1877
1878 if (count == 0) {
1879 return null;
1880 }
1881
1882 List<AssetEntry> list = findByExpirationDate(expirationDate, count - 1,
1883 count, orderByComparator);
1884
1885 if (!list.isEmpty()) {
1886 return list.get(0);
1887 }
1888
1889 return null;
1890 }
1891
1892
1902 @Override
1903 public AssetEntry[] findByExpirationDate_PrevAndNext(long entryId,
1904 Date expirationDate, OrderByComparator orderByComparator)
1905 throws NoSuchEntryException, SystemException {
1906 AssetEntry assetEntry = findByPrimaryKey(entryId);
1907
1908 Session session = null;
1909
1910 try {
1911 session = openSession();
1912
1913 AssetEntry[] array = new AssetEntryImpl[3];
1914
1915 array[0] = getByExpirationDate_PrevAndNext(session, assetEntry,
1916 expirationDate, orderByComparator, true);
1917
1918 array[1] = assetEntry;
1919
1920 array[2] = getByExpirationDate_PrevAndNext(session, assetEntry,
1921 expirationDate, orderByComparator, false);
1922
1923 return array;
1924 }
1925 catch (Exception e) {
1926 throw processException(e);
1927 }
1928 finally {
1929 closeSession(session);
1930 }
1931 }
1932
1933 protected AssetEntry getByExpirationDate_PrevAndNext(Session session,
1934 AssetEntry assetEntry, Date expirationDate,
1935 OrderByComparator orderByComparator, boolean previous) {
1936 StringBundler query = null;
1937
1938 if (orderByComparator != null) {
1939 query = new StringBundler(6 +
1940 (orderByComparator.getOrderByFields().length * 6));
1941 }
1942 else {
1943 query = new StringBundler(3);
1944 }
1945
1946 query.append(_SQL_SELECT_ASSETENTRY_WHERE);
1947
1948 boolean bindExpirationDate = false;
1949
1950 if (expirationDate == null) {
1951 query.append(_FINDER_COLUMN_EXPIRATIONDATE_EXPIRATIONDATE_1);
1952 }
1953 else {
1954 bindExpirationDate = true;
1955
1956 query.append(_FINDER_COLUMN_EXPIRATIONDATE_EXPIRATIONDATE_2);
1957 }
1958
1959 if (orderByComparator != null) {
1960 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1961
1962 if (orderByConditionFields.length > 0) {
1963 query.append(WHERE_AND);
1964 }
1965
1966 for (int i = 0; i < orderByConditionFields.length; i++) {
1967 query.append(_ORDER_BY_ENTITY_ALIAS);
1968 query.append(orderByConditionFields[i]);
1969
1970 if ((i + 1) < orderByConditionFields.length) {
1971 if (orderByComparator.isAscending() ^ previous) {
1972 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1973 }
1974 else {
1975 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1976 }
1977 }
1978 else {
1979 if (orderByComparator.isAscending() ^ previous) {
1980 query.append(WHERE_GREATER_THAN);
1981 }
1982 else {
1983 query.append(WHERE_LESSER_THAN);
1984 }
1985 }
1986 }
1987
1988 query.append(ORDER_BY_CLAUSE);
1989
1990 String[] orderByFields = orderByComparator.getOrderByFields();
1991
1992 for (int i = 0; i < orderByFields.length; i++) {
1993 query.append(_ORDER_BY_ENTITY_ALIAS);
1994 query.append(orderByFields[i]);
1995
1996 if ((i + 1) < orderByFields.length) {
1997 if (orderByComparator.isAscending() ^ previous) {
1998 query.append(ORDER_BY_ASC_HAS_NEXT);
1999 }
2000 else {
2001 query.append(ORDER_BY_DESC_HAS_NEXT);
2002 }
2003 }
2004 else {
2005 if (orderByComparator.isAscending() ^ previous) {
2006 query.append(ORDER_BY_ASC);
2007 }
2008 else {
2009 query.append(ORDER_BY_DESC);
2010 }
2011 }
2012 }
2013 }
2014 else {
2015 query.append(AssetEntryModelImpl.ORDER_BY_JPQL);
2016 }
2017
2018 String sql = query.toString();
2019
2020 Query q = session.createQuery(sql);
2021
2022 q.setFirstResult(0);
2023 q.setMaxResults(2);
2024
2025 QueryPos qPos = QueryPos.getInstance(q);
2026
2027 if (bindExpirationDate) {
2028 qPos.add(CalendarUtil.getTimestamp(expirationDate));
2029 }
2030
2031 if (orderByComparator != null) {
2032 Object[] values = orderByComparator.getOrderByConditionValues(assetEntry);
2033
2034 for (Object value : values) {
2035 qPos.add(value);
2036 }
2037 }
2038
2039 List<AssetEntry> list = q.list();
2040
2041 if (list.size() == 2) {
2042 return list.get(1);
2043 }
2044 else {
2045 return null;
2046 }
2047 }
2048
2049
2055 @Override
2056 public void removeByExpirationDate(Date expirationDate)
2057 throws SystemException {
2058 for (AssetEntry assetEntry : findByExpirationDate(expirationDate,
2059 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
2060 remove(assetEntry);
2061 }
2062 }
2063
2064
2071 @Override
2072 public int countByExpirationDate(Date expirationDate)
2073 throws SystemException {
2074 FinderPath finderPath = FINDER_PATH_COUNT_BY_EXPIRATIONDATE;
2075
2076 Object[] finderArgs = new Object[] { expirationDate };
2077
2078 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
2079 this);
2080
2081 if (count == null) {
2082 StringBundler query = new StringBundler(2);
2083
2084 query.append(_SQL_COUNT_ASSETENTRY_WHERE);
2085
2086 boolean bindExpirationDate = false;
2087
2088 if (expirationDate == null) {
2089 query.append(_FINDER_COLUMN_EXPIRATIONDATE_EXPIRATIONDATE_1);
2090 }
2091 else {
2092 bindExpirationDate = true;
2093
2094 query.append(_FINDER_COLUMN_EXPIRATIONDATE_EXPIRATIONDATE_2);
2095 }
2096
2097 String sql = query.toString();
2098
2099 Session session = null;
2100
2101 try {
2102 session = openSession();
2103
2104 Query q = session.createQuery(sql);
2105
2106 QueryPos qPos = QueryPos.getInstance(q);
2107
2108 if (bindExpirationDate) {
2109 qPos.add(CalendarUtil.getTimestamp(expirationDate));
2110 }
2111
2112 count = (Long)q.uniqueResult();
2113
2114 FinderCacheUtil.putResult(finderPath, finderArgs, count);
2115 }
2116 catch (Exception e) {
2117 FinderCacheUtil.removeResult(finderPath, finderArgs);
2118
2119 throw processException(e);
2120 }
2121 finally {
2122 closeSession(session);
2123 }
2124 }
2125
2126 return count.intValue();
2127 }
2128
2129 private static final String _FINDER_COLUMN_EXPIRATIONDATE_EXPIRATIONDATE_1 = "assetEntry.expirationDate IS NULL";
2130 private static final String _FINDER_COLUMN_EXPIRATIONDATE_EXPIRATIONDATE_2 = "assetEntry.expirationDate = ?";
2131 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_LAYOUTUUID =
2132 new FinderPath(AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
2133 AssetEntryModelImpl.FINDER_CACHE_ENABLED, AssetEntryImpl.class,
2134 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByLayoutUuid",
2135 new String[] {
2136 String.class.getName(),
2137
2138 Integer.class.getName(), Integer.class.getName(),
2139 OrderByComparator.class.getName()
2140 });
2141 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_LAYOUTUUID =
2142 new FinderPath(AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
2143 AssetEntryModelImpl.FINDER_CACHE_ENABLED, AssetEntryImpl.class,
2144 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByLayoutUuid",
2145 new String[] { String.class.getName() },
2146 AssetEntryModelImpl.LAYOUTUUID_COLUMN_BITMASK);
2147 public static final FinderPath FINDER_PATH_COUNT_BY_LAYOUTUUID = new FinderPath(AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
2148 AssetEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
2149 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByLayoutUuid",
2150 new String[] { String.class.getName() });
2151
2152
2159 @Override
2160 public List<AssetEntry> findByLayoutUuid(String layoutUuid)
2161 throws SystemException {
2162 return findByLayoutUuid(layoutUuid, QueryUtil.ALL_POS,
2163 QueryUtil.ALL_POS, null);
2164 }
2165
2166
2179 @Override
2180 public List<AssetEntry> findByLayoutUuid(String layoutUuid, int start,
2181 int end) throws SystemException {
2182 return findByLayoutUuid(layoutUuid, start, end, null);
2183 }
2184
2185
2199 @Override
2200 public List<AssetEntry> findByLayoutUuid(String layoutUuid, int start,
2201 int end, OrderByComparator orderByComparator) throws SystemException {
2202 boolean pagination = true;
2203 FinderPath finderPath = null;
2204 Object[] finderArgs = null;
2205
2206 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2207 (orderByComparator == null)) {
2208 pagination = false;
2209 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_LAYOUTUUID;
2210 finderArgs = new Object[] { layoutUuid };
2211 }
2212 else {
2213 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_LAYOUTUUID;
2214 finderArgs = new Object[] { layoutUuid, start, end, orderByComparator };
2215 }
2216
2217 List<AssetEntry> list = (List<AssetEntry>)FinderCacheUtil.getResult(finderPath,
2218 finderArgs, this);
2219
2220 if ((list != null) && !list.isEmpty()) {
2221 for (AssetEntry assetEntry : list) {
2222 if (!Validator.equals(layoutUuid, assetEntry.getLayoutUuid())) {
2223 list = null;
2224
2225 break;
2226 }
2227 }
2228 }
2229
2230 if (list == null) {
2231 StringBundler query = null;
2232
2233 if (orderByComparator != null) {
2234 query = new StringBundler(3 +
2235 (orderByComparator.getOrderByFields().length * 3));
2236 }
2237 else {
2238 query = new StringBundler(3);
2239 }
2240
2241 query.append(_SQL_SELECT_ASSETENTRY_WHERE);
2242
2243 boolean bindLayoutUuid = false;
2244
2245 if (layoutUuid == null) {
2246 query.append(_FINDER_COLUMN_LAYOUTUUID_LAYOUTUUID_1);
2247 }
2248 else if (layoutUuid.equals(StringPool.BLANK)) {
2249 query.append(_FINDER_COLUMN_LAYOUTUUID_LAYOUTUUID_3);
2250 }
2251 else {
2252 bindLayoutUuid = true;
2253
2254 query.append(_FINDER_COLUMN_LAYOUTUUID_LAYOUTUUID_2);
2255 }
2256
2257 if (orderByComparator != null) {
2258 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2259 orderByComparator);
2260 }
2261 else
2262 if (pagination) {
2263 query.append(AssetEntryModelImpl.ORDER_BY_JPQL);
2264 }
2265
2266 String sql = query.toString();
2267
2268 Session session = null;
2269
2270 try {
2271 session = openSession();
2272
2273 Query q = session.createQuery(sql);
2274
2275 QueryPos qPos = QueryPos.getInstance(q);
2276
2277 if (bindLayoutUuid) {
2278 qPos.add(layoutUuid);
2279 }
2280
2281 if (!pagination) {
2282 list = (List<AssetEntry>)QueryUtil.list(q, getDialect(),
2283 start, end, false);
2284
2285 Collections.sort(list);
2286
2287 list = new UnmodifiableList<AssetEntry>(list);
2288 }
2289 else {
2290 list = (List<AssetEntry>)QueryUtil.list(q, getDialect(),
2291 start, end);
2292 }
2293
2294 cacheResult(list);
2295
2296 FinderCacheUtil.putResult(finderPath, finderArgs, list);
2297 }
2298 catch (Exception e) {
2299 FinderCacheUtil.removeResult(finderPath, finderArgs);
2300
2301 throw processException(e);
2302 }
2303 finally {
2304 closeSession(session);
2305 }
2306 }
2307
2308 return list;
2309 }
2310
2311
2320 @Override
2321 public AssetEntry findByLayoutUuid_First(String layoutUuid,
2322 OrderByComparator orderByComparator)
2323 throws NoSuchEntryException, SystemException {
2324 AssetEntry assetEntry = fetchByLayoutUuid_First(layoutUuid,
2325 orderByComparator);
2326
2327 if (assetEntry != null) {
2328 return assetEntry;
2329 }
2330
2331 StringBundler msg = new StringBundler(4);
2332
2333 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2334
2335 msg.append("layoutUuid=");
2336 msg.append(layoutUuid);
2337
2338 msg.append(StringPool.CLOSE_CURLY_BRACE);
2339
2340 throw new NoSuchEntryException(msg.toString());
2341 }
2342
2343
2351 @Override
2352 public AssetEntry fetchByLayoutUuid_First(String layoutUuid,
2353 OrderByComparator orderByComparator) throws SystemException {
2354 List<AssetEntry> list = findByLayoutUuid(layoutUuid, 0, 1,
2355 orderByComparator);
2356
2357 if (!list.isEmpty()) {
2358 return list.get(0);
2359 }
2360
2361 return null;
2362 }
2363
2364
2373 @Override
2374 public AssetEntry findByLayoutUuid_Last(String layoutUuid,
2375 OrderByComparator orderByComparator)
2376 throws NoSuchEntryException, SystemException {
2377 AssetEntry assetEntry = fetchByLayoutUuid_Last(layoutUuid,
2378 orderByComparator);
2379
2380 if (assetEntry != null) {
2381 return assetEntry;
2382 }
2383
2384 StringBundler msg = new StringBundler(4);
2385
2386 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2387
2388 msg.append("layoutUuid=");
2389 msg.append(layoutUuid);
2390
2391 msg.append(StringPool.CLOSE_CURLY_BRACE);
2392
2393 throw new NoSuchEntryException(msg.toString());
2394 }
2395
2396
2404 @Override
2405 public AssetEntry fetchByLayoutUuid_Last(String layoutUuid,
2406 OrderByComparator orderByComparator) throws SystemException {
2407 int count = countByLayoutUuid(layoutUuid);
2408
2409 if (count == 0) {
2410 return null;
2411 }
2412
2413 List<AssetEntry> list = findByLayoutUuid(layoutUuid, count - 1, count,
2414 orderByComparator);
2415
2416 if (!list.isEmpty()) {
2417 return list.get(0);
2418 }
2419
2420 return null;
2421 }
2422
2423
2433 @Override
2434 public AssetEntry[] findByLayoutUuid_PrevAndNext(long entryId,
2435 String layoutUuid, OrderByComparator orderByComparator)
2436 throws NoSuchEntryException, SystemException {
2437 AssetEntry assetEntry = findByPrimaryKey(entryId);
2438
2439 Session session = null;
2440
2441 try {
2442 session = openSession();
2443
2444 AssetEntry[] array = new AssetEntryImpl[3];
2445
2446 array[0] = getByLayoutUuid_PrevAndNext(session, assetEntry,
2447 layoutUuid, orderByComparator, true);
2448
2449 array[1] = assetEntry;
2450
2451 array[2] = getByLayoutUuid_PrevAndNext(session, assetEntry,
2452 layoutUuid, orderByComparator, false);
2453
2454 return array;
2455 }
2456 catch (Exception e) {
2457 throw processException(e);
2458 }
2459 finally {
2460 closeSession(session);
2461 }
2462 }
2463
2464 protected AssetEntry getByLayoutUuid_PrevAndNext(Session session,
2465 AssetEntry assetEntry, String layoutUuid,
2466 OrderByComparator orderByComparator, boolean previous) {
2467 StringBundler query = null;
2468
2469 if (orderByComparator != null) {
2470 query = new StringBundler(6 +
2471 (orderByComparator.getOrderByFields().length * 6));
2472 }
2473 else {
2474 query = new StringBundler(3);
2475 }
2476
2477 query.append(_SQL_SELECT_ASSETENTRY_WHERE);
2478
2479 boolean bindLayoutUuid = false;
2480
2481 if (layoutUuid == null) {
2482 query.append(_FINDER_COLUMN_LAYOUTUUID_LAYOUTUUID_1);
2483 }
2484 else if (layoutUuid.equals(StringPool.BLANK)) {
2485 query.append(_FINDER_COLUMN_LAYOUTUUID_LAYOUTUUID_3);
2486 }
2487 else {
2488 bindLayoutUuid = true;
2489
2490 query.append(_FINDER_COLUMN_LAYOUTUUID_LAYOUTUUID_2);
2491 }
2492
2493 if (orderByComparator != null) {
2494 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2495
2496 if (orderByConditionFields.length > 0) {
2497 query.append(WHERE_AND);
2498 }
2499
2500 for (int i = 0; i < orderByConditionFields.length; i++) {
2501 query.append(_ORDER_BY_ENTITY_ALIAS);
2502 query.append(orderByConditionFields[i]);
2503
2504 if ((i + 1) < orderByConditionFields.length) {
2505 if (orderByComparator.isAscending() ^ previous) {
2506 query.append(WHERE_GREATER_THAN_HAS_NEXT);
2507 }
2508 else {
2509 query.append(WHERE_LESSER_THAN_HAS_NEXT);
2510 }
2511 }
2512 else {
2513 if (orderByComparator.isAscending() ^ previous) {
2514 query.append(WHERE_GREATER_THAN);
2515 }
2516 else {
2517 query.append(WHERE_LESSER_THAN);
2518 }
2519 }
2520 }
2521
2522 query.append(ORDER_BY_CLAUSE);
2523
2524 String[] orderByFields = orderByComparator.getOrderByFields();
2525
2526 for (int i = 0; i < orderByFields.length; i++) {
2527 query.append(_ORDER_BY_ENTITY_ALIAS);
2528 query.append(orderByFields[i]);
2529
2530 if ((i + 1) < orderByFields.length) {
2531 if (orderByComparator.isAscending() ^ previous) {
2532 query.append(ORDER_BY_ASC_HAS_NEXT);
2533 }
2534 else {
2535 query.append(ORDER_BY_DESC_HAS_NEXT);
2536 }
2537 }
2538 else {
2539 if (orderByComparator.isAscending() ^ previous) {
2540 query.append(ORDER_BY_ASC);
2541 }
2542 else {
2543 query.append(ORDER_BY_DESC);
2544 }
2545 }
2546 }
2547 }
2548 else {
2549 query.append(AssetEntryModelImpl.ORDER_BY_JPQL);
2550 }
2551
2552 String sql = query.toString();
2553
2554 Query q = session.createQuery(sql);
2555
2556 q.setFirstResult(0);
2557 q.setMaxResults(2);
2558
2559 QueryPos qPos = QueryPos.getInstance(q);
2560
2561 if (bindLayoutUuid) {
2562 qPos.add(layoutUuid);
2563 }
2564
2565 if (orderByComparator != null) {
2566 Object[] values = orderByComparator.getOrderByConditionValues(assetEntry);
2567
2568 for (Object value : values) {
2569 qPos.add(value);
2570 }
2571 }
2572
2573 List<AssetEntry> list = q.list();
2574
2575 if (list.size() == 2) {
2576 return list.get(1);
2577 }
2578 else {
2579 return null;
2580 }
2581 }
2582
2583
2589 @Override
2590 public void removeByLayoutUuid(String layoutUuid) throws SystemException {
2591 for (AssetEntry assetEntry : findByLayoutUuid(layoutUuid,
2592 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
2593 remove(assetEntry);
2594 }
2595 }
2596
2597
2604 @Override
2605 public int countByLayoutUuid(String layoutUuid) throws SystemException {
2606 FinderPath finderPath = FINDER_PATH_COUNT_BY_LAYOUTUUID;
2607
2608 Object[] finderArgs = new Object[] { layoutUuid };
2609
2610 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
2611 this);
2612
2613 if (count == null) {
2614 StringBundler query = new StringBundler(2);
2615
2616 query.append(_SQL_COUNT_ASSETENTRY_WHERE);
2617
2618 boolean bindLayoutUuid = false;
2619
2620 if (layoutUuid == null) {
2621 query.append(_FINDER_COLUMN_LAYOUTUUID_LAYOUTUUID_1);
2622 }
2623 else if (layoutUuid.equals(StringPool.BLANK)) {
2624 query.append(_FINDER_COLUMN_LAYOUTUUID_LAYOUTUUID_3);
2625 }
2626 else {
2627 bindLayoutUuid = true;
2628
2629 query.append(_FINDER_COLUMN_LAYOUTUUID_LAYOUTUUID_2);
2630 }
2631
2632 String sql = query.toString();
2633
2634 Session session = null;
2635
2636 try {
2637 session = openSession();
2638
2639 Query q = session.createQuery(sql);
2640
2641 QueryPos qPos = QueryPos.getInstance(q);
2642
2643 if (bindLayoutUuid) {
2644 qPos.add(layoutUuid);
2645 }
2646
2647 count = (Long)q.uniqueResult();
2648
2649 FinderCacheUtil.putResult(finderPath, finderArgs, count);
2650 }
2651 catch (Exception e) {
2652 FinderCacheUtil.removeResult(finderPath, finderArgs);
2653
2654 throw processException(e);
2655 }
2656 finally {
2657 closeSession(session);
2658 }
2659 }
2660
2661 return count.intValue();
2662 }
2663
2664 private static final String _FINDER_COLUMN_LAYOUTUUID_LAYOUTUUID_1 = "assetEntry.layoutUuid IS NULL";
2665 private static final String _FINDER_COLUMN_LAYOUTUUID_LAYOUTUUID_2 = "assetEntry.layoutUuid = ?";
2666 private static final String _FINDER_COLUMN_LAYOUTUUID_LAYOUTUUID_3 = "(assetEntry.layoutUuid IS NULL OR assetEntry.layoutUuid = '')";
2667 public static final FinderPath FINDER_PATH_FETCH_BY_G_CU = new FinderPath(AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
2668 AssetEntryModelImpl.FINDER_CACHE_ENABLED, AssetEntryImpl.class,
2669 FINDER_CLASS_NAME_ENTITY, "fetchByG_CU",
2670 new String[] { Long.class.getName(), String.class.getName() },
2671 AssetEntryModelImpl.GROUPID_COLUMN_BITMASK |
2672 AssetEntryModelImpl.CLASSUUID_COLUMN_BITMASK);
2673 public static final FinderPath FINDER_PATH_COUNT_BY_G_CU = new FinderPath(AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
2674 AssetEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
2675 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_CU",
2676 new String[] { Long.class.getName(), String.class.getName() });
2677
2678
2687 @Override
2688 public AssetEntry findByG_CU(long groupId, String classUuid)
2689 throws NoSuchEntryException, SystemException {
2690 AssetEntry assetEntry = fetchByG_CU(groupId, classUuid);
2691
2692 if (assetEntry == null) {
2693 StringBundler msg = new StringBundler(6);
2694
2695 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2696
2697 msg.append("groupId=");
2698 msg.append(groupId);
2699
2700 msg.append(", classUuid=");
2701 msg.append(classUuid);
2702
2703 msg.append(StringPool.CLOSE_CURLY_BRACE);
2704
2705 if (_log.isWarnEnabled()) {
2706 _log.warn(msg.toString());
2707 }
2708
2709 throw new NoSuchEntryException(msg.toString());
2710 }
2711
2712 return assetEntry;
2713 }
2714
2715
2723 @Override
2724 public AssetEntry fetchByG_CU(long groupId, String classUuid)
2725 throws SystemException {
2726 return fetchByG_CU(groupId, classUuid, true);
2727 }
2728
2729
2738 @Override
2739 public AssetEntry fetchByG_CU(long groupId, String classUuid,
2740 boolean retrieveFromCache) throws SystemException {
2741 Object[] finderArgs = new Object[] { groupId, classUuid };
2742
2743 Object result = null;
2744
2745 if (retrieveFromCache) {
2746 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_G_CU,
2747 finderArgs, this);
2748 }
2749
2750 if (result instanceof AssetEntry) {
2751 AssetEntry assetEntry = (AssetEntry)result;
2752
2753 if ((groupId != assetEntry.getGroupId()) ||
2754 !Validator.equals(classUuid, assetEntry.getClassUuid())) {
2755 result = null;
2756 }
2757 }
2758
2759 if (result == null) {
2760 StringBundler query = new StringBundler(4);
2761
2762 query.append(_SQL_SELECT_ASSETENTRY_WHERE);
2763
2764 query.append(_FINDER_COLUMN_G_CU_GROUPID_2);
2765
2766 boolean bindClassUuid = false;
2767
2768 if (classUuid == null) {
2769 query.append(_FINDER_COLUMN_G_CU_CLASSUUID_1);
2770 }
2771 else if (classUuid.equals(StringPool.BLANK)) {
2772 query.append(_FINDER_COLUMN_G_CU_CLASSUUID_3);
2773 }
2774 else {
2775 bindClassUuid = true;
2776
2777 query.append(_FINDER_COLUMN_G_CU_CLASSUUID_2);
2778 }
2779
2780 String sql = query.toString();
2781
2782 Session session = null;
2783
2784 try {
2785 session = openSession();
2786
2787 Query q = session.createQuery(sql);
2788
2789 QueryPos qPos = QueryPos.getInstance(q);
2790
2791 qPos.add(groupId);
2792
2793 if (bindClassUuid) {
2794 qPos.add(classUuid);
2795 }
2796
2797 List<AssetEntry> list = q.list();
2798
2799 if (list.isEmpty()) {
2800 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_CU,
2801 finderArgs, list);
2802 }
2803 else {
2804 if ((list.size() > 1) && _log.isWarnEnabled()) {
2805 _log.warn(
2806 "AssetEntryPersistenceImpl.fetchByG_CU(long, String, boolean) with parameters (" +
2807 StringUtil.merge(finderArgs) +
2808 ") yields a result set with more than 1 result. This violates the logical unique restriction. There is no order guarantee on which result is returned by this finder.");
2809 }
2810
2811 AssetEntry assetEntry = list.get(0);
2812
2813 result = assetEntry;
2814
2815 cacheResult(assetEntry);
2816
2817 if ((assetEntry.getGroupId() != groupId) ||
2818 (assetEntry.getClassUuid() == null) ||
2819 !assetEntry.getClassUuid().equals(classUuid)) {
2820 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_CU,
2821 finderArgs, assetEntry);
2822 }
2823 }
2824 }
2825 catch (Exception e) {
2826 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_CU,
2827 finderArgs);
2828
2829 throw processException(e);
2830 }
2831 finally {
2832 closeSession(session);
2833 }
2834 }
2835
2836 if (result instanceof List<?>) {
2837 return null;
2838 }
2839 else {
2840 return (AssetEntry)result;
2841 }
2842 }
2843
2844
2852 @Override
2853 public AssetEntry removeByG_CU(long groupId, String classUuid)
2854 throws NoSuchEntryException, SystemException {
2855 AssetEntry assetEntry = findByG_CU(groupId, classUuid);
2856
2857 return remove(assetEntry);
2858 }
2859
2860
2868 @Override
2869 public int countByG_CU(long groupId, String classUuid)
2870 throws SystemException {
2871 FinderPath finderPath = FINDER_PATH_COUNT_BY_G_CU;
2872
2873 Object[] finderArgs = new Object[] { groupId, classUuid };
2874
2875 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
2876 this);
2877
2878 if (count == null) {
2879 StringBundler query = new StringBundler(3);
2880
2881 query.append(_SQL_COUNT_ASSETENTRY_WHERE);
2882
2883 query.append(_FINDER_COLUMN_G_CU_GROUPID_2);
2884
2885 boolean bindClassUuid = false;
2886
2887 if (classUuid == null) {
2888 query.append(_FINDER_COLUMN_G_CU_CLASSUUID_1);
2889 }
2890 else if (classUuid.equals(StringPool.BLANK)) {
2891 query.append(_FINDER_COLUMN_G_CU_CLASSUUID_3);
2892 }
2893 else {
2894 bindClassUuid = true;
2895
2896 query.append(_FINDER_COLUMN_G_CU_CLASSUUID_2);
2897 }
2898
2899 String sql = query.toString();
2900
2901 Session session = null;
2902
2903 try {
2904 session = openSession();
2905
2906 Query q = session.createQuery(sql);
2907
2908 QueryPos qPos = QueryPos.getInstance(q);
2909
2910 qPos.add(groupId);
2911
2912 if (bindClassUuid) {
2913 qPos.add(classUuid);
2914 }
2915
2916 count = (Long)q.uniqueResult();
2917
2918 FinderCacheUtil.putResult(finderPath, finderArgs, count);
2919 }
2920 catch (Exception e) {
2921 FinderCacheUtil.removeResult(finderPath, finderArgs);
2922
2923 throw processException(e);
2924 }
2925 finally {
2926 closeSession(session);
2927 }
2928 }
2929
2930 return count.intValue();
2931 }
2932
2933 private static final String _FINDER_COLUMN_G_CU_GROUPID_2 = "assetEntry.groupId = ? AND ";
2934 private static final String _FINDER_COLUMN_G_CU_CLASSUUID_1 = "assetEntry.classUuid IS NULL";
2935 private static final String _FINDER_COLUMN_G_CU_CLASSUUID_2 = "assetEntry.classUuid = ?";
2936 private static final String _FINDER_COLUMN_G_CU_CLASSUUID_3 = "(assetEntry.classUuid IS NULL OR assetEntry.classUuid = '')";
2937 public static final FinderPath FINDER_PATH_FETCH_BY_C_C = new FinderPath(AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
2938 AssetEntryModelImpl.FINDER_CACHE_ENABLED, AssetEntryImpl.class,
2939 FINDER_CLASS_NAME_ENTITY, "fetchByC_C",
2940 new String[] { Long.class.getName(), Long.class.getName() },
2941 AssetEntryModelImpl.CLASSNAMEID_COLUMN_BITMASK |
2942 AssetEntryModelImpl.CLASSPK_COLUMN_BITMASK);
2943 public static final FinderPath FINDER_PATH_COUNT_BY_C_C = new FinderPath(AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
2944 AssetEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
2945 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_C",
2946 new String[] { Long.class.getName(), Long.class.getName() });
2947
2948
2957 @Override
2958 public AssetEntry findByC_C(long classNameId, long classPK)
2959 throws NoSuchEntryException, SystemException {
2960 AssetEntry assetEntry = fetchByC_C(classNameId, classPK);
2961
2962 if (assetEntry == null) {
2963 StringBundler msg = new StringBundler(6);
2964
2965 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2966
2967 msg.append("classNameId=");
2968 msg.append(classNameId);
2969
2970 msg.append(", classPK=");
2971 msg.append(classPK);
2972
2973 msg.append(StringPool.CLOSE_CURLY_BRACE);
2974
2975 if (_log.isWarnEnabled()) {
2976 _log.warn(msg.toString());
2977 }
2978
2979 throw new NoSuchEntryException(msg.toString());
2980 }
2981
2982 return assetEntry;
2983 }
2984
2985
2993 @Override
2994 public AssetEntry fetchByC_C(long classNameId, long classPK)
2995 throws SystemException {
2996 return fetchByC_C(classNameId, classPK, true);
2997 }
2998
2999
3008 @Override
3009 public AssetEntry fetchByC_C(long classNameId, long classPK,
3010 boolean retrieveFromCache) throws SystemException {
3011 Object[] finderArgs = new Object[] { classNameId, classPK };
3012
3013 Object result = null;
3014
3015 if (retrieveFromCache) {
3016 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_C_C,
3017 finderArgs, this);
3018 }
3019
3020 if (result instanceof AssetEntry) {
3021 AssetEntry assetEntry = (AssetEntry)result;
3022
3023 if ((classNameId != assetEntry.getClassNameId()) ||
3024 (classPK != assetEntry.getClassPK())) {
3025 result = null;
3026 }
3027 }
3028
3029 if (result == null) {
3030 StringBundler query = new StringBundler(4);
3031
3032 query.append(_SQL_SELECT_ASSETENTRY_WHERE);
3033
3034 query.append(_FINDER_COLUMN_C_C_CLASSNAMEID_2);
3035
3036 query.append(_FINDER_COLUMN_C_C_CLASSPK_2);
3037
3038 String sql = query.toString();
3039
3040 Session session = null;
3041
3042 try {
3043 session = openSession();
3044
3045 Query q = session.createQuery(sql);
3046
3047 QueryPos qPos = QueryPos.getInstance(q);
3048
3049 qPos.add(classNameId);
3050
3051 qPos.add(classPK);
3052
3053 List<AssetEntry> list = q.list();
3054
3055 if (list.isEmpty()) {
3056 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C,
3057 finderArgs, list);
3058 }
3059 else {
3060 AssetEntry assetEntry = list.get(0);
3061
3062 result = assetEntry;
3063
3064 cacheResult(assetEntry);
3065
3066 if ((assetEntry.getClassNameId() != classNameId) ||
3067 (assetEntry.getClassPK() != classPK)) {
3068 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C,
3069 finderArgs, assetEntry);
3070 }
3071 }
3072 }
3073 catch (Exception e) {
3074 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_C,
3075 finderArgs);
3076
3077 throw processException(e);
3078 }
3079 finally {
3080 closeSession(session);
3081 }
3082 }
3083
3084 if (result instanceof List<?>) {
3085 return null;
3086 }
3087 else {
3088 return (AssetEntry)result;
3089 }
3090 }
3091
3092
3100 @Override
3101 public AssetEntry removeByC_C(long classNameId, long classPK)
3102 throws NoSuchEntryException, SystemException {
3103 AssetEntry assetEntry = findByC_C(classNameId, classPK);
3104
3105 return remove(assetEntry);
3106 }
3107
3108
3116 @Override
3117 public int countByC_C(long classNameId, long classPK)
3118 throws SystemException {
3119 FinderPath finderPath = FINDER_PATH_COUNT_BY_C_C;
3120
3121 Object[] finderArgs = new Object[] { classNameId, classPK };
3122
3123 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
3124 this);
3125
3126 if (count == null) {
3127 StringBundler query = new StringBundler(3);
3128
3129 query.append(_SQL_COUNT_ASSETENTRY_WHERE);
3130
3131 query.append(_FINDER_COLUMN_C_C_CLASSNAMEID_2);
3132
3133 query.append(_FINDER_COLUMN_C_C_CLASSPK_2);
3134
3135 String sql = query.toString();
3136
3137 Session session = null;
3138
3139 try {
3140 session = openSession();
3141
3142 Query q = session.createQuery(sql);
3143
3144 QueryPos qPos = QueryPos.getInstance(q);
3145
3146 qPos.add(classNameId);
3147
3148 qPos.add(classPK);
3149
3150 count = (Long)q.uniqueResult();
3151
3152 FinderCacheUtil.putResult(finderPath, finderArgs, count);
3153 }
3154 catch (Exception e) {
3155 FinderCacheUtil.removeResult(finderPath, finderArgs);
3156
3157 throw processException(e);
3158 }
3159 finally {
3160 closeSession(session);
3161 }
3162 }
3163
3164 return count.intValue();
3165 }
3166
3167 private static final String _FINDER_COLUMN_C_C_CLASSNAMEID_2 = "assetEntry.classNameId = ? AND ";
3168 private static final String _FINDER_COLUMN_C_C_CLASSPK_2 = "assetEntry.classPK = ?";
3169
3170 public AssetEntryPersistenceImpl() {
3171 setModelClass(AssetEntry.class);
3172 }
3173
3174
3179 @Override
3180 public void cacheResult(AssetEntry assetEntry) {
3181 EntityCacheUtil.putResult(AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
3182 AssetEntryImpl.class, assetEntry.getPrimaryKey(), assetEntry);
3183
3184 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_CU,
3185 new Object[] { assetEntry.getGroupId(), assetEntry.getClassUuid() },
3186 assetEntry);
3187
3188 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C,
3189 new Object[] { assetEntry.getClassNameId(), assetEntry.getClassPK() },
3190 assetEntry);
3191
3192 assetEntry.resetOriginalValues();
3193 }
3194
3195
3200 @Override
3201 public void cacheResult(List<AssetEntry> assetEntries) {
3202 for (AssetEntry assetEntry : assetEntries) {
3203 if (EntityCacheUtil.getResult(
3204 AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
3205 AssetEntryImpl.class, assetEntry.getPrimaryKey()) == null) {
3206 cacheResult(assetEntry);
3207 }
3208 else {
3209 assetEntry.resetOriginalValues();
3210 }
3211 }
3212 }
3213
3214
3221 @Override
3222 public void clearCache() {
3223 if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
3224 CacheRegistryUtil.clear(AssetEntryImpl.class.getName());
3225 }
3226
3227 EntityCacheUtil.clearCache(AssetEntryImpl.class.getName());
3228
3229 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
3230 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
3231 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
3232 }
3233
3234
3241 @Override
3242 public void clearCache(AssetEntry assetEntry) {
3243 EntityCacheUtil.removeResult(AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
3244 AssetEntryImpl.class, assetEntry.getPrimaryKey());
3245
3246 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
3247 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
3248
3249 clearUniqueFindersCache(assetEntry);
3250 }
3251
3252 @Override
3253 public void clearCache(List<AssetEntry> assetEntries) {
3254 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
3255 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
3256
3257 for (AssetEntry assetEntry : assetEntries) {
3258 EntityCacheUtil.removeResult(AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
3259 AssetEntryImpl.class, assetEntry.getPrimaryKey());
3260
3261 clearUniqueFindersCache(assetEntry);
3262 }
3263 }
3264
3265 protected void cacheUniqueFindersCache(AssetEntry assetEntry) {
3266 if (assetEntry.isNew()) {
3267 Object[] args = new Object[] {
3268 assetEntry.getGroupId(), assetEntry.getClassUuid()
3269 };
3270
3271 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_CU, args,
3272 Long.valueOf(1));
3273 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_CU, args,
3274 assetEntry);
3275
3276 args = new Object[] {
3277 assetEntry.getClassNameId(), assetEntry.getClassPK()
3278 };
3279
3280 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_C, args,
3281 Long.valueOf(1));
3282 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C, args, assetEntry);
3283 }
3284 else {
3285 AssetEntryModelImpl assetEntryModelImpl = (AssetEntryModelImpl)assetEntry;
3286
3287 if ((assetEntryModelImpl.getColumnBitmask() &
3288 FINDER_PATH_FETCH_BY_G_CU.getColumnBitmask()) != 0) {
3289 Object[] args = new Object[] {
3290 assetEntry.getGroupId(), assetEntry.getClassUuid()
3291 };
3292
3293 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_CU, args,
3294 Long.valueOf(1));
3295 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_CU, args,
3296 assetEntry);
3297 }
3298
3299 if ((assetEntryModelImpl.getColumnBitmask() &
3300 FINDER_PATH_FETCH_BY_C_C.getColumnBitmask()) != 0) {
3301 Object[] args = new Object[] {
3302 assetEntry.getClassNameId(), assetEntry.getClassPK()
3303 };
3304
3305 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_C, args,
3306 Long.valueOf(1));
3307 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C, args,
3308 assetEntry);
3309 }
3310 }
3311 }
3312
3313 protected void clearUniqueFindersCache(AssetEntry assetEntry) {
3314 AssetEntryModelImpl assetEntryModelImpl = (AssetEntryModelImpl)assetEntry;
3315
3316 Object[] args = new Object[] {
3317 assetEntry.getGroupId(), assetEntry.getClassUuid()
3318 };
3319
3320 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_CU, args);
3321 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_CU, args);
3322
3323 if ((assetEntryModelImpl.getColumnBitmask() &
3324 FINDER_PATH_FETCH_BY_G_CU.getColumnBitmask()) != 0) {
3325 args = new Object[] {
3326 assetEntryModelImpl.getOriginalGroupId(),
3327 assetEntryModelImpl.getOriginalClassUuid()
3328 };
3329
3330 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_CU, args);
3331 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_CU, args);
3332 }
3333
3334 args = new Object[] { assetEntry.getClassNameId(), assetEntry.getClassPK() };
3335
3336 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_C, args);
3337 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_C, args);
3338
3339 if ((assetEntryModelImpl.getColumnBitmask() &
3340 FINDER_PATH_FETCH_BY_C_C.getColumnBitmask()) != 0) {
3341 args = new Object[] {
3342 assetEntryModelImpl.getOriginalClassNameId(),
3343 assetEntryModelImpl.getOriginalClassPK()
3344 };
3345
3346 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_C, args);
3347 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_C, args);
3348 }
3349 }
3350
3351
3357 @Override
3358 public AssetEntry create(long entryId) {
3359 AssetEntry assetEntry = new AssetEntryImpl();
3360
3361 assetEntry.setNew(true);
3362 assetEntry.setPrimaryKey(entryId);
3363
3364 return assetEntry;
3365 }
3366
3367
3375 @Override
3376 public AssetEntry remove(long entryId)
3377 throws NoSuchEntryException, SystemException {
3378 return remove((Serializable)entryId);
3379 }
3380
3381
3389 @Override
3390 public AssetEntry remove(Serializable primaryKey)
3391 throws NoSuchEntryException, SystemException {
3392 Session session = null;
3393
3394 try {
3395 session = openSession();
3396
3397 AssetEntry assetEntry = (AssetEntry)session.get(AssetEntryImpl.class,
3398 primaryKey);
3399
3400 if (assetEntry == null) {
3401 if (_log.isWarnEnabled()) {
3402 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
3403 }
3404
3405 throw new NoSuchEntryException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
3406 primaryKey);
3407 }
3408
3409 return remove(assetEntry);
3410 }
3411 catch (NoSuchEntryException nsee) {
3412 throw nsee;
3413 }
3414 catch (Exception e) {
3415 throw processException(e);
3416 }
3417 finally {
3418 closeSession(session);
3419 }
3420 }
3421
3422 @Override
3423 protected AssetEntry removeImpl(AssetEntry assetEntry)
3424 throws SystemException {
3425 assetEntry = toUnwrappedModel(assetEntry);
3426
3427 assetEntryToAssetCategoryTableMapper.deleteLeftPrimaryKeyTableMappings(assetEntry.getPrimaryKey());
3428
3429 assetEntryToAssetTagTableMapper.deleteLeftPrimaryKeyTableMappings(assetEntry.getPrimaryKey());
3430
3431 Session session = null;
3432
3433 try {
3434 session = openSession();
3435
3436 if (!session.contains(assetEntry)) {
3437 assetEntry = (AssetEntry)session.get(AssetEntryImpl.class,
3438 assetEntry.getPrimaryKeyObj());
3439 }
3440
3441 if (assetEntry != null) {
3442 session.delete(assetEntry);
3443 }
3444 }
3445 catch (Exception e) {
3446 throw processException(e);
3447 }
3448 finally {
3449 closeSession(session);
3450 }
3451
3452 if (assetEntry != null) {
3453 clearCache(assetEntry);
3454 }
3455
3456 return assetEntry;
3457 }
3458
3459 @Override
3460 public AssetEntry updateImpl(
3461 com.liferay.portlet.asset.model.AssetEntry assetEntry)
3462 throws SystemException {
3463 assetEntry = toUnwrappedModel(assetEntry);
3464
3465 boolean isNew = assetEntry.isNew();
3466
3467 AssetEntryModelImpl assetEntryModelImpl = (AssetEntryModelImpl)assetEntry;
3468
3469 Session session = null;
3470
3471 try {
3472 session = openSession();
3473
3474 if (assetEntry.isNew()) {
3475 session.save(assetEntry);
3476
3477 assetEntry.setNew(false);
3478 }
3479 else {
3480 session.merge(assetEntry);
3481 }
3482 }
3483 catch (Exception e) {
3484 throw processException(e);
3485 }
3486 finally {
3487 closeSession(session);
3488 }
3489
3490 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
3491
3492 if (isNew || !AssetEntryModelImpl.COLUMN_BITMASK_ENABLED) {
3493 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
3494 }
3495
3496 else {
3497 if ((assetEntryModelImpl.getColumnBitmask() &
3498 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID.getColumnBitmask()) != 0) {
3499 Object[] args = new Object[] {
3500 assetEntryModelImpl.getOriginalCompanyId()
3501 };
3502
3503 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_COMPANYID,
3504 args);
3505 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
3506 args);
3507
3508 args = new Object[] { assetEntryModelImpl.getCompanyId() };
3509
3510 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_COMPANYID,
3511 args);
3512 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
3513 args);
3514 }
3515
3516 if ((assetEntryModelImpl.getColumnBitmask() &
3517 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_VISIBLE.getColumnBitmask()) != 0) {
3518 Object[] args = new Object[] {
3519 assetEntryModelImpl.getOriginalVisible()
3520 };
3521
3522 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_VISIBLE, args);
3523 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_VISIBLE,
3524 args);
3525
3526 args = new Object[] { assetEntryModelImpl.getVisible() };
3527
3528 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_VISIBLE, args);
3529 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_VISIBLE,
3530 args);
3531 }
3532
3533 if ((assetEntryModelImpl.getColumnBitmask() &
3534 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_PUBLISHDATE.getColumnBitmask()) != 0) {
3535 Object[] args = new Object[] {
3536 assetEntryModelImpl.getOriginalPublishDate()
3537 };
3538
3539 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_PUBLISHDATE,
3540 args);
3541 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_PUBLISHDATE,
3542 args);
3543
3544 args = new Object[] { assetEntryModelImpl.getPublishDate() };
3545
3546 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_PUBLISHDATE,
3547 args);
3548 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_PUBLISHDATE,
3549 args);
3550 }
3551
3552 if ((assetEntryModelImpl.getColumnBitmask() &
3553 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_EXPIRATIONDATE.getColumnBitmask()) != 0) {
3554 Object[] args = new Object[] {
3555 assetEntryModelImpl.getOriginalExpirationDate()
3556 };
3557
3558 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_EXPIRATIONDATE,
3559 args);
3560 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_EXPIRATIONDATE,
3561 args);
3562
3563 args = new Object[] { assetEntryModelImpl.getExpirationDate() };
3564
3565 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_EXPIRATIONDATE,
3566 args);
3567 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_EXPIRATIONDATE,
3568 args);
3569 }
3570
3571 if ((assetEntryModelImpl.getColumnBitmask() &
3572 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_LAYOUTUUID.getColumnBitmask()) != 0) {
3573 Object[] args = new Object[] {
3574 assetEntryModelImpl.getOriginalLayoutUuid()
3575 };
3576
3577 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_LAYOUTUUID,
3578 args);
3579 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_LAYOUTUUID,
3580 args);
3581
3582 args = new Object[] { assetEntryModelImpl.getLayoutUuid() };
3583
3584 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_LAYOUTUUID,
3585 args);
3586 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_LAYOUTUUID,
3587 args);
3588 }
3589 }
3590
3591 EntityCacheUtil.putResult(AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
3592 AssetEntryImpl.class, assetEntry.getPrimaryKey(), assetEntry);
3593
3594 clearUniqueFindersCache(assetEntry);
3595 cacheUniqueFindersCache(assetEntry);
3596
3597 return assetEntry;
3598 }
3599
3600 protected AssetEntry toUnwrappedModel(AssetEntry assetEntry) {
3601 if (assetEntry instanceof AssetEntryImpl) {
3602 return assetEntry;
3603 }
3604
3605 AssetEntryImpl assetEntryImpl = new AssetEntryImpl();
3606
3607 assetEntryImpl.setNew(assetEntry.isNew());
3608 assetEntryImpl.setPrimaryKey(assetEntry.getPrimaryKey());
3609
3610 assetEntryImpl.setEntryId(assetEntry.getEntryId());
3611 assetEntryImpl.setGroupId(assetEntry.getGroupId());
3612 assetEntryImpl.setCompanyId(assetEntry.getCompanyId());
3613 assetEntryImpl.setUserId(assetEntry.getUserId());
3614 assetEntryImpl.setUserName(assetEntry.getUserName());
3615 assetEntryImpl.setCreateDate(assetEntry.getCreateDate());
3616 assetEntryImpl.setModifiedDate(assetEntry.getModifiedDate());
3617 assetEntryImpl.setClassNameId(assetEntry.getClassNameId());
3618 assetEntryImpl.setClassPK(assetEntry.getClassPK());
3619 assetEntryImpl.setClassUuid(assetEntry.getClassUuid());
3620 assetEntryImpl.setClassTypeId(assetEntry.getClassTypeId());
3621 assetEntryImpl.setVisible(assetEntry.isVisible());
3622 assetEntryImpl.setStartDate(assetEntry.getStartDate());
3623 assetEntryImpl.setEndDate(assetEntry.getEndDate());
3624 assetEntryImpl.setPublishDate(assetEntry.getPublishDate());
3625 assetEntryImpl.setExpirationDate(assetEntry.getExpirationDate());
3626 assetEntryImpl.setMimeType(assetEntry.getMimeType());
3627 assetEntryImpl.setTitle(assetEntry.getTitle());
3628 assetEntryImpl.setDescription(assetEntry.getDescription());
3629 assetEntryImpl.setSummary(assetEntry.getSummary());
3630 assetEntryImpl.setUrl(assetEntry.getUrl());
3631 assetEntryImpl.setLayoutUuid(assetEntry.getLayoutUuid());
3632 assetEntryImpl.setHeight(assetEntry.getHeight());
3633 assetEntryImpl.setWidth(assetEntry.getWidth());
3634 assetEntryImpl.setPriority(assetEntry.getPriority());
3635 assetEntryImpl.setViewCount(assetEntry.getViewCount());
3636
3637 return assetEntryImpl;
3638 }
3639
3640
3648 @Override
3649 public AssetEntry findByPrimaryKey(Serializable primaryKey)
3650 throws NoSuchEntryException, SystemException {
3651 AssetEntry assetEntry = fetchByPrimaryKey(primaryKey);
3652
3653 if (assetEntry == null) {
3654 if (_log.isWarnEnabled()) {
3655 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
3656 }
3657
3658 throw new NoSuchEntryException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
3659 primaryKey);
3660 }
3661
3662 return assetEntry;
3663 }
3664
3665
3673 @Override
3674 public AssetEntry findByPrimaryKey(long entryId)
3675 throws NoSuchEntryException, SystemException {
3676 return findByPrimaryKey((Serializable)entryId);
3677 }
3678
3679
3686 @Override
3687 public AssetEntry fetchByPrimaryKey(Serializable primaryKey)
3688 throws SystemException {
3689 AssetEntry assetEntry = (AssetEntry)EntityCacheUtil.getResult(AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
3690 AssetEntryImpl.class, primaryKey);
3691
3692 if (assetEntry == _nullAssetEntry) {
3693 return null;
3694 }
3695
3696 if (assetEntry == null) {
3697 Session session = null;
3698
3699 try {
3700 session = openSession();
3701
3702 assetEntry = (AssetEntry)session.get(AssetEntryImpl.class,
3703 primaryKey);
3704
3705 if (assetEntry != null) {
3706 cacheResult(assetEntry);
3707 }
3708 else {
3709 EntityCacheUtil.putResult(AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
3710 AssetEntryImpl.class, primaryKey, _nullAssetEntry);
3711 }
3712 }
3713 catch (Exception e) {
3714 EntityCacheUtil.removeResult(AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
3715 AssetEntryImpl.class, primaryKey);
3716
3717 throw processException(e);
3718 }
3719 finally {
3720 closeSession(session);
3721 }
3722 }
3723
3724 return assetEntry;
3725 }
3726
3727
3734 @Override
3735 public AssetEntry fetchByPrimaryKey(long entryId) throws SystemException {
3736 return fetchByPrimaryKey((Serializable)entryId);
3737 }
3738
3739
3745 @Override
3746 public List<AssetEntry> findAll() throws SystemException {
3747 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
3748 }
3749
3750
3762 @Override
3763 public List<AssetEntry> findAll(int start, int end)
3764 throws SystemException {
3765 return findAll(start, end, null);
3766 }
3767
3768
3781 @Override
3782 public List<AssetEntry> findAll(int start, int end,
3783 OrderByComparator orderByComparator) throws SystemException {
3784 boolean pagination = true;
3785 FinderPath finderPath = null;
3786 Object[] finderArgs = null;
3787
3788 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
3789 (orderByComparator == null)) {
3790 pagination = false;
3791 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
3792 finderArgs = FINDER_ARGS_EMPTY;
3793 }
3794 else {
3795 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
3796 finderArgs = new Object[] { start, end, orderByComparator };
3797 }
3798
3799 List<AssetEntry> list = (List<AssetEntry>)FinderCacheUtil.getResult(finderPath,
3800 finderArgs, this);
3801
3802 if (list == null) {
3803 StringBundler query = null;
3804 String sql = null;
3805
3806 if (orderByComparator != null) {
3807 query = new StringBundler(2 +
3808 (orderByComparator.getOrderByFields().length * 3));
3809
3810 query.append(_SQL_SELECT_ASSETENTRY);
3811
3812 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3813 orderByComparator);
3814
3815 sql = query.toString();
3816 }
3817 else {
3818 sql = _SQL_SELECT_ASSETENTRY;
3819
3820 if (pagination) {
3821 sql = sql.concat(AssetEntryModelImpl.ORDER_BY_JPQL);
3822 }
3823 }
3824
3825 Session session = null;
3826
3827 try {
3828 session = openSession();
3829
3830 Query q = session.createQuery(sql);
3831
3832 if (!pagination) {
3833 list = (List<AssetEntry>)QueryUtil.list(q, getDialect(),
3834 start, end, false);
3835
3836 Collections.sort(list);
3837
3838 list = new UnmodifiableList<AssetEntry>(list);
3839 }
3840 else {
3841 list = (List<AssetEntry>)QueryUtil.list(q, getDialect(),
3842 start, end);
3843 }
3844
3845 cacheResult(list);
3846
3847 FinderCacheUtil.putResult(finderPath, finderArgs, list);
3848 }
3849 catch (Exception e) {
3850 FinderCacheUtil.removeResult(finderPath, finderArgs);
3851
3852 throw processException(e);
3853 }
3854 finally {
3855 closeSession(session);
3856 }
3857 }
3858
3859 return list;
3860 }
3861
3862
3867 @Override
3868 public void removeAll() throws SystemException {
3869 for (AssetEntry assetEntry : findAll()) {
3870 remove(assetEntry);
3871 }
3872 }
3873
3874
3880 @Override
3881 public int countAll() throws SystemException {
3882 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
3883 FINDER_ARGS_EMPTY, this);
3884
3885 if (count == null) {
3886 Session session = null;
3887
3888 try {
3889 session = openSession();
3890
3891 Query q = session.createQuery(_SQL_COUNT_ASSETENTRY);
3892
3893 count = (Long)q.uniqueResult();
3894
3895 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
3896 FINDER_ARGS_EMPTY, count);
3897 }
3898 catch (Exception e) {
3899 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_ALL,
3900 FINDER_ARGS_EMPTY);
3901
3902 throw processException(e);
3903 }
3904 finally {
3905 closeSession(session);
3906 }
3907 }
3908
3909 return count.intValue();
3910 }
3911
3912
3919 @Override
3920 public List<com.liferay.portlet.asset.model.AssetCategory> getAssetCategories(
3921 long pk) throws SystemException {
3922 return getAssetCategories(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
3923 }
3924
3925
3938 @Override
3939 public List<com.liferay.portlet.asset.model.AssetCategory> getAssetCategories(
3940 long pk, int start, int end) throws SystemException {
3941 return getAssetCategories(pk, start, end, null);
3942 }
3943
3944
3958 @Override
3959 public List<com.liferay.portlet.asset.model.AssetCategory> getAssetCategories(
3960 long pk, int start, int end, OrderByComparator orderByComparator)
3961 throws SystemException {
3962 return assetEntryToAssetCategoryTableMapper.getRightBaseModels(pk,
3963 start, end, orderByComparator);
3964 }
3965
3966
3973 @Override
3974 public int getAssetCategoriesSize(long pk) throws SystemException {
3975 long[] pks = assetEntryToAssetCategoryTableMapper.getRightPrimaryKeys(pk);
3976
3977 return pks.length;
3978 }
3979
3980
3988 @Override
3989 public boolean containsAssetCategory(long pk, long assetCategoryPK)
3990 throws SystemException {
3991 return assetEntryToAssetCategoryTableMapper.containsTableMapping(pk,
3992 assetCategoryPK);
3993 }
3994
3995
4002 @Override
4003 public boolean containsAssetCategories(long pk) throws SystemException {
4004 if (getAssetCategoriesSize(pk) > 0) {
4005 return true;
4006 }
4007 else {
4008 return false;
4009 }
4010 }
4011
4012
4019 @Override
4020 public void addAssetCategory(long pk, long assetCategoryPK)
4021 throws SystemException {
4022 assetEntryToAssetCategoryTableMapper.addTableMapping(pk, assetCategoryPK);
4023 }
4024
4025
4032 @Override
4033 public void addAssetCategory(long pk,
4034 com.liferay.portlet.asset.model.AssetCategory assetCategory)
4035 throws SystemException {
4036 assetEntryToAssetCategoryTableMapper.addTableMapping(pk,
4037 assetCategory.getPrimaryKey());
4038 }
4039
4040
4047 @Override
4048 public void addAssetCategories(long pk, long[] assetCategoryPKs)
4049 throws SystemException {
4050 for (long assetCategoryPK : assetCategoryPKs) {
4051 assetEntryToAssetCategoryTableMapper.addTableMapping(pk,
4052 assetCategoryPK);
4053 }
4054 }
4055
4056
4063 @Override
4064 public void addAssetCategories(long pk,
4065 List<com.liferay.portlet.asset.model.AssetCategory> assetCategories)
4066 throws SystemException {
4067 for (com.liferay.portlet.asset.model.AssetCategory assetCategory : assetCategories) {
4068 assetEntryToAssetCategoryTableMapper.addTableMapping(pk,
4069 assetCategory.getPrimaryKey());
4070 }
4071 }
4072
4073
4079 @Override
4080 public void clearAssetCategories(long pk) throws SystemException {
4081 assetEntryToAssetCategoryTableMapper.deleteLeftPrimaryKeyTableMappings(pk);
4082 }
4083
4084
4091 @Override
4092 public void removeAssetCategory(long pk, long assetCategoryPK)
4093 throws SystemException {
4094 assetEntryToAssetCategoryTableMapper.deleteTableMapping(pk,
4095 assetCategoryPK);
4096 }
4097
4098
4105 @Override
4106 public void removeAssetCategory(long pk,
4107 com.liferay.portlet.asset.model.AssetCategory assetCategory)
4108 throws SystemException {
4109 assetEntryToAssetCategoryTableMapper.deleteTableMapping(pk,
4110 assetCategory.getPrimaryKey());
4111 }
4112
4113
4120 @Override
4121 public void removeAssetCategories(long pk, long[] assetCategoryPKs)
4122 throws SystemException {
4123 for (long assetCategoryPK : assetCategoryPKs) {
4124 assetEntryToAssetCategoryTableMapper.deleteTableMapping(pk,
4125 assetCategoryPK);
4126 }
4127 }
4128
4129
4136 @Override
4137 public void removeAssetCategories(long pk,
4138 List<com.liferay.portlet.asset.model.AssetCategory> assetCategories)
4139 throws SystemException {
4140 for (com.liferay.portlet.asset.model.AssetCategory assetCategory : assetCategories) {
4141 assetEntryToAssetCategoryTableMapper.deleteTableMapping(pk,
4142 assetCategory.getPrimaryKey());
4143 }
4144 }
4145
4146
4153 @Override
4154 public void setAssetCategories(long pk, long[] assetCategoryPKs)
4155 throws SystemException {
4156 Set<Long> newAssetCategoryPKsSet = SetUtil.fromArray(assetCategoryPKs);
4157 Set<Long> oldAssetCategoryPKsSet = SetUtil.fromArray(assetEntryToAssetCategoryTableMapper.getRightPrimaryKeys(
4158 pk));
4159
4160 Set<Long> removeAssetCategoryPKsSet = new HashSet<Long>(oldAssetCategoryPKsSet);
4161
4162 removeAssetCategoryPKsSet.removeAll(newAssetCategoryPKsSet);
4163
4164 for (long removeAssetCategoryPK : removeAssetCategoryPKsSet) {
4165 assetEntryToAssetCategoryTableMapper.deleteTableMapping(pk,
4166 removeAssetCategoryPK);
4167 }
4168
4169 newAssetCategoryPKsSet.removeAll(oldAssetCategoryPKsSet);
4170
4171 for (long newAssetCategoryPK : newAssetCategoryPKsSet) {
4172 assetEntryToAssetCategoryTableMapper.addTableMapping(pk,
4173 newAssetCategoryPK);
4174 }
4175 }
4176
4177
4184 @Override
4185 public void setAssetCategories(long pk,
4186 List<com.liferay.portlet.asset.model.AssetCategory> assetCategories)
4187 throws SystemException {
4188 try {
4189 long[] assetCategoryPKs = new long[assetCategories.size()];
4190
4191 for (int i = 0; i < assetCategories.size(); i++) {
4192 com.liferay.portlet.asset.model.AssetCategory assetCategory = assetCategories.get(i);
4193
4194 assetCategoryPKs[i] = assetCategory.getPrimaryKey();
4195 }
4196
4197 setAssetCategories(pk, assetCategoryPKs);
4198 }
4199 catch (Exception e) {
4200 throw processException(e);
4201 }
4202 finally {
4203 FinderCacheUtil.clearCache(AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
4204 }
4205 }
4206
4207
4214 @Override
4215 public List<com.liferay.portlet.asset.model.AssetTag> getAssetTags(long pk)
4216 throws SystemException {
4217 return getAssetTags(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
4218 }
4219
4220
4233 @Override
4234 public List<com.liferay.portlet.asset.model.AssetTag> getAssetTags(
4235 long pk, int start, int end) throws SystemException {
4236 return getAssetTags(pk, start, end, null);
4237 }
4238
4239
4253 @Override
4254 public List<com.liferay.portlet.asset.model.AssetTag> getAssetTags(
4255 long pk, int start, int end, OrderByComparator orderByComparator)
4256 throws SystemException {
4257 return assetEntryToAssetTagTableMapper.getRightBaseModels(pk, start,
4258 end, orderByComparator);
4259 }
4260
4261
4268 @Override
4269 public int getAssetTagsSize(long pk) throws SystemException {
4270 long[] pks = assetEntryToAssetTagTableMapper.getRightPrimaryKeys(pk);
4271
4272 return pks.length;
4273 }
4274
4275
4283 @Override
4284 public boolean containsAssetTag(long pk, long assetTagPK)
4285 throws SystemException {
4286 return assetEntryToAssetTagTableMapper.containsTableMapping(pk,
4287 assetTagPK);
4288 }
4289
4290
4297 @Override
4298 public boolean containsAssetTags(long pk) throws SystemException {
4299 if (getAssetTagsSize(pk) > 0) {
4300 return true;
4301 }
4302 else {
4303 return false;
4304 }
4305 }
4306
4307
4314 @Override
4315 public void addAssetTag(long pk, long assetTagPK) throws SystemException {
4316 assetEntryToAssetTagTableMapper.addTableMapping(pk, assetTagPK);
4317 }
4318
4319
4326 @Override
4327 public void addAssetTag(long pk,
4328 com.liferay.portlet.asset.model.AssetTag assetTag)
4329 throws SystemException {
4330 assetEntryToAssetTagTableMapper.addTableMapping(pk,
4331 assetTag.getPrimaryKey());
4332 }
4333
4334
4341 @Override
4342 public void addAssetTags(long pk, long[] assetTagPKs)
4343 throws SystemException {
4344 for (long assetTagPK : assetTagPKs) {
4345 assetEntryToAssetTagTableMapper.addTableMapping(pk, assetTagPK);
4346 }
4347 }
4348
4349
4356 @Override
4357 public void addAssetTags(long pk,
4358 List<com.liferay.portlet.asset.model.AssetTag> assetTags)
4359 throws SystemException {
4360 for (com.liferay.portlet.asset.model.AssetTag assetTag : assetTags) {
4361 assetEntryToAssetTagTableMapper.addTableMapping(pk,
4362 assetTag.getPrimaryKey());
4363 }
4364 }
4365
4366
4372 @Override
4373 public void clearAssetTags(long pk) throws SystemException {
4374 assetEntryToAssetTagTableMapper.deleteLeftPrimaryKeyTableMappings(pk);
4375 }
4376
4377
4384 @Override
4385 public void removeAssetTag(long pk, long assetTagPK)
4386 throws SystemException {
4387 assetEntryToAssetTagTableMapper.deleteTableMapping(pk, assetTagPK);
4388 }
4389
4390
4397 @Override
4398 public void removeAssetTag(long pk,
4399 com.liferay.portlet.asset.model.AssetTag assetTag)
4400 throws SystemException {
4401 assetEntryToAssetTagTableMapper.deleteTableMapping(pk,
4402 assetTag.getPrimaryKey());
4403 }
4404
4405
4412 @Override
4413 public void removeAssetTags(long pk, long[] assetTagPKs)
4414 throws SystemException {
4415 for (long assetTagPK : assetTagPKs) {
4416 assetEntryToAssetTagTableMapper.deleteTableMapping(pk, assetTagPK);
4417 }
4418 }
4419
4420
4427 @Override
4428 public void removeAssetTags(long pk,
4429 List<com.liferay.portlet.asset.model.AssetTag> assetTags)
4430 throws SystemException {
4431 for (com.liferay.portlet.asset.model.AssetTag assetTag : assetTags) {
4432 assetEntryToAssetTagTableMapper.deleteTableMapping(pk,
4433 assetTag.getPrimaryKey());
4434 }
4435 }
4436
4437
4444 @Override
4445 public void setAssetTags(long pk, long[] assetTagPKs)
4446 throws SystemException {
4447 Set<Long> newAssetTagPKsSet = SetUtil.fromArray(assetTagPKs);
4448 Set<Long> oldAssetTagPKsSet = SetUtil.fromArray(assetEntryToAssetTagTableMapper.getRightPrimaryKeys(
4449 pk));
4450
4451 Set<Long> removeAssetTagPKsSet = new HashSet<Long>(oldAssetTagPKsSet);
4452
4453 removeAssetTagPKsSet.removeAll(newAssetTagPKsSet);
4454
4455 for (long removeAssetTagPK : removeAssetTagPKsSet) {
4456 assetEntryToAssetTagTableMapper.deleteTableMapping(pk,
4457 removeAssetTagPK);
4458 }
4459
4460 newAssetTagPKsSet.removeAll(oldAssetTagPKsSet);
4461
4462 for (long newAssetTagPK : newAssetTagPKsSet) {
4463 assetEntryToAssetTagTableMapper.addTableMapping(pk, newAssetTagPK);
4464 }
4465 }
4466
4467
4474 @Override
4475 public void setAssetTags(long pk,
4476 List<com.liferay.portlet.asset.model.AssetTag> assetTags)
4477 throws SystemException {
4478 try {
4479 long[] assetTagPKs = new long[assetTags.size()];
4480
4481 for (int i = 0; i < assetTags.size(); i++) {
4482 com.liferay.portlet.asset.model.AssetTag assetTag = assetTags.get(i);
4483
4484 assetTagPKs[i] = assetTag.getPrimaryKey();
4485 }
4486
4487 setAssetTags(pk, assetTagPKs);
4488 }
4489 catch (Exception e) {
4490 throw processException(e);
4491 }
4492 finally {
4493 FinderCacheUtil.clearCache(AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETTAGS_NAME);
4494 }
4495 }
4496
4497
4500 public void afterPropertiesSet() {
4501 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
4502 com.liferay.portal.util.PropsUtil.get(
4503 "value.object.listener.com.liferay.portlet.asset.model.AssetEntry")));
4504
4505 if (listenerClassNames.length > 0) {
4506 try {
4507 List<ModelListener<AssetEntry>> listenersList = new ArrayList<ModelListener<AssetEntry>>();
4508
4509 for (String listenerClassName : listenerClassNames) {
4510 listenersList.add((ModelListener<AssetEntry>)InstanceFactory.newInstance(
4511 getClassLoader(), listenerClassName));
4512 }
4513
4514 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
4515 }
4516 catch (Exception e) {
4517 _log.error(e);
4518 }
4519 }
4520
4521 assetEntryToAssetCategoryTableMapper = TableMapperFactory.getTableMapper("AssetEntries_AssetCategories",
4522 "entryId", "categoryId", this, assetCategoryPersistence);
4523
4524 assetEntryToAssetTagTableMapper = TableMapperFactory.getTableMapper("AssetEntries_AssetTags",
4525 "entryId", "tagId", this, assetTagPersistence);
4526 }
4527
4528 public void destroy() {
4529 EntityCacheUtil.removeCache(AssetEntryImpl.class.getName());
4530 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
4531 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
4532 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
4533
4534 TableMapperFactory.removeTableMapper("AssetEntries_AssetCategories");
4535 TableMapperFactory.removeTableMapper("AssetEntries_AssetTags");
4536 }
4537
4538 @BeanReference(type = AssetCategoryPersistence.class)
4539 protected AssetCategoryPersistence assetCategoryPersistence;
4540 protected TableMapper<AssetEntry, com.liferay.portlet.asset.model.AssetCategory> assetEntryToAssetCategoryTableMapper;
4541 @BeanReference(type = AssetTagPersistence.class)
4542 protected AssetTagPersistence assetTagPersistence;
4543 protected TableMapper<AssetEntry, com.liferay.portlet.asset.model.AssetTag> assetEntryToAssetTagTableMapper;
4544 private static final String _SQL_SELECT_ASSETENTRY = "SELECT assetEntry FROM AssetEntry assetEntry";
4545 private static final String _SQL_SELECT_ASSETENTRY_WHERE = "SELECT assetEntry FROM AssetEntry assetEntry WHERE ";
4546 private static final String _SQL_COUNT_ASSETENTRY = "SELECT COUNT(assetEntry) FROM AssetEntry assetEntry";
4547 private static final String _SQL_COUNT_ASSETENTRY_WHERE = "SELECT COUNT(assetEntry) FROM AssetEntry assetEntry WHERE ";
4548 private static final String _ORDER_BY_ENTITY_ALIAS = "assetEntry.";
4549 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No AssetEntry exists with the primary key ";
4550 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No AssetEntry exists with the key {";
4551 private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
4552 private static Log _log = LogFactoryUtil.getLog(AssetEntryPersistenceImpl.class);
4553 private static AssetEntry _nullAssetEntry = new AssetEntryImpl() {
4554 @Override
4555 public Object clone() {
4556 return this;
4557 }
4558
4559 @Override
4560 public CacheModel<AssetEntry> toCacheModel() {
4561 return _nullAssetEntryCacheModel;
4562 }
4563 };
4564
4565 private static CacheModel<AssetEntry> _nullAssetEntryCacheModel = new CacheModel<AssetEntry>() {
4566 @Override
4567 public AssetEntry toEntityModel() {
4568 return _nullAssetEntry;
4569 }
4570 };
4571 }