Search in sources :

Example 1 with UnaryLogicOpType

use of net.opengis.filter.v_2_0_0.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 net.opengis.filter.v_2_0_0.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 net.opengis.filter.v_2_0_0.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 net.opengis.filter.v_2_0_0.UnaryLogicOpType in project ddf by codice.

the class WfsFilterDelegate method not.

@Override
public FilterType not(FilterType filterToBeNoted) {
    areLogicalOperationsSupported();
    FilterType returnFilter = new FilterType();
    if (filterToBeNoted == null) {
        return null;
    }
    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(net.opengis.filter.v_2_0_0.UnaryLogicOpType) FilterType(net.opengis.filter.v_2_0_0.FilterType)

Example 5 with UnaryLogicOpType

use of net.opengis.filter.v_2_0_0.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

FilterType (net.opengis.filter.v_2_0_0.FilterType)9 UnaryLogicOpType (net.opengis.filter.v_2_0_0.UnaryLogicOpType)9 Test (org.junit.Test)9 DistanceBufferType (net.opengis.filter.v_2_0_0.DistanceBufferType)3 FilterType (net.opengis.filter.v_1_1_0.FilterType)2 UnaryLogicOpType (net.opengis.filter.v_1_1_0.UnaryLogicOpType)2 BinarySpatialOpType (net.opengis.filter.v_2_0_0.BinarySpatialOpType)2 PropertyIsLikeType (net.opengis.filter.v_2_0_0.PropertyIsLikeType)2 ArrayList (java.util.ArrayList)1 BBOXType (net.opengis.filter.v_2_0_0.BBOXType)1 BinaryLogicOpType (net.opengis.filter.v_2_0_0.BinaryLogicOpType)1 FilterType (ogc.schema.opengis.filter.v_1_0_0.FilterType)1 UnaryLogicOpType (ogc.schema.opengis.filter.v_1_0_0.UnaryLogicOpType)1