1
2
3
4
5
6
7
8
9
10
11
12
13
14 package org.astrogrid.applications.commandline.dft;
15
16 import org.apache.commons.logging.Log;
17 import org.apache.commons.logging.LogFactory;
18
19 import org.astrogrid.applications.beans.v1.parameters.ParameterValue;
20 import org.astrogrid.applications.commandline.CommandLineApplication;
21 import org.astrogrid.applications.commandline.CommandLineApplicationEnvironment;
22 import org.astrogrid.applications.commandline.CommandLineParameterDescription;
23 import org.astrogrid.applications.commandline.DefaultCommandLineParameterAdapter;
24 import org.astrogrid.applications.commandline.MergingParameterAdapter;
25 import org.astrogrid.applications.commandline.MergingParameterAdapter.Concentrator;
26 import org.astrogrid.applications.description.ApplicationInterface;
27 import org.astrogrid.applications.description.ParameterDescription;
28 import org.astrogrid.applications.parameter.ParameterAdapter;
29 import org.astrogrid.applications.parameter.protocol.ExternalValue;
30 import org.astrogrid.applications.parameter.protocol.ProtocolLibrary;
31 import org.astrogrid.workflow.beans.v1.Tool;
32
33 import java.util.ArrayList;
34 import java.util.Iterator;
35 import java.util.List;
36
37 /***
38 * @author Paul Harrison (pah@jb.man.ac.uk)
39 * @version $Name: $
40 * @since iteration4.1
41 * @TODO should not really need this class - better to build adding standard
42 * parameters to the interface definition so that the standard commandline
43 * application could deal with it
44 */
45 public class Dft extends CommandLineApplication {
46 /***
47 * Logger for this class
48 */
49 private static final Log logger = LogFactory.getLog(Dft.class);
50
51
52
53
54 private final Concentrator matchConcentrator = new MergingParameterAdapter.Concentrator(
55 " ");
56
57 private final Concentrator targetConcentrator = new MergingParameterAdapter.Concentrator(
58 ",");
59
60 /***
61 * Construct a new Dft
62 *
63 * @param id
64 * @param jobStepId
65 * @param user
66 * @param description
67 */
68 public Dft(String id, String jobStepId, Tool tool,
69 ApplicationInterface interf, CommandLineApplicationEnvironment env,
70 ProtocolLibrary lib) {
71 super(jobStepId, tool, interf, env, lib);
72 }
73
74
75
76
77
78
79 protected void preRunHook() {
80 argvals.add("output=VOTable");
81 argvals.add("maxMatches=1");
82
83 }
84
85 protected ParameterAdapter instantiateAdapter(ParameterValue pval,
86 ParameterDescription desr, ExternalValue indirectVal) {
87
88 if (desr.getName().equals("matches")) {
89 if (logger.isDebugEnabled()) {
90 logger.debug("creating merging adapter for parameter matches");
91 }
92
93 return new MergingParameterAdapter(getApplicationInterface(), pval,
94 (CommandLineParameterDescription)desr, indirectVal,
95 applicationEnvironment, matchConcentrator);
96 }
97 else if (desr.getName().equals("targets"))
98 {
99 if (logger.isDebugEnabled()) {
100 logger.debug("creating merging adapter for parameter targets");
101 }
102
103 return new MergingParameterAdapter(getApplicationInterface(), pval,
104 (CommandLineParameterDescription)desr, indirectVal,
105 applicationEnvironment, targetConcentrator);
106
107 }
108 else {
109 return super.instantiateAdapter(pval, desr, indirectVal);
110 }
111 }
112 }