View Javadoc

1   /*
2    * $Id: AdqlQueryMaker.java,v 1.8 2004/11/09 17:42:22 mch Exp $
3    *
4    * (C) Copyright Astrogrid...
5    */
6   
7   package org.astrogrid.datacenter.query;
8   
9   import java.io.IOException;
10  import java.io.InputStream;
11  import javax.xml.parsers.ParserConfigurationException;
12  import org.apache.axis.encoding.Serializer;
13  import org.astrogrid.slinger.targets.TargetIndicator;
14  import org.astrogrid.util.DomHelper;
15  import org.w3c.dom.Element;
16  import org.xml.sax.SAXException;
17  
18  /***
19   * Convenience routines for making a Query from an ADQL document, string or SOAP-generated model
20   * <p>
21   *
22   * @author M Hill
23   */
24  
25  
26  public class AdqlQueryMaker  {
27  
28     /*** Constructs a Query from the given ADQL (0.7.4) OM which is generated from the
29      * SkyNode (0.7.4) WSDL
30      */
31     public static Query makeQuery(net.ivoa.www.xml.ADQL.v0_7_4.SelectType adql) {
32        
33  //    Serializer s = net.ivoa.www.xml.ADQL.v0_7_4.SelectType.getSerializer();
34  //    s.serialize();
35        Adql074Parser maker = new Adql074Parser();
36        return maker.makeQuery(adql);
37     }
38  
39     
40     /*** Constructs a Query from the given ADQL DOM.  */
41     public static Query makeQuery(Element adql) throws QueryException {
42        
43        return AdqlXml074Parser.makeQuery(adql);
44     }
45  
46     /*** Convenience routine - creates a Query (object model) from the given ADQL string.
47      */
48     public static Query makeQuery(String adql) throws QueryException, SAXException, IOException, ParserConfigurationException {
49        return makeQuery(DomHelper.newDocument(adql).getDocumentElement());
50     }
51  
52     /*** Convenience routine - Constructs query from given inputstream
53      */
54     public static Query makeQuery(InputStream in) throws QueryException, IOException, SAXException, ParserConfigurationException {
55        return makeQuery(DomHelper.newDocument(in).getDocumentElement());
56     }
57  
58     public static Query makeQuery(String adql, TargetIndicator target, String format) throws QueryException, SAXException, IOException, ParserConfigurationException {
59        Query query = makeQuery(adql);
60        query.getResultsDef().setTarget(target);
61        query.getResultsDef().setFormat(format);
62        return query;
63     }
64  
65     /*** Constructs query from given inputstream
66      */
67     public static Query makeQuery(InputStream in, TargetIndicator target, String format) throws QueryException, IOException, SAXException, ParserConfigurationException {
68        Query query = makeQuery(in);
69        query.getResultsDef().setTarget(target);
70        query.getResultsDef().setFormat(format);
71        return query;
72     }
73    
74     public static Query makeQuery(Element adql, TargetIndicator target, String format) throws QueryException {
75        Query query = makeQuery(adql);
76        query.getResultsDef().setTarget(target);
77        query.getResultsDef().setFormat(format);
78        return query;
79     }
80     
81     
82  }
83  /*
84   $Log: AdqlQueryMaker.java,v $
85   Revision 1.8  2004/11/09 17:42:22  mch
86   Fixes to tests after fixes for demos, incl adding closable to targetIndicators
87  
88   Revision 1.7  2004/11/03 05:14:33  mch
89   Bringing Vizier back online
90  
91   Revision 1.6  2004/10/18 13:11:30  mch
92   Lumpy Merge
93  
94   Revision 1.5.2.1  2004/10/15 19:59:05  mch
95   Lots of changes during trip to CDS to improve int test pass rate
96  
97   Revision 1.5  2004/10/13 01:25:46  mch
98   makes ADQL/sql rather than std sql (leave in CIRCLE)
99  
100  Revision 1.4  2004/10/12 22:46:42  mch
101  Introduced typed function arguments
102 
103  Revision 1.3  2004/10/08 09:40:52  mch
104  Started proper ADQL parsing
105 
106  Revision 1.2  2004/10/07 10:34:44  mch
107  Fixes to Cone maker functions and reading/writing String comparisons from Query
108 
109  Revision 1.1  2004/10/06 21:12:16  mch
110  Big Lump of changes to pass Query OM around instead of Query subclasses, and TargetIndicator mixed into Slinger
111 
112 
113  */
114 
115 
116