Search in sources :

Example 1 with CiResponsibleParty

use of org.n52.shetland.iso.gmd.CiResponsibleParty in project arctic-sea by 52North.

the class Iso19139GmdEncoderTest method checkMDMetadataEncoding.

// @Test
// public void checkMDMetadataReferenceEncoding() throws EncodingException {
// MDMetadata mdMmetadata = new MDMetadata(new SimpleAttrs().setHref("href").setTitle("title"));
// XmlObject xmlObject = encoder.encode(mdMmetadata);
// xmlObject.validate();
// errors.checkThat(xmlObject, instanceOf(MDMetadataPropertyType.class));
// }
@Test
public void checkMDMetadataEncoding() throws EncodingException {
    MDDataIdentification identificationInfo = new MDDataIdentification(new GmdCitation("title", new GmdCitationDate(GmdDateType.publication(), "2018-10-11")), "abstrakt", "ger");
    MDMetadata mdMmetadata = new MDMetadata(new CiResponsibleParty(new org.n52.shetland.iso.gco.Role(CodeList.CiRoleCodes.CI_RoleCode_author.name())), DateTime.now(), identificationInfo);
    XmlObject xmlObject = encoder.encode(mdMmetadata, EncodingContext.of(XmlBeansEncodingFlags.PROPERTY_TYPE));
    xmlObject.validate();
    errors.checkThat(xmlObject, instanceOf(MDMetadataPropertyType.class));
}
Also used : CiResponsibleParty(org.n52.shetland.iso.gmd.CiResponsibleParty) Role(org.n52.shetland.iso.gco.Role) MDDataIdentification(org.n52.shetland.iso.gmd.MDDataIdentification) GmdCitationDate(org.n52.shetland.iso.gmd.GmdCitationDate) MDMetadata(org.n52.shetland.iso.gmd.MDMetadata) XmlObject(org.apache.xmlbeans.XmlObject) MDMetadataPropertyType(org.isotc211.x2005.gmd.MDMetadataPropertyType) GmdCitation(org.n52.shetland.iso.gmd.GmdCitation) Test(org.junit.Test)

Example 2 with CiResponsibleParty

use of org.n52.shetland.iso.gmd.CiResponsibleParty 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 3 with CiResponsibleParty

use of org.n52.shetland.iso.gmd.CiResponsibleParty in project arctic-sea by 52North.

the class Iso19139GmdEncoder method encodeMDMetadata.

private XmlObject encodeMDMetadata(MDMetadata mdMetadata, EncodingContext context) throws EncodingException {
    if (mdMetadata.isSetSimpleAttrs()) {
        MDMetadataPropertyType mdmpt = MDMetadataPropertyType.Factory.newInstance(getXmlOptions());
        mdmpt.setHref(mdMetadata.getSimpleAttrs().getHref());
        if (mdMetadata.getSimpleAttrs().isSetTitle()) {
            mdmpt.setTitle(mdMetadata.getSimpleAttrs().getTitle());
        }
        if (mdMetadata.getSimpleAttrs().isSetRole()) {
            mdmpt.setRole(mdMetadata.getSimpleAttrs().getRole());
        }
        return mdmpt;
    }
    MDMetadataType mdmt = MDMetadataType.Factory.newInstance(getXmlOptions());
    encodeAbstractObject(mdmt, mdMetadata);
    // add contacts
    for (CiResponsibleParty contact : mdMetadata.getContact()) {
        mdmt.addNewContact().set(encodeResponsibleParty(contact, EncodingContext.of(XmlBeansEncodingFlags.PROPERTY_TYPE, true)));
    }
    // add dateStamp
    mdmt.addNewDateStamp().setDateTime(mdMetadata.getDateStamp().toCalendar(Locale.ROOT));
    // add identificationInfo
    for (AbstractMDIdentification identificationInfo : mdMetadata.getIdentificationInfo()) {
        if (identificationInfo.isSetSimpleAttrs()) {
            MDIdentificationPropertyType mdipt = mdmt.addNewIdentificationInfo();
            mdipt.setHref(identificationInfo.getSimpleAttrs().getHref());
            if (identificationInfo.getSimpleAttrs().isSetTitle()) {
                mdipt.setTitle(identificationInfo.getSimpleAttrs().getTitle());
            }
            if (identificationInfo.getSimpleAttrs().isSetRole()) {
                mdipt.setRole(identificationInfo.getSimpleAttrs().getRole());
            }
        } else {
            mdmt.addNewIdentificationInfo().set(encode(identificationInfo, EncodingContext.of(XmlBeansEncodingFlags.PROPERTY_TYPE)));
        // TODO substitution???
        }
    }
    // TODO all other optional elements if required
    if (context.has(XmlBeansEncodingFlags.PROPERTY_TYPE)) {
        MDMetadataPropertyType mdmpt = MDMetadataPropertyType.Factory.newInstance(getXmlOptions());
        mdmpt.setMDMetadata(mdmt);
        return mdmpt;
    } else if (context.has(XmlBeansEncodingFlags.DOCUMENT)) {
        MDMetadataDocument mdmd = MDMetadataDocument.Factory.newInstance(getXmlOptions());
        mdmd.setMDMetadata(mdmt);
        return mdmd;
    }
    return mdmt;
}
Also used : CiResponsibleParty(org.n52.shetland.iso.gmd.CiResponsibleParty) AbstractMDIdentification(org.n52.shetland.iso.gmd.AbstractMDIdentification) MDMetadataType(org.isotc211.x2005.gmd.MDMetadataType) MDMetadataPropertyType(org.isotc211.x2005.gmd.MDMetadataPropertyType) MDIdentificationPropertyType(org.isotc211.x2005.gmd.MDIdentificationPropertyType) MDMetadataDocument(org.isotc211.x2005.gmd.MDMetadataDocument)

Aggregations

CiResponsibleParty (org.n52.shetland.iso.gmd.CiResponsibleParty)3 XmlObject (org.apache.xmlbeans.XmlObject)2 MDMetadataPropertyType (org.isotc211.x2005.gmd.MDMetadataPropertyType)2 VerticalDatumPropertyType (net.opengis.gml.x32.VerticalDatumPropertyType)1 VerticalDatumType (net.opengis.gml.x32.VerticalDatumType)1 OMObservationType (net.opengis.om.x20.OMObservationType)1 ShapeType (net.opengis.samplingSpatial.x20.ShapeType)1 CollectionType (net.opengis.waterml.x20.CollectionType)1 MonitoringPointType (net.opengis.waterml.x20.MonitoringPointType)1 ObservationProcessType (net.opengis.waterml.x20.ObservationProcessType)1 CIResponsiblePartyPropertyType (org.isotc211.x2005.gmd.CIResponsiblePartyPropertyType)1 CIResponsiblePartyType (org.isotc211.x2005.gmd.CIResponsiblePartyType)1 MDIdentificationPropertyType (org.isotc211.x2005.gmd.MDIdentificationPropertyType)1 MDMetadataDocument (org.isotc211.x2005.gmd.MDMetadataDocument)1 MDMetadataType (org.isotc211.x2005.gmd.MDMetadataType)1 Test (org.junit.Test)1 MediaType (org.n52.janmayen.http.MediaType)1 Role (org.n52.shetland.iso.gco.Role)1 AbstractMDIdentification (org.n52.shetland.iso.gmd.AbstractMDIdentification)1 GmdCitation (org.n52.shetland.iso.gmd.GmdCitation)1