2020-09-13 01:28:27 +02:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2020 Christian Pierre MOMON <christian@momon.org>
|
|
|
|
*
|
|
|
|
* 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 03:59:11 +02:00
|
|
|
import java.io.File;
|
|
|
|
import java.net.MalformedURLException;
|
|
|
|
import java.net.URL;
|
|
|
|
|
2020-09-17 02:03:56 +02:00
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
|
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;
|
2020-09-13 01:28:27 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The Class PathProperty.
|
|
|
|
*/
|
2020-09-15 03:16:26 +02:00
|
|
|
public class Federation extends PathPropertyList
|
2020-09-13 01:28:27 +02:00
|
|
|
{
|
2020-09-15 03:16:26 +02:00
|
|
|
private static final long serialVersionUID = -8970835291634661580L;
|
|
|
|
private Organizations organizations;
|
2020-09-23 21:56:40 +02:00
|
|
|
private File inputFile;
|
2020-09-13 01:28:27 +02:00
|
|
|
|
2020-09-13 02:10:28 +02:00
|
|
|
/**
|
2020-09-15 03:16:26 +02:00
|
|
|
* Instantiates a new federation.
|
|
|
|
*/
|
|
|
|
public Federation()
|
|
|
|
{
|
2020-09-17 02:03:56 +02:00
|
|
|
super();
|
|
|
|
this.organizations = new Organizations();
|
2020-09-15 03:16:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Instantiates a new federation.
|
2020-09-13 02:10:28 +02:00
|
|
|
*
|
2020-09-15 03:16:26 +02:00
|
|
|
* @param properties
|
|
|
|
* the properties
|
2020-09-13 02:10:28 +02:00
|
|
|
*/
|
2020-09-17 02:28:37 +02:00
|
|
|
public Federation(final PathProperties properties)
|
2020-09-13 02:10:28 +02:00
|
|
|
{
|
2020-09-15 03:16:26 +02:00
|
|
|
super(properties);
|
2020-09-17 02:03:56 +02:00
|
|
|
|
|
|
|
if ((properties == null) || (StringUtils.isBlank(properties.get("federation.name"))))
|
|
|
|
{
|
|
|
|
throw new IllegalArgumentException("Not a federation.");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
this.organizations = new Organizations();
|
|
|
|
}
|
2020-09-13 02:10:28 +02:00
|
|
|
}
|
2020-09-13 01:28:27 +02:00
|
|
|
|
2020-09-21 00:20:14 +02:00
|
|
|
/**
|
|
|
|
* Gets the all services.
|
|
|
|
*
|
|
|
|
* @return the all services
|
|
|
|
*/
|
|
|
|
public Services getAllServices()
|
|
|
|
{
|
|
|
|
Services result;
|
|
|
|
|
|
|
|
result = new Services();
|
|
|
|
|
|
|
|
for (Organization organization : this.organizations)
|
|
|
|
{
|
|
|
|
result.addAll(organization.getServices());
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2020-09-15 03:16:26 +02:00
|
|
|
/**
|
|
|
|
* Gets the description.
|
|
|
|
*
|
|
|
|
* @return the description
|
|
|
|
*/
|
|
|
|
public String getDescription()
|
2020-09-13 02:10:28 +02:00
|
|
|
{
|
|
|
|
String result;
|
2020-09-13 01:28:27 +02:00
|
|
|
|
2020-09-17 03:59:11 +02:00
|
|
|
result = get("federation.description");
|
|
|
|
|
|
|
|
//
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2020-09-23 21:56:40 +02:00
|
|
|
public File getInputFile()
|
2020-09-17 03:59:11 +02:00
|
|
|
{
|
2020-09-23 21:56:40 +02:00
|
|
|
return this.inputFile;
|
2020-09-17 03:59:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the logo URL.
|
|
|
|
*
|
|
|
|
* @return the logo URL
|
|
|
|
* @throws MalformedURLException
|
|
|
|
*/
|
|
|
|
public URL getLogoURL() throws MalformedURLException
|
|
|
|
{
|
|
|
|
URL result;
|
|
|
|
|
|
|
|
String path = get("federation.logo");
|
|
|
|
if ((StringUtils.isBlank(path)) || (!StringUtils.startsWith(path, "http")))
|
|
|
|
{
|
|
|
|
result = null;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
result = new URL(path);
|
|
|
|
}
|
2020-09-13 01:28:27 +02:00
|
|
|
|
2020-09-13 02:10:28 +02:00
|
|
|
//
|
|
|
|
return result;
|
|
|
|
}
|
2020-09-13 01:28:27 +02:00
|
|
|
|
2020-09-15 03:16:26 +02:00
|
|
|
/**
|
|
|
|
* Gets the name.
|
|
|
|
*
|
|
|
|
* @return the name
|
|
|
|
*/
|
|
|
|
public String getName()
|
2020-09-13 02:10:28 +02:00
|
|
|
{
|
2020-09-15 03:16:26 +02:00
|
|
|
String result;
|
2020-09-13 01:28:27 +02:00
|
|
|
|
2020-09-17 02:03:56 +02:00
|
|
|
result = get("federation.name");
|
2020-09-13 01:28:27 +02:00
|
|
|
|
2020-09-15 03:16:26 +02:00
|
|
|
//
|
|
|
|
return result;
|
2020-09-13 02:10:28 +02:00
|
|
|
}
|
2020-09-13 01:28:27 +02:00
|
|
|
|
2020-09-19 02:37:52 +02:00
|
|
|
/**
|
|
|
|
* Gets the organiation count.
|
|
|
|
*
|
|
|
|
* @return the organiation count
|
|
|
|
*/
|
|
|
|
public int getOrganiationCount()
|
|
|
|
{
|
|
|
|
int result;
|
|
|
|
|
|
|
|
result = this.organizations.size();
|
|
|
|
|
|
|
|
//
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2020-09-15 03:16:26 +02:00
|
|
|
public Organizations getOrganizations()
|
2020-09-13 02:10:28 +02:00
|
|
|
{
|
2020-09-15 03:16:26 +02:00
|
|
|
return this.organizations;
|
2020-09-13 02:10:28 +02:00
|
|
|
}
|
2020-09-17 02:03:56 +02:00
|
|
|
|
2020-09-19 02:37:52 +02:00
|
|
|
/**
|
|
|
|
* Gets the service count.
|
|
|
|
*
|
|
|
|
* @return the service count
|
|
|
|
*/
|
|
|
|
public int getServiceCount()
|
|
|
|
{
|
|
|
|
int result;
|
|
|
|
|
|
|
|
result = 0;
|
|
|
|
for (Organization organization : this.organizations)
|
|
|
|
{
|
|
|
|
result += organization.getServiceCount();
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2020-09-17 02:03:56 +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());
|
2020-09-17 02:03:56 +02:00
|
|
|
|
|
|
|
//
|
|
|
|
return result;
|
|
|
|
}
|
2020-09-17 03:59:11 +02:00
|
|
|
|
2020-09-23 21:56:40 +02:00
|
|
|
public void setInputFile(final File inputFile)
|
2020-09-17 03:59:11 +02:00
|
|
|
{
|
2020-09-23 21:56:40 +02:00
|
|
|
this.inputFile = inputFile;
|
2020-09-17 03:59:11 +02:00
|
|
|
}
|
2020-09-13 01:28:27 +02:00
|
|
|
}
|