001
014
015 package com.liferay.counter.service.base;
016
017 import com.liferay.counter.model.Counter;
018 import com.liferay.counter.service.CounterLocalService;
019 import com.liferay.counter.service.persistence.CounterFinder;
020 import com.liferay.counter.service.persistence.CounterPersistence;
021
022 import com.liferay.portal.kernel.bean.BeanReference;
023 import com.liferay.portal.kernel.bean.IdentifiableBean;
024 import com.liferay.portal.kernel.dao.jdbc.SqlUpdate;
025 import com.liferay.portal.kernel.dao.jdbc.SqlUpdateFactoryUtil;
026 import com.liferay.portal.kernel.dao.orm.DynamicQuery;
027 import com.liferay.portal.kernel.dao.orm.DynamicQueryFactoryUtil;
028 import com.liferay.portal.kernel.exception.PortalException;
029 import com.liferay.portal.kernel.exception.SystemException;
030 import com.liferay.portal.kernel.search.Indexable;
031 import com.liferay.portal.kernel.search.IndexableType;
032 import com.liferay.portal.kernel.util.OrderByComparator;
033 import com.liferay.portal.model.PersistedModel;
034 import com.liferay.portal.service.BaseLocalServiceImpl;
035 import com.liferay.portal.service.PersistedModelLocalServiceRegistry;
036 import com.liferay.portal.service.ResourceLocalService;
037 import com.liferay.portal.service.UserLocalService;
038 import com.liferay.portal.service.UserService;
039 import com.liferay.portal.service.persistence.UserFinder;
040 import com.liferay.portal.service.persistence.UserPersistence;
041
042 import java.io.Serializable;
043
044 import java.util.List;
045
046 import javax.sql.DataSource;
047
048
060 public abstract class CounterLocalServiceBaseImpl extends BaseLocalServiceImpl
061 implements CounterLocalService, IdentifiableBean {
062
067
068
075 @Indexable(type = IndexableType.REINDEX)
076 public Counter addCounter(Counter counter) throws SystemException {
077 counter.setNew(true);
078
079 return counterPersistence.update(counter);
080 }
081
082
088 public Counter createCounter(String name) {
089 return counterPersistence.create(name);
090 }
091
092
100 @Indexable(type = IndexableType.DELETE)
101 public Counter deleteCounter(String name)
102 throws PortalException, SystemException {
103 return counterPersistence.remove(name);
104 }
105
106
113 @Indexable(type = IndexableType.DELETE)
114 public Counter deleteCounter(Counter counter) throws SystemException {
115 return counterPersistence.remove(counter);
116 }
117
118 public DynamicQuery dynamicQuery() {
119 Class<?> clazz = getClass();
120
121 return DynamicQueryFactoryUtil.forClass(Counter.class,
122 clazz.getClassLoader());
123 }
124
125
132 @SuppressWarnings("rawtypes")
133 public List dynamicQuery(DynamicQuery dynamicQuery)
134 throws SystemException {
135 return counterPersistence.findWithDynamicQuery(dynamicQuery);
136 }
137
138
151 @SuppressWarnings("rawtypes")
152 public List dynamicQuery(DynamicQuery dynamicQuery, int start, int end)
153 throws SystemException {
154 return counterPersistence.findWithDynamicQuery(dynamicQuery, start, end);
155 }
156
157
171 @SuppressWarnings("rawtypes")
172 public List dynamicQuery(DynamicQuery dynamicQuery, int start, int end,
173 OrderByComparator orderByComparator) throws SystemException {
174 return counterPersistence.findWithDynamicQuery(dynamicQuery, start,
175 end, orderByComparator);
176 }
177
178
185 public long dynamicQueryCount(DynamicQuery dynamicQuery)
186 throws SystemException {
187 return counterPersistence.countWithDynamicQuery(dynamicQuery);
188 }
189
190 public Counter fetchCounter(String name) throws SystemException {
191 return counterPersistence.fetchByPrimaryKey(name);
192 }
193
194
202 public Counter getCounter(String name)
203 throws PortalException, SystemException {
204 return counterPersistence.findByPrimaryKey(name);
205 }
206
207 public PersistedModel getPersistedModel(Serializable primaryKeyObj)
208 throws PortalException, SystemException {
209 return counterPersistence.findByPrimaryKey(primaryKeyObj);
210 }
211
212
224 public List<Counter> getCounters(int start, int end)
225 throws SystemException {
226 return counterPersistence.findAll(start, end);
227 }
228
229
235 public int getCountersCount() throws SystemException {
236 return counterPersistence.countAll();
237 }
238
239
246 @Indexable(type = IndexableType.REINDEX)
247 public Counter updateCounter(Counter counter) throws SystemException {
248 return counterPersistence.update(counter);
249 }
250
251
256 public CounterLocalService getCounterLocalService() {
257 return counterLocalService;
258 }
259
260
265 public void setCounterLocalService(CounterLocalService counterLocalService) {
266 this.counterLocalService = counterLocalService;
267 }
268
269
274 public CounterPersistence getCounterPersistence() {
275 return counterPersistence;
276 }
277
278
283 public void setCounterPersistence(CounterPersistence counterPersistence) {
284 this.counterPersistence = counterPersistence;
285 }
286
287
292 public CounterFinder getCounterFinder() {
293 return counterFinder;
294 }
295
296
301 public void setCounterFinder(CounterFinder counterFinder) {
302 this.counterFinder = counterFinder;
303 }
304
305
310 public ResourceLocalService getResourceLocalService() {
311 return resourceLocalService;
312 }
313
314
319 public void setResourceLocalService(
320 ResourceLocalService resourceLocalService) {
321 this.resourceLocalService = resourceLocalService;
322 }
323
324
329 public UserLocalService getUserLocalService() {
330 return userLocalService;
331 }
332
333
338 public void setUserLocalService(UserLocalService userLocalService) {
339 this.userLocalService = userLocalService;
340 }
341
342
347 public UserService getUserService() {
348 return userService;
349 }
350
351
356 public void setUserService(UserService userService) {
357 this.userService = userService;
358 }
359
360
365 public UserPersistence getUserPersistence() {
366 return userPersistence;
367 }
368
369
374 public void setUserPersistence(UserPersistence userPersistence) {
375 this.userPersistence = userPersistence;
376 }
377
378
383 public UserFinder getUserFinder() {
384 return userFinder;
385 }
386
387
392 public void setUserFinder(UserFinder userFinder) {
393 this.userFinder = userFinder;
394 }
395
396 public void afterPropertiesSet() {
397 persistedModelLocalServiceRegistry.register("com.liferay.counter.model.Counter",
398 counterLocalService);
399 }
400
401 public void destroy() {
402 persistedModelLocalServiceRegistry.unregister(
403 "com.liferay.counter.model.Counter");
404 }
405
406
411 public String getBeanIdentifier() {
412 return _beanIdentifier;
413 }
414
415
420 public void setBeanIdentifier(String beanIdentifier) {
421 _beanIdentifier = beanIdentifier;
422 }
423
424 protected Class<?> getModelClass() {
425 return Counter.class;
426 }
427
428 protected String getModelClassName() {
429 return Counter.class.getName();
430 }
431
432
437 protected void runSQL(String sql) throws SystemException {
438 try {
439 DataSource dataSource = counterPersistence.getDataSource();
440
441 SqlUpdate sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(dataSource,
442 sql, new int[0]);
443
444 sqlUpdate.update();
445 }
446 catch (Exception e) {
447 throw new SystemException(e);
448 }
449 }
450
451 @BeanReference(type = CounterLocalService.class)
452 protected CounterLocalService counterLocalService;
453 @BeanReference(type = CounterPersistence.class)
454 protected CounterPersistence counterPersistence;
455 @BeanReference(type = CounterFinder.class)
456 protected CounterFinder counterFinder;
457 @BeanReference(type = ResourceLocalService.class)
458 protected ResourceLocalService resourceLocalService;
459 @BeanReference(type = UserLocalService.class)
460 protected UserLocalService userLocalService;
461 @BeanReference(type = UserService.class)
462 protected UserService userService;
463 @BeanReference(type = UserPersistence.class)
464 protected UserPersistence userPersistence;
465 @BeanReference(type = UserFinder.class)
466 protected UserFinder userFinder;
467 @BeanReference(type = PersistedModelLocalServiceRegistry.class)
468 protected PersistedModelLocalServiceRegistry persistedModelLocalServiceRegistry;
469 private String _beanIdentifier;
470 }