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