1
2
3
4
5
6
7
8
9
10
11 package org.astrogrid.dataservice.service.cea;
12
13 import EDU.oswego.cs.dl.util.concurrent.Executor;
14 import org.apache.commons.logging.Log;
15 import org.apache.commons.logging.LogFactory;
16 import org.astrogrid.applications.Application;
17 import org.astrogrid.applications.DefaultIDs;
18 import org.astrogrid.applications.beans.v1.parameters.types.ParameterTypes;
19 import org.astrogrid.applications.description.ApplicationInterface;
20 import org.astrogrid.applications.description.base.AbstractApplicationDescription;
21 import org.astrogrid.applications.description.base.ApplicationDescriptionEnvironment;
22 import org.astrogrid.applications.description.base.BaseApplicationInterface;
23 import org.astrogrid.applications.description.base.BaseParameterDescription;
24 import org.astrogrid.applications.description.exception.ParameterDescriptionNotFoundException;
25 import org.astrogrid.community.User;
26 import org.astrogrid.dataservice.service.DataServer;
27 import org.astrogrid.workflow.beans.v1.Tool;
28
29 /*** Descrption object for the datacenter 'application'.
30 * Supports two interfaces - a cone search interface, and a full ADQL.
31 * @author Noel Winstanley nw@jb.man.ac.uk 12-Jul-2004
32 *
33 */
34 public class DatacenterApplicationDescription extends AbstractApplicationDescription {
35 /*** name of the cone search interface */
36 public static final String CONE_IFACE = "cone";
37 /*** name of the adql search interface */
38 public static final String ADQL_IFACE = "adql";
39 /*** name of the 'ra' parameter */
40 public static final String RA = "RA";
41 /*** name of the 'dec' parameter */
42 public static final String DEC = "DEC";
43 /*** name of the 'radius' parameter */
44 public static final String RADIUS = "Radius";
45 /*** name of the 'result' output parameter */
46 public static final String RESULT = "Result";
47 /*** name of the 'query' parameter */
48 public static final String QUERY = "Query";
49 /*** name of the 'format' parameter */
50 public static final String FORMAT = "Format";
51 /***
52 * Commons Logger for this class
53 */
54 private static final Log logger = LogFactory.getLog(DatacenterApplicationDescription.class);
55
56 /*** Construct a new DatacenterApplicationDescription
57 * @param arg0
58 */
59 public DatacenterApplicationDescription(String name,DataServer ds,ApplicationDescriptionEnvironment arg0, Executor exec) {
60 super(arg0);
61 this.ds = ds;
62 this.exec = exec;
63 try {
64 this.createMetadata(name);
65 }
66 catch (ParameterDescriptionNotFoundException e) {
67
68 logger.fatal("Programming error",e);
69 throw new RuntimeException("Programming error",e);
70 }
71
72 }
73
74 /*** adds self-description bits to the application description
75 *@todo get an astronomer-type to check over this metadata, verify it is sensible, etc.
76 */
77 protected final void createMetadata(String name) throws ParameterDescriptionNotFoundException {
78 this.setName(name);
79 BaseParameterDescription query = new BaseParameterDescription();
80 query.setDisplayDescription("Astronomy Data Query Language that defines the search criteria");
81 query.setDisplayName(QUERY);
82 query.setName(QUERY);
83 query.setType(ParameterTypes.ADQL);
84 this.addParameterDescription(query);
85
86
87 BaseParameterDescription ra = new BaseParameterDescription();
88 ra.setDisplayDescription("Right-Ascension of cone");
89 ra.setDisplayName(RA);
90 ra.setName(RA);
91 ra.setType(ParameterTypes.RA);
92 this.addParameterDescription(ra);
93
94 BaseParameterDescription dec = new BaseParameterDescription();
95 dec.setDisplayDescription("Declination of cone");
96 dec.setDisplayName(DEC);
97 dec.setName(DEC);
98 dec.setType(ParameterTypes.DEC);
99 this.addParameterDescription(dec);
100
101 BaseParameterDescription radius = new BaseParameterDescription();
102 radius.setDisplayDescription("Radius of cone");
103 radius.setDisplayName(RADIUS);
104 radius.setName(RADIUS);
105 radius.setType(ParameterTypes.DOUBLE);
106 this.addParameterDescription(radius);
107
108 BaseParameterDescription format = new BaseParameterDescription();
109 format.setDisplayDescription("How the results are to be returned. VOTABLE or CSV for now");
110 format.setDisplayName(FORMAT);
111 format.setName(FORMAT);
112 format.setDefaultValue("VOTABLE");
113 format.setType(ParameterTypes.TEXT);
114 this.addParameterDescription(format);
115
116 BaseParameterDescription result = new BaseParameterDescription();
117 result.setDisplayDescription("Query results");
118 result.setDisplayName(RESULT);
119 result.setName(RESULT);
120 result.setType(ParameterTypes.TEXT);
121 this.addParameterDescription(result);
122
123 BaseApplicationInterface adql = new BaseApplicationInterface(ADQL_IFACE,this);
124 this.addInterface(adql);
125 adql.addInputParameter(FORMAT);
126 adql.addInputParameter(QUERY);
127 adql.addOutputParameter(RESULT);
128
129
130
131
132
133
134
135
136
137
138
139 }
140
141 protected final DataServer ds;
142 protected final Executor exec;
143 /***
144 * @see org.astrogrid.applications.description.ApplicationDescription#initializeApplication(java.lang.String, org.astrogrid.community.User, org.astrogrid.workflow.beans.v1.Tool)
145 */
146 public Application initializeApplication(String id, User user, Tool tool) throws Exception {
147 String newID = env.getIdGen().getNewID();
148 logger.debug("Initializing new datacenter application " + newID + " " + id);
149 final DefaultIDs ids = new DefaultIDs(id,newID, user);
150 ApplicationInterface interf = this.getInterface(tool.getInterface());
151 return new DatacenterApplication(ids,tool,interf,env.getProtocolLib(),ds,exec);
152 }
153
154 }
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183