Revision 10627 trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/layers/VectorialDBAdapter.java
VectorialDBAdapter.java | ||
---|---|---|
41 | 41 |
package com.iver.cit.gvsig.fmap.layers; |
42 | 42 |
|
43 | 43 |
import java.awt.geom.Rectangle2D; |
44 |
import java.io.IOException; |
|
45 |
import java.sql.Connection; |
|
46 |
import java.sql.ResultSet; |
|
47 |
import java.sql.SQLException; |
|
48 |
import java.sql.Statement; |
|
49 | 44 |
|
50 | 45 |
import com.hardcode.driverManager.DriverLoadException; |
46 |
import com.hardcode.gdbms.driver.exceptions.ReadDriverException; |
|
51 | 47 |
import com.hardcode.gdbms.engine.data.DataSource; |
52 | 48 |
import com.hardcode.gdbms.engine.data.DataSourceFactory; |
53 | 49 |
import com.hardcode.gdbms.engine.data.NoSuchTableException; |
54 | 50 |
import com.hardcode.gdbms.engine.data.driver.ObjectDriver; |
55 | 51 |
import com.hardcode.gdbms.engine.values.Value; |
56 |
import com.iver.cit.gvsig.fmap.DriverException; |
|
57 | 52 |
import com.iver.cit.gvsig.fmap.core.DefaultFeature; |
58 |
import com.iver.cit.gvsig.fmap.core.FShape; |
|
59 | 53 |
import com.iver.cit.gvsig.fmap.core.IFeature; |
60 | 54 |
import com.iver.cit.gvsig.fmap.core.IGeometry; |
61 | 55 |
import com.iver.cit.gvsig.fmap.drivers.DBLayerDefinition; |
62 |
import com.iver.cit.gvsig.fmap.drivers.DriverIOException; |
|
63 | 56 |
import com.iver.cit.gvsig.fmap.drivers.IFeatureIterator; |
64 | 57 |
import com.iver.cit.gvsig.fmap.drivers.VectorialDatabaseDriver; |
65 | 58 |
|
... | ... | |
78 | 71 |
* Solamente cuando el contador est? a cero pide al driver que conecte con |
79 | 72 |
* la base de datos |
80 | 73 |
*/ |
81 |
public void start() { |
|
82 |
try { |
|
83 |
((VectorialDatabaseDriver)driver).open(); |
|
84 |
} catch (DriverException e) { |
|
85 |
// TODO Auto-generated catch block |
|
86 |
e.printStackTrace(); |
|
87 |
} |
|
88 |
} |
|
74 |
public void start() throws ReadDriverException { |
|
75 |
((VectorialDatabaseDriver)driver).open(); |
|
76 |
} |
|
89 | 77 |
|
90 | 78 |
/** |
91 | 79 |
* decrementa el contador de n?mero de aperturas y cuando llega a cero pide |
92 | 80 |
* al driver que cierre la conexion con el servidor de base de datos |
93 | 81 |
*/ |
94 |
public void stop() { |
|
82 |
public void stop() throws ReadDriverException {
|
|
95 | 83 |
((VectorialDatabaseDriver)driver).close(); |
96 | 84 |
} |
97 | 85 |
|
... | ... | |
106 | 94 |
{ |
107 | 95 |
return ((VectorialDatabaseDriver)driver).getFeatureIterator(sql); |
108 | 96 |
}*/ |
109 |
public IFeatureIterator getFeatureIterator(Rectangle2D r, String strEPSG) throws DriverException |
|
97 |
public IFeatureIterator getFeatureIterator(Rectangle2D r, String strEPSG) throws ReadDriverException
|
|
110 | 98 |
{ |
111 | 99 |
return ((VectorialDatabaseDriver)driver).getFeatureIterator(r, strEPSG); |
112 | 100 |
} |
... | ... | |
114 | 102 |
/* (non-Javadoc) |
115 | 103 |
* @see com.iver.cit.gvsig.fmap.layers.ISpatialDB#getFeatureIterator(java.awt.geom.Rectangle2D, java.lang.String, java.lang.String[]) |
116 | 104 |
*/ |
117 |
public IFeatureIterator getFeatureIterator(Rectangle2D r, String strEPSG, String[] alphaNumericFieldsNeeded) throws DriverException |
|
105 |
public IFeatureIterator getFeatureIterator(Rectangle2D r, String strEPSG, String[] alphaNumericFieldsNeeded) throws ReadDriverException
|
|
118 | 106 |
{ |
119 | 107 |
return ((VectorialDatabaseDriver)driver).getFeatureIterator(r, strEPSG, alphaNumericFieldsNeeded); |
120 | 108 |
} |
... | ... | |
145 | 133 |
/** |
146 | 134 |
* @see com.iver.cit.gvsig.fmap.layers.ReadableVectorial#getShape(int) |
147 | 135 |
*/ |
148 |
public IGeometry getShape(int index) throws DriverIOException {
|
|
136 |
public IGeometry getShape(int index) throws ReadDriverException {
|
|
149 | 137 |
IGeometry geom = null; |
150 |
try { |
|
151 |
geom = ((VectorialDatabaseDriver)driver).getShape(index); |
|
152 |
} catch (IOException e) { |
|
153 |
throw new DriverIOException(e); |
|
154 |
} |
|
155 |
return geom; |
|
138 |
geom = ((VectorialDatabaseDriver)driver).getShape(index); |
|
139 |
return geom; |
|
156 | 140 |
} |
157 | 141 |
|
158 | 142 |
/** |
159 | 143 |
* @see com.iver.cit.gvsig.fmap.layers.ReadableVectorial#getShapeType() |
160 | 144 |
*/ |
161 |
public int getShapeType() throws DriverIOException {
|
|
145 |
public int getShapeType() throws ReadDriverException {
|
|
162 | 146 |
return ((VectorialDatabaseDriver)driver).getShapeType(); |
163 | 147 |
} |
164 | 148 |
|
165 | 149 |
/** |
150 |
* @throws ReadDriverException |
|
166 | 151 |
* @see com.iver.cit.gvsig.fmap.layers.VectorialAdapter#getRecordset() |
167 | 152 |
*/ |
168 |
public SelectableDataSource getRecordset() throws DriverLoadException { |
|
153 |
public SelectableDataSource getRecordset() throws DriverLoadException, ReadDriverException {
|
|
169 | 154 |
if (driver instanceof ObjectDriver) |
170 | 155 |
{ |
171 | 156 |
if (ds == null) |
... | ... | |
175 | 160 |
ds = new SelectableDataSource(LayerFactory.getDataSourceFactory().createRandomDataSource(name, DataSourceFactory.AUTOMATIC_OPENING)); |
176 | 161 |
} catch (NoSuchTableException e) { |
177 | 162 |
throw new RuntimeException(e); |
178 |
} catch (com.hardcode.gdbms.engine.data.driver.DriverException e) { |
|
179 |
throw new RuntimeException(e); |
|
180 | 163 |
} |
181 | 164 |
} |
182 | 165 |
} |
... | ... | |
186 | 169 |
/* (non-Javadoc) |
187 | 170 |
* @see com.iver.cit.gvsig.fmap.layers.VectorialAdapter#getFeature(int) |
188 | 171 |
*/ |
189 |
public IFeature getFeature(int numReg) throws DriverException { |
|
172 |
public IFeature getFeature(int numReg) throws ReadDriverException {
|
|
190 | 173 |
IGeometry geom; |
191 | 174 |
IFeature feat = null; |
192 | 175 |
try { |
... | ... | |
203 | 186 |
} |
204 | 187 |
|
205 | 188 |
feat = new DefaultFeature(geom, regAtt, theID); |
206 |
} catch (DriverIOException e) { |
|
207 |
throw new DriverException(e); |
|
208 | 189 |
} catch (DriverLoadException e) { |
209 |
throw new DriverException(e); |
|
210 |
} catch (com.hardcode.gdbms.engine.data.driver.DriverException e) { |
|
211 |
throw new DriverException(e); |
|
190 |
throw new ReadDriverException(getDriver().getName(),e); |
|
212 | 191 |
} |
213 | 192 |
return feat; |
214 | 193 |
} |
... | ... | |
222 | 201 |
} |
223 | 202 |
|
224 | 203 |
public int getRowIndexByFID(IFeature feat) { |
225 |
return ((VectorialDatabaseDriver) driver).getRowIndexByFID(feat);
|
|
204 |
return ((VectorialDatabaseDriver) driver).getRowIndexByFID(feat); |
|
226 | 205 |
} |
227 | 206 |
} |
Also available in: Unified diff