Revision 10627 trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/edition/VectorialEditableDBAdapter.java
VectorialEditableDBAdapter.java | ||
---|---|---|
4 | 4 |
package com.iver.cit.gvsig.fmap.edition; |
5 | 5 |
|
6 | 6 |
import java.awt.geom.Rectangle2D; |
7 |
import java.io.IOException; |
|
8 | 7 |
import java.util.ArrayList; |
9 | 8 |
import java.util.Hashtable; |
10 | 9 |
import java.util.List; |
11 | 10 |
|
12 | 11 |
import com.hardcode.driverManager.Driver; |
13 |
import com.iver.cit.gvsig.fmap.DriverException; |
|
14 |
import com.iver.cit.gvsig.fmap.DriverIOExceptionType; |
|
12 |
import com.hardcode.gdbms.driver.exceptions.ReadDriverException; |
|
13 |
import com.iver.cit.gvsig.exceptions.commands.EditionCommandException; |
|
14 |
import com.iver.cit.gvsig.exceptions.expansionfile.ExpansionFileReadException; |
|
15 |
import com.iver.cit.gvsig.exceptions.expansionfile.ExpansionFileWriteException; |
|
16 |
import com.iver.cit.gvsig.exceptions.expansionfile.OpenExpansionFileException; |
|
17 |
import com.iver.cit.gvsig.exceptions.layers.StartEditionLayerException; |
|
18 |
import com.iver.cit.gvsig.exceptions.visitors.StartWriterVisitorException; |
|
15 | 19 |
import com.iver.cit.gvsig.fmap.core.IFeature; |
16 | 20 |
import com.iver.cit.gvsig.fmap.core.IRow; |
17 | 21 |
import com.iver.cit.gvsig.fmap.core.v02.FConverter; |
18 | 22 |
import com.iver.cit.gvsig.fmap.drivers.DBLayerDefinition; |
19 |
import com.iver.cit.gvsig.fmap.drivers.DriverIOException; |
|
20 | 23 |
import com.iver.cit.gvsig.fmap.drivers.IFeatureIterator; |
21 | 24 |
import com.iver.cit.gvsig.fmap.drivers.VectorialDatabaseDriver; |
22 | 25 |
import com.iver.cit.gvsig.fmap.layers.ISpatialDB; |
... | ... | |
52 | 55 |
|
53 | 56 |
private boolean bOriginalCursorOpened = true; |
54 | 57 |
|
55 |
public MyIterator(Rectangle2D r, String strEPSG) throws DriverException { |
|
58 |
public MyIterator(Rectangle2D r, String strEPSG) throws ReadDriverException {
|
|
56 | 59 |
extent = r; |
57 | 60 |
epsg = strEPSG; |
58 | 61 |
orig = (VectorialDBAdapter) ova; |
... | ... | |
61 | 64 |
getFeaturesFromExpansionFile(); |
62 | 65 |
} |
63 | 66 |
|
64 |
public boolean hasNext() throws DriverException {
|
|
67 |
public boolean hasNext() throws ReadDriverException, ExpansionFileReadException {
|
|
65 | 68 |
feat = null; |
66 | 69 |
int calculatedIndex = -1; |
67 | 70 |
if (bOriginalCursorOpened) // Si hay originales (Es porque si se ha |
... | ... | |
107 | 110 |
} else { // Si est? en el fichero de expansi?n |
108 | 111 |
int num = ((Integer) relations.get(integer)).intValue(); |
109 | 112 |
IRowEdited auxR; |
110 |
try { |
|
111 |
auxR = expansionFile.getRow(num); |
|
112 |
feat = (IFeature) auxR.getLinkedRow().cloneRow(); |
|
113 |
// feat = (IFeature) auxR.getLinkedRow(); |
|
114 |
alreadyDone.put(integer, feat); |
|
115 |
} catch (IOException e) { |
|
116 |
DriverIOExceptionType type = |
|
117 |
new DriverIOExceptionType(); |
|
118 |
type.setDriverName(getDriver().getName()); |
|
119 |
throw new DriverException(e, type); |
|
120 |
} |
|
121 |
|
|
122 |
|
|
123 |
|
|
124 |
|
|
125 |
|
|
113 |
auxR = expansionFile.getRow(num); |
|
114 |
feat = (IFeature) auxR.getLinkedRow().cloneRow(); |
|
115 |
// feat = (IFeature) auxR.getLinkedRow(); |
|
116 |
alreadyDone.put(integer, feat); |
|
126 | 117 |
} // else |
127 | 118 |
} // if tercer bOriginalCursorOpened |
128 | 119 |
} // if segundo bOriginalCursorOpened |
... | ... | |
131 | 122 |
// Si ya no hay m?s de las originales, todav?a tenemos |
132 | 123 |
// que revisar las a?adidas que hay en el fichero |
133 | 124 |
// de expansi?n |
134 |
try { |
|
135 | 125 |
while ((idFromExpansion < expansionFile.getSize()) && (feat == null)) |
136 | 126 |
{ |
137 | 127 |
IRowEdited rowEd = expansionFile.getRow(idFromExpansion); |
... | ... | |
188 | 178 |
} |
189 | 179 |
idFromExpansion++; |
190 | 180 |
} |
191 |
} catch (IOException e) { |
|
192 |
throw new DriverException(e); |
|
193 |
} |
|
194 | 181 |
} |
195 | 182 |
|
196 | 183 |
if (calculatedIndex == -1) |
... | ... | |
210 | 197 |
|
211 | 198 |
} |
212 | 199 |
|
213 |
public IFeature next() throws DriverException {
|
|
200 |
public IFeature next() { |
|
214 | 201 |
return feat; |
215 | 202 |
} |
216 | 203 |
|
217 |
public void closeIterator() throws DriverException { |
|
204 |
public void closeIterator() throws ReadDriverException {
|
|
218 | 205 |
// TODO Auto-generated method stub |
219 | 206 |
|
220 | 207 |
} |
... | ... | |
241 | 228 |
* @see com.iver.cit.gvsig.fmap.edition.VectorialEditableAdapter#getFeatures(java.awt.geom.Rectangle2D, |
242 | 229 |
* java.lang.String) |
243 | 230 |
*/ |
244 |
public IRowEdited[] getFeatures(Rectangle2D r, String strEPSG) |
|
245 |
throws DriverException { |
|
231 |
public IRowEdited[] getFeatures(Rectangle2D r, String strEPSG) throws ReadDriverException, ExpansionFileReadException { |
|
246 | 232 |
ArrayList aux = new ArrayList(); |
247 | 233 |
IFeatureIterator featIt = getFeatureIterator(r, strEPSG, null); |
248 | 234 |
int numEntities = 0; |
... | ... | |
266 | 252 |
* |
267 | 253 |
* @see com.iver.cit.gvsig.fmap.edition.VectorialEditableAdapter#startEdition() |
268 | 254 |
*/ |
269 |
public void startEdition(int sourceType) throws EditionException {
|
|
255 |
public void startEdition(int sourceType) throws StartWriterVisitorException {
|
|
270 | 256 |
isEditing = true; |
271 | 257 |
Driver drv = ova.getDriver(); |
272 | 258 |
if (drv instanceof IWriteable) |
... | ... | |
304 | 290 |
* r.getHeight()); index.insert(e, new Integer(i)); } } catch |
305 | 291 |
* (DriverIOException e) { throw new EditionException(e); |
306 | 292 |
*/ |
307 |
} catch (IOException e) {
|
|
308 |
throw new EditionException(e);
|
|
309 |
} catch (DriverIOException e) {
|
|
310 |
throw new EditionException(e);
|
|
311 |
} catch (DriverException e) {
|
|
312 |
throw new EditionException(e);
|
|
293 |
} catch (ReadDriverException e) {
|
|
294 |
throw new StartWriterVisitorException(writer.getName(),e);
|
|
295 |
} catch (ExpansionFileReadException e) {
|
|
296 |
throw new StartWriterVisitorException(writer.getName(),e);
|
|
297 |
} catch (OpenExpansionFileException e) {
|
|
298 |
throw new StartWriterVisitorException(writer.getName(),e);
|
|
313 | 299 |
} |
314 | 300 |
|
315 | 301 |
System.err.println("Se han metido en el ?ndice " |
... | ... | |
318 | 304 |
} |
319 | 305 |
|
320 | 306 |
public IFeatureIterator getFeatureIterator(Rectangle2D r, String strEPSG) |
321 |
throws DriverException { |
|
307 |
throws ReadDriverException {
|
|
322 | 308 |
return new MyIterator(r, strEPSG); |
323 | 309 |
} |
324 | 310 |
|
325 | 311 |
public IFeatureIterator getFeatureIterator(Rectangle2D r, String strEPSG, |
326 |
String[] alphaNumericFieldsNeeded) throws DriverException { |
|
312 |
String[] alphaNumericFieldsNeeded) throws ReadDriverException {
|
|
327 | 313 |
return new MyIterator(r, strEPSG); |
328 | 314 |
} |
329 | 315 |
|
... | ... | |
340 | 326 |
/* (non-Javadoc) |
341 | 327 |
* @see com.iver.cit.gvsig.fmap.edition.VectorialEditableAdapter#doAddRow(com.iver.cit.gvsig.fmap.core.IRow) |
342 | 328 |
*/ |
343 |
public int doAddRow(IRow feat, int sourceType) throws DriverIOException, IOException {
|
|
329 |
public int doAddRow(IRow feat, int sourceType) throws ReadDriverException, ExpansionFileWriteException {
|
|
344 | 330 |
int calculatedIndex = super.doAddRow(feat, sourceType); |
345 | 331 |
// Integer posInExpansionFile = (Integer) relations.get(new Integer(calculatedIndex)); |
346 | 332 |
Integer virtual = new Integer(calculatedIndex); // calculatedIndex es igual al numero de shapes originales + el numero de entidades a?adidas. |
... | ... | |
355 | 341 |
/* (non-Javadoc) |
356 | 342 |
* @see com.iver.cit.gvsig.fmap.edition.VectorialEditableAdapter#doModifyRow(int, com.iver.cit.gvsig.fmap.core.IRow) |
357 | 343 |
*/ |
358 |
public int doModifyRow(int calculatedIndex, IRow feat,int sourceType) throws IOException, DriverIOException {
|
|
344 |
public int doModifyRow(int calculatedIndex, IRow feat,int sourceType) throws ReadDriverException, ExpansionFileWriteException, ExpansionFileReadException{
|
|
359 | 345 |
int posAnteriorInExpansionFile = super.doModifyRow(calculatedIndex, feat, sourceType); // devolver? -1 si es original |
360 | 346 |
// No hacemos nada con las modificaciones sobre los ?ndices. |
361 | 347 |
// Suponiendo que feat tenga la misma ID que la que hab?a antes. |
... | ... | |
375 | 361 |
/* (non-Javadoc) |
376 | 362 |
* @see com.iver.cit.gvsig.fmap.edition.VectorialEditableAdapter#doRemoveRow(int) |
377 | 363 |
*/ |
378 |
public IRow doRemoveRow(int index,int sourceType) throws DriverIOException, IOException {
|
|
364 |
public IRow doRemoveRow(int index,int sourceType) throws ReadDriverException, ExpansionFileReadException {
|
|
379 | 365 |
// Le entra un calculatedIndex, as? que delRows tiene guardados |
380 | 366 |
// los ?ndices internos, no los externos. |
381 | 367 |
IFeature deletedFeat = (IFeature) super.doRemoveRow(index, sourceType); |
... | ... | |
387 | 373 |
/* (non-Javadoc) |
388 | 374 |
* @see com.iver.cit.gvsig.fmap.edition.VectorialEditableAdapter#undoAddRow(int) |
389 | 375 |
*/ |
390 |
public void undoAddRow(int calculatedIndex, int sourceType) throws DriverIOException, IOException {
|
|
376 |
public void undoAddRow(int calculatedIndex, int sourceType) throws EditionCommandException {
|
|
391 | 377 |
// TODO Auto-generated method stub |
392 | 378 |
super.undoAddRow(calculatedIndex,sourceType); |
393 | 379 |
Integer calculated = new Integer(calculatedIndex); |
Also available in: Unified diff