001    /**
002     * Copyright (c) 2000-present Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portal.service.base;
016    
017    import aQute.bnd.annotation.ProviderType;
018    
019    import com.liferay.portal.kernel.bean.BeanReference;
020    import com.liferay.portal.kernel.dao.db.DB;
021    import com.liferay.portal.kernel.dao.db.DBManagerUtil;
022    import com.liferay.portal.kernel.dao.jdbc.SqlUpdate;
023    import com.liferay.portal.kernel.dao.jdbc.SqlUpdateFactoryUtil;
024    import com.liferay.portal.kernel.dao.orm.ActionableDynamicQuery;
025    import com.liferay.portal.kernel.dao.orm.DefaultActionableDynamicQuery;
026    import com.liferay.portal.kernel.dao.orm.DynamicQuery;
027    import com.liferay.portal.kernel.dao.orm.DynamicQueryFactoryUtil;
028    import com.liferay.portal.kernel.dao.orm.IndexableActionableDynamicQuery;
029    import com.liferay.portal.kernel.dao.orm.Projection;
030    import com.liferay.portal.kernel.exception.PortalException;
031    import com.liferay.portal.kernel.exception.SystemException;
032    import com.liferay.portal.kernel.module.framework.service.IdentifiableOSGiService;
033    import com.liferay.portal.kernel.search.Indexable;
034    import com.liferay.portal.kernel.search.IndexableType;
035    import com.liferay.portal.kernel.util.OrderByComparator;
036    import com.liferay.portal.model.PersistedModel;
037    import com.liferay.portal.model.ServiceComponent;
038    import com.liferay.portal.service.BaseLocalServiceImpl;
039    import com.liferay.portal.service.PersistedModelLocalServiceRegistry;
040    import com.liferay.portal.service.ServiceComponentLocalService;
041    import com.liferay.portal.service.persistence.ServiceComponentFinder;
042    import com.liferay.portal.service.persistence.ServiceComponentPersistence;
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 service component 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.ServiceComponentLocalServiceImpl}.
056     * </p>
057     *
058     * @author Brian Wing Shun Chan
059     * @see com.liferay.portal.service.impl.ServiceComponentLocalServiceImpl
060     * @see com.liferay.portal.service.ServiceComponentLocalServiceUtil
061     * @generated
062     */
063    @ProviderType
064    public abstract class ServiceComponentLocalServiceBaseImpl
065            extends BaseLocalServiceImpl implements ServiceComponentLocalService,
066                    IdentifiableOSGiService {
067            /*
068             * NOTE FOR DEVELOPERS:
069             *
070             * Never modify or reference this class directly. Always use {@link com.liferay.portal.service.ServiceComponentLocalServiceUtil} to access the service component local service.
071             */
072    
073            /**
074             * Adds the service component to the database. Also notifies the appropriate model listeners.
075             *
076             * @param serviceComponent the service component
077             * @return the service component that was added
078             */
079            @Indexable(type = IndexableType.REINDEX)
080            @Override
081            public ServiceComponent addServiceComponent(
082                    ServiceComponent serviceComponent) {
083                    serviceComponent.setNew(true);
084    
085                    return serviceComponentPersistence.update(serviceComponent);
086            }
087    
088            /**
089             * Creates a new service component with the primary key. Does not add the service component to the database.
090             *
091             * @param serviceComponentId the primary key for the new service component
092             * @return the new service component
093             */
094            @Override
095            public ServiceComponent createServiceComponent(long serviceComponentId) {
096                    return serviceComponentPersistence.create(serviceComponentId);
097            }
098    
099            /**
100             * Deletes the service component with the primary key from the database. Also notifies the appropriate model listeners.
101             *
102             * @param serviceComponentId the primary key of the service component
103             * @return the service component that was removed
104             * @throws PortalException if a service component with the primary key could not be found
105             */
106            @Indexable(type = IndexableType.DELETE)
107            @Override
108            public ServiceComponent deleteServiceComponent(long serviceComponentId)
109                    throws PortalException {
110                    return serviceComponentPersistence.remove(serviceComponentId);
111            }
112    
113            /**
114             * Deletes the service component from the database. Also notifies the appropriate model listeners.
115             *
116             * @param serviceComponent the service component
117             * @return the service component that was removed
118             */
119            @Indexable(type = IndexableType.DELETE)
120            @Override
121            public ServiceComponent deleteServiceComponent(
122                    ServiceComponent serviceComponent) {
123                    return serviceComponentPersistence.remove(serviceComponent);
124            }
125    
126            @Override
127            public DynamicQuery dynamicQuery() {
128                    Class<?> clazz = getClass();
129    
130                    return DynamicQueryFactoryUtil.forClass(ServiceComponent.class,
131                            clazz.getClassLoader());
132            }
133    
134            /**
135             * Performs a dynamic query on the database and returns the matching rows.
136             *
137             * @param dynamicQuery the dynamic query
138             * @return the matching rows
139             */
140            @Override
141            public <T> List<T> dynamicQuery(DynamicQuery dynamicQuery) {
142                    return serviceComponentPersistence.findWithDynamicQuery(dynamicQuery);
143            }
144    
145            /**
146             * Performs a dynamic query on the database and returns a range of the matching rows.
147             *
148             * <p>
149             * 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.
150             * </p>
151             *
152             * @param dynamicQuery the dynamic query
153             * @param start the lower bound of the range of model instances
154             * @param end the upper bound of the range of model instances (not inclusive)
155             * @return the range of matching rows
156             */
157            @Override
158            public <T> List<T> dynamicQuery(DynamicQuery dynamicQuery, int start,
159                    int end) {
160                    return serviceComponentPersistence.findWithDynamicQuery(dynamicQuery,
161                            start, end);
162            }
163    
164            /**
165             * Performs a dynamic query on the database and returns an ordered range of the matching rows.
166             *
167             * <p>
168             * 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.
169             * </p>
170             *
171             * @param dynamicQuery the dynamic query
172             * @param start the lower bound of the range of model instances
173             * @param end the upper bound of the range of model instances (not inclusive)
174             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
175             * @return the ordered range of matching rows
176             */
177            @Override
178            public <T> List<T> dynamicQuery(DynamicQuery dynamicQuery, int start,
179                    int end, OrderByComparator<T> orderByComparator) {
180                    return serviceComponentPersistence.findWithDynamicQuery(dynamicQuery,
181                            start, end, orderByComparator);
182            }
183    
184            /**
185             * Returns the number of rows matching the dynamic query.
186             *
187             * @param dynamicQuery the dynamic query
188             * @return the number of rows matching the dynamic query
189             */
190            @Override
191            public long dynamicQueryCount(DynamicQuery dynamicQuery) {
192                    return serviceComponentPersistence.countWithDynamicQuery(dynamicQuery);
193            }
194    
195            /**
196             * Returns the number of rows matching the dynamic query.
197             *
198             * @param dynamicQuery the dynamic query
199             * @param projection the projection to apply to the query
200             * @return the number of rows matching the dynamic query
201             */
202            @Override
203            public long dynamicQueryCount(DynamicQuery dynamicQuery,
204                    Projection projection) {
205                    return serviceComponentPersistence.countWithDynamicQuery(dynamicQuery,
206                            projection);
207            }
208    
209            @Override
210            public ServiceComponent fetchServiceComponent(long serviceComponentId) {
211                    return serviceComponentPersistence.fetchByPrimaryKey(serviceComponentId);
212            }
213    
214            /**
215             * Returns the service component with the primary key.
216             *
217             * @param serviceComponentId the primary key of the service component
218             * @return the service component
219             * @throws PortalException if a service component with the primary key could not be found
220             */
221            @Override
222            public ServiceComponent getServiceComponent(long serviceComponentId)
223                    throws PortalException {
224                    return serviceComponentPersistence.findByPrimaryKey(serviceComponentId);
225            }
226    
227            @Override
228            public ActionableDynamicQuery getActionableDynamicQuery() {
229                    ActionableDynamicQuery actionableDynamicQuery = new DefaultActionableDynamicQuery();
230    
231                    actionableDynamicQuery.setBaseLocalService(com.liferay.portal.service.ServiceComponentLocalServiceUtil.getService());
232                    actionableDynamicQuery.setClassLoader(getClassLoader());
233                    actionableDynamicQuery.setModelClass(ServiceComponent.class);
234    
235                    actionableDynamicQuery.setPrimaryKeyPropertyName("serviceComponentId");
236    
237                    return actionableDynamicQuery;
238            }
239    
240            @Override
241            public IndexableActionableDynamicQuery getIndexableActionableDynamicQuery() {
242                    IndexableActionableDynamicQuery indexableActionableDynamicQuery = new IndexableActionableDynamicQuery();
243    
244                    indexableActionableDynamicQuery.setBaseLocalService(com.liferay.portal.service.ServiceComponentLocalServiceUtil.getService());
245                    indexableActionableDynamicQuery.setClassLoader(getClassLoader());
246                    indexableActionableDynamicQuery.setModelClass(ServiceComponent.class);
247    
248                    indexableActionableDynamicQuery.setPrimaryKeyPropertyName(
249                            "serviceComponentId");
250    
251                    return indexableActionableDynamicQuery;
252            }
253    
254            protected void initActionableDynamicQuery(
255                    ActionableDynamicQuery actionableDynamicQuery) {
256                    actionableDynamicQuery.setBaseLocalService(com.liferay.portal.service.ServiceComponentLocalServiceUtil.getService());
257                    actionableDynamicQuery.setClassLoader(getClassLoader());
258                    actionableDynamicQuery.setModelClass(ServiceComponent.class);
259    
260                    actionableDynamicQuery.setPrimaryKeyPropertyName("serviceComponentId");
261            }
262    
263            /**
264             * @throws PortalException
265             */
266            @Override
267            public PersistedModel deletePersistedModel(PersistedModel persistedModel)
268                    throws PortalException {
269                    return serviceComponentLocalService.deleteServiceComponent((ServiceComponent)persistedModel);
270            }
271    
272            @Override
273            public PersistedModel getPersistedModel(Serializable primaryKeyObj)
274                    throws PortalException {
275                    return serviceComponentPersistence.findByPrimaryKey(primaryKeyObj);
276            }
277    
278            /**
279             * Returns a range of all the service components.
280             *
281             * <p>
282             * 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.
283             * </p>
284             *
285             * @param start the lower bound of the range of service components
286             * @param end the upper bound of the range of service components (not inclusive)
287             * @return the range of service components
288             */
289            @Override
290            public List<ServiceComponent> getServiceComponents(int start, int end) {
291                    return serviceComponentPersistence.findAll(start, end);
292            }
293    
294            /**
295             * Returns the number of service components.
296             *
297             * @return the number of service components
298             */
299            @Override
300            public int getServiceComponentsCount() {
301                    return serviceComponentPersistence.countAll();
302            }
303    
304            /**
305             * Updates the service component in the database or adds it if it does not yet exist. Also notifies the appropriate model listeners.
306             *
307             * @param serviceComponent the service component
308             * @return the service component that was updated
309             */
310            @Indexable(type = IndexableType.REINDEX)
311            @Override
312            public ServiceComponent updateServiceComponent(
313                    ServiceComponent serviceComponent) {
314                    return serviceComponentPersistence.update(serviceComponent);
315            }
316    
317            /**
318             * Returns the service component local service.
319             *
320             * @return the service component local service
321             */
322            public ServiceComponentLocalService getServiceComponentLocalService() {
323                    return serviceComponentLocalService;
324            }
325    
326            /**
327             * Sets the service component local service.
328             *
329             * @param serviceComponentLocalService the service component local service
330             */
331            public void setServiceComponentLocalService(
332                    ServiceComponentLocalService serviceComponentLocalService) {
333                    this.serviceComponentLocalService = serviceComponentLocalService;
334            }
335    
336            /**
337             * Returns the service component persistence.
338             *
339             * @return the service component persistence
340             */
341            public ServiceComponentPersistence getServiceComponentPersistence() {
342                    return serviceComponentPersistence;
343            }
344    
345            /**
346             * Sets the service component persistence.
347             *
348             * @param serviceComponentPersistence the service component persistence
349             */
350            public void setServiceComponentPersistence(
351                    ServiceComponentPersistence serviceComponentPersistence) {
352                    this.serviceComponentPersistence = serviceComponentPersistence;
353            }
354    
355            /**
356             * Returns the service component finder.
357             *
358             * @return the service component finder
359             */
360            public ServiceComponentFinder getServiceComponentFinder() {
361                    return serviceComponentFinder;
362            }
363    
364            /**
365             * Sets the service component finder.
366             *
367             * @param serviceComponentFinder the service component finder
368             */
369            public void setServiceComponentFinder(
370                    ServiceComponentFinder serviceComponentFinder) {
371                    this.serviceComponentFinder = serviceComponentFinder;
372            }
373    
374            /**
375             * Returns the counter local service.
376             *
377             * @return the counter local service
378             */
379            public com.liferay.counter.service.CounterLocalService getCounterLocalService() {
380                    return counterLocalService;
381            }
382    
383            /**
384             * Sets the counter local service.
385             *
386             * @param counterLocalService the counter local service
387             */
388            public void setCounterLocalService(
389                    com.liferay.counter.service.CounterLocalService counterLocalService) {
390                    this.counterLocalService = counterLocalService;
391            }
392    
393            public void afterPropertiesSet() {
394                    persistedModelLocalServiceRegistry.register("com.liferay.portal.model.ServiceComponent",
395                            serviceComponentLocalService);
396            }
397    
398            public void destroy() {
399                    persistedModelLocalServiceRegistry.unregister(
400                            "com.liferay.portal.model.ServiceComponent");
401            }
402    
403            /**
404             * Returns the OSGi service identifier.
405             *
406             * @return the OSGi service identifier
407             */
408            @Override
409            public String getOSGiServiceIdentifier() {
410                    return ServiceComponentLocalService.class.getName();
411            }
412    
413            protected Class<?> getModelClass() {
414                    return ServiceComponent.class;
415            }
416    
417            protected String getModelClassName() {
418                    return ServiceComponent.class.getName();
419            }
420    
421            /**
422             * Performs a SQL query.
423             *
424             * @param sql the sql query
425             */
426            protected void runSQL(String sql) {
427                    try {
428                            DataSource dataSource = serviceComponentPersistence.getDataSource();
429    
430                            DB db = DBManagerUtil.getDB();
431    
432                            sql = db.buildSQL(sql);
433                            sql = PortalUtil.transformSQL(sql);
434    
435                            SqlUpdate sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(dataSource,
436                                            sql, new int[0]);
437    
438                            sqlUpdate.update();
439                    }
440                    catch (Exception e) {
441                            throw new SystemException(e);
442                    }
443            }
444    
445            @BeanReference(type = com.liferay.portal.service.ServiceComponentLocalService.class)
446            protected ServiceComponentLocalService serviceComponentLocalService;
447            @BeanReference(type = ServiceComponentPersistence.class)
448            protected ServiceComponentPersistence serviceComponentPersistence;
449            @BeanReference(type = ServiceComponentFinder.class)
450            protected ServiceComponentFinder serviceComponentFinder;
451            @BeanReference(type = com.liferay.counter.service.CounterLocalService.class)
452            protected com.liferay.counter.service.CounterLocalService counterLocalService;
453            @BeanReference(type = PersistedModelLocalServiceRegistry.class)
454            protected PersistedModelLocalServiceRegistry persistedModelLocalServiceRegistry;
455    }