statoolinfosweb/src/fr/devinsy/statoolinfos/core/Organization.java

439 lines
8.6 KiB
Java
Raw Normal View History

2020-09-15 03:16:26 +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;
import java.io.File;
2020-09-19 02:37:52 +02:00
import java.net.MalformedURLException;
import java.net.URL;
2020-09-28 03:52:51 +02:00
import java.time.LocalDateTime;
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;
/**
* The Class PathProperty.
*/
public class Organization extends PathPropertyList
{
private static final long serialVersionUID = -2709210934548224213L;
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-09-15 03:16:26 +02:00
/**
* Instantiates a new organization.
*/
public Organization()
{
super();
this.services = new Services();
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);
if ((properties == null) || (StringUtils.isBlank(properties.get("organization.name"))))
{
throw new IllegalArgumentException("Not an organization.");
}
else
{
this.services = new Services();
}
2020-09-15 03:16:26 +02:00
}
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
*/
public String getContactWebsite()
{
String result;
result = get("organization.contact.url");
//
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"));
//
return result;
}
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;
result = get("organization.socialnetworks.diaspora");
//
return result;
}
2020-10-04 03:51:27 +02:00
/**
* Gets the end date.
*
* @return the end date
*/
public String getEndDate()
{
String result;
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-09-23 21:56:40 +02:00
public File getInputFile()
{
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-10-04 03:51:27 +02:00
/**
* Gets the legal website.
*
* @return the legal website
*/
public String getLegalWebsite()
{
String result;
result = get("organization.legal.url", "organization.legal");
//
return result;
}
2020-09-19 02:37:52 +02:00
/**
* Gets the logo URL.
*
* @return the logo URL
* @throws MalformedURLException
* the malformed URL exception
*/
public URL getLogoURL() throws MalformedURLException
{
URL result;
String path = get("organization.logo");
if ((StringUtils.isBlank(path)) || (!StringUtils.startsWith(path, "http")))
{
result = null;
}
else
{
result = new URL(path);
}
//
return result;
}
2020-10-11 06:57:21 +02:00
/**
* Gets the mastodon page.
*
* @return the mastodon page
*/
public String getMastodonWebpage()
{
String result;
result = get("organization.socialnetworks.mastodon");
//
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");
//
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;
result = get("organization.startdate");
2020-10-04 03:51:27 +02:00
//
return result;
}
/**
* Gets the technical doc website.
*
* @return the technical doc website
*/
public String getTechnicalDocWebsite()
{
String result;
result = get("organization.documentation.technical", "organization.documentationtechnical.url", "organization.technical", "organization.technical.url", "service.guide.technical",
"organization.guide.technical.url");
//
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;
}
/**
* Gets the user count.
*
* @return the user count
*/
public int getUserCount()
{
int result;
result = 0;
//
return result;
}
2020-10-04 03:51:27 +02:00
/**
* Gets the user doc website.
*
* @return the user doc website
*/
public String getUserDocWebsite()
{
String result;
result = get("organization.documentation", "organization.documentation.url", "organization.documentation.user", "organization.documentation.user.url", "service.documentation.tutorial",
"organization.documentation.tutorial.url",
"organization.guide.user",
"organization.guide.user.url");
//
return result;
}
/**
* Gets the website.
*
* @return the website
*/
public String getWebsite()
{
String result;
result = get("organization.website");
2020-09-15 03:16:26 +02:00
//
return result;
}
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;
}
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-23 21:56:40 +02:00
this.inputURL = inputURL;
}
2020-09-15 03:16:26 +02:00
}