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.PluginSetting;
038    import com.liferay.portal.service.BaseLocalServiceImpl;
039    import com.liferay.portal.service.PersistedModelLocalServiceRegistry;
040    import com.liferay.portal.service.PluginSettingLocalService;
041    import com.liferay.portal.service.persistence.PluginSettingPersistence;
042    import com.liferay.portal.service.persistence.RoleFinder;
043    import com.liferay.portal.service.persistence.RolePersistence;
044    import com.liferay.portal.service.persistence.UserFinder;
045    import com.liferay.portal.service.persistence.UserPersistence;
046    import com.liferay.portal.util.PortalUtil;
047    
048    import java.io.Serializable;
049    
050    import java.util.List;
051    
052    import javax.sql.DataSource;
053    
054    /**
055     * Provides the base implementation for the plugin setting local service.
056     *
057     * <p>
058     * 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.PluginSettingLocalServiceImpl}.
059     * </p>
060     *
061     * @author Brian Wing Shun Chan
062     * @see com.liferay.portal.service.impl.PluginSettingLocalServiceImpl
063     * @see com.liferay.portal.service.PluginSettingLocalServiceUtil
064     * @generated
065     */
066    @ProviderType
067    public abstract class PluginSettingLocalServiceBaseImpl
068            extends BaseLocalServiceImpl implements PluginSettingLocalService,
069                    IdentifiableOSGiService {
070            /*
071             * NOTE FOR DEVELOPERS:
072             *
073             * Never modify or reference this class directly. Always use {@link com.liferay.portal.service.PluginSettingLocalServiceUtil} to access the plugin setting local service.
074             */
075    
076            /**
077             * Adds the plugin setting to the database. Also notifies the appropriate model listeners.
078             *
079             * @param pluginSetting the plugin setting
080             * @return the plugin setting that was added
081             */
082            @Indexable(type = IndexableType.REINDEX)
083            @Override
084            public PluginSetting addPluginSetting(PluginSetting pluginSetting) {
085                    pluginSetting.setNew(true);
086    
087                    return pluginSettingPersistence.update(pluginSetting);
088            }
089    
090            /**
091             * Creates a new plugin setting with the primary key. Does not add the plugin setting to the database.
092             *
093             * @param pluginSettingId the primary key for the new plugin setting
094             * @return the new plugin setting
095             */
096            @Override
097            public PluginSetting createPluginSetting(long pluginSettingId) {
098                    return pluginSettingPersistence.create(pluginSettingId);
099            }
100    
101            /**
102             * Deletes the plugin setting with the primary key from the database. Also notifies the appropriate model listeners.
103             *
104             * @param pluginSettingId the primary key of the plugin setting
105             * @return the plugin setting that was removed
106             * @throws PortalException if a plugin setting with the primary key could not be found
107             */
108            @Indexable(type = IndexableType.DELETE)
109            @Override
110            public PluginSetting deletePluginSetting(long pluginSettingId)
111                    throws PortalException {
112                    return pluginSettingPersistence.remove(pluginSettingId);
113            }
114    
115            /**
116             * Deletes the plugin setting from the database. Also notifies the appropriate model listeners.
117             *
118             * @param pluginSetting the plugin setting
119             * @return the plugin setting that was removed
120             */
121            @Indexable(type = IndexableType.DELETE)
122            @Override
123            public PluginSetting deletePluginSetting(PluginSetting pluginSetting) {
124                    return pluginSettingPersistence.remove(pluginSetting);
125            }
126    
127            @Override
128            public DynamicQuery dynamicQuery() {
129                    Class<?> clazz = getClass();
130    
131                    return DynamicQueryFactoryUtil.forClass(PluginSetting.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 pluginSettingPersistence.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.PluginSettingModelImpl}. 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 pluginSettingPersistence.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.PluginSettingModelImpl}. 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 pluginSettingPersistence.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 pluginSettingPersistence.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 pluginSettingPersistence.countWithDynamicQuery(dynamicQuery,
207                            projection);
208            }
209    
210            @Override
211            public PluginSetting fetchPluginSetting(long pluginSettingId) {
212                    return pluginSettingPersistence.fetchByPrimaryKey(pluginSettingId);
213            }
214    
215            /**
216             * Returns the plugin setting with the primary key.
217             *
218             * @param pluginSettingId the primary key of the plugin setting
219             * @return the plugin setting
220             * @throws PortalException if a plugin setting with the primary key could not be found
221             */
222            @Override
223            public PluginSetting getPluginSetting(long pluginSettingId)
224                    throws PortalException {
225                    return pluginSettingPersistence.findByPrimaryKey(pluginSettingId);
226            }
227    
228            @Override
229            public ActionableDynamicQuery getActionableDynamicQuery() {
230                    ActionableDynamicQuery actionableDynamicQuery = new DefaultActionableDynamicQuery();
231    
232                    actionableDynamicQuery.setBaseLocalService(com.liferay.portal.service.PluginSettingLocalServiceUtil.getService());
233                    actionableDynamicQuery.setClassLoader(getClassLoader());
234                    actionableDynamicQuery.setModelClass(PluginSetting.class);
235    
236                    actionableDynamicQuery.setPrimaryKeyPropertyName("pluginSettingId");
237    
238                    return actionableDynamicQuery;
239            }
240    
241            @Override
242            public IndexableActionableDynamicQuery getIndexableActionableDynamicQuery() {
243                    IndexableActionableDynamicQuery indexableActionableDynamicQuery = new IndexableActionableDynamicQuery();
244    
245                    indexableActionableDynamicQuery.setBaseLocalService(com.liferay.portal.service.PluginSettingLocalServiceUtil.getService());
246                    indexableActionableDynamicQuery.setClassLoader(getClassLoader());
247                    indexableActionableDynamicQuery.setModelClass(PluginSetting.class);
248    
249                    indexableActionableDynamicQuery.setPrimaryKeyPropertyName(
250                            "pluginSettingId");
251    
252                    return indexableActionableDynamicQuery;
253            }
254    
255            protected void initActionableDynamicQuery(
256                    ActionableDynamicQuery actionableDynamicQuery) {
257                    actionableDynamicQuery.setBaseLocalService(com.liferay.portal.service.PluginSettingLocalServiceUtil.getService());
258                    actionableDynamicQuery.setClassLoader(getClassLoader());
259                    actionableDynamicQuery.setModelClass(PluginSetting.class);
260    
261                    actionableDynamicQuery.setPrimaryKeyPropertyName("pluginSettingId");
262            }
263    
264            /**
265             * @throws PortalException
266             */
267            @Override
268            public PersistedModel deletePersistedModel(PersistedModel persistedModel)
269                    throws PortalException {
270                    return pluginSettingLocalService.deletePluginSetting((PluginSetting)persistedModel);
271            }
272    
273            @Override
274            public PersistedModel getPersistedModel(Serializable primaryKeyObj)
275                    throws PortalException {
276                    return pluginSettingPersistence.findByPrimaryKey(primaryKeyObj);
277            }
278    
279            /**
280             * Returns a range of all the plugin settings.
281             *
282             * <p>
283             * 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.PluginSettingModelImpl}. 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.
284             * </p>
285             *
286             * @param start the lower bound of the range of plugin settings
287             * @param end the upper bound of the range of plugin settings (not inclusive)
288             * @return the range of plugin settings
289             */
290            @Override
291            public List<PluginSetting> getPluginSettings(int start, int end) {
292                    return pluginSettingPersistence.findAll(start, end);
293            }
294    
295            /**
296             * Returns the number of plugin settings.
297             *
298             * @return the number of plugin settings
299             */
300            @Override
301            public int getPluginSettingsCount() {
302                    return pluginSettingPersistence.countAll();
303            }
304    
305            /**
306             * Updates the plugin setting in the database or adds it if it does not yet exist. Also notifies the appropriate model listeners.
307             *
308             * @param pluginSetting the plugin setting
309             * @return the plugin setting that was updated
310             */
311            @Indexable(type = IndexableType.REINDEX)
312            @Override
313            public PluginSetting updatePluginSetting(PluginSetting pluginSetting) {
314                    return pluginSettingPersistence.update(pluginSetting);
315            }
316    
317            /**
318             * Returns the plugin setting local service.
319             *
320             * @return the plugin setting local service
321             */
322            public PluginSettingLocalService getPluginSettingLocalService() {
323                    return pluginSettingLocalService;
324            }
325    
326            /**
327             * Sets the plugin setting local service.
328             *
329             * @param pluginSettingLocalService the plugin setting local service
330             */
331            public void setPluginSettingLocalService(
332                    PluginSettingLocalService pluginSettingLocalService) {
333                    this.pluginSettingLocalService = pluginSettingLocalService;
334            }
335    
336            /**
337             * Returns the plugin setting persistence.
338             *
339             * @return the plugin setting persistence
340             */
341            public PluginSettingPersistence getPluginSettingPersistence() {
342                    return pluginSettingPersistence;
343            }
344    
345            /**
346             * Sets the plugin setting persistence.
347             *
348             * @param pluginSettingPersistence the plugin setting persistence
349             */
350            public void setPluginSettingPersistence(
351                    PluginSettingPersistence pluginSettingPersistence) {
352                    this.pluginSettingPersistence = pluginSettingPersistence;
353            }
354    
355            /**
356             * Returns the counter local service.
357             *
358             * @return the counter local service
359             */
360            public com.liferay.counter.service.CounterLocalService getCounterLocalService() {
361                    return counterLocalService;
362            }
363    
364            /**
365             * Sets the counter local service.
366             *
367             * @param counterLocalService the counter local service
368             */
369            public void setCounterLocalService(
370                    com.liferay.counter.service.CounterLocalService counterLocalService) {
371                    this.counterLocalService = counterLocalService;
372            }
373    
374            /**
375             * Returns the layout template local service.
376             *
377             * @return the layout template local service
378             */
379            public com.liferay.portal.service.LayoutTemplateLocalService getLayoutTemplateLocalService() {
380                    return layoutTemplateLocalService;
381            }
382    
383            /**
384             * Sets the layout template local service.
385             *
386             * @param layoutTemplateLocalService the layout template local service
387             */
388            public void setLayoutTemplateLocalService(
389                    com.liferay.portal.service.LayoutTemplateLocalService layoutTemplateLocalService) {
390                    this.layoutTemplateLocalService = layoutTemplateLocalService;
391            }
392    
393            /**
394             * Returns the role local service.
395             *
396             * @return the role local service
397             */
398            public com.liferay.portal.service.RoleLocalService getRoleLocalService() {
399                    return roleLocalService;
400            }
401    
402            /**
403             * Sets the role local service.
404             *
405             * @param roleLocalService the role local service
406             */
407            public void setRoleLocalService(
408                    com.liferay.portal.service.RoleLocalService roleLocalService) {
409                    this.roleLocalService = roleLocalService;
410            }
411    
412            /**
413             * Returns the role persistence.
414             *
415             * @return the role persistence
416             */
417            public RolePersistence getRolePersistence() {
418                    return rolePersistence;
419            }
420    
421            /**
422             * Sets the role persistence.
423             *
424             * @param rolePersistence the role persistence
425             */
426            public void setRolePersistence(RolePersistence rolePersistence) {
427                    this.rolePersistence = rolePersistence;
428            }
429    
430            /**
431             * Returns the role finder.
432             *
433             * @return the role finder
434             */
435            public RoleFinder getRoleFinder() {
436                    return roleFinder;
437            }
438    
439            /**
440             * Sets the role finder.
441             *
442             * @param roleFinder the role finder
443             */
444            public void setRoleFinder(RoleFinder roleFinder) {
445                    this.roleFinder = roleFinder;
446            }
447    
448            /**
449             * Returns the theme local service.
450             *
451             * @return the theme local service
452             */
453            public com.liferay.portal.service.ThemeLocalService getThemeLocalService() {
454                    return themeLocalService;
455            }
456    
457            /**
458             * Sets the theme local service.
459             *
460             * @param themeLocalService the theme local service
461             */
462            public void setThemeLocalService(
463                    com.liferay.portal.service.ThemeLocalService themeLocalService) {
464                    this.themeLocalService = themeLocalService;
465            }
466    
467            /**
468             * Returns the user local service.
469             *
470             * @return the user local service
471             */
472            public com.liferay.portal.service.UserLocalService getUserLocalService() {
473                    return userLocalService;
474            }
475    
476            /**
477             * Sets the user local service.
478             *
479             * @param userLocalService the user local service
480             */
481            public void setUserLocalService(
482                    com.liferay.portal.service.UserLocalService userLocalService) {
483                    this.userLocalService = userLocalService;
484            }
485    
486            /**
487             * Returns the user persistence.
488             *
489             * @return the user persistence
490             */
491            public UserPersistence getUserPersistence() {
492                    return userPersistence;
493            }
494    
495            /**
496             * Sets the user persistence.
497             *
498             * @param userPersistence the user persistence
499             */
500            public void setUserPersistence(UserPersistence userPersistence) {
501                    this.userPersistence = userPersistence;
502            }
503    
504            /**
505             * Returns the user finder.
506             *
507             * @return the user finder
508             */
509            public UserFinder getUserFinder() {
510                    return userFinder;
511            }
512    
513            /**
514             * Sets the user finder.
515             *
516             * @param userFinder the user finder
517             */
518            public void setUserFinder(UserFinder userFinder) {
519                    this.userFinder = userFinder;
520            }
521    
522            public void afterPropertiesSet() {
523                    persistedModelLocalServiceRegistry.register("com.liferay.portal.model.PluginSetting",
524                            pluginSettingLocalService);
525            }
526    
527            public void destroy() {
528                    persistedModelLocalServiceRegistry.unregister(
529                            "com.liferay.portal.model.PluginSetting");
530            }
531    
532            /**
533             * Returns the OSGi service identifier.
534             *
535             * @return the OSGi service identifier
536             */
537            @Override
538            public String getOSGiServiceIdentifier() {
539                    return PluginSettingLocalService.class.getName();
540            }
541    
542            protected Class<?> getModelClass() {
543                    return PluginSetting.class;
544            }
545    
546            protected String getModelClassName() {
547                    return PluginSetting.class.getName();
548            }
549    
550            /**
551             * Performs a SQL query.
552             *
553             * @param sql the sql query
554             */
555            protected void runSQL(String sql) {
556                    try {
557                            DataSource dataSource = pluginSettingPersistence.getDataSource();
558    
559                            DB db = DBManagerUtil.getDB();
560    
561                            sql = db.buildSQL(sql);
562                            sql = PortalUtil.transformSQL(sql);
563    
564                            SqlUpdate sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(dataSource,
565                                            sql, new int[0]);
566    
567                            sqlUpdate.update();
568                    }
569                    catch (Exception e) {
570                            throw new SystemException(e);
571                    }
572            }
573    
574            @BeanReference(type = com.liferay.portal.service.PluginSettingLocalService.class)
575            protected PluginSettingLocalService pluginSettingLocalService;
576            @BeanReference(type = PluginSettingPersistence.class)
577            protected PluginSettingPersistence pluginSettingPersistence;
578            @BeanReference(type = com.liferay.counter.service.CounterLocalService.class)
579            protected com.liferay.counter.service.CounterLocalService counterLocalService;
580            @BeanReference(type = com.liferay.portal.service.LayoutTemplateLocalService.class)
581            protected com.liferay.portal.service.LayoutTemplateLocalService layoutTemplateLocalService;
582            @BeanReference(type = com.liferay.portal.service.RoleLocalService.class)
583            protected com.liferay.portal.service.RoleLocalService roleLocalService;
584            @BeanReference(type = RolePersistence.class)
585            protected RolePersistence rolePersistence;
586            @BeanReference(type = RoleFinder.class)
587            protected RoleFinder roleFinder;
588            @BeanReference(type = com.liferay.portal.service.ThemeLocalService.class)
589            protected com.liferay.portal.service.ThemeLocalService themeLocalService;
590            @BeanReference(type = com.liferay.portal.service.UserLocalService.class)
591            protected com.liferay.portal.service.UserLocalService userLocalService;
592            @BeanReference(type = UserPersistence.class)
593            protected UserPersistence userPersistence;
594            @BeanReference(type = UserFinder.class)
595            protected UserFinder userFinder;
596            @BeanReference(type = PersistedModelLocalServiceRegistry.class)
597            protected PersistedModelLocalServiceRegistry persistedModelLocalServiceRegistry;
598    }