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