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.dynamicdatamapping.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.dynamicdatamapping.model.DDMTemplateLink;
041    import com.liferay.portlet.dynamicdatamapping.service.DDMTemplateLinkLocalService;
042    import com.liferay.portlet.dynamicdatamapping.service.persistence.DDMTemplateLinkPersistence;
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 d d m template link 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.dynamicdatamapping.service.impl.DDMTemplateLinkLocalServiceImpl}.
055     * </p>
056     *
057     * @author Brian Wing Shun Chan
058     * @see com.liferay.portlet.dynamicdatamapping.service.impl.DDMTemplateLinkLocalServiceImpl
059     * @see com.liferay.portlet.dynamicdatamapping.service.DDMTemplateLinkLocalServiceUtil
060     * @generated
061     */
062    @ProviderType
063    public abstract class DDMTemplateLinkLocalServiceBaseImpl
064            extends BaseLocalServiceImpl implements DDMTemplateLinkLocalService,
065                    IdentifiableBean {
066            /*
067             * NOTE FOR DEVELOPERS:
068             *
069             * Never modify or reference this class directly. Always use {@link com.liferay.portlet.dynamicdatamapping.service.DDMTemplateLinkLocalServiceUtil} to access the d d m template link local service.
070             */
071    
072            /**
073             * Adds the d d m template link to the database. Also notifies the appropriate model listeners.
074             *
075             * @param ddmTemplateLink the d d m template link
076             * @return the d d m template link that was added
077             */
078            @Indexable(type = IndexableType.REINDEX)
079            @Override
080            public DDMTemplateLink addDDMTemplateLink(DDMTemplateLink ddmTemplateLink) {
081                    ddmTemplateLink.setNew(true);
082    
083                    return ddmTemplateLinkPersistence.update(ddmTemplateLink);
084            }
085    
086            /**
087             * Creates a new d d m template link with the primary key. Does not add the d d m template link to the database.
088             *
089             * @param templateLinkId the primary key for the new d d m template link
090             * @return the new d d m template link
091             */
092            @Override
093            public DDMTemplateLink createDDMTemplateLink(long templateLinkId) {
094                    return ddmTemplateLinkPersistence.create(templateLinkId);
095            }
096    
097            /**
098             * Deletes the d d m template link with the primary key from the database. Also notifies the appropriate model listeners.
099             *
100             * @param templateLinkId the primary key of the d d m template link
101             * @return the d d m template link that was removed
102             * @throws PortalException if a d d m template link with the primary key could not be found
103             */
104            @Indexable(type = IndexableType.DELETE)
105            @Override
106            public DDMTemplateLink deleteDDMTemplateLink(long templateLinkId)
107                    throws PortalException {
108                    return ddmTemplateLinkPersistence.remove(templateLinkId);
109            }
110    
111            /**
112             * Deletes the d d m template link from the database. Also notifies the appropriate model listeners.
113             *
114             * @param ddmTemplateLink the d d m template link
115             * @return the d d m template link that was removed
116             */
117            @Indexable(type = IndexableType.DELETE)
118            @Override
119            public DDMTemplateLink deleteDDMTemplateLink(
120                    DDMTemplateLink ddmTemplateLink) {
121                    return ddmTemplateLinkPersistence.remove(ddmTemplateLink);
122            }
123    
124            @Override
125            public DynamicQuery dynamicQuery() {
126                    Class<?> clazz = getClass();
127    
128                    return DynamicQueryFactoryUtil.forClass(DDMTemplateLink.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 ddmTemplateLinkPersistence.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.portlet.dynamicdatamapping.model.impl.DDMTemplateLinkModelImpl}. 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 ddmTemplateLinkPersistence.findWithDynamicQuery(dynamicQuery,
159                            start, end);
160            }
161    
162            /**
163             * Performs a dynamic query on the database and returns an ordered range of the matching rows.
164             *
165             * <p>
166             * 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.dynamicdatamapping.model.impl.DDMTemplateLinkModelImpl}. 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.
167             * </p>
168             *
169             * @param dynamicQuery the dynamic query
170             * @param start the lower bound of the range of model instances
171             * @param end the upper bound of the range of model instances (not inclusive)
172             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
173             * @return the ordered range of matching rows
174             */
175            @Override
176            public <T> List<T> dynamicQuery(DynamicQuery dynamicQuery, int start,
177                    int end, OrderByComparator<T> orderByComparator) {
178                    return ddmTemplateLinkPersistence.findWithDynamicQuery(dynamicQuery,
179                            start, end, orderByComparator);
180            }
181    
182            /**
183             * Returns the number of rows matching the dynamic query.
184             *
185             * @param dynamicQuery the dynamic query
186             * @return the number of rows matching the dynamic query
187             */
188            @Override
189            public long dynamicQueryCount(DynamicQuery dynamicQuery) {
190                    return ddmTemplateLinkPersistence.countWithDynamicQuery(dynamicQuery);
191            }
192    
193            /**
194             * Returns the number of rows matching the dynamic query.
195             *
196             * @param dynamicQuery the dynamic query
197             * @param projection the projection to apply to the query
198             * @return the number of rows matching the dynamic query
199             */
200            @Override
201            public long dynamicQueryCount(DynamicQuery dynamicQuery,
202                    Projection projection) {
203                    return ddmTemplateLinkPersistence.countWithDynamicQuery(dynamicQuery,
204                            projection);
205            }
206    
207            @Override
208            public DDMTemplateLink fetchDDMTemplateLink(long templateLinkId) {
209                    return ddmTemplateLinkPersistence.fetchByPrimaryKey(templateLinkId);
210            }
211    
212            /**
213             * Returns the d d m template link with the primary key.
214             *
215             * @param templateLinkId the primary key of the d d m template link
216             * @return the d d m template link
217             * @throws PortalException if a d d m template link with the primary key could not be found
218             */
219            @Override
220            public DDMTemplateLink getDDMTemplateLink(long templateLinkId)
221                    throws PortalException {
222                    return ddmTemplateLinkPersistence.findByPrimaryKey(templateLinkId);
223            }
224    
225            @Override
226            public ActionableDynamicQuery getActionableDynamicQuery() {
227                    ActionableDynamicQuery actionableDynamicQuery = new DefaultActionableDynamicQuery();
228    
229                    actionableDynamicQuery.setBaseLocalService(com.liferay.portlet.dynamicdatamapping.service.DDMTemplateLinkLocalServiceUtil.getService());
230                    actionableDynamicQuery.setClass(DDMTemplateLink.class);
231                    actionableDynamicQuery.setClassLoader(getClassLoader());
232    
233                    actionableDynamicQuery.setPrimaryKeyPropertyName("templateLinkId");
234    
235                    return actionableDynamicQuery;
236            }
237    
238            protected void initActionableDynamicQuery(
239                    ActionableDynamicQuery actionableDynamicQuery) {
240                    actionableDynamicQuery.setBaseLocalService(com.liferay.portlet.dynamicdatamapping.service.DDMTemplateLinkLocalServiceUtil.getService());
241                    actionableDynamicQuery.setClass(DDMTemplateLink.class);
242                    actionableDynamicQuery.setClassLoader(getClassLoader());
243    
244                    actionableDynamicQuery.setPrimaryKeyPropertyName("templateLinkId");
245            }
246    
247            /**
248             * @throws PortalException
249             */
250            @Override
251            public PersistedModel deletePersistedModel(PersistedModel persistedModel)
252                    throws PortalException {
253                    return ddmTemplateLinkLocalService.deleteDDMTemplateLink((DDMTemplateLink)persistedModel);
254            }
255    
256            @Override
257            public PersistedModel getPersistedModel(Serializable primaryKeyObj)
258                    throws PortalException {
259                    return ddmTemplateLinkPersistence.findByPrimaryKey(primaryKeyObj);
260            }
261    
262            /**
263             * Returns a range of all the d d m template links.
264             *
265             * <p>
266             * 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.dynamicdatamapping.model.impl.DDMTemplateLinkModelImpl}. 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.
267             * </p>
268             *
269             * @param start the lower bound of the range of d d m template links
270             * @param end the upper bound of the range of d d m template links (not inclusive)
271             * @return the range of d d m template links
272             */
273            @Override
274            public List<DDMTemplateLink> getDDMTemplateLinks(int start, int end) {
275                    return ddmTemplateLinkPersistence.findAll(start, end);
276            }
277    
278            /**
279             * Returns the number of d d m template links.
280             *
281             * @return the number of d d m template links
282             */
283            @Override
284            public int getDDMTemplateLinksCount() {
285                    return ddmTemplateLinkPersistence.countAll();
286            }
287    
288            /**
289             * Updates the d d m template link in the database or adds it if it does not yet exist. Also notifies the appropriate model listeners.
290             *
291             * @param ddmTemplateLink the d d m template link
292             * @return the d d m template link that was updated
293             */
294            @Indexable(type = IndexableType.REINDEX)
295            @Override
296            public DDMTemplateLink updateDDMTemplateLink(
297                    DDMTemplateLink ddmTemplateLink) {
298                    return ddmTemplateLinkPersistence.update(ddmTemplateLink);
299            }
300    
301            /**
302             * Returns the d d m template link local service.
303             *
304             * @return the d d m template link local service
305             */
306            public DDMTemplateLinkLocalService getDDMTemplateLinkLocalService() {
307                    return ddmTemplateLinkLocalService;
308            }
309    
310            /**
311             * Sets the d d m template link local service.
312             *
313             * @param ddmTemplateLinkLocalService the d d m template link local service
314             */
315            public void setDDMTemplateLinkLocalService(
316                    DDMTemplateLinkLocalService ddmTemplateLinkLocalService) {
317                    this.ddmTemplateLinkLocalService = ddmTemplateLinkLocalService;
318            }
319    
320            /**
321             * Returns the d d m template link persistence.
322             *
323             * @return the d d m template link persistence
324             */
325            public DDMTemplateLinkPersistence getDDMTemplateLinkPersistence() {
326                    return ddmTemplateLinkPersistence;
327            }
328    
329            /**
330             * Sets the d d m template link persistence.
331             *
332             * @param ddmTemplateLinkPersistence the d d m template link persistence
333             */
334            public void setDDMTemplateLinkPersistence(
335                    DDMTemplateLinkPersistence ddmTemplateLinkPersistence) {
336                    this.ddmTemplateLinkPersistence = ddmTemplateLinkPersistence;
337            }
338    
339            /**
340             * Returns the counter local service.
341             *
342             * @return the counter local service
343             */
344            public com.liferay.counter.service.CounterLocalService getCounterLocalService() {
345                    return counterLocalService;
346            }
347    
348            /**
349             * Sets the counter local service.
350             *
351             * @param counterLocalService the counter local service
352             */
353            public void setCounterLocalService(
354                    com.liferay.counter.service.CounterLocalService counterLocalService) {
355                    this.counterLocalService = counterLocalService;
356            }
357    
358            public void afterPropertiesSet() {
359                    persistedModelLocalServiceRegistry.register("com.liferay.portlet.dynamicdatamapping.model.DDMTemplateLink",
360                            ddmTemplateLinkLocalService);
361            }
362    
363            public void destroy() {
364                    persistedModelLocalServiceRegistry.unregister(
365                            "com.liferay.portlet.dynamicdatamapping.model.DDMTemplateLink");
366            }
367    
368            /**
369             * Returns the Spring bean ID for this bean.
370             *
371             * @return the Spring bean ID for this bean
372             */
373            @Override
374            public String getBeanIdentifier() {
375                    return _beanIdentifier;
376            }
377    
378            /**
379             * Sets the Spring bean ID for this bean.
380             *
381             * @param beanIdentifier the Spring bean ID for this bean
382             */
383            @Override
384            public void setBeanIdentifier(String beanIdentifier) {
385                    _beanIdentifier = beanIdentifier;
386            }
387    
388            protected Class<?> getModelClass() {
389                    return DDMTemplateLink.class;
390            }
391    
392            protected String getModelClassName() {
393                    return DDMTemplateLink.class.getName();
394            }
395    
396            /**
397             * Performs a SQL query.
398             *
399             * @param sql the sql query
400             */
401            protected void runSQL(String sql) {
402                    try {
403                            DataSource dataSource = ddmTemplateLinkPersistence.getDataSource();
404    
405                            DB db = DBFactoryUtil.getDB();
406    
407                            sql = db.buildSQL(sql);
408                            sql = PortalUtil.transformSQL(sql);
409    
410                            SqlUpdate sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(dataSource,
411                                            sql, new int[0]);
412    
413                            sqlUpdate.update();
414                    }
415                    catch (Exception e) {
416                            throw new SystemException(e);
417                    }
418            }
419    
420            @BeanReference(type = DDMTemplateLinkLocalService.class)
421            protected DDMTemplateLinkLocalService ddmTemplateLinkLocalService;
422            @BeanReference(type = DDMTemplateLinkPersistence.class)
423            protected DDMTemplateLinkPersistence ddmTemplateLinkPersistence;
424            @BeanReference(type = com.liferay.counter.service.CounterLocalService.class)
425            protected com.liferay.counter.service.CounterLocalService counterLocalService;
426            @BeanReference(type = PersistedModelLocalServiceRegistry.class)
427            protected PersistedModelLocalServiceRegistry persistedModelLocalServiceRegistry;
428            private String _beanIdentifier;
429    }