argos/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/CostRDAMapper.java

23 lines
657 B
Java
Raw Normal View History

2020-11-13 17:26:09 +01:00
package eu.eudat.models.rda.mapper;
import java.util.Map;
import eu.eudat.models.rda.Cost;
public class CostRDAMapper {
public static Cost toRDA(Map<String, Object> cost) {
Cost rda = new Cost();
Map<String, Object> code = new org.json.JSONObject((String) cost.get("code")).toMap();
rda.setCurrencyCode(Cost.CurrencyCode.fromValue((String) code.get("value")));
rda.setDescription((String) cost.get("description"));
if (cost.get("title") == null) {
throw new IllegalArgumentException("Cost Title is missing");
}
rda.setTitle((String) cost.get("title"));
rda.setValue(((Integer) cost.get("value")).doubleValue());
return rda;
}
}