use of org.alfresco.module.org_alfresco_module_rm.disposition.DispositionAction 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.DispositionAction 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.DispositionAction in project records-management by Alfresco.
the class OnReferencedRecordActionedUpon method doEventComplete.
private void doEventComplete(NodeRef nodeRef) {
DispositionAction da = dispositionService.getNextDispositionAction(nodeRef);
if (da != null) {
List<EventCompletionDetails> events = da.getEventCompletionDetails();
for (EventCompletionDetails event : events) {
RecordsManagementEvent rmEvent = getRecordsManagementEventService().getEvent(event.getEventName());
if (!event.isEventComplete() && rmEvent.getType().equals(getName())) {
// Complete the event
Map<String, Serializable> params = new HashMap<String, Serializable>(3);
params.put(CompleteEventAction.PARAM_EVENT_NAME, event.getEventName());
params.put(CompleteEventAction.PARAM_EVENT_COMPLETED_BY, AuthenticationUtil.getFullyAuthenticatedUser());
params.put(CompleteEventAction.PARAM_EVENT_COMPLETED_AT, new Date());
recordsManagementActionService.executeRecordsManagementAction(nodeRef, "completeEvent", params);
break;
}
}
}
}
use of org.alfresco.module.org_alfresco_module_rm.disposition.DispositionAction in project records-management by Alfresco.
the class OnReferenceCreateEventType method onCreateReference.
/**
* @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementPolicies.OnCreateReference#onCreateReference(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.namespace.QName)
*/
@Override
@Behaviour(kind = BehaviourKind.CLASS, type = "rma:record", notificationFrequency = NotificationFrequency.TRANSACTION_COMMIT)
public void onCreateReference(final NodeRef fromNodeRef, final NodeRef toNodeRef, final QName reference) {
AuthenticationUtil.RunAsWork<Object> work = new AuthenticationUtil.RunAsWork<Object>() {
public Object doWork() {
// Check whether it is the reference type we care about
if (reference.equals(OnReferenceCreateEventType.this.reference)) {
DispositionAction da = dispositionService.getNextDispositionAction(toNodeRef);
if (da != null) {
List<EventCompletionDetails> events = da.getEventCompletionDetails();
for (EventCompletionDetails event : events) {
RecordsManagementEvent rmEvent = getRecordsManagementEventService().getEvent(event.getEventName());
if (!event.isEventComplete() && rmEvent.getType().equals(getName())) {
// Complete the event
Map<String, Serializable> params = new HashMap<String, Serializable>(3);
params.put(CompleteEventAction.PARAM_EVENT_NAME, event.getEventName());
params.put(CompleteEventAction.PARAM_EVENT_COMPLETED_BY, AuthenticationUtil.getFullyAuthenticatedUser());
params.put(CompleteEventAction.PARAM_EVENT_COMPLETED_AT, new Date());
recordsManagementActionService.executeRecordsManagementAction(toNodeRef, "completeEvent", params);
break;
}
}
}
}
return null;
}
};
AuthenticationUtil.runAs(work, AuthenticationUtil.getAdminUserName());
}
use of org.alfresco.module.org_alfresco_module_rm.disposition.DispositionAction in project records-management by Alfresco.
the class IsScheduledCapabilityCondition method evaluateImpl.
/**
* @see org.alfresco.module.org_alfresco_module_rm.capability.declarative.CapabilityCondition#evaluate(org.alfresco.service.cmr.repository.NodeRef)
*/
@Override
public boolean evaluateImpl(NodeRef nodeRef) {
boolean result = false;
DispositionAction nextDispositionAction = dispositionService.getNextDispositionAction(nodeRef);
if (nextDispositionAction != null) {
// Get the disposition actions name
String actionName = nextDispositionAction.getName();
if (actionName.equals(dispositionAction) && dispositionService.isNextDispositionActionEligible(nodeRef)) {
result = true;
}
}
return result;
}
Aggregations