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:
parent
a78044920a
commit
b878bf9d8f
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue