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.service.persistence.BatchSessionUtil;
046 import com.liferay.portal.service.persistence.ResourcePersistence;
047 import com.liferay.portal.service.persistence.UserPersistence;
048 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
049
050 import com.liferay.portlet.softwarecatalog.NoSuchProductVersionException;
051 import com.liferay.portlet.softwarecatalog.model.SCProductVersion;
052 import com.liferay.portlet.softwarecatalog.model.impl.SCProductVersionImpl;
053 import com.liferay.portlet.softwarecatalog.model.impl.SCProductVersionModelImpl;
054
055 import java.io.Serializable;
056
057 import java.util.ArrayList;
058 import java.util.Collections;
059 import java.util.List;
060 import java.util.Set;
061
062
068 public class SCProductVersionPersistenceImpl extends BasePersistenceImpl<SCProductVersion>
069 implements SCProductVersionPersistence {
070 public static final String FINDER_CLASS_NAME_ENTITY = SCProductVersionImpl.class.getName();
071 public static final String FINDER_CLASS_NAME_LIST = FINDER_CLASS_NAME_ENTITY +
072 ".List";
073 public static final FinderPath FINDER_PATH_FIND_BY_PRODUCTENTRYID = new FinderPath(SCProductVersionModelImpl.ENTITY_CACHE_ENABLED,
074 SCProductVersionModelImpl.FINDER_CACHE_ENABLED,
075 FINDER_CLASS_NAME_LIST, "findByProductEntryId",
076 new String[] {
077 Long.class.getName(),
078
079 "java.lang.Integer", "java.lang.Integer",
080 "com.liferay.portal.kernel.util.OrderByComparator"
081 });
082 public static final FinderPath FINDER_PATH_COUNT_BY_PRODUCTENTRYID = new FinderPath(SCProductVersionModelImpl.ENTITY_CACHE_ENABLED,
083 SCProductVersionModelImpl.FINDER_CACHE_ENABLED,
084 FINDER_CLASS_NAME_LIST, "countByProductEntryId",
085 new String[] { Long.class.getName() });
086 public static final FinderPath FINDER_PATH_FETCH_BY_DIRECTDOWNLOADURL = new FinderPath(SCProductVersionModelImpl.ENTITY_CACHE_ENABLED,
087 SCProductVersionModelImpl.FINDER_CACHE_ENABLED,
088 FINDER_CLASS_NAME_ENTITY, "fetchByDirectDownloadURL",
089 new String[] { String.class.getName() });
090 public static final FinderPath FINDER_PATH_COUNT_BY_DIRECTDOWNLOADURL = new FinderPath(SCProductVersionModelImpl.ENTITY_CACHE_ENABLED,
091 SCProductVersionModelImpl.FINDER_CACHE_ENABLED,
092 FINDER_CLASS_NAME_LIST, "countByDirectDownloadURL",
093 new String[] { String.class.getName() });
094 public static final FinderPath FINDER_PATH_FIND_ALL = new FinderPath(SCProductVersionModelImpl.ENTITY_CACHE_ENABLED,
095 SCProductVersionModelImpl.FINDER_CACHE_ENABLED,
096 FINDER_CLASS_NAME_LIST, "findAll", new String[0]);
097 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(SCProductVersionModelImpl.ENTITY_CACHE_ENABLED,
098 SCProductVersionModelImpl.FINDER_CACHE_ENABLED,
099 FINDER_CLASS_NAME_LIST, "countAll", new String[0]);
100
101 public void cacheResult(SCProductVersion scProductVersion) {
102 EntityCacheUtil.putResult(SCProductVersionModelImpl.ENTITY_CACHE_ENABLED,
103 SCProductVersionImpl.class, scProductVersion.getPrimaryKey(),
104 scProductVersion);
105
106 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_DIRECTDOWNLOADURL,
107 new Object[] { scProductVersion.getDirectDownloadURL() },
108 scProductVersion);
109 }
110
111 public void cacheResult(List<SCProductVersion> scProductVersions) {
112 for (SCProductVersion scProductVersion : scProductVersions) {
113 if (EntityCacheUtil.getResult(
114 SCProductVersionModelImpl.ENTITY_CACHE_ENABLED,
115 SCProductVersionImpl.class,
116 scProductVersion.getPrimaryKey(), this) == null) {
117 cacheResult(scProductVersion);
118 }
119 }
120 }
121
122 public void clearCache() {
123 CacheRegistryUtil.clear(SCProductVersionImpl.class.getName());
124 EntityCacheUtil.clearCache(SCProductVersionImpl.class.getName());
125 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
126 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
127 }
128
129 public void clearCache(SCProductVersion scProductVersion) {
130 EntityCacheUtil.removeResult(SCProductVersionModelImpl.ENTITY_CACHE_ENABLED,
131 SCProductVersionImpl.class, scProductVersion.getPrimaryKey());
132
133 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_DIRECTDOWNLOADURL,
134 new Object[] { scProductVersion.getDirectDownloadURL() });
135 }
136
137 public SCProductVersion create(long productVersionId) {
138 SCProductVersion scProductVersion = new SCProductVersionImpl();
139
140 scProductVersion.setNew(true);
141 scProductVersion.setPrimaryKey(productVersionId);
142
143 return scProductVersion;
144 }
145
146 public SCProductVersion remove(Serializable primaryKey)
147 throws NoSuchModelException, SystemException {
148 return remove(((Long)primaryKey).longValue());
149 }
150
151 public SCProductVersion remove(long productVersionId)
152 throws NoSuchProductVersionException, SystemException {
153 Session session = null;
154
155 try {
156 session = openSession();
157
158 SCProductVersion scProductVersion = (SCProductVersion)session.get(SCProductVersionImpl.class,
159 new Long(productVersionId));
160
161 if (scProductVersion == null) {
162 if (_log.isWarnEnabled()) {
163 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
164 productVersionId);
165 }
166
167 throw new NoSuchProductVersionException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
168 productVersionId);
169 }
170
171 return remove(scProductVersion);
172 }
173 catch (NoSuchProductVersionException nsee) {
174 throw nsee;
175 }
176 catch (Exception e) {
177 throw processException(e);
178 }
179 finally {
180 closeSession(session);
181 }
182 }
183
184 protected SCProductVersion removeImpl(SCProductVersion scProductVersion)
185 throws SystemException {
186 scProductVersion = toUnwrappedModel(scProductVersion);
187
188 try {
189 clearSCFrameworkVersions.clear(scProductVersion.getPrimaryKey());
190 }
191 catch (Exception e) {
192 throw processException(e);
193 }
194 finally {
195 FinderCacheUtil.clearCache(SCProductVersionModelImpl.MAPPING_TABLE_SCFRAMEWORKVERSI_SCPRODUCTVERS_NAME);
196 }
197
198 Session session = null;
199
200 try {
201 session = openSession();
202
203 if (scProductVersion.isCachedModel() ||
204 BatchSessionUtil.isEnabled()) {
205 Object staleObject = session.get(SCProductVersionImpl.class,
206 scProductVersion.getPrimaryKeyObj());
207
208 if (staleObject != null) {
209 session.evict(staleObject);
210 }
211 }
212
213 session.delete(scProductVersion);
214
215 session.flush();
216 }
217 catch (Exception e) {
218 throw processException(e);
219 }
220 finally {
221 closeSession(session);
222 }
223
224 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
225
226 SCProductVersionModelImpl scProductVersionModelImpl = (SCProductVersionModelImpl)scProductVersion;
227
228 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_DIRECTDOWNLOADURL,
229 new Object[] {
230 scProductVersionModelImpl.getOriginalDirectDownloadURL()
231 });
232
233 EntityCacheUtil.removeResult(SCProductVersionModelImpl.ENTITY_CACHE_ENABLED,
234 SCProductVersionImpl.class, scProductVersion.getPrimaryKey());
235
236 return scProductVersion;
237 }
238
239 public SCProductVersion updateImpl(
240 com.liferay.portlet.softwarecatalog.model.SCProductVersion scProductVersion,
241 boolean merge) throws SystemException {
242 scProductVersion = toUnwrappedModel(scProductVersion);
243
244 boolean isNew = scProductVersion.isNew();
245
246 SCProductVersionModelImpl scProductVersionModelImpl = (SCProductVersionModelImpl)scProductVersion;
247
248 Session session = null;
249
250 try {
251 session = openSession();
252
253 BatchSessionUtil.update(session, scProductVersion, merge);
254
255 scProductVersion.setNew(false);
256 }
257 catch (Exception e) {
258 throw processException(e);
259 }
260 finally {
261 closeSession(session);
262 }
263
264 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
265
266 EntityCacheUtil.putResult(SCProductVersionModelImpl.ENTITY_CACHE_ENABLED,
267 SCProductVersionImpl.class, scProductVersion.getPrimaryKey(),
268 scProductVersion);
269
270 if (!isNew &&
271 (!Validator.equals(scProductVersion.getDirectDownloadURL(),
272 scProductVersionModelImpl.getOriginalDirectDownloadURL()))) {
273 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_DIRECTDOWNLOADURL,
274 new Object[] {
275 scProductVersionModelImpl.getOriginalDirectDownloadURL()
276 });
277 }
278
279 if (isNew ||
280 (!Validator.equals(scProductVersion.getDirectDownloadURL(),
281 scProductVersionModelImpl.getOriginalDirectDownloadURL()))) {
282 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_DIRECTDOWNLOADURL,
283 new Object[] { scProductVersion.getDirectDownloadURL() },
284 scProductVersion);
285 }
286
287 return scProductVersion;
288 }
289
290 protected SCProductVersion toUnwrappedModel(
291 SCProductVersion scProductVersion) {
292 if (scProductVersion instanceof SCProductVersionImpl) {
293 return scProductVersion;
294 }
295
296 SCProductVersionImpl scProductVersionImpl = new SCProductVersionImpl();
297
298 scProductVersionImpl.setNew(scProductVersion.isNew());
299 scProductVersionImpl.setPrimaryKey(scProductVersion.getPrimaryKey());
300
301 scProductVersionImpl.setProductVersionId(scProductVersion.getProductVersionId());
302 scProductVersionImpl.setCompanyId(scProductVersion.getCompanyId());
303 scProductVersionImpl.setUserId(scProductVersion.getUserId());
304 scProductVersionImpl.setUserName(scProductVersion.getUserName());
305 scProductVersionImpl.setCreateDate(scProductVersion.getCreateDate());
306 scProductVersionImpl.setModifiedDate(scProductVersion.getModifiedDate());
307 scProductVersionImpl.setProductEntryId(scProductVersion.getProductEntryId());
308 scProductVersionImpl.setVersion(scProductVersion.getVersion());
309 scProductVersionImpl.setChangeLog(scProductVersion.getChangeLog());
310 scProductVersionImpl.setDownloadPageURL(scProductVersion.getDownloadPageURL());
311 scProductVersionImpl.setDirectDownloadURL(scProductVersion.getDirectDownloadURL());
312 scProductVersionImpl.setRepoStoreArtifact(scProductVersion.isRepoStoreArtifact());
313
314 return scProductVersionImpl;
315 }
316
317 public SCProductVersion findByPrimaryKey(Serializable primaryKey)
318 throws NoSuchModelException, SystemException {
319 return findByPrimaryKey(((Long)primaryKey).longValue());
320 }
321
322 public SCProductVersion findByPrimaryKey(long productVersionId)
323 throws NoSuchProductVersionException, SystemException {
324 SCProductVersion scProductVersion = fetchByPrimaryKey(productVersionId);
325
326 if (scProductVersion == null) {
327 if (_log.isWarnEnabled()) {
328 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + productVersionId);
329 }
330
331 throw new NoSuchProductVersionException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
332 productVersionId);
333 }
334
335 return scProductVersion;
336 }
337
338 public SCProductVersion fetchByPrimaryKey(Serializable primaryKey)
339 throws SystemException {
340 return fetchByPrimaryKey(((Long)primaryKey).longValue());
341 }
342
343 public SCProductVersion fetchByPrimaryKey(long productVersionId)
344 throws SystemException {
345 SCProductVersion scProductVersion = (SCProductVersion)EntityCacheUtil.getResult(SCProductVersionModelImpl.ENTITY_CACHE_ENABLED,
346 SCProductVersionImpl.class, productVersionId, this);
347
348 if (scProductVersion == null) {
349 Session session = null;
350
351 try {
352 session = openSession();
353
354 scProductVersion = (SCProductVersion)session.get(SCProductVersionImpl.class,
355 new Long(productVersionId));
356 }
357 catch (Exception e) {
358 throw processException(e);
359 }
360 finally {
361 if (scProductVersion != null) {
362 cacheResult(scProductVersion);
363 }
364
365 closeSession(session);
366 }
367 }
368
369 return scProductVersion;
370 }
371
372 public List<SCProductVersion> findByProductEntryId(long productEntryId)
373 throws SystemException {
374 return findByProductEntryId(productEntryId, QueryUtil.ALL_POS,
375 QueryUtil.ALL_POS, null);
376 }
377
378 public List<SCProductVersion> findByProductEntryId(long productEntryId,
379 int start, int end) throws SystemException {
380 return findByProductEntryId(productEntryId, start, end, null);
381 }
382
383 public List<SCProductVersion> findByProductEntryId(long productEntryId,
384 int start, int end, OrderByComparator orderByComparator)
385 throws SystemException {
386 Object[] finderArgs = new Object[] {
387 productEntryId,
388
389 String.valueOf(start), String.valueOf(end),
390 String.valueOf(orderByComparator)
391 };
392
393 List<SCProductVersion> list = (List<SCProductVersion>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_PRODUCTENTRYID,
394 finderArgs, this);
395
396 if (list == null) {
397 Session session = null;
398
399 try {
400 session = openSession();
401
402 StringBundler query = null;
403
404 if (orderByComparator != null) {
405 query = new StringBundler(3 +
406 (orderByComparator.getOrderByFields().length * 3));
407 }
408 else {
409 query = new StringBundler(3);
410 }
411
412 query.append(_SQL_SELECT_SCPRODUCTVERSION_WHERE);
413
414 query.append(_FINDER_COLUMN_PRODUCTENTRYID_PRODUCTENTRYID_2);
415
416 if (orderByComparator != null) {
417 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
418 orderByComparator);
419 }
420
421 else {
422 query.append(SCProductVersionModelImpl.ORDER_BY_JPQL);
423 }
424
425 String sql = query.toString();
426
427 Query q = session.createQuery(sql);
428
429 QueryPos qPos = QueryPos.getInstance(q);
430
431 qPos.add(productEntryId);
432
433 list = (List<SCProductVersion>)QueryUtil.list(q, getDialect(),
434 start, end);
435 }
436 catch (Exception e) {
437 throw processException(e);
438 }
439 finally {
440 if (list == null) {
441 list = new ArrayList<SCProductVersion>();
442 }
443
444 cacheResult(list);
445
446 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_PRODUCTENTRYID,
447 finderArgs, list);
448
449 closeSession(session);
450 }
451 }
452
453 return list;
454 }
455
456 public SCProductVersion findByProductEntryId_First(long productEntryId,
457 OrderByComparator orderByComparator)
458 throws NoSuchProductVersionException, SystemException {
459 List<SCProductVersion> list = findByProductEntryId(productEntryId, 0,
460 1, orderByComparator);
461
462 if (list.isEmpty()) {
463 StringBundler msg = new StringBundler(4);
464
465 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
466
467 msg.append("productEntryId=");
468 msg.append(productEntryId);
469
470 msg.append(StringPool.CLOSE_CURLY_BRACE);
471
472 throw new NoSuchProductVersionException(msg.toString());
473 }
474 else {
475 return list.get(0);
476 }
477 }
478
479 public SCProductVersion findByProductEntryId_Last(long productEntryId,
480 OrderByComparator orderByComparator)
481 throws NoSuchProductVersionException, SystemException {
482 int count = countByProductEntryId(productEntryId);
483
484 List<SCProductVersion> list = findByProductEntryId(productEntryId,
485 count - 1, count, orderByComparator);
486
487 if (list.isEmpty()) {
488 StringBundler msg = new StringBundler(4);
489
490 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
491
492 msg.append("productEntryId=");
493 msg.append(productEntryId);
494
495 msg.append(StringPool.CLOSE_CURLY_BRACE);
496
497 throw new NoSuchProductVersionException(msg.toString());
498 }
499 else {
500 return list.get(0);
501 }
502 }
503
504 public SCProductVersion[] findByProductEntryId_PrevAndNext(
505 long productVersionId, long productEntryId,
506 OrderByComparator orderByComparator)
507 throws NoSuchProductVersionException, SystemException {
508 SCProductVersion scProductVersion = findByPrimaryKey(productVersionId);
509
510 Session session = null;
511
512 try {
513 session = openSession();
514
515 SCProductVersion[] array = new SCProductVersionImpl[3];
516
517 array[0] = getByProductEntryId_PrevAndNext(session,
518 scProductVersion, productEntryId, orderByComparator, true);
519
520 array[1] = scProductVersion;
521
522 array[2] = getByProductEntryId_PrevAndNext(session,
523 scProductVersion, productEntryId, orderByComparator, false);
524
525 return array;
526 }
527 catch (Exception e) {
528 throw processException(e);
529 }
530 finally {
531 closeSession(session);
532 }
533 }
534
535 protected SCProductVersion getByProductEntryId_PrevAndNext(
536 Session session, SCProductVersion scProductVersion,
537 long productEntryId, OrderByComparator orderByComparator,
538 boolean previous) {
539 StringBundler query = null;
540
541 if (orderByComparator != null) {
542 query = new StringBundler(6 +
543 (orderByComparator.getOrderByFields().length * 6));
544 }
545 else {
546 query = new StringBundler(3);
547 }
548
549 query.append(_SQL_SELECT_SCPRODUCTVERSION_WHERE);
550
551 query.append(_FINDER_COLUMN_PRODUCTENTRYID_PRODUCTENTRYID_2);
552
553 if (orderByComparator != null) {
554 String[] orderByFields = orderByComparator.getOrderByFields();
555
556 if (orderByFields.length > 0) {
557 query.append(WHERE_AND);
558 }
559
560 for (int i = 0; i < orderByFields.length; i++) {
561 query.append(_ORDER_BY_ENTITY_ALIAS);
562 query.append(orderByFields[i]);
563
564 if ((i + 1) < orderByFields.length) {
565 if (orderByComparator.isAscending() ^ previous) {
566 query.append(WHERE_GREATER_THAN_HAS_NEXT);
567 }
568 else {
569 query.append(WHERE_LESSER_THAN_HAS_NEXT);
570 }
571 }
572 else {
573 if (orderByComparator.isAscending() ^ previous) {
574 query.append(WHERE_GREATER_THAN);
575 }
576 else {
577 query.append(WHERE_LESSER_THAN);
578 }
579 }
580 }
581
582 query.append(ORDER_BY_CLAUSE);
583
584 for (int i = 0; i < orderByFields.length; i++) {
585 query.append(_ORDER_BY_ENTITY_ALIAS);
586 query.append(orderByFields[i]);
587
588 if ((i + 1) < orderByFields.length) {
589 if (orderByComparator.isAscending() ^ previous) {
590 query.append(ORDER_BY_ASC_HAS_NEXT);
591 }
592 else {
593 query.append(ORDER_BY_DESC_HAS_NEXT);
594 }
595 }
596 else {
597 if (orderByComparator.isAscending() ^ previous) {
598 query.append(ORDER_BY_ASC);
599 }
600 else {
601 query.append(ORDER_BY_DESC);
602 }
603 }
604 }
605 }
606
607 else {
608 query.append(SCProductVersionModelImpl.ORDER_BY_JPQL);
609 }
610
611 String sql = query.toString();
612
613 Query q = session.createQuery(sql);
614
615 q.setFirstResult(0);
616 q.setMaxResults(2);
617
618 QueryPos qPos = QueryPos.getInstance(q);
619
620 qPos.add(productEntryId);
621
622 if (orderByComparator != null) {
623 Object[] values = orderByComparator.getOrderByValues(scProductVersion);
624
625 for (Object value : values) {
626 qPos.add(value);
627 }
628 }
629
630 List<SCProductVersion> list = q.list();
631
632 if (list.size() == 2) {
633 return list.get(1);
634 }
635 else {
636 return null;
637 }
638 }
639
640 public SCProductVersion findByDirectDownloadURL(String directDownloadURL)
641 throws NoSuchProductVersionException, SystemException {
642 SCProductVersion scProductVersion = fetchByDirectDownloadURL(directDownloadURL);
643
644 if (scProductVersion == null) {
645 StringBundler msg = new StringBundler(4);
646
647 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
648
649 msg.append("directDownloadURL=");
650 msg.append(directDownloadURL);
651
652 msg.append(StringPool.CLOSE_CURLY_BRACE);
653
654 if (_log.isWarnEnabled()) {
655 _log.warn(msg.toString());
656 }
657
658 throw new NoSuchProductVersionException(msg.toString());
659 }
660
661 return scProductVersion;
662 }
663
664 public SCProductVersion fetchByDirectDownloadURL(String directDownloadURL)
665 throws SystemException {
666 return fetchByDirectDownloadURL(directDownloadURL, true);
667 }
668
669 public SCProductVersion fetchByDirectDownloadURL(String directDownloadURL,
670 boolean retrieveFromCache) throws SystemException {
671 Object[] finderArgs = new Object[] { directDownloadURL };
672
673 Object result = null;
674
675 if (retrieveFromCache) {
676 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_DIRECTDOWNLOADURL,
677 finderArgs, this);
678 }
679
680 if (result == null) {
681 Session session = null;
682
683 try {
684 session = openSession();
685
686 StringBundler query = new StringBundler(3);
687
688 query.append(_SQL_SELECT_SCPRODUCTVERSION_WHERE);
689
690 if (directDownloadURL == null) {
691 query.append(_FINDER_COLUMN_DIRECTDOWNLOADURL_DIRECTDOWNLOADURL_1);
692 }
693 else {
694 if (directDownloadURL.equals(StringPool.BLANK)) {
695 query.append(_FINDER_COLUMN_DIRECTDOWNLOADURL_DIRECTDOWNLOADURL_3);
696 }
697 else {
698 query.append(_FINDER_COLUMN_DIRECTDOWNLOADURL_DIRECTDOWNLOADURL_2);
699 }
700 }
701
702 query.append(SCProductVersionModelImpl.ORDER_BY_JPQL);
703
704 String sql = query.toString();
705
706 Query q = session.createQuery(sql);
707
708 QueryPos qPos = QueryPos.getInstance(q);
709
710 if (directDownloadURL != null) {
711 qPos.add(directDownloadURL);
712 }
713
714 List<SCProductVersion> list = q.list();
715
716 result = list;
717
718 SCProductVersion scProductVersion = null;
719
720 if (list.isEmpty()) {
721 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_DIRECTDOWNLOADURL,
722 finderArgs, list);
723 }
724 else {
725 scProductVersion = list.get(0);
726
727 cacheResult(scProductVersion);
728
729 if ((scProductVersion.getDirectDownloadURL() == null) ||
730 !scProductVersion.getDirectDownloadURL()
731 .equals(directDownloadURL)) {
732 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_DIRECTDOWNLOADURL,
733 finderArgs, scProductVersion);
734 }
735 }
736
737 return scProductVersion;
738 }
739 catch (Exception e) {
740 throw processException(e);
741 }
742 finally {
743 if (result == null) {
744 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_DIRECTDOWNLOADURL,
745 finderArgs, new ArrayList<SCProductVersion>());
746 }
747
748 closeSession(session);
749 }
750 }
751 else {
752 if (result instanceof List<?>) {
753 return null;
754 }
755 else {
756 return (SCProductVersion)result;
757 }
758 }
759 }
760
761 public List<SCProductVersion> findAll() throws SystemException {
762 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
763 }
764
765 public List<SCProductVersion> findAll(int start, int end)
766 throws SystemException {
767 return findAll(start, end, null);
768 }
769
770 public List<SCProductVersion> findAll(int start, int end,
771 OrderByComparator orderByComparator) throws SystemException {
772 Object[] finderArgs = new Object[] {
773 String.valueOf(start), String.valueOf(end),
774 String.valueOf(orderByComparator)
775 };
776
777 List<SCProductVersion> list = (List<SCProductVersion>)FinderCacheUtil.getResult(FINDER_PATH_FIND_ALL,
778 finderArgs, this);
779
780 if (list == null) {
781 Session session = null;
782
783 try {
784 session = openSession();
785
786 StringBundler query = null;
787 String sql = null;
788
789 if (orderByComparator != null) {
790 query = new StringBundler(2 +
791 (orderByComparator.getOrderByFields().length * 3));
792
793 query.append(_SQL_SELECT_SCPRODUCTVERSION);
794
795 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
796 orderByComparator);
797
798 sql = query.toString();
799 }
800 else {
801 sql = _SQL_SELECT_SCPRODUCTVERSION.concat(SCProductVersionModelImpl.ORDER_BY_JPQL);
802 }
803
804 Query q = session.createQuery(sql);
805
806 if (orderByComparator == null) {
807 list = (List<SCProductVersion>)QueryUtil.list(q,
808 getDialect(), start, end, false);
809
810 Collections.sort(list);
811 }
812 else {
813 list = (List<SCProductVersion>)QueryUtil.list(q,
814 getDialect(), start, end);
815 }
816 }
817 catch (Exception e) {
818 throw processException(e);
819 }
820 finally {
821 if (list == null) {
822 list = new ArrayList<SCProductVersion>();
823 }
824
825 cacheResult(list);
826
827 FinderCacheUtil.putResult(FINDER_PATH_FIND_ALL, finderArgs, list);
828
829 closeSession(session);
830 }
831 }
832
833 return list;
834 }
835
836 public void removeByProductEntryId(long productEntryId)
837 throws SystemException {
838 for (SCProductVersion scProductVersion : findByProductEntryId(
839 productEntryId)) {
840 remove(scProductVersion);
841 }
842 }
843
844 public void removeByDirectDownloadURL(String directDownloadURL)
845 throws NoSuchProductVersionException, SystemException {
846 SCProductVersion scProductVersion = findByDirectDownloadURL(directDownloadURL);
847
848 remove(scProductVersion);
849 }
850
851 public void removeAll() throws SystemException {
852 for (SCProductVersion scProductVersion : findAll()) {
853 remove(scProductVersion);
854 }
855 }
856
857 public int countByProductEntryId(long productEntryId)
858 throws SystemException {
859 Object[] finderArgs = new Object[] { productEntryId };
860
861 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_PRODUCTENTRYID,
862 finderArgs, this);
863
864 if (count == null) {
865 Session session = null;
866
867 try {
868 session = openSession();
869
870 StringBundler query = new StringBundler(2);
871
872 query.append(_SQL_COUNT_SCPRODUCTVERSION_WHERE);
873
874 query.append(_FINDER_COLUMN_PRODUCTENTRYID_PRODUCTENTRYID_2);
875
876 String sql = query.toString();
877
878 Query q = session.createQuery(sql);
879
880 QueryPos qPos = QueryPos.getInstance(q);
881
882 qPos.add(productEntryId);
883
884 count = (Long)q.uniqueResult();
885 }
886 catch (Exception e) {
887 throw processException(e);
888 }
889 finally {
890 if (count == null) {
891 count = Long.valueOf(0);
892 }
893
894 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_PRODUCTENTRYID,
895 finderArgs, count);
896
897 closeSession(session);
898 }
899 }
900
901 return count.intValue();
902 }
903
904 public int countByDirectDownloadURL(String directDownloadURL)
905 throws SystemException {
906 Object[] finderArgs = new Object[] { directDownloadURL };
907
908 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_DIRECTDOWNLOADURL,
909 finderArgs, this);
910
911 if (count == null) {
912 Session session = null;
913
914 try {
915 session = openSession();
916
917 StringBundler query = new StringBundler(2);
918
919 query.append(_SQL_COUNT_SCPRODUCTVERSION_WHERE);
920
921 if (directDownloadURL == null) {
922 query.append(_FINDER_COLUMN_DIRECTDOWNLOADURL_DIRECTDOWNLOADURL_1);
923 }
924 else {
925 if (directDownloadURL.equals(StringPool.BLANK)) {
926 query.append(_FINDER_COLUMN_DIRECTDOWNLOADURL_DIRECTDOWNLOADURL_3);
927 }
928 else {
929 query.append(_FINDER_COLUMN_DIRECTDOWNLOADURL_DIRECTDOWNLOADURL_2);
930 }
931 }
932
933 String sql = query.toString();
934
935 Query q = session.createQuery(sql);
936
937 QueryPos qPos = QueryPos.getInstance(q);
938
939 if (directDownloadURL != null) {
940 qPos.add(directDownloadURL);
941 }
942
943 count = (Long)q.uniqueResult();
944 }
945 catch (Exception e) {
946 throw processException(e);
947 }
948 finally {
949 if (count == null) {
950 count = Long.valueOf(0);
951 }
952
953 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_DIRECTDOWNLOADURL,
954 finderArgs, count);
955
956 closeSession(session);
957 }
958 }
959
960 return count.intValue();
961 }
962
963 public int countAll() throws SystemException {
964 Object[] finderArgs = new Object[0];
965
966 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
967 finderArgs, this);
968
969 if (count == null) {
970 Session session = null;
971
972 try {
973 session = openSession();
974
975 Query q = session.createQuery(_SQL_COUNT_SCPRODUCTVERSION);
976
977 count = (Long)q.uniqueResult();
978 }
979 catch (Exception e) {
980 throw processException(e);
981 }
982 finally {
983 if (count == null) {
984 count = Long.valueOf(0);
985 }
986
987 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL, finderArgs,
988 count);
989
990 closeSession(session);
991 }
992 }
993
994 return count.intValue();
995 }
996
997 public List<com.liferay.portlet.softwarecatalog.model.SCFrameworkVersion> getSCFrameworkVersions(
998 long pk) throws SystemException {
999 return getSCFrameworkVersions(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
1000 }
1001
1002 public List<com.liferay.portlet.softwarecatalog.model.SCFrameworkVersion> getSCFrameworkVersions(
1003 long pk, int start, int end) throws SystemException {
1004 return getSCFrameworkVersions(pk, start, end, null);
1005 }
1006
1007 public static final FinderPath FINDER_PATH_GET_SCFRAMEWORKVERSIONS = new FinderPath(com.liferay.portlet.softwarecatalog.model.impl.SCFrameworkVersionModelImpl.ENTITY_CACHE_ENABLED,
1008 SCProductVersionModelImpl.FINDER_CACHE_ENABLED_SCFRAMEWORKVERSI_SCPRODUCTVERS,
1009 SCProductVersionModelImpl.MAPPING_TABLE_SCFRAMEWORKVERSI_SCPRODUCTVERS_NAME,
1010 "getSCFrameworkVersions",
1011 new String[] {
1012 Long.class.getName(), "java.lang.Integer", "java.lang.Integer",
1013 "com.liferay.portal.kernel.util.OrderByComparator"
1014 });
1015
1016 public List<com.liferay.portlet.softwarecatalog.model.SCFrameworkVersion> getSCFrameworkVersions(
1017 long pk, int start, int end, OrderByComparator orderByComparator)
1018 throws SystemException {
1019 Object[] finderArgs = new Object[] {
1020 pk, String.valueOf(start), String.valueOf(end),
1021 String.valueOf(orderByComparator)
1022 };
1023
1024 List<com.liferay.portlet.softwarecatalog.model.SCFrameworkVersion> list = (List<com.liferay.portlet.softwarecatalog.model.SCFrameworkVersion>)FinderCacheUtil.getResult(FINDER_PATH_GET_SCFRAMEWORKVERSIONS,
1025 finderArgs, this);
1026
1027 if (list == null) {
1028 Session session = null;
1029
1030 try {
1031 session = openSession();
1032
1033 String sql = null;
1034
1035 if (orderByComparator != null) {
1036 sql = _SQL_GETSCFRAMEWORKVERSIONS.concat(ORDER_BY_CLAUSE)
1037 .concat(orderByComparator.getOrderBy());
1038 }
1039 else {
1040 sql = _SQL_GETSCFRAMEWORKVERSIONS.concat(com.liferay.portlet.softwarecatalog.model.impl.SCFrameworkVersionModelImpl.ORDER_BY_SQL);
1041 }
1042
1043 SQLQuery q = session.createSQLQuery(sql);
1044
1045 q.addEntity("SCFrameworkVersion",
1046 com.liferay.portlet.softwarecatalog.model.impl.SCFrameworkVersionImpl.class);
1047
1048 QueryPos qPos = QueryPos.getInstance(q);
1049
1050 qPos.add(pk);
1051
1052 list = (List<com.liferay.portlet.softwarecatalog.model.SCFrameworkVersion>)QueryUtil.list(q,
1053 getDialect(), start, end);
1054 }
1055 catch (Exception e) {
1056 throw processException(e);
1057 }
1058 finally {
1059 if (list == null) {
1060 list = new ArrayList<com.liferay.portlet.softwarecatalog.model.SCFrameworkVersion>();
1061 }
1062
1063 scFrameworkVersionPersistence.cacheResult(list);
1064
1065 FinderCacheUtil.putResult(FINDER_PATH_GET_SCFRAMEWORKVERSIONS,
1066 finderArgs, list);
1067
1068 closeSession(session);
1069 }
1070 }
1071
1072 return list;
1073 }
1074
1075 public static final FinderPath FINDER_PATH_GET_SCFRAMEWORKVERSIONS_SIZE = new FinderPath(com.liferay.portlet.softwarecatalog.model.impl.SCFrameworkVersionModelImpl.ENTITY_CACHE_ENABLED,
1076 SCProductVersionModelImpl.FINDER_CACHE_ENABLED_SCFRAMEWORKVERSI_SCPRODUCTVERS,
1077 SCProductVersionModelImpl.MAPPING_TABLE_SCFRAMEWORKVERSI_SCPRODUCTVERS_NAME,
1078 "getSCFrameworkVersionsSize", new String[] { Long.class.getName() });
1079
1080 public int getSCFrameworkVersionsSize(long pk) throws SystemException {
1081 Object[] finderArgs = new Object[] { pk };
1082
1083 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_GET_SCFRAMEWORKVERSIONS_SIZE,
1084 finderArgs, this);
1085
1086 if (count == null) {
1087 Session session = null;
1088
1089 try {
1090 session = openSession();
1091
1092 SQLQuery q = session.createSQLQuery(_SQL_GETSCFRAMEWORKVERSIONSSIZE);
1093
1094 q.addScalar(COUNT_COLUMN_NAME,
1095 com.liferay.portal.kernel.dao.orm.Type.LONG);
1096
1097 QueryPos qPos = QueryPos.getInstance(q);
1098
1099 qPos.add(pk);
1100
1101 count = (Long)q.uniqueResult();
1102 }
1103 catch (Exception e) {
1104 throw processException(e);
1105 }
1106 finally {
1107 if (count == null) {
1108 count = Long.valueOf(0);
1109 }
1110
1111 FinderCacheUtil.putResult(FINDER_PATH_GET_SCFRAMEWORKVERSIONS_SIZE,
1112 finderArgs, count);
1113
1114 closeSession(session);
1115 }
1116 }
1117
1118 return count.intValue();
1119 }
1120
1121 public static final FinderPath FINDER_PATH_CONTAINS_SCFRAMEWORKVERSION = new FinderPath(com.liferay.portlet.softwarecatalog.model.impl.SCFrameworkVersionModelImpl.ENTITY_CACHE_ENABLED,
1122 SCProductVersionModelImpl.FINDER_CACHE_ENABLED_SCFRAMEWORKVERSI_SCPRODUCTVERS,
1123 SCProductVersionModelImpl.MAPPING_TABLE_SCFRAMEWORKVERSI_SCPRODUCTVERS_NAME,
1124 "containsSCFrameworkVersion",
1125 new String[] { Long.class.getName(), Long.class.getName() });
1126
1127 public boolean containsSCFrameworkVersion(long pk, long scFrameworkVersionPK)
1128 throws SystemException {
1129 Object[] finderArgs = new Object[] { pk, scFrameworkVersionPK };
1130
1131 Boolean value = (Boolean)FinderCacheUtil.getResult(FINDER_PATH_CONTAINS_SCFRAMEWORKVERSION,
1132 finderArgs, this);
1133
1134 if (value == null) {
1135 try {
1136 value = Boolean.valueOf(containsSCFrameworkVersion.contains(
1137 pk, scFrameworkVersionPK));
1138 }
1139 catch (Exception e) {
1140 throw processException(e);
1141 }
1142 finally {
1143 if (value == null) {
1144 value = Boolean.FALSE;
1145 }
1146
1147 FinderCacheUtil.putResult(FINDER_PATH_CONTAINS_SCFRAMEWORKVERSION,
1148 finderArgs, value);
1149 }
1150 }
1151
1152 return value.booleanValue();
1153 }
1154
1155 public boolean containsSCFrameworkVersions(long pk)
1156 throws SystemException {
1157 if (getSCFrameworkVersionsSize(pk) > 0) {
1158 return true;
1159 }
1160 else {
1161 return false;
1162 }
1163 }
1164
1165 public void addSCFrameworkVersion(long pk, long scFrameworkVersionPK)
1166 throws SystemException {
1167 try {
1168 addSCFrameworkVersion.add(pk, scFrameworkVersionPK);
1169 }
1170 catch (Exception e) {
1171 throw processException(e);
1172 }
1173 finally {
1174 FinderCacheUtil.clearCache(SCProductVersionModelImpl.MAPPING_TABLE_SCFRAMEWORKVERSI_SCPRODUCTVERS_NAME);
1175 }
1176 }
1177
1178 public void addSCFrameworkVersion(long pk,
1179 com.liferay.portlet.softwarecatalog.model.SCFrameworkVersion scFrameworkVersion)
1180 throws SystemException {
1181 try {
1182 addSCFrameworkVersion.add(pk, scFrameworkVersion.getPrimaryKey());
1183 }
1184 catch (Exception e) {
1185 throw processException(e);
1186 }
1187 finally {
1188 FinderCacheUtil.clearCache(SCProductVersionModelImpl.MAPPING_TABLE_SCFRAMEWORKVERSI_SCPRODUCTVERS_NAME);
1189 }
1190 }
1191
1192 public void addSCFrameworkVersions(long pk, long[] scFrameworkVersionPKs)
1193 throws SystemException {
1194 try {
1195 for (long scFrameworkVersionPK : scFrameworkVersionPKs) {
1196 addSCFrameworkVersion.add(pk, scFrameworkVersionPK);
1197 }
1198 }
1199 catch (Exception e) {
1200 throw processException(e);
1201 }
1202 finally {
1203 FinderCacheUtil.clearCache(SCProductVersionModelImpl.MAPPING_TABLE_SCFRAMEWORKVERSI_SCPRODUCTVERS_NAME);
1204 }
1205 }
1206
1207 public void addSCFrameworkVersions(long pk,
1208 List<com.liferay.portlet.softwarecatalog.model.SCFrameworkVersion> scFrameworkVersions)
1209 throws SystemException {
1210 try {
1211 for (com.liferay.portlet.softwarecatalog.model.SCFrameworkVersion scFrameworkVersion : scFrameworkVersions) {
1212 addSCFrameworkVersion.add(pk, scFrameworkVersion.getPrimaryKey());
1213 }
1214 }
1215 catch (Exception e) {
1216 throw processException(e);
1217 }
1218 finally {
1219 FinderCacheUtil.clearCache(SCProductVersionModelImpl.MAPPING_TABLE_SCFRAMEWORKVERSI_SCPRODUCTVERS_NAME);
1220 }
1221 }
1222
1223 public void clearSCFrameworkVersions(long pk) throws SystemException {
1224 try {
1225 clearSCFrameworkVersions.clear(pk);
1226 }
1227 catch (Exception e) {
1228 throw processException(e);
1229 }
1230 finally {
1231 FinderCacheUtil.clearCache(SCProductVersionModelImpl.MAPPING_TABLE_SCFRAMEWORKVERSI_SCPRODUCTVERS_NAME);
1232 }
1233 }
1234
1235 public void removeSCFrameworkVersion(long pk, long scFrameworkVersionPK)
1236 throws SystemException {
1237 try {
1238 removeSCFrameworkVersion.remove(pk, scFrameworkVersionPK);
1239 }
1240 catch (Exception e) {
1241 throw processException(e);
1242 }
1243 finally {
1244 FinderCacheUtil.clearCache(SCProductVersionModelImpl.MAPPING_TABLE_SCFRAMEWORKVERSI_SCPRODUCTVERS_NAME);
1245 }
1246 }
1247
1248 public void removeSCFrameworkVersion(long pk,
1249 com.liferay.portlet.softwarecatalog.model.SCFrameworkVersion scFrameworkVersion)
1250 throws SystemException {
1251 try {
1252 removeSCFrameworkVersion.remove(pk,
1253 scFrameworkVersion.getPrimaryKey());
1254 }
1255 catch (Exception e) {
1256 throw processException(e);
1257 }
1258 finally {
1259 FinderCacheUtil.clearCache(SCProductVersionModelImpl.MAPPING_TABLE_SCFRAMEWORKVERSI_SCPRODUCTVERS_NAME);
1260 }
1261 }
1262
1263 public void removeSCFrameworkVersions(long pk, long[] scFrameworkVersionPKs)
1264 throws SystemException {
1265 try {
1266 for (long scFrameworkVersionPK : scFrameworkVersionPKs) {
1267 removeSCFrameworkVersion.remove(pk, scFrameworkVersionPK);
1268 }
1269 }
1270 catch (Exception e) {
1271 throw processException(e);
1272 }
1273 finally {
1274 FinderCacheUtil.clearCache(SCProductVersionModelImpl.MAPPING_TABLE_SCFRAMEWORKVERSI_SCPRODUCTVERS_NAME);
1275 }
1276 }
1277
1278 public void removeSCFrameworkVersions(long pk,
1279 List<com.liferay.portlet.softwarecatalog.model.SCFrameworkVersion> scFrameworkVersions)
1280 throws SystemException {
1281 try {
1282 for (com.liferay.portlet.softwarecatalog.model.SCFrameworkVersion scFrameworkVersion : scFrameworkVersions) {
1283 removeSCFrameworkVersion.remove(pk,
1284 scFrameworkVersion.getPrimaryKey());
1285 }
1286 }
1287 catch (Exception e) {
1288 throw processException(e);
1289 }
1290 finally {
1291 FinderCacheUtil.clearCache(SCProductVersionModelImpl.MAPPING_TABLE_SCFRAMEWORKVERSI_SCPRODUCTVERS_NAME);
1292 }
1293 }
1294
1295 public void setSCFrameworkVersions(long pk, long[] scFrameworkVersionPKs)
1296 throws SystemException {
1297 try {
1298 Set<Long> scFrameworkVersionPKSet = SetUtil.fromArray(scFrameworkVersionPKs);
1299
1300 List<com.liferay.portlet.softwarecatalog.model.SCFrameworkVersion> scFrameworkVersions =
1301 getSCFrameworkVersions(pk);
1302
1303 for (com.liferay.portlet.softwarecatalog.model.SCFrameworkVersion scFrameworkVersion : scFrameworkVersions) {
1304 if (!scFrameworkVersionPKSet.contains(
1305 scFrameworkVersion.getPrimaryKey())) {
1306 removeSCFrameworkVersion.remove(pk,
1307 scFrameworkVersion.getPrimaryKey());
1308 }
1309 else {
1310 scFrameworkVersionPKSet.remove(scFrameworkVersion.getPrimaryKey());
1311 }
1312 }
1313
1314 for (Long scFrameworkVersionPK : scFrameworkVersionPKSet) {
1315 addSCFrameworkVersion.add(pk, scFrameworkVersionPK);
1316 }
1317 }
1318 catch (Exception e) {
1319 throw processException(e);
1320 }
1321 finally {
1322 FinderCacheUtil.clearCache(SCProductVersionModelImpl.MAPPING_TABLE_SCFRAMEWORKVERSI_SCPRODUCTVERS_NAME);
1323 }
1324 }
1325
1326 public void setSCFrameworkVersions(long pk,
1327 List<com.liferay.portlet.softwarecatalog.model.SCFrameworkVersion> scFrameworkVersions)
1328 throws SystemException {
1329 try {
1330 long[] scFrameworkVersionPKs = new long[scFrameworkVersions.size()];
1331
1332 for (int i = 0; i < scFrameworkVersions.size(); i++) {
1333 com.liferay.portlet.softwarecatalog.model.SCFrameworkVersion scFrameworkVersion =
1334 scFrameworkVersions.get(i);
1335
1336 scFrameworkVersionPKs[i] = scFrameworkVersion.getPrimaryKey();
1337 }
1338
1339 setSCFrameworkVersions(pk, scFrameworkVersionPKs);
1340 }
1341 catch (Exception e) {
1342 throw processException(e);
1343 }
1344 finally {
1345 FinderCacheUtil.clearCache(SCProductVersionModelImpl.MAPPING_TABLE_SCFRAMEWORKVERSI_SCPRODUCTVERS_NAME);
1346 }
1347 }
1348
1349 public void afterPropertiesSet() {
1350 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
1351 com.liferay.portal.util.PropsUtil.get(
1352 "value.object.listener.com.liferay.portlet.softwarecatalog.model.SCProductVersion")));
1353
1354 if (listenerClassNames.length > 0) {
1355 try {
1356 List<ModelListener<SCProductVersion>> listenersList = new ArrayList<ModelListener<SCProductVersion>>();
1357
1358 for (String listenerClassName : listenerClassNames) {
1359 listenersList.add((ModelListener<SCProductVersion>)InstanceFactory.newInstance(
1360 listenerClassName));
1361 }
1362
1363 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
1364 }
1365 catch (Exception e) {
1366 _log.error(e);
1367 }
1368 }
1369
1370 containsSCFrameworkVersion = new ContainsSCFrameworkVersion(this);
1371
1372 addSCFrameworkVersion = new AddSCFrameworkVersion(this);
1373 clearSCFrameworkVersions = new ClearSCFrameworkVersions(this);
1374 removeSCFrameworkVersion = new RemoveSCFrameworkVersion(this);
1375 }
1376
1377 @BeanReference(type = SCLicensePersistence.class)
1378 protected SCLicensePersistence scLicensePersistence;
1379 @BeanReference(type = SCFrameworkVersionPersistence.class)
1380 protected SCFrameworkVersionPersistence scFrameworkVersionPersistence;
1381 @BeanReference(type = SCProductEntryPersistence.class)
1382 protected SCProductEntryPersistence scProductEntryPersistence;
1383 @BeanReference(type = SCProductScreenshotPersistence.class)
1384 protected SCProductScreenshotPersistence scProductScreenshotPersistence;
1385 @BeanReference(type = SCProductVersionPersistence.class)
1386 protected SCProductVersionPersistence scProductVersionPersistence;
1387 @BeanReference(type = ResourcePersistence.class)
1388 protected ResourcePersistence resourcePersistence;
1389 @BeanReference(type = UserPersistence.class)
1390 protected UserPersistence userPersistence;
1391 protected ContainsSCFrameworkVersion containsSCFrameworkVersion;
1392 protected AddSCFrameworkVersion addSCFrameworkVersion;
1393 protected ClearSCFrameworkVersions clearSCFrameworkVersions;
1394 protected RemoveSCFrameworkVersion removeSCFrameworkVersion;
1395
1396 protected class ContainsSCFrameworkVersion {
1397 protected ContainsSCFrameworkVersion(
1398 SCProductVersionPersistenceImpl persistenceImpl) {
1399 super();
1400
1401 _mappingSqlQuery = MappingSqlQueryFactoryUtil.getMappingSqlQuery(getDataSource(),
1402 _SQL_CONTAINSSCFRAMEWORKVERSION,
1403 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT },
1404 RowMapper.COUNT);
1405 }
1406
1407 protected boolean contains(long productVersionId,
1408 long frameworkVersionId) {
1409 List<Integer> results = _mappingSqlQuery.execute(new Object[] {
1410 new Long(productVersionId), new Long(frameworkVersionId)
1411 });
1412
1413 if (results.size() > 0) {
1414 Integer count = results.get(0);
1415
1416 if (count.intValue() > 0) {
1417 return true;
1418 }
1419 }
1420
1421 return false;
1422 }
1423
1424 private MappingSqlQuery<Integer> _mappingSqlQuery;
1425 }
1426
1427 protected class AddSCFrameworkVersion {
1428 protected AddSCFrameworkVersion(
1429 SCProductVersionPersistenceImpl persistenceImpl) {
1430 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
1431 "INSERT INTO SCFrameworkVersi_SCProductVers (productVersionId, frameworkVersionId) VALUES (?, ?)",
1432 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
1433 _persistenceImpl = persistenceImpl;
1434 }
1435
1436 protected void add(long productVersionId, long frameworkVersionId)
1437 throws SystemException {
1438 if (!_persistenceImpl.containsSCFrameworkVersion.contains(
1439 productVersionId, frameworkVersionId)) {
1440 ModelListener<com.liferay.portlet.softwarecatalog.model.SCFrameworkVersion>[] scFrameworkVersionListeners =
1441 scFrameworkVersionPersistence.getListeners();
1442
1443 for (ModelListener<SCProductVersion> listener : listeners) {
1444 listener.onBeforeAddAssociation(productVersionId,
1445 com.liferay.portlet.softwarecatalog.model.SCFrameworkVersion.class.getName(),
1446 frameworkVersionId);
1447 }
1448
1449 for (ModelListener<com.liferay.portlet.softwarecatalog.model.SCFrameworkVersion> listener : scFrameworkVersionListeners) {
1450 listener.onBeforeAddAssociation(frameworkVersionId,
1451 SCProductVersion.class.getName(), productVersionId);
1452 }
1453
1454 _sqlUpdate.update(new Object[] {
1455 new Long(productVersionId), new Long(frameworkVersionId)
1456 });
1457
1458 for (ModelListener<SCProductVersion> listener : listeners) {
1459 listener.onAfterAddAssociation(productVersionId,
1460 com.liferay.portlet.softwarecatalog.model.SCFrameworkVersion.class.getName(),
1461 frameworkVersionId);
1462 }
1463
1464 for (ModelListener<com.liferay.portlet.softwarecatalog.model.SCFrameworkVersion> listener : scFrameworkVersionListeners) {
1465 listener.onAfterAddAssociation(frameworkVersionId,
1466 SCProductVersion.class.getName(), productVersionId);
1467 }
1468 }
1469 }
1470
1471 private SqlUpdate _sqlUpdate;
1472 private SCProductVersionPersistenceImpl _persistenceImpl;
1473 }
1474
1475 protected class ClearSCFrameworkVersions {
1476 protected ClearSCFrameworkVersions(
1477 SCProductVersionPersistenceImpl persistenceImpl) {
1478 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
1479 "DELETE FROM SCFrameworkVersi_SCProductVers WHERE productVersionId = ?",
1480 new int[] { java.sql.Types.BIGINT });
1481 }
1482
1483 protected void clear(long productVersionId) throws SystemException {
1484 ModelListener<com.liferay.portlet.softwarecatalog.model.SCFrameworkVersion>[] scFrameworkVersionListeners =
1485 scFrameworkVersionPersistence.getListeners();
1486
1487 List<com.liferay.portlet.softwarecatalog.model.SCFrameworkVersion> scFrameworkVersions =
1488 null;
1489
1490 if ((listeners.length > 0) ||
1491 (scFrameworkVersionListeners.length > 0)) {
1492 scFrameworkVersions = getSCFrameworkVersions(productVersionId);
1493
1494 for (com.liferay.portlet.softwarecatalog.model.SCFrameworkVersion scFrameworkVersion : scFrameworkVersions) {
1495 for (ModelListener<SCProductVersion> listener : listeners) {
1496 listener.onBeforeRemoveAssociation(productVersionId,
1497 com.liferay.portlet.softwarecatalog.model.SCFrameworkVersion.class.getName(),
1498 scFrameworkVersion.getPrimaryKey());
1499 }
1500
1501 for (ModelListener<com.liferay.portlet.softwarecatalog.model.SCFrameworkVersion> listener : scFrameworkVersionListeners) {
1502 listener.onBeforeRemoveAssociation(scFrameworkVersion.getPrimaryKey(),
1503 SCProductVersion.class.getName(), productVersionId);
1504 }
1505 }
1506 }
1507
1508 _sqlUpdate.update(new Object[] { new Long(productVersionId) });
1509
1510 if ((listeners.length > 0) ||
1511 (scFrameworkVersionListeners.length > 0)) {
1512 for (com.liferay.portlet.softwarecatalog.model.SCFrameworkVersion scFrameworkVersion : scFrameworkVersions) {
1513 for (ModelListener<SCProductVersion> listener : listeners) {
1514 listener.onAfterRemoveAssociation(productVersionId,
1515 com.liferay.portlet.softwarecatalog.model.SCFrameworkVersion.class.getName(),
1516 scFrameworkVersion.getPrimaryKey());
1517 }
1518
1519 for (ModelListener<com.liferay.portlet.softwarecatalog.model.SCFrameworkVersion> listener : scFrameworkVersionListeners) {
1520 listener.onAfterRemoveAssociation(scFrameworkVersion.getPrimaryKey(),
1521 SCProductVersion.class.getName(), productVersionId);
1522 }
1523 }
1524 }
1525 }
1526
1527 private SqlUpdate _sqlUpdate;
1528 }
1529
1530 protected class RemoveSCFrameworkVersion {
1531 protected RemoveSCFrameworkVersion(
1532 SCProductVersionPersistenceImpl persistenceImpl) {
1533 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
1534 "DELETE FROM SCFrameworkVersi_SCProductVers WHERE productVersionId = ? AND frameworkVersionId = ?",
1535 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
1536 _persistenceImpl = persistenceImpl;
1537 }
1538
1539 protected void remove(long productVersionId, long frameworkVersionId)
1540 throws SystemException {
1541 if (_persistenceImpl.containsSCFrameworkVersion.contains(
1542 productVersionId, frameworkVersionId)) {
1543 ModelListener<com.liferay.portlet.softwarecatalog.model.SCFrameworkVersion>[] scFrameworkVersionListeners =
1544 scFrameworkVersionPersistence.getListeners();
1545
1546 for (ModelListener<SCProductVersion> listener : listeners) {
1547 listener.onBeforeRemoveAssociation(productVersionId,
1548 com.liferay.portlet.softwarecatalog.model.SCFrameworkVersion.class.getName(),
1549 frameworkVersionId);
1550 }
1551
1552 for (ModelListener<com.liferay.portlet.softwarecatalog.model.SCFrameworkVersion> listener : scFrameworkVersionListeners) {
1553 listener.onBeforeRemoveAssociation(frameworkVersionId,
1554 SCProductVersion.class.getName(), productVersionId);
1555 }
1556
1557 _sqlUpdate.update(new Object[] {
1558 new Long(productVersionId), new Long(frameworkVersionId)
1559 });
1560
1561 for (ModelListener<SCProductVersion> listener : listeners) {
1562 listener.onAfterRemoveAssociation(productVersionId,
1563 com.liferay.portlet.softwarecatalog.model.SCFrameworkVersion.class.getName(),
1564 frameworkVersionId);
1565 }
1566
1567 for (ModelListener<com.liferay.portlet.softwarecatalog.model.SCFrameworkVersion> listener : scFrameworkVersionListeners) {
1568 listener.onAfterRemoveAssociation(frameworkVersionId,
1569 SCProductVersion.class.getName(), productVersionId);
1570 }
1571 }
1572 }
1573
1574 private SqlUpdate _sqlUpdate;
1575 private SCProductVersionPersistenceImpl _persistenceImpl;
1576 }
1577
1578 private static final String _SQL_SELECT_SCPRODUCTVERSION = "SELECT scProductVersion FROM SCProductVersion scProductVersion";
1579 private static final String _SQL_SELECT_SCPRODUCTVERSION_WHERE = "SELECT scProductVersion FROM SCProductVersion scProductVersion WHERE ";
1580 private static final String _SQL_COUNT_SCPRODUCTVERSION = "SELECT COUNT(scProductVersion) FROM SCProductVersion scProductVersion";
1581 private static final String _SQL_COUNT_SCPRODUCTVERSION_WHERE = "SELECT COUNT(scProductVersion) FROM SCProductVersion scProductVersion WHERE ";
1582 private static final String _SQL_GETSCFRAMEWORKVERSIONS = "SELECT {SCFrameworkVersion.*} FROM SCFrameworkVersion INNER JOIN SCFrameworkVersi_SCProductVers ON (SCFrameworkVersi_SCProductVers.frameworkVersionId = SCFrameworkVersion.frameworkVersionId) WHERE (SCFrameworkVersi_SCProductVers.productVersionId = ?)";
1583 private static final String _SQL_GETSCFRAMEWORKVERSIONSSIZE = "SELECT COUNT(*) AS COUNT_VALUE FROM SCFrameworkVersi_SCProductVers WHERE productVersionId = ?";
1584 private static final String _SQL_CONTAINSSCFRAMEWORKVERSION = "SELECT COUNT(*) AS COUNT_VALUE FROM SCFrameworkVersi_SCProductVers WHERE productVersionId = ? AND frameworkVersionId = ?";
1585 private static final String _FINDER_COLUMN_PRODUCTENTRYID_PRODUCTENTRYID_2 = "scProductVersion.productEntryId = ?";
1586 private static final String _FINDER_COLUMN_DIRECTDOWNLOADURL_DIRECTDOWNLOADURL_1 =
1587 "scProductVersion.directDownloadURL IS NULL";
1588 private static final String _FINDER_COLUMN_DIRECTDOWNLOADURL_DIRECTDOWNLOADURL_2 =
1589 "lower(scProductVersion.directDownloadURL) = lower(?)";
1590 private static final String _FINDER_COLUMN_DIRECTDOWNLOADURL_DIRECTDOWNLOADURL_3 =
1591 "(scProductVersion.directDownloadURL IS NULL OR lower(scProductVersion.directDownloadURL) = lower(?))";
1592 private static final String _ORDER_BY_ENTITY_ALIAS = "scProductVersion.";
1593 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No SCProductVersion exists with the primary key ";
1594 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No SCProductVersion exists with the key {";
1595 private static Log _log = LogFactoryUtil.getLog(SCProductVersionPersistenceImpl.class);
1596 }