I've changed the method that calculates the as of date to take in consideration the record creation date instead of the action creation date.

This commit is contained in:
roxana
2016-10-11 12:28:07 +03:00
parent d13850dd6e
commit d9bb9b2e00
3 changed files with 12 additions and 11 deletions

View File

@@ -238,11 +238,12 @@ public interface DispositionService
* Gets date of the disposition action for the given * Gets date of the disposition action for the given
* disposition schedule with the given action name * disposition schedule with the given action name
* *
* @param record
* @param dispositionSchedule nodeRef * @param dispositionSchedule nodeRef
* @param dispositionActionName * @param dispositionActionName
* @return date * @return date
*/ */
Date getDispositionActionDate(NodeRef dispositionSchedule, String dispositionActionName); Date getDispositionActionDate(NodeRef record, NodeRef dispositionSchedule, String dispositionActionName);
/** /**
* Compute the "disposition as of" date (if necessary) for a disposition action and a node. * Compute the "disposition as of" date (if necessary) for a disposition action and a node.

View File

@@ -1004,7 +1004,7 @@ public class DispositionServiceImpl extends ServiceBaseImpl
} }
} }
public Date getDispositionActionDate(NodeRef dispositionSchedule, String dispositionActionName) public Date getDispositionActionDate(NodeRef record, NodeRef dispositionSchedule, String dispositionActionName)
{ {
List<ChildAssociationRef> assocs = nodeService.getChildAssocs(dispositionSchedule); List<ChildAssociationRef> assocs = nodeService.getChildAssocs(dispositionSchedule);
if (assocs != null && assocs.size() > 0) if (assocs != null && assocs.size() > 0)
@@ -1015,12 +1015,12 @@ public class DispositionServiceImpl extends ServiceBaseImpl
{ {
Date newAsOfDate = null; Date newAsOfDate = null;
Period dispositionPeriod = (Period) nodeService.getProperty(assoc.getChildRef(), PROP_DISPOSITION_PERIOD); Period dispositionPeriod = (Period) nodeService.getProperty(assoc.getChildRef(), PROP_DISPOSITION_PERIOD);
Date actionCreationDate = (Date)nodeService.getProperty(assoc.getChildRef(), ContentModel.PROP_CREATED); Date recordCreationDate = (Date)nodeService.getProperty(record, ContentModel.PROP_CREATED);
if (dispositionPeriod != null) if (dispositionPeriod != null)
{ {
// calculate the new as of date as we have been provided a new period // calculate the new as of date as we have been provided a new period
newAsOfDate = dispositionPeriod.getNextDate(actionCreationDate); newAsOfDate = dispositionPeriod.getNextDate(recordCreationDate);
} }
return newAsOfDate; return newAsOfDate;
} }
@@ -1093,11 +1093,11 @@ public class DispositionServiceImpl extends ServiceBaseImpl
if (nextDispositionAction == null) if (nextDispositionAction == null)
{ {
return getFirstDispositionAction(recordFolders); return getFirstDispositionAction(record, recordFolders);
} }
else else
{ {
return getNextDispositionAction(recordFolders, nextDispositionAction); return getNextDispositionAction(record, recordFolders, nextDispositionAction);
} }
} }
@@ -1107,7 +1107,7 @@ public class DispositionServiceImpl extends ServiceBaseImpl
* @param nextDispositionAction * @param nextDispositionAction
* @return next disposition action and the associated disposition schedule * @return next disposition action and the associated disposition schedule
*/ */
private NextActionFromDisposition getNextDispositionAction(List<NodeRef> recordFolders, DispositionAction nextDispositionAction) private NextActionFromDisposition getNextDispositionAction(NodeRef record, List<NodeRef> recordFolders, DispositionAction nextDispositionAction)
{ {
String recordNextDispositionActionName = nextDispositionAction.getName(); String recordNextDispositionActionName = nextDispositionAction.getName();
Date recordNextDispositionActionDate = nextDispositionAction.getAsOfDate(); Date recordNextDispositionActionDate = nextDispositionAction.getAsOfDate();
@@ -1119,7 +1119,7 @@ public class DispositionServiceImpl extends ServiceBaseImpl
NodeRef dsNodeRef = getDispositionScheduleImpl(folder); NodeRef dsNodeRef = getDispositionScheduleImpl(folder);
if (dsNodeRef != null) if (dsNodeRef != null)
{ {
Date dispActionDate = getDispositionActionDate(dsNodeRef, recordNextDispositionActionName); Date dispActionDate = getDispositionActionDate(record, dsNodeRef, recordNextDispositionActionName);
if (nextDispositionActionDate == null || nextDispositionActionDate.before(dispActionDate)) if (nextDispositionActionDate == null || nextDispositionActionDate.before(dispActionDate))
{ {
nextDispositionActionDate = dispActionDate; nextDispositionActionDate = dispActionDate;
@@ -1150,7 +1150,7 @@ public class DispositionServiceImpl extends ServiceBaseImpl
* @param recordFolders * @param recordFolders
* @return next disposition action and the associated disposition schedule * @return next disposition action and the associated disposition schedule
*/ */
private NextActionFromDisposition getFirstDispositionAction(List<NodeRef> recordFolders) private NextActionFromDisposition getFirstDispositionAction(NodeRef record, List<NodeRef> recordFolders)
{ {
NodeRef newAction = null; NodeRef newAction = null;
String newDispositionActionName = null; String newDispositionActionName = null;
@@ -1171,7 +1171,7 @@ public class DispositionServiceImpl extends ServiceBaseImpl
{ {
newAction = firstAction; newAction = firstAction;
newDispositionActionName = (String)nodeService.getProperty(newAction, PROP_DISPOSITION_ACTION_NAME); newDispositionActionName = (String)nodeService.getProperty(newAction, PROP_DISPOSITION_ACTION_NAME);
newDispositionActionDateAsOf = getDispositionActionDate(folderDS, newDispositionActionName); newDispositionActionDateAsOf = getDispositionActionDate(record, folderDS, newDispositionActionName);
} }
else if (firstDispositionAction.getAsOfDate() != null && newDispositionActionDateAsOf.before(firstDispositionAction.getAsOfDate())) else if (firstDispositionAction.getAsOfDate() != null && newDispositionActionDateAsOf.before(firstDispositionAction.getAsOfDate()))
{ {

View File

@@ -98,7 +98,7 @@ public class UpdateNextDispositionActionTest extends BaseRMTestCase
// set the disposition as of date to now on the record // set the disposition as of date to now on the record
rmActionService.executeRecordsManagementAction(record, rmActionService.executeRecordsManagementAction(record,
EditDispositionActionAsOfDateAction.NAME, EditDispositionActionAsOfDateAction.NAME,
Collections.singletonMap(EditDispositionActionAsOfDateAction.PARAM_AS_OF_DATE, new Date())); Collections.singletonMap(EditDispositionActionAsOfDateAction.PARAM_AS_OF_DATE, (Serializable)new Date()));
// cut off // cut off
rmActionService.executeRecordsManagementAction(record, CutOffAction.NAME, null); rmActionService.executeRecordsManagementAction(record, CutOffAction.NAME, null);