Adds "source" property on external autocomplete field of Dataset Description Template.

This commit is contained in:
gkolokythas 2019-09-10 18:30:46 +03:00
parent 0db79b9498
commit bd6170f711
7 changed files with 29 additions and 9 deletions

View File

@ -111,8 +111,8 @@ public class DatasetProfileManager {
ResponseEntity<Object> response = restTemplate.exchange(data.getUrl() + "?search=" + like, HttpMethod.GET, entity, Object.class);
DocumentContext jsonContext = JsonPath.parse(response.getBody());
List<Map<String, String>> jsonItems = jsonContext.read(data.getOptionsRoot() + "['" + data.getAutoCompleteOptions().getLabel() + "','" + data.getAutoCompleteOptions().getValue() + "']");
jsonItems.forEach(item -> result.add(new ExternalAutocompleteFieldModel(item.get(data.getAutoCompleteOptions().getValue()), item.get(data.getAutoCompleteOptions().getLabel()), data.getUrl())));
List<Map<String, String>> jsonItems = jsonContext.read(data.getOptionsRoot() + "['" + data.getAutoCompleteOptions().getLabel() + "','" + data.getAutoCompleteOptions().getValue() + "','" + data.getAutoCompleteOptions().getSource() + "']");
jsonItems.forEach(item -> result.add(new ExternalAutocompleteFieldModel(item.get(data.getAutoCompleteOptions().getValue()), item.get(data.getAutoCompleteOptions().getLabel()), item.get(data.getAutoCompleteOptions().getSource()))));
return result;
}

View File

@ -46,6 +46,7 @@ public class AutoCompleteData extends ComboBoxData<AutoCompleteData> {
Element element = doc.createElement("option");
element.setAttribute("label", this.autoCompleteOptions.getLabel());
element.setAttribute("value", autoCompleteOptions.getValue());
element.setAttribute("source", autoCompleteOptions.getSource());
root.appendChild(element);
return root;
}
@ -61,6 +62,7 @@ public class AutoCompleteData extends ComboBoxData<AutoCompleteData> {
this.autoCompleteOptions = new Option();
this.autoCompleteOptions.setLabel(optionElement.getAttribute("label"));
this.autoCompleteOptions.setValue(optionElement.getAttribute("value"));
this.autoCompleteOptions.setSource(optionElement.getAttribute("source"));
}
return this;
}
@ -77,6 +79,7 @@ public class AutoCompleteData extends ComboBoxData<AutoCompleteData> {
if (options != null) {
this.autoCompleteOptions.setLabel(options.get("label"));
this.autoCompleteOptions.setValue(options.get("value"));
this.autoCompleteOptions.setSource(options.get("source"));
}
}
@ -110,6 +113,7 @@ public class AutoCompleteData extends ComboBoxData<AutoCompleteData> {
HashMap dataMap = new HashMap();
dataMap.put("label", item != null ? item.getAttribute("label") : "");
dataMap.put("value", item != null ? item.getAttribute("value") : "");
dataMap.put("source", item != null ? item.getAttribute("source") : "");
return dataMap;
}
}

View File

@ -11,11 +11,11 @@ public abstract class ComboBoxData<T> extends FieldData<T> {
public class Option implements XmlSerializable<Option> {
private String label;
private String value;
private String source;
public String getLabel() {
return label;
}
public void setLabel(String label) {
this.label = label;
}
@ -23,16 +23,23 @@ public abstract class ComboBoxData<T> extends FieldData<T> {
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
public String getSource() {
return source;
}
public void setSource(String source) {
this.source = source;
}
@Override
public Element toXml(Document doc) {
Element option = doc.createElement("option");
option.setAttribute("label", this.label);
option.setAttribute("value", this.value);
option.setAttribute("source", this.source);
return option;
}
@ -40,6 +47,7 @@ public abstract class ComboBoxData<T> extends FieldData<T> {
public Option fromXml(Element item) {
this.label = item.getAttribute("label");
this.value = item.getAttribute("value");
this.source = item.getAttribute("source");
return this;
}

View File

@ -41,6 +41,7 @@ export interface WordListFieldData extends FieldData {
export interface FieldDataOption extends FieldData {
label: string;
value: string;
source: string;
}
export interface DatePickerFieldData extends FieldData {

View File

@ -5,17 +5,20 @@ import { FieldDataEditorModel } from './field-data-editor-model';
export class FieldDataOptionEditorModel extends FieldDataEditorModel<FieldDataOptionEditorModel> {
public label: string;
public value: string;
public source: string;
buildForm(disabled: boolean = false, skipDisable: Array<String> = []): FormGroup {
return new FormBuilder().group({
label: [{ value: this.label, disabled: (disabled && !skipDisable.includes('FieldDataOptionEditorModel.label')) }],
value: [{ value: this.value, disabled: (disabled && !skipDisable.includes('FieldDataOptionEditorModel.value')) }]
value: [{ value: this.value, disabled: (disabled && !skipDisable.includes('FieldDataOptionEditorModel.value')) }],
source: [{ value: this.source, disabled: (disabled && !skipDisable.includes('FieldDataOptionEditorModel.source')) }]
});
}
fromModel(item: FieldDataOption): FieldDataOptionEditorModel {
this.label = item.label;
this.value = item.value;
this.source = item.source;
return this;
}
}

View File

@ -12,14 +12,17 @@
<mat-form-field class="col-md-12">
<input matInput placeholder="{{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-AUTOCOMPLETE-URL' | translate}}" [formControl]="this.form.get('data').get('url')">
</mat-form-field>
<mat-form-field class="col-md-4">
<mat-form-field class="col-md-3">
<input matInput placeholder="{{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-AUTOCOMPLETE-OPTIONS-ROOT' | translate}}"
[formControl]="this.form.get('data').get('optionsRoot')">
</mat-form-field>
<mat-form-field class="col-md-4">
<mat-form-field class="col-md-3">
<input matInput placeholder="{{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-AUTOCOMPLETE-LABEL' | translate}}" [formControl]="this.form.get('data').get('autoCompleteOptions').get('label')">
</mat-form-field>
<mat-form-field class="col-md-4">
<mat-form-field class="col-md-3">
<input matInput placeholder="{{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-AUTOCOMPLETE-VALUE' | translate}}" [formControl]="this.form.get('data').get('autoCompleteOptions').get('value')">
</mat-form-field>
<mat-form-field class="col-md-3">
<input matInput placeholder="{{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-AUTOCOMPLETE-SOURCE' | translate}}" [formControl]="this.form.get('data').get('autoCompleteOptions').get('source')">
</mat-form-field>
</div>

View File

@ -223,6 +223,7 @@
"FIELD-AUTOCOMPLETE-PLACEHOLDER": "Input Placeholder",
"FIELD-AUTOCOMPLETE-LABEL": "Label",
"FIELD-AUTOCOMPLETE-VALUE": "Value",
"FIELD-AUTOCOMPLETE-SOURCE": "Source",
"FIELD-AUTOCOMPLETE-URL": "Url",
"FIELD-AUTOCOMPLETE-OPTIONS-ROOT": "Options Root",
"FIELD-DATE-PICKER-TITLE": "Date Picker",
@ -347,7 +348,7 @@
"EDITOR": {
"FIELDS": {
"EXTERNAL-DATASET-TYPE": "Type",
"EXTERNAL-AUTOCOMPLETE-SUBTITLE": "External url: "
"EXTERNAL-AUTOCOMPLETE-SUBTITLE": "Source: "
}
},
"FIRST-STEP": {