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.PersistedModel;
039 import com.liferay.portal.model.Website;
040 import com.liferay.portal.service.BaseLocalServiceImpl;
041 import com.liferay.portal.service.PersistedModelLocalServiceRegistry;
042 import com.liferay.portal.service.WebsiteLocalService;
043 import com.liferay.portal.service.persistence.ClassNamePersistence;
044 import com.liferay.portal.service.persistence.ListTypePersistence;
045 import com.liferay.portal.service.persistence.UserFinder;
046 import com.liferay.portal.service.persistence.UserPersistence;
047 import com.liferay.portal.service.persistence.WebsitePersistence;
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 WebsiteLocalServiceBaseImpl extends BaseLocalServiceImpl
076 implements WebsiteLocalService, IdentifiableBean {
077
082
083
089 @Indexable(type = IndexableType.REINDEX)
090 @Override
091 public Website addWebsite(Website website) {
092 website.setNew(true);
093
094 return websitePersistence.update(website);
095 }
096
097
103 @Override
104 public Website createWebsite(long websiteId) {
105 return websitePersistence.create(websiteId);
106 }
107
108
115 @Indexable(type = IndexableType.DELETE)
116 @Override
117 public Website deleteWebsite(long websiteId) throws PortalException {
118 return websitePersistence.remove(websiteId);
119 }
120
121
127 @Indexable(type = IndexableType.DELETE)
128 @Override
129 public Website deleteWebsite(Website website) {
130 return websitePersistence.remove(website);
131 }
132
133 @Override
134 public DynamicQuery dynamicQuery() {
135 Class<?> clazz = getClass();
136
137 return DynamicQueryFactoryUtil.forClass(Website.class,
138 clazz.getClassLoader());
139 }
140
141
147 @Override
148 public <T> List<T> dynamicQuery(DynamicQuery dynamicQuery) {
149 return websitePersistence.findWithDynamicQuery(dynamicQuery);
150 }
151
152
164 @Override
165 public <T> List<T> dynamicQuery(DynamicQuery dynamicQuery, int start,
166 int end) {
167 return websitePersistence.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 websitePersistence.findWithDynamicQuery(dynamicQuery, start,
187 end, orderByComparator);
188 }
189
190
196 @Override
197 public long dynamicQueryCount(DynamicQuery dynamicQuery) {
198 return websitePersistence.countWithDynamicQuery(dynamicQuery);
199 }
200
201
208 @Override
209 public long dynamicQueryCount(DynamicQuery dynamicQuery,
210 Projection projection) {
211 return websitePersistence.countWithDynamicQuery(dynamicQuery, projection);
212 }
213
214 @Override
215 public Website fetchWebsite(long websiteId) {
216 return websitePersistence.fetchByPrimaryKey(websiteId);
217 }
218
219
226 @Override
227 public Website fetchWebsiteByUuidAndCompanyId(String uuid, long companyId) {
228 return websitePersistence.fetchByUuid_C_First(uuid, companyId, null);
229 }
230
231
238 @Override
239 public Website getWebsite(long websiteId) throws PortalException {
240 return websitePersistence.findByPrimaryKey(websiteId);
241 }
242
243 @Override
244 public ActionableDynamicQuery getActionableDynamicQuery() {
245 ActionableDynamicQuery actionableDynamicQuery = new DefaultActionableDynamicQuery();
246
247 actionableDynamicQuery.setBaseLocalService(com.liferay.portal.service.WebsiteLocalServiceUtil.getService());
248 actionableDynamicQuery.setClass(Website.class);
249 actionableDynamicQuery.setClassLoader(getClassLoader());
250
251 actionableDynamicQuery.setPrimaryKeyPropertyName("websiteId");
252
253 return actionableDynamicQuery;
254 }
255
256 protected void initActionableDynamicQuery(
257 ActionableDynamicQuery actionableDynamicQuery) {
258 actionableDynamicQuery.setBaseLocalService(com.liferay.portal.service.WebsiteLocalServiceUtil.getService());
259 actionableDynamicQuery.setClass(Website.class);
260 actionableDynamicQuery.setClassLoader(getClassLoader());
261
262 actionableDynamicQuery.setPrimaryKeyPropertyName("websiteId");
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.toString(),
278 modelAdditionCount);
279
280 long modelDeletionCount = ExportImportHelperUtil.getModelDeletionCount(portletDataContext,
281 stagedModelType);
282
283 manifestSummary.addModelDeletionCount(stagedModelType.toString(),
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 if (stagedModelType.getReferrerClassNameId() >= 0) {
301 Property classNameIdProperty = PropertyFactoryUtil.forName(
302 "classNameId");
303
304 dynamicQuery.add(classNameIdProperty.eq(
305 stagedModelType.getReferrerClassNameId()));
306 }
307 }
308 });
309
310 exportActionableDynamicQuery.setCompanyId(portletDataContext.getCompanyId());
311
312 exportActionableDynamicQuery.setPerformActionMethod(new ActionableDynamicQuery.PerformActionMethod() {
313 @Override
314 public void performAction(Object object)
315 throws PortalException {
316 Website stagedModel = (Website)object;
317
318 StagedModelDataHandlerUtil.exportStagedModel(portletDataContext,
319 stagedModel);
320 }
321 });
322 exportActionableDynamicQuery.setStagedModelType(new StagedModelType(
323 PortalUtil.getClassNameId(Website.class.getName())));
324
325 return exportActionableDynamicQuery;
326 }
327
328
331 @Override
332 public PersistedModel deletePersistedModel(PersistedModel persistedModel)
333 throws PortalException {
334 return websiteLocalService.deleteWebsite((Website)persistedModel);
335 }
336
337 @Override
338 public PersistedModel getPersistedModel(Serializable primaryKeyObj)
339 throws PortalException {
340 return websitePersistence.findByPrimaryKey(primaryKeyObj);
341 }
342
343
351 @Override
352 public Website getWebsiteByUuidAndCompanyId(String uuid, long companyId)
353 throws PortalException {
354 return websitePersistence.findByUuid_C_First(uuid, companyId, null);
355 }
356
357
368 @Override
369 public List<Website> getWebsites(int start, int end) {
370 return websitePersistence.findAll(start, end);
371 }
372
373
378 @Override
379 public int getWebsitesCount() {
380 return websitePersistence.countAll();
381 }
382
383
389 @Indexable(type = IndexableType.REINDEX)
390 @Override
391 public Website updateWebsite(Website website) {
392 return websitePersistence.update(website);
393 }
394
395
400 public WebsiteLocalService getWebsiteLocalService() {
401 return websiteLocalService;
402 }
403
404
409 public void setWebsiteLocalService(WebsiteLocalService websiteLocalService) {
410 this.websiteLocalService = websiteLocalService;
411 }
412
413
418 public com.liferay.portal.service.WebsiteService getWebsiteService() {
419 return websiteService;
420 }
421
422
427 public void setWebsiteService(
428 com.liferay.portal.service.WebsiteService websiteService) {
429 this.websiteService = websiteService;
430 }
431
432
437 public WebsitePersistence getWebsitePersistence() {
438 return websitePersistence;
439 }
440
441
446 public void setWebsitePersistence(WebsitePersistence websitePersistence) {
447 this.websitePersistence = websitePersistence;
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.ListTypeLocalService getListTypeLocalService() {
532 return listTypeLocalService;
533 }
534
535
540 public void setListTypeLocalService(
541 com.liferay.portal.service.ListTypeLocalService listTypeLocalService) {
542 this.listTypeLocalService = listTypeLocalService;
543 }
544
545
550 public com.liferay.portal.service.ListTypeService getListTypeService() {
551 return listTypeService;
552 }
553
554
559 public void setListTypeService(
560 com.liferay.portal.service.ListTypeService listTypeService) {
561 this.listTypeService = listTypeService;
562 }
563
564
569 public ListTypePersistence getListTypePersistence() {
570 return listTypePersistence;
571 }
572
573
578 public void setListTypePersistence(ListTypePersistence listTypePersistence) {
579 this.listTypePersistence = listTypePersistence;
580 }
581
582
587 public com.liferay.portal.service.UserLocalService getUserLocalService() {
588 return userLocalService;
589 }
590
591
596 public void setUserLocalService(
597 com.liferay.portal.service.UserLocalService userLocalService) {
598 this.userLocalService = userLocalService;
599 }
600
601
606 public com.liferay.portal.service.UserService getUserService() {
607 return userService;
608 }
609
610
615 public void setUserService(
616 com.liferay.portal.service.UserService userService) {
617 this.userService = userService;
618 }
619
620
625 public UserPersistence getUserPersistence() {
626 return userPersistence;
627 }
628
629
634 public void setUserPersistence(UserPersistence userPersistence) {
635 this.userPersistence = userPersistence;
636 }
637
638
643 public UserFinder getUserFinder() {
644 return userFinder;
645 }
646
647
652 public void setUserFinder(UserFinder userFinder) {
653 this.userFinder = userFinder;
654 }
655
656 public void afterPropertiesSet() {
657 persistedModelLocalServiceRegistry.register("com.liferay.portal.model.Website",
658 websiteLocalService);
659 }
660
661 public void destroy() {
662 persistedModelLocalServiceRegistry.unregister(
663 "com.liferay.portal.model.Website");
664 }
665
666
671 @Override
672 public String getBeanIdentifier() {
673 return _beanIdentifier;
674 }
675
676
681 @Override
682 public void setBeanIdentifier(String beanIdentifier) {
683 _beanIdentifier = beanIdentifier;
684 }
685
686 protected Class<?> getModelClass() {
687 return Website.class;
688 }
689
690 protected String getModelClassName() {
691 return Website.class.getName();
692 }
693
694
699 protected void runSQL(String sql) {
700 try {
701 DataSource dataSource = websitePersistence.getDataSource();
702
703 DB db = DBFactoryUtil.getDB();
704
705 sql = db.buildSQL(sql);
706 sql = PortalUtil.transformSQL(sql);
707
708 SqlUpdate sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(dataSource,
709 sql, new int[0]);
710
711 sqlUpdate.update();
712 }
713 catch (Exception e) {
714 throw new SystemException(e);
715 }
716 }
717
718 @BeanReference(type = WebsiteLocalService.class)
719 protected WebsiteLocalService websiteLocalService;
720 @BeanReference(type = com.liferay.portal.service.WebsiteService.class)
721 protected com.liferay.portal.service.WebsiteService websiteService;
722 @BeanReference(type = WebsitePersistence.class)
723 protected WebsitePersistence websitePersistence;
724 @BeanReference(type = com.liferay.counter.service.CounterLocalService.class)
725 protected com.liferay.counter.service.CounterLocalService counterLocalService;
726 @BeanReference(type = com.liferay.portal.service.ClassNameLocalService.class)
727 protected com.liferay.portal.service.ClassNameLocalService classNameLocalService;
728 @BeanReference(type = com.liferay.portal.service.ClassNameService.class)
729 protected com.liferay.portal.service.ClassNameService classNameService;
730 @BeanReference(type = ClassNamePersistence.class)
731 protected ClassNamePersistence classNamePersistence;
732 @BeanReference(type = com.liferay.portal.service.ListTypeLocalService.class)
733 protected com.liferay.portal.service.ListTypeLocalService listTypeLocalService;
734 @BeanReference(type = com.liferay.portal.service.ListTypeService.class)
735 protected com.liferay.portal.service.ListTypeService listTypeService;
736 @BeanReference(type = ListTypePersistence.class)
737 protected ListTypePersistence listTypePersistence;
738 @BeanReference(type = com.liferay.portal.service.UserLocalService.class)
739 protected com.liferay.portal.service.UserLocalService userLocalService;
740 @BeanReference(type = com.liferay.portal.service.UserService.class)
741 protected com.liferay.portal.service.UserService userService;
742 @BeanReference(type = UserPersistence.class)
743 protected UserPersistence userPersistence;
744 @BeanReference(type = UserFinder.class)
745 protected UserFinder userFinder;
746 @BeanReference(type = PersistedModelLocalServiceRegistry.class)
747 protected PersistedModelLocalServiceRegistry persistedModelLocalServiceRegistry;
748 private String _beanIdentifier;
749 }