1
2
3
4
5
6
7
8
9
10
11 package org.astrogrid.applications.http.script;
12
13 import java.util.Enumeration;
14
15 import org.astrogrid.applications.beans.v1.SimpleParameter;
16 import org.astrogrid.applications.beans.v1.WebHttpCall;
17 import org.astrogrid.applications.beans.v1.parameters.ParameterValue;
18 import org.astrogrid.registry.beans.cea.CeaHttpApplicationType;
19 import org.astrogrid.workflow.beans.v1.Input;
20 import org.astrogrid.workflow.beans.v1.Tool;
21
22 /***
23 * A default preprocessor that simply programatically changes the format from Tool and CeaHttpApplicationType to WebHttpCall
24 * without any actual processing. Should be deprecated by the default version of XSLTPreprocessor, if I can
25 * get it working.
26 * @author jdt
27 */
28 public final class IdentityPreprocessor implements Preprocessor {
29
30
31
32
33 public WebHttpCall process(final Tool tool, final CeaHttpApplicationType app) {
34 final WebHttpCall webCall = new WebHttpCall();
35 webCall.setURL(app.getCeaHttpAdapterSetup().getURL());
36 final Input inputs = tool.getInput();
37 final Enumeration enum = inputs.enumerateParameter();
38
39 while (enum.hasMoreElements()) {
40 final ParameterValue parameter = (ParameterValue) enum.nextElement();
41 final SimpleParameter simpleParameter = new ConstructableSimpleParameter(parameter);
42 webCall.addSimpleParameter(simpleParameter);
43 }
44
45 return webCall;
46 }
47
48 /***
49 * Just another SimpleParameter (which is generated) with an extra constructor
50 * @author jdt
51 */
52 private static class ConstructableSimpleParameter extends SimpleParameter {
53 public ConstructableSimpleParameter(ParameterValue parameter) {
54 this.setName(parameter.getName().trim());
55 this.setValue(parameter.getValue().trim());
56 }
57 }
58
59 }