Package net.opengis.wfs

Examples of net.opengis.wfs.UpdateElementType


        }

        FilterFactory ff = CommonFactoryFinder.getFilterFactory( null );
       
        // check that all required properties have a specified value
        UpdateElementType update = (UpdateElementType) element;

        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 "
                + update.getTypeName(), e, update.getHandle());
        }
    }
View Full Code Here


    }

    public void execute(EObject element, TransactionType request, Map featureStores,
        TransactionResponseType response, TransactionListener listener)
        throws WFSTransactionException {
        UpdateElementType update = (UpdateElementType) element;
        final QName elementName = update.getTypeName();
        String handle = update.getHandle();
        long updated = response.getTransactionSummary().getTotalUpdated().longValue();

        FeatureStore<SimpleFeatureType, SimpleFeature> store;
        store = (FeatureStore<SimpleFeatureType, SimpleFeature>) featureStores.get(elementName);

        if (store == null) {
            throw new WFSException("Could not locate FeatureStore for '" + elementName + "'");
        }

        LOGGER.finer("Transaction Update:" + element);

        try {
            Filter filter = (Filter) update.getFilter();
           
           
            // make sure all geometric elements in the filter have a crs, and that the filter
            // is reprojected to store's native crs as well
            CoordinateReferenceSystem declaredCRS = WFSReprojectionUtil.getDeclaredCrs(
                    store.getSchema(), request.getVersion());
            filter = WFSReprojectionUtil.normalizeFilterCRS(filter, store.getSchema(), declaredCRS);


            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
View Full Code Here

     *
     * @generated modifiable
     */
    public Object parse(ElementInstance instance, Node node, Object value)
        throws Exception {
        UpdateElementType updateElement = wfsfactory.createUpdateElementType();

        //&lt;xsd:element maxOccurs="unbounded" ref="wfs:Property"/&gt;
        updateElement.getProperty().addAll(node.getChildValues(PropertyType.class));

        //&lt;xsd:element maxOccurs="1" minOccurs="0" ref="ogc:Filter"&gt;
        updateElement.setFilter((Filter) node.getChildValue(Filter.class));

        //&lt;xsd:attribute name="handle" type="xsd:string" use="optional"/&gt;
        if (node.hasAttribute("handle")) {
            updateElement.setHandle((String) node.getAttributeValue("handle"));
        }

        //&lt;xsd:attribute name="typeName" type="xsd:QName" use="required"/&gt;
        updateElement.setTypeName((QName) node.getAttributeValue("typeName"));

        return updateElement;
    }
View Full Code Here

                    qnames.add(det.getTypeName().getLocalPart());
                }

                it = tx.getUpdate().iterator();
                while (it.hasNext()){
                    UpdateElementType uet = (UpdateElementType)it.next();
                    qnames.add(uet.getTypeName().getLocalPart());
                }

                return qnames.contains(myLayer);// evt.getLayerName().toString());
            } catch (Exception e){
                e.printStackTrace();
View Full Code Here

     *
     * @generated modifiable
     */
    public Object parse(ElementInstance instance, Node node, Object value)
        throws Exception {
        UpdateElementType updateElement = wfsfactory.createUpdateElementType();

        //&lt;xsd:element maxOccurs="unbounded" ref="wfs:Property"&gt;
        updateElement.getProperty().addAll(node.getChildValues(PropertyType.class));

        //&lt;xsd:element maxOccurs="1" minOccurs="0" ref="ogc:Filter"&gt;
        updateElement.setFilter((Filter) node.getChildValue(Filter.class));

        //&lt;xsd:attribute name="handle" type="xsd:string" use="optional"&gt;
        if (node.hasAttribute("handle")) {
            updateElement.setHandle((String) node.getAttributeValue("handle"));
        }

        //&lt;xsd:attribute name="typeName" type="xsd:QName" use="required"&gt;
        updateElement.setTypeName((QName) node.getAttributeValue("typeName"));

        //&lt;xsd:attribute default="x-application/gml:3" name="inputFormat"
        //  type="xsd:string" use="optional"&gt;
        if (node.hasAttribute("inputFormat")) {
            updateElement.setInputFormat((String) node.getAttributeValue("inputFormat"));
        }

        //&lt;xsd:attribute name="srsName" type="xsd:anyURI" use="optional"&gt;
        if (node.hasAttribute("srsName")) {
            updateElement.setSrsName((URI) node.getAttributeValue("srsName"));
        }

        return updateElement;
    }
View Full Code Here

                break;

            case FeatureDiff.UPDATED:

                final UpdateElementType update = WfsFactory.eINSTANCE.createUpdateElementType();
                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));
                update.setFilter(filter);
                update.setTypeName(typeName);
                transaction.getUpdate().add(update);

                break;

            default:
View Full Code Here

    List updates = req.getUpdate();
    assertEquals(2, updates.size());
    assertTrue(updates.get(0) instanceof UpdateElementType);
    assertTrue(updates.get(1) instanceof UpdateElementType);
   
    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

            for (TransactionElement elem : transactionElements) {
                if (elem instanceof TransactionRequest.Insert) {
                    InsertElementType insert = createInsert(factory, (Insert) elem);
                    inserts.add(insert);
                } else if (elem instanceof TransactionRequest.Update) {
                    UpdateElementType update = createUpdate(factory, (Update) elem);
                    updates.add(update);
                } else if (elem instanceof TransactionRequest.Delete) {
                    DeleteElementType delete = createDelete(factory, (Delete) elem);
                    deletes.add(delete);
                }
View Full Code Here

        if (propertyNames.size() != newValues.size()) {
            throw new IllegalArgumentException("Got " + propertyNames.size()
                    + " property names and " + newValues.size() + " values");
        }

        UpdateElementType update = factory.createUpdateElementType();

        QName typeName = elem.getTypeName();
        update.setTypeName(typeName);
        String srsName = getFeatureTypeInfo(typeName).getDefaultSRS();
        update.setSrsName(new URI(srsName));

        Filter filter = elem.getFilter();
        update.setFilter(filter);

        @SuppressWarnings("unchecked")
        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();
View Full Code Here

    public void encodeUpdate() throws IOException, SAXException, TransformerException, XpathException{
        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());
View Full Code Here

TOP

Related Classes of net.opengis.wfs.UpdateElementType

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.