Fix various issues with various template fields
This commit is contained in:
parent
4a1f260849
commit
3d9a2b2331
|
@ -1,5 +1,6 @@
|
|||
package eu.eudat.logic.utilities.documents.word;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonParseException;
|
||||
import com.fasterxml.jackson.databind.DeserializationFeature;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import eu.eudat.logic.services.forms.VisibilityRuleService;
|
||||
|
@ -226,9 +227,22 @@ public class WordBuilder {
|
|||
}
|
||||
|
||||
private String formatter(Field field) throws IOException {
|
||||
String comboboxType = null;
|
||||
switch (field.getViewStyle().getRenderStyle()) {
|
||||
case "researchers":
|
||||
case "projects":
|
||||
case "organizations":
|
||||
case "externalDatasets":
|
||||
case "dataRepositories":
|
||||
case "registries":
|
||||
case "services":
|
||||
case "tags":
|
||||
case "currency":
|
||||
comboboxType = "autocomplete";
|
||||
case "combobox": {
|
||||
String comboboxType = ((ComboBoxData) field.getData()).getType();
|
||||
if (comboboxType == null) {
|
||||
comboboxType = ((ComboBoxData) field.getData()).getType();
|
||||
}
|
||||
if (comboboxType.equals("autocomplete")) {
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
mapper.configure(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY, true);
|
||||
|
@ -271,13 +285,14 @@ public class WordBuilder {
|
|||
StringBuilder sb = new StringBuilder();
|
||||
int index = 0;
|
||||
for (Map<String, Object> map: mapList) {
|
||||
if (!map.containsKey("label") && !map.containsKey("description")) {
|
||||
/*if (!map.containsKey("label") && !map.containsKey("description")) {
|
||||
logger.error("Value is missing the \"label\" and the \"description\" attributes");
|
||||
map.put("label", "unknown Name");
|
||||
}
|
||||
}*/
|
||||
for (Map.Entry<String, Object> entry : map.entrySet()) {
|
||||
if (entry.getValue() != null && (entry.getKey().equals("label") || entry.getKey().equals("description"))) {
|
||||
if (entry.getValue() != null && (entry.getKey().equals("label") || entry.getKey().equals("description") || entry.getKey().equals("name"))) {
|
||||
sb.append(entry.getValue().toString());
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (index != mapList.size() - 1) sb.append(", ");
|
||||
|
@ -314,6 +329,23 @@ public class WordBuilder {
|
|||
case "datepicker":
|
||||
case "textarea":
|
||||
return field.getValue() != null ? field.getValue().toString(): "";
|
||||
case "datasetIdentifier":
|
||||
case "validation":
|
||||
Map<String, String> identifierData;
|
||||
try {
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
identifierData = mapper.readValue(field.getValue().toString(), HashMap.class);
|
||||
} catch (JsonParseException ex) {
|
||||
identifierData = new HashMap<>();
|
||||
String parsedData = field.getValue().toString().substring(1, field.getValue().toString().length() - 1);
|
||||
StringTokenizer commaTokens = new StringTokenizer(parsedData, ", ");
|
||||
while (commaTokens.hasMoreTokens()) {
|
||||
String token = commaTokens.nextToken();
|
||||
StringTokenizer equalTokens = new StringTokenizer(token, "=");
|
||||
identifierData.put(equalTokens.nextToken(), equalTokens.nextToken());
|
||||
}
|
||||
}
|
||||
return "id: " + identifierData.get("identifier") + ", Validation Type: " + identifierData.get("type");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -51,8 +51,8 @@ public class DataRepositoriesData extends FieldData<DataRepositoriesData> {
|
|||
@Override
|
||||
public Map<String, Object> toMap(Element item) {
|
||||
HashMap dataMap = new HashMap();
|
||||
dataMap.put("label", item != null ? item.getAttribute("label") : "");
|
||||
dataMap.put("multiAutoComplete", item != null ? item.getAttribute("multiAutoComplete") : false);
|
||||
dataMap.put("label", item != null && item.getAttributes().getLength() > 0? item.getAttribute("label") : "");
|
||||
dataMap.put("multiAutoComplete", item != null && item.getAttributes().getLength() > 0 ? item.getAttribute("multiAutoComplete") : false);
|
||||
return dataMap;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -51,8 +51,8 @@ public class ExternalDatasetsData extends FieldData<ExternalDatasetsData> {
|
|||
@Override
|
||||
public Map<String, Object> toMap(Element item) {
|
||||
HashMap dataMap = new HashMap();
|
||||
dataMap.put("label", item != null ? item.getAttribute("label") : "");
|
||||
dataMap.put("multiAutoComplete", item != null ? item.getAttribute("multiAutoComplete") : false);
|
||||
dataMap.put("label", item != null && item.getAttributes().getLength() > 0? item.getAttribute("label") : "");
|
||||
dataMap.put("multiAutoComplete", item != null && item.getAttributes().getLength() > 0? item.getAttribute("multiAutoComplete") : false);
|
||||
return dataMap;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -51,8 +51,8 @@ public class OrganizationsData extends FieldData<OrganizationsData> {
|
|||
@Override
|
||||
public Map<String, Object> toMap(Element item) {
|
||||
HashMap dataMap = new HashMap();
|
||||
dataMap.put("label", item != null ? item.getAttribute("label") : "");
|
||||
dataMap.put("multiAutoComplete", item != null ? item.getAttribute("multiAutoComplete") : false);
|
||||
dataMap.put("label", item != null && item.getAttributes().getLength() > 0? item.getAttribute("label") : "");
|
||||
dataMap.put("multiAutoComplete", item != null && item.getAttributes().getLength() > 0? item.getAttribute("multiAutoComplete") : false);
|
||||
return dataMap;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -118,7 +118,28 @@ public class RadioBoxData extends FieldData<RadioBoxData> {
|
|||
public Map<String, Object> toMap(Element item) {
|
||||
HashMap dataMap = new HashMap();
|
||||
dataMap.put("label", item != null ? item.getAttribute("label") : "");
|
||||
dataMap.put("options", item != null ? item.getAttribute("options") : "");
|
||||
Element optionsElement = (Element) item.getElementsByTagName("options").item(0);
|
||||
List<Map<String,String>> option =new LinkedList<>();
|
||||
|
||||
if (optionsElement != null) {
|
||||
NodeList optionElements = optionsElement.getChildNodes();
|
||||
for (int temp = 0; temp < optionElements.getLength(); temp++) {
|
||||
Node optionElement = optionElements.item(temp);
|
||||
if (optionElement.getNodeType() == Node.ELEMENT_NODE) {
|
||||
option.add(optionToMap((Element) optionElement));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dataMap.put("options", option != null ? option : null);
|
||||
return dataMap;
|
||||
}
|
||||
|
||||
private Map<String, String> optionToMap(Element item){
|
||||
HashMap dataMap = new HashMap();
|
||||
dataMap.put("label",item.getAttribute("label"));
|
||||
dataMap.put("value",item.getAttribute("value"));
|
||||
|
||||
return dataMap;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -51,8 +51,8 @@ public class RegistriesData extends FieldData<RegistriesData> {
|
|||
@Override
|
||||
public Map<String, Object> toMap(Element item) {
|
||||
HashMap dataMap = new HashMap();
|
||||
dataMap.put("label", item != null ? item.getAttribute("label") : "");
|
||||
dataMap.put("multiAutoComplete", item != null ? item.getAttribute("multiAutoComplete") : false);
|
||||
dataMap.put("label", item != null && item.getAttributes().getLength() > 0? item.getAttribute("label") : "");
|
||||
dataMap.put("multiAutoComplete", item != null && item.getAttributes().getLength() > 0? item.getAttribute("multiAutoComplete") : false);
|
||||
return dataMap;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -51,8 +51,8 @@ public class ResearcherData extends FieldData<ResearcherData> {
|
|||
@Override
|
||||
public Map<String, Object> toMap(Element item) {
|
||||
HashMap dataMap = new HashMap();
|
||||
dataMap.put("label", item != null ? item.getAttribute("label") : "");
|
||||
dataMap.put("multiAutoComplete", item != null ? item.getAttribute("multiAutoComplete") : false);
|
||||
dataMap.put("label", item != null && item.getAttributes().getLength() > 0 ? item.getAttribute("label") : "");
|
||||
dataMap.put("multiAutoComplete", item != null && item.getAttributes().getLength() > 0 ? item.getAttribute("multiAutoComplete") : false);
|
||||
return dataMap;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -51,8 +51,8 @@ public class ServicesData extends FieldData<ServicesData> {
|
|||
@Override
|
||||
public Map<String, Object> toMap(Element item) {
|
||||
HashMap dataMap = new HashMap();
|
||||
dataMap.put("label", item != null ? item.getAttribute("label") : "");
|
||||
dataMap.put("multiAutoComplete", item != null ? item.getAttribute("multiAutoComplete") : false);
|
||||
dataMap.put("label", item != null && item.getAttributes().getLength() > 0? item.getAttribute("label") : "");
|
||||
dataMap.put("multiAutoComplete", item != null && item.getAttributes().getLength() > 0? item.getAttribute("multiAutoComplete") : false);
|
||||
return dataMap;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,8 +8,8 @@ export class ExternalDatasetsDataEditorModel extends FieldDataEditorModel<Extern
|
|||
|
||||
buildForm(disabled: boolean = false, skipDisable: Array<String> = []): FormGroup {
|
||||
const formGroup = this.formBuilder.group({
|
||||
label: [{ value: this.label, disabled: (disabled && !skipDisable.includes('ServicesDataEditorModel.label')) }],
|
||||
multiAutoComplete: [{ value: this.multiAutoComplete, disabled: (disabled && !skipDisable.includes('ServicesDataEditorModel.multiAutoComplete')) }]
|
||||
label: [{ value: this.label, disabled: (disabled && !skipDisable.includes('ExternalDatasetsDataEditorModel.label')) }],
|
||||
multiAutoComplete: [{ value: this.multiAutoComplete, disabled: (disabled && !skipDisable.includes('ExternalDatasetsDataEditorModel.multiAutoComplete')) }]
|
||||
});
|
||||
return formGroup;
|
||||
}
|
||||
|
|
|
@ -8,8 +8,8 @@ export class RegistriesDataEditorModel extends FieldDataEditorModel<RegistriesDa
|
|||
|
||||
buildForm(disabled: boolean = false, skipDisable: Array<String> = []): FormGroup {
|
||||
const formGroup = this.formBuilder.group({
|
||||
label: [{ value: this.label, disabled: (disabled && !skipDisable.includes('ServicesDataEditorModel.label')) }],
|
||||
multiAutoComplete: [{ value: this.multiAutoComplete, disabled: (disabled && !skipDisable.includes('ServicesDataEditorModel.multiAutoComplete')) }]
|
||||
label: [{ value: this.label, disabled: (disabled && !skipDisable.includes('RegistriesDataEditorModel.label')) }],
|
||||
multiAutoComplete: [{ value: this.multiAutoComplete, disabled: (disabled && !skipDisable.includes('RegistriesDataEditorModel.multiAutoComplete')) }]
|
||||
});
|
||||
return formGroup;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue