Package com.google.visualization.datasource.datatable

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


                r.renderDataTable(testData, true, true).toString());
    }

    private DataTable getTestDataTable() throws DataSourceException {
        DataTable dataTable = 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");

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


    /**
     * Tests the createColumnDescription method.
     */
    public void testCreateColumnDescription() {
        ColumnDescription simpleColumnDescription =
                new ColumnDescription("simpleColumn", ValueType.DATE, "simpleLabel");
        ColumnDescription aggreationColumnDescription =
                new ColumnDescription("min-simpleColumn", ValueType.DATE,
                        "aggLabel");
        DataTable table = new DataTable();
        table.addColumn(simpleColumnDescription);
        table.addColumn(aggreationColumnDescription);

        List<AbstractColumn> simpleColumns =
                Lists.newArrayList((AbstractColumn) new SimpleColumn("simpleColumn"));
        List<AbstractColumn> aggregationColumns =
                Lists.newArrayList((AbstractColumn) new AggregationColumn(
                        new SimpleColumn("simpleColumn"), AggregationType.MIN));
        ScalarFunctionColumnTitle titleYear =
                new ScalarFunctionColumnTitle(Lists.<Value>newArrayList(),
                        new ScalarFunctionColumn(simpleColumns,
                                TimeComponentExtractor.getInstance(
                                        TimeComponentExtractor.TimeComponent.YEAR)));

        ScalarFunctionColumnTitle titleSecondWithAggregation =
                new ScalarFunctionColumnTitle(Lists.<Value>newArrayList(),
                        new ScalarFunctionColumn(aggregationColumns,
                                TimeComponentExtractor.getInstance(
                                        TimeComponentExtractor.TimeComponent.SECOND)));

        ScalarFunctionColumnTitle titleMonthWithPivot =
                new ScalarFunctionColumnTitle(Lists.newArrayList(new NumberValue(3.14),
                        BooleanValue.TRUE), new ScalarFunctionColumn(simpleColumns,
                        TimeComponentExtractor.getInstance(
                                TimeComponentExtractor.TimeComponent.MONTH)));

        ScalarFunctionColumnTitle titleDayWithPivotAndAgg =
                new ScalarFunctionColumnTitle(Lists.newArrayList(new NumberValue(3.14),
                        BooleanValue.TRUE), new ScalarFunctionColumn(aggregationColumns,
                        TimeComponentExtractor.getInstance(
                                TimeComponentExtractor.TimeComponent.DAY)));

        ColumnDescription resultColumnDescriptionYear = titleYear.createColumnDescription(table);

        ColumnDescription resultColumnDescriptionSecondWithAgg =
                titleSecondWithAggregation.createColumnDescription(table);

        ColumnDescription resultColumnDescriptionMonthWithPivot =
                titleMonthWithPivot.createColumnDescription(table);

        ColumnDescription resultColumnDescriptionDayWithPivotAndAgg =
                titleDayWithPivotAndAgg.createColumnDescription(table);

        // Check the creation of result column description with year.
        assertEquals("year_simpleColumn", resultColumnDescriptionYear.getId());
        assertEquals(" year(simpleLabel)", resultColumnDescriptionYear.getLabel());
        assertEquals(ValueType.NUMBER, resultColumnDescriptionYear.getType());

        // Check the creation of result column description with aggregation.
        assertEquals("second_min-simpleColumn",
                resultColumnDescriptionSecondWithAgg.getId());
        assertEquals(" second(aggLabel)",
                resultColumnDescriptionSecondWithAgg.getLabel());
        assertEquals(ValueType.NUMBER,
                resultColumnDescriptionSecondWithAgg.getType());

        // Check the creation of result column description with pivot.
        assertEquals("3.14,true month_simpleColumn",
                resultColumnDescriptionMonthWithPivot.getId());
        assertEquals("3.14,true month(simpleLabel)",
                resultColumnDescriptionMonthWithPivot.getLabel());
        assertEquals(ValueType.NUMBER,
                resultColumnDescriptionMonthWithPivot.getType());

        // Check the creation of result column description with aggregation
        // and pivot.
        assertEquals("3.14,true day_min-simpleColumn",
                resultColumnDescriptionDayWithPivotAndAgg.getId());
        assertEquals("3.14,true day(aggLabel)",
                resultColumnDescriptionDayWithPivotAndAgg.getLabel());
        assertEquals(ValueType.NUMBER,
                resultColumnDescriptionDayWithPivotAndAgg.getType());
    }
View Full Code Here

        else {
            dateTimeColumnType = ValueType.DATE;
        }
       
        //Setup the date/time column description
        final ColumnDescription dateTimeColumn;
        switch (dateTimeColumnType) {
            case TIMEOFDAY: {
                dateTimeColumn = new ColumnDescription("time", dateTimeColumnType, "Time");
                break;
            }
            default: {
                dateTimeColumn = new ColumnDescription("date", dateTimeColumnType, "Date");
            }
        }
       
        final DataTable table = new JsonDataTable();
        table.addColumn(dateTimeColumn);
View Full Code Here

            // Default to group name, else portlet name
            description = groupSize == 1 && portletSize > 1 ? portletName : groupName;
        }

        final List<ColumnDescription> columnDescriptions = new ArrayList<ColumnDescription>();
        columnDescriptions.add(new ColumnDescription(description, ValueType.NUMBER, description));
        return columnDescriptions;
    }
View Full Code Here

        final String groupName = columnDiscriminator.getAggregatedGroup().getGroupName();
       
        if (form.isTotalLogins() && form.isUniqueLogins()) {
            return ImmutableList.of(
                    //THE ORDER OF RETURNED COLUMNS HERE MUST MATCH THE ORDER OF THE VALUES RETURNED IN createRowValues
                    new ColumnDescription(groupName + "-uniqueLogins", ValueType.NUMBER, groupName + " - Unique Logins"),
                    new ColumnDescription(groupName + "-totalLogins", ValueType.NUMBER, groupName + " - Total Logins")
                );
        }
        else if (form.isUniqueLogins()) {
            return Collections.singletonList(new ColumnDescription(groupName + "-uniqueLogins", ValueType.NUMBER, groupName + " - Unique Logins"));
        }
        else {
            return Collections.singletonList(new ColumnDescription(groupName + "-totalLogins", ValueType.NUMBER, groupName + " - Total Logins"));
        }
    }
View Full Code Here

        if (multipleValues == 0 || items.length == 1) {
            description = items[0].getCriteriaItem();
        }

        final List<ColumnDescription> columnDescriptions = new ArrayList<ColumnDescription>();
        columnDescriptions.add(new ColumnDescription(description, ValueType.NUMBER, description));
        return columnDescriptions;
    }
View Full Code Here

    }
   
    @Override
    protected List<ColumnDescription> getColumnDescriptions(ConcurrentUserAggregationDiscriminator discriminator, ConcurrentUserReportForm form) {
        final String groupName = discriminator.getAggregatedGroup().getGroupName();
        return Collections.singletonList(new ColumnDescription(groupName, ValueType.NUMBER, groupName));
    }
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

      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 {
        for (int colIndex : colIndices) {
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

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.