mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
RM-5733 Changed the way retention as of date is calculated.
This commit is contained in:
@@ -253,7 +253,7 @@ public class BroadcastDispositionActionDefinitionUpdateAction extends RMActionEx
|
|||||||
{
|
{
|
||||||
NodeRef dispositionedNode = getNodeService().getPrimaryParent(nextAction.getNodeRef()).getParentRef();
|
NodeRef dispositionedNode = getNodeService().getPrimaryParent(nextAction.getNodeRef()).getParentRef();
|
||||||
DispositionActionDefinition definition = nextAction.getDispositionActionDefinition();
|
DispositionActionDefinition definition = nextAction.getDispositionActionDefinition();
|
||||||
Date newAsOfDate = getDispositionService().calculateAsOfDate(dispositionedNode, definition, false);
|
Date newAsOfDate = getDispositionService().calculateAsOfDate(dispositionedNode, definition);
|
||||||
|
|
||||||
if (logger.isDebugEnabled())
|
if (logger.isDebugEnabled())
|
||||||
{
|
{
|
||||||
|
@@ -260,11 +260,9 @@ public interface DispositionService
|
|||||||
*
|
*
|
||||||
* @param nodeRef The node which the schedule applies to.
|
* @param nodeRef The node which the schedule applies to.
|
||||||
* @param dispositionActionDefinition The definition of the disposition action.
|
* @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.
|
* @return The new "disposition as of" date.
|
||||||
*/
|
*/
|
||||||
Date calculateAsOfDate(NodeRef nodeRef, DispositionActionDefinition dispositionActionDefinition,
|
Date calculateAsOfDate(NodeRef nodeRef, DispositionActionDefinition dispositionActionDefinition);
|
||||||
boolean allowContextFromAsOf);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the origin disposition schedule for the record, not the calculated one
|
* Gets the origin disposition schedule for the record, not the calculated one
|
||||||
|
@@ -699,7 +699,6 @@ public class DispositionServiceImpl extends ServiceBaseImpl
|
|||||||
*
|
*
|
||||||
* @param nodeRef node reference
|
* @param nodeRef node reference
|
||||||
* @param dispositionActionDefinition disposition action definition
|
* @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)
|
private DispositionAction initialiseDispositionAction(NodeRef nodeRef, DispositionActionDefinition dispositionActionDefinition, boolean allowContextFromAsOf)
|
||||||
{
|
{
|
||||||
@@ -712,7 +711,7 @@ public class DispositionServiceImpl extends ServiceBaseImpl
|
|||||||
// Create the properties
|
// Create the properties
|
||||||
Map<QName, Serializable> props = new HashMap<QName, Serializable>(10);
|
Map<QName, Serializable> props = new HashMap<QName, Serializable>(10);
|
||||||
|
|
||||||
Date asOfDate = calculateAsOfDate(nodeRef, dispositionActionDefinition, allowContextFromAsOf);
|
Date asOfDate = calculateAsOfDate(nodeRef, dispositionActionDefinition);
|
||||||
|
|
||||||
// Set the property values
|
// Set the property values
|
||||||
props.put(PROP_DISPOSITION_ACTION_ID, dispositionActionDefinition.getId());
|
props.put(PROP_DISPOSITION_ACTION_ID, dispositionActionDefinition.getId());
|
||||||
@@ -750,8 +749,7 @@ public class DispositionServiceImpl extends ServiceBaseImpl
|
|||||||
* @return The new "disposition as of" date.
|
* @return The new "disposition as of" date.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Date calculateAsOfDate(NodeRef nodeRef, DispositionActionDefinition dispositionActionDefinition,
|
public Date calculateAsOfDate(NodeRef nodeRef, DispositionActionDefinition dispositionActionDefinition)
|
||||||
boolean allowContextFromAsOf)
|
|
||||||
{
|
{
|
||||||
// Calculate the asOf date
|
// Calculate the asOf date
|
||||||
Date asOfDate = null;
|
Date asOfDate = null;
|
||||||
@@ -762,13 +760,30 @@ public class DispositionServiceImpl extends ServiceBaseImpl
|
|||||||
|
|
||||||
// Get the period properties value
|
// Get the period properties value
|
||||||
QName periodProperty = dispositionActionDefinition.getPeriodProperty();
|
QName periodProperty = dispositionActionDefinition.getPeriodProperty();
|
||||||
if (periodProperty != null && (allowContextFromAsOf
|
if (periodProperty != null)
|
||||||
|| !RecordsManagementModel.PROP_DISPOSITION_AS_OF.equals(periodProperty)))
|
// && (allowContextFromAsOf
|
||||||
|
// || !RecordsManagementModel.PROP_DISPOSITION_AS_OF.equals(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
|
// 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
|
// when the value of the period property is set
|
||||||
contextDate = (Date)this.nodeService.getProperty(nodeRef, periodProperty);
|
contextDate = (Date)this.nodeService.getProperty(nodeRef, periodProperty);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (period.getPeriodType().equals(Immediately.PERIOD_TYPE))
|
if (period.getPeriodType().equals(Immediately.PERIOD_TYPE))
|
||||||
@@ -1097,7 +1112,7 @@ public class DispositionServiceImpl extends ServiceBaseImpl
|
|||||||
if (assoc != null && assoc.getQName().getLocalName().contains(dispositionActionName))
|
if (assoc != null && assoc.getQName().getLocalName().contains(dispositionActionName))
|
||||||
{
|
{
|
||||||
DispositionActionDefinition actionDefinition = ds.getDispositionActionDefinition(assoc.getChildRef().getId());
|
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)
|
else if (firstDispositionActionDef.getPeriod() != null)
|
||||||
{
|
{
|
||||||
Date firstActionDate = calculateAsOfDate(record, firstDispositionActionDef, true);
|
Date firstActionDate = calculateAsOfDate(record, firstDispositionActionDef);
|
||||||
if (firstActionDate == null || (newDispositionActionDateAsOf != null
|
if (firstActionDate == null || (newDispositionActionDateAsOf != null
|
||||||
&& newDispositionActionDateAsOf.before(firstActionDate)))
|
&& newDispositionActionDateAsOf.before(firstActionDate)))
|
||||||
{
|
{
|
||||||
|
@@ -102,7 +102,7 @@ public class BroadcastDispositionActionDefinitionUpdateActionUnitTest
|
|||||||
when(mockAction.getName()).thenReturn("mockAction");
|
when(mockAction.getName()).thenReturn("mockAction");
|
||||||
// Set up the disposition service to return a known "disposition as of" date.
|
// Set up the disposition service to return a known "disposition as of" date.
|
||||||
Date asOfDate = new Date();
|
Date asOfDate = new Date();
|
||||||
when(mockDispositionService.calculateAsOfDate(CONTENT_NODE_REF, mockDispositionActionDefinition, false))
|
when(mockDispositionService.calculateAsOfDate(CONTENT_NODE_REF, mockDispositionActionDefinition))
|
||||||
.thenReturn(asOfDate);
|
.thenReturn(asOfDate);
|
||||||
|
|
||||||
// Call the method under test.
|
// Call the method under test.
|
||||||
@@ -160,7 +160,7 @@ public class BroadcastDispositionActionDefinitionUpdateActionUnitTest
|
|||||||
when(mockAction.getParameterValue(CHANGED_PROPERTIES)).thenReturn((Serializable) asList(PROP_DISPOSITION_PERIOD_PROPERTY));
|
when(mockAction.getParameterValue(CHANGED_PROPERTIES)).thenReturn((Serializable) asList(PROP_DISPOSITION_PERIOD_PROPERTY));
|
||||||
// Set up the expected "as of" date.
|
// Set up the expected "as of" date.
|
||||||
Date newAsOfDate = new Date(123456789000L);
|
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.
|
// Call the method under test.
|
||||||
action.executeImpl(mockAction, definitionNode);
|
action.executeImpl(mockAction, definitionNode);
|
||||||
|
@@ -82,7 +82,7 @@ public class DispositionServiceImplUnitTest
|
|||||||
when(mockPeriod.getNextDate(createdDate)).thenReturn(nextDate);
|
when(mockPeriod.getNextDate(createdDate)).thenReturn(nextDate);
|
||||||
|
|
||||||
// Call the method under test.
|
// 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);
|
assertEquals("Unexpected calculation for 'as of' date", nextDate, asOfDate);
|
||||||
}
|
}
|
||||||
@@ -95,7 +95,7 @@ public class DispositionServiceImplUnitTest
|
|||||||
when(mockDispositionActionDefinition.getPeriod()).thenReturn(null);
|
when(mockDispositionActionDefinition.getPeriod()).thenReturn(null);
|
||||||
|
|
||||||
// Call the method under test.
|
// 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);
|
assertNull("It should not be possible to determine the 'as of' date.", asOfDate);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user