git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/data-analysis/EcologicalEngineExternalAlgorithms@71571 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
07d349a8e4
commit
ee9dadc4f5
|
@ -0,0 +1,104 @@
|
|||
package org.gcube.dataanalysis;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.gcube.contentmanagement.lexicalmatcher.utils.AnalysisLogger;
|
||||
import org.gcube.dataanalysis.ecoengine.configuration.AlgorithmConfiguration;
|
||||
import org.gcube.dataanalysis.ecoengine.configuration.INFRASTRUCTURE;
|
||||
import org.gcube.dataanalysis.ecoengine.datatypes.PrimitiveType;
|
||||
import org.gcube.dataanalysis.ecoengine.datatypes.StatisticalType;
|
||||
import org.gcube.dataanalysis.ecoengine.datatypes.enumtypes.PrimitiveTypes;
|
||||
import org.gcube.dataanalysis.ecoengine.interfaces.Transducerer;
|
||||
import org.gcube.dataanalysis.ecoengine.utils.ResourceFactory;
|
||||
|
||||
public abstract class StandardLocalExternalAlgorithm implements Transducerer {
|
||||
protected AlgorithmConfiguration config;
|
||||
protected float status = 0;
|
||||
protected List<StatisticalType> inputs = new ArrayList<StatisticalType>();
|
||||
protected ResourceFactory resourceManager;
|
||||
protected LinkedHashMap<String, String> outputParameters = new LinkedHashMap<String, String>();
|
||||
|
||||
|
||||
protected void addEnumerateInput(Object itemsList, String name, String description, String defaultvalue) {
|
||||
inputs.add(new PrimitiveType(Enum.class.getName(), itemsList, PrimitiveTypes.ENUMERATED, name, description, defaultvalue));
|
||||
}
|
||||
|
||||
protected void addStringInput(String name, String description, String defaultvalue) {
|
||||
inputs.add(new PrimitiveType(String.class.getName(), null, PrimitiveTypes.STRING, name, description, defaultvalue));
|
||||
}
|
||||
|
||||
protected void addOutputString(String name, String value) {
|
||||
outputParameters.put(name, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void compute() throws Exception {
|
||||
AnalysisLogger.setLogger(config.getConfigPath() + AlgorithmConfiguration.defaultLoggerFile);
|
||||
status = 0;
|
||||
process();
|
||||
status = 100;
|
||||
}
|
||||
|
||||
protected void log(Object message){
|
||||
AnalysisLogger.getLogger().trace(message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public abstract void init() throws Exception;
|
||||
|
||||
@Override
|
||||
public abstract String getDescription();
|
||||
|
||||
@Override
|
||||
public INFRASTRUCTURE getInfrastructure() {
|
||||
return INFRASTRUCTURE.LOCAL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<StatisticalType> getInputParameters() {
|
||||
setInputParameters();
|
||||
return inputs;
|
||||
}
|
||||
|
||||
protected String getInputParameter(String paramName) {
|
||||
return config.getParam(paramName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public StatisticalType getOutput() {
|
||||
PrimitiveType p = new PrimitiveType(Map.class.getName(), PrimitiveType.stringMap2StatisticalMap(outputParameters), PrimitiveTypes.MAP, "Species Match","");
|
||||
return p;
|
||||
}
|
||||
|
||||
public String getResourceLoad() {
|
||||
if (resourceManager == null)
|
||||
resourceManager = new ResourceFactory();
|
||||
return resourceManager.getResourceLoad(1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getResources() {
|
||||
return ResourceFactory.getResources(100f);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
protected abstract void process() throws Exception;
|
||||
|
||||
@Override
|
||||
public void setConfiguration(AlgorithmConfiguration config) {
|
||||
this.config = config;
|
||||
}
|
||||
|
||||
protected abstract void setInputParameters();
|
||||
|
||||
@Override
|
||||
public abstract void shutdown();
|
||||
|
||||
}
|
|
@ -1,24 +0,0 @@
|
|||
package org.gcube.dataanalysis.fin.taxamatch;
|
||||
import org.gcube.dataanalysis.taxamatch.fin.func_Taxamatch;
|
||||
|
||||
|
||||
|
||||
public class Test {
|
||||
|
||||
public static void main(String[] args) throws Exception{
|
||||
func_Taxamatch func = new func_Taxamatch();
|
||||
|
||||
String EQUAL = "EQUAL";
|
||||
String genus = "Gadus";
|
||||
String species = "morhua";
|
||||
String ip = "biodiversity.db.i-marine.research-infrastructures.eu";
|
||||
String user = "postgres";
|
||||
String password = "0b1s@d4sc13nc3";
|
||||
String db = "fishbase";
|
||||
|
||||
String[] matches = func.func_Taxamatch(genus, species, EQUAL, EQUAL, ip, user, password, db);
|
||||
|
||||
System.out.println("Match: "+matches[0]);
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue