[EOSC Dump] modifying schema and code for eosc if guidelines to accomodate elements with more than one correspondence

This commit is contained in:
Miriam Baglioni 2022-11-22 16:42:13 +01:00
parent 795d4cc1dc
commit 3efb8be533
3 changed files with 13 additions and 92 deletions

View File

@ -15,7 +15,7 @@ import eu.dnetlib.dhp.oa.model.community.CommunityResult;
public class EoscResult extends CommunityResult {
@JsonSchema(description = "Describes a reference to the EOSC Interoperability Framework (IF) Guidelines")
private EoscInteroperabilityFramework eoscIF;
private List<EoscInteroperabilityFramework> eoscIF;
@JsonSchema(description = "The subject dumped by type associated to the result")
private Map<String, List<Subject>> subject;
@ -45,11 +45,11 @@ public class EoscResult extends CommunityResult {
this.keywords = keywords;
}
public EoscInteroperabilityFramework getEoscIF() {
public List<EoscInteroperabilityFramework> getEoscIF() {
return eoscIF;
}
public void setEoscIF(EoscInteroperabilityFramework eoscIF) {
public void setEoscIF(List<EoscInteroperabilityFramework> eoscIF) {
this.eoscIF = eoscIF;
}

View File

@ -56,28 +56,6 @@ public class ResultMapper implements Serializable {
addTypeSpecificInformation(out, input, ort);
// if (Optional.ofNullable(((eu.dnetlib.dhp.schema.oaf.Result) in).getMeasures()).isPresent()) {
// String downloads = "";
// String views = "";
// for (eu.dnetlib.dhp.schema.oaf.Measure m : ((eu.dnetlib.dhp.schema.oaf.Result) in)
// .getMeasures()
// .stream()
// .filter(m -> m.getId().equals("downloads") || m.getId().equals("views"))
// .collect(Collectors.toList())) {
// if (m.getId().equals("downloads")) {
// downloads = m.getUnit().get(0).getValue();
// }
// if (m.getId().equals("views")) {
// views = m.getUnit().get(0).getValue();
// }
//
// }
// if (downloads != "" && views != "") {
// ((EoscResult) out).setIndicator(Indicator.newInstance(downloads, views));
// }
//
// }
Optional
.ofNullable(input.getAuthor())
.ifPresent(
@ -269,77 +247,20 @@ public class ResultMapper implements Serializable {
!s.getValue().equalsIgnoreCase("EOSC::RO-crate"))
.map(s -> s.getValue())
.collect(Collectors.toList()));
long eoscSubjectNumber = input
.getSubject()
.stream()
.filter(s -> s.getValue().equalsIgnoreCase("EOSC::RO-crate"))
.count();
// if (eoscSubjectNumber > 1) {
// throw new CardinalityTooHighException(
// "EOSC IF in the result has cardinality greater than one. Change dump!");
// }
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()));
}
}
if (eoscSubjectNumber > 0 && Optional.ofNullable(((EoscResult) out).getEoscIF()).isPresent()) {
throw new CardinalityTooHighException(
"EOSC IF in the result has cardinality greater than one. Change dump!");
} else {
if (eoscSubjectNumber > 0) {
StructuredProperty ifra = input
.getSubject()
((EoscResult) out)
.setEoscIF(input.getEoscifguidelines()
.stream()
.filter(s -> s.getValue().equalsIgnoreCase("EOSC::RO-crate"))
.findFirst()
.get();
((EoscResult) out)
.setEoscIF(
EoscInteroperabilityFramework
.newInstance(
ifra.getValue(), ifra.getValue(), "",
"compliesWith"));
}
.map(eig -> EoscInteroperabilityFramework.newInstance(eig.getCode(), eig.getLabel(), eig.getUrl(), eig.getSemanticRelation()))
.collect(Collectors.toList()));
}
}
}
out.setType(input.getResulttype().getClassid());
// if (Constants.DUMPTYPE.EOSC.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()));
//
// }
// }
// }
if (!Constants.DUMPTYPE.COMPLETE.getType().equals(dumpType)) {
if (!Constants.DUMPTYPE.EOSC.getType().equals(dumpType)) {
((CommunityResult) out)

View File

@ -921,10 +921,10 @@ public class DumpJobTest {
Assertions.assertEquals(1, verificationDataset.filter("type = 'dataset'").count());
Assertions.assertEquals(1, tmp.filter(d -> d.getEoscIF().getCode().equals("EOSC::Twitter Data")).count());
Assertions.assertEquals(1, tmp.filter(d -> d.getEoscIF().getLabel().equals("EOSC::Twitter Data")).count());
Assertions.assertEquals(1, tmp.filter(d -> d.getEoscIF().getUrl().equals("")).count());
Assertions.assertEquals(1, tmp.filter(d -> d.getEoscIF().getSemanticRelation().equals("compliesWith")).count());
Assertions.assertEquals(1, tmp.filter(d -> d.getEoscIF().stream().anyMatch(c -> c.getCode().equals("EOSC::Twitter Data"))).count());
Assertions.assertEquals(1, tmp.filter(d -> d.getEoscIF().stream().anyMatch(c -> c.getLabel().equals("EOSC::Twitter Data"))).count());
Assertions.assertEquals(1, tmp.filter(d -> d.getEoscIF().stream().anyMatch(c -> c.getUrl().equals(""))).count());
Assertions.assertEquals(1, tmp.filter(d -> d.getEoscIF().stream().anyMatch(c -> c.getSemanticRelation().equals("compliesWith"))).count());
System.out.println(OBJECT_MAPPER.writeValueAsString(verificationDataset.first()));