Search in sources :

Example 1 with Filter

use of org.n52.shetland.ogc.filter.Filter in project arctic-sea by 52North.

the class SimpleBinding method getServiceOperator.

protected ServiceOperator getServiceOperator(OwsServiceRequest request) throws OwsExceptionReport {
    checkServiceOperatorKeyTypes(request);
    String service = request.getService();
    String version = request.getVersion();
    if (request instanceof GetCapabilitiesRequest) {
        GetCapabilitiesRequest gcr = (GetCapabilitiesRequest) request;
        if (gcr.isSetAcceptVersions()) {
            return gcr.getAcceptVersions().stream().map(v -> new OwsServiceKey(service, v)).map(this::getServiceOperator).filter(Objects::nonNull).findFirst().orElseThrow(() -> new InvalidServiceOrVersionException(service, version));
        } else {
            Set<String> supportedVersions = serviceOperatorRepository.getSupportedVersions(service);
            String newest = supportedVersions.stream().max(Comparables.version()).orElseThrow(() -> new InvalidServiceParameterException(service));
            return getServiceOperator(new OwsServiceKey(service, newest));
        }
    } else {
        return getServiceOperator(new OwsServiceKey(service, version));
    }
}
Also used : GetCapabilitiesRequest(org.n52.shetland.ogc.ows.service.GetCapabilitiesRequest) InvalidServiceParameterException(org.n52.iceland.exception.ows.concrete.InvalidServiceParameterException) OwsServiceKey(org.n52.shetland.ogc.ows.service.OwsServiceKey) Objects(java.util.Objects) InvalidServiceOrVersionException(org.n52.iceland.exception.ows.concrete.InvalidServiceOrVersionException)

Example 2 with Filter

use of org.n52.shetland.ogc.filter.Filter in project arctic-sea by 52North.

the class AbstractOperationHandler method getRequestMethodsForServiceURL.

private Stream<OwsRequestMethod> getRequestMethodsForServiceURL(OwsOperationKey operation) {
    Map<String, Set<OwsValue>> mediaTypesByMethod = new HashMap<>(HTTPMethods.METHODS.size());
    this.bindingRepository.getBindings().values().stream().forEach(binding -> HTTPMethods.METHODS.stream().filter(isMethodSupported(binding, operation)).forEach(method -> mediaTypesByMethod.computeIfAbsent(method, Functions.forSupplier(HashSet::new)).addAll(getMediaTypes(binding))));
    return mediaTypesByMethod.entrySet().stream().map(e -> new OwsRequestMethod(this.serviceURL, e.getKey(), createContentTypeDomains(e.getValue())));
}
Also used : Binding(org.n52.iceland.binding.Binding) HTTPException(org.n52.iceland.exception.HTTPException) ConfigurationError(org.n52.faroe.ConfigurationError) HashMap(java.util.HashMap) OwsDCP(org.n52.shetland.ogc.ows.OwsDCP) MediaType(org.n52.janmayen.http.MediaType) I18NSettings(org.n52.iceland.i18n.I18NSettings) OwsAllowedValues(org.n52.shetland.ogc.ows.OwsAllowedValues) HashSet(java.util.HashSet) Inject(javax.inject.Inject) BindingRepository(org.n52.iceland.binding.BindingRepository) Locale(java.util.Locale) Map(java.util.Map) Validation(org.n52.faroe.Validation) URI(java.net.URI) OwsRequestMethod(org.n52.shetland.ogc.ows.OwsRequestMethod) Functions(org.n52.janmayen.function.Functions) OwsValue(org.n52.shetland.ogc.ows.OwsValue) Collectors.toSet(java.util.stream.Collectors.toSet) MediaTypeBindingKey(org.n52.iceland.binding.MediaTypeBindingKey) OwsOperationKey(org.n52.shetland.ogc.ows.service.OwsOperationKey) Predicate(java.util.function.Predicate) Set(java.util.Set) Setting(org.n52.faroe.annotation.Setting) LocaleHelper(org.n52.janmayen.i18n.LocaleHelper) OwsMetadata(org.n52.shetland.ogc.ows.OwsMetadata) HTTPMethods(org.n52.janmayen.http.HTTPMethods) OwsExceptionReport(org.n52.shetland.ogc.ows.exception.OwsExceptionReport) OwsServiceRequest(org.n52.shetland.ogc.ows.service.OwsServiceRequest) Objects(java.util.Objects) Stream(java.util.stream.Stream) OwsHttp(org.n52.shetland.ogc.ows.OwsHttp) HTTPHeaders(org.n52.janmayen.http.HTTPHeaders) Optional(java.util.Optional) Configurable(org.n52.faroe.annotation.Configurable) PathBindingKey(org.n52.iceland.binding.PathBindingKey) ServiceSettings(org.n52.iceland.service.ServiceSettings) OwsOperation(org.n52.shetland.ogc.ows.OwsOperation) Collections(java.util.Collections) OwsDomain(org.n52.shetland.ogc.ows.OwsDomain) HashSet(java.util.HashSet) Collectors.toSet(java.util.stream.Collectors.toSet) Set(java.util.Set) HashMap(java.util.HashMap) OwsRequestMethod(org.n52.shetland.ogc.ows.OwsRequestMethod) HashSet(java.util.HashSet)

Example 3 with Filter

use of org.n52.shetland.ogc.filter.Filter in project arctic-sea by 52North.

the class ODataFesParserTest method testFeatureOfInterestGeoIntersectsPolygon.

@Test
public void testFeatureOfInterestGeoIntersectsPolygon() throws Exception {
    Filter<?> filter = parser.decode(String.format("geo.intersects(featureOfInterest,'SRID=%s;%s')", polygon.getSRID(), wktGeometry));
    assertThat(filter, is(instanceOf(SpatialFilter.class)));
    SpatialFilter sf = (SpatialFilter) filter;
    errors.checkThat(sf.getSrid(), is(4326));
    errors.checkThat(sf.getGeometry().isEnvelope(), is(false));
    errors.checkThat(sf.getGeometry().isGeometry(), is(true));
    errors.checkThat(sf.getGeometry().getGeometry().get(), is(instanceOf(Polygon.class)));
    errors.checkThat(sf.getValueReference(), is("om:featureOfInterest/*/sams:shape"));
}
Also used : SpatialFilter(org.n52.shetland.ogc.filter.SpatialFilter) Test(org.junit.Test)

Example 4 with Filter

use of org.n52.shetland.ogc.filter.Filter in project arctic-sea by 52North.

the class ODataFesParserTest method testEndswith.

@Test
public void testEndswith() throws DecodingException {
    Filter<?> filter = parser.decode("endswith(textValue,'asdf')");
    assertThat(filter, is(instanceOf(ComparisonFilter.class)));
    ComparisonFilter cf = (ComparisonFilter) filter;
    errors.checkThat(cf.getOperator(), is(ComparisonOperator.PropertyIsLike));
    errors.checkThat(cf.getValue(), is("%asdf"));
    errors.checkThat(cf.getValueReference(), is("om:result"));
}
Also used : ComparisonFilter(org.n52.shetland.ogc.filter.ComparisonFilter) Test(org.junit.Test)

Example 5 with Filter

use of org.n52.shetland.ogc.filter.Filter in project arctic-sea by 52North.

the class ODataFesParserTest method testStartswith.

@Test
public void testStartswith() throws DecodingException {
    Filter<?> filter = parser.decode("startswith(textValue,'asdf')");
    assertThat(filter, is(instanceOf(ComparisonFilter.class)));
    ComparisonFilter cf = (ComparisonFilter) filter;
    errors.checkThat(cf.getOperator(), is(ComparisonOperator.PropertyIsLike));
    errors.checkThat(cf.getValue(), is("asdf%"));
    errors.checkThat(cf.getValueReference(), is("om:result"));
}
Also used : ComparisonFilter(org.n52.shetland.ogc.filter.ComparisonFilter) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)10 SpatialFilter (org.n52.shetland.ogc.filter.SpatialFilter)10 XmlObject (org.apache.xmlbeans.XmlObject)9 ComparisonFilter (org.n52.shetland.ogc.filter.ComparisonFilter)9 XmlException (org.apache.xmlbeans.XmlException)6 DecodingException (org.n52.svalbard.decode.exception.DecodingException)6 URI (java.net.URI)3 Objects (java.util.Objects)3 Set (java.util.Set)3 BinaryTemporalOpType (net.opengis.fes.x20.BinaryTemporalOpType)3 XmlCursor (org.apache.xmlbeans.XmlCursor)3 LocalizedString (org.n52.janmayen.i18n.LocalizedString)3 MultilingualString (org.n52.janmayen.i18n.MultilingualString)3 TimeOperator (org.n52.shetland.ogc.filter.FilterConstants.TimeOperator)3 TimePeriod (org.n52.shetland.ogc.gml.time.TimePeriod)3 OwsDomain (org.n52.shetland.ogc.ows.OwsDomain)3 OwsLanguageString (org.n52.shetland.ogc.ows.OwsLanguageString)3 OwsMetadata (org.n52.shetland.ogc.ows.OwsMetadata)3 Strings (com.google.common.base.Strings)2 Arrays (java.util.Arrays)2