Search in sources :

Example 1 with OwsCode

use of org.n52.shetland.ogc.ows.OwsCode 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 OwsCode

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

the class AbstractCapabilitiesBaseTypeDecoder method parseResponsibleParty.

private OwsResponsibleParty parseResponsibleParty(ResponsiblePartySubsetType responsibleParty) {
    if (responsibleParty == null) {
        return null;
    }
    String positionName = responsibleParty.getPositionName();
    String individualName = responsibleParty.getIndividualName();
    String organisationName = null;
    OwsContact contactInfo = parseContact(responsibleParty.getContactInfo());
    OwsCode role = parseCode(responsibleParty.getRole());
    return new OwsResponsibleParty(individualName, organisationName, positionName, contactInfo, role);
}
Also used : OwsResponsibleParty(org.n52.shetland.ogc.ows.OwsResponsibleParty) OwsContact(org.n52.shetland.ogc.ows.OwsContact) 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)

Example 3 with OwsCode

use of org.n52.shetland.ogc.ows.OwsCode 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 4 with OwsCode

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

the class OwsServiceProviderFactory method create.

@Override
protected OwsServiceProvider create(Locale language) throws ConfigurationError {
    // TODO organisation name is missing
    String organisationName = null;
    OwsOnlineResource onlineResource = null;
    if (site != null) {
        onlineResource = new OwsOnlineResource(site);
    }
    OwsCode roleCode = null;
    if (role != null) {
        roleCode = new OwsCode(role, roleCodespace);
    }
    OwsOnlineResource providerSite = null;
    if (onlineResoureHref != null) {
        providerSite = new OwsOnlineResource(onlineResoureHref, onlineResoureTitle);
    }
    OwsAddress address = null;
    if (anyNonNull(deliveryPoint, city, administrativeArea, postalCode, country, electronicMailAddress)) {
        address = new OwsAddress(deliveryPoint, city, administrativeArea, postalCode, country, electronicMailAddress);
    }
    OwsPhone owsPhone = null;
    if (anyNonNull(phone, facsimile)) {
        owsPhone = new OwsPhone(phone, facsimile);
    }
    OwsContact contactInfo = null;
    if (anyNonNull(owsPhone, address, onlineResource, hoursOfService, contactInstructions)) {
        contactInfo = new OwsContact(owsPhone, address, onlineResource, hoursOfService, contactInstructions);
    }
    OwsResponsibleParty serviceContact = new OwsResponsibleParty(individualName, organisationName, positionName, contactInfo, roleCode);
    return new OwsServiceProvider(name, providerSite, serviceContact);
}
Also used : OwsOnlineResource(org.n52.shetland.ogc.ows.OwsOnlineResource) OwsResponsibleParty(org.n52.shetland.ogc.ows.OwsResponsibleParty) OwsContact(org.n52.shetland.ogc.ows.OwsContact) OwsServiceProvider(org.n52.shetland.ogc.ows.OwsServiceProvider) OwsCode(org.n52.shetland.ogc.ows.OwsCode) OwsAddress(org.n52.shetland.ogc.ows.OwsAddress) OwsPhone(org.n52.shetland.ogc.ows.OwsPhone)

Example 5 with OwsCode

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

the class OwsEncoderv110Test method should_encode_service_identification_with_service_type_codespace.

@Test
public void should_encode_service_identification_with_service_type_codespace() throws EncodingException {
    String serviceTypeValue = "serviceType";
    String serviceTypeCodeSpaceValue = "codeSpace";
    OwsServiceIdentification serviceId = new OwsServiceIdentification(new OwsCode(serviceTypeValue, URI.create(serviceTypeCodeSpaceValue)), 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(), equalTo(serviceTypeCodeSpaceValue));
}
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)

Aggregations

OwsCode (org.n52.shetland.ogc.ows.OwsCode)5 OwsServiceIdentification (org.n52.shetland.ogc.ows.OwsServiceIdentification)3 ServiceIdentification (net.opengis.ows.x11.ServiceIdentificationDocument.ServiceIdentification)2 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 OwsContact (org.n52.shetland.ogc.ows.OwsContact)2 OwsLanguageString (org.n52.shetland.ogc.ows.OwsLanguageString)2 OwsResponsibleParty (org.n52.shetland.ogc.ows.OwsResponsibleParty)2 URI (java.net.URI)1 Arrays (java.util.Arrays)1 Collections (java.util.Collections)1 Stream (java.util.stream.Stream)1 OwsAddress (org.n52.shetland.ogc.ows.OwsAddress)1 OwsKeyword (org.n52.shetland.ogc.ows.OwsKeyword)1 OwsOnlineResource (org.n52.shetland.ogc.ows.OwsOnlineResource)1 OwsPhone (org.n52.shetland.ogc.ows.OwsPhone)1 OwsServiceProvider (org.n52.shetland.ogc.ows.OwsServiceProvider)1