Search in sources :

Example 6 with Nillable

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());
                    }
                }
            }
        }
    }
}
Also used : ActuateType(org.w3.x1999.xlink.ActuateType) VerticalDatumPropertyType(net.opengis.gml.x32.VerticalDatumPropertyType) Reference(org.n52.shetland.w3c.xlink.Reference) VerticalDatum(org.n52.shetland.ogc.gml.VerticalDatum) Actuate(org.n52.shetland.w3c.xlink.Actuate) VerticalDatumPropertyType(net.opengis.gml.x32.VerticalDatumPropertyType) ActuateType(org.w3.x1999.xlink.ActuateType) CodeType(org.n52.shetland.ogc.gml.CodeType) MonitoringPointType(net.opengis.waterml.x20.MonitoringPointType) ObservationProcessType(net.opengis.waterml.x20.ObservationProcessType) CIResponsiblePartyType(org.isotc211.x2005.gmd.CIResponsiblePartyType) ShapeType(net.opengis.samplingSpatial.x20.ShapeType) CollectionType(net.opengis.waterml.x20.CollectionType) MediaType(org.n52.janmayen.http.MediaType) TypeType(org.w3.x1999.xlink.TypeType) Type(org.n52.shetland.w3c.xlink.Type) VerticalDatumType(net.opengis.gml.x32.VerticalDatumType) OMObservationType(net.opengis.om.x20.OMObservationType) ShowType(org.w3.x1999.xlink.ShowType) CIResponsiblePartyPropertyType(org.isotc211.x2005.gmd.CIResponsiblePartyPropertyType) ReferenceType(org.n52.shetland.ogc.gml.ReferenceType) VerticalDatumType(net.opengis.gml.x32.VerticalDatumType) Show(org.n52.shetland.w3c.xlink.Show) XmlObject(org.apache.xmlbeans.XmlObject) TypeType(org.w3.x1999.xlink.TypeType) ShowType(org.w3.x1999.xlink.ShowType)

Example 7 with Nillable

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());
                    }
                }
            }
        }
    }
}
Also used : CiResponsibleParty(org.n52.shetland.iso.gmd.CiResponsibleParty) ActuateType(org.w3.x1999.xlink.ActuateType) Reference(org.n52.shetland.w3c.xlink.Reference) Actuate(org.n52.shetland.w3c.xlink.Actuate) CIResponsiblePartyType(org.isotc211.x2005.gmd.CIResponsiblePartyType) VerticalDatumPropertyType(net.opengis.gml.x32.VerticalDatumPropertyType) ActuateType(org.w3.x1999.xlink.ActuateType) CodeType(org.n52.shetland.ogc.gml.CodeType) MonitoringPointType(net.opengis.waterml.x20.MonitoringPointType) ObservationProcessType(net.opengis.waterml.x20.ObservationProcessType) CIResponsiblePartyType(org.isotc211.x2005.gmd.CIResponsiblePartyType) ShapeType(net.opengis.samplingSpatial.x20.ShapeType) CollectionType(net.opengis.waterml.x20.CollectionType) MediaType(org.n52.janmayen.http.MediaType) TypeType(org.w3.x1999.xlink.TypeType) Type(org.n52.shetland.w3c.xlink.Type) VerticalDatumType(net.opengis.gml.x32.VerticalDatumType) OMObservationType(net.opengis.om.x20.OMObservationType) ShowType(org.w3.x1999.xlink.ShowType) CIResponsiblePartyPropertyType(org.isotc211.x2005.gmd.CIResponsiblePartyPropertyType) ReferenceType(org.n52.shetland.ogc.gml.ReferenceType) CIResponsiblePartyPropertyType(org.isotc211.x2005.gmd.CIResponsiblePartyPropertyType) Show(org.n52.shetland.w3c.xlink.Show) XmlObject(org.apache.xmlbeans.XmlObject) TypeType(org.w3.x1999.xlink.TypeType) ShowType(org.w3.x1999.xlink.ShowType)

Example 8 with Nillable

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);
}
Also used : DocumentCitationType(eu.europa.ec.inspire.schemas.base2.x20.DocumentCitationType) DocumentCitation(org.n52.shetland.inspire.base2.DocumentCitation) UnsupportedDecoderInputException(org.n52.svalbard.decode.exception.UnsupportedDecoderInputException) DateTime(org.joda.time.DateTime) Link(eu.europa.ec.inspire.schemas.base2.x20.DocumentCitationType.Link)

Example 9 with Nillable

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);
}
Also used : GeographicalName(org.n52.shetland.inspire.GeographicalName) LocalisedCharacterString(org.n52.shetland.iso.gmd.LocalisedCharacterString)

Example 10 with Nillable

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>&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)

Aggregations

Actuate (org.n52.shetland.w3c.xlink.Actuate)12 Reference (org.n52.shetland.w3c.xlink.Reference)12 Show (org.n52.shetland.w3c.xlink.Show)12 Type (org.n52.shetland.w3c.xlink.Type)12 ActuateType (org.w3.x1999.xlink.ActuateType)12 ShowType (org.w3.x1999.xlink.ShowType)12 TypeType (org.w3.x1999.xlink.TypeType)12 AbstractCRSType (net.opengis.gml.x32.AbstractCRSType)10 CodeType (net.opengis.gml.x32.CodeType)10 EXExtentType (org.isotc211.x2005.gmd.EXExtentType)10 CIResponsiblePartyPropertyType (org.isotc211.x2005.gmd.CIResponsiblePartyPropertyType)8 CIResponsiblePartyType (org.isotc211.x2005.gmd.CIResponsiblePartyType)8 BaseUnitType (net.opengis.gml.x32.BaseUnitType)6 VerticalDatumPropertyType (net.opengis.gml.x32.VerticalDatumPropertyType)5 VerticalDatumType (net.opengis.gml.x32.VerticalDatumType)5 XmlObject (org.apache.xmlbeans.XmlObject)4 AbstractCoordinateSystemType (net.opengis.gml.x32.AbstractCoordinateSystemType)3 AbstractDatumType (net.opengis.gml.x32.AbstractDatumType)3 AbstractGeometryType (net.opengis.gml.x32.AbstractGeometryType)3 AbstractRingPropertyType (net.opengis.gml.x32.AbstractRingPropertyType)3