Search in sources :

Example 1 with MDMetadataType

use of org.isotc211.x2005.gmd.MDMetadataType 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

MDIdentificationPropertyType (org.isotc211.x2005.gmd.MDIdentificationPropertyType)1 MDMetadataDocument (org.isotc211.x2005.gmd.MDMetadataDocument)1 MDMetadataPropertyType (org.isotc211.x2005.gmd.MDMetadataPropertyType)1 MDMetadataType (org.isotc211.x2005.gmd.MDMetadataType)1 AbstractMDIdentification (org.n52.shetland.iso.gmd.AbstractMDIdentification)1 CiResponsibleParty (org.n52.shetland.iso.gmd.CiResponsibleParty)1