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