Improved date management.

This commit is contained in:
Christian P. MOMON 2022-07-24 11:24:28 +02:00
parent 04aed10a38
commit 92f6674bfc
4 changed files with 155 additions and 12 deletions

View file

@ -23,6 +23,7 @@ import java.net.MalformedURLException;
import java.net.URL; import java.net.URL;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.time.Year;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
@ -604,6 +605,29 @@ public class Federation extends PathPropertyList
return result; return result;
} }
/**
* Gets the start year.
*
* @return the start year
*/
public Year getStartYear()
{
Year result;
LocalDate date = getStartDate();
if (date == null)
{
result = null;
}
else
{
result = Year.from(date);
}
//
return result;
}
/** /**
* Gets the technical doc website. * Gets the technical doc website.
* *

View file

@ -22,6 +22,7 @@ import java.io.File;
import java.net.URL; import java.net.URL;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.time.Year;
import org.apache.commons.codec.digest.DigestUtils; import org.apache.commons.codec.digest.DigestUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
@ -294,6 +295,30 @@ public class Organization extends PathPropertyList
return result; return result;
} }
/**
* Gets the end year.
*
* @return the end year
*/
public Year getEndYear()
{
Year result;
LocalDate date = getEndDate();
if (date == null)
{
result = null;
}
else
{
result = Year.from(date);
}
//
return result;
}
public Federation getFederation() public Federation getFederation()
{ {
return this.federation; return this.federation;
@ -780,6 +805,30 @@ public class Organization extends PathPropertyList
return result; return result;
} }
/**
* Gets the start year.
*
* @return the start year
*/
public Year getStartYear()
{
Year result;
LocalDate date = getStartDate();
if (date == null)
{
result = null;
}
else
{
result = Year.from(date);
}
//
return result;
}
/** /**
* Gets the status. * Gets the status.
* *

View file

@ -22,6 +22,7 @@ import java.io.File;
import java.net.URL; import java.net.URL;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.time.Year;
import java.time.YearMonth; import java.time.YearMonth;
import org.apache.commons.codec.digest.DigestUtils; import org.apache.commons.codec.digest.DigestUtils;
@ -272,6 +273,30 @@ public class Service extends PathPropertyList
return result; return result;
} }
/**
* Gets the end year.
*
* @return the end year
*/
public Year getEndYear()
{
Year result;
LocalDate date = getEndDate();
if (date == null)
{
result = null;
}
else
{
result = Year.from(date);
}
//
return result;
}
/** /**
* Gets the host name. * Gets the host name.
* *
@ -888,6 +913,30 @@ public class Service extends PathPropertyList
return result; return result;
} }
/**
* Gets the start year.
*
* @return the start year
*/
public Year getStartYear()
{
Year result;
LocalDate date = getStartDate();
if (date == null)
{
result = null;
}
else
{
result = Year.from(date);
}
//
return result;
}
/** /**
* Gets the status. * Gets the status.
* *

View file

@ -38,7 +38,6 @@ import fr.devinsy.statoolinfos.core.Organizations;
import fr.devinsy.statoolinfos.core.Service; import fr.devinsy.statoolinfos.core.Service;
import fr.devinsy.statoolinfos.core.Services; import fr.devinsy.statoolinfos.core.Services;
import fr.devinsy.statoolinfos.core.StatoolInfosException; import fr.devinsy.statoolinfos.core.StatoolInfosException;
import fr.devinsy.statoolinfos.core.StatoolInfosUtils;
import fr.devinsy.statoolinfos.htmlize.charts.BarChart; import fr.devinsy.statoolinfos.htmlize.charts.BarChart;
import fr.devinsy.statoolinfos.htmlize.charts.BarChartView; import fr.devinsy.statoolinfos.htmlize.charts.BarChartView;
import fr.devinsy.statoolinfos.htmlize.charts.ChartColor; import fr.devinsy.statoolinfos.htmlize.charts.ChartColor;
@ -1452,7 +1451,7 @@ public class ChartHtmlizer
{ {
String result; String result;
result = htmlizeServiceCountYearChart(federation.getServices(), federation.getStartDate().getYear()); result = htmlizeServiceCountYearChart(federation.getServices(), federation.getStartYear());
// //
return result; return result;
@ -1471,16 +1470,7 @@ public class ChartHtmlizer
{ {
String result; String result;
LocalDate startDate = organization.getFederation().getStartDate(); result = htmlizeServiceCountYearChart(organization.getServices(), organization.getFederation().getStartYear());
if (startDate == null)
{
result = null;
}
else
{
result = htmlizeServiceCountYearChart(organization.getServices(), startDate.getYear());
}
// //
return result; return result;
@ -1583,6 +1573,37 @@ public class ChartHtmlizer
return result; return result;
} }
/**
* Htmlize service count year chart.
*
* @param services
* the services
* @param first
* the first
* @return the string
* @throws StatoolInfosException
* the statool infos exception
*/
public static String htmlizeServiceCountYearChart(final Services services, final Year first) throws StatoolInfosException
{
String result;
Integer value;
if (first == null)
{
value = null;
}
else
{
value = first.getValue();
}
result = htmlizeServiceCountYearChart(services, value);
//
return result;
}
/** /**
* Htmlize service date status chart. * Htmlize service date status chart.
* *