Examples of DataSetTableModel


Examples of org.apache.metamodel.data.DataSetTableModel

        assertTrue(data1.next());
        assertEquals("Row[values=[Australia, 430300.0]]", data1.getRow().toString());
        DataSet data2 = dataContext2.executeQuery(q);
        assertTrue(data2.next());
        assertEquals("Row[values=[Australia, 430300.0]]", data2.getRow().toString());
        assertEquals(new DataSetTableModel(data1), new DataSetTableModel(data2));
    }
View Full Code Here

Examples of org.apache.metamodel.data.DataSetTableModel

                "SELECT \"PRODUCTS\".\"PRODUCTCODE\", \"ORDERFACT\".\"ORDERNUMBER\" FROM PUBLIC.\"PRODUCTS\" INNER JOIN PUBLIC.\"ORDERFACT\" ON \"PRODUCTS\".\"PRODUCTCODE\" = \"ORDERFACT\".\"PRODUCTCODE\"",
                q.toString());
        assertEquals(25000, dc.getFetchSizeCalculator().getFetchSize(q));

        DataSet data = dc.executeQuery(q);
        TableModel tableModel = new DataSetTableModel(data);
        assertEquals(2, tableModel.getColumnCount());
        assertEquals(2996, tableModel.getRowCount());

        assertEquals(110, MetaModelHelper.executeSingleRowQuery(dc, new Query().selectCount().from(productsTable)).getValue(0));
    }
View Full Code Here

Examples of org.apache.metamodel.data.DataSetTableModel

        Column productPriceColumn = productsTable.getColumnByName("price");
        q.select(titleColumn, productPriceColumn);
        q.getSelectClause().getItem(0).setAlias("product-title");

        DataSet data = dc.executeQuery(q);
        TableModel tableModel = new DataSetTableModel(data);
        assertEquals(2, tableModel.getColumnCount());
        assertEquals(10000, tableModel.getRowCount());

        assertEquals("ACADEMY ACADEMY", tableModel.getValueAt(0, 0).toString());
        assertEquals("25.99", tableModel.getValueAt(0, 1).toString());

        assertEquals("ACADEMY HORN", tableModel.getValueAt(432, 0).toString());
        assertEquals("16.99", tableModel.getValueAt(6346, 1).toString());

        assertEquals("ALADDIN ZORRO", tableModel.getValueAt(9999, 0).toString());
        assertEquals("10.99", tableModel.getValueAt(9999, 1).toString());

        data = null;
        tableModel = null;

        Column prodIdColumn = productsTable.getColumnByName("prod_id");
        Table orderlinesTable = schema.getTableByName("orderlines");
        Column commonProdIdColumn = orderlinesTable.getColumnByName("prod_id");
        Column quantityColumn = orderlinesTable.getColumnByName("quantity");

        q.from(orderlinesTable);
        q.where(new FilterItem(new SelectItem(prodIdColumn), OperatorType.EQUALS_TO, new SelectItem(commonProdIdColumn)));
        q.groupBy(titleColumn);
        q.getSelectClause().removeItem(q.getSelectClause().getSelectItem(productPriceColumn));
        SelectItem quantitySum = new SelectItem(FunctionType.SUM, quantityColumn).setAlias("orderAmount");
        q.select(quantitySum);
        q.having(new FilterItem(quantitySum, OperatorType.GREATER_THAN, 25));
        q.orderBy(new OrderByItem(q.getSelectClause().getItem(0)));

        assertEquals("SELECT \"products\".\"title\" AS product-title, SUM(\"orderlines\".\"quantity\") AS orderAmount "
                + "FROM public.\"products\", public.\"orderlines\" "
                + "WHERE \"products\".\"prod_id\" = \"orderlines\".\"prod_id\" " + "GROUP BY \"products\".\"title\" "
                + "HAVING SUM(\"orderlines\".\"quantity\") > 25 " + "ORDER BY \"products\".\"title\" ASC", q.toString());
        data = dc.executeQuery(q);
        tableModel = new DataSetTableModel(data);
        assertEquals(2, tableModel.getColumnCount());
        assertEquals(136, tableModel.getRowCount());

        assertEquals("ACADEMY ALABAMA", tableModel.getValueAt(0, 0).toString());
        assertEquals("27", tableModel.getValueAt(0, 1).toString());

        assertEquals("AIRPORT MOURNING", tableModel.getValueAt(99, 0).toString());
        assertEquals("29", tableModel.getValueAt(99, 1).toString());

        assertEquals("ALADDIN WORKER", tableModel.getValueAt(135, 0).toString());
        assertEquals("27", tableModel.getValueAt(135, 1).toString());
    }
View Full Code Here

Examples of org.apache.metamodel.data.DataSetTableModel

    assertEquals(
        "SELECT \"CONTRIBUTORS\".\"ID\", \"CONTRIBUTORS\".\"USERNAME\", \"CONTRIBUTORS\".\"ROLE\", \"CONTRIBUTORS\".\"COUNTRY\" FROM PUBLIC.\"CONTRIBUTORS\"",
        q.toString());

    DataSet data = _dataContext.executeQuery(q);
    TableModel tableModel = new DataSetTableModel(data);
    assertEquals(4, tableModel.getColumnCount());
    assertEquals(4, tableModel.getRowCount());
  }
View Full Code Here

Examples of org.apache.metamodel.data.DataSetTableModel

    assertEquals(
        "SELECT \"projects\".\"ID\", \"projects\".\"project\", \"projects\".\"type\", \"projects\".\"admin\" FROM PUBLIC.\"projects\"",
        q.toString());

    DataSet data = _dataContext.executeQuery(q);
    TableModel tableModel = new DataSetTableModel(data);
    assertEquals(4, tableModel.getColumnCount());
    assertEquals(3, tableModel.getRowCount());
  }
View Full Code Here

Examples of org.apache.metamodel.data.DataSetTableModel

        q.toString());

    DataSet data = _dataContext.executeQuery(q);
    assertNotNull(data);

    TableModel tableModel = new DataSetTableModel(data);
    assertEquals(2, tableModel.getColumnCount());
    assertEquals(17, tableModel.getRowCount());
    assertEquals("Quality Assurance", tableModel.getValueAt(4, 0).toString());

    Date date = (Date) tableModel.getValueAt(4, 1);
    assertEquals("1989-04-17 00:00:00.000000", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSSSSS").format(date));

  }
View Full Code Here

Examples of org.apache.metamodel.data.DataSetTableModel

        + "Schema[name=sakila], Schema[name=world]]", Arrays.toString(schemas));

    Table table = dc.getSchemaByName("sakila").getTableByName("film");
    Query q = new Query().from(table).select(table.getColumns());
    DataSet data = dc.executeQuery(q);
    TableModel tableModel = new DataSetTableModel(data);
    assertEquals(13, tableModel.getColumnCount());
    assertEquals(1000, tableModel.getRowCount());
  }
View Full Code Here

Examples of org.apache.metamodel.data.DataSetTableModel

    FilterItem f1 = new FilterItem(q.getSelectClause().getItem(0), OperatorType.EQUALS_TO, 5);
    FilterItem f2 = new FilterItem(q.getSelectClause().getItem(0), OperatorType.EQUALS_TO, 8);
    q.where(new FilterItem(f1, f2));

    DataSet dataSet = dc.executeQuery(q);
    TableModel tableModel = new DataSetTableModel(dataSet);
    assertEquals(4, tableModel.getColumnCount());
    assertEquals(2, tableModel.getRowCount());
    assertEquals("LOLLOBRIGIDA", tableModel.getValueAt(0, 2));

    q.setMaxRows(1);
    dataSet = dc.executeQuery(q);
    tableModel = new DataSetTableModel(dataSet);
    assertEquals(4, tableModel.getColumnCount());
    assertEquals(1, tableModel.getRowCount());
    assertEquals("LOLLOBRIGIDA", tableModel.getValueAt(0, 2));
   
    q.setMaxRows(1);
    q.setFirstRow(2);
        dataSet = dc.executeQuery(q);
        tableModel = new DataSetTableModel(dataSet);
        assertEquals(4, tableModel.getColumnCount());
        assertEquals(1, tableModel.getRowCount());
        assertEquals("JOHANSSON", tableModel.getValueAt(0, 2));

    q.getWhereClause().removeItems();
    q.setMaxRows(25);
    q.setFirstRow(1);
    dataSet = dc.executeQuery(q);
    tableModel = new DataSetTableModel(dataSet);
    assertEquals(4, tableModel.getColumnCount());
    assertEquals(25, tableModel.getRowCount());
    assertEquals("GUINESS", tableModel.getValueAt(0, 2).toString());
  }
View Full Code Here

Examples of org.apache.metamodel.data.DataSetTableModel

        Column productPriceColumn = productsTable.getColumnByName("price");
        q.select(titleColumn, productPriceColumn);
        q.getSelectClause().getItem(0).setAlias("product-title");

        DataSet data = dc.executeQuery(q);
        TableModel tableModel = new DataSetTableModel(data);
        assertEquals(2, tableModel.getColumnCount());
        assertEquals(10000, tableModel.getRowCount());

        assertEquals("ACADEMY ACADEMY", tableModel.getValueAt(0, 0).toString());
        assertEquals("25.99", tableModel.getValueAt(0, 1).toString());

        assertEquals("ACADEMY HORN", tableModel.getValueAt(432, 0).toString());
        assertEquals("16.99", tableModel.getValueAt(6346, 1).toString());

        assertEquals("ALADDIN ZORRO", tableModel.getValueAt(9999, 0).toString());
        assertEquals("10.99", tableModel.getValueAt(9999, 1).toString());

        data = null;
        tableModel = null;

        Column prodIdColumn = productsTable.getColumnByName("prod_id");
        Table orderlinesTable = schema.getTableByName("orderlines");
        Column commonProdIdColumn = orderlinesTable.getColumnByName("prod_id");
        Column quantityColumn = orderlinesTable.getColumnByName("quantity");

        q.from(orderlinesTable);
        q.where(new FilterItem(new SelectItem(prodIdColumn), OperatorType.EQUALS_TO, new SelectItem(commonProdIdColumn)));
        q.groupBy(titleColumn);
        q.getSelectClause().removeItem(q.getSelectClause().getSelectItem(productPriceColumn));
        SelectItem quantitySum = new SelectItem(FunctionType.SUM, quantityColumn).setAlias("orderAmount");
        q.select(quantitySum);
        q.having(new FilterItem(quantitySum, OperatorType.GREATER_THAN, 25));
        q.orderBy(new OrderByItem(q.getSelectClause().getItem(0)));

        assertEquals("SELECT \"products\".\"title\" AS product-title, SUM(\"orderlines\".\"quantity\") AS orderAmount "
                + "FROM public.\"products\", public.\"orderlines\" "
                + "WHERE \"products\".\"prod_id\" = \"orderlines\".\"prod_id\" " + "GROUP BY \"products\".\"title\" "
                + "HAVING SUM(\"orderlines\".\"quantity\") > 25 " + "ORDER BY \"products\".\"title\" ASC", q.toString());
        data = dc.executeQuery(q);
        tableModel = new DataSetTableModel(data);
        assertEquals(2, tableModel.getColumnCount());
        assertEquals(136, tableModel.getRowCount());

        assertEquals("ACADEMY ALABAMA", tableModel.getValueAt(0, 0).toString());
        assertEquals("27", tableModel.getValueAt(0, 1).toString());

        assertEquals("AIRPORT MOURNING", tableModel.getValueAt(99, 0).toString());
        assertEquals("29", tableModel.getValueAt(99, 1).toString());

        assertEquals("ALADDIN WORKER", tableModel.getValueAt(135, 0).toString());
        assertEquals("27", tableModel.getValueAt(135, 1).toString());
    }
View Full Code Here

Examples of org.apache.metamodel.data.DataSetTableModel

        CsvDataContext dc = new CsvDataContext(file, semicolonConfiguration);
        Table table = dc.getDefaultSchema().getTables()[0];
        Query query = new Query().from(table).select(table.getColumns()).setMaxRows(5);
        DataSet dataSet = dc.executeQuery(query);

        TableModel tableModel = new DataSetTableModel(dataSet);
        assertEquals(5, tableModel.getRowCount());
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.