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