From 1d36510ac39939e6f2c01722c149d23e85729970 Mon Sep 17 00:00:00 2001 From: "Christian P. MOMON" Date: Fri, 21 Jan 2022 00:31:33 +0100 Subject: [PATCH] Replaced 0 value with emoji in tables. --- .../statoolinfos/core/StatoolInfosUtils.java | 26 +++++++++++++++++++ .../htmlize/OrganizationListView.java | 7 ++--- .../statoolinfos/htmlize/ServiceListView.java | 6 ++--- 3 files changed, 33 insertions(+), 6 deletions(-) diff --git a/src/fr/devinsy/statoolinfos/core/StatoolInfosUtils.java b/src/fr/devinsy/statoolinfos/core/StatoolInfosUtils.java index 2aba2a7..529ed25 100644 --- a/src/fr/devinsy/statoolinfos/core/StatoolInfosUtils.java +++ b/src/fr/devinsy/statoolinfos/core/StatoolInfosUtils.java @@ -65,6 +65,32 @@ public class StatoolInfosUtils public static final DateTimeFormatter PATTERN_SHORTDATE = DateTimeFormatter.ofPattern("dd/MM/yyyy", Locale.FRANCE); public static final DateTimeFormatter PATTERN_LONGDATE = DateTimeFormatter.ofPattern("dd/MM/yyyy HH':'mm", Locale.FRANCE); + /** + * Default if zero. + * + * @param value + * the value + * @param defaultValue + * the default value + * @return the string + */ + public static String defaultIfZero(final long value, final String defaultValue) + { + String result; + + if (value == 0) + { + result = defaultValue; + } + else + { + result = String.valueOf(value); + } + + // + return result; + } + /** * Epoch to local date time. * diff --git a/src/fr/devinsy/statoolinfos/htmlize/OrganizationListView.java b/src/fr/devinsy/statoolinfos/htmlize/OrganizationListView.java index 056aa87..0fea56b 100644 --- a/src/fr/devinsy/statoolinfos/htmlize/OrganizationListView.java +++ b/src/fr/devinsy/statoolinfos/htmlize/OrganizationListView.java @@ -28,6 +28,7 @@ import org.slf4j.LoggerFactory; import fr.devinsy.statoolinfos.core.Organization; import fr.devinsy.statoolinfos.core.Organizations; import fr.devinsy.statoolinfos.core.StatoolInfosException; +import fr.devinsy.statoolinfos.core.StatoolInfosUtils; import fr.devinsy.xidyn.XidynException; import fr.devinsy.xidyn.data.TagDataManager; import fr.devinsy.xidyn.presenters.PresenterUtils; @@ -78,9 +79,9 @@ public class OrganizationListView data.setEscapedContent("organizationListLine", index, "organizationListLineUrlLink", organization.getWebsiteURL().toString()); data.setEscapedAttribute("organizationListLine", index, "organizationListLineUrlLink", "href", organization.getWebsiteURL().toString()); } - data.setContent("organizationListLine", index, "organizationListLineServiceCount", organization.getServiceActiveCount()); - data.setContent("organizationListLine", index, "organizationListLineUserCount", organization.getPreviousMonthUserCount()); - data.setContent("organizationListLine", index, "organizationListLineVisitCount", organization.getPreviousMonthVisitCount()); + data.setContent("organizationListLine", index, "organizationListLineServiceCount", StatoolInfosUtils.defaultIfZero(organization.getServiceActiveCount(), "😿")); + data.setContent("organizationListLine", index, "organizationListLineUserCount", StatoolInfosUtils.defaultIfZero(organization.getPreviousMonthUserCount(), "😢")); + data.setContent("organizationListLine", index, "organizationListLineVisitCount", StatoolInfosUtils.defaultIfZero(organization.getPreviousMonthVisitCount(), "😞")); data.setContent("organizationListLine", index, "organizationListLineDate", organization.getCrawledDate().format(DateTimeFormatter.ofPattern("dd/MM/YYYY"))); data.setAttribute("organizationListLine", index, "organizationListLineDate", "title", organization.getCrawledDate().format(DateTimeFormatter.ofPattern("HH:mm:ss"))); diff --git a/src/fr/devinsy/statoolinfos/htmlize/ServiceListView.java b/src/fr/devinsy/statoolinfos/htmlize/ServiceListView.java index 3ff1ba7..780f0ae 100644 --- a/src/fr/devinsy/statoolinfos/htmlize/ServiceListView.java +++ b/src/fr/devinsy/statoolinfos/htmlize/ServiceListView.java @@ -27,6 +27,7 @@ import org.slf4j.LoggerFactory; import fr.devinsy.statoolinfos.core.Service; import fr.devinsy.statoolinfos.core.Services; import fr.devinsy.statoolinfos.core.StatoolInfosException; +import fr.devinsy.statoolinfos.core.StatoolInfosUtils; import fr.devinsy.xidyn.XidynException; import fr.devinsy.xidyn.data.DisplayMode; import fr.devinsy.xidyn.data.TagDataManager; @@ -88,9 +89,8 @@ public class ServiceListView data.setEscapedContent("serviceListLine", index, "serviceListLineSoftwareLink", service.getSoftwareName()); data.setAttribute("serviceListLine", index, "serviceListLineSoftwareLink", "href", "software-" + service.getSoftwareTechnicalName() + ".xhtml"); - data.setContent("serviceListLine", index, "serviceListLineUserCount", service.getPreviousMonthUserCount()); - - data.setContent("serviceListLine", index, "serviceListLineVisitCount", service.getPreviousMonthVisitCount()); + data.setContent("serviceListLine", index, "serviceListLineUserCount", StatoolInfosUtils.defaultIfZero(service.getPreviousMonthUserCount(), "😞")); + data.setContent("serviceListLine", index, "serviceListLineVisitCount", StatoolInfosUtils.defaultIfZero(service.getPreviousMonthVisitCount(), "😢")); data.setEscapedContent("serviceListLine", index, "serviceListLineDate", service.getCrawledDate().format(DateTimeFormatter.ofPattern("dd/MM/YYYY"))); data.setEscapedAttribute("serviceListLine", index, "serviceListLineDate", "title", service.getCrawledDate().format(DateTimeFormatter.ofPattern("HH:mm:ss")));