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.dao.db.DB;
021 import com.liferay.portal.kernel.dao.db.DBFactoryUtil;
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.Projection;
030 import com.liferay.portal.kernel.dao.orm.Property;
031 import com.liferay.portal.kernel.dao.orm.PropertyFactoryUtil;
032 import com.liferay.portal.kernel.exception.PortalException;
033 import com.liferay.portal.kernel.exception.SystemException;
034 import com.liferay.portal.kernel.module.framework.service.IdentifiableOSGiService;
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.PersistedModel;
039 import com.liferay.portal.model.Phone;
040 import com.liferay.portal.service.BaseLocalServiceImpl;
041 import com.liferay.portal.service.PersistedModelLocalServiceRegistry;
042 import com.liferay.portal.service.PhoneLocalService;
043 import com.liferay.portal.service.persistence.ClassNamePersistence;
044 import com.liferay.portal.service.persistence.ListTypePersistence;
045 import com.liferay.portal.service.persistence.PhonePersistence;
046 import com.liferay.portal.service.persistence.UserFinder;
047 import com.liferay.portal.service.persistence.UserPersistence;
048 import com.liferay.portal.util.PortalUtil;
049
050 import com.liferay.portlet.exportimport.lar.ExportImportHelperUtil;
051 import com.liferay.portlet.exportimport.lar.ManifestSummary;
052 import com.liferay.portlet.exportimport.lar.PortletDataContext;
053 import com.liferay.portlet.exportimport.lar.StagedModelDataHandlerUtil;
054 import com.liferay.portlet.exportimport.lar.StagedModelType;
055
056 import java.io.Serializable;
057
058 import java.util.List;
059
060 import javax.sql.DataSource;
061
062
074 @ProviderType
075 public abstract class PhoneLocalServiceBaseImpl extends BaseLocalServiceImpl
076 implements PhoneLocalService, IdentifiableOSGiService {
077
082
083
089 @Indexable(type = IndexableType.REINDEX)
090 @Override
091 public Phone addPhone(Phone phone) {
092 phone.setNew(true);
093
094 return phonePersistence.update(phone);
095 }
096
097
103 @Override
104 public Phone createPhone(long phoneId) {
105 return phonePersistence.create(phoneId);
106 }
107
108
115 @Indexable(type = IndexableType.DELETE)
116 @Override
117 public Phone deletePhone(long phoneId) throws PortalException {
118 return phonePersistence.remove(phoneId);
119 }
120
121
127 @Indexable(type = IndexableType.DELETE)
128 @Override
129 public Phone deletePhone(Phone phone) {
130 return phonePersistence.remove(phone);
131 }
132
133 @Override
134 public DynamicQuery dynamicQuery() {
135 Class<?> clazz = getClass();
136
137 return DynamicQueryFactoryUtil.forClass(Phone.class,
138 clazz.getClassLoader());
139 }
140
141
147 @Override
148 public <T> List<T> dynamicQuery(DynamicQuery dynamicQuery) {
149 return phonePersistence.findWithDynamicQuery(dynamicQuery);
150 }
151
152
164 @Override
165 public <T> List<T> dynamicQuery(DynamicQuery dynamicQuery, int start,
166 int end) {
167 return phonePersistence.findWithDynamicQuery(dynamicQuery, start, end);
168 }
169
170
183 @Override
184 public <T> List<T> dynamicQuery(DynamicQuery dynamicQuery, int start,
185 int end, OrderByComparator<T> orderByComparator) {
186 return phonePersistence.findWithDynamicQuery(dynamicQuery, start, end,
187 orderByComparator);
188 }
189
190
196 @Override
197 public long dynamicQueryCount(DynamicQuery dynamicQuery) {
198 return phonePersistence.countWithDynamicQuery(dynamicQuery);
199 }
200
201
208 @Override
209 public long dynamicQueryCount(DynamicQuery dynamicQuery,
210 Projection projection) {
211 return phonePersistence.countWithDynamicQuery(dynamicQuery, projection);
212 }
213
214 @Override
215 public Phone fetchPhone(long phoneId) {
216 return phonePersistence.fetchByPrimaryKey(phoneId);
217 }
218
219
226 @Override
227 public Phone fetchPhoneByUuidAndCompanyId(String uuid, long companyId) {
228 return phonePersistence.fetchByUuid_C_First(uuid, companyId, null);
229 }
230
231
238 @Override
239 public Phone getPhone(long phoneId) throws PortalException {
240 return phonePersistence.findByPrimaryKey(phoneId);
241 }
242
243 @Override
244 public ActionableDynamicQuery getActionableDynamicQuery() {
245 ActionableDynamicQuery actionableDynamicQuery = new DefaultActionableDynamicQuery();
246
247 actionableDynamicQuery.setBaseLocalService(com.liferay.portal.service.PhoneLocalServiceUtil.getService());
248 actionableDynamicQuery.setClass(Phone.class);
249 actionableDynamicQuery.setClassLoader(getClassLoader());
250
251 actionableDynamicQuery.setPrimaryKeyPropertyName("phoneId");
252
253 return actionableDynamicQuery;
254 }
255
256 protected void initActionableDynamicQuery(
257 ActionableDynamicQuery actionableDynamicQuery) {
258 actionableDynamicQuery.setBaseLocalService(com.liferay.portal.service.PhoneLocalServiceUtil.getService());
259 actionableDynamicQuery.setClass(Phone.class);
260 actionableDynamicQuery.setClassLoader(getClassLoader());
261
262 actionableDynamicQuery.setPrimaryKeyPropertyName("phoneId");
263 }
264
265 @Override
266 public ExportActionableDynamicQuery getExportActionableDynamicQuery(
267 final PortletDataContext portletDataContext) {
268 final ExportActionableDynamicQuery exportActionableDynamicQuery = new ExportActionableDynamicQuery() {
269 @Override
270 public long performCount() throws PortalException {
271 ManifestSummary manifestSummary = portletDataContext.getManifestSummary();
272
273 StagedModelType stagedModelType = getStagedModelType();
274
275 long modelAdditionCount = super.performCount();
276
277 manifestSummary.addModelAdditionCount(stagedModelType,
278 modelAdditionCount);
279
280 long modelDeletionCount = ExportImportHelperUtil.getModelDeletionCount(portletDataContext,
281 stagedModelType);
282
283 manifestSummary.addModelDeletionCount(stagedModelType,
284 modelDeletionCount);
285
286 return modelAdditionCount;
287 }
288 };
289
290 initActionableDynamicQuery(exportActionableDynamicQuery);
291
292 exportActionableDynamicQuery.setAddCriteriaMethod(new ActionableDynamicQuery.AddCriteriaMethod() {
293 @Override
294 public void addCriteria(DynamicQuery dynamicQuery) {
295 portletDataContext.addDateRangeCriteria(dynamicQuery,
296 "modifiedDate");
297
298 StagedModelType stagedModelType = exportActionableDynamicQuery.getStagedModelType();
299
300 long referrerClassNameId = stagedModelType.getReferrerClassNameId();
301
302 Property classNameIdProperty = PropertyFactoryUtil.forName(
303 "classNameId");
304
305 if ((referrerClassNameId != StagedModelType.REFERRER_CLASS_NAME_ID_ALL) &&
306 (referrerClassNameId != StagedModelType.REFERRER_CLASS_NAME_ID_ANY)) {
307 dynamicQuery.add(classNameIdProperty.eq(
308 stagedModelType.getReferrerClassNameId()));
309 }
310 else if (referrerClassNameId == StagedModelType.REFERRER_CLASS_NAME_ID_ANY) {
311 dynamicQuery.add(classNameIdProperty.isNotNull());
312 }
313 }
314 });
315
316 exportActionableDynamicQuery.setCompanyId(portletDataContext.getCompanyId());
317
318 exportActionableDynamicQuery.setPerformActionMethod(new ActionableDynamicQuery.PerformActionMethod<Phone>() {
319 @Override
320 public void performAction(Phone phone)
321 throws PortalException {
322 StagedModelDataHandlerUtil.exportStagedModel(portletDataContext,
323 phone);
324 }
325 });
326 exportActionableDynamicQuery.setStagedModelType(new StagedModelType(
327 PortalUtil.getClassNameId(Phone.class.getName()),
328 StagedModelType.REFERRER_CLASS_NAME_ID_ALL));
329
330 return exportActionableDynamicQuery;
331 }
332
333
336 @Override
337 public PersistedModel deletePersistedModel(PersistedModel persistedModel)
338 throws PortalException {
339 return phoneLocalService.deletePhone((Phone)persistedModel);
340 }
341
342 @Override
343 public PersistedModel getPersistedModel(Serializable primaryKeyObj)
344 throws PortalException {
345 return phonePersistence.findByPrimaryKey(primaryKeyObj);
346 }
347
348
356 @Override
357 public Phone getPhoneByUuidAndCompanyId(String uuid, long companyId)
358 throws PortalException {
359 return phonePersistence.findByUuid_C_First(uuid, companyId, null);
360 }
361
362
373 @Override
374 public List<Phone> getPhones(int start, int end) {
375 return phonePersistence.findAll(start, end);
376 }
377
378
383 @Override
384 public int getPhonesCount() {
385 return phonePersistence.countAll();
386 }
387
388
394 @Indexable(type = IndexableType.REINDEX)
395 @Override
396 public Phone updatePhone(Phone phone) {
397 return phonePersistence.update(phone);
398 }
399
400
405 public PhoneLocalService getPhoneLocalService() {
406 return phoneLocalService;
407 }
408
409
414 public void setPhoneLocalService(PhoneLocalService phoneLocalService) {
415 this.phoneLocalService = phoneLocalService;
416 }
417
418
423 public com.liferay.portal.service.PhoneService getPhoneService() {
424 return phoneService;
425 }
426
427
432 public void setPhoneService(
433 com.liferay.portal.service.PhoneService phoneService) {
434 this.phoneService = phoneService;
435 }
436
437
442 public PhonePersistence getPhonePersistence() {
443 return phonePersistence;
444 }
445
446
451 public void setPhonePersistence(PhonePersistence phonePersistence) {
452 this.phonePersistence = phonePersistence;
453 }
454
455
460 public com.liferay.counter.service.CounterLocalService getCounterLocalService() {
461 return counterLocalService;
462 }
463
464
469 public void setCounterLocalService(
470 com.liferay.counter.service.CounterLocalService counterLocalService) {
471 this.counterLocalService = counterLocalService;
472 }
473
474
479 public com.liferay.portal.service.ClassNameLocalService getClassNameLocalService() {
480 return classNameLocalService;
481 }
482
483
488 public void setClassNameLocalService(
489 com.liferay.portal.service.ClassNameLocalService classNameLocalService) {
490 this.classNameLocalService = classNameLocalService;
491 }
492
493
498 public com.liferay.portal.service.ClassNameService getClassNameService() {
499 return classNameService;
500 }
501
502
507 public void setClassNameService(
508 com.liferay.portal.service.ClassNameService classNameService) {
509 this.classNameService = classNameService;
510 }
511
512
517 public ClassNamePersistence getClassNamePersistence() {
518 return classNamePersistence;
519 }
520
521
526 public void setClassNamePersistence(
527 ClassNamePersistence classNamePersistence) {
528 this.classNamePersistence = classNamePersistence;
529 }
530
531
536 public com.liferay.portal.service.ListTypeLocalService getListTypeLocalService() {
537 return listTypeLocalService;
538 }
539
540
545 public void setListTypeLocalService(
546 com.liferay.portal.service.ListTypeLocalService listTypeLocalService) {
547 this.listTypeLocalService = listTypeLocalService;
548 }
549
550
555 public com.liferay.portal.service.ListTypeService getListTypeService() {
556 return listTypeService;
557 }
558
559
564 public void setListTypeService(
565 com.liferay.portal.service.ListTypeService listTypeService) {
566 this.listTypeService = listTypeService;
567 }
568
569
574 public ListTypePersistence getListTypePersistence() {
575 return listTypePersistence;
576 }
577
578
583 public void setListTypePersistence(ListTypePersistence listTypePersistence) {
584 this.listTypePersistence = listTypePersistence;
585 }
586
587
592 public com.liferay.portal.service.UserLocalService getUserLocalService() {
593 return userLocalService;
594 }
595
596
601 public void setUserLocalService(
602 com.liferay.portal.service.UserLocalService userLocalService) {
603 this.userLocalService = userLocalService;
604 }
605
606
611 public com.liferay.portal.service.UserService getUserService() {
612 return userService;
613 }
614
615
620 public void setUserService(
621 com.liferay.portal.service.UserService userService) {
622 this.userService = userService;
623 }
624
625
630 public UserPersistence getUserPersistence() {
631 return userPersistence;
632 }
633
634
639 public void setUserPersistence(UserPersistence userPersistence) {
640 this.userPersistence = userPersistence;
641 }
642
643
648 public UserFinder getUserFinder() {
649 return userFinder;
650 }
651
652
657 public void setUserFinder(UserFinder userFinder) {
658 this.userFinder = userFinder;
659 }
660
661 public void afterPropertiesSet() {
662 persistedModelLocalServiceRegistry.register("com.liferay.portal.model.Phone",
663 phoneLocalService);
664 }
665
666 public void destroy() {
667 persistedModelLocalServiceRegistry.unregister(
668 "com.liferay.portal.model.Phone");
669 }
670
671
676 @Override
677 public String getOSGiServiceIdentifier() {
678 return PhoneLocalService.class.getName();
679 }
680
681 protected Class<?> getModelClass() {
682 return Phone.class;
683 }
684
685 protected String getModelClassName() {
686 return Phone.class.getName();
687 }
688
689
694 protected void runSQL(String sql) {
695 try {
696 DataSource dataSource = phonePersistence.getDataSource();
697
698 DB db = DBFactoryUtil.getDB();
699
700 sql = db.buildSQL(sql);
701 sql = PortalUtil.transformSQL(sql);
702
703 SqlUpdate sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(dataSource,
704 sql, new int[0]);
705
706 sqlUpdate.update();
707 }
708 catch (Exception e) {
709 throw new SystemException(e);
710 }
711 }
712
713 @BeanReference(type = com.liferay.portal.service.PhoneLocalService.class)
714 protected PhoneLocalService phoneLocalService;
715 @BeanReference(type = com.liferay.portal.service.PhoneService.class)
716 protected com.liferay.portal.service.PhoneService phoneService;
717 @BeanReference(type = PhonePersistence.class)
718 protected PhonePersistence phonePersistence;
719 @BeanReference(type = com.liferay.counter.service.CounterLocalService.class)
720 protected com.liferay.counter.service.CounterLocalService counterLocalService;
721 @BeanReference(type = com.liferay.portal.service.ClassNameLocalService.class)
722 protected com.liferay.portal.service.ClassNameLocalService classNameLocalService;
723 @BeanReference(type = com.liferay.portal.service.ClassNameService.class)
724 protected com.liferay.portal.service.ClassNameService classNameService;
725 @BeanReference(type = ClassNamePersistence.class)
726 protected ClassNamePersistence classNamePersistence;
727 @BeanReference(type = com.liferay.portal.service.ListTypeLocalService.class)
728 protected com.liferay.portal.service.ListTypeLocalService listTypeLocalService;
729 @BeanReference(type = com.liferay.portal.service.ListTypeService.class)
730 protected com.liferay.portal.service.ListTypeService listTypeService;
731 @BeanReference(type = ListTypePersistence.class)
732 protected ListTypePersistence listTypePersistence;
733 @BeanReference(type = com.liferay.portal.service.UserLocalService.class)
734 protected com.liferay.portal.service.UserLocalService userLocalService;
735 @BeanReference(type = com.liferay.portal.service.UserService.class)
736 protected com.liferay.portal.service.UserService userService;
737 @BeanReference(type = UserPersistence.class)
738 protected UserPersistence userPersistence;
739 @BeanReference(type = UserFinder.class)
740 protected UserFinder userFinder;
741 @BeanReference(type = PersistedModelLocalServiceRegistry.class)
742 protected PersistedModelLocalServiceRegistry persistedModelLocalServiceRegistry;
743 }