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