Skip to content

Commit

Permalink
ufal/be-confidence-authority-not-imported (#438)
Browse files Browse the repository at this point in the history
* Configured `dc.relation` for controlled authority and created test.

* Updated VersioningWithRelationshipsTest - updated adding dc.relation metadata.
  • Loading branch information
milanmajchrak authored Sep 21, 2023
1 parent 1eb7971 commit fb252cf
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 3 deletions.
3 changes: 3 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,6 @@ 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`
authority.controlled.dc.relation = true
Original file line number Diff line number Diff line change
Expand Up @@ -2162,7 +2162,7 @@ public void test_placeRecalculationAfterDelete_complex() throws Exception {
.build();

// metadata - person 3 & project 2
itemService.addMetadata(context, pe3_1, "dc", "relation", null, null, "project 2 (mdv)");
itemService.addMetadata(context, pe3_1, "dc", "relation", null, null, "project 2 (mdv)", "20000", 300);

// relationship - person 1 & project 3
RelationshipBuilder.createRelationshipBuilder(context, pe1_1, pr3_1, isProjectOfPerson)
Expand Down Expand Up @@ -2193,14 +2193,14 @@ public void test_placeRecalculationAfterDelete_complex() throws Exception {
.build();

// metadata - person 3 & project 4
itemService.addMetadata(context, pe3_1, "dc", "relation", null, null, "project 4 (mdv)");
itemService.addMetadata(context, pe3_1, "dc", "relation", null, null, "project 4 (mdv)", "20000", 300);

// relationship - person 3 & project 5
RelationshipBuilder.createRelationshipBuilder(context, pe3_1, pr5_1, isProjectOfPerson)
.build();

// metadata - person 3 & project 6
itemService.addMetadata(context, pe3_1, "dc", "relation", null, null, "project 6 (mdv)");
itemService.addMetadata(context, pe3_1, "dc", "relation", null, null, "project 6 (mdv)", "20000", 300);

// SUMMARY
//
Expand Down
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);
}
}
5 changes: 5 additions & 0 deletions dspace/config/clarin-dspace.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -219,3 +219,8 @@ 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`
## dc.relation authority is configured only because of correct item importing, but it is not used anymore.
authority.controlled.dc.relation = true

0 comments on commit fb252cf

Please sign in to comment.