Compare commits
5 commits
a414ba7956
...
c98fc07e1b
Author | SHA1 | Date | |
---|---|---|---|
c98fc07e1b | |||
92f6674bfc | |||
04aed10a38 | |||
8712c99894 | |||
f23834d8e3 |
12 changed files with 707 additions and 134 deletions
|
@ -21,7 +21,9 @@ package fr.devinsy.statoolinfos.core;
|
|||
import java.io.File;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.Year;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
|
@ -384,6 +386,23 @@ public class Federation extends PathPropertyList
|
|||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the member organizations.
|
||||
*
|
||||
* @param year
|
||||
* the year
|
||||
* @return the member organizations
|
||||
*/
|
||||
public Organizations getMemberOrganizations(final Year year)
|
||||
{
|
||||
Organizations result;
|
||||
|
||||
result = this.organizations.filterMemberFor(year);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the metric month values all.
|
||||
*
|
||||
|
@ -504,6 +523,40 @@ public class Federation extends PathPropertyList
|
|||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the service count by.
|
||||
*
|
||||
* @param year
|
||||
* the year
|
||||
* @return the service count by
|
||||
*/
|
||||
public long getServiceCountBy(final Year year)
|
||||
{
|
||||
long result;
|
||||
|
||||
Organizations organizations = this.organizations.filterMemberFor(year);
|
||||
|
||||
result = 0;
|
||||
for (Organization organization : organizations)
|
||||
{
|
||||
for (Service service : organization.getServices().getBy(year))
|
||||
{
|
||||
Year memberStart = organization.getMemberStartYear();
|
||||
Year memberEnd = organization.getMemberEndYear();
|
||||
Year serviceStart = service.getStartYear();
|
||||
Year serviceEnd = service.getEndYear();
|
||||
|
||||
if (StatoolInfosUtils.overlapp(memberStart, memberEnd, serviceStart, serviceEnd))
|
||||
{
|
||||
result += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the all services.
|
||||
*
|
||||
|
@ -578,7 +631,22 @@ public class Federation extends PathPropertyList
|
|||
*
|
||||
* @return the start date
|
||||
*/
|
||||
public String getStartDate()
|
||||
public LocalDate getStartDate()
|
||||
{
|
||||
LocalDate result;
|
||||
|
||||
result = StatoolInfosUtils.parseDate(getStartDateValue());
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the start date.
|
||||
*
|
||||
* @return the start date
|
||||
*/
|
||||
public String getStartDateValue()
|
||||
{
|
||||
String result;
|
||||
|
||||
|
@ -588,6 +656,29 @@ public class Federation extends PathPropertyList
|
|||
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.
|
||||
*
|
||||
|
|
|
@ -22,6 +22,7 @@ import java.io.File;
|
|||
import java.net.URL;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.Year;
|
||||
|
||||
import org.apache.commons.codec.digest.DigestUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
@ -148,10 +149,7 @@ public class Organization extends PathPropertyList
|
|||
{
|
||||
String result;
|
||||
|
||||
LocalDate startDate = StatoolInfosUtils.parseDate(getStartDate());
|
||||
LocalDate endDate = StatoolInfosUtils.parseDate(getEndDate());
|
||||
|
||||
result = StatoolInfosUtils.toHumanDuration(startDate, endDate);
|
||||
result = StatoolInfosUtils.toHumanDuration(getStartDate(), getEndDate());
|
||||
|
||||
//
|
||||
return result;
|
||||
|
@ -272,7 +270,22 @@ public class Organization extends PathPropertyList
|
|||
*
|
||||
* @return the end date
|
||||
*/
|
||||
public String getEndDate()
|
||||
public LocalDate getEndDate()
|
||||
{
|
||||
LocalDate result;
|
||||
|
||||
result = StatoolInfosUtils.parseDate(getEndDateValue());
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the end date.
|
||||
*
|
||||
* @return the end date
|
||||
*/
|
||||
public String getEndDateValue()
|
||||
{
|
||||
String result;
|
||||
|
||||
|
@ -282,6 +295,30 @@ public class Organization extends PathPropertyList
|
|||
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()
|
||||
{
|
||||
return this.federation;
|
||||
|
@ -464,10 +501,7 @@ public class Organization extends PathPropertyList
|
|||
{
|
||||
String result;
|
||||
|
||||
LocalDate startDate = StatoolInfosUtils.parseDate(getMemberStartDate());
|
||||
LocalDate endDate = StatoolInfosUtils.parseDate(getMemberEndDate());
|
||||
|
||||
result = StatoolInfosUtils.toHumanDuration(startDate, endDate);
|
||||
result = StatoolInfosUtils.toHumanDuration(getMemberStartDate(), getMemberEndDate());
|
||||
|
||||
//
|
||||
return result;
|
||||
|
@ -478,7 +512,39 @@ public class Organization extends PathPropertyList
|
|||
*
|
||||
* @return the member end date
|
||||
*/
|
||||
public String getMemberEndDate()
|
||||
public LocalDate getMemberEndDate()
|
||||
{
|
||||
LocalDate result;
|
||||
|
||||
result = getDate("organization.memberof." + this.federation.getName() + ".enddate");
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the member end date.
|
||||
*
|
||||
* @param entityName
|
||||
* the entity name
|
||||
* @return the member end date
|
||||
*/
|
||||
public LocalDate getMemberEndDate(final String entityName)
|
||||
{
|
||||
LocalDate result;
|
||||
|
||||
result = getDate("organization.memberof." + entityName + ".enddate");
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the member end date.
|
||||
*
|
||||
* @return the member end date
|
||||
*/
|
||||
public String getMemberEndDateValue()
|
||||
{
|
||||
String result;
|
||||
|
||||
|
@ -488,12 +554,67 @@ public class Organization extends PathPropertyList
|
|||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the member end year.
|
||||
*
|
||||
* @return the member end year
|
||||
*/
|
||||
public Year getMemberEndYear()
|
||||
{
|
||||
Year result;
|
||||
|
||||
LocalDate date = getMemberEndDate();
|
||||
if (date == null)
|
||||
{
|
||||
result = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
result = Year.from(date);
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the member start date.
|
||||
*
|
||||
* @return the member start date
|
||||
*/
|
||||
public String getMemberStartDate()
|
||||
public LocalDate getMemberStartDate()
|
||||
{
|
||||
LocalDate result;
|
||||
|
||||
result = getDate("organization.memberof." + this.federation.getName() + ".startdate");
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the member start date.
|
||||
*
|
||||
* @param entityName
|
||||
* the entity name
|
||||
* @return the member start date
|
||||
*/
|
||||
public LocalDate getMemberStartDate(final String entityName)
|
||||
{
|
||||
LocalDate result;
|
||||
|
||||
result = getDate("organization.memberof." + entityName + ".startdate");
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the member start date.
|
||||
*
|
||||
* @return the member start date
|
||||
*/
|
||||
public String getMemberStartDateValue()
|
||||
{
|
||||
String result;
|
||||
|
||||
|
@ -503,6 +624,29 @@ public class Organization extends PathPropertyList
|
|||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the member start year.
|
||||
*
|
||||
* @return the member start year
|
||||
*/
|
||||
public Year getMemberStartYear()
|
||||
{
|
||||
Year result;
|
||||
|
||||
LocalDate date = getMemberStartDate();
|
||||
if (date == null)
|
||||
{
|
||||
result = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
result = Year.from(date);
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the status member of.
|
||||
*
|
||||
|
@ -743,7 +887,22 @@ public class Organization extends PathPropertyList
|
|||
*
|
||||
* @return the start date
|
||||
*/
|
||||
public String getStartDate()
|
||||
public LocalDate getStartDate()
|
||||
{
|
||||
LocalDate result;
|
||||
|
||||
result = StatoolInfosUtils.parseDate(getStartDateValue());
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the start date.
|
||||
*
|
||||
* @return the start date
|
||||
*/
|
||||
public String getStartDateValue()
|
||||
{
|
||||
String result;
|
||||
|
||||
|
@ -753,6 +912,30 @@ public class Organization extends PathPropertyList
|
|||
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.
|
||||
*
|
||||
|
@ -1112,7 +1295,7 @@ public class Organization extends PathPropertyList
|
|||
{
|
||||
boolean result;
|
||||
|
||||
if ((getServiceCount() == 0) && (getLogoURLValue() == null) && (getStartDate() == null))
|
||||
if ((getServiceCount() == 0) && (getLogoURLValue() == null) && (getStartDateValue() == null))
|
||||
{
|
||||
result = true;
|
||||
}
|
||||
|
@ -1148,6 +1331,51 @@ public class Organization extends PathPropertyList
|
|||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if is member.
|
||||
*
|
||||
* @param year
|
||||
* the year
|
||||
* @return true, if is member
|
||||
*/
|
||||
public boolean isMember(final Year year)
|
||||
{
|
||||
boolean result;
|
||||
|
||||
if (year == null)
|
||||
{
|
||||
result = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
Year startYear = getMemberStartYear();
|
||||
if (startYear == null)
|
||||
{
|
||||
result = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
Year endYear = getMemberEndYear();
|
||||
if (endYear == null)
|
||||
{
|
||||
endYear = Year.now();
|
||||
}
|
||||
|
||||
if ((year.isBefore(startYear)) || (year.isAfter(endYear)))
|
||||
{
|
||||
result = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
result = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if is valid.
|
||||
*
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
*/
|
||||
package fr.devinsy.statoolinfos.core;
|
||||
|
||||
import java.time.Year;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
|
||||
|
@ -182,6 +183,31 @@ public class Organizations extends ArrayList<Organization>
|
|||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter member for.
|
||||
*
|
||||
* @param year
|
||||
* the year
|
||||
* @return the organizations
|
||||
*/
|
||||
public Organizations filterMemberFor(final Year year)
|
||||
{
|
||||
Organizations result;
|
||||
|
||||
result = new Organizations();
|
||||
|
||||
for (Organization organization : this)
|
||||
{
|
||||
if (organization.isMember(year))
|
||||
{
|
||||
result.add(organization);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the active service count.
|
||||
*
|
||||
|
|
|
@ -22,6 +22,7 @@ import java.io.File;
|
|||
import java.net.URL;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.Year;
|
||||
import java.time.YearMonth;
|
||||
|
||||
import org.apache.commons.codec.digest.DigestUtils;
|
||||
|
@ -136,10 +137,7 @@ public class Service extends PathPropertyList
|
|||
{
|
||||
String result;
|
||||
|
||||
LocalDate startDate = StatoolInfosUtils.parseDate(getStartDate());
|
||||
LocalDate endDate = StatoolInfosUtils.parseDate(getEndDate());
|
||||
|
||||
result = StatoolInfosUtils.toHumanDuration(startDate, endDate);
|
||||
result = StatoolInfosUtils.toHumanDuration(getStartDate(), getEndDate());
|
||||
|
||||
//
|
||||
return result;
|
||||
|
@ -250,7 +248,22 @@ public class Service extends PathPropertyList
|
|||
*
|
||||
* @return the end date
|
||||
*/
|
||||
public String getEndDate()
|
||||
public LocalDate getEndDate()
|
||||
{
|
||||
LocalDate result;
|
||||
|
||||
result = StatoolInfosUtils.parseDate(getEndDateValue());
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the end date value.
|
||||
*
|
||||
* @return the end date value
|
||||
*/
|
||||
public String getEndDateValue()
|
||||
{
|
||||
String result;
|
||||
|
||||
|
@ -260,6 +273,30 @@ public class Service extends PathPropertyList
|
|||
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.
|
||||
*
|
||||
|
@ -851,7 +888,22 @@ public class Service extends PathPropertyList
|
|||
*
|
||||
* @return the start date
|
||||
*/
|
||||
public String getStartDate()
|
||||
public LocalDate getStartDate()
|
||||
{
|
||||
LocalDate result;
|
||||
|
||||
result = StatoolInfosUtils.parseDate(getStartDateValue());
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the start date value.
|
||||
*
|
||||
* @return the start date value
|
||||
*/
|
||||
public String getStartDateValue()
|
||||
{
|
||||
String result;
|
||||
|
||||
|
@ -861,6 +913,30 @@ public class Service extends PathPropertyList
|
|||
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.
|
||||
*
|
||||
|
@ -1056,7 +1132,7 @@ public class Service extends PathPropertyList
|
|||
{
|
||||
boolean result;
|
||||
|
||||
if (getEndDate() == null)
|
||||
if (getEndDateValue() == null)
|
||||
{
|
||||
result = false;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (C) 2020 Christian Pierre MOMON <christian@momon.org>
|
||||
* Copyright (C) 2020-2022 Christian Pierre MOMON <christian@momon.org>
|
||||
*
|
||||
* This file is part of StatoolInfos, simple service statistics tool.
|
||||
*
|
||||
|
@ -18,6 +18,8 @@
|
|||
*/
|
||||
package fr.devinsy.statoolinfos.core;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.Year;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
|
||||
|
@ -40,6 +42,42 @@ public class Services extends ArrayList<Service>
|
|||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* Count by year.
|
||||
*
|
||||
* @param year
|
||||
* the year
|
||||
* @return the long
|
||||
*/
|
||||
public long countBy(final Year year)
|
||||
{
|
||||
long result;
|
||||
|
||||
result = 0;
|
||||
Year now = Year.now();
|
||||
for (Service service : this)
|
||||
{
|
||||
Year start = service.getStartYear();
|
||||
Year end = service.getEndYear();
|
||||
|
||||
if (start != null)
|
||||
{
|
||||
if (end == null)
|
||||
{
|
||||
end = now;
|
||||
}
|
||||
|
||||
if ((!start.isAfter(year) && (!end.isBefore(year))))
|
||||
{
|
||||
result += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the by.
|
||||
*
|
||||
|
@ -117,6 +155,95 @@ public class Services extends ArrayList<Service>
|
|||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the by.
|
||||
*
|
||||
* @param year
|
||||
* the year
|
||||
* @return the by
|
||||
*/
|
||||
public Services getBy(final Year year)
|
||||
{
|
||||
Services result;
|
||||
|
||||
result = new Services();
|
||||
|
||||
if (year != null)
|
||||
{
|
||||
for (Service service : this)
|
||||
{
|
||||
Year startYear = service.getStartYear();
|
||||
Year endYear = service.getEndYear();
|
||||
if (endYear == null)
|
||||
{
|
||||
endYear = Year.now();
|
||||
}
|
||||
|
||||
if ((startYear != null) && (!year.isBefore(startYear)) && (!year.isAfter(endYear)))
|
||||
{
|
||||
result.add(service);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the older.
|
||||
*
|
||||
* @return the older
|
||||
*/
|
||||
public Service getOldestService()
|
||||
{
|
||||
Service result;
|
||||
|
||||
result = null;
|
||||
LocalDate oldestDate = null;
|
||||
for (Service current : this)
|
||||
{
|
||||
LocalDate date = current.getStartDate();
|
||||
|
||||
if (date != null)
|
||||
{
|
||||
LocalDate currentDate = current.getStartDate();
|
||||
if ((result == null) || (currentDate.isBefore(oldestDate)))
|
||||
{
|
||||
result = current;
|
||||
oldestDate = currentDate;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the oldest year.
|
||||
*
|
||||
* @return the oldest year
|
||||
*/
|
||||
public Year getOldestStartYear()
|
||||
{
|
||||
Year result;
|
||||
|
||||
Service oldestService = getOldestService();
|
||||
|
||||
if (oldestService == null)
|
||||
{
|
||||
result = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
result = oldestService.getStartYear();
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse.
|
||||
*
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (C) 2020-2021 Christian Pierre MOMON <christian@momon.org>
|
||||
* Copyright (C) 2020-2022 Christian Pierre MOMON <christian@momon.org>
|
||||
*
|
||||
* This file is part of StatoolInfos, simple service statistics tool.
|
||||
*
|
||||
|
@ -27,6 +27,7 @@ import java.time.Instant;
|
|||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.Period;
|
||||
import java.time.Year;
|
||||
import java.time.ZoneId;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.time.format.DateTimeParseException;
|
||||
|
@ -206,6 +207,63 @@ public class StatoolInfosUtils
|
|||
return new Date().getTime();
|
||||
}
|
||||
|
||||
/**
|
||||
* Overlapp.
|
||||
*
|
||||
* @param start1
|
||||
* the start 1
|
||||
* @param end1
|
||||
* the end 1
|
||||
* @param start2
|
||||
* the start 2
|
||||
* @param end2
|
||||
* the end 2
|
||||
* @return true, if successful
|
||||
*/
|
||||
public static boolean overlapp(final Year start1, final Year end1, final Year start2, final Year end2)
|
||||
{
|
||||
boolean result;
|
||||
|
||||
if ((start1 == null) || (start2 == null))
|
||||
{
|
||||
result = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
Year end11;
|
||||
if (end1 == null)
|
||||
{
|
||||
end11 = Year.now();
|
||||
}
|
||||
else
|
||||
{
|
||||
end11 = end1;
|
||||
}
|
||||
|
||||
Year end22;
|
||||
if (end2 == null)
|
||||
{
|
||||
end22 = Year.now();
|
||||
}
|
||||
else
|
||||
{
|
||||
end22 = end2;
|
||||
}
|
||||
|
||||
if ((end22.isBefore(start1)) || (start2.isAfter(end11)))
|
||||
{
|
||||
result = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
result = true;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses the date.
|
||||
*
|
||||
|
@ -235,6 +293,10 @@ public class StatoolInfosUtils
|
|||
{
|
||||
result = LocalDate.parse("01/" + date, DateTimeFormatter.ofPattern("dd/MM/yyyy"));
|
||||
}
|
||||
else if (date.matches("\\d{4}-\\d{2}"))
|
||||
{
|
||||
result = LocalDate.parse(date + "-01", DateTimeFormatter.ofPattern("yyyy-MM-dd"));
|
||||
}
|
||||
else
|
||||
{
|
||||
result = null;
|
||||
|
|
|
@ -38,7 +38,6 @@ import fr.devinsy.statoolinfos.core.Organizations;
|
|||
import fr.devinsy.statoolinfos.core.Service;
|
||||
import fr.devinsy.statoolinfos.core.Services;
|
||||
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.BarChartView;
|
||||
import fr.devinsy.statoolinfos.htmlize.charts.ChartColor;
|
||||
|
@ -1267,8 +1266,7 @@ public class ChartHtmlizer
|
|||
{
|
||||
String result;
|
||||
|
||||
result = htmlizeServiceCountMonthChart(federation.getServicesAll(),
|
||||
YearMonth.from(StatoolInfosUtils.parseDate(federation.getStartDate())));
|
||||
result = htmlizeServiceCountMonthChart(federation.getServicesAll(), YearMonth.from(federation.getStartDate()));
|
||||
|
||||
//
|
||||
return result;
|
||||
|
@ -1287,7 +1285,7 @@ public class ChartHtmlizer
|
|||
{
|
||||
String result;
|
||||
|
||||
LocalDate startDate = StatoolInfosUtils.parseDate(organization.getFederation().getStartDate());
|
||||
LocalDate startDate = organization.getFederation().getStartDate();
|
||||
|
||||
if (startDate == null)
|
||||
{
|
||||
|
@ -1318,7 +1316,7 @@ public class ChartHtmlizer
|
|||
YearMonth first = null;
|
||||
for (Service service : services)
|
||||
{
|
||||
LocalDate date = StatoolInfosUtils.parseDate(service.getStartDate());
|
||||
LocalDate date = service.getStartDate();
|
||||
if (date != null)
|
||||
{
|
||||
YearMonth current = YearMonth.from(date);
|
||||
|
@ -1362,8 +1360,8 @@ public class ChartHtmlizer
|
|||
long count = 0;
|
||||
for (Service service : services)
|
||||
{
|
||||
LocalDate startDate = StatoolInfosUtils.parseDate(service.getStartDate());
|
||||
LocalDate endDate = StatoolInfosUtils.parseDate(service.getEndDate());
|
||||
LocalDate startDate = service.getStartDate();
|
||||
LocalDate endDate = service.getEndDate();
|
||||
|
||||
if (startDate != null)
|
||||
{
|
||||
|
@ -1453,7 +1451,23 @@ public class ChartHtmlizer
|
|||
{
|
||||
String result;
|
||||
|
||||
result = htmlizeServiceCountYearChart(federation.getServices(), StatoolInfosUtils.parseDate(federation.getStartDate()).getYear());
|
||||
BarChart chart;
|
||||
|
||||
chart = new BarChart("Nombre de services");
|
||||
chart.addDataset("Services");
|
||||
|
||||
Year current = federation.getStartYear();
|
||||
Year now = Year.now();
|
||||
while (!current.isAfter(now))
|
||||
{
|
||||
long count = federation.getServiceCountBy(current);
|
||||
|
||||
chart.add(String.valueOf(current), count, ChartColor.YELLOW);
|
||||
|
||||
current = current.plusYears(1);
|
||||
}
|
||||
|
||||
result = BarChartView.build(chart);
|
||||
|
||||
//
|
||||
return result;
|
||||
|
@ -1472,16 +1486,7 @@ public class ChartHtmlizer
|
|||
{
|
||||
String result;
|
||||
|
||||
LocalDate startDate = StatoolInfosUtils.parseDate(organization.getFederation().getStartDate());
|
||||
|
||||
if (startDate == null)
|
||||
{
|
||||
result = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
result = htmlizeServiceCountYearChart(organization.getServices(), startDate.getYear());
|
||||
}
|
||||
result = htmlizeServiceCountYearChart(organization.getServices(), organization.getFederation().getStartYear());
|
||||
|
||||
//
|
||||
return result;
|
||||
|
@ -1503,7 +1508,7 @@ public class ChartHtmlizer
|
|||
Integer first = null;
|
||||
for (Service service : services)
|
||||
{
|
||||
LocalDate date = StatoolInfosUtils.parseDate(service.getStartDate());
|
||||
LocalDate date = service.getStartDate();
|
||||
if (date != null)
|
||||
{
|
||||
int current = date.getYear();
|
||||
|
@ -1542,36 +1547,11 @@ public class ChartHtmlizer
|
|||
|
||||
if (first != null)
|
||||
{
|
||||
int now = LocalDate.now().getYear();
|
||||
int now = Year.now().getValue();
|
||||
int current = first;
|
||||
while (current <= now)
|
||||
{
|
||||
long count = 0;
|
||||
for (Service service : services)
|
||||
{
|
||||
LocalDate startDate = StatoolInfosUtils.parseDate(service.getStartDate());
|
||||
LocalDate endDate = StatoolInfosUtils.parseDate(service.getEndDate());
|
||||
|
||||
if (startDate != null)
|
||||
{
|
||||
int start = startDate.getYear();
|
||||
int end;
|
||||
if (endDate == null)
|
||||
{
|
||||
end = now;
|
||||
}
|
||||
else
|
||||
{
|
||||
end = endDate.getYear();
|
||||
}
|
||||
|
||||
if ((current >= start) && (current <= end))
|
||||
{
|
||||
count += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
long count = services.countBy(Year.of(current));
|
||||
chart.add(String.valueOf(current), count, ChartColor.YELLOW);
|
||||
|
||||
current += 1;
|
||||
|
@ -1584,6 +1564,37 @@ public class ChartHtmlizer
|
|||
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.
|
||||
*
|
||||
|
@ -1603,7 +1614,7 @@ public class ChartHtmlizer
|
|||
long unfilled = 0;
|
||||
for (Service service : services)
|
||||
{
|
||||
if (StatoolInfosUtils.parseDate(service.getStartDate()) == null)
|
||||
if (service.getStartDate() == null)
|
||||
{
|
||||
unfilled += 1;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (C) 2020-2021 Christian Pierre MOMON <christian@momon.org>
|
||||
* Copyright (C) 2020-2022 Christian Pierre MOMON <christian@momon.org>
|
||||
*
|
||||
* This file is part of StatoolInfos, simple service statistics tool.
|
||||
*
|
||||
|
@ -69,7 +69,7 @@ public class FederationHeaderView
|
|||
data.setEscapedContent("federationURL", federation.getWebsiteURL().toString());
|
||||
data.setEscapedAttribute("federationURL", "href", federation.getWebsiteURL().toString());
|
||||
}
|
||||
data.setContent("federationStartDate", StringUtils.defaultIfBlank(federation.getStartDate(), "n/a"));
|
||||
data.setContent("federationStartDate", StringUtils.defaultIfBlank(federation.getStartDateValue(), "n/a"));
|
||||
|
||||
data.setAttribute("organizationsLink", "href", federation.getTechnicalName() + "-organizations.xhtml");
|
||||
data.setAttribute("servicesLink", "href", federation.getTechnicalName() + "-services.xhtml");
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (C) 2021 Christian Pierre MOMON <christian@momon.org>
|
||||
* Copyright (C) 2021-2022 Christian Pierre MOMON <christian@momon.org>
|
||||
*
|
||||
* This file is part of StatoolInfos, simple service statistics tool.
|
||||
*
|
||||
|
@ -71,10 +71,10 @@ public class OrganizationHeaderView
|
|||
data.setEscapedContent("organizationDescription", organization.get("organization.description"));
|
||||
|
||||
data.setEscapedContent("organizationMemberOfName", StringUtils.defaultIfBlank(organization.getFederation().getName(), "n/a"));
|
||||
data.setContent("organizationStartDate", StringUtils.defaultIfBlank(organization.getStartDate(), "n/a"));
|
||||
data.setContent("organizationEndDate", StringUtils.defaultIfBlank(organization.getEndDate(), "n/a"));
|
||||
data.setContent("organizationStartDate", StringUtils.defaultIfBlank(organization.getStartDateValue(), "n/a"));
|
||||
data.setContent("organizationEndDate", StringUtils.defaultIfBlank(organization.getEndDateValue(), "n/a"));
|
||||
data.setContent("organizationAge", StringUtils.defaultIfBlank(organization.getAge(), "n/a"));
|
||||
if (StringUtils.isBlank(organization.getEndDate()))
|
||||
if (StringUtils.isBlank(organization.getEndDateValue()))
|
||||
{
|
||||
data.setContent("organizationMemberOfWord", "depuis");
|
||||
data.setAttribute("organizationEndDateData", "style", "display: none;");
|
||||
|
@ -84,10 +84,10 @@ public class OrganizationHeaderView
|
|||
data.setContent("organizationMemberOfWord", ":");
|
||||
}
|
||||
|
||||
data.setContent("organizationMemberStartDate", StringUtils.defaultIfBlank(organization.getMemberStartDate(), "n/a"));
|
||||
data.setContent("organizationMemberEndDate", StringUtils.defaultIfBlank(organization.getMemberEndDate(), "n/a"));
|
||||
data.setContent("organizationMemberStartDate", StringUtils.defaultIfBlank(organization.getMemberStartDateValue(), "n/a"));
|
||||
data.setContent("organizationMemberEndDate", StringUtils.defaultIfBlank(organization.getMemberEndDateValue(), "n/a"));
|
||||
data.setContent("organizationMemberAge", StringUtils.defaultIfBlank(organization.getMemberAge(), "n/a"));
|
||||
if (StringUtils.isBlank(organization.getMemberEndDate()))
|
||||
if (StringUtils.isBlank(organization.getMemberEndDateValue()))
|
||||
{
|
||||
data.setAttribute("organizationMemberEndDateData", "style", "display: none;");
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (C) 2020-2021 Christian Pierre MOMON <christian@momon.org>
|
||||
* Copyright (C) 2020-2022 Christian Pierre MOMON <christian@momon.org>
|
||||
*
|
||||
* This file is part of StatoolInfos, simple service statistics tool.
|
||||
*
|
||||
|
@ -69,10 +69,10 @@ public class ServiceHeaderView
|
|||
|
||||
data.setEscapedContent("serviceDescription", StringUtils.defaultIfBlank(service.getDescription(), "n/a"));
|
||||
|
||||
data.setContent("serviceStartDate", StringUtils.defaultIfBlank(service.getStartDate(), "n/a"));
|
||||
data.setContent("serviceEndDate", StringUtils.defaultIfBlank(service.getEndDate(), "n/a"));
|
||||
data.setContent("serviceStartDate", StringUtils.defaultIfBlank(service.getStartDateValue(), "n/a"));
|
||||
data.setContent("serviceEndDate", StringUtils.defaultIfBlank(service.getEndDateValue(), "n/a"));
|
||||
data.setContent("serviceAge", StringUtils.defaultIfBlank(service.getAge(), "n/a"));
|
||||
if (StringUtils.isBlank(service.getEndDate()))
|
||||
if (StringUtils.isBlank(service.getEndDateValue()))
|
||||
{
|
||||
data.setAttribute("serviceEndDateData", "style", "display: none;");
|
||||
}
|
||||
|
|
|
@ -24,8 +24,6 @@ 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;
|
||||
|
@ -315,53 +313,7 @@ public class PathPropertyList extends ArrayList<PathProperty> implements PathPro
|
|||
{
|
||||
LocalDate result;
|
||||
|
||||
String value = get(path);
|
||||
if (value == null)
|
||||
{
|
||||
result = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
String pattern;
|
||||
if (value.matches("\\d{1,2}/\\d{1,2}/\\d{4}"))
|
||||
{
|
||||
pattern = "dd/MM/yyyy";
|
||||
}
|
||||
else if (value.matches("\\d{4}-\\d{2}-\\d{2}"))
|
||||
{
|
||||
pattern = "yyyy-MM-dd";
|
||||
}
|
||||
else if (value.matches("\\d{1,2}/\\d{4}"))
|
||||
{
|
||||
value = "01/" + value;
|
||||
pattern = "dd/MM/yyyy";
|
||||
}
|
||||
else if (value.matches("\\d{4}-\\d{2}"))
|
||||
{
|
||||
value = value + "-01";
|
||||
pattern = "yyyy-MM-dd";
|
||||
}
|
||||
else
|
||||
{
|
||||
pattern = null;
|
||||
}
|
||||
|
||||
if (pattern == null)
|
||||
{
|
||||
result = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
result = LocalDate.parse(value, DateTimeFormatter.ofPattern(pattern));
|
||||
}
|
||||
catch (DateTimeParseException exception)
|
||||
{
|
||||
result = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
result = StatoolInfosUtils.parseDate(get(path));
|
||||
|
||||
//
|
||||
return result;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (C) 2020-2021 Christian Pierre MOMON <christian@momon.org>
|
||||
* Copyright (C) 2020-2022 Christian Pierre MOMON <christian@momon.org>
|
||||
*
|
||||
* This file is part of StatoolInfos, simple service statistics tool.
|
||||
*
|
||||
|
@ -507,7 +507,7 @@ public class StatAgent
|
|||
//
|
||||
for (Organization organization : organizations)
|
||||
{
|
||||
if (StringUtils.isBlank(organization.getStartDate()))
|
||||
if (StringUtils.isBlank(organization.getStartDateValue()))
|
||||
{
|
||||
result.incPassiveCount();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue