RM-1099 (Refactor Transfer and Accession reports)

* The record type and the destination is now passed from the UI

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/HEAD@58392 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Tuna Aksoy
2013-11-28 15:14:22 +00:00
parent cfa932d0a0
commit 120d3340ea
7 changed files with 116 additions and 103 deletions

View File

@@ -35,3 +35,4 @@ rm.action.undo-not-last=The cut off can't be undone, because the last dispositio
rm.action.records_only_undeclared=Only records can be completed.
rm.action.event-not-undone=The event {0} can't be undone, because it's not defined on the disposition lifecycle.
rm.action.node-not-record-category=The disposition schedule could not be created, because the actioned upon node ({0}) was not a record category.
rm.action.parameter-not-supplied=The parameter ''{0}'' has not been supplied.

View File

@@ -149,8 +149,6 @@
class="org.alfresco.module.org_alfresco_module_rm.report.action.FileTransferAction"
parent="rmAction">
<property name="reportService" ref="ReportService" />
<property name="filePlanService" ref="FilePlanService" />
<property name="reportType" value="rmr:transferReport" />
</bean>
</beans>

View File

@@ -89,14 +89,15 @@ public interface RecordService
void createRecord(NodeRef filePlan, NodeRef nodeRef);
/**
* Creates a new document as a unfiled record.
* Creates a new document in the unfiled records container if the given node reference is a file plan
* node reference otherwise the node reference will be used as the destination for the new record.
*
* @param filePlan
* @param nodeRef
* @param name
* @param type
* @param properties
*/
NodeRef createRecord(NodeRef filePlan, String name, QName type, Map<QName, Serializable> properties, ContentReader reader);
NodeRef createRecord(NodeRef nodeRef, String name, QName type, Map<QName, Serializable> properties, ContentReader reader);
/**
* Indicates whether the record is filed or not

View File

@@ -772,11 +772,22 @@ public class RecordServiceImpl implements RecordService,
* @see org.alfresco.module.org_alfresco_module_rm.record.RecordService#createRecord(org.alfresco.service.cmr.repository.NodeRef, java.lang.String, org.alfresco.service.namespace.QName, java.util.Map, org.alfresco.service.cmr.repository.ContentReader)
*/
@Override
public NodeRef createRecord(NodeRef filePlan, String name, QName type, Map<QName, Serializable> properties, ContentReader reader)
public NodeRef createRecord(NodeRef nodeRef, String name, QName type, Map<QName, Serializable> properties, ContentReader reader)
{
ParameterCheck.mandatory("filePlan", filePlan);
ParameterCheck.mandatory("nodeRef", nodeRef);
ParameterCheck.mandatory("name", name);
NodeRef destination = nodeRef;
if (filePlanService.isFilePlan(nodeRef) == true)
{
// get the unfiled record container for the file plan
destination = filePlanService.getUnfiledContainer(nodeRef);
if (destination == null)
{
throw new AlfrescoRuntimeException("Unable to create record, because unfiled container could not be found.");
}
}
// if none set the default record type is cm:content
if (type == null)
{
@@ -784,15 +795,8 @@ public class RecordServiceImpl implements RecordService,
}
// TODO ensure that the type is a sub-type of cm:content
// get the unfiled record container for the file plan
NodeRef unfiledContainer = filePlanService.getUnfiledContainer(filePlan);
if (unfiledContainer == null)
{
throw new AlfrescoRuntimeException("Unable to create record, because unfiled container could not be found.");
}
// create the new record
NodeRef record = fileFolderService.create(unfiledContainer, name, type).getNodeRef();
NodeRef record = fileFolderService.create(destination, name, type).getNodeRef();
// set the properties
if (properties != null)

View File

@@ -63,11 +63,12 @@ public interface ReportService
Report generateReport(QName reportType, NodeRef reportedUponNodeRef, String mimetype);
/**
* File report as unfiled record in a file plan.
* File report in the given destination. If the given node reference is a file plan node
* reference the report will be filed in the unfiled records container.
*
* @param filePlan file plan
* @param nodeRef node reference
* @param report report
* @return NodeRef node reference of unfiled record
* @return NodeRef node reference of the filed report
*/
NodeRef fileReport(NodeRef filePlan, Report report);
NodeRef fileReport(NodeRef nodeRef, Report report);
}

View File

@@ -144,18 +144,12 @@ public class ReportServiceImpl extends ServiceBaseImpl
* @see org.alfresco.module.org_alfresco_module_rm.report.ReportService#fileReport(org.alfresco.module.org_alfresco_module_rm.report.Report)
*/
@Override
public NodeRef fileReport(NodeRef filePlan, Report report)
public NodeRef fileReport(NodeRef nodeRef, Report report)
{
ParameterCheck.mandatory("nodeRef", nodeRef);
ParameterCheck.mandatory("report", report);
ParameterCheck.mandatory("filePlan", filePlan);
// check that the passed node reference is a file plan
if (filePlanService.isFilePlan(filePlan) == false)
{
throw new AlfrescoRuntimeException("Unable to file report, because " + filePlan.toString() + " is not a file plan.");
}
return recordService.createRecord(filePlan,
return recordService.createRecord(nodeRef,
report.getReportName(),
report.getReportType(),
report.getReportProperties(),

View File

@@ -20,32 +20,33 @@ package org.alfresco.module.org_alfresco_module_rm.report.action;
import org.alfresco.error.AlfrescoRuntimeException;
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.ReportModel;
import org.alfresco.module.org_alfresco_module_rm.report.ReportService;
import org.alfresco.service.cmr.action.Action;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.namespace.QName;
import org.alfresco.util.ParameterCheck;
import org.apache.commons.lang.StringUtils;
import org.springframework.extensions.surf.util.I18NUtil;
/**
* FIXME!!!
* File transfer action
*
* @author Tuna Aksoy
* @since 2.2
*/
public class FileTransferAction 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 */
protected ReportService reportService;
/** file plan service */
protected FilePlanService filePlanService;
/** report type string value */
private String reportType;
/**
* @param reportService report service
*/
@@ -54,31 +55,6 @@ public class FileTransferAction extends RMActionExecuterAbstractBase implements
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)
*/
@@ -90,13 +66,51 @@ public class FileTransferAction extends RMActionExecuterAbstractBase implements
// TODO allow the mimetype of the report to be specified as a parameter
NodeRef filePlan = filePlanService.getFilePlan(actionedUponNodeRef);
if (filePlan == null)
{
throw new AlfrescoRuntimeException("Unable to file destruction report, because file plan could not be resolved.");
QName reportType = getReportType(action);
Report report = reportService.generateReport(reportType, actionedUponNodeRef);
NodeRef destination = getDestination(action);
reportService.fileReport(destination, report);
}
Report report = reportService.generateReport(getReportType(), actionedUponNodeRef);
reportService.fileReport(filePlan, 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));
}
return paramValue;
}
/**
* 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);
}
}