001    /**
002     * Copyright (c) 2000-2013 Liferay, Inc. All rights reserved.
003     *
004     * The contents of this file are subject to the terms of the Liferay Enterprise
005     * Subscription License ("License"). You may not use this file except in
006     * compliance with the License. You can obtain a copy of the License by
007     * contacting Liferay, Inc. See the License for the specific language governing
008     * permissions and limitations under the License, including but not limited to
009     * distribution rights of the Software.
010     *
011     *
012     *
013     */
014    
015    package com.liferay.portal.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.StagedModelDataHandlerUtil;
026    import com.liferay.portal.kernel.lar.StagedModelType;
027    import com.liferay.portal.model.Role;
028    import com.liferay.portal.util.PortalUtil;
029    
030    /**
031     * @author Brian Wing Shun Chan
032     * @generated
033     */
034    public class RoleExportActionableDynamicQuery extends RoleActionableDynamicQuery {
035            public RoleExportActionableDynamicQuery(
036                    PortletDataContext portletDataContext) throws SystemException {
037                    _portletDataContext = portletDataContext;
038    
039                    setCompanyId(_portletDataContext.getCompanyId());
040            }
041    
042            @Override
043            public long performCount() throws PortalException, SystemException {
044                    ManifestSummary manifestSummary = _portletDataContext.getManifestSummary();
045    
046                    StagedModelType stagedModelType = getStagedModelType();
047    
048                    long modelAdditionCount = super.performCount();
049    
050                    manifestSummary.addModelAdditionCount(stagedModelType.toString(),
051                            modelAdditionCount);
052    
053                    long modelDeletionCount = ExportImportHelperUtil.getModelDeletionCount(_portletDataContext,
054                                    stagedModelType);
055    
056                    manifestSummary.addModelDeletionCount(stagedModelType.toString(),
057                            modelDeletionCount);
058    
059                    return modelAdditionCount;
060            }
061    
062            @Override
063            protected void addCriteria(DynamicQuery dynamicQuery) {
064                    _portletDataContext.addDateRangeCriteria(dynamicQuery, "modifiedDate");
065    
066                    if (getStagedModelType().getReferrerClassNameId() >= 0) {
067                            Property classNameIdProperty = PropertyFactoryUtil.forName(
068                                            "classNameId");
069    
070                            dynamicQuery.add(classNameIdProperty.eq(getStagedModelType()
071                                                                                                                    .getReferrerClassNameId()));
072                    }
073            }
074    
075            protected StagedModelType getStagedModelType() {
076                    return new StagedModelType(PortalUtil.getClassNameId(
077                                    Role.class.getName()));
078            }
079    
080            @Override
081            @SuppressWarnings("unused")
082            protected void performAction(Object object)
083                    throws PortalException, SystemException {
084                    Role stagedModel = (Role)object;
085    
086                    StagedModelDataHandlerUtil.exportStagedModel(_portletDataContext,
087                            stagedModel);
088            }
089    
090            private PortletDataContext _portletDataContext;
091    }