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.DBManagerUtil;
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.IndexableActionableDynamicQuery;
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.module.framework.service.IdentifiableOSGiService;
036 import com.liferay.portal.kernel.search.Indexable;
037 import com.liferay.portal.kernel.search.IndexableType;
038 import com.liferay.portal.kernel.util.OrderByComparator;
039 import com.liferay.portal.model.PersistedModel;
040 import com.liferay.portal.model.Website;
041 import com.liferay.portal.service.BaseLocalServiceImpl;
042 import com.liferay.portal.service.PersistedModelLocalServiceRegistry;
043 import com.liferay.portal.service.WebsiteLocalService;
044 import com.liferay.portal.service.persistence.ClassNamePersistence;
045 import com.liferay.portal.service.persistence.ListTypePersistence;
046 import com.liferay.portal.service.persistence.UserFinder;
047 import com.liferay.portal.service.persistence.UserPersistence;
048 import com.liferay.portal.service.persistence.WebsitePersistence;
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 WebsiteLocalServiceBaseImpl extends BaseLocalServiceImpl
077 implements WebsiteLocalService, IdentifiableOSGiService {
078
083
084
090 @Indexable(type = IndexableType.REINDEX)
091 @Override
092 public Website addWebsite(Website website) {
093 website.setNew(true);
094
095 return websitePersistence.update(website);
096 }
097
098
104 @Override
105 public Website createWebsite(long websiteId) {
106 return websitePersistence.create(websiteId);
107 }
108
109
116 @Indexable(type = IndexableType.DELETE)
117 @Override
118 public Website deleteWebsite(long websiteId) throws PortalException {
119 return websitePersistence.remove(websiteId);
120 }
121
122
128 @Indexable(type = IndexableType.DELETE)
129 @Override
130 public Website deleteWebsite(Website website) {
131 return websitePersistence.remove(website);
132 }
133
134 @Override
135 public DynamicQuery dynamicQuery() {
136 Class<?> clazz = getClass();
137
138 return DynamicQueryFactoryUtil.forClass(Website.class,
139 clazz.getClassLoader());
140 }
141
142
148 @Override
149 public <T> List<T> dynamicQuery(DynamicQuery dynamicQuery) {
150 return websitePersistence.findWithDynamicQuery(dynamicQuery);
151 }
152
153
165 @Override
166 public <T> List<T> dynamicQuery(DynamicQuery dynamicQuery, int start,
167 int end) {
168 return websitePersistence.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 websitePersistence.findWithDynamicQuery(dynamicQuery, start,
188 end, orderByComparator);
189 }
190
191
197 @Override
198 public long dynamicQueryCount(DynamicQuery dynamicQuery) {
199 return websitePersistence.countWithDynamicQuery(dynamicQuery);
200 }
201
202
209 @Override
210 public long dynamicQueryCount(DynamicQuery dynamicQuery,
211 Projection projection) {
212 return websitePersistence.countWithDynamicQuery(dynamicQuery, projection);
213 }
214
215 @Override
216 public Website fetchWebsite(long websiteId) {
217 return websitePersistence.fetchByPrimaryKey(websiteId);
218 }
219
220
227 @Override
228 public Website fetchWebsiteByUuidAndCompanyId(String uuid, long companyId) {
229 return websitePersistence.fetchByUuid_C_First(uuid, companyId, null);
230 }
231
232
239 @Override
240 public Website getWebsite(long websiteId) throws PortalException {
241 return websitePersistence.findByPrimaryKey(websiteId);
242 }
243
244 @Override
245 public ActionableDynamicQuery getActionableDynamicQuery() {
246 ActionableDynamicQuery actionableDynamicQuery = new DefaultActionableDynamicQuery();
247
248 actionableDynamicQuery.setBaseLocalService(com.liferay.portal.service.WebsiteLocalServiceUtil.getService());
249 actionableDynamicQuery.setClassLoader(getClassLoader());
250 actionableDynamicQuery.setModelClass(Website.class);
251
252 actionableDynamicQuery.setPrimaryKeyPropertyName("websiteId");
253
254 return actionableDynamicQuery;
255 }
256
257 @Override
258 public IndexableActionableDynamicQuery getIndexableActionableDynamicQuery() {
259 IndexableActionableDynamicQuery indexableActionableDynamicQuery = new IndexableActionableDynamicQuery();
260
261 indexableActionableDynamicQuery.setBaseLocalService(com.liferay.portal.service.WebsiteLocalServiceUtil.getService());
262 indexableActionableDynamicQuery.setClassLoader(getClassLoader());
263 indexableActionableDynamicQuery.setModelClass(Website.class);
264
265 indexableActionableDynamicQuery.setPrimaryKeyPropertyName("websiteId");
266
267 return indexableActionableDynamicQuery;
268 }
269
270 protected void initActionableDynamicQuery(
271 ActionableDynamicQuery actionableDynamicQuery) {
272 actionableDynamicQuery.setBaseLocalService(com.liferay.portal.service.WebsiteLocalServiceUtil.getService());
273 actionableDynamicQuery.setClassLoader(getClassLoader());
274 actionableDynamicQuery.setModelClass(Website.class);
275
276 actionableDynamicQuery.setPrimaryKeyPropertyName("websiteId");
277 }
278
279 @Override
280 public ExportActionableDynamicQuery getExportActionableDynamicQuery(
281 final PortletDataContext portletDataContext) {
282 final ExportActionableDynamicQuery exportActionableDynamicQuery = new ExportActionableDynamicQuery() {
283 @Override
284 public long performCount() throws PortalException {
285 ManifestSummary manifestSummary = portletDataContext.getManifestSummary();
286
287 StagedModelType stagedModelType = getStagedModelType();
288
289 long modelAdditionCount = super.performCount();
290
291 manifestSummary.addModelAdditionCount(stagedModelType,
292 modelAdditionCount);
293
294 long modelDeletionCount = ExportImportHelperUtil.getModelDeletionCount(portletDataContext,
295 stagedModelType);
296
297 manifestSummary.addModelDeletionCount(stagedModelType,
298 modelDeletionCount);
299
300 return modelAdditionCount;
301 }
302 };
303
304 initActionableDynamicQuery(exportActionableDynamicQuery);
305
306 exportActionableDynamicQuery.setAddCriteriaMethod(new ActionableDynamicQuery.AddCriteriaMethod() {
307 @Override
308 public void addCriteria(DynamicQuery dynamicQuery) {
309 portletDataContext.addDateRangeCriteria(dynamicQuery,
310 "modifiedDate");
311
312 StagedModelType stagedModelType = exportActionableDynamicQuery.getStagedModelType();
313
314 long referrerClassNameId = stagedModelType.getReferrerClassNameId();
315
316 Property classNameIdProperty = PropertyFactoryUtil.forName(
317 "classNameId");
318
319 if ((referrerClassNameId != StagedModelType.REFERRER_CLASS_NAME_ID_ALL) &&
320 (referrerClassNameId != StagedModelType.REFERRER_CLASS_NAME_ID_ANY)) {
321 dynamicQuery.add(classNameIdProperty.eq(
322 stagedModelType.getReferrerClassNameId()));
323 }
324 else if (referrerClassNameId == StagedModelType.REFERRER_CLASS_NAME_ID_ANY) {
325 dynamicQuery.add(classNameIdProperty.isNotNull());
326 }
327 }
328 });
329
330 exportActionableDynamicQuery.setCompanyId(portletDataContext.getCompanyId());
331
332 exportActionableDynamicQuery.setPerformActionMethod(new ActionableDynamicQuery.PerformActionMethod<Website>() {
333 @Override
334 public void performAction(Website website)
335 throws PortalException {
336 StagedModelDataHandlerUtil.exportStagedModel(portletDataContext,
337 website);
338 }
339 });
340 exportActionableDynamicQuery.setStagedModelType(new StagedModelType(
341 PortalUtil.getClassNameId(Website.class.getName()),
342 StagedModelType.REFERRER_CLASS_NAME_ID_ALL));
343
344 return exportActionableDynamicQuery;
345 }
346
347
350 @Override
351 public PersistedModel deletePersistedModel(PersistedModel persistedModel)
352 throws PortalException {
353 return websiteLocalService.deleteWebsite((Website)persistedModel);
354 }
355
356 @Override
357 public PersistedModel getPersistedModel(Serializable primaryKeyObj)
358 throws PortalException {
359 return websitePersistence.findByPrimaryKey(primaryKeyObj);
360 }
361
362
370 @Override
371 public Website getWebsiteByUuidAndCompanyId(String uuid, long companyId)
372 throws PortalException {
373 return websitePersistence.findByUuid_C_First(uuid, companyId, null);
374 }
375
376
387 @Override
388 public List<Website> getWebsites(int start, int end) {
389 return websitePersistence.findAll(start, end);
390 }
391
392
397 @Override
398 public int getWebsitesCount() {
399 return websitePersistence.countAll();
400 }
401
402
408 @Indexable(type = IndexableType.REINDEX)
409 @Override
410 public Website updateWebsite(Website website) {
411 return websitePersistence.update(website);
412 }
413
414
419 public WebsiteLocalService getWebsiteLocalService() {
420 return websiteLocalService;
421 }
422
423
428 public void setWebsiteLocalService(WebsiteLocalService websiteLocalService) {
429 this.websiteLocalService = websiteLocalService;
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 ClassNamePersistence getClassNamePersistence() {
494 return classNamePersistence;
495 }
496
497
502 public void setClassNamePersistence(
503 ClassNamePersistence classNamePersistence) {
504 this.classNamePersistence = classNamePersistence;
505 }
506
507
512 public com.liferay.portal.service.ListTypeLocalService getListTypeLocalService() {
513 return listTypeLocalService;
514 }
515
516
521 public void setListTypeLocalService(
522 com.liferay.portal.service.ListTypeLocalService listTypeLocalService) {
523 this.listTypeLocalService = listTypeLocalService;
524 }
525
526
531 public ListTypePersistence getListTypePersistence() {
532 return listTypePersistence;
533 }
534
535
540 public void setListTypePersistence(ListTypePersistence listTypePersistence) {
541 this.listTypePersistence = listTypePersistence;
542 }
543
544
549 public com.liferay.portal.service.UserLocalService getUserLocalService() {
550 return userLocalService;
551 }
552
553
558 public void setUserLocalService(
559 com.liferay.portal.service.UserLocalService userLocalService) {
560 this.userLocalService = userLocalService;
561 }
562
563
568 public UserPersistence getUserPersistence() {
569 return userPersistence;
570 }
571
572
577 public void setUserPersistence(UserPersistence userPersistence) {
578 this.userPersistence = userPersistence;
579 }
580
581
586 public UserFinder getUserFinder() {
587 return userFinder;
588 }
589
590
595 public void setUserFinder(UserFinder userFinder) {
596 this.userFinder = userFinder;
597 }
598
599 public void afterPropertiesSet() {
600 persistedModelLocalServiceRegistry.register("com.liferay.portal.model.Website",
601 websiteLocalService);
602 }
603
604 public void destroy() {
605 persistedModelLocalServiceRegistry.unregister(
606 "com.liferay.portal.model.Website");
607 }
608
609
614 @Override
615 public String getOSGiServiceIdentifier() {
616 return WebsiteLocalService.class.getName();
617 }
618
619 protected Class<?> getModelClass() {
620 return Website.class;
621 }
622
623 protected String getModelClassName() {
624 return Website.class.getName();
625 }
626
627
632 protected void runSQL(String sql) {
633 try {
634 DataSource dataSource = websitePersistence.getDataSource();
635
636 DB db = DBManagerUtil.getDB();
637
638 sql = db.buildSQL(sql);
639 sql = PortalUtil.transformSQL(sql);
640
641 SqlUpdate sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(dataSource,
642 sql, new int[0]);
643
644 sqlUpdate.update();
645 }
646 catch (Exception e) {
647 throw new SystemException(e);
648 }
649 }
650
651 @BeanReference(type = com.liferay.portal.service.WebsiteLocalService.class)
652 protected WebsiteLocalService websiteLocalService;
653 @BeanReference(type = WebsitePersistence.class)
654 protected WebsitePersistence websitePersistence;
655 @BeanReference(type = com.liferay.counter.service.CounterLocalService.class)
656 protected com.liferay.counter.service.CounterLocalService counterLocalService;
657 @BeanReference(type = com.liferay.portal.service.ClassNameLocalService.class)
658 protected com.liferay.portal.service.ClassNameLocalService classNameLocalService;
659 @BeanReference(type = ClassNamePersistence.class)
660 protected ClassNamePersistence classNamePersistence;
661 @BeanReference(type = com.liferay.portal.service.ListTypeLocalService.class)
662 protected com.liferay.portal.service.ListTypeLocalService listTypeLocalService;
663 @BeanReference(type = ListTypePersistence.class)
664 protected ListTypePersistence listTypePersistence;
665 @BeanReference(type = com.liferay.portal.service.UserLocalService.class)
666 protected com.liferay.portal.service.UserLocalService userLocalService;
667 @BeanReference(type = UserPersistence.class)
668 protected UserPersistence userPersistence;
669 @BeanReference(type = UserFinder.class)
670 protected UserFinder userFinder;
671 @BeanReference(type = PersistedModelLocalServiceRegistry.class)
672 protected PersistedModelLocalServiceRegistry persistedModelLocalServiceRegistry;
673 }