001
014
015 package com.liferay.portlet.ratings.service.base;
016
017 import aQute.bnd.annotation.ProviderType;
018
019 import com.liferay.portal.kernel.bean.BeanReference;
020 import com.liferay.portal.kernel.dao.db.DB;
021 import com.liferay.portal.kernel.dao.db.DBManagerUtil;
022 import com.liferay.portal.kernel.dao.jdbc.SqlUpdate;
023 import com.liferay.portal.kernel.dao.jdbc.SqlUpdateFactoryUtil;
024 import com.liferay.portal.kernel.dao.orm.ActionableDynamicQuery;
025 import com.liferay.portal.kernel.dao.orm.DefaultActionableDynamicQuery;
026 import com.liferay.portal.kernel.dao.orm.DynamicQuery;
027 import com.liferay.portal.kernel.dao.orm.DynamicQueryFactoryUtil;
028 import com.liferay.portal.kernel.dao.orm.ExportActionableDynamicQuery;
029 import com.liferay.portal.kernel.dao.orm.IndexableActionableDynamicQuery;
030 import com.liferay.portal.kernel.dao.orm.Projection;
031 import com.liferay.portal.kernel.dao.orm.Property;
032 import com.liferay.portal.kernel.dao.orm.PropertyFactoryUtil;
033 import com.liferay.portal.kernel.exception.PortalException;
034 import com.liferay.portal.kernel.exception.SystemException;
035 import com.liferay.portal.kernel.module.framework.service.IdentifiableOSGiService;
036 import com.liferay.portal.kernel.search.Indexable;
037 import com.liferay.portal.kernel.search.IndexableType;
038 import com.liferay.portal.kernel.util.OrderByComparator;
039 import com.liferay.portal.model.PersistedModel;
040 import com.liferay.portal.service.BaseLocalServiceImpl;
041 import com.liferay.portal.service.PersistedModelLocalServiceRegistry;
042 import com.liferay.portal.service.persistence.ClassNamePersistence;
043 import com.liferay.portal.service.persistence.UserFinder;
044 import com.liferay.portal.service.persistence.UserPersistence;
045 import com.liferay.portal.util.PortalUtil;
046
047 import com.liferay.portlet.asset.service.persistence.AssetEntryFinder;
048 import com.liferay.portlet.asset.service.persistence.AssetEntryPersistence;
049 import com.liferay.portlet.blogs.service.persistence.BlogsEntryFinder;
050 import com.liferay.portlet.blogs.service.persistence.BlogsEntryPersistence;
051 import com.liferay.portlet.blogs.service.persistence.BlogsStatsUserFinder;
052 import com.liferay.portlet.blogs.service.persistence.BlogsStatsUserPersistence;
053 import com.liferay.portlet.exportimport.lar.ExportImportHelperUtil;
054 import com.liferay.portlet.exportimport.lar.ManifestSummary;
055 import com.liferay.portlet.exportimport.lar.PortletDataContext;
056 import com.liferay.portlet.exportimport.lar.StagedModelDataHandlerUtil;
057 import com.liferay.portlet.exportimport.lar.StagedModelType;
058 import com.liferay.portlet.ratings.model.RatingsEntry;
059 import com.liferay.portlet.ratings.service.RatingsEntryLocalService;
060 import com.liferay.portlet.ratings.service.persistence.RatingsEntryFinder;
061 import com.liferay.portlet.ratings.service.persistence.RatingsEntryPersistence;
062 import com.liferay.portlet.ratings.service.persistence.RatingsStatsFinder;
063 import com.liferay.portlet.ratings.service.persistence.RatingsStatsPersistence;
064
065 import java.io.Serializable;
066
067 import java.util.List;
068
069 import javax.sql.DataSource;
070
071
083 @ProviderType
084 public abstract class RatingsEntryLocalServiceBaseImpl
085 extends BaseLocalServiceImpl implements RatingsEntryLocalService,
086 IdentifiableOSGiService {
087
092
093
099 @Indexable(type = IndexableType.REINDEX)
100 @Override
101 public RatingsEntry addRatingsEntry(RatingsEntry ratingsEntry) {
102 ratingsEntry.setNew(true);
103
104 return ratingsEntryPersistence.update(ratingsEntry);
105 }
106
107
113 @Override
114 public RatingsEntry createRatingsEntry(long entryId) {
115 return ratingsEntryPersistence.create(entryId);
116 }
117
118
125 @Indexable(type = IndexableType.DELETE)
126 @Override
127 public RatingsEntry deleteRatingsEntry(long entryId)
128 throws PortalException {
129 return ratingsEntryPersistence.remove(entryId);
130 }
131
132
138 @Indexable(type = IndexableType.DELETE)
139 @Override
140 public RatingsEntry deleteRatingsEntry(RatingsEntry ratingsEntry) {
141 return ratingsEntryPersistence.remove(ratingsEntry);
142 }
143
144 @Override
145 public DynamicQuery dynamicQuery() {
146 Class<?> clazz = getClass();
147
148 return DynamicQueryFactoryUtil.forClass(RatingsEntry.class,
149 clazz.getClassLoader());
150 }
151
152
158 @Override
159 public <T> List<T> dynamicQuery(DynamicQuery dynamicQuery) {
160 return ratingsEntryPersistence.findWithDynamicQuery(dynamicQuery);
161 }
162
163
175 @Override
176 public <T> List<T> dynamicQuery(DynamicQuery dynamicQuery, int start,
177 int end) {
178 return ratingsEntryPersistence.findWithDynamicQuery(dynamicQuery,
179 start, end);
180 }
181
182
195 @Override
196 public <T> List<T> dynamicQuery(DynamicQuery dynamicQuery, int start,
197 int end, OrderByComparator<T> orderByComparator) {
198 return ratingsEntryPersistence.findWithDynamicQuery(dynamicQuery,
199 start, end, orderByComparator);
200 }
201
202
208 @Override
209 public long dynamicQueryCount(DynamicQuery dynamicQuery) {
210 return ratingsEntryPersistence.countWithDynamicQuery(dynamicQuery);
211 }
212
213
220 @Override
221 public long dynamicQueryCount(DynamicQuery dynamicQuery,
222 Projection projection) {
223 return ratingsEntryPersistence.countWithDynamicQuery(dynamicQuery,
224 projection);
225 }
226
227 @Override
228 public RatingsEntry fetchRatingsEntry(long entryId) {
229 return ratingsEntryPersistence.fetchByPrimaryKey(entryId);
230 }
231
232
239 @Override
240 public RatingsEntry fetchRatingsEntryByUuidAndCompanyId(String uuid,
241 long companyId) {
242 return ratingsEntryPersistence.fetchByUuid_C_First(uuid, companyId, null);
243 }
244
245
252 @Override
253 public RatingsEntry getRatingsEntry(long entryId) throws PortalException {
254 return ratingsEntryPersistence.findByPrimaryKey(entryId);
255 }
256
257 @Override
258 public ActionableDynamicQuery getActionableDynamicQuery() {
259 ActionableDynamicQuery actionableDynamicQuery = new DefaultActionableDynamicQuery();
260
261 actionableDynamicQuery.setBaseLocalService(com.liferay.portlet.ratings.service.RatingsEntryLocalServiceUtil.getService());
262 actionableDynamicQuery.setClassLoader(getClassLoader());
263 actionableDynamicQuery.setModelClass(RatingsEntry.class);
264
265 actionableDynamicQuery.setPrimaryKeyPropertyName("entryId");
266
267 return actionableDynamicQuery;
268 }
269
270 @Override
271 public IndexableActionableDynamicQuery getIndexableActionableDynamicQuery() {
272 IndexableActionableDynamicQuery indexableActionableDynamicQuery = new IndexableActionableDynamicQuery();
273
274 indexableActionableDynamicQuery.setBaseLocalService(com.liferay.portlet.ratings.service.RatingsEntryLocalServiceUtil.getService());
275 indexableActionableDynamicQuery.setClassLoader(getClassLoader());
276 indexableActionableDynamicQuery.setModelClass(RatingsEntry.class);
277
278 indexableActionableDynamicQuery.setPrimaryKeyPropertyName("entryId");
279
280 return indexableActionableDynamicQuery;
281 }
282
283 protected void initActionableDynamicQuery(
284 ActionableDynamicQuery actionableDynamicQuery) {
285 actionableDynamicQuery.setBaseLocalService(com.liferay.portlet.ratings.service.RatingsEntryLocalServiceUtil.getService());
286 actionableDynamicQuery.setClassLoader(getClassLoader());
287 actionableDynamicQuery.setModelClass(RatingsEntry.class);
288
289 actionableDynamicQuery.setPrimaryKeyPropertyName("entryId");
290 }
291
292 @Override
293 public ExportActionableDynamicQuery getExportActionableDynamicQuery(
294 final PortletDataContext portletDataContext) {
295 final ExportActionableDynamicQuery exportActionableDynamicQuery = new ExportActionableDynamicQuery() {
296 @Override
297 public long performCount() throws PortalException {
298 ManifestSummary manifestSummary = portletDataContext.getManifestSummary();
299
300 StagedModelType stagedModelType = getStagedModelType();
301
302 long modelAdditionCount = super.performCount();
303
304 manifestSummary.addModelAdditionCount(stagedModelType,
305 modelAdditionCount);
306
307 long modelDeletionCount = ExportImportHelperUtil.getModelDeletionCount(portletDataContext,
308 stagedModelType);
309
310 manifestSummary.addModelDeletionCount(stagedModelType,
311 modelDeletionCount);
312
313 return modelAdditionCount;
314 }
315 };
316
317 initActionableDynamicQuery(exportActionableDynamicQuery);
318
319 exportActionableDynamicQuery.setAddCriteriaMethod(new ActionableDynamicQuery.AddCriteriaMethod() {
320 @Override
321 public void addCriteria(DynamicQuery dynamicQuery) {
322 portletDataContext.addDateRangeCriteria(dynamicQuery,
323 "modifiedDate");
324
325 StagedModelType stagedModelType = exportActionableDynamicQuery.getStagedModelType();
326
327 long referrerClassNameId = stagedModelType.getReferrerClassNameId();
328
329 Property classNameIdProperty = PropertyFactoryUtil.forName(
330 "classNameId");
331
332 if ((referrerClassNameId != StagedModelType.REFERRER_CLASS_NAME_ID_ALL) &&
333 (referrerClassNameId != StagedModelType.REFERRER_CLASS_NAME_ID_ANY)) {
334 dynamicQuery.add(classNameIdProperty.eq(
335 stagedModelType.getReferrerClassNameId()));
336 }
337 else if (referrerClassNameId == StagedModelType.REFERRER_CLASS_NAME_ID_ANY) {
338 dynamicQuery.add(classNameIdProperty.isNotNull());
339 }
340 }
341 });
342
343 exportActionableDynamicQuery.setCompanyId(portletDataContext.getCompanyId());
344
345 exportActionableDynamicQuery.setPerformActionMethod(new ActionableDynamicQuery.PerformActionMethod<RatingsEntry>() {
346 @Override
347 public void performAction(RatingsEntry ratingsEntry)
348 throws PortalException {
349 StagedModelDataHandlerUtil.exportStagedModel(portletDataContext,
350 ratingsEntry);
351 }
352 });
353 exportActionableDynamicQuery.setStagedModelType(new StagedModelType(
354 PortalUtil.getClassNameId(RatingsEntry.class.getName()),
355 StagedModelType.REFERRER_CLASS_NAME_ID_ALL));
356
357 return exportActionableDynamicQuery;
358 }
359
360
363 @Override
364 public PersistedModel deletePersistedModel(PersistedModel persistedModel)
365 throws PortalException {
366 return ratingsEntryLocalService.deleteRatingsEntry((RatingsEntry)persistedModel);
367 }
368
369 @Override
370 public PersistedModel getPersistedModel(Serializable primaryKeyObj)
371 throws PortalException {
372 return ratingsEntryPersistence.findByPrimaryKey(primaryKeyObj);
373 }
374
375
383 @Override
384 public RatingsEntry getRatingsEntryByUuidAndCompanyId(String uuid,
385 long companyId) throws PortalException {
386 return ratingsEntryPersistence.findByUuid_C_First(uuid, companyId, null);
387 }
388
389
400 @Override
401 public List<RatingsEntry> getRatingsEntries(int start, int end) {
402 return ratingsEntryPersistence.findAll(start, end);
403 }
404
405
410 @Override
411 public int getRatingsEntriesCount() {
412 return ratingsEntryPersistence.countAll();
413 }
414
415
421 @Indexable(type = IndexableType.REINDEX)
422 @Override
423 public RatingsEntry updateRatingsEntry(RatingsEntry ratingsEntry) {
424 return ratingsEntryPersistence.update(ratingsEntry);
425 }
426
427
432 public RatingsEntryLocalService getRatingsEntryLocalService() {
433 return ratingsEntryLocalService;
434 }
435
436
441 public void setRatingsEntryLocalService(
442 RatingsEntryLocalService ratingsEntryLocalService) {
443 this.ratingsEntryLocalService = ratingsEntryLocalService;
444 }
445
446
451 public RatingsEntryPersistence getRatingsEntryPersistence() {
452 return ratingsEntryPersistence;
453 }
454
455
460 public void setRatingsEntryPersistence(
461 RatingsEntryPersistence ratingsEntryPersistence) {
462 this.ratingsEntryPersistence = ratingsEntryPersistence;
463 }
464
465
470 public RatingsEntryFinder getRatingsEntryFinder() {
471 return ratingsEntryFinder;
472 }
473
474
479 public void setRatingsEntryFinder(RatingsEntryFinder ratingsEntryFinder) {
480 this.ratingsEntryFinder = ratingsEntryFinder;
481 }
482
483
488 public com.liferay.portlet.ratings.service.RatingsStatsLocalService getRatingsStatsLocalService() {
489 return ratingsStatsLocalService;
490 }
491
492
497 public void setRatingsStatsLocalService(
498 com.liferay.portlet.ratings.service.RatingsStatsLocalService ratingsStatsLocalService) {
499 this.ratingsStatsLocalService = ratingsStatsLocalService;
500 }
501
502
507 public RatingsStatsPersistence getRatingsStatsPersistence() {
508 return ratingsStatsPersistence;
509 }
510
511
516 public void setRatingsStatsPersistence(
517 RatingsStatsPersistence ratingsStatsPersistence) {
518 this.ratingsStatsPersistence = ratingsStatsPersistence;
519 }
520
521
526 public RatingsStatsFinder getRatingsStatsFinder() {
527 return ratingsStatsFinder;
528 }
529
530
535 public void setRatingsStatsFinder(RatingsStatsFinder ratingsStatsFinder) {
536 this.ratingsStatsFinder = ratingsStatsFinder;
537 }
538
539
544 public com.liferay.counter.service.CounterLocalService getCounterLocalService() {
545 return counterLocalService;
546 }
547
548
553 public void setCounterLocalService(
554 com.liferay.counter.service.CounterLocalService counterLocalService) {
555 this.counterLocalService = counterLocalService;
556 }
557
558
563 public com.liferay.portal.service.ClassNameLocalService getClassNameLocalService() {
564 return classNameLocalService;
565 }
566
567
572 public void setClassNameLocalService(
573 com.liferay.portal.service.ClassNameLocalService classNameLocalService) {
574 this.classNameLocalService = classNameLocalService;
575 }
576
577
582 public ClassNamePersistence getClassNamePersistence() {
583 return classNamePersistence;
584 }
585
586
591 public void setClassNamePersistence(
592 ClassNamePersistence classNamePersistence) {
593 this.classNamePersistence = classNamePersistence;
594 }
595
596
601 public com.liferay.portal.service.ResourceLocalService getResourceLocalService() {
602 return resourceLocalService;
603 }
604
605
610 public void setResourceLocalService(
611 com.liferay.portal.service.ResourceLocalService resourceLocalService) {
612 this.resourceLocalService = resourceLocalService;
613 }
614
615
620 public com.liferay.portal.service.UserLocalService getUserLocalService() {
621 return userLocalService;
622 }
623
624
629 public void setUserLocalService(
630 com.liferay.portal.service.UserLocalService userLocalService) {
631 this.userLocalService = userLocalService;
632 }
633
634
639 public UserPersistence getUserPersistence() {
640 return userPersistence;
641 }
642
643
648 public void setUserPersistence(UserPersistence userPersistence) {
649 this.userPersistence = userPersistence;
650 }
651
652
657 public UserFinder getUserFinder() {
658 return userFinder;
659 }
660
661
666 public void setUserFinder(UserFinder userFinder) {
667 this.userFinder = userFinder;
668 }
669
670
675 public com.liferay.portlet.asset.service.AssetEntryLocalService getAssetEntryLocalService() {
676 return assetEntryLocalService;
677 }
678
679
684 public void setAssetEntryLocalService(
685 com.liferay.portlet.asset.service.AssetEntryLocalService assetEntryLocalService) {
686 this.assetEntryLocalService = assetEntryLocalService;
687 }
688
689
694 public AssetEntryPersistence getAssetEntryPersistence() {
695 return assetEntryPersistence;
696 }
697
698
703 public void setAssetEntryPersistence(
704 AssetEntryPersistence assetEntryPersistence) {
705 this.assetEntryPersistence = assetEntryPersistence;
706 }
707
708
713 public AssetEntryFinder getAssetEntryFinder() {
714 return assetEntryFinder;
715 }
716
717
722 public void setAssetEntryFinder(AssetEntryFinder assetEntryFinder) {
723 this.assetEntryFinder = assetEntryFinder;
724 }
725
726
731 public com.liferay.portlet.blogs.service.BlogsEntryLocalService getBlogsEntryLocalService() {
732 return blogsEntryLocalService;
733 }
734
735
740 public void setBlogsEntryLocalService(
741 com.liferay.portlet.blogs.service.BlogsEntryLocalService blogsEntryLocalService) {
742 this.blogsEntryLocalService = blogsEntryLocalService;
743 }
744
745
750 public BlogsEntryPersistence getBlogsEntryPersistence() {
751 return blogsEntryPersistence;
752 }
753
754
759 public void setBlogsEntryPersistence(
760 BlogsEntryPersistence blogsEntryPersistence) {
761 this.blogsEntryPersistence = blogsEntryPersistence;
762 }
763
764
769 public BlogsEntryFinder getBlogsEntryFinder() {
770 return blogsEntryFinder;
771 }
772
773
778 public void setBlogsEntryFinder(BlogsEntryFinder blogsEntryFinder) {
779 this.blogsEntryFinder = blogsEntryFinder;
780 }
781
782
787 public com.liferay.portlet.blogs.service.BlogsStatsUserLocalService getBlogsStatsUserLocalService() {
788 return blogsStatsUserLocalService;
789 }
790
791
796 public void setBlogsStatsUserLocalService(
797 com.liferay.portlet.blogs.service.BlogsStatsUserLocalService blogsStatsUserLocalService) {
798 this.blogsStatsUserLocalService = blogsStatsUserLocalService;
799 }
800
801
806 public BlogsStatsUserPersistence getBlogsStatsUserPersistence() {
807 return blogsStatsUserPersistence;
808 }
809
810
815 public void setBlogsStatsUserPersistence(
816 BlogsStatsUserPersistence blogsStatsUserPersistence) {
817 this.blogsStatsUserPersistence = blogsStatsUserPersistence;
818 }
819
820
825 public BlogsStatsUserFinder getBlogsStatsUserFinder() {
826 return blogsStatsUserFinder;
827 }
828
829
834 public void setBlogsStatsUserFinder(
835 BlogsStatsUserFinder blogsStatsUserFinder) {
836 this.blogsStatsUserFinder = blogsStatsUserFinder;
837 }
838
839 public void afterPropertiesSet() {
840 persistedModelLocalServiceRegistry.register("com.liferay.portlet.ratings.model.RatingsEntry",
841 ratingsEntryLocalService);
842 }
843
844 public void destroy() {
845 persistedModelLocalServiceRegistry.unregister(
846 "com.liferay.portlet.ratings.model.RatingsEntry");
847 }
848
849
854 @Override
855 public String getOSGiServiceIdentifier() {
856 return RatingsEntryLocalService.class.getName();
857 }
858
859 protected Class<?> getModelClass() {
860 return RatingsEntry.class;
861 }
862
863 protected String getModelClassName() {
864 return RatingsEntry.class.getName();
865 }
866
867
872 protected void runSQL(String sql) {
873 try {
874 DataSource dataSource = ratingsEntryPersistence.getDataSource();
875
876 DB db = DBManagerUtil.getDB();
877
878 sql = db.buildSQL(sql);
879 sql = PortalUtil.transformSQL(sql);
880
881 SqlUpdate sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(dataSource,
882 sql, new int[0]);
883
884 sqlUpdate.update();
885 }
886 catch (Exception e) {
887 throw new SystemException(e);
888 }
889 }
890
891 @BeanReference(type = com.liferay.portlet.ratings.service.RatingsEntryLocalService.class)
892 protected RatingsEntryLocalService ratingsEntryLocalService;
893 @BeanReference(type = RatingsEntryPersistence.class)
894 protected RatingsEntryPersistence ratingsEntryPersistence;
895 @BeanReference(type = RatingsEntryFinder.class)
896 protected RatingsEntryFinder ratingsEntryFinder;
897 @BeanReference(type = com.liferay.portlet.ratings.service.RatingsStatsLocalService.class)
898 protected com.liferay.portlet.ratings.service.RatingsStatsLocalService ratingsStatsLocalService;
899 @BeanReference(type = RatingsStatsPersistence.class)
900 protected RatingsStatsPersistence ratingsStatsPersistence;
901 @BeanReference(type = RatingsStatsFinder.class)
902 protected RatingsStatsFinder ratingsStatsFinder;
903 @BeanReference(type = com.liferay.counter.service.CounterLocalService.class)
904 protected com.liferay.counter.service.CounterLocalService counterLocalService;
905 @BeanReference(type = com.liferay.portal.service.ClassNameLocalService.class)
906 protected com.liferay.portal.service.ClassNameLocalService classNameLocalService;
907 @BeanReference(type = ClassNamePersistence.class)
908 protected ClassNamePersistence classNamePersistence;
909 @BeanReference(type = com.liferay.portal.service.ResourceLocalService.class)
910 protected com.liferay.portal.service.ResourceLocalService resourceLocalService;
911 @BeanReference(type = com.liferay.portal.service.UserLocalService.class)
912 protected com.liferay.portal.service.UserLocalService userLocalService;
913 @BeanReference(type = UserPersistence.class)
914 protected UserPersistence userPersistence;
915 @BeanReference(type = UserFinder.class)
916 protected UserFinder userFinder;
917 @BeanReference(type = com.liferay.portlet.asset.service.AssetEntryLocalService.class)
918 protected com.liferay.portlet.asset.service.AssetEntryLocalService assetEntryLocalService;
919 @BeanReference(type = AssetEntryPersistence.class)
920 protected AssetEntryPersistence assetEntryPersistence;
921 @BeanReference(type = AssetEntryFinder.class)
922 protected AssetEntryFinder assetEntryFinder;
923 @BeanReference(type = com.liferay.portlet.blogs.service.BlogsEntryLocalService.class)
924 protected com.liferay.portlet.blogs.service.BlogsEntryLocalService blogsEntryLocalService;
925 @BeanReference(type = BlogsEntryPersistence.class)
926 protected BlogsEntryPersistence blogsEntryPersistence;
927 @BeanReference(type = BlogsEntryFinder.class)
928 protected BlogsEntryFinder blogsEntryFinder;
929 @BeanReference(type = com.liferay.portlet.blogs.service.BlogsStatsUserLocalService.class)
930 protected com.liferay.portlet.blogs.service.BlogsStatsUserLocalService blogsStatsUserLocalService;
931 @BeanReference(type = BlogsStatsUserPersistence.class)
932 protected BlogsStatsUserPersistence blogsStatsUserPersistence;
933 @BeanReference(type = BlogsStatsUserFinder.class)
934 protected BlogsStatsUserFinder blogsStatsUserFinder;
935 @BeanReference(type = PersistedModelLocalServiceRegistry.class)
936 protected PersistedModelLocalServiceRegistry persistedModelLocalServiceRegistry;
937 }