RM-1099 (Refactor Transfer and Accession reports)

* Added a patch for the new report template
 * Changed the module property to 2.2 to get the patch executed
 * Refactored the transfer report action

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/HEAD@58546 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Tuna Aksoy
2013-12-03 15:49:57 +00:00
parent 41fdb5864c
commit ea20a6a648
6 changed files with 229 additions and 74 deletions

View File

@@ -210,7 +210,6 @@
</view:properties> </view:properties>
</cm:content> </cm:content>
</cm:contains> </cm:contains>
<!-- FIXME -->
<cm:contains> <cm:contains>
<cm:content view:childName="cm:report_rmr_transferReport.html.ftl"> <cm:content view:childName="cm:report_rmr_transferReport.html.ftl">
<view:aspects> <view:aspects>

View File

@@ -6,6 +6,6 @@ module.aliases=org_alfresco_module_dod5015
module.title=Records Management module.title=Records Management
module.description=Alfresco Record Management Extension module.description=Alfresco Record Management Extension
module.version=2.1 module.version=2.2
module.repo.version.min=4.2 module.repo.version.min=4.2

View File

@@ -3,8 +3,8 @@
<beans> <beans>
<bean id="rm.baseModulePatch" abstract="true" parent="module.baseComponent"> <bean id="rm.baseModulePatch" abstract="true" parent="module.baseComponent">
<property name="retryingTransactionHelper" ref="retryingTransactionHelper"/> <property name="retryingTransactionHelper" ref="retryingTransactionHelper"/>
<property name="behaviourFilter" ref="policyBehaviourFilter" /> <property name="behaviourFilter" ref="policyBehaviourFilter" />
</bean> </bean>
@@ -53,8 +53,8 @@
<property name="nodeDAO" ref="nodeDAO" /> <property name="nodeDAO" ref="nodeDAO" />
<property name="qnameDAO" ref="qnameDAO"/> <property name="qnameDAO" ref="qnameDAO"/>
</bean> </bean>
<bean id="org_alfresco_module_rm_RMv2FilePlanNodeRefPatch" <bean id="org_alfresco_module_rm_RMv2FilePlanNodeRefPatch"
parent="rm.baseModulePatch" parent="rm.baseModulePatch"
class="org.alfresco.module.org_alfresco_module_rm.patch.RMv2FilePlanNodeRefPatch"> class="org.alfresco.module.org_alfresco_module_rm.patch.RMv2FilePlanNodeRefPatch">
<property name="moduleId" value="org_alfresco_module_rm"/> <property name="moduleId" value="org_alfresco_module_rm"/>
@@ -70,8 +70,8 @@
<property name="filePlanService" ref="FilePlanService" /> <property name="filePlanService" ref="FilePlanService" />
<property name="filePlanRoleService" ref="filePlanRoleService" /> <property name="filePlanRoleService" ref="filePlanRoleService" />
</bean> </bean>
<bean id="org_alfresco_module_rm_RMv2SavedSearchPatch" <bean id="org_alfresco_module_rm_RMv2SavedSearchPatch"
parent="rm.baseModulePatch" parent="rm.baseModulePatch"
class="org.alfresco.module.org_alfresco_module_rm.patch.RMv2SavedSearchPatch"> class="org.alfresco.module.org_alfresco_module_rm.patch.RMv2SavedSearchPatch">
<property name="moduleId" value="org_alfresco_module_rm"/> <property name="moduleId" value="org_alfresco_module_rm"/>
@@ -155,7 +155,7 @@
<property name="filePlanRoleService" ref="FilePlanRoleService"/> <property name="filePlanRoleService" ref="FilePlanRoleService"/>
<property name="authorityService" ref="AuthorityService"></property> <property name="authorityService" ref="AuthorityService"></property>
</bean> </bean>
<bean id="org_alfresco_module_rm_RMv21ReportServicePatch" <bean id="org_alfresco_module_rm_RMv21ReportServicePatch"
parent="rm.baseModulePatch" parent="rm.baseModulePatch"
class="org.alfresco.module.org_alfresco_module_rm.patch.RMv21ReportServicePatch"> class="org.alfresco.module.org_alfresco_module_rm.patch.RMv21ReportServicePatch">
@@ -177,7 +177,24 @@
<property name="sinceVersion" value="2.1"/> <property name="sinceVersion" value="2.1"/>
<property name="appliesFromVersion" value="2.1"/> <property name="appliesFromVersion" value="2.1"/>
<property name="fileFolderService" ref="FileFolderService"/> <property name="fileFolderService" ref="FileFolderService"/>
<property name="nodeService" ref="NodeService"/> <property name="nodeService" ref="NodeService"/>
</bean> </bean>
<bean id="org_alfresco_module_rm_RMv22ReportTemplatePatch"
parent="rm.baseModulePatch"
class="org.alfresco.module.org_alfresco_module_rm.patch.RMv22ReportTemplatePatch">
<property name="moduleId" value="org_alfresco_module_rm"/>
<property name="name" value="org_alfresco_module_rm_RMv22ReportTemplatePatch"/>
<property name="description" value="Patches new versions of the report templates."/>
<property name="sinceVersion" value="2.2"/>
<property name="appliesFromVersion" value="2.2"/>
<property name="dependsOn">
<list>
<ref bean="org_alfresco_module_rm_RMv21ReportServicePatch" />
</list>
</property>
<property name="nodeService" ref="NodeService"/>
<property name="contentService" ref="ContentService"/>
</bean>
</beans> </beans>

View File

@@ -33,16 +33,14 @@ import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.cmr.repository.StoreRef; import org.alfresco.service.cmr.repository.StoreRef;
import org.alfresco.service.namespace.NamespaceService; import org.alfresco.service.namespace.NamespaceService;
import org.alfresco.service.namespace.QName; import org.alfresco.service.namespace.QName;
import org.springframework.beans.factory.BeanNameAware;
/** /**
* Adds a new email template for rejected records to the existing templates * Adds a new email template for rejected records to the existing templates
* *
* @author Tuna Aksoy * @author Tuna Aksoy
* @since v2.1 * @since 2.1
*/ */
public class NotificationTemplatePatch_v21 extends ModulePatchComponent public class NotificationTemplatePatch_v21 extends ModulePatchComponent
implements BeanNameAware
{ {
/** Email template path */ /** Email template path */
private static final String PATH_REJECTED = "alfresco/module/org_alfresco_module_rm/bootstrap/content/record-rejected-email.ftl"; private static final String PATH_REJECTED = "alfresco/module/org_alfresco_module_rm/bootstrap/content/record-rejected-email.ftl";
@@ -87,36 +85,33 @@ public class NotificationTemplatePatch_v21 extends ModulePatchComponent
protected void executePatch() throws Throwable protected void executePatch() throws Throwable
{ {
NodeRef nodeRef = new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, CONFIG_NODEID); NodeRef nodeRef = new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, CONFIG_NODEID);
if (nodeService.exists(nodeRef) == false) // get the parent node
NodeRef supersededTemplate = notificationHelper.getSupersededTemplate();
if (nodeService.exists(nodeRef) == false && nodeService.exists(supersededTemplate) == true)
{ {
// get the parent node NodeRef parent = nodeService.getPrimaryParent(supersededTemplate).getParentRef();
NodeRef supersededTemplate = notificationHelper.getSupersededTemplate();
if (nodeService.exists(supersededTemplate) == true) // build the node properties
{ Map<QName, Serializable> props = new HashMap<QName, Serializable>(4);
NodeRef parent = nodeService.getPrimaryParent(supersededTemplate).getParentRef(); props.put(ContentModel.PROP_DESCRIPTION, "Record superseded email template.");
props.put(ContentModel.PROP_TITLE, "record-rejected-email.ftl");
// build the node properties props.put(ContentModel.PROP_NAME, "record-rejected-email.ftl");
Map<QName, Serializable> props = new HashMap<QName, Serializable>(4); props.put(ContentModel.PROP_NODE_UUID, "record_rejected_template");
props.put(ContentModel.PROP_DESCRIPTION, "Record superseded email template.");
props.put(ContentModel.PROP_TITLE, "record-rejected-email.ftl"); // get the assoc qname
props.put(ContentModel.PROP_NAME, "record-rejected-email.ftl"); QName assocQName = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, QName.createValidLocalName("record-rejected-email.ftl"));
props.put(ContentModel.PROP_NODE_UUID, "record_rejected_template");
// create the node
// get the assoc qname ChildAssociationRef node = nodeService.createNode(parent,
QName assocQName = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, QName.createValidLocalName("record-rejected-email.ftl")); ContentModel.ASSOC_CONTAINS,
assocQName,
// create the node ContentModel.TYPE_CONTENT,
ChildAssociationRef node = nodeService.createNode(parent, props);
ContentModel.ASSOC_CONTAINS,
assocQName, // put the content
ContentModel.TYPE_CONTENT, ContentWriter writer = contentService.getWriter(node.getChildRef(), ContentModel.PROP_CONTENT, true);
props); InputStream is = getClass().getClassLoader().getResourceAsStream(PATH_REJECTED);
writer.putContent(is);
// put the content
ContentWriter writer = contentService.getWriter(node.getChildRef(), ContentModel.PROP_CONTENT, true);
InputStream is = getClass().getClassLoader().getResourceAsStream(PATH_REJECTED);
writer.putContent(is);
}
} }
} }
} }

View File

@@ -0,0 +1,105 @@
/*
* Copyright (C) 2005-2013 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
package org.alfresco.module.org_alfresco_module_rm.patch;
import java.io.InputStream;
import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;
import org.alfresco.model.ContentModel;
import org.alfresco.service.cmr.repository.ChildAssociationRef;
import org.alfresco.service.cmr.repository.ContentService;
import org.alfresco.service.cmr.repository.ContentWriter;
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.namespace.NamespaceService;
import org.alfresco.service.namespace.QName;
/**
* Adds a new transfer/accession report template to the existing report templates
*
* @author Tuna Aksoy
* @since 2.2
*/
public class RMv22ReportTemplatePatch extends ModulePatchComponent
{
/** Report template path */
private static final String REPORT_TEMPLATE_PATH = "alfresco/module/org_alfresco_module_rm/bootstrap/report/report_rmr_transferReport.html.ftl";
/** Report template config node IDs */
private static final String TRANSFER_REPORT = "rmr_transferReport";
private static final String DESTRUCTION_REPORT = "rmr_destructionReport";
/** Node service */
private NodeService nodeService;
/** Content service */
private ContentService contentService;
/**
* @param nodeService node service
*/
public void setNodeService(NodeService nodeService)
{
this.nodeService = nodeService;
}
/**
* @param contentService content service
*/
public void setContentService(ContentService contentService)
{
this.contentService = contentService;
}
@Override
protected void executePatch() throws Throwable
{
NodeRef transferReport = new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, TRANSFER_REPORT);
NodeRef destructionReport = new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, DESTRUCTION_REPORT);
if (nodeService.exists(transferReport) == false && nodeService.exists(destructionReport) == true)
{
NodeRef parent = nodeService.getPrimaryParent(destructionReport).getParentRef();
// get the assoc qname
QName assocQName = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, QName.createValidLocalName("report_rmr_transferReport.html.ftl"));
// build the node properties
Map<QName, Serializable> props = new HashMap<QName, Serializable>(4);
props.put(ContentModel.PROP_DESCRIPTION, "Transfer report template.");
props.put(ContentModel.PROP_TITLE, "Transfer Report Template");
props.put(ContentModel.PROP_NAME, "report_rmr_transferReport.html.ftl");
props.put(ContentModel.PROP_NODE_UUID, "rmr_transferReport");
// create the node
ChildAssociationRef node = nodeService.createNode(parent,
ContentModel.ASSOC_CONTAINS,
assocQName,
ContentModel.TYPE_CONTENT,
props);
// put the content
ContentWriter writer = contentService.getWriter(node.getChildRef(), ContentModel.PROP_CONTENT, true);
InputStream is = getClass().getClassLoader().getResourceAsStream(REPORT_TEMPLATE_PATH);
writer.putContent(is);
}
}
}

View File

@@ -88,28 +88,18 @@ public class TransferReportAction extends BaseReportAction
{ {
Map<String, Serializable> transferNodeProperties = new HashMap<String, Serializable>(6); Map<String, Serializable> transferNodeProperties = new HashMap<String, Serializable>(6);
Map<QName, Serializable> properties = nodeService.getProperties(childRef);
String name = (String) properties.get(ContentModel.PROP_NAME);
String identifier = (String) properties.get(RecordsManagementModel.PROP_IDENTIFIER);
boolean isFolder = dictionaryService.isSubClass(nodeService.getType(childRef), ContentModel.TYPE_FOLDER); boolean isFolder = dictionaryService.isSubClass(nodeService.getType(childRef), ContentModel.TYPE_FOLDER);
transferNodeProperties.put("name", name);
transferNodeProperties.put("identifier", identifier);
transferNodeProperties.put("isFolder", isFolder); transferNodeProperties.put("isFolder", isFolder);
if (isFolder == true) if (isFolder == true)
{ {
transferNodeProperties.put("records", (ArrayList<TransferNode>) getRecords(childRef)); Map<String, Serializable> folderProperties = getFolderProperties(childRef);
transferNodeProperties.putAll(folderProperties);
} }
else else
{ {
String declaredBy = (String) properties.get(RecordsManagementModel.PROP_DECLARED_BY); Map<String, Serializable> recordProperties = getRecordProperties(childRef);
Date declaredOn = (Date) properties.get(RecordsManagementModel.PROP_DECLARED_AT); transferNodeProperties.putAll(recordProperties);
boolean isDeclared = nodeService.hasAspect(childRef, RecordsManagementModel.ASPECT_DECLARED_RECORD);
transferNodeProperties.put("declaredBy", declaredBy);
transferNodeProperties.put("declaredOn", declaredOn);
transferNodeProperties.put("isDeclared", isDeclared);
} }
return transferNodeProperties; return transferNodeProperties;
@@ -128,29 +118,78 @@ public class TransferReportAction extends BaseReportAction
for (ChildAssociationRef child : assocs) for (ChildAssociationRef child : assocs)
{ {
NodeRef record = child.getChildRef(); NodeRef record = child.getChildRef();
if (nodeService.hasAspect(record, RecordsManagementModel.ASPECT_RECORD)) if (nodeService.hasAspect(record, RecordsManagementModel.ASPECT_RECORD) == true)
{ {
Map<String, Serializable> transferNodeProperties = new HashMap<String, Serializable>(6); Map<String, Serializable> recordProperties = getRecordProperties(record);
TransferNode transferNode = new TransferNode(record, recordProperties);
Map<QName, Serializable> properties = nodeService.getProperties(record); records.add(transferNode);
String name = (String) properties.get(ContentModel.PROP_NAME);
String identifier = (String) properties.get(RecordsManagementModel.PROP_IDENTIFIER);
String declaredBy = (String) properties.get(RecordsManagementModel.PROP_DECLARED_BY);
Date declaredOn = (Date) properties.get(RecordsManagementModel.PROP_DECLARED_AT);
boolean isDeclared = nodeService.hasAspect(record, RecordsManagementModel.ASPECT_DECLARED_RECORD);
transferNodeProperties.put("name", name);
transferNodeProperties.put("identifier", identifier);
transferNodeProperties.put("declaredBy", declaredBy);
transferNodeProperties.put("declaredOn", declaredOn);
transferNodeProperties.put("isDeclared", isDeclared);
records.add(new TransferNode(record, transferNodeProperties));
} }
} }
return records; return records;
} }
/**
* Helper method to get the common transfer node properties
*
* @param nodeRef Node reference of the transfer node
* @return Map of the common transfer node properties
*/
private Map<String, Serializable> getCommonProperties(NodeRef nodeRef)
{
Map<String, Serializable> transferNodeProperties = new HashMap<String, Serializable>(3);
Map<QName, Serializable> properties = nodeService.getProperties(nodeRef);
String name = (String) properties.get(ContentModel.PROP_NAME);
String identifier = (String) properties.get(RecordsManagementModel.PROP_IDENTIFIER);
transferNodeProperties.put("name", name);
transferNodeProperties.put("identifier", identifier);
return transferNodeProperties;
}
/**
* Helper method to get the folder specific properties
*
* @param folder Node reference of the folder
* @return Map of the folder specific properties
*/
private Map<String, Serializable> getFolderProperties(NodeRef folder)
{
Map<String, Serializable> transferNodeProperties = new HashMap<String, Serializable>(3);
Map<String, Serializable> commonProperties = getCommonProperties(folder);
ArrayList<TransferNode> records = (ArrayList<TransferNode>) getRecords(folder);
transferNodeProperties.putAll(commonProperties);
transferNodeProperties.put("records", records);
return transferNodeProperties;
}
/**
* Helper method to get the record folder properties
*
* @param record Node reference of the record
* @return Map of the record specific properties
*/
private Map<String, Serializable> getRecordProperties(NodeRef record)
{
Map<String, Serializable> transferNodeProperties = new HashMap<String, Serializable>(5);
Map<QName, Serializable> properties = nodeService.getProperties(record);
String declaredBy = (String) properties.get(RecordsManagementModel.PROP_DECLARED_BY);
Date declaredOn = (Date) properties.get(RecordsManagementModel.PROP_DECLARED_AT);
boolean isDeclared = nodeService.hasAspect(record, RecordsManagementModel.ASPECT_DECLARED_RECORD);
Map<String, Serializable> commonProperties = getCommonProperties(record);
transferNodeProperties.putAll(commonProperties);
transferNodeProperties.put("declaredBy", declaredBy);
transferNodeProperties.put("declaredOn", declaredOn);
transferNodeProperties.put("isDeclared", isDeclared);
return transferNodeProperties;
}
/** /**
* Gets the disposition authority from the list of the transfer nodes * Gets the disposition authority from the list of the transfer nodes
* *