Revision 45318
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.basicformats/src/main/java/org/gvsig/basicformats/impl/DefaultCPGFile.java | ||
---|---|---|
10 | 10 |
import org.slf4j.LoggerFactory; |
11 | 11 |
|
12 | 12 |
|
13 |
public class DefaultCPGFile implements CPGFile { |
|
13 |
public class DefaultCPGFile extends AbstractFormatFile implements CPGFile {
|
|
14 | 14 |
|
15 | 15 |
private static final Logger logger = LoggerFactory.getLogger(DefaultPRJFile.class); |
16 | 16 |
|
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.basicformats/src/main/java/org/gvsig/basicformats/impl/DefaultPRJFile.java | ||
---|---|---|
15 | 15 |
import org.slf4j.LoggerFactory; |
16 | 16 |
|
17 | 17 |
|
18 |
public class DefaultPRJFile implements PRJFile { |
|
18 |
public class DefaultPRJFile extends AbstractFormatFile implements PRJFile {
|
|
19 | 19 |
|
20 | 20 |
private static final Logger logger = LoggerFactory.getLogger(DefaultPRJFile.class); |
21 | 21 |
|
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.basicformats/src/main/java/org/gvsig/basicformats/impl/DefaultHDRFile.java | ||
---|---|---|
17 | 17 |
import org.slf4j.Logger; |
18 | 18 |
import org.slf4j.LoggerFactory; |
19 | 19 |
|
20 |
public class DefaultHDRFile implements HDRFile { |
|
20 |
public class DefaultHDRFile extends AbstractFormatFile implements HDRFile {
|
|
21 | 21 |
|
22 | 22 |
// http://resources.esri.com/help/9.3/arcgisdesktop/com/gp_toolref/spatial_analyst_tools/esri_ascii_raster_format.htm |
23 | 23 |
private static final Logger logger = LoggerFactory.getLogger(DefaultHDRFile.class); |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.basicformats/src/main/java/org/gvsig/basicformats/impl/DefaultSTXFile.java | ||
---|---|---|
14 | 14 |
import org.slf4j.LoggerFactory; |
15 | 15 |
|
16 | 16 |
|
17 |
public class DefaultSTXFile implements STXFile { |
|
17 |
public class DefaultSTXFile extends AbstractFormatFile implements STXFile {
|
|
18 | 18 |
|
19 | 19 |
private static final Logger logger = LoggerFactory.getLogger(DefaultSTXFile.class); |
20 | 20 |
|
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.basicformats/src/main/java/org/gvsig/basicformats/impl/DefaultCLRFile.java | ||
---|---|---|
16 | 16 |
import org.slf4j.Logger; |
17 | 17 |
import org.slf4j.LoggerFactory; |
18 | 18 |
|
19 |
public class DefaultCLRFile implements CLRFile { |
|
19 |
public class DefaultCLRFile extends AbstractFormatFile implements CLRFile {
|
|
20 | 20 |
|
21 | 21 |
private static final Logger logger = LoggerFactory.getLogger(DefaultCLRFile.class); |
22 | 22 |
|
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.basicformats/src/main/java/org/gvsig/basicformats/impl/DefaultWLDFile.java | ||
---|---|---|
13 | 13 |
import org.slf4j.LoggerFactory; |
14 | 14 |
|
15 | 15 |
|
16 |
public class DefaultWLDFile implements WLDFile { |
|
16 |
public class DefaultWLDFile extends AbstractFormatFile implements WLDFile {
|
|
17 | 17 |
|
18 | 18 |
private static final Logger logger = LoggerFactory.getLogger(DefaultWLDFile.class); |
19 | 19 |
|
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.basicformats/src/main/java/org/gvsig/basicformats/impl/AbstractFormatFile.java | ||
---|---|---|
1 |
/* |
|
2 |
* To change this license header, choose License Headers in Project Properties. |
|
3 |
* To change this template file, choose Tools | Templates |
|
4 |
* and open the template in the editor. |
|
5 |
*/ |
|
6 |
package org.gvsig.basicformats.impl; |
|
7 |
|
|
8 |
import java.io.File; |
|
9 |
import java.io.IOException; |
|
10 |
import org.gvsig.basicformats.FormatFile; |
|
11 |
|
|
12 |
/** |
|
13 |
* |
|
14 |
* @author fdiaz |
|
15 |
*/ |
|
16 |
public abstract class AbstractFormatFile implements FormatFile { |
|
17 |
|
|
18 |
@Override |
|
19 |
public void writeQuietly(File file) throws IOException { |
|
20 |
try { |
|
21 |
write(file); |
|
22 |
} catch (Exception e) { |
|
23 |
} |
|
24 |
} |
|
25 |
|
|
26 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.basicformats/src/main/java/org/gvsig/basicformats/FormatFile.java | ||
---|---|---|
14 | 14 |
public void read(File file) throws IOException ; |
15 | 15 |
|
16 | 16 |
public void write(File file) throws IOException ; |
17 |
|
|
18 |
public void writeQuietly(File file) throws IOException ; |
|
17 | 19 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.file/org.gvsig.fmap.dal.file.shp/src/main/java/org/gvsig/fmap/dal/store/shp/SHPFilesystemServerProvider.java | ||
---|---|---|
25 | 25 |
|
26 | 26 |
import java.io.File; |
27 | 27 |
import java.io.IOException; |
28 |
|
|
28 |
import org.gvsig.basicformats.FormatsFile; |
|
29 |
import org.gvsig.basicformats.PRJFile; |
|
29 | 30 |
import org.gvsig.fmap.dal.DALLocator; |
30 | 31 |
import org.gvsig.fmap.dal.DataManager; |
31 | 32 |
import org.gvsig.fmap.dal.DataServerExplorer; |
... | ... | |
36 | 37 |
import org.gvsig.fmap.dal.exception.DataException; |
37 | 38 |
import org.gvsig.fmap.dal.exception.InitializeException; |
38 | 39 |
import org.gvsig.fmap.dal.exception.RemoveException; |
39 |
import org.gvsig.fmap.dal.feature.EditableFeatureAttributeDescriptor; |
|
40 | 40 |
import org.gvsig.fmap.dal.feature.EditableFeatureType; |
41 | 41 |
import org.gvsig.fmap.dal.resource.ResourceAction; |
42 | 42 |
import org.gvsig.fmap.dal.resource.exception.ResourceNotifyChangesException; |
... | ... | |
45 | 45 |
import org.gvsig.fmap.dal.resource.spi.ResourceProvider; |
46 | 46 |
import org.gvsig.fmap.dal.serverexplorer.filesystem.AbsolutePathRequiredException; |
47 | 47 |
import org.gvsig.fmap.dal.store.dbf.DBFFilesystemServerProvider; |
48 |
import org.slf4j.Logger; |
|
49 |
import org.slf4j.LoggerFactory; |
|
48 | 50 |
|
49 | 51 |
/** |
50 | 52 |
* @author jmvivo |
51 | 53 |
* |
52 | 54 |
*/ |
53 | 55 |
public class SHPFilesystemServerProvider extends DBFFilesystemServerProvider { |
56 |
|
|
57 |
protected static final Logger LOGGER = LoggerFactory.getLogger(SHPFilesystemServerProvider.class); |
|
54 | 58 |
|
59 |
|
|
60 |
@Override |
|
55 | 61 |
public boolean accept(File pathname) { |
56 | 62 |
return pathname.getName().toLowerCase().endsWith(".shp"); |
57 | 63 |
} |
58 | 64 |
|
65 |
@Override |
|
59 | 66 |
public int getMode() { |
60 | 67 |
return DataServerExplorer.MODE_GEOMETRY|DataServerExplorer.MODE_FEATURE; |
61 | 68 |
} |
62 | 69 |
|
70 |
@Override |
|
63 | 71 |
public boolean canCreate() { |
64 | 72 |
return true; |
65 | 73 |
} |
66 | 74 |
|
67 |
// private FileResource[] createResources(File[] files) |
|
68 |
// throws InitializeException { |
|
69 |
// FileResource[] result = new FileResource[files.length]; |
|
70 |
// for (int i = 0; i < files.length; i++) { |
|
71 |
// result[i] = this.createResource(files[i]); |
|
72 |
// } |
|
73 |
// |
|
74 |
// return result; |
|
75 |
// } |
|
76 |
|
|
77 | 75 |
private ResourceProvider createResource(File shpFile, File[] otherFiles) |
78 | 76 |
throws InitializeException { |
79 | 77 |
|
... | ... | |
105 | 103 |
// return resource; |
106 | 104 |
// } |
107 | 105 |
|
106 |
@Override |
|
108 | 107 |
public boolean canCreate(NewDataStoreParameters parameters) { |
109 | 108 |
if (!super.canCreate(parameters)) { |
110 | 109 |
return false; |
... | ... | |
129 | 128 |
return true; |
130 | 129 |
} |
131 | 130 |
|
131 |
@Override |
|
132 | 132 |
public boolean closeResourceRequested(ResourceProvider resource) { |
133 | 133 |
// while it is using a resource anyone can't close it |
134 | 134 |
return false; |
135 | 135 |
} |
136 | 136 |
|
137 |
@Override |
|
137 | 138 |
public void create(NewDataStoreParameters parameters, boolean overwrite) |
138 | 139 |
throws CreateException { |
139 | 140 |
|
... | ... | |
197 | 198 |
// beginResources(resources); |
198 | 199 |
|
199 | 200 |
resource.execute(new ResourceAction() { |
201 |
@Override |
|
200 | 202 |
public Object run() throws Exception { |
201 | 203 |
SHPFeatureWriter writer = |
202 | 204 |
new SHPFeatureWriter(getDataStoreProviderName()); |
203 | 205 |
|
204 | 206 |
writer.begin(params, fType, 0); |
207 |
|
|
208 |
PRJFile prjFile = FormatsFile.createPRJFile(); |
|
209 |
prjFile.setCRS(params.getCRS()); |
|
210 |
prjFile.writeQuietly(params.getFile()); |
|
205 | 211 |
|
206 | 212 |
writer.end(); |
207 | 213 |
return null; |
... | ... | |
217 | 223 |
// removeConsumer(resources); |
218 | 224 |
resource.removeConsumer(this); |
219 | 225 |
} |
220 |
}
|
|
226 |
}
|
|
221 | 227 |
|
222 |
// private boolean closeResources(FileResource[] resources) |
|
223 |
// throws ResourceException { |
|
224 |
// for (int i = 0; i < resources.length; i++) { |
|
225 |
// // TODO |
|
226 |
// // if (!resources[i].closeRequest()){ |
|
227 |
// // return false; |
|
228 |
// // } |
|
229 |
// resources[i].closeRequest(); |
|
230 |
// } |
|
231 |
// return true; |
|
232 |
// |
|
233 |
// } |
|
234 |
|
|
235 | 228 |
private void removeConsumer(FileResource[] resources) { |
236 |
for (int i = 0; i < resources.length; i++) {
|
|
237 |
resources[i].removeConsumer(this);
|
|
238 |
}
|
|
229 |
for (FileResource resource : resources) {
|
|
230 |
resource.removeConsumer(this);
|
|
231 |
}
|
|
239 | 232 |
} |
240 | 233 |
|
241 | 234 |
// private void endResources(FileResource[] resources) { |
... | ... | |
246 | 239 |
|
247 | 240 |
private void notifyChangesResources(FileResource[] resources) |
248 | 241 |
throws ResourceNotifyChangesException { |
249 |
for (int i = 0; i < resources.length; i++) {
|
|
250 |
resources[i].notifyChanges();
|
|
251 |
}
|
|
242 |
for (FileResource resource : resources) {
|
|
243 |
resource.notifyChanges();
|
|
244 |
}
|
|
252 | 245 |
|
253 | 246 |
} |
254 | 247 |
|
255 |
// private void beginResources(FileResource[] resources) |
|
256 |
// throws ResourceExecuteException { |
|
257 |
// for (int i = 0; i < resources.length; i++) { |
|
258 |
// resources[i].begin(); |
|
259 |
// } |
|
260 |
// |
|
261 |
// } |
|
262 |
|
|
248 |
@Override |
|
263 | 249 |
public NewDataStoreParameters getCreateParameters() { |
264 | 250 |
SHPNewStoreParameters params = |
265 | 251 |
(SHPNewStoreParameters) super.getCreateParameters(); |
... | ... | |
271 | 257 |
return params; |
272 | 258 |
} |
273 | 259 |
|
260 |
@Override |
|
274 | 261 |
protected NewDataStoreParameters createInstanceNewDataStoreParameters() { |
275 | 262 |
return new SHPNewStoreParameters(); |
276 | 263 |
} |
277 | 264 |
|
265 |
@Override |
|
278 | 266 |
public String getDataStoreProviderName() { |
279 | 267 |
return SHPStoreProvider.NAME; |
280 | 268 |
} |
281 | 269 |
|
270 |
@Override |
|
282 | 271 |
public String getDescription() { |
283 | 272 |
return SHPStoreProvider.DESCRIPTION; |
284 | 273 |
} |
285 | 274 |
|
275 |
@Override |
|
286 | 276 |
public DataStoreParameters getParameters(File file) throws DataException { |
287 | 277 |
DataManager manager = DALLocator.getDataManager(); |
288 | 278 |
SHPStoreParameters params = |
... | ... | |
292 | 282 |
|
293 | 283 |
} |
294 | 284 |
|
285 |
@Override |
|
295 | 286 |
public void remove(DataStoreParameters parameters) throws RemoveException { |
296 | 287 |
SHPStoreParameters params = (SHPStoreParameters) parameters; |
297 | 288 |
|
... | ... | |
307 | 298 |
File[] otherFiles = new File[] { shxFile, dbfFile }; |
308 | 299 |
final ResourceProvider resource; |
309 | 300 |
try { |
310 |
// resources = this.createResources(files); |
|
311 | 301 |
resource = createResource(shpFile, otherFiles); |
312 | 302 |
resource.closeRequest(); |
313 | 303 |
resource.closeRequest(); |
314 |
// closeResources(resources); |
|
315 | 304 |
} catch (DataException e1) { |
316 | 305 |
throw new RemoveException(shpFile.getPath(), e1); |
317 | 306 |
} |
318 | 307 |
|
319 | 308 |
try { |
320 |
// beginResources(resources); |
|
321 | 309 |
resource.execute(new ResourceAction() { |
310 |
@Override |
|
322 | 311 |
public Object run() throws Exception { |
323 | 312 |
deleteFile(shpFile); |
324 | 313 |
deleteFile(dbfFile); |
... | ... | |
327 | 316 |
return null; |
328 | 317 |
} |
329 | 318 |
}); |
330 |
// for (int i = 0; i < files.length; i++) { |
|
331 |
// if (!files[i].exists()) { |
|
332 |
// continue; |
|
333 |
// } |
|
334 |
// if (!files[i].delete()) { |
|
335 |
// throw new RemoveException(this.getDataStoreProviderName(), |
|
336 |
// new IOException()); // FIXME Exception |
|
337 |
// } |
|
338 |
// } |
|
339 |
|
|
340 |
// notifyChangesResources(resources); |
|
341 | 319 |
} catch (Exception e) { |
342 | 320 |
throw new RemoveException(this.getDataStoreProviderName(), e); |
343 | 321 |
} finally { |
344 |
// endResources(resources); |
|
345 |
// removeConsumer(resources); |
|
346 | 322 |
resource.removeConsumer(this); |
347 | 323 |
} |
348 | 324 |
} |
... | ... | |
354 | 330 |
} |
355 | 331 |
} |
356 | 332 |
|
333 |
@Override |
|
357 | 334 |
public String getResourceRootPathName(DataStore dataStore) { |
358 | 335 |
SHPStoreParameters shpParams = (SHPStoreParameters) dataStore.getParameters(); |
359 | 336 |
return removeFileExtension(shpParams.getSHPFile()); |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.file/org.gvsig.fmap.dal.file.shp/pom.xml | ||
---|---|---|
79 | 79 |
<artifactId>org.gvsig.expressionevaluator.geometry.lib.impl</artifactId> |
80 | 80 |
<scope>test</scope> |
81 | 81 |
</dependency> |
82 |
|
|
82 |
<dependency> |
|
83 |
<groupId>org.gvsig</groupId> |
|
84 |
<artifactId>org.gvsig.basicformats</artifactId> |
|
85 |
<scope>compile</scope> |
|
86 |
</dependency> |
|
83 | 87 |
</dependencies> |
84 | 88 |
|
85 | 89 |
|
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.app/org.gvsig.app.mainplugin/pom.xml | ||
---|---|---|
418 | 418 |
<scope>runtime</scope> |
419 | 419 |
</dependency> |
420 | 420 |
|
421 |
<dependency> |
|
422 |
<groupId>org.gvsig</groupId> |
|
423 |
<artifactId>org.gvsig.basicformats</artifactId> |
|
424 |
<scope>runtime</scope> |
|
425 |
</dependency> |
|
421 | 426 |
|
422 | 427 |
|
423 | 428 |
<!-- Dependencias de los test --> |
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.app/org.gvsig.app.mainplugin/src/main/assembly/gvsig-plugin-package.xml | ||
---|---|---|
120 | 120 |
<include>org.jpedal:jpedal_lgpl</include> |
121 | 121 |
|
122 | 122 |
<include>zql:zql</include> |
123 |
|
|
124 |
<include>org.gvsig:org.gvsig.basicformats</include> |
|
123 | 125 |
</includes> |
124 | 126 |
</dependencySet> |
125 | 127 |
</dependencySets> |
Also available in: Unified diff