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.Website;
045 import com.liferay.portal.service.BaseLocalServiceImpl;
046 import com.liferay.portal.service.PersistedModelLocalServiceRegistry;
047 import com.liferay.portal.service.WebsiteLocalService;
048 import com.liferay.portal.service.persistence.ClassNamePersistence;
049 import com.liferay.portal.service.persistence.ListTypePersistence;
050 import com.liferay.portal.service.persistence.UserFinder;
051 import com.liferay.portal.service.persistence.UserPersistence;
052 import com.liferay.portal.service.persistence.WebsitePersistence;
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 WebsiteLocalServiceBaseImpl extends BaseLocalServiceImpl
075 implements WebsiteLocalService, IdentifiableBean {
076
081
082
088 @Indexable(type = IndexableType.REINDEX)
089 @Override
090 public Website addWebsite(Website website) {
091 website.setNew(true);
092
093 return websitePersistence.update(website);
094 }
095
096
102 @Override
103 public Website createWebsite(long websiteId) {
104 return websitePersistence.create(websiteId);
105 }
106
107
114 @Indexable(type = IndexableType.DELETE)
115 @Override
116 public Website deleteWebsite(long websiteId) throws PortalException {
117 return websitePersistence.remove(websiteId);
118 }
119
120
126 @Indexable(type = IndexableType.DELETE)
127 @Override
128 public Website deleteWebsite(Website website) {
129 return websitePersistence.remove(website);
130 }
131
132 @Override
133 public DynamicQuery dynamicQuery() {
134 Class<?> clazz = getClass();
135
136 return DynamicQueryFactoryUtil.forClass(Website.class,
137 clazz.getClassLoader());
138 }
139
140
146 @Override
147 public <T> List<T> dynamicQuery(DynamicQuery dynamicQuery) {
148 return websitePersistence.findWithDynamicQuery(dynamicQuery);
149 }
150
151
163 @Override
164 public <T> List<T> dynamicQuery(DynamicQuery dynamicQuery, int start,
165 int end) {
166 return websitePersistence.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 websitePersistence.findWithDynamicQuery(dynamicQuery, start,
186 end, orderByComparator);
187 }
188
189
195 @Override
196 public long dynamicQueryCount(DynamicQuery dynamicQuery) {
197 return websitePersistence.countWithDynamicQuery(dynamicQuery);
198 }
199
200
207 @Override
208 public long dynamicQueryCount(DynamicQuery dynamicQuery,
209 Projection projection) {
210 return websitePersistence.countWithDynamicQuery(dynamicQuery, projection);
211 }
212
213 @Override
214 public Website fetchWebsite(long websiteId) {
215 return websitePersistence.fetchByPrimaryKey(websiteId);
216 }
217
218
225 @Override
226 public Website fetchWebsiteByUuidAndCompanyId(String uuid, long companyId) {
227 return websitePersistence.fetchByUuid_C_First(uuid, companyId, null);
228 }
229
230
237 @Override
238 public Website getWebsite(long websiteId) throws PortalException {
239 return websitePersistence.findByPrimaryKey(websiteId);
240 }
241
242 @Override
243 public ActionableDynamicQuery getActionableDynamicQuery() {
244 ActionableDynamicQuery actionableDynamicQuery = new DefaultActionableDynamicQuery();
245
246 actionableDynamicQuery.setBaseLocalService(com.liferay.portal.service.WebsiteLocalServiceUtil.getService());
247 actionableDynamicQuery.setClass(Website.class);
248 actionableDynamicQuery.setClassLoader(getClassLoader());
249
250 actionableDynamicQuery.setPrimaryKeyPropertyName("websiteId");
251
252 return actionableDynamicQuery;
253 }
254
255 protected void initActionableDynamicQuery(
256 ActionableDynamicQuery actionableDynamicQuery) {
257 actionableDynamicQuery.setBaseLocalService(com.liferay.portal.service.WebsiteLocalServiceUtil.getService());
258 actionableDynamicQuery.setClass(Website.class);
259 actionableDynamicQuery.setClassLoader(getClassLoader());
260
261 actionableDynamicQuery.setPrimaryKeyPropertyName("websiteId");
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 Website stagedModel = (Website)object;
316
317 StagedModelDataHandlerUtil.exportStagedModel(portletDataContext,
318 stagedModel);
319 }
320 });
321 exportActionableDynamicQuery.setStagedModelType(new StagedModelType(
322 PortalUtil.getClassNameId(Website.class.getName())));
323
324 return exportActionableDynamicQuery;
325 }
326
327
330 @Override
331 public PersistedModel deletePersistedModel(PersistedModel persistedModel)
332 throws PortalException {
333 return websiteLocalService.deleteWebsite((Website)persistedModel);
334 }
335
336 @Override
337 public PersistedModel getPersistedModel(Serializable primaryKeyObj)
338 throws PortalException {
339 return websitePersistence.findByPrimaryKey(primaryKeyObj);
340 }
341
342
350 @Override
351 public Website getWebsiteByUuidAndCompanyId(String uuid, long companyId)
352 throws PortalException {
353 return websitePersistence.findByUuid_C_First(uuid, companyId, null);
354 }
355
356
367 @Override
368 public List<Website> getWebsites(int start, int end) {
369 return websitePersistence.findAll(start, end);
370 }
371
372
377 @Override
378 public int getWebsitesCount() {
379 return websitePersistence.countAll();
380 }
381
382
388 @Indexable(type = IndexableType.REINDEX)
389 @Override
390 public Website updateWebsite(Website website) {
391 return websitePersistence.update(website);
392 }
393
394
399 public com.liferay.portal.service.WebsiteLocalService getWebsiteLocalService() {
400 return websiteLocalService;
401 }
402
403
408 public void setWebsiteLocalService(
409 com.liferay.portal.service.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.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.Website",
639 websiteLocalService);
640 }
641
642 public void destroy() {
643 persistedModelLocalServiceRegistry.unregister(
644 "com.liferay.portal.model.Website");
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 Website.class;
669 }
670
671 protected String getModelClassName() {
672 return Website.class.getName();
673 }
674
675
680 protected void runSQL(String sql) {
681 try {
682 DataSource dataSource = websitePersistence.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.WebsiteLocalService.class)
700 protected com.liferay.portal.service.WebsiteLocalService websiteLocalService;
701 @BeanReference(type = com.liferay.portal.service.WebsiteService.class)
702 protected com.liferay.portal.service.WebsiteService websiteService;
703 @BeanReference(type = WebsitePersistence.class)
704 protected WebsitePersistence websitePersistence;
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 }