Search in sources :

Example 1 with ComparisonOperatorType

use of net.opengis.filter.v_1_1_0.ComparisonOperatorType in project ddf by codice.

the class TestWfsFilterDelegate method makeDelegateForLogicalSupportTests.

private WfsFilterDelegate makeDelegateForLogicalSupportTests() {
    String mockProperty = "myPropertyName";
    String mockType = "myType";
    List<String> mockProperties = new ArrayList<>(1);
    mockProperties.add(mockProperty);
    when(mockFeatureMetacardType.getProperties()).thenReturn(mockProperties);
    when(mockFeatureMetacardType.getGmlProperties()).thenReturn(mockProperties);
    when(mockFeatureMetacardType.getTextualProperties()).thenReturn(mockProperties);
    when(mockFeatureMetacardType.getTemporalProperties()).thenReturn(mockProperties);
    when(mockFeatureMetacardType.getName()).thenReturn(mockType);
    FeatureAttributeDescriptor mockFeatureAttributeDescriptor = mock(FeatureAttributeDescriptor.class);
    when(mockFeatureAttributeDescriptor.isIndexed()).thenReturn(true);
    when(mockFeatureAttributeDescriptor.getPropertyName()).thenReturn(mockProperty);
    when(mockFeatureMetacardType.getAttributeDescriptor(mockProperty)).thenReturn(mockFeatureAttributeDescriptor);
    FilterCapabilities filterCap = MockWfsServer.getFilterCapabilities();
    //Create new ScalarCapabiltiesType without Logical Operator support
    ScalarCapabilitiesType scalar = new ScalarCapabilitiesType();
    scalar.setComparisonOperators(new ComparisonOperatorsType());
    for (COMPARISON_OPERATORS compOp : COMPARISON_OPERATORS.values()) {
        ComparisonOperatorType operator = new ComparisonOperatorType();
        operator.setName(compOp.toString());
        scalar.getComparisonOperators().getComparisonOperator().add(operator);
    }
    filterCap.setScalarCapabilities(scalar);
    return new WfsFilterDelegate(mockFeatureMetacardType, filterCap, GeospatialUtil.EPSG_4326_URN, null, GeospatialUtil.LAT_LON_ORDER);
}
Also used : FilterCapabilities(net.opengis.filter.v_2_0_0.FilterCapabilities) ComparisonOperatorsType(net.opengis.filter.v_2_0_0.ComparisonOperatorsType) ScalarCapabilitiesType(net.opengis.filter.v_2_0_0.ScalarCapabilitiesType) FeatureAttributeDescriptor(org.codice.ddf.spatial.ogc.wfs.catalog.common.FeatureAttributeDescriptor) ArrayList(java.util.ArrayList) ComparisonOperatorType(net.opengis.filter.v_2_0_0.ComparisonOperatorType) COMPARISON_OPERATORS(org.codice.ddf.spatial.ogc.wfs.v2_0_0.catalog.common.Wfs20Constants.COMPARISON_OPERATORS)

Example 2 with ComparisonOperatorType

use of net.opengis.filter.v_1_1_0.ComparisonOperatorType in project ddf by codice.

the class TestCswFilterDelegate method getXmlProperty.

private String getXmlProperty(CswFilterDelegate localCswFilterDelegate, String propName, ComparisonOperatorType comparisonOp, Date beginDate, Date endDate, Map<String, Object> propMap) throws JAXBException {
    String extendedComparisonOp = null;
    if (null != propMap) {
        extendedComparisonOp = (String) propMap.get("extendedComparisonOp");
    }
    FilterType filterType = null;
    switch(comparisonOp) {
        case BETWEEN:
            if (!StringUtils.isBlank(extendedComparisonOp) && extendedComparisonOp.equals("relative")) {
                Object duration = propMap.get("duration");
                if (duration instanceof Long) {
                    filterType = localCswFilterDelegate.relative(propName, ((Long) duration).longValue());
                }
            } else {
                filterType = localCswFilterDelegate.during(propName, beginDate, endDate);
            }
            break;
        default:
            break;
    }
    marshaller.marshal(getFilterTypeJaxbElement(filterType), writer);
    String xml = writer.toString();
    LOGGER.debug(xml);
    return xml;
}
Also used : FilterType(net.opengis.filter.v_1_1_0.FilterType)

Example 3 with ComparisonOperatorType

use of net.opengis.filter.v_1_1_0.ComparisonOperatorType in project ddf by codice.

the class CswFilterDelegateTest method getXmlProperty.

private String getXmlProperty(CswFilterDelegate localCswFilterDelegate, String propName, ComparisonOperatorType comparisonOp, Date beginDate, Date endDate, Map<String, Object> propMap) throws JAXBException {
    String extendedComparisonOp = null;
    if (null != propMap) {
        extendedComparisonOp = (String) propMap.get("extendedComparisonOp");
    }
    FilterType filterType = null;
    switch(comparisonOp) {
        case BETWEEN:
            if (!StringUtils.isBlank(extendedComparisonOp) && extendedComparisonOp.equals("relative")) {
                Object duration = propMap.get("duration");
                if (duration instanceof Long) {
                    filterType = localCswFilterDelegate.relative(propName, ((Long) duration).longValue());
                }
            } else {
                filterType = localCswFilterDelegate.during(propName, beginDate, endDate);
            }
            break;
        default:
            break;
    }
    marshaller.marshal(getFilterTypeJaxbElement(filterType), writer);
    String xml = writer.toString();
    LOGGER.debug(xml);
    return xml;
}
Also used : FilterType(net.opengis.filter.v_1_1_0.FilterType)

Example 4 with ComparisonOperatorType

use of net.opengis.filter.v_1_1_0.ComparisonOperatorType in project ddf by codice.

the class CswEndpointTest method verifyFilterCapabilities.

/**
 * Helper method to verify the FilterCapabilities section matches the endpoint's definition
 *
 * @param ct The CapabilitiesType to verify
 */
private void verifyFilterCapabilities(CapabilitiesType ct) {
    FilterCapabilities fc = ct.getFilterCapabilities();
    assertThat(fc.getIdCapabilities(), notNullValue());
    assertThat(fc.getIdCapabilities().getEIDOrFID(), hasSize(1));
    assertThat(fc.getScalarCapabilities(), notNullValue());
    assertThat(CswEndpoint.COMPARISON_OPERATORS, hasSize(fc.getScalarCapabilities().getComparisonOperators().getComparisonOperator().size()));
    for (ComparisonOperatorType cot : CswEndpoint.COMPARISON_OPERATORS) {
        assertThat(fc.getScalarCapabilities().getComparisonOperators().getComparisonOperator(), hasItem(cot));
    }
    assertThat(fc.getSpatialCapabilities(), notNullValue());
    assertThat(CswEndpoint.SPATIAL_OPERATORS, hasSize(fc.getSpatialCapabilities().getSpatialOperators().getSpatialOperator().size()));
    for (SpatialOperatorType sot : fc.getSpatialCapabilities().getSpatialOperators().getSpatialOperator()) {
        assertThat(CswEndpoint.SPATIAL_OPERATORS, hasItem(sot.getName()));
    }
}
Also used : FilterCapabilities(net.opengis.filter.v_1_1_0.FilterCapabilities) SpatialOperatorType(net.opengis.filter.v_1_1_0.SpatialOperatorType) ComparisonOperatorType(net.opengis.filter.v_1_1_0.ComparisonOperatorType)

Example 5 with ComparisonOperatorType

use of net.opengis.filter.v_1_1_0.ComparisonOperatorType in project ddf by codice.

the class WfsFilterDelegate method updateAllowedOperations.

private void updateAllowedOperations(FilterCapabilities filterCapabilities) {
    comparisonOps = Collections.newSetFromMap(new ConcurrentHashMap<>(new EnumMap<>(COMPARISON_OPERATORS.class)));
    geometryOperands = new ArrayList<>();
    temporalOperands = new ArrayList<>();
    if (filterCapabilities == null) {
        LOGGER.debug("WFS 2.0 Service doesn't support any filters");
        return;
    }
    // CONFORMANCE
    configureConformance(filterCapabilities.getConformance());
    ScalarCapabilitiesType scalarCapabilities = filterCapabilities.getScalarCapabilities();
    if (scalarCapabilities != null) {
        // LOGICAL OPERATORS
        if (scalarCapabilities.getLogicalOperators() != null) {
            logicalOps = true;
        }
        // COMPARISON OPERATORS
        ComparisonOperatorsType comparisonOperators = scalarCapabilities.getComparisonOperators();
        if (comparisonOperators != null) {
            for (ComparisonOperatorType comp : comparisonOperators.getComparisonOperator()) {
                if (null != comp) {
                    comparisonOps.add(COMPARISON_OPERATORS.getEnum(comp.getName()));
                }
            }
        }
    }
    // SPATIAL OPERATORS
    SpatialCapabilitiesType spatialCapabilities = filterCapabilities.getSpatialCapabilities();
    if (spatialCapabilities != null) {
        if (spatialCapabilities.getSpatialOperators() != null) {
            setSpatialOps(spatialCapabilities.getSpatialOperators());
        }
        // GEOMETRY OPERANDS
        GeometryOperandsType geometryOperandsType = spatialCapabilities.getGeometryOperands();
        if (geometryOperandsType != null) {
            for (GeometryOperandsType.GeometryOperand geoOperand : geometryOperandsType.getGeometryOperand()) {
                if (geoOperand.getName() != null) {
                    geometryOperands.add(geoOperand.getName());
                }
            }
            LOGGER.debug("geometryOperands: {}", geometryOperands);
        }
    }
    // TEMPORAL OPERATORS
    TemporalCapabilitiesType temporalCapabilitiesType = filterCapabilities.getTemporalCapabilities();
    if (temporalCapabilitiesType != null) {
        if (temporalCapabilitiesType.getTemporalOperators() != null) {
            setTemporalOps(temporalCapabilitiesType.getTemporalOperators());
        }
        // TEMPORAL OPERANDS
        TemporalOperandsType temporalOperandsType = temporalCapabilitiesType.getTemporalOperands();
        if (temporalOperandsType != null) {
            for (TemporalOperandsType.TemporalOperand temporalOperand : temporalOperandsType.getTemporalOperand()) {
                if (temporalOperand.getName() != null) {
                    temporalOperands.add(temporalOperand.getName());
                }
            }
            LOGGER.debug("temporalOperands: {}", temporalOperands);
        }
    }
}
Also used : TemporalCapabilitiesType(net.opengis.filter.v_2_0_0.TemporalCapabilitiesType) SpatialCapabilitiesType(net.opengis.filter.v_2_0_0.SpatialCapabilitiesType) ComparisonOperatorsType(net.opengis.filter.v_2_0_0.ComparisonOperatorsType) ScalarCapabilitiesType(net.opengis.filter.v_2_0_0.ScalarCapabilitiesType) GeometryOperandsType(net.opengis.filter.v_2_0_0.GeometryOperandsType) ComparisonOperatorType(net.opengis.filter.v_2_0_0.ComparisonOperatorType) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) COMPARISON_OPERATORS(org.codice.ddf.spatial.ogc.wfs.v2_0_0.catalog.common.Wfs20Constants.COMPARISON_OPERATORS) GeometryOperand(net.opengis.filter.v_2_0_0.GeometryOperandsType.GeometryOperand) TemporalOperandsType(net.opengis.filter.v_2_0_0.TemporalOperandsType) TemporalOperand(net.opengis.filter.v_2_0_0.TemporalOperandsType.TemporalOperand)

Aggregations

ComparisonOperatorType (net.opengis.filter.v_1_1_0.ComparisonOperatorType)4 ComparisonOperatorType (net.opengis.filter.v_2_0_0.ComparisonOperatorType)4 ComparisonOperatorsType (net.opengis.filter.v_2_0_0.ComparisonOperatorsType)4 ScalarCapabilitiesType (net.opengis.filter.v_2_0_0.ScalarCapabilitiesType)4 COMPARISON_OPERATORS (org.codice.ddf.spatial.ogc.wfs.v2_0_0.catalog.common.Wfs20Constants.COMPARISON_OPERATORS)4 ArrayList (java.util.ArrayList)3 FilterCapabilities (net.opengis.filter.v_1_1_0.FilterCapabilities)3 FilterCapabilities (net.opengis.filter.v_2_0_0.FilterCapabilities)3 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)2 ComparisonOperatorsType (net.opengis.filter.v_1_1_0.ComparisonOperatorsType)2 FilterType (net.opengis.filter.v_1_1_0.FilterType)2 ScalarCapabilitiesType (net.opengis.filter.v_1_1_0.ScalarCapabilitiesType)2 SpatialOperatorType (net.opengis.filter.v_1_1_0.SpatialOperatorType)2 GeometryOperandsType (net.opengis.filter.v_2_0_0.GeometryOperandsType)2 GeometryOperand (net.opengis.filter.v_2_0_0.GeometryOperandsType.GeometryOperand)2 SpatialCapabilitiesType (net.opengis.filter.v_2_0_0.SpatialCapabilitiesType)2 TemporalCapabilitiesType (net.opengis.filter.v_2_0_0.TemporalCapabilitiesType)2 TemporalOperandsType (net.opengis.filter.v_2_0_0.TemporalOperandsType)2 TemporalOperand (net.opengis.filter.v_2_0_0.TemporalOperandsType.TemporalOperand)2 Metacard (ddf.catalog.data.Metacard)1