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.documentlibrary.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.dao.orm.Session;
031    import com.liferay.portal.kernel.exception.PortalException;
032    import com.liferay.portal.kernel.exception.SystemException;
033    import com.liferay.portal.kernel.search.Indexable;
034    import com.liferay.portal.kernel.search.IndexableType;
035    import com.liferay.portal.kernel.util.OrderByComparator;
036    import com.liferay.portal.model.PersistedModel;
037    import com.liferay.portal.service.BaseLocalServiceImpl;
038    import com.liferay.portal.service.PersistedModelLocalServiceRegistry;
039    import com.liferay.portal.util.PortalUtil;
040    
041    import com.liferay.portlet.documentlibrary.model.DLContent;
042    import com.liferay.portlet.documentlibrary.model.DLContentDataBlobModel;
043    import com.liferay.portlet.documentlibrary.service.DLContentLocalService;
044    import com.liferay.portlet.documentlibrary.service.persistence.DLContentPersistence;
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 document library content 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.portlet.documentlibrary.service.impl.DLContentLocalServiceImpl}.
057     * </p>
058     *
059     * @author Brian Wing Shun Chan
060     * @see com.liferay.portlet.documentlibrary.service.impl.DLContentLocalServiceImpl
061     * @see com.liferay.portlet.documentlibrary.service.DLContentLocalServiceUtil
062     * @generated
063     */
064    @ProviderType
065    public abstract class DLContentLocalServiceBaseImpl extends BaseLocalServiceImpl
066            implements DLContentLocalService, IdentifiableBean {
067            /*
068             * NOTE FOR DEVELOPERS:
069             *
070             * Never modify or reference this class directly. Always use {@link com.liferay.portlet.documentlibrary.service.DLContentLocalServiceUtil} to access the document library content local service.
071             */
072    
073            /**
074             * Adds the document library content to the database. Also notifies the appropriate model listeners.
075             *
076             * @param dlContent the document library content
077             * @return the document library content that was added
078             */
079            @Indexable(type = IndexableType.REINDEX)
080            @Override
081            public DLContent addDLContent(DLContent dlContent) {
082                    dlContent.setNew(true);
083    
084                    return dlContentPersistence.update(dlContent);
085            }
086    
087            /**
088             * Creates a new document library content with the primary key. Does not add the document library content to the database.
089             *
090             * @param contentId the primary key for the new document library content
091             * @return the new document library content
092             */
093            @Override
094            public DLContent createDLContent(long contentId) {
095                    return dlContentPersistence.create(contentId);
096            }
097    
098            /**
099             * Deletes the document library content with the primary key from the database. Also notifies the appropriate model listeners.
100             *
101             * @param contentId the primary key of the document library content
102             * @return the document library content that was removed
103             * @throws PortalException if a document library content with the primary key could not be found
104             */
105            @Indexable(type = IndexableType.DELETE)
106            @Override
107            public DLContent deleteDLContent(long contentId) throws PortalException {
108                    return dlContentPersistence.remove(contentId);
109            }
110    
111            /**
112             * Deletes the document library content from the database. Also notifies the appropriate model listeners.
113             *
114             * @param dlContent the document library content
115             * @return the document library content that was removed
116             */
117            @Indexable(type = IndexableType.DELETE)
118            @Override
119            public DLContent deleteDLContent(DLContent dlContent) {
120                    return dlContentPersistence.remove(dlContent);
121            }
122    
123            @Override
124            public DynamicQuery dynamicQuery() {
125                    Class<?> clazz = getClass();
126    
127                    return DynamicQueryFactoryUtil.forClass(DLContent.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 dlContentPersistence.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.portlet.documentlibrary.model.impl.DLContentModelImpl}. 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 dlContentPersistence.findWithDynamicQuery(dynamicQuery, start,
158                            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.portlet.documentlibrary.model.impl.DLContentModelImpl}. 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 dlContentPersistence.findWithDynamicQuery(dynamicQuery, start,
178                            end, 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 dlContentPersistence.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 dlContentPersistence.countWithDynamicQuery(dynamicQuery,
203                            projection);
204            }
205    
206            @Override
207            public DLContent fetchDLContent(long contentId) {
208                    return dlContentPersistence.fetchByPrimaryKey(contentId);
209            }
210    
211            /**
212             * Returns the document library content with the primary key.
213             *
214             * @param contentId the primary key of the document library content
215             * @return the document library content
216             * @throws PortalException if a document library content with the primary key could not be found
217             */
218            @Override
219            public DLContent getDLContent(long contentId) throws PortalException {
220                    return dlContentPersistence.findByPrimaryKey(contentId);
221            }
222    
223            @Override
224            public ActionableDynamicQuery getActionableDynamicQuery() {
225                    ActionableDynamicQuery actionableDynamicQuery = new DefaultActionableDynamicQuery();
226    
227                    actionableDynamicQuery.setBaseLocalService(com.liferay.portlet.documentlibrary.service.DLContentLocalServiceUtil.getService());
228                    actionableDynamicQuery.setClass(DLContent.class);
229                    actionableDynamicQuery.setClassLoader(getClassLoader());
230    
231                    actionableDynamicQuery.setPrimaryKeyPropertyName("contentId");
232    
233                    return actionableDynamicQuery;
234            }
235    
236            protected void initActionableDynamicQuery(
237                    ActionableDynamicQuery actionableDynamicQuery) {
238                    actionableDynamicQuery.setBaseLocalService(com.liferay.portlet.documentlibrary.service.DLContentLocalServiceUtil.getService());
239                    actionableDynamicQuery.setClass(DLContent.class);
240                    actionableDynamicQuery.setClassLoader(getClassLoader());
241    
242                    actionableDynamicQuery.setPrimaryKeyPropertyName("contentId");
243            }
244    
245            /**
246             * @throws PortalException
247             */
248            @Override
249            public PersistedModel deletePersistedModel(PersistedModel persistedModel)
250                    throws PortalException {
251                    return dlContentLocalService.deleteDLContent((DLContent)persistedModel);
252            }
253    
254            @Override
255            public PersistedModel getPersistedModel(Serializable primaryKeyObj)
256                    throws PortalException {
257                    return dlContentPersistence.findByPrimaryKey(primaryKeyObj);
258            }
259    
260            /**
261             * Returns a range of all the document library contents.
262             *
263             * <p>
264             * 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.documentlibrary.model.impl.DLContentModelImpl}. 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.
265             * </p>
266             *
267             * @param start the lower bound of the range of document library contents
268             * @param end the upper bound of the range of document library contents (not inclusive)
269             * @return the range of document library contents
270             */
271            @Override
272            public List<DLContent> getDLContents(int start, int end) {
273                    return dlContentPersistence.findAll(start, end);
274            }
275    
276            /**
277             * Returns the number of document library contents.
278             *
279             * @return the number of document library contents
280             */
281            @Override
282            public int getDLContentsCount() {
283                    return dlContentPersistence.countAll();
284            }
285    
286            /**
287             * Updates the document library content in the database or adds it if it does not yet exist. Also notifies the appropriate model listeners.
288             *
289             * @param dlContent the document library content
290             * @return the document library content that was updated
291             */
292            @Indexable(type = IndexableType.REINDEX)
293            @Override
294            public DLContent updateDLContent(DLContent dlContent) {
295                    return dlContentPersistence.update(dlContent);
296            }
297    
298            @Override
299            public DLContentDataBlobModel getDataBlobModel(Serializable primaryKey) {
300                    Session session = null;
301    
302                    try {
303                            session = dlContentPersistence.openSession();
304    
305                            return (com.liferay.portlet.documentlibrary.model.DLContentDataBlobModel)session.get(DLContentDataBlobModel.class,
306                                    primaryKey);
307                    }
308                    catch (Exception e) {
309                            throw dlContentPersistence.processException(e);
310                    }
311                    finally {
312                            dlContentPersistence.closeSession(session);
313                    }
314            }
315    
316            /**
317             * Returns the document library content local service.
318             *
319             * @return the document library content local service
320             */
321            public com.liferay.portlet.documentlibrary.service.DLContentLocalService getDLContentLocalService() {
322                    return dlContentLocalService;
323            }
324    
325            /**
326             * Sets the document library content local service.
327             *
328             * @param dlContentLocalService the document library content local service
329             */
330            public void setDLContentLocalService(
331                    com.liferay.portlet.documentlibrary.service.DLContentLocalService dlContentLocalService) {
332                    this.dlContentLocalService = dlContentLocalService;
333            }
334    
335            /**
336             * Returns the document library content persistence.
337             *
338             * @return the document library content persistence
339             */
340            public DLContentPersistence getDLContentPersistence() {
341                    return dlContentPersistence;
342            }
343    
344            /**
345             * Sets the document library content persistence.
346             *
347             * @param dlContentPersistence the document library content persistence
348             */
349            public void setDLContentPersistence(
350                    DLContentPersistence dlContentPersistence) {
351                    this.dlContentPersistence = dlContentPersistence;
352            }
353    
354            /**
355             * Returns the counter local service.
356             *
357             * @return the counter local service
358             */
359            public com.liferay.counter.service.CounterLocalService getCounterLocalService() {
360                    return counterLocalService;
361            }
362    
363            /**
364             * Sets the counter local service.
365             *
366             * @param counterLocalService the counter local service
367             */
368            public void setCounterLocalService(
369                    com.liferay.counter.service.CounterLocalService counterLocalService) {
370                    this.counterLocalService = counterLocalService;
371            }
372    
373            public void afterPropertiesSet() {
374                    persistedModelLocalServiceRegistry.register("com.liferay.portlet.documentlibrary.model.DLContent",
375                            dlContentLocalService);
376            }
377    
378            public void destroy() {
379                    persistedModelLocalServiceRegistry.unregister(
380                            "com.liferay.portlet.documentlibrary.model.DLContent");
381            }
382    
383            /**
384             * Returns the Spring bean ID for this bean.
385             *
386             * @return the Spring bean ID for this bean
387             */
388            @Override
389            public String getBeanIdentifier() {
390                    return _beanIdentifier;
391            }
392    
393            /**
394             * Sets the Spring bean ID for this bean.
395             *
396             * @param beanIdentifier the Spring bean ID for this bean
397             */
398            @Override
399            public void setBeanIdentifier(String beanIdentifier) {
400                    _beanIdentifier = beanIdentifier;
401            }
402    
403            protected Class<?> getModelClass() {
404                    return DLContent.class;
405            }
406    
407            protected String getModelClassName() {
408                    return DLContent.class.getName();
409            }
410    
411            /**
412             * Performs a SQL query.
413             *
414             * @param sql the sql query
415             */
416            protected void runSQL(String sql) {
417                    try {
418                            DataSource dataSource = dlContentPersistence.getDataSource();
419    
420                            DB db = DBFactoryUtil.getDB();
421    
422                            sql = db.buildSQL(sql);
423                            sql = PortalUtil.transformSQL(sql);
424    
425                            SqlUpdate sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(dataSource,
426                                            sql, new int[0]);
427    
428                            sqlUpdate.update();
429                    }
430                    catch (Exception e) {
431                            throw new SystemException(e);
432                    }
433            }
434    
435            @BeanReference(type = com.liferay.portlet.documentlibrary.service.DLContentLocalService.class)
436            protected com.liferay.portlet.documentlibrary.service.DLContentLocalService dlContentLocalService;
437            @BeanReference(type = DLContentPersistence.class)
438            protected DLContentPersistence dlContentPersistence;
439            @BeanReference(type = com.liferay.counter.service.CounterLocalService.class)
440            protected com.liferay.counter.service.CounterLocalService counterLocalService;
441            @BeanReference(type = PersistedModelLocalServiceRegistry.class)
442            protected PersistedModelLocalServiceRegistry persistedModelLocalServiceRegistry;
443            private String _beanIdentifier;
444    }