use of net.opengis.filter.v_2_0_0.FilterCapabilities 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);
}
use of net.opengis.filter.v_2_0_0.FilterCapabilities in project ddf by codice.
the class WfsFilterDelegate method updateAllowedOperations.
private final void updateAllowedOperations(FilterCapabilities filterCapabilities) {
comparisonOps = Collections.newSetFromMap(new ConcurrentHashMap<COMPARISON_OPERATORS, Boolean>(new EnumMap<COMPARISON_OPERATORS, Boolean>(COMPARISON_OPERATORS.class)));
geometryOperands = new ArrayList<QName>();
temporalOperands = new ArrayList<QName>();
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.valueOf(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);
}
}
}
use of net.opengis.filter.v_2_0_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_2_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 net.opengis.filter.v_2_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;
}
Aggregations