com.okworx.ilcd.validation.util.Statistics Maven / Gradle / Ivy
Show all versions of ilcd-validation Show documentation
package com.okworx.ilcd.validation.util;
import java.util.HashSet;
import java.util.Set;
import org.apache.logging.log4j.Logger;
import com.okworx.ilcd.validation.reference.IDatasetReference;
/**
* Statistics class.
*
* @author oliver.kusche
* @version $Id: $Id
*/
public class Statistics {
protected final Logger log = org.apache.logging.log4j.LogManager.getLogger(this.getClass());
protected String aspects;
protected Set validProcesses = new HashSet();
protected Set validFlows = new HashSet();
protected Set validFlowProperties = new HashSet();
protected Set validUnitGroups = new HashSet();
protected Set validSources = new HashSet();
protected Set validContacts = new HashSet();
protected Set validLCIAMethods = new HashSet();
protected Set validLCModels = new HashSet();
protected Set validExternalFiles = new HashSet();
protected Set invalidProcesses = new HashSet();
protected Set invalidFlows = new HashSet();
protected Set invalidFlowProperties = new HashSet();
protected Set invalidUnitGroups = new HashSet();
protected Set invalidSources = new HashSet();
protected Set invalidContacts = new HashSet();
protected Set invalidLCIAMethods = new HashSet();
protected Set invalidLCModels = new HashSet();
protected Set invalidExternalFiles = new HashSet();
/**
* update.
*
* @param reference a {@link com.okworx.ilcd.validation.reference.IDatasetReference} object.
* @param success a boolean.
*/
public void update(IDatasetReference reference, boolean success) {
if (log.isTraceEnabled())
log.trace("counting " + (success ? "" : "un") + "successful validation of " + reference.getDatasetType());
switch (reference.getDatasetType()) {
case CONTACT:
if (success) {
this.validContacts.add(reference);
} else {
this.invalidContacts.add(reference);
this.validContacts.remove(reference);
}
break;
case EXTERNAL_FILE:
if (success) {
this.validExternalFiles.add(reference);
} else {
this.invalidExternalFiles.add(reference);
this.validExternalFiles.remove(reference);
}
break;
case FLOW:
if (success) {
this.validFlows.add(reference);
} else {
this.invalidFlows.add(reference);
this.validFlows.remove(reference);
}
break;
case FLOWPROPERTY:
if (success) {
this.validFlowProperties.add(reference);
} else {
this.invalidFlowProperties.add(reference);
this.validFlowProperties.remove(reference);
}
break;
case LCIAMETHOD:
if (success) {
this.validLCIAMethods.add(reference);
} else {
this.invalidLCIAMethods.add(reference);
this.validLCIAMethods.remove(reference);
}
break;
case PROCESS:
if (success) {
this.validProcesses.add(reference);
} else {
this.invalidProcesses.add(reference);
this.validProcesses.remove(reference);
}
break;
case SOURCE:
if (success) {
this.validSources.add(reference);
} else {
this.invalidSources.add(reference);
this.validSources.remove(reference);
}
break;
case UNITGROUP:
if (success) {
this.validUnitGroups.add(reference);
} else {
this.invalidUnitGroups.add(reference);
this.validUnitGroups.remove(reference);
}
break;
case LCMODEL:
if (success) {
this.validLCModels.add(reference);
} else {
this.invalidLCModels.add(reference);
this.validLCModels.remove(reference);
}
break;
}
}
/**
* This method combines two statistics by merely adding them.
* Use only for statistics from sets of disjunct data.
*
* @param stats a {@link com.okworx.ilcd.validation.util.Statistics} object.
*/
public void add(Statistics stats) {
this.validContacts.addAll(stats.getValidContacts());
this.validFlowProperties.addAll(stats.getValidFlowProperties());
this.validFlows.addAll(stats.getValidFlows());
this.validLCIAMethods.addAll(stats.getValidLCIAMethods());
this.validProcesses.addAll(stats.getValidProcesses());
this.validSources.addAll(stats.getValidSources());
this.validUnitGroups.addAll(stats.getValidUnitGroups());
this.validLCModels.addAll(stats.getValidLCModels());
this.validExternalFiles.addAll(stats.getValidExternalFiles());
this.invalidContacts.addAll(stats.getInvalidContacts());
this.invalidFlowProperties.addAll(stats.getInvalidFlowProperties());
this.invalidFlows.addAll(stats.getInvalidFlows());
this.invalidLCIAMethods.addAll(stats.getInvalidLCIAMethods());
this.invalidProcesses.addAll(stats.getInvalidProcesses());
this.invalidSources.addAll(stats.getInvalidSources());
this.invalidUnitGroups.addAll(stats.getInvalidUnitGroups());
this.invalidLCModels.addAll(stats.getInvalidLCModels());
this.invalidExternalFiles.addAll(stats.getInvalidExternalFiles());
this.aspects = stats.getAspects();
}
/**
* Merges the results of two Statistics. As if a dataset has been found
* invalid once, its status cannot revert back to valid, thus the number
* of valid datasets will be constant or reduced with each merge operation
* but never growing.
*
* @param stats a {@link com.okworx.ilcd.validation.util.Statistics} object.
*/
public void merge(Statistics stats) {
this.invalidContacts.addAll(stats.getInvalidContacts());
this.invalidFlowProperties.addAll(stats.getInvalidFlowProperties());
this.invalidFlows.addAll(stats.getInvalidFlows());
this.invalidLCIAMethods.addAll(stats.getInvalidLCIAMethods());
this.invalidProcesses.addAll(stats.getInvalidProcesses());
this.invalidSources.addAll(stats.getInvalidSources());
this.invalidUnitGroups.addAll(stats.getInvalidUnitGroups());
this.invalidLCModels.addAll(stats.getInvalidLCModels());
this.invalidExternalFiles.addAll(stats.getInvalidExternalFiles());
this.validContacts.removeAll(stats.getInvalidContacts());
this.validFlowProperties.removeAll(stats.getInvalidFlowProperties());
this.validFlows.removeAll(stats.getInvalidFlows());
this.validLCIAMethods.removeAll(stats.getInvalidLCIAMethods());
this.validProcesses.removeAll(stats.getInvalidProcesses());
this.validSources.removeAll(stats.getInvalidSources());
this.validUnitGroups.removeAll(stats.getInvalidUnitGroups());
this.validLCModels.removeAll(stats.getInvalidLCModels());
this.validExternalFiles.removeAll(stats.getInvalidExternalFiles());
this.aspects = stats.getAspects();
}
/**
* toString.
*
* @return a {@link java.lang.String} object.
*/
public String toString() {
StringBuilder builder = new StringBuilder();
builder.append("Total files processed: ").append(this.getTotalValidCount() + this.getTotalInvalidCount());
builder.append(System.lineSeparator());
builder.append(System.lineSeparator());
builder.append("Process datasets found valid: ").append(this.getValidProcessesCount()).append(" / invalid: ").append(this.getInvalidProcessesCount());
builder.append(System.lineSeparator());
builder.append("Flow datasets found valid: ").append(this.getValidFlowsCount()).append(" / invalid: ").append(this.getInvalidFlowsCount());
builder.append(System.lineSeparator());
builder.append("Source datasets found valid: ").append(this.getValidSourcesCount()).append(" / invalid: ").append(this.getInvalidSourcesCount());
builder.append(System.lineSeparator());
builder.append("Contact datasets found valid: ").append(this.getValidContactsCount()).append(" / invalid: ").append(this.getInvalidContactsCount());
builder.append(System.lineSeparator());
builder.append("LCIA Method datasets found valid: ").append(this.getValidLCIAMethodsCount()).append(" / invalid: ").append(this.getInvalidLCIAMethodsCount());
builder.append(System.lineSeparator());
builder.append("Flow Property datasets found valid: ").append(this.getValidFlowPropertiesCount()).append(" / invalid: ").append(this.getInvalidFlowPropertiesCount());
builder.append(System.lineSeparator());
builder.append("Unit Group datasets found valid: ").append(this.getValidUnitGroupsCount()).append(" / invalid: ").append(this.getInvalidUnitGroupsCount());
builder.append(System.lineSeparator());
builder.append("Life Cycle Model datasets found valid: ").append(this.getValidLCModelsCount()).append(" / invalid: ").append(this.getInvalidLCModelsCount());
builder.append(System.lineSeparator());
builder.append("External files found valid: ").append(this.getValidExternalFilesCount()).append(" / invalid: ").append(this.getInvalidExternalFilesCount());
builder.append(System.lineSeparator());
return builder.toString();
}
/**
* getTotalProcessesCount.
*
* @return a int.
*/
public int getTotalProcessesCount() {
return validProcesses.size() + invalidProcesses.size();
}
/**
* getTotalFlowsCount.
*
* @return a int.
*/
public int getTotalFlowsCount() {
return validFlows.size() + invalidFlows.size();
}
/**
* getTotalFlowPropertiesCount.
*
* @return a int.
*/
public int getTotalFlowPropertiesCount() {
return validFlowProperties.size() + invalidFlowProperties.size();
}
/**
* getTotalUnitGroupsCount.
*
* @return a int.
*/
public int getTotalUnitGroupsCount() {
return validUnitGroups.size() + invalidUnitGroups.size();
}
/**
* getTotalSourcesCount.
*
* @return a int.
*/
public int getTotalSourcesCount() {
return validSources.size() + invalidSources.size();
}
/**
* getTotalContactsCount.
*
* @return a int.
*/
public int getTotalContactsCount() {
return validContacts.size() + invalidContacts.size();
}
/**
* getTotalLCIAMethodsCount.
*
* @return a int.
*/
public int getTotalLCIAMethodsCount() {
return validLCIAMethods.size() + invalidLCIAMethods.size();
}
/**
* getTotalLCModelsCount.
*
* @return a int.
*/
public int getTotalLCModelsCount() {
return validLCModels.size() + invalidLCModels.size();
}
/**
* getTotalExternalFilesCount.
*
* @return a int.
*/
public int getTotalExternalFilesCount() {
return validExternalFiles.size() + invalidExternalFiles.size();
}
/**
* getValidProcessesCount.
*
* @return a int.
*/
public int getValidProcessesCount() {
return validProcesses.size();
}
/**
* getValidFlowsCount.
*
* @return a int.
*/
public int getValidFlowsCount() {
return validFlows.size();
}
/**
* getValidFlowPropertiesCount.
*
* @return a int.
*/
public int getValidFlowPropertiesCount() {
return validFlowProperties.size();
}
/**
* getValidUnitGroupsCount.
*
* @return a int.
*/
public int getValidUnitGroupsCount() {
return validUnitGroups.size();
}
/**
* getValidSourcesCount.
*
* @return a int.
*/
public int getValidSourcesCount() {
return validSources.size();
}
/**
* getValidContactsCount.
*
* @return a int.
*/
public int getValidContactsCount() {
return validContacts.size();
}
/**
* getValidLCIAMethodsCount.
*
* @return a int.
*/
public int getValidLCIAMethodsCount() {
return validLCIAMethods.size();
}
/**
* getValidLCModelsCount.
*
* @return a int.
*/
public int getValidLCModelsCount() {
return validLCModels.size();
}
/**
* getValidExternalFilesCount.
*
* @return a int.
*/
public int getValidExternalFilesCount() {
return validExternalFiles.size();
}
/**
* getInvalidProcessesCount.
*
* @return a int.
*/
public int getInvalidProcessesCount() {
return invalidProcesses.size();
}
/**
* getInvalidFlowsCount.
*
* @return a int.
*/
public int getInvalidFlowsCount() {
return invalidFlows.size();
}
/**
* getInvalidFlowPropertiesCount.
*
* @return a int.
*/
public int getInvalidFlowPropertiesCount() {
return invalidFlowProperties.size();
}
/**
* getInvalidUnitGroupsCount.
*
* @return a int.
*/
public int getInvalidUnitGroupsCount() {
return invalidUnitGroups.size();
}
/**
* getInvalidSourcesCount.
*
* @return a int.
*/
public int getInvalidSourcesCount() {
return invalidSources.size();
}
/**
* getInvalidContactsCount.
*
* @return a int.
*/
public int getInvalidContactsCount() {
return invalidContacts.size();
}
/**
* getInvalidLCIAMethodsCount.
*
* @return a int.
*/
public int getInvalidLCIAMethodsCount() {
return invalidLCIAMethods.size();
}
/**
* getInvalidLCModelsCount.
*
* @return a int.
*/
public int getInvalidLCModelsCount() {
return invalidLCModels.size();
}
/**
* getInvalidExternalFilesCount.
*
* @return a int.
*/
public int getInvalidExternalFilesCount() {
return invalidExternalFiles.size();
}
/**
* getTotalValidCount.
*
* @return a int.
*/
public int getTotalValidCount() {
return validContacts.size() + validFlowProperties.size() + validFlows.size() + validLCIAMethods.size()
+ validProcesses.size() + validSources.size() + validUnitGroups.size() + validLCModels.size() + validExternalFiles.size();
}
/**
* getTotalInvalidCount.
*
* @return a int.
*/
public int getTotalInvalidCount() {
return invalidContacts.size() + invalidFlowProperties.size() + invalidFlows.size() + invalidLCIAMethods.size()
+ invalidProcesses.size() + invalidSources.size() + invalidUnitGroups.size() + invalidLCModels.size() + invalidExternalFiles.size();
}
/**
* getValidDatasetsCount.
*
* @return a int.
*/
public int getValidDatasetsCount() {
return validContacts.size() + validFlowProperties.size() + validFlows.size() + validLCIAMethods.size()
+ validProcesses.size() + validSources.size() + validUnitGroups.size() + validLCModels.size();
}
/**
* getInvalidDatasetsCount.
*
* @return a int.
*/
public int getInvalidDatasetsCount() {
return invalidContacts.size() + invalidFlowProperties.size() + invalidFlows.size() + invalidLCIAMethods.size()
+ invalidProcesses.size() + invalidSources.size() + invalidUnitGroups.size() + invalidLCModels.size();
}
/**
* getTotalCount.
*
* @return a int.
*/
public int getTotalCount() {
return getTotalValidCount() + getTotalInvalidCount();
}
/**
* getTotalDatasetsCount.
*
* @return a int.
*/
public int getTotalDatasetsCount() {
return getValidDatasetsCount() + getInvalidDatasetsCount();
}
/**
* Getter for the field validProcesses
.
*
* @return a {@link java.util.Set} object.
*/
public Set getValidProcesses() {
return validProcesses;
}
/**
* Setter for the field validProcesses
.
*
* @param validProcesses a {@link java.util.Set} object.
*/
public void setValidProcesses(Set validProcesses) {
this.validProcesses = validProcesses;
}
/**
* Getter for the field validFlows
.
*
* @return a {@link java.util.Set} object.
*/
public Set getValidFlows() {
return validFlows;
}
/**
* Setter for the field validFlows
.
*
* @param validFlows a {@link java.util.Set} object.
*/
public void setValidFlows(Set validFlows) {
this.validFlows = validFlows;
}
/**
* Getter for the field validFlowProperties
.
*
* @return a {@link java.util.Set} object.
*/
public Set getValidFlowProperties() {
return validFlowProperties;
}
/**
* Setter for the field validFlowProperties
.
*
* @param validFlowProperties a {@link java.util.Set} object.
*/
public void setValidFlowProperties(Set validFlowProperties) {
this.validFlowProperties = validFlowProperties;
}
/**
* Getter for the field validUnitGroups
.
*
* @return a {@link java.util.Set} object.
*/
public Set getValidUnitGroups() {
return validUnitGroups;
}
/**
* Setter for the field validUnitGroups
.
*
* @param validUnitGroups a {@link java.util.Set} object.
*/
public void setValidUnitGroups(Set validUnitGroups) {
this.validUnitGroups = validUnitGroups;
}
/**
* Getter for the field validSources
.
*
* @return a {@link java.util.Set} object.
*/
public Set getValidSources() {
return validSources;
}
/**
* Setter for the field validSources
.
*
* @param validSources a {@link java.util.Set} object.
*/
public void setValidSources(Set validSources) {
this.validSources = validSources;
}
/**
* Getter for the field validContacts
.
*
* @return a {@link java.util.Set} object.
*/
public Set getValidContacts() {
return validContacts;
}
/**
* Setter for the field validContacts
.
*
* @param validContacts a {@link java.util.Set} object.
*/
public void setValidContacts(Set validContacts) {
this.validContacts = validContacts;
}
/**
* Getter for the field validLCIAMethods
.
*
* @return a {@link java.util.Set} object.
*/
public Set getValidLCIAMethods() {
return validLCIAMethods;
}
/**
* Setter for the field validLCIAMethods
.
*
* @param validLCIAMethods a {@link java.util.Set} object.
*/
public void setValidLCIAMethods(Set validLCIAMethods) {
this.validLCIAMethods = validLCIAMethods;
}
/**
* Getter for the field invalidProcesses
.
*
* @return a {@link java.util.Set} object.
*/
public Set getInvalidProcesses() {
return invalidProcesses;
}
/**
* Setter for the field invalidProcesses
.
*
* @param invalidProcesses a {@link java.util.Set} object.
*/
public void setInvalidProcesses(Set invalidProcesses) {
this.invalidProcesses = invalidProcesses;
}
/**
* Getter for the field invalidFlows
.
*
* @return a {@link java.util.Set} object.
*/
public Set getInvalidFlows() {
return invalidFlows;
}
/**
* Setter for the field invalidFlows
.
*
* @param invalidFlows a {@link java.util.Set} object.
*/
public void setInvalidFlows(Set invalidFlows) {
this.invalidFlows = invalidFlows;
}
/**
* Getter for the field invalidFlowProperties
.
*
* @return a {@link java.util.Set} object.
*/
public Set getInvalidFlowProperties() {
return invalidFlowProperties;
}
/**
* Setter for the field invalidFlowProperties
.
*
* @param invalidFlowProperties a {@link java.util.Set} object.
*/
public void setInvalidFlowProperties(Set invalidFlowProperties) {
this.invalidFlowProperties = invalidFlowProperties;
}
/**
* Getter for the field invalidUnitGroups
.
*
* @return a {@link java.util.Set} object.
*/
public Set getInvalidUnitGroups() {
return invalidUnitGroups;
}
/**
* Setter for the field invalidUnitGroups
.
*
* @param invalidUnitGroups a {@link java.util.Set} object.
*/
public void setInvalidUnitGroups(Set invalidUnitGroups) {
this.invalidUnitGroups = invalidUnitGroups;
}
/**
* Getter for the field invalidSources
.
*
* @return a {@link java.util.Set} object.
*/
public Set getInvalidSources() {
return invalidSources;
}
/**
* Setter for the field invalidSources
.
*
* @param invalidSources a {@link java.util.Set} object.
*/
public void setInvalidSources(Set invalidSources) {
this.invalidSources = invalidSources;
}
/**
* Getter for the field invalidContacts
.
*
* @return a {@link java.util.Set} object.
*/
public Set getInvalidContacts() {
return invalidContacts;
}
/**
* Setter for the field invalidContacts
.
*
* @param invalidContacts a {@link java.util.Set} object.
*/
public void setInvalidContacts(Set invalidContacts) {
this.invalidContacts = invalidContacts;
}
/**
* Getter for the field invalidLCIAMethods
.
*
* @return a {@link java.util.Set} object.
*/
public Set getInvalidLCIAMethods() {
return invalidLCIAMethods;
}
/**
* Setter for the field invalidLCIAMethods
.
*
* @param invalidLCIAMethods a {@link java.util.Set} object.
*/
public void setInvalidLCIAMethods(Set invalidLCIAMethods) {
this.invalidLCIAMethods = invalidLCIAMethods;
}
/**
* Getter for the field validExternalFiles
.
*
* @return a {@link java.util.Set} object.
*/
public Set getValidExternalFiles() {
return validExternalFiles;
}
/**
* Setter for the field validExternalFiles
.
*
* @param validExtFiles a {@link java.util.Set} object.
*/
public void setValidExternalFiles(Set validExtFiles) {
this.validExternalFiles = validExtFiles;
}
/**
* Getter for the field invalidExternalFiles
.
*
* @return a {@link java.util.Set} object.
*/
public Set getInvalidExternalFiles() {
return invalidExternalFiles;
}
/**
* Setter for the field invalidExternalFiles
.
*
* @param invalidExtFiles a {@link java.util.Set} object.
*/
public void setInvalidExternalFiles(Set invalidExtFiles) {
this.invalidExternalFiles = invalidExtFiles;
}
/**
* @return the validLCModels
*/
public Set getValidLCModels() {
return validLCModels;
}
/**
* @param validLCModels the validLCModels to set
*/
public void setValidLCModels(Set validLCModels) {
this.validLCModels = validLCModels;
}
/**
* @return the invalidLCModels
*/
public Set getInvalidLCModels() {
return invalidLCModels;
}
/**
* @param invalidLCModels the invalidLCModels to set
*/
public void setInvalidLCModels(Set invalidLCModels) {
this.invalidLCModels = invalidLCModels;
}
/**
* Getter for the field aspects
.
*
* @return a {@link java.lang.String} object.
*/
public String getAspects() {
return aspects;
}
/**
* Setter for the field aspects
.
*
* @param aspects a {@link java.lang.String} object.
*/
public void setAspects(String aspects) {
this.aspects = aspects;
}
}