RM-1099 (Refactor Transfer and Accession reports)

* Bug fixing

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/HEAD@58637 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Tuna Aksoy
2013-12-05 17:51:22 +00:00
parent c9735c347d
commit 077f5839f4
5 changed files with 202 additions and 63 deletions

View File

@@ -31,6 +31,9 @@ import org.alfresco.service.cmr.repository.NodeRef;
*/
public class TransferAction extends RMDispositionActionExecuterAbstractBase
{
/** Action name */
public static final String NAME = "transfer";
/** Indicates whether the transfer is an accession or not */
private boolean isAccession = false;

View File

@@ -32,6 +32,9 @@ import org.alfresco.service.cmr.repository.NodeRef;
*/
public class DestructionReportAction extends BaseReportAction
{
/** Action name */
public static final String NAME = "destructionReport";
@Override
protected Map<String, Serializable> addProperties(NodeRef nodeRef)
{

View File

@@ -42,6 +42,9 @@ import org.apache.commons.lang.StringUtils;
*/
public class TransferReportAction extends BaseReportAction
{
/** Action name */
public static final String NAME = "transferReport";
@Override
protected Map<String, Serializable> addProperties(NodeRef nodeRef)
{

View File

@@ -19,6 +19,7 @@
package org.alfresco.module.org_alfresco_module_rm.test.service;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
@@ -26,13 +27,19 @@ import java.util.Set;
import org.alfresco.module.org_alfresco_module_rm.action.impl.CompleteEventAction;
import org.alfresco.module.org_alfresco_module_rm.action.impl.CutOffAction;
import org.alfresco.module.org_alfresco_module_rm.action.impl.DestroyAction;
import org.alfresco.module.org_alfresco_module_rm.action.impl.TransferAction;
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.action.DestructionReportAction;
import org.alfresco.module.org_alfresco_module_rm.report.action.TransferNode;
import org.alfresco.module.org_alfresco_module_rm.report.action.TransferReportAction;
import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase;
import org.alfresco.module.org_alfresco_module_rm.test.util.CommonRMTestUtils;
import org.alfresco.repo.content.MimetypeMap;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.namespace.QName;
import org.alfresco.util.GUID;
import org.apache.commons.lang.StringUtils;
/**
* Report service implementation unit test.
@@ -41,12 +48,6 @@ import org.alfresco.service.namespace.QName;
*/
public class ReportServiceImplTest extends BaseRMTestCase implements ReportModel
{
@Override
protected boolean isRecordTest()
{
return false;
}
public void testGetReportTypes() throws Exception
{
doTestInTransaction(new Test<Void>()
@@ -76,10 +77,15 @@ public class ReportServiceImplTest extends BaseRMTestCase implements ReportModel
@Override
public Void run() throws Exception
{
Report report = reportService.generateReport(TYPE_DESTRUCTION_REPORT, rmFolder);
// Destruction Report
Report destructionReport = generateDestructionReport();
System.out.println(destructionReport.getReportName());
System.out.println(destructionReport.getReportContent().getContentString());
System.out.println(report.getReportName());
System.out.println(report.getReportContent().getContentString());
// Transfer Report
Report transferReport = generateTransfertReport();
System.out.println(transferReport.getReportName());
System.out.println(transferReport.getReportContent().getContentString());
return null;
}
@@ -93,20 +99,74 @@ public class ReportServiceImplTest extends BaseRMTestCase implements ReportModel
@Override
public Void run() throws Exception
{
Report report = reportService.generateReport(TYPE_DESTRUCTION_REPORT, rmFolder);
NodeRef reportNodeRef = reportService.fileReport(filePlan, report);
// Destruction Report
NodeRef destructionReportNodeRef = fileDestructionReport();
assertNotNull(destructionReportNodeRef);
assertTrue(recordService.isRecord(destructionReportNodeRef));
assertFalse(recordService.isFiled(destructionReportNodeRef));
assertEquals(TYPE_DESTRUCTION_REPORT, nodeService.getType(destructionReportNodeRef));
assertNotNull(reportNodeRef);
assertTrue(recordService.isRecord(reportNodeRef));
assertFalse(recordService.isFiled(reportNodeRef));
assertEquals(TYPE_DESTRUCTION_REPORT, nodeService.getType(reportNodeRef));
// Transfer Report
NodeRef transferReportNodeRef = fileTransferReport();
assertNotNull(transferReportNodeRef);
assertTrue(recordService.isRecord(transferReportNodeRef));
assertFalse(recordService.isFiled(transferReportNodeRef));
assertEquals(TYPE_TRANSFER_REPORT, nodeService.getType(transferReportNodeRef));
return null;
}
});
}
// FIXME!!! FileDestructionReport vs FileReport
/**
* Helper method to generate a destruction report
*
* @return Destruction report
*/
private Report generateDestructionReport()
{
return reportService.generateReport(TYPE_DESTRUCTION_REPORT, rmFolder);
}
/**
* Helper method to generate a transfer report
*
* @return Transfer report
*/
private Report generateTransfertReport()
{
nodeService.setProperty(rmFolder, PROP_TRANSFER_ACCESSION_INDICATOR, false);
nodeService.setProperty(rmFolder, PROP_TRANSFER_LOCATION, filePlan.toString());
Map<String, Serializable> properties = new HashMap<String, Serializable>(2);
ArrayList<TransferNode> transferNodes = new ArrayList<TransferNode>(1);
String dispositionAuthority = StringUtils.EMPTY;
properties.put("transferNodes", transferNodes);
properties.put("dispositionAuthority", dispositionAuthority);
return reportService.generateReport(TYPE_TRANSFER_REPORT, rmFolder, MimetypeMap.MIMETYPE_HTML, properties);
}
/**
* Helper method to file a destruction report
*
* @return Node reference of the destruction report
*/
private NodeRef fileDestructionReport()
{
Report destructionReport = generateDestructionReport();
return reportService.fileReport(filePlan, destructionReport);
}
/**
* Helper method to file a transfer report
*
* @return Node reference of the transfer report
*/
private NodeRef fileTransferReport()
{
Report transferReport = generateTransfertReport();
return reportService.fileReport(filePlan, transferReport);
}
public void testFileDestructionReportAction() throws Exception
{
doTestInTransaction(new Test<Void>()
@@ -122,7 +182,41 @@ public class ReportServiceImplTest extends BaseRMTestCase implements ReportModel
Map<String, Serializable> fileReportParams = new HashMap<String, Serializable>(2);
fileReportParams.put(DestructionReportAction.REPORT_TYPE, "rmr:destructionReport");
fileReportParams.put(DestructionReportAction.DESTINATION, filePlan.toString());
rmActionService.executeRecordsManagementAction(rmFolder, "destructionReport", fileReportParams);
rmActionService.executeRecordsManagementAction(rmFolder, DestructionReportAction.NAME, fileReportParams);
return null;
}
});
}
public void testFileTransferReportAction() throws Exception
{
doTestInTransaction(new Test<Void>()
{
@Override
public Void run() throws Exception
{
NodeRef recordCategory = filePlanService.createRecordCategory(filePlan, GUID.generate());
utils.createDispositionSchedule(
recordCategory,
CommonRMTestUtils.DEFAULT_DISPOSITION_INSTRUCTIONS,
CommonRMTestUtils.DEFAULT_DISPOSITION_AUTHORITY,
false, // record level
true, // set the default actions
true); // extended disposition schedule
NodeRef recordFolder = recordFolderService.createRecordFolder(recordCategory, GUID.generate());
nodeService.setProperty(recordFolder, PROP_TRANSFER_ACCESSION_INDICATOR, false);
nodeService.setProperty(recordFolder, PROP_TRANSFER_LOCATION, filePlan.toString());
Map<String, Serializable> params = new HashMap<String, Serializable>(1);
params.put(CompleteEventAction.PARAM_EVENT_NAME, CommonRMTestUtils.DEFAULT_EVENT_NAME);
rmActionService.executeRecordsManagementAction(recordFolder, CompleteEventAction.NAME, params);
rmActionService.executeRecordsManagementAction(recordFolder, CutOffAction.NAME);
rmActionService.executeRecordsManagementAction(recordFolder, TransferAction.NAME);
Map<String, Serializable> fileReportParams = new HashMap<String, Serializable>(2);
fileReportParams.put(TransferReportAction.REPORT_TYPE, "rmr:transferReport");
fileReportParams.put(TransferReportAction.DESTINATION, filePlan.toString());
rmActionService.executeRecordsManagementAction(recordFolder, TransferReportAction.NAME, fileReportParams);
return null;
}
});

View File

@@ -15,7 +15,10 @@ import java.util.Set;
import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.model.ContentModel;
import org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementActionService;
import org.alfresco.module.org_alfresco_module_rm.action.impl.CutOffAction;
import org.alfresco.module.org_alfresco_module_rm.action.impl.DestroyAction;
import org.alfresco.module.org_alfresco_module_rm.action.impl.FreezeAction;
import org.alfresco.module.org_alfresco_module_rm.action.impl.TransferAction;
import org.alfresco.module.org_alfresco_module_rm.capability.Capability;
import org.alfresco.module.org_alfresco_module_rm.capability.CapabilityService;
import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionSchedule;
@@ -80,6 +83,8 @@ public class CommonRMTestUtils implements RecordsManagementModel
/**
*
* @param container
* @param dispositionInstructions
* @param dispositionAuthority
* @param isRecordLevel
* @param defaultDispositionActions
* @return
@@ -90,6 +95,27 @@ public class CommonRMTestUtils implements RecordsManagementModel
String dispositionAuthority,
boolean isRecordLevel,
boolean defaultDispositionActions)
{
return createDispositionSchedule(container, dispositionInstructions, dispositionAuthority, isRecordLevel, defaultDispositionActions, false);
}
/**
*
* @param container
* @param dispositionInstructions
* @param dispositionAuthority
* @param isRecordLevel
* @param defaultDispositionActions
* @param extendedDispositionSchedule
* @return
*/
public DispositionSchedule createDispositionSchedule(
NodeRef container,
String dispositionInstructions,
String dispositionAuthority,
boolean isRecordLevel,
boolean defaultDispositionActions,
boolean extendedDispositionSchedule)
{
Map<QName, Serializable> dsProps = new HashMap<QName, Serializable>(3);
dsProps.put(PROP_DISPOSITION_AUTHORITY, dispositionAuthority);
@@ -100,7 +126,7 @@ public class CommonRMTestUtils implements RecordsManagementModel
if (defaultDispositionActions == true)
{
Map<QName, Serializable> adParams = new HashMap<QName, Serializable>(3);
adParams.put(PROP_DISPOSITION_ACTION_NAME, "cutoff");
adParams.put(PROP_DISPOSITION_ACTION_NAME, CutOffAction.NAME);
adParams.put(PROP_DISPOSITION_DESCRIPTION, DEFAULT_DISPOSITION_DESCRIPTION);
List<String> events = new ArrayList<String>(1);
@@ -109,10 +135,20 @@ public class CommonRMTestUtils implements RecordsManagementModel
dispositionService.addDispositionActionDefinition(dispositionSchedule, adParams);
if (extendedDispositionSchedule == true)
{
adParams = new HashMap<QName, Serializable>(3);
adParams.put(PROP_DISPOSITION_ACTION_NAME, "destroy");
adParams.put(PROP_DISPOSITION_ACTION_NAME, TransferAction.NAME);
adParams.put(PROP_DISPOSITION_DESCRIPTION, DEFAULT_DISPOSITION_DESCRIPTION);
adParams.put(PROP_DISPOSITION_PERIOD, "immediately|0");
adParams.put(PROP_DISPOSITION_PERIOD, PERIOD_IMMEDIATELY);
dispositionService.addDispositionActionDefinition(dispositionSchedule, adParams);
}
adParams = new HashMap<QName, Serializable>(3);
adParams.put(PROP_DISPOSITION_ACTION_NAME, DestroyAction.NAME);
adParams.put(PROP_DISPOSITION_DESCRIPTION, DEFAULT_DISPOSITION_DESCRIPTION);
adParams.put(PROP_DISPOSITION_PERIOD, PERIOD_IMMEDIATELY);
dispositionService.addDispositionActionDefinition(dispositionSchedule, adParams);
}