class AnalyticsUtils {

    public static void handleGridForDataValueSet( DataQueryParams params, Grid grid )
    {
        Map<String, DimensionalItemObject> dimItemObjectMap = AnalyticsUtils.getDimensionalItemObjectMap( params );

        List<Object> cocCol = Lists.newArrayList();
        List<Object> aocCol = Lists.newArrayList();

        int dxInx = grid.getIndexOfHeader( DATA_X_DIM_ID );
        int vlInx = grid.getHeaderWidth() - 1;

        Assert.isTrue( dxInx >= 0, "Data dimension index must be greater than or equal to zero" );
        Assert.isTrue( vlInx >= 0, "Value index must be greater than or equal to zero" );

        for ( List<Object> row : grid.getRows() )
        {
            String dx = String.valueOf( row.get( dxInx ) );

            Assert.notNull( dx, "Data dimension item cannot be null" );

            DimensionalItemObject item = dimItemObjectMap.get( dx );

            Assert.notNull( item, "Dimensional item cannot be null" );

            Object value = AnalyticsUtils.getIntegerOrValue( row.get( vlInx ), item );

            row.set( vlInx, value );

            String coc = null, aoc = null;

            if ( DataDimensionalItemObject.class.isAssignableFrom( item.getClass() ) )
            {
                DataDimensionalItemObject dataItem = (DataDimensionalItemObject) item;
                coc = dataItem.getAggregateExportCategoryOptionCombo();
                aoc = dataItem.getAggregateExportAttributeOptionCombo();
            }
            else if ( DataElementOperand.class.isAssignableFrom( item.getClass() ) )
            {
                row.set( dxInx, DimensionalObjectUtils.getFirstIdentifer( dx ) );
                coc = DimensionalObjectUtils.getSecondIdentifer( dx );
            }

            cocCol.add( coc );
            aocCol.add( aoc );
        }

        grid.addHeader( vlInx, new GridHeader( ATTRIBUTEOPTIONCOMBO_DIM_ID, ATTRIBUTEOPTIONCOMBO_DIM_ID, ValueType.TEXT, String.class.getName(), false, true ) )
            .addHeader( vlInx, new GridHeader( CATEGORYOPTIONCOMBO_DIM_ID, CATEGORYOPTIONCOMBO_DIM_ID, ValueType.TEXT, String.class.getName(), false, true ) )
            .addColumn( vlInx, aocCol )
            .addColumn( vlInx, cocCol );
    }

}