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.UserNotificationDelivery;
038    import com.liferay.portal.service.BaseLocalServiceImpl;
039    import com.liferay.portal.service.PersistedModelLocalServiceRegistry;
040    import com.liferay.portal.service.UserNotificationDeliveryLocalService;
041    import com.liferay.portal.service.persistence.UserFinder;
042    import com.liferay.portal.service.persistence.UserNotificationDeliveryPersistence;
043    import com.liferay.portal.service.persistence.UserPersistence;
044    import com.liferay.portal.util.PortalUtil;
045    
046    import java.io.Serializable;
047    
048    import java.util.List;
049    
050    import javax.sql.DataSource;
051    
052    /**
053     * Provides the base implementation for the user notification delivery local service.
054     *
055     * <p>
056     * 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}.
057     * </p>
058     *
059     * @author Brian Wing Shun Chan
060     * @see com.liferay.portal.service.impl.UserNotificationDeliveryLocalServiceImpl
061     * @see com.liferay.portal.service.UserNotificationDeliveryLocalServiceUtil
062     * @generated
063     */
064    @ProviderType
065    public abstract class UserNotificationDeliveryLocalServiceBaseImpl
066            extends BaseLocalServiceImpl implements UserNotificationDeliveryLocalService,
067                    IdentifiableOSGiService {
068            /*
069             * NOTE FOR DEVELOPERS:
070             *
071             * Never modify or reference this class directly. Always use {@link com.liferay.portal.service.UserNotificationDeliveryLocalServiceUtil} to access the user notification delivery local service.
072             */
073    
074            /**
075             * Adds the user notification delivery to the database. Also notifies the appropriate model listeners.
076             *
077             * @param userNotificationDelivery the user notification delivery
078             * @return the user notification delivery that was added
079             */
080            @Indexable(type = IndexableType.REINDEX)
081            @Override
082            public UserNotificationDelivery addUserNotificationDelivery(
083                    UserNotificationDelivery userNotificationDelivery) {
084                    userNotificationDelivery.setNew(true);
085    
086                    return userNotificationDeliveryPersistence.update(userNotificationDelivery);
087            }
088    
089            /**
090             * Creates a new user notification delivery with the primary key. Does not add the user notification delivery to the database.
091             *
092             * @param userNotificationDeliveryId the primary key for the new user notification delivery
093             * @return the new user notification delivery
094             */
095            @Override
096            public UserNotificationDelivery createUserNotificationDelivery(
097                    long userNotificationDeliveryId) {
098                    return userNotificationDeliveryPersistence.create(userNotificationDeliveryId);
099            }
100    
101            /**
102             * Deletes the user notification delivery with the primary key from the database. Also notifies the appropriate model listeners.
103             *
104             * @param userNotificationDeliveryId the primary key of the user notification delivery
105             * @return the user notification delivery that was removed
106             * @throws PortalException if a user notification delivery with the primary key could not be found
107             */
108            @Indexable(type = IndexableType.DELETE)
109            @Override
110            public UserNotificationDelivery deleteUserNotificationDelivery(
111                    long userNotificationDeliveryId) throws PortalException {
112                    return userNotificationDeliveryPersistence.remove(userNotificationDeliveryId);
113            }
114    
115            /**
116             * Deletes the user notification delivery from the database. Also notifies the appropriate model listeners.
117             *
118             * @param userNotificationDelivery the user notification delivery
119             * @return the user notification delivery that was removed
120             */
121            @Indexable(type = IndexableType.DELETE)
122            @Override
123            public UserNotificationDelivery deleteUserNotificationDelivery(
124                    UserNotificationDelivery userNotificationDelivery) {
125                    return userNotificationDeliveryPersistence.remove(userNotificationDelivery);
126            }
127    
128            @Override
129            public DynamicQuery dynamicQuery() {
130                    Class<?> clazz = getClass();
131    
132                    return DynamicQueryFactoryUtil.forClass(UserNotificationDelivery.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 userNotificationDeliveryPersistence.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.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.
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 userNotificationDeliveryPersistence.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.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.
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 userNotificationDeliveryPersistence.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 userNotificationDeliveryPersistence.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 userNotificationDeliveryPersistence.countWithDynamicQuery(dynamicQuery,
208                            projection);
209            }
210    
211            @Override
212            public UserNotificationDelivery fetchUserNotificationDelivery(
213                    long userNotificationDeliveryId) {
214                    return userNotificationDeliveryPersistence.fetchByPrimaryKey(userNotificationDeliveryId);
215            }
216    
217            /**
218             * Returns the user notification delivery with the primary key.
219             *
220             * @param userNotificationDeliveryId the primary key of the user notification delivery
221             * @return the user notification delivery
222             * @throws PortalException if a user notification delivery with the primary key could not be found
223             */
224            @Override
225            public UserNotificationDelivery getUserNotificationDelivery(
226                    long userNotificationDeliveryId) throws PortalException {
227                    return userNotificationDeliveryPersistence.findByPrimaryKey(userNotificationDeliveryId);
228            }
229    
230            @Override
231            public ActionableDynamicQuery getActionableDynamicQuery() {
232                    ActionableDynamicQuery actionableDynamicQuery = new DefaultActionableDynamicQuery();
233    
234                    actionableDynamicQuery.setBaseLocalService(com.liferay.portal.service.UserNotificationDeliveryLocalServiceUtil.getService());
235                    actionableDynamicQuery.setClassLoader(getClassLoader());
236                    actionableDynamicQuery.setModelClass(UserNotificationDelivery.class);
237    
238                    actionableDynamicQuery.setPrimaryKeyPropertyName(
239                            "userNotificationDeliveryId");
240    
241                    return actionableDynamicQuery;
242            }
243    
244            @Override
245            public IndexableActionableDynamicQuery getIndexableActionableDynamicQuery() {
246                    IndexableActionableDynamicQuery indexableActionableDynamicQuery = new IndexableActionableDynamicQuery();
247    
248                    indexableActionableDynamicQuery.setBaseLocalService(com.liferay.portal.service.UserNotificationDeliveryLocalServiceUtil.getService());
249                    indexableActionableDynamicQuery.setClassLoader(getClassLoader());
250                    indexableActionableDynamicQuery.setModelClass(UserNotificationDelivery.class);
251    
252                    indexableActionableDynamicQuery.setPrimaryKeyPropertyName(
253                            "userNotificationDeliveryId");
254    
255                    return indexableActionableDynamicQuery;
256            }
257    
258            protected void initActionableDynamicQuery(
259                    ActionableDynamicQuery actionableDynamicQuery) {
260                    actionableDynamicQuery.setBaseLocalService(com.liferay.portal.service.UserNotificationDeliveryLocalServiceUtil.getService());
261                    actionableDynamicQuery.setClassLoader(getClassLoader());
262                    actionableDynamicQuery.setModelClass(UserNotificationDelivery.class);
263    
264                    actionableDynamicQuery.setPrimaryKeyPropertyName(
265                            "userNotificationDeliveryId");
266            }
267    
268            /**
269             * @throws PortalException
270             */
271            @Override
272            public PersistedModel deletePersistedModel(PersistedModel persistedModel)
273                    throws PortalException {
274                    return userNotificationDeliveryLocalService.deleteUserNotificationDelivery((UserNotificationDelivery)persistedModel);
275            }
276    
277            @Override
278            public PersistedModel getPersistedModel(Serializable primaryKeyObj)
279                    throws PortalException {
280                    return userNotificationDeliveryPersistence.findByPrimaryKey(primaryKeyObj);
281            }
282    
283            /**
284             * Returns a range of all the user notification deliveries.
285             *
286             * <p>
287             * 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.
288             * </p>
289             *
290             * @param start the lower bound of the range of user notification deliveries
291             * @param end the upper bound of the range of user notification deliveries (not inclusive)
292             * @return the range of user notification deliveries
293             */
294            @Override
295            public List<UserNotificationDelivery> getUserNotificationDeliveries(
296                    int start, int end) {
297                    return userNotificationDeliveryPersistence.findAll(start, end);
298            }
299    
300            /**
301             * Returns the number of user notification deliveries.
302             *
303             * @return the number of user notification deliveries
304             */
305            @Override
306            public int getUserNotificationDeliveriesCount() {
307                    return userNotificationDeliveryPersistence.countAll();
308            }
309    
310            /**
311             * Updates the user notification delivery in the database or adds it if it does not yet exist. Also notifies the appropriate model listeners.
312             *
313             * @param userNotificationDelivery the user notification delivery
314             * @return the user notification delivery that was updated
315             */
316            @Indexable(type = IndexableType.REINDEX)
317            @Override
318            public UserNotificationDelivery updateUserNotificationDelivery(
319                    UserNotificationDelivery userNotificationDelivery) {
320                    return userNotificationDeliveryPersistence.update(userNotificationDelivery);
321            }
322    
323            /**
324             * Returns the user notification delivery local service.
325             *
326             * @return the user notification delivery local service
327             */
328            public UserNotificationDeliveryLocalService getUserNotificationDeliveryLocalService() {
329                    return userNotificationDeliveryLocalService;
330            }
331    
332            /**
333             * Sets the user notification delivery local service.
334             *
335             * @param userNotificationDeliveryLocalService the user notification delivery local service
336             */
337            public void setUserNotificationDeliveryLocalService(
338                    UserNotificationDeliveryLocalService userNotificationDeliveryLocalService) {
339                    this.userNotificationDeliveryLocalService = userNotificationDeliveryLocalService;
340            }
341    
342            /**
343             * Returns the user notification delivery persistence.
344             *
345             * @return the user notification delivery persistence
346             */
347            public UserNotificationDeliveryPersistence getUserNotificationDeliveryPersistence() {
348                    return userNotificationDeliveryPersistence;
349            }
350    
351            /**
352             * Sets the user notification delivery persistence.
353             *
354             * @param userNotificationDeliveryPersistence the user notification delivery persistence
355             */
356            public void setUserNotificationDeliveryPersistence(
357                    UserNotificationDeliveryPersistence userNotificationDeliveryPersistence) {
358                    this.userNotificationDeliveryPersistence = userNotificationDeliveryPersistence;
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 user local service.
382             *
383             * @return the user local service
384             */
385            public com.liferay.portal.service.UserLocalService getUserLocalService() {
386                    return userLocalService;
387            }
388    
389            /**
390             * Sets the user local service.
391             *
392             * @param userLocalService the user local service
393             */
394            public void setUserLocalService(
395                    com.liferay.portal.service.UserLocalService userLocalService) {
396                    this.userLocalService = userLocalService;
397            }
398    
399            /**
400             * Returns the user persistence.
401             *
402             * @return the user persistence
403             */
404            public UserPersistence getUserPersistence() {
405                    return userPersistence;
406            }
407    
408            /**
409             * Sets the user persistence.
410             *
411             * @param userPersistence the user persistence
412             */
413            public void setUserPersistence(UserPersistence userPersistence) {
414                    this.userPersistence = userPersistence;
415            }
416    
417            /**
418             * Returns the user finder.
419             *
420             * @return the user finder
421             */
422            public UserFinder getUserFinder() {
423                    return userFinder;
424            }
425    
426            /**
427             * Sets the user finder.
428             *
429             * @param userFinder the user finder
430             */
431            public void setUserFinder(UserFinder userFinder) {
432                    this.userFinder = userFinder;
433            }
434    
435            public void afterPropertiesSet() {
436                    persistedModelLocalServiceRegistry.register("com.liferay.portal.model.UserNotificationDelivery",
437                            userNotificationDeliveryLocalService);
438            }
439    
440            public void destroy() {
441                    persistedModelLocalServiceRegistry.unregister(
442                            "com.liferay.portal.model.UserNotificationDelivery");
443            }
444    
445            /**
446             * Returns the OSGi service identifier.
447             *
448             * @return the OSGi service identifier
449             */
450            @Override
451            public String getOSGiServiceIdentifier() {
452                    return UserNotificationDeliveryLocalService.class.getName();
453            }
454    
455            protected Class<?> getModelClass() {
456                    return UserNotificationDelivery.class;
457            }
458    
459            protected String getModelClassName() {
460                    return UserNotificationDelivery.class.getName();
461            }
462    
463            /**
464             * Performs a SQL query.
465             *
466             * @param sql the sql query
467             */
468            protected void runSQL(String sql) {
469                    try {
470                            DataSource dataSource = userNotificationDeliveryPersistence.getDataSource();
471    
472                            DB db = DBManagerUtil.getDB();
473    
474                            sql = db.buildSQL(sql);
475                            sql = PortalUtil.transformSQL(sql);
476    
477                            SqlUpdate sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(dataSource,
478                                            sql, new int[0]);
479    
480                            sqlUpdate.update();
481                    }
482                    catch (Exception e) {
483                            throw new SystemException(e);
484                    }
485            }
486    
487            @BeanReference(type = com.liferay.portal.service.UserNotificationDeliveryLocalService.class)
488            protected UserNotificationDeliveryLocalService userNotificationDeliveryLocalService;
489            @BeanReference(type = UserNotificationDeliveryPersistence.class)
490            protected UserNotificationDeliveryPersistence userNotificationDeliveryPersistence;
491            @BeanReference(type = com.liferay.counter.service.CounterLocalService.class)
492            protected com.liferay.counter.service.CounterLocalService counterLocalService;
493            @BeanReference(type = com.liferay.portal.service.UserLocalService.class)
494            protected com.liferay.portal.service.UserLocalService userLocalService;
495            @BeanReference(type = UserPersistence.class)
496            protected UserPersistence userPersistence;
497            @BeanReference(type = UserFinder.class)
498            protected UserFinder userFinder;
499            @BeanReference(type = PersistedModelLocalServiceRegistry.class)
500            protected PersistedModelLocalServiceRegistry persistedModelLocalServiceRegistry;
501    }