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.bean.IdentifiableBean;
021    import com.liferay.portal.kernel.dao.db.DB;
022    import com.liferay.portal.kernel.dao.db.DBFactoryUtil;
023    import com.liferay.portal.kernel.dao.jdbc.SqlUpdate;
024    import com.liferay.portal.kernel.dao.jdbc.SqlUpdateFactoryUtil;
025    import com.liferay.portal.kernel.dao.orm.ActionableDynamicQuery;
026    import com.liferay.portal.kernel.dao.orm.DefaultActionableDynamicQuery;
027    import com.liferay.portal.kernel.dao.orm.DynamicQuery;
028    import com.liferay.portal.kernel.dao.orm.DynamicQueryFactoryUtil;
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.search.Indexable;
033    import com.liferay.portal.kernel.search.IndexableType;
034    import com.liferay.portal.kernel.util.OrderByComparator;
035    import com.liferay.portal.model.ListType;
036    import com.liferay.portal.model.PersistedModel;
037    import com.liferay.portal.service.BaseLocalServiceImpl;
038    import com.liferay.portal.service.ListTypeLocalService;
039    import com.liferay.portal.service.PersistedModelLocalServiceRegistry;
040    import com.liferay.portal.service.persistence.ClassNamePersistence;
041    import com.liferay.portal.service.persistence.ListTypePersistence;
042    import com.liferay.portal.util.PortalUtil;
043    
044    import java.io.Serializable;
045    
046    import java.util.List;
047    
048    import javax.sql.DataSource;
049    
050    /**
051     * Provides the base implementation for the list type local service.
052     *
053     * <p>
054     * This implementation exists only as a container for the default service methods generated by ServiceBuilder. All custom service methods should be put in {@link com.liferay.portal.service.impl.ListTypeLocalServiceImpl}.
055     * </p>
056     *
057     * @author Brian Wing Shun Chan
058     * @see com.liferay.portal.service.impl.ListTypeLocalServiceImpl
059     * @see com.liferay.portal.service.ListTypeLocalServiceUtil
060     * @generated
061     */
062    @ProviderType
063    public abstract class ListTypeLocalServiceBaseImpl extends BaseLocalServiceImpl
064            implements ListTypeLocalService, IdentifiableBean {
065            /*
066             * NOTE FOR DEVELOPERS:
067             *
068             * Never modify or reference this class directly. Always use {@link com.liferay.portal.service.ListTypeLocalServiceUtil} to access the list type local service.
069             */
070    
071            /**
072             * Adds the list type to the database. Also notifies the appropriate model listeners.
073             *
074             * @param listType the list type
075             * @return the list type that was added
076             */
077            @Indexable(type = IndexableType.REINDEX)
078            @Override
079            public ListType addListType(ListType listType) {
080                    listType.setNew(true);
081    
082                    return listTypePersistence.update(listType);
083            }
084    
085            /**
086             * Creates a new list type with the primary key. Does not add the list type to the database.
087             *
088             * @param listTypeId the primary key for the new list type
089             * @return the new list type
090             */
091            @Override
092            public ListType createListType(long listTypeId) {
093                    return listTypePersistence.create(listTypeId);
094            }
095    
096            /**
097             * Deletes the list type with the primary key from the database. Also notifies the appropriate model listeners.
098             *
099             * @param listTypeId the primary key of the list type
100             * @return the list type that was removed
101             * @throws PortalException if a list type with the primary key could not be found
102             */
103            @Indexable(type = IndexableType.DELETE)
104            @Override
105            public ListType deleteListType(long listTypeId) throws PortalException {
106                    return listTypePersistence.remove(listTypeId);
107            }
108    
109            /**
110             * Deletes the list type from the database. Also notifies the appropriate model listeners.
111             *
112             * @param listType the list type
113             * @return the list type that was removed
114             */
115            @Indexable(type = IndexableType.DELETE)
116            @Override
117            public ListType deleteListType(ListType listType) {
118                    return listTypePersistence.remove(listType);
119            }
120    
121            @Override
122            public DynamicQuery dynamicQuery() {
123                    Class<?> clazz = getClass();
124    
125                    return DynamicQueryFactoryUtil.forClass(ListType.class,
126                            clazz.getClassLoader());
127            }
128    
129            /**
130             * Performs a dynamic query on the database and returns the matching rows.
131             *
132             * @param dynamicQuery the dynamic query
133             * @return the matching rows
134             */
135            @Override
136            public <T> List<T> dynamicQuery(DynamicQuery dynamicQuery) {
137                    return listTypePersistence.findWithDynamicQuery(dynamicQuery);
138            }
139    
140            /**
141             * Performs a dynamic query on the database and returns a range of the matching rows.
142             *
143             * <p>
144             * 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.ListTypeModelImpl}. 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.
145             * </p>
146             *
147             * @param dynamicQuery the dynamic query
148             * @param start the lower bound of the range of model instances
149             * @param end the upper bound of the range of model instances (not inclusive)
150             * @return the range of matching rows
151             */
152            @Override
153            public <T> List<T> dynamicQuery(DynamicQuery dynamicQuery, int start,
154                    int end) {
155                    return listTypePersistence.findWithDynamicQuery(dynamicQuery, start, end);
156            }
157    
158            /**
159             * Performs a dynamic query on the database and returns an ordered range of the matching rows.
160             *
161             * <p>
162             * 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.ListTypeModelImpl}. 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.
163             * </p>
164             *
165             * @param dynamicQuery the dynamic query
166             * @param start the lower bound of the range of model instances
167             * @param end the upper bound of the range of model instances (not inclusive)
168             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
169             * @return the ordered range of matching rows
170             */
171            @Override
172            public <T> List<T> dynamicQuery(DynamicQuery dynamicQuery, int start,
173                    int end, OrderByComparator<T> orderByComparator) {
174                    return listTypePersistence.findWithDynamicQuery(dynamicQuery, start,
175                            end, orderByComparator);
176            }
177    
178            /**
179             * Returns the number of rows matching the dynamic query.
180             *
181             * @param dynamicQuery the dynamic query
182             * @return the number of rows matching the dynamic query
183             */
184            @Override
185            public long dynamicQueryCount(DynamicQuery dynamicQuery) {
186                    return listTypePersistence.countWithDynamicQuery(dynamicQuery);
187            }
188    
189            /**
190             * Returns the number of rows matching the dynamic query.
191             *
192             * @param dynamicQuery the dynamic query
193             * @param projection the projection to apply to the query
194             * @return the number of rows matching the dynamic query
195             */
196            @Override
197            public long dynamicQueryCount(DynamicQuery dynamicQuery,
198                    Projection projection) {
199                    return listTypePersistence.countWithDynamicQuery(dynamicQuery,
200                            projection);
201            }
202    
203            @Override
204            public ListType fetchListType(long listTypeId) {
205                    return listTypePersistence.fetchByPrimaryKey(listTypeId);
206            }
207    
208            /**
209             * Returns the list type with the primary key.
210             *
211             * @param listTypeId the primary key of the list type
212             * @return the list type
213             * @throws PortalException if a list type with the primary key could not be found
214             */
215            @Override
216            public ListType getListType(long listTypeId) throws PortalException {
217                    return listTypePersistence.findByPrimaryKey(listTypeId);
218            }
219    
220            @Override
221            public ActionableDynamicQuery getActionableDynamicQuery() {
222                    ActionableDynamicQuery actionableDynamicQuery = new DefaultActionableDynamicQuery();
223    
224                    actionableDynamicQuery.setBaseLocalService(com.liferay.portal.service.ListTypeLocalServiceUtil.getService());
225                    actionableDynamicQuery.setClass(ListType.class);
226                    actionableDynamicQuery.setClassLoader(getClassLoader());
227    
228                    actionableDynamicQuery.setPrimaryKeyPropertyName("listTypeId");
229    
230                    return actionableDynamicQuery;
231            }
232    
233            protected void initActionableDynamicQuery(
234                    ActionableDynamicQuery actionableDynamicQuery) {
235                    actionableDynamicQuery.setBaseLocalService(com.liferay.portal.service.ListTypeLocalServiceUtil.getService());
236                    actionableDynamicQuery.setClass(ListType.class);
237                    actionableDynamicQuery.setClassLoader(getClassLoader());
238    
239                    actionableDynamicQuery.setPrimaryKeyPropertyName("listTypeId");
240            }
241    
242            /**
243             * @throws PortalException
244             */
245            @Override
246            public PersistedModel deletePersistedModel(PersistedModel persistedModel)
247                    throws PortalException {
248                    return listTypeLocalService.deleteListType((ListType)persistedModel);
249            }
250    
251            @Override
252            public PersistedModel getPersistedModel(Serializable primaryKeyObj)
253                    throws PortalException {
254                    return listTypePersistence.findByPrimaryKey(primaryKeyObj);
255            }
256    
257            /**
258             * Returns a range of all the list types.
259             *
260             * <p>
261             * 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.ListTypeModelImpl}. 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.
262             * </p>
263             *
264             * @param start the lower bound of the range of list types
265             * @param end the upper bound of the range of list types (not inclusive)
266             * @return the range of list types
267             */
268            @Override
269            public List<ListType> getListTypes(int start, int end) {
270                    return listTypePersistence.findAll(start, end);
271            }
272    
273            /**
274             * Returns the number of list types.
275             *
276             * @return the number of list types
277             */
278            @Override
279            public int getListTypesCount() {
280                    return listTypePersistence.countAll();
281            }
282    
283            /**
284             * Updates the list type in the database or adds it if it does not yet exist. Also notifies the appropriate model listeners.
285             *
286             * @param listType the list type
287             * @return the list type that was updated
288             */
289            @Indexable(type = IndexableType.REINDEX)
290            @Override
291            public ListType updateListType(ListType listType) {
292                    return listTypePersistence.update(listType);
293            }
294    
295            /**
296             * Returns the list type local service.
297             *
298             * @return the list type local service
299             */
300            public ListTypeLocalService getListTypeLocalService() {
301                    return listTypeLocalService;
302            }
303    
304            /**
305             * Sets the list type local service.
306             *
307             * @param listTypeLocalService the list type local service
308             */
309            public void setListTypeLocalService(
310                    ListTypeLocalService listTypeLocalService) {
311                    this.listTypeLocalService = listTypeLocalService;
312            }
313    
314            /**
315             * Returns the list type remote service.
316             *
317             * @return the list type remote service
318             */
319            public com.liferay.portal.service.ListTypeService getListTypeService() {
320                    return listTypeService;
321            }
322    
323            /**
324             * Sets the list type remote service.
325             *
326             * @param listTypeService the list type remote service
327             */
328            public void setListTypeService(
329                    com.liferay.portal.service.ListTypeService listTypeService) {
330                    this.listTypeService = listTypeService;
331            }
332    
333            /**
334             * Returns the list type persistence.
335             *
336             * @return the list type persistence
337             */
338            public ListTypePersistence getListTypePersistence() {
339                    return listTypePersistence;
340            }
341    
342            /**
343             * Sets the list type persistence.
344             *
345             * @param listTypePersistence the list type persistence
346             */
347            public void setListTypePersistence(ListTypePersistence listTypePersistence) {
348                    this.listTypePersistence = listTypePersistence;
349            }
350    
351            /**
352             * Returns the counter local service.
353             *
354             * @return the counter local service
355             */
356            public com.liferay.counter.service.CounterLocalService getCounterLocalService() {
357                    return counterLocalService;
358            }
359    
360            /**
361             * Sets the counter local service.
362             *
363             * @param counterLocalService the counter local service
364             */
365            public void setCounterLocalService(
366                    com.liferay.counter.service.CounterLocalService counterLocalService) {
367                    this.counterLocalService = counterLocalService;
368            }
369    
370            /**
371             * Returns the class name local service.
372             *
373             * @return the class name local service
374             */
375            public com.liferay.portal.service.ClassNameLocalService getClassNameLocalService() {
376                    return classNameLocalService;
377            }
378    
379            /**
380             * Sets the class name local service.
381             *
382             * @param classNameLocalService the class name local service
383             */
384            public void setClassNameLocalService(
385                    com.liferay.portal.service.ClassNameLocalService classNameLocalService) {
386                    this.classNameLocalService = classNameLocalService;
387            }
388    
389            /**
390             * Returns the class name remote service.
391             *
392             * @return the class name remote service
393             */
394            public com.liferay.portal.service.ClassNameService getClassNameService() {
395                    return classNameService;
396            }
397    
398            /**
399             * Sets the class name remote service.
400             *
401             * @param classNameService the class name remote service
402             */
403            public void setClassNameService(
404                    com.liferay.portal.service.ClassNameService classNameService) {
405                    this.classNameService = classNameService;
406            }
407    
408            /**
409             * Returns the class name persistence.
410             *
411             * @return the class name persistence
412             */
413            public ClassNamePersistence getClassNamePersistence() {
414                    return classNamePersistence;
415            }
416    
417            /**
418             * Sets the class name persistence.
419             *
420             * @param classNamePersistence the class name persistence
421             */
422            public void setClassNamePersistence(
423                    ClassNamePersistence classNamePersistence) {
424                    this.classNamePersistence = classNamePersistence;
425            }
426    
427            public void afterPropertiesSet() {
428                    persistedModelLocalServiceRegistry.register("com.liferay.portal.model.ListType",
429                            listTypeLocalService);
430            }
431    
432            public void destroy() {
433                    persistedModelLocalServiceRegistry.unregister(
434                            "com.liferay.portal.model.ListType");
435            }
436    
437            /**
438             * Returns the Spring bean ID for this bean.
439             *
440             * @return the Spring bean ID for this bean
441             */
442            @Override
443            public String getBeanIdentifier() {
444                    return _beanIdentifier;
445            }
446    
447            /**
448             * Sets the Spring bean ID for this bean.
449             *
450             * @param beanIdentifier the Spring bean ID for this bean
451             */
452            @Override
453            public void setBeanIdentifier(String beanIdentifier) {
454                    _beanIdentifier = beanIdentifier;
455            }
456    
457            protected Class<?> getModelClass() {
458                    return ListType.class;
459            }
460    
461            protected String getModelClassName() {
462                    return ListType.class.getName();
463            }
464    
465            /**
466             * Performs a SQL query.
467             *
468             * @param sql the sql query
469             */
470            protected void runSQL(String sql) {
471                    try {
472                            DataSource dataSource = listTypePersistence.getDataSource();
473    
474                            DB db = DBFactoryUtil.getDB();
475    
476                            sql = db.buildSQL(sql);
477                            sql = PortalUtil.transformSQL(sql);
478    
479                            SqlUpdate sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(dataSource,
480                                            sql, new int[0]);
481    
482                            sqlUpdate.update();
483                    }
484                    catch (Exception e) {
485                            throw new SystemException(e);
486                    }
487            }
488    
489            @BeanReference(type = ListTypeLocalService.class)
490            protected ListTypeLocalService listTypeLocalService;
491            @BeanReference(type = com.liferay.portal.service.ListTypeService.class)
492            protected com.liferay.portal.service.ListTypeService listTypeService;
493            @BeanReference(type = ListTypePersistence.class)
494            protected ListTypePersistence listTypePersistence;
495            @BeanReference(type = com.liferay.counter.service.CounterLocalService.class)
496            protected com.liferay.counter.service.CounterLocalService counterLocalService;
497            @BeanReference(type = com.liferay.portal.service.ClassNameLocalService.class)
498            protected com.liferay.portal.service.ClassNameLocalService classNameLocalService;
499            @BeanReference(type = com.liferay.portal.service.ClassNameService.class)
500            protected com.liferay.portal.service.ClassNameService classNameService;
501            @BeanReference(type = ClassNamePersistence.class)
502            protected ClassNamePersistence classNamePersistence;
503            @BeanReference(type = PersistedModelLocalServiceRegistry.class)
504            protected PersistedModelLocalServiceRegistry persistedModelLocalServiceRegistry;
505            private String _beanIdentifier;
506    }