001    /**
002     * Copyright (c) 2000-2013 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.documentlibrary.service.persistence;
016    
017    import com.liferay.portal.kernel.dao.orm.DynamicQuery;
018    import com.liferay.portal.kernel.dao.orm.Property;
019    import com.liferay.portal.kernel.dao.orm.PropertyFactoryUtil;
020    import com.liferay.portal.kernel.exception.PortalException;
021    import com.liferay.portal.kernel.exception.SystemException;
022    import com.liferay.portal.kernel.lar.ExportImportHelperUtil;
023    import com.liferay.portal.kernel.lar.ManifestSummary;
024    import com.liferay.portal.kernel.lar.PortletDataContext;
025    import com.liferay.portal.kernel.lar.StagedModelDataHandler;
026    import com.liferay.portal.kernel.lar.StagedModelDataHandlerRegistryUtil;
027    import com.liferay.portal.kernel.lar.StagedModelDataHandlerUtil;
028    import com.liferay.portal.kernel.lar.StagedModelType;
029    import com.liferay.portal.util.PortalUtil;
030    
031    import com.liferay.portlet.documentlibrary.model.DLFileVersion;
032    
033    /**
034     * @author Brian Wing Shun Chan
035     * @generated
036     */
037    public class DLFileVersionExportActionableDynamicQuery
038            extends DLFileVersionActionableDynamicQuery {
039            public DLFileVersionExportActionableDynamicQuery(
040                    PortletDataContext portletDataContext) throws SystemException {
041                    _portletDataContext = portletDataContext;
042    
043                    setCompanyId(_portletDataContext.getCompanyId());
044    
045                    setGroupId(_portletDataContext.getScopeGroupId());
046            }
047    
048            @Override
049            public long performCount() throws PortalException, SystemException {
050                    ManifestSummary manifestSummary = _portletDataContext.getManifestSummary();
051    
052                    StagedModelType stagedModelType = getStagedModelType();
053    
054                    long modelAdditionCount = super.performCount();
055    
056                    manifestSummary.addModelAdditionCount(stagedModelType.toString(),
057                            modelAdditionCount);
058    
059                    long modelDeletionCount = ExportImportHelperUtil.getModelDeletionCount(_portletDataContext,
060                                    stagedModelType);
061    
062                    manifestSummary.addModelDeletionCount(stagedModelType.toString(),
063                            modelDeletionCount);
064    
065                    return modelAdditionCount;
066            }
067    
068            @Override
069            protected void addCriteria(DynamicQuery dynamicQuery) {
070                    _portletDataContext.addDateRangeCriteria(dynamicQuery, "modifiedDate");
071    
072                    StagedModelDataHandler<?> stagedModelDataHandler = StagedModelDataHandlerRegistryUtil.getStagedModelDataHandler(DLFileVersion.class.getName());
073    
074                    Property workflowStatusProperty = PropertyFactoryUtil.forName("status");
075    
076                    dynamicQuery.add(workflowStatusProperty.in(
077                                    stagedModelDataHandler.getExportableStatuses()));
078            }
079    
080            protected StagedModelType getStagedModelType() {
081                    return new StagedModelType(PortalUtil.getClassNameId(
082                                    DLFileVersion.class.getName()));
083            }
084    
085            @Override
086            @SuppressWarnings("unused")
087            protected void performAction(Object object)
088                    throws PortalException, SystemException {
089                    DLFileVersion stagedModel = (DLFileVersion)object;
090    
091                    StagedModelDataHandlerUtil.exportStagedModel(_portletDataContext,
092                            stagedModel);
093            }
094    
095            private PortletDataContext _portletDataContext;
096    }