use of org.n52.shetland.inspire.GeographicalName 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.inspire.GeographicalName in project arctic-sea by 52North.
the class GeographicalNameJSONDecoder method decodeJSON.
@Override
public GeographicalName decodeJSON(JsonNode node, boolean validate) throws DecodingException {
GeographicalName geographicalName = new GeographicalName();
geographicalName.setGrammaticalGender(parseNillableCodeType(node.path(AQDJSONConstants.GRAMMATICAL_GENDER)));
geographicalName.setGrammaticalNumber(parseNillableCodeType(node.path(AQDJSONConstants.GRAMMATICAL_NUMBER)));
geographicalName.setLanguage(parseNillableString(node.path(AQDJSONConstants.LANGUAGE)));
geographicalName.setNameStatus(parseNillableCodeType(node.path(AQDJSONConstants.NAME_STATUS)));
geographicalName.setNativeness(parseNillableCodeType(node.path(AQDJSONConstants.NATIVENESS)));
geographicalName.setSourceOfName(parseNillableString(node.path(AQDJSONConstants.SOURCE_OF_NAME)));
geographicalName.setPronunciation(decodeJsonToNillable(node.path(AQDJSONConstants.PRONUNCIATION), Pronunciation.class));
for (JsonNode n : node.path(AQDJSONConstants.SPELLING)) {
geographicalName.addSpelling(decodeJsonToObject(n, Spelling.class));
}
return geographicalName;
}
use of org.n52.shetland.inspire.GeographicalName in project arctic-sea by 52North.
the class EReportingHeaderEncoder method encodeGeographicalName.
private void encodeGeographicalName(GeographicalName v) throws XMLStreamException {
start(AqdConstants.QN_GN_GEOGRAPHICAL_NAME);
encodeNillableString(AqdConstants.QN_GN_LANGUAGE, v.getLanguage());
encodeNillableCodeType(AqdConstants.QN_GN_NATIVENESS, v.getNativeness());
encodeNillableCodeType(AqdConstants.QN_GN_NAME_STATUS, v.getNameStatus());
encodeNillableString(AqdConstants.QN_GN_SOURCE_OF_NAME, v.getSourceOfName());
encodeNillablePronunciation(AqdConstants.QN_GN_PRONUNCIATION, v.getPronunciation());
for (Spelling value : v.getSpelling()) {
start(AqdConstants.QN_GN_SPELLING);
encodeSpellingOfName(value);
end(AqdConstants.QN_GN_SPELLING);
}
encodeNillableCodeType(AqdConstants.QN_GN_GRAMMATICAL_GENDER, v.getGrammaticalGender());
encodeNillableCodeType(AqdConstants.QN_GN_GRAMMATICAL_NUMBER, v.getGrammaticalNumber());
end(AqdConstants.QN_GN_GEOGRAPHICAL_NAME);
}
use of org.n52.shetland.inspire.GeographicalName 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.inspire.GeographicalName 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