001
014
015 package com.liferay.portal.service.base;
016
017 import aQute.bnd.annotation.ProviderType;
018
019 import com.liferay.portal.kernel.bean.BeanReference;
020 import com.liferay.portal.kernel.bean.IdentifiableBean;
021 import com.liferay.portal.kernel.dao.db.DB;
022 import com.liferay.portal.kernel.dao.db.DBFactoryUtil;
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.ActionableDynamicQuery;
026 import com.liferay.portal.kernel.dao.orm.DefaultActionableDynamicQuery;
027 import com.liferay.portal.kernel.dao.orm.DynamicQuery;
028 import com.liferay.portal.kernel.dao.orm.DynamicQueryFactoryUtil;
029 import com.liferay.portal.kernel.dao.orm.ExportActionableDynamicQuery;
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.search.Indexable;
036 import com.liferay.portal.kernel.search.IndexableType;
037 import com.liferay.portal.kernel.util.OrderByComparator;
038 import com.liferay.portal.model.Address;
039 import com.liferay.portal.model.PersistedModel;
040 import com.liferay.portal.service.AddressLocalService;
041 import com.liferay.portal.service.BaseLocalServiceImpl;
042 import com.liferay.portal.service.PersistedModelLocalServiceRegistry;
043 import com.liferay.portal.service.persistence.AddressPersistence;
044 import com.liferay.portal.service.persistence.ClassNamePersistence;
045 import com.liferay.portal.service.persistence.CountryPersistence;
046 import com.liferay.portal.service.persistence.ListTypePersistence;
047 import com.liferay.portal.service.persistence.UserFinder;
048 import com.liferay.portal.service.persistence.UserPersistence;
049 import com.liferay.portal.util.PortalUtil;
050
051 import com.liferay.portlet.exportimport.lar.ExportImportHelperUtil;
052 import com.liferay.portlet.exportimport.lar.ManifestSummary;
053 import com.liferay.portlet.exportimport.lar.PortletDataContext;
054 import com.liferay.portlet.exportimport.lar.StagedModelDataHandlerUtil;
055 import com.liferay.portlet.exportimport.lar.StagedModelType;
056
057 import java.io.Serializable;
058
059 import java.util.List;
060
061 import javax.sql.DataSource;
062
063
075 @ProviderType
076 public abstract class AddressLocalServiceBaseImpl extends BaseLocalServiceImpl
077 implements AddressLocalService, IdentifiableBean {
078
083
084
090 @Indexable(type = IndexableType.REINDEX)
091 @Override
092 public Address addAddress(Address address) {
093 address.setNew(true);
094
095 return addressPersistence.update(address);
096 }
097
098
104 @Override
105 public Address createAddress(long addressId) {
106 return addressPersistence.create(addressId);
107 }
108
109
116 @Indexable(type = IndexableType.DELETE)
117 @Override
118 public Address deleteAddress(long addressId) throws PortalException {
119 return addressPersistence.remove(addressId);
120 }
121
122
128 @Indexable(type = IndexableType.DELETE)
129 @Override
130 public Address deleteAddress(Address address) {
131 return addressPersistence.remove(address);
132 }
133
134 @Override
135 public DynamicQuery dynamicQuery() {
136 Class<?> clazz = getClass();
137
138 return DynamicQueryFactoryUtil.forClass(Address.class,
139 clazz.getClassLoader());
140 }
141
142
148 @Override
149 public <T> List<T> dynamicQuery(DynamicQuery dynamicQuery) {
150 return addressPersistence.findWithDynamicQuery(dynamicQuery);
151 }
152
153
165 @Override
166 public <T> List<T> dynamicQuery(DynamicQuery dynamicQuery, int start,
167 int end) {
168 return addressPersistence.findWithDynamicQuery(dynamicQuery, start, end);
169 }
170
171
184 @Override
185 public <T> List<T> dynamicQuery(DynamicQuery dynamicQuery, int start,
186 int end, OrderByComparator<T> orderByComparator) {
187 return addressPersistence.findWithDynamicQuery(dynamicQuery, start,
188 end, orderByComparator);
189 }
190
191
197 @Override
198 public long dynamicQueryCount(DynamicQuery dynamicQuery) {
199 return addressPersistence.countWithDynamicQuery(dynamicQuery);
200 }
201
202
209 @Override
210 public long dynamicQueryCount(DynamicQuery dynamicQuery,
211 Projection projection) {
212 return addressPersistence.countWithDynamicQuery(dynamicQuery, projection);
213 }
214
215 @Override
216 public Address fetchAddress(long addressId) {
217 return addressPersistence.fetchByPrimaryKey(addressId);
218 }
219
220
227 @Override
228 public Address fetchAddressByUuidAndCompanyId(String uuid, long companyId) {
229 return addressPersistence.fetchByUuid_C_First(uuid, companyId, null);
230 }
231
232
239 @Override
240 public Address getAddress(long addressId) throws PortalException {
241 return addressPersistence.findByPrimaryKey(addressId);
242 }
243
244 @Override
245 public ActionableDynamicQuery getActionableDynamicQuery() {
246 ActionableDynamicQuery actionableDynamicQuery = new DefaultActionableDynamicQuery();
247
248 actionableDynamicQuery.setBaseLocalService(com.liferay.portal.service.AddressLocalServiceUtil.getService());
249 actionableDynamicQuery.setClass(Address.class);
250 actionableDynamicQuery.setClassLoader(getClassLoader());
251
252 actionableDynamicQuery.setPrimaryKeyPropertyName("addressId");
253
254 return actionableDynamicQuery;
255 }
256
257 protected void initActionableDynamicQuery(
258 ActionableDynamicQuery actionableDynamicQuery) {
259 actionableDynamicQuery.setBaseLocalService(com.liferay.portal.service.AddressLocalServiceUtil.getService());
260 actionableDynamicQuery.setClass(Address.class);
261 actionableDynamicQuery.setClassLoader(getClassLoader());
262
263 actionableDynamicQuery.setPrimaryKeyPropertyName("addressId");
264 }
265
266 @Override
267 public ExportActionableDynamicQuery getExportActionableDynamicQuery(
268 final PortletDataContext portletDataContext) {
269 final ExportActionableDynamicQuery exportActionableDynamicQuery = new ExportActionableDynamicQuery() {
270 @Override
271 public long performCount() throws PortalException {
272 ManifestSummary manifestSummary = portletDataContext.getManifestSummary();
273
274 StagedModelType stagedModelType = getStagedModelType();
275
276 long modelAdditionCount = super.performCount();
277
278 manifestSummary.addModelAdditionCount(stagedModelType,
279 modelAdditionCount);
280
281 long modelDeletionCount = ExportImportHelperUtil.getModelDeletionCount(portletDataContext,
282 stagedModelType);
283
284 manifestSummary.addModelDeletionCount(stagedModelType,
285 modelDeletionCount);
286
287 return modelAdditionCount;
288 }
289 };
290
291 initActionableDynamicQuery(exportActionableDynamicQuery);
292
293 exportActionableDynamicQuery.setAddCriteriaMethod(new ActionableDynamicQuery.AddCriteriaMethod() {
294 @Override
295 public void addCriteria(DynamicQuery dynamicQuery) {
296 portletDataContext.addDateRangeCriteria(dynamicQuery,
297 "modifiedDate");
298
299 StagedModelType stagedModelType = exportActionableDynamicQuery.getStagedModelType();
300
301 long referrerClassNameId = stagedModelType.getReferrerClassNameId();
302
303 Property classNameIdProperty = PropertyFactoryUtil.forName(
304 "classNameId");
305
306 if ((referrerClassNameId != StagedModelType.REFERRER_CLASS_NAME_ID_ALL) &&
307 (referrerClassNameId != StagedModelType.REFERRER_CLASS_NAME_ID_ANY)) {
308 dynamicQuery.add(classNameIdProperty.eq(
309 stagedModelType.getReferrerClassNameId()));
310 }
311 else if (referrerClassNameId == StagedModelType.REFERRER_CLASS_NAME_ID_ANY) {
312 dynamicQuery.add(classNameIdProperty.isNotNull());
313 }
314 }
315 });
316
317 exportActionableDynamicQuery.setCompanyId(portletDataContext.getCompanyId());
318
319 exportActionableDynamicQuery.setPerformActionMethod(new ActionableDynamicQuery.PerformActionMethod<Address>() {
320 @Override
321 public void performAction(Address address)
322 throws PortalException {
323 StagedModelDataHandlerUtil.exportStagedModel(portletDataContext,
324 address);
325 }
326 });
327 exportActionableDynamicQuery.setStagedModelType(new StagedModelType(
328 PortalUtil.getClassNameId(Address.class.getName()),
329 StagedModelType.REFERRER_CLASS_NAME_ID_ALL));
330
331 return exportActionableDynamicQuery;
332 }
333
334
337 @Override
338 public PersistedModel deletePersistedModel(PersistedModel persistedModel)
339 throws PortalException {
340 return addressLocalService.deleteAddress((Address)persistedModel);
341 }
342
343 @Override
344 public PersistedModel getPersistedModel(Serializable primaryKeyObj)
345 throws PortalException {
346 return addressPersistence.findByPrimaryKey(primaryKeyObj);
347 }
348
349
357 @Override
358 public Address getAddressByUuidAndCompanyId(String uuid, long companyId)
359 throws PortalException {
360 return addressPersistence.findByUuid_C_First(uuid, companyId, null);
361 }
362
363
374 @Override
375 public List<Address> getAddresses(int start, int end) {
376 return addressPersistence.findAll(start, end);
377 }
378
379
384 @Override
385 public int getAddressesCount() {
386 return addressPersistence.countAll();
387 }
388
389
395 @Indexable(type = IndexableType.REINDEX)
396 @Override
397 public Address updateAddress(Address address) {
398 return addressPersistence.update(address);
399 }
400
401
406 public AddressLocalService getAddressLocalService() {
407 return addressLocalService;
408 }
409
410
415 public void setAddressLocalService(AddressLocalService addressLocalService) {
416 this.addressLocalService = addressLocalService;
417 }
418
419
424 public com.liferay.portal.service.AddressService getAddressService() {
425 return addressService;
426 }
427
428
433 public void setAddressService(
434 com.liferay.portal.service.AddressService addressService) {
435 this.addressService = addressService;
436 }
437
438
443 public AddressPersistence getAddressPersistence() {
444 return addressPersistence;
445 }
446
447
452 public void setAddressPersistence(AddressPersistence addressPersistence) {
453 this.addressPersistence = addressPersistence;
454 }
455
456
461 public com.liferay.counter.service.CounterLocalService getCounterLocalService() {
462 return counterLocalService;
463 }
464
465
470 public void setCounterLocalService(
471 com.liferay.counter.service.CounterLocalService counterLocalService) {
472 this.counterLocalService = counterLocalService;
473 }
474
475
480 public com.liferay.portal.service.ClassNameLocalService getClassNameLocalService() {
481 return classNameLocalService;
482 }
483
484
489 public void setClassNameLocalService(
490 com.liferay.portal.service.ClassNameLocalService classNameLocalService) {
491 this.classNameLocalService = classNameLocalService;
492 }
493
494
499 public com.liferay.portal.service.ClassNameService getClassNameService() {
500 return classNameService;
501 }
502
503
508 public void setClassNameService(
509 com.liferay.portal.service.ClassNameService classNameService) {
510 this.classNameService = classNameService;
511 }
512
513
518 public ClassNamePersistence getClassNamePersistence() {
519 return classNamePersistence;
520 }
521
522
527 public void setClassNamePersistence(
528 ClassNamePersistence classNamePersistence) {
529 this.classNamePersistence = classNamePersistence;
530 }
531
532
537 public com.liferay.portal.service.CountryService getCountryService() {
538 return countryService;
539 }
540
541
546 public void setCountryService(
547 com.liferay.portal.service.CountryService countryService) {
548 this.countryService = countryService;
549 }
550
551
556 public CountryPersistence getCountryPersistence() {
557 return countryPersistence;
558 }
559
560
565 public void setCountryPersistence(CountryPersistence countryPersistence) {
566 this.countryPersistence = countryPersistence;
567 }
568
569
574 public com.liferay.portal.service.ListTypeLocalService getListTypeLocalService() {
575 return listTypeLocalService;
576 }
577
578
583 public void setListTypeLocalService(
584 com.liferay.portal.service.ListTypeLocalService listTypeLocalService) {
585 this.listTypeLocalService = listTypeLocalService;
586 }
587
588
593 public com.liferay.portal.service.ListTypeService getListTypeService() {
594 return listTypeService;
595 }
596
597
602 public void setListTypeService(
603 com.liferay.portal.service.ListTypeService listTypeService) {
604 this.listTypeService = listTypeService;
605 }
606
607
612 public ListTypePersistence getListTypePersistence() {
613 return listTypePersistence;
614 }
615
616
621 public void setListTypePersistence(ListTypePersistence listTypePersistence) {
622 this.listTypePersistence = listTypePersistence;
623 }
624
625
630 public com.liferay.portal.service.UserLocalService getUserLocalService() {
631 return userLocalService;
632 }
633
634
639 public void setUserLocalService(
640 com.liferay.portal.service.UserLocalService userLocalService) {
641 this.userLocalService = userLocalService;
642 }
643
644
649 public com.liferay.portal.service.UserService getUserService() {
650 return userService;
651 }
652
653
658 public void setUserService(
659 com.liferay.portal.service.UserService userService) {
660 this.userService = userService;
661 }
662
663
668 public UserPersistence getUserPersistence() {
669 return userPersistence;
670 }
671
672
677 public void setUserPersistence(UserPersistence userPersistence) {
678 this.userPersistence = userPersistence;
679 }
680
681
686 public UserFinder getUserFinder() {
687 return userFinder;
688 }
689
690
695 public void setUserFinder(UserFinder userFinder) {
696 this.userFinder = userFinder;
697 }
698
699 public void afterPropertiesSet() {
700 persistedModelLocalServiceRegistry.register("com.liferay.portal.model.Address",
701 addressLocalService);
702 }
703
704 public void destroy() {
705 persistedModelLocalServiceRegistry.unregister(
706 "com.liferay.portal.model.Address");
707 }
708
709
714 @Override
715 public String getBeanIdentifier() {
716 return _beanIdentifier;
717 }
718
719
724 @Override
725 public void setBeanIdentifier(String beanIdentifier) {
726 _beanIdentifier = beanIdentifier;
727 }
728
729 protected Class<?> getModelClass() {
730 return Address.class;
731 }
732
733 protected String getModelClassName() {
734 return Address.class.getName();
735 }
736
737
742 protected void runSQL(String sql) {
743 try {
744 DataSource dataSource = addressPersistence.getDataSource();
745
746 DB db = DBFactoryUtil.getDB();
747
748 sql = db.buildSQL(sql);
749 sql = PortalUtil.transformSQL(sql);
750
751 SqlUpdate sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(dataSource,
752 sql, new int[0]);
753
754 sqlUpdate.update();
755 }
756 catch (Exception e) {
757 throw new SystemException(e);
758 }
759 }
760
761 @BeanReference(type = com.liferay.portal.service.AddressLocalService.class)
762 protected AddressLocalService addressLocalService;
763 @BeanReference(type = com.liferay.portal.service.AddressService.class)
764 protected com.liferay.portal.service.AddressService addressService;
765 @BeanReference(type = AddressPersistence.class)
766 protected AddressPersistence addressPersistence;
767 @BeanReference(type = com.liferay.counter.service.CounterLocalService.class)
768 protected com.liferay.counter.service.CounterLocalService counterLocalService;
769 @BeanReference(type = com.liferay.portal.service.ClassNameLocalService.class)
770 protected com.liferay.portal.service.ClassNameLocalService classNameLocalService;
771 @BeanReference(type = com.liferay.portal.service.ClassNameService.class)
772 protected com.liferay.portal.service.ClassNameService classNameService;
773 @BeanReference(type = ClassNamePersistence.class)
774 protected ClassNamePersistence classNamePersistence;
775 @BeanReference(type = com.liferay.portal.service.CountryService.class)
776 protected com.liferay.portal.service.CountryService countryService;
777 @BeanReference(type = CountryPersistence.class)
778 protected CountryPersistence countryPersistence;
779 @BeanReference(type = com.liferay.portal.service.ListTypeLocalService.class)
780 protected com.liferay.portal.service.ListTypeLocalService listTypeLocalService;
781 @BeanReference(type = com.liferay.portal.service.ListTypeService.class)
782 protected com.liferay.portal.service.ListTypeService listTypeService;
783 @BeanReference(type = ListTypePersistence.class)
784 protected ListTypePersistence listTypePersistence;
785 @BeanReference(type = com.liferay.portal.service.UserLocalService.class)
786 protected com.liferay.portal.service.UserLocalService userLocalService;
787 @BeanReference(type = com.liferay.portal.service.UserService.class)
788 protected com.liferay.portal.service.UserService userService;
789 @BeanReference(type = UserPersistence.class)
790 protected UserPersistence userPersistence;
791 @BeanReference(type = UserFinder.class)
792 protected UserFinder userFinder;
793 @BeanReference(type = PersistedModelLocalServiceRegistry.class)
794 protected PersistedModelLocalServiceRegistry persistedModelLocalServiceRegistry;
795 private String _beanIdentifier;
796 }