[SKG-IF] trying to fix exception for missing collectedfrom in instance

This commit is contained in:
Miriam Baglioni 2024-06-06 09:37:26 +02:00
parent 233aa9ed82
commit c2ecfdd6cb
1 changed files with 25 additions and 9 deletions

View File

@ -274,9 +274,9 @@ public class DumpResearchProduct implements Serializable {
.mapGroups((MapGroupsFunction<String, Tuple2<Publication, Row>, ResearchProduct>) (k, v) -> {
ArrayList<String> journalHbIds = new ArrayList<>();
Tuple2<Publication, Row> first = v.next();
if (Optional.ofNullable(first._2()).isPresent())
journalHbIds.add(first._2().getAs("journalHostedBy"));
v.forEachRemaining(value -> journalHbIds.add(value._2().getAs("journalHostedBy")));
addJournalHostedbyId(first, journalHbIds);
while (v.hasNext())
addJournalHostedbyId(v.next(), journalHbIds);
Publication p = first._1();
ResearchProduct rp = ResultMapper.map(p);
rp
@ -295,6 +295,11 @@ public class DumpResearchProduct implements Serializable {
.json(workingDir + "products" + e.name() + "/temp_researchProduct");
}
private static void addJournalHostedbyId(Tuple2<Publication, Row> next, ArrayList<String> journalHbIds) {
if (Optional.ofNullable(next._2()).isPresent())
journalHbIds.add(next._2().getAs("jopurnalHostedBy"));
}
@NotNull
private static <R extends Result> Manifestation getManifestation(Instance i, ArrayList<String> journalHbIds, R p,
List<MasterDuplicate> eoscDatasourceIdMap) {
@ -347,12 +352,23 @@ public class DumpResearchProduct implements Serializable {
List<MasterDuplicate> eoscDsIds = eoscDatasourceIdMap
.stream()
.filter(
dm -> dm
.getGraphId()
.equals(i.getHostedby().getKey()) ||
dm
.getGraphId()
.equals(i.getCollectedfrom().getKey()))
dm -> Optional
.ofNullable(i.getHostedby())
.map(
hb -> Optional
.ofNullable(hb.getKey())
.map(key -> key.equalsIgnoreCase(dm.getGraphId()))
.orElse(false))
.orElse(false)
||
Optional
.ofNullable(i.getCollectedfrom())
.map(
cf -> Optional
.ofNullable(cf.getKey())
.map(key -> key.equalsIgnoreCase(dm.getGraphId()))
.orElse(false))
.orElse(false))
.collect(Collectors.toList());
if (eoscDsIds.size() > 0) {