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