This commit is contained in:
Efstratios Giannopoulos 2024-01-30 17:23:18 +02:00
parent 268b82eb49
commit 16222fc02c
6 changed files with 34 additions and 59 deletions

View File

@ -26,34 +26,13 @@ public class FieldEntity implements DatabaseViewStyleDefinition {
private List<RuleEntity> visibilityRules; private List<RuleEntity> visibilityRules;
@XmlElements({ @XmlElements({
@XmlElement(name = FieldType.Names.CheckBox, type = LabelDataEntity.class), @XmlElement(name = "labelData", type = LabelDataEntity.class),
@XmlElement(name = FieldType.Names.Validation, type = LabelDataEntity.class), @XmlElement(name = "labelAndMultiplicityData", type = LabelAndMultiplicityDataEntity.class),
@XmlElement(name = FieldType.Names.TextArea, type = LabelDataEntity.class), @XmlElement(name = "externalDatasetsData", type = ExternalDatasetDataEntity.class),
@XmlElement(name = FieldType.Names.Taxonomies, type = LabelAndMultiplicityDataEntity.class), @XmlElement(name = "uploadData", type = UploadDataEntity.class),
@XmlElement(name = FieldType.Names.Tags, type = LabelDataEntity.class), @XmlElement(name = "radioBoxData", type = RadioBoxDataEntity.class),
@XmlElement(name = FieldType.Names.Services, type = LabelAndMultiplicityDataEntity.class), @XmlElement(name = "wordListData", type = WordListDataEntity.class),
@XmlElement(name = FieldType.Names.RichTextarea, type = LabelDataEntity.class), @XmlElement(name = "autocompleteData", type = AutoCompleteDataEntity.class),
@XmlElement(name = FieldType.Names.Researchers, type = LabelAndMultiplicityDataEntity.class),
@XmlElement(name = FieldType.Names.Registries, type = LabelAndMultiplicityDataEntity.class),
@XmlElement(name = FieldType.Names.PubRepositories, type = LabelAndMultiplicityDataEntity.class),
@XmlElement(name = FieldType.Names.Publications, type = LabelAndMultiplicityDataEntity.class),
@XmlElement(name = FieldType.Names.Organizations, type = LabelAndMultiplicityDataEntity.class),
@XmlElement(name = FieldType.Names.Licenses, type = LabelAndMultiplicityDataEntity.class),
@XmlElement(name = FieldType.Names.JournalRepositories, type = LabelAndMultiplicityDataEntity.class),
@XmlElement(name = FieldType.Names.FreeText, type = LabelDataEntity.class),
@XmlElement(name = FieldType.Names.ExternalDatasets, type = ExternalDatasetDataEntity.class),
@XmlElement(name = FieldType.Names.DatePicker, type = LabelDataEntity.class),
@XmlElement(name = FieldType.Names.DatasetIdentifier, type = LabelDataEntity.class),
@XmlElement(name = FieldType.Names.DataRepositories, type = LabelAndMultiplicityDataEntity.class),
@XmlElement(name = FieldType.Names.Currency, type = LabelDataEntity.class),
@XmlElement(name = FieldType.Names.BooleanDecision, type = LabelDataEntity.class),
@XmlElement(name = FieldType.Names.Upload, type = UploadDataEntity.class),
@XmlElement(name = FieldType.Names.RadioBox, type = RadioBoxDataEntity.class),
@XmlElement(name = FieldType.Names.Wordlist, type = WordListDataEntity.class),
@XmlElement(name = FieldType.Names.Autocomplete, type = AutoCompleteDataEntity.class),
@XmlElement(name = FieldType.Names.InternalDmpDatasets, type = LabelAndMultiplicityDataEntity.class),
@XmlElement(name = FieldType.Names.InternalDmpDmps, type = LabelAndMultiplicityDataEntity.class),
@XmlElement(name = FieldType.Names.InternalDmpResearchers, type = LabelAndMultiplicityDataEntity.class),
}) })
private BaseFieldDataEntity<?> data; private BaseFieldDataEntity<?> data;
@XmlElementWrapper(name = "validations") @XmlElementWrapper(name = "validations")

View File

@ -2,6 +2,7 @@ package eu.eudat.commons.types.descriptiontemplate.importexport;
import eu.eudat.commons.enums.FieldType; import eu.eudat.commons.enums.FieldType;
import eu.eudat.commons.enums.FieldValidationType; import eu.eudat.commons.enums.FieldValidationType;
import eu.eudat.commons.types.descriptiontemplate.fielddata.*;
import eu.eudat.commons.types.descriptiontemplate.importexport.fielddata.*; import eu.eudat.commons.types.descriptiontemplate.importexport.fielddata.*;
import jakarta.xml.bind.annotation.*; import jakarta.xml.bind.annotation.*;
@ -34,34 +35,13 @@ public class FieldImportExport {
private FieldType fieldType; private FieldType fieldType;
@XmlElements({ @XmlElements({
@XmlElement(name = FieldType.Names.CheckBox, type = LabelDataImportExport.class), @XmlElement(name = "labelData", type = LabelDataImportExport.class),
@XmlElement(name = FieldType.Names.Validation, type = LabelDataImportExport.class), @XmlElement(name = "labelAndMultiplicityData", type = LabelAndMultiplicityDataImportExport.class),
@XmlElement(name = FieldType.Names.TextArea, type = LabelDataImportExport.class), @XmlElement(name = "externalDatasetsData", type = ExternalDatasetDataImportExport.class),
@XmlElement(name = FieldType.Names.Taxonomies, type = LabelAndMultiplicityDataImportExport.class), @XmlElement(name = "uploadData", type = UploadDataImportExport.class),
@XmlElement(name = FieldType.Names.Tags, type = LabelDataImportExport.class), @XmlElement(name = "radioBoxData", type = RadioBoxDataImportExport.class),
@XmlElement(name = FieldType.Names.Services, type = LabelAndMultiplicityDataImportExport.class), @XmlElement(name = "wordListData", type = WordListDataImportExport.class),
@XmlElement(name = FieldType.Names.RichTextarea, type = LabelDataImportExport.class), @XmlElement(name = "autocompleteData", type = AutoCompleteDataImportExport.class),
@XmlElement(name = FieldType.Names.Researchers, type = LabelAndMultiplicityDataImportExport.class),
@XmlElement(name = FieldType.Names.Registries, type = LabelAndMultiplicityDataImportExport.class),
@XmlElement(name = FieldType.Names.PubRepositories, type = LabelAndMultiplicityDataImportExport.class),
@XmlElement(name = FieldType.Names.Publications, type = LabelAndMultiplicityDataImportExport.class),
@XmlElement(name = FieldType.Names.Organizations, type = LabelAndMultiplicityDataImportExport.class),
@XmlElement(name = FieldType.Names.Licenses, type = LabelAndMultiplicityDataImportExport.class),
@XmlElement(name = FieldType.Names.JournalRepositories, type = LabelAndMultiplicityDataImportExport.class),
@XmlElement(name = FieldType.Names.FreeText, type = LabelDataImportExport.class),
@XmlElement(name = FieldType.Names.ExternalDatasets, type = ExternalDatasetDataImportExport.class),
@XmlElement(name = FieldType.Names.DatePicker, type = LabelDataImportExport.class),
@XmlElement(name = FieldType.Names.DatasetIdentifier, type = LabelDataImportExport.class),
@XmlElement(name = FieldType.Names.DataRepositories, type = LabelAndMultiplicityDataImportExport.class),
@XmlElement(name = FieldType.Names.Currency, type = LabelDataImportExport.class),
@XmlElement(name = FieldType.Names.BooleanDecision, type = LabelDataImportExport.class),
@XmlElement(name = FieldType.Names.Upload, type = UploadDataImportExport.class),
@XmlElement(name = FieldType.Names.RadioBox, type = RadioBoxDataImportExport.class),
@XmlElement(name = FieldType.Names.Wordlist, type = WordListDataImportExport.class),
@XmlElement(name = FieldType.Names.Autocomplete, type = AutoCompleteDataImportExport.class),
@XmlElement(name = FieldType.Names.InternalDmpDatasets, type = LabelAndMultiplicityDataImportExport.class),
@XmlElement(name = FieldType.Names.InternalDmpDmps, type = LabelAndMultiplicityDataImportExport.class),
@XmlElement(name = FieldType.Names.InternalDmpResearchers, type = LabelAndMultiplicityDataImportExport.class),
}) })
private BaseFieldDataImportExport data; private BaseFieldDataImportExport data;

View File

@ -11,6 +11,8 @@ import java.util.Map;
public abstract class BaseFieldDataImportExport { public abstract class BaseFieldDataImportExport {
@XmlAttribute(name = "label") @XmlAttribute(name = "label")
private String label; private String label;
@XmlAttribute(name = "fieldType")
private FieldType fieldType;
public String getLabel() { public String getLabel() {
return label; return label;
@ -19,4 +21,12 @@ public abstract class BaseFieldDataImportExport {
public void setLabel(String label) { public void setLabel(String label) {
this.label = label; this.label = label;
} }
public FieldType getFieldType() {
return fieldType;
}
public void setFieldType(FieldType fieldType) {
this.fieldType = fieldType;
}
} }

View File

@ -65,8 +65,13 @@ public class FieldBuilder extends BaseBuilder<Field, FieldEntity> {
if (fields.hasField(this.asIndexer(Field._numbering))) m.setNumbering(d.getNumbering()); if (fields.hasField(this.asIndexer(Field._numbering))) m.setNumbering(d.getNumbering());
if (!visibilityRulesFields.isEmpty() && d.getVisibilityRules() != null) m.setVisibilityRules(this.builderFactory.builder(RuleBuilder.class).authorize(this.authorize).build(visibilityRulesFields, d.getVisibilityRules())); if (!visibilityRulesFields.isEmpty() && d.getVisibilityRules() != null) m.setVisibilityRules(this.builderFactory.builder(RuleBuilder.class).authorize(this.authorize).build(visibilityRulesFields, d.getVisibilityRules()));
if (!dataFields.isEmpty() && d.getData() != null){ if (!dataFields.isEmpty() && d.getData() != null){
try {
FieldDataHelperService fieldDataHelperService = this.fieldDataHelperServiceProvider.get(d.getData().getFieldType()); FieldDataHelperService fieldDataHelperService = this.fieldDataHelperServiceProvider.get(d.getData().getFieldType());
m.setData(fieldDataHelperService.buildOne(dataFields, d.getData(), this.authorize)); m.setData(fieldDataHelperService.buildOne(dataFields, d.getData(), this.authorize));
} catch (Exception e){
throw e;
}
} }
models.add(m); models.add(m);

View File

@ -67,6 +67,7 @@ public abstract class BaseFieldDataHelperService<M extends BaseFieldData, PM ext
public BaseFieldDataImportExport dataToImportExportXml(BaseFieldDataEntity<?> data){ public BaseFieldDataImportExport dataToImportExportXml(BaseFieldDataEntity<?> data){
IE xml = this.newImportExportInstanceInternal(); IE xml = this.newImportExportInstanceInternal();
xml.setLabel(data.getLabel()); xml.setLabel(data.getLabel());
xml.setFieldType(data.getFieldType());
return this.dataToImportExportXmlInternal((D)data, xml); return this.dataToImportExportXmlInternal((D)data, xml);
} }

View File

@ -265,7 +265,7 @@ public class DescriptionTemplateXmlMigrationService {
return this.buildLabelAndMultiplicityDataEntity(persist.getLabel(), ((DataRepositoriesData)persist).getMultiAutoComplete(),FieldType.DATA_REPOSITORIES); return this.buildLabelAndMultiplicityDataEntity(persist.getLabel(), ((DataRepositoriesData)persist).getMultiAutoComplete(),FieldType.DATA_REPOSITORIES);
} }
if (renderStyle.equals("booleanDecision")){ if (renderStyle.equals("booleanDecision")){
return this.buildLabelDataEntity(persist.getLabel(), FieldType.DATA_REPOSITORIES); return this.buildLabelDataEntity(persist.getLabel(), FieldType.BOOLEAN_DECISION);
} }
if (renderStyle.equals("internalDmpEntities")){ if (renderStyle.equals("internalDmpEntities")){
switch (((InternalDmpEntitiesData<?>)persist).getType()){ switch (((InternalDmpEntitiesData<?>)persist).getType()){