Statistics
| Revision:

svn-gvsig-desktop / 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 @ 44276

History | View | Annotate | Download (2.41 KB)

1
package org.gvsig.fmap.dal.store.h2;
2

    
3
import java.io.File;
4
import java.util.ArrayList;
5
import java.util.List;
6
import org.apache.commons.io.FilenameUtils;
7
import org.gvsig.fmap.dal.DataStore;
8
import org.gvsig.fmap.dal.exception.DataException;
9
import org.gvsig.fmap.dal.exception.InitializeException;
10
import org.gvsig.fmap.dal.spi.DataServerExplorerProviderServices;
11
import org.gvsig.fmap.dal.spi.FileMultiResource;
12
import org.gvsig.fmap.dal.store.jdbc.JDBCServerExplorerParameters;
13
import org.gvsig.fmap.dal.store.jdbc2.JDBCHelper;
14
import org.gvsig.fmap.dal.store.jdbc2.spi.JDBCServerExplorerBase;
15
import org.gvsig.tools.util.ResourcesStorage.Resource;
16

    
17
/**
18
 *
19
 * @author jjdelcerro
20
 */
21
@SuppressWarnings("UseSpecificCatch")
22
public class H2SpatialExplorer extends JDBCServerExplorerBase {
23
        
24
    public H2SpatialExplorer(JDBCServerExplorerParameters parameters, DataServerExplorerProviderServices services, JDBCHelper helper) throws InitializeException {
25
        super(parameters, services, helper);
26
    }
27

    
28
    @Override
29
    public H2SpatialExplorerParameters getParameters() {
30
        return (H2SpatialExplorerParameters) super.getParameters(); 
31
    }
32

    
33
    @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++;
60
        }
61
        if( ress.isEmpty() ) {
62
            return null;
63
        }
64
        return ress;
65
    }
66
}