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 d0e2c5c9b0
7 changed files with 207 additions and 27 deletions

View file

@ -20,6 +20,8 @@ package fr.devinsy.statoolinfos.checker;
import java.util.ArrayList; import java.util.ArrayList;
import fr.devinsy.statoolinfos.core.Service.Status;
/** /**
* The Class PropertyChecks. * The Class PropertyChecks.
*/ */
@ -57,4 +59,92 @@ public class PropertyChecks extends ArrayList<PropertyCheck>
// //
return result; 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()); URL serviceInputURL = new URL(property.getValue());
Service service = loadService(serviceInputURL, cache); Service service = loadService(serviceInputURL, cache);
service.setOrganization(result); service.setOrganization(result);
result.setLogoFileName(result.getTechnicalName() + "-" + result.getLogoFileName()); service.setLogoFileName(result.getTechnicalName() + "-" + result.getLogoFileName());
result.getServices().add(service); result.getServices().add(service);
} }
} }

View file

@ -79,7 +79,40 @@ public class PropertiesFilesPage
data.setContent("fileListLine", index, "fileListLineActiveCount", stat.getActiveLineCount()); data.setContent("fileListLine", index, "fileListLineActiveCount", stat.getActiveLineCount());
data.setContent("fileListLine", index, "fileListLineBlankPropertyCount", stat.getBlankPropertyCount()); data.setContent("fileListLine", index, "fileListLineBlankPropertyCount", stat.getBlankPropertyCount());
data.setContent("fileListLine", index, "fileListLineFilledPropertyCount", stat.getFilledPropertyCount()); 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.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()); 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()); data.setContent("fileListLine", index, "fileListLineDate", stat.getUpdateDate().toString());
index += 1; index += 1;

View file

@ -11,7 +11,7 @@
<script src="Chart.bundle.min.js"></script> <script src="Chart.bundle.min.js"></script>
</head> </head>
<body> <body>
<div class="center_table" style="width: 1200px;"> <div class="center_table" style="width: 1400px;">
<div class="center" > <div class="center" >
<h2>Fichiers properties</h2> <h2>Fichiers properties</h2>
<div>Nombre de fichiers : <span id="fileCount">n/a</span></div> <div>Nombre de fichiers : <span id="fileCount">n/a</span></div>
@ -25,7 +25,9 @@
<th style="width: 100px;">Propriétés</th> <th style="width: 100px;">Propriétés</th>
<th style="width: 100px;">Remplies</th> <th style="width: 100px;">Remplies</th>
<th style="width: 100px;">Vides</th> <th style="width: 100px;">Vides</th>
<th style="width: 100px;">Erreurs</th> <th style="width: 50px;">Attendues</th>
<th style="width: 50px;">Erreurs</th>
<th style="width: 50px;">Inconnues</th>
<th style="width: 100px;">Date</th> <th style="width: 100px;">Date</th>
</tr> </tr>
</thead> </thead>
@ -44,7 +46,9 @@
<td id="fileListLineActiveCount" class="td_number">n/a</td> <td id="fileListLineActiveCount" class="td_number">n/a</td>
<td id="fileListLineFilledPropertyCount" 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="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="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> <td id="fileListLineDate" class="td_number">n/a</td>
</tr> </tr>
</tbody> </tbody>

View file

@ -140,11 +140,11 @@ public class StatAgent
for (Organization organization : federation.getOrganizations()) for (Organization organization : federation.getOrganizations())
{ {
result.add(result.stat(organization)); result.stat(organization);
for (Service service : organization.getServices()) 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 activeLineCount;
private int blankPropertyCount; private int blankPropertyCount;
private int filledPropertyCount; private int filledPropertyCount;
private int warningCount;
private int alertCount;
private int errorCount; private int errorCount;
private int voidCount;
private LocalDateTime updateDate; private LocalDateTime updateDate;
/** /**
@ -50,6 +53,11 @@ public class PropertiesFileStat
return this.activeLineCount; return this.activeLineCount;
} }
public int getAlertCount()
{
return this.alertCount;
}
public int getBlankPropertyCount() public int getBlankPropertyCount()
{ {
return this.blankPropertyCount; return this.blankPropertyCount;
@ -90,11 +98,26 @@ public class PropertiesFileStat
return this.url; return this.url;
} }
public int getVoidCount()
{
return this.voidCount;
}
public int getWarningCount()
{
return this.warningCount;
}
public void incActiveLineCount() public void incActiveLineCount()
{ {
this.activeLineCount += 1; this.activeLineCount += 1;
} }
public void incAlertCount()
{
this.alertCount += 1;
}
public void incBlankPropertyCount() public void incBlankPropertyCount()
{ {
this.blankPropertyCount += 1; this.blankPropertyCount += 1;
@ -115,11 +138,26 @@ public class PropertiesFileStat
this.lineCount += 1; this.lineCount += 1;
} }
public void incVoidCount()
{
this.voidCount += 1;
}
public void incWarningCount()
{
this.warningCount += 1;
}
public void setActiveLineCount(final int activeLineCount) public void setActiveLineCount(final int activeLineCount)
{ {
this.activeLineCount = activeLineCount; this.activeLineCount = activeLineCount;
} }
public void setAlertCount(final int alertCount)
{
this.alertCount = alertCount;
}
public void setBlankPropertyCount(final int blankPropertyCount) public void setBlankPropertyCount(final int blankPropertyCount)
{ {
this.blankPropertyCount = blankPropertyCount; this.blankPropertyCount = blankPropertyCount;
@ -159,4 +197,14 @@ public class PropertiesFileStat
{ {
this.url = url; 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 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.Organization;
import fr.devinsy.statoolinfos.core.Service; import fr.devinsy.statoolinfos.core.Service;
import fr.devinsy.strings.StringList; import fr.devinsy.strings.StringList;
@ -125,23 +127,26 @@ public class PropertiesFileStats extends ArrayList<PropertiesFileStat>
* *
* @param organization * @param organization
* the organization * the organization
* @return the properties file stat
* @throws IOException * @throws IOException
* Signals that an I/O exception has occurred. * 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()); PropertyChecker checker = new PropertyChecker();
result.setLocalName(organization.getTechnicalName() + ".properties"); PropertyChecks checks = checker.checkOrganization(organization.getInputFile());
result.setOrganization(organization); stat.setWarningCount(checks.getWarningCount());
result.setUpdateDate(organization.getCrawledDate()); stat.setAlertCount(checks.getAlertCount());
stat.setErrorCount(checks.getErrorCount());
stat.setVoidCount(checks.getVoidCount());
// add(stat);
return result;
} }
/** /**
@ -149,22 +154,22 @@ public class PropertiesFileStats extends ArrayList<PropertiesFileStat>
* *
* @param service * @param service
* the service * the service
* @return the properties file stat
* @throws IOException * @throws IOException
* Signals that an I/O exception has occurred. * 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()); PropertyChecker checker = new PropertyChecker();
result.setLocalName(service.getOrganization().getTechnicalName() + "-" + service.getTechnicalName() + ".properties"); PropertyChecks checks = checker.checkService(service.getInputFile());
result.setOrganization(service.getOrganization()); stat.setErrorCount(checks.getErrorCount());
result.setUpdateDate(service.getCrawledDate());
// add(stat);
return result;
} }
} }