Fetching funders on grants for dmps for public API

This commit is contained in:
Thomas Georgios Giannos 2023-11-28 16:50:00 +02:00
parent b00b048632
commit e6cba30e4c
1 changed files with 9 additions and 0 deletions

View File

@ -79,7 +79,15 @@ public class GrantPublicOverviewModel {
}
public static GrantPublicOverviewModel fromDmpReferences(List<DmpReference> dmpReferences) {
FunderPublicOverviewModel funder = null;
for (DmpReference dmpReference : dmpReferences) {
if (dmpReference.getReference().getType() == ReferenceType.Funder) {
funder = new FunderPublicOverviewModel();
Reference reference = dmpReference.getReference();
funder.setId(reference.getId());
funder.setLabel(reference.getLabel());
continue;
}
if (dmpReference.getReference().getType() != ReferenceType.Grants)
continue;
GrantPublicOverviewModel model = new GrantPublicOverviewModel();
@ -88,6 +96,7 @@ public class GrantPublicOverviewModel {
model.setDescription(reference.getDescription());
model.setAbbreviation(reference.getAbbreviation());
model.setLabel(reference.getLabel());
model.setFunder(funder);
Field startDate = reference.getDefinition().getFields().stream().filter(x -> x.getCode().equals("startDate")).toList().get(0);
if (startDate != null) model.setStartDate(Date.from(Instant.parse(startDate.getValue())));
Field endDate = reference.getDefinition().getFields().stream().filter(x -> x.getCode().equals("endDate")).toList().get(0);