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.DBFactoryUtil;
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.LayoutBranch;
037    import com.liferay.portal.model.PersistedModel;
038    import com.liferay.portal.service.BaseLocalServiceImpl;
039    import com.liferay.portal.service.LayoutBranchLocalService;
040    import com.liferay.portal.service.PersistedModelLocalServiceRegistry;
041    import com.liferay.portal.service.persistence.LayoutBranchPersistence;
042    import com.liferay.portal.service.persistence.LayoutRevisionPersistence;
043    import com.liferay.portal.service.persistence.LayoutSetBranchPersistence;
044    import com.liferay.portal.service.persistence.UserFinder;
045    import com.liferay.portal.service.persistence.UserPersistence;
046    import com.liferay.portal.util.PortalUtil;
047    
048    import java.io.Serializable;
049    
050    import java.util.List;
051    
052    import javax.sql.DataSource;
053    
054    /**
055     * Provides the base implementation for the layout branch local service.
056     *
057     * <p>
058     * 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.LayoutBranchLocalServiceImpl}.
059     * </p>
060     *
061     * @author Brian Wing Shun Chan
062     * @see com.liferay.portal.service.impl.LayoutBranchLocalServiceImpl
063     * @see com.liferay.portal.service.LayoutBranchLocalServiceUtil
064     * @generated
065     */
066    @ProviderType
067    public abstract class LayoutBranchLocalServiceBaseImpl
068            extends BaseLocalServiceImpl implements LayoutBranchLocalService,
069                    IdentifiableOSGiService {
070            /*
071             * NOTE FOR DEVELOPERS:
072             *
073             * Never modify or reference this class directly. Always use {@link com.liferay.portal.service.LayoutBranchLocalServiceUtil} to access the layout branch local service.
074             */
075    
076            /**
077             * Adds the layout branch to the database. Also notifies the appropriate model listeners.
078             *
079             * @param layoutBranch the layout branch
080             * @return the layout branch that was added
081             */
082            @Indexable(type = IndexableType.REINDEX)
083            @Override
084            public LayoutBranch addLayoutBranch(LayoutBranch layoutBranch) {
085                    layoutBranch.setNew(true);
086    
087                    return layoutBranchPersistence.update(layoutBranch);
088            }
089    
090            /**
091             * Creates a new layout branch with the primary key. Does not add the layout branch to the database.
092             *
093             * @param layoutBranchId the primary key for the new layout branch
094             * @return the new layout branch
095             */
096            @Override
097            public LayoutBranch createLayoutBranch(long layoutBranchId) {
098                    return layoutBranchPersistence.create(layoutBranchId);
099            }
100    
101            /**
102             * Deletes the layout branch with the primary key from the database. Also notifies the appropriate model listeners.
103             *
104             * @param layoutBranchId the primary key of the layout branch
105             * @return the layout branch that was removed
106             * @throws PortalException if a layout branch with the primary key could not be found
107             */
108            @Indexable(type = IndexableType.DELETE)
109            @Override
110            public LayoutBranch deleteLayoutBranch(long layoutBranchId)
111                    throws PortalException {
112                    return layoutBranchPersistence.remove(layoutBranchId);
113            }
114    
115            /**
116             * Deletes the layout branch from the database. Also notifies the appropriate model listeners.
117             *
118             * @param layoutBranch the layout branch
119             * @return the layout branch that was removed
120             */
121            @Indexable(type = IndexableType.DELETE)
122            @Override
123            public LayoutBranch deleteLayoutBranch(LayoutBranch layoutBranch) {
124                    return layoutBranchPersistence.remove(layoutBranch);
125            }
126    
127            @Override
128            public DynamicQuery dynamicQuery() {
129                    Class<?> clazz = getClass();
130    
131                    return DynamicQueryFactoryUtil.forClass(LayoutBranch.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 layoutBranchPersistence.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.LayoutBranchModelImpl}. 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 layoutBranchPersistence.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.LayoutBranchModelImpl}. 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 layoutBranchPersistence.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 layoutBranchPersistence.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 layoutBranchPersistence.countWithDynamicQuery(dynamicQuery,
207                            projection);
208            }
209    
210            @Override
211            public LayoutBranch fetchLayoutBranch(long layoutBranchId) {
212                    return layoutBranchPersistence.fetchByPrimaryKey(layoutBranchId);
213            }
214    
215            /**
216             * Returns the layout branch with the primary key.
217             *
218             * @param layoutBranchId the primary key of the layout branch
219             * @return the layout branch
220             * @throws PortalException if a layout branch with the primary key could not be found
221             */
222            @Override
223            public LayoutBranch getLayoutBranch(long layoutBranchId)
224                    throws PortalException {
225                    return layoutBranchPersistence.findByPrimaryKey(layoutBranchId);
226            }
227    
228            @Override
229            public ActionableDynamicQuery getActionableDynamicQuery() {
230                    ActionableDynamicQuery actionableDynamicQuery = new DefaultActionableDynamicQuery();
231    
232                    actionableDynamicQuery.setBaseLocalService(com.liferay.portal.service.LayoutBranchLocalServiceUtil.getService());
233                    actionableDynamicQuery.setClassLoader(getClassLoader());
234                    actionableDynamicQuery.setModelClass(LayoutBranch.class);
235    
236                    actionableDynamicQuery.setPrimaryKeyPropertyName("layoutBranchId");
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.LayoutBranchLocalServiceUtil.getService());
246                    indexableActionableDynamicQuery.setClassLoader(getClassLoader());
247                    indexableActionableDynamicQuery.setModelClass(LayoutBranch.class);
248    
249                    indexableActionableDynamicQuery.setPrimaryKeyPropertyName(
250                            "layoutBranchId");
251    
252                    return indexableActionableDynamicQuery;
253            }
254    
255            protected void initActionableDynamicQuery(
256                    ActionableDynamicQuery actionableDynamicQuery) {
257                    actionableDynamicQuery.setBaseLocalService(com.liferay.portal.service.LayoutBranchLocalServiceUtil.getService());
258                    actionableDynamicQuery.setClassLoader(getClassLoader());
259                    actionableDynamicQuery.setModelClass(LayoutBranch.class);
260    
261                    actionableDynamicQuery.setPrimaryKeyPropertyName("layoutBranchId");
262            }
263    
264            /**
265             * @throws PortalException
266             */
267            @Override
268            public PersistedModel deletePersistedModel(PersistedModel persistedModel)
269                    throws PortalException {
270                    return layoutBranchLocalService.deleteLayoutBranch((LayoutBranch)persistedModel);
271            }
272    
273            @Override
274            public PersistedModel getPersistedModel(Serializable primaryKeyObj)
275                    throws PortalException {
276                    return layoutBranchPersistence.findByPrimaryKey(primaryKeyObj);
277            }
278    
279            /**
280             * Returns a range of all the 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.LayoutBranchModelImpl}. 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 layout branchs
287             * @param end the upper bound of the range of layout branchs (not inclusive)
288             * @return the range of layout branchs
289             */
290            @Override
291            public List<LayoutBranch> getLayoutBranchs(int start, int end) {
292                    return layoutBranchPersistence.findAll(start, end);
293            }
294    
295            /**
296             * Returns the number of layout branchs.
297             *
298             * @return the number of layout branchs
299             */
300            @Override
301            public int getLayoutBranchsCount() {
302                    return layoutBranchPersistence.countAll();
303            }
304    
305            /**
306             * Updates the layout branch in the database or adds it if it does not yet exist. Also notifies the appropriate model listeners.
307             *
308             * @param layoutBranch the layout branch
309             * @return the layout branch that was updated
310             */
311            @Indexable(type = IndexableType.REINDEX)
312            @Override
313            public LayoutBranch updateLayoutBranch(LayoutBranch layoutBranch) {
314                    return layoutBranchPersistence.update(layoutBranch);
315            }
316    
317            /**
318             * Returns the layout branch local service.
319             *
320             * @return the layout branch local service
321             */
322            public LayoutBranchLocalService getLayoutBranchLocalService() {
323                    return layoutBranchLocalService;
324            }
325    
326            /**
327             * Sets the layout branch local service.
328             *
329             * @param layoutBranchLocalService the layout branch local service
330             */
331            public void setLayoutBranchLocalService(
332                    LayoutBranchLocalService layoutBranchLocalService) {
333                    this.layoutBranchLocalService = layoutBranchLocalService;
334            }
335    
336            /**
337             * Returns the layout branch persistence.
338             *
339             * @return the layout branch persistence
340             */
341            public LayoutBranchPersistence getLayoutBranchPersistence() {
342                    return layoutBranchPersistence;
343            }
344    
345            /**
346             * Sets the layout branch persistence.
347             *
348             * @param layoutBranchPersistence the layout branch persistence
349             */
350            public void setLayoutBranchPersistence(
351                    LayoutBranchPersistence layoutBranchPersistence) {
352                    this.layoutBranchPersistence = layoutBranchPersistence;
353            }
354    
355            /**
356             * Returns the counter local service.
357             *
358             * @return the counter local service
359             */
360            public com.liferay.counter.service.CounterLocalService getCounterLocalService() {
361                    return counterLocalService;
362            }
363    
364            /**
365             * Sets the counter local service.
366             *
367             * @param counterLocalService the counter local service
368             */
369            public void setCounterLocalService(
370                    com.liferay.counter.service.CounterLocalService counterLocalService) {
371                    this.counterLocalService = counterLocalService;
372            }
373    
374            /**
375             * Returns the layout revision local service.
376             *
377             * @return the layout revision local service
378             */
379            public com.liferay.portal.service.LayoutRevisionLocalService getLayoutRevisionLocalService() {
380                    return layoutRevisionLocalService;
381            }
382    
383            /**
384             * Sets the layout revision local service.
385             *
386             * @param layoutRevisionLocalService the layout revision local service
387             */
388            public void setLayoutRevisionLocalService(
389                    com.liferay.portal.service.LayoutRevisionLocalService layoutRevisionLocalService) {
390                    this.layoutRevisionLocalService = layoutRevisionLocalService;
391            }
392    
393            /**
394             * Returns the layout revision persistence.
395             *
396             * @return the layout revision persistence
397             */
398            public LayoutRevisionPersistence getLayoutRevisionPersistence() {
399                    return layoutRevisionPersistence;
400            }
401    
402            /**
403             * Sets the layout revision persistence.
404             *
405             * @param layoutRevisionPersistence the layout revision persistence
406             */
407            public void setLayoutRevisionPersistence(
408                    LayoutRevisionPersistence layoutRevisionPersistence) {
409                    this.layoutRevisionPersistence = layoutRevisionPersistence;
410            }
411    
412            /**
413             * Returns the layout set branch local service.
414             *
415             * @return the layout set branch local service
416             */
417            public com.liferay.portal.service.LayoutSetBranchLocalService getLayoutSetBranchLocalService() {
418                    return layoutSetBranchLocalService;
419            }
420    
421            /**
422             * Sets the layout set branch local service.
423             *
424             * @param layoutSetBranchLocalService the layout set branch local service
425             */
426            public void setLayoutSetBranchLocalService(
427                    com.liferay.portal.service.LayoutSetBranchLocalService layoutSetBranchLocalService) {
428                    this.layoutSetBranchLocalService = layoutSetBranchLocalService;
429            }
430    
431            /**
432             * Returns the layout set branch persistence.
433             *
434             * @return the layout set branch persistence
435             */
436            public LayoutSetBranchPersistence getLayoutSetBranchPersistence() {
437                    return layoutSetBranchPersistence;
438            }
439    
440            /**
441             * Sets the layout set branch persistence.
442             *
443             * @param layoutSetBranchPersistence the layout set branch persistence
444             */
445            public void setLayoutSetBranchPersistence(
446                    LayoutSetBranchPersistence layoutSetBranchPersistence) {
447                    this.layoutSetBranchPersistence = layoutSetBranchPersistence;
448            }
449    
450            /**
451             * Returns the user local service.
452             *
453             * @return the user local service
454             */
455            public com.liferay.portal.service.UserLocalService getUserLocalService() {
456                    return userLocalService;
457            }
458    
459            /**
460             * Sets the user local service.
461             *
462             * @param userLocalService the user local service
463             */
464            public void setUserLocalService(
465                    com.liferay.portal.service.UserLocalService userLocalService) {
466                    this.userLocalService = userLocalService;
467            }
468    
469            /**
470             * Returns the user persistence.
471             *
472             * @return the user persistence
473             */
474            public UserPersistence getUserPersistence() {
475                    return userPersistence;
476            }
477    
478            /**
479             * Sets the user persistence.
480             *
481             * @param userPersistence the user persistence
482             */
483            public void setUserPersistence(UserPersistence userPersistence) {
484                    this.userPersistence = userPersistence;
485            }
486    
487            /**
488             * Returns the user finder.
489             *
490             * @return the user finder
491             */
492            public UserFinder getUserFinder() {
493                    return userFinder;
494            }
495    
496            /**
497             * Sets the user finder.
498             *
499             * @param userFinder the user finder
500             */
501            public void setUserFinder(UserFinder userFinder) {
502                    this.userFinder = userFinder;
503            }
504    
505            public void afterPropertiesSet() {
506                    persistedModelLocalServiceRegistry.register("com.liferay.portal.model.LayoutBranch",
507                            layoutBranchLocalService);
508            }
509    
510            public void destroy() {
511                    persistedModelLocalServiceRegistry.unregister(
512                            "com.liferay.portal.model.LayoutBranch");
513            }
514    
515            /**
516             * Returns the OSGi service identifier.
517             *
518             * @return the OSGi service identifier
519             */
520            @Override
521            public String getOSGiServiceIdentifier() {
522                    return LayoutBranchLocalService.class.getName();
523            }
524    
525            protected Class<?> getModelClass() {
526                    return LayoutBranch.class;
527            }
528    
529            protected String getModelClassName() {
530                    return LayoutBranch.class.getName();
531            }
532    
533            /**
534             * Performs a SQL query.
535             *
536             * @param sql the sql query
537             */
538            protected void runSQL(String sql) {
539                    try {
540                            DataSource dataSource = layoutBranchPersistence.getDataSource();
541    
542                            DB db = DBFactoryUtil.getDB();
543    
544                            sql = db.buildSQL(sql);
545                            sql = PortalUtil.transformSQL(sql);
546    
547                            SqlUpdate sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(dataSource,
548                                            sql, new int[0]);
549    
550                            sqlUpdate.update();
551                    }
552                    catch (Exception e) {
553                            throw new SystemException(e);
554                    }
555            }
556    
557            @BeanReference(type = com.liferay.portal.service.LayoutBranchLocalService.class)
558            protected LayoutBranchLocalService layoutBranchLocalService;
559            @BeanReference(type = LayoutBranchPersistence.class)
560            protected LayoutBranchPersistence layoutBranchPersistence;
561            @BeanReference(type = com.liferay.counter.service.CounterLocalService.class)
562            protected com.liferay.counter.service.CounterLocalService counterLocalService;
563            @BeanReference(type = com.liferay.portal.service.LayoutRevisionLocalService.class)
564            protected com.liferay.portal.service.LayoutRevisionLocalService layoutRevisionLocalService;
565            @BeanReference(type = LayoutRevisionPersistence.class)
566            protected LayoutRevisionPersistence layoutRevisionPersistence;
567            @BeanReference(type = com.liferay.portal.service.LayoutSetBranchLocalService.class)
568            protected com.liferay.portal.service.LayoutSetBranchLocalService layoutSetBranchLocalService;
569            @BeanReference(type = LayoutSetBranchPersistence.class)
570            protected LayoutSetBranchPersistence layoutSetBranchPersistence;
571            @BeanReference(type = com.liferay.portal.service.UserLocalService.class)
572            protected com.liferay.portal.service.UserLocalService userLocalService;
573            @BeanReference(type = UserPersistence.class)
574            protected UserPersistence userPersistence;
575            @BeanReference(type = UserFinder.class)
576            protected UserFinder userFinder;
577            @BeanReference(type = PersistedModelLocalServiceRegistry.class)
578            protected PersistedModelLocalServiceRegistry persistedModelLocalServiceRegistry;
579    }