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.SystemEvent;
038    import com.liferay.portal.service.BaseLocalServiceImpl;
039    import com.liferay.portal.service.PersistedModelLocalServiceRegistry;
040    import com.liferay.portal.service.SystemEventLocalService;
041    import com.liferay.portal.service.persistence.CompanyPersistence;
042    import com.liferay.portal.service.persistence.GroupFinder;
043    import com.liferay.portal.service.persistence.GroupPersistence;
044    import com.liferay.portal.service.persistence.SystemEventPersistence;
045    import com.liferay.portal.service.persistence.UserFinder;
046    import com.liferay.portal.service.persistence.UserPersistence;
047    import com.liferay.portal.util.PortalUtil;
048    
049    import java.io.Serializable;
050    
051    import java.util.List;
052    
053    import javax.sql.DataSource;
054    
055    /**
056     * Provides the base implementation for the system event local service.
057     *
058     * <p>
059     * 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.SystemEventLocalServiceImpl}.
060     * </p>
061     *
062     * @author Brian Wing Shun Chan
063     * @see com.liferay.portal.service.impl.SystemEventLocalServiceImpl
064     * @see com.liferay.portal.service.SystemEventLocalServiceUtil
065     * @generated
066     */
067    @ProviderType
068    public abstract class SystemEventLocalServiceBaseImpl
069            extends BaseLocalServiceImpl implements SystemEventLocalService,
070                    IdentifiableOSGiService {
071            /*
072             * NOTE FOR DEVELOPERS:
073             *
074             * Never modify or reference this class directly. Always use {@link com.liferay.portal.service.SystemEventLocalServiceUtil} to access the system event local service.
075             */
076    
077            /**
078             * Adds the system event to the database. Also notifies the appropriate model listeners.
079             *
080             * @param systemEvent the system event
081             * @return the system event that was added
082             */
083            @Indexable(type = IndexableType.REINDEX)
084            @Override
085            public SystemEvent addSystemEvent(SystemEvent systemEvent) {
086                    systemEvent.setNew(true);
087    
088                    return systemEventPersistence.update(systemEvent);
089            }
090    
091            /**
092             * Creates a new system event with the primary key. Does not add the system event to the database.
093             *
094             * @param systemEventId the primary key for the new system event
095             * @return the new system event
096             */
097            @Override
098            public SystemEvent createSystemEvent(long systemEventId) {
099                    return systemEventPersistence.create(systemEventId);
100            }
101    
102            /**
103             * Deletes the system event with the primary key from the database. Also notifies the appropriate model listeners.
104             *
105             * @param systemEventId the primary key of the system event
106             * @return the system event that was removed
107             * @throws PortalException if a system event with the primary key could not be found
108             */
109            @Indexable(type = IndexableType.DELETE)
110            @Override
111            public SystemEvent deleteSystemEvent(long systemEventId)
112                    throws PortalException {
113                    return systemEventPersistence.remove(systemEventId);
114            }
115    
116            /**
117             * Deletes the system event from the database. Also notifies the appropriate model listeners.
118             *
119             * @param systemEvent the system event
120             * @return the system event that was removed
121             */
122            @Indexable(type = IndexableType.DELETE)
123            @Override
124            public SystemEvent deleteSystemEvent(SystemEvent systemEvent) {
125                    return systemEventPersistence.remove(systemEvent);
126            }
127    
128            @Override
129            public DynamicQuery dynamicQuery() {
130                    Class<?> clazz = getClass();
131    
132                    return DynamicQueryFactoryUtil.forClass(SystemEvent.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 systemEventPersistence.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.SystemEventModelImpl}. 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 systemEventPersistence.findWithDynamicQuery(dynamicQuery, start,
163                            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.SystemEventModelImpl}. 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 systemEventPersistence.findWithDynamicQuery(dynamicQuery, start,
183                            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 systemEventPersistence.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 systemEventPersistence.countWithDynamicQuery(dynamicQuery,
208                            projection);
209            }
210    
211            @Override
212            public SystemEvent fetchSystemEvent(long systemEventId) {
213                    return systemEventPersistence.fetchByPrimaryKey(systemEventId);
214            }
215    
216            /**
217             * Returns the system event with the primary key.
218             *
219             * @param systemEventId the primary key of the system event
220             * @return the system event
221             * @throws PortalException if a system event with the primary key could not be found
222             */
223            @Override
224            public SystemEvent getSystemEvent(long systemEventId)
225                    throws PortalException {
226                    return systemEventPersistence.findByPrimaryKey(systemEventId);
227            }
228    
229            @Override
230            public ActionableDynamicQuery getActionableDynamicQuery() {
231                    ActionableDynamicQuery actionableDynamicQuery = new DefaultActionableDynamicQuery();
232    
233                    actionableDynamicQuery.setBaseLocalService(com.liferay.portal.service.SystemEventLocalServiceUtil.getService());
234                    actionableDynamicQuery.setClassLoader(getClassLoader());
235                    actionableDynamicQuery.setModelClass(SystemEvent.class);
236    
237                    actionableDynamicQuery.setPrimaryKeyPropertyName("systemEventId");
238    
239                    return actionableDynamicQuery;
240            }
241    
242            @Override
243            public IndexableActionableDynamicQuery getIndexableActionableDynamicQuery() {
244                    IndexableActionableDynamicQuery indexableActionableDynamicQuery = new IndexableActionableDynamicQuery();
245    
246                    indexableActionableDynamicQuery.setBaseLocalService(com.liferay.portal.service.SystemEventLocalServiceUtil.getService());
247                    indexableActionableDynamicQuery.setClassLoader(getClassLoader());
248                    indexableActionableDynamicQuery.setModelClass(SystemEvent.class);
249    
250                    indexableActionableDynamicQuery.setPrimaryKeyPropertyName(
251                            "systemEventId");
252    
253                    return indexableActionableDynamicQuery;
254            }
255    
256            protected void initActionableDynamicQuery(
257                    ActionableDynamicQuery actionableDynamicQuery) {
258                    actionableDynamicQuery.setBaseLocalService(com.liferay.portal.service.SystemEventLocalServiceUtil.getService());
259                    actionableDynamicQuery.setClassLoader(getClassLoader());
260                    actionableDynamicQuery.setModelClass(SystemEvent.class);
261    
262                    actionableDynamicQuery.setPrimaryKeyPropertyName("systemEventId");
263            }
264    
265            /**
266             * @throws PortalException
267             */
268            @Override
269            public PersistedModel deletePersistedModel(PersistedModel persistedModel)
270                    throws PortalException {
271                    return systemEventLocalService.deleteSystemEvent((SystemEvent)persistedModel);
272            }
273    
274            @Override
275            public PersistedModel getPersistedModel(Serializable primaryKeyObj)
276                    throws PortalException {
277                    return systemEventPersistence.findByPrimaryKey(primaryKeyObj);
278            }
279    
280            /**
281             * Returns a range of all the system events.
282             *
283             * <p>
284             * 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.SystemEventModelImpl}. 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.
285             * </p>
286             *
287             * @param start the lower bound of the range of system events
288             * @param end the upper bound of the range of system events (not inclusive)
289             * @return the range of system events
290             */
291            @Override
292            public List<SystemEvent> getSystemEvents(int start, int end) {
293                    return systemEventPersistence.findAll(start, end);
294            }
295    
296            /**
297             * Returns the number of system events.
298             *
299             * @return the number of system events
300             */
301            @Override
302            public int getSystemEventsCount() {
303                    return systemEventPersistence.countAll();
304            }
305    
306            /**
307             * Updates the system event in the database or adds it if it does not yet exist. Also notifies the appropriate model listeners.
308             *
309             * @param systemEvent the system event
310             * @return the system event that was updated
311             */
312            @Indexable(type = IndexableType.REINDEX)
313            @Override
314            public SystemEvent updateSystemEvent(SystemEvent systemEvent) {
315                    return systemEventPersistence.update(systemEvent);
316            }
317    
318            /**
319             * Returns the system event local service.
320             *
321             * @return the system event local service
322             */
323            public SystemEventLocalService getSystemEventLocalService() {
324                    return systemEventLocalService;
325            }
326    
327            /**
328             * Sets the system event local service.
329             *
330             * @param systemEventLocalService the system event local service
331             */
332            public void setSystemEventLocalService(
333                    SystemEventLocalService systemEventLocalService) {
334                    this.systemEventLocalService = systemEventLocalService;
335            }
336    
337            /**
338             * Returns the system event persistence.
339             *
340             * @return the system event persistence
341             */
342            public SystemEventPersistence getSystemEventPersistence() {
343                    return systemEventPersistence;
344            }
345    
346            /**
347             * Sets the system event persistence.
348             *
349             * @param systemEventPersistence the system event persistence
350             */
351            public void setSystemEventPersistence(
352                    SystemEventPersistence systemEventPersistence) {
353                    this.systemEventPersistence = systemEventPersistence;
354            }
355    
356            /**
357             * Returns the counter local service.
358             *
359             * @return the counter local service
360             */
361            public com.liferay.counter.service.CounterLocalService getCounterLocalService() {
362                    return counterLocalService;
363            }
364    
365            /**
366             * Sets the counter local service.
367             *
368             * @param counterLocalService the counter local service
369             */
370            public void setCounterLocalService(
371                    com.liferay.counter.service.CounterLocalService counterLocalService) {
372                    this.counterLocalService = counterLocalService;
373            }
374    
375            /**
376             * Returns the company local service.
377             *
378             * @return the company local service
379             */
380            public com.liferay.portal.service.CompanyLocalService getCompanyLocalService() {
381                    return companyLocalService;
382            }
383    
384            /**
385             * Sets the company local service.
386             *
387             * @param companyLocalService the company local service
388             */
389            public void setCompanyLocalService(
390                    com.liferay.portal.service.CompanyLocalService companyLocalService) {
391                    this.companyLocalService = companyLocalService;
392            }
393    
394            /**
395             * Returns the company persistence.
396             *
397             * @return the company persistence
398             */
399            public CompanyPersistence getCompanyPersistence() {
400                    return companyPersistence;
401            }
402    
403            /**
404             * Sets the company persistence.
405             *
406             * @param companyPersistence the company persistence
407             */
408            public void setCompanyPersistence(CompanyPersistence companyPersistence) {
409                    this.companyPersistence = companyPersistence;
410            }
411    
412            /**
413             * Returns the group local service.
414             *
415             * @return the group local service
416             */
417            public com.liferay.portal.service.GroupLocalService getGroupLocalService() {
418                    return groupLocalService;
419            }
420    
421            /**
422             * Sets the group local service.
423             *
424             * @param groupLocalService the group local service
425             */
426            public void setGroupLocalService(
427                    com.liferay.portal.service.GroupLocalService groupLocalService) {
428                    this.groupLocalService = groupLocalService;
429            }
430    
431            /**
432             * Returns the group persistence.
433             *
434             * @return the group persistence
435             */
436            public GroupPersistence getGroupPersistence() {
437                    return groupPersistence;
438            }
439    
440            /**
441             * Sets the group persistence.
442             *
443             * @param groupPersistence the group persistence
444             */
445            public void setGroupPersistence(GroupPersistence groupPersistence) {
446                    this.groupPersistence = groupPersistence;
447            }
448    
449            /**
450             * Returns the group finder.
451             *
452             * @return the group finder
453             */
454            public GroupFinder getGroupFinder() {
455                    return groupFinder;
456            }
457    
458            /**
459             * Sets the group finder.
460             *
461             * @param groupFinder the group finder
462             */
463            public void setGroupFinder(GroupFinder groupFinder) {
464                    this.groupFinder = groupFinder;
465            }
466    
467            /**
468             * Returns the user local service.
469             *
470             * @return the user local service
471             */
472            public com.liferay.portal.service.UserLocalService getUserLocalService() {
473                    return userLocalService;
474            }
475    
476            /**
477             * Sets the user local service.
478             *
479             * @param userLocalService the user local service
480             */
481            public void setUserLocalService(
482                    com.liferay.portal.service.UserLocalService userLocalService) {
483                    this.userLocalService = userLocalService;
484            }
485    
486            /**
487             * Returns the user persistence.
488             *
489             * @return the user persistence
490             */
491            public UserPersistence getUserPersistence() {
492                    return userPersistence;
493            }
494    
495            /**
496             * Sets the user persistence.
497             *
498             * @param userPersistence the user persistence
499             */
500            public void setUserPersistence(UserPersistence userPersistence) {
501                    this.userPersistence = userPersistence;
502            }
503    
504            /**
505             * Returns the user finder.
506             *
507             * @return the user finder
508             */
509            public UserFinder getUserFinder() {
510                    return userFinder;
511            }
512    
513            /**
514             * Sets the user finder.
515             *
516             * @param userFinder the user finder
517             */
518            public void setUserFinder(UserFinder userFinder) {
519                    this.userFinder = userFinder;
520            }
521    
522            public void afterPropertiesSet() {
523                    persistedModelLocalServiceRegistry.register("com.liferay.portal.model.SystemEvent",
524                            systemEventLocalService);
525            }
526    
527            public void destroy() {
528                    persistedModelLocalServiceRegistry.unregister(
529                            "com.liferay.portal.model.SystemEvent");
530            }
531    
532            /**
533             * Returns the OSGi service identifier.
534             *
535             * @return the OSGi service identifier
536             */
537            @Override
538            public String getOSGiServiceIdentifier() {
539                    return SystemEventLocalService.class.getName();
540            }
541    
542            protected Class<?> getModelClass() {
543                    return SystemEvent.class;
544            }
545    
546            protected String getModelClassName() {
547                    return SystemEvent.class.getName();
548            }
549    
550            /**
551             * Performs a SQL query.
552             *
553             * @param sql the sql query
554             */
555            protected void runSQL(String sql) {
556                    try {
557                            DataSource dataSource = systemEventPersistence.getDataSource();
558    
559                            DB db = DBManagerUtil.getDB();
560    
561                            sql = db.buildSQL(sql);
562                            sql = PortalUtil.transformSQL(sql);
563    
564                            SqlUpdate sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(dataSource,
565                                            sql, new int[0]);
566    
567                            sqlUpdate.update();
568                    }
569                    catch (Exception e) {
570                            throw new SystemException(e);
571                    }
572            }
573    
574            @BeanReference(type = com.liferay.portal.service.SystemEventLocalService.class)
575            protected SystemEventLocalService systemEventLocalService;
576            @BeanReference(type = SystemEventPersistence.class)
577            protected SystemEventPersistence systemEventPersistence;
578            @BeanReference(type = com.liferay.counter.service.CounterLocalService.class)
579            protected com.liferay.counter.service.CounterLocalService counterLocalService;
580            @BeanReference(type = com.liferay.portal.service.CompanyLocalService.class)
581            protected com.liferay.portal.service.CompanyLocalService companyLocalService;
582            @BeanReference(type = CompanyPersistence.class)
583            protected CompanyPersistence companyPersistence;
584            @BeanReference(type = com.liferay.portal.service.GroupLocalService.class)
585            protected com.liferay.portal.service.GroupLocalService groupLocalService;
586            @BeanReference(type = GroupPersistence.class)
587            protected GroupPersistence groupPersistence;
588            @BeanReference(type = GroupFinder.class)
589            protected GroupFinder groupFinder;
590            @BeanReference(type = com.liferay.portal.service.UserLocalService.class)
591            protected com.liferay.portal.service.UserLocalService userLocalService;
592            @BeanReference(type = UserPersistence.class)
593            protected UserPersistence userPersistence;
594            @BeanReference(type = UserFinder.class)
595            protected UserFinder userFinder;
596            @BeanReference(type = PersistedModelLocalServiceRegistry.class)
597            protected PersistedModelLocalServiceRegistry persistedModelLocalServiceRegistry;
598    }