Improved status management in organizations and services display.
This commit is contained in:
parent
251d4ef761
commit
6bf8037cc5
13 changed files with 196 additions and 54 deletions
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 2020 Christian Pierre MOMON <christian@momon.org>
|
* Copyright (C) 2020-2022 Christian Pierre MOMON <christian@momon.org>
|
||||||
*
|
*
|
||||||
* This file is part of StatoolInfos, simple service statistics tool.
|
* This file is part of StatoolInfos, simple service statistics tool.
|
||||||
*
|
*
|
||||||
|
@ -81,6 +81,60 @@ public class Federation extends PathPropertyList
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the organizations active.
|
||||||
|
*
|
||||||
|
* @return the organizations active
|
||||||
|
*/
|
||||||
|
public Organizations getActiveOrganizations()
|
||||||
|
{
|
||||||
|
Organizations result;
|
||||||
|
|
||||||
|
result = this.organizations.filterActiveFor(getTechnicalName());
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the active services.
|
||||||
|
*
|
||||||
|
* @return the active services
|
||||||
|
*/
|
||||||
|
public Services getActiveServices()
|
||||||
|
{
|
||||||
|
Services result;
|
||||||
|
|
||||||
|
result = new Services();
|
||||||
|
|
||||||
|
for (Organization organization : getActiveOrganizations())
|
||||||
|
{
|
||||||
|
result.addAll(organization.getActiveServices());
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the active services.
|
||||||
|
*
|
||||||
|
* @return the active services
|
||||||
|
*/
|
||||||
|
public long getActiveServiceCount()
|
||||||
|
{
|
||||||
|
long result;
|
||||||
|
|
||||||
|
result = 0;
|
||||||
|
for (Organization organization : getActiveOrganizations())
|
||||||
|
{
|
||||||
|
result += organization.getActiveServiceCount();
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the contact email.
|
* Gets the contact email.
|
||||||
*
|
*
|
||||||
|
@ -386,21 +440,6 @@ public class Federation extends PathPropertyList
|
||||||
return this.organizations;
|
return this.organizations;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the organizations active.
|
|
||||||
*
|
|
||||||
* @return the organizations active
|
|
||||||
*/
|
|
||||||
public Organizations getActiveOrganizations()
|
|
||||||
{
|
|
||||||
Organizations result;
|
|
||||||
|
|
||||||
result = this.organizations.filterActiveFor(getTechnicalName());
|
|
||||||
|
|
||||||
//
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the service count.
|
* Gets the service count.
|
||||||
*
|
*
|
||||||
|
@ -411,7 +450,7 @@ public class Federation extends PathPropertyList
|
||||||
int result;
|
int result;
|
||||||
|
|
||||||
result = 0;
|
result = 0;
|
||||||
for (Organization organization : this.organizations)
|
for (Organization organization : getActiveOrganizations())
|
||||||
{
|
{
|
||||||
result += organization.getServiceCount();
|
result += organization.getServiceCount();
|
||||||
}
|
}
|
||||||
|
@ -420,6 +459,26 @@ public class Federation extends PathPropertyList
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the all services.
|
||||||
|
*
|
||||||
|
* @return the all services
|
||||||
|
*/
|
||||||
|
public Services getServices()
|
||||||
|
{
|
||||||
|
Services result;
|
||||||
|
|
||||||
|
result = new Services();
|
||||||
|
|
||||||
|
for (Organization organization : getActiveOrganizations())
|
||||||
|
{
|
||||||
|
result.addAll(organization.getServices());
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the all services.
|
* Gets the all services.
|
||||||
*
|
*
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 2020-2021 Christian Pierre MOMON <christian@momon.org>
|
* Copyright (C) 2020-2022 Christian Pierre MOMON <christian@momon.org>
|
||||||
*
|
*
|
||||||
* This file is part of StatoolInfos, simple service statistics tool.
|
* This file is part of StatoolInfos, simple service statistics tool.
|
||||||
*
|
*
|
||||||
|
@ -86,6 +86,51 @@ public class Organization extends PathPropertyList
|
||||||
this.crawlJournal = new CrawlJournal();
|
this.crawlJournal = new CrawlJournal();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the active services.
|
||||||
|
*
|
||||||
|
* @return the active services
|
||||||
|
*/
|
||||||
|
public Services getActiveServices()
|
||||||
|
{
|
||||||
|
Services result;
|
||||||
|
|
||||||
|
result = new Services();
|
||||||
|
|
||||||
|
for (Service service : this.services)
|
||||||
|
{
|
||||||
|
if (service.isActive())
|
||||||
|
{
|
||||||
|
result.add(service);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
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.
|
* Gets the age.
|
||||||
*
|
*
|
||||||
|
@ -665,21 +710,6 @@ public class Organization extends PathPropertyList
|
||||||
return result;
|
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.
|
* Gets the service count.
|
||||||
*
|
*
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 2020 Christian Pierre MOMON <christian@momon.org>
|
* Copyright (C) 2020-2022 Christian Pierre MOMON <christian@momon.org>
|
||||||
*
|
*
|
||||||
* This file is part of StatoolInfos, simple service statistics tool.
|
* This file is part of StatoolInfos, simple service statistics tool.
|
||||||
*
|
*
|
||||||
|
@ -110,18 +110,18 @@ public class Organizations extends ArrayList<Organization>
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the service active count.
|
* Gets the active service count.
|
||||||
*
|
*
|
||||||
* @return the service active count
|
* @return the active service count
|
||||||
*/
|
*/
|
||||||
public int getServiceActiveCount()
|
public int getActiveServiceCount()
|
||||||
{
|
{
|
||||||
int result;
|
int result;
|
||||||
|
|
||||||
result = 0;
|
result = 0;
|
||||||
for (Organization organization : this)
|
for (Organization organization : this)
|
||||||
{
|
{
|
||||||
result += organization.getServiceCount();
|
result += organization.getActiveServiceCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 2020-2021 Christian Pierre MOMON <christian@momon.org>
|
* Copyright (C) 2020-2022 Christian Pierre MOMON <christian@momon.org>
|
||||||
*
|
*
|
||||||
* This file is part of StatoolInfos, simple service statistics tool.
|
* This file is part of StatoolInfos, simple service statistics tool.
|
||||||
*
|
*
|
||||||
|
@ -860,6 +860,59 @@ public class Service extends PathPropertyList
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if is active.
|
||||||
|
*
|
||||||
|
* @return true, if is active
|
||||||
|
*/
|
||||||
|
public boolean isActive()
|
||||||
|
{
|
||||||
|
boolean result;
|
||||||
|
|
||||||
|
if (((getStatus() == Service.Status.OK) || (getStatus() == Status.WARNING) || (getStatus() == Status.ERROR)) && (!isAway()))
|
||||||
|
{
|
||||||
|
result = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
result = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if is away.
|
||||||
|
*
|
||||||
|
* @return true, if is away
|
||||||
|
*/
|
||||||
|
public boolean isAway()
|
||||||
|
{
|
||||||
|
boolean result;
|
||||||
|
|
||||||
|
if (getEndDate() == null)
|
||||||
|
{
|
||||||
|
result = false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
LocalDate endDate = getDate("service.enddate");
|
||||||
|
|
||||||
|
if ((endDate == null) || (endDate.isAfter(LocalDate.now())))
|
||||||
|
{
|
||||||
|
result = false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
result = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if is registration client.
|
* Checks if is registration client.
|
||||||
*
|
*
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 2020 Christian Pierre MOMON <christian@momon.org>
|
* Copyright (C) 2020-2022 Christian Pierre MOMON <christian@momon.org>
|
||||||
*
|
*
|
||||||
* This file is part of StatoolInfos, simple service statistics tool.
|
* This file is part of StatoolInfos, simple service statistics tool.
|
||||||
*
|
*
|
||||||
|
@ -60,7 +60,7 @@ public class CategoryPage
|
||||||
logger.info("Htmlize category pages.");
|
logger.info("Htmlize category pages.");
|
||||||
for (Category category : categories)
|
for (Category category : categories)
|
||||||
{
|
{
|
||||||
Services services = federation.getServicesAll().getBy(category);
|
Services services = federation.getServices().getBy(category);
|
||||||
String page = CategoryPage.htmlize(category, services);
|
String page = CategoryPage.htmlize(category, services);
|
||||||
FileUtils.write(new File(htmlizeDirectory, "category-" + category.getTechnicalName() + ".xhtml"), page, StandardCharsets.UTF_8);
|
FileUtils.write(new File(htmlizeDirectory, "category-" + category.getTechnicalName() + ".xhtml"), page, StandardCharsets.UTF_8);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 2020-2021 Christian Pierre MOMON <christian@momon.org>
|
* Copyright (C) 2020-2022 Christian Pierre MOMON <christian@momon.org>
|
||||||
*
|
*
|
||||||
* This file is part of StatoolInfos, simple service statistics tool.
|
* This file is part of StatoolInfos, simple service statistics tool.
|
||||||
*
|
*
|
||||||
|
|
|
@ -78,7 +78,7 @@ public class FederationServicesPage
|
||||||
TagDataManager data = new TagDataManager();
|
TagDataManager data = new TagDataManager();
|
||||||
|
|
||||||
data.setContent("federationHeaderView", FederationHeaderView.htmlize(federation));
|
data.setContent("federationHeaderView", FederationHeaderView.htmlize(federation));
|
||||||
data.setContent("serviceListView", ServiceListView.htmlize(federation.getServicesAll()));
|
data.setContent("serviceListView", ServiceListView.htmlize(federation.getServices()));
|
||||||
|
|
||||||
String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/federationServices.xhtml", data).toString();
|
String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/federationServices.xhtml", data).toString();
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 2021 Christian Pierre MOMON <christian@momon.org>
|
* Copyright (C) 2021-2022 Christian Pierre MOMON <christian@momon.org>
|
||||||
*
|
*
|
||||||
* This file is part of StatoolInfos, simple service statistics tool.
|
* This file is part of StatoolInfos, simple service statistics tool.
|
||||||
*
|
*
|
||||||
|
@ -81,7 +81,7 @@ public class FederationUptimePage
|
||||||
TagDataManager data = new TagDataManager();
|
TagDataManager data = new TagDataManager();
|
||||||
|
|
||||||
data.setContent("headerView", FederationHeaderView.htmlize(federation));
|
data.setContent("headerView", FederationHeaderView.htmlize(federation));
|
||||||
data.setContent("uptimeView", UptimeView.htmlize(federation.getServicesAll(), journal));
|
data.setContent("uptimeView", UptimeView.htmlize(federation.getActiveServices(), journal));
|
||||||
|
|
||||||
String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/uptimePage.xhtml", data).toString();
|
String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/uptimePage.xhtml", data).toString();
|
||||||
|
|
||||||
|
|
|
@ -61,7 +61,7 @@ public class OrganizationListView
|
||||||
TagDataManager data = new TagDataManager();
|
TagDataManager data = new TagDataManager();
|
||||||
|
|
||||||
data.setContent("organizationCount", organizations.size());
|
data.setContent("organizationCount", organizations.size());
|
||||||
data.setContent("serviceCount", organizations.getServiceCount());
|
data.setContent("serviceCount", organizations.getActiveServiceCount());
|
||||||
|
|
||||||
String monthLabel = LocalDate.now().minusMonths(1).format(DateTimeFormatter.ofPattern("MMMM yyyy")).replace(" ", " ");
|
String monthLabel = LocalDate.now().minusMonths(1).format(DateTimeFormatter.ofPattern("MMMM yyyy")).replace(" ", " ");
|
||||||
data.setContent("monthLabel", monthLabel);
|
data.setContent("monthLabel", monthLabel);
|
||||||
|
@ -81,7 +81,7 @@ public class OrganizationListView
|
||||||
data.setEscapedContent("organizationListLine", index, "organizationListLineUrlLink", organization.getWebsiteURL().toString());
|
data.setEscapedContent("organizationListLine", index, "organizationListLineUrlLink", organization.getWebsiteURL().toString());
|
||||||
data.setEscapedAttribute("organizationListLine", index, "organizationListLineUrlLink", "href", organization.getWebsiteURL().toString());
|
data.setEscapedAttribute("organizationListLine", index, "organizationListLineUrlLink", "href", organization.getWebsiteURL().toString());
|
||||||
}
|
}
|
||||||
data.setContent("organizationListLine", index, "organizationListLineServiceCount", StatoolInfosUtils.defaultIfZero(organization.getServiceActiveCount(), "😿"));
|
data.setContent("organizationListLine", index, "organizationListLineServiceCount", StatoolInfosUtils.defaultIfZero(organization.getActiveServiceCount(), "😿"));
|
||||||
data.setContent("organizationListLine", index, "organizationListLineUserCount", StatoolInfosUtils.defaultIfZero(organization.getPreviousMonthUserCount(), "😢"));
|
data.setContent("organizationListLine", index, "organizationListLineUserCount", StatoolInfosUtils.defaultIfZero(organization.getPreviousMonthUserCount(), "😢"));
|
||||||
data.setContent("organizationListLine", index, "organizationListLineVisitCount", StatoolInfosUtils.defaultIfZero(organization.getPreviousMonthVisitCount(), "😞"));
|
data.setContent("organizationListLine", index, "organizationListLineVisitCount", StatoolInfosUtils.defaultIfZero(organization.getPreviousMonthVisitCount(), "😞"));
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 2020-2021 Christian Pierre MOMON <christian@momon.org>
|
* Copyright (C) 2020-2022 Christian Pierre MOMON <christian@momon.org>
|
||||||
*
|
*
|
||||||
* This file is part of StatoolInfos, simple service statistics tool.
|
* This file is part of StatoolInfos, simple service statistics tool.
|
||||||
*
|
*
|
||||||
|
@ -95,8 +95,8 @@ public class ServiceListView
|
||||||
data.setEscapedContent("serviceListLine", index, "serviceListLineSoftwareLink", service.getSoftwareName());
|
data.setEscapedContent("serviceListLine", index, "serviceListLineSoftwareLink", service.getSoftwareName());
|
||||||
data.setAttribute("serviceListLine", index, "serviceListLineSoftwareLink", "href", "software-" + service.getSoftwareTechnicalName() + ".xhtml");
|
data.setAttribute("serviceListLine", index, "serviceListLineSoftwareLink", "href", "software-" + service.getSoftwareTechnicalName() + ".xhtml");
|
||||||
|
|
||||||
data.setContent("serviceListLine", index, "serviceListLineUserCount", StatoolInfosUtils.defaultIfZero(service.getPreviousMonthUserCount(), "😞"));
|
data.setContent("serviceListLine", index, "serviceListLineUserCount", StatoolInfosUtils.defaultIfZero(service.getPreviousMonthUserCount(), "😢"));
|
||||||
data.setContent("serviceListLine", index, "serviceListLineVisitCount", StatoolInfosUtils.defaultIfZero(service.getPreviousMonthVisitCount(), "😢"));
|
data.setContent("serviceListLine", index, "serviceListLineVisitCount", StatoolInfosUtils.defaultIfZero(service.getPreviousMonthVisitCount(), "😞"));
|
||||||
|
|
||||||
data.setEscapedContent("serviceListLine", index, "serviceListLineDate", service.getCrawledDate().format(DateTimeFormatter.ofPattern("dd/MM/YYYY")));
|
data.setEscapedContent("serviceListLine", index, "serviceListLineDate", service.getCrawledDate().format(DateTimeFormatter.ofPattern("dd/MM/YYYY")));
|
||||||
data.setEscapedAttribute("serviceListLine", index, "serviceListLineDate", "title", service.getCrawledDate().format(DateTimeFormatter.ofPattern("HH:mm:ss")));
|
data.setEscapedAttribute("serviceListLine", index, "serviceListLineDate", "title", service.getCrawledDate().format(DateTimeFormatter.ofPattern("HH:mm:ss")));
|
||||||
|
|
|
@ -53,7 +53,7 @@ public class ServicesPage
|
||||||
File htmlizeDirectory = HtmlizerContext.instance().getHtmlizeDirectory();
|
File htmlizeDirectory = HtmlizerContext.instance().getHtmlizeDirectory();
|
||||||
|
|
||||||
logger.info("Htmlize services page.");
|
logger.info("Htmlize services page.");
|
||||||
String page = ServicesPage.htmlize(federation.getServicesAll());
|
String page = ServicesPage.htmlize(federation.getServices());
|
||||||
FileUtils.write(new File(htmlizeDirectory, "services.xhtml"), page, StandardCharsets.UTF_8);
|
FileUtils.write(new File(htmlizeDirectory, "services.xhtml"), page, StandardCharsets.UTF_8);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -58,7 +58,7 @@ public class SoftwarePage
|
||||||
Softwares catalog = federation.getSoftwares();
|
Softwares catalog = federation.getSoftwares();
|
||||||
for (Software software : catalog.values())
|
for (Software software : catalog.values())
|
||||||
{
|
{
|
||||||
Services services = federation.getServicesAll().getBy(software);
|
Services services = federation.getServices().getBy(software);
|
||||||
String page = SoftwarePage.htmlize(software, services);
|
String page = SoftwarePage.htmlize(software, services);
|
||||||
FileUtils.write(new File(htmlizeDirectory, "software-" + software.getTechnicalName() + ".xhtml"), page, StandardCharsets.UTF_8);
|
FileUtils.write(new File(htmlizeDirectory, "software-" + software.getTechnicalName() + ".xhtml"), page, StandardCharsets.UTF_8);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 2021 Christian Pierre MOMON <christian@momon.org>
|
* Copyright (C) 2021-2022 Christian Pierre MOMON <christian@momon.org>
|
||||||
*
|
*
|
||||||
* This file is part of StatoolInfos, simple service statistics tool.
|
* This file is part of StatoolInfos, simple service statistics tool.
|
||||||
*
|
*
|
||||||
|
@ -156,7 +156,7 @@ public class UptimeView
|
||||||
}
|
}
|
||||||
|
|
||||||
int index = 0;
|
int index = 0;
|
||||||
for (Service service : services.getBy(Service.Status.OK).sortByName())
|
for (Service service : services.sortByName())
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
data.setAttribute("line", index, "lineLogo", "src", service.getLogoFileName());
|
data.setAttribute("line", index, "lineLogo", "src", service.getLogoFileName());
|
||||||
|
|
Loading…
Reference in a new issue