Search in sources :

Example 1 with Spelling

use of org.n52.shetland.inspire.Spelling 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);
}
Also used : LocalisedCharacterString(org.n52.shetland.iso.gmd.LocalisedCharacterString) Spelling(org.n52.shetland.inspire.Spelling) Pronunciation(org.n52.shetland.inspire.Pronunciation) Reference(org.n52.shetland.w3c.xlink.Reference) PT_FreeText(org.n52.shetland.iso.gmd.PT_FreeText) URI(java.net.URI) Contact(org.n52.shetland.inspire.base2.Contact) Identifier(org.n52.shetland.inspire.base.Identifier) EReportingHeader(org.n52.shetland.aqd.EReportingHeader) AddressRepresentation(org.n52.shetland.inspire.ad.AddressRepresentation) GeographicalName(org.n52.shetland.inspire.GeographicalName) RelatedParty(org.n52.shetland.inspire.base2.RelatedParty) CodeType(org.n52.shetland.ogc.gml.CodeType) EReportingChange(org.n52.shetland.aqd.EReportingChange) TimeInstant(org.n52.shetland.ogc.gml.time.TimeInstant) Test(org.junit.Test)

Example 2 with Spelling

use of org.n52.shetland.inspire.Spelling in project arctic-sea by 52North.

the class SpellingJSONDecoder method decodeJSON.

@Override
public Spelling decodeJSON(JsonNode node, boolean validate) throws DecodingException {
    Spelling spelling = new Spelling();
    spelling.setScript(parseNillableString(node.path(AQDJSONConstants.SCRIPT)));
    spelling.setText(node.path(AQDJSONConstants.TEXT).textValue());
    spelling.setTransliterationScheme(parseNillableString(node.path(AQDJSONConstants.TRANSLITERATION_SCHEME)));
    return spelling;
}
Also used : Spelling(org.n52.shetland.inspire.Spelling)

Example 3 with Spelling

use of org.n52.shetland.inspire.Spelling 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);
}
Also used : Spelling(org.n52.shetland.inspire.Spelling)

Example 4 with Spelling

use of org.n52.shetland.inspire.Spelling 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>&lt;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"))));
}
Also used : Spelling(org.n52.shetland.inspire.Spelling) ByteArrayInputStream(java.io.ByteArrayInputStream) GeographicalName(org.n52.shetland.inspire.GeographicalName) CodeType(org.n52.shetland.ogc.gml.CodeType) URI(java.net.URI) Test(org.junit.Test)

Example 5 with Spelling

use of org.n52.shetland.inspire.Spelling in project arctic-sea by 52North.

the class ReportingHeaderReaderTest method testValidity.

@Test
public void testValidity() throws Exception {
    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")))))));
    try (ByteArrayOutputStream baos = new ByteArrayOutputStream()) {
        new EReportingHeaderEncoder(EncodingContext.of(EncoderFlags.ENCODER_REPOSITORY, new EncoderRepository()), baos, header).write();
        ByteArrayInputStream in = new ByteArrayInputStream(baos.toByteArray());
        EReportingHeader read = new ReportingHeaderReader().read(in);
        errors.checkThat(read.getChange(), is(equalTo(header.getChange())));
        errors.checkThat(read.getContent(), is(equalTo(header.getContent())));
        errors.checkThat(read.getDelete(), is(equalTo(header.getDelete())));
        errors.checkThat(read.getInspireID(), is(equalTo(header.getInspireID())));
        errors.checkThat(read.getReportingPeriod(), is(equalTo(header.getReportingPeriod())));
        errors.checkThat(read.getReportingAuthority(), is(equalTo(header.getReportingAuthority())));
        errors.checkThat(read.getReportingAuthority().getIndividualName(), is(header.getReportingAuthority().getIndividualName()));
        errors.checkThat(read.getReportingAuthority().getOrganisationName().get(), is(header.getReportingAuthority().getOrganisationName().get()));
        errors.checkThat(read.getReportingAuthority().getPositionName().get(), is(header.getReportingAuthority().getPositionName().get()));
        Contact c1 = read.getReportingAuthority().getContact().get();
        Contact c2 = header.getReportingAuthority().getContact().get();
        errors.checkThat(c1, is(c2));
        errors.checkThat(c1.getContactInstructions(), is(c2.getContactInstructions()));
        errors.checkThat(c1.getElectronicMailAddress(), is(c2.getElectronicMailAddress()));
        errors.checkThat(c1.getHoursOfService().get(), is(c2.getHoursOfService().get()));
        errors.checkThat(c1.getTelephoneFacsimile(), is(c2.getTelephoneFacsimile()));
        errors.checkThat(c1.getTelephoneVoice(), is(c2.getTelephoneVoice()));
        errors.checkThat(c1.getWebsite(), is(c2.getWebsite()));
        AddressRepresentation a1 = c1.getAddress().get();
        AddressRepresentation a2 = c2.getAddress().get();
        errors.checkThat(a1.getAddressAreas(), is(a2.getAddressAreas()));
        errors.checkThat(a1.getAddressFeature(), is(a2.getAddressFeature()));
        errors.checkThat(a1.getAdminUnits(), is(a2.getAdminUnits()));
        errors.checkThat(a1.getLocatorDesignators(), is(a2.getLocatorDesignators()));
        errors.checkThat(a1.getLocatorNames(), is(a2.getLocatorNames()));
        errors.checkThat(a1.getPostCode(), is(a2.getPostCode()));
        errors.checkThat(a1.getPostNames(), is(a2.getPostNames()));
        errors.checkThat(a1.getThoroughfares(), is(a2.getThoroughfares()));
    } catch (Exception e) {
        errors.addError(e);
    }
}
Also used : LocalisedCharacterString(org.n52.shetland.iso.gmd.LocalisedCharacterString) Spelling(org.n52.shetland.inspire.Spelling) Pronunciation(org.n52.shetland.inspire.Pronunciation) Reference(org.n52.shetland.w3c.xlink.Reference) EncoderRepository(org.n52.svalbard.encode.EncoderRepository) PT_FreeText(org.n52.shetland.iso.gmd.PT_FreeText) ByteArrayOutputStream(java.io.ByteArrayOutputStream) URI(java.net.URI) Contact(org.n52.shetland.inspire.base2.Contact) Identifier(org.n52.shetland.inspire.base.Identifier) ByteArrayInputStream(java.io.ByteArrayInputStream) ReportingHeaderReader(org.n52.svalbard.read.ReportingHeaderReader) EReportingHeader(org.n52.shetland.aqd.EReportingHeader) AddressRepresentation(org.n52.shetland.inspire.ad.AddressRepresentation) GeographicalName(org.n52.shetland.inspire.GeographicalName) RelatedParty(org.n52.shetland.inspire.base2.RelatedParty) CodeType(org.n52.shetland.ogc.gml.CodeType) EReportingChange(org.n52.shetland.aqd.EReportingChange) TimeInstant(org.n52.shetland.ogc.gml.time.TimeInstant) Test(org.junit.Test)

Aggregations

Spelling (org.n52.shetland.inspire.Spelling)5 URI (java.net.URI)3 Test (org.junit.Test)3 GeographicalName (org.n52.shetland.inspire.GeographicalName)3 CodeType (org.n52.shetland.ogc.gml.CodeType)3 ByteArrayInputStream (java.io.ByteArrayInputStream)2 EReportingChange (org.n52.shetland.aqd.EReportingChange)2 EReportingHeader (org.n52.shetland.aqd.EReportingHeader)2 Pronunciation (org.n52.shetland.inspire.Pronunciation)2 AddressRepresentation (org.n52.shetland.inspire.ad.AddressRepresentation)2 Identifier (org.n52.shetland.inspire.base.Identifier)2 Contact (org.n52.shetland.inspire.base2.Contact)2 RelatedParty (org.n52.shetland.inspire.base2.RelatedParty)2 LocalisedCharacterString (org.n52.shetland.iso.gmd.LocalisedCharacterString)2 PT_FreeText (org.n52.shetland.iso.gmd.PT_FreeText)2 TimeInstant (org.n52.shetland.ogc.gml.time.TimeInstant)2 Reference (org.n52.shetland.w3c.xlink.Reference)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 EncoderRepository (org.n52.svalbard.encode.EncoderRepository)1 ReportingHeaderReader (org.n52.svalbard.read.ReportingHeaderReader)1