org.geotools.arcsde.data
Class ViewRegisteringFactoryHelper

java.lang.Object
  extended by org.geotools.arcsde.data.ViewRegisteringFactoryHelper

public class ViewRegisteringFactoryHelper
extends java.lang.Object

Utility class to help DataStoreFactories for org.geotools.data.sql.SqlDataStores register the views provided in a java.util.Map in the call to the factory's createDataStore(Map) method.

NOTE this class is a rough copy of the one in the sql-datastore unsupported module. We are incorporating it here as don't want to depend on sql-datastore. Thus, it's expected to be replaced by the original once we work out what to do with the sql-datastore module.

Due to the non hierarchical nature of a Map, it is no so easy to provide a variable number of arguments on it for the same keyword, since they're usually read from a .properties file.

This class helps to minimize the work needed to provide such a mapping of various SQL views to an in-process feature type by defining the following structure for a Map<String,String> passed to createDataStore. Example .properties file:
 <code>
      dbtype=...
      <usual datastore's parameters>...
      sqlView.1.typeName = ViewType1
      sqlView.1.sqlQuery = select gid, the_geom, table2.someField \
                           from table1, table2 \
                           where table1.gid = table2.table1_id
     
      sqlView.2.typeName = ViewType2
      sqlView.2.sqlQuery = select ...
 </code>
 
This way, this class' utility method #registerSqlViews(SqlDataStore, Map) will receive a org.geotools.data.sql.SqlDataStore and the Map of datastore factory parameters and call org.geotools.data.sql.SqlDataStore#registerView(String, String) for each pair of sqlView.N.typeName, sqlView.N.sqlQuery

Version:
$Id: ViewRegisteringFactoryHelper.java 32195 2009-01-09 19:00:35Z groldan $
Author:
Gabriel Roldan, Axios Engineering

Method Summary
static java.util.Map cleanUpViewDefinitions(java.util.Map params)
          Looks up the set of "sqlView.N.typeName" and "sqlView.N.sqlQuery" keys in params and returns a cleaned up map of typeName/query.
static net.sf.jsqlparser.statement.select.PlainSelect parseSqlQuery(java.lang.String selectStatement)
           
static void registerSqlViews(ArcSDEDataStore dataStore, java.util.Map params)
          Registers the sql views provided in params on the SqlDataStore dataStore
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

registerSqlViews

public static void registerSqlViews(ArcSDEDataStore dataStore,
                                    java.util.Map params)
                             throws java.io.IOException
Registers the sql views provided in params on the SqlDataStore dataStore

Parameters:
dataStore -
params -
Throws:
java.io.IOException

cleanUpViewDefinitions

public static java.util.Map cleanUpViewDefinitions(java.util.Map params)
Looks up the set of "sqlView.N.typeName" and "sqlView.N.sqlQuery" keys in params and returns a cleaned up map of typeName/query.

Parameters:
params -
Returns:

parseSqlQuery

public static net.sf.jsqlparser.statement.select.PlainSelect parseSqlQuery(java.lang.String selectStatement)
                                                                    throws java.io.IOException
Throws:
java.io.IOException


Copyright © 1996-2010 Geotools. All Rights Reserved.