001
014
015 package com.liferay.portlet.ratings.service.base;
016
017 import aQute.bnd.annotation.ProviderType;
018
019 import com.liferay.asset.kernel.service.persistence.AssetEntryFinder;
020 import com.liferay.asset.kernel.service.persistence.AssetEntryPersistence;
021
022 import com.liferay.blogs.kernel.service.persistence.BlogsEntryFinder;
023 import com.liferay.blogs.kernel.service.persistence.BlogsEntryPersistence;
024 import com.liferay.blogs.kernel.service.persistence.BlogsStatsUserFinder;
025 import com.liferay.blogs.kernel.service.persistence.BlogsStatsUserPersistence;
026
027 import com.liferay.exportimport.kernel.lar.ExportImportHelperUtil;
028 import com.liferay.exportimport.kernel.lar.ManifestSummary;
029 import com.liferay.exportimport.kernel.lar.PortletDataContext;
030 import com.liferay.exportimport.kernel.lar.StagedModelDataHandlerUtil;
031 import com.liferay.exportimport.kernel.lar.StagedModelType;
032
033 import com.liferay.portal.kernel.bean.BeanReference;
034 import com.liferay.portal.kernel.dao.db.DB;
035 import com.liferay.portal.kernel.dao.db.DBManagerUtil;
036 import com.liferay.portal.kernel.dao.jdbc.SqlUpdate;
037 import com.liferay.portal.kernel.dao.jdbc.SqlUpdateFactoryUtil;
038 import com.liferay.portal.kernel.dao.orm.ActionableDynamicQuery;
039 import com.liferay.portal.kernel.dao.orm.DefaultActionableDynamicQuery;
040 import com.liferay.portal.kernel.dao.orm.DynamicQuery;
041 import com.liferay.portal.kernel.dao.orm.DynamicQueryFactoryUtil;
042 import com.liferay.portal.kernel.dao.orm.ExportActionableDynamicQuery;
043 import com.liferay.portal.kernel.dao.orm.IndexableActionableDynamicQuery;
044 import com.liferay.portal.kernel.dao.orm.Projection;
045 import com.liferay.portal.kernel.dao.orm.Property;
046 import com.liferay.portal.kernel.dao.orm.PropertyFactoryUtil;
047 import com.liferay.portal.kernel.exception.PortalException;
048 import com.liferay.portal.kernel.exception.SystemException;
049 import com.liferay.portal.kernel.model.PersistedModel;
050 import com.liferay.portal.kernel.module.framework.service.IdentifiableOSGiService;
051 import com.liferay.portal.kernel.search.Indexable;
052 import com.liferay.portal.kernel.search.IndexableType;
053 import com.liferay.portal.kernel.service.BaseLocalServiceImpl;
054 import com.liferay.portal.kernel.service.PersistedModelLocalServiceRegistry;
055 import com.liferay.portal.kernel.service.persistence.ClassNamePersistence;
056 import com.liferay.portal.kernel.service.persistence.UserFinder;
057 import com.liferay.portal.kernel.service.persistence.UserPersistence;
058 import com.liferay.portal.kernel.util.OrderByComparator;
059 import com.liferay.portal.kernel.util.PortalUtil;
060
061 import com.liferay.ratings.kernel.model.RatingsEntry;
062 import com.liferay.ratings.kernel.service.RatingsEntryLocalService;
063 import com.liferay.ratings.kernel.service.persistence.RatingsEntryFinder;
064 import com.liferay.ratings.kernel.service.persistence.RatingsEntryPersistence;
065 import com.liferay.ratings.kernel.service.persistence.RatingsStatsFinder;
066 import com.liferay.ratings.kernel.service.persistence.RatingsStatsPersistence;
067
068 import java.io.Serializable;
069
070 import java.util.List;
071
072 import javax.sql.DataSource;
073
074
086 @ProviderType
087 public abstract class RatingsEntryLocalServiceBaseImpl
088 extends BaseLocalServiceImpl implements RatingsEntryLocalService,
089 IdentifiableOSGiService {
090
095
096
102 @Indexable(type = IndexableType.REINDEX)
103 @Override
104 public RatingsEntry addRatingsEntry(RatingsEntry ratingsEntry) {
105 ratingsEntry.setNew(true);
106
107 return ratingsEntryPersistence.update(ratingsEntry);
108 }
109
110
116 @Override
117 public RatingsEntry createRatingsEntry(long entryId) {
118 return ratingsEntryPersistence.create(entryId);
119 }
120
121
128 @Indexable(type = IndexableType.DELETE)
129 @Override
130 public RatingsEntry deleteRatingsEntry(long entryId)
131 throws PortalException {
132 return ratingsEntryPersistence.remove(entryId);
133 }
134
135
141 @Indexable(type = IndexableType.DELETE)
142 @Override
143 public RatingsEntry deleteRatingsEntry(RatingsEntry ratingsEntry) {
144 return ratingsEntryPersistence.remove(ratingsEntry);
145 }
146
147 @Override
148 public DynamicQuery dynamicQuery() {
149 Class<?> clazz = getClass();
150
151 return DynamicQueryFactoryUtil.forClass(RatingsEntry.class,
152 clazz.getClassLoader());
153 }
154
155
161 @Override
162 public <T> List<T> dynamicQuery(DynamicQuery dynamicQuery) {
163 return ratingsEntryPersistence.findWithDynamicQuery(dynamicQuery);
164 }
165
166
178 @Override
179 public <T> List<T> dynamicQuery(DynamicQuery dynamicQuery, int start,
180 int end) {
181 return ratingsEntryPersistence.findWithDynamicQuery(dynamicQuery,
182 start, end);
183 }
184
185
198 @Override
199 public <T> List<T> dynamicQuery(DynamicQuery dynamicQuery, int start,
200 int end, OrderByComparator<T> orderByComparator) {
201 return ratingsEntryPersistence.findWithDynamicQuery(dynamicQuery,
202 start, end, orderByComparator);
203 }
204
205
211 @Override
212 public long dynamicQueryCount(DynamicQuery dynamicQuery) {
213 return ratingsEntryPersistence.countWithDynamicQuery(dynamicQuery);
214 }
215
216
223 @Override
224 public long dynamicQueryCount(DynamicQuery dynamicQuery,
225 Projection projection) {
226 return ratingsEntryPersistence.countWithDynamicQuery(dynamicQuery,
227 projection);
228 }
229
230 @Override
231 public RatingsEntry fetchRatingsEntry(long entryId) {
232 return ratingsEntryPersistence.fetchByPrimaryKey(entryId);
233 }
234
235
242 @Override
243 public RatingsEntry fetchRatingsEntryByUuidAndCompanyId(String uuid,
244 long companyId) {
245 return ratingsEntryPersistence.fetchByUuid_C_First(uuid, companyId, null);
246 }
247
248
255 @Override
256 public RatingsEntry getRatingsEntry(long entryId) throws PortalException {
257 return ratingsEntryPersistence.findByPrimaryKey(entryId);
258 }
259
260 @Override
261 public ActionableDynamicQuery getActionableDynamicQuery() {
262 ActionableDynamicQuery actionableDynamicQuery = new DefaultActionableDynamicQuery();
263
264 actionableDynamicQuery.setBaseLocalService(ratingsEntryLocalService);
265 actionableDynamicQuery.setClassLoader(getClassLoader());
266 actionableDynamicQuery.setModelClass(RatingsEntry.class);
267
268 actionableDynamicQuery.setPrimaryKeyPropertyName("entryId");
269
270 return actionableDynamicQuery;
271 }
272
273 @Override
274 public IndexableActionableDynamicQuery getIndexableActionableDynamicQuery() {
275 IndexableActionableDynamicQuery indexableActionableDynamicQuery = new IndexableActionableDynamicQuery();
276
277 indexableActionableDynamicQuery.setBaseLocalService(ratingsEntryLocalService);
278 indexableActionableDynamicQuery.setClassLoader(getClassLoader());
279 indexableActionableDynamicQuery.setModelClass(RatingsEntry.class);
280
281 indexableActionableDynamicQuery.setPrimaryKeyPropertyName("entryId");
282
283 return indexableActionableDynamicQuery;
284 }
285
286 protected void initActionableDynamicQuery(
287 ActionableDynamicQuery actionableDynamicQuery) {
288 actionableDynamicQuery.setBaseLocalService(ratingsEntryLocalService);
289 actionableDynamicQuery.setClassLoader(getClassLoader());
290 actionableDynamicQuery.setModelClass(RatingsEntry.class);
291
292 actionableDynamicQuery.setPrimaryKeyPropertyName("entryId");
293 }
294
295 @Override
296 public ExportActionableDynamicQuery getExportActionableDynamicQuery(
297 final PortletDataContext portletDataContext) {
298 final ExportActionableDynamicQuery exportActionableDynamicQuery = new ExportActionableDynamicQuery() {
299 @Override
300 public long performCount() throws PortalException {
301 ManifestSummary manifestSummary = portletDataContext.getManifestSummary();
302
303 StagedModelType stagedModelType = getStagedModelType();
304
305 long modelAdditionCount = super.performCount();
306
307 manifestSummary.addModelAdditionCount(stagedModelType,
308 modelAdditionCount);
309
310 long modelDeletionCount = ExportImportHelperUtil.getModelDeletionCount(portletDataContext,
311 stagedModelType);
312
313 manifestSummary.addModelDeletionCount(stagedModelType,
314 modelDeletionCount);
315
316 return modelAdditionCount;
317 }
318 };
319
320 initActionableDynamicQuery(exportActionableDynamicQuery);
321
322 exportActionableDynamicQuery.setAddCriteriaMethod(new ActionableDynamicQuery.AddCriteriaMethod() {
323 @Override
324 public void addCriteria(DynamicQuery dynamicQuery) {
325 portletDataContext.addDateRangeCriteria(dynamicQuery,
326 "modifiedDate");
327
328 StagedModelType stagedModelType = exportActionableDynamicQuery.getStagedModelType();
329
330 long referrerClassNameId = stagedModelType.getReferrerClassNameId();
331
332 Property classNameIdProperty = PropertyFactoryUtil.forName(
333 "classNameId");
334
335 if ((referrerClassNameId != StagedModelType.REFERRER_CLASS_NAME_ID_ALL) &&
336 (referrerClassNameId != StagedModelType.REFERRER_CLASS_NAME_ID_ANY)) {
337 dynamicQuery.add(classNameIdProperty.eq(
338 stagedModelType.getReferrerClassNameId()));
339 }
340 else if (referrerClassNameId == StagedModelType.REFERRER_CLASS_NAME_ID_ANY) {
341 dynamicQuery.add(classNameIdProperty.isNotNull());
342 }
343 }
344 });
345
346 exportActionableDynamicQuery.setCompanyId(portletDataContext.getCompanyId());
347
348 exportActionableDynamicQuery.setPerformActionMethod(new ActionableDynamicQuery.PerformActionMethod<RatingsEntry>() {
349 @Override
350 public void performAction(RatingsEntry ratingsEntry)
351 throws PortalException {
352 StagedModelDataHandlerUtil.exportStagedModel(portletDataContext,
353 ratingsEntry);
354 }
355 });
356 exportActionableDynamicQuery.setStagedModelType(new StagedModelType(
357 PortalUtil.getClassNameId(RatingsEntry.class.getName()),
358 StagedModelType.REFERRER_CLASS_NAME_ID_ALL));
359
360 return exportActionableDynamicQuery;
361 }
362
363
366 @Override
367 public PersistedModel deletePersistedModel(PersistedModel persistedModel)
368 throws PortalException {
369 return ratingsEntryLocalService.deleteRatingsEntry((RatingsEntry)persistedModel);
370 }
371
372 @Override
373 public PersistedModel getPersistedModel(Serializable primaryKeyObj)
374 throws PortalException {
375 return ratingsEntryPersistence.findByPrimaryKey(primaryKeyObj);
376 }
377
378
386 @Override
387 public RatingsEntry getRatingsEntryByUuidAndCompanyId(String uuid,
388 long companyId) throws PortalException {
389 return ratingsEntryPersistence.findByUuid_C_First(uuid, companyId, null);
390 }
391
392
403 @Override
404 public List<RatingsEntry> getRatingsEntries(int start, int end) {
405 return ratingsEntryPersistence.findAll(start, end);
406 }
407
408
413 @Override
414 public int getRatingsEntriesCount() {
415 return ratingsEntryPersistence.countAll();
416 }
417
418
424 @Indexable(type = IndexableType.REINDEX)
425 @Override
426 public RatingsEntry updateRatingsEntry(RatingsEntry ratingsEntry) {
427 return ratingsEntryPersistence.update(ratingsEntry);
428 }
429
430
435 public RatingsEntryLocalService getRatingsEntryLocalService() {
436 return ratingsEntryLocalService;
437 }
438
439
444 public void setRatingsEntryLocalService(
445 RatingsEntryLocalService ratingsEntryLocalService) {
446 this.ratingsEntryLocalService = ratingsEntryLocalService;
447 }
448
449
454 public RatingsEntryPersistence getRatingsEntryPersistence() {
455 return ratingsEntryPersistence;
456 }
457
458
463 public void setRatingsEntryPersistence(
464 RatingsEntryPersistence ratingsEntryPersistence) {
465 this.ratingsEntryPersistence = ratingsEntryPersistence;
466 }
467
468
473 public RatingsEntryFinder getRatingsEntryFinder() {
474 return ratingsEntryFinder;
475 }
476
477
482 public void setRatingsEntryFinder(RatingsEntryFinder ratingsEntryFinder) {
483 this.ratingsEntryFinder = ratingsEntryFinder;
484 }
485
486
491 public com.liferay.ratings.kernel.service.RatingsStatsLocalService getRatingsStatsLocalService() {
492 return ratingsStatsLocalService;
493 }
494
495
500 public void setRatingsStatsLocalService(
501 com.liferay.ratings.kernel.service.RatingsStatsLocalService ratingsStatsLocalService) {
502 this.ratingsStatsLocalService = ratingsStatsLocalService;
503 }
504
505
510 public RatingsStatsPersistence getRatingsStatsPersistence() {
511 return ratingsStatsPersistence;
512 }
513
514
519 public void setRatingsStatsPersistence(
520 RatingsStatsPersistence ratingsStatsPersistence) {
521 this.ratingsStatsPersistence = ratingsStatsPersistence;
522 }
523
524
529 public RatingsStatsFinder getRatingsStatsFinder() {
530 return ratingsStatsFinder;
531 }
532
533
538 public void setRatingsStatsFinder(RatingsStatsFinder ratingsStatsFinder) {
539 this.ratingsStatsFinder = ratingsStatsFinder;
540 }
541
542
547 public com.liferay.counter.kernel.service.CounterLocalService getCounterLocalService() {
548 return counterLocalService;
549 }
550
551
556 public void setCounterLocalService(
557 com.liferay.counter.kernel.service.CounterLocalService counterLocalService) {
558 this.counterLocalService = counterLocalService;
559 }
560
561
566 public com.liferay.portal.kernel.service.ClassNameLocalService getClassNameLocalService() {
567 return classNameLocalService;
568 }
569
570
575 public void setClassNameLocalService(
576 com.liferay.portal.kernel.service.ClassNameLocalService classNameLocalService) {
577 this.classNameLocalService = classNameLocalService;
578 }
579
580
585 public ClassNamePersistence getClassNamePersistence() {
586 return classNamePersistence;
587 }
588
589
594 public void setClassNamePersistence(
595 ClassNamePersistence classNamePersistence) {
596 this.classNamePersistence = classNamePersistence;
597 }
598
599
604 public com.liferay.portal.kernel.service.ResourceLocalService getResourceLocalService() {
605 return resourceLocalService;
606 }
607
608
613 public void setResourceLocalService(
614 com.liferay.portal.kernel.service.ResourceLocalService resourceLocalService) {
615 this.resourceLocalService = resourceLocalService;
616 }
617
618
623 public com.liferay.portal.kernel.service.UserLocalService getUserLocalService() {
624 return userLocalService;
625 }
626
627
632 public void setUserLocalService(
633 com.liferay.portal.kernel.service.UserLocalService userLocalService) {
634 this.userLocalService = userLocalService;
635 }
636
637
642 public UserPersistence getUserPersistence() {
643 return userPersistence;
644 }
645
646
651 public void setUserPersistence(UserPersistence userPersistence) {
652 this.userPersistence = userPersistence;
653 }
654
655
660 public UserFinder getUserFinder() {
661 return userFinder;
662 }
663
664
669 public void setUserFinder(UserFinder userFinder) {
670 this.userFinder = userFinder;
671 }
672
673
678 public com.liferay.asset.kernel.service.AssetEntryLocalService getAssetEntryLocalService() {
679 return assetEntryLocalService;
680 }
681
682
687 public void setAssetEntryLocalService(
688 com.liferay.asset.kernel.service.AssetEntryLocalService assetEntryLocalService) {
689 this.assetEntryLocalService = assetEntryLocalService;
690 }
691
692
697 public AssetEntryPersistence getAssetEntryPersistence() {
698 return assetEntryPersistence;
699 }
700
701
706 public void setAssetEntryPersistence(
707 AssetEntryPersistence assetEntryPersistence) {
708 this.assetEntryPersistence = assetEntryPersistence;
709 }
710
711
716 public AssetEntryFinder getAssetEntryFinder() {
717 return assetEntryFinder;
718 }
719
720
725 public void setAssetEntryFinder(AssetEntryFinder assetEntryFinder) {
726 this.assetEntryFinder = assetEntryFinder;
727 }
728
729
734 public com.liferay.blogs.kernel.service.BlogsEntryLocalService getBlogsEntryLocalService() {
735 return blogsEntryLocalService;
736 }
737
738
743 public void setBlogsEntryLocalService(
744 com.liferay.blogs.kernel.service.BlogsEntryLocalService blogsEntryLocalService) {
745 this.blogsEntryLocalService = blogsEntryLocalService;
746 }
747
748
753 public BlogsEntryPersistence getBlogsEntryPersistence() {
754 return blogsEntryPersistence;
755 }
756
757
762 public void setBlogsEntryPersistence(
763 BlogsEntryPersistence blogsEntryPersistence) {
764 this.blogsEntryPersistence = blogsEntryPersistence;
765 }
766
767
772 public BlogsEntryFinder getBlogsEntryFinder() {
773 return blogsEntryFinder;
774 }
775
776
781 public void setBlogsEntryFinder(BlogsEntryFinder blogsEntryFinder) {
782 this.blogsEntryFinder = blogsEntryFinder;
783 }
784
785
790 public com.liferay.blogs.kernel.service.BlogsStatsUserLocalService getBlogsStatsUserLocalService() {
791 return blogsStatsUserLocalService;
792 }
793
794
799 public void setBlogsStatsUserLocalService(
800 com.liferay.blogs.kernel.service.BlogsStatsUserLocalService blogsStatsUserLocalService) {
801 this.blogsStatsUserLocalService = blogsStatsUserLocalService;
802 }
803
804
809 public BlogsStatsUserPersistence getBlogsStatsUserPersistence() {
810 return blogsStatsUserPersistence;
811 }
812
813
818 public void setBlogsStatsUserPersistence(
819 BlogsStatsUserPersistence blogsStatsUserPersistence) {
820 this.blogsStatsUserPersistence = blogsStatsUserPersistence;
821 }
822
823
828 public BlogsStatsUserFinder getBlogsStatsUserFinder() {
829 return blogsStatsUserFinder;
830 }
831
832
837 public void setBlogsStatsUserFinder(
838 BlogsStatsUserFinder blogsStatsUserFinder) {
839 this.blogsStatsUserFinder = blogsStatsUserFinder;
840 }
841
842 public void afterPropertiesSet() {
843 persistedModelLocalServiceRegistry.register("com.liferay.ratings.kernel.model.RatingsEntry",
844 ratingsEntryLocalService);
845 }
846
847 public void destroy() {
848 persistedModelLocalServiceRegistry.unregister(
849 "com.liferay.ratings.kernel.model.RatingsEntry");
850 }
851
852
857 @Override
858 public String getOSGiServiceIdentifier() {
859 return RatingsEntryLocalService.class.getName();
860 }
861
862 protected Class<?> getModelClass() {
863 return RatingsEntry.class;
864 }
865
866 protected String getModelClassName() {
867 return RatingsEntry.class.getName();
868 }
869
870
875 protected void runSQL(String sql) {
876 try {
877 DataSource dataSource = ratingsEntryPersistence.getDataSource();
878
879 DB db = DBManagerUtil.getDB();
880
881 sql = db.buildSQL(sql);
882 sql = PortalUtil.transformSQL(sql);
883
884 SqlUpdate sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(dataSource,
885 sql);
886
887 sqlUpdate.update();
888 }
889 catch (Exception e) {
890 throw new SystemException(e);
891 }
892 }
893
894 @BeanReference(type = RatingsEntryLocalService.class)
895 protected RatingsEntryLocalService ratingsEntryLocalService;
896 @BeanReference(type = RatingsEntryPersistence.class)
897 protected RatingsEntryPersistence ratingsEntryPersistence;
898 @BeanReference(type = RatingsEntryFinder.class)
899 protected RatingsEntryFinder ratingsEntryFinder;
900 @BeanReference(type = com.liferay.ratings.kernel.service.RatingsStatsLocalService.class)
901 protected com.liferay.ratings.kernel.service.RatingsStatsLocalService ratingsStatsLocalService;
902 @BeanReference(type = RatingsStatsPersistence.class)
903 protected RatingsStatsPersistence ratingsStatsPersistence;
904 @BeanReference(type = RatingsStatsFinder.class)
905 protected RatingsStatsFinder ratingsStatsFinder;
906 @BeanReference(type = com.liferay.counter.kernel.service.CounterLocalService.class)
907 protected com.liferay.counter.kernel.service.CounterLocalService counterLocalService;
908 @BeanReference(type = com.liferay.portal.kernel.service.ClassNameLocalService.class)
909 protected com.liferay.portal.kernel.service.ClassNameLocalService classNameLocalService;
910 @BeanReference(type = ClassNamePersistence.class)
911 protected ClassNamePersistence classNamePersistence;
912 @BeanReference(type = com.liferay.portal.kernel.service.ResourceLocalService.class)
913 protected com.liferay.portal.kernel.service.ResourceLocalService resourceLocalService;
914 @BeanReference(type = com.liferay.portal.kernel.service.UserLocalService.class)
915 protected com.liferay.portal.kernel.service.UserLocalService userLocalService;
916 @BeanReference(type = UserPersistence.class)
917 protected UserPersistence userPersistence;
918 @BeanReference(type = UserFinder.class)
919 protected UserFinder userFinder;
920 @BeanReference(type = com.liferay.asset.kernel.service.AssetEntryLocalService.class)
921 protected com.liferay.asset.kernel.service.AssetEntryLocalService assetEntryLocalService;
922 @BeanReference(type = AssetEntryPersistence.class)
923 protected AssetEntryPersistence assetEntryPersistence;
924 @BeanReference(type = AssetEntryFinder.class)
925 protected AssetEntryFinder assetEntryFinder;
926 @BeanReference(type = com.liferay.blogs.kernel.service.BlogsEntryLocalService.class)
927 protected com.liferay.blogs.kernel.service.BlogsEntryLocalService blogsEntryLocalService;
928 @BeanReference(type = BlogsEntryPersistence.class)
929 protected BlogsEntryPersistence blogsEntryPersistence;
930 @BeanReference(type = BlogsEntryFinder.class)
931 protected BlogsEntryFinder blogsEntryFinder;
932 @BeanReference(type = com.liferay.blogs.kernel.service.BlogsStatsUserLocalService.class)
933 protected com.liferay.blogs.kernel.service.BlogsStatsUserLocalService blogsStatsUserLocalService;
934 @BeanReference(type = BlogsStatsUserPersistence.class)
935 protected BlogsStatsUserPersistence blogsStatsUserPersistence;
936 @BeanReference(type = BlogsStatsUserFinder.class)
937 protected BlogsStatsUserFinder blogsStatsUserFinder;
938 @BeanReference(type = PersistedModelLocalServiceRegistry.class)
939 protected PersistedModelLocalServiceRegistry persistedModelLocalServiceRegistry;
940 }