Search in sources :

Example 6 with DispositionAction

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;
}
Also used : QName(org.alfresco.service.namespace.QName) DispositionSchedule(org.alfresco.module.org_alfresco_module_rm.disposition.DispositionSchedule) DispositionActionDefinition(org.alfresco.module.org_alfresco_module_rm.disposition.DispositionActionDefinition) DispositionAction(org.alfresco.module.org_alfresco_module_rm.disposition.DispositionAction)

Example 7 with DispositionAction

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);
}
Also used : NodeRef(org.alfresco.service.cmr.repository.NodeRef) Action(org.alfresco.service.cmr.action.Action) DispositionAction(org.alfresco.module.org_alfresco_module_rm.disposition.DispositionAction) DispositionSchedule(org.alfresco.module.org_alfresco_module_rm.disposition.DispositionSchedule) DispositionActionDefinition(org.alfresco.module.org_alfresco_module_rm.disposition.DispositionActionDefinition) ChildAssociationRef(org.alfresco.service.cmr.repository.ChildAssociationRef) DispositionAction(org.alfresco.module.org_alfresco_module_rm.disposition.DispositionAction) Date(java.util.Date) Test(org.junit.Test)

Example 8 with DispositionAction

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;
            }
        }
    }
}
Also used : Serializable(java.io.Serializable) HashMap(java.util.HashMap) DispositionAction(org.alfresco.module.org_alfresco_module_rm.disposition.DispositionAction) Date(java.util.Date)

Example 9 with DispositionAction

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());
}
Also used : Serializable(java.io.Serializable) HashMap(java.util.HashMap) Date(java.util.Date) AuthenticationUtil(org.alfresco.repo.security.authentication.AuthenticationUtil) DispositionAction(org.alfresco.module.org_alfresco_module_rm.disposition.DispositionAction) Behaviour(org.alfresco.repo.policy.annotation.Behaviour)

Example 10 with DispositionAction

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;
}
Also used : DispositionAction(org.alfresco.module.org_alfresco_module_rm.disposition.DispositionAction)

Aggregations

DispositionAction (org.alfresco.module.org_alfresco_module_rm.disposition.DispositionAction)23 NodeRef (org.alfresco.service.cmr.repository.NodeRef)10 Date (java.util.Date)8 Serializable (java.io.Serializable)6 DispositionActionDefinition (org.alfresco.module.org_alfresco_module_rm.disposition.DispositionActionDefinition)6 QName (org.alfresco.service.namespace.QName)6 HashMap (java.util.HashMap)5 AlfrescoRuntimeException (org.alfresco.error.AlfrescoRuntimeException)4 ArrayList (java.util.ArrayList)2 Map (java.util.Map)2 DispositionSchedule (org.alfresco.module.org_alfresco_module_rm.disposition.DispositionSchedule)2 EventCompletionDetails (org.alfresco.module.org_alfresco_module_rm.event.EventCompletionDetails)2 ChildAssociationRef (org.alfresco.service.cmr.repository.ChildAssociationRef)2 Period (org.alfresco.service.cmr.repository.Period)2 Test (org.junit.Test)2 Capability (org.alfresco.module.org_alfresco_module_rm.capability.Capability)1 DispositionActionImpl (org.alfresco.module.org_alfresco_module_rm.disposition.DispositionActionImpl)1 Behaviour (org.alfresco.repo.policy.annotation.Behaviour)1 AuthenticationUtil (org.alfresco.repo.security.authentication.AuthenticationUtil)1 Action (org.alfresco.service.cmr.action.Action)1