Added status property stats in property file page.

This commit is contained in:
Christian P. MOMON 2020-10-24 04:41:02 +02:00
parent f01d42a3c6
commit 8e965f1464
7 changed files with 219 additions and 26 deletions

View file

@ -20,6 +20,8 @@ package fr.devinsy.statoolinfos.checker;
import java.util.ArrayList;
import fr.devinsy.statoolinfos.core.Service.Status;
/**
* The Class PropertyChecks.
*/
@ -57,4 +59,92 @@ public class PropertyChecks extends ArrayList<PropertyCheck>
//
return result;
}
/**
* Gets the alert count.
*
* @return the alert count
*/
public int getAlertCount()
{
int result;
result = 0;
for (PropertyCheck check : this)
{
if (check.getStatus() == Status.ALERT)
{
result += 1;
}
}
//
return result;
}
/**
* Gets the error count.
*
* @return the error count
*/
public int getErrorCount()
{
int result;
result = 0;
for (PropertyCheck check : this)
{
if (check.getStatus() == Status.ERROR)
{
result += 1;
}
}
//
return result;
}
/**
* Gets the void count.
*
* @return the void count
*/
public int getVoidCount()
{
int result;
result = 0;
for (PropertyCheck check : this)
{
if (check.getStatus() == Status.VOID)
{
result += 1;
}
}
//
return result;
}
/**
* Gets the warning count.
*
* @return the warning count
*/
public int getWarningCount()
{
int result;
result = 0;
for (PropertyCheck check : this)
{
if (check.getStatus() == Status.WARNING)
{
result += 1;
}
}
//
return result;
}
}

View file

@ -247,7 +247,7 @@ public class Factory
URL serviceInputURL = new URL(property.getValue());
Service service = loadService(serviceInputURL, cache);
service.setOrganization(result);
result.setLogoFileName(result.getTechnicalName() + "-" + result.getLogoFileName());
service.setLogoFileName(result.getTechnicalName() + "-" + result.getLogoFileName());
result.getServices().add(service);
}
}

View file

@ -79,7 +79,51 @@ public class PropertiesFilesPage
data.setContent("fileListLine", index, "fileListLineActiveCount", stat.getActiveLineCount());
data.setContent("fileListLine", index, "fileListLineBlankPropertyCount", stat.getBlankPropertyCount());
data.setContent("fileListLine", index, "fileListLineFilledPropertyCount", stat.getFilledPropertyCount());
if (stat.getWarningCount() > 0)
{
data.setAttribute("fileListLine", index, "fileListLineWarningCountLink", "href", stat.getLocalName().replace(".properties", "-check.xhtml"));
data.setContent("fileListLine", index, "fileListLineWarningCountLink", stat.getWarningCount());
data.setAttribute("fileListLine", index, "fileListLineWarningCount", "style", "background-color: yellow;");
}
else
{
data.setContent("fileListLine", index, "fileListLineWarningCount", stat.getWarningCount());
}
if (stat.getAlertCount() > 0)
{
data.setAttribute("fileListLine", index, "fileListLineAlertCountLink", "href", stat.getLocalName().replace(".properties", "-check.xhtml"));
data.setContent("fileListLine", index, "fileListLineAlertCountLink", stat.getAlertCount());
data.setAttribute("fileListLine", index, "fileListLineAlertCount", "style", "background-color: orange;");
}
else
{
data.setContent("fileListLine", index, "fileListLineAlertCount", stat.getAlertCount());
}
if (stat.getErrorCount() > 0)
{
data.setAttribute("fileListLine", index, "fileListLineErrorCountLink", "href", stat.getLocalName().replace(".properties", "-check.xhtml"));
data.setContent("fileListLine", index, "fileListLineErrorCountLink", stat.getErrorCount());
data.setAttribute("fileListLine", index, "fileListLineErrorCount", "style", "background-color: red;");
}
else
{
data.setContent("fileListLine", index, "fileListLineErrorCount", stat.getErrorCount());
}
if (stat.getVoidCount() > 0)
{
data.setAttribute("fileListLine", index, "fileListLineVoidCountLink", "href", stat.getLocalName().replace(".properties", "-check.xhtml"));
data.setContent("fileListLine", index, "fileListLineVoidCountLink", stat.getVoidCount());
data.setAttribute("fileListLine", index, "fileListLineVoidCount", "style", "background-color: rgb(54, 162, 235, 0.2);");
}
else
{
data.setContent("fileListLine", index, "fileListLineVoidCount", stat.getVoidCount());
}
data.setContent("fileListLine", index, "fileListLineDate", stat.getUpdateDate().toString());
index += 1;

View file

@ -11,7 +11,7 @@
<script src="Chart.bundle.min.js"></script>
</head>
<body>
<div class="center_table" style="width: 1200px;">
<div class="center_table" style="width: 1400px;">
<div class="center" >
<h2>Fichiers properties</h2>
<div>Nombre de fichiers : <span id="fileCount">n/a</span></div>
@ -25,7 +25,10 @@
<th style="width: 100px;">Propriétés</th>
<th style="width: 100px;">Remplies</th>
<th style="width: 100px;">Vides</th>
<th style="width: 100px;">Warning</th>
<th style="width: 100px;">Alerte</th>
<th style="width: 100px;">Erreurs</th>
<th style="width: 100px;">Inconnues</th>
<th style="width: 100px;">Date</th>
</tr>
</thead>
@ -44,7 +47,10 @@
<td id="fileListLineActiveCount" class="td_number">n/a</td>
<td id="fileListLineFilledPropertyCount" class="td_number">n/a</td>
<td id="fileListLineBlankPropertyCount" class="td_number">n/a</td>
<td id="fileListLineErrorCount" class="td_number">n/a</td>
<td id="fileListLineWarningCount" class="td_number"><a id="fileListLineWarningCountLink" href="#">n/a</a></td>
<td id="fileListLineAlertCount" class="td_number"><a id="fileListLineAlertCountLink" href="#">n/a</a></td>
<td id="fileListLineErrorCount" class="td_number"><a id="fileListLineErrorCountLink" href="#">n/a</a></td>
<td id="fileListLineVoidCount" class="td_number"><a id="fileListLineVoidCountLink" href="#">n/a</a></td>
<td id="fileListLineDate" class="td_number">n/a</td>
</tr>
</tbody>

View file

@ -140,11 +140,11 @@ public class StatAgent
for (Organization organization : federation.getOrganizations())
{
result.add(result.stat(organization));
result.stat(organization);
for (Service service : organization.getServices())
{
result.add(result.stat(service));
result.stat(service);
}
}

View file

@ -35,7 +35,10 @@ public class PropertiesFileStat
private int activeLineCount;
private int blankPropertyCount;
private int filledPropertyCount;
private int warningCount;
private int alertCount;
private int errorCount;
private int voidCount;
private LocalDateTime updateDate;
/**
@ -50,6 +53,11 @@ public class PropertiesFileStat
return this.activeLineCount;
}
public int getAlertCount()
{
return this.alertCount;
}
public int getBlankPropertyCount()
{
return this.blankPropertyCount;
@ -90,11 +98,26 @@ public class PropertiesFileStat
return this.url;
}
public int getVoidCount()
{
return this.voidCount;
}
public int getWarningCount()
{
return this.warningCount;
}
public void incActiveLineCount()
{
this.activeLineCount += 1;
}
public void incAlertCount()
{
this.alertCount += 1;
}
public void incBlankPropertyCount()
{
this.blankPropertyCount += 1;
@ -115,11 +138,26 @@ public class PropertiesFileStat
this.lineCount += 1;
}
public void incVoidCount()
{
this.voidCount += 1;
}
public void incWarningCount()
{
this.warningCount += 1;
}
public void setActiveLineCount(final int activeLineCount)
{
this.activeLineCount = activeLineCount;
}
public void setAlertCount(final int alertCount)
{
this.alertCount = alertCount;
}
public void setBlankPropertyCount(final int blankPropertyCount)
{
this.blankPropertyCount = blankPropertyCount;
@ -159,4 +197,14 @@ public class PropertiesFileStat
{
this.url = url;
}
public void setVoidCount(final int voidCount)
{
this.voidCount = voidCount;
}
public void setWarningCount(final int warningCount)
{
this.warningCount = warningCount;
}
}

View file

@ -24,6 +24,8 @@ import java.util.ArrayList;
import org.apache.commons.lang3.StringUtils;
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.strings.StringList;
@ -125,23 +127,26 @@ public class PropertiesFileStats extends ArrayList<PropertiesFileStat>
*
* @param organization
* the organization
* @return the properties file stat
* @throws IOException
* Signals that an I/O exception has occurred.
*/
public PropertiesFileStat stat(final Organization organization) throws IOException
public void stat(final Organization organization) throws IOException
{
PropertiesFileStat result;
PropertiesFileStat stat = stat(organization.getInputFile());
result = stat(organization.getInputFile());
stat.setURL(organization.getInputURL());
stat.setLocalName(organization.getTechnicalName() + ".properties");
stat.setOrganization(organization);
stat.setUpdateDate(organization.getCrawledDate());
result.setURL(organization.getInputURL());
result.setLocalName(organization.getTechnicalName() + ".properties");
result.setOrganization(organization);
result.setUpdateDate(organization.getCrawledDate());
PropertyChecker checker = new PropertyChecker();
PropertyChecks checks = checker.checkOrganization(organization.getInputFile());
stat.setWarningCount(checks.getWarningCount());
stat.setAlertCount(checks.getAlertCount());
stat.setErrorCount(checks.getErrorCount());
stat.setVoidCount(checks.getVoidCount());
//
return result;
add(stat);
}
/**
@ -149,22 +154,22 @@ public class PropertiesFileStats extends ArrayList<PropertiesFileStat>
*
* @param service
* the service
* @return the properties file stat
* @throws IOException
* Signals that an I/O exception has occurred.
*/
public PropertiesFileStat stat(final Service service) throws IOException
public void stat(final Service service) throws IOException
{
PropertiesFileStat result;
PropertiesFileStat stat = stat(service.getInputFile());
result = stat(service.getInputFile());
stat.setURL(service.getInputURL());
stat.setLocalName(service.getOrganization().getTechnicalName() + "-" + service.getTechnicalName() + ".properties");
stat.setOrganization(service.getOrganization());
stat.setUpdateDate(service.getCrawledDate());
result.setURL(service.getInputURL());
result.setLocalName(service.getOrganization().getTechnicalName() + "-" + service.getTechnicalName() + ".properties");
result.setOrganization(service.getOrganization());
result.setUpdateDate(service.getCrawledDate());
PropertyChecker checker = new PropertyChecker();
PropertyChecks checks = checker.checkService(service.getInputFile());
stat.setErrorCount(checks.getErrorCount());
//
return result;
add(stat);
}
}