1
19
20 package com.liferay.portlet.softwarecatalog.service.persistence;
21
22 import com.liferay.portal.SystemException;
23 import com.liferay.portal.kernel.annotation.BeanReference;
24 import com.liferay.portal.kernel.cache.CacheRegistry;
25 import com.liferay.portal.kernel.dao.jdbc.MappingSqlQuery;
26 import com.liferay.portal.kernel.dao.jdbc.MappingSqlQueryFactoryUtil;
27 import com.liferay.portal.kernel.dao.jdbc.RowMapper;
28 import com.liferay.portal.kernel.dao.jdbc.SqlUpdate;
29 import com.liferay.portal.kernel.dao.jdbc.SqlUpdateFactoryUtil;
30 import com.liferay.portal.kernel.dao.orm.DynamicQuery;
31 import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
32 import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
33 import com.liferay.portal.kernel.dao.orm.FinderPath;
34 import com.liferay.portal.kernel.dao.orm.Query;
35 import com.liferay.portal.kernel.dao.orm.QueryPos;
36 import com.liferay.portal.kernel.dao.orm.QueryUtil;
37 import com.liferay.portal.kernel.dao.orm.SQLQuery;
38 import com.liferay.portal.kernel.dao.orm.Session;
39 import com.liferay.portal.kernel.dao.orm.Type;
40 import com.liferay.portal.kernel.log.Log;
41 import com.liferay.portal.kernel.log.LogFactoryUtil;
42 import com.liferay.portal.kernel.util.GetterUtil;
43 import com.liferay.portal.kernel.util.OrderByComparator;
44 import com.liferay.portal.kernel.util.StringPool;
45 import com.liferay.portal.kernel.util.StringUtil;
46 import com.liferay.portal.kernel.util.Validator;
47 import com.liferay.portal.model.ModelListener;
48 import com.liferay.portal.service.persistence.BatchSessionUtil;
49 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
50
51 import com.liferay.portlet.softwarecatalog.NoSuchProductEntryException;
52 import com.liferay.portlet.softwarecatalog.model.SCProductEntry;
53 import com.liferay.portlet.softwarecatalog.model.impl.SCProductEntryImpl;
54 import com.liferay.portlet.softwarecatalog.model.impl.SCProductEntryModelImpl;
55
56 import java.sql.Types;
57
58 import java.util.ArrayList;
59 import java.util.Collections;
60 import java.util.List;
61
62
68 public class SCProductEntryPersistenceImpl extends BasePersistenceImpl
69 implements SCProductEntryPersistence {
70 public static final String FINDER_CLASS_NAME_ENTITY = SCProductEntryImpl.class.getName();
71 public static final String FINDER_CLASS_NAME_LIST = FINDER_CLASS_NAME_ENTITY +
72 ".List";
73 public static final FinderPath FINDER_PATH_FIND_BY_GROUPID = new FinderPath(SCProductEntryModelImpl.ENTITY_CACHE_ENABLED,
74 SCProductEntryModelImpl.FINDER_CACHE_ENABLED,
75 FINDER_CLASS_NAME_LIST, "findByGroupId",
76 new String[] { Long.class.getName() });
77 public static final FinderPath FINDER_PATH_FIND_BY_OBC_GROUPID = new FinderPath(SCProductEntryModelImpl.ENTITY_CACHE_ENABLED,
78 SCProductEntryModelImpl.FINDER_CACHE_ENABLED,
79 FINDER_CLASS_NAME_LIST, "findByGroupId",
80 new String[] {
81 Long.class.getName(),
82
83 "java.lang.Integer", "java.lang.Integer",
84 "com.liferay.portal.kernel.util.OrderByComparator"
85 });
86 public static final FinderPath FINDER_PATH_COUNT_BY_GROUPID = new FinderPath(SCProductEntryModelImpl.ENTITY_CACHE_ENABLED,
87 SCProductEntryModelImpl.FINDER_CACHE_ENABLED,
88 FINDER_CLASS_NAME_LIST, "countByGroupId",
89 new String[] { Long.class.getName() });
90 public static final FinderPath FINDER_PATH_FIND_BY_COMPANYID = new FinderPath(SCProductEntryModelImpl.ENTITY_CACHE_ENABLED,
91 SCProductEntryModelImpl.FINDER_CACHE_ENABLED,
92 FINDER_CLASS_NAME_LIST, "findByCompanyId",
93 new String[] { Long.class.getName() });
94 public static final FinderPath FINDER_PATH_FIND_BY_OBC_COMPANYID = new FinderPath(SCProductEntryModelImpl.ENTITY_CACHE_ENABLED,
95 SCProductEntryModelImpl.FINDER_CACHE_ENABLED,
96 FINDER_CLASS_NAME_LIST, "findByCompanyId",
97 new String[] {
98 Long.class.getName(),
99
100 "java.lang.Integer", "java.lang.Integer",
101 "com.liferay.portal.kernel.util.OrderByComparator"
102 });
103 public static final FinderPath FINDER_PATH_COUNT_BY_COMPANYID = new FinderPath(SCProductEntryModelImpl.ENTITY_CACHE_ENABLED,
104 SCProductEntryModelImpl.FINDER_CACHE_ENABLED,
105 FINDER_CLASS_NAME_LIST, "countByCompanyId",
106 new String[] { Long.class.getName() });
107 public static final FinderPath FINDER_PATH_FIND_BY_G_U = new FinderPath(SCProductEntryModelImpl.ENTITY_CACHE_ENABLED,
108 SCProductEntryModelImpl.FINDER_CACHE_ENABLED,
109 FINDER_CLASS_NAME_LIST, "findByG_U",
110 new String[] { Long.class.getName(), Long.class.getName() });
111 public static final FinderPath FINDER_PATH_FIND_BY_OBC_G_U = new FinderPath(SCProductEntryModelImpl.ENTITY_CACHE_ENABLED,
112 SCProductEntryModelImpl.FINDER_CACHE_ENABLED,
113 FINDER_CLASS_NAME_LIST, "findByG_U",
114 new String[] {
115 Long.class.getName(), Long.class.getName(),
116
117 "java.lang.Integer", "java.lang.Integer",
118 "com.liferay.portal.kernel.util.OrderByComparator"
119 });
120 public static final FinderPath FINDER_PATH_COUNT_BY_G_U = new FinderPath(SCProductEntryModelImpl.ENTITY_CACHE_ENABLED,
121 SCProductEntryModelImpl.FINDER_CACHE_ENABLED,
122 FINDER_CLASS_NAME_LIST, "countByG_U",
123 new String[] { Long.class.getName(), Long.class.getName() });
124 public static final FinderPath FINDER_PATH_FETCH_BY_RG_RA = new FinderPath(SCProductEntryModelImpl.ENTITY_CACHE_ENABLED,
125 SCProductEntryModelImpl.FINDER_CACHE_ENABLED,
126 FINDER_CLASS_NAME_ENTITY, "fetchByRG_RA",
127 new String[] { String.class.getName(), String.class.getName() });
128 public static final FinderPath FINDER_PATH_COUNT_BY_RG_RA = new FinderPath(SCProductEntryModelImpl.ENTITY_CACHE_ENABLED,
129 SCProductEntryModelImpl.FINDER_CACHE_ENABLED,
130 FINDER_CLASS_NAME_LIST, "countByRG_RA",
131 new String[] { String.class.getName(), String.class.getName() });
132 public static final FinderPath FINDER_PATH_FIND_ALL = new FinderPath(SCProductEntryModelImpl.ENTITY_CACHE_ENABLED,
133 SCProductEntryModelImpl.FINDER_CACHE_ENABLED,
134 FINDER_CLASS_NAME_LIST, "findAll", new String[0]);
135 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(SCProductEntryModelImpl.ENTITY_CACHE_ENABLED,
136 SCProductEntryModelImpl.FINDER_CACHE_ENABLED,
137 FINDER_CLASS_NAME_LIST, "countAll", new String[0]);
138
139 public void cacheResult(SCProductEntry scProductEntry) {
140 EntityCacheUtil.putResult(SCProductEntryModelImpl.ENTITY_CACHE_ENABLED,
141 SCProductEntryImpl.class, scProductEntry.getPrimaryKey(),
142 scProductEntry);
143
144 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_RG_RA,
145 new Object[] {
146 scProductEntry.getRepoGroupId(),
147
148 scProductEntry.getRepoArtifactId()
149 }, scProductEntry);
150 }
151
152 public void cacheResult(List<SCProductEntry> scProductEntries) {
153 for (SCProductEntry scProductEntry : scProductEntries) {
154 if (EntityCacheUtil.getResult(
155 SCProductEntryModelImpl.ENTITY_CACHE_ENABLED,
156 SCProductEntryImpl.class,
157 scProductEntry.getPrimaryKey(), this) == null) {
158 cacheResult(scProductEntry);
159 }
160 }
161 }
162
163 public void clearCache() {
164 CacheRegistry.clear(SCProductEntryImpl.class.getName());
165 EntityCacheUtil.clearCache(SCProductEntryImpl.class.getName());
166 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
167 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
168 }
169
170 public SCProductEntry create(long productEntryId) {
171 SCProductEntry scProductEntry = new SCProductEntryImpl();
172
173 scProductEntry.setNew(true);
174 scProductEntry.setPrimaryKey(productEntryId);
175
176 return scProductEntry;
177 }
178
179 public SCProductEntry remove(long productEntryId)
180 throws NoSuchProductEntryException, SystemException {
181 Session session = null;
182
183 try {
184 session = openSession();
185
186 SCProductEntry scProductEntry = (SCProductEntry)session.get(SCProductEntryImpl.class,
187 new Long(productEntryId));
188
189 if (scProductEntry == null) {
190 if (_log.isWarnEnabled()) {
191 _log.warn("No SCProductEntry exists with the primary key " +
192 productEntryId);
193 }
194
195 throw new NoSuchProductEntryException(
196 "No SCProductEntry exists with the primary key " +
197 productEntryId);
198 }
199
200 return remove(scProductEntry);
201 }
202 catch (NoSuchProductEntryException nsee) {
203 throw nsee;
204 }
205 catch (Exception e) {
206 throw processException(e);
207 }
208 finally {
209 closeSession(session);
210 }
211 }
212
213 public SCProductEntry remove(SCProductEntry scProductEntry)
214 throws SystemException {
215 for (ModelListener<SCProductEntry> listener : listeners) {
216 listener.onBeforeRemove(scProductEntry);
217 }
218
219 scProductEntry = removeImpl(scProductEntry);
220
221 for (ModelListener<SCProductEntry> listener : listeners) {
222 listener.onAfterRemove(scProductEntry);
223 }
224
225 return scProductEntry;
226 }
227
228 protected SCProductEntry removeImpl(SCProductEntry scProductEntry)
229 throws SystemException {
230 try {
231 clearSCLicenses.clear(scProductEntry.getPrimaryKey());
232 }
233 catch (Exception e) {
234 throw processException(e);
235 }
236 finally {
237 FinderCacheUtil.clearCache("SCLicenses_SCProductEntries");
238 }
239
240 Session session = null;
241
242 try {
243 session = openSession();
244
245 if (scProductEntry.isCachedModel() || BatchSessionUtil.isEnabled()) {
246 Object staleObject = session.get(SCProductEntryImpl.class,
247 scProductEntry.getPrimaryKeyObj());
248
249 if (staleObject != null) {
250 session.evict(staleObject);
251 }
252 }
253
254 session.delete(scProductEntry);
255
256 session.flush();
257 }
258 catch (Exception e) {
259 throw processException(e);
260 }
261 finally {
262 closeSession(session);
263 }
264
265 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
266
267 SCProductEntryModelImpl scProductEntryModelImpl = (SCProductEntryModelImpl)scProductEntry;
268
269 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_RG_RA,
270 new Object[] {
271 scProductEntryModelImpl.getOriginalRepoGroupId(),
272
273 scProductEntryModelImpl.getOriginalRepoArtifactId()
274 });
275
276 EntityCacheUtil.removeResult(SCProductEntryModelImpl.ENTITY_CACHE_ENABLED,
277 SCProductEntryImpl.class, scProductEntry.getPrimaryKey());
278
279 return scProductEntry;
280 }
281
282
285 public SCProductEntry update(SCProductEntry scProductEntry)
286 throws SystemException {
287 if (_log.isWarnEnabled()) {
288 _log.warn(
289 "Using the deprecated update(SCProductEntry scProductEntry) method. Use update(SCProductEntry scProductEntry, boolean merge) instead.");
290 }
291
292 return update(scProductEntry, false);
293 }
294
295
308 public SCProductEntry update(SCProductEntry scProductEntry, boolean merge)
309 throws SystemException {
310 boolean isNew = scProductEntry.isNew();
311
312 for (ModelListener<SCProductEntry> listener : listeners) {
313 if (isNew) {
314 listener.onBeforeCreate(scProductEntry);
315 }
316 else {
317 listener.onBeforeUpdate(scProductEntry);
318 }
319 }
320
321 scProductEntry = updateImpl(scProductEntry, merge);
322
323 for (ModelListener<SCProductEntry> listener : listeners) {
324 if (isNew) {
325 listener.onAfterCreate(scProductEntry);
326 }
327 else {
328 listener.onAfterUpdate(scProductEntry);
329 }
330 }
331
332 return scProductEntry;
333 }
334
335 public SCProductEntry updateImpl(
336 com.liferay.portlet.softwarecatalog.model.SCProductEntry scProductEntry,
337 boolean merge) throws SystemException {
338 boolean isNew = scProductEntry.isNew();
339
340 SCProductEntryModelImpl scProductEntryModelImpl = (SCProductEntryModelImpl)scProductEntry;
341
342 Session session = null;
343
344 try {
345 session = openSession();
346
347 BatchSessionUtil.update(session, scProductEntry, merge);
348
349 scProductEntry.setNew(false);
350 }
351 catch (Exception e) {
352 throw processException(e);
353 }
354 finally {
355 closeSession(session);
356 }
357
358 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
359
360 EntityCacheUtil.putResult(SCProductEntryModelImpl.ENTITY_CACHE_ENABLED,
361 SCProductEntryImpl.class, scProductEntry.getPrimaryKey(),
362 scProductEntry);
363
364 if (!isNew &&
365 (!Validator.equals(scProductEntry.getRepoGroupId(),
366 scProductEntryModelImpl.getOriginalRepoGroupId()) ||
367 !Validator.equals(scProductEntry.getRepoArtifactId(),
368 scProductEntryModelImpl.getOriginalRepoArtifactId()))) {
369 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_RG_RA,
370 new Object[] {
371 scProductEntryModelImpl.getOriginalRepoGroupId(),
372
373 scProductEntryModelImpl.getOriginalRepoArtifactId()
374 });
375 }
376
377 if (isNew ||
378 (!Validator.equals(scProductEntry.getRepoGroupId(),
379 scProductEntryModelImpl.getOriginalRepoGroupId()) ||
380 !Validator.equals(scProductEntry.getRepoArtifactId(),
381 scProductEntryModelImpl.getOriginalRepoArtifactId()))) {
382 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_RG_RA,
383 new Object[] {
384 scProductEntry.getRepoGroupId(),
385
386 scProductEntry.getRepoArtifactId()
387 }, scProductEntry);
388 }
389
390 return scProductEntry;
391 }
392
393 public SCProductEntry findByPrimaryKey(long productEntryId)
394 throws NoSuchProductEntryException, SystemException {
395 SCProductEntry scProductEntry = fetchByPrimaryKey(productEntryId);
396
397 if (scProductEntry == null) {
398 if (_log.isWarnEnabled()) {
399 _log.warn("No SCProductEntry exists with the primary key " +
400 productEntryId);
401 }
402
403 throw new NoSuchProductEntryException(
404 "No SCProductEntry exists with the primary key " +
405 productEntryId);
406 }
407
408 return scProductEntry;
409 }
410
411 public SCProductEntry fetchByPrimaryKey(long productEntryId)
412 throws SystemException {
413 SCProductEntry scProductEntry = (SCProductEntry)EntityCacheUtil.getResult(SCProductEntryModelImpl.ENTITY_CACHE_ENABLED,
414 SCProductEntryImpl.class, productEntryId, this);
415
416 if (scProductEntry == null) {
417 Session session = null;
418
419 try {
420 session = openSession();
421
422 scProductEntry = (SCProductEntry)session.get(SCProductEntryImpl.class,
423 new Long(productEntryId));
424 }
425 catch (Exception e) {
426 throw processException(e);
427 }
428 finally {
429 if (scProductEntry != null) {
430 cacheResult(scProductEntry);
431 }
432
433 closeSession(session);
434 }
435 }
436
437 return scProductEntry;
438 }
439
440 public List<SCProductEntry> findByGroupId(long groupId)
441 throws SystemException {
442 Object[] finderArgs = new Object[] { new Long(groupId) };
443
444 List<SCProductEntry> list = (List<SCProductEntry>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_GROUPID,
445 finderArgs, this);
446
447 if (list == null) {
448 Session session = null;
449
450 try {
451 session = openSession();
452
453 StringBuilder query = new StringBuilder();
454
455 query.append(
456 "SELECT scProductEntry FROM SCProductEntry scProductEntry WHERE ");
457
458 query.append("scProductEntry.groupId = ?");
459
460 query.append(" ");
461
462 query.append("ORDER BY ");
463
464 query.append("scProductEntry.modifiedDate DESC, ");
465 query.append("scProductEntry.name DESC");
466
467 Query q = session.createQuery(query.toString());
468
469 QueryPos qPos = QueryPos.getInstance(q);
470
471 qPos.add(groupId);
472
473 list = q.list();
474 }
475 catch (Exception e) {
476 throw processException(e);
477 }
478 finally {
479 if (list == null) {
480 list = new ArrayList<SCProductEntry>();
481 }
482
483 cacheResult(list);
484
485 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_GROUPID,
486 finderArgs, list);
487
488 closeSession(session);
489 }
490 }
491
492 return list;
493 }
494
495 public List<SCProductEntry> findByGroupId(long groupId, int start, int end)
496 throws SystemException {
497 return findByGroupId(groupId, start, end, null);
498 }
499
500 public List<SCProductEntry> findByGroupId(long groupId, int start, int end,
501 OrderByComparator obc) throws SystemException {
502 Object[] finderArgs = new Object[] {
503 new Long(groupId),
504
505 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
506 };
507
508 List<SCProductEntry> list = (List<SCProductEntry>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_GROUPID,
509 finderArgs, this);
510
511 if (list == null) {
512 Session session = null;
513
514 try {
515 session = openSession();
516
517 StringBuilder query = new StringBuilder();
518
519 query.append(
520 "SELECT scProductEntry FROM SCProductEntry scProductEntry WHERE ");
521
522 query.append("scProductEntry.groupId = ?");
523
524 query.append(" ");
525
526 if (obc != null) {
527 query.append("ORDER BY ");
528
529 String[] orderByFields = obc.getOrderByFields();
530
531 for (int i = 0; i < orderByFields.length; i++) {
532 query.append("scProductEntry.");
533 query.append(orderByFields[i]);
534
535 if (obc.isAscending()) {
536 query.append(" ASC");
537 }
538 else {
539 query.append(" DESC");
540 }
541
542 if ((i + 1) < orderByFields.length) {
543 query.append(", ");
544 }
545 }
546 }
547
548 else {
549 query.append("ORDER BY ");
550
551 query.append("scProductEntry.modifiedDate DESC, ");
552 query.append("scProductEntry.name DESC");
553 }
554
555 Query q = session.createQuery(query.toString());
556
557 QueryPos qPos = QueryPos.getInstance(q);
558
559 qPos.add(groupId);
560
561 list = (List<SCProductEntry>)QueryUtil.list(q, getDialect(),
562 start, end);
563 }
564 catch (Exception e) {
565 throw processException(e);
566 }
567 finally {
568 if (list == null) {
569 list = new ArrayList<SCProductEntry>();
570 }
571
572 cacheResult(list);
573
574 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_GROUPID,
575 finderArgs, list);
576
577 closeSession(session);
578 }
579 }
580
581 return list;
582 }
583
584 public SCProductEntry findByGroupId_First(long groupId,
585 OrderByComparator obc)
586 throws NoSuchProductEntryException, SystemException {
587 List<SCProductEntry> list = findByGroupId(groupId, 0, 1, obc);
588
589 if (list.isEmpty()) {
590 StringBuilder msg = new StringBuilder();
591
592 msg.append("No SCProductEntry exists with the key {");
593
594 msg.append("groupId=" + groupId);
595
596 msg.append(StringPool.CLOSE_CURLY_BRACE);
597
598 throw new NoSuchProductEntryException(msg.toString());
599 }
600 else {
601 return list.get(0);
602 }
603 }
604
605 public SCProductEntry findByGroupId_Last(long groupId, OrderByComparator obc)
606 throws NoSuchProductEntryException, SystemException {
607 int count = countByGroupId(groupId);
608
609 List<SCProductEntry> list = findByGroupId(groupId, count - 1, count, obc);
610
611 if (list.isEmpty()) {
612 StringBuilder msg = new StringBuilder();
613
614 msg.append("No SCProductEntry exists with the key {");
615
616 msg.append("groupId=" + groupId);
617
618 msg.append(StringPool.CLOSE_CURLY_BRACE);
619
620 throw new NoSuchProductEntryException(msg.toString());
621 }
622 else {
623 return list.get(0);
624 }
625 }
626
627 public SCProductEntry[] findByGroupId_PrevAndNext(long productEntryId,
628 long groupId, OrderByComparator obc)
629 throws NoSuchProductEntryException, SystemException {
630 SCProductEntry scProductEntry = findByPrimaryKey(productEntryId);
631
632 int count = countByGroupId(groupId);
633
634 Session session = null;
635
636 try {
637 session = openSession();
638
639 StringBuilder query = new StringBuilder();
640
641 query.append(
642 "SELECT scProductEntry FROM SCProductEntry scProductEntry WHERE ");
643
644 query.append("scProductEntry.groupId = ?");
645
646 query.append(" ");
647
648 if (obc != null) {
649 query.append("ORDER BY ");
650
651 String[] orderByFields = obc.getOrderByFields();
652
653 for (int i = 0; i < orderByFields.length; i++) {
654 query.append("scProductEntry.");
655 query.append(orderByFields[i]);
656
657 if (obc.isAscending()) {
658 query.append(" ASC");
659 }
660 else {
661 query.append(" DESC");
662 }
663
664 if ((i + 1) < orderByFields.length) {
665 query.append(", ");
666 }
667 }
668 }
669
670 else {
671 query.append("ORDER BY ");
672
673 query.append("scProductEntry.modifiedDate DESC, ");
674 query.append("scProductEntry.name DESC");
675 }
676
677 Query q = session.createQuery(query.toString());
678
679 QueryPos qPos = QueryPos.getInstance(q);
680
681 qPos.add(groupId);
682
683 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
684 scProductEntry);
685
686 SCProductEntry[] array = new SCProductEntryImpl[3];
687
688 array[0] = (SCProductEntry)objArray[0];
689 array[1] = (SCProductEntry)objArray[1];
690 array[2] = (SCProductEntry)objArray[2];
691
692 return array;
693 }
694 catch (Exception e) {
695 throw processException(e);
696 }
697 finally {
698 closeSession(session);
699 }
700 }
701
702 public List<SCProductEntry> findByCompanyId(long companyId)
703 throws SystemException {
704 Object[] finderArgs = new Object[] { new Long(companyId) };
705
706 List<SCProductEntry> list = (List<SCProductEntry>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_COMPANYID,
707 finderArgs, this);
708
709 if (list == null) {
710 Session session = null;
711
712 try {
713 session = openSession();
714
715 StringBuilder query = new StringBuilder();
716
717 query.append(
718 "SELECT scProductEntry FROM SCProductEntry scProductEntry WHERE ");
719
720 query.append("scProductEntry.companyId = ?");
721
722 query.append(" ");
723
724 query.append("ORDER BY ");
725
726 query.append("scProductEntry.modifiedDate DESC, ");
727 query.append("scProductEntry.name DESC");
728
729 Query q = session.createQuery(query.toString());
730
731 QueryPos qPos = QueryPos.getInstance(q);
732
733 qPos.add(companyId);
734
735 list = q.list();
736 }
737 catch (Exception e) {
738 throw processException(e);
739 }
740 finally {
741 if (list == null) {
742 list = new ArrayList<SCProductEntry>();
743 }
744
745 cacheResult(list);
746
747 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_COMPANYID,
748 finderArgs, list);
749
750 closeSession(session);
751 }
752 }
753
754 return list;
755 }
756
757 public List<SCProductEntry> findByCompanyId(long companyId, int start,
758 int end) throws SystemException {
759 return findByCompanyId(companyId, start, end, null);
760 }
761
762 public List<SCProductEntry> findByCompanyId(long companyId, int start,
763 int end, OrderByComparator obc) throws SystemException {
764 Object[] finderArgs = new Object[] {
765 new Long(companyId),
766
767 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
768 };
769
770 List<SCProductEntry> list = (List<SCProductEntry>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_COMPANYID,
771 finderArgs, this);
772
773 if (list == null) {
774 Session session = null;
775
776 try {
777 session = openSession();
778
779 StringBuilder query = new StringBuilder();
780
781 query.append(
782 "SELECT scProductEntry FROM SCProductEntry scProductEntry WHERE ");
783
784 query.append("scProductEntry.companyId = ?");
785
786 query.append(" ");
787
788 if (obc != null) {
789 query.append("ORDER BY ");
790
791 String[] orderByFields = obc.getOrderByFields();
792
793 for (int i = 0; i < orderByFields.length; i++) {
794 query.append("scProductEntry.");
795 query.append(orderByFields[i]);
796
797 if (obc.isAscending()) {
798 query.append(" ASC");
799 }
800 else {
801 query.append(" DESC");
802 }
803
804 if ((i + 1) < orderByFields.length) {
805 query.append(", ");
806 }
807 }
808 }
809
810 else {
811 query.append("ORDER BY ");
812
813 query.append("scProductEntry.modifiedDate DESC, ");
814 query.append("scProductEntry.name DESC");
815 }
816
817 Query q = session.createQuery(query.toString());
818
819 QueryPos qPos = QueryPos.getInstance(q);
820
821 qPos.add(companyId);
822
823 list = (List<SCProductEntry>)QueryUtil.list(q, getDialect(),
824 start, end);
825 }
826 catch (Exception e) {
827 throw processException(e);
828 }
829 finally {
830 if (list == null) {
831 list = new ArrayList<SCProductEntry>();
832 }
833
834 cacheResult(list);
835
836 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_COMPANYID,
837 finderArgs, list);
838
839 closeSession(session);
840 }
841 }
842
843 return list;
844 }
845
846 public SCProductEntry findByCompanyId_First(long companyId,
847 OrderByComparator obc)
848 throws NoSuchProductEntryException, SystemException {
849 List<SCProductEntry> list = findByCompanyId(companyId, 0, 1, obc);
850
851 if (list.isEmpty()) {
852 StringBuilder msg = new StringBuilder();
853
854 msg.append("No SCProductEntry exists with the key {");
855
856 msg.append("companyId=" + companyId);
857
858 msg.append(StringPool.CLOSE_CURLY_BRACE);
859
860 throw new NoSuchProductEntryException(msg.toString());
861 }
862 else {
863 return list.get(0);
864 }
865 }
866
867 public SCProductEntry findByCompanyId_Last(long companyId,
868 OrderByComparator obc)
869 throws NoSuchProductEntryException, SystemException {
870 int count = countByCompanyId(companyId);
871
872 List<SCProductEntry> list = findByCompanyId(companyId, count - 1,
873 count, obc);
874
875 if (list.isEmpty()) {
876 StringBuilder msg = new StringBuilder();
877
878 msg.append("No SCProductEntry exists with the key {");
879
880 msg.append("companyId=" + companyId);
881
882 msg.append(StringPool.CLOSE_CURLY_BRACE);
883
884 throw new NoSuchProductEntryException(msg.toString());
885 }
886 else {
887 return list.get(0);
888 }
889 }
890
891 public SCProductEntry[] findByCompanyId_PrevAndNext(long productEntryId,
892 long companyId, OrderByComparator obc)
893 throws NoSuchProductEntryException, SystemException {
894 SCProductEntry scProductEntry = findByPrimaryKey(productEntryId);
895
896 int count = countByCompanyId(companyId);
897
898 Session session = null;
899
900 try {
901 session = openSession();
902
903 StringBuilder query = new StringBuilder();
904
905 query.append(
906 "SELECT scProductEntry FROM SCProductEntry scProductEntry WHERE ");
907
908 query.append("scProductEntry.companyId = ?");
909
910 query.append(" ");
911
912 if (obc != null) {
913 query.append("ORDER BY ");
914
915 String[] orderByFields = obc.getOrderByFields();
916
917 for (int i = 0; i < orderByFields.length; i++) {
918 query.append("scProductEntry.");
919 query.append(orderByFields[i]);
920
921 if (obc.isAscending()) {
922 query.append(" ASC");
923 }
924 else {
925 query.append(" DESC");
926 }
927
928 if ((i + 1) < orderByFields.length) {
929 query.append(", ");
930 }
931 }
932 }
933
934 else {
935 query.append("ORDER BY ");
936
937 query.append("scProductEntry.modifiedDate DESC, ");
938 query.append("scProductEntry.name DESC");
939 }
940
941 Query q = session.createQuery(query.toString());
942
943 QueryPos qPos = QueryPos.getInstance(q);
944
945 qPos.add(companyId);
946
947 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
948 scProductEntry);
949
950 SCProductEntry[] array = new SCProductEntryImpl[3];
951
952 array[0] = (SCProductEntry)objArray[0];
953 array[1] = (SCProductEntry)objArray[1];
954 array[2] = (SCProductEntry)objArray[2];
955
956 return array;
957 }
958 catch (Exception e) {
959 throw processException(e);
960 }
961 finally {
962 closeSession(session);
963 }
964 }
965
966 public List<SCProductEntry> findByG_U(long groupId, long userId)
967 throws SystemException {
968 Object[] finderArgs = new Object[] { new Long(groupId), new Long(userId) };
969
970 List<SCProductEntry> list = (List<SCProductEntry>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_G_U,
971 finderArgs, this);
972
973 if (list == null) {
974 Session session = null;
975
976 try {
977 session = openSession();
978
979 StringBuilder query = new StringBuilder();
980
981 query.append(
982 "SELECT scProductEntry FROM SCProductEntry scProductEntry WHERE ");
983
984 query.append("scProductEntry.groupId = ?");
985
986 query.append(" AND ");
987
988 query.append("scProductEntry.userId = ?");
989
990 query.append(" ");
991
992 query.append("ORDER BY ");
993
994 query.append("scProductEntry.modifiedDate DESC, ");
995 query.append("scProductEntry.name DESC");
996
997 Query q = session.createQuery(query.toString());
998
999 QueryPos qPos = QueryPos.getInstance(q);
1000
1001 qPos.add(groupId);
1002
1003 qPos.add(userId);
1004
1005 list = q.list();
1006 }
1007 catch (Exception e) {
1008 throw processException(e);
1009 }
1010 finally {
1011 if (list == null) {
1012 list = new ArrayList<SCProductEntry>();
1013 }
1014
1015 cacheResult(list);
1016
1017 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_G_U, finderArgs,
1018 list);
1019
1020 closeSession(session);
1021 }
1022 }
1023
1024 return list;
1025 }
1026
1027 public List<SCProductEntry> findByG_U(long groupId, long userId, int start,
1028 int end) throws SystemException {
1029 return findByG_U(groupId, userId, start, end, null);
1030 }
1031
1032 public List<SCProductEntry> findByG_U(long groupId, long userId, int start,
1033 int end, OrderByComparator obc) throws SystemException {
1034 Object[] finderArgs = new Object[] {
1035 new Long(groupId), new Long(userId),
1036
1037 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
1038 };
1039
1040 List<SCProductEntry> list = (List<SCProductEntry>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_G_U,
1041 finderArgs, this);
1042
1043 if (list == null) {
1044 Session session = null;
1045
1046 try {
1047 session = openSession();
1048
1049 StringBuilder query = new StringBuilder();
1050
1051 query.append(
1052 "SELECT scProductEntry FROM SCProductEntry scProductEntry WHERE ");
1053
1054 query.append("scProductEntry.groupId = ?");
1055
1056 query.append(" AND ");
1057
1058 query.append("scProductEntry.userId = ?");
1059
1060 query.append(" ");
1061
1062 if (obc != null) {
1063 query.append("ORDER BY ");
1064
1065 String[] orderByFields = obc.getOrderByFields();
1066
1067 for (int i = 0; i < orderByFields.length; i++) {
1068 query.append("scProductEntry.");
1069 query.append(orderByFields[i]);
1070
1071 if (obc.isAscending()) {
1072 query.append(" ASC");
1073 }
1074 else {
1075 query.append(" DESC");
1076 }
1077
1078 if ((i + 1) < orderByFields.length) {
1079 query.append(", ");
1080 }
1081 }
1082 }
1083
1084 else {
1085 query.append("ORDER BY ");
1086
1087 query.append("scProductEntry.modifiedDate DESC, ");
1088 query.append("scProductEntry.name DESC");
1089 }
1090
1091 Query q = session.createQuery(query.toString());
1092
1093 QueryPos qPos = QueryPos.getInstance(q);
1094
1095 qPos.add(groupId);
1096
1097 qPos.add(userId);
1098
1099 list = (List<SCProductEntry>)QueryUtil.list(q, getDialect(),
1100 start, end);
1101 }
1102 catch (Exception e) {
1103 throw processException(e);
1104 }
1105 finally {
1106 if (list == null) {
1107 list = new ArrayList<SCProductEntry>();
1108 }
1109
1110 cacheResult(list);
1111
1112 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_G_U,
1113 finderArgs, list);
1114
1115 closeSession(session);
1116 }
1117 }
1118
1119 return list;
1120 }
1121
1122 public SCProductEntry findByG_U_First(long groupId, long userId,
1123 OrderByComparator obc)
1124 throws NoSuchProductEntryException, SystemException {
1125 List<SCProductEntry> list = findByG_U(groupId, userId, 0, 1, obc);
1126
1127 if (list.isEmpty()) {
1128 StringBuilder msg = new StringBuilder();
1129
1130 msg.append("No SCProductEntry exists with the key {");
1131
1132 msg.append("groupId=" + groupId);
1133
1134 msg.append(", ");
1135 msg.append("userId=" + userId);
1136
1137 msg.append(StringPool.CLOSE_CURLY_BRACE);
1138
1139 throw new NoSuchProductEntryException(msg.toString());
1140 }
1141 else {
1142 return list.get(0);
1143 }
1144 }
1145
1146 public SCProductEntry findByG_U_Last(long groupId, long userId,
1147 OrderByComparator obc)
1148 throws NoSuchProductEntryException, SystemException {
1149 int count = countByG_U(groupId, userId);
1150
1151 List<SCProductEntry> list = findByG_U(groupId, userId, count - 1,
1152 count, obc);
1153
1154 if (list.isEmpty()) {
1155 StringBuilder msg = new StringBuilder();
1156
1157 msg.append("No SCProductEntry exists with the key {");
1158
1159 msg.append("groupId=" + groupId);
1160
1161 msg.append(", ");
1162 msg.append("userId=" + userId);
1163
1164 msg.append(StringPool.CLOSE_CURLY_BRACE);
1165
1166 throw new NoSuchProductEntryException(msg.toString());
1167 }
1168 else {
1169 return list.get(0);
1170 }
1171 }
1172
1173 public SCProductEntry[] findByG_U_PrevAndNext(long productEntryId,
1174 long groupId, long userId, OrderByComparator obc)
1175 throws NoSuchProductEntryException, SystemException {
1176 SCProductEntry scProductEntry = findByPrimaryKey(productEntryId);
1177
1178 int count = countByG_U(groupId, userId);
1179
1180 Session session = null;
1181
1182 try {
1183 session = openSession();
1184
1185 StringBuilder query = new StringBuilder();
1186
1187 query.append(
1188 "SELECT scProductEntry FROM SCProductEntry scProductEntry WHERE ");
1189
1190 query.append("scProductEntry.groupId = ?");
1191
1192 query.append(" AND ");
1193
1194 query.append("scProductEntry.userId = ?");
1195
1196 query.append(" ");
1197
1198 if (obc != null) {
1199 query.append("ORDER BY ");
1200
1201 String[] orderByFields = obc.getOrderByFields();
1202
1203 for (int i = 0; i < orderByFields.length; i++) {
1204 query.append("scProductEntry.");
1205 query.append(orderByFields[i]);
1206
1207 if (obc.isAscending()) {
1208 query.append(" ASC");
1209 }
1210 else {
1211 query.append(" DESC");
1212 }
1213
1214 if ((i + 1) < orderByFields.length) {
1215 query.append(", ");
1216 }
1217 }
1218 }
1219
1220 else {
1221 query.append("ORDER BY ");
1222
1223 query.append("scProductEntry.modifiedDate DESC, ");
1224 query.append("scProductEntry.name DESC");
1225 }
1226
1227 Query q = session.createQuery(query.toString());
1228
1229 QueryPos qPos = QueryPos.getInstance(q);
1230
1231 qPos.add(groupId);
1232
1233 qPos.add(userId);
1234
1235 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
1236 scProductEntry);
1237
1238 SCProductEntry[] array = new SCProductEntryImpl[3];
1239
1240 array[0] = (SCProductEntry)objArray[0];
1241 array[1] = (SCProductEntry)objArray[1];
1242 array[2] = (SCProductEntry)objArray[2];
1243
1244 return array;
1245 }
1246 catch (Exception e) {
1247 throw processException(e);
1248 }
1249 finally {
1250 closeSession(session);
1251 }
1252 }
1253
1254 public SCProductEntry findByRG_RA(String repoGroupId, String repoArtifactId)
1255 throws NoSuchProductEntryException, SystemException {
1256 SCProductEntry scProductEntry = fetchByRG_RA(repoGroupId, repoArtifactId);
1257
1258 if (scProductEntry == null) {
1259 StringBuilder msg = new StringBuilder();
1260
1261 msg.append("No SCProductEntry exists with the key {");
1262
1263 msg.append("repoGroupId=" + repoGroupId);
1264
1265 msg.append(", ");
1266 msg.append("repoArtifactId=" + repoArtifactId);
1267
1268 msg.append(StringPool.CLOSE_CURLY_BRACE);
1269
1270 if (_log.isWarnEnabled()) {
1271 _log.warn(msg.toString());
1272 }
1273
1274 throw new NoSuchProductEntryException(msg.toString());
1275 }
1276
1277 return scProductEntry;
1278 }
1279
1280 public SCProductEntry fetchByRG_RA(String repoGroupId, String repoArtifactId)
1281 throws SystemException {
1282 return fetchByRG_RA(repoGroupId, repoArtifactId, true);
1283 }
1284
1285 public SCProductEntry fetchByRG_RA(String repoGroupId,
1286 String repoArtifactId, boolean retrieveFromCache)
1287 throws SystemException {
1288 Object[] finderArgs = new Object[] { repoGroupId, repoArtifactId };
1289
1290 Object result = null;
1291
1292 if (retrieveFromCache) {
1293 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_RG_RA,
1294 finderArgs, this);
1295 }
1296
1297 if (result == null) {
1298 Session session = null;
1299
1300 try {
1301 session = openSession();
1302
1303 StringBuilder query = new StringBuilder();
1304
1305 query.append(
1306 "SELECT scProductEntry FROM SCProductEntry scProductEntry WHERE ");
1307
1308 if (repoGroupId == null) {
1309 query.append("scProductEntry.repoGroupId IS NULL");
1310 }
1311 else {
1312 query.append("scProductEntry.lower(repoGroupId) = ?");
1313 }
1314
1315 query.append(" AND ");
1316
1317 if (repoArtifactId == null) {
1318 query.append("scProductEntry.repoArtifactId IS NULL");
1319 }
1320 else {
1321 query.append("scProductEntry.lower(repoArtifactId) = ?");
1322 }
1323
1324 query.append(" ");
1325
1326 query.append("ORDER BY ");
1327
1328 query.append("scProductEntry.modifiedDate DESC, ");
1329 query.append("scProductEntry.name DESC");
1330
1331 Query q = session.createQuery(query.toString());
1332
1333 QueryPos qPos = QueryPos.getInstance(q);
1334
1335 if (repoGroupId != null) {
1336 qPos.add(repoGroupId);
1337 }
1338
1339 if (repoArtifactId != null) {
1340 qPos.add(repoArtifactId);
1341 }
1342
1343 List<SCProductEntry> list = q.list();
1344
1345 result = list;
1346
1347 SCProductEntry scProductEntry = null;
1348
1349 if (list.isEmpty()) {
1350 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_RG_RA,
1351 finderArgs, list);
1352 }
1353 else {
1354 scProductEntry = list.get(0);
1355
1356 cacheResult(scProductEntry);
1357
1358 if ((scProductEntry.getRepoGroupId() == null) ||
1359 !scProductEntry.getRepoGroupId().equals(repoGroupId) ||
1360 (scProductEntry.getRepoArtifactId() == null) ||
1361 !scProductEntry.getRepoArtifactId()
1362 .equals(repoArtifactId)) {
1363 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_RG_RA,
1364 finderArgs, scProductEntry);
1365 }
1366 }
1367
1368 return scProductEntry;
1369 }
1370 catch (Exception e) {
1371 throw processException(e);
1372 }
1373 finally {
1374 if (result == null) {
1375 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_RG_RA,
1376 finderArgs, new ArrayList<SCProductEntry>());
1377 }
1378
1379 closeSession(session);
1380 }
1381 }
1382 else {
1383 if (result instanceof List) {
1384 return null;
1385 }
1386 else {
1387 return (SCProductEntry)result;
1388 }
1389 }
1390 }
1391
1392 public List<Object> findWithDynamicQuery(DynamicQuery dynamicQuery)
1393 throws SystemException {
1394 Session session = null;
1395
1396 try {
1397 session = openSession();
1398
1399 dynamicQuery.compile(session);
1400
1401 return dynamicQuery.list();
1402 }
1403 catch (Exception e) {
1404 throw processException(e);
1405 }
1406 finally {
1407 closeSession(session);
1408 }
1409 }
1410
1411 public List<Object> findWithDynamicQuery(DynamicQuery dynamicQuery,
1412 int start, int end) throws SystemException {
1413 Session session = null;
1414
1415 try {
1416 session = openSession();
1417
1418 dynamicQuery.setLimit(start, end);
1419
1420 dynamicQuery.compile(session);
1421
1422 return dynamicQuery.list();
1423 }
1424 catch (Exception e) {
1425 throw processException(e);
1426 }
1427 finally {
1428 closeSession(session);
1429 }
1430 }
1431
1432 public List<SCProductEntry> findAll() throws SystemException {
1433 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1434 }
1435
1436 public List<SCProductEntry> findAll(int start, int end)
1437 throws SystemException {
1438 return findAll(start, end, null);
1439 }
1440
1441 public List<SCProductEntry> findAll(int start, int end,
1442 OrderByComparator obc) throws SystemException {
1443 Object[] finderArgs = new Object[] {
1444 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
1445 };
1446
1447 List<SCProductEntry> list = (List<SCProductEntry>)FinderCacheUtil.getResult(FINDER_PATH_FIND_ALL,
1448 finderArgs, this);
1449
1450 if (list == null) {
1451 Session session = null;
1452
1453 try {
1454 session = openSession();
1455
1456 StringBuilder query = new StringBuilder();
1457
1458 query.append(
1459 "SELECT scProductEntry FROM SCProductEntry scProductEntry ");
1460
1461 if (obc != null) {
1462 query.append("ORDER BY ");
1463
1464 String[] orderByFields = obc.getOrderByFields();
1465
1466 for (int i = 0; i < orderByFields.length; i++) {
1467 query.append("scProductEntry.");
1468 query.append(orderByFields[i]);
1469
1470 if (obc.isAscending()) {
1471 query.append(" ASC");
1472 }
1473 else {
1474 query.append(" DESC");
1475 }
1476
1477 if ((i + 1) < orderByFields.length) {
1478 query.append(", ");
1479 }
1480 }
1481 }
1482
1483 else {
1484 query.append("ORDER BY ");
1485
1486 query.append("scProductEntry.modifiedDate DESC, ");
1487 query.append("scProductEntry.name DESC");
1488 }
1489
1490 Query q = session.createQuery(query.toString());
1491
1492 if (obc == null) {
1493 list = (List<SCProductEntry>)QueryUtil.list(q,
1494 getDialect(), start, end, false);
1495
1496 Collections.sort(list);
1497 }
1498 else {
1499 list = (List<SCProductEntry>)QueryUtil.list(q,
1500 getDialect(), start, end);
1501 }
1502 }
1503 catch (Exception e) {
1504 throw processException(e);
1505 }
1506 finally {
1507 if (list == null) {
1508 list = new ArrayList<SCProductEntry>();
1509 }
1510
1511 cacheResult(list);
1512
1513 FinderCacheUtil.putResult(FINDER_PATH_FIND_ALL, finderArgs, list);
1514
1515 closeSession(session);
1516 }
1517 }
1518
1519 return list;
1520 }
1521
1522 public void removeByGroupId(long groupId) throws SystemException {
1523 for (SCProductEntry scProductEntry : findByGroupId(groupId)) {
1524 remove(scProductEntry);
1525 }
1526 }
1527
1528 public void removeByCompanyId(long companyId) throws SystemException {
1529 for (SCProductEntry scProductEntry : findByCompanyId(companyId)) {
1530 remove(scProductEntry);
1531 }
1532 }
1533
1534 public void removeByG_U(long groupId, long userId)
1535 throws SystemException {
1536 for (SCProductEntry scProductEntry : findByG_U(groupId, userId)) {
1537 remove(scProductEntry);
1538 }
1539 }
1540
1541 public void removeByRG_RA(String repoGroupId, String repoArtifactId)
1542 throws NoSuchProductEntryException, SystemException {
1543 SCProductEntry scProductEntry = findByRG_RA(repoGroupId, repoArtifactId);
1544
1545 remove(scProductEntry);
1546 }
1547
1548 public void removeAll() throws SystemException {
1549 for (SCProductEntry scProductEntry : findAll()) {
1550 remove(scProductEntry);
1551 }
1552 }
1553
1554 public int countByGroupId(long groupId) throws SystemException {
1555 Object[] finderArgs = new Object[] { new Long(groupId) };
1556
1557 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_GROUPID,
1558 finderArgs, this);
1559
1560 if (count == null) {
1561 Session session = null;
1562
1563 try {
1564 session = openSession();
1565
1566 StringBuilder query = new StringBuilder();
1567
1568 query.append("SELECT COUNT(scProductEntry) ");
1569 query.append("FROM SCProductEntry scProductEntry WHERE ");
1570
1571 query.append("scProductEntry.groupId = ?");
1572
1573 query.append(" ");
1574
1575 Query q = session.createQuery(query.toString());
1576
1577 QueryPos qPos = QueryPos.getInstance(q);
1578
1579 qPos.add(groupId);
1580
1581 count = (Long)q.uniqueResult();
1582 }
1583 catch (Exception e) {
1584 throw processException(e);
1585 }
1586 finally {
1587 if (count == null) {
1588 count = Long.valueOf(0);
1589 }
1590
1591 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_GROUPID,
1592 finderArgs, count);
1593
1594 closeSession(session);
1595 }
1596 }
1597
1598 return count.intValue();
1599 }
1600
1601 public int countByCompanyId(long companyId) throws SystemException {
1602 Object[] finderArgs = new Object[] { new Long(companyId) };
1603
1604 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_COMPANYID,
1605 finderArgs, this);
1606
1607 if (count == null) {
1608 Session session = null;
1609
1610 try {
1611 session = openSession();
1612
1613 StringBuilder query = new StringBuilder();
1614
1615 query.append("SELECT COUNT(scProductEntry) ");
1616 query.append("FROM SCProductEntry scProductEntry WHERE ");
1617
1618 query.append("scProductEntry.companyId = ?");
1619
1620 query.append(" ");
1621
1622 Query q = session.createQuery(query.toString());
1623
1624 QueryPos qPos = QueryPos.getInstance(q);
1625
1626 qPos.add(companyId);
1627
1628 count = (Long)q.uniqueResult();
1629 }
1630 catch (Exception e) {
1631 throw processException(e);
1632 }
1633 finally {
1634 if (count == null) {
1635 count = Long.valueOf(0);
1636 }
1637
1638 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_COMPANYID,
1639 finderArgs, count);
1640
1641 closeSession(session);
1642 }
1643 }
1644
1645 return count.intValue();
1646 }
1647
1648 public int countByG_U(long groupId, long userId) throws SystemException {
1649 Object[] finderArgs = new Object[] { new Long(groupId), new Long(userId) };
1650
1651 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_U,
1652 finderArgs, this);
1653
1654 if (count == null) {
1655 Session session = null;
1656
1657 try {
1658 session = openSession();
1659
1660 StringBuilder query = new StringBuilder();
1661
1662 query.append("SELECT COUNT(scProductEntry) ");
1663 query.append("FROM SCProductEntry scProductEntry WHERE ");
1664
1665 query.append("scProductEntry.groupId = ?");
1666
1667 query.append(" AND ");
1668
1669 query.append("scProductEntry.userId = ?");
1670
1671 query.append(" ");
1672
1673 Query q = session.createQuery(query.toString());
1674
1675 QueryPos qPos = QueryPos.getInstance(q);
1676
1677 qPos.add(groupId);
1678
1679 qPos.add(userId);
1680
1681 count = (Long)q.uniqueResult();
1682 }
1683 catch (Exception e) {
1684 throw processException(e);
1685 }
1686 finally {
1687 if (count == null) {
1688 count = Long.valueOf(0);
1689 }
1690
1691 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_U, finderArgs,
1692 count);
1693
1694 closeSession(session);
1695 }
1696 }
1697
1698 return count.intValue();
1699 }
1700
1701 public int countByRG_RA(String repoGroupId, String repoArtifactId)
1702 throws SystemException {
1703 Object[] finderArgs = new Object[] { repoGroupId, repoArtifactId };
1704
1705 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_RG_RA,
1706 finderArgs, this);
1707
1708 if (count == null) {
1709 Session session = null;
1710
1711 try {
1712 session = openSession();
1713
1714 StringBuilder query = new StringBuilder();
1715
1716 query.append("SELECT COUNT(scProductEntry) ");
1717 query.append("FROM SCProductEntry scProductEntry WHERE ");
1718
1719 if (repoGroupId == null) {
1720 query.append("scProductEntry.repoGroupId IS NULL");
1721 }
1722 else {
1723 query.append("scProductEntry.lower(repoGroupId) = ?");
1724 }
1725
1726 query.append(" AND ");
1727
1728 if (repoArtifactId == null) {
1729 query.append("scProductEntry.repoArtifactId IS NULL");
1730 }
1731 else {
1732 query.append("scProductEntry.lower(repoArtifactId) = ?");
1733 }
1734
1735 query.append(" ");
1736
1737 Query q = session.createQuery(query.toString());
1738
1739 QueryPos qPos = QueryPos.getInstance(q);
1740
1741 if (repoGroupId != null) {
1742 qPos.add(repoGroupId);
1743 }
1744
1745 if (repoArtifactId != null) {
1746 qPos.add(repoArtifactId);
1747 }
1748
1749 count = (Long)q.uniqueResult();
1750 }
1751 catch (Exception e) {
1752 throw processException(e);
1753 }
1754 finally {
1755 if (count == null) {
1756 count = Long.valueOf(0);
1757 }
1758
1759 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_RG_RA,
1760 finderArgs, count);
1761
1762 closeSession(session);
1763 }
1764 }
1765
1766 return count.intValue();
1767 }
1768
1769 public int countAll() throws SystemException {
1770 Object[] finderArgs = new Object[0];
1771
1772 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
1773 finderArgs, this);
1774
1775 if (count == null) {
1776 Session session = null;
1777
1778 try {
1779 session = openSession();
1780
1781 Query q = session.createQuery(
1782 "SELECT COUNT(scProductEntry) FROM SCProductEntry scProductEntry");
1783
1784 count = (Long)q.uniqueResult();
1785 }
1786 catch (Exception e) {
1787 throw processException(e);
1788 }
1789 finally {
1790 if (count == null) {
1791 count = Long.valueOf(0);
1792 }
1793
1794 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL, finderArgs,
1795 count);
1796
1797 closeSession(session);
1798 }
1799 }
1800
1801 return count.intValue();
1802 }
1803
1804 public List<com.liferay.portlet.softwarecatalog.model.SCLicense> getSCLicenses(
1805 long pk) throws SystemException {
1806 return getSCLicenses(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
1807 }
1808
1809 public List<com.liferay.portlet.softwarecatalog.model.SCLicense> getSCLicenses(
1810 long pk, int start, int end) throws SystemException {
1811 return getSCLicenses(pk, start, end, null);
1812 }
1813
1814 public static final FinderPath FINDER_PATH_GET_SCLICENSES = new FinderPath(com.liferay.portlet.softwarecatalog.model.impl.SCLicenseModelImpl.ENTITY_CACHE_ENABLED,
1815 SCProductEntryModelImpl.FINDER_CACHE_ENABLED_SCLICENSES_SCPRODUCTENTRIES,
1816 "SCLicenses_SCProductEntries", "getSCLicenses",
1817 new String[] {
1818 Long.class.getName(), "java.lang.Integer", "java.lang.Integer",
1819 "com.liferay.portal.kernel.util.OrderByComparator"
1820 });
1821
1822 public List<com.liferay.portlet.softwarecatalog.model.SCLicense> getSCLicenses(
1823 long pk, int start, int end, OrderByComparator obc)
1824 throws SystemException {
1825 Object[] finderArgs = new Object[] {
1826 new Long(pk), String.valueOf(start), String.valueOf(end),
1827 String.valueOf(obc)
1828 };
1829
1830 List<com.liferay.portlet.softwarecatalog.model.SCLicense> list = (List<com.liferay.portlet.softwarecatalog.model.SCLicense>)FinderCacheUtil.getResult(FINDER_PATH_GET_SCLICENSES,
1831 finderArgs, this);
1832
1833 if (list == null) {
1834 Session session = null;
1835
1836 try {
1837 session = openSession();
1838
1839 StringBuilder sb = new StringBuilder();
1840
1841 sb.append(_SQL_GETSCLICENSES);
1842
1843 if (obc != null) {
1844 sb.append("ORDER BY ");
1845 sb.append(obc.getOrderBy());
1846 }
1847
1848 else {
1849 sb.append("ORDER BY ");
1850
1851 sb.append("SCLicense.name ASC");
1852 }
1853
1854 String sql = sb.toString();
1855
1856 SQLQuery q = session.createSQLQuery(sql);
1857
1858 q.addEntity("SCLicense",
1859 com.liferay.portlet.softwarecatalog.model.impl.SCLicenseImpl.class);
1860
1861 QueryPos qPos = QueryPos.getInstance(q);
1862
1863 qPos.add(pk);
1864
1865 list = (List<com.liferay.portlet.softwarecatalog.model.SCLicense>)QueryUtil.list(q,
1866 getDialect(), start, end);
1867 }
1868 catch (Exception e) {
1869 throw processException(e);
1870 }
1871 finally {
1872 if (list == null) {
1873 list = new ArrayList<com.liferay.portlet.softwarecatalog.model.SCLicense>();
1874 }
1875
1876 scLicensePersistence.cacheResult(list);
1877
1878 FinderCacheUtil.putResult(FINDER_PATH_GET_SCLICENSES,
1879 finderArgs, list);
1880
1881 closeSession(session);
1882 }
1883 }
1884
1885 return list;
1886 }
1887
1888 public static final FinderPath FINDER_PATH_GET_SCLICENSES_SIZE = new FinderPath(com.liferay.portlet.softwarecatalog.model.impl.SCLicenseModelImpl.ENTITY_CACHE_ENABLED,
1889 SCProductEntryModelImpl.FINDER_CACHE_ENABLED_SCLICENSES_SCPRODUCTENTRIES,
1890 "SCLicenses_SCProductEntries", "getSCLicensesSize",
1891 new String[] { Long.class.getName() });
1892
1893 public int getSCLicensesSize(long pk) throws SystemException {
1894 Object[] finderArgs = new Object[] { new Long(pk) };
1895
1896 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_GET_SCLICENSES_SIZE,
1897 finderArgs, this);
1898
1899 if (count == null) {
1900 Session session = null;
1901
1902 try {
1903 session = openSession();
1904
1905 SQLQuery q = session.createSQLQuery(_SQL_GETSCLICENSESSIZE);
1906
1907 q.addScalar(COUNT_COLUMN_NAME, Type.LONG);
1908
1909 QueryPos qPos = QueryPos.getInstance(q);
1910
1911 qPos.add(pk);
1912
1913 count = (Long)q.uniqueResult();
1914 }
1915 catch (Exception e) {
1916 throw processException(e);
1917 }
1918 finally {
1919 if (count == null) {
1920 count = Long.valueOf(0);
1921 }
1922
1923 FinderCacheUtil.putResult(FINDER_PATH_GET_SCLICENSES_SIZE,
1924 finderArgs, count);
1925
1926 closeSession(session);
1927 }
1928 }
1929
1930 return count.intValue();
1931 }
1932
1933 public static final FinderPath FINDER_PATH_CONTAINS_SCLICENSE = new FinderPath(com.liferay.portlet.softwarecatalog.model.impl.SCLicenseModelImpl.ENTITY_CACHE_ENABLED,
1934 SCProductEntryModelImpl.FINDER_CACHE_ENABLED_SCLICENSES_SCPRODUCTENTRIES,
1935 "SCLicenses_SCProductEntries", "containsSCLicense",
1936 new String[] { Long.class.getName(), Long.class.getName() });
1937
1938 public boolean containsSCLicense(long pk, long scLicensePK)
1939 throws SystemException {
1940 Object[] finderArgs = new Object[] { new Long(pk), new Long(scLicensePK) };
1941
1942 Boolean value = (Boolean)FinderCacheUtil.getResult(FINDER_PATH_CONTAINS_SCLICENSE,
1943 finderArgs, this);
1944
1945 if (value == null) {
1946 try {
1947 value = Boolean.valueOf(containsSCLicense.contains(pk,
1948 scLicensePK));
1949 }
1950 catch (Exception e) {
1951 throw processException(e);
1952 }
1953 finally {
1954 if (value == null) {
1955 value = Boolean.FALSE;
1956 }
1957
1958 FinderCacheUtil.putResult(FINDER_PATH_CONTAINS_SCLICENSE,
1959 finderArgs, value);
1960 }
1961 }
1962
1963 return value.booleanValue();
1964 }
1965
1966 public boolean containsSCLicenses(long pk) throws SystemException {
1967 if (getSCLicensesSize(pk) > 0) {
1968 return true;
1969 }
1970 else {
1971 return false;
1972 }
1973 }
1974
1975 public void addSCLicense(long pk, long scLicensePK)
1976 throws SystemException {
1977 try {
1978 addSCLicense.add(pk, scLicensePK);
1979 }
1980 catch (Exception e) {
1981 throw processException(e);
1982 }
1983 finally {
1984 FinderCacheUtil.clearCache("SCLicenses_SCProductEntries");
1985 }
1986 }
1987
1988 public void addSCLicense(long pk,
1989 com.liferay.portlet.softwarecatalog.model.SCLicense scLicense)
1990 throws SystemException {
1991 try {
1992 addSCLicense.add(pk, scLicense.getPrimaryKey());
1993 }
1994 catch (Exception e) {
1995 throw processException(e);
1996 }
1997 finally {
1998 FinderCacheUtil.clearCache("SCLicenses_SCProductEntries");
1999 }
2000 }
2001
2002 public void addSCLicenses(long pk, long[] scLicensePKs)
2003 throws SystemException {
2004 try {
2005 for (long scLicensePK : scLicensePKs) {
2006 addSCLicense.add(pk, scLicensePK);
2007 }
2008 }
2009 catch (Exception e) {
2010 throw processException(e);
2011 }
2012 finally {
2013 FinderCacheUtil.clearCache("SCLicenses_SCProductEntries");
2014 }
2015 }
2016
2017 public void addSCLicenses(long pk,
2018 List<com.liferay.portlet.softwarecatalog.model.SCLicense> scLicenses)
2019 throws SystemException {
2020 try {
2021 for (com.liferay.portlet.softwarecatalog.model.SCLicense scLicense : scLicenses) {
2022 addSCLicense.add(pk, scLicense.getPrimaryKey());
2023 }
2024 }
2025 catch (Exception e) {
2026 throw processException(e);
2027 }
2028 finally {
2029 FinderCacheUtil.clearCache("SCLicenses_SCProductEntries");
2030 }
2031 }
2032
2033 public void clearSCLicenses(long pk) throws SystemException {
2034 try {
2035 clearSCLicenses.clear(pk);
2036 }
2037 catch (Exception e) {
2038 throw processException(e);
2039 }
2040 finally {
2041 FinderCacheUtil.clearCache("SCLicenses_SCProductEntries");
2042 }
2043 }
2044
2045 public void removeSCLicense(long pk, long scLicensePK)
2046 throws SystemException {
2047 try {
2048 removeSCLicense.remove(pk, scLicensePK);
2049 }
2050 catch (Exception e) {
2051 throw processException(e);
2052 }
2053 finally {
2054 FinderCacheUtil.clearCache("SCLicenses_SCProductEntries");
2055 }
2056 }
2057
2058 public void removeSCLicense(long pk,
2059 com.liferay.portlet.softwarecatalog.model.SCLicense scLicense)
2060 throws SystemException {
2061 try {
2062 removeSCLicense.remove(pk, scLicense.getPrimaryKey());
2063 }
2064 catch (Exception e) {
2065 throw processException(e);
2066 }
2067 finally {
2068 FinderCacheUtil.clearCache("SCLicenses_SCProductEntries");
2069 }
2070 }
2071
2072 public void removeSCLicenses(long pk, long[] scLicensePKs)
2073 throws SystemException {
2074 try {
2075 for (long scLicensePK : scLicensePKs) {
2076 removeSCLicense.remove(pk, scLicensePK);
2077 }
2078 }
2079 catch (Exception e) {
2080 throw processException(e);
2081 }
2082 finally {
2083 FinderCacheUtil.clearCache("SCLicenses_SCProductEntries");
2084 }
2085 }
2086
2087 public void removeSCLicenses(long pk,
2088 List<com.liferay.portlet.softwarecatalog.model.SCLicense> scLicenses)
2089 throws SystemException {
2090 try {
2091 for (com.liferay.portlet.softwarecatalog.model.SCLicense scLicense : scLicenses) {
2092 removeSCLicense.remove(pk, scLicense.getPrimaryKey());
2093 }
2094 }
2095 catch (Exception e) {
2096 throw processException(e);
2097 }
2098 finally {
2099 FinderCacheUtil.clearCache("SCLicenses_SCProductEntries");
2100 }
2101 }
2102
2103 public void setSCLicenses(long pk, long[] scLicensePKs)
2104 throws SystemException {
2105 try {
2106 clearSCLicenses.clear(pk);
2107
2108 for (long scLicensePK : scLicensePKs) {
2109 addSCLicense.add(pk, scLicensePK);
2110 }
2111 }
2112 catch (Exception e) {
2113 throw processException(e);
2114 }
2115 finally {
2116 FinderCacheUtil.clearCache("SCLicenses_SCProductEntries");
2117 }
2118 }
2119
2120 public void setSCLicenses(long pk,
2121 List<com.liferay.portlet.softwarecatalog.model.SCLicense> scLicenses)
2122 throws SystemException {
2123 try {
2124 clearSCLicenses.clear(pk);
2125
2126 for (com.liferay.portlet.softwarecatalog.model.SCLicense scLicense : scLicenses) {
2127 addSCLicense.add(pk, scLicense.getPrimaryKey());
2128 }
2129 }
2130 catch (Exception e) {
2131 throw processException(e);
2132 }
2133 finally {
2134 FinderCacheUtil.clearCache("SCLicenses_SCProductEntries");
2135 }
2136 }
2137
2138 public void afterPropertiesSet() {
2139 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
2140 com.liferay.portal.util.PropsUtil.get(
2141 "value.object.listener.com.liferay.portlet.softwarecatalog.model.SCProductEntry")));
2142
2143 if (listenerClassNames.length > 0) {
2144 try {
2145 List<ModelListener<SCProductEntry>> listenersList = new ArrayList<ModelListener<SCProductEntry>>();
2146
2147 for (String listenerClassName : listenerClassNames) {
2148 listenersList.add((ModelListener<SCProductEntry>)Class.forName(
2149 listenerClassName).newInstance());
2150 }
2151
2152 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
2153 }
2154 catch (Exception e) {
2155 _log.error(e);
2156 }
2157 }
2158
2159 containsSCLicense = new ContainsSCLicense(this);
2160
2161 addSCLicense = new AddSCLicense(this);
2162 clearSCLicenses = new ClearSCLicenses(this);
2163 removeSCLicense = new RemoveSCLicense(this);
2164 }
2165
2166 @BeanReference(name = "com.liferay.portlet.softwarecatalog.service.persistence.SCLicensePersistence.impl")
2167 protected com.liferay.portlet.softwarecatalog.service.persistence.SCLicensePersistence scLicensePersistence;
2168 @BeanReference(name = "com.liferay.portlet.softwarecatalog.service.persistence.SCFrameworkVersionPersistence.impl")
2169 protected com.liferay.portlet.softwarecatalog.service.persistence.SCFrameworkVersionPersistence scFrameworkVersionPersistence;
2170 @BeanReference(name = "com.liferay.portlet.softwarecatalog.service.persistence.SCProductEntryPersistence.impl")
2171 protected com.liferay.portlet.softwarecatalog.service.persistence.SCProductEntryPersistence scProductEntryPersistence;
2172 @BeanReference(name = "com.liferay.portlet.softwarecatalog.service.persistence.SCProductScreenshotPersistence.impl")
2173 protected com.liferay.portlet.softwarecatalog.service.persistence.SCProductScreenshotPersistence scProductScreenshotPersistence;
2174 @BeanReference(name = "com.liferay.portlet.softwarecatalog.service.persistence.SCProductVersionPersistence.impl")
2175 protected com.liferay.portlet.softwarecatalog.service.persistence.SCProductVersionPersistence scProductVersionPersistence;
2176 @BeanReference(name = "com.liferay.portal.service.persistence.ImagePersistence.impl")
2177 protected com.liferay.portal.service.persistence.ImagePersistence imagePersistence;
2178 @BeanReference(name = "com.liferay.portal.service.persistence.ResourcePersistence.impl")
2179 protected com.liferay.portal.service.persistence.ResourcePersistence resourcePersistence;
2180 @BeanReference(name = "com.liferay.portal.service.persistence.UserPersistence.impl")
2181 protected com.liferay.portal.service.persistence.UserPersistence userPersistence;
2182 @BeanReference(name = "com.liferay.portlet.messageboards.service.persistence.MBMessagePersistence.impl")
2183 protected com.liferay.portlet.messageboards.service.persistence.MBMessagePersistence mbMessagePersistence;
2184 @BeanReference(name = "com.liferay.portlet.ratings.service.persistence.RatingsStatsPersistence.impl")
2185 protected com.liferay.portlet.ratings.service.persistence.RatingsStatsPersistence ratingsStatsPersistence;
2186 protected ContainsSCLicense containsSCLicense;
2187 protected AddSCLicense addSCLicense;
2188 protected ClearSCLicenses clearSCLicenses;
2189 protected RemoveSCLicense removeSCLicense;
2190
2191 protected class ContainsSCLicense {
2192 protected ContainsSCLicense(
2193 SCProductEntryPersistenceImpl persistenceImpl) {
2194 super();
2195
2196 _mappingSqlQuery = MappingSqlQueryFactoryUtil.getMappingSqlQuery(getDataSource(),
2197 _SQL_CONTAINSSCLICENSE,
2198 new int[] { Types.BIGINT, Types.BIGINT }, RowMapper.COUNT);
2199 }
2200
2201 protected boolean contains(long productEntryId, long licenseId) {
2202 List<Integer> results = _mappingSqlQuery.execute(new Object[] {
2203 new Long(productEntryId), new Long(licenseId)
2204 });
2205
2206 if (results.size() > 0) {
2207 Integer count = results.get(0);
2208
2209 if (count.intValue() > 0) {
2210 return true;
2211 }
2212 }
2213
2214 return false;
2215 }
2216
2217 private MappingSqlQuery _mappingSqlQuery;
2218 }
2219
2220 protected class AddSCLicense {
2221 protected AddSCLicense(SCProductEntryPersistenceImpl persistenceImpl) {
2222 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
2223 "INSERT INTO SCLicenses_SCProductEntries (productEntryId, licenseId) VALUES (?, ?)",
2224 new int[] { Types.BIGINT, Types.BIGINT });
2225 _persistenceImpl = persistenceImpl;
2226 }
2227
2228 protected void add(long productEntryId, long licenseId)
2229 throws SystemException {
2230 if (!_persistenceImpl.containsSCLicense.contains(productEntryId,
2231 licenseId)) {
2232 ModelListener<com.liferay.portlet.softwarecatalog.model.SCLicense>[] scLicenseListeners =
2233 scLicensePersistence.getListeners();
2234
2235 for (ModelListener<SCProductEntry> listener : listeners) {
2236 listener.onBeforeAddAssociation(productEntryId,
2237 com.liferay.portlet.softwarecatalog.model.SCLicense.class.getName(),
2238 licenseId);
2239 }
2240
2241 for (ModelListener<com.liferay.portlet.softwarecatalog.model.SCLicense> listener : scLicenseListeners) {
2242 listener.onBeforeAddAssociation(licenseId,
2243 SCProductEntry.class.getName(), productEntryId);
2244 }
2245
2246 _sqlUpdate.update(new Object[] {
2247 new Long(productEntryId), new Long(licenseId)
2248 });
2249
2250 for (ModelListener<SCProductEntry> listener : listeners) {
2251 listener.onAfterAddAssociation(productEntryId,
2252 com.liferay.portlet.softwarecatalog.model.SCLicense.class.getName(),
2253 licenseId);
2254 }
2255
2256 for (ModelListener<com.liferay.portlet.softwarecatalog.model.SCLicense> listener : scLicenseListeners) {
2257 listener.onAfterAddAssociation(licenseId,
2258 SCProductEntry.class.getName(), productEntryId);
2259 }
2260 }
2261 }
2262
2263 private SqlUpdate _sqlUpdate;
2264 private SCProductEntryPersistenceImpl _persistenceImpl;
2265 }
2266
2267 protected class ClearSCLicenses {
2268 protected ClearSCLicenses(SCProductEntryPersistenceImpl persistenceImpl) {
2269 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
2270 "DELETE FROM SCLicenses_SCProductEntries WHERE productEntryId = ?",
2271 new int[] { Types.BIGINT });
2272 }
2273
2274 protected void clear(long productEntryId) throws SystemException {
2275 ModelListener<com.liferay.portlet.softwarecatalog.model.SCLicense>[] scLicenseListeners =
2276 scLicensePersistence.getListeners();
2277
2278 List<com.liferay.portlet.softwarecatalog.model.SCLicense> scLicenses =
2279 null;
2280
2281 if ((listeners.length > 0) || (scLicenseListeners.length > 0)) {
2282 scLicenses = getSCLicenses(productEntryId);
2283
2284 for (com.liferay.portlet.softwarecatalog.model.SCLicense scLicense : scLicenses) {
2285 for (ModelListener<SCProductEntry> listener : listeners) {
2286 listener.onBeforeRemoveAssociation(productEntryId,
2287 com.liferay.portlet.softwarecatalog.model.SCLicense.class.getName(),
2288 scLicense.getPrimaryKey());
2289 }
2290
2291 for (ModelListener<com.liferay.portlet.softwarecatalog.model.SCLicense> listener : scLicenseListeners) {
2292 listener.onBeforeRemoveAssociation(scLicense.getPrimaryKey(),
2293 SCProductEntry.class.getName(), productEntryId);
2294 }
2295 }
2296 }
2297
2298 _sqlUpdate.update(new Object[] { new Long(productEntryId) });
2299
2300 if ((listeners.length > 0) || (scLicenseListeners.length > 0)) {
2301 for (com.liferay.portlet.softwarecatalog.model.SCLicense scLicense : scLicenses) {
2302 for (ModelListener<SCProductEntry> listener : listeners) {
2303 listener.onAfterRemoveAssociation(productEntryId,
2304 com.liferay.portlet.softwarecatalog.model.SCLicense.class.getName(),
2305 scLicense.getPrimaryKey());
2306 }
2307
2308 for (ModelListener<com.liferay.portlet.softwarecatalog.model.SCLicense> listener : scLicenseListeners) {
2309 listener.onBeforeRemoveAssociation(scLicense.getPrimaryKey(),
2310 SCProductEntry.class.getName(), productEntryId);
2311 }
2312 }
2313 }
2314 }
2315
2316 private SqlUpdate _sqlUpdate;
2317 }
2318
2319 protected class RemoveSCLicense {
2320 protected RemoveSCLicense(SCProductEntryPersistenceImpl persistenceImpl) {
2321 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
2322 "DELETE FROM SCLicenses_SCProductEntries WHERE productEntryId = ? AND licenseId = ?",
2323 new int[] { Types.BIGINT, Types.BIGINT });
2324 _persistenceImpl = persistenceImpl;
2325 }
2326
2327 protected void remove(long productEntryId, long licenseId)
2328 throws SystemException {
2329 if (_persistenceImpl.containsSCLicense.contains(productEntryId,
2330 licenseId)) {
2331 ModelListener<com.liferay.portlet.softwarecatalog.model.SCLicense>[] scLicenseListeners =
2332 scLicensePersistence.getListeners();
2333
2334 for (ModelListener<SCProductEntry> listener : listeners) {
2335 listener.onBeforeRemoveAssociation(productEntryId,
2336 com.liferay.portlet.softwarecatalog.model.SCLicense.class.getName(),
2337 licenseId);
2338 }
2339
2340 for (ModelListener<com.liferay.portlet.softwarecatalog.model.SCLicense> listener : scLicenseListeners) {
2341 listener.onBeforeRemoveAssociation(licenseId,
2342 SCProductEntry.class.getName(), productEntryId);
2343 }
2344
2345 _sqlUpdate.update(new Object[] {
2346 new Long(productEntryId), new Long(licenseId)
2347 });
2348
2349 for (ModelListener<SCProductEntry> listener : listeners) {
2350 listener.onAfterRemoveAssociation(productEntryId,
2351 com.liferay.portlet.softwarecatalog.model.SCLicense.class.getName(),
2352 licenseId);
2353 }
2354
2355 for (ModelListener<com.liferay.portlet.softwarecatalog.model.SCLicense> listener : scLicenseListeners) {
2356 listener.onAfterRemoveAssociation(licenseId,
2357 SCProductEntry.class.getName(), productEntryId);
2358 }
2359 }
2360 }
2361
2362 private SqlUpdate _sqlUpdate;
2363 private SCProductEntryPersistenceImpl _persistenceImpl;
2364 }
2365
2366 private static final String _SQL_GETSCLICENSES = "SELECT {SCLicense.*} FROM SCLicense INNER JOIN SCLicenses_SCProductEntries ON (SCLicenses_SCProductEntries.licenseId = SCLicense.licenseId) WHERE (SCLicenses_SCProductEntries.productEntryId = ?)";
2367 private static final String _SQL_GETSCLICENSESSIZE = "SELECT COUNT(*) AS COUNT_VALUE FROM SCLicenses_SCProductEntries WHERE productEntryId = ?";
2368 private static final String _SQL_CONTAINSSCLICENSE = "SELECT COUNT(*) AS COUNT_VALUE FROM SCLicenses_SCProductEntries WHERE productEntryId = ? AND licenseId = ?";
2369 private static Log _log = LogFactoryUtil.getLog(SCProductEntryPersistenceImpl.class);
2370}