check for grant, since it is not a mandatory field

This commit is contained in:
Aldo Mihasi 2023-10-05 09:31:56 +03:00
parent ace8cf6189
commit 591ed6fcd9
1 changed files with 24 additions and 20 deletions

View File

@ -234,6 +234,7 @@ public class DMPToZenodoMapper {
deposit.getMetadata().getContributors().addAll(contributors1);
deposit.getMetadata().getContributors().addAll(researchers);
if (dmp.getGrant() != null) {
if (dmp.getGrant().getReference() == null) {
dmp.getGrant().setReference("dmp:" + dmp.getGrant().getId());
}
@ -247,6 +248,7 @@ public class DMPToZenodoMapper {
} catch (IOException e) {
logger.error(e.getLocalizedMessage(), e);
}
if (dmp.getGrant().getFunder() != null && dmp.getGrant().getFunder().getLabel() != null) {
DOIFunder doiFunder = doiFunders.stream()
.filter(doiFunder1 -> dmp.getGrant().getFunder().getLabel().contains(doiFunder1.getFunder()) || doiFunder1.getFunder().contains(dmp.getGrant().getFunder().getLabel()))
.findFirst().orElse(null);
@ -257,6 +259,8 @@ public class DMPToZenodoMapper {
deposit.getMetadata().getGrants().add(grant);
}
}
}
}
ZenodoCreator creator = new ZenodoCreator();
creator.setName(dmp.getUsers().stream().filter(userDMP -> userDMP.getRole().equals(UserDMPDepositModel.UserDMPRoles.OWNER.getValue())).findFirst().get().getUser().getName());
if (dmp.getOrganisations() != null && !dmp.getOrganisations().isEmpty()) {