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