Update File Transformer Builder
This commit is contained in:
parent
bcd42d66b7
commit
02a1437a91
|
@ -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>
|
||||
|
|
|
@ -98,8 +98,12 @@ public class DescriptionTemplateDefinitionFileTransformerBuilder extends BaseFil
|
|||
m.setExtendedDescription(d.getExtendedDescription());
|
||||
m.setMultiplicity(d.getMultiplicity());
|
||||
m.setNumbering(d.getNumbering());
|
||||
m.setSections(collectSections(d.getSections()));
|
||||
m.setFieldSets(collectFieldSet(d.getFieldSets()));
|
||||
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());
|
||||
m.setVisibilityRules(convertVisibilityRules(d.getVisibilityRules()));
|
||||
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,23 @@ 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());
|
||||
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 +245,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);
|
||||
|
|
|
@ -94,7 +94,9 @@ public class DmpBlueprintFileTransformerBuilder extends BaseFileTransformerBuild
|
|||
m.setLabel(section.getLabel());
|
||||
m.setOrdinal(section.getOrdinal());
|
||||
m.setDescription(section.getDescription());
|
||||
m.setFields(mapFields(section.getFields()));
|
||||
if (section.getFields() != null && !section.getFields().isEmpty()) {
|
||||
m.setFields(mapFields(section.getFields()));
|
||||
}
|
||||
m.setHasTemplates(section.getHasTemplates());
|
||||
result.getSections().add(m);
|
||||
});
|
||||
|
|
|
@ -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>
|
||||
|
|
Loading…
Reference in New Issue