mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
RM-3386 Refactor duplicated disposition date code into method.
This commit is contained in:
@@ -217,7 +217,7 @@ public class DispositionServiceImpl extends ServiceBaseImpl
|
|||||||
DispositionActionDefinition nextDispositionActionDefinition = dispositionActionDefinitions.get(0);
|
DispositionActionDefinition nextDispositionActionDefinition = dispositionActionDefinitions.get(0);
|
||||||
|
|
||||||
// initialise the details of the next disposition action
|
// initialise the details of the next disposition action
|
||||||
initialiseDispositionAction(nodeRef, nextDispositionActionDefinition);
|
initialiseDispositionAction(nodeRef, nextDispositionActionDefinition, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -618,10 +618,11 @@ public class DispositionServiceImpl extends ServiceBaseImpl
|
|||||||
* Initialises the details of the next disposition action based on the details of a disposition
|
* Initialises the details of the next disposition action based on the details of a disposition
|
||||||
* action definition.
|
* action definition.
|
||||||
*
|
*
|
||||||
* @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 void initialiseDispositionAction(NodeRef nodeRef, DispositionActionDefinition dispositionActionDefinition)
|
private void initialiseDispositionAction(NodeRef nodeRef, DispositionActionDefinition dispositionActionDefinition, boolean allowContextFromAsOf)
|
||||||
{
|
{
|
||||||
// Create the properties
|
// Create the properties
|
||||||
Map<QName, Serializable> props = new HashMap<QName, Serializable>(10);
|
Map<QName, Serializable> props = new HashMap<QName, Serializable>(10);
|
||||||
@@ -635,7 +636,8 @@ 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)
|
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
|
// 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
|
||||||
@@ -898,63 +900,7 @@ public class DispositionServiceImpl extends ServiceBaseImpl
|
|||||||
nodeService.addAspect(nodeRef, ASPECT_DISPOSITION_LIFECYCLE, null);
|
nodeService.addAspect(nodeRef, ASPECT_DISPOSITION_LIFECYCLE, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create the properties
|
initialiseDispositionAction(nodeRef, nextDispositionActionDefinition, false);
|
||||||
Map<QName, Serializable> props = new HashMap<QName, Serializable>(10);
|
|
||||||
|
|
||||||
// Calculate the asOf date
|
|
||||||
Date asOfDate = null;
|
|
||||||
Period period = nextDispositionActionDefinition.getPeriod();
|
|
||||||
if (period != null)
|
|
||||||
{
|
|
||||||
Date contextDate = null;
|
|
||||||
|
|
||||||
// Get the period properties value
|
|
||||||
QName periodProperty = nextDispositionActionDefinition.getPeriodProperty();
|
|
||||||
if (periodProperty != null &&
|
|
||||||
!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) nodeService.getProperty(nodeRef, periodProperty);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// for now use 'NOW' as the default context date
|
|
||||||
// TODO set the default period property ... cut off date or last disposition date depending on context
|
|
||||||
contextDate = new Date();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Calculate the as of date
|
|
||||||
if (contextDate != null)
|
|
||||||
{
|
|
||||||
asOfDate = period.getNextDate(contextDate);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Set the property values
|
|
||||||
props.put(PROP_DISPOSITION_ACTION_ID, nextDispositionActionDefinition.getId());
|
|
||||||
props.put(PROP_DISPOSITION_ACTION, nextDispositionActionDefinition.getName());
|
|
||||||
if (asOfDate != null)
|
|
||||||
{
|
|
||||||
props.put(PROP_DISPOSITION_AS_OF, asOfDate);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create a new disposition action object
|
|
||||||
NodeRef dispositionActionNodeRef = nodeService.createNode(
|
|
||||||
nodeRef,
|
|
||||||
ASSOC_NEXT_DISPOSITION_ACTION,
|
|
||||||
ASSOC_NEXT_DISPOSITION_ACTION,
|
|
||||||
TYPE_DISPOSITION_ACTION,
|
|
||||||
props).getChildRef();
|
|
||||||
DispositionAction da = new DispositionActionImpl(serviceRegistry, dispositionActionNodeRef);
|
|
||||||
|
|
||||||
// Create the events
|
|
||||||
List<RecordsManagementEvent> events = nextDispositionActionDefinition.getEvents();
|
|
||||||
for (RecordsManagementEvent event : events)
|
|
||||||
{
|
|
||||||
// For every event create an entry on the action
|
|
||||||
da.addEventCompletionDetails(event);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1009,7 +955,7 @@ public class DispositionServiceImpl extends ServiceBaseImpl
|
|||||||
recordFolderService.closeRecordFolder(nodeRef);
|
recordFolderService.closeRecordFolder(nodeRef);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
Reference in New Issue
Block a user