001
014
015 package com.liferay.portlet.shopping.service.base;
016
017 import com.liferay.counter.service.CounterLocalService;
018
019 import com.liferay.portal.kernel.bean.BeanReference;
020 import com.liferay.portal.kernel.bean.IdentifiableBean;
021 import com.liferay.portal.kernel.dao.jdbc.SqlUpdate;
022 import com.liferay.portal.kernel.dao.jdbc.SqlUpdateFactoryUtil;
023 import com.liferay.portal.kernel.dao.orm.DynamicQuery;
024 import com.liferay.portal.kernel.exception.PortalException;
025 import com.liferay.portal.kernel.exception.SystemException;
026 import com.liferay.portal.kernel.log.Log;
027 import com.liferay.portal.kernel.log.LogFactoryUtil;
028 import com.liferay.portal.kernel.search.Indexer;
029 import com.liferay.portal.kernel.search.IndexerRegistryUtil;
030 import com.liferay.portal.kernel.search.SearchException;
031 import com.liferay.portal.kernel.util.OrderByComparator;
032 import com.liferay.portal.model.PersistedModel;
033 import com.liferay.portal.service.ImageLocalService;
034 import com.liferay.portal.service.ImageService;
035 import com.liferay.portal.service.PersistedModelLocalServiceRegistry;
036 import com.liferay.portal.service.ResourceLocalService;
037 import com.liferay.portal.service.ResourceService;
038 import com.liferay.portal.service.UserLocalService;
039 import com.liferay.portal.service.UserService;
040 import com.liferay.portal.service.persistence.ImagePersistence;
041 import com.liferay.portal.service.persistence.ResourceFinder;
042 import com.liferay.portal.service.persistence.ResourcePersistence;
043 import com.liferay.portal.service.persistence.UserFinder;
044 import com.liferay.portal.service.persistence.UserPersistence;
045
046 import com.liferay.portlet.shopping.model.ShoppingItem;
047 import com.liferay.portlet.shopping.service.ShoppingCartLocalService;
048 import com.liferay.portlet.shopping.service.ShoppingCategoryLocalService;
049 import com.liferay.portlet.shopping.service.ShoppingCategoryService;
050 import com.liferay.portlet.shopping.service.ShoppingCouponLocalService;
051 import com.liferay.portlet.shopping.service.ShoppingCouponService;
052 import com.liferay.portlet.shopping.service.ShoppingItemFieldLocalService;
053 import com.liferay.portlet.shopping.service.ShoppingItemLocalService;
054 import com.liferay.portlet.shopping.service.ShoppingItemPriceLocalService;
055 import com.liferay.portlet.shopping.service.ShoppingItemService;
056 import com.liferay.portlet.shopping.service.ShoppingOrderItemLocalService;
057 import com.liferay.portlet.shopping.service.ShoppingOrderLocalService;
058 import com.liferay.portlet.shopping.service.ShoppingOrderService;
059 import com.liferay.portlet.shopping.service.persistence.ShoppingCartPersistence;
060 import com.liferay.portlet.shopping.service.persistence.ShoppingCategoryPersistence;
061 import com.liferay.portlet.shopping.service.persistence.ShoppingCouponFinder;
062 import com.liferay.portlet.shopping.service.persistence.ShoppingCouponPersistence;
063 import com.liferay.portlet.shopping.service.persistence.ShoppingItemFieldPersistence;
064 import com.liferay.portlet.shopping.service.persistence.ShoppingItemFinder;
065 import com.liferay.portlet.shopping.service.persistence.ShoppingItemPersistence;
066 import com.liferay.portlet.shopping.service.persistence.ShoppingItemPricePersistence;
067 import com.liferay.portlet.shopping.service.persistence.ShoppingOrderFinder;
068 import com.liferay.portlet.shopping.service.persistence.ShoppingOrderItemPersistence;
069 import com.liferay.portlet.shopping.service.persistence.ShoppingOrderPersistence;
070
071 import java.io.Serializable;
072
073 import java.util.List;
074
075 import javax.sql.DataSource;
076
077
089 public abstract class ShoppingItemLocalServiceBaseImpl
090 implements ShoppingItemLocalService, IdentifiableBean {
091
096
097
104 public ShoppingItem addShoppingItem(ShoppingItem shoppingItem)
105 throws SystemException {
106 shoppingItem.setNew(true);
107
108 shoppingItem = shoppingItemPersistence.update(shoppingItem, false);
109
110 Indexer indexer = IndexerRegistryUtil.getIndexer(getModelClassName());
111
112 if (indexer != null) {
113 try {
114 indexer.reindex(shoppingItem);
115 }
116 catch (SearchException se) {
117 if (_log.isWarnEnabled()) {
118 _log.warn(se, se);
119 }
120 }
121 }
122
123 return shoppingItem;
124 }
125
126
132 public ShoppingItem createShoppingItem(long itemId) {
133 return shoppingItemPersistence.create(itemId);
134 }
135
136
143 public void deleteShoppingItem(long itemId)
144 throws PortalException, SystemException {
145 ShoppingItem shoppingItem = shoppingItemPersistence.remove(itemId);
146
147 Indexer indexer = IndexerRegistryUtil.getIndexer(getModelClassName());
148
149 if (indexer != null) {
150 try {
151 indexer.delete(shoppingItem);
152 }
153 catch (SearchException se) {
154 if (_log.isWarnEnabled()) {
155 _log.warn(se, se);
156 }
157 }
158 }
159 }
160
161
167 public void deleteShoppingItem(ShoppingItem shoppingItem)
168 throws SystemException {
169 shoppingItemPersistence.remove(shoppingItem);
170
171 Indexer indexer = IndexerRegistryUtil.getIndexer(getModelClassName());
172
173 if (indexer != null) {
174 try {
175 indexer.delete(shoppingItem);
176 }
177 catch (SearchException se) {
178 if (_log.isWarnEnabled()) {
179 _log.warn(se, se);
180 }
181 }
182 }
183 }
184
185
192 @SuppressWarnings("rawtypes")
193 public List dynamicQuery(DynamicQuery dynamicQuery)
194 throws SystemException {
195 return shoppingItemPersistence.findWithDynamicQuery(dynamicQuery);
196 }
197
198
211 @SuppressWarnings("rawtypes")
212 public List dynamicQuery(DynamicQuery dynamicQuery, int start, int end)
213 throws SystemException {
214 return shoppingItemPersistence.findWithDynamicQuery(dynamicQuery,
215 start, end);
216 }
217
218
232 @SuppressWarnings("rawtypes")
233 public List dynamicQuery(DynamicQuery dynamicQuery, int start, int end,
234 OrderByComparator orderByComparator) throws SystemException {
235 return shoppingItemPersistence.findWithDynamicQuery(dynamicQuery,
236 start, end, orderByComparator);
237 }
238
239
246 public long dynamicQueryCount(DynamicQuery dynamicQuery)
247 throws SystemException {
248 return shoppingItemPersistence.countWithDynamicQuery(dynamicQuery);
249 }
250
251 public ShoppingItem fetchShoppingItem(long itemId)
252 throws SystemException {
253 return shoppingItemPersistence.fetchByPrimaryKey(itemId);
254 }
255
256
264 public ShoppingItem getShoppingItem(long itemId)
265 throws PortalException, SystemException {
266 return shoppingItemPersistence.findByPrimaryKey(itemId);
267 }
268
269 public PersistedModel getPersistedModel(Serializable primaryKeyObj)
270 throws PortalException, SystemException {
271 return shoppingItemPersistence.findByPrimaryKey(primaryKeyObj);
272 }
273
274
286 public List<ShoppingItem> getShoppingItems(int start, int end)
287 throws SystemException {
288 return shoppingItemPersistence.findAll(start, end);
289 }
290
291
297 public int getShoppingItemsCount() throws SystemException {
298 return shoppingItemPersistence.countAll();
299 }
300
301
308 public ShoppingItem updateShoppingItem(ShoppingItem shoppingItem)
309 throws SystemException {
310 return updateShoppingItem(shoppingItem, true);
311 }
312
313
321 public ShoppingItem updateShoppingItem(ShoppingItem shoppingItem,
322 boolean merge) throws SystemException {
323 shoppingItem.setNew(false);
324
325 shoppingItem = shoppingItemPersistence.update(shoppingItem, merge);
326
327 Indexer indexer = IndexerRegistryUtil.getIndexer(getModelClassName());
328
329 if (indexer != null) {
330 try {
331 indexer.reindex(shoppingItem);
332 }
333 catch (SearchException se) {
334 if (_log.isWarnEnabled()) {
335 _log.warn(se, se);
336 }
337 }
338 }
339
340 return shoppingItem;
341 }
342
343
348 public ShoppingCartLocalService getShoppingCartLocalService() {
349 return shoppingCartLocalService;
350 }
351
352
357 public void setShoppingCartLocalService(
358 ShoppingCartLocalService shoppingCartLocalService) {
359 this.shoppingCartLocalService = shoppingCartLocalService;
360 }
361
362
367 public ShoppingCartPersistence getShoppingCartPersistence() {
368 return shoppingCartPersistence;
369 }
370
371
376 public void setShoppingCartPersistence(
377 ShoppingCartPersistence shoppingCartPersistence) {
378 this.shoppingCartPersistence = shoppingCartPersistence;
379 }
380
381
386 public ShoppingCategoryLocalService getShoppingCategoryLocalService() {
387 return shoppingCategoryLocalService;
388 }
389
390
395 public void setShoppingCategoryLocalService(
396 ShoppingCategoryLocalService shoppingCategoryLocalService) {
397 this.shoppingCategoryLocalService = shoppingCategoryLocalService;
398 }
399
400
405 public ShoppingCategoryService getShoppingCategoryService() {
406 return shoppingCategoryService;
407 }
408
409
414 public void setShoppingCategoryService(
415 ShoppingCategoryService shoppingCategoryService) {
416 this.shoppingCategoryService = shoppingCategoryService;
417 }
418
419
424 public ShoppingCategoryPersistence getShoppingCategoryPersistence() {
425 return shoppingCategoryPersistence;
426 }
427
428
433 public void setShoppingCategoryPersistence(
434 ShoppingCategoryPersistence shoppingCategoryPersistence) {
435 this.shoppingCategoryPersistence = shoppingCategoryPersistence;
436 }
437
438
443 public ShoppingCouponLocalService getShoppingCouponLocalService() {
444 return shoppingCouponLocalService;
445 }
446
447
452 public void setShoppingCouponLocalService(
453 ShoppingCouponLocalService shoppingCouponLocalService) {
454 this.shoppingCouponLocalService = shoppingCouponLocalService;
455 }
456
457
462 public ShoppingCouponService getShoppingCouponService() {
463 return shoppingCouponService;
464 }
465
466
471 public void setShoppingCouponService(
472 ShoppingCouponService shoppingCouponService) {
473 this.shoppingCouponService = shoppingCouponService;
474 }
475
476
481 public ShoppingCouponPersistence getShoppingCouponPersistence() {
482 return shoppingCouponPersistence;
483 }
484
485
490 public void setShoppingCouponPersistence(
491 ShoppingCouponPersistence shoppingCouponPersistence) {
492 this.shoppingCouponPersistence = shoppingCouponPersistence;
493 }
494
495
500 public ShoppingCouponFinder getShoppingCouponFinder() {
501 return shoppingCouponFinder;
502 }
503
504
509 public void setShoppingCouponFinder(
510 ShoppingCouponFinder shoppingCouponFinder) {
511 this.shoppingCouponFinder = shoppingCouponFinder;
512 }
513
514
519 public ShoppingItemLocalService getShoppingItemLocalService() {
520 return shoppingItemLocalService;
521 }
522
523
528 public void setShoppingItemLocalService(
529 ShoppingItemLocalService shoppingItemLocalService) {
530 this.shoppingItemLocalService = shoppingItemLocalService;
531 }
532
533
538 public ShoppingItemService getShoppingItemService() {
539 return shoppingItemService;
540 }
541
542
547 public void setShoppingItemService(ShoppingItemService shoppingItemService) {
548 this.shoppingItemService = shoppingItemService;
549 }
550
551
556 public ShoppingItemPersistence getShoppingItemPersistence() {
557 return shoppingItemPersistence;
558 }
559
560
565 public void setShoppingItemPersistence(
566 ShoppingItemPersistence shoppingItemPersistence) {
567 this.shoppingItemPersistence = shoppingItemPersistence;
568 }
569
570
575 public ShoppingItemFinder getShoppingItemFinder() {
576 return shoppingItemFinder;
577 }
578
579
584 public void setShoppingItemFinder(ShoppingItemFinder shoppingItemFinder) {
585 this.shoppingItemFinder = shoppingItemFinder;
586 }
587
588
593 public ShoppingItemFieldLocalService getShoppingItemFieldLocalService() {
594 return shoppingItemFieldLocalService;
595 }
596
597
602 public void setShoppingItemFieldLocalService(
603 ShoppingItemFieldLocalService shoppingItemFieldLocalService) {
604 this.shoppingItemFieldLocalService = shoppingItemFieldLocalService;
605 }
606
607
612 public ShoppingItemFieldPersistence getShoppingItemFieldPersistence() {
613 return shoppingItemFieldPersistence;
614 }
615
616
621 public void setShoppingItemFieldPersistence(
622 ShoppingItemFieldPersistence shoppingItemFieldPersistence) {
623 this.shoppingItemFieldPersistence = shoppingItemFieldPersistence;
624 }
625
626
631 public ShoppingItemPriceLocalService getShoppingItemPriceLocalService() {
632 return shoppingItemPriceLocalService;
633 }
634
635
640 public void setShoppingItemPriceLocalService(
641 ShoppingItemPriceLocalService shoppingItemPriceLocalService) {
642 this.shoppingItemPriceLocalService = shoppingItemPriceLocalService;
643 }
644
645
650 public ShoppingItemPricePersistence getShoppingItemPricePersistence() {
651 return shoppingItemPricePersistence;
652 }
653
654
659 public void setShoppingItemPricePersistence(
660 ShoppingItemPricePersistence shoppingItemPricePersistence) {
661 this.shoppingItemPricePersistence = shoppingItemPricePersistence;
662 }
663
664
669 public ShoppingOrderLocalService getShoppingOrderLocalService() {
670 return shoppingOrderLocalService;
671 }
672
673
678 public void setShoppingOrderLocalService(
679 ShoppingOrderLocalService shoppingOrderLocalService) {
680 this.shoppingOrderLocalService = shoppingOrderLocalService;
681 }
682
683
688 public ShoppingOrderService getShoppingOrderService() {
689 return shoppingOrderService;
690 }
691
692
697 public void setShoppingOrderService(
698 ShoppingOrderService shoppingOrderService) {
699 this.shoppingOrderService = shoppingOrderService;
700 }
701
702
707 public ShoppingOrderPersistence getShoppingOrderPersistence() {
708 return shoppingOrderPersistence;
709 }
710
711
716 public void setShoppingOrderPersistence(
717 ShoppingOrderPersistence shoppingOrderPersistence) {
718 this.shoppingOrderPersistence = shoppingOrderPersistence;
719 }
720
721
726 public ShoppingOrderFinder getShoppingOrderFinder() {
727 return shoppingOrderFinder;
728 }
729
730
735 public void setShoppingOrderFinder(ShoppingOrderFinder shoppingOrderFinder) {
736 this.shoppingOrderFinder = shoppingOrderFinder;
737 }
738
739
744 public ShoppingOrderItemLocalService getShoppingOrderItemLocalService() {
745 return shoppingOrderItemLocalService;
746 }
747
748
753 public void setShoppingOrderItemLocalService(
754 ShoppingOrderItemLocalService shoppingOrderItemLocalService) {
755 this.shoppingOrderItemLocalService = shoppingOrderItemLocalService;
756 }
757
758
763 public ShoppingOrderItemPersistence getShoppingOrderItemPersistence() {
764 return shoppingOrderItemPersistence;
765 }
766
767
772 public void setShoppingOrderItemPersistence(
773 ShoppingOrderItemPersistence shoppingOrderItemPersistence) {
774 this.shoppingOrderItemPersistence = shoppingOrderItemPersistence;
775 }
776
777
782 public CounterLocalService getCounterLocalService() {
783 return counterLocalService;
784 }
785
786
791 public void setCounterLocalService(CounterLocalService counterLocalService) {
792 this.counterLocalService = counterLocalService;
793 }
794
795
800 public ImageLocalService getImageLocalService() {
801 return imageLocalService;
802 }
803
804
809 public void setImageLocalService(ImageLocalService imageLocalService) {
810 this.imageLocalService = imageLocalService;
811 }
812
813
818 public ImageService getImageService() {
819 return imageService;
820 }
821
822
827 public void setImageService(ImageService imageService) {
828 this.imageService = imageService;
829 }
830
831
836 public ImagePersistence getImagePersistence() {
837 return imagePersistence;
838 }
839
840
845 public void setImagePersistence(ImagePersistence imagePersistence) {
846 this.imagePersistence = imagePersistence;
847 }
848
849
854 public ResourceLocalService getResourceLocalService() {
855 return resourceLocalService;
856 }
857
858
863 public void setResourceLocalService(
864 ResourceLocalService resourceLocalService) {
865 this.resourceLocalService = resourceLocalService;
866 }
867
868
873 public ResourceService getResourceService() {
874 return resourceService;
875 }
876
877
882 public void setResourceService(ResourceService resourceService) {
883 this.resourceService = resourceService;
884 }
885
886
891 public ResourcePersistence getResourcePersistence() {
892 return resourcePersistence;
893 }
894
895
900 public void setResourcePersistence(ResourcePersistence resourcePersistence) {
901 this.resourcePersistence = resourcePersistence;
902 }
903
904
909 public ResourceFinder getResourceFinder() {
910 return resourceFinder;
911 }
912
913
918 public void setResourceFinder(ResourceFinder resourceFinder) {
919 this.resourceFinder = resourceFinder;
920 }
921
922
927 public UserLocalService getUserLocalService() {
928 return userLocalService;
929 }
930
931
936 public void setUserLocalService(UserLocalService userLocalService) {
937 this.userLocalService = userLocalService;
938 }
939
940
945 public UserService getUserService() {
946 return userService;
947 }
948
949
954 public void setUserService(UserService userService) {
955 this.userService = userService;
956 }
957
958
963 public UserPersistence getUserPersistence() {
964 return userPersistence;
965 }
966
967
972 public void setUserPersistence(UserPersistence userPersistence) {
973 this.userPersistence = userPersistence;
974 }
975
976
981 public UserFinder getUserFinder() {
982 return userFinder;
983 }
984
985
990 public void setUserFinder(UserFinder userFinder) {
991 this.userFinder = userFinder;
992 }
993
994 public void afterPropertiesSet() {
995 persistedModelLocalServiceRegistry.register("com.liferay.portlet.shopping.model.ShoppingItem",
996 shoppingItemLocalService);
997 }
998
999 public void destroy() {
1000 persistedModelLocalServiceRegistry.unregister(
1001 "com.liferay.portlet.shopping.model.ShoppingItem");
1002 }
1003
1004
1009 public String getBeanIdentifier() {
1010 return _beanIdentifier;
1011 }
1012
1013
1018 public void setBeanIdentifier(String beanIdentifier) {
1019 _beanIdentifier = beanIdentifier;
1020 }
1021
1022 protected ClassLoader getClassLoader() {
1023 Class<?> clazz = getClass();
1024
1025 return clazz.getClassLoader();
1026 }
1027
1028 protected Class<?> getModelClass() {
1029 return ShoppingItem.class;
1030 }
1031
1032 protected String getModelClassName() {
1033 return ShoppingItem.class.getName();
1034 }
1035
1036
1041 protected void runSQL(String sql) throws SystemException {
1042 try {
1043 DataSource dataSource = shoppingItemPersistence.getDataSource();
1044
1045 SqlUpdate sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(dataSource,
1046 sql, new int[0]);
1047
1048 sqlUpdate.update();
1049 }
1050 catch (Exception e) {
1051 throw new SystemException(e);
1052 }
1053 }
1054
1055 @BeanReference(type = ShoppingCartLocalService.class)
1056 protected ShoppingCartLocalService shoppingCartLocalService;
1057 @BeanReference(type = ShoppingCartPersistence.class)
1058 protected ShoppingCartPersistence shoppingCartPersistence;
1059 @BeanReference(type = ShoppingCategoryLocalService.class)
1060 protected ShoppingCategoryLocalService shoppingCategoryLocalService;
1061 @BeanReference(type = ShoppingCategoryService.class)
1062 protected ShoppingCategoryService shoppingCategoryService;
1063 @BeanReference(type = ShoppingCategoryPersistence.class)
1064 protected ShoppingCategoryPersistence shoppingCategoryPersistence;
1065 @BeanReference(type = ShoppingCouponLocalService.class)
1066 protected ShoppingCouponLocalService shoppingCouponLocalService;
1067 @BeanReference(type = ShoppingCouponService.class)
1068 protected ShoppingCouponService shoppingCouponService;
1069 @BeanReference(type = ShoppingCouponPersistence.class)
1070 protected ShoppingCouponPersistence shoppingCouponPersistence;
1071 @BeanReference(type = ShoppingCouponFinder.class)
1072 protected ShoppingCouponFinder shoppingCouponFinder;
1073 @BeanReference(type = ShoppingItemLocalService.class)
1074 protected ShoppingItemLocalService shoppingItemLocalService;
1075 @BeanReference(type = ShoppingItemService.class)
1076 protected ShoppingItemService shoppingItemService;
1077 @BeanReference(type = ShoppingItemPersistence.class)
1078 protected ShoppingItemPersistence shoppingItemPersistence;
1079 @BeanReference(type = ShoppingItemFinder.class)
1080 protected ShoppingItemFinder shoppingItemFinder;
1081 @BeanReference(type = ShoppingItemFieldLocalService.class)
1082 protected ShoppingItemFieldLocalService shoppingItemFieldLocalService;
1083 @BeanReference(type = ShoppingItemFieldPersistence.class)
1084 protected ShoppingItemFieldPersistence shoppingItemFieldPersistence;
1085 @BeanReference(type = ShoppingItemPriceLocalService.class)
1086 protected ShoppingItemPriceLocalService shoppingItemPriceLocalService;
1087 @BeanReference(type = ShoppingItemPricePersistence.class)
1088 protected ShoppingItemPricePersistence shoppingItemPricePersistence;
1089 @BeanReference(type = ShoppingOrderLocalService.class)
1090 protected ShoppingOrderLocalService shoppingOrderLocalService;
1091 @BeanReference(type = ShoppingOrderService.class)
1092 protected ShoppingOrderService shoppingOrderService;
1093 @BeanReference(type = ShoppingOrderPersistence.class)
1094 protected ShoppingOrderPersistence shoppingOrderPersistence;
1095 @BeanReference(type = ShoppingOrderFinder.class)
1096 protected ShoppingOrderFinder shoppingOrderFinder;
1097 @BeanReference(type = ShoppingOrderItemLocalService.class)
1098 protected ShoppingOrderItemLocalService shoppingOrderItemLocalService;
1099 @BeanReference(type = ShoppingOrderItemPersistence.class)
1100 protected ShoppingOrderItemPersistence shoppingOrderItemPersistence;
1101 @BeanReference(type = CounterLocalService.class)
1102 protected CounterLocalService counterLocalService;
1103 @BeanReference(type = ImageLocalService.class)
1104 protected ImageLocalService imageLocalService;
1105 @BeanReference(type = ImageService.class)
1106 protected ImageService imageService;
1107 @BeanReference(type = ImagePersistence.class)
1108 protected ImagePersistence imagePersistence;
1109 @BeanReference(type = ResourceLocalService.class)
1110 protected ResourceLocalService resourceLocalService;
1111 @BeanReference(type = ResourceService.class)
1112 protected ResourceService resourceService;
1113 @BeanReference(type = ResourcePersistence.class)
1114 protected ResourcePersistence resourcePersistence;
1115 @BeanReference(type = ResourceFinder.class)
1116 protected ResourceFinder resourceFinder;
1117 @BeanReference(type = UserLocalService.class)
1118 protected UserLocalService userLocalService;
1119 @BeanReference(type = UserService.class)
1120 protected UserService userService;
1121 @BeanReference(type = UserPersistence.class)
1122 protected UserPersistence userPersistence;
1123 @BeanReference(type = UserFinder.class)
1124 protected UserFinder userFinder;
1125 @BeanReference(type = PersistedModelLocalServiceRegistry.class)
1126 protected PersistedModelLocalServiceRegistry persistedModelLocalServiceRegistry;
1127 private static Log _log = LogFactoryUtil.getLog(ShoppingItemLocalServiceBaseImpl.class);
1128 private String _beanIdentifier;
1129 }