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