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.lar.ExportImportHelperUtil;
036 import com.liferay.portal.kernel.lar.ManifestSummary;
037 import com.liferay.portal.kernel.lar.PortletDataContext;
038 import com.liferay.portal.kernel.lar.StagedModelDataHandlerUtil;
039 import com.liferay.portal.kernel.lar.StagedModelType;
040 import com.liferay.portal.kernel.search.Indexable;
041 import com.liferay.portal.kernel.search.IndexableType;
042 import com.liferay.portal.kernel.util.OrderByComparator;
043 import com.liferay.portal.model.PersistedModel;
044 import com.liferay.portal.model.Phone;
045 import com.liferay.portal.service.BaseLocalServiceImpl;
046 import com.liferay.portal.service.PersistedModelLocalServiceRegistry;
047 import com.liferay.portal.service.PhoneLocalService;
048 import com.liferay.portal.service.persistence.ClassNamePersistence;
049 import com.liferay.portal.service.persistence.ListTypePersistence;
050 import com.liferay.portal.service.persistence.PhonePersistence;
051 import com.liferay.portal.service.persistence.UserFinder;
052 import com.liferay.portal.service.persistence.UserPersistence;
053 import com.liferay.portal.util.PortalUtil;
054
055 import java.io.Serializable;
056
057 import java.util.List;
058
059 import javax.sql.DataSource;
060
061
073 @ProviderType
074 public abstract class PhoneLocalServiceBaseImpl extends BaseLocalServiceImpl
075 implements PhoneLocalService, IdentifiableBean {
076
081
082
088 @Indexable(type = IndexableType.REINDEX)
089 @Override
090 public Phone addPhone(Phone phone) {
091 phone.setNew(true);
092
093 return phonePersistence.update(phone);
094 }
095
096
102 @Override
103 public Phone createPhone(long phoneId) {
104 return phonePersistence.create(phoneId);
105 }
106
107
114 @Indexable(type = IndexableType.DELETE)
115 @Override
116 public Phone deletePhone(long phoneId) throws PortalException {
117 return phonePersistence.remove(phoneId);
118 }
119
120
126 @Indexable(type = IndexableType.DELETE)
127 @Override
128 public Phone deletePhone(Phone phone) {
129 return phonePersistence.remove(phone);
130 }
131
132 @Override
133 public DynamicQuery dynamicQuery() {
134 Class<?> clazz = getClass();
135
136 return DynamicQueryFactoryUtil.forClass(Phone.class,
137 clazz.getClassLoader());
138 }
139
140
146 @Override
147 public <T> List<T> dynamicQuery(DynamicQuery dynamicQuery) {
148 return phonePersistence.findWithDynamicQuery(dynamicQuery);
149 }
150
151
163 @Override
164 public <T> List<T> dynamicQuery(DynamicQuery dynamicQuery, int start,
165 int end) {
166 return phonePersistence.findWithDynamicQuery(dynamicQuery, start, end);
167 }
168
169
182 @Override
183 public <T> List<T> dynamicQuery(DynamicQuery dynamicQuery, int start,
184 int end, OrderByComparator<T> orderByComparator) {
185 return phonePersistence.findWithDynamicQuery(dynamicQuery, start, end,
186 orderByComparator);
187 }
188
189
195 @Override
196 public long dynamicQueryCount(DynamicQuery dynamicQuery) {
197 return phonePersistence.countWithDynamicQuery(dynamicQuery);
198 }
199
200
207 @Override
208 public long dynamicQueryCount(DynamicQuery dynamicQuery,
209 Projection projection) {
210 return phonePersistence.countWithDynamicQuery(dynamicQuery, projection);
211 }
212
213 @Override
214 public Phone fetchPhone(long phoneId) {
215 return phonePersistence.fetchByPrimaryKey(phoneId);
216 }
217
218
225 @Override
226 public Phone fetchPhoneByUuidAndCompanyId(String uuid, long companyId) {
227 return phonePersistence.fetchByUuid_C_First(uuid, companyId, null);
228 }
229
230
237 @Override
238 public Phone getPhone(long phoneId) throws PortalException {
239 return phonePersistence.findByPrimaryKey(phoneId);
240 }
241
242 @Override
243 public ActionableDynamicQuery getActionableDynamicQuery() {
244 ActionableDynamicQuery actionableDynamicQuery = new DefaultActionableDynamicQuery();
245
246 actionableDynamicQuery.setBaseLocalService(com.liferay.portal.service.PhoneLocalServiceUtil.getService());
247 actionableDynamicQuery.setClass(Phone.class);
248 actionableDynamicQuery.setClassLoader(getClassLoader());
249
250 actionableDynamicQuery.setPrimaryKeyPropertyName("phoneId");
251
252 return actionableDynamicQuery;
253 }
254
255 protected void initActionableDynamicQuery(
256 ActionableDynamicQuery actionableDynamicQuery) {
257 actionableDynamicQuery.setBaseLocalService(com.liferay.portal.service.PhoneLocalServiceUtil.getService());
258 actionableDynamicQuery.setClass(Phone.class);
259 actionableDynamicQuery.setClassLoader(getClassLoader());
260
261 actionableDynamicQuery.setPrimaryKeyPropertyName("phoneId");
262 }
263
264 @Override
265 public ExportActionableDynamicQuery getExportActionableDynamicQuery(
266 final PortletDataContext portletDataContext) {
267 final ExportActionableDynamicQuery exportActionableDynamicQuery = new ExportActionableDynamicQuery() {
268 @Override
269 public long performCount() throws PortalException {
270 ManifestSummary manifestSummary = portletDataContext.getManifestSummary();
271
272 StagedModelType stagedModelType = getStagedModelType();
273
274 long modelAdditionCount = super.performCount();
275
276 manifestSummary.addModelAdditionCount(stagedModelType.toString(),
277 modelAdditionCount);
278
279 long modelDeletionCount = ExportImportHelperUtil.getModelDeletionCount(portletDataContext,
280 stagedModelType);
281
282 manifestSummary.addModelDeletionCount(stagedModelType.toString(),
283 modelDeletionCount);
284
285 return modelAdditionCount;
286 }
287 };
288
289 initActionableDynamicQuery(exportActionableDynamicQuery);
290
291 exportActionableDynamicQuery.setAddCriteriaMethod(new ActionableDynamicQuery.AddCriteriaMethod() {
292 @Override
293 public void addCriteria(DynamicQuery dynamicQuery) {
294 portletDataContext.addDateRangeCriteria(dynamicQuery,
295 "modifiedDate");
296
297 StagedModelType stagedModelType = exportActionableDynamicQuery.getStagedModelType();
298
299 if (stagedModelType.getReferrerClassNameId() >= 0) {
300 Property classNameIdProperty = PropertyFactoryUtil.forName(
301 "classNameId");
302
303 dynamicQuery.add(classNameIdProperty.eq(
304 stagedModelType.getReferrerClassNameId()));
305 }
306 }
307 });
308
309 exportActionableDynamicQuery.setCompanyId(portletDataContext.getCompanyId());
310
311 exportActionableDynamicQuery.setPerformActionMethod(new ActionableDynamicQuery.PerformActionMethod() {
312 @Override
313 public void performAction(Object object)
314 throws PortalException {
315 Phone stagedModel = (Phone)object;
316
317 StagedModelDataHandlerUtil.exportStagedModel(portletDataContext,
318 stagedModel);
319 }
320 });
321 exportActionableDynamicQuery.setStagedModelType(new StagedModelType(
322 PortalUtil.getClassNameId(Phone.class.getName())));
323
324 return exportActionableDynamicQuery;
325 }
326
327
330 @Override
331 public PersistedModel deletePersistedModel(PersistedModel persistedModel)
332 throws PortalException {
333 return phoneLocalService.deletePhone((Phone)persistedModel);
334 }
335
336 @Override
337 public PersistedModel getPersistedModel(Serializable primaryKeyObj)
338 throws PortalException {
339 return phonePersistence.findByPrimaryKey(primaryKeyObj);
340 }
341
342
350 @Override
351 public Phone getPhoneByUuidAndCompanyId(String uuid, long companyId)
352 throws PortalException {
353 return phonePersistence.findByUuid_C_First(uuid, companyId, null);
354 }
355
356
367 @Override
368 public List<Phone> getPhones(int start, int end) {
369 return phonePersistence.findAll(start, end);
370 }
371
372
377 @Override
378 public int getPhonesCount() {
379 return phonePersistence.countAll();
380 }
381
382
388 @Indexable(type = IndexableType.REINDEX)
389 @Override
390 public Phone updatePhone(Phone phone) {
391 return phonePersistence.update(phone);
392 }
393
394
399 public com.liferay.portal.service.PhoneLocalService getPhoneLocalService() {
400 return phoneLocalService;
401 }
402
403
408 public void setPhoneLocalService(
409 com.liferay.portal.service.PhoneLocalService phoneLocalService) {
410 this.phoneLocalService = phoneLocalService;
411 }
412
413
418 public com.liferay.portal.service.PhoneService getPhoneService() {
419 return phoneService;
420 }
421
422
427 public void setPhoneService(
428 com.liferay.portal.service.PhoneService phoneService) {
429 this.phoneService = phoneService;
430 }
431
432
437 public PhonePersistence getPhonePersistence() {
438 return phonePersistence;
439 }
440
441
446 public void setPhonePersistence(PhonePersistence phonePersistence) {
447 this.phonePersistence = phonePersistence;
448 }
449
450
455 public com.liferay.counter.service.CounterLocalService getCounterLocalService() {
456 return counterLocalService;
457 }
458
459
464 public void setCounterLocalService(
465 com.liferay.counter.service.CounterLocalService counterLocalService) {
466 this.counterLocalService = counterLocalService;
467 }
468
469
474 public com.liferay.portal.service.ClassNameLocalService getClassNameLocalService() {
475 return classNameLocalService;
476 }
477
478
483 public void setClassNameLocalService(
484 com.liferay.portal.service.ClassNameLocalService classNameLocalService) {
485 this.classNameLocalService = classNameLocalService;
486 }
487
488
493 public com.liferay.portal.service.ClassNameService getClassNameService() {
494 return classNameService;
495 }
496
497
502 public void setClassNameService(
503 com.liferay.portal.service.ClassNameService classNameService) {
504 this.classNameService = classNameService;
505 }
506
507
512 public ClassNamePersistence getClassNamePersistence() {
513 return classNamePersistence;
514 }
515
516
521 public void setClassNamePersistence(
522 ClassNamePersistence classNamePersistence) {
523 this.classNamePersistence = classNamePersistence;
524 }
525
526
531 public com.liferay.portal.service.ListTypeService getListTypeService() {
532 return listTypeService;
533 }
534
535
540 public void setListTypeService(
541 com.liferay.portal.service.ListTypeService listTypeService) {
542 this.listTypeService = listTypeService;
543 }
544
545
550 public ListTypePersistence getListTypePersistence() {
551 return listTypePersistence;
552 }
553
554
559 public void setListTypePersistence(ListTypePersistence listTypePersistence) {
560 this.listTypePersistence = listTypePersistence;
561 }
562
563
568 public com.liferay.portal.service.UserLocalService getUserLocalService() {
569 return userLocalService;
570 }
571
572
577 public void setUserLocalService(
578 com.liferay.portal.service.UserLocalService userLocalService) {
579 this.userLocalService = userLocalService;
580 }
581
582
587 public com.liferay.portal.service.UserService getUserService() {
588 return userService;
589 }
590
591
596 public void setUserService(
597 com.liferay.portal.service.UserService userService) {
598 this.userService = userService;
599 }
600
601
606 public UserPersistence getUserPersistence() {
607 return userPersistence;
608 }
609
610
615 public void setUserPersistence(UserPersistence userPersistence) {
616 this.userPersistence = userPersistence;
617 }
618
619
624 public UserFinder getUserFinder() {
625 return userFinder;
626 }
627
628
633 public void setUserFinder(UserFinder userFinder) {
634 this.userFinder = userFinder;
635 }
636
637 public void afterPropertiesSet() {
638 persistedModelLocalServiceRegistry.register("com.liferay.portal.model.Phone",
639 phoneLocalService);
640 }
641
642 public void destroy() {
643 persistedModelLocalServiceRegistry.unregister(
644 "com.liferay.portal.model.Phone");
645 }
646
647
652 @Override
653 public String getBeanIdentifier() {
654 return _beanIdentifier;
655 }
656
657
662 @Override
663 public void setBeanIdentifier(String beanIdentifier) {
664 _beanIdentifier = beanIdentifier;
665 }
666
667 protected Class<?> getModelClass() {
668 return Phone.class;
669 }
670
671 protected String getModelClassName() {
672 return Phone.class.getName();
673 }
674
675
680 protected void runSQL(String sql) {
681 try {
682 DataSource dataSource = phonePersistence.getDataSource();
683
684 DB db = DBFactoryUtil.getDB();
685
686 sql = db.buildSQL(sql);
687 sql = PortalUtil.transformSQL(sql);
688
689 SqlUpdate sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(dataSource,
690 sql, new int[0]);
691
692 sqlUpdate.update();
693 }
694 catch (Exception e) {
695 throw new SystemException(e);
696 }
697 }
698
699 @BeanReference(type = com.liferay.portal.service.PhoneLocalService.class)
700 protected com.liferay.portal.service.PhoneLocalService phoneLocalService;
701 @BeanReference(type = com.liferay.portal.service.PhoneService.class)
702 protected com.liferay.portal.service.PhoneService phoneService;
703 @BeanReference(type = PhonePersistence.class)
704 protected PhonePersistence phonePersistence;
705 @BeanReference(type = com.liferay.counter.service.CounterLocalService.class)
706 protected com.liferay.counter.service.CounterLocalService counterLocalService;
707 @BeanReference(type = com.liferay.portal.service.ClassNameLocalService.class)
708 protected com.liferay.portal.service.ClassNameLocalService classNameLocalService;
709 @BeanReference(type = com.liferay.portal.service.ClassNameService.class)
710 protected com.liferay.portal.service.ClassNameService classNameService;
711 @BeanReference(type = ClassNamePersistence.class)
712 protected ClassNamePersistence classNamePersistence;
713 @BeanReference(type = com.liferay.portal.service.ListTypeService.class)
714 protected com.liferay.portal.service.ListTypeService listTypeService;
715 @BeanReference(type = ListTypePersistence.class)
716 protected ListTypePersistence listTypePersistence;
717 @BeanReference(type = com.liferay.portal.service.UserLocalService.class)
718 protected com.liferay.portal.service.UserLocalService userLocalService;
719 @BeanReference(type = com.liferay.portal.service.UserService.class)
720 protected com.liferay.portal.service.UserService userService;
721 @BeanReference(type = UserPersistence.class)
722 protected UserPersistence userPersistence;
723 @BeanReference(type = UserFinder.class)
724 protected UserFinder userFinder;
725 @BeanReference(type = PersistedModelLocalServiceRegistry.class)
726 protected PersistedModelLocalServiceRegistry persistedModelLocalServiceRegistry;
727 private String _beanIdentifier;
728 }