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.BackgroundTask;
036    import com.liferay.portal.model.PersistedModel;
037    import com.liferay.portal.service.BackgroundTaskLocalService;
038    import com.liferay.portal.service.BaseLocalServiceImpl;
039    import com.liferay.portal.service.PersistedModelLocalServiceRegistry;
040    import com.liferay.portal.service.persistence.BackgroundTaskPersistence;
041    import com.liferay.portal.service.persistence.UserFinder;
042    import com.liferay.portal.service.persistence.UserPersistence;
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 background task 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.BackgroundTaskLocalServiceImpl}.
056     * </p>
057     *
058     * @author Brian Wing Shun Chan
059     * @see com.liferay.portal.service.impl.BackgroundTaskLocalServiceImpl
060     * @see com.liferay.portal.service.BackgroundTaskLocalServiceUtil
061     * @generated
062     */
063    @ProviderType
064    public abstract class BackgroundTaskLocalServiceBaseImpl
065            extends BaseLocalServiceImpl implements BackgroundTaskLocalService,
066                    IdentifiableBean {
067            /*
068             * NOTE FOR DEVELOPERS:
069             *
070             * Never modify or reference this class directly. Always use {@link com.liferay.portal.service.BackgroundTaskLocalServiceUtil} to access the background task local service.
071             */
072    
073            /**
074             * Adds the background task to the database. Also notifies the appropriate model listeners.
075             *
076             * @param backgroundTask the background task
077             * @return the background task that was added
078             */
079            @Indexable(type = IndexableType.REINDEX)
080            @Override
081            public BackgroundTask addBackgroundTask(BackgroundTask backgroundTask) {
082                    backgroundTask.setNew(true);
083    
084                    return backgroundTaskPersistence.update(backgroundTask);
085            }
086    
087            /**
088             * Creates a new background task with the primary key. Does not add the background task to the database.
089             *
090             * @param backgroundTaskId the primary key for the new background task
091             * @return the new background task
092             */
093            @Override
094            public BackgroundTask createBackgroundTask(long backgroundTaskId) {
095                    return backgroundTaskPersistence.create(backgroundTaskId);
096            }
097    
098            /**
099             * Deletes the background task with the primary key from the database. Also notifies the appropriate model listeners.
100             *
101             * @param backgroundTaskId the primary key of the background task
102             * @return the background task that was removed
103             * @throws PortalException if a background task with the primary key could not be found
104             */
105            @Indexable(type = IndexableType.DELETE)
106            @Override
107            public BackgroundTask deleteBackgroundTask(long backgroundTaskId)
108                    throws PortalException {
109                    return backgroundTaskPersistence.remove(backgroundTaskId);
110            }
111    
112            /**
113             * Deletes the background task from the database. Also notifies the appropriate model listeners.
114             *
115             * @param backgroundTask the background task
116             * @return the background task that was removed
117             * @throws PortalException
118             */
119            @Indexable(type = IndexableType.DELETE)
120            @Override
121            public BackgroundTask deleteBackgroundTask(BackgroundTask backgroundTask)
122                    throws PortalException {
123                    return backgroundTaskPersistence.remove(backgroundTask);
124            }
125    
126            @Override
127            public DynamicQuery dynamicQuery() {
128                    Class<?> clazz = getClass();
129    
130                    return DynamicQueryFactoryUtil.forClass(BackgroundTask.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 backgroundTaskPersistence.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.BackgroundTaskModelImpl}. 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 backgroundTaskPersistence.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.BackgroundTaskModelImpl}. 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 backgroundTaskPersistence.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 backgroundTaskPersistence.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 backgroundTaskPersistence.countWithDynamicQuery(dynamicQuery,
206                            projection);
207            }
208    
209            @Override
210            public BackgroundTask fetchBackgroundTask(long backgroundTaskId) {
211                    return backgroundTaskPersistence.fetchByPrimaryKey(backgroundTaskId);
212            }
213    
214            /**
215             * Returns the background task with the primary key.
216             *
217             * @param backgroundTaskId the primary key of the background task
218             * @return the background task
219             * @throws PortalException if a background task with the primary key could not be found
220             */
221            @Override
222            public BackgroundTask getBackgroundTask(long backgroundTaskId)
223                    throws PortalException {
224                    return backgroundTaskPersistence.findByPrimaryKey(backgroundTaskId);
225            }
226    
227            @Override
228            public ActionableDynamicQuery getActionableDynamicQuery() {
229                    ActionableDynamicQuery actionableDynamicQuery = new DefaultActionableDynamicQuery();
230    
231                    actionableDynamicQuery.setBaseLocalService(com.liferay.portal.service.BackgroundTaskLocalServiceUtil.getService());
232                    actionableDynamicQuery.setClass(BackgroundTask.class);
233                    actionableDynamicQuery.setClassLoader(getClassLoader());
234    
235                    actionableDynamicQuery.setPrimaryKeyPropertyName("backgroundTaskId");
236    
237                    return actionableDynamicQuery;
238            }
239    
240            protected void initActionableDynamicQuery(
241                    ActionableDynamicQuery actionableDynamicQuery) {
242                    actionableDynamicQuery.setBaseLocalService(com.liferay.portal.service.BackgroundTaskLocalServiceUtil.getService());
243                    actionableDynamicQuery.setClass(BackgroundTask.class);
244                    actionableDynamicQuery.setClassLoader(getClassLoader());
245    
246                    actionableDynamicQuery.setPrimaryKeyPropertyName("backgroundTaskId");
247            }
248    
249            /**
250             * @throws PortalException
251             */
252            @Override
253            public PersistedModel deletePersistedModel(PersistedModel persistedModel)
254                    throws PortalException {
255                    return backgroundTaskLocalService.deleteBackgroundTask((BackgroundTask)persistedModel);
256            }
257    
258            @Override
259            public PersistedModel getPersistedModel(Serializable primaryKeyObj)
260                    throws PortalException {
261                    return backgroundTaskPersistence.findByPrimaryKey(primaryKeyObj);
262            }
263    
264            /**
265             * Returns a range of all the background tasks.
266             *
267             * <p>
268             * 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.BackgroundTaskModelImpl}. 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.
269             * </p>
270             *
271             * @param start the lower bound of the range of background tasks
272             * @param end the upper bound of the range of background tasks (not inclusive)
273             * @return the range of background tasks
274             */
275            @Override
276            public List<BackgroundTask> getBackgroundTasks(int start, int end) {
277                    return backgroundTaskPersistence.findAll(start, end);
278            }
279    
280            /**
281             * Returns the number of background tasks.
282             *
283             * @return the number of background tasks
284             */
285            @Override
286            public int getBackgroundTasksCount() {
287                    return backgroundTaskPersistence.countAll();
288            }
289    
290            /**
291             * Updates the background task in the database or adds it if it does not yet exist. Also notifies the appropriate model listeners.
292             *
293             * @param backgroundTask the background task
294             * @return the background task that was updated
295             */
296            @Indexable(type = IndexableType.REINDEX)
297            @Override
298            public BackgroundTask updateBackgroundTask(BackgroundTask backgroundTask) {
299                    return backgroundTaskPersistence.update(backgroundTask);
300            }
301    
302            /**
303             * Returns the background task local service.
304             *
305             * @return the background task local service
306             */
307            public BackgroundTaskLocalService getBackgroundTaskLocalService() {
308                    return backgroundTaskLocalService;
309            }
310    
311            /**
312             * Sets the background task local service.
313             *
314             * @param backgroundTaskLocalService the background task local service
315             */
316            public void setBackgroundTaskLocalService(
317                    BackgroundTaskLocalService backgroundTaskLocalService) {
318                    this.backgroundTaskLocalService = backgroundTaskLocalService;
319            }
320    
321            /**
322             * Returns the background task remote service.
323             *
324             * @return the background task remote service
325             */
326            public com.liferay.portal.service.BackgroundTaskService getBackgroundTaskService() {
327                    return backgroundTaskService;
328            }
329    
330            /**
331             * Sets the background task remote service.
332             *
333             * @param backgroundTaskService the background task remote service
334             */
335            public void setBackgroundTaskService(
336                    com.liferay.portal.service.BackgroundTaskService backgroundTaskService) {
337                    this.backgroundTaskService = backgroundTaskService;
338            }
339    
340            /**
341             * Returns the background task persistence.
342             *
343             * @return the background task persistence
344             */
345            public BackgroundTaskPersistence getBackgroundTaskPersistence() {
346                    return backgroundTaskPersistence;
347            }
348    
349            /**
350             * Sets the background task persistence.
351             *
352             * @param backgroundTaskPersistence the background task persistence
353             */
354            public void setBackgroundTaskPersistence(
355                    BackgroundTaskPersistence backgroundTaskPersistence) {
356                    this.backgroundTaskPersistence = backgroundTaskPersistence;
357            }
358    
359            /**
360             * Returns the counter local service.
361             *
362             * @return the counter local service
363             */
364            public com.liferay.counter.service.CounterLocalService getCounterLocalService() {
365                    return counterLocalService;
366            }
367    
368            /**
369             * Sets the counter local service.
370             *
371             * @param counterLocalService the counter local service
372             */
373            public void setCounterLocalService(
374                    com.liferay.counter.service.CounterLocalService counterLocalService) {
375                    this.counterLocalService = counterLocalService;
376            }
377    
378            /**
379             * Returns the user local service.
380             *
381             * @return the user local service
382             */
383            public com.liferay.portal.service.UserLocalService getUserLocalService() {
384                    return userLocalService;
385            }
386    
387            /**
388             * Sets the user local service.
389             *
390             * @param userLocalService the user local service
391             */
392            public void setUserLocalService(
393                    com.liferay.portal.service.UserLocalService userLocalService) {
394                    this.userLocalService = userLocalService;
395            }
396    
397            /**
398             * Returns the user remote service.
399             *
400             * @return the user remote service
401             */
402            public com.liferay.portal.service.UserService getUserService() {
403                    return userService;
404            }
405    
406            /**
407             * Sets the user remote service.
408             *
409             * @param userService the user remote service
410             */
411            public void setUserService(
412                    com.liferay.portal.service.UserService userService) {
413                    this.userService = userService;
414            }
415    
416            /**
417             * Returns the user persistence.
418             *
419             * @return the user persistence
420             */
421            public UserPersistence getUserPersistence() {
422                    return userPersistence;
423            }
424    
425            /**
426             * Sets the user persistence.
427             *
428             * @param userPersistence the user persistence
429             */
430            public void setUserPersistence(UserPersistence userPersistence) {
431                    this.userPersistence = userPersistence;
432            }
433    
434            /**
435             * Returns the user finder.
436             *
437             * @return the user finder
438             */
439            public UserFinder getUserFinder() {
440                    return userFinder;
441            }
442    
443            /**
444             * Sets the user finder.
445             *
446             * @param userFinder the user finder
447             */
448            public void setUserFinder(UserFinder userFinder) {
449                    this.userFinder = userFinder;
450            }
451    
452            public void afterPropertiesSet() {
453                    persistedModelLocalServiceRegistry.register("com.liferay.portal.model.BackgroundTask",
454                            backgroundTaskLocalService);
455            }
456    
457            public void destroy() {
458                    persistedModelLocalServiceRegistry.unregister(
459                            "com.liferay.portal.model.BackgroundTask");
460            }
461    
462            /**
463             * Returns the Spring bean ID for this bean.
464             *
465             * @return the Spring bean ID for this bean
466             */
467            @Override
468            public String getBeanIdentifier() {
469                    return _beanIdentifier;
470            }
471    
472            /**
473             * Sets the Spring bean ID for this bean.
474             *
475             * @param beanIdentifier the Spring bean ID for this bean
476             */
477            @Override
478            public void setBeanIdentifier(String beanIdentifier) {
479                    _beanIdentifier = beanIdentifier;
480            }
481    
482            protected Class<?> getModelClass() {
483                    return BackgroundTask.class;
484            }
485    
486            protected String getModelClassName() {
487                    return BackgroundTask.class.getName();
488            }
489    
490            /**
491             * Performs a SQL query.
492             *
493             * @param sql the sql query
494             */
495            protected void runSQL(String sql) {
496                    try {
497                            DataSource dataSource = backgroundTaskPersistence.getDataSource();
498    
499                            DB db = DBFactoryUtil.getDB();
500    
501                            sql = db.buildSQL(sql);
502                            sql = PortalUtil.transformSQL(sql);
503    
504                            SqlUpdate sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(dataSource,
505                                            sql, new int[0]);
506    
507                            sqlUpdate.update();
508                    }
509                    catch (Exception e) {
510                            throw new SystemException(e);
511                    }
512            }
513    
514            @BeanReference(type = BackgroundTaskLocalService.class)
515            protected BackgroundTaskLocalService backgroundTaskLocalService;
516            @BeanReference(type = com.liferay.portal.service.BackgroundTaskService.class)
517            protected com.liferay.portal.service.BackgroundTaskService backgroundTaskService;
518            @BeanReference(type = BackgroundTaskPersistence.class)
519            protected BackgroundTaskPersistence backgroundTaskPersistence;
520            @BeanReference(type = com.liferay.counter.service.CounterLocalService.class)
521            protected com.liferay.counter.service.CounterLocalService counterLocalService;
522            @BeanReference(type = com.liferay.portal.service.UserLocalService.class)
523            protected com.liferay.portal.service.UserLocalService userLocalService;
524            @BeanReference(type = com.liferay.portal.service.UserService.class)
525            protected com.liferay.portal.service.UserService userService;
526            @BeanReference(type = UserPersistence.class)
527            protected UserPersistence userPersistence;
528            @BeanReference(type = UserFinder.class)
529            protected UserFinder userFinder;
530            @BeanReference(type = PersistedModelLocalServiceRegistry.class)
531            protected PersistedModelLocalServiceRegistry persistedModelLocalServiceRegistry;
532            private String _beanIdentifier;
533    }