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.dao.db.DB;
021    import com.liferay.portal.kernel.dao.db.DBFactoryUtil;
022    import com.liferay.portal.kernel.dao.jdbc.SqlUpdate;
023    import com.liferay.portal.kernel.dao.jdbc.SqlUpdateFactoryUtil;
024    import com.liferay.portal.kernel.dao.orm.ActionableDynamicQuery;
025    import com.liferay.portal.kernel.dao.orm.DefaultActionableDynamicQuery;
026    import com.liferay.portal.kernel.dao.orm.DynamicQuery;
027    import com.liferay.portal.kernel.dao.orm.DynamicQueryFactoryUtil;
028    import com.liferay.portal.kernel.dao.orm.Projection;
029    import com.liferay.portal.kernel.exception.PortalException;
030    import com.liferay.portal.kernel.exception.SystemException;
031    import com.liferay.portal.kernel.module.framework.service.IdentifiableOSGiService;
032    import com.liferay.portal.kernel.search.Indexable;
033    import com.liferay.portal.kernel.search.IndexableType;
034    import com.liferay.portal.kernel.util.OrderByComparator;
035    import com.liferay.portal.model.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, IdentifiableOSGiService {
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 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(ImageLocalService imageLocalService) {
311                    this.imageLocalService = imageLocalService;
312            }
313    
314            /**
315             * Returns the image remote service.
316             *
317             * @return the image remote service
318             */
319            public com.liferay.portal.service.ImageService getImageService() {
320                    return imageService;
321            }
322    
323            /**
324             * Sets the image remote service.
325             *
326             * @param imageService the image remote service
327             */
328            public void setImageService(
329                    com.liferay.portal.service.ImageService imageService) {
330                    this.imageService = imageService;
331            }
332    
333            /**
334             * Returns the image persistence.
335             *
336             * @return the image persistence
337             */
338            public ImagePersistence getImagePersistence() {
339                    return imagePersistence;
340            }
341    
342            /**
343             * Sets the image persistence.
344             *
345             * @param imagePersistence the image persistence
346             */
347            public void setImagePersistence(ImagePersistence imagePersistence) {
348                    this.imagePersistence = imagePersistence;
349            }
350    
351            /**
352             * Returns the counter local service.
353             *
354             * @return the counter local service
355             */
356            public com.liferay.counter.service.CounterLocalService getCounterLocalService() {
357                    return counterLocalService;
358            }
359    
360            /**
361             * Sets the counter local service.
362             *
363             * @param counterLocalService the counter local service
364             */
365            public void setCounterLocalService(
366                    com.liferay.counter.service.CounterLocalService counterLocalService) {
367                    this.counterLocalService = counterLocalService;
368            }
369    
370            /**
371             * Returns the document library file entry local service.
372             *
373             * @return the document library file entry local service
374             */
375            public com.liferay.portlet.documentlibrary.service.DLFileEntryLocalService getDLFileEntryLocalService() {
376                    return dlFileEntryLocalService;
377            }
378    
379            /**
380             * Sets the document library file entry local service.
381             *
382             * @param dlFileEntryLocalService the document library file entry local service
383             */
384            public void setDLFileEntryLocalService(
385                    com.liferay.portlet.documentlibrary.service.DLFileEntryLocalService dlFileEntryLocalService) {
386                    this.dlFileEntryLocalService = dlFileEntryLocalService;
387            }
388    
389            /**
390             * Returns the document library file entry remote service.
391             *
392             * @return the document library file entry remote service
393             */
394            public com.liferay.portlet.documentlibrary.service.DLFileEntryService getDLFileEntryService() {
395                    return dlFileEntryService;
396            }
397    
398            /**
399             * Sets the document library file entry remote service.
400             *
401             * @param dlFileEntryService the document library file entry remote service
402             */
403            public void setDLFileEntryService(
404                    com.liferay.portlet.documentlibrary.service.DLFileEntryService dlFileEntryService) {
405                    this.dlFileEntryService = dlFileEntryService;
406            }
407    
408            /**
409             * Returns the document library file entry persistence.
410             *
411             * @return the document library file entry persistence
412             */
413            public DLFileEntryPersistence getDLFileEntryPersistence() {
414                    return dlFileEntryPersistence;
415            }
416    
417            /**
418             * Sets the document library file entry persistence.
419             *
420             * @param dlFileEntryPersistence the document library file entry persistence
421             */
422            public void setDLFileEntryPersistence(
423                    DLFileEntryPersistence dlFileEntryPersistence) {
424                    this.dlFileEntryPersistence = dlFileEntryPersistence;
425            }
426    
427            /**
428             * Returns the document library file entry finder.
429             *
430             * @return the document library file entry finder
431             */
432            public DLFileEntryFinder getDLFileEntryFinder() {
433                    return dlFileEntryFinder;
434            }
435    
436            /**
437             * Sets the document library file entry finder.
438             *
439             * @param dlFileEntryFinder the document library file entry finder
440             */
441            public void setDLFileEntryFinder(DLFileEntryFinder dlFileEntryFinder) {
442                    this.dlFileEntryFinder = dlFileEntryFinder;
443            }
444    
445            public void afterPropertiesSet() {
446                    persistedModelLocalServiceRegistry.register("com.liferay.portal.model.Image",
447                            imageLocalService);
448            }
449    
450            public void destroy() {
451                    persistedModelLocalServiceRegistry.unregister(
452                            "com.liferay.portal.model.Image");
453            }
454    
455            /**
456             * Returns the OSGi service identifier.
457             *
458             * @return the OSGi service identifier
459             */
460            @Override
461            public String getOSGiServiceIdentifier() {
462                    return ImageLocalService.class.getName();
463            }
464    
465            protected Class<?> getModelClass() {
466                    return Image.class;
467            }
468    
469            protected String getModelClassName() {
470                    return Image.class.getName();
471            }
472    
473            /**
474             * Performs a SQL query.
475             *
476             * @param sql the sql query
477             */
478            protected void runSQL(String sql) {
479                    try {
480                            DataSource dataSource = imagePersistence.getDataSource();
481    
482                            DB db = DBFactoryUtil.getDB();
483    
484                            sql = db.buildSQL(sql);
485                            sql = PortalUtil.transformSQL(sql);
486    
487                            SqlUpdate sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(dataSource,
488                                            sql, new int[0]);
489    
490                            sqlUpdate.update();
491                    }
492                    catch (Exception e) {
493                            throw new SystemException(e);
494                    }
495            }
496    
497            @BeanReference(type = com.liferay.portal.service.ImageLocalService.class)
498            protected ImageLocalService imageLocalService;
499            @BeanReference(type = com.liferay.portal.service.ImageService.class)
500            protected com.liferay.portal.service.ImageService imageService;
501            @BeanReference(type = ImagePersistence.class)
502            protected ImagePersistence imagePersistence;
503            @BeanReference(type = com.liferay.counter.service.CounterLocalService.class)
504            protected com.liferay.counter.service.CounterLocalService counterLocalService;
505            @BeanReference(type = com.liferay.portlet.documentlibrary.service.DLFileEntryLocalService.class)
506            protected com.liferay.portlet.documentlibrary.service.DLFileEntryLocalService dlFileEntryLocalService;
507            @BeanReference(type = com.liferay.portlet.documentlibrary.service.DLFileEntryService.class)
508            protected com.liferay.portlet.documentlibrary.service.DLFileEntryService dlFileEntryService;
509            @BeanReference(type = DLFileEntryPersistence.class)
510            protected DLFileEntryPersistence dlFileEntryPersistence;
511            @BeanReference(type = DLFileEntryFinder.class)
512            protected DLFileEntryFinder dlFileEntryFinder;
513            @BeanReference(type = PersistedModelLocalServiceRegistry.class)
514            protected PersistedModelLocalServiceRegistry persistedModelLocalServiceRegistry;
515    }