|
|
|
@ -10,6 +10,7 @@ import org.opencdmp.commonmodels.models.description.PropertyDefinitionFieldSetIt
|
|
|
|
|
import org.opencdmp.commonmodels.models.description.PropertyDefinitionFieldSetModel;
|
|
|
|
|
import org.opencdmp.commonmodels.models.description.PropertyDefinitionModel;
|
|
|
|
|
import org.opencdmp.commonmodels.models.descriptiotemplate.FieldModel;
|
|
|
|
|
import org.opencdmp.commonmodels.models.descriptiotemplate.FieldSetModel;
|
|
|
|
|
import org.opencdmp.commonmodels.models.dmp.DmpBlueprintValueModel;
|
|
|
|
|
import org.opencdmp.commonmodels.models.dmp.DmpModel;
|
|
|
|
|
import org.opencdmp.commonmodels.models.dmpblueprint.SectionModel;
|
|
|
|
@ -56,7 +57,7 @@ public class RdaFileTransformerService implements FileTransformerClient {
|
|
|
|
|
private static final String SEMANTIC_ETHICAL_ISSUES = "ethicalIssues";
|
|
|
|
|
private static final String SEMANTIC_ETHICAL_ISSUES_DESCRIPTION = "ethicalIssuesDescription";
|
|
|
|
|
private static final String SEMANTIC_ETHICAL_ISSUES_REPORT = "ethicalIssuesReport";
|
|
|
|
|
private static final String SEMANTIC_COST_CURRENCY_CODE = "rda.dmp.cost.currencycode";
|
|
|
|
|
private static final String SEMANTIC_COST_CURRENCY_CODE = "rda.dmp.cost.currency_code";
|
|
|
|
|
private static final String SEMANTIC_COST_DESCRIPTION = "rda.dmp.cost.description";
|
|
|
|
|
private static final String SEMANTIC_COST_TITLE = "rda.dmp.cost.title";
|
|
|
|
|
private static final String SEMANTIC_COST_VALUE = "rda.dmp.cost.value";
|
|
|
|
@ -68,6 +69,37 @@ public class RdaFileTransformerService implements FileTransformerClient {
|
|
|
|
|
private static final String SEMANTIC_DATASET_SENSITIVE_DATA = "rda.dataset.sensitive_data";
|
|
|
|
|
private static final String SEMANTIC_DATASET_PRESERVATION_STATEMENT = "rda.dataset.preservation_statement";
|
|
|
|
|
private static final String SEMANTIC_DATASET_DATA_QUALITY_ASSURANCE = "rda.dataset.data_quality_assurance";
|
|
|
|
|
private static final String SEMANTIC_DATASET_TECHNICAL_RESOURCE_DESCRIPTION = "rda.dataset.technical_resource.description";
|
|
|
|
|
private static final String SEMANTIC_DATASET_TECHNICAL_RESOURCE_NAME = "rda.dataset.technical_resource.name";
|
|
|
|
|
private static final String SEMANTIC_DATASET_SECURITY_AND_PRIVACY_DESCRIPTION = "rda.dataset.security_and_privacy.description";
|
|
|
|
|
private static final String SEMANTIC_DATASET_SECURITY_AND_PRIVACY_TITLE = "rda.dataset.security_and_privacy.title";
|
|
|
|
|
private static final String SEMANTIC_DATASET_METADATA_LANGUAGE = "rda.dataset.metadata.language";
|
|
|
|
|
private static final String SEMANTIC_DATASET_METADATA_DESCRIPTION = "rda.dataset.metadata.description";
|
|
|
|
|
private static final String SEMANTIC_DATASET_METADATA_STANDARD_ID = "rda.dataset.metadata.standard_id";
|
|
|
|
|
private static final String SEMANTIC_DATASET_DATASET_ID = "rda.dataset.metadata.dataset_id";
|
|
|
|
|
private static final String SEMANTIC_DATASET_DATASET_ID_ID = "rda.dataset.metadata.dataset_id.id";
|
|
|
|
|
private static final String SEMANTIC_DATASET_DATASET_ID_TYPE = "rda.dataset.metadata.dataset_id.type";
|
|
|
|
|
private static final String SEMANTIC_DATASET_DISTRIBUTION_ACCESS_URL = "rda.dataset.distribution.access_url";
|
|
|
|
|
private static final String SEMANTIC_DATASET_DISTRIBUTION_AVAILABLE_UTIL = "rda.dataset.distribution.available_until";
|
|
|
|
|
private static final String SEMANTIC_DATASET_DISTRIBUTION_BYTE_SIZE = "rda.dataset.distribution.byte_size";
|
|
|
|
|
private static final String SEMANTIC_DATASET_DISTRIBUTION_DATA_ACCESS = "rda.dataset.distribution.data_access";
|
|
|
|
|
private static final String SEMANTIC_DATASET_DISTRIBUTION_DESCRIPTION = "rda.dataset.distribution.description";
|
|
|
|
|
private static final String SEMANTIC_DATASET_DISTRIBUTION_DOWNLOAD_URL = "rda.dataset.distribution.download_url";
|
|
|
|
|
private static final String SEMANTIC_DATASET_DISTRIBUTION_FORMAT = "rda.dataset.distribution.format";
|
|
|
|
|
private static final String SEMANTIC_DATASET_DISTRIBUTION_TITLE = "rda.dataset.distribution.title";
|
|
|
|
|
private static final String SEMANTIC_DATASET_DISTRIBUTION_LICENCE = "rda.dataset.distribution.license";
|
|
|
|
|
private static final String SEMANTIC_DATASET_DISTRIBUTION_HOST_AVAILABILITY = "rda.dataset.distribution.host.availability";
|
|
|
|
|
private static final String SEMANTIC_DATASET_DISTRIBUTION_HOST_BACKUP_FREQUENCY = "rda.dataset.distribution.host.backup_frequency";
|
|
|
|
|
private static final String SEMANTIC_DATASET_DISTRIBUTION_HOST_BACKUP_TYPE = "rda.dataset.distribution.host.backup_type";
|
|
|
|
|
private static final String SEMANTIC_DATASET_DISTRIBUTION_HOST_CERTIFIED_WITH = "rda.dataset.distribution.host.certified_with";
|
|
|
|
|
private static final String SEMANTIC_DATASET_DISTRIBUTION_HOST_DESCRIPTION = "rda.dataset.distribution.host.description";
|
|
|
|
|
private static final String SEMANTIC_DATASET_DISTRIBUTION_HOST_GEO_LOCATION = "rda.dataset.distribution.host.geo_location";
|
|
|
|
|
private static final String SEMANTIC_DATASET_DISTRIBUTION_HOST_PID_SYSTEM = "rda.dataset.distribution.host.pid_system";
|
|
|
|
|
private static final String SEMANTIC_DATASET_DISTRIBUTION_HOST_STORAGE_TYPE = "rda.dataset.distribution.host.storage_type";
|
|
|
|
|
private static final String SEMANTIC_DATASET_DISTRIBUTION_HOST_SUPPORT_VERSIONING = "rda.dataset.distribution.host.support_versioning";
|
|
|
|
|
private static final String SEMANTIC_DATASET_DISTRIBUTION_HOST_TITLE = "rda.dataset.distribution.host.title";
|
|
|
|
|
private static final String SEMANTIC_DATASET_DISTRIBUTION_HOST_URL = "rda.dataset.distribution.host.url";
|
|
|
|
|
private static final String SEMANTIC_DATASET_CONTRIBUTOR = "rda.dmp.contributor";
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
public RdaFileTransformerService(DmpRDAMapper dmpRDAMapper, DatasetRDAMapper descriptionRDAMapper, FileStorageService storageService, JsonHandlingService jsonHandlingService, RdaFileTransformerServiceConfiguration configuration, TemplateFieldSearcherService templateFieldSearcherService) {
|
|
|
|
@ -147,7 +179,13 @@ public class RdaFileTransformerService implements FileTransformerClient {
|
|
|
|
|
rda.setEthicalIssuesExist(buildRdaEthicalIssuesExist(dmp));
|
|
|
|
|
rda.setEthicalIssuesDescription(buildRdaEthicalIssuesDescription(dmp));
|
|
|
|
|
rda.setEthicalIssuesReport(buildRdaEthicalIssueReport(dmp));
|
|
|
|
|
rda.setProject(buildRdaProjects(projects, grants, funders));
|
|
|
|
|
if (projects.size() == 1 && grants.size() == 1 && funders.size() == 1) { //TODO: Project hierarchy not implemented should rewrite this logic
|
|
|
|
|
rda.setProject(buildRdaProjects(projects, grants, funders));
|
|
|
|
|
} else if (!projects.isEmpty()){
|
|
|
|
|
rda.setProject(buildRdaProjects(projects, new ArrayList<>(), new ArrayList<>()));
|
|
|
|
|
} else if (grants.size() == 1 && funders.size() == 1) {
|
|
|
|
|
rda.setProject(buildRdaProjects(grants, grants, funders));
|
|
|
|
|
}
|
|
|
|
|
Cost cost = buildRdaCost(dmp);
|
|
|
|
|
rda.setCost(new ArrayList<>());
|
|
|
|
|
if (cost != null) rda.getCost().add(cost);
|
|
|
|
@ -214,7 +252,7 @@ public class RdaFileTransformerService implements FileTransformerClient {
|
|
|
|
|
project.getDefinition().getFields().stream().filter(field -> this.configuration.getRdaFileTransformerServiceProperties().getProjectStartDateCode().equalsIgnoreCase(field.getCode()) && field.getValue() != null && !field.getValue().isBlank()).map(ReferenceFieldModel::getValue).findFirst().ifPresent(rda::setStart);
|
|
|
|
|
project.getDefinition().getFields().stream().filter(field -> this.configuration.getRdaFileTransformerServiceProperties().getProjectEndDateCode().equalsIgnoreCase(field.getCode()) && field.getValue() != null && !field.getValue().isBlank()).map(ReferenceFieldModel::getValue).findFirst().ifPresent(rda::setEnd);
|
|
|
|
|
}
|
|
|
|
|
rda.setFunding(List.of(this.buildRRdaFunding(grants.getFirst(), funders.getFirst()))); //TODO
|
|
|
|
|
if (!funders.isEmpty()) rda.setFunding(List.of(this.buildRRdaFunding(funders.getFirst(), grants.isEmpty() ? null : grants.getFirst())));
|
|
|
|
|
|
|
|
|
|
return rda;
|
|
|
|
|
}
|
|
|
|
@ -228,7 +266,7 @@ public class RdaFileTransformerService implements FileTransformerClient {
|
|
|
|
|
return rdaModels;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Funding buildRRdaFunding(ReferenceModel grant, ReferenceModel funder) {
|
|
|
|
|
public Funding buildRRdaFunding(ReferenceModel funder, ReferenceModel grant) {
|
|
|
|
|
if (grant == null && funder == null) return null;
|
|
|
|
|
Funding rda = new Funding();
|
|
|
|
|
String referencePrefix;
|
|
|
|
@ -445,6 +483,7 @@ public class RdaFileTransformerService implements FileTransformerClient {
|
|
|
|
|
if (model.getLabel() == null) throw new MyApplicationException("Dataset Label is missing");
|
|
|
|
|
|
|
|
|
|
Dataset rda = new Dataset();
|
|
|
|
|
rda.setDatasetId(this.buildRdaDatasetId(model));
|
|
|
|
|
rda.setTitle(model.getLabel());
|
|
|
|
|
rda.setDescription(model.getDescription());
|
|
|
|
|
rda.setLanguage(this.buildRdaDatasetLanguage(model));
|
|
|
|
@ -454,24 +493,623 @@ public class RdaFileTransformerService implements FileTransformerClient {
|
|
|
|
|
rda.setPersonalData(this.buildRdaDatasetPersonalData(model));
|
|
|
|
|
rda.setSensitiveData(this.buildRdaDatasetSensitiveData(model));
|
|
|
|
|
rda.setPreservationStatement(this.buildRdaDatasetPreservationStatement(model));
|
|
|
|
|
rda.setTechnicalResource(this.buildRdaDatasetTechnicalResources(model));
|
|
|
|
|
rda.setSecurityAndPrivacy(this.buildRdaDatasetSecurityAndPrivacy(model));
|
|
|
|
|
rda.setMetadata(this.buildRdaDatasetMetadata(model));
|
|
|
|
|
rda.setDataQualityAssurance(this.buildDataQualityAssurances(model));
|
|
|
|
|
rda.setDistribution(this.buildRdaDistribution(model));
|
|
|
|
|
|
|
|
|
|
dmpRda.getCost().addAll(this.buildRdaCosts(model));
|
|
|
|
|
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 = 0 ;
|
|
|
|
|
for (String keyword : rda.getKeyword()) {
|
|
|
|
|
rda.setAdditionalProperty("keyword" + (i + 1), keyword);
|
|
|
|
|
i++;
|
|
|
|
|
int i = 1;
|
|
|
|
|
for (String keyword : rda.getKeyword()) rda.setAdditionalProperty("keyword" + (i++), keyword);
|
|
|
|
|
} //TODO Old logic not moved
|
|
|
|
|
return rda;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private List<Contributor> buildContributor(DescriptionModel model){
|
|
|
|
|
List<Contributor> values = new ArrayList<>();
|
|
|
|
|
for (FieldModel field : this.templateFieldSearcherService.searchFieldsBySemanticsFlat(model.getDescriptionTemplate(), SEMANTIC_DATASET_CONTRIBUTOR)) {
|
|
|
|
|
List<org.opencdmp.commonmodels.models.description.FieldModel> fieldValues = this.findValueField(field, model.getProperties());
|
|
|
|
|
for (org.opencdmp.commonmodels.models.description.FieldModel fieldValue : fieldValues) {
|
|
|
|
|
if (fieldValue.getReferences() != null && !fieldValue.getReferences().isEmpty()) {
|
|
|
|
|
for (ReferenceModel referenceModel : fieldValue.getReferences()){
|
|
|
|
|
values.add(this.buildRdaContributor(referenceModel));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return rda;
|
|
|
|
|
return values;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void mergeEthicalIssues(DescriptionModel model, Dmp dmpRda){
|
|
|
|
|
for (FieldModel field : this.templateFieldSearcherService.searchFieldsBySemanticsFlat(model.getDescriptionTemplate(), SEMANTIC_ETHICAL_ISSUES)) {
|
|
|
|
|
List<org.opencdmp.commonmodels.models.description.FieldModel> fieldValues = this.findValueField(field, model.getProperties());
|
|
|
|
|
for (org.opencdmp.commonmodels.models.description.FieldModel fieldValue : fieldValues) {
|
|
|
|
|
if (fieldValue.getTextValue() != null && !fieldValue.getTextValue().isBlank()) {
|
|
|
|
|
try {
|
|
|
|
|
Dmp.EthicalIssuesExist value = Dmp.EthicalIssuesExist.fromValue(fieldValue.getTextValue());
|
|
|
|
|
if (!Dmp.EthicalIssuesExist.UNKNOWN.equals(value)) dmpRda.setEthicalIssuesExist(value);
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
logger.error(e.getMessage(), e);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
for (FieldSetModel fieldSet : this.templateFieldSearcherService.searchFieldSetsBySemantics(model.getDescriptionTemplate(), List.of(SEMANTIC_ETHICAL_ISSUES, SEMANTIC_ETHICAL_ISSUES_DESCRIPTION, SEMANTIC_ETHICAL_ISSUES_REPORT))) {
|
|
|
|
|
|
|
|
|
|
FieldModel field = this.templateFieldSearcherService.findFieldBySemantic(fieldSet, SEMANTIC_ETHICAL_ISSUES);
|
|
|
|
|
List<org.opencdmp.commonmodels.models.description.FieldModel> valueField = this.findValueField(field, model.getProperties());
|
|
|
|
|
for (org.opencdmp.commonmodels.models.description.FieldModel fieldValue : valueField) {
|
|
|
|
|
if (fieldValue.getTextValue() != null && !fieldValue.getTextValue().isBlank()) {
|
|
|
|
|
try {
|
|
|
|
|
Dmp.EthicalIssuesExist value = Dmp.EthicalIssuesExist.fromValue(fieldValue.getTextValue());
|
|
|
|
|
if (!Dmp.EthicalIssuesExist.UNKNOWN.equals(value)) dmpRda.setEthicalIssuesExist(value);
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
logger.error(e.getMessage(), e);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (dmpRda.getEthicalIssuesDescription() == null || dmpRda.getEthicalIssuesDescription().isBlank()) {
|
|
|
|
|
field = this.templateFieldSearcherService.findFieldBySemantic(fieldSet, SEMANTIC_ETHICAL_ISSUES_DESCRIPTION);
|
|
|
|
|
valueField = this.findValueField(field, model.getProperties());
|
|
|
|
|
for (org.opencdmp.commonmodels.models.description.FieldModel fieldValue : valueField) {
|
|
|
|
|
if (fieldValue.getTextValue() != null && !fieldValue.getTextValue().isBlank()) {
|
|
|
|
|
dmpRda.setEthicalIssuesDescription(fieldValue.getTextValue());
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (dmpRda.getEthicalIssuesReport() == null) {
|
|
|
|
|
field = this.templateFieldSearcherService.findFieldBySemantic(fieldSet, SEMANTIC_ETHICAL_ISSUES_REPORT);
|
|
|
|
|
valueField = this.findValueField(field, model.getProperties());
|
|
|
|
|
for (org.opencdmp.commonmodels.models.description.FieldModel fieldValue : valueField) {
|
|
|
|
|
if (fieldValue.getTextValue() != null && !fieldValue.getTextValue().isBlank()) {
|
|
|
|
|
try {
|
|
|
|
|
dmpRda.setEthicalIssuesReport(URI.create(fieldValue.getTextValue()));
|
|
|
|
|
break;
|
|
|
|
|
} catch (Exception ex){
|
|
|
|
|
logger.error(ex.getMessage(), ex);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private List<Cost> buildRdaCosts(DescriptionModel model){
|
|
|
|
|
List<Cost> values = new ArrayList<>();
|
|
|
|
|
for (FieldSetModel fieldSet : this.templateFieldSearcherService.searchFieldSetsBySemantics(model.getDescriptionTemplate(), List.of(SEMANTIC_COST_CURRENCY_CODE, SEMANTIC_COST_VALUE, SEMANTIC_COST_DESCRIPTION, SEMANTIC_COST_TITLE))) {
|
|
|
|
|
boolean valueFound = false;
|
|
|
|
|
Cost item = new Cost();
|
|
|
|
|
|
|
|
|
|
FieldModel field = this.templateFieldSearcherService.findFieldBySemantic(fieldSet, SEMANTIC_COST_CURRENCY_CODE);
|
|
|
|
|
List<org.opencdmp.commonmodels.models.description.FieldModel> valueField = this.findValueField(field, model.getProperties());
|
|
|
|
|
for (org.opencdmp.commonmodels.models.description.FieldModel fieldValue : valueField) {
|
|
|
|
|
if (fieldValue.getTextValue() != null && !fieldValue.getTextValue().isBlank()) {
|
|
|
|
|
try {
|
|
|
|
|
item.setCurrencyCode(Cost.CurrencyCode.fromValue(fieldValue.getTextValue()));
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
logger.error(e.getMessage(), e);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
field = this.templateFieldSearcherService.findFieldBySemantic(fieldSet, SEMANTIC_COST_DESCRIPTION);
|
|
|
|
|
valueField = this.findValueField(field, model.getProperties());
|
|
|
|
|
for (org.opencdmp.commonmodels.models.description.FieldModel fieldValue : valueField) {
|
|
|
|
|
if (fieldValue.getTextValue() != null && !fieldValue.getTextValue().isBlank()) {
|
|
|
|
|
item.setDescription(fieldValue.getTextValue());
|
|
|
|
|
valueFound = true;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
field = this.templateFieldSearcherService.findFieldBySemantic(fieldSet, SEMANTIC_COST_TITLE);
|
|
|
|
|
valueField = this.findValueField(field, model.getProperties());
|
|
|
|
|
for (org.opencdmp.commonmodels.models.description.FieldModel fieldValue : valueField) {
|
|
|
|
|
if (fieldValue.getTextValue() != null && !fieldValue.getTextValue().isBlank()) {
|
|
|
|
|
item.setTitle(fieldValue.getTextValue());
|
|
|
|
|
valueFound = true;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
field = this.templateFieldSearcherService.findFieldBySemantic(fieldSet, SEMANTIC_COST_VALUE);
|
|
|
|
|
valueField = this.findValueField(field, model.getProperties());
|
|
|
|
|
for (org.opencdmp.commonmodels.models.description.FieldModel fieldValue : valueField) {
|
|
|
|
|
if (fieldValue.getTextValue() != null && !fieldValue.getTextValue().isBlank()) {
|
|
|
|
|
try {
|
|
|
|
|
item.setValue(Double.valueOf(fieldValue.getTextValue()));
|
|
|
|
|
valueFound = true;
|
|
|
|
|
break;
|
|
|
|
|
} catch (Exception ex){
|
|
|
|
|
logger.error(ex.getMessage(), ex);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (valueFound) values.add(item);
|
|
|
|
|
}
|
|
|
|
|
return values;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private List<Distribution> buildRdaDistribution(DescriptionModel model){
|
|
|
|
|
List<Distribution> values = new ArrayList<>();
|
|
|
|
|
for (FieldSetModel fieldSet : this.templateFieldSearcherService.searchFieldSetsBySemantics(model.getDescriptionTemplate(), List.of(
|
|
|
|
|
SEMANTIC_DATASET_DISTRIBUTION_LICENCE, SEMANTIC_DATASET_DISTRIBUTION_TITLE, SEMANTIC_DATASET_DISTRIBUTION_FORMAT,
|
|
|
|
|
SEMANTIC_DATASET_DISTRIBUTION_DOWNLOAD_URL, SEMANTIC_DATASET_DISTRIBUTION_DESCRIPTION, SEMANTIC_DATASET_DISTRIBUTION_DATA_ACCESS,
|
|
|
|
|
SEMANTIC_DATASET_DISTRIBUTION_BYTE_SIZE, SEMANTIC_DATASET_DISTRIBUTION_AVAILABLE_UTIL, SEMANTIC_DATASET_DISTRIBUTION_ACCESS_URL))) {
|
|
|
|
|
boolean valueFound = false;
|
|
|
|
|
Distribution item = new Distribution();
|
|
|
|
|
|
|
|
|
|
FieldModel field = this.templateFieldSearcherService.findFieldBySemantic(fieldSet, SEMANTIC_DATASET_DISTRIBUTION_TITLE);
|
|
|
|
|
List<org.opencdmp.commonmodels.models.description.FieldModel> valueField = this.findValueField(field, model.getProperties());
|
|
|
|
|
for (org.opencdmp.commonmodels.models.description.FieldModel fieldValue : valueField) {
|
|
|
|
|
if (fieldValue.getTextValue() != null && !fieldValue.getTextValue().isBlank()) {
|
|
|
|
|
item.setTitle(fieldValue.getTextValue());
|
|
|
|
|
valueFound = true;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
field = this.templateFieldSearcherService.findFieldBySemantic(fieldSet, SEMANTIC_DATASET_DISTRIBUTION_FORMAT);
|
|
|
|
|
valueField = this.findValueField(field, model.getProperties());
|
|
|
|
|
item.setFormat(new ArrayList<>());
|
|
|
|
|
for (org.opencdmp.commonmodels.models.description.FieldModel fieldValue : valueField) {
|
|
|
|
|
if (fieldValue.getTextValue() != null && !fieldValue.getTextValue().isBlank()) {
|
|
|
|
|
item.getFormat().add(fieldValue.getTextValue());
|
|
|
|
|
valueFound = true;
|
|
|
|
|
}
|
|
|
|
|
if (fieldValue.getTextListValue() != null && !fieldValue.getTextListValue().isEmpty()) {
|
|
|
|
|
item.getFormat().add(fieldValue.getTextValue());
|
|
|
|
|
valueFound = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
item.setFormat(item.getFormat().stream().distinct().toList());
|
|
|
|
|
|
|
|
|
|
field = this.templateFieldSearcherService.findFieldBySemantic(fieldSet, SEMANTIC_DATASET_DISTRIBUTION_DOWNLOAD_URL);
|
|
|
|
|
valueField = this.findValueField(field, model.getProperties());
|
|
|
|
|
for (org.opencdmp.commonmodels.models.description.FieldModel fieldValue : valueField) {
|
|
|
|
|
if (fieldValue.getTextValue() != null && !fieldValue.getTextValue().isBlank()) {
|
|
|
|
|
try {
|
|
|
|
|
item.setDownloadUrl(URI.create(fieldValue.getTextValue()));
|
|
|
|
|
valueFound = true;
|
|
|
|
|
break;
|
|
|
|
|
} catch (Exception ex){
|
|
|
|
|
logger.error(ex.getMessage(), ex);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
field = this.templateFieldSearcherService.findFieldBySemantic(fieldSet, SEMANTIC_DATASET_DISTRIBUTION_DESCRIPTION);
|
|
|
|
|
valueField = this.findValueField(field, model.getProperties());
|
|
|
|
|
for (org.opencdmp.commonmodels.models.description.FieldModel fieldValue : valueField) {
|
|
|
|
|
if (fieldValue.getTextValue() != null && !fieldValue.getTextValue().isBlank()) {
|
|
|
|
|
item.setDescription(fieldValue.getTextValue());
|
|
|
|
|
valueFound = true;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
field = this.templateFieldSearcherService.findFieldBySemantic(fieldSet, SEMANTIC_DATASET_DISTRIBUTION_DATA_ACCESS);
|
|
|
|
|
valueField = this.findValueField(field, model.getProperties());
|
|
|
|
|
for (org.opencdmp.commonmodels.models.description.FieldModel fieldValue : valueField) {
|
|
|
|
|
if (fieldValue.getTextValue() != null && !fieldValue.getTextValue().isBlank()) {
|
|
|
|
|
try {
|
|
|
|
|
item.setDataAccess(Distribution.DataAccess.fromValue(fieldValue.getTextValue()));
|
|
|
|
|
valueFound = true;
|
|
|
|
|
break;
|
|
|
|
|
} catch (Exception ex){
|
|
|
|
|
logger.error(ex.getMessage(), ex);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
field = this.templateFieldSearcherService.findFieldBySemantic(fieldSet, SEMANTIC_DATASET_DISTRIBUTION_BYTE_SIZE);
|
|
|
|
|
valueField = this.findValueField(field, model.getProperties());
|
|
|
|
|
for (org.opencdmp.commonmodels.models.description.FieldModel fieldValue : valueField) {
|
|
|
|
|
if (fieldValue.getTextValue() != null && !fieldValue.getTextValue().isBlank()) {
|
|
|
|
|
try {
|
|
|
|
|
item.setByteSize(Integer.valueOf(fieldValue.getTextValue()));
|
|
|
|
|
valueFound = true;
|
|
|
|
|
break;
|
|
|
|
|
} catch (Exception ex){
|
|
|
|
|
logger.error(ex.getMessage(), ex);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
field = this.templateFieldSearcherService.findFieldBySemantic(fieldSet, SEMANTIC_DATASET_DISTRIBUTION_AVAILABLE_UTIL);
|
|
|
|
|
valueField = this.findValueField(field, model.getProperties());
|
|
|
|
|
for (org.opencdmp.commonmodels.models.description.FieldModel fieldValue : valueField) {
|
|
|
|
|
try {
|
|
|
|
|
if (fieldValue.getTextValue() != null && !fieldValue.getTextValue().isBlank()) {
|
|
|
|
|
item.setAvailableUntil(fieldValue.getTextValue());
|
|
|
|
|
valueFound = true;
|
|
|
|
|
break;
|
|
|
|
|
} else if (fieldValue.getDateValue() != null){
|
|
|
|
|
item.setAvailableUntil(DateTimeFormatter.ISO_DATE.format(fieldValue.getDateValue()));
|
|
|
|
|
valueFound = true;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex){
|
|
|
|
|
logger.error(ex.getMessage(), ex);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
field = this.templateFieldSearcherService.findFieldBySemantic(fieldSet, SEMANTIC_DATASET_DISTRIBUTION_ACCESS_URL);
|
|
|
|
|
valueField = this.findValueField(field, model.getProperties());
|
|
|
|
|
for (org.opencdmp.commonmodels.models.description.FieldModel fieldValue : valueField) {
|
|
|
|
|
if (fieldValue.getTextValue() != null && !fieldValue.getTextValue().isBlank()) {
|
|
|
|
|
item.setAccessUrl(fieldValue.getTextValue());
|
|
|
|
|
valueFound = true;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
field = this.templateFieldSearcherService.findFieldBySemantic(fieldSet, SEMANTIC_DATASET_DISTRIBUTION_LICENCE);
|
|
|
|
|
valueField = this.findValueField(field, model.getProperties());
|
|
|
|
|
for (org.opencdmp.commonmodels.models.description.FieldModel fieldValue : valueField) {
|
|
|
|
|
if (fieldValue.getReferences() != null && !fieldValue.getReferences().isEmpty()) {
|
|
|
|
|
item.setLicense(new ArrayList<>());
|
|
|
|
|
for (ReferenceModel referenceModel : fieldValue.getReferences()){
|
|
|
|
|
if (referenceModel.getDefinition() != null && referenceModel.getDefinition().getFields() != null) {
|
|
|
|
|
try {
|
|
|
|
|
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);
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
|
|
item.getLicense().add(license);
|
|
|
|
|
} catch (Exception ex){
|
|
|
|
|
logger.error(ex.getMessage(), ex);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (!item.getLicense().isEmpty()) valueFound = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (valueFound) {
|
|
|
|
|
item.setHost(this.buildRdaDistributionHost(model, fieldSet));
|
|
|
|
|
values.add(item);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return values.isEmpty() ? null : values;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private Host buildRdaDistributionHost(DescriptionModel model, FieldSetModel fieldSet) {
|
|
|
|
|
boolean valueFound = false;
|
|
|
|
|
Host item = new Host();
|
|
|
|
|
|
|
|
|
|
FieldModel field = this.templateFieldSearcherService.findFieldBySemantic(fieldSet, SEMANTIC_DATASET_DISTRIBUTION_HOST_TITLE);
|
|
|
|
|
List<org.opencdmp.commonmodels.models.description.FieldModel> valueField = this.findValueField(field, model.getProperties());
|
|
|
|
|
for (org.opencdmp.commonmodels.models.description.FieldModel fieldValue : valueField) {
|
|
|
|
|
if (fieldValue.getTextValue() != null && !fieldValue.getTextValue().isBlank()) {
|
|
|
|
|
item.setTitle(fieldValue.getTextValue());
|
|
|
|
|
valueFound = true;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
field = this.templateFieldSearcherService.findFieldBySemantic(fieldSet, SEMANTIC_DATASET_DISTRIBUTION_HOST_URL);
|
|
|
|
|
valueField = this.findValueField(field, model.getProperties());
|
|
|
|
|
for (org.opencdmp.commonmodels.models.description.FieldModel fieldValue : valueField) {
|
|
|
|
|
if (fieldValue.getTextValue() != null && !fieldValue.getTextValue().isBlank()) {
|
|
|
|
|
try {
|
|
|
|
|
item.setUrl(URI.create(fieldValue.getTextValue()));
|
|
|
|
|
valueFound = true;
|
|
|
|
|
break;
|
|
|
|
|
} catch (Exception ex) {
|
|
|
|
|
logger.error(ex.getMessage(), ex);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
field = this.templateFieldSearcherService.findFieldBySemantic(fieldSet, SEMANTIC_DATASET_DISTRIBUTION_HOST_DESCRIPTION);
|
|
|
|
|
valueField = this.findValueField(field, model.getProperties());
|
|
|
|
|
for (org.opencdmp.commonmodels.models.description.FieldModel fieldValue : valueField) {
|
|
|
|
|
if (fieldValue.getTextValue() != null && !fieldValue.getTextValue().isBlank()) {
|
|
|
|
|
item.setDescription(fieldValue.getTextValue());
|
|
|
|
|
valueFound = true;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
field = this.templateFieldSearcherService.findFieldBySemantic(fieldSet, SEMANTIC_DATASET_DISTRIBUTION_HOST_STORAGE_TYPE);
|
|
|
|
|
valueField = this.findValueField(field, model.getProperties());
|
|
|
|
|
for (org.opencdmp.commonmodels.models.description.FieldModel fieldValue : valueField) {
|
|
|
|
|
if (fieldValue.getTextValue() != null && !fieldValue.getTextValue().isBlank()) {
|
|
|
|
|
item.setStorageType(fieldValue.getTextValue());
|
|
|
|
|
valueFound = true;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
field = this.templateFieldSearcherService.findFieldBySemantic(fieldSet, SEMANTIC_DATASET_DISTRIBUTION_HOST_BACKUP_TYPE);
|
|
|
|
|
valueField = this.findValueField(field, model.getProperties());
|
|
|
|
|
for (org.opencdmp.commonmodels.models.description.FieldModel fieldValue : valueField) {
|
|
|
|
|
if (fieldValue.getTextValue() != null && !fieldValue.getTextValue().isBlank()) {
|
|
|
|
|
item.setBackupType(fieldValue.getTextValue());
|
|
|
|
|
valueFound = true;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
field = this.templateFieldSearcherService.findFieldBySemantic(fieldSet, SEMANTIC_DATASET_DISTRIBUTION_HOST_AVAILABILITY);
|
|
|
|
|
valueField = this.findValueField(field, model.getProperties());
|
|
|
|
|
for (org.opencdmp.commonmodels.models.description.FieldModel fieldValue : valueField) {
|
|
|
|
|
if (fieldValue.getTextValue() != null && !fieldValue.getTextValue().isBlank()) {
|
|
|
|
|
item.setAvailability(fieldValue.getTextValue());
|
|
|
|
|
valueFound = true;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
field = this.templateFieldSearcherService.findFieldBySemantic(fieldSet, SEMANTIC_DATASET_DISTRIBUTION_HOST_BACKUP_FREQUENCY);
|
|
|
|
|
valueField = this.findValueField(field, model.getProperties());
|
|
|
|
|
for (org.opencdmp.commonmodels.models.description.FieldModel fieldValue : valueField) {
|
|
|
|
|
if (fieldValue.getTextValue() != null && !fieldValue.getTextValue().isBlank()) {
|
|
|
|
|
item.setBackupFrequency(fieldValue.getTextValue());
|
|
|
|
|
valueFound = true;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
field = this.templateFieldSearcherService.findFieldBySemantic(fieldSet, SEMANTIC_DATASET_DISTRIBUTION_HOST_GEO_LOCATION);
|
|
|
|
|
valueField = this.findValueField(field, model.getProperties());
|
|
|
|
|
for (org.opencdmp.commonmodels.models.description.FieldModel fieldValue : valueField) {
|
|
|
|
|
if (fieldValue.getTextValue() != null && !fieldValue.getTextValue().isBlank()) {
|
|
|
|
|
try {
|
|
|
|
|
item.setGeoLocation(Host.GeoLocation.fromValue(fieldValue.getTextValue()));
|
|
|
|
|
valueFound = true;
|
|
|
|
|
break;
|
|
|
|
|
} catch (Exception ex) {
|
|
|
|
|
logger.error(ex.getMessage(), ex);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
field = this.templateFieldSearcherService.findFieldBySemantic(fieldSet, SEMANTIC_DATASET_DISTRIBUTION_HOST_SUPPORT_VERSIONING);
|
|
|
|
|
valueField = this.findValueField(field, model.getProperties());
|
|
|
|
|
for (org.opencdmp.commonmodels.models.description.FieldModel fieldValue : valueField) {
|
|
|
|
|
if (fieldValue.getTextValue() != null && !fieldValue.getTextValue().isBlank()) {
|
|
|
|
|
try {
|
|
|
|
|
item.setSupportVersioning(Host.SupportVersioning.fromValue(fieldValue.getTextValue()));
|
|
|
|
|
valueFound = true;
|
|
|
|
|
break;
|
|
|
|
|
} catch (Exception ex) {
|
|
|
|
|
logger.error(ex.getMessage(), ex);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
field = this.templateFieldSearcherService.findFieldBySemantic(fieldSet, SEMANTIC_DATASET_DISTRIBUTION_HOST_CERTIFIED_WITH);
|
|
|
|
|
valueField = this.findValueField(field, model.getProperties());
|
|
|
|
|
for (org.opencdmp.commonmodels.models.description.FieldModel fieldValue : valueField) {
|
|
|
|
|
if (fieldValue.getTextValue() != null && !fieldValue.getTextValue().isBlank()) {
|
|
|
|
|
try {
|
|
|
|
|
item.setCertifiedWith(Host.CertifiedWith.fromValue(fieldValue.getTextValue()));
|
|
|
|
|
valueFound = true;
|
|
|
|
|
break;
|
|
|
|
|
} catch (Exception ex) {
|
|
|
|
|
logger.error(ex.getMessage(), ex);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
field = this.templateFieldSearcherService.findFieldBySemantic(fieldSet, SEMANTIC_DATASET_DISTRIBUTION_HOST_PID_SYSTEM);
|
|
|
|
|
valueField = this.findValueField(field, model.getProperties());
|
|
|
|
|
item.setPidSystem(new ArrayList<>());
|
|
|
|
|
for (org.opencdmp.commonmodels.models.description.FieldModel fieldValue : valueField) {
|
|
|
|
|
try {
|
|
|
|
|
if (fieldValue.getTextValue() != null && !fieldValue.getTextValue().isBlank()) {
|
|
|
|
|
try {
|
|
|
|
|
item.getPidSystem().add(PidSystem.fromValue(fieldValue.getTextValue()));
|
|
|
|
|
valueFound = true;
|
|
|
|
|
} catch (Exception ex) {
|
|
|
|
|
logger.error(ex.getMessage(), ex);
|
|
|
|
|
}
|
|
|
|
|
valueFound = true;
|
|
|
|
|
}
|
|
|
|
|
if (fieldValue.getTextListValue() != null && !fieldValue.getTextListValue().isEmpty()) {
|
|
|
|
|
try {
|
|
|
|
|
item.getPidSystem().add(PidSystem.fromValue(fieldValue.getTextValue()));
|
|
|
|
|
valueFound = true;
|
|
|
|
|
} catch (Exception ex) {
|
|
|
|
|
logger.error(ex.getMessage(), ex);
|
|
|
|
|
}
|
|
|
|
|
valueFound = true;
|
|
|
|
|
}
|
|
|
|
|
} catch (Exception ex) {
|
|
|
|
|
logger.error(ex.getMessage(), ex);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (valueFound) return item;
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private List<String> buildDataQualityAssurances(DescriptionModel model){
|
|
|
|
|
List<String> values = new ArrayList<>();
|
|
|
|
|
for (FieldModel field : this.templateFieldSearcherService.searchFieldsBySemanticsFlat(model.getDescriptionTemplate(), SEMANTIC_DATASET_DATA_QUALITY_ASSURANCE)) {
|
|
|
|
|
List<org.opencdmp.commonmodels.models.description.FieldModel> fieldValues = this.findValueField(field, model.getProperties());
|
|
|
|
|
for (org.opencdmp.commonmodels.models.description.FieldModel fieldValue : fieldValues) {
|
|
|
|
|
if (fieldValue.getTextValue() != null && !fieldValue.getTextValue().isBlank()) {
|
|
|
|
|
values.add(fieldValue.getTextValue());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return values;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private DatasetId buildRdaDatasetId(DescriptionModel model){
|
|
|
|
|
DatasetId datasetId = new DatasetId();
|
|
|
|
|
datasetId.setType(DatasetId.Type.OTHER);
|
|
|
|
|
|
|
|
|
|
for (FieldModel field : this.templateFieldSearcherService.searchFieldsBySemanticsFlat(model.getDescriptionTemplate(), SEMANTIC_DATASET_DATASET_ID)) {
|
|
|
|
|
List<org.opencdmp.commonmodels.models.description.FieldModel> fieldValues = this.findValueField(field, model.getProperties());
|
|
|
|
|
for (org.opencdmp.commonmodels.models.description.FieldModel fieldValue : fieldValues) {
|
|
|
|
|
if (fieldValue.getTextValue() != null && !fieldValue.getTextValue().isBlank()) {
|
|
|
|
|
datasetId.setIdentifier(fieldValue.getTextValue() );
|
|
|
|
|
return datasetId;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (FieldSetModel fieldSet : this.templateFieldSearcherService.searchFieldSetsBySemantics(model.getDescriptionTemplate(), List.of(SEMANTIC_DATASET_DATASET_ID_ID, SEMANTIC_DATASET_DATASET_ID_TYPE))) {
|
|
|
|
|
boolean valueFound = false;
|
|
|
|
|
|
|
|
|
|
FieldModel field = this.templateFieldSearcherService.findFieldBySemantic(fieldSet, SEMANTIC_DATASET_DATASET_ID_ID);
|
|
|
|
|
List<org.opencdmp.commonmodels.models.description.FieldModel> valueField = this.findValueField(field, model.getProperties());
|
|
|
|
|
for (org.opencdmp.commonmodels.models.description.FieldModel fieldValue : valueField) {
|
|
|
|
|
if (fieldValue.getTextValue() != null && !fieldValue.getTextValue().isBlank()) {
|
|
|
|
|
datasetId.setIdentifier(fieldValue.getTextValue());
|
|
|
|
|
valueFound = true;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
field = this.templateFieldSearcherService.findFieldBySemantic(fieldSet, SEMANTIC_DATASET_DATASET_ID_TYPE);
|
|
|
|
|
valueField = this.findValueField(field, model.getProperties());
|
|
|
|
|
for (org.opencdmp.commonmodels.models.description.FieldModel fieldValue : valueField) {
|
|
|
|
|
if (fieldValue.getTextValue() != null && !fieldValue.getTextValue().isBlank()) {
|
|
|
|
|
datasetId.setType(DatasetId.Type.fromValue(fieldValue.getTextValue()));
|
|
|
|
|
valueFound = true;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (valueFound) return datasetId;
|
|
|
|
|
}
|
|
|
|
|
return new DatasetId(model.getId().toString(), DatasetId.Type.OTHER);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private List<Metadatum> buildRdaDatasetMetadata(DescriptionModel model){
|
|
|
|
|
List<Metadatum> values = new ArrayList<>();
|
|
|
|
|
for (FieldSetModel fieldSet : this.templateFieldSearcherService.searchFieldSetsBySemantics(model.getDescriptionTemplate(), List.of(SEMANTIC_DATASET_METADATA_DESCRIPTION, SEMANTIC_DATASET_METADATA_LANGUAGE, SEMANTIC_DATASET_METADATA_STANDARD_ID))) {
|
|
|
|
|
boolean valueFound = false;
|
|
|
|
|
Metadatum item = new Metadatum();
|
|
|
|
|
|
|
|
|
|
FieldModel field = this.templateFieldSearcherService.findFieldBySemantic(fieldSet, SEMANTIC_DATASET_METADATA_LANGUAGE);
|
|
|
|
|
List<org.opencdmp.commonmodels.models.description.FieldModel> valueField = this.findValueField(field, model.getProperties());
|
|
|
|
|
for (org.opencdmp.commonmodels.models.description.FieldModel fieldValue : valueField) {
|
|
|
|
|
if (fieldValue.getTextValue() != null && !fieldValue.getTextValue().isBlank()) {
|
|
|
|
|
try {
|
|
|
|
|
item.setLanguage(Metadatum.Language.fromValue(fieldValue.getTextValue()));
|
|
|
|
|
valueFound = true;
|
|
|
|
|
break;
|
|
|
|
|
} catch (Exception e){
|
|
|
|
|
logger.error(e.getMessage(), e);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
field = this.templateFieldSearcherService.findFieldBySemantic(fieldSet, SEMANTIC_DATASET_METADATA_DESCRIPTION);
|
|
|
|
|
valueField = this.findValueField(field, model.getProperties());
|
|
|
|
|
for (org.opencdmp.commonmodels.models.description.FieldModel fieldValue : valueField) {
|
|
|
|
|
if (fieldValue.getTextValue() != null && !fieldValue.getTextValue().isBlank()) {
|
|
|
|
|
item.setDescription(fieldValue.getTextValue());
|
|
|
|
|
valueFound = true;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
field = this.templateFieldSearcherService.findFieldBySemantic(fieldSet, SEMANTIC_DATASET_METADATA_STANDARD_ID);
|
|
|
|
|
valueField = this.findValueField(field, model.getProperties());
|
|
|
|
|
for (org.opencdmp.commonmodels.models.description.FieldModel fieldValue : valueField) {
|
|
|
|
|
if (fieldValue.getTextValue() != null && !fieldValue.getTextValue().isBlank()) {
|
|
|
|
|
MetadataStandardId standardId = new MetadataStandardId();
|
|
|
|
|
standardId.setIdentifier(fieldValue.getTextValue());
|
|
|
|
|
standardId.setType(MetadataStandardId.Type.URL);
|
|
|
|
|
item.setMetadataStandardId(standardId);
|
|
|
|
|
valueFound = true;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (valueFound) values.add(item);
|
|
|
|
|
}
|
|
|
|
|
return values.isEmpty() ? null : values;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private List<SecurityAndPrivacy> buildRdaDatasetSecurityAndPrivacy(DescriptionModel model){
|
|
|
|
|
List<SecurityAndPrivacy> values = new ArrayList<>();
|
|
|
|
|
for (FieldSetModel fieldSet : this.templateFieldSearcherService.searchFieldSetsBySemantics(model.getDescriptionTemplate(), List.of(SEMANTIC_DATASET_SECURITY_AND_PRIVACY_TITLE, SEMANTIC_DATASET_SECURITY_AND_PRIVACY_DESCRIPTION))) {
|
|
|
|
|
boolean valueFound = false;
|
|
|
|
|
SecurityAndPrivacy item = new SecurityAndPrivacy();
|
|
|
|
|
|
|
|
|
|
FieldModel field = this.templateFieldSearcherService.findFieldBySemantic(fieldSet, SEMANTIC_DATASET_SECURITY_AND_PRIVACY_TITLE);
|
|
|
|
|
List<org.opencdmp.commonmodels.models.description.FieldModel> valueField = this.findValueField(field, model.getProperties());
|
|
|
|
|
for (org.opencdmp.commonmodels.models.description.FieldModel fieldValue : valueField) {
|
|
|
|
|
if (fieldValue.getTextValue() != null && !fieldValue.getTextValue().isBlank()) {
|
|
|
|
|
item.setTitle(fieldValue.getTextValue());
|
|
|
|
|
valueFound = true;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
field = this.templateFieldSearcherService.findFieldBySemantic(fieldSet, SEMANTIC_DATASET_SECURITY_AND_PRIVACY_DESCRIPTION);
|
|
|
|
|
valueField = this.findValueField(field, model.getProperties());
|
|
|
|
|
for (org.opencdmp.commonmodels.models.description.FieldModel fieldValue : valueField) {
|
|
|
|
|
if (fieldValue.getTextValue() != null && !fieldValue.getTextValue().isBlank()) {
|
|
|
|
|
item.setDescription(fieldValue.getTextValue());
|
|
|
|
|
valueFound = true;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (valueFound) values.add(item);
|
|
|
|
|
}
|
|
|
|
|
return values.isEmpty() ? null : values;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private List<TechnicalResource> buildRdaDatasetTechnicalResources(DescriptionModel model){
|
|
|
|
|
List<TechnicalResource> values = new ArrayList<>();
|
|
|
|
|
for (FieldSetModel fieldSet : this.templateFieldSearcherService.searchFieldSetsBySemantics(model.getDescriptionTemplate(), List.of(SEMANTIC_DATASET_TECHNICAL_RESOURCE_NAME, SEMANTIC_DATASET_TECHNICAL_RESOURCE_DESCRIPTION))) {
|
|
|
|
|
boolean valueFound = false;
|
|
|
|
|
TechnicalResource item = new TechnicalResource();
|
|
|
|
|
|
|
|
|
|
FieldModel field = this.templateFieldSearcherService.findFieldBySemantic(fieldSet, SEMANTIC_DATASET_TECHNICAL_RESOURCE_NAME);
|
|
|
|
|
List<org.opencdmp.commonmodels.models.description.FieldModel> valueField = this.findValueField(field, model.getProperties());
|
|
|
|
|
for (org.opencdmp.commonmodels.models.description.FieldModel fieldValue : valueField) {
|
|
|
|
|
if (fieldValue.getTextValue() != null && !fieldValue.getTextValue().isBlank()) {
|
|
|
|
|
item.setName(fieldValue.getTextValue());
|
|
|
|
|
valueFound = true;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
field = this.templateFieldSearcherService.findFieldBySemantic(fieldSet, SEMANTIC_DATASET_TECHNICAL_RESOURCE_DESCRIPTION);
|
|
|
|
|
valueField = this.findValueField(field, model.getProperties());
|
|
|
|
|
for (org.opencdmp.commonmodels.models.description.FieldModel fieldValue : valueField) {
|
|
|
|
|
if (fieldValue.getTextValue() != null && !fieldValue.getTextValue().isBlank()) {
|
|
|
|
|
item.setDescription(fieldValue.getTextValue());
|
|
|
|
|
valueFound = true;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (valueFound) values.add(item);
|
|
|
|
|
}
|
|
|
|
|
return values;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private String buildRdaDatasetPreservationStatement(DescriptionModel model){
|
|
|
|
|
for (FieldModel field : this.templateFieldSearcherService.searchFieldsBySemanticsFlat(model.getDescriptionTemplate(), SEMANTIC_DATASET_PRESERVATION_STATEMENT)) {
|
|
|
|
|
List<org.opencdmp.commonmodels.models.description.FieldModel> fieldValues = this.findValueField(field, model.getProperties());
|
|
|
|
|
for (org.opencdmp.commonmodels.models.description.FieldModel fieldValue : fieldValues) {
|
|
|
|
|
if (fieldValue.getTextValue() != null && fieldValue.getTextValue().isBlank()) {
|
|
|
|
|
if (fieldValue.getTextValue() != null && !fieldValue.getTextValue().isBlank()) {
|
|
|
|
|
return fieldValue.getTextValue();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -484,7 +1122,7 @@ public class RdaFileTransformerService implements FileTransformerClient {
|
|
|
|
|
for (FieldModel field : this.templateFieldSearcherService.searchFieldsBySemanticsFlat(model.getDescriptionTemplate(), SEMANTIC_DATASET_SENSITIVE_DATA)) {
|
|
|
|
|
List<org.opencdmp.commonmodels.models.description.FieldModel> fieldValues = this.findValueField(field, model.getProperties());
|
|
|
|
|
for (org.opencdmp.commonmodels.models.description.FieldModel fieldValue : fieldValues) {
|
|
|
|
|
if (fieldValue.getTextValue() != null && fieldValue.getTextValue().isBlank()) {
|
|
|
|
|
if (fieldValue.getTextValue() != null && !fieldValue.getTextValue().isBlank()) {
|
|
|
|
|
try {
|
|
|
|
|
value = Dataset.PersonalData.fromValue(fieldValue.getTextValue());
|
|
|
|
|
} catch (IllegalArgumentException | MyApplicationException e) {
|
|
|
|
@ -503,7 +1141,7 @@ public class RdaFileTransformerService implements FileTransformerClient {
|
|
|
|
|
for (FieldModel field : this.templateFieldSearcherService.searchFieldsBySemanticsFlat(model.getDescriptionTemplate(), SEMANTIC_DATASET_PERSONAL_DATA)) {
|
|
|
|
|
List<org.opencdmp.commonmodels.models.description.FieldModel> fieldValues = this.findValueField(field, model.getProperties());
|
|
|
|
|
for (org.opencdmp.commonmodels.models.description.FieldModel fieldValue : fieldValues) {
|
|
|
|
|
if (fieldValue.getTextValue() != null && fieldValue.getTextValue().isBlank()) {
|
|
|
|
|
if (fieldValue.getTextValue() != null && !fieldValue.getTextValue().isBlank()) {
|
|
|
|
|
try {
|
|
|
|
|
value = Dataset.PersonalData.fromValue(fieldValue.getTextValue());
|
|
|
|
|
} catch (IllegalArgumentException | MyApplicationException e) {
|
|
|
|
@ -522,7 +1160,7 @@ public class RdaFileTransformerService implements FileTransformerClient {
|
|
|
|
|
for (FieldModel field : this.templateFieldSearcherService.searchFieldsBySemanticsFlat(model.getDescriptionTemplate(), SEMANTIC_DATASET_KEYWORD)) {
|
|
|
|
|
List<org.opencdmp.commonmodels.models.description.FieldModel> fieldValues = this.findValueField(field, model.getProperties());
|
|
|
|
|
for (org.opencdmp.commonmodels.models.description.FieldModel fieldValue : fieldValues) {
|
|
|
|
|
if (fieldValue.getTextValue() != null && fieldValue.getTextValue().isBlank()) {
|
|
|
|
|
if (fieldValue.getTextValue() != null && !fieldValue.getTextValue().isBlank()) {
|
|
|
|
|
values.add(fieldValue.getTextValue());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -534,7 +1172,7 @@ public class RdaFileTransformerService implements FileTransformerClient {
|
|
|
|
|
for (FieldModel field : this.templateFieldSearcherService.searchFieldsBySemanticsFlat(model.getDescriptionTemplate(), SEMANTIC_DATASET_ISSUED)) {
|
|
|
|
|
List<org.opencdmp.commonmodels.models.description.FieldModel> fieldValues = this.findValueField(field, model.getProperties());
|
|
|
|
|
for (org.opencdmp.commonmodels.models.description.FieldModel fieldValue : fieldValues) {
|
|
|
|
|
if (fieldValue.getTextValue() != null && fieldValue.getTextValue().isBlank()) {
|
|
|
|
|
if (fieldValue.getTextValue() != null && !fieldValue.getTextValue().isBlank()) {
|
|
|
|
|
return fieldValue.getTextValue();
|
|
|
|
|
} else if (fieldValue.getDateValue() != null){
|
|
|
|
|
return DateTimeFormatter.ISO_DATE.format(fieldValue.getDateValue());
|
|
|
|
@ -549,7 +1187,7 @@ public class RdaFileTransformerService implements FileTransformerClient {
|
|
|
|
|
for (FieldModel field : this.templateFieldSearcherService.searchFieldsBySemanticsFlat(model.getDescriptionTemplate(), SEMANTIC_DATASET_LANGUAGE)) {
|
|
|
|
|
List<org.opencdmp.commonmodels.models.description.FieldModel> fieldValues = this.findValueField(field, model.getProperties());
|
|
|
|
|
for (org.opencdmp.commonmodels.models.description.FieldModel fieldValue : fieldValues) {
|
|
|
|
|
if (fieldValue.getTextValue() != null && fieldValue.getTextValue().isBlank()) {
|
|
|
|
|
if (fieldValue.getTextValue() != null && !fieldValue.getTextValue().isBlank()) {
|
|
|
|
|
try {
|
|
|
|
|
value = Language.fromValue(fieldValue.getTextValue());
|
|
|
|
|
} catch (IllegalArgumentException | MyApplicationException e) {
|
|
|
|
@ -569,7 +1207,7 @@ public class RdaFileTransformerService implements FileTransformerClient {
|
|
|
|
|
for (FieldModel field : this.templateFieldSearcherService.searchFieldsBySemanticsFlat(model.getDescriptionTemplate(), SEMANTIC_DATASET_TYPE)) {
|
|
|
|
|
List<org.opencdmp.commonmodels.models.description.FieldModel> fieldValues = this.findValueField(field, model.getProperties());
|
|
|
|
|
for (org.opencdmp.commonmodels.models.description.FieldModel fieldValue : fieldValues) {
|
|
|
|
|
if (fieldValue.getTextValue() != null && fieldValue.getTextValue().isBlank()) {
|
|
|
|
|
if (fieldValue.getTextValue() != null && !fieldValue.getTextValue().isBlank()) {
|
|
|
|
|
return fieldValue.getTextValue();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|