use of org.alfresco.module.org_alfresco_module_rm.disposition.DispositionActionDefinition in project records-management by Alfresco.
the class BroadcastDispositionActionDefinitionUpdateAction method persistPeriodChanges.
/**
* Persists any changes made to the period on the given disposition action
* definition on the given next action.
*
* @param dispositionActionDef The disposition action definition node
* @param nextAction The next disposition action
*/
protected void persistPeriodChanges(NodeRef dispositionActionDef, DispositionAction nextAction) {
NodeRef dispositionedNode = getNodeService().getPrimaryParent(nextAction.getNodeRef()).getParentRef();
DispositionActionDefinition definition = nextAction.getDispositionActionDefinition();
Date newAsOfDate = getDispositionService().calculateAsOfDate(dispositionedNode, definition);
if (logger.isDebugEnabled()) {
logger.debug("Set disposition as of date for next action '" + nextAction.getName() + "' (" + nextAction.getNodeRef() + ") to: " + newAsOfDate);
}
getNodeService().setProperty(nextAction.getNodeRef(), PROP_DISPOSITION_AS_OF, newAsOfDate);
}
use of org.alfresco.module.org_alfresco_module_rm.disposition.DispositionActionDefinition in project records-management by Alfresco.
the class BroadcastDispositionActionDefinitionUpdateAction method rollupSearchProperties.
/**
* Manually update the rolled up search properties
*
* @param disposableItem disposable item
*/
private void rollupSearchProperties(NodeRef disposableItem) {
DispositionAction da = getDispositionService().getNextDispositionAction(disposableItem);
if (da != null) {
Map<QName, Serializable> props = getNodeService().getProperties(disposableItem);
props.put(PROP_RS_DISPOSITION_ACTION_NAME, da.getName());
props.put(PROP_RS_DISPOSITION_ACTION_AS_OF, da.getAsOfDate());
props.put(PROP_RS_DISPOSITION_EVENTS_ELIGIBLE, getNodeService().getProperty(da.getNodeRef(), PROP_DISPOSITION_EVENTS_ELIGIBLE));
DispositionActionDefinition daDefinition = da.getDispositionActionDefinition();
Period period = daDefinition.getPeriod();
if (period != null) {
props.put(PROP_RS_DISPOSITION_PERIOD, period.getPeriodType());
props.put(PROP_RS_DISPOSITION_PERIOD_EXPRESSION, period.getExpression());
} else {
props.put(PROP_RS_DISPOSITION_PERIOD, null);
props.put(PROP_RS_DISPOSITION_PERIOD_EXPRESSION, null);
}
List<EventCompletionDetails> events = da.getEventCompletionDetails();
List<String> list = new ArrayList<String>(events.size());
for (EventCompletionDetails event : events) {
list.add(event.getEventName());
}
props.put(PROP_RS_DISPOSITION_EVENTS, (Serializable) list);
getNodeService().setProperties(disposableItem, props);
}
}
use of org.alfresco.module.org_alfresco_module_rm.disposition.DispositionActionDefinition in project records-management by Alfresco.
the class HasDispositionActionEvaluator method evaluateImpl.
@Override
protected boolean evaluateImpl(ActionCondition actionCondition, NodeRef actionedUponNodeRef) {
boolean result = false;
String position = ((QName) actionCondition.getParameterValue(PARAM_DISPOSITION_ACTION_RELATIVE_POSITION)).getLocalName();
String action = ((QName) actionCondition.getParameterValue(PARAM_DISPOSITION_ACTION)).getLocalName();
if (dispositionService.isDisposableItem(actionedUponNodeRef)) {
if (position.equals(DispositionActionRelativePositions.ANY.toString())) {
DispositionSchedule dispositionSchedule = dispositionService.getDispositionSchedule(actionedUponNodeRef);
if (dispositionSchedule != null) {
for (DispositionActionDefinition dispositionActionDefinition : dispositionSchedule.getDispositionActionDefinitions()) {
if (dispositionActionDefinition.getName().equals(action)) {
result = true;
break;
}
}
}
} else if (position.equals(DispositionActionRelativePositions.NEXT.toString())) {
DispositionAction nextDispositionAction = dispositionService.getNextDispositionAction(actionedUponNodeRef);
if (nextDispositionAction != null) {
// Get the disposition actions name
String actionName = nextDispositionAction.getName();
if (actionName.equals(action)) {
result = true;
}
}
} else if (position.equals(DispositionActionRelativePositions.PREVIOUS.toString())) {
DispositionAction lastCompletedDispositionAction = dispositionService.getLastCompletedDispostionAction(actionedUponNodeRef);
if (lastCompletedDispositionAction != null) {
// Get the disposition actions name
String actionName = lastCompletedDispositionAction.getName();
if (actionName.equals(action)) {
result = true;
}
}
}
}
return result;
}
use of org.alfresco.module.org_alfresco_module_rm.disposition.DispositionActionDefinition in project records-management by Alfresco.
the class BroadcastDispositionActionDefinitionUpdateActionUnitTest method testChangePeriodProperty.
/**
* Check that changing the period property triggers a recalculation of the "disposition as of" date.
* <p>
* Set up a disposition action definition node under a schedule defintion node, under a category node. Create a
* record whose next action is an instance of the action definition. Check that if the "period property" of the
* action definition changes then the "disposition as of" date is recalculated and persisted against the node of the
* next action.
*/
@Test
public void testChangePeriodProperty() {
// Set up the action definition node.
String definitionNodeId = "definitionNodeId";
NodeRef definitionNode = new NodeRef("definition://node/" + definitionNodeId);
DispositionSchedule mockDispositionSchedule = mock(DispositionSchedule.class);
when(mockDispositionSchedule.getNodeRef()).thenReturn(definitionNode);
when(mockNodeService.getType(definitionNode)).thenReturn(TYPE_DISPOSITION_ACTION_DEFINITION);
// Set up the schedule definition node hierarchy.
NodeRef categoryNode = new NodeRef("category://node/");
NodeRef scheduleNode = new NodeRef("schedule://node/");
ChildAssociationRef scheduleDefinitionRelationship = new ChildAssociationRef(null, scheduleNode, null, definitionNode);
when(mockNodeService.getPrimaryParent(definitionNode)).thenReturn(scheduleDefinitionRelationship);
ChildAssociationRef categoryScheduleRelationship = new ChildAssociationRef(null, categoryNode, null, scheduleNode);
when(mockNodeService.getPrimaryParent(scheduleNode)).thenReturn(categoryScheduleRelationship);
// Set up the record/step relationship.
NodeRef recordNode = new NodeRef("record://node/");
NodeRef stepNode = new NodeRef("step://node/");
ChildAssociationRef recordStepRelationship = new ChildAssociationRef(null, recordNode, null, stepNode);
when(mockNodeService.getPrimaryParent(stepNode)).thenReturn(recordStepRelationship);
// Set up the disposition schedule.
when(mockDispositionService.getAssociatedDispositionSchedule(categoryNode)).thenReturn(mockDispositionSchedule);
when(mockDispositionService.getDisposableItems(mockDispositionSchedule)).thenReturn(asList(recordNode));
when(mockDispositionService.getDispositionSchedule(recordNode)).thenReturn(mockDispositionSchedule);
// Set up the record.
when(mockNodeService.hasAspect(recordNode, ASPECT_DISPOSITION_LIFECYCLE)).thenReturn(true);
// Set up the next disposition action.
DispositionAction nextAction = mock(DispositionAction.class);
when(nextAction.getId()).thenReturn(definitionNodeId);
when(nextAction.getNodeRef()).thenReturn(stepNode);
when(mockDispositionService.getNextDispositionAction(recordNode)).thenReturn(nextAction);
DispositionActionDefinition mockActionDefinition = mock(DispositionActionDefinition.class);
when(nextAction.getDispositionActionDefinition()).thenReturn(mockActionDefinition);
// Set up the action so that it looks like the period property has been changed.
Action mockAction = mock(Action.class);
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)).thenReturn(newAsOfDate);
// Call the method under test.
action.executeImpl(mockAction, definitionNode);
// Check that the "as of" date is updated.
verify(mockNodeService).setProperty(stepNode, PROP_DISPOSITION_AS_OF, newAsOfDate);
}
use of org.alfresco.module.org_alfresco_module_rm.disposition.DispositionActionDefinition in project records-management by Alfresco.
the class DispositionActionDefinitionDelete method executeImpl.
/*
* @see org.alfresco.web.scripts.DeclarativeWebScript#executeImpl(org.alfresco.web.scripts.WebScriptRequest, org.alfresco.web.scripts.Status, org.alfresco.web.scripts.Cache)
*/
@Override
protected Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache) {
// parse the request to retrieve the schedule object
DispositionSchedule schedule = parseRequestForSchedule(req);
// parse the request to retrieve the action definition object
DispositionActionDefinition actionDef = parseRequestForActionDefinition(req, schedule);
// remove the action definition from the schedule
removeDispositionActionDefinitions(schedule, actionDef);
// return the disposition schedule model
return getDispositionScheduleModel(req);
}
Aggregations