svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.compat.cdc / org.gvsig.fmap.dal / org.gvsig.fmap.dal.impl / src / main / java / org / gvsig / fmap / dal / impl / DALDefaultImplLibrary.java @ 45650
History | View | Annotate | Download (11.9 KB)
1 | 40559 | jjdelcerro | /**
|
---|---|---|---|
2 | * gvSIG. Desktop Geographic Information System.
|
||
3 | 40435 | jjdelcerro | *
|
4 | 40559 | jjdelcerro | * Copyright (C) 2007-2013 gvSIG Association.
|
5 | 40435 | jjdelcerro | *
|
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 | 40559 | jjdelcerro | * as published by the Free Software Foundation; either version 3
|
9 | 40435 | jjdelcerro | * 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 | 40559 | jjdelcerro | * For any additional information, do not hesitate to contact us
|
22 | * at info AT gvsig.com, or visit our website www.gvsig.com.
|
||
23 | 40435 | jjdelcerro | */
|
24 | package org.gvsig.fmap.dal.impl; |
||
25 | |||
26 | import java.io.IOException; |
||
27 | import java.util.ArrayList; |
||
28 | import java.util.List; |
||
29 | import java.util.Map; |
||
30 | 44669 | jjdelcerro | import org.gvsig.expressionevaluator.ExpressionEvaluatorLibrary; |
31 | 44769 | jjdelcerro | import org.gvsig.expressionevaluator.impl.DALFunctions; |
32 | 40435 | jjdelcerro | import org.gvsig.fmap.dal.DALLibrary; |
33 | import org.gvsig.fmap.dal.DALLocator; |
||
34 | import org.gvsig.fmap.dal.DataManager; |
||
35 | 44351 | jjdelcerro | import org.gvsig.fmap.dal.DataTypes; |
36 | 40435 | jjdelcerro | import org.gvsig.fmap.dal.feature.AbstractFeatureStoreTransform; |
37 | 43954 | jjdelcerro | import org.gvsig.fmap.dal.feature.impl.DALFile; |
38 | 45425 | jjdelcerro | import org.gvsig.fmap.dal.feature.impl.DefaultEditableFeatureAttributeDescriptor; |
39 | 44190 | jjdelcerro | import org.gvsig.fmap.dal.feature.impl.DefaultFeatureAttributeDescriptor; |
40 | 44829 | omartinez | import org.gvsig.fmap.dal.feature.impl.DefaultFeatureExtraColumns; |
41 | 40435 | jjdelcerro | import org.gvsig.fmap.dal.feature.impl.DefaultFeatureQuery; |
42 | 45308 | fdiaz | import org.gvsig.fmap.dal.feature.impl.DefaultFeatureQueryOrder; |
43 | 40435 | jjdelcerro | import org.gvsig.fmap.dal.feature.impl.DefaultFeatureReferenceSelection; |
44 | import org.gvsig.fmap.dal.feature.impl.DefaultFeatureSelection; |
||
45 | import org.gvsig.fmap.dal.feature.impl.DefaultFeatureStore; |
||
46 | import org.gvsig.fmap.dal.feature.impl.DefaultFeatureStoreTransforms; |
||
47 | 44190 | jjdelcerro | import org.gvsig.fmap.dal.feature.impl.DefaultFeatureType; |
48 | 44262 | jjdelcerro | import org.gvsig.fmap.dal.feature.impl.DefaultForeingKey; |
49 | 45426 | fdiaz | import org.gvsig.fmap.dal.feature.impl.LargeFeatureReferenceSelection; |
50 | import org.gvsig.fmap.dal.feature.impl.LargeFeatureSelection; |
||
51 | 42775 | jjdelcerro | import org.gvsig.fmap.dal.feature.impl.dynobjectutils.ComputeAvailableValuesFromTable; |
52 | import org.gvsig.fmap.dal.feature.impl.dynobjectutils.DumbFeatureTypeDefinitionsManager; |
||
53 | import org.gvsig.fmap.dal.feature.impl.dynobjectutils.relations.DALLink_getRelatedFeature; |
||
54 | import org.gvsig.fmap.dal.feature.impl.dynobjectutils.relations.DALLink_getRelatedFeatures; |
||
55 | 45647 | fdiaz | import org.gvsig.fmap.dal.feature.impl.featurereference.FeatureReferenceFactory; |
56 | import org.gvsig.fmap.dal.feature.impl.indexes.jsir.JSIRSpatialIndexProviderFactory; |
||
57 | 44927 | jjdelcerro | import org.gvsig.fmap.dal.feature.impl.indexes.memorybasictypes.MemoryBigDecimalIndexProviderFactory; |
58 | 44158 | jjdelcerro | import org.gvsig.fmap.dal.feature.impl.indexes.memorybasictypes.MemoryDoubleIndexProviderFactory; |
59 | import org.gvsig.fmap.dal.feature.impl.indexes.memorybasictypes.MemoryFloatIndexProviderFactory; |
||
60 | import org.gvsig.fmap.dal.feature.impl.indexes.memorybasictypes.MemoryIntIndexProviderFactory; |
||
61 | import org.gvsig.fmap.dal.feature.impl.indexes.memorybasictypes.MemoryLongIndexProviderFactory; |
||
62 | import org.gvsig.fmap.dal.feature.impl.indexes.memorybasictypes.MemoryStringIndexProviderFactory; |
||
63 | 45647 | fdiaz | import org.gvsig.fmap.dal.feature.impl.indexes.memoryspatial.MemorySpatialIndexProviderFactory; |
64 | 40435 | jjdelcerro | import org.gvsig.fmap.dal.feature.spi.memory.MemoryResource; |
65 | import org.gvsig.fmap.dal.feature.spi.memory.MemoryResourceParameters; |
||
66 | 43989 | jjdelcerro | import org.gvsig.fmap.dal.impl.expressionevaluator.DefaultFeatureAttributeEmulatorExpression; |
67 | 45366 | omartinez | import org.gvsig.fmap.dal.impl.expressionevaluator.DefaultFeatureExpressionEvaluator; |
68 | 40435 | jjdelcerro | import org.gvsig.fmap.dal.resource.impl.DefaultResourceManager; |
69 | import org.gvsig.fmap.dal.resource.spi.MultiResource; |
||
70 | import org.gvsig.fmap.dal.resource.spi.MultiResourceParameters; |
||
71 | import org.gvsig.fmap.dal.resource.spi.ResourceManagerProviderServices; |
||
72 | 45425 | jjdelcerro | import org.gvsig.fmap.dal.spi.DataServerExplorerPoolEntryImpl; |
73 | import org.gvsig.fmap.dal.spi.DataServerExplorerPoolImpl; |
||
74 | 40435 | jjdelcerro | import org.gvsig.fmap.dal.spi.DataStoreProviderServices; |
75 | import org.gvsig.i18n.Messages; |
||
76 | import org.gvsig.metadata.exceptions.MetadataException; |
||
77 | 45425 | jjdelcerro | import org.gvsig.srs.SRSJsonSerializer; |
78 | 40435 | jjdelcerro | import org.gvsig.tools.ToolsLocator; |
79 | import org.gvsig.tools.dynobject.DynClass; |
||
80 | import org.gvsig.tools.dynobject.DynObjectManager; |
||
81 | 44351 | jjdelcerro | import org.gvsig.tools.dynobject.DynObjectValueItem; |
82 | 41936 | jjdelcerro | import org.gvsig.tools.identitymanagement.SimpleIdentityManager; |
83 | 40435 | jjdelcerro | import org.gvsig.tools.library.AbstractLibrary; |
84 | import org.gvsig.tools.library.LibraryException; |
||
85 | import org.gvsig.tools.locator.ReferenceNotRegisteredException; |
||
86 | import org.xmlpull.v1.XmlPullParserException; |
||
87 | |||
88 | /**
|
||
89 | * Initialize the implementation of DAL.
|
||
90 | *
|
||
91 | * @author gvSIG Team
|
||
92 | * @version $Id$
|
||
93 | *
|
||
94 | */
|
||
95 | public class DALDefaultImplLibrary extends AbstractLibrary { |
||
96 | |||
97 | 43020 | jjdelcerro | @Override
|
98 | 40435 | jjdelcerro | public void doRegistration() { |
99 | registerAsImplementationOf(DALLibrary.class); |
||
100 | 44669 | jjdelcerro | require(ExpressionEvaluatorLibrary.class); |
101 | 40435 | jjdelcerro | } |
102 | |||
103 | 43020 | jjdelcerro | @Override
|
104 | 40435 | jjdelcerro | protected void doInitialize() throws LibraryException { |
105 | DALLocator.registerDefaultDataManager(DefaultDataManager.class); |
||
106 | DALLocator.registerResourceManager(DefaultResourceManager.class); |
||
107 | 42775 | jjdelcerro | DALLocator.registerDefaultFeatureTypeDefinitionsManager(DumbFeatureTypeDefinitionsManager.class); |
108 | 40435 | jjdelcerro | } |
109 | |||
110 | 43020 | jjdelcerro | @Override
|
111 | 40435 | jjdelcerro | protected void doPostInitialize() throws LibraryException { |
112 | List exs = new ArrayList(); |
||
113 | |||
114 | Messages.addResourceFamily("org.gvsig.fmap.dal.i18n.text",
|
||
115 | DALDefaultImplLibrary.class.getClassLoader(), |
||
116 | DALDefaultImplLibrary.class.getClass().getName()); |
||
117 | |||
118 | try {
|
||
119 | registerBaseNewProvidersParametersDefinition(); |
||
120 | } catch (XmlPullParserException e) {
|
||
121 | exs.add(e); |
||
122 | } catch (IOException e) { |
||
123 | exs.add(e); |
||
124 | } |
||
125 | |||
126 | 41936 | jjdelcerro | SimpleIdentityManager identityManager = ToolsLocator.getIdentityManager(); |
127 | identityManager.registerAction(DataManager.CREATE_STORE_AUTHORIZATION); |
||
128 | identityManager.registerAction(DataManager.READ_STORE_AUTHORIZATION); |
||
129 | identityManager.registerAction(DataManager.WRITE_STORE_AUTHORIZATION); |
||
130 | |||
131 | |||
132 | 40435 | jjdelcerro | DefaultFeatureQuery.registerPersistent(); |
133 | 45308 | fdiaz | DefaultFeatureQueryOrder.registerPersistent(); |
134 | 45647 | fdiaz | FeatureReferenceFactory.registerPersistent(); |
135 | 40435 | jjdelcerro | DefaultFeatureStoreTransforms.registerPersistent(); |
136 | AbstractFeatureStoreTransform.registerPersistent(); |
||
137 | DefaultFeatureReferenceSelection.registerPersistent(); |
||
138 | DefaultFeatureSelection.registerPersistent(); |
||
139 | 45426 | fdiaz | LargeFeatureReferenceSelection.registerPersistent(); |
140 | LargeFeatureSelection.registerPersistent(); |
||
141 | 44262 | jjdelcerro | DefaultForeingKey.registerPersistenceDefinition(); |
142 | 44829 | omartinez | DefaultFeatureExtraColumns.registerPersistent(); |
143 | 45366 | omartinez | DefaultFeatureExpressionEvaluator.registerPersistence(); |
144 | 40435 | jjdelcerro | |
145 | DefaultFeatureStore.registerPersistenceDefinition(); |
||
146 | 45425 | jjdelcerro | DataServerExplorerPoolImpl.registerPersistenceDefinition(); |
147 | DataServerExplorerPoolEntryImpl.registerPersistenceDefinition(); |
||
148 | 43954 | jjdelcerro | |
149 | DALFile.registerPersistenceDefinition(); |
||
150 | 45425 | jjdelcerro | DefaultFeatureAttributeEmulatorExpression.selfRegister(); |
151 | DefaultFeatureType.selfRegister(); |
||
152 | DefaultFeatureExtraColumns.selfRegister(); |
||
153 | DefaultFeatureAttributeDescriptor.selfRegister(); |
||
154 | DefaultEditableFeatureAttributeDescriptor.selfRegister(); |
||
155 | SRSJsonSerializer.selfRegister(); |
||
156 | 43989 | jjdelcerro | |
157 | 44262 | jjdelcerro | org.gvsig.fmap.dal.impl.dataprofile.DataProfileText.selfRegister(); |
158 | 44253 | jjdelcerro | |
159 | 44262 | jjdelcerro | org.gvsig.fmap.dal.complements.relatedfeatures.RelatedFeaturesFactory.selfRegister(); |
160 | org.gvsig.fmap.dal.complements.search.SearchFactory.selfRegister(); |
||
161 | |||
162 | 40435 | jjdelcerro | try {
|
163 | DefaultFeatureStore.registerMetadataDefinition(); |
||
164 | } catch (MetadataException e) {
|
||
165 | exs.add(e); |
||
166 | } |
||
167 | |||
168 | // DefaultFeatureAttributeDescriptor.registerPersistent();
|
||
169 | |||
170 | //Register the FeatureAttributeTransform
|
||
171 | 43020 | jjdelcerro | DefaultDataManager dataManager = (DefaultDataManager) DALLocator.getDataManager(); |
172 | 40435 | jjdelcerro | if (dataManager == null) { |
173 | throw new ReferenceNotRegisteredException( |
||
174 | DALLocator.DATA_MANAGER_NAME, DALLocator.getInstance()); |
||
175 | } |
||
176 | |||
177 | 44158 | jjdelcerro | MemorySpatialIndexProviderFactory.selfRegister(); |
178 | JSIRSpatialIndexProviderFactory.selfRegister(); |
||
179 | MemoryStringIndexProviderFactory.selfRegister(); |
||
180 | MemoryIntIndexProviderFactory.selfRegister(); |
||
181 | MemoryLongIndexProviderFactory.selfRegister(); |
||
182 | MemoryFloatIndexProviderFactory.selfRegister(); |
||
183 | MemoryDoubleIndexProviderFactory.selfRegister(); |
||
184 | 44927 | jjdelcerro | MemoryBigDecimalIndexProviderFactory.selfRegister(); |
185 | 44158 | jjdelcerro | |
186 | 40435 | jjdelcerro | ResourceManagerProviderServices resourceManager = |
187 | (ResourceManagerProviderServices) DALLocator.getResourceManager(); |
||
188 | if (resourceManager == null) { |
||
189 | throw new ReferenceNotRegisteredException( |
||
190 | DALLocator.RESOURCE_MANAGER_NAME, DALLocator.getInstance()); |
||
191 | } |
||
192 | |||
193 | if (!resourceManager.getResourceProviders().contains(
|
||
194 | MultiResource.TYPE_NAME)) { |
||
195 | resourceManager.register(MultiResource.TYPE_NAME, |
||
196 | MultiResource.DESCRIPTION, MultiResource.class, |
||
197 | MultiResourceParameters.class); |
||
198 | } |
||
199 | |||
200 | if (!resourceManager.getResourceProviders().contains(
|
||
201 | MemoryResource.NAME)) { |
||
202 | resourceManager.register(MemoryResource.NAME, |
||
203 | MemoryResource.DESCRIPTION, MemoryResource.class, |
||
204 | MemoryResourceParameters.class); |
||
205 | } |
||
206 | |||
207 | 42775 | jjdelcerro | DynObjectManager dynObjectmanager = ToolsLocator.getDynObjectManager(); |
208 | dynObjectmanager.registerDynMethod(new DALLink_getRelatedFeatures());
|
||
209 | dynObjectmanager.registerDynMethod(new DALLink_getRelatedFeature());
|
||
210 | dynObjectmanager.registerDynMethod(new ComputeAvailableValuesFromTable("getAvailableValuesFromTable", "Retrieve available values from the elements of a table.")); |
||
211 | 44351 | jjdelcerro | |
212 | registerTags(); |
||
213 | 44190 | jjdelcerro | DefaultFeatureAttributeDescriptor.registerPersistenceDefinition(); |
214 | DefaultFeatureType.registerPersistenceDefinition(); |
||
215 | 44769 | jjdelcerro | |
216 | DALFunctions.register(); |
||
217 | 43983 | jjdelcerro | |
218 | 40435 | jjdelcerro | if (exs.size() > 0) { |
219 | throw new LibraryException(this.getClass(), exs); |
||
220 | } |
||
221 | } |
||
222 | |||
223 | private void registerBaseNewProvidersParametersDefinition() |
||
224 | throws XmlPullParserException, IOException { |
||
225 | DynObjectManager manager = ToolsLocator.getDynObjectManager(); |
||
226 | if (manager
|
||
227 | .get( |
||
228 | "DAL",
|
||
229 | DataStoreProviderServices.BASE_NEWPARAMETERS_PROVIDER_DEFINITION_NAME) == null) {
|
||
230 | Map definitions =
|
||
231 | manager |
||
232 | .importDynClassDefinitions( |
||
233 | DataStoreProviderServices.class |
||
234 | .getResourceAsStream("ProviderParametersDefinition.xml"),
|
||
235 | DataStoreProviderServices.class.getClassLoader()); |
||
236 | manager |
||
237 | .add((DynClass) definitions |
||
238 | .get(DataStoreProviderServices.BASE_NEWPARAMETERS_PROVIDER_DEFINITION_FULLNAME)); |
||
239 | manager |
||
240 | .add((DynClass) definitions |
||
241 | .get(DataStoreProviderServices.BASE_PARAMETERS_PROVIDER_DEFINITION_FULLNAME)); |
||
242 | } |
||
243 | } |
||
244 | |||
245 | 44351 | jjdelcerro | private void registerTags() { |
246 | DynObjectManager dynObjectManager = ToolsLocator.getDynObjectManager(); |
||
247 | dynObjectManager.registerTag( |
||
248 | DataManager.DAL_USE_LABELS, |
||
249 | "Indicates the preference when using labels over names."
|
||
250 | ).setAvailableValues( |
||
251 | new DynObjectValueItem[] { |
||
252 | new DynObjectValueItem(0, "Use names"), |
||
253 | new DynObjectValueItem(1, "Use labels"), |
||
254 | new DynObjectValueItem(2, "Use labels and names"), |
||
255 | } |
||
256 | ).setType(DataTypes.INT); |
||
257 | |||
258 | 45425 | jjdelcerro | |
259 | 44351 | jjdelcerro | } |
260 | 40435 | jjdelcerro | } |