svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.plugin / org.gvsig.h2spatial / org.gvsig.h2spatial.h2gis132 / org.gvsig.h2spatial.h2gis132.provider / src / main / java / org / gvsig / fmap / dal / store / h2 / H2SpatialExplorer.java @ 46414
History | View | Annotate | Download (2.21 KB)
1 | 45472 | jjdelcerro | package org.gvsig.fmap.dal.store.h2; |
---|---|---|---|
2 | |||
3 | 45867 | jjdelcerro | import java.io.File; |
4 | 45472 | jjdelcerro | import org.apache.commons.lang3.StringUtils; |
5 | import org.gvsig.fmap.dal.DataStore; |
||
6 | import org.gvsig.fmap.dal.exception.InitializeException; |
||
7 | import org.gvsig.fmap.dal.spi.DataServerExplorerProviderServices; |
||
8 | import org.gvsig.fmap.dal.store.jdbc.JDBCServerExplorerParameters; |
||
9 | import org.gvsig.fmap.dal.store.jdbc2.JDBCHelper; |
||
10 | import org.gvsig.fmap.dal.store.jdbc2.spi.JDBCServerExplorerBase; |
||
11 | import org.gvsig.tools.resourcesstorage.ResourcesStorage; |
||
12 | |||
13 | /**
|
||
14 | *
|
||
15 | * @author jjdelcerro
|
||
16 | */
|
||
17 | @SuppressWarnings("UseSpecificCatch") |
||
18 | public class H2SpatialExplorer extends JDBCServerExplorerBase { |
||
19 | |||
20 | public H2SpatialExplorer(JDBCServerExplorerParameters parameters, DataServerExplorerProviderServices services, JDBCHelper helper) throws InitializeException { |
||
21 | super(parameters, services, helper);
|
||
22 | } |
||
23 | |||
24 | @Override
|
||
25 | public H2SpatialExplorerParameters getParameters() {
|
||
26 | return (H2SpatialExplorerParameters) super.getParameters(); |
||
27 | } |
||
28 | |||
29 | @Override
|
||
30 | public ResourcesStorage getResourcesStorage(DataStore dataStore) {
|
||
31 | ResourcesStorage ress = super.getResourcesStorage(dataStore);
|
||
32 | // if( ress instanceof EmptyResourcesStorage ) {
|
||
33 | // String zipPath = this.getParameters().getFile().getAbsolutePath();
|
||
34 | // String zipPathName = FilenameUtils.removeExtension(zipPath);
|
||
35 | // ress = new ZipResourcesStorage(zipPathName, dataStore.getName());
|
||
36 | // }
|
||
37 | return ress;
|
||
38 | } |
||
39 | |||
40 | @Override
|
||
41 | public H2SpatialHelper getHelper() {
|
||
42 | return (H2SpatialHelper) super.getHelper(); |
||
43 | } |
||
44 | |||
45 | @Override
|
||
46 | public Object execute(String sql) { |
||
47 | if( StringUtils.equalsIgnoreCase(sql, "!SHUTDOWN") ) { |
||
48 | this.getHelper().shutdown();
|
||
49 | return null; |
||
50 | } |
||
51 | return super.execute(sql); |
||
52 | } |
||
53 | 45867 | jjdelcerro | |
54 | @Override
|
||
55 | public boolean exists() { |
||
56 | try {
|
||
57 | H2SpatialExplorerParameters serverParameters = this.getParameters();
|
||
58 | 45901 | jjdelcerro | File f = H2SpatialUtils.normalizeH2File(serverParameters.getFile());
|
59 | 45867 | jjdelcerro | if( !f.exists() ) {
|
60 | return false; |
||
61 | } |
||
62 | return super.exists(); |
||
63 | } catch(Throwable th) { |
||
64 | return false; |
||
65 | } |
||
66 | } |
||
67 | |||
68 | |||
69 | 45472 | jjdelcerro | } |