Class: DataQueryMetadata

data. DataQueryMetadata

DataQueryMetadata provides information about what data exists in the context of the DataQuery which this DataQueryMetadata belongs to.

A count of valid series, and potential observations, reporting start and end dates are reported, as well as providing access to Codes for each Dimension for which there is known to have data.

DataQueryMetadata contains DataQueryDimensions which in turn contain DataQueryCodes.

The DataQueryDimensions and DataQueryCodes both contain links to additional ReferenceMetadata in the context of the Dataflow, for example if ReferenceMetadata has been attached to a Code in the context of the Dataflow for which this DataQuery is for, then the DataQueryCode will have a link to that ReferenceMetadata.

DataQueryDimensions and DataQueryCodes are both stateful, a DataQueryDimension will only contain DataQueryCode for which there exists data. In addition, the DataQueryCode knows if it contain data in the context of the current DataQuery selections. For example if the selection of 'Reporting Country=France' is added to the DataQuery this may invalidate other code choices in other Dimensions such as 'Frequency=Annual'.

To update the series count, and state on a DataQueryCode use the updateMetadata() method

Note : This class should be obtained via the DataQuery.loadDataQueryMetadata() method


new DataQueryMetadata()

Examples

Obtaining an instance

dataQuery.loadDataQueryMetadata(function(dqm) {
		//dqm is an instance of DataQueryMetadata
});

Updating information after a Code selection/de-selection in the DataQuery

dataQueryMetadata.updateMetadata();

Methods


addCodeDataStateChangeListener(callback)

Adds a callback function to be called each time a DataQueryCode dataQueryCode.hasData() state changes

Parameters:
Name Type Description
callback function

to be called with the DataQueryCode whose data state has changed

Example
addCodeDataStateChangeListener(onCodeSelect)

function onCodeChange(dataQueryCode) {
  var hasData = dataQueryCode.hasData();
  console.log(dataQueryCode.getId() + " has data = " + hasData);
}

addCodeSelectionStateChangeListener(callback)

Adds a callback function to be called each time a DataQueryCode dataQueryCode.isSelected() has its selection state changed.

Parameters:
Name Type Description
callback function

to be called with the DataQueryCode whose selection state has changed

Example
addCodeSelectionStateChangeListener(onCodeSelect)

function onCodeChange(dataQueryCode) {
  var isSelected = dataQueryCode.isSelected();
  console.log(dataQueryCode.getId() + " is selected = " + isSelected);
}

addUpdateMetadataCompleteListener(callback)

Adds a callback function to be called each time a dataQueryMetadata.updateMetadata() has completed

Parameters:
Name Type Description
callback function

to be called with DataQueryMetadata on completion of update

Example
addUpdateMetadataCompleteListener(onMetadataUpdated)

function onMetadataUpdated(dataQueryMetadata) {
  var seriesCount = getValidSeriesCount();
  console.log(dataQueryMetadata.getId() + " series count = " + seriesCount);
}

getCodeDataStateChangeListeners()

Returns the array of callback functions registered for code data state changes

See:
Returns:

callback

Type
Array.<function()>

getCodeSelectionStateChangeListeners()

Returns the array of callback functions registered for code selection state changes

See:
Returns:

callback

Type
Array.<function()>

getDataQuery()

Returns the DataQuery that this DataQueryMetadata is for

Returns:
Type
data.DataQuery

getDataQueryDimension(dimensionId)

Returns the DataQueryDimension with the give id, or null if no DataQueryDimension exist with the given id.

Parameters:
Name Type Description
dimensionId string

The Id of the dimension to return

See:
Returns:
Type
data.DataQueryDimension

getDataQueryDimensions()

Returns an array of DataQueryDimension associated with this data query.

Each DataQueryDimension defines the valid filters the user can choose, these filters are represented as DataQueryCode.

The user is able to select or de-select DataQueryCodes to the DataQuery, by calling the method dataQuery.addCodeSelection() or dataQuery.removeCodeSelection()

A DataQueryDimension has a direct relationship with the DimensionBean from a DataStructureBean. This method will return a DataQueryDimension for every DimensionBean in the DataStructureBean.

The difference between a DimensionBean and a DataQueryDimension is that the DataQueryDimension only contains Codes which are known to contain data in the context of the Dataflow. The Codes are also stateful, they know if the are selected, and if they have data in the context of the current DataQuery. The Codes can also be represented as a flat list or as a Hierarchy, if there is an associated bean.hierarchicalcodelist

Returns:
Type
Array.<data.DataQueryDimension>

getReportingBegin()

Returns the reporting being date, or null if this is unknown. This represents the earliest date for which there is data for the given data query.

Returns:
Type
date

getReportingEnd()

Returns the reporting end date, or null if this is unknown. This represents the latest date for which there is data for the given data query.

Returns:
Type
date

getUpdateMetadataCompleteListener()

Returns the array of callback functions registered for update metadata function completion

See:
Returns:
  • callback

    Type
    Array.<function()>

getValidObsCount()

Returns the number of valid observations. This is updated each time the dataQueryMetadata.updateMetadata() method is invoked, and the update is based on the current query state

Note This is an estimate based on the valid series, time selections, and selected frequencies.

Returns -1 if there is not enough information required to calculate the value, this may be because there is no Frequency (FREQ) Dimension for the DataStructure associated with the DataQuery - or if the FREQ codes do not match the SDMX cross domain Frequency Codelist.

Returns:
Type
integer

getValidSeriesCount()

Returns the number of valid series keys that will be returned for the DataQuery taking into account the current code selections.

This value is updated each time the dataQueryMetadata.updateMetadata() method is invoked, and the update is based on the current query state

Returns:
Type
integer

updateMetadata(callback)

Queries the service to update the series and observation count that will be returned as a result of executing this DataQuery.

DataQueryCodes will also be updated to reflect if they have data based on the code state

Parameters:
Name Type Description
callback function

function to be invoked on completion

See: