use of org.n52.shetland.inspire.base2.RelatedParty in project arctic-sea by 52North.
the class RelatedPartyJSONDecoder method decodeJSON.
@Override
public RelatedParty decodeJSON(JsonNode node, boolean validate) throws DecodingException {
RelatedParty relatedParty = new RelatedParty();
relatedParty.setContact(decodeJsonToNillable(node.path(AQDJSONConstants.CONTACT), Contact.class));
relatedParty.setIndividualName(parseNillable(node.path(AQDJSONConstants.INDIVIDUAL_NAME)).map(this::parseFreeText));
relatedParty.setOrganisationName(parseNillable(node.path(AQDJSONConstants.ORGANISATION_NAME)).map(this::parseFreeText));
relatedParty.setPositionName(parseNillable(node.path(AQDJSONConstants.POSITION_NAME)).map(this::parseFreeText));
for (JsonNode n : node.path(AQDJSONConstants.ROLES)) {
relatedParty.addRole(parseNillableReference(n));
}
return relatedParty;
}
use of org.n52.shetland.inspire.base2.RelatedParty 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.base2.RelatedParty in project arctic-sea by 52North.
the class RelatedPartyTypeDecoder method decode.
@Override
public RelatedParty decode(XmlObject xmlObject) throws DecodingException {
if (xmlObject instanceof RelatedPartyType) {
RelatedPartyType rpt = (RelatedPartyType) xmlObject;
RelatedParty relatedParty = new RelatedParty();
relatedParty.setContact(parseContact(rpt));
relatedParty.setIndividualName((PT_FreeText) decodeXmlElement(rpt.getIndividualName()));
relatedParty.setOrganisationName((PT_FreeText) decodeXmlElement(rpt.getOrganisationName()));
relatedParty.setPositionName((PT_FreeText) decodeXmlElement(rpt.getPositionName()));
relatedParty.setRoles(parseRole(rpt));
return relatedParty;
}
throw new UnsupportedDecoderInputException(this, xmlObject);
}
use of org.n52.shetland.inspire.base2.RelatedParty 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.inspire.base2.RelatedParty 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);
}
}
Aggregations