Improve RDA mapping (contributed by M.Aldo)
This commit is contained in:
parent
42c5dbb3b2
commit
316d0903c8
|
@ -89,7 +89,11 @@ public class DatasetRDAMapper {
|
||||||
for (int i = 0; i < qaNodes.size(); i++) {
|
for (int i = 0; i < qaNodes.size(); i++) {
|
||||||
rda.setAdditionalProperty("qaId" + (i + 1), qaNodes.get(i).get("id").asText());
|
rda.setAdditionalProperty("qaId" + (i + 1), qaNodes.get(i).get("id").asText());
|
||||||
}*/
|
}*/
|
||||||
rda.setDataQualityAssurance(Collections.singletonList(qaNodes.get(0).get("value").asText()));
|
List<String> qaList = new ArrayList<>();
|
||||||
|
for(JsonNode qaNode: qaNodes){
|
||||||
|
qaList.add(qaNode.get("value").asText());
|
||||||
|
}
|
||||||
|
rda.setDataQualityAssurance(qaList);
|
||||||
}
|
}
|
||||||
List<JsonNode> preservationNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.preservation_statement");
|
List<JsonNode> preservationNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.preservation_statement");
|
||||||
if (!preservationNodes.isEmpty()) {
|
if (!preservationNodes.isEmpty()) {
|
||||||
|
|
|
@ -20,10 +20,25 @@ public class DistributionRDAMapper {
|
||||||
for (JsonNode node: nodes) {
|
for (JsonNode node: nodes) {
|
||||||
String rdaProperty = node.get("rdaProperty").asText();
|
String rdaProperty = node.get("rdaProperty").asText();
|
||||||
String rdaValue = node.get("value").asText();
|
String rdaValue = node.get("value").asText();
|
||||||
Distribution rda = getRelative(rdaMap, node.get("numbering").asText());
|
String key = node.get("numbering").asText();
|
||||||
|
if(!key.contains("mult")){
|
||||||
|
key = "0";
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
key = "" + key.charAt(4);
|
||||||
|
}
|
||||||
|
Distribution rda;
|
||||||
|
if(rdaMap.containsKey(key)){
|
||||||
|
rda = rdaMap.get(key);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
rda = new Distribution();
|
||||||
|
rdaMap.put(key, rda);
|
||||||
|
}
|
||||||
|
/* Distribution rda = getRelative(rdaMap, node.get("numbering").asText());
|
||||||
if (!rdaMap.containsValue(rda)) {
|
if (!rdaMap.containsValue(rda)) {
|
||||||
rdaMap.put(node.get("numbering").asText(), rda);
|
rdaMap.put(node.get("numbering").asText(), rda);
|
||||||
}
|
}*/
|
||||||
for (ExportPropertyName exportPropertyName : ExportPropertyName.values()) {
|
for (ExportPropertyName exportPropertyName : ExportPropertyName.values()) {
|
||||||
if (rdaProperty.contains(exportPropertyName.getName())) {
|
if (rdaProperty.contains(exportPropertyName.getName())) {
|
||||||
switch (exportPropertyName) {
|
switch (exportPropertyName) {
|
||||||
|
@ -31,17 +46,19 @@ public class DistributionRDAMapper {
|
||||||
rda.setAccessUrl(rdaValue);
|
rda.setAccessUrl(rdaValue);
|
||||||
rda.setAdditionalProperty(ImportPropertyName.ACCESS_URL.getName(), node.get("id").asText());
|
rda.setAdditionalProperty(ImportPropertyName.ACCESS_URL.getName(), node.get("id").asText());
|
||||||
break;
|
break;
|
||||||
case AVAILABLE_UTIL:
|
case AVAILABLE_UNTIL:
|
||||||
rda.setAvailableUntil(rdaValue);
|
rda.setAvailableUntil(rdaValue);
|
||||||
rda.setAdditionalProperty(ImportPropertyName.AVAILABLE_UTIL.getName(), node.get("id").asText());
|
rda.setAdditionalProperty(ImportPropertyName.AVAILABLE_UNTIL.getName(), node.get("id").asText());
|
||||||
break;
|
break;
|
||||||
case DOWNLOAD_URL:
|
case DOWNLOAD_URL:
|
||||||
rda.setDownloadUrl(URI.create(rdaValue));
|
rda.setDownloadUrl(URI.create(rdaValue));
|
||||||
rda.setAdditionalProperty(ImportPropertyName.DOWNLOAD_URL.getName(), node.get("id").asText());
|
rda.setAdditionalProperty(ImportPropertyName.DOWNLOAD_URL.getName(), node.get("id").asText());
|
||||||
break;
|
break;
|
||||||
case DESCRIPTION:
|
case DESCRIPTION:
|
||||||
rda.setDescription(rdaValue);
|
if(!rdaProperty.contains("host")) {
|
||||||
rda.setAdditionalProperty(ImportPropertyName.DESCRIPTION.getName(), node.get("id").asText());
|
rda.setDescription(rdaValue);
|
||||||
|
rda.setAdditionalProperty(ImportPropertyName.DESCRIPTION.getName(), node.get("id").asText());
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case DATA_ACCESS:
|
case DATA_ACCESS:
|
||||||
rda.setDataAccess(Distribution.DataAccess.fromValue(rdaValue));
|
rda.setDataAccess(Distribution.DataAccess.fromValue(rdaValue));
|
||||||
|
@ -60,8 +77,10 @@ public class DistributionRDAMapper {
|
||||||
rda.setAdditionalProperty(ImportPropertyName.FORMAT.getName(), node.get("id").asText());
|
rda.setAdditionalProperty(ImportPropertyName.FORMAT.getName(), node.get("id").asText());
|
||||||
break;
|
break;
|
||||||
case TITLE:
|
case TITLE:
|
||||||
rda.setTitle(rdaValue);
|
if(!rdaProperty.contains("host")) {
|
||||||
rda.setAdditionalProperty(ImportPropertyName.TITLE.getName(), node.get("id").asText());
|
rda.setTitle(rdaValue);
|
||||||
|
rda.setAdditionalProperty(ImportPropertyName.TITLE.getName(), node.get("id").asText());
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case HOST:
|
case HOST:
|
||||||
rda.setHost(HostRDAMapper.toRDA(nodes, node.get("numbering").asText()));
|
rda.setHost(HostRDAMapper.toRDA(nodes, node.get("numbering").asText()));
|
||||||
|
@ -103,7 +122,7 @@ public class DistributionRDAMapper {
|
||||||
case DOWNLOAD_URL:
|
case DOWNLOAD_URL:
|
||||||
properties.put(entry.getValue().toString(), rda.getDownloadUrl().toString());
|
properties.put(entry.getValue().toString(), rda.getDownloadUrl().toString());
|
||||||
break;
|
break;
|
||||||
case AVAILABLE_UTIL:
|
case AVAILABLE_UNTIL:
|
||||||
properties.put(entry.getValue().toString(), rda.getAvailableUntil());
|
properties.put(entry.getValue().toString(), rda.getAvailableUntil());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -141,7 +160,7 @@ public class DistributionRDAMapper {
|
||||||
case TITLE:
|
case TITLE:
|
||||||
properties.put(distributionNode.get("id").asText(), rda.getTitle());
|
properties.put(distributionNode.get("id").asText(), rda.getTitle());
|
||||||
break;
|
break;
|
||||||
case AVAILABLE_UTIL:
|
case AVAILABLE_UNTIL:
|
||||||
properties.put(distributionNode.get("id").asText(), rda.getAvailableUntil());
|
properties.put(distributionNode.get("id").asText(), rda.getAvailableUntil());
|
||||||
break;
|
break;
|
||||||
case DOWNLOAD_URL:
|
case DOWNLOAD_URL:
|
||||||
|
@ -197,7 +216,7 @@ public class DistributionRDAMapper {
|
||||||
case TITLE:
|
case TITLE:
|
||||||
rda.setTitle(rdaValue);
|
rda.setTitle(rdaValue);
|
||||||
break;
|
break;
|
||||||
case AVAILABLE_UTIL:
|
case AVAILABLE_UNTIL:
|
||||||
rda.setAvailableUntil(rdaValue);
|
rda.setAvailableUntil(rdaValue);
|
||||||
break;
|
break;
|
||||||
case DOWNLOAD_URL:
|
case DOWNLOAD_URL:
|
||||||
|
@ -265,7 +284,7 @@ public class DistributionRDAMapper {
|
||||||
|
|
||||||
private enum ExportPropertyName {
|
private enum ExportPropertyName {
|
||||||
ACCESS_URL("access_url"),
|
ACCESS_URL("access_url"),
|
||||||
AVAILABLE_UTIL("available_util"),
|
AVAILABLE_UNTIL("available_until"),
|
||||||
BYTE_SIZE("byte_size"),
|
BYTE_SIZE("byte_size"),
|
||||||
DATA_ACCESS("data_access"),
|
DATA_ACCESS("data_access"),
|
||||||
DESCRIPTION("description"),
|
DESCRIPTION("description"),
|
||||||
|
@ -288,7 +307,7 @@ public class DistributionRDAMapper {
|
||||||
|
|
||||||
private enum ImportPropertyName {
|
private enum ImportPropertyName {
|
||||||
ACCESS_URL("accessurlId"),
|
ACCESS_URL("accessurlId"),
|
||||||
AVAILABLE_UTIL("availableUtilId"),
|
AVAILABLE_UNTIL("availableUtilId"),
|
||||||
BYTE_SIZE("byteSizeId"),
|
BYTE_SIZE("byteSizeId"),
|
||||||
DATA_ACCESS("dataAccessId"),
|
DATA_ACCESS("dataAccessId"),
|
||||||
DESCRIPTION("descriptionId"),
|
DESCRIPTION("descriptionId"),
|
||||||
|
|
|
@ -39,6 +39,9 @@ public class HostRDAMapper {
|
||||||
rda.setBackupType(rdaValue);
|
rda.setBackupType(rdaValue);
|
||||||
break;
|
break;
|
||||||
case CERTIFIED_WITH:
|
case CERTIFIED_WITH:
|
||||||
|
if(rdaValue == null || rdaValue.isEmpty()){
|
||||||
|
break;
|
||||||
|
}
|
||||||
rda.setCertifiedWith(Host.CertifiedWith.fromValue(rdaValue));
|
rda.setCertifiedWith(Host.CertifiedWith.fromValue(rdaValue));
|
||||||
rda.setAdditionalProperty(ImportPropertyName.CERTIFIED_WITH.getName(), node.get("id").asText());
|
rda.setAdditionalProperty(ImportPropertyName.CERTIFIED_WITH.getName(), node.get("id").asText());
|
||||||
break;
|
break;
|
||||||
|
@ -47,6 +50,9 @@ public class HostRDAMapper {
|
||||||
rda.setAdditionalProperty(ImportPropertyName.DESCRIPTION.getName(), node.get("id").asText());
|
rda.setAdditionalProperty(ImportPropertyName.DESCRIPTION.getName(), node.get("id").asText());
|
||||||
break;
|
break;
|
||||||
case GEO_LOCATION:
|
case GEO_LOCATION:
|
||||||
|
if(rdaValue == null || rdaValue.isEmpty()){
|
||||||
|
break;
|
||||||
|
}
|
||||||
rda.setGeoLocation(Host.GeoLocation.fromValue(rdaValue));
|
rda.setGeoLocation(Host.GeoLocation.fromValue(rdaValue));
|
||||||
rda.setAdditionalProperty(ImportPropertyName.GEO_LOCATION.getName(), node.get("id").asText());
|
rda.setAdditionalProperty(ImportPropertyName.GEO_LOCATION.getName(), node.get("id").asText());
|
||||||
break;
|
break;
|
||||||
|
@ -59,6 +65,9 @@ public class HostRDAMapper {
|
||||||
rda.setAdditionalProperty(ImportPropertyName.STORAGE_TYPE.getName(), node.get("id").asText());
|
rda.setAdditionalProperty(ImportPropertyName.STORAGE_TYPE.getName(), node.get("id").asText());
|
||||||
break;
|
break;
|
||||||
case SUPPORT_VERSIONING:
|
case SUPPORT_VERSIONING:
|
||||||
|
if(rdaValue == null || rdaValue.isEmpty()){
|
||||||
|
break;
|
||||||
|
}
|
||||||
rda.setSupportVersioning(Host.SupportVersioning.fromValue(rdaValue));
|
rda.setSupportVersioning(Host.SupportVersioning.fromValue(rdaValue));
|
||||||
rda.setAdditionalProperty(ImportPropertyName.SUPPORT_VERSIONING.getName(), node.get("id").asText());
|
rda.setAdditionalProperty(ImportPropertyName.SUPPORT_VERSIONING.getName(), node.get("id").asText());
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in New Issue