From 772eb7664c3fda3fc790df319b08759b932838c3 Mon Sep 17 00:00:00 2001 From: sgiannopoulos Date: Tue, 4 Jun 2024 11:59:05 +0300 Subject: [PATCH] fixes --- .../RdaFileTransformerService.java | 26 ++++++------------- .../RdaFileTransformerServiceProperties.java | 9 ------- .../resources/config/rda-file-transformer.yml | 1 - 3 files changed, 8 insertions(+), 28 deletions(-) diff --git a/core/src/main/java/org/opencdmp/filetransformer/rda/service/rdafiletransformer/RdaFileTransformerService.java b/core/src/main/java/org/opencdmp/filetransformer/rda/service/rdafiletransformer/RdaFileTransformerService.java index 77f7a61..25576c8 100644 --- a/core/src/main/java/org/opencdmp/filetransformer/rda/service/rdafiletransformer/RdaFileTransformerService.java +++ b/core/src/main/java/org/opencdmp/filetransformer/rda/service/rdafiletransformer/RdaFileTransformerService.java @@ -33,6 +33,7 @@ import org.springframework.stereotype.Service; import java.net.URI; import java.nio.charset.StandardCharsets; +import java.time.Instant; import java.util.*; @Service @@ -186,14 +187,6 @@ public class RdaFileTransformerService implements FileTransformerClient { rda.setCost(new ArrayList<>()); if (cost != null) rda.getCost().add(cost); -// if (dmp.getDescriptions() != null) rda.setAdditionalProperty("templates", jsonHandlingService.toJsonSafe(dmp.getDescriptions().stream().filter(x-> x.getDescriptionTemplate() != null && x.getDescriptionTemplate().getId() != null).map(descriptionModel -> descriptionModel.getDescriptionTemplate().getId()).toList())); -// if (dmp.getDmpBlueprint() != null) rda.setAdditionalProperty("blueprintId", dmp.getDmpBlueprint().getId().toString()); -// if (!licences.isEmpty()) rda.setAdditionalProperty("license", jsonHandlingService.toJsonSafe(licences)); -// if (dmp.getAccessType() != null) rda.setAdditionalProperty("visible", dmp.getAccessType()); -// if (dmp.getPublicAfter() != null) rda.setAdditionalProperty("publicDate", jsonHandlingService.toJsonSafe(dmp.getPublicAfter())); -// if (dmp.getProperties() != null && dmp.getProperties().getContacts() != null) rda.setAdditionalProperty("contact", jsonHandlingService.toJsonSafe(dmp.getProperties().getContacts())); -// if (dmp.getProperties() != null && dmp.getProperties().getDmpBlueprintValues() != null) rda.setAdditionalProperty("dmpProperties", jsonHandlingService.toJsonSafe(dmp.getProperties().getDmpBlueprintValues())); - if (dmp.getDescriptions() != null){ rda.setDataset(new ArrayList<>()); for (DescriptionModel descriptionModel : dmp.getDescriptions()) rda.getDataset().add(this.buildRdaDataset(descriptionModel, rda)); @@ -476,7 +469,10 @@ public class RdaFileTransformerService implements FileTransformerClient { rda.setLanguage(this.buildRdaDatasetLanguage(model)); rda.setType(this.buildRdaDatasetType(model)); rda.setIssued(this.buildRdaDatasetIssued(model)); - rda.setKeyword(this.buildRdaDatasetKeywords(model));//TODO: Build By Tags ? + rda.setKeyword(this.buildRdaDatasetKeywords(model)); + if (rda.getKeyword().isEmpty() && model.getTags() != null){ + rda.getKeyword().addAll(model.getTags()); + } rda.setPersonalData(this.buildRdaDatasetPersonalData(model)); rda.setSensitiveData(this.buildRdaDatasetSensitiveData(model)); rda.setPreservationStatement(this.buildRdaDatasetPreservationStatement(model)); @@ -490,13 +486,6 @@ public class RdaFileTransformerService implements FileTransformerClient { dmpRda.getContributor().addAll(this.buildContributor(model)); this.mergeEthicalIssues(model, dmpRda); -// if (model.getDescriptionTemplate() != null) rda.setAdditionalProperty("template", model.getDescriptionTemplate().getId()); -// rda.setAdditionalProperty("dmpSectionIndex", model.getSectionId()); -// if (model.getProperties() != null) rda.setAdditionalProperty("properties", jsonHandlingService.toJsonSafe(model.getProperties())); -// if (rda.getKeyword() != null){ -// int i = 1; -// for (String keyword : rda.getKeyword()) rda.setAdditionalProperty("keyword" + (i++), keyword); -// } //TODO Old logic not moved return rda; } @@ -710,11 +699,12 @@ public class RdaFileTransformerService implements FileTransformerClient { for (ReferenceModel referenceModel : fieldValue.getReferences()) { if (referenceModel.getDefinition() != null && referenceModel.getDefinition().getFields() != null) { try { - License license = new License(); //TODO - String refValue = referenceModel.getDefinition().getFields().stream().filter(f -> this.configuration.getRdaFileTransformerServiceProperties().getLicenseRefCode().equalsIgnoreCase(f.getCode()) && f.getValue() != null && !f.getValue().isBlank()).map(ReferenceFieldModel::getValue).findFirst().orElse(null); + License license = new License(); + String refValue = referenceModel.getReference(); if (refValue != null && !refValue.isBlank()) license.setLicenseRef(URI.create(refValue)); String startDateValue = referenceModel.getDefinition().getFields().stream().filter(f -> this.configuration.getRdaFileTransformerServiceProperties().getLicenseStartDateCode().equalsIgnoreCase(f.getCode()) && f.getValue() != null && !f.getValue().isBlank()).map(ReferenceFieldModel::getValue).findFirst().orElse(null); if (refValue != null && !refValue.isBlank()) license.setStartDate(startDateValue); + else license.setStartDate(Instant.now().toString()); item.getLicense().add(license); } catch (Exception ex) { diff --git a/core/src/main/java/org/opencdmp/filetransformer/rda/service/rdafiletransformer/RdaFileTransformerServiceProperties.java b/core/src/main/java/org/opencdmp/filetransformer/rda/service/rdafiletransformer/RdaFileTransformerServiceProperties.java index 023bc9d..c2ccd25 100644 --- a/core/src/main/java/org/opencdmp/filetransformer/rda/service/rdafiletransformer/RdaFileTransformerServiceProperties.java +++ b/core/src/main/java/org/opencdmp/filetransformer/rda/service/rdafiletransformer/RdaFileTransformerServiceProperties.java @@ -19,7 +19,6 @@ public class RdaFileTransformerServiceProperties { private String researcherMalCode; private String projectStartDateCode; private String projectEndDateCode; - private String licenseRefCode; private String licenseStartDateCode; private Map languageMap; @@ -137,14 +136,6 @@ public class RdaFileTransformerServiceProperties { this.languageMap = languageMap; } - public String getLicenseRefCode() { - return licenseRefCode; - } - - public void setLicenseRefCode(String licenseRefCode) { - this.licenseRefCode = licenseRefCode; - } - public String getLicenseStartDateCode() { return licenseStartDateCode; } diff --git a/web/src/main/resources/config/rda-file-transformer.yml b/web/src/main/resources/config/rda-file-transformer.yml index 3dac36f..92dccbd 100644 --- a/web/src/main/resources/config/rda-file-transformer.yml +++ b/web/src/main/resources/config/rda-file-transformer.yml @@ -11,7 +11,6 @@ rda-file-transformer: researcherMalCode: "primaryEmail" projectStartDateCode: "startDate" projectEndDateCode: "endDate" - licenseRefCode: "license_ref" licenseStartDateCode: "start_date" language-map: aa: aar