Revision 1993 branches/Fmap_GisPlanet/libraries/libFMap/src/com/iver/cit/gvsig/fmap/layers/LayerFactory.java
LayerFactory.java | ||
---|---|---|
55 | 55 |
import com.hardcode.gdbms.engine.values.ValueFactory; |
56 | 56 |
|
57 | 57 |
import com.iver.cit.gvsig.fmap.DriverException; |
58 |
import com.iver.cit.gvsig.fmap.ProgressListener; |
|
58 | 59 |
import com.iver.cit.gvsig.fmap.core.IGeometry; |
59 | 60 |
import com.iver.cit.gvsig.fmap.drivers.DriverIOException; |
60 | 61 |
import com.iver.cit.gvsig.fmap.drivers.RasterDriver; |
... | ... | |
410 | 411 |
* @throws ClassNotFoundException |
411 | 412 |
* @throws |
412 | 413 |
*/ |
413 |
public static FLayer createDisconnectedDBLayer(VectorialDatabaseDriver driver, String layerName, IProjection proj) throws SQLException, IOException, DriverIOException, DriverLoadException, NoSuchTableException, com.hardcode.gdbms.engine.data.driver.DriverException, ClassNotFoundException { |
|
414 |
public static FLayer createDisconnectedDBLayer(VectorialDatabaseDriver driver, String layerName, IProjection proj, ProgressListener listener) throws SQLException, IOException, DriverIOException, DriverLoadException, NoSuchTableException, com.hardcode.gdbms.engine.data.driver.DriverException, ClassNotFoundException {
|
|
414 | 415 |
VectorialDisconnectedDBAdapter dbAdapter = new VectorialDisconnectedDBAdapter(); |
415 | 416 |
dbAdapter.setDriver(driver); |
416 | 417 |
DataSource ds = dbAdapter.getRecordset(); |
... | ... | |
432 | 433 |
DataWare dw = local.getDataWare(); |
433 | 434 |
dw.beginTrans(); |
434 | 435 |
|
436 |
if (listener == null){ |
|
437 |
listener = new ProgressListener() { |
|
438 |
/** |
|
439 |
* @see com.iver.cit.gvsig.fmap.ProgressListener#progress(int) |
|
440 |
*/ |
|
441 |
public void progress(int n) { |
|
442 |
//do nothing |
|
443 |
} |
|
444 |
}; |
|
445 |
} |
|
446 |
|
|
435 | 447 |
for (int i = 0; i < dbAdapter.getShapeCount(); i++) { |
436 |
dw.insertRow(ds.getPKValue(i)); |
|
448 |
Value[] row = new Value[ds.getFieldCount() + 1]; |
|
449 |
|
|
437 | 450 |
byte[] bytes = dbAdapter.getShape(i).toWKB(); |
438 |
Value v = ValueFactory.createValue(bytes);
|
|
439 |
dw.setFieldValue(i, 0, v); |
|
451 |
row[0] = ValueFactory.createValue(bytes);
|
|
452 |
|
|
440 | 453 |
for (int j = 0; j < ds.getFieldCount(); j++) { |
441 |
dw.setFieldValue(i, j+1, ds.getFieldValue(i, j));
|
|
454 |
row[j+1] = ds.getFieldValue(i, j);
|
|
442 | 455 |
} |
456 |
|
|
457 |
dw.insertFilledRow(row); |
|
458 |
listener.progress(100 * i / dbAdapter.getShapeCount()); |
|
443 | 459 |
} |
444 | 460 |
|
445 | 461 |
dw.commitTrans(); |
... | ... | |
448 | 464 |
VectorialJDBCDriver cacheDriver = (VectorialJDBCDriver) LayerFactory.getDM().getDriver("HSQLDB Driver"); |
449 | 465 |
Class.forName("org.hsqldb.jdbcDriver"); |
450 | 466 |
|
451 |
cacheDriver.setData(java.sql.DriverManager.getConnection("jdbc:hsqldb:file:" + database, "sa", ""), dsName, StringUtilities.getComaSeparated(local.getFieldNames()), "", local.getPrimaryKeys()[0]); |
|
467 |
cacheDriver.setData(java.sql.DriverManager.getConnection("jdbc:hsqldb:file:" + database, "sa", ""), dsName, StringUtilities.getComaSeparated(local.getFieldNames()), "", local.getPrimaryKeys()[0]+1);
|
|
452 | 468 |
return createDBLayer(cacheDriver, layerName, proj); |
453 | 469 |
} |
454 | 470 |
|
Also available in: Unified diff