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.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    }