Fixed former member display in organization page.
This commit is contained in:
parent
fd19427700
commit
9f7de0cde4
5 changed files with 238 additions and 1 deletions
|
@ -386,6 +386,21 @@ public class Federation extends PathPropertyList
|
|||
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.
|
||||
*
|
||||
|
|
|
@ -42,6 +42,17 @@ import fr.devinsy.statoolinfos.util.URLUtils;
|
|||
public class Organization extends PathPropertyList
|
||||
{
|
||||
private static final long serialVersionUID = -2709210934548224213L;
|
||||
|
||||
/**
|
||||
* The Enum Status.
|
||||
*/
|
||||
public enum Status
|
||||
{
|
||||
ACTIVE,
|
||||
IDLE,
|
||||
AWAY
|
||||
}
|
||||
|
||||
private Federation federation;
|
||||
private Services services;
|
||||
private File inputFile;
|
||||
|
@ -439,6 +450,44 @@ public class Organization extends PathPropertyList
|
|||
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.
|
||||
*
|
||||
|
@ -666,6 +715,42 @@ public class Organization extends PathPropertyList
|
|||
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.
|
||||
*
|
||||
|
@ -860,6 +945,83 @@ public class Organization extends PathPropertyList
|
|||
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.
|
||||
*
|
||||
|
|
|
@ -36,6 +36,31 @@ public class Organizations extends ArrayList<Organization>
|
|||
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.
|
||||
*
|
||||
|
|
|
@ -78,7 +78,7 @@ public class FederationOrganizationsPage
|
|||
TagDataManager data = new TagDataManager();
|
||||
|
||||
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();
|
||||
|
||||
|
|
|
@ -21,8 +21,11 @@ package fr.devinsy.statoolinfos.properties;
|
|||
import java.io.File;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.time.LocalDate;
|
||||
import java.time.Year;
|
||||
import java.time.YearMonth;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.time.format.DateTimeParseException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.regex.Matcher;
|
||||
|
@ -310,6 +313,38 @@ public class PathPropertyList extends ArrayList<PathProperty> implements PathPro
|
|||
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.
|
||||
*
|
||||
|
|
Loading…
Reference in a new issue