001    /**
002     * Copyright (c) 2000-present 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.portal.service.base;
016    
017    import aQute.bnd.annotation.ProviderType;
018    
019    import com.liferay.portal.kernel.bean.BeanReference;
020    import com.liferay.portal.kernel.bean.IdentifiableBean;
021    import com.liferay.portal.kernel.dao.db.DB;
022    import com.liferay.portal.kernel.dao.db.DBFactoryUtil;
023    import com.liferay.portal.kernel.dao.jdbc.SqlUpdate;
024    import com.liferay.portal.kernel.dao.jdbc.SqlUpdateFactoryUtil;
025    import com.liferay.portal.kernel.dao.orm.ActionableDynamicQuery;
026    import com.liferay.portal.kernel.dao.orm.DefaultActionableDynamicQuery;
027    import com.liferay.portal.kernel.dao.orm.DynamicQuery;
028    import com.liferay.portal.kernel.dao.orm.DynamicQueryFactoryUtil;
029    import com.liferay.portal.kernel.dao.orm.Projection;
030    import com.liferay.portal.kernel.exception.PortalException;
031    import com.liferay.portal.kernel.exception.SystemException;
032    import com.liferay.portal.kernel.search.Indexable;
033    import com.liferay.portal.kernel.search.IndexableType;
034    import com.liferay.portal.kernel.util.OrderByComparator;
035    import com.liferay.portal.model.PersistedModel;
036    import com.liferay.portal.model.Release;
037    import com.liferay.portal.service.BaseLocalServiceImpl;
038    import com.liferay.portal.service.PersistedModelLocalServiceRegistry;
039    import com.liferay.portal.service.ReleaseLocalService;
040    import com.liferay.portal.service.persistence.ReleasePersistence;
041    import com.liferay.portal.util.PortalUtil;
042    
043    import java.io.Serializable;
044    
045    import java.util.List;
046    
047    import javax.sql.DataSource;
048    
049    /**
050     * Provides the base implementation for the release local service.
051     *
052     * <p>
053     * 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.portal.service.impl.ReleaseLocalServiceImpl}.
054     * </p>
055     *
056     * @author Brian Wing Shun Chan
057     * @see com.liferay.portal.service.impl.ReleaseLocalServiceImpl
058     * @see com.liferay.portal.service.ReleaseLocalServiceUtil
059     * @generated
060     */
061    @ProviderType
062    public abstract class ReleaseLocalServiceBaseImpl extends BaseLocalServiceImpl
063            implements ReleaseLocalService, IdentifiableBean {
064            /*
065             * NOTE FOR DEVELOPERS:
066             *
067             * Never modify or reference this class directly. Always use {@link com.liferay.portal.service.ReleaseLocalServiceUtil} to access the release local service.
068             */
069    
070            /**
071             * Adds the release to the database. Also notifies the appropriate model listeners.
072             *
073             * @param release the release
074             * @return the release that was added
075             */
076            @Indexable(type = IndexableType.REINDEX)
077            @Override
078            public Release addRelease(Release release) {
079                    release.setNew(true);
080    
081                    return releasePersistence.update(release);
082            }
083    
084            /**
085             * Creates a new release with the primary key. Does not add the release to the database.
086             *
087             * @param releaseId the primary key for the new release
088             * @return the new release
089             */
090            @Override
091            public Release createRelease(long releaseId) {
092                    return releasePersistence.create(releaseId);
093            }
094    
095            /**
096             * Deletes the release with the primary key from the database. Also notifies the appropriate model listeners.
097             *
098             * @param releaseId the primary key of the release
099             * @return the release that was removed
100             * @throws PortalException if a release with the primary key could not be found
101             */
102            @Indexable(type = IndexableType.DELETE)
103            @Override
104            public Release deleteRelease(long releaseId) throws PortalException {
105                    return releasePersistence.remove(releaseId);
106            }
107    
108            /**
109             * Deletes the release from the database. Also notifies the appropriate model listeners.
110             *
111             * @param release the release
112             * @return the release that was removed
113             */
114            @Indexable(type = IndexableType.DELETE)
115            @Override
116            public Release deleteRelease(Release release) {
117                    return releasePersistence.remove(release);
118            }
119    
120            @Override
121            public DynamicQuery dynamicQuery() {
122                    Class<?> clazz = getClass();
123    
124                    return DynamicQueryFactoryUtil.forClass(Release.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             */
134            @Override
135            public <T> List<T> dynamicQuery(DynamicQuery dynamicQuery) {
136                    return releasePersistence.findWithDynamicQuery(dynamicQuery);
137            }
138    
139            /**
140             * Performs a dynamic query on the database and returns a range of the matching rows.
141             *
142             * <p>
143             * 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.portal.model.impl.ReleaseModelImpl}. 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.
144             * </p>
145             *
146             * @param dynamicQuery the dynamic query
147             * @param start the lower bound of the range of model instances
148             * @param end the upper bound of the range of model instances (not inclusive)
149             * @return the range of matching rows
150             */
151            @Override
152            public <T> List<T> dynamicQuery(DynamicQuery dynamicQuery, int start,
153                    int end) {
154                    return releasePersistence.findWithDynamicQuery(dynamicQuery, start, end);
155            }
156    
157            /**
158             * Performs a dynamic query on the database and returns an ordered range of the matching rows.
159             *
160             * <p>
161             * 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.portal.model.impl.ReleaseModelImpl}. 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.
162             * </p>
163             *
164             * @param dynamicQuery the dynamic query
165             * @param start the lower bound of the range of model instances
166             * @param end the upper bound of the range of model instances (not inclusive)
167             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
168             * @return the ordered range of matching rows
169             */
170            @Override
171            public <T> List<T> dynamicQuery(DynamicQuery dynamicQuery, int start,
172                    int end, OrderByComparator<T> orderByComparator) {
173                    return releasePersistence.findWithDynamicQuery(dynamicQuery, start,
174                            end, orderByComparator);
175            }
176    
177            /**
178             * Returns the number of rows matching the dynamic query.
179             *
180             * @param dynamicQuery the dynamic query
181             * @return the number of rows matching the dynamic query
182             */
183            @Override
184            public long dynamicQueryCount(DynamicQuery dynamicQuery) {
185                    return releasePersistence.countWithDynamicQuery(dynamicQuery);
186            }
187    
188            /**
189             * Returns the number of rows matching the dynamic query.
190             *
191             * @param dynamicQuery the dynamic query
192             * @param projection the projection to apply to the query
193             * @return the number of rows matching the dynamic query
194             */
195            @Override
196            public long dynamicQueryCount(DynamicQuery dynamicQuery,
197                    Projection projection) {
198                    return releasePersistence.countWithDynamicQuery(dynamicQuery, projection);
199            }
200    
201            @Override
202            public Release fetchRelease(long releaseId) {
203                    return releasePersistence.fetchByPrimaryKey(releaseId);
204            }
205    
206            /**
207             * Returns the release with the primary key.
208             *
209             * @param releaseId the primary key of the release
210             * @return the release
211             * @throws PortalException if a release with the primary key could not be found
212             */
213            @Override
214            public Release getRelease(long releaseId) throws PortalException {
215                    return releasePersistence.findByPrimaryKey(releaseId);
216            }
217    
218            @Override
219            public ActionableDynamicQuery getActionableDynamicQuery() {
220                    ActionableDynamicQuery actionableDynamicQuery = new DefaultActionableDynamicQuery();
221    
222                    actionableDynamicQuery.setBaseLocalService(com.liferay.portal.service.ReleaseLocalServiceUtil.getService());
223                    actionableDynamicQuery.setClass(Release.class);
224                    actionableDynamicQuery.setClassLoader(getClassLoader());
225    
226                    actionableDynamicQuery.setPrimaryKeyPropertyName("releaseId");
227    
228                    return actionableDynamicQuery;
229            }
230    
231            protected void initActionableDynamicQuery(
232                    ActionableDynamicQuery actionableDynamicQuery) {
233                    actionableDynamicQuery.setBaseLocalService(com.liferay.portal.service.ReleaseLocalServiceUtil.getService());
234                    actionableDynamicQuery.setClass(Release.class);
235                    actionableDynamicQuery.setClassLoader(getClassLoader());
236    
237                    actionableDynamicQuery.setPrimaryKeyPropertyName("releaseId");
238            }
239    
240            /**
241             * @throws PortalException
242             */
243            @Override
244            public PersistedModel deletePersistedModel(PersistedModel persistedModel)
245                    throws PortalException {
246                    return releaseLocalService.deleteRelease((Release)persistedModel);
247            }
248    
249            @Override
250            public PersistedModel getPersistedModel(Serializable primaryKeyObj)
251                    throws PortalException {
252                    return releasePersistence.findByPrimaryKey(primaryKeyObj);
253            }
254    
255            /**
256             * Returns a range of all the releases.
257             *
258             * <p>
259             * 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.portal.model.impl.ReleaseModelImpl}. 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.
260             * </p>
261             *
262             * @param start the lower bound of the range of releases
263             * @param end the upper bound of the range of releases (not inclusive)
264             * @return the range of releases
265             */
266            @Override
267            public List<Release> getReleases(int start, int end) {
268                    return releasePersistence.findAll(start, end);
269            }
270    
271            /**
272             * Returns the number of releases.
273             *
274             * @return the number of releases
275             */
276            @Override
277            public int getReleasesCount() {
278                    return releasePersistence.countAll();
279            }
280    
281            /**
282             * Updates the release in the database or adds it if it does not yet exist. Also notifies the appropriate model listeners.
283             *
284             * @param release the release
285             * @return the release that was updated
286             */
287            @Indexable(type = IndexableType.REINDEX)
288            @Override
289            public Release updateRelease(Release release) {
290                    return releasePersistence.update(release);
291            }
292    
293            /**
294             * Returns the release local service.
295             *
296             * @return the release local service
297             */
298            public ReleaseLocalService getReleaseLocalService() {
299                    return releaseLocalService;
300            }
301    
302            /**
303             * Sets the release local service.
304             *
305             * @param releaseLocalService the release local service
306             */
307            public void setReleaseLocalService(ReleaseLocalService releaseLocalService) {
308                    this.releaseLocalService = releaseLocalService;
309            }
310    
311            /**
312             * Returns the release persistence.
313             *
314             * @return the release persistence
315             */
316            public ReleasePersistence getReleasePersistence() {
317                    return releasePersistence;
318            }
319    
320            /**
321             * Sets the release persistence.
322             *
323             * @param releasePersistence the release persistence
324             */
325            public void setReleasePersistence(ReleasePersistence releasePersistence) {
326                    this.releasePersistence = releasePersistence;
327            }
328    
329            /**
330             * Returns the counter local service.
331             *
332             * @return the counter local service
333             */
334            public com.liferay.counter.service.CounterLocalService getCounterLocalService() {
335                    return counterLocalService;
336            }
337    
338            /**
339             * Sets the counter local service.
340             *
341             * @param counterLocalService the counter local service
342             */
343            public void setCounterLocalService(
344                    com.liferay.counter.service.CounterLocalService counterLocalService) {
345                    this.counterLocalService = counterLocalService;
346            }
347    
348            public void afterPropertiesSet() {
349                    persistedModelLocalServiceRegistry.register("com.liferay.portal.model.Release",
350                            releaseLocalService);
351            }
352    
353            public void destroy() {
354                    persistedModelLocalServiceRegistry.unregister(
355                            "com.liferay.portal.model.Release");
356            }
357    
358            /**
359             * Returns the Spring bean ID for this bean.
360             *
361             * @return the Spring bean ID for this bean
362             */
363            @Override
364            public String getBeanIdentifier() {
365                    return _beanIdentifier;
366            }
367    
368            /**
369             * Sets the Spring bean ID for this bean.
370             *
371             * @param beanIdentifier the Spring bean ID for this bean
372             */
373            @Override
374            public void setBeanIdentifier(String beanIdentifier) {
375                    _beanIdentifier = beanIdentifier;
376            }
377    
378            protected Class<?> getModelClass() {
379                    return Release.class;
380            }
381    
382            protected String getModelClassName() {
383                    return Release.class.getName();
384            }
385    
386            /**
387             * Performs a SQL query.
388             *
389             * @param sql the sql query
390             */
391            protected void runSQL(String sql) {
392                    try {
393                            DataSource dataSource = releasePersistence.getDataSource();
394    
395                            DB db = DBFactoryUtil.getDB();
396    
397                            sql = db.buildSQL(sql);
398                            sql = PortalUtil.transformSQL(sql);
399    
400                            SqlUpdate sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(dataSource,
401                                            sql, new int[0]);
402    
403                            sqlUpdate.update();
404                    }
405                    catch (Exception e) {
406                            throw new SystemException(e);
407                    }
408            }
409    
410            @BeanReference(type = com.liferay.portal.service.ReleaseLocalService.class)
411            protected ReleaseLocalService releaseLocalService;
412            @BeanReference(type = ReleasePersistence.class)
413            protected ReleasePersistence releasePersistence;
414            @BeanReference(type = com.liferay.counter.service.CounterLocalService.class)
415            protected com.liferay.counter.service.CounterLocalService counterLocalService;
416            @BeanReference(type = PersistedModelLocalServiceRegistry.class)
417            protected PersistedModelLocalServiceRegistry persistedModelLocalServiceRegistry;
418            private String _beanIdentifier;
419    }