Statistics
| Revision:

svn-gvsig-desktop / 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 / SHPLibrary.java @ 40596

History | View | Annotate | Download (3.08 KB)

1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
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 3
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
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24

    
25
package org.gvsig.fmap.dal.store.shp;
26

    
27
import java.util.ArrayList;
28
import java.util.List;
29

    
30
import org.gvsig.fmap.dal.DALFileLibrary;
31
import org.gvsig.fmap.dal.DALFileLocator;
32
import org.gvsig.fmap.dal.DALLibrary;
33
import org.gvsig.fmap.dal.DALLocator;
34
import org.gvsig.fmap.dal.FileHelper;
35
import org.gvsig.fmap.dal.spi.DataManagerProviderServices;
36
import org.gvsig.fmap.dal.store.dbf.DBFLibrary;
37
import org.gvsig.metadata.exceptions.MetadataException;
38
import org.gvsig.tools.library.AbstractLibrary;
39
import org.gvsig.tools.library.LibraryException;
40

    
41
public class SHPLibrary extends AbstractLibrary {
42

    
43
    @Override
44
    public void doRegistration() {
45
        registerAsServiceOf(DALLibrary.class);
46
        require(DALFileLibrary.class);
47
        require(DBFLibrary.class);
48
    }
49

    
50
        @Override
51
        protected void doPostInitialize() throws LibraryException {
52
                List<Throwable> exs = new ArrayList<Throwable>();
53

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

    
70
                try {
71
                        if (!dataman.getStoreProviders().contains(SHPStoreProvider.NAME)) {
72
                                dataman.registerStoreProviderFactory(new SHPStoreProviderFactory(SHPStoreProvider.NAME, SHPStoreProvider.DESCRIPTION));
73

    
74
                        }
75
                } catch (RuntimeException e) {
76
                        exs.add(e);
77
                }
78

    
79
                try {
80
                        DALFileLocator.getFilesystemServerExplorerManager()
81
                                        .registerProvider(SHPStoreProvider.NAME,
82
                                                        SHPStoreProvider.DESCRIPTION,
83
                                                        SHPFilesystemServerProvider.class);
84
                } catch (RuntimeException e) {
85
                        exs.add(e);
86
                }
87

    
88
                if (exs.size() > 0) {
89
                        throw new LibraryException(this.getClass(), exs);
90
                }
91
        }
92

    
93
        @Override
94
        protected void doInitialize() throws LibraryException {
95
                // Do nothing
96
                
97
        }
98

    
99
}