Search in sources :

Example 11 with DispositionActionDefinition

use of org.alfresco.module.org_alfresco_module_rm.disposition.DispositionActionDefinition in project records-management by Alfresco.

the class MayBeScheduledCapabilityCondition 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;
    DispositionSchedule dispositionSchedule = dispositionService.getDispositionSchedule(nodeRef);
    if (dispositionSchedule != null && checkDispositionLevel(nodeRef, dispositionSchedule)) {
        for (DispositionActionDefinition dispositionActionDefinition : dispositionSchedule.getDispositionActionDefinitions()) {
            if (dispositionActionDefinition.getName().equals(dispositionAction)) {
                result = true;
                break;
            }
        }
    }
    return result;
}
Also used : DispositionSchedule(org.alfresco.module.org_alfresco_module_rm.disposition.DispositionSchedule) DispositionActionDefinition(org.alfresco.module.org_alfresco_module_rm.disposition.DispositionActionDefinition)

Example 12 with DispositionActionDefinition

use of org.alfresco.module.org_alfresco_module_rm.disposition.DispositionActionDefinition in project records-management by Alfresco.

the class DispositionActionDefinitionDelete method removeDispositionActionDefinitions.

/**
 * Helper method to remove a disposition action definition and the following definition(s)
 *
 * @param schedule The disposition schedule
 * @param actionDef The disposition action definition
 */
private void removeDispositionActionDefinitions(DispositionSchedule schedule, DispositionActionDefinition actionDef) {
    int index = actionDef.getIndex();
    List<DispositionActionDefinition> dispositionActionDefinitions = schedule.getDispositionActionDefinitions();
    for (DispositionActionDefinition dispositionActionDefinition : dispositionActionDefinitions) {
        if (dispositionActionDefinition.getIndex() >= index) {
            getDispositionService().removeDispositionActionDefinition(schedule, dispositionActionDefinition);
        }
    }
}
Also used : DispositionActionDefinition(org.alfresco.module.org_alfresco_module_rm.disposition.DispositionActionDefinition)

Example 13 with DispositionActionDefinition

use of org.alfresco.module.org_alfresco_module_rm.disposition.DispositionActionDefinition in project records-management by Alfresco.

the class DispositionActionDefinitionPut 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);
    // retrieve the rest of the post body and update the action definition
    JSONObject json = null;
    try {
        json = new JSONObject(new JSONTokener(req.getContent().getContent()));
        actionDef = updateActionDefinition(actionDef, json);
    } catch (IOException iox) {
        throw new WebScriptException(Status.STATUS_BAD_REQUEST, "Could not read content from req.", iox);
    } catch (JSONException je) {
        throw new WebScriptException(Status.STATUS_BAD_REQUEST, "Could not parse JSON from req.", je);
    }
    // create model object with just the action data
    Map<String, Object> model = new HashMap<String, Object>(1);
    model.put("action", createActionDefModel(actionDef, req.getURL()));
    return model;
}
Also used : JSONTokener(org.json.JSONTokener) JSONObject(org.json.JSONObject) WebScriptException(org.springframework.extensions.webscripts.WebScriptException) HashMap(java.util.HashMap) DispositionSchedule(org.alfresco.module.org_alfresco_module_rm.disposition.DispositionSchedule) JSONException(org.json.JSONException) DispositionActionDefinition(org.alfresco.module.org_alfresco_module_rm.disposition.DispositionActionDefinition) JSONObject(org.json.JSONObject) IOException(java.io.IOException)

Example 14 with DispositionActionDefinition

use of org.alfresco.module.org_alfresco_module_rm.disposition.DispositionActionDefinition in project records-management by Alfresco.

the class RecordsManagementSearchBehaviour method updateDispositionActionProperties.

/**
 * On update disposition action properties behaviour implementation
 *
 * @param record            record node reference
 * @param dispositionAction disposition action
 */
private void updateDispositionActionProperties(NodeRef record, NodeRef dispositionAction) {
    Map<QName, Serializable> props = nodeService.getProperties(record);
    DispositionAction da = new DispositionActionImpl(recordsManagementServiceRegistry, dispositionAction);
    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, nodeService.getProperty(dispositionAction, PROP_DISPOSITION_EVENTS_ELIGIBLE));
    DispositionActionDefinition daDefinition = da.getDispositionActionDefinition();
    if (daDefinition != null) {
        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);
        }
    }
    nodeService.setProperties(record, props);
    if (logger.isDebugEnabled()) {
        logger.debug("Set rma:recordSearchDispositionActionName for node " + record + " to: " + props.get(PROP_RS_DISPOSITION_ACTION_NAME));
        logger.debug("Set rma:recordSearchDispositionActionAsOf for node " + record + " to: " + props.get(PROP_RS_DISPOSITION_ACTION_AS_OF));
        logger.debug("Set rma:recordSearchDispositionEventsEligible for node " + record + " to: " + props.get(PROP_RS_DISPOSITION_EVENTS_ELIGIBLE));
        logger.debug("Set rma:recordSearchDispositionPeriod for node " + record + " to: " + props.get(PROP_RS_DISPOSITION_PERIOD));
        logger.debug("Set rma:recordSearchDispositionPeriodExpression for node " + record + " to: " + props.get(PROP_RS_DISPOSITION_PERIOD_EXPRESSION));
    }
}
Also used : Serializable(java.io.Serializable) QName(org.alfresco.service.namespace.QName) 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) DispositionActionImpl(org.alfresco.module.org_alfresco_module_rm.disposition.DispositionActionImpl)

Example 15 with DispositionActionDefinition

use of org.alfresco.module.org_alfresco_module_rm.disposition.DispositionActionDefinition in project records-management by Alfresco.

the class DestroyAction method isGhostOnDestroySetForAction.

/**
 * Return true if the ghost on destroy property is set against the
 * definition for the passed action on the specified node
 *
 * @param action
 * @param nodeRef
 * @return
 */
private boolean isGhostOnDestroySetForAction(Action action, NodeRef nodeRef) {
    boolean ghostOnDestroy = this.ghostingEnabled;
    String actionDefinitionName = action.getActionDefinitionName();
    if (!StringUtils.isEmpty(actionDefinitionName)) {
        DispositionSchedule dispositionSchedule = this.getDispositionService().getDispositionSchedule(nodeRef);
        if (dispositionSchedule != null) {
            DispositionActionDefinition actionDefinition = dispositionSchedule.getDispositionActionDefinitionByName(actionDefinitionName);
            if (actionDefinition != null) {
                String ghostOnDestroyProperty = actionDefinition.getGhostOnDestroy();
                if (ghostOnDestroyProperty != null) {
                    ghostOnDestroy = "ghost".equals(actionDefinition.getGhostOnDestroy());
                }
            }
        }
    }
    return ghostOnDestroy;
}
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