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.ExportActionableDynamicQuery;
030    import com.liferay.portal.kernel.dao.orm.Projection;
031    import com.liferay.portal.kernel.exception.PortalException;
032    import com.liferay.portal.kernel.exception.SystemException;
033    import com.liferay.portal.kernel.lar.ExportImportHelperUtil;
034    import com.liferay.portal.kernel.lar.ManifestSummary;
035    import com.liferay.portal.kernel.lar.PortletDataContext;
036    import com.liferay.portal.kernel.lar.StagedModelDataHandlerUtil;
037    import com.liferay.portal.kernel.lar.StagedModelType;
038    import com.liferay.portal.kernel.search.Indexable;
039    import com.liferay.portal.kernel.search.IndexableType;
040    import com.liferay.portal.kernel.util.OrderByComparator;
041    import com.liferay.portal.model.PersistedModel;
042    import com.liferay.portal.service.BaseLocalServiceImpl;
043    import com.liferay.portal.service.PersistedModelLocalServiceRegistry;
044    import com.liferay.portal.service.persistence.UserFinder;
045    import com.liferay.portal.service.persistence.UserPersistence;
046    import com.liferay.portal.util.PortalUtil;
047    
048    import com.liferay.portlet.dynamicdatamapping.model.DDMContent;
049    import com.liferay.portlet.dynamicdatamapping.service.DDMContentLocalService;
050    import com.liferay.portlet.dynamicdatamapping.service.persistence.DDMContentPersistence;
051    
052    import java.io.Serializable;
053    
054    import java.util.List;
055    
056    import javax.sql.DataSource;
057    
058    /**
059     * Provides the base implementation for the d d m content local service.
060     *
061     * <p>
062     * 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.DDMContentLocalServiceImpl}.
063     * </p>
064     *
065     * @author Brian Wing Shun Chan
066     * @see com.liferay.portlet.dynamicdatamapping.service.impl.DDMContentLocalServiceImpl
067     * @see com.liferay.portlet.dynamicdatamapping.service.DDMContentLocalServiceUtil
068     * @generated
069     */
070    @ProviderType
071    public abstract class DDMContentLocalServiceBaseImpl
072            extends BaseLocalServiceImpl implements DDMContentLocalService,
073                    IdentifiableBean {
074            /*
075             * NOTE FOR DEVELOPERS:
076             *
077             * Never modify or reference this class directly. Always use {@link com.liferay.portlet.dynamicdatamapping.service.DDMContentLocalServiceUtil} to access the d d m content local service.
078             */
079    
080            /**
081             * Adds the d d m content to the database. Also notifies the appropriate model listeners.
082             *
083             * @param ddmContent the d d m content
084             * @return the d d m content that was added
085             */
086            @Indexable(type = IndexableType.REINDEX)
087            @Override
088            public DDMContent addDDMContent(DDMContent ddmContent) {
089                    ddmContent.setNew(true);
090    
091                    return ddmContentPersistence.update(ddmContent);
092            }
093    
094            /**
095             * Creates a new d d m content with the primary key. Does not add the d d m content to the database.
096             *
097             * @param contentId the primary key for the new d d m content
098             * @return the new d d m content
099             */
100            @Override
101            public DDMContent createDDMContent(long contentId) {
102                    return ddmContentPersistence.create(contentId);
103            }
104    
105            /**
106             * Deletes the d d m content with the primary key from the database. Also notifies the appropriate model listeners.
107             *
108             * @param contentId the primary key of the d d m content
109             * @return the d d m content that was removed
110             * @throws PortalException if a d d m content with the primary key could not be found
111             */
112            @Indexable(type = IndexableType.DELETE)
113            @Override
114            public DDMContent deleteDDMContent(long contentId)
115                    throws PortalException {
116                    return ddmContentPersistence.remove(contentId);
117            }
118    
119            /**
120             * Deletes the d d m content from the database. Also notifies the appropriate model listeners.
121             *
122             * @param ddmContent the d d m content
123             * @return the d d m content that was removed
124             */
125            @Indexable(type = IndexableType.DELETE)
126            @Override
127            public DDMContent deleteDDMContent(DDMContent ddmContent) {
128                    return ddmContentPersistence.remove(ddmContent);
129            }
130    
131            @Override
132            public DynamicQuery dynamicQuery() {
133                    Class<?> clazz = getClass();
134    
135                    return DynamicQueryFactoryUtil.forClass(DDMContent.class,
136                            clazz.getClassLoader());
137            }
138    
139            /**
140             * Performs a dynamic query on the database and returns the matching rows.
141             *
142             * @param dynamicQuery the dynamic query
143             * @return the matching rows
144             */
145            @Override
146            public <T> List<T> dynamicQuery(DynamicQuery dynamicQuery) {
147                    return ddmContentPersistence.findWithDynamicQuery(dynamicQuery);
148            }
149    
150            /**
151             * Performs a dynamic query on the database and returns a range of the matching rows.
152             *
153             * <p>
154             * 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.DDMContentModelImpl}. 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.
155             * </p>
156             *
157             * @param dynamicQuery the dynamic query
158             * @param start the lower bound of the range of model instances
159             * @param end the upper bound of the range of model instances (not inclusive)
160             * @return the range of matching rows
161             */
162            @Override
163            public <T> List<T> dynamicQuery(DynamicQuery dynamicQuery, int start,
164                    int end) {
165                    return ddmContentPersistence.findWithDynamicQuery(dynamicQuery, start,
166                            end);
167            }
168    
169            /**
170             * Performs a dynamic query on the database and returns an ordered range of the matching rows.
171             *
172             * <p>
173             * 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.DDMContentModelImpl}. 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.
174             * </p>
175             *
176             * @param dynamicQuery the dynamic query
177             * @param start the lower bound of the range of model instances
178             * @param end the upper bound of the range of model instances (not inclusive)
179             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
180             * @return the ordered range of matching rows
181             */
182            @Override
183            public <T> List<T> dynamicQuery(DynamicQuery dynamicQuery, int start,
184                    int end, OrderByComparator<T> orderByComparator) {
185                    return ddmContentPersistence.findWithDynamicQuery(dynamicQuery, start,
186                            end, orderByComparator);
187            }
188    
189            /**
190             * Returns the number of rows that match the dynamic query.
191             *
192             * @param dynamicQuery the dynamic query
193             * @return the number of rows that match the dynamic query
194             */
195            @Override
196            public long dynamicQueryCount(DynamicQuery dynamicQuery) {
197                    return ddmContentPersistence.countWithDynamicQuery(dynamicQuery);
198            }
199    
200            /**
201             * Returns the number of rows that match the dynamic query.
202             *
203             * @param dynamicQuery the dynamic query
204             * @param projection the projection to apply to the query
205             * @return the number of rows that match the dynamic query
206             */
207            @Override
208            public long dynamicQueryCount(DynamicQuery dynamicQuery,
209                    Projection projection) {
210                    return ddmContentPersistence.countWithDynamicQuery(dynamicQuery,
211                            projection);
212            }
213    
214            @Override
215            public DDMContent fetchDDMContent(long contentId) {
216                    return ddmContentPersistence.fetchByPrimaryKey(contentId);
217            }
218    
219            /**
220             * Returns the d d m content matching the UUID and group.
221             *
222             * @param uuid the d d m content's UUID
223             * @param groupId the primary key of the group
224             * @return the matching d d m content, or <code>null</code> if a matching d d m content could not be found
225             */
226            @Override
227            public DDMContent fetchDDMContentByUuidAndGroupId(String uuid, long groupId) {
228                    return ddmContentPersistence.fetchByUUID_G(uuid, groupId);
229            }
230    
231            /**
232             * Returns the d d m content with the primary key.
233             *
234             * @param contentId the primary key of the d d m content
235             * @return the d d m content
236             * @throws PortalException if a d d m content with the primary key could not be found
237             */
238            @Override
239            public DDMContent getDDMContent(long contentId) throws PortalException {
240                    return ddmContentPersistence.findByPrimaryKey(contentId);
241            }
242    
243            @Override
244            public ActionableDynamicQuery getActionableDynamicQuery() {
245                    ActionableDynamicQuery actionableDynamicQuery = new DefaultActionableDynamicQuery();
246    
247                    actionableDynamicQuery.setBaseLocalService(com.liferay.portlet.dynamicdatamapping.service.DDMContentLocalServiceUtil.getService());
248                    actionableDynamicQuery.setClass(DDMContent.class);
249                    actionableDynamicQuery.setClassLoader(getClassLoader());
250    
251                    actionableDynamicQuery.setPrimaryKeyPropertyName("contentId");
252    
253                    return actionableDynamicQuery;
254            }
255    
256            protected void initActionableDynamicQuery(
257                    ActionableDynamicQuery actionableDynamicQuery) {
258                    actionableDynamicQuery.setBaseLocalService(com.liferay.portlet.dynamicdatamapping.service.DDMContentLocalServiceUtil.getService());
259                    actionableDynamicQuery.setClass(DDMContent.class);
260                    actionableDynamicQuery.setClassLoader(getClassLoader());
261    
262                    actionableDynamicQuery.setPrimaryKeyPropertyName("contentId");
263            }
264    
265            @Override
266            public ExportActionableDynamicQuery getExportActionableDynamicQuery(
267                    final PortletDataContext portletDataContext) {
268                    final ExportActionableDynamicQuery exportActionableDynamicQuery = new ExportActionableDynamicQuery() {
269                                    @Override
270                                    public long performCount() throws PortalException {
271                                            ManifestSummary manifestSummary = portletDataContext.getManifestSummary();
272    
273                                            StagedModelType stagedModelType = getStagedModelType();
274    
275                                            long modelAdditionCount = super.performCount();
276    
277                                            manifestSummary.addModelAdditionCount(stagedModelType.toString(),
278                                                    modelAdditionCount);
279    
280                                            long modelDeletionCount = ExportImportHelperUtil.getModelDeletionCount(portletDataContext,
281                                                            stagedModelType);
282    
283                                            manifestSummary.addModelDeletionCount(stagedModelType.toString(),
284                                                    modelDeletionCount);
285    
286                                            return modelAdditionCount;
287                                    }
288                            };
289    
290                    initActionableDynamicQuery(exportActionableDynamicQuery);
291    
292                    exportActionableDynamicQuery.setAddCriteriaMethod(new ActionableDynamicQuery.AddCriteriaMethod() {
293                                    @Override
294                                    public void addCriteria(DynamicQuery dynamicQuery) {
295                                            portletDataContext.addDateRangeCriteria(dynamicQuery,
296                                                    "modifiedDate");
297                                    }
298                            });
299    
300                    exportActionableDynamicQuery.setCompanyId(portletDataContext.getCompanyId());
301    
302                    exportActionableDynamicQuery.setGroupId(portletDataContext.getScopeGroupId());
303    
304                    exportActionableDynamicQuery.setPerformActionMethod(new ActionableDynamicQuery.PerformActionMethod() {
305                                    @Override
306                                    public void performAction(Object object)
307                                            throws PortalException {
308                                            DDMContent stagedModel = (DDMContent)object;
309    
310                                            StagedModelDataHandlerUtil.exportStagedModel(portletDataContext,
311                                                    stagedModel);
312                                    }
313                            });
314                    exportActionableDynamicQuery.setStagedModelType(new StagedModelType(
315                                    PortalUtil.getClassNameId(DDMContent.class.getName())));
316    
317                    return exportActionableDynamicQuery;
318            }
319    
320            /**
321             * @throws PortalException
322             */
323            @Override
324            public PersistedModel deletePersistedModel(PersistedModel persistedModel)
325                    throws PortalException {
326                    return ddmContentLocalService.deleteDDMContent((DDMContent)persistedModel);
327            }
328    
329            @Override
330            public PersistedModel getPersistedModel(Serializable primaryKeyObj)
331                    throws PortalException {
332                    return ddmContentPersistence.findByPrimaryKey(primaryKeyObj);
333            }
334    
335            @Override
336            public List<DDMContent> getDDMContentsByUuidAndCompanyId(String uuid,
337                    long companyId) {
338                    return ddmContentPersistence.findByUuid_C(uuid, companyId);
339            }
340    
341            @Override
342            public List<DDMContent> getDDMContentsByUuidAndCompanyId(String uuid,
343                    long companyId, int start, int end,
344                    OrderByComparator<DDMContent> orderByComparator) {
345                    return ddmContentPersistence.findByUuid_C(uuid, companyId, start, end,
346                            orderByComparator);
347            }
348    
349            /**
350             * Returns the d d m content matching the UUID and group.
351             *
352             * @param uuid the d d m content's UUID
353             * @param groupId the primary key of the group
354             * @return the matching d d m content
355             * @throws PortalException if a matching d d m content could not be found
356             */
357            @Override
358            public DDMContent getDDMContentByUuidAndGroupId(String uuid, long groupId)
359                    throws PortalException {
360                    return ddmContentPersistence.findByUUID_G(uuid, groupId);
361            }
362    
363            /**
364             * Returns a range of all the d d m contents.
365             *
366             * <p>
367             * 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.DDMContentModelImpl}. 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.
368             * </p>
369             *
370             * @param start the lower bound of the range of d d m contents
371             * @param end the upper bound of the range of d d m contents (not inclusive)
372             * @return the range of d d m contents
373             */
374            @Override
375            public List<DDMContent> getDDMContents(int start, int end) {
376                    return ddmContentPersistence.findAll(start, end);
377            }
378    
379            /**
380             * Returns the number of d d m contents.
381             *
382             * @return the number of d d m contents
383             */
384            @Override
385            public int getDDMContentsCount() {
386                    return ddmContentPersistence.countAll();
387            }
388    
389            /**
390             * Updates the d d m content in the database or adds it if it does not yet exist. Also notifies the appropriate model listeners.
391             *
392             * @param ddmContent the d d m content
393             * @return the d d m content that was updated
394             */
395            @Indexable(type = IndexableType.REINDEX)
396            @Override
397            public DDMContent updateDDMContent(DDMContent ddmContent) {
398                    return ddmContentPersistence.update(ddmContent);
399            }
400    
401            /**
402             * Returns the d d m content local service.
403             *
404             * @return the d d m content local service
405             */
406            public com.liferay.portlet.dynamicdatamapping.service.DDMContentLocalService getDDMContentLocalService() {
407                    return ddmContentLocalService;
408            }
409    
410            /**
411             * Sets the d d m content local service.
412             *
413             * @param ddmContentLocalService the d d m content local service
414             */
415            public void setDDMContentLocalService(
416                    com.liferay.portlet.dynamicdatamapping.service.DDMContentLocalService ddmContentLocalService) {
417                    this.ddmContentLocalService = ddmContentLocalService;
418            }
419    
420            /**
421             * Returns the d d m content persistence.
422             *
423             * @return the d d m content persistence
424             */
425            public DDMContentPersistence getDDMContentPersistence() {
426                    return ddmContentPersistence;
427            }
428    
429            /**
430             * Sets the d d m content persistence.
431             *
432             * @param ddmContentPersistence the d d m content persistence
433             */
434            public void setDDMContentPersistence(
435                    DDMContentPersistence ddmContentPersistence) {
436                    this.ddmContentPersistence = ddmContentPersistence;
437            }
438    
439            /**
440             * Returns the counter local service.
441             *
442             * @return the counter local service
443             */
444            public com.liferay.counter.service.CounterLocalService getCounterLocalService() {
445                    return counterLocalService;
446            }
447    
448            /**
449             * Sets the counter local service.
450             *
451             * @param counterLocalService the counter local service
452             */
453            public void setCounterLocalService(
454                    com.liferay.counter.service.CounterLocalService counterLocalService) {
455                    this.counterLocalService = counterLocalService;
456            }
457    
458            /**
459             * Returns the user local service.
460             *
461             * @return the user local service
462             */
463            public com.liferay.portal.service.UserLocalService getUserLocalService() {
464                    return userLocalService;
465            }
466    
467            /**
468             * Sets the user local service.
469             *
470             * @param userLocalService the user local service
471             */
472            public void setUserLocalService(
473                    com.liferay.portal.service.UserLocalService userLocalService) {
474                    this.userLocalService = userLocalService;
475            }
476    
477            /**
478             * Returns the user remote service.
479             *
480             * @return the user remote service
481             */
482            public com.liferay.portal.service.UserService getUserService() {
483                    return userService;
484            }
485    
486            /**
487             * Sets the user remote service.
488             *
489             * @param userService the user remote service
490             */
491            public void setUserService(
492                    com.liferay.portal.service.UserService userService) {
493                    this.userService = userService;
494            }
495    
496            /**
497             * Returns the user persistence.
498             *
499             * @return the user persistence
500             */
501            public UserPersistence getUserPersistence() {
502                    return userPersistence;
503            }
504    
505            /**
506             * Sets the user persistence.
507             *
508             * @param userPersistence the user persistence
509             */
510            public void setUserPersistence(UserPersistence userPersistence) {
511                    this.userPersistence = userPersistence;
512            }
513    
514            /**
515             * Returns the user finder.
516             *
517             * @return the user finder
518             */
519            public UserFinder getUserFinder() {
520                    return userFinder;
521            }
522    
523            /**
524             * Sets the user finder.
525             *
526             * @param userFinder the user finder
527             */
528            public void setUserFinder(UserFinder userFinder) {
529                    this.userFinder = userFinder;
530            }
531    
532            public void afterPropertiesSet() {
533                    persistedModelLocalServiceRegistry.register("com.liferay.portlet.dynamicdatamapping.model.DDMContent",
534                            ddmContentLocalService);
535            }
536    
537            public void destroy() {
538                    persistedModelLocalServiceRegistry.unregister(
539                            "com.liferay.portlet.dynamicdatamapping.model.DDMContent");
540            }
541    
542            /**
543             * Returns the Spring bean ID for this bean.
544             *
545             * @return the Spring bean ID for this bean
546             */
547            @Override
548            public String getBeanIdentifier() {
549                    return _beanIdentifier;
550            }
551    
552            /**
553             * Sets the Spring bean ID for this bean.
554             *
555             * @param beanIdentifier the Spring bean ID for this bean
556             */
557            @Override
558            public void setBeanIdentifier(String beanIdentifier) {
559                    _beanIdentifier = beanIdentifier;
560            }
561    
562            protected Class<?> getModelClass() {
563                    return DDMContent.class;
564            }
565    
566            protected String getModelClassName() {
567                    return DDMContent.class.getName();
568            }
569    
570            /**
571             * Performs a SQL query.
572             *
573             * @param sql the sql query
574             */
575            protected void runSQL(String sql) {
576                    try {
577                            DataSource dataSource = ddmContentPersistence.getDataSource();
578    
579                            DB db = DBFactoryUtil.getDB();
580    
581                            sql = db.buildSQL(sql);
582                            sql = PortalUtil.transformSQL(sql);
583    
584                            SqlUpdate sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(dataSource,
585                                            sql, new int[0]);
586    
587                            sqlUpdate.update();
588                    }
589                    catch (Exception e) {
590                            throw new SystemException(e);
591                    }
592            }
593    
594            @BeanReference(type = com.liferay.portlet.dynamicdatamapping.service.DDMContentLocalService.class)
595            protected com.liferay.portlet.dynamicdatamapping.service.DDMContentLocalService ddmContentLocalService;
596            @BeanReference(type = DDMContentPersistence.class)
597            protected DDMContentPersistence ddmContentPersistence;
598            @BeanReference(type = com.liferay.counter.service.CounterLocalService.class)
599            protected com.liferay.counter.service.CounterLocalService counterLocalService;
600            @BeanReference(type = com.liferay.portal.service.UserLocalService.class)
601            protected com.liferay.portal.service.UserLocalService userLocalService;
602            @BeanReference(type = com.liferay.portal.service.UserService.class)
603            protected com.liferay.portal.service.UserService userService;
604            @BeanReference(type = UserPersistence.class)
605            protected UserPersistence userPersistence;
606            @BeanReference(type = UserFinder.class)
607            protected UserFinder userFinder;
608            @BeanReference(type = PersistedModelLocalServiceRegistry.class)
609            protected PersistedModelLocalServiceRegistry persistedModelLocalServiceRegistry;
610            private String _beanIdentifier;
611    }