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