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.RecentLayoutSetBranch;
038    import com.liferay.portal.service.BaseLocalServiceImpl;
039    import com.liferay.portal.service.PersistedModelLocalServiceRegistry;
040    import com.liferay.portal.service.RecentLayoutSetBranchLocalService;
041    import com.liferay.portal.service.persistence.LayoutSetBranchPersistence;
042    import com.liferay.portal.service.persistence.RecentLayoutSetBranchPersistence;
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 set 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.RecentLayoutSetBranchLocalServiceImpl}.
056     * </p>
057     *
058     * @author Brian Wing Shun Chan
059     * @see com.liferay.portal.service.impl.RecentLayoutSetBranchLocalServiceImpl
060     * @see com.liferay.portal.service.RecentLayoutSetBranchLocalServiceUtil
061     * @generated
062     */
063    @ProviderType
064    public abstract class RecentLayoutSetBranchLocalServiceBaseImpl
065            extends BaseLocalServiceImpl implements RecentLayoutSetBranchLocalService,
066                    IdentifiableOSGiService {
067            /*
068             * NOTE FOR DEVELOPERS:
069             *
070             * Never modify or reference this class directly. Always use {@link com.liferay.portal.service.RecentLayoutSetBranchLocalServiceUtil} to access the recent layout set branch local service.
071             */
072    
073            /**
074             * Adds the recent layout set branch to the database. Also notifies the appropriate model listeners.
075             *
076             * @param recentLayoutSetBranch the recent layout set branch
077             * @return the recent layout set branch that was added
078             */
079            @Indexable(type = IndexableType.REINDEX)
080            @Override
081            public RecentLayoutSetBranch addRecentLayoutSetBranch(
082                    RecentLayoutSetBranch recentLayoutSetBranch) {
083                    recentLayoutSetBranch.setNew(true);
084    
085                    return recentLayoutSetBranchPersistence.update(recentLayoutSetBranch);
086            }
087    
088            /**
089             * Creates a new recent layout set branch with the primary key. Does not add the recent layout set branch to the database.
090             *
091             * @param recentLayoutSetBranchId the primary key for the new recent layout set branch
092             * @return the new recent layout set branch
093             */
094            @Override
095            public RecentLayoutSetBranch createRecentLayoutSetBranch(
096                    long recentLayoutSetBranchId) {
097                    return recentLayoutSetBranchPersistence.create(recentLayoutSetBranchId);
098            }
099    
100            /**
101             * Deletes the recent layout set branch with the primary key from the database. Also notifies the appropriate model listeners.
102             *
103             * @param recentLayoutSetBranchId the primary key of the recent layout set branch
104             * @return the recent layout set branch that was removed
105             * @throws PortalException if a recent layout set branch with the primary key could not be found
106             */
107            @Indexable(type = IndexableType.DELETE)
108            @Override
109            public RecentLayoutSetBranch deleteRecentLayoutSetBranch(
110                    long recentLayoutSetBranchId) throws PortalException {
111                    return recentLayoutSetBranchPersistence.remove(recentLayoutSetBranchId);
112            }
113    
114            /**
115             * Deletes the recent layout set branch from the database. Also notifies the appropriate model listeners.
116             *
117             * @param recentLayoutSetBranch the recent layout set branch
118             * @return the recent layout set branch that was removed
119             */
120            @Indexable(type = IndexableType.DELETE)
121            @Override
122            public RecentLayoutSetBranch deleteRecentLayoutSetBranch(
123                    RecentLayoutSetBranch recentLayoutSetBranch) {
124                    return recentLayoutSetBranchPersistence.remove(recentLayoutSetBranch);
125            }
126    
127            @Override
128            public DynamicQuery dynamicQuery() {
129                    Class<?> clazz = getClass();
130    
131                    return DynamicQueryFactoryUtil.forClass(RecentLayoutSetBranch.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 recentLayoutSetBranchPersistence.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.RecentLayoutSetBranchModelImpl}. 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 recentLayoutSetBranchPersistence.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.RecentLayoutSetBranchModelImpl}. 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 recentLayoutSetBranchPersistence.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 recentLayoutSetBranchPersistence.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 recentLayoutSetBranchPersistence.countWithDynamicQuery(dynamicQuery,
207                            projection);
208            }
209    
210            @Override
211            public RecentLayoutSetBranch fetchRecentLayoutSetBranch(
212                    long recentLayoutSetBranchId) {
213                    return recentLayoutSetBranchPersistence.fetchByPrimaryKey(recentLayoutSetBranchId);
214            }
215    
216            /**
217             * Returns the recent layout set branch with the primary key.
218             *
219             * @param recentLayoutSetBranchId the primary key of the recent layout set branch
220             * @return the recent layout set branch
221             * @throws PortalException if a recent layout set branch with the primary key could not be found
222             */
223            @Override
224            public RecentLayoutSetBranch getRecentLayoutSetBranch(
225                    long recentLayoutSetBranchId) throws PortalException {
226                    return recentLayoutSetBranchPersistence.findByPrimaryKey(recentLayoutSetBranchId);
227            }
228    
229            @Override
230            public ActionableDynamicQuery getActionableDynamicQuery() {
231                    ActionableDynamicQuery actionableDynamicQuery = new DefaultActionableDynamicQuery();
232    
233                    actionableDynamicQuery.setBaseLocalService(com.liferay.portal.service.RecentLayoutSetBranchLocalServiceUtil.getService());
234                    actionableDynamicQuery.setClassLoader(getClassLoader());
235                    actionableDynamicQuery.setModelClass(RecentLayoutSetBranch.class);
236    
237                    actionableDynamicQuery.setPrimaryKeyPropertyName(
238                            "recentLayoutSetBranchId");
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.RecentLayoutSetBranchLocalServiceUtil.getService());
248                    indexableActionableDynamicQuery.setClassLoader(getClassLoader());
249                    indexableActionableDynamicQuery.setModelClass(RecentLayoutSetBranch.class);
250    
251                    indexableActionableDynamicQuery.setPrimaryKeyPropertyName(
252                            "recentLayoutSetBranchId");
253    
254                    return indexableActionableDynamicQuery;
255            }
256    
257            protected void initActionableDynamicQuery(
258                    ActionableDynamicQuery actionableDynamicQuery) {
259                    actionableDynamicQuery.setBaseLocalService(com.liferay.portal.service.RecentLayoutSetBranchLocalServiceUtil.getService());
260                    actionableDynamicQuery.setClassLoader(getClassLoader());
261                    actionableDynamicQuery.setModelClass(RecentLayoutSetBranch.class);
262    
263                    actionableDynamicQuery.setPrimaryKeyPropertyName(
264                            "recentLayoutSetBranchId");
265            }
266    
267            /**
268             * @throws PortalException
269             */
270            @Override
271            public PersistedModel deletePersistedModel(PersistedModel persistedModel)
272                    throws PortalException {
273                    return recentLayoutSetBranchLocalService.deleteRecentLayoutSetBranch((RecentLayoutSetBranch)persistedModel);
274            }
275    
276            @Override
277            public PersistedModel getPersistedModel(Serializable primaryKeyObj)
278                    throws PortalException {
279                    return recentLayoutSetBranchPersistence.findByPrimaryKey(primaryKeyObj);
280            }
281    
282            /**
283             * Returns a range of all the recent layout set branchs.
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.RecentLayoutSetBranchModelImpl}. 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 set branchs
290             * @param end the upper bound of the range of recent layout set branchs (not inclusive)
291             * @return the range of recent layout set branchs
292             */
293            @Override
294            public List<RecentLayoutSetBranch> getRecentLayoutSetBranchs(int start,
295                    int end) {
296                    return recentLayoutSetBranchPersistence.findAll(start, end);
297            }
298    
299            /**
300             * Returns the number of recent layout set branchs.
301             *
302             * @return the number of recent layout set branchs
303             */
304            @Override
305            public int getRecentLayoutSetBranchsCount() {
306                    return recentLayoutSetBranchPersistence.countAll();
307            }
308    
309            /**
310             * Updates the recent layout set branch in the database or adds it if it does not yet exist. Also notifies the appropriate model listeners.
311             *
312             * @param recentLayoutSetBranch the recent layout set branch
313             * @return the recent layout set branch that was updated
314             */
315            @Indexable(type = IndexableType.REINDEX)
316            @Override
317            public RecentLayoutSetBranch updateRecentLayoutSetBranch(
318                    RecentLayoutSetBranch recentLayoutSetBranch) {
319                    return recentLayoutSetBranchPersistence.update(recentLayoutSetBranch);
320            }
321    
322            /**
323             * Returns the recent layout set branch local service.
324             *
325             * @return the recent layout set branch local service
326             */
327            public RecentLayoutSetBranchLocalService getRecentLayoutSetBranchLocalService() {
328                    return recentLayoutSetBranchLocalService;
329            }
330    
331            /**
332             * Sets the recent layout set branch local service.
333             *
334             * @param recentLayoutSetBranchLocalService the recent layout set branch local service
335             */
336            public void setRecentLayoutSetBranchLocalService(
337                    RecentLayoutSetBranchLocalService recentLayoutSetBranchLocalService) {
338                    this.recentLayoutSetBranchLocalService = recentLayoutSetBranchLocalService;
339            }
340    
341            /**
342             * Returns the recent layout set branch persistence.
343             *
344             * @return the recent layout set branch persistence
345             */
346            public RecentLayoutSetBranchPersistence getRecentLayoutSetBranchPersistence() {
347                    return recentLayoutSetBranchPersistence;
348            }
349    
350            /**
351             * Sets the recent layout set branch persistence.
352             *
353             * @param recentLayoutSetBranchPersistence the recent layout set branch persistence
354             */
355            public void setRecentLayoutSetBranchPersistence(
356                    RecentLayoutSetBranchPersistence recentLayoutSetBranchPersistence) {
357                    this.recentLayoutSetBranchPersistence = recentLayoutSetBranchPersistence;
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 set branch local service.
381             *
382             * @return the layout set branch local service
383             */
384            public com.liferay.portal.service.LayoutSetBranchLocalService getLayoutSetBranchLocalService() {
385                    return layoutSetBranchLocalService;
386            }
387    
388            /**
389             * Sets the layout set branch local service.
390             *
391             * @param layoutSetBranchLocalService the layout set branch local service
392             */
393            public void setLayoutSetBranchLocalService(
394                    com.liferay.portal.service.LayoutSetBranchLocalService layoutSetBranchLocalService) {
395                    this.layoutSetBranchLocalService = layoutSetBranchLocalService;
396            }
397    
398            /**
399             * Returns the layout set branch persistence.
400             *
401             * @return the layout set branch persistence
402             */
403            public LayoutSetBranchPersistence getLayoutSetBranchPersistence() {
404                    return layoutSetBranchPersistence;
405            }
406    
407            /**
408             * Sets the layout set branch persistence.
409             *
410             * @param layoutSetBranchPersistence the layout set branch persistence
411             */
412            public void setLayoutSetBranchPersistence(
413                    LayoutSetBranchPersistence layoutSetBranchPersistence) {
414                    this.layoutSetBranchPersistence = layoutSetBranchPersistence;
415            }
416    
417            public void afterPropertiesSet() {
418                    persistedModelLocalServiceRegistry.register("com.liferay.portal.model.RecentLayoutSetBranch",
419                            recentLayoutSetBranchLocalService);
420            }
421    
422            public void destroy() {
423                    persistedModelLocalServiceRegistry.unregister(
424                            "com.liferay.portal.model.RecentLayoutSetBranch");
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 RecentLayoutSetBranchLocalService.class.getName();
435            }
436    
437            protected Class<?> getModelClass() {
438                    return RecentLayoutSetBranch.class;
439            }
440    
441            protected String getModelClassName() {
442                    return RecentLayoutSetBranch.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 = recentLayoutSetBranchPersistence.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.RecentLayoutSetBranchLocalService.class)
470            protected RecentLayoutSetBranchLocalService recentLayoutSetBranchLocalService;
471            @BeanReference(type = RecentLayoutSetBranchPersistence.class)
472            protected RecentLayoutSetBranchPersistence recentLayoutSetBranchPersistence;
473            @BeanReference(type = com.liferay.counter.service.CounterLocalService.class)
474            protected com.liferay.counter.service.CounterLocalService counterLocalService;
475            @BeanReference(type = com.liferay.portal.service.LayoutSetBranchLocalService.class)
476            protected com.liferay.portal.service.LayoutSetBranchLocalService layoutSetBranchLocalService;
477            @BeanReference(type = LayoutSetBranchPersistence.class)
478            protected LayoutSetBranchPersistence layoutSetBranchPersistence;
479            @BeanReference(type = PersistedModelLocalServiceRegistry.class)
480            protected PersistedModelLocalServiceRegistry persistedModelLocalServiceRegistry;
481    }