Refactored check and check alerts. Add check alerts for federation.
This commit is contained in:
parent
54203f50a0
commit
a9cf905788
11 changed files with 153 additions and 82 deletions
|
@ -26,6 +26,8 @@ import org.apache.commons.lang3.StringUtils;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import fr.devinsy.statoolinfos.checker.PropertyChecker;
|
||||
import fr.devinsy.statoolinfos.checker.PropertyChecks;
|
||||
import fr.devinsy.statoolinfos.crawl.CrawlCache;
|
||||
import fr.devinsy.statoolinfos.properties.PathProperties;
|
||||
import fr.devinsy.statoolinfos.properties.PathProperty;
|
||||
|
@ -166,6 +168,11 @@ public class Factory
|
|||
result.setInputFile(federationFile);
|
||||
result.setLogoFileName(result.getTechnicalName() + "-logo" + StringUtils.defaultIfBlank(cache.getExtension(result.getLogoURL()), ".png"));
|
||||
|
||||
PropertyChecker checker = new PropertyChecker();
|
||||
PropertyChecks checks = checker.checkFederation(result.getInputFile());
|
||||
result.getInputChecks().addAll(checks);
|
||||
result.getInputChecks().setFileName(result.getLocalFileName());
|
||||
|
||||
PathProperties subs = result.getByPrefix("subs");
|
||||
for (PathProperty property : subs)
|
||||
{
|
||||
|
@ -252,6 +259,12 @@ public class Factory
|
|||
result.setInputURL(inputURL);
|
||||
result.setLogoFileName(result.getTechnicalName() + "-logo" + StringUtils.defaultIfBlank(cache.getExtension(result.getLogoURL()), ".png"));
|
||||
|
||||
//
|
||||
PropertyChecker checker = new PropertyChecker();
|
||||
PropertyChecks checks = checker.checkOrganization(result.getInputFile());
|
||||
result.getInputChecks().addAll(checks);
|
||||
result.getInputChecks().setFileName(result.getLocalFileName());
|
||||
|
||||
PathProperties subs = result.getByPrefix("subs");
|
||||
for (PathProperty property : subs)
|
||||
{
|
||||
|
@ -263,6 +276,11 @@ public class Factory
|
|||
{
|
||||
service.setOrganization(result);
|
||||
service.setLogoFileName(result.getTechnicalName() + "-" + service.getLogoFileName());
|
||||
|
||||
PropertyChecks subChecks = checker.checkService(service.getInputFile());
|
||||
service.getInputChecks().addAll(subChecks);
|
||||
service.getInputChecks().setFileName(service.getLocalFileName());
|
||||
|
||||
result.getServices().add(service);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,6 +25,7 @@ import java.time.LocalDateTime;
|
|||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import fr.devinsy.statoolinfos.checker.PropertyChecks;
|
||||
import fr.devinsy.statoolinfos.properties.PathProperties;
|
||||
import fr.devinsy.statoolinfos.properties.PathPropertyList;
|
||||
|
||||
|
@ -37,6 +38,7 @@ public class Federation extends PathPropertyList
|
|||
private Organizations organizations;
|
||||
private File inputFile;
|
||||
private String logoFileName;
|
||||
private PropertyChecks inputChecks;
|
||||
|
||||
/**
|
||||
* Instantiates a new federation.
|
||||
|
@ -44,6 +46,7 @@ public class Federation extends PathPropertyList
|
|||
public Federation()
|
||||
{
|
||||
super();
|
||||
this.inputChecks = new PropertyChecks();
|
||||
this.organizations = new Organizations();
|
||||
}
|
||||
|
||||
|
@ -56,6 +59,7 @@ public class Federation extends PathPropertyList
|
|||
public Federation(final PathProperties properties)
|
||||
{
|
||||
super(properties);
|
||||
this.inputChecks = new PropertyChecks();
|
||||
|
||||
if ((properties == null) || (StringUtils.isBlank(properties.get("federation.name"))))
|
||||
{
|
||||
|
@ -148,6 +152,33 @@ public class Federation extends PathPropertyList
|
|||
return result;
|
||||
}
|
||||
|
||||
public PropertyChecks getInputChecks()
|
||||
{
|
||||
return this.inputChecks;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the input checks all.
|
||||
*
|
||||
* @return the input checks all
|
||||
*/
|
||||
public PropertyChecks getInputChecksAll()
|
||||
{
|
||||
PropertyChecks result;
|
||||
|
||||
result = new PropertyChecks();
|
||||
|
||||
result.addAll(this.getInputChecks());
|
||||
|
||||
for (Organization organization : this.organizations)
|
||||
{
|
||||
result.addAll(organization.getInputChecksAll());
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
public File getInputFile()
|
||||
{
|
||||
return this.inputFile;
|
||||
|
@ -168,6 +199,21 @@ public class Federation extends PathPropertyList
|
|||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the local file name.
|
||||
*
|
||||
* @return the local file name
|
||||
*/
|
||||
public String getLocalFileName()
|
||||
{
|
||||
String result;
|
||||
|
||||
result = getTechnicalName() + ".properties";
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
public String getLogoFileName()
|
||||
{
|
||||
return this.logoFileName;
|
||||
|
|
|
@ -27,6 +27,7 @@ import java.time.LocalDateTime;
|
|||
import org.apache.commons.codec.digest.DigestUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import fr.devinsy.statoolinfos.checker.PropertyChecks;
|
||||
import fr.devinsy.statoolinfos.properties.PathProperties;
|
||||
import fr.devinsy.statoolinfos.properties.PathPropertyList;
|
||||
|
||||
|
@ -41,6 +42,7 @@ public class Organization extends PathPropertyList
|
|||
private File inputFile;
|
||||
private URL inputURL;
|
||||
private String logoFileName;
|
||||
private PropertyChecks inputChecks;
|
||||
|
||||
/**
|
||||
* Instantiates a new organization.
|
||||
|
@ -48,6 +50,7 @@ public class Organization extends PathPropertyList
|
|||
public Organization()
|
||||
{
|
||||
super();
|
||||
this.inputChecks = new PropertyChecks();
|
||||
this.services = new Services();
|
||||
}
|
||||
|
||||
|
@ -60,6 +63,7 @@ public class Organization extends PathPropertyList
|
|||
public Organization(final PathProperties properties)
|
||||
{
|
||||
super(properties);
|
||||
this.inputChecks = new PropertyChecks();
|
||||
this.services = new Services();
|
||||
}
|
||||
|
||||
|
@ -201,6 +205,32 @@ public class Organization extends PathPropertyList
|
|||
return result;
|
||||
}
|
||||
|
||||
public PropertyChecks getInputChecks()
|
||||
{
|
||||
return this.inputChecks;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the input checks all.
|
||||
*
|
||||
* @return the input checks all
|
||||
*/
|
||||
public PropertyChecks getInputChecksAll()
|
||||
{
|
||||
PropertyChecks result;
|
||||
|
||||
result = new PropertyChecks();
|
||||
|
||||
result.addAll(this.inputChecks);
|
||||
for (Service service : this.services)
|
||||
{
|
||||
result.addAll(service.getInputChecks());
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
public File getInputFile()
|
||||
{
|
||||
return this.inputFile;
|
||||
|
|
|
@ -32,6 +32,7 @@ import org.apache.commons.lang3.StringUtils;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import fr.devinsy.statoolinfos.checker.PropertyChecks;
|
||||
import fr.devinsy.statoolinfos.metrics.Metric;
|
||||
import fr.devinsy.statoolinfos.properties.PathProperties;
|
||||
import fr.devinsy.statoolinfos.properties.PathProperty;
|
||||
|
@ -102,13 +103,14 @@ public class Service extends PathPropertyList
|
|||
private File inputFile;
|
||||
private URL inputURL;
|
||||
private String logoFileName;
|
||||
private PropertyChecks inputChecks;
|
||||
|
||||
/**
|
||||
* Instantiates a new service.
|
||||
*/
|
||||
public Service()
|
||||
{
|
||||
super(null);
|
||||
this(null);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -120,6 +122,7 @@ public class Service extends PathPropertyList
|
|||
public Service(final PathProperties properties)
|
||||
{
|
||||
super(properties);
|
||||
this.inputChecks = new PropertyChecks();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -293,6 +296,11 @@ public class Service extends PathPropertyList
|
|||
return result;
|
||||
}
|
||||
|
||||
public PropertyChecks getInputChecks()
|
||||
{
|
||||
return this.inputChecks;
|
||||
}
|
||||
|
||||
public File getInputFile()
|
||||
{
|
||||
return this.inputFile;
|
||||
|
|
|
@ -29,6 +29,7 @@ import org.slf4j.LoggerFactory;
|
|||
|
||||
import fr.devinsy.catgenerator.core.CatGenerator;
|
||||
import fr.devinsy.statoolinfos.HtmlizerContext;
|
||||
import fr.devinsy.statoolinfos.checker.PropertyChecks;
|
||||
import fr.devinsy.statoolinfos.core.Federation;
|
||||
import fr.devinsy.statoolinfos.core.Organization;
|
||||
import fr.devinsy.statoolinfos.core.StatoolInfosException;
|
||||
|
@ -69,6 +70,10 @@ public class FederationPage
|
|||
logger.info("PAGE FEDERATION federation page: {}.", federation.getName());
|
||||
String page = htmlize(federation);
|
||||
FileUtils.write(new File(htmlizeDirectory, "index.xhtml"), page, StandardCharsets.UTF_8);
|
||||
|
||||
//
|
||||
page = PropertyFilesCheckPage.htmlize(federation.getName(), federation.getInputChecksAll().getAlertLines());
|
||||
FileUtils.write(new File(htmlizeDirectory, federation.getTechnicalName() + "-checkalerts.xhtml"), page, StandardCharsets.UTF_8);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -104,6 +109,16 @@ public class FederationPage
|
|||
|
||||
data.setAttribute("statsLink", "href", federation.getTechnicalName() + "-stats.xhtml");
|
||||
|
||||
{
|
||||
PropertyChecks checks = federation.getInputChecksAll();
|
||||
|
||||
data.setContent("errorCount", checks.getErrorCount());
|
||||
data.setContent("warningCount", checks.getWarningCount());
|
||||
data.setContent("voidCount", checks.getVoidCount());
|
||||
|
||||
data.setAttribute("alertLink", "href", federation.getTechnicalName() + "-checkalerts.xhtml");
|
||||
}
|
||||
|
||||
if (StringUtils.isNotBlank(federation.getLegalWebsite()))
|
||||
{
|
||||
data.setEscapedAttribute("legalLink", "href", federation.getLegalWebsite());
|
||||
|
|
|
@ -29,11 +29,8 @@ import org.slf4j.LoggerFactory;
|
|||
|
||||
import fr.devinsy.catgenerator.core.CatGenerator;
|
||||
import fr.devinsy.statoolinfos.HtmlizerContext;
|
||||
import fr.devinsy.statoolinfos.checker.PropertyCheck;
|
||||
import fr.devinsy.statoolinfos.checker.PropertyChecker;
|
||||
import fr.devinsy.statoolinfos.checker.PropertyChecks;
|
||||
import fr.devinsy.statoolinfos.core.Organization;
|
||||
import fr.devinsy.statoolinfos.core.Service;
|
||||
import fr.devinsy.statoolinfos.core.StatoolInfosException;
|
||||
import fr.devinsy.statoolinfos.crawl.CrawlCache;
|
||||
import fr.devinsy.xidyn.XidynException;
|
||||
|
@ -74,34 +71,9 @@ public class OrganizationPage
|
|||
String page = OrganizationPage.htmlize(organization);
|
||||
FileUtils.write(new File(htmlizeDirectory, organization.getTechnicalName() + ".xhtml"), page, StandardCharsets.UTF_8);
|
||||
|
||||
{
|
||||
try
|
||||
{
|
||||
PropertyChecker checker = new PropertyChecker();
|
||||
PropertyChecks checks = checker.checkOrganization(organization.getInputFile());
|
||||
for (PropertyCheck check : checks)
|
||||
{
|
||||
check.setFileName(organization.getLocalFileName());
|
||||
}
|
||||
|
||||
for (Service service : organization.getServices())
|
||||
{
|
||||
PropertyChecks subChecks = checker.checkService(service.getInputFile());
|
||||
for (PropertyCheck check : subChecks)
|
||||
{
|
||||
check.setFileName(service.getLocalFileName());
|
||||
}
|
||||
checks.addAll(subChecks);
|
||||
}
|
||||
|
||||
page = PropertyFilesCheckPage.htmlize(organization.getName(), checks.getAlertLines());
|
||||
FileUtils.write(new File(htmlizeDirectory, "alertChecks-" + organization.getTechnicalName() + ".xhtml"), page, StandardCharsets.UTF_8);
|
||||
}
|
||||
catch (IOException exception)
|
||||
{
|
||||
exception.printStackTrace();
|
||||
}
|
||||
}
|
||||
//
|
||||
page = PropertyFilesCheckPage.htmlize(organization.getName(), organization.getInputChecksAll().getAlertLines());
|
||||
FileUtils.write(new File(htmlizeDirectory, organization.getTechnicalName() + "-checkalerts.xhtml"), page, StandardCharsets.UTF_8);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -173,29 +145,6 @@ public class OrganizationPage
|
|||
data.setContent("organizationStartDateWord", "");
|
||||
}
|
||||
|
||||
{
|
||||
try
|
||||
{
|
||||
PropertyChecker checker = new PropertyChecker();
|
||||
PropertyChecks checks = checker.checkOrganization(organization.getInputFile());
|
||||
for (Service service : organization.getServices())
|
||||
{
|
||||
PropertyChecks subChecks = checker.checkService(service.getInputFile());
|
||||
checks.addAll(subChecks);
|
||||
}
|
||||
|
||||
data.setContent("errorCount", checks.getErrorCount());
|
||||
data.setContent("warningCount", checks.getWarningCount());
|
||||
data.setContent("voidCount", checks.getVoidCount());
|
||||
|
||||
data.setAttribute("alertLink", "href", "alertChecks-" + organization.getTechnicalName() + ".xhtml");
|
||||
}
|
||||
catch (IOException exception)
|
||||
{
|
||||
exception.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
data.setContent("serviceCount", organization.getServices().size());
|
||||
|
||||
data.setAttribute("rawLink", "href", organization.getTechnicalName() + ".properties");
|
||||
|
@ -203,6 +152,16 @@ public class OrganizationPage
|
|||
|
||||
data.setAttribute("statsLink", "href", organization.getTechnicalName() + "-stats.xhtml");
|
||||
|
||||
{
|
||||
PropertyChecks checks = organization.getInputChecksAll();
|
||||
|
||||
data.setContent("errorCount", checks.getErrorCount());
|
||||
data.setContent("warningCount", checks.getWarningCount());
|
||||
data.setContent("voidCount", checks.getVoidCount());
|
||||
|
||||
data.setAttribute("alertLink", "href", organization.getTechnicalName() + "-checkalerts.xhtml");
|
||||
}
|
||||
|
||||
if (StringUtils.isNotBlank(organization.getLegalWebsite()))
|
||||
{
|
||||
data.setEscapedAttribute("legalLink", "href", organization.getLegalWebsite());
|
||||
|
|
|
@ -28,7 +28,6 @@ import org.slf4j.LoggerFactory;
|
|||
|
||||
import fr.devinsy.statoolinfos.HtmlizerContext;
|
||||
import fr.devinsy.statoolinfos.checker.PropertyCheck;
|
||||
import fr.devinsy.statoolinfos.checker.PropertyChecker;
|
||||
import fr.devinsy.statoolinfos.checker.PropertyChecks;
|
||||
import fr.devinsy.statoolinfos.core.Federation;
|
||||
import fr.devinsy.statoolinfos.core.Organization;
|
||||
|
@ -57,15 +56,13 @@ public class PropertyFileCheckPage
|
|||
Federation federation = HtmlizerContext.instance().getFederation();
|
||||
File htmlizeDirectory = HtmlizerContext.instance().getHtmlizeDirectory();
|
||||
|
||||
PropertyChecker checker = new PropertyChecker();
|
||||
|
||||
PropertyChecks allAlertChecks = new PropertyChecks();
|
||||
PropertyChecks federationAlertChecks = new PropertyChecks();
|
||||
PropertyChecks organizationAlertChecks = new PropertyChecks();
|
||||
PropertyChecks serviceAlertChecks = new PropertyChecks();
|
||||
|
||||
//
|
||||
PropertyChecks checks = checker.checkFederation(federation.getInputFile());
|
||||
PropertyChecks checks = federation.getInputChecks();
|
||||
String page = htmlize("Fédération", checks);
|
||||
FileUtils.write(new File(htmlizeDirectory, federation.getTechnicalName() + "-check.xhtml"), page, StandardCharsets.UTF_8);
|
||||
|
||||
|
@ -76,7 +73,7 @@ public class PropertyFileCheckPage
|
|||
//
|
||||
for (Organization organization : federation.getOrganizations())
|
||||
{
|
||||
checks = checker.checkOrganization(organization.getInputFile());
|
||||
checks = organization.getInputChecks();
|
||||
page = htmlize("Organisation", checks);
|
||||
FileUtils.write(new File(htmlizeDirectory, organization.getTechnicalName() + "-check.xhtml"), page, StandardCharsets.UTF_8);
|
||||
|
||||
|
@ -89,7 +86,7 @@ public class PropertyFileCheckPage
|
|||
|
||||
for (Service service : organization.getServices())
|
||||
{
|
||||
checks = checker.checkService(service.getInputFile());
|
||||
checks = service.getInputChecks();
|
||||
page = htmlize("Service", checks);
|
||||
FileUtils.write(new File(htmlizeDirectory, organization.getTechnicalName() + "-" + service.getTechnicalName() + "-check.xhtml"), page, StandardCharsets.UTF_8);
|
||||
|
||||
|
|
|
@ -29,7 +29,6 @@ import org.slf4j.LoggerFactory;
|
|||
|
||||
import fr.devinsy.catgenerator.core.BirdGenerator;
|
||||
import fr.devinsy.statoolinfos.HtmlizerContext;
|
||||
import fr.devinsy.statoolinfos.checker.PropertyChecker;
|
||||
import fr.devinsy.statoolinfos.checker.PropertyChecks;
|
||||
import fr.devinsy.statoolinfos.core.Organization;
|
||||
import fr.devinsy.statoolinfos.core.Service;
|
||||
|
@ -107,7 +106,7 @@ public class ServicePage
|
|||
|
||||
try
|
||||
{
|
||||
logger.debug("Building organization page {}…", service.get("organization.name"));
|
||||
logger.debug("Building service page {}…", service.get("service.name"));
|
||||
|
||||
TagDataManager data = new TagDataManager();
|
||||
|
||||
|
@ -223,21 +222,13 @@ public class ServicePage
|
|||
}
|
||||
|
||||
{
|
||||
try
|
||||
{
|
||||
PropertyChecker checker = new PropertyChecker();
|
||||
PropertyChecks checks = checker.checkService(service.getInputFile());
|
||||
PropertyChecks checks = service.getInputChecks();
|
||||
data.setContent("errorCount", checks.getErrorCount());
|
||||
data.setContent("warningCount", checks.getWarningCount());
|
||||
data.setContent("voidCount", checks.getVoidCount());
|
||||
|
||||
data.setAttribute("alertLink", "href", organization.getTechnicalName() + "-" + service.getTechnicalName() + "-check.xhtml#alerts");
|
||||
}
|
||||
catch (IOException exception)
|
||||
{
|
||||
exception.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
int graphicIndex = 0;
|
||||
|
|
|
@ -32,6 +32,13 @@
|
|||
<a id="rawCheckLink" href="#"><img id="rawCheckLinkImg" src="circle-icons/clipboard-mono.svg" title="Fichier propriétés analysé"/></a>
|
||||
<a id="rawLink" href="#"><img id="rawLinkImg" src="circle-icons/document-mono.svg" title="Fichier propriétés"/></a>
|
||||
<a id="statsLink" href="#"><img id="statsLinkImg" src="circle-icons/barchart-mono.svg" title="Statistiques"/></a>
|
||||
<div style="display: inline-block; vertical-align: middle; font-size: smaller; margin-left: 2px; width: 35px;">
|
||||
<a id="alertLink" href="#" style="text-decoration: none;">
|
||||
<div id="errorCount" class="bg_error center" title="Propriétés en erreurs">n/a</div>
|
||||
<div id="warningCount" class="bg_warning cener" title="Propriétés attendues">n/a</div>
|
||||
<div id="voidCount" class="bg_void center" title="Propriétés Inconnues">n/a</div>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
<br/>
|
||||
</div>
|
||||
|
|
|
@ -36,9 +36,9 @@
|
|||
<a id="statsLink" href="#"><img id="statsLinkImg" src="circle-icons/barchart-mono.svg" title="Statistiques"/></a>
|
||||
<div style="display: inline-block; vertical-align: middle; font-size: smaller; margin-left: 2px; width: 35px;">
|
||||
<a id="alertLink" href="#" style="text-decoration: none;">
|
||||
<div id="errorCount" class="bg_error" style="padding: 0 10px;" title="Propriétés en erreurs">n/a</div>
|
||||
<div id="warningCount" class="bg_warning" style="padding: 0 10px;" title="Propriétés attendues">n/a</div>
|
||||
<div id="voidCount" class="bg_void" style="padding: 0 10px;" title="Propriétés Inconnues">n/a</div>
|
||||
<div id="errorCount" class="bg_error center" title="Propriétés en erreurs">n/a</div>
|
||||
<div id="warningCount" class="bg_warning center" title="Propriétés attendues">n/a</div>
|
||||
<div id="voidCount" class="bg_void center" title="Propriétés Inconnues">n/a</div>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -44,9 +44,9 @@
|
|||
<a id="statsLink" href="#"><img id="statsLinkImg" src="circle-icons/barchart-mono.svg" title="Statistiques"/></a>
|
||||
<div style="display: inline-block; vertical-align: middle; font-size: smaller; margin-left: 2px; width: 35px;">
|
||||
<a id="alertLink" href="#" style="text-decoration: none;">
|
||||
<div id="errorCount" class="bg_error" style="padding: 0 10px;" title="Propriétés en erreurs">n/a</div>
|
||||
<div id="warningCount" class="bg_warning" style="padding: 0 10px;" title="Propriétés attendues">n/a</div>
|
||||
<div id="voidCount" class="bg_void" style="padding: 0 10px;" title="Propriétés Inconnues">n/a</div>
|
||||
<div id="errorCount" class="bg_error center" title="Propriétés en erreurs">n/a</div>
|
||||
<div id="warningCount" class="bg_warning center" title="Propriétés attendues">n/a</div>
|
||||
<div id="voidCount" class="bg_void center" title="Propriétés Inconnues">n/a</div>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
|
Loading…
Reference in a new issue