Revision 44297 trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.h2/src/main/java/org/gvsig/fmap/dal/store/h2/H2SpatialExplorer.java
H2SpatialExplorer.java | ||
---|---|---|
1 | 1 |
package org.gvsig.fmap.dal.store.h2; |
2 | 2 |
|
3 |
import java.io.File; |
|
4 |
import java.util.ArrayList; |
|
5 |
import java.util.List; |
|
6 | 3 |
import org.apache.commons.io.FilenameUtils; |
7 | 4 |
import org.gvsig.fmap.dal.DataStore; |
8 |
import org.gvsig.fmap.dal.exception.DataException; |
|
9 | 5 |
import org.gvsig.fmap.dal.exception.InitializeException; |
10 | 6 |
import org.gvsig.fmap.dal.spi.DataServerExplorerProviderServices; |
11 |
import org.gvsig.fmap.dal.spi.FileMultiResource;
|
|
7 |
import org.gvsig.fmap.dal.spi.ZipResourcesStorage;
|
|
12 | 8 |
import org.gvsig.fmap.dal.store.jdbc.JDBCServerExplorerParameters; |
13 | 9 |
import org.gvsig.fmap.dal.store.jdbc2.JDBCHelper; |
14 | 10 |
import org.gvsig.fmap.dal.store.jdbc2.spi.JDBCServerExplorerBase; |
15 |
import org.gvsig.tools.util.ResourcesStorage.Resource; |
|
11 |
import org.gvsig.tools.resourcesstorage.EmptyResourcesStorage; |
|
12 |
import org.gvsig.tools.resourcesstorage.ResourcesStorage; |
|
16 | 13 |
|
17 | 14 |
/** |
18 | 15 |
* |
... | ... | |
31 | 28 |
} |
32 | 29 |
|
33 | 30 |
@Override |
34 |
public Resource getResource(DataStore dataStore, String resourceName) throws DataException { |
|
35 |
String zipPath = this.getParameters().getFile().getAbsolutePath(); |
|
36 |
zipPath = FilenameUtils.removeExtension(zipPath); |
|
37 |
FileMultiResource resource = new FileMultiResource(new File(zipPath), dataStore.getName(),resourceName); |
|
38 |
return resource; |
|
39 |
} |
|
40 |
|
|
41 |
@Override |
|
42 |
public List<Resource> getResources(DataStore dataStore, String resourceName) throws DataException { |
|
43 |
String zipPath = this.getParameters().getFile().getAbsolutePath(); |
|
44 |
zipPath = FilenameUtils.removeExtension(zipPath); |
|
45 |
List<Resource>ress = new ArrayList<>(); |
|
46 |
int n = 0; |
|
47 |
while(true) { |
|
48 |
String multiresourceName; |
|
49 |
if( n==0 ) { |
|
50 |
multiresourceName = resourceName; |
|
51 |
} else { |
|
52 |
multiresourceName = String.valueOf(n)+"."+resourceName; |
|
53 |
} |
|
54 |
FileMultiResource resource = new FileMultiResource(new File(zipPath), dataStore.getName(),multiresourceName); |
|
55 |
if( !resource.exists() ) { |
|
56 |
break; |
|
57 |
} |
|
58 |
ress.add(resource); |
|
59 |
n++; |
|
31 |
public ResourcesStorage getResourcesStorage(DataStore dataStore) { |
|
32 |
ResourcesStorage ress = super.getResourcesStorage(dataStore); |
|
33 |
if( ress instanceof EmptyResourcesStorage ) { |
|
34 |
String zipPath = this.getParameters().getFile().getAbsolutePath(); |
|
35 |
String zipPathName = FilenameUtils.removeExtension(zipPath); |
|
36 |
this.resourcesStorage = new ZipResourcesStorage(zipPathName, dataStore.getName()); |
|
60 | 37 |
} |
61 |
if( ress.isEmpty() ) { |
|
62 |
return null; |
|
63 |
} |
|
64 |
return ress; |
|
38 |
return this.resourcesStorage; |
|
65 | 39 |
} |
40 |
|
|
41 |
|
|
66 | 42 |
} |
Also available in: Unified diff