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.persistence;
016    
017    import aQute.bnd.annotation.ProviderType;
018    
019    import com.liferay.portal.kernel.dao.orm.DynamicQuery;
020    import com.liferay.portal.kernel.dao.orm.Projection;
021    import com.liferay.portal.kernel.dao.orm.ProjectionFactoryUtil;
022    import com.liferay.portal.kernel.dao.orm.Property;
023    import com.liferay.portal.kernel.dao.orm.PropertyFactoryUtil;
024    import com.liferay.portal.kernel.exception.PortalException;
025    import com.liferay.portal.kernel.lar.ExportImportHelperUtil;
026    import com.liferay.portal.kernel.lar.ManifestSummary;
027    import com.liferay.portal.kernel.lar.PortletDataContext;
028    import com.liferay.portal.kernel.lar.StagedModelDataHandler;
029    import com.liferay.portal.kernel.lar.StagedModelDataHandlerRegistryUtil;
030    import com.liferay.portal.kernel.lar.StagedModelDataHandlerUtil;
031    import com.liferay.portal.kernel.lar.StagedModelType;
032    import com.liferay.portal.util.PortalUtil;
033    
034    import com.liferay.portlet.journal.model.JournalArticle;
035    
036    /**
037     * @author Brian Wing Shun Chan
038     * @deprecated As of 7.0.0, replaced by {@link com.liferay.portlet.journal.service.JournalArticleLocalServiceUtil#getExportActionableDynamicQuery()}
039     * @generated
040     */
041    @Deprecated
042    @ProviderType
043    public class JournalArticleExportActionableDynamicQuery
044            extends JournalArticleActionableDynamicQuery {
045            public JournalArticleExportActionableDynamicQuery(
046                    PortletDataContext portletDataContext) {
047                    _portletDataContext = portletDataContext;
048    
049                    setCompanyId(_portletDataContext.getCompanyId());
050    
051                    setGroupId(_portletDataContext.getScopeGroupId());
052            }
053    
054            @Override
055            public long performCount() throws PortalException {
056                    ManifestSummary manifestSummary = _portletDataContext.getManifestSummary();
057    
058                    StagedModelType stagedModelType = getStagedModelType();
059    
060                    long modelAdditionCount = super.performCount();
061    
062                    manifestSummary.addModelAdditionCount(stagedModelType.toString(),
063                            modelAdditionCount);
064    
065                    long modelDeletionCount = ExportImportHelperUtil.getModelDeletionCount(_portletDataContext,
066                                    stagedModelType);
067    
068                    manifestSummary.addModelDeletionCount(stagedModelType.toString(),
069                            modelDeletionCount);
070    
071                    return modelAdditionCount;
072            }
073    
074            @Override
075            protected void addCriteria(DynamicQuery dynamicQuery) {
076                    _portletDataContext.addDateRangeCriteria(dynamicQuery, "modifiedDate");
077    
078                    if (getStagedModelType().getReferrerClassNameId() >= 0) {
079                            Property classNameIdProperty = PropertyFactoryUtil.forName(
080                                            "classNameId");
081    
082                            dynamicQuery.add(classNameIdProperty.eq(getStagedModelType()
083                                                                                                                    .getReferrerClassNameId()));
084                    }
085    
086                    StagedModelDataHandler<?> stagedModelDataHandler = StagedModelDataHandlerRegistryUtil.getStagedModelDataHandler(JournalArticle.class.getName());
087    
088                    Property workflowStatusProperty = PropertyFactoryUtil.forName("status");
089    
090                    dynamicQuery.add(workflowStatusProperty.in(
091                                    stagedModelDataHandler.getExportableStatuses()));
092            }
093    
094            @Override
095            protected Projection getCountProjection() {
096                    return ProjectionFactoryUtil.countDistinct("resourcePrimKey");
097            }
098    
099            protected StagedModelType getStagedModelType() {
100                    return new StagedModelType(PortalUtil.getClassNameId(
101                                    JournalArticle.class.getName()));
102            }
103    
104            @Override
105            protected void performAction(Object object) throws PortalException {
106                    JournalArticle stagedModel = (JournalArticle)object;
107    
108                    StagedModelDataHandlerUtil.exportStagedModel(_portletDataContext,
109                            stagedModel);
110            }
111    
112            private PortletDataContext _portletDataContext;
113    }