use of org.n52.shetland.iso.gmd.PT_FreeText in project arctic-sea by 52North.
the class EReportingHeaderEncoder method encodeNillableFreeText.
protected void encodeNillableFreeText(QName qn, Nillable<PT_FreeText> nillable) throws XMLStreamException {
if (!nillable.isAbsent()) {
if (nillable.isNil()) {
empty(qn);
encodeGCONilAttr(nillable);
} else {
for (LocalisedCharacterString lcs : nillable.get().getTextGroup()) {
start(qn);
start(GcoConstants.QN_GCO_CHARACTER_STRING);
chars(lcs.getValue());
endInline(GcoConstants.QN_GCO_CHARACTER_STRING);
end(qn);
}
}
}
}
use of org.n52.shetland.iso.gmd.PT_FreeText in project arctic-sea by 52North.
the class EReportingHeaderEncoderTest method testValidity.
@Test
public void testValidity() throws XMLStreamException, OwsExceptionReport, SAXException, MalformedURLException, IOException, URISyntaxException, EncodingException {
EReportingHeader header = new EReportingHeader().setInspireID(new Identifier("id", "namespace").setVersionId(Nillable.missing())).setChange(new EReportingChange("Changed because... you know")).setReportingPeriod(Referenceable.of(Nillable.present(new TimeInstant(DateTime.now())))).setReportingAuthority(new RelatedParty().setIndividualName(Nillable.missing()).setOrganisationName("Organisation").setPositionName("Postionti").addRole(new Reference().setHref(URI.create("http://hallo"))).addRole(Nillable.withheld()).setContact(new Contact().addTelephoneFacsimile("1234").addTelephoneFacsimile(Nillable.missing()).addTelephoneVoice("asdfasdf").setHoursOfService(new PT_FreeText().addTextGroup(new LocalisedCharacterString("asdfasdf"))).setWebsite(Nillable.unknown()).setElectronicMailAddress(Nillable.unknown()).setAddress(new AddressRepresentation().setPostCode("12341234").setAddressFeature(new Reference().setHref(URI.create("http://asdfasdf"))).addLocatorDesignator("localtor").addAddressArea(Nillable.withheld()).addAddressArea(new GeographicalName().setGrammaticalGender(new CodeType("a", new URI("b"))).setGrammaticalNumber(new CodeType("c", new URI("d"))).setLanguage("eng").setNativeness(new CodeType("<asdfasdf")).setNameStatus(Nillable.unknown()).addSpelling(new Spelling().setScript("asdfasdf").setText("asdfasdf").setTransliterationScheme("asdfasdfasdf")).setPronunciation(new Pronunciation().setIPA("asdfasdf").setSoundLink(URI.create("http://asdfasdf")))).addAdminUnit(new GeographicalName().setGrammaticalGender(new CodeType("a", new URI("b"))).setGrammaticalNumber(new CodeType("c", new URI("d"))).setLanguage("eng").setNativeness(new CodeType("<asdfasdf")).setNameStatus(Nillable.unknown()).addSpelling(new Spelling().setScript("asdfasdf").setText("asdfasdf").setTransliterationScheme("asdfasdfasdf")).setPronunciation(new Pronunciation().setIPA("asdfasdf").setSoundLink(URI.create("http://asdfasdf")))).addPostName(Nillable.withheld()).addPostName(new GeographicalName().setGrammaticalGender(new CodeType("a", new URI("b"))).setGrammaticalNumber(new CodeType("c", new URI("d"))).setLanguage("eng").setNativeness(new CodeType("<asdfasdf")).setNameStatus(Nillable.unknown()).addSpelling(new Spelling().setScript("asdfasdf").setText("asdfasdf").setTransliterationScheme("asdfasdfasdf")).setPronunciation(new Pronunciation().setIPA("asdfasdf").setSoundLink(URI.create("http://asdfasdf")))).addThoroughfare(Nillable.withheld()).addThoroughfare(new GeographicalName().setGrammaticalGender(new CodeType("a", new URI("b"))).setGrammaticalNumber(new CodeType("c", new URI("d"))).setLanguage("eng").setNativeness(new CodeType("<asdfasdf")).setNameStatus(Nillable.unknown()).addSpelling(new Spelling().setScript("asdfasdf").setText("asdfasdf").setTransliterationScheme("asdfasdfasdf")).setPronunciation(new Pronunciation().setIPA("asdfasdf").setSoundLink(URI.create("http://asdfasdf")))))));
validate(header);
}
use of org.n52.shetland.iso.gmd.PT_FreeText in project arctic-sea by 52North.
the class AbstractJSONDecoder method parseFreeText.
protected PT_FreeText parseFreeText(JsonNode n) {
LocalisedCharacterString localisedCharacterString = new LocalisedCharacterString("");
if (n.isArray()) {
ArrayNode arrayNode = (ArrayNode) n;
Iterator<JsonNode> it = arrayNode.iterator();
while (it.hasNext()) {
final JsonNode next = it.next();
if (next.has(AQDJSONConstants.TEXT)) {
localisedCharacterString.setValue(next.get(AQDJSONConstants.TEXT).asText());
} else if (next.has(AQDJSONConstants.LANGUAGE)) {
localisedCharacterString.setLocale(next.get(AQDJSONConstants.LANGUAGE).asText());
}
}
}
return new PT_FreeText().addTextGroup(localisedCharacterString);
}
use of org.n52.shetland.iso.gmd.PT_FreeText in project arctic-sea by 52North.
the class AbstractJSONDecoder method parsePTFreeText.
protected PT_FreeText parsePTFreeText(JsonNode node) {
PT_FreeText ptFreeText = new PT_FreeText();
ptFreeText.addTextGroup(new LocalisedCharacterString(node.textValue()));
return ptFreeText;
}
use of org.n52.shetland.iso.gmd.PT_FreeText in project arctic-sea by 52North.
the class EReportingHeaderJSONDecoderTest method checkPtFreeText.
private void checkPtFreeText(PT_FreeText decoded, PT_FreeText original) {
assertThat(decoded.isSetTextGroup(), is(true));
assertThat(decoded.getTextGroup().size(), equalTo(original.getTextGroup().size()));
Iterator<LocalisedCharacterString> decodedIterator = decoded.getTextGroup().iterator();
Iterator<LocalisedCharacterString> originalIterator = original.getTextGroup().iterator();
while (decodedIterator.hasNext() && originalIterator.hasNext()) {
LocalisedCharacterString decodedLCS = decodedIterator.next();
LocalisedCharacterString originalLCS = originalIterator.next();
assertThat(decodedLCS.isSetLocale(), equalTo(originalLCS.isSetLocale()));
if (decodedLCS.isSetLocale() && originalLCS.isSetLocale()) {
assertThat(decodedLCS.getLocale(), equalTo(originalLCS.getLocale()));
}
assertThat(decodedLCS.getValue(), equalTo(originalLCS.getValue()));
}
}
Aggregations