use of org.alfresco.service.cmr.version.Version in project records-management by Alfresco.
the class RecordableVersionsBaseTest method checkNotRecordedAspect.
/**
* Helper method to check that the current version is not recorded
*/
protected void checkNotRecordedAspect(NodeRef document, String description, String versionLabel) {
// double check that the document is not a record
assertFalse(recordService.isRecord(document));
// get the current version
Version version = versionService.getCurrentVersion(document);
// version has been created
assertNotNull(version);
// check the version properties
assertEquals(description, version.getDescription());
assertEquals(versionLabel, version.getVersionLabel());
// record version node reference is available on version
NodeRef record = recordableVersionService.getVersionRecord(version);
assertNull(record);
// check the version history
VersionHistory versionHistory = versionService.getVersionHistory(document);
assertNotNull(versionHistory);
Version headVersion = versionHistory.getHeadVersion();
assertNotNull(headVersion);
}
use of org.alfresco.service.cmr.version.Version in project records-management by Alfresco.
the class DeleteRecordVersionTest method testDeleteOldestVersion.
/**
* Given a chain of version records (1.0, 1.1, 1.2) which are all related
* When I delete version record 1.0
* Then 1.1 is the oldest version
*/
public void testDeleteOldestVersion() {
final NodeRef myDocument = createDocumentWithRecordVersions();
doBehaviourDrivenTest(new BehaviourDrivenTest() {
private VersionHistory versionHistory;
public void given() throws Exception {
// get version history
versionHistory = versionService.getVersionHistory(myDocument);
}
public void when() {
Version version10 = versionHistory.getVersion("1.0");
NodeRef recordVersion10 = recordableVersionService.getVersionRecord(version10);
// delete record version 1.0
nodeService.deleteNode(recordVersion10);
}
public void then() {
// check the deleted version
Version version10 = versionHistory.getVersion("1.0");
assertNotNull(version10);
assertTrue(recordableVersionService.isRecordedVersionDestroyed(version10));
NodeRef recordVersion10 = recordableVersionService.getVersionRecord(version10);
assertNull(recordVersion10);
// verify 1.2 setup as expected
Version version12 = versionHistory.getHeadVersion();
assertEquals("1.2", version12.getVersionLabel());
NodeRef recordVersion12 = recordableVersionService.getVersionRecord(version12);
assertNotNull(recordVersion12);
assertTrue(relationshipService.getRelationshipsTo(recordVersion12, RelationshipService.RELATIONSHIP_VERSIONS).isEmpty());
Set<Relationship> from12 = relationshipService.getRelationshipsFrom(recordVersion12, RelationshipService.RELATIONSHIP_VERSIONS);
assertEquals(1, from12.size());
// verify 1.1 setup as expected
Version version11 = versionHistory.getPredecessor(version12);
assertEquals("1.1", version11.getVersionLabel());
NodeRef recordVersion11 = recordableVersionService.getVersionRecord(version11);
assertNotNull(recordVersion11);
Set<Relationship> to11 = relationshipService.getRelationshipsTo(recordVersion11, RelationshipService.RELATIONSHIP_VERSIONS);
assertEquals(1, to11.size());
assertEquals(recordVersion12, to11.iterator().next().getSource());
assertTrue(relationshipService.getRelationshipsFrom(recordVersion11, RelationshipService.RELATIONSHIP_VERSIONS).isEmpty());
}
});
}
use of org.alfresco.service.cmr.version.Version in project records-management by Alfresco.
the class DeleteRecordVersionTest method testDestroyVersionRecordWithMetadata.
/**
* Given that a version record
* When the version record is destroyed whilst retaining the meta data
* Then the version is marked as destroyed in the collab version history
*/
public void testDestroyVersionRecordWithMetadata() {
final NodeRef myDocument = createDocumentWithRecordVersions();
doBehaviourDrivenTest(new BehaviourDrivenTest() {
private VersionHistory versionHistory;
private NodeRef recordVersion11;
public void given() throws Exception {
// create file plan structure
NodeRef myCategory = filePlanService.createRecordCategory(filePlan, GUID.generate());
utils.createBasicDispositionSchedule(myCategory, GUID.generate(), GUID.generate(), true, true);
NodeRef myRecordFolder = recordFolderService.createRecordFolder(myCategory, GUID.generate());
// get version history
versionHistory = versionService.getVersionHistory(myDocument);
// file and complete all the version records into my record folder
for (Version version : versionHistory.getAllVersions()) {
NodeRef record = recordableVersionService.getVersionRecord(version);
fileFolderService.move(record, myRecordFolder, null);
utils.completeRecord(record);
}
}
public void when() {
Version version11 = versionHistory.getVersion("1.1");
recordVersion11 = recordableVersionService.getVersionRecord(version11);
Map<String, Serializable> params = new HashMap<String, Serializable>(1);
params.put(CompleteEventAction.PARAM_EVENT_NAME, CommonRMTestUtils.DEFAULT_EVENT_NAME);
rmActionService.executeRecordsManagementAction(recordVersion11, CompleteEventAction.NAME, params);
rmActionService.executeRecordsManagementAction(recordVersion11, CutOffAction.NAME);
rmActionService.executeRecordsManagementAction(recordVersion11, DestroyAction.NAME);
}
public void then() {
// verify that the version history looks as expected
VersionHistory versionHistory = versionService.getVersionHistory(myDocument);
assertNotNull(versionHistory);
Collection<Version> versions = versionHistory.getAllVersions();
assertEquals(3, versions.size());
// verify 1.2 setup as expected
Version version12 = versionHistory.getHeadVersion();
assertEquals("1.2", version12.getVersionLabel());
assertFalse(recordableVersionService.isRecordedVersionDestroyed(version12));
NodeRef recordVersion12 = recordableVersionService.getVersionRecord(version12);
assertNotNull(recordVersion12);
assertFalse(recordService.isMetadataStub(recordVersion12));
assertTrue(relationshipService.getRelationshipsTo(recordVersion12, "versions").isEmpty());
Set<Relationship> from12 = relationshipService.getRelationshipsFrom(recordVersion12, "versions");
assertEquals(1, from12.size());
// verify 1.1 setup as expected
Version version11 = versionHistory.getPredecessor(version12);
assertEquals("1.1", version11.getVersionLabel());
assertTrue(recordableVersionService.isRecordedVersionDestroyed(version11));
assertNotNull(recordVersion11);
assertTrue(recordService.isMetadataStub(recordVersion11));
Set<Relationship> to11 = relationshipService.getRelationshipsTo(recordVersion11, "versions");
assertEquals(1, to11.size());
assertEquals(recordVersion12, to11.iterator().next().getSource());
Set<Relationship> from11 = relationshipService.getRelationshipsFrom(recordVersion11, "versions");
assertEquals(1, from11.size());
// verify 1.0 setup as expected
Version version10 = versionHistory.getPredecessor(version11);
assertEquals("1.0", version10.getVersionLabel());
assertFalse(recordableVersionService.isRecordedVersionDestroyed(version10));
NodeRef recordVersion10 = recordableVersionService.getVersionRecord(version10);
assertNotNull(recordVersion10);
assertFalse(recordService.isMetadataStub(recordVersion10));
Set<Relationship> to10 = relationshipService.getRelationshipsTo(recordVersion10, "versions");
assertEquals(1, to10.size());
assertEquals(recordVersion11, to10.iterator().next().getSource());
assertTrue(relationshipService.getRelationshipsFrom(recordVersion10, "versions").isEmpty());
}
});
}
use of org.alfresco.service.cmr.version.Version in project records-management by Alfresco.
the class DestroyAction method executeRecordLevelDisposition.
/**
* @see org.alfresco.module.org_alfresco_module_rm.action.RMDispositionActionExecuterAbstractBase#executeRecordLevelDisposition(org.alfresco.service.cmr.action.Action, org.alfresco.service.cmr.repository.NodeRef)
*/
@Override
protected void executeRecordLevelDisposition(Action action, NodeRef record) {
if (isGhostOnDestroySetForAction(action, record)) {
// mark version as destroyed
Version version = recordableVersionService.getRecordedVersion(record);
if (version != null) {
recordableVersionService.destroyRecordedVersion(version);
}
// Hide from inplace users to give the impression of destruction
inplaceRecordService.hideRecord(record);
// Add the ghosted aspect
getNodeService().addAspect(record, ASPECT_GHOSTED, null);
// destroy content
contentDestructionComponent.destroyContent(record);
} else {
// just delete the node
getNodeService().deleteNode(record);
}
}
use of org.alfresco.service.cmr.version.Version in project records-management by Alfresco.
the class AdHocRecordableVersionsTest method testRecordedVersionWithRecordMetadataAspect.
/**
* Test recorded version with record metadata aspect (want to ensure additional non-rm URI properties and aspects
* don't find their way into the frozen state)
*/
public void testRecordedVersionWithRecordMetadataAspect() {
doBehaviourDrivenTest(new BehaviourDrivenTest(dmCollaborator) {
private Map<String, Serializable> versionProperties;
public void given() throws Exception {
// setup version properties
versionProperties = new HashMap<String, Serializable>(4);
versionProperties.put(Version.PROP_DESCRIPTION, DESCRIPTION);
versionProperties.put(VersionModel.PROP_VERSION_TYPE, VersionType.MINOR);
versionProperties.put(RecordableVersionServiceImpl.KEY_RECORDABLE_VERSION, true);
versionProperties.put(RecordableVersionServiceImpl.KEY_FILE_PLAN, filePlan);
}
public void when() {
// create version
final Version version = versionService.createVersion(dmDocument, versionProperties);
AuthenticationUtil.runAs(new RunAsWork<Void>() {
public Void doWork() throws Exception {
// add custom meta-data to record
NodeRef record = recordableVersionService.getVersionRecord(version);
assertNotNull(record);
recordService.addRecordType(record, TestModel.ASPECT_RECORD_METADATA);
nodeService.setProperty(record, TestModel.PROPERTY_RECORD_METADATA, "Peter Wetherall");
return null;
}
}, AuthenticationUtil.getAdminUserName());
}
public void then() {
// check that the record has been recorded
checkRecordedVersion(dmDocument, DESCRIPTION, "0.1");
}
});
}
Aggregations