Search in sources :

Example 16 with DispositionActionDefinition

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

the class RMv22GhostOnDestroyDispositionActionPatch method processDispositionSchedule.

/**
 * Patch the specified disposition schedule. To do this add the host on
 * destroy to any action definition that doesn't already have it defined and
 * set the value to the value set in the global properties file. Leave any
 * action definitions that have this property already defined untouched.
 *
 * @param dispositionSchedule
 */
private void processDispositionSchedule(DispositionSchedule dispositionSchedule) {
    List<DispositionActionDefinition> actionDefinitions = dispositionSchedule.getDispositionActionDefinitions();
    for (DispositionActionDefinition actionDefinition : actionDefinitions) {
        String actionName = (String) nodeService.getProperty(actionDefinition.getNodeRef(), RecordsManagementModel.PROP_DISPOSITION_ACTION_NAME);
        if ("destroy".equals(actionName)) {
            // we only want to add the ghost on destroy property to action
            // definitions that do not already have it defined
            String ghostOnDestroyValue = (String) nodeService.getProperty(actionDefinition.getNodeRef(), RecordsManagementModel.PROP_DISPOSITION_ACTION_GHOST_ON_DESTROY);
            if (ghostOnDestroyValue == null) {
                Map<QName, Serializable> props = new HashMap<QName, Serializable>(1);
                props.put(RecordsManagementModel.PROP_DISPOSITION_ACTION_GHOST_ON_DESTROY, this.ghostingEnabled ? "ghost" : "destroy");
                this.dispositionService.updateDispositionActionDefinition(actionDefinition, props);
            }
        }
    }
}
Also used : Serializable(java.io.Serializable) HashMap(java.util.HashMap) QName(org.alfresco.service.namespace.QName) DispositionActionDefinition(org.alfresco.module.org_alfresco_module_rm.disposition.DispositionActionDefinition)

Example 17 with DispositionActionDefinition

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

the class BroadcastDispositionActionDefinitionUpdateActionUnitTest method testPersistPeriodChanges.

/**
 * Check that the disposition service is used to determine the "disposition as of" date when changes are made to the
 * disposition period.
 */
@Test
public void testPersistPeriodChanges() {
    // Set up the data associated with the next disposition action.
    DispositionAction mockAction = mock(DispositionAction.class);
    when(mockAction.getNodeRef()).thenReturn(NEXT_ACTION_NODE_REF);
    DispositionActionDefinition mockDispositionActionDefinition = mock(DispositionActionDefinition.class);
    when(mockAction.getDispositionActionDefinition()).thenReturn(mockDispositionActionDefinition);
    when(mockAction.getName()).thenReturn("mockAction");
    // Set up the disposition service to return a known "disposition as of" date.
    Date asOfDate = new Date();
    when(mockDispositionService.calculateAsOfDate(CONTENT_NODE_REF, mockDispositionActionDefinition)).thenReturn(asOfDate);
    // Call the method under test.
    action.persistPeriodChanges(DISPOSITION_ACTION_DEF_NODE, mockAction);
    // Check that the "disposition as of" date has been set on the next action.
    verify(mockNodeService).setProperty(NEXT_ACTION_NODE_REF, PROP_DISPOSITION_AS_OF, asOfDate);
}
Also used : DispositionActionDefinition(org.alfresco.module.org_alfresco_module_rm.disposition.DispositionActionDefinition) DispositionAction(org.alfresco.module.org_alfresco_module_rm.disposition.DispositionAction) Date(java.util.Date) Test(org.junit.Test)

Example 18 with DispositionActionDefinition

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

the class DispositionServiceImplTest method updateDispositionScheduleOnContainer.

private void updateDispositionScheduleOnContainer(NodeRef nodeRef) {
    Map<QName, Serializable> updateProps = new HashMap<QName, Serializable>(3);
    updateProps.put(PROP_DISPOSITION_PERIOD, "week|1");
    updateProps.put(PROP_DISPOSITION_EVENT, (Serializable) Arrays.asList(CommonRMTestUtils.DEFAULT_EVENT_NAME, "abolished"));
    DispositionSchedule ds = dispositionService.getDispositionSchedule(nodeRef);
    DispositionActionDefinition dad = ds.getDispositionActionDefinitionByName("cutoff");
    dispositionService.updateDispositionActionDefinition(dad, updateProps);
    publishDispositionActionDefinitionChange(dad);
}
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) DispositionActionDefinition(org.alfresco.module.org_alfresco_module_rm.disposition.DispositionActionDefinition)

Example 19 with DispositionActionDefinition

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

the class DispositionServiceImplTest method checkDispositionSchedule.

/**
 * Checks a disposition schedule
 *
 * @param ds    disposition scheduleS
 */
private void checkDispositionSchedule(DispositionSchedule ds, String dispositionInstructions, String dispositionAuthority, boolean isRecordLevel) {
    assertEquals(dispositionAuthority, ds.getDispositionAuthority());
    assertEquals(dispositionInstructions, ds.getDispositionInstructions());
    assertEquals(isRecordLevel, ds.isRecordLevelDisposition());
    List<DispositionActionDefinition> defs = ds.getDispositionActionDefinitions();
    assertNotNull(defs);
    assertEquals(2, defs.size());
    DispositionActionDefinition defCutoff = ds.getDispositionActionDefinitionByName("cutoff");
    assertNotNull(defCutoff);
    assertEquals("cutoff", defCutoff.getName());
    DispositionActionDefinition defDestroy = ds.getDispositionActionDefinitionByName("destroy");
    assertNotNull(defDestroy);
    assertEquals("destroy", defDestroy.getName());
}
Also used : 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