View Javadoc

1   /*$Id: DatacenterApplicationDescription.java,v 1.1.1.1 2005/02/17 18:37:35 mch Exp $
2    * Created on 12-Jul-2004
3    *
4    * Copyright (C) AstroGrid. All rights reserved.
5    *
6    * This software is published under the terms of the AstroGrid
7    * Software License version 1.2, a copy of which has been included
8    * with this distribution in the LICENSE.txt file.
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                  // really should not happen - as statically build.
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); // assume this is correct.
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); // probably votable.
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        //removed cone altogether for the moment, otherwise it turns up before the adql i/f on the portal
130        //UI, which at the omment can only handle one i/f
131 //        BaseApplicationInterface cone = new BaseApplicationInterface(CONE_IFACE,this);
132 //        this.addInterface(cone);
133 //        cone.addInputParameter(FORMAT);
134 //        cone.addInputParameter(RA);
135 //        cone.addInputParameter(DEC);
136 //        cone.addInputParameter(RADIUS);
137 //        cone.addOutputParameter(RESULT);
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 $Log: DatacenterApplicationDescription.java,v $
159 Revision 1.1.1.1  2005/02/17 18:37:35  mch
160 Initial checkin
161 
162 Revision 1.1.1.1  2005/02/16 17:11:24  mch
163 Initial checkin
164 
165 Revision 1.2.10.1  2004/11/22 00:57:16  mch
166 New interfaces for SIAP etc and new slinger package
167 
168 Revision 1.2  2004/11/08 02:58:44  mch
169 Various fixes and better error messages
170 
171 Revision 1.1  2004/09/28 15:02:13  mch
172 Merged PAL and server packages
173 
174 Revision 1.3  2004/09/17 01:27:21  nw
175 added thread management.
176 
177 Revision 1.2  2004/07/20 02:14:48  nw
178 final implementaiton of itn06 Datacenter CEA interface
179 
180 Revision 1.1  2004/07/13 17:11:09  nw
181 first draft of an itn06 CEA implementation for datacenter
182  
183 */