Search in sources :

Example 21 with FilterCapabilities

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

the class CswEndpoint method buildCapabilitiesType.

/**
     * Creates a CapabilitiesType object with only specified sections to be returned as a
     * GetCapabilities response.
     *
     * @param sections The list of desired sections for the GetCapabilities response
     * @return The constructed CapabilitiesType object, containing only the user-specified sections
     */
private CapabilitiesType buildCapabilitiesType(List<String> sections) {
    // If no sections are specified, return them all
    if (sections == null || sections.size() == 0) {
        return capabilitiesType;
    }
    CapabilitiesType cswCapabilities = new CapabilitiesType();
    cswCapabilities.setVersion(capabilitiesType.getVersion());
    // Grab the desired sections from the global capabilitiesType variable
    for (String section : sections) {
        if (section.equalsIgnoreCase(SERVICE_IDENTIFICATION)) {
            cswCapabilities.setServiceIdentification(capabilitiesType.getServiceIdentification());
        } else if (section.equalsIgnoreCase(SERVICE_PROVIDER)) {
            cswCapabilities.setServiceProvider(capabilitiesType.getServiceProvider());
        } else if (section.equalsIgnoreCase(OPERATIONS_METADATA)) {
            cswCapabilities.setOperationsMetadata(capabilitiesType.getOperationsMetadata());
        }
    }
    // filterCapabilities is required.  Add it even if it isn't in the sections list.
    cswCapabilities.setFilterCapabilities(capabilitiesType.getFilterCapabilities());
    return cswCapabilities;
}
Also used : ScalarCapabilitiesType(net.opengis.filter.v_1_1_0.ScalarCapabilitiesType) SpatialCapabilitiesType(net.opengis.filter.v_1_1_0.SpatialCapabilitiesType) IdCapabilitiesType(net.opengis.filter.v_1_1_0.IdCapabilitiesType) CapabilitiesType(net.opengis.cat.csw.v_2_0_2.CapabilitiesType) GetCapabilitiesType(net.opengis.cat.csw.v_2_0_2.GetCapabilitiesType)

Example 22 with FilterCapabilities

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

the class TestWfsFilterDelegate method testRelativeTemporalOnlyQueryAfterUnsupported.

/**
     * If the WFS server does not support an 'After' temporal query and supports a
     * 'During' temporal query, the query should be translated into a 'During <date> to <now>'
     */
@Test
public void testRelativeTemporalOnlyQueryAfterUnsupported() {
    setupMockMetacardType();
    FilterType afterFilter = setupAfterFilterType();
    FilterCapabilities duringFilterCapabilities = setupFilterCapabilities();
    WfsFilterDelegate duringDelegate = new WfsFilterDelegate(mockFeatureMetacardType, duringFilterCapabilities, GeospatialUtil.EPSG_4326_URN, mockMapper, GeospatialUtil.LAT_LON_ORDER);
    List<FilterType> testFilters = new ArrayList<>();
    testFilters.add(afterFilter);
    List<FilterType> convertedFilters = duringDelegate.applyTemporalFallbacks(testFilters);
    FilterType duringFilter = convertedFilters.get(0);
    assertThat(duringFilter.getTemporalOps().getName().toString(), is("{http://www.opengis.net/fes/2.0}During"));
    BinaryTemporalOpType binaryTemporalOpType = (BinaryTemporalOpType) duringFilter.getTemporalOps().getValue();
    assertThat(binaryTemporalOpType.isSetValueReference(), is(true));
    assertThat(binaryTemporalOpType.isSetExpression(), is(true));
    TimePeriodType timePeriod = (TimePeriodType) binaryTemporalOpType.getExpression().getValue();
    TimePositionType beginPositionType = timePeriod.getBeginPosition();
    Date beginDate = timePositionTypeToDate(beginPositionType);
    TimePositionType endPositionType = timePeriod.getEndPosition();
    Date endDate = timePositionTypeToDate(endPositionType);
    // Verify Date range is created correctly
    assertThat(endDate.after(beginDate), is(true));
}
Also used : FilterCapabilities(net.opengis.filter.v_2_0_0.FilterCapabilities) FilterType(net.opengis.filter.v_2_0_0.FilterType) TimePeriodType(net.opengis.gml.v_3_2_1.TimePeriodType) ArrayList(java.util.ArrayList) BinaryTemporalOpType(net.opengis.filter.v_2_0_0.BinaryTemporalOpType) TimePositionType(net.opengis.gml.v_3_2_1.TimePositionType) Date(java.util.Date) Test(org.junit.Test)

Example 23 with FilterCapabilities

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

the class CswFilterDelegate method updateAllowedOperations.

/**
     * Reads the {@link net.opengis.filter.v_1_1_0.FilterCapabilities} in order to determine what types of queries the server
     * can handle.
     *
     * @param filterCapabilities The {@link net.opengis.filter.v_1_1_0.FilterCapabilities} understood by the Csw service
     */
private final void updateAllowedOperations(FilterCapabilities filterCapabilities) {
    comparisonOps = Collections.newSetFromMap(new ConcurrentHashMap<>(new EnumMap<>(ComparisonOperatorType.class)));
    spatialOps = new ConcurrentHashMap<>(new EnumMap<>(SpatialOperatorNameType.class));
    logicalOps = true;
    if (null == filterCapabilities) {
        LOGGER.info("CSW Service doesn't support any filters");
        return;
    }
    ScalarCapabilitiesType scalarCapabilities = filterCapabilities.getScalarCapabilities();
    if (null != scalarCapabilities) {
        ComparisonOperatorsType comparisonOperators = scalarCapabilities.getComparisonOperators();
        if (null != comparisonOperators) {
            // filter out nulls
            for (ComparisonOperatorType comp : comparisonOperators.getComparisonOperator()) {
                if (null != comp) {
                    comparisonOps.add(comp);
                }
            }
        }
        logicalOps = (null != scalarCapabilities.getLogicalOperators());
    }
    SpatialCapabilitiesType spatialCapabilities = filterCapabilities.getSpatialCapabilities();
    if (null != spatialCapabilities && null != spatialCapabilities.getSpatialOperators()) {
        setSpatialOps(spatialCapabilities.getSpatialOperators());
    }
    GeometryOperandsType geometryOperandsType = null;
    if (spatialCapabilities != null) {
        geometryOperandsType = spatialCapabilities.getGeometryOperands();
    }
    if (geometryOperandsType != null) {
        globalGeometryOperands = geometryOperandsType.getGeometryOperand();
        LOGGER.debug("globalGeometryOperands: {}", globalGeometryOperands);
    }
}
Also used : ComparisonOperatorsType(net.opengis.filter.v_1_1_0.ComparisonOperatorsType) ScalarCapabilitiesType(net.opengis.filter.v_1_1_0.ScalarCapabilitiesType) GeometryOperandsType(net.opengis.filter.v_1_1_0.GeometryOperandsType) ComparisonOperatorType(net.opengis.filter.v_1_1_0.ComparisonOperatorType) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) EnumMap(java.util.EnumMap) SpatialCapabilitiesType(net.opengis.filter.v_1_1_0.SpatialCapabilitiesType)

Example 24 with FilterCapabilities

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

the class TestWfsSource method setUp.

public void setUp(final String schema, final List<Object> supportedGeos, final String srsName, final Integer numFeatures, final Integer numResults) throws WfsException, SecurityServiceException {
    mockFactory = mock(SecureCxfClientFactory.class);
    when(mockFactory.getClient()).thenReturn(mockWfs);
    // GetCapabilities Response
    when(mockWfs.getCapabilities(any(GetCapabilitiesRequest.class))).thenReturn(mockCapabilites);
    mockCapabilites.setFilterCapabilities(new FilterCapabilities());
    mockCapabilites.getFilterCapabilities().setSpatialCapabilities(new SpatialCapabilitiesType());
    mockCapabilites.getFilterCapabilities().getSpatialCapabilities().setSpatialOperators(new SpatialOperatorsType());
    if (null != supportedGeos && !supportedGeos.isEmpty()) {
        mockCapabilites.getFilterCapabilities().getSpatialCapabilities().getSpatialOperators().getBBOXOrEqualsOrDisjoint().addAll(supportedGeos);
    }
    // DescribeFeatureType Response
    XmlSchema xmlSchema = null;
    if (null != schema) {
        XmlSchemaCollection schemaCollection = new XmlSchemaCollection();
        wfsUriResolver.setGmlNamespace(Wfs10Constants.GML_NAMESPACE);
        wfsUriResolver.setWfsNamespace(Wfs10Constants.WFS_NAMESPACE);
        schemaCollection.setSchemaResolver(wfsUriResolver);
        xmlSchema = schemaCollection.read(new StreamSource(new ByteArrayInputStream(schema.getBytes())));
    }
    when(mockWfs.describeFeatureType(any(DescribeFeatureTypeRequest.class))).thenReturn(xmlSchema);
    sampleFeatures = new ArrayList<>();
    mockCapabilites.setFeatureTypeList(new FeatureTypeListType());
    if (numFeatures != null) {
        for (int ii = 0; ii < numFeatures; ii++) {
            FeatureTypeType feature = new FeatureTypeType();
            QName qName;
            if (ii == 0) {
                qName = new QName("SampleFeature" + ii);
            } else {
                qName = new QName("http://example.com", "SampleFeature" + ii, "Prefix" + ii);
            }
            sampleFeatures.add(qName);
            feature.setName(qName);
            // feature.setName(SAMPLE_FEATURE[ii]);
            if (null != srsName) {
                feature.setSRS(srsName);
            }
            mockCapabilites.getFeatureTypeList().getFeatureType().add(feature);
        }
    }
    // GetFeature Response
    when(mockWfs.getFeature(any(GetFeatureType.class))).thenReturn(mockFeatureCollection);
    when(mockFeatureCollection.getFeatureMembers()).thenAnswer(new Answer<List<Metacard>>() {

        @Override
        public List<Metacard> answer(InvocationOnMock invocation) {
            // Create as many metacards as there are features
            Integer resultsToReturn = numResults;
            if (resultsToReturn == null && numFeatures != null) {
                resultsToReturn = numFeatures;
            }
            List<Metacard> metacards = new ArrayList<Metacard>(resultsToReturn);
            for (int i = 0; i < resultsToReturn; i++) {
                MetacardImpl mc = new MetacardImpl();
                mc.setId("ID_" + String.valueOf(i + 1));
                metacards.add(mc);
            }
            return metacards;
        }
    });
    when(mockAvailabilityTask.isAvailable()).thenReturn(true);
    source = new WfsSource(new GeotoolsFilterAdapterImpl(), mockContext, mockAvailabilityTask, mockFactory, encryptionService);
}
Also used : SecureCxfClientFactory(org.codice.ddf.cxf.SecureCxfClientFactory) SpatialCapabilitiesType(ogc.schema.opengis.filter_capabilities.v_1_0_0.SpatialCapabilitiesType) FilterCapabilities(ogc.schema.opengis.filter_capabilities.v_1_0_0.FilterCapabilities) SpatialOperatorsType(ogc.schema.opengis.filter_capabilities.v_1_0_0.SpatialOperatorsType) List(java.util.List) ArrayList(java.util.ArrayList) GetFeatureType(ogc.schema.opengis.wfs.v_1_0_0.GetFeatureType) GetCapabilitiesRequest(org.codice.ddf.spatial.ogc.wfs.v1_0_0.catalog.common.GetCapabilitiesRequest) FeatureTypeType(ogc.schema.opengis.wfs_capabilities.v_1_0_0.FeatureTypeType) FeatureTypeListType(ogc.schema.opengis.wfs_capabilities.v_1_0_0.FeatureTypeListType) QName(javax.xml.namespace.QName) StreamSource(javax.xml.transform.stream.StreamSource) XmlSchemaCollection(org.apache.ws.commons.schema.XmlSchemaCollection) MetacardImpl(ddf.catalog.data.impl.MetacardImpl) BigInteger(java.math.BigInteger) Metacard(ddf.catalog.data.Metacard) XmlSchema(org.apache.ws.commons.schema.XmlSchema) ByteArrayInputStream(java.io.ByteArrayInputStream) InvocationOnMock(org.mockito.invocation.InvocationOnMock) DescribeFeatureTypeRequest(org.codice.ddf.spatial.ogc.wfs.v1_0_0.catalog.common.DescribeFeatureTypeRequest) GeotoolsFilterAdapterImpl(ddf.catalog.filter.proxy.adapter.GeotoolsFilterAdapterImpl)

Example 25 with FilterCapabilities

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

the class TestCswCqlFilter method getMockFilterCapabilities.

private static FilterCapabilities getMockFilterCapabilities() {
    FilterCapabilities mockFilterCapabilities = mock(FilterCapabilities.class);
    ComparisonOperatorsType mockComparisonOps = mock(ComparisonOperatorsType.class);
    when(mockComparisonOps.getComparisonOperator()).thenReturn(getFullComparisonOpsList());
    SpatialOperatorsType mockSpatialOperatorsType = mock(SpatialOperatorsType.class);
    when(mockSpatialOperatorsType.getSpatialOperator()).thenReturn(getSpatialOperatorsList());
    SpatialCapabilitiesType mockSpatialCapabilities = getAllSpatialCapabilities();
    when(mockSpatialCapabilities.getSpatialOperators()).thenReturn(mockSpatialOperatorsType);
    ScalarCapabilitiesType mockScalarCapabilities = mock(ScalarCapabilitiesType.class);
    when(mockScalarCapabilities.getComparisonOperators()).thenReturn(mockComparisonOps);
    when(mockFilterCapabilities.getScalarCapabilities()).thenReturn(mockScalarCapabilities);
    when(mockFilterCapabilities.getSpatialCapabilities()).thenReturn(mockSpatialCapabilities);
    when(mockScalarCapabilities.getLogicalOperators()).thenReturn(mock(LogicalOperators.class));
    return mockFilterCapabilities;
}
Also used : FilterCapabilities(net.opengis.filter.v_1_1_0.FilterCapabilities) ComparisonOperatorsType(net.opengis.filter.v_1_1_0.ComparisonOperatorsType) ScalarCapabilitiesType(net.opengis.filter.v_1_1_0.ScalarCapabilitiesType) SpatialOperatorsType(net.opengis.filter.v_1_1_0.SpatialOperatorsType) LogicalOperators(net.opengis.filter.v_1_1_0.LogicalOperators) SpatialCapabilitiesType(net.opengis.filter.v_1_1_0.SpatialCapabilitiesType)

Aggregations

FilterCapabilities (net.opengis.filter.v_2_0_0.FilterCapabilities)17 ArrayList (java.util.ArrayList)15 Test (org.junit.Test)12 ScalarCapabilitiesType (net.opengis.filter.v_1_1_0.ScalarCapabilitiesType)7 FilterType (net.opengis.filter.v_2_0_0.FilterType)7 ComparisonOperatorsType (net.opengis.filter.v_1_1_0.ComparisonOperatorsType)6 FilterCapabilities (net.opengis.filter.v_1_1_0.FilterCapabilities)6 SpatialCapabilitiesType (net.opengis.filter.v_1_1_0.SpatialCapabilitiesType)6 SpatialOperatorType (net.opengis.filter.v_2_0_0.SpatialOperatorType)6 LogicalOperators (net.opengis.filter.v_1_1_0.LogicalOperators)5 FeatureAttributeDescriptor (org.codice.ddf.spatial.ogc.wfs.catalog.common.FeatureAttributeDescriptor)5 QName (javax.xml.namespace.QName)4 SpatialOperatorsType (net.opengis.filter.v_1_1_0.SpatialOperatorsType)4 Date (java.util.Date)3 ComparisonOperatorType (net.opengis.filter.v_1_1_0.ComparisonOperatorType)3 SpatialOperatorType (net.opengis.filter.v_1_1_0.SpatialOperatorType)3 BinarySpatialOpType (net.opengis.filter.v_2_0_0.BinarySpatialOpType)3 BinaryTemporalOpType (net.opengis.filter.v_2_0_0.BinaryTemporalOpType)3 ConformanceType (net.opengis.filter.v_2_0_0.ConformanceType)3 GeometryOperand (net.opengis.filter.v_2_0_0.GeometryOperandsType.GeometryOperand)3