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.ResourceService;
038 import com.liferay.portal.service.UserLocalService;
039 import com.liferay.portal.service.UserService;
040 import com.liferay.portal.service.persistence.ResourceFinder;
041 import com.liferay.portal.service.persistence.ResourcePersistence;
042 import com.liferay.portal.service.persistence.UserFinder;
043 import com.liferay.portal.service.persistence.UserPersistence;
044
045 import java.io.Serializable;
046
047 import java.util.List;
048
049 import javax.sql.DataSource;
050
051
063 public abstract class CounterLocalServiceBaseImpl extends BaseLocalServiceImpl
064 implements CounterLocalService, IdentifiableBean {
065
070
071
078 @Indexable(type = IndexableType.REINDEX)
079 public Counter addCounter(Counter counter) throws SystemException {
080 counter.setNew(true);
081
082 return counterPersistence.update(counter, false);
083 }
084
085
091 public Counter createCounter(String name) {
092 return counterPersistence.create(name);
093 }
094
095
103 @Indexable(type = IndexableType.DELETE)
104 public Counter deleteCounter(String name)
105 throws PortalException, SystemException {
106 return counterPersistence.remove(name);
107 }
108
109
116 @Indexable(type = IndexableType.DELETE)
117 public Counter deleteCounter(Counter counter) throws SystemException {
118 return counterPersistence.remove(counter);
119 }
120
121 public DynamicQuery dynamicQuery() {
122 Class<?> clazz = getClass();
123
124 return DynamicQueryFactoryUtil.forClass(Counter.class,
125 clazz.getClassLoader());
126 }
127
128
135 @SuppressWarnings("rawtypes")
136 public List dynamicQuery(DynamicQuery dynamicQuery)
137 throws SystemException {
138 return counterPersistence.findWithDynamicQuery(dynamicQuery);
139 }
140
141
154 @SuppressWarnings("rawtypes")
155 public List dynamicQuery(DynamicQuery dynamicQuery, int start, int end)
156 throws SystemException {
157 return counterPersistence.findWithDynamicQuery(dynamicQuery, start, end);
158 }
159
160
174 @SuppressWarnings("rawtypes")
175 public List dynamicQuery(DynamicQuery dynamicQuery, int start, int end,
176 OrderByComparator orderByComparator) throws SystemException {
177 return counterPersistence.findWithDynamicQuery(dynamicQuery, start,
178 end, orderByComparator);
179 }
180
181
188 public long dynamicQueryCount(DynamicQuery dynamicQuery)
189 throws SystemException {
190 return counterPersistence.countWithDynamicQuery(dynamicQuery);
191 }
192
193 public Counter fetchCounter(String name) throws SystemException {
194 return counterPersistence.fetchByPrimaryKey(name);
195 }
196
197
205 public Counter getCounter(String name)
206 throws PortalException, SystemException {
207 return counterPersistence.findByPrimaryKey(name);
208 }
209
210 public PersistedModel getPersistedModel(Serializable primaryKeyObj)
211 throws PortalException, SystemException {
212 return counterPersistence.findByPrimaryKey(primaryKeyObj);
213 }
214
215
227 public List<Counter> getCounters(int start, int end)
228 throws SystemException {
229 return counterPersistence.findAll(start, end);
230 }
231
232
238 public int getCountersCount() throws SystemException {
239 return counterPersistence.countAll();
240 }
241
242
249 @Indexable(type = IndexableType.REINDEX)
250 public Counter updateCounter(Counter counter) throws SystemException {
251 return updateCounter(counter, true);
252 }
253
254
262 @Indexable(type = IndexableType.REINDEX)
263 public Counter updateCounter(Counter counter, boolean merge)
264 throws SystemException {
265 counter.setNew(false);
266
267 return counterPersistence.update(counter, merge);
268 }
269
270
275 public CounterLocalService getCounterLocalService() {
276 return counterLocalService;
277 }
278
279
284 public void setCounterLocalService(CounterLocalService counterLocalService) {
285 this.counterLocalService = counterLocalService;
286 }
287
288
293 public CounterPersistence getCounterPersistence() {
294 return counterPersistence;
295 }
296
297
302 public void setCounterPersistence(CounterPersistence counterPersistence) {
303 this.counterPersistence = counterPersistence;
304 }
305
306
311 public CounterFinder getCounterFinder() {
312 return counterFinder;
313 }
314
315
320 public void setCounterFinder(CounterFinder counterFinder) {
321 this.counterFinder = counterFinder;
322 }
323
324
329 public ResourceLocalService getResourceLocalService() {
330 return resourceLocalService;
331 }
332
333
338 public void setResourceLocalService(
339 ResourceLocalService resourceLocalService) {
340 this.resourceLocalService = resourceLocalService;
341 }
342
343
348 public ResourceService getResourceService() {
349 return resourceService;
350 }
351
352
357 public void setResourceService(ResourceService resourceService) {
358 this.resourceService = resourceService;
359 }
360
361
366 public ResourcePersistence getResourcePersistence() {
367 return resourcePersistence;
368 }
369
370
375 public void setResourcePersistence(ResourcePersistence resourcePersistence) {
376 this.resourcePersistence = resourcePersistence;
377 }
378
379
384 public ResourceFinder getResourceFinder() {
385 return resourceFinder;
386 }
387
388
393 public void setResourceFinder(ResourceFinder resourceFinder) {
394 this.resourceFinder = resourceFinder;
395 }
396
397
402 public UserLocalService getUserLocalService() {
403 return userLocalService;
404 }
405
406
411 public void setUserLocalService(UserLocalService userLocalService) {
412 this.userLocalService = userLocalService;
413 }
414
415
420 public UserService getUserService() {
421 return userService;
422 }
423
424
429 public void setUserService(UserService userService) {
430 this.userService = userService;
431 }
432
433
438 public UserPersistence getUserPersistence() {
439 return userPersistence;
440 }
441
442
447 public void setUserPersistence(UserPersistence userPersistence) {
448 this.userPersistence = userPersistence;
449 }
450
451
456 public UserFinder getUserFinder() {
457 return userFinder;
458 }
459
460
465 public void setUserFinder(UserFinder userFinder) {
466 this.userFinder = userFinder;
467 }
468
469 public void afterPropertiesSet() {
470 persistedModelLocalServiceRegistry.register("com.liferay.counter.model.Counter",
471 counterLocalService);
472 }
473
474 public void destroy() {
475 persistedModelLocalServiceRegistry.unregister(
476 "com.liferay.counter.model.Counter");
477 }
478
479
484 public String getBeanIdentifier() {
485 return _beanIdentifier;
486 }
487
488
493 public void setBeanIdentifier(String beanIdentifier) {
494 _beanIdentifier = beanIdentifier;
495 }
496
497 protected Class<?> getModelClass() {
498 return Counter.class;
499 }
500
501 protected String getModelClassName() {
502 return Counter.class.getName();
503 }
504
505
510 protected void runSQL(String sql) throws SystemException {
511 try {
512 DataSource dataSource = counterPersistence.getDataSource();
513
514 SqlUpdate sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(dataSource,
515 sql, new int[0]);
516
517 sqlUpdate.update();
518 }
519 catch (Exception e) {
520 throw new SystemException(e);
521 }
522 }
523
524 @BeanReference(type = CounterLocalService.class)
525 protected CounterLocalService counterLocalService;
526 @BeanReference(type = CounterPersistence.class)
527 protected CounterPersistence counterPersistence;
528 @BeanReference(type = CounterFinder.class)
529 protected CounterFinder counterFinder;
530 @BeanReference(type = ResourceLocalService.class)
531 protected ResourceLocalService resourceLocalService;
532 @BeanReference(type = ResourceService.class)
533 protected ResourceService resourceService;
534 @BeanReference(type = ResourcePersistence.class)
535 protected ResourcePersistence resourcePersistence;
536 @BeanReference(type = ResourceFinder.class)
537 protected ResourceFinder resourceFinder;
538 @BeanReference(type = UserLocalService.class)
539 protected UserLocalService userLocalService;
540 @BeanReference(type = UserService.class)
541 protected UserService userService;
542 @BeanReference(type = UserPersistence.class)
543 protected UserPersistence userPersistence;
544 @BeanReference(type = UserFinder.class)
545 protected UserFinder userFinder;
546 @BeanReference(type = PersistedModelLocalServiceRegistry.class)
547 protected PersistedModelLocalServiceRegistry persistedModelLocalServiceRegistry;
548 private String _beanIdentifier;
549 }