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 @ 40435
History | View | Annotate | Download (3.1 KB)
1 | 40435 | jjdelcerro | /* 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.metadata.exceptions.MetadataException; |
||
41 | import org.gvsig.tools.library.AbstractLibrary; |
||
42 | import org.gvsig.tools.library.LibraryException; |
||
43 | |||
44 | public class SHPLibrary extends AbstractLibrary { |
||
45 | |||
46 | @Override
|
||
47 | public void doRegistration() { |
||
48 | registerAsServiceOf(DALLibrary.class); |
||
49 | require(DALFileLibrary.class); |
||
50 | require(DBFLibrary.class); |
||
51 | } |
||
52 | |||
53 | @Override
|
||
54 | protected void doPostInitialize() throws LibraryException { |
||
55 | List<Throwable> exs = new ArrayList<Throwable>(); |
||
56 | |||
57 | FileHelper.registerParametersDefinition( |
||
58 | SHPStoreParameters.PARAMETERS_DEFINITION_NAME, |
||
59 | SHPStoreParameters.class, "SHPParameters.xml");
|
||
60 | FileHelper.registerParametersDefinition( |
||
61 | SHPNewStoreParameters.PARAMETERS_DEFINITION_NAME, |
||
62 | SHPNewStoreParameters.class, "SHPParameters.xml");
|
||
63 | try {
|
||
64 | FileHelper.registerMetadataDefinition( |
||
65 | SHPStoreProvider.METADATA_DEFINITION_NAME, |
||
66 | SHPStoreProvider.class, "SHPMetadata.xml");
|
||
67 | } catch (MetadataException e1) {
|
||
68 | exs.add(e1); |
||
69 | } |
||
70 | DataManagerProviderServices dataman = (DataManagerProviderServices) DALLocator |
||
71 | .getDataManager(); |
||
72 | |||
73 | try {
|
||
74 | if (!dataman.getStoreProviders().contains(SHPStoreProvider.NAME)) {
|
||
75 | dataman.registerStoreProviderFactory(new SHPStoreProviderFactory(SHPStoreProvider.NAME, SHPStoreProvider.DESCRIPTION));
|
||
76 | |||
77 | } |
||
78 | } catch (RuntimeException e) { |
||
79 | exs.add(e); |
||
80 | } |
||
81 | |||
82 | try {
|
||
83 | DALFileLocator.getFilesystemServerExplorerManager() |
||
84 | .registerProvider(SHPStoreProvider.NAME, |
||
85 | SHPStoreProvider.DESCRIPTION, |
||
86 | SHPFilesystemServerProvider.class); |
||
87 | } catch (RuntimeException e) { |
||
88 | exs.add(e); |
||
89 | } |
||
90 | |||
91 | if (exs.size() > 0) { |
||
92 | throw new LibraryException(this.getClass(), exs); |
||
93 | } |
||
94 | } |
||
95 | |||
96 | @Override
|
||
97 | protected void doInitialize() throws LibraryException { |
||
98 | // Do nothing
|
||
99 | |||
100 | } |
||
101 | |||
102 | } |