Revision 40417
branches/v2_0_0_prep/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/postgresql/PostgreSQLHelper.java | ||
---|---|---|
234 | 234 |
} |
235 | 235 |
}); |
236 | 236 |
} |
237 |
|
|
238 |
public String getVersion() throws DataException { |
|
239 |
final String sql = "Select PostGIS_lib_version()"; |
|
240 |
|
|
241 |
this.open(); |
|
237 | 242 |
|
243 |
return (String) getResource().execute(new ResourceAction() { |
|
244 |
public Object run() throws Exception { |
|
245 |
ResultSet rs = null; |
|
246 |
Statement st = null; |
|
247 |
Connection conn = null; |
|
248 |
try { |
|
249 |
conn = getConnection(); |
|
250 |
st = conn.createStatement(); |
|
251 |
try { |
|
252 |
rs = st.executeQuery(sql); |
|
253 |
} catch (java.sql.SQLException e) { |
|
254 |
throw new JDBCExecuteSQLException(sql, e); |
|
255 |
} |
|
256 |
if (!rs.next()) { |
|
257 |
return null; |
|
258 |
} |
|
259 |
|
|
260 |
String data = rs.getString(1); |
|
261 |
if (data == null) { |
|
262 |
return null; |
|
263 |
} |
|
264 |
return data; |
|
265 |
} catch (java.sql.SQLException e) { |
|
266 |
throw new JDBCSQLException(e); |
|
267 |
} catch (BaseException e) { |
|
268 |
throw new ReadException(user.getProviderName(), e); |
|
269 |
} finally { |
|
270 |
try { |
|
271 |
rs.close(); |
|
272 |
} catch (Exception e) { |
|
273 |
} |
|
274 |
try { |
|
275 |
st.close(); |
|
276 |
} catch (Exception e) { |
|
277 |
} |
|
278 |
try { |
|
279 |
conn.close(); |
|
280 |
} catch (Exception e) { |
|
281 |
} |
|
282 |
rs = null; |
|
283 |
st = null; |
|
284 |
conn = null; |
|
285 |
} |
|
286 |
} |
|
287 |
}); |
|
288 |
} |
|
289 |
|
|
238 | 290 |
@Override |
239 | 291 |
protected boolean supportsGeometry() { |
240 | 292 |
return true; |
... | ... | |
796 | 848 |
return super.getSqlFieldDescription(attr); |
797 | 849 |
} |
798 | 850 |
|
799 |
|
|
800 | 851 |
public boolean allowAutomaticValues() { |
801 | 852 |
return Boolean.TRUE; |
802 | 853 |
} |
branches/v2_0_0_prep/libraries/libFMap_daldb/src/org/gvsig/fmap/dal/store/postgresql/PostgreSQLStoreProvider.java | ||
---|---|---|
67 | 67 |
DataStoreProviderServices storeServices) |
68 | 68 |
throws InitializeException { |
69 | 69 |
super(params, storeServices, DBHelper.newMetadataContainer(METADATA_DEFINITION_NAME)); |
70 |
/*try { |
|
71 |
System.out.println("======>>>>>" + ((PostgreSQLHelper) helper).getVersion()); |
|
72 |
} catch (DataException e) { |
|
73 |
e.printStackTrace(); |
|
74 |
}*/ |
|
70 | 75 |
} |
71 | 76 |
|
72 | 77 |
private PostgreSQLStoreParameters getPGParameters() { |
... | ... | |
225 | 230 |
FeatureAttributeDescriptor attr, List<String> fields, List<String> values) { |
226 | 231 |
|
227 | 232 |
if (attr.getType() == DataTypes.GEOMETRY) { |
228 |
fields.add(helper.escapeFieldName(attr.getName())); |
|
229 |
values.add("ST_GeomFromWKB(?,?)"); |
|
233 |
fields.add(helper.escapeFieldName(attr.getName())); |
|
234 |
int subType = attr.getGeomType().getSubType(); |
|
235 |
if(subType == Geometry.SUBTYPES.GEOM3D) |
|
236 |
values.add("ST_Force_4D(ST_GeomFromWKB(?,?))"); |
|
237 |
else |
|
238 |
values.add("ST_GeomFromWKB(?,?)"); |
|
230 | 239 |
} else { |
231 | 240 |
super.prepareAttributeForInsert(attr, fields, values); |
232 | 241 |
} |
... | ... | |
236 | 245 |
protected void prepareAttributeForUpdate(FeatureAttributeDescriptor attr, |
237 | 246 |
List<String> values) { |
238 | 247 |
if (attr.getType() == DataTypes.GEOMETRY) { |
239 |
values.add(helper.escapeFieldName(attr.getName()) |
|
240 |
+ " = ST_GeomFromWKB(?,?)"); |
|
248 |
int subType = attr.getGeomType().getSubType(); |
|
249 |
if(subType == Geometry.SUBTYPES.GEOM3D) |
|
250 |
values.add(helper.escapeFieldName(attr.getName()) + " = ST_Force_4D(ST_GeomFromWKB(?,?))"); |
|
251 |
else |
|
252 |
values.add(helper.escapeFieldName(attr.getName()) + " = ST_GeomFromWKB(?,?)"); |
|
241 | 253 |
} else { |
242 | 254 |
super.prepareAttributeForUpdate(attr, values); |
243 | 255 |
} |
Also available in: Unified diff