Search in sources :

Example 1 with OwsServiceIdentification

use of org.n52.shetland.ogc.ows.OwsServiceIdentification in project arctic-sea by 52North.

the class AbstractCapabilitiesBaseTypeDecoder method parseServiceIdentification.

private OwsServiceIdentification parseServiceIdentification(ServiceIdentification serviceIdentification) {
    if (serviceIdentification == null) {
        return null;
    }
    OwsCode serviceType = parseCode(serviceIdentification.getServiceType());
    Set<String> serviceTypeVersion = Optional.ofNullable(serviceIdentification.getServiceTypeVersionArray()).map(Arrays::stream).orElseGet(Stream::empty).collect(toSet());
    Set<String> fees = Optional.ofNullable(serviceIdentification.getFees()).map(Collections::singleton).orElseGet(Collections::emptySet);
    Set<URI> profiles = Optional.ofNullable(serviceIdentification.getProfileArray()).map(Arrays::stream).orElseGet(Stream::empty).map(URI::create).collect(toSet());
    Set<String> accessConstraints = Optional.ofNullable(serviceIdentification.getAccessConstraintsArray()).map(Arrays::stream).orElseGet(Stream::empty).collect(toSet());
    MultilingualString title = new MultilingualString();
    MultilingualString abstrakt = new MultilingualString();
    Optional.ofNullable(serviceIdentification.getTitleArray()).map(Arrays::stream).orElseGet(Stream::empty).map(this::parseLanguageString).forEach(title::addLocalization);
    Optional.ofNullable(serviceIdentification.getAbstractArray()).map(Arrays::stream).orElseGet(Stream::empty).map(this::parseLanguageString).forEach(abstrakt::addLocalization);
    Set<OwsKeyword> keywords = Optional.ofNullable(serviceIdentification.getKeywordsArray()).map(Arrays::stream).orElseGet(Stream::empty).flatMap(this::parseKeyword).filter(Objects::nonNull).collect(toSet());
    return new OwsServiceIdentification(serviceType, serviceTypeVersion, profiles, fees, accessConstraints, title, abstrakt, keywords);
}
Also used : OwsCode(org.n52.shetland.ogc.ows.OwsCode) LocalizedString(org.n52.janmayen.i18n.LocalizedString) MultilingualString(org.n52.janmayen.i18n.MultilingualString) OwsLanguageString(org.n52.shetland.ogc.ows.OwsLanguageString) OwsServiceIdentification(org.n52.shetland.ogc.ows.OwsServiceIdentification) URI(java.net.URI) OwsKeyword(org.n52.shetland.ogc.ows.OwsKeyword) Stream(java.util.stream.Stream) MultilingualString(org.n52.janmayen.i18n.MultilingualString) Arrays(java.util.Arrays) Collections(java.util.Collections)

Example 2 with OwsServiceIdentification

use of org.n52.shetland.ogc.ows.OwsServiceIdentification in project arctic-sea by 52North.

the class OwsEncoderv110Test method should_encode_service_identification_without_service_type_codespace.

@Test
public void should_encode_service_identification_without_service_type_codespace() throws EncodingException {
    String serviceTypeValue = "serviceType";
    OwsServiceIdentification serviceId = new OwsServiceIdentification(new OwsCode(serviceTypeValue), null, null, null, null, null, null, null);
    XmlObject xbEncoded = encodeObjectToXml(OWSConstants.NS_OWS, serviceId);
    assertThat(xbEncoded, instanceOf(ServiceIdentification.class));
    ServiceIdentification xbServiceId = (ServiceIdentification) xbEncoded;
    assertThat(xbServiceId.getServiceType().getStringValue(), equalTo(serviceTypeValue));
    assertThat(xbServiceId.getServiceType().getCodeSpace(), nullValue());
}
Also used : OwsCode(org.n52.shetland.ogc.ows.OwsCode) XmlObject(org.apache.xmlbeans.XmlObject) OwsServiceIdentification(org.n52.shetland.ogc.ows.OwsServiceIdentification) ServiceIdentification(net.opengis.ows.x11.ServiceIdentificationDocument.ServiceIdentification) OwsServiceIdentification(org.n52.shetland.ogc.ows.OwsServiceIdentification) Test(org.junit.Test)

Example 3 with OwsServiceIdentification

use of org.n52.shetland.ogc.ows.OwsServiceIdentification in project arctic-sea by 52North.

the class AbstractGetCapabilitiesHandler method createCapabilities.

private OwsCapabilities createCapabilities(GetCapabilitiesRequest request, String service, String version) throws OwsExceptionReport {
    Set<CapabilitiesSection> sections = getRequestedSections(request);
    Locale requestedLocale = getRequestedLocale(request);
    String updateSequence = null;
    OwsServiceIdentification serviceIdentification = null;
    if (sections.contains(CapabilitiesSection.ServiceIdentification)) {
        serviceIdentification = getServiceIdentification(service, requestedLocale);
    }
    OwsServiceProvider serviceProvider = null;
    if (sections.contains(CapabilitiesSection.ServiceProvider)) {
        serviceProvider = getServiceProvider(service, requestedLocale);
    }
    OwsOperationsMetadata operationsMetadata = null;
    if (sections.contains(CapabilitiesSection.OperationsMetadata)) {
        operationsMetadata = getOperations(service, version);
    }
    Set<String> languages = null;
    if (sections.contains(CapabilitiesSection.Languages)) {
        languages = getLanguages();
    }
    T contents = null;
    if (sections.contains(CapabilitiesSection.Contents)) {
        contents = createContents(service, version);
    }
    Collection<OwsCapabilitiesExtension> extensions = getExtensions(request, service, version);
    OwsCapabilities capabilities = new OwsCapabilities(service, version, updateSequence, serviceIdentification, serviceProvider, operationsMetadata, languages, extensions);
    return createCapabilities(capabilities, contents);
}
Also used : Locale(java.util.Locale) OwsCapabilitiesExtension(org.n52.shetland.ogc.ows.OwsCapabilitiesExtension) CapabilitiesSection(org.n52.shetland.ogc.ows.OWSConstants.CapabilitiesSection) OwsOperationsMetadata(org.n52.shetland.ogc.ows.OwsOperationsMetadata) OwsServiceProvider(org.n52.shetland.ogc.ows.OwsServiceProvider) OwsCapabilities(org.n52.shetland.ogc.ows.OwsCapabilities) OwsServiceIdentification(org.n52.shetland.ogc.ows.OwsServiceIdentification)

Example 4 with OwsServiceIdentification

use of org.n52.shetland.ogc.ows.OwsServiceIdentification in project arctic-sea by 52North.

the class OwsEncoderv110 method encodeServiceIdentification.

private XmlObject encodeServiceIdentification(OwsServiceIdentification serviceIdentification) throws EncodingException {
    ServiceIdentification serviceIdent;
    /* TODO check for required fields and fail on missing ones */
    serviceIdent = ServiceIdentification.Factory.newInstance();
    serviceIdentification.getAccessConstraints().forEach(serviceIdent::addAccessConstraints);
    if (!serviceIdentification.getFees().isEmpty()) {
        serviceIdent.setFees(serviceIdentification.getFees().iterator().next());
    }
    CodeType xbServiceType = serviceIdent.addNewServiceType();
    xbServiceType.setStringValue(serviceIdentification.getServiceType().getValue());
    if (serviceIdentification.getServiceType().getCodeSpace().isPresent()) {
        xbServiceType.setCodeSpace(serviceIdentification.getServiceType().getCodeSpace().get().toString());
    }
    encodeMultilingualString(serviceIdentification.getTitle(), serviceIdent::addNewTitle);
    encodeMultilingualString(serviceIdentification.getAbstract(), serviceIdent::addNewAbstract);
    serviceIdentification.getServiceTypeVersion().stream().forEach(serviceIdent::addServiceTypeVersion);
    serviceIdentification.getProfiles().stream().map(URI::toString).forEach(serviceIdent::addProfile);
    serviceIdentification.getKeywords().stream().collect(groupingBy(OwsKeyword::getType, mapping(OwsKeyword::getKeyword, toList()))).forEach((type, keywords) -> encodeOwsKeywords(type, keywords, serviceIdent.addNewKeywords()));
    return serviceIdent;
}
Also used : OwsKeyword(org.n52.shetland.ogc.ows.OwsKeyword) CodeType(net.opengis.ows.x11.CodeType) ServiceIdentification(net.opengis.ows.x11.ServiceIdentificationDocument.ServiceIdentification) OwsServiceIdentification(org.n52.shetland.ogc.ows.OwsServiceIdentification)

Example 5 with OwsServiceIdentification

use of org.n52.shetland.ogc.ows.OwsServiceIdentification in project arctic-sea by 52North.

the class OwsEncoderv110 method encode.

@Override
public XmlObject encode(Object element, EncodingContext additionalValues) throws EncodingException {
    if (element instanceof OwsServiceIdentification) {
        return encodeServiceIdentification((OwsServiceIdentification) element);
    } else if (element instanceof OwsServiceProvider) {
        return encodeServiceProvider((OwsServiceProvider) element);
    } else if (element instanceof OwsOperationsMetadata) {
        return encodeOperationsMetadata((OwsOperationsMetadata) element);
    } else if (element instanceof OwsExceptionReport) {
        if (isEncodeExceptionsOnly(additionalValues) && !((OwsExceptionReport) element).getExceptions().isEmpty()) {
            return encodeOwsException(((OwsExceptionReport) element).getExceptions().get(0));
        }
        return encodeOwsExceptionReport((OwsExceptionReport) element);
    } else if (element instanceof OwsMetadata) {
        MetadataType metadataType = MetadataType.Factory.newInstance(getXmlOptions());
        encodeOwsMetadata((OwsMetadata) element, metadataType);
        return metadataType;
    } else if (element instanceof OwsDomain) {
        DomainType domainType = DomainType.Factory.newInstance(getXmlOptions());
        encodeOwsDomain((OwsDomain) element, domainType);
        return domainType;
    } else if (element instanceof OwsAcceptVersions) {
        return encodeAcceptVersions((OwsAcceptVersions) element);
    } else if (element instanceof OwsSections) {
        return encodeSections((OwsSections) element);
    }
    throw new UnsupportedEncoderInputException(this, element);
}
Also used : OwsDomain(org.n52.shetland.ogc.ows.OwsDomain) DomainType(net.opengis.ows.x11.DomainType) OwsOperationsMetadata(org.n52.shetland.ogc.ows.OwsOperationsMetadata) OwsMetadata(org.n52.shetland.ogc.ows.OwsMetadata) OwsSections(org.n52.shetland.ogc.ows.OwsSections) OwsServiceProvider(org.n52.shetland.ogc.ows.OwsServiceProvider) MetadataType(net.opengis.ows.x11.MetadataType) DomainMetadataType(net.opengis.ows.x11.DomainMetadataType) OwsServiceIdentification(org.n52.shetland.ogc.ows.OwsServiceIdentification) OwsExceptionReport(org.n52.shetland.ogc.ows.exception.OwsExceptionReport) OwsAcceptVersions(org.n52.shetland.ogc.ows.OwsAcceptVersions) UnsupportedEncoderInputException(org.n52.svalbard.encode.exception.UnsupportedEncoderInputException)

Aggregations

OwsServiceIdentification (org.n52.shetland.ogc.ows.OwsServiceIdentification)7 ServiceIdentification (net.opengis.ows.x11.ServiceIdentificationDocument.ServiceIdentification)3 OwsCode (org.n52.shetland.ogc.ows.OwsCode)3 OwsOperationsMetadata (org.n52.shetland.ogc.ows.OwsOperationsMetadata)3 OwsServiceProvider (org.n52.shetland.ogc.ows.OwsServiceProvider)3 XmlObject (org.apache.xmlbeans.XmlObject)2 Test (org.junit.Test)2 LocalizedString (org.n52.janmayen.i18n.LocalizedString)2 MultilingualString (org.n52.janmayen.i18n.MultilingualString)2 OwsCapabilities (org.n52.shetland.ogc.ows.OwsCapabilities)2 OwsCapabilitiesExtension (org.n52.shetland.ogc.ows.OwsCapabilitiesExtension)2 OwsKeyword (org.n52.shetland.ogc.ows.OwsKeyword)2 OwsLanguageString (org.n52.shetland.ogc.ows.OwsLanguageString)2 URI (java.net.URI)1 Arrays (java.util.Arrays)1 Collections (java.util.Collections)1 Locale (java.util.Locale)1 Stream (java.util.stream.Stream)1 CodeType (net.opengis.ows.x11.CodeType)1 DomainMetadataType (net.opengis.ows.x11.DomainMetadataType)1