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.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.service.BaseLocalServiceImpl;
038    import com.liferay.portal.service.PersistedModelLocalServiceRegistry;
039    import com.liferay.portal.util.PortalUtil;
040    
041    import com.liferay.portlet.announcements.model.AnnouncementsFlag;
042    import com.liferay.portlet.announcements.service.AnnouncementsFlagLocalService;
043    import com.liferay.portlet.announcements.service.persistence.AnnouncementsFlagPersistence;
044    
045    import java.io.Serializable;
046    
047    import java.util.List;
048    
049    import javax.sql.DataSource;
050    
051    /**
052     * Provides the base implementation for the announcements flag local service.
053     *
054     * <p>
055     * 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.AnnouncementsFlagLocalServiceImpl}.
056     * </p>
057     *
058     * @author Brian Wing Shun Chan
059     * @see com.liferay.portlet.announcements.service.impl.AnnouncementsFlagLocalServiceImpl
060     * @see com.liferay.portlet.announcements.service.AnnouncementsFlagLocalServiceUtil
061     * @generated
062     */
063    @ProviderType
064    public abstract class AnnouncementsFlagLocalServiceBaseImpl
065            extends BaseLocalServiceImpl implements AnnouncementsFlagLocalService,
066                    IdentifiableOSGiService {
067            /*
068             * NOTE FOR DEVELOPERS:
069             *
070             * Never modify or reference this class directly. Always use {@link com.liferay.portlet.announcements.service.AnnouncementsFlagLocalServiceUtil} to access the announcements flag local service.
071             */
072    
073            /**
074             * Adds the announcements flag to the database. Also notifies the appropriate model listeners.
075             *
076             * @param announcementsFlag the announcements flag
077             * @return the announcements flag that was added
078             */
079            @Indexable(type = IndexableType.REINDEX)
080            @Override
081            public AnnouncementsFlag addAnnouncementsFlag(
082                    AnnouncementsFlag announcementsFlag) {
083                    announcementsFlag.setNew(true);
084    
085                    return announcementsFlagPersistence.update(announcementsFlag);
086            }
087    
088            /**
089             * Creates a new announcements flag with the primary key. Does not add the announcements flag to the database.
090             *
091             * @param flagId the primary key for the new announcements flag
092             * @return the new announcements flag
093             */
094            @Override
095            public AnnouncementsFlag createAnnouncementsFlag(long flagId) {
096                    return announcementsFlagPersistence.create(flagId);
097            }
098    
099            /**
100             * Deletes the announcements flag with the primary key from the database. Also notifies the appropriate model listeners.
101             *
102             * @param flagId the primary key of the announcements flag
103             * @return the announcements flag that was removed
104             * @throws PortalException if a announcements flag with the primary key could not be found
105             */
106            @Indexable(type = IndexableType.DELETE)
107            @Override
108            public AnnouncementsFlag deleteAnnouncementsFlag(long flagId)
109                    throws PortalException {
110                    return announcementsFlagPersistence.remove(flagId);
111            }
112    
113            /**
114             * Deletes the announcements flag from the database. Also notifies the appropriate model listeners.
115             *
116             * @param announcementsFlag the announcements flag
117             * @return the announcements flag that was removed
118             */
119            @Indexable(type = IndexableType.DELETE)
120            @Override
121            public AnnouncementsFlag deleteAnnouncementsFlag(
122                    AnnouncementsFlag announcementsFlag) {
123                    return announcementsFlagPersistence.remove(announcementsFlag);
124            }
125    
126            @Override
127            public DynamicQuery dynamicQuery() {
128                    Class<?> clazz = getClass();
129    
130                    return DynamicQueryFactoryUtil.forClass(AnnouncementsFlag.class,
131                            clazz.getClassLoader());
132            }
133    
134            /**
135             * Performs a dynamic query on the database and returns the matching rows.
136             *
137             * @param dynamicQuery the dynamic query
138             * @return the matching rows
139             */
140            @Override
141            public <T> List<T> dynamicQuery(DynamicQuery dynamicQuery) {
142                    return announcementsFlagPersistence.findWithDynamicQuery(dynamicQuery);
143            }
144    
145            /**
146             * Performs a dynamic query on the database and returns a range of the matching rows.
147             *
148             * <p>
149             * 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.AnnouncementsFlagModelImpl}. 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.
150             * </p>
151             *
152             * @param dynamicQuery the dynamic query
153             * @param start the lower bound of the range of model instances
154             * @param end the upper bound of the range of model instances (not inclusive)
155             * @return the range of matching rows
156             */
157            @Override
158            public <T> List<T> dynamicQuery(DynamicQuery dynamicQuery, int start,
159                    int end) {
160                    return announcementsFlagPersistence.findWithDynamicQuery(dynamicQuery,
161                            start, end);
162            }
163    
164            /**
165             * Performs a dynamic query on the database and returns an ordered range of the matching rows.
166             *
167             * <p>
168             * 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.AnnouncementsFlagModelImpl}. 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.
169             * </p>
170             *
171             * @param dynamicQuery the dynamic query
172             * @param start the lower bound of the range of model instances
173             * @param end the upper bound of the range of model instances (not inclusive)
174             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
175             * @return the ordered range of matching rows
176             */
177            @Override
178            public <T> List<T> dynamicQuery(DynamicQuery dynamicQuery, int start,
179                    int end, OrderByComparator<T> orderByComparator) {
180                    return announcementsFlagPersistence.findWithDynamicQuery(dynamicQuery,
181                            start, end, orderByComparator);
182            }
183    
184            /**
185             * Returns the number of rows matching the dynamic query.
186             *
187             * @param dynamicQuery the dynamic query
188             * @return the number of rows matching the dynamic query
189             */
190            @Override
191            public long dynamicQueryCount(DynamicQuery dynamicQuery) {
192                    return announcementsFlagPersistence.countWithDynamicQuery(dynamicQuery);
193            }
194    
195            /**
196             * Returns the number of rows matching the dynamic query.
197             *
198             * @param dynamicQuery the dynamic query
199             * @param projection the projection to apply to the query
200             * @return the number of rows matching the dynamic query
201             */
202            @Override
203            public long dynamicQueryCount(DynamicQuery dynamicQuery,
204                    Projection projection) {
205                    return announcementsFlagPersistence.countWithDynamicQuery(dynamicQuery,
206                            projection);
207            }
208    
209            @Override
210            public AnnouncementsFlag fetchAnnouncementsFlag(long flagId) {
211                    return announcementsFlagPersistence.fetchByPrimaryKey(flagId);
212            }
213    
214            /**
215             * Returns the announcements flag with the primary key.
216             *
217             * @param flagId the primary key of the announcements flag
218             * @return the announcements flag
219             * @throws PortalException if a announcements flag with the primary key could not be found
220             */
221            @Override
222            public AnnouncementsFlag getAnnouncementsFlag(long flagId)
223                    throws PortalException {
224                    return announcementsFlagPersistence.findByPrimaryKey(flagId);
225            }
226    
227            @Override
228            public ActionableDynamicQuery getActionableDynamicQuery() {
229                    ActionableDynamicQuery actionableDynamicQuery = new DefaultActionableDynamicQuery();
230    
231                    actionableDynamicQuery.setBaseLocalService(com.liferay.portlet.announcements.service.AnnouncementsFlagLocalServiceUtil.getService());
232                    actionableDynamicQuery.setClassLoader(getClassLoader());
233                    actionableDynamicQuery.setModelClass(AnnouncementsFlag.class);
234    
235                    actionableDynamicQuery.setPrimaryKeyPropertyName("flagId");
236    
237                    return actionableDynamicQuery;
238            }
239    
240            @Override
241            public IndexableActionableDynamicQuery getIndexableActionableDynamicQuery() {
242                    IndexableActionableDynamicQuery indexableActionableDynamicQuery = new IndexableActionableDynamicQuery();
243    
244                    indexableActionableDynamicQuery.setBaseLocalService(com.liferay.portlet.announcements.service.AnnouncementsFlagLocalServiceUtil.getService());
245                    indexableActionableDynamicQuery.setClassLoader(getClassLoader());
246                    indexableActionableDynamicQuery.setModelClass(AnnouncementsFlag.class);
247    
248                    indexableActionableDynamicQuery.setPrimaryKeyPropertyName("flagId");
249    
250                    return indexableActionableDynamicQuery;
251            }
252    
253            protected void initActionableDynamicQuery(
254                    ActionableDynamicQuery actionableDynamicQuery) {
255                    actionableDynamicQuery.setBaseLocalService(com.liferay.portlet.announcements.service.AnnouncementsFlagLocalServiceUtil.getService());
256                    actionableDynamicQuery.setClassLoader(getClassLoader());
257                    actionableDynamicQuery.setModelClass(AnnouncementsFlag.class);
258    
259                    actionableDynamicQuery.setPrimaryKeyPropertyName("flagId");
260            }
261    
262            /**
263             * @throws PortalException
264             */
265            @Override
266            public PersistedModel deletePersistedModel(PersistedModel persistedModel)
267                    throws PortalException {
268                    return announcementsFlagLocalService.deleteAnnouncementsFlag((AnnouncementsFlag)persistedModel);
269            }
270    
271            @Override
272            public PersistedModel getPersistedModel(Serializable primaryKeyObj)
273                    throws PortalException {
274                    return announcementsFlagPersistence.findByPrimaryKey(primaryKeyObj);
275            }
276    
277            /**
278             * Returns a range of all the announcements flags.
279             *
280             * <p>
281             * 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.AnnouncementsFlagModelImpl}. 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.
282             * </p>
283             *
284             * @param start the lower bound of the range of announcements flags
285             * @param end the upper bound of the range of announcements flags (not inclusive)
286             * @return the range of announcements flags
287             */
288            @Override
289            public List<AnnouncementsFlag> getAnnouncementsFlags(int start, int end) {
290                    return announcementsFlagPersistence.findAll(start, end);
291            }
292    
293            /**
294             * Returns the number of announcements flags.
295             *
296             * @return the number of announcements flags
297             */
298            @Override
299            public int getAnnouncementsFlagsCount() {
300                    return announcementsFlagPersistence.countAll();
301            }
302    
303            /**
304             * Updates the announcements flag in the database or adds it if it does not yet exist. Also notifies the appropriate model listeners.
305             *
306             * @param announcementsFlag the announcements flag
307             * @return the announcements flag that was updated
308             */
309            @Indexable(type = IndexableType.REINDEX)
310            @Override
311            public AnnouncementsFlag updateAnnouncementsFlag(
312                    AnnouncementsFlag announcementsFlag) {
313                    return announcementsFlagPersistence.update(announcementsFlag);
314            }
315    
316            /**
317             * Returns the announcements flag local service.
318             *
319             * @return the announcements flag local service
320             */
321            public AnnouncementsFlagLocalService getAnnouncementsFlagLocalService() {
322                    return announcementsFlagLocalService;
323            }
324    
325            /**
326             * Sets the announcements flag local service.
327             *
328             * @param announcementsFlagLocalService the announcements flag local service
329             */
330            public void setAnnouncementsFlagLocalService(
331                    AnnouncementsFlagLocalService announcementsFlagLocalService) {
332                    this.announcementsFlagLocalService = announcementsFlagLocalService;
333            }
334    
335            /**
336             * Returns the announcements flag persistence.
337             *
338             * @return the announcements flag persistence
339             */
340            public AnnouncementsFlagPersistence getAnnouncementsFlagPersistence() {
341                    return announcementsFlagPersistence;
342            }
343    
344            /**
345             * Sets the announcements flag persistence.
346             *
347             * @param announcementsFlagPersistence the announcements flag persistence
348             */
349            public void setAnnouncementsFlagPersistence(
350                    AnnouncementsFlagPersistence announcementsFlagPersistence) {
351                    this.announcementsFlagPersistence = announcementsFlagPersistence;
352            }
353    
354            /**
355             * Returns the counter local service.
356             *
357             * @return the counter local service
358             */
359            public com.liferay.counter.service.CounterLocalService getCounterLocalService() {
360                    return counterLocalService;
361            }
362    
363            /**
364             * Sets the counter local service.
365             *
366             * @param counterLocalService the counter local service
367             */
368            public void setCounterLocalService(
369                    com.liferay.counter.service.CounterLocalService counterLocalService) {
370                    this.counterLocalService = counterLocalService;
371            }
372    
373            public void afterPropertiesSet() {
374                    persistedModelLocalServiceRegistry.register("com.liferay.portlet.announcements.model.AnnouncementsFlag",
375                            announcementsFlagLocalService);
376            }
377    
378            public void destroy() {
379                    persistedModelLocalServiceRegistry.unregister(
380                            "com.liferay.portlet.announcements.model.AnnouncementsFlag");
381            }
382    
383            /**
384             * Returns the OSGi service identifier.
385             *
386             * @return the OSGi service identifier
387             */
388            @Override
389            public String getOSGiServiceIdentifier() {
390                    return AnnouncementsFlagLocalService.class.getName();
391            }
392    
393            protected Class<?> getModelClass() {
394                    return AnnouncementsFlag.class;
395            }
396    
397            protected String getModelClassName() {
398                    return AnnouncementsFlag.class.getName();
399            }
400    
401            /**
402             * Performs a SQL query.
403             *
404             * @param sql the sql query
405             */
406            protected void runSQL(String sql) {
407                    try {
408                            DataSource dataSource = announcementsFlagPersistence.getDataSource();
409    
410                            DB db = DBManagerUtil.getDB();
411    
412                            sql = db.buildSQL(sql);
413                            sql = PortalUtil.transformSQL(sql);
414    
415                            SqlUpdate sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(dataSource,
416                                            sql, new int[0]);
417    
418                            sqlUpdate.update();
419                    }
420                    catch (Exception e) {
421                            throw new SystemException(e);
422                    }
423            }
424    
425            @BeanReference(type = com.liferay.portlet.announcements.service.AnnouncementsFlagLocalService.class)
426            protected AnnouncementsFlagLocalService announcementsFlagLocalService;
427            @BeanReference(type = AnnouncementsFlagPersistence.class)
428            protected AnnouncementsFlagPersistence announcementsFlagPersistence;
429            @BeanReference(type = com.liferay.counter.service.CounterLocalService.class)
430            protected com.liferay.counter.service.CounterLocalService counterLocalService;
431            @BeanReference(type = PersistedModelLocalServiceRegistry.class)
432            protected PersistedModelLocalServiceRegistry persistedModelLocalServiceRegistry;
433    }