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