use of ogc.schema.opengis.filter_capabilities.v_1_0_0.FilterCapabilities in project ddf by codice.
the class TestWfsFilterDelegate method testNoTemporalOps.
@Test
public void testNoTemporalOps() {
FilterCapabilities capabilities = MockWfsServer.getFilterCapabilities();
capabilities.setTemporalCapabilities(null);
WfsFilterDelegate delegate = new WfsFilterDelegate(mockFeatureMetacardType, capabilities, GeospatialUtil.EPSG_4326_URN, null, GeospatialUtil.LAT_LON_ORDER);
assertThat(delegate.isLogicalOps(), is(true));
assertThat(delegate.isEpsg4326(), is(true));
assertThat(delegate.isSortingSupported(), is(true));
assertThat(delegate.getSrsName(), is(GeospatialUtil.EPSG_4326_URN));
assertThat(delegate.getComparisonOps().size(), is(COMPARISON_OPERATORS.values().length));
assertThat(delegate.getGeometryOperands().size(), greaterThan(0));
assertThat(delegate.getSpatialOps().size(), is(SPATIAL_OPERATORS.values().length));
assertThat(delegate.getTemporalOps().size(), is(0));
assertThat(delegate.getTemporalOperands().size(), is(0));
}
use of ogc.schema.opengis.filter_capabilities.v_1_0_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));
}
use of ogc.schema.opengis.filter_capabilities.v_1_0_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);
}
use of ogc.schema.opengis.filter_capabilities.v_1_0_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;
}
use of ogc.schema.opengis.filter_capabilities.v_1_0_0.FilterCapabilities in project ddf by codice.
the class MockWfsServer method getFilterCapabilities.
public static FilterCapabilities getFilterCapabilities() {
FilterCapabilities capabilities = new FilterCapabilities();
ConformanceType conformance = new ConformanceType();
for (CONFORMANCE_CONSTRAINTS constraint : CONFORMANCE_CONSTRAINTS.values()) {
DomainType domain = new DomainType();
NoValues noValues = new NoValues();
domain.setNoValues(noValues);
ValueType value = new ValueType();
value.setValue("TRUE");
domain.setDefaultValue(value);
domain.setName(constraint.toString());
conformance.getConstraint().add(domain);
}
capabilities.setConformance(conformance);
ScalarCapabilitiesType scalar = new ScalarCapabilitiesType();
scalar.setLogicalOperators(new LogicalOperators());
scalar.setComparisonOperators(new ComparisonOperatorsType());
for (COMPARISON_OPERATORS compOp : COMPARISON_OPERATORS.values()) {
ComparisonOperatorType operator = new ComparisonOperatorType();
operator.setName(compOp.toString());
scalar.getComparisonOperators().getComparisonOperator().add(operator);
}
capabilities.setScalarCapabilities(scalar);
SpatialCapabilitiesType spatial = new SpatialCapabilitiesType();
spatial.setSpatialOperators(new SpatialOperatorsType());
for (SPATIAL_OPERATORS spatialOp : SPATIAL_OPERATORS.values()) {
SpatialOperatorType operator = new SpatialOperatorType();
operator.setName(spatialOp.toString());
spatial.getSpatialOperators().getSpatialOperator().add(operator);
}
GeometryOperandsType geometryOperands = new GeometryOperandsType();
List<QName> qnames = Arrays.asList(Wfs20Constants.POINT, Wfs20Constants.ENVELOPE, Wfs20Constants.POLYGON, Wfs20Constants.LINESTRING);
for (QName qName : qnames) {
GeometryOperand operand = new GeometryOperand();
operand.setName(qName);
geometryOperands.getGeometryOperand().add(operand);
}
spatial.setGeometryOperands(geometryOperands);
capabilities.setSpatialCapabilities(spatial);
TemporalCapabilitiesType temporal = new TemporalCapabilitiesType();
temporal.setTemporalOperators(new TemporalOperatorsType());
for (TEMPORAL_OPERATORS temporalOp : TEMPORAL_OPERATORS.values()) {
TemporalOperatorType operator = new TemporalOperatorType();
operator.setName(temporalOp.toString());
temporal.getTemporalOperators().getTemporalOperator().add(operator);
}
TemporalOperandsType temporalOperands = new TemporalOperandsType();
List<QName> timeQNames = Arrays.asList(new QName(Wfs20Constants.GML_3_2_NAMESPACE, "TimePeriod"), new QName(Wfs20Constants.GML_3_2_NAMESPACE, "TimeInstant"));
for (QName qName : timeQNames) {
TemporalOperand operand = new TemporalOperand();
operand.setName(qName);
temporalOperands.getTemporalOperand().add(operand);
}
temporal.setTemporalOperands(temporalOperands);
capabilities.setTemporalCapabilities(temporal);
return capabilities;
}
Aggregations