Fixed former member display in organization page.

This commit is contained in:
Christian P. MOMON 2022-01-08 04:55:31 +01:00
parent fd19427700
commit 9f7de0cde4
5 changed files with 238 additions and 1 deletions

View file

@ -386,6 +386,21 @@ public class Federation extends PathPropertyList
return this.organizations; return this.organizations;
} }
/**
* Gets the organizations active.
*
* @return the organizations active
*/
public Organizations getActiveOrganizations()
{
Organizations result;
result = this.organizations.filterActiveFor(getTechnicalName());
//
return result;
}
/** /**
* Gets the service count. * Gets the service count.
* *

View file

@ -42,6 +42,17 @@ import fr.devinsy.statoolinfos.util.URLUtils;
public class Organization extends PathPropertyList public class Organization extends PathPropertyList
{ {
private static final long serialVersionUID = -2709210934548224213L; private static final long serialVersionUID = -2709210934548224213L;
/**
* The Enum Status.
*/
public enum Status
{
ACTIVE,
IDLE,
AWAY
}
private Federation federation; private Federation federation;
private Services services; private Services services;
private File inputFile; private File inputFile;
@ -439,6 +450,44 @@ public class Organization extends PathPropertyList
return result; return result;
} }
/**
* Gets the status member of.
*
* @param entityName
* the entity name
* @return the status member of
*/
public Status getMemberStatusOf(final String entityName)
{
Status result;
String value = get("organization.memberof." + entityName + ".status");
if (StringUtils.isBlank(value))
{
result = null;
}
else if (StringUtils.equalsIgnoreCase(value, "ACTIVE"))
{
result = Status.ACTIVE;
}
else if (StringUtils.equalsIgnoreCase(value, "IDLE"))
{
result = Status.IDLE;
}
else if (StringUtils.equalsIgnoreCase(value, "AWAY"))
{
result = Status.AWAY;
}
else
{
result = null;
}
//
return result;
}
/** /**
* Gets the metric month values all. * Gets the metric month values all.
* *
@ -666,6 +715,42 @@ public class Organization extends PathPropertyList
return result; return result;
} }
/**
* Gets the status.
*
* @return the status
*/
public Status getStatus()
{
Status result;
String value = get("organization.status.level", "organization.status");
if (StringUtils.isBlank(value))
{
result = null;
}
else if (StringUtils.equalsIgnoreCase(value, "ACTIVE"))
{
result = Status.ACTIVE;
}
else if (StringUtils.equalsIgnoreCase(value, "IDLE"))
{
result = Status.IDLE;
}
else if (StringUtils.equalsIgnoreCase(value, "AWAY"))
{
result = Status.AWAY;
}
else
{
result = null;
}
//
return result;
}
/** /**
* Gets the technical guide website. * Gets the technical guide website.
* *
@ -860,6 +945,83 @@ public class Organization extends PathPropertyList
return result; return result;
} }
/**
* Checks if is active.
*
* @return true, if is active
*/
public boolean isActive()
{
boolean result;
if (getStatus() == Status.ACTIVE)
{
result = true;
}
else
{
result = false;
}
//
return result;
}
/**
* Checks if is away.
*
* @return true, if is away
*/
public boolean isAway()
{
boolean result;
Status status = getStatus();
if (status == Status.AWAY)
{
result = true;
}
else
{
result = false;
}
//
return result;
}
/**
* Checks if is away for.
*
* @param entityName
* the entity name
* @return true, if is away for
*/
public boolean isAwayFor(final String entityName)
{
boolean result;
Status memberStatus = getMemberStatusOf(entityName);
LocalDate endDate = getDate("organization.memberof." + entityName + ".enddate");
if (memberStatus == Status.AWAY)
{
result = true;
}
else if ((endDate == null) || (endDate.isAfter(LocalDate.now())))
{
result = false;
}
else
{
result = true;
}
//
return result;
}
/** /**
* Checks if is default. * Checks if is default.
* *

View file

@ -36,6 +36,31 @@ public class Organizations extends ArrayList<Organization>
super(); super();
} }
/**
* Filter member of.
*
* @param entityName
* the entity name
* @return the organizations
*/
public Organizations filterActiveFor(final String entityName)
{
Organizations result;
result = new Organizations();
for (Organization organization : this)
{
if ((!organization.isAway()) && (!organization.isAwayFor(entityName)))
{
result.add(organization);
}
}
//
return result;
}
/** /**
* Filter by social network. * Filter by social network.
* *

View file

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

View file

@ -21,8 +21,11 @@ package fr.devinsy.statoolinfos.properties;
import java.io.File; import java.io.File;
import java.net.MalformedURLException; import java.net.MalformedURLException;
import java.net.URL; import java.net.URL;
import java.time.LocalDate;
import java.time.Year; import java.time.Year;
import java.time.YearMonth; import java.time.YearMonth;
import java.time.format.DateTimeFormatter;
import java.time.format.DateTimeParseException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Iterator; import java.util.Iterator;
import java.util.regex.Matcher; import java.util.regex.Matcher;
@ -310,6 +313,38 @@ public class PathPropertyList extends ArrayList<PathProperty> implements PathPro
return result; return result;
} }
/**
* Gets the date.
*
* @param path
* the path
* @return the date
*/
public LocalDate getDate(final String path)
{
LocalDate result;
String value = get(path);
if (value == null)
{
result = null;
}
else
{
try
{
result = LocalDate.parse(value, DateTimeFormatter.ofPattern("dd/MM/yyyy"));
}
catch (DateTimeParseException exception)
{
result = null;
}
}
//
return result;
}
/** /**
* Gets the index property. * Gets the index property.
* *