1
2
3
4
5
6
7
8
9
10
11
12
13
14 package org.astrogrid.applications.commandline.hyperz;
15
16 import org.astrogrid.applications.beans.v1.parameters.ParameterValue;
17 import org.astrogrid.applications.commandline.CommandLineApplication;
18 import org.astrogrid.applications.commandline.CommandLineApplicationEnvironment;
19 import org.astrogrid.applications.commandline.CommandLineParameterDescription;
20 import org.astrogrid.applications.description.ApplicationInterface;
21 import org.astrogrid.applications.description.ParameterDescription;
22 import org.astrogrid.applications.parameter.ParameterAdapter;
23 import org.astrogrid.applications.parameter.protocol.ExternalValue;
24 import org.astrogrid.applications.parameter.protocol.ProtocolLibrary;
25 import org.astrogrid.workflow.beans.v1.Tool;
26
27 import cds.savot.model.SavotVOTable;
28
29 /***
30 * Specialization for HyperZ. This needs to take a VOTable and convert it to suitable form for native input into hyperZ, and then create a
31 * @author Paul Harrison (pah@jb.man.ac.uk)
32 * @version $Name: $
33 * @since iteration4.1
34 * @TODO there are dependencies on the AVO DEMO setup file paths that need to be removed
35 */
36 public class HyperZ extends CommandLineApplication {
37
38 /*** Construct a new HyperZ
39 * @param id
40 * @param jobStepId
41 * @param user
42 * @param description
43 */
44 public HyperZ(String id, String jobStepId, Tool tool, ApplicationInterface description, CommandLineApplicationEnvironment env,ProtocolLibrary lib) {
45 super(jobStepId, tool,description,env,lib);
46 }
47
48 private SavotVOTable inputVOTable;
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74 protected final VOTableSourceIndirector votableSource = new VOTableSourceIndirector();
75
76 /*** specialized parameter adapter factory, that will build custom parameter adapters for the input and output files -
77 * more structured than the previous technique of hacking with pre and post- hooks.
78 * @author Noel Winstanley nw@jb.man.ac.uk 07-Jun-2004
79 * @author Paul Harrison (pah@jb.man.ac.uk)
80 *
81 */
82
83 protected ParameterAdapter instantiateAdapter( ParameterValue pval, ParameterDescription desr, ExternalValue indirectVal) {
84 if (pval.getName().equals("input_catalog")) {
85 String bands = findInputParameter("BAND_ORDER").getValue();
86 HyperZVOTableReader reader = new HyperZVOTableReader(getApplicationInterface(),pval, (CommandLineParameterDescription) desr,applicationEnvironment,indirectVal, bands);
87 votableSource.setSource(reader);
88 return reader;
89 } else if (pval.getName().equals("output_catalog")) {
90 return new HyperZVOTableWriter(getApplicationInterface(), pval,(CommandLineParameterDescription)desr,applicationEnvironment,indirectVal,votableSource);
91 } else {
92 return super.instantiateAdapter(pval,desr,indirectVal);
93 }
94 }
95
96
97
98 static class VOTableSourceIndirector implements HyperZVOTableWriter.VOTableSource {
99 public SavotVOTable getVOTable() {
100 return source.getVOTable();
101 }
102 private HyperZVOTableWriter.VOTableSource source;
103 public void setSource(HyperZVOTableWriter.VOTableSource source) {
104 this.source = source;
105 }
106 }
107
108
109
110 }