Gianpaolo Coro 2013-03-19 11:34:50 +00:00
parent 44bbd09bc9
commit f51d727c04
5 changed files with 155 additions and 6 deletions

View File

@ -1,7 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src/main/java"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
<classpathentry kind="src" output="target/classes" path="src/main/java"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER"/>
<classpathentry kind="lib" path="/rapidminder-custom/TaxamatchPostgresv1.1.jar"/>
<classpathentry kind="output" path="target/classes"/>
</classpath>

View File

@ -0,0 +1,4 @@
#Tue Mar 19 10:56:09 CET 2013
eclipse.preferences.version=1
encoding//src/main/java=UTF-8
encoding/<project>=UTF-8

View File

@ -1,13 +1,13 @@
#Tue Mar 19 10:38:38 CET 2013
#Tue Mar 19 10:56:09 CET 2013
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.5
org.eclipse.jdt.core.compiler.compliance=1.6
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
org.eclipse.jdt.core.compiler.source=1.5
org.eclipse.jdt.core.compiler.source=1.6

View File

@ -0,0 +1,120 @@
package org.gcube.dataanalysis.fin.taxamatch;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
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.transducers.OccurrencePointsInSeaOnEarth.inseasonearth;
import org.gcube.dataanalysis.ecoengine.utils.ResourceFactory;
import org.gcube.dataanalysis.taxamatch.fin.func_Taxamatch;
public class TaxaMatchTransducer implements Transducerer{
public static enum operators {EQUAL, NOT_EQUAL,CONTAINS,BEGINS_WITH,ENDS_WITH};
static String GenusOperator = "Comparison Operator for Genus";
static String SpeciesOperator = "Comparison Operator for Species";
static String Genus = "Genus";
static String Species = "Species";
protected AlgorithmConfiguration config;
protected float status = 0;
LinkedHashMap<String, String> count = new LinkedHashMap<String, String>();
@Override
public String getDescription() {
return "An algorithm for Taxa Matching with respect to the Fishbase database";
}
@Override
public INFRASTRUCTURE getInfrastructure() {
return INFRASTRUCTURE.LOCAL;
}
@Override
public List<StatisticalType> getInputParameters() {
PrimitiveType genus = new PrimitiveType(String.class.getName(), null, PrimitiveTypes.STRING, Genus,"Genus", "Gadus");
PrimitiveType genusComp = new PrimitiveType(Enum.class.getName(), inseasonearth.values(), PrimitiveTypes.ENUMERATED, GenusOperator, "Comparison Operator for Genus",""+operators.EQUAL);
PrimitiveType species = new PrimitiveType(String.class.getName(), null, PrimitiveTypes.STRING, Species,"Species", "morhua");
PrimitiveType speciesComp = new PrimitiveType(Enum.class.getName(), inseasonearth.values(), PrimitiveTypes.ENUMERATED, SpeciesOperator, "Comparison Operator for Species",""+operators.EQUAL);
List<StatisticalType> inputs = new ArrayList<StatisticalType>();
inputs.add(genus);
inputs.add(species);
inputs.add(genusComp);
inputs.add(speciesComp);
return inputs;
}
@Override
public StatisticalType getOutput() {
PrimitiveType p = new PrimitiveType(Map.class.getName(), PrimitiveType.stringMap2StatisticalMap(count), PrimitiveTypes.MAP, "Species Match","");
return p;
}
ResourceFactory resourceManager;
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;
}
@Override
public void init() throws Exception {
}
@Override
public void setConfiguration(AlgorithmConfiguration config) {
this.config = config;
}
@Override
public void shutdown() {
}
@Override
public void compute() throws Exception {
String genus = config.getParam(Genus);
String species = config.getParam(Species);
String genusOperator = config.getParam(GenusOperator);
String speciesOperator = config.getParam(SpeciesOperator);
String databaseIP = "biodiversity.db.i-marine.research-infrastructures.eu";
String databaseUser = "postgres";
String databasePwd = "0b1s@d4sc13nc3";
String databaseName = "fishbase";
func_Taxamatch func = new func_Taxamatch();
String[] matches = func.func_Taxamatch(genus, species, genusOperator, speciesOperator, databaseIP, databaseUser, databasePwd, databaseName);
if ((matches==null) || (matches.length==0))
count.put("Number of Matches", "0");
else{
count.put("Number of Matches", matches[0]);
for (int i=1;i<matches.length;i++){
count.put("Match "+i, matches[i]);
}
}
}
}

View File

@ -0,0 +1,24 @@
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]);
}
}