001
014
015 package com.liferay.portlet.softwarecatalog.service.persistence;
016
017 import com.liferay.portal.NoSuchModelException;
018 import com.liferay.portal.kernel.annotation.BeanReference;
019 import com.liferay.portal.kernel.cache.CacheRegistryUtil;
020 import com.liferay.portal.kernel.dao.jdbc.MappingSqlQuery;
021 import com.liferay.portal.kernel.dao.jdbc.MappingSqlQueryFactoryUtil;
022 import com.liferay.portal.kernel.dao.jdbc.RowMapper;
023 import com.liferay.portal.kernel.dao.jdbc.SqlUpdate;
024 import com.liferay.portal.kernel.dao.jdbc.SqlUpdateFactoryUtil;
025 import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
026 import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
027 import com.liferay.portal.kernel.dao.orm.FinderPath;
028 import com.liferay.portal.kernel.dao.orm.Query;
029 import com.liferay.portal.kernel.dao.orm.QueryPos;
030 import com.liferay.portal.kernel.dao.orm.QueryUtil;
031 import com.liferay.portal.kernel.dao.orm.SQLQuery;
032 import com.liferay.portal.kernel.dao.orm.Session;
033 import com.liferay.portal.kernel.exception.SystemException;
034 import com.liferay.portal.kernel.log.Log;
035 import com.liferay.portal.kernel.log.LogFactoryUtil;
036 import com.liferay.portal.kernel.util.GetterUtil;
037 import com.liferay.portal.kernel.util.InstanceFactory;
038 import com.liferay.portal.kernel.util.OrderByComparator;
039 import com.liferay.portal.kernel.util.SetUtil;
040 import com.liferay.portal.kernel.util.StringBundler;
041 import com.liferay.portal.kernel.util.StringPool;
042 import com.liferay.portal.kernel.util.StringUtil;
043 import com.liferay.portal.model.ModelListener;
044 import com.liferay.portal.service.persistence.BatchSessionUtil;
045 import com.liferay.portal.service.persistence.ResourcePersistence;
046 import com.liferay.portal.service.persistence.UserPersistence;
047 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
048
049 import com.liferay.portlet.softwarecatalog.NoSuchLicenseException;
050 import com.liferay.portlet.softwarecatalog.model.SCLicense;
051 import com.liferay.portlet.softwarecatalog.model.impl.SCLicenseImpl;
052 import com.liferay.portlet.softwarecatalog.model.impl.SCLicenseModelImpl;
053
054 import java.io.Serializable;
055
056 import java.util.ArrayList;
057 import java.util.Collections;
058 import java.util.List;
059 import java.util.Set;
060
061
077 public class SCLicensePersistenceImpl extends BasePersistenceImpl<SCLicense>
078 implements SCLicensePersistence {
079 public static final String FINDER_CLASS_NAME_ENTITY = SCLicenseImpl.class.getName();
080 public static final String FINDER_CLASS_NAME_LIST = FINDER_CLASS_NAME_ENTITY +
081 ".List";
082 public static final FinderPath FINDER_PATH_FIND_BY_ACTIVE = new FinderPath(SCLicenseModelImpl.ENTITY_CACHE_ENABLED,
083 SCLicenseModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
084 "findByActive",
085 new String[] {
086 Boolean.class.getName(),
087
088 "java.lang.Integer", "java.lang.Integer",
089 "com.liferay.portal.kernel.util.OrderByComparator"
090 });
091 public static final FinderPath FINDER_PATH_COUNT_BY_ACTIVE = new FinderPath(SCLicenseModelImpl.ENTITY_CACHE_ENABLED,
092 SCLicenseModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
093 "countByActive", new String[] { Boolean.class.getName() });
094 public static final FinderPath FINDER_PATH_FIND_BY_A_R = new FinderPath(SCLicenseModelImpl.ENTITY_CACHE_ENABLED,
095 SCLicenseModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
096 "findByA_R",
097 new String[] {
098 Boolean.class.getName(), Boolean.class.getName(),
099
100 "java.lang.Integer", "java.lang.Integer",
101 "com.liferay.portal.kernel.util.OrderByComparator"
102 });
103 public static final FinderPath FINDER_PATH_COUNT_BY_A_R = new FinderPath(SCLicenseModelImpl.ENTITY_CACHE_ENABLED,
104 SCLicenseModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
105 "countByA_R",
106 new String[] { Boolean.class.getName(), Boolean.class.getName() });
107 public static final FinderPath FINDER_PATH_FIND_ALL = new FinderPath(SCLicenseModelImpl.ENTITY_CACHE_ENABLED,
108 SCLicenseModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
109 "findAll", new String[0]);
110 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(SCLicenseModelImpl.ENTITY_CACHE_ENABLED,
111 SCLicenseModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
112 "countAll", new String[0]);
113
114
119 public void cacheResult(SCLicense scLicense) {
120 EntityCacheUtil.putResult(SCLicenseModelImpl.ENTITY_CACHE_ENABLED,
121 SCLicenseImpl.class, scLicense.getPrimaryKey(), scLicense);
122 }
123
124
129 public void cacheResult(List<SCLicense> scLicenses) {
130 for (SCLicense scLicense : scLicenses) {
131 if (EntityCacheUtil.getResult(
132 SCLicenseModelImpl.ENTITY_CACHE_ENABLED,
133 SCLicenseImpl.class, scLicense.getPrimaryKey(), this) == null) {
134 cacheResult(scLicense);
135 }
136 }
137 }
138
139
146 public void clearCache() {
147 CacheRegistryUtil.clear(SCLicenseImpl.class.getName());
148 EntityCacheUtil.clearCache(SCLicenseImpl.class.getName());
149 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
150 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
151 }
152
153
160 public void clearCache(SCLicense scLicense) {
161 EntityCacheUtil.removeResult(SCLicenseModelImpl.ENTITY_CACHE_ENABLED,
162 SCLicenseImpl.class, scLicense.getPrimaryKey());
163 }
164
165
171 public SCLicense create(long licenseId) {
172 SCLicense scLicense = new SCLicenseImpl();
173
174 scLicense.setNew(true);
175 scLicense.setPrimaryKey(licenseId);
176
177 return scLicense;
178 }
179
180
188 public SCLicense remove(Serializable primaryKey)
189 throws NoSuchModelException, SystemException {
190 return remove(((Long)primaryKey).longValue());
191 }
192
193
201 public SCLicense remove(long licenseId)
202 throws NoSuchLicenseException, SystemException {
203 Session session = null;
204
205 try {
206 session = openSession();
207
208 SCLicense scLicense = (SCLicense)session.get(SCLicenseImpl.class,
209 new Long(licenseId));
210
211 if (scLicense == null) {
212 if (_log.isWarnEnabled()) {
213 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + licenseId);
214 }
215
216 throw new NoSuchLicenseException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
217 licenseId);
218 }
219
220 return remove(scLicense);
221 }
222 catch (NoSuchLicenseException nsee) {
223 throw nsee;
224 }
225 catch (Exception e) {
226 throw processException(e);
227 }
228 finally {
229 closeSession(session);
230 }
231 }
232
233 protected SCLicense removeImpl(SCLicense scLicense)
234 throws SystemException {
235 scLicense = toUnwrappedModel(scLicense);
236
237 try {
238 clearSCProductEntries.clear(scLicense.getPrimaryKey());
239 }
240 catch (Exception e) {
241 throw processException(e);
242 }
243 finally {
244 FinderCacheUtil.clearCache(SCLicenseModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME);
245 }
246
247 Session session = null;
248
249 try {
250 session = openSession();
251
252 if (scLicense.isCachedModel() || BatchSessionUtil.isEnabled()) {
253 Object staleObject = session.get(SCLicenseImpl.class,
254 scLicense.getPrimaryKeyObj());
255
256 if (staleObject != null) {
257 session.evict(staleObject);
258 }
259 }
260
261 session.delete(scLicense);
262
263 session.flush();
264 }
265 catch (Exception e) {
266 throw processException(e);
267 }
268 finally {
269 closeSession(session);
270 }
271
272 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
273
274 EntityCacheUtil.removeResult(SCLicenseModelImpl.ENTITY_CACHE_ENABLED,
275 SCLicenseImpl.class, scLicense.getPrimaryKey());
276
277 return scLicense;
278 }
279
280 public SCLicense updateImpl(
281 com.liferay.portlet.softwarecatalog.model.SCLicense scLicense,
282 boolean merge) throws SystemException {
283 scLicense = toUnwrappedModel(scLicense);
284
285 Session session = null;
286
287 try {
288 session = openSession();
289
290 BatchSessionUtil.update(session, scLicense, merge);
291
292 scLicense.setNew(false);
293 }
294 catch (Exception e) {
295 throw processException(e);
296 }
297 finally {
298 closeSession(session);
299 }
300
301 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
302
303 EntityCacheUtil.putResult(SCLicenseModelImpl.ENTITY_CACHE_ENABLED,
304 SCLicenseImpl.class, scLicense.getPrimaryKey(), scLicense);
305
306 return scLicense;
307 }
308
309 protected SCLicense toUnwrappedModel(SCLicense scLicense) {
310 if (scLicense instanceof SCLicenseImpl) {
311 return scLicense;
312 }
313
314 SCLicenseImpl scLicenseImpl = new SCLicenseImpl();
315
316 scLicenseImpl.setNew(scLicense.isNew());
317 scLicenseImpl.setPrimaryKey(scLicense.getPrimaryKey());
318
319 scLicenseImpl.setLicenseId(scLicense.getLicenseId());
320 scLicenseImpl.setName(scLicense.getName());
321 scLicenseImpl.setUrl(scLicense.getUrl());
322 scLicenseImpl.setOpenSource(scLicense.isOpenSource());
323 scLicenseImpl.setActive(scLicense.isActive());
324 scLicenseImpl.setRecommended(scLicense.isRecommended());
325
326 return scLicenseImpl;
327 }
328
329
337 public SCLicense findByPrimaryKey(Serializable primaryKey)
338 throws NoSuchModelException, SystemException {
339 return findByPrimaryKey(((Long)primaryKey).longValue());
340 }
341
342
350 public SCLicense findByPrimaryKey(long licenseId)
351 throws NoSuchLicenseException, SystemException {
352 SCLicense scLicense = fetchByPrimaryKey(licenseId);
353
354 if (scLicense == null) {
355 if (_log.isWarnEnabled()) {
356 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + licenseId);
357 }
358
359 throw new NoSuchLicenseException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
360 licenseId);
361 }
362
363 return scLicense;
364 }
365
366
373 public SCLicense fetchByPrimaryKey(Serializable primaryKey)
374 throws SystemException {
375 return fetchByPrimaryKey(((Long)primaryKey).longValue());
376 }
377
378
385 public SCLicense fetchByPrimaryKey(long licenseId)
386 throws SystemException {
387 SCLicense scLicense = (SCLicense)EntityCacheUtil.getResult(SCLicenseModelImpl.ENTITY_CACHE_ENABLED,
388 SCLicenseImpl.class, licenseId, this);
389
390 if (scLicense == null) {
391 Session session = null;
392
393 try {
394 session = openSession();
395
396 scLicense = (SCLicense)session.get(SCLicenseImpl.class,
397 new Long(licenseId));
398 }
399 catch (Exception e) {
400 throw processException(e);
401 }
402 finally {
403 if (scLicense != null) {
404 cacheResult(scLicense);
405 }
406
407 closeSession(session);
408 }
409 }
410
411 return scLicense;
412 }
413
414
421 public List<SCLicense> findByActive(boolean active)
422 throws SystemException {
423 return findByActive(active, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
424 }
425
426
439 public List<SCLicense> findByActive(boolean active, int start, int end)
440 throws SystemException {
441 return findByActive(active, start, end, null);
442 }
443
444
458 public List<SCLicense> findByActive(boolean active, int start, int end,
459 OrderByComparator orderByComparator) throws SystemException {
460 Object[] finderArgs = new Object[] {
461 active,
462
463 String.valueOf(start), String.valueOf(end),
464 String.valueOf(orderByComparator)
465 };
466
467 List<SCLicense> list = (List<SCLicense>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_ACTIVE,
468 finderArgs, this);
469
470 if (list == null) {
471 Session session = null;
472
473 try {
474 session = openSession();
475
476 StringBundler query = null;
477
478 if (orderByComparator != null) {
479 query = new StringBundler(3 +
480 (orderByComparator.getOrderByFields().length * 3));
481 }
482 else {
483 query = new StringBundler(3);
484 }
485
486 query.append(_SQL_SELECT_SCLICENSE_WHERE);
487
488 query.append(_FINDER_COLUMN_ACTIVE_ACTIVE_2);
489
490 if (orderByComparator != null) {
491 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
492 orderByComparator);
493 }
494
495 else {
496 query.append(SCLicenseModelImpl.ORDER_BY_JPQL);
497 }
498
499 String sql = query.toString();
500
501 Query q = session.createQuery(sql);
502
503 QueryPos qPos = QueryPos.getInstance(q);
504
505 qPos.add(active);
506
507 list = (List<SCLicense>)QueryUtil.list(q, getDialect(), start,
508 end);
509 }
510 catch (Exception e) {
511 throw processException(e);
512 }
513 finally {
514 if (list == null) {
515 list = new ArrayList<SCLicense>();
516 }
517
518 cacheResult(list);
519
520 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_ACTIVE,
521 finderArgs, list);
522
523 closeSession(session);
524 }
525 }
526
527 return list;
528 }
529
530
543 public SCLicense findByActive_First(boolean active,
544 OrderByComparator orderByComparator)
545 throws NoSuchLicenseException, SystemException {
546 List<SCLicense> list = findByActive(active, 0, 1, orderByComparator);
547
548 if (list.isEmpty()) {
549 StringBundler msg = new StringBundler(4);
550
551 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
552
553 msg.append("active=");
554 msg.append(active);
555
556 msg.append(StringPool.CLOSE_CURLY_BRACE);
557
558 throw new NoSuchLicenseException(msg.toString());
559 }
560 else {
561 return list.get(0);
562 }
563 }
564
565
578 public SCLicense findByActive_Last(boolean active,
579 OrderByComparator orderByComparator)
580 throws NoSuchLicenseException, SystemException {
581 int count = countByActive(active);
582
583 List<SCLicense> list = findByActive(active, count - 1, count,
584 orderByComparator);
585
586 if (list.isEmpty()) {
587 StringBundler msg = new StringBundler(4);
588
589 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
590
591 msg.append("active=");
592 msg.append(active);
593
594 msg.append(StringPool.CLOSE_CURLY_BRACE);
595
596 throw new NoSuchLicenseException(msg.toString());
597 }
598 else {
599 return list.get(0);
600 }
601 }
602
603
617 public SCLicense[] findByActive_PrevAndNext(long licenseId, boolean active,
618 OrderByComparator orderByComparator)
619 throws NoSuchLicenseException, SystemException {
620 SCLicense scLicense = findByPrimaryKey(licenseId);
621
622 Session session = null;
623
624 try {
625 session = openSession();
626
627 SCLicense[] array = new SCLicenseImpl[3];
628
629 array[0] = getByActive_PrevAndNext(session, scLicense, active,
630 orderByComparator, true);
631
632 array[1] = scLicense;
633
634 array[2] = getByActive_PrevAndNext(session, scLicense, active,
635 orderByComparator, false);
636
637 return array;
638 }
639 catch (Exception e) {
640 throw processException(e);
641 }
642 finally {
643 closeSession(session);
644 }
645 }
646
647 protected SCLicense getByActive_PrevAndNext(Session session,
648 SCLicense scLicense, boolean active,
649 OrderByComparator orderByComparator, boolean previous) {
650 StringBundler query = null;
651
652 if (orderByComparator != null) {
653 query = new StringBundler(6 +
654 (orderByComparator.getOrderByFields().length * 6));
655 }
656 else {
657 query = new StringBundler(3);
658 }
659
660 query.append(_SQL_SELECT_SCLICENSE_WHERE);
661
662 query.append(_FINDER_COLUMN_ACTIVE_ACTIVE_2);
663
664 if (orderByComparator != null) {
665 String[] orderByFields = orderByComparator.getOrderByFields();
666
667 if (orderByFields.length > 0) {
668 query.append(WHERE_AND);
669 }
670
671 for (int i = 0; i < orderByFields.length; i++) {
672 query.append(_ORDER_BY_ENTITY_ALIAS);
673 query.append(orderByFields[i]);
674
675 if ((i + 1) < orderByFields.length) {
676 if (orderByComparator.isAscending() ^ previous) {
677 query.append(WHERE_GREATER_THAN_HAS_NEXT);
678 }
679 else {
680 query.append(WHERE_LESSER_THAN_HAS_NEXT);
681 }
682 }
683 else {
684 if (orderByComparator.isAscending() ^ previous) {
685 query.append(WHERE_GREATER_THAN);
686 }
687 else {
688 query.append(WHERE_LESSER_THAN);
689 }
690 }
691 }
692
693 query.append(ORDER_BY_CLAUSE);
694
695 for (int i = 0; i < orderByFields.length; i++) {
696 query.append(_ORDER_BY_ENTITY_ALIAS);
697 query.append(orderByFields[i]);
698
699 if ((i + 1) < orderByFields.length) {
700 if (orderByComparator.isAscending() ^ previous) {
701 query.append(ORDER_BY_ASC_HAS_NEXT);
702 }
703 else {
704 query.append(ORDER_BY_DESC_HAS_NEXT);
705 }
706 }
707 else {
708 if (orderByComparator.isAscending() ^ previous) {
709 query.append(ORDER_BY_ASC);
710 }
711 else {
712 query.append(ORDER_BY_DESC);
713 }
714 }
715 }
716 }
717
718 else {
719 query.append(SCLicenseModelImpl.ORDER_BY_JPQL);
720 }
721
722 String sql = query.toString();
723
724 Query q = session.createQuery(sql);
725
726 q.setFirstResult(0);
727 q.setMaxResults(2);
728
729 QueryPos qPos = QueryPos.getInstance(q);
730
731 qPos.add(active);
732
733 if (orderByComparator != null) {
734 Object[] values = orderByComparator.getOrderByValues(scLicense);
735
736 for (Object value : values) {
737 qPos.add(value);
738 }
739 }
740
741 List<SCLicense> list = q.list();
742
743 if (list.size() == 2) {
744 return list.get(1);
745 }
746 else {
747 return null;
748 }
749 }
750
751
759 public List<SCLicense> findByA_R(boolean active, boolean recommended)
760 throws SystemException {
761 return findByA_R(active, recommended, QueryUtil.ALL_POS,
762 QueryUtil.ALL_POS, null);
763 }
764
765
779 public List<SCLicense> findByA_R(boolean active, boolean recommended,
780 int start, int end) throws SystemException {
781 return findByA_R(active, recommended, start, end, null);
782 }
783
784
799 public List<SCLicense> findByA_R(boolean active, boolean recommended,
800 int start, int end, OrderByComparator orderByComparator)
801 throws SystemException {
802 Object[] finderArgs = new Object[] {
803 active, recommended,
804
805 String.valueOf(start), String.valueOf(end),
806 String.valueOf(orderByComparator)
807 };
808
809 List<SCLicense> list = (List<SCLicense>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_A_R,
810 finderArgs, this);
811
812 if (list == null) {
813 Session session = null;
814
815 try {
816 session = openSession();
817
818 StringBundler query = null;
819
820 if (orderByComparator != null) {
821 query = new StringBundler(4 +
822 (orderByComparator.getOrderByFields().length * 3));
823 }
824 else {
825 query = new StringBundler(4);
826 }
827
828 query.append(_SQL_SELECT_SCLICENSE_WHERE);
829
830 query.append(_FINDER_COLUMN_A_R_ACTIVE_2);
831
832 query.append(_FINDER_COLUMN_A_R_RECOMMENDED_2);
833
834 if (orderByComparator != null) {
835 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
836 orderByComparator);
837 }
838
839 else {
840 query.append(SCLicenseModelImpl.ORDER_BY_JPQL);
841 }
842
843 String sql = query.toString();
844
845 Query q = session.createQuery(sql);
846
847 QueryPos qPos = QueryPos.getInstance(q);
848
849 qPos.add(active);
850
851 qPos.add(recommended);
852
853 list = (List<SCLicense>)QueryUtil.list(q, getDialect(), start,
854 end);
855 }
856 catch (Exception e) {
857 throw processException(e);
858 }
859 finally {
860 if (list == null) {
861 list = new ArrayList<SCLicense>();
862 }
863
864 cacheResult(list);
865
866 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_A_R, finderArgs,
867 list);
868
869 closeSession(session);
870 }
871 }
872
873 return list;
874 }
875
876
890 public SCLicense findByA_R_First(boolean active, boolean recommended,
891 OrderByComparator orderByComparator)
892 throws NoSuchLicenseException, SystemException {
893 List<SCLicense> list = findByA_R(active, recommended, 0, 1,
894 orderByComparator);
895
896 if (list.isEmpty()) {
897 StringBundler msg = new StringBundler(6);
898
899 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
900
901 msg.append("active=");
902 msg.append(active);
903
904 msg.append(", recommended=");
905 msg.append(recommended);
906
907 msg.append(StringPool.CLOSE_CURLY_BRACE);
908
909 throw new NoSuchLicenseException(msg.toString());
910 }
911 else {
912 return list.get(0);
913 }
914 }
915
916
930 public SCLicense findByA_R_Last(boolean active, boolean recommended,
931 OrderByComparator orderByComparator)
932 throws NoSuchLicenseException, SystemException {
933 int count = countByA_R(active, recommended);
934
935 List<SCLicense> list = findByA_R(active, recommended, count - 1, count,
936 orderByComparator);
937
938 if (list.isEmpty()) {
939 StringBundler msg = new StringBundler(6);
940
941 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
942
943 msg.append("active=");
944 msg.append(active);
945
946 msg.append(", recommended=");
947 msg.append(recommended);
948
949 msg.append(StringPool.CLOSE_CURLY_BRACE);
950
951 throw new NoSuchLicenseException(msg.toString());
952 }
953 else {
954 return list.get(0);
955 }
956 }
957
958
973 public SCLicense[] findByA_R_PrevAndNext(long licenseId, boolean active,
974 boolean recommended, OrderByComparator orderByComparator)
975 throws NoSuchLicenseException, SystemException {
976 SCLicense scLicense = findByPrimaryKey(licenseId);
977
978 Session session = null;
979
980 try {
981 session = openSession();
982
983 SCLicense[] array = new SCLicenseImpl[3];
984
985 array[0] = getByA_R_PrevAndNext(session, scLicense, active,
986 recommended, orderByComparator, true);
987
988 array[1] = scLicense;
989
990 array[2] = getByA_R_PrevAndNext(session, scLicense, active,
991 recommended, orderByComparator, false);
992
993 return array;
994 }
995 catch (Exception e) {
996 throw processException(e);
997 }
998 finally {
999 closeSession(session);
1000 }
1001 }
1002
1003 protected SCLicense getByA_R_PrevAndNext(Session session,
1004 SCLicense scLicense, boolean active, boolean recommended,
1005 OrderByComparator orderByComparator, boolean previous) {
1006 StringBundler query = null;
1007
1008 if (orderByComparator != null) {
1009 query = new StringBundler(6 +
1010 (orderByComparator.getOrderByFields().length * 6));
1011 }
1012 else {
1013 query = new StringBundler(3);
1014 }
1015
1016 query.append(_SQL_SELECT_SCLICENSE_WHERE);
1017
1018 query.append(_FINDER_COLUMN_A_R_ACTIVE_2);
1019
1020 query.append(_FINDER_COLUMN_A_R_RECOMMENDED_2);
1021
1022 if (orderByComparator != null) {
1023 String[] orderByFields = orderByComparator.getOrderByFields();
1024
1025 if (orderByFields.length > 0) {
1026 query.append(WHERE_AND);
1027 }
1028
1029 for (int i = 0; i < orderByFields.length; i++) {
1030 query.append(_ORDER_BY_ENTITY_ALIAS);
1031 query.append(orderByFields[i]);
1032
1033 if ((i + 1) < orderByFields.length) {
1034 if (orderByComparator.isAscending() ^ previous) {
1035 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1036 }
1037 else {
1038 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1039 }
1040 }
1041 else {
1042 if (orderByComparator.isAscending() ^ previous) {
1043 query.append(WHERE_GREATER_THAN);
1044 }
1045 else {
1046 query.append(WHERE_LESSER_THAN);
1047 }
1048 }
1049 }
1050
1051 query.append(ORDER_BY_CLAUSE);
1052
1053 for (int i = 0; i < orderByFields.length; i++) {
1054 query.append(_ORDER_BY_ENTITY_ALIAS);
1055 query.append(orderByFields[i]);
1056
1057 if ((i + 1) < orderByFields.length) {
1058 if (orderByComparator.isAscending() ^ previous) {
1059 query.append(ORDER_BY_ASC_HAS_NEXT);
1060 }
1061 else {
1062 query.append(ORDER_BY_DESC_HAS_NEXT);
1063 }
1064 }
1065 else {
1066 if (orderByComparator.isAscending() ^ previous) {
1067 query.append(ORDER_BY_ASC);
1068 }
1069 else {
1070 query.append(ORDER_BY_DESC);
1071 }
1072 }
1073 }
1074 }
1075
1076 else {
1077 query.append(SCLicenseModelImpl.ORDER_BY_JPQL);
1078 }
1079
1080 String sql = query.toString();
1081
1082 Query q = session.createQuery(sql);
1083
1084 q.setFirstResult(0);
1085 q.setMaxResults(2);
1086
1087 QueryPos qPos = QueryPos.getInstance(q);
1088
1089 qPos.add(active);
1090
1091 qPos.add(recommended);
1092
1093 if (orderByComparator != null) {
1094 Object[] values = orderByComparator.getOrderByValues(scLicense);
1095
1096 for (Object value : values) {
1097 qPos.add(value);
1098 }
1099 }
1100
1101 List<SCLicense> list = q.list();
1102
1103 if (list.size() == 2) {
1104 return list.get(1);
1105 }
1106 else {
1107 return null;
1108 }
1109 }
1110
1111
1117 public List<SCLicense> findAll() throws SystemException {
1118 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1119 }
1120
1121
1133 public List<SCLicense> findAll(int start, int end)
1134 throws SystemException {
1135 return findAll(start, end, null);
1136 }
1137
1138
1151 public List<SCLicense> findAll(int start, int end,
1152 OrderByComparator orderByComparator) throws SystemException {
1153 Object[] finderArgs = new Object[] {
1154 String.valueOf(start), String.valueOf(end),
1155 String.valueOf(orderByComparator)
1156 };
1157
1158 List<SCLicense> list = (List<SCLicense>)FinderCacheUtil.getResult(FINDER_PATH_FIND_ALL,
1159 finderArgs, this);
1160
1161 if (list == null) {
1162 Session session = null;
1163
1164 try {
1165 session = openSession();
1166
1167 StringBundler query = null;
1168 String sql = null;
1169
1170 if (orderByComparator != null) {
1171 query = new StringBundler(2 +
1172 (orderByComparator.getOrderByFields().length * 3));
1173
1174 query.append(_SQL_SELECT_SCLICENSE);
1175
1176 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1177 orderByComparator);
1178
1179 sql = query.toString();
1180 }
1181 else {
1182 sql = _SQL_SELECT_SCLICENSE.concat(SCLicenseModelImpl.ORDER_BY_JPQL);
1183 }
1184
1185 Query q = session.createQuery(sql);
1186
1187 if (orderByComparator == null) {
1188 list = (List<SCLicense>)QueryUtil.list(q, getDialect(),
1189 start, end, false);
1190
1191 Collections.sort(list);
1192 }
1193 else {
1194 list = (List<SCLicense>)QueryUtil.list(q, getDialect(),
1195 start, end);
1196 }
1197 }
1198 catch (Exception e) {
1199 throw processException(e);
1200 }
1201 finally {
1202 if (list == null) {
1203 list = new ArrayList<SCLicense>();
1204 }
1205
1206 cacheResult(list);
1207
1208 FinderCacheUtil.putResult(FINDER_PATH_FIND_ALL, finderArgs, list);
1209
1210 closeSession(session);
1211 }
1212 }
1213
1214 return list;
1215 }
1216
1217
1223 public void removeByActive(boolean active) throws SystemException {
1224 for (SCLicense scLicense : findByActive(active)) {
1225 remove(scLicense);
1226 }
1227 }
1228
1229
1236 public void removeByA_R(boolean active, boolean recommended)
1237 throws SystemException {
1238 for (SCLicense scLicense : findByA_R(active, recommended)) {
1239 remove(scLicense);
1240 }
1241 }
1242
1243
1248 public void removeAll() throws SystemException {
1249 for (SCLicense scLicense : findAll()) {
1250 remove(scLicense);
1251 }
1252 }
1253
1254
1261 public int countByActive(boolean active) throws SystemException {
1262 Object[] finderArgs = new Object[] { active };
1263
1264 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_ACTIVE,
1265 finderArgs, this);
1266
1267 if (count == null) {
1268 Session session = null;
1269
1270 try {
1271 session = openSession();
1272
1273 StringBundler query = new StringBundler(2);
1274
1275 query.append(_SQL_COUNT_SCLICENSE_WHERE);
1276
1277 query.append(_FINDER_COLUMN_ACTIVE_ACTIVE_2);
1278
1279 String sql = query.toString();
1280
1281 Query q = session.createQuery(sql);
1282
1283 QueryPos qPos = QueryPos.getInstance(q);
1284
1285 qPos.add(active);
1286
1287 count = (Long)q.uniqueResult();
1288 }
1289 catch (Exception e) {
1290 throw processException(e);
1291 }
1292 finally {
1293 if (count == null) {
1294 count = Long.valueOf(0);
1295 }
1296
1297 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_ACTIVE,
1298 finderArgs, count);
1299
1300 closeSession(session);
1301 }
1302 }
1303
1304 return count.intValue();
1305 }
1306
1307
1315 public int countByA_R(boolean active, boolean recommended)
1316 throws SystemException {
1317 Object[] finderArgs = new Object[] { active, recommended };
1318
1319 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_A_R,
1320 finderArgs, this);
1321
1322 if (count == null) {
1323 Session session = null;
1324
1325 try {
1326 session = openSession();
1327
1328 StringBundler query = new StringBundler(3);
1329
1330 query.append(_SQL_COUNT_SCLICENSE_WHERE);
1331
1332 query.append(_FINDER_COLUMN_A_R_ACTIVE_2);
1333
1334 query.append(_FINDER_COLUMN_A_R_RECOMMENDED_2);
1335
1336 String sql = query.toString();
1337
1338 Query q = session.createQuery(sql);
1339
1340 QueryPos qPos = QueryPos.getInstance(q);
1341
1342 qPos.add(active);
1343
1344 qPos.add(recommended);
1345
1346 count = (Long)q.uniqueResult();
1347 }
1348 catch (Exception e) {
1349 throw processException(e);
1350 }
1351 finally {
1352 if (count == null) {
1353 count = Long.valueOf(0);
1354 }
1355
1356 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_A_R, finderArgs,
1357 count);
1358
1359 closeSession(session);
1360 }
1361 }
1362
1363 return count.intValue();
1364 }
1365
1366
1372 public int countAll() throws SystemException {
1373 Object[] finderArgs = new Object[0];
1374
1375 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
1376 finderArgs, this);
1377
1378 if (count == null) {
1379 Session session = null;
1380
1381 try {
1382 session = openSession();
1383
1384 Query q = session.createQuery(_SQL_COUNT_SCLICENSE);
1385
1386 count = (Long)q.uniqueResult();
1387 }
1388 catch (Exception e) {
1389 throw processException(e);
1390 }
1391 finally {
1392 if (count == null) {
1393 count = Long.valueOf(0);
1394 }
1395
1396 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL, finderArgs,
1397 count);
1398
1399 closeSession(session);
1400 }
1401 }
1402
1403 return count.intValue();
1404 }
1405
1406
1413 public List<com.liferay.portlet.softwarecatalog.model.SCProductEntry> getSCProductEntries(
1414 long pk) throws SystemException {
1415 return getSCProductEntries(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
1416 }
1417
1418
1431 public List<com.liferay.portlet.softwarecatalog.model.SCProductEntry> getSCProductEntries(
1432 long pk, int start, int end) throws SystemException {
1433 return getSCProductEntries(pk, start, end, null);
1434 }
1435
1436 public static final FinderPath FINDER_PATH_GET_SCPRODUCTENTRIES = new FinderPath(com.liferay.portlet.softwarecatalog.model.impl.SCProductEntryModelImpl.ENTITY_CACHE_ENABLED,
1437 SCLicenseModelImpl.FINDER_CACHE_ENABLED_SCLICENSES_SCPRODUCTENTRIES,
1438 SCLicenseModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME,
1439 "getSCProductEntries",
1440 new String[] {
1441 Long.class.getName(), "java.lang.Integer", "java.lang.Integer",
1442 "com.liferay.portal.kernel.util.OrderByComparator"
1443 });
1444
1445
1459 public List<com.liferay.portlet.softwarecatalog.model.SCProductEntry> getSCProductEntries(
1460 long pk, int start, int end, OrderByComparator orderByComparator)
1461 throws SystemException {
1462 Object[] finderArgs = new Object[] {
1463 pk, String.valueOf(start), String.valueOf(end),
1464 String.valueOf(orderByComparator)
1465 };
1466
1467 List<com.liferay.portlet.softwarecatalog.model.SCProductEntry> list = (List<com.liferay.portlet.softwarecatalog.model.SCProductEntry>)FinderCacheUtil.getResult(FINDER_PATH_GET_SCPRODUCTENTRIES,
1468 finderArgs, this);
1469
1470 if (list == null) {
1471 Session session = null;
1472
1473 try {
1474 session = openSession();
1475
1476 String sql = null;
1477
1478 if (orderByComparator != null) {
1479 sql = _SQL_GETSCPRODUCTENTRIES.concat(ORDER_BY_CLAUSE)
1480 .concat(orderByComparator.getOrderBy());
1481 }
1482 else {
1483 sql = _SQL_GETSCPRODUCTENTRIES.concat(com.liferay.portlet.softwarecatalog.model.impl.SCProductEntryModelImpl.ORDER_BY_SQL);
1484 }
1485
1486 SQLQuery q = session.createSQLQuery(sql);
1487
1488 q.addEntity("SCProductEntry",
1489 com.liferay.portlet.softwarecatalog.model.impl.SCProductEntryImpl.class);
1490
1491 QueryPos qPos = QueryPos.getInstance(q);
1492
1493 qPos.add(pk);
1494
1495 list = (List<com.liferay.portlet.softwarecatalog.model.SCProductEntry>)QueryUtil.list(q,
1496 getDialect(), start, end);
1497 }
1498 catch (Exception e) {
1499 throw processException(e);
1500 }
1501 finally {
1502 if (list == null) {
1503 list = new ArrayList<com.liferay.portlet.softwarecatalog.model.SCProductEntry>();
1504 }
1505
1506 scProductEntryPersistence.cacheResult(list);
1507
1508 FinderCacheUtil.putResult(FINDER_PATH_GET_SCPRODUCTENTRIES,
1509 finderArgs, list);
1510
1511 closeSession(session);
1512 }
1513 }
1514
1515 return list;
1516 }
1517
1518 public static final FinderPath FINDER_PATH_GET_SCPRODUCTENTRIES_SIZE = new FinderPath(com.liferay.portlet.softwarecatalog.model.impl.SCProductEntryModelImpl.ENTITY_CACHE_ENABLED,
1519 SCLicenseModelImpl.FINDER_CACHE_ENABLED_SCLICENSES_SCPRODUCTENTRIES,
1520 SCLicenseModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME,
1521 "getSCProductEntriesSize", new String[] { Long.class.getName() });
1522
1523
1530 public int getSCProductEntriesSize(long pk) throws SystemException {
1531 Object[] finderArgs = new Object[] { pk };
1532
1533 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_GET_SCPRODUCTENTRIES_SIZE,
1534 finderArgs, this);
1535
1536 if (count == null) {
1537 Session session = null;
1538
1539 try {
1540 session = openSession();
1541
1542 SQLQuery q = session.createSQLQuery(_SQL_GETSCPRODUCTENTRIESSIZE);
1543
1544 q.addScalar(COUNT_COLUMN_NAME,
1545 com.liferay.portal.kernel.dao.orm.Type.LONG);
1546
1547 QueryPos qPos = QueryPos.getInstance(q);
1548
1549 qPos.add(pk);
1550
1551 count = (Long)q.uniqueResult();
1552 }
1553 catch (Exception e) {
1554 throw processException(e);
1555 }
1556 finally {
1557 if (count == null) {
1558 count = Long.valueOf(0);
1559 }
1560
1561 FinderCacheUtil.putResult(FINDER_PATH_GET_SCPRODUCTENTRIES_SIZE,
1562 finderArgs, count);
1563
1564 closeSession(session);
1565 }
1566 }
1567
1568 return count.intValue();
1569 }
1570
1571 public static final FinderPath FINDER_PATH_CONTAINS_SCPRODUCTENTRY = new FinderPath(com.liferay.portlet.softwarecatalog.model.impl.SCProductEntryModelImpl.ENTITY_CACHE_ENABLED,
1572 SCLicenseModelImpl.FINDER_CACHE_ENABLED_SCLICENSES_SCPRODUCTENTRIES,
1573 SCLicenseModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME,
1574 "containsSCProductEntry",
1575 new String[] { Long.class.getName(), Long.class.getName() });
1576
1577
1585 public boolean containsSCProductEntry(long pk, long scProductEntryPK)
1586 throws SystemException {
1587 Object[] finderArgs = new Object[] { pk, scProductEntryPK };
1588
1589 Boolean value = (Boolean)FinderCacheUtil.getResult(FINDER_PATH_CONTAINS_SCPRODUCTENTRY,
1590 finderArgs, this);
1591
1592 if (value == null) {
1593 try {
1594 value = Boolean.valueOf(containsSCProductEntry.contains(pk,
1595 scProductEntryPK));
1596 }
1597 catch (Exception e) {
1598 throw processException(e);
1599 }
1600 finally {
1601 if (value == null) {
1602 value = Boolean.FALSE;
1603 }
1604
1605 FinderCacheUtil.putResult(FINDER_PATH_CONTAINS_SCPRODUCTENTRY,
1606 finderArgs, value);
1607 }
1608 }
1609
1610 return value.booleanValue();
1611 }
1612
1613
1620 public boolean containsSCProductEntries(long pk) throws SystemException {
1621 if (getSCProductEntriesSize(pk) > 0) {
1622 return true;
1623 }
1624 else {
1625 return false;
1626 }
1627 }
1628
1629
1636 public void addSCProductEntry(long pk, long scProductEntryPK)
1637 throws SystemException {
1638 try {
1639 addSCProductEntry.add(pk, scProductEntryPK);
1640 }
1641 catch (Exception e) {
1642 throw processException(e);
1643 }
1644 finally {
1645 FinderCacheUtil.clearCache(SCLicenseModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME);
1646 }
1647 }
1648
1649
1656 public void addSCProductEntry(long pk,
1657 com.liferay.portlet.softwarecatalog.model.SCProductEntry scProductEntry)
1658 throws SystemException {
1659 try {
1660 addSCProductEntry.add(pk, scProductEntry.getPrimaryKey());
1661 }
1662 catch (Exception e) {
1663 throw processException(e);
1664 }
1665 finally {
1666 FinderCacheUtil.clearCache(SCLicenseModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME);
1667 }
1668 }
1669
1670
1677 public void addSCProductEntries(long pk, long[] scProductEntryPKs)
1678 throws SystemException {
1679 try {
1680 for (long scProductEntryPK : scProductEntryPKs) {
1681 addSCProductEntry.add(pk, scProductEntryPK);
1682 }
1683 }
1684 catch (Exception e) {
1685 throw processException(e);
1686 }
1687 finally {
1688 FinderCacheUtil.clearCache(SCLicenseModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME);
1689 }
1690 }
1691
1692
1699 public void addSCProductEntries(long pk,
1700 List<com.liferay.portlet.softwarecatalog.model.SCProductEntry> scProductEntries)
1701 throws SystemException {
1702 try {
1703 for (com.liferay.portlet.softwarecatalog.model.SCProductEntry scProductEntry : scProductEntries) {
1704 addSCProductEntry.add(pk, scProductEntry.getPrimaryKey());
1705 }
1706 }
1707 catch (Exception e) {
1708 throw processException(e);
1709 }
1710 finally {
1711 FinderCacheUtil.clearCache(SCLicenseModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME);
1712 }
1713 }
1714
1715
1721 public void clearSCProductEntries(long pk) throws SystemException {
1722 try {
1723 clearSCProductEntries.clear(pk);
1724 }
1725 catch (Exception e) {
1726 throw processException(e);
1727 }
1728 finally {
1729 FinderCacheUtil.clearCache(SCLicenseModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME);
1730 }
1731 }
1732
1733
1740 public void removeSCProductEntry(long pk, long scProductEntryPK)
1741 throws SystemException {
1742 try {
1743 removeSCProductEntry.remove(pk, scProductEntryPK);
1744 }
1745 catch (Exception e) {
1746 throw processException(e);
1747 }
1748 finally {
1749 FinderCacheUtil.clearCache(SCLicenseModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME);
1750 }
1751 }
1752
1753
1760 public void removeSCProductEntry(long pk,
1761 com.liferay.portlet.softwarecatalog.model.SCProductEntry scProductEntry)
1762 throws SystemException {
1763 try {
1764 removeSCProductEntry.remove(pk, scProductEntry.getPrimaryKey());
1765 }
1766 catch (Exception e) {
1767 throw processException(e);
1768 }
1769 finally {
1770 FinderCacheUtil.clearCache(SCLicenseModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME);
1771 }
1772 }
1773
1774
1781 public void removeSCProductEntries(long pk, long[] scProductEntryPKs)
1782 throws SystemException {
1783 try {
1784 for (long scProductEntryPK : scProductEntryPKs) {
1785 removeSCProductEntry.remove(pk, scProductEntryPK);
1786 }
1787 }
1788 catch (Exception e) {
1789 throw processException(e);
1790 }
1791 finally {
1792 FinderCacheUtil.clearCache(SCLicenseModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME);
1793 }
1794 }
1795
1796
1803 public void removeSCProductEntries(long pk,
1804 List<com.liferay.portlet.softwarecatalog.model.SCProductEntry> scProductEntries)
1805 throws SystemException {
1806 try {
1807 for (com.liferay.portlet.softwarecatalog.model.SCProductEntry scProductEntry : scProductEntries) {
1808 removeSCProductEntry.remove(pk, scProductEntry.getPrimaryKey());
1809 }
1810 }
1811 catch (Exception e) {
1812 throw processException(e);
1813 }
1814 finally {
1815 FinderCacheUtil.clearCache(SCLicenseModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME);
1816 }
1817 }
1818
1819
1826 public void setSCProductEntries(long pk, long[] scProductEntryPKs)
1827 throws SystemException {
1828 try {
1829 Set<Long> scProductEntryPKSet = SetUtil.fromArray(scProductEntryPKs);
1830
1831 List<com.liferay.portlet.softwarecatalog.model.SCProductEntry> scProductEntries =
1832 getSCProductEntries(pk);
1833
1834 for (com.liferay.portlet.softwarecatalog.model.SCProductEntry scProductEntry : scProductEntries) {
1835 if (!scProductEntryPKSet.remove(scProductEntry.getPrimaryKey())) {
1836 removeSCProductEntry.remove(pk,
1837 scProductEntry.getPrimaryKey());
1838 }
1839 }
1840
1841 for (Long scProductEntryPK : scProductEntryPKSet) {
1842 addSCProductEntry.add(pk, scProductEntryPK);
1843 }
1844 }
1845 catch (Exception e) {
1846 throw processException(e);
1847 }
1848 finally {
1849 FinderCacheUtil.clearCache(SCLicenseModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME);
1850 }
1851 }
1852
1853
1860 public void setSCProductEntries(long pk,
1861 List<com.liferay.portlet.softwarecatalog.model.SCProductEntry> scProductEntries)
1862 throws SystemException {
1863 try {
1864 long[] scProductEntryPKs = new long[scProductEntries.size()];
1865
1866 for (int i = 0; i < scProductEntries.size(); i++) {
1867 com.liferay.portlet.softwarecatalog.model.SCProductEntry scProductEntry =
1868 scProductEntries.get(i);
1869
1870 scProductEntryPKs[i] = scProductEntry.getPrimaryKey();
1871 }
1872
1873 setSCProductEntries(pk, scProductEntryPKs);
1874 }
1875 catch (Exception e) {
1876 throw processException(e);
1877 }
1878 finally {
1879 FinderCacheUtil.clearCache(SCLicenseModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME);
1880 }
1881 }
1882
1883
1886 public void afterPropertiesSet() {
1887 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
1888 com.liferay.portal.util.PropsUtil.get(
1889 "value.object.listener.com.liferay.portlet.softwarecatalog.model.SCLicense")));
1890
1891 if (listenerClassNames.length > 0) {
1892 try {
1893 List<ModelListener<SCLicense>> listenersList = new ArrayList<ModelListener<SCLicense>>();
1894
1895 for (String listenerClassName : listenerClassNames) {
1896 listenersList.add((ModelListener<SCLicense>)InstanceFactory.newInstance(
1897 listenerClassName));
1898 }
1899
1900 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
1901 }
1902 catch (Exception e) {
1903 _log.error(e);
1904 }
1905 }
1906
1907 containsSCProductEntry = new ContainsSCProductEntry(this);
1908
1909 addSCProductEntry = new AddSCProductEntry(this);
1910 clearSCProductEntries = new ClearSCProductEntries(this);
1911 removeSCProductEntry = new RemoveSCProductEntry(this);
1912 }
1913
1914 @BeanReference(type = SCLicensePersistence.class)
1915 protected SCLicensePersistence scLicensePersistence;
1916 @BeanReference(type = SCFrameworkVersionPersistence.class)
1917 protected SCFrameworkVersionPersistence scFrameworkVersionPersistence;
1918 @BeanReference(type = SCProductEntryPersistence.class)
1919 protected SCProductEntryPersistence scProductEntryPersistence;
1920 @BeanReference(type = SCProductScreenshotPersistence.class)
1921 protected SCProductScreenshotPersistence scProductScreenshotPersistence;
1922 @BeanReference(type = SCProductVersionPersistence.class)
1923 protected SCProductVersionPersistence scProductVersionPersistence;
1924 @BeanReference(type = ResourcePersistence.class)
1925 protected ResourcePersistence resourcePersistence;
1926 @BeanReference(type = UserPersistence.class)
1927 protected UserPersistence userPersistence;
1928 protected ContainsSCProductEntry containsSCProductEntry;
1929 protected AddSCProductEntry addSCProductEntry;
1930 protected ClearSCProductEntries clearSCProductEntries;
1931 protected RemoveSCProductEntry removeSCProductEntry;
1932
1933 protected class ContainsSCProductEntry {
1934 protected ContainsSCProductEntry(
1935 SCLicensePersistenceImpl persistenceImpl) {
1936 super();
1937
1938 _mappingSqlQuery = MappingSqlQueryFactoryUtil.getMappingSqlQuery(getDataSource(),
1939 _SQL_CONTAINSSCPRODUCTENTRY,
1940 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT },
1941 RowMapper.COUNT);
1942 }
1943
1944 protected boolean contains(long licenseId, long productEntryId) {
1945 List<Integer> results = _mappingSqlQuery.execute(new Object[] {
1946 new Long(licenseId), new Long(productEntryId)
1947 });
1948
1949 if (results.size() > 0) {
1950 Integer count = results.get(0);
1951
1952 if (count.intValue() > 0) {
1953 return true;
1954 }
1955 }
1956
1957 return false;
1958 }
1959
1960 private MappingSqlQuery<Integer> _mappingSqlQuery;
1961 }
1962
1963 protected class AddSCProductEntry {
1964 protected AddSCProductEntry(SCLicensePersistenceImpl persistenceImpl) {
1965 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
1966 "INSERT INTO SCLicenses_SCProductEntries (licenseId, productEntryId) VALUES (?, ?)",
1967 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
1968 _persistenceImpl = persistenceImpl;
1969 }
1970
1971 protected void add(long licenseId, long productEntryId)
1972 throws SystemException {
1973 if (!_persistenceImpl.containsSCProductEntry.contains(licenseId,
1974 productEntryId)) {
1975 ModelListener<com.liferay.portlet.softwarecatalog.model.SCProductEntry>[] scProductEntryListeners =
1976 scProductEntryPersistence.getListeners();
1977
1978 for (ModelListener<SCLicense> listener : listeners) {
1979 listener.onBeforeAddAssociation(licenseId,
1980 com.liferay.portlet.softwarecatalog.model.SCProductEntry.class.getName(),
1981 productEntryId);
1982 }
1983
1984 for (ModelListener<com.liferay.portlet.softwarecatalog.model.SCProductEntry> listener : scProductEntryListeners) {
1985 listener.onBeforeAddAssociation(productEntryId,
1986 SCLicense.class.getName(), licenseId);
1987 }
1988
1989 _sqlUpdate.update(new Object[] {
1990 new Long(licenseId), new Long(productEntryId)
1991 });
1992
1993 for (ModelListener<SCLicense> listener : listeners) {
1994 listener.onAfterAddAssociation(licenseId,
1995 com.liferay.portlet.softwarecatalog.model.SCProductEntry.class.getName(),
1996 productEntryId);
1997 }
1998
1999 for (ModelListener<com.liferay.portlet.softwarecatalog.model.SCProductEntry> listener : scProductEntryListeners) {
2000 listener.onAfterAddAssociation(productEntryId,
2001 SCLicense.class.getName(), licenseId);
2002 }
2003 }
2004 }
2005
2006 private SqlUpdate _sqlUpdate;
2007 private SCLicensePersistenceImpl _persistenceImpl;
2008 }
2009
2010 protected class ClearSCProductEntries {
2011 protected ClearSCProductEntries(
2012 SCLicensePersistenceImpl persistenceImpl) {
2013 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
2014 "DELETE FROM SCLicenses_SCProductEntries WHERE licenseId = ?",
2015 new int[] { java.sql.Types.BIGINT });
2016 }
2017
2018 protected void clear(long licenseId) throws SystemException {
2019 ModelListener<com.liferay.portlet.softwarecatalog.model.SCProductEntry>[] scProductEntryListeners =
2020 scProductEntryPersistence.getListeners();
2021
2022 List<com.liferay.portlet.softwarecatalog.model.SCProductEntry> scProductEntries =
2023 null;
2024
2025 if ((listeners.length > 0) || (scProductEntryListeners.length > 0)) {
2026 scProductEntries = getSCProductEntries(licenseId);
2027
2028 for (com.liferay.portlet.softwarecatalog.model.SCProductEntry scProductEntry : scProductEntries) {
2029 for (ModelListener<SCLicense> listener : listeners) {
2030 listener.onBeforeRemoveAssociation(licenseId,
2031 com.liferay.portlet.softwarecatalog.model.SCProductEntry.class.getName(),
2032 scProductEntry.getPrimaryKey());
2033 }
2034
2035 for (ModelListener<com.liferay.portlet.softwarecatalog.model.SCProductEntry> listener : scProductEntryListeners) {
2036 listener.onBeforeRemoveAssociation(scProductEntry.getPrimaryKey(),
2037 SCLicense.class.getName(), licenseId);
2038 }
2039 }
2040 }
2041
2042 _sqlUpdate.update(new Object[] { new Long(licenseId) });
2043
2044 if ((listeners.length > 0) || (scProductEntryListeners.length > 0)) {
2045 for (com.liferay.portlet.softwarecatalog.model.SCProductEntry scProductEntry : scProductEntries) {
2046 for (ModelListener<SCLicense> listener : listeners) {
2047 listener.onAfterRemoveAssociation(licenseId,
2048 com.liferay.portlet.softwarecatalog.model.SCProductEntry.class.getName(),
2049 scProductEntry.getPrimaryKey());
2050 }
2051
2052 for (ModelListener<com.liferay.portlet.softwarecatalog.model.SCProductEntry> listener : scProductEntryListeners) {
2053 listener.onAfterRemoveAssociation(scProductEntry.getPrimaryKey(),
2054 SCLicense.class.getName(), licenseId);
2055 }
2056 }
2057 }
2058 }
2059
2060 private SqlUpdate _sqlUpdate;
2061 }
2062
2063 protected class RemoveSCProductEntry {
2064 protected RemoveSCProductEntry(SCLicensePersistenceImpl persistenceImpl) {
2065 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
2066 "DELETE FROM SCLicenses_SCProductEntries WHERE licenseId = ? AND productEntryId = ?",
2067 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
2068 _persistenceImpl = persistenceImpl;
2069 }
2070
2071 protected void remove(long licenseId, long productEntryId)
2072 throws SystemException {
2073 if (_persistenceImpl.containsSCProductEntry.contains(licenseId,
2074 productEntryId)) {
2075 ModelListener<com.liferay.portlet.softwarecatalog.model.SCProductEntry>[] scProductEntryListeners =
2076 scProductEntryPersistence.getListeners();
2077
2078 for (ModelListener<SCLicense> listener : listeners) {
2079 listener.onBeforeRemoveAssociation(licenseId,
2080 com.liferay.portlet.softwarecatalog.model.SCProductEntry.class.getName(),
2081 productEntryId);
2082 }
2083
2084 for (ModelListener<com.liferay.portlet.softwarecatalog.model.SCProductEntry> listener : scProductEntryListeners) {
2085 listener.onBeforeRemoveAssociation(productEntryId,
2086 SCLicense.class.getName(), licenseId);
2087 }
2088
2089 _sqlUpdate.update(new Object[] {
2090 new Long(licenseId), new Long(productEntryId)
2091 });
2092
2093 for (ModelListener<SCLicense> listener : listeners) {
2094 listener.onAfterRemoveAssociation(licenseId,
2095 com.liferay.portlet.softwarecatalog.model.SCProductEntry.class.getName(),
2096 productEntryId);
2097 }
2098
2099 for (ModelListener<com.liferay.portlet.softwarecatalog.model.SCProductEntry> listener : scProductEntryListeners) {
2100 listener.onAfterRemoveAssociation(productEntryId,
2101 SCLicense.class.getName(), licenseId);
2102 }
2103 }
2104 }
2105
2106 private SqlUpdate _sqlUpdate;
2107 private SCLicensePersistenceImpl _persistenceImpl;
2108 }
2109
2110 private static final String _SQL_SELECT_SCLICENSE = "SELECT scLicense FROM SCLicense scLicense";
2111 private static final String _SQL_SELECT_SCLICENSE_WHERE = "SELECT scLicense FROM SCLicense scLicense WHERE ";
2112 private static final String _SQL_COUNT_SCLICENSE = "SELECT COUNT(scLicense) FROM SCLicense scLicense";
2113 private static final String _SQL_COUNT_SCLICENSE_WHERE = "SELECT COUNT(scLicense) FROM SCLicense scLicense WHERE ";
2114 private static final String _SQL_GETSCPRODUCTENTRIES = "SELECT {SCProductEntry.*} FROM SCProductEntry INNER JOIN SCLicenses_SCProductEntries ON (SCLicenses_SCProductEntries.productEntryId = SCProductEntry.productEntryId) WHERE (SCLicenses_SCProductEntries.licenseId = ?)";
2115 private static final String _SQL_GETSCPRODUCTENTRIESSIZE = "SELECT COUNT(*) AS COUNT_VALUE FROM SCLicenses_SCProductEntries WHERE licenseId = ?";
2116 private static final String _SQL_CONTAINSSCPRODUCTENTRY = "SELECT COUNT(*) AS COUNT_VALUE FROM SCLicenses_SCProductEntries WHERE licenseId = ? AND productEntryId = ?";
2117 private static final String _FINDER_COLUMN_ACTIVE_ACTIVE_2 = "scLicense.active = ?";
2118 private static final String _FINDER_COLUMN_A_R_ACTIVE_2 = "scLicense.active = ? AND ";
2119 private static final String _FINDER_COLUMN_A_R_RECOMMENDED_2 = "scLicense.recommended = ?";
2120 private static final String _ORDER_BY_ENTITY_ALIAS = "scLicense.";
2121 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No SCLicense exists with the primary key ";
2122 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No SCLicense exists with the key {";
2123 private static Log _log = LogFactoryUtil.getLog(SCLicensePersistenceImpl.class);
2124 }