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