Added Category page.
This commit is contained in:
parent
00320d7df4
commit
53732f23af
11 changed files with 312 additions and 70 deletions
|
@ -86,6 +86,30 @@ public class Category
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Matches.
|
||||||
|
*
|
||||||
|
* @param service
|
||||||
|
* the service
|
||||||
|
* @return true, if successful
|
||||||
|
*/
|
||||||
|
public boolean matches(final Service service)
|
||||||
|
{
|
||||||
|
boolean result;
|
||||||
|
|
||||||
|
if (this.softwares.contains(service.getSoftwareName()))
|
||||||
|
{
|
||||||
|
result = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
result = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
public void setDescription(final String description)
|
public void setDescription(final String description)
|
||||||
{
|
{
|
||||||
this.description = description;
|
this.description = description;
|
||||||
|
|
|
@ -50,8 +50,11 @@ public class Factory
|
||||||
/**
|
/**
|
||||||
* Load categories.
|
* Load categories.
|
||||||
*
|
*
|
||||||
|
* @param source
|
||||||
|
* the source
|
||||||
* @return the categories
|
* @return the categories
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
|
* Signals that an I/O exception has occurred.
|
||||||
*/
|
*/
|
||||||
public static Categories loadCategories(final File source) throws IOException
|
public static Categories loadCategories(final File source) throws IOException
|
||||||
{
|
{
|
||||||
|
@ -85,6 +88,38 @@ public class Factory
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Load categories.
|
||||||
|
*
|
||||||
|
* @param source
|
||||||
|
* the source
|
||||||
|
* @param federation
|
||||||
|
* the federation
|
||||||
|
* @return the categories
|
||||||
|
* @throws IOException
|
||||||
|
* Signals that an I/O exception has occurred.
|
||||||
|
*/
|
||||||
|
public static Categories loadCategories(final File source, final Federation federation) throws IOException
|
||||||
|
{
|
||||||
|
Categories result;
|
||||||
|
|
||||||
|
result = loadCategories(source);
|
||||||
|
|
||||||
|
Category other = new Category("{Autres}", "Qui ne rentre pas dans une catégorie existante.");
|
||||||
|
result.add(other);
|
||||||
|
|
||||||
|
for (Service service : federation.getAllServices())
|
||||||
|
{
|
||||||
|
if (!result.matches(service.getSoftwareName()))
|
||||||
|
{
|
||||||
|
other.getSoftwares().add(service.getSoftwareName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load configuration.
|
* Load configuration.
|
||||||
*
|
*
|
||||||
|
|
|
@ -36,6 +36,31 @@ public class Services extends ArrayList<Service>
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the by.
|
||||||
|
*
|
||||||
|
* @param category
|
||||||
|
* the category
|
||||||
|
* @return the by
|
||||||
|
*/
|
||||||
|
public Services getBy(final Category category)
|
||||||
|
{
|
||||||
|
Services result;
|
||||||
|
|
||||||
|
result = new Services();
|
||||||
|
|
||||||
|
for (Service service : this)
|
||||||
|
{
|
||||||
|
if (category.matches(service))
|
||||||
|
{
|
||||||
|
result.add(service);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reverse.
|
* Reverse.
|
||||||
*
|
*
|
||||||
|
|
97
src/fr/devinsy/statoolinfos/htmlize/CategoryPage.java
Normal file
97
src/fr/devinsy/statoolinfos/htmlize/CategoryPage.java
Normal file
|
@ -0,0 +1,97 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2020 Christian Pierre MOMON <christian@momon.org>
|
||||||
|
*
|
||||||
|
* 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 <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
package fr.devinsy.statoolinfos.htmlize;
|
||||||
|
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import fr.devinsy.statoolinfos.core.Category;
|
||||||
|
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 CategoryPage
|
||||||
|
{
|
||||||
|
private static Logger logger = LoggerFactory.getLogger(CategoryPage.class);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Builds the.
|
||||||
|
*
|
||||||
|
* @param categories
|
||||||
|
* the services
|
||||||
|
* @return the string
|
||||||
|
* @throws StatoolInfosException
|
||||||
|
* the statool infos exception
|
||||||
|
*/
|
||||||
|
public static String build(final Category category, final Services services) throws StatoolInfosException
|
||||||
|
{
|
||||||
|
String result;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
logger.debug("Building category page.");
|
||||||
|
|
||||||
|
TagDataManager data = new TagDataManager();
|
||||||
|
|
||||||
|
data.setContent("categoryName", category.getName());
|
||||||
|
data.setContent("categoryDescription", category.getDescription());
|
||||||
|
data.setContent("categorySoftwares", category.getSoftwares().toStringWithFrenchCommas());
|
||||||
|
data.setContent("serviceCount", services.size());
|
||||||
|
|
||||||
|
int index = 0;
|
||||||
|
for (Service service : services.sortByName())
|
||||||
|
{
|
||||||
|
data.setAttribute("serviceListLine", index, "serviceListLineNameLink", "href", service.getOrganization().getTechnicalName() + "-" + service.getTechnicalName() + ".xhtml");
|
||||||
|
data.setAttribute("serviceListLine", index, "serviceListLineLogo", "src", service.getOrganization().getTechnicalName() + "-" + service.getTechnicalName() + "-logo.png");
|
||||||
|
data.setEscapedContent("serviceListLine", index, "serviceListLineNameValue", service.getName());
|
||||||
|
|
||||||
|
data.setAttribute("serviceListLine", index, "serviceListLineOrganizationLink", "href", service.getOrganization().getTechnicalName() + ".xhtml");
|
||||||
|
data.setAttribute("serviceListLine", index, "serviceListLineOrganizationLogo", "src", service.getOrganization().getTechnicalName() + "-logo.png");
|
||||||
|
data.setEscapedContent("serviceListLine", index, "serviceListLineOrganizationValue", service.getOrganization().getName());
|
||||||
|
|
||||||
|
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.getSoftwareName());
|
||||||
|
|
||||||
|
index += 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/category.xhtml", data).toString();
|
||||||
|
|
||||||
|
BreadcrumbTrail trail = new BreadcrumbTrail();
|
||||||
|
trail.add("Catégories", "categories.xhtml");
|
||||||
|
trail.add("Catégorie", "category.xhtml");
|
||||||
|
result = WebCharterView.build(content, trail);
|
||||||
|
}
|
||||||
|
catch (XidynException exception)
|
||||||
|
{
|
||||||
|
throw new StatoolInfosException("Error building service page: " + exception.getMessage(), exception);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
|
@ -28,11 +28,13 @@ import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import fr.devinsy.statoolinfos.core.Categories;
|
import fr.devinsy.statoolinfos.core.Categories;
|
||||||
|
import fr.devinsy.statoolinfos.core.Category;
|
||||||
import fr.devinsy.statoolinfos.core.Configuration;
|
import fr.devinsy.statoolinfos.core.Configuration;
|
||||||
import fr.devinsy.statoolinfos.core.Factory;
|
import fr.devinsy.statoolinfos.core.Factory;
|
||||||
import fr.devinsy.statoolinfos.core.Federation;
|
import fr.devinsy.statoolinfos.core.Federation;
|
||||||
import fr.devinsy.statoolinfos.core.Organization;
|
import fr.devinsy.statoolinfos.core.Organization;
|
||||||
import fr.devinsy.statoolinfos.core.Service;
|
import fr.devinsy.statoolinfos.core.Service;
|
||||||
|
import fr.devinsy.statoolinfos.core.Services;
|
||||||
import fr.devinsy.statoolinfos.core.StatoolInfosException;
|
import fr.devinsy.statoolinfos.core.StatoolInfosException;
|
||||||
import fr.devinsy.statoolinfos.core.StatoolInfosUtils;
|
import fr.devinsy.statoolinfos.core.StatoolInfosUtils;
|
||||||
import fr.devinsy.statoolinfos.crawl.CrawlCache;
|
import fr.devinsy.statoolinfos.crawl.CrawlCache;
|
||||||
|
@ -209,6 +211,7 @@ public class Htmlizer
|
||||||
File htmlizeDirectory = configuration.getHtmlizeDirectory();
|
File htmlizeDirectory = configuration.getHtmlizeDirectory();
|
||||||
|
|
||||||
Federation federation = Factory.loadFederation(htmlizeInput, cache);
|
Federation federation = Factory.loadFederation(htmlizeInput, cache);
|
||||||
|
Categories categories = Factory.loadCategories(configuration.getCategoryFile(), federation);
|
||||||
|
|
||||||
copyStuff(htmlizeDirectory);
|
copyStuff(htmlizeDirectory);
|
||||||
|
|
||||||
|
@ -283,11 +286,21 @@ public class Htmlizer
|
||||||
//
|
//
|
||||||
{
|
{
|
||||||
logger.info("Htmlize categories page.");
|
logger.info("Htmlize categories page.");
|
||||||
Categories categories = Factory.loadCategories(configuration.getCategoryFile());
|
|
||||||
CategoryStats stats = StatAgent.statAllCategories(federation, categories);
|
CategoryStats stats = StatAgent.statAllCategories(federation, categories);
|
||||||
page = CategoriesPage.build(stats);
|
page = CategoriesPage.build(stats);
|
||||||
FileUtils.write(new File(htmlizeDirectory, "categories.xhtml"), page, StandardCharsets.UTF_8);
|
FileUtils.write(new File(htmlizeDirectory, "categories.xhtml"), page, StandardCharsets.UTF_8);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
{
|
||||||
|
logger.info("Htmlize category page.");
|
||||||
|
for (Category category : categories)
|
||||||
|
{
|
||||||
|
Services services = federation.getAllServices().getBy(category);
|
||||||
|
page = CategoryPage.build(category, services);
|
||||||
|
FileUtils.write(new File(htmlizeDirectory, "category-" + category.getTechnicalName() + ".xhtml"), page, StandardCharsets.UTF_8);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -62,8 +62,11 @@ public class ServicesPage
|
||||||
data.setAttribute("serviceListLine", index, "serviceListLineLogo", "src", service.getOrganization().getTechnicalName() + "-" + service.getTechnicalName() + "-logo.png");
|
data.setAttribute("serviceListLine", index, "serviceListLineLogo", "src", service.getOrganization().getTechnicalName() + "-" + service.getTechnicalName() + "-logo.png");
|
||||||
data.setEscapedContent("serviceListLine", index, "serviceListLineNameValue", service.getName());
|
data.setEscapedContent("serviceListLine", index, "serviceListLineNameValue", service.getName());
|
||||||
data.setAttribute("serviceListLine", index, "serviceListLineNameLink", "href", service.getOrganization().getTechnicalName() + "-" + service.getTechnicalName() + ".xhtml");
|
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.setAttribute("serviceListLine", index, "serviceListLineOrganizationLink", "href", service.getOrganization().getTechnicalName() + ".xhtml");
|
||||||
|
data.setAttribute("serviceListLine", index, "serviceListLineOrganizationLogo", "src", service.getOrganization().getTechnicalName() + "-logo.png");
|
||||||
|
data.setEscapedContent("serviceListLine", index, "serviceListLineOrganizationValue", service.getOrganization().getName());
|
||||||
|
|
||||||
data.setEscapedContent("serviceListLine", index, "serviceListLineUrlLink", service.getWebsite());
|
data.setEscapedContent("serviceListLine", index, "serviceListLineUrlLink", service.getWebsite());
|
||||||
data.setEscapedContent("serviceListLine", index, "serviceListLineWebsiteLink", service.getWebsite());
|
data.setEscapedContent("serviceListLine", index, "serviceListLineWebsiteLink", service.getWebsite());
|
||||||
data.setAttribute("serviceListLine", index, "serviceListLineWebsiteLink", "href", service.getWebsite());
|
data.setAttribute("serviceListLine", index, "serviceListLineWebsiteLink", "href", service.getWebsite());
|
||||||
|
|
54
src/fr/devinsy/statoolinfos/htmlize/category.xhtml
Normal file
54
src/fr/devinsy/statoolinfos/htmlize/category.xhtml
Normal file
|
@ -0,0 +1,54 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||||
|
<head>
|
||||||
|
<title>StatoolInfos</title>
|
||||||
|
<meta charset="UTF-8" />
|
||||||
|
<meta name="keywords" content="statoolinfos,devinsy,federation" />
|
||||||
|
<link rel="shortcut icon" href="favicon.ico" type="image/x-icon" />
|
||||||
|
<link rel="stylesheet" type="text/css" href="statoolinfos.css" />
|
||||||
|
<script src="sorttable.js" />
|
||||||
|
<script src="Chart.bundle.min.js"></script>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class="center">
|
||||||
|
<h2>Catégorie <span id="categoryName">n/a</span></h2>
|
||||||
|
|
||||||
|
<p id="categoryDescription">Bla bla description</p>
|
||||||
|
<div>Logiciels : <span id="categorySoftwares">Bla bla logiciels</span></div>
|
||||||
|
<div>Nombre de services : <span id="serviceCount">n/a</span></div>
|
||||||
|
<div class="left">
|
||||||
|
<table class="table_classic center_table sortable" style="width: 900px; margin-left: auto; margin-right: auto;">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th class="" style="width: 200px;">Nom du service</th>
|
||||||
|
<th class="" style="width: 200px;">Organisation</th>
|
||||||
|
<th class="" style="width: 200px;">URL</th>
|
||||||
|
<th class="" style="width: 200px;">Logiciel</th>
|
||||||
|
<th class="" style="width: 100px;">Utilisateurs mensuels</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<tr id="serviceListLine">
|
||||||
|
<td id="serviceListLineName" style="padding-top: 0; padding-bottom: 0;">
|
||||||
|
<a href="#" id="serviceListLineNameLink">
|
||||||
|
<img id="serviceListLineLogo" src="" style="width: 26px; height: 26px; padding-top:0; padding-bottom: 0; vertical-align: middle;"/>
|
||||||
|
 <span id="serviceListLineNameValue">n/a</span>
|
||||||
|
</a>
|
||||||
|
</td>
|
||||||
|
<td id="serviceListLineOrganization" style="padding-top: 0; padding-bottom: 0;">
|
||||||
|
<a href="#" id="serviceListLineOrganizationLink">
|
||||||
|
<img id="serviceListLineOrganizationLogo" src="" style="width: 26px; height: 26px; padding-top:0; padding-bottom: 0; vertical-align: middle;"/>
|
||||||
|
 <span id="serviceListLineOrganizationValue">n/a</span>
|
||||||
|
</a>
|
||||||
|
</td>
|
||||||
|
<td id="serviceListLineWebsite"><a href="#" id="serviceListLineWebsiteLink">n/a</a></td>
|
||||||
|
<td id="serviceListLineSoftware">n/a</td>
|
||||||
|
<td id="serviceListLineUserCount" class="td_number">n/a</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
|
@ -18,7 +18,7 @@
|
||||||
<table class="table_classic center_table sortable" style="width: 1000px; margin-left: auto; margin-right: auto;">
|
<table class="table_classic center_table sortable" style="width: 1000px; margin-left: auto; margin-right: auto;">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th style="width: 600px;">Nom</th>
|
<th style="width: 600px;">Nom local</th>
|
||||||
<th style="width: 300px;">Organisation</th>
|
<th style="width: 300px;">Organisation</th>
|
||||||
<th style="width: 100px;">Lignes</th>
|
<th style="width: 100px;">Lignes</th>
|
||||||
<th style="width: 100px;">Propriétés</th>
|
<th style="width: 100px;">Propriétés</th>
|
||||||
|
|
|
@ -11,11 +11,12 @@
|
||||||
<script src="Chart.bundle.min.js"></script>
|
<script src="Chart.bundle.min.js"></script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
<div class="center">
|
||||||
<h2>Tous les services</h2>
|
<h2>Tous les services</h2>
|
||||||
|
|
||||||
<div>Nombre de services : <span id="serviceCount">n/a</span></div>
|
<div>Nombre de services : <span id="serviceCount">n/a</span></div>
|
||||||
<div>
|
<div class="left">
|
||||||
<table class="table_classic sortable">
|
<table class="table_classic center_table sortable" style="width: 900px; margin-left: auto; margin-right: auto;">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th class="">Nom du service</th>
|
<th class="">Nom du service</th>
|
||||||
|
@ -33,7 +34,12 @@
|
||||||
 <span id="serviceListLineNameValue">n/a</span>
|
 <span id="serviceListLineNameValue">n/a</span>
|
||||||
</a>
|
</a>
|
||||||
</td>
|
</td>
|
||||||
<td id="serviceListLineOrganization"><a href="#" id="serviceListLineOrganizationLink">n/a</a></td>
|
<td id="serviceListLineOrganization" style="padding-top: 0; padding-bottom: 0;">
|
||||||
|
<a href="#" id="serviceListLineOrganizationLink">
|
||||||
|
<img id="serviceListLineOrganizationLogo" src="" style="width: 26px; height: 26px; padding-top:0; padding-bottom: 0; vertical-align: middle;"/>
|
||||||
|
 <span id="serviceListLineOrganizationValue">n/a</span>
|
||||||
|
</a>
|
||||||
|
</td>
|
||||||
<td id="serviceListLineWebsite"><a href="#" id="serviceListLineWebsiteLink">n/a</a></td>
|
<td id="serviceListLineWebsite"><a href="#" id="serviceListLineWebsiteLink">n/a</a></td>
|
||||||
<td id="serviceListLineSoftware">n/a</td>
|
<td id="serviceListLineSoftware">n/a</td>
|
||||||
<td id="serviceListLineUserCount" class="td_number">n/a</td>
|
<td id="serviceListLineUserCount" class="td_number">n/a</td>
|
||||||
|
@ -41,5 +47,6 @@
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -83,22 +83,6 @@ public class StatAgent
|
||||||
result.add(stat);
|
result.add(stat);
|
||||||
}
|
}
|
||||||
|
|
||||||
Category other = new Category("{Autres}", "Qui ne rentre pas dans une catégorie existante.");
|
|
||||||
CategoryStat stat = new CategoryStat(other);
|
|
||||||
StringSet organizations = new StringSet();
|
|
||||||
for (Service service : federation.getAllServices())
|
|
||||||
{
|
|
||||||
if (!categories.matches(service.getSoftwareName()))
|
|
||||||
{
|
|
||||||
stat.incServiceCount();
|
|
||||||
stat.incUserCount(service.getUserCount());
|
|
||||||
organizations.add(service.getOrganization().getName());
|
|
||||||
other.getSoftwares().add(service.getSoftwareName());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
stat.setOrganizationCount(organizations.size());
|
|
||||||
result.add(stat);
|
|
||||||
|
|
||||||
//
|
//
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue