Search in sources :

Example 6 with DispositionSchedule

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

the class UpdateDispositionScheduleTest method testUpdatePeriod.

/**
 * <a href="https://issues.alfresco.com/jira/browse/RM-3386">RM-3386</a>
 * <p><pre>
 * Given a record subject to a disposition schedule
 * And the next step is due to run at some period after the date the content was created
 * When I update the period of the next step (and wait for this to be processed)
 * Then the "as of" date is updated to be at the new period after the creation date.
 * </pre>
 */
public void testUpdatePeriod() {
    test().given(() -> {
        // Create a category.
        category = filePlanService.createRecordCategory(filePlan, CATEGORY_NAME);
        // Create a disposition schedule for the category (Cut off immediately, then Destroy 1 year after the creation date).
        DispositionSchedule dispSched = utils.createBasicDispositionSchedule(category, "instructions", "authority", true, false);
        Map<QName, Serializable> cutOffParams = ImmutableMap.of(PROP_DISPOSITION_ACTION_NAME, CutOffAction.NAME, PROP_DISPOSITION_DESCRIPTION, "description", PROP_DISPOSITION_PERIOD, CommonRMTestUtils.PERIOD_IMMEDIATELY);
        dispositionService.addDispositionActionDefinition(dispSched, cutOffParams);
        Map<QName, Serializable> destroyParams = ImmutableMap.of(PROP_DISPOSITION_ACTION_NAME, DestroyAction.NAME, PROP_DISPOSITION_DESCRIPTION, "description", PROP_DISPOSITION_PERIOD, CommonRMTestUtils.PERIOD_ONE_YEAR, PROP_DISPOSITION_PERIOD_PROPERTY, ContentModel.PROP_CREATED);
        dispositionService.addDispositionActionDefinition(dispSched, destroyParams);
        // Create a folder containing a record within the category.
        folder = recordFolderService.createRecordFolder(category, FOLDER_NAME);
        record = fileFolderService.create(folder, RECORD_NAME, ContentModel.TYPE_CONTENT).getNodeRef();
        dispositionService.cutoffDisposableItem(record);
        // Ensure the update has been applied to the record.
        internalDispositionService.updateNextDispositionAction(record);
        originalAsOfDate = dispositionService.getNextDispositionAction(record).getAsOfDate();
    }).when(() -> {
        // Update the Destroy step to be 3 years after the creation date.
        DispositionSchedule dispSched = dispositionService.getDispositionSchedule(category);
        DispositionActionDefinition destroy = dispSched.getDispositionActionDefinitionByName(DestroyAction.NAME);
        Map<QName, Serializable> destroyParams = ImmutableMap.of(PROP_DISPOSITION_ACTION_NAME, DestroyAction.NAME, PROP_DISPOSITION_DESCRIPTION, "description", PROP_DISPOSITION_PERIOD, CommonRMTestUtils.PERIOD_THREE_YEARS, PROP_DISPOSITION_PERIOD_PROPERTY, ContentModel.PROP_CREATED);
        dispositionService.updateDispositionActionDefinition(destroy, destroyParams);
        // Make the disposition action definition update job run.
        dispositionActionDefinitionPublishExecutor.publish(destroy.getNodeRef());
    }).then().expect(true).from(() -> aboutTwoYearsApart(originalAsOfDate, dispositionService.getNextDispositionAction(record).getAsOfDate())).because("Increasing the destroy period by two years should increase the 'as of' date by two years.");
}
Also used : Serializable(java.io.Serializable) 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) ImmutableMap(com.google.common.collect.ImmutableMap) Map(java.util.Map)

Example 7 with DispositionSchedule

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

the class BroadcastDispositionActionDefinitionUpdateAction method executeImpl.

/**
 * @see org.alfresco.repo.action.executer.ActionExecuterAbstractBase#executeImpl(org.alfresco.service.cmr.action.Action,
 *      org.alfresco.service.cmr.repository.NodeRef)
 */
@SuppressWarnings("unchecked")
@Override
protected void executeImpl(Action action, NodeRef actionedUponNodeRef) {
    if (!RecordsManagementModel.TYPE_DISPOSITION_ACTION_DEFINITION.equals(getNodeService().getType(actionedUponNodeRef))) {
        return;
    }
    List<QName> changedProps = (List<QName>) action.getParameterValue(CHANGED_PROPERTIES);
    // Navigate up the containment hierarchy to get the record category grandparent and schedule.
    NodeRef dispositionScheduleNode = getNodeService().getPrimaryParent(actionedUponNodeRef).getParentRef();
    NodeRef rmContainer = getNodeService().getPrimaryParent(dispositionScheduleNode).getParentRef();
    DispositionSchedule dispositionSchedule = getDispositionService().getAssociatedDispositionSchedule(rmContainer);
    behaviourFilter.disableBehaviour();
    try {
        List<NodeRef> disposableItems = getDispositionService().getDisposableItems(dispositionSchedule);
        for (NodeRef disposableItem : disposableItems) {
            updateDisposableItem(dispositionSchedule, disposableItem, actionedUponNodeRef, changedProps);
        }
    } finally {
        behaviourFilter.enableBehaviour();
    }
}
Also used : NodeRef(org.alfresco.service.cmr.repository.NodeRef) QName(org.alfresco.service.namespace.QName) DispositionSchedule(org.alfresco.module.org_alfresco_module_rm.disposition.DispositionSchedule) ArrayList(java.util.ArrayList) List(java.util.List)

Example 8 with DispositionSchedule

use of org.alfresco.module.org_alfresco_module_rm.disposition.DispositionSchedule 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 DispositionSchedule

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

the class RMv22GhostOnDestroyDispositionActionPatch method processFilePlan.

/**
 * Apply the patch to each file plan
 *
 * @param filePlan
 */
private void processFilePlan(NodeRef filePlan) {
    Set<DispositionSchedule> dispositionSchedules = new HashSet<DispositionSchedule>();
    getDispositionSchedules(filePlan, dispositionSchedules);
    for (DispositionSchedule dispositionSchedule : dispositionSchedules) {
        processDispositionSchedule(dispositionSchedule);
    }
}
Also used : DispositionSchedule(org.alfresco.module.org_alfresco_module_rm.disposition.DispositionSchedule) HashSet(java.util.HashSet)

Example 10 with DispositionSchedule

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

the class CommonRMTestUtils method createDispositionSchedule.

/**
 * Create test disposition schedule
 */
public DispositionSchedule createDispositionSchedule(NodeRef container, String dispositionInstructions, String dispositionAuthority, boolean isRecordLevel, boolean defaultDispositionActions, boolean extendedDispositionSchedule, String defaultEvent) {
    Map<QName, Serializable> dsProps = new HashMap<QName, Serializable>(3);
    dsProps.put(PROP_DISPOSITION_AUTHORITY, dispositionAuthority);
    dsProps.put(PROP_DISPOSITION_INSTRUCTIONS, dispositionInstructions);
    dsProps.put(PROP_RECORD_LEVEL_DISPOSITION, isRecordLevel);
    DispositionSchedule dispositionSchedule = dispositionService.createDispositionSchedule(container, dsProps);
    if (defaultDispositionActions) {
        Map<QName, Serializable> adParams = new HashMap<QName, Serializable>(3);
        adParams.put(PROP_DISPOSITION_ACTION_NAME, CutOffAction.NAME);
        adParams.put(PROP_DISPOSITION_DESCRIPTION, DEFAULT_DISPOSITION_DESCRIPTION);
        List<String> events = new ArrayList<String>(1);
        events.add(defaultEvent);
        adParams.put(PROP_DISPOSITION_EVENT, (Serializable) events);
        dispositionService.addDispositionActionDefinition(dispositionSchedule, adParams);
        if (extendedDispositionSchedule) {
            adParams = new HashMap<QName, Serializable>(4);
            adParams.put(PROP_DISPOSITION_ACTION_NAME, TransferAction.NAME);
            adParams.put(PROP_DISPOSITION_DESCRIPTION, DEFAULT_DISPOSITION_DESCRIPTION);
            adParams.put(PROP_DISPOSITION_PERIOD, PERIOD_IMMEDIATELY);
            adParams.put(PROP_DISPOSITION_LOCATION, StringUtils.EMPTY);
            dispositionService.addDispositionActionDefinition(dispositionSchedule, adParams);
        }
        adParams = new HashMap<QName, Serializable>(3);
        adParams.put(PROP_DISPOSITION_ACTION_NAME, DestroyAction.NAME);
        adParams.put(PROP_DISPOSITION_DESCRIPTION, DEFAULT_DISPOSITION_DESCRIPTION);
        adParams.put(PROP_DISPOSITION_PERIOD, PERIOD_IMMEDIATELY);
        dispositionService.addDispositionActionDefinition(dispositionSchedule, adParams);
    }
    return dispositionSchedule;
}
Also used : Serializable(java.io.Serializable) HashMap(java.util.HashMap) QName(org.alfresco.service.namespace.QName) DispositionSchedule(org.alfresco.module.org_alfresco_module_rm.disposition.DispositionSchedule) ArrayList(java.util.ArrayList)

Aggregations

DispositionSchedule (org.alfresco.module.org_alfresco_module_rm.disposition.DispositionSchedule)34 NodeRef (org.alfresco.service.cmr.repository.NodeRef)16 DispositionActionDefinition (org.alfresco.module.org_alfresco_module_rm.disposition.DispositionActionDefinition)10 QName (org.alfresco.service.namespace.QName)9 HashMap (java.util.HashMap)8 Serializable (java.io.Serializable)7 Date (java.util.Date)4 ArrayList (java.util.ArrayList)3 Map (java.util.Map)3 Test (org.junit.Test)3 WebScriptException (org.springframework.extensions.webscripts.WebScriptException)3 File (java.io.File)2 FileOutputStream (java.io.FileOutputStream)2 IOException (java.io.IOException)2 OutputStreamWriter (java.io.OutputStreamWriter)2 Writer (java.io.Writer)2 List (java.util.List)2 AlfrescoRuntimeException (org.alfresco.error.AlfrescoRuntimeException)2 DispositionAction (org.alfresco.module.org_alfresco_module_rm.disposition.DispositionAction)2 DispositionScheduleImpl (org.alfresco.module.org_alfresco_module_rm.disposition.DispositionScheduleImpl)2