From 5caa07bf03b4e02e5da9171678ae48dd217e3b0e Mon Sep 17 00:00:00 2001 From: Gianpaolo Coro Date: Mon, 25 Mar 2013 14:28:50 +0000 Subject: [PATCH] git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/data-analysis/EcologicalEngineExternalAlgorithms@71702 82a268e6-3cf1-43bd-a215-b396298e98cf --- .../StandardLocalExternalAlgorithm.java | 14 +++++------ .../fin/taxamatch/TaxaMatchTransducer.java | 23 +++++++++++++++---- 2 files changed, 25 insertions(+), 12 deletions(-) diff --git a/src/main/java/org/gcube/dataanalysis/StandardLocalExternalAlgorithm.java b/src/main/java/org/gcube/dataanalysis/StandardLocalExternalAlgorithm.java index 1f75cb7..18b451d 100644 --- a/src/main/java/org/gcube/dataanalysis/StandardLocalExternalAlgorithm.java +++ b/src/main/java/org/gcube/dataanalysis/StandardLocalExternalAlgorithm.java @@ -28,13 +28,13 @@ public abstract class StandardLocalExternalAlgorithm implements Transducerer { inputs.add(new PrimitiveType(Enum.class.getName(), itemsList, PrimitiveTypes.ENUMERATED, name, description, defaultvalue)); } - protected void addRemoteDatabaseInput(String name, String urlParameterName, String userParameterName, String passwordParameterName) { - inputs.add(new DatabaseType(DatabaseParameters.REMOTEDATABASERRNAME,name,"RR name")); - inputs.add(new DatabaseType(DatabaseParameters.REMOTEDATABASEURL,urlParameterName,"RR name")); - inputs.add(new DatabaseType(DatabaseParameters.REMOTEDATABASEUSERNAME,name,"RR name")); - inputs.add(new DatabaseType(DatabaseParameters.REMOTEDATABASEPASSWORD,name,"RR name")); - inputs.add(new DatabaseType(DatabaseParameters.REMOTEDATABASEDRIVER,name,"RR name")); - inputs.add(new DatabaseType(DatabaseParameters.REMOTEDATABASEDIALECT,name,"RR name")); + protected void addRemoteDatabaseInput(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,"")); } protected void addStringInput(String name, String description, String defaultvalue) { diff --git a/src/main/java/org/gcube/dataanalysis/fin/taxamatch/TaxaMatchTransducer.java b/src/main/java/org/gcube/dataanalysis/fin/taxamatch/TaxaMatchTransducer.java index 2058e9b..300945e 100644 --- a/src/main/java/org/gcube/dataanalysis/fin/taxamatch/TaxaMatchTransducer.java +++ b/src/main/java/org/gcube/dataanalysis/fin/taxamatch/TaxaMatchTransducer.java @@ -14,6 +14,10 @@ public class TaxaMatchTransducer extends StandardLocalExternalAlgorithm { static String SpeciesOperator = "ComparisonOperatorforSpecies"; static String Genus = "Genus"; static String Species = "Species"; + static String databaseParameterName = "FishBase"; + static String userParameterName = "user"; + static String passwordParameterName = "password"; + static String urlParameterName = "FishBase"; @Override public String getDescription() { @@ -38,11 +42,20 @@ public class TaxaMatchTransducer extends StandardLocalExternalAlgorithm { String databasePwd = "0b1s@d4sc13nc3"; String databaseName = "fishbase"; */ - String databaseIP = "biodiversity.db.i-marine.research-infrastructures.eu"; - String databaseUser = "postgres"; - String databasePwd = "0b1s@d4sc13nc3"; - String databaseName = "fishbase"; + String databaseJdbc = getInputParameter(urlParameterName); + int separator = databaseJdbc.lastIndexOf("/"); + if (separator<0){ + log("Bad database URL: "+databaseJdbc); + addOutputString("Number of Matches", "0"); + return; + } + String databaseIP = databaseJdbc.substring(0,separator); + String databaseName = databaseJdbc.substring(separator+1); + String databaseUser = getInputParameter(userParameterName); + String databasePwd = getInputParameter(passwordParameterName); + log("Database Parameters to use: "+databaseIP+" "+databaseName+" "+databaseUser+" "+databasePwd); + log("Computing matching for " + genus + " " + species); log("With operators: " + genusOperator + " " + speciesOperator); if ((genus == null) || (species == null)) { @@ -81,7 +94,7 @@ public class TaxaMatchTransducer extends StandardLocalExternalAlgorithm { addStringInput(Species, "Species", "morhua"); addEnumerateInput(operators.values(), GenusOperator, "Comparison Operator for Genus", "" + operators.EQUAL); addEnumerateInput(operators.values(), SpeciesOperator, "Comparison Operator for Species", "" + operators.EQUAL); -// addRemoteDatabaseInput("FishBase"); + addRemoteDatabaseInput(databaseParameterName,urlParameterName,userParameterName,passwordParameterName,"driver","dialect"); } }