1
22
23 package com.liferay.portlet.softwarecatalog.service.persistence;
24
25 import com.liferay.portal.SystemException;
26 import com.liferay.portal.kernel.annotation.BeanReference;
27 import com.liferay.portal.kernel.cache.CacheRegistry;
28 import com.liferay.portal.kernel.dao.jdbc.MappingSqlQuery;
29 import com.liferay.portal.kernel.dao.jdbc.MappingSqlQueryFactoryUtil;
30 import com.liferay.portal.kernel.dao.jdbc.RowMapper;
31 import com.liferay.portal.kernel.dao.jdbc.SqlUpdate;
32 import com.liferay.portal.kernel.dao.jdbc.SqlUpdateFactoryUtil;
33 import com.liferay.portal.kernel.dao.orm.DynamicQuery;
34 import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
35 import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
36 import com.liferay.portal.kernel.dao.orm.FinderPath;
37 import com.liferay.portal.kernel.dao.orm.Query;
38 import com.liferay.portal.kernel.dao.orm.QueryPos;
39 import com.liferay.portal.kernel.dao.orm.QueryUtil;
40 import com.liferay.portal.kernel.dao.orm.SQLQuery;
41 import com.liferay.portal.kernel.dao.orm.Session;
42 import com.liferay.portal.kernel.dao.orm.Type;
43 import com.liferay.portal.kernel.log.Log;
44 import com.liferay.portal.kernel.log.LogFactoryUtil;
45 import com.liferay.portal.kernel.util.GetterUtil;
46 import com.liferay.portal.kernel.util.OrderByComparator;
47 import com.liferay.portal.kernel.util.StringPool;
48 import com.liferay.portal.kernel.util.StringUtil;
49 import com.liferay.portal.kernel.util.Validator;
50 import com.liferay.portal.model.ModelListener;
51 import com.liferay.portal.service.persistence.BatchSessionUtil;
52 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
53
54 import com.liferay.portlet.softwarecatalog.NoSuchProductVersionException;
55 import com.liferay.portlet.softwarecatalog.model.SCProductVersion;
56 import com.liferay.portlet.softwarecatalog.model.impl.SCProductVersionImpl;
57 import com.liferay.portlet.softwarecatalog.model.impl.SCProductVersionModelImpl;
58
59 import java.sql.Types;
60
61 import java.util.ArrayList;
62 import java.util.Collections;
63 import java.util.List;
64
65
71 public class SCProductVersionPersistenceImpl extends BasePersistenceImpl
72 implements SCProductVersionPersistence {
73 public static final String FINDER_CLASS_NAME_ENTITY = SCProductVersionImpl.class.getName();
74 public static final String FINDER_CLASS_NAME_LIST = FINDER_CLASS_NAME_ENTITY +
75 ".List";
76 public static final FinderPath FINDER_PATH_FIND_BY_PRODUCTENTRYID = new FinderPath(SCProductVersionModelImpl.ENTITY_CACHE_ENABLED,
77 SCProductVersionModelImpl.FINDER_CACHE_ENABLED,
78 FINDER_CLASS_NAME_LIST, "findByProductEntryId",
79 new String[] { Long.class.getName() });
80 public static final FinderPath FINDER_PATH_FIND_BY_OBC_PRODUCTENTRYID = new FinderPath(SCProductVersionModelImpl.ENTITY_CACHE_ENABLED,
81 SCProductVersionModelImpl.FINDER_CACHE_ENABLED,
82 FINDER_CLASS_NAME_LIST, "findByProductEntryId",
83 new String[] {
84 Long.class.getName(),
85
86 "java.lang.Integer", "java.lang.Integer",
87 "com.liferay.portal.kernel.util.OrderByComparator"
88 });
89 public static final FinderPath FINDER_PATH_COUNT_BY_PRODUCTENTRYID = new FinderPath(SCProductVersionModelImpl.ENTITY_CACHE_ENABLED,
90 SCProductVersionModelImpl.FINDER_CACHE_ENABLED,
91 FINDER_CLASS_NAME_LIST, "countByProductEntryId",
92 new String[] { Long.class.getName() });
93 public static final FinderPath FINDER_PATH_FETCH_BY_DIRECTDOWNLOADURL = new FinderPath(SCProductVersionModelImpl.ENTITY_CACHE_ENABLED,
94 SCProductVersionModelImpl.FINDER_CACHE_ENABLED,
95 FINDER_CLASS_NAME_ENTITY, "fetchByDirectDownloadURL",
96 new String[] { String.class.getName() });
97 public static final FinderPath FINDER_PATH_COUNT_BY_DIRECTDOWNLOADURL = new FinderPath(SCProductVersionModelImpl.ENTITY_CACHE_ENABLED,
98 SCProductVersionModelImpl.FINDER_CACHE_ENABLED,
99 FINDER_CLASS_NAME_LIST, "countByDirectDownloadURL",
100 new String[] { String.class.getName() });
101 public static final FinderPath FINDER_PATH_FIND_ALL = new FinderPath(SCProductVersionModelImpl.ENTITY_CACHE_ENABLED,
102 SCProductVersionModelImpl.FINDER_CACHE_ENABLED,
103 FINDER_CLASS_NAME_LIST, "findAll", new String[0]);
104 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(SCProductVersionModelImpl.ENTITY_CACHE_ENABLED,
105 SCProductVersionModelImpl.FINDER_CACHE_ENABLED,
106 FINDER_CLASS_NAME_LIST, "countAll", new String[0]);
107
108 public void cacheResult(SCProductVersion scProductVersion) {
109 EntityCacheUtil.putResult(SCProductVersionModelImpl.ENTITY_CACHE_ENABLED,
110 SCProductVersionImpl.class, scProductVersion.getPrimaryKey(),
111 scProductVersion);
112
113 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_DIRECTDOWNLOADURL,
114 new Object[] { scProductVersion.getDirectDownloadURL() },
115 scProductVersion);
116 }
117
118 public void cacheResult(List<SCProductVersion> scProductVersions) {
119 for (SCProductVersion scProductVersion : scProductVersions) {
120 if (EntityCacheUtil.getResult(
121 SCProductVersionModelImpl.ENTITY_CACHE_ENABLED,
122 SCProductVersionImpl.class,
123 scProductVersion.getPrimaryKey(), this) == null) {
124 cacheResult(scProductVersion);
125 }
126 }
127 }
128
129 public void clearCache() {
130 CacheRegistry.clear(SCProductVersionImpl.class.getName());
131 EntityCacheUtil.clearCache(SCProductVersionImpl.class.getName());
132 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
133 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
134 }
135
136 public SCProductVersion create(long productVersionId) {
137 SCProductVersion scProductVersion = new SCProductVersionImpl();
138
139 scProductVersion.setNew(true);
140 scProductVersion.setPrimaryKey(productVersionId);
141
142 return scProductVersion;
143 }
144
145 public SCProductVersion remove(long productVersionId)
146 throws NoSuchProductVersionException, SystemException {
147 Session session = null;
148
149 try {
150 session = openSession();
151
152 SCProductVersion scProductVersion = (SCProductVersion)session.get(SCProductVersionImpl.class,
153 new Long(productVersionId));
154
155 if (scProductVersion == null) {
156 if (_log.isWarnEnabled()) {
157 _log.warn(
158 "No SCProductVersion exists with the primary key " +
159 productVersionId);
160 }
161
162 throw new NoSuchProductVersionException(
163 "No SCProductVersion exists with the primary key " +
164 productVersionId);
165 }
166
167 return remove(scProductVersion);
168 }
169 catch (NoSuchProductVersionException nsee) {
170 throw nsee;
171 }
172 catch (Exception e) {
173 throw processException(e);
174 }
175 finally {
176 closeSession(session);
177 }
178 }
179
180 public SCProductVersion remove(SCProductVersion scProductVersion)
181 throws SystemException {
182 for (ModelListener<SCProductVersion> listener : listeners) {
183 listener.onBeforeRemove(scProductVersion);
184 }
185
186 scProductVersion = removeImpl(scProductVersion);
187
188 for (ModelListener<SCProductVersion> listener : listeners) {
189 listener.onAfterRemove(scProductVersion);
190 }
191
192 return scProductVersion;
193 }
194
195 protected SCProductVersion removeImpl(SCProductVersion scProductVersion)
196 throws SystemException {
197 try {
198 clearSCFrameworkVersions.clear(scProductVersion.getPrimaryKey());
199 }
200 catch (Exception e) {
201 throw processException(e);
202 }
203 finally {
204 FinderCacheUtil.clearCache("SCFrameworkVersi_SCProductVers");
205 }
206
207 Session session = null;
208
209 try {
210 session = openSession();
211
212 if (scProductVersion.isCachedModel() ||
213 BatchSessionUtil.isEnabled()) {
214 Object staleObject = session.get(SCProductVersionImpl.class,
215 scProductVersion.getPrimaryKeyObj());
216
217 if (staleObject != null) {
218 session.evict(staleObject);
219 }
220 }
221
222 session.delete(scProductVersion);
223
224 session.flush();
225 }
226 catch (Exception e) {
227 throw processException(e);
228 }
229 finally {
230 closeSession(session);
231 }
232
233 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
234
235 SCProductVersionModelImpl scProductVersionModelImpl = (SCProductVersionModelImpl)scProductVersion;
236
237 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_DIRECTDOWNLOADURL,
238 new Object[] {
239 scProductVersionModelImpl.getOriginalDirectDownloadURL()
240 });
241
242 EntityCacheUtil.removeResult(SCProductVersionModelImpl.ENTITY_CACHE_ENABLED,
243 SCProductVersionImpl.class, scProductVersion.getPrimaryKey());
244
245 return scProductVersion;
246 }
247
248
251 public SCProductVersion update(SCProductVersion scProductVersion)
252 throws SystemException {
253 if (_log.isWarnEnabled()) {
254 _log.warn(
255 "Using the deprecated update(SCProductVersion scProductVersion) method. Use update(SCProductVersion scProductVersion, boolean merge) instead.");
256 }
257
258 return update(scProductVersion, false);
259 }
260
261
274 public SCProductVersion update(SCProductVersion scProductVersion,
275 boolean merge) throws SystemException {
276 boolean isNew = scProductVersion.isNew();
277
278 for (ModelListener<SCProductVersion> listener : listeners) {
279 if (isNew) {
280 listener.onBeforeCreate(scProductVersion);
281 }
282 else {
283 listener.onBeforeUpdate(scProductVersion);
284 }
285 }
286
287 scProductVersion = updateImpl(scProductVersion, merge);
288
289 for (ModelListener<SCProductVersion> listener : listeners) {
290 if (isNew) {
291 listener.onAfterCreate(scProductVersion);
292 }
293 else {
294 listener.onAfterUpdate(scProductVersion);
295 }
296 }
297
298 return scProductVersion;
299 }
300
301 public SCProductVersion updateImpl(
302 com.liferay.portlet.softwarecatalog.model.SCProductVersion scProductVersion,
303 boolean merge) throws SystemException {
304 boolean isNew = scProductVersion.isNew();
305
306 SCProductVersionModelImpl scProductVersionModelImpl = (SCProductVersionModelImpl)scProductVersion;
307
308 Session session = null;
309
310 try {
311 session = openSession();
312
313 BatchSessionUtil.update(session, scProductVersion, merge);
314
315 scProductVersion.setNew(false);
316 }
317 catch (Exception e) {
318 throw processException(e);
319 }
320 finally {
321 closeSession(session);
322 }
323
324 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
325
326 EntityCacheUtil.putResult(SCProductVersionModelImpl.ENTITY_CACHE_ENABLED,
327 SCProductVersionImpl.class, scProductVersion.getPrimaryKey(),
328 scProductVersion);
329
330 if (!isNew &&
331 (!Validator.equals(scProductVersion.getDirectDownloadURL(),
332 scProductVersionModelImpl.getOriginalDirectDownloadURL()))) {
333 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_DIRECTDOWNLOADURL,
334 new Object[] {
335 scProductVersionModelImpl.getOriginalDirectDownloadURL()
336 });
337 }
338
339 if (isNew ||
340 (!Validator.equals(scProductVersion.getDirectDownloadURL(),
341 scProductVersionModelImpl.getOriginalDirectDownloadURL()))) {
342 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_DIRECTDOWNLOADURL,
343 new Object[] { scProductVersion.getDirectDownloadURL() },
344 scProductVersion);
345 }
346
347 return scProductVersion;
348 }
349
350 public SCProductVersion findByPrimaryKey(long productVersionId)
351 throws NoSuchProductVersionException, SystemException {
352 SCProductVersion scProductVersion = fetchByPrimaryKey(productVersionId);
353
354 if (scProductVersion == null) {
355 if (_log.isWarnEnabled()) {
356 _log.warn("No SCProductVersion exists with the primary key " +
357 productVersionId);
358 }
359
360 throw new NoSuchProductVersionException(
361 "No SCProductVersion exists with the primary key " +
362 productVersionId);
363 }
364
365 return scProductVersion;
366 }
367
368 public SCProductVersion fetchByPrimaryKey(long productVersionId)
369 throws SystemException {
370 SCProductVersion scProductVersion = (SCProductVersion)EntityCacheUtil.getResult(SCProductVersionModelImpl.ENTITY_CACHE_ENABLED,
371 SCProductVersionImpl.class, productVersionId, this);
372
373 if (scProductVersion == null) {
374 Session session = null;
375
376 try {
377 session = openSession();
378
379 scProductVersion = (SCProductVersion)session.get(SCProductVersionImpl.class,
380 new Long(productVersionId));
381 }
382 catch (Exception e) {
383 throw processException(e);
384 }
385 finally {
386 if (scProductVersion != null) {
387 cacheResult(scProductVersion);
388 }
389
390 closeSession(session);
391 }
392 }
393
394 return scProductVersion;
395 }
396
397 public List<SCProductVersion> findByProductEntryId(long productEntryId)
398 throws SystemException {
399 Object[] finderArgs = new Object[] { new Long(productEntryId) };
400
401 List<SCProductVersion> list = (List<SCProductVersion>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_PRODUCTENTRYID,
402 finderArgs, this);
403
404 if (list == null) {
405 Session session = null;
406
407 try {
408 session = openSession();
409
410 StringBuilder query = new StringBuilder();
411
412 query.append(
413 "FROM com.liferay.portlet.softwarecatalog.model.SCProductVersion WHERE ");
414
415 query.append("productEntryId = ?");
416
417 query.append(" ");
418
419 query.append("ORDER BY ");
420
421 query.append("createDate DESC");
422
423 Query q = session.createQuery(query.toString());
424
425 QueryPos qPos = QueryPos.getInstance(q);
426
427 qPos.add(productEntryId);
428
429 list = q.list();
430 }
431 catch (Exception e) {
432 throw processException(e);
433 }
434 finally {
435 if (list == null) {
436 list = new ArrayList<SCProductVersion>();
437 }
438
439 cacheResult(list);
440
441 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_PRODUCTENTRYID,
442 finderArgs, list);
443
444 closeSession(session);
445 }
446 }
447
448 return list;
449 }
450
451 public List<SCProductVersion> findByProductEntryId(long productEntryId,
452 int start, int end) throws SystemException {
453 return findByProductEntryId(productEntryId, start, end, null);
454 }
455
456 public List<SCProductVersion> findByProductEntryId(long productEntryId,
457 int start, int end, OrderByComparator obc) throws SystemException {
458 Object[] finderArgs = new Object[] {
459 new Long(productEntryId),
460
461 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
462 };
463
464 List<SCProductVersion> list = (List<SCProductVersion>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_PRODUCTENTRYID,
465 finderArgs, this);
466
467 if (list == null) {
468 Session session = null;
469
470 try {
471 session = openSession();
472
473 StringBuilder query = new StringBuilder();
474
475 query.append(
476 "FROM com.liferay.portlet.softwarecatalog.model.SCProductVersion WHERE ");
477
478 query.append("productEntryId = ?");
479
480 query.append(" ");
481
482 if (obc != null) {
483 query.append("ORDER BY ");
484 query.append(obc.getOrderBy());
485 }
486
487 else {
488 query.append("ORDER BY ");
489
490 query.append("createDate DESC");
491 }
492
493 Query q = session.createQuery(query.toString());
494
495 QueryPos qPos = QueryPos.getInstance(q);
496
497 qPos.add(productEntryId);
498
499 list = (List<SCProductVersion>)QueryUtil.list(q, getDialect(),
500 start, end);
501 }
502 catch (Exception e) {
503 throw processException(e);
504 }
505 finally {
506 if (list == null) {
507 list = new ArrayList<SCProductVersion>();
508 }
509
510 cacheResult(list);
511
512 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_PRODUCTENTRYID,
513 finderArgs, list);
514
515 closeSession(session);
516 }
517 }
518
519 return list;
520 }
521
522 public SCProductVersion findByProductEntryId_First(long productEntryId,
523 OrderByComparator obc)
524 throws NoSuchProductVersionException, SystemException {
525 List<SCProductVersion> list = findByProductEntryId(productEntryId, 0,
526 1, obc);
527
528 if (list.isEmpty()) {
529 StringBuilder msg = new StringBuilder();
530
531 msg.append("No SCProductVersion exists with the key {");
532
533 msg.append("productEntryId=" + productEntryId);
534
535 msg.append(StringPool.CLOSE_CURLY_BRACE);
536
537 throw new NoSuchProductVersionException(msg.toString());
538 }
539 else {
540 return list.get(0);
541 }
542 }
543
544 public SCProductVersion findByProductEntryId_Last(long productEntryId,
545 OrderByComparator obc)
546 throws NoSuchProductVersionException, SystemException {
547 int count = countByProductEntryId(productEntryId);
548
549 List<SCProductVersion> list = findByProductEntryId(productEntryId,
550 count - 1, count, obc);
551
552 if (list.isEmpty()) {
553 StringBuilder msg = new StringBuilder();
554
555 msg.append("No SCProductVersion exists with the key {");
556
557 msg.append("productEntryId=" + productEntryId);
558
559 msg.append(StringPool.CLOSE_CURLY_BRACE);
560
561 throw new NoSuchProductVersionException(msg.toString());
562 }
563 else {
564 return list.get(0);
565 }
566 }
567
568 public SCProductVersion[] findByProductEntryId_PrevAndNext(
569 long productVersionId, long productEntryId, OrderByComparator obc)
570 throws NoSuchProductVersionException, SystemException {
571 SCProductVersion scProductVersion = findByPrimaryKey(productVersionId);
572
573 int count = countByProductEntryId(productEntryId);
574
575 Session session = null;
576
577 try {
578 session = openSession();
579
580 StringBuilder query = new StringBuilder();
581
582 query.append(
583 "FROM com.liferay.portlet.softwarecatalog.model.SCProductVersion WHERE ");
584
585 query.append("productEntryId = ?");
586
587 query.append(" ");
588
589 if (obc != null) {
590 query.append("ORDER BY ");
591 query.append(obc.getOrderBy());
592 }
593
594 else {
595 query.append("ORDER BY ");
596
597 query.append("createDate DESC");
598 }
599
600 Query q = session.createQuery(query.toString());
601
602 QueryPos qPos = QueryPos.getInstance(q);
603
604 qPos.add(productEntryId);
605
606 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
607 scProductVersion);
608
609 SCProductVersion[] array = new SCProductVersionImpl[3];
610
611 array[0] = (SCProductVersion)objArray[0];
612 array[1] = (SCProductVersion)objArray[1];
613 array[2] = (SCProductVersion)objArray[2];
614
615 return array;
616 }
617 catch (Exception e) {
618 throw processException(e);
619 }
620 finally {
621 closeSession(session);
622 }
623 }
624
625 public SCProductVersion findByDirectDownloadURL(String directDownloadURL)
626 throws NoSuchProductVersionException, SystemException {
627 SCProductVersion scProductVersion = fetchByDirectDownloadURL(directDownloadURL);
628
629 if (scProductVersion == null) {
630 StringBuilder msg = new StringBuilder();
631
632 msg.append("No SCProductVersion exists with the key {");
633
634 msg.append("directDownloadURL=" + directDownloadURL);
635
636 msg.append(StringPool.CLOSE_CURLY_BRACE);
637
638 if (_log.isWarnEnabled()) {
639 _log.warn(msg.toString());
640 }
641
642 throw new NoSuchProductVersionException(msg.toString());
643 }
644
645 return scProductVersion;
646 }
647
648 public SCProductVersion fetchByDirectDownloadURL(String directDownloadURL)
649 throws SystemException {
650 return fetchByDirectDownloadURL(directDownloadURL, true);
651 }
652
653 public SCProductVersion fetchByDirectDownloadURL(String directDownloadURL,
654 boolean retrieveFromCache) throws SystemException {
655 Object[] finderArgs = new Object[] { directDownloadURL };
656
657 Object result = null;
658
659 if (retrieveFromCache) {
660 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_DIRECTDOWNLOADURL,
661 finderArgs, this);
662 }
663
664 if (result == null) {
665 Session session = null;
666
667 try {
668 session = openSession();
669
670 StringBuilder query = new StringBuilder();
671
672 query.append(
673 "FROM com.liferay.portlet.softwarecatalog.model.SCProductVersion WHERE ");
674
675 if (directDownloadURL == null) {
676 query.append("directDownloadURL IS NULL");
677 }
678 else {
679 query.append("lower(directDownloadURL) = ?");
680 }
681
682 query.append(" ");
683
684 query.append("ORDER BY ");
685
686 query.append("createDate DESC");
687
688 Query q = session.createQuery(query.toString());
689
690 QueryPos qPos = QueryPos.getInstance(q);
691
692 if (directDownloadURL != null) {
693 qPos.add(directDownloadURL);
694 }
695
696 List<SCProductVersion> list = q.list();
697
698 result = list;
699
700 SCProductVersion scProductVersion = null;
701
702 if (list.isEmpty()) {
703 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_DIRECTDOWNLOADURL,
704 finderArgs, list);
705 }
706 else {
707 scProductVersion = list.get(0);
708
709 cacheResult(scProductVersion);
710
711 if ((scProductVersion.getDirectDownloadURL() == null) ||
712 !scProductVersion.getDirectDownloadURL()
713 .equals(directDownloadURL)) {
714 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_DIRECTDOWNLOADURL,
715 finderArgs, scProductVersion);
716 }
717 }
718
719 return scProductVersion;
720 }
721 catch (Exception e) {
722 throw processException(e);
723 }
724 finally {
725 if (result == null) {
726 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_DIRECTDOWNLOADURL,
727 finderArgs, new ArrayList<SCProductVersion>());
728 }
729
730 closeSession(session);
731 }
732 }
733 else {
734 if (result instanceof List) {
735 return null;
736 }
737 else {
738 return (SCProductVersion)result;
739 }
740 }
741 }
742
743 public List<Object> findWithDynamicQuery(DynamicQuery dynamicQuery)
744 throws SystemException {
745 Session session = null;
746
747 try {
748 session = openSession();
749
750 dynamicQuery.compile(session);
751
752 return dynamicQuery.list();
753 }
754 catch (Exception e) {
755 throw processException(e);
756 }
757 finally {
758 closeSession(session);
759 }
760 }
761
762 public List<Object> findWithDynamicQuery(DynamicQuery dynamicQuery,
763 int start, int end) throws SystemException {
764 Session session = null;
765
766 try {
767 session = openSession();
768
769 dynamicQuery.setLimit(start, end);
770
771 dynamicQuery.compile(session);
772
773 return dynamicQuery.list();
774 }
775 catch (Exception e) {
776 throw processException(e);
777 }
778 finally {
779 closeSession(session);
780 }
781 }
782
783 public List<SCProductVersion> findAll() throws SystemException {
784 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
785 }
786
787 public List<SCProductVersion> findAll(int start, int end)
788 throws SystemException {
789 return findAll(start, end, null);
790 }
791
792 public List<SCProductVersion> findAll(int start, int end,
793 OrderByComparator obc) throws SystemException {
794 Object[] finderArgs = new Object[] {
795 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
796 };
797
798 List<SCProductVersion> list = (List<SCProductVersion>)FinderCacheUtil.getResult(FINDER_PATH_FIND_ALL,
799 finderArgs, this);
800
801 if (list == null) {
802 Session session = null;
803
804 try {
805 session = openSession();
806
807 StringBuilder query = new StringBuilder();
808
809 query.append(
810 "FROM com.liferay.portlet.softwarecatalog.model.SCProductVersion ");
811
812 if (obc != null) {
813 query.append("ORDER BY ");
814 query.append(obc.getOrderBy());
815 }
816
817 else {
818 query.append("ORDER BY ");
819
820 query.append("createDate DESC");
821 }
822
823 Query q = session.createQuery(query.toString());
824
825 if (obc == null) {
826 list = (List<SCProductVersion>)QueryUtil.list(q,
827 getDialect(), start, end, false);
828
829 Collections.sort(list);
830 }
831 else {
832 list = (List<SCProductVersion>)QueryUtil.list(q,
833 getDialect(), start, end);
834 }
835 }
836 catch (Exception e) {
837 throw processException(e);
838 }
839 finally {
840 if (list == null) {
841 list = new ArrayList<SCProductVersion>();
842 }
843
844 cacheResult(list);
845
846 FinderCacheUtil.putResult(FINDER_PATH_FIND_ALL, finderArgs, list);
847
848 closeSession(session);
849 }
850 }
851
852 return list;
853 }
854
855 public void removeByProductEntryId(long productEntryId)
856 throws SystemException {
857 for (SCProductVersion scProductVersion : findByProductEntryId(
858 productEntryId)) {
859 remove(scProductVersion);
860 }
861 }
862
863 public void removeByDirectDownloadURL(String directDownloadURL)
864 throws NoSuchProductVersionException, SystemException {
865 SCProductVersion scProductVersion = findByDirectDownloadURL(directDownloadURL);
866
867 remove(scProductVersion);
868 }
869
870 public void removeAll() throws SystemException {
871 for (SCProductVersion scProductVersion : findAll()) {
872 remove(scProductVersion);
873 }
874 }
875
876 public int countByProductEntryId(long productEntryId)
877 throws SystemException {
878 Object[] finderArgs = new Object[] { new Long(productEntryId) };
879
880 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_PRODUCTENTRYID,
881 finderArgs, this);
882
883 if (count == null) {
884 Session session = null;
885
886 try {
887 session = openSession();
888
889 StringBuilder query = new StringBuilder();
890
891 query.append("SELECT COUNT(*) ");
892 query.append(
893 "FROM com.liferay.portlet.softwarecatalog.model.SCProductVersion WHERE ");
894
895 query.append("productEntryId = ?");
896
897 query.append(" ");
898
899 Query q = session.createQuery(query.toString());
900
901 QueryPos qPos = QueryPos.getInstance(q);
902
903 qPos.add(productEntryId);
904
905 count = (Long)q.uniqueResult();
906 }
907 catch (Exception e) {
908 throw processException(e);
909 }
910 finally {
911 if (count == null) {
912 count = Long.valueOf(0);
913 }
914
915 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_PRODUCTENTRYID,
916 finderArgs, count);
917
918 closeSession(session);
919 }
920 }
921
922 return count.intValue();
923 }
924
925 public int countByDirectDownloadURL(String directDownloadURL)
926 throws SystemException {
927 Object[] finderArgs = new Object[] { directDownloadURL };
928
929 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_DIRECTDOWNLOADURL,
930 finderArgs, this);
931
932 if (count == null) {
933 Session session = null;
934
935 try {
936 session = openSession();
937
938 StringBuilder query = new StringBuilder();
939
940 query.append("SELECT COUNT(*) ");
941 query.append(
942 "FROM com.liferay.portlet.softwarecatalog.model.SCProductVersion WHERE ");
943
944 if (directDownloadURL == null) {
945 query.append("directDownloadURL IS NULL");
946 }
947 else {
948 query.append("lower(directDownloadURL) = ?");
949 }
950
951 query.append(" ");
952
953 Query q = session.createQuery(query.toString());
954
955 QueryPos qPos = QueryPos.getInstance(q);
956
957 if (directDownloadURL != null) {
958 qPos.add(directDownloadURL);
959 }
960
961 count = (Long)q.uniqueResult();
962 }
963 catch (Exception e) {
964 throw processException(e);
965 }
966 finally {
967 if (count == null) {
968 count = Long.valueOf(0);
969 }
970
971 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_DIRECTDOWNLOADURL,
972 finderArgs, count);
973
974 closeSession(session);
975 }
976 }
977
978 return count.intValue();
979 }
980
981 public int countAll() throws SystemException {
982 Object[] finderArgs = new Object[0];
983
984 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
985 finderArgs, this);
986
987 if (count == null) {
988 Session session = null;
989
990 try {
991 session = openSession();
992
993 Query q = session.createQuery(
994 "SELECT COUNT(*) FROM com.liferay.portlet.softwarecatalog.model.SCProductVersion");
995
996 count = (Long)q.uniqueResult();
997 }
998 catch (Exception e) {
999 throw processException(e);
1000 }
1001 finally {
1002 if (count == null) {
1003 count = Long.valueOf(0);
1004 }
1005
1006 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL, finderArgs,
1007 count);
1008
1009 closeSession(session);
1010 }
1011 }
1012
1013 return count.intValue();
1014 }
1015
1016 public List<com.liferay.portlet.softwarecatalog.model.SCFrameworkVersion> getSCFrameworkVersions(
1017 long pk) throws SystemException {
1018 return getSCFrameworkVersions(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
1019 }
1020
1021 public List<com.liferay.portlet.softwarecatalog.model.SCFrameworkVersion> getSCFrameworkVersions(
1022 long pk, int start, int end) throws SystemException {
1023 return getSCFrameworkVersions(pk, start, end, null);
1024 }
1025
1026 public static final FinderPath FINDER_PATH_GET_SCFRAMEWORKVERSIONS = new FinderPath(com.liferay.portlet.softwarecatalog.model.impl.SCFrameworkVersionModelImpl.ENTITY_CACHE_ENABLED,
1027 SCProductVersionModelImpl.FINDER_CACHE_ENABLED_SCFRAMEWORKVERSI_SCPRODUCTVERS,
1028 "SCFrameworkVersi_SCProductVers", "getSCFrameworkVersions",
1029 new String[] {
1030 Long.class.getName(), "java.lang.Integer", "java.lang.Integer",
1031 "com.liferay.portal.kernel.util.OrderByComparator"
1032 });
1033
1034 public List<com.liferay.portlet.softwarecatalog.model.SCFrameworkVersion> getSCFrameworkVersions(
1035 long pk, int start, int end, OrderByComparator obc)
1036 throws SystemException {
1037 Object[] finderArgs = new Object[] {
1038 new Long(pk), String.valueOf(start), String.valueOf(end),
1039 String.valueOf(obc)
1040 };
1041
1042 List<com.liferay.portlet.softwarecatalog.model.SCFrameworkVersion> list = (List<com.liferay.portlet.softwarecatalog.model.SCFrameworkVersion>)FinderCacheUtil.getResult(FINDER_PATH_GET_SCFRAMEWORKVERSIONS,
1043 finderArgs, this);
1044
1045 if (list == null) {
1046 Session session = null;
1047
1048 try {
1049 session = openSession();
1050
1051 StringBuilder sb = new StringBuilder();
1052
1053 sb.append(_SQL_GETSCFRAMEWORKVERSIONS);
1054
1055 if (obc != null) {
1056 sb.append("ORDER BY ");
1057 sb.append(obc.getOrderBy());
1058 }
1059
1060 else {
1061 sb.append("ORDER BY ");
1062
1063 sb.append("SCFrameworkVersion.name DESC");
1064 }
1065
1066 String sql = sb.toString();
1067
1068 SQLQuery q = session.createSQLQuery(sql);
1069
1070 q.addEntity("SCFrameworkVersion",
1071 com.liferay.portlet.softwarecatalog.model.impl.SCFrameworkVersionImpl.class);
1072
1073 QueryPos qPos = QueryPos.getInstance(q);
1074
1075 qPos.add(pk);
1076
1077 list = (List<com.liferay.portlet.softwarecatalog.model.SCFrameworkVersion>)QueryUtil.list(q,
1078 getDialect(), start, end);
1079 }
1080 catch (Exception e) {
1081 throw processException(e);
1082 }
1083 finally {
1084 if (list == null) {
1085 list = new ArrayList<com.liferay.portlet.softwarecatalog.model.SCFrameworkVersion>();
1086 }
1087
1088 scFrameworkVersionPersistence.cacheResult(list);
1089
1090 FinderCacheUtil.putResult(FINDER_PATH_GET_SCFRAMEWORKVERSIONS,
1091 finderArgs, list);
1092
1093 closeSession(session);
1094 }
1095 }
1096
1097 return list;
1098 }
1099
1100 public static final FinderPath FINDER_PATH_GET_SCFRAMEWORKVERSIONS_SIZE = new FinderPath(com.liferay.portlet.softwarecatalog.model.impl.SCFrameworkVersionModelImpl.ENTITY_CACHE_ENABLED,
1101 SCProductVersionModelImpl.FINDER_CACHE_ENABLED_SCFRAMEWORKVERSI_SCPRODUCTVERS,
1102 "SCFrameworkVersi_SCProductVers", "getSCFrameworkVersionsSize",
1103 new String[] { Long.class.getName() });
1104
1105 public int getSCFrameworkVersionsSize(long pk) throws SystemException {
1106 Object[] finderArgs = new Object[] { new Long(pk) };
1107
1108 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_GET_SCFRAMEWORKVERSIONS_SIZE,
1109 finderArgs, this);
1110
1111 if (count == null) {
1112 Session session = null;
1113
1114 try {
1115 session = openSession();
1116
1117 SQLQuery q = session.createSQLQuery(_SQL_GETSCFRAMEWORKVERSIONSSIZE);
1118
1119 q.addScalar(COUNT_COLUMN_NAME, Type.LONG);
1120
1121 QueryPos qPos = QueryPos.getInstance(q);
1122
1123 qPos.add(pk);
1124
1125 count = (Long)q.uniqueResult();
1126 }
1127 catch (Exception e) {
1128 throw processException(e);
1129 }
1130 finally {
1131 if (count == null) {
1132 count = Long.valueOf(0);
1133 }
1134
1135 FinderCacheUtil.putResult(FINDER_PATH_GET_SCFRAMEWORKVERSIONS_SIZE,
1136 finderArgs, count);
1137
1138 closeSession(session);
1139 }
1140 }
1141
1142 return count.intValue();
1143 }
1144
1145 public static final FinderPath FINDER_PATH_CONTAINS_SCFRAMEWORKVERSION = new FinderPath(com.liferay.portlet.softwarecatalog.model.impl.SCFrameworkVersionModelImpl.ENTITY_CACHE_ENABLED,
1146 SCProductVersionModelImpl.FINDER_CACHE_ENABLED_SCFRAMEWORKVERSI_SCPRODUCTVERS,
1147 "SCFrameworkVersi_SCProductVers", "containsSCFrameworkVersion",
1148 new String[] { Long.class.getName(), Long.class.getName() });
1149
1150 public boolean containsSCFrameworkVersion(long pk, long scFrameworkVersionPK)
1151 throws SystemException {
1152 Object[] finderArgs = new Object[] {
1153 new Long(pk),
1154
1155 new Long(scFrameworkVersionPK)
1156 };
1157
1158 Boolean value = (Boolean)FinderCacheUtil.getResult(FINDER_PATH_CONTAINS_SCFRAMEWORKVERSION,
1159 finderArgs, this);
1160
1161 if (value == null) {
1162 try {
1163 value = Boolean.valueOf(containsSCFrameworkVersion.contains(
1164 pk, scFrameworkVersionPK));
1165 }
1166 catch (Exception e) {
1167 throw processException(e);
1168 }
1169 finally {
1170 if (value == null) {
1171 value = Boolean.FALSE;
1172 }
1173
1174 FinderCacheUtil.putResult(FINDER_PATH_CONTAINS_SCFRAMEWORKVERSION,
1175 finderArgs, value);
1176 }
1177 }
1178
1179 return value.booleanValue();
1180 }
1181
1182 public boolean containsSCFrameworkVersions(long pk)
1183 throws SystemException {
1184 if (getSCFrameworkVersionsSize(pk) > 0) {
1185 return true;
1186 }
1187 else {
1188 return false;
1189 }
1190 }
1191
1192 public void addSCFrameworkVersion(long pk, long scFrameworkVersionPK)
1193 throws SystemException {
1194 try {
1195 addSCFrameworkVersion.add(pk, scFrameworkVersionPK);
1196 }
1197 catch (Exception e) {
1198 throw processException(e);
1199 }
1200 finally {
1201 FinderCacheUtil.clearCache("SCFrameworkVersi_SCProductVers");
1202 }
1203 }
1204
1205 public void addSCFrameworkVersion(long pk,
1206 com.liferay.portlet.softwarecatalog.model.SCFrameworkVersion scFrameworkVersion)
1207 throws SystemException {
1208 try {
1209 addSCFrameworkVersion.add(pk, scFrameworkVersion.getPrimaryKey());
1210 }
1211 catch (Exception e) {
1212 throw processException(e);
1213 }
1214 finally {
1215 FinderCacheUtil.clearCache("SCFrameworkVersi_SCProductVers");
1216 }
1217 }
1218
1219 public void addSCFrameworkVersions(long pk, long[] scFrameworkVersionPKs)
1220 throws SystemException {
1221 try {
1222 for (long scFrameworkVersionPK : scFrameworkVersionPKs) {
1223 addSCFrameworkVersion.add(pk, scFrameworkVersionPK);
1224 }
1225 }
1226 catch (Exception e) {
1227 throw processException(e);
1228 }
1229 finally {
1230 FinderCacheUtil.clearCache("SCFrameworkVersi_SCProductVers");
1231 }
1232 }
1233
1234 public void addSCFrameworkVersions(long pk,
1235 List<com.liferay.portlet.softwarecatalog.model.SCFrameworkVersion> scFrameworkVersions)
1236 throws SystemException {
1237 try {
1238 for (com.liferay.portlet.softwarecatalog.model.SCFrameworkVersion scFrameworkVersion : scFrameworkVersions) {
1239 addSCFrameworkVersion.add(pk, scFrameworkVersion.getPrimaryKey());
1240 }
1241 }
1242 catch (Exception e) {
1243 throw processException(e);
1244 }
1245 finally {
1246 FinderCacheUtil.clearCache("SCFrameworkVersi_SCProductVers");
1247 }
1248 }
1249
1250 public void clearSCFrameworkVersions(long pk) throws SystemException {
1251 try {
1252 clearSCFrameworkVersions.clear(pk);
1253 }
1254 catch (Exception e) {
1255 throw processException(e);
1256 }
1257 finally {
1258 FinderCacheUtil.clearCache("SCFrameworkVersi_SCProductVers");
1259 }
1260 }
1261
1262 public void removeSCFrameworkVersion(long pk, long scFrameworkVersionPK)
1263 throws SystemException {
1264 try {
1265 removeSCFrameworkVersion.remove(pk, scFrameworkVersionPK);
1266 }
1267 catch (Exception e) {
1268 throw processException(e);
1269 }
1270 finally {
1271 FinderCacheUtil.clearCache("SCFrameworkVersi_SCProductVers");
1272 }
1273 }
1274
1275 public void removeSCFrameworkVersion(long pk,
1276 com.liferay.portlet.softwarecatalog.model.SCFrameworkVersion scFrameworkVersion)
1277 throws SystemException {
1278 try {
1279 removeSCFrameworkVersion.remove(pk,
1280 scFrameworkVersion.getPrimaryKey());
1281 }
1282 catch (Exception e) {
1283 throw processException(e);
1284 }
1285 finally {
1286 FinderCacheUtil.clearCache("SCFrameworkVersi_SCProductVers");
1287 }
1288 }
1289
1290 public void removeSCFrameworkVersions(long pk, long[] scFrameworkVersionPKs)
1291 throws SystemException {
1292 try {
1293 for (long scFrameworkVersionPK : scFrameworkVersionPKs) {
1294 removeSCFrameworkVersion.remove(pk, scFrameworkVersionPK);
1295 }
1296 }
1297 catch (Exception e) {
1298 throw processException(e);
1299 }
1300 finally {
1301 FinderCacheUtil.clearCache("SCFrameworkVersi_SCProductVers");
1302 }
1303 }
1304
1305 public void removeSCFrameworkVersions(long pk,
1306 List<com.liferay.portlet.softwarecatalog.model.SCFrameworkVersion> scFrameworkVersions)
1307 throws SystemException {
1308 try {
1309 for (com.liferay.portlet.softwarecatalog.model.SCFrameworkVersion scFrameworkVersion : scFrameworkVersions) {
1310 removeSCFrameworkVersion.remove(pk,
1311 scFrameworkVersion.getPrimaryKey());
1312 }
1313 }
1314 catch (Exception e) {
1315 throw processException(e);
1316 }
1317 finally {
1318 FinderCacheUtil.clearCache("SCFrameworkVersi_SCProductVers");
1319 }
1320 }
1321
1322 public void setSCFrameworkVersions(long pk, long[] scFrameworkVersionPKs)
1323 throws SystemException {
1324 try {
1325 clearSCFrameworkVersions.clear(pk);
1326
1327 for (long scFrameworkVersionPK : scFrameworkVersionPKs) {
1328 addSCFrameworkVersion.add(pk, scFrameworkVersionPK);
1329 }
1330 }
1331 catch (Exception e) {
1332 throw processException(e);
1333 }
1334 finally {
1335 FinderCacheUtil.clearCache("SCFrameworkVersi_SCProductVers");
1336 }
1337 }
1338
1339 public void setSCFrameworkVersions(long pk,
1340 List<com.liferay.portlet.softwarecatalog.model.SCFrameworkVersion> scFrameworkVersions)
1341 throws SystemException {
1342 try {
1343 clearSCFrameworkVersions.clear(pk);
1344
1345 for (com.liferay.portlet.softwarecatalog.model.SCFrameworkVersion scFrameworkVersion : scFrameworkVersions) {
1346 addSCFrameworkVersion.add(pk, scFrameworkVersion.getPrimaryKey());
1347 }
1348 }
1349 catch (Exception e) {
1350 throw processException(e);
1351 }
1352 finally {
1353 FinderCacheUtil.clearCache("SCFrameworkVersi_SCProductVers");
1354 }
1355 }
1356
1357 public void afterPropertiesSet() {
1358 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
1359 com.liferay.portal.util.PropsUtil.get(
1360 "value.object.listener.com.liferay.portlet.softwarecatalog.model.SCProductVersion")));
1361
1362 if (listenerClassNames.length > 0) {
1363 try {
1364 List<ModelListener<SCProductVersion>> listenersList = new ArrayList<ModelListener<SCProductVersion>>();
1365
1366 for (String listenerClassName : listenerClassNames) {
1367 listenersList.add((ModelListener<SCProductVersion>)Class.forName(
1368 listenerClassName).newInstance());
1369 }
1370
1371 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
1372 }
1373 catch (Exception e) {
1374 _log.error(e);
1375 }
1376 }
1377
1378 containsSCFrameworkVersion = new ContainsSCFrameworkVersion(this);
1379
1380 addSCFrameworkVersion = new AddSCFrameworkVersion(this);
1381 clearSCFrameworkVersions = new ClearSCFrameworkVersions(this);
1382 removeSCFrameworkVersion = new RemoveSCFrameworkVersion(this);
1383 }
1384
1385 @BeanReference(name = "com.liferay.portlet.softwarecatalog.service.persistence.SCLicensePersistence.impl")
1386 protected com.liferay.portlet.softwarecatalog.service.persistence.SCLicensePersistence scLicensePersistence;
1387 @BeanReference(name = "com.liferay.portlet.softwarecatalog.service.persistence.SCFrameworkVersionPersistence.impl")
1388 protected com.liferay.portlet.softwarecatalog.service.persistence.SCFrameworkVersionPersistence scFrameworkVersionPersistence;
1389 @BeanReference(name = "com.liferay.portlet.softwarecatalog.service.persistence.SCProductEntryPersistence.impl")
1390 protected com.liferay.portlet.softwarecatalog.service.persistence.SCProductEntryPersistence scProductEntryPersistence;
1391 @BeanReference(name = "com.liferay.portlet.softwarecatalog.service.persistence.SCProductScreenshotPersistence.impl")
1392 protected com.liferay.portlet.softwarecatalog.service.persistence.SCProductScreenshotPersistence scProductScreenshotPersistence;
1393 @BeanReference(name = "com.liferay.portlet.softwarecatalog.service.persistence.SCProductVersionPersistence.impl")
1394 protected com.liferay.portlet.softwarecatalog.service.persistence.SCProductVersionPersistence scProductVersionPersistence;
1395 @BeanReference(name = "com.liferay.portal.service.persistence.UserPersistence.impl")
1396 protected com.liferay.portal.service.persistence.UserPersistence userPersistence;
1397 protected ContainsSCFrameworkVersion containsSCFrameworkVersion;
1398 protected AddSCFrameworkVersion addSCFrameworkVersion;
1399 protected ClearSCFrameworkVersions clearSCFrameworkVersions;
1400 protected RemoveSCFrameworkVersion removeSCFrameworkVersion;
1401
1402 protected class ContainsSCFrameworkVersion {
1403 protected ContainsSCFrameworkVersion(
1404 SCProductVersionPersistenceImpl persistenceImpl) {
1405 super();
1406
1407 _mappingSqlQuery = MappingSqlQueryFactoryUtil.getMappingSqlQuery(getDataSource(),
1408 _SQL_CONTAINSSCFRAMEWORKVERSION,
1409 new int[] { Types.BIGINT, Types.BIGINT }, RowMapper.COUNT);
1410 }
1411
1412 protected boolean contains(long productVersionId,
1413 long frameworkVersionId) {
1414 List<Integer> results = _mappingSqlQuery.execute(new Object[] {
1415 new Long(productVersionId), new Long(frameworkVersionId)
1416 });
1417
1418 if (results.size() > 0) {
1419 Integer count = results.get(0);
1420
1421 if (count.intValue() > 0) {
1422 return true;
1423 }
1424 }
1425
1426 return false;
1427 }
1428
1429 private MappingSqlQuery _mappingSqlQuery;
1430 }
1431
1432 protected class AddSCFrameworkVersion {
1433 protected AddSCFrameworkVersion(
1434 SCProductVersionPersistenceImpl persistenceImpl) {
1435 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
1436 "INSERT INTO SCFrameworkVersi_SCProductVers (productVersionId, frameworkVersionId) VALUES (?, ?)",
1437 new int[] { Types.BIGINT, Types.BIGINT });
1438 _persistenceImpl = persistenceImpl;
1439 }
1440
1441 protected void add(long productVersionId, long frameworkVersionId)
1442 throws SystemException {
1443 if (!_persistenceImpl.containsSCFrameworkVersion.contains(
1444 productVersionId, frameworkVersionId)) {
1445 ModelListener<com.liferay.portlet.softwarecatalog.model.SCFrameworkVersion>[] scFrameworkVersionListeners =
1446 scFrameworkVersionPersistence.getListeners();
1447
1448 for (ModelListener<SCProductVersion> listener : listeners) {
1449 listener.onBeforeAddAssociation(productVersionId,
1450 com.liferay.portlet.softwarecatalog.model.SCFrameworkVersion.class.getName(),
1451 frameworkVersionId);
1452 }
1453
1454 for (ModelListener<com.liferay.portlet.softwarecatalog.model.SCFrameworkVersion> listener : scFrameworkVersionListeners) {
1455 listener.onBeforeAddAssociation(frameworkVersionId,
1456 SCProductVersion.class.getName(), productVersionId);
1457 }
1458
1459 _sqlUpdate.update(new Object[] {
1460 new Long(productVersionId), new Long(frameworkVersionId)
1461 });
1462
1463 for (ModelListener<SCProductVersion> listener : listeners) {
1464 listener.onAfterAddAssociation(productVersionId,
1465 com.liferay.portlet.softwarecatalog.model.SCFrameworkVersion.class.getName(),
1466 frameworkVersionId);
1467 }
1468
1469 for (ModelListener<com.liferay.portlet.softwarecatalog.model.SCFrameworkVersion> listener : scFrameworkVersionListeners) {
1470 listener.onAfterAddAssociation(frameworkVersionId,
1471 SCProductVersion.class.getName(), productVersionId);
1472 }
1473 }
1474 }
1475
1476 private SqlUpdate _sqlUpdate;
1477 private SCProductVersionPersistenceImpl _persistenceImpl;
1478 }
1479
1480 protected class ClearSCFrameworkVersions {
1481 protected ClearSCFrameworkVersions(
1482 SCProductVersionPersistenceImpl persistenceImpl) {
1483 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
1484 "DELETE FROM SCFrameworkVersi_SCProductVers WHERE productVersionId = ?",
1485 new int[] { Types.BIGINT });
1486 }
1487
1488 protected void clear(long productVersionId) throws SystemException {
1489 ModelListener<com.liferay.portlet.softwarecatalog.model.SCFrameworkVersion>[] scFrameworkVersionListeners =
1490 scFrameworkVersionPersistence.getListeners();
1491
1492 List<com.liferay.portlet.softwarecatalog.model.SCFrameworkVersion> scFrameworkVersions =
1493 null;
1494
1495 if ((listeners.length > 0) ||
1496 (scFrameworkVersionListeners.length > 0)) {
1497 scFrameworkVersions = getSCFrameworkVersions(productVersionId);
1498
1499 for (com.liferay.portlet.softwarecatalog.model.SCFrameworkVersion scFrameworkVersion : scFrameworkVersions) {
1500 for (ModelListener<SCProductVersion> listener : listeners) {
1501 listener.onBeforeRemoveAssociation(productVersionId,
1502 com.liferay.portlet.softwarecatalog.model.SCFrameworkVersion.class.getName(),
1503 scFrameworkVersion.getPrimaryKey());
1504 }
1505
1506 for (ModelListener<com.liferay.portlet.softwarecatalog.model.SCFrameworkVersion> listener : scFrameworkVersionListeners) {
1507 listener.onBeforeRemoveAssociation(scFrameworkVersion.getPrimaryKey(),
1508 SCProductVersion.class.getName(), productVersionId);
1509 }
1510 }
1511 }
1512
1513 _sqlUpdate.update(new Object[] { new Long(productVersionId) });
1514
1515 if ((listeners.length > 0) ||
1516 (scFrameworkVersionListeners.length > 0)) {
1517 for (com.liferay.portlet.softwarecatalog.model.SCFrameworkVersion scFrameworkVersion : scFrameworkVersions) {
1518 for (ModelListener<SCProductVersion> listener : listeners) {
1519 listener.onAfterRemoveAssociation(productVersionId,
1520 com.liferay.portlet.softwarecatalog.model.SCFrameworkVersion.class.getName(),
1521 scFrameworkVersion.getPrimaryKey());
1522 }
1523
1524 for (ModelListener<com.liferay.portlet.softwarecatalog.model.SCFrameworkVersion> listener : scFrameworkVersionListeners) {
1525 listener.onBeforeRemoveAssociation(scFrameworkVersion.getPrimaryKey(),
1526 SCProductVersion.class.getName(), productVersionId);
1527 }
1528 }
1529 }
1530 }
1531
1532 private SqlUpdate _sqlUpdate;
1533 }
1534
1535 protected class RemoveSCFrameworkVersion {
1536 protected RemoveSCFrameworkVersion(
1537 SCProductVersionPersistenceImpl persistenceImpl) {
1538 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
1539 "DELETE FROM SCFrameworkVersi_SCProductVers WHERE productVersionId = ? AND frameworkVersionId = ?",
1540 new int[] { Types.BIGINT, Types.BIGINT });
1541 _persistenceImpl = persistenceImpl;
1542 }
1543
1544 protected void remove(long productVersionId, long frameworkVersionId)
1545 throws SystemException {
1546 if (_persistenceImpl.containsSCFrameworkVersion.contains(
1547 productVersionId, frameworkVersionId)) {
1548 ModelListener<com.liferay.portlet.softwarecatalog.model.SCFrameworkVersion>[] scFrameworkVersionListeners =
1549 scFrameworkVersionPersistence.getListeners();
1550
1551 for (ModelListener<SCProductVersion> listener : listeners) {
1552 listener.onBeforeRemoveAssociation(productVersionId,
1553 com.liferay.portlet.softwarecatalog.model.SCFrameworkVersion.class.getName(),
1554 frameworkVersionId);
1555 }
1556
1557 for (ModelListener<com.liferay.portlet.softwarecatalog.model.SCFrameworkVersion> listener : scFrameworkVersionListeners) {
1558 listener.onBeforeRemoveAssociation(frameworkVersionId,
1559 SCProductVersion.class.getName(), productVersionId);
1560 }
1561
1562 _sqlUpdate.update(new Object[] {
1563 new Long(productVersionId), new Long(frameworkVersionId)
1564 });
1565
1566 for (ModelListener<SCProductVersion> listener : listeners) {
1567 listener.onAfterRemoveAssociation(productVersionId,
1568 com.liferay.portlet.softwarecatalog.model.SCFrameworkVersion.class.getName(),
1569 frameworkVersionId);
1570 }
1571
1572 for (ModelListener<com.liferay.portlet.softwarecatalog.model.SCFrameworkVersion> listener : scFrameworkVersionListeners) {
1573 listener.onAfterRemoveAssociation(frameworkVersionId,
1574 SCProductVersion.class.getName(), productVersionId);
1575 }
1576 }
1577 }
1578
1579 private SqlUpdate _sqlUpdate;
1580 private SCProductVersionPersistenceImpl _persistenceImpl;
1581 }
1582
1583 private static final String _SQL_GETSCFRAMEWORKVERSIONS = "SELECT {SCFrameworkVersion.*} FROM SCFrameworkVersion INNER JOIN SCFrameworkVersi_SCProductVers ON (SCFrameworkVersi_SCProductVers.frameworkVersionId = SCFrameworkVersion.frameworkVersionId) WHERE (SCFrameworkVersi_SCProductVers.productVersionId = ?)";
1584 private static final String _SQL_GETSCFRAMEWORKVERSIONSSIZE = "SELECT COUNT(*) AS COUNT_VALUE FROM SCFrameworkVersi_SCProductVers WHERE productVersionId = ?";
1585 private static final String _SQL_CONTAINSSCFRAMEWORKVERSION = "SELECT COUNT(*) AS COUNT_VALUE FROM SCFrameworkVersi_SCProductVers WHERE productVersionId = ? AND frameworkVersionId = ?";
1586 private static Log _log = LogFactoryUtil.getLog(SCProductVersionPersistenceImpl.class);
1587}