From 3a340bd73769a1a2cf3a5604c0f503007cb23b87 Mon Sep 17 00:00:00 2001 From: "michele.artini" Date: Mon, 3 Jul 2023 12:37:03 +0200 Subject: [PATCH] fixed invalid prefix --- .../importer/CommunityImporterService.java | 29 ++++++++++++++++--- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/importer/CommunityImporterService.java b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/importer/CommunityImporterService.java index d81c0cd8..006b270c 100644 --- a/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/importer/CommunityImporterService.java +++ b/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/community/importer/CommunityImporterService.java @@ -121,7 +121,15 @@ public class CommunityImporterService { .readValue(json, new TypeReference>>() {}) .entrySet() .stream() - .flatMap(e -> e.getValue().stream().map(community -> new DbOrganization(community, e.getKey()))) + .flatMap(e -> e.getValue() + .stream() + .map(community -> { + if (e.getKey().contains("|")) { + return new DbOrganization(community, StringUtils.substringAfter(e.getKey(), "|")); + } else { + return new DbOrganization(community, e.getKey()); + } + })) .collect(Collectors.toList()); if (!simulation) { @@ -144,7 +152,18 @@ public class CommunityImporterService { final CommunityDetails community = asCommunityDetails(context); final List datasources = - getCommunityInfo(context, CONTENTPROVIDERS_ID_SUFFIX, c -> asCommunityDataprovider(context.getId(), c)); + getCommunityInfo(context, CONTENTPROVIDERS_ID_SUFFIX, c -> asCommunityDataprovider(context.getId(), c)) + .stream() + .map(o -> { + if (o.getOpenaireId() == null) { + log.warn("Openaire ID is missing, organization: " + o.getOfficialname()); + } else if (o.getOpenaireId().contains("|")) { + o.setOpenaireId(StringUtils.substringAfter(o.getOpenaireId(), "|")); + } + return o; + }) + .filter(o -> o.getOpenaireId() != null) + .collect(Collectors.toList()); final List projects = getCommunityInfo(context, PROJECTS_ID_SUFFIX, c -> asCommunityProject(context.getId(), c)) @@ -165,6 +184,8 @@ public class CommunityImporterService { } else { log.warn("Openaire ID is missing, funder: " + p.getFunder()); } + } else if (p.getOpenaireId().contains("|")) { + p.setOpenaireId(StringUtils.substringAfter(p.getOpenaireId(), "|")); } return p; }) @@ -174,10 +195,10 @@ public class CommunityImporterService { final List orgs = getCommunityInfo(context, ORGANIZATION_ID_SUFFIX, c -> asCommunityOrganization(context.getId(), c)); - final List otherZenodoCimmunities = + final List otherZenodoCommunities = getCommunityInfo(context, ZENODOCOMMUNITY_ID_SUFFIX, c -> asZenodoCommunity(c)); - community.setOtherZenodoCommunities(otherZenodoCimmunities); + community.setOtherZenodoCommunities(otherZenodoCommunities); final List subs = context.getCategories() .entrySet()