From faea30cda0fd4ccae91be5d83d34b5427ec528c3 Mon Sep 17 00:00:00 2001 From: "miriam.baglioni" Date: Thu, 9 Jul 2020 14:05:21 +0200 Subject: [PATCH] - --- .../community/QueryInformationSystem.java | 2 +- .../dhp/bulktag/community/ResultTagger.java | 29 ++++++++++++------- 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/dhp-workflows/dhp-enrichment/src/main/java/eu/dnetlib/dhp/bulktag/community/QueryInformationSystem.java b/dhp-workflows/dhp-enrichment/src/main/java/eu/dnetlib/dhp/bulktag/community/QueryInformationSystem.java index cb5ad083b..6a40bc2e2 100644 --- a/dhp-workflows/dhp-enrichment/src/main/java/eu/dnetlib/dhp/bulktag/community/QueryInformationSystem.java +++ b/dhp-workflows/dhp-enrichment/src/main/java/eu/dnetlib/dhp/bulktag/community/QueryInformationSystem.java @@ -41,7 +41,7 @@ public class QueryInformationSystem { + " " + " } " + " " + - " "+ + " " + "{for $zc in $zenodo " + "return " + " " + diff --git a/dhp-workflows/dhp-enrichment/src/main/java/eu/dnetlib/dhp/bulktag/community/ResultTagger.java b/dhp-workflows/dhp-enrichment/src/main/java/eu/dnetlib/dhp/bulktag/community/ResultTagger.java index f5a985d15..d58704b75 100644 --- a/dhp-workflows/dhp-enrichment/src/main/java/eu/dnetlib/dhp/bulktag/community/ResultTagger.java +++ b/dhp-workflows/dhp-enrichment/src/main/java/eu/dnetlib/dhp/bulktag/community/ResultTagger.java @@ -71,10 +71,9 @@ public class ResultTagger implements Serializable { // tagging for Subject final Set subjects = new HashSet<>(); - Optional> oresultsubj = Optional.ofNullable(result.getSubject()); - if (oresultsubj.isPresent()) { - oresultsubj - .get() + + if (Objects.nonNull(result.getSubject())){ + result.getSubject() .stream() .map(subject -> subject.getValue()) .filter(StringUtils::isNotBlank) @@ -90,15 +89,23 @@ public class ResultTagger implements Serializable { final Set datasources = new HashSet<>(); final Set tmp = new HashSet<>(); - Optional> oresultinstance = Optional.ofNullable(result.getInstance()); - if (oresultinstance.isPresent()) { - for (Instance i : oresultinstance.get()) { - tmp.add(StringUtils.substringAfter(i.getCollectedfrom().getKey(), "|")); - tmp.add(StringUtils.substringAfter(i.getHostedby().getKey(), "|")); + if (Objects.nonNull(result.getInstance())) { + for (Instance i : result.getInstance()) { + if(Objects.nonNull(i.getCollectedfrom())){ + if(Objects.nonNull(i.getCollectedfrom().getKey())){ + tmp.add(StringUtils.substringAfter(i.getCollectedfrom().getKey(), "|")); + } + } + if(Objects.nonNull(i.getHostedby())){ + if(Objects.nonNull(i.getHostedby().getKey())){ + tmp.add(StringUtils.substringAfter(i.getHostedby().getKey(), "|")); + } + } + } - oresultinstance - .get() + result + .getInstance() .stream() .map(i -> new Pair<>(i.getCollectedfrom().getKey(), i.getHostedby().getKey())) .flatMap(p -> Stream.of(p.getFst(), p.getSnd()))