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