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.PortalPreferences;
038    import com.liferay.portal.service.BaseLocalServiceImpl;
039    import com.liferay.portal.service.PersistedModelLocalServiceRegistry;
040    import com.liferay.portal.service.PortalPreferencesLocalService;
041    import com.liferay.portal.service.persistence.PortalPreferencesPersistence;
042    import com.liferay.portal.util.PortalUtil;
043    
044    import java.io.Serializable;
045    
046    import java.util.List;
047    
048    import javax.sql.DataSource;
049    
050    /**
051     * Provides the base implementation for the portal preferences local service.
052     *
053     * <p>
054     * 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.PortalPreferencesLocalServiceImpl}.
055     * </p>
056     *
057     * @author Brian Wing Shun Chan
058     * @see com.liferay.portal.service.impl.PortalPreferencesLocalServiceImpl
059     * @see com.liferay.portal.service.PortalPreferencesLocalServiceUtil
060     * @generated
061     */
062    @ProviderType
063    public abstract class PortalPreferencesLocalServiceBaseImpl
064            extends BaseLocalServiceImpl implements PortalPreferencesLocalService,
065                    IdentifiableOSGiService {
066            /*
067             * NOTE FOR DEVELOPERS:
068             *
069             * Never modify or reference this class directly. Always use {@link com.liferay.portal.service.PortalPreferencesLocalServiceUtil} to access the portal preferences local service.
070             */
071    
072            /**
073             * Adds the portal preferences to the database. Also notifies the appropriate model listeners.
074             *
075             * @param portalPreferences the portal preferences
076             * @return the portal preferences that was added
077             */
078            @Indexable(type = IndexableType.REINDEX)
079            @Override
080            public PortalPreferences addPortalPreferences(
081                    PortalPreferences portalPreferences) {
082                    portalPreferences.setNew(true);
083    
084                    return portalPreferencesPersistence.update(portalPreferences);
085            }
086    
087            /**
088             * Creates a new portal preferences with the primary key. Does not add the portal preferences to the database.
089             *
090             * @param portalPreferencesId the primary key for the new portal preferences
091             * @return the new portal preferences
092             */
093            @Override
094            public PortalPreferences createPortalPreferences(long portalPreferencesId) {
095                    return portalPreferencesPersistence.create(portalPreferencesId);
096            }
097    
098            /**
099             * Deletes the portal preferences with the primary key from the database. Also notifies the appropriate model listeners.
100             *
101             * @param portalPreferencesId the primary key of the portal preferences
102             * @return the portal preferences that was removed
103             * @throws PortalException if a portal preferences with the primary key could not be found
104             */
105            @Indexable(type = IndexableType.DELETE)
106            @Override
107            public PortalPreferences deletePortalPreferences(long portalPreferencesId)
108                    throws PortalException {
109                    return portalPreferencesPersistence.remove(portalPreferencesId);
110            }
111    
112            /**
113             * Deletes the portal preferences from the database. Also notifies the appropriate model listeners.
114             *
115             * @param portalPreferences the portal preferences
116             * @return the portal preferences that was removed
117             */
118            @Indexable(type = IndexableType.DELETE)
119            @Override
120            public PortalPreferences deletePortalPreferences(
121                    PortalPreferences portalPreferences) {
122                    return portalPreferencesPersistence.remove(portalPreferences);
123            }
124    
125            @Override
126            public DynamicQuery dynamicQuery() {
127                    Class<?> clazz = getClass();
128    
129                    return DynamicQueryFactoryUtil.forClass(PortalPreferences.class,
130                            clazz.getClassLoader());
131            }
132    
133            /**
134             * Performs a dynamic query on the database and returns the matching rows.
135             *
136             * @param dynamicQuery the dynamic query
137             * @return the matching rows
138             */
139            @Override
140            public <T> List<T> dynamicQuery(DynamicQuery dynamicQuery) {
141                    return portalPreferencesPersistence.findWithDynamicQuery(dynamicQuery);
142            }
143    
144            /**
145             * Performs a dynamic query on the database and returns a range of the matching rows.
146             *
147             * <p>
148             * 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.PortalPreferencesModelImpl}. 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.
149             * </p>
150             *
151             * @param dynamicQuery the dynamic query
152             * @param start the lower bound of the range of model instances
153             * @param end the upper bound of the range of model instances (not inclusive)
154             * @return the range of matching rows
155             */
156            @Override
157            public <T> List<T> dynamicQuery(DynamicQuery dynamicQuery, int start,
158                    int end) {
159                    return portalPreferencesPersistence.findWithDynamicQuery(dynamicQuery,
160                            start, end);
161            }
162    
163            /**
164             * Performs a dynamic query on the database and returns an ordered range of the matching rows.
165             *
166             * <p>
167             * 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.PortalPreferencesModelImpl}. 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.
168             * </p>
169             *
170             * @param dynamicQuery the dynamic query
171             * @param start the lower bound of the range of model instances
172             * @param end the upper bound of the range of model instances (not inclusive)
173             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
174             * @return the ordered range of matching rows
175             */
176            @Override
177            public <T> List<T> dynamicQuery(DynamicQuery dynamicQuery, int start,
178                    int end, OrderByComparator<T> orderByComparator) {
179                    return portalPreferencesPersistence.findWithDynamicQuery(dynamicQuery,
180                            start, end, orderByComparator);
181            }
182    
183            /**
184             * Returns the number of rows matching the dynamic query.
185             *
186             * @param dynamicQuery the dynamic query
187             * @return the number of rows matching the dynamic query
188             */
189            @Override
190            public long dynamicQueryCount(DynamicQuery dynamicQuery) {
191                    return portalPreferencesPersistence.countWithDynamicQuery(dynamicQuery);
192            }
193    
194            /**
195             * Returns the number of rows matching the dynamic query.
196             *
197             * @param dynamicQuery the dynamic query
198             * @param projection the projection to apply to the query
199             * @return the number of rows matching the dynamic query
200             */
201            @Override
202            public long dynamicQueryCount(DynamicQuery dynamicQuery,
203                    Projection projection) {
204                    return portalPreferencesPersistence.countWithDynamicQuery(dynamicQuery,
205                            projection);
206            }
207    
208            @Override
209            public PortalPreferences fetchPortalPreferences(long portalPreferencesId) {
210                    return portalPreferencesPersistence.fetchByPrimaryKey(portalPreferencesId);
211            }
212    
213            /**
214             * Returns the portal preferences with the primary key.
215             *
216             * @param portalPreferencesId the primary key of the portal preferences
217             * @return the portal preferences
218             * @throws PortalException if a portal preferences with the primary key could not be found
219             */
220            @Override
221            public PortalPreferences getPortalPreferences(long portalPreferencesId)
222                    throws PortalException {
223                    return portalPreferencesPersistence.findByPrimaryKey(portalPreferencesId);
224            }
225    
226            @Override
227            public ActionableDynamicQuery getActionableDynamicQuery() {
228                    ActionableDynamicQuery actionableDynamicQuery = new DefaultActionableDynamicQuery();
229    
230                    actionableDynamicQuery.setBaseLocalService(com.liferay.portal.service.PortalPreferencesLocalServiceUtil.getService());
231                    actionableDynamicQuery.setClassLoader(getClassLoader());
232                    actionableDynamicQuery.setModelClass(PortalPreferences.class);
233    
234                    actionableDynamicQuery.setPrimaryKeyPropertyName("portalPreferencesId");
235    
236                    return actionableDynamicQuery;
237            }
238    
239            @Override
240            public IndexableActionableDynamicQuery getIndexableActionableDynamicQuery() {
241                    IndexableActionableDynamicQuery indexableActionableDynamicQuery = new IndexableActionableDynamicQuery();
242    
243                    indexableActionableDynamicQuery.setBaseLocalService(com.liferay.portal.service.PortalPreferencesLocalServiceUtil.getService());
244                    indexableActionableDynamicQuery.setClassLoader(getClassLoader());
245                    indexableActionableDynamicQuery.setModelClass(PortalPreferences.class);
246    
247                    indexableActionableDynamicQuery.setPrimaryKeyPropertyName(
248                            "portalPreferencesId");
249    
250                    return indexableActionableDynamicQuery;
251            }
252    
253            protected void initActionableDynamicQuery(
254                    ActionableDynamicQuery actionableDynamicQuery) {
255                    actionableDynamicQuery.setBaseLocalService(com.liferay.portal.service.PortalPreferencesLocalServiceUtil.getService());
256                    actionableDynamicQuery.setClassLoader(getClassLoader());
257                    actionableDynamicQuery.setModelClass(PortalPreferences.class);
258    
259                    actionableDynamicQuery.setPrimaryKeyPropertyName("portalPreferencesId");
260            }
261    
262            /**
263             * @throws PortalException
264             */
265            @Override
266            public PersistedModel deletePersistedModel(PersistedModel persistedModel)
267                    throws PortalException {
268                    return portalPreferencesLocalService.deletePortalPreferences((PortalPreferences)persistedModel);
269            }
270    
271            @Override
272            public PersistedModel getPersistedModel(Serializable primaryKeyObj)
273                    throws PortalException {
274                    return portalPreferencesPersistence.findByPrimaryKey(primaryKeyObj);
275            }
276    
277            /**
278             * Returns a range of all the portal preferenceses.
279             *
280             * <p>
281             * 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.PortalPreferencesModelImpl}. 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.
282             * </p>
283             *
284             * @param start the lower bound of the range of portal preferenceses
285             * @param end the upper bound of the range of portal preferenceses (not inclusive)
286             * @return the range of portal preferenceses
287             */
288            @Override
289            public List<PortalPreferences> getPortalPreferenceses(int start, int end) {
290                    return portalPreferencesPersistence.findAll(start, end);
291            }
292    
293            /**
294             * Returns the number of portal preferenceses.
295             *
296             * @return the number of portal preferenceses
297             */
298            @Override
299            public int getPortalPreferencesesCount() {
300                    return portalPreferencesPersistence.countAll();
301            }
302    
303            /**
304             * Updates the portal preferences in the database or adds it if it does not yet exist. Also notifies the appropriate model listeners.
305             *
306             * @param portalPreferences the portal preferences
307             * @return the portal preferences that was updated
308             */
309            @Indexable(type = IndexableType.REINDEX)
310            @Override
311            public PortalPreferences updatePortalPreferences(
312                    PortalPreferences portalPreferences) {
313                    return portalPreferencesPersistence.update(portalPreferences);
314            }
315    
316            /**
317             * Returns the portal preferences local service.
318             *
319             * @return the portal preferences local service
320             */
321            public PortalPreferencesLocalService getPortalPreferencesLocalService() {
322                    return portalPreferencesLocalService;
323            }
324    
325            /**
326             * Sets the portal preferences local service.
327             *
328             * @param portalPreferencesLocalService the portal preferences local service
329             */
330            public void setPortalPreferencesLocalService(
331                    PortalPreferencesLocalService portalPreferencesLocalService) {
332                    this.portalPreferencesLocalService = portalPreferencesLocalService;
333            }
334    
335            /**
336             * Returns the portal preferences persistence.
337             *
338             * @return the portal preferences persistence
339             */
340            public PortalPreferencesPersistence getPortalPreferencesPersistence() {
341                    return portalPreferencesPersistence;
342            }
343    
344            /**
345             * Sets the portal preferences persistence.
346             *
347             * @param portalPreferencesPersistence the portal preferences persistence
348             */
349            public void setPortalPreferencesPersistence(
350                    PortalPreferencesPersistence portalPreferencesPersistence) {
351                    this.portalPreferencesPersistence = portalPreferencesPersistence;
352            }
353    
354            /**
355             * Returns the counter local service.
356             *
357             * @return the counter local service
358             */
359            public com.liferay.counter.service.CounterLocalService getCounterLocalService() {
360                    return counterLocalService;
361            }
362    
363            /**
364             * Sets the counter local service.
365             *
366             * @param counterLocalService the counter local service
367             */
368            public void setCounterLocalService(
369                    com.liferay.counter.service.CounterLocalService counterLocalService) {
370                    this.counterLocalService = counterLocalService;
371            }
372    
373            public void afterPropertiesSet() {
374                    persistedModelLocalServiceRegistry.register("com.liferay.portal.model.PortalPreferences",
375                            portalPreferencesLocalService);
376            }
377    
378            public void destroy() {
379                    persistedModelLocalServiceRegistry.unregister(
380                            "com.liferay.portal.model.PortalPreferences");
381            }
382    
383            /**
384             * Returns the OSGi service identifier.
385             *
386             * @return the OSGi service identifier
387             */
388            @Override
389            public String getOSGiServiceIdentifier() {
390                    return PortalPreferencesLocalService.class.getName();
391            }
392    
393            protected Class<?> getModelClass() {
394                    return PortalPreferences.class;
395            }
396    
397            protected String getModelClassName() {
398                    return PortalPreferences.class.getName();
399            }
400    
401            /**
402             * Performs a SQL query.
403             *
404             * @param sql the sql query
405             */
406            protected void runSQL(String sql) {
407                    try {
408                            DataSource dataSource = portalPreferencesPersistence.getDataSource();
409    
410                            DB db = DBManagerUtil.getDB();
411    
412                            sql = db.buildSQL(sql);
413                            sql = PortalUtil.transformSQL(sql);
414    
415                            SqlUpdate sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(dataSource,
416                                            sql, new int[0]);
417    
418                            sqlUpdate.update();
419                    }
420                    catch (Exception e) {
421                            throw new SystemException(e);
422                    }
423            }
424    
425            @BeanReference(type = com.liferay.portal.service.PortalPreferencesLocalService.class)
426            protected PortalPreferencesLocalService portalPreferencesLocalService;
427            @BeanReference(type = PortalPreferencesPersistence.class)
428            protected PortalPreferencesPersistence portalPreferencesPersistence;
429            @BeanReference(type = com.liferay.counter.service.CounterLocalService.class)
430            protected com.liferay.counter.service.CounterLocalService counterLocalService;
431            @BeanReference(type = PersistedModelLocalServiceRegistry.class)
432            protected PersistedModelLocalServiceRegistry persistedModelLocalServiceRegistry;
433    }