export changes
This commit is contained in:
parent
9b44da2aea
commit
896d0148a8
|
@ -1,2 +1,3 @@
|
|||
.idea/
|
||||
target/
|
||||
logs/
|
||||
|
|
|
@ -16,17 +16,17 @@ public class LanguageRDAMapper {
|
|||
private final static Map<String, String> langMap = new HashMap<>();
|
||||
|
||||
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(LanguageRDAMapper.class));
|
||||
static {
|
||||
try {
|
||||
ObjectMapper mapper = new ObjectMapper(); //TODO
|
||||
InputStreamReader isr = new InputStreamReader(LanguageRDAMapper.class.getClassLoader().getResource("internal/rda-lang-map.json").openStream(), StandardCharsets.UTF_8);
|
||||
langMap.putAll(mapper.readValue(isr, LinkedHashMap.class));
|
||||
isr.close();
|
||||
|
||||
} catch (IOException e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
// static {
|
||||
// try {
|
||||
// ObjectMapper mapper = new ObjectMapper(); //TODO
|
||||
// InputStreamReader isr = new InputStreamReader(LanguageRDAMapper.class.getClassLoader().getResource("internal/rda-lang-map.json").openStream(), StandardCharsets.UTF_8);
|
||||
// langMap.putAll(mapper.readValue(isr, LinkedHashMap.class));
|
||||
// isr.close();
|
||||
//
|
||||
// } catch (IOException e) {
|
||||
// logger.error(e.getMessage(), e);
|
||||
// }
|
||||
// }
|
||||
|
||||
public Language toRDA(String code) {
|
||||
if (code == null || code.isBlank()) return null;
|
||||
|
|
|
@ -35,6 +35,7 @@ import org.springframework.stereotype.Service;
|
|||
|
||||
import java.net.URI;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.time.ZoneId;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.*;
|
||||
|
||||
|
@ -54,9 +55,9 @@ public class RdaFileTransformerService implements FileTransformerClient {
|
|||
private final static String REPOSITORY_ZENODO = "Zenodo";
|
||||
private final static String PREFIX_ORCID = "orcid";
|
||||
private final static String ORCID_URL = "http://orcid.org/";
|
||||
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_ETHICAL_ISSUES_EXISTS = "rda.dmp.ethical_issues_exist";
|
||||
private static final String SEMANTIC_ETHICAL_ISSUES_DESCRIPTION = "rda.dmp.ethical_issues_description";
|
||||
private static final String SEMANTIC_ETHICAL_ISSUES_REPORT = "rda.dmp.ethical_issues_report";
|
||||
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";
|
||||
|
@ -75,10 +76,12 @@ public class RdaFileTransformerService implements FileTransformerClient {
|
|||
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_METADATA_STANDARD_ID = "rda.dataset.metadata.metadata_standard_id";
|
||||
private static final String SEMANTIC_DATASET_METADATA_STANDARD_ID_IDENTIFIER = "rda.dataset.metadata.metadata_standard_id.identifier";
|
||||
private static final String SEMANTIC_DATASET_METADATA_STANDARD_ID_TYPE = "rda.dataset.metadata.metadata_standard_id.type";
|
||||
private static final String SEMANTIC_DATASET_DATASET_ID = "rda.dataset.dataset_id";
|
||||
private static final String SEMANTIC_DATASET_DATASET_ID_ID = "rda.dataset.dataset_id.identifier";
|
||||
private static final String SEMANTIC_DATASET_DATASET_ID_TYPE = "rda.dataset.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";
|
||||
|
@ -199,6 +202,7 @@ public class RdaFileTransformerService implements FileTransformerClient {
|
|||
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));
|
||||
}
|
||||
|
||||
|
@ -307,7 +311,7 @@ public class RdaFileTransformerService implements FileTransformerClient {
|
|||
|
||||
public Dmp.EthicalIssuesExist buildRdaEthicalIssuesExist(DmpModel model) {
|
||||
if (model == null) throw new MyApplicationException("Dmp is missing");
|
||||
List<org.opencdmp.commonmodels.models.dmpblueprint.FieldModel> fields = this.getFieldsOfSemantic(model, SEMANTIC_ETHICAL_ISSUES);
|
||||
List<org.opencdmp.commonmodels.models.dmpblueprint.FieldModel> fields = this.getFieldsOfSemantic(model, SEMANTIC_ETHICAL_ISSUES_EXISTS);
|
||||
for(org.opencdmp.commonmodels.models.dmpblueprint.FieldModel field : fields) {
|
||||
DmpBlueprintValueModel valueModel = field != null ? this.getDmpBlueprintValue(model, field.getId()) : null;
|
||||
if (valueModel != null && valueModel.getValue() != null && !valueModel.getValue().isBlank()) return Dmp.EthicalIssuesExist.fromValue(valueModel.getValue());
|
||||
|
@ -489,7 +493,7 @@ 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));//TODO: Build By Tags ?
|
||||
rda.setPersonalData(this.buildRdaDatasetPersonalData(model));
|
||||
rda.setSensitiveData(this.buildRdaDatasetSensitiveData(model));
|
||||
rda.setPreservationStatement(this.buildRdaDatasetPreservationStatement(model));
|
||||
|
@ -528,8 +532,9 @@ public class RdaFileTransformerService implements FileTransformerClient {
|
|||
return values;
|
||||
}
|
||||
|
||||
|
||||
private void mergeEthicalIssues(DescriptionModel model, Dmp dmpRda){
|
||||
for (FieldModel field : this.templateFieldSearcherService.searchFieldsBySemanticsFlat(model.getDescriptionTemplate(), SEMANTIC_ETHICAL_ISSUES)) {
|
||||
for (FieldModel field : this.templateFieldSearcherService.searchFieldsBySemanticsFlat(model.getDescriptionTemplate(), SEMANTIC_ETHICAL_ISSUES_EXISTS)) {
|
||||
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()) {
|
||||
|
@ -542,40 +547,31 @@ public class RdaFileTransformerService implements FileTransformerClient {
|
|||
}
|
||||
}
|
||||
}
|
||||
for (FieldSetModel fieldSet : this.templateFieldSearcherService.searchFieldSetsBySemantics(model.getDescriptionTemplate(), List.of(SEMANTIC_ETHICAL_ISSUES, SEMANTIC_ETHICAL_ISSUES_DESCRIPTION, SEMANTIC_ETHICAL_ISSUES_REPORT))) {
|
||||
for (FieldSetModel fieldSet : this.templateFieldSearcherService.searchFieldSetsBySemantics(model.getDescriptionTemplate(), List.of(SEMANTIC_ETHICAL_ISSUES_EXISTS, SEMANTIC_ETHICAL_ISSUES_DESCRIPTION, SEMANTIC_ETHICAL_ISSUES_REPORT))) {
|
||||
List<org.opencdmp.commonmodels.models.description.PropertyDefinitionFieldSetItemModel> propertyDefinitionFieldSetItemModels = this.findFieldSetValue(fieldSet, model.getProperties());
|
||||
for (org.opencdmp.commonmodels.models.description.PropertyDefinitionFieldSetItemModel propertyDefinitionFieldSetItemModel : propertyDefinitionFieldSetItemModels) {
|
||||
|
||||
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()) {
|
||||
org.opencdmp.commonmodels.models.description.FieldModel fieldValue = this.findValueFieldBySemantic(fieldSet, propertyDefinitionFieldSetItemModel, SEMANTIC_ETHICAL_ISSUES_EXISTS);
|
||||
if (fieldValue != null && 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);
|
||||
}
|
||||
}
|
||||
} 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()) {
|
||||
fieldValue = this.findValueFieldBySemantic(fieldSet, propertyDefinitionFieldSetItemModel, SEMANTIC_ETHICAL_ISSUES_DESCRIPTION);
|
||||
if (fieldValue != null && 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()) {
|
||||
fieldValue = this.findValueFieldBySemantic(fieldSet, propertyDefinitionFieldSetItemModel, SEMANTIC_ETHICAL_ISSUES_REPORT);
|
||||
if (fieldValue != null && fieldValue.getTextValue() != null && !fieldValue.getTextValue().isBlank()) {
|
||||
try {
|
||||
dmpRda.setEthicalIssuesReport(URI.create(fieldValue.getTextValue()));
|
||||
break;
|
||||
} catch (Exception ex){
|
||||
} catch (Exception ex) {
|
||||
logger.error(ex.getMessage(), ex);
|
||||
}
|
||||
}
|
||||
|
@ -587,57 +583,46 @@ public class RdaFileTransformerService implements FileTransformerClient {
|
|||
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))) {
|
||||
List<org.opencdmp.commonmodels.models.description.PropertyDefinitionFieldSetItemModel> propertyDefinitionFieldSetItemModels = this.findFieldSetValue(fieldSet, model.getProperties());
|
||||
for (org.opencdmp.commonmodels.models.description.PropertyDefinitionFieldSetItemModel propertyDefinitionFieldSetItemModel : propertyDefinitionFieldSetItemModels) {
|
||||
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()) {
|
||||
org.opencdmp.commonmodels.models.description.FieldModel fieldValue = this.findValueFieldBySemantic(fieldSet, propertyDefinitionFieldSetItemModel, SEMANTIC_COST_CURRENCY_CODE);
|
||||
if (fieldValue != null && fieldValue.getTextValue() != null && !fieldValue.getTextValue().isBlank()) {
|
||||
try {
|
||||
item.setCurrencyCode(Cost.CurrencyCode.fromValue(fieldValue.getTextValue()));
|
||||
valueFound = true;
|
||||
} 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()) {
|
||||
fieldValue = this.findValueFieldBySemantic(fieldSet, propertyDefinitionFieldSetItemModel, SEMANTIC_COST_DESCRIPTION);
|
||||
if (fieldValue != null && 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()) {
|
||||
fieldValue = this.findValueFieldBySemantic(fieldSet, propertyDefinitionFieldSetItemModel, SEMANTIC_COST_TITLE);
|
||||
if (fieldValue != null && 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()) {
|
||||
fieldValue = this.findValueFieldBySemantic(fieldSet, propertyDefinitionFieldSetItemModel, SEMANTIC_COST_VALUE);
|
||||
if (fieldValue != null && fieldValue.getTextValue() != null && !fieldValue.getTextValue().isBlank()) {
|
||||
try {
|
||||
item.setValue(Double.valueOf(fieldValue.getTextValue()));
|
||||
valueFound = true;
|
||||
break;
|
||||
} catch (Exception ex){
|
||||
} catch (Exception ex) {
|
||||
logger.error(ex.getMessage(), ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (valueFound) values.add(item);
|
||||
}
|
||||
}
|
||||
return values;
|
||||
}
|
||||
|
||||
|
@ -647,121 +632,72 @@ public class RdaFileTransformerService implements FileTransformerClient {
|
|||
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))) {
|
||||
List<org.opencdmp.commonmodels.models.description.PropertyDefinitionFieldSetItemModel> propertyDefinitionFieldSetItemModels = this.findFieldSetValue(fieldSet, model.getProperties());
|
||||
for (org.opencdmp.commonmodels.models.description.PropertyDefinitionFieldSetItemModel propertyDefinitionFieldSetItemModel : propertyDefinitionFieldSetItemModels) {
|
||||
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()) {
|
||||
org.opencdmp.commonmodels.models.description.FieldModel fieldValue = this.findValueFieldBySemantic(fieldSet, propertyDefinitionFieldSetItemModel, SEMANTIC_DATASET_DISTRIBUTION_TITLE);
|
||||
if (fieldValue != null && 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());
|
||||
fieldValue = this.findValueFieldBySemantic(fieldSet, propertyDefinitionFieldSetItemModel, SEMANTIC_DATASET_DISTRIBUTION_FORMAT);
|
||||
if (fieldValue != null && fieldValue.getTextValue() != null && !fieldValue.getTextValue().isBlank()) { //TODO: multiple
|
||||
item.setFormat(List.of(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()) {
|
||||
fieldValue = this.findValueFieldBySemantic(fieldSet, propertyDefinitionFieldSetItemModel, SEMANTIC_DATASET_DISTRIBUTION_DOWNLOAD_URL);
|
||||
if (fieldValue != null && fieldValue.getTextValue() != null && !fieldValue.getTextValue().isBlank()) {
|
||||
try {
|
||||
item.setDownloadUrl(URI.create(fieldValue.getTextValue()));
|
||||
valueFound = true;
|
||||
break;
|
||||
} catch (Exception ex){
|
||||
logger.error(ex.getMessage(), ex);
|
||||
}
|
||||
}
|
||||
} 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()) {
|
||||
fieldValue = this.findValueFieldBySemantic(fieldSet, propertyDefinitionFieldSetItemModel, SEMANTIC_DATASET_DISTRIBUTION_DESCRIPTION);
|
||||
if (fieldValue != null && 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()) {
|
||||
fieldValue = this.findValueFieldBySemantic(fieldSet, propertyDefinitionFieldSetItemModel, SEMANTIC_DATASET_DISTRIBUTION_DATA_ACCESS);
|
||||
if (fieldValue != null && 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);
|
||||
}
|
||||
}
|
||||
} 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()) {
|
||||
fieldValue = this.findValueFieldBySemantic(fieldSet, propertyDefinitionFieldSetItemModel, SEMANTIC_DATASET_DISTRIBUTION_BYTE_SIZE);
|
||||
if (fieldValue != null && fieldValue.getTextValue() != null && !fieldValue.getTextValue().isBlank()) {
|
||||
try {
|
||||
item.setByteSize(Integer.valueOf(fieldValue.getTextValue()));
|
||||
valueFound = true;
|
||||
break;
|
||||
} catch (Exception ex){
|
||||
logger.error(ex.getMessage(), ex);
|
||||
}
|
||||
}
|
||||
} 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()) {
|
||||
fieldValue = this.findValueFieldBySemantic(fieldSet, propertyDefinitionFieldSetItemModel, SEMANTIC_DATASET_DISTRIBUTION_AVAILABLE_UTIL);
|
||||
if (fieldValue != null && fieldValue.getDateValue() != null) {
|
||||
item.setAvailableUntil(DateTimeFormatter.ISO_DATE.withZone(ZoneId.systemDefault()).format(fieldValue.getDateValue()));
|
||||
valueFound = true;
|
||||
} else if (fieldValue != null && 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()) {
|
||||
fieldValue = this.findValueFieldBySemantic(fieldSet, propertyDefinitionFieldSetItemModel, SEMANTIC_DATASET_DISTRIBUTION_ACCESS_URL);
|
||||
if (fieldValue != null && 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()) {
|
||||
fieldValue = this.findValueFieldBySemantic(fieldSet, propertyDefinitionFieldSetItemModel, SEMANTIC_DATASET_DISTRIBUTION_ACCESS_URL);
|
||||
if (fieldValue != null && fieldValue.getReferences() != null && !fieldValue.getReferences().isEmpty()) {
|
||||
item.setLicense(new ArrayList<>());
|
||||
for (ReferenceModel referenceModel : fieldValue.getReferences()){
|
||||
for (ReferenceModel referenceModel : fieldValue.getReferences()) {
|
||||
if (referenceModel.getDefinition() != null && referenceModel.getDefinition().getFields() != null) {
|
||||
try {
|
||||
License license = new License();
|
||||
|
@ -771,168 +707,116 @@ public class RdaFileTransformerService implements FileTransformerClient {
|
|||
if (refValue != null && !refValue.isBlank()) license.setStartDate(startDateValue);
|
||||
|
||||
item.getLicense().add(license);
|
||||
} catch (Exception ex){
|
||||
} catch (Exception ex) {
|
||||
logger.error(ex.getMessage(), ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!item.getLicense().isEmpty()) valueFound = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (valueFound) {
|
||||
item.setHost(this.buildRdaDistributionHost(model, fieldSet));
|
||||
item.setHost(this.buildRdaDistributionHost(propertyDefinitionFieldSetItemModel, fieldSet));
|
||||
values.add(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
return values.isEmpty() ? null : values;
|
||||
}
|
||||
|
||||
private Host buildRdaDistributionHost(DescriptionModel model, FieldSetModel fieldSet) {
|
||||
private Host buildRdaDistributionHost(org.opencdmp.commonmodels.models.description.PropertyDefinitionFieldSetItemModel propertyDefinitionFieldSetItemModel, 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()) {
|
||||
org.opencdmp.commonmodels.models.description.FieldModel fieldValue = this.findValueFieldBySemantic(fieldSet, propertyDefinitionFieldSetItemModel, SEMANTIC_DATASET_DISTRIBUTION_HOST_TITLE);
|
||||
if (fieldValue != null && 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()) {
|
||||
fieldValue = this.findValueFieldBySemantic(fieldSet, propertyDefinitionFieldSetItemModel, SEMANTIC_DATASET_DISTRIBUTION_HOST_URL);
|
||||
if (fieldValue != null && fieldValue.getTextValue() != null && !fieldValue.getTextValue().isBlank()) {
|
||||
try {
|
||||
item.setUrl(URI.create(fieldValue.getTextValue()));
|
||||
valueFound = true;
|
||||
break;
|
||||
} catch (Exception ex) {
|
||||
logger.error(ex.getMessage(), ex);
|
||||
}
|
||||
}
|
||||
} 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()) {
|
||||
fieldValue = this.findValueFieldBySemantic(fieldSet, propertyDefinitionFieldSetItemModel, SEMANTIC_DATASET_DISTRIBUTION_HOST_DESCRIPTION);
|
||||
if (fieldValue != null && 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()) {
|
||||
fieldValue = this.findValueFieldBySemantic(fieldSet, propertyDefinitionFieldSetItemModel, SEMANTIC_DATASET_DISTRIBUTION_HOST_STORAGE_TYPE);
|
||||
if (fieldValue != null && 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()) {
|
||||
fieldValue = this.findValueFieldBySemantic(fieldSet, propertyDefinitionFieldSetItemModel, SEMANTIC_DATASET_DISTRIBUTION_HOST_BACKUP_TYPE);
|
||||
if (fieldValue != null && 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()) {
|
||||
fieldValue = this.findValueFieldBySemantic(fieldSet, propertyDefinitionFieldSetItemModel, SEMANTIC_DATASET_DISTRIBUTION_HOST_AVAILABILITY);
|
||||
if (fieldValue != null && 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()) {
|
||||
fieldValue = this.findValueFieldBySemantic(fieldSet, propertyDefinitionFieldSetItemModel, SEMANTIC_DATASET_DISTRIBUTION_HOST_BACKUP_FREQUENCY);
|
||||
if (fieldValue != null && 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()) {
|
||||
fieldValue = this.findValueFieldBySemantic(fieldSet, propertyDefinitionFieldSetItemModel, SEMANTIC_DATASET_DISTRIBUTION_HOST_GEO_LOCATION);
|
||||
if (fieldValue != null && 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);
|
||||
}
|
||||
}
|
||||
} 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()) {
|
||||
fieldValue = this.findValueFieldBySemantic(fieldSet, propertyDefinitionFieldSetItemModel, SEMANTIC_DATASET_DISTRIBUTION_HOST_SUPPORT_VERSIONING);
|
||||
if (fieldValue != null && 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()) {
|
||||
fieldValue = this.findValueFieldBySemantic(fieldSet, propertyDefinitionFieldSetItemModel, SEMANTIC_DATASET_DISTRIBUTION_HOST_CERTIFIED_WITH);
|
||||
if (fieldValue != null && 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()) {
|
||||
fieldValue = this.findValueFieldBySemantic(fieldSet, propertyDefinitionFieldSetItemModel, SEMANTIC_DATASET_DISTRIBUTION_HOST_PID_SYSTEM);
|
||||
if (fieldValue != null && 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()) {
|
||||
if (fieldValue != null && fieldValue.getTextListValue() != null && !fieldValue.getTextListValue().isEmpty()) {
|
||||
for (String itm : fieldValue.getTextListValue()) {
|
||||
try {
|
||||
item.getPidSystem().add(PidSystem.fromValue(fieldValue.getTextValue()));
|
||||
|
||||
item.getPidSystem().add(PidSystem.fromValue(itm));
|
||||
valueFound = true;
|
||||
} catch (Exception ex) {
|
||||
logger.error(ex.getMessage(), ex);
|
||||
}
|
||||
valueFound = true;
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
logger.error(ex.getMessage(), ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -948,6 +832,7 @@ public class RdaFileTransformerService implements FileTransformerClient {
|
|||
if (fieldValue.getTextValue() != null && !fieldValue.getTextValue().isBlank()) {
|
||||
values.add(fieldValue.getTextValue());
|
||||
}
|
||||
if (fieldValue.getTextListValue() != null && !fieldValue.getTextListValue().isEmpty()) values.addAll(fieldValue.getTextListValue());
|
||||
}
|
||||
}
|
||||
return values;
|
||||
|
@ -968,141 +853,181 @@ public class RdaFileTransformerService implements FileTransformerClient {
|
|||
}
|
||||
|
||||
for (FieldSetModel fieldSet : this.templateFieldSearcherService.searchFieldSetsBySemantics(model.getDescriptionTemplate(), List.of(SEMANTIC_DATASET_DATASET_ID_ID, SEMANTIC_DATASET_DATASET_ID_TYPE))) {
|
||||
List<org.opencdmp.commonmodels.models.description.PropertyDefinitionFieldSetItemModel> propertyDefinitionFieldSetItemModels = this.findFieldSetValue(fieldSet, model.getProperties());
|
||||
for (org.opencdmp.commonmodels.models.description.PropertyDefinitionFieldSetItemModel propertyDefinitionFieldSetItemModel : propertyDefinitionFieldSetItemModels) {
|
||||
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()) {
|
||||
org.opencdmp.commonmodels.models.description.FieldModel fieldValue = this.findValueFieldBySemantic(fieldSet, propertyDefinitionFieldSetItemModel, SEMANTIC_DATASET_DATASET_ID_ID);
|
||||
if (fieldValue != null && 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()) {
|
||||
fieldValue = this.findValueFieldBySemantic(fieldSet, propertyDefinitionFieldSetItemModel, SEMANTIC_DATASET_DATASET_ID_TYPE);
|
||||
if (fieldValue != null && fieldValue.getTextValue() != null && !fieldValue.getTextValue().isBlank()) {
|
||||
try {
|
||||
datasetId.setType(DatasetId.Type.fromValue(fieldValue.getTextValue()));
|
||||
valueFound = true;
|
||||
break;
|
||||
} catch (Exception ex){
|
||||
logger.error(ex.getMessage(), ex);
|
||||
}
|
||||
}
|
||||
if (fieldValue != null && fieldValue.getTextListValue() != null && !fieldValue.getTextListValue().isEmpty()) {
|
||||
for (String val : fieldValue.getTextListValue()) {
|
||||
try {
|
||||
datasetId.setType(DatasetId.Type.fromValue(val));
|
||||
valueFound = true;
|
||||
} catch (Exception ex) {
|
||||
logger.error(ex.getMessage(), ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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))) {
|
||||
for (FieldSetModel fieldSet : this.templateFieldSearcherService.searchFieldSetsBySemantics(model.getDescriptionTemplate(), List.of(SEMANTIC_DATASET_METADATA_DESCRIPTION, SEMANTIC_DATASET_METADATA_LANGUAGE, SEMANTIC_DATASET_METADATA_STANDARD_ID, SEMANTIC_DATASET_METADATA_STANDARD_ID_IDENTIFIER, SEMANTIC_DATASET_METADATA_STANDARD_ID_TYPE))) {
|
||||
List<org.opencdmp.commonmodels.models.description.PropertyDefinitionFieldSetItemModel> propertyDefinitionFieldSetItemModels = this.findFieldSetValue(fieldSet, model.getProperties());
|
||||
for (org.opencdmp.commonmodels.models.description.PropertyDefinitionFieldSetItemModel propertyDefinitionFieldSetItemModel : propertyDefinitionFieldSetItemModels) {
|
||||
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()) {
|
||||
org.opencdmp.commonmodels.models.description.FieldModel fieldValue = this.findValueFieldBySemantic(fieldSet, propertyDefinitionFieldSetItemModel, SEMANTIC_DATASET_METADATA_LANGUAGE);
|
||||
if (fieldValue != null && fieldValue.getTextValue() != null && !fieldValue.getTextValue().isBlank()) {
|
||||
try {
|
||||
item.setLanguage(Metadatum.Language.fromValue(fieldValue.getTextValue()));
|
||||
valueFound = true;
|
||||
break;
|
||||
} catch (Exception e){
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
if (fieldValue != null && fieldValue.getTextListValue() != null && !fieldValue.getTextListValue().isEmpty()) {
|
||||
for (String val : fieldValue.getTextListValue()) {
|
||||
try {
|
||||
item.setLanguage(Metadatum.Language.fromValue(val));
|
||||
valueFound = true;
|
||||
} 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()) {
|
||||
|
||||
fieldValue = this.findValueFieldBySemantic(fieldSet, propertyDefinitionFieldSetItemModel, SEMANTIC_DATASET_METADATA_DESCRIPTION);
|
||||
if (fieldValue != null && 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);
|
||||
MetadataStandardId standardId = this.buildRdaMetadataStandardId(propertyDefinitionFieldSetItemModel, fieldSet);
|
||||
if (standardId != null) {
|
||||
item.setMetadataStandardId(standardId);
|
||||
valueFound = true;
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (valueFound) values.add(item);
|
||||
}
|
||||
}
|
||||
return values.isEmpty() ? null : values;
|
||||
}
|
||||
|
||||
private List<SecurityAndPrivacy> buildRdaDatasetSecurityAndPrivacy(DescriptionModel model){
|
||||
private MetadataStandardId buildRdaMetadataStandardId(org.opencdmp.commonmodels.models.description.PropertyDefinitionFieldSetItemModel propertyDefinitionFieldSetItemModel, FieldSetModel fieldSet){
|
||||
boolean valueFound = false;
|
||||
MetadataStandardId standardId = new MetadataStandardId();
|
||||
standardId.setType(MetadataStandardId.Type.OTHER);
|
||||
|
||||
org.opencdmp.commonmodels.models.description.FieldModel fieldValue = this.findValueFieldBySemantic(fieldSet, propertyDefinitionFieldSetItemModel, SEMANTIC_DATASET_METADATA_STANDARD_ID);
|
||||
if (fieldValue != null && fieldValue.getTextValue() != null && !fieldValue.getTextValue().isBlank()) {
|
||||
standardId.setIdentifier(fieldValue.getTextValue());
|
||||
return standardId;
|
||||
}
|
||||
|
||||
fieldValue = this.findValueFieldBySemantic(fieldSet, propertyDefinitionFieldSetItemModel, SEMANTIC_DATASET_METADATA_STANDARD_ID_IDENTIFIER);
|
||||
if (fieldValue != null && fieldValue.getTextValue() != null && !fieldValue.getTextValue().isBlank()) {
|
||||
standardId.setIdentifier(fieldValue.getTextValue());
|
||||
valueFound = true;
|
||||
}
|
||||
|
||||
fieldValue = this.findValueFieldBySemantic(fieldSet, propertyDefinitionFieldSetItemModel, SEMANTIC_DATASET_METADATA_STANDARD_ID_TYPE);
|
||||
if (fieldValue != null && fieldValue.getTextValue() != null && !fieldValue.getTextValue().isBlank()) {
|
||||
try {
|
||||
standardId.setType(MetadataStandardId.Type.fromValue(fieldValue.getTextValue()));
|
||||
} catch (Exception ex){
|
||||
logger.error(ex.getMessage(), ex);
|
||||
}
|
||||
}
|
||||
if (fieldValue != null && fieldValue.getTextListValue() != null && !fieldValue.getTextListValue().isEmpty()) {
|
||||
for (String val : fieldValue.getTextListValue()) {
|
||||
try {
|
||||
standardId.setType(MetadataStandardId.Type.fromValue(val));
|
||||
} catch (Exception ex) {
|
||||
logger.error(ex.getMessage(), ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (valueFound) return standardId;
|
||||
return null;
|
||||
}
|
||||
|
||||
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))) {
|
||||
List<org.opencdmp.commonmodels.models.description.PropertyDefinitionFieldSetItemModel> propertyDefinitionFieldSetItemModels = this.findFieldSetValue(fieldSet, model.getProperties());
|
||||
for (org.opencdmp.commonmodels.models.description.PropertyDefinitionFieldSetItemModel propertyDefinitionFieldSetItemModel : propertyDefinitionFieldSetItemModels) {
|
||||
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()) {
|
||||
org.opencdmp.commonmodels.models.description.FieldModel fieldValue = this.findValueFieldBySemantic(fieldSet, propertyDefinitionFieldSetItemModel, SEMANTIC_DATASET_SECURITY_AND_PRIVACY_TITLE);
|
||||
if (fieldValue != null && 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()) {
|
||||
fieldValue = this.findValueFieldBySemantic(fieldSet, propertyDefinitionFieldSetItemModel, SEMANTIC_DATASET_SECURITY_AND_PRIVACY_DESCRIPTION);
|
||||
if (fieldValue != null && 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){
|
||||
|
||||
|
||||
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))) {
|
||||
List<org.opencdmp.commonmodels.models.description.PropertyDefinitionFieldSetItemModel> propertyDefinitionFieldSetItemModels = this.findFieldSetValue(fieldSet, model.getProperties());
|
||||
for (org.opencdmp.commonmodels.models.description.PropertyDefinitionFieldSetItemModel propertyDefinitionFieldSetItemModel : propertyDefinitionFieldSetItemModels) {
|
||||
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()) {
|
||||
org.opencdmp.commonmodels.models.description.FieldModel fieldValue = this.findValueFieldBySemantic(fieldSet, propertyDefinitionFieldSetItemModel, SEMANTIC_DATASET_TECHNICAL_RESOURCE_NAME);
|
||||
if (fieldValue != null && 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()) {
|
||||
fieldValue = this.findValueFieldBySemantic(fieldSet, propertyDefinitionFieldSetItemModel, SEMANTIC_DATASET_TECHNICAL_RESOURCE_DESCRIPTION);
|
||||
if (fieldValue != null && 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){
|
||||
|
@ -1118,20 +1043,29 @@ public class RdaFileTransformerService implements FileTransformerClient {
|
|||
}
|
||||
|
||||
private Dataset.SensitiveData buildRdaDatasetSensitiveData(DescriptionModel model){
|
||||
Dataset.PersonalData value = null;
|
||||
Dataset.SensitiveData value = null;
|
||||
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()) {
|
||||
try {
|
||||
value = Dataset.PersonalData.fromValue(fieldValue.getTextValue());
|
||||
value = Dataset.SensitiveData.fromValue(fieldValue.getTextValue());
|
||||
return value;
|
||||
} catch (IllegalArgumentException | MyApplicationException e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
if (value != null) break;
|
||||
if (fieldValue.getTextListValue() != null && !fieldValue.getTextListValue().isEmpty()) {
|
||||
for (String val : fieldValue.getTextListValue()) {
|
||||
try {
|
||||
value = Dataset.SensitiveData.fromValue(val);
|
||||
return value;
|
||||
} catch (IllegalArgumentException | MyApplicationException e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (value != null) break;
|
||||
}
|
||||
return Dataset.SensitiveData.UNKNOWN;
|
||||
}
|
||||
|
@ -1144,13 +1078,22 @@ public class RdaFileTransformerService implements FileTransformerClient {
|
|||
if (fieldValue.getTextValue() != null && !fieldValue.getTextValue().isBlank()) {
|
||||
try {
|
||||
value = Dataset.PersonalData.fromValue(fieldValue.getTextValue());
|
||||
return value;
|
||||
} catch (IllegalArgumentException | MyApplicationException e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
if (value != null) break;
|
||||
if (fieldValue.getTextListValue() != null && !fieldValue.getTextListValue().isEmpty()) {
|
||||
for (String val : fieldValue.getTextListValue()) {
|
||||
try {
|
||||
value = Dataset.PersonalData.fromValue(val);
|
||||
return value;
|
||||
} catch (IllegalArgumentException | MyApplicationException e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (value != null) break;
|
||||
}
|
||||
return Dataset.PersonalData.UNKNOWN;
|
||||
}
|
||||
|
@ -1163,6 +1106,9 @@ public class RdaFileTransformerService implements FileTransformerClient {
|
|||
if (fieldValue.getTextValue() != null && !fieldValue.getTextValue().isBlank()) {
|
||||
values.add(fieldValue.getTextValue());
|
||||
}
|
||||
if (fieldValue.getTextListValue() != null && !fieldValue.getTextListValue().isEmpty()) {
|
||||
values.addAll(fieldValue.getTextListValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
return values;
|
||||
|
@ -1172,10 +1118,10 @@ 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.getDateValue() != null){
|
||||
return DateTimeFormatter.ISO_DATE.withZone(ZoneId.systemDefault()).format(fieldValue.getDateValue());
|
||||
} else if (fieldValue.getTextValue() != null && !fieldValue.getTextValue().isBlank()) {
|
||||
return fieldValue.getTextValue();
|
||||
} else if (fieldValue.getDateValue() != null){
|
||||
return DateTimeFormatter.ISO_DATE.format(fieldValue.getDateValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1190,17 +1136,24 @@ public class RdaFileTransformerService implements FileTransformerClient {
|
|||
if (fieldValue.getTextValue() != null && !fieldValue.getTextValue().isBlank()) {
|
||||
try {
|
||||
value = Language.fromValue(fieldValue.getTextValue());
|
||||
return value;
|
||||
} catch (IllegalArgumentException | MyApplicationException e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
logger.warn("Language " + fieldValue.getTextValue() + " from semantic rda.dataset.language was not found.");
|
||||
}
|
||||
}
|
||||
if (value != null) break;
|
||||
}
|
||||
if (value != null) break;
|
||||
}
|
||||
if (value == null) value = buildRdaLanguage(model.getDescriptionTemplate().getLanguage());
|
||||
if (fieldValue.getTextListValue() != null && !fieldValue.getTextListValue().isEmpty()) {
|
||||
for (String val : fieldValue.getTextListValue()) {
|
||||
try {
|
||||
value = Language.fromValue(val);
|
||||
return value;
|
||||
} catch (IllegalArgumentException | MyApplicationException e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return buildRdaLanguage(model.getDescriptionTemplate().getLanguage());
|
||||
}
|
||||
|
||||
private String buildRdaDatasetType(DescriptionModel model){
|
||||
|
@ -1210,6 +1163,10 @@ public class RdaFileTransformerService implements FileTransformerClient {
|
|||
if (fieldValue.getTextValue() != null && !fieldValue.getTextValue().isBlank()) {
|
||||
return fieldValue.getTextValue();
|
||||
}
|
||||
|
||||
if (fieldValue.getTextListValue() != null && !fieldValue.getTextListValue().isEmpty()) {
|
||||
return fieldValue.getTextListValue().getFirst();
|
||||
}
|
||||
}
|
||||
}
|
||||
return "DMP Dataset";
|
||||
|
@ -1217,7 +1174,7 @@ public class RdaFileTransformerService implements FileTransformerClient {
|
|||
|
||||
private List<org.opencdmp.commonmodels.models.description.FieldModel> findValueField(FieldModel fieldModel, PropertyDefinitionModel descriptionTemplateModel){
|
||||
List<org.opencdmp.commonmodels.models.description.FieldModel> items = new ArrayList<>();
|
||||
if (descriptionTemplateModel == null || descriptionTemplateModel.getFieldSets() == null) return items;
|
||||
if (fieldModel == null || descriptionTemplateModel == null || descriptionTemplateModel.getFieldSets() == null) return items;
|
||||
for (PropertyDefinitionFieldSetModel propertyDefinitionFieldSetModel : descriptionTemplateModel.getFieldSets().values()){
|
||||
if (propertyDefinitionFieldSetModel.getItems() == null) continue;
|
||||
for (PropertyDefinitionFieldSetItemModel propertyDefinitionFieldSetItemModel : propertyDefinitionFieldSetModel.getItems()){
|
||||
|
@ -1229,6 +1186,18 @@ public class RdaFileTransformerService implements FileTransformerClient {
|
|||
return items;
|
||||
}
|
||||
|
||||
private List<org.opencdmp.commonmodels.models.description.PropertyDefinitionFieldSetItemModel> findFieldSetValue(FieldSetModel fieldSetModel, PropertyDefinitionModel descriptionTemplateModel){
|
||||
List<org.opencdmp.commonmodels.models.description.PropertyDefinitionFieldSetItemModel> items = new ArrayList<>();
|
||||
if (fieldSetModel == null || descriptionTemplateModel == null || descriptionTemplateModel.getFieldSets() == null) return items;
|
||||
PropertyDefinitionFieldSetModel propertyDefinitionFieldSetModel = descriptionTemplateModel.getFieldSets().getOrDefault(fieldSetModel.getId(), null);
|
||||
if (propertyDefinitionFieldSetModel != null && propertyDefinitionFieldSetModel.getItems() != null) return propertyDefinitionFieldSetModel.getItems();
|
||||
return items;
|
||||
}
|
||||
|
||||
private org.opencdmp.commonmodels.models.description.FieldModel findValueFieldBySemantic(FieldSetModel fieldSet, org.opencdmp.commonmodels.models.description.PropertyDefinitionFieldSetItemModel propertyDefinitionFieldSetItemModel, String semantic){
|
||||
FieldModel field = this.templateFieldSearcherService.findFieldBySemantic(fieldSet, semantic);
|
||||
return field != null ? propertyDefinitionFieldSetItemModel.getFields().getOrDefault(field.getId(), null) : null;
|
||||
}
|
||||
//endregion
|
||||
|
||||
//endregion
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
rda-file-transformer:
|
||||
useSharedStorage: true
|
||||
useSharedStorage: false
|
||||
|
|
Loading…
Reference in New Issue