mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
RM-777: Destruction report generation
* template now correct and matches email notification style * record or folder details shown including basic disposition details * destroyed records shown if record folder * generalised report action * other tweaks git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/HEAD@52685 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -26,25 +26,27 @@ 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;
|
||||
|
||||
/**
|
||||
* File Destruction Report
|
||||
* File Report Action
|
||||
*
|
||||
* @author Roy Wetherall
|
||||
* @since 2.1
|
||||
*/
|
||||
public class FileDestructionReport extends RMActionExecuterAbstractBase
|
||||
implements ReportModel
|
||||
public class FileReportAction extends RMActionExecuterAbstractBase
|
||||
implements ReportModel
|
||||
{
|
||||
/** Action name */
|
||||
public static final String NAME = "fileDestructionReport";
|
||||
|
||||
/** report service */
|
||||
protected ReportService reportService;
|
||||
|
||||
/** file plan service */
|
||||
protected FilePlanService filePlanService;
|
||||
|
||||
/** report type string value */
|
||||
private String reportType;
|
||||
|
||||
/**
|
||||
* @param reportService report service
|
||||
*/
|
||||
@@ -61,6 +63,23 @@ public class FileDestructionReport extends RMActionExecuterAbstractBase
|
||||
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)
|
||||
*/
|
||||
@@ -78,7 +97,7 @@ public class FileDestructionReport extends RMActionExecuterAbstractBase
|
||||
throw new AlfrescoRuntimeException("Unable to file destruction report, because file plan could not be resolved.");
|
||||
}
|
||||
|
||||
Report report = reportService.generateReport(TYPE_DESTRUCTION_REPORT, actionedUponNodeRef);
|
||||
Report report = reportService.generateReport(getReportType(), actionedUponNodeRef);
|
||||
reportService.fileReport(filePlan, report);
|
||||
|
||||
}
|
@@ -23,15 +23,20 @@ import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.alfresco.error.AlfrescoRuntimeException;
|
||||
import org.alfresco.repo.action.parameter.ParameterProcessorComponent;
|
||||
import org.alfresco.repo.admin.SysAdminParams;
|
||||
import org.alfresco.repo.model.Repository;
|
||||
import org.alfresco.service.cmr.model.FileFolderService;
|
||||
import org.alfresco.service.cmr.repository.ContentReader;
|
||||
import org.alfresco.service.cmr.repository.ContentService;
|
||||
import org.alfresco.service.cmr.repository.ContentWriter;
|
||||
import org.alfresco.service.cmr.repository.MimetypeService;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.NodeService;
|
||||
import org.alfresco.service.cmr.repository.StoreRef;
|
||||
import org.alfresco.service.cmr.repository.TemplateService;
|
||||
import org.alfresco.util.GUID;
|
||||
import org.alfresco.util.UrlUtil;
|
||||
import org.springframework.extensions.surf.util.I18NUtil;
|
||||
|
||||
/**
|
||||
* Declarative report generator.
|
||||
@@ -41,27 +46,56 @@ import org.alfresco.util.GUID;
|
||||
*/
|
||||
public class DeclarativeReportGenerator extends BaseReportGenerator
|
||||
{
|
||||
/** template lookup root */
|
||||
protected static final NodeRef TEMPLATE_ROOT = new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, "rm_report_templates");
|
||||
|
||||
/** model keys */
|
||||
protected static final String KEY_NODE = "node";
|
||||
protected static final String KEY_CHILDREN = "children";
|
||||
|
||||
/** content service */
|
||||
protected ContentService contentService;
|
||||
|
||||
/** mimetype service */
|
||||
protected MimetypeService mimetypeService;
|
||||
|
||||
/** file folder service */
|
||||
protected FileFolderService fileFolderService;
|
||||
|
||||
/** template service */
|
||||
protected TemplateService templateService;
|
||||
|
||||
/** node service */
|
||||
protected NodeService nodeService;
|
||||
|
||||
/** repository helper */
|
||||
protected Repository repository;
|
||||
|
||||
/** parameter processor component */
|
||||
protected ParameterProcessorComponent parameterProcessorComponent;
|
||||
|
||||
/** sys admin params */
|
||||
protected SysAdminParams sysAdminParams;
|
||||
|
||||
/**
|
||||
* @param mimetypeService mimetype service
|
||||
*/
|
||||
public void setMimetypeService(MimetypeService mimetypeService)
|
||||
{
|
||||
this.mimetypeService = mimetypeService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param fileFolderService file folder service
|
||||
*/
|
||||
public void setFileFolderService(FileFolderService fileFolderService)
|
||||
{
|
||||
this.fileFolderService = fileFolderService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param templateService template service
|
||||
*/
|
||||
public void setTemplateService(TemplateService templateService)
|
||||
{
|
||||
this.templateService = templateService;
|
||||
@@ -75,14 +109,47 @@ public class DeclarativeReportGenerator extends BaseReportGenerator
|
||||
this.contentService = contentService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param nodeService node service
|
||||
*/
|
||||
public void setNodeService(NodeService nodeService)
|
||||
{
|
||||
this.nodeService = nodeService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param parameterProcessorComponent parameter processor component
|
||||
*/
|
||||
public void setParameterProcessorComponent(ParameterProcessorComponent parameterProcessorComponent)
|
||||
{
|
||||
this.parameterProcessorComponent = parameterProcessorComponent;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param repository repository helper
|
||||
*/
|
||||
public void setRepository(Repository repository)
|
||||
{
|
||||
this.repository = repository;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param sysAdminParams sys admin params
|
||||
*/
|
||||
public void setSysAdminParams(SysAdminParams sysAdminParams)
|
||||
{
|
||||
this.sysAdminParams = sysAdminParams;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.report.generator.BaseReportGenerator#generateReportName(org.alfresco.service.cmr.repository.NodeRef)
|
||||
*/
|
||||
@Override
|
||||
protected String generateReportName(NodeRef reportedUponNodeRef)
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return GUID.generate();
|
||||
String reportTypeName = reportType.getPrefixedQName(namespaceService).getPrefixString().replace(":", "_");
|
||||
String value = I18NUtil.getMessage("report." + reportTypeName + ".name");
|
||||
return parameterProcessorComponent.process(value, reportedUponNodeRef);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -95,7 +162,7 @@ public class DeclarativeReportGenerator extends BaseReportGenerator
|
||||
NodeRef reportTemplateNodeRef = getReportTemplate(mimetype);
|
||||
|
||||
// get the model
|
||||
Map<String, Serializable> model = new HashMap<String, Serializable>();
|
||||
Map<String, Serializable> model = createTemplateModel(reportTemplateNodeRef, reportedUponNodeRef);
|
||||
|
||||
// run the template
|
||||
String result = templateService.processTemplate("freemarker", reportTemplateNodeRef.toString(), model);
|
||||
@@ -106,10 +173,34 @@ public class DeclarativeReportGenerator extends BaseReportGenerator
|
||||
contentWriter.setMimetype(mimetype);
|
||||
contentWriter.putContent(result);
|
||||
|
||||
// return the reader to the temp content
|
||||
return contentWriter.getReader();
|
||||
}
|
||||
|
||||
protected Map<String, Serializable> createTemplateModel(NodeRef templateNodeRef, NodeRef reportedUponNodeRef)
|
||||
{
|
||||
Map<String, Serializable> model = new HashMap<String, Serializable>();
|
||||
|
||||
// build the default model
|
||||
NodeRef person = repository.getPerson();
|
||||
templateService.buildDefaultModel(person,
|
||||
repository.getCompanyHome(),
|
||||
repository.getUserHome(person),
|
||||
templateNodeRef,
|
||||
null);
|
||||
|
||||
// put the reported upon node reference in the model
|
||||
model.put(KEY_NODE, reportedUponNodeRef);
|
||||
|
||||
// context url's (handy for images and links)
|
||||
model.put("url", UrlUtil.getAlfrescoUrl(sysAdminParams));
|
||||
model.put(TemplateService.KEY_SHARE_URL, UrlUtil.getShareUrl(sysAdminParams));
|
||||
|
||||
return model;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get's the report template based on the type and mimetype.
|
||||
*
|
||||
* @param mimetype
|
||||
* @return
|
||||
@@ -137,6 +228,7 @@ public class DeclarativeReportGenerator extends BaseReportGenerator
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the template name based on the type and mimetype.
|
||||
*
|
||||
* @param mimetype
|
||||
* @return
|
||||
|
Reference in New Issue
Block a user