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