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