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