# HG changeset patch # User Tim Englich # Date 1252051890 0 # Node ID 5a583cff97eade3c825d8d414117811d5cb026e6 # Parent d8ff739b9f3b19cf7170b541bd04a3e69fa26a8c Implementation of the Datainfrastructure for fetching Data from different DataStores. geo-backend/trunk@12 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r d8ff739b9f3b -r 5a583cff97ea geo-backend/Changelog --- a/geo-backend/Changelog Wed Sep 02 15:28:51 2009 +0000 +++ b/geo-backend/Changelog Fri Sep 04 08:11:30 2009 +0000 @@ -1,3 +1,49 @@ +2009-09-04 Tim Englich + + * src/test/java/de/intevation/gnv/geobackend/sde/datasources/ArcSDEConnectionPoolTestCase.java: Edited + Changed Tabs against 4 Spaces. Commennts written + + * src/main/java/de/intevation/gnv/geobackend/base/connectionpool/ConnectionPoolFactory.java: Edited, + src/main/java/de/intevation/gnv/geobackend/base/connectionpool/ConnectionPool.java: Edited + + Changed Tabs against 4 Spaces + + * src/test/ressources/QueryExecutorTestCase.properties: + Create a Testpropertiesfile with Samplestatements for the Testcase QueryExecutorTestCase. + + * src/main/java/de/intevation/gnv/geobackend/sde/datasources/SDEResultSet.java: Edited: + The Method getResultSetMetaData modified to return an Instance of the ArcSDEResultSetMetaData-Class + + * src/main/java/de/intevation/gnv/geobackend/sde/datasources/ArcSDEResultSetMetaData.java: + Implementation of the java.sql.ResultSetMetaData Interface for wrapping the Metainformations of an + ArcSDE-ResultSet + + * src/test/java/de/intevation/gnv/geobackend/base/query/QueryExecutorTestCase.java: Testfall + Testcase for the Inteface QueryExecuor implemented. This Testcats should test the fundamental Functions of the + Impelmentation of this interface. currently the DefaulQueryExecutor is used to fetch Resukts from the MEDIAN.MESH + Table from BSH. + + * src/main/java/de/intevation/gnv/geobackend/base/query/container/exception/QueryContainerException.java, + src/main/java/de/intevation/gnv/geobackend/base/query/container/QueryContainerFactory.java, + src/main/java/de/intevation/gnv/geobackend/base/query/container/DefaultQueryContainer.java: + src/main/java/de/intevation/gnv/geobackend/base/query/container/QueryContainer.java, + Container for central providing of configured Datastorequeries. + An instance can be instantiated using the factory. + + * src/main/java/de/intevation/gnv/geobackend/base/query/QueryExecutorFactory.java, + src/main/java/de/intevation/gnv/geobackend/base/query/QueryExecutorBase.java, + src/main/java/de/intevation/gnv/geobackend/base/query/DefaultQueryExceutor.java, + src/main/java/de/intevation/gnv/geobackend/base/query/QueryExecutor.java: + Implementation of an Infrastructure for querying Datastores. + An Instance can be instantiated using the factory. + + * src/main/java/de/intevation/gnv/geobackend/base/query/exception/QueryException.java, + src/main/java/de/intevation/gnv/geobackend/base/DefaultResult.java, + src/main/java/de/intevation/gnv/geobackend/base/DefaultResultDescriptor.java, + src/main/java/de/intevation/gnv/geobackend/base/ResultDescriptor.java, + src/main/java/de/intevation/gnv/geobackend/base/Result.java: + Implementation of an Containerinfrastrucure for storing of ResultSets of Querys + 2009-09-02 Tim Englich * geo-backend/trunk/Changelog diff -r d8ff739b9f3b -r 5a583cff97ea geo-backend/src/main/java/de/intevation/gnv/geobackend/base/DefaultResult.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/geo-backend/src/main/java/de/intevation/gnv/geobackend/base/DefaultResult.java Fri Sep 04 08:11:30 2009 +0000 @@ -0,0 +1,92 @@ +/** + * + */ +package de.intevation.gnv.geobackend.base; + +import java.util.Date; +import java.util.HashMap; + +/** + * Defaultimplementation of the Interface Result. + * This Class stores the Attributevalues of one Result. + * @author Tim Englich + * + */ +public class DefaultResult implements Result { + + /** + * HashMap which stores the Columnvalues identified by the unique Columnname + */ + private HashMap columnValues = new HashMap(); + + + /** + * The ResultDescriptor which describes the ColumnValues + */ + private ResultDescriptor resultDescriptor = null; + + /** + * Constructor + */ + public DefaultResult(ResultDescriptor resultDescriptor) { + super(); + this.resultDescriptor = resultDescriptor; + } + + /** + * @see de.intevation.gnv.geobackend.base.Result#getDate(java.lang.String) + */ + public Date getDate(String columnName) { + return (Date)this.columnValues.get(columnName); + } + + /** + * @see de.intevation.gnv.geobackend.base.Result#getDouble(java.lang.String) + */ + public Double getDouble(String columnName) { + return (Double)this.columnValues.get(columnName); + } + + /** + * @see de.intevation.gnv.geobackend.base.Result#getFloat(java.lang.String) + */ + public Float getFloat(String columnName) { + return (Float)this.columnValues.get(columnName); + } + + /** + * @see de.intevation.gnv.geobackend.base.Result#getInteger(java.lang.String) + */ + public Integer getInteger(String columnName) { + return (Integer)this.columnValues.get(columnName); + } + + /** + * @see de.intevation.gnv.geobackend.base.Result#getResultDescriptor() + */ + public ResultDescriptor getResultDescriptor() { + return this.resultDescriptor; + } + + /** + * @see de.intevation.gnv.geobackend.base.Result#getString(java.lang.String) + */ + public String getString(String columnName) { + return this.columnValues.get(columnName).toString(); + } + + /** + * @see de.intevation.gnv.geobackend.base.Result#addColumnValue(java.lang.String, java.lang.Object) + */ + public void addColumnValue(String columnName, Object value) { + this.columnValues.put(columnName, value); + } + + /** + * @see de.intevation.gnv.geobackend.base.Result#getObject(java.lang.String) + */ + public Object getObject(String columnName) { + return this.columnValues.get(columnName); + } + +} diff -r d8ff739b9f3b -r 5a583cff97ea geo-backend/src/main/java/de/intevation/gnv/geobackend/base/DefaultResultDescriptor.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/geo-backend/src/main/java/de/intevation/gnv/geobackend/base/DefaultResultDescriptor.java Fri Sep 04 08:11:30 2009 +0000 @@ -0,0 +1,65 @@ +/** + * + */ +package de.intevation.gnv.geobackend.base; + +import java.util.ArrayList; +import java.util.List; + +/** + * This Class is the DefaultImplementation of the + * Interface ResultDescriptor + * @author Tim Englich + * + */ +public class DefaultResultDescriptor implements ResultDescriptor { + + /** + * The Names of the Columns of one Result + */ + private List columnNames = new ArrayList(); + + /** + * The Name of the Classes of the Values of one Result. + */ + private List columnClassNames = new ArrayList(); + + + + /** + * Constructor + */ + public DefaultResultDescriptor() { + super(); + } + + /** + * @see de.intevation.gnv.geobackend.base.ResultDescriptor#getColumnClassName(int) + */ + public String getColumnClassName(int column) { + return this.columnClassNames.get(column); + } + + /** + * @see de.intevation.gnv.geobackend.base.ResultDescriptor#getColumnCount() + */ + public int getColumnCount() { + return this.columnClassNames.size(); + } + + /** + * @see de.intevation.gnv.geobackend.base.ResultDescriptor#getColumnName(int) + */ + public String getColumnName(int column) { + return this.columnNames.get(column); + } + + /** + * @see de.intevation.gnv.geobackend.base.ResultDescriptor#addColumn(java.lang.String, java.lang.String) + */ + public void addColumn(String name, String className) { + this.columnClassNames.add(className); + this.columnNames.add(name); + } + +} \ No newline at end of file diff -r d8ff739b9f3b -r 5a583cff97ea geo-backend/src/main/java/de/intevation/gnv/geobackend/base/Result.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/geo-backend/src/main/java/de/intevation/gnv/geobackend/base/Result.java Fri Sep 04 08:11:30 2009 +0000 @@ -0,0 +1,72 @@ +/** + * + */ +package de.intevation.gnv.geobackend.base; + +import java.util.Date; + + +/** + * Interface which provides the Methods for Accessing + * the Data of an ResultEntry + * @author Tim Englich + * + */ +public interface Result { + + /** + * Returns the ResultDescriptor which provides the + * ResultMetadatse + * @return the ResultDescriptor + */ + public ResultDescriptor getResultDescriptor(); + + /** + * Returns the Columnvalue as a String + * @param columnName the Name of the column + * @return the Columnvalue as a String + */ + public String getString(String columnName); + + /** + * Returns the Columnvalue as a Date + * @param columnName the Name of the column + * @return the Columnvalue as a Date + */ + public Date getDate(String columnName); + + /** + * Returns the Columnvalue as a Integer + * @param columnName the Name of the column + * @return the Columnvalue as a Integer + */ + public Integer getInteger(String columnName); + + /** + * Returns the Columnvalue as a Float + * @param columnName the Name of the column + * @return the Columnvalue as a Float + */ + public Float getFloat(String columnName); + + /** + * Returns the Columnvalue as a Double + * @param columnName the Name of the column + * @return the Columnvalue as a Double + */ + public Double getDouble(String columnName); + + /** + * Returns the Columnvalue as a Object + * @param columnName the Name of the column + * @return the Columnvalue as a Object + */ + public Object getObject(String columnName); + + /** + * Adds an new Coumnvalue to the Result. + * @param columnName the Name of the Column + * @param value the Value of the Column + */ + public void addColumnValue(String columnName, Object value); +} diff -r d8ff739b9f3b -r 5a583cff97ea geo-backend/src/main/java/de/intevation/gnv/geobackend/base/ResultDescriptor.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/geo-backend/src/main/java/de/intevation/gnv/geobackend/base/ResultDescriptor.java Fri Sep 04 08:11:30 2009 +0000 @@ -0,0 +1,38 @@ +/** + * + */ +package de.intevation.gnv.geobackend.base; +/** + * Interface which provides the Methods for Accessing + * the MetaData of an ResultEntry + * @author Tim Englich + */ +public interface ResultDescriptor { + + /** + * Returns the Classname of the Column + * @param column the id of the Column which is requested + * @return the Classname of the Column + */ + public String getColumnClassName(int column); + + /** + * Returns the Number of Columns + * @return the Number of Columns + */ + public int getColumnCount(); + + /** + * Returns the Name of the Column which belongs to the given Columnindex + * @param column the Index of the Column + * @return the Name of the Column + */ + public String getColumnName(int column); + + /** + * Adds a new ColumnDescription into the Descriptor + * @param name the Name of the Column (unique) + * @param className the Name of the Class (e.g. Double, Integer + */ + public void addColumn(String name, String className); +} diff -r d8ff739b9f3b -r 5a583cff97ea geo-backend/src/main/java/de/intevation/gnv/geobackend/base/connectionpool/ConnectionPool.java --- a/geo-backend/src/main/java/de/intevation/gnv/geobackend/base/connectionpool/ConnectionPool.java Wed Sep 02 15:28:51 2009 +0000 +++ b/geo-backend/src/main/java/de/intevation/gnv/geobackend/base/connectionpool/ConnectionPool.java Fri Sep 04 08:11:30 2009 +0000 @@ -10,26 +10,26 @@ * @author Tim Englich */ public interface ConnectionPool { - - /** - * Delivers the Connection to the Database - * @param connectionID the ID of the Connection - * @return the Connection to the Database - * @throws ConnectionException - */ - public Connection getConnection(String connectionID) throws ConnectionException; - - /** - * Returns the Connection to the Pool - * @param connection the Connection which should be returned to the Pool - * @throws ConnectionException - */ - public void closeConnection(Connection connection) throws ConnectionException; - - /** - * Initializes the ConnectionPool - * @param properties The Properties which should be used for initializing theConnectionPool - */ - public void initialize(Properties properties); + + /** + * Delivers the Connection to the Database + * @param connectionID the ID of the Connection + * @return the Connection to the Database + * @throws ConnectionException + */ + public Connection getConnection(String connectionID) throws ConnectionException; + + /** + * Returns the Connection to the Pool + * @param connection the Connection which should be returned to the Pool + * @throws ConnectionException + */ + public void closeConnection(Connection connection) throws ConnectionException; + + /** + * Initializes the ConnectionPool + * @param properties The Properties which should be used for initializing theConnectionPool + */ + public void initialize(Properties properties); } diff -r d8ff739b9f3b -r 5a583cff97ea geo-backend/src/main/java/de/intevation/gnv/geobackend/base/connectionpool/ConnectionPoolFactory.java --- a/geo-backend/src/main/java/de/intevation/gnv/geobackend/base/connectionpool/ConnectionPoolFactory.java Wed Sep 02 15:28:51 2009 +0000 +++ b/geo-backend/src/main/java/de/intevation/gnv/geobackend/base/connectionpool/ConnectionPoolFactory.java Fri Sep 04 08:11:30 2009 +0000 @@ -16,73 +16,70 @@ */ public class ConnectionPoolFactory { - - /** + /** * the logger, used to log exceptions and additonaly information */ private static Logger log = Logger.getLogger(ConnectionPoolFactory.class); - + /** * The singleton Instance of this Factory. */ - private static ConnectionPoolFactory instance = null; - - /** - * The ConnectionPool providing the Connections to the DatabaseBackends - */ - private ConnectionPool connectionPool = null; - - /** - * Basic-Constructor of this Class - */ - private ConnectionPoolFactory() { - super(); - } - - - /** - * This Method provides an singleton Instance of this Class. - * @return an singleton Instance of this Class - */ - public static ConnectionPoolFactory getInstance(){ - if (instance == null){ - instance = new ConnectionPoolFactory(); - } - return instance; - } - - - /** - * Getting the ConnectionPool - * @return the ConnectionPool - */ - public ConnectionPool getConnectionPool(){ - return this.connectionPool; - } - - - /** - * Initializes the ConnectionPool. - * Should only be called once on system startup - * @param properties the Properties for the Individual Configuration of the ConnectionPool - */ - public void initializeConnectionPool(Properties properties){ - log.debug("ConnectionPoolFactory.initializeConnectionPool"); - if (this.connectionPool == null){ - //TODO: Hier könnte anhand eines Flags die Instanz des Connectionpools umgeschaltet werden. - this.connectionPool = new ArcSDEConnectionPool(); - this.connectionPool.initialize(properties); - }else{ - log.warn("ConnectionPool already initialized"); - } - } - - /** - * Checks if the ConnectionPool has already been initialized. - * @return true if the ConnectionPool is initialized. - */ - public boolean isInitialized(){ - return this.connectionPool != null; - } + private static ConnectionPoolFactory instance = null; + + /** + * The ConnectionPool providing the Connections to the DatabaseBackends + */ + private ConnectionPool connectionPool = null; + + /** + * Basic-Constructor of this Class + */ + private ConnectionPoolFactory() { + super(); + } + + /** + * This Method provides an singleton Instance of this Class. + * @return an singleton Instance of this Class + */ + public static ConnectionPoolFactory getInstance(){ + if (instance == null){ + instance = new ConnectionPoolFactory(); + } + return instance; + } + + + /** + * Getting the ConnectionPool + * @return the ConnectionPool + */ + public ConnectionPool getConnectionPool(){ + return this.connectionPool; + } + + /** + * Initializes the ConnectionPool. + * Should only be called once on system startup + * @param properties the Properties for the Individual Configuration of the ConnectionPool + */ + public void initializeConnectionPool(Properties properties){ + log.debug("ConnectionPoolFactory.initializeConnectionPool"); + if (this.connectionPool == null){ + //TODO: Hier könnte anhand eines Flags die Instanz des Connectionpools umgeschaltet werden. + this.connectionPool = new ArcSDEConnectionPool(); + this.connectionPool.initialize(properties); + }else{ + log.warn("ConnectionPool already initialized"); + } + } + + /** + * Checks if the ConnectionPool has already been initialized. + * @return true if the ConnectionPool is initialized. + */ + public boolean isInitialized(){ + return this.connectionPool != null; + } } diff -r d8ff739b9f3b -r 5a583cff97ea geo-backend/src/main/java/de/intevation/gnv/geobackend/base/query/DefaultQueryExceutor.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/geo-backend/src/main/java/de/intevation/gnv/geobackend/base/query/DefaultQueryExceutor.java Fri Sep 04 08:11:30 2009 +0000 @@ -0,0 +1,103 @@ +/** + * + */ +package de.intevation.gnv.geobackend.base.query; + +import java.sql.Connection; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Statement; +import java.util.Collection; + +import org.apache.log4j.Logger; + +import de.intevation.gnv.geobackend.base.Result; +import de.intevation.gnv.geobackend.base.connectionpool.ConnectionPool; +import de.intevation.gnv.geobackend.base.connectionpool.ConnectionPoolFactory; +import de.intevation.gnv.geobackend.base.connectionpool.exception.ConnectionException; +import de.intevation.gnv.geobackend.base.query.container.QueryContainerFactory; +import de.intevation.gnv.geobackend.base.query.container.exception.QueryContainerException; +import de.intevation.gnv.geobackend.base.query.exception.QueryException; + +/** + * This is an Standard Implementation of the Interface QueryExecutor. + * It fetchs the Query from the Querycontainer an put the Filtervalues into the Query. + * @author Tim Englich + * + */ +public class DefaultQueryExceutor extends QueryExecutorBase{ + + + /** + * the logger, used to log exceptions and additonaly information + */ + private static Logger log = Logger.getLogger(DefaultQueryExceutor.class); + + /** + * The ConnectionID identifing the Connection to use executing the Query. + */ + private String connectionID = "N/N"; + + /** + * Constructor + */ + public DefaultQueryExceutor() { + super(); + } + + /** + * @see de.intevation.gnv.geobackend.base.query.QueryExecutor#executeQuery(java.lang.String, java.lang.String[]) + */ + public Collection executeQuery(String queryID, String[] filter) throws QueryException { + Collection returnValue = null; + try { + String queryString = QueryContainerFactory.getInstance().getQueryContainer().getQuery(queryID); + if (queryString != null){ + if (filter != null && filter.length > 0){ + //Insert the Filtervalues into the QueryString + queryString = super.setFilterValues(queryString, filter); + } + + Connection connection = null; + ConnectionPool connectionPool = ConnectionPoolFactory.getInstance().getConnectionPool(); + try { + // Submit the Query + connection = connectionPool.getConnection(this.connectionID); + if (connection != null){ + Statement stmt = connection.createStatement(); + ResultSet rs = stmt.executeQuery(queryString); + returnValue = super.createResultCollection(rs); + + }else{ + log.error("Could not establish Databaseconnection."); + throw new QueryException("Could not establish Databaseconnection."); + } + + } catch (ConnectionException e) { + log.error(e,e); + throw new QueryException("Could not establish Databaseconnection.",e); + } catch (SQLException e) { + log.error(e,e); + throw new QueryException(e); + }finally{ + if (connection != null){ + try { + connectionPool.closeConnection(connection); + } catch (ConnectionException e) { + log.error("Connection could not be returned to ConnectionPool."); + log.error(e,e); + } + } + } + }else{ + log.error("No QueryString defined for "+queryID); + throw new QueryException("Cannot get the Querystring"); + } + + } catch (QueryContainerException e) { + log.error(e,e); + throw new QueryException("Cannot get the Querystring",e); + } + return returnValue; + } +} diff -r d8ff739b9f3b -r 5a583cff97ea geo-backend/src/main/java/de/intevation/gnv/geobackend/base/query/QueryExecutor.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/geo-backend/src/main/java/de/intevation/gnv/geobackend/base/query/QueryExecutor.java Fri Sep 04 08:11:30 2009 +0000 @@ -0,0 +1,29 @@ +/** + * + */ +package de.intevation.gnv.geobackend.base.query; + +import java.util.Collection; + +import de.intevation.gnv.geobackend.base.Result; +import de.intevation.gnv.geobackend.base.query.exception.QueryException; + +/** + * This Interface provides the Method to execute Queries + * against a Datastore eg. Databases + * @author Tim Englich + * + */ +public interface QueryExecutor { + + + /** + * This Method executes the Query an returns the Result + * in an Collection. + * @param queryID the ID of the Query which should be used. + * @param filter the Filterarguments to limit the Data + * @return the fetched Values + * @throws QueryException + */ + public Collection executeQuery(String queryID, String[] filter) throws QueryException; +} diff -r d8ff739b9f3b -r 5a583cff97ea geo-backend/src/main/java/de/intevation/gnv/geobackend/base/query/QueryExecutorBase.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/geo-backend/src/main/java/de/intevation/gnv/geobackend/base/query/QueryExecutorBase.java Fri Sep 04 08:11:30 2009 +0000 @@ -0,0 +1,97 @@ +/** + * + */ +package de.intevation.gnv.geobackend.base.query; + +import java.sql.ResultSet; +import java.sql.ResultSetMetaData; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + +import de.intevation.gnv.geobackend.base.DefaultResult; +import de.intevation.gnv.geobackend.base.DefaultResultDescriptor; +import de.intevation.gnv.geobackend.base.Result; +import de.intevation.gnv.geobackend.base.ResultDescriptor; + +/** + * This is an abstract Basicimplementation of the Interface + * QueryExecutor providing several Helpermethods. + * @author Tim Englich + * + */ +public abstract class QueryExecutorBase implements QueryExecutor { + + /** + * Constructor + */ + public QueryExecutorBase() { + super(); + } + + /** + * This Method puts the Filtervalues into the Querystring + * @param queryString the Query which should be manipulated + * @param filter the values which should be put into the Query + * @return the manipulated Query + */ + protected String setFilterValues(String queryString, String[] filter){ + String returnValue = queryString; + for (int i = 0; i < filter.length; i++){ + returnValue = returnValue.replaceFirst("?", filter[i]); + } + return returnValue; + } + + /** + * This Methods converts the ResultSet into an Collection of Result-objects + * @param resultSet the ResultSet which should be converted + * @return an Collection containing Result-Objects + * @throws SQLException + */ + protected Collection createResultCollection(ResultSet resultSet) throws SQLException{ + Collection returnValue = new ArrayList(); + + ResultDescriptor resultDescriptor = null; + int columns = -1; + List columnNames = null; + while (resultSet.next()){ + if (resultDescriptor == null){ + resultDescriptor = new DefaultResultDescriptor(); + ResultSetMetaData rsmd = resultSet.getMetaData(); + columns = rsmd.getColumnCount(); + columnNames = new ArrayList(columns); + for (int i = 1; i <= columns; i++){ + resultDescriptor.addColumn(rsmd.getColumnName(i), rsmd.getColumnClassName(i)); + columnNames.add(rsmd.getColumnName(i)); + } + } + + Result result = convertResult(resultSet, resultDescriptor,columnNames); + + returnValue.add(result); + } + return returnValue; + } + + /** + * This Method converts one Singel ResultSetEntry into an Result-Object + * @param resultSet the ResultSet where the Entry should be took from. + * @param resultDescriptor the ResultsetDescriptor which describes the Entry + * @param columnNames the Name of the Columns which Values should be fetched. + * @return an new Result-Objects containing the Values of the ResultSet-Entry + * @throws SQLException + */ + private Result convertResult(ResultSet resultSet, + ResultDescriptor resultDescriptor, List columnNames) + throws SQLException { + Result result = new DefaultResult(resultDescriptor); + for (int i = 0; i < columnNames.size(); i++){ + String columnName = columnNames.get(i); + result.addColumnValue(columnName, resultSet.getObject(columnName)); + } + return result; + } + +} diff -r d8ff739b9f3b -r 5a583cff97ea geo-backend/src/main/java/de/intevation/gnv/geobackend/base/query/QueryExecutorFactory.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/geo-backend/src/main/java/de/intevation/gnv/geobackend/base/query/QueryExecutorFactory.java Fri Sep 04 08:11:30 2009 +0000 @@ -0,0 +1,51 @@ +/** + * + */ +package de.intevation.gnv.geobackend.base.query; + +import org.apache.log4j.Logger; + +/** + * @author Tim Englich + * + */ +public class QueryExecutorFactory { + + /** + * the logger, used to log exceptions and additonaly information + */ + private static Logger log = Logger.getLogger(QueryExecutorFactory.class); + + + /** + * The singleton Instance of this Factory. + */ + private static QueryExecutorFactory instance = null; + + /** + * Basic-Constructor of this Class + */ + private QueryExecutorFactory() { + super(); + } + + /** + * This Method provides an singleton Instance of this Class. + * @return an singleton Instance of this Class + */ + public static QueryExecutorFactory getInstance(){ + if (instance == null){ + instance = new QueryExecutorFactory(); + } + return instance; + } + + + /** + * Getting the QueryExecutor + * @return the QueryExecutor + */ + public QueryExecutor getQueryExecutor(){ + return new DefaultQueryExceutor(); + } +} diff -r d8ff739b9f3b -r 5a583cff97ea geo-backend/src/main/java/de/intevation/gnv/geobackend/base/query/container/DefaultQueryContainer.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/geo-backend/src/main/java/de/intevation/gnv/geobackend/base/query/container/DefaultQueryContainer.java Fri Sep 04 08:11:30 2009 +0000 @@ -0,0 +1,63 @@ +/** + * + */ +package de.intevation.gnv.geobackend.base.query.container; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Properties; + +import de.intevation.gnv.geobackend.base.query.container.exception.QueryContainerException; + +/** + * Defaultimplementation of an QueryContainer. + * All Queries are provided using a Propertiescontainer. + * @author Tim Englich + */ +public class DefaultQueryContainer implements QueryContainer { + + /** + * The Properties-Object all Queries are provided in. + */ + private Properties queries = null; + + /** + * Constructor + */ + public DefaultQueryContainer() { + super(); + } + + /** + * @see de.intevation.gnv.geobackend.base.query.container.QueryContainer#gerQueryIDs() + */ + public Collection gerQueryIDs() throws QueryContainerException { + //TODO: Typsicherheit herstellen. + Collection returnValue = null; + if (this.queries != null){ + returnValue = this.queries.keySet(); + }else{ + returnValue = new ArrayList(0); + } + return returnValue; + } + + /** + * @see de.intevation.gnv.geobackend.base.query.container.QueryContainer#getQuery(java.lang.String) + */ + public String getQuery(String queryID) throws QueryContainerException { + String returnValue = null; + if (this.queries != null){ + returnValue = this.queries.getProperty(queryID); + } + return returnValue; + } + + /** + * @see de.intevation.gnv.geobackend.base.query.container.QueryContainer#initialize(java.util.Properties) + */ + public void initialize(Properties properties) throws QueryContainerException { + this.queries = properties; + } + +} diff -r d8ff739b9f3b -r 5a583cff97ea geo-backend/src/main/java/de/intevation/gnv/geobackend/base/query/container/QueryContainer.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/geo-backend/src/main/java/de/intevation/gnv/geobackend/base/query/container/QueryContainer.java Fri Sep 04 08:11:30 2009 +0000 @@ -0,0 +1,39 @@ +/** + * + */ +package de.intevation.gnv.geobackend.base.query.container; + +import java.util.Collection; +import java.util.Properties; + +import de.intevation.gnv.geobackend.base.query.container.exception.QueryContainerException; + +/** + * @author Tim Englich + * + */ +public interface QueryContainer { + + + /** + * Returns the Query specified by the given queryID. + * @param queryID the ID which speciogies the Query which should be returned + * @return the Query + * @throws QueryContainerException + */ + public String getQuery(String queryID) throws QueryContainerException; + + /** + * Returns all QueryIDs provided by the Querycontainer + * @return ll QueryIDs provided by the Querycontainer + * @throws QueryContainerException + */ + public Collection gerQueryIDs() throws QueryContainerException;; + + /** + * Initializes the QueryContainer + * @param properties The Properties which should be used for initializing QueryContainer + * @throws QueryContainerException + */ + public void initialize(Properties properties) throws QueryContainerException; +} diff -r d8ff739b9f3b -r 5a583cff97ea geo-backend/src/main/java/de/intevation/gnv/geobackend/base/query/container/QueryContainerFactory.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/geo-backend/src/main/java/de/intevation/gnv/geobackend/base/query/container/QueryContainerFactory.java Fri Sep 04 08:11:30 2009 +0000 @@ -0,0 +1,84 @@ +/** + * + */ +package de.intevation.gnv.geobackend.base.query.container; + +import java.util.Properties; + +import org.apache.log4j.Logger; + +import de.intevation.gnv.geobackend.base.query.container.exception.QueryContainerException; + +/** + * @author Tim Englich + * + */ +public class QueryContainerFactory { + + /** + * the logger, used to log exceptions and additonaly information + */ + private static Logger log = Logger.getLogger(QueryContainerFactory.class); + + + /** + * The singleton Instance of this Factory. + */ + private static QueryContainerFactory instance = null; + + /** + * The ConnectionPool providing the Connections to the DatabaseBackends + */ + private QueryContainer queryContainer = null; + + /** + * Basic-Constructor of this Class + */ + private QueryContainerFactory() { + super(); + } + + /** + * This Method provides an singleton Instance of this Class. + * @return an singleton Instance of this Class + */ + public static QueryContainerFactory getInstance(){ + if (instance == null){ + instance = new QueryContainerFactory(); + } + return instance; + } + + + /** + * Getting the QueryContainer + * @return the QueryContainer + */ + public QueryContainer getQueryContainer(){ + return this.queryContainer; + } + + /** + * Initializes the QueryContainer. + * Should only be called once on system startup + * @param properties the Properties for the Individual Configuration of the QueryContainerbb + * @throws QueryContainerException + */ + public synchronized void initializeQueryContainer(Properties properties) throws QueryContainerException{ + log.debug("ConnectionPoolFactory.initializeConnectionPool"); + if (this.queryContainer == null){ + this.queryContainer = new DefaultQueryContainer(); + this.queryContainer.initialize(properties); + }else{ + log.warn("ConnectionPool already initialized"); + } + } + + /** + * Checks if the QueryContainer has already been initialized. + * @return true if the QueryContainer is initialized. + */ + public boolean isInitialized(){ + return this.queryContainer != null; + } +} diff -r d8ff739b9f3b -r 5a583cff97ea geo-backend/src/main/java/de/intevation/gnv/geobackend/base/query/container/exception/QueryContainerException.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/geo-backend/src/main/java/de/intevation/gnv/geobackend/base/query/container/exception/QueryContainerException.java Fri Sep 04 08:11:30 2009 +0000 @@ -0,0 +1,49 @@ +/** + * + */ +package de.intevation.gnv.geobackend.base.query.container.exception; +/** + * Exceptioncalls which will be used to retun Exception in + * the QuerContainer-Package. + * @author Tim Englich + * + */ +public class QueryContainerException extends Exception { + + /** + * The UID auf this Class + */ + private static final long serialVersionUID = -1811252311941938708L; + + /** + * Constructor + */ + public QueryContainerException() { + } + + /** + * Constructor + * @param arg0 + */ + public QueryContainerException(String arg0) { + super(arg0); + } + + /** + * Constructor + * @param arg0 + */ + public QueryContainerException(Throwable arg0) { + super(arg0); + } + + /** + * Constructor + * @param arg0 + * @param arg1 + */ + public QueryContainerException(String arg0, Throwable arg1) { + super(arg0, arg1); + } + +} diff -r d8ff739b9f3b -r 5a583cff97ea geo-backend/src/main/java/de/intevation/gnv/geobackend/base/query/exception/QueryException.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/geo-backend/src/main/java/de/intevation/gnv/geobackend/base/query/exception/QueryException.java Fri Sep 04 08:11:30 2009 +0000 @@ -0,0 +1,47 @@ +/** + * + */ +package de.intevation.gnv.geobackend.base.query.exception; +/** + * @author Tim Englich + * + */ +public class QueryException extends Exception { + + /** + * The UID for this Class + */ + private static final long serialVersionUID = -1337567603858112424L; + + /** + * Constructor + */ + public QueryException() { + } + + /** + * Constructor + * @param message + */ + public QueryException(String message) { + super(message); + } + + /** + * Constructor + * @param cause + */ + public QueryException(Throwable cause) { + super(cause); + } + + /** + * Constructor + * @param message + * @param cause + */ + public QueryException(String message, Throwable cause) { + super(message, cause); + } + +} diff -r d8ff739b9f3b -r 5a583cff97ea geo-backend/src/main/java/de/intevation/gnv/geobackend/sde/datasources/ArcSDEResultSetMetaData.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/geo-backend/src/main/java/de/intevation/gnv/geobackend/sde/datasources/ArcSDEResultSetMetaData.java Fri Sep 04 08:11:30 2009 +0000 @@ -0,0 +1,194 @@ +/** + * + */ +package de.intevation.gnv.geobackend.sde.datasources; + +import java.sql.ResultSetMetaData; +import java.sql.SQLException; +import java.util.List; + +/** + * @author Tim Englich + * + */ +public class ArcSDEResultSetMetaData implements ResultSetMetaData { + + private List columnDefinitions = null; + /** + * Constructor + */ + public ArcSDEResultSetMetaData(List columnDefinitions) { + this.columnDefinitions = columnDefinitions; + } + + /** + * @see java.sql.ResultSetMetaData#getCatalogName(int) + */ + public String getCatalogName(int column) throws SQLException { + + return null; + } + + /** + * @see java.sql.ResultSetMetaData#getColumnClassName(int) + */ + public String getColumnClassName(int column) throws SQLException { + + int type = this.getColumnType(column); + Class clazz = java.lang.Object.class; + if (type == 2){ + clazz = int.class; + } + // TODO weitere Klassen Implementieren + return clazz.getName(); + } + + /** + * @see java.sql.ResultSetMetaData#getColumnCount() + */ + public int getColumnCount() throws SQLException { + return columnDefinitions.size(); + } + + /** + * @see java.sql.ResultSetMetaData#getColumnDisplaySize(int) + */ + public int getColumnDisplaySize(int column) throws SQLException { + + return 0; + } + + /** + * @see java.sql.ResultSetMetaData#getColumnLabel(int) + */ + public String getColumnLabel(int column) throws SQLException { + return columnDefinitions.get(column-1).getName(); + } + + /** + * @see java.sql.ResultSetMetaData#getColumnName(int) + */ + public String getColumnName(int column) throws SQLException { + return columnDefinitions.get(column-1).getName(); + } + + /** + * @see java.sql.ResultSetMetaData#getColumnType(int) + */ + public int getColumnType(int column) throws SQLException { + return columnDefinitions.get(column-1).getType(); + } + + /** + * @see java.sql.ResultSetMetaData#getColumnTypeName(int) + */ + public String getColumnTypeName(int column) throws SQLException { + + return null; + } + + /** + * @see java.sql.ResultSetMetaData#getPrecision(int) + */ + public int getPrecision(int column) throws SQLException { + + return 0; + } + + /** + * @see java.sql.ResultSetMetaData#getScale(int) + */ + public int getScale(int column) throws SQLException { + + return 0; + } + + /** + * @see java.sql.ResultSetMetaData#getSchemaName(int) + */ + public String getSchemaName(int column) throws SQLException { + + return null; + } + + /** + * @see java.sql.ResultSetMetaData#getTableName(int) + */ + public String getTableName(int column) throws SQLException { + + return null; + } + + /** + * @see java.sql.ResultSetMetaData#isAutoIncrement(int) + */ + public boolean isAutoIncrement(int column) throws SQLException { + + return false; + } + + /** + * @see java.sql.ResultSetMetaData#isCaseSensitive(int) + */ + public boolean isCaseSensitive(int column) throws SQLException { + + return false; + } + + /** + * @see java.sql.ResultSetMetaData#isCurrency(int) + */ + public boolean isCurrency(int column) throws SQLException { + + return false; + } + + /** + * @see java.sql.ResultSetMetaData#isDefinitelyWritable(int) + */ + public boolean isDefinitelyWritable(int column) throws SQLException { + + return false; + } + + /** + * @see java.sql.ResultSetMetaData#isNullable(int) + */ + public int isNullable(int column) throws SQLException { + + return 0; + } + + /** + * @see java.sql.ResultSetMetaData#isReadOnly(int) + */ + public boolean isReadOnly(int column) throws SQLException { + + return true; + } + + /** + * @see java.sql.ResultSetMetaData#isSearchable(int) + */ + public boolean isSearchable(int column) throws SQLException { + + return true; + } + + /** + * @see java.sql.ResultSetMetaData#isSigned(int) + */ + public boolean isSigned(int column) throws SQLException { + + return false; + } + + /** + * @see java.sql.ResultSetMetaData#isWritable(int) + */ + public boolean isWritable(int column) throws SQLException { + + return false; + } + +} diff -r d8ff739b9f3b -r 5a583cff97ea geo-backend/src/main/java/de/intevation/gnv/geobackend/sde/datasources/SDEResultSet.java --- a/geo-backend/src/main/java/de/intevation/gnv/geobackend/sde/datasources/SDEResultSet.java Wed Sep 02 15:28:51 2009 +0000 +++ b/geo-backend/src/main/java/de/intevation/gnv/geobackend/sde/datasources/SDEResultSet.java Fri Sep 04 08:11:30 2009 +0000 @@ -48,1110 +48,1109 @@ * @since 21.11.2007 11:01:27 */ public class SDEResultSet extends ResultSet { - - /** - * Default Logging instance - */ - private static Logger log = Logger.getLogger(SDEResultSet.class); - - private List mRows = Collections.synchronizedList(new ArrayList()); - private List mCols = Collections.synchronizedList(new ArrayList()); - - private Row currentRow = null; - private int cursor = 0; - - public SDEResultSet() { - } - - public int getCount() { - return mRows.size(); - } - - public int getNumberOfColumns() { - return mCols.size(); - } - - public ColDefinition[] getColumnDefinitions() { - ColDefinition[] lColDefinitions = new ColDefinition[mCols.size()]; - return mCols.toArray(lColDefinitions); - } - - public Row[] getResults() { - Row[] lRows = new Row[mRows.size()]; - return mRows.toArray(lRows); - } - - public void addRow(Row pRow) { - mRows.add(pRow); - } - - public void addCol(ColDefinition pColDefinition) { - mCols.add(pColDefinition); - } - - /** - * @see java.sql.ResultSet#absolute(int) - */ - public boolean absolute(int row) throws SQLException { - - return false; - } - - /** - * @see java.sql.ResultSet#afterLast() - */ - public void afterLast() throws SQLException { - } - - /** - * @see java.sql.ResultSet#beforeFirst() - */ - public void beforeFirst() throws SQLException { - } - - /** - * @see java.sql.ResultSet#cancelRowUpdates() - */ - public void cancelRowUpdates() throws SQLException { - } - - /** - * @see java.sql.ResultSet#clearWarnings() - */ - public void clearWarnings() throws SQLException { - } - - /** - * @see java.sql.ResultSet#close() - */ - public void close() throws SQLException { - } - - /** - * @see java.sql.ResultSet#deleteRow() - */ - public void deleteRow() throws SQLException { - } - - /** - * @see java.sql.ResultSet#findColumn(java.lang.String) - */ - public int findColumn(String columnName) throws SQLException { - - return 0; - } - - /** - * @see java.sql.ResultSet#first() - */ - public boolean first() throws SQLException { - - return false; - } - - /** - * @see java.sql.ResultSet#getArray(int) - */ - public Array getArray(int i) throws SQLException { - - return null; - } - - /** - * @see java.sql.ResultSet#getArray(java.lang.String) - */ - public Array getArray(String colName) throws SQLException { - - return null; - } - - /** - * @see java.sql.ResultSet#getAsciiStream(int) - */ - public InputStream getAsciiStream(int columnIndex) throws SQLException { - - return null; - } - - /** - * @see java.sql.ResultSet#getAsciiStream(java.lang.String) - */ - public InputStream getAsciiStream(String columnName) throws SQLException { - - return null; - } - - /** - * @see java.sql.ResultSet#getBigDecimal(int) - */ - public BigDecimal getBigDecimal(int columnIndex) throws SQLException { - - return null; - } - - /** - * @see java.sql.ResultSet#getBigDecimal(java.lang.String) - */ - public BigDecimal getBigDecimal(String columnName) throws SQLException { - - return null; - } - - /** - * @see java.sql.ResultSet#getBigDecimal(int, int) - */ - public BigDecimal getBigDecimal(int columnIndex, int scale) - throws SQLException { - - return null; - } - - /** - * @see java.sql.ResultSet#getBigDecimal(java.lang.String, int) - */ - public BigDecimal getBigDecimal(String columnName, int scale) - throws SQLException { - - return null; - } - - /** - * @see java.sql.ResultSet#getBinaryStream(int) - */ - public InputStream getBinaryStream(int columnIndex) throws SQLException { - - return null; - } - - /** - * @see java.sql.ResultSet#getBinaryStream(java.lang.String) - */ - public InputStream getBinaryStream(String columnName) throws SQLException { - - return null; - } - - /** - * @see java.sql.ResultSet#getBlob(int) - */ - public Blob getBlob(int i) throws SQLException { - - return null; - } - - /** - * @see java.sql.ResultSet#getBlob(java.lang.String) - */ - public Blob getBlob(String colName) throws SQLException { - - return null; - } - - /** - * @see java.sql.ResultSet#getBoolean(int) - */ - public boolean getBoolean(int columnIndex) throws SQLException { - - return false; - } - - /** - * @see java.sql.ResultSet#getBoolean(java.lang.String) - */ - public boolean getBoolean(String columnName) throws SQLException { - - return false; - } - - /** - * @see java.sql.ResultSet#getByte(int) - */ - public byte getByte(int columnIndex) throws SQLException { - - return 0; - } - - /** - * @see java.sql.ResultSet#getByte(java.lang.String) - */ - public byte getByte(String columnName) throws SQLException { - - return 0; - } - - /** - * @see java.sql.ResultSet#getBytes(int) - */ - public byte[] getBytes(int columnIndex) throws SQLException { - - return null; - } - - /** - * @see java.sql.ResultSet#getBytes(java.lang.String) - */ - public byte[] getBytes(String columnName) throws SQLException { - - return null; - } - - /** - * @see java.sql.ResultSet#getCharacterStream(int) - */ - public Reader getCharacterStream(int columnIndex) throws SQLException { - - return null; - } - - /** - * @see java.sql.ResultSet#getCharacterStream(java.lang.String) - */ - public Reader getCharacterStream(String columnName) throws SQLException { - - return null; - } - - /** - * @see java.sql.ResultSet#getClob(int) - */ - public Clob getClob(int i) throws SQLException { - - return null; - } - - /** - * @see java.sql.ResultSet#getClob(java.lang.String) - */ - public Clob getClob(String colName) throws SQLException { - - return null; - } - - /** - * @see java.sql.ResultSet#getConcurrency() - */ - public int getConcurrency() throws SQLException { - - return 0; - } - - /** - * @see java.sql.ResultSet#getCursorName() - */ - public String getCursorName() throws SQLException { - - return null; - } - - /** - * @see java.sql.ResultSet#getDate(int) - */ - public Date getDate(int columnIndex) throws SQLException { - try { - return new java.sql.Date(this.currentRow.getDateValue(columnIndex-1).getTime()); + + /** + * Default Logging instance + */ + private static Logger log = Logger.getLogger(SDEResultSet.class); + + private List mRows = Collections.synchronizedList(new ArrayList()); + private List mCols = Collections.synchronizedList(new ArrayList()); + + private Row currentRow = null; + private int cursor = 0; + + public SDEResultSet() { + } + + public int getCount() { + return mRows.size(); + } + + public int getNumberOfColumns() { + return mCols.size(); + } + + public ColDefinition[] getColumnDefinitions() { + ColDefinition[] lColDefinitions = new ColDefinition[mCols.size()]; + return mCols.toArray(lColDefinitions); + } + + public Row[] getResults() { + Row[] lRows = new Row[mRows.size()]; + return mRows.toArray(lRows); + } + + public void addRow(Row pRow) { + mRows.add(pRow); + } + + public void addCol(ColDefinition pColDefinition) { + mCols.add(pColDefinition); + } + + /** + * @see java.sql.ResultSet#absolute(int) + */ + public boolean absolute(int row) throws SQLException { + + return false; + } + + /** + * @see java.sql.ResultSet#afterLast() + */ + public void afterLast() throws SQLException { + } + + /** + * @see java.sql.ResultSet#beforeFirst() + */ + public void beforeFirst() throws SQLException { + } + + /** + * @see java.sql.ResultSet#cancelRowUpdates() + */ + public void cancelRowUpdates() throws SQLException { + } + + /** + * @see java.sql.ResultSet#clearWarnings() + */ + public void clearWarnings() throws SQLException { + } + + /** + * @see java.sql.ResultSet#close() + */ + public void close() throws SQLException { + } + + /** + * @see java.sql.ResultSet#deleteRow() + */ + public void deleteRow() throws SQLException { + } + + /** + * @see java.sql.ResultSet#findColumn(java.lang.String) + */ + public int findColumn(String columnName) throws SQLException { + + return 0; + } + + /** + * @see java.sql.ResultSet#first() + */ + public boolean first() throws SQLException { + + return false; + } + + /** + * @see java.sql.ResultSet#getArray(int) + */ + public Array getArray(int i) throws SQLException { + + return null; + } + + /** + * @see java.sql.ResultSet#getArray(java.lang.String) + */ + public Array getArray(String colName) throws SQLException { + + return null; + } + + /** + * @see java.sql.ResultSet#getAsciiStream(int) + */ + public InputStream getAsciiStream(int columnIndex) throws SQLException { + + return null; + } + + /** + * @see java.sql.ResultSet#getAsciiStream(java.lang.String) + */ + public InputStream getAsciiStream(String columnName) throws SQLException { + + return null; + } + + /** + * @see java.sql.ResultSet#getBigDecimal(int) + */ + public BigDecimal getBigDecimal(int columnIndex) throws SQLException { + + return null; + } + + /** + * @see java.sql.ResultSet#getBigDecimal(java.lang.String) + */ + public BigDecimal getBigDecimal(String columnName) throws SQLException { + + return null; + } + + /** + * @see java.sql.ResultSet#getBigDecimal(int, int) + */ + public BigDecimal getBigDecimal(int columnIndex, int scale) + throws SQLException { + + return null; + } + + /** + * @see java.sql.ResultSet#getBigDecimal(java.lang.String, int) + */ + public BigDecimal getBigDecimal(String columnName, int scale) + throws SQLException { + + return null; + } + + /** + * @see java.sql.ResultSet#getBinaryStream(int) + */ + public InputStream getBinaryStream(int columnIndex) throws SQLException { + + return null; + } + + /** + * @see java.sql.ResultSet#getBinaryStream(java.lang.String) + */ + public InputStream getBinaryStream(String columnName) throws SQLException { + + return null; + } + + /** + * @see java.sql.ResultSet#getBlob(int) + */ + public Blob getBlob(int i) throws SQLException { + + return null; + } + + /** + * @see java.sql.ResultSet#getBlob(java.lang.String) + */ + public Blob getBlob(String colName) throws SQLException { + + return null; + } + + /** + * @see java.sql.ResultSet#getBoolean(int) + */ + public boolean getBoolean(int columnIndex) throws SQLException { + + return false; + } + + /** + * @see java.sql.ResultSet#getBoolean(java.lang.String) + */ + public boolean getBoolean(String columnName) throws SQLException { + + return false; + } + + /** + * @see java.sql.ResultSet#getByte(int) + */ + public byte getByte(int columnIndex) throws SQLException { + + return 0; + } + + /** + * @see java.sql.ResultSet#getByte(java.lang.String) + */ + public byte getByte(String columnName) throws SQLException { + + return 0; + } + + /** + * @see java.sql.ResultSet#getBytes(int) + */ + public byte[] getBytes(int columnIndex) throws SQLException { + + return null; + } + + /** + * @see java.sql.ResultSet#getBytes(java.lang.String) + */ + public byte[] getBytes(String columnName) throws SQLException { + + return null; + } + + /** + * @see java.sql.ResultSet#getCharacterStream(int) + */ + public Reader getCharacterStream(int columnIndex) throws SQLException { + + return null; + } + + /** + * @see java.sql.ResultSet#getCharacterStream(java.lang.String) + */ + public Reader getCharacterStream(String columnName) throws SQLException { + + return null; + } + + /** + * @see java.sql.ResultSet#getClob(int) + */ + public Clob getClob(int i) throws SQLException { + + return null; + } + + /** + * @see java.sql.ResultSet#getClob(java.lang.String) + */ + public Clob getClob(String colName) throws SQLException { + + return null; + } + + /** + * @see java.sql.ResultSet#getConcurrency() + */ + public int getConcurrency() throws SQLException { + + return 0; + } + + /** + * @see java.sql.ResultSet#getCursorName() + */ + public String getCursorName() throws SQLException { + + return null; + } + + /** + * @see java.sql.ResultSet#getDate(int) + */ + public Date getDate(int columnIndex) throws SQLException { + try { + return new java.sql.Date(this.currentRow.getDateValue(columnIndex-1).getTime()); } catch (TechnicalException e) { - log.error(e,e); - throw new SQLException(e.getMessage()); - } - } - - /** - * @see java.sql.ResultSet#getDate(java.lang.String) - */ - public Date getDate(String columnName) throws SQLException { - int columnIndex = this.getColumnIndex(columnName); - return this.getDate(columnIndex); - } - - /** - * @see java.sql.ResultSet#getDate(int, java.util.Calendar) - */ - public Date getDate(int columnIndex, Calendar cal) throws SQLException { - - return null; - } - - /** - * @see java.sql.ResultSet#getDate(java.lang.String, java.util.Calendar) - */ - public Date getDate(String columnName, Calendar cal) throws SQLException { - - return null; - } - - /** - * @see java.sql.ResultSet#getDouble(int) - */ - public double getDouble(int columnIndex) throws SQLException { - try { - return this.currentRow.getDoubleValue(columnIndex-1); - } catch (TechnicalException e) { - log.error(e,e); - throw new SQLException(e.getMessage()); - } - } - - /** - * @see java.sql.ResultSet#getDouble(java.lang.String) - */ - public double getDouble(String columnName) throws SQLException { - int columnIndex = this.getColumnIndex(columnName); - return this.getDouble(columnIndex); - } - - /** - * @see java.sql.ResultSet#getFetchDirection() - */ - public int getFetchDirection() throws SQLException { - - return 0; - } - - /** - * @see java.sql.ResultSet#getFetchSize() - */ - public int getFetchSize() throws SQLException { - - return 0; - } - - /** - * @see java.sql.ResultSet#getFloat(int) - */ - public float getFloat(int columnIndex) throws SQLException { - try { - return this.currentRow.getFloatValue(columnIndex-1); - } catch (TechnicalException e) { - log.error(e,e); - throw new SQLException(e.getMessage()); - } - } - - /** - * @see java.sql.ResultSet#getFloat(java.lang.String) - */ - public float getFloat(String columnName) throws SQLException { - int columnIndex = this.getColumnIndex(columnName); - return this.getFloat(columnIndex); - } - - /** - * @see java.sql.ResultSet#getInt(int) - */ - public int getInt(int columnIndex) throws SQLException { - - try { - return this.currentRow.getIntValue(columnIndex-1); - } catch (TechnicalException e) { - log.error(e,e); - throw new SQLException(e.getMessage()); - } - } - - /** - * @see java.sql.ResultSet#getInt(java.lang.String) - */ - public int getInt(String columnName) throws SQLException { - int columnIndex = this.getColumnIndex(columnName); - return this.getInt(columnIndex); - } - - /** - * @see java.sql.ResultSet#getLong(int) - */ - public long getLong(int columnIndex) throws SQLException { - - return 0; - } - - /** - * @see java.sql.ResultSet#getLong(java.lang.String) - */ - public long getLong(String columnName) throws SQLException { - - return 0; - } - - /** - * @see java.sql.ResultSet#getMetaData() - */ - public ResultSetMetaData getMetaData() throws SQLException { - - return null; - } - - /** - * @see java.sql.ResultSet#getObject(int) - */ - public Object getObject(int columnIndex) throws SQLException { - try { - return this.currentRow.getValue(columnIndex-1); - } catch (TechnicalException e) { - log.error(e,e); - throw new SQLException(e.getMessage()); - } - } - - /** - * @see java.sql.ResultSet#getObject(java.lang.String) - */ - public Object getObject(String columnName) throws SQLException { - int columnIndex = this.getColumnIndex(columnName); - return this.getObject(columnIndex); - } - - /** - * @see java.sql.ResultSet#getObject(int, java.util.Map) - */ - public Object getObject(int i, Map> map) - throws SQLException { - - return null; - } - - /** - * @see java.sql.ResultSet#getObject(java.lang.String, java.util.Map) - */ - public Object getObject(String colName, Map> map) - throws SQLException { - - return null; - } - - /** - * @see java.sql.ResultSet#getRef(int) - */ - public Ref getRef(int i) throws SQLException { - - return null; - } - - /** - * @see java.sql.ResultSet#getRef(java.lang.String) - */ - public Ref getRef(String colName) throws SQLException { - - return null; - } - - /** - * @see java.sql.ResultSet#getRow() - */ - public int getRow() throws SQLException { - - return 0; - } - - /** - * @see java.sql.ResultSet#getShort(int) - */ - public short getShort(int columnIndex) throws SQLException { - - return 0; - } - - /** - * @see java.sql.ResultSet#getShort(java.lang.String) - */ - public short getShort(String columnName) throws SQLException { - - return 0; - } - - /** - * @see java.sql.ResultSet#getStatement() - */ - public Statement getStatement() throws SQLException { - - return null; - } - - /** - * @see java.sql.ResultSet#getString(int) - */ - public String getString(int columnIndex) throws SQLException { - - try { - return this.currentRow.getStringValue(columnIndex-1); - } catch (TechnicalException e) { - log.error(e,e); - throw new SQLException(e.getMessage()); + log.error(e,e); + throw new SQLException(e.getMessage()); } - } - - /** - * @see java.sql.ResultSet#getString(java.lang.String) - */ - public String getString(String columnName) throws SQLException { - int columnIndex = this.getColumnIndex(columnName); - return this.getString(columnIndex); - } - - /** - * @see java.sql.ResultSet#getTime(int) - */ - public Time getTime(int columnIndex) throws SQLException { - - return null; - } - - /** - * @see java.sql.ResultSet#getTime(java.lang.String) - */ - public Time getTime(String columnName) throws SQLException { - - return null; - } - - /** - * @see java.sql.ResultSet#getTime(int, java.util.Calendar) - */ - public Time getTime(int columnIndex, Calendar cal) throws SQLException { - - return null; - } - - /** - * @see java.sql.ResultSet#getTime(java.lang.String, java.util.Calendar) - */ - public Time getTime(String columnName, Calendar cal) throws SQLException { - - return null; - } - - /** - * @see java.sql.ResultSet#getTimestamp(int) - */ - public Timestamp getTimestamp(int columnIndex) throws SQLException { - - return null; - } - - /** - * @see java.sql.ResultSet#getTimestamp(java.lang.String) - */ - public Timestamp getTimestamp(String columnName) throws SQLException { - - return null; - } - - /** - * @see java.sql.ResultSet#getTimestamp(int, java.util.Calendar) - */ - public Timestamp getTimestamp(int columnIndex, Calendar cal) - throws SQLException { - - return null; - } - - /** - * @see java.sql.ResultSet#getTimestamp(java.lang.String, - * java.util.Calendar) - */ - public Timestamp getTimestamp(String columnName, Calendar cal) - throws SQLException { - - return null; - } - - /** - * @see java.sql.ResultSet#getType() - */ - public int getType() throws SQLException { - - return 0; - } - - /** - * @see java.sql.ResultSet#getURL(int) - */ - public URL getURL(int columnIndex) throws SQLException { - - return null; - } - - /** - * @see java.sql.ResultSet#getURL(java.lang.String) - */ - public URL getURL(String columnName) throws SQLException { - - return null; - } - - /** - * @see java.sql.ResultSet#getUnicodeStream(int) - */ - public InputStream getUnicodeStream(int columnIndex) throws SQLException { - - return null; - } - - /** - * @see java.sql.ResultSet#getUnicodeStream(java.lang.String) - */ - public InputStream getUnicodeStream(String columnName) throws SQLException { - - return null; - } - - /** - * @see java.sql.ResultSet#getWarnings() - */ - public SQLWarning getWarnings() throws SQLException { - - return null; - } - - /** - * @see java.sql.ResultSet#insertRow() - */ - public void insertRow() throws SQLException { - } - - /** - * @see java.sql.ResultSet#isAfterLast() - */ - public boolean isAfterLast() throws SQLException { - - return false; - } - - /** - * @see java.sql.ResultSet#isBeforeFirst() - */ - public boolean isBeforeFirst() throws SQLException { - - return false; - } - - /** - * @see java.sql.ResultSet#isFirst() - */ - public boolean isFirst() throws SQLException { - - return false; - } - - /** - * @see java.sql.ResultSet#isLast() - */ - public boolean isLast() throws SQLException { - - return false; - } - - /** - * @see java.sql.ResultSet#last() - */ - public boolean last() throws SQLException { - - return false; - } - - /** - * @see java.sql.ResultSet#moveToCurrentRow() - */ - public void moveToCurrentRow() throws SQLException { - } - - /** - * @see java.sql.ResultSet#moveToInsertRow() - */ - public void moveToInsertRow() throws SQLException { - } - - /** - * @see java.sql.ResultSet#next() - */ - public boolean next() throws SQLException { - - boolean next = this.mRows.size() > this.cursor; - if (next){ - log.debug("Zeile "+(cursor+1)+" von "+this.mRows.size()+" wird angesteuert."); - this.currentRow = this.mRows.get(this.cursor); - this.cursor++; - }else{ - this.currentRow = null; - } - return next; - } - - /** - * @see java.sql.ResultSet#previous() - */ - public boolean previous() throws SQLException { - - return false; - } - - /** - * @see java.sql.ResultSet#refreshRow() - */ - public void refreshRow() throws SQLException { - } - - /** - * @see java.sql.ResultSet#relative(int) - */ - public boolean relative(int rows) throws SQLException { - - return false; - } - - /** - * @see java.sql.ResultSet#rowDeleted() - */ - public boolean rowDeleted() throws SQLException { - - return false; - } - - /** - * @see java.sql.ResultSet#rowInserted() - */ - public boolean rowInserted() throws SQLException { - - return false; - } - - /** - * @see java.sql.ResultSet#rowUpdated() - */ - public boolean rowUpdated() throws SQLException { - - return false; - } - - /** - * @see java.sql.ResultSet#setFetchDirection(int) - */ - public void setFetchDirection(int direction) throws SQLException { - } - - /** - * @see java.sql.ResultSet#setFetchSize(int) - */ - public void setFetchSize(int rows) throws SQLException { - } - - /** - * @see java.sql.ResultSet#updateArray(int, java.sql.Array) - */ - public void updateArray(int columnIndex, Array x) throws SQLException { - } - - /** - * @see java.sql.ResultSet#updateArray(java.lang.String, java.sql.Array) - */ - public void updateArray(String columnName, Array x) throws SQLException { - } - - /** - * @see java.sql.ResultSet#updateAsciiStream(int, java.io.InputStream, int) - */ - public void updateAsciiStream(int columnIndex, InputStream x, int length) - throws SQLException { - } - - /** - * @see java.sql.ResultSet#updateAsciiStream(java.lang.String, - * java.io.InputStream, int) - */ - public void updateAsciiStream(String columnName, InputStream x, int length) - throws SQLException { - } - - /** - * @see java.sql.ResultSet#updateBigDecimal(int, java.math.BigDecimal) - */ - public void updateBigDecimal(int columnIndex, BigDecimal x) - throws SQLException { - } - - /** - * @see java.sql.ResultSet#updateBigDecimal(java.lang.String, - * java.math.BigDecimal) - */ - public void updateBigDecimal(String columnName, BigDecimal x) - throws SQLException { - } - - /** - * @see java.sql.ResultSet#updateBinaryStream(int, java.io.InputStream, int) - */ - public void updateBinaryStream(int columnIndex, InputStream x, int length) - throws SQLException { - } - - /** - * @see java.sql.ResultSet#updateBinaryStream(java.lang.String, - * java.io.InputStream, int) - */ - public void updateBinaryStream(String columnName, InputStream x, int length) - throws SQLException { - } - - /** - * @see java.sql.ResultSet#updateBlob(int, java.sql.Blob) - */ - public void updateBlob(int columnIndex, Blob x) throws SQLException { - } - - /** - * @see java.sql.ResultSet#updateBlob(java.lang.String, java.sql.Blob) - */ - public void updateBlob(String columnName, Blob x) throws SQLException { - } - - /** - * @see java.sql.ResultSet#updateBoolean(int, boolean) - */ - public void updateBoolean(int columnIndex, boolean x) throws SQLException { - } - - /** - * @see java.sql.ResultSet#updateBoolean(java.lang.String, boolean) - */ - public void updateBoolean(String columnName, boolean x) throws SQLException { - } - - /** - * @see java.sql.ResultSet#updateByte(int, byte) - */ - public void updateByte(int columnIndex, byte x) throws SQLException { - } - - /** - * @see java.sql.ResultSet#updateByte(java.lang.String, byte) - */ - public void updateByte(String columnName, byte x) throws SQLException { - } - - /** - * @see java.sql.ResultSet#updateBytes(int, byte[]) - */ - public void updateBytes(int columnIndex, byte[] x) throws SQLException { - } - - /** - * @see java.sql.ResultSet#updateBytes(java.lang.String, byte[]) - */ - public void updateBytes(String columnName, byte[] x) throws SQLException { - } - - /** - * @see java.sql.ResultSet#updateCharacterStream(int, java.io.Reader, int) - */ - public void updateCharacterStream(int columnIndex, Reader x, int length) - throws SQLException { - } - - /** - * @see java.sql.ResultSet#updateCharacterStream(java.lang.String, - * java.io.Reader, int) - */ - public void updateCharacterStream(String columnName, Reader reader, - int length) throws SQLException { - } - - /** - * @see java.sql.ResultSet#updateClob(int, java.sql.Clob) - */ - public void updateClob(int columnIndex, Clob x) throws SQLException { - } - - /** - * @see java.sql.ResultSet#updateClob(java.lang.String, java.sql.Clob) - */ - public void updateClob(String columnName, Clob x) throws SQLException { - } - - /** - * @see java.sql.ResultSet#updateDate(int, java.sql.Date) - */ - public void updateDate(int columnIndex, Date x) throws SQLException { - } - - /** - * @see java.sql.ResultSet#updateDate(java.lang.String, java.sql.Date) - */ - public void updateDate(String columnName, Date x) throws SQLException { - } - - /** - * @see java.sql.ResultSet#updateDouble(int, double) - */ - public void updateDouble(int columnIndex, double x) throws SQLException { - } - - /** - * @see java.sql.ResultSet#updateDouble(java.lang.String, double) - */ - public void updateDouble(String columnName, double x) throws SQLException { - } - - /** - * @see java.sql.ResultSet#updateFloat(int, float) - */ - public void updateFloat(int columnIndex, float x) throws SQLException { - } - - /** - * @see java.sql.ResultSet#updateFloat(java.lang.String, float) - */ - public void updateFloat(String columnName, float x) throws SQLException { - } - - /** - * @see java.sql.ResultSet#updateInt(int, int) - */ - public void updateInt(int columnIndex, int x) throws SQLException { - } - - /** - * @see java.sql.ResultSet#updateInt(java.lang.String, int) - */ - public void updateInt(String columnName, int x) throws SQLException { - } - - /** - * @see java.sql.ResultSet#updateLong(int, long) - */ - public void updateLong(int columnIndex, long x) throws SQLException { - } - - /** - * @see java.sql.ResultSet#updateLong(java.lang.String, long) - */ - public void updateLong(String columnName, long x) throws SQLException { - } - - /** - * @see java.sql.ResultSet#updateNull(int) - */ - public void updateNull(int columnIndex) throws SQLException { - } - - /** - * @see java.sql.ResultSet#updateNull(java.lang.String) - */ - public void updateNull(String columnName) throws SQLException { - } - - /** - * @see java.sql.ResultSet#updateObject(int, java.lang.Object) - */ - public void updateObject(int columnIndex, Object x) throws SQLException { - } - - /** - * @see java.sql.ResultSet#updateObject(java.lang.String, java.lang.Object) - */ - public void updateObject(String columnName, Object x) throws SQLException { - } - - /** - * @see java.sql.ResultSet#updateObject(int, java.lang.Object, int) - */ - public void updateObject(int columnIndex, Object x, int scale) - throws SQLException { - } - - /** - * @see java.sql.ResultSet#updateObject(java.lang.String, java.lang.Object, - * int) - */ - public void updateObject(String columnName, Object x, int scale) - throws SQLException { - } - - /** - * @see java.sql.ResultSet#updateRef(int, java.sql.Ref) - */ - public void updateRef(int columnIndex, Ref x) throws SQLException { - } - - /** - * @see java.sql.ResultSet#updateRef(java.lang.String, java.sql.Ref) - */ - public void updateRef(String columnName, Ref x) throws SQLException { - } - - /** - * @see java.sql.ResultSet#updateRow() - */ - public void updateRow() throws SQLException { - } - - /** - * @see java.sql.ResultSet#updateShort(int, short) - */ - public void updateShort(int columnIndex, short x) throws SQLException { - } - - /** - * @see java.sql.ResultSet#updateShort(java.lang.String, short) - */ - public void updateShort(String columnName, short x) throws SQLException { - } - - /** - * @see java.sql.ResultSet#updateString(int, java.lang.String) - */ - public void updateString(int columnIndex, String x) throws SQLException { - } - - /** - * @see java.sql.ResultSet#updateString(java.lang.String, java.lang.String) - */ - public void updateString(String columnName, String x) throws SQLException { - } - - /** - * @see java.sql.ResultSet#updateTime(int, java.sql.Time) - */ - public void updateTime(int columnIndex, Time x) throws SQLException { - } - - /** - * @see java.sql.ResultSet#updateTime(java.lang.String, java.sql.Time) - */ - public void updateTime(String columnName, Time x) throws SQLException { - } - - /** - * @see java.sql.ResultSet#updateTimestamp(int, java.sql.Timestamp) - */ - public void updateTimestamp(int columnIndex, Timestamp x) - throws SQLException { - } - - /** - * @see java.sql.ResultSet#updateTimestamp(java.lang.String, - * java.sql.Timestamp) - */ - public void updateTimestamp(String columnName, Timestamp x) - throws SQLException { - } - - /** - * @see java.sql.ResultSet#wasNull() - */ - public boolean wasNull() throws SQLException { - - return false; - } - - - private int getColumnIndex(String columnName) throws SQLException{ - //TODO: Es gibt effizentere Lösungen. Hier noch mal über HashMap nachdenken - for (int i = 0 ; i < this.mCols.size();i++){ - if(this.mCols.get(i).getName().equalsIgnoreCase(columnName)){ - return i +1; // PLUS 1 da SQL-Cursor 1 nasiert sind - } - } - throw new SQLException("Column "+columnName+" does not exist in ResulSet"); - - } + } + + /** + * @see java.sql.ResultSet#getDate(java.lang.String) + */ + public Date getDate(String columnName) throws SQLException { + int columnIndex = this.getColumnIndex(columnName); + return this.getDate(columnIndex); + } + + /** + * @see java.sql.ResultSet#getDate(int, java.util.Calendar) + */ + public Date getDate(int columnIndex, Calendar cal) throws SQLException { + + return null; + } + + /** + * @see java.sql.ResultSet#getDate(java.lang.String, java.util.Calendar) + */ + public Date getDate(String columnName, Calendar cal) throws SQLException { + + return null; + } + + /** + * @see java.sql.ResultSet#getDouble(int) + */ + public double getDouble(int columnIndex) throws SQLException { + try { + return this.currentRow.getDoubleValue(columnIndex-1); + } catch (TechnicalException e) { + log.error(e,e); + throw new SQLException(e.getMessage()); + } + } + + /** + * @see java.sql.ResultSet#getDouble(java.lang.String) + */ + public double getDouble(String columnName) throws SQLException { + int columnIndex = this.getColumnIndex(columnName); + return this.getDouble(columnIndex); + } + + /** + * @see java.sql.ResultSet#getFetchDirection() + */ + public int getFetchDirection() throws SQLException { + + return 0; + } + + /** + * @see java.sql.ResultSet#getFetchSize() + */ + public int getFetchSize() throws SQLException { + + return 0; + } + + /** + * @see java.sql.ResultSet#getFloat(int) + */ + public float getFloat(int columnIndex) throws SQLException { + try { + return this.currentRow.getFloatValue(columnIndex-1); + } catch (TechnicalException e) { + log.error(e,e); + throw new SQLException(e.getMessage()); + } + } + + /** + * @see java.sql.ResultSet#getFloat(java.lang.String) + */ + public float getFloat(String columnName) throws SQLException { + int columnIndex = this.getColumnIndex(columnName); + return this.getFloat(columnIndex); + } + + /** + * @see java.sql.ResultSet#getInt(int) + */ + public int getInt(int columnIndex) throws SQLException { + + try { + return this.currentRow.getIntValue(columnIndex-1); + } catch (TechnicalException e) { + log.error(e,e); + throw new SQLException(e.getMessage()); + } + } + + /** + * @see java.sql.ResultSet#getInt(java.lang.String) + */ + public int getInt(String columnName) throws SQLException { + int columnIndex = this.getColumnIndex(columnName); + return this.getInt(columnIndex); + } + + /** + * @see java.sql.ResultSet#getLong(int) + */ + public long getLong(int columnIndex) throws SQLException { + + return 0; + } + + /** + * @see java.sql.ResultSet#getLong(java.lang.String) + */ + public long getLong(String columnName) throws SQLException { + + return 0; + } + + /** + * @see java.sql.ResultSet#getMetaData() + */ + public ResultSetMetaData getMetaData() throws SQLException { + log.debug("SDEREsultSet.getMetaData"); + return new ArcSDEResultSetMetaData(this.mCols); + } + + /** + * @see java.sql.ResultSet#getObject(int) + */ + public Object getObject(int columnIndex) throws SQLException { + try { + return this.currentRow.getValue(columnIndex-1); + } catch (TechnicalException e) { + log.error(e,e); + throw new SQLException(e.getMessage()); + } + } + + /** + * @see java.sql.ResultSet#getObject(java.lang.String) + */ + public Object getObject(String columnName) throws SQLException { + int columnIndex = this.getColumnIndex(columnName); + return this.getObject(columnIndex); + } + + /** + * @see java.sql.ResultSet#getObject(int, java.util.Map) + */ + public Object getObject(int i, Map> map) + throws SQLException { + + return null; + } + + /** + * @see java.sql.ResultSet#getObject(java.lang.String, java.util.Map) + */ + public Object getObject(String colName, Map> map) + throws SQLException { + + return null; + } + + /** + * @see java.sql.ResultSet#getRef(int) + */ + public Ref getRef(int i) throws SQLException { + + return null; + } + + /** + * @see java.sql.ResultSet#getRef(java.lang.String) + */ + public Ref getRef(String colName) throws SQLException { + + return null; + } + + /** + * @see java.sql.ResultSet#getRow() + */ + public int getRow() throws SQLException { + + return 0; + } + + /** + * @see java.sql.ResultSet#getShort(int) + */ + public short getShort(int columnIndex) throws SQLException { + + return 0; + } + + /** + * @see java.sql.ResultSet#getShort(java.lang.String) + */ + public short getShort(String columnName) throws SQLException { + + return 0; + } + + /** + * @see java.sql.ResultSet#getStatement() + */ + public Statement getStatement() throws SQLException { + + return null; + } + + /** + * @see java.sql.ResultSet#getString(int) + */ + public String getString(int columnIndex) throws SQLException { + + try { + return this.currentRow.getStringValue(columnIndex-1); + } catch (TechnicalException e) { + log.error(e,e); + throw new SQLException(e.getMessage()); + } + } + + /** + * @see java.sql.ResultSet#getString(java.lang.String) + */ + public String getString(String columnName) throws SQLException { + int columnIndex = this.getColumnIndex(columnName); + return this.getString(columnIndex); + } + + /** + * @see java.sql.ResultSet#getTime(int) + */ + public Time getTime(int columnIndex) throws SQLException { + + return null; + } + + /** + * @see java.sql.ResultSet#getTime(java.lang.String) + */ + public Time getTime(String columnName) throws SQLException { + + return null; + } + + /** + * @see java.sql.ResultSet#getTime(int, java.util.Calendar) + */ + public Time getTime(int columnIndex, Calendar cal) throws SQLException { + + return null; + } + + /** + * @see java.sql.ResultSet#getTime(java.lang.String, java.util.Calendar) + */ + public Time getTime(String columnName, Calendar cal) throws SQLException { + + return null; + } + + /** + * @see java.sql.ResultSet#getTimestamp(int) + */ + public Timestamp getTimestamp(int columnIndex) throws SQLException { + + return null; + } + + /** + * @see java.sql.ResultSet#getTimestamp(java.lang.String) + */ + public Timestamp getTimestamp(String columnName) throws SQLException { + + return null; + } + + /** + * @see java.sql.ResultSet#getTimestamp(int, java.util.Calendar) + */ + public Timestamp getTimestamp(int columnIndex, Calendar cal) + throws SQLException { + + return null; + } + + /** + * @see java.sql.ResultSet#getTimestamp(java.lang.String, + * java.util.Calendar) + */ + public Timestamp getTimestamp(String columnName, Calendar cal) + throws SQLException { + + return null; + } + + /** + * @see java.sql.ResultSet#getType() + */ + public int getType() throws SQLException { + + return 0; + } + + /** + * @see java.sql.ResultSet#getURL(int) + */ + public URL getURL(int columnIndex) throws SQLException { + + return null; + } + + /** + * @see java.sql.ResultSet#getURL(java.lang.String) + */ + public URL getURL(String columnName) throws SQLException { + + return null; + } + + /** + * @see java.sql.ResultSet#getUnicodeStream(int) + */ + public InputStream getUnicodeStream(int columnIndex) throws SQLException { + + return null; + } + + /** + * @see java.sql.ResultSet#getUnicodeStream(java.lang.String) + */ + public InputStream getUnicodeStream(String columnName) throws SQLException { + + return null; + } + + /** + * @see java.sql.ResultSet#getWarnings() + */ + public SQLWarning getWarnings() throws SQLException { + + return null; + } + + /** + * @see java.sql.ResultSet#insertRow() + */ + public void insertRow() throws SQLException { + } + + /** + * @see java.sql.ResultSet#isAfterLast() + */ + public boolean isAfterLast() throws SQLException { + + return false; + } + + /** + * @see java.sql.ResultSet#isBeforeFirst() + */ + public boolean isBeforeFirst() throws SQLException { + + return false; + } + + /** + * @see java.sql.ResultSet#isFirst() + */ + public boolean isFirst() throws SQLException { + + return false; + } + + /** + * @see java.sql.ResultSet#isLast() + */ + public boolean isLast() throws SQLException { + + return false; + } + + /** + * @see java.sql.ResultSet#last() + */ + public boolean last() throws SQLException { + + return false; + } + + /** + * @see java.sql.ResultSet#moveToCurrentRow() + */ + public void moveToCurrentRow() throws SQLException { + } + + /** + * @see java.sql.ResultSet#moveToInsertRow() + */ + public void moveToInsertRow() throws SQLException { + } + + /** + * @see java.sql.ResultSet#next() + */ + public boolean next() throws SQLException { + + boolean next = this.mRows.size() > this.cursor; + if (next){ + log.debug("Zeile "+(cursor+1)+" von "+this.mRows.size()+" wird angesteuert."); + this.currentRow = this.mRows.get(this.cursor); + this.cursor++; + }else{ + this.currentRow = null; + } + return next; + } + + /** + * @see java.sql.ResultSet#previous() + */ + public boolean previous() throws SQLException { + + return false; + } + + /** + * @see java.sql.ResultSet#refreshRow() + */ + public void refreshRow() throws SQLException { + } + + /** + * @see java.sql.ResultSet#relative(int) + */ + public boolean relative(int rows) throws SQLException { + + return false; + } + + /** + * @see java.sql.ResultSet#rowDeleted() + */ + public boolean rowDeleted() throws SQLException { + + return false; + } + + /** + * @see java.sql.ResultSet#rowInserted() + */ + public boolean rowInserted() throws SQLException { + + return false; + } + + /** + * @see java.sql.ResultSet#rowUpdated() + */ + public boolean rowUpdated() throws SQLException { + + return false; + } + + /** + * @see java.sql.ResultSet#setFetchDirection(int) + */ + public void setFetchDirection(int direction) throws SQLException { + } + + /** + * @see java.sql.ResultSet#setFetchSize(int) + */ + public void setFetchSize(int rows) throws SQLException { + } + + /** + * @see java.sql.ResultSet#updateArray(int, java.sql.Array) + */ + public void updateArray(int columnIndex, Array x) throws SQLException { + } + + /** + * @see java.sql.ResultSet#updateArray(java.lang.String, java.sql.Array) + */ + public void updateArray(String columnName, Array x) throws SQLException { + } + + /** + * @see java.sql.ResultSet#updateAsciiStream(int, java.io.InputStream, int) + */ + public void updateAsciiStream(int columnIndex, InputStream x, int length) + throws SQLException { + } + + /** + * @see java.sql.ResultSet#updateAsciiStream(java.lang.String, + * java.io.InputStream, int) + */ + public void updateAsciiStream(String columnName, InputStream x, int length) + throws SQLException { + } + + /** + * @see java.sql.ResultSet#updateBigDecimal(int, java.math.BigDecimal) + */ + public void updateBigDecimal(int columnIndex, BigDecimal x) + throws SQLException { + } + + /** + * @see java.sql.ResultSet#updateBigDecimal(java.lang.String, + * java.math.BigDecimal) + */ + public void updateBigDecimal(String columnName, BigDecimal x) + throws SQLException { + } + + /** + * @see java.sql.ResultSet#updateBinaryStream(int, java.io.InputStream, int) + */ + public void updateBinaryStream(int columnIndex, InputStream x, int length) + throws SQLException { + } + + /** + * @see java.sql.ResultSet#updateBinaryStream(java.lang.String, + * java.io.InputStream, int) + */ + public void updateBinaryStream(String columnName, InputStream x, int length) + throws SQLException { + } + + /** + * @see java.sql.ResultSet#updateBlob(int, java.sql.Blob) + */ + public void updateBlob(int columnIndex, Blob x) throws SQLException { + } + + /** + * @see java.sql.ResultSet#updateBlob(java.lang.String, java.sql.Blob) + */ + public void updateBlob(String columnName, Blob x) throws SQLException { + } + + /** + * @see java.sql.ResultSet#updateBoolean(int, boolean) + */ + public void updateBoolean(int columnIndex, boolean x) throws SQLException { + } + + /** + * @see java.sql.ResultSet#updateBoolean(java.lang.String, boolean) + */ + public void updateBoolean(String columnName, boolean x) throws SQLException { + } + + /** + * @see java.sql.ResultSet#updateByte(int, byte) + */ + public void updateByte(int columnIndex, byte x) throws SQLException { + } + + /** + * @see java.sql.ResultSet#updateByte(java.lang.String, byte) + */ + public void updateByte(String columnName, byte x) throws SQLException { + } + + /** + * @see java.sql.ResultSet#updateBytes(int, byte[]) + */ + public void updateBytes(int columnIndex, byte[] x) throws SQLException { + } + + /** + * @see java.sql.ResultSet#updateBytes(java.lang.String, byte[]) + */ + public void updateBytes(String columnName, byte[] x) throws SQLException { + } + + /** + * @see java.sql.ResultSet#updateCharacterStream(int, java.io.Reader, int) + */ + public void updateCharacterStream(int columnIndex, Reader x, int length) + throws SQLException { + } + + /** + * @see java.sql.ResultSet#updateCharacterStream(java.lang.String, + * java.io.Reader, int) + */ + public void updateCharacterStream(String columnName, Reader reader, + int length) throws SQLException { + } + + /** + * @see java.sql.ResultSet#updateClob(int, java.sql.Clob) + */ + public void updateClob(int columnIndex, Clob x) throws SQLException { + } + + /** + * @see java.sql.ResultSet#updateClob(java.lang.String, java.sql.Clob) + */ + public void updateClob(String columnName, Clob x) throws SQLException { + } + + /** + * @see java.sql.ResultSet#updateDate(int, java.sql.Date) + */ + public void updateDate(int columnIndex, Date x) throws SQLException { + } + + /** + * @see java.sql.ResultSet#updateDate(java.lang.String, java.sql.Date) + */ + public void updateDate(String columnName, Date x) throws SQLException { + } + + /** + * @see java.sql.ResultSet#updateDouble(int, double) + */ + public void updateDouble(int columnIndex, double x) throws SQLException { + } + + /** + * @see java.sql.ResultSet#updateDouble(java.lang.String, double) + */ + public void updateDouble(String columnName, double x) throws SQLException { + } + + /** + * @see java.sql.ResultSet#updateFloat(int, float) + */ + public void updateFloat(int columnIndex, float x) throws SQLException { + } + + /** + * @see java.sql.ResultSet#updateFloat(java.lang.String, float) + */ + public void updateFloat(String columnName, float x) throws SQLException { + } + + /** + * @see java.sql.ResultSet#updateInt(int, int) + */ + public void updateInt(int columnIndex, int x) throws SQLException { + } + + /** + * @see java.sql.ResultSet#updateInt(java.lang.String, int) + */ + public void updateInt(String columnName, int x) throws SQLException { + } + + /** + * @see java.sql.ResultSet#updateLong(int, long) + */ + public void updateLong(int columnIndex, long x) throws SQLException { + } + + /** + * @see java.sql.ResultSet#updateLong(java.lang.String, long) + */ + public void updateLong(String columnName, long x) throws SQLException { + } + + /** + * @see java.sql.ResultSet#updateNull(int) + */ + public void updateNull(int columnIndex) throws SQLException { + } + + /** + * @see java.sql.ResultSet#updateNull(java.lang.String) + */ + public void updateNull(String columnName) throws SQLException { + } + + /** + * @see java.sql.ResultSet#updateObject(int, java.lang.Object) + */ + public void updateObject(int columnIndex, Object x) throws SQLException { + } + + /** + * @see java.sql.ResultSet#updateObject(java.lang.String, java.lang.Object) + */ + public void updateObject(String columnName, Object x) throws SQLException { + } + + /** + * @see java.sql.ResultSet#updateObject(int, java.lang.Object, int) + */ + public void updateObject(int columnIndex, Object x, int scale) + throws SQLException { + } + + /** + * @see java.sql.ResultSet#updateObject(java.lang.String, java.lang.Object, + * int) + */ + public void updateObject(String columnName, Object x, int scale) + throws SQLException { + } + + /** + * @see java.sql.ResultSet#updateRef(int, java.sql.Ref) + */ + public void updateRef(int columnIndex, Ref x) throws SQLException { + } + + /** + * @see java.sql.ResultSet#updateRef(java.lang.String, java.sql.Ref) + */ + public void updateRef(String columnName, Ref x) throws SQLException { + } + + /** + * @see java.sql.ResultSet#updateRow() + */ + public void updateRow() throws SQLException { + } + + /** + * @see java.sql.ResultSet#updateShort(int, short) + */ + public void updateShort(int columnIndex, short x) throws SQLException { + } + + /** + * @see java.sql.ResultSet#updateShort(java.lang.String, short) + */ + public void updateShort(String columnName, short x) throws SQLException { + } + + /** + * @see java.sql.ResultSet#updateString(int, java.lang.String) + */ + public void updateString(int columnIndex, String x) throws SQLException { + } + + /** + * @see java.sql.ResultSet#updateString(java.lang.String, java.lang.String) + */ + public void updateString(String columnName, String x) throws SQLException { + } + + /** + * @see java.sql.ResultSet#updateTime(int, java.sql.Time) + */ + public void updateTime(int columnIndex, Time x) throws SQLException { + } + + /** + * @see java.sql.ResultSet#updateTime(java.lang.String, java.sql.Time) + */ + public void updateTime(String columnName, Time x) throws SQLException { + } + + /** + * @see java.sql.ResultSet#updateTimestamp(int, java.sql.Timestamp) + */ + public void updateTimestamp(int columnIndex, Timestamp x) + throws SQLException { + } + + /** + * @see java.sql.ResultSet#updateTimestamp(java.lang.String, + * java.sql.Timestamp) + */ + public void updateTimestamp(String columnName, Timestamp x) + throws SQLException { + } + + /** + * @see java.sql.ResultSet#wasNull() + */ + public boolean wasNull() throws SQLException { + + return false; + } + + + private int getColumnIndex(String columnName) throws SQLException{ + //TODO: Es gibt effizentere Lösungen. Hier noch mal über HashMap nachdenken + for (int i = 0 ; i < this.mCols.size();i++){ + if(this.mCols.get(i).getName().equalsIgnoreCase(columnName)){ + return i +1; // PLUS 1 da SQL-Cursor 1 nasiert sind + } + } + throw new SQLException("Column "+columnName+" does not exist in ResulSet"); + } } diff -r d8ff739b9f3b -r 5a583cff97ea geo-backend/src/test/java/de/intevation/gnv/geobackend/base/query/QueryExecutorTestCase.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/geo-backend/src/test/java/de/intevation/gnv/geobackend/base/query/QueryExecutorTestCase.java Fri Sep 04 08:11:30 2009 +0000 @@ -0,0 +1,104 @@ +/** + * + */ +package de.intevation.gnv.geobackend.base.query; + +import java.io.FileInputStream; +import java.io.InputStream; +import java.util.Collection; +import java.util.Iterator; +import java.util.Properties; + +import org.apache.log4j.BasicConfigurator; +import org.apache.log4j.Logger; + +import de.intevation.gnv.geobackend.base.Result; +import de.intevation.gnv.geobackend.base.ResultDescriptor; +import de.intevation.gnv.geobackend.base.connectionpool.ConnectionPoolFactory; +import de.intevation.gnv.geobackend.base.query.container.QueryContainerFactory; +import de.intevation.gnv.geobackend.base.query.exception.QueryException; +import junit.framework.TestCase; + +/** + * TestCase for the QueryExecutor interface + * @author Tim Englich + * + */ +public class QueryExecutorTestCase extends TestCase { + + + /** + * the logger, used to log exceptions and additonaly information + */ + private static Logger log = null; + + static{ + BasicConfigurator.configure(); + log = Logger.getLogger(QueryExecutorTestCase.class); + } + + /** + * Constructor + * @param name + */ + public QueryExecutorTestCase(String name) { + super(name); + } + + /** + * Tests if the Databaseconnection can be established and + * Data could be read from the Database + */ + public void testQueryExecutor(){ + + try { + QueryExecutor queryExecutor = QueryExecutorFactory.getInstance().getQueryExecutor(); + Collection results = queryExecutor.executeQuery("mesh", null); + if (results == null || results.size() == 0){ + log.error("Keine Daten erhalten"); + fail(); + }else { + log.debug("Datem erhalten"); + Iterator it = results.iterator(); + while (it.hasNext()){ + Result tmpResult = it.next(); + ResultDescriptor resultDescriptor = tmpResult.getResultDescriptor(); + int columns = resultDescriptor.getColumnCount(); + for (int i = 0; i < columns; i++){ + String columnName = resultDescriptor.getColumnName(i); + Object value = tmpResult.getObject(columnName); + log.debug(columnName + " ==> "+value.toString()); + } + } + } + } catch (QueryException e) { + log.error(e,e); + fail(); + } + } + + + /** + * @see junit.framework.TestCase#setUp() + */ + @Override + protected void setUp() throws Exception { + + super.setUp(); + InputStream inputStream = new FileInputStream("src/test/ressources/ArcSDEConnectionPoolTestCase.properties"); + Properties properties = new Properties(); + properties.load(inputStream); + + ConnectionPoolFactory cpf = ConnectionPoolFactory.getInstance(); + cpf.initializeConnectionPool(properties); + + + inputStream = new FileInputStream("src/test/ressources/QueryExecutorTestCase.properties"); + properties = new Properties(); + properties.load(inputStream); + + QueryContainerFactory qcf = QueryContainerFactory.getInstance(); + qcf.initializeQueryContainer(properties); + } + +} diff -r d8ff739b9f3b -r 5a583cff97ea geo-backend/src/test/java/de/intevation/gnv/geobackend/sde/datasources/ArcSDEConnectionPoolTestCase.java --- a/geo-backend/src/test/java/de/intevation/gnv/geobackend/sde/datasources/ArcSDEConnectionPoolTestCase.java Wed Sep 02 15:28:51 2009 +0000 +++ b/geo-backend/src/test/java/de/intevation/gnv/geobackend/sde/datasources/ArcSDEConnectionPoolTestCase.java Fri Sep 04 08:11:30 2009 +0000 @@ -27,97 +27,94 @@ */ public class ArcSDEConnectionPoolTestCase extends TestCase { - /** + /** * the logger, used to log exceptions and additonaly information */ private static Logger log = null; static { - BasicConfigurator.configure(); - log = Logger.getLogger(ArcSDEPoolableObjectFactory.class); + BasicConfigurator.configure(); + log = Logger.getLogger(ArcSDEPoolableObjectFactory.class); } - - - - /** - * - */ - public ArcSDEConnectionPoolTestCase() { - super(); - } - - /** - * - * @param name - */ - public ArcSDEConnectionPoolTestCase(String name) { - super(name); - } - - public void testArcSDEConnectionPool(){ - log.debug("ArcSDEConnectionPoolTestCase.testArcSDEConnectionPool"); - try { - InputStream inputStream = new FileInputStream("src/test/ressources/ArcSDEConnectionPoolTestCase.properties"); - Properties properties = new Properties(); - properties.load(inputStream); - - ConnectionPoolFactory cpf = ConnectionPoolFactory.getInstance(); - cpf.initializeConnectionPool(properties); - - assertTrue(cpf.isInitialized()); - log.debug("ConnectionPoolFactory ist initialisiert."); - - ConnectionPool cp = cpf.getConnectionPool(); - assertNotNull(cp); - log.debug("ConnectionPool ist initialisiert."); - - Connection connection = null; - try{ - try { - connection = cp.getConnection("N/N"); - assertNotNull(connection); - log.debug("Connection ist initialisiert."); - } catch (ConnectionException e) { - log.error("Es traten Probleme bei der Verbinung zur Datenbank auf."); - fail(); - } - - - try { - Statement stmt = connection.createStatement(); - ResultSet rs = stmt.executeQuery("Select MESHID, NAME from MEDIAN.MESH"); - - while (rs.next()){ - log.debug(rs.getInt(1)); - log.debug(rs.getString(2)); - - log.debug(rs.getInt("MESHID")); - log.debug(rs.getString("NAME")); - } - - } catch (SQLException e) { - log.error(e,e); - } - }finally{ - if (connection != null){ - try { - connection.close(); + /** + * + */ + public ArcSDEConnectionPoolTestCase() { + super(); + } + + /** + * + * @param name + */ + public ArcSDEConnectionPoolTestCase(String name) { + super(name); + } + + /** + * Test if the ArcSDEConnectionPool can be established + * and if a Request could be done. + */ + public void testArcSDEConnectionPool(){ + log.debug("ArcSDEConnectionPoolTestCase.testArcSDEConnectionPool"); + try { + InputStream inputStream = new FileInputStream("src/test/ressources/ArcSDEConnectionPoolTestCase.properties"); + Properties properties = new Properties(); + properties.load(inputStream); + + ConnectionPoolFactory cpf = ConnectionPoolFactory.getInstance(); + cpf.initializeConnectionPool(properties); + + assertTrue(cpf.isInitialized()); + log.debug("ConnectionPoolFactory ist initialisiert."); + + ConnectionPool cp = cpf.getConnectionPool(); + assertNotNull(cp); + log.debug("ConnectionPool ist initialisiert."); + + Connection connection = null; + try{ + try { + connection = cp.getConnection("N/N"); + assertNotNull(connection); + log.debug("Connection ist initialisiert."); + } catch (ConnectionException e) { + log.error("Es traten Probleme bei der Verbinung zur Datenbank auf."); + fail(); + } + + + try { + Statement stmt = connection.createStatement(); + ResultSet rs = stmt.executeQuery("Select MESHID, NAME from MEDIAN.MESH"); + + while (rs.next()){ + log.debug(rs.getInt(1)); + log.debug(rs.getString(2)); + + log.debug(rs.getInt("MESHID")); + log.debug(rs.getString("NAME")); + } + + } catch (SQLException e) { + log.error(e,e); + } + }finally{ + if (connection != null){ + try { + connection.close(); } catch (SQLException e) { - log.error(e,e); - fail(); + log.error(e,e); + fail(); } - } - } - - - - } catch (FileNotFoundException e) { - log.error(e,e); - fail(); - } catch (IOException e) { - log.error(e,e); - fail(); - } - } - + } + } + } catch (FileNotFoundException e) { + log.error(e,e); + fail(); + } catch (IOException e) { + log.error(e,e); + fail(); + } + } } diff -r d8ff739b9f3b -r 5a583cff97ea geo-backend/src/test/ressources/QueryExecutorTestCase.properties --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/geo-backend/src/test/ressources/QueryExecutorTestCase.properties Fri Sep 04 08:11:30 2009 +0000 @@ -0,0 +1,1 @@ +mesh=Select MESHID, NAME from MEDIAN.MESH \ No newline at end of file