Skip to content

Commit

Permalink
Configured dc.relation for controlled authority and created test.
Browse files Browse the repository at this point in the history
  • Loading branch information
milanmajchrak committed Sep 19, 2023
1 parent 1eb7971 commit 0e2a386
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 0 deletions.
6 changes: 6 additions & 0 deletions dspace-api/src/test/data/dspaceFolder/config/local.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -268,3 +268,9 @@ versioning.enabled=true
### PID config
lr.pid.community.configurations = community=47501cdc-e2eb-44e5-85e0-89a31dc8ceee, prefix=123456789, type=epic, canonical_prefix=http://hdl.handle.net/, subprefix=1
lr.pid.community.configurations = community=*, prefix=123456789, type=local, canonical_prefix=http://hdl.handle.net/, subprefix=2

#### Authority configuration `authority.cfg`
choices.plugin.dc.relation = OpenAIRE
choices.presentation.dc.relation = suggest
choices.closed.dc.relation = true
authority.controlled.dc.relation = true
Original file line number Diff line number Diff line change
Expand Up @@ -410,4 +410,64 @@ public void importItemWithUnsortedAuthors() throws Exception {
ItemBuilder.deleteItem(uuid);
context.restoreAuthSystemState();
}

@Test
public void testImportAuthorityAndConfidenceInMetadata() throws Exception {
String DC_RELATION_METADATA_FIELD = "dc.relation";
String DC_RELATION_METADATA_VALUE = "this is metadata value";
int CONFIDENCE = 300;
int AUTHORITY = 20000;

context.turnOffAuthorisationSystem();
ObjectNode node = jsonNodeFactory.objectNode();
node.set("withdrawn", jsonNodeFactory.textNode("false"));
node.set("inArchive", jsonNodeFactory.textNode("false"));
node.set("discoverable", jsonNodeFactory.textNode("false"));

// Metadata which should be kept after installing the new Item.
ObjectNode metadataNode = jsonNodeFactory.objectNode();

// `dc.relation` metadata added into `metadata` of the ItemRest object
ObjectNode dcRelationMetadataNode = jsonNodeFactory.objectNode();
dcRelationMetadataNode.set("value", jsonNodeFactory.textNode(DC_RELATION_METADATA_VALUE));
dcRelationMetadataNode.set("language", jsonNodeFactory.textNode("en_US"));
dcRelationMetadataNode.set("authority", jsonNodeFactory.numberNode(AUTHORITY));
dcRelationMetadataNode.set("confidence", jsonNodeFactory.numberNode(CONFIDENCE));
metadataNode.set(DC_RELATION_METADATA_FIELD, jsonNodeFactory.arrayNode()
.add(dcRelationMetadataNode));

node.set("metadata", metadataNode);
context.restoreAuthSystemState();

ObjectMapper mapper = new ObjectMapper();
String token = getAuthToken(admin.getEmail(), password);

UUID uuid = UUID.fromString(read(getClient(token).perform(post("/api/clarin/import/item")
.content(mapper.writeValueAsBytes(node))
.contentType(org.springframework.http.MediaType.APPLICATION_JSON)
.param("owningCollection", col.getID().toString())
.param("epersonUUID", submitter.getID().toString()))
.andExpect(status().isOk()).andReturn().getResponse().getContentAsString(),
"$.id"));

// workspaceitem should nt exist
List<WorkspaceItem> workflowItems = workspaceItemService.findAll(context);
assertEquals(workflowItems.size(), 0);
// controlling of the created item
Item item = itemService.find(context, uuid);
assertFalse(item.isWithdrawn());
assertFalse(item.isArchived());
assertFalse(item.isDiscoverable());
assertEquals(item.getSubmitter().getID(), submitter.getID());
assertEquals(item.getOwningCollection().getID(), col.getID());

// get all `dc.contributor.author`metadata values
List<MetadataValue> dcRelationValues =
itemService.getMetadata(item, "dc", "relation", null, "en_US");
assertEquals(dcRelationValues.size(), 1);

MetadataValue dcRelationValue = dcRelationValues.get(0);
assertEquals(dcRelationValue.getAuthority(), String.valueOf(AUTHORITY));
assertEquals(dcRelationValue.getConfidence(), CONFIDENCE);
}
}
7 changes: 7 additions & 0 deletions dspace/config/clarin-dspace.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -219,3 +219,10 @@ identifiers.item-status.register-doi = false
##### Dataquest URL - sing in the footer #####
themed.by.url = https://www.dataquest.sk/dspace
themed.by.company.name = dataquest s.r.o.


#### Authority configuration `authority.cfg`
choices.plugin.dc.relation = OpenAIRE
choices.presentation.dc.relation = suggest
choices.closed.dc.relation = true
authority.controlled.dc.relation = true

0 comments on commit 0e2a386

Please sign in to comment.