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.Repository;
028    import com.liferay.portal.util.PortalUtil;
029    
030    /**
031     * @author Brian Wing Shun Chan
032     * @generated
033     */
034    public class RepositoryExportActionableDynamicQuery
035            extends RepositoryActionableDynamicQuery {
036            public RepositoryExportActionableDynamicQuery(
037                    PortletDataContext portletDataContext) throws SystemException {
038                    _portletDataContext = portletDataContext;
039    
040                    setCompanyId(_portletDataContext.getCompanyId());
041    
042                    setGroupId(_portletDataContext.getScopeGroupId());
043            }
044    
045            @Override
046            public long performCount() throws PortalException, SystemException {
047                    ManifestSummary manifestSummary = _portletDataContext.getManifestSummary();
048    
049                    StagedModelType stagedModelType = getStagedModelType();
050    
051                    long modelAdditionCount = super.performCount();
052    
053                    manifestSummary.addModelAdditionCount(stagedModelType.toString(),
054                            modelAdditionCount);
055    
056                    long modelDeletionCount = ExportImportHelperUtil.getModelDeletionCount(_portletDataContext,
057                                    stagedModelType);
058    
059                    manifestSummary.addModelDeletionCount(stagedModelType.toString(),
060                            modelDeletionCount);
061    
062                    return modelAdditionCount;
063            }
064    
065            @Override
066            protected void addCriteria(DynamicQuery dynamicQuery) {
067                    _portletDataContext.addDateRangeCriteria(dynamicQuery, "modifiedDate");
068    
069                    if (getStagedModelType().getReferrerClassNameId() >= 0) {
070                            Property classNameIdProperty = PropertyFactoryUtil.forName(
071                                            "classNameId");
072    
073                            dynamicQuery.add(classNameIdProperty.eq(getStagedModelType()
074                                                                                                                    .getReferrerClassNameId()));
075                    }
076            }
077    
078            protected StagedModelType getStagedModelType() {
079                    return new StagedModelType(PortalUtil.getClassNameId(
080                                    Repository.class.getName()));
081            }
082    
083            @Override
084            @SuppressWarnings("unused")
085            protected void performAction(Object object)
086                    throws PortalException, SystemException {
087                    Repository stagedModel = (Repository)object;
088    
089                    StagedModelDataHandlerUtil.exportStagedModel(_portletDataContext,
090                            stagedModel);
091            }
092    
093            private PortletDataContext _portletDataContext;
094    }