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