001    /**
002     * Copyright (c) 2000-present Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portal.service.base;
016    
017    import aQute.bnd.annotation.ProviderType;
018    
019    import com.liferay.portal.kernel.bean.BeanReference;
020    import com.liferay.portal.kernel.bean.IdentifiableBean;
021    import com.liferay.portal.kernel.dao.db.DB;
022    import com.liferay.portal.kernel.dao.db.DBFactoryUtil;
023    import com.liferay.portal.kernel.dao.jdbc.SqlUpdate;
024    import com.liferay.portal.kernel.dao.jdbc.SqlUpdateFactoryUtil;
025    import com.liferay.portal.kernel.dao.orm.ActionableDynamicQuery;
026    import com.liferay.portal.kernel.dao.orm.DefaultActionableDynamicQuery;
027    import com.liferay.portal.kernel.dao.orm.DynamicQuery;
028    import com.liferay.portal.kernel.dao.orm.DynamicQueryFactoryUtil;
029    import com.liferay.portal.kernel.dao.orm.Projection;
030    import com.liferay.portal.kernel.exception.PortalException;
031    import com.liferay.portal.kernel.exception.SystemException;
032    import com.liferay.portal.kernel.search.Indexable;
033    import com.liferay.portal.kernel.search.IndexableType;
034    import com.liferay.portal.kernel.util.OrderByComparator;
035    import com.liferay.portal.model.Image;
036    import com.liferay.portal.model.PersistedModel;
037    import com.liferay.portal.service.BaseLocalServiceImpl;
038    import com.liferay.portal.service.ImageLocalService;
039    import com.liferay.portal.service.PersistedModelLocalServiceRegistry;
040    import com.liferay.portal.service.persistence.ImagePersistence;
041    import com.liferay.portal.util.PortalUtil;
042    
043    import com.liferay.portlet.documentlibrary.service.persistence.DLFileEntryFinder;
044    import com.liferay.portlet.documentlibrary.service.persistence.DLFileEntryPersistence;
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 image 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.portal.service.impl.ImageLocalServiceImpl}.
057     * </p>
058     *
059     * @author Brian Wing Shun Chan
060     * @see com.liferay.portal.service.impl.ImageLocalServiceImpl
061     * @see com.liferay.portal.service.ImageLocalServiceUtil
062     * @generated
063     */
064    @ProviderType
065    public abstract class ImageLocalServiceBaseImpl extends BaseLocalServiceImpl
066            implements ImageLocalService, IdentifiableBean {
067            /*
068             * NOTE FOR DEVELOPERS:
069             *
070             * Never modify or reference this class directly. Always use {@link com.liferay.portal.service.ImageLocalServiceUtil} to access the image local service.
071             */
072    
073            /**
074             * Adds the image to the database. Also notifies the appropriate model listeners.
075             *
076             * @param image the image
077             * @return the image that was added
078             */
079            @Indexable(type = IndexableType.REINDEX)
080            @Override
081            public Image addImage(Image image) {
082                    image.setNew(true);
083    
084                    return imagePersistence.update(image);
085            }
086    
087            /**
088             * Creates a new image with the primary key. Does not add the image to the database.
089             *
090             * @param imageId the primary key for the new image
091             * @return the new image
092             */
093            @Override
094            public Image createImage(long imageId) {
095                    return imagePersistence.create(imageId);
096            }
097    
098            /**
099             * Deletes the image with the primary key from the database. Also notifies the appropriate model listeners.
100             *
101             * @param imageId the primary key of the image
102             * @return the image that was removed
103             * @throws PortalException if a image with the primary key could not be found
104             */
105            @Indexable(type = IndexableType.DELETE)
106            @Override
107            public Image deleteImage(long imageId) throws PortalException {
108                    return imagePersistence.remove(imageId);
109            }
110    
111            /**
112             * Deletes the image from the database. Also notifies the appropriate model listeners.
113             *
114             * @param image the image
115             * @return the image that was removed
116             */
117            @Indexable(type = IndexableType.DELETE)
118            @Override
119            public Image deleteImage(Image image) {
120                    return imagePersistence.remove(image);
121            }
122    
123            @Override
124            public DynamicQuery dynamicQuery() {
125                    Class<?> clazz = getClass();
126    
127                    return DynamicQueryFactoryUtil.forClass(Image.class,
128                            clazz.getClassLoader());
129            }
130    
131            /**
132             * Performs a dynamic query on the database and returns the matching rows.
133             *
134             * @param dynamicQuery the dynamic query
135             * @return the matching rows
136             */
137            @Override
138            public <T> List<T> dynamicQuery(DynamicQuery dynamicQuery) {
139                    return imagePersistence.findWithDynamicQuery(dynamicQuery);
140            }
141    
142            /**
143             * Performs a dynamic query on the database and returns a range of the matching rows.
144             *
145             * <p>
146             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portal.model.impl.ImageModelImpl}. 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.
147             * </p>
148             *
149             * @param dynamicQuery the dynamic query
150             * @param start the lower bound of the range of model instances
151             * @param end the upper bound of the range of model instances (not inclusive)
152             * @return the range of matching rows
153             */
154            @Override
155            public <T> List<T> dynamicQuery(DynamicQuery dynamicQuery, int start,
156                    int end) {
157                    return imagePersistence.findWithDynamicQuery(dynamicQuery, start, end);
158            }
159    
160            /**
161             * Performs a dynamic query on the database and returns an ordered range of the matching rows.
162             *
163             * <p>
164             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portal.model.impl.ImageModelImpl}. 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.
165             * </p>
166             *
167             * @param dynamicQuery the dynamic query
168             * @param start the lower bound of the range of model instances
169             * @param end the upper bound of the range of model instances (not inclusive)
170             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
171             * @return the ordered range of matching rows
172             */
173            @Override
174            public <T> List<T> dynamicQuery(DynamicQuery dynamicQuery, int start,
175                    int end, OrderByComparator<T> orderByComparator) {
176                    return imagePersistence.findWithDynamicQuery(dynamicQuery, start, end,
177                            orderByComparator);
178            }
179    
180            /**
181             * Returns the number of rows matching the dynamic query.
182             *
183             * @param dynamicQuery the dynamic query
184             * @return the number of rows matching the dynamic query
185             */
186            @Override
187            public long dynamicQueryCount(DynamicQuery dynamicQuery) {
188                    return imagePersistence.countWithDynamicQuery(dynamicQuery);
189            }
190    
191            /**
192             * Returns the number of rows matching the dynamic query.
193             *
194             * @param dynamicQuery the dynamic query
195             * @param projection the projection to apply to the query
196             * @return the number of rows matching the dynamic query
197             */
198            @Override
199            public long dynamicQueryCount(DynamicQuery dynamicQuery,
200                    Projection projection) {
201                    return imagePersistence.countWithDynamicQuery(dynamicQuery, projection);
202            }
203    
204            @Override
205            public Image fetchImage(long imageId) {
206                    return imagePersistence.fetchByPrimaryKey(imageId);
207            }
208    
209            /**
210             * Returns the image with the primary key.
211             *
212             * @param imageId the primary key of the image
213             * @return the image
214             * @throws PortalException if a image with the primary key could not be found
215             */
216            @Override
217            public Image getImage(long imageId) throws PortalException {
218                    return imagePersistence.findByPrimaryKey(imageId);
219            }
220    
221            @Override
222            public ActionableDynamicQuery getActionableDynamicQuery() {
223                    ActionableDynamicQuery actionableDynamicQuery = new DefaultActionableDynamicQuery();
224    
225                    actionableDynamicQuery.setBaseLocalService(com.liferay.portal.service.ImageLocalServiceUtil.getService());
226                    actionableDynamicQuery.setClass(Image.class);
227                    actionableDynamicQuery.setClassLoader(getClassLoader());
228    
229                    actionableDynamicQuery.setPrimaryKeyPropertyName("imageId");
230    
231                    return actionableDynamicQuery;
232            }
233    
234            protected void initActionableDynamicQuery(
235                    ActionableDynamicQuery actionableDynamicQuery) {
236                    actionableDynamicQuery.setBaseLocalService(com.liferay.portal.service.ImageLocalServiceUtil.getService());
237                    actionableDynamicQuery.setClass(Image.class);
238                    actionableDynamicQuery.setClassLoader(getClassLoader());
239    
240                    actionableDynamicQuery.setPrimaryKeyPropertyName("imageId");
241            }
242    
243            /**
244             * @throws PortalException
245             */
246            @Override
247            public PersistedModel deletePersistedModel(PersistedModel persistedModel)
248                    throws PortalException {
249                    return imageLocalService.deleteImage((Image)persistedModel);
250            }
251    
252            @Override
253            public PersistedModel getPersistedModel(Serializable primaryKeyObj)
254                    throws PortalException {
255                    return imagePersistence.findByPrimaryKey(primaryKeyObj);
256            }
257    
258            /**
259             * Returns a range of all the images.
260             *
261             * <p>
262             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portal.model.impl.ImageModelImpl}. 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.
263             * </p>
264             *
265             * @param start the lower bound of the range of images
266             * @param end the upper bound of the range of images (not inclusive)
267             * @return the range of images
268             */
269            @Override
270            public List<Image> getImages(int start, int end) {
271                    return imagePersistence.findAll(start, end);
272            }
273    
274            /**
275             * Returns the number of images.
276             *
277             * @return the number of images
278             */
279            @Override
280            public int getImagesCount() {
281                    return imagePersistence.countAll();
282            }
283    
284            /**
285             * Updates the image in the database or adds it if it does not yet exist. Also notifies the appropriate model listeners.
286             *
287             * @param image the image
288             * @return the image that was updated
289             */
290            @Indexable(type = IndexableType.REINDEX)
291            @Override
292            public Image updateImage(Image image) {
293                    return imagePersistence.update(image);
294            }
295    
296            /**
297             * Returns the image local service.
298             *
299             * @return the image local service
300             */
301            public com.liferay.portal.service.ImageLocalService getImageLocalService() {
302                    return imageLocalService;
303            }
304    
305            /**
306             * Sets the image local service.
307             *
308             * @param imageLocalService the image local service
309             */
310            public void setImageLocalService(
311                    com.liferay.portal.service.ImageLocalService imageLocalService) {
312                    this.imageLocalService = imageLocalService;
313            }
314    
315            /**
316             * Returns the image remote service.
317             *
318             * @return the image remote service
319             */
320            public com.liferay.portal.service.ImageService getImageService() {
321                    return imageService;
322            }
323    
324            /**
325             * Sets the image remote service.
326             *
327             * @param imageService the image remote service
328             */
329            public void setImageService(
330                    com.liferay.portal.service.ImageService imageService) {
331                    this.imageService = imageService;
332            }
333    
334            /**
335             * Returns the image persistence.
336             *
337             * @return the image persistence
338             */
339            public ImagePersistence getImagePersistence() {
340                    return imagePersistence;
341            }
342    
343            /**
344             * Sets the image persistence.
345             *
346             * @param imagePersistence the image persistence
347             */
348            public void setImagePersistence(ImagePersistence imagePersistence) {
349                    this.imagePersistence = imagePersistence;
350            }
351    
352            /**
353             * Returns the counter local service.
354             *
355             * @return the counter local service
356             */
357            public com.liferay.counter.service.CounterLocalService getCounterLocalService() {
358                    return counterLocalService;
359            }
360    
361            /**
362             * Sets the counter local service.
363             *
364             * @param counterLocalService the counter local service
365             */
366            public void setCounterLocalService(
367                    com.liferay.counter.service.CounterLocalService counterLocalService) {
368                    this.counterLocalService = counterLocalService;
369            }
370    
371            /**
372             * Returns the document library file entry local service.
373             *
374             * @return the document library file entry local service
375             */
376            public com.liferay.portlet.documentlibrary.service.DLFileEntryLocalService getDLFileEntryLocalService() {
377                    return dlFileEntryLocalService;
378            }
379    
380            /**
381             * Sets the document library file entry local service.
382             *
383             * @param dlFileEntryLocalService the document library file entry local service
384             */
385            public void setDLFileEntryLocalService(
386                    com.liferay.portlet.documentlibrary.service.DLFileEntryLocalService dlFileEntryLocalService) {
387                    this.dlFileEntryLocalService = dlFileEntryLocalService;
388            }
389    
390            /**
391             * Returns the document library file entry remote service.
392             *
393             * @return the document library file entry remote service
394             */
395            public com.liferay.portlet.documentlibrary.service.DLFileEntryService getDLFileEntryService() {
396                    return dlFileEntryService;
397            }
398    
399            /**
400             * Sets the document library file entry remote service.
401             *
402             * @param dlFileEntryService the document library file entry remote service
403             */
404            public void setDLFileEntryService(
405                    com.liferay.portlet.documentlibrary.service.DLFileEntryService dlFileEntryService) {
406                    this.dlFileEntryService = dlFileEntryService;
407            }
408    
409            /**
410             * Returns the document library file entry persistence.
411             *
412             * @return the document library file entry persistence
413             */
414            public DLFileEntryPersistence getDLFileEntryPersistence() {
415                    return dlFileEntryPersistence;
416            }
417    
418            /**
419             * Sets the document library file entry persistence.
420             *
421             * @param dlFileEntryPersistence the document library file entry persistence
422             */
423            public void setDLFileEntryPersistence(
424                    DLFileEntryPersistence dlFileEntryPersistence) {
425                    this.dlFileEntryPersistence = dlFileEntryPersistence;
426            }
427    
428            /**
429             * Returns the document library file entry finder.
430             *
431             * @return the document library file entry finder
432             */
433            public DLFileEntryFinder getDLFileEntryFinder() {
434                    return dlFileEntryFinder;
435            }
436    
437            /**
438             * Sets the document library file entry finder.
439             *
440             * @param dlFileEntryFinder the document library file entry finder
441             */
442            public void setDLFileEntryFinder(DLFileEntryFinder dlFileEntryFinder) {
443                    this.dlFileEntryFinder = dlFileEntryFinder;
444            }
445    
446            public void afterPropertiesSet() {
447                    persistedModelLocalServiceRegistry.register("com.liferay.portal.model.Image",
448                            imageLocalService);
449            }
450    
451            public void destroy() {
452                    persistedModelLocalServiceRegistry.unregister(
453                            "com.liferay.portal.model.Image");
454            }
455    
456            /**
457             * Returns the Spring bean ID for this bean.
458             *
459             * @return the Spring bean ID for this bean
460             */
461            @Override
462            public String getBeanIdentifier() {
463                    return _beanIdentifier;
464            }
465    
466            /**
467             * Sets the Spring bean ID for this bean.
468             *
469             * @param beanIdentifier the Spring bean ID for this bean
470             */
471            @Override
472            public void setBeanIdentifier(String beanIdentifier) {
473                    _beanIdentifier = beanIdentifier;
474            }
475    
476            protected Class<?> getModelClass() {
477                    return Image.class;
478            }
479    
480            protected String getModelClassName() {
481                    return Image.class.getName();
482            }
483    
484            /**
485             * Performs a SQL query.
486             *
487             * @param sql the sql query
488             */
489            protected void runSQL(String sql) {
490                    try {
491                            DataSource dataSource = imagePersistence.getDataSource();
492    
493                            DB db = DBFactoryUtil.getDB();
494    
495                            sql = db.buildSQL(sql);
496                            sql = PortalUtil.transformSQL(sql);
497    
498                            SqlUpdate sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(dataSource,
499                                            sql, new int[0]);
500    
501                            sqlUpdate.update();
502                    }
503                    catch (Exception e) {
504                            throw new SystemException(e);
505                    }
506            }
507    
508            @BeanReference(type = com.liferay.portal.service.ImageLocalService.class)
509            protected com.liferay.portal.service.ImageLocalService imageLocalService;
510            @BeanReference(type = com.liferay.portal.service.ImageService.class)
511            protected com.liferay.portal.service.ImageService imageService;
512            @BeanReference(type = ImagePersistence.class)
513            protected ImagePersistence imagePersistence;
514            @BeanReference(type = com.liferay.counter.service.CounterLocalService.class)
515            protected com.liferay.counter.service.CounterLocalService counterLocalService;
516            @BeanReference(type = com.liferay.portlet.documentlibrary.service.DLFileEntryLocalService.class)
517            protected com.liferay.portlet.documentlibrary.service.DLFileEntryLocalService dlFileEntryLocalService;
518            @BeanReference(type = com.liferay.portlet.documentlibrary.service.DLFileEntryService.class)
519            protected com.liferay.portlet.documentlibrary.service.DLFileEntryService dlFileEntryService;
520            @BeanReference(type = DLFileEntryPersistence.class)
521            protected DLFileEntryPersistence dlFileEntryPersistence;
522            @BeanReference(type = DLFileEntryFinder.class)
523            protected DLFileEntryFinder dlFileEntryFinder;
524            @BeanReference(type = PersistedModelLocalServiceRegistry.class)
525            protected PersistedModelLocalServiceRegistry persistedModelLocalServiceRegistry;
526            private String _beanIdentifier;
527    }