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 @ 40559

History | View | Annotate | Download (3.15 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
 * AUTHORS (In addition to CIT):
26
 * 2008 IVER T.I. S.A.   {{Task}}
27
 */
28

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

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

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

    
45
public class SHPLibrary extends AbstractLibrary {
46

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

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

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

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

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

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

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

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

    
103
}