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.ResourceAction;
038    import com.liferay.portal.service.BaseLocalServiceImpl;
039    import com.liferay.portal.service.PersistedModelLocalServiceRegistry;
040    import com.liferay.portal.service.ResourceActionLocalService;
041    import com.liferay.portal.service.persistence.ResourceActionPersistence;
042    import com.liferay.portal.service.persistence.ResourcePermissionFinder;
043    import com.liferay.portal.service.persistence.ResourcePermissionPersistence;
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    /**
053     * Provides the base implementation for the resource action local service.
054     *
055     * <p>
056     * 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.ResourceActionLocalServiceImpl}.
057     * </p>
058     *
059     * @author Brian Wing Shun Chan
060     * @see com.liferay.portal.service.impl.ResourceActionLocalServiceImpl
061     * @see com.liferay.portal.service.ResourceActionLocalServiceUtil
062     * @generated
063     */
064    @ProviderType
065    public abstract class ResourceActionLocalServiceBaseImpl
066            extends BaseLocalServiceImpl implements ResourceActionLocalService,
067                    IdentifiableOSGiService {
068            /*
069             * NOTE FOR DEVELOPERS:
070             *
071             * Never modify or reference this class directly. Always use {@link com.liferay.portal.service.ResourceActionLocalServiceUtil} to access the resource action local service.
072             */
073    
074            /**
075             * Adds the resource action to the database. Also notifies the appropriate model listeners.
076             *
077             * @param resourceAction the resource action
078             * @return the resource action that was added
079             */
080            @Indexable(type = IndexableType.REINDEX)
081            @Override
082            public ResourceAction addResourceAction(ResourceAction resourceAction) {
083                    resourceAction.setNew(true);
084    
085                    return resourceActionPersistence.update(resourceAction);
086            }
087    
088            /**
089             * Creates a new resource action with the primary key. Does not add the resource action to the database.
090             *
091             * @param resourceActionId the primary key for the new resource action
092             * @return the new resource action
093             */
094            @Override
095            public ResourceAction createResourceAction(long resourceActionId) {
096                    return resourceActionPersistence.create(resourceActionId);
097            }
098    
099            /**
100             * Deletes the resource action with the primary key from the database. Also notifies the appropriate model listeners.
101             *
102             * @param resourceActionId the primary key of the resource action
103             * @return the resource action that was removed
104             * @throws PortalException if a resource action with the primary key could not be found
105             */
106            @Indexable(type = IndexableType.DELETE)
107            @Override
108            public ResourceAction deleteResourceAction(long resourceActionId)
109                    throws PortalException {
110                    return resourceActionPersistence.remove(resourceActionId);
111            }
112    
113            /**
114             * Deletes the resource action from the database. Also notifies the appropriate model listeners.
115             *
116             * @param resourceAction the resource action
117             * @return the resource action that was removed
118             */
119            @Indexable(type = IndexableType.DELETE)
120            @Override
121            public ResourceAction deleteResourceAction(ResourceAction resourceAction) {
122                    return resourceActionPersistence.remove(resourceAction);
123            }
124    
125            @Override
126            public DynamicQuery dynamicQuery() {
127                    Class<?> clazz = getClass();
128    
129                    return DynamicQueryFactoryUtil.forClass(ResourceAction.class,
130                            clazz.getClassLoader());
131            }
132    
133            /**
134             * Performs a dynamic query on the database and returns the matching rows.
135             *
136             * @param dynamicQuery the dynamic query
137             * @return the matching rows
138             */
139            @Override
140            public <T> List<T> dynamicQuery(DynamicQuery dynamicQuery) {
141                    return resourceActionPersistence.findWithDynamicQuery(dynamicQuery);
142            }
143    
144            /**
145             * Performs a dynamic query on the database and returns a range of the matching rows.
146             *
147             * <p>
148             * 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.ResourceActionModelImpl}. 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.
149             * </p>
150             *
151             * @param dynamicQuery the dynamic query
152             * @param start the lower bound of the range of model instances
153             * @param end the upper bound of the range of model instances (not inclusive)
154             * @return the range of matching rows
155             */
156            @Override
157            public <T> List<T> dynamicQuery(DynamicQuery dynamicQuery, int start,
158                    int end) {
159                    return resourceActionPersistence.findWithDynamicQuery(dynamicQuery,
160                            start, end);
161            }
162    
163            /**
164             * Performs a dynamic query on the database and returns an ordered range of the matching rows.
165             *
166             * <p>
167             * 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.ResourceActionModelImpl}. 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.
168             * </p>
169             *
170             * @param dynamicQuery the dynamic query
171             * @param start the lower bound of the range of model instances
172             * @param end the upper bound of the range of model instances (not inclusive)
173             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
174             * @return the ordered range of matching rows
175             */
176            @Override
177            public <T> List<T> dynamicQuery(DynamicQuery dynamicQuery, int start,
178                    int end, OrderByComparator<T> orderByComparator) {
179                    return resourceActionPersistence.findWithDynamicQuery(dynamicQuery,
180                            start, end, orderByComparator);
181            }
182    
183            /**
184             * Returns the number of rows matching the dynamic query.
185             *
186             * @param dynamicQuery the dynamic query
187             * @return the number of rows matching the dynamic query
188             */
189            @Override
190            public long dynamicQueryCount(DynamicQuery dynamicQuery) {
191                    return resourceActionPersistence.countWithDynamicQuery(dynamicQuery);
192            }
193    
194            /**
195             * Returns the number of rows matching the dynamic query.
196             *
197             * @param dynamicQuery the dynamic query
198             * @param projection the projection to apply to the query
199             * @return the number of rows matching the dynamic query
200             */
201            @Override
202            public long dynamicQueryCount(DynamicQuery dynamicQuery,
203                    Projection projection) {
204                    return resourceActionPersistence.countWithDynamicQuery(dynamicQuery,
205                            projection);
206            }
207    
208            @Override
209            public ResourceAction fetchResourceAction(long resourceActionId) {
210                    return resourceActionPersistence.fetchByPrimaryKey(resourceActionId);
211            }
212    
213            /**
214             * Returns the resource action with the primary key.
215             *
216             * @param resourceActionId the primary key of the resource action
217             * @return the resource action
218             * @throws PortalException if a resource action with the primary key could not be found
219             */
220            @Override
221            public ResourceAction getResourceAction(long resourceActionId)
222                    throws PortalException {
223                    return resourceActionPersistence.findByPrimaryKey(resourceActionId);
224            }
225    
226            @Override
227            public ActionableDynamicQuery getActionableDynamicQuery() {
228                    ActionableDynamicQuery actionableDynamicQuery = new DefaultActionableDynamicQuery();
229    
230                    actionableDynamicQuery.setBaseLocalService(com.liferay.portal.service.ResourceActionLocalServiceUtil.getService());
231                    actionableDynamicQuery.setClassLoader(getClassLoader());
232                    actionableDynamicQuery.setModelClass(ResourceAction.class);
233    
234                    actionableDynamicQuery.setPrimaryKeyPropertyName("resourceActionId");
235    
236                    return actionableDynamicQuery;
237            }
238    
239            @Override
240            public IndexableActionableDynamicQuery getIndexableActionableDynamicQuery() {
241                    IndexableActionableDynamicQuery indexableActionableDynamicQuery = new IndexableActionableDynamicQuery();
242    
243                    indexableActionableDynamicQuery.setBaseLocalService(com.liferay.portal.service.ResourceActionLocalServiceUtil.getService());
244                    indexableActionableDynamicQuery.setClassLoader(getClassLoader());
245                    indexableActionableDynamicQuery.setModelClass(ResourceAction.class);
246    
247                    indexableActionableDynamicQuery.setPrimaryKeyPropertyName(
248                            "resourceActionId");
249    
250                    return indexableActionableDynamicQuery;
251            }
252    
253            protected void initActionableDynamicQuery(
254                    ActionableDynamicQuery actionableDynamicQuery) {
255                    actionableDynamicQuery.setBaseLocalService(com.liferay.portal.service.ResourceActionLocalServiceUtil.getService());
256                    actionableDynamicQuery.setClassLoader(getClassLoader());
257                    actionableDynamicQuery.setModelClass(ResourceAction.class);
258    
259                    actionableDynamicQuery.setPrimaryKeyPropertyName("resourceActionId");
260            }
261    
262            /**
263             * @throws PortalException
264             */
265            @Override
266            public PersistedModel deletePersistedModel(PersistedModel persistedModel)
267                    throws PortalException {
268                    return resourceActionLocalService.deleteResourceAction((ResourceAction)persistedModel);
269            }
270    
271            @Override
272            public PersistedModel getPersistedModel(Serializable primaryKeyObj)
273                    throws PortalException {
274                    return resourceActionPersistence.findByPrimaryKey(primaryKeyObj);
275            }
276    
277            /**
278             * Returns a range of all the resource actions.
279             *
280             * <p>
281             * 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.ResourceActionModelImpl}. 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.
282             * </p>
283             *
284             * @param start the lower bound of the range of resource actions
285             * @param end the upper bound of the range of resource actions (not inclusive)
286             * @return the range of resource actions
287             */
288            @Override
289            public List<ResourceAction> getResourceActions(int start, int end) {
290                    return resourceActionPersistence.findAll(start, end);
291            }
292    
293            /**
294             * Returns the number of resource actions.
295             *
296             * @return the number of resource actions
297             */
298            @Override
299            public int getResourceActionsCount() {
300                    return resourceActionPersistence.countAll();
301            }
302    
303            /**
304             * Updates the resource action in the database or adds it if it does not yet exist. Also notifies the appropriate model listeners.
305             *
306             * @param resourceAction the resource action
307             * @return the resource action that was updated
308             */
309            @Indexable(type = IndexableType.REINDEX)
310            @Override
311            public ResourceAction updateResourceAction(ResourceAction resourceAction) {
312                    return resourceActionPersistence.update(resourceAction);
313            }
314    
315            /**
316             * Returns the resource action local service.
317             *
318             * @return the resource action local service
319             */
320            public ResourceActionLocalService getResourceActionLocalService() {
321                    return resourceActionLocalService;
322            }
323    
324            /**
325             * Sets the resource action local service.
326             *
327             * @param resourceActionLocalService the resource action local service
328             */
329            public void setResourceActionLocalService(
330                    ResourceActionLocalService resourceActionLocalService) {
331                    this.resourceActionLocalService = resourceActionLocalService;
332            }
333    
334            /**
335             * Returns the resource action persistence.
336             *
337             * @return the resource action persistence
338             */
339            public ResourceActionPersistence getResourceActionPersistence() {
340                    return resourceActionPersistence;
341            }
342    
343            /**
344             * Sets the resource action persistence.
345             *
346             * @param resourceActionPersistence the resource action persistence
347             */
348            public void setResourceActionPersistence(
349                    ResourceActionPersistence resourceActionPersistence) {
350                    this.resourceActionPersistence = resourceActionPersistence;
351            }
352    
353            /**
354             * Returns the counter local service.
355             *
356             * @return the counter local service
357             */
358            public com.liferay.counter.service.CounterLocalService getCounterLocalService() {
359                    return counterLocalService;
360            }
361    
362            /**
363             * Sets the counter local service.
364             *
365             * @param counterLocalService the counter local service
366             */
367            public void setCounterLocalService(
368                    com.liferay.counter.service.CounterLocalService counterLocalService) {
369                    this.counterLocalService = counterLocalService;
370            }
371    
372            /**
373             * Returns the resource permission local service.
374             *
375             * @return the resource permission local service
376             */
377            public com.liferay.portal.service.ResourcePermissionLocalService getResourcePermissionLocalService() {
378                    return resourcePermissionLocalService;
379            }
380    
381            /**
382             * Sets the resource permission local service.
383             *
384             * @param resourcePermissionLocalService the resource permission local service
385             */
386            public void setResourcePermissionLocalService(
387                    com.liferay.portal.service.ResourcePermissionLocalService resourcePermissionLocalService) {
388                    this.resourcePermissionLocalService = resourcePermissionLocalService;
389            }
390    
391            /**
392             * Returns the resource permission persistence.
393             *
394             * @return the resource permission persistence
395             */
396            public ResourcePermissionPersistence getResourcePermissionPersistence() {
397                    return resourcePermissionPersistence;
398            }
399    
400            /**
401             * Sets the resource permission persistence.
402             *
403             * @param resourcePermissionPersistence the resource permission persistence
404             */
405            public void setResourcePermissionPersistence(
406                    ResourcePermissionPersistence resourcePermissionPersistence) {
407                    this.resourcePermissionPersistence = resourcePermissionPersistence;
408            }
409    
410            /**
411             * Returns the resource permission finder.
412             *
413             * @return the resource permission finder
414             */
415            public ResourcePermissionFinder getResourcePermissionFinder() {
416                    return resourcePermissionFinder;
417            }
418    
419            /**
420             * Sets the resource permission finder.
421             *
422             * @param resourcePermissionFinder the resource permission finder
423             */
424            public void setResourcePermissionFinder(
425                    ResourcePermissionFinder resourcePermissionFinder) {
426                    this.resourcePermissionFinder = resourcePermissionFinder;
427            }
428    
429            public void afterPropertiesSet() {
430                    persistedModelLocalServiceRegistry.register("com.liferay.portal.model.ResourceAction",
431                            resourceActionLocalService);
432            }
433    
434            public void destroy() {
435                    persistedModelLocalServiceRegistry.unregister(
436                            "com.liferay.portal.model.ResourceAction");
437            }
438    
439            /**
440             * Returns the OSGi service identifier.
441             *
442             * @return the OSGi service identifier
443             */
444            @Override
445            public String getOSGiServiceIdentifier() {
446                    return ResourceActionLocalService.class.getName();
447            }
448    
449            protected Class<?> getModelClass() {
450                    return ResourceAction.class;
451            }
452    
453            protected String getModelClassName() {
454                    return ResourceAction.class.getName();
455            }
456    
457            /**
458             * Performs a SQL query.
459             *
460             * @param sql the sql query
461             */
462            protected void runSQL(String sql) {
463                    try {
464                            DataSource dataSource = resourceActionPersistence.getDataSource();
465    
466                            DB db = DBManagerUtil.getDB();
467    
468                            sql = db.buildSQL(sql);
469                            sql = PortalUtil.transformSQL(sql);
470    
471                            SqlUpdate sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(dataSource,
472                                            sql, new int[0]);
473    
474                            sqlUpdate.update();
475                    }
476                    catch (Exception e) {
477                            throw new SystemException(e);
478                    }
479            }
480    
481            @BeanReference(type = com.liferay.portal.service.ResourceActionLocalService.class)
482            protected ResourceActionLocalService resourceActionLocalService;
483            @BeanReference(type = ResourceActionPersistence.class)
484            protected ResourceActionPersistence resourceActionPersistence;
485            @BeanReference(type = com.liferay.counter.service.CounterLocalService.class)
486            protected com.liferay.counter.service.CounterLocalService counterLocalService;
487            @BeanReference(type = com.liferay.portal.service.ResourcePermissionLocalService.class)
488            protected com.liferay.portal.service.ResourcePermissionLocalService resourcePermissionLocalService;
489            @BeanReference(type = ResourcePermissionPersistence.class)
490            protected ResourcePermissionPersistence resourcePermissionPersistence;
491            @BeanReference(type = ResourcePermissionFinder.class)
492            protected ResourcePermissionFinder resourcePermissionFinder;
493            @BeanReference(type = PersistedModelLocalServiceRegistry.class)
494            protected PersistedModelLocalServiceRegistry persistedModelLocalServiceRegistry;
495    }