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.csv / src / main / java / org / gvsig / fmap / dal / store / simplereader / SimpleReaderLibrary.java @ 47638
History | View | Annotate | Download (5.29 KB)
1 | 40846 | jjdelcerro | /**
|
---|---|---|---|
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 | 47638 | jjdelcerro | package org.gvsig.fmap.dal.store.simplereader; |
25 | 40846 | jjdelcerro | |
26 | import java.util.ArrayList; |
||
27 | import java.util.List; |
||
28 | |||
29 | import org.gvsig.fmap.dal.DALFileLibrary; |
||
30 | import org.gvsig.fmap.dal.DALFileLocator; |
||
31 | import org.gvsig.fmap.dal.DALLibrary; |
||
32 | import org.gvsig.fmap.dal.DALLocator; |
||
33 | import org.gvsig.fmap.dal.FileHelper; |
||
34 | 47638 | jjdelcerro | import org.gvsig.fmap.dal.serverexplorer.filesystem.spi.FilesystemServerExplorerManager; |
35 | 40846 | jjdelcerro | import org.gvsig.fmap.dal.spi.DataManagerProviderServices; |
36 | 47638 | jjdelcerro | import org.gvsig.fmap.dal.store.csv.CSVFilesystemServerProvider; |
37 | import org.gvsig.fmap.dal.store.csv.CSVNewStoreParameters; |
||
38 | import org.gvsig.fmap.dal.store.csv.CSVStoreParameters; |
||
39 | import org.gvsig.fmap.dal.store.csv.CSVStoreProvider; |
||
40 | import org.gvsig.fmap.dal.store.csv.CSVStoreProviderFactory; |
||
41 | import org.gvsig.fmap.dal.store.gml.GMLFilesystemServerProvider; |
||
42 | import org.gvsig.fmap.dal.store.gml.GMLStoreParameters; |
||
43 | import org.gvsig.fmap.dal.store.gml.GMLStoreProvider; |
||
44 | import org.gvsig.fmap.dal.store.gml.GMLStoreProviderFactory; |
||
45 | 40846 | jjdelcerro | import org.gvsig.metadata.exceptions.MetadataException; |
46 | import org.gvsig.tools.library.AbstractLibrary; |
||
47 | import org.gvsig.tools.library.LibraryException; |
||
48 | |||
49 | 47638 | jjdelcerro | public class SimpleReaderLibrary extends AbstractLibrary { |
50 | 40846 | jjdelcerro | |
51 | @Override
|
||
52 | public void doRegistration() { |
||
53 | registerAsServiceOf(DALLibrary.class); |
||
54 | require(DALFileLibrary.class); |
||
55 | } |
||
56 | |||
57 | 44309 | omartinez | @Override
|
58 | protected void doInitialize() throws LibraryException { |
||
59 | } |
||
60 | 40846 | jjdelcerro | |
61 | 44309 | omartinez | @Override
|
62 | protected void doPostInitialize() throws LibraryException { |
||
63 | List<Throwable> exs = new ArrayList<Throwable>(); |
||
64 | 40846 | jjdelcerro | |
65 | 44309 | omartinez | try {
|
66 | 47638 | jjdelcerro | FileHelper.registerParametersDefinition( |
67 | CSVStoreParameters.PARAMETERS_DEFINITION_NAME, |
||
68 | CSVStoreParameters.class, "CSVParameters.xml"
|
||
69 | ); |
||
70 | FileHelper.registerParametersDefinition( |
||
71 | CSVNewStoreParameters.PARAMETERS_DEFINITION_NAME, |
||
72 | CSVNewStoreParameters.class, "CSVParameters.xml"
|
||
73 | ); |
||
74 | 40846 | jjdelcerro | |
75 | 47638 | jjdelcerro | FileHelper.registerParametersDefinition( |
76 | GMLStoreParameters.PARAMETERS_DEFINITION_NAME, |
||
77 | GMLStoreParameters.class, "GMLParameters.xml"
|
||
78 | ); |
||
79 | 44309 | omartinez | } catch (Exception e) { |
80 | exs.add(e); |
||
81 | } |
||
82 | 47638 | jjdelcerro | |
83 | 44309 | omartinez | try {
|
84 | FileHelper.registerMetadataDefinition( |
||
85 | CSVStoreProvider.METADATA_DEFINITION_NAME, |
||
86 | 47638 | jjdelcerro | CSVStoreProvider.class, "CSVMetadata.xml"
|
87 | ); |
||
88 | FileHelper.registerMetadataDefinition( |
||
89 | GMLStoreProvider.METADATA_DEFINITION_NAME, |
||
90 | GMLStoreProvider.class, "GMLMetadata.xml"
|
||
91 | ); |
||
92 | 44309 | omartinez | } catch (MetadataException e) {
|
93 | exs.add(e); |
||
94 | } |
||
95 | 40846 | jjdelcerro | |
96 | 44309 | omartinez | DataManagerProviderServices dataman = (DataManagerProviderServices) DALLocator |
97 | .getDataManager(); |
||
98 | 40846 | jjdelcerro | |
99 | 44309 | omartinez | try {
|
100 | if (!dataman.getStoreProviders().contains(CSVStoreProvider.NAME)) {
|
||
101 | 47638 | jjdelcerro | dataman.registerStoreProviderFactory( |
102 | new CSVStoreProviderFactory(
|
||
103 | CSVStoreProvider.NAME, |
||
104 | CSVStoreProvider.DESCRIPTION |
||
105 | ) |
||
106 | ); |
||
107 | 44309 | omartinez | } |
108 | 47638 | jjdelcerro | if (!dataman.getStoreProviders().contains(GMLStoreProvider.NAME)) {
|
109 | dataman.registerStoreProviderFactory( |
||
110 | new GMLStoreProviderFactory(
|
||
111 | GMLStoreProvider.NAME, |
||
112 | GMLStoreProvider.DESCRIPTION |
||
113 | ) |
||
114 | ); |
||
115 | } |
||
116 | 44309 | omartinez | } catch (RuntimeException e) { |
117 | exs.add(e); |
||
118 | } |
||
119 | 40846 | jjdelcerro | |
120 | 44309 | omartinez | try {
|
121 | 47638 | jjdelcerro | FilesystemServerExplorerManager filesystemServerExplorerManager = |
122 | DALFileLocator.getFilesystemServerExplorerManager(); |
||
123 | filesystemServerExplorerManager.registerProvider( |
||
124 | CSVStoreProvider.NAME, |
||
125 | CSVStoreProvider.DESCRIPTION, |
||
126 | CSVFilesystemServerProvider.class |
||
127 | ); |
||
128 | filesystemServerExplorerManager.registerProvider( |
||
129 | GMLStoreProvider.NAME, |
||
130 | GMLStoreProvider.DESCRIPTION, |
||
131 | GMLFilesystemServerProvider.class |
||
132 | ); |
||
133 | 44309 | omartinez | } catch (RuntimeException e) { |
134 | exs.add(e); |
||
135 | } |
||
136 | |||
137 | if (exs.size() > 0) { |
||
138 | throw new LibraryException(this.getClass(), exs); |
||
139 | } |
||
140 | } |
||
141 | 40846 | jjdelcerro | } |