1
14
15 package com.liferay.portlet.softwarecatalog.service.persistence;
16
17 import com.liferay.portal.NoSuchModelException;
18 import com.liferay.portal.SystemException;
19 import com.liferay.portal.kernel.annotation.BeanReference;
20 import com.liferay.portal.kernel.cache.CacheRegistry;
21 import com.liferay.portal.kernel.dao.jdbc.MappingSqlQuery;
22 import com.liferay.portal.kernel.dao.jdbc.MappingSqlQueryFactoryUtil;
23 import com.liferay.portal.kernel.dao.jdbc.RowMapper;
24 import com.liferay.portal.kernel.dao.jdbc.SqlUpdate;
25 import com.liferay.portal.kernel.dao.jdbc.SqlUpdateFactoryUtil;
26 import com.liferay.portal.kernel.dao.orm.DynamicQuery;
27 import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
28 import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
29 import com.liferay.portal.kernel.dao.orm.FinderPath;
30 import com.liferay.portal.kernel.dao.orm.Query;
31 import com.liferay.portal.kernel.dao.orm.QueryPos;
32 import com.liferay.portal.kernel.dao.orm.QueryUtil;
33 import com.liferay.portal.kernel.dao.orm.SQLQuery;
34 import com.liferay.portal.kernel.dao.orm.Session;
35 import com.liferay.portal.kernel.dao.orm.Type;
36 import com.liferay.portal.kernel.log.Log;
37 import com.liferay.portal.kernel.log.LogFactoryUtil;
38 import com.liferay.portal.kernel.util.GetterUtil;
39 import com.liferay.portal.kernel.util.OrderByComparator;
40 import com.liferay.portal.kernel.util.SetUtil;
41 import com.liferay.portal.kernel.util.StringBundler;
42 import com.liferay.portal.kernel.util.StringPool;
43 import com.liferay.portal.kernel.util.StringUtil;
44 import com.liferay.portal.model.ModelListener;
45 import com.liferay.portal.service.persistence.BatchSessionUtil;
46 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
47
48 import com.liferay.portlet.softwarecatalog.NoSuchLicenseException;
49 import com.liferay.portlet.softwarecatalog.model.SCLicense;
50 import com.liferay.portlet.softwarecatalog.model.impl.SCLicenseImpl;
51 import com.liferay.portlet.softwarecatalog.model.impl.SCLicenseModelImpl;
52
53 import java.io.Serializable;
54
55 import java.sql.Types;
56
57 import java.util.ArrayList;
58 import java.util.Collections;
59 import java.util.List;
60 import java.util.Set;
61
62
75 public class SCLicensePersistenceImpl extends BasePersistenceImpl<SCLicense>
76 implements SCLicensePersistence {
77 public static final String FINDER_CLASS_NAME_ENTITY = SCLicenseImpl.class.getName();
78 public static final String FINDER_CLASS_NAME_LIST = FINDER_CLASS_NAME_ENTITY +
79 ".List";
80 public static final FinderPath FINDER_PATH_FIND_BY_ACTIVE = new FinderPath(SCLicenseModelImpl.ENTITY_CACHE_ENABLED,
81 SCLicenseModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
82 "findByActive", new String[] { Boolean.class.getName() });
83 public static final FinderPath FINDER_PATH_FIND_BY_OBC_ACTIVE = new FinderPath(SCLicenseModelImpl.ENTITY_CACHE_ENABLED,
84 SCLicenseModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
85 "findByActive",
86 new String[] {
87 Boolean.class.getName(),
88
89 "java.lang.Integer", "java.lang.Integer",
90 "com.liferay.portal.kernel.util.OrderByComparator"
91 });
92 public static final FinderPath FINDER_PATH_COUNT_BY_ACTIVE = new FinderPath(SCLicenseModelImpl.ENTITY_CACHE_ENABLED,
93 SCLicenseModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
94 "countByActive", new String[] { Boolean.class.getName() });
95 public static final FinderPath FINDER_PATH_FIND_BY_A_R = new FinderPath(SCLicenseModelImpl.ENTITY_CACHE_ENABLED,
96 SCLicenseModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
97 "findByA_R",
98 new String[] { Boolean.class.getName(), Boolean.class.getName() });
99 public static final FinderPath FINDER_PATH_FIND_BY_OBC_A_R = new FinderPath(SCLicenseModelImpl.ENTITY_CACHE_ENABLED,
100 SCLicenseModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
101 "findByA_R",
102 new String[] {
103 Boolean.class.getName(), Boolean.class.getName(),
104
105 "java.lang.Integer", "java.lang.Integer",
106 "com.liferay.portal.kernel.util.OrderByComparator"
107 });
108 public static final FinderPath FINDER_PATH_COUNT_BY_A_R = new FinderPath(SCLicenseModelImpl.ENTITY_CACHE_ENABLED,
109 SCLicenseModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
110 "countByA_R",
111 new String[] { Boolean.class.getName(), Boolean.class.getName() });
112 public static final FinderPath FINDER_PATH_FIND_ALL = new FinderPath(SCLicenseModelImpl.ENTITY_CACHE_ENABLED,
113 SCLicenseModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
114 "findAll", new String[0]);
115 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(SCLicenseModelImpl.ENTITY_CACHE_ENABLED,
116 SCLicenseModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
117 "countAll", new String[0]);
118
119 public void cacheResult(SCLicense scLicense) {
120 EntityCacheUtil.putResult(SCLicenseModelImpl.ENTITY_CACHE_ENABLED,
121 SCLicenseImpl.class, scLicense.getPrimaryKey(), scLicense);
122 }
123
124 public void cacheResult(List<SCLicense> scLicenses) {
125 for (SCLicense scLicense : scLicenses) {
126 if (EntityCacheUtil.getResult(
127 SCLicenseModelImpl.ENTITY_CACHE_ENABLED,
128 SCLicenseImpl.class, scLicense.getPrimaryKey(), this) == null) {
129 cacheResult(scLicense);
130 }
131 }
132 }
133
134 public void clearCache() {
135 CacheRegistry.clear(SCLicenseImpl.class.getName());
136 EntityCacheUtil.clearCache(SCLicenseImpl.class.getName());
137 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
138 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
139 }
140
141 public SCLicense create(long licenseId) {
142 SCLicense scLicense = new SCLicenseImpl();
143
144 scLicense.setNew(true);
145 scLicense.setPrimaryKey(licenseId);
146
147 return scLicense;
148 }
149
150 public SCLicense remove(Serializable primaryKey)
151 throws NoSuchModelException, SystemException {
152 return remove(((Long)primaryKey).longValue());
153 }
154
155 public SCLicense remove(long licenseId)
156 throws NoSuchLicenseException, SystemException {
157 Session session = null;
158
159 try {
160 session = openSession();
161
162 SCLicense scLicense = (SCLicense)session.get(SCLicenseImpl.class,
163 new Long(licenseId));
164
165 if (scLicense == null) {
166 if (_log.isWarnEnabled()) {
167 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + licenseId);
168 }
169
170 throw new NoSuchLicenseException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
171 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(SCLicenseModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME);
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 public SCLicense updateImpl(
261 com.liferay.portlet.softwarecatalog.model.SCLicense scLicense,
262 boolean merge) throws SystemException {
263 scLicense = toUnwrappedModel(scLicense);
264
265 Session session = null;
266
267 try {
268 session = openSession();
269
270 BatchSessionUtil.update(session, scLicense, merge);
271
272 scLicense.setNew(false);
273 }
274 catch (Exception e) {
275 throw processException(e);
276 }
277 finally {
278 closeSession(session);
279 }
280
281 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
282
283 EntityCacheUtil.putResult(SCLicenseModelImpl.ENTITY_CACHE_ENABLED,
284 SCLicenseImpl.class, scLicense.getPrimaryKey(), scLicense);
285
286 return scLicense;
287 }
288
289 protected SCLicense toUnwrappedModel(SCLicense scLicense) {
290 if (scLicense instanceof SCLicenseImpl) {
291 return scLicense;
292 }
293
294 SCLicenseImpl scLicenseImpl = new SCLicenseImpl();
295
296 scLicenseImpl.setNew(scLicense.isNew());
297 scLicenseImpl.setPrimaryKey(scLicense.getPrimaryKey());
298
299 scLicenseImpl.setLicenseId(scLicense.getLicenseId());
300 scLicenseImpl.setName(scLicense.getName());
301 scLicenseImpl.setUrl(scLicense.getUrl());
302 scLicenseImpl.setOpenSource(scLicense.isOpenSource());
303 scLicenseImpl.setActive(scLicense.isActive());
304 scLicenseImpl.setRecommended(scLicense.isRecommended());
305
306 return scLicenseImpl;
307 }
308
309 public SCLicense findByPrimaryKey(Serializable primaryKey)
310 throws NoSuchModelException, SystemException {
311 return findByPrimaryKey(((Long)primaryKey).longValue());
312 }
313
314 public SCLicense findByPrimaryKey(long licenseId)
315 throws NoSuchLicenseException, SystemException {
316 SCLicense scLicense = fetchByPrimaryKey(licenseId);
317
318 if (scLicense == null) {
319 if (_log.isWarnEnabled()) {
320 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + licenseId);
321 }
322
323 throw new NoSuchLicenseException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
324 licenseId);
325 }
326
327 return scLicense;
328 }
329
330 public SCLicense fetchByPrimaryKey(Serializable primaryKey)
331 throws SystemException {
332 return fetchByPrimaryKey(((Long)primaryKey).longValue());
333 }
334
335 public SCLicense fetchByPrimaryKey(long licenseId)
336 throws SystemException {
337 SCLicense scLicense = (SCLicense)EntityCacheUtil.getResult(SCLicenseModelImpl.ENTITY_CACHE_ENABLED,
338 SCLicenseImpl.class, licenseId, this);
339
340 if (scLicense == null) {
341 Session session = null;
342
343 try {
344 session = openSession();
345
346 scLicense = (SCLicense)session.get(SCLicenseImpl.class,
347 new Long(licenseId));
348 }
349 catch (Exception e) {
350 throw processException(e);
351 }
352 finally {
353 if (scLicense != null) {
354 cacheResult(scLicense);
355 }
356
357 closeSession(session);
358 }
359 }
360
361 return scLicense;
362 }
363
364 public List<SCLicense> findByActive(boolean active)
365 throws SystemException {
366 Object[] finderArgs = new Object[] { Boolean.valueOf(active) };
367
368 List<SCLicense> list = (List<SCLicense>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_ACTIVE,
369 finderArgs, this);
370
371 if (list == null) {
372 Session session = null;
373
374 try {
375 session = openSession();
376
377 StringBundler query = new StringBundler(3);
378
379 query.append(_SQL_SELECT_SCLICENSE_WHERE);
380
381 query.append(_FINDER_COLUMN_ACTIVE_ACTIVE_2);
382
383 query.append(SCLicenseModelImpl.ORDER_BY_JPQL);
384
385 String sql = query.toString();
386
387 Query q = session.createQuery(sql);
388
389 QueryPos qPos = QueryPos.getInstance(q);
390
391 qPos.add(active);
392
393 list = q.list();
394 }
395 catch (Exception e) {
396 throw processException(e);
397 }
398 finally {
399 if (list == null) {
400 list = new ArrayList<SCLicense>();
401 }
402
403 cacheResult(list);
404
405 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_ACTIVE,
406 finderArgs, list);
407
408 closeSession(session);
409 }
410 }
411
412 return list;
413 }
414
415 public List<SCLicense> findByActive(boolean active, int start, int end)
416 throws SystemException {
417 return findByActive(active, start, end, null);
418 }
419
420 public List<SCLicense> findByActive(boolean active, int start, int end,
421 OrderByComparator obc) throws SystemException {
422 Object[] finderArgs = new Object[] {
423 Boolean.valueOf(active),
424
425 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
426 };
427
428 List<SCLicense> list = (List<SCLicense>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_ACTIVE,
429 finderArgs, this);
430
431 if (list == null) {
432 Session session = null;
433
434 try {
435 session = openSession();
436
437 StringBundler query = null;
438
439 if (obc != null) {
440 query = new StringBundler(3 +
441 (obc.getOrderByFields().length * 3));
442 }
443 else {
444 query = new StringBundler(3);
445 }
446
447 query.append(_SQL_SELECT_SCLICENSE_WHERE);
448
449 query.append(_FINDER_COLUMN_ACTIVE_ACTIVE_2);
450
451 if (obc != null) {
452 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, obc);
453 }
454
455 else {
456 query.append(SCLicenseModelImpl.ORDER_BY_JPQL);
457 }
458
459 String sql = query.toString();
460
461 Query q = session.createQuery(sql);
462
463 QueryPos qPos = QueryPos.getInstance(q);
464
465 qPos.add(active);
466
467 list = (List<SCLicense>)QueryUtil.list(q, getDialect(), start,
468 end);
469 }
470 catch (Exception e) {
471 throw processException(e);
472 }
473 finally {
474 if (list == null) {
475 list = new ArrayList<SCLicense>();
476 }
477
478 cacheResult(list);
479
480 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_ACTIVE,
481 finderArgs, list);
482
483 closeSession(session);
484 }
485 }
486
487 return list;
488 }
489
490 public SCLicense findByActive_First(boolean active, OrderByComparator obc)
491 throws NoSuchLicenseException, SystemException {
492 List<SCLicense> list = findByActive(active, 0, 1, obc);
493
494 if (list.isEmpty()) {
495 StringBundler msg = new StringBundler(4);
496
497 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
498
499 msg.append("active=");
500 msg.append(active);
501
502 msg.append(StringPool.CLOSE_CURLY_BRACE);
503
504 throw new NoSuchLicenseException(msg.toString());
505 }
506 else {
507 return list.get(0);
508 }
509 }
510
511 public SCLicense findByActive_Last(boolean active, OrderByComparator obc)
512 throws NoSuchLicenseException, SystemException {
513 int count = countByActive(active);
514
515 List<SCLicense> list = findByActive(active, count - 1, count, obc);
516
517 if (list.isEmpty()) {
518 StringBundler msg = new StringBundler(4);
519
520 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
521
522 msg.append("active=");
523 msg.append(active);
524
525 msg.append(StringPool.CLOSE_CURLY_BRACE);
526
527 throw new NoSuchLicenseException(msg.toString());
528 }
529 else {
530 return list.get(0);
531 }
532 }
533
534 public SCLicense[] findByActive_PrevAndNext(long licenseId, boolean active,
535 OrderByComparator obc) throws NoSuchLicenseException, SystemException {
536 SCLicense scLicense = findByPrimaryKey(licenseId);
537
538 int count = countByActive(active);
539
540 Session session = null;
541
542 try {
543 session = openSession();
544
545 StringBundler query = null;
546
547 if (obc != null) {
548 query = new StringBundler(3 +
549 (obc.getOrderByFields().length * 3));
550 }
551 else {
552 query = new StringBundler(3);
553 }
554
555 query.append(_SQL_SELECT_SCLICENSE_WHERE);
556
557 query.append(_FINDER_COLUMN_ACTIVE_ACTIVE_2);
558
559 if (obc != null) {
560 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, obc);
561 }
562
563 else {
564 query.append(SCLicenseModelImpl.ORDER_BY_JPQL);
565 }
566
567 String sql = query.toString();
568
569 Query q = session.createQuery(sql);
570
571 QueryPos qPos = QueryPos.getInstance(q);
572
573 qPos.add(active);
574
575 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
576 scLicense);
577
578 SCLicense[] array = new SCLicenseImpl[3];
579
580 array[0] = (SCLicense)objArray[0];
581 array[1] = (SCLicense)objArray[1];
582 array[2] = (SCLicense)objArray[2];
583
584 return array;
585 }
586 catch (Exception e) {
587 throw processException(e);
588 }
589 finally {
590 closeSession(session);
591 }
592 }
593
594 public List<SCLicense> findByA_R(boolean active, boolean recommended)
595 throws SystemException {
596 Object[] finderArgs = new Object[] {
597 Boolean.valueOf(active), Boolean.valueOf(recommended)
598 };
599
600 List<SCLicense> list = (List<SCLicense>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_A_R,
601 finderArgs, this);
602
603 if (list == null) {
604 Session session = null;
605
606 try {
607 session = openSession();
608
609 StringBundler query = new StringBundler(4);
610
611 query.append(_SQL_SELECT_SCLICENSE_WHERE);
612
613 query.append(_FINDER_COLUMN_A_R_ACTIVE_2);
614
615 query.append(_FINDER_COLUMN_A_R_RECOMMENDED_2);
616
617 query.append(SCLicenseModelImpl.ORDER_BY_JPQL);
618
619 String sql = query.toString();
620
621 Query q = session.createQuery(sql);
622
623 QueryPos qPos = QueryPos.getInstance(q);
624
625 qPos.add(active);
626
627 qPos.add(recommended);
628
629 list = q.list();
630 }
631 catch (Exception e) {
632 throw processException(e);
633 }
634 finally {
635 if (list == null) {
636 list = new ArrayList<SCLicense>();
637 }
638
639 cacheResult(list);
640
641 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_A_R, finderArgs,
642 list);
643
644 closeSession(session);
645 }
646 }
647
648 return list;
649 }
650
651 public List<SCLicense> findByA_R(boolean active, boolean recommended,
652 int start, int end) throws SystemException {
653 return findByA_R(active, recommended, start, end, null);
654 }
655
656 public List<SCLicense> findByA_R(boolean active, boolean recommended,
657 int start, int end, OrderByComparator obc) throws SystemException {
658 Object[] finderArgs = new Object[] {
659 Boolean.valueOf(active), Boolean.valueOf(recommended),
660
661 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
662 };
663
664 List<SCLicense> list = (List<SCLicense>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_A_R,
665 finderArgs, this);
666
667 if (list == null) {
668 Session session = null;
669
670 try {
671 session = openSession();
672
673 StringBundler query = null;
674
675 if (obc != null) {
676 query = new StringBundler(4 +
677 (obc.getOrderByFields().length * 3));
678 }
679 else {
680 query = new StringBundler(4);
681 }
682
683 query.append(_SQL_SELECT_SCLICENSE_WHERE);
684
685 query.append(_FINDER_COLUMN_A_R_ACTIVE_2);
686
687 query.append(_FINDER_COLUMN_A_R_RECOMMENDED_2);
688
689 if (obc != null) {
690 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, obc);
691 }
692
693 else {
694 query.append(SCLicenseModelImpl.ORDER_BY_JPQL);
695 }
696
697 String sql = query.toString();
698
699 Query q = session.createQuery(sql);
700
701 QueryPos qPos = QueryPos.getInstance(q);
702
703 qPos.add(active);
704
705 qPos.add(recommended);
706
707 list = (List<SCLicense>)QueryUtil.list(q, getDialect(), start,
708 end);
709 }
710 catch (Exception e) {
711 throw processException(e);
712 }
713 finally {
714 if (list == null) {
715 list = new ArrayList<SCLicense>();
716 }
717
718 cacheResult(list);
719
720 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_A_R,
721 finderArgs, list);
722
723 closeSession(session);
724 }
725 }
726
727 return list;
728 }
729
730 public SCLicense findByA_R_First(boolean active, boolean recommended,
731 OrderByComparator obc) throws NoSuchLicenseException, SystemException {
732 List<SCLicense> list = findByA_R(active, recommended, 0, 1, obc);
733
734 if (list.isEmpty()) {
735 StringBundler msg = new StringBundler(6);
736
737 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
738
739 msg.append("active=");
740 msg.append(active);
741
742 msg.append(", recommended=");
743 msg.append(recommended);
744
745 msg.append(StringPool.CLOSE_CURLY_BRACE);
746
747 throw new NoSuchLicenseException(msg.toString());
748 }
749 else {
750 return list.get(0);
751 }
752 }
753
754 public SCLicense findByA_R_Last(boolean active, boolean recommended,
755 OrderByComparator obc) throws NoSuchLicenseException, SystemException {
756 int count = countByA_R(active, recommended);
757
758 List<SCLicense> list = findByA_R(active, recommended, count - 1, count,
759 obc);
760
761 if (list.isEmpty()) {
762 StringBundler msg = new StringBundler(6);
763
764 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
765
766 msg.append("active=");
767 msg.append(active);
768
769 msg.append(", recommended=");
770 msg.append(recommended);
771
772 msg.append(StringPool.CLOSE_CURLY_BRACE);
773
774 throw new NoSuchLicenseException(msg.toString());
775 }
776 else {
777 return list.get(0);
778 }
779 }
780
781 public SCLicense[] findByA_R_PrevAndNext(long licenseId, boolean active,
782 boolean recommended, OrderByComparator obc)
783 throws NoSuchLicenseException, SystemException {
784 SCLicense scLicense = findByPrimaryKey(licenseId);
785
786 int count = countByA_R(active, recommended);
787
788 Session session = null;
789
790 try {
791 session = openSession();
792
793 StringBundler query = null;
794
795 if (obc != null) {
796 query = new StringBundler(4 +
797 (obc.getOrderByFields().length * 3));
798 }
799 else {
800 query = new StringBundler(4);
801 }
802
803 query.append(_SQL_SELECT_SCLICENSE_WHERE);
804
805 query.append(_FINDER_COLUMN_A_R_ACTIVE_2);
806
807 query.append(_FINDER_COLUMN_A_R_RECOMMENDED_2);
808
809 if (obc != null) {
810 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, obc);
811 }
812
813 else {
814 query.append(SCLicenseModelImpl.ORDER_BY_JPQL);
815 }
816
817 String sql = query.toString();
818
819 Query q = session.createQuery(sql);
820
821 QueryPos qPos = QueryPos.getInstance(q);
822
823 qPos.add(active);
824
825 qPos.add(recommended);
826
827 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
828 scLicense);
829
830 SCLicense[] array = new SCLicenseImpl[3];
831
832 array[0] = (SCLicense)objArray[0];
833 array[1] = (SCLicense)objArray[1];
834 array[2] = (SCLicense)objArray[2];
835
836 return array;
837 }
838 catch (Exception e) {
839 throw processException(e);
840 }
841 finally {
842 closeSession(session);
843 }
844 }
845
846 public List<Object> findWithDynamicQuery(DynamicQuery dynamicQuery)
847 throws SystemException {
848 Session session = null;
849
850 try {
851 session = openSession();
852
853 dynamicQuery.compile(session);
854
855 return dynamicQuery.list();
856 }
857 catch (Exception e) {
858 throw processException(e);
859 }
860 finally {
861 closeSession(session);
862 }
863 }
864
865 public List<Object> findWithDynamicQuery(DynamicQuery dynamicQuery,
866 int start, int end) throws SystemException {
867 Session session = null;
868
869 try {
870 session = openSession();
871
872 dynamicQuery.setLimit(start, end);
873
874 dynamicQuery.compile(session);
875
876 return dynamicQuery.list();
877 }
878 catch (Exception e) {
879 throw processException(e);
880 }
881 finally {
882 closeSession(session);
883 }
884 }
885
886 public List<SCLicense> findAll() throws SystemException {
887 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
888 }
889
890 public List<SCLicense> findAll(int start, int end)
891 throws SystemException {
892 return findAll(start, end, null);
893 }
894
895 public List<SCLicense> findAll(int start, int end, OrderByComparator obc)
896 throws SystemException {
897 Object[] finderArgs = new Object[] {
898 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
899 };
900
901 List<SCLicense> list = (List<SCLicense>)FinderCacheUtil.getResult(FINDER_PATH_FIND_ALL,
902 finderArgs, this);
903
904 if (list == null) {
905 Session session = null;
906
907 try {
908 session = openSession();
909
910 StringBundler query = null;
911 String sql = null;
912
913 if (obc != null) {
914 query = new StringBundler(2 +
915 (obc.getOrderByFields().length * 3));
916
917 query.append(_SQL_SELECT_SCLICENSE);
918
919 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, obc);
920
921 sql = query.toString();
922 }
923
924 else {
925 sql = _SQL_SELECT_SCLICENSE.concat(SCLicenseModelImpl.ORDER_BY_JPQL);
926 }
927
928 Query q = session.createQuery(sql);
929
930 if (obc == null) {
931 list = (List<SCLicense>)QueryUtil.list(q, getDialect(),
932 start, end, false);
933
934 Collections.sort(list);
935 }
936 else {
937 list = (List<SCLicense>)QueryUtil.list(q, getDialect(),
938 start, end);
939 }
940 }
941 catch (Exception e) {
942 throw processException(e);
943 }
944 finally {
945 if (list == null) {
946 list = new ArrayList<SCLicense>();
947 }
948
949 cacheResult(list);
950
951 FinderCacheUtil.putResult(FINDER_PATH_FIND_ALL, finderArgs, list);
952
953 closeSession(session);
954 }
955 }
956
957 return list;
958 }
959
960 public void removeByActive(boolean active) throws SystemException {
961 for (SCLicense scLicense : findByActive(active)) {
962 remove(scLicense);
963 }
964 }
965
966 public void removeByA_R(boolean active, boolean recommended)
967 throws SystemException {
968 for (SCLicense scLicense : findByA_R(active, recommended)) {
969 remove(scLicense);
970 }
971 }
972
973 public void removeAll() throws SystemException {
974 for (SCLicense scLicense : findAll()) {
975 remove(scLicense);
976 }
977 }
978
979 public int countByActive(boolean active) throws SystemException {
980 Object[] finderArgs = new Object[] { Boolean.valueOf(active) };
981
982 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_ACTIVE,
983 finderArgs, this);
984
985 if (count == null) {
986 Session session = null;
987
988 try {
989 session = openSession();
990
991 StringBundler query = new StringBundler(2);
992
993 query.append(_SQL_COUNT_SCLICENSE_WHERE);
994
995 query.append(_FINDER_COLUMN_ACTIVE_ACTIVE_2);
996
997 String sql = query.toString();
998
999 Query q = session.createQuery(sql);
1000
1001 QueryPos qPos = QueryPos.getInstance(q);
1002
1003 qPos.add(active);
1004
1005 count = (Long)q.uniqueResult();
1006 }
1007 catch (Exception e) {
1008 throw processException(e);
1009 }
1010 finally {
1011 if (count == null) {
1012 count = Long.valueOf(0);
1013 }
1014
1015 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_ACTIVE,
1016 finderArgs, count);
1017
1018 closeSession(session);
1019 }
1020 }
1021
1022 return count.intValue();
1023 }
1024
1025 public int countByA_R(boolean active, boolean recommended)
1026 throws SystemException {
1027 Object[] finderArgs = new Object[] {
1028 Boolean.valueOf(active), Boolean.valueOf(recommended)
1029 };
1030
1031 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_A_R,
1032 finderArgs, this);
1033
1034 if (count == null) {
1035 Session session = null;
1036
1037 try {
1038 session = openSession();
1039
1040 StringBundler query = new StringBundler(3);
1041
1042 query.append(_SQL_COUNT_SCLICENSE_WHERE);
1043
1044 query.append(_FINDER_COLUMN_A_R_ACTIVE_2);
1045
1046 query.append(_FINDER_COLUMN_A_R_RECOMMENDED_2);
1047
1048 String sql = query.toString();
1049
1050 Query q = session.createQuery(sql);
1051
1052 QueryPos qPos = QueryPos.getInstance(q);
1053
1054 qPos.add(active);
1055
1056 qPos.add(recommended);
1057
1058 count = (Long)q.uniqueResult();
1059 }
1060 catch (Exception e) {
1061 throw processException(e);
1062 }
1063 finally {
1064 if (count == null) {
1065 count = Long.valueOf(0);
1066 }
1067
1068 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_A_R, finderArgs,
1069 count);
1070
1071 closeSession(session);
1072 }
1073 }
1074
1075 return count.intValue();
1076 }
1077
1078 public int countAll() throws SystemException {
1079 Object[] finderArgs = new Object[0];
1080
1081 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
1082 finderArgs, this);
1083
1084 if (count == null) {
1085 Session session = null;
1086
1087 try {
1088 session = openSession();
1089
1090 Query q = session.createQuery(_SQL_COUNT_SCLICENSE);
1091
1092 count = (Long)q.uniqueResult();
1093 }
1094 catch (Exception e) {
1095 throw processException(e);
1096 }
1097 finally {
1098 if (count == null) {
1099 count = Long.valueOf(0);
1100 }
1101
1102 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL, finderArgs,
1103 count);
1104
1105 closeSession(session);
1106 }
1107 }
1108
1109 return count.intValue();
1110 }
1111
1112 public List<com.liferay.portlet.softwarecatalog.model.SCProductEntry> getSCProductEntries(
1113 long pk) throws SystemException {
1114 return getSCProductEntries(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
1115 }
1116
1117 public List<com.liferay.portlet.softwarecatalog.model.SCProductEntry> getSCProductEntries(
1118 long pk, int start, int end) throws SystemException {
1119 return getSCProductEntries(pk, start, end, null);
1120 }
1121
1122 public static final FinderPath FINDER_PATH_GET_SCPRODUCTENTRIES = new FinderPath(com.liferay.portlet.softwarecatalog.model.impl.SCProductEntryModelImpl.ENTITY_CACHE_ENABLED,
1123 SCLicenseModelImpl.FINDER_CACHE_ENABLED_SCLICENSES_SCPRODUCTENTRIES,
1124 SCLicenseModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME,
1125 "getSCProductEntries",
1126 new String[] {
1127 Long.class.getName(), "java.lang.Integer", "java.lang.Integer",
1128 "com.liferay.portal.kernel.util.OrderByComparator"
1129 });
1130
1131 public List<com.liferay.portlet.softwarecatalog.model.SCProductEntry> getSCProductEntries(
1132 long pk, int start, int end, OrderByComparator obc)
1133 throws SystemException {
1134 Object[] finderArgs = new Object[] {
1135 new Long(pk), String.valueOf(start), String.valueOf(end),
1136 String.valueOf(obc)
1137 };
1138
1139 List<com.liferay.portlet.softwarecatalog.model.SCProductEntry> list = (List<com.liferay.portlet.softwarecatalog.model.SCProductEntry>)FinderCacheUtil.getResult(FINDER_PATH_GET_SCPRODUCTENTRIES,
1140 finderArgs, this);
1141
1142 if (list == null) {
1143 Session session = null;
1144
1145 try {
1146 session = openSession();
1147
1148 String sql = null;
1149
1150 if (obc != null) {
1151 sql = _SQL_GETSCPRODUCTENTRIES.concat(ORDER_BY_CLAUSE)
1152 .concat(obc.getOrderBy());
1153 }
1154
1155 else {
1156 sql = _SQL_GETSCPRODUCTENTRIES.concat(com.liferay.portlet.softwarecatalog.model.impl.SCProductEntryModelImpl.ORDER_BY_SQL);
1157 }
1158
1159 SQLQuery q = session.createSQLQuery(sql);
1160
1161 q.addEntity("SCProductEntry",
1162 com.liferay.portlet.softwarecatalog.model.impl.SCProductEntryImpl.class);
1163
1164 QueryPos qPos = QueryPos.getInstance(q);
1165
1166 qPos.add(pk);
1167
1168 list = (List<com.liferay.portlet.softwarecatalog.model.SCProductEntry>)QueryUtil.list(q,
1169 getDialect(), start, end);
1170 }
1171 catch (Exception e) {
1172 throw processException(e);
1173 }
1174 finally {
1175 if (list == null) {
1176 list = new ArrayList<com.liferay.portlet.softwarecatalog.model.SCProductEntry>();
1177 }
1178
1179 scProductEntryPersistence.cacheResult(list);
1180
1181 FinderCacheUtil.putResult(FINDER_PATH_GET_SCPRODUCTENTRIES,
1182 finderArgs, list);
1183
1184 closeSession(session);
1185 }
1186 }
1187
1188 return list;
1189 }
1190
1191 public static final FinderPath FINDER_PATH_GET_SCPRODUCTENTRIES_SIZE = new FinderPath(com.liferay.portlet.softwarecatalog.model.impl.SCProductEntryModelImpl.ENTITY_CACHE_ENABLED,
1192 SCLicenseModelImpl.FINDER_CACHE_ENABLED_SCLICENSES_SCPRODUCTENTRIES,
1193 SCLicenseModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME,
1194 "getSCProductEntriesSize", new String[] { Long.class.getName() });
1195
1196 public int getSCProductEntriesSize(long pk) throws SystemException {
1197 Object[] finderArgs = new Object[] { new Long(pk) };
1198
1199 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_GET_SCPRODUCTENTRIES_SIZE,
1200 finderArgs, this);
1201
1202 if (count == null) {
1203 Session session = null;
1204
1205 try {
1206 session = openSession();
1207
1208 SQLQuery q = session.createSQLQuery(_SQL_GETSCPRODUCTENTRIESSIZE);
1209
1210 q.addScalar(COUNT_COLUMN_NAME, Type.LONG);
1211
1212 QueryPos qPos = QueryPos.getInstance(q);
1213
1214 qPos.add(pk);
1215
1216 count = (Long)q.uniqueResult();
1217 }
1218 catch (Exception e) {
1219 throw processException(e);
1220 }
1221 finally {
1222 if (count == null) {
1223 count = Long.valueOf(0);
1224 }
1225
1226 FinderCacheUtil.putResult(FINDER_PATH_GET_SCPRODUCTENTRIES_SIZE,
1227 finderArgs, count);
1228
1229 closeSession(session);
1230 }
1231 }
1232
1233 return count.intValue();
1234 }
1235
1236 public static final FinderPath FINDER_PATH_CONTAINS_SCPRODUCTENTRY = new FinderPath(com.liferay.portlet.softwarecatalog.model.impl.SCProductEntryModelImpl.ENTITY_CACHE_ENABLED,
1237 SCLicenseModelImpl.FINDER_CACHE_ENABLED_SCLICENSES_SCPRODUCTENTRIES,
1238 SCLicenseModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME,
1239 "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(SCLicenseModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME);
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(SCLicenseModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME);
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(SCLicenseModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME);
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(SCLicenseModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME);
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(SCLicenseModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME);
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(SCLicenseModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME);
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(SCLicenseModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME);
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(SCLicenseModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME);
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(SCLicenseModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME);
1408 }
1409 }
1410
1411 public void setSCProductEntries(long pk, long[] scProductEntryPKs)
1412 throws SystemException {
1413 try {
1414 Set<Long> scProductEntryPKSet = SetUtil.fromArray(scProductEntryPKs);
1415
1416 List<com.liferay.portlet.softwarecatalog.model.SCProductEntry> scProductEntries =
1417 getSCProductEntries(pk);
1418
1419 for (com.liferay.portlet.softwarecatalog.model.SCProductEntry scProductEntry : scProductEntries) {
1420 if (!scProductEntryPKSet.contains(
1421 scProductEntry.getPrimaryKey())) {
1422 removeSCProductEntry.remove(pk,
1423 scProductEntry.getPrimaryKey());
1424 }
1425 else {
1426 scProductEntryPKSet.remove(scProductEntry.getPrimaryKey());
1427 }
1428 }
1429
1430 for (Long scProductEntryPK : scProductEntryPKSet) {
1431 addSCProductEntry.add(pk, scProductEntryPK);
1432 }
1433 }
1434 catch (Exception e) {
1435 throw processException(e);
1436 }
1437 finally {
1438 FinderCacheUtil.clearCache(SCLicenseModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME);
1439 }
1440 }
1441
1442 public void setSCProductEntries(long pk,
1443 List<com.liferay.portlet.softwarecatalog.model.SCProductEntry> scProductEntries)
1444 throws SystemException {
1445 try {
1446 long[] scProductEntryPKs = new long[scProductEntries.size()];
1447
1448 for (int i = 0; i < scProductEntries.size(); i++) {
1449 com.liferay.portlet.softwarecatalog.model.SCProductEntry scProductEntry =
1450 scProductEntries.get(i);
1451
1452 scProductEntryPKs[i] = scProductEntry.getPrimaryKey();
1453 }
1454
1455 setSCProductEntries(pk, scProductEntryPKs);
1456 }
1457 catch (Exception e) {
1458 throw processException(e);
1459 }
1460 finally {
1461 FinderCacheUtil.clearCache(SCLicenseModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME);
1462 }
1463 }
1464
1465 public void afterPropertiesSet() {
1466 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
1467 com.liferay.portal.util.PropsUtil.get(
1468 "value.object.listener.com.liferay.portlet.softwarecatalog.model.SCLicense")));
1469
1470 if (listenerClassNames.length > 0) {
1471 try {
1472 List<ModelListener<SCLicense>> listenersList = new ArrayList<ModelListener<SCLicense>>();
1473
1474 for (String listenerClassName : listenerClassNames) {
1475 listenersList.add((ModelListener<SCLicense>)Class.forName(
1476 listenerClassName).newInstance());
1477 }
1478
1479 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
1480 }
1481 catch (Exception e) {
1482 _log.error(e);
1483 }
1484 }
1485
1486 containsSCProductEntry = new ContainsSCProductEntry(this);
1487
1488 addSCProductEntry = new AddSCProductEntry(this);
1489 clearSCProductEntries = new ClearSCProductEntries(this);
1490 removeSCProductEntry = new RemoveSCProductEntry(this);
1491 }
1492
1493 @BeanReference(name = "com.liferay.portlet.softwarecatalog.service.persistence.SCLicensePersistence")
1494 protected com.liferay.portlet.softwarecatalog.service.persistence.SCLicensePersistence scLicensePersistence;
1495 @BeanReference(name = "com.liferay.portlet.softwarecatalog.service.persistence.SCFrameworkVersionPersistence")
1496 protected com.liferay.portlet.softwarecatalog.service.persistence.SCFrameworkVersionPersistence scFrameworkVersionPersistence;
1497 @BeanReference(name = "com.liferay.portlet.softwarecatalog.service.persistence.SCProductEntryPersistence")
1498 protected com.liferay.portlet.softwarecatalog.service.persistence.SCProductEntryPersistence scProductEntryPersistence;
1499 @BeanReference(name = "com.liferay.portlet.softwarecatalog.service.persistence.SCProductScreenshotPersistence")
1500 protected com.liferay.portlet.softwarecatalog.service.persistence.SCProductScreenshotPersistence scProductScreenshotPersistence;
1501 @BeanReference(name = "com.liferay.portlet.softwarecatalog.service.persistence.SCProductVersionPersistence")
1502 protected com.liferay.portlet.softwarecatalog.service.persistence.SCProductVersionPersistence scProductVersionPersistence;
1503 @BeanReference(name = "com.liferay.portal.service.persistence.ResourcePersistence")
1504 protected com.liferay.portal.service.persistence.ResourcePersistence resourcePersistence;
1505 @BeanReference(name = "com.liferay.portal.service.persistence.UserPersistence")
1506 protected com.liferay.portal.service.persistence.UserPersistence userPersistence;
1507 protected ContainsSCProductEntry containsSCProductEntry;
1508 protected AddSCProductEntry addSCProductEntry;
1509 protected ClearSCProductEntries clearSCProductEntries;
1510 protected RemoveSCProductEntry removeSCProductEntry;
1511
1512 protected class ContainsSCProductEntry {
1513 protected ContainsSCProductEntry(
1514 SCLicensePersistenceImpl persistenceImpl) {
1515 super();
1516
1517 _mappingSqlQuery = MappingSqlQueryFactoryUtil.getMappingSqlQuery(getDataSource(),
1518 _SQL_CONTAINSSCPRODUCTENTRY,
1519 new int[] { Types.BIGINT, Types.BIGINT }, RowMapper.COUNT);
1520 }
1521
1522 protected boolean contains(long licenseId, long productEntryId) {
1523 List<Integer> results = _mappingSqlQuery.execute(new Object[] {
1524 new Long(licenseId), new Long(productEntryId)
1525 });
1526
1527 if (results.size() > 0) {
1528 Integer count = results.get(0);
1529
1530 if (count.intValue() > 0) {
1531 return true;
1532 }
1533 }
1534
1535 return false;
1536 }
1537
1538 private MappingSqlQuery _mappingSqlQuery;
1539 }
1540
1541 protected class AddSCProductEntry {
1542 protected AddSCProductEntry(SCLicensePersistenceImpl persistenceImpl) {
1543 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
1544 "INSERT INTO SCLicenses_SCProductEntries (licenseId, productEntryId) VALUES (?, ?)",
1545 new int[] { Types.BIGINT, Types.BIGINT });
1546 _persistenceImpl = persistenceImpl;
1547 }
1548
1549 protected void add(long licenseId, long productEntryId) {
1550 if (!_persistenceImpl.containsSCProductEntry.contains(licenseId,
1551 productEntryId)) {
1552 _sqlUpdate.update(new Object[] {
1553 new Long(licenseId), new Long(productEntryId)
1554 });
1555 }
1556 }
1557
1558 private SqlUpdate _sqlUpdate;
1559 private SCLicensePersistenceImpl _persistenceImpl;
1560 }
1561
1562 protected class ClearSCProductEntries {
1563 protected ClearSCProductEntries(
1564 SCLicensePersistenceImpl persistenceImpl) {
1565 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
1566 "DELETE FROM SCLicenses_SCProductEntries WHERE licenseId = ?",
1567 new int[] { Types.BIGINT });
1568 }
1569
1570 protected void clear(long licenseId) {
1571 _sqlUpdate.update(new Object[] { new Long(licenseId) });
1572 }
1573
1574 private SqlUpdate _sqlUpdate;
1575 }
1576
1577 protected class RemoveSCProductEntry {
1578 protected RemoveSCProductEntry(SCLicensePersistenceImpl persistenceImpl) {
1579 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
1580 "DELETE FROM SCLicenses_SCProductEntries WHERE licenseId = ? AND productEntryId = ?",
1581 new int[] { Types.BIGINT, Types.BIGINT });
1582 }
1583
1584 protected void remove(long licenseId, long productEntryId) {
1585 _sqlUpdate.update(new Object[] {
1586 new Long(licenseId), new Long(productEntryId)
1587 });
1588 }
1589
1590 private SqlUpdate _sqlUpdate;
1591 }
1592
1593 private static final String _SQL_SELECT_SCLICENSE = "SELECT scLicense FROM SCLicense scLicense";
1594 private static final String _SQL_SELECT_SCLICENSE_WHERE = "SELECT scLicense FROM SCLicense scLicense WHERE ";
1595 private static final String _SQL_COUNT_SCLICENSE = "SELECT COUNT(scLicense) FROM SCLicense scLicense";
1596 private static final String _SQL_COUNT_SCLICENSE_WHERE = "SELECT COUNT(scLicense) FROM SCLicense scLicense WHERE ";
1597 private static final String _SQL_GETSCPRODUCTENTRIES = "SELECT {SCProductEntry.*} FROM SCProductEntry INNER JOIN SCLicenses_SCProductEntries ON (SCLicenses_SCProductEntries.productEntryId = SCProductEntry.productEntryId) WHERE (SCLicenses_SCProductEntries.licenseId = ?)";
1598 private static final String _SQL_GETSCPRODUCTENTRIESSIZE = "SELECT COUNT(*) AS COUNT_VALUE FROM SCLicenses_SCProductEntries WHERE licenseId = ?";
1599 private static final String _SQL_CONTAINSSCPRODUCTENTRY = "SELECT COUNT(*) AS COUNT_VALUE FROM SCLicenses_SCProductEntries WHERE licenseId = ? AND productEntryId = ?";
1600 private static final String _FINDER_COLUMN_ACTIVE_ACTIVE_2 = "scLicense.active = ?";
1601 private static final String _FINDER_COLUMN_A_R_ACTIVE_2 = "scLicense.active = ? AND ";
1602 private static final String _FINDER_COLUMN_A_R_RECOMMENDED_2 = "scLicense.recommended = ?";
1603 private static final String _ORDER_BY_ENTITY_ALIAS = "scLicense.";
1604 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No SCLicense exists with the primary key ";
1605 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No SCLicense exists with the key {";
1606 private static Log _log = LogFactoryUtil.getLog(SCLicensePersistenceImpl.class);
1607}