use of org.n52.shetland.w3c.Nillable in project arctic-sea by 52North.
the class AbstractWmlEncoderv20 method addVerticalDatum.
private void addVerticalDatum(MonitoringPointType mpt, List<Referenceable<VerticalDatum>> verticalDatums) throws EncodingException {
for (Referenceable<VerticalDatum> verticalDatum : verticalDatums) {
VerticalDatumPropertyType vdpt = mpt.addNewVerticalDatum();
if (verticalDatum.isReference()) {
Reference reference = verticalDatum.getReference();
reference.getActuate().map(Actuate::toString).map(ActuateType.Enum::forString).ifPresent(vdpt::setActuate);
reference.getArcrole().ifPresent(vdpt::setArcrole);
reference.getHref().map(URI::toString).ifPresent(vdpt::setHref);
reference.getRole().ifPresent(vdpt::setRole);
reference.getShow().map(Show::toString).map(ShowType.Enum::forString).ifPresent(vdpt::setShow);
reference.getTitle().ifPresent(vdpt::setTitle);
reference.getType().map(Type::toString).map(TypeType.Enum::forString).ifPresent(vdpt::setType);
} else {
if (verticalDatum.isInstance()) {
Nillable<VerticalDatum> nillable = verticalDatum.getInstance();
if (nillable.isPresent()) {
XmlObject xml = encodeGML(nillable.get());
if (xml != null && xml instanceof VerticalDatumType) {
vdpt.setVerticalDatum((VerticalDatumType) xml);
} else {
vdpt.setNil();
vdpt.setNilReason(Nillable.missing().get());
}
} else {
vdpt.setNil();
if (nillable.hasReason()) {
vdpt.setNilReason(nillable.getNilReason().get());
} else {
vdpt.setNilReason(Nillable.missing().get());
}
}
}
}
}
}
use of org.n52.shetland.w3c.Nillable in project arctic-sea by 52North.
the class AbstractWmlEncoderv20 method addRelatedParty.
private void addRelatedParty(MonitoringPointType mpt, List<Referenceable<CiResponsibleParty>> relatedParties) throws EncodingException {
for (Referenceable<CiResponsibleParty> relatedParty : relatedParties) {
CIResponsiblePartyPropertyType citppt = mpt.addNewRelatedParty();
if (relatedParty.isReference()) {
Reference reference = relatedParty.getReference();
reference.getActuate().map(Actuate::toString).map(ActuateType.Enum::forString).ifPresent(citppt::setActuate);
reference.getArcrole().ifPresent(citppt::setArcrole);
reference.getHref().map(URI::toString).ifPresent(citppt::setHref);
reference.getRole().ifPresent(citppt::setRole);
reference.getShow().map(Show::toString).map(ShowType.Enum::forString).ifPresent(citppt::setShow);
reference.getTitle().ifPresent(citppt::setTitle);
reference.getType().map(Type::toString).map(TypeType.Enum::forString).ifPresent(citppt::setType);
} else {
if (relatedParty.isInstance()) {
Nillable<CiResponsibleParty> nillable = relatedParty.getInstance();
if (nillable.isPresent()) {
XmlObject xml = encodeObjectToXml(nillable.get().getDefaultElementEncoding(), nillable.get());
if (xml != null && xml instanceof CIResponsiblePartyType) {
citppt.setCIResponsibleParty((CIResponsiblePartyType) xml);
} else {
citppt.setNil();
citppt.setNilReason(Nillable.missing().get());
}
} else {
citppt.setNil();
if (nillable.hasReason()) {
citppt.setNilReason(nillable.getNilReason().get());
} else {
citppt.setNilReason(Nillable.missing().get());
}
}
}
}
}
}
use of org.n52.shetland.w3c.Nillable in project arctic-sea by 52North.
the class DocumentCitationTypeDecoder method decode.
@Override
public DocumentCitation decode(XmlObject xmlObject) throws DecodingException {
if (xmlObject instanceof DocumentCitationType) {
DocumentCitation documentCitation = new DocumentCitation();
DocumentCitationType dct = (DocumentCitationType) xmlObject;
documentCitation.setDescription(dct.getDescription().getStringValue());
if (dct.isNilDate()) {
if (dct.getDate().isSetNilReason()) {
documentCitation.setDate(Nillable.<DateTime>nil(dct.getDate().getNilReason().toString()));
}
} else {
documentCitation.setDate(new DateTime(dct.getDate().getCIDate().getDate().getDate().getTime()));
}
if (dct.getLinkArray() != null) {
for (Link link : dct.getLinkArray()) {
if (link.isNil() && link.isSetNilReason()) {
documentCitation.addLink(Nillable.<String>nil(link.getNilReason().toString()));
} else {
documentCitation.addLink(link.getStringValue());
}
}
}
return documentCitation;
}
throw new UnsupportedDecoderInputException(this, xmlObject);
}
use of org.n52.shetland.w3c.Nillable in project arctic-sea by 52North.
the class EReportingHeaderEncoder method encodeAddress.
private void encodeAddress(AddressRepresentation v) throws XMLStreamException {
start(AqdConstants.QN_AD_ADDRESS_REPRESENTATION);
for (GeographicalName value : v.getAdminUnits()) {
start(AqdConstants.QN_AD_ADMIN_UNIT);
encodeGeographicalName(value);
end(AqdConstants.QN_AD_ADMIN_UNIT);
}
for (String value : v.getLocatorDesignators()) {
start(AqdConstants.QN_AD_LOCATOR_DESIGNATOR);
chars(value);
endInline(AqdConstants.QN_AD_LOCATOR_DESIGNATOR);
}
for (GeographicalName value : v.getLocatorNames()) {
start(AqdConstants.QN_AD_LOCATOR_NAME);
encodeGeographicalName(value);
end(AqdConstants.QN_AD_LOCATOR_NAME);
}
for (Nillable<GeographicalName> value : v.getAddressAreas()) {
encodeNillableGeographicalName(AqdConstants.QN_AD_ADDRESS_AREA, value);
}
for (Nillable<GeographicalName> value : v.getPostNames()) {
encodeNillableGeographicalName(AqdConstants.QN_AD_POST_NAME, value);
}
encodeNillableString(AqdConstants.QN_AD_POST_CODE, v.getPostCode());
for (Nillable<GeographicalName> value : v.getThoroughfares()) {
encodeNillableGeographicalName(AqdConstants.QN_AD_THOROUGHFARE, value);
}
encodeNillableReference(AqdConstants.QN_AD_ADDRESS_FEATURE, v.getAddressFeature());
end(AqdConstants.QN_AD_ADDRESS_REPRESENTATION);
}
use of org.n52.shetland.w3c.Nillable in project arctic-sea by 52North.
the class GeographicalNameReaderTest method test.
@Test
public void test() throws UnsupportedEncodingException, XMLStreamException, URISyntaxException, DecodingException {
String xml = "<gn:GeographicalName xmlns:gn=\"urn:x-inspire:specification:gmlas:GeographicalNames:3.0\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">\n" + " <gn:language>eng</gn:language>\n" + " <gn:nativeness><asdfasdf</gn:nativeness>\n" + " <gn:nameStatus xsi:nil=\"true\" nilReason=\"unknown\"/>\n" + " <gn:sourceOfName xsi:nil=\"true\" nilReason=\"missing\"/>\n" + " <gn:pronunciation>\n" + " <gn:PronunciationOfName>\n" + " <gn:pronunciationSoundLink>http://asdfasdf</gn:pronunciationSoundLink>\n" + " <gn:pronunciationIPA>asdfasdf</gn:pronunciationIPA>\n" + " </gn:PronunciationOfName>\n" + " </gn:pronunciation>\n" + " <gn:spelling>\n" + " <gn:SpellingOfName>\n" + " <gn:text>asdfasdf</gn:text>\n" + " <gn:script>asdfasdf</gn:script>\n" + " <gn:transliterationScheme>asdfasdfasdf</gn:transliterationScheme>\n" + " </gn:SpellingOfName>\n" + " </gn:spelling>\n" + " <gn:grammaticalGender codeSpace=\"b\">a</gn:grammaticalGender>\n" + " <gn:grammaticalNumber codeSpace=\"d\">c</gn:grammaticalNumber>\n" + "</gn:GeographicalName>";
GeographicalName gn = new GeographicalNameReader().read(new ByteArrayInputStream(xml.getBytes("UTF-8")));
errors.checkThat(gn.getGrammaticalGender(), is(Nillable.of(new CodeType("a", new URI("b")))));
errors.checkThat(gn.getGrammaticalNumber(), is(Nillable.of(new CodeType("c", new URI("d")))));
errors.checkThat(gn.getLanguage(), is(Nillable.of("eng")));
errors.checkThat(gn.getNativeness(), is(Nillable.of(new CodeType("<asdfasdf"))));
errors.checkThat(gn.getNameStatus(), is(Nillable.<CodeType>unknown()));
for (Spelling sp : gn.getSpelling()) {
errors.checkThat(sp.getText(), is("asdfasdf"));
errors.checkThat(sp.getScript(), is(Nillable.of("asdfasdf")));
errors.checkThat(sp.getTransliterationScheme(), is(Nillable.of("asdfasdfasdf")));
}
errors.checkThat(gn.getPronunciation().get().getIPA(), is(Nillable.of("asdfasdf")));
errors.checkThat(gn.getPronunciation().get().getSoundLink(), is(Nillable.of(URI.create("http://asdfasdf"))));
}
Aggregations