added IOHelper to manage input and outputs of the algorithms

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/data-analysis/EcologicalEngine@76893 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Gianpaolo Coro 2013-06-07 15:45:18 +00:00
parent 6e3f7f97b4
commit ca9657079e
1 changed files with 53 additions and 0 deletions

View File

@ -0,0 +1,53 @@
package org.gcube.dataanalysis.ecoengine.utils;
import java.util.LinkedHashMap;
import java.util.List;
import org.gcube.dataanalysis.ecoengine.configuration.AlgorithmConfiguration;
import org.gcube.dataanalysis.ecoengine.datatypes.DatabaseType;
import org.gcube.dataanalysis.ecoengine.datatypes.PrimitiveType;
import org.gcube.dataanalysis.ecoengine.datatypes.StatisticalType;
import org.gcube.dataanalysis.ecoengine.datatypes.enumtypes.DatabaseParameters;
import org.gcube.dataanalysis.ecoengine.datatypes.enumtypes.PrimitiveTypes;
public class IOHelper {
protected AlgorithmConfiguration config;
public LinkedHashMap<String, String> outputParameters = new LinkedHashMap<String, String>();
public static void addEnumerateInput(List<StatisticalType> inputs,Object itemsList, String name, String description, String defaultvalue) {
inputs.add(new PrimitiveType(Enum.class.getName(), itemsList, PrimitiveTypes.ENUMERATED, name, description, defaultvalue));
}
public static void addRemoteDatabaseInput(List<StatisticalType> inputs, String runtimeResourceName, String urlParameterName, String userParameterName, String passwordParameterName, String driverParameterName, String dialectParameterName) {
inputs.add(new DatabaseType(DatabaseParameters.REMOTEDATABASERRNAME,runtimeResourceName,"RR name"));
inputs.add(new DatabaseType(DatabaseParameters.REMOTEDATABASEURL,urlParameterName,""));
inputs.add(new DatabaseType(DatabaseParameters.REMOTEDATABASEUSERNAME,userParameterName,""));
inputs.add(new DatabaseType(DatabaseParameters.REMOTEDATABASEPASSWORD,passwordParameterName,""));
inputs.add(new DatabaseType(DatabaseParameters.REMOTEDATABASEDRIVER,driverParameterName,""));
inputs.add(new DatabaseType(DatabaseParameters.REMOTEDATABASEDIALECT,dialectParameterName,""));
}
public static void addStringInput(List<StatisticalType> inputs,String name, String description, String defaultvalue) {
inputs.add(new PrimitiveType(String.class.getName(), null, PrimitiveTypes.STRING, name, description, defaultvalue));
}
public static void addIntegerInput(List<StatisticalType> inputs,String name, String description, String defaultvalue) {
inputs.add(new PrimitiveType(Integer.class.getName(), null, PrimitiveTypes.NUMBER, name,description,defaultvalue));
}
public static void addDoubleInput(List<StatisticalType> inputs,String name, String description, String defaultvalue) {
inputs.add(new PrimitiveType(Double.class.getName(), null, PrimitiveTypes.NUMBER, name,description,defaultvalue));
}
public static void addOutputString(LinkedHashMap<String, String> outputParameters, String name, String value) {
outputParameters.put(name, value);
}
public static String getInputParameter(AlgorithmConfiguration config, String paramName) {
return config.getParam(paramName);
}
}