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