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