001    /**
002     * Copyright (c) 2000-2013 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
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.dao.orm.Projection;
029    import com.liferay.portal.kernel.exception.PortalException;
030    import com.liferay.portal.kernel.exception.SystemException;
031    import com.liferay.portal.kernel.search.Indexable;
032    import com.liferay.portal.kernel.search.IndexableType;
033    import com.liferay.portal.kernel.util.OrderByComparator;
034    import com.liferay.portal.model.PersistedModel;
035    import com.liferay.portal.service.BaseLocalServiceImpl;
036    import com.liferay.portal.service.PersistedModelLocalServiceRegistry;
037    import com.liferay.portal.service.persistence.UserFinder;
038    import com.liferay.portal.service.persistence.UserPersistence;
039    
040    import java.io.Serializable;
041    
042    import java.util.List;
043    
044    import javax.sql.DataSource;
045    
046    /**
047     * Provides the base implementation for the counter local service.
048     *
049     * <p>
050     * This implementation exists only as a container for the default service methods generated by ServiceBuilder. All custom service methods should be put in {@link com.liferay.counter.service.impl.CounterLocalServiceImpl}.
051     * </p>
052     *
053     * @author Brian Wing Shun Chan
054     * @see com.liferay.counter.service.impl.CounterLocalServiceImpl
055     * @see com.liferay.counter.service.CounterLocalServiceUtil
056     * @generated
057     */
058    public abstract class CounterLocalServiceBaseImpl extends BaseLocalServiceImpl
059            implements CounterLocalService, IdentifiableBean {
060            /*
061             * NOTE FOR DEVELOPERS:
062             *
063             * Never modify or reference this class directly. Always use {@link com.liferay.counter.service.CounterLocalServiceUtil} to access the counter local service.
064             */
065    
066            /**
067             * Adds the counter to the database. Also notifies the appropriate model listeners.
068             *
069             * @param counter the counter
070             * @return the counter that was added
071             * @throws SystemException if a system exception occurred
072             */
073            @Indexable(type = IndexableType.REINDEX)
074            @Override
075            public Counter addCounter(Counter counter) throws SystemException {
076                    counter.setNew(true);
077    
078                    return counterPersistence.update(counter);
079            }
080    
081            /**
082             * Creates a new counter with the primary key. Does not add the counter to the database.
083             *
084             * @param name the primary key for the new counter
085             * @return the new counter
086             */
087            @Override
088            public Counter createCounter(String name) {
089                    return counterPersistence.create(name);
090            }
091    
092            /**
093             * Deletes the counter with the primary key from the database. Also notifies the appropriate model listeners.
094             *
095             * @param name the primary key of the counter
096             * @return the counter that was removed
097             * @throws PortalException if a counter with the primary key could not be found
098             * @throws SystemException if a system exception occurred
099             */
100            @Indexable(type = IndexableType.DELETE)
101            @Override
102            public Counter deleteCounter(String name)
103                    throws PortalException, SystemException {
104                    return counterPersistence.remove(name);
105            }
106    
107            /**
108             * Deletes the counter from the database. Also notifies the appropriate model listeners.
109             *
110             * @param counter the counter
111             * @return the counter that was removed
112             * @throws SystemException if a system exception occurred
113             */
114            @Indexable(type = IndexableType.DELETE)
115            @Override
116            public Counter deleteCounter(Counter counter) throws SystemException {
117                    return counterPersistence.remove(counter);
118            }
119    
120            @Override
121            public DynamicQuery dynamicQuery() {
122                    Class<?> clazz = getClass();
123    
124                    return DynamicQueryFactoryUtil.forClass(Counter.class,
125                            clazz.getClassLoader());
126            }
127    
128            /**
129             * Performs a dynamic query on the database and returns the matching rows.
130             *
131             * @param dynamicQuery the dynamic query
132             * @return the matching rows
133             * @throws SystemException if a system exception occurred
134             */
135            @Override
136            @SuppressWarnings("rawtypes")
137            public List dynamicQuery(DynamicQuery dynamicQuery)
138                    throws SystemException {
139                    return counterPersistence.findWithDynamicQuery(dynamicQuery);
140            }
141    
142            /**
143             * Performs a dynamic query on the database and returns a range of the matching rows.
144             *
145             * <p>
146             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.counter.model.impl.CounterModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
147             * </p>
148             *
149             * @param dynamicQuery the dynamic query
150             * @param start the lower bound of the range of model instances
151             * @param end the upper bound of the range of model instances (not inclusive)
152             * @return the range of matching rows
153             * @throws SystemException if a system exception occurred
154             */
155            @Override
156            @SuppressWarnings("rawtypes")
157            public List dynamicQuery(DynamicQuery dynamicQuery, int start, int end)
158                    throws SystemException {
159                    return counterPersistence.findWithDynamicQuery(dynamicQuery, start, end);
160            }
161    
162            /**
163             * Performs a dynamic query on the database and returns an ordered range of the matching rows.
164             *
165             * <p>
166             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.counter.model.impl.CounterModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
167             * </p>
168             *
169             * @param dynamicQuery the dynamic query
170             * @param start the lower bound of the range of model instances
171             * @param end the upper bound of the range of model instances (not inclusive)
172             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
173             * @return the ordered range of matching rows
174             * @throws SystemException if a system exception occurred
175             */
176            @Override
177            @SuppressWarnings("rawtypes")
178            public List dynamicQuery(DynamicQuery dynamicQuery, int start, int end,
179                    OrderByComparator orderByComparator) throws SystemException {
180                    return counterPersistence.findWithDynamicQuery(dynamicQuery, start,
181                            end, orderByComparator);
182            }
183    
184            /**
185             * Returns the number of rows that match the dynamic query.
186             *
187             * @param dynamicQuery the dynamic query
188             * @return the number of rows that match the dynamic query
189             * @throws SystemException if a system exception occurred
190             */
191            @Override
192            public long dynamicQueryCount(DynamicQuery dynamicQuery)
193                    throws SystemException {
194                    return counterPersistence.countWithDynamicQuery(dynamicQuery);
195            }
196    
197            /**
198             * Returns the number of rows that match the dynamic query.
199             *
200             * @param dynamicQuery the dynamic query
201             * @param projection the projection to apply to the query
202             * @return the number of rows that match the dynamic query
203             * @throws SystemException if a system exception occurred
204             */
205            @Override
206            public long dynamicQueryCount(DynamicQuery dynamicQuery,
207                    Projection projection) throws SystemException {
208                    return counterPersistence.countWithDynamicQuery(dynamicQuery, projection);
209            }
210    
211            @Override
212            public Counter fetchCounter(String name) throws SystemException {
213                    return counterPersistence.fetchByPrimaryKey(name);
214            }
215    
216            /**
217             * Returns the counter with the primary key.
218             *
219             * @param name the primary key of the counter
220             * @return the counter
221             * @throws PortalException if a counter with the primary key could not be found
222             * @throws SystemException if a system exception occurred
223             */
224            @Override
225            public Counter getCounter(String name)
226                    throws PortalException, SystemException {
227                    return counterPersistence.findByPrimaryKey(name);
228            }
229    
230            @Override
231            public PersistedModel getPersistedModel(Serializable primaryKeyObj)
232                    throws PortalException, SystemException {
233                    return counterPersistence.findByPrimaryKey(primaryKeyObj);
234            }
235    
236            /**
237             * Returns a range of all the counters.
238             *
239             * <p>
240             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.counter.model.impl.CounterModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
241             * </p>
242             *
243             * @param start the lower bound of the range of counters
244             * @param end the upper bound of the range of counters (not inclusive)
245             * @return the range of counters
246             * @throws SystemException if a system exception occurred
247             */
248            @Override
249            public List<Counter> getCounters(int start, int end)
250                    throws SystemException {
251                    return counterPersistence.findAll(start, end);
252            }
253    
254            /**
255             * Returns the number of counters.
256             *
257             * @return the number of counters
258             * @throws SystemException if a system exception occurred
259             */
260            @Override
261            public int getCountersCount() throws SystemException {
262                    return counterPersistence.countAll();
263            }
264    
265            /**
266             * Updates the counter in the database or adds it if it does not yet exist. Also notifies the appropriate model listeners.
267             *
268             * @param counter the counter
269             * @return the counter that was updated
270             * @throws SystemException if a system exception occurred
271             */
272            @Indexable(type = IndexableType.REINDEX)
273            @Override
274            public Counter updateCounter(Counter counter) throws SystemException {
275                    return counterPersistence.update(counter);
276            }
277    
278            /**
279             * Returns the counter local service.
280             *
281             * @return the counter local service
282             */
283            public com.liferay.counter.service.CounterLocalService getCounterLocalService() {
284                    return counterLocalService;
285            }
286    
287            /**
288             * Sets the counter local service.
289             *
290             * @param counterLocalService the counter local service
291             */
292            public void setCounterLocalService(
293                    com.liferay.counter.service.CounterLocalService counterLocalService) {
294                    this.counterLocalService = counterLocalService;
295            }
296    
297            /**
298             * Returns the counter persistence.
299             *
300             * @return the counter persistence
301             */
302            public CounterPersistence getCounterPersistence() {
303                    return counterPersistence;
304            }
305    
306            /**
307             * Sets the counter persistence.
308             *
309             * @param counterPersistence the counter persistence
310             */
311            public void setCounterPersistence(CounterPersistence counterPersistence) {
312                    this.counterPersistence = counterPersistence;
313            }
314    
315            /**
316             * Returns the counter finder.
317             *
318             * @return the counter finder
319             */
320            public CounterFinder getCounterFinder() {
321                    return counterFinder;
322            }
323    
324            /**
325             * Sets the counter finder.
326             *
327             * @param counterFinder the counter finder
328             */
329            public void setCounterFinder(CounterFinder counterFinder) {
330                    this.counterFinder = counterFinder;
331            }
332    
333            /**
334             * Returns the resource local service.
335             *
336             * @return the resource local service
337             */
338            public com.liferay.portal.service.ResourceLocalService getResourceLocalService() {
339                    return resourceLocalService;
340            }
341    
342            /**
343             * Sets the resource local service.
344             *
345             * @param resourceLocalService the resource local service
346             */
347            public void setResourceLocalService(
348                    com.liferay.portal.service.ResourceLocalService resourceLocalService) {
349                    this.resourceLocalService = resourceLocalService;
350            }
351    
352            /**
353             * Returns the user local service.
354             *
355             * @return the user local service
356             */
357            public com.liferay.portal.service.UserLocalService getUserLocalService() {
358                    return userLocalService;
359            }
360    
361            /**
362             * Sets the user local service.
363             *
364             * @param userLocalService the user local service
365             */
366            public void setUserLocalService(
367                    com.liferay.portal.service.UserLocalService userLocalService) {
368                    this.userLocalService = userLocalService;
369            }
370    
371            /**
372             * Returns the user remote service.
373             *
374             * @return the user remote service
375             */
376            public com.liferay.portal.service.UserService getUserService() {
377                    return userService;
378            }
379    
380            /**
381             * Sets the user remote service.
382             *
383             * @param userService the user remote service
384             */
385            public void setUserService(
386                    com.liferay.portal.service.UserService userService) {
387                    this.userService = userService;
388            }
389    
390            /**
391             * Returns the user persistence.
392             *
393             * @return the user persistence
394             */
395            public UserPersistence getUserPersistence() {
396                    return userPersistence;
397            }
398    
399            /**
400             * Sets the user persistence.
401             *
402             * @param userPersistence the user persistence
403             */
404            public void setUserPersistence(UserPersistence userPersistence) {
405                    this.userPersistence = userPersistence;
406            }
407    
408            /**
409             * Returns the user finder.
410             *
411             * @return the user finder
412             */
413            public UserFinder getUserFinder() {
414                    return userFinder;
415            }
416    
417            /**
418             * Sets the user finder.
419             *
420             * @param userFinder the user finder
421             */
422            public void setUserFinder(UserFinder userFinder) {
423                    this.userFinder = userFinder;
424            }
425    
426            public void afterPropertiesSet() {
427                    persistedModelLocalServiceRegistry.register("com.liferay.counter.model.Counter",
428                            counterLocalService);
429            }
430    
431            public void destroy() {
432                    persistedModelLocalServiceRegistry.unregister(
433                            "com.liferay.counter.model.Counter");
434            }
435    
436            /**
437             * Returns the Spring bean ID for this bean.
438             *
439             * @return the Spring bean ID for this bean
440             */
441            @Override
442            public String getBeanIdentifier() {
443                    return _beanIdentifier;
444            }
445    
446            /**
447             * Sets the Spring bean ID for this bean.
448             *
449             * @param beanIdentifier the Spring bean ID for this bean
450             */
451            @Override
452            public void setBeanIdentifier(String beanIdentifier) {
453                    _beanIdentifier = beanIdentifier;
454            }
455    
456            protected Class<?> getModelClass() {
457                    return Counter.class;
458            }
459    
460            protected String getModelClassName() {
461                    return Counter.class.getName();
462            }
463    
464            /**
465             * Performs an SQL query.
466             *
467             * @param sql the sql query
468             */
469            protected void runSQL(String sql) throws SystemException {
470                    try {
471                            DataSource dataSource = counterPersistence.getDataSource();
472    
473                            SqlUpdate sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(dataSource,
474                                            sql, new int[0]);
475    
476                            sqlUpdate.update();
477                    }
478                    catch (Exception e) {
479                            throw new SystemException(e);
480                    }
481            }
482    
483            @BeanReference(type = com.liferay.counter.service.CounterLocalService.class)
484            protected com.liferay.counter.service.CounterLocalService counterLocalService;
485            @BeanReference(type = CounterPersistence.class)
486            protected CounterPersistence counterPersistence;
487            @BeanReference(type = CounterFinder.class)
488            protected CounterFinder counterFinder;
489            @BeanReference(type = com.liferay.portal.service.ResourceLocalService.class)
490            protected com.liferay.portal.service.ResourceLocalService resourceLocalService;
491            @BeanReference(type = com.liferay.portal.service.UserLocalService.class)
492            protected com.liferay.portal.service.UserLocalService userLocalService;
493            @BeanReference(type = com.liferay.portal.service.UserService.class)
494            protected com.liferay.portal.service.UserService userService;
495            @BeanReference(type = UserPersistence.class)
496            protected UserPersistence userPersistence;
497            @BeanReference(type = UserFinder.class)
498            protected UserFinder userFinder;
499            @BeanReference(type = PersistedModelLocalServiceRegistry.class)
500            protected PersistedModelLocalServiceRegistry persistedModelLocalServiceRegistry;
501            private String _beanIdentifier;
502    }