001
014
015 package com.liferay.portlet.expando.service.base;
016
017 import com.liferay.counter.service.CounterLocalService;
018
019 import com.liferay.portal.kernel.bean.BeanReference;
020 import com.liferay.portal.kernel.bean.IdentifiableBean;
021 import com.liferay.portal.kernel.dao.jdbc.SqlUpdate;
022 import com.liferay.portal.kernel.dao.jdbc.SqlUpdateFactoryUtil;
023 import com.liferay.portal.kernel.dao.orm.DynamicQuery;
024 import com.liferay.portal.kernel.exception.PortalException;
025 import com.liferay.portal.kernel.exception.SystemException;
026 import com.liferay.portal.kernel.log.Log;
027 import com.liferay.portal.kernel.log.LogFactoryUtil;
028 import com.liferay.portal.kernel.search.Indexer;
029 import com.liferay.portal.kernel.search.IndexerRegistryUtil;
030 import com.liferay.portal.kernel.search.SearchException;
031 import com.liferay.portal.kernel.util.OrderByComparator;
032 import com.liferay.portal.model.PersistedModel;
033 import com.liferay.portal.service.PersistedModelLocalServiceRegistry;
034 import com.liferay.portal.service.ResourceLocalService;
035 import com.liferay.portal.service.ResourceService;
036 import com.liferay.portal.service.UserLocalService;
037 import com.liferay.portal.service.UserService;
038 import com.liferay.portal.service.persistence.ResourceFinder;
039 import com.liferay.portal.service.persistence.ResourcePersistence;
040 import com.liferay.portal.service.persistence.UserFinder;
041 import com.liferay.portal.service.persistence.UserPersistence;
042
043 import com.liferay.portlet.expando.model.ExpandoRow;
044 import com.liferay.portlet.expando.service.ExpandoColumnLocalService;
045 import com.liferay.portlet.expando.service.ExpandoColumnService;
046 import com.liferay.portlet.expando.service.ExpandoRowLocalService;
047 import com.liferay.portlet.expando.service.ExpandoTableLocalService;
048 import com.liferay.portlet.expando.service.ExpandoValueLocalService;
049 import com.liferay.portlet.expando.service.ExpandoValueService;
050 import com.liferay.portlet.expando.service.persistence.ExpandoColumnPersistence;
051 import com.liferay.portlet.expando.service.persistence.ExpandoRowPersistence;
052 import com.liferay.portlet.expando.service.persistence.ExpandoTablePersistence;
053 import com.liferay.portlet.expando.service.persistence.ExpandoValuePersistence;
054
055 import java.io.Serializable;
056
057 import java.util.List;
058
059 import javax.sql.DataSource;
060
061
073 public abstract class ExpandoRowLocalServiceBaseImpl
074 implements ExpandoRowLocalService, IdentifiableBean {
075
080
081
088 public ExpandoRow addExpandoRow(ExpandoRow expandoRow)
089 throws SystemException {
090 expandoRow.setNew(true);
091
092 expandoRow = expandoRowPersistence.update(expandoRow, false);
093
094 Indexer indexer = IndexerRegistryUtil.getIndexer(getModelClassName());
095
096 if (indexer != null) {
097 try {
098 indexer.reindex(expandoRow);
099 }
100 catch (SearchException se) {
101 if (_log.isWarnEnabled()) {
102 _log.warn(se, se);
103 }
104 }
105 }
106
107 return expandoRow;
108 }
109
110
116 public ExpandoRow createExpandoRow(long rowId) {
117 return expandoRowPersistence.create(rowId);
118 }
119
120
127 public void deleteExpandoRow(long rowId)
128 throws PortalException, SystemException {
129 ExpandoRow expandoRow = expandoRowPersistence.remove(rowId);
130
131 Indexer indexer = IndexerRegistryUtil.getIndexer(getModelClassName());
132
133 if (indexer != null) {
134 try {
135 indexer.delete(expandoRow);
136 }
137 catch (SearchException se) {
138 if (_log.isWarnEnabled()) {
139 _log.warn(se, se);
140 }
141 }
142 }
143 }
144
145
151 public void deleteExpandoRow(ExpandoRow expandoRow)
152 throws SystemException {
153 expandoRowPersistence.remove(expandoRow);
154
155 Indexer indexer = IndexerRegistryUtil.getIndexer(getModelClassName());
156
157 if (indexer != null) {
158 try {
159 indexer.delete(expandoRow);
160 }
161 catch (SearchException se) {
162 if (_log.isWarnEnabled()) {
163 _log.warn(se, se);
164 }
165 }
166 }
167 }
168
169
176 @SuppressWarnings("rawtypes")
177 public List dynamicQuery(DynamicQuery dynamicQuery)
178 throws SystemException {
179 return expandoRowPersistence.findWithDynamicQuery(dynamicQuery);
180 }
181
182
195 @SuppressWarnings("rawtypes")
196 public List dynamicQuery(DynamicQuery dynamicQuery, int start, int end)
197 throws SystemException {
198 return expandoRowPersistence.findWithDynamicQuery(dynamicQuery, start,
199 end);
200 }
201
202
216 @SuppressWarnings("rawtypes")
217 public List dynamicQuery(DynamicQuery dynamicQuery, int start, int end,
218 OrderByComparator orderByComparator) throws SystemException {
219 return expandoRowPersistence.findWithDynamicQuery(dynamicQuery, start,
220 end, orderByComparator);
221 }
222
223
230 public long dynamicQueryCount(DynamicQuery dynamicQuery)
231 throws SystemException {
232 return expandoRowPersistence.countWithDynamicQuery(dynamicQuery);
233 }
234
235 public ExpandoRow fetchExpandoRow(long rowId) throws SystemException {
236 return expandoRowPersistence.fetchByPrimaryKey(rowId);
237 }
238
239
247 public ExpandoRow getExpandoRow(long rowId)
248 throws PortalException, SystemException {
249 return expandoRowPersistence.findByPrimaryKey(rowId);
250 }
251
252 public PersistedModel getPersistedModel(Serializable primaryKeyObj)
253 throws PortalException, SystemException {
254 return expandoRowPersistence.findByPrimaryKey(primaryKeyObj);
255 }
256
257
269 public List<ExpandoRow> getExpandoRows(int start, int end)
270 throws SystemException {
271 return expandoRowPersistence.findAll(start, end);
272 }
273
274
280 public int getExpandoRowsCount() throws SystemException {
281 return expandoRowPersistence.countAll();
282 }
283
284
291 public ExpandoRow updateExpandoRow(ExpandoRow expandoRow)
292 throws SystemException {
293 return updateExpandoRow(expandoRow, true);
294 }
295
296
304 public ExpandoRow updateExpandoRow(ExpandoRow expandoRow, boolean merge)
305 throws SystemException {
306 expandoRow.setNew(false);
307
308 expandoRow = expandoRowPersistence.update(expandoRow, merge);
309
310 Indexer indexer = IndexerRegistryUtil.getIndexer(getModelClassName());
311
312 if (indexer != null) {
313 try {
314 indexer.reindex(expandoRow);
315 }
316 catch (SearchException se) {
317 if (_log.isWarnEnabled()) {
318 _log.warn(se, se);
319 }
320 }
321 }
322
323 return expandoRow;
324 }
325
326
331 public ExpandoColumnLocalService getExpandoColumnLocalService() {
332 return expandoColumnLocalService;
333 }
334
335
340 public void setExpandoColumnLocalService(
341 ExpandoColumnLocalService expandoColumnLocalService) {
342 this.expandoColumnLocalService = expandoColumnLocalService;
343 }
344
345
350 public ExpandoColumnService getExpandoColumnService() {
351 return expandoColumnService;
352 }
353
354
359 public void setExpandoColumnService(
360 ExpandoColumnService expandoColumnService) {
361 this.expandoColumnService = expandoColumnService;
362 }
363
364
369 public ExpandoColumnPersistence getExpandoColumnPersistence() {
370 return expandoColumnPersistence;
371 }
372
373
378 public void setExpandoColumnPersistence(
379 ExpandoColumnPersistence expandoColumnPersistence) {
380 this.expandoColumnPersistence = expandoColumnPersistence;
381 }
382
383
388 public ExpandoRowLocalService getExpandoRowLocalService() {
389 return expandoRowLocalService;
390 }
391
392
397 public void setExpandoRowLocalService(
398 ExpandoRowLocalService expandoRowLocalService) {
399 this.expandoRowLocalService = expandoRowLocalService;
400 }
401
402
407 public ExpandoRowPersistence getExpandoRowPersistence() {
408 return expandoRowPersistence;
409 }
410
411
416 public void setExpandoRowPersistence(
417 ExpandoRowPersistence expandoRowPersistence) {
418 this.expandoRowPersistence = expandoRowPersistence;
419 }
420
421
426 public ExpandoTableLocalService getExpandoTableLocalService() {
427 return expandoTableLocalService;
428 }
429
430
435 public void setExpandoTableLocalService(
436 ExpandoTableLocalService expandoTableLocalService) {
437 this.expandoTableLocalService = expandoTableLocalService;
438 }
439
440
445 public ExpandoTablePersistence getExpandoTablePersistence() {
446 return expandoTablePersistence;
447 }
448
449
454 public void setExpandoTablePersistence(
455 ExpandoTablePersistence expandoTablePersistence) {
456 this.expandoTablePersistence = expandoTablePersistence;
457 }
458
459
464 public ExpandoValueLocalService getExpandoValueLocalService() {
465 return expandoValueLocalService;
466 }
467
468
473 public void setExpandoValueLocalService(
474 ExpandoValueLocalService expandoValueLocalService) {
475 this.expandoValueLocalService = expandoValueLocalService;
476 }
477
478
483 public ExpandoValueService getExpandoValueService() {
484 return expandoValueService;
485 }
486
487
492 public void setExpandoValueService(ExpandoValueService expandoValueService) {
493 this.expandoValueService = expandoValueService;
494 }
495
496
501 public ExpandoValuePersistence getExpandoValuePersistence() {
502 return expandoValuePersistence;
503 }
504
505
510 public void setExpandoValuePersistence(
511 ExpandoValuePersistence expandoValuePersistence) {
512 this.expandoValuePersistence = expandoValuePersistence;
513 }
514
515
520 public CounterLocalService getCounterLocalService() {
521 return counterLocalService;
522 }
523
524
529 public void setCounterLocalService(CounterLocalService counterLocalService) {
530 this.counterLocalService = counterLocalService;
531 }
532
533
538 public ResourceLocalService getResourceLocalService() {
539 return resourceLocalService;
540 }
541
542
547 public void setResourceLocalService(
548 ResourceLocalService resourceLocalService) {
549 this.resourceLocalService = resourceLocalService;
550 }
551
552
557 public ResourceService getResourceService() {
558 return resourceService;
559 }
560
561
566 public void setResourceService(ResourceService resourceService) {
567 this.resourceService = resourceService;
568 }
569
570
575 public ResourcePersistence getResourcePersistence() {
576 return resourcePersistence;
577 }
578
579
584 public void setResourcePersistence(ResourcePersistence resourcePersistence) {
585 this.resourcePersistence = resourcePersistence;
586 }
587
588
593 public ResourceFinder getResourceFinder() {
594 return resourceFinder;
595 }
596
597
602 public void setResourceFinder(ResourceFinder resourceFinder) {
603 this.resourceFinder = resourceFinder;
604 }
605
606
611 public UserLocalService getUserLocalService() {
612 return userLocalService;
613 }
614
615
620 public void setUserLocalService(UserLocalService userLocalService) {
621 this.userLocalService = userLocalService;
622 }
623
624
629 public UserService getUserService() {
630 return userService;
631 }
632
633
638 public void setUserService(UserService userService) {
639 this.userService = userService;
640 }
641
642
647 public UserPersistence getUserPersistence() {
648 return userPersistence;
649 }
650
651
656 public void setUserPersistence(UserPersistence userPersistence) {
657 this.userPersistence = userPersistence;
658 }
659
660
665 public UserFinder getUserFinder() {
666 return userFinder;
667 }
668
669
674 public void setUserFinder(UserFinder userFinder) {
675 this.userFinder = userFinder;
676 }
677
678 public void afterPropertiesSet() {
679 persistedModelLocalServiceRegistry.register("com.liferay.portlet.expando.model.ExpandoRow",
680 expandoRowLocalService);
681 }
682
683 public void destroy() {
684 persistedModelLocalServiceRegistry.unregister(
685 "com.liferay.portlet.expando.model.ExpandoRow");
686 }
687
688
693 public String getBeanIdentifier() {
694 return _beanIdentifier;
695 }
696
697
702 public void setBeanIdentifier(String beanIdentifier) {
703 _beanIdentifier = beanIdentifier;
704 }
705
706 protected ClassLoader getClassLoader() {
707 Class<?> clazz = getClass();
708
709 return clazz.getClassLoader();
710 }
711
712 protected Class<?> getModelClass() {
713 return ExpandoRow.class;
714 }
715
716 protected String getModelClassName() {
717 return ExpandoRow.class.getName();
718 }
719
720
725 protected void runSQL(String sql) throws SystemException {
726 try {
727 DataSource dataSource = expandoRowPersistence.getDataSource();
728
729 SqlUpdate sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(dataSource,
730 sql, new int[0]);
731
732 sqlUpdate.update();
733 }
734 catch (Exception e) {
735 throw new SystemException(e);
736 }
737 }
738
739 @BeanReference(type = ExpandoColumnLocalService.class)
740 protected ExpandoColumnLocalService expandoColumnLocalService;
741 @BeanReference(type = ExpandoColumnService.class)
742 protected ExpandoColumnService expandoColumnService;
743 @BeanReference(type = ExpandoColumnPersistence.class)
744 protected ExpandoColumnPersistence expandoColumnPersistence;
745 @BeanReference(type = ExpandoRowLocalService.class)
746 protected ExpandoRowLocalService expandoRowLocalService;
747 @BeanReference(type = ExpandoRowPersistence.class)
748 protected ExpandoRowPersistence expandoRowPersistence;
749 @BeanReference(type = ExpandoTableLocalService.class)
750 protected ExpandoTableLocalService expandoTableLocalService;
751 @BeanReference(type = ExpandoTablePersistence.class)
752 protected ExpandoTablePersistence expandoTablePersistence;
753 @BeanReference(type = ExpandoValueLocalService.class)
754 protected ExpandoValueLocalService expandoValueLocalService;
755 @BeanReference(type = ExpandoValueService.class)
756 protected ExpandoValueService expandoValueService;
757 @BeanReference(type = ExpandoValuePersistence.class)
758 protected ExpandoValuePersistence expandoValuePersistence;
759 @BeanReference(type = CounterLocalService.class)
760 protected CounterLocalService counterLocalService;
761 @BeanReference(type = ResourceLocalService.class)
762 protected ResourceLocalService resourceLocalService;
763 @BeanReference(type = ResourceService.class)
764 protected ResourceService resourceService;
765 @BeanReference(type = ResourcePersistence.class)
766 protected ResourcePersistence resourcePersistence;
767 @BeanReference(type = ResourceFinder.class)
768 protected ResourceFinder resourceFinder;
769 @BeanReference(type = UserLocalService.class)
770 protected UserLocalService userLocalService;
771 @BeanReference(type = UserService.class)
772 protected UserService userService;
773 @BeanReference(type = UserPersistence.class)
774 protected UserPersistence userPersistence;
775 @BeanReference(type = UserFinder.class)
776 protected UserFinder userFinder;
777 @BeanReference(type = PersistedModelLocalServiceRegistry.class)
778 protected PersistedModelLocalServiceRegistry persistedModelLocalServiceRegistry;
779 private static Log _log = LogFactoryUtil.getLog(ExpandoRowLocalServiceBaseImpl.class);
780 private String _beanIdentifier;
781 }