From 04aed10a38f4061f34a2430901d74401f573d9bb Mon Sep 17 00:00:00 2001 From: "Christian P. MOMON" Date: Sun, 24 Jul 2022 11:01:46 +0200 Subject: [PATCH] Improved startDate and endDate management for services. --- src/fr/devinsy/statoolinfos/core/Service.java | 41 +++++++++++++++---- .../statoolinfos/htmlize/ChartHtmlizer.java | 14 +++---- .../htmlize/ServiceHeaderView.java | 8 ++-- 3 files changed, 45 insertions(+), 18 deletions(-) diff --git a/src/fr/devinsy/statoolinfos/core/Service.java b/src/fr/devinsy/statoolinfos/core/Service.java index f8dc55b..e3b4c66 100644 --- a/src/fr/devinsy/statoolinfos/core/Service.java +++ b/src/fr/devinsy/statoolinfos/core/Service.java @@ -136,10 +136,7 @@ public class Service extends PathPropertyList { String result; - LocalDate startDate = StatoolInfosUtils.parseDate(getStartDate()); - LocalDate endDate = StatoolInfosUtils.parseDate(getEndDate()); - - result = StatoolInfosUtils.toHumanDuration(startDate, endDate); + result = StatoolInfosUtils.toHumanDuration(getStartDate(), getEndDate()); // return result; @@ -250,7 +247,22 @@ public class Service extends PathPropertyList * * @return the end date */ - public String getEndDate() + public LocalDate getEndDate() + { + LocalDate result; + + result = StatoolInfosUtils.parseDate(getEndDateValue()); + + // + return result; + } + + /** + * Gets the end date value. + * + * @return the end date value + */ + public String getEndDateValue() { String result; @@ -851,7 +863,22 @@ public class Service extends PathPropertyList * * @return the start date */ - public String getStartDate() + public LocalDate getStartDate() + { + LocalDate result; + + result = StatoolInfosUtils.parseDate(getStartDateValue()); + + // + return result; + } + + /** + * Gets the start date value. + * + * @return the start date value + */ + public String getStartDateValue() { String result; @@ -1056,7 +1083,7 @@ public class Service extends PathPropertyList { boolean result; - if (getEndDate() == null) + if (getEndDateValue() == null) { result = false; } diff --git a/src/fr/devinsy/statoolinfos/htmlize/ChartHtmlizer.java b/src/fr/devinsy/statoolinfos/htmlize/ChartHtmlizer.java index 4b3419f..2f5e321 100644 --- a/src/fr/devinsy/statoolinfos/htmlize/ChartHtmlizer.java +++ b/src/fr/devinsy/statoolinfos/htmlize/ChartHtmlizer.java @@ -1317,7 +1317,7 @@ public class ChartHtmlizer YearMonth first = null; for (Service service : services) { - LocalDate date = StatoolInfosUtils.parseDate(service.getStartDate()); + LocalDate date = service.getStartDate(); if (date != null) { YearMonth current = YearMonth.from(date); @@ -1361,8 +1361,8 @@ public class ChartHtmlizer long count = 0; for (Service service : services) { - LocalDate startDate = StatoolInfosUtils.parseDate(service.getStartDate()); - LocalDate endDate = StatoolInfosUtils.parseDate(service.getEndDate()); + LocalDate startDate = service.getStartDate(); + LocalDate endDate = service.getEndDate(); if (startDate != null) { @@ -1502,7 +1502,7 @@ public class ChartHtmlizer Integer first = null; for (Service service : services) { - LocalDate date = StatoolInfosUtils.parseDate(service.getStartDate()); + LocalDate date = service.getStartDate(); if (date != null) { int current = date.getYear(); @@ -1548,8 +1548,8 @@ public class ChartHtmlizer long count = 0; for (Service service : services) { - LocalDate startDate = StatoolInfosUtils.parseDate(service.getStartDate()); - LocalDate endDate = StatoolInfosUtils.parseDate(service.getEndDate()); + LocalDate startDate = service.getStartDate(); + LocalDate endDate = service.getEndDate(); if (startDate != null) { @@ -1602,7 +1602,7 @@ public class ChartHtmlizer long unfilled = 0; for (Service service : services) { - if (StatoolInfosUtils.parseDate(service.getStartDate()) == null) + if (service.getStartDate() == null) { unfilled += 1; } diff --git a/src/fr/devinsy/statoolinfos/htmlize/ServiceHeaderView.java b/src/fr/devinsy/statoolinfos/htmlize/ServiceHeaderView.java index 14f276b..f4f3fdd 100644 --- a/src/fr/devinsy/statoolinfos/htmlize/ServiceHeaderView.java +++ b/src/fr/devinsy/statoolinfos/htmlize/ServiceHeaderView.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,10 +69,10 @@ public class ServiceHeaderView data.setEscapedContent("serviceDescription", StringUtils.defaultIfBlank(service.getDescription(), "n/a")); - data.setContent("serviceStartDate", StringUtils.defaultIfBlank(service.getStartDate(), "n/a")); - data.setContent("serviceEndDate", StringUtils.defaultIfBlank(service.getEndDate(), "n/a")); + data.setContent("serviceStartDate", StringUtils.defaultIfBlank(service.getStartDateValue(), "n/a")); + data.setContent("serviceEndDate", StringUtils.defaultIfBlank(service.getEndDateValue(), "n/a")); data.setContent("serviceAge", StringUtils.defaultIfBlank(service.getAge(), "n/a")); - if (StringUtils.isBlank(service.getEndDate())) + if (StringUtils.isBlank(service.getEndDateValue())) { data.setAttribute("serviceEndDateData", "style", "display: none;"); }