lib/Models/AbsIttCatalogItem.js
function buildValueColumns(item, tableStructures, activeCombinations) {
  // The tableStructures are from the raw data files, one per activeCombinations.
  return tableStructures.map(function(tableStructure, index) {
    var columnNames = tableStructure.getColumnNames();
    // Check that the data is not blank, and that the column names are ["Time", "Value", "REGION" (or equivalent), "Description"]
    if (columnNames.length === 0) {
      throwLoadError(item, "GetGenericData");
    } else if (
      !arraysAreEqual(columnNames, [
        "Time",
        "Value",
        item.regionConcept,
        "Description"
      ])
    ) {
      throwDataColumnsError(item, columnNames);
    }
    var absCodes = activeCombinations[index];
    // Pull out and clone the 'Value' column, and rename it to match all the codes except the region type, eg. Persons 0-4 years.
    var valueColumn = tableStructure.columns[columnNames.indexOf("Value")];
    var valueName = absCodes
      .filter(function(absCode) {
        return absCode.concept.id !== item.regionTypeConcept;
      })
      .map(function(absCode) {
        return absCode.name.trim();
      })
      .reverse() // It would be nice to specify a preferred order of codes here; reverse because "Persons 0-4 years" sounds better than "0-4 years Persons".
      .join(" ");
    valueColumn = new TableColumn(
      valueName,
      valueColumn.values,
      valueColumn.options
    );
    return valueColumn;
  });
}
function buildValueColumns(item, tableStructures, activeCombinations) {
  // The tableStructures are from the raw data files, one per activeCombinations.
  return tableStructures.map(function(tableStructure, index) {
    var columnNames = tableStructure.getColumnNames();
    // Check that the data is not blank, and that the column names are ["Time", "Value", "REGION" (or equivalent), "Description"]
    if (columnNames.length === 0) {
      throwLoadError(item, "GetGenericData");
    } else if (
      !arraysAreEqual(columnNames, [
        "Time",
        "Value",
        item.regionConcept,
        "Description"
      ])
    ) {
      throwDataColumnsError(item, columnNames);
    }
    var absCodes = activeCombinations[index];
    // Pull out and clone the 'Value' column, and rename it to match all the codes except the region type, eg. Persons 0-4 years.
    var valueColumn = tableStructure.columns[columnNames.indexOf("Value")];
    var valueName = absCodes
      .filter(function(absCode) {
        return absCode.concept.id !== item.regionTypeConcept;
      })
      .map(function(absCode) {
        return absCode.name.trim();
      })
      .reverse() // It would be nice to specify a preferred order of codes here; reverse because "Persons 0-4 years" sounds better than "0-4 years Persons".
      .join(" ");
    valueColumn = new TableColumn(
      valueName,
      valueColumn.values,
      valueColumn.options
    );
    return valueColumn;
  });
}
function buildValueColumns ( item , tableStructures , activeCombinations ) { // The tableStructures are from the raw data files, one per activeCombinations. return tableStructures . map ( function ( tableStructure , index ) { var columnNames = tableStructure . getColumnNames ( ) ; // Check that the data is not blank, and that the column names are ["Time", "Value", "REGION" (or equivalent), "Description"] if ( columnNames . length === 0 ) { throwLoadError ( item , "GetGenericData" ) ; } else if ( ! arraysAreEqual ( columnNames , [ "Time" , "Value" , item . regionConcept , "Description" ] ) ) { throwDataColumnsError ( item , columnNames ) ; } var absCodes = activeCombinations [ index ] ; // Pull out and clone the 'Value' column, and rename it to match all the codes except the region type, eg. Persons 0-4 years. var valueColumn = tableStructure . columns [ columnNames . indexOf ( "Value" ) ] ; var valueName = absCodes . filter ( function ( absCode ) { return absCode . concept . id !== item . regionTypeConcept ; } ) . map ( function ( absCode ) { return absCode . name . trim ( ) ; } ) . reverse ( ) // It would be nice to specify a preferred order of codes here; reverse because "Persons 0-4 years" sounds better than "0-4 years Persons". . join ( " " ) ; valueColumn = new TableColumn ( valueName , valueColumn . values , valueColumn . options ) ; return valueColumn ; } ) ; }
Given the loaded data files in their TableStructures, create a suitably named array of columns, from their "Value" columns.
Given the loaded data files in their TableStructures create a suitably named array of columns from their Value columns .