Revision 5115 trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/edition/VectorialEditableDBAdapter.java

View differences:

VectorialEditableDBAdapter.java
1 1
/**
2
 * 
2
 *
3 3
 */
4 4
package com.iver.cit.gvsig.fmap.edition;
5 5

  
......
26 26

  
27 27
/**
28 28
 * @author fjp
29
 * 
29
 *
30 30
 */
31 31
public class VectorialEditableDBAdapter extends VectorialEditableAdapter
32 32
		implements ISpatialDB {
......
72 72
				if (bOriginalCursorOpened) {
73 73
					feat = featIt.next();
74 74
					int originalIndex = dbDriver.getRowIndexByFID(feat);
75
					
75

  
76 76
					// Iteramos hasta que encontremos alguno no borrado.
77 77
					// Aqu? suponemos que el orden es el original. Si no, no funcionar?.
78 78
					if (delRows.get(originalIndex)) // Si est? borrado
......
131 131
						Integer calculated = (Integer) mapFID2index.get(aux.getID());
132 132
						calculatedIndex = calculated.intValue();
133 133
						System.out.println("El elemento idFromExpansion = " + idFromExpansion + " es " + aux.getID());
134
						
134

  
135 135
						// Revisamos los borrados
136 136
						if (delRows.get(calculatedIndex) == true)
137 137
						{
......
142 142
								idFromExpansion++;
143 143
								rowEd = expansionFile.getRow(idFromExpansion);
144 144
								aux = (IFeature) rowEd.getLinkedRow();
145
								
146
								
147
								
145

  
146

  
147

  
148 148
								Integer auxCalculated = (Integer) mapFID2index.get(aux.getID());
149 149
								calculatedIndex = auxCalculated.intValue();
150 150
								// Si no est? borrado y es una entidad v?lida, que est? siendo usada (no es algo que est? en el expansionFile sin usarse)
......
156 156
								}
157 157
								else
158 158
								{
159
									System.out.println("El elemento idFromExpansion = " + idFromExpansion + " est? borrado");									
159
									System.out.println("El elemento idFromExpansion = " + idFromExpansion + " est? borrado");
160 160
								}
161 161
							}
162 162
							if (bFound)
163 163
							{
164 164
								calculated = new Integer(calculatedIndex);
165 165
								rowEd = expansionFile.getRow(idFromExpansion);
166
								aux = (IFeature) rowEd.getLinkedRow();							
166
								aux = (IFeature) rowEd.getLinkedRow();
167 167
							}
168 168
							else
169 169
							{
......
217 217
		}
218 218
	}
219 219

  
220
	
220

  
221 221
	private Hashtable mapFID2index = new Hashtable();
222 222
	private Hashtable mapIndex2FID = new Hashtable();
223 223
	/**
224
	 * 
224
	 *
225 225
	 */
226 226
	public VectorialEditableDBAdapter() {
227 227
		super();
......
230 230

  
231 231
	/*
232 232
	 * (non-Javadoc)
233
	 * 
233
	 *
234 234
	 * @see com.iver.cit.gvsig.fmap.edition.VectorialEditableAdapter#getFeatures(java.awt.geom.Rectangle2D,
235 235
	 *      java.lang.String)
236 236
	 */
......
256 256

  
257 257
	/*
258 258
	 * (non-Javadoc)
259
	 * 
259
	 *
260 260
	 * @see com.iver.cit.gvsig.fmap.edition.VectorialEditableAdapter#startEdition()
261 261
	 */
262 262
	public void startEdition() throws EditionException {
......
283 283
			 * try { g = ((DefaultFeature) ova.getFeature(i)).getGeometry(); }
284 284
			 * catch (DriverException e1) { // TODO Auto-generated catch block
285 285
			 * e1.printStackTrace(); }
286
			 * 
286
			 *
287 287
			 * if (g == null) { continue; }
288
			 * 
288
			 *
289 289
			 * Rectangle2D r = g.getBounds2D(); Envelope e = new
290 290
			 * Envelope(r.getX(), r.getX() + r.getWidth(), r.getY(), r.getY() +
291 291
			 * r.getHeight()); index.insert(e, new Integer(i)); } } catch
......
306 306

  
307 307
	/*
308 308
	 * (non-Javadoc)
309
	 * 
309
	 *
310 310
	 * @see com.iver.cit.gvsig.fmap.edition.VectorialEditableAdapter#stopEdition(com.iver.cit.gvsig.fmap.edition.IWriter)
311 311
	 */
312 312
	public void stopEdition(IWriter writer) throws EditionException {
......
348 348
		/* int resul;
349 349
		VectorialDBAdapter orig = (VectorialDBAdapter) ova;
350 350
		resul = orig.getRowIndexByFID(feat);
351
		int externalIndex = -1; 
351
		int externalIndex = -1;
352 352
		if (resul == -1)
353 353
		{
354
			// No est? en los originales. Si no est? borrado, 
354
			// No est? en los originales. Si no est? borrado,
355 355
			// estar? en el fichero de expansi?n.
356 356
			Integer integer = (Integer) hashFIDtoExpansionFile.get(feat.getID());
357 357
			resul = integer.intValue();
......
363 363
				// TODO Auto-generated catch block
364 364
				e.printStackTrace();
365 365
			}
366
				
367
			
366

  
367

  
368 368
		}
369 369
		else
370 370
		{
371
			externalIndex = getInversedIndex(resul); 
371
			externalIndex = getInversedIndex(resul);
372 372
		} */
373 373
		Integer calculatedIndex = (Integer) mapFID2index.get(feat.getID());
374 374
		return getInversedIndex(calculatedIndex.intValue());
......
386 386
		mapFID2index.put(feat.getID(), virtual);
387 387
		mapIndex2FID.put(virtual, feat.getID());
388 388
		return calculatedIndex;
389
		
389

  
390 390
	}
391 391

  
392 392
	/* (non-Javadoc)
393 393
	 * @see com.iver.cit.gvsig.fmap.edition.VectorialEditableAdapter#doModifyRow(int, com.iver.cit.gvsig.fmap.core.IRow)
394 394
	 */
395
	public int doModifyRow(int calculatedIndex, IRow feat) throws IOException, DriverIOException {
396
		int posAnteriorInExpansionFile = super.doModifyRow(calculatedIndex, feat); // devolver? -1 si es original
395
	public int doModifyRow(int calculatedIndex, IRow feat,int type) throws IOException, DriverIOException {
396
		int posAnteriorInExpansionFile = super.doModifyRow(calculatedIndex, feat, type); // devolver? -1 si es original
397 397
		// No hacemos nada con las modificaciones sobre los ?ndices.
398 398
		// Suponiendo que feat tenga la misma ID que la que hab?a antes.
399 399
		Integer virtual = new Integer(calculatedIndex);
......
405 405
		}
406 406
		// hashFIDtoExpansionFile.put(feat.getID(), new Integer(posInExpansionFile));
407 407
		mapFID2index.put(feat.getID(), virtual);
408
		mapIndex2FID.put(virtual, feat.getID());		
408
		mapIndex2FID.put(virtual, feat.getID());
409 409
		return posAnteriorInExpansionFile;
410 410
	}
411 411

  
......
481 481
		String theID = (String) mapIndex2FID.get(calculated);
482 482
		mapFID2index.remove(calculated);
483 483
		mapIndex2FID.remove(theID);
484
		
484

  
485 485
	}
486 486

  
487 487
	/* (non-Javadoc)

Also available in: Unified diff