Revision 14028 branches/v10/extensions/extOracleSpatial/src/es/prodevelop/cit/gvsig/fmap/drivers/jdbc/oracle/OracleSpatialWriter.java
OracleSpatialWriter.java | ||
---|---|---|
46 | 46 |
import com.iver.cit.gvsig.fmap.core.FShape; |
47 | 47 |
import com.iver.cit.gvsig.fmap.core.IFeature; |
48 | 48 |
import com.iver.cit.gvsig.fmap.core.IGeometry; |
49 |
import com.iver.cit.gvsig.fmap.drivers.ConnectionJDBC; |
|
49 | 50 |
import com.iver.cit.gvsig.fmap.drivers.DBLayerDefinition; |
50 | 51 |
import com.iver.cit.gvsig.fmap.drivers.FieldDescription; |
52 |
import com.iver.cit.gvsig.fmap.drivers.IConnection; |
|
51 | 53 |
import com.iver.cit.gvsig.fmap.edition.DefaultRowEdited; |
52 | 54 |
import com.iver.cit.gvsig.fmap.edition.EditionException; |
53 | 55 |
import com.iver.cit.gvsig.fmap.edition.IFieldManager; |
... | ... | |
116 | 118 |
public void preProcess() throws EditionException { |
117 | 119 |
if (tableCreation) { |
118 | 120 |
String srid_epsg = ((DBLayerDefinition) tableDef).getSRID_EPSG(); |
119 |
|
|
120 |
|
|
121 |
|
|
122 |
|
|
121 | 123 |
try { |
122 | 124 |
oracleSRID = OracleSpatialDriver.epsgSridToOracleSrid(srid_epsg); |
123 | 125 |
} catch (Exception e1) { |
... | ... | |
143 | 145 |
oracleSRID, bbox, dim_aux, storeWithSrid); |
144 | 146 |
|
145 | 147 |
//dimensions); |
146 |
Connection conn = ((DBLayerDefinition) tableDef).getConnection(); |
|
148 |
IConnection conn = ((DBLayerDefinition) tableDef).getConnection();
|
|
147 | 149 |
|
148 | 150 |
boolean removed = true; |
149 | 151 |
|
150 | 152 |
try { |
151 |
java.sql.PreparedStatement ps = conn.prepareStatement(_sql_drop);
|
|
153 |
java.sql.PreparedStatement ps = ((ConnectionJDBC)conn).getConnection().prepareStatement(_sql_drop);
|
|
152 | 154 |
ps.execute(); |
153 | 155 |
ps.close(); |
154 | 156 |
} |
... | ... | |
164 | 166 |
} |
165 | 167 |
|
166 | 168 |
try { |
167 |
java.sql.PreparedStatement ps = conn.prepareStatement(_sql_rem_meta);
|
|
169 |
java.sql.PreparedStatement ps = ((ConnectionJDBC)conn).getConnection().prepareStatement(_sql_rem_meta);
|
|
168 | 170 |
ps.execute(); |
169 | 171 |
ps.close(); |
170 | 172 |
} |
... | ... | |
174 | 176 |
} |
175 | 177 |
|
176 | 178 |
try { |
177 |
java.sql.PreparedStatement ps = conn.prepareStatement(_sql_creation);
|
|
179 |
java.sql.PreparedStatement ps = ((ConnectionJDBC)conn).getConnection().prepareStatement(_sql_creation);
|
|
178 | 180 |
ps.execute(); |
179 | 181 |
ps.close(); |
180 | 182 |
} |
... | ... | |
184 | 186 |
} |
185 | 187 |
|
186 | 188 |
try { |
187 |
java.sql.PreparedStatement ps = conn.prepareStatement(_sql_meta);
|
|
189 |
java.sql.PreparedStatement ps = ((ConnectionJDBC)conn).getConnection().prepareStatement(_sql_meta);
|
|
188 | 190 |
ps.execute(); |
189 | 191 |
ps.close(); |
190 | 192 |
} |
... | ... | |
195 | 197 |
} |
196 | 198 |
|
197 | 199 |
try { |
198 |
java.sql.PreparedStatement ps = conn.prepareStatement(_sql_index);
|
|
200 |
java.sql.PreparedStatement ps = ((ConnectionJDBC)conn).getConnection().prepareStatement(_sql_index);
|
|
199 | 201 |
ps.execute(); |
200 | 202 |
ps.close(); |
201 | 203 |
} |
... | ... | |
207 | 209 |
rowIndex = 0; |
208 | 210 |
|
209 | 211 |
try { |
210 |
conn.setAutoCommit(false);
|
|
212 |
((ConnectionJDBC)conn).getConnection().setAutoCommit(false);
|
|
211 | 213 |
} |
212 | 214 |
catch (SQLException e) { |
213 | 215 |
logger.error("Error while setting auto commit FALSE: " + |
... | ... | |
259 | 261 |
IFeature ifeat = (IFeature) row.getLinkedRow(); |
260 | 262 |
String _sql_insert = OracleSpatialDriver.getRowInsertSql( |
261 | 263 |
ifeat, (DBLayerDefinition) tableDef, rowIndex, geoColName); |
262 |
|
|
264 |
|
|
263 | 265 |
Connection conn = ((DBLayerDefinition) tableDef).getConnection(); |
264 |
|
|
266 |
|
|
265 | 267 |
try { |
266 | 268 |
// java.sql.PreparedStatement ps = conn.prepareStatement(_sql_insert); |
267 | 269 |
creationStatement = conn.prepareStatement(_sql_insert); |
... | ... | |
270 | 272 |
// STRUCT st = driver.shapeToStruct(shp, lyrShapeType, conn, oracleSRID, false); |
271 | 273 |
STRUCT st = OracleSpatialDriver.iGeometryToSTRUCT(_ig, lyrShapeType, conn, |
272 | 274 |
oracleSRID, storeWithSrid, aguBien, isGeoCS); |
273 |
|
|
275 |
|
|
274 | 276 |
ps.setObject(1, st); |
275 | 277 |
ps.execute(); |
276 | 278 |
ps.close(); |
277 | 279 |
rowIndex++; |
278 |
|
|
280 |
|
|
279 | 281 |
// getDriver().addRow(irow.getID()); |
280 | 282 |
} catch (Exception ex) { |
281 | 283 |
logger.error("Error while executing SQL for row insertion: " + ex.getMessage(), ex); |
... | ... | |
289 | 291 |
IFeature ifeat = (IFeature) row.getLinkedRow(); |
290 | 292 |
String _sql_insert = OracleSpatialDriver.getRowInsertSql(ifeat, |
291 | 293 |
(DBLayerDefinition) tableDef, rowIndex, geoColName); |
292 |
|
|
293 |
Connection conn = ((DBLayerDefinition) tableDef).getConnection(); |
|
294 |
|
|
295 |
IConnection conn = ((DBLayerDefinition) tableDef).getConnection();
|
|
294 | 296 |
try { |
295 |
java.sql.PreparedStatement ps = conn.prepareStatement(_sql_insert);
|
|
297 |
java.sql.PreparedStatement ps = ((ConnectionJDBC)conn).getConnection().prepareStatement(_sql_insert);
|
|
296 | 298 |
// Shape shp = ifeat.getGeometry().getInternalShape(); |
297 | 299 |
IGeometry _ig = ifeat.getGeometry(); |
298 | 300 |
// STRUCT st = driver.shapeToStruct(shp, lyrShapeType, conn, oracleSRID, false); |
299 | 301 |
STRUCT st; |
300 |
|
|
302 |
|
|
301 | 303 |
if (driver.getDestProjectionOracleCode().compareToIgnoreCase(oracleSRID) == 0) { |
302 |
|
|
304 |
|
|
303 | 305 |
st = OracleSpatialDriver.iGeometryToSTRUCT(_ig, |
304 | 306 |
lyrShapeType, conn, oracleSRID, storeWithSrid, aguBien, |
305 | 307 |
isGeoCS); |
... | ... | |
335 | 337 |
String _sql_delete = OracleSpatialDriver.getRowDeleteSql((DBLayerDefinition) tableDef, |
336 | 338 |
id); |
337 | 339 |
|
338 |
Connection conn = ((DBLayerDefinition) tableDef).getConnection(); |
|
340 |
IConnection conn = ((DBLayerDefinition) tableDef).getConnection();
|
|
339 | 341 |
|
340 | 342 |
try { |
341 |
java.sql.PreparedStatement ps = conn.prepareStatement(_sql_delete);
|
|
343 |
java.sql.PreparedStatement ps = ((ConnectionJDBC)conn).getConnection().prepareStatement(_sql_delete);
|
|
342 | 344 |
ps.execute(); |
343 | 345 |
ps.close(); |
344 | 346 |
|
... | ... | |
382 | 384 |
String _sql_update = OracleSpatialDriver.getRowUpdateSql(ifeat, |
383 | 385 |
(DBLayerDefinition) tableDef, rowIndex, geoColName); |
384 | 386 |
|
385 |
Connection conn = ((DBLayerDefinition) tableDef).getConnection(); |
|
387 |
IConnection conn = ((DBLayerDefinition) tableDef).getConnection();
|
|
386 | 388 |
|
387 | 389 |
try { |
388 |
java.sql.PreparedStatement ps = conn.prepareStatement(_sql_update);
|
|
390 |
java.sql.PreparedStatement ps = ((ConnectionJDBC)conn).getConnection().prepareStatement(_sql_update);
|
|
389 | 391 |
|
390 | 392 |
// Shape shp = ifeat.getGeometry().getInternalShape(); |
391 | 393 |
IGeometry _ig = ifeat.getGeometry(); |
392 | 394 |
STRUCT st; |
393 |
|
|
395 |
|
|
394 | 396 |
if (driver.getDestProjectionOracleCode().compareToIgnoreCase(oracleSRID) == 0) { |
395 |
|
|
397 |
|
|
396 | 398 |
st = OracleSpatialDriver.iGeometryToSTRUCT(_ig, |
397 | 399 |
lyrShapeType, conn, oracleSRID, storeWithSrid, aguBien, |
398 | 400 |
isGeoCS); |
399 |
|
|
401 |
|
|
400 | 402 |
} else { |
401 | 403 |
String viewSrid = driver.getDestProjectionOracleCode(); |
402 | 404 |
boolean isViewSridGedetic = driver.getIsDestProjectionGeog(); |
... | ... | |
425 | 427 |
|
426 | 428 |
public void postProcess() throws EditionException { |
427 | 429 |
if (tableCreation) { |
428 |
Connection conn = ((DBLayerDefinition) tableDef).getConnection(); |
|
430 |
IConnection conn = ((DBLayerDefinition) tableDef).getConnection();
|
|
429 | 431 |
|
430 | 432 |
try { |
431 |
conn.commit();
|
|
432 |
conn.setAutoCommit(true);
|
|
433 |
((ConnectionJDBC)conn).getConnection().commit();
|
|
434 |
((ConnectionJDBC)conn).getConnection().setAutoCommit(true);
|
|
433 | 435 |
} |
434 | 436 |
catch (SQLException e) { |
435 | 437 |
logger.error( |
Also available in: Unified diff