Skip to content

Creating Reference Metadata

Reference Metadata are programmatically created in sdmx-core using the Mutable Bean, and then converting into an immutable instance.

public static void main(String[] args) {

    IReportedMetadataSetMutableBean mutable = new ReportedMetadataSetMutableBean();

    //Set the maintainable properties
    mutable.setAgencyId("PROVIDER_ID");
    mutable.setId("EXPLANITORY_NOTES");
    mutable.setVersion("1.0.0");
    mutable.addName("en", "Explanatory Notes");

    //Attach the report to a Dataflow
    mutable.addTarget(StructureReferenceBeanImpl.fromShortCode("Dataflow=ABS:GBP(1.0.0)"));

    //Link to the Metadataflow or Metadata Provision
    mutable.setStructure(StructureReferenceBeanImpl.fromShortCode("MetadataFlow=IMF:DQAF(1.0.0)"));

    //Create the attributes (attributeId must match that on MSD)
    IReportedMetadataAttributeMutableBean s1 = getReportedAttribute("INTRODUCTION",
            "This publication contains estimates of gross domestic product (GDP) and its components...");

    IReportedMetadataAttributeMutableBean s2 = getReportedAttribute("SOURCES",
            "Australia's national accounts statistics are compiled in accordance with... ");

    IReportedMetadataAttributeMutableBean s3 = getReportedAttribute("GDP",
            "GDP is derived by three approaches: the income approach (I), the expenditure approach ... ");

    IReportedMetadataAttributeMutableBean s4 = getReportedAttribute("METHOD",
            "The general methods for deriving seasonally adjusted and trend estimates are described in ");

    IReportedMetadataAttributeMutableBean s4_1 = getReportedAttribute("SEASONAL_ADJUSTMENT",
            "Data that are affected by seasonal factors are adjusted to remove the effects of these factors ");

    IReportedMetadataAttributeMutableBean s4_2 = getReportedAttribute("TREND_ESTIMATE",
            "A trend estimate is obtained by removing the irregular component from the seasonally adjusted series ");

    //add leaf nodes (hierarchy)
    s4.addAttribute(s4_1);
    s4.addAttribute(s4_2);

    //Add top level attributes to report
    mutable.addAttribute(s1);
    mutable.addAttribute(s2);
    mutable.addAttribute(s3);
    mutable.addAttribute(s4);

    //create immutable (production) version
    IReportedMetadataSetBean finalVersion = mutable.getImmutableInstance();
}

private static IReportedMetadataAttributeMutableBean getReportedAttribute(String attributeId, String text) {
    IReportedMetadataAttributeMutableBean attribute = new ReportedMetadataAttributeMutableBean();
    attribute.setId(attributeId);
    attribute.addStructuredValue("en", text);
    return attribute;
}