From 0caec170a0c8c3f84d82558cbb9e3c6b8a960fd4 Mon Sep 17 00:00:00 2001 From: "Goulven.Furet" Date: Thu, 19 Oct 2023 23:13:26 +0200 Subject: [PATCH] tooltip on unmatched attributes --- .../model/product/AggregatedAttribute.java | 40 +++++++++++++++++++ .../resources/i18n/messages_fr.properties | 2 + .../inc/product-unmatched-attributes.html | 19 ++++++--- 3 files changed, 56 insertions(+), 5 deletions(-) diff --git a/commons/src/main/java/org/open4goods/model/product/AggregatedAttribute.java b/commons/src/main/java/org/open4goods/model/product/AggregatedAttribute.java index 9268ba8ed..7cafa228e 100644 --- a/commons/src/main/java/org/open4goods/model/product/AggregatedAttribute.java +++ b/commons/src/main/java/org/open4goods/model/product/AggregatedAttribute.java @@ -48,7 +48,47 @@ public class AggregatedAttribute implements IAttribute { private Set sources = new HashSet<>(); + /** + * Number of sources for this attribute + * @return + */ + public int sourcesCount() { + return sources.size(); + } + + /** + * The number of different values for this item + * @return + */ + public long distinctValues () { + return sources.stream().map(e-> e.getValue()).distinct().count(); + } + + public boolean hasConflicts() { + return distinctValues() > 1; + } + + public String bgRow() { + String ret="table-default"; + int sCount = sourcesCount(); + long dValues = distinctValues(); + + if (sCount == 0) { + ret="table-danger"; + } else if (sCount == 1) { + ret="table-default"; + } else { + ret="table-info"; + } + + if (dValues > 1) { + ret = "table-danger"; + } + + return ret; + } + // TODO : Simple, but does not allow to handle conflicts, and so on @Override public int hashCode() { diff --git a/ui/src/main/resources/i18n/messages_fr.properties b/ui/src/main/resources/i18n/messages_fr.properties index f232092a8..5340f5e9c 100644 --- a/ui/src/main/resources/i18n/messages_fr.properties +++ b/ui/src/main/resources/i18n/messages_fr.properties @@ -1,3 +1,5 @@ +attribute.sourcing = {0} source(s) de donnée(s), {1} conflit(s) + ecoscore.WARRANTY.tooltip = La garantie est de {0} an(s). ecoscore.DATA-QUALITY.tooltip = La qualité de la donnée est de {1} sur 5. ecoscore.REPAIRABILITY_INDEX.tooltip = L''indice de réparabilité est de {0} sur 10 ({1}/5 en valeur relative). diff --git a/ui/src/main/resources/templates/inc/product-unmatched-attributes.html b/ui/src/main/resources/templates/inc/product-unmatched-attributes.html index edd0a4c99..c80a0acb7 100644 --- a/ui/src/main/resources/templates/inc/product-unmatched-attributes.html +++ b/ui/src/main/resources/templates/inc/product-unmatched-attributes.html @@ -1,7 +1,7 @@

Toutes les caractéristiques

- +
@@ -10,10 +10,19 @@ - - - - + + + + + + + + + + + + +
Nom