Commit 6d491b59 authored by George Kalampokis's avatar George Kalampokis
Browse files

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

parent 7127f6db
......@@ -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()));
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment