mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
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:
@@ -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
|
||||
|
@@ -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)
|
||||
|
@@ -25,37 +25,37 @@ import org.alfresco.service.namespace.QName;
|
||||
|
||||
/**
|
||||
* Report service.
|
||||
*
|
||||
*
|
||||
* @author Roy Wetherall
|
||||
* @since 2.1
|
||||
*/
|
||||
public interface ReportService
|
||||
public interface ReportService
|
||||
{
|
||||
/**
|
||||
* Register a report generator with the report service.
|
||||
*
|
||||
*
|
||||
* @param reportGenerator report generator
|
||||
*/
|
||||
void registerReportGenerator(ReportGenerator reportGenerator);
|
||||
|
||||
|
||||
/**
|
||||
* Get a list of the available report types.
|
||||
*
|
||||
* @return
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
Set<QName> getReportTypes();
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
* @param reportType
|
||||
* @param reportedUponNodeRef
|
||||
* @return
|
||||
*/
|
||||
Report generateReport(QName reportType, NodeRef reportedUponNodeRef);
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @param reportType
|
||||
* @param reportedUponNodeRef
|
||||
* @return
|
||||
@@ -63,11 +63,12 @@ public interface ReportService
|
||||
Report generateReport(QName reportType, NodeRef reportedUponNodeRef, String mimetype);
|
||||
|
||||
/**
|
||||
* File report as unfiled record in a file plan.
|
||||
*
|
||||
* @param filePlan 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 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);
|
||||
}
|
||||
|
@@ -35,7 +35,7 @@ import org.springframework.extensions.surf.util.ParameterCheck;
|
||||
|
||||
/**
|
||||
* Report service implementation.
|
||||
*
|
||||
*
|
||||
* @author Roy Wetherall
|
||||
* @since 2.1
|
||||
*/
|
||||
@@ -44,16 +44,16 @@ public class ReportServiceImpl extends ServiceBaseImpl
|
||||
{
|
||||
/** file folder service */
|
||||
protected FileFolderService fileFolderService;
|
||||
|
||||
|
||||
/** file plan service */
|
||||
protected FilePlanService filePlanService;
|
||||
|
||||
|
||||
/** content service */
|
||||
protected ContentService contentService;
|
||||
|
||||
|
||||
/** record service */
|
||||
protected RecordService recordService;
|
||||
|
||||
|
||||
/** report generator registry */
|
||||
private Map<QName, ReportGenerator> registry = new HashMap<QName, ReportGenerator>();
|
||||
|
||||
@@ -64,7 +64,7 @@ public class ReportServiceImpl extends ServiceBaseImpl
|
||||
{
|
||||
this.fileFolderService = fileFolderService;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param filePlanService file plan service
|
||||
*/
|
||||
@@ -72,7 +72,7 @@ public class ReportServiceImpl extends ServiceBaseImpl
|
||||
{
|
||||
this.filePlanService = filePlanService;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param contentService content service
|
||||
*/
|
||||
@@ -80,7 +80,7 @@ public class ReportServiceImpl extends ServiceBaseImpl
|
||||
{
|
||||
this.contentService = contentService;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param recordService record service
|
||||
*/
|
||||
@@ -88,17 +88,17 @@ public class ReportServiceImpl extends ServiceBaseImpl
|
||||
{
|
||||
this.recordService = recordService;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.report.ReportService#registerReportGenerator(org.alfresco.module.org_alfresco_module_rm.report.ReportGenerator)
|
||||
*/
|
||||
@Override
|
||||
public void registerReportGenerator(ReportGenerator reportGenerator)
|
||||
{
|
||||
ParameterCheck.mandatory("reportGenerator", reportGenerator);
|
||||
ParameterCheck.mandatory("reportGenerator", reportGenerator);
|
||||
registry.put(reportGenerator.getReportType(), reportGenerator);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.report.ReportService#getReportTypes()
|
||||
*/
|
||||
@@ -116,7 +116,7 @@ public class ReportServiceImpl extends ServiceBaseImpl
|
||||
{
|
||||
return generateReport(reportType, reportedUponNodeRef, MimetypeMap.MIMETYPE_HTML);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.report.ReportService#generateReport(org.alfresco.service.namespace.QName, org.alfresco.service.cmr.repository.NodeRef)
|
||||
*/
|
||||
@@ -126,39 +126,33 @@ public class ReportServiceImpl extends ServiceBaseImpl
|
||||
ParameterCheck.mandatory("reportType", reportType);
|
||||
ParameterCheck.mandatory("reportedUponNodeRef", reportedUponNodeRef);
|
||||
ParameterCheck.mandatory("mimetype", mimetype);
|
||||
|
||||
|
||||
// get the generator
|
||||
ReportGenerator generator = registry.get(reportType);
|
||||
|
||||
|
||||
// error is generator not found in registry
|
||||
if (generator == null)
|
||||
{
|
||||
throw new AlfrescoRuntimeException("Unable to generate report, because report type " + reportType.toString() + " does not correspond to a registered report type.");
|
||||
}
|
||||
|
||||
|
||||
// generate the report
|
||||
return generator.generateReport(reportedUponNodeRef, mimetype);
|
||||
return generator.generateReport(reportedUponNodeRef, mimetype);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @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,
|
||||
report.getReportName(),
|
||||
report.getReportType(),
|
||||
report.getReportProperties(),
|
||||
|
||||
return recordService.createRecord(nodeRef,
|
||||
report.getReportName(),
|
||||
report.getReportType(),
|
||||
report.getReportProperties(),
|
||||
report.getReportContent());
|
||||
}
|
||||
}
|
||||
|
@@ -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);
|
||||
|
||||
Report report = reportService.generateReport(getReportType(), actionedUponNodeRef);
|
||||
reportService.fileReport(filePlan, report);
|
||||
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));
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user