001    /**
002     * Copyright (c) 2000-present Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portal.service.base;
016    
017    import aQute.bnd.annotation.ProviderType;
018    
019    import com.liferay.portal.kernel.bean.BeanReference;
020    import com.liferay.portal.kernel.bean.IdentifiableBean;
021    import com.liferay.portal.kernel.dao.db.DB;
022    import com.liferay.portal.kernel.dao.db.DBFactoryUtil;
023    import com.liferay.portal.kernel.dao.jdbc.SqlUpdate;
024    import com.liferay.portal.kernel.dao.jdbc.SqlUpdateFactoryUtil;
025    import com.liferay.portal.kernel.dao.orm.ActionableDynamicQuery;
026    import com.liferay.portal.kernel.dao.orm.DefaultActionableDynamicQuery;
027    import com.liferay.portal.kernel.dao.orm.DynamicQuery;
028    import com.liferay.portal.kernel.dao.orm.DynamicQueryFactoryUtil;
029    import com.liferay.portal.kernel.dao.orm.Projection;
030    import com.liferay.portal.kernel.exception.PortalException;
031    import com.liferay.portal.kernel.exception.SystemException;
032    import com.liferay.portal.kernel.search.Indexable;
033    import com.liferay.portal.kernel.search.IndexableType;
034    import com.liferay.portal.kernel.util.OrderByComparator;
035    import com.liferay.portal.model.PersistedModel;
036    import com.liferay.portal.model.PortletPreferences;
037    import com.liferay.portal.service.BaseLocalServiceImpl;
038    import com.liferay.portal.service.PersistedModelLocalServiceRegistry;
039    import com.liferay.portal.service.PortletPreferencesLocalService;
040    import com.liferay.portal.service.persistence.PortletItemPersistence;
041    import com.liferay.portal.service.persistence.PortletPersistence;
042    import com.liferay.portal.service.persistence.PortletPreferencesFinder;
043    import com.liferay.portal.service.persistence.PortletPreferencesPersistence;
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 portlet preferences 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.PortletPreferencesLocalServiceImpl}.
057     * </p>
058     *
059     * @author Brian Wing Shun Chan
060     * @see com.liferay.portal.service.impl.PortletPreferencesLocalServiceImpl
061     * @see com.liferay.portal.service.PortletPreferencesLocalServiceUtil
062     * @generated
063     */
064    @ProviderType
065    public abstract class PortletPreferencesLocalServiceBaseImpl
066            extends BaseLocalServiceImpl implements PortletPreferencesLocalService,
067                    IdentifiableBean {
068            /*
069             * NOTE FOR DEVELOPERS:
070             *
071             * Never modify or reference this class directly. Always use {@link com.liferay.portal.service.PortletPreferencesLocalServiceUtil} to access the portlet preferences local service.
072             */
073    
074            /**
075             * Adds the portlet preferences to the database. Also notifies the appropriate model listeners.
076             *
077             * @param portletPreferences the portlet preferences
078             * @return the portlet preferences that was added
079             */
080            @Indexable(type = IndexableType.REINDEX)
081            @Override
082            public PortletPreferences addPortletPreferences(
083                    PortletPreferences portletPreferences) {
084                    portletPreferences.setNew(true);
085    
086                    return portletPreferencesPersistence.update(portletPreferences);
087            }
088    
089            /**
090             * Creates a new portlet preferences with the primary key. Does not add the portlet preferences to the database.
091             *
092             * @param portletPreferencesId the primary key for the new portlet preferences
093             * @return the new portlet preferences
094             */
095            @Override
096            public PortletPreferences createPortletPreferences(
097                    long portletPreferencesId) {
098                    return portletPreferencesPersistence.create(portletPreferencesId);
099            }
100    
101            /**
102             * Deletes the portlet preferences with the primary key from the database. Also notifies the appropriate model listeners.
103             *
104             * @param portletPreferencesId the primary key of the portlet preferences
105             * @return the portlet preferences that was removed
106             * @throws PortalException if a portlet preferences with the primary key could not be found
107             */
108            @Indexable(type = IndexableType.DELETE)
109            @Override
110            public PortletPreferences deletePortletPreferences(
111                    long portletPreferencesId) throws PortalException {
112                    return portletPreferencesPersistence.remove(portletPreferencesId);
113            }
114    
115            /**
116             * Deletes the portlet preferences from the database. Also notifies the appropriate model listeners.
117             *
118             * @param portletPreferences the portlet preferences
119             * @return the portlet preferences that was removed
120             */
121            @Indexable(type = IndexableType.DELETE)
122            @Override
123            public PortletPreferences deletePortletPreferences(
124                    PortletPreferences portletPreferences) {
125                    return portletPreferencesPersistence.remove(portletPreferences);
126            }
127    
128            @Override
129            public DynamicQuery dynamicQuery() {
130                    Class<?> clazz = getClass();
131    
132                    return DynamicQueryFactoryUtil.forClass(PortletPreferences.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 portletPreferencesPersistence.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.PortletPreferencesModelImpl}. 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 portletPreferencesPersistence.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.PortletPreferencesModelImpl}. 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 portletPreferencesPersistence.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 portletPreferencesPersistence.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 portletPreferencesPersistence.countWithDynamicQuery(dynamicQuery,
208                            projection);
209            }
210    
211            @Override
212            public PortletPreferences fetchPortletPreferences(long portletPreferencesId) {
213                    return portletPreferencesPersistence.fetchByPrimaryKey(portletPreferencesId);
214            }
215    
216            /**
217             * Returns the portlet preferences with the primary key.
218             *
219             * @param portletPreferencesId the primary key of the portlet preferences
220             * @return the portlet preferences
221             * @throws PortalException if a portlet preferences with the primary key could not be found
222             */
223            @Override
224            public PortletPreferences getPortletPreferences(long portletPreferencesId)
225                    throws PortalException {
226                    return portletPreferencesPersistence.findByPrimaryKey(portletPreferencesId);
227            }
228    
229            @Override
230            public ActionableDynamicQuery getActionableDynamicQuery() {
231                    ActionableDynamicQuery actionableDynamicQuery = new DefaultActionableDynamicQuery();
232    
233                    actionableDynamicQuery.setBaseLocalService(com.liferay.portal.service.PortletPreferencesLocalServiceUtil.getService());
234                    actionableDynamicQuery.setClass(PortletPreferences.class);
235                    actionableDynamicQuery.setClassLoader(getClassLoader());
236    
237                    actionableDynamicQuery.setPrimaryKeyPropertyName("portletPreferencesId");
238    
239                    return actionableDynamicQuery;
240            }
241    
242            protected void initActionableDynamicQuery(
243                    ActionableDynamicQuery actionableDynamicQuery) {
244                    actionableDynamicQuery.setBaseLocalService(com.liferay.portal.service.PortletPreferencesLocalServiceUtil.getService());
245                    actionableDynamicQuery.setClass(PortletPreferences.class);
246                    actionableDynamicQuery.setClassLoader(getClassLoader());
247    
248                    actionableDynamicQuery.setPrimaryKeyPropertyName("portletPreferencesId");
249            }
250    
251            /**
252             * @throws PortalException
253             */
254            @Override
255            public PersistedModel deletePersistedModel(PersistedModel persistedModel)
256                    throws PortalException {
257                    return portletPreferencesLocalService.deletePortletPreferences((PortletPreferences)persistedModel);
258            }
259    
260            @Override
261            public PersistedModel getPersistedModel(Serializable primaryKeyObj)
262                    throws PortalException {
263                    return portletPreferencesPersistence.findByPrimaryKey(primaryKeyObj);
264            }
265    
266            /**
267             * Returns a range of all the portlet preferenceses.
268             *
269             * <p>
270             * 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.PortletPreferencesModelImpl}. 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.
271             * </p>
272             *
273             * @param start the lower bound of the range of portlet preferenceses
274             * @param end the upper bound of the range of portlet preferenceses (not inclusive)
275             * @return the range of portlet preferenceses
276             */
277            @Override
278            public List<PortletPreferences> getPortletPreferenceses(int start, int end) {
279                    return portletPreferencesPersistence.findAll(start, end);
280            }
281    
282            /**
283             * Returns the number of portlet preferenceses.
284             *
285             * @return the number of portlet preferenceses
286             */
287            @Override
288            public int getPortletPreferencesesCount() {
289                    return portletPreferencesPersistence.countAll();
290            }
291    
292            /**
293             * Updates the portlet preferences in the database or adds it if it does not yet exist. Also notifies the appropriate model listeners.
294             *
295             * @param portletPreferences the portlet preferences
296             * @return the portlet preferences that was updated
297             */
298            @Indexable(type = IndexableType.REINDEX)
299            @Override
300            public PortletPreferences updatePortletPreferences(
301                    PortletPreferences portletPreferences) {
302                    return portletPreferencesPersistence.update(portletPreferences);
303            }
304    
305            /**
306             * Returns the portlet preferences local service.
307             *
308             * @return the portlet preferences local service
309             */
310            public PortletPreferencesLocalService getPortletPreferencesLocalService() {
311                    return portletPreferencesLocalService;
312            }
313    
314            /**
315             * Sets the portlet preferences local service.
316             *
317             * @param portletPreferencesLocalService the portlet preferences local service
318             */
319            public void setPortletPreferencesLocalService(
320                    PortletPreferencesLocalService portletPreferencesLocalService) {
321                    this.portletPreferencesLocalService = portletPreferencesLocalService;
322            }
323    
324            /**
325             * Returns the portlet preferences remote service.
326             *
327             * @return the portlet preferences remote service
328             */
329            public com.liferay.portal.service.PortletPreferencesService getPortletPreferencesService() {
330                    return portletPreferencesService;
331            }
332    
333            /**
334             * Sets the portlet preferences remote service.
335             *
336             * @param portletPreferencesService the portlet preferences remote service
337             */
338            public void setPortletPreferencesService(
339                    com.liferay.portal.service.PortletPreferencesService portletPreferencesService) {
340                    this.portletPreferencesService = portletPreferencesService;
341            }
342    
343            /**
344             * Returns the portlet preferences persistence.
345             *
346             * @return the portlet preferences persistence
347             */
348            public PortletPreferencesPersistence getPortletPreferencesPersistence() {
349                    return portletPreferencesPersistence;
350            }
351    
352            /**
353             * Sets the portlet preferences persistence.
354             *
355             * @param portletPreferencesPersistence the portlet preferences persistence
356             */
357            public void setPortletPreferencesPersistence(
358                    PortletPreferencesPersistence portletPreferencesPersistence) {
359                    this.portletPreferencesPersistence = portletPreferencesPersistence;
360            }
361    
362            /**
363             * Returns the portlet preferences finder.
364             *
365             * @return the portlet preferences finder
366             */
367            public PortletPreferencesFinder getPortletPreferencesFinder() {
368                    return portletPreferencesFinder;
369            }
370    
371            /**
372             * Sets the portlet preferences finder.
373             *
374             * @param portletPreferencesFinder the portlet preferences finder
375             */
376            public void setPortletPreferencesFinder(
377                    PortletPreferencesFinder portletPreferencesFinder) {
378                    this.portletPreferencesFinder = portletPreferencesFinder;
379            }
380    
381            /**
382             * Returns the counter local service.
383             *
384             * @return the counter local service
385             */
386            public com.liferay.counter.service.CounterLocalService getCounterLocalService() {
387                    return counterLocalService;
388            }
389    
390            /**
391             * Sets the counter local service.
392             *
393             * @param counterLocalService the counter local service
394             */
395            public void setCounterLocalService(
396                    com.liferay.counter.service.CounterLocalService counterLocalService) {
397                    this.counterLocalService = counterLocalService;
398            }
399    
400            /**
401             * Returns the portlet local service.
402             *
403             * @return the portlet local service
404             */
405            public com.liferay.portal.service.PortletLocalService getPortletLocalService() {
406                    return portletLocalService;
407            }
408    
409            /**
410             * Sets the portlet local service.
411             *
412             * @param portletLocalService the portlet local service
413             */
414            public void setPortletLocalService(
415                    com.liferay.portal.service.PortletLocalService portletLocalService) {
416                    this.portletLocalService = portletLocalService;
417            }
418    
419            /**
420             * Returns the portlet remote service.
421             *
422             * @return the portlet remote service
423             */
424            public com.liferay.portal.service.PortletService getPortletService() {
425                    return portletService;
426            }
427    
428            /**
429             * Sets the portlet remote service.
430             *
431             * @param portletService the portlet remote service
432             */
433            public void setPortletService(
434                    com.liferay.portal.service.PortletService portletService) {
435                    this.portletService = portletService;
436            }
437    
438            /**
439             * Returns the portlet persistence.
440             *
441             * @return the portlet persistence
442             */
443            public PortletPersistence getPortletPersistence() {
444                    return portletPersistence;
445            }
446    
447            /**
448             * Sets the portlet persistence.
449             *
450             * @param portletPersistence the portlet persistence
451             */
452            public void setPortletPersistence(PortletPersistence portletPersistence) {
453                    this.portletPersistence = portletPersistence;
454            }
455    
456            /**
457             * Returns the portlet item local service.
458             *
459             * @return the portlet item local service
460             */
461            public com.liferay.portal.service.PortletItemLocalService getPortletItemLocalService() {
462                    return portletItemLocalService;
463            }
464    
465            /**
466             * Sets the portlet item local service.
467             *
468             * @param portletItemLocalService the portlet item local service
469             */
470            public void setPortletItemLocalService(
471                    com.liferay.portal.service.PortletItemLocalService portletItemLocalService) {
472                    this.portletItemLocalService = portletItemLocalService;
473            }
474    
475            /**
476             * Returns the portlet item persistence.
477             *
478             * @return the portlet item persistence
479             */
480            public PortletItemPersistence getPortletItemPersistence() {
481                    return portletItemPersistence;
482            }
483    
484            /**
485             * Sets the portlet item persistence.
486             *
487             * @param portletItemPersistence the portlet item persistence
488             */
489            public void setPortletItemPersistence(
490                    PortletItemPersistence portletItemPersistence) {
491                    this.portletItemPersistence = portletItemPersistence;
492            }
493    
494            public void afterPropertiesSet() {
495                    persistedModelLocalServiceRegistry.register("com.liferay.portal.model.PortletPreferences",
496                            portletPreferencesLocalService);
497            }
498    
499            public void destroy() {
500                    persistedModelLocalServiceRegistry.unregister(
501                            "com.liferay.portal.model.PortletPreferences");
502            }
503    
504            /**
505             * Returns the Spring bean ID for this bean.
506             *
507             * @return the Spring bean ID for this bean
508             */
509            @Override
510            public String getBeanIdentifier() {
511                    return _beanIdentifier;
512            }
513    
514            /**
515             * Sets the Spring bean ID for this bean.
516             *
517             * @param beanIdentifier the Spring bean ID for this bean
518             */
519            @Override
520            public void setBeanIdentifier(String beanIdentifier) {
521                    _beanIdentifier = beanIdentifier;
522            }
523    
524            protected Class<?> getModelClass() {
525                    return PortletPreferences.class;
526            }
527    
528            protected String getModelClassName() {
529                    return PortletPreferences.class.getName();
530            }
531    
532            /**
533             * Performs a SQL query.
534             *
535             * @param sql the sql query
536             */
537            protected void runSQL(String sql) {
538                    try {
539                            DataSource dataSource = portletPreferencesPersistence.getDataSource();
540    
541                            DB db = DBFactoryUtil.getDB();
542    
543                            sql = db.buildSQL(sql);
544                            sql = PortalUtil.transformSQL(sql);
545    
546                            SqlUpdate sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(dataSource,
547                                            sql, new int[0]);
548    
549                            sqlUpdate.update();
550                    }
551                    catch (Exception e) {
552                            throw new SystemException(e);
553                    }
554            }
555    
556            @BeanReference(type = PortletPreferencesLocalService.class)
557            protected PortletPreferencesLocalService portletPreferencesLocalService;
558            @BeanReference(type = com.liferay.portal.service.PortletPreferencesService.class)
559            protected com.liferay.portal.service.PortletPreferencesService portletPreferencesService;
560            @BeanReference(type = PortletPreferencesPersistence.class)
561            protected PortletPreferencesPersistence portletPreferencesPersistence;
562            @BeanReference(type = PortletPreferencesFinder.class)
563            protected PortletPreferencesFinder portletPreferencesFinder;
564            @BeanReference(type = com.liferay.counter.service.CounterLocalService.class)
565            protected com.liferay.counter.service.CounterLocalService counterLocalService;
566            @BeanReference(type = com.liferay.portal.service.PortletLocalService.class)
567            protected com.liferay.portal.service.PortletLocalService portletLocalService;
568            @BeanReference(type = com.liferay.portal.service.PortletService.class)
569            protected com.liferay.portal.service.PortletService portletService;
570            @BeanReference(type = PortletPersistence.class)
571            protected PortletPersistence portletPersistence;
572            @BeanReference(type = com.liferay.portal.service.PortletItemLocalService.class)
573            protected com.liferay.portal.service.PortletItemLocalService portletItemLocalService;
574            @BeanReference(type = PortletItemPersistence.class)
575            protected PortletItemPersistence portletItemPersistence;
576            @BeanReference(type = PersistedModelLocalServiceRegistry.class)
577            protected PersistedModelLocalServiceRegistry persistedModelLocalServiceRegistry;
578            private String _beanIdentifier;
579    }