View Javadoc

1   /*
2    * $Id: ConeConfigQueryableResource.java,v 1.5 2005/03/21 18:45:55 mch Exp $
3    *
4    * (C) Copyright Astrogrid...
5    */
6   
7   package org.astrogrid.dataservice.metadata.queryable;
8   import java.io.IOException;
9   import org.astrogrid.cfg.ConfigFactory;
10  import org.astrogrid.tableserver.metadata.TableInfo;
11  import org.astrogrid.tableserver.metadata.TableMetaDocInterpreter;
12  
13  /***
14   * An implementation of QueryableResourceReader that looks in the config file
15   * for what to search on for cones
16   */
17  
18  public class ConeConfigQueryableResource extends TableMetaDocInterpreter {
19     
20     /*** Key used to look up the column containing RA for cone searches */
21     public static final String CONE_SEARCH_TABLE_KEY = "conesearch.table";
22     public static final String CONE_SEARCH_RA_COL_KEY = "conesearch.ra.column";
23     public static final String CONE_SEARCH_DEC_COL_KEY = "conesearch.dec.column";
24  
25     /*** A temporary key specifying whether the db columns asre in degrees or radians */
26     public static final String CONE_SEARCH_COL_UNITS_KEY = "conesearch.columns.units";
27     
28     
29     public ConeConfigQueryableResource() throws IOException {
30        super();
31     }
32     
33     /*** Special case for spatial searches.  Returns the groups that contain
34      * fields suitable for spatial searching */
35     public SearchGroup[] getSpatialGroups()
36     {
37        String configTable = ConfigFactory.getCommonConfig().getString(CONE_SEARCH_TABLE_KEY);
38        SearchGroup table = new TableInfo();
39        table.setId(configTable);
40        table.setName(configTable);
41        return new SearchGroup[] { table };
42        
43     }
44     
45     /*** botch botch botch */
46     public SearchField[] getSpatialFields(SearchGroup parent) throws IOException
47     {
48        if (parent.getId().equals(ConfigFactory.getCommonConfig().getString(CONE_SEARCH_TABLE_KEY))) {
49           //get which columns given RA & DEC for cone searches
50           SearchField[] fields = {
51              getColumn(getCatalogs()[0], parent.getName(), ConfigFactory.getCommonConfig().getString(CONE_SEARCH_RA_COL_KEY)),
52              getColumn(getCatalogs()[0], parent.getName(), ConfigFactory.getCommonConfig().getString(CONE_SEARCH_DEC_COL_KEY))
53           };
54           return fields;
55        }
56        else {
57           return null;
58        }
59     }
60  }
61  
62