Search in sources :

Example 21 with DispositionAction

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

the class MoveRecordFolderTest method testMoveRecordFolderFromNoDisToDis.

/**
 * Try and move a folder from no disposition schedule to a disposition schedule
 *
 * @see https://issues.alfresco.com/jira/browse/RM-1039
 */
public void testMoveRecordFolderFromNoDisToDis() throws Exception {
    final NodeRef recordFolder = doTestInTransaction(new Test<NodeRef>() {

        @Override
        public NodeRef run() {
            // create a record category (no disposition schedule)
            NodeRef recordCategory = filePlanService.createRecordCategory(filePlan, "Caitlin Reed");
            // create a record folder
            return recordFolderService.createRecordFolder(recordCategory, "Grace Wetherall");
        }

        @Override
        public void test(NodeRef result) throws Exception {
            assertNotNull(result);
            assertNull(dispositionService.getDispositionSchedule(result));
            assertFalse(nodeService.hasAspect(result, ASPECT_DISPOSITION_LIFECYCLE));
            assertEquals(AccessStatus.ALLOWED, permissionService.hasPermission(result, FILING));
        }
    });
    final NodeRef record = doTestInTransaction(new Test<NodeRef>() {

        @Override
        public NodeRef run() {
            // create a record
            return fileFolderService.create(recordFolder, "mytest.txt", ContentModel.TYPE_CONTENT).getNodeRef();
        }

        @Override
        public void test(NodeRef result) throws Exception {
            assertNotNull(result);
            assertNull(dispositionService.getDispositionSchedule(result));
            assertFalse(nodeService.hasAspect(result, ASPECT_DISPOSITION_LIFECYCLE));
            assertEquals(AccessStatus.ALLOWED, permissionService.hasPermission(result, FILING));
        }
    });
    doTestInTransaction(new Test<NodeRef>() {

        @Override
        public NodeRef run() throws Exception {
            Capability capability = capabilityService.getCapability("CreateModifyDestroyFolders");
            assertEquals(AccessDecisionVoter.ACCESS_GRANTED, capability.evaluate(recordFolder));
            assertEquals(AccessDecisionVoter.ACCESS_GRANTED, capability.evaluate(recordFolder, rmContainer));
            // take a look at the move capability
            Capability moveCapability = capabilityService.getCapability("Move");
            assertEquals(AccessDecisionVoter.ACCESS_GRANTED, moveCapability.evaluate(recordFolder, rmContainer));
            // move the node
            return fileFolderService.move(recordFolder, rmContainer, null).getNodeRef();
        }

        @Override
        public void test(NodeRef result) throws Exception {
            assertNotNull(result);
            assertNotNull(dispositionService.getDispositionSchedule(result));
            assertTrue(nodeService.hasAspect(result, ASPECT_DISPOSITION_LIFECYCLE));
            DispositionAction dispositionAction = dispositionService.getNextDispositionAction(result);
            assertNotNull(dispositionAction);
            assertNull(dispositionAction.getAsOfDate());
            assertEquals("cutoff", dispositionAction.getName());
            assertEquals(1, dispositionAction.getEventCompletionDetails().size());
            // take a look at the record and check things are as we would expect
            assertFalse(nodeService.hasAspect(record, ASPECT_DISPOSITION_LIFECYCLE));
        }
    });
}
Also used : NodeRef(org.alfresco.service.cmr.repository.NodeRef) Capability(org.alfresco.module.org_alfresco_module_rm.capability.Capability) DispositionAction(org.alfresco.module.org_alfresco_module_rm.disposition.DispositionAction)

Example 22 with DispositionAction

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

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

the class DispositionServiceImplTest method testRM_263.

/**
 * https://issues.alfresco.com/jira/browse/RM-263
 */
public void testRM_263() throws Exception {
    doTestInTransaction(new Test<Void>() {

        @Override
        public Void run() throws Exception {
            testRM263RecordCategory = filePlanService.createRecordCategory(rmContainer, "rm263");
            testRM263DispositionSchedule = utils.createBasicDispositionSchedule(testRM263RecordCategory, "test", "test", true, false);
            Map<QName, Serializable> adParams = new HashMap<QName, Serializable>(3);
            adParams.put(PROP_DISPOSITION_ACTION_NAME, "cutoff");
            adParams.put(PROP_DISPOSITION_DESCRIPTION, "test");
            adParams.put(PROP_DISPOSITION_PERIOD, "week|1");
            adParams.put(PROP_DISPOSITION_PERIOD_PROPERTY, DOD5015Model.PROP_PUBLICATION_DATE.toString());
            dispositionService.addDispositionActionDefinition(testRM263DispositionSchedule, adParams);
            NodeRef recordFolder = recordFolderService.createRecordFolder(testRM263RecordCategory, "testRM263RecordFolder");
            testRM263Record = utils.createRecord(recordFolder, "testRM263Record", "testRM263Record");
            return null;
        }
    });
    doTestInTransaction(new Test<Void>() {

        private final QName PROP_SEARCH_ASOF = QName.createQName(RM_URI, "recordSearchDispositionActionAsOf");

        @Override
        public Void run() throws Exception {
            Date pubDate = (Date) nodeService.getProperty(testRM263Record, DOD5015Model.PROP_PUBLICATION_DATE);
            assertNull(pubDate);
            Date asOfDate = (Date) nodeService.getProperty(testRM263Record, PROP_SEARCH_ASOF);
            assertNull(asOfDate);
            DispositionAction da = dispositionService.getNextDispositionAction(testRM263Record);
            assertNotNull(da);
            assertNull(da.getAsOfDate());
            // rma:recordSearchDispositionActionAsOf"
            nodeService.setProperty(testRM263Record, DOD5015Model.PROP_PUBLICATION_DATE, new Date());
            return null;
        }

        @Override
        public void test(Void result) throws Exception {
            Date pubDate = (Date) nodeService.getProperty(testRM263Record, DOD5015Model.PROP_PUBLICATION_DATE);
            assertNotNull(pubDate);
            Date asOfDate = (Date) nodeService.getProperty(testRM263Record, PROP_SEARCH_ASOF);
            assertNotNull(asOfDate);
            DispositionAction da = dispositionService.getNextDispositionAction(testRM263Record);
            assertNotNull(da);
            assertNotNull(da.getAsOfDate());
        }
    });
}
Also used : NodeRef(org.alfresco.service.cmr.repository.NodeRef) Serializable(java.io.Serializable) QName(org.alfresco.service.namespace.QName) HashMap(java.util.HashMap) Map(java.util.Map) AlfrescoRuntimeException(org.alfresco.error.AlfrescoRuntimeException) Date(java.util.Date) 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