RM-5733 Changed the way retention as of date is calculated.

This commit is contained in:
Roxana Lucanu-Ghetu
2018-02-02 16:11:38 +02:00
parent 72b4fc4011
commit 4c42b2cdf6
5 changed files with 32 additions and 19 deletions

View File

@@ -253,7 +253,7 @@ public class BroadcastDispositionActionDefinitionUpdateAction extends RMActionEx
{
NodeRef dispositionedNode = getNodeService().getPrimaryParent(nextAction.getNodeRef()).getParentRef();
DispositionActionDefinition definition = nextAction.getDispositionActionDefinition();
Date newAsOfDate = getDispositionService().calculateAsOfDate(dispositionedNode, definition, false);
Date newAsOfDate = getDispositionService().calculateAsOfDate(dispositionedNode, definition);
if (logger.isDebugEnabled())
{

View File

@@ -260,11 +260,9 @@ public interface DispositionService
*
* @param nodeRef The node which the schedule applies to.
* @param dispositionActionDefinition The definition of the disposition action.
* @param allowContextFromAsOf true if the context date is allowed to be obtained from the disposition "as of" property.
* @return The new "disposition as of" date.
*/
Date calculateAsOfDate(NodeRef nodeRef, DispositionActionDefinition dispositionActionDefinition,
boolean allowContextFromAsOf);
Date calculateAsOfDate(NodeRef nodeRef, DispositionActionDefinition dispositionActionDefinition);
/**
* Gets the origin disposition schedule for the record, not the calculated one

View File

@@ -699,7 +699,6 @@ public class DispositionServiceImpl extends ServiceBaseImpl
*
* @param nodeRef node reference
* @param dispositionActionDefinition disposition action definition
* @param allowContextFromAsOf true if the context date is allowed to be obtained from the disposition "as of" property.
*/
private DispositionAction initialiseDispositionAction(NodeRef nodeRef, DispositionActionDefinition dispositionActionDefinition, boolean allowContextFromAsOf)
{
@@ -712,7 +711,7 @@ public class DispositionServiceImpl extends ServiceBaseImpl
// Create the properties
Map<QName, Serializable> props = new HashMap<QName, Serializable>(10);
Date asOfDate = calculateAsOfDate(nodeRef, dispositionActionDefinition, allowContextFromAsOf);
Date asOfDate = calculateAsOfDate(nodeRef, dispositionActionDefinition);
// Set the property values
props.put(PROP_DISPOSITION_ACTION_ID, dispositionActionDefinition.getId());
@@ -750,8 +749,7 @@ public class DispositionServiceImpl extends ServiceBaseImpl
* @return The new "disposition as of" date.
*/
@Override
public Date calculateAsOfDate(NodeRef nodeRef, DispositionActionDefinition dispositionActionDefinition,
boolean allowContextFromAsOf)
public Date calculateAsOfDate(NodeRef nodeRef, DispositionActionDefinition dispositionActionDefinition)
{
// Calculate the asOf date
Date asOfDate = null;
@@ -762,12 +760,29 @@ public class DispositionServiceImpl extends ServiceBaseImpl
// Get the period properties value
QName periodProperty = dispositionActionDefinition.getPeriodProperty();
if (periodProperty != null && (allowContextFromAsOf
|| !RecordsManagementModel.PROP_DISPOSITION_AS_OF.equals(periodProperty)))
if (periodProperty != null)
// && (allowContextFromAsOf
// || !RecordsManagementModel.PROP_DISPOSITION_AS_OF.equals(periodProperty)))
{
// doesn't matter if the period property isn't set ... the asOfDate will get updated later
// when the value of the period property is set
contextDate = (Date)this.nodeService.getProperty(nodeRef, periodProperty);
if (RecordsManagementModel.PROP_DISPOSITION_AS_OF.equals(periodProperty))
{
DispositionAction lastCompletedDispositionAction = getLastCompletedDispostionAction(nodeRef);
if (lastCompletedDispositionAction != null)
{
contextDate = lastCompletedDispositionAction.getCompletedAt();
}
else
{
contextDate = (Date)this.nodeService.getProperty(nodeRef, periodProperty);
}
}
else
{
// doesn't matter if the period property isn't set ... the asOfDate will get updated later
// when the value of the period property is set
contextDate = (Date)this.nodeService.getProperty(nodeRef, periodProperty);
}
}
else
{
@@ -1097,7 +1112,7 @@ public class DispositionServiceImpl extends ServiceBaseImpl
if (assoc != null && assoc.getQName().getLocalName().contains(dispositionActionName))
{
DispositionActionDefinition actionDefinition = ds.getDispositionActionDefinition(assoc.getChildRef().getId());
return calculateAsOfDate(record, actionDefinition, true);
return calculateAsOfDate(record, actionDefinition);
}
}
}
@@ -1319,7 +1334,7 @@ public class DispositionServiceImpl extends ServiceBaseImpl
}
else if (firstDispositionActionDef.getPeriod() != null)
{
Date firstActionDate = calculateAsOfDate(record, firstDispositionActionDef, true);
Date firstActionDate = calculateAsOfDate(record, firstDispositionActionDef);
if (firstActionDate == null || (newDispositionActionDateAsOf != null
&& newDispositionActionDateAsOf.before(firstActionDate)))
{

View File

@@ -102,7 +102,7 @@ public class BroadcastDispositionActionDefinitionUpdateActionUnitTest
when(mockAction.getName()).thenReturn("mockAction");
// Set up the disposition service to return a known "disposition as of" date.
Date asOfDate = new Date();
when(mockDispositionService.calculateAsOfDate(CONTENT_NODE_REF, mockDispositionActionDefinition, false))
when(mockDispositionService.calculateAsOfDate(CONTENT_NODE_REF, mockDispositionActionDefinition))
.thenReturn(asOfDate);
// Call the method under test.
@@ -160,7 +160,7 @@ public class BroadcastDispositionActionDefinitionUpdateActionUnitTest
when(mockAction.getParameterValue(CHANGED_PROPERTIES)).thenReturn((Serializable) asList(PROP_DISPOSITION_PERIOD_PROPERTY));
// Set up the expected "as of" date.
Date newAsOfDate = new Date(123456789000L);
when(mockDispositionService.calculateAsOfDate(recordNode, mockActionDefinition, false)).thenReturn(newAsOfDate);
when(mockDispositionService.calculateAsOfDate(recordNode, mockActionDefinition)).thenReturn(newAsOfDate);
// Call the method under test.
action.executeImpl(mockAction, definitionNode);

View File

@@ -82,7 +82,7 @@ public class DispositionServiceImplUnitTest
when(mockPeriod.getNextDate(createdDate)).thenReturn(nextDate);
// Call the method under test.
Date asOfDate = dispositionService.calculateAsOfDate(CONTENT_NODE_REF, mockDispositionActionDefinition, true);
Date asOfDate = dispositionService.calculateAsOfDate(CONTENT_NODE_REF, mockDispositionActionDefinition);
assertEquals("Unexpected calculation for 'as of' date", nextDate, asOfDate);
}
@@ -95,7 +95,7 @@ public class DispositionServiceImplUnitTest
when(mockDispositionActionDefinition.getPeriod()).thenReturn(null);
// Call the method under test.
Date asOfDate = dispositionService.calculateAsOfDate(CONTENT_NODE_REF, mockDispositionActionDefinition, true);
Date asOfDate = dispositionService.calculateAsOfDate(CONTENT_NODE_REF, mockDispositionActionDefinition);
assertNull("It should not be possible to determine the 'as of' date.", asOfDate);
}