From 33c585d4ca5954826d39d8f7c9e0224b836dedc2 Mon Sep 17 00:00:00 2001 From: "Christian P. MOMON" Date: Thu, 16 Sep 2021 17:31:53 +0200 Subject: [PATCH] Managed active service in organizationList and uptimes. --- .../devinsy/statoolinfos/core/Federation.java | 29 +++++++++++++ .../statoolinfos/core/Organization.java | 43 +++++++++++++++++++ .../statoolinfos/core/Organizations.java | 19 ++++++++ .../devinsy/statoolinfos/core/Services.java | 27 ++++++++++++ .../statoolinfos/core/StatoolInfos.java | 2 +- .../htmlize/OrganizationListView.java | 2 +- .../statoolinfos/htmlize/UptimeView.java | 2 +- 7 files changed, 121 insertions(+), 3 deletions(-) diff --git a/src/fr/devinsy/statoolinfos/core/Federation.java b/src/fr/devinsy/statoolinfos/core/Federation.java index 504ec5b..e5d0310 100644 --- a/src/fr/devinsy/statoolinfos/core/Federation.java +++ b/src/fr/devinsy/statoolinfos/core/Federation.java @@ -501,6 +501,35 @@ public class Federation extends PathPropertyList return result; } + /** + * Gets the URL active all. + * + * @return the URL active all + */ + public URLSet getURLActiveAll() + { + URLSet result; + + result = new URLSet(); + + // + result.add(getContactURL()); + result.add(getLegalURL()); + result.add(getLogoURL()); + result.add(getTechnicalGuideURL()); + result.add(getUserGuideURL()); + result.add(getWebsiteURL()); + + // + for (Organization organization : getOrganizations()) + { + result.addAll(organization.getURLActiveAll()); + } + + // + return result; + } + /** * Gets the URL all. * diff --git a/src/fr/devinsy/statoolinfos/core/Organization.java b/src/fr/devinsy/statoolinfos/core/Organization.java index 1c595df..2eac8de 100644 --- a/src/fr/devinsy/statoolinfos/core/Organization.java +++ b/src/fr/devinsy/statoolinfos/core/Organization.java @@ -616,6 +616,21 @@ public class Organization extends PathPropertyList return result; } + /** + * Gets the service active count. + * + * @return the service active count + */ + public int getServiceActiveCount() + { + int result; + + result = this.services.getBy(Service.Status.OK).size(); + + // + return result; + } + /** * Gets the service count. * @@ -683,6 +698,34 @@ public class Organization extends PathPropertyList return result; } + /** + * Gets the URL all. + * + * @return the URL all + */ + public URLSet getURLActiveAll() + { + URLSet result; + + result = new URLSet(); + + result.add(getContactURL()); + result.add(getLegalURL()); + result.add(getLogoURL()); + result.add(getTechnicalGuideURL()); + result.add(getUserGuideURL()); + result.add(getWebsiteURL()); + + // + for (Service service : getServices().getBy(Service.Status.OK)) + { + result.addAll(service.getURLAll()); + } + + // + return result; + } + /** * Gets the URL all. * diff --git a/src/fr/devinsy/statoolinfos/core/Organizations.java b/src/fr/devinsy/statoolinfos/core/Organizations.java index 090aaa4..d65d89e 100644 --- a/src/fr/devinsy/statoolinfos/core/Organizations.java +++ b/src/fr/devinsy/statoolinfos/core/Organizations.java @@ -84,6 +84,25 @@ public class Organizations extends ArrayList return result; } + /** + * Gets the service active count. + * + * @return the service active count + */ + public int getServiceActiveCount() + { + int result; + + result = 0; + for (Organization organization : this) + { + result += organization.getServiceCount(); + } + + // + return result; + } + /** * Gets the service count. * diff --git a/src/fr/devinsy/statoolinfos/core/Services.java b/src/fr/devinsy/statoolinfos/core/Services.java index b8a7f01..6b5da8b 100644 --- a/src/fr/devinsy/statoolinfos/core/Services.java +++ b/src/fr/devinsy/statoolinfos/core/Services.java @@ -23,6 +23,8 @@ import java.util.Collections; import org.apache.commons.lang3.StringUtils; +import fr.devinsy.statoolinfos.core.Service.Status; + /** * The Class Services. */ @@ -90,6 +92,31 @@ public class Services extends ArrayList return result; } + /** + * Gets the by. + * + * @param status + * the category + * @return the by + */ + public Services getBy(final Status status) + { + Services result; + + result = new Services(); + + for (Service service : this) + { + if (service.getStatus() == status) + { + result.add(service); + } + } + + // + return result; + } + /** * Reverse. * diff --git a/src/fr/devinsy/statoolinfos/core/StatoolInfos.java b/src/fr/devinsy/statoolinfos/core/StatoolInfos.java index 9d7174f..68a8233 100644 --- a/src/fr/devinsy/statoolinfos/core/StatoolInfos.java +++ b/src/fr/devinsy/statoolinfos/core/StatoolInfos.java @@ -547,7 +547,7 @@ public class StatoolInfos UptimeJournal journal = HtmlizerContext.instance().getUptimeJournal(); Federation federation = HtmlizerContext.instance().getFederation(); - UptimeSurveyor.survey(journal, federation.getURLAll()); + UptimeSurveyor.survey(journal, federation.getURLActiveAll()); HtmlizerContext.instance().getCache().storeUptimeJournal(journal); } } diff --git a/src/fr/devinsy/statoolinfos/htmlize/OrganizationListView.java b/src/fr/devinsy/statoolinfos/htmlize/OrganizationListView.java index 1980ede..5f83ca6 100644 --- a/src/fr/devinsy/statoolinfos/htmlize/OrganizationListView.java +++ b/src/fr/devinsy/statoolinfos/htmlize/OrganizationListView.java @@ -74,7 +74,7 @@ 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.getServiceCount()); + data.setContent("organizationListLine", index, "organizationListLineServiceCount", organization.getServiceActiveCount()); data.setContent("organizationListLine", index, "organizationListLineUserCount", organization.getPreviousMonthUserCount()); data.setContent("organizationListLine", index, "organizationListLineVisitCount", organization.getPreviousMonthVisitCount()); diff --git a/src/fr/devinsy/statoolinfos/htmlize/UptimeView.java b/src/fr/devinsy/statoolinfos/htmlize/UptimeView.java index 73358de..71bbfc4 100644 --- a/src/fr/devinsy/statoolinfos/htmlize/UptimeView.java +++ b/src/fr/devinsy/statoolinfos/htmlize/UptimeView.java @@ -156,7 +156,7 @@ public class UptimeView } int index = 0; - for (Service service : services.sortByName()) + for (Service service : services.getBy(Service.Status.OK).sortByName()) { // data.setAttribute("line", index, "lineLogo", "src", service.getLogoFileName());