Search in sources :

Example 6 with DispositionActionDefinition

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

Example 7 with DispositionActionDefinition

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);
    }
}
Also used : Serializable(java.io.Serializable) QName(org.alfresco.service.namespace.QName) EventCompletionDetails(org.alfresco.module.org_alfresco_module_rm.event.EventCompletionDetails) ArrayList(java.util.ArrayList) Period(org.alfresco.service.cmr.repository.Period) DispositionActionDefinition(org.alfresco.module.org_alfresco_module_rm.disposition.DispositionActionDefinition) DispositionAction(org.alfresco.module.org_alfresco_module_rm.disposition.DispositionAction)

Example 8 with DispositionActionDefinition

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;
}
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 9 with DispositionActionDefinition

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);
}
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 10 with DispositionActionDefinition

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

Aggregations

DispositionActionDefinition (org.alfresco.module.org_alfresco_module_rm.disposition.DispositionActionDefinition)19 DispositionSchedule (org.alfresco.module.org_alfresco_module_rm.disposition.DispositionSchedule)10 QName (org.alfresco.service.namespace.QName)7 Serializable (java.io.Serializable)6 HashMap (java.util.HashMap)6 DispositionAction (org.alfresco.module.org_alfresco_module_rm.disposition.DispositionAction)6 NodeRef (org.alfresco.service.cmr.repository.NodeRef)4 Date (java.util.Date)3 WebScriptException (org.springframework.extensions.webscripts.WebScriptException)3 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 Map (java.util.Map)2 ChildAssociationRef (org.alfresco.service.cmr.repository.ChildAssociationRef)2 Period (org.alfresco.service.cmr.repository.Period)2 JSONException (org.json.JSONException)2 JSONObject (org.json.JSONObject)2 JSONTokener (org.json.JSONTokener)2 Test (org.junit.Test)2 ImmutableMap (com.google.common.collect.ImmutableMap)1 AlfrescoRuntimeException (org.alfresco.error.AlfrescoRuntimeException)1