Package net.opengis.wfs

Examples of net.opengis.wfs.PropertyType


     *
     * @generated modifiable
     */
    public Object parse(ElementInstance instance, Node node, Object value)
        throws Exception {
        PropertyType property = wfsfactory.createPropertyType();

        //<xsd:element name="Name" type="xsd:string">
        String name = (String) node.getChildValue("Name");

        //turn into qname
        QName qName = (QName) new XSQNameBinding(namespaceContext).parse(null, name);
        property.setName(qName);

        //<xsd:element minOccurs="0" name="Value">
        if (node.hasChild("Value")) {
            Object object = node.getChildValue("Value");

            //check for a map
            if (object instanceof Map) {
                Map map = (Map) object;

                //this means a complex element parsed by xs:AnyType binding
                // try to pull out some text
                if (!map.isEmpty()) {
                    //first check for some text
                    if (map.containsKey(null)) {
                        property.setValue(map.get(null));
                    } else {
                        //perhaps some other value
                        property.setValue(map.values().iterator().next());
                    }
                }
            } else {
                property.setValue(object);
            }
        }

        return property;
    }
View Full Code Here


    public boolean canHandle(Object object) {
        return object instanceof PropertyType;
    }

    public List properties(Object object, XSDElementDeclaration element) {
        PropertyType property = (PropertyType) object;

        List properties = new ArrayList(2);

        //the Name particle we can use as is
        properties.add(new Object[] {
                Schemas.getChildElementParticle(element.getType(), "Name", false),
                property.getName()
            });

        //the Value particle we must retype

        //first guess its type
        QName newTypeName = guessValueType(property.getValue());
        XSDTypeDefinition type = (newTypeName != null) ? index.getTypeDefinition(newTypeName) : null;

        if (type != null) {
            //create a new particle based on the new type
            XSDElementDeclaration value = XSDFactory.eINSTANCE.createXSDElementDeclaration();
            value.setName("Value");
            value.setTypeDefinition(type);

            XSDParticle particle = XSDFactory.eINSTANCE.createXSDParticle();
            particle.setMinOccurs(1);
            particle.setMaxOccurs(1);
            particle.setContent(value);

            properties.add(new Object[] { particle, property.getValue() });
        } else {
            //coudl not determine new type, just fall back to xs:anyType
            Object[] p = new Object[] {
                    Schemas.getChildElementParticle(element.getType(), "Value", false),
                    property.getValue()
                };
            properties.add(p);
        }

        return properties;
View Full Code Here

     */
    public Object parse(ElementInstance instance, Node node, Object value)
        throws Exception {
        //TODO: much of this method is duplicated in the 1.1.0 binding, it
        // would be nice if we could sync them up somewhow....
        PropertyType property = wfsfactory.createPropertyType();

        //<xsd:element name="Name" type="xsd:QName">
        property.setName((QName) node.getChildValue(QName.class));

        //<xsd:element minOccurs="0" name="Value">
        if (node.hasChild("Value")) {
            Object object = node.getChildValue("Value");

            //check for a map
            if (object instanceof Map) {
                Map map = (Map) object;

                //this means a complex element parsed by xs:AnyType binding
                // try to pull out some text
                if (!map.isEmpty()) {
                    //first check for some text
                    if (map.containsKey(null)) {
                        property.setValue(map.get(null));
                    } else {
                        //perhaps some other value
                        property.setValue(map.values().iterator().next());
                    }
                }
            } else {
                property.setValue(object);
            }
        }

        return property;
    }
View Full Code Here

        try {
            FeatureTypeInfo meta = (FeatureTypeInfo) typeInfos.values().iterator().next();
            FeatureType featureType = meta.getFeatureType();

            for (Iterator prop = update.getProperty().iterator(); prop.hasNext();) {
                PropertyType property = (PropertyType) prop.next();

                //check that valus that are non-nillable exist
                if (property.getValue() == null) {
                    String propertyName = property.getName().getLocalPart();
                    AttributeDescriptor attributeType = null;
                    PropertyDescriptor pd = featureType.getDescriptor(propertyName);
                    if(pd instanceof AttributeDescriptor) {
                        attributeType = (AttributeDescriptor) pd;
                    }
                    if ((attributeType != null) && (attributeType.getMinOccurs() > 0)) {
                        String msg = "Property '" + attributeType.getLocalName()
                            + "' is mandatory but no value specified.";
                        throw new WFSException(msg, "MissingParameterValue");
                    }
                }
               
                //check that property names are actually valid
                QName name = property.getName();
                PropertyName propertyName = null;
               
                if ( name.getPrefix() != null && !"".equals( name.getPrefix() )) {
                    propertyName = ff.property( name.getPrefix() + ":" + name.getLocalPart() );
                }
                else {
                    propertyName = ff.property( name.getLocalPart() );
                }
               
                if ( propertyName.evaluate( featureType ) == null ) {
                    String msg = "No such property: " + property.getName();
                    throw new WFSException( msg );
                }
            }
        } catch (IOException e) {
            throw new WFSTransactionException("Could not locate feature type information for "
View Full Code Here

            AttributeDescriptor[] types = new AttributeDescriptor[update.getProperty().size()];
            Object[] values = new Object[update.getProperty().size()];

            for (int j = 0; j < update.getProperty().size(); j++) {
                PropertyType property = (PropertyType) update.getProperty().get(j);
                types[j] = store.getSchema().getDescriptor(property.getName().getLocalPart());
                values[j] = property.getValue();
               
                // if geometry, it may be necessary to reproject it to the native CRS before
                // update
                if (values[j] instanceof Geometry ) {
                    Geometry geometry = (Geometry) values[j];
View Full Code Here

                final EList properties = update.getProperty();

                SimpleFeature f = diff.getFeature();

                for (Iterator it = diff.getChangedAttributes().iterator(); it.hasNext();) {
                    final PropertyType property = WfsFactory.eINSTANCE.createPropertyType();
                    String name = (String) it.next();
                    property.setName(new QName(name));
                    property.setValue(f.getAttribute(name));
                    properties.add(property);
                }

                FeatureId featureId = filterFactory.featureId(diff.getID());
                final Filter filter = filterFactory.id(Collections.singleton(featureId));
View Full Code Here

    UpdateElementType update1 = (UpdateElementType)updates.get(0);
    List properties = update1.getProperty();
    assertTrue(update1.getFilter() instanceof Id);
    assertEquals(1, properties.size());
    assertTrue(properties.get(0) instanceof PropertyType);
    PropertyType property = (PropertyType) properties.get(0);
    assertEquals("prop1", property.getName().getLocalPart());
    assertEquals("val1", property.getValue());
  }
View Full Code Here

        List<PropertyType> properties = update.getProperty();

        for (int i = 0; i < propertyNames.size(); i++) {
            QName propName = propertyNames.get(i);
            Object value = newValues.get(i);
            PropertyType property = factory.createPropertyType();
            property.setName(propName);
            property.setValue(value);

            properties.add(property);
        }

        return update;
View Full Code Here

        WfsFactory wfsfac = WfsFactory.eINSTANCE;
        FilterFactory2 filterfac = CommonFactoryFinder.getFilterFactory2();
        GeometryFactory geomfac = new GeometryFactory(new PrecisionModel(10));
       
        UpdateElementType update = wfsfac.createUpdateElementType();
        PropertyType propertyType = wfsfac.createPropertyType();
        propertyType.setName(new QName("http://my.namespace","myproperty","mn"));
        update.getProperty().add(propertyType);
        update.setTypeName(new QName("http://my.namespace","mytypename","mn"));
        update.setFilter(filterfac.id( filterfac.featureId("someid")));
       
        //try with string
        propertyType.setValue("myvalue");
       
        Encoder encoder = new Encoder(new WFSConfiguration());
        //System.out.println(encoder.encodeAsString(update, WFS.Update));
        Document doc = encoder.encodeAsDOM(update, WFS.Update);
        XMLAssert.assertXpathEvaluatesTo("mn:mytypename", "//wfs:Update/@typeName", doc);
        XMLAssert.assertXpathEvaluatesTo("mn:myproperty", "//wfs:Update/wfs:Property/wfs:Name", doc);
        XMLAssert.assertXpathEvaluatesTo("myvalue", "//wfs:Update/wfs:Property/wfs:Value", doc);
        XMLAssert.assertXpathEvaluatesTo("someid", "//wfs:Update/ogc:Filter/ogc:FeatureId/@fid", doc);
       
        //try with numeric value
        propertyType.setValue(100.25);
       
        encoder = new Encoder(new WFSConfiguration());
        //System.out.println(encoder.encodeAsString(update, WFS.Update));
        doc = encoder.encodeAsDOM(update, WFS.Update);
        XMLAssert.assertXpathEvaluatesTo("100.25", "//wfs:Update/wfs:Property/wfs:Value", doc);
               
        //try with geometry
        Coordinate insideCoord = new Coordinate(5.2, 7.5);
        Point myPoint = geomfac.createPoint(insideCoord);
       
        propertyType.setValue(myPoint);
       
        encoder = new Encoder(new WFSConfiguration());
        //System.out.println(encoder.encodeAsString(update, WFS.Update));
        doc = encoder.encodeAsDOM(update, WFS.Update);
        XMLAssert.assertXpathEvaluatesTo("5.2", "//wfs:Update/wfs:Property/wfs:Value/gml:Point/gml:coord/gml:X", doc);
View Full Code Here

        WfsFactory wfsfac = WfsFactory.eINSTANCE;
        FilterFactory2 filterfac = CommonFactoryFinder.getFilterFactory2();
        GeometryFactory geomfac = new GeometryFactory(new PrecisionModel(10));
       
        UpdateElementType update = wfsfac.createUpdateElementType();
        PropertyType propertyType = wfsfac.createPropertyType();
        propertyType.setName(new QName("http://my.namespace","myproperty","mn"));
        update.getProperty().add(propertyType);
        update.setTypeName(new QName("http://my.namespace","mytypename","mn"));
        update.setFilter(filterfac.id( filterfac.featureId("someid")));
       
        //try with string
        propertyType.setValue("myvalue");
       
        Encoder encoder = new Encoder(new WFSConfiguration());
        //System.out.println(encoder.encodeAsString(update, WFS.Update));
        Document doc = encoder.encodeAsDOM(update, WFS.Update);
        XMLAssert.assertXpathEvaluatesTo("mn:mytypename", "//wfs:Update/@typeName", doc);
        XMLAssert.assertXpathEvaluatesTo("mn:myproperty", "//wfs:Update/wfs:Property/wfs:Name", doc);
        XMLAssert.assertXpathEvaluatesTo("myvalue", "//wfs:Update/wfs:Property/wfs:Value", doc);
        XMLAssert.assertXpathEvaluatesTo("someid", "//wfs:Update/ogc:Filter/ogc:FeatureId/@fid", doc);
       
        //try with numeric value
        propertyType.setValue(100.25);
       
        encoder = new Encoder(new WFSConfiguration());
        //System.out.println(encoder.encodeAsString(update, WFS.Update));
        doc = encoder.encodeAsDOM(update, WFS.Update);
        XMLAssert.assertXpathEvaluatesTo("100.25", "//wfs:Update/wfs:Property/wfs:Value", doc);
               
        //try with geometry
        Coordinate insideCoord = new Coordinate(5.2, 7.5);
        Point myPoint = geomfac.createPoint(insideCoord);
       
        propertyType.setValue(myPoint);
       
        encoder = new Encoder(new WFSConfiguration());
        //System.out.println(encoder.encodeAsString(update, WFS.Update));
        doc = encoder.encodeAsDOM(update, WFS.Update);
        XMLAssert.assertXpathEvaluatesTo("5.2", "//wfs:Update/wfs:Property/wfs:Value/gml:Point/gml:coord/gml:X", doc);
View Full Code Here

TOP

Related Classes of net.opengis.wfs.PropertyType

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.