From 746a06d4ea1939483f6016d14bb0411e4cc382c5 Mon Sep 17 00:00:00 2001 From: "miriam.baglioni" Date: Tue, 11 Oct 2022 10:57:50 +0200 Subject: [PATCH] [Dump] removing all EOSC related addition from master --- .../model/EoscInteroperabilityFramework.java | 67 ------------------- .../eu/dnetlib/dhp/eosc/model/EoscResult.java | 23 ------- .../dnetlib/dhp/oa/graph/dump/Constants.java | 24 +++---- .../dhp/oa/graph/dump/ResultMapper.java | 47 +++---------- .../dhp/oa/graph/dump/DumpJobTest.java | 4 +- 5 files changed, 22 insertions(+), 143 deletions(-) delete mode 100644 dump-schema/src/main/java/eu/dnetlib/dhp/eosc/model/EoscInteroperabilityFramework.java delete mode 100644 dump-schema/src/main/java/eu/dnetlib/dhp/eosc/model/EoscResult.java diff --git a/dump-schema/src/main/java/eu/dnetlib/dhp/eosc/model/EoscInteroperabilityFramework.java b/dump-schema/src/main/java/eu/dnetlib/dhp/eosc/model/EoscInteroperabilityFramework.java deleted file mode 100644 index 8b92bb2..0000000 --- a/dump-schema/src/main/java/eu/dnetlib/dhp/eosc/model/EoscInteroperabilityFramework.java +++ /dev/null @@ -1,67 +0,0 @@ - -package eu.dnetlib.dhp.eosc.model; - -import java.io.Serializable; - -import com.github.imifou.jsonschema.module.addon.annotation.JsonSchema; - -/** - * @author miriam.baglioni - * @Date 29/07/22 - */ -public class EoscInteroperabilityFramework implements Serializable { - @JsonSchema(description = "EOSC-IF label") - private String label; - - @JsonSchema( - description = "EOSC-IF local code. Later on it could be populated with a PID (e.g. DOI), but for the time being we stick to a more loose definition.") - private String code; - - @JsonSchema(description = "EOSC-IF url to the guidelines") - private String url; - - @JsonSchema(description = "EOSC-IF semantic relation (e.g. compliesWith)") - private String semanticRelation; - - public String getLabel() { - return label; - } - - public void setLabel(String label) { - this.label = label; - } - - public String getCode() { - return code; - } - - public void setCode(String code) { - this.code = code; - } - - public String getUrl() { - return url; - } - - public void setUrl(String url) { - this.url = url; - } - - public String getSemanticRelation() { - return semanticRelation; - } - - public void setSemanticRelation(String semanticRelation) { - this.semanticRelation = semanticRelation; - } - - public static EoscInteroperabilityFramework newInstance(String code, String label, String url, - String semanticRelation) { - EoscInteroperabilityFramework eif = new EoscInteroperabilityFramework(); - eif.label = label; - eif.code = code; - eif.url = url; - eif.semanticRelation = semanticRelation; - return eif; - } -} diff --git a/dump-schema/src/main/java/eu/dnetlib/dhp/eosc/model/EoscResult.java b/dump-schema/src/main/java/eu/dnetlib/dhp/eosc/model/EoscResult.java deleted file mode 100644 index 1bbc675..0000000 --- a/dump-schema/src/main/java/eu/dnetlib/dhp/eosc/model/EoscResult.java +++ /dev/null @@ -1,23 +0,0 @@ - -package eu.dnetlib.dhp.eosc.model; - -import com.github.imifou.jsonschema.module.addon.annotation.JsonSchema; - -import eu.dnetlib.dhp.oa.model.graph.GraphResult; - -/** - * @author miriam.baglioni - * @Date 29/07/22 - */ -public class EoscResult extends GraphResult { - @JsonSchema(description = "Describes a reference to the EOSC Interoperability Framework (IF) Guidelines") - private EoscInteroperabilityFramework eoscIF; - - public EoscInteroperabilityFramework getEoscIF() { - return eoscIF; - } - - public void setEoscIF(EoscInteroperabilityFramework eoscIF) { - this.eoscIF = eoscIF; - } -} diff --git a/dump/src/main/java/eu/dnetlib/dhp/oa/graph/dump/Constants.java b/dump/src/main/java/eu/dnetlib/dhp/oa/graph/dump/Constants.java index 06f7d79..7c74066 100644 --- a/dump/src/main/java/eu/dnetlib/dhp/oa/graph/dump/Constants.java +++ b/dump/src/main/java/eu/dnetlib/dhp/oa/graph/dump/Constants.java @@ -9,8 +9,8 @@ import eu.dnetlib.dhp.schema.common.ModelConstants; public class Constants { - protected static final Map accessRightsCoarMap = Maps.newHashMap(); - protected static final Map coarCodeLabelMap = Maps.newHashMap(); + protected static final Map ACCESS_RIGHTS_COAR_MAP = Maps.newHashMap(); + protected static final Map COAR_CODE_LABEL_MAP = Maps.newHashMap(); public static final String INFERRED = "Inferred by OpenAIRE"; public static final String CABF2 = "c_abf2"; @@ -28,22 +28,22 @@ public class Constants { public static final String RESEARCH_INFRASTRUCTURE = "Research Infrastructure/Initiative"; static { - accessRightsCoarMap.put(ModelConstants.ACCESS_RIGHT_OPEN, CABF2); - accessRightsCoarMap.put("RESTRICTED", "c_16ec"); - accessRightsCoarMap.put("OPEN SOURCE", CABF2); - accessRightsCoarMap.put(ModelConstants.ACCESS_RIGHT_CLOSED, "c_14cb"); - accessRightsCoarMap.put(ModelConstants.ACCESS_RIGHT_EMBARGO, "c_f1cf"); + ACCESS_RIGHTS_COAR_MAP.put(ModelConstants.ACCESS_RIGHT_OPEN, CABF2); + ACCESS_RIGHTS_COAR_MAP.put("RESTRICTED", "c_16ec"); + ACCESS_RIGHTS_COAR_MAP.put("OPEN SOURCE", CABF2); + ACCESS_RIGHTS_COAR_MAP.put(ModelConstants.ACCESS_RIGHT_CLOSED, "c_14cb"); + ACCESS_RIGHTS_COAR_MAP.put(ModelConstants.ACCESS_RIGHT_EMBARGO, "c_f1cf"); } static { - coarCodeLabelMap.put(CABF2, ModelConstants.ACCESS_RIGHT_OPEN); - coarCodeLabelMap.put("c_16ec", "RESTRICTED"); - coarCodeLabelMap.put("c_14cb", ModelConstants.ACCESS_RIGHT_CLOSED); - coarCodeLabelMap.put("c_f1cf", "EMBARGO"); + COAR_CODE_LABEL_MAP.put(CABF2, ModelConstants.ACCESS_RIGHT_OPEN); + COAR_CODE_LABEL_MAP.put("c_16ec", "RESTRICTED"); + COAR_CODE_LABEL_MAP.put("c_14cb", ModelConstants.ACCESS_RIGHT_CLOSED); + COAR_CODE_LABEL_MAP.put("c_f1cf", "EMBARGO"); } public enum DUMPTYPE { - COMPLETE("complete"), COMMUNITY("community"), FUNDER("funder"), EOSC("eosc"); + COMPLETE("complete"), COMMUNITY("community"), FUNDER("funder"); private final String type; diff --git a/dump/src/main/java/eu/dnetlib/dhp/oa/graph/dump/ResultMapper.java b/dump/src/main/java/eu/dnetlib/dhp/oa/graph/dump/ResultMapper.java index 8d4035b..6e9d20f 100644 --- a/dump/src/main/java/eu/dnetlib/dhp/oa/graph/dump/ResultMapper.java +++ b/dump/src/main/java/eu/dnetlib/dhp/oa/graph/dump/ResultMapper.java @@ -9,12 +9,6 @@ import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.ObjectMapper; - -import eu.dnetlib.dhp.eosc.model.EoscInteroperabilityFramework; -import eu.dnetlib.dhp.eosc.model.EoscResult; -import eu.dnetlib.dhp.oa.graph.dump.eosc.SelectEoscResultsJobStep1; import eu.dnetlib.dhp.oa.graph.dump.exceptions.CardinalityTooHighException; import eu.dnetlib.dhp.oa.graph.dump.exceptions.NoAvailableEntityTypeException; import eu.dnetlib.dhp.oa.model.*; @@ -43,8 +37,6 @@ public class ResultMapper implements Serializable { Result out; if (Constants.DUMPTYPE.COMPLETE.getType().equals(dumpType)) { out = new GraphResult(); - } else if (Constants.DUMPTYPE.EOSC.getType().equals(dumpType)) { - out = new EoscResult(); } else { out = new CommunityResult(); } @@ -64,15 +56,15 @@ public class ResultMapper implements Serializable { // I do not map Access Right UNKNOWN or OTHER Optional oar = Optional.ofNullable(input.getBestaccessright()); - if (oar.isPresent() && Constants.accessRightsCoarMap.containsKey(oar.get().getClassid())) { - String code = Constants.accessRightsCoarMap.get(oar.get().getClassid()); + if (oar.isPresent() && Constants.ACCESS_RIGHTS_COAR_MAP.containsKey(oar.get().getClassid())) { + String code = Constants.ACCESS_RIGHTS_COAR_MAP.get(oar.get().getClassid()); out .setBestaccessright( BestAccessRight .newInstance( code, - Constants.coarCodeLabelMap.get(code), + Constants.COAR_CODE_LABEL_MAP.get(code), Constants.COAR_ACCESS_RIGHT_SCHEMA)); } @@ -157,11 +149,7 @@ public class ResultMapper implements Serializable { ((GraphResult) out) .setInstance( oInst.get().stream().map(ResultMapper::getGraphInstance).collect(Collectors.toList())); - } else if (Constants.DUMPTYPE.EOSC.getType().equals(dumpType)) { - ((EoscResult) out) - .setInstance( - oInst.get().stream().map(ResultMapper::getGraphInstance).collect(Collectors.toList())); - } else { + } else { ((CommunityResult) out) .setInstance( oInst @@ -240,26 +228,7 @@ public class ResultMapper implements Serializable { out.setType(input.getResulttype().getClassid()); - if (Constants.DUMPTYPE.EOSC.getType().equals(dumpType)) { - if (Optional.ofNullable(input.getEoscifguidelines()).isPresent()) { - List gei = input.getEoscifguidelines(); - if (gei.size() > 1) { - throw new CardinalityTooHighException( - "EOSC IF in the result has cardinality greater than one. Change dump!"); - } - if (gei.size() == 1) { - - EoscIfGuidelines ifra = gei.get(0); - ((EoscResult) out) - .setEoscIF( - EoscInteroperabilityFramework - .newInstance( - ifra.getCode(), ifra.getLabel(), ifra.getUrl(), - ifra.getSemanticRelation())); - - } - } - } else if (!Constants.DUMPTYPE.COMPLETE.getType().equals(dumpType)) { + if (!Constants.DUMPTYPE.COMPLETE.getType().equals(dumpType)) { ((CommunityResult) out) .setCollectedfrom( input @@ -472,15 +441,15 @@ public class ResultMapper implements Serializable { private static void setCommonValue(eu.dnetlib.dhp.schema.oaf.Instance i, I instance) { Optional opAr = Optional.ofNullable(i.getAccessright()); - if (opAr.isPresent() && Constants.accessRightsCoarMap.containsKey(opAr.get().getClassid())) { - String code = Constants.accessRightsCoarMap.get(opAr.get().getClassid()); + if (opAr.isPresent() && Constants.ACCESS_RIGHTS_COAR_MAP.containsKey(opAr.get().getClassid())) { + String code = Constants.ACCESS_RIGHTS_COAR_MAP.get(opAr.get().getClassid()); instance .setAccessright( AccessRight .newInstance( code, - Constants.coarCodeLabelMap.get(code), + Constants.COAR_CODE_LABEL_MAP.get(code), Constants.COAR_ACCESS_RIGHT_SCHEMA)); Optional> mes = Optional.ofNullable(i.getMeasures()); diff --git a/dump/src/test/java/eu/dnetlib/dhp/oa/graph/dump/DumpJobTest.java b/dump/src/test/java/eu/dnetlib/dhp/oa/graph/dump/DumpJobTest.java index 34da999..0cfade8 100644 --- a/dump/src/test/java/eu/dnetlib/dhp/oa/graph/dump/DumpJobTest.java +++ b/dump/src/test/java/eu/dnetlib/dhp/oa/graph/dump/DumpJobTest.java @@ -317,7 +317,7 @@ public class DumpJobTest { Assertions.assertEquals(ModelConstants.ACCESS_RIGHT_OPEN, gr.getBestaccessright().getLabel()); Assertions .assertEquals( - Constants.accessRightsCoarMap.get(ModelConstants.ACCESS_RIGHT_OPEN), gr.getBestaccessright().getCode()); + Constants.ACCESS_RIGHTS_COAR_MAP.get(ModelConstants.ACCESS_RIGHT_OPEN), gr.getBestaccessright().getCode()); Assertions.assertEquals("One Ecosystem", gr.getContainer().getName()); Assertions.assertEquals("2367-8194", gr.getContainer().getIssnOnline()); @@ -373,7 +373,7 @@ public class DumpJobTest { .getAccessright() .getCode() .equals( - Constants.accessRightsCoarMap + Constants.ACCESS_RIGHTS_COAR_MAP .get(ModelConstants.ACCESS_RIGHT_OPEN))); Assertions.assertTrue(instance.getAccessright().getLabel().equals(ModelConstants.ACCESS_RIGHT_OPEN)); Assertions.assertTrue(instance.getAccessright().getOpenAccessRoute().equals(OpenAccessRoute.green));