2020-09-15 03:16:26 +02:00
|
|
|
/*
|
2022-01-22 03:31:16 +01:00
|
|
|
* Copyright (C) 2020-2022 Christian Pierre MOMON <christian@momon.org>
|
2020-09-15 03:16:26 +02:00
|
|
|
*
|
|
|
|
* This file is part of StatoolInfos, simple service statistics tool.
|
|
|
|
*
|
|
|
|
* StatoolInfos is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Affero General Public License as
|
|
|
|
* published by the Free Software Foundation, either version 3 of the
|
|
|
|
* License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* StatoolInfos is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Affero General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Affero General Public License
|
|
|
|
* along with StatoolInfos. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
package fr.devinsy.statoolinfos.core;
|
|
|
|
|
2020-09-17 18:54:29 +02:00
|
|
|
import java.io.File;
|
2020-09-19 02:37:52 +02:00
|
|
|
import java.net.URL;
|
2021-01-25 02:00:48 +01:00
|
|
|
import java.time.LocalDate;
|
2020-09-28 03:52:51 +02:00
|
|
|
import java.time.LocalDateTime;
|
2020-09-17 18:54:29 +02:00
|
|
|
|
2021-01-08 04:19:21 +01:00
|
|
|
import org.apache.commons.codec.digest.DigestUtils;
|
2020-09-17 02:03:56 +02:00
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
|
2021-05-14 02:40:15 +02:00
|
|
|
import fr.devinsy.statoolinfos.checker.PropertyChecks;
|
2021-05-18 19:40:29 +02:00
|
|
|
import fr.devinsy.statoolinfos.crawl.CrawlJournal;
|
2021-05-24 17:46:07 +02:00
|
|
|
import fr.devinsy.statoolinfos.htmlize.charts.MonthValues;
|
2021-06-02 18:36:02 +02:00
|
|
|
import fr.devinsy.statoolinfos.htmlize.charts.WeekValues;
|
|
|
|
import fr.devinsy.statoolinfos.htmlize.charts.YearValues;
|
2020-09-17 02:28:37 +02:00
|
|
|
import fr.devinsy.statoolinfos.properties.PathProperties;
|
2020-09-15 03:16:26 +02:00
|
|
|
import fr.devinsy.statoolinfos.properties.PathPropertyList;
|
2021-06-11 23:35:50 +02:00
|
|
|
import fr.devinsy.statoolinfos.uptime.URLSet;
|
2021-06-08 19:01:11 +02:00
|
|
|
import fr.devinsy.statoolinfos.util.URLUtils;
|
2020-09-15 03:16:26 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The Class PathProperty.
|
|
|
|
*/
|
|
|
|
public class Organization extends PathPropertyList
|
|
|
|
{
|
|
|
|
private static final long serialVersionUID = -2709210934548224213L;
|
2022-01-08 04:55:31 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The Enum Status.
|
|
|
|
*/
|
|
|
|
public enum Status
|
|
|
|
{
|
|
|
|
ACTIVE,
|
|
|
|
IDLE,
|
|
|
|
AWAY
|
|
|
|
}
|
|
|
|
|
2020-09-21 06:15:07 +02:00
|
|
|
private Federation federation;
|
2020-09-15 03:16:26 +02:00
|
|
|
private Services services;
|
2020-09-23 21:56:40 +02:00
|
|
|
private File inputFile;
|
|
|
|
private URL inputURL;
|
2020-10-23 03:59:44 +02:00
|
|
|
private String logoFileName;
|
2021-05-14 02:40:15 +02:00
|
|
|
private PropertyChecks inputChecks;
|
2021-05-18 19:40:29 +02:00
|
|
|
private CrawlJournal crawlJournal;
|
2020-09-15 03:16:26 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Instantiates a new organization.
|
|
|
|
*/
|
|
|
|
public Organization()
|
|
|
|
{
|
2020-09-17 02:03:56 +02:00
|
|
|
super();
|
2021-05-14 02:40:15 +02:00
|
|
|
this.inputChecks = new PropertyChecks();
|
2020-09-17 02:03:56 +02:00
|
|
|
this.services = new Services();
|
2021-05-18 19:40:29 +02:00
|
|
|
this.crawlJournal = new CrawlJournal();
|
2020-09-15 03:16:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Instantiates a new organization.
|
|
|
|
*
|
|
|
|
* @param properties
|
|
|
|
* the properties
|
|
|
|
*/
|
2020-09-17 02:28:37 +02:00
|
|
|
public Organization(final PathProperties properties)
|
2020-09-15 03:16:26 +02:00
|
|
|
{
|
|
|
|
super(properties);
|
2021-05-14 02:40:15 +02:00
|
|
|
this.inputChecks = new PropertyChecks();
|
2021-01-08 04:19:21 +01:00
|
|
|
this.services = new Services();
|
2021-05-18 19:40:29 +02:00
|
|
|
this.crawlJournal = new CrawlJournal();
|
2020-09-15 03:16:26 +02:00
|
|
|
}
|
|
|
|
|
2022-01-22 03:31:16 +01:00
|
|
|
/**
|
|
|
|
* Gets the active services.
|
|
|
|
*
|
|
|
|
* @return the active services
|
|
|
|
*/
|
|
|
|
public Services getActiveServices()
|
|
|
|
{
|
|
|
|
Services result;
|
|
|
|
|
|
|
|
result = new Services();
|
|
|
|
|
|
|
|
for (Service service : this.services)
|
|
|
|
{
|
|
|
|
if (service.isActive())
|
|
|
|
{
|
|
|
|
result.add(service);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2021-01-25 02:00:48 +01:00
|
|
|
/**
|
|
|
|
* Gets the age.
|
|
|
|
*
|
|
|
|
* @return the age
|
|
|
|
*/
|
|
|
|
public String getAge()
|
|
|
|
{
|
|
|
|
String result;
|
|
|
|
|
|
|
|
LocalDate startDate = StatoolInfosUtils.parseDate(getStartDate());
|
|
|
|
LocalDate endDate = StatoolInfosUtils.parseDate(getEndDate());
|
|
|
|
|
|
|
|
result = StatoolInfosUtils.toHumanDuration(startDate, endDate);
|
|
|
|
|
|
|
|
//
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2020-10-04 05:58:01 +02:00
|
|
|
/**
|
|
|
|
* Gets the contact email.
|
|
|
|
*
|
|
|
|
* @return the contact email
|
|
|
|
*/
|
2020-10-04 03:51:27 +02:00
|
|
|
public String getContactEmail()
|
|
|
|
{
|
|
|
|
String result;
|
|
|
|
|
|
|
|
result = get("organization.contact.email");
|
|
|
|
|
|
|
|
//
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the contact website.
|
|
|
|
*
|
|
|
|
* @return the contact website
|
|
|
|
*/
|
2021-06-08 19:01:11 +02:00
|
|
|
public URL getContactURL()
|
2020-10-04 03:51:27 +02:00
|
|
|
{
|
2021-06-08 19:01:11 +02:00
|
|
|
URL result;
|
2020-10-04 03:51:27 +02:00
|
|
|
|
2021-06-08 19:01:11 +02:00
|
|
|
result = getURL("organization.contact.url");
|
2020-10-04 03:51:27 +02:00
|
|
|
|
|
|
|
//
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2021-01-15 05:49:47 +01:00
|
|
|
/**
|
|
|
|
* Gets the country code.
|
|
|
|
*
|
|
|
|
* @return the country code
|
|
|
|
*/
|
|
|
|
public String getCountryCode()
|
|
|
|
{
|
|
|
|
String result;
|
|
|
|
|
2021-01-21 06:25:05 +01:00
|
|
|
result = StringUtils.toRootUpperCase(get("organization.country.code"));
|
2021-01-15 05:49:47 +01:00
|
|
|
|
|
|
|
//
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2021-05-16 11:46:11 +02:00
|
|
|
/**
|
|
|
|
* Gets the crawl date.
|
|
|
|
*
|
|
|
|
* @return the crawl date
|
|
|
|
*/
|
|
|
|
public LocalDateTime getCrawlDate()
|
|
|
|
{
|
|
|
|
LocalDateTime result;
|
|
|
|
|
|
|
|
result = LocalDateTime.parse(get("crawl.datetime"));
|
|
|
|
|
|
|
|
//
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2020-09-28 03:52:51 +02:00
|
|
|
/**
|
|
|
|
* Gets the crawled date.
|
|
|
|
*
|
|
|
|
* @return the crawled date
|
|
|
|
*/
|
|
|
|
public LocalDateTime getCrawledDate()
|
|
|
|
{
|
|
|
|
LocalDateTime result;
|
|
|
|
|
|
|
|
result = LocalDateTime.parse(get("crawl.file.datetime"));
|
|
|
|
|
2021-05-16 11:46:11 +02:00
|
|
|
if (result.getYear() == 1970)
|
|
|
|
{
|
|
|
|
result = getCrawlDate();
|
|
|
|
}
|
|
|
|
|
2020-09-28 03:52:51 +02:00
|
|
|
//
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2021-05-18 19:40:29 +02:00
|
|
|
public CrawlJournal getCrawlJournal()
|
|
|
|
{
|
|
|
|
return this.crawlJournal;
|
|
|
|
}
|
|
|
|
|
2020-09-15 03:16:26 +02:00
|
|
|
public String getDescription()
|
|
|
|
{
|
|
|
|
String result;
|
|
|
|
|
|
|
|
result = get("organization.description");
|
|
|
|
|
|
|
|
//
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2020-10-11 06:57:21 +02:00
|
|
|
/**
|
|
|
|
* Gets the diaspora page.
|
|
|
|
*
|
|
|
|
* @return the diaspora page
|
|
|
|
*/
|
|
|
|
public String getDiasporaWebpage()
|
|
|
|
{
|
|
|
|
String result;
|
|
|
|
|
2020-10-16 00:47:26 +02:00
|
|
|
result = get("organization.socialnetworks.diaspora", "organization.socialnetworks.diaspora.url");
|
2020-10-11 06:57:21 +02:00
|
|
|
|
|
|
|
//
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2020-10-04 03:51:27 +02:00
|
|
|
/**
|
|
|
|
* Gets the end date.
|
|
|
|
*
|
|
|
|
* @return the end date
|
|
|
|
*/
|
|
|
|
public String getEndDate()
|
|
|
|
{
|
|
|
|
String result;
|
|
|
|
|
2020-10-15 01:49:55 +02:00
|
|
|
result = get("organization.enddate");
|
2020-10-04 03:51:27 +02:00
|
|
|
|
|
|
|
//
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2020-09-21 06:15:07 +02:00
|
|
|
public Federation getFederation()
|
|
|
|
{
|
|
|
|
return this.federation;
|
|
|
|
}
|
|
|
|
|
2020-10-16 03:50:53 +02:00
|
|
|
/**
|
|
|
|
* Gets the funkwhale webpage.
|
|
|
|
*
|
|
|
|
* @return the funkwhale webpage
|
|
|
|
*/
|
|
|
|
public String getFunkwhaleWebpage()
|
|
|
|
{
|
|
|
|
String result;
|
|
|
|
|
|
|
|
result = get("organization.socialnetworks.funkwhale", "organization.socialnetworks.funkwhale.url");
|
|
|
|
|
|
|
|
//
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2021-05-14 02:40:15 +02:00
|
|
|
public PropertyChecks getInputChecks()
|
|
|
|
{
|
|
|
|
return this.inputChecks;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the input checks all.
|
|
|
|
*
|
|
|
|
* @return the input checks all
|
|
|
|
*/
|
|
|
|
public PropertyChecks getInputChecksAll()
|
|
|
|
{
|
|
|
|
PropertyChecks result;
|
|
|
|
|
|
|
|
result = new PropertyChecks();
|
|
|
|
|
|
|
|
result.addAll(this.inputChecks);
|
|
|
|
for (Service service : this.services)
|
|
|
|
{
|
2021-05-20 16:03:29 +02:00
|
|
|
result.addAll(service.getInputChecksAll());
|
2021-05-14 02:40:15 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2020-09-23 21:56:40 +02:00
|
|
|
public File getInputFile()
|
2020-09-17 18:54:29 +02:00
|
|
|
{
|
2020-09-23 21:56:40 +02:00
|
|
|
return this.inputFile;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the crawled input URL.
|
|
|
|
*
|
|
|
|
* @return the crawled input URL
|
|
|
|
*/
|
|
|
|
public URL getInputURL()
|
|
|
|
{
|
|
|
|
URL result;
|
|
|
|
|
|
|
|
result = this.inputURL;
|
|
|
|
|
|
|
|
//
|
|
|
|
return result;
|
2020-09-17 18:54:29 +02:00
|
|
|
}
|
|
|
|
|
2020-10-04 03:51:27 +02:00
|
|
|
/**
|
|
|
|
* Gets the legal website.
|
|
|
|
*
|
|
|
|
* @return the legal website
|
|
|
|
*/
|
2021-06-08 19:01:11 +02:00
|
|
|
public URL getLegalURL()
|
2020-10-04 03:51:27 +02:00
|
|
|
{
|
2021-06-08 19:01:11 +02:00
|
|
|
URL result;
|
|
|
|
|
|
|
|
String value = get("organization.legal.url", "organization.legal");
|
2020-10-04 03:51:27 +02:00
|
|
|
|
2021-06-08 19:01:11 +02:00
|
|
|
result = URLUtils.of(value);
|
2020-10-04 03:51:27 +02:00
|
|
|
|
|
|
|
//
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2021-05-20 16:03:29 +02:00
|
|
|
/**
|
|
|
|
* Gets the local file base name.
|
|
|
|
*
|
|
|
|
* @return the local file base name
|
|
|
|
*/
|
|
|
|
public String getLocalFileBaseName()
|
|
|
|
{
|
|
|
|
String result;
|
|
|
|
|
|
|
|
result = getTechnicalName();
|
|
|
|
|
|
|
|
//
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2021-01-15 04:58:55 +01:00
|
|
|
/**
|
|
|
|
* Gets the local file name.
|
|
|
|
*
|
|
|
|
* @return the local file name
|
|
|
|
*/
|
|
|
|
public String getLocalFileName()
|
|
|
|
{
|
|
|
|
String result;
|
|
|
|
|
2021-05-20 16:03:29 +02:00
|
|
|
result = getLocalFileBaseName() + ".properties";
|
2021-01-15 04:58:55 +01:00
|
|
|
|
|
|
|
//
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2020-10-23 03:59:44 +02:00
|
|
|
/**
|
|
|
|
* Gets the logo file name.
|
|
|
|
*
|
|
|
|
* @return the logo file name
|
|
|
|
*/
|
|
|
|
public String getLogoFileName()
|
|
|
|
{
|
|
|
|
String result;
|
|
|
|
|
|
|
|
result = this.logoFileName;
|
|
|
|
|
|
|
|
//
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2020-09-19 02:37:52 +02:00
|
|
|
/**
|
|
|
|
* Gets the logo URL.
|
|
|
|
*
|
|
|
|
* @return the logo URL
|
|
|
|
*/
|
2021-06-08 19:01:11 +02:00
|
|
|
public URL getLogoURL()
|
2020-09-19 02:37:52 +02:00
|
|
|
{
|
|
|
|
URL result;
|
|
|
|
|
2021-06-08 19:01:11 +02:00
|
|
|
result = URLUtils.of(getLogoURLValue());
|
2020-09-19 02:37:52 +02:00
|
|
|
|
|
|
|
//
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2021-04-15 03:55:18 +02:00
|
|
|
/**
|
|
|
|
* Gets the logo URL value.
|
|
|
|
*
|
|
|
|
* @return the logo URL value
|
|
|
|
*/
|
|
|
|
public String getLogoURLValue()
|
|
|
|
{
|
|
|
|
String result;
|
|
|
|
|
|
|
|
result = get("organization.logo");
|
|
|
|
|
|
|
|
//
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2020-10-11 06:57:21 +02:00
|
|
|
/**
|
|
|
|
* Gets the mastodon page.
|
|
|
|
*
|
|
|
|
* @return the mastodon page
|
|
|
|
*/
|
|
|
|
public String getMastodonWebpage()
|
|
|
|
{
|
|
|
|
String result;
|
|
|
|
|
2020-10-16 00:47:26 +02:00
|
|
|
result = get("organization.socialnetworks.mastodon", "organization.socialnetworks.mastodon.url");
|
2020-10-11 06:57:21 +02:00
|
|
|
|
|
|
|
//
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2021-01-25 02:00:48 +01:00
|
|
|
/**
|
|
|
|
* Gets the member age.
|
|
|
|
*
|
|
|
|
* @return the member age
|
|
|
|
*/
|
|
|
|
public String getMemberAge()
|
|
|
|
{
|
|
|
|
String result;
|
|
|
|
|
|
|
|
LocalDate startDate = StatoolInfosUtils.parseDate(getMemberStartDate());
|
|
|
|
LocalDate endDate = StatoolInfosUtils.parseDate(getMemberEndDate());
|
|
|
|
|
|
|
|
result = StatoolInfosUtils.toHumanDuration(startDate, endDate);
|
|
|
|
|
|
|
|
//
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the member end date.
|
|
|
|
*
|
|
|
|
* @return the member end date
|
|
|
|
*/
|
|
|
|
public String getMemberEndDate()
|
|
|
|
{
|
|
|
|
String result;
|
|
|
|
|
|
|
|
result = get("organization.memberof." + this.federation.getName() + ".enddate");
|
|
|
|
|
|
|
|
//
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the member start date.
|
|
|
|
*
|
|
|
|
* @return the member start date
|
|
|
|
*/
|
|
|
|
public String getMemberStartDate()
|
|
|
|
{
|
|
|
|
String result;
|
|
|
|
|
|
|
|
result = get("organization.memberof." + this.federation.getName() + ".startdate");
|
|
|
|
|
|
|
|
//
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2022-01-08 04:55:31 +01:00
|
|
|
/**
|
|
|
|
* 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;
|
|
|
|
}
|
|
|
|
|
2021-05-24 17:46:07 +02:00
|
|
|
/**
|
|
|
|
* Gets the metric month values all.
|
|
|
|
*
|
|
|
|
* @param path
|
|
|
|
* the path
|
|
|
|
* @return the metric month values all
|
|
|
|
*/
|
|
|
|
public MonthValues getMetricMonthValuesAll(final String path)
|
|
|
|
{
|
|
|
|
MonthValues result;
|
|
|
|
|
|
|
|
result = getMetricMonthValues(path);
|
|
|
|
|
|
|
|
for (Service service : getServices())
|
|
|
|
{
|
|
|
|
result.addAll(service.getMetricMonthValues(path));
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2021-06-02 18:36:02 +02:00
|
|
|
/**
|
|
|
|
* Gets the metric week values all.
|
|
|
|
*
|
|
|
|
* @param path
|
|
|
|
* the path
|
|
|
|
* @return the metric week values all
|
|
|
|
*/
|
|
|
|
public WeekValues getMetricWeekValuesAll(final String path)
|
|
|
|
{
|
|
|
|
WeekValues result;
|
|
|
|
|
|
|
|
result = getMetricWeekValues(path);
|
|
|
|
|
|
|
|
for (Service service : getServices())
|
|
|
|
{
|
|
|
|
result.addAll(service.getMetricWeekValues(path));
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the metric year values all.
|
|
|
|
*
|
|
|
|
* @param path
|
|
|
|
* the path
|
|
|
|
* @return the metric year values all
|
|
|
|
*/
|
|
|
|
public YearValues getMetricYearValuesAll(final String path)
|
|
|
|
{
|
|
|
|
YearValues result;
|
|
|
|
|
|
|
|
result = getMetricYearValues(path);
|
|
|
|
|
|
|
|
for (Service service : getServices())
|
|
|
|
{
|
|
|
|
result.addAll(service.getMetricYearValues(path));
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2020-10-16 03:50:53 +02:00
|
|
|
/**
|
|
|
|
* Gets the mobilizon webpage.
|
|
|
|
*
|
|
|
|
* @return the mobilizon webpage
|
|
|
|
*/
|
|
|
|
public String getMobilizonWebpage()
|
|
|
|
{
|
|
|
|
String result;
|
|
|
|
|
|
|
|
result = get("organization.socialnetworks.mobilizon", "organization.socialnetworks.mobilizon.url");
|
|
|
|
|
|
|
|
//
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2020-09-15 03:16:26 +02:00
|
|
|
/**
|
|
|
|
* Gets the name.
|
|
|
|
*
|
|
|
|
* @return the name
|
|
|
|
*/
|
|
|
|
public String getName()
|
|
|
|
{
|
|
|
|
String result;
|
|
|
|
|
|
|
|
result = get("organization.name");
|
|
|
|
|
2021-01-08 04:19:21 +01:00
|
|
|
if (StringUtils.isBlank(result))
|
|
|
|
{
|
|
|
|
URL url = getInputURL();
|
|
|
|
if (url == null)
|
|
|
|
{
|
|
|
|
result = "anonymous";
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
result = DigestUtils.md5Hex(url.toString()).substring(0, 8);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-09-15 03:16:26 +02:00
|
|
|
//
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2020-10-16 03:50:53 +02:00
|
|
|
/**
|
|
|
|
* Gets the peertube webpage.
|
|
|
|
*
|
|
|
|
* @return the peertube webpage
|
|
|
|
*/
|
|
|
|
public String getPeertubeWebpage()
|
|
|
|
{
|
|
|
|
String result;
|
|
|
|
|
|
|
|
result = get("organization.socialnetworks.peertube", "organization.socialnetworks.peertube.url");
|
|
|
|
|
|
|
|
//
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the pixelfed webpage.
|
|
|
|
*
|
|
|
|
* @return the pixelfed webpage
|
|
|
|
*/
|
|
|
|
public String getPixelfedWebpage()
|
|
|
|
{
|
|
|
|
String result;
|
|
|
|
|
|
|
|
result = get("organization.socialnetworks.pixelfed", "organization.socialnetworks.pixelfed.url");
|
|
|
|
|
|
|
|
//
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2021-06-03 04:50:51 +02:00
|
|
|
/**
|
|
|
|
* Gets the previous month user count.
|
|
|
|
*
|
|
|
|
* @return the previous month user count
|
|
|
|
*/
|
|
|
|
public long getPreviousMonthUserCount()
|
|
|
|
{
|
|
|
|
long result;
|
|
|
|
|
|
|
|
result = 0;
|
|
|
|
for (Service service : this.services)
|
|
|
|
{
|
|
|
|
result += service.getPreviousMonthUserCount();
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the previous month visit count.
|
|
|
|
*
|
|
|
|
* @return the previous month visit count
|
|
|
|
*/
|
|
|
|
public long getPreviousMonthVisitCount()
|
|
|
|
{
|
|
|
|
long result;
|
|
|
|
|
|
|
|
result = 0;
|
|
|
|
for (Service service : this.services)
|
|
|
|
{
|
|
|
|
result += service.getPreviousMonthVisitCount();
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2020-09-19 02:37:52 +02:00
|
|
|
/**
|
|
|
|
* Gets the service count.
|
|
|
|
*
|
|
|
|
* @return the service count
|
|
|
|
*/
|
|
|
|
public int getServiceCount()
|
|
|
|
{
|
|
|
|
int result;
|
|
|
|
|
|
|
|
result = this.services.size();
|
|
|
|
|
|
|
|
//
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2020-09-15 03:16:26 +02:00
|
|
|
public Services getServices()
|
|
|
|
{
|
|
|
|
return this.services;
|
|
|
|
}
|
|
|
|
|
2020-10-04 03:51:27 +02:00
|
|
|
/**
|
|
|
|
* Gets the start date.
|
|
|
|
*
|
|
|
|
* @return the start date
|
|
|
|
*/
|
|
|
|
public String getStartDate()
|
|
|
|
{
|
|
|
|
String result;
|
|
|
|
|
2020-10-15 01:49:55 +02:00
|
|
|
result = get("organization.startdate");
|
2020-10-04 03:51:27 +02:00
|
|
|
|
|
|
|
//
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2022-01-08 04:55:31 +01:00
|
|
|
/**
|
|
|
|
* 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;
|
|
|
|
}
|
|
|
|
|
2020-10-04 03:51:27 +02:00
|
|
|
/**
|
2020-10-22 23:12:19 +02:00
|
|
|
* Gets the technical guide website.
|
2020-10-04 03:51:27 +02:00
|
|
|
*
|
2020-10-22 23:12:19 +02:00
|
|
|
* @return the technical guide website
|
2020-10-04 03:51:27 +02:00
|
|
|
*/
|
2021-06-08 19:01:11 +02:00
|
|
|
public URL getTechnicalGuideURL()
|
2020-10-04 03:51:27 +02:00
|
|
|
{
|
2021-06-08 19:01:11 +02:00
|
|
|
URL result;
|
2020-10-04 03:51:27 +02:00
|
|
|
|
2021-06-08 19:01:11 +02:00
|
|
|
String value = get("organization.guide.technical", "organization.guide.technical.url");
|
|
|
|
|
|
|
|
result = URLUtils.of(value);
|
2020-10-04 03:51:27 +02:00
|
|
|
|
|
|
|
//
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2020-09-15 03:16:26 +02:00
|
|
|
/**
|
|
|
|
* Gets the technical name.
|
|
|
|
*
|
|
|
|
* @return the technical name
|
|
|
|
*/
|
|
|
|
public String getTechnicalName()
|
|
|
|
{
|
|
|
|
String result;
|
|
|
|
|
2020-09-25 04:36:38 +02:00
|
|
|
result = StatoolInfosUtils.toTechnicalName(getName());
|
|
|
|
|
|
|
|
//
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2021-09-16 17:31:53 +02:00
|
|
|
/**
|
|
|
|
* Gets the URL all.
|
|
|
|
*
|
|
|
|
* @return the URL all
|
|
|
|
*/
|
|
|
|
public URLSet getURLActiveAll()
|
|
|
|
{
|
|
|
|
URLSet result;
|
|
|
|
|
|
|
|
result = new URLSet();
|
|
|
|
|
|
|
|
result.add(getContactURL());
|
|
|
|
result.add(getLegalURL());
|
|
|
|
result.add(getLogoURL());
|
|
|
|
result.add(getTechnicalGuideURL());
|
|
|
|
result.add(getUserGuideURL());
|
|
|
|
result.add(getWebsiteURL());
|
|
|
|
|
|
|
|
//
|
|
|
|
for (Service service : getServices().getBy(Service.Status.OK))
|
|
|
|
{
|
|
|
|
result.addAll(service.getURLAll());
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2021-06-11 23:35:50 +02:00
|
|
|
/**
|
|
|
|
* Gets the URL all.
|
|
|
|
*
|
|
|
|
* @return the URL all
|
|
|
|
*/
|
|
|
|
public URLSet getURLAll()
|
|
|
|
{
|
|
|
|
URLSet result;
|
|
|
|
|
|
|
|
result = new URLSet();
|
|
|
|
|
|
|
|
result.add(getContactURL());
|
|
|
|
result.add(getLegalURL());
|
|
|
|
result.add(getLogoURL());
|
|
|
|
result.add(getTechnicalGuideURL());
|
|
|
|
result.add(getUserGuideURL());
|
|
|
|
result.add(getWebsiteURL());
|
|
|
|
|
|
|
|
//
|
|
|
|
for (Service service : getServices())
|
|
|
|
{
|
|
|
|
result.addAll(service.getURLAll());
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2020-09-25 04:36:38 +02:00
|
|
|
/**
|
|
|
|
* Gets the user count.
|
|
|
|
*
|
|
|
|
* @return the user count
|
|
|
|
*/
|
|
|
|
public int getUserCount()
|
|
|
|
{
|
|
|
|
int result;
|
|
|
|
|
|
|
|
result = 0;
|
2020-09-17 02:03:56 +02:00
|
|
|
|
|
|
|
//
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2020-10-04 03:51:27 +02:00
|
|
|
/**
|
2020-10-22 23:12:19 +02:00
|
|
|
* Gets the user guide website.
|
2020-10-04 03:51:27 +02:00
|
|
|
*
|
2020-10-22 23:12:19 +02:00
|
|
|
* @return the user guide website
|
2020-10-04 03:51:27 +02:00
|
|
|
*/
|
2021-06-08 19:01:11 +02:00
|
|
|
public URL getUserGuideURL()
|
2020-10-04 03:51:27 +02:00
|
|
|
{
|
2021-06-08 19:01:11 +02:00
|
|
|
URL result;
|
|
|
|
|
|
|
|
String value = get("organization.guide.user", "organization.guide.user.url");
|
2020-10-04 03:51:27 +02:00
|
|
|
|
2021-06-08 19:01:11 +02:00
|
|
|
result = URLUtils.of(value);
|
2020-10-04 03:51:27 +02:00
|
|
|
|
|
|
|
//
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2020-09-17 02:03:56 +02:00
|
|
|
/**
|
|
|
|
* Gets the website.
|
|
|
|
*
|
|
|
|
* @return the website
|
|
|
|
*/
|
2021-06-08 19:01:11 +02:00
|
|
|
public URL getWebsiteURL()
|
2020-09-17 02:03:56 +02:00
|
|
|
{
|
2021-06-08 19:01:11 +02:00
|
|
|
URL result;
|
2020-09-17 02:03:56 +02:00
|
|
|
|
2021-06-08 19:01:11 +02:00
|
|
|
result = getURL("organization.website");
|
2020-09-15 03:16:26 +02:00
|
|
|
|
|
|
|
//
|
|
|
|
return result;
|
|
|
|
}
|
2020-09-17 18:54:29 +02:00
|
|
|
|
2020-10-11 06:57:21 +02:00
|
|
|
/**
|
|
|
|
* Checks for social network.
|
|
|
|
*
|
|
|
|
* @return true, if successful
|
|
|
|
*/
|
|
|
|
public boolean hasSocialNetwork()
|
|
|
|
{
|
|
|
|
boolean result;
|
|
|
|
|
|
|
|
if (StringUtils.isAllBlank(getDiasporaWebpage(), getMastodonWebpage()))
|
|
|
|
{
|
|
|
|
result = false;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
result = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Checks for social network.
|
|
|
|
*
|
|
|
|
* @param value
|
|
|
|
* the value
|
|
|
|
* @return true, if successful
|
|
|
|
*/
|
|
|
|
public boolean hasSocialNetwork(final SocialNetworks value)
|
|
|
|
{
|
|
|
|
boolean result;
|
|
|
|
|
|
|
|
String link;
|
|
|
|
switch (value)
|
|
|
|
{
|
|
|
|
case DIASPORA:
|
|
|
|
link = getDiasporaWebpage();
|
|
|
|
break;
|
|
|
|
case MASTODON:
|
|
|
|
link = getMastodonWebpage();
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
link = null;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (StringUtils.isBlank(link))
|
|
|
|
{
|
|
|
|
result = false;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
result = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2022-01-08 04:55:31 +01:00
|
|
|
/**
|
|
|
|
* 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;
|
|
|
|
}
|
|
|
|
|
2021-04-15 03:55:18 +02:00
|
|
|
/**
|
|
|
|
* Checks if is default.
|
|
|
|
*
|
|
|
|
* @return true, if is default
|
|
|
|
*/
|
|
|
|
public boolean isDefault()
|
|
|
|
{
|
|
|
|
boolean result;
|
|
|
|
|
|
|
|
if ((getServiceCount() == 0) && (getLogoURLValue() == null) && (getStartDate() == null))
|
|
|
|
{
|
|
|
|
result = true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
result = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2021-01-08 04:19:21 +01:00
|
|
|
/**
|
|
|
|
* Checks if is valid.
|
|
|
|
*
|
|
|
|
* @return true, if is valid
|
|
|
|
*/
|
|
|
|
public boolean isValid()
|
|
|
|
{
|
|
|
|
boolean result;
|
|
|
|
|
|
|
|
// if (StringUtils.equalsIgnoreCase(get("file.class"), "organization"))
|
|
|
|
if (isEmpty())
|
|
|
|
{
|
|
|
|
result = false;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
result = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2020-09-21 06:15:07 +02:00
|
|
|
public void setFederation(final Federation federation)
|
|
|
|
{
|
|
|
|
this.federation = federation;
|
|
|
|
}
|
|
|
|
|
2020-09-23 21:56:40 +02:00
|
|
|
public void setInputFile(final File inputFile)
|
|
|
|
{
|
|
|
|
this.inputFile = inputFile;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setInputURL(final URL inputURL)
|
2020-09-17 18:54:29 +02:00
|
|
|
{
|
2020-09-23 21:56:40 +02:00
|
|
|
this.inputURL = inputURL;
|
2020-09-17 18:54:29 +02:00
|
|
|
}
|
2020-10-23 03:59:44 +02:00
|
|
|
|
|
|
|
public void setLogoFileName(final String logoFileName)
|
|
|
|
{
|
|
|
|
this.logoFileName = logoFileName;
|
|
|
|
}
|
2020-09-15 03:16:26 +02:00
|
|
|
}
|