diff --git a/data/dtd/program_description.dtd b/data/dtd/program_description.dtd index 92ed1819c06c066684cc3ae1ee02cafcc3c700b9..bd0050b229e98775d4c9ce11c7d9be40c283fcb2 100644 --- a/data/dtd/program_description.dtd +++ b/data/dtd/program_description.dtd @@ -35,7 +35,7 @@ ismandatory %boolean; #IMPLIED ishidden %boolean; #IMPLIED isexpert %boolean; #IMPLIED - type (command | code | input | output | input-directory | output-directory | int | float | string | boolean | enum | List ) #REQUIRED + type (command | code | input | output | input-directory | output-directory | int | float | string | text | boolean | enum | List ) #REQUIRED create-directory %boolean; #IMPLIED > diff --git a/projects/test/configuration/platform/platform_test.brs b/projects/test/configuration/platform/platform_test.brs index d3c7220bf200a9c288b419ac2dbb06a1eb9605be..58c7ed1c0aba644e1059b1ed2bbc988b1e38302a 100644 --- a/projects/test/configuration/platform/platform_test.brs +++ b/projects/test/configuration/platform/platform_test.brs @@ -7,5 +7,6 @@ <program id="test___cat_input_with_vdef___1.0"/> <program id="test___sleep___1.0"/> <program id="test___failure___1.0"/> + <program id="test___generic___1.0"/> </programs> </platform> diff --git a/projects/test/configuration/run_cfg/types.cfg b/projects/test/configuration/run_cfg/types.cfg index ea99815256589c3376078c75beede22efbd1f3ae..7571b94cd1962f89ea7da1aa4f81108269b847af 100644 --- a/projects/test/configuration/run_cfg/types.cfg +++ b/projects/test/configuration/run_cfg/types.cfg @@ -1,7 +1,6 @@ application.id=test -ALL=YELLOW +ALL=BLACK OTHER=WHITE -BANK=WHITE FILE=GREEN # Universal types can be connected to any type universal_types=ALL diff --git a/projects/test/configuration/server/resources.clientTree.xml b/projects/test/configuration/server/resources.clientTree.xml index 58c9590b2d7168dd26b59d83f558cefe90b3bbd4..31c86b17a8d826256f9484cfc37694255f5280cf 100644 --- a/projects/test/configuration/server/resources.clientTree.xml +++ b/projects/test/configuration/server/resources.clientTree.xml @@ -23,5 +23,6 @@ <resource name="test___cat_input_with_vdef___1.0" /> <resource name="test___sleep___1.0" /> <resource name="test___failure___1.0" /> + <resource name="test___generic___1.0" /> </type> </resourcesTree> diff --git a/projects/test/descriptions/test___generic___1.0.xml b/projects/test/descriptions/test___generic___1.0.xml new file mode 100644 index 0000000000000000000000000000000000000000..e16c2bc79b869baf3672ff4b0c5e3b94025714a3 --- /dev/null +++ b/projects/test/descriptions/test___generic___1.0.xml @@ -0,0 +1,84 @@ +<?xml version="1.0" encoding="iso-8859-1"?> +<!DOCTYPE program_description PUBLIC "-//Telecom Bretagne/DTD XML Praxis Program Description 3.0//EN" "http://perso.telecom-bretagne.eu/~bigaret/praxis/dtd/program_description.dtd"> + +<program_description export_date="2009-08-15 18:30" modification_date="2009-08-15 18:30"> + <program provider="test" name="generic" version="1.0" /> + <from desc_id="S9999" /> + <description>A generic box allowing to execute commands and custom scripts + - The input file is named 'infile'. + - An output file should be written, named 'outfile'. + - The script, if used, will be written in a file named 'script' before the command-line is executed. + +Example: a program reading the infile in python and numbering the lines + +cmdline: 'python script infile outfile' (without the quotes) +Use a script: Yes +Script (until "# end"): +import sys +print "argv: ", sys.argv +# here, sys.argv[0] is 'script' +input=sys.argv[1] +output=sys.argv[2] + +idx=0 +output=open(output, 'w') +for line in open(input): + output.write("%i: %s"%(idx, line)) + idx += 1 + +output.close() +# end + +Remarks: +- the cmdline launches python on the script file: +- the script reads its arguments from the command-line; another solution would be to hard-code the name "infile" and "outfile" in the script itself. +</description> + <parameters> + <parameter id="generic_cmd" type="string"> + <name>cmdline</name> + <description>Command-line</description> + <position>1</position> + <code>%s</code> + <vdef /> + </parameter> + <parameter id="infile" ishidden="0" type="input"> + <name>infile </name> + <description>Input data file</description> + <position>200</position> + <code /> + <types> + <type>all</type> + </types> + <vdef>infile</vdef> + </parameter> + <parameter id="outfile" ishidden="0" type="output"> + <name>outfile</name> + <description>Output data file</description> + <position>300</position> + <code /> + <types> + <type>all</type> + </types> + <vdef>outfile</vdef> + </parameter> + <parameter id="provide_script" ishidden="0" type="boolean"> + <name>Use a script? </name> + <indent>0</indent> + <description> Produce second output? </description> + <position>0</position> + <code /> + <vdef>0</vdef> + <dep/> + </parameter> + <parameter id="script" ishidden="0" type="text"> + <name>Script (put in file named: 'script')</name> + <indent>0</indent> + <description>The script to execute</description> + <position>0</position> + <code><![CDATA[cat >script<<EOF%n%s%nEOF%n]]></code> + <vdef></vdef> + <dep>(provide_script:value="1")</dep> + </parameter> + </parameters> +</program_description> + diff --git a/src/eu/telecom_bretagne/praxis/core/resource/ParameterDescription.java b/src/eu/telecom_bretagne/praxis/core/resource/ParameterDescription.java index 580dd71ba509d7bf5591e5ca4180bc6c00b7a5da..196f3a56fd32f07db0c2e7d768a1f814a8b83a14 100644 --- a/src/eu/telecom_bretagne/praxis/core/resource/ParameterDescription.java +++ b/src/eu/telecom_bretagne/praxis/core/resource/ParameterDescription.java @@ -39,7 +39,7 @@ public class ParameterDescription implements Serializable public enum ParameterType { - COMMAND, CODE, INPUT, INPUT_DIRECTORY, OUTPUT, OUTPUT_DIRECTORY, ENUM, BOOLEAN, INT, FLOAT, STRING; + COMMAND, CODE, INPUT, INPUT_DIRECTORY, OUTPUT, OUTPUT_DIRECTORY, ENUM, BOOLEAN, INT, FLOAT, STRING, TEXT; /** * Tells whether the type denotes an input parameter. @@ -751,6 +751,7 @@ public class ParameterDescription implements Serializable case OUTPUT: case OUTPUT_DIRECTORY: case STRING: + case TEXT: default: return data; } diff --git a/src/eu/telecom_bretagne/praxis/core/workflow/Parameter.java b/src/eu/telecom_bretagne/praxis/core/workflow/Parameter.java index 6010c48e964248e58a420479b7278b15b6658bae..c4f1363202aed68b0a6ac62fbc8aaa0c51c47eb4 100644 --- a/src/eu/telecom_bretagne/praxis/core/workflow/Parameter.java +++ b/src/eu/telecom_bretagne/praxis/core/workflow/Parameter.java @@ -58,7 +58,7 @@ public class Parameter implements Cloneable, PropertyChangeListener protected Program program; /** Value for the parameter, only for {@link ParameterType#INT}, - * {@link ParameterType#FLOAT}, {@link ParameterType#STRING}, + * {@link ParameterType#FLOAT}, {@link ParameterType#STRING}, {@link ParameterType#TEXT}, * and {@link ParameterType#BOOLEAN} parameters */ String data = null; @@ -120,6 +120,7 @@ public class Parameter implements Cloneable, PropertyChangeListener case FLOAT: case INT: case STRING: + case TEXT: data = xml.getChildText("data"); // TODO: check FLOAT, INT, peut-ĂȘtre pour tout le monde d'ailleurs (boolean, etc.) break; @@ -181,6 +182,7 @@ public class Parameter implements Cloneable, PropertyChangeListener data = description.getVdef().equals("")?"0":description.getVdef(); break; case STRING: + case TEXT: data = description.getVdef(); break; case ENUM: diff --git a/src/eu/telecom_bretagne/praxis/core/workflow/Program.java b/src/eu/telecom_bretagne/praxis/core/workflow/Program.java index 8f1bd6a776bff6d5174e73943d7dbff14bc10452..87a9f209f4b769cc8a99b3a1591da5f4fe9e1356 100644 --- a/src/eu/telecom_bretagne/praxis/core/workflow/Program.java +++ b/src/eu/telecom_bretagne/praxis/core/workflow/Program.java @@ -587,7 +587,8 @@ public class Program param.setItem(copied_param.getItem()); if (parameterType.equals(ParameterType.INT) || parameterType.equals(ParameterType.FLOAT) - || parameterType.equals(ParameterType.STRING) || parameterType.equals(ParameterType.BOOLEAN)) + || parameterType.equals(ParameterType.STRING) || parameterType.equals(ParameterType.TEXT) + || parameterType.equals(ParameterType.BOOLEAN)) { param.setData(copied_param.getData()); } diff --git a/src/eu/telecom_bretagne/praxis/server/execution/SimpleFormatterPlatform.java b/src/eu/telecom_bretagne/praxis/server/execution/SimpleFormatterPlatform.java index 1c843ff0aef13cadb85c7858a31b92439cd32154..1afee6620ea7190166e0b199e0bb55a91f8ffed5 100644 --- a/src/eu/telecom_bretagne/praxis/server/execution/SimpleFormatterPlatform.java +++ b/src/eu/telecom_bretagne/praxis/server/execution/SimpleFormatterPlatform.java @@ -435,6 +435,7 @@ public abstract class SimpleFormatterPlatform case INT: case FLOAT: case STRING: + case TEXT: return getCode_IntFloatString(parameter); case OUTPUT: case OUTPUT_DIRECTORY: @@ -521,6 +522,7 @@ public abstract class SimpleFormatterPlatform { assert ((param.getDescription().getType().equals(ParameterType.INT)) || (param.getDescription().getType().equals(ParameterType.STRING)) + || (param.getDescription().getType().equals(ParameterType.TEXT)) || (param.getDescription().getType().equals(ParameterType.FLOAT))); return String.format(param.getDescription().getValueTemplate(), param.getData(), param.getData()); }