Statistics
| Revision:

root / branches / v2_0_0_prep / libraries / libFMap_dalfile / src / org / gvsig / fmap / dal / store / shp / SHPLibrary.java @ 36208

History | View | Annotate | Download (3.21 KB)

1
/* gvSIG. Geographic Information System of the Valencian Government
2
 *
3
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
4
 * of the Valencian Government (CIT)
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 */
22

    
23
/*
24
 * AUTHORS (In addition to CIT):
25
 * 2008 IVER T.I. S.A.   {{Task}}
26
 */
27

    
28
package org.gvsig.fmap.dal.store.shp;
29

    
30
import java.util.ArrayList;
31
import java.util.List;
32

    
33
import org.gvsig.fmap.dal.DALFileLibrary;
34
import org.gvsig.fmap.dal.DALFileLocator;
35
import org.gvsig.fmap.dal.DALLibrary;
36
import org.gvsig.fmap.dal.DALLocator;
37
import org.gvsig.fmap.dal.FileHelper;
38
import org.gvsig.fmap.dal.spi.DataManagerProviderServices;
39
import org.gvsig.fmap.dal.store.dbf.DBFLibrary;
40
import org.gvsig.fmap.dal.store.dgn.DGNStoreProvider;
41
import org.gvsig.fmap.dal.store.dgn.DGNStoreProviderFactory;
42
import org.gvsig.metadata.exceptions.MetadataException;
43
import org.gvsig.tools.library.AbstractLibrary;
44
import org.gvsig.tools.library.LibraryException;
45

    
46
public class SHPLibrary extends AbstractLibrary {
47

    
48
    @Override
49
    public void doRegistration() {
50
        registerAsServiceOf(DALLibrary.class);
51
        require(DALFileLibrary.class);
52
        require(DBFLibrary.class);
53
    }
54

    
55
        @Override
56
        protected void doPostInitialize() throws LibraryException {
57
                List<Throwable> exs = new ArrayList<Throwable>();
58

    
59
                FileHelper.registerParametersDefinition(
60
                                SHPStoreParameters.PARAMETERS_DEFINITION_NAME,
61
                                SHPStoreParameters.class, "SHPParameters.xml");
62
                FileHelper.registerParametersDefinition(
63
                                SHPNewStoreParameters.PARAMETERS_DEFINITION_NAME,
64
                                SHPNewStoreParameters.class, "SHPParameters.xml");
65
                try {
66
                        FileHelper.registerMetadataDefinition(
67
                                        SHPStoreProvider.METADATA_DEFINITION_NAME,
68
                                        SHPStoreProvider.class, "SHPMetadata.xml");
69
                } catch (MetadataException e1) {
70
                        exs.add(e1);
71
                }
72
                DataManagerProviderServices dataman = (DataManagerProviderServices) DALLocator
73
                                .getDataManager();
74

    
75
                try {
76
                        if (!dataman.getStoreProviders().contains(SHPStoreProvider.NAME)) {
77
                                dataman.registerStoreProviderFactory(new SHPStoreProviderFactory(SHPStoreProvider.NAME, SHPStoreProvider.DESCRIPTION));
78

    
79
                        }
80
                } catch (RuntimeException e) {
81
                        exs.add(e);
82
                }
83

    
84
                try {
85
                        DALFileLocator.getFilesystemServerExplorerManager()
86
                                        .registerProvider(SHPStoreProvider.NAME,
87
                                                        SHPStoreProvider.DESCRIPTION,
88
                                                        SHPFilesystemServerProvider.class);
89
                } catch (RuntimeException e) {
90
                        exs.add(e);
91
                }
92

    
93
                if (exs.size() > 0) {
94
                        throw new LibraryException(this.getClass(), exs);
95
                }
96
        }
97

    
98
        @Override
99
        protected void doInitialize() throws LibraryException {
100
                // Do nothing
101
                
102
        }
103

    
104
}