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());
}
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;
}
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));
}
Aggregations