rda json dmp import/export
This commit is contained in:
parent
9a8fc5e92e
commit
0c57bba0b4
|
@ -1136,7 +1136,7 @@ public class DatasetManager {
|
|||
List<Tag> tags = apiContext.getOperationsContext().getElasticRepository().getDatasetRepository().query(criteria).stream().map(eu.eudat.elastic.entities.Dataset::getTags).flatMap(Collection::stream).filter(StreamDistinctBy.distinctByKey(Tag::getId)).collect(Collectors.toList());
|
||||
Set<JsonNode> tagNodes = new HashSet<>();
|
||||
tagNodes.addAll(JsonSearcher.findNodes(propertiesJson, "renderStyle", "tags", true));
|
||||
tagNodes.addAll(JsonSearcher.findNodes(propertiesJson, "rdaProperty", "dataset.keyword"));
|
||||
tagNodes.addAll(JsonSearcher.findNodes(propertiesJson, "schematics", "rda.dataset.keyword"));
|
||||
if(wizardModel.getTags() == null){
|
||||
wizardModel.setTags(new ArrayList<>());
|
||||
}
|
||||
|
|
|
@ -29,6 +29,18 @@ public class JsonSearcher {
|
|||
}
|
||||
found++;
|
||||
}
|
||||
else if(node.get(fieldName).isArray()){
|
||||
for(JsonNode item: node.get(fieldName)){
|
||||
if(item.asText().equals(value) || item.asText().startsWith(value)){
|
||||
if (parent) {
|
||||
nodes.add(root);
|
||||
} else {
|
||||
nodes.add(node);
|
||||
}
|
||||
found++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -31,7 +31,19 @@ public class CostRDAMapper {
|
|||
public static List<Cost> toRDAList(List<JsonNode> nodes) throws JsonProcessingException {
|
||||
Map<String, Cost> rdaMap = new HashMap<>();
|
||||
for(JsonNode node: nodes){
|
||||
String rdaProperty = node.get("rdaProperty").asText();
|
||||
String rdaProperty = "";
|
||||
JsonNode schematics = node.get("schematics");
|
||||
if(schematics.isArray()){
|
||||
for(JsonNode schematic: schematics){
|
||||
if(schematic.asText().startsWith("rda.dmp.cost")){
|
||||
rdaProperty = schematic.asText();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else{
|
||||
continue;
|
||||
}
|
||||
String rdaValue = node.get("value").asText();
|
||||
if(rdaValue == null || (rdaValue.isEmpty() && !node.get("value").isArray())){
|
||||
continue;
|
||||
|
|
|
@ -27,7 +27,19 @@ public class DatasetIdRDAMapper {
|
|||
public static DatasetId toRDA(List<JsonNode> nodes) {
|
||||
DatasetId data = new DatasetId();
|
||||
for (JsonNode node: nodes) {
|
||||
String rdaProperty = node.get("rdaProperty").asText();
|
||||
String rdaProperty = "";
|
||||
JsonNode schematics = node.get("schematics");
|
||||
if(schematics.isArray()){
|
||||
for(JsonNode schematic: schematics){
|
||||
if(schematic.asText().startsWith("rda.dataset.dataset_id")){
|
||||
rdaProperty = schematic.asText();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else{
|
||||
continue;
|
||||
}
|
||||
String rdaValue = node.get("value").asText();
|
||||
if(rdaValue == null || rdaValue.isEmpty()){
|
||||
continue;
|
||||
|
@ -77,11 +89,14 @@ public class DatasetIdRDAMapper {
|
|||
public static Map<String, String> toProperties(DatasetId rda, JsonNode node) {
|
||||
Map<String, String> properties = new HashMap<>();
|
||||
|
||||
List<JsonNode> idNodes = JsonSearcher.findNodes(node, "rdaProperty", "dataset.dataset_id");
|
||||
List<JsonNode> idNodes = JsonSearcher.findNodes(node, "schematics", "rda.dataset.dataset_id");
|
||||
|
||||
for (JsonNode idNode: idNodes) {
|
||||
for (DatasetIdProperties datasetIdProperties : DatasetIdProperties.values()) {
|
||||
if (idNode.get("rdaProperty").asText().endsWith(datasetIdProperties.getName())) {
|
||||
JsonNode schematics = idNode.get("schematics");
|
||||
if(schematics.isArray()){
|
||||
for(JsonNode schematic: schematics){
|
||||
if(schematic.asText().endsWith(datasetIdProperties.getName())){
|
||||
switch (datasetIdProperties) {
|
||||
case IDENTIFIER:
|
||||
properties.put(idNode.get("id").asText(), rda.getIdentifier());
|
||||
|
@ -90,7 +105,9 @@ public class DatasetIdRDAMapper {
|
|||
properties.put(idNode.get("id").asText(), rda.getType().value());
|
||||
break;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -59,32 +59,32 @@ public class DatasetRDAMapper {
|
|||
ObjectMapper mapper = new ObjectMapper();
|
||||
String datasetDescriptionJson = mapper.writeValueAsString(datasetWizardModel.getDatasetProfileDefinition());
|
||||
JsonNode datasetDescriptionObj = mapper.readTree(datasetDescriptionJson);
|
||||
List<JsonNode> idNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.dataset_id");
|
||||
List<JsonNode> idNodes = JsonSearcher.findNodes(datasetDescriptionObj, "schematics", "rda.dataset.dataset_id");
|
||||
if (!idNodes.isEmpty()) {
|
||||
rda.setDatasetId(DatasetIdRDAMapper.toRDA(idNodes));
|
||||
}
|
||||
if (rda.getDatasetId() == null) {
|
||||
rda.setDatasetId(new DatasetId(dataset.getId().toString(), DatasetId.Type.OTHER));
|
||||
}
|
||||
List<JsonNode> typeNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.type");
|
||||
List<JsonNode> typeNodes = JsonSearcher.findNodes(datasetDescriptionObj, "schematics", "rda.dataset.type");
|
||||
if (!typeNodes.isEmpty() && !typeNodes.get(0).get("value").asText().isEmpty()) {
|
||||
rda.setType(typeNodes.get(0).get("value").asText());
|
||||
} else {
|
||||
rda.setType("DMP Dataset");
|
||||
}
|
||||
List<JsonNode> languageNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.language");
|
||||
List<JsonNode> languageNodes = JsonSearcher.findNodes(datasetDescriptionObj, "schematics", "rda.dataset.language");
|
||||
if (!languageNodes.isEmpty() && !languageNodes.get(0).get("value").asText().isEmpty()) {
|
||||
rda.setLanguage(Language.fromValue(languageNodes.get(0).get("value").asText()));
|
||||
} else {
|
||||
rda.setLanguage(LanguageRDAMapper.mapLanguageIsoToRDAIso(dataset.getProfile().getLanguage()));
|
||||
}
|
||||
List<JsonNode> metadataNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.metadata");
|
||||
List<JsonNode> metadataNodes = JsonSearcher.findNodes(datasetDescriptionObj, "schematics", "rda.dataset.metadata");
|
||||
if (!metadataNodes.isEmpty()) {
|
||||
rda.setMetadata(MetadataRDAMapper.toRDAList(metadataNodes));
|
||||
}else{
|
||||
rda.setMetadata(new ArrayList<>());
|
||||
}
|
||||
List<JsonNode> qaNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.data_quality_assurance");
|
||||
List<JsonNode> qaNodes = JsonSearcher.findNodes(datasetDescriptionObj, "schematics", "rda.dataset.data_quality_assurance");
|
||||
if (!qaNodes.isEmpty()) {
|
||||
/*rda.setDataQualityAssurance(qaNodes.stream().map(qaNode -> qaNode.get("value").asText()).collect(Collectors.toList()));
|
||||
for (int i = 0; i < qaNodes.size(); i++) {
|
||||
|
@ -115,17 +115,17 @@ public class DatasetRDAMapper {
|
|||
}else{
|
||||
rda.setDataQualityAssurance(new ArrayList<>());
|
||||
}
|
||||
List<JsonNode> preservationNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.preservation_statement");
|
||||
List<JsonNode> preservationNodes = JsonSearcher.findNodes(datasetDescriptionObj, "schematics", "rda.dataset.preservation_statement");
|
||||
if (!preservationNodes.isEmpty() && !preservationNodes.get(0).get("value").asText().isEmpty()) {
|
||||
rda.setPreservationStatement(preservationNodes.get(0).get("value").asText());
|
||||
}
|
||||
List<JsonNode> distributionNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.distribution");
|
||||
List<JsonNode> distributionNodes = JsonSearcher.findNodes(datasetDescriptionObj, "schematics", "rda.dataset.distribution");
|
||||
if (!distributionNodes.isEmpty()) {
|
||||
rda.setDistribution(DistributionRDAMapper.toRDAList(distributionNodes));
|
||||
}else{
|
||||
rda.setDistribution(new ArrayList<>());
|
||||
}
|
||||
List<JsonNode> keywordNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.keyword");
|
||||
List<JsonNode> keywordNodes = JsonSearcher.findNodes(datasetDescriptionObj, "schematics", "rda.dataset.keyword");
|
||||
if (!keywordNodes.isEmpty()) {
|
||||
rda.setKeyword(keywordNodes.stream().map(keywordNode -> {
|
||||
JsonNode value = keywordNode.get("value");
|
||||
|
@ -142,7 +142,7 @@ public class DatasetRDAMapper {
|
|||
List<String> tags = apiContext.getOperationsContext().getElasticRepository().getDatasetRepository().findDocument(dataset.getId().toString()).getTags().stream().map(Tag::getName).collect(Collectors.toList());
|
||||
rda.setKeyword(tags);
|
||||
}
|
||||
List<JsonNode> personalDataNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.personal_data");
|
||||
List<JsonNode> personalDataNodes = JsonSearcher.findNodes(datasetDescriptionObj, "schematics", "rda.dataset.personal_data");
|
||||
if (!personalDataNodes.isEmpty()) {
|
||||
try{
|
||||
rda.setPersonalData(personalDataNodes.stream().map(personalDataNode -> Dataset.PersonalData.fromValue(personalDataNode.get("value").asText())).findFirst().get());
|
||||
|
@ -152,13 +152,13 @@ public class DatasetRDAMapper {
|
|||
} else {
|
||||
rda.setPersonalData(Dataset.PersonalData.UNKNOWN);
|
||||
}
|
||||
List<JsonNode> securityAndPrivacyNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.security_and_privacy");
|
||||
List<JsonNode> securityAndPrivacyNodes = JsonSearcher.findNodes(datasetDescriptionObj, "schematics", "rda.dataset.security_and_privacy");
|
||||
if (!securityAndPrivacyNodes.isEmpty()) {
|
||||
rda.setSecurityAndPrivacy(SecurityAndPrivacyRDAMapper.toRDAList(securityAndPrivacyNodes));
|
||||
}else{
|
||||
rda.setSecurityAndPrivacy(new ArrayList<>());
|
||||
}
|
||||
List<JsonNode> sensitiveDataNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.sensitive_data");
|
||||
List<JsonNode> sensitiveDataNodes = JsonSearcher.findNodes(datasetDescriptionObj, "schematics", "rda.dataset.sensitive_data");
|
||||
if (!sensitiveDataNodes.isEmpty()) {
|
||||
try{
|
||||
rda.setSensitiveData(sensitiveDataNodes.stream().map(sensitiveDataNode -> Dataset.SensitiveData.fromValue(sensitiveDataNode.get("value").asText())).findFirst().get());
|
||||
|
@ -168,35 +168,47 @@ public class DatasetRDAMapper {
|
|||
} else {
|
||||
rda.setSensitiveData(Dataset.SensitiveData.UNKNOWN);
|
||||
}
|
||||
List<JsonNode> technicalResourceNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.technical_resource");
|
||||
List<JsonNode> technicalResourceNodes = JsonSearcher.findNodes(datasetDescriptionObj, "schematics", "rda.dataset.technical_resource");
|
||||
if (!technicalResourceNodes.isEmpty()) {
|
||||
rda.setTechnicalResource(TechnicalResourceRDAMapper.toRDAList(technicalResourceNodes));
|
||||
}else{
|
||||
rda.setTechnicalResource(new ArrayList<>());
|
||||
}
|
||||
List<JsonNode> issuedNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.issued");
|
||||
List<JsonNode> issuedNodes = JsonSearcher.findNodes(datasetDescriptionObj, "schematics", "rda.dataset.issued");
|
||||
if (!issuedNodes.isEmpty() && !issuedNodes.get(0).get("value").asText().isEmpty()) {
|
||||
rda.setIssued(issuedNodes.get(0).get("value").asText());
|
||||
}
|
||||
List<JsonNode> contributorNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dmp.contributor");
|
||||
List<JsonNode> contributorNodes = JsonSearcher.findNodes(datasetDescriptionObj, "schematics", "rda.dmp.contributor");
|
||||
if (!contributorNodes.isEmpty()) {
|
||||
dmp.getContributor().addAll(contributorNodes.stream().map(contributorNode -> {
|
||||
JsonNode value = contributorNode.get("value");
|
||||
if (value.isArray()) {
|
||||
return StreamSupport.stream(value.spliterator(), false).map(node -> ContributorRDAMapper.toRDA(node.asText())).collect(Collectors.toList());
|
||||
} else {
|
||||
return Collections.singletonList(new Contributor()); // return null kalutera
|
||||
return Collections.singletonList(new Contributor());
|
||||
}
|
||||
}).flatMap(Collection::stream).collect(Collectors.toList()));
|
||||
}
|
||||
List<JsonNode> costNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dmp.cost");
|
||||
List<JsonNode> costNodes = JsonSearcher.findNodes(datasetDescriptionObj, "schematics", "rda.dmp.cost");
|
||||
if (!costNodes.isEmpty()) {
|
||||
dmp.getCost().addAll(CostRDAMapper.toRDAList(costNodes));
|
||||
}
|
||||
List<JsonNode> ethicsNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dmp.ethical_issues");
|
||||
List<JsonNode> ethicsNodes = JsonSearcher.findNodes(datasetDescriptionObj, "schematics", "rda.dmp.ethical_issues");
|
||||
if (!ethicsNodes.isEmpty()) {
|
||||
for(JsonNode node: ethicsNodes){
|
||||
String rdaProperty = node.get("rdaProperty").asText();
|
||||
String rdaProperty = "";
|
||||
JsonNode schematics = node.get("schematics");
|
||||
if(schematics.isArray()){
|
||||
for(JsonNode schematic: schematics){
|
||||
if(schematic.asText().startsWith("rda.dmp.ethical_issues")){
|
||||
rdaProperty = schematic.asText();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else{
|
||||
continue;
|
||||
}
|
||||
String rdaValue = node.get("value").asText();
|
||||
if(rdaValue == null || rdaValue.isEmpty()){
|
||||
continue;
|
||||
|
@ -276,12 +288,12 @@ public class DatasetRDAMapper {
|
|||
String datasetDescriptionJson = mapper.writeValueAsString(datasetWizardModel.getDatasetProfileDefinition());
|
||||
JsonNode datasetDescriptionObj = mapper.readTree(datasetDescriptionJson);
|
||||
|
||||
List<JsonNode> typeNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.type");
|
||||
List<JsonNode> typeNodes = JsonSearcher.findNodes(datasetDescriptionObj, "schematics", "rda.dataset.type");
|
||||
if (!typeNodes.isEmpty()) {
|
||||
properties.put(typeNodes.get(0).get("id").asText(), rda.getType());
|
||||
}
|
||||
|
||||
List<JsonNode> languageNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.language");
|
||||
List<JsonNode> languageNodes = JsonSearcher.findNodes(datasetDescriptionObj, "schematics", "rda.dataset.language");
|
||||
if (!languageNodes.isEmpty() && rda.getLanguage() != null) {
|
||||
properties.put(languageNodes.get(0).get("id").asText(), rda.getLanguage().value());
|
||||
}
|
||||
|
@ -298,7 +310,7 @@ public class DatasetRDAMapper {
|
|||
for (int i = 0; i < qaIds.size(); i++) {
|
||||
properties.put(qaIds.get(i), rda.getDataQualityAssurance().get(i));
|
||||
}*/
|
||||
List<JsonNode> qaNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.data_quality_assurance");
|
||||
List<JsonNode> qaNodes = JsonSearcher.findNodes(datasetDescriptionObj, "schematics", "rda.dataset.data_quality_assurance");
|
||||
if (!qaNodes.isEmpty() && rda.getDataQualityAssurance() != null && !rda.getDataQualityAssurance().isEmpty()) {
|
||||
ObjectMapper m = new ObjectMapper();
|
||||
List<String> qas = new ArrayList<>(rda.getDataQualityAssurance());
|
||||
|
@ -310,12 +322,12 @@ public class DatasetRDAMapper {
|
|||
}
|
||||
}
|
||||
|
||||
List<JsonNode> preservationNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.preservation_statement");
|
||||
List<JsonNode> preservationNodes = JsonSearcher.findNodes(datasetDescriptionObj, "schematics", "rda.dataset.preservation_statement");
|
||||
if (!preservationNodes.isEmpty()) {
|
||||
properties.put(preservationNodes.get(0).get("id").asText(), rda.getPreservationStatement());
|
||||
}
|
||||
|
||||
List<JsonNode> issuedNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.issued");
|
||||
List<JsonNode> issuedNodes = JsonSearcher.findNodes(datasetDescriptionObj, "schematics", "rda.dataset.issued");
|
||||
if (!issuedNodes.isEmpty()) {
|
||||
properties.put(issuedNodes.get(0).get("id").asText(), rda.getIssued());
|
||||
}
|
||||
|
@ -351,7 +363,7 @@ public class DatasetRDAMapper {
|
|||
}
|
||||
}
|
||||
|
||||
List<JsonNode> personalDataNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.personal_data");
|
||||
List<JsonNode> personalDataNodes = JsonSearcher.findNodes(datasetDescriptionObj, "schematics", "rda.dataset.personal_data");
|
||||
if (!personalDataNodes.isEmpty()) {
|
||||
properties.put(personalDataNodes.get(0).get("id").asText(), rda.getPersonalData().value());
|
||||
}
|
||||
|
@ -360,7 +372,7 @@ public class DatasetRDAMapper {
|
|||
properties.putAll(SecurityAndPrivacyRDAMapper.toProperties(rda.getSecurityAndPrivacy()));
|
||||
}
|
||||
|
||||
List<JsonNode> sensitiveDataNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.sensitive_data");
|
||||
List<JsonNode> sensitiveDataNodes = JsonSearcher.findNodes(datasetDescriptionObj, "schematics", "rda.dataset.sensitive_data");
|
||||
if (!sensitiveDataNodes.isEmpty()) {
|
||||
properties.put(sensitiveDataNodes.get(0).get("id").asText(), rda.getSensitiveData().value());
|
||||
}
|
||||
|
|
|
@ -24,7 +24,10 @@ public class DistributionRDAMapper {
|
|||
Map<String, Distribution> rdaMap = new HashMap<>();
|
||||
|
||||
for (JsonNode node: nodes) {
|
||||
String rdaProperty = node.get("rdaProperty").asText();
|
||||
String rdaProperty = getRdaDistributionProperty(node);
|
||||
if(rdaProperty.isEmpty()){
|
||||
continue;
|
||||
}
|
||||
String rdaValue = node.get("value").asText();
|
||||
//if(rdaValue == null || rdaValue.isEmpty()){
|
||||
if(rdaValue == null || (rdaValue.isEmpty() && !node.get("value").isArray())){
|
||||
|
@ -79,7 +82,16 @@ public class DistributionRDAMapper {
|
|||
rda.setAdditionalProperty(ImportPropertyName.BYTE_SIZE.getName(), node.get("id").asText());
|
||||
break;
|
||||
case LICENSE:
|
||||
List<JsonNode> licenseNodes = nodes.stream().filter(lnode -> lnode.get("rdaProperty").asText().toLowerCase().contains("license")).collect(Collectors.toList());
|
||||
List<JsonNode> licenseNodes = nodes.stream().filter(lnode -> {
|
||||
if(lnode.get("schematics").isArray()){
|
||||
for(JsonNode schematic: lnode.get("schematics")){
|
||||
if(schematic.asText().startsWith("rda.dataset.distribution.license")){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}).collect(Collectors.toList());
|
||||
License license = LicenseRDAMapper.toRDA(licenseNodes);
|
||||
rda.setLicense(license != null? Collections.singletonList(license): new ArrayList<>());
|
||||
break;
|
||||
|
@ -182,11 +194,14 @@ public class DistributionRDAMapper {
|
|||
public static Map<String, String> toProperties(Distribution rda, JsonNode root) {
|
||||
Map<String, String> properties = new HashMap<>();
|
||||
|
||||
List<JsonNode> distributionNodes = JsonSearcher.findNodes(root, "rdaProperty", "dataset.distribution");
|
||||
List<JsonNode> distributionNodes = JsonSearcher.findNodes(root, "schematics", "rda.dataset.distribution");
|
||||
|
||||
for (JsonNode distributionNode: distributionNodes) {
|
||||
for (ExportPropertyName exportPropertyName: ExportPropertyName.values()) {
|
||||
if (distributionNode.get("rdaProperty").asText().contains(exportPropertyName.getName())) {
|
||||
JsonNode schematics = distributionNode.get("schematics");
|
||||
if(schematics.isArray()){
|
||||
for(JsonNode schematic: schematics){
|
||||
if(schematic.asText().contains(exportPropertyName.getName())){
|
||||
switch (exportPropertyName) {
|
||||
case ACCESS_URL:
|
||||
properties.put(distributionNode.get("id").asText(), rda.getAccessUrl());
|
||||
|
@ -248,6 +263,9 @@ public class DistributionRDAMapper {
|
|||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -258,7 +276,10 @@ public class DistributionRDAMapper {
|
|||
public static Distribution toRDA(List<JsonNode> nodes) {
|
||||
Distribution rda = new Distribution();
|
||||
for (JsonNode node: nodes) {
|
||||
String rdaProperty = node.get("rdaProperty").asText();
|
||||
String rdaProperty = getRdaDistributionProperty(node);
|
||||
if(rdaProperty.isEmpty()){
|
||||
continue;
|
||||
}
|
||||
String rdaValue = node.get("value").asText();
|
||||
for (ExportPropertyName exportPropertyName: ExportPropertyName.values()) {
|
||||
if (rdaProperty.contains(exportPropertyName.getName())) {
|
||||
|
@ -288,11 +309,29 @@ public class DistributionRDAMapper {
|
|||
rda.setFormat(Collections.singletonList(rdaValue));
|
||||
break;
|
||||
case LICENSE:
|
||||
List<JsonNode> licenseNodes = nodes.stream().filter(lnode -> lnode.get("rdaProperty").asText().toLowerCase().contains("license")).collect(Collectors.toList());
|
||||
List<JsonNode> licenseNodes = nodes.stream().filter(lnode -> {
|
||||
if(lnode.get("schematics").isArray()){
|
||||
for(JsonNode schematic: lnode.get("schematics")){
|
||||
if(schematic.asText().startsWith("rda.dataset.distribution.license")){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}).collect(Collectors.toList());
|
||||
rda.setLicense(Collections.singletonList(LicenseRDAMapper.toRDA(licenseNodes)));
|
||||
break;
|
||||
case HOST:
|
||||
List<JsonNode> hostNodes = nodes.stream().filter(lnode -> lnode.get("rdaProperty").asText().toLowerCase().contains("host")).collect(Collectors.toList());
|
||||
List<JsonNode> hostNodes = nodes.stream().filter(lnode -> {
|
||||
if(lnode.get("schematics").isArray()){
|
||||
for(JsonNode schematic: lnode.get("schematics")){
|
||||
if(schematic.asText().startsWith("rda.dataset.distribution.host")){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}).collect(Collectors.toList());
|
||||
rda.setHost(HostRDAMapper.toRDA(hostNodes, "0"));
|
||||
break;
|
||||
}
|
||||
|
@ -333,6 +372,20 @@ public class DistributionRDAMapper {
|
|||
return rda;
|
||||
}
|
||||
|
||||
private static String getRdaDistributionProperty(JsonNode node) {
|
||||
String rdaProperty = "";
|
||||
JsonNode schematics = node.get("schematics");
|
||||
if(schematics.isArray()){
|
||||
for(JsonNode schematic: schematics){
|
||||
if(schematic.asText().startsWith("rda.dataset.distribution")){
|
||||
rdaProperty = schematic.asText();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return rdaProperty;
|
||||
}
|
||||
|
||||
private static Distribution getRelative( Map<String, Distribution> rdaMap, String numbering) {
|
||||
return rdaMap.entrySet().stream().filter(entry -> MyStringUtils.getFirstDifference(entry.getKey(), numbering) > 0)
|
||||
.max(Comparator.comparingInt(entry -> MyStringUtils.getFirstDifference(entry.getKey(), numbering))).map(Map.Entry::getValue).orElse(new Distribution());
|
||||
|
|
|
@ -19,7 +19,19 @@ public class HostRDAMapper {
|
|||
public static Host toRDA(List<JsonNode> nodes, String numbering) {
|
||||
Host rda = new Host();
|
||||
for (JsonNode node: nodes) {
|
||||
String rdaProperty = node.get("rdaProperty").asText();
|
||||
String rdaProperty = "";
|
||||
JsonNode schematics = node.get("schematics");
|
||||
if(schematics.isArray()){
|
||||
for(JsonNode schematic: schematics){
|
||||
if(schematic.asText().startsWith("rda.dataset.distribution.host")){
|
||||
rdaProperty = schematic.asText();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else{
|
||||
continue;
|
||||
}
|
||||
if (rdaProperty.contains("host")) {
|
||||
int firstDiff = MyStringUtils.getFirstDifference(numbering, node.get("numbering").asText());
|
||||
if (firstDiff == -1 || firstDiff >= 2) {
|
||||
|
|
|
@ -17,7 +17,19 @@ public class LicenseRDAMapper {
|
|||
public static License toRDA(List<JsonNode> nodes) {
|
||||
License rda = new License();
|
||||
for (JsonNode node: nodes) {
|
||||
String rdaProperty = node.get("rdaProperty").asText();
|
||||
String rdaProperty = "";
|
||||
JsonNode schematics = node.get("schematics");
|
||||
if(schematics.isArray()){
|
||||
for(JsonNode schematic: schematics){
|
||||
if(schematic.asText().startsWith("rda.dataset.distribution.license")){
|
||||
rdaProperty = schematic.asText();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else{
|
||||
continue;
|
||||
}
|
||||
String value = node.get("value").asText();
|
||||
if(value == null || value.isEmpty()){
|
||||
continue;
|
||||
|
@ -78,11 +90,14 @@ public class LicenseRDAMapper {
|
|||
public static Map<String, String> toProperties(License rda, JsonNode root) {
|
||||
Map<String, String> properties = new HashMap<>();
|
||||
|
||||
List<JsonNode> licenseNodes = JsonSearcher.findNodes(root, "rdaProperty", "dataset.distribution.license");
|
||||
List<JsonNode> licenseNodes = JsonSearcher.findNodes(root, "schematics", "rda.dataset.distribution.license");
|
||||
|
||||
for (JsonNode licenseNode: licenseNodes) {
|
||||
for (LicenceProperties licenceProperty: LicenceProperties.values()) {
|
||||
if (licenseNode.get("rdaProperty").asText().endsWith(licenceProperty.getName())) {
|
||||
JsonNode schematics = licenseNode.get("schematics");
|
||||
if(schematics.isArray()) {
|
||||
for (JsonNode schematic : schematics) {
|
||||
if (schematic.asText().endsWith(licenceProperty.getName())) {
|
||||
switch (licenceProperty) {
|
||||
case LICENSE_REF:
|
||||
if (rda.getLicenseRef() != null) {
|
||||
|
@ -94,6 +109,9 @@ public class LicenseRDAMapper {
|
|||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -20,7 +20,19 @@ public class MetadataRDAMapper {
|
|||
Map<String, String> rdaMap = new HashMap<>();
|
||||
List<Metadatum> rdas = new ArrayList<>();
|
||||
for (JsonNode node: nodes) {
|
||||
String rdaProperty = node.get("rdaProperty").asText();
|
||||
String rdaProperty = "";
|
||||
JsonNode schematics = node.get("schematics");
|
||||
if(schematics.isArray()){
|
||||
for(JsonNode schematic: schematics){
|
||||
if(schematic.asText().startsWith("rda.dataset.metadata")){
|
||||
rdaProperty = schematic.asText();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else{
|
||||
continue;
|
||||
}
|
||||
JsonNode rdaValue = node.get("value");
|
||||
|
||||
for (PropertyName propertyName: PropertyName.values()) {
|
||||
|
@ -119,7 +131,16 @@ public class MetadataRDAMapper {
|
|||
|
||||
public static Metadatum toRDA(JsonNode node) {
|
||||
Metadatum rda = new Metadatum();
|
||||
String rdaProperty = node.get("rdaProperty").asText();
|
||||
String rdaProperty = "";
|
||||
JsonNode schematics = node.get("schematics");
|
||||
if(schematics.isArray()){
|
||||
for(JsonNode schematic: schematics){
|
||||
if(schematic.asText().startsWith("rda.dataset.metadata")){
|
||||
rdaProperty = schematic.asText();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
JsonNode rdaValue = node.get("value");
|
||||
if (rdaProperty.contains("metadata_standard_id")) {
|
||||
if (rdaValue instanceof ArrayNode) {
|
||||
|
|
|
@ -16,7 +16,19 @@ public class SecurityAndPrivacyRDAMapper {
|
|||
Map<String, SecurityAndPrivacy> rdaMap = new HashMap<>();
|
||||
|
||||
for (JsonNode node: nodes) {
|
||||
String rdaProperty = node.get("rdaProperty").asText();
|
||||
String rdaProperty = "";
|
||||
JsonNode schematics = node.get("schematics");
|
||||
if(schematics.isArray()){
|
||||
for(JsonNode schematic: schematics){
|
||||
if(schematic.asText().startsWith("rda.dataset.security_and_privacy")){
|
||||
rdaProperty = schematic.asText();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else{
|
||||
continue;
|
||||
}
|
||||
String rdaValue = node.get("value").asText();
|
||||
if(rdaValue == null || rdaValue.isEmpty()){
|
||||
continue;
|
||||
|
@ -69,7 +81,16 @@ public class SecurityAndPrivacyRDAMapper {
|
|||
|
||||
public static SecurityAndPrivacy toRDA(JsonNode node) {
|
||||
SecurityAndPrivacy rda = new SecurityAndPrivacy();
|
||||
String rdaProperty = node.get("rdaProperty").asText();
|
||||
String rdaProperty = "";
|
||||
JsonNode schematics = node.get("schematics");
|
||||
if(schematics.isArray()){
|
||||
for(JsonNode schematic: schematics){
|
||||
if(schematic.asText().startsWith("rda.dataset.security_and_privacy")){
|
||||
rdaProperty = schematic.asText();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
String value = node.get("value").asText();
|
||||
|
||||
if (rdaProperty.contains("description")) {
|
||||
|
|
|
@ -16,7 +16,19 @@ public class TechnicalResourceRDAMapper {
|
|||
Map<String, TechnicalResource> rdaMap = new HashMap<>();
|
||||
|
||||
for (JsonNode node: nodes) {
|
||||
String rdaProperty = node.get("rdaProperty").asText();
|
||||
String rdaProperty = "";
|
||||
JsonNode schematics = node.get("schematics");
|
||||
if(schematics.isArray()){
|
||||
for(JsonNode schematic: schematics){
|
||||
if(schematic.asText().startsWith("rda.dataset.technical_resource")){
|
||||
rdaProperty = schematic.asText();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else{
|
||||
continue;
|
||||
}
|
||||
String rdaValue = node.get("value").asText();
|
||||
if(rdaValue == null || rdaValue.isEmpty()){
|
||||
continue;
|
||||
|
@ -70,7 +82,16 @@ public class TechnicalResourceRDAMapper {
|
|||
|
||||
public static TechnicalResource toRDA(JsonNode node) {
|
||||
TechnicalResource rda = new TechnicalResource();
|
||||
String rdaProperty = node.get("rdaProperty").asText();
|
||||
String rdaProperty = "";
|
||||
JsonNode schematics = node.get("schematics");
|
||||
if(schematics.isArray()){
|
||||
for(JsonNode schematic: schematics){
|
||||
if(schematic.asText().startsWith("rda.dataset.technical_resource")){
|
||||
rdaProperty = schematic.asText();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
String value = node.get("value").asText();
|
||||
|
||||
if (rdaProperty.contains("description")) {
|
||||
|
|
Loading…
Reference in New Issue