40 lines
1.7 KiB
Java
40 lines
1.7 KiB
Java
package eu.eudat.models.rda.mapper;
|
|
|
|
import com.fasterxml.jackson.databind.JsonNode;
|
|
import eu.eudat.models.rda.Distribution;
|
|
|
|
import java.net.URI;
|
|
import java.util.Collections;
|
|
|
|
public class DistributionRDAMapper {
|
|
|
|
public static Distribution toRDA(JsonNode structure, JsonNode properties) {
|
|
Distribution rda = new Distribution();
|
|
String rdaProperty = structure.get("rdaProperty").asText();
|
|
if (rdaProperty.contains("access_url")) {
|
|
rda.setAccessUrl(properties.get(structure.get("id").asText()).asText());
|
|
} else if (rdaProperty.contains("available_util")) {
|
|
rda.setAvailableUntil(properties.get(structure.get("id").asText()).asText());
|
|
} else if (rdaProperty.contains("byte_size")) {
|
|
rda.setByteSize(properties.get(structure.get("id").asText()).asInt());
|
|
} else if (rdaProperty.contains("data_access")) {
|
|
rda.setDataAccess(Distribution.DataAccess.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("download_url")) {
|
|
rda.setDownloadUrl(URI.create(properties.get(structure.get("id").asText()).asText()));
|
|
} else if (rdaProperty.contains("format")) {
|
|
rda.setFormat(Collections.singletonList(properties.get(structure.get("id").asText()).asText()));
|
|
} else if (rdaProperty.contains("host")) {
|
|
rda.setHost(HostRDAMapper.toRDA(structure, properties));
|
|
} else if (rdaProperty.contains("license")) {
|
|
rda.setLicense(Collections.singletonList(LicenseRDAMapper.toRDA(structure, properties)));
|
|
} else if (rdaProperty.contains("title")) {
|
|
rda.setTitle(properties.get(structure.get("id").asText()).asText());
|
|
}
|
|
|
|
|
|
return rda;
|
|
}
|
|
}
|