001
014
015 package com.liferay.counter.service.base;
016
017 import aQute.bnd.annotation.ProviderType;
018
019 import com.liferay.counter.model.Counter;
020 import com.liferay.counter.service.CounterLocalService;
021 import com.liferay.counter.service.persistence.CounterFinder;
022 import com.liferay.counter.service.persistence.CounterPersistence;
023
024 import com.liferay.portal.kernel.bean.BeanReference;
025 import com.liferay.portal.kernel.bean.IdentifiableBean;
026 import com.liferay.portal.kernel.dao.db.DB;
027 import com.liferay.portal.kernel.dao.db.DBFactoryUtil;
028 import com.liferay.portal.kernel.dao.jdbc.SqlUpdate;
029 import com.liferay.portal.kernel.dao.jdbc.SqlUpdateFactoryUtil;
030 import com.liferay.portal.kernel.dao.orm.DynamicQuery;
031 import com.liferay.portal.kernel.dao.orm.DynamicQueryFactoryUtil;
032 import com.liferay.portal.kernel.dao.orm.Projection;
033 import com.liferay.portal.kernel.exception.PortalException;
034 import com.liferay.portal.kernel.exception.SystemException;
035 import com.liferay.portal.kernel.search.Indexable;
036 import com.liferay.portal.kernel.search.IndexableType;
037 import com.liferay.portal.kernel.util.OrderByComparator;
038 import com.liferay.portal.model.PersistedModel;
039 import com.liferay.portal.service.BaseLocalServiceImpl;
040 import com.liferay.portal.service.PersistedModelLocalServiceRegistry;
041 import com.liferay.portal.service.persistence.ClassNamePersistence;
042 import com.liferay.portal.service.persistence.UserFinder;
043 import com.liferay.portal.service.persistence.UserPersistence;
044 import com.liferay.portal.util.PortalUtil;
045
046 import java.io.Serializable;
047
048 import java.util.List;
049
050 import javax.sql.DataSource;
051
052
064 @ProviderType
065 public abstract class CounterLocalServiceBaseImpl extends BaseLocalServiceImpl
066 implements CounterLocalService, IdentifiableBean {
067
072
073
079 @Indexable(type = IndexableType.REINDEX)
080 @Override
081 public Counter addCounter(Counter counter) {
082 counter.setNew(true);
083
084 return counterPersistence.update(counter);
085 }
086
087
093 @Override
094 public Counter createCounter(String name) {
095 return counterPersistence.create(name);
096 }
097
098
105 @Indexable(type = IndexableType.DELETE)
106 @Override
107 public Counter deleteCounter(String name) throws PortalException {
108 return counterPersistence.remove(name);
109 }
110
111
117 @Indexable(type = IndexableType.DELETE)
118 @Override
119 public Counter deleteCounter(Counter counter) {
120 return counterPersistence.remove(counter);
121 }
122
123 @Override
124 public DynamicQuery dynamicQuery() {
125 Class<?> clazz = getClass();
126
127 return DynamicQueryFactoryUtil.forClass(Counter.class,
128 clazz.getClassLoader());
129 }
130
131
137 @Override
138 public <T> List<T> dynamicQuery(DynamicQuery dynamicQuery) {
139 return counterPersistence.findWithDynamicQuery(dynamicQuery);
140 }
141
142
154 @Override
155 public <T> List<T> dynamicQuery(DynamicQuery dynamicQuery, int start,
156 int end) {
157 return counterPersistence.findWithDynamicQuery(dynamicQuery, start, end);
158 }
159
160
173 @Override
174 public <T> List<T> dynamicQuery(DynamicQuery dynamicQuery, int start,
175 int end, OrderByComparator<T> orderByComparator) {
176 return counterPersistence.findWithDynamicQuery(dynamicQuery, start,
177 end, orderByComparator);
178 }
179
180
186 @Override
187 public long dynamicQueryCount(DynamicQuery dynamicQuery) {
188 return counterPersistence.countWithDynamicQuery(dynamicQuery);
189 }
190
191
198 @Override
199 public long dynamicQueryCount(DynamicQuery dynamicQuery,
200 Projection projection) {
201 return counterPersistence.countWithDynamicQuery(dynamicQuery, projection);
202 }
203
204 @Override
205 public Counter fetchCounter(String name) {
206 return counterPersistence.fetchByPrimaryKey(name);
207 }
208
209
216 @Override
217 public Counter getCounter(String name) throws PortalException {
218 return counterPersistence.findByPrimaryKey(name);
219 }
220
221
224 @Override
225 public PersistedModel deletePersistedModel(PersistedModel persistedModel)
226 throws PortalException {
227 return counterLocalService.deleteCounter((Counter)persistedModel);
228 }
229
230 @Override
231 public PersistedModel getPersistedModel(Serializable primaryKeyObj)
232 throws PortalException {
233 return counterPersistence.findByPrimaryKey(primaryKeyObj);
234 }
235
236
247 @Override
248 public List<Counter> getCounters(int start, int end) {
249 return counterPersistence.findAll(start, end);
250 }
251
252
257 @Override
258 public int getCountersCount() {
259 return counterPersistence.countAll();
260 }
261
262
268 @Indexable(type = IndexableType.REINDEX)
269 @Override
270 public Counter updateCounter(Counter counter) {
271 return counterPersistence.update(counter);
272 }
273
274
279 public com.liferay.counter.service.CounterLocalService getCounterLocalService() {
280 return counterLocalService;
281 }
282
283
288 public void setCounterLocalService(
289 com.liferay.counter.service.CounterLocalService counterLocalService) {
290 this.counterLocalService = counterLocalService;
291 }
292
293
298 public CounterPersistence getCounterPersistence() {
299 return counterPersistence;
300 }
301
302
307 public void setCounterPersistence(CounterPersistence counterPersistence) {
308 this.counterPersistence = counterPersistence;
309 }
310
311
316 public CounterFinder getCounterFinder() {
317 return counterFinder;
318 }
319
320
325 public void setCounterFinder(CounterFinder counterFinder) {
326 this.counterFinder = counterFinder;
327 }
328
329
334 public com.liferay.portal.service.ClassNameLocalService getClassNameLocalService() {
335 return classNameLocalService;
336 }
337
338
343 public void setClassNameLocalService(
344 com.liferay.portal.service.ClassNameLocalService classNameLocalService) {
345 this.classNameLocalService = classNameLocalService;
346 }
347
348
353 public com.liferay.portal.service.ClassNameService getClassNameService() {
354 return classNameService;
355 }
356
357
362 public void setClassNameService(
363 com.liferay.portal.service.ClassNameService classNameService) {
364 this.classNameService = classNameService;
365 }
366
367
372 public ClassNamePersistence getClassNamePersistence() {
373 return classNamePersistence;
374 }
375
376
381 public void setClassNamePersistence(
382 ClassNamePersistence classNamePersistence) {
383 this.classNamePersistence = classNamePersistence;
384 }
385
386
391 public com.liferay.portal.service.ResourceLocalService getResourceLocalService() {
392 return resourceLocalService;
393 }
394
395
400 public void setResourceLocalService(
401 com.liferay.portal.service.ResourceLocalService resourceLocalService) {
402 this.resourceLocalService = resourceLocalService;
403 }
404
405
410 public com.liferay.portal.service.UserLocalService getUserLocalService() {
411 return userLocalService;
412 }
413
414
419 public void setUserLocalService(
420 com.liferay.portal.service.UserLocalService userLocalService) {
421 this.userLocalService = userLocalService;
422 }
423
424
429 public com.liferay.portal.service.UserService getUserService() {
430 return userService;
431 }
432
433
438 public void setUserService(
439 com.liferay.portal.service.UserService userService) {
440 this.userService = userService;
441 }
442
443
448 public UserPersistence getUserPersistence() {
449 return userPersistence;
450 }
451
452
457 public void setUserPersistence(UserPersistence userPersistence) {
458 this.userPersistence = userPersistence;
459 }
460
461
466 public UserFinder getUserFinder() {
467 return userFinder;
468 }
469
470
475 public void setUserFinder(UserFinder userFinder) {
476 this.userFinder = userFinder;
477 }
478
479 public void afterPropertiesSet() {
480 persistedModelLocalServiceRegistry.register("com.liferay.counter.model.Counter",
481 counterLocalService);
482 }
483
484 public void destroy() {
485 persistedModelLocalServiceRegistry.unregister(
486 "com.liferay.counter.model.Counter");
487 }
488
489
494 @Override
495 public String getBeanIdentifier() {
496 return _beanIdentifier;
497 }
498
499
504 @Override
505 public void setBeanIdentifier(String beanIdentifier) {
506 _beanIdentifier = beanIdentifier;
507 }
508
509 protected Class<?> getModelClass() {
510 return Counter.class;
511 }
512
513 protected String getModelClassName() {
514 return Counter.class.getName();
515 }
516
517
522 protected void runSQL(String sql) {
523 try {
524 DataSource dataSource = counterPersistence.getDataSource();
525
526 DB db = DBFactoryUtil.getDB();
527
528 sql = db.buildSQL(sql);
529 sql = PortalUtil.transformSQL(sql);
530
531 SqlUpdate sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(dataSource,
532 sql, new int[0]);
533
534 sqlUpdate.update();
535 }
536 catch (Exception e) {
537 throw new SystemException(e);
538 }
539 }
540
541 @BeanReference(type = com.liferay.counter.service.CounterLocalService.class)
542 protected com.liferay.counter.service.CounterLocalService counterLocalService;
543 @BeanReference(type = CounterPersistence.class)
544 protected CounterPersistence counterPersistence;
545 @BeanReference(type = CounterFinder.class)
546 protected CounterFinder counterFinder;
547 @BeanReference(type = com.liferay.portal.service.ClassNameLocalService.class)
548 protected com.liferay.portal.service.ClassNameLocalService classNameLocalService;
549 @BeanReference(type = com.liferay.portal.service.ClassNameService.class)
550 protected com.liferay.portal.service.ClassNameService classNameService;
551 @BeanReference(type = ClassNamePersistence.class)
552 protected ClassNamePersistence classNamePersistence;
553 @BeanReference(type = com.liferay.portal.service.ResourceLocalService.class)
554 protected com.liferay.portal.service.ResourceLocalService resourceLocalService;
555 @BeanReference(type = com.liferay.portal.service.UserLocalService.class)
556 protected com.liferay.portal.service.UserLocalService userLocalService;
557 @BeanReference(type = com.liferay.portal.service.UserService.class)
558 protected com.liferay.portal.service.UserService userService;
559 @BeanReference(type = UserPersistence.class)
560 protected UserPersistence userPersistence;
561 @BeanReference(type = UserFinder.class)
562 protected UserFinder userFinder;
563 @BeanReference(type = PersistedModelLocalServiceRegistry.class)
564 protected PersistedModelLocalServiceRegistry persistedModelLocalServiceRegistry;
565 private String _beanIdentifier;
566 }