View Javadoc

1   /*$Id: EgsoQuerierPlugin.java,v 1.2 2005/03/10 15:13:48 mch Exp $
2    * Created on 13-Nov-2003
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.impl.sec;
12  
13  import java.io.IOException;
14  import java.net.MalformedURLException;
15  import java.net.URL;
16  import java.rmi.RemoteException;
17  import java.security.Principal;
18  import javax.xml.parsers.ParserConfigurationException;
19  import javax.xml.rpc.ServiceException;
20  import org.astrogrid.dataservice.impl.sec.SEC_Port;
21  import org.astrogrid.dataservice.impl.sec.SEC_Service;
22  import org.astrogrid.dataservice.impl.sec.SEC_ServiceLocator;
23  import org.astrogrid.dataservice.queriers.DefaultPlugin;
24  import org.astrogrid.dataservice.queriers.Querier;
25  import org.astrogrid.dataservice.queriers.QuerierPluginException;
26  import org.astrogrid.dataservice.queriers.VotableDomResults;
27  import org.astrogrid.tableserver.jdbc.StdSqlMaker;
28  import org.astrogrid.dataservice.queriers.status.QuerierQuerying;
29  import org.astrogrid.query.Query;
30  import org.xml.sax.SAXException;
31  
32  /*** Datacenter querier that performs queries against SEC webservice.
33   * @author Kevin Benson kmb@mssl.ucl.ac.uk
34   * @author mch
35   */
36  public class EgsoQuerierPlugin extends DefaultPlugin {
37     
38     public final static String SEC_URL = "http://radiosun.ts.astro.it/sec/sec_server.php";
39   
40     /*** WSDL-generated binding to the service */
41     protected SEC_Port secPort;
42     
43     public EgsoQuerierPlugin() throws ServiceException, MalformedURLException {
44        SEC_Service service = new SEC_ServiceLocator();
45        secPort = service.getSECPort(new URL(SEC_URL));
46     }
47     
48     /*** Called by the querier plugin mechanism to do the query.
49      * The EGSO service takes an SQL string and returns a VOTable.
50      */
51     public void askQuery(Principal user, Query query, Querier querier) throws IOException {
52  
53        //convert query to SQL
54        StdSqlMaker ssm = new StdSqlMaker();
55        
56        String sql = ssm.makeSql(query);
57  
58        querier.setStatus(new QuerierQuerying(querier.getStatus(), sql));
59        
60        try {
61           //call SEC - results come back as a complete String
62           String resultsVot = secPort.sql(sql);
63           VotableDomResults results = new VotableDomResults(querier, resultsVot);
64           if (!aborted) {
65              results.send(query.getResultsDef(), querier.getUser());
66           }
67        }
68        catch (RemoteException e) {
69           throw new QuerierPluginException(e+" from PAL to EGSO, Submitting '"+sql+"' to EGSO service at "+SEC_URL,e);
70        }
71        catch (SAXException e) {
72           throw new QuerierPluginException(e+" parsing results from submitting '"+sql+"' to EGSO service at "+SEC_URL,e);
73        }
74        catch (ParserConfigurationException e) {
75           throw new QuerierPluginException(e+", Server Configuration Error",e);
76        }
77     }
78     
79     /*** Returns just the number of matches rather than the list of matches */
80     public long getCount(Principal user, Query query, Querier querier) throws IOException {
81        //convert query to SQL
82        StdSqlMaker ssm = new StdSqlMaker();
83        String sql = ssm.makeCountSql(query);
84  
85        querier.setStatus(new QuerierQuerying(querier.getStatus(), sql));
86  
87        try {
88           //call SEC - results come back as a complete String
89           String resultsVot = secPort.sql(sql);
90           VotableDomResults results = new VotableDomResults(querier, resultsVot);
91           if (!aborted) {
92              throw new UnsupportedOperationException("Not done yet");
93           }
94           return -1;
95        }
96        catch (RemoteException e) {
97           throw new QuerierPluginException(e+" from PAL to EGSO, Submitting '"+sql+"' to EGSO service at "+SEC_URL,e);
98        }
99        catch (SAXException e) {
100          throw new QuerierPluginException(e+" parsing results from submitting '"+sql+"' to EGSO service at "+SEC_URL,e);
101       }
102       catch (ParserConfigurationException e) {
103          throw new QuerierPluginException(e+", Server Configuration Error",e);
104       }
105    }
106    
107    /*** Returns the formats that this plugin can provide.  Asks the results class; override in subclasse if nec */
108    public String[] getFormats() {
109       return VotableDomResults.listFormats();
110    }
111    
112    
113    
114 }
115 
116 
117 /*
118  $Log: EgsoQuerierPlugin.java,v $
119  Revision 1.2  2005/03/10 15:13:48  mch
120  Seperating out fits, table and xdb servers
121 
122  Revision 1.1.1.1  2005/02/17 18:37:34  mch
123  Initial checkin
124 
125  Revision 1.1.1.1  2005/02/16 17:11:24  mch
126  Initial checkin
127 
128  Revision 1.5.2.3  2004/12/08 18:36:40  mch
129  Added Vizier, rationalised SqlWriters etc, separated out TableResults from QueryResults
130 
131  Revision 1.5.2.2  2004/11/24 20:59:37  mch
132  doc fixes and added slinger browser
133 
134  Revision 1.5.2.1  2004/11/22 00:57:16  mch
135  New interfaces for SIAP etc and new slinger package
136 
137  Revision 1.5  2004/11/12 13:49:12  mch
138  Fix where keyword maker might not have had keywords made
139 
140  Revision 1.4  2004/11/03 00:17:56  mch
141  PAL_MCH Candidate 2 merge
142 
143  Revision 1.3.6.1  2004/10/27 00:43:39  mch
144  Started adding getCount, some resource fixes, some jsps
145 
146  Revision 1.3  2004/10/18 13:11:30  mch
147  Lumpy Merge
148 
149  Revision 1.2.2.1  2004/10/15 19:59:05  mch
150  Lots of changes during trip to CDS to improve int test pass rate
151 
152  Revision 1.2  2004/10/07 10:34:44  mch
153  Fixes to Cone maker functions and reading/writing String comparisons from Query
154 
155  Revision 1.1  2004/10/05 16:10:43  mch
156  Merged with PAL
157 
158  Revision 1.5  2004/09/29 13:39:01  mch
159  Removed obsolete ADQL 0.5
160 
161  Revision 1.4  2004/09/07 00:54:20  mch
162  Tidied up Querier/Plugin/Results, and removed deprecated SPI-visitor-SQL-translator
163 
164  Revision 1.3  2004/09/06 21:36:15  mch
165  Factored out VotableResults
166 
167  Revision 1.2  2004/07/07 14:32:54  KevinBenson
168  Few small changes because I had it referencing "cds" at the moment.
169 
170  Revision 1.1  2004/07/07 09:17:40  KevinBenson
171  New SEC/EGSO proxy to query there web service on the Solar Event Catalog
172 
173  Revision 1.2  2004/03/14 04:14:20  mch
174  Wrapped output target in TargetIndicator
175 
176  Revision 1.1  2004/03/13 23:40:59  mch
177  Changes to adapt to It05 refactor
178 
179  Revision 1.6  2003/12/09 16:25:08  nw
180  wrote plugin documentation
181 
182  Revision 1.5  2003/12/01 16:50:11  nw
183  first working tested version
184 
185  Revision 1.4  2003/11/28 19:12:16  nw
186  getting there..
187 
188  Revision 1.3  2003/11/25 11:14:51  nw
189  upgraded to new service interface
190 
191  Revision 1.2  2003/11/20 15:47:18  nw
192  improved testing
193 
194  Revision 1.1  2003/11/18 11:23:49  nw
195  mavenized cds delegate
196 
197  Revision 1.1  2003/11/18 11:10:05  nw
198  mavenized cds delegate
199  
200  */