Revision 26252 branches/v2_0_0_prep/libraries/libFMap_dalfile/src/org/gvsig/fmap/dal/store/shp/SHPStoreProvider.java
SHPStoreProvider.java | ||
---|---|---|
33 | 33 |
import org.gvsig.fmap.dal.DataTypes; |
34 | 34 |
import org.gvsig.fmap.dal.exception.CloseException; |
35 | 35 |
import org.gvsig.fmap.dal.exception.DataException; |
36 |
import org.gvsig.fmap.dal.exception.FileNotFoundException; |
|
37 | 36 |
import org.gvsig.fmap.dal.exception.InitializeException; |
38 |
import org.gvsig.fmap.dal.exception.OpenException; |
|
39 | 37 |
import org.gvsig.fmap.dal.exception.ReadException; |
40 |
import org.gvsig.fmap.dal.exception.UnsupportedVersionException; |
|
41 | 38 |
import org.gvsig.fmap.dal.feature.EditableFeatureAttributeDescriptor; |
42 | 39 |
import org.gvsig.fmap.dal.feature.EditableFeatureType; |
43 | 40 |
import org.gvsig.fmap.dal.feature.Feature; |
... | ... | |
62 | 59 |
import org.gvsig.tools.dynobject.DynClass; |
63 | 60 |
import org.gvsig.tools.dynobject.DynField; |
64 | 61 |
import org.gvsig.tools.dynobject.DynObjectManager; |
62 |
import org.gvsig.tools.dynobject.exception.DynFieldNotFoundException; |
|
65 | 63 |
import org.gvsig.tools.persistence.PersistenceException; |
66 | 64 |
import org.gvsig.tools.persistence.PersistentState; |
67 | 65 |
|
... | ... | |
93 | 91 |
new Object[] { this.shpParams.getSHXFileName() }); |
94 | 92 |
shxResource.addConsumer(this); |
95 | 93 |
|
94 |
// TODO .prj |
|
95 |
|
|
96 | 96 |
// FIXME |
97 | 97 |
this.dynObject = (DelegatedDynObject) ToolsLocator |
98 | 98 |
.getDynObjectManager().createDynObject(DYNCLASS); |
... | ... | |
100 | 100 |
this.shpFile = new SHPFile(this.shpParams); |
101 | 101 |
} |
102 | 102 |
|
103 |
private void resourcesBegin() throws ResourceBeginException { |
|
103 |
protected void resourcesBegin() throws ResourceBeginException { |
|
104 |
super.resourcesBegin(); |
|
104 | 105 |
this.shpResource.begin(); |
105 | 106 |
this.shxResource.begin(); |
107 |
// TODO .prj |
|
108 |
|
|
106 | 109 |
} |
107 | 110 |
|
108 |
private void resourcesEnd() { |
|
111 |
protected void resourcesEnd() { |
|
112 |
super.resourcesEnd(); |
|
109 | 113 |
this.shpResource.end(); |
110 | 114 |
this.shxResource.end(); |
115 |
// TODO .prj |
|
116 |
|
|
111 | 117 |
} |
112 | 118 |
|
113 | 119 |
/** |
114 | 120 |
* |
115 | 121 |
* @throws ResourceNotifyChangesException |
116 | 122 |
*/ |
117 |
private void resourcesNotifyChanges() throws ResourceNotifyChangesException { |
|
123 |
protected void resourcesNotifyChanges() |
|
124 |
throws ResourceNotifyChangesException { |
|
125 |
super.resourcesNotifyChanges(); |
|
118 | 126 |
this.shpResource.notifyChanges(); |
119 | 127 |
this.shxResource.notifyChanges(); |
128 |
// TODO .prj |
|
129 |
|
|
120 | 130 |
} |
121 | 131 |
|
122 | 132 |
/** |
123 | 133 |
* @throws ResourceNotifyCloseException |
124 | 134 |
* |
125 | 135 |
*/ |
126 |
private void resourcesNotifyClose() throws ResourceNotifyCloseException { |
|
136 |
protected void resourcesNotifyClose() throws ResourceNotifyCloseException { |
|
137 |
super.resourcesNotifyClose(); |
|
127 | 138 |
this.shpResource.notifyClose(); |
128 | 139 |
this.shxResource.notifyClose(); |
140 |
// TODO .prj |
|
141 |
|
|
129 | 142 |
} |
130 | 143 |
|
144 |
public void dispose() throws CloseException { |
|
145 |
super.dispose(); |
|
146 |
this.shpResource.removeConsumer(this); |
|
147 |
this.shxResource.removeConsumer(this); |
|
148 |
this.shpResource = null; |
|
149 |
this.shxResource = null; |
|
150 |
this.shpParams = null; |
|
151 |
this.writer = null; |
|
152 |
this.shpFile = null; |
|
153 |
} |
|
154 |
|
|
131 | 155 |
/** |
132 | 156 |
* @throws ResourceNotifyOpenException |
133 | 157 |
* |
134 | 158 |
*/ |
135 |
private void resourcesOpen() throws ResourceNotifyOpenException { |
|
159 |
protected void resourcesOpen() throws ResourceNotifyOpenException { |
|
160 |
super.resourcesOpen(); |
|
136 | 161 |
this.shpResource.notifyOpen(); |
137 | 162 |
this.shxResource.notifyOpen(); |
138 | 163 |
} |
... | ... | |
332 | 357 |
FeatureData data = new SHPFeatureData(this, (DefaultFeatureType) type); |
333 | 358 |
return data; |
334 | 359 |
} |
335 |
public void open() throws OpenException { |
|
336 |
super.open(); |
|
337 |
if (this.shpFile.isOpen()) { |
|
338 |
return; |
|
339 |
} |
|
340 |
try { |
|
341 |
this.resourcesBegin(); |
|
342 |
} catch (ResourceBeginException e) { |
|
343 |
throw new OpenException(this.getName(), e); |
|
344 |
} |
|
345 |
try { |
|
346 |
this.shpFile.open(); |
|
347 |
this.resourcesOpen(); |
|
348 | 360 |
|
349 | 361 |
|
362 |
protected void openFile() throws IOException, DataException { |
|
363 |
super.openFile(); |
|
364 |
this.shpFile.open(); |
|
350 | 365 |
|
351 |
// load metadata |
|
352 |
// TODO: Load .prj data |
|
353 |
// this.dynObject.setDynValue( |
|
354 |
// DYNFIELD_SRSORIGINALPARAMETERS_NAME, |
|
355 |
// this.shpFile.??); |
|
366 |
} |
|
356 | 367 |
|
357 |
this.dynObject.setDynValue("DefaultSRS", this.shpFile |
|
358 |
.getSRSParameters()); |
|
368 |
protected void loadMetadataValues() throws DynFieldNotFoundException, |
|
369 |
ReadException { |
|
370 |
super.loadMetadataValues(); |
|
371 |
// TODO: Load .prj data |
|
372 |
// this.dynObject.setDynValue( |
|
373 |
// DYNFIELD_SRSORIGINALPARAMETERS_NAME, |
|
374 |
// this.shpFile.??); |
|
359 | 375 |
|
376 |
this.dynObject.setDynValue("DefaultSRS", this.shpFile |
|
377 |
.getSRSParameters()); |
|
360 | 378 |
|
361 |
this.dynObject.setDynValue("Envelope", shpFile.getFullExtent());
|
|
379 |
this.dynObject.setDynValue("Envelope", shpFile.getFullExtent()); |
|
362 | 380 |
|
363 |
} catch (UnsupportedVersionException e) { |
|
364 |
throw new OpenException(this.getName(), e); |
|
365 |
} catch (ResourceNotifyOpenException e) { |
|
366 |
throw new OpenException(this.getName(), e); |
|
367 |
} catch (FileNotFoundException e) { |
|
368 |
throw new OpenException(this.getName(), e); |
|
369 |
} catch (DataException e) { |
|
370 |
throw new OpenException(this.getName(), e); |
|
371 |
} finally { |
|
372 |
this.resourcesEnd(); |
|
373 |
} |
|
374 | 381 |
} |
375 | 382 |
|
376 |
public void close() throws CloseException { |
|
377 |
super.close(); |
|
383 |
|
|
384 |
protected void closeFile() throws CloseException { |
|
385 |
super.closeFile(); |
|
378 | 386 |
if (!this.shpFile.isOpen()) { |
379 | 387 |
return; |
380 | 388 |
} |
381 |
try { |
|
382 |
this.resourcesBegin(); |
|
383 |
} catch (ResourceBeginException e) { |
|
384 |
throw new CloseException(this.getName(), e); |
|
385 |
} |
|
386 |
try { |
|
387 |
this.shpFile.close(); |
|
388 |
this.resourcesNotifyClose(); |
|
389 |
|
|
390 |
} catch (ResourceNotifyCloseException e) { |
|
391 |
throw new CloseException(this.getName(), e); |
|
392 |
} finally { |
|
393 |
this.resourcesEnd(); |
|
394 |
} |
|
389 |
this.shpFile.close(); |
|
395 | 390 |
} |
396 | 391 |
|
397 | 392 |
public boolean canWriteGeometry(int geometryType) throws DataException { |
... | ... | |
421 | 416 |
|
422 | 417 |
try { |
423 | 418 |
this.resourcesBegin(); |
424 |
this.getDBFResource().begin(); |
|
425 | 419 |
} catch (ResourceBeginException e1) { |
426 | 420 |
throw new PerformEditingException(this.getName(), e1); |
427 | 421 |
} |
... | ... | |
448 | 442 |
writer.end(); |
449 | 443 |
|
450 | 444 |
this.close(); |
451 |
|
|
452 | 445 |
if (!this.shpParams.getDBFFile().delete()) { |
453 | 446 |
throw new PerformEditingException(this.getName(), |
454 | 447 |
new IOException(this.shpParams.getDBFFileName())); |
... | ... | |
476 | 469 |
|
477 | 470 |
|
478 | 471 |
this.resourcesNotifyChanges(); |
479 |
this.getDBFResource().notifyChanges(); |
|
472 |
this.initFeatureType(); |
|
473 |
|
|
480 | 474 |
} catch (Exception e) { |
481 | 475 |
throw new PerformEditingException(this.getName(), e); |
482 | 476 |
} finally { |
483 | 477 |
this.resourcesEnd(); |
484 |
this.getDBFResource().end(); |
|
485 | 478 |
} |
486 | 479 |
|
487 | 480 |
|
Also available in: Unified diff