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