Rda mapper will now be able to use the new DMP fields

This commit is contained in:
George Kalampokis 2020-07-02 18:36:18 +03:00
parent 7127f6dbd6
commit 6d491b5930
1 changed files with 22 additions and 3 deletions

View File

@ -3,6 +3,7 @@ package eu.eudat.models.rda.mapper;
import eu.eudat.data.entities.*;
import eu.eudat.logic.services.ApiContext;
import eu.eudat.logic.utilities.helpers.StreamDistinctBy;
import eu.eudat.models.rda.Cost;
import eu.eudat.models.rda.Dmp;
import eu.eudat.models.rda.DmpId;
import net.minidev.json.JSONObject;
@ -43,16 +44,34 @@ public class DmpRDAMapper {
Map<String, Object> extraProperties = new org.json.JSONObject(dmp.getExtraProperties()).toMap();
if (!extraProperties.isEmpty()) {
rda.setLanguage(LanguageRDAMapper.mapLanguageIsoToRDAIso(extraProperties.get("language").toString()));
if (extraProperties.get("language") != null) {
rda.setLanguage(LanguageRDAMapper.mapLanguageIsoToRDAIso(extraProperties.get("language").toString()));
}
if (extraProperties.get("costs") != null) {
rda.setCost(new ArrayList<>());
((List) extraProperties.get("costs")).forEach(costl -> {
Cost cost = new Cost();
Map<String, Object> code = new org.json.JSONObject((String) ((Map) costl).get("code")).toMap();
cost.setCurrencyCode(Cost.CurrencyCode.fromValue((String) code.get("value")));
cost.setDescription((String) ((Map) costl).get("description"));
cost.setTitle((String) ((Map) costl).get("title"));
cost.setValue(((Integer) ((Map) costl).get("value")).doubleValue());
rda.getCost().add(cost);
});
}
if (extraProperties.get("contact") != null) {
UserInfo contact = apiContext.getOperationsContext().getDatabaseRepository().getUserInfoDao().find(UUID.fromString((String)extraProperties.get("contact")));
rda.setContact(ContactRDAMapper.toRDA(contact));
}
}
UserInfo creator;
/*UserInfo creator;
if (dmp.getCreator() != null) {
creator = dmp.getCreator();
} else {
creator = dmp.getUsers().stream().filter(userDMP -> userDMP.getRole().equals(UserDMP.UserDMPRoles.OWNER.getValue())).map(UserDMP::getUser).findFirst().orElse(new UserInfo());
}
rda.setContact(ContactRDAMapper.toRDA(creator));
rda.setContact(ContactRDAMapper.toRDA(creator));*/
rda.setContributor(new ArrayList<>());
if (dmp.getResearchers() != null && !dmp.getResearchers().isEmpty()) {
rda.getContributor().addAll(dmp.getResearchers().stream().map(ContributorRDAMapper::toRDA).collect(Collectors.toList()));