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