Revision 12132 branches/v10/libraries/libFMap/src/com/iver/cit/gvsig/fmap/edition/VectorialEditableDBAdapter.java
VectorialEditableDBAdapter.java | ||
---|---|---|
30 | 30 |
*/ |
31 | 31 |
public class VectorialEditableDBAdapter extends VectorialEditableAdapter |
32 | 32 |
implements ISpatialDB { |
33 |
private int maxIndex=0; |
|
34 | 33 |
private class MyIterator implements IFeatureIterator { |
35 | 34 |
private Rectangle2D extent = null; |
36 | 35 |
|
... | ... | |
226 | 225 |
|
227 | 226 |
|
228 | 227 |
private Hashtable mapFID2index = new Hashtable(); |
229 |
private Hashtable mapIndex2FID = new Hashtable(); |
|
228 |
// private Hashtable mapIndex2FID = new Hashtable();
|
|
230 | 229 |
/** |
231 | 230 |
* |
232 | 231 |
*/ |
... | ... | |
293 | 292 |
IFeature feat = ova.getFeature(i); |
294 | 293 |
Integer calculatedIndex = new Integer(i); |
295 | 294 |
mapFID2index.put(feat.getID(), calculatedIndex); |
296 |
int featInt=Integer.parseInt(feat.getID()); |
|
297 |
if (maxIndex<featInt){ |
|
298 |
maxIndex=featInt; |
|
299 |
} |
|
300 |
mapIndex2FID.put(calculatedIndex, feat.getID()); |
|
295 |
// mapIndex2FID.put(calculatedIndex, feat.getID()); |
|
301 | 296 |
} |
302 | 297 |
|
303 | 298 |
/* |
... | ... | |
356 | 351 |
// es decir, virtual es el calculatedIndex (no tiene en cuenta los borrados) |
357 | 352 |
// calculatedIndex = indiceExterno + borrados hasta ese punto. |
358 | 353 |
mapFID2index.put(feat.getID(), virtual); |
359 |
mapIndex2FID.put(virtual, feat.getID()); |
|
354 |
// mapIndex2FID.put(virtual, feat.getID());
|
|
360 | 355 |
return calculatedIndex; |
361 | 356 |
|
362 | 357 |
} |
... | ... | |
369 | 364 |
// No hacemos nada con las modificaciones sobre los ?ndices. |
370 | 365 |
// Suponiendo que feat tenga la misma ID que la que hab?a antes. |
371 | 366 |
Integer virtual = new Integer(calculatedIndex); |
372 |
String theIDoriginal = (String) mapIndex2FID.get(virtual); |
|
373 |
if (!theIDoriginal.equals(feat.getID())) |
|
374 |
{ |
|
375 |
AssertionError err = new AssertionError("Fallo al modificar la fila. ID viejo=" + theIDoriginal + " ID nuevo = " + feat.getID()); |
|
376 |
err.printStackTrace(); |
|
377 |
} |
|
367 |
// String theIDoriginal = (String) mapIndex2FID.get(virtual);
|
|
368 |
// if (!theIDoriginal.equals(feat.getID()))
|
|
369 |
// {
|
|
370 |
// AssertionError err = new AssertionError("Fallo al modificar la fila. ID viejo=" + theIDoriginal + " ID nuevo = " + feat.getID());
|
|
371 |
// err.printStackTrace();
|
|
372 |
// }
|
|
378 | 373 |
// hashFIDtoExpansionFile.put(feat.getID(), new Integer(posInExpansionFile)); |
379 | 374 |
mapFID2index.put(feat.getID(), virtual); |
380 |
mapIndex2FID.put(virtual, feat.getID()); |
|
375 |
// mapIndex2FID.put(virtual, feat.getID());
|
|
381 | 376 |
return posAnteriorInExpansionFile; |
382 | 377 |
} |
383 | 378 |
|
... | ... | |
400 | 395 |
// TODO Auto-generated method stub |
401 | 396 |
super.undoAddRow(calculatedIndex,sourceType); |
402 | 397 |
Integer calculated = new Integer(calculatedIndex); |
403 |
String theID = (String) mapIndex2FID.get(calculated); |
|
398 |
// String theID = (String) mapIndex2FID.get(calculated);
|
|
404 | 399 |
mapFID2index.remove(calculated); |
405 |
mapIndex2FID.remove(theID); |
|
400 |
// mapIndex2FID.remove(theID);
|
|
406 | 401 |
|
407 | 402 |
} |
408 | 403 |
|
409 | 404 |
public void cancelEdition(int sourceType) throws IOException { |
410 | 405 |
super.cancelEdition(sourceType); |
411 | 406 |
mapFID2index.clear(); |
412 |
mapIndex2FID.clear(); |
|
407 |
// mapIndex2FID.clear();
|
|
413 | 408 |
} |
414 | 409 |
|
415 | 410 |
public void stopEdition(IWriter writer, int sourceType) throws EditionException { |
416 | 411 |
super.stopEdition(writer, sourceType); |
417 | 412 |
mapFID2index.clear(); |
418 |
mapIndex2FID.clear(); |
|
413 |
// mapIndex2FID.clear();
|
|
419 | 414 |
} |
420 | 415 |
|
421 |
public int getNewIndex() throws com.hardcode.gdbms.engine.data.driver.DriverException { |
|
422 |
int index = maxIndex+1;
|
|
423 |
while(mapFID2index.containsKey(String.valueOf(index))){ |
|
424 |
index++; |
|
425 |
} |
|
426 |
return index; |
|
427 |
} |
|
416 |
// public int getNewIndex() throws com.hardcode.gdbms.engine.data.driver.DriverException {
|
|
417 |
// int index = maxIndex;
|
|
418 |
// while(mapFID2index.containsKey(String.valueOf(index))){
|
|
419 |
// index++;
|
|
420 |
// }
|
|
421 |
// return index;
|
|
422 |
// }
|
|
428 | 423 |
|
429 | 424 |
|
430 | 425 |
} |
Also available in: Unified diff