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