|
From: Senthil <sen...@gm...> - 2010-07-16 10:40:48
|
Hi Ben Here JIRA issue : http://jira.codehaus.org/browse/GEOT-3198 <http://jira.codehaus.org/browse/GEOT-3198>Regards Senthil On Thu, Jul 15, 2010 at 2:56 PM, Ben Caradoc-Davies <Ben...@cs...> wrote: > Sorry, it should be a GeoTools issue: > http://jira.codehaus.org/browse/GEOT > > > On 15/07/10 10:46, Ben Caradoc-Davies wrote: > >> Senthil, >> >> please submit your patch attached to a GeoServer Jira issue: >> http://jira.codehaus.org/browse/GEOS >> >> Kind regards, >> Ben. >> >> On 08/07/10 16:54, Senthil wrote: >> >>> Hi all, >>> >>> When i used Oracle database table with primary key is NUMBER(38,0) to >>> represent with complex feature, The following exception thrown >>> >>> 4 Jul 16:32:27 WARN [org.geotools.jdbc] - Unable to convert 4198885 to >>> java.math.BigDecimal >>> 4 Jul 16:32:27 DEBUG [org.geotools.jdbc] - CLOSE CONNECTION >>> 4 Jul 16:32:27 ERROR [org.geoserver.ows] - >>> java.lang.RuntimeException: java.io.IOException >>> at >>> org.geotools.data.store.ContentFeatureCollection.iterator(ContentFeatureCollection.java:266) >>> at >>> org.geotools.data.complex.DataAccessMappingFeatureIterator.setNextFilteredFeature(DataAccessMappingFeatureIterator.java:628) >>> at >>> org.geotools.data.complex.DataAccessMappingFeatureIterator.computeNext(DataAccessMappingFeatureIterator.java:674) >>> at >>> org.geotools.data.complex.AbstractMappingFeatureIterator.next(AbstractMappingFeatureIterator.java:193) >>> at >>> org.geotools.data.complex.AbstractMappingFeatureIterator.next(AbstractMappingFeatureIterator.java:64) >>> at >>> org.geotools.data.complex.NestedAttributeMapping.getFeatures(NestedAttributeMapping.java:286) >>> at >>> org.geotools.data.complex.DataAccessMappingFeatureIterator.setAttributeValue(DataAccessMappingFeatureIterator.java:373) >>> at >>> org.geotools.data.complex.DataAccessMappingFeatureIterator.computeNext(DataAccessMappingFeatureIterator.java:701) >>> at >>> org.geotools.data.complex.AbstractMappingFeatureIterator.next(AbstractMappingFeatureIterator.java:193) >>> at >>> org.geotools.data.complex.MappingFeatureCollection.size(MappingFeatureCollection.java:300) >>> >>> I found the reason for that and wrote a BigDecimalConverterFactory class >>> to util package, which solved the issue. >>> --------------------------------------------------------------- >>> >>> package org.geotools.util; >>> >>> import java.math.BigDecimal; >>> import java.math.BigInteger; >>> >>> import org.geotools.factory.Hints; >>> >>> public class BigDecimalConverterFactory implements ConverterFactory { >>> >>> public Converter createConverter(Class source, Class target, Hints >>> hints) { >>> >>> if ( target.equals( BigDecimal.class ) ) { >>> >>> //string to BigDecimal >>> if ( source.equals( String.class ) ) { >>> return new Converter() { >>> >>> public Object convert(Object source, Class target) throws Exception >>> { >>> return new BigDecimal(source.toString()); >>> } >>> >>> }; >>> } >>> >>> //integer to BigDecimal >>> if ( source.equals( Integer.class ) ) { >>> return new Converter() { >>> >>> public Object convert(Object source, Class target) throws Exception >>> { >>> if (source.equals((Integer)source)) >>> return new BigDecimal((Integer)source); >>> else >>> return null; >>> } >>> >>> }; >>> } >>> >>> //org.geotools.filter.identity.FeatureIdImpl to BigDecimal >>> if ( source.equals( org.geotools.filter.identity.FeatureIdImpl.class >>> ) ) { >>> return new Converter() { >>> >>> public Object convert(Object source, Class target) throws Exception >>> { >>> if (source.toString().matches("((-|\\+)?[0-9]+(\\.[0-9 ( >>> file://\.[0-9 )]+)?)+")) >>> return new BigDecimal(source.toString()); >>> else >>> return null; >>> } >>> >>> }; >>> } >>> >>> // BigInteger to BigDecimal >>> if ( source.equals( BigInteger.class ) ) { >>> return new Converter() { >>> >>> public Object convert(Object source, Class target) throws Exception >>> { >>> if (source.equals((BigInteger)source)) >>> return new BigDecimal((BigInteger)source); >>> else >>> return null; >>> } >>> >>> }; >>> } >>> >>> // double to BigDecimal >>> if ( source.equals( Double.class ) ) { >>> return new Converter() { >>> >>> public Object convert(Object source, Class target) throws Exception >>> { >>> if (source.equals((Double)source)) >>> return new BigDecimal((Double)source); >>> else >>> return null; >>> } >>> >>> }; >>> } >>> >>> } >>> >>> return null; >>> } >>> >>> } >>> ------------------------------------------------------ >>> >>> Regards >>> Senthil >>> >>> >> >> > > -- > Ben Caradoc-Davies <Ben...@cs...> > Software Engineering Team Leader > CSIRO Earth Science and Resource Engineering > Australian Resources Research Centre > |