root / branches / v2_0_0_prep / extensions / extGPE-gvSIG / src / org / gvsig / fmap / dal / store / gpe / DALGPELibrary.java @ 38564
History | View | Annotate | Download (7.13 KB)
1 | 27499 | jpiera | /* 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 | 30067 | jmvivo | *
|
6 | 27499 | jpiera | * 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 | 30067 | jmvivo | *
|
11 | 27499 | jpiera | * 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 | 30067 | jmvivo | *
|
16 | 27499 | jpiera | * 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 | 30067 | jmvivo | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
19 | 27499 | jpiera | * MA 02110-1301, USA.
|
20 | 30067 | jmvivo | *
|
21 | 27499 | jpiera | */
|
22 | |||
23 | /*
|
||
24 | * AUTHORS (In addition to CIT):
|
||
25 | * 2009 {Iver T.I.} {Task}
|
||
26 | */
|
||
27 | |||
28 | package org.gvsig.fmap.dal.store.gpe; |
||
29 | |||
30 | 32953 | cordinyana | import java.util.ArrayList; |
31 | import java.util.List; |
||
32 | |||
33 | 30719 | jpiera | import org.gvsig.fmap.dal.DALFileLibrary; |
34 | 27499 | jpiera | import org.gvsig.fmap.dal.DALFileLocator; |
35 | 32953 | cordinyana | import org.gvsig.fmap.dal.DALLibrary; |
36 | 27499 | jpiera | import org.gvsig.fmap.dal.DALLocator; |
37 | 32880 | jjdelcerro | import org.gvsig.fmap.dal.DataTypes; |
38 | 32953 | cordinyana | import org.gvsig.fmap.dal.FileHelper; |
39 | 27499 | jpiera | import org.gvsig.fmap.dal.spi.DataManagerProviderServices; |
40 | 31838 | jpiera | import org.gvsig.fmap.geom.Geometry; |
41 | 34119 | jpiera | import org.gvsig.fmap.geom.GeometryLocator; |
42 | import org.gvsig.fmap.geom.GeometryManager; |
||
43 | import org.gvsig.fmap.geom.operation.writegml2.CurveWriteGml2Operation; |
||
44 | import org.gvsig.fmap.geom.operation.writegml2.MultiCurveWriteGml2Operation; |
||
45 | import org.gvsig.fmap.geom.operation.writegml2.MultiPointWriteGml2Operation; |
||
46 | import org.gvsig.fmap.geom.operation.writegml2.MultiSurfaceWriteGml2Operation; |
||
47 | import org.gvsig.fmap.geom.operation.writegml2.PointWriteGml2Operation; |
||
48 | import org.gvsig.fmap.geom.operation.writegml2.SurfaceWriteGml2Operation; |
||
49 | import org.gvsig.fmap.geom.operation.writegml2.WriteGml2Operation; |
||
50 | 32953 | cordinyana | import org.gvsig.metadata.exceptions.MetadataException; |
51 | 30633 | cordinyana | import org.gvsig.tools.library.AbstractLibrary; |
52 | 30580 | cordinyana | import org.gvsig.tools.library.LibraryException; |
53 | 31838 | jpiera | import org.gvsig.tools.locator.ReferenceNotRegisteredException; |
54 | 32051 | jpiera | import org.gvsig.xmlschema.lib.api.XMLSchemaLocator; |
55 | import org.gvsig.xmlschema.lib.api.XMLSchemaManager; |
||
56 | 27499 | jpiera | |
57 | /**
|
||
58 | * @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a>
|
||
59 | */
|
||
60 | 30633 | cordinyana | public class DALGPELibrary extends AbstractLibrary { |
61 | 33032 | jjdelcerro | |
62 | 35142 | cordinyana | @Override
|
63 | public void doRegistration() { |
||
64 | registerAsServiceOf(DALLibrary.class); |
||
65 | require(DALFileLibrary.class); |
||
66 | } |
||
67 | |||
68 | 30580 | cordinyana | protected void doInitialize() throws LibraryException { |
69 | 33032 | jjdelcerro | // Do nothing
|
70 | 27499 | jpiera | } |
71 | |||
72 | 30580 | cordinyana | protected void doPostInitialize() throws LibraryException { |
73 | 27499 | jpiera | |
74 | 33032 | jjdelcerro | List exs = new ArrayList(); |
75 | 32953 | cordinyana | |
76 | 34130 | jpiera | GPEStoreParameters.registerParametersDefinition(); |
77 | |||
78 | 32953 | cordinyana | try {
|
79 | FileHelper.registerMetadataDefinition( |
||
80 | GPEStoreProvider.METADATA_DEFINITION_NAME, |
||
81 | GPEStoreProvider.class, "GPEMetadata.xml");
|
||
82 | } catch (MetadataException e) {
|
||
83 | exs.add(e); |
||
84 | } |
||
85 | |||
86 | |||
87 | 27499 | jpiera | DataManagerProviderServices dataman = (DataManagerProviderServices) DALLocator |
88 | .getDataManager(); |
||
89 | |||
90 | if (!dataman.getStoreProviders().contains(GPEStoreProvider.NAME)) {
|
||
91 | dataman.registerStoreProvider(GPEStoreProvider.NAME, |
||
92 | GPEStoreProvider.class, GPEStoreParameters.class); |
||
93 | } |
||
94 | 30067 | jmvivo | |
95 | 27499 | jpiera | DALFileLocator.getFilesystemServerExplorerManager().registerProvider( |
96 | GPEStoreProvider.NAME, GPEStoreProvider.DESCRIPTION, |
||
97 | GPEFileSystemServerProvider.class); |
||
98 | 31838 | jpiera | |
99 | // Validate there is any implementation registered.
|
||
100 | 32051 | jpiera | XMLSchemaManager xmlSchemaManager = XMLSchemaLocator.getXMLSchemaManager(); |
101 | if (xmlSchemaManager == null) { |
||
102 | 32953 | cordinyana | exs.add(new ReferenceNotRegisteredException(
|
103 | XMLSchemaLocator.XMLSCHEMA_MANAGER_NAME, XMLSchemaLocator |
||
104 | .getInstance())); |
||
105 | 31838 | jpiera | } |
106 | |||
107 | 34119 | jpiera | //Register the application types in gpe. GPE uses the DAL types like internal types
|
108 | 32051 | jpiera | xmlSchemaManager.registerAppDataType(DataTypes.UNKNOWN, DataTypes.UNKNOWN); |
109 | xmlSchemaManager.registerAppDataType(DataTypes.BOOLEAN, DataTypes.BOOLEAN); |
||
110 | xmlSchemaManager.registerAppDataType(DataTypes.BYTE, DataTypes.BYTE); |
||
111 | xmlSchemaManager.registerAppDataType(DataTypes.CHAR, DataTypes.CHAR); |
||
112 | xmlSchemaManager.registerAppDataType(DataTypes.INT, DataTypes.INT); |
||
113 | xmlSchemaManager.registerAppDataType(DataTypes.LONG, DataTypes.LONG); |
||
114 | xmlSchemaManager.registerAppDataType(DataTypes.FLOAT, DataTypes.FLOAT); |
||
115 | xmlSchemaManager.registerAppDataType(DataTypes.DOUBLE, DataTypes.DOUBLE); |
||
116 | xmlSchemaManager.registerAppDataType(DataTypes.STRING, DataTypes.STRING); |
||
117 | xmlSchemaManager.registerAppDataType(DataTypes.DATE, DataTypes.DATE); |
||
118 | xmlSchemaManager.registerAppDataType(DataTypes.TIME, DataTypes.TIME); |
||
119 | xmlSchemaManager.registerAppDataType(DataTypes.TIMESTAMP, DataTypes.TIMESTAMP); |
||
120 | xmlSchemaManager.registerAppDataType(DataTypes.GEOMETRY, DataTypes.GEOMETRY); |
||
121 | xmlSchemaManager.registerAppDataType(DataTypes.OBJECT, DataTypes.OBJECT); |
||
122 | 32880 | jjdelcerro | xmlSchemaManager.registerAppDataType(DataTypes.DYNOBJECT, DataTypes.DYNOBJECT); |
123 | xmlSchemaManager.registerAppDataType(DataTypes.CRS, DataTypes.CRS); |
||
124 | 32051 | jpiera | xmlSchemaManager.registerAppDataType(DataTypes.FILE, DataTypes.FILE); |
125 | xmlSchemaManager.registerAppDataType(DataTypes.BYTEARRAY, DataTypes.BYTEARRAY); |
||
126 | 34119 | jpiera | |
127 | //Mapping between GPE types and the application types
|
||
128 | 32051 | jpiera | xmlSchemaManager.registerAppGeometryType(Geometry.TYPES.GEOMETRY, XMLSchemaManager.GEOMETRY); |
129 | xmlSchemaManager.registerAppGeometryType(Geometry.TYPES.POINT, XMLSchemaManager.POINT); |
||
130 | xmlSchemaManager.registerAppGeometryType(Geometry.TYPES.CURVE, XMLSchemaManager.LINESTRING); |
||
131 | xmlSchemaManager.registerAppGeometryType(Geometry.TYPES.SURFACE, XMLSchemaManager.POLYGON); |
||
132 | xmlSchemaManager.registerAppGeometryType(Geometry.TYPES.SOLID, XMLSchemaManager.SOLID); |
||
133 | xmlSchemaManager.registerAppGeometryType(Geometry.TYPES.AGGREGATE, XMLSchemaManager.MULTIGEOMETRY); |
||
134 | xmlSchemaManager.registerAppGeometryType(Geometry.TYPES.MULTIPOINT, XMLSchemaManager.MULTIPOINT); |
||
135 | xmlSchemaManager.registerAppGeometryType(Geometry.TYPES.MULTICURVE, XMLSchemaManager.MULTILINESTRING); |
||
136 | xmlSchemaManager.registerAppGeometryType(Geometry.TYPES.MULTISURFACE, XMLSchemaManager.MULTIPOLYGON); |
||
137 | xmlSchemaManager.registerAppGeometryType(Geometry.TYPES.MULTISOLID, XMLSchemaManager.MULTISOLID); |
||
138 | 34119 | jpiera | |
139 | //Operations
|
||
140 | GeometryManager geometryManager = GeometryLocator.getGeometryManager(); |
||
141 | geometryManager.registerGeometryOperation(WriteGml2Operation.NAME, new PointWriteGml2Operation(), Geometry.TYPES.POINT);
|
||
142 | geometryManager.registerGeometryOperation(WriteGml2Operation.NAME, new CurveWriteGml2Operation(), Geometry.TYPES.CURVE);
|
||
143 | geometryManager.registerGeometryOperation(WriteGml2Operation.NAME, new SurfaceWriteGml2Operation(), Geometry.TYPES.SURFACE);
|
||
144 | geometryManager.registerGeometryOperation(WriteGml2Operation.NAME, new MultiPointWriteGml2Operation(), Geometry.TYPES.MULTIPOINT);
|
||
145 | geometryManager.registerGeometryOperation(WriteGml2Operation.NAME, new MultiCurveWriteGml2Operation(), Geometry.TYPES.MULTICURVE);
|
||
146 | geometryManager.registerGeometryOperation(WriteGml2Operation.NAME, new MultiSurfaceWriteGml2Operation(), Geometry.TYPES.MULTISURFACE);
|
||
147 | |||
148 | 32953 | cordinyana | if (exs.size() > 0) { |
149 | throw new LibraryException(this.getClass(), exs); |
||
150 | } |
||
151 | 27499 | jpiera | } |
152 | 32953 | cordinyana | |
153 | 27499 | jpiera | } |
154 |