Package org.geotools.data.complex.config

Examples of org.geotools.data.complex.config.AppSchemaFeatureTypeRegistry


        } catch (Exception e) {
            e.printStackTrace();
            throw e;
        }

        AppSchemaFeatureTypeRegistry typeRegistry = new AppSchemaFeatureTypeRegistry();
        try {
            typeRegistry.addSchemas(schemaIndex);
   
            Name typeName = Types.typeName(GSMLNS, "MappedFeatureType");
            ComplexType mf = (ComplexType) typeRegistry.getAttributeType(typeName);
            assertNotNull(mf);
            assertTrue(mf instanceof FeatureType);
   
            typeName = Types.typeName("http://www.opengis.net/sampling/1.0", "SamplingFeatureType");
            mf = (ComplexType) typeRegistry.getAttributeType(typeName);
            assertNotNull(mf);
            assertTrue(mf instanceof FeatureType);
        }
        finally {
            typeRegistry.disposeSchemaIndexes();
        }
        /*
         * AttributeType superType = mf.getSuper(); assertNotNull(superType); Name superTypeName =
         * Types.typeName(SANS, "ProfileType"); assertEquals(superTypeName, superType.getName());
         * assertTrue(superType instanceof FeatureType); // ensure all needed types were parsed and
View Full Code Here


        } catch (Exception e) {
            e.printStackTrace();
            throw e;
        }

        final AppSchemaFeatureTypeRegistry typeRegistry = new AppSchemaFeatureTypeRegistry();
        try {
            typeRegistry.addSchemas(schemaIndex);
   
            final Name typeName = Types.typeName(AWNS, "SiteSinglePhenomTimeSeriesType");
            final ComplexType testType = (ComplexType) typeRegistry.getAttributeType(typeName);
   
            assertNotNull(testType);
            assertTrue(testType instanceof FeatureType);
   
            AttributeType superType = testType.getSuper();
            assertNotNull(superType);
   
            Name superTypeName = Types.typeName(AWNS, "SamplingSitePurposeType");
            assertEquals(superTypeName, superType.getName());
            // assertTrue(superType instanceof FeatureType);
   
            // ensure all needed types were parsed and aren't just empty proxies
            Map samplingProperties = new HashMap();
   
            // from gml:AbstractFeatureType
            samplingProperties.put(name(GMLNS, "metaDataProperty"), typeName(GMLNS,
                    "MetaDataPropertyType"));
            samplingProperties.put(name(GMLNS, "description"), typeName(GMLNS, "StringOrRefType"));
            samplingProperties.put(name(GMLNS, "name"), typeName(GMLNS, "CodeType"));
            samplingProperties.put(name(GMLNS, "boundedBy"), typeName(GMLNS, "BoundingShapeType"));
            samplingProperties.put(name(GMLNS, "location"), typeName(GMLNS, "LocationPropertyType"));
   
            // aw:SamplingSiteType
            samplingProperties.put(name(AWNS, "samplingRegimeType"), Types.toTypeName(GML.CodeType));
            samplingProperties.put(name(AWNS, "waterBodyType"), Types.toTypeName(GML.CodeType));
            samplingProperties.put(name(AWNS, "accessTypeCode"), Types.toTypeName(GML.CodeType));
   
            // sa:SamplingPointType
            samplingProperties.put(name(SANS, "position"), typeName(GMLNS, "PointPropertyType"));
   
            // sa:SamplingFeatureType
            samplingProperties.put(name(SANS, "relatedObservation"), typeName(OMNS,
                    "ObservationPropertyType"));
            samplingProperties.put(name(SANS, "relatedSamplingFeature"), typeName(SANS,
                    "SamplingFeatureRelationPropertyType"));
            samplingProperties
                    .put(name(SANS, "sampledFeature"), typeName(GMLNS, "FeaturePropertyType"));
            samplingProperties.put(name(SANS, "surveyDetails"), typeName(SANS,
                    "SurveyProcedurePropertyType"));
   
            // sa:SiteSinglePhenomTimeSeriesType
            samplingProperties.put(name(AWNS, "relatedObservation"), typeName(AWNS,
                    "PhenomenonTimeSeriesPropertyType"));
   
            assertPropertyNamesAndTypeNames(testType, samplingProperties);
   
            AttributeDescriptor relatedObservation = (AttributeDescriptor) Types.descriptor(testType,
                    name(AWNS, "relatedObservation"));
            Map relatedObsProps = new HashMap();
            relatedObsProps.put(name(AWNS, "PhenomenonTimeSeries"), typeName(AWNS,
                    "PhenomenonTimeSeriesType"));
            ComplexType phenomenonTimeSeriesPropertyType = (ComplexType) relatedObservation.getType();
   
            assertPropertyNamesAndTypeNames(phenomenonTimeSeriesPropertyType, relatedObsProps);
   
            AttributeDescriptor phenomenonTimeSeries = (AttributeDescriptor) Types.descriptor(
                    phenomenonTimeSeriesPropertyType, name(AWNS, "PhenomenonTimeSeries"));
            ComplexType phenomenonTimeSeriesType = (ComplexType) phenomenonTimeSeries.getType();
            Map phenomenonTimeSeriesProps = new HashMap();
            // from
            // aw:WaterObservationType/om:TimeSeriesObsType/om:AbstractObservationType
            // phenomenonTimeSeriesProps.put(name(OMNS, "procedure"), typeName(OMNS,
            // "ObservationProcedurePropertyType"));
            // phenomenonTimeSeriesProps.put(name(OMNS, "countParameter"),
            // typeName(SWENS,
            // "TypedCountType"));
            // phenomenonTimeSeriesProps.put(name(OMNS, "measureParameter"),
            // typeName(SWENS,
            // "TypedMeasureType"));
            // phenomenonTimeSeriesProps.put(name(OMNS, "termParameter"),
            // typeName(SWENS,
            // "TypedCategoryType"));
            // phenomenonTimeSeriesProps.put(name(OMNS, "observedProperty"),
            // typeName(SWENS,
            // "PhenomenonPropertyType"));
            //
            // from PhenomenonTimeSeriesType
            phenomenonTimeSeriesProps.put(name(AWNS, "result"), typeName(CVNS,
                    "CompactDiscreteTimeCoveragePropertyType"));
   
            assertPropertyNamesAndTypeNames(phenomenonTimeSeriesType, phenomenonTimeSeriesProps);
   
            AttributeDescriptor observedProperty = (AttributeDescriptor) Types.descriptor(
                    phenomenonTimeSeriesType, name(OMNS, "observedProperty"));
   
            ComplexType phenomenonPropertyType = (ComplexType) observedProperty.getType();
   
            assertPropertyNamesAndTypeNames(phenomenonPropertyType, Collections.singletonMap(name(
                    SWENS, "Phenomenon"), typeName(SWENS, "PhenomenonType")));
   
            AttributeDescriptor phenomenon = (AttributeDescriptor) Types.descriptor(
                    phenomenonPropertyType, name(SWENS, "Phenomenon"));
            ComplexType phenomenonType = (ComplexType) phenomenon.getType();
            assertNotNull(phenomenonType.getSuper());
            assertEquals(typeName(GMLNS, "DefinitionType"), phenomenonType.getSuper().getName());
   
            Map phenomenonProps = new HashMap();
            // from gml:DefinitionType
            phenomenonProps.put(name(GMLNS, "metaDataProperty"), null);
            phenomenonProps.put(name(GMLNS, "description"), null);
            phenomenonProps.put(name(GMLNS, "name"), null);
   
            assertPropertyNamesAndTypeNames(phenomenonType, phenomenonProps);
        }
        finally {
            typeRegistry.disposeSchemaIndexes();
        }
    }
View Full Code Here

     */
    @Test
    public void testPolymorphism() throws Exception {
        SchemaIndex schemaIndex = loadSchema("http://schemas.opengis.net/GeoSciML/Gsml.xsd");

        AppSchemaFeatureTypeRegistry typeRegistry = new AppSchemaFeatureTypeRegistry();
       
        try {
            typeRegistry.addSchemas(schemaIndex);
   
            Name typeName = Types.typeName(GSMLNS, "MappedFeatureType");      
            ComplexType mf = (ComplexType) typeRegistry.getAttributeType(typeName);
            assertNotNull(mf);
            assertTrue(mf instanceof FeatureType);
           
            AttributeExpressionImpl ex = new AttributeExpressionImpl("gsml:specification/gsml:GeologicUnit/gsml:preferredAge/gsml:GeologicEvent/gsml:eventAge/gsml:CGI_TermRange/gsml:upper/gsml:CGI_TermValue/gsml:value",
                    new Hints(FeaturePropertyAccessorFactory.NAMESPACE_CONTEXT, GSMLNAMESPACES));
                   
            Object o = ex.evaluate(mf);
            assertNotNull(o);
            assertTrue(o instanceof PropertyDescriptor);
           
            ex = new AttributeExpressionImpl("gsml:specification/gsml:GeologicUnit/gsml:composition/gsml:CompositionPart/gsml:lithology/@xlink:href",
                    new Hints(FeaturePropertyAccessorFactory.NAMESPACE_CONTEXT, GSMLNAMESPACES));
                   
            o = ex.evaluate(mf);
            assertNotNull(o);
            assertTrue(o.equals (Types.typeName(XLINKNS, "href")));
           
            ex = new AttributeExpressionImpl("gsml:specification/gsml:GeologicUnit/gsml:composition/gsml:CompositionPart/gsml:lithology/@foo:bar",
                    new Hints(FeaturePropertyAccessorFactory.NAMESPACE_CONTEXT, GSMLNAMESPACES));
                   
            o = ex.evaluate(mf);
            assertNull(o);
        }
        finally {       
            typeRegistry.disposeSchemaIndexes();
        }
       
    }
View Full Code Here

     */
    @Test
    public void testParseSchema() throws Exception {
        SchemaIndex schemaIndex = loadSchema("http://schemas.opengis.net/GeoSciML/Gsml.xsd");

        AppSchemaFeatureTypeRegistry typeRegistry = new AppSchemaFeatureTypeRegistry();
        try {
            typeRegistry.addSchemas(schemaIndex);
   
            Name typeName = Types.typeName(GSMLNS, "GeologicUnitType");
            ComplexType mf = (ComplexType) typeRegistry.getAttributeType(typeName);
            assertNotNull(mf);
            assertTrue(mf instanceof FeatureType);
   
            AttributeType superType = mf.getSuper();
            assertNotNull(superType);
            Name superTypeName = Types.typeName(GSMLNS, "GeologicFeatureType");
            assertEquals(superTypeName, superType.getName());
            assertTrue(superType instanceof FeatureType);
        }
        finally {
            typeRegistry.disposeSchemaIndexes();
        }
    }
View Full Code Here

        } catch (Exception e) {
            e.printStackTrace();
            throw e;
        }

        AppSchemaFeatureTypeRegistry typeRegistry = new AppSchemaFeatureTypeRegistry();
        try {
            typeRegistry.addSchemas(schemaIndex);
   
            Name typeName = Types.typeName(XMMLNS, "BoreholeType");
            ComplexFeatureTypeImpl borehole = (ComplexFeatureTypeImpl) typeRegistry.getAttributeType(typeName);
            assertNotNull(borehole);
            assertTrue(borehole instanceof FeatureType);
   
            AttributeType superType = borehole.getSuper();
            assertNotNull(superType);
            Name superTypeName = Types.typeName(SANS, "ProfileType");
            assertEquals(superTypeName, superType.getName());
            assertTrue(superType instanceof FeatureType);
   
            // ensure all needed types were parsed and aren't just empty proxies
            Collection properties = borehole.getTypeDescriptors();
            assertEquals(16, properties.size());
            Map expectedNamesAndTypes = new HashMap();
            // from gml:AbstractFeatureType
            expectedNamesAndTypes.put(name(GMLNS, "metaDataProperty"), typeName(GMLNS,
                    "MetaDataPropertyType"));
            expectedNamesAndTypes.put(name(GMLNS, "description"), typeName(GMLNS, "StringOrRefType"));
            expectedNamesAndTypes.put(name(GMLNS, "name"), typeName(GMLNS, "CodeType"));
            expectedNamesAndTypes.put(name(GMLNS, "boundedBy"), typeName(GMLNS, "BoundingShapeType"));
            expectedNamesAndTypes.put(name(GMLNS, "location"), typeName(GMLNS, "LocationPropertyType"));
            // from sa:ProfileType
            expectedNamesAndTypes.put(name(SANS, "begin"), typeName(GMLNS, "PointPropertyType"));
            expectedNamesAndTypes.put(name(SANS, "end"), typeName(GMLNS, "PointPropertyType"));
            expectedNamesAndTypes.put(name(SANS, "length"), typeName(SWENS, "RelativeMeasureType"));
            expectedNamesAndTypes.put(name(SANS, "shape"), typeName(GEONS, "Shape1DPropertyType"));
            // sa:SamplingFeatureType
            expectedNamesAndTypes.put(name(SANS, "member"), typeName(SANS,
                    "SamplingFeaturePropertyType"));
            expectedNamesAndTypes.put(name(SANS, "surveyDetails"), typeName(SANS,
                    "SurveyProcedurePropertyType"));
            expectedNamesAndTypes.put(name(SANS, "associatedSpecimen"), typeName(SANS,
                    "SpecimenPropertyType"));
            expectedNamesAndTypes.put(name(SANS, "relatedObservation"), typeName(OMNS,
                    "AbstractObservationPropertyType"));
            // from xmml:BoreholeType
            expectedNamesAndTypes.put(name(XMMLNS, "drillMethod"), typeName(XMMLNS, "drillCode"));
            expectedNamesAndTypes.put(name(XMMLNS, "collarDiameter"), typeName(GMLNS, "MeasureType"));
            expectedNamesAndTypes.put(name(XMMLNS, "log"), typeName(XMMLNS, "LogPropertyType"));
   
            for (Iterator it = expectedNamesAndTypes.entrySet().iterator(); it.hasNext();) {
                Map.Entry entry = (Entry) it.next();
                Name dName = (Name) entry.getKey();
                Name tName = (Name) entry.getValue();
   
                AttributeDescriptor d = (AttributeDescriptor) Types.descriptor(borehole, dName);
                assertNotNull("Descriptor not found: " + dName, d);
                AttributeType type;
                try {
                    type = (AttributeType) d.getType();
                } catch (Exception e) {
                    LOGGER.log(Level.SEVERE, "type not parsed for "
                            + ((AttributeDescriptor) d).getName(), e);
                    throw e;
                }
                assertNotNull(type);
                assertNotNull(type.getName());
                assertNotNull(type.getBinding());
                if (tName != null) {
                    assertEquals(tName, type.getName());
                }
            }
   
            Name tcl = Types.typeName(SWENS, "TypedCategoryListType");
            AttributeType typedCategoryListType = (AttributeType) typeRegistry.getAttributeType(tcl);
            assertNotNull(typedCategoryListType);
            assertTrue(typedCategoryListType instanceof ComplexType);
        }
        finally {
            typeRegistry.disposeSchemaIndexes();
        }
    }
View Full Code Here

TOP

Related Classes of org.geotools.data.complex.config.AppSchemaFeatureTypeRegistry

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.