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>
<groupId>gr.cite.opendmp</groupId>
<artifactId>file-transformer-base</artifactId>
<version>0.0.3</version>
<version>1.0.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>gr.cite</groupId>

View File

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

View File

@ -94,7 +94,9 @@ public class DmpBlueprintFileTransformerBuilder extends BaseFileTransformerBuild
m.setLabel(section.getLabel());
m.setOrdinal(section.getOrdinal());
m.setDescription(section.getDescription());
if (section.getFields() != null && !section.getFields().isEmpty()) {
m.setFields(mapFields(section.getFields()));
}
m.setHasTemplates(section.getHasTemplates());
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();
repositories = new ArrayList<>(repositories);
List<TransformerRepository> toDelete = new ArrayList<>();
repositories.forEach((client) -> {
try {
FileTransformerConfiguration repositoryConfigs = client.getConfiguration();
@ -119,12 +118,10 @@ public class FileTransformerService {
configurations.addAll(repositoryConfigs.getExportVariants());
}
} catch (Exception e) {
toDelete.add(client);
logger.warn(e.getLocalizedMessage(), e);
}
});
repositories.removeAll(toDelete);
configs = new TransformerCacheModel(configurations);
this.fileTransformerConfigurationCache.put("base", configs);
}

View File

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