Search in sources :

Example 11 with MultiValueFilter

use of io.arlas.server.core.model.request.MultiValueFilter in project ARLAS-server by gisaia.

the class AbstractFilteredTest method testPwithinFilter.

@Test
public void testPwithinFilter() throws Exception {
    /**
     * west < east bbox
     */
    request.filter.f = Arrays.asList(new MultiValueFilter<>(new Expression("geo_params.centroid", OperatorEnum.within, "-5,-5,5,5")));
    // an empty column filter is not considered
    handleMatchingGeometryFilter(post(request, "column-filter", ""), 1, everyItem(equalTo("0,0")));
    // an empty column filter is not considered
    handleMatchingGeometryFilter(get("f", request.filter.f.get(0).get(0).toString(), "column-filter", ""), 1, everyItem(equalTo("0,0")));
    handleMatchingGeometryFilter(header(request.filter), 1, everyItem(equalTo("0,0")));
    /**
     * clock-wise WKT
     */
    request.filter.f = Arrays.asList(new MultiValueFilter<>(new Expression("geo_params.centroid", OperatorEnum.within, "POLYGON((-5 -5, -5 5, 5 5, 5 -5, -5 -5))")));
    handleMatchingGeometryFilter(post(request, "column-filter", "fullname"), 1, everyItem(equalTo("0,0")));
    handleMatchingGeometryFilter(get("f", request.filter.f.get(0).get(0).toString(), "column-filter", "fullname"), 1, everyItem(equalTo("0,0")));
    handleMatchingGeometryFilter(header(request.filter), 1, everyItem(equalTo("0,0")));
    /**
     * west > east bbox
     */
    request.filter.f = Arrays.asList(new MultiValueFilter<>(new Expression("geo_params.centroid", OperatorEnum.within, "5,-5,-5,5")));
    handleMatchingGeometryFilter(post(request), 34, everyItem(startsWith("0,")));
    handleMatchingGeometryFilter(get("f", request.filter.f.get(0).get(0).toString()), 34, everyItem(startsWith("0,")));
    handleMatchingGeometryFilter(header(request.filter), 34, everyItem(startsWith("0,")));
    /**
     * counter clock-wise WKT
     */
    request.filter.f = Arrays.asList(new MultiValueFilter<>(new Expression("geo_params.centroid", OperatorEnum.within, "POLYGON((-5 -5, 5 -5, 5 5, -5 5, -5 -5))")));
    handleMatchingGeometryFilter(post(request), 34, everyItem(startsWith("0,")));
    handleMatchingGeometryFilter(get("f", request.filter.f.get(0).get(0).toString()), 34, everyItem(startsWith("0,")));
    handleMatchingGeometryFilter(header(request.filter), 34, everyItem(startsWith("0,")));
    /**
     * west > east bbox
     */
    request.filter.f = Arrays.asList(new MultiValueFilter<>(new Expression("geo_params.centroid", OperatorEnum.within, "180,0,-165,5")));
    handleMatchingGeometryFilter(post(request), 1, everyItem(equalTo("0,-170")));
    handleMatchingGeometryFilter(get("f", request.filter.f.get(0).get(0).toString()), 1, everyItem(equalTo("0,-170")));
    handleMatchingGeometryFilter(header(request.filter), 1, everyItem(equalTo("0,-170")));
    /**
     * counter clock-wise WKT
     */
    request.filter.f = Arrays.asList(new MultiValueFilter<>(new Expression("geo_params.centroid", OperatorEnum.within, "POLYGON((180 5, -165 5, -165 -5, 180 -5, 180 5))")));
    handleMatchingGeometryFilter(post(request), 1, everyItem(equalTo("0,-170")));
    handleMatchingGeometryFilter(get("f", request.filter.f.get(0).get(0).toString()), 1, everyItem(equalTo("0,-170")));
    handleMatchingGeometryFilter(header(request.filter), 1, everyItem(equalTo("0,-170")));
    /**
     * west < east bbox
     */
    request.filter.f = Arrays.asList(new MultiValueFilter<>(new Expression("geo_params.centroid", OperatorEnum.within, "175,85,180,90")));
    handleNotMatchingPwithinFilter(post(request));
    handleNotMatchingPwithinFilter(get("f", request.filter.f.get(0).get(0).toString()));
    handleNotMatchingPwithinFilter(header(request.filter));
    /**
     * clock-wise WKT
     */
    request.filter.f = Arrays.asList(new MultiValueFilter<>(new Expression("geo_params.centroid", OperatorEnum.within, "POLYGON((175 85, 175 90, 180 90, 180 85, 175 85))")));
    handleNotMatchingPwithinFilter(post(request));
    handleNotMatchingPwithinFilter(get("f", request.filter.f.get(0).get(0).toString()));
    handleNotMatchingPwithinFilter(header(request.filter));
    /**
     * west < east bbox
     */
    request.filter.f = Arrays.asList(new MultiValueFilter<>(new Expression("geo_params.centroid", OperatorEnum.within, "-5,-50,180,50")), new MultiValueFilter<>(new Expression("geo_params.centroid", OperatorEnum.within, "-180,-50,5,50")));
    handleMatchingGeometryFilter(post(request), 10, everyItem(endsWith("0")));
    handleMatchingGeometryFilter(get(Arrays.asList(new ImmutablePair<>("f", request.filter.f.get(0).get(0).toString()), new ImmutablePair<>("f", request.filter.f.get(1).get(0).toString()))), 10, everyItem(endsWith("0")));
    handleMatchingGeometryFilter(header(request.filter), 10, everyItem(endsWith("0")));
    /**
     * clock-wise WKT with west < east bbox
     */
    request.filter.f = Arrays.asList(new MultiValueFilter<>(new Expression("geo_params.centroid", OperatorEnum.within, "POLYGON((-5 -50, -5 50, 180 50, 180 -50, -5 -50))")), new MultiValueFilter<>(new Expression("geo_params.centroid", OperatorEnum.within, "-180,-50,5,50")));
    handleMatchingGeometryFilter(post(request), 10, everyItem(endsWith("0")));
    handleMatchingGeometryFilter(get(Arrays.asList(new ImmutablePair<>("f", request.filter.f.get(0).get(0).toString()), new ImmutablePair<>("f", request.filter.f.get(1).get(0).toString()))), 10, everyItem(endsWith("0")));
    handleMatchingGeometryFilter(header(request.filter), 10, everyItem(endsWith("0")));
    request.filter.f = Arrays.asList(new MultiValueFilter<>(Arrays.asList(new Expression("geo_params.centroid", OperatorEnum.within, "-5,-5,5,5"), new Expression("geo_params.centroid", OperatorEnum.within, "5,5,15,15"))));
    handleMatchingGeometryFilter(post(request), 2, everyItem(isOneOf("0,0", "10,10")));
    handleMatchingGeometryFilter(get("f", request.filter.f.get(0).get(0).toString() + ";" + request.filter.f.get(0).get(1).toString()), 2, everyItem(isOneOf("0,0", "10,10")));
    handleMatchingGeometryFilter(header(request.filter), 2, everyItem(isOneOf("0,0", "10,10")));
    /**
     * west < east bbox
     */
    request.filter.f = Arrays.asList(new MultiValueFilter<>(new Expression("geo_params.centroid", OperatorEnum.notwithin, "-170,-85,175,85")));
    handleMatchingGeometryFilter(post(request), 17, everyItem(endsWith("170")));
    handleMatchingGeometryFilter(get("f", request.filter.f.get(0).get(0).toString()), 17, everyItem(endsWith("170")));
    handleMatchingGeometryFilter(header(request.filter), 17, everyItem(endsWith("170")));
    /**
     * clock-wise WKT
     */
    request.filter.f = Arrays.asList(new MultiValueFilter<>(new Expression("geo_params.centroid", OperatorEnum.notwithin, "POLYGON((-170 -85, -170 85, 175 85, 175 -85, -170 -85))")));
    handleMatchingGeometryFilter(post(request), 17, everyItem(endsWith("170")));
    handleMatchingGeometryFilter(get("f", request.filter.f.get(0).get(0).toString()), 17, everyItem(endsWith("170")));
    handleMatchingGeometryFilter(header(request.filter), 17, everyItem(endsWith("170")));
    /**
     * counter clock-wise WKT
     */
    request.filter.f = Arrays.asList(new MultiValueFilter<>(new Expression("geo_params.centroid", OperatorEnum.notwithin, "POLYGON((-2 -2, 2 -2, 2 2,-2 2, -2 -2))")));
    handleMatchingGeometryFilter(post(request), 561, everyItem(notNullValue()));
    handleMatchingGeometryFilter(get("f", request.filter.f.get(0).get(0).toString()), 561, everyItem(notNullValue()));
    handleMatchingGeometryFilter(header(request.filter), 561, everyItem(notNullValue()));
    /**
     * west < east bbox
     */
    request.filter.f = Arrays.asList(new MultiValueFilter<>(new Expression("geo_params.centroid", OperatorEnum.notwithin, "-175,-85,175,85")));
    handleNotMatchingNotPwithinFilter(post(request));
    handleNotMatchingNotPwithinFilter(get("f", request.filter.f.get(0).get(0).toString()));
    handleNotMatchingNotPwithinFilter(header(request.filter));
    /**
     * clock-wise WKT
     */
    request.filter.f = Arrays.asList(new MultiValueFilter<>(new Expression("geo_params.centroid", OperatorEnum.notwithin, "POLYGON((-175 -85, -175 85, 175 85, 175 -85, -175 -85))")));
    handleNotMatchingNotPwithinFilter(post(request));
    handleNotMatchingNotPwithinFilter(get("f", request.filter.f.get(0).get(0).toString()));
    handleNotMatchingNotPwithinFilter(header(request.filter));
    /**
     * counter clock-wise WKT
     */
    request.filter.f = Arrays.asList(new MultiValueFilter<>(new Expression("geo_params.centroid", OperatorEnum.notwithin, "POLYGON((160 -2, 160 2, -160 2, -160 -2, 160 -2))")));
    handleMatchingGeometryFilter(post(request), 592, everyItem(notNullValue()));
    handleMatchingGeometryFilter(get("f", request.filter.f.get(0).get(0).toString()), 592, notNullValue());
    handleMatchingGeometryFilter(header(request.filter), 592, everyItem(notNullValue()));
    /**
     * multi polygon *
     */
    request.filter.f = Arrays.asList(new MultiValueFilter<>(new Expression("geo_params.centroid", OperatorEnum.notwithin, "MULTIPOLYGON (((-180 -90, -180 90, -5 90, -5 -90, -180 -90)), ((5 -90, 5 90, 180 90, 180 -90, 5 -90)))")));
    handleMatchingGeometryFilter(post(request), 17, everyItem(endsWith("0")));
    handleMatchingGeometryFilter(get("f", request.filter.f.get(0).get(0).toString()), 17, everyItem(endsWith("0")));
    handleMatchingGeometryFilter(header(request.filter), 17, everyItem(endsWith("0")));
    request.filter.f = Arrays.asList(new MultiValueFilter<>(new Expression("geo_params.centroid", OperatorEnum.notwithin, "-180,-90,-5,90")), new MultiValueFilter<>(new Expression("geo_params.centroid", OperatorEnum.notwithin, "5,-90,180,90")));
    handleMatchingGeometryFilter(post(request), 17, everyItem(endsWith("0")));
    handleMatchingGeometryFilter(get(Arrays.asList(new ImmutablePair<>("f", request.filter.f.get(0).get(0).toString()), new ImmutablePair<>("f", request.filter.f.get(1).get(0).toString()))), 17, everyItem(endsWith("0")));
    handleMatchingGeometryFilter(header(request.filter), 17, everyItem(endsWith("0")));
    request.filter.f = Arrays.asList(new MultiValueFilter<>(new Expression("geo_params.centroid", OperatorEnum.notwithin, "POLYGON((-180 -90, -180 90, -5 90, -5 -90, -180 -90))")), new MultiValueFilter<>(new Expression("geo_params.centroid", OperatorEnum.notwithin, "5,-90,180,90")));
    handleMatchingGeometryFilter(post(request), 17, everyItem(endsWith("0")));
    handleMatchingGeometryFilter(get(Arrays.asList(new ImmutablePair<>("f", request.filter.f.get(0).get(0).toString()), new ImmutablePair<>("f", request.filter.f.get(1).get(0).toString()))), 17, everyItem(endsWith("0")));
    handleMatchingGeometryFilter(header(request.filter), 17, everyItem(endsWith("0")));
    request.filter.f = Arrays.asList(new MultiValueFilter<>(Arrays.asList(new Expression("geo_params.centroid", OperatorEnum.notwithin, "-180,-90,-5,90"), new Expression("geo_params.centroid", OperatorEnum.notwithin, "5,-90,180,90"))));
    handleMatchingGeometryFilter(post(request), 595, everyItem(notNullValue()));
    handleMatchingGeometryFilter(get("f", request.filter.f.get(0).get(0).toString() + ";" + request.filter.f.get(0).get(1).toString()), 595, notNullValue());
    handleMatchingGeometryFilter(header(request.filter), 595, everyItem(notNullValue()));
    request.filter.f = Arrays.asList(new MultiValueFilter<>(Arrays.asList(new Expression("geo_params.centroid", OperatorEnum.notwithin, "POLYGON((-180 -90, -180 90, -5 90, -5 -90, -180 -90))"), new Expression("geo_params.centroid", OperatorEnum.notwithin, "5,-90,180,90"))));
    handleMatchingGeometryFilter(post(request), 595, everyItem(notNullValue()));
    handleMatchingGeometryFilter(get("f", request.filter.f.get(0).get(0).toString() + ";" + request.filter.f.get(0).get(1).toString()), 595, notNullValue());
    handleMatchingGeometryFilter(header(request.filter), 595, everyItem(notNullValue()));
    // TODO support correct 10,-10,-10,10 bounding box
    request.filter.f = Arrays.asList(new MultiValueFilter<>(new Expression("geo_params.centroid", OperatorEnum.within, "-11,-11,11,11")), new MultiValueFilter<>(new Expression("geo_params.centroid", OperatorEnum.notwithin, "-5,-5,5,5")));
    handleMatchingGeometryFilter(post(request), 8, hasItems("10,0", "10,-10", "10,10", "10,10", "10,0", "10,-10", "0,10", "0,-10"));
    handleMatchingGeometryFilter(givenFilterableRequestParams().param("f", request.filter.f.get(0).get(0).toString()).param("f", request.filter.f.get(1).get(0).toString()).when().get(getUrlPath("geodata")).then(), 8, hasItems("10,0", "10,-10", "10,10", "10,10", "10,0", "10,-10", "0,10", "0,-10"));
    handleMatchingGeometryFilter(header(request.filter), 8, hasItems("10,0", "10,-10", "10,10", "10,10", "10,0", "10,-10", "0,10", "0,-10"));
    request.filter.f = Arrays.asList(new MultiValueFilter<>(new Expression("geo_params.centroid", OperatorEnum.within, "-6,-6,6,6")), new MultiValueFilter<>(new Expression("geo_params.centroid", OperatorEnum.notwithin, "-5,-5,5,5")));
    handleNotMatchingPwithinComboFilter(post(request));
    handleNotMatchingPwithinComboFilter(givenFilterableRequestParams().param("f", request.filter.f.get(0).get(0).toString()).param("f", request.filter.f.get(1).get(0).toString()).when().get(getUrlPath("geodata")).then());
    handleNotMatchingPwithinComboFilter(header(request.filter));
    // column filter allows other geometry fields
    request.filter.f = Arrays.asList(new MultiValueFilter<>(new Expression("geo_params.other_geopoint", OperatorEnum.within, "-5,-5,5,5")));
    handleMatchingGeometryFilter(post(request, "column-filter", "geo_params"), 1, everyItem(equalTo("-10,-10")));
    handleMatchingGeometryFilter(get("f", request.filter.f.get(0).get(0).toString(), "column-filter", "geo_params"), 1, everyItem(equalTo("-10,-10")));
    request.filter.f = null;
}
Also used : Expression(io.arlas.server.core.model.request.Expression) MultiValueFilter(io.arlas.server.core.model.request.MultiValueFilter) Test(org.junit.Test)

Example 12 with MultiValueFilter

use of io.arlas.server.core.model.request.MultiValueFilter in project ARLAS-server by gisaia.

the class AbstractFilteredTest method testRangeFilter.

@Test
public void testRangeFilter() throws Exception {
    // TIMESTAMP RANGE
    request.filter.f = Arrays.asList(new MultiValueFilter<>(new Expression("params.startdate", OperatorEnum.range, "[0<775000]")));
    handleMatchingTimestampRangeFilter(post(request), 0, 775000, 3);
    handleMatchingTimestampRangeFilter(get("f", request.filter.f.get(0).get(0).toString()), 0, 775000, 3);
    handleMatchingTimestampRangeFilter(header(request.filter), 0, 775000, 3);
    // ALIAS
    request.filter.f = Arrays.asList(new MultiValueFilter<>(new Expression("$timestamp", OperatorEnum.range, "[0<775000]")));
    handleMatchingTimestampRangeFilter(post(request), 0, 775000, 3);
    handleMatchingTimestampRangeFilter(get("f", request.filter.f.get(0).get(0).toString()), 0, 775000, 3);
    handleMatchingTimestampRangeFilter(header(request.filter), 0, 775000, 3);
    // ALIAS
    request.filter.f = Arrays.asList(new MultiValueFilter<>(new Expression("$timestamp", OperatorEnum.range, "[0<775000||-3s/s[")));
    handleMatchingTimestampRangeFilter(post(request), 0, 772000, 2);
    handleMatchingTimestampRangeFilter(get("f", request.filter.f.get(0).get(0).toString()), 0, 772000, 2);
    handleMatchingTimestampRangeFilter(header(request.filter), 0, 772000, 2);
    request.filter.f = Arrays.asList(new MultiValueFilter<>(new Expression("$timestamp", OperatorEnum.range, "[770000<775000]")));
    handleMatchingTimestampRangeFilter(post(request), 770000, 775000, 2);
    handleMatchingTimestampRangeFilter(get("f", request.filter.f.get(0).get(0).toString()), 770000, 775000, 2);
    handleMatchingTimestampRangeFilter(header(request.filter), 770000, 775000, 2);
    // MULTIRANGE
    request.filter.f = Arrays.asList(new MultiValueFilter<>(new Expression("$timestamp", OperatorEnum.range, "[0<765000],[770000<775000]")));
    handleMatchingTimestampRangeFilter(post(request), 0, 775000, 3);
    handleMatchingTimestampRangeFilter(get("f", request.filter.f.get(0).get(0).toString()), 0, 775000, 3);
    handleMatchingTimestampRangeFilter(header(request.filter), 0, 775000, 3);
    request.filter.f = Arrays.asList(new MultiValueFilter<>(new Expression("params.startdate", OperatorEnum.range, "[1270000<1283600]")));
    handleNotMatchingRange(post(request));
    handleNotMatchingRange(get("f", request.filter.f.get(0).get(0).toString()));
    handleNotMatchingRange(header(request.filter));
    request.filter.f = Arrays.asList(new MultiValueFilter<>(new Expression("params.startdate", OperatorEnum.range, "[now<now+2M/d]")));
    handleNotMatchingRange(post(request));
    handleNotMatchingRange(get("f", request.filter.f.get(0).get(0).toString()));
    handleNotMatchingRange(header(request.filter));
    request.filter.f = Arrays.asList(new MultiValueFilter<>(new Expression("params.startdate", OperatorEnum.range, "[765000<770000],[1270000<1283600]")));
    handleNotMatchingRange(post(request));
    handleNotMatchingRange(get("f", request.filter.f.get(0).get(0).toString()));
    handleNotMatchingRange(header(request.filter));
    // TEXT RANGE
    request.filter.f = Arrays.asList(new MultiValueFilter<>(new Expression("params.job", OperatorEnum.range, "[Ac<An]")));
    handleMatchingStringRangeFilter(post(request), "Ac", "An", 59);
    handleMatchingStringRangeFilter(get("f", request.filter.f.get(0).get(0).toString()), "Ac", "An", 59);
    handleMatchingStringRangeFilter(header(request.filter), "Ac", "An", 59);
    request.filter.f = Arrays.asList(new MultiValueFilter<>(new Expression("params.job", OperatorEnum.range, "[Coa<Cod]")));
    handleMatchingStringRangeFilter(post(request), "Coa", "Cod", 58);
    handleMatchingStringRangeFilter(get("f", request.filter.f.get(0).get(0).toString()), "Coa", "Cod", 58);
    handleMatchingStringRangeFilter(header(request.filter), "Coa", "Cod", 58);
    request.filter.f = Arrays.asList(new MultiValueFilter<>(new Expression("params.job", OperatorEnum.range, "[Coa<Cod],[Ac<An]")));
    handleMatchingStringRangeFilter(post(request), "Ac", "Cod", 117);
    handleMatchingStringRangeFilter(get("f", request.filter.f.get(0).get(0).toString()), "Ac", "Cod", 117);
    handleMatchingStringRangeFilter(header(request.filter), "Ac", "Cod", 117);
    request.filter.f = Arrays.asList(new MultiValueFilter<>(new Expression("params.job", OperatorEnum.range, "[X<Z]")));
    handleNotMatchingRange(post(request));
    handleNotMatchingRange(get("f", request.filter.f.get(0).get(0).toString()));
    handleNotMatchingRange(header(request.filter));
    request.filter.f = null;
}
Also used : Expression(io.arlas.server.core.model.request.Expression) MultiValueFilter(io.arlas.server.core.model.request.MultiValueFilter) Test(org.junit.Test)

Example 13 with MultiValueFilter

use of io.arlas.server.core.model.request.MultiValueFilter in project ARLAS-server by gisaia.

the class AbstractFilteredTest method testInvalidFilterParameters.

@Test
public void testInvalidFilterParameters() throws Exception {
    // FIELD
    // );
    request.filter.f = Arrays.asList(new MultiValueFilter<>(new Expression("foobar", null, null)));
    handleInvalidParameters(post(request));
    handleInvalidParameters(get("f", request.filter.f.get(0).get(0)));
    handleInvalidParameters(header(request.filter));
    request.filter.f = null;
    request.filter.f = Arrays.asList(new MultiValueFilter<>(new Expression("params.startdate", OperatorEnum.range, "[0<775000],")));
    handleInvalidParameters(post(request));
    handleInvalidParameters(get("f", request.filter.f.get(0).get(0).toString()));
    handleInvalidParameters(header(request.filter));
    request.filter.f = null;
    request.filter.f = Arrays.asList(new MultiValueFilter<>(new Expression("params.startdate", OperatorEnum.gte, "775000.0")));
    handleInvalidParameters(post(request));
    handleInvalidParameters(get("f", request.filter.f.get(0).get(0).toString()));
    handleInvalidParameters(header(request.filter));
    request.filter.f = null;
    request.filter.f = Arrays.asList(new MultiValueFilter<>(new Expression("params.startdate", OperatorEnum.gte, "now-")));
    handleInvalidParameters(post(request));
    handleInvalidParameters(get("f", request.filter.f.get(0).get(0).toString()));
    handleInvalidParameters(header(request.filter));
    request.filter.f = null;
    // PWITHIN
    request.filter.f = Arrays.asList(new MultiValueFilter<>(new Expression("geo_params.centroid", OperatorEnum.within, "-5,5,5,-5")));
    handleInvalidParameters(post(request));
    handleInvalidParameters(get("f", request.filter.f.get(0).get(0).toString()));
    handleInvalidParameters(header(request.filter));
    request.filter.f = Arrays.asList(new MultiValueFilter<>(new Expression("geo_params.centroid", OperatorEnum.within, "foo")));
    handleInvalidParameters(post(request));
    handleInvalidParameters(get("f", request.filter.f.get(0).get(0).toString()));
    handleInvalidParameters(header(request.filter));
    request.filter.f = Arrays.asList(new MultiValueFilter<>(new Expression("geo_params.centroid", OperatorEnum.notwithin, "-5,5,5,-5")));
    handleInvalidParameters(post(request));
    handleInvalidParameters(get("f", request.filter.f.get(0).get(0).toString()));
    handleInvalidParameters(header(request.filter));
    request.filter.f = Arrays.asList(new MultiValueFilter<>(new Expression("geo_params.centroid", OperatorEnum.notwithin, "foo")));
    handleInvalidParameters(post(request));
    handleInvalidParameters(get("f", request.filter.f.get(0).get(0).toString()));
    handleInvalidParameters(header(request.filter));
    // GWITHIN
    request.filter.f = Arrays.asList(new MultiValueFilter<>(new Expression("geo_params.geometry", OperatorEnum.within, "POLYGON((10 10,10 -10,0 -10))")));
    handleInvalidParameters(post(request));
    handleInvalidParameters(get("f", request.filter.f.get(0).get(0).toString()));
    handleInvalidParameters(header(request.filter));
    /**
     * Right oriented polygon that cannot be drawn on the other facet of the globe
     */
    request.filter.f = Arrays.asList(new MultiValueFilter<>(new Expression("geo_params.geometry", OperatorEnum.within, "POLYGON((180 90,-180 90,-180 -90,180 -90,180 90))")));
    handleInvalidParameters(post(request));
    handleInvalidParameters(get("f", request.filter.f.get(0).get(0).toString()));
    handleInvalidParameters(header(request.filter));
    request.filter.f = Arrays.asList(new MultiValueFilter<>(new Expression("geo_params.geometry", OperatorEnum.within, "230,10,100,-10")));
    handleInvalidParameters(post(request));
    handleInvalidParameters(get("f", request.filter.f.get(0).get(0).toString()));
    handleInvalidParameters(header(request.filter));
    request.filter.f = Arrays.asList(new MultiValueFilter<>(new Expression("geo_params.geometry", OperatorEnum.within, "foo")));
    handleInvalidParameters(post(request));
    handleInvalidParameters(get("f", request.filter.f.get(0).get(0).toString()));
    handleInvalidParameters(header(request.filter));
    request.filter.f = Arrays.asList(new MultiValueFilter<>(new Expression("geo_params.geometry", OperatorEnum.within, "POLYGON((1000 10000,10 -10,0 -10,1000 10000))")));
    handleInvalidParameters(post(request));
    handleInvalidParameters(get("f", request.filter.f.get(0).get(0).toString()));
    handleInvalidParameters(header(request.filter));
    request.filter.f = Arrays.asList(new MultiValueFilter<>(new Expression("geo_params.geometry", OperatorEnum.notwithin, "POLYGON((10 10,10 -10,0 -10))")));
    handleInvalidParameters(post(request));
    handleInvalidParameters(get("f", request.filter.f.get(0).get(0).toString()));
    handleInvalidParameters(header(request.filter));
    request.filter.f = Arrays.asList(new MultiValueFilter<>(new Expression("geo_params.geometry", OperatorEnum.notwithin, ("foo"))));
    handleInvalidParameters(post(request));
    handleInvalidParameters(get("f", request.filter.f.get(0).get(0).toString()));
    handleInvalidParameters(header(request.filter));
    request.filter.f = Arrays.asList(new MultiValueFilter<>(new Expression("geo_params.geometry", OperatorEnum.notwithin, "POLYGON((10 10,10 -10,0 -10))")));
    handleInvalidParameters(post(request));
    handleInvalidParameters(get("f", request.filter.f.get(0).get(0).toString()));
    handleInvalidParameters(header(request.filter));
    // GINTERSECT
    request.filter.f = Arrays.asList(new MultiValueFilter<>(new Expression("geo_params.geometry", OperatorEnum.intersects, "POLYGON((10 10,10 -10,0 -10))")));
    handleInvalidParameters(post(request));
    handleInvalidParameters(get("f", request.filter.f.get(0).get(0).toString()));
    handleInvalidParameters(header(request.filter));
    request.filter.f = Arrays.asList(new MultiValueFilter<>(new Expression("geo_params.geometry", OperatorEnum.intersects, "foo")));
    handleInvalidParameters(post(request));
    handleInvalidParameters(get("f", request.filter.f.get(0).get(0).toString()));
    handleInvalidParameters(header(request.filter));
    request.filter.f = Arrays.asList(new MultiValueFilter<>(new Expression("geo_params.geometry", OperatorEnum.intersects, "POLYGON((1000 10000,10 -10,0 -10,1000 10000))")));
    handleInvalidParameters(post(request));
    handleInvalidParameters(get("f", request.filter.f.get(0).get(0).toString()));
    handleInvalidParameters(header(request.filter));
    request.filter.f = Arrays.asList(new MultiValueFilter<>(new Expression("geo_params.geometry", OperatorEnum.notintersects, "POLYGON((10 10,10 -10,0 -10))")));
    handleInvalidParameters(post(request));
    handleInvalidParameters(get("f", request.filter.f.get(0).get(0).toString()));
    handleInvalidParameters(header(request.filter));
    request.filter.f = Arrays.asList(new MultiValueFilter<>(new Expression("geo_params.geometry", OperatorEnum.notintersects, "foo")));
    handleInvalidParameters(post(request));
    handleInvalidParameters(get("f", request.filter.f.get(0).get(0).toString()));
    handleInvalidParameters(header(request.filter));
    request.filter.f = Arrays.asList(new MultiValueFilter<>(new Expression("geo_params.geometry", OperatorEnum.notintersects, "POLYGON((1000 10000,10 -10,0 -10,1000 10000))")));
    handleInvalidParameters(post(request));
    handleInvalidParameters(get("f", request.filter.f.get(0).get(0).toString()));
    handleInvalidParameters(header(request.filter));
    // DATEFORMAT : format not matching the given date
    request.filter.f = Arrays.asList(new MultiValueFilter<>(new Expression("params.startdate", OperatorEnum.lte, "01-01-1970 00:12:55")));
    request.filter.dateformat = "dd-MM-yyyy";
    handleInvalidParameters(post(request));
    handleInvalidParameters(givenFilterableRequestParams().param("f", request.filter.f.get(0).get(0).toString()).param("dateformat", request.filter.dateformat).when().get(getUrlPath("geodata")).then());
    handleInvalidParameters(header(request.filter));
    // DATEFORMAT : format containing `||`
    request.filter.f = Arrays.asList(new MultiValueFilter<>(new Expression("params.startdate", OperatorEnum.lte, "01-01||1970 ||-1h")));
    request.filter.dateformat = "dd-MM||yyyy";
    handleInvalidParameters(post(request));
    handleInvalidParameters(givenFilterableRequestParams().param("f", request.filter.f.get(0).get(0).toString()).param("dateformat", request.filter.dateformat).when().get(getUrlPath("geodata")).then());
    handleInvalidParameters(header(request.filter));
    // DATEFORMAT : format set when no date field is queried
    request.filter.f = Arrays.asList(new MultiValueFilter<>(new Expression("params.job", OperatorEnum.like, "Architect")));
    request.filter.dateformat = "dd-MM-yyyy";
    handleInvalidParameters(post(request));
    handleInvalidParameters(givenFilterableRequestParams().param("f", request.filter.f.get(0).get(0).toString()).param("dateformat", request.filter.dateformat).when().get(getUrlPath("geodata")).then());
    handleInvalidParameters(header(request.filter));
}
Also used : Expression(io.arlas.server.core.model.request.Expression) MultiValueFilter(io.arlas.server.core.model.request.MultiValueFilter) Test(org.junit.Test)

Example 14 with MultiValueFilter

use of io.arlas.server.core.model.request.MultiValueFilter in project ARLAS-server by gisaia.

the class AbstractFilteredTest method testMultiGeometriesFilter.

@Test
public void testMultiGeometriesFilter() throws Exception {
    // geometry intersects AND second_geometry within : match found
    request.filter.f = Arrays.asList(new MultiValueFilter<>(new Expression("geo_params.geometry", OperatorEnum.intersects, "-12,-12,0,0")), new MultiValueFilter<>(new Expression("geo_params.second_geometry", OperatorEnum.within, "3,3,10,10")));
    handleMatchingGeometryFilter(post(request), 1, everyItem(equalTo("0,0")));
    handleMatchingGeometryFilter(get(Arrays.asList(new ImmutablePair<>("f", request.filter.f.get(0).get(0).toString()), new ImmutablePair<>("f", request.filter.f.get(1).get(0).toString()))), 1, everyItem(equalTo("0,0")));
    handleMatchingGeometryFilter(header(request.filter), 1, everyItem(equalTo("0,0")));
    // geometry intersects AND second_geometry within : match NOT found
    request.filter.f = Arrays.asList(new MultiValueFilter<>(new Expression("geo_params.geometry", OperatorEnum.intersects, "-12,-12,-10,-10")), new MultiValueFilter<>(new Expression("geo_params.second_geometry", OperatorEnum.within, "3,3,10,10")));
    handleNotMatchingRequest(post(request));
    handleNotMatchingRequest(get(Arrays.asList(new ImmutablePair<>("f", request.filter.f.get(0).get(0).toString()), new ImmutablePair<>("f", request.filter.f.get(1).get(0).toString()))));
    handleNotMatchingRequest(header(request.filter));
    // geometry intersects OR second_geometry within : match found
    request.filter.f = Arrays.asList(new MultiValueFilter<>(Arrays.asList(new Expression("geo_params.geometry", OperatorEnum.intersects, "-12,-12,-10,-10"), new Expression("geo_params.second_geometry", OperatorEnum.within, "3,3,10,10"))));
    handleMatchingGeometryFilter(post(request), 2, hasItems("0,0", "-10,-10"));
    handleMatchingGeometryFilter(get("f", request.filter.f.get(0).get(0).toString() + ";" + request.filter.f.get(0).get(1).toString()), 2, hasItems("0,0", "-10,-10"));
    handleMatchingGeometryFilter(header(request.filter), 2, hasItems("0,0", "-10,-10"));
    // centroid within AND other_geopoint within : match found
    request.filter.f = Arrays.asList(new MultiValueFilter<>(new Expression("geo_params.centroid", OperatorEnum.within, "-12,-12,0,0")), new MultiValueFilter<>(new Expression("geo_params.other_geopoint", OperatorEnum.within, "3,3,10,10")));
    handleMatchingGeometryFilter(post(request), 1, everyItem(equalTo("0,0")));
    handleMatchingGeometryFilter(get(Arrays.asList(new ImmutablePair<>("f", request.filter.f.get(0).get(0).toString()), new ImmutablePair<>("f", request.filter.f.get(1).get(0).toString()))), 1, everyItem(equalTo("0,0")));
    handleMatchingGeometryFilter(header(request.filter), 1, everyItem(equalTo("0,0")));
    // centroid within AND other_geopoint within : match NOT found
    request.filter.f = Arrays.asList(new MultiValueFilter<>(new Expression("geo_params.centroid", OperatorEnum.within, "-12,-12,-10,-10")), new MultiValueFilter<>(new Expression("geo_params.other_geopoint", OperatorEnum.within, "3,3,10,10")));
    handleNotMatchingRequest(post(request));
    handleNotMatchingRequest(get(Arrays.asList(new ImmutablePair<>("f", request.filter.f.get(0).get(0).toString()), new ImmutablePair<>("f", request.filter.f.get(1).get(0).toString()))));
    handleNotMatchingRequest(header(request.filter));
    // centroid within OR other_geopoint within : match found
    request.filter.f = Arrays.asList(new MultiValueFilter<>(Arrays.asList(new Expression("geo_params.centroid", OperatorEnum.within, "-12,-12,-10,-10"), new Expression("geo_params.other_geopoint", OperatorEnum.within, "3,3,10,10"))));
    handleMatchingGeometryFilter(post(request), 2, hasItems("0,0", "-10,-10"));
    handleMatchingGeometryFilter(get("f", request.filter.f.get(0).get(0).toString() + ";" + request.filter.f.get(0).get(1).toString()), 2, hasItems("0,0", "-10,-10"));
    handleMatchingGeometryFilter(header(request.filter), 2, hasItems("0,0", "-10,-10"));
    // geometry intersects AND other_geopoint within : match found
    request.filter.f = Arrays.asList(new MultiValueFilter<>(new Expression("geo_params.geometry", OperatorEnum.intersects, "-12,-12,0,0")), new MultiValueFilter<>(new Expression("geo_params.other_geopoint", OperatorEnum.within, "3,3,10,10")));
    handleMatchingGeometryFilter(post(request), 1, everyItem(equalTo("0,0")));
    handleMatchingGeometryFilter(get(Arrays.asList(new ImmutablePair<>("f", request.filter.f.get(0).get(0).toString()), new ImmutablePair<>("f", request.filter.f.get(1).get(0).toString()))), 1, everyItem(equalTo("0,0")));
    handleMatchingGeometryFilter(header(request.filter), 1, everyItem(equalTo("0,0")));
}
Also used : Expression(io.arlas.server.core.model.request.Expression) MultiValueFilter(io.arlas.server.core.model.request.MultiValueFilter) Test(org.junit.Test)

Example 15 with MultiValueFilter

use of io.arlas.server.core.model.request.MultiValueFilter in project ARLAS-server by gisaia.

the class AbstractFilteredTest method testFieldFilterWithUnavailableColumns.

@Test
public void testFieldFilterWithUnavailableColumns() throws Exception {
    request.filter = new Filter();
    request.filter.f = Arrays.asList(new MultiValueFilter<>(new Expression("params.job", OperatorEnum.eq, "Architect")));
    handleUnavailableColumn(givenFilterableRequestParams().header("column-filter", "params.city").param("f", new Expression("params.job", OperatorEnum.eq, "Architect").toString()).when().get(getUrlPath("geodata")).then());
    handleUnavailableColumn(post(request, "column-filter", "params.city"));
    // also filter geometry filters
    request.filter.f = Arrays.asList(new MultiValueFilter<>(new Expression("geo_params.other_geopoint", OperatorEnum.within, "-5,-5,5,5")));
    handleUnavailableColumn(post(request, "column-filter", "fullname"));
    handleUnavailableColumn(get("f", request.filter.f.get(0).get(0).toString(), "column-filter", "fullname"));
    request.filter = new Filter();
}
Also used : Filter(io.arlas.server.core.model.request.Filter) MultiValueFilter(io.arlas.server.core.model.request.MultiValueFilter) Expression(io.arlas.server.core.model.request.Expression) MultiValueFilter(io.arlas.server.core.model.request.MultiValueFilter) Test(org.junit.Test)

Aggregations

MultiValueFilter (io.arlas.server.core.model.request.MultiValueFilter)19 Expression (io.arlas.server.core.model.request.Expression)17 Test (org.junit.Test)17 Filter (io.arlas.server.core.model.request.Filter)11 ArlasException (io.arlas.server.core.exceptions.ArlasException)2 CollectionReferenceParameters (io.arlas.server.core.model.CollectionReferenceParameters)2 DublinCoreElementName (io.arlas.server.core.model.DublinCoreElementName)2 Inspire (io.arlas.server.core.model.Inspire)2 IOException (java.io.IOException)2 UnknownHostException (java.net.UnknownHostException)2 RequestSpecification (io.restassured.specification.RequestSpecification)1