use of net.opengis.filter.v_1_1_0.FilterCapabilities in project ddf by codice.
the class CswEndpoint method buildFilterCapabilities.
/**
* Creates the Filter_Capabilities section of the GetCapabilities response. These are defined
* statically by the DDF FilterAdapter implementation TODO: If the implementation changes,
* update this method to reflect the changes.
*
* @return The constructed FilterCapabilities object
*/
private FilterCapabilities buildFilterCapabilities() {
// Create the FilterCapabilites - These are defined statically by the
// DDF FilterAdapter implementation
FilterCapabilities filterCapabilities = new FilterCapabilities();
ScalarCapabilitiesType scalarCapabilities = new ScalarCapabilitiesType();
ComparisonOperatorsType cot = new ComparisonOperatorsType();
cot.setComparisonOperator(COMPARISON_OPERATORS);
scalarCapabilities.setLogicalOperators(new LogicalOperators());
scalarCapabilities.setComparisonOperators(cot);
filterCapabilities.setScalarCapabilities(scalarCapabilities);
SpatialOperatorsType spatialOpsType = new SpatialOperatorsType();
ArrayList<SpatialOperatorType> spatialOpTypes = new ArrayList<>();
for (SpatialOperatorNameType sont : SPATIAL_OPERATORS) {
SpatialOperatorType sot = new SpatialOperatorType();
sot.setName(sont);
spatialOpTypes.add(sot);
}
GeometryOperandsType geometryOperands = new GeometryOperandsType();
List<QName> geoOperandsList = geometryOperands.getGeometryOperand();
geoOperandsList.add(new QName(CswConstants.GML_SCHEMA, CswConstants.GML_POINT, CswConstants.GML_NAMESPACE_PREFIX));
geoOperandsList.add(new QName(CswConstants.GML_SCHEMA, CswConstants.GML_LINESTRING, CswConstants.GML_NAMESPACE_PREFIX));
geoOperandsList.add(new QName(CswConstants.GML_SCHEMA, CswConstants.GML_POLYGON, CswConstants.GML_NAMESPACE_PREFIX));
spatialOpsType.setSpatialOperator(spatialOpTypes);
SpatialCapabilitiesType spatialCaps = new SpatialCapabilitiesType();
spatialCaps.setSpatialOperators(spatialOpsType);
spatialCaps.setGeometryOperands(geometryOperands);
filterCapabilities.setSpatialCapabilities(spatialCaps);
IdCapabilitiesType idCapabilities = new IdCapabilitiesType();
idCapabilities.getEIDOrFID().add(new EID());
filterCapabilities.setIdCapabilities(idCapabilities);
return filterCapabilities;
}
use of net.opengis.filter.v_1_1_0.FilterCapabilities in project ddf by codice.
the class TestWfsSource method testSortingAscendingSortingNotSupported.
/**
* Verify that the SortBy is NOT set. In this case, sorting is not supported in the capabilities.
*/
@Test
public void testSortingAscendingSortingNotSupported() throws Exception {
// Setup
final String searchPhrase = "*";
final String mockTemporalFeatureProperty = "myTemporalFeatureProperty";
final String mockFeatureType = "{http://example.com}" + SAMPLE_FEATURE_NAME + 0;
final int pageSize = 1;
// Set ImplementsSorting to FALSE (sorting not supported)
FilterCapabilities mockCapabilitiesSortingNotSupported = MockWfsServer.getFilterCapabilities();
ConformanceType conformance = mockCapabilitiesSortingNotSupported.getConformance();
List<DomainType> domainTypes = conformance.getConstraint();
for (DomainType domainType : domainTypes) {
if (StringUtils.equals(domainType.getName(), "ImplementsSorting")) {
ValueType valueType = new ValueType();
valueType.setValue("FALSE");
domainType.setDefaultValue(valueType);
break;
}
}
WfsSource source = getWfsSource(ONE_TEXT_PROPERTY_SCHEMA, mockCapabilitiesSortingNotSupported, GeospatialUtil.EPSG_4326_URN, 1, false, false, 0);
MetacardMapper mockMetacardMapper = mock(MetacardMapper.class);
when(mockMetacardMapper.getFeatureType()).thenReturn(mockFeatureType);
when(mockMetacardMapper.getSortByTemporalFeatureProperty()).thenReturn(mockTemporalFeatureProperty);
List<MetacardMapper> mappers = new ArrayList<MetacardMapper>(1);
mappers.add(mockMetacardMapper);
source.setMetacardToFeatureMapper(mappers);
QueryImpl query = new QueryImpl(builder.attribute(Metacard.ANY_TEXT).is().like().text(searchPhrase));
query.setPageSize(pageSize);
SortBy sortBy = new SortByImpl(Result.TEMPORAL, SortOrder.ASCENDING);
query.setSortBy(sortBy);
// Perform Test
GetFeatureType featureType = source.buildGetFeatureRequest(query);
// Verify
QueryType queryType = (QueryType) featureType.getAbstractQueryExpression().get(0).getValue();
assertFalse(queryType.isSetAbstractSortingClause());
}
use of net.opengis.filter.v_1_1_0.FilterCapabilities in project ddf by codice.
the class TestWfsFilterDelegate method testIntersectsLonLat.
@Test
public void testIntersectsLonLat() throws SAXException, IOException, JAXBException {
List<String> gmlProps = new ArrayList<>();
gmlProps.add(MOCK_GEOM);
when(mockFeatureMetacardType.getGmlProperties()).thenReturn(gmlProps);
when(mockFeatureMetacardType.getAttributeDescriptor(MOCK_GEOM)).thenReturn(new FeatureAttributeDescriptor(MOCK_GEOM, MOCK_GEOM, true, false, false, false, BasicTypes.STRING_TYPE));
SpatialOperatorType operator = new SpatialOperatorType();
operator.setName(SPATIAL_OPERATORS.Intersects.toString());
FilterCapabilities capabilities = MockWfsServer.getFilterCapabilities();
capabilities.getSpatialCapabilities().getSpatialOperators().getSpatialOperator().clear();
capabilities.getSpatialCapabilities().getSpatialOperators().getSpatialOperator().add(operator);
WfsFilterDelegate delegate = new WfsFilterDelegate(mockFeatureMetacardType, capabilities, GeospatialUtil.EPSG_4326_URN, null, GeospatialUtil.LON_LAT_ORDER);
FilterType filter = delegate.intersects(Metacard.ANY_GEO, POLYGON);
assertTrue(filter.getSpatialOps().getValue() instanceof BinarySpatialOpType);
assertFalse(filter.isSetLogicOps());
assertXMLEqual(MockWfsServer.getIntersectsLonLatXmlFilter(), getXmlFromMarshaller(filter));
}
use of net.opengis.filter.v_1_1_0.FilterCapabilities in project ddf by codice.
the class TestWfsFilterDelegate method testAbsoluteTemporalOnlyQueryDuringSupported.
/**
* If the WFS server does not support an 'After' and 'Before' temporal query,
* and supports a 'During' temporal query, the query should be translated
* into 'During <after> to <before>'
*/
@Test
public void testAbsoluteTemporalOnlyQueryDuringSupported() {
setupMockMetacardType();
FilterType afterFilter = setupAfterFilterType();
FilterType beforeFilter = setupBeforeFilterType();
FilterCapabilities duringFilterCapabilities = setupFilterCapabilities();
WfsFilterDelegate duringDelegate = new WfsFilterDelegate(mockFeatureMetacardType, duringFilterCapabilities, GeospatialUtil.EPSG_4326_URN, mockMapper, GeospatialUtil.LAT_LON_ORDER);
// Get After Filter Date
BinaryTemporalOpType binaryTemporalOpType = (BinaryTemporalOpType) afterFilter.getTemporalOps().getValue();
assertThat(binaryTemporalOpType.isSetValueReference(), is(true));
assertThat(binaryTemporalOpType.isSetExpression(), is(true));
TimeInstantType timePeriod = (TimeInstantType) binaryTemporalOpType.getExpression().getValue();
TimePositionType beginPositionType = timePeriod.getTimePosition();
Date afterDate = timePositionTypeToDate(beginPositionType);
// Get Before Filter Date
binaryTemporalOpType = (BinaryTemporalOpType) beforeFilter.getTemporalOps().getValue();
assertThat(binaryTemporalOpType.isSetValueReference(), is(true));
assertThat(binaryTemporalOpType.isSetExpression(), is(true));
timePeriod = (TimeInstantType) binaryTemporalOpType.getExpression().getValue();
TimePositionType endPositionType = timePeriod.getTimePosition();
Date beforeDate = timePositionTypeToDate(endPositionType);
List<FilterType> testFilters = new ArrayList<>();
testFilters.add(afterFilter);
testFilters.add(beforeFilter);
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) duringFilter.getTemporalOps().getValue();
assertThat(binaryTemporalOpType.isSetValueReference(), is(true));
assertThat(binaryTemporalOpType.isSetExpression(), is(true));
TimePeriodType timePeriodType = (TimePeriodType) binaryTemporalOpType.getExpression().getValue();
beginPositionType = timePeriodType.getBeginPosition();
Date beginDate = timePositionTypeToDate(beginPositionType);
endPositionType = timePeriodType.getEndPosition();
Date endDate = timePositionTypeToDate(endPositionType);
// Verify Date range is created correctly
assertThat(endDate.after(beginDate), is(true));
assertThat(endDate.equals(beforeDate), is(true));
assertThat(beginDate.equals(afterDate), is(true));
}
use of net.opengis.filter.v_1_1_0.FilterCapabilities in project ddf by codice.
the class TestWfsFilterDelegate method testIntersectsWithEnvelopeLonLat.
@Test
public void testIntersectsWithEnvelopeLonLat() throws SAXException, IOException, JAXBException {
List<String> gmlProps = new ArrayList<>();
gmlProps.add(MOCK_GEOM);
when(mockFeatureMetacardType.getGmlProperties()).thenReturn(gmlProps);
when(mockFeatureMetacardType.getAttributeDescriptor(MOCK_GEOM)).thenReturn(new FeatureAttributeDescriptor(MOCK_GEOM, MOCK_GEOM, true, false, false, false, BasicTypes.STRING_TYPE));
SpatialOperatorType operator = new SpatialOperatorType();
operator.setName(SPATIAL_OPERATORS.Intersects.toString());
FilterCapabilities capabilities = MockWfsServer.getFilterCapabilities();
capabilities.getSpatialCapabilities().getSpatialOperators().getSpatialOperator().clear();
capabilities.getSpatialCapabilities().getSpatialOperators().getSpatialOperator().add(operator);
capabilities.getSpatialCapabilities().getGeometryOperands().getGeometryOperand().clear();
GeometryOperand geoOperand = new GeometryOperand();
geoOperand.setName(Wfs20Constants.ENVELOPE);
capabilities.getSpatialCapabilities().getGeometryOperands().getGeometryOperand().add(geoOperand);
WfsFilterDelegate delegate = new WfsFilterDelegate(mockFeatureMetacardType, capabilities, GeospatialUtil.EPSG_4326_URN, null, GeospatialUtil.LON_LAT_ORDER);
FilterType filter = delegate.intersects(Metacard.ANY_GEO, POLYGON);
assertTrue(filter.getSpatialOps().getValue() instanceof BinarySpatialOpType);
assertFalse(filter.isSetLogicOps());
assertXMLEqual(MockWfsServer.getIntersectsWithEnvelopeLonLatXmlFilter(), getXmlFromMarshaller(filter));
}
Aggregations