Revision 29579
branches/v2_0_0_prep/extensions/extOracleSpatial/.settings/org.eclipse.jdt.core.prefs | ||
---|---|---|
1 |
#Fri Jun 26 09:17:59 CEST 2009
|
|
1 |
#Fri Jun 26 14:38:09 CEST 2009
|
|
2 | 2 |
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 |
3 | 3 |
eclipse.preferences.version=1 |
4 | 4 |
org.eclipse.jdt.core.compiler.source=1.5 |
branches/v2_0_0_prep/extensions/extOracleSpatial/config/text.properties | ||
---|---|---|
18 | 18 |
oracle_spatial=Oracle Spatial |
19 | 19 |
password=Contrase?a |
20 | 20 |
|
21 |
|
|
22 |
enter_layer_name=Nombre de la capa |
|
23 |
select_geometry_type=Selecciona el tipo de geometr?a |
|
24 |
Geometry_types=Tipos de geometr?a |
|
25 |
point_type=Punto |
|
26 |
line_type=L?nea |
|
27 |
polygon_type=Pol?gono |
|
28 |
multi_type=Multi-geometr?a |
|
29 |
multipoint_type=Multi-punto |
|
30 |
define_fields=Crea nuevos campos |
|
31 |
length=Tama?o |
|
32 |
add_field=Nuevo campo |
|
33 |
new_layer=Nueva capa |
|
34 |
|
branches/v2_0_0_prep/extensions/extOracleSpatial/config/text_en.properties | ||
---|---|---|
16 | 16 |
nombre_no_valido=Invalid name |
17 | 17 |
new_oracle_spatial_table=New Oracle Spatial table |
18 | 18 |
oracle_spatial=Oracle Spatial |
19 |
password=Password |
|
19 |
password=Password |
|
20 |
|
|
21 |
enter_layer_name=Layer name |
|
22 |
select_geometry_type=Select geometry type |
|
23 |
Geometry_types=geometry types |
|
24 |
point_type=Point |
|
25 |
line_type=Line |
|
26 |
polygon_type=Polygon |
|
27 |
multi_type=Multi-geometry |
|
28 |
multipoint_type=Multi-point |
|
29 |
define_fields=Build new fields |
|
30 |
length=Length |
|
31 |
add_field=Add field |
|
32 |
new_layer=New layer |
branches/v2_0_0_prep/extensions/extOracleSpatial/src/org/gvsig/fmap/dal/store/oraclespatial/OracleSpatialServerExplorer.java | ||
---|---|---|
1 | 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 |
*/ |
|
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 | 22 |
|
23 | 23 |
/* |
24 |
* AUTHORS (In addition to CIT): |
|
25 |
* 2009 IVER T.I {{Task}} |
|
26 |
*/ |
|
24 |
* AUTHORS (In addition to CIT):
|
|
25 |
* 2009 IVER T.I {{Task}}
|
|
26 |
*/
|
|
27 | 27 |
|
28 | 28 |
/** |
29 | 29 |
* |
... | ... | |
31 | 31 |
package org.gvsig.fmap.dal.store.oraclespatial; |
32 | 32 |
|
33 | 33 |
import java.sql.Connection; |
34 |
import java.sql.ResultSet; |
|
34 | 35 |
import java.sql.SQLException; |
35 | 36 |
import java.sql.Statement; |
36 | 37 |
import java.util.ArrayList; |
38 |
import java.util.Iterator; |
|
37 | 39 |
import java.util.List; |
38 | 40 |
|
39 | 41 |
import org.gvsig.fmap.dal.DataStoreParameters; |
... | ... | |
41 | 43 |
import org.gvsig.fmap.dal.exception.DataException; |
42 | 44 |
import org.gvsig.fmap.dal.exception.InitializeException; |
43 | 45 |
import org.gvsig.fmap.dal.exception.ProviderNotRegisteredException; |
46 |
import org.gvsig.fmap.dal.exception.ReadException; |
|
44 | 47 |
import org.gvsig.fmap.dal.exception.RemoveException; |
45 | 48 |
import org.gvsig.fmap.dal.spi.DataServerExplorerProviderServices; |
49 |
import org.gvsig.fmap.dal.store.jdbc.ConnectionAction; |
|
46 | 50 |
import org.gvsig.fmap.dal.store.jdbc.JDBCHelper; |
47 | 51 |
import org.gvsig.fmap.dal.store.jdbc.JDBCServerExplorer; |
48 | 52 |
import org.gvsig.fmap.dal.store.jdbc.JDBCStoreParameters; |
... | ... | |
54 | 58 |
|
55 | 59 |
/** |
56 | 60 |
* @author vsanjaime |
57 |
* |
|
61 |
*
|
|
58 | 62 |
*/ |
59 | 63 |
public class OracleSpatialServerExplorer extends JDBCServerExplorer { |
60 | 64 |
final static private Logger logger = LoggerFactory |
... | ... | |
62 | 66 |
|
63 | 67 |
public static final String NAME = "OracleSpatialExplorer"; |
64 | 68 |
|
65 |
|
|
66 | 69 |
public OracleSpatialServerExplorer( |
67 | 70 |
OracleSpatialServerExplorerParameters parameters, |
68 | 71 |
DataServerExplorerProviderServices services) |
... | ... | |
74 | 77 |
return (OracleSpatialServerExplorerParameters) getParameters(); |
75 | 78 |
} |
76 | 79 |
|
77 |
|
|
78 | 80 |
protected JDBCHelper createHelper() throws InitializeException { |
79 | 81 |
return new OracleSpatialHelper(this, getOracleSpatialParameters()); |
80 | 82 |
} |
81 | 83 |
|
82 |
|
|
83 | 84 |
protected String getStoreName() { |
84 | 85 |
return OracleSpatialStoreProvider.NAME; |
85 | 86 |
} |
... | ... | |
98 | 99 |
return orgParams; |
99 | 100 |
} |
100 | 101 |
|
101 |
|
|
102 | 102 |
// **************************** |
103 | 103 |
|
104 |
|
|
105 | 104 |
public boolean canAdd() { |
106 | 105 |
return true; |
107 | 106 |
} |
108 | 107 |
|
108 |
/** |
|
109 |
* |
|
110 |
*/ |
|
109 | 111 |
protected void checkIsMine(DataStoreParameters dsp) { |
110 | 112 |
if (!(dsp instanceof OracleSpatialStoreParameters)) { |
111 | 113 |
// FIXME Excpetion ??? |
... | ... | |
121 | 123 |
} |
122 | 124 |
} |
123 | 125 |
|
126 |
/** |
|
127 |
* |
|
128 |
*/ |
|
124 | 129 |
public void remove(DataStoreParameters dsp) throws RemoveException { |
125 |
final OracleSpatialStoreParameters osParams =(OracleSpatialStoreParameters) dsp; |
|
130 |
final OracleSpatialStoreParameters osParams = (OracleSpatialStoreParameters) dsp;
|
|
126 | 131 |
|
127 | 132 |
TransactionalAction action = new TransactionalAction() { |
128 | 133 |
public boolean continueTransactionAllowed() { |
129 | 134 |
return false; |
130 | 135 |
} |
136 |
|
|
131 | 137 |
public Object action(Connection conn) throws DataException { |
132 | 138 |
|
133 |
|
|
134 | 139 |
Statement st; |
135 |
try{ |
|
140 |
try {
|
|
136 | 141 |
st = conn.createStatement(); |
137 | 142 |
} catch (SQLException e) { |
138 | 143 |
throw new JDBCSQLException(e); |
139 | 144 |
} |
140 | 145 |
|
141 |
String sqlDrop = "Drop table " |
|
142 |
+ osParams.tableID(); |
|
146 |
String sqlDrop = "Drop table " + osParams.tableID(); |
|
143 | 147 |
|
144 | 148 |
StringBuilder strb = new StringBuilder(); |
145 |
strb.append("Delete from GEOMETRY_COLUMNS where f_table_schema = "); |
|
146 |
if (osParams.getSchema() == null || osParams.getSchema().length() == 0) { |
|
149 |
strb |
|
150 |
.append("Delete from GEOMETRY_COLUMNS where f_table_schema = "); |
|
151 |
if (osParams.getSchema() == null |
|
152 |
|| osParams.getSchema().length() == 0) { |
|
147 | 153 |
strb.append("current_schema() "); |
148 | 154 |
} else { |
149 | 155 |
strb.append('\''); |
... | ... | |
155 | 161 |
strb.append('\''); |
156 | 162 |
|
157 | 163 |
String sqlDeleteFromGeometry_column = strb.toString(); |
158 |
try{ |
|
159 |
try{ |
|
164 |
try {
|
|
165 |
try {
|
|
160 | 166 |
st.execute(sqlDrop); |
161 | 167 |
} catch (SQLException e) { |
162 | 168 |
throw new JDBCExecuteSQLException(sqlDrop, e); |
... | ... | |
169 | 175 |
sqlDeleteFromGeometry_column, e); |
170 | 176 |
} |
171 | 177 |
|
172 |
} finally{ |
|
173 |
try{ st.close(); } catch (SQLException e) {}; |
|
178 |
} finally { |
|
179 |
try { |
|
180 |
st.close(); |
|
181 |
} catch (SQLException e) { |
|
182 |
} |
|
183 |
; |
|
174 | 184 |
} |
175 | 185 |
return null; |
176 | 186 |
} |
... | ... | |
182 | 192 |
} |
183 | 193 |
} |
184 | 194 |
|
195 |
/** |
|
196 |
* |
|
197 |
*/ |
|
185 | 198 |
public NewDataStoreParameters getAddParameters() throws DataException { |
186 | 199 |
OracleSpatialServerExplorerParameters parameters = getOracleSpatialParameters(); |
187 | 200 |
OracleSpatialNewStoreParameters params = new OracleSpatialNewStoreParameters(); |
... | ... | |
196 | 209 |
params.setUrl(parameters.getUrl()); |
197 | 210 |
params.setUseSSL(parameters.getUseSSL()); |
198 | 211 |
|
199 |
|
|
200 | 212 |
params.setDefaultFeatureType(this.getServerExplorerProviderServices() |
201 | 213 |
.createNewFeatureType()); |
202 | 214 |
|
203 |
|
|
204 | 215 |
return params; |
205 | 216 |
} |
206 | 217 |
|
207 |
|
|
208 |
|
|
209 |
// *********************** |
|
210 |
// *********************** |
|
211 |
|
|
212 |
|
|
218 |
/** |
|
219 |
* Geometry support |
|
220 |
*/ |
|
213 | 221 |
public boolean hasGeometrySupport() { |
214 | 222 |
return true; |
215 | 223 |
} |
216 | 224 |
|
225 |
/** |
|
226 |
* get helper |
|
227 |
* |
|
228 |
* @return |
|
229 |
*/ |
|
217 | 230 |
protected OracleSpatialHelper getOSHelper() { |
218 | 231 |
return (OracleSpatialHelper) getHelper(); |
219 | 232 |
} |
220 | 233 |
|
234 |
/** |
|
235 |
* get sql sentence for list available tables |
|
236 |
*/ |
|
237 |
protected List<String> getSQLForList(int mode, |
|
238 |
boolean showInformationDBTables) { |
|
239 |
List<String> list = new ArrayList<String>(1); |
|
240 |
list.add("SELECT TABLE_NAME FROM USER_SDO_GEOM_METADATA"); |
|
221 | 241 |
|
222 |
protected List getSQLForList(int mode, boolean showInformationDBTables) { |
|
223 |
List list = new ArrayList(1); |
|
224 |
StringBuffer sqlBuf = new StringBuffer(); |
|
225 |
sqlBuf |
|
226 |
.append("SELECT null as TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME, false as ISVIEW "); |
|
227 |
sqlBuf.append(" FROM INFORMATION_SCHEMA.TABLES "); |
|
228 |
sqlBuf.append(" xxWHERExx "); |
|
229 |
sqlBuf.append(" union "); |
|
230 |
sqlBuf |
|
231 |
.append("SELECT null as TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME, true as ISVIEW "); |
|
232 |
sqlBuf.append(" FROM INFORMATION_SCHEMA.VIEWS "); |
|
233 |
sqlBuf.append(" xxWHERExx "); |
|
242 |
return list; |
|
234 | 243 |
|
235 |
if (showInformationDBTables) { |
|
236 |
list.add(sqlBuf.toString().replaceAll("xxWHERExx", "")); |
|
237 |
} else { |
|
238 |
list |
|
239 |
.add(sqlBuf |
|
240 |
.toString() |
|
241 |
.replaceAll("xxWHERExx", |
|
242 |
"WHERE TABLE_SCHEMA NOT IN ('information_schema','pg_catalog')")); |
|
244 |
} |
|
245 |
|
|
246 |
public List list(final int mode, final boolean showInformationDBTables) |
|
247 |
throws DataException { |
|
243 | 248 |
|
249 |
final JDBCStoreParameters orgParams = createStoreParams(); |
|
250 |
|
|
251 |
ConnectionAction action = new ConnectionAction() { |
|
252 |
|
|
253 |
public Object action(Connection conn) throws DataException { |
|
254 |
ResultSet rs = null; |
|
255 |
Statement st = null; |
|
256 |
List sqls = getSQLForList(mode, showInformationDBTables); |
|
257 |
|
|
258 |
try { |
|
259 |
JDBCStoreParameters params; |
|
260 |
|
|
261 |
List paramList = new ArrayList(); |
|
262 |
|
|
263 |
conn = helper.getConnection(); |
|
264 |
st = conn.createStatement(); |
|
265 |
String sql; |
|
266 |
Iterator sqlIter = sqls.iterator(); |
|
267 |
while (sqlIter.hasNext()){ |
|
268 |
sql = (String) sqlIter.next(); |
|
269 |
rs = st.executeQuery(sql); |
|
270 |
while (rs.next()) { |
|
271 |
params = (JDBCStoreParameters) orgParams |
|
272 |
.getCopy(); |
|
273 |
params.setTable(rs.getString(1)); |
|
274 |
// TODO |
|
275 |
// if (rs.getBoolean(4)) { |
|
276 |
// param.setIsView(param.IS_VIEW); |
|
277 |
// } else { |
|
278 |
// param.setIsView(param.NOT_IS_VIEW); |
|
279 |
// } |
|
280 |
paramList.add(params); |
|
281 |
} |
|
282 |
} |
|
283 |
|
|
284 |
return paramList; |
|
285 |
} catch (SQLException e) { |
|
286 |
throw new JDBCSQLException(e); |
|
287 |
} finally { |
|
288 |
try {rs.close();} catch (Exception e) { }; |
|
289 |
try {st.close();} catch (Exception e) { }; |
|
244 | 290 |
} |
245 |
return list;
|
|
291 |
}
|
|
246 | 292 |
|
293 |
}; |
|
247 | 294 |
|
248 |
} |
|
295 |
try { |
|
296 |
return (List) helper.doConnectionAction(action); |
|
297 |
} catch (Exception e) { |
|
298 |
throw new ReadException(this.getName(), e); |
|
249 | 299 |
} |
300 |
} |
|
301 |
|
|
302 |
|
|
303 |
|
|
304 |
} |
branches/v2_0_0_prep/extensions/extOracleSpatial/src/org/gvsig/fmap/dal/store/oraclespatial/OracleSpatialHelper.java | ||
---|---|---|
28 | 28 |
package org.gvsig.fmap.dal.store.oraclespatial; |
29 | 29 |
|
30 | 30 |
import java.sql.Connection; |
31 |
import java.sql.PreparedStatement; |
|
32 | 31 |
import java.sql.ResultSet; |
33 | 32 |
import java.sql.ResultSetMetaData; |
34 | 33 |
import java.sql.SQLException; |
35 | 34 |
import java.sql.Statement; |
36 |
import java.sql.Types; |
|
37 | 35 |
import java.util.ArrayList; |
36 |
import java.util.Arrays; |
|
38 | 37 |
import java.util.Comparator; |
39 | 38 |
import java.util.Iterator; |
40 | 39 |
import java.util.List; |
... | ... | |
49 | 48 |
import org.gvsig.fmap.dal.exception.DataException; |
50 | 49 |
import org.gvsig.fmap.dal.exception.InitializeException; |
51 | 50 |
import org.gvsig.fmap.dal.exception.ReadException; |
52 |
import org.gvsig.fmap.dal.exception.WriteException; |
|
53 | 51 |
import org.gvsig.fmap.dal.feature.EditableFeatureAttributeDescriptor; |
54 | 52 |
import org.gvsig.fmap.dal.feature.EditableFeatureType; |
55 | 53 |
import org.gvsig.fmap.dal.feature.Feature; |
... | ... | |
61 | 59 |
import org.gvsig.fmap.dal.feature.exception.UnsupportedDataTypeException; |
62 | 60 |
import org.gvsig.fmap.dal.feature.exception.UnsupportedGeometryException; |
63 | 61 |
import org.gvsig.fmap.dal.resource.spi.ResourceManagerProviderServices; |
64 |
import org.gvsig.fmap.dal.store.jdbc.ConnectionAction; |
|
65 | 62 |
import org.gvsig.fmap.dal.store.jdbc.JDBCHelper; |
66 | 63 |
import org.gvsig.fmap.dal.store.jdbc.JDBCHelperUser; |
67 | 64 |
import org.gvsig.fmap.dal.store.jdbc.JDBCStoreParameters; |
68 | 65 |
import org.gvsig.fmap.dal.store.jdbc.exception.JDBCException; |
69 |
import org.gvsig.fmap.dal.store.jdbc.exception.JDBCExecutePreparedSQLException; |
|
70 | 66 |
import org.gvsig.fmap.dal.store.jdbc.exception.JDBCExecuteSQLException; |
71 |
import org.gvsig.fmap.dal.store.jdbc.exception.JDBCPreparingSQLException; |
|
72 | 67 |
import org.gvsig.fmap.dal.store.jdbc.exception.JDBCSQLException; |
73 | 68 |
import org.gvsig.fmap.geom.Geometry; |
74 | 69 |
import org.gvsig.fmap.geom.GeometryLocator; |
... | ... | |
90 | 85 |
private static Logger logger = LoggerFactory |
91 | 86 |
.getLogger(OracleSpatialHelper.class); |
92 | 87 |
|
93 |
OracleSpatialHelper(JDBCHelperUser consumer, |
|
88 |
/** |
|
89 |
* Constructor |
|
90 |
* |
|
91 |
* @param consumer |
|
92 |
* @param params |
|
93 |
* @throws InitializeException |
|
94 |
*/ |
|
95 |
public OracleSpatialHelper(JDBCHelperUser consumer, |
|
94 | 96 |
OracleSpatialConnectionParameters params) |
95 | 97 |
throws InitializeException { |
96 | 98 |
|
97 | 99 |
super(consumer, params); |
98 | 100 |
} |
99 | 101 |
|
102 |
/** |
|
103 |
* Initialize resource |
|
104 |
*/ |
|
100 | 105 |
protected void initializeResource() throws InitializeException { |
101 | 106 |
ResourceManagerProviderServices manager = (ResourceManagerProviderServices) DALLocator |
102 | 107 |
.getResourceManager(); |
... | ... | |
114 | 119 |
this.setResource(resource); |
115 | 120 |
} |
116 | 121 |
|
122 |
/** |
|
123 |
* Get default schema |
|
124 |
*/ |
|
117 | 125 |
protected String getDefaultSchema(Connection conn) throws JDBCException { |
118 | 126 |
if (defaultSchema == null) { |
119 | 127 |
String sql = "SELECT sys_context('USERENV', 'CURRENT_SCHEMA') FROM dual;"; |
... | ... | |
153 | 161 |
return defaultSchema; |
154 | 162 |
} |
155 | 163 |
|
164 |
/** |
|
165 |
* |
|
166 |
*/ |
|
156 | 167 |
public Envelope getFullEnvelopeOfField(JDBCStoreParameters storeParams, |
157 | 168 |
String geometryAttrName, Envelope limit) throws DataException { |
158 | 169 |
|
... | ... | |
609 | 620 |
case Geometry.TYPES.CURVE: |
610 | 621 |
oraGeomType = OracleSpatialValues.OraGeometry_GTYPE_CURVE; |
611 | 622 |
break; |
623 |
case Geometry.TYPES.TEXT: |
|
624 |
oraGeomType = OracleSpatialValues.OraGeometry_GTYPE_GEOMETRY; |
|
625 |
break; |
|
626 |
case Geometry.TYPES.SOLID: |
|
627 |
oraGeomType = OracleSpatialValues.OraGeometry_GTYPE_GEOMETRY; |
|
628 |
break; |
|
629 |
case Geometry.TYPES.AGGREGATE: |
|
630 |
oraGeomType = OracleSpatialValues.OraGeometry_GTYPE_GEOMETRY; |
|
631 |
break; |
|
612 | 632 |
case Geometry.TYPES.SURFACE: |
613 | 633 |
oraGeomType = OracleSpatialValues.OraGeometry_GTYPE_POLYGON; |
614 | 634 |
break; |
... | ... | |
621 | 641 |
case Geometry.TYPES.MULTISURFACE: |
622 | 642 |
oraGeomType = OracleSpatialValues.OraGeometry_GTYPE_MULTIPOLYGON; |
623 | 643 |
break; |
644 |
case Geometry.TYPES.MULTISOLID: |
|
645 |
oraGeomType = OracleSpatialValues.OraGeometry_GTYPE_GEOMETRY; |
|
646 |
break; |
|
647 |
case Geometry.TYPES.CIRCLE: |
|
648 |
oraGeomType = OracleSpatialValues.OraGeometry_GTYPE_GEOMETRY; |
|
649 |
break; |
|
650 |
case Geometry.TYPES.ARC: |
|
651 |
oraGeomType = OracleSpatialValues.OraGeometry_GTYPE_GEOMETRY; |
|
652 |
break; |
|
653 |
case Geometry.TYPES.ELLIPSE: |
|
654 |
oraGeomType = OracleSpatialValues.OraGeometry_GTYPE_GEOMETRY; |
|
655 |
break; |
|
656 |
case Geometry.TYPES.SPLINE: |
|
657 |
oraGeomType = OracleSpatialValues.OraGeometry_GTYPE_GEOMETRY; |
|
658 |
break; |
|
659 |
case Geometry.TYPES.ELLIPTICARC: |
|
660 |
oraGeomType = OracleSpatialValues.OraGeometry_GTYPE_GEOMETRY; |
|
661 |
break; |
|
624 | 662 |
default: |
625 | 663 |
throw new UnsupportedGeometryException(geometryType, |
626 | 664 |
geometrySubType); |
627 |
} |
|
665 |
} |
|
666 |
|
|
628 | 667 |
return oraGeomType; |
629 | 668 |
} |
630 | 669 |
|
631 | 670 |
/** |
632 |
* |
|
671 |
* Get oracle srid from srs code(EPSG code)
|
|
633 | 672 |
*/ |
634 | 673 |
public int getProviderSRID(String srs) { |
635 | 674 |
|
636 | 675 |
DataManager manager = DALLocator.getDataManager(); |
637 |
|
|
676 |
Integer isrs = null; |
|
638 | 677 |
if (srs != null) { |
639 | 678 |
FeatureStore oraSrsStore = (FeatureStore) OracleSpatialLibrary |
640 | 679 |
.getSRSDataStore(); |
... | ... | |
652 | 691 |
int iora = ora.intValue(); |
653 | 692 |
double prefe = feat.getDouble("PRF_ORACLE"); |
654 | 693 |
if (prefe == 1) { |
655 |
srs = new Integer(iora).toString();
|
|
694 |
isrs = new Integer(iora);
|
|
656 | 695 |
break; |
657 | 696 |
} |
658 | 697 |
} |
... | ... | |
660 | 699 |
} catch (DataException e) { |
661 | 700 |
e.printStackTrace(); |
662 | 701 |
} |
663 |
|
|
664 |
return searchOraSRID(srs);
|
|
665 |
|
|
702 |
if (isrs != null) { |
|
703 |
return isrs;
|
|
704 |
} |
|
666 | 705 |
} |
667 | 706 |
return -1; |
668 | 707 |
} |
669 | 708 |
|
670 |
public int getProviderSRID(IProjection srs) { |
|
671 |
if (srs != null) { |
|
672 |
String epsg = srs.getAbrev().trim(); |
|
709 |
/** |
|
710 |
* Get oracle srid from gvSIG projection |
|
711 |
* @param proj |
|
712 |
*/ |
|
713 |
public int getProviderSRID(IProjection proj) { |
|
714 |
if (proj != null) { |
|
715 |
String epsg = proj.getAbrev().trim(); |
|
673 | 716 |
int ocu = epsg.indexOf(":"); |
674 | 717 |
if (ocu != -1) { |
675 | 718 |
epsg = epsg.substring(ocu + 1); |
... | ... | |
678 | 721 |
if (oraSRID != null) { |
679 | 722 |
return oraSRID.intValue(); |
680 | 723 |
} |
681 |
|
|
682 |
return searchOraSRID(srs); |
|
683 |
|
|
684 | 724 |
} |
685 | 725 |
return -1; |
686 | 726 |
} |
687 | 727 |
|
688 |
private int searchOraSRID(final IProjection srs) { |
|
689 |
if (srs == null) { |
|
690 |
return -1; |
|
691 |
} |
|
692 |
return searchOraSRID(srs.getAbrev()); |
|
693 |
} |
|
728 |
// private int searchOraSRID(final IProjection srs) { |
|
729 |
// if (srs == null) { |
|
730 |
// return -1; |
|
731 |
// } |
|
732 |
// return searchOraSRID(srs.getAbrev()); |
|
733 |
// } |
|
734 |
// |
|
735 |
// private int searchOraSRID(final String srsID) { |
|
736 |
// if (srsID == null) { |
|
737 |
// return -1; |
|
738 |
// } |
|
739 |
// |
|
740 |
// ConnectionAction action = new ConnectionAction() { |
|
741 |
// |
|
742 |
// public Object action(Connection conn) throws DataException { |
|
743 |
// // select srid from spatial_ref_sys where auth_name = 'EPSG' and |
|
744 |
// // auth_srid = 23030 |
|
745 |
// String[] abrev = srsID.split(":"); |
|
746 |
// StringBuilder sqlb = new StringBuilder(); |
|
747 |
// sqlb.append("select SRID from MDSYS.CS_SRS where "); |
|
748 |
// if (abrev.length > 1) { |
|
749 |
// sqlb.append("auth_name = ? and "); |
|
750 |
// } |
|
751 |
// sqlb.append("auth_srid = ?"); |
|
752 |
// |
|
753 |
// String sql = sqlb.toString(); |
|
754 |
// PreparedStatement st; |
|
755 |
// try { |
|
756 |
// st = conn.prepareStatement(sql); |
|
757 |
// } catch (SQLException e) { |
|
758 |
// throw new JDBCPreparingSQLException(sql, e); |
|
759 |
// } |
|
760 |
// ResultSet rs = null; |
|
761 |
// try { |
|
762 |
// int i = 0; |
|
763 |
// if (abrev.length > 1) { |
|
764 |
// st.setString(i + 1, abrev[i]); |
|
765 |
// i++; |
|
766 |
// } |
|
767 |
// st.setInt(i + 1, Integer.parseInt(abrev[i])); |
|
768 |
// |
|
769 |
// try { |
|
770 |
// rs = st.executeQuery(); |
|
771 |
// } catch (SQLException e) { |
|
772 |
// throw new JDBCExecutePreparedSQLException(sql, abrev, e); |
|
773 |
// } |
|
774 |
// |
|
775 |
// if (!rs.next()) { |
|
776 |
// return null; |
|
777 |
// } |
|
778 |
// |
|
779 |
// return new Integer(rs.getInt(1)); |
|
780 |
// |
|
781 |
// } catch (SQLException e) { |
|
782 |
// throw new JDBCSQLException(e); |
|
783 |
// } finally { |
|
784 |
// try { |
|
785 |
// rs.close(); |
|
786 |
// } catch (Exception e) { |
|
787 |
// } |
|
788 |
// ; |
|
789 |
// try { |
|
790 |
// st.close(); |
|
791 |
// } catch (Exception e) { |
|
792 |
// } |
|
793 |
// ; |
|
794 |
// } |
|
795 |
// |
|
796 |
// } |
|
797 |
// |
|
798 |
// }; |
|
799 |
// |
|
800 |
// Integer oraSRSID = null; |
|
801 |
// try { |
|
802 |
// oraSRSID = (Integer) doConnectionAction(action); |
|
803 |
// return oraSRSID.intValue(); |
|
804 |
// } catch (Exception e) { |
|
805 |
// logger.error("Excetion searching pgSRS", e); |
|
806 |
// return -1; |
|
807 |
// } |
|
808 |
// } |
|
694 | 809 |
|
695 |
private int searchOraSRID(final String srsID) { |
|
696 |
if (srsID == null) { |
|
697 |
return -1; |
|
698 |
} |
|
699 |
|
|
700 |
ConnectionAction action = new ConnectionAction() { |
|
701 |
|
|
702 |
public Object action(Connection conn) throws DataException { |
|
703 |
// select srid from spatial_ref_sys where auth_name = 'EPSG' and |
|
704 |
// auth_srid = 23030 |
|
705 |
String[] abrev = srsID.split(":"); |
|
706 |
StringBuilder sqlb = new StringBuilder(); |
|
707 |
sqlb.append("select SRID from MDSYS.CS_SRS where "); |
|
708 |
if (abrev.length > 1) { |
|
709 |
sqlb.append("auth_name = ? and "); |
|
710 |
} |
|
711 |
sqlb.append("auth_srid = ?"); |
|
712 |
|
|
713 |
String sql = sqlb.toString(); |
|
714 |
PreparedStatement st; |
|
715 |
try { |
|
716 |
st = conn.prepareStatement(sql); |
|
717 |
} catch (SQLException e) { |
|
718 |
throw new JDBCPreparingSQLException(sql, e); |
|
719 |
} |
|
720 |
ResultSet rs = null; |
|
721 |
try { |
|
722 |
int i = 0; |
|
723 |
if (abrev.length > 1) { |
|
724 |
st.setString(i + 1, abrev[i]); |
|
725 |
i++; |
|
726 |
} |
|
727 |
st.setInt(i + 1, Integer.parseInt(abrev[i])); |
|
728 |
|
|
729 |
try { |
|
730 |
rs = st.executeQuery(); |
|
731 |
} catch (SQLException e) { |
|
732 |
throw new JDBCExecutePreparedSQLException(sql, abrev, e); |
|
733 |
} |
|
734 |
|
|
735 |
if (!rs.next()) { |
|
736 |
return null; |
|
737 |
} |
|
738 |
|
|
739 |
return new Integer(rs.getInt(1)); |
|
740 |
|
|
741 |
} catch (SQLException e) { |
|
742 |
throw new JDBCSQLException(e); |
|
743 |
} finally { |
|
744 |
try { |
|
745 |
rs.close(); |
|
746 |
} catch (Exception e) { |
|
747 |
} |
|
748 |
; |
|
749 |
try { |
|
750 |
st.close(); |
|
751 |
} catch (Exception e) { |
|
752 |
} |
|
753 |
; |
|
754 |
} |
|
755 |
|
|
756 |
} |
|
757 |
|
|
758 |
}; |
|
759 |
|
|
760 |
Integer oraSRSID = null; |
|
761 |
try { |
|
762 |
oraSRSID = (Integer) doConnectionAction(action); |
|
763 |
return oraSRSID.intValue(); |
|
764 |
} catch (Exception e) { |
|
765 |
logger.error("Excetion searching pgSRS", e); |
|
766 |
return -1; |
|
767 |
} |
|
768 |
} |
|
769 |
|
|
770 | 810 |
public List getSqlGeometyFieldAdd(FeatureAttributeDescriptor attr, |
771 | 811 |
String table, String schema) { |
772 | 812 |
// SELECT AddGeometryColumn({schema}, {table}, {field}, {srid}(int), |
... | ... | |
846 | 886 |
OracleSpatialNewStoreParameters oraNdsp = (OracleSpatialNewStoreParameters) ndsp; |
847 | 887 |
while (iter.hasNext()) { |
848 | 888 |
attr = (FeatureAttributeDescriptor) iter.next(); |
849 |
if (attr.getDataType() == DataTypes.GEOMETRY) { |
|
850 |
result.addAll(getSqlGeometyFieldAdd(attr, oraNdsp.getTable(), |
|
851 |
oraNdsp.getSchema())); |
|
852 |
} |
|
889 |
// if (attr.getDataType() == DataTypes.GEOMETRY) {
|
|
890 |
// result.addAll(getSqlGeometyFieldAdd(attr, oraNdsp.getTable(),
|
|
891 |
// oraNdsp.getSchema()));
|
|
892 |
// }
|
|
853 | 893 |
} |
854 | 894 |
|
855 | 895 |
return result; |
... | ... | |
910 | 950 |
return strb.toString(); |
911 | 951 |
} |
912 | 952 |
|
913 |
// public String getSqlFieldDescription(FeatureAttributeDescriptor attr) |
|
914 |
// throws DataException { |
|
915 |
// if (attr.getDataType() == DataTypes.GEOMETRY) { |
|
916 |
// return null; |
|
917 |
// } |
|
918 |
// return super.getSqlFieldDescription(attr); |
|
919 |
// } |
|
920 |
|
|
921 | 953 |
public static int nvarchar2Limited(int n) { |
922 | 954 |
|
923 | 955 |
if (n <= OracleSpatialValues.VARCHAR2_STANDARD_SIZE) |
... | ... | |
927 | 959 |
|
928 | 960 |
return OracleSpatialValues.VARCHAR2_LONG_SIZE; |
929 | 961 |
} |
962 |
|
|
963 |
public void loadFeatureType(EditableFeatureType featureType, |
|
964 |
JDBCStoreParameters storeParams) throws DataException { |
|
965 |
if (storeParams.getSQL() != null |
|
966 |
&& storeParams.getSQL().trim().length() == 0) { |
|
967 |
loadFeatureType(featureType, storeParams, storeParams.getSQL(), |
|
968 |
null, null); |
|
969 |
} else { |
|
970 |
String sql = "select * from all_tab_columns where table_name ='"+storeParams.tableID()+"'"; |
|
930 | 971 |
|
972 |
|
|
973 |
loadFeatureType(featureType, storeParams, sql, storeParams |
|
974 |
.getSchema(), storeParams.getTable()); |
|
975 |
} |
|
976 |
} |
|
977 |
|
|
978 |
|
|
979 |
|
|
931 | 980 |
} |
branches/v2_0_0_prep/extensions/extOracleSpatial/src/org/gvsig/oraclespatial/extension/NewOracleSpatialTableFinishAction.java | ||
---|---|---|
7 | 7 |
|
8 | 8 |
import org.gvsig.fmap.dal.DALLocator; |
9 | 9 |
import org.gvsig.fmap.dal.DataManager; |
10 |
import org.gvsig.fmap.dal.DataServerExplorer; |
|
11 | 10 |
import org.gvsig.fmap.dal.DataTypes; |
12 | 11 |
import org.gvsig.fmap.dal.exception.DataException; |
13 | 12 |
import org.gvsig.fmap.dal.exception.ValidateDataParametersException; |
... | ... | |
16 | 15 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
17 | 16 |
import org.gvsig.fmap.dal.feature.FeatureType; |
18 | 17 |
import org.gvsig.fmap.dal.feature.NewFeatureStoreParameters; |
19 |
import org.gvsig.fmap.dal.serverexplorer.db.DBServerExplorer; |
|
20 | 18 |
import org.gvsig.fmap.dal.store.jdbc.JDBCServerExplorer; |
21 | 19 |
import org.gvsig.fmap.dal.store.jdbc.JDBCServerExplorerParameters; |
22 | 20 |
import org.gvsig.fmap.dal.store.jdbc.JDBCStoreParameters; |
23 |
import org.gvsig.fmap.dal.store.oraclespatial.OracleSpatialServerExplorer; |
|
24 |
import org.gvsig.fmap.dal.store.oraclespatial.OracleSpatialServerExplorerParameters; |
|
25 |
import org.gvsig.fmap.dal.store.oraclespatial.OracleSpatialStoreParameters; |
|
26 | 21 |
import org.gvsig.fmap.dal.store.oraclespatial.OracleSpatialValues; |
27 | 22 |
import org.gvsig.fmap.mapcontext.MapContext; |
28 | 23 |
import org.gvsig.fmap.mapcontext.exceptions.LoadLayerException; |
... | ... | |
49 | 44 |
private MapContext theMapContext; |
50 | 45 |
private IWindow closeThis; |
51 | 46 |
|
47 |
/** |
|
48 |
* Constructor |
|
49 |
* @param wc |
|
50 |
* @param closeit |
|
51 |
* @param connPanel |
|
52 |
* @param mc |
|
53 |
*/ |
|
52 | 54 |
public NewOracleSpatialTableFinishAction(JWizardComponents wc, |
53 | 55 |
IWindow closeit, NewOracleSpatialTableWizard connPanel, |
54 | 56 |
MapContext mc) { |
... | ... | |
61 | 63 |
fieldsPanel = (RepeatedFieldDefinitionPanel) wc.getWizardPanel(1); |
62 | 64 |
} |
63 | 65 |
|
66 |
/** |
|
67 |
* run process |
|
68 |
*/ |
|
64 | 69 |
public void performAction() { |
65 | 70 |
|
66 | 71 |
PluginServices.getMDIManager().closeWindow(closeThis); |
... | ... | |
83 | 88 |
NewFeatureStoreParameters newStoreParams = (NewFeatureStoreParameters) explorer |
84 | 89 |
.getAddParameters(); |
85 | 90 |
|
86 |
((JDBCStoreParameters) newStoreParams).setTable(tableName);
|
|
87 |
|
|
91 |
((JDBCStoreParameters) newStoreParams).setTable(tableName); |
|
92 |
|
|
88 | 93 |
EditableFeatureType eFType = (EditableFeatureType) newStoreParams |
89 |
.getDefaultFeatureType();
|
|
90 |
|
|
94 |
.getDefaultFeatureType(); |
|
95 |
|
|
91 | 96 |
TableModel model = fieldsPanel.getFieldsDescription(); |
92 | 97 |
FeatureType fType = createDefaultFeatureType(eFType, model); |
93 |
|
|
98 |
|
|
94 | 99 |
newStoreParams.setDefaultFeatureType(fType); |
95 |
|
|
96 |
explorer.add(newStoreParams, true); |
|
97 |
|
|
98 |
target = (FeatureStore) dataManager.createStore(newStoreParams); |
|
99 |
|
|
100 | 100 |
|
101 |
explorer.add(newStoreParams, true); |
|
102 |
|
|
103 |
target = (FeatureStore) dataManager.createStore(newStoreParams); |
|
104 |
|
|
101 | 105 |
} catch (DataException e) { |
102 | 106 |
NotificationManager.addError(e.getMessage(), e); |
103 | 107 |
} catch (ValidateDataParametersException e) { |
... | ... | |
116 | 120 |
} |
117 | 121 |
lyr.setVisible(true); |
118 | 122 |
theMapContext.getLayers().addLayer(lyr); |
119 |
|
|
120 |
// |
|
121 |
// theMapContext.endAtomicEvent(); |
|
122 |
// |
|
123 |
// String usr = connectionPanel.getServExplorerParams(); |
|
124 |
// lyr_def.setUser(usr.toUpperCase()); |
|
125 |
// String epsg_code = vp.getProjection().getAbrev(); |
|
126 |
// lyr_def.setSRID_EPSG(epsg_code.substring(5)); |
|
127 |
// |
|
128 |
// lyr_def.setFieldID(OracleSpatialValues.ORACLE_ID_FIELD); |
|
129 |
// lyr_def.setFieldGeometry(OracleSpatialValues.DEFAULT_GEO_FIELD); |
|
130 |
// lyr_def.setWhereClause(""); |
|
131 |
// |
|
132 |
// Rectangle2D extent = vp.getAdjustedExtent(); |
|
133 |
// if (extent == null) { |
|
134 |
// int h = vp.getImageHeight(); |
|
135 |
// int w = vp.getImageWidth(); |
|
136 |
// extent = new Rectangle2D.Double(0, 0, w, h); |
|
137 |
// } |
|
138 |
// IConnection iconn = connectionPanel.getConnectionWithParams() |
|
139 |
// .getConnection(); |
|
140 |
// |
|
141 |
// // |
|
142 |
// -------------------------------------------------------------------- |
|
143 |
// // |
|
144 |
// ------------------------------------------------------------------- |
|
145 |
// // |
|
146 |
// -------------------------------------------------------------------- |
|
147 |
// theMapContext.beginAtomicEvent(); |
|
148 |
// |
|
149 |
// OracleSpatialWriter.createEmptyTable(lyr_def, iconn, extent); |
|
150 |
// OracleSpatialDriver oracleDrv = new OracleSpatialDriver(); |
|
151 |
// oracleDrv.setData(iconn, lyr_def); |
|
152 |
// FLyrVect lyr = (FLyrVect) LayerFactory.createDBLayer(oracleDrv, |
|
153 |
// table_name, vp.getProjection()); |
|
154 |
// |
|
155 |
// lyr.setVisible(true); |
|
156 |
// theMapContext.getLayers().addLayer(lyr); |
|
157 |
// theMapContext.endAtomicEvent(); |
|
158 |
|
|
159 | 123 |
} |
160 | 124 |
|
161 | 125 |
/** |
162 |
* |
|
163 |
* @param f_desc
|
|
164 |
* @return |
|
126 |
* Validate field name
|
|
127 |
* @param field name
|
|
128 |
* @return field name
|
|
165 | 129 |
*/ |
166 | 130 |
private String validFieldName(String name) { |
167 | 131 |
|
... | ... | |
175 | 139 |
} |
176 | 140 |
|
177 | 141 |
/** |
178 |
* |
|
142 |
* Build feature type from field table model
|
|
179 | 143 |
* @param eFType |
180 | 144 |
* @param model |
181 | 145 |
* @return |
branches/v2_0_0_prep/extensions/extOracleSpatial/src/org/gvsig/oraclespatial/extension/ExportToOracle.java | ||
---|---|---|
95 | 95 |
System.out.println("Start export process..."); |
96 | 96 |
} |
97 | 97 |
|
98 |
/** |
|
99 |
* run export process |
|
100 |
* @param mapContext |
|
101 |
* @param layer |
|
102 |
*/ |
|
98 | 103 |
public void toOracle(MapContext mapContext, FLyrVect layer) { |
99 | 104 |
|
100 | 105 |
// name of oracle table |
... | ... | |
125 | 130 |
|
126 | 131 |
this.createNewOracleStore(mapContext, layer, explorerParams, tableName, |
127 | 132 |
pkFieldName); |
128 |
|
|
129 | 133 |
} |
130 | 134 |
|
131 | 135 |
/** |
... | ... | |
198 | 202 |
} |
199 | 203 |
|
200 | 204 |
/** |
201 |
* |
|
205 |
* Create new fields and fill data
|
|
202 | 206 |
* @param explorer |
203 | 207 |
* @param params |
204 | 208 |
* @param set |
branches/v2_0_0_prep/extensions/extOracleSpatial/src/org/gvsig/oraclespatial/extension/NewOracleSpatialTableExtension.java | ||
---|---|---|
15 | 15 |
import com.iver.cit.gvsig.project.documents.view.gui.View; |
16 | 16 |
|
17 | 17 |
public class NewOracleSpatialTableExtension extends Extension { |
18 |
|
|
19 |
private static Logger logger = Logger.getLogger(NewOracleSpatialTableExtension.class.getName()); |
|
20 |
public static boolean ORACLE_JAR_PRESENT = false; |
|
21 |
|
|
22 | 18 |
|
19 |
private static Logger logger = Logger |
|
20 |
.getLogger(NewOracleSpatialTableExtension.class.getName()); |
|
21 |
public static boolean ORACLE_JAR_PRESENT = false; |
|
22 |
|
|
23 |
/** |
|
24 |
* Initialize extension |
|
25 |
*/ |
|
23 | 26 |
public void initialize() { |
27 |
// Validate if Oracle Jar is present |
|
24 | 28 |
ORACLE_JAR_PRESENT = isOracleJarPresent(); |
25 | 29 |
} |
26 | 30 |
|
31 |
/** |
|
32 |
* execute extension process |
|
33 |
* |
|
34 |
* @param event |
|
35 |
* name |
|
36 |
*/ |
|
27 | 37 |
public void execute(String actionCommand) { |
28 |
if (actionCommand.compareToIgnoreCase("NEW_ORACLE_SPATIAL") == 0) { |
|
29 | 38 |
|
30 |
IWindow w = PluginServices.getMDIManager().getActiveWindow(); |
|
31 |
if (w instanceof View) { |
|
32 |
try { |
|
33 |
String _file = createResourceUrl("images/new_geodb_table.png").getFile(); |
|
34 |
ImageIcon iicon = new ImageIcon(_file); |
|
35 |
|
|
36 |
WizardAndami wizard = new WizardAndami(iicon); |
|
37 |
RepeatedChooseGeometryTypePanel panelChoose = |
|
38 |
new RepeatedChooseGeometryTypePanel(wizard.getWizardComponents()); |
|
39 |
RepeatedFieldDefinitionPanel panelFields = |
|
40 |
new RepeatedFieldDefinitionPanel(wizard.getWizardComponents()); |
|
41 |
NewOracleSpatialTableWizard connPanel = |
|
42 |
new NewOracleSpatialTableWizard(wizard.getWizardComponents()); |
|
39 |
// NEW ORACLE TABLE |
|
40 |
if (actionCommand.compareToIgnoreCase("NEW_ORACLE_SPATIAL") == 0) { |
|
43 | 41 |
|
44 |
wizard.getWizardComponents().addWizardPanel(panelChoose); |
|
45 |
wizard.getWizardComponents().addWizardPanel(panelFields); |
|
46 |
wizard.getWizardComponents().addWizardPanel(connPanel); |
|
42 |
IWindow w = PluginServices.getMDIManager().getActiveWindow(); |
|
43 |
if (w instanceof View) { |
|
44 |
try { |
|
45 |
String _file = createResourceUrl( |
|
46 |
"images/new_geodb_table.png").getFile(); |
|
47 |
ImageIcon iicon = new ImageIcon(_file); |
|
47 | 48 |
|
48 |
View theView = (View) w; |
|
49 |
MapContext mc = theView.getMapControl().getMapContext(); |
|
50 |
|
|
51 |
NewOracleSpatialTableFinishAction action = |
|
52 |
new NewOracleSpatialTableFinishAction( |
|
53 |
wizard.getWizardComponents(), |
|
54 |
wizard, |
|
55 |
connPanel, |
|
56 |
mc); |
|
57 |
|
|
58 |
wizard.getWizardComponents().setFinishAction(action); |
|
59 |
wizard.getWizardComponents().getFinishButton().setEnabled(false); |
|
60 |
wizard.getWindowInfo().setWidth(640); |
|
61 |
wizard.getWindowInfo().setHeight(350); |
|
62 |
wizard.getWindowInfo().setTitle(PluginServices.getText(this, "new_layer")); |
|
63 |
PluginServices.getMDIManager().addWindow(wizard); |
|
64 |
|
|
65 |
} catch (Exception ex) { |
|
66 |
logger.error("While showing new oracle spatial table wizard: " + ex.getMessage()); |
|
67 |
} |
|
68 |
} |
|
69 |
} |
|
49 |
WizardAndami wizard = new WizardAndami(iicon); |
|
50 |
RepeatedChooseGeometryTypePanel panelChoose = new RepeatedChooseGeometryTypePanel( |
|
51 |
wizard.getWizardComponents()); |
|
52 |
RepeatedFieldDefinitionPanel panelFields = new RepeatedFieldDefinitionPanel( |
|
53 |
wizard.getWizardComponents()); |
|
54 |
NewOracleSpatialTableWizard connPanel = new NewOracleSpatialTableWizard( |
|
55 |
wizard.getWizardComponents()); |
|
56 |
|
|
57 |
wizard.getWizardComponents().addWizardPanel(panelChoose); |
|
58 |
wizard.getWizardComponents().addWizardPanel(panelFields); |
|
59 |
wizard.getWizardComponents().addWizardPanel(connPanel); |
|
60 |
|
|
61 |
View theView = (View) w; |
|
62 |
MapContext mc = theView.getMapControl().getMapContext(); |
|
63 |
|
|
64 |
NewOracleSpatialTableFinishAction action = new NewOracleSpatialTableFinishAction( |
|
65 |
wizard.getWizardComponents(), wizard, connPanel, mc); |
|
66 |
|
|
67 |
wizard.getWizardComponents().setFinishAction(action); |
|
68 |
wizard.getWizardComponents().getFinishButton().setEnabled( |
|
69 |
false); |
|
70 |
wizard.getWindowInfo().setWidth(640); |
|
71 |
wizard.getWindowInfo().setHeight(350); |
|
72 |
wizard.getWindowInfo().setTitle( |
|
73 |
PluginServices.getText(this, "new_layer")); |
|
74 |
PluginServices.getMDIManager().addWindow(wizard); |
|
75 |
|
|
76 |
} catch (Exception ex) { |
|
77 |
logger |
|
78 |
.error("While showing new oracle spatial table wizard: " |
|
79 |
+ ex.getMessage()); |
|
80 |
} |
|
81 |
} |
|
82 |
} |
|
70 | 83 |
} |
71 | 84 |
|
85 |
/** |
|
86 |
* extension enable |
|
87 |
* |
|
88 |
* @return |
|
89 |
*/ |
|
72 | 90 |
public boolean isEnabled() { |
73 | 91 |
|
74 |
if (!ORACLE_JAR_PRESENT) return false; |
|
75 |
|
|
92 |
if (!ORACLE_JAR_PRESENT) |
|
93 |
return false; |
|
94 |
|
|
76 | 95 |
IWindow w = PluginServices.getMDIManager().getActiveWindow(); |
77 |
return (w instanceof View);
|
|
96 |
return (w instanceof View);
|
|
78 | 97 |
} |
79 | 98 |
|
99 |
/** |
|
100 |
* extension functionalities visible |
|
101 |
* |
|
102 |
* @return |
|
103 |
*/ |
|
80 | 104 |
public boolean isVisible() { |
81 | 105 |
return isEnabled(); |
82 | 106 |
} |
83 |
|
|
107 |
|
|
84 | 108 |
/** |
85 | 109 |
* Check presence of ojdbc14.jar. |
110 |
* |
|
86 | 111 |
* @return |
87 | 112 |
*/ |
88 |
private boolean isOracleJarPresent() { |
|
89 |
|
|
90 |
try { |
|
91 |
Class rowid_class = Class.forName("oracle.sql.ROWID"); |
|
92 |
} catch (Exception ex) { |
|
93 |
logger.error("Unable to instantiate ROWID (oracle jar missing?) : " + ex.getMessage()); |
|
94 |
return false; |
|
95 |
} |
|
113 |
private boolean isOracleJarPresent() { |
|
114 |
|
|
115 |
try { |
|
116 |
Class rowid_class = Class.forName("oracle.sql.ROWID"); |
|
117 |
} catch (Exception ex) { |
|
118 |
logger.error("Unable to instantiate ROWID (oracle jar missing?) : " |
|
119 |
+ ex.getMessage()); |
|
120 |
return false; |
|
121 |
} |
|
96 | 122 |
return true; |
97 |
} |
|
98 |
|
|
99 |
private java.net.URL createResourceUrl(String path) { |
|
100 |
return getClass().getClassLoader().getResource(path); |
|
101 |
} |
|
123 |
} |
|
102 | 124 |
|
125 |
private java.net.URL createResourceUrl(String path) { |
|
126 |
return getClass().getClassLoader().getResource(path); |
|
127 |
} |
|
128 |
|
|
103 | 129 |
} |
branches/v2_0_0_prep/extensions/extOracleSpatial/src/org/gvsig/oraclespatial/gui/NewOracleSpatialTableWizard.java | ||
---|---|---|
34 | 34 |
import java.beans.PropertyChangeEvent; |
35 | 35 |
import java.beans.PropertyChangeListener; |
36 | 36 |
|
37 |
import javax.swing.JLabel; |
|
38 |
|
|
39 | 37 |
import jwizardcomponent.JWizardComponents; |
40 | 38 |
import jwizardcomponent.JWizardPanel; |
41 | 39 |
|
42 | 40 |
import org.slf4j.Logger; |
43 | 41 |
import org.slf4j.LoggerFactory; |
44 | 42 |
|
45 |
import com.iver.andami.PluginServices; |
|
46 | 43 |
import com.prodevelop.cit.gvsig.vectorialdb.wizard.MyExplorer; |
47 | 44 |
|
48 | 45 |
/** |
... | ... | |
54 | 51 |
|
55 | 52 |
public class NewOracleSpatialTableWizard extends JWizardPanel implements |
56 | 53 |
ItemListener, PropertyChangeListener { |
57 |
|
|
54 |
|
|
55 |
private static final long serialVersionUID = 1L; |
|
56 |
@SuppressWarnings("unused") |
|
58 | 57 |
private static final Logger logger = LoggerFactory |
59 | 58 |
.getLogger(NewOracleSpatialTableWizard.class); |
60 | 59 |
private ConnectionChooserPanel connectionPanel = null; |
... | ... | |
124 | 123 |
* This method initializes this |
125 | 124 |
* |
126 | 125 |
*/ |
127 |
private void initialize() {
|
|
126 |
private void initialize() { |
|
128 | 127 |
|
129 | 128 |
connectionPanel = new ConnectionChooserPanel(); |
130 |
|
|
129 |
|
|
131 | 130 |
this.setLayout(new GridBagLayout()); |
132 | 131 |
this.setSize(new java.awt.Dimension(358, 263)); |
133 |
|
|
132 |
|
|
134 | 133 |
GridBagConstraints gridBagConstraints = new GridBagConstraints(); |
135 | 134 |
gridBagConstraints.gridx = 0; |
136 | 135 |
gridBagConstraints.gridy = 0; |
... | ... | |
138 | 137 |
gridBagConstraints.weightx = 1.0; |
139 | 138 |
gridBagConstraints.weighty = 1.0; |
140 | 139 |
this.add(connectionPanel, gridBagConstraints); |
141 |
|
|
140 |
|
|
142 | 141 |
connectionPanel.availableConnectionsComboBox.addItemListener(this); |
143 |
|
|
142 |
|
|
144 | 143 |
getWizardComponents().getFinishButton().setEnabled(false); |
145 | 144 |
} |
146 | 145 |
|
147 |
|
|
148 | 146 |
} |
branches/v2_0_0_prep/extensions/extOracleSpatial/src/org/gvsig/oraclespatial/gui/RepeatedFieldDefinitionPanel.java | ||
---|---|---|
3 | 3 |
import java.awt.BorderLayout; |
4 | 4 |
import java.awt.Component; |
5 | 5 |
import java.util.ArrayList; |
6 |
import java.util.List; |
|
6 | 7 |
|
7 | 8 |
import javax.swing.DefaultCellEditor; |
8 | 9 |
import javax.swing.JButton; |
... | ... | |
22 | 23 |
import jwizardcomponent.JWizardComponents; |
23 | 24 |
import jwizardcomponent.JWizardPanel; |
24 | 25 |
|
25 |
import org.gvsig.fmap.dal.feature.FeatureType; |
|
26 |
|
|
27 | 26 |
import com.iver.andami.PluginServices; |
28 | 27 |
|
29 | 28 |
/** |
... | ... | |
34 | 33 |
*/ |
35 | 34 |
public class RepeatedFieldDefinitionPanel extends JWizardPanel { |
36 | 35 |
|
36 |
private static final long serialVersionUID = 1L; |
|
37 |
|
|
37 | 38 |
private JLabel jLabel = null; |
38 | 39 |
private JScrollPane jScrollPane = null; |
39 | 40 |
private JTable jTable = null; |
... | ... | |
97 | 98 |
} |
98 | 99 |
|
99 | 100 |
// ensure no field name is used more than once |
100 |
ArrayList fieldNames = new ArrayList();
|
|
101 |
List<Object> fieldNames = new ArrayList<Object>();
|
|
101 | 102 |
for (int i = 0; i < jTable.getRowCount(); i++) { |
102 | 103 |
if (fieldNames.contains(tm.getValueAt(i, 0))) { |
103 | 104 |
valid = false; |
... | ... | |
165 | 166 |
+ "\n" |
166 | 167 |
+ PluginServices.getText(this, |
167 | 168 |
"contiene_espacios_en_blanco")); |
168 |
}
|
|
169 |
} |
|
169 | 170 |
return valid; |
170 | 171 |
} |
171 | 172 |
|
... | ... | |
284 | 285 |
.getModel(); |
285 | 286 |
|
286 | 287 |
// Figure out a suitable field name |
287 |
ArrayList fieldNames = new ArrayList();
|
|
288 |
List<Object> fieldNames = new ArrayList<Object>();
|
|
288 | 289 |
for (int i = 0; i < jTable.getRowCount(); i++) { |
289 | 290 |
fieldNames.add(tm.getValueAt(i, 0)); |
290 | 291 |
} |
branches/v2_0_0_prep/extensions/extOracleSpatial/src/org/gvsig/oraclespatial/gui/OracleConnectionChooserPanel.java | ||
---|---|---|
55 | 55 |
public class OracleConnectionChooserPanel extends JPanel implements IWindow, |
56 | 56 |
ActionListener, ItemListener, KeyListener { |
57 | 57 |
|
58 |
private static final long serialVersionUID = 1L; |
|
59 |
|
|
58 | 60 |
@SuppressWarnings("unused") |
59 | 61 |
private static Logger logger = LoggerFactory |
60 | 62 |
.getLogger(OracleConnectionChooserPanel.class.getName()); |
... | ... | |
133 | 135 |
} |
134 | 136 |
|
135 | 137 |
/** |
136 |
* |
|
138 |
* changes selected item
|
|
137 | 139 |
*/ |
138 | 140 |
public void itemStateChanged(ItemEvent e) { |
139 | 141 |
// combo explorers |
... | ... | |
151 | 153 |
okButton.setEnabled(true); |
152 | 154 |
okButton.requestFocus(); |
153 | 155 |
} |
154 |
} |
|
155 |
|
|
156 |
} |
|
156 | 157 |
} |
157 | 158 |
|
158 |
|
|
159 |
|
|
160 | 159 |
/** |
161 | 160 |
* Key pressed event |
162 | 161 |
*/ |
... | ... | |
229 | 228 |
if(selectedExplorerParams == null){ |
230 | 229 |
getOkButton().setEnabled(false); |
231 | 230 |
} |
232 |
|
|
233 |
|
|
234 | 231 |
} |
235 | 232 |
|
236 | 233 |
/** |
... | ... | |
259 | 256 |
cancelButton.addKeyListener(this); |
260 | 257 |
} |
261 | 258 |
return cancelButton; |
262 |
} |
|
259 |
}
|
|
263 | 260 |
|
264 |
|
|
265 |
|
|
266 | 261 |
} |
branches/v2_0_0_prep/extensions/extOracleSpatial/src/org/gvsig/oraclespatial/gui/RepeatedChooseGeometryTypePanel.java | ||
---|---|---|
23 | 23 |
*/ |
24 | 24 |
public class RepeatedChooseGeometryTypePanel extends JWizardPanel { |
25 | 25 |
|
26 |
private static final long serialVersionUID = 1L; |
|
27 |
|
|
26 | 28 |
private JLabel lblSelecGeometryType = null; |
27 | 29 |
private JPanel jPanelGeometryTypeOptions = null; |
28 | 30 |
private JRadioButton jRadioButtonPoint = null; |
... | ... | |
63 | 65 |
if (getJRadioButtonMultiPoint().isSelected()) |
64 | 66 |
return Geometry.TYPES.MULTIPOINT; |
65 | 67 |
if (getJRadioButtonLine().isSelected()) |
66 |
return Geometry.TYPES.ARC;
|
|
68 |
return Geometry.TYPES.CURVE;
|
|
67 | 69 |
if (getJRadioButtonPolygon().isSelected()) |
68 | 70 |
return Geometry.TYPES.SURFACE; |
69 | 71 |
if (getJRadioButtonMulti().isSelected()) |
branches/v2_0_0_prep/extensions/extOracleSpatial/src/org/gvsig/oraclespatial/gui/ConnectionChooserPanel.java | ||
---|---|---|
31 | 31 |
import java.awt.GridBagLayout; |
32 | 32 |
import java.awt.event.ActionEvent; |
33 | 33 |
import java.awt.event.ActionListener; |
34 |
import java.awt.event.ItemListener; |
|
35 | 34 |
import java.util.List; |
36 | 35 |
|
37 | 36 |
import javax.swing.ImageIcon; |
... | ... | |
51 | 50 |
import com.prodevelop.cit.gvsig.vectorialdb.wizard.VectorialDBConnectionParamsDialog; |
52 | 51 |
|
53 | 52 |
/** |
54 |
* This dialog lets the user choose an available connection. |
|
53 |
* This dialog lets the user choose an available connection (explorer).
|
|
55 | 54 |
* |
56 | 55 |
* @author jldominguez, vsanjaime |
57 | 56 |
* |
Also available in: Unified diff