use of org.alfresco.service.cmr.repository.Period in project records-management by Alfresco.
the class VitalRecordServiceImpl method setupVitalRecordDefinition.
/**
* @see org.alfresco.module.org_alfresco_module_rm.vital.VitalRecordService#setupVitalRecordDefinition(org.alfresco.service.cmr.repository.NodeRef)
*/
@Override
public void setupVitalRecordDefinition(NodeRef nodeRef) {
// get the current review period value
Period currentReviewPeriod = (Period) nodeService.getProperty(nodeRef, PROP_REVIEW_PERIOD);
if (currentReviewPeriod == null || PERIOD_NONE.equals(currentReviewPeriod)) {
// get the immediate parent
NodeRef parentRef = nodeService.getPrimaryParent(nodeRef).getParentRef();
// is the parent a record category
if (parentRef != null && FilePlanComponentKind.RECORD_CATEGORY.equals(filePlanService.getFilePlanComponentKind(parentRef))) {
// is the child a record category or folder
FilePlanComponentKind kind = filePlanService.getFilePlanComponentKind(nodeRef);
if (kind.equals(FilePlanComponentKind.RECORD_CATEGORY) || kind.equals(FilePlanComponentKind.RECORD_FOLDER)) {
// set the vital record definition values to match that of the parent
nodeService.setProperty(nodeRef, PROP_VITAL_RECORD_INDICATOR, nodeService.getProperty(parentRef, PROP_VITAL_RECORD_INDICATOR));
nodeService.setProperty(nodeRef, PROP_REVIEW_PERIOD, nodeService.getProperty(parentRef, PROP_REVIEW_PERIOD));
}
}
}
}
use of org.alfresco.service.cmr.repository.Period 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);
}
}
use of org.alfresco.service.cmr.repository.Period in project records-management by Alfresco.
the class ReviewedActionUnitTest method testReviewRecordWithAdHocReviewPeriod.
/**
* Given a record having the vital record definition of immediately
* When I mark the record as reviewed
* Then review as of date is removed from the record
*/
@Test
public void testReviewRecordWithAdHocReviewPeriod() {
/*
* Given
*/
NodeRef mockedRecord = new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, GUID.generate());
when(mockedRecordService.isRecord(mockedRecord)).thenReturn(true);
VitalRecordDefinition mockedVRDef = mock(VitalRecordDefinition.class);
when(mockedVRDef.isEnabled()).thenReturn(true);
when(mockedVitalRecordService.getVitalRecordDefinition(mockedRecord)).thenReturn(mockedVRDef);
Period mockedReviewPeriod = mock(Period.class);
when(mockedReviewPeriod.getPeriodType()).thenReturn(Immediately.PERIOD_TYPE);
when(mockedVRDef.getReviewPeriod()).thenReturn(mockedReviewPeriod);
/*
* When
*/
reviewedAction.executeImpl(null, mockedRecord);
/*
* Then
*/
verify(mockedNodeService).removeProperty(mockedRecord, PROP_REVIEW_AS_OF);
}
use of org.alfresco.service.cmr.repository.Period in project records-management by Alfresco.
the class BaseRMWebScriptTestCase method setupTestDataImpl.
/**
* Impl of test data setup
*/
protected void setupTestDataImpl() {
storeRef = StoreRef.STORE_REF_WORKSPACE_SPACESSTORE;
rootNodeRef = nodeService.getRootNode(storeRef);
// Create folder
String containerName = "RM2_" + System.currentTimeMillis();
Map<QName, Serializable> containerProps = new HashMap<QName, Serializable>(1);
containerProps.put(ContentModel.PROP_NAME, containerName);
folder = nodeService.createNode(rootNodeRef, ContentModel.ASSOC_CHILDREN, QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, containerName), ContentModel.TYPE_FOLDER, containerProps).getChildRef();
assertNotNull("Could not create base folder", folder);
// Create the site
siteId = getRMSiteId();
siteInfo = siteService.createSite("rm-site-dashboard", siteId, "title", "descrition", SiteVisibility.PUBLIC, RecordsManagementModel.TYPE_RM_SITE);
filePlan = siteService.getContainer(siteId, RmSiteType.COMPONENT_DOCUMENT_LIBRARY);
assertNotNull("Site document library container was not created successfully.", filePlan);
recordSeries = filePlanService.createRecordCategory(filePlan, "recordSeries");
assertNotNull("Could not create record category with no disposition schedule", recordSeries);
recordCategory = filePlanService.createRecordCategory(recordSeries, "rmContainer");
assertNotNull("Could not create record category", recordCategory);
// Make vital record
vitalRecordService.setVitalRecordDefintion(recordCategory, true, new Period("week|1"));
// Create disposition schedule
dispositionSchedule = utils.createBasicDispositionSchedule(recordCategory);
// Create RM folder
recordFolder = recordFolderService.createRecordFolder(recordCategory, "rmFolder");
assertNotNull("Could not create rm folder", recordFolder);
recordFolder2 = recordFolderService.createRecordFolder(recordCategory, "rmFolder2");
assertNotNull("Could not create rm folder 2", recordFolder2);
// Create collaboration data
if (isCollaborationSiteTest()) {
setupCollaborationSiteTestData();
}
}
use of org.alfresco.service.cmr.repository.Period in project records-management by Alfresco.
the class DispositionServiceImplUnitTest method testCalculateAsOfDate.
/**
* Check that the relevant information is retrieved from the DispositionActionDefinition in order to determine the
* "disposition as of" date.
*/
@Test
public void testCalculateAsOfDate() {
// Set up a mock for the disposition action definition.
DispositionActionDefinition mockDispositionActionDefinition = mock(DispositionActionDefinition.class);
Period mockPeriod = mock(Period.class);
when(mockDispositionActionDefinition.getPeriod()).thenReturn(mockPeriod);
when(mockDispositionActionDefinition.getPeriodProperty()).thenReturn(ContentModel.PROP_CREATED);
// Set up a created date and another date that is some Period later.
Date createdDate = new Date(1234567890);
when(mockNodeService.getProperty(CONTENT_NODE_REF, ContentModel.PROP_CREATED)).thenReturn(createdDate);
Date nextDate = new Date(1240000000);
when(mockPeriod.getNextDate(createdDate)).thenReturn(nextDate);
// Call the method under test.
Date asOfDate = dispositionService.calculateAsOfDate(CONTENT_NODE_REF, mockDispositionActionDefinition);
assertEquals("Unexpected calculation for 'as of' date", nextDate, asOfDate);
}
Aggregations