This commit is contained in:
Efstratios Giannopoulos 2024-06-04 11:59:05 +03:00
parent da57359f5c
commit 772eb7664c
3 changed files with 8 additions and 28 deletions

View File

@ -33,6 +33,7 @@ import org.springframework.stereotype.Service;
import java.net.URI; import java.net.URI;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.time.Instant;
import java.util.*; import java.util.*;
@Service @Service
@ -186,14 +187,6 @@ public class RdaFileTransformerService implements FileTransformerClient {
rda.setCost(new ArrayList<>()); rda.setCost(new ArrayList<>());
if (cost != null) rda.getCost().add(cost); 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){ if (dmp.getDescriptions() != null){
rda.setDataset(new ArrayList<>()); rda.setDataset(new ArrayList<>());
for (DescriptionModel descriptionModel : dmp.getDescriptions()) rda.getDataset().add(this.buildRdaDataset(descriptionModel, rda)); 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.setLanguage(this.buildRdaDatasetLanguage(model));
rda.setType(this.buildRdaDatasetType(model)); rda.setType(this.buildRdaDatasetType(model));
rda.setIssued(this.buildRdaDatasetIssued(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.setPersonalData(this.buildRdaDatasetPersonalData(model));
rda.setSensitiveData(this.buildRdaDatasetSensitiveData(model)); rda.setSensitiveData(this.buildRdaDatasetSensitiveData(model));
rda.setPreservationStatement(this.buildRdaDatasetPreservationStatement(model)); rda.setPreservationStatement(this.buildRdaDatasetPreservationStatement(model));
@ -490,13 +486,6 @@ public class RdaFileTransformerService implements FileTransformerClient {
dmpRda.getContributor().addAll(this.buildContributor(model)); dmpRda.getContributor().addAll(this.buildContributor(model));
this.mergeEthicalIssues(model, dmpRda); 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; return rda;
} }
@ -710,11 +699,12 @@ public class RdaFileTransformerService implements FileTransformerClient {
for (ReferenceModel referenceModel : fieldValue.getReferences()) { for (ReferenceModel referenceModel : fieldValue.getReferences()) {
if (referenceModel.getDefinition() != null && referenceModel.getDefinition().getFields() != null) { if (referenceModel.getDefinition() != null && referenceModel.getDefinition().getFields() != null) {
try { try {
License license = new License(); //TODO License license = new License();
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); String refValue = referenceModel.getReference();
if (refValue != null && !refValue.isBlank()) license.setLicenseRef(URI.create(refValue)); 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); 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); if (refValue != null && !refValue.isBlank()) license.setStartDate(startDateValue);
else license.setStartDate(Instant.now().toString());
item.getLicense().add(license); item.getLicense().add(license);
} catch (Exception ex) { } catch (Exception ex) {

View File

@ -19,7 +19,6 @@ public class RdaFileTransformerServiceProperties {
private String researcherMalCode; private String researcherMalCode;
private String projectStartDateCode; private String projectStartDateCode;
private String projectEndDateCode; private String projectEndDateCode;
private String licenseRefCode;
private String licenseStartDateCode; private String licenseStartDateCode;
private Map<String, String> languageMap; private Map<String, String> languageMap;
@ -137,14 +136,6 @@ public class RdaFileTransformerServiceProperties {
this.languageMap = languageMap; this.languageMap = languageMap;
} }
public String getLicenseRefCode() {
return licenseRefCode;
}
public void setLicenseRefCode(String licenseRefCode) {
this.licenseRefCode = licenseRefCode;
}
public String getLicenseStartDateCode() { public String getLicenseStartDateCode() {
return licenseStartDateCode; return licenseStartDateCode;
} }

View File

@ -11,7 +11,6 @@ rda-file-transformer:
researcherMalCode: "primaryEmail" researcherMalCode: "primaryEmail"
projectStartDateCode: "startDate" projectStartDateCode: "startDate"
projectEndDateCode: "endDate" projectEndDateCode: "endDate"
licenseRefCode: "license_ref"
licenseStartDateCode: "start_date" licenseStartDateCode: "start_date"
language-map: language-map:
aa: aar aa: aar