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