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