From: <gr...@sv...> - 2005-02-07 12:50:34
|
Author: groldan Date: 2005-02-07 05:01:21 -0800 (Mon, 07 Feb 2005) New Revision: 11153 Added: geotools/trunk/gt/plugin/arcsde/test/org/geotools/data/arcsde/ArcSDEFe= atureStoreTest.java geotools/trunk/gt/plugin/arcsde/test/org/geotools/data/arcsde/ArcSDEQu= eryTest.java geotools/trunk/gt/plugin/arcsde/test/org/geotools/data/arcsde/TestData= .java Modified: geotools/trunk/gt/plugin/arcsde/project.xml geotools/trunk/gt/plugin/arcsde/src/org/geotools/data/arcsde/ArcSDEAda= pter.java geotools/trunk/gt/plugin/arcsde/src/org/geotools/data/arcsde/ArcSDEAtt= ributeReader.java geotools/trunk/gt/plugin/arcsde/src/org/geotools/data/arcsde/ArcSDECon= nectionPool.java geotools/trunk/gt/plugin/arcsde/src/org/geotools/data/arcsde/ArcSDEDat= aStore.java geotools/trunk/gt/plugin/arcsde/src/org/geotools/data/arcsde/ArcSDEDat= aStoreFactory.java geotools/trunk/gt/plugin/arcsde/src/org/geotools/data/arcsde/ArcSDEFea= tureWriter.java geotools/trunk/gt/plugin/arcsde/src/org/geotools/data/arcsde/ArcSDEQue= ry.java geotools/trunk/gt/plugin/arcsde/src/org/geotools/data/arcsde/ArcTransa= ctionState.java geotools/trunk/gt/plugin/arcsde/src/org/geotools/data/arcsde/Connectio= nPoolFactory.java geotools/trunk/gt/plugin/arcsde/src/org/geotools/data/arcsde/GeometryB= uilder.java geotools/trunk/gt/plugin/arcsde/test/org/geotools/data/arcsde/ArcSDEDa= taStoreTest.java geotools/trunk/gt/plugin/arcsde/test/testData/testparams.properties Log: merged Brock's optimizations and done some refactoring, added some unit t= est skeletons and a new unit test named testMixedQueries Modified: geotools/trunk/gt/plugin/arcsde/project.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- geotools/trunk/gt/plugin/arcsde/project.xml 2005-02-07 12:20:40 UTC (= rev 11152) +++ geotools/trunk/gt/plugin/arcsde/project.xml 2005-02-07 13:01:21 UTC (= rev 11153) @@ -54,12 +54,31 @@ <version>SNAPSHOT</version> <url>http://geoapi.sourceforge.net</url> </dependency> + <!-- <dependency> <artifactId>jsde_sdk</artifactId> <groupId>arcsde</groupId> <version>8.3</version> </dependency> + --> + <dependency> + <artifactId>jsde_sdk</artifactId> + <groupId>arcsde</groupId> + <version>9.0</version> + </dependency> + <dependency> + <artifactId>jsde_concurrent</artifactId> + <groupId>arcsde</groupId> + <version>9.0</version> + </dependency> + <dependency> + <artifactId>jsde_jpe_sdk</artifactId> + <groupId>arcsde</groupId> + <version>9.0</version> + </dependency> + + <dependency> <id>JTS</id> <version>1.6-SNAPSHOT</version> <url>http://www.vividsolutions.com/JTS/jts_frame.htm</url> @@ -73,8 +92,12 @@ <!-- This section excludes the tests, comment out if your testData/testparams.properties are set correctly --> <excludes> + <!-- <exclude>**/ArcSDEDataStoreTest.java</exclude> <exclude>**/ArcSDEConnectionPoolTest.java</exclude> + --> + <exclude>**/ArcSDEQueryTest.java</exclude> + <exclude>**/ArcSDEFeatureStoreTest.java</exclude> <exclude>**/FilterTest.java</exclude> </excludes> <!-- End exclude tests --> Modified: geotools/trunk/gt/plugin/arcsde/src/org/geotools/data/arcsde/Ar= cSDEAdapter.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- geotools/trunk/gt/plugin/arcsde/src/org/geotools/data/arcsde/ArcSDEAd= apter.java 2005-02-07 12:20:40 UTC (rev 11152) +++ geotools/trunk/gt/plugin/arcsde/src/org/geotools/data/arcsde/ArcSDEAd= apter.java 2005-02-07 13:01:21 UTC (rev 11153) @@ -57,10 +57,10 @@ * from geotool's Query's, mapping SDE types to Java ones and JTS Geomet= ries, * etc. * - * @author Gabriel Rold=E1n + * @author Gabriel Rold?n * @version $Id: ArcSDEAdapter.java,v 1.4 2004/06/22 20:13:15 jfear Exp = $ */ -public class ArcSDEAdapter { +class ArcSDEAdapter { /** Logger for ths class' package */ private static final Logger LOGGER =3D Logger.getLogger(ArcSDEAdapte= r.class.getPackage() = .getName()); @@ -504,160 +504,167 @@ =20 return queryColumns; } -} =20 + /** + * DOCUMENT ME! + * + * @author $author$ + * @version $Revision: 1.4 $ + */ + public static class SdeTypeDef { + /** DOCUMENT ME! */ + final int colDefType; =20 -/** - * DOCUMENT ME! - * - * @author $author$ - * @version $Revision: 1.4 $ - */ -class SdeTypeDef { - /** DOCUMENT ME! */ - final int colDefType; + /** DOCUMENT ME! */ + final int size; =20 - /** DOCUMENT ME! */ - final int size; + /** DOCUMENT ME! */ + final int scale; =20 - /** DOCUMENT ME! */ - final int scale; + /** + * Creates a new SdeTypeDef object. + * + * @param colDefType DOCUMENT ME! + * @param size DOCUMENT ME! + * @param scale DOCUMENT ME! + */ + public SdeTypeDef(int colDefType, int size, int scale) { + this.colDefType =3D colDefType; + this.size =3D size; + this.scale =3D scale; + } + } =20 /** - * Creates a new SdeTypeDef object. + * DOCUMENT ME! * - * @param colDefType DOCUMENT ME! - * @param size DOCUMENT ME! - * @param scale DOCUMENT ME! + * @author $author$ + * @version $Revision: 1.9 $ */ - public SdeTypeDef(int colDefType, int size, int scale) { - this.colDefType =3D colDefType; - this.size =3D size; - this.scale =3D scale; - } -} + public static class FilterSet { + /** DOCUMENT ME! */ + private Filter sourceFilter; =20 + /** DOCUMENT ME! */ + private Filter sqlFilter; =20 -/** - * DOCUMENT ME! - * - * @author $author$ - * @version $Revision: 1.9 $ - */ -class FilterSet { - private Filter sourceFilter; - private Filter sqlFilter; - private Filter geometryFilter; - private Filter unsupportedFilter; + /** DOCUMENT ME! */ + private Filter geometryFilter; =20 - /** DOCUMENT ME! */ - SQLEncoderSDE sqlEncoder; + /** DOCUMENT ME! */ + private Filter unsupportedFilter; =20 - /** DOCUMENT ME! */ - GeometryEncoderSDE geometryEncoder; + /** DOCUMENT ME! */ + SQLEncoderSDE sqlEncoder; =20 - /** - * Creates a new FilterSet object. - * - * @param sdeLayer DOCUMENT ME! - * @param sourceFilter DOCUMENT ME! - */ - public FilterSet(SeLayer sdeLayer, Filter sourceFilter) { - sqlEncoder =3D new SQLEncoderSDE(sdeLayer); - geometryEncoder =3D new GeometryEncoderSDE(sdeLayer); - setFilter(sourceFilter); - } + /** DOCUMENT ME! */ + GeometryEncoderSDE geometryEncoder; =20 - /** - * DOCUMENT ME! - * - * @param sourceFilter DOCUMENT ME! - */ - public void setFilter(Filter sourceFilter) { - this.sourceFilter =3D sourceFilter; - createFilters(); - } + /** + * Creates a new FilterSet object. + * + * @param sdeLayer DOCUMENT ME! + * @param sourceFilter DOCUMENT ME! + */ + public FilterSet(SeLayer sdeLayer, Filter sourceFilter) { + sqlEncoder =3D new SQLEncoderSDE(sdeLayer); + geometryEncoder =3D new GeometryEncoderSDE(sdeLayer); + setFilter(sourceFilter); + } =20 - /** - * DOCUMENT ME! - */ - private void createFilters() { - SQLUnpacker unpacker =3D new SQLUnpacker(sqlEncoder.getCapabilit= ies()); - unpacker.unPackAND(sourceFilter); + /** + * DOCUMENT ME! + * + * @param sourceFilter DOCUMENT ME! + */ + public void setFilter(Filter sourceFilter) { + this.sourceFilter =3D sourceFilter; + createFilters(); + } =20 - this.sqlFilter =3D unpacker.getSupported(); + /** + * DOCUMENT ME! + */ + private void createFilters() { + SQLUnpacker unpacker =3D new SQLUnpacker(sqlEncoder.getCapab= ilities()); + unpacker.unPackAND(sourceFilter); =20 - Filter remainingFilter =3D unpacker.getUnSupported(); + this.sqlFilter =3D unpacker.getSupported(); =20 - unpacker =3D new SQLUnpacker(GeometryEncoderSDE.getCapabilities(= )); - unpacker.unPackAND(remainingFilter); + Filter remainingFilter =3D unpacker.getUnSupported(); =20 - this.geometryFilter =3D unpacker.getSupported(); - this.unsupportedFilter =3D unpacker.getUnSupported(); - } + unpacker =3D new SQLUnpacker(GeometryEncoderSDE.getCapabilit= ies()); + unpacker.unPackAND(remainingFilter); =20 - /** - * DOCUMENT ME! - * - * @return DOCUMENT ME! - * - * @throws DataSourceException DOCUMENT ME! - */ - public String createSqlWhereClause() throws DataSourceException { - String where =3D null; - Filter sqlFilter =3D getSqlFilter(); + this.geometryFilter =3D unpacker.getSupported(); + this.unsupportedFilter =3D unpacker.getUnSupported(); + } =20 - if (sqlFilter !=3D Filter.NONE) { - try { - where =3D sqlEncoder.encode(sqlFilter); - } catch (SQLEncoderException sqle) { - String message =3D "Geometry encoder error: " + sqle.get= Message(); - throw new DataSourceException(message, sqle); + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + * + * @throws DataSourceException DOCUMENT ME! + */ + public String createSqlWhereClause() throws DataSourceException = { + String where =3D null; + Filter sqlFilter =3D getSqlFilter(); + + if (sqlFilter !=3D Filter.NONE) { + try { + where =3D sqlEncoder.encode(sqlFilter); + } catch (SQLEncoderException sqle) { + String message =3D "Geometry encoder error: " + + sqle.getMessage(); + throw new DataSourceException(message, sqle); + } } + + return where; } =20 - return where; - } + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + * + * @throws GeometryEncoderException DOCUMENT ME! + */ + public SeFilter[] createSpatialFilters() + throws GeometryEncoderException { + geometryEncoder.encode(geometryFilter); =20 - /** - * DOCUMENT ME! - * - * @return DOCUMENT ME! - * - * @throws GeometryEncoderException DOCUMENT ME! - */ - public SeFilter[] createSpatialFilters() throws GeometryEncoderExcep= tion { - geometryEncoder.encode(geometryFilter); + SeFilter[] sdeSpatialFilters =3D geometryEncoder.getSpatialF= ilters(); =20 - SeFilter[] sdeSpatialFilters =3D geometryEncoder.getSpatialFilte= rs(); + return sdeSpatialFilters; + } =20 - return sdeSpatialFilters; - } + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public Filter getSqlFilter() { + return (sqlFilter =3D=3D null) ? Filter.NONE : sqlFilter; + } =20 - /** - * DOCUMENT ME! - * - * @return DOCUMENT ME! - */ - public Filter getSqlFilter() { - return (sqlFilter =3D=3D null) ? Filter.NONE : sqlFilter; - } + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public Filter getGeometryFilter() { + return (geometryFilter =3D=3D null) ? Filter.NONE : geometry= Filter; + } =20 - /** - * DOCUMENT ME! - * - * @return DOCUMENT ME! - */ - public Filter getGeometryFilter() { - return (geometryFilter =3D=3D null) ? Filter.NONE : geometryFilt= er; + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public Filter getUnsupportedFilter() { + return (unsupportedFilter =3D=3D null) ? Filter.NONE : unsup= portedFilter; + } } - - /** - * DOCUMENT ME! - * - * @return DOCUMENT ME! - */ - public Filter getUnsupportedFilter() { - return (unsupportedFilter =3D=3D null) ? Filter.NONE : unsupport= edFilter; - } } Modified: geotools/trunk/gt/plugin/arcsde/src/org/geotools/data/arcsde/Ar= cSDEAttributeReader.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- geotools/trunk/gt/plugin/arcsde/src/org/geotools/data/arcsde/ArcSDEAt= tributeReader.java 2005-02-07 12:20:40 UTC (rev 11152) +++ geotools/trunk/gt/plugin/arcsde/src/org/geotools/data/arcsde/ArcSDEAt= tributeReader.java 2005-02-07 13:01:21 UTC (rev 11153) @@ -16,34 +16,45 @@ */ package org.geotools.data.arcsde; =20 -import java.io.IOException; -import java.util.logging.Level; -import java.util.logging.Logger; - +import com.esri.sde.sdk.client.SeException; +import com.esri.sde.sdk.client.SeRow; +import com.esri.sde.sdk.client.SeShape; import org.geotools.data.AttributeReader; import org.geotools.data.DataSourceException; import org.geotools.feature.AttributeType; import org.geotools.feature.FeatureType; +import java.io.IOException; +import java.util.logging.Level; +import java.util.logging.Logger; =20 -import com.esri.sde.sdk.client.SeException; -import com.esri.sde.sdk.client.SeRow; -import com.esri.sde.sdk.client.SeShape; =20 - /** * Implements an attribute reader that is aware of the particulars of Ar= cSDE. * This class sends its logging to the log named "org.geotools.data". * - * @author Gabriel Rold=E1n + * @author Gabriel Roldan, Axios Engineering * @version $Id$ */ -public class ArcSDEAttributeReader implements AttributeReader { +class ArcSDEAttributeReader implements AttributeReader { + /** DOCUMENT ME! */ private static final Logger LOGGER =3D Logger.getLogger("org.geotool= s.data"); + + /** DOCUMENT ME! */ private ArcSDEQuery query; + + /** DOCUMENT ME! */ private FeatureType schema; + + /** DOCUMENT ME! */ private SeRow currentRow; + + /** DOCUMENT ME! */ private SeShape currentShape; + + /** DOCUMENT ME! */ private GeometryBuilder geometryBuilder; + + /** DOCUMENT ME! */ private int geometryTypeIndex =3D -1; =20 /** DOCUMENT ME! */ @@ -51,6 +62,8 @@ =20 /** DOCUMENT ME! */ int fidPrefixLen; + + /** DOCUMENT ME! */ private boolean hasNextAlreadyCalled =3D false; =20 /** Modified: geotools/trunk/gt/plugin/arcsde/src/org/geotools/data/arcsde/Ar= cSDEConnectionPool.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- geotools/trunk/gt/plugin/arcsde/src/org/geotools/data/arcsde/ArcSDECo= nnectionPool.java 2005-02-07 12:20:40 UTC (rev 11152) +++ geotools/trunk/gt/plugin/arcsde/src/org/geotools/data/arcsde/ArcSDECo= nnectionPool.java 2005-02-07 13:01:21 UTC (rev 11153) @@ -16,7 +16,13 @@ */ package org.geotools.data.arcsde; =20 +import com.esri.sde.sdk.client.SeConnection; +import com.esri.sde.sdk.client.SeException; +import com.esri.sde.sdk.client.SeLayer; +import com.esri.sde.sdk.client.SeTable; +import org.geotools.data.DataSourceException; import java.io.IOException; +import java.util.HashMap; import java.util.Iterator; import java.util.LinkedList; import java.util.List; @@ -24,14 +30,7 @@ import java.util.Vector; import java.util.logging.Logger; =20 -import org.geotools.data.DataSourceException; =20 -import com.esri.sde.sdk.client.SeConnection; -import com.esri.sde.sdk.client.SeException; -import com.esri.sde.sdk.client.SeLayer; -import com.esri.sde.sdk.client.SeTable; - - /** * Maintains <code>SeConnection</code>'s for a single set of connection * properties (for instance: by server, port, user and password) in a po= oled @@ -79,7 +78,7 @@ * </ul> * </p> * - * @author Gabriel Rold=E1n + * @author Gabriel Rold?n * @version $Id: ArcSDEConnectionPool.java,v 1.1 2004/06/21 15:00:33 cdi= llard Exp $ */ public class ArcSDEConnectionPool { @@ -132,6 +131,13 @@ */ private boolean closed =3D false; =20 + // START ADDED BY BROCK + + /** DOCUMENT ME! */ + private HashMap cachedLayers; + + // END ADDED BY BROCK + /** * Creates a new SdeConnectionPool object with the connection parame= ters * holded by <code>config</code> @@ -149,6 +155,10 @@ throw new NullPointerException("parameter config can't be nu= ll"); } =20 + // START ADDED BY BROCK + cachedLayers =3D new HashMap(); + + // END ADDED BY BROCK =20 this.config =3D config; LOGGER.fine("populating ArcSDE connection pool"); =20 @@ -200,47 +210,58 @@ } =20 /** - * This method does not just release a connection, it 'recycles' it,= =20 - * to make a completely new connection. This is due to a nasty prob= lem - * with <i>some</i> arcsde instances on <i>some</i> datastores, only= when - * spatial constraints are used. They seem to poison the connection= . - * So this is a half decent work around, which probably slows things= a bit, + * This method does not just release a connection, it 'recycles' it,= to + * make a completely new connection. This is due to a nasty problem= with + * <i>some</i> arcsde instances on <i>some</i> datastores, only when + * spatial constraints are used. They seem to poison the connection= . So + * this is a half decent work around, which probably slows things a = bit, * but also makes it work. + * + * @param seConnection DOCUMENT ME! + * + * @throws DataSourceException DOCUMENT ME! */ public void recycle(SeConnection seConnection) throws DataSourceExce= ption { - if (seConnection =3D=3D null) { - LOGGER.fine("trying to recycle a null connection"); - return; + if (seConnection =3D=3D null) { + LOGGER.fine("trying to recycle a null connection"); + + return; } =20 synchronized (mutex) { - LOGGER.finer("trying to recycle seconnection: " + seConnection); - LOGGER.finer("used is: " + usedConnections + "\navailable is " + av= ailableConnections); - //added to force close - try { - seConnection.close(); - } catch (SeException sex) { - LOGGER.fine("trouble closing seconnection: " + sex.getMessage()); - sex.printStackTrace(); - } - if (usedConnections.contains(seConnection)) { - usedConnections.remove(seConnection); - } - if (availableConnections.contains(seConnection)) { - LOGGER.fine("trying to recycle an already freed connection, " + - "getting rid of the free one..."); - availableConnections.remove(seConnection); - }=20 + LOGGER.finer("trying to recycle seconnection: " + seConnecti= on); + LOGGER.finer("used is: " + usedConnections + "\navailable is= " + + availableConnections); =20 - SeConnection newConnection =3D null; - try { - newConnection =3D newConnection(); - availableConnections.add(newConnection); - LOGGER.fine("recycled new connection to pool: " + ne= wConnection); - } catch (SeException ex) { - throw new DataSourceException("Can't create connecti= on to " - + config.getServerName() + ": " + ex.getMessage(= ), ex); - } + //added to force close + try { + seConnection.close(); + } catch (SeException sex) { + LOGGER.fine("trouble closing seconnection: " + sex.getMe= ssage()); + sex.printStackTrace(); + } + + if (usedConnections.contains(seConnection)) { + usedConnections.remove(seConnection); + } + + if (availableConnections.contains(seConnection)) { + LOGGER.fine("trying to recycle an already freed connecti= on, " + + "getting rid of the free one..."); + availableConnections.remove(seConnection); + } + + SeConnection newConnection =3D null; + + try { + newConnection =3D newConnection(); + availableConnections.add(newConnection); + LOGGER.fine("recycled new connection to pool: " + newCon= nection); + } catch (SeException ex) { + throw new DataSourceException("Can't create connection t= o " + + config.getServerName() + ": " + ex.getMessage(), e= x); + } + LOGGER.fine(seConnection + " freed" + ", added " + newConnec= tion); } } @@ -252,23 +273,25 @@ */ public void release(SeConnection seConnection) { if (seConnection =3D=3D null) { - LOGGER.fine("trying to release a null connection"); - return; + LOGGER.fine("trying to release a null connection"); + + return; } =20 synchronized (mutex) { - LOGGER.fine("trying to release a seconnection: " + seConnection); - LOGGER.finer("used is: " + usedConnections + "\navailable is " + av= ailableConnections); - usedConnections.remove(seConnection); + LOGGER.fine("trying to release a seconnection: " + seConnect= ion); + LOGGER.finer("used is: " + usedConnections + "\navailable is= " + + availableConnections); + usedConnections.remove(seConnection); + if (availableConnections.contains(seConnection)) { LOGGER.fine("trying to free an already freed connection.= .."); } else { availableConnections.add(seConnection); } - =20 - LOGGER.fine(seConnection + "freed, after release used is: " +=20 - usedConnections +=20 - "\navailable is " + availableConnections); + + LOGGER.fine(seConnection + "freed, after release used is: " + + usedConnections + "\navailable is " + availableConnect= ions); } } =20 @@ -511,42 +534,42 @@ * * @throws NoSuchElementException DOCUMENT ME! * @throws IOException DOCUMENT ME! - * @throws DataSourceException DOCUMENT ME! */ public SeLayer getSdeLayer(String typeName) throws NoSuchElementException, IOException { - SeConnection conn =3D null; - Vector layers =3D null; + //attempt to get the SeLayer object from cache before creating a= new + //one, because creation is costly for SeLayer objects. + SeLayer layer =3D (SeLayer) cachedLayers.get(typeName); =20 - try { - conn =3D getConnection(); - layers =3D conn.getLayers(); - } catch (SeException ex) { - throw new DataSourceException("Error querying the layers lis= t" - + ex.getSeError().getSdeError() + - " (" + ex.getSeError().getErrDesc() - + ") ", ex); - } catch (UnavailableConnectionException ex) { - throw new DataSourceException("No free connection found to q= uery the layers list", - ex); - } finally { - release(conn); - } + //if the layer was not cached, create it + if (layer =3D=3D null) { + synchronized (mutex) { + //check for race condition + if ((layer =3D (SeLayer) cachedLayers.get(typeName)) !=3D= null) { + return layer; + } =20 - SeLayer layer =3D null; + List layers =3D getAvailableSdeLayers(); =20 - try { - for (Iterator it =3D layers.iterator(); it.hasNext();) { - layer =3D (SeLayer) it.next(); + try { + for (Iterator it =3D layers.iterator(); it.hasNext()= ;) { + layer =3D (SeLayer) it.next(); =20 - if (layer.getQualifiedName().equalsIgnoreCase(typeName))= { - break; + if (layer.getQualifiedName().equalsIgnoreCase(ty= peName)) { + break; + } + + layer =3D null; + } + } catch (SeException ex) { + throw new NoSuchElementException(ex.getMessage()); } =20 - layer =3D null; + //cache the layer. + if (layer !=3D null) { + cachedLayers.put(typeName, layer); + } } - } catch (SeException ex) { - throw new NoSuchElementException(ex.getMessage()); } =20 return layer; @@ -568,8 +591,9 @@ =20 return conn.getLayers(); } catch (SeException ex) { - throw new DataSourceException("Error consulting the list of = available layers", - ex); + throw new DataSourceException("Error querying the layers lis= t" + + ex.getSeError().getSdeError() + " (" + + ex.getSeError().getErrDesc() + ") ", ex); } catch (UnavailableConnectionException ex) { throw new DataSourceException("No free connection found to q= uery the layers list", ex); Modified: geotools/trunk/gt/plugin/arcsde/src/org/geotools/data/arcsde/Ar= cSDEDataStore.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- geotools/trunk/gt/plugin/arcsde/src/org/geotools/data/arcsde/ArcSDEDa= taStore.java 2005-02-07 12:20:40 UTC (rev 11152) +++ geotools/trunk/gt/plugin/arcsde/src/org/geotools/data/arcsde/ArcSDEDa= taStore.java 2005-02-07 13:01:21 UTC (rev 11153) @@ -59,24 +59,24 @@ * Transaction and Locking Support. These implementations will not be op= timal * but they will work. * </p> - *=20 - * <p> - * Pleae note that there may be a better place for you to start out from= , (like - * JDBCDataStore). - * </p> * - * @author Gabriel Rold?n + * @author Gabriel Roldan, Axios Engineering * @version $Id: ArcSDEDataStore.java,v 1.8 2004/06/28 10:24:32 jfear Ex= p $ */ -public class ArcSDEDataStore extends AbstractDataStore { +class ArcSDEDataStore extends AbstractDataStore { /** DOCUMENT ME! */ private static final Logger LOGGER =3D Logger.getLogger(ArcSDEDataSt= ore.class.getPackage() = .getName()); + + /** DOCUMENT ME! */ private ArcSDEConnectionPool connectionPool; =20 /** <code>Map<typeName/FeatureType></code> of feature type sch= emas */ private Map schemasCache =3D new HashMap(); =20 + /** A mutex for synchronizing */ + private Object mutex =3D new Object(); + /** * Creates a new ArcSDEDataStore object. * @@ -247,8 +247,8 @@ sdeQuery.close(); } =20 - throw new DataSourceException("Problem with feature reader: = " + - t.getMessage(), t); + throw new DataSourceException("Problem with feature reader: = " + + t.getMessage(), t); } =20 return reader; @@ -282,8 +282,8 @@ */ protected Filter getUnsupportedFilter(String typeName, Filter filter= ) { try { - FilterSet filters =3D ArcSDEAdapter.computeFilters(this, typ= eName, - filter); + ArcSDEAdapter.FilterSet filters =3D ArcSDEAdapter.computeFil= ters(this, + typeName, filter); =20 Filter result =3D filters.getUnsupportedFilter(); =20 @@ -463,14 +463,21 @@ * @throws IOException if there are errors getting the count */ protected int getCount(Query query) throws IOException { + LOGGER.info("getCount"); + ArcSDEQuery sdeQuery =3D null; =20 try { sdeQuery =3D ArcSDEAdapter.createSeQuery(this, query); + sdeQuery.prepareQuery(); =20 - return sdeQuery.calculateResultCount(); - } catch (DataSourceException ex) { - throw ex; + int count =3D sdeQuery.calculateResultCount(); + LOGGER.info("count: " + count); + + return count; + } catch (Exception ex) { + LOGGER.info("Error calculating count"); + throw new IOException(); } finally { if (sdeQuery !=3D null) { sdeQuery.close(); @@ -493,17 +500,31 @@ * @return the bounds, or null if too expensive * * @throws IOException + * @throws DataSourceException DOCUMENT ME! */ protected Envelope getBounds(Query query) throws IOException { + LOGGER.info("getBounds"); + ArcSDEQuery sdeQuery =3D null; =20 try { sdeQuery =3D ArcSDEAdapter.createSeQuery(this, query); + sdeQuery.prepareQuery(); =20 - return sdeQuery.calculateQueryExtent(); - } catch (DataSourceException ex) { - throw ex; + Envelope ev =3D sdeQuery.calculateQueryExtent(); + LOGGER.info("bounds: " + ev); + + return ev; + } catch (Exception ex) { + if (ex instanceof IOException) { + throw (IOException) ex; + } else { + throw new DataSourceException("unable to get bounds: " + + ex.getMessage(), ex); + } } finally { + LOGGER.info("closing query for bounds"); + if (sdeQuery !=3D null) { sdeQuery.close(); } Modified: geotools/trunk/gt/plugin/arcsde/src/org/geotools/data/arcsde/Ar= cSDEDataStoreFactory.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- geotools/trunk/gt/plugin/arcsde/src/org/geotools/data/arcsde/ArcSDEDa= taStoreFactory.java 2005-02-07 12:20:40 UTC (rev 11152) +++ geotools/trunk/gt/plugin/arcsde/src/org/geotools/data/arcsde/ArcSDEDa= taStoreFactory.java 2005-02-07 13:01:21 UTC (rev 11153) @@ -16,9 +16,11 @@ */ package org.geotools.data.arcsde; =20 +import java.io.IOException; import java.util.Map; import java.util.logging.Logger; =20 +import org.geotools.data.DataSourceException; import org.geotools.data.DataStore; import org.geotools.data.DataStoreFactorySpi; =20 Modified: geotools/trunk/gt/plugin/arcsde/src/org/geotools/data/arcsde/Ar= cSDEFeatureWriter.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- geotools/trunk/gt/plugin/arcsde/src/org/geotools/data/arcsde/ArcSDEFe= atureWriter.java 2005-02-07 12:20:40 UTC (rev 11152) +++ geotools/trunk/gt/plugin/arcsde/src/org/geotools/data/arcsde/ArcSDEFe= atureWriter.java 2005-02-07 13:01:21 UTC (rev 11153) @@ -52,7 +52,7 @@ * @author Jake Fear, jf...@po... * @version */ -public class ArcSDEFeatureWriter implements FeatureWriter { +class ArcSDEFeatureWriter implements FeatureWriter { private static final Logger LOGGER =3D Logger.getLogger(ArcSDEFeatur= eWriter.class.getPackage() = .getName()); private ArcSDEDataStore dataStore; Modified: geotools/trunk/gt/plugin/arcsde/src/org/geotools/data/arcsde/Ar= cSDEQuery.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- geotools/trunk/gt/plugin/arcsde/src/org/geotools/data/arcsde/ArcSDEQu= ery.java 2005-02-07 12:20:40 UTC (rev 11152) +++ geotools/trunk/gt/plugin/arcsde/src/org/geotools/data/arcsde/ArcSDEQu= ery.java 2005-02-07 13:01:21 UTC (rev 11153) @@ -16,14 +16,6 @@ */ package org.geotools.data.arcsde; =20 -import java.io.IOException; -import java.util.logging.Logger; - -import org.geotools.data.DataSourceException; -import org.geotools.feature.FeatureType; -import org.geotools.filter.Filter; -import org.geotools.filter.GeometryEncoderException; - import com.esri.sde.sdk.client.SeColumnDefinition; import com.esri.sde.sdk.client.SeConnection; import com.esri.sde.sdk.client.SeException; @@ -37,31 +29,52 @@ import com.esri.sde.sdk.client.SeRow; import com.esri.sde.sdk.client.SeSqlConstruct; import com.vividsolutions.jts.geom.Envelope; +import org.geotools.data.DataSourceException; +import org.geotools.feature.FeatureType; +import org.geotools.filter.Filter; +import org.geotools.filter.GeometryEncoderException; +import java.io.IOException; +import java.util.logging.Logger; =20 =20 /** * Wrapper class extends SeQuery to hold a SeConnection until close() is * called. * - * @author Gabriel Rold=EF=BF=BDn + * @author Gabriel Rold?n * @version $Id: ArcSDEQuery.java,v 1.1 2004/06/21 15:00:33 cdillard Exp= $ */ -public class ArcSDEQuery { +class ArcSDEQuery { /** DOCUMENT ME! */ private static final Logger LOGGER =3D Logger.getLogger(ArcSDEQuery.= class.getPackage() = .getName()); =20 //private SeConnection connection; + + /** DOCUMENT ME! */ private ArcSDEConnectionPool connectionPool; + + /** DOCUMENT ME! */ private FeatureType schema; + + /** DOCUMENT ME! */ private SeQuery query; + + /** DOCUMENT ME! */ private SeSqlConstruct sqlConstruct; - private FilterSet filters; + + /** DOCUMENT ME! */ + private ArcSDEAdapter.FilterSet filters; + + /** DOCUMENT ME! */ private SeConnection connection =3D null; - /** This field is a bit of a hack, to help with GEOT-264. It seems = spatial - queries on some installs get stale, so I added code to recycle=20 - connections. With this we optimize a bit to only recycle on queries - that use spatial constraints. */ + + /** + * This field is a bit of a hack, to help with GEOT-264. It seems s= patial + * queries on some installs get stale, so I added code to recycle + * connections. With this we optimize a bit to only recycle on quer= ies + * that use spatial constraints. + */ private boolean spatialConstraintsSet =3D false; =20 /** @@ -81,14 +94,12 @@ this.connectionPool =3D pool; this.sqlConstruct =3D sqlConstruct; =20 - - try { connection =3D this.connectionPool.getConnection(); - LOGGER.fine("constructing new sql query with connection: " + - connection + ", propnames: " +=20 - java.util.Arrays.asList(getPropertyNames()) + - " sqlConstruct: " + sqlConstruct); + LOGGER.fine("constructing new sql query with connection: " + + connection + ", propnames: " + + java.util.Arrays.asList(getPropertyNames()) + + " sqlConstruct: " + sqlConstruct); this.query =3D new SeQuery(connection, getPropertyNames(), sqlConstruct); } catch (SeException seEx) { @@ -144,7 +155,7 @@ * * @param filters DOCUMENT ME! */ - public void setFilterSet(FilterSet filters) { + public void setFilterSet(ArcSDEAdapter.FilterSet filters) { this.filters =3D filters; } =20 @@ -153,7 +164,7 @@ * * @return DOCUMENT ME! */ - public FilterSet getFilters() { + public ArcSDEAdapter.FilterSet getFilters() { return filters; } =20 @@ -173,15 +184,27 @@ */ public int calculateResultCount() throws DataSourceException { int count =3D -1; + + /* LOGGER.warning("Calculate Qry: " + query); + try { + SeQueryInfo sdeQueryInfo =3D new SeQueryInfo(); + sdeQueryInfo.setConstruct(sqlConstruct); + SeLayerStats stats =3D query.calculateLayerStatistics(sde= QueryInfo); + count =3D stats.getTotFeatures(); + } catch(Exception e) { + LOGGER.warning("Calculate Count Error: " + e); + } + */ //SeConnection connection =3D null; - /*try { - connection =3D connectionPool.getConnection(); - } catch (UnavailableConnectionException ex) { - throw new DataSourceException(ex.getMessage(), ex); - }*/ + connection =3D connectionPool.getConnection(); + } catch (UnavailableConnectionException ex) { + throw new DataSourceException(ex.getMessage(), ex); + }*/ LOGGER.fine("about to calculate result count"); - SeQuery countQuery =3D null; + + SeQuery countQuery =3D null; + try { if (!filters.getGeometryFilter().equals(Filter.NONE)) { count =3D countResults(connection); @@ -190,8 +213,10 @@ "Using the count(*) optimized result count calculati= on"); =20 String[] columns =3D { "count(*)" }; + //SeQuery countQuery =3D null; - countQuery =3D new SeQuery(connection, columns, sqlConst= ruct); + countQuery =3D new SeQuery(connection, columns, + (SeSqlConstruct) sqlConstruct.clone()); countQuery.prepareQuery(); countQuery.execute(); =20 @@ -206,14 +231,12 @@ + ", could not count, object is " + countObj + " of class " + countObj.getClass()); } - - //count =3D countQuery.fetch().getInteger(0).intValue(); } - } catch (DataSourceException ex) { - throw ex; } catch (SeException ex) { throw new DataSourceException("Error obtaining result count:= " + ex.getMessage(), ex); + } catch (Exception e) { + LOGGER.warning(e.getMessage()); } finally { try { if (countQuery !=3D null) { @@ -222,8 +245,9 @@ } catch (SeException ex) { LOGGER.warning(ex.getMessage()); } + //connectionPool.release(connection); - } + } =20 return count; } @@ -257,6 +281,7 @@ try { countQuery =3D new SeQuery(connection, cols, sqlConstruct); LOGGER.fine("not freeing connection here..."); + //connectionPool.release(connection); countQuery.setSpatialConstraints(SeQuery.SE_OPTIMIZE, false, geometryFilters); @@ -287,66 +312,89 @@ * @return DOCUMENT ME! * * @throws IOException DOCUMENT ME! - * @throws DataSourceException DOCUMENT ME! */ public Envelope calculateQueryExtent() throws IOException { Envelope envelope =3D null; - SeExtent extent =3D null; =20 - if ((this.sqlConstruct.getWhere() =3D=3D null) - && filters.getGeometryFilter().equals(Filter.NONE)) { - LOGGER.fine("Using optimized full layer extent query"); + try { + SeExtent extent =3D null; =20 - SeLayer layer =3D connectionPool.getSdeLayer(sqlConstruct.ge= tTables()[0]); - extent =3D layer.getExtent(); - } else { - LOGGER.fine( - "Building a new SeQuery to consult it's resulting envelo= pe"); + if ((this.sqlConstruct.getWhere() =3D=3D null) + && filters.getGeometryFilter().equals(Filter.NONE)) = { + LOGGER.fine("Using optimized full layer extent query"); =20 - //we can't reuse the fetching query because the extent can't - //be calculated if the stream is opened - SeQuery extentQuery =3D null; - //SeConnection connection =3D null; + SeLayer layer =3D connectionPool.getSdeLayer(sqlConstruc= t + .getTables()[0]); + extent =3D layer.getExtent(); + } else { + LOGGER.fine( + "Building a new SeQuery to consult it's resulting en= velope"); =20 - try { - //connection =3D connectionPool.getConnection(); - extentQuery =3D new SeQuery(connection, getPropertyNames= (), - sqlConstruct); + //we can't reuse the fetching query because the extent c= an't + //be calculated if the stream is opened + SeQuery extentQuery =3D null; =20 - if (filters.getGeometryFilter() !=3D Filter.NONE) { - SeFilter[] geometryFilters =3D filters.createSpatial= Filters(); - extentQuery.setSpatialConstraints(SeQuery.SE_OPTIMIZ= E, - false, geometryFilters); - spatialConstraintsSet =3D true; - } + //SeConnection connection =3D null; + try { + //connection =3D connectionPool.getConnection(); + extentQuery =3D new SeQuery(connection, getPropertyN= ames(), + sqlConstruct); =20 - SeQueryInfo sdeQueryInfo =3D new SeQueryInfo(); - sdeQueryInfo.setConstruct(sqlConstruct); + /* this section causes calculateLayerExtent to throw= an + * indexOutOfBoundsException + =20 + ---- start of section that causes errors + * */ + if (filters.getGeometryFilter() !=3D Filter.NONE) { + SeFilter[] geometryFilters =3D filters + .createSpatialFilters(); + extentQuery.setSpatialConstraints(SeQuery.SE_OPT= IMIZE, + false, geometryFilters); + spatialConstraintsSet =3D true; + } =20 - extent =3D extentQuery.calculateLayerExtent(sdeQueryInfo= ); - } catch (GeometryEncoderException ex) { - throw new DataSourceException( - "Can't create the spatial filter: " + ex.getMessage(= ), ex); - } catch (Exception ex) { - throw new DataSourceException( - "Can't consult the query extent: " + ex.getMessage()= , ex); - } finally { - //connectionPool.release(connection); + /* + ----- end of section that causes errors + */ + SeQueryInfo sdeQueryInfo =3D new SeQueryInfo(); + sdeQueryInfo.setConstruct(sqlConstruct); =20 - try { - if (extentQuery !=3D null) { - extentQuery.close(); + extent =3D extentQuery.calculateLayerExtent(sdeQuery= Info); + + /* } catch (GeometryEncoderException ex) { + System.out.println(ex); + //throw new DataSourceException( + // "Can't create the spatial filter: " + ex.ge= tMessage(), ex); + */ + } catch (Exception ex) { + ex.printStackTrace(); + + //throw new DataSourceException( + // "Can't consult the query extent: " + ex.getMes= sage(), ex); + } finally { + //connectionPool.release(connection); + try { + if (extentQuery !=3D null) { + LOGGER.info("closing inner query for bounds"= ); + extentQuery.close(); + } + } catch (Exception ex) { + LOGGER.warning("error closing query: " + + ex.getMessage()); } - } catch (SeException ex) { - LOGGER.warning("error closing query: " + ex.getMessa= ge()); } } + + if (extent !=3D null) { + envelope =3D new Envelope(extent.getMinX(), extent.getMa= xX(), + extent.getMinY(), extent.getMaxY()); + } + } catch (Exception e) { + LOGGER.info("Error: calculateQueryExtents: " + e); + e.printStackTrace(); } =20 - envelope =3D new Envelope(extent.getMinX(), extent.getMaxX(), - extent.getMinY(), extent.getMaxY()); - - return envelope;=20 + return envelope; } =20 ////////////////////////////////////////////////////////////////////= //// @@ -360,33 +408,27 @@ */ public void close() { try { - LOGGER.finer("close called on ArcSDEQuery: " + toString()); + LOGGER.finer("close called on ArcSDEQuery: " + toString()); + if (query !=3D null) { query.close(); } + } catch (Exception e) { + LOGGER.finer("ArcSDEQuery not cleanly closed."); + e.printStackTrace(); + } =20 - if ( (connectionPool !=3D null) && (connection !=3D null)= ) { - if (spatialConstraintsSet) { - LOGGER.finer("recycling connection: " + connection);=20 - connectionPool.recycle(connection); - } else { - LOGGER.finer("releasing connection: " + connection); - connectionPool.release(connection); - } - connection =3D null; - connectionPool =3D null; - } - =09 - =20 - } catch (SeException ex) { - LOGGER.warning("Trying to close an SeQuery: " + ex.getMessag= e() - + ex.getSeError().getSdeError() + " (" - + ex.getSeError().getErrDesc() + ")"); - ex.printStackTrace(); - } catch (DataSourceException dse) { - LOGGER.warning("error with connectionPool: " + dse.getMessage()); - dse.printStackTrace(); - } + try { + if ((connectionPool !=3D null) && (connection !=3D null)) { + LOGGER.finer("releasing connection: " + connection); + connectionPool.release(connection); + connection =3D null; + connectionPool =3D null; + } + } catch (Exception e) { + LOGGER.finer("ArcSDEQuery not cleanly closed."); + e.printStackTrace(); + } } =20 /** @@ -674,9 +716,13 @@ spatialConstraintsSet =3D true; } =20 + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ public String toString() { - return "Schema: " + schema.getTypeName() + ", query: " + query + - " obj: " + super.toString(); + return "Schema: " + schema.getTypeName() + ", query: " + query + + " obj: " + super.toString(); } - } Modified: geotools/trunk/gt/plugin/arcsde/src/org/geotools/data/arcsde/Ar= cTransactionState.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- geotools/trunk/gt/plugin/arcsde/src/org/geotools/data/arcsde/ArcTrans= actionState.java 2005-02-07 12:20:40 UTC (rev 11152) +++ geotools/trunk/gt/plugin/arcsde/src/org/geotools/data/arcsde/ArcTrans= actionState.java 2005-02-07 13:01:21 UTC (rev 11153) @@ -33,7 +33,7 @@ * @author Jake Fear * @version */ -public class ArcTransactionState implements Transaction.State { +class ArcTransactionState implements Transaction.State { private static final Logger LOGGER =3D Logger.getLogger(ArcTransacti= onState.class.getPackage() = .getName()); private SeConnection connection; Modified: geotools/trunk/gt/plugin/arcsde/src/org/geotools/data/arcsde/Co= nnectionPoolFactory.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- geotools/trunk/gt/plugin/arcsde/src/org/geotools/data/arcsde/Connecti= onPoolFactory.java 2005-02-07 12:20:40 UTC (rev 11152) +++ geotools/trunk/gt/plugin/arcsde/src/org/geotools/data/arcsde/Connecti= onPoolFactory.java 2005-02-07 13:01:21 UTC (rev 11153) @@ -30,7 +30,7 @@ * @author Gabriel Rold?n * @version $Id: ConnectionPoolFactory.java,v 1.1 2004/06/21 15:00:33 cd= illard Exp $ */ -public class ConnectionPoolFactory { +class ConnectionPoolFactory { /** DOCUMENT ME! */ private static Logger LOGGER =3D Logger.getLogger(ConnectionPoolFact= ory.class.getPackage() = .getName()); Modified: geotools/trunk/gt/plugin/arcsde/src/org/geotools/data/arcsde/Ge= ometryBuilder.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- geotools/trunk/gt/plugin/arcsde/src/org/geotools/data/arcsde/Geometry= Builder.java 2005-02-07 12:20:40 UTC (rev 11152) +++ geotools/trunk/gt/plugin/arcsde/src/org/geotools/data/arcsde/Geometry= Builder.java 2005-02-07 13:01:21 UTC (rev 11153) @@ -92,7 +92,7 @@ * propper geometry type * </p> * - * @author Gabriel Rold=E1n + * @author Gabriel Rold?n * @version $Id: GeometryBuilder.java,v 1.4 2004/06/23 15:12:16 jfear Ex= p $ */ public abstract class GeometryBuilder { @@ -428,7 +428,7 @@ * <code>GeometryBuilder</code> specialized in creating JTS * <code>Point</code>s from <code>SeShape</code> points and viceversa * - * @author Gabriel Rold=E1n + * @author Gabriel Rold?n * @version $Id: GeometryBuilder.java,v 1.4 2004/06/23 15:12:16 jfear Ex= p $ */ class PointBuilder extends GeometryBuilder { @@ -492,7 +492,7 @@ * <code>MultiPoint</code>s from <code>SeShape</code> multipoints and * viceversa * - * @author Gabriel Rold=E1n + * @author Gabriel Rold?n * @version $Id: GeometryBuilder.java,v 1.4 2004/06/23 15:12:16 jfear Ex= p $ */ class MultiPointBuilder extends GeometryBuilder { @@ -571,7 +571,7 @@ * <code>GeometryBuilder</code> specialized in creating JTS * <code>LineString</code>s from <code>SeShape</code> linestring and vic= eversa * - * @author Gabriel Rold=E1n + * @author Gabriel Rold?n * @version $Id: GeometryBuilder.java,v 1.4 2004/06/23 15:12:16 jfear Ex= p $ */ class LineStringBuilder extends GeometryBuilder { @@ -650,7 +650,7 @@ * <code>MultiLineString</code>s from <code>SeShape</code> multilinestri= ngs * and viceversa * - * @author Gabriel Rold=E1n + * @author Gabriel Rold?n * @version $Id: GeometryBuilder.java,v 1.4 2004/06/23 15:12:16 jfear Ex= p $ */ class MultiLineStringBuilder extends LineStringBuilder { @@ -741,7 +741,7 @@ * <code>GeometryBuilder</code> specialized in creating JTS * <code>Polygon</code>s from <code>SeShape</code> polygon and viceversa * - * @author Gabriel Rold=E1n + * @author Gabriel Rold?n * @version $Id: GeometryBuilder.java,v 1.4 2004/06/23 15:12:16 jfear Ex= p $ */ class PolygonBuilder extends GeometryBuilder { @@ -868,7 +868,7 @@ * <code>MultiPolygon</code>s from <code>SeShape</code> multipolygons an= d * viceversa * - * @author Gabriel Rold=E1n + * @author Gabriel Rold?n * @version $Id: GeometryBuilder.java,v 1.4 2004/06/23 15:12:16 jfear Ex= p $ */ class MultiPolygonBuilder extends PolygonBuilder { Modified: geotools/trunk/gt/plugin/arcsde/test/org/geotools/data/arcsde/A= rcSDEDataStoreTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- geotools/trunk/gt/plugin/arcsde/test/org/geotools/data/arcsde/ArcSDED= ataStoreTest.java 2005-02-07 12:20:40 UTC (rev 11152) +++ geotools/trunk/gt/plugin/arcsde/test/org/geotools/data/arcsde/ArcSDED= ataStoreTest.java 2005-02-07 13:01:21 UTC (rev 11153) @@ -17,10 +17,7 @@ package org.geotools.data.arcsde; =20 import java.io.IOException; -import java.io.InputStream; -import java.net.URL; import java.util.NoSuchElementException; -import java.util.Properties; import java.util.logging.Logger; =20 import javax.xml.parsers.SAXParser; @@ -47,6 +44,7 @@ import org.geotools.filter.Filter; import org.geotools.filter.FilterFactory; import org.geotools.filter.FilterFilter; +import org.geotools.filter.LogicFilter; import org.geotools.gml.GMLFilterDocument; import org.geotools.gml.GMLFilterGeometry; import org.xml.sax.helpers.ParserAdapter; @@ -58,7 +56,7 @@ /** * SdeDatasource's test cases * - * @author Gabriel Rold=E1n + * @author Gabriel Rold?n * @version $Id: ArcSDEDataStoreTest.java,v 1.1 2004/03/11 00:36:41 grol= dan Exp $ */ public class ArcSDEDataStoreTest extends TestCase { @@ -66,21 +64,9 @@ private static Logger LOGGER =3D Logger.getLogger(ArcSDEDataStoreTes= t.class.getPackage() = .getName()); =20 - /** folder used to load test filters */ - private String dataFolder =3D "/testData/"; + /** DOCUMENT ME! */ + private TestData testData; =20 - /** the set of test parameters loaded from /testData/testparams.prop= erties */ - private Properties conProps =3D null; - - /** the name of the table holding the point test features */ - private String point_table; - - /** the name of the table holding the linestring test features */ - private String line_table; - - /** the name of the table holding the polygon test features */ - private String polygon_table; - /** an ArcSDEDataStore created on setUp() to run tests against */ private DataStore store; =20 @@ -101,9 +87,6 @@ */ public ArcSDEDataStoreTest(String name) { super(name); - - URL folderUrl =3D getClass().getResource("/testData"); - dataFolder =3D folderUrl.toExternalForm() + "/"; } =20 /** @@ -115,23 +98,8 @@ */ protected void setUp() throws Exception { super.setUp(); - conProps =3D new Properties(); - - String propsFile =3D "/testData/testparams.properties"; - InputStream in =3D getClass().getResourceAsStream(propsFile); - - if (in =3D=3D null) { - fail("cannot find test params: " + propsFile); - } - - conProps.load(in); - point_table =3D conProps.getProperty("point_table"); - line_table =3D conProps.getProperty("line_table"); - polygon_table =3D conProps.getProperty("polygon_table"); - assertNotNull("point_table not defined in " + propsFile, point_t= able); - assertNotNull("line_table not defined in " + propsFile, line_tab= le); - assertNotNull("polygon_table not defined in " + propsFile, polyg= on_table); - store =3D getDataStore(); + this.testData =3D new TestData(); + this.store =3D testData.getDataStore(); } =20 /** @@ -140,52 +108,46 @@ * @throws Exception DOCUMENT ME! */ protected void tearDown() throws Exception { - conProps =3D null; + testData =3D null; super.tearDown(); } =20 /** * DOCUMENT ME! + * + * @throws IOException DOCUMENT ME! */ - public void testFinder() { + public void testFinder() throws IOException { DataStore sdeDs =3D null; =20 - try { - sdeDs =3D DataStoreFinder.getDataStore(conProps); + sdeDs =3D DataStoreFinder.getDataStore(testData.getConProps()); =20 - String failMsg =3D sdeDs + " is not an ArcSDEDataStore"; - assertTrue(failMsg, (sdeDs instanceof ArcSDEDataStore)); - LOGGER.info("testFinder OK :" + sdeDs.getClass().getName()); - } catch (IOException ex) { - ex.printStackTrace(); - fail("can't find the SdeDataSource:" + ex.getMessage()); - } + String failMsg =3D sdeDs + " is not an ArcSDEDataStore"; + assertTrue(failMsg, (sdeDs instanceof ArcSDEDataStore)); + LOGGER.info("testFinder OK :" + sdeDs.getClass().getName()); } =20 /** * tests that a connection to a live ArcSDE database can be establis= hed * with the parameters defined int testparams.properties, and a * ArcSDEConnectionPool can be properly setted up + * + * @throws IOException DOCUMENT ME! */ - public void testConnect() { + public void testConnect() throws IOException { LOGGER.info("testing connection to the sde database"); =20 ConnectionPoolFactory pf =3D ConnectionPoolFactory.getInstance()= ; ConnectionConfig congfig =3D null; =20 - try { - congfig =3D new ConnectionConfig(conProps); - } catch (Exception ex) { - pf.clear(); //close and remove all pools - fail(ex.getMessage()); - } + congfig =3D new ConnectionConfig(testData.getConProps()); =20 try { ArcSDEConnectionPool pool =3D pf.getPoolFor(congfig); LOGGER.info("connection succeed " + pool.getPoolSize() + " connections ready"); } catch (DataSourceException ex) { - fail(ex.getMessage()); + throw ex; } finally { pf.clear(); //close and remove all pools } @@ -203,32 +165,29 @@ public void testGetTypeNames() throws IOException { String[] featureTypes =3D store.getTypeNames(); assertNotNull(featureTypes); - testTypeExists(featureTypes, point_table); - testTypeExists(featureTypes, line_table); - testTypeExists(featureTypes, polygon_table); + testTypeExists(featureTypes, testData.getPoint_table()); + testTypeExists(featureTypes, testData.getLine_table()); + testTypeExists(featureTypes, testData.getPolygon_table()); } =20 /** * tests that the schema for the defined tests tables are returned. + * + * @throws IOException DOCUMENT ME! */ - public void testGetSchema() { + public void testGetSchema() throws IOException { FeatureType schema; =20 - try { - schema =3D store.getSchema(point_table); - assertNotNull(schema); - assertTrue(schema.getAttributeCount() > 0); - schema =3D store.getSchema(line_table); - assertNotNull(schema); - assertTrue(schema.getAttributeCount() > 0); - schema =3D store.getSchema(polygon_table); - assertNotNull(schema); - assertTrue(schema.getAttributeCount() > 0); - LOGGER.info("testGetSchema OK: " + schema); - } catch (IOException ex) { - ex.printStackTrace(); - fail(ex.getMessage()); - } + schema =3D store.getSchema(testData.getPoint_table()); + assertNotNull(schema); + assertTrue(schema.getAttributeCount() > 0); + schema =3D store.getSchema(testData.getLine_table()); + assertNotNull(schema); + assertTrue(schema.getAttributeCount() > 0); + schema =3D store.getSchema(testData.getPolygon_table()); + assertNotNull(schema); + assertTrue(schema.getAttributeCount() > 0); + LOGGER.info("testGetSchema OK: " + schema); } =20 /** @@ -244,67 +203,70 @@ * SeConnection, an exception is thrown by de Java ArcSDE API saying= that * a "NETWORK I/O OPERATION FAILED" * </p> + * + * @thr... [truncated message content] |