Revision 12148 trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/edition/VectorialEditableDBAdapter.java
VectorialEditableDBAdapter.java | ||
---|---|---|
40 | 40 |
*/ |
41 | 41 |
public class VectorialEditableDBAdapter extends VectorialEditableAdapter |
42 | 42 |
implements ISpatialDB { |
43 |
private int maxIndex=0; |
|
44 | 43 |
private class MyIterator implements IFeatureIterator { |
45 | 44 |
private Rectangle2D extent = null; |
46 | 45 |
|
... | ... | |
253 | 252 |
|
254 | 253 |
|
255 | 254 |
private Hashtable mapFID2index = new Hashtable(); |
256 |
private Hashtable mapIndex2FID = new Hashtable(); |
|
255 |
// private Hashtable mapIndex2FID = new Hashtable();
|
|
257 | 256 |
/** |
258 | 257 |
* |
259 | 258 |
*/ |
... | ... | |
313 | 312 |
IFeature feat = ova.getFeature(i); |
314 | 313 |
Integer calculatedIndex = new Integer(i); |
315 | 314 |
mapFID2index.put(feat.getID(), calculatedIndex); |
316 |
int featInt=Integer.parseInt(feat.getID()); |
|
317 |
if (maxIndex<featInt){ |
|
318 |
maxIndex=featInt; |
|
319 |
} |
|
320 |
mapIndex2FID.put(calculatedIndex, feat.getID()); |
|
315 |
// mapIndex2FID.put(calculatedIndex, feat.getID()); |
|
321 | 316 |
} |
322 | 317 |
|
323 | 318 |
/* |
... | ... | |
404 | 399 |
// es decir, virtual es el calculatedIndex (no tiene en cuenta los borrados) |
405 | 400 |
// calculatedIndex = indiceExterno + borrados hasta ese punto. |
406 | 401 |
mapFID2index.put(feat.getID(), virtual); |
407 |
mapIndex2FID.put(virtual, feat.getID()); |
|
402 |
// mapIndex2FID.put(virtual, feat.getID());
|
|
408 | 403 |
return calculatedIndex; |
409 | 404 |
|
410 | 405 |
} |
... | ... | |
417 | 412 |
// No hacemos nada con las modificaciones sobre los ?ndices. |
418 | 413 |
// Suponiendo que feat tenga la misma ID que la que hab?a antes. |
419 | 414 |
Integer virtual = new Integer(calculatedIndex); |
420 |
String theIDoriginal = (String) mapIndex2FID.get(virtual); |
|
421 |
if (!theIDoriginal.equals(feat.getID())) |
|
422 |
{ |
|
423 |
AssertionError err = new AssertionError("Fallo al modificar la fila. ID viejo=" + theIDoriginal + " ID nuevo = " + feat.getID()); |
|
424 |
err.printStackTrace(); |
|
425 |
} |
|
415 |
// String theIDoriginal = (String) mapIndex2FID.get(virtual);
|
|
416 |
// if (!theIDoriginal.equals(feat.getID()))
|
|
417 |
// {
|
|
418 |
// AssertionError err = new AssertionError("Fallo al modificar la fila. ID viejo=" + theIDoriginal + " ID nuevo = " + feat.getID());
|
|
419 |
// err.printStackTrace();
|
|
420 |
// }
|
|
426 | 421 |
// hashFIDtoExpansionFile.put(feat.getID(), new Integer(posInExpansionFile)); |
427 | 422 |
mapFID2index.put(feat.getID(), virtual); |
428 |
mapIndex2FID.put(virtual, feat.getID()); |
|
423 |
// mapIndex2FID.put(virtual, feat.getID());
|
|
429 | 424 |
return posAnteriorInExpansionFile; |
430 | 425 |
} |
431 | 426 |
|
... | ... | |
448 | 443 |
// TODO Auto-generated method stub |
449 | 444 |
super.undoAddRow(calculatedIndex,sourceType); |
450 | 445 |
Integer calculated = new Integer(calculatedIndex); |
451 |
String theID = (String) mapIndex2FID.get(calculated); |
|
446 |
// String theID = (String) mapIndex2FID.get(calculated);
|
|
452 | 447 |
mapFID2index.remove(calculated); |
453 |
mapIndex2FID.remove(theID); |
|
448 |
// mapIndex2FID.remove(theID);
|
|
454 | 449 |
|
455 | 450 |
} |
456 | 451 |
public void cancelEdition(int sourceType) throws CancelEditingLayerException { |
457 | 452 |
super.cancelEdition(sourceType); |
458 | 453 |
mapFID2index.clear(); |
459 |
mapIndex2FID.clear(); |
|
454 |
// mapIndex2FID.clear();
|
|
460 | 455 |
} |
461 | 456 |
|
462 | 457 |
public void stopEdition(IWriter writer, int sourceType) throws StopWriterVisitorException{ |
463 | 458 |
super.stopEdition(writer, sourceType); |
464 | 459 |
mapFID2index.clear(); |
465 |
mapIndex2FID.clear(); |
|
460 |
// mapIndex2FID.clear();
|
|
466 | 461 |
} |
467 |
public int getNewIndex(){ |
|
468 |
int index = maxIndex+1; |
|
469 |
while(mapFID2index.containsKey(String.valueOf(index))){ |
|
470 |
index++; |
|
471 |
} |
|
472 |
return index; |
|
473 |
} |
|
474 |
|
|
475 | 462 |
} |
Also available in: Unified diff