de.clusteval.run.statistics.RunStatisticCalculator.java Source code

Java tutorial

Introduction

Here is the source code for de.clusteval.run.statistics.RunStatisticCalculator.java

Source

/*******************************************************************************
 * Copyright (c) 2013 Christian Wiwie.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the GNU Public License v3.0
 * which accompanies this distribution, and is available at
 * http://www.gnu.org/licenses/gpl.html
 * 
 * Contributors:
 *     Christian Wiwie - initial API and implementation
 ******************************************************************************/
/**
 * 
 */
package de.clusteval.run.statistics;

import java.io.File;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;

import org.apache.commons.configuration.ConfigurationException;
import org.rosuda.REngine.REngineException;

import de.clusteval.cluster.paramOptimization.IncompatibleParameterOptimizationMethodException;
import de.clusteval.cluster.paramOptimization.InvalidOptimizationParameterException;
import de.clusteval.cluster.paramOptimization.UnknownParameterOptimizationMethodException;
import de.clusteval.cluster.quality.UnknownClusteringQualityMeasureException;
import de.clusteval.context.IncompatibleContextException;
import de.clusteval.context.UnknownContextException;
import de.clusteval.data.DataConfigNotFoundException;
import de.clusteval.data.DataConfigurationException;
import de.clusteval.data.dataset.DataSetConfigNotFoundException;
import de.clusteval.data.dataset.DataSetConfigurationException;
import de.clusteval.data.dataset.DataSetNotFoundException;
import de.clusteval.data.dataset.IncompatibleDataSetConfigPreprocessorException;
import de.clusteval.data.dataset.NoDataSetException;
import de.clusteval.data.dataset.format.InvalidDataSetFormatVersionException;
import de.clusteval.data.dataset.format.UnknownDataSetFormatException;
import de.clusteval.data.dataset.type.UnknownDataSetTypeException;
import de.clusteval.data.distance.UnknownDistanceMeasureException;
import de.clusteval.data.goldstandard.GoldStandardConfigNotFoundException;
import de.clusteval.data.goldstandard.GoldStandardConfigurationException;
import de.clusteval.data.goldstandard.GoldStandardNotFoundException;
import de.clusteval.data.goldstandard.format.UnknownGoldStandardFormatException;
import de.clusteval.data.preprocessing.UnknownDataPreprocessorException;
import de.clusteval.data.statistics.IncompatibleDataConfigDataStatisticException;
import de.clusteval.data.statistics.UnknownDataStatisticException;
import de.clusteval.framework.repository.InvalidRepositoryException;
import de.clusteval.framework.repository.NoRepositoryFoundException;
import de.clusteval.framework.repository.RegisterException;
import de.clusteval.framework.repository.Repository;
import de.clusteval.framework.repository.RepositoryAlreadyExistsException;
import de.clusteval.framework.repository.config.RepositoryConfigNotFoundException;
import de.clusteval.framework.repository.config.RepositoryConfigurationException;
import de.clusteval.program.NoOptimizableProgramParameterException;
import de.clusteval.program.UnknownParameterType;
import de.clusteval.program.UnknownProgramParameterException;
import de.clusteval.program.UnknownProgramTypeException;
import de.clusteval.program.r.UnknownRProgramException;
import de.clusteval.run.InvalidRunModeException;
import de.clusteval.run.RunException;
import de.clusteval.run.result.AnalysisRunResultException;
import de.clusteval.run.result.RunResultParseException;
import de.clusteval.run.result.format.UnknownRunResultFormatException;
import de.clusteval.utils.InternalAttributeException;
import de.clusteval.utils.InvalidConfigurationFileException;
import de.clusteval.utils.RNotAvailableException;
import de.clusteval.utils.StatisticCalculator;

/**
 * @author Christian Wiwie
 * @param <T>
 * 
 */
public abstract class RunStatisticCalculator<T extends RunStatistic> extends StatisticCalculator<T> {

    protected String uniqueRunIdentifiers;

    /**
     * @param repository
     * @param changeDate
     * @param absPath
     * @param uniqueRunIdentifiers
     * @throws RegisterException
     */
    public RunStatisticCalculator(Repository repository, long changeDate, File absPath,
            final String uniqueRunIdentifiers) throws RegisterException {
        super(repository, changeDate, absPath);
        this.uniqueRunIdentifiers = uniqueRunIdentifiers;
    }

    /**
     * The copy constructor of run statistic calculators.
     * 
     * @param other
     *            The object to clone.
     * @throws RegisterException
     */
    public RunStatisticCalculator(final RunStatisticCalculator<T> other) throws RegisterException {
        super(other);

        this.uniqueRunIdentifiers = other.uniqueRunIdentifiers + "";
    }

    /*
     * (non-Javadoc)
     * 
     * @see utils.StatisticCalculator#clone()
     */
    @SuppressWarnings("unchecked")
    @Override
    public RunStatisticCalculator<T> clone() {
        try {
            return this.getClass().getConstructor(RunStatisticCalculator.class).newInstance(this);
        } catch (IllegalArgumentException e) {
            e.printStackTrace();
        } catch (SecurityException e) {
            e.printStackTrace();
        } catch (InstantiationException e) {
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        } catch (InvocationTargetException e) {
            e.printStackTrace();
        } catch (NoSuchMethodException e) {
            e.printStackTrace();
        }
        this.log.warn("Cloning instance of class " + this.getClass().getSimpleName() + " failed");
        return null;
    }

    /*
     * (non-Javadoc)
     * 
     * @see utils.StatisticCalculator#calculate()
     */
    @Override
    public T calculate() throws IncompatibleDataConfigDataStatisticException, UnknownGoldStandardFormatException,
            UnknownDataSetFormatException, IllegalArgumentException, IOException,
            InvalidDataSetFormatVersionException, ConfigurationException, GoldStandardConfigurationException,
            DataSetConfigurationException, DataSetNotFoundException, DataSetConfigNotFoundException,
            GoldStandardConfigNotFoundException, DataConfigurationException, DataConfigNotFoundException,
            UnknownRunResultFormatException, UnknownClusteringQualityMeasureException, InvalidRunModeException,
            UnknownParameterOptimizationMethodException, NoOptimizableProgramParameterException,
            UnknownProgramParameterException, InternalAttributeException, InvalidConfigurationFileException,
            RepositoryAlreadyExistsException, InvalidRepositoryException, NoRepositoryFoundException,
            GoldStandardNotFoundException, InvalidOptimizationParameterException, RunException,
            UnknownDataStatisticException, UnknownProgramTypeException, UnknownRProgramException,
            IncompatibleParameterOptimizationMethodException, UnknownDistanceMeasureException,
            UnknownRunStatisticException, AnalysisRunResultException, RepositoryConfigNotFoundException,
            RepositoryConfigurationException, RepositoryConfigNotFoundException, RepositoryConfigurationException,
            RegisterException, UnknownDataSetTypeException, NoDataSetException, UnknownRunDataStatisticException,
            RunResultParseException, UnknownDataPreprocessorException,
            IncompatibleDataSetConfigPreprocessorException, IncompatibleContextException, UnknownContextException,
            RNotAvailableException, REngineException, UnknownParameterType, InterruptedException {
        return super.calculate();
    }

    /*
     * (non-Javadoc)
     * 
     * @see utils.StatisticCalculator#calculateResult()
     */
    @Override
    protected abstract T calculateResult() throws IncompatibleDataConfigDataStatisticException,
            UnknownGoldStandardFormatException, UnknownDataSetFormatException, IllegalArgumentException,
            IOException, InvalidDataSetFormatVersionException, ConfigurationException,
            GoldStandardConfigurationException, DataSetConfigurationException, DataSetNotFoundException,
            DataSetConfigNotFoundException, GoldStandardConfigNotFoundException, DataConfigurationException,
            DataConfigNotFoundException, UnknownRunResultFormatException, UnknownClusteringQualityMeasureException,
            InvalidRunModeException, UnknownParameterOptimizationMethodException,
            NoOptimizableProgramParameterException, UnknownProgramParameterException, InternalAttributeException,
            InvalidConfigurationFileException, RepositoryAlreadyExistsException, InvalidRepositoryException,
            NoRepositoryFoundException, GoldStandardNotFoundException, InvalidOptimizationParameterException,
            RunException, UnknownDataStatisticException, UnknownProgramTypeException, UnknownRProgramException,
            IncompatibleParameterOptimizationMethodException, UnknownDistanceMeasureException,
            UnknownRunStatisticException, AnalysisRunResultException, RepositoryConfigNotFoundException,
            RepositoryConfigurationException, RepositoryConfigNotFoundException, RepositoryConfigurationException,
            RegisterException, UnknownDataSetTypeException, NoDataSetException, UnknownRunDataStatisticException,
            RunResultParseException, UnknownDataPreprocessorException,
            IncompatibleDataSetConfigPreprocessorException, UnknownContextException, IncompatibleContextException,
            RNotAvailableException, REngineException, UnknownParameterType, InterruptedException;

    /*
     * (non-Javadoc)
     * 
     * @see utils.StatisticCalculator#getStatistic()
     */
    @Override
    public abstract T getStatistic();
}