From 0f9e3c4ae8c4bf0c3b66585d3f7bf881f1a9f1d0 Mon Sep 17 00:00:00 2001 From: "Christian P. MOMON" Date: Wed, 16 Feb 2022 19:37:31 +0100 Subject: [PATCH] Improved organization list view with actives, idles and aways. --- .../devinsy/statoolinfos/core/Federation.java | 45 +++++++++ .../statoolinfos/core/Organization.java | 67 ++++++++----- .../statoolinfos/core/Organizations.java | 98 ++++++++++++++++++- .../htmlize/FederationOrganizationsPage.java | 3 +- .../htmlize/OrganizationListView.java | 39 +++++++- .../htmlize/organizationListView.xhtml | 6 +- 6 files changed, 228 insertions(+), 30 deletions(-) diff --git a/src/fr/devinsy/statoolinfos/core/Federation.java b/src/fr/devinsy/statoolinfos/core/Federation.java index d11ea9a..13293d9 100644 --- a/src/fr/devinsy/statoolinfos/core/Federation.java +++ b/src/fr/devinsy/statoolinfos/core/Federation.java @@ -135,6 +135,21 @@ public class Federation extends PathPropertyList return result; } + /** + * Gets the away organizations. + * + * @return the away organizations + */ + public Organizations getAwayOrganizations() + { + Organizations result; + + result = this.organizations.filterAwayFor(getTechnicalName()); + + // + return result; + } + /** * Gets the contact email. * @@ -220,6 +235,21 @@ public class Federation extends PathPropertyList return result; } + /** + * Gets the idle organizations. + * + * @return the idle organizations + */ + public Organizations getIdleOrganizations() + { + Organizations result; + + result = this.organizations.getIdles(); + + // + return result; + } + public PropertyChecks getInputChecks() { return this.inputChecks; @@ -339,6 +369,21 @@ public class Federation extends PathPropertyList return result; } + /** + * Gets the member organizations. + * + * @return the member organizations + */ + public Organizations getMemberOrganizations() + { + Organizations result; + + result = this.organizations.filterMemberFor(getTechnicalName()); + + // + return result; + } + /** * Gets the metric month values all. * diff --git a/src/fr/devinsy/statoolinfos/core/Organization.java b/src/fr/devinsy/statoolinfos/core/Organization.java index e7ace71..b09dd5f 100644 --- a/src/fr/devinsy/statoolinfos/core/Organization.java +++ b/src/fr/devinsy/statoolinfos/core/Organization.java @@ -86,6 +86,28 @@ public class Organization extends PathPropertyList this.crawlJournal = new CrawlJournal(); } + /** + * Gets the service active count. + * + * @return the service active count + */ + public int getActiveServiceCount() + { + int result; + + result = 0; + for (Service service : this.services) + { + if (service.isActive()) + { + result += 1; + } + } + + // + return result; + } + /** * Gets the active services. * @@ -109,28 +131,6 @@ public class Organization extends PathPropertyList return result; } - /** - * Gets the service active count. - * - * @return the service active count - */ - public int getActiveServiceCount() - { - int result; - - result = 0; - for (Service service : this.services) - { - if (service.isActive()) - { - result += 1; - } - } - - // - return result; - } - /** * Gets the age. * @@ -1074,6 +1074,29 @@ public class Organization extends PathPropertyList return result; } + /** + * Checks if is idle. + * + * @return true, if is idle + */ + public boolean isIdle() + { + boolean result; + + Status status = getStatus(); + if ((status == null) || (status == Status.IDLE)) + { + result = true; + } + else + { + result = false; + } + + // + return result; + } + /** * Checks if is valid. * diff --git a/src/fr/devinsy/statoolinfos/core/Organizations.java b/src/fr/devinsy/statoolinfos/core/Organizations.java index 7153a7b..1f45f8c 100644 --- a/src/fr/devinsy/statoolinfos/core/Organizations.java +++ b/src/fr/devinsy/statoolinfos/core/Organizations.java @@ -36,6 +36,29 @@ public class Organizations extends ArrayList super(); } + /** + * Filter active. + * + * @return the organizations + */ + public Organizations filterActive() + { + Organizations result; + + result = new Organizations(); + + for (Organization organization : this) + { + if (organization.isActive()) + { + result.add(organization); + } + } + + // + return result; + } + /** * Filter member of. * @@ -51,7 +74,32 @@ public class Organizations extends ArrayList for (Organization organization : this) { - if ((!organization.isAway()) && (!organization.isAwayFor(entityName))) + if ((organization.isActive()) && (!organization.isAwayFor(entityName))) + { + result.add(organization); + } + } + + // + return result; + } + + /** + * Filter away for. + * + * @param entityName + * the entity name + * @return the organizations + */ + public Organizations filterAwayFor(final String entityName) + { + Organizations result; + + result = new Organizations(); + + for (Organization organization : this) + { + if ((organization.isAway()) || (organization.isAwayFor(entityName))) { result.add(organization); } @@ -109,6 +157,31 @@ public class Organizations extends ArrayList return result; } + /** + * Filter member for. + * + * @param entityName + * the entity name + * @return the organizations + */ + public Organizations filterMemberFor(final String entityName) + { + Organizations result; + + result = new Organizations(); + + for (Organization organization : this) + { + if ((!organization.isAway()) && (!organization.isAwayFor(entityName))) + { + result.add(organization); + } + } + + // + return result; + } + /** * Gets the active service count. * @@ -128,6 +201,29 @@ public class Organizations extends ArrayList return result; } + /** + * Gets the idles. + * + * @return the idles + */ + public Organizations getIdles() + { + Organizations result; + + result = new Organizations(); + + for (Organization organization : this) + { + if (organization.isIdle()) + { + result.add(organization); + } + } + + // + return result; + } + /** * Gets the service count. * diff --git a/src/fr/devinsy/statoolinfos/htmlize/FederationOrganizationsPage.java b/src/fr/devinsy/statoolinfos/htmlize/FederationOrganizationsPage.java index 3c52e1e..cb0b0bb 100644 --- a/src/fr/devinsy/statoolinfos/htmlize/FederationOrganizationsPage.java +++ b/src/fr/devinsy/statoolinfos/htmlize/FederationOrganizationsPage.java @@ -78,7 +78,8 @@ public class FederationOrganizationsPage TagDataManager data = new TagDataManager(); data.setContent("federationHeaderView", FederationHeaderView.htmlize(federation)); - data.setContent("organizationListView", OrganizationListView.htmlize(federation.getActiveOrganizations())); + + data.setContent("organizationListView", OrganizationListView.htmlize(federation.getMemberOrganizations(), federation.getAwayOrganizations())); String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/federationOrganizations.xhtml", data).toString(); diff --git a/src/fr/devinsy/statoolinfos/htmlize/OrganizationListView.java b/src/fr/devinsy/statoolinfos/htmlize/OrganizationListView.java index f9a2a63..dcbef76 100644 --- a/src/fr/devinsy/statoolinfos/htmlize/OrganizationListView.java +++ b/src/fr/devinsy/statoolinfos/htmlize/OrganizationListView.java @@ -29,6 +29,7 @@ import fr.devinsy.statoolinfos.core.Organization; import fr.devinsy.statoolinfos.core.Organizations; import fr.devinsy.statoolinfos.core.StatoolInfosException; import fr.devinsy.statoolinfos.core.StatoolInfosUtils; +import fr.devinsy.strings.StringList; import fr.devinsy.xidyn.XidynException; import fr.devinsy.xidyn.data.TagDataManager; import fr.devinsy.xidyn.presenters.PresenterUtils; @@ -52,7 +53,7 @@ public class OrganizationListView * @throws IOException * Signals that an I/O exception has occurred. */ - public static String htmlize(final Organizations organizations) throws StatoolInfosException, IOException + public static String htmlize(final Organizations organizations, final Organizations aways) throws StatoolInfosException, IOException { String result; @@ -60,8 +61,9 @@ public class OrganizationListView { TagDataManager data = new TagDataManager(); - data.setContent("organizationCount", organizations.size()); - data.setContent("serviceCount", organizations.getActiveServiceCount()); + Organizations actives = organizations.filterActive(); + data.setContent("organizationCount", actives.size()); + data.setContent("serviceCount", actives.getActiveServiceCount()); String monthLabel = LocalDate.now().minusMonths(1).format(DateTimeFormatter.ofPattern("MMMM yyyy")).replace(" ", " "); data.setContent("monthLabel", monthLabel); @@ -69,7 +71,7 @@ public class OrganizationListView data.setAttribute("visitCountHeaderColumn", "title", monthLabel); int index = 0; - for (Organization organization : organizations.sortByReverseServiceCount()) + for (Organization organization : actives.sortByReverseServiceCount()) { data.setAttribute("organizationListLine", index, "organizationListLineNameLink", "href", organization.getTechnicalName() + ".xhtml"); data.setAttribute("organizationListLine", index, "organizationListLineLogo", "src", organization.getLogoFileName()); @@ -91,6 +93,35 @@ public class OrganizationListView index += 1; } + Organizations idles = organizations.getIdles(); + if (idles.isEmpty()) + { + data.setContent("idleMembers", "aucun."); + } + else + { + StringList buffer = new StringList(); + for (Organization idle : idles) + { + buffer.add(String.format("%s", idle.getTechnicalName() + ".xhtml", idle.getName())); + } + data.setContent("idleMembers", buffer.toString("", ", ", ".")); + } + + if (aways.isEmpty()) + { + data.setContent("awayMembers", "aucun."); + } + else + { + StringList buffer = new StringList(); + for (Organization away : aways) + { + buffer.add(String.format("%s", away.getTechnicalName() + ".xhtml", away.getName())); + } + data.setContent("awayMembers", buffer.toString("", ", ", ".")); + } + String page = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/organizationListView.xhtml", data).toString(); result = XidynUtils.extractBodyContent(page); diff --git a/src/fr/devinsy/statoolinfos/htmlize/organizationListView.xhtml b/src/fr/devinsy/statoolinfos/htmlize/organizationListView.xhtml index 19a6165..f216cb7 100644 --- a/src/fr/devinsy/statoolinfos/htmlize/organizationListView.xhtml +++ b/src/fr/devinsy/statoolinfos/htmlize/organizationListView.xhtml @@ -13,8 +13,8 @@

-
Nombre de membres : n/a
-
Nombre de services : n/a
+
Nombre de membres actifs : n/a
+
Nombre de services acfifs : n/a
@@ -43,6 +43,8 @@
(*) chiffres de n/a
+
Membres en sommeil : n/a
+
Anciens membres : n/a