001
014
015 package com.liferay.portlet.softwarecatalog.service.persistence;
016
017 import com.liferay.portal.NoSuchModelException;
018 import com.liferay.portal.kernel.annotation.BeanReference;
019 import com.liferay.portal.kernel.cache.CacheRegistryUtil;
020 import com.liferay.portal.kernel.dao.jdbc.MappingSqlQuery;
021 import com.liferay.portal.kernel.dao.jdbc.MappingSqlQueryFactoryUtil;
022 import com.liferay.portal.kernel.dao.jdbc.RowMapper;
023 import com.liferay.portal.kernel.dao.jdbc.SqlUpdate;
024 import com.liferay.portal.kernel.dao.jdbc.SqlUpdateFactoryUtil;
025 import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
026 import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
027 import com.liferay.portal.kernel.dao.orm.FinderPath;
028 import com.liferay.portal.kernel.dao.orm.Query;
029 import com.liferay.portal.kernel.dao.orm.QueryPos;
030 import com.liferay.portal.kernel.dao.orm.QueryUtil;
031 import com.liferay.portal.kernel.dao.orm.SQLQuery;
032 import com.liferay.portal.kernel.dao.orm.Session;
033 import com.liferay.portal.kernel.exception.SystemException;
034 import com.liferay.portal.kernel.log.Log;
035 import com.liferay.portal.kernel.log.LogFactoryUtil;
036 import com.liferay.portal.kernel.util.GetterUtil;
037 import com.liferay.portal.kernel.util.InstanceFactory;
038 import com.liferay.portal.kernel.util.OrderByComparator;
039 import com.liferay.portal.kernel.util.SetUtil;
040 import com.liferay.portal.kernel.util.StringBundler;
041 import com.liferay.portal.kernel.util.StringPool;
042 import com.liferay.portal.kernel.util.StringUtil;
043 import com.liferay.portal.kernel.util.Validator;
044 import com.liferay.portal.model.ModelListener;
045 import com.liferay.portal.security.permission.InlineSQLHelperUtil;
046 import com.liferay.portal.service.persistence.BatchSessionUtil;
047 import com.liferay.portal.service.persistence.GroupPersistence;
048 import com.liferay.portal.service.persistence.ImagePersistence;
049 import com.liferay.portal.service.persistence.ResourcePersistence;
050 import com.liferay.portal.service.persistence.UserPersistence;
051 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
052
053 import com.liferay.portlet.messageboards.service.persistence.MBMessagePersistence;
054 import com.liferay.portlet.ratings.service.persistence.RatingsStatsPersistence;
055 import com.liferay.portlet.softwarecatalog.NoSuchProductEntryException;
056 import com.liferay.portlet.softwarecatalog.model.SCProductEntry;
057 import com.liferay.portlet.softwarecatalog.model.impl.SCProductEntryImpl;
058 import com.liferay.portlet.softwarecatalog.model.impl.SCProductEntryModelImpl;
059
060 import java.io.Serializable;
061
062 import java.util.ArrayList;
063 import java.util.Collections;
064 import java.util.List;
065 import java.util.Set;
066
067
083 public class SCProductEntryPersistenceImpl extends BasePersistenceImpl<SCProductEntry>
084 implements SCProductEntryPersistence {
085 public static final String FINDER_CLASS_NAME_ENTITY = SCProductEntryImpl.class.getName();
086 public static final String FINDER_CLASS_NAME_LIST = FINDER_CLASS_NAME_ENTITY +
087 ".List";
088 public static final FinderPath FINDER_PATH_FIND_BY_GROUPID = new FinderPath(SCProductEntryModelImpl.ENTITY_CACHE_ENABLED,
089 SCProductEntryModelImpl.FINDER_CACHE_ENABLED,
090 FINDER_CLASS_NAME_LIST, "findByGroupId",
091 new String[] {
092 Long.class.getName(),
093
094 "java.lang.Integer", "java.lang.Integer",
095 "com.liferay.portal.kernel.util.OrderByComparator"
096 });
097 public static final FinderPath FINDER_PATH_COUNT_BY_GROUPID = new FinderPath(SCProductEntryModelImpl.ENTITY_CACHE_ENABLED,
098 SCProductEntryModelImpl.FINDER_CACHE_ENABLED,
099 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
147 public void cacheResult(SCProductEntry scProductEntry) {
148 EntityCacheUtil.putResult(SCProductEntryModelImpl.ENTITY_CACHE_ENABLED,
149 SCProductEntryImpl.class, scProductEntry.getPrimaryKey(),
150 scProductEntry);
151
152 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_RG_RA,
153 new Object[] {
154 scProductEntry.getRepoGroupId(),
155
156 scProductEntry.getRepoArtifactId()
157 }, scProductEntry);
158 }
159
160
165 public void cacheResult(List<SCProductEntry> scProductEntries) {
166 for (SCProductEntry scProductEntry : scProductEntries) {
167 if (EntityCacheUtil.getResult(
168 SCProductEntryModelImpl.ENTITY_CACHE_ENABLED,
169 SCProductEntryImpl.class,
170 scProductEntry.getPrimaryKey(), this) == null) {
171 cacheResult(scProductEntry);
172 }
173 }
174 }
175
176
183 public void clearCache() {
184 CacheRegistryUtil.clear(SCProductEntryImpl.class.getName());
185 EntityCacheUtil.clearCache(SCProductEntryImpl.class.getName());
186 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
187 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
188 }
189
190
197 public void clearCache(SCProductEntry scProductEntry) {
198 EntityCacheUtil.removeResult(SCProductEntryModelImpl.ENTITY_CACHE_ENABLED,
199 SCProductEntryImpl.class, scProductEntry.getPrimaryKey());
200
201 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_RG_RA,
202 new Object[] {
203 scProductEntry.getRepoGroupId(),
204
205 scProductEntry.getRepoArtifactId()
206 });
207 }
208
209
215 public SCProductEntry create(long productEntryId) {
216 SCProductEntry scProductEntry = new SCProductEntryImpl();
217
218 scProductEntry.setNew(true);
219 scProductEntry.setPrimaryKey(productEntryId);
220
221 return scProductEntry;
222 }
223
224
232 public SCProductEntry remove(Serializable primaryKey)
233 throws NoSuchModelException, SystemException {
234 return remove(((Long)primaryKey).longValue());
235 }
236
237
245 public SCProductEntry remove(long productEntryId)
246 throws NoSuchProductEntryException, SystemException {
247 Session session = null;
248
249 try {
250 session = openSession();
251
252 SCProductEntry scProductEntry = (SCProductEntry)session.get(SCProductEntryImpl.class,
253 new Long(productEntryId));
254
255 if (scProductEntry == null) {
256 if (_log.isWarnEnabled()) {
257 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
258 productEntryId);
259 }
260
261 throw new NoSuchProductEntryException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
262 productEntryId);
263 }
264
265 return remove(scProductEntry);
266 }
267 catch (NoSuchProductEntryException nsee) {
268 throw nsee;
269 }
270 catch (Exception e) {
271 throw processException(e);
272 }
273 finally {
274 closeSession(session);
275 }
276 }
277
278 protected SCProductEntry removeImpl(SCProductEntry scProductEntry)
279 throws SystemException {
280 scProductEntry = toUnwrappedModel(scProductEntry);
281
282 try {
283 clearSCLicenses.clear(scProductEntry.getPrimaryKey());
284 }
285 catch (Exception e) {
286 throw processException(e);
287 }
288 finally {
289 FinderCacheUtil.clearCache(SCProductEntryModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME);
290 }
291
292 Session session = null;
293
294 try {
295 session = openSession();
296
297 if (scProductEntry.isCachedModel() || BatchSessionUtil.isEnabled()) {
298 Object staleObject = session.get(SCProductEntryImpl.class,
299 scProductEntry.getPrimaryKeyObj());
300
301 if (staleObject != null) {
302 session.evict(staleObject);
303 }
304 }
305
306 session.delete(scProductEntry);
307
308 session.flush();
309 }
310 catch (Exception e) {
311 throw processException(e);
312 }
313 finally {
314 closeSession(session);
315 }
316
317 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
318
319 SCProductEntryModelImpl scProductEntryModelImpl = (SCProductEntryModelImpl)scProductEntry;
320
321 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_RG_RA,
322 new Object[] {
323 scProductEntryModelImpl.getOriginalRepoGroupId(),
324
325 scProductEntryModelImpl.getOriginalRepoArtifactId()
326 });
327
328 EntityCacheUtil.removeResult(SCProductEntryModelImpl.ENTITY_CACHE_ENABLED,
329 SCProductEntryImpl.class, scProductEntry.getPrimaryKey());
330
331 return scProductEntry;
332 }
333
334 public SCProductEntry updateImpl(
335 com.liferay.portlet.softwarecatalog.model.SCProductEntry scProductEntry,
336 boolean merge) throws SystemException {
337 scProductEntry = toUnwrappedModel(scProductEntry);
338
339 boolean isNew = scProductEntry.isNew();
340
341 SCProductEntryModelImpl scProductEntryModelImpl = (SCProductEntryModelImpl)scProductEntry;
342
343 Session session = null;
344
345 try {
346 session = openSession();
347
348 BatchSessionUtil.update(session, scProductEntry, merge);
349
350 scProductEntry.setNew(false);
351 }
352 catch (Exception e) {
353 throw processException(e);
354 }
355 finally {
356 closeSession(session);
357 }
358
359 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
360
361 EntityCacheUtil.putResult(SCProductEntryModelImpl.ENTITY_CACHE_ENABLED,
362 SCProductEntryImpl.class, scProductEntry.getPrimaryKey(),
363 scProductEntry);
364
365 if (!isNew &&
366 (!Validator.equals(scProductEntry.getRepoGroupId(),
367 scProductEntryModelImpl.getOriginalRepoGroupId()) ||
368 !Validator.equals(scProductEntry.getRepoArtifactId(),
369 scProductEntryModelImpl.getOriginalRepoArtifactId()))) {
370 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_RG_RA,
371 new Object[] {
372 scProductEntryModelImpl.getOriginalRepoGroupId(),
373
374 scProductEntryModelImpl.getOriginalRepoArtifactId()
375 });
376 }
377
378 if (isNew ||
379 (!Validator.equals(scProductEntry.getRepoGroupId(),
380 scProductEntryModelImpl.getOriginalRepoGroupId()) ||
381 !Validator.equals(scProductEntry.getRepoArtifactId(),
382 scProductEntryModelImpl.getOriginalRepoArtifactId()))) {
383 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_RG_RA,
384 new Object[] {
385 scProductEntry.getRepoGroupId(),
386
387 scProductEntry.getRepoArtifactId()
388 }, scProductEntry);
389 }
390
391 return scProductEntry;
392 }
393
394 protected SCProductEntry toUnwrappedModel(SCProductEntry scProductEntry) {
395 if (scProductEntry instanceof SCProductEntryImpl) {
396 return scProductEntry;
397 }
398
399 SCProductEntryImpl scProductEntryImpl = new SCProductEntryImpl();
400
401 scProductEntryImpl.setNew(scProductEntry.isNew());
402 scProductEntryImpl.setPrimaryKey(scProductEntry.getPrimaryKey());
403
404 scProductEntryImpl.setProductEntryId(scProductEntry.getProductEntryId());
405 scProductEntryImpl.setGroupId(scProductEntry.getGroupId());
406 scProductEntryImpl.setCompanyId(scProductEntry.getCompanyId());
407 scProductEntryImpl.setUserId(scProductEntry.getUserId());
408 scProductEntryImpl.setUserName(scProductEntry.getUserName());
409 scProductEntryImpl.setCreateDate(scProductEntry.getCreateDate());
410 scProductEntryImpl.setModifiedDate(scProductEntry.getModifiedDate());
411 scProductEntryImpl.setName(scProductEntry.getName());
412 scProductEntryImpl.setType(scProductEntry.getType());
413 scProductEntryImpl.setTags(scProductEntry.getTags());
414 scProductEntryImpl.setShortDescription(scProductEntry.getShortDescription());
415 scProductEntryImpl.setLongDescription(scProductEntry.getLongDescription());
416 scProductEntryImpl.setPageURL(scProductEntry.getPageURL());
417 scProductEntryImpl.setAuthor(scProductEntry.getAuthor());
418 scProductEntryImpl.setRepoGroupId(scProductEntry.getRepoGroupId());
419 scProductEntryImpl.setRepoArtifactId(scProductEntry.getRepoArtifactId());
420
421 return scProductEntryImpl;
422 }
423
424
432 public SCProductEntry findByPrimaryKey(Serializable primaryKey)
433 throws NoSuchModelException, SystemException {
434 return findByPrimaryKey(((Long)primaryKey).longValue());
435 }
436
437
445 public SCProductEntry findByPrimaryKey(long productEntryId)
446 throws NoSuchProductEntryException, SystemException {
447 SCProductEntry scProductEntry = fetchByPrimaryKey(productEntryId);
448
449 if (scProductEntry == null) {
450 if (_log.isWarnEnabled()) {
451 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + productEntryId);
452 }
453
454 throw new NoSuchProductEntryException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
455 productEntryId);
456 }
457
458 return scProductEntry;
459 }
460
461
468 public SCProductEntry fetchByPrimaryKey(Serializable primaryKey)
469 throws SystemException {
470 return fetchByPrimaryKey(((Long)primaryKey).longValue());
471 }
472
473
480 public SCProductEntry fetchByPrimaryKey(long productEntryId)
481 throws SystemException {
482 SCProductEntry scProductEntry = (SCProductEntry)EntityCacheUtil.getResult(SCProductEntryModelImpl.ENTITY_CACHE_ENABLED,
483 SCProductEntryImpl.class, productEntryId, this);
484
485 if (scProductEntry == null) {
486 Session session = null;
487
488 try {
489 session = openSession();
490
491 scProductEntry = (SCProductEntry)session.get(SCProductEntryImpl.class,
492 new Long(productEntryId));
493 }
494 catch (Exception e) {
495 throw processException(e);
496 }
497 finally {
498 if (scProductEntry != null) {
499 cacheResult(scProductEntry);
500 }
501
502 closeSession(session);
503 }
504 }
505
506 return scProductEntry;
507 }
508
509
516 public List<SCProductEntry> findByGroupId(long groupId)
517 throws SystemException {
518 return findByGroupId(groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
519 }
520
521
534 public List<SCProductEntry> findByGroupId(long groupId, int start, int end)
535 throws SystemException {
536 return findByGroupId(groupId, start, end, null);
537 }
538
539
553 public List<SCProductEntry> findByGroupId(long groupId, int start, int end,
554 OrderByComparator orderByComparator) throws SystemException {
555 Object[] finderArgs = new Object[] {
556 groupId,
557
558 String.valueOf(start), String.valueOf(end),
559 String.valueOf(orderByComparator)
560 };
561
562 List<SCProductEntry> list = (List<SCProductEntry>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_GROUPID,
563 finderArgs, this);
564
565 if (list == null) {
566 Session session = null;
567
568 try {
569 session = openSession();
570
571 StringBundler query = null;
572
573 if (orderByComparator != null) {
574 query = new StringBundler(3 +
575 (orderByComparator.getOrderByFields().length * 3));
576 }
577 else {
578 query = new StringBundler(3);
579 }
580
581 query.append(_SQL_SELECT_SCPRODUCTENTRY_WHERE);
582
583 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
584
585 if (orderByComparator != null) {
586 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
587 orderByComparator);
588 }
589
590 else {
591 query.append(SCProductEntryModelImpl.ORDER_BY_JPQL);
592 }
593
594 String sql = query.toString();
595
596 Query q = session.createQuery(sql);
597
598 QueryPos qPos = QueryPos.getInstance(q);
599
600 qPos.add(groupId);
601
602 list = (List<SCProductEntry>)QueryUtil.list(q, getDialect(),
603 start, end);
604 }
605 catch (Exception e) {
606 throw processException(e);
607 }
608 finally {
609 if (list == null) {
610 list = new ArrayList<SCProductEntry>();
611 }
612
613 cacheResult(list);
614
615 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_GROUPID,
616 finderArgs, list);
617
618 closeSession(session);
619 }
620 }
621
622 return list;
623 }
624
625
638 public SCProductEntry findByGroupId_First(long groupId,
639 OrderByComparator orderByComparator)
640 throws NoSuchProductEntryException, SystemException {
641 List<SCProductEntry> list = findByGroupId(groupId, 0, 1,
642 orderByComparator);
643
644 if (list.isEmpty()) {
645 StringBundler msg = new StringBundler(4);
646
647 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
648
649 msg.append("groupId=");
650 msg.append(groupId);
651
652 msg.append(StringPool.CLOSE_CURLY_BRACE);
653
654 throw new NoSuchProductEntryException(msg.toString());
655 }
656 else {
657 return list.get(0);
658 }
659 }
660
661
674 public SCProductEntry findByGroupId_Last(long groupId,
675 OrderByComparator orderByComparator)
676 throws NoSuchProductEntryException, SystemException {
677 int count = countByGroupId(groupId);
678
679 List<SCProductEntry> list = findByGroupId(groupId, count - 1, count,
680 orderByComparator);
681
682 if (list.isEmpty()) {
683 StringBundler msg = new StringBundler(4);
684
685 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
686
687 msg.append("groupId=");
688 msg.append(groupId);
689
690 msg.append(StringPool.CLOSE_CURLY_BRACE);
691
692 throw new NoSuchProductEntryException(msg.toString());
693 }
694 else {
695 return list.get(0);
696 }
697 }
698
699
713 public SCProductEntry[] findByGroupId_PrevAndNext(long productEntryId,
714 long groupId, OrderByComparator orderByComparator)
715 throws NoSuchProductEntryException, SystemException {
716 SCProductEntry scProductEntry = findByPrimaryKey(productEntryId);
717
718 Session session = null;
719
720 try {
721 session = openSession();
722
723 SCProductEntry[] array = new SCProductEntryImpl[3];
724
725 array[0] = getByGroupId_PrevAndNext(session, scProductEntry,
726 groupId, orderByComparator, true);
727
728 array[1] = scProductEntry;
729
730 array[2] = getByGroupId_PrevAndNext(session, scProductEntry,
731 groupId, orderByComparator, false);
732
733 return array;
734 }
735 catch (Exception e) {
736 throw processException(e);
737 }
738 finally {
739 closeSession(session);
740 }
741 }
742
743 protected SCProductEntry getByGroupId_PrevAndNext(Session session,
744 SCProductEntry scProductEntry, long groupId,
745 OrderByComparator orderByComparator, boolean previous) {
746 StringBundler query = null;
747
748 if (orderByComparator != null) {
749 query = new StringBundler(6 +
750 (orderByComparator.getOrderByFields().length * 6));
751 }
752 else {
753 query = new StringBundler(3);
754 }
755
756 query.append(_SQL_SELECT_SCPRODUCTENTRY_WHERE);
757
758 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
759
760 if (orderByComparator != null) {
761 String[] orderByFields = orderByComparator.getOrderByFields();
762
763 if (orderByFields.length > 0) {
764 query.append(WHERE_AND);
765 }
766
767 for (int i = 0; i < orderByFields.length; i++) {
768 query.append(_ORDER_BY_ENTITY_ALIAS);
769 query.append(orderByFields[i]);
770
771 if ((i + 1) < orderByFields.length) {
772 if (orderByComparator.isAscending() ^ previous) {
773 query.append(WHERE_GREATER_THAN_HAS_NEXT);
774 }
775 else {
776 query.append(WHERE_LESSER_THAN_HAS_NEXT);
777 }
778 }
779 else {
780 if (orderByComparator.isAscending() ^ previous) {
781 query.append(WHERE_GREATER_THAN);
782 }
783 else {
784 query.append(WHERE_LESSER_THAN);
785 }
786 }
787 }
788
789 query.append(ORDER_BY_CLAUSE);
790
791 for (int i = 0; i < orderByFields.length; i++) {
792 query.append(_ORDER_BY_ENTITY_ALIAS);
793 query.append(orderByFields[i]);
794
795 if ((i + 1) < orderByFields.length) {
796 if (orderByComparator.isAscending() ^ previous) {
797 query.append(ORDER_BY_ASC_HAS_NEXT);
798 }
799 else {
800 query.append(ORDER_BY_DESC_HAS_NEXT);
801 }
802 }
803 else {
804 if (orderByComparator.isAscending() ^ previous) {
805 query.append(ORDER_BY_ASC);
806 }
807 else {
808 query.append(ORDER_BY_DESC);
809 }
810 }
811 }
812 }
813
814 else {
815 query.append(SCProductEntryModelImpl.ORDER_BY_JPQL);
816 }
817
818 String sql = query.toString();
819
820 Query q = session.createQuery(sql);
821
822 q.setFirstResult(0);
823 q.setMaxResults(2);
824
825 QueryPos qPos = QueryPos.getInstance(q);
826
827 qPos.add(groupId);
828
829 if (orderByComparator != null) {
830 Object[] values = orderByComparator.getOrderByValues(scProductEntry);
831
832 for (Object value : values) {
833 qPos.add(value);
834 }
835 }
836
837 List<SCProductEntry> list = q.list();
838
839 if (list.size() == 2) {
840 return list.get(1);
841 }
842 else {
843 return null;
844 }
845 }
846
847
854 public List<SCProductEntry> filterFindByGroupId(long groupId)
855 throws SystemException {
856 return filterFindByGroupId(groupId, QueryUtil.ALL_POS,
857 QueryUtil.ALL_POS, null);
858 }
859
860
873 public List<SCProductEntry> filterFindByGroupId(long groupId, int start,
874 int end) throws SystemException {
875 return filterFindByGroupId(groupId, start, end, null);
876 }
877
878
892 public List<SCProductEntry> filterFindByGroupId(long groupId, int start,
893 int end, OrderByComparator orderByComparator) throws SystemException {
894 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
895 return findByGroupId(groupId, start, end, orderByComparator);
896 }
897
898 Session session = null;
899
900 try {
901 session = openSession();
902
903 StringBundler query = null;
904
905 if (orderByComparator != null) {
906 query = new StringBundler(3 +
907 (orderByComparator.getOrderByFields().length * 3));
908 }
909 else {
910 query = new StringBundler(3);
911 }
912
913 query.append(_FILTER_SQL_SELECT_SCPRODUCTENTRY_WHERE);
914
915 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
916
917 if (orderByComparator != null) {
918 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
919 orderByComparator);
920 }
921
922 else {
923 query.append(SCProductEntryModelImpl.ORDER_BY_JPQL);
924 }
925
926 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
927 SCProductEntry.class.getName(), _FILTER_COLUMN_PK,
928 _FILTER_COLUMN_USERID, groupId);
929
930 SQLQuery q = session.createSQLQuery(sql);
931
932 q.addEntity(_FILTER_ENTITY_ALIAS, SCProductEntryImpl.class);
933
934 QueryPos qPos = QueryPos.getInstance(q);
935
936 qPos.add(groupId);
937
938 return (List<SCProductEntry>)QueryUtil.list(q, getDialect(), start,
939 end);
940 }
941 catch (Exception e) {
942 throw processException(e);
943 }
944 finally {
945 closeSession(session);
946 }
947 }
948
949
956 public List<SCProductEntry> findByCompanyId(long companyId)
957 throws SystemException {
958 return findByCompanyId(companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
959 null);
960 }
961
962
975 public List<SCProductEntry> findByCompanyId(long companyId, int start,
976 int end) throws SystemException {
977 return findByCompanyId(companyId, start, end, null);
978 }
979
980
994 public List<SCProductEntry> findByCompanyId(long companyId, int start,
995 int end, OrderByComparator orderByComparator) throws SystemException {
996 Object[] finderArgs = new Object[] {
997 companyId,
998
999 String.valueOf(start), String.valueOf(end),
1000 String.valueOf(orderByComparator)
1001 };
1002
1003 List<SCProductEntry> list = (List<SCProductEntry>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_COMPANYID,
1004 finderArgs, this);
1005
1006 if (list == null) {
1007 Session session = null;
1008
1009 try {
1010 session = openSession();
1011
1012 StringBundler query = null;
1013
1014 if (orderByComparator != null) {
1015 query = new StringBundler(3 +
1016 (orderByComparator.getOrderByFields().length * 3));
1017 }
1018 else {
1019 query = new StringBundler(3);
1020 }
1021
1022 query.append(_SQL_SELECT_SCPRODUCTENTRY_WHERE);
1023
1024 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
1025
1026 if (orderByComparator != null) {
1027 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1028 orderByComparator);
1029 }
1030
1031 else {
1032 query.append(SCProductEntryModelImpl.ORDER_BY_JPQL);
1033 }
1034
1035 String sql = query.toString();
1036
1037 Query q = session.createQuery(sql);
1038
1039 QueryPos qPos = QueryPos.getInstance(q);
1040
1041 qPos.add(companyId);
1042
1043 list = (List<SCProductEntry>)QueryUtil.list(q, getDialect(),
1044 start, end);
1045 }
1046 catch (Exception e) {
1047 throw processException(e);
1048 }
1049 finally {
1050 if (list == null) {
1051 list = new ArrayList<SCProductEntry>();
1052 }
1053
1054 cacheResult(list);
1055
1056 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_COMPANYID,
1057 finderArgs, list);
1058
1059 closeSession(session);
1060 }
1061 }
1062
1063 return list;
1064 }
1065
1066
1079 public SCProductEntry findByCompanyId_First(long companyId,
1080 OrderByComparator orderByComparator)
1081 throws NoSuchProductEntryException, SystemException {
1082 List<SCProductEntry> list = findByCompanyId(companyId, 0, 1,
1083 orderByComparator);
1084
1085 if (list.isEmpty()) {
1086 StringBundler msg = new StringBundler(4);
1087
1088 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1089
1090 msg.append("companyId=");
1091 msg.append(companyId);
1092
1093 msg.append(StringPool.CLOSE_CURLY_BRACE);
1094
1095 throw new NoSuchProductEntryException(msg.toString());
1096 }
1097 else {
1098 return list.get(0);
1099 }
1100 }
1101
1102
1115 public SCProductEntry findByCompanyId_Last(long companyId,
1116 OrderByComparator orderByComparator)
1117 throws NoSuchProductEntryException, SystemException {
1118 int count = countByCompanyId(companyId);
1119
1120 List<SCProductEntry> list = findByCompanyId(companyId, count - 1,
1121 count, orderByComparator);
1122
1123 if (list.isEmpty()) {
1124 StringBundler msg = new StringBundler(4);
1125
1126 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1127
1128 msg.append("companyId=");
1129 msg.append(companyId);
1130
1131 msg.append(StringPool.CLOSE_CURLY_BRACE);
1132
1133 throw new NoSuchProductEntryException(msg.toString());
1134 }
1135 else {
1136 return list.get(0);
1137 }
1138 }
1139
1140
1154 public SCProductEntry[] findByCompanyId_PrevAndNext(long productEntryId,
1155 long companyId, OrderByComparator orderByComparator)
1156 throws NoSuchProductEntryException, SystemException {
1157 SCProductEntry scProductEntry = findByPrimaryKey(productEntryId);
1158
1159 Session session = null;
1160
1161 try {
1162 session = openSession();
1163
1164 SCProductEntry[] array = new SCProductEntryImpl[3];
1165
1166 array[0] = getByCompanyId_PrevAndNext(session, scProductEntry,
1167 companyId, orderByComparator, true);
1168
1169 array[1] = scProductEntry;
1170
1171 array[2] = getByCompanyId_PrevAndNext(session, scProductEntry,
1172 companyId, orderByComparator, false);
1173
1174 return array;
1175 }
1176 catch (Exception e) {
1177 throw processException(e);
1178 }
1179 finally {
1180 closeSession(session);
1181 }
1182 }
1183
1184 protected SCProductEntry getByCompanyId_PrevAndNext(Session session,
1185 SCProductEntry scProductEntry, long companyId,
1186 OrderByComparator orderByComparator, boolean previous) {
1187 StringBundler query = null;
1188
1189 if (orderByComparator != null) {
1190 query = new StringBundler(6 +
1191 (orderByComparator.getOrderByFields().length * 6));
1192 }
1193 else {
1194 query = new StringBundler(3);
1195 }
1196
1197 query.append(_SQL_SELECT_SCPRODUCTENTRY_WHERE);
1198
1199 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
1200
1201 if (orderByComparator != null) {
1202 String[] orderByFields = orderByComparator.getOrderByFields();
1203
1204 if (orderByFields.length > 0) {
1205 query.append(WHERE_AND);
1206 }
1207
1208 for (int i = 0; i < orderByFields.length; i++) {
1209 query.append(_ORDER_BY_ENTITY_ALIAS);
1210 query.append(orderByFields[i]);
1211
1212 if ((i + 1) < orderByFields.length) {
1213 if (orderByComparator.isAscending() ^ previous) {
1214 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1215 }
1216 else {
1217 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1218 }
1219 }
1220 else {
1221 if (orderByComparator.isAscending() ^ previous) {
1222 query.append(WHERE_GREATER_THAN);
1223 }
1224 else {
1225 query.append(WHERE_LESSER_THAN);
1226 }
1227 }
1228 }
1229
1230 query.append(ORDER_BY_CLAUSE);
1231
1232 for (int i = 0; i < orderByFields.length; i++) {
1233 query.append(_ORDER_BY_ENTITY_ALIAS);
1234 query.append(orderByFields[i]);
1235
1236 if ((i + 1) < orderByFields.length) {
1237 if (orderByComparator.isAscending() ^ previous) {
1238 query.append(ORDER_BY_ASC_HAS_NEXT);
1239 }
1240 else {
1241 query.append(ORDER_BY_DESC_HAS_NEXT);
1242 }
1243 }
1244 else {
1245 if (orderByComparator.isAscending() ^ previous) {
1246 query.append(ORDER_BY_ASC);
1247 }
1248 else {
1249 query.append(ORDER_BY_DESC);
1250 }
1251 }
1252 }
1253 }
1254
1255 else {
1256 query.append(SCProductEntryModelImpl.ORDER_BY_JPQL);
1257 }
1258
1259 String sql = query.toString();
1260
1261 Query q = session.createQuery(sql);
1262
1263 q.setFirstResult(0);
1264 q.setMaxResults(2);
1265
1266 QueryPos qPos = QueryPos.getInstance(q);
1267
1268 qPos.add(companyId);
1269
1270 if (orderByComparator != null) {
1271 Object[] values = orderByComparator.getOrderByValues(scProductEntry);
1272
1273 for (Object value : values) {
1274 qPos.add(value);
1275 }
1276 }
1277
1278 List<SCProductEntry> list = q.list();
1279
1280 if (list.size() == 2) {
1281 return list.get(1);
1282 }
1283 else {
1284 return null;
1285 }
1286 }
1287
1288
1296 public List<SCProductEntry> findByG_U(long groupId, long userId)
1297 throws SystemException {
1298 return findByG_U(groupId, userId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
1299 null);
1300 }
1301
1302
1316 public List<SCProductEntry> findByG_U(long groupId, long userId, int start,
1317 int end) throws SystemException {
1318 return findByG_U(groupId, userId, start, end, null);
1319 }
1320
1321
1336 public List<SCProductEntry> findByG_U(long groupId, long userId, int start,
1337 int end, OrderByComparator orderByComparator) throws SystemException {
1338 Object[] finderArgs = new Object[] {
1339 groupId, userId,
1340
1341 String.valueOf(start), String.valueOf(end),
1342 String.valueOf(orderByComparator)
1343 };
1344
1345 List<SCProductEntry> list = (List<SCProductEntry>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_G_U,
1346 finderArgs, this);
1347
1348 if (list == null) {
1349 Session session = null;
1350
1351 try {
1352 session = openSession();
1353
1354 StringBundler query = null;
1355
1356 if (orderByComparator != null) {
1357 query = new StringBundler(4 +
1358 (orderByComparator.getOrderByFields().length * 3));
1359 }
1360 else {
1361 query = new StringBundler(4);
1362 }
1363
1364 query.append(_SQL_SELECT_SCPRODUCTENTRY_WHERE);
1365
1366 query.append(_FINDER_COLUMN_G_U_GROUPID_2);
1367
1368 query.append(_FINDER_COLUMN_G_U_USERID_2);
1369
1370 if (orderByComparator != null) {
1371 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1372 orderByComparator);
1373 }
1374
1375 else {
1376 query.append(SCProductEntryModelImpl.ORDER_BY_JPQL);
1377 }
1378
1379 String sql = query.toString();
1380
1381 Query q = session.createQuery(sql);
1382
1383 QueryPos qPos = QueryPos.getInstance(q);
1384
1385 qPos.add(groupId);
1386
1387 qPos.add(userId);
1388
1389 list = (List<SCProductEntry>)QueryUtil.list(q, getDialect(),
1390 start, end);
1391 }
1392 catch (Exception e) {
1393 throw processException(e);
1394 }
1395 finally {
1396 if (list == null) {
1397 list = new ArrayList<SCProductEntry>();
1398 }
1399
1400 cacheResult(list);
1401
1402 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_G_U, finderArgs,
1403 list);
1404
1405 closeSession(session);
1406 }
1407 }
1408
1409 return list;
1410 }
1411
1412
1426 public SCProductEntry findByG_U_First(long groupId, long userId,
1427 OrderByComparator orderByComparator)
1428 throws NoSuchProductEntryException, SystemException {
1429 List<SCProductEntry> list = findByG_U(groupId, userId, 0, 1,
1430 orderByComparator);
1431
1432 if (list.isEmpty()) {
1433 StringBundler msg = new StringBundler(6);
1434
1435 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1436
1437 msg.append("groupId=");
1438 msg.append(groupId);
1439
1440 msg.append(", userId=");
1441 msg.append(userId);
1442
1443 msg.append(StringPool.CLOSE_CURLY_BRACE);
1444
1445 throw new NoSuchProductEntryException(msg.toString());
1446 }
1447 else {
1448 return list.get(0);
1449 }
1450 }
1451
1452
1466 public SCProductEntry findByG_U_Last(long groupId, long userId,
1467 OrderByComparator orderByComparator)
1468 throws NoSuchProductEntryException, SystemException {
1469 int count = countByG_U(groupId, userId);
1470
1471 List<SCProductEntry> list = findByG_U(groupId, userId, count - 1,
1472 count, orderByComparator);
1473
1474 if (list.isEmpty()) {
1475 StringBundler msg = new StringBundler(6);
1476
1477 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1478
1479 msg.append("groupId=");
1480 msg.append(groupId);
1481
1482 msg.append(", userId=");
1483 msg.append(userId);
1484
1485 msg.append(StringPool.CLOSE_CURLY_BRACE);
1486
1487 throw new NoSuchProductEntryException(msg.toString());
1488 }
1489 else {
1490 return list.get(0);
1491 }
1492 }
1493
1494
1509 public SCProductEntry[] findByG_U_PrevAndNext(long productEntryId,
1510 long groupId, long userId, OrderByComparator orderByComparator)
1511 throws NoSuchProductEntryException, SystemException {
1512 SCProductEntry scProductEntry = findByPrimaryKey(productEntryId);
1513
1514 Session session = null;
1515
1516 try {
1517 session = openSession();
1518
1519 SCProductEntry[] array = new SCProductEntryImpl[3];
1520
1521 array[0] = getByG_U_PrevAndNext(session, scProductEntry, groupId,
1522 userId, orderByComparator, true);
1523
1524 array[1] = scProductEntry;
1525
1526 array[2] = getByG_U_PrevAndNext(session, scProductEntry, groupId,
1527 userId, orderByComparator, false);
1528
1529 return array;
1530 }
1531 catch (Exception e) {
1532 throw processException(e);
1533 }
1534 finally {
1535 closeSession(session);
1536 }
1537 }
1538
1539 protected SCProductEntry getByG_U_PrevAndNext(Session session,
1540 SCProductEntry scProductEntry, long groupId, long userId,
1541 OrderByComparator orderByComparator, boolean previous) {
1542 StringBundler query = null;
1543
1544 if (orderByComparator != null) {
1545 query = new StringBundler(6 +
1546 (orderByComparator.getOrderByFields().length * 6));
1547 }
1548 else {
1549 query = new StringBundler(3);
1550 }
1551
1552 query.append(_SQL_SELECT_SCPRODUCTENTRY_WHERE);
1553
1554 query.append(_FINDER_COLUMN_G_U_GROUPID_2);
1555
1556 query.append(_FINDER_COLUMN_G_U_USERID_2);
1557
1558 if (orderByComparator != null) {
1559 String[] orderByFields = orderByComparator.getOrderByFields();
1560
1561 if (orderByFields.length > 0) {
1562 query.append(WHERE_AND);
1563 }
1564
1565 for (int i = 0; i < orderByFields.length; i++) {
1566 query.append(_ORDER_BY_ENTITY_ALIAS);
1567 query.append(orderByFields[i]);
1568
1569 if ((i + 1) < orderByFields.length) {
1570 if (orderByComparator.isAscending() ^ previous) {
1571 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1572 }
1573 else {
1574 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1575 }
1576 }
1577 else {
1578 if (orderByComparator.isAscending() ^ previous) {
1579 query.append(WHERE_GREATER_THAN);
1580 }
1581 else {
1582 query.append(WHERE_LESSER_THAN);
1583 }
1584 }
1585 }
1586
1587 query.append(ORDER_BY_CLAUSE);
1588
1589 for (int i = 0; i < orderByFields.length; i++) {
1590 query.append(_ORDER_BY_ENTITY_ALIAS);
1591 query.append(orderByFields[i]);
1592
1593 if ((i + 1) < orderByFields.length) {
1594 if (orderByComparator.isAscending() ^ previous) {
1595 query.append(ORDER_BY_ASC_HAS_NEXT);
1596 }
1597 else {
1598 query.append(ORDER_BY_DESC_HAS_NEXT);
1599 }
1600 }
1601 else {
1602 if (orderByComparator.isAscending() ^ previous) {
1603 query.append(ORDER_BY_ASC);
1604 }
1605 else {
1606 query.append(ORDER_BY_DESC);
1607 }
1608 }
1609 }
1610 }
1611
1612 else {
1613 query.append(SCProductEntryModelImpl.ORDER_BY_JPQL);
1614 }
1615
1616 String sql = query.toString();
1617
1618 Query q = session.createQuery(sql);
1619
1620 q.setFirstResult(0);
1621 q.setMaxResults(2);
1622
1623 QueryPos qPos = QueryPos.getInstance(q);
1624
1625 qPos.add(groupId);
1626
1627 qPos.add(userId);
1628
1629 if (orderByComparator != null) {
1630 Object[] values = orderByComparator.getOrderByValues(scProductEntry);
1631
1632 for (Object value : values) {
1633 qPos.add(value);
1634 }
1635 }
1636
1637 List<SCProductEntry> list = q.list();
1638
1639 if (list.size() == 2) {
1640 return list.get(1);
1641 }
1642 else {
1643 return null;
1644 }
1645 }
1646
1647
1655 public List<SCProductEntry> filterFindByG_U(long groupId, long userId)
1656 throws SystemException {
1657 return filterFindByG_U(groupId, userId, QueryUtil.ALL_POS,
1658 QueryUtil.ALL_POS, null);
1659 }
1660
1661
1675 public List<SCProductEntry> filterFindByG_U(long groupId, long userId,
1676 int start, int end) throws SystemException {
1677 return filterFindByG_U(groupId, userId, start, end, null);
1678 }
1679
1680
1695 public List<SCProductEntry> filterFindByG_U(long groupId, long userId,
1696 int start, int end, OrderByComparator orderByComparator)
1697 throws SystemException {
1698 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
1699 return findByG_U(groupId, userId, start, end, orderByComparator);
1700 }
1701
1702 Session session = null;
1703
1704 try {
1705 session = openSession();
1706
1707 StringBundler query = null;
1708
1709 if (orderByComparator != null) {
1710 query = new StringBundler(4 +
1711 (orderByComparator.getOrderByFields().length * 3));
1712 }
1713 else {
1714 query = new StringBundler(4);
1715 }
1716
1717 query.append(_FILTER_SQL_SELECT_SCPRODUCTENTRY_WHERE);
1718
1719 query.append(_FINDER_COLUMN_G_U_GROUPID_2);
1720
1721 query.append(_FINDER_COLUMN_G_U_USERID_2);
1722
1723 if (orderByComparator != null) {
1724 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1725 orderByComparator);
1726 }
1727
1728 else {
1729 query.append(SCProductEntryModelImpl.ORDER_BY_JPQL);
1730 }
1731
1732 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1733 SCProductEntry.class.getName(), _FILTER_COLUMN_PK,
1734 _FILTER_COLUMN_USERID, groupId);
1735
1736 SQLQuery q = session.createSQLQuery(sql);
1737
1738 q.addEntity(_FILTER_ENTITY_ALIAS, SCProductEntryImpl.class);
1739
1740 QueryPos qPos = QueryPos.getInstance(q);
1741
1742 qPos.add(groupId);
1743
1744 qPos.add(userId);
1745
1746 return (List<SCProductEntry>)QueryUtil.list(q, getDialect(), start,
1747 end);
1748 }
1749 catch (Exception e) {
1750 throw processException(e);
1751 }
1752 finally {
1753 closeSession(session);
1754 }
1755 }
1756
1757
1766 public SCProductEntry findByRG_RA(String repoGroupId, String repoArtifactId)
1767 throws NoSuchProductEntryException, SystemException {
1768 SCProductEntry scProductEntry = fetchByRG_RA(repoGroupId, repoArtifactId);
1769
1770 if (scProductEntry == null) {
1771 StringBundler msg = new StringBundler(6);
1772
1773 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1774
1775 msg.append("repoGroupId=");
1776 msg.append(repoGroupId);
1777
1778 msg.append(", repoArtifactId=");
1779 msg.append(repoArtifactId);
1780
1781 msg.append(StringPool.CLOSE_CURLY_BRACE);
1782
1783 if (_log.isWarnEnabled()) {
1784 _log.warn(msg.toString());
1785 }
1786
1787 throw new NoSuchProductEntryException(msg.toString());
1788 }
1789
1790 return scProductEntry;
1791 }
1792
1793
1801 public SCProductEntry fetchByRG_RA(String repoGroupId, String repoArtifactId)
1802 throws SystemException {
1803 return fetchByRG_RA(repoGroupId, repoArtifactId, true);
1804 }
1805
1806
1814 public SCProductEntry fetchByRG_RA(String repoGroupId,
1815 String repoArtifactId, boolean retrieveFromCache)
1816 throws SystemException {
1817 Object[] finderArgs = new Object[] { repoGroupId, repoArtifactId };
1818
1819 Object result = null;
1820
1821 if (retrieveFromCache) {
1822 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_RG_RA,
1823 finderArgs, this);
1824 }
1825
1826 if (result == null) {
1827 Session session = null;
1828
1829 try {
1830 session = openSession();
1831
1832 StringBundler query = new StringBundler(4);
1833
1834 query.append(_SQL_SELECT_SCPRODUCTENTRY_WHERE);
1835
1836 if (repoGroupId == null) {
1837 query.append(_FINDER_COLUMN_RG_RA_REPOGROUPID_1);
1838 }
1839 else {
1840 if (repoGroupId.equals(StringPool.BLANK)) {
1841 query.append(_FINDER_COLUMN_RG_RA_REPOGROUPID_3);
1842 }
1843 else {
1844 query.append(_FINDER_COLUMN_RG_RA_REPOGROUPID_2);
1845 }
1846 }
1847
1848 if (repoArtifactId == null) {
1849 query.append(_FINDER_COLUMN_RG_RA_REPOARTIFACTID_1);
1850 }
1851 else {
1852 if (repoArtifactId.equals(StringPool.BLANK)) {
1853 query.append(_FINDER_COLUMN_RG_RA_REPOARTIFACTID_3);
1854 }
1855 else {
1856 query.append(_FINDER_COLUMN_RG_RA_REPOARTIFACTID_2);
1857 }
1858 }
1859
1860 query.append(SCProductEntryModelImpl.ORDER_BY_JPQL);
1861
1862 String sql = query.toString();
1863
1864 Query q = session.createQuery(sql);
1865
1866 QueryPos qPos = QueryPos.getInstance(q);
1867
1868 if (repoGroupId != null) {
1869 qPos.add(repoGroupId);
1870 }
1871
1872 if (repoArtifactId != null) {
1873 qPos.add(repoArtifactId);
1874 }
1875
1876 List<SCProductEntry> list = q.list();
1877
1878 result = list;
1879
1880 SCProductEntry scProductEntry = null;
1881
1882 if (list.isEmpty()) {
1883 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_RG_RA,
1884 finderArgs, list);
1885 }
1886 else {
1887 scProductEntry = list.get(0);
1888
1889 cacheResult(scProductEntry);
1890
1891 if ((scProductEntry.getRepoGroupId() == null) ||
1892 !scProductEntry.getRepoGroupId().equals(repoGroupId) ||
1893 (scProductEntry.getRepoArtifactId() == null) ||
1894 !scProductEntry.getRepoArtifactId()
1895 .equals(repoArtifactId)) {
1896 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_RG_RA,
1897 finderArgs, scProductEntry);
1898 }
1899 }
1900
1901 return scProductEntry;
1902 }
1903 catch (Exception e) {
1904 throw processException(e);
1905 }
1906 finally {
1907 if (result == null) {
1908 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_RG_RA,
1909 finderArgs, new ArrayList<SCProductEntry>());
1910 }
1911
1912 closeSession(session);
1913 }
1914 }
1915 else {
1916 if (result instanceof List<?>) {
1917 return null;
1918 }
1919 else {
1920 return (SCProductEntry)result;
1921 }
1922 }
1923 }
1924
1925
1931 public List<SCProductEntry> findAll() throws SystemException {
1932 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1933 }
1934
1935
1947 public List<SCProductEntry> findAll(int start, int end)
1948 throws SystemException {
1949 return findAll(start, end, null);
1950 }
1951
1952
1965 public List<SCProductEntry> findAll(int start, int end,
1966 OrderByComparator orderByComparator) throws SystemException {
1967 Object[] finderArgs = new Object[] {
1968 String.valueOf(start), String.valueOf(end),
1969 String.valueOf(orderByComparator)
1970 };
1971
1972 List<SCProductEntry> list = (List<SCProductEntry>)FinderCacheUtil.getResult(FINDER_PATH_FIND_ALL,
1973 finderArgs, this);
1974
1975 if (list == null) {
1976 Session session = null;
1977
1978 try {
1979 session = openSession();
1980
1981 StringBundler query = null;
1982 String sql = null;
1983
1984 if (orderByComparator != null) {
1985 query = new StringBundler(2 +
1986 (orderByComparator.getOrderByFields().length * 3));
1987
1988 query.append(_SQL_SELECT_SCPRODUCTENTRY);
1989
1990 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1991 orderByComparator);
1992
1993 sql = query.toString();
1994 }
1995 else {
1996 sql = _SQL_SELECT_SCPRODUCTENTRY.concat(SCProductEntryModelImpl.ORDER_BY_JPQL);
1997 }
1998
1999 Query q = session.createQuery(sql);
2000
2001 if (orderByComparator == null) {
2002 list = (List<SCProductEntry>)QueryUtil.list(q,
2003 getDialect(), start, end, false);
2004
2005 Collections.sort(list);
2006 }
2007 else {
2008 list = (List<SCProductEntry>)QueryUtil.list(q,
2009 getDialect(), start, end);
2010 }
2011 }
2012 catch (Exception e) {
2013 throw processException(e);
2014 }
2015 finally {
2016 if (list == null) {
2017 list = new ArrayList<SCProductEntry>();
2018 }
2019
2020 cacheResult(list);
2021
2022 FinderCacheUtil.putResult(FINDER_PATH_FIND_ALL, finderArgs, list);
2023
2024 closeSession(session);
2025 }
2026 }
2027
2028 return list;
2029 }
2030
2031
2037 public void removeByGroupId(long groupId) throws SystemException {
2038 for (SCProductEntry scProductEntry : findByGroupId(groupId)) {
2039 remove(scProductEntry);
2040 }
2041 }
2042
2043
2049 public void removeByCompanyId(long companyId) throws SystemException {
2050 for (SCProductEntry scProductEntry : findByCompanyId(companyId)) {
2051 remove(scProductEntry);
2052 }
2053 }
2054
2055
2062 public void removeByG_U(long groupId, long userId)
2063 throws SystemException {
2064 for (SCProductEntry scProductEntry : findByG_U(groupId, userId)) {
2065 remove(scProductEntry);
2066 }
2067 }
2068
2069
2076 public void removeByRG_RA(String repoGroupId, String repoArtifactId)
2077 throws NoSuchProductEntryException, SystemException {
2078 SCProductEntry scProductEntry = findByRG_RA(repoGroupId, repoArtifactId);
2079
2080 remove(scProductEntry);
2081 }
2082
2083
2088 public void removeAll() throws SystemException {
2089 for (SCProductEntry scProductEntry : findAll()) {
2090 remove(scProductEntry);
2091 }
2092 }
2093
2094
2101 public int countByGroupId(long groupId) throws SystemException {
2102 Object[] finderArgs = new Object[] { groupId };
2103
2104 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_GROUPID,
2105 finderArgs, this);
2106
2107 if (count == null) {
2108 Session session = null;
2109
2110 try {
2111 session = openSession();
2112
2113 StringBundler query = new StringBundler(2);
2114
2115 query.append(_SQL_COUNT_SCPRODUCTENTRY_WHERE);
2116
2117 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2118
2119 String sql = query.toString();
2120
2121 Query q = session.createQuery(sql);
2122
2123 QueryPos qPos = QueryPos.getInstance(q);
2124
2125 qPos.add(groupId);
2126
2127 count = (Long)q.uniqueResult();
2128 }
2129 catch (Exception e) {
2130 throw processException(e);
2131 }
2132 finally {
2133 if (count == null) {
2134 count = Long.valueOf(0);
2135 }
2136
2137 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_GROUPID,
2138 finderArgs, count);
2139
2140 closeSession(session);
2141 }
2142 }
2143
2144 return count.intValue();
2145 }
2146
2147
2154 public int filterCountByGroupId(long groupId) throws SystemException {
2155 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2156 return countByGroupId(groupId);
2157 }
2158
2159 Session session = null;
2160
2161 try {
2162 session = openSession();
2163
2164 StringBundler query = new StringBundler(2);
2165
2166 query.append(_FILTER_SQL_COUNT_SCPRODUCTENTRY_WHERE);
2167
2168 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2169
2170 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2171 SCProductEntry.class.getName(), _FILTER_COLUMN_PK,
2172 _FILTER_COLUMN_USERID, groupId);
2173
2174 SQLQuery q = session.createSQLQuery(sql);
2175
2176 q.addScalar(COUNT_COLUMN_NAME,
2177 com.liferay.portal.kernel.dao.orm.Type.LONG);
2178
2179 QueryPos qPos = QueryPos.getInstance(q);
2180
2181 qPos.add(groupId);
2182
2183 Long count = (Long)q.uniqueResult();
2184
2185 return count.intValue();
2186 }
2187 catch (Exception e) {
2188 throw processException(e);
2189 }
2190 finally {
2191 closeSession(session);
2192 }
2193 }
2194
2195
2202 public int countByCompanyId(long companyId) throws SystemException {
2203 Object[] finderArgs = new Object[] { companyId };
2204
2205 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_COMPANYID,
2206 finderArgs, this);
2207
2208 if (count == null) {
2209 Session session = null;
2210
2211 try {
2212 session = openSession();
2213
2214 StringBundler query = new StringBundler(2);
2215
2216 query.append(_SQL_COUNT_SCPRODUCTENTRY_WHERE);
2217
2218 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
2219
2220 String sql = query.toString();
2221
2222 Query q = session.createQuery(sql);
2223
2224 QueryPos qPos = QueryPos.getInstance(q);
2225
2226 qPos.add(companyId);
2227
2228 count = (Long)q.uniqueResult();
2229 }
2230 catch (Exception e) {
2231 throw processException(e);
2232 }
2233 finally {
2234 if (count == null) {
2235 count = Long.valueOf(0);
2236 }
2237
2238 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_COMPANYID,
2239 finderArgs, count);
2240
2241 closeSession(session);
2242 }
2243 }
2244
2245 return count.intValue();
2246 }
2247
2248
2256 public int countByG_U(long groupId, long userId) throws SystemException {
2257 Object[] finderArgs = new Object[] { groupId, userId };
2258
2259 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_U,
2260 finderArgs, this);
2261
2262 if (count == null) {
2263 Session session = null;
2264
2265 try {
2266 session = openSession();
2267
2268 StringBundler query = new StringBundler(3);
2269
2270 query.append(_SQL_COUNT_SCPRODUCTENTRY_WHERE);
2271
2272 query.append(_FINDER_COLUMN_G_U_GROUPID_2);
2273
2274 query.append(_FINDER_COLUMN_G_U_USERID_2);
2275
2276 String sql = query.toString();
2277
2278 Query q = session.createQuery(sql);
2279
2280 QueryPos qPos = QueryPos.getInstance(q);
2281
2282 qPos.add(groupId);
2283
2284 qPos.add(userId);
2285
2286 count = (Long)q.uniqueResult();
2287 }
2288 catch (Exception e) {
2289 throw processException(e);
2290 }
2291 finally {
2292 if (count == null) {
2293 count = Long.valueOf(0);
2294 }
2295
2296 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_U, finderArgs,
2297 count);
2298
2299 closeSession(session);
2300 }
2301 }
2302
2303 return count.intValue();
2304 }
2305
2306
2314 public int filterCountByG_U(long groupId, long userId)
2315 throws SystemException {
2316 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2317 return countByG_U(groupId, userId);
2318 }
2319
2320 Session session = null;
2321
2322 try {
2323 session = openSession();
2324
2325 StringBundler query = new StringBundler(3);
2326
2327 query.append(_FILTER_SQL_COUNT_SCPRODUCTENTRY_WHERE);
2328
2329 query.append(_FINDER_COLUMN_G_U_GROUPID_2);
2330
2331 query.append(_FINDER_COLUMN_G_U_USERID_2);
2332
2333 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2334 SCProductEntry.class.getName(), _FILTER_COLUMN_PK,
2335 _FILTER_COLUMN_USERID, groupId);
2336
2337 SQLQuery q = session.createSQLQuery(sql);
2338
2339 q.addScalar(COUNT_COLUMN_NAME,
2340 com.liferay.portal.kernel.dao.orm.Type.LONG);
2341
2342 QueryPos qPos = QueryPos.getInstance(q);
2343
2344 qPos.add(groupId);
2345
2346 qPos.add(userId);
2347
2348 Long count = (Long)q.uniqueResult();
2349
2350 return count.intValue();
2351 }
2352 catch (Exception e) {
2353 throw processException(e);
2354 }
2355 finally {
2356 closeSession(session);
2357 }
2358 }
2359
2360
2368 public int countByRG_RA(String repoGroupId, String repoArtifactId)
2369 throws SystemException {
2370 Object[] finderArgs = new Object[] { repoGroupId, repoArtifactId };
2371
2372 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_RG_RA,
2373 finderArgs, this);
2374
2375 if (count == null) {
2376 Session session = null;
2377
2378 try {
2379 session = openSession();
2380
2381 StringBundler query = new StringBundler(3);
2382
2383 query.append(_SQL_COUNT_SCPRODUCTENTRY_WHERE);
2384
2385 if (repoGroupId == null) {
2386 query.append(_FINDER_COLUMN_RG_RA_REPOGROUPID_1);
2387 }
2388 else {
2389 if (repoGroupId.equals(StringPool.BLANK)) {
2390 query.append(_FINDER_COLUMN_RG_RA_REPOGROUPID_3);
2391 }
2392 else {
2393 query.append(_FINDER_COLUMN_RG_RA_REPOGROUPID_2);
2394 }
2395 }
2396
2397 if (repoArtifactId == null) {
2398 query.append(_FINDER_COLUMN_RG_RA_REPOARTIFACTID_1);
2399 }
2400 else {
2401 if (repoArtifactId.equals(StringPool.BLANK)) {
2402 query.append(_FINDER_COLUMN_RG_RA_REPOARTIFACTID_3);
2403 }
2404 else {
2405 query.append(_FINDER_COLUMN_RG_RA_REPOARTIFACTID_2);
2406 }
2407 }
2408
2409 String sql = query.toString();
2410
2411 Query q = session.createQuery(sql);
2412
2413 QueryPos qPos = QueryPos.getInstance(q);
2414
2415 if (repoGroupId != null) {
2416 qPos.add(repoGroupId);
2417 }
2418
2419 if (repoArtifactId != null) {
2420 qPos.add(repoArtifactId);
2421 }
2422
2423 count = (Long)q.uniqueResult();
2424 }
2425 catch (Exception e) {
2426 throw processException(e);
2427 }
2428 finally {
2429 if (count == null) {
2430 count = Long.valueOf(0);
2431 }
2432
2433 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_RG_RA,
2434 finderArgs, count);
2435
2436 closeSession(session);
2437 }
2438 }
2439
2440 return count.intValue();
2441 }
2442
2443
2449 public int countAll() throws SystemException {
2450 Object[] finderArgs = new Object[0];
2451
2452 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
2453 finderArgs, this);
2454
2455 if (count == null) {
2456 Session session = null;
2457
2458 try {
2459 session = openSession();
2460
2461 Query q = session.createQuery(_SQL_COUNT_SCPRODUCTENTRY);
2462
2463 count = (Long)q.uniqueResult();
2464 }
2465 catch (Exception e) {
2466 throw processException(e);
2467 }
2468 finally {
2469 if (count == null) {
2470 count = Long.valueOf(0);
2471 }
2472
2473 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL, finderArgs,
2474 count);
2475
2476 closeSession(session);
2477 }
2478 }
2479
2480 return count.intValue();
2481 }
2482
2483
2490 public List<com.liferay.portlet.softwarecatalog.model.SCLicense> getSCLicenses(
2491 long pk) throws SystemException {
2492 return getSCLicenses(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
2493 }
2494
2495
2508 public List<com.liferay.portlet.softwarecatalog.model.SCLicense> getSCLicenses(
2509 long pk, int start, int end) throws SystemException {
2510 return getSCLicenses(pk, start, end, null);
2511 }
2512
2513 public static final FinderPath FINDER_PATH_GET_SCLICENSES = new FinderPath(com.liferay.portlet.softwarecatalog.model.impl.SCLicenseModelImpl.ENTITY_CACHE_ENABLED,
2514 SCProductEntryModelImpl.FINDER_CACHE_ENABLED_SCLICENSES_SCPRODUCTENTRIES,
2515 SCProductEntryModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME,
2516 "getSCLicenses",
2517 new String[] {
2518 Long.class.getName(), "java.lang.Integer", "java.lang.Integer",
2519 "com.liferay.portal.kernel.util.OrderByComparator"
2520 });
2521
2522
2536 public List<com.liferay.portlet.softwarecatalog.model.SCLicense> getSCLicenses(
2537 long pk, int start, int end, OrderByComparator orderByComparator)
2538 throws SystemException {
2539 Object[] finderArgs = new Object[] {
2540 pk, String.valueOf(start), String.valueOf(end),
2541 String.valueOf(orderByComparator)
2542 };
2543
2544 List<com.liferay.portlet.softwarecatalog.model.SCLicense> list = (List<com.liferay.portlet.softwarecatalog.model.SCLicense>)FinderCacheUtil.getResult(FINDER_PATH_GET_SCLICENSES,
2545 finderArgs, this);
2546
2547 if (list == null) {
2548 Session session = null;
2549
2550 try {
2551 session = openSession();
2552
2553 String sql = null;
2554
2555 if (orderByComparator != null) {
2556 sql = _SQL_GETSCLICENSES.concat(ORDER_BY_CLAUSE)
2557 .concat(orderByComparator.getOrderBy());
2558 }
2559 else {
2560 sql = _SQL_GETSCLICENSES.concat(com.liferay.portlet.softwarecatalog.model.impl.SCLicenseModelImpl.ORDER_BY_SQL);
2561 }
2562
2563 SQLQuery q = session.createSQLQuery(sql);
2564
2565 q.addEntity("SCLicense",
2566 com.liferay.portlet.softwarecatalog.model.impl.SCLicenseImpl.class);
2567
2568 QueryPos qPos = QueryPos.getInstance(q);
2569
2570 qPos.add(pk);
2571
2572 list = (List<com.liferay.portlet.softwarecatalog.model.SCLicense>)QueryUtil.list(q,
2573 getDialect(), start, end);
2574 }
2575 catch (Exception e) {
2576 throw processException(e);
2577 }
2578 finally {
2579 if (list == null) {
2580 list = new ArrayList<com.liferay.portlet.softwarecatalog.model.SCLicense>();
2581 }
2582
2583 scLicensePersistence.cacheResult(list);
2584
2585 FinderCacheUtil.putResult(FINDER_PATH_GET_SCLICENSES,
2586 finderArgs, list);
2587
2588 closeSession(session);
2589 }
2590 }
2591
2592 return list;
2593 }
2594
2595 public static final FinderPath FINDER_PATH_GET_SCLICENSES_SIZE = new FinderPath(com.liferay.portlet.softwarecatalog.model.impl.SCLicenseModelImpl.ENTITY_CACHE_ENABLED,
2596 SCProductEntryModelImpl.FINDER_CACHE_ENABLED_SCLICENSES_SCPRODUCTENTRIES,
2597 SCProductEntryModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME,
2598 "getSCLicensesSize", new String[] { Long.class.getName() });
2599
2600
2607 public int getSCLicensesSize(long pk) throws SystemException {
2608 Object[] finderArgs = new Object[] { pk };
2609
2610 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_GET_SCLICENSES_SIZE,
2611 finderArgs, this);
2612
2613 if (count == null) {
2614 Session session = null;
2615
2616 try {
2617 session = openSession();
2618
2619 SQLQuery q = session.createSQLQuery(_SQL_GETSCLICENSESSIZE);
2620
2621 q.addScalar(COUNT_COLUMN_NAME,
2622 com.liferay.portal.kernel.dao.orm.Type.LONG);
2623
2624 QueryPos qPos = QueryPos.getInstance(q);
2625
2626 qPos.add(pk);
2627
2628 count = (Long)q.uniqueResult();
2629 }
2630 catch (Exception e) {
2631 throw processException(e);
2632 }
2633 finally {
2634 if (count == null) {
2635 count = Long.valueOf(0);
2636 }
2637
2638 FinderCacheUtil.putResult(FINDER_PATH_GET_SCLICENSES_SIZE,
2639 finderArgs, count);
2640
2641 closeSession(session);
2642 }
2643 }
2644
2645 return count.intValue();
2646 }
2647
2648 public static final FinderPath FINDER_PATH_CONTAINS_SCLICENSE = new FinderPath(com.liferay.portlet.softwarecatalog.model.impl.SCLicenseModelImpl.ENTITY_CACHE_ENABLED,
2649 SCProductEntryModelImpl.FINDER_CACHE_ENABLED_SCLICENSES_SCPRODUCTENTRIES,
2650 SCProductEntryModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME,
2651 "containsSCLicense",
2652 new String[] { Long.class.getName(), Long.class.getName() });
2653
2654
2662 public boolean containsSCLicense(long pk, long scLicensePK)
2663 throws SystemException {
2664 Object[] finderArgs = new Object[] { pk, scLicensePK };
2665
2666 Boolean value = (Boolean)FinderCacheUtil.getResult(FINDER_PATH_CONTAINS_SCLICENSE,
2667 finderArgs, this);
2668
2669 if (value == null) {
2670 try {
2671 value = Boolean.valueOf(containsSCLicense.contains(pk,
2672 scLicensePK));
2673 }
2674 catch (Exception e) {
2675 throw processException(e);
2676 }
2677 finally {
2678 if (value == null) {
2679 value = Boolean.FALSE;
2680 }
2681
2682 FinderCacheUtil.putResult(FINDER_PATH_CONTAINS_SCLICENSE,
2683 finderArgs, value);
2684 }
2685 }
2686
2687 return value.booleanValue();
2688 }
2689
2690
2697 public boolean containsSCLicenses(long pk) throws SystemException {
2698 if (getSCLicensesSize(pk) > 0) {
2699 return true;
2700 }
2701 else {
2702 return false;
2703 }
2704 }
2705
2706
2713 public void addSCLicense(long pk, long scLicensePK)
2714 throws SystemException {
2715 try {
2716 addSCLicense.add(pk, scLicensePK);
2717 }
2718 catch (Exception e) {
2719 throw processException(e);
2720 }
2721 finally {
2722 FinderCacheUtil.clearCache(SCProductEntryModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME);
2723 }
2724 }
2725
2726
2733 public void addSCLicense(long pk,
2734 com.liferay.portlet.softwarecatalog.model.SCLicense scLicense)
2735 throws SystemException {
2736 try {
2737 addSCLicense.add(pk, scLicense.getPrimaryKey());
2738 }
2739 catch (Exception e) {
2740 throw processException(e);
2741 }
2742 finally {
2743 FinderCacheUtil.clearCache(SCProductEntryModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME);
2744 }
2745 }
2746
2747
2754 public void addSCLicenses(long pk, long[] scLicensePKs)
2755 throws SystemException {
2756 try {
2757 for (long scLicensePK : scLicensePKs) {
2758 addSCLicense.add(pk, scLicensePK);
2759 }
2760 }
2761 catch (Exception e) {
2762 throw processException(e);
2763 }
2764 finally {
2765 FinderCacheUtil.clearCache(SCProductEntryModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME);
2766 }
2767 }
2768
2769
2776 public void addSCLicenses(long pk,
2777 List<com.liferay.portlet.softwarecatalog.model.SCLicense> scLicenses)
2778 throws SystemException {
2779 try {
2780 for (com.liferay.portlet.softwarecatalog.model.SCLicense scLicense : scLicenses) {
2781 addSCLicense.add(pk, scLicense.getPrimaryKey());
2782 }
2783 }
2784 catch (Exception e) {
2785 throw processException(e);
2786 }
2787 finally {
2788 FinderCacheUtil.clearCache(SCProductEntryModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME);
2789 }
2790 }
2791
2792
2798 public void clearSCLicenses(long pk) throws SystemException {
2799 try {
2800 clearSCLicenses.clear(pk);
2801 }
2802 catch (Exception e) {
2803 throw processException(e);
2804 }
2805 finally {
2806 FinderCacheUtil.clearCache(SCProductEntryModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME);
2807 }
2808 }
2809
2810
2817 public void removeSCLicense(long pk, long scLicensePK)
2818 throws SystemException {
2819 try {
2820 removeSCLicense.remove(pk, scLicensePK);
2821 }
2822 catch (Exception e) {
2823 throw processException(e);
2824 }
2825 finally {
2826 FinderCacheUtil.clearCache(SCProductEntryModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME);
2827 }
2828 }
2829
2830
2837 public void removeSCLicense(long pk,
2838 com.liferay.portlet.softwarecatalog.model.SCLicense scLicense)
2839 throws SystemException {
2840 try {
2841 removeSCLicense.remove(pk, scLicense.getPrimaryKey());
2842 }
2843 catch (Exception e) {
2844 throw processException(e);
2845 }
2846 finally {
2847 FinderCacheUtil.clearCache(SCProductEntryModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME);
2848 }
2849 }
2850
2851
2858 public void removeSCLicenses(long pk, long[] scLicensePKs)
2859 throws SystemException {
2860 try {
2861 for (long scLicensePK : scLicensePKs) {
2862 removeSCLicense.remove(pk, scLicensePK);
2863 }
2864 }
2865 catch (Exception e) {
2866 throw processException(e);
2867 }
2868 finally {
2869 FinderCacheUtil.clearCache(SCProductEntryModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME);
2870 }
2871 }
2872
2873
2880 public void removeSCLicenses(long pk,
2881 List<com.liferay.portlet.softwarecatalog.model.SCLicense> scLicenses)
2882 throws SystemException {
2883 try {
2884 for (com.liferay.portlet.softwarecatalog.model.SCLicense scLicense : scLicenses) {
2885 removeSCLicense.remove(pk, scLicense.getPrimaryKey());
2886 }
2887 }
2888 catch (Exception e) {
2889 throw processException(e);
2890 }
2891 finally {
2892 FinderCacheUtil.clearCache(SCProductEntryModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME);
2893 }
2894 }
2895
2896
2903 public void setSCLicenses(long pk, long[] scLicensePKs)
2904 throws SystemException {
2905 try {
2906 Set<Long> scLicensePKSet = SetUtil.fromArray(scLicensePKs);
2907
2908 List<com.liferay.portlet.softwarecatalog.model.SCLicense> scLicenses =
2909 getSCLicenses(pk);
2910
2911 for (com.liferay.portlet.softwarecatalog.model.SCLicense scLicense : scLicenses) {
2912 if (!scLicensePKSet.remove(scLicense.getPrimaryKey())) {
2913 removeSCLicense.remove(pk, scLicense.getPrimaryKey());
2914 }
2915 }
2916
2917 for (Long scLicensePK : scLicensePKSet) {
2918 addSCLicense.add(pk, scLicensePK);
2919 }
2920 }
2921 catch (Exception e) {
2922 throw processException(e);
2923 }
2924 finally {
2925 FinderCacheUtil.clearCache(SCProductEntryModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME);
2926 }
2927 }
2928
2929
2936 public void setSCLicenses(long pk,
2937 List<com.liferay.portlet.softwarecatalog.model.SCLicense> scLicenses)
2938 throws SystemException {
2939 try {
2940 long[] scLicensePKs = new long[scLicenses.size()];
2941
2942 for (int i = 0; i < scLicenses.size(); i++) {
2943 com.liferay.portlet.softwarecatalog.model.SCLicense scLicense = scLicenses.get(i);
2944
2945 scLicensePKs[i] = scLicense.getPrimaryKey();
2946 }
2947
2948 setSCLicenses(pk, scLicensePKs);
2949 }
2950 catch (Exception e) {
2951 throw processException(e);
2952 }
2953 finally {
2954 FinderCacheUtil.clearCache(SCProductEntryModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME);
2955 }
2956 }
2957
2958
2961 public void afterPropertiesSet() {
2962 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
2963 com.liferay.portal.util.PropsUtil.get(
2964 "value.object.listener.com.liferay.portlet.softwarecatalog.model.SCProductEntry")));
2965
2966 if (listenerClassNames.length > 0) {
2967 try {
2968 List<ModelListener<SCProductEntry>> listenersList = new ArrayList<ModelListener<SCProductEntry>>();
2969
2970 for (String listenerClassName : listenerClassNames) {
2971 listenersList.add((ModelListener<SCProductEntry>)InstanceFactory.newInstance(
2972 listenerClassName));
2973 }
2974
2975 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
2976 }
2977 catch (Exception e) {
2978 _log.error(e);
2979 }
2980 }
2981
2982 containsSCLicense = new ContainsSCLicense(this);
2983
2984 addSCLicense = new AddSCLicense(this);
2985 clearSCLicenses = new ClearSCLicenses(this);
2986 removeSCLicense = new RemoveSCLicense(this);
2987 }
2988
2989 @BeanReference(type = SCLicensePersistence.class)
2990 protected SCLicensePersistence scLicensePersistence;
2991 @BeanReference(type = SCFrameworkVersionPersistence.class)
2992 protected SCFrameworkVersionPersistence scFrameworkVersionPersistence;
2993 @BeanReference(type = SCProductEntryPersistence.class)
2994 protected SCProductEntryPersistence scProductEntryPersistence;
2995 @BeanReference(type = SCProductScreenshotPersistence.class)
2996 protected SCProductScreenshotPersistence scProductScreenshotPersistence;
2997 @BeanReference(type = SCProductVersionPersistence.class)
2998 protected SCProductVersionPersistence scProductVersionPersistence;
2999 @BeanReference(type = GroupPersistence.class)
3000 protected GroupPersistence groupPersistence;
3001 @BeanReference(type = ImagePersistence.class)
3002 protected ImagePersistence imagePersistence;
3003 @BeanReference(type = ResourcePersistence.class)
3004 protected ResourcePersistence resourcePersistence;
3005 @BeanReference(type = UserPersistence.class)
3006 protected UserPersistence userPersistence;
3007 @BeanReference(type = MBMessagePersistence.class)
3008 protected MBMessagePersistence mbMessagePersistence;
3009 @BeanReference(type = RatingsStatsPersistence.class)
3010 protected RatingsStatsPersistence ratingsStatsPersistence;
3011 protected ContainsSCLicense containsSCLicense;
3012 protected AddSCLicense addSCLicense;
3013 protected ClearSCLicenses clearSCLicenses;
3014 protected RemoveSCLicense removeSCLicense;
3015
3016 protected class ContainsSCLicense {
3017 protected ContainsSCLicense(
3018 SCProductEntryPersistenceImpl persistenceImpl) {
3019 super();
3020
3021 _mappingSqlQuery = MappingSqlQueryFactoryUtil.getMappingSqlQuery(getDataSource(),
3022 _SQL_CONTAINSSCLICENSE,
3023 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT },
3024 RowMapper.COUNT);
3025 }
3026
3027 protected boolean contains(long productEntryId, long licenseId) {
3028 List<Integer> results = _mappingSqlQuery.execute(new Object[] {
3029 new Long(productEntryId), new Long(licenseId)
3030 });
3031
3032 if (results.size() > 0) {
3033 Integer count = results.get(0);
3034
3035 if (count.intValue() > 0) {
3036 return true;
3037 }
3038 }
3039
3040 return false;
3041 }
3042
3043 private MappingSqlQuery<Integer> _mappingSqlQuery;
3044 }
3045
3046 protected class AddSCLicense {
3047 protected AddSCLicense(SCProductEntryPersistenceImpl persistenceImpl) {
3048 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
3049 "INSERT INTO SCLicenses_SCProductEntries (productEntryId, licenseId) VALUES (?, ?)",
3050 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
3051 _persistenceImpl = persistenceImpl;
3052 }
3053
3054 protected void add(long productEntryId, long licenseId)
3055 throws SystemException {
3056 if (!_persistenceImpl.containsSCLicense.contains(productEntryId,
3057 licenseId)) {
3058 ModelListener<com.liferay.portlet.softwarecatalog.model.SCLicense>[] scLicenseListeners =
3059 scLicensePersistence.getListeners();
3060
3061 for (ModelListener<SCProductEntry> listener : listeners) {
3062 listener.onBeforeAddAssociation(productEntryId,
3063 com.liferay.portlet.softwarecatalog.model.SCLicense.class.getName(),
3064 licenseId);
3065 }
3066
3067 for (ModelListener<com.liferay.portlet.softwarecatalog.model.SCLicense> listener : scLicenseListeners) {
3068 listener.onBeforeAddAssociation(licenseId,
3069 SCProductEntry.class.getName(), productEntryId);
3070 }
3071
3072 _sqlUpdate.update(new Object[] {
3073 new Long(productEntryId), new Long(licenseId)
3074 });
3075
3076 for (ModelListener<SCProductEntry> listener : listeners) {
3077 listener.onAfterAddAssociation(productEntryId,
3078 com.liferay.portlet.softwarecatalog.model.SCLicense.class.getName(),
3079 licenseId);
3080 }
3081
3082 for (ModelListener<com.liferay.portlet.softwarecatalog.model.SCLicense> listener : scLicenseListeners) {
3083 listener.onAfterAddAssociation(licenseId,
3084 SCProductEntry.class.getName(), productEntryId);
3085 }
3086 }
3087 }
3088
3089 private SqlUpdate _sqlUpdate;
3090 private SCProductEntryPersistenceImpl _persistenceImpl;
3091 }
3092
3093 protected class ClearSCLicenses {
3094 protected ClearSCLicenses(SCProductEntryPersistenceImpl persistenceImpl) {
3095 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
3096 "DELETE FROM SCLicenses_SCProductEntries WHERE productEntryId = ?",
3097 new int[] { java.sql.Types.BIGINT });
3098 }
3099
3100 protected void clear(long productEntryId) throws SystemException {
3101 ModelListener<com.liferay.portlet.softwarecatalog.model.SCLicense>[] scLicenseListeners =
3102 scLicensePersistence.getListeners();
3103
3104 List<com.liferay.portlet.softwarecatalog.model.SCLicense> scLicenses =
3105 null;
3106
3107 if ((listeners.length > 0) || (scLicenseListeners.length > 0)) {
3108 scLicenses = getSCLicenses(productEntryId);
3109
3110 for (com.liferay.portlet.softwarecatalog.model.SCLicense scLicense : scLicenses) {
3111 for (ModelListener<SCProductEntry> listener : listeners) {
3112 listener.onBeforeRemoveAssociation(productEntryId,
3113 com.liferay.portlet.softwarecatalog.model.SCLicense.class.getName(),
3114 scLicense.getPrimaryKey());
3115 }
3116
3117 for (ModelListener<com.liferay.portlet.softwarecatalog.model.SCLicense> listener : scLicenseListeners) {
3118 listener.onBeforeRemoveAssociation(scLicense.getPrimaryKey(),
3119 SCProductEntry.class.getName(), productEntryId);
3120 }
3121 }
3122 }
3123
3124 _sqlUpdate.update(new Object[] { new Long(productEntryId) });
3125
3126 if ((listeners.length > 0) || (scLicenseListeners.length > 0)) {
3127 for (com.liferay.portlet.softwarecatalog.model.SCLicense scLicense : scLicenses) {
3128 for (ModelListener<SCProductEntry> listener : listeners) {
3129 listener.onAfterRemoveAssociation(productEntryId,
3130 com.liferay.portlet.softwarecatalog.model.SCLicense.class.getName(),
3131 scLicense.getPrimaryKey());
3132 }
3133
3134 for (ModelListener<com.liferay.portlet.softwarecatalog.model.SCLicense> listener : scLicenseListeners) {
3135 listener.onAfterRemoveAssociation(scLicense.getPrimaryKey(),
3136 SCProductEntry.class.getName(), productEntryId);
3137 }
3138 }
3139 }
3140 }
3141
3142 private SqlUpdate _sqlUpdate;
3143 }
3144
3145 protected class RemoveSCLicense {
3146 protected RemoveSCLicense(SCProductEntryPersistenceImpl persistenceImpl) {
3147 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
3148 "DELETE FROM SCLicenses_SCProductEntries WHERE productEntryId = ? AND licenseId = ?",
3149 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
3150 _persistenceImpl = persistenceImpl;
3151 }
3152
3153 protected void remove(long productEntryId, long licenseId)
3154 throws SystemException {
3155 if (_persistenceImpl.containsSCLicense.contains(productEntryId,
3156 licenseId)) {
3157 ModelListener<com.liferay.portlet.softwarecatalog.model.SCLicense>[] scLicenseListeners =
3158 scLicensePersistence.getListeners();
3159
3160 for (ModelListener<SCProductEntry> listener : listeners) {
3161 listener.onBeforeRemoveAssociation(productEntryId,
3162 com.liferay.portlet.softwarecatalog.model.SCLicense.class.getName(),
3163 licenseId);
3164 }
3165
3166 for (ModelListener<com.liferay.portlet.softwarecatalog.model.SCLicense> listener : scLicenseListeners) {
3167 listener.onBeforeRemoveAssociation(licenseId,
3168 SCProductEntry.class.getName(), productEntryId);
3169 }
3170
3171 _sqlUpdate.update(new Object[] {
3172 new Long(productEntryId), new Long(licenseId)
3173 });
3174
3175 for (ModelListener<SCProductEntry> listener : listeners) {
3176 listener.onAfterRemoveAssociation(productEntryId,
3177 com.liferay.portlet.softwarecatalog.model.SCLicense.class.getName(),
3178 licenseId);
3179 }
3180
3181 for (ModelListener<com.liferay.portlet.softwarecatalog.model.SCLicense> listener : scLicenseListeners) {
3182 listener.onAfterRemoveAssociation(licenseId,
3183 SCProductEntry.class.getName(), productEntryId);
3184 }
3185 }
3186 }
3187
3188 private SqlUpdate _sqlUpdate;
3189 private SCProductEntryPersistenceImpl _persistenceImpl;
3190 }
3191
3192 private static final String _SQL_SELECT_SCPRODUCTENTRY = "SELECT scProductEntry FROM SCProductEntry scProductEntry";
3193 private static final String _SQL_SELECT_SCPRODUCTENTRY_WHERE = "SELECT scProductEntry FROM SCProductEntry scProductEntry WHERE ";
3194 private static final String _SQL_COUNT_SCPRODUCTENTRY = "SELECT COUNT(scProductEntry) FROM SCProductEntry scProductEntry";
3195 private static final String _SQL_COUNT_SCPRODUCTENTRY_WHERE = "SELECT COUNT(scProductEntry) FROM SCProductEntry scProductEntry WHERE ";
3196 private static final String _SQL_GETSCLICENSES = "SELECT {SCLicense.*} FROM SCLicense INNER JOIN SCLicenses_SCProductEntries ON (SCLicenses_SCProductEntries.licenseId = SCLicense.licenseId) WHERE (SCLicenses_SCProductEntries.productEntryId = ?)";
3197 private static final String _SQL_GETSCLICENSESSIZE = "SELECT COUNT(*) AS COUNT_VALUE FROM SCLicenses_SCProductEntries WHERE productEntryId = ?";
3198 private static final String _SQL_CONTAINSSCLICENSE = "SELECT COUNT(*) AS COUNT_VALUE FROM SCLicenses_SCProductEntries WHERE productEntryId = ? AND licenseId = ?";
3199 private static final String _FINDER_COLUMN_GROUPID_GROUPID_2 = "scProductEntry.groupId = ?";
3200 private static final String _FINDER_COLUMN_COMPANYID_COMPANYID_2 = "scProductEntry.companyId = ?";
3201 private static final String _FINDER_COLUMN_G_U_GROUPID_2 = "scProductEntry.groupId = ? AND ";
3202 private static final String _FINDER_COLUMN_G_U_USERID_2 = "scProductEntry.userId = ?";
3203 private static final String _FINDER_COLUMN_RG_RA_REPOGROUPID_1 = "scProductEntry.repoGroupId IS NULL AND ";
3204 private static final String _FINDER_COLUMN_RG_RA_REPOGROUPID_2 = "lower(scProductEntry.repoGroupId) = lower(?) AND ";
3205 private static final String _FINDER_COLUMN_RG_RA_REPOGROUPID_3 = "(scProductEntry.repoGroupId IS NULL OR lower(scProductEntry.repoGroupId) = lower(?)) AND ";
3206 private static final String _FINDER_COLUMN_RG_RA_REPOARTIFACTID_1 = "scProductEntry.repoArtifactId IS NULL";
3207 private static final String _FINDER_COLUMN_RG_RA_REPOARTIFACTID_2 = "lower(scProductEntry.repoArtifactId) = lower(?)";
3208 private static final String _FINDER_COLUMN_RG_RA_REPOARTIFACTID_3 = "(scProductEntry.repoArtifactId IS NULL OR lower(scProductEntry.repoArtifactId) = lower(?))";
3209 private static final String _FILTER_SQL_SELECT_SCPRODUCTENTRY_WHERE = "SELECT DISTINCT {scProductEntry.*} FROM SCProductEntry scProductEntry WHERE ";
3210 private static final String _FILTER_SQL_COUNT_SCPRODUCTENTRY_WHERE = "SELECT COUNT(DISTINCT scProductEntry.productEntryId) AS COUNT_VALUE FROM SCProductEntry scProductEntry WHERE ";
3211 private static final String _FILTER_COLUMN_PK = "scProductEntry.productEntryId";
3212 private static final String _FILTER_COLUMN_USERID = "scProductEntry.userId";
3213 private static final String _FILTER_ENTITY_ALIAS = "scProductEntry";
3214 private static final String _ORDER_BY_ENTITY_ALIAS = "scProductEntry.";
3215 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No SCProductEntry exists with the primary key ";
3216 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No SCProductEntry exists with the key {";
3217 private static Log _log = LogFactoryUtil.getLog(SCProductEntryPersistenceImpl.class);
3218 }