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.journal.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.service.BaseLocalServiceImpl;
037    import com.liferay.portal.service.PersistedModelLocalServiceRegistry;
038    import com.liferay.portal.service.persistence.ImagePersistence;
039    import com.liferay.portal.util.PortalUtil;
040    
041    import com.liferay.portlet.journal.model.JournalArticleImage;
042    import com.liferay.portlet.journal.service.JournalArticleImageLocalService;
043    import com.liferay.portlet.journal.service.persistence.JournalArticleImagePersistence;
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 journal article image 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.journal.service.impl.JournalArticleImageLocalServiceImpl}.
056     * </p>
057     *
058     * @author Brian Wing Shun Chan
059     * @see com.liferay.portlet.journal.service.impl.JournalArticleImageLocalServiceImpl
060     * @see com.liferay.portlet.journal.service.JournalArticleImageLocalServiceUtil
061     * @generated
062     */
063    @ProviderType
064    public abstract class JournalArticleImageLocalServiceBaseImpl
065            extends BaseLocalServiceImpl implements JournalArticleImageLocalService,
066                    IdentifiableBean {
067            /*
068             * NOTE FOR DEVELOPERS:
069             *
070             * Never modify or reference this class directly. Always use {@link com.liferay.portlet.journal.service.JournalArticleImageLocalServiceUtil} to access the journal article image local service.
071             */
072    
073            /**
074             * Adds the journal article image to the database. Also notifies the appropriate model listeners.
075             *
076             * @param journalArticleImage the journal article image
077             * @return the journal article image that was added
078             */
079            @Indexable(type = IndexableType.REINDEX)
080            @Override
081            public JournalArticleImage addJournalArticleImage(
082                    JournalArticleImage journalArticleImage) {
083                    journalArticleImage.setNew(true);
084    
085                    return journalArticleImagePersistence.update(journalArticleImage);
086            }
087    
088            /**
089             * Creates a new journal article image with the primary key. Does not add the journal article image to the database.
090             *
091             * @param articleImageId the primary key for the new journal article image
092             * @return the new journal article image
093             */
094            @Override
095            public JournalArticleImage createJournalArticleImage(long articleImageId) {
096                    return journalArticleImagePersistence.create(articleImageId);
097            }
098    
099            /**
100             * Deletes the journal article image with the primary key from the database. Also notifies the appropriate model listeners.
101             *
102             * @param articleImageId the primary key of the journal article image
103             * @return the journal article image that was removed
104             * @throws PortalException if a journal article image with the primary key could not be found
105             */
106            @Indexable(type = IndexableType.DELETE)
107            @Override
108            public JournalArticleImage deleteJournalArticleImage(long articleImageId)
109                    throws PortalException {
110                    return journalArticleImagePersistence.remove(articleImageId);
111            }
112    
113            /**
114             * Deletes the journal article image from the database. Also notifies the appropriate model listeners.
115             *
116             * @param journalArticleImage the journal article image
117             * @return the journal article image that was removed
118             */
119            @Indexable(type = IndexableType.DELETE)
120            @Override
121            public JournalArticleImage deleteJournalArticleImage(
122                    JournalArticleImage journalArticleImage) {
123                    return journalArticleImagePersistence.remove(journalArticleImage);
124            }
125    
126            @Override
127            public DynamicQuery dynamicQuery() {
128                    Class<?> clazz = getClass();
129    
130                    return DynamicQueryFactoryUtil.forClass(JournalArticleImage.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 journalArticleImagePersistence.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.journal.model.impl.JournalArticleImageModelImpl}. 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 journalArticleImagePersistence.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.journal.model.impl.JournalArticleImageModelImpl}. 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 journalArticleImagePersistence.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 journalArticleImagePersistence.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 journalArticleImagePersistence.countWithDynamicQuery(dynamicQuery,
206                            projection);
207            }
208    
209            @Override
210            public JournalArticleImage fetchJournalArticleImage(long articleImageId) {
211                    return journalArticleImagePersistence.fetchByPrimaryKey(articleImageId);
212            }
213    
214            /**
215             * Returns the journal article image with the primary key.
216             *
217             * @param articleImageId the primary key of the journal article image
218             * @return the journal article image
219             * @throws PortalException if a journal article image with the primary key could not be found
220             */
221            @Override
222            public JournalArticleImage getJournalArticleImage(long articleImageId)
223                    throws PortalException {
224                    return journalArticleImagePersistence.findByPrimaryKey(articleImageId);
225            }
226    
227            @Override
228            public ActionableDynamicQuery getActionableDynamicQuery() {
229                    ActionableDynamicQuery actionableDynamicQuery = new DefaultActionableDynamicQuery();
230    
231                    actionableDynamicQuery.setBaseLocalService(com.liferay.portlet.journal.service.JournalArticleImageLocalServiceUtil.getService());
232                    actionableDynamicQuery.setClass(JournalArticleImage.class);
233                    actionableDynamicQuery.setClassLoader(getClassLoader());
234    
235                    actionableDynamicQuery.setPrimaryKeyPropertyName("articleImageId");
236    
237                    return actionableDynamicQuery;
238            }
239    
240            protected void initActionableDynamicQuery(
241                    ActionableDynamicQuery actionableDynamicQuery) {
242                    actionableDynamicQuery.setBaseLocalService(com.liferay.portlet.journal.service.JournalArticleImageLocalServiceUtil.getService());
243                    actionableDynamicQuery.setClass(JournalArticleImage.class);
244                    actionableDynamicQuery.setClassLoader(getClassLoader());
245    
246                    actionableDynamicQuery.setPrimaryKeyPropertyName("articleImageId");
247            }
248    
249            /**
250             * @throws PortalException
251             */
252            @Override
253            public PersistedModel deletePersistedModel(PersistedModel persistedModel)
254                    throws PortalException {
255                    return journalArticleImageLocalService.deleteJournalArticleImage((JournalArticleImage)persistedModel);
256            }
257    
258            @Override
259            public PersistedModel getPersistedModel(Serializable primaryKeyObj)
260                    throws PortalException {
261                    return journalArticleImagePersistence.findByPrimaryKey(primaryKeyObj);
262            }
263    
264            /**
265             * Returns a range of all the journal article images.
266             *
267             * <p>
268             * 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.journal.model.impl.JournalArticleImageModelImpl}. 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.
269             * </p>
270             *
271             * @param start the lower bound of the range of journal article images
272             * @param end the upper bound of the range of journal article images (not inclusive)
273             * @return the range of journal article images
274             */
275            @Override
276            public List<JournalArticleImage> getJournalArticleImages(int start, int end) {
277                    return journalArticleImagePersistence.findAll(start, end);
278            }
279    
280            /**
281             * Returns the number of journal article images.
282             *
283             * @return the number of journal article images
284             */
285            @Override
286            public int getJournalArticleImagesCount() {
287                    return journalArticleImagePersistence.countAll();
288            }
289    
290            /**
291             * Updates the journal article image in the database or adds it if it does not yet exist. Also notifies the appropriate model listeners.
292             *
293             * @param journalArticleImage the journal article image
294             * @return the journal article image that was updated
295             */
296            @Indexable(type = IndexableType.REINDEX)
297            @Override
298            public JournalArticleImage updateJournalArticleImage(
299                    JournalArticleImage journalArticleImage) {
300                    return journalArticleImagePersistence.update(journalArticleImage);
301            }
302    
303            /**
304             * Returns the journal article image local service.
305             *
306             * @return the journal article image local service
307             */
308            public com.liferay.portlet.journal.service.JournalArticleImageLocalService getJournalArticleImageLocalService() {
309                    return journalArticleImageLocalService;
310            }
311    
312            /**
313             * Sets the journal article image local service.
314             *
315             * @param journalArticleImageLocalService the journal article image local service
316             */
317            public void setJournalArticleImageLocalService(
318                    com.liferay.portlet.journal.service.JournalArticleImageLocalService journalArticleImageLocalService) {
319                    this.journalArticleImageLocalService = journalArticleImageLocalService;
320            }
321    
322            /**
323             * Returns the journal article image persistence.
324             *
325             * @return the journal article image persistence
326             */
327            public JournalArticleImagePersistence getJournalArticleImagePersistence() {
328                    return journalArticleImagePersistence;
329            }
330    
331            /**
332             * Sets the journal article image persistence.
333             *
334             * @param journalArticleImagePersistence the journal article image persistence
335             */
336            public void setJournalArticleImagePersistence(
337                    JournalArticleImagePersistence journalArticleImagePersistence) {
338                    this.journalArticleImagePersistence = journalArticleImagePersistence;
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 image local service.
362             *
363             * @return the image local service
364             */
365            public com.liferay.portal.service.ImageLocalService getImageLocalService() {
366                    return imageLocalService;
367            }
368    
369            /**
370             * Sets the image local service.
371             *
372             * @param imageLocalService the image local service
373             */
374            public void setImageLocalService(
375                    com.liferay.portal.service.ImageLocalService imageLocalService) {
376                    this.imageLocalService = imageLocalService;
377            }
378    
379            /**
380             * Returns the image remote service.
381             *
382             * @return the image remote service
383             */
384            public com.liferay.portal.service.ImageService getImageService() {
385                    return imageService;
386            }
387    
388            /**
389             * Sets the image remote service.
390             *
391             * @param imageService the image remote service
392             */
393            public void setImageService(
394                    com.liferay.portal.service.ImageService imageService) {
395                    this.imageService = imageService;
396            }
397    
398            /**
399             * Returns the image persistence.
400             *
401             * @return the image persistence
402             */
403            public ImagePersistence getImagePersistence() {
404                    return imagePersistence;
405            }
406    
407            /**
408             * Sets the image persistence.
409             *
410             * @param imagePersistence the image persistence
411             */
412            public void setImagePersistence(ImagePersistence imagePersistence) {
413                    this.imagePersistence = imagePersistence;
414            }
415    
416            public void afterPropertiesSet() {
417                    persistedModelLocalServiceRegistry.register("com.liferay.portlet.journal.model.JournalArticleImage",
418                            journalArticleImageLocalService);
419            }
420    
421            public void destroy() {
422                    persistedModelLocalServiceRegistry.unregister(
423                            "com.liferay.portlet.journal.model.JournalArticleImage");
424            }
425    
426            /**
427             * Returns the Spring bean ID for this bean.
428             *
429             * @return the Spring bean ID for this bean
430             */
431            @Override
432            public String getBeanIdentifier() {
433                    return _beanIdentifier;
434            }
435    
436            /**
437             * Sets the Spring bean ID for this bean.
438             *
439             * @param beanIdentifier the Spring bean ID for this bean
440             */
441            @Override
442            public void setBeanIdentifier(String beanIdentifier) {
443                    _beanIdentifier = beanIdentifier;
444            }
445    
446            protected Class<?> getModelClass() {
447                    return JournalArticleImage.class;
448            }
449    
450            protected String getModelClassName() {
451                    return JournalArticleImage.class.getName();
452            }
453    
454            /**
455             * Performs a SQL query.
456             *
457             * @param sql the sql query
458             */
459            protected void runSQL(String sql) {
460                    try {
461                            DataSource dataSource = journalArticleImagePersistence.getDataSource();
462    
463                            DB db = DBFactoryUtil.getDB();
464    
465                            sql = db.buildSQL(sql);
466                            sql = PortalUtil.transformSQL(sql);
467    
468                            SqlUpdate sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(dataSource,
469                                            sql, new int[0]);
470    
471                            sqlUpdate.update();
472                    }
473                    catch (Exception e) {
474                            throw new SystemException(e);
475                    }
476            }
477    
478            @BeanReference(type = com.liferay.portlet.journal.service.JournalArticleImageLocalService.class)
479            protected com.liferay.portlet.journal.service.JournalArticleImageLocalService journalArticleImageLocalService;
480            @BeanReference(type = JournalArticleImagePersistence.class)
481            protected JournalArticleImagePersistence journalArticleImagePersistence;
482            @BeanReference(type = com.liferay.counter.service.CounterLocalService.class)
483            protected com.liferay.counter.service.CounterLocalService counterLocalService;
484            @BeanReference(type = com.liferay.portal.service.ImageLocalService.class)
485            protected com.liferay.portal.service.ImageLocalService imageLocalService;
486            @BeanReference(type = com.liferay.portal.service.ImageService.class)
487            protected com.liferay.portal.service.ImageService imageService;
488            @BeanReference(type = ImagePersistence.class)
489            protected ImagePersistence imagePersistence;
490            @BeanReference(type = PersistedModelLocalServiceRegistry.class)
491            protected PersistedModelLocalServiceRegistry persistedModelLocalServiceRegistry;
492            private String _beanIdentifier;
493    }