package eu.eudat.models.rda.mapper; import com.fasterxml.jackson.databind.JsonNode; import eu.eudat.models.rda.Host; import eu.eudat.models.rda.PidSystem; import java.net.URI; import java.util.Collections; public class HostRDAMapper { public static Host toRDA(JsonNode structure, JsonNode properties) { Host rda = new Host(); String rdaProperty = structure.get("rdaProperties").asText(); if (rdaProperty.contains("availability")) { rda.setAvailability(properties.get(structure.get("id").asText()).asText()); } else if (rdaProperty.contains("backup_frequency")) { rda.setBackupFrequency(properties.get(structure.get("id").asText()).asText()); } else if (rdaProperty.contains("backup_type")) { rda.setBackupType(properties.get(structure.get("id").asText()).asText()); } else if (rdaProperty.contains("certified_with")) { rda.setCertifiedWith(Host.CertifiedWith.fromValue(properties.get(structure.get("id").asText()).asText())); } else if (rdaProperty.contains("description")) { rda.setDescription(properties.get(structure.get("id").asText()).asText()); } else if (rdaProperty.contains("geo_location")) { rda.setGeoLocation(Host.GeoLocation.fromValue(properties.get(structure.get("id").asText()).asText())); } else if (rdaProperty.contains("pid_system")) { rda.setPidSystem(Collections.singletonList(PidSystem.fromValue(properties.get(structure.get("id").asText()).asText()))); } else if (rdaProperty.contains("storage_type")) { rda.setStorageType(properties.get(structure.get("id").asText()).asText()); } else if (rdaProperty.contains("support_versioning")) { rda.setSupportVersioning(Host.SupportVersioning.fromValue(properties.get(structure.get("id").asText()).asText())); } else if (rdaProperty.contains("title")) { rda.setTitle(properties.get(structure.get("id").asText()).asText()); } else if (rdaProperty.contains("url")) { rda.setUrl(URI.create(properties.get(structure.get("id").asText()).asText())); } return rda; } }