From 642f74153c2b27eef9b882abcb16389e35cf14a7 Mon Sep 17 00:00:00 2001 From: Denis Kuchelev Date: Thu, 5 Aug 2021 18:00:57 +0200 Subject: [PATCH] Display labels for categorical parameter values Resolves #72. --- .../details/details.component.html | 8 ++++- .../experiments/details/details.component.ts | 31 ++++++++++++------- hobbit-gui/gui-client/src/app/model.ts | 2 +- .../hobbit/gui/rabbitmq/RdfModelHelper.java | 7 +++++ .../beans/ConfigurationParamValueBean.java | 9 ++++++ parent-pom/pom.xml | 2 +- 6 files changed, 44 insertions(+), 15 deletions(-) diff --git a/hobbit-gui/gui-client/src/app/experiments/details/details.component.html b/hobbit-gui/gui-client/src/app/experiments/details/details.component.html index e789f9b8..9a3bd3d4 100644 --- a/hobbit-gui/gui-client/src/app/experiments/details/details.component.html +++ b/hobbit-gui/gui-client/src/app/experiments/details/details.component.html @@ -42,11 +42,17 @@ -
+
+ +
+ {{row.labels[i]}} +
+
+ {{row.values[i]}} diff --git a/hobbit-gui/gui-client/src/app/experiments/details/details.component.ts b/hobbit-gui/gui-client/src/app/experiments/details/details.component.ts index 570d3cef..e4ec3f49 100644 --- a/hobbit-gui/gui-client/src/app/experiments/details/details.component.ts +++ b/hobbit-gui/gui-client/src/app/experiments/details/details.component.ts @@ -5,7 +5,10 @@ import { Component, OnInit, Input, OnChanges } from '@angular/core'; class TableRow { constructor(public group: string, public kpiSample: ConfigParamRealisation, - public values: Map, public descriptions: Map) { } + public values: Map, + public labels: Map, + public descriptions: Map, + ) { } } @Component({ @@ -110,14 +113,14 @@ export class DetailsComponent implements OnInit, OnChanges { this.rows = []; // FIXME server should send the real experiment URI - this.rows.push(this.buildRow('Experiment', 'URI', 'Permanent URI of the experiment', t => ['http://w3id.org/hobbit/experiments#' + t.id, ''])); + this.rows.push(this.buildRow('Experiment', 'URI', 'Permanent URI of the experiment', t => ['http://w3id.org/hobbit/experiments#' + t.id, '', ''])); this.rows.push(this.buildRow('Experiment', 'Benchmark', 'The benchmark performed', t => DetailsComponent.safeNameAndDescription(t.benchmark))); this.rows.push(this.buildRow('Experiment', 'System', 'The system evaluated', t => DetailsComponent.safeNameAndDescription(t.system))); this.rows.push(this.buildRow('Experiment', 'Challenge Task', 'The challenge task performed', t => DetailsComponent.safeNameAndDescription(t.challengeTask))); if (experiments.some(experiment => experiment.error !== undefined)) { - this.rows.push(this.buildRow('Experiment', 'Error', 'The error message, if an error occured', t => [t.error, ''])); + this.rows.push(this.buildRow('Experiment', 'Error', 'The error message, if an error occured', t => [t.error, '', ''])); } for (const key of Object.keys(experimentParameterSamples)) { @@ -151,16 +154,16 @@ export class DetailsComponent implements OnInit, OnChanges { const name = Object.keys(diagrams)[i]; const row = this.buildRow('Plots', name, diagrams[name], e => { const res = e.diagrams && e.diagrams.find(d => d.name === name); - return [res, name]; + return [res, '', name]; }); this.rows.push(row); } this.rows.push(this.buildRow('Logs', 'Benchmark Log', '', t => [ - t.benchmarkLogAvailable ? [`benchmark/query?id=${t.id}`, `${t.id} benchmark log`] : null, 'Download' + t.benchmarkLogAvailable ? [`benchmark/query?id=${t.id}`, `${t.id} benchmark log`] : null, '', 'Download' ])); this.rows.push(this.buildRow('Logs', 'System Log', '', t => [ - t.systemLogAvailable ? [`system/query?id=${t.id}`, `${t.id} system log`] : null, 'Download' + t.systemLogAvailable ? [`system/query?id=${t.id}`, `${t.id} system log`] : null, '', 'Download' ])); this.rows.sort((a, b) => { @@ -170,33 +173,37 @@ export class DetailsComponent implements OnInit, OnChanges { }); } - private buildRow(group: string, name: string, description: string, selector: (ex: Experiment) => [any, string]): TableRow { + private buildRow(group: string, name: string, description: string, selector: (ex: Experiment) => [any, string, string]): TableRow { return this.buildRowKpi(group, new ConfigParamRealisation('', name, 'xsd.string', '', description), selector); } - private buildRowKpi(group: string, kpi: ConfigParamRealisation, selector: (ex: Experiment) => [any, string]): TableRow { + private buildRowKpi(group: string, kpi: ConfigParamRealisation, selector: (ex: Experiment) => [any, string, string]): TableRow { const values = new Map(); + const labels = new Map(); const descriptions = new Map(); for (let i = 0; i < this.experiments.length; i++) { if (this.experiments[i].benchmark) { - const [name, description] = selector(this.experiments[i]); + const [name, label, description] = selector(this.experiments[i]); values['' + i] = name; + labels['' + i] = label; descriptions['' + i] = description; } } - return new TableRow(group, kpi, values, descriptions); + return new TableRow(group, kpi, values, labels, descriptions); } - static safeNameAndDescription(entity: NamedEntity): [string, string] { + static safeNameAndDescription(entity: NamedEntity): [string, string, string] { return [ (entity && entity.name) ? entity.name : '', + '', (entity && entity.description) ? entity.description : '' ]; } - static safeValueAndDescription(pv: ConfigParamRealisation): [string, string] { + static safeValueAndDescription(pv: ConfigParamRealisation): [string, string, string] { return [ (pv && pv.value) ? pv.value : '', + (pv && pv.label) ? pv.label : '', (pv && pv.description) ? pv.description : ((pv && pv.name) ? pv.name : '') ]; } diff --git a/hobbit-gui/gui-client/src/app/model.ts b/hobbit-gui/gui-client/src/app/model.ts index 8bb5a3a1..e735120b 100644 --- a/hobbit-gui/gui-client/src/app/model.ts +++ b/hobbit-gui/gui-client/src/app/model.ts @@ -109,7 +109,7 @@ export class ConfigParamDefinition extends ConfigParam { export class ConfigParamRealisation extends ConfigParam { constructor(id: string, name: string, datatype: string, - public value: string, description?: string, range?: string) { + public value: string, public label?: string, description?: string, range?: string) { super(id, name, datatype, description, range); } } diff --git a/hobbit-gui/gui-serverbackend/src/main/java/de/usu/research/hobbit/gui/rabbitmq/RdfModelHelper.java b/hobbit-gui/gui-serverbackend/src/main/java/de/usu/research/hobbit/gui/rabbitmq/RdfModelHelper.java index 48a33a65..b9ce189d 100644 --- a/hobbit-gui/gui-serverbackend/src/main/java/de/usu/research/hobbit/gui/rabbitmq/RdfModelHelper.java +++ b/hobbit-gui/gui-serverbackend/src/main/java/de/usu/research/hobbit/gui/rabbitmq/RdfModelHelper.java @@ -526,6 +526,13 @@ private static void createParamValueBeans(Model model, Resource taskResource, Re ConfigurationParamValueBean paramBean = new ConfigurationParamValueBean(); paramBean.setId(parameterUri); paramBean.setValue(RdfHelper.getStringValue(model, taskResource, paraProp)); + Resource valueResource = RdfHelper.getObjectResource(model, taskResource, paraProp); + if (valueResource != null) { + String label = RdfHelper.getLabel(model, valueResource); + if (label != null) { + paramBean.setLabel(label); + } + } paramBean.setName(RdfHelper.getLabel(model, paraProp)); if (paramBean.getName() == null) { diff --git a/hobbit-gui/gui-serverbackend/src/main/java/de/usu/research/hobbit/gui/rest/beans/ConfigurationParamValueBean.java b/hobbit-gui/gui-serverbackend/src/main/java/de/usu/research/hobbit/gui/rest/beans/ConfigurationParamValueBean.java index 4f3a9a14..82976829 100644 --- a/hobbit-gui/gui-serverbackend/src/main/java/de/usu/research/hobbit/gui/rest/beans/ConfigurationParamValueBean.java +++ b/hobbit-gui/gui-serverbackend/src/main/java/de/usu/research/hobbit/gui/rest/beans/ConfigurationParamValueBean.java @@ -27,6 +27,7 @@ public class ConfigurationParamValueBean extends NamedEntityBean { private Datatype datatype; private String value; private String range; + private String label; public Datatype getDatatype() { return datatype; @@ -57,4 +58,12 @@ public void setRange(String range) { this.range = range; } + public String getLabel() { + return label; + } + + public void setLabel(String label) { + this.label = label; + } + } diff --git a/parent-pom/pom.xml b/parent-pom/pom.xml index 4656ade5..f5649855 100644 --- a/parent-pom/pom.xml +++ b/parent-pom/pom.xml @@ -68,7 +68,7 @@ org.hobbit core - 1.0.19 + 1.0.22-SNAPSHOT