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.blogs.service.persistence;
016    
017    import com.liferay.portal.kernel.dao.orm.Criterion;
018    import com.liferay.portal.kernel.dao.orm.Disjunction;
019    import com.liferay.portal.kernel.dao.orm.DynamicQuery;
020    import com.liferay.portal.kernel.dao.orm.Property;
021    import com.liferay.portal.kernel.dao.orm.PropertyFactoryUtil;
022    import com.liferay.portal.kernel.dao.orm.RestrictionsFactoryUtil;
023    import com.liferay.portal.kernel.exception.PortalException;
024    import com.liferay.portal.kernel.exception.SystemException;
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.blogs.model.BlogsEntry;
035    
036    /**
037     * @author Brian Wing Shun Chan
038     * @generated
039     */
040    public class BlogsEntryExportActionableDynamicQuery
041            extends BlogsEntryActionableDynamicQuery {
042            public BlogsEntryExportActionableDynamicQuery(
043                    PortletDataContext portletDataContext) throws SystemException {
044                    _portletDataContext = portletDataContext;
045    
046                    setCompanyId(_portletDataContext.getCompanyId());
047    
048                    setGroupId(_portletDataContext.getScopeGroupId());
049            }
050    
051            @Override
052            public long performCount() throws PortalException, SystemException {
053                    ManifestSummary manifestSummary = _portletDataContext.getManifestSummary();
054    
055                    StagedModelType stagedModelType = getStagedModelType();
056    
057                    long modelAdditionCount = super.performCount();
058    
059                    manifestSummary.addModelAdditionCount(stagedModelType.toString(),
060                            modelAdditionCount);
061    
062                    long modelDeletionCount = ExportImportHelperUtil.getModelDeletionCount(_portletDataContext,
063                                    stagedModelType);
064    
065                    manifestSummary.addModelDeletionCount(stagedModelType.toString(),
066                            modelDeletionCount);
067    
068                    return modelAdditionCount;
069            }
070    
071            @Override
072            protected void addCriteria(DynamicQuery dynamicQuery) {
073                    Criterion modifiedDateCriterion = _portletDataContext.getDateRangeCriteria(
074                                    "modifiedDate");
075                    Criterion statusDateCriterion = _portletDataContext.getDateRangeCriteria(
076                                    "statusDate");
077    
078                    if ((modifiedDateCriterion != null) && (statusDateCriterion != null)) {
079                            Disjunction disjunction = RestrictionsFactoryUtil.disjunction();
080    
081                            disjunction.add(modifiedDateCriterion);
082                            disjunction.add(statusDateCriterion);
083    
084                            dynamicQuery.add(disjunction);
085                    }
086    
087                    StagedModelDataHandler<?> stagedModelDataHandler = StagedModelDataHandlerRegistryUtil.getStagedModelDataHandler(BlogsEntry.class.getName());
088    
089                    Property workflowStatusProperty = PropertyFactoryUtil.forName("status");
090    
091                    dynamicQuery.add(workflowStatusProperty.in(
092                                    stagedModelDataHandler.getExportableStatuses()));
093            }
094    
095            protected StagedModelType getStagedModelType() {
096                    return new StagedModelType(PortalUtil.getClassNameId(
097                                    BlogsEntry.class.getName()));
098            }
099    
100            @Override
101            @SuppressWarnings("unused")
102            protected void performAction(Object object)
103                    throws PortalException, SystemException {
104                    BlogsEntry stagedModel = (BlogsEntry)object;
105    
106                    StagedModelDataHandlerUtil.exportStagedModel(_portletDataContext,
107                            stagedModel);
108            }
109    
110            private PortletDataContext _portletDataContext;
111    }