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.LockFinder;
042    import com.liferay.portal.service.persistence.LockPersistence;
043    import com.liferay.portal.service.persistence.UserFinder;
044    import com.liferay.portal.service.persistence.UserPersistence;
045    import com.liferay.portal.util.PortalUtil;
046    
047    import java.io.Serializable;
048    
049    import java.util.List;
050    
051    import javax.sql.DataSource;
052    
053    /**
054     * Provides the base implementation for the background task local service.
055     *
056     * <p>
057     * 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}.
058     * </p>
059     *
060     * @author Brian Wing Shun Chan
061     * @see com.liferay.portal.service.impl.BackgroundTaskLocalServiceImpl
062     * @see com.liferay.portal.service.BackgroundTaskLocalServiceUtil
063     * @generated
064     */
065    @ProviderType
066    public abstract class BackgroundTaskLocalServiceBaseImpl
067            extends BaseLocalServiceImpl implements BackgroundTaskLocalService,
068                    IdentifiableBean {
069            /*
070             * NOTE FOR DEVELOPERS:
071             *
072             * Never modify or reference this class directly. Always use {@link com.liferay.portal.service.BackgroundTaskLocalServiceUtil} to access the background task local service.
073             */
074    
075            /**
076             * Adds the background task to the database. Also notifies the appropriate model listeners.
077             *
078             * @param backgroundTask the background task
079             * @return the background task that was added
080             */
081            @Indexable(type = IndexableType.REINDEX)
082            @Override
083            public BackgroundTask addBackgroundTask(BackgroundTask backgroundTask) {
084                    backgroundTask.setNew(true);
085    
086                    return backgroundTaskPersistence.update(backgroundTask);
087            }
088    
089            /**
090             * Creates a new background task with the primary key. Does not add the background task to the database.
091             *
092             * @param backgroundTaskId the primary key for the new background task
093             * @return the new background task
094             */
095            @Override
096            public BackgroundTask createBackgroundTask(long backgroundTaskId) {
097                    return backgroundTaskPersistence.create(backgroundTaskId);
098            }
099    
100            /**
101             * Deletes the background task with the primary key from the database. Also notifies the appropriate model listeners.
102             *
103             * @param backgroundTaskId the primary key of the background task
104             * @return the background task that was removed
105             * @throws PortalException if a background task with the primary key could not be found
106             */
107            @Indexable(type = IndexableType.DELETE)
108            @Override
109            public BackgroundTask deleteBackgroundTask(long backgroundTaskId)
110                    throws PortalException {
111                    return backgroundTaskPersistence.remove(backgroundTaskId);
112            }
113    
114            /**
115             * Deletes the background task from the database. Also notifies the appropriate model listeners.
116             *
117             * @param backgroundTask the background task
118             * @return the background task that was removed
119             * @throws PortalException
120             */
121            @Indexable(type = IndexableType.DELETE)
122            @Override
123            public BackgroundTask deleteBackgroundTask(BackgroundTask backgroundTask)
124                    throws PortalException {
125                    return backgroundTaskPersistence.remove(backgroundTask);
126            }
127    
128            @Override
129            public DynamicQuery dynamicQuery() {
130                    Class<?> clazz = getClass();
131    
132                    return DynamicQueryFactoryUtil.forClass(BackgroundTask.class,
133                            clazz.getClassLoader());
134            }
135    
136            /**
137             * Performs a dynamic query on the database and returns the matching rows.
138             *
139             * @param dynamicQuery the dynamic query
140             * @return the matching rows
141             */
142            @Override
143            public <T> List<T> dynamicQuery(DynamicQuery dynamicQuery) {
144                    return backgroundTaskPersistence.findWithDynamicQuery(dynamicQuery);
145            }
146    
147            /**
148             * Performs a dynamic query on the database and returns a range of the matching rows.
149             *
150             * <p>
151             * 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.
152             * </p>
153             *
154             * @param dynamicQuery the dynamic query
155             * @param start the lower bound of the range of model instances
156             * @param end the upper bound of the range of model instances (not inclusive)
157             * @return the range of matching rows
158             */
159            @Override
160            public <T> List<T> dynamicQuery(DynamicQuery dynamicQuery, int start,
161                    int end) {
162                    return backgroundTaskPersistence.findWithDynamicQuery(dynamicQuery,
163                            start, end);
164            }
165    
166            /**
167             * Performs a dynamic query on the database and returns an ordered range of the matching rows.
168             *
169             * <p>
170             * 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.
171             * </p>
172             *
173             * @param dynamicQuery the dynamic query
174             * @param start the lower bound of the range of model instances
175             * @param end the upper bound of the range of model instances (not inclusive)
176             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
177             * @return the ordered range of matching rows
178             */
179            @Override
180            public <T> List<T> dynamicQuery(DynamicQuery dynamicQuery, int start,
181                    int end, OrderByComparator<T> orderByComparator) {
182                    return backgroundTaskPersistence.findWithDynamicQuery(dynamicQuery,
183                            start, end, orderByComparator);
184            }
185    
186            /**
187             * Returns the number of rows matching the dynamic query.
188             *
189             * @param dynamicQuery the dynamic query
190             * @return the number of rows matching the dynamic query
191             */
192            @Override
193            public long dynamicQueryCount(DynamicQuery dynamicQuery) {
194                    return backgroundTaskPersistence.countWithDynamicQuery(dynamicQuery);
195            }
196    
197            /**
198             * Returns the number of rows matching the dynamic query.
199             *
200             * @param dynamicQuery the dynamic query
201             * @param projection the projection to apply to the query
202             * @return the number of rows matching the dynamic query
203             */
204            @Override
205            public long dynamicQueryCount(DynamicQuery dynamicQuery,
206                    Projection projection) {
207                    return backgroundTaskPersistence.countWithDynamicQuery(dynamicQuery,
208                            projection);
209            }
210    
211            @Override
212            public BackgroundTask fetchBackgroundTask(long backgroundTaskId) {
213                    return backgroundTaskPersistence.fetchByPrimaryKey(backgroundTaskId);
214            }
215    
216            /**
217             * Returns the background task with the primary key.
218             *
219             * @param backgroundTaskId the primary key of the background task
220             * @return the background task
221             * @throws PortalException if a background task with the primary key could not be found
222             */
223            @Override
224            public BackgroundTask getBackgroundTask(long backgroundTaskId)
225                    throws PortalException {
226                    return backgroundTaskPersistence.findByPrimaryKey(backgroundTaskId);
227            }
228    
229            @Override
230            public ActionableDynamicQuery getActionableDynamicQuery() {
231                    ActionableDynamicQuery actionableDynamicQuery = new DefaultActionableDynamicQuery();
232    
233                    actionableDynamicQuery.setBaseLocalService(com.liferay.portal.service.BackgroundTaskLocalServiceUtil.getService());
234                    actionableDynamicQuery.setClass(BackgroundTask.class);
235                    actionableDynamicQuery.setClassLoader(getClassLoader());
236    
237                    actionableDynamicQuery.setPrimaryKeyPropertyName("backgroundTaskId");
238    
239                    return actionableDynamicQuery;
240            }
241    
242            protected void initActionableDynamicQuery(
243                    ActionableDynamicQuery actionableDynamicQuery) {
244                    actionableDynamicQuery.setBaseLocalService(com.liferay.portal.service.BackgroundTaskLocalServiceUtil.getService());
245                    actionableDynamicQuery.setClass(BackgroundTask.class);
246                    actionableDynamicQuery.setClassLoader(getClassLoader());
247    
248                    actionableDynamicQuery.setPrimaryKeyPropertyName("backgroundTaskId");
249            }
250    
251            /**
252             * @throws PortalException
253             */
254            @Override
255            public PersistedModel deletePersistedModel(PersistedModel persistedModel)
256                    throws PortalException {
257                    return backgroundTaskLocalService.deleteBackgroundTask((BackgroundTask)persistedModel);
258            }
259    
260            @Override
261            public PersistedModel getPersistedModel(Serializable primaryKeyObj)
262                    throws PortalException {
263                    return backgroundTaskPersistence.findByPrimaryKey(primaryKeyObj);
264            }
265    
266            /**
267             * Returns a range of all the background tasks.
268             *
269             * <p>
270             * 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.
271             * </p>
272             *
273             * @param start the lower bound of the range of background tasks
274             * @param end the upper bound of the range of background tasks (not inclusive)
275             * @return the range of background tasks
276             */
277            @Override
278            public List<BackgroundTask> getBackgroundTasks(int start, int end) {
279                    return backgroundTaskPersistence.findAll(start, end);
280            }
281    
282            /**
283             * Returns the number of background tasks.
284             *
285             * @return the number of background tasks
286             */
287            @Override
288            public int getBackgroundTasksCount() {
289                    return backgroundTaskPersistence.countAll();
290            }
291    
292            /**
293             * Updates the background task in the database or adds it if it does not yet exist. Also notifies the appropriate model listeners.
294             *
295             * @param backgroundTask the background task
296             * @return the background task that was updated
297             */
298            @Indexable(type = IndexableType.REINDEX)
299            @Override
300            public BackgroundTask updateBackgroundTask(BackgroundTask backgroundTask) {
301                    return backgroundTaskPersistence.update(backgroundTask);
302            }
303    
304            /**
305             * Returns the background task local service.
306             *
307             * @return the background task local service
308             */
309            public com.liferay.portal.service.BackgroundTaskLocalService getBackgroundTaskLocalService() {
310                    return backgroundTaskLocalService;
311            }
312    
313            /**
314             * Sets the background task local service.
315             *
316             * @param backgroundTaskLocalService the background task local service
317             */
318            public void setBackgroundTaskLocalService(
319                    com.liferay.portal.service.BackgroundTaskLocalService backgroundTaskLocalService) {
320                    this.backgroundTaskLocalService = backgroundTaskLocalService;
321            }
322    
323            /**
324             * Returns the background task remote service.
325             *
326             * @return the background task remote service
327             */
328            public com.liferay.portal.service.BackgroundTaskService getBackgroundTaskService() {
329                    return backgroundTaskService;
330            }
331    
332            /**
333             * Sets the background task remote service.
334             *
335             * @param backgroundTaskService the background task remote service
336             */
337            public void setBackgroundTaskService(
338                    com.liferay.portal.service.BackgroundTaskService backgroundTaskService) {
339                    this.backgroundTaskService = backgroundTaskService;
340            }
341    
342            /**
343             * Returns the background task persistence.
344             *
345             * @return the background task persistence
346             */
347            public BackgroundTaskPersistence getBackgroundTaskPersistence() {
348                    return backgroundTaskPersistence;
349            }
350    
351            /**
352             * Sets the background task persistence.
353             *
354             * @param backgroundTaskPersistence the background task persistence
355             */
356            public void setBackgroundTaskPersistence(
357                    BackgroundTaskPersistence backgroundTaskPersistence) {
358                    this.backgroundTaskPersistence = backgroundTaskPersistence;
359            }
360    
361            /**
362             * Returns the counter local service.
363             *
364             * @return the counter local service
365             */
366            public com.liferay.counter.service.CounterLocalService getCounterLocalService() {
367                    return counterLocalService;
368            }
369    
370            /**
371             * Sets the counter local service.
372             *
373             * @param counterLocalService the counter local service
374             */
375            public void setCounterLocalService(
376                    com.liferay.counter.service.CounterLocalService counterLocalService) {
377                    this.counterLocalService = counterLocalService;
378            }
379    
380            /**
381             * Returns the lock local service.
382             *
383             * @return the lock local service
384             */
385            public com.liferay.portal.service.LockLocalService getLockLocalService() {
386                    return lockLocalService;
387            }
388    
389            /**
390             * Sets the lock local service.
391             *
392             * @param lockLocalService the lock local service
393             */
394            public void setLockLocalService(
395                    com.liferay.portal.service.LockLocalService lockLocalService) {
396                    this.lockLocalService = lockLocalService;
397            }
398    
399            /**
400             * Returns the lock persistence.
401             *
402             * @return the lock persistence
403             */
404            public LockPersistence getLockPersistence() {
405                    return lockPersistence;
406            }
407    
408            /**
409             * Sets the lock persistence.
410             *
411             * @param lockPersistence the lock persistence
412             */
413            public void setLockPersistence(LockPersistence lockPersistence) {
414                    this.lockPersistence = lockPersistence;
415            }
416    
417            /**
418             * Returns the lock finder.
419             *
420             * @return the lock finder
421             */
422            public LockFinder getLockFinder() {
423                    return lockFinder;
424            }
425    
426            /**
427             * Sets the lock finder.
428             *
429             * @param lockFinder the lock finder
430             */
431            public void setLockFinder(LockFinder lockFinder) {
432                    this.lockFinder = lockFinder;
433            }
434    
435            /**
436             * Returns the user local service.
437             *
438             * @return the user local service
439             */
440            public com.liferay.portal.service.UserLocalService getUserLocalService() {
441                    return userLocalService;
442            }
443    
444            /**
445             * Sets the user local service.
446             *
447             * @param userLocalService the user local service
448             */
449            public void setUserLocalService(
450                    com.liferay.portal.service.UserLocalService userLocalService) {
451                    this.userLocalService = userLocalService;
452            }
453    
454            /**
455             * Returns the user remote service.
456             *
457             * @return the user remote service
458             */
459            public com.liferay.portal.service.UserService getUserService() {
460                    return userService;
461            }
462    
463            /**
464             * Sets the user remote service.
465             *
466             * @param userService the user remote service
467             */
468            public void setUserService(
469                    com.liferay.portal.service.UserService userService) {
470                    this.userService = userService;
471            }
472    
473            /**
474             * Returns the user persistence.
475             *
476             * @return the user persistence
477             */
478            public UserPersistence getUserPersistence() {
479                    return userPersistence;
480            }
481    
482            /**
483             * Sets the user persistence.
484             *
485             * @param userPersistence the user persistence
486             */
487            public void setUserPersistence(UserPersistence userPersistence) {
488                    this.userPersistence = userPersistence;
489            }
490    
491            /**
492             * Returns the user finder.
493             *
494             * @return the user finder
495             */
496            public UserFinder getUserFinder() {
497                    return userFinder;
498            }
499    
500            /**
501             * Sets the user finder.
502             *
503             * @param userFinder the user finder
504             */
505            public void setUserFinder(UserFinder userFinder) {
506                    this.userFinder = userFinder;
507            }
508    
509            public void afterPropertiesSet() {
510                    persistedModelLocalServiceRegistry.register("com.liferay.portal.model.BackgroundTask",
511                            backgroundTaskLocalService);
512            }
513    
514            public void destroy() {
515                    persistedModelLocalServiceRegistry.unregister(
516                            "com.liferay.portal.model.BackgroundTask");
517            }
518    
519            /**
520             * Returns the Spring bean ID for this bean.
521             *
522             * @return the Spring bean ID for this bean
523             */
524            @Override
525            public String getBeanIdentifier() {
526                    return _beanIdentifier;
527            }
528    
529            /**
530             * Sets the Spring bean ID for this bean.
531             *
532             * @param beanIdentifier the Spring bean ID for this bean
533             */
534            @Override
535            public void setBeanIdentifier(String beanIdentifier) {
536                    _beanIdentifier = beanIdentifier;
537            }
538    
539            protected Class<?> getModelClass() {
540                    return BackgroundTask.class;
541            }
542    
543            protected String getModelClassName() {
544                    return BackgroundTask.class.getName();
545            }
546    
547            /**
548             * Performs a SQL query.
549             *
550             * @param sql the sql query
551             */
552            protected void runSQL(String sql) {
553                    try {
554                            DataSource dataSource = backgroundTaskPersistence.getDataSource();
555    
556                            DB db = DBFactoryUtil.getDB();
557    
558                            sql = db.buildSQL(sql);
559                            sql = PortalUtil.transformSQL(sql);
560    
561                            SqlUpdate sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(dataSource,
562                                            sql, new int[0]);
563    
564                            sqlUpdate.update();
565                    }
566                    catch (Exception e) {
567                            throw new SystemException(e);
568                    }
569            }
570    
571            @BeanReference(type = com.liferay.portal.service.BackgroundTaskLocalService.class)
572            protected com.liferay.portal.service.BackgroundTaskLocalService backgroundTaskLocalService;
573            @BeanReference(type = com.liferay.portal.service.BackgroundTaskService.class)
574            protected com.liferay.portal.service.BackgroundTaskService backgroundTaskService;
575            @BeanReference(type = BackgroundTaskPersistence.class)
576            protected BackgroundTaskPersistence backgroundTaskPersistence;
577            @BeanReference(type = com.liferay.counter.service.CounterLocalService.class)
578            protected com.liferay.counter.service.CounterLocalService counterLocalService;
579            @BeanReference(type = com.liferay.portal.service.LockLocalService.class)
580            protected com.liferay.portal.service.LockLocalService lockLocalService;
581            @BeanReference(type = LockPersistence.class)
582            protected LockPersistence lockPersistence;
583            @BeanReference(type = LockFinder.class)
584            protected LockFinder lockFinder;
585            @BeanReference(type = com.liferay.portal.service.UserLocalService.class)
586            protected com.liferay.portal.service.UserLocalService userLocalService;
587            @BeanReference(type = com.liferay.portal.service.UserService.class)
588            protected com.liferay.portal.service.UserService userService;
589            @BeanReference(type = UserPersistence.class)
590            protected UserPersistence userPersistence;
591            @BeanReference(type = UserFinder.class)
592            protected UserFinder userFinder;
593            @BeanReference(type = PersistedModelLocalServiceRegistry.class)
594            protected PersistedModelLocalServiceRegistry persistedModelLocalServiceRegistry;
595            private String _beanIdentifier;
596    }