View Javadoc

1   /*
2    * $Id: RdbmsQueryValidator.java,v 1.2 2005/03/10 20:19:21 mch Exp $
3    *
4    * (C) Copyright Astrogrid...
5    */
6   
7   package org.astrogrid.tableserver.jdbc;
8   
9   import org.astrogrid.dataservice.metadata.MetadataException;
10  import org.astrogrid.tableserver.metadata.TableMetaDocInterpreter;
11  import org.astrogrid.query.DefaultQueryTraverser;
12  import org.astrogrid.query.condition.ColumnReference;
13  
14  
15  /***
16   * Checks the query against the rdbms resource
17   */
18  
19  public class RdbmsQueryValidator extends DefaultQueryTraverser {
20     
21     TableMetaDocInterpreter interpreter = null;
22  
23     public RdbmsQueryValidator(TableMetaDocInterpreter reader)  {
24        this.interpreter = reader;
25     }
26     
27     /*** Assumes only one catalog at the moment, and checks against the first one */
28     public void visitScope(String[] scope) {
29        for (int i = 0; i < scope.length; i++) {
30           if (interpreter.getTable(interpreter.getCatalogs()[0], scope[i]) ==null) {
31              throw new IllegalArgumentException("Table '"+scope[i]+"' is not available in this RDBMS Resource");
32           }
33        }
34     }
35     
36     public void visitColumnReference(ColumnReference expression) {
37        try {
38           if (interpreter.getColumn(interpreter.getCatalogs()[0],expression.getTableName(), expression.getColName()) == null) {
39              throw new IllegalArgumentException(expression+" is not in RDBMS Resource and so cannot be queried");
40           }
41        } catch (MetadataException me) {
42           throw new RuntimeException(me);
43        }
44        
45     }
46     
47  }
48  
49  /*
50   $Log: RdbmsQueryValidator.java,v $
51   Revision 1.2  2005/03/10 20:19:21  mch
52   Fixed tests more metadata fixes
53  
54   Revision 1.1  2005/03/10 16:42:55  mch
55   Split fits, sql and xdb
56  
57   Revision 1.2  2005/03/10 13:49:52  mch
58   Updating metadata
59  
60   Revision 1.1.1.1  2005/02/17 18:37:35  mch
61   Initial checkin
62  
63   Revision 1.1.1.1  2005/02/16 17:11:24  mch
64   Initial checkin
65  
66   Revision 1.1.2.3  2005/01/24 12:14:28  mch
67   Fixes to VizieR proxy and resource stuff
68  
69   Revision 1.1.2.2  2004/12/10 12:37:13  mch
70   Cone searches to look in metadata, lots of metadata interpreterrs
71  
72   Revision 1.1.2.1  2004/12/08 18:36:40  mch
73   Added Vizier, rationalised SqlWriters etc, separated out TableResults from QueryResults
74  
75   Revision 1.1.2.2  2004/12/07 21:21:09  mch
76   Fixes after a days integration testing
77  
78   Revision 1.1.2.1  2004/12/05 19:38:37  mch
79   changed skynode to 'raw' soap (from axis) and bug fixes
80  
81  
82   */
83  
84  
85  
86