Package org.vfny.geoserver.wfs.requests

Examples of org.vfny.geoserver.wfs.requests.TransactionRequest


     * @throws WfsException If no type is found, if filter length doesn't match
     *         feature length, or if no filter is found.  We don't want  users
     *         to accidentally delete their whole db.
     */
    public Request getRequest(HttpServletRequest request) throws WfsException {
        TransactionRequest parentRequest = new TransactionRequest();
        parentRequest.setHttpServletRequest(request);
        boolean releaseAll = true;

        // set global request parameters
        LOGGER.finest("setting global request parameters");

        if (keyExists("VERSION")) {
            parentRequest.setVersion(getValue("VERSION"));
        }

        if (keyExists("REQUEST")) {
            parentRequest.setRequest(getValue("REQUEST"));
        }

        //REVISIT: This is not in spec, but really should be.  Waiting to hear
        //about features like this, that were just accidentally left out.
        if (keyExists("LOCKID")) {
            parentRequest.setLockId(getValue("LOCKID"));
        }

        // declare tokenizers for repeating elements
        LOGGER.finest("setting query request parameters");

        List typeList = readFlat(getValue("TYPENAME"), INNER_DELIMETER);
        LOGGER.finest("type list size: " + typeList.size());

        List filterList = null;
        filterList = readFilters(getValue("FEATUREID"), getValue("FILTER"),
                getValue("BBOX"));

        if (typeList.size() == 0) {
            typeList = getTypesFromFids(getValue("FEATUREID"));

            if (typeList.size() == 0) {
                throw new WfsException("The typename element is mandatory if "
                    + "no FEATUREID is present");
            }
        }

        int featureSize = typeList.size();
        int filterSize = (filterList == null) ? 0 : filterList.size();

        // prepare the release action boolean for all delete transactions
        if (keyExists("RELEASEACTION")) {
            String lockAction = getValue("RELEASEACTION");
            parentRequest.setReleaseAction(lockAction);
        }

        // check for errors in the request
        if (((filterSize != featureSize) && (filterSize > 0))
                || ((filterSize > 0) && (featureSize == 0))) {
            throw new WfsException("Filter size does not match"
                + " feature types.  Filter size: " + filterSize
                + " Feature size: " + featureSize);
        } else if (filterSize == featureSize) {
            for (int i = 0, n = featureSize; i < n; i++) {
                DeleteRequest childRequest = new DeleteRequest();
                childRequest.setTypeName((String) typeList.get(i));
                childRequest.setFilter((Filter) filterList.get(i));
                childRequest.setReleaseAll(releaseAll);
                parentRequest.addSubRequest(childRequest);
            }
        } else if (filterSize == 0) {
            String message = "No filter found.  If you are sure you want to "
                + "wipe out your database, then use a filter that is always true"
                + ".  We just don't want you to inadvertantly wipe everything "
View Full Code Here


        InsertRequest insert = new InsertRequest();

        insert.setHandle("insert 1");
        insert.addFeature(testFeature);

        TransactionRequest baseRequest = new TransactionRequest();
        baseRequest.addSubRequest(insert);
        baseRequest.setHandle("my insert");

        // run test      
        //assertTrue(runXmlTest(baseRequest, "insert1", true));
    }
View Full Code Here

        // make base comparison objects       
        InsertRequest insert = new InsertRequest();
        insert.setHandle("insert 2");
        insert.addFeature(testFeature);

        TransactionRequest baseRequest = new TransactionRequest();
        baseRequest.addSubRequest(insert);

        Coordinate[] points = {
            new Coordinate(5, 5), new Coordinate(5, 15), new Coordinate(15, 15),
            new Coordinate(15, 5), new Coordinate(5, 5)
        };
        PrecisionModel precModel = new PrecisionModel();
        int srid = 2035;
        LinearRing shell = new LinearRing(points, precModel, srid);
        Polygon the_geom = new Polygon(shell, precModel, srid);

        Integer featureId = new Integer(23);
        String name = "polygon2";
        Object[] attributes = { featureId, the_geom, name };

        //try{
        Feature feature2 = schema.create(attributes, String.valueOf(featureId));

        insert.addFeature(feature2);
        baseRequest.setHandle("my second insert");

        // run test      
        //assertTrue(runXmlTest(baseRequest, "insert2", true));
    }
View Full Code Here

        UpdateRequest update = new UpdateRequest();
        update.setTypeName("BUILTUPA_1M");
        update.setFilter(factory.createFidFilter("10131"));
        update.addProperty("POPULATION", "4070000");

        TransactionRequest baseRequest = new TransactionRequest();
        baseRequest.addSubRequest(update);

        // run test      
        assertTrue(runXmlTest(baseRequest, "update1", true));
    }
View Full Code Here

        tempFilter.addFid("34");
        tempFilter.addFid("24256");
        update.setFilter(tempFilter);
        update.addProperty("POPULATION_TYPE", "CITY");

        TransactionRequest baseRequest = new TransactionRequest();
        baseRequest.addSubRequest(update);

        // run test      
        assertTrue(runXmlTest(baseRequest, "update2", true));
    }
View Full Code Here

        compFilter.addLeftValue(tempLeftExp);
        compFilter.addRightValue(tempRightExp);
        update2.setFilter(compFilter);
        update2.addProperty("FAC_ID", "100");

        TransactionRequest baseRequest = new TransactionRequest();
        baseRequest.addSubRequest(update);
        baseRequest.addSubRequest(update2);

        // run test      
        assertTrue(runXmlTest(baseRequest, "update3", true));
    }
View Full Code Here

        UpdateRequest update = new UpdateRequest();
        update.setTypeName("BUILTUPA_1M");
        update.setFilter(factory.createFidFilter("10131"));
        update.addProperty("POPULATION", "4070000");

        TransactionRequest baseRequest = new TransactionRequest();
        baseRequest.addSubRequest(update);

        // run test      
        assertTrue(runXmlTest(baseRequest, "update5", true));
    }
View Full Code Here

        String testRequest = "VERSION=1.0.0&" + "SERVICE=WFS&"
            + "REQUEST=TRANSACTION&" + "OPERATION=delete&" + "TYPENAME=rail&"
            + "featureID=123";

        // make base comparison objects       
        TransactionRequest baseRequest = new TransactionRequest();
        DeleteRequest internalRequest = new DeleteRequest();
        internalRequest.setTypeName("rail");

        FidFilter filter = factory.createFidFilter("123");
        internalRequest.setFilter(filter);
        baseRequest.addSubRequest(internalRequest);

        // run test      
        assertTrue(runKvpTest(baseRequest, testRequest, true));
    }
View Full Code Here

        String testRequest = "VERSION=1.0.0&" + "SERVICE=WFS&"
            + "REQUEST=TRANSACTION&" + "OPERATION=delete&"
            + "TYPENAME=rail,roads&"
            + "FILTER=(<Filter xmlns:gml='http://www.opengis.net/gml'><Within><PropertyName>location</PropertyName><gml:Box><gml:coordinates>10,10 20,20</gml:coordinates></gml:Box></Within></Filter>)(<Filter xmlns:gml='http://www.opengis.net/gml'><Within><PropertyName>location</PropertyName><gml:Box><gml:coordinates>10,10 20,20</gml:coordinates></gml:Box></Within></Filter>)";

        TransactionRequest baseRequest = new TransactionRequest();
        baseRequest.setVersion("1.0.0");

        DeleteRequest internalRequest1 = new DeleteRequest();
        internalRequest1.setTypeName("rail");

        //baseRequest.setReleaseAction(true);
        // make base comparison objects
        GeometryFilter filter = factory.createGeometryFilter(AbstractFilter.GEOMETRY_WITHIN);
        AttributeExpression leftExpression = factory.createAttributeExpression((AttributeType)null);
        leftExpression.setAttributePath("location");

        // Creates coordinates for the linear ring
        Coordinate[] coords = new Coordinate[5];
        coords[0] = new Coordinate(10, 10);
        coords[1] = new Coordinate(10, 20);
        coords[2] = new Coordinate(20, 20);
        coords[3] = new Coordinate(20, 10);
        coords[4] = new Coordinate(10, 10);

        LinearRing outerShell = new LinearRing(coords, new PrecisionModel(), 0);
        Polygon polygon = new Polygon(outerShell, new PrecisionModel(), 0);
        LiteralExpression rightExpression = factory.createLiteralExpression(polygon);
        filter.addLeftGeometry(leftExpression);
        filter.addRightGeometry(rightExpression);

        internalRequest1.setFilter(filter);

        DeleteRequest internalRequest2 = new DeleteRequest();
        internalRequest2.setTypeName("roads");
        internalRequest2.setFilter(filter);

        baseRequest.addSubRequest(internalRequest1);
        baseRequest.addSubRequest(internalRequest2);

        // run test      
        assertTrue(runKvpTest(baseRequest, testRequest, true));
    }
View Full Code Here

    public void testKVP3() throws Exception {
        String testRequest = "VERSION=1.0.0&" + "SERVICE=WFS&"
            + "REQUEST=TRANSACTION&" + "OPERATION=delete&" + "TYPENAME=rail&"
            + "BBOX=10,10,20,20";

        TransactionRequest baseRequest = new TransactionRequest();
        baseRequest.setVersion("1.0.0");

        DeleteRequest internalRequest1 = new DeleteRequest();
        internalRequest1.setTypeName("rail");

        // make base comparison objects
        GeometryFilter filter = factory.createGeometryFilter(AbstractFilter.GEOMETRY_BBOX);

        // Creates coordinates for the linear ring
        Coordinate[] coords = new Coordinate[5];
        coords[0] = new Coordinate(10, 10);
        coords[1] = new Coordinate(10, 20);
        coords[2] = new Coordinate(20, 20);
        coords[3] = new Coordinate(20, 10);
        coords[4] = new Coordinate(10, 10);

        LinearRing outerShell = new LinearRing(coords, new PrecisionModel(), 0);
        Polygon polygon = new Polygon(outerShell, new PrecisionModel(), 0);
        LiteralExpression rightExpression = factory.createLiteralExpression(polygon);
        filter.addRightGeometry(rightExpression);

        internalRequest1.setFilter(filter);
        baseRequest.addSubRequest(internalRequest1);

        // run test      
        assertTrue(runKvpTest(baseRequest, testRequest, true));
    }
View Full Code Here

TOP

Related Classes of org.vfny.geoserver.wfs.requests.TransactionRequest

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.