Revision 41483 trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.jdbc/src/main/java/org/gvsig/fmap/dal/store/jdbc/JDBCHelper.java
JDBCHelper.java | ||
---|---|---|
849 | 849 |
return geometry; |
850 | 850 |
} |
851 | 851 |
|
852 |
public Object dalValueToJDBC( |
|
853 |
FeatureAttributeDescriptor attributeDescriptor, Object object) |
|
854 |
throws WriteException { |
|
852 |
public Object dalValueToJDBC( |
|
853 |
FeatureAttributeDescriptor attributeDescriptor, Object value) |
|
854 |
throws WriteException { |
|
855 |
|
|
856 |
try { |
|
857 |
if (value == null) { |
|
858 |
return null; |
|
859 |
} |
|
860 |
switch (attributeDescriptor.getType()) { |
|
861 |
case DataTypes.TIME: |
|
862 |
return new Time(((Date)value).getTime()); |
|
863 |
|
|
864 |
case DataTypes.GEOMETRY: |
|
865 |
IProjection srs = null; |
|
866 |
byte[] wkb = null; |
|
867 |
Geometry geom = null; |
|
868 |
try { |
|
869 |
geom = (Geometry)value; |
|
870 |
Geometry geom1 = coerce(attributeDescriptor.getGeomType(), geom); |
|
871 |
srs = attributeDescriptor.getSRS(); |
|
872 |
if (srs != null) { |
|
873 |
wkb = geom1.convertToWKBForcingType(getProviderSRID(srs), attributeDescriptor.getGeomType().getType()); |
|
874 |
} else { |
|
875 |
wkb = geom1.convertToWKB(); |
|
876 |
} |
|
877 |
} catch (Exception e) { |
|
878 |
String problem = ""; |
|
879 |
if (geom != null) { |
|
880 |
Geometry.ValidationStatus vs = geom.getValidationStatus(); |
|
881 |
problem = vs.getMessage(); |
|
882 |
} |
|
883 |
throw new DalValueToJDBCException(attributeDescriptor, value, problem, e); |
|
884 |
} |
|
885 |
return wkb; |
|
886 |
|
|
887 |
default: |
|
888 |
return value; |
|
889 |
} |
|
855 | 890 |
|
856 |
IProjection srs = null; |
|
857 |
byte[] wkb = null; |
|
858 |
Geometry geom = null; |
|
859 |
try { |
|
860 |
if (object == null) { |
|
861 |
return null; |
|
862 |
} |
|
863 |
|
|
864 |
if (attributeDescriptor.getType() == DataTypes.TIME) { |
|
865 |
return new Time(((Date)object).getTime()); |
|
866 |
} |
|
867 |
if (attributeDescriptor.getType() != DataTypes.GEOMETRY) { |
|
868 |
return object; |
|
869 |
} |
|
870 |
geom = coerce(attributeDescriptor.getGeomType(),(Geometry) object); |
|
871 |
srs = attributeDescriptor.getSRS(); |
|
872 |
if (srs != null) { |
|
873 |
wkb = geom.convertToWKBForcingType(getProviderSRID(srs), attributeDescriptor.getGeomType().getType()); |
|
874 |
} else { |
|
875 |
wkb = geom.convertToWKB(); |
|
876 |
} |
|
877 |
return wkb; |
|
878 |
} catch (Exception e) { |
|
879 |
String problem = ""; |
|
880 |
if( geom!=null ) { |
|
881 |
Geometry.ValidationStatus vs = geom.getValidationStatus(); |
|
882 |
problem = vs.getMessage(); |
|
883 |
} |
|
884 |
throw new DalValueToJDBCException(attributeDescriptor, object,problem, e); |
|
885 |
} |
|
886 |
} |
|
891 |
} catch(DalValueToJDBCException ex) { |
|
892 |
throw ex; |
|
893 |
} catch (Exception e) { |
|
894 |
throw new DalValueToJDBCException(attributeDescriptor, value, e); |
|
895 |
} |
|
887 | 896 |
|
897 |
} |
|
898 |
|
|
888 | 899 |
public String getSqlColumnTypeDescription(FeatureAttributeDescriptor attr) { |
889 | 900 |
switch (attr.getType()) { |
890 | 901 |
case DataTypes.STRING: |
Also available in: Unified diff