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