Package org.opengis.feature.type

Examples of org.opengis.feature.type.AttributeType


            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


        FeatureTypeFactory tfac = new UniqueNameFeatureTypeFactoryImpl();
        TypeBuilder builder = new TypeBuilder(tfac);

        FeatureType wq_plusType;

        AttributeType detdesc = builder.name("determinand_description").bind(String.class)
                .attribute();
        AttributeType result = builder.name("result").bind(Float.class).attribute();

        builder.setName("measurement");
        builder.addAttribute("determinand_description", detdesc);
        builder.addAttribute("result", result);

        ComplexType MEASUREMENT = builder.complex();

        /*
         * <li>sitename <li>anzlic_no <li>project_no <li>location <li>measurement
         * (0..*) <ul> <li>determinand_description</li> <li>result</li>
         * </ul>
         */

        AttributeType sitename = builder.name("sitename").bind(String.class).attribute();
        AttributeType anzlic_no = builder.name("anzlic_no").bind(String.class).attribute();
        AttributeType project_no = builder.name("project_no").bind(String.class).attribute();
        AttributeType location = builder.name("location").bind(Point.class).geometry();

        builder.setName("wq_plus");
        builder.addAttribute("sitename", sitename);
        builder.addAttribute("anzlic_no", anzlic_no);
        builder.addAttribute("project_no", project_no);
View Full Code Here

    private FeatureTypeMapping createSampleDerivedAttributeMappings() throws Exception {
        // create the target type
        FeatureTypeFactory tf = new UniqueNameFeatureTypeFactoryImpl();
        TypeBuilder builder = new TypeBuilder(tf);

        AttributeType areaOfInfluence = builder.name("areaOfInfluence").bind(Polygon.class)
                .attribute();
        AttributeType concatType = builder.name("concatenated").bind(String.class).attribute();

        builder.setName("target");
        builder.addAttribute("areaOfInfluence", areaOfInfluence);
        builder.addAttribute("concatenated", concatType);
View Full Code Here

        FeatureTypeFactory tfac = new UniqueNameFeatureTypeFactoryImpl();
        TypeBuilder builder = new TypeBuilder(tfac);

        FeatureType sampleType;

        AttributeType parameter = builder.name("parameter").bind(String.class).attribute();
        AttributeType value = builder.name("value").bind(Double.class).attribute();

        builder.setName("measurement");
        builder.addAttribute("parameter", parameter);
        builder.addAttribute("value", value);
        ComplexType MEASUREMENT = builder.complex();
View Full Code Here

            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

                            + name);
                }
                this.mappings.put(name, mapping);
                // if the type is not a feature, it should be wrapped with
                // a fake feature type, so attributes can be chained/nested
                AttributeType type = mapping.getTargetFeature().getType();
                if (!(type instanceof FeatureType)) {
                    // nasty side-effect: constructor edits mapping to use this type proxy
                    new NonFeatureTypeProxy(type, mapping);
                }
            }
View Full Code Here

            List<AttributeMapping> attMappings = mapping.getAttributeMappings();
            // NC - add feature to list, to include its ID expression
            requestedProperties.add(filterFac.property(mapping.getTargetFeature().getName()));

            // get source type
            AttributeType mappedType;
            try {
                mappedType = mapping.getSource().getSchema();
            } catch (UnsupportedOperationException e) {
                // web service backend doesn't support getSchema()
                mappedType = null;
View Full Code Here

            AttributeDescriptor currStepDescriptor = null;
            final boolean isLastStep = !stepsIterator.hasNext();
            final QName stepName = currStep.getName();
            final Name attributeName = Types.toName(stepName);

            final AttributeType _parentType = parent.getType();
            if (_parentType.getName().equals(XSSchema.ANYTYPE_TYPE.getName()) && targetDescriptor != null) {
                // this needs to be passed on if casting anyType to something else, since it won't
                // exist in the schema
                currStepDescriptor = targetDescriptor;
            } else {
                ComplexType parentType = (ComplexType) _parentType;

                if (!isLastStep || targetNodeType == null) {
                    if (null == attributeName.getNamespaceURI()) {
                        currStepDescriptor = (AttributeDescriptor) Types.findDescriptor(parentType, attributeName.getLocalPart());
                    } else {
                        currStepDescriptor = (AttributeDescriptor) Types.findDescriptor(parentType, attributeName);
                    }

                    if (currStepDescriptor == null) {
                        // need to take the non easy way, may be the instance has a
                        // value for this step with a different name, of a derived
                        // type of the one declared in the parent type
                        String prefixedStepName = currStep.toString();
                        PropertyName name = FF.property(prefixedStepName);
                        Attribute child = (Attribute) name.evaluate(parent);
                        if (child != null) {
                            currStepDescriptor = child.getDescriptor();
                        }
                    }
                } else {
                    AttributeDescriptor actualDescriptor;
                    if (null == attributeName.getNamespaceURI()) {
                        actualDescriptor = (AttributeDescriptor) Types.findDescriptor(parentType, attributeName.getLocalPart());
                    } else {
                        actualDescriptor = (AttributeDescriptor) Types.findDescriptor(parentType, attributeName);
                    }

                    if (actualDescriptor != null) {
                        int minOccurs = actualDescriptor.getMinOccurs();
                        int maxOccurs = actualDescriptor.getMaxOccurs();
                        boolean nillable = actualDescriptor.isNillable();
                        if (actualDescriptor instanceof GeometryDescriptor) {
                            // important to maintain CRS information encoding
                            if (Geometry.class.isAssignableFrom(targetNodeType.getBinding())) {
                                if (!(targetNodeType instanceof GeometryType)) {
                                    targetNodeType = new GeometryTypeImpl(targetNodeType.getName(),
                                            targetNodeType.getBinding(), crs != null ? crs
                                                    : ((GeometryDescriptor) actualDescriptor)
                                                            .getCoordinateReferenceSystem(),
                                            targetNodeType.isIdentified(), targetNodeType
                                                    .isAbstract(),
                                            targetNodeType.getRestrictions(), targetNodeType
                                                    .getSuper(), targetNodeType.getDescription());
                                }
                                currStepDescriptor = descriptorFactory.createGeometryDescriptor(
                                        (GeometryType) targetNodeType, attributeName, minOccurs,
                                        maxOccurs, nillable, null);
                            } else {
                                throw new IllegalArgumentException("Can't set targetNodeType: "
                                        + targetNodeType.toString() + " for attribute mapping: "
                                        + attributeName + " as it is not a Geometry type!");
                            }
                        } else {
                            currStepDescriptor = descriptorFactory.createAttributeDescriptor(
                                    targetNodeType, attributeName, minOccurs, maxOccurs, nillable,
                                    null);
                        }
                    }
                }

                if (currStepDescriptor == null) {
                    StringBuffer parentAtts = new StringBuffer();
                    Collection properties = parentType.getDescriptors();
                    for (Iterator it = properties.iterator(); it.hasNext();) {
                        PropertyDescriptor desc = (PropertyDescriptor) it.next();
                        Name name = desc.getName();
                        parentAtts.append(name.getNamespaceURI());
                        parentAtts.append("#");
                        parentAtts.append(name.getLocalPart());
                        if (it.hasNext()) {
                            parentAtts.append(", ");
                        }
                    }
                    throw new IllegalArgumentException(currStep
                            + " is not a valid location path for type " + parentType.getName()
                            + ". " + currStep + " ns: " + currStep.getName().getNamespaceURI()
                            + ", " + parentType.getName().getLocalPart() + " properties: "
                            + parentAtts);
                }
            }

            if (isLastStep) {
                // reached the leaf
                if (currStepDescriptor == null) {
                    throw new IllegalArgumentException(currStep
                            + " is not a valid location path for type " + _parentType.getName());
                }

                return setLeafAttribute(currStepDescriptor, currStep, id, value, parent,
                        targetNodeType, isXlinkRef);
            } else {
View Full Code Here

     * @param value
     * @return
     */
    @SuppressWarnings("serial")
    private Object convertValue(final AttributeDescriptor descriptor, final Object value) {
        final AttributeType type = descriptor.getType();
        Class<?> binding = type.getBinding();

        if (type instanceof ComplexType && binding == Collection.class) {
            if (!(value instanceof Collection)) {
                if (Types.isSimpleContentType(type)) {
                    ArrayList<Property> list = new ArrayList<Property>();
View Full Code Here

     * @param type
     * @param value
     * @return
     */
    Attribute buildSimpleContent(AttributeType type, Object value) {
        AttributeType simpleContentType = getSimpleContentType(type);
        Object convertedValue = FF.literal(value).evaluate(value,
                getSimpleContentType(type).getBinding());
        AttributeDescriptor descriptor = new AttributeDescriptorImpl(simpleContentType,
                ComplexFeatureConstants.SIMPLE_CONTENT, 1, 1, true, (Object) null);
        return new AttributeImpl(convertedValue, descriptor, null);
View Full Code Here

TOP

Related Classes of org.opengis.feature.type.AttributeType

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.