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