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