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.DBFactoryUtil;
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.Projection;
029    import com.liferay.portal.kernel.exception.PortalException;
030    import com.liferay.portal.kernel.exception.SystemException;
031    import com.liferay.portal.kernel.module.framework.service.IdentifiableOSGiService;
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.ResourceBlockPermission;
037    import com.liferay.portal.service.BaseLocalServiceImpl;
038    import com.liferay.portal.service.PersistedModelLocalServiceRegistry;
039    import com.liferay.portal.service.ResourceBlockPermissionLocalService;
040    import com.liferay.portal.service.persistence.ResourceBlockFinder;
041    import com.liferay.portal.service.persistence.ResourceBlockPermissionPersistence;
042    import com.liferay.portal.service.persistence.ResourceBlockPersistence;
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 block 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.ResourceBlockPermissionLocalServiceImpl}.
056     * </p>
057     *
058     * @author Brian Wing Shun Chan
059     * @see com.liferay.portal.service.impl.ResourceBlockPermissionLocalServiceImpl
060     * @see com.liferay.portal.service.ResourceBlockPermissionLocalServiceUtil
061     * @generated
062     */
063    @ProviderType
064    public abstract class ResourceBlockPermissionLocalServiceBaseImpl
065            extends BaseLocalServiceImpl implements ResourceBlockPermissionLocalService,
066                    IdentifiableOSGiService {
067            /*
068             * NOTE FOR DEVELOPERS:
069             *
070             * Never modify or reference this class directly. Always use {@link com.liferay.portal.service.ResourceBlockPermissionLocalServiceUtil} to access the resource block permission local service.
071             */
072    
073            /**
074             * Adds the resource block permission to the database. Also notifies the appropriate model listeners.
075             *
076             * @param resourceBlockPermission the resource block permission
077             * @return the resource block permission that was added
078             */
079            @Indexable(type = IndexableType.REINDEX)
080            @Override
081            public ResourceBlockPermission addResourceBlockPermission(
082                    ResourceBlockPermission resourceBlockPermission) {
083                    resourceBlockPermission.setNew(true);
084    
085                    return resourceBlockPermissionPersistence.update(resourceBlockPermission);
086            }
087    
088            /**
089             * Creates a new resource block permission with the primary key. Does not add the resource block permission to the database.
090             *
091             * @param resourceBlockPermissionId the primary key for the new resource block permission
092             * @return the new resource block permission
093             */
094            @Override
095            public ResourceBlockPermission createResourceBlockPermission(
096                    long resourceBlockPermissionId) {
097                    return resourceBlockPermissionPersistence.create(resourceBlockPermissionId);
098            }
099    
100            /**
101             * Deletes the resource block permission with the primary key from the database. Also notifies the appropriate model listeners.
102             *
103             * @param resourceBlockPermissionId the primary key of the resource block permission
104             * @return the resource block permission that was removed
105             * @throws PortalException if a resource block permission with the primary key could not be found
106             */
107            @Indexable(type = IndexableType.DELETE)
108            @Override
109            public ResourceBlockPermission deleteResourceBlockPermission(
110                    long resourceBlockPermissionId) throws PortalException {
111                    return resourceBlockPermissionPersistence.remove(resourceBlockPermissionId);
112            }
113    
114            /**
115             * Deletes the resource block permission from the database. Also notifies the appropriate model listeners.
116             *
117             * @param resourceBlockPermission the resource block permission
118             * @return the resource block permission that was removed
119             */
120            @Indexable(type = IndexableType.DELETE)
121            @Override
122            public ResourceBlockPermission deleteResourceBlockPermission(
123                    ResourceBlockPermission resourceBlockPermission) {
124                    return resourceBlockPermissionPersistence.remove(resourceBlockPermission);
125            }
126    
127            @Override
128            public DynamicQuery dynamicQuery() {
129                    Class<?> clazz = getClass();
130    
131                    return DynamicQueryFactoryUtil.forClass(ResourceBlockPermission.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 resourceBlockPermissionPersistence.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.ResourceBlockPermissionModelImpl}. 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 resourceBlockPermissionPersistence.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.ResourceBlockPermissionModelImpl}. 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 resourceBlockPermissionPersistence.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 resourceBlockPermissionPersistence.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 resourceBlockPermissionPersistence.countWithDynamicQuery(dynamicQuery,
207                            projection);
208            }
209    
210            @Override
211            public ResourceBlockPermission fetchResourceBlockPermission(
212                    long resourceBlockPermissionId) {
213                    return resourceBlockPermissionPersistence.fetchByPrimaryKey(resourceBlockPermissionId);
214            }
215    
216            /**
217             * Returns the resource block permission with the primary key.
218             *
219             * @param resourceBlockPermissionId the primary key of the resource block permission
220             * @return the resource block permission
221             * @throws PortalException if a resource block permission with the primary key could not be found
222             */
223            @Override
224            public ResourceBlockPermission getResourceBlockPermission(
225                    long resourceBlockPermissionId) throws PortalException {
226                    return resourceBlockPermissionPersistence.findByPrimaryKey(resourceBlockPermissionId);
227            }
228    
229            @Override
230            public ActionableDynamicQuery getActionableDynamicQuery() {
231                    ActionableDynamicQuery actionableDynamicQuery = new DefaultActionableDynamicQuery();
232    
233                    actionableDynamicQuery.setBaseLocalService(com.liferay.portal.service.ResourceBlockPermissionLocalServiceUtil.getService());
234                    actionableDynamicQuery.setClass(ResourceBlockPermission.class);
235                    actionableDynamicQuery.setClassLoader(getClassLoader());
236    
237                    actionableDynamicQuery.setPrimaryKeyPropertyName(
238                            "resourceBlockPermissionId");
239    
240                    return actionableDynamicQuery;
241            }
242    
243            protected void initActionableDynamicQuery(
244                    ActionableDynamicQuery actionableDynamicQuery) {
245                    actionableDynamicQuery.setBaseLocalService(com.liferay.portal.service.ResourceBlockPermissionLocalServiceUtil.getService());
246                    actionableDynamicQuery.setClass(ResourceBlockPermission.class);
247                    actionableDynamicQuery.setClassLoader(getClassLoader());
248    
249                    actionableDynamicQuery.setPrimaryKeyPropertyName(
250                            "resourceBlockPermissionId");
251            }
252    
253            /**
254             * @throws PortalException
255             */
256            @Override
257            public PersistedModel deletePersistedModel(PersistedModel persistedModel)
258                    throws PortalException {
259                    return resourceBlockPermissionLocalService.deleteResourceBlockPermission((ResourceBlockPermission)persistedModel);
260            }
261    
262            @Override
263            public PersistedModel getPersistedModel(Serializable primaryKeyObj)
264                    throws PortalException {
265                    return resourceBlockPermissionPersistence.findByPrimaryKey(primaryKeyObj);
266            }
267    
268            /**
269             * Returns a range of all the resource block 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.ResourceBlockPermissionModelImpl}. 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 block permissions
276             * @param end the upper bound of the range of resource block permissions (not inclusive)
277             * @return the range of resource block permissions
278             */
279            @Override
280            public List<ResourceBlockPermission> getResourceBlockPermissions(
281                    int start, int end) {
282                    return resourceBlockPermissionPersistence.findAll(start, end);
283            }
284    
285            /**
286             * Returns the number of resource block permissions.
287             *
288             * @return the number of resource block permissions
289             */
290            @Override
291            public int getResourceBlockPermissionsCount() {
292                    return resourceBlockPermissionPersistence.countAll();
293            }
294    
295            /**
296             * Updates the resource block permission in the database or adds it if it does not yet exist. Also notifies the appropriate model listeners.
297             *
298             * @param resourceBlockPermission the resource block permission
299             * @return the resource block permission that was updated
300             */
301            @Indexable(type = IndexableType.REINDEX)
302            @Override
303            public ResourceBlockPermission updateResourceBlockPermission(
304                    ResourceBlockPermission resourceBlockPermission) {
305                    return resourceBlockPermissionPersistence.update(resourceBlockPermission);
306            }
307    
308            /**
309             * Returns the resource block permission local service.
310             *
311             * @return the resource block permission local service
312             */
313            public ResourceBlockPermissionLocalService getResourceBlockPermissionLocalService() {
314                    return resourceBlockPermissionLocalService;
315            }
316    
317            /**
318             * Sets the resource block permission local service.
319             *
320             * @param resourceBlockPermissionLocalService the resource block permission local service
321             */
322            public void setResourceBlockPermissionLocalService(
323                    ResourceBlockPermissionLocalService resourceBlockPermissionLocalService) {
324                    this.resourceBlockPermissionLocalService = resourceBlockPermissionLocalService;
325            }
326    
327            /**
328             * Returns the resource block permission persistence.
329             *
330             * @return the resource block permission persistence
331             */
332            public ResourceBlockPermissionPersistence getResourceBlockPermissionPersistence() {
333                    return resourceBlockPermissionPersistence;
334            }
335    
336            /**
337             * Sets the resource block permission persistence.
338             *
339             * @param resourceBlockPermissionPersistence the resource block permission persistence
340             */
341            public void setResourceBlockPermissionPersistence(
342                    ResourceBlockPermissionPersistence resourceBlockPermissionPersistence) {
343                    this.resourceBlockPermissionPersistence = resourceBlockPermissionPersistence;
344            }
345    
346            /**
347             * Returns the counter local service.
348             *
349             * @return the counter local service
350             */
351            public com.liferay.counter.service.CounterLocalService getCounterLocalService() {
352                    return counterLocalService;
353            }
354    
355            /**
356             * Sets the counter local service.
357             *
358             * @param counterLocalService the counter local service
359             */
360            public void setCounterLocalService(
361                    com.liferay.counter.service.CounterLocalService counterLocalService) {
362                    this.counterLocalService = counterLocalService;
363            }
364    
365            /**
366             * Returns the resource block local service.
367             *
368             * @return the resource block local service
369             */
370            public com.liferay.portal.service.ResourceBlockLocalService getResourceBlockLocalService() {
371                    return resourceBlockLocalService;
372            }
373    
374            /**
375             * Sets the resource block local service.
376             *
377             * @param resourceBlockLocalService the resource block local service
378             */
379            public void setResourceBlockLocalService(
380                    com.liferay.portal.service.ResourceBlockLocalService resourceBlockLocalService) {
381                    this.resourceBlockLocalService = resourceBlockLocalService;
382            }
383    
384            /**
385             * Returns the resource block remote service.
386             *
387             * @return the resource block remote service
388             */
389            public com.liferay.portal.service.ResourceBlockService getResourceBlockService() {
390                    return resourceBlockService;
391            }
392    
393            /**
394             * Sets the resource block remote service.
395             *
396             * @param resourceBlockService the resource block remote service
397             */
398            public void setResourceBlockService(
399                    com.liferay.portal.service.ResourceBlockService resourceBlockService) {
400                    this.resourceBlockService = resourceBlockService;
401            }
402    
403            /**
404             * Returns the resource block persistence.
405             *
406             * @return the resource block persistence
407             */
408            public ResourceBlockPersistence getResourceBlockPersistence() {
409                    return resourceBlockPersistence;
410            }
411    
412            /**
413             * Sets the resource block persistence.
414             *
415             * @param resourceBlockPersistence the resource block persistence
416             */
417            public void setResourceBlockPersistence(
418                    ResourceBlockPersistence resourceBlockPersistence) {
419                    this.resourceBlockPersistence = resourceBlockPersistence;
420            }
421    
422            /**
423             * Returns the resource block finder.
424             *
425             * @return the resource block finder
426             */
427            public ResourceBlockFinder getResourceBlockFinder() {
428                    return resourceBlockFinder;
429            }
430    
431            /**
432             * Sets the resource block finder.
433             *
434             * @param resourceBlockFinder the resource block finder
435             */
436            public void setResourceBlockFinder(ResourceBlockFinder resourceBlockFinder) {
437                    this.resourceBlockFinder = resourceBlockFinder;
438            }
439    
440            public void afterPropertiesSet() {
441                    persistedModelLocalServiceRegistry.register("com.liferay.portal.model.ResourceBlockPermission",
442                            resourceBlockPermissionLocalService);
443            }
444    
445            public void destroy() {
446                    persistedModelLocalServiceRegistry.unregister(
447                            "com.liferay.portal.model.ResourceBlockPermission");
448            }
449    
450            /**
451             * Returns the OSGi service identifier.
452             *
453             * @return the OSGi service identifier
454             */
455            @Override
456            public String getOSGiServiceIdentifier() {
457                    return ResourceBlockPermissionLocalService.class.getName();
458            }
459    
460            protected Class<?> getModelClass() {
461                    return ResourceBlockPermission.class;
462            }
463    
464            protected String getModelClassName() {
465                    return ResourceBlockPermission.class.getName();
466            }
467    
468            /**
469             * Performs a SQL query.
470             *
471             * @param sql the sql query
472             */
473            protected void runSQL(String sql) {
474                    try {
475                            DataSource dataSource = resourceBlockPermissionPersistence.getDataSource();
476    
477                            DB db = DBFactoryUtil.getDB();
478    
479                            sql = db.buildSQL(sql);
480                            sql = PortalUtil.transformSQL(sql);
481    
482                            SqlUpdate sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(dataSource,
483                                            sql, new int[0]);
484    
485                            sqlUpdate.update();
486                    }
487                    catch (Exception e) {
488                            throw new SystemException(e);
489                    }
490            }
491    
492            @BeanReference(type = com.liferay.portal.service.ResourceBlockPermissionLocalService.class)
493            protected ResourceBlockPermissionLocalService resourceBlockPermissionLocalService;
494            @BeanReference(type = ResourceBlockPermissionPersistence.class)
495            protected ResourceBlockPermissionPersistence resourceBlockPermissionPersistence;
496            @BeanReference(type = com.liferay.counter.service.CounterLocalService.class)
497            protected com.liferay.counter.service.CounterLocalService counterLocalService;
498            @BeanReference(type = com.liferay.portal.service.ResourceBlockLocalService.class)
499            protected com.liferay.portal.service.ResourceBlockLocalService resourceBlockLocalService;
500            @BeanReference(type = com.liferay.portal.service.ResourceBlockService.class)
501            protected com.liferay.portal.service.ResourceBlockService resourceBlockService;
502            @BeanReference(type = ResourceBlockPersistence.class)
503            protected ResourceBlockPersistence resourceBlockPersistence;
504            @BeanReference(type = ResourceBlockFinder.class)
505            protected ResourceBlockFinder resourceBlockFinder;
506            @BeanReference(type = PersistedModelLocalServiceRegistry.class)
507            protected PersistedModelLocalServiceRegistry persistedModelLocalServiceRegistry;
508    }