fixed invalid prefix

This commit is contained in:
Michele Artini 2023-07-03 12:37:03 +02:00
parent 6f873b1e45
commit 3a340bd737
1 changed files with 25 additions and 4 deletions

View File

@ -121,7 +121,15 @@ public class CommunityImporterService {
.readValue(json, new TypeReference<Map<String, List<String>>>() {})
.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<CommunityContentprovider> 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<CommunityProject> 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<CommunityOrganization> orgs =
getCommunityInfo(context, ORGANIZATION_ID_SUFFIX, c -> asCommunityOrganization(context.getId(), c));
final List<String> otherZenodoCimmunities =
final List<String> otherZenodoCommunities =
getCommunityInfo(context, ZENODOCOMMUNITY_ID_SUFFIX, c -> asZenodoCommunity(c));
community.setOtherZenodoCommunities(otherZenodoCimmunities);
community.setOtherZenodoCommunities(otherZenodoCommunities);
final List<SubCommunity> subs = context.getCategories()
.entrySet()