Package com.google.visualization.datasource.datatable

Examples of com.google.visualization.datasource.datatable.ColumnDescription


    public ColumnDescription createColumnDescription(DataTable originalTable) {
        String columnId = createIdPivotPrefix() + scalarFunctionColumn.getId();
        ValueType type = scalarFunctionColumn.getValueType(originalTable);
        String label = createLabelPivotPart() + " " +
                getColumnDescriptionLabel(originalTable, scalarFunctionColumn);
        ColumnDescription result = new ColumnDescription(columnId, type, label);

        return result;
    }
View Full Code Here


            selectedIndices.addAll(colIndices);
            // If the selected column does not exist in the columnIndices, then it is
            // a scalar function column that was not in the original table, and was not
            // calculated in the grouping and pivoting stage.
            if(colIndices.size() == 0) {
                newColumnDescriptions.add(new ColumnDescription(col.getId(),
                        col.getValueType(table),
                        ScalarFunctionColumnTitle.getColumnDescriptionLabel(table, col)));
                newColumnIndices.put(col, currIndex++);
            }
            else {
View Full Code Here

        // Add to the table description the scalar function columns included in the
        // group and pivot. The groups of rows are defined according to the
        // values of those columns, and so it is necessary to add them before the
        // calculations of the groups, pivots and aggregations.
        for(ScalarFunctionColumn column : groupAndPivotScalarFunctionColumns) {
            newColumnDescriptions.add(new ColumnDescription(column.getId(),
                    column.getValueType(table),
                    ScalarFunctionColumnTitle.getColumnDescriptionLabel(table, column)));
        }

        DataTable tempTable = new DataTable();
View Full Code Here

                columnDescriptions.get(indices.get(0)).setLabel(label);
            }
            else {
                String columnId = column.getId(); // Without pivot values.
                for(int i : indices) {
                    ColumnDescription colDesc = columnDescriptions.get(i);
                    String colDescId = colDesc.getId(); // Includes pivot values.
                    String specificLabel =
                            colDescId.substring(0, colDescId.length() - columnId.length()) + label;
                    columnDescriptions.get(i).setLabel(specificLabel);
                }
View Full Code Here

        for(AbstractColumn col : queryFormat.getColumns()) {
            String pattern = queryFormat.getPattern(col);
            List<Integer> indices = columnIndices.getColumnIndices(col);
            boolean allSucceeded = true;
            for(int i : indices) {
                ColumnDescription colDesc = columnDescriptions.get(i);
                ValueFormatter f = ValueFormatter.createFromPattern(colDesc.getType(), pattern, locale);
                if(f == null) {
                    allSucceeded = false;
                }
                else {
                    indexToFormatter.put(i, f);
View Full Code Here

    /**
     * Tests the createAggregationColumnDescription.
     */
    public void testCreateAggregationColumnDescription() {
        ColumnDescription columnDescription = new ColumnDescription("id",
                ValueType.TEXT, "label");


        ColumnTitle columnTitleCount = new ColumnTitle(Lists.<Value>newArrayList(),
                new AggregationColumn(new SimpleColumn("id"),
                        AggregationType.COUNT), false);

        ColumnTitle columnTitleMin = new ColumnTitle(Lists.<Value>newArrayList(),
                new AggregationColumn(new SimpleColumn("id"),
                        AggregationType.MIN), true);

        ColumnTitle columnTitleCountWithPivot =
                new ColumnTitle(Lists.newArrayList(new NumberValue(3.14),
                        BooleanValue.TRUE), new AggregationColumn(new SimpleColumn("id"),
                        AggregationType.COUNT), false);

        ColumnTitle columnTitleMinWithPivot =
                new ColumnTitle(Lists.newArrayList(new NumberValue(3.14),
                        BooleanValue.TRUE), new AggregationColumn(new SimpleColumn("id"),
                        AggregationType.MIN), true);


        ColumnDescription resultColumnDescriptionCount =
                columnTitleCount.createAggregationColumnDescription(columnDescription);

        ColumnDescription resultColumnDescriptionMin =
                columnTitleMin.createAggregationColumnDescription(columnDescription);

        ColumnDescription resultColumnDescriptionCountWithPivot =
                columnTitleCountWithPivot.createAggregationColumnDescription(columnDescription);

        ColumnDescription resultColumnDescriptionMinWithPivot =
                columnTitleMinWithPivot.createAggregationColumnDescription(columnDescription);

        // Check the creation of result column description with aggregation
        // type count.
        assertEquals("count-id", resultColumnDescriptionCount.getId());
        assertEquals("count label", resultColumnDescriptionCount.getLabel());
        assertEquals(ValueType.NUMBER, resultColumnDescriptionCount.getType());

        // Check the creation of result column description with aggregation
        // type min.
        assertEquals("min-id", resultColumnDescriptionMin.getId());
        assertEquals("min label", resultColumnDescriptionMin.getLabel());
        assertEquals(ValueType.TEXT, resultColumnDescriptionMin.getType());

        // Check the creation of result column description with aggregation
        // type count with pivot and single aggregation.
        assertEquals("3.14,true count-id", resultColumnDescriptionCountWithPivot.getId());
        assertEquals("3.14,true", resultColumnDescriptionCountWithPivot.getLabel());
        assertEquals(ValueType.NUMBER, resultColumnDescriptionCountWithPivot.getType());

        // Check the creation of result column description with aggregation
        // type min with pivot, multi-aggregation.
        assertEquals("3.14,true min-id",
                resultColumnDescriptionMinWithPivot.getId());
        assertEquals("3.14,true min label",
                resultColumnDescriptionMinWithPivot.getLabel());
        assertEquals(ValueType.TEXT, resultColumnDescriptionMinWithPivot.getType());
    }
View Full Code Here

    @Override
    public void setUp() throws Exception {
        super.setUp();

        input = new DataTable();
        input.addColumn(new ColumnDescription("name", ValueType.TEXT, "label0"));
        input.addColumn(new ColumnDescription("weight", ValueType.NUMBER, "label1"));
        input.addColumn(new ColumnDescription("isPig", ValueType.BOOLEAN, "label2"));

        TableRow row;

        row = new TableRow();
        row.addCell(new TableCell(new TextValue("aaa")));
View Full Code Here

    public void testSimpleDataTableToHtml() throws DataSourceException {
        DataTable testData;
        List<TableRow> rows;

        testData = new DataTable();
        ColumnDescription c0 = new ColumnDescription("A", ValueType.TEXT, "col0");
        ColumnDescription c1 = new ColumnDescription("B", ValueType.NUMBER, "col1");
        ColumnDescription c2 = new ColumnDescription("C", ValueType.BOOLEAN, "col2");

        testData.addColumn(c0);
        testData.addColumn(c1);
        testData.addColumn(c2);
View Full Code Here

    public void testWarnings() throws DataSourceException {
        DataTable testData;
        List<TableRow> rows;

        testData = new DataTable();
        ColumnDescription c0 = new ColumnDescription("A", ValueType.TEXT, "col0");
        ColumnDescription c1 = new ColumnDescription("B", ValueType.NUMBER, "col1");

        testData.addColumn(c0);
        testData.addColumn(c1);

        rows = Lists.newArrayList();
View Full Code Here

        StringBuilder sb = new StringBuilder();
        sb.append("{");
        sb.append("\"cols\":["); // column descriptions.

        ColumnDescription col;
        for(int colId = 0; colId < columnDescriptions.size(); colId++) {
            col = columnDescriptions.get(colId);
            appendColumnDescriptionJson(col, sb);
            if(colId != (columnDescriptions.size() - 1)) {
                sb.append(",");
            }
        }
        sb.append("]"); // columns.

        if(includeValues) {
            sb.append(",\"rows\":[");
            List<TableCell> cells;
            TableCell cell;
            ColumnDescription columnDescription;

            List<TableRow> rows = dataTable.getRows();
            for(int rowId = 0; rowId < rows.size(); rowId++) {
                TableRow tableRow = rows.get(rowId);
                cells = tableRow.getCells();
View Full Code Here

TOP

Related Classes of com.google.visualization.datasource.datatable.ColumnDescription

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.