Skip to content

Commit

Permalink
remove fdo profile from request
Browse files Browse the repository at this point in the history
  • Loading branch information
southeo committed May 1, 2024
1 parent 188206e commit 4d44e9a
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,16 @@

@Getter
public enum FdoProfileAttributes {
FDO_PROFILE("fdoProfile", null),
// Issued for agent should be DiSSCo PID; currently it's set as Naturalis's ROR
ISSUED_FOR_AGENT("issuedForAgent", "https://ror.org/0566bfb96"),
ISSUED_FOR_AGENT("issuedForAgent"),
// Mapping
SOURCE_DATA_STANDARD("sourceDataStandard", null),
SOURCE_DATA_STANDARD("sourceDataStandard"),
// Source System
SOURCE_SYSTEM_NAME("sourceSystemName", null),
MAS_NAME("machineAnnotationServiceName", null);
SOURCE_SYSTEM_NAME("sourceSystemName"),
MAS_NAME("machineAnnotationServiceName");

private final String attribute;
private final String defaultValue;

private FdoProfileAttributes(String attribute, String defaultValue) {
this.attribute = attribute;
this.defaultValue = defaultValue;
}
FdoProfileAttributes(String attribute) {
this.attribute = attribute;}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package eu.dissco.orchestration.backend.service;

import static eu.dissco.orchestration.backend.domain.FdoProfileAttributes.FDO_PROFILE;
import static eu.dissco.orchestration.backend.domain.FdoProfileAttributes.ISSUED_FOR_AGENT;
import static eu.dissco.orchestration.backend.domain.FdoProfileAttributes.MAS_NAME;
import static eu.dissco.orchestration.backend.domain.FdoProfileAttributes.SOURCE_DATA_STANDARD;
Expand All @@ -23,6 +22,7 @@
public class FdoRecordService {

private final ObjectMapper mapper;
private static final String ISSUED_FOR_AGENT_ROR = "https://ror.org/0566bfb96";

public JsonNode buildCreateRequest(Object object, ObjectType type) {
var request = mapper.createObjectNode();
Expand Down Expand Up @@ -56,29 +56,23 @@ private JsonNode buildRequestAttributes(Object object, ObjectType type) {
}

private JsonNode buildMappingAttributes(Mapping mapping) {
var attributes = buildGeneralAttributes(ObjectType.MAPPING);
attributes.put(SOURCE_DATA_STANDARD.getAttribute(), mapping.sourceDataStandard());
return attributes;
return buildGeneralAttributes()
.put(SOURCE_DATA_STANDARD.getAttribute(), mapping.sourceDataStandard());
}

private JsonNode buildMasAttributes(MachineAnnotationService mas) {
var attributes = buildGeneralAttributes(ObjectType.MAS);
attributes.put(MAS_NAME.getAttribute(), mas.getName());
return attributes;
return buildGeneralAttributes()
.put(MAS_NAME.getAttribute(), mas.getName());
}

private JsonNode buildSourceSystemAttributes(SourceSystem sourceSystem) {
var attributes = buildGeneralAttributes(ObjectType.SOURCE_SYSTEM);
attributes.put(SOURCE_SYSTEM_NAME.getAttribute(), sourceSystem.name());
return attributes;
return buildGeneralAttributes()
.put(SOURCE_SYSTEM_NAME.getAttribute(), sourceSystem.name());
}

private ObjectNode buildGeneralAttributes(ObjectType type) {
var attributes = mapper.createObjectNode();
attributes.put(FDO_PROFILE.getAttribute(), type.getFdoProfile());
attributes.put(ISSUED_FOR_AGENT.getAttribute(), ISSUED_FOR_AGENT.getDefaultValue());
return attributes;
private ObjectNode buildGeneralAttributes() {
return mapper.createObjectNode()
.put(ISSUED_FOR_AGENT.getAttribute(), ISSUED_FOR_AGENT_ROR);
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,6 @@ public static JsonNode givenMasHandleRequest() throws Exception {
"data": {
"type": "https://hdl.handle.net/21.T11148/22e71a0015cbcfba8ffa",
"attributes": {
"fdoProfile": "https://hdl.handle.net/21.T11148/22e71a0015cbcfba8ffa",
"issuedForAgent": "https://ror.org/0566bfb96",
"machineAnnotationServiceName":"A Machine Annotation Service"
}
Expand All @@ -277,7 +276,6 @@ public static JsonNode givenSourceSystemHandleRequest() throws Exception{
"data": {
"type": "https://hdl.handle.net/21.T11148/417a4f472f60f7974c12",
"attributes": {
"fdoProfile": "https://hdl.handle.net/21.T11148/417a4f472f60f7974c12",
"issuedForAgent": "https://ror.org/0566bfb96",
"sourceSystemName":"Naturalis Tunicate DWCA endpoint"
}
Expand All @@ -291,7 +289,6 @@ public static JsonNode givenMappingHandleRequest() throws Exception {
"data": {
"type": "https://hdl.handle.net/21.T11148/ce794a6f4df42eb7e77e",
"attributes": {
"fdoProfile": "https://hdl.handle.net/21.T11148/ce794a6f4df42eb7e77e",
"issuedForAgent": "https://ror.org/0566bfb96",
"sourceDataStandard": "dwc"
}
Expand Down

0 comments on commit 4d44e9a

Please sign in to comment.