Improved organization list view with actives, idles and aways.

This commit is contained in:
Christian P. MOMON 2022-02-16 19:37:31 +01:00
parent 5bd6e2c600
commit 0f9e3c4ae8
6 changed files with 228 additions and 30 deletions

View file

@ -135,6 +135,21 @@ public class Federation extends PathPropertyList
return result;
}
/**
* Gets the away organizations.
*
* @return the away organizations
*/
public Organizations getAwayOrganizations()
{
Organizations result;
result = this.organizations.filterAwayFor(getTechnicalName());
//
return result;
}
/**
* Gets the contact email.
*
@ -220,6 +235,21 @@ public class Federation extends PathPropertyList
return result;
}
/**
* Gets the idle organizations.
*
* @return the idle organizations
*/
public Organizations getIdleOrganizations()
{
Organizations result;
result = this.organizations.getIdles();
//
return result;
}
public PropertyChecks getInputChecks()
{
return this.inputChecks;
@ -339,6 +369,21 @@ public class Federation extends PathPropertyList
return result;
}
/**
* Gets the member organizations.
*
* @return the member organizations
*/
public Organizations getMemberOrganizations()
{
Organizations result;
result = this.organizations.filterMemberFor(getTechnicalName());
//
return result;
}
/**
* Gets the metric month values all.
*

View file

@ -86,6 +86,28 @@ public class Organization extends PathPropertyList
this.crawlJournal = new CrawlJournal();
}
/**
* Gets the service active count.
*
* @return the service active count
*/
public int getActiveServiceCount()
{
int result;
result = 0;
for (Service service : this.services)
{
if (service.isActive())
{
result += 1;
}
}
//
return result;
}
/**
* Gets the active services.
*
@ -109,28 +131,6 @@ public class Organization extends PathPropertyList
return result;
}
/**
* Gets the service active count.
*
* @return the service active count
*/
public int getActiveServiceCount()
{
int result;
result = 0;
for (Service service : this.services)
{
if (service.isActive())
{
result += 1;
}
}
//
return result;
}
/**
* Gets the age.
*
@ -1074,6 +1074,29 @@ public class Organization extends PathPropertyList
return result;
}
/**
* Checks if is idle.
*
* @return true, if is idle
*/
public boolean isIdle()
{
boolean result;
Status status = getStatus();
if ((status == null) || (status == Status.IDLE))
{
result = true;
}
else
{
result = false;
}
//
return result;
}
/**
* Checks if is valid.
*

View file

@ -36,6 +36,29 @@ public class Organizations extends ArrayList<Organization>
super();
}
/**
* Filter active.
*
* @return the organizations
*/
public Organizations filterActive()
{
Organizations result;
result = new Organizations();
for (Organization organization : this)
{
if (organization.isActive())
{
result.add(organization);
}
}
//
return result;
}
/**
* Filter member of.
*
@ -51,7 +74,32 @@ public class Organizations extends ArrayList<Organization>
for (Organization organization : this)
{
if ((!organization.isAway()) && (!organization.isAwayFor(entityName)))
if ((organization.isActive()) && (!organization.isAwayFor(entityName)))
{
result.add(organization);
}
}
//
return result;
}
/**
* Filter away for.
*
* @param entityName
* the entity name
* @return the organizations
*/
public Organizations filterAwayFor(final String entityName)
{
Organizations result;
result = new Organizations();
for (Organization organization : this)
{
if ((organization.isAway()) || (organization.isAwayFor(entityName)))
{
result.add(organization);
}
@ -109,6 +157,31 @@ public class Organizations extends ArrayList<Organization>
return result;
}
/**
* Filter member for.
*
* @param entityName
* the entity name
* @return the organizations
*/
public Organizations filterMemberFor(final String entityName)
{
Organizations result;
result = new Organizations();
for (Organization organization : this)
{
if ((!organization.isAway()) && (!organization.isAwayFor(entityName)))
{
result.add(organization);
}
}
//
return result;
}
/**
* Gets the active service count.
*
@ -128,6 +201,29 @@ public class Organizations extends ArrayList<Organization>
return result;
}
/**
* Gets the idles.
*
* @return the idles
*/
public Organizations getIdles()
{
Organizations result;
result = new Organizations();
for (Organization organization : this)
{
if (organization.isIdle())
{
result.add(organization);
}
}
//
return result;
}
/**
* Gets the service count.
*

View file

@ -78,7 +78,8 @@ public class FederationOrganizationsPage
TagDataManager data = new TagDataManager();
data.setContent("federationHeaderView", FederationHeaderView.htmlize(federation));
data.setContent("organizationListView", OrganizationListView.htmlize(federation.getActiveOrganizations()));
data.setContent("organizationListView", OrganizationListView.htmlize(federation.getMemberOrganizations(), federation.getAwayOrganizations()));
String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/federationOrganizations.xhtml", data).toString();

View file

@ -29,6 +29,7 @@ import fr.devinsy.statoolinfos.core.Organization;
import fr.devinsy.statoolinfos.core.Organizations;
import fr.devinsy.statoolinfos.core.StatoolInfosException;
import fr.devinsy.statoolinfos.core.StatoolInfosUtils;
import fr.devinsy.strings.StringList;
import fr.devinsy.xidyn.XidynException;
import fr.devinsy.xidyn.data.TagDataManager;
import fr.devinsy.xidyn.presenters.PresenterUtils;
@ -52,7 +53,7 @@ public class OrganizationListView
* @throws IOException
* Signals that an I/O exception has occurred.
*/
public static String htmlize(final Organizations organizations) throws StatoolInfosException, IOException
public static String htmlize(final Organizations organizations, final Organizations aways) throws StatoolInfosException, IOException
{
String result;
@ -60,8 +61,9 @@ public class OrganizationListView
{
TagDataManager data = new TagDataManager();
data.setContent("organizationCount", organizations.size());
data.setContent("serviceCount", organizations.getActiveServiceCount());
Organizations actives = organizations.filterActive();
data.setContent("organizationCount", actives.size());
data.setContent("serviceCount", actives.getActiveServiceCount());
String monthLabel = LocalDate.now().minusMonths(1).format(DateTimeFormatter.ofPattern("MMMM yyyy")).replace(" ", "&#160;");
data.setContent("monthLabel", monthLabel);
@ -69,7 +71,7 @@ public class OrganizationListView
data.setAttribute("visitCountHeaderColumn", "title", monthLabel);
int index = 0;
for (Organization organization : organizations.sortByReverseServiceCount())
for (Organization organization : actives.sortByReverseServiceCount())
{
data.setAttribute("organizationListLine", index, "organizationListLineNameLink", "href", organization.getTechnicalName() + ".xhtml");
data.setAttribute("organizationListLine", index, "organizationListLineLogo", "src", organization.getLogoFileName());
@ -91,6 +93,35 @@ public class OrganizationListView
index += 1;
}
Organizations idles = organizations.getIdles();
if (idles.isEmpty())
{
data.setContent("idleMembers", "aucun.");
}
else
{
StringList buffer = new StringList();
for (Organization idle : idles)
{
buffer.add(String.format("<a href=\"%s\" style=\"text-decoration: none;\">%s</a>", idle.getTechnicalName() + ".xhtml", idle.getName()));
}
data.setContent("idleMembers", buffer.toString("", ", ", "."));
}
if (aways.isEmpty())
{
data.setContent("awayMembers", "aucun.");
}
else
{
StringList buffer = new StringList();
for (Organization away : aways)
{
buffer.add(String.format("<a href=\"%s\" style=\"text-decoration: none;\">%s</a>", away.getTechnicalName() + ".xhtml", away.getName()));
}
data.setContent("awayMembers", buffer.toString("", ", ", "."));
}
String page = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/organizationListView.xhtml", data).toString();
result = XidynUtils.extractBodyContent(page);

View file

@ -13,8 +13,8 @@
<body>
<div class="center_table" style="width: 900px;">
<br/>
<div class="center">Nombre de membres : <span id="organizationCount">n/a</span></div>
<div class="center">Nombre de services : <span id="serviceCount">n/a</span></div>
<div class="center">Nombre de membres actifs : <span id="organizationCount">n/a</span></div>
<div class="center">Nombre de services acfifs : <span id="serviceCount">n/a</span></div>
<table id="organizations" class="table_classic left">
<thead>
<tr>
@ -43,6 +43,8 @@
</tbody>
</table>
<div id="month_asterisk">(*) chiffres de <span id="monthLabel">n/a</span></div>
<div id="idleMembersZone" class="left">Membres en sommeil : <span id="idleMembers">n/a</span></div>
<div id="awayMembersZone" class="left">Anciens membres : <span id="awayMembers">n/a</span></div>
</div>
<script type="text/javascript">
$(document).ready(function()