From: <svn...@os...> - 2012-05-16 05:16:00
|
Author: ang05a Date: 2012-05-15 22:15:52 -0700 (Tue, 15 May 2012) New Revision: 38736 Modified: trunk/modules/extension/app-schema/app-schema/src/main/java/org/geotools/data/complex/MappingAttributeIterator.java trunk/modules/extension/app-schema/app-schema/src/test/java/org/geotools/util/ComplexAttributeConverterFactoryTest.java trunk/modules/unsupported/app-schema/webservice/pom.xml trunk/modules/unsupported/app-schema/webservice/src/main/java/org/geotools/filter/AsXpathFunctionExpression.java Log: Fix svn properties for some app-schema files. Modified: trunk/modules/extension/app-schema/app-schema/src/main/java/org/geotools/data/complex/MappingAttributeIterator.java =================================================================== --- trunk/modules/extension/app-schema/app-schema/src/main/java/org/geotools/data/complex/MappingAttributeIterator.java 2012-05-16 01:36:44 UTC (rev 38735) +++ trunk/modules/extension/app-schema/app-schema/src/main/java/org/geotools/data/complex/MappingAttributeIterator.java 2012-05-16 05:15:52 UTC (rev 38736) @@ -1,85 +1,85 @@ -/* - * GeoTools - The Open Source Java GIS Toolkit - * http://geotools.org - * - * (C) 2007-2011, Open Source Geospatial Foundation (OSGeo) - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - */ - -package org.geotools.data.complex; - -import java.io.IOException; -import java.util.Iterator; - -import org.geotools.data.Query; -import org.geotools.data.complex.filter.XPath.StepList; -import org.geotools.feature.Types; -import org.opengis.feature.type.Name; -/** - * A Feature iterator that operates over the FeatureSource of a - * {@linkplain org.geotools.data.complex.FeatureTypeMapping} that is of a simple content type, e.g. - * representing a gml:name element. This is required for feature chaining for such types to reduce - * the need of creating an additional database view when simple element values come from another - * table. Therefore this iterator should have a method that return attributes that are to be chained - * directly in another feature type. - * - * @author Rini Angreani (CSIRO Earth Science and Resource Engineering) - * - * @source $URL: - * http://svn.osgeo.org/geotools/trunk/modules/extension/app-schema/app-schema/src/main - * /java/org/geotools/data/complex/MappingAttributeIterator.java $ - * http://svn.osgeo.org/geotools/trunk/modules/unsupported/app-schema/app-schema/src/main - * /java/org/geotools/data/complex/MappingAttributeIterator.java $ - * @since 2.7 - */ -public class MappingAttributeIterator extends DataAccessMappingFeatureIterator { - /** - * Name of the chained element, e.g. gml:name. - */ - private Name elementName; - - public MappingAttributeIterator(AppSchemaDataAccess store, FeatureTypeMapping mapping, - Query query, Query unrolledQuery) throws IOException { - super(store, mapping, query, unrolledQuery); - elementName = mapping.getTargetFeature().getName(); - checkAttributeMappings(); - } - - private void checkAttributeMappings() { - // there should only be 1 attribute mapping for this element since it's a simple type - // exception for FEATURE_LINK attributes - Iterator<AttributeMapping> mappings = mapping.getAttributeMappings().iterator(); - AttributeMapping rootMapping = null; - while (mappings.hasNext()) { - AttributeMapping att = mappings.next(); - StepList xpath = att.getTargetXPath(); - if (Types.equals(elementName, xpath)) { - if (rootMapping != null) { - throw new RuntimeException("Duplicate AttributeMapping for: '" + elementName - + "' is found in FeatureTypeMapping '" + elementName + "'!"); - } - rootMapping = att; - } else if (!Types.equals(ComplexFeatureConstants.FEATURE_CHAINING_LINK_NAME, xpath)) { - // log warning - String msg = "AttributeMapping for: '" + xpath + "' found in FeatureTypeMapping '" - + elementName - + "' ! This will be ignored as it doesn't belong to the type."; - LOGGER.warning(msg); - } - } - if (rootMapping == null) { - // not found, throw exception - throw new RuntimeException("AttributeMapping for: '" + elementName - + "' is missing in FeatureTypeMapping '" + elementName + "'!"); - } - } -} +/* + * GeoTools - The Open Source Java GIS Toolkit + * http://geotools.org + * + * (C) 2007-2011, Open Source Geospatial Foundation (OSGeo) + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + */ + +package org.geotools.data.complex; + +import java.io.IOException; +import java.util.Iterator; + +import org.geotools.data.Query; +import org.geotools.data.complex.filter.XPath.StepList; +import org.geotools.feature.Types; +import org.opengis.feature.type.Name; +/** + * A Feature iterator that operates over the FeatureSource of a + * {@linkplain org.geotools.data.complex.FeatureTypeMapping} that is of a simple content type, e.g. + * representing a gml:name element. This is required for feature chaining for such types to reduce + * the need of creating an additional database view when simple element values come from another + * table. Therefore this iterator should have a method that return attributes that are to be chained + * directly in another feature type. + * + * @author Rini Angreani (CSIRO Earth Science and Resource Engineering) + * + * @source $URL: + * http://svn.osgeo.org/geotools/trunk/modules/extension/app-schema/app-schema/src/main + * /java/org/geotools/data/complex/MappingAttributeIterator.java $ + * http://svn.osgeo.org/geotools/trunk/modules/unsupported/app-schema/app-schema/src/main + * /java/org/geotools/data/complex/MappingAttributeIterator.java $ + * @since 2.7 + */ +public class MappingAttributeIterator extends DataAccessMappingFeatureIterator { + /** + * Name of the chained element, e.g. gml:name. + */ + private Name elementName; + + public MappingAttributeIterator(AppSchemaDataAccess store, FeatureTypeMapping mapping, + Query query, Query unrolledQuery) throws IOException { + super(store, mapping, query, unrolledQuery); + elementName = mapping.getTargetFeature().getName(); + checkAttributeMappings(); + } + + private void checkAttributeMappings() { + // there should only be 1 attribute mapping for this element since it's a simple type + // exception for FEATURE_LINK attributes + Iterator<AttributeMapping> mappings = mapping.getAttributeMappings().iterator(); + AttributeMapping rootMapping = null; + while (mappings.hasNext()) { + AttributeMapping att = mappings.next(); + StepList xpath = att.getTargetXPath(); + if (Types.equals(elementName, xpath)) { + if (rootMapping != null) { + throw new RuntimeException("Duplicate AttributeMapping for: '" + elementName + + "' is found in FeatureTypeMapping '" + elementName + "'!"); + } + rootMapping = att; + } else if (!Types.equals(ComplexFeatureConstants.FEATURE_CHAINING_LINK_NAME, xpath)) { + // log warning + String msg = "AttributeMapping for: '" + xpath + "' found in FeatureTypeMapping '" + + elementName + + "' ! This will be ignored as it doesn't belong to the type."; + LOGGER.warning(msg); + } + } + if (rootMapping == null) { + // not found, throw exception + throw new RuntimeException("AttributeMapping for: '" + elementName + + "' is missing in FeatureTypeMapping '" + elementName + "'!"); + } + } +} Property changes on: trunk/modules/extension/app-schema/app-schema/src/main/java/org/geotools/data/complex/MappingAttributeIterator.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Id URL Added: svn:eol-style + native Modified: trunk/modules/extension/app-schema/app-schema/src/test/java/org/geotools/util/ComplexAttributeConverterFactoryTest.java =================================================================== --- trunk/modules/extension/app-schema/app-schema/src/test/java/org/geotools/util/ComplexAttributeConverterFactoryTest.java 2012-05-16 01:36:44 UTC (rev 38735) +++ trunk/modules/extension/app-schema/app-schema/src/test/java/org/geotools/util/ComplexAttributeConverterFactoryTest.java 2012-05-16 05:15:52 UTC (rev 38736) @@ -1,124 +1,124 @@ -/* - * GeoTools - The Open Source Java GIS Toolkit - * http://geotools.org - * - * (C) 2009-2011, Open Source Geospatial Foundation (OSGeo) - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - */ - -package org.geotools.util; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Set; - -import junit.framework.TestCase; - -import org.geotools.data.complex.ComplexFeatureConstants; -import org.geotools.feature.AttributeImpl; -import org.geotools.feature.ComplexAttributeImpl; -import org.geotools.feature.GeometryAttributeImpl; -import org.geotools.feature.NameImpl; -import org.geotools.feature.type.AttributeDescriptorImpl; -import org.geotools.feature.type.GeometryDescriptorImpl; -import org.geotools.feature.type.GeometryTypeImpl; -import org.geotools.gml3.GMLSchema; -import org.geotools.xs.XSSchema; -import org.opengis.feature.Attribute; -import org.opengis.feature.ComplexAttribute; -import org.opengis.feature.GeometryAttribute; -import org.opengis.feature.Property; -import org.opengis.feature.type.AttributeDescriptor; -import org.opengis.filter.identity.FeatureId; -import com.vividsolutions.jts.geom.EmptyGeometry; -import com.vividsolutions.jts.geom.Geometry; - -/** - * Tests for {@link ComplexAttributeConverterFactory}. - * - * @author Rini Angreani (CSIRO Earth Science and Resource Engineering) - * @author Niels Charlier - * - * - * - * - * @source $URL: http://svn.osgeo.org/geotools/trunk/modules/extension/app-schema/app-schema/src/test/java/org/geotools/util/ComplexAttributeConverterFactoryTest.java $ - */ -public class ComplexAttributeConverterFactoryTest extends TestCase { - - /** - * Test extracting complex attribute leaf value should be successful. - */ - public void testLeafComplexAttribute() { - Collection<Property> attributes = new ArrayList<Property>(); - AttributeDescriptor descriptor = new AttributeDescriptorImpl(XSSchema.STRING_TYPE, - ComplexFeatureConstants.SIMPLE_CONTENT, 1, 1, true, (Object) null); - attributes.add(new AttributeImpl("rini", descriptor, null)); - ComplexAttribute gmlName = new ComplexAttributeImpl(attributes, GMLSchema.CODETYPE_TYPE, null); - String nameString = Converters.convert(gmlName, String.class); - assertEquals("rini", nameString); - } - - /** - * Test extracting complex attribute non-leaf value should fail. - */ - public void testParentComplexAttribute() { - Collection<Property> attributes = new ArrayList<Property>(); - AttributeDescriptor descriptor = new AttributeDescriptorImpl(XSSchema.STRING_TYPE, - ComplexFeatureConstants.SIMPLE_CONTENT, 1, 1, true, (Object) null); - attributes.add(new AttributeImpl("rini", descriptor, null)); - ComplexAttribute gmlName = new ComplexAttributeImpl(attributes, GMLSchema.CODETYPE_TYPE, null); - - Collection<Property> parentAttributes = new ArrayList<Property>(); - parentAttributes.add(gmlName); - ComplexAttribute parentAtt = new ComplexAttributeImpl(parentAttributes, GMLSchema.ABSTRACTFEATURETYPE_TYPE, null); - String nameString = Converters.convert(parentAtt, String.class); - - assertEquals(parentAtt.toString(), nameString); - assertNotSame("rini", nameString); - } - - /** - * Test that normal Attribute shouldn't be affected by the converter. - */ - public void testAttribute() { - AttributeDescriptor descriptor = new AttributeDescriptorImpl(XSSchema.STRING_TYPE, - ComplexFeatureConstants.SIMPLE_CONTENT, 1, 1, true, (Object) null); - Attribute att = new AttributeImpl("rini", descriptor, null); - Set<ConverterFactory> factories = Converters.getConverterFactories(att.getClass(), String.class); - for (ConverterFactory factory : factories) { - assertFalse(factory instanceof ComplexAttributeConverterFactory); - } - } - - /** - * Test converting String to FeatureId successful. This is required by feature chaining. - * @throws Exception - */ - public void testFeatureId() throws Exception { - FeatureId id = Converters.convert("blah", FeatureId.class); - assertNotNull(id); - assertEquals(id.getID(), "blah"); - } - - /** - * Test extracting geometry from geometryattribute should be successful. - */ - public void testGeometry() { - Geometry geometry = new EmptyGeometry(); - GeometryAttribute geoatt = new GeometryAttributeImpl(geometry, new GeometryDescriptorImpl(new GeometryTypeImpl(new NameImpl(""), EmptyGeometry.class, null, false, false, null, null, null), new NameImpl(""), 0, 0, false, null), null); - Geometry geometry2 = Converters.convert(geoatt, Geometry.class); - assertTrue(geometry == geometry2); - } - - -} +/* + * GeoTools - The Open Source Java GIS Toolkit + * http://geotools.org + * + * (C) 2009-2011, Open Source Geospatial Foundation (OSGeo) + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + */ + +package org.geotools.util; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Set; + +import junit.framework.TestCase; + +import org.geotools.data.complex.ComplexFeatureConstants; +import org.geotools.feature.AttributeImpl; +import org.geotools.feature.ComplexAttributeImpl; +import org.geotools.feature.GeometryAttributeImpl; +import org.geotools.feature.NameImpl; +import org.geotools.feature.type.AttributeDescriptorImpl; +import org.geotools.feature.type.GeometryDescriptorImpl; +import org.geotools.feature.type.GeometryTypeImpl; +import org.geotools.gml3.GMLSchema; +import org.geotools.xs.XSSchema; +import org.opengis.feature.Attribute; +import org.opengis.feature.ComplexAttribute; +import org.opengis.feature.GeometryAttribute; +import org.opengis.feature.Property; +import org.opengis.feature.type.AttributeDescriptor; +import org.opengis.filter.identity.FeatureId; +import com.vividsolutions.jts.geom.EmptyGeometry; +import com.vividsolutions.jts.geom.Geometry; + +/** + * Tests for {@link ComplexAttributeConverterFactory}. + * + * @author Rini Angreani (CSIRO Earth Science and Resource Engineering) + * @author Niels Charlier + * + * + * + * + * @source $URL$ + */ +public class ComplexAttributeConverterFactoryTest extends TestCase { + + /** + * Test extracting complex attribute leaf value should be successful. + */ + public void testLeafComplexAttribute() { + Collection<Property> attributes = new ArrayList<Property>(); + AttributeDescriptor descriptor = new AttributeDescriptorImpl(XSSchema.STRING_TYPE, + ComplexFeatureConstants.SIMPLE_CONTENT, 1, 1, true, (Object) null); + attributes.add(new AttributeImpl("rini", descriptor, null)); + ComplexAttribute gmlName = new ComplexAttributeImpl(attributes, GMLSchema.CODETYPE_TYPE, null); + String nameString = Converters.convert(gmlName, String.class); + assertEquals("rini", nameString); + } + + /** + * Test extracting complex attribute non-leaf value should fail. + */ + public void testParentComplexAttribute() { + Collection<Property> attributes = new ArrayList<Property>(); + AttributeDescriptor descriptor = new AttributeDescriptorImpl(XSSchema.STRING_TYPE, + ComplexFeatureConstants.SIMPLE_CONTENT, 1, 1, true, (Object) null); + attributes.add(new AttributeImpl("rini", descriptor, null)); + ComplexAttribute gmlName = new ComplexAttributeImpl(attributes, GMLSchema.CODETYPE_TYPE, null); + + Collection<Property> parentAttributes = new ArrayList<Property>(); + parentAttributes.add(gmlName); + ComplexAttribute parentAtt = new ComplexAttributeImpl(parentAttributes, GMLSchema.ABSTRACTFEATURETYPE_TYPE, null); + String nameString = Converters.convert(parentAtt, String.class); + + assertEquals(parentAtt.toString(), nameString); + assertNotSame("rini", nameString); + } + + /** + * Test that normal Attribute shouldn't be affected by the converter. + */ + public void testAttribute() { + AttributeDescriptor descriptor = new AttributeDescriptorImpl(XSSchema.STRING_TYPE, + ComplexFeatureConstants.SIMPLE_CONTENT, 1, 1, true, (Object) null); + Attribute att = new AttributeImpl("rini", descriptor, null); + Set<ConverterFactory> factories = Converters.getConverterFactories(att.getClass(), String.class); + for (ConverterFactory factory : factories) { + assertFalse(factory instanceof ComplexAttributeConverterFactory); + } + } + + /** + * Test converting String to FeatureId successful. This is required by feature chaining. + * @throws Exception + */ + public void testFeatureId() throws Exception { + FeatureId id = Converters.convert("blah", FeatureId.class); + assertNotNull(id); + assertEquals(id.getID(), "blah"); + } + + /** + * Test extracting geometry from geometryattribute should be successful. + */ + public void testGeometry() { + Geometry geometry = new EmptyGeometry(); + GeometryAttribute geoatt = new GeometryAttributeImpl(geometry, new GeometryDescriptorImpl(new GeometryTypeImpl(new NameImpl(""), EmptyGeometry.class, null, false, false, null, null, null), new NameImpl(""), 0, 0, false, null), null); + Geometry geometry2 = Converters.convert(geoatt, Geometry.class); + assertTrue(geometry == geometry2); + } + + +} Property changes on: trunk/modules/extension/app-schema/app-schema/src/test/java/org/geotools/util/ComplexAttributeConverterFactoryTest.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Id URL Added: svn:eol-style + native Property changes on: trunk/modules/unsupported/app-schema/webservice/pom.xml ___________________________________________________________________ Modified: svn:keywords - Id + Id URL Property changes on: trunk/modules/unsupported/app-schema/webservice/src/main/java/org/geotools/filter/AsXpathFunctionExpression.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + native |