From 92f6674bfcab9c0362da11b2b0be25c71557fd97 Mon Sep 17 00:00:00 2001 From: "Christian P. MOMON" Date: Sun, 24 Jul 2022 11:24:28 +0200 Subject: [PATCH] Improved date management. --- .../devinsy/statoolinfos/core/Federation.java | 24 +++++++++ .../statoolinfos/core/Organization.java | 49 +++++++++++++++++++ src/fr/devinsy/statoolinfos/core/Service.java | 49 +++++++++++++++++++ .../statoolinfos/htmlize/ChartHtmlizer.java | 45 ++++++++++++----- 4 files changed, 155 insertions(+), 12 deletions(-) diff --git a/src/fr/devinsy/statoolinfos/core/Federation.java b/src/fr/devinsy/statoolinfos/core/Federation.java index 4c50b09..d68e3f4 100644 --- a/src/fr/devinsy/statoolinfos/core/Federation.java +++ b/src/fr/devinsy/statoolinfos/core/Federation.java @@ -23,6 +23,7 @@ import java.net.MalformedURLException; import java.net.URL; import java.time.LocalDate; import java.time.LocalDateTime; +import java.time.Year; import org.apache.commons.lang3.StringUtils; @@ -604,6 +605,29 @@ public class Federation extends PathPropertyList return result; } + /** + * Gets the start year. + * + * @return the start year + */ + public Year getStartYear() + { + Year result; + + LocalDate date = getStartDate(); + if (date == null) + { + result = null; + } + else + { + result = Year.from(date); + } + + // + return result; + } + /** * Gets the technical doc website. * diff --git a/src/fr/devinsy/statoolinfos/core/Organization.java b/src/fr/devinsy/statoolinfos/core/Organization.java index 69d0468..8d242cd 100644 --- a/src/fr/devinsy/statoolinfos/core/Organization.java +++ b/src/fr/devinsy/statoolinfos/core/Organization.java @@ -22,6 +22,7 @@ import java.io.File; import java.net.URL; import java.time.LocalDate; import java.time.LocalDateTime; +import java.time.Year; import org.apache.commons.codec.digest.DigestUtils; import org.apache.commons.lang3.StringUtils; @@ -294,6 +295,30 @@ public class Organization extends PathPropertyList return result; } + /** + * Gets the end year. + * + * @return the end year + */ + public Year getEndYear() + { + Year result; + + LocalDate date = getEndDate(); + + if (date == null) + { + result = null; + } + else + { + result = Year.from(date); + } + + // + return result; + } + public Federation getFederation() { return this.federation; @@ -780,6 +805,30 @@ public class Organization extends PathPropertyList return result; } + /** + * Gets the start year. + * + * @return the start year + */ + public Year getStartYear() + { + Year result; + + LocalDate date = getStartDate(); + + if (date == null) + { + result = null; + } + else + { + result = Year.from(date); + } + + // + return result; + } + /** * Gets the status. * diff --git a/src/fr/devinsy/statoolinfos/core/Service.java b/src/fr/devinsy/statoolinfos/core/Service.java index e3b4c66..d93d92f 100644 --- a/src/fr/devinsy/statoolinfos/core/Service.java +++ b/src/fr/devinsy/statoolinfos/core/Service.java @@ -22,6 +22,7 @@ import java.io.File; import java.net.URL; import java.time.LocalDate; import java.time.LocalDateTime; +import java.time.Year; import java.time.YearMonth; import org.apache.commons.codec.digest.DigestUtils; @@ -272,6 +273,30 @@ public class Service extends PathPropertyList return result; } + /** + * Gets the end year. + * + * @return the end year + */ + public Year getEndYear() + { + Year result; + + LocalDate date = getEndDate(); + + if (date == null) + { + result = null; + } + else + { + result = Year.from(date); + } + + // + return result; + } + /** * Gets the host name. * @@ -888,6 +913,30 @@ public class Service extends PathPropertyList return result; } + /** + * Gets the start year. + * + * @return the start year + */ + public Year getStartYear() + { + Year result; + + LocalDate date = getStartDate(); + + if (date == null) + { + result = null; + } + else + { + result = Year.from(date); + } + + // + return result; + } + /** * Gets the status. * diff --git a/src/fr/devinsy/statoolinfos/htmlize/ChartHtmlizer.java b/src/fr/devinsy/statoolinfos/htmlize/ChartHtmlizer.java index 2f5e321..cf4d63e 100644 --- a/src/fr/devinsy/statoolinfos/htmlize/ChartHtmlizer.java +++ b/src/fr/devinsy/statoolinfos/htmlize/ChartHtmlizer.java @@ -38,7 +38,6 @@ import fr.devinsy.statoolinfos.core.Organizations; 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.statoolinfos.htmlize.charts.BarChart; import fr.devinsy.statoolinfos.htmlize.charts.BarChartView; import fr.devinsy.statoolinfos.htmlize.charts.ChartColor; @@ -1452,7 +1451,7 @@ public class ChartHtmlizer { String result; - result = htmlizeServiceCountYearChart(federation.getServices(), federation.getStartDate().getYear()); + result = htmlizeServiceCountYearChart(federation.getServices(), federation.getStartYear()); // return result; @@ -1471,16 +1470,7 @@ public class ChartHtmlizer { String result; - LocalDate startDate = organization.getFederation().getStartDate(); - - if (startDate == null) - { - result = null; - } - else - { - result = htmlizeServiceCountYearChart(organization.getServices(), startDate.getYear()); - } + result = htmlizeServiceCountYearChart(organization.getServices(), organization.getFederation().getStartYear()); // return result; @@ -1583,6 +1573,37 @@ public class ChartHtmlizer return result; } + /** + * Htmlize service count year chart. + * + * @param services + * the services + * @param first + * the first + * @return the string + * @throws StatoolInfosException + * the statool infos exception + */ + public static String htmlizeServiceCountYearChart(final Services services, final Year first) throws StatoolInfosException + { + String result; + + Integer value; + if (first == null) + { + value = null; + } + else + { + value = first.getValue(); + } + + result = htmlizeServiceCountYearChart(services, value); + + // + return result; + } + /** * Htmlize service date status chart. *