Merge remote-tracking branch 'origin/dmp-refactor-desc-templates' into dmp-refactoring

This commit is contained in:
George Kalampokis 2024-02-06 16:18:58 +02:00
commit a22644be56
5 changed files with 66 additions and 32 deletions

View File

@ -47,7 +47,7 @@
<dependency> <dependency>
<groupId>gr.cite.opendmp</groupId> <groupId>gr.cite.opendmp</groupId>
<artifactId>file-transformer-base</artifactId> <artifactId>file-transformer-base</artifactId>
<version>0.0.3</version> <version>1.0.0-SNAPSHOT</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>gr.cite</groupId> <groupId>gr.cite</groupId>

View File

@ -98,8 +98,12 @@ public class DescriptionTemplateDefinitionFileTransformerBuilder extends BaseFil
m.setExtendedDescription(d.getExtendedDescription()); m.setExtendedDescription(d.getExtendedDescription());
m.setMultiplicity(d.getMultiplicity()); m.setMultiplicity(d.getMultiplicity());
m.setNumbering(d.getNumbering()); m.setNumbering(d.getNumbering());
if (d.getSections() != null && !d.getSections().isEmpty()) {
m.setSections(collectSections(d.getSections())); m.setSections(collectSections(d.getSections()));
}
if (d.getFieldSets() != null && !d.getFieldSets().isEmpty()) {
m.setFieldSets(collectFieldSet(d.getFieldSets())); m.setFieldSets(collectFieldSet(d.getFieldSets()));
}
result.add(m); result.add(m);
} }
return result; return result;
@ -135,7 +139,9 @@ public class DescriptionTemplateDefinitionFileTransformerBuilder extends BaseFil
m.setDefaultValue(d.getDefaultValue()); m.setDefaultValue(d.getDefaultValue());
m.setIncludeInExport(d.getIncludeInExport()); m.setIncludeInExport(d.getIncludeInExport());
m.setValidations(d.getValidations().stream().map(fieldValidationType -> FieldValidationType.of(fieldValidationType.getValue())).toList()); m.setValidations(d.getValidations().stream().map(fieldValidationType -> FieldValidationType.of(fieldValidationType.getValue())).toList());
if (d.getVisibilityRules() != null && !d.getVisibilityRules().isEmpty()) {
m.setVisibilityRules(convertVisibilityRules(d.getVisibilityRules())); m.setVisibilityRules(convertVisibilityRules(d.getVisibilityRules()));
}
m.setData(convertData(d.getData())); m.setData(convertData(d.getData()));
result.add(m); result.add(m);
} }
@ -157,11 +163,11 @@ public class DescriptionTemplateDefinitionFileTransformerBuilder extends BaseFil
BaseFieldDataFileTransformerModel m; BaseFieldDataFileTransformerModel m;
switch (data) { switch (data) {
case ExternalSelectDataEntity d -> { case ExternalSelectDataEntity d -> {
m = new AutoCompleteDataFileTransformerModel(); m = new ExternalSelectDataFileTransformerModel();
m.setLabel(d.getLabel()); m.setLabel(d.getLabel());
m.setFieldType(FieldType.of(d.getFieldType().getValue())); m.setFieldType(FieldType.of(d.getFieldType().getValue()));
((AutoCompleteDataFileTransformerModel)m).setMultiAutoComplete(d.getMultipleSelect()); ((ExternalSelectDataFileTransformerModel)m).setMultipleSelect(d.getMultipleSelect());
((AutoCompleteDataFileTransformerModel) m).setAutoCompleteSingleDataList(convertAutoCompleteSingleData(d.getSources())); ((ExternalSelectDataFileTransformerModel) m).setSources(convertAutoCompleteSingleData(d.getSources()));
} }
case ExternalDatasetDataEntity d -> { case ExternalDatasetDataEntity d -> {
m = new ExternalDatasetDataFileTransformerModel(); m = new ExternalDatasetDataFileTransformerModel();
@ -183,21 +189,31 @@ public class DescriptionTemplateDefinitionFileTransformerBuilder extends BaseFil
((UploadDataFileTransformerModel) m).setTypes(convertUploadDataOptions(d.getTypes())); ((UploadDataFileTransformerModel) m).setTypes(convertUploadDataOptions(d.getTypes()));
} }
case SelectDataEntity d -> { case SelectDataEntity d -> {
m = new WordListDataFileTransformerModel(); m = new SelectDataFileTransformerModel();
m.setLabel(d.getLabel()); m.setLabel(d.getLabel());
m.setFieldType(FieldType.of(d.getFieldType().getValue())); m.setFieldType(FieldType.of(d.getFieldType().getValue()));
((WordListDataFileTransformerModel) m).setMultiList(d.getMultipleSelect()); ((SelectDataFileTransformerModel) m).setMultipleSelect(d.getMultipleSelect());
((WordListDataFileTransformerModel) m).setOptions(d.getOptions().stream().map(this::convertComboBoxOption).toList()); ((SelectDataFileTransformerModel) m).setOptions(d.getOptions().stream().map(this::convertComboBoxOption).toList());
}
case LabelAndMultiplicityDataEntity d -> {
m = new LabelAndMultiplicityDataFileTransformerModel();
m.setLabel(d.getLabel());
m.setFieldType(FieldType.of(d.getFieldType().getValue()));
((LabelAndMultiplicityDataFileTransformerModel)m).setMultipleSelect(d.getMultipleSelect());
}
default -> {
m = new LabelDataFileTransformerModel();
m.setLabel(data.getLabel());
m.setFieldType(FieldType.of(data.getFieldType().getValue()));
} }
default -> m = null;
} }
return m; return m;
} }
private List<RadioBoxOptionFileTransformerModel> convertRadioBoxOptions(List<RadioBoxDataEntity.RadioBoxDataOptionEntity> data) { private List<RadioBoxDataFileTransformerModel.RadioBoxDataOptionFileTransformerModel> convertRadioBoxOptions(List<RadioBoxDataEntity.RadioBoxDataOptionEntity> data) {
List<RadioBoxOptionFileTransformerModel> result = new ArrayList<>(); List<RadioBoxDataFileTransformerModel.RadioBoxDataOptionFileTransformerModel> result = new ArrayList<>();
for (RadioBoxDataEntity.RadioBoxDataOptionEntity d : data) { for (RadioBoxDataEntity.RadioBoxDataOptionEntity d : data) {
RadioBoxOptionFileTransformerModel m = new RadioBoxOptionFileTransformerModel(); RadioBoxDataFileTransformerModel.RadioBoxDataOptionFileTransformerModel m = new RadioBoxDataFileTransformerModel.RadioBoxDataOptionFileTransformerModel();
m.setLabel(d.getLabel()); m.setLabel(d.getLabel());
m.setValue(d.getValue()); m.setValue(d.getValue());
result.add(m); result.add(m);
@ -205,19 +221,25 @@ public class DescriptionTemplateDefinitionFileTransformerBuilder extends BaseFil
return result; return result;
} }
private List<AutoCompleteSingleDataFileTransformerModel> convertAutoCompleteSingleData(List<ExternalSelectDataEntity.ExternalSelectSourceEntity> data) { private List<ExternalSelectDataFileTransformerModel.ExternalSelectSourceFileTransformerModel> convertAutoCompleteSingleData(List<ExternalSelectDataEntity.ExternalSelectSourceEntity> data) {
List<AutoCompleteSingleDataFileTransformerModel> result = new ArrayList<>(); List<ExternalSelectDataFileTransformerModel.ExternalSelectSourceFileTransformerModel> result = new ArrayList<>();
for (ExternalSelectDataEntity.ExternalSelectSourceEntity d : data) { for (ExternalSelectDataEntity.ExternalSelectSourceEntity d : data) {
AutoCompleteSingleDataFileTransformerModel m = new AutoCompleteSingleDataFileTransformerModel(); ExternalSelectDataFileTransformerModel.ExternalSelectSourceFileTransformerModel m = new ExternalSelectDataFileTransformerModel.ExternalSelectSourceFileTransformerModel();
m.setUrl(d.getUrl()); m.setUrl(d.getUrl());
m.setAutoCompleteOptions(convertComboBoxOption(d.getSourceBinding())); m.setMethod(d.getMethod());
m.setHasAuth(d.getHasAuth());
m.setOptionsRoot(d.getOptionsRoot());
if (d.getAuth() != null) {
m.setAuth(convertAuthData(d.getAuth()));
}
m.setSourceBinding(convertComboBoxOption(d.getSourceBinding()));
result.add(m); result.add(m);
} }
return result; return result;
} }
private ComboBoxOptionFileTransformerModel convertComboBoxOption(ExternalSelectDataEntity.ExternalSelectSourceBindingEntity data) { private ExternalSelectDataFileTransformerModel.ExternalSelectSourceBindingFileTransformerModel convertComboBoxOption(ExternalSelectDataEntity.ExternalSelectSourceBindingEntity data) {
ComboBoxOptionFileTransformerModel m = new ComboBoxOptionFileTransformerModel(); ExternalSelectDataFileTransformerModel.ExternalSelectSourceBindingFileTransformerModel m = new ExternalSelectDataFileTransformerModel.ExternalSelectSourceBindingFileTransformerModel();
// m.setUri(data.getUri()); // m.setUri(data.getUri());
m.setSource(data.getSource()); m.setSource(data.getSource());
m.setLabel(data.getLabel()); m.setLabel(data.getLabel());
@ -225,19 +247,27 @@ public class DescriptionTemplateDefinitionFileTransformerBuilder extends BaseFil
return m; return m;
} }
private ComboBoxOptionFileTransformerModel convertComboBoxOption(SelectDataEntity.OptionEntity data) { private ExternalSelectDataFileTransformerModel.ExternalSelectAuthDataFileTransformerModel convertAuthData(ExternalSelectDataEntity.ExternalSelectAuthDataEntity data) {
ComboBoxOptionFileTransformerModel m = new ComboBoxOptionFileTransformerModel(); ExternalSelectDataFileTransformerModel.ExternalSelectAuthDataFileTransformerModel m = new ExternalSelectDataFileTransformerModel.ExternalSelectAuthDataFileTransformerModel();
// m.setUri(data.getUri()); m.setMethod(data.getMethod());
// m.setSource(data.getSource()); m.setUrl(data.getUrl());
m.setType(data.getType());
m.setBody(data.getBody());
m.setPath(data.getPath());
return m;
}
private SelectDataFileTransformerModel.OptionFileTransformerModel convertComboBoxOption(SelectDataEntity.OptionEntity data) {
SelectDataFileTransformerModel.OptionFileTransformerModel m = new SelectDataFileTransformerModel.OptionFileTransformerModel();
m.setLabel(data.getLabel()); m.setLabel(data.getLabel());
m.setValue(data.getValue()); m.setValue(data.getValue());
return m; return m;
} }
private List<UploadOptionFileTransformerModel> convertUploadDataOptions(List<UploadDataEntity.UploadDataOptionEntity> data) { private List<UploadDataFileTransformerModel.UploadDataOptionFileTransformerModel> convertUploadDataOptions(List<UploadDataEntity.UploadDataOptionEntity> data) {
List<UploadOptionFileTransformerModel> result = new ArrayList<>(); List<UploadDataFileTransformerModel.UploadDataOptionFileTransformerModel> result = new ArrayList<>();
for (UploadDataEntity.UploadDataOptionEntity d : data) { for (UploadDataEntity.UploadDataOptionEntity d : data) {
UploadOptionFileTransformerModel m = new UploadOptionFileTransformerModel(); UploadDataFileTransformerModel.UploadDataOptionFileTransformerModel m = new UploadDataFileTransformerModel.UploadDataOptionFileTransformerModel();
m.setLabel(d.getLabel()); m.setLabel(d.getLabel());
m.setValue(d.getValue()); m.setValue(d.getValue());
result.add(m); result.add(m);

View File

@ -94,7 +94,9 @@ public class DmpBlueprintFileTransformerBuilder extends BaseFileTransformerBuild
m.setLabel(section.getLabel()); m.setLabel(section.getLabel());
m.setOrdinal(section.getOrdinal()); m.setOrdinal(section.getOrdinal());
m.setDescription(section.getDescription()); m.setDescription(section.getDescription());
if (section.getFields() != null && !section.getFields().isEmpty()) {
m.setFields(mapFields(section.getFields())); m.setFields(mapFields(section.getFields()));
}
m.setHasTemplates(section.getHasTemplates()); m.setHasTemplates(section.getHasTemplates());
result.getSections().add(m); result.getSections().add(m);
}); });

View File

@ -111,7 +111,6 @@ public class FileTransformerService {
List<TransformerRepository> repositories = transformerProperties.getSources().stream().map(depositSource -> getRepository(depositSource.getCodes().get(0))).toList(); List<TransformerRepository> repositories = transformerProperties.getSources().stream().map(depositSource -> getRepository(depositSource.getCodes().get(0))).toList();
repositories = new ArrayList<>(repositories); repositories = new ArrayList<>(repositories);
List<TransformerRepository> toDelete = new ArrayList<>();
repositories.forEach((client) -> { repositories.forEach((client) -> {
try { try {
FileTransformerConfiguration repositoryConfigs = client.getConfiguration(); FileTransformerConfiguration repositoryConfigs = client.getConfiguration();
@ -119,12 +118,10 @@ public class FileTransformerService {
configurations.addAll(repositoryConfigs.getExportVariants()); configurations.addAll(repositoryConfigs.getExportVariants());
} }
} catch (Exception e) { } catch (Exception e) {
toDelete.add(client); logger.warn(e.getLocalizedMessage(), e);
} }
}); });
repositories.removeAll(toDelete);
configs = new TransformerCacheModel(configurations); configs = new TransformerCacheModel(configurations);
this.fileTransformerConfigurationCache.put("base", configs); this.fileTransformerConfigurationCache.put("base", configs);
} }

View File

@ -202,6 +202,11 @@
<artifactId>exceptions-web</artifactId> <artifactId>exceptions-web</artifactId>
<version>1.0.0</version> <version>1.0.0</version>
</dependency> </dependency>
<dependency>
<groupId>gr.cite.opendmp</groupId>
<artifactId>file-transformer-base</artifactId>
<version>1.0.0-SNAPSHOT</version>
</dependency>
</dependencies> </dependencies>
<build> <build>