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