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 |
/* 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 |
package org.gvsig.fmap.dal.store.gpe; |
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.DataTypes; |
38 |
import org.gvsig.fmap.dal.FileHelper; |
39 |
import org.gvsig.fmap.dal.spi.DataManagerProviderServices; |
40 |
import org.gvsig.fmap.geom.Geometry; |
41 |
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 |
import org.gvsig.metadata.exceptions.MetadataException; |
51 |
import org.gvsig.tools.library.AbstractLibrary; |
52 |
import org.gvsig.tools.library.LibraryException; |
53 |
import org.gvsig.tools.locator.ReferenceNotRegisteredException; |
54 |
import org.gvsig.xmlschema.lib.api.XMLSchemaLocator; |
55 |
import org.gvsig.xmlschema.lib.api.XMLSchemaManager; |
56 |
|
57 |
/**
|
58 |
* @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a>
|
59 |
*/
|
60 |
public class DALGPELibrary extends AbstractLibrary { |
61 |
|
62 |
@Override
|
63 |
public void doRegistration() { |
64 |
registerAsServiceOf(DALLibrary.class); |
65 |
require(DALFileLibrary.class); |
66 |
} |
67 |
|
68 |
protected void doInitialize() throws LibraryException { |
69 |
// Do nothing
|
70 |
} |
71 |
|
72 |
protected void doPostInitialize() throws LibraryException { |
73 |
|
74 |
List exs = new ArrayList(); |
75 |
|
76 |
GPEStoreParameters.registerParametersDefinition(); |
77 |
|
78 |
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 |
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 |
|
95 |
DALFileLocator.getFilesystemServerExplorerManager().registerProvider( |
96 |
GPEStoreProvider.NAME, GPEStoreProvider.DESCRIPTION, |
97 |
GPEFileSystemServerProvider.class); |
98 |
|
99 |
// Validate there is any implementation registered.
|
100 |
XMLSchemaManager xmlSchemaManager = XMLSchemaLocator.getXMLSchemaManager(); |
101 |
if (xmlSchemaManager == null) { |
102 |
exs.add(new ReferenceNotRegisteredException(
|
103 |
XMLSchemaLocator.XMLSCHEMA_MANAGER_NAME, XMLSchemaLocator |
104 |
.getInstance())); |
105 |
} |
106 |
|
107 |
//Register the application types in gpe. GPE uses the DAL types like internal types
|
108 |
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 |
xmlSchemaManager.registerAppDataType(DataTypes.DYNOBJECT, DataTypes.DYNOBJECT); |
123 |
xmlSchemaManager.registerAppDataType(DataTypes.CRS, DataTypes.CRS); |
124 |
xmlSchemaManager.registerAppDataType(DataTypes.FILE, DataTypes.FILE); |
125 |
xmlSchemaManager.registerAppDataType(DataTypes.BYTEARRAY, DataTypes.BYTEARRAY); |
126 |
|
127 |
//Mapping between GPE types and the application types
|
128 |
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 |
|
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 |
if (exs.size() > 0) { |
149 |
throw new LibraryException(this.getClass(), exs); |
150 |
} |
151 |
} |
152 |
|
153 |
} |
154 |
|
155 |
|