Fix issue when importing from RDA and the predefined template(s) inside the json does not exist on the database

This commit is contained in:
George Kalampokis 2020-10-13 11:05:01 +03:00
parent a78044920a
commit b878bf9d8f
1 changed files with 2 additions and 2 deletions

View File

@ -102,7 +102,7 @@ public class DmpRDAMapper {
entity.setDoi(rda.getDmpId().getIdentifier());
}
if (((List<String>) rda.getAdditionalProperties().get("templates")) != null && !((List<String>) rda.getAdditionalProperties().get("templates")).isEmpty()) {
entity.setAssociatedDmps(((List<String>) rda.getAdditionalProperties().get("templates")).stream().map(this::getProfile).collect(Collectors.toSet()));
entity.setAssociatedDmps(((List<String>) rda.getAdditionalProperties().get("templates")).stream().map(this::getProfile).filter(Objects::nonNull).collect(Collectors.toSet()));
}
if (entity.getAssociatedDmps() == null) {
entity.setAssociatedDmps(new HashSet<>());
@ -134,6 +134,6 @@ public class DmpRDAMapper {
}
private DatasetProfile getProfile(String id) {
return apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().find(UUID.fromString(id));
return apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().asQueryable().where(((builder, root) -> builder.equal(root.get("id"), UUID.fromString(id)))).getSingleOrDefault();
}
}