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