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 if (scProductVersion.isCachedModel() ||
260 BatchSessionUtil.isEnabled()) {
261 Object staleObject = session.get(SCProductVersionImpl.class,
262 scProductVersion.getPrimaryKeyObj());
263
264 if (staleObject != null) {
265 session.evict(staleObject);
266 }
267 }
268
269 session.delete(scProductVersion);
270
271 session.flush();
272 }
273 catch (Exception e) {
274 throw processException(e);
275 }
276 finally {
277 closeSession(session);
278 }
279
280 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
281
282 SCProductVersionModelImpl scProductVersionModelImpl = (SCProductVersionModelImpl)scProductVersion;
283
284 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_DIRECTDOWNLOADURL,
285 new Object[] {
286 scProductVersionModelImpl.getOriginalDirectDownloadURL()
287 });
288
289 EntityCacheUtil.removeResult(SCProductVersionModelImpl.ENTITY_CACHE_ENABLED,
290 SCProductVersionImpl.class, scProductVersion.getPrimaryKey());
291
292 return scProductVersion;
293 }
294
295 public SCProductVersion updateImpl(
296 com.liferay.portlet.softwarecatalog.model.SCProductVersion scProductVersion,
297 boolean merge) throws SystemException {
298 scProductVersion = toUnwrappedModel(scProductVersion);
299
300 boolean isNew = scProductVersion.isNew();
301
302 SCProductVersionModelImpl scProductVersionModelImpl = (SCProductVersionModelImpl)scProductVersion;
303
304 Session session = null;
305
306 try {
307 session = openSession();
308
309 BatchSessionUtil.update(session, scProductVersion, merge);
310
311 scProductVersion.setNew(false);
312 }
313 catch (Exception e) {
314 throw processException(e);
315 }
316 finally {
317 closeSession(session);
318 }
319
320 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
321
322 EntityCacheUtil.putResult(SCProductVersionModelImpl.ENTITY_CACHE_ENABLED,
323 SCProductVersionImpl.class, scProductVersion.getPrimaryKey(),
324 scProductVersion);
325
326 if (!isNew &&
327 (!Validator.equals(scProductVersion.getDirectDownloadURL(),
328 scProductVersionModelImpl.getOriginalDirectDownloadURL()))) {
329 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_DIRECTDOWNLOADURL,
330 new Object[] {
331 scProductVersionModelImpl.getOriginalDirectDownloadURL()
332 });
333 }
334
335 if (isNew ||
336 (!Validator.equals(scProductVersion.getDirectDownloadURL(),
337 scProductVersionModelImpl.getOriginalDirectDownloadURL()))) {
338 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_DIRECTDOWNLOADURL,
339 new Object[] { scProductVersion.getDirectDownloadURL() },
340 scProductVersion);
341 }
342
343 return scProductVersion;
344 }
345
346 protected SCProductVersion toUnwrappedModel(
347 SCProductVersion scProductVersion) {
348 if (scProductVersion instanceof SCProductVersionImpl) {
349 return scProductVersion;
350 }
351
352 SCProductVersionImpl scProductVersionImpl = new SCProductVersionImpl();
353
354 scProductVersionImpl.setNew(scProductVersion.isNew());
355 scProductVersionImpl.setPrimaryKey(scProductVersion.getPrimaryKey());
356
357 scProductVersionImpl.setProductVersionId(scProductVersion.getProductVersionId());
358 scProductVersionImpl.setCompanyId(scProductVersion.getCompanyId());
359 scProductVersionImpl.setUserId(scProductVersion.getUserId());
360 scProductVersionImpl.setUserName(scProductVersion.getUserName());
361 scProductVersionImpl.setCreateDate(scProductVersion.getCreateDate());
362 scProductVersionImpl.setModifiedDate(scProductVersion.getModifiedDate());
363 scProductVersionImpl.setProductEntryId(scProductVersion.getProductEntryId());
364 scProductVersionImpl.setVersion(scProductVersion.getVersion());
365 scProductVersionImpl.setChangeLog(scProductVersion.getChangeLog());
366 scProductVersionImpl.setDownloadPageURL(scProductVersion.getDownloadPageURL());
367 scProductVersionImpl.setDirectDownloadURL(scProductVersion.getDirectDownloadURL());
368 scProductVersionImpl.setRepoStoreArtifact(scProductVersion.isRepoStoreArtifact());
369
370 return scProductVersionImpl;
371 }
372
373
381 public SCProductVersion findByPrimaryKey(Serializable primaryKey)
382 throws NoSuchModelException, SystemException {
383 return findByPrimaryKey(((Long)primaryKey).longValue());
384 }
385
386
394 public SCProductVersion findByPrimaryKey(long productVersionId)
395 throws NoSuchProductVersionException, SystemException {
396 SCProductVersion scProductVersion = fetchByPrimaryKey(productVersionId);
397
398 if (scProductVersion == null) {
399 if (_log.isWarnEnabled()) {
400 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + productVersionId);
401 }
402
403 throw new NoSuchProductVersionException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
404 productVersionId);
405 }
406
407 return scProductVersion;
408 }
409
410
417 public SCProductVersion fetchByPrimaryKey(Serializable primaryKey)
418 throws SystemException {
419 return fetchByPrimaryKey(((Long)primaryKey).longValue());
420 }
421
422
429 public SCProductVersion fetchByPrimaryKey(long productVersionId)
430 throws SystemException {
431 SCProductVersion scProductVersion = (SCProductVersion)EntityCacheUtil.getResult(SCProductVersionModelImpl.ENTITY_CACHE_ENABLED,
432 SCProductVersionImpl.class, productVersionId, this);
433
434 if (scProductVersion == null) {
435 Session session = null;
436
437 try {
438 session = openSession();
439
440 scProductVersion = (SCProductVersion)session.get(SCProductVersionImpl.class,
441 new Long(productVersionId));
442 }
443 catch (Exception e) {
444 throw processException(e);
445 }
446 finally {
447 if (scProductVersion != null) {
448 cacheResult(scProductVersion);
449 }
450
451 closeSession(session);
452 }
453 }
454
455 return scProductVersion;
456 }
457
458
465 public List<SCProductVersion> findByProductEntryId(long productEntryId)
466 throws SystemException {
467 return findByProductEntryId(productEntryId, QueryUtil.ALL_POS,
468 QueryUtil.ALL_POS, null);
469 }
470
471
484 public List<SCProductVersion> findByProductEntryId(long productEntryId,
485 int start, int end) throws SystemException {
486 return findByProductEntryId(productEntryId, start, end, null);
487 }
488
489
503 public List<SCProductVersion> findByProductEntryId(long productEntryId,
504 int start, int end, OrderByComparator orderByComparator)
505 throws SystemException {
506 Object[] finderArgs = new Object[] {
507 productEntryId,
508
509 String.valueOf(start), String.valueOf(end),
510 String.valueOf(orderByComparator)
511 };
512
513 List<SCProductVersion> list = (List<SCProductVersion>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_PRODUCTENTRYID,
514 finderArgs, this);
515
516 if (list == null) {
517 Session session = null;
518
519 try {
520 session = openSession();
521
522 StringBundler query = null;
523
524 if (orderByComparator != null) {
525 query = new StringBundler(3 +
526 (orderByComparator.getOrderByFields().length * 3));
527 }
528 else {
529 query = new StringBundler(3);
530 }
531
532 query.append(_SQL_SELECT_SCPRODUCTVERSION_WHERE);
533
534 query.append(_FINDER_COLUMN_PRODUCTENTRYID_PRODUCTENTRYID_2);
535
536 if (orderByComparator != null) {
537 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
538 orderByComparator);
539 }
540
541 else {
542 query.append(SCProductVersionModelImpl.ORDER_BY_JPQL);
543 }
544
545 String sql = query.toString();
546
547 Query q = session.createQuery(sql);
548
549 QueryPos qPos = QueryPos.getInstance(q);
550
551 qPos.add(productEntryId);
552
553 list = (List<SCProductVersion>)QueryUtil.list(q, getDialect(),
554 start, end);
555 }
556 catch (Exception e) {
557 throw processException(e);
558 }
559 finally {
560 if (list == null) {
561 list = new ArrayList<SCProductVersion>();
562 }
563
564 cacheResult(list);
565
566 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_PRODUCTENTRYID,
567 finderArgs, list);
568
569 closeSession(session);
570 }
571 }
572
573 return list;
574 }
575
576
589 public SCProductVersion findByProductEntryId_First(long productEntryId,
590 OrderByComparator orderByComparator)
591 throws NoSuchProductVersionException, SystemException {
592 List<SCProductVersion> list = findByProductEntryId(productEntryId, 0,
593 1, orderByComparator);
594
595 if (list.isEmpty()) {
596 StringBundler msg = new StringBundler(4);
597
598 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
599
600 msg.append("productEntryId=");
601 msg.append(productEntryId);
602
603 msg.append(StringPool.CLOSE_CURLY_BRACE);
604
605 throw new NoSuchProductVersionException(msg.toString());
606 }
607 else {
608 return list.get(0);
609 }
610 }
611
612
625 public SCProductVersion findByProductEntryId_Last(long productEntryId,
626 OrderByComparator orderByComparator)
627 throws NoSuchProductVersionException, SystemException {
628 int count = countByProductEntryId(productEntryId);
629
630 List<SCProductVersion> list = findByProductEntryId(productEntryId,
631 count - 1, count, orderByComparator);
632
633 if (list.isEmpty()) {
634 StringBundler msg = new StringBundler(4);
635
636 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
637
638 msg.append("productEntryId=");
639 msg.append(productEntryId);
640
641 msg.append(StringPool.CLOSE_CURLY_BRACE);
642
643 throw new NoSuchProductVersionException(msg.toString());
644 }
645 else {
646 return list.get(0);
647 }
648 }
649
650
664 public SCProductVersion[] findByProductEntryId_PrevAndNext(
665 long productVersionId, long productEntryId,
666 OrderByComparator orderByComparator)
667 throws NoSuchProductVersionException, SystemException {
668 SCProductVersion scProductVersion = findByPrimaryKey(productVersionId);
669
670 Session session = null;
671
672 try {
673 session = openSession();
674
675 SCProductVersion[] array = new SCProductVersionImpl[3];
676
677 array[0] = getByProductEntryId_PrevAndNext(session,
678 scProductVersion, productEntryId, orderByComparator, true);
679
680 array[1] = scProductVersion;
681
682 array[2] = getByProductEntryId_PrevAndNext(session,
683 scProductVersion, productEntryId, orderByComparator, false);
684
685 return array;
686 }
687 catch (Exception e) {
688 throw processException(e);
689 }
690 finally {
691 closeSession(session);
692 }
693 }
694
695 protected SCProductVersion getByProductEntryId_PrevAndNext(
696 Session session, SCProductVersion scProductVersion,
697 long productEntryId, OrderByComparator orderByComparator,
698 boolean previous) {
699 StringBundler query = null;
700
701 if (orderByComparator != null) {
702 query = new StringBundler(6 +
703 (orderByComparator.getOrderByFields().length * 6));
704 }
705 else {
706 query = new StringBundler(3);
707 }
708
709 query.append(_SQL_SELECT_SCPRODUCTVERSION_WHERE);
710
711 query.append(_FINDER_COLUMN_PRODUCTENTRYID_PRODUCTENTRYID_2);
712
713 if (orderByComparator != null) {
714 String[] orderByFields = orderByComparator.getOrderByFields();
715
716 if (orderByFields.length > 0) {
717 query.append(WHERE_AND);
718 }
719
720 for (int i = 0; i < orderByFields.length; i++) {
721 query.append(_ORDER_BY_ENTITY_ALIAS);
722 query.append(orderByFields[i]);
723
724 if ((i + 1) < orderByFields.length) {
725 if (orderByComparator.isAscending() ^ previous) {
726 query.append(WHERE_GREATER_THAN_HAS_NEXT);
727 }
728 else {
729 query.append(WHERE_LESSER_THAN_HAS_NEXT);
730 }
731 }
732 else {
733 if (orderByComparator.isAscending() ^ previous) {
734 query.append(WHERE_GREATER_THAN);
735 }
736 else {
737 query.append(WHERE_LESSER_THAN);
738 }
739 }
740 }
741
742 query.append(ORDER_BY_CLAUSE);
743
744 for (int i = 0; i < orderByFields.length; i++) {
745 query.append(_ORDER_BY_ENTITY_ALIAS);
746 query.append(orderByFields[i]);
747
748 if ((i + 1) < orderByFields.length) {
749 if (orderByComparator.isAscending() ^ previous) {
750 query.append(ORDER_BY_ASC_HAS_NEXT);
751 }
752 else {
753 query.append(ORDER_BY_DESC_HAS_NEXT);
754 }
755 }
756 else {
757 if (orderByComparator.isAscending() ^ previous) {
758 query.append(ORDER_BY_ASC);
759 }
760 else {
761 query.append(ORDER_BY_DESC);
762 }
763 }
764 }
765 }
766
767 else {
768 query.append(SCProductVersionModelImpl.ORDER_BY_JPQL);
769 }
770
771 String sql = query.toString();
772
773 Query q = session.createQuery(sql);
774
775 q.setFirstResult(0);
776 q.setMaxResults(2);
777
778 QueryPos qPos = QueryPos.getInstance(q);
779
780 qPos.add(productEntryId);
781
782 if (orderByComparator != null) {
783 Object[] values = orderByComparator.getOrderByValues(scProductVersion);
784
785 for (Object value : values) {
786 qPos.add(value);
787 }
788 }
789
790 List<SCProductVersion> list = q.list();
791
792 if (list.size() == 2) {
793 return list.get(1);
794 }
795 else {
796 return null;
797 }
798 }
799
800
808 public SCProductVersion findByDirectDownloadURL(String directDownloadURL)
809 throws NoSuchProductVersionException, SystemException {
810 SCProductVersion scProductVersion = fetchByDirectDownloadURL(directDownloadURL);
811
812 if (scProductVersion == null) {
813 StringBundler msg = new StringBundler(4);
814
815 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
816
817 msg.append("directDownloadURL=");
818 msg.append(directDownloadURL);
819
820 msg.append(StringPool.CLOSE_CURLY_BRACE);
821
822 if (_log.isWarnEnabled()) {
823 _log.warn(msg.toString());
824 }
825
826 throw new NoSuchProductVersionException(msg.toString());
827 }
828
829 return scProductVersion;
830 }
831
832
839 public SCProductVersion fetchByDirectDownloadURL(String directDownloadURL)
840 throws SystemException {
841 return fetchByDirectDownloadURL(directDownloadURL, true);
842 }
843
844
851 public SCProductVersion fetchByDirectDownloadURL(String directDownloadURL,
852 boolean retrieveFromCache) throws SystemException {
853 Object[] finderArgs = new Object[] { directDownloadURL };
854
855 Object result = null;
856
857 if (retrieveFromCache) {
858 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_DIRECTDOWNLOADURL,
859 finderArgs, this);
860 }
861
862 if (result == null) {
863 Session session = null;
864
865 try {
866 session = openSession();
867
868 StringBundler query = new StringBundler(3);
869
870 query.append(_SQL_SELECT_SCPRODUCTVERSION_WHERE);
871
872 if (directDownloadURL == null) {
873 query.append(_FINDER_COLUMN_DIRECTDOWNLOADURL_DIRECTDOWNLOADURL_1);
874 }
875 else {
876 if (directDownloadURL.equals(StringPool.BLANK)) {
877 query.append(_FINDER_COLUMN_DIRECTDOWNLOADURL_DIRECTDOWNLOADURL_3);
878 }
879 else {
880 query.append(_FINDER_COLUMN_DIRECTDOWNLOADURL_DIRECTDOWNLOADURL_2);
881 }
882 }
883
884 query.append(SCProductVersionModelImpl.ORDER_BY_JPQL);
885
886 String sql = query.toString();
887
888 Query q = session.createQuery(sql);
889
890 QueryPos qPos = QueryPos.getInstance(q);
891
892 if (directDownloadURL != null) {
893 qPos.add(directDownloadURL);
894 }
895
896 List<SCProductVersion> list = q.list();
897
898 result = list;
899
900 SCProductVersion scProductVersion = null;
901
902 if (list.isEmpty()) {
903 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_DIRECTDOWNLOADURL,
904 finderArgs, list);
905 }
906 else {
907 scProductVersion = list.get(0);
908
909 cacheResult(scProductVersion);
910
911 if ((scProductVersion.getDirectDownloadURL() == null) ||
912 !scProductVersion.getDirectDownloadURL()
913 .equals(directDownloadURL)) {
914 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_DIRECTDOWNLOADURL,
915 finderArgs, scProductVersion);
916 }
917 }
918
919 return scProductVersion;
920 }
921 catch (Exception e) {
922 throw processException(e);
923 }
924 finally {
925 if (result == null) {
926 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_DIRECTDOWNLOADURL,
927 finderArgs, new ArrayList<SCProductVersion>());
928 }
929
930 closeSession(session);
931 }
932 }
933 else {
934 if (result instanceof List<?>) {
935 return null;
936 }
937 else {
938 return (SCProductVersion)result;
939 }
940 }
941 }
942
943
949 public List<SCProductVersion> findAll() throws SystemException {
950 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
951 }
952
953
965 public List<SCProductVersion> findAll(int start, int end)
966 throws SystemException {
967 return findAll(start, end, null);
968 }
969
970
983 public List<SCProductVersion> findAll(int start, int end,
984 OrderByComparator orderByComparator) throws SystemException {
985 Object[] finderArgs = new Object[] {
986 String.valueOf(start), String.valueOf(end),
987 String.valueOf(orderByComparator)
988 };
989
990 List<SCProductVersion> list = (List<SCProductVersion>)FinderCacheUtil.getResult(FINDER_PATH_FIND_ALL,
991 finderArgs, this);
992
993 if (list == null) {
994 Session session = null;
995
996 try {
997 session = openSession();
998
999 StringBundler query = null;
1000 String sql = null;
1001
1002 if (orderByComparator != null) {
1003 query = new StringBundler(2 +
1004 (orderByComparator.getOrderByFields().length * 3));
1005
1006 query.append(_SQL_SELECT_SCPRODUCTVERSION);
1007
1008 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1009 orderByComparator);
1010
1011 sql = query.toString();
1012 }
1013 else {
1014 sql = _SQL_SELECT_SCPRODUCTVERSION.concat(SCProductVersionModelImpl.ORDER_BY_JPQL);
1015 }
1016
1017 Query q = session.createQuery(sql);
1018
1019 if (orderByComparator == null) {
1020 list = (List<SCProductVersion>)QueryUtil.list(q,
1021 getDialect(), start, end, false);
1022
1023 Collections.sort(list);
1024 }
1025 else {
1026 list = (List<SCProductVersion>)QueryUtil.list(q,
1027 getDialect(), start, end);
1028 }
1029 }
1030 catch (Exception e) {
1031 throw processException(e);
1032 }
1033 finally {
1034 if (list == null) {
1035 list = new ArrayList<SCProductVersion>();
1036 }
1037
1038 cacheResult(list);
1039
1040 FinderCacheUtil.putResult(FINDER_PATH_FIND_ALL, finderArgs, list);
1041
1042 closeSession(session);
1043 }
1044 }
1045
1046 return list;
1047 }
1048
1049
1055 public void removeByProductEntryId(long productEntryId)
1056 throws SystemException {
1057 for (SCProductVersion scProductVersion : findByProductEntryId(
1058 productEntryId)) {
1059 remove(scProductVersion);
1060 }
1061 }
1062
1063
1069 public void removeByDirectDownloadURL(String directDownloadURL)
1070 throws NoSuchProductVersionException, SystemException {
1071 SCProductVersion scProductVersion = findByDirectDownloadURL(directDownloadURL);
1072
1073 remove(scProductVersion);
1074 }
1075
1076
1081 public void removeAll() throws SystemException {
1082 for (SCProductVersion scProductVersion : findAll()) {
1083 remove(scProductVersion);
1084 }
1085 }
1086
1087
1094 public int countByProductEntryId(long productEntryId)
1095 throws SystemException {
1096 Object[] finderArgs = new Object[] { productEntryId };
1097
1098 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_PRODUCTENTRYID,
1099 finderArgs, this);
1100
1101 if (count == null) {
1102 Session session = null;
1103
1104 try {
1105 session = openSession();
1106
1107 StringBundler query = new StringBundler(2);
1108
1109 query.append(_SQL_COUNT_SCPRODUCTVERSION_WHERE);
1110
1111 query.append(_FINDER_COLUMN_PRODUCTENTRYID_PRODUCTENTRYID_2);
1112
1113 String sql = query.toString();
1114
1115 Query q = session.createQuery(sql);
1116
1117 QueryPos qPos = QueryPos.getInstance(q);
1118
1119 qPos.add(productEntryId);
1120
1121 count = (Long)q.uniqueResult();
1122 }
1123 catch (Exception e) {
1124 throw processException(e);
1125 }
1126 finally {
1127 if (count == null) {
1128 count = Long.valueOf(0);
1129 }
1130
1131 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_PRODUCTENTRYID,
1132 finderArgs, count);
1133
1134 closeSession(session);
1135 }
1136 }
1137
1138 return count.intValue();
1139 }
1140
1141
1148 public int countByDirectDownloadURL(String directDownloadURL)
1149 throws SystemException {
1150 Object[] finderArgs = new Object[] { directDownloadURL };
1151
1152 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_DIRECTDOWNLOADURL,
1153 finderArgs, this);
1154
1155 if (count == null) {
1156 Session session = null;
1157
1158 try {
1159 session = openSession();
1160
1161 StringBundler query = new StringBundler(2);
1162
1163 query.append(_SQL_COUNT_SCPRODUCTVERSION_WHERE);
1164
1165 if (directDownloadURL == null) {
1166 query.append(_FINDER_COLUMN_DIRECTDOWNLOADURL_DIRECTDOWNLOADURL_1);
1167 }
1168 else {
1169 if (directDownloadURL.equals(StringPool.BLANK)) {
1170 query.append(_FINDER_COLUMN_DIRECTDOWNLOADURL_DIRECTDOWNLOADURL_3);
1171 }
1172 else {
1173 query.append(_FINDER_COLUMN_DIRECTDOWNLOADURL_DIRECTDOWNLOADURL_2);
1174 }
1175 }
1176
1177 String sql = query.toString();
1178
1179 Query q = session.createQuery(sql);
1180
1181 QueryPos qPos = QueryPos.getInstance(q);
1182
1183 if (directDownloadURL != null) {
1184 qPos.add(directDownloadURL);
1185 }
1186
1187 count = (Long)q.uniqueResult();
1188 }
1189 catch (Exception e) {
1190 throw processException(e);
1191 }
1192 finally {
1193 if (count == null) {
1194 count = Long.valueOf(0);
1195 }
1196
1197 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_DIRECTDOWNLOADURL,
1198 finderArgs, count);
1199
1200 closeSession(session);
1201 }
1202 }
1203
1204 return count.intValue();
1205 }
1206
1207
1213 public int countAll() throws SystemException {
1214 Object[] finderArgs = new Object[0];
1215
1216 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
1217 finderArgs, this);
1218
1219 if (count == null) {
1220 Session session = null;
1221
1222 try {
1223 session = openSession();
1224
1225 Query q = session.createQuery(_SQL_COUNT_SCPRODUCTVERSION);
1226
1227 count = (Long)q.uniqueResult();
1228 }
1229 catch (Exception e) {
1230 throw processException(e);
1231 }
1232 finally {
1233 if (count == null) {
1234 count = Long.valueOf(0);
1235 }
1236
1237 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL, finderArgs,
1238 count);
1239
1240 closeSession(session);
1241 }
1242 }
1243
1244 return count.intValue();
1245 }
1246
1247
1254 public List<com.liferay.portlet.softwarecatalog.model.SCFrameworkVersion> getSCFrameworkVersions(
1255 long pk) throws SystemException {
1256 return getSCFrameworkVersions(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
1257 }
1258
1259
1272 public List<com.liferay.portlet.softwarecatalog.model.SCFrameworkVersion> getSCFrameworkVersions(
1273 long pk, int start, int end) throws SystemException {
1274 return getSCFrameworkVersions(pk, start, end, null);
1275 }
1276
1277 public static final FinderPath FINDER_PATH_GET_SCFRAMEWORKVERSIONS = new FinderPath(com.liferay.portlet.softwarecatalog.model.impl.SCFrameworkVersionModelImpl.ENTITY_CACHE_ENABLED,
1278 SCProductVersionModelImpl.FINDER_CACHE_ENABLED_SCFRAMEWORKVERSI_SCPRODUCTVERS,
1279 SCProductVersionModelImpl.MAPPING_TABLE_SCFRAMEWORKVERSI_SCPRODUCTVERS_NAME,
1280 "getSCFrameworkVersions",
1281 new String[] {
1282 Long.class.getName(), "java.lang.Integer", "java.lang.Integer",
1283 "com.liferay.portal.kernel.util.OrderByComparator"
1284 });
1285
1286
1300 public List<com.liferay.portlet.softwarecatalog.model.SCFrameworkVersion> getSCFrameworkVersions(
1301 long pk, int start, int end, OrderByComparator orderByComparator)
1302 throws SystemException {
1303 Object[] finderArgs = new Object[] {
1304 pk, String.valueOf(start), String.valueOf(end),
1305 String.valueOf(orderByComparator)
1306 };
1307
1308 List<com.liferay.portlet.softwarecatalog.model.SCFrameworkVersion> list = (List<com.liferay.portlet.softwarecatalog.model.SCFrameworkVersion>)FinderCacheUtil.getResult(FINDER_PATH_GET_SCFRAMEWORKVERSIONS,
1309 finderArgs, this);
1310
1311 if (list == null) {
1312 Session session = null;
1313
1314 try {
1315 session = openSession();
1316
1317 String sql = null;
1318
1319 if (orderByComparator != null) {
1320 sql = _SQL_GETSCFRAMEWORKVERSIONS.concat(ORDER_BY_CLAUSE)
1321 .concat(orderByComparator.getOrderBy());
1322 }
1323 else {
1324 sql = _SQL_GETSCFRAMEWORKVERSIONS.concat(com.liferay.portlet.softwarecatalog.model.impl.SCFrameworkVersionModelImpl.ORDER_BY_SQL);
1325 }
1326
1327 SQLQuery q = session.createSQLQuery(sql);
1328
1329 q.addEntity("SCFrameworkVersion",
1330 com.liferay.portlet.softwarecatalog.model.impl.SCFrameworkVersionImpl.class);
1331
1332 QueryPos qPos = QueryPos.getInstance(q);
1333
1334 qPos.add(pk);
1335
1336 list = (List<com.liferay.portlet.softwarecatalog.model.SCFrameworkVersion>)QueryUtil.list(q,
1337 getDialect(), start, end);
1338 }
1339 catch (Exception e) {
1340 throw processException(e);
1341 }
1342 finally {
1343 if (list == null) {
1344 list = new ArrayList<com.liferay.portlet.softwarecatalog.model.SCFrameworkVersion>();
1345 }
1346
1347 scFrameworkVersionPersistence.cacheResult(list);
1348
1349 FinderCacheUtil.putResult(FINDER_PATH_GET_SCFRAMEWORKVERSIONS,
1350 finderArgs, list);
1351
1352 closeSession(session);
1353 }
1354 }
1355
1356 return list;
1357 }
1358
1359 public static final FinderPath FINDER_PATH_GET_SCFRAMEWORKVERSIONS_SIZE = new FinderPath(com.liferay.portlet.softwarecatalog.model.impl.SCFrameworkVersionModelImpl.ENTITY_CACHE_ENABLED,
1360 SCProductVersionModelImpl.FINDER_CACHE_ENABLED_SCFRAMEWORKVERSI_SCPRODUCTVERS,
1361 SCProductVersionModelImpl.MAPPING_TABLE_SCFRAMEWORKVERSI_SCPRODUCTVERS_NAME,
1362 "getSCFrameworkVersionsSize", new String[] { Long.class.getName() });
1363
1364
1371 public int getSCFrameworkVersionsSize(long pk) throws SystemException {
1372 Object[] finderArgs = new Object[] { pk };
1373
1374 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_GET_SCFRAMEWORKVERSIONS_SIZE,
1375 finderArgs, this);
1376
1377 if (count == null) {
1378 Session session = null;
1379
1380 try {
1381 session = openSession();
1382
1383 SQLQuery q = session.createSQLQuery(_SQL_GETSCFRAMEWORKVERSIONSSIZE);
1384
1385 q.addScalar(COUNT_COLUMN_NAME,
1386 com.liferay.portal.kernel.dao.orm.Type.LONG);
1387
1388 QueryPos qPos = QueryPos.getInstance(q);
1389
1390 qPos.add(pk);
1391
1392 count = (Long)q.uniqueResult();
1393 }
1394 catch (Exception e) {
1395 throw processException(e);
1396 }
1397 finally {
1398 if (count == null) {
1399 count = Long.valueOf(0);
1400 }
1401
1402 FinderCacheUtil.putResult(FINDER_PATH_GET_SCFRAMEWORKVERSIONS_SIZE,
1403 finderArgs, count);
1404
1405 closeSession(session);
1406 }
1407 }
1408
1409 return count.intValue();
1410 }
1411
1412 public static final FinderPath FINDER_PATH_CONTAINS_SCFRAMEWORKVERSION = new FinderPath(com.liferay.portlet.softwarecatalog.model.impl.SCFrameworkVersionModelImpl.ENTITY_CACHE_ENABLED,
1413 SCProductVersionModelImpl.FINDER_CACHE_ENABLED_SCFRAMEWORKVERSI_SCPRODUCTVERS,
1414 SCProductVersionModelImpl.MAPPING_TABLE_SCFRAMEWORKVERSI_SCPRODUCTVERS_NAME,
1415 "containsSCFrameworkVersion",
1416 new String[] { Long.class.getName(), Long.class.getName() });
1417
1418
1426 public boolean containsSCFrameworkVersion(long pk, long scFrameworkVersionPK)
1427 throws SystemException {
1428 Object[] finderArgs = new Object[] { pk, scFrameworkVersionPK };
1429
1430 Boolean value = (Boolean)FinderCacheUtil.getResult(FINDER_PATH_CONTAINS_SCFRAMEWORKVERSION,
1431 finderArgs, this);
1432
1433 if (value == null) {
1434 try {
1435 value = Boolean.valueOf(containsSCFrameworkVersion.contains(
1436 pk, scFrameworkVersionPK));
1437 }
1438 catch (Exception e) {
1439 throw processException(e);
1440 }
1441 finally {
1442 if (value == null) {
1443 value = Boolean.FALSE;
1444 }
1445
1446 FinderCacheUtil.putResult(FINDER_PATH_CONTAINS_SCFRAMEWORKVERSION,
1447 finderArgs, value);
1448 }
1449 }
1450
1451 return value.booleanValue();
1452 }
1453
1454
1461 public boolean containsSCFrameworkVersions(long pk)
1462 throws SystemException {
1463 if (getSCFrameworkVersionsSize(pk) > 0) {
1464 return true;
1465 }
1466 else {
1467 return false;
1468 }
1469 }
1470
1471
1478 public void addSCFrameworkVersion(long pk, long scFrameworkVersionPK)
1479 throws SystemException {
1480 try {
1481 addSCFrameworkVersion.add(pk, scFrameworkVersionPK);
1482 }
1483 catch (Exception e) {
1484 throw processException(e);
1485 }
1486 finally {
1487 FinderCacheUtil.clearCache(SCProductVersionModelImpl.MAPPING_TABLE_SCFRAMEWORKVERSI_SCPRODUCTVERS_NAME);
1488 }
1489 }
1490
1491
1498 public void addSCFrameworkVersion(long pk,
1499 com.liferay.portlet.softwarecatalog.model.SCFrameworkVersion scFrameworkVersion)
1500 throws SystemException {
1501 try {
1502 addSCFrameworkVersion.add(pk, scFrameworkVersion.getPrimaryKey());
1503 }
1504 catch (Exception e) {
1505 throw processException(e);
1506 }
1507 finally {
1508 FinderCacheUtil.clearCache(SCProductVersionModelImpl.MAPPING_TABLE_SCFRAMEWORKVERSI_SCPRODUCTVERS_NAME);
1509 }
1510 }
1511
1512
1519 public void addSCFrameworkVersions(long pk, long[] scFrameworkVersionPKs)
1520 throws SystemException {
1521 try {
1522 for (long scFrameworkVersionPK : scFrameworkVersionPKs) {
1523 addSCFrameworkVersion.add(pk, scFrameworkVersionPK);
1524 }
1525 }
1526 catch (Exception e) {
1527 throw processException(e);
1528 }
1529 finally {
1530 FinderCacheUtil.clearCache(SCProductVersionModelImpl.MAPPING_TABLE_SCFRAMEWORKVERSI_SCPRODUCTVERS_NAME);
1531 }
1532 }
1533
1534
1541 public void addSCFrameworkVersions(long pk,
1542 List<com.liferay.portlet.softwarecatalog.model.SCFrameworkVersion> scFrameworkVersions)
1543 throws SystemException {
1544 try {
1545 for (com.liferay.portlet.softwarecatalog.model.SCFrameworkVersion scFrameworkVersion : scFrameworkVersions) {
1546 addSCFrameworkVersion.add(pk, scFrameworkVersion.getPrimaryKey());
1547 }
1548 }
1549 catch (Exception e) {
1550 throw processException(e);
1551 }
1552 finally {
1553 FinderCacheUtil.clearCache(SCProductVersionModelImpl.MAPPING_TABLE_SCFRAMEWORKVERSI_SCPRODUCTVERS_NAME);
1554 }
1555 }
1556
1557
1563 public void clearSCFrameworkVersions(long pk) throws SystemException {
1564 try {
1565 clearSCFrameworkVersions.clear(pk);
1566 }
1567 catch (Exception e) {
1568 throw processException(e);
1569 }
1570 finally {
1571 FinderCacheUtil.clearCache(SCProductVersionModelImpl.MAPPING_TABLE_SCFRAMEWORKVERSI_SCPRODUCTVERS_NAME);
1572 }
1573 }
1574
1575
1582 public void removeSCFrameworkVersion(long pk, long scFrameworkVersionPK)
1583 throws SystemException {
1584 try {
1585 removeSCFrameworkVersion.remove(pk, scFrameworkVersionPK);
1586 }
1587 catch (Exception e) {
1588 throw processException(e);
1589 }
1590 finally {
1591 FinderCacheUtil.clearCache(SCProductVersionModelImpl.MAPPING_TABLE_SCFRAMEWORKVERSI_SCPRODUCTVERS_NAME);
1592 }
1593 }
1594
1595
1602 public void removeSCFrameworkVersion(long pk,
1603 com.liferay.portlet.softwarecatalog.model.SCFrameworkVersion scFrameworkVersion)
1604 throws SystemException {
1605 try {
1606 removeSCFrameworkVersion.remove(pk,
1607 scFrameworkVersion.getPrimaryKey());
1608 }
1609 catch (Exception e) {
1610 throw processException(e);
1611 }
1612 finally {
1613 FinderCacheUtil.clearCache(SCProductVersionModelImpl.MAPPING_TABLE_SCFRAMEWORKVERSI_SCPRODUCTVERS_NAME);
1614 }
1615 }
1616
1617
1624 public void removeSCFrameworkVersions(long pk, long[] scFrameworkVersionPKs)
1625 throws SystemException {
1626 try {
1627 for (long scFrameworkVersionPK : scFrameworkVersionPKs) {
1628 removeSCFrameworkVersion.remove(pk, scFrameworkVersionPK);
1629 }
1630 }
1631 catch (Exception e) {
1632 throw processException(e);
1633 }
1634 finally {
1635 FinderCacheUtil.clearCache(SCProductVersionModelImpl.MAPPING_TABLE_SCFRAMEWORKVERSI_SCPRODUCTVERS_NAME);
1636 }
1637 }
1638
1639
1646 public void removeSCFrameworkVersions(long pk,
1647 List<com.liferay.portlet.softwarecatalog.model.SCFrameworkVersion> scFrameworkVersions)
1648 throws SystemException {
1649 try {
1650 for (com.liferay.portlet.softwarecatalog.model.SCFrameworkVersion scFrameworkVersion : scFrameworkVersions) {
1651 removeSCFrameworkVersion.remove(pk,
1652 scFrameworkVersion.getPrimaryKey());
1653 }
1654 }
1655 catch (Exception e) {
1656 throw processException(e);
1657 }
1658 finally {
1659 FinderCacheUtil.clearCache(SCProductVersionModelImpl.MAPPING_TABLE_SCFRAMEWORKVERSI_SCPRODUCTVERS_NAME);
1660 }
1661 }
1662
1663
1670 public void setSCFrameworkVersions(long pk, long[] scFrameworkVersionPKs)
1671 throws SystemException {
1672 try {
1673 Set<Long> scFrameworkVersionPKSet = SetUtil.fromArray(scFrameworkVersionPKs);
1674
1675 List<com.liferay.portlet.softwarecatalog.model.SCFrameworkVersion> scFrameworkVersions =
1676 getSCFrameworkVersions(pk);
1677
1678 for (com.liferay.portlet.softwarecatalog.model.SCFrameworkVersion scFrameworkVersion : scFrameworkVersions) {
1679 if (!scFrameworkVersionPKSet.remove(
1680 scFrameworkVersion.getPrimaryKey())) {
1681 removeSCFrameworkVersion.remove(pk,
1682 scFrameworkVersion.getPrimaryKey());
1683 }
1684 }
1685
1686 for (Long scFrameworkVersionPK : scFrameworkVersionPKSet) {
1687 addSCFrameworkVersion.add(pk, scFrameworkVersionPK);
1688 }
1689 }
1690 catch (Exception e) {
1691 throw processException(e);
1692 }
1693 finally {
1694 FinderCacheUtil.clearCache(SCProductVersionModelImpl.MAPPING_TABLE_SCFRAMEWORKVERSI_SCPRODUCTVERS_NAME);
1695 }
1696 }
1697
1698
1705 public void setSCFrameworkVersions(long pk,
1706 List<com.liferay.portlet.softwarecatalog.model.SCFrameworkVersion> scFrameworkVersions)
1707 throws SystemException {
1708 try {
1709 long[] scFrameworkVersionPKs = new long[scFrameworkVersions.size()];
1710
1711 for (int i = 0; i < scFrameworkVersions.size(); i++) {
1712 com.liferay.portlet.softwarecatalog.model.SCFrameworkVersion scFrameworkVersion =
1713 scFrameworkVersions.get(i);
1714
1715 scFrameworkVersionPKs[i] = scFrameworkVersion.getPrimaryKey();
1716 }
1717
1718 setSCFrameworkVersions(pk, scFrameworkVersionPKs);
1719 }
1720 catch (Exception e) {
1721 throw processException(e);
1722 }
1723 finally {
1724 FinderCacheUtil.clearCache(SCProductVersionModelImpl.MAPPING_TABLE_SCFRAMEWORKVERSI_SCPRODUCTVERS_NAME);
1725 }
1726 }
1727
1728
1731 public void afterPropertiesSet() {
1732 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
1733 com.liferay.portal.util.PropsUtil.get(
1734 "value.object.listener.com.liferay.portlet.softwarecatalog.model.SCProductVersion")));
1735
1736 if (listenerClassNames.length > 0) {
1737 try {
1738 List<ModelListener<SCProductVersion>> listenersList = new ArrayList<ModelListener<SCProductVersion>>();
1739
1740 for (String listenerClassName : listenerClassNames) {
1741 listenersList.add((ModelListener<SCProductVersion>)InstanceFactory.newInstance(
1742 listenerClassName));
1743 }
1744
1745 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
1746 }
1747 catch (Exception e) {
1748 _log.error(e);
1749 }
1750 }
1751
1752 containsSCFrameworkVersion = new ContainsSCFrameworkVersion(this);
1753
1754 addSCFrameworkVersion = new AddSCFrameworkVersion(this);
1755 clearSCFrameworkVersions = new ClearSCFrameworkVersions(this);
1756 removeSCFrameworkVersion = new RemoveSCFrameworkVersion(this);
1757 }
1758
1759 @BeanReference(type = SCLicensePersistence.class)
1760 protected SCLicensePersistence scLicensePersistence;
1761 @BeanReference(type = SCFrameworkVersionPersistence.class)
1762 protected SCFrameworkVersionPersistence scFrameworkVersionPersistence;
1763 @BeanReference(type = SCProductEntryPersistence.class)
1764 protected SCProductEntryPersistence scProductEntryPersistence;
1765 @BeanReference(type = SCProductScreenshotPersistence.class)
1766 protected SCProductScreenshotPersistence scProductScreenshotPersistence;
1767 @BeanReference(type = SCProductVersionPersistence.class)
1768 protected SCProductVersionPersistence scProductVersionPersistence;
1769 @BeanReference(type = ResourcePersistence.class)
1770 protected ResourcePersistence resourcePersistence;
1771 @BeanReference(type = UserPersistence.class)
1772 protected UserPersistence userPersistence;
1773 protected ContainsSCFrameworkVersion containsSCFrameworkVersion;
1774 protected AddSCFrameworkVersion addSCFrameworkVersion;
1775 protected ClearSCFrameworkVersions clearSCFrameworkVersions;
1776 protected RemoveSCFrameworkVersion removeSCFrameworkVersion;
1777
1778 protected class ContainsSCFrameworkVersion {
1779 protected ContainsSCFrameworkVersion(
1780 SCProductVersionPersistenceImpl persistenceImpl) {
1781 super();
1782
1783 _mappingSqlQuery = MappingSqlQueryFactoryUtil.getMappingSqlQuery(getDataSource(),
1784 _SQL_CONTAINSSCFRAMEWORKVERSION,
1785 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT },
1786 RowMapper.COUNT);
1787 }
1788
1789 protected boolean contains(long productVersionId,
1790 long frameworkVersionId) {
1791 List<Integer> results = _mappingSqlQuery.execute(new Object[] {
1792 new Long(productVersionId), new Long(frameworkVersionId)
1793 });
1794
1795 if (results.size() > 0) {
1796 Integer count = results.get(0);
1797
1798 if (count.intValue() > 0) {
1799 return true;
1800 }
1801 }
1802
1803 return false;
1804 }
1805
1806 private MappingSqlQuery<Integer> _mappingSqlQuery;
1807 }
1808
1809 protected class AddSCFrameworkVersion {
1810 protected AddSCFrameworkVersion(
1811 SCProductVersionPersistenceImpl persistenceImpl) {
1812 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
1813 "INSERT INTO SCFrameworkVersi_SCProductVers (productVersionId, frameworkVersionId) VALUES (?, ?)",
1814 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
1815 _persistenceImpl = persistenceImpl;
1816 }
1817
1818 protected void add(long productVersionId, long frameworkVersionId)
1819 throws SystemException {
1820 if (!_persistenceImpl.containsSCFrameworkVersion.contains(
1821 productVersionId, frameworkVersionId)) {
1822 ModelListener<com.liferay.portlet.softwarecatalog.model.SCFrameworkVersion>[] scFrameworkVersionListeners =
1823 scFrameworkVersionPersistence.getListeners();
1824
1825 for (ModelListener<SCProductVersion> listener : listeners) {
1826 listener.onBeforeAddAssociation(productVersionId,
1827 com.liferay.portlet.softwarecatalog.model.SCFrameworkVersion.class.getName(),
1828 frameworkVersionId);
1829 }
1830
1831 for (ModelListener<com.liferay.portlet.softwarecatalog.model.SCFrameworkVersion> listener : scFrameworkVersionListeners) {
1832 listener.onBeforeAddAssociation(frameworkVersionId,
1833 SCProductVersion.class.getName(), productVersionId);
1834 }
1835
1836 _sqlUpdate.update(new Object[] {
1837 new Long(productVersionId), new Long(frameworkVersionId)
1838 });
1839
1840 for (ModelListener<SCProductVersion> listener : listeners) {
1841 listener.onAfterAddAssociation(productVersionId,
1842 com.liferay.portlet.softwarecatalog.model.SCFrameworkVersion.class.getName(),
1843 frameworkVersionId);
1844 }
1845
1846 for (ModelListener<com.liferay.portlet.softwarecatalog.model.SCFrameworkVersion> listener : scFrameworkVersionListeners) {
1847 listener.onAfterAddAssociation(frameworkVersionId,
1848 SCProductVersion.class.getName(), productVersionId);
1849 }
1850 }
1851 }
1852
1853 private SqlUpdate _sqlUpdate;
1854 private SCProductVersionPersistenceImpl _persistenceImpl;
1855 }
1856
1857 protected class ClearSCFrameworkVersions {
1858 protected ClearSCFrameworkVersions(
1859 SCProductVersionPersistenceImpl persistenceImpl) {
1860 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
1861 "DELETE FROM SCFrameworkVersi_SCProductVers WHERE productVersionId = ?",
1862 new int[] { java.sql.Types.BIGINT });
1863 }
1864
1865 protected void clear(long productVersionId) throws SystemException {
1866 ModelListener<com.liferay.portlet.softwarecatalog.model.SCFrameworkVersion>[] scFrameworkVersionListeners =
1867 scFrameworkVersionPersistence.getListeners();
1868
1869 List<com.liferay.portlet.softwarecatalog.model.SCFrameworkVersion> scFrameworkVersions =
1870 null;
1871
1872 if ((listeners.length > 0) ||
1873 (scFrameworkVersionListeners.length > 0)) {
1874 scFrameworkVersions = getSCFrameworkVersions(productVersionId);
1875
1876 for (com.liferay.portlet.softwarecatalog.model.SCFrameworkVersion scFrameworkVersion : scFrameworkVersions) {
1877 for (ModelListener<SCProductVersion> listener : listeners) {
1878 listener.onBeforeRemoveAssociation(productVersionId,
1879 com.liferay.portlet.softwarecatalog.model.SCFrameworkVersion.class.getName(),
1880 scFrameworkVersion.getPrimaryKey());
1881 }
1882
1883 for (ModelListener<com.liferay.portlet.softwarecatalog.model.SCFrameworkVersion> listener : scFrameworkVersionListeners) {
1884 listener.onBeforeRemoveAssociation(scFrameworkVersion.getPrimaryKey(),
1885 SCProductVersion.class.getName(), productVersionId);
1886 }
1887 }
1888 }
1889
1890 _sqlUpdate.update(new Object[] { new Long(productVersionId) });
1891
1892 if ((listeners.length > 0) ||
1893 (scFrameworkVersionListeners.length > 0)) {
1894 for (com.liferay.portlet.softwarecatalog.model.SCFrameworkVersion scFrameworkVersion : scFrameworkVersions) {
1895 for (ModelListener<SCProductVersion> listener : listeners) {
1896 listener.onAfterRemoveAssociation(productVersionId,
1897 com.liferay.portlet.softwarecatalog.model.SCFrameworkVersion.class.getName(),
1898 scFrameworkVersion.getPrimaryKey());
1899 }
1900
1901 for (ModelListener<com.liferay.portlet.softwarecatalog.model.SCFrameworkVersion> listener : scFrameworkVersionListeners) {
1902 listener.onAfterRemoveAssociation(scFrameworkVersion.getPrimaryKey(),
1903 SCProductVersion.class.getName(), productVersionId);
1904 }
1905 }
1906 }
1907 }
1908
1909 private SqlUpdate _sqlUpdate;
1910 }
1911
1912 protected class RemoveSCFrameworkVersion {
1913 protected RemoveSCFrameworkVersion(
1914 SCProductVersionPersistenceImpl persistenceImpl) {
1915 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
1916 "DELETE FROM SCFrameworkVersi_SCProductVers WHERE productVersionId = ? AND frameworkVersionId = ?",
1917 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
1918 _persistenceImpl = persistenceImpl;
1919 }
1920
1921 protected void remove(long productVersionId, long frameworkVersionId)
1922 throws SystemException {
1923 if (_persistenceImpl.containsSCFrameworkVersion.contains(
1924 productVersionId, frameworkVersionId)) {
1925 ModelListener<com.liferay.portlet.softwarecatalog.model.SCFrameworkVersion>[] scFrameworkVersionListeners =
1926 scFrameworkVersionPersistence.getListeners();
1927
1928 for (ModelListener<SCProductVersion> listener : listeners) {
1929 listener.onBeforeRemoveAssociation(productVersionId,
1930 com.liferay.portlet.softwarecatalog.model.SCFrameworkVersion.class.getName(),
1931 frameworkVersionId);
1932 }
1933
1934 for (ModelListener<com.liferay.portlet.softwarecatalog.model.SCFrameworkVersion> listener : scFrameworkVersionListeners) {
1935 listener.onBeforeRemoveAssociation(frameworkVersionId,
1936 SCProductVersion.class.getName(), productVersionId);
1937 }
1938
1939 _sqlUpdate.update(new Object[] {
1940 new Long(productVersionId), new Long(frameworkVersionId)
1941 });
1942
1943 for (ModelListener<SCProductVersion> listener : listeners) {
1944 listener.onAfterRemoveAssociation(productVersionId,
1945 com.liferay.portlet.softwarecatalog.model.SCFrameworkVersion.class.getName(),
1946 frameworkVersionId);
1947 }
1948
1949 for (ModelListener<com.liferay.portlet.softwarecatalog.model.SCFrameworkVersion> listener : scFrameworkVersionListeners) {
1950 listener.onAfterRemoveAssociation(frameworkVersionId,
1951 SCProductVersion.class.getName(), productVersionId);
1952 }
1953 }
1954 }
1955
1956 private SqlUpdate _sqlUpdate;
1957 private SCProductVersionPersistenceImpl _persistenceImpl;
1958 }
1959
1960 private static final String _SQL_SELECT_SCPRODUCTVERSION = "SELECT scProductVersion FROM SCProductVersion scProductVersion";
1961 private static final String _SQL_SELECT_SCPRODUCTVERSION_WHERE = "SELECT scProductVersion FROM SCProductVersion scProductVersion WHERE ";
1962 private static final String _SQL_COUNT_SCPRODUCTVERSION = "SELECT COUNT(scProductVersion) FROM SCProductVersion scProductVersion";
1963 private static final String _SQL_COUNT_SCPRODUCTVERSION_WHERE = "SELECT COUNT(scProductVersion) FROM SCProductVersion scProductVersion WHERE ";
1964 private static final String _SQL_GETSCFRAMEWORKVERSIONS = "SELECT {SCFrameworkVersion.*} FROM SCFrameworkVersion INNER JOIN SCFrameworkVersi_SCProductVers ON (SCFrameworkVersi_SCProductVers.frameworkVersionId = SCFrameworkVersion.frameworkVersionId) WHERE (SCFrameworkVersi_SCProductVers.productVersionId = ?)";
1965 private static final String _SQL_GETSCFRAMEWORKVERSIONSSIZE = "SELECT COUNT(*) AS COUNT_VALUE FROM SCFrameworkVersi_SCProductVers WHERE productVersionId = ?";
1966 private static final String _SQL_CONTAINSSCFRAMEWORKVERSION = "SELECT COUNT(*) AS COUNT_VALUE FROM SCFrameworkVersi_SCProductVers WHERE productVersionId = ? AND frameworkVersionId = ?";
1967 private static final String _FINDER_COLUMN_PRODUCTENTRYID_PRODUCTENTRYID_2 = "scProductVersion.productEntryId = ?";
1968 private static final String _FINDER_COLUMN_DIRECTDOWNLOADURL_DIRECTDOWNLOADURL_1 =
1969 "scProductVersion.directDownloadURL IS NULL";
1970 private static final String _FINDER_COLUMN_DIRECTDOWNLOADURL_DIRECTDOWNLOADURL_2 =
1971 "lower(scProductVersion.directDownloadURL) = lower(?)";
1972 private static final String _FINDER_COLUMN_DIRECTDOWNLOADURL_DIRECTDOWNLOADURL_3 =
1973 "(scProductVersion.directDownloadURL IS NULL OR lower(scProductVersion.directDownloadURL) = lower(?))";
1974 private static final String _ORDER_BY_ENTITY_ALIAS = "scProductVersion.";
1975 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No SCProductVersion exists with the primary key ";
1976 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No SCProductVersion exists with the key {";
1977 private static Log _log = LogFactoryUtil.getLog(SCProductVersionPersistenceImpl.class);
1978 }