root / branches / dal_time_support / libraries / libFMap_dal / src / org / gvsig / fmap / dal / impl / DALDefaultImplLibrary.java @ 34623
History | View | Annotate | Download (6.23 KB)
1 |
/* 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 |
* 2009 IVER T.I {{Task}}
|
26 |
*/
|
27 |
|
28 |
/**
|
29 |
*
|
30 |
*/
|
31 |
package org.gvsig.fmap.dal.impl; |
32 |
|
33 |
import java.io.IOException; |
34 |
import java.util.ArrayList; |
35 |
import java.util.List; |
36 |
import java.util.Map; |
37 |
|
38 |
import org.xmlpull.v1.XmlPullParserException; |
39 |
|
40 |
import org.gvsig.fmap.dal.DALLibrary; |
41 |
import org.gvsig.fmap.dal.DALLocator; |
42 |
import org.gvsig.fmap.dal.DataManager; |
43 |
import org.gvsig.fmap.dal.DataTypes; |
44 |
import org.gvsig.fmap.dal.feature.AbstractFeatureStoreTransform; |
45 |
import org.gvsig.fmap.dal.feature.impl.DefaultFeatureQuery; |
46 |
import org.gvsig.fmap.dal.feature.impl.DefaultFeatureReference; |
47 |
import org.gvsig.fmap.dal.feature.impl.DefaultFeatureReferenceSelection; |
48 |
import org.gvsig.fmap.dal.feature.impl.DefaultFeatureSelection; |
49 |
import org.gvsig.fmap.dal.feature.impl.DefaultFeatureStore; |
50 |
import org.gvsig.fmap.dal.feature.impl.DefaultFeatureStoreTransforms; |
51 |
import org.gvsig.fmap.dal.feature.impl.attributegetter.DayToPartialFeatureAttributeGetter; |
52 |
import org.gvsig.fmap.dal.feature.impl.attributegetter.HourToPartialFeatureAttributeGetter; |
53 |
import org.gvsig.fmap.dal.feature.impl.attributegetter.MilliToPartialFeatureAttributeGetter; |
54 |
import org.gvsig.fmap.dal.feature.impl.attributegetter.MinuteToPartialFeatureAttributeGetter; |
55 |
import org.gvsig.fmap.dal.feature.impl.attributegetter.MonthToPartialFeatureAttributeGetter; |
56 |
import org.gvsig.fmap.dal.feature.impl.attributegetter.SecondToPartialFeatureAttributeGetter; |
57 |
import org.gvsig.fmap.dal.feature.impl.attributegetter.YearToPartialFeatureAttributeGetter; |
58 |
import org.gvsig.fmap.dal.impl.coerce.CoerceToCRS; |
59 |
import org.gvsig.fmap.dal.impl.coerce.CoerceToGeometry; |
60 |
import org.gvsig.fmap.dal.resource.impl.DefaultResourceManager; |
61 |
import org.gvsig.fmap.dal.spi.DataStoreProviderServices; |
62 |
import org.gvsig.metadata.exceptions.MetadataException; |
63 |
import org.gvsig.tools.ToolsLocator; |
64 |
import org.gvsig.tools.dataTypes.DataTypesManager; |
65 |
import org.gvsig.tools.dynobject.DynClass; |
66 |
import org.gvsig.tools.dynobject.DynObjectManager; |
67 |
import org.gvsig.tools.library.AbstractLibrary; |
68 |
import org.gvsig.tools.library.Library; |
69 |
import org.gvsig.tools.library.LibraryException; |
70 |
import org.gvsig.tools.locator.ReferenceNotRegisteredException; |
71 |
|
72 |
public class DALDefaultImplLibrary extends AbstractLibrary { |
73 |
|
74 |
public DALDefaultImplLibrary() {
|
75 |
super(DALLibrary.class,Library.TYPE.IMPL);
|
76 |
} |
77 |
|
78 |
protected void doInitialize() throws LibraryException { |
79 |
DALLocator.registerDefaultDataManager(DefaultDataManager.class); |
80 |
DALLocator.registerResourceManager(DefaultResourceManager.class); |
81 |
} |
82 |
|
83 |
protected void doPostInitialize() throws LibraryException { |
84 |
List exs = new ArrayList(); |
85 |
DataTypesManager dataTypesManager = ToolsLocator.getDataTypesManager(); |
86 |
|
87 |
dataTypesManager.setCoercion(DataTypes.GEOMETRY, new CoerceToGeometry());
|
88 |
dataTypesManager.setCoercion(DataTypes.CRS, new CoerceToCRS());
|
89 |
try {
|
90 |
registerBaseNewProvidersParametersDefinition(); |
91 |
} catch (XmlPullParserException e) {
|
92 |
exs.add(e); |
93 |
} catch (IOException e) { |
94 |
exs.add(e); |
95 |
} |
96 |
|
97 |
DefaultFeatureQuery.registerPersistent(); |
98 |
DefaultFeatureReference.registerPersistent(); |
99 |
DefaultFeatureStoreTransforms.registerPersistent(); |
100 |
AbstractFeatureStoreTransform.registerPersistent(); |
101 |
DefaultFeatureReferenceSelection.registerPersistent(); |
102 |
DefaultFeatureSelection.registerPersistent(); |
103 |
// DefaultCoverageStore.registerPersistent();
|
104 |
|
105 |
DefaultFeatureStore.registerPersistenceDefinition(); |
106 |
try {
|
107 |
DefaultFeatureStore.registerMetadataDefinition(); |
108 |
} catch (MetadataException e) {
|
109 |
exs.add(e); |
110 |
} |
111 |
|
112 |
//DefaultFeatureAttributeDescriptor.registerPersistent();
|
113 |
|
114 |
//Register the FeatureAttributeTransform
|
115 |
DataManager dataManager = DALLocator.getDataManager(); |
116 |
if (dataManager == null) { |
117 |
throw new ReferenceNotRegisteredException( |
118 |
DALLocator.DATA_MANAGER_NAME, DALLocator.getInstance()); |
119 |
} |
120 |
dataManager.registerFeatureAttributeGetter("milliToPartial", MilliToPartialFeatureAttributeGetter.class);
|
121 |
dataManager.registerFeatureAttributeGetter("secondToPartial",SecondToPartialFeatureAttributeGetter.class);
|
122 |
dataManager.registerFeatureAttributeGetter("minuteToPartial", MinuteToPartialFeatureAttributeGetter.class);
|
123 |
dataManager.registerFeatureAttributeGetter("hourToPartial", HourToPartialFeatureAttributeGetter.class);
|
124 |
dataManager.registerFeatureAttributeGetter("dayToPartial", DayToPartialFeatureAttributeGetter.class);
|
125 |
dataManager.registerFeatureAttributeGetter("monthToPartial", MonthToPartialFeatureAttributeGetter.class);
|
126 |
dataManager.registerFeatureAttributeGetter("yearToPartial", YearToPartialFeatureAttributeGetter.class);
|
127 |
|
128 |
|
129 |
if (exs.size() > 0) { |
130 |
throw new LibraryException(this.getClass(), exs); |
131 |
} |
132 |
} |
133 |
|
134 |
private void registerBaseNewProvidersParametersDefinition() throws XmlPullParserException, IOException { |
135 |
DynObjectManager manager = ToolsLocator.getDynObjectManager(); |
136 |
if( manager.get("DAL", DataStoreProviderServices.BASE_NEWPARAMETERS_PROVIDER_DEFINITION_NAME)==null ) { |
137 |
Map definitions = manager.importDynClassDefinitions(
|
138 |
DataStoreProviderServices.class.getResourceAsStream("ProviderParametersDefinition.xml"),
|
139 |
DataStoreProviderServices.class.getClassLoader() |
140 |
); |
141 |
manager.add((DynClass) definitions.get(DataStoreProviderServices.BASE_NEWPARAMETERS_PROVIDER_DEFINITION_FULLNAME)); |
142 |
manager.add((DynClass) definitions.get(DataStoreProviderServices.BASE_PARAMETERS_PROVIDER_DEFINITION_FULLNAME)); |
143 |
} |
144 |
} |
145 |
|
146 |
|
147 |
} |