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.toString(),
279 modelAdditionCount);
280
281 long modelDeletionCount = ExportImportHelperUtil.getModelDeletionCount(portletDataContext,
282 stagedModelType);
283
284 manifestSummary.addModelDeletionCount(stagedModelType.toString(),
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 if (stagedModelType.getReferrerClassNameId() >= 0) {
302 Property classNameIdProperty = PropertyFactoryUtil.forName(
303 "classNameId");
304
305 dynamicQuery.add(classNameIdProperty.eq(
306 stagedModelType.getReferrerClassNameId()));
307 }
308 }
309 });
310
311 exportActionableDynamicQuery.setCompanyId(portletDataContext.getCompanyId());
312
313 exportActionableDynamicQuery.setPerformActionMethod(new ActionableDynamicQuery.PerformActionMethod() {
314 @Override
315 public void performAction(Object object)
316 throws PortalException {
317 Address stagedModel = (Address)object;
318
319 StagedModelDataHandlerUtil.exportStagedModel(portletDataContext,
320 stagedModel);
321 }
322 });
323 exportActionableDynamicQuery.setStagedModelType(new StagedModelType(
324 PortalUtil.getClassNameId(Address.class.getName())));
325
326 return exportActionableDynamicQuery;
327 }
328
329
332 @Override
333 public PersistedModel deletePersistedModel(PersistedModel persistedModel)
334 throws PortalException {
335 return addressLocalService.deleteAddress((Address)persistedModel);
336 }
337
338 @Override
339 public PersistedModel getPersistedModel(Serializable primaryKeyObj)
340 throws PortalException {
341 return addressPersistence.findByPrimaryKey(primaryKeyObj);
342 }
343
344
352 @Override
353 public Address getAddressByUuidAndCompanyId(String uuid, long companyId)
354 throws PortalException {
355 return addressPersistence.findByUuid_C_First(uuid, companyId, null);
356 }
357
358
369 @Override
370 public List<Address> getAddresses(int start, int end) {
371 return addressPersistence.findAll(start, end);
372 }
373
374
379 @Override
380 public int getAddressesCount() {
381 return addressPersistence.countAll();
382 }
383
384
390 @Indexable(type = IndexableType.REINDEX)
391 @Override
392 public Address updateAddress(Address address) {
393 return addressPersistence.update(address);
394 }
395
396
401 public AddressLocalService getAddressLocalService() {
402 return addressLocalService;
403 }
404
405
410 public void setAddressLocalService(AddressLocalService addressLocalService) {
411 this.addressLocalService = addressLocalService;
412 }
413
414
419 public com.liferay.portal.service.AddressService getAddressService() {
420 return addressService;
421 }
422
423
428 public void setAddressService(
429 com.liferay.portal.service.AddressService addressService) {
430 this.addressService = addressService;
431 }
432
433
438 public AddressPersistence getAddressPersistence() {
439 return addressPersistence;
440 }
441
442
447 public void setAddressPersistence(AddressPersistence addressPersistence) {
448 this.addressPersistence = addressPersistence;
449 }
450
451
456 public com.liferay.counter.service.CounterLocalService getCounterLocalService() {
457 return counterLocalService;
458 }
459
460
465 public void setCounterLocalService(
466 com.liferay.counter.service.CounterLocalService counterLocalService) {
467 this.counterLocalService = counterLocalService;
468 }
469
470
475 public com.liferay.portal.service.ClassNameLocalService getClassNameLocalService() {
476 return classNameLocalService;
477 }
478
479
484 public void setClassNameLocalService(
485 com.liferay.portal.service.ClassNameLocalService classNameLocalService) {
486 this.classNameLocalService = classNameLocalService;
487 }
488
489
494 public com.liferay.portal.service.ClassNameService getClassNameService() {
495 return classNameService;
496 }
497
498
503 public void setClassNameService(
504 com.liferay.portal.service.ClassNameService classNameService) {
505 this.classNameService = classNameService;
506 }
507
508
513 public ClassNamePersistence getClassNamePersistence() {
514 return classNamePersistence;
515 }
516
517
522 public void setClassNamePersistence(
523 ClassNamePersistence classNamePersistence) {
524 this.classNamePersistence = classNamePersistence;
525 }
526
527
532 public com.liferay.portal.service.CountryService getCountryService() {
533 return countryService;
534 }
535
536
541 public void setCountryService(
542 com.liferay.portal.service.CountryService countryService) {
543 this.countryService = countryService;
544 }
545
546
551 public CountryPersistence getCountryPersistence() {
552 return countryPersistence;
553 }
554
555
560 public void setCountryPersistence(CountryPersistence countryPersistence) {
561 this.countryPersistence = countryPersistence;
562 }
563
564
569 public com.liferay.portal.service.ListTypeLocalService getListTypeLocalService() {
570 return listTypeLocalService;
571 }
572
573
578 public void setListTypeLocalService(
579 com.liferay.portal.service.ListTypeLocalService listTypeLocalService) {
580 this.listTypeLocalService = listTypeLocalService;
581 }
582
583
588 public com.liferay.portal.service.ListTypeService getListTypeService() {
589 return listTypeService;
590 }
591
592
597 public void setListTypeService(
598 com.liferay.portal.service.ListTypeService listTypeService) {
599 this.listTypeService = listTypeService;
600 }
601
602
607 public ListTypePersistence getListTypePersistence() {
608 return listTypePersistence;
609 }
610
611
616 public void setListTypePersistence(ListTypePersistence listTypePersistence) {
617 this.listTypePersistence = listTypePersistence;
618 }
619
620
625 public com.liferay.portal.service.UserLocalService getUserLocalService() {
626 return userLocalService;
627 }
628
629
634 public void setUserLocalService(
635 com.liferay.portal.service.UserLocalService userLocalService) {
636 this.userLocalService = userLocalService;
637 }
638
639
644 public com.liferay.portal.service.UserService getUserService() {
645 return userService;
646 }
647
648
653 public void setUserService(
654 com.liferay.portal.service.UserService userService) {
655 this.userService = userService;
656 }
657
658
663 public UserPersistence getUserPersistence() {
664 return userPersistence;
665 }
666
667
672 public void setUserPersistence(UserPersistence userPersistence) {
673 this.userPersistence = userPersistence;
674 }
675
676
681 public UserFinder getUserFinder() {
682 return userFinder;
683 }
684
685
690 public void setUserFinder(UserFinder userFinder) {
691 this.userFinder = userFinder;
692 }
693
694 public void afterPropertiesSet() {
695 persistedModelLocalServiceRegistry.register("com.liferay.portal.model.Address",
696 addressLocalService);
697 }
698
699 public void destroy() {
700 persistedModelLocalServiceRegistry.unregister(
701 "com.liferay.portal.model.Address");
702 }
703
704
709 @Override
710 public String getBeanIdentifier() {
711 return _beanIdentifier;
712 }
713
714
719 @Override
720 public void setBeanIdentifier(String beanIdentifier) {
721 _beanIdentifier = beanIdentifier;
722 }
723
724 protected Class<?> getModelClass() {
725 return Address.class;
726 }
727
728 protected String getModelClassName() {
729 return Address.class.getName();
730 }
731
732
737 protected void runSQL(String sql) {
738 try {
739 DataSource dataSource = addressPersistence.getDataSource();
740
741 DB db = DBFactoryUtil.getDB();
742
743 sql = db.buildSQL(sql);
744 sql = PortalUtil.transformSQL(sql);
745
746 SqlUpdate sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(dataSource,
747 sql, new int[0]);
748
749 sqlUpdate.update();
750 }
751 catch (Exception e) {
752 throw new SystemException(e);
753 }
754 }
755
756 @BeanReference(type = AddressLocalService.class)
757 protected AddressLocalService addressLocalService;
758 @BeanReference(type = com.liferay.portal.service.AddressService.class)
759 protected com.liferay.portal.service.AddressService addressService;
760 @BeanReference(type = AddressPersistence.class)
761 protected AddressPersistence addressPersistence;
762 @BeanReference(type = com.liferay.counter.service.CounterLocalService.class)
763 protected com.liferay.counter.service.CounterLocalService counterLocalService;
764 @BeanReference(type = com.liferay.portal.service.ClassNameLocalService.class)
765 protected com.liferay.portal.service.ClassNameLocalService classNameLocalService;
766 @BeanReference(type = com.liferay.portal.service.ClassNameService.class)
767 protected com.liferay.portal.service.ClassNameService classNameService;
768 @BeanReference(type = ClassNamePersistence.class)
769 protected ClassNamePersistence classNamePersistence;
770 @BeanReference(type = com.liferay.portal.service.CountryService.class)
771 protected com.liferay.portal.service.CountryService countryService;
772 @BeanReference(type = CountryPersistence.class)
773 protected CountryPersistence countryPersistence;
774 @BeanReference(type = com.liferay.portal.service.ListTypeLocalService.class)
775 protected com.liferay.portal.service.ListTypeLocalService listTypeLocalService;
776 @BeanReference(type = com.liferay.portal.service.ListTypeService.class)
777 protected com.liferay.portal.service.ListTypeService listTypeService;
778 @BeanReference(type = ListTypePersistence.class)
779 protected ListTypePersistence listTypePersistence;
780 @BeanReference(type = com.liferay.portal.service.UserLocalService.class)
781 protected com.liferay.portal.service.UserLocalService userLocalService;
782 @BeanReference(type = com.liferay.portal.service.UserService.class)
783 protected com.liferay.portal.service.UserService userService;
784 @BeanReference(type = UserPersistence.class)
785 protected UserPersistence userPersistence;
786 @BeanReference(type = UserFinder.class)
787 protected UserFinder userFinder;
788 @BeanReference(type = PersistedModelLocalServiceRegistry.class)
789 protected PersistedModelLocalServiceRegistry persistedModelLocalServiceRegistry;
790 private String _beanIdentifier;
791 }