diff --git a/src/fr/devinsy/statoolinfos/core/Factory.java b/src/fr/devinsy/statoolinfos/core/Factory.java index dd83758..97ab525 100644 --- a/src/fr/devinsy/statoolinfos/core/Factory.java +++ b/src/fr/devinsy/statoolinfos/core/Factory.java @@ -93,6 +93,7 @@ public class Factory { File subFile = cache.restoreFile(new URL(property.getValue())); Organization organization = loadOrganization(subFile, cache); + organization.setFederation(result); result.getOrganizations().add(organization); } } @@ -127,6 +128,7 @@ public class Factory { File subFile = cache.restoreFile(new URL(property.getValue())); Service service = loadService(subFile); + service.setOrganization(result); result.getServices().add(service); } } diff --git a/src/fr/devinsy/statoolinfos/core/Organization.java b/src/fr/devinsy/statoolinfos/core/Organization.java index a555f3a..d311cab 100644 --- a/src/fr/devinsy/statoolinfos/core/Organization.java +++ b/src/fr/devinsy/statoolinfos/core/Organization.java @@ -33,6 +33,7 @@ import fr.devinsy.statoolinfos.properties.PathPropertyList; public class Organization extends PathPropertyList { private static final long serialVersionUID = -2709210934548224213L; + private Federation federation; private Services services; private File localFile; @@ -75,6 +76,11 @@ public class Organization extends PathPropertyList return result; } + public Federation getFederation() + { + return this.federation; + } + public File getLocalFile() { return this.localFile; @@ -170,6 +176,11 @@ public class Organization extends PathPropertyList return result; } + public void setFederation(final Federation federation) + { + this.federation = federation; + } + public void setLocalFile(final File localFile) { this.localFile = localFile; diff --git a/src/fr/devinsy/statoolinfos/core/Service.java b/src/fr/devinsy/statoolinfos/core/Service.java index 8f74448..1cfc8be 100644 --- a/src/fr/devinsy/statoolinfos/core/Service.java +++ b/src/fr/devinsy/statoolinfos/core/Service.java @@ -33,6 +33,7 @@ import fr.devinsy.statoolinfos.properties.PathPropertyList; public class Service extends PathPropertyList { private static final long serialVersionUID = 3629841771102288863L; + private Organization organization; private File localFile; /** @@ -114,6 +115,11 @@ public class Service extends PathPropertyList return result; } + public Organization getOrganization() + { + return this.organization; + } + public String getSoftware() { String result; @@ -158,4 +164,9 @@ public class Service extends PathPropertyList { this.localFile = localFile; } + + public void setOrganization(final Organization organization) + { + this.organization = organization; + } } diff --git a/src/fr/devinsy/statoolinfos/htmlize/Htmlizer.java b/src/fr/devinsy/statoolinfos/htmlize/Htmlizer.java index f6dc9a1..ee8d0bd 100644 --- a/src/fr/devinsy/statoolinfos/htmlize/Htmlizer.java +++ b/src/fr/devinsy/statoolinfos/htmlize/Htmlizer.java @@ -254,6 +254,10 @@ public class Htmlizer } // + logger.info("Htmlize services page."); + page = ServicesPage.build(federation.getAllServices()); + FileUtils.write(new File(htmlizeDirectory, "services.xhtml"), page, StandardCharsets.UTF_8); + logger.info("Htmlize propertiesFiles page."); page = PropertiesFilesPage.build(federation); FileUtils.write(new File(htmlizeDirectory, "propertiesFiles.xhtml"), page, StandardCharsets.UTF_8); diff --git a/src/fr/devinsy/statoolinfos/htmlize/OrganizationPage.java b/src/fr/devinsy/statoolinfos/htmlize/OrganizationPage.java index 50225a5..d71c543 100644 --- a/src/fr/devinsy/statoolinfos/htmlize/OrganizationPage.java +++ b/src/fr/devinsy/statoolinfos/htmlize/OrganizationPage.java @@ -18,17 +18,12 @@ */ package fr.devinsy.statoolinfos.htmlize; -import java.time.LocalDateTime; -import java.time.format.DateTimeFormatter; -import java.util.Locale; - import org.slf4j.Logger; import org.slf4j.LoggerFactory; import fr.devinsy.statoolinfos.core.Organization; import fr.devinsy.statoolinfos.core.Service; import fr.devinsy.statoolinfos.core.StatoolInfosException; -import fr.devinsy.statoolinfos.util.BuildInformation; import fr.devinsy.xidyn.XidynException; import fr.devinsy.xidyn.data.TagDataManager; import fr.devinsy.xidyn.presenters.PresenterUtils; @@ -59,9 +54,6 @@ public class OrganizationPage TagDataManager data = new TagDataManager(); - data.setContent("versionsup", BuildInformation.instance().version()); - data.setContent("lastUpdateDate", LocalDateTime.now().format(DateTimeFormatter.ofPattern("dd/MM/yyyy HH':'mm", Locale.FRANCE))); - data.setAttribute("organizationRawButton", "href", organization.getTechnicalName() + ".properties"); data.setAttribute("organizationLogo", "src", organization.getTechnicalName() + "-logo.png"); diff --git a/src/fr/devinsy/statoolinfos/htmlize/ServicePage.java b/src/fr/devinsy/statoolinfos/htmlize/ServicePage.java index 49b2680..006ebbb 100644 --- a/src/fr/devinsy/statoolinfos/htmlize/ServicePage.java +++ b/src/fr/devinsy/statoolinfos/htmlize/ServicePage.java @@ -18,17 +18,12 @@ */ package fr.devinsy.statoolinfos.htmlize; -import java.time.LocalDateTime; -import java.time.format.DateTimeFormatter; -import java.util.Locale; - import org.slf4j.Logger; import org.slf4j.LoggerFactory; import fr.devinsy.statoolinfos.core.Organization; import fr.devinsy.statoolinfos.core.Service; import fr.devinsy.statoolinfos.core.StatoolInfosException; -import fr.devinsy.statoolinfos.util.BuildInformation; import fr.devinsy.xidyn.XidynException; import fr.devinsy.xidyn.data.TagDataManager; import fr.devinsy.xidyn.presenters.PresenterUtils; @@ -59,9 +54,6 @@ public class ServicePage TagDataManager data = new TagDataManager(); - data.setContent("versionsup", BuildInformation.instance().version()); - data.setContent("lastUpdateDate", LocalDateTime.now().format(DateTimeFormatter.ofPattern("dd/MM/yyyy HH':'mm", Locale.FRANCE))); - data.setAttribute("serviceRawButton", "href", organization.getTechnicalName() + "-" + service.getTechnicalName() + ".properties"); data.setAttribute("serviceLogo", "src", organization.getTechnicalName() + "-" + service.getTechnicalName() + "-logo.png"); diff --git a/src/fr/devinsy/statoolinfos/htmlize/ServicesPage.java b/src/fr/devinsy/statoolinfos/htmlize/ServicesPage.java new file mode 100644 index 0000000..da14c6e --- /dev/null +++ b/src/fr/devinsy/statoolinfos/htmlize/ServicesPage.java @@ -0,0 +1,87 @@ +/* + * Copyright (C) 2020 Christian Pierre MOMON + * + * This file is part of StatoolInfos, simple service statistics tool. + * + * StatoolInfos is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * StatoolInfos is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with StatoolInfos. If not, see . + */ +package fr.devinsy.statoolinfos.htmlize; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import fr.devinsy.statoolinfos.core.Service; +import fr.devinsy.statoolinfos.core.Services; +import fr.devinsy.statoolinfos.core.StatoolInfosException; +import fr.devinsy.xidyn.XidynException; +import fr.devinsy.xidyn.data.TagDataManager; +import fr.devinsy.xidyn.presenters.PresenterUtils; + +/** + * The Class ServicesPage. + */ +public class ServicesPage +{ + private static Logger logger = LoggerFactory.getLogger(ServicesPage.class); + + /** + * Builds the. + * + * @param services + * the services + * @return the string + * @throws StatoolInfosException + * the statool infos exception + */ + public static String build(final Services services) throws StatoolInfosException + { + String result; + + try + { + logger.debug("Building services page."); + + TagDataManager data = new TagDataManager(); + + data.setContent("serviceCount", services.size()); + + int index = 0; + for (Service service : services) + { + data.setAttribute("serviceListLine", index, "serviceListLineLogo", "src", service.getOrganization().getTechnicalName() + "-" + service.getTechnicalName() + "-logo.png"); + data.setEscapedContent("serviceListLine", index, "serviceListLineNameValue", service.getName()); + data.setAttribute("serviceListLine", index, "serviceListLineNameLink", "href", service.getOrganization().getTechnicalName() + "-" + service.getTechnicalName() + ".xhtml"); + data.setEscapedContent("serviceListLine", index, "serviceListLineOrganizationLink", service.getOrganization().getName()); + data.setAttribute("serviceListLine", index, "serviceListLineOrganizationLink", "href", service.getOrganization().getTechnicalName() + ".xhtml"); + data.setEscapedContent("serviceListLine", index, "serviceListLineUrlLink", service.getWebsite()); + data.setEscapedContent("serviceListLine", index, "serviceListLineWebsiteLink", service.getWebsite()); + data.setAttribute("serviceListLine", index, "serviceListLineWebsiteLink", "href", service.getWebsite()); + data.setEscapedContent("serviceListLine", index, "serviceListLineSoftware", service.getSoftware()); + + index += 1; + } + + String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/services.xhtml", data).toString(); + + result = WebCharterView.build(content); + } + catch (XidynException exception) + { + throw new StatoolInfosException("Error building service page: " + exception.getMessage(), exception); + } + + // + return result; + } +} diff --git a/src/fr/devinsy/statoolinfos/htmlize/services.xhtml b/src/fr/devinsy/statoolinfos/htmlize/services.xhtml new file mode 100644 index 0000000..5a33df0 --- /dev/null +++ b/src/fr/devinsy/statoolinfos/htmlize/services.xhtml @@ -0,0 +1,43 @@ + + + + + StatoolInfos + + + + + + + +

Tous les services

+ +
Nombre de services : n/a
+
+ + + + + + + + + + + + + + + + + +
Nom du serviceOrganisationURLLogiciel
+ + +  n/a + + n/an/an/a
+
+ + diff --git a/src/fr/devinsy/statoolinfos/htmlize/webCharterView.xhtml b/src/fr/devinsy/statoolinfos/htmlize/webCharterView.xhtml index b4995fb..c659fdf 100644 --- a/src/fr/devinsy/statoolinfos/htmlize/webCharterView.xhtml +++ b/src/fr/devinsy/statoolinfos/htmlize/webCharterView.xhtml @@ -17,7 +17,7 @@
Fichiers properties Toutes les property - Tous les services + Tous les services Tous les logiciels