Search in sources :

Example 1 with AssetColumn

use of bio.terra.service.dataset.AssetColumn in project jade-data-repo by DataBiosphere.

the class SnapshotService method conjureSnapshotTablesFromAsset.

/**
 * Magic up the snapshot tables and snapshot map from the asset tables and columns.
 * This method sets the table lists into snapshot and snapshotSource.
 *
 * @param asset  the one and only asset specification for this snapshot
 * @param snapshot snapshot to point back to and fill in
 * @param snapshotSource snapshotSource to point back to and fill in
 */
private void conjureSnapshotTablesFromAsset(AssetSpecification asset, Snapshot snapshot, SnapshotSource snapshotSource) {
    List<SnapshotTable> tableList = new ArrayList<>();
    List<SnapshotMapTable> mapTableList = new ArrayList<>();
    for (AssetTable assetTable : asset.getAssetTables()) {
        // Create early so we can hook up back pointers.
        SnapshotTable table = new SnapshotTable();
        // Build the column lists in parallel, so we can easily connect the
        // map column to the snapshot column.
        List<Column> columnList = new ArrayList<>();
        List<SnapshotMapColumn> mapColumnList = new ArrayList<>();
        for (AssetColumn assetColumn : assetTable.getColumns()) {
            Column column = new Column(assetColumn.getDatasetColumn());
            columnList.add(column);
            mapColumnList.add(new SnapshotMapColumn().fromColumn(assetColumn.getDatasetColumn()).toColumn(column));
        }
        table.name(assetTable.getTable().getName()).columns(columnList);
        tableList.add(table);
        mapTableList.add(new SnapshotMapTable().fromTable(assetTable.getTable()).toTable(table).snapshotMapColumns(mapColumnList));
    }
    snapshotSource.snapshotMapTables(mapTableList);
    snapshot.snapshotTables(tableList);
}
Also used : AssetTable(bio.terra.service.dataset.AssetTable) AssetColumn(bio.terra.service.dataset.AssetColumn) Column(bio.terra.common.Column) ArrayList(java.util.ArrayList) AssetColumn(bio.terra.service.dataset.AssetColumn)

Aggregations

Column (bio.terra.common.Column)1 AssetColumn (bio.terra.service.dataset.AssetColumn)1 AssetTable (bio.terra.service.dataset.AssetTable)1 ArrayList (java.util.ArrayList)1