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.wiki.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.wiki.model.WikiPage;
035    
036    /**
037     * @author Brian Wing Shun Chan
038     * @deprecated As of 7.0.0, replaced by {@link com.liferay.portlet.wiki.service.WikiPageLocalServiceUtil#getExportActionableDynamicQuery()}
039     * @generated
040     */
041    @Deprecated
042    @ProviderType
043    public class WikiPageExportActionableDynamicQuery
044            extends WikiPageActionableDynamicQuery {
045            public WikiPageExportActionableDynamicQuery(
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                    StagedModelDataHandler<?> stagedModelDataHandler = StagedModelDataHandlerRegistryUtil.getStagedModelDataHandler(WikiPage.class.getName());
079    
080                    Property workflowStatusProperty = PropertyFactoryUtil.forName("status");
081    
082                    dynamicQuery.add(workflowStatusProperty.in(
083                                    stagedModelDataHandler.getExportableStatuses()));
084            }
085    
086            @Override
087            protected Projection getCountProjection() {
088                    return ProjectionFactoryUtil.countDistinct("resourcePrimKey");
089            }
090    
091            protected StagedModelType getStagedModelType() {
092                    return new StagedModelType(PortalUtil.getClassNameId(
093                                    WikiPage.class.getName()));
094            }
095    
096            @Override
097            protected void performAction(Object object) throws PortalException {
098                    WikiPage stagedModel = (WikiPage)object;
099    
100                    StagedModelDataHandlerUtil.exportStagedModel(_portletDataContext,
101                            stagedModel);
102            }
103    
104            private PortletDataContext _portletDataContext;
105    }