Search in sources :

Example 1 with ServiceIdentification

use of net.opengis.ows.x11.ServiceIdentificationDocument.ServiceIdentification 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 2 with ServiceIdentification

use of net.opengis.ows.x11.ServiceIdentificationDocument.ServiceIdentification 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 3 with ServiceIdentification

use of net.opengis.ows.x11.ServiceIdentificationDocument.ServiceIdentification 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

ServiceIdentification (net.opengis.ows.x11.ServiceIdentificationDocument.ServiceIdentification)3 OwsServiceIdentification (org.n52.shetland.ogc.ows.OwsServiceIdentification)3 XmlObject (org.apache.xmlbeans.XmlObject)2 Test (org.junit.Test)2 OwsCode (org.n52.shetland.ogc.ows.OwsCode)2 CodeType (net.opengis.ows.x11.CodeType)1 OwsKeyword (org.n52.shetland.ogc.ows.OwsKeyword)1