Search in sources :

Example 1 with UnaryLogicOpType

use of org.geotoolkit.ogc.xml.v110.UnaryLogicOpType in project ddf by codice.

the class TestWfsFilterDelegate method testIntersectsAsNotDisjoint.

@Test
public void testIntersectsAsNotDisjoint() {
    WfsFilterDelegate delegate = setupFilterDelegate(SPATIAL_OPERATORS.Disjoint.toString());
    FilterType filter = delegate.intersects(Metacard.ANY_GEO, POLYGON);
    assertTrue(filter.isSetLogicOps());
    assertTrue(filter.getLogicOps().getValue() instanceof UnaryLogicOpType);
    UnaryLogicOpType type = (UnaryLogicOpType) filter.getLogicOps().getValue();
    assertTrue(type.isSetSpatialOps());
    assertTrue(type.getSpatialOps().getValue() instanceof BinarySpatialOpType);
}
Also used : UnaryLogicOpType(net.opengis.filter.v_2_0_0.UnaryLogicOpType) FilterType(net.opengis.filter.v_2_0_0.FilterType) BinarySpatialOpType(net.opengis.filter.v_2_0_0.BinarySpatialOpType) Test(org.junit.Test)

Example 2 with UnaryLogicOpType

use of org.geotoolkit.ogc.xml.v110.UnaryLogicOpType in project ddf by codice.

the class TestWfsFilterDelegate method testLogicalNotOfLogicals.

@Test
public void testLogicalNotOfLogicals() throws Exception {
    String mockProperty = "myPropertyName";
    String mockType = "myType";
    WfsFilterDelegate delegate = mockFeatureMetacardCreateDelegate(mockProperty, mockType);
    FilterType compFilter1 = delegate.propertyIsLike(Metacard.ANY_TEXT, LITERAL, true);
    FilterType compFilter2 = delegate.propertyIsLike(Metacard.ANY_TEXT, LITERAL, true);
    List<FilterType> subFiltersToBeOred = new ArrayList<>();
    subFiltersToBeOred.add(compFilter1);
    subFiltersToBeOred.add(compFilter2);
    //Perform Test
    FilterType filter = delegate.not(delegate.or(subFiltersToBeOred));
    //Verify
    assertThat(filter.getLogicOps().getName().toString(), is(LOGICAL_NOT_NAME));
    UnaryLogicOpType logicOpType = (UnaryLogicOpType) filter.getLogicOps().getValue();
    BinaryLogicOpType logicOrType = (BinaryLogicOpType) logicOpType.getLogicOps().getValue();
    assertThat(logicOpType.getLogicOps().getName().toString(), is(LOGICAL_OR_NAME));
    PropertyIsLikeType compOpsType1 = (PropertyIsLikeType) logicOrType.getComparisonOpsOrSpatialOpsOrTemporalOps().get(0).getValue();
    String valRef1 = fetchPropertyIsLikeExpression(compOpsType1, VALUE_REFERENCE);
    assertThat(valRef1, is(mockProperty));
    String literal1 = fetchPropertyIsLikeExpression(compOpsType1, LITERAL);
    assertThat(literal1, is(LITERAL));
    PropertyIsLikeType compOpsType2 = (PropertyIsLikeType) logicOrType.getComparisonOpsOrSpatialOpsOrTemporalOps().get(1).getValue();
    String valRef2 = fetchPropertyIsLikeExpression(compOpsType2, VALUE_REFERENCE);
    assertThat(valRef2, is(mockProperty));
    String literal2 = fetchPropertyIsLikeExpression(compOpsType2, LITERAL);
    assertThat(literal2, is(LITERAL));
}
Also used : UnaryLogicOpType(net.opengis.filter.v_2_0_0.UnaryLogicOpType) FilterType(net.opengis.filter.v_2_0_0.FilterType) BinaryLogicOpType(net.opengis.filter.v_2_0_0.BinaryLogicOpType) ArrayList(java.util.ArrayList) PropertyIsLikeType(net.opengis.filter.v_2_0_0.PropertyIsLikeType) Test(org.junit.Test)

Example 3 with UnaryLogicOpType

use of org.geotoolkit.ogc.xml.v110.UnaryLogicOpType in project ddf by codice.

the class TestWfsFilterDelegate method testLogicalNotOfSpatial.

@Test
public void testLogicalNotOfSpatial() throws Exception {
    String mockProperty = "myPropertyName";
    String mockType = "myType";
    WfsFilterDelegate delegate = mockFeatureMetacardCreateDelegate(mockProperty, mockType);
    FilterType spatialFilter1 = delegate.dwithin(Metacard.ANY_GEO, "POINT (30 10)", Double.valueOf(1000));
    //Perform Test
    FilterType filter = delegate.not(spatialFilter1);
    //Verify
    assertThat(filter.getLogicOps().getName().toString(), is(LOGICAL_NOT_NAME));
    UnaryLogicOpType logicOpType = (UnaryLogicOpType) filter.getLogicOps().getValue();
    DistanceBufferType spatialOpsType1 = (DistanceBufferType) logicOpType.getSpatialOps().getValue();
    assertThat(Double.toString(spatialOpsType1.getDistance().getValue()), is(Double.valueOf(1000).toString()));
}
Also used : UnaryLogicOpType(net.opengis.filter.v_2_0_0.UnaryLogicOpType) FilterType(net.opengis.filter.v_2_0_0.FilterType) DistanceBufferType(net.opengis.filter.v_2_0_0.DistanceBufferType) Test(org.junit.Test)

Example 4 with UnaryLogicOpType

use of org.geotoolkit.ogc.xml.v110.UnaryLogicOpType in project ddf by codice.

the class WfsFilterDelegate method not.

@Override
public FilterType not(FilterType filterToBeNoted) {
    FilterType returnFilter = new FilterType();
    if (filterToBeNoted == null) {
        return returnFilter;
    }
    UnaryLogicOpType notType = new UnaryLogicOpType();
    if (filterToBeNoted.isSetComparisonOps()) {
        notType.setComparisonOps(filterToBeNoted.getComparisonOps());
    } else if (filterToBeNoted.isSetLogicOps()) {
        notType.setLogicOps(filterToBeNoted.getLogicOps());
    } else if (filterToBeNoted.isSetSpatialOps()) {
        notType.setSpatialOps(filterToBeNoted.getSpatialOps());
    } else {
        return returnFilter;
    }
    returnFilter.setLogicOps(filterObjectFactory.createNot(notType));
    return returnFilter;
}
Also used : UnaryLogicOpType(ogc.schema.opengis.filter.v_1_0_0.UnaryLogicOpType) FilterType(ogc.schema.opengis.filter.v_1_0_0.FilterType)

Example 5 with UnaryLogicOpType

use of org.geotoolkit.ogc.xml.v110.UnaryLogicOpType in project ddf by codice.

the class CswFilterFactory method buildNotFilter.

public FilterType buildNotFilter(FilterType filter) {
    FilterType returnFilter = new FilterType();
    if (filter == null) {
        return returnFilter;
    }
    UnaryLogicOpType notType = new UnaryLogicOpType();
    if (filter.isSetComparisonOps()) {
        notType.setComparisonOps(filter.getComparisonOps());
    } else if (filter.isSetLogicOps()) {
        notType.setLogicOps(filter.getLogicOps());
    } else if (filter.isSetSpatialOps()) {
        notType.setSpatialOps(filter.getSpatialOps());
    } else {
        return returnFilter;
    }
    returnFilter.setLogicOps(filterObjectFactory.createNot(notType));
    return returnFilter;
}
Also used : UnaryLogicOpType(net.opengis.filter.v_1_1_0.UnaryLogicOpType) FilterType(net.opengis.filter.v_1_1_0.FilterType)

Aggregations

Test (org.junit.Test)24 FilterType (net.opengis.filter.v_2_0_0.FilterType)17 UnaryLogicOpType (net.opengis.filter.v_2_0_0.UnaryLogicOpType)17 FilterType (net.opengis.filter.v_1_1_0.FilterType)8 UnaryLogicOpType (net.opengis.filter.v_1_1_0.UnaryLogicOpType)8 JAXBElement (javax.xml.bind.JAXBElement)6 DistanceBufferType (net.opengis.filter.v_2_0_0.DistanceBufferType)6 ArrayList (java.util.ArrayList)5 BinarySpatialOpType (net.opengis.filter.v_2_0_0.BinarySpatialOpType)4 PropertyIsLikeType (net.opengis.filter.v_2_0_0.PropertyIsLikeType)4 UnaryLogicOpType (org.geosdi.geoplatform.xml.filter.v110.UnaryLogicOpType)4 Filter (org.opengis.filter.Filter)3 Marshaller (javax.xml.bind.Marshaller)2 Unmarshaller (javax.xml.bind.Unmarshaller)2 BBOXType (net.opengis.filter.v_2_0_0.BBOXType)2 BinaryLogicOpType (net.opengis.filter.v_2_0_0.BinaryLogicOpType)2 BinaryLogicOpType (org.geosdi.geoplatform.xml.filter.v110.BinaryLogicOpType)2 LogicOpsType (org.geotoolkit.ogc.xml.v110.LogicOpsType)2 BinaryComparisonOperator (org.opengis.filter.BinaryComparisonOperator)2 Literal (org.opengis.filter.Literal)2