From f23834d8e32fff199e59fd19bc5e172780ff8d80 Mon Sep 17 00:00:00 2001 From: "Christian P. MOMON" Date: Sun, 24 Jul 2022 10:49:28 +0200 Subject: [PATCH] Improved Federation getStartDate management. --- .../devinsy/statoolinfos/core/Federation.java | 18 +++++++++++++++++- .../statoolinfos/htmlize/ChartHtmlizer.java | 9 ++++----- .../htmlize/FederationHeaderView.java | 4 ++-- 3 files changed, 23 insertions(+), 8 deletions(-) diff --git a/src/fr/devinsy/statoolinfos/core/Federation.java b/src/fr/devinsy/statoolinfos/core/Federation.java index 13293d9..4c50b09 100644 --- a/src/fr/devinsy/statoolinfos/core/Federation.java +++ b/src/fr/devinsy/statoolinfos/core/Federation.java @@ -21,6 +21,7 @@ package fr.devinsy.statoolinfos.core; import java.io.File; import java.net.MalformedURLException; import java.net.URL; +import java.time.LocalDate; import java.time.LocalDateTime; import org.apache.commons.lang3.StringUtils; @@ -578,7 +579,22 @@ public class Federation extends PathPropertyList * * @return the start date */ - public String getStartDate() + public LocalDate getStartDate() + { + LocalDate result; + + result = StatoolInfosUtils.parseDate(getStartDateValue()); + + // + return result; + } + + /** + * Gets the start date. + * + * @return the start date + */ + public String getStartDateValue() { String result; diff --git a/src/fr/devinsy/statoolinfos/htmlize/ChartHtmlizer.java b/src/fr/devinsy/statoolinfos/htmlize/ChartHtmlizer.java index f4ab5c6..4b3419f 100644 --- a/src/fr/devinsy/statoolinfos/htmlize/ChartHtmlizer.java +++ b/src/fr/devinsy/statoolinfos/htmlize/ChartHtmlizer.java @@ -1267,8 +1267,7 @@ public class ChartHtmlizer { String result; - result = htmlizeServiceCountMonthChart(federation.getServicesAll(), - YearMonth.from(StatoolInfosUtils.parseDate(federation.getStartDate()))); + result = htmlizeServiceCountMonthChart(federation.getServicesAll(), YearMonth.from(federation.getStartDate())); // return result; @@ -1287,7 +1286,7 @@ public class ChartHtmlizer { String result; - LocalDate startDate = StatoolInfosUtils.parseDate(organization.getFederation().getStartDate()); + LocalDate startDate = organization.getFederation().getStartDate(); if (startDate == null) { @@ -1453,7 +1452,7 @@ public class ChartHtmlizer { String result; - result = htmlizeServiceCountYearChart(federation.getServices(), StatoolInfosUtils.parseDate(federation.getStartDate()).getYear()); + result = htmlizeServiceCountYearChart(federation.getServices(), federation.getStartDate().getYear()); // return result; @@ -1472,7 +1471,7 @@ public class ChartHtmlizer { String result; - LocalDate startDate = StatoolInfosUtils.parseDate(organization.getFederation().getStartDate()); + LocalDate startDate = organization.getFederation().getStartDate(); if (startDate == null) { diff --git a/src/fr/devinsy/statoolinfos/htmlize/FederationHeaderView.java b/src/fr/devinsy/statoolinfos/htmlize/FederationHeaderView.java index cd15008..85c9238 100644 --- a/src/fr/devinsy/statoolinfos/htmlize/FederationHeaderView.java +++ b/src/fr/devinsy/statoolinfos/htmlize/FederationHeaderView.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2020-2021 Christian Pierre MOMON + * Copyright (C) 2020-2022 Christian Pierre MOMON * * This file is part of StatoolInfos, simple service statistics tool. * @@ -69,7 +69,7 @@ public class FederationHeaderView data.setEscapedContent("federationURL", federation.getWebsiteURL().toString()); data.setEscapedAttribute("federationURL", "href", federation.getWebsiteURL().toString()); } - data.setContent("federationStartDate", StringUtils.defaultIfBlank(federation.getStartDate(), "n/a")); + data.setContent("federationStartDate", StringUtils.defaultIfBlank(federation.getStartDateValue(), "n/a")); data.setAttribute("organizationsLink", "href", federation.getTechnicalName() + "-organizations.xhtml"); data.setAttribute("servicesLink", "href", federation.getTechnicalName() + "-services.xhtml");