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.kernel.util.Validator;
044 import com.liferay.portal.model.ModelListener;
045 import com.liferay.portal.service.persistence.BatchSessionUtil;
046 import com.liferay.portal.service.persistence.ResourcePersistence;
047 import com.liferay.portal.service.persistence.UserPersistence;
048 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
049
050 import com.liferay.portlet.softwarecatalog.NoSuchProductVersionException;
051 import com.liferay.portlet.softwarecatalog.model.SCProductVersion;
052 import com.liferay.portlet.softwarecatalog.model.impl.SCProductVersionImpl;
053 import com.liferay.portlet.softwarecatalog.model.impl.SCProductVersionModelImpl;
054
055 import java.io.Serializable;
056
057 import java.util.ArrayList;
058 import java.util.Collections;
059 import java.util.List;
060 import java.util.Set;
061
062
078 public class SCProductVersionPersistenceImpl extends BasePersistenceImpl<SCProductVersion>
079 implements SCProductVersionPersistence {
080 public static final String FINDER_CLASS_NAME_ENTITY = SCProductVersionImpl.class.getName();
081 public static final String FINDER_CLASS_NAME_LIST = FINDER_CLASS_NAME_ENTITY +
082 ".List";
083 public static final FinderPath FINDER_PATH_FIND_BY_PRODUCTENTRYID = new FinderPath(SCProductVersionModelImpl.ENTITY_CACHE_ENABLED,
084 SCProductVersionModelImpl.FINDER_CACHE_ENABLED,
085 FINDER_CLASS_NAME_LIST, "findByProductEntryId",
086 new String[] {
087 Long.class.getName(),
088
089 "java.lang.Integer", "java.lang.Integer",
090 "com.liferay.portal.kernel.util.OrderByComparator"
091 });
092 public static final FinderPath FINDER_PATH_COUNT_BY_PRODUCTENTRYID = new FinderPath(SCProductVersionModelImpl.ENTITY_CACHE_ENABLED,
093 SCProductVersionModelImpl.FINDER_CACHE_ENABLED,
094 FINDER_CLASS_NAME_LIST, "countByProductEntryId",
095 new String[] { Long.class.getName() });
096 public static final FinderPath FINDER_PATH_FETCH_BY_DIRECTDOWNLOADURL = new FinderPath(SCProductVersionModelImpl.ENTITY_CACHE_ENABLED,
097 SCProductVersionModelImpl.FINDER_CACHE_ENABLED,
098 FINDER_CLASS_NAME_ENTITY, "fetchByDirectDownloadURL",
099 new String[] { String.class.getName() });
100 public static final FinderPath FINDER_PATH_COUNT_BY_DIRECTDOWNLOADURL = new FinderPath(SCProductVersionModelImpl.ENTITY_CACHE_ENABLED,
101 SCProductVersionModelImpl.FINDER_CACHE_ENABLED,
102 FINDER_CLASS_NAME_LIST, "countByDirectDownloadURL",
103 new String[] { String.class.getName() });
104 public static final FinderPath FINDER_PATH_FIND_ALL = new FinderPath(SCProductVersionModelImpl.ENTITY_CACHE_ENABLED,
105 SCProductVersionModelImpl.FINDER_CACHE_ENABLED,
106 FINDER_CLASS_NAME_LIST, "findAll", new String[0]);
107 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(SCProductVersionModelImpl.ENTITY_CACHE_ENABLED,
108 SCProductVersionModelImpl.FINDER_CACHE_ENABLED,
109 FINDER_CLASS_NAME_LIST, "countAll", new String[0]);
110
111
116 public void cacheResult(SCProductVersion scProductVersion) {
117 EntityCacheUtil.putResult(SCProductVersionModelImpl.ENTITY_CACHE_ENABLED,
118 SCProductVersionImpl.class, scProductVersion.getPrimaryKey(),
119 scProductVersion);
120
121 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_DIRECTDOWNLOADURL,
122 new Object[] { scProductVersion.getDirectDownloadURL() },
123 scProductVersion);
124 }
125
126
131 public void cacheResult(List<SCProductVersion> scProductVersions) {
132 for (SCProductVersion scProductVersion : scProductVersions) {
133 if (EntityCacheUtil.getResult(
134 SCProductVersionModelImpl.ENTITY_CACHE_ENABLED,
135 SCProductVersionImpl.class,
136 scProductVersion.getPrimaryKey(), this) == null) {
137 cacheResult(scProductVersion);
138 }
139 }
140 }
141
142
149 public void clearCache() {
150 CacheRegistryUtil.clear(SCProductVersionImpl.class.getName());
151 EntityCacheUtil.clearCache(SCProductVersionImpl.class.getName());
152 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
153 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
154 }
155
156
163 public void clearCache(SCProductVersion scProductVersion) {
164 EntityCacheUtil.removeResult(SCProductVersionModelImpl.ENTITY_CACHE_ENABLED,
165 SCProductVersionImpl.class, scProductVersion.getPrimaryKey());
166
167 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_DIRECTDOWNLOADURL,
168 new Object[] { scProductVersion.getDirectDownloadURL() });
169 }
170
171
177 public SCProductVersion create(long productVersionId) {
178 SCProductVersion scProductVersion = new SCProductVersionImpl();
179
180 scProductVersion.setNew(true);
181 scProductVersion.setPrimaryKey(productVersionId);
182
183 return scProductVersion;
184 }
185
186
194 public SCProductVersion remove(Serializable primaryKey)
195 throws NoSuchModelException, SystemException {
196 return remove(((Long)primaryKey).longValue());
197 }
198
199
207 public SCProductVersion remove(long productVersionId)
208 throws NoSuchProductVersionException, SystemException {
209 Session session = null;
210
211 try {
212 session = openSession();
213
214 SCProductVersion scProductVersion = (SCProductVersion)session.get(SCProductVersionImpl.class,
215 new Long(productVersionId));
216
217 if (scProductVersion == null) {
218 if (_log.isWarnEnabled()) {
219 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
220 productVersionId);
221 }
222
223 throw new NoSuchProductVersionException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
224 productVersionId);
225 }
226
227 return remove(scProductVersion);
228 }
229 catch (NoSuchProductVersionException nsee) {
230 throw nsee;
231 }
232 catch (Exception e) {
233 throw processException(e);
234 }
235 finally {
236 closeSession(session);
237 }
238 }
239
240 protected SCProductVersion removeImpl(SCProductVersion scProductVersion)
241 throws SystemException {
242 scProductVersion = toUnwrappedModel(scProductVersion);
243
244 try {
245 clearSCFrameworkVersions.clear(scProductVersion.getPrimaryKey());
246 }
247 catch (Exception e) {
248 throw processException(e);
249 }
250 finally {
251 FinderCacheUtil.clearCache(SCProductVersionModelImpl.MAPPING_TABLE_SCFRAMEWORKVERSI_SCPRODUCTVERS_NAME);
252 }
253
254 Session session = null;
255
256 try {
257 session = openSession();
258
259 BatchSessionUtil.delete(session, scProductVersion);
260 }
261 catch (Exception e) {
262 throw processException(e);
263 }
264 finally {
265 closeSession(session);
266 }
267
268 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
269
270 SCProductVersionModelImpl scProductVersionModelImpl = (SCProductVersionModelImpl)scProductVersion;
271
272 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_DIRECTDOWNLOADURL,
273 new Object[] {
274 scProductVersionModelImpl.getOriginalDirectDownloadURL()
275 });
276
277 EntityCacheUtil.removeResult(SCProductVersionModelImpl.ENTITY_CACHE_ENABLED,
278 SCProductVersionImpl.class, scProductVersion.getPrimaryKey());
279
280 return scProductVersion;
281 }
282
283 public SCProductVersion updateImpl(
284 com.liferay.portlet.softwarecatalog.model.SCProductVersion scProductVersion,
285 boolean merge) throws SystemException {
286 scProductVersion = toUnwrappedModel(scProductVersion);
287
288 boolean isNew = scProductVersion.isNew();
289
290 SCProductVersionModelImpl scProductVersionModelImpl = (SCProductVersionModelImpl)scProductVersion;
291
292 Session session = null;
293
294 try {
295 session = openSession();
296
297 BatchSessionUtil.update(session, scProductVersion, merge);
298
299 scProductVersion.setNew(false);
300 }
301 catch (Exception e) {
302 throw processException(e);
303 }
304 finally {
305 closeSession(session);
306 }
307
308 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
309
310 EntityCacheUtil.putResult(SCProductVersionModelImpl.ENTITY_CACHE_ENABLED,
311 SCProductVersionImpl.class, scProductVersion.getPrimaryKey(),
312 scProductVersion);
313
314 if (!isNew &&
315 (!Validator.equals(scProductVersion.getDirectDownloadURL(),
316 scProductVersionModelImpl.getOriginalDirectDownloadURL()))) {
317 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_DIRECTDOWNLOADURL,
318 new Object[] {
319 scProductVersionModelImpl.getOriginalDirectDownloadURL()
320 });
321 }
322
323 if (isNew ||
324 (!Validator.equals(scProductVersion.getDirectDownloadURL(),
325 scProductVersionModelImpl.getOriginalDirectDownloadURL()))) {
326 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_DIRECTDOWNLOADURL,
327 new Object[] { scProductVersion.getDirectDownloadURL() },
328 scProductVersion);
329 }
330
331 return scProductVersion;
332 }
333
334 protected SCProductVersion toUnwrappedModel(
335 SCProductVersion scProductVersion) {
336 if (scProductVersion instanceof SCProductVersionImpl) {
337 return scProductVersion;
338 }
339
340 SCProductVersionImpl scProductVersionImpl = new SCProductVersionImpl();
341
342 scProductVersionImpl.setNew(scProductVersion.isNew());
343 scProductVersionImpl.setPrimaryKey(scProductVersion.getPrimaryKey());
344
345 scProductVersionImpl.setProductVersionId(scProductVersion.getProductVersionId());
346 scProductVersionImpl.setCompanyId(scProductVersion.getCompanyId());
347 scProductVersionImpl.setUserId(scProductVersion.getUserId());
348 scProductVersionImpl.setUserName(scProductVersion.getUserName());
349 scProductVersionImpl.setCreateDate(scProductVersion.getCreateDate());
350 scProductVersionImpl.setModifiedDate(scProductVersion.getModifiedDate());
351 scProductVersionImpl.setProductEntryId(scProductVersion.getProductEntryId());
352 scProductVersionImpl.setVersion(scProductVersion.getVersion());
353 scProductVersionImpl.setChangeLog(scProductVersion.getChangeLog());
354 scProductVersionImpl.setDownloadPageURL(scProductVersion.getDownloadPageURL());
355 scProductVersionImpl.setDirectDownloadURL(scProductVersion.getDirectDownloadURL());
356 scProductVersionImpl.setRepoStoreArtifact(scProductVersion.isRepoStoreArtifact());
357
358 return scProductVersionImpl;
359 }
360
361
369 public SCProductVersion findByPrimaryKey(Serializable primaryKey)
370 throws NoSuchModelException, SystemException {
371 return findByPrimaryKey(((Long)primaryKey).longValue());
372 }
373
374
382 public SCProductVersion findByPrimaryKey(long productVersionId)
383 throws NoSuchProductVersionException, SystemException {
384 SCProductVersion scProductVersion = fetchByPrimaryKey(productVersionId);
385
386 if (scProductVersion == null) {
387 if (_log.isWarnEnabled()) {
388 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + productVersionId);
389 }
390
391 throw new NoSuchProductVersionException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
392 productVersionId);
393 }
394
395 return scProductVersion;
396 }
397
398
405 public SCProductVersion fetchByPrimaryKey(Serializable primaryKey)
406 throws SystemException {
407 return fetchByPrimaryKey(((Long)primaryKey).longValue());
408 }
409
410
417 public SCProductVersion fetchByPrimaryKey(long productVersionId)
418 throws SystemException {
419 SCProductVersion scProductVersion = (SCProductVersion)EntityCacheUtil.getResult(SCProductVersionModelImpl.ENTITY_CACHE_ENABLED,
420 SCProductVersionImpl.class, productVersionId, this);
421
422 if (scProductVersion == null) {
423 Session session = null;
424
425 try {
426 session = openSession();
427
428 scProductVersion = (SCProductVersion)session.get(SCProductVersionImpl.class,
429 new Long(productVersionId));
430 }
431 catch (Exception e) {
432 throw processException(e);
433 }
434 finally {
435 if (scProductVersion != null) {
436 cacheResult(scProductVersion);
437 }
438
439 closeSession(session);
440 }
441 }
442
443 return scProductVersion;
444 }
445
446
453 public List<SCProductVersion> findByProductEntryId(long productEntryId)
454 throws SystemException {
455 return findByProductEntryId(productEntryId, QueryUtil.ALL_POS,
456 QueryUtil.ALL_POS, null);
457 }
458
459
472 public List<SCProductVersion> findByProductEntryId(long productEntryId,
473 int start, int end) throws SystemException {
474 return findByProductEntryId(productEntryId, start, end, null);
475 }
476
477
491 public List<SCProductVersion> findByProductEntryId(long productEntryId,
492 int start, int end, OrderByComparator orderByComparator)
493 throws SystemException {
494 Object[] finderArgs = new Object[] {
495 productEntryId,
496
497 String.valueOf(start), String.valueOf(end),
498 String.valueOf(orderByComparator)
499 };
500
501 List<SCProductVersion> list = (List<SCProductVersion>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_PRODUCTENTRYID,
502 finderArgs, this);
503
504 if (list == null) {
505 Session session = null;
506
507 try {
508 session = openSession();
509
510 StringBundler query = null;
511
512 if (orderByComparator != null) {
513 query = new StringBundler(3 +
514 (orderByComparator.getOrderByFields().length * 3));
515 }
516 else {
517 query = new StringBundler(3);
518 }
519
520 query.append(_SQL_SELECT_SCPRODUCTVERSION_WHERE);
521
522 query.append(_FINDER_COLUMN_PRODUCTENTRYID_PRODUCTENTRYID_2);
523
524 if (orderByComparator != null) {
525 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
526 orderByComparator);
527 }
528
529 else {
530 query.append(SCProductVersionModelImpl.ORDER_BY_JPQL);
531 }
532
533 String sql = query.toString();
534
535 Query q = session.createQuery(sql);
536
537 QueryPos qPos = QueryPos.getInstance(q);
538
539 qPos.add(productEntryId);
540
541 list = (List<SCProductVersion>)QueryUtil.list(q, getDialect(),
542 start, end);
543 }
544 catch (Exception e) {
545 throw processException(e);
546 }
547 finally {
548 if (list == null) {
549 list = new ArrayList<SCProductVersion>();
550 }
551
552 cacheResult(list);
553
554 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_PRODUCTENTRYID,
555 finderArgs, list);
556
557 closeSession(session);
558 }
559 }
560
561 return list;
562 }
563
564
577 public SCProductVersion findByProductEntryId_First(long productEntryId,
578 OrderByComparator orderByComparator)
579 throws NoSuchProductVersionException, SystemException {
580 List<SCProductVersion> list = findByProductEntryId(productEntryId, 0,
581 1, orderByComparator);
582
583 if (list.isEmpty()) {
584 StringBundler msg = new StringBundler(4);
585
586 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
587
588 msg.append("productEntryId=");
589 msg.append(productEntryId);
590
591 msg.append(StringPool.CLOSE_CURLY_BRACE);
592
593 throw new NoSuchProductVersionException(msg.toString());
594 }
595 else {
596 return list.get(0);
597 }
598 }
599
600
613 public SCProductVersion findByProductEntryId_Last(long productEntryId,
614 OrderByComparator orderByComparator)
615 throws NoSuchProductVersionException, SystemException {
616 int count = countByProductEntryId(productEntryId);
617
618 List<SCProductVersion> list = findByProductEntryId(productEntryId,
619 count - 1, count, orderByComparator);
620
621 if (list.isEmpty()) {
622 StringBundler msg = new StringBundler(4);
623
624 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
625
626 msg.append("productEntryId=");
627 msg.append(productEntryId);
628
629 msg.append(StringPool.CLOSE_CURLY_BRACE);
630
631 throw new NoSuchProductVersionException(msg.toString());
632 }
633 else {
634 return list.get(0);
635 }
636 }
637
638
652 public SCProductVersion[] findByProductEntryId_PrevAndNext(
653 long productVersionId, long productEntryId,
654 OrderByComparator orderByComparator)
655 throws NoSuchProductVersionException, SystemException {
656 SCProductVersion scProductVersion = findByPrimaryKey(productVersionId);
657
658 Session session = null;
659
660 try {
661 session = openSession();
662
663 SCProductVersion[] array = new SCProductVersionImpl[3];
664
665 array[0] = getByProductEntryId_PrevAndNext(session,
666 scProductVersion, productEntryId, orderByComparator, true);
667
668 array[1] = scProductVersion;
669
670 array[2] = getByProductEntryId_PrevAndNext(session,
671 scProductVersion, productEntryId, orderByComparator, false);
672
673 return array;
674 }
675 catch (Exception e) {
676 throw processException(e);
677 }
678 finally {
679 closeSession(session);
680 }
681 }
682
683 protected SCProductVersion getByProductEntryId_PrevAndNext(
684 Session session, SCProductVersion scProductVersion,
685 long productEntryId, OrderByComparator orderByComparator,
686 boolean previous) {
687 StringBundler query = null;
688
689 if (orderByComparator != null) {
690 query = new StringBundler(6 +
691 (orderByComparator.getOrderByFields().length * 6));
692 }
693 else {
694 query = new StringBundler(3);
695 }
696
697 query.append(_SQL_SELECT_SCPRODUCTVERSION_WHERE);
698
699 query.append(_FINDER_COLUMN_PRODUCTENTRYID_PRODUCTENTRYID_2);
700
701 if (orderByComparator != null) {
702 String[] orderByFields = orderByComparator.getOrderByFields();
703
704 if (orderByFields.length > 0) {
705 query.append(WHERE_AND);
706 }
707
708 for (int i = 0; i < orderByFields.length; i++) {
709 query.append(_ORDER_BY_ENTITY_ALIAS);
710 query.append(orderByFields[i]);
711
712 if ((i + 1) < orderByFields.length) {
713 if (orderByComparator.isAscending() ^ previous) {
714 query.append(WHERE_GREATER_THAN_HAS_NEXT);
715 }
716 else {
717 query.append(WHERE_LESSER_THAN_HAS_NEXT);
718 }
719 }
720 else {
721 if (orderByComparator.isAscending() ^ previous) {
722 query.append(WHERE_GREATER_THAN);
723 }
724 else {
725 query.append(WHERE_LESSER_THAN);
726 }
727 }
728 }
729
730 query.append(ORDER_BY_CLAUSE);
731
732 for (int i = 0; i < orderByFields.length; i++) {
733 query.append(_ORDER_BY_ENTITY_ALIAS);
734 query.append(orderByFields[i]);
735
736 if ((i + 1) < orderByFields.length) {
737 if (orderByComparator.isAscending() ^ previous) {
738 query.append(ORDER_BY_ASC_HAS_NEXT);
739 }
740 else {
741 query.append(ORDER_BY_DESC_HAS_NEXT);
742 }
743 }
744 else {
745 if (orderByComparator.isAscending() ^ previous) {
746 query.append(ORDER_BY_ASC);
747 }
748 else {
749 query.append(ORDER_BY_DESC);
750 }
751 }
752 }
753 }
754
755 else {
756 query.append(SCProductVersionModelImpl.ORDER_BY_JPQL);
757 }
758
759 String sql = query.toString();
760
761 Query q = session.createQuery(sql);
762
763 q.setFirstResult(0);
764 q.setMaxResults(2);
765
766 QueryPos qPos = QueryPos.getInstance(q);
767
768 qPos.add(productEntryId);
769
770 if (orderByComparator != null) {
771 Object[] values = orderByComparator.getOrderByValues(scProductVersion);
772
773 for (Object value : values) {
774 qPos.add(value);
775 }
776 }
777
778 List<SCProductVersion> list = q.list();
779
780 if (list.size() == 2) {
781 return list.get(1);
782 }
783 else {
784 return null;
785 }
786 }
787
788
796 public SCProductVersion findByDirectDownloadURL(String directDownloadURL)
797 throws NoSuchProductVersionException, SystemException {
798 SCProductVersion scProductVersion = fetchByDirectDownloadURL(directDownloadURL);
799
800 if (scProductVersion == null) {
801 StringBundler msg = new StringBundler(4);
802
803 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
804
805 msg.append("directDownloadURL=");
806 msg.append(directDownloadURL);
807
808 msg.append(StringPool.CLOSE_CURLY_BRACE);
809
810 if (_log.isWarnEnabled()) {
811 _log.warn(msg.toString());
812 }
813
814 throw new NoSuchProductVersionException(msg.toString());
815 }
816
817 return scProductVersion;
818 }
819
820
827 public SCProductVersion fetchByDirectDownloadURL(String directDownloadURL)
828 throws SystemException {
829 return fetchByDirectDownloadURL(directDownloadURL, true);
830 }
831
832
839 public SCProductVersion fetchByDirectDownloadURL(String directDownloadURL,
840 boolean retrieveFromCache) throws SystemException {
841 Object[] finderArgs = new Object[] { directDownloadURL };
842
843 Object result = null;
844
845 if (retrieveFromCache) {
846 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_DIRECTDOWNLOADURL,
847 finderArgs, this);
848 }
849
850 if (result == null) {
851 Session session = null;
852
853 try {
854 session = openSession();
855
856 StringBundler query = new StringBundler(3);
857
858 query.append(_SQL_SELECT_SCPRODUCTVERSION_WHERE);
859
860 if (directDownloadURL == null) {
861 query.append(_FINDER_COLUMN_DIRECTDOWNLOADURL_DIRECTDOWNLOADURL_1);
862 }
863 else {
864 if (directDownloadURL.equals(StringPool.BLANK)) {
865 query.append(_FINDER_COLUMN_DIRECTDOWNLOADURL_DIRECTDOWNLOADURL_3);
866 }
867 else {
868 query.append(_FINDER_COLUMN_DIRECTDOWNLOADURL_DIRECTDOWNLOADURL_2);
869 }
870 }
871
872 query.append(SCProductVersionModelImpl.ORDER_BY_JPQL);
873
874 String sql = query.toString();
875
876 Query q = session.createQuery(sql);
877
878 QueryPos qPos = QueryPos.getInstance(q);
879
880 if (directDownloadURL != null) {
881 qPos.add(directDownloadURL);
882 }
883
884 List<SCProductVersion> list = q.list();
885
886 result = list;
887
888 SCProductVersion scProductVersion = null;
889
890 if (list.isEmpty()) {
891 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_DIRECTDOWNLOADURL,
892 finderArgs, list);
893 }
894 else {
895 scProductVersion = list.get(0);
896
897 cacheResult(scProductVersion);
898
899 if ((scProductVersion.getDirectDownloadURL() == null) ||
900 !scProductVersion.getDirectDownloadURL()
901 .equals(directDownloadURL)) {
902 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_DIRECTDOWNLOADURL,
903 finderArgs, scProductVersion);
904 }
905 }
906
907 return scProductVersion;
908 }
909 catch (Exception e) {
910 throw processException(e);
911 }
912 finally {
913 if (result == null) {
914 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_DIRECTDOWNLOADURL,
915 finderArgs, new ArrayList<SCProductVersion>());
916 }
917
918 closeSession(session);
919 }
920 }
921 else {
922 if (result instanceof List<?>) {
923 return null;
924 }
925 else {
926 return (SCProductVersion)result;
927 }
928 }
929 }
930
931
937 public List<SCProductVersion> findAll() throws SystemException {
938 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
939 }
940
941
953 public List<SCProductVersion> findAll(int start, int end)
954 throws SystemException {
955 return findAll(start, end, null);
956 }
957
958
971 public List<SCProductVersion> findAll(int start, int end,
972 OrderByComparator orderByComparator) throws SystemException {
973 Object[] finderArgs = new Object[] {
974 String.valueOf(start), String.valueOf(end),
975 String.valueOf(orderByComparator)
976 };
977
978 List<SCProductVersion> list = (List<SCProductVersion>)FinderCacheUtil.getResult(FINDER_PATH_FIND_ALL,
979 finderArgs, this);
980
981 if (list == null) {
982 Session session = null;
983
984 try {
985 session = openSession();
986
987 StringBundler query = null;
988 String sql = null;
989
990 if (orderByComparator != null) {
991 query = new StringBundler(2 +
992 (orderByComparator.getOrderByFields().length * 3));
993
994 query.append(_SQL_SELECT_SCPRODUCTVERSION);
995
996 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
997 orderByComparator);
998
999 sql = query.toString();
1000 }
1001 else {
1002 sql = _SQL_SELECT_SCPRODUCTVERSION.concat(SCProductVersionModelImpl.ORDER_BY_JPQL);
1003 }
1004
1005 Query q = session.createQuery(sql);
1006
1007 if (orderByComparator == null) {
1008 list = (List<SCProductVersion>)QueryUtil.list(q,
1009 getDialect(), start, end, false);
1010
1011 Collections.sort(list);
1012 }
1013 else {
1014 list = (List<SCProductVersion>)QueryUtil.list(q,
1015 getDialect(), start, end);
1016 }
1017 }
1018 catch (Exception e) {
1019 throw processException(e);
1020 }
1021 finally {
1022 if (list == null) {
1023 list = new ArrayList<SCProductVersion>();
1024 }
1025
1026 cacheResult(list);
1027
1028 FinderCacheUtil.putResult(FINDER_PATH_FIND_ALL, finderArgs, list);
1029
1030 closeSession(session);
1031 }
1032 }
1033
1034 return list;
1035 }
1036
1037
1043 public void removeByProductEntryId(long productEntryId)
1044 throws SystemException {
1045 for (SCProductVersion scProductVersion : findByProductEntryId(
1046 productEntryId)) {
1047 remove(scProductVersion);
1048 }
1049 }
1050
1051
1057 public void removeByDirectDownloadURL(String directDownloadURL)
1058 throws NoSuchProductVersionException, SystemException {
1059 SCProductVersion scProductVersion = findByDirectDownloadURL(directDownloadURL);
1060
1061 remove(scProductVersion);
1062 }
1063
1064
1069 public void removeAll() throws SystemException {
1070 for (SCProductVersion scProductVersion : findAll()) {
1071 remove(scProductVersion);
1072 }
1073 }
1074
1075
1082 public int countByProductEntryId(long productEntryId)
1083 throws SystemException {
1084 Object[] finderArgs = new Object[] { productEntryId };
1085
1086 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_PRODUCTENTRYID,
1087 finderArgs, this);
1088
1089 if (count == null) {
1090 Session session = null;
1091
1092 try {
1093 session = openSession();
1094
1095 StringBundler query = new StringBundler(2);
1096
1097 query.append(_SQL_COUNT_SCPRODUCTVERSION_WHERE);
1098
1099 query.append(_FINDER_COLUMN_PRODUCTENTRYID_PRODUCTENTRYID_2);
1100
1101 String sql = query.toString();
1102
1103 Query q = session.createQuery(sql);
1104
1105 QueryPos qPos = QueryPos.getInstance(q);
1106
1107 qPos.add(productEntryId);
1108
1109 count = (Long)q.uniqueResult();
1110 }
1111 catch (Exception e) {
1112 throw processException(e);
1113 }
1114 finally {
1115 if (count == null) {
1116 count = Long.valueOf(0);
1117 }
1118
1119 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_PRODUCTENTRYID,
1120 finderArgs, count);
1121
1122 closeSession(session);
1123 }
1124 }
1125
1126 return count.intValue();
1127 }
1128
1129
1136 public int countByDirectDownloadURL(String directDownloadURL)
1137 throws SystemException {
1138 Object[] finderArgs = new Object[] { directDownloadURL };
1139
1140 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_DIRECTDOWNLOADURL,
1141 finderArgs, this);
1142
1143 if (count == null) {
1144 Session session = null;
1145
1146 try {
1147 session = openSession();
1148
1149 StringBundler query = new StringBundler(2);
1150
1151 query.append(_SQL_COUNT_SCPRODUCTVERSION_WHERE);
1152
1153 if (directDownloadURL == null) {
1154 query.append(_FINDER_COLUMN_DIRECTDOWNLOADURL_DIRECTDOWNLOADURL_1);
1155 }
1156 else {
1157 if (directDownloadURL.equals(StringPool.BLANK)) {
1158 query.append(_FINDER_COLUMN_DIRECTDOWNLOADURL_DIRECTDOWNLOADURL_3);
1159 }
1160 else {
1161 query.append(_FINDER_COLUMN_DIRECTDOWNLOADURL_DIRECTDOWNLOADURL_2);
1162 }
1163 }
1164
1165 String sql = query.toString();
1166
1167 Query q = session.createQuery(sql);
1168
1169 QueryPos qPos = QueryPos.getInstance(q);
1170
1171 if (directDownloadURL != null) {
1172 qPos.add(directDownloadURL);
1173 }
1174
1175 count = (Long)q.uniqueResult();
1176 }
1177 catch (Exception e) {
1178 throw processException(e);
1179 }
1180 finally {
1181 if (count == null) {
1182 count = Long.valueOf(0);
1183 }
1184
1185 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_DIRECTDOWNLOADURL,
1186 finderArgs, count);
1187
1188 closeSession(session);
1189 }
1190 }
1191
1192 return count.intValue();
1193 }
1194
1195
1201 public int countAll() throws SystemException {
1202 Object[] finderArgs = new Object[0];
1203
1204 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
1205 finderArgs, this);
1206
1207 if (count == null) {
1208 Session session = null;
1209
1210 try {
1211 session = openSession();
1212
1213 Query q = session.createQuery(_SQL_COUNT_SCPRODUCTVERSION);
1214
1215 count = (Long)q.uniqueResult();
1216 }
1217 catch (Exception e) {
1218 throw processException(e);
1219 }
1220 finally {
1221 if (count == null) {
1222 count = Long.valueOf(0);
1223 }
1224
1225 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL, finderArgs,
1226 count);
1227
1228 closeSession(session);
1229 }
1230 }
1231
1232 return count.intValue();
1233 }
1234
1235
1242 public List<com.liferay.portlet.softwarecatalog.model.SCFrameworkVersion> getSCFrameworkVersions(
1243 long pk) throws SystemException {
1244 return getSCFrameworkVersions(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
1245 }
1246
1247
1260 public List<com.liferay.portlet.softwarecatalog.model.SCFrameworkVersion> getSCFrameworkVersions(
1261 long pk, int start, int end) throws SystemException {
1262 return getSCFrameworkVersions(pk, start, end, null);
1263 }
1264
1265 public static final FinderPath FINDER_PATH_GET_SCFRAMEWORKVERSIONS = new FinderPath(com.liferay.portlet.softwarecatalog.model.impl.SCFrameworkVersionModelImpl.ENTITY_CACHE_ENABLED,
1266 SCProductVersionModelImpl.FINDER_CACHE_ENABLED_SCFRAMEWORKVERSI_SCPRODUCTVERS,
1267 SCProductVersionModelImpl.MAPPING_TABLE_SCFRAMEWORKVERSI_SCPRODUCTVERS_NAME,
1268 "getSCFrameworkVersions",
1269 new String[] {
1270 Long.class.getName(), "java.lang.Integer", "java.lang.Integer",
1271 "com.liferay.portal.kernel.util.OrderByComparator"
1272 });
1273
1274
1288 public List<com.liferay.portlet.softwarecatalog.model.SCFrameworkVersion> getSCFrameworkVersions(
1289 long pk, int start, int end, OrderByComparator orderByComparator)
1290 throws SystemException {
1291 Object[] finderArgs = new Object[] {
1292 pk, String.valueOf(start), String.valueOf(end),
1293 String.valueOf(orderByComparator)
1294 };
1295
1296 List<com.liferay.portlet.softwarecatalog.model.SCFrameworkVersion> list = (List<com.liferay.portlet.softwarecatalog.model.SCFrameworkVersion>)FinderCacheUtil.getResult(FINDER_PATH_GET_SCFRAMEWORKVERSIONS,
1297 finderArgs, this);
1298
1299 if (list == null) {
1300 Session session = null;
1301
1302 try {
1303 session = openSession();
1304
1305 String sql = null;
1306
1307 if (orderByComparator != null) {
1308 sql = _SQL_GETSCFRAMEWORKVERSIONS.concat(ORDER_BY_CLAUSE)
1309 .concat(orderByComparator.getOrderBy());
1310 }
1311 else {
1312 sql = _SQL_GETSCFRAMEWORKVERSIONS.concat(com.liferay.portlet.softwarecatalog.model.impl.SCFrameworkVersionModelImpl.ORDER_BY_SQL);
1313 }
1314
1315 SQLQuery q = session.createSQLQuery(sql);
1316
1317 q.addEntity("SCFrameworkVersion",
1318 com.liferay.portlet.softwarecatalog.model.impl.SCFrameworkVersionImpl.class);
1319
1320 QueryPos qPos = QueryPos.getInstance(q);
1321
1322 qPos.add(pk);
1323
1324 list = (List<com.liferay.portlet.softwarecatalog.model.SCFrameworkVersion>)QueryUtil.list(q,
1325 getDialect(), start, end);
1326 }
1327 catch (Exception e) {
1328 throw processException(e);
1329 }
1330 finally {
1331 if (list == null) {
1332 list = new ArrayList<com.liferay.portlet.softwarecatalog.model.SCFrameworkVersion>();
1333 }
1334
1335 scFrameworkVersionPersistence.cacheResult(list);
1336
1337 FinderCacheUtil.putResult(FINDER_PATH_GET_SCFRAMEWORKVERSIONS,
1338 finderArgs, list);
1339
1340 closeSession(session);
1341 }
1342 }
1343
1344 return list;
1345 }
1346
1347 public static final FinderPath FINDER_PATH_GET_SCFRAMEWORKVERSIONS_SIZE = new FinderPath(com.liferay.portlet.softwarecatalog.model.impl.SCFrameworkVersionModelImpl.ENTITY_CACHE_ENABLED,
1348 SCProductVersionModelImpl.FINDER_CACHE_ENABLED_SCFRAMEWORKVERSI_SCPRODUCTVERS,
1349 SCProductVersionModelImpl.MAPPING_TABLE_SCFRAMEWORKVERSI_SCPRODUCTVERS_NAME,
1350 "getSCFrameworkVersionsSize", new String[] { Long.class.getName() });
1351
1352
1359 public int getSCFrameworkVersionsSize(long pk) throws SystemException {
1360 Object[] finderArgs = new Object[] { pk };
1361
1362 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_GET_SCFRAMEWORKVERSIONS_SIZE,
1363 finderArgs, this);
1364
1365 if (count == null) {
1366 Session session = null;
1367
1368 try {
1369 session = openSession();
1370
1371 SQLQuery q = session.createSQLQuery(_SQL_GETSCFRAMEWORKVERSIONSSIZE);
1372
1373 q.addScalar(COUNT_COLUMN_NAME,
1374 com.liferay.portal.kernel.dao.orm.Type.LONG);
1375
1376 QueryPos qPos = QueryPos.getInstance(q);
1377
1378 qPos.add(pk);
1379
1380 count = (Long)q.uniqueResult();
1381 }
1382 catch (Exception e) {
1383 throw processException(e);
1384 }
1385 finally {
1386 if (count == null) {
1387 count = Long.valueOf(0);
1388 }
1389
1390 FinderCacheUtil.putResult(FINDER_PATH_GET_SCFRAMEWORKVERSIONS_SIZE,
1391 finderArgs, count);
1392
1393 closeSession(session);
1394 }
1395 }
1396
1397 return count.intValue();
1398 }
1399
1400 public static final FinderPath FINDER_PATH_CONTAINS_SCFRAMEWORKVERSION = new FinderPath(com.liferay.portlet.softwarecatalog.model.impl.SCFrameworkVersionModelImpl.ENTITY_CACHE_ENABLED,
1401 SCProductVersionModelImpl.FINDER_CACHE_ENABLED_SCFRAMEWORKVERSI_SCPRODUCTVERS,
1402 SCProductVersionModelImpl.MAPPING_TABLE_SCFRAMEWORKVERSI_SCPRODUCTVERS_NAME,
1403 "containsSCFrameworkVersion",
1404 new String[] { Long.class.getName(), Long.class.getName() });
1405
1406
1414 public boolean containsSCFrameworkVersion(long pk, long scFrameworkVersionPK)
1415 throws SystemException {
1416 Object[] finderArgs = new Object[] { pk, scFrameworkVersionPK };
1417
1418 Boolean value = (Boolean)FinderCacheUtil.getResult(FINDER_PATH_CONTAINS_SCFRAMEWORKVERSION,
1419 finderArgs, this);
1420
1421 if (value == null) {
1422 try {
1423 value = Boolean.valueOf(containsSCFrameworkVersion.contains(
1424 pk, scFrameworkVersionPK));
1425 }
1426 catch (Exception e) {
1427 throw processException(e);
1428 }
1429 finally {
1430 if (value == null) {
1431 value = Boolean.FALSE;
1432 }
1433
1434 FinderCacheUtil.putResult(FINDER_PATH_CONTAINS_SCFRAMEWORKVERSION,
1435 finderArgs, value);
1436 }
1437 }
1438
1439 return value.booleanValue();
1440 }
1441
1442
1449 public boolean containsSCFrameworkVersions(long pk)
1450 throws SystemException {
1451 if (getSCFrameworkVersionsSize(pk) > 0) {
1452 return true;
1453 }
1454 else {
1455 return false;
1456 }
1457 }
1458
1459
1466 public void addSCFrameworkVersion(long pk, long scFrameworkVersionPK)
1467 throws SystemException {
1468 try {
1469 addSCFrameworkVersion.add(pk, scFrameworkVersionPK);
1470 }
1471 catch (Exception e) {
1472 throw processException(e);
1473 }
1474 finally {
1475 FinderCacheUtil.clearCache(SCProductVersionModelImpl.MAPPING_TABLE_SCFRAMEWORKVERSI_SCPRODUCTVERS_NAME);
1476 }
1477 }
1478
1479
1486 public void addSCFrameworkVersion(long pk,
1487 com.liferay.portlet.softwarecatalog.model.SCFrameworkVersion scFrameworkVersion)
1488 throws SystemException {
1489 try {
1490 addSCFrameworkVersion.add(pk, scFrameworkVersion.getPrimaryKey());
1491 }
1492 catch (Exception e) {
1493 throw processException(e);
1494 }
1495 finally {
1496 FinderCacheUtil.clearCache(SCProductVersionModelImpl.MAPPING_TABLE_SCFRAMEWORKVERSI_SCPRODUCTVERS_NAME);
1497 }
1498 }
1499
1500
1507 public void addSCFrameworkVersions(long pk, long[] scFrameworkVersionPKs)
1508 throws SystemException {
1509 try {
1510 for (long scFrameworkVersionPK : scFrameworkVersionPKs) {
1511 addSCFrameworkVersion.add(pk, scFrameworkVersionPK);
1512 }
1513 }
1514 catch (Exception e) {
1515 throw processException(e);
1516 }
1517 finally {
1518 FinderCacheUtil.clearCache(SCProductVersionModelImpl.MAPPING_TABLE_SCFRAMEWORKVERSI_SCPRODUCTVERS_NAME);
1519 }
1520 }
1521
1522
1529 public void addSCFrameworkVersions(long pk,
1530 List<com.liferay.portlet.softwarecatalog.model.SCFrameworkVersion> scFrameworkVersions)
1531 throws SystemException {
1532 try {
1533 for (com.liferay.portlet.softwarecatalog.model.SCFrameworkVersion scFrameworkVersion : scFrameworkVersions) {
1534 addSCFrameworkVersion.add(pk, scFrameworkVersion.getPrimaryKey());
1535 }
1536 }
1537 catch (Exception e) {
1538 throw processException(e);
1539 }
1540 finally {
1541 FinderCacheUtil.clearCache(SCProductVersionModelImpl.MAPPING_TABLE_SCFRAMEWORKVERSI_SCPRODUCTVERS_NAME);
1542 }
1543 }
1544
1545
1551 public void clearSCFrameworkVersions(long pk) throws SystemException {
1552 try {
1553 clearSCFrameworkVersions.clear(pk);
1554 }
1555 catch (Exception e) {
1556 throw processException(e);
1557 }
1558 finally {
1559 FinderCacheUtil.clearCache(SCProductVersionModelImpl.MAPPING_TABLE_SCFRAMEWORKVERSI_SCPRODUCTVERS_NAME);
1560 }
1561 }
1562
1563
1570 public void removeSCFrameworkVersion(long pk, long scFrameworkVersionPK)
1571 throws SystemException {
1572 try {
1573 removeSCFrameworkVersion.remove(pk, scFrameworkVersionPK);
1574 }
1575 catch (Exception e) {
1576 throw processException(e);
1577 }
1578 finally {
1579 FinderCacheUtil.clearCache(SCProductVersionModelImpl.MAPPING_TABLE_SCFRAMEWORKVERSI_SCPRODUCTVERS_NAME);
1580 }
1581 }
1582
1583
1590 public void removeSCFrameworkVersion(long pk,
1591 com.liferay.portlet.softwarecatalog.model.SCFrameworkVersion scFrameworkVersion)
1592 throws SystemException {
1593 try {
1594 removeSCFrameworkVersion.remove(pk,
1595 scFrameworkVersion.getPrimaryKey());
1596 }
1597 catch (Exception e) {
1598 throw processException(e);
1599 }
1600 finally {
1601 FinderCacheUtil.clearCache(SCProductVersionModelImpl.MAPPING_TABLE_SCFRAMEWORKVERSI_SCPRODUCTVERS_NAME);
1602 }
1603 }
1604
1605
1612 public void removeSCFrameworkVersions(long pk, long[] scFrameworkVersionPKs)
1613 throws SystemException {
1614 try {
1615 for (long scFrameworkVersionPK : scFrameworkVersionPKs) {
1616 removeSCFrameworkVersion.remove(pk, scFrameworkVersionPK);
1617 }
1618 }
1619 catch (Exception e) {
1620 throw processException(e);
1621 }
1622 finally {
1623 FinderCacheUtil.clearCache(SCProductVersionModelImpl.MAPPING_TABLE_SCFRAMEWORKVERSI_SCPRODUCTVERS_NAME);
1624 }
1625 }
1626
1627
1634 public void removeSCFrameworkVersions(long pk,
1635 List<com.liferay.portlet.softwarecatalog.model.SCFrameworkVersion> scFrameworkVersions)
1636 throws SystemException {
1637 try {
1638 for (com.liferay.portlet.softwarecatalog.model.SCFrameworkVersion scFrameworkVersion : scFrameworkVersions) {
1639 removeSCFrameworkVersion.remove(pk,
1640 scFrameworkVersion.getPrimaryKey());
1641 }
1642 }
1643 catch (Exception e) {
1644 throw processException(e);
1645 }
1646 finally {
1647 FinderCacheUtil.clearCache(SCProductVersionModelImpl.MAPPING_TABLE_SCFRAMEWORKVERSI_SCPRODUCTVERS_NAME);
1648 }
1649 }
1650
1651
1658 public void setSCFrameworkVersions(long pk, long[] scFrameworkVersionPKs)
1659 throws SystemException {
1660 try {
1661 Set<Long> scFrameworkVersionPKSet = SetUtil.fromArray(scFrameworkVersionPKs);
1662
1663 List<com.liferay.portlet.softwarecatalog.model.SCFrameworkVersion> scFrameworkVersions =
1664 getSCFrameworkVersions(pk);
1665
1666 for (com.liferay.portlet.softwarecatalog.model.SCFrameworkVersion scFrameworkVersion : scFrameworkVersions) {
1667 if (!scFrameworkVersionPKSet.remove(
1668 scFrameworkVersion.getPrimaryKey())) {
1669 removeSCFrameworkVersion.remove(pk,
1670 scFrameworkVersion.getPrimaryKey());
1671 }
1672 }
1673
1674 for (Long scFrameworkVersionPK : scFrameworkVersionPKSet) {
1675 addSCFrameworkVersion.add(pk, scFrameworkVersionPK);
1676 }
1677 }
1678 catch (Exception e) {
1679 throw processException(e);
1680 }
1681 finally {
1682 FinderCacheUtil.clearCache(SCProductVersionModelImpl.MAPPING_TABLE_SCFRAMEWORKVERSI_SCPRODUCTVERS_NAME);
1683 }
1684 }
1685
1686
1693 public void setSCFrameworkVersions(long pk,
1694 List<com.liferay.portlet.softwarecatalog.model.SCFrameworkVersion> scFrameworkVersions)
1695 throws SystemException {
1696 try {
1697 long[] scFrameworkVersionPKs = new long[scFrameworkVersions.size()];
1698
1699 for (int i = 0; i < scFrameworkVersions.size(); i++) {
1700 com.liferay.portlet.softwarecatalog.model.SCFrameworkVersion scFrameworkVersion =
1701 scFrameworkVersions.get(i);
1702
1703 scFrameworkVersionPKs[i] = scFrameworkVersion.getPrimaryKey();
1704 }
1705
1706 setSCFrameworkVersions(pk, scFrameworkVersionPKs);
1707 }
1708 catch (Exception e) {
1709 throw processException(e);
1710 }
1711 finally {
1712 FinderCacheUtil.clearCache(SCProductVersionModelImpl.MAPPING_TABLE_SCFRAMEWORKVERSI_SCPRODUCTVERS_NAME);
1713 }
1714 }
1715
1716
1719 public void afterPropertiesSet() {
1720 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
1721 com.liferay.portal.util.PropsUtil.get(
1722 "value.object.listener.com.liferay.portlet.softwarecatalog.model.SCProductVersion")));
1723
1724 if (listenerClassNames.length > 0) {
1725 try {
1726 List<ModelListener<SCProductVersion>> listenersList = new ArrayList<ModelListener<SCProductVersion>>();
1727
1728 for (String listenerClassName : listenerClassNames) {
1729 listenersList.add((ModelListener<SCProductVersion>)InstanceFactory.newInstance(
1730 listenerClassName));
1731 }
1732
1733 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
1734 }
1735 catch (Exception e) {
1736 _log.error(e);
1737 }
1738 }
1739
1740 containsSCFrameworkVersion = new ContainsSCFrameworkVersion(this);
1741
1742 addSCFrameworkVersion = new AddSCFrameworkVersion(this);
1743 clearSCFrameworkVersions = new ClearSCFrameworkVersions(this);
1744 removeSCFrameworkVersion = new RemoveSCFrameworkVersion(this);
1745 }
1746
1747 public void destroy() {
1748 EntityCacheUtil.removeCache(SCProductVersionImpl.class.getName());
1749 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
1750 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST);
1751 }
1752
1753 @BeanReference(type = SCLicensePersistence.class)
1754 protected SCLicensePersistence scLicensePersistence;
1755 @BeanReference(type = SCFrameworkVersionPersistence.class)
1756 protected SCFrameworkVersionPersistence scFrameworkVersionPersistence;
1757 @BeanReference(type = SCProductEntryPersistence.class)
1758 protected SCProductEntryPersistence scProductEntryPersistence;
1759 @BeanReference(type = SCProductScreenshotPersistence.class)
1760 protected SCProductScreenshotPersistence scProductScreenshotPersistence;
1761 @BeanReference(type = SCProductVersionPersistence.class)
1762 protected SCProductVersionPersistence scProductVersionPersistence;
1763 @BeanReference(type = ResourcePersistence.class)
1764 protected ResourcePersistence resourcePersistence;
1765 @BeanReference(type = UserPersistence.class)
1766 protected UserPersistence userPersistence;
1767 protected ContainsSCFrameworkVersion containsSCFrameworkVersion;
1768 protected AddSCFrameworkVersion addSCFrameworkVersion;
1769 protected ClearSCFrameworkVersions clearSCFrameworkVersions;
1770 protected RemoveSCFrameworkVersion removeSCFrameworkVersion;
1771
1772 protected class ContainsSCFrameworkVersion {
1773 protected ContainsSCFrameworkVersion(
1774 SCProductVersionPersistenceImpl persistenceImpl) {
1775 super();
1776
1777 _mappingSqlQuery = MappingSqlQueryFactoryUtil.getMappingSqlQuery(getDataSource(),
1778 _SQL_CONTAINSSCFRAMEWORKVERSION,
1779 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT },
1780 RowMapper.COUNT);
1781 }
1782
1783 protected boolean contains(long productVersionId,
1784 long frameworkVersionId) {
1785 List<Integer> results = _mappingSqlQuery.execute(new Object[] {
1786 new Long(productVersionId), new Long(frameworkVersionId)
1787 });
1788
1789 if (results.size() > 0) {
1790 Integer count = results.get(0);
1791
1792 if (count.intValue() > 0) {
1793 return true;
1794 }
1795 }
1796
1797 return false;
1798 }
1799
1800 private MappingSqlQuery<Integer> _mappingSqlQuery;
1801 }
1802
1803 protected class AddSCFrameworkVersion {
1804 protected AddSCFrameworkVersion(
1805 SCProductVersionPersistenceImpl persistenceImpl) {
1806 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
1807 "INSERT INTO SCFrameworkVersi_SCProductVers (productVersionId, frameworkVersionId) VALUES (?, ?)",
1808 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
1809 _persistenceImpl = persistenceImpl;
1810 }
1811
1812 protected void add(long productVersionId, long frameworkVersionId)
1813 throws SystemException {
1814 if (!_persistenceImpl.containsSCFrameworkVersion.contains(
1815 productVersionId, frameworkVersionId)) {
1816 ModelListener<com.liferay.portlet.softwarecatalog.model.SCFrameworkVersion>[] scFrameworkVersionListeners =
1817 scFrameworkVersionPersistence.getListeners();
1818
1819 for (ModelListener<SCProductVersion> listener : listeners) {
1820 listener.onBeforeAddAssociation(productVersionId,
1821 com.liferay.portlet.softwarecatalog.model.SCFrameworkVersion.class.getName(),
1822 frameworkVersionId);
1823 }
1824
1825 for (ModelListener<com.liferay.portlet.softwarecatalog.model.SCFrameworkVersion> listener : scFrameworkVersionListeners) {
1826 listener.onBeforeAddAssociation(frameworkVersionId,
1827 SCProductVersion.class.getName(), productVersionId);
1828 }
1829
1830 _sqlUpdate.update(new Object[] {
1831 new Long(productVersionId), new Long(frameworkVersionId)
1832 });
1833
1834 for (ModelListener<SCProductVersion> listener : listeners) {
1835 listener.onAfterAddAssociation(productVersionId,
1836 com.liferay.portlet.softwarecatalog.model.SCFrameworkVersion.class.getName(),
1837 frameworkVersionId);
1838 }
1839
1840 for (ModelListener<com.liferay.portlet.softwarecatalog.model.SCFrameworkVersion> listener : scFrameworkVersionListeners) {
1841 listener.onAfterAddAssociation(frameworkVersionId,
1842 SCProductVersion.class.getName(), productVersionId);
1843 }
1844 }
1845 }
1846
1847 private SqlUpdate _sqlUpdate;
1848 private SCProductVersionPersistenceImpl _persistenceImpl;
1849 }
1850
1851 protected class ClearSCFrameworkVersions {
1852 protected ClearSCFrameworkVersions(
1853 SCProductVersionPersistenceImpl persistenceImpl) {
1854 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
1855 "DELETE FROM SCFrameworkVersi_SCProductVers WHERE productVersionId = ?",
1856 new int[] { java.sql.Types.BIGINT });
1857 }
1858
1859 protected void clear(long productVersionId) throws SystemException {
1860 ModelListener<com.liferay.portlet.softwarecatalog.model.SCFrameworkVersion>[] scFrameworkVersionListeners =
1861 scFrameworkVersionPersistence.getListeners();
1862
1863 List<com.liferay.portlet.softwarecatalog.model.SCFrameworkVersion> scFrameworkVersions =
1864 null;
1865
1866 if ((listeners.length > 0) ||
1867 (scFrameworkVersionListeners.length > 0)) {
1868 scFrameworkVersions = getSCFrameworkVersions(productVersionId);
1869
1870 for (com.liferay.portlet.softwarecatalog.model.SCFrameworkVersion scFrameworkVersion : scFrameworkVersions) {
1871 for (ModelListener<SCProductVersion> listener : listeners) {
1872 listener.onBeforeRemoveAssociation(productVersionId,
1873 com.liferay.portlet.softwarecatalog.model.SCFrameworkVersion.class.getName(),
1874 scFrameworkVersion.getPrimaryKey());
1875 }
1876
1877 for (ModelListener<com.liferay.portlet.softwarecatalog.model.SCFrameworkVersion> listener : scFrameworkVersionListeners) {
1878 listener.onBeforeRemoveAssociation(scFrameworkVersion.getPrimaryKey(),
1879 SCProductVersion.class.getName(), productVersionId);
1880 }
1881 }
1882 }
1883
1884 _sqlUpdate.update(new Object[] { new Long(productVersionId) });
1885
1886 if ((listeners.length > 0) ||
1887 (scFrameworkVersionListeners.length > 0)) {
1888 for (com.liferay.portlet.softwarecatalog.model.SCFrameworkVersion scFrameworkVersion : scFrameworkVersions) {
1889 for (ModelListener<SCProductVersion> listener : listeners) {
1890 listener.onAfterRemoveAssociation(productVersionId,
1891 com.liferay.portlet.softwarecatalog.model.SCFrameworkVersion.class.getName(),
1892 scFrameworkVersion.getPrimaryKey());
1893 }
1894
1895 for (ModelListener<com.liferay.portlet.softwarecatalog.model.SCFrameworkVersion> listener : scFrameworkVersionListeners) {
1896 listener.onAfterRemoveAssociation(scFrameworkVersion.getPrimaryKey(),
1897 SCProductVersion.class.getName(), productVersionId);
1898 }
1899 }
1900 }
1901 }
1902
1903 private SqlUpdate _sqlUpdate;
1904 }
1905
1906 protected class RemoveSCFrameworkVersion {
1907 protected RemoveSCFrameworkVersion(
1908 SCProductVersionPersistenceImpl persistenceImpl) {
1909 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
1910 "DELETE FROM SCFrameworkVersi_SCProductVers WHERE productVersionId = ? AND frameworkVersionId = ?",
1911 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
1912 _persistenceImpl = persistenceImpl;
1913 }
1914
1915 protected void remove(long productVersionId, long frameworkVersionId)
1916 throws SystemException {
1917 if (_persistenceImpl.containsSCFrameworkVersion.contains(
1918 productVersionId, frameworkVersionId)) {
1919 ModelListener<com.liferay.portlet.softwarecatalog.model.SCFrameworkVersion>[] scFrameworkVersionListeners =
1920 scFrameworkVersionPersistence.getListeners();
1921
1922 for (ModelListener<SCProductVersion> listener : listeners) {
1923 listener.onBeforeRemoveAssociation(productVersionId,
1924 com.liferay.portlet.softwarecatalog.model.SCFrameworkVersion.class.getName(),
1925 frameworkVersionId);
1926 }
1927
1928 for (ModelListener<com.liferay.portlet.softwarecatalog.model.SCFrameworkVersion> listener : scFrameworkVersionListeners) {
1929 listener.onBeforeRemoveAssociation(frameworkVersionId,
1930 SCProductVersion.class.getName(), productVersionId);
1931 }
1932
1933 _sqlUpdate.update(new Object[] {
1934 new Long(productVersionId), new Long(frameworkVersionId)
1935 });
1936
1937 for (ModelListener<SCProductVersion> listener : listeners) {
1938 listener.onAfterRemoveAssociation(productVersionId,
1939 com.liferay.portlet.softwarecatalog.model.SCFrameworkVersion.class.getName(),
1940 frameworkVersionId);
1941 }
1942
1943 for (ModelListener<com.liferay.portlet.softwarecatalog.model.SCFrameworkVersion> listener : scFrameworkVersionListeners) {
1944 listener.onAfterRemoveAssociation(frameworkVersionId,
1945 SCProductVersion.class.getName(), productVersionId);
1946 }
1947 }
1948 }
1949
1950 private SqlUpdate _sqlUpdate;
1951 private SCProductVersionPersistenceImpl _persistenceImpl;
1952 }
1953
1954 private static final String _SQL_SELECT_SCPRODUCTVERSION = "SELECT scProductVersion FROM SCProductVersion scProductVersion";
1955 private static final String _SQL_SELECT_SCPRODUCTVERSION_WHERE = "SELECT scProductVersion FROM SCProductVersion scProductVersion WHERE ";
1956 private static final String _SQL_COUNT_SCPRODUCTVERSION = "SELECT COUNT(scProductVersion) FROM SCProductVersion scProductVersion";
1957 private static final String _SQL_COUNT_SCPRODUCTVERSION_WHERE = "SELECT COUNT(scProductVersion) FROM SCProductVersion scProductVersion WHERE ";
1958 private static final String _SQL_GETSCFRAMEWORKVERSIONS = "SELECT {SCFrameworkVersion.*} FROM SCFrameworkVersion INNER JOIN SCFrameworkVersi_SCProductVers ON (SCFrameworkVersi_SCProductVers.frameworkVersionId = SCFrameworkVersion.frameworkVersionId) WHERE (SCFrameworkVersi_SCProductVers.productVersionId = ?)";
1959 private static final String _SQL_GETSCFRAMEWORKVERSIONSSIZE = "SELECT COUNT(*) AS COUNT_VALUE FROM SCFrameworkVersi_SCProductVers WHERE productVersionId = ?";
1960 private static final String _SQL_CONTAINSSCFRAMEWORKVERSION = "SELECT COUNT(*) AS COUNT_VALUE FROM SCFrameworkVersi_SCProductVers WHERE productVersionId = ? AND frameworkVersionId = ?";
1961 private static final String _FINDER_COLUMN_PRODUCTENTRYID_PRODUCTENTRYID_2 = "scProductVersion.productEntryId = ?";
1962 private static final String _FINDER_COLUMN_DIRECTDOWNLOADURL_DIRECTDOWNLOADURL_1 =
1963 "scProductVersion.directDownloadURL IS NULL";
1964 private static final String _FINDER_COLUMN_DIRECTDOWNLOADURL_DIRECTDOWNLOADURL_2 =
1965 "lower(scProductVersion.directDownloadURL) = lower(?)";
1966 private static final String _FINDER_COLUMN_DIRECTDOWNLOADURL_DIRECTDOWNLOADURL_3 =
1967 "(scProductVersion.directDownloadURL IS NULL OR lower(scProductVersion.directDownloadURL) = lower(?))";
1968 private static final String _ORDER_BY_ENTITY_ALIAS = "scProductVersion.";
1969 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No SCProductVersion exists with the primary key ";
1970 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No SCProductVersion exists with the key {";
1971 private static Log _log = LogFactoryUtil.getLog(SCProductVersionPersistenceImpl.class);
1972 }