Rda mapper will now be able to use the new DMP fields
This commit is contained in:
parent
7127f6dbd6
commit
6d491b5930
|
@ -3,6 +3,7 @@ package eu.eudat.models.rda.mapper;
|
||||||
import eu.eudat.data.entities.*;
|
import eu.eudat.data.entities.*;
|
||||||
import eu.eudat.logic.services.ApiContext;
|
import eu.eudat.logic.services.ApiContext;
|
||||||
import eu.eudat.logic.utilities.helpers.StreamDistinctBy;
|
import eu.eudat.logic.utilities.helpers.StreamDistinctBy;
|
||||||
|
import eu.eudat.models.rda.Cost;
|
||||||
import eu.eudat.models.rda.Dmp;
|
import eu.eudat.models.rda.Dmp;
|
||||||
import eu.eudat.models.rda.DmpId;
|
import eu.eudat.models.rda.DmpId;
|
||||||
import net.minidev.json.JSONObject;
|
import net.minidev.json.JSONObject;
|
||||||
|
@ -43,16 +44,34 @@ public class DmpRDAMapper {
|
||||||
|
|
||||||
Map<String, Object> extraProperties = new org.json.JSONObject(dmp.getExtraProperties()).toMap();
|
Map<String, Object> extraProperties = new org.json.JSONObject(dmp.getExtraProperties()).toMap();
|
||||||
if (!extraProperties.isEmpty()) {
|
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) {
|
if (dmp.getCreator() != null) {
|
||||||
creator = dmp.getCreator();
|
creator = dmp.getCreator();
|
||||||
} else {
|
} else {
|
||||||
creator = dmp.getUsers().stream().filter(userDMP -> userDMP.getRole().equals(UserDMP.UserDMPRoles.OWNER.getValue())).map(UserDMP::getUser).findFirst().orElse(new UserInfo());
|
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<>());
|
rda.setContributor(new ArrayList<>());
|
||||||
if (dmp.getResearchers() != null && !dmp.getResearchers().isEmpty()) {
|
if (dmp.getResearchers() != null && !dmp.getResearchers().isEmpty()) {
|
||||||
rda.getContributor().addAll(dmp.getResearchers().stream().map(ContributorRDAMapper::toRDA).collect(Collectors.toList()));
|
rda.getContributor().addAll(dmp.getResearchers().stream().map(ContributorRDAMapper::toRDA).collect(Collectors.toList()));
|
||||||
|
|
Loading…
Reference in New Issue