001    /**
002     * Copyright (c) 2000-present 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.announcements.kernel.service.persistence;
016    
017    import aQute.bnd.annotation.ProviderType;
018    
019    import com.liferay.announcements.kernel.model.AnnouncementsEntry;
020    
021    import com.liferay.portal.kernel.dao.orm.DynamicQuery;
022    import com.liferay.portal.kernel.dao.orm.Property;
023    import com.liferay.portal.kernel.dao.orm.PropertyFactoryUtil;
024    import com.liferay.portal.kernel.exception.PortalException;
025    import com.liferay.portal.util.PortalUtil;
026    
027    import com.liferay.portlet.exportimport.lar.ExportImportHelperUtil;
028    import com.liferay.portlet.exportimport.lar.ManifestSummary;
029    import com.liferay.portlet.exportimport.lar.PortletDataContext;
030    import com.liferay.portlet.exportimport.lar.StagedModelDataHandlerUtil;
031    import com.liferay.portlet.exportimport.lar.StagedModelType;
032    
033    /**
034     * @author Brian Wing Shun Chan
035     * @deprecated As of 7.0.0, replaced by {@link com.liferay.announcements.kernel.service.AnnouncementsEntryLocalServiceUtil#getExportActionableDynamicQuery(PortletDataContext)}
036     * @generated
037     */
038    @Deprecated
039    @ProviderType
040    public class AnnouncementsEntryExportActionableDynamicQuery
041            extends AnnouncementsEntryActionableDynamicQuery {
042            public AnnouncementsEntryExportActionableDynamicQuery(
043                    PortletDataContext portletDataContext) {
044                    _portletDataContext = portletDataContext;
045    
046                    setCompanyId(_portletDataContext.getCompanyId());
047            }
048    
049            @Override
050            public long performCount() throws PortalException {
051                    ManifestSummary manifestSummary = _portletDataContext.getManifestSummary();
052    
053                    StagedModelType stagedModelType = getStagedModelType();
054    
055                    long modelAdditionCount = super.performCount();
056    
057                    manifestSummary.addModelAdditionCount(stagedModelType.toString(),
058                            modelAdditionCount);
059    
060                    long modelDeletionCount = ExportImportHelperUtil.getModelDeletionCount(_portletDataContext,
061                                    stagedModelType);
062    
063                    manifestSummary.addModelDeletionCount(stagedModelType.toString(),
064                            modelDeletionCount);
065    
066                    return modelAdditionCount;
067            }
068    
069            @Override
070            protected void addCriteria(DynamicQuery dynamicQuery) {
071                    _portletDataContext.addDateRangeCriteria(dynamicQuery, "modifiedDate");
072    
073                    if (getStagedModelType().getReferrerClassNameId() >= 0) {
074                            Property classNameIdProperty = PropertyFactoryUtil.forName(
075                                            "classNameId");
076    
077                            dynamicQuery.add(classNameIdProperty.eq(getStagedModelType()
078                                                                                                                    .getReferrerClassNameId()));
079                    }
080            }
081    
082            protected StagedModelType getStagedModelType() {
083                    return new StagedModelType(PortalUtil.getClassNameId(
084                                    AnnouncementsEntry.class.getName()));
085            }
086    
087            @Override
088            protected void performAction(Object object) throws PortalException {
089                    AnnouncementsEntry stagedModel = (AnnouncementsEntry)object;
090    
091                    StagedModelDataHandlerUtil.exportStagedModel(_portletDataContext,
092                            stagedModel);
093            }
094    
095            private PortletDataContext _portletDataContext;
096    }