Export properly the data for each field type on dataset templates
This commit is contained in:
parent
af432cf329
commit
15c3a6fcb5
|
@ -2,6 +2,7 @@ package eu.eudat.logic.utilities.documents.xml.datasetProfileXml;
|
||||||
|
|
||||||
|
|
||||||
import eu.eudat.models.data.admin.components.datasetprofile.Page;
|
import eu.eudat.models.data.admin.components.datasetprofile.Page;
|
||||||
|
import eu.eudat.models.data.components.commons.ViewStyle;
|
||||||
import eu.eudat.models.data.components.commons.datafield.*;
|
import eu.eudat.models.data.components.commons.datafield.*;
|
||||||
import eu.eudat.models.data.user.components.datasetprofile.Field;
|
import eu.eudat.models.data.user.components.datasetprofile.Field;
|
||||||
import eu.eudat.models.data.user.components.datasetprofile.FieldSet;
|
import eu.eudat.models.data.user.components.datasetprofile.FieldSet;
|
||||||
|
@ -202,67 +203,120 @@ public class ExportXmlBuilderDatasetProfile {
|
||||||
|
|
||||||
if (field.getData() != null) {
|
if (field.getData() != null) {
|
||||||
Element dataOut = element.createElement("data");
|
Element dataOut = element.createElement("data");
|
||||||
if (field.getViewStyle().getRenderStyle().equals("combobox")) {
|
ViewStyle.Type viewStyleType = ViewStyle.Type.fromName(field.getViewStyle().getRenderStyle());
|
||||||
ComboBoxData comboBoxDataObject = (ComboBoxData) field.getData();
|
switch (viewStyleType) {
|
||||||
if (comboBoxDataObject.getType().equals("wordlist")) {
|
case COMBO_BOX:
|
||||||
WordListData wordListDataObject = (WordListData) field.getData();
|
ComboBoxData comboBoxDataObject = (ComboBoxData) field.getData();
|
||||||
dataOut.setAttribute("label", wordListDataObject.getLabel());
|
if (comboBoxDataObject.getType().equals("wordlist")) {
|
||||||
dataOut.setAttribute("type", wordListDataObject.getType());
|
WordListData wordListDataObject = (WordListData) field.getData();
|
||||||
dataOut.setAttribute("multiList", wordListDataObject.getMultiList().toString());
|
dataOut.setAttribute("label", wordListDataObject.getLabel());
|
||||||
|
dataOut.setAttribute("type", wordListDataObject.getType());
|
||||||
|
dataOut.setAttribute("multiList", wordListDataObject.getMultiList().toString());
|
||||||
|
Element options = element.createElement("options");
|
||||||
|
wordListDataObject.getOptions().forEach(optionChildFor -> {
|
||||||
|
Element optionChild = element.createElement("option");
|
||||||
|
optionChild.setAttribute("label", optionChildFor.getLabel());
|
||||||
|
optionChild.setAttribute("value", optionChildFor.getValue());
|
||||||
|
options.appendChild(optionChild);
|
||||||
|
});
|
||||||
|
dataOut.appendChild(options);
|
||||||
|
} else if (comboBoxDataObject.getType().equals("autocomplete")) {
|
||||||
|
AutoCompleteData autoCompleteDataObject = (AutoCompleteData) field.getData();
|
||||||
|
dataOut.setAttribute("label", autoCompleteDataObject.getLabel());
|
||||||
|
dataOut.setAttribute("type", autoCompleteDataObject.getType());
|
||||||
|
dataOut.setAttribute("multiAutoComplete", autoCompleteDataObject.getMultiAutoComplete().toString());
|
||||||
|
for (AutoCompleteData.AutoCompleteSingleData singleData: autoCompleteDataObject.getAutoCompleteSingleDataList()) {
|
||||||
|
Element singleItem = element.createElement("autocompleteSingle");
|
||||||
|
singleItem.setAttribute("optionsRoot", singleData.getOptionsRoot());
|
||||||
|
singleItem.setAttribute("url", singleData.getUrl());
|
||||||
|
singleItem.setAttribute("autoCompleteType", Integer.toString(singleData.getAutocompleteType()));
|
||||||
|
if (singleData.getAutoCompleteOptions() != null) {
|
||||||
|
Element optionChild = element.createElement("option");
|
||||||
|
optionChild.setAttribute("label", singleData.getAutoCompleteOptions().getLabel());
|
||||||
|
optionChild.setAttribute("value", singleData.getAutoCompleteOptions().getValue());
|
||||||
|
singleItem.appendChild(optionChild);
|
||||||
|
}
|
||||||
|
dataOut.appendChild(singleItem);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case BOOLEAN_DECISION:
|
||||||
|
BooleanDecisionData booleanDecisionDataObject = (BooleanDecisionData) field.getData();
|
||||||
|
dataOut.setAttribute("label", booleanDecisionDataObject.getLabel());
|
||||||
|
break;
|
||||||
|
case RADIO_BOX:
|
||||||
|
RadioBoxData radioBoxDataObject = (RadioBoxData) field.getData();
|
||||||
|
dataOut.setAttribute("label", radioBoxDataObject.getLabel());
|
||||||
|
|
||||||
Element options = element.createElement("options");
|
Element options = element.createElement("options");
|
||||||
wordListDataObject.getOptions().forEach(optionChildFor -> {
|
radioBoxDataObject.getOptions().forEach(optionChildFor -> {
|
||||||
Element optionChild = element.createElement("option");
|
Element optionChild = element.createElement("option");
|
||||||
optionChild.setAttribute("label", optionChildFor.getLabel());
|
optionChild.setAttribute("label", optionChildFor.getLabel());
|
||||||
optionChild.setAttribute("value", optionChildFor.getValue());
|
optionChild.setAttribute("value", optionChildFor.getValue());
|
||||||
options.appendChild(optionChild);
|
options.appendChild(optionChild);
|
||||||
});
|
});
|
||||||
dataOut.appendChild(options);
|
dataOut.appendChild(options);
|
||||||
} else if (comboBoxDataObject.getType().equals("autocomplete")) {
|
break;
|
||||||
AutoCompleteData autoCompleteDataObject = (AutoCompleteData) field.getData();
|
case CHECK_BOX:
|
||||||
dataOut.setAttribute("label", autoCompleteDataObject.getLabel());
|
case FREE_TEXT:
|
||||||
dataOut.setAttribute("type", autoCompleteDataObject.getType());
|
case TEXT_AREA:
|
||||||
dataOut.setAttribute("multiAutoComplete", autoCompleteDataObject.getMultiAutoComplete().toString());
|
case DATE_PICKER:
|
||||||
for (AutoCompleteData.AutoCompleteSingleData singleData: autoCompleteDataObject.getAutoCompleteSingleDataList()) {
|
case DATASET_IDENTIFIER:
|
||||||
Element singleItem = element.createElement("autocompleteSingle");
|
case CURRENCY:
|
||||||
singleItem.setAttribute("optionsRoot", singleData.getOptionsRoot());
|
case TAGS:
|
||||||
singleItem.setAttribute("url", singleData.getUrl());
|
FieldData fieldDataObject = (FieldData) field.getData();
|
||||||
singleItem.setAttribute("autoCompleteType", Integer.toString(singleData.getAutocompleteType()));
|
dataOut.setAttribute("label", fieldDataObject.getLabel());
|
||||||
if (singleData.getAutoCompleteOptions() != null) {
|
break;
|
||||||
Element optionChild = element.createElement("option");
|
case INTERNAL_DMP_ENTRIES:
|
||||||
optionChild.setAttribute("label", singleData.getAutoCompleteOptions().getLabel());
|
InternalDmpEntitiesData internalDmpEntitiesData = (InternalDmpEntitiesData) field.getData();
|
||||||
optionChild.setAttribute("value", singleData.getAutoCompleteOptions().getValue());
|
dataOut.setAttribute("label", internalDmpEntitiesData.getLabel());
|
||||||
singleItem.appendChild(optionChild);
|
dataOut.setAttribute("type", internalDmpEntitiesData.getType());
|
||||||
}
|
switch (internalDmpEntitiesData.getType()) {
|
||||||
dataOut.appendChild(singleItem);
|
case "researchers":
|
||||||
|
ResearchersAutoCompleteData researchersAutoCompleteData = (ResearchersAutoCompleteData) internalDmpEntitiesData;
|
||||||
|
dataOut.setAttribute("multiAutocomplete", researchersAutoCompleteData.getMultiAutoComplete().toString());
|
||||||
|
break;
|
||||||
|
case "datasets":
|
||||||
|
DatasetsAutoCompleteData datasetsAutoCompleteData = (DatasetsAutoCompleteData) internalDmpEntitiesData;
|
||||||
|
dataOut.setAttribute("multiAutocomplete", datasetsAutoCompleteData.getMultiAutoComplete().toString());
|
||||||
|
break;
|
||||||
|
case "dmps":
|
||||||
|
DMPsAutoCompleteData dmPsAutoCompleteData = (DMPsAutoCompleteData) internalDmpEntitiesData;
|
||||||
|
dataOut.setAttribute("multiAutocomplete", dmPsAutoCompleteData.getMultiAutoComplete().toString());
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
break;
|
||||||
} else if (field.getViewStyle().getRenderStyle().equals("booleanDecision")) {
|
case EXTERNAL_DATASETS:
|
||||||
BooleanDecisionData booleanDecisionDataObject = (BooleanDecisionData) field.getData();
|
ExternalDatasetsData externalDatasetsData = (ExternalDatasetsData) field.getData();
|
||||||
dataOut.setAttribute("label", booleanDecisionDataObject.getLabel());
|
dataOut.setAttribute("label", externalDatasetsData.getLabel());
|
||||||
} else if (field.getViewStyle().getRenderStyle().equals("radiobox")) {
|
dataOut.setAttribute("multiAutocomplete", externalDatasetsData.getMultiAutoComplete().toString());
|
||||||
RadioBoxData radioBoxDataObject = (RadioBoxData) field.getData();
|
break;
|
||||||
dataOut.setAttribute("label", radioBoxDataObject.getLabel());
|
case DATA_REPOSITORIES:
|
||||||
|
DataRepositoriesData dataRepositoriesData = (DataRepositoriesData) field.getData();
|
||||||
|
dataOut.setAttribute("label", dataRepositoriesData.getLabel());
|
||||||
|
dataOut.setAttribute("multiAutocomplete", dataRepositoriesData.getMultiAutoComplete().toString());
|
||||||
|
break;
|
||||||
|
case ORGANIZATIONS:
|
||||||
|
OrganizationsData organizationsData = (OrganizationsData) field.getData();
|
||||||
|
dataOut.setAttribute("label", organizationsData.getLabel());
|
||||||
|
dataOut.setAttribute("multiAutocomplete", organizationsData.getMultiAutoComplete().toString());
|
||||||
|
break;
|
||||||
|
case RESEARCHERS:
|
||||||
|
ResearcherData researcherData = (ResearcherData) field.getData();
|
||||||
|
dataOut.setAttribute("label", researcherData.getLabel());
|
||||||
|
dataOut.setAttribute("multiAutocomplete", researcherData.getMultiAutoComplete().toString());
|
||||||
|
break;
|
||||||
|
case REGISTRIES:
|
||||||
|
RegistriesData registriesData = (RegistriesData) field.getData();
|
||||||
|
dataOut.setAttribute("label", registriesData.getLabel());
|
||||||
|
dataOut.setAttribute("multiAutocomplete", registriesData.getMultiAutoComplete().toString());
|
||||||
|
break;
|
||||||
|
case SERVICES:
|
||||||
|
ServicesData servicesData = (ServicesData) field.getData();
|
||||||
|
dataOut.setAttribute("label", servicesData.getLabel());
|
||||||
|
dataOut.setAttribute("multiAutocomplete", servicesData.getMultiAutoComplete().toString());
|
||||||
|
break;
|
||||||
|
|
||||||
Element options = element.createElement("options");
|
|
||||||
radioBoxDataObject.getOptions().forEach(optionChildFor -> {
|
|
||||||
Element optionChild = element.createElement("option");
|
|
||||||
optionChild.setAttribute("label", optionChildFor.getLabel());
|
|
||||||
optionChild.setAttribute("value", optionChildFor.getValue());
|
|
||||||
options.appendChild(optionChild);
|
|
||||||
});
|
|
||||||
dataOut.appendChild(options);
|
|
||||||
} else if (field.getViewStyle().getRenderStyle().equals("checkBox")) {
|
|
||||||
CheckBoxData checkBoxDataObject = (CheckBoxData) field.getData();
|
|
||||||
dataOut.setAttribute("label", checkBoxDataObject.getLabel());
|
|
||||||
} else if (field.getViewStyle().getRenderStyle().equals("freetext")) {
|
|
||||||
FreeTextData freeTextDataObject = (FreeTextData) field.getData();
|
|
||||||
dataOut.setAttribute("label", freeTextDataObject.getLabel());
|
|
||||||
} else if (field.getViewStyle().getRenderStyle().equals("textarea")) {
|
|
||||||
TextAreaData textAreaDataObject = (TextAreaData) field.getData();
|
|
||||||
dataOut.setAttribute("label", textAreaDataObject.getLabel());
|
|
||||||
} else if (field.getViewStyle().getRenderStyle().equals("datePicker")) {
|
|
||||||
DatePickerData datePickerDataObject = (DatePickerData) field.getData();
|
|
||||||
dataOut.setAttribute("label", datePickerDataObject.getLabel());
|
|
||||||
}
|
}
|
||||||
elementField.appendChild(dataOut);
|
elementField.appendChild(dataOut);
|
||||||
}
|
}
|
||||||
|
|
|
@ -117,7 +117,9 @@ public class Field {
|
||||||
fieldEntity.setViewStyle(this.viewStyle.toAdminCompositeModelSection());
|
fieldEntity.setViewStyle(this.viewStyle.toAdminCompositeModelSection());
|
||||||
FieldData data = new ModelBuilder().toFieldData(null, this.viewStyle.getRenderStyle(), (Element) this.data);
|
FieldData data = new ModelBuilder().toFieldData(null, this.viewStyle.getRenderStyle(), (Element) this.data);
|
||||||
// fieldEntity.setData( data.fromXml((Element) this.data));
|
// fieldEntity.setData( data.fromXml((Element) this.data));
|
||||||
fieldEntity.setData( data.toMap((Element)this.data));
|
if (data != null) {
|
||||||
|
fieldEntity.setData(data.toMap((Element) this.data));
|
||||||
|
}
|
||||||
return fieldEntity;
|
return fieldEntity;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,4 +20,44 @@ public class ViewStyle {
|
||||||
this.cssClass = cssClass;
|
this.cssClass = cssClass;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public enum Type {
|
||||||
|
COMBO_BOX("combobox"),
|
||||||
|
BOOLEAN_DECISION("booleanDecision"),
|
||||||
|
RADIO_BOX("radiobox"),
|
||||||
|
INTERNAL_DMP_ENTRIES("internalDmpEntities"),
|
||||||
|
CHECK_BOX("checkBox"),
|
||||||
|
FREE_TEXT("freetext"),
|
||||||
|
TEXT_AREA("textarea"),
|
||||||
|
DATE_PICKER("datePicker"),
|
||||||
|
EXTERNAL_DATASETS("externalDatasets"),
|
||||||
|
DATA_REPOSITORIES("dataRepositories"),
|
||||||
|
REGISTRIES("registries"),
|
||||||
|
SERVICES("services"),
|
||||||
|
TAGS("tags"),
|
||||||
|
RESEARCHERS("researchers"),
|
||||||
|
ORGANIZATIONS("organizations"),
|
||||||
|
DATASET_IDENTIFIER("datasetIdentifier"),
|
||||||
|
CURRENCY("currency"),
|
||||||
|
VALIDATION("validation");
|
||||||
|
|
||||||
|
private final String name;
|
||||||
|
|
||||||
|
Type(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Type fromName(String name) {
|
||||||
|
for (Type type: Type.values()) {
|
||||||
|
if (name.equals(type.getName())) {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
throw new IllegalArgumentException("View Style Type [" + name + "] is not valid");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue