use of org.n52.shetland.w3c.xlink.Type in project arctic-sea by 52North.
the class OmEncoderv20Test method shouldThrowExceptionWhenReceivedInvalidObservationTypeInObservationTemplate.
@Test
public void shouldThrowExceptionWhenReceivedInvalidObservationTypeInObservationTemplate() throws EncodingException {
thrown.expect(UnsupportedEncoderInputException.class);
thrown.expectMessage(Is.is("Encoder " + OmEncoderv20.class.getSimpleName() + " can not encode 'missing type in OM_Observation'"));
omEncoderv20.encode(new OmObservationConstellation());
}
use of org.n52.shetland.w3c.xlink.Type in project arctic-sea by 52North.
the class Iso19139GmdEncoder method encodePhone.
private void encodePhone(CITelephonePropertyType citpt, Referenceable<CiTelephone> referenceable) {
if (referenceable.isReference()) {
Reference reference = referenceable.getReference();
reference.getActuate().map(Actuate::toString).map(ActuateType.Enum::forString).ifPresent(citpt::setActuate);
reference.getArcrole().ifPresent(citpt::setArcrole);
reference.getHref().map(URI::toString).ifPresent(citpt::setHref);
reference.getRole().ifPresent(citpt::setRole);
reference.getShow().map(Show::toString).map(ShowType.Enum::forString).ifPresent(citpt::setShow);
reference.getTitle().ifPresent(citpt::setTitle);
reference.getType().map(Type::toString).map(TypeType.Enum::forString).ifPresent(citpt::setType);
} else {
if (referenceable.isInstance()) {
Nillable<CiTelephone> nillable = referenceable.getInstance();
if (nillable.isPresent()) {
CiTelephone ciTelephone = referenceable.getInstance().get();
CITelephoneType citt = citpt.addNewCITelephone();
if (ciTelephone.isSetVoice()) {
citt.setVoiceArray(listToCharacterStringPropertyTypeArray(ciTelephone.getVoice()));
}
if (ciTelephone.isSetFacsimile()) {
citt.setFacsimileArray(listToCharacterStringPropertyTypeArray(ciTelephone.getFacsimile()));
}
if (ciTelephone.isSetId()) {
citt.setId(ciTelephone.getId());
}
if (ciTelephone.isSetUuid()) {
citt.setUuid(ciTelephone.getUuid());
}
} else {
if (nillable.hasReason()) {
citpt.setNilReason(nillable.getNilReason().get());
}
}
}
}
}
use of org.n52.shetland.w3c.xlink.Type in project arctic-sea by 52North.
the class Iso19139GmdEncoder method encodeContact.
private void encodeContact(CIContactPropertyType cicpt, Referenceable<CiContact> referenceable) {
if (referenceable.isReference()) {
Reference reference = referenceable.getReference();
reference.getActuate().map(Actuate::toString).map(ActuateType.Enum::forString).ifPresent(cicpt::setActuate);
reference.getArcrole().ifPresent(cicpt::setArcrole);
reference.getHref().map(URI::toString).ifPresent(cicpt::setHref);
reference.getRole().ifPresent(cicpt::setRole);
reference.getShow().map(Show::toString).map(ShowType.Enum::forString).ifPresent(cicpt::setShow);
reference.getTitle().ifPresent(cicpt::setTitle);
reference.getType().map(Type::toString).map(TypeType.Enum::forString).ifPresent(cicpt::setType);
} else {
if (referenceable.isInstance()) {
Nillable<CiContact> nillable = referenceable.getInstance();
if (nillable.isPresent()) {
CiContact ciContact = referenceable.getInstance().get();
CIContactType cict = cicpt.addNewCIContact();
if (ciContact.getAddress() != null) {
encodeCiAddress(cict.addNewAddress(), ciContact.getAddress());
}
if (ciContact.getContactInstructionsNillable() != null) {
if (ciContact.getContactInstructionsNillable().isPresent()) {
cict.addNewContactInstructions().setCharacterString(ciContact.getContactInstructions());
} else if (ciContact.getContactInstructionsNillable().hasReason()) {
cict.addNewContactInstructions().setNilReason(ciContact.getContactInstructionsNillable().getNilReason().get());
}
}
if (ciContact.isSetHoursOfService()) {
if (ciContact.getHoursOfServiceNillable().isPresent()) {
cict.addNewHoursOfService().setCharacterString(ciContact.getHoursOfService());
} else if (ciContact.getHoursOfServiceNillable().hasReason()) {
cict.addNewHoursOfService().setNilReason(ciContact.getHoursOfServiceNillable().getNilReason().get());
}
}
if (ciContact.getOnlineResourceReferenceable() != null) {
encodeOnlineResource(cict.addNewOnlineResource(), ciContact.getOnlineResourceReferenceable());
}
if (ciContact.isSetPhone()) {
encodePhone(cict.addNewPhone(), ciContact.getPhone());
}
} else {
if (nillable.hasReason()) {
cicpt.setNilReason(nillable.getNilReason().get());
}
}
}
}
}
use of org.n52.shetland.w3c.xlink.Type in project arctic-sea by 52North.
the class Iso19139GmdEncoder method encodeCiAddress.
private void encodeCiAddress(CIAddressPropertyType ciapt, Referenceable<CiAddress> referenceable) {
if (referenceable.isReference()) {
Reference reference = referenceable.getReference();
reference.getActuate().map(Actuate::toString).map(ActuateType.Enum::forString).ifPresent(ciapt::setActuate);
reference.getArcrole().ifPresent(ciapt::setArcrole);
reference.getHref().map(URI::toString).ifPresent(ciapt::setHref);
reference.getRole().ifPresent(ciapt::setRole);
reference.getShow().map(Show::toString).map(ShowType.Enum::forString).ifPresent(ciapt::setShow);
reference.getTitle().ifPresent(ciapt::setTitle);
reference.getType().map(Type::toString).map(TypeType.Enum::forString).ifPresent(ciapt::setType);
} else {
if (referenceable.isInstance()) {
Nillable<CiAddress> nillable = referenceable.getInstance();
if (nillable.isPresent()) {
CiAddress ciAddress = referenceable.getInstance().get();
CIAddressType ciat = ciapt.addNewCIAddress();
if (ciAddress.isSetAdministrativeArea()) {
ciat.addNewAdministrativeArea().setCharacterString(ciAddress.getAdministrativeArea());
}
if (ciAddress.isSetCity()) {
ciat.addNewCity().setCharacterString(ciAddress.getCity());
}
if (ciAddress.isSetCountry()) {
ciat.addNewCountry().setCharacterString(ciAddress.getCountry());
}
if (ciAddress.isSetPostalCode()) {
ciat.addNewPostalCode().setCharacterString(ciAddress.getPostalCode());
}
if (ciAddress.hasDeliveryPoints()) {
ciat.setDeliveryPointArray(listToCharacterStringPropertyTypeArray(ciAddress.getDeliveryPoints()));
}
if (ciAddress.hasElectronicMailAddresses()) {
ciat.setElectronicMailAddressArray(listToCharacterStringPropertyTypeArray(Lists.newArrayList(ciAddress.getElectronicMailAddresses())));
}
if (ciAddress.isSetId()) {
ciat.setId(ciAddress.getId());
}
if (ciAddress.isSetUuid()) {
ciat.setUuid(ciAddress.getUuid());
}
} else {
if (nillable.hasReason()) {
ciapt.setNilReason(nillable.getNilReason().get());
}
}
}
}
}
use of org.n52.shetland.w3c.xlink.Type in project arctic-sea by 52North.
the class SensorMLDecoderV20 method parseCharacteristics.
/**
* Parses the characteristics
*
* @param clpts
* XML characteristics
* @return SOS characteristics
*
* @throws DecodingException
* * if an error occurs
*/
private List<SmlCharacteristics> parseCharacteristics(final CharacteristicListPropertyType[] clpts) throws DecodingException {
final List<SmlCharacteristics> sosCharacteristicsList = new ArrayList<>(clpts.length);
for (final CharacteristicListPropertyType clpt : clpts) {
final SmlCharacteristics sosCharacteristics = new SmlCharacteristics();
if (clpt.isSetCharacteristicList()) {
CharacteristicListType clt = clpt.getCharacteristicList();
if (CollectionHelper.isNotNullOrEmpty(clt.getCharacteristicArray())) {
for (Characteristic c : clt.getCharacteristicArray()) {
final SmlCharacteristic characteristic = new SmlCharacteristic(c.getName());
if (c.isSetAbstractDataComponent()) {
final Object o = decodeXmlElement(c.getAbstractDataComponent());
if (o instanceof SweAbstractDataComponent) {
characteristic.setAbstractDataComponent((SweAbstractDataComponent) o);
} else {
throw new DecodingException(XmlHelper.getLocalName(clpt), "Error while parsing the characteristics of the SensorML " + "(the characteristics' data record is not of " + "type DataRecordPropertyType)!");
}
} else if (c.isSetHref()) {
characteristic.setHref(c.getHref());
if (c.isSetTitle()) {
characteristic.setTitle(c.getTitle());
}
}
sosCharacteristics.addCharacteristic(characteristic);
}
}
}
sosCharacteristicsList.add(sosCharacteristics);
}
return sosCharacteristicsList;
}
Aggregations