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