RM-1099 (Refactor Transfer and Accession reports)

* Fixed failing tests

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/HEAD@58401 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Tuna Aksoy
2013-11-28 17:46:16 +00:00
parent 4b89aa32e3
commit 05aefebbdf
4 changed files with 123 additions and 124 deletions

View File

@@ -160,9 +160,9 @@ retain.description=Retain
# Add Record Types # Add Record Types
addRecordTypes.title=Add record types addRecordTypes.title=Add record types
addRecordTypes.description=Adds the selected type(s) to the record addRecordTypes.description=Adds the selected type(s) to the record
# File Transfer Report # File Report
fileTransferReport.title=File transfer report fileReport.title=File transfer report
fileTransferReport.description=File transfer report fileReport.description=File transfer report
# Action parameter constraints # Action parameter constraints

View File

@@ -87,7 +87,6 @@
<property name="reportTypeName" value="rmr:destructionReport" /> <property name="reportTypeName" value="rmr:destructionReport" />
</bean> </bean>
<!-- FIXME -->
<bean id="transferReportGenerator" parent="declarativeReportGenerator"> <bean id="transferReportGenerator" parent="declarativeReportGenerator">
<property name="reportTypeName" value="rmr:transferReport" /> <property name="reportTypeName" value="rmr:transferReport" />
</bean> </bean>
@@ -116,7 +115,7 @@
</bean> </bean>
<bean id="fileDestructionReport" <bean id="fileDestructionReport"
class="org.alfresco.module.org_alfresco_module_rm.report.action.FileReportAction" class="org.alfresco.module.org_alfresco_module_rm.report.action.FileDestructionReportAction"
parent="rmAction"> parent="rmAction">
<property name="reportService" ref="ReportService" /> <property name="reportService" ref="ReportService" />
<property name="filePlanService" ref="FilePlanService" /> <property name="filePlanService" ref="FilePlanService" />
@@ -147,7 +146,7 @@
</bean> </bean>
<bean id="fileReport" <bean id="fileReport"
class="org.alfresco.module.org_alfresco_module_rm.report.action.FileTransferAction" class="org.alfresco.module.org_alfresco_module_rm.report.action.FileReportAction"
parent="rmAction"> parent="rmAction">
<property name="reportService" ref="ReportService" /> <property name="reportService" ref="ReportService" />
</bean> </bean>

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2005-2013 Alfresco Software Limited. * Copyright (C) 2005-2011 Alfresco Software Limited.
* *
* This file is part of Alfresco * This file is part of Alfresco
* *
@@ -20,33 +20,33 @@ package org.alfresco.module.org_alfresco_module_rm.report.action;
import org.alfresco.error.AlfrescoRuntimeException; import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.module.org_alfresco_module_rm.action.RMActionExecuterAbstractBase; import org.alfresco.module.org_alfresco_module_rm.action.RMActionExecuterAbstractBase;
import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService;
import org.alfresco.module.org_alfresco_module_rm.report.Report; import org.alfresco.module.org_alfresco_module_rm.report.Report;
import org.alfresco.module.org_alfresco_module_rm.report.ReportModel; import org.alfresco.module.org_alfresco_module_rm.report.ReportModel;
import org.alfresco.module.org_alfresco_module_rm.report.ReportService; import org.alfresco.module.org_alfresco_module_rm.report.ReportService;
import org.alfresco.service.cmr.action.Action; import org.alfresco.service.cmr.action.Action;
import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.namespace.QName; import org.alfresco.service.namespace.QName;
import org.apache.commons.lang.StringUtils; import org.alfresco.util.ParameterCheck;
import org.springframework.extensions.surf.util.I18NUtil;
/** /**
* File transfer action * File Report Action
* *
* @author Tuna Aksoy * @author Roy Wetherall
* @since 2.2 * @since 2.1
*/ */
public class FileTransferAction extends RMActionExecuterAbstractBase implements ReportModel public class FileDestructionReportAction extends RMActionExecuterAbstractBase
implements ReportModel
{ {
/** Constants for the parameters passed from UI */
private static final String REPORT_TYPE = "reportType";
private static final String DESTINATION = "destination";
/** I18N */
private static final String MSG_PARAM_NOT_SUPPLIED = "rm.action.parameter-not-supplied";
/** report service */ /** report service */
protected ReportService reportService; protected ReportService reportService;
/** file plan service */
protected FilePlanService filePlanService;
/** report type string value */
private String reportType;
/** /**
* @param reportService report service * @param reportService report service
*/ */
@@ -54,7 +54,32 @@ public class FileTransferAction extends RMActionExecuterAbstractBase implements
{ {
this.reportService = reportService; this.reportService = reportService;
} }
/**
* @param filePlanService file plan service
*/
public void setFilePlanService(FilePlanService filePlanService)
{
this.filePlanService = filePlanService;
}
/**
* @param reportType report type string value
*/
public void setReportType(String reportType)
{
this.reportType = reportType;
}
/**
* @return QName report type
*/
protected QName getReportType()
{
ParameterCheck.mandatory("this.reportType", reportType);
return QName.createQName(reportType, namespaceService);
}
/** /**
* @see org.alfresco.repo.action.executer.ActionExecuterAbstractBase#executeImpl(org.alfresco.service.cmr.action.Action, org.alfresco.service.cmr.repository.NodeRef) * @see org.alfresco.repo.action.executer.ActionExecuterAbstractBase#executeImpl(org.alfresco.service.cmr.action.Action, org.alfresco.service.cmr.repository.NodeRef)
*/ */
@@ -63,54 +88,17 @@ public class FileTransferAction extends RMActionExecuterAbstractBase implements
{ {
// TODO check that the actionedUponNodeRef is in a state to generate a destruction report // TODO check that the actionedUponNodeRef is in a state to generate a destruction report
// ie: is it eligable for destruction .. use fileDestructionReport capability! // ie: is it eligable for destruction .. use fileDestructionReport capability!
// TODO allow the mimetype of the report to be specified as a parameter // TODO allow the mimetype of the report to be specified as a parameter
QName reportType = getReportType(action); NodeRef filePlan = filePlanService.getFilePlan(actionedUponNodeRef);
Report report = reportService.generateReport(reportType, actionedUponNodeRef); if (filePlan == null)
NodeRef destination = getDestination(action);
reportService.fileReport(destination, report);
}
/**
* Retrieves the value of the given parameter. If the parameter has not been passed from the UI an error will be thrown
*
* @param action The action
* @param parameter The parameter for which the value should be retrieved
* @return The value of the given parameter
*/
private String getParameterValue(Action action, String parameter)
{
String paramValue = (String) action.getParameterValue(parameter);
if (StringUtils.isBlank(paramValue) == true)
{ {
throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_PARAM_NOT_SUPPLIED, parameter)); throw new AlfrescoRuntimeException("Unable to file destruction report, because file plan could not be resolved.");
} }
return paramValue;
} Report report = reportService.generateReport(getReportType(), actionedUponNodeRef);
reportService.fileReport(filePlan, report);
/**
* Helper method for getting the destination. }
* }
* @param action The action
* @return The file plan node reference
*/
private NodeRef getDestination(Action action)
{
String destination = getParameterValue(action, DESTINATION);
return new NodeRef(destination);
}
/**
* Helper method for getting the report type.
*
* @param action The action
* @return The report type
*/
private QName getReportType(Action action)
{
String reportType = getParameterValue(action, REPORT_TYPE);
return QName.createQName(reportType, namespaceService);
}
}

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2005-2011 Alfresco Software Limited. * Copyright (C) 2005-2013 Alfresco Software Limited.
* *
* This file is part of Alfresco * This file is part of Alfresco
* *
@@ -20,33 +20,33 @@ package org.alfresco.module.org_alfresco_module_rm.report.action;
import org.alfresco.error.AlfrescoRuntimeException; import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.module.org_alfresco_module_rm.action.RMActionExecuterAbstractBase; import org.alfresco.module.org_alfresco_module_rm.action.RMActionExecuterAbstractBase;
import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService;
import org.alfresco.module.org_alfresco_module_rm.report.Report; import org.alfresco.module.org_alfresco_module_rm.report.Report;
import org.alfresco.module.org_alfresco_module_rm.report.ReportModel; import org.alfresco.module.org_alfresco_module_rm.report.ReportModel;
import org.alfresco.module.org_alfresco_module_rm.report.ReportService; import org.alfresco.module.org_alfresco_module_rm.report.ReportService;
import org.alfresco.service.cmr.action.Action; import org.alfresco.service.cmr.action.Action;
import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.namespace.QName; import org.alfresco.service.namespace.QName;
import org.alfresco.util.ParameterCheck; import org.apache.commons.lang.StringUtils;
import org.springframework.extensions.surf.util.I18NUtil;
/** /**
* File Report Action * File report action
* *
* @author Roy Wetherall * @author Tuna Aksoy
* @since 2.1 * @since 2.2
*/ */
public class FileReportAction extends RMActionExecuterAbstractBase public class FileReportAction extends RMActionExecuterAbstractBase implements ReportModel
implements ReportModel
{ {
/** Constants for the parameters passed from UI */
private static final String REPORT_TYPE = "reportType";
private static final String DESTINATION = "destination";
/** I18N */
private static final String MSG_PARAM_NOT_SUPPLIED = "rm.action.parameter-not-supplied";
/** report service */ /** report service */
protected ReportService reportService; protected ReportService reportService;
/** file plan service */
protected FilePlanService filePlanService;
/** report type string value */
private String reportType;
/** /**
* @param reportService report service * @param reportService report service
*/ */
@@ -54,32 +54,7 @@ public class FileReportAction extends RMActionExecuterAbstractBase
{ {
this.reportService = reportService; this.reportService = reportService;
} }
/**
* @param filePlanService file plan service
*/
public void setFilePlanService(FilePlanService filePlanService)
{
this.filePlanService = filePlanService;
}
/**
* @param reportType report type string value
*/
public void setReportType(String reportType)
{
this.reportType = reportType;
}
/**
* @return QName report type
*/
protected QName getReportType()
{
ParameterCheck.mandatory("this.reportType", reportType);
return QName.createQName(reportType, namespaceService);
}
/** /**
* @see org.alfresco.repo.action.executer.ActionExecuterAbstractBase#executeImpl(org.alfresco.service.cmr.action.Action, org.alfresco.service.cmr.repository.NodeRef) * @see org.alfresco.repo.action.executer.ActionExecuterAbstractBase#executeImpl(org.alfresco.service.cmr.action.Action, org.alfresco.service.cmr.repository.NodeRef)
*/ */
@@ -88,17 +63,54 @@ public class FileReportAction extends RMActionExecuterAbstractBase
{ {
// TODO check that the actionedUponNodeRef is in a state to generate a destruction report // TODO check that the actionedUponNodeRef is in a state to generate a destruction report
// ie: is it eligable for destruction .. use fileDestructionReport capability! // ie: is it eligable for destruction .. use fileDestructionReport capability!
// TODO allow the mimetype of the report to be specified as a parameter // TODO allow the mimetype of the report to be specified as a parameter
NodeRef filePlan = filePlanService.getFilePlan(actionedUponNodeRef); QName reportType = getReportType(action);
if (filePlan == null) Report report = reportService.generateReport(reportType, actionedUponNodeRef);
NodeRef destination = getDestination(action);
reportService.fileReport(destination, report);
}
/**
* Retrieves the value of the given parameter. If the parameter has not been passed from the UI an error will be thrown
*
* @param action The action
* @param parameter The parameter for which the value should be retrieved
* @return The value of the given parameter
*/
private String getParameterValue(Action action, String parameter)
{
String paramValue = (String) action.getParameterValue(parameter);
if (StringUtils.isBlank(paramValue) == true)
{ {
throw new AlfrescoRuntimeException("Unable to file destruction report, because file plan could not be resolved."); throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_PARAM_NOT_SUPPLIED, parameter));
} }
return paramValue;
Report report = reportService.generateReport(getReportType(), actionedUponNodeRef); }
reportService.fileReport(filePlan, report);
/**
} * Helper method for getting the destination.
} *
* @param action The action
* @return The file plan node reference
*/
private NodeRef getDestination(Action action)
{
String destination = getParameterValue(action, DESTINATION);
return new NodeRef(destination);
}
/**
* Helper method for getting the report type.
*
* @param action The action
* @return The report type
*/
private QName getReportType(Action action)
{
String reportType = getParameterValue(action, REPORT_TYPE);
return QName.createQName(reportType, namespaceService);
}
}