[Dump] removing all EOSC related addition from master

This commit is contained in:
Miriam Baglioni 2022-10-11 10:57:50 +02:00
parent 67ee82535a
commit 746a06d4ea
5 changed files with 22 additions and 143 deletions

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -9,8 +9,8 @@ import eu.dnetlib.dhp.schema.common.ModelConstants;
public class Constants { public class Constants {
protected static final Map<String, String> accessRightsCoarMap = Maps.newHashMap(); protected static final Map<String, String> ACCESS_RIGHTS_COAR_MAP = Maps.newHashMap();
protected static final Map<String, String> coarCodeLabelMap = Maps.newHashMap(); protected static final Map<String, String> COAR_CODE_LABEL_MAP = Maps.newHashMap();
public static final String INFERRED = "Inferred by OpenAIRE"; public static final String INFERRED = "Inferred by OpenAIRE";
public static final String CABF2 = "c_abf2"; public static final String CABF2 = "c_abf2";
@ -28,22 +28,22 @@ public class Constants {
public static final String RESEARCH_INFRASTRUCTURE = "Research Infrastructure/Initiative"; public static final String RESEARCH_INFRASTRUCTURE = "Research Infrastructure/Initiative";
static { static {
accessRightsCoarMap.put(ModelConstants.ACCESS_RIGHT_OPEN, CABF2); ACCESS_RIGHTS_COAR_MAP.put(ModelConstants.ACCESS_RIGHT_OPEN, CABF2);
accessRightsCoarMap.put("RESTRICTED", "c_16ec"); ACCESS_RIGHTS_COAR_MAP.put("RESTRICTED", "c_16ec");
accessRightsCoarMap.put("OPEN SOURCE", CABF2); ACCESS_RIGHTS_COAR_MAP.put("OPEN SOURCE", CABF2);
accessRightsCoarMap.put(ModelConstants.ACCESS_RIGHT_CLOSED, "c_14cb"); ACCESS_RIGHTS_COAR_MAP.put(ModelConstants.ACCESS_RIGHT_CLOSED, "c_14cb");
accessRightsCoarMap.put(ModelConstants.ACCESS_RIGHT_EMBARGO, "c_f1cf"); ACCESS_RIGHTS_COAR_MAP.put(ModelConstants.ACCESS_RIGHT_EMBARGO, "c_f1cf");
} }
static { static {
coarCodeLabelMap.put(CABF2, ModelConstants.ACCESS_RIGHT_OPEN); COAR_CODE_LABEL_MAP.put(CABF2, ModelConstants.ACCESS_RIGHT_OPEN);
coarCodeLabelMap.put("c_16ec", "RESTRICTED"); COAR_CODE_LABEL_MAP.put("c_16ec", "RESTRICTED");
coarCodeLabelMap.put("c_14cb", ModelConstants.ACCESS_RIGHT_CLOSED); COAR_CODE_LABEL_MAP.put("c_14cb", ModelConstants.ACCESS_RIGHT_CLOSED);
coarCodeLabelMap.put("c_f1cf", "EMBARGO"); COAR_CODE_LABEL_MAP.put("c_f1cf", "EMBARGO");
} }
public enum DUMPTYPE { public enum DUMPTYPE {
COMPLETE("complete"), COMMUNITY("community"), FUNDER("funder"), EOSC("eosc"); COMPLETE("complete"), COMMUNITY("community"), FUNDER("funder");
private final String type; private final String type;

View File

@ -9,12 +9,6 @@ import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; 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.CardinalityTooHighException;
import eu.dnetlib.dhp.oa.graph.dump.exceptions.NoAvailableEntityTypeException; import eu.dnetlib.dhp.oa.graph.dump.exceptions.NoAvailableEntityTypeException;
import eu.dnetlib.dhp.oa.model.*; import eu.dnetlib.dhp.oa.model.*;
@ -43,8 +37,6 @@ public class ResultMapper implements Serializable {
Result out; Result out;
if (Constants.DUMPTYPE.COMPLETE.getType().equals(dumpType)) { if (Constants.DUMPTYPE.COMPLETE.getType().equals(dumpType)) {
out = new GraphResult(); out = new GraphResult();
} else if (Constants.DUMPTYPE.EOSC.getType().equals(dumpType)) {
out = new EoscResult();
} else { } else {
out = new CommunityResult(); out = new CommunityResult();
} }
@ -64,15 +56,15 @@ public class ResultMapper implements Serializable {
// I do not map Access Right UNKNOWN or OTHER // I do not map Access Right UNKNOWN or OTHER
Optional<eu.dnetlib.dhp.schema.oaf.Qualifier> oar = Optional.ofNullable(input.getBestaccessright()); Optional<eu.dnetlib.dhp.schema.oaf.Qualifier> oar = Optional.ofNullable(input.getBestaccessright());
if (oar.isPresent() && Constants.accessRightsCoarMap.containsKey(oar.get().getClassid())) { if (oar.isPresent() && Constants.ACCESS_RIGHTS_COAR_MAP.containsKey(oar.get().getClassid())) {
String code = Constants.accessRightsCoarMap.get(oar.get().getClassid()); String code = Constants.ACCESS_RIGHTS_COAR_MAP.get(oar.get().getClassid());
out out
.setBestaccessright( .setBestaccessright(
BestAccessRight BestAccessRight
.newInstance( .newInstance(
code, code,
Constants.coarCodeLabelMap.get(code), Constants.COAR_CODE_LABEL_MAP.get(code),
Constants.COAR_ACCESS_RIGHT_SCHEMA)); Constants.COAR_ACCESS_RIGHT_SCHEMA));
} }
@ -157,11 +149,7 @@ public class ResultMapper implements Serializable {
((GraphResult) out) ((GraphResult) out)
.setInstance( .setInstance(
oInst.get().stream().map(ResultMapper::getGraphInstance).collect(Collectors.toList())); oInst.get().stream().map(ResultMapper::getGraphInstance).collect(Collectors.toList()));
} else if (Constants.DUMPTYPE.EOSC.getType().equals(dumpType)) { } else {
((EoscResult) out)
.setInstance(
oInst.get().stream().map(ResultMapper::getGraphInstance).collect(Collectors.toList()));
} else {
((CommunityResult) out) ((CommunityResult) out)
.setInstance( .setInstance(
oInst oInst
@ -240,26 +228,7 @@ public class ResultMapper implements Serializable {
out.setType(input.getResulttype().getClassid()); out.setType(input.getResulttype().getClassid());
if (Constants.DUMPTYPE.EOSC.getType().equals(dumpType)) { if (!Constants.DUMPTYPE.COMPLETE.getType().equals(dumpType)) {
if (Optional.ofNullable(input.getEoscifguidelines()).isPresent()) {
List<EoscIfGuidelines> 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)) {
((CommunityResult) out) ((CommunityResult) out)
.setCollectedfrom( .setCollectedfrom(
input input
@ -472,15 +441,15 @@ public class ResultMapper implements Serializable {
private static <I extends Instance> void setCommonValue(eu.dnetlib.dhp.schema.oaf.Instance i, I instance) { private static <I extends Instance> void setCommonValue(eu.dnetlib.dhp.schema.oaf.Instance i, I instance) {
Optional<eu.dnetlib.dhp.schema.oaf.AccessRight> opAr = Optional.ofNullable(i.getAccessright()); Optional<eu.dnetlib.dhp.schema.oaf.AccessRight> opAr = Optional.ofNullable(i.getAccessright());
if (opAr.isPresent() && Constants.accessRightsCoarMap.containsKey(opAr.get().getClassid())) { if (opAr.isPresent() && Constants.ACCESS_RIGHTS_COAR_MAP.containsKey(opAr.get().getClassid())) {
String code = Constants.accessRightsCoarMap.get(opAr.get().getClassid()); String code = Constants.ACCESS_RIGHTS_COAR_MAP.get(opAr.get().getClassid());
instance instance
.setAccessright( .setAccessright(
AccessRight AccessRight
.newInstance( .newInstance(
code, code,
Constants.coarCodeLabelMap.get(code), Constants.COAR_CODE_LABEL_MAP.get(code),
Constants.COAR_ACCESS_RIGHT_SCHEMA)); Constants.COAR_ACCESS_RIGHT_SCHEMA));
Optional<List<eu.dnetlib.dhp.schema.oaf.Measure>> mes = Optional.ofNullable(i.getMeasures()); Optional<List<eu.dnetlib.dhp.schema.oaf.Measure>> mes = Optional.ofNullable(i.getMeasures());

View File

@ -317,7 +317,7 @@ public class DumpJobTest {
Assertions.assertEquals(ModelConstants.ACCESS_RIGHT_OPEN, gr.getBestaccessright().getLabel()); Assertions.assertEquals(ModelConstants.ACCESS_RIGHT_OPEN, gr.getBestaccessright().getLabel());
Assertions Assertions
.assertEquals( .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("One Ecosystem", gr.getContainer().getName());
Assertions.assertEquals("2367-8194", gr.getContainer().getIssnOnline()); Assertions.assertEquals("2367-8194", gr.getContainer().getIssnOnline());
@ -373,7 +373,7 @@ public class DumpJobTest {
.getAccessright() .getAccessright()
.getCode() .getCode()
.equals( .equals(
Constants.accessRightsCoarMap Constants.ACCESS_RIGHTS_COAR_MAP
.get(ModelConstants.ACCESS_RIGHT_OPEN))); .get(ModelConstants.ACCESS_RIGHT_OPEN)));
Assertions.assertTrue(instance.getAccessright().getLabel().equals(ModelConstants.ACCESS_RIGHT_OPEN)); Assertions.assertTrue(instance.getAccessright().getLabel().equals(ModelConstants.ACCESS_RIGHT_OPEN));
Assertions.assertTrue(instance.getAccessright().getOpenAccessRoute().equals(OpenAccessRoute.green)); Assertions.assertTrue(instance.getAccessright().getOpenAccessRoute().equals(OpenAccessRoute.green));