manage standard local algorithms executions

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/data-analysis/EcologicalEngine@93133 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Gianpaolo Coro 2014-03-14 13:53:37 +00:00
parent a9579a12af
commit 678a68060d
4 changed files with 34 additions and 21 deletions

View File

@ -4,6 +4,7 @@ public enum INFRASTRUCTURE {
RAINY_CLOUD,
D4SCIENCE,
LOCAL
LOCAL,
EXTERNAL_WPS
}

View File

@ -23,49 +23,55 @@ public abstract class StandardLocalExternalAlgorithm implements Transducerer {
protected List<StatisticalType> inputs = new ArrayList<StatisticalType>();
protected ResourceFactory resourceManager;
public 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 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,""));
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) {
inputs.add(new PrimitiveType(String.class.getName(), null, PrimitiveTypes.STRING, name, description, defaultvalue));
}
protected void addIntegerInput(String name, String description, String defaultvalue) {
inputs.add(new PrimitiveType(Integer.class.getName(), null, PrimitiveTypes.NUMBER, name,description,defaultvalue));
inputs.add(new PrimitiveType(Integer.class.getName(), null, PrimitiveTypes.NUMBER, name, description, defaultvalue));
}
protected void addDoubleInput(String name, String description, String defaultvalue) {
inputs.add(new PrimitiveType(Double.class.getName(), null, PrimitiveTypes.NUMBER, name,description,defaultvalue));
inputs.add(new PrimitiveType(Double.class.getName(), null, PrimitiveTypes.NUMBER, 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;
try {
process();
} catch (Exception e) {
e.printStackTrace();
AnalysisLogger.getLogger().debug("StandardLocalExternalAlgorithm->Error in processing");
throw e;
} finally {
status = 100;
}
}
protected void log(Object message){
protected void log(Object message) {
AnalysisLogger.getLogger().debug(message);
}
@Override
public abstract void init() throws Exception;
@ -89,7 +95,7 @@ public abstract class StandardLocalExternalAlgorithm implements Transducerer {
@Override
public StatisticalType getOutput() {
PrimitiveType p = new PrimitiveType(Map.class.getName(), PrimitiveType.stringMap2StatisticalMap(outputParameters), PrimitiveTypes.MAP, "Species Match","");
PrimitiveType p = new PrimitiveType(Map.class.getName(), PrimitiveType.stringMap2StatisticalMap(outputParameters), PrimitiveTypes.MAP, "Species Match", "");
return p;
}

View File

@ -172,7 +172,10 @@ public class PeriodicityDetector {
power = MathFunctions.incrementPerc(power, (float)powers[i], counter);
counter++;
}
this.periodicityStrength=power;
if (this.periodicityStrength==-0.0)
this.periodicityStrength=0;
// reconstruct the F
double meanF = MathFunctions.mean(maxfrequencies);

View File

@ -177,7 +177,10 @@ public class DatabaseUtils {
for (int j=0;j<row.length;j++){
String preprow = row[j].replaceAll("^'", "").replaceAll("'$", "");
preprow=preprow.replace("'", ""+(char)96);
sb.append("'"+preprow+"'");
if (preprow.equalsIgnoreCase("NULL"))
sb.append(preprow);
else
sb.append("'"+preprow+"'");
if (j<row.length-1)
sb.append(",");
}