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.RecentLayoutRevision;
038    import com.liferay.portal.service.BaseLocalServiceImpl;
039    import com.liferay.portal.service.PersistedModelLocalServiceRegistry;
040    import com.liferay.portal.service.RecentLayoutRevisionLocalService;
041    import com.liferay.portal.service.persistence.LayoutRevisionPersistence;
042    import com.liferay.portal.service.persistence.RecentLayoutRevisionPersistence;
043    import com.liferay.portal.util.PortalUtil;
044    
045    import java.io.Serializable;
046    
047    import java.util.List;
048    
049    import javax.sql.DataSource;
050    
051    /**
052     * Provides the base implementation for the recent layout revision local service.
053     *
054     * <p>
055     * This implementation exists only as a container for the default service methods generated by ServiceBuilder. All custom service methods should be put in {@link com.liferay.portal.service.impl.RecentLayoutRevisionLocalServiceImpl}.
056     * </p>
057     *
058     * @author Brian Wing Shun Chan
059     * @see com.liferay.portal.service.impl.RecentLayoutRevisionLocalServiceImpl
060     * @see com.liferay.portal.service.RecentLayoutRevisionLocalServiceUtil
061     * @generated
062     */
063    @ProviderType
064    public abstract class RecentLayoutRevisionLocalServiceBaseImpl
065            extends BaseLocalServiceImpl implements RecentLayoutRevisionLocalService,
066                    IdentifiableOSGiService {
067            /*
068             * NOTE FOR DEVELOPERS:
069             *
070             * Never modify or reference this class directly. Always use {@link com.liferay.portal.service.RecentLayoutRevisionLocalServiceUtil} to access the recent layout revision local service.
071             */
072    
073            /**
074             * Adds the recent layout revision to the database. Also notifies the appropriate model listeners.
075             *
076             * @param recentLayoutRevision the recent layout revision
077             * @return the recent layout revision that was added
078             */
079            @Indexable(type = IndexableType.REINDEX)
080            @Override
081            public RecentLayoutRevision addRecentLayoutRevision(
082                    RecentLayoutRevision recentLayoutRevision) {
083                    recentLayoutRevision.setNew(true);
084    
085                    return recentLayoutRevisionPersistence.update(recentLayoutRevision);
086            }
087    
088            /**
089             * Creates a new recent layout revision with the primary key. Does not add the recent layout revision to the database.
090             *
091             * @param recentLayoutRevisionId the primary key for the new recent layout revision
092             * @return the new recent layout revision
093             */
094            @Override
095            public RecentLayoutRevision createRecentLayoutRevision(
096                    long recentLayoutRevisionId) {
097                    return recentLayoutRevisionPersistence.create(recentLayoutRevisionId);
098            }
099    
100            /**
101             * Deletes the recent layout revision with the primary key from the database. Also notifies the appropriate model listeners.
102             *
103             * @param recentLayoutRevisionId the primary key of the recent layout revision
104             * @return the recent layout revision that was removed
105             * @throws PortalException if a recent layout revision with the primary key could not be found
106             */
107            @Indexable(type = IndexableType.DELETE)
108            @Override
109            public RecentLayoutRevision deleteRecentLayoutRevision(
110                    long recentLayoutRevisionId) throws PortalException {
111                    return recentLayoutRevisionPersistence.remove(recentLayoutRevisionId);
112            }
113    
114            /**
115             * Deletes the recent layout revision from the database. Also notifies the appropriate model listeners.
116             *
117             * @param recentLayoutRevision the recent layout revision
118             * @return the recent layout revision that was removed
119             */
120            @Indexable(type = IndexableType.DELETE)
121            @Override
122            public RecentLayoutRevision deleteRecentLayoutRevision(
123                    RecentLayoutRevision recentLayoutRevision) {
124                    return recentLayoutRevisionPersistence.remove(recentLayoutRevision);
125            }
126    
127            @Override
128            public DynamicQuery dynamicQuery() {
129                    Class<?> clazz = getClass();
130    
131                    return DynamicQueryFactoryUtil.forClass(RecentLayoutRevision.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 recentLayoutRevisionPersistence.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.RecentLayoutRevisionModelImpl}. 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 recentLayoutRevisionPersistence.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.RecentLayoutRevisionModelImpl}. 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 recentLayoutRevisionPersistence.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 recentLayoutRevisionPersistence.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 recentLayoutRevisionPersistence.countWithDynamicQuery(dynamicQuery,
207                            projection);
208            }
209    
210            @Override
211            public RecentLayoutRevision fetchRecentLayoutRevision(
212                    long recentLayoutRevisionId) {
213                    return recentLayoutRevisionPersistence.fetchByPrimaryKey(recentLayoutRevisionId);
214            }
215    
216            /**
217             * Returns the recent layout revision with the primary key.
218             *
219             * @param recentLayoutRevisionId the primary key of the recent layout revision
220             * @return the recent layout revision
221             * @throws PortalException if a recent layout revision with the primary key could not be found
222             */
223            @Override
224            public RecentLayoutRevision getRecentLayoutRevision(
225                    long recentLayoutRevisionId) throws PortalException {
226                    return recentLayoutRevisionPersistence.findByPrimaryKey(recentLayoutRevisionId);
227            }
228    
229            @Override
230            public ActionableDynamicQuery getActionableDynamicQuery() {
231                    ActionableDynamicQuery actionableDynamicQuery = new DefaultActionableDynamicQuery();
232    
233                    actionableDynamicQuery.setBaseLocalService(com.liferay.portal.service.RecentLayoutRevisionLocalServiceUtil.getService());
234                    actionableDynamicQuery.setClassLoader(getClassLoader());
235                    actionableDynamicQuery.setModelClass(RecentLayoutRevision.class);
236    
237                    actionableDynamicQuery.setPrimaryKeyPropertyName(
238                            "recentLayoutRevisionId");
239    
240                    return actionableDynamicQuery;
241            }
242    
243            @Override
244            public IndexableActionableDynamicQuery getIndexableActionableDynamicQuery() {
245                    IndexableActionableDynamicQuery indexableActionableDynamicQuery = new IndexableActionableDynamicQuery();
246    
247                    indexableActionableDynamicQuery.setBaseLocalService(com.liferay.portal.service.RecentLayoutRevisionLocalServiceUtil.getService());
248                    indexableActionableDynamicQuery.setClassLoader(getClassLoader());
249                    indexableActionableDynamicQuery.setModelClass(RecentLayoutRevision.class);
250    
251                    indexableActionableDynamicQuery.setPrimaryKeyPropertyName(
252                            "recentLayoutRevisionId");
253    
254                    return indexableActionableDynamicQuery;
255            }
256    
257            protected void initActionableDynamicQuery(
258                    ActionableDynamicQuery actionableDynamicQuery) {
259                    actionableDynamicQuery.setBaseLocalService(com.liferay.portal.service.RecentLayoutRevisionLocalServiceUtil.getService());
260                    actionableDynamicQuery.setClassLoader(getClassLoader());
261                    actionableDynamicQuery.setModelClass(RecentLayoutRevision.class);
262    
263                    actionableDynamicQuery.setPrimaryKeyPropertyName(
264                            "recentLayoutRevisionId");
265            }
266    
267            /**
268             * @throws PortalException
269             */
270            @Override
271            public PersistedModel deletePersistedModel(PersistedModel persistedModel)
272                    throws PortalException {
273                    return recentLayoutRevisionLocalService.deleteRecentLayoutRevision((RecentLayoutRevision)persistedModel);
274            }
275    
276            @Override
277            public PersistedModel getPersistedModel(Serializable primaryKeyObj)
278                    throws PortalException {
279                    return recentLayoutRevisionPersistence.findByPrimaryKey(primaryKeyObj);
280            }
281    
282            /**
283             * Returns a range of all the recent layout revisions.
284             *
285             * <p>
286             * 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.RecentLayoutRevisionModelImpl}. 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.
287             * </p>
288             *
289             * @param start the lower bound of the range of recent layout revisions
290             * @param end the upper bound of the range of recent layout revisions (not inclusive)
291             * @return the range of recent layout revisions
292             */
293            @Override
294            public List<RecentLayoutRevision> getRecentLayoutRevisions(int start,
295                    int end) {
296                    return recentLayoutRevisionPersistence.findAll(start, end);
297            }
298    
299            /**
300             * Returns the number of recent layout revisions.
301             *
302             * @return the number of recent layout revisions
303             */
304            @Override
305            public int getRecentLayoutRevisionsCount() {
306                    return recentLayoutRevisionPersistence.countAll();
307            }
308    
309            /**
310             * Updates the recent layout revision in the database or adds it if it does not yet exist. Also notifies the appropriate model listeners.
311             *
312             * @param recentLayoutRevision the recent layout revision
313             * @return the recent layout revision that was updated
314             */
315            @Indexable(type = IndexableType.REINDEX)
316            @Override
317            public RecentLayoutRevision updateRecentLayoutRevision(
318                    RecentLayoutRevision recentLayoutRevision) {
319                    return recentLayoutRevisionPersistence.update(recentLayoutRevision);
320            }
321    
322            /**
323             * Returns the recent layout revision local service.
324             *
325             * @return the recent layout revision local service
326             */
327            public RecentLayoutRevisionLocalService getRecentLayoutRevisionLocalService() {
328                    return recentLayoutRevisionLocalService;
329            }
330    
331            /**
332             * Sets the recent layout revision local service.
333             *
334             * @param recentLayoutRevisionLocalService the recent layout revision local service
335             */
336            public void setRecentLayoutRevisionLocalService(
337                    RecentLayoutRevisionLocalService recentLayoutRevisionLocalService) {
338                    this.recentLayoutRevisionLocalService = recentLayoutRevisionLocalService;
339            }
340    
341            /**
342             * Returns the recent layout revision persistence.
343             *
344             * @return the recent layout revision persistence
345             */
346            public RecentLayoutRevisionPersistence getRecentLayoutRevisionPersistence() {
347                    return recentLayoutRevisionPersistence;
348            }
349    
350            /**
351             * Sets the recent layout revision persistence.
352             *
353             * @param recentLayoutRevisionPersistence the recent layout revision persistence
354             */
355            public void setRecentLayoutRevisionPersistence(
356                    RecentLayoutRevisionPersistence recentLayoutRevisionPersistence) {
357                    this.recentLayoutRevisionPersistence = recentLayoutRevisionPersistence;
358            }
359    
360            /**
361             * Returns the counter local service.
362             *
363             * @return the counter local service
364             */
365            public com.liferay.counter.service.CounterLocalService getCounterLocalService() {
366                    return counterLocalService;
367            }
368    
369            /**
370             * Sets the counter local service.
371             *
372             * @param counterLocalService the counter local service
373             */
374            public void setCounterLocalService(
375                    com.liferay.counter.service.CounterLocalService counterLocalService) {
376                    this.counterLocalService = counterLocalService;
377            }
378    
379            /**
380             * Returns the layout revision local service.
381             *
382             * @return the layout revision local service
383             */
384            public com.liferay.portal.service.LayoutRevisionLocalService getLayoutRevisionLocalService() {
385                    return layoutRevisionLocalService;
386            }
387    
388            /**
389             * Sets the layout revision local service.
390             *
391             * @param layoutRevisionLocalService the layout revision local service
392             */
393            public void setLayoutRevisionLocalService(
394                    com.liferay.portal.service.LayoutRevisionLocalService layoutRevisionLocalService) {
395                    this.layoutRevisionLocalService = layoutRevisionLocalService;
396            }
397    
398            /**
399             * Returns the layout revision persistence.
400             *
401             * @return the layout revision persistence
402             */
403            public LayoutRevisionPersistence getLayoutRevisionPersistence() {
404                    return layoutRevisionPersistence;
405            }
406    
407            /**
408             * Sets the layout revision persistence.
409             *
410             * @param layoutRevisionPersistence the layout revision persistence
411             */
412            public void setLayoutRevisionPersistence(
413                    LayoutRevisionPersistence layoutRevisionPersistence) {
414                    this.layoutRevisionPersistence = layoutRevisionPersistence;
415            }
416    
417            public void afterPropertiesSet() {
418                    persistedModelLocalServiceRegistry.register("com.liferay.portal.model.RecentLayoutRevision",
419                            recentLayoutRevisionLocalService);
420            }
421    
422            public void destroy() {
423                    persistedModelLocalServiceRegistry.unregister(
424                            "com.liferay.portal.model.RecentLayoutRevision");
425            }
426    
427            /**
428             * Returns the OSGi service identifier.
429             *
430             * @return the OSGi service identifier
431             */
432            @Override
433            public String getOSGiServiceIdentifier() {
434                    return RecentLayoutRevisionLocalService.class.getName();
435            }
436    
437            protected Class<?> getModelClass() {
438                    return RecentLayoutRevision.class;
439            }
440    
441            protected String getModelClassName() {
442                    return RecentLayoutRevision.class.getName();
443            }
444    
445            /**
446             * Performs a SQL query.
447             *
448             * @param sql the sql query
449             */
450            protected void runSQL(String sql) {
451                    try {
452                            DataSource dataSource = recentLayoutRevisionPersistence.getDataSource();
453    
454                            DB db = DBManagerUtil.getDB();
455    
456                            sql = db.buildSQL(sql);
457                            sql = PortalUtil.transformSQL(sql);
458    
459                            SqlUpdate sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(dataSource,
460                                            sql, new int[0]);
461    
462                            sqlUpdate.update();
463                    }
464                    catch (Exception e) {
465                            throw new SystemException(e);
466                    }
467            }
468    
469            @BeanReference(type = com.liferay.portal.service.RecentLayoutRevisionLocalService.class)
470            protected RecentLayoutRevisionLocalService recentLayoutRevisionLocalService;
471            @BeanReference(type = RecentLayoutRevisionPersistence.class)
472            protected RecentLayoutRevisionPersistence recentLayoutRevisionPersistence;
473            @BeanReference(type = com.liferay.counter.service.CounterLocalService.class)
474            protected com.liferay.counter.service.CounterLocalService counterLocalService;
475            @BeanReference(type = com.liferay.portal.service.LayoutRevisionLocalService.class)
476            protected com.liferay.portal.service.LayoutRevisionLocalService layoutRevisionLocalService;
477            @BeanReference(type = LayoutRevisionPersistence.class)
478            protected LayoutRevisionPersistence layoutRevisionPersistence;
479            @BeanReference(type = PersistedModelLocalServiceRegistry.class)
480            protected PersistedModelLocalServiceRegistry persistedModelLocalServiceRegistry;
481    }