From 8712c998949ad67fdea4a3566c0d7c867345f6cc Mon Sep 17 00:00:00 2001 From: "Christian P. MOMON" Date: Sun, 24 Jul 2022 10:55:50 +0200 Subject: [PATCH] Improved startDate and endDate management for organizations. --- .../statoolinfos/core/Organization.java | 41 +++++++++++++++---- .../htmlize/OrganizationHeaderView.java | 8 ++-- .../devinsy/statoolinfos/stats/StatAgent.java | 4 +- 3 files changed, 40 insertions(+), 13 deletions(-) diff --git a/src/fr/devinsy/statoolinfos/core/Organization.java b/src/fr/devinsy/statoolinfos/core/Organization.java index e8c898f..69d0468 100644 --- a/src/fr/devinsy/statoolinfos/core/Organization.java +++ b/src/fr/devinsy/statoolinfos/core/Organization.java @@ -148,10 +148,7 @@ public class Organization 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; @@ -272,7 +269,22 @@ public class Organization extends PathPropertyList * * @return the end date */ - public String getEndDate() + public LocalDate getEndDate() + { + LocalDate result; + + result = StatoolInfosUtils.parseDate(getEndDateValue()); + + // + return result; + } + + /** + * Gets the end date. + * + * @return the end date + */ + public String getEndDateValue() { String result; @@ -743,7 +755,22 @@ public class Organization 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; @@ -1112,7 +1139,7 @@ public class Organization extends PathPropertyList { boolean result; - if ((getServiceCount() == 0) && (getLogoURLValue() == null) && (getStartDate() == null)) + if ((getServiceCount() == 0) && (getLogoURLValue() == null) && (getStartDateValue() == null)) { result = true; } diff --git a/src/fr/devinsy/statoolinfos/htmlize/OrganizationHeaderView.java b/src/fr/devinsy/statoolinfos/htmlize/OrganizationHeaderView.java index e8e0bac..e822e27 100644 --- a/src/fr/devinsy/statoolinfos/htmlize/OrganizationHeaderView.java +++ b/src/fr/devinsy/statoolinfos/htmlize/OrganizationHeaderView.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 Christian Pierre MOMON + * Copyright (C) 2021-2022 Christian Pierre MOMON * * This file is part of StatoolInfos, simple service statistics tool. * @@ -71,10 +71,10 @@ public class OrganizationHeaderView data.setEscapedContent("organizationDescription", organization.get("organization.description")); data.setEscapedContent("organizationMemberOfName", StringUtils.defaultIfBlank(organization.getFederation().getName(), "n/a")); - data.setContent("organizationStartDate", StringUtils.defaultIfBlank(organization.getStartDate(), "n/a")); - data.setContent("organizationEndDate", StringUtils.defaultIfBlank(organization.getEndDate(), "n/a")); + data.setContent("organizationStartDate", StringUtils.defaultIfBlank(organization.getStartDateValue(), "n/a")); + data.setContent("organizationEndDate", StringUtils.defaultIfBlank(organization.getEndDateValue(), "n/a")); data.setContent("organizationAge", StringUtils.defaultIfBlank(organization.getAge(), "n/a")); - if (StringUtils.isBlank(organization.getEndDate())) + if (StringUtils.isBlank(organization.getEndDateValue())) { data.setContent("organizationMemberOfWord", "depuis"); data.setAttribute("organizationEndDateData", "style", "display: none;"); diff --git a/src/fr/devinsy/statoolinfos/stats/StatAgent.java b/src/fr/devinsy/statoolinfos/stats/StatAgent.java index 59ce591..d03541f 100644 --- a/src/fr/devinsy/statoolinfos/stats/StatAgent.java +++ b/src/fr/devinsy/statoolinfos/stats/StatAgent.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. * @@ -507,7 +507,7 @@ public class StatAgent // for (Organization organization : organizations) { - if (StringUtils.isBlank(organization.getStartDate())) + if (StringUtils.isBlank(organization.getStartDateValue())) { result.incPassiveCount(); }