Search in sources :

Example 36 with IPentahoResultSet

use of org.pentaho.commons.connection.IPentahoResultSet in project pentaho-platform by pentaho.

the class PentahoFlashChartTest method getRelationOneColData.

public static IPentahoResultSet getRelationOneColData() {
    IPentahoResultSet ips = null;
    ArrayList<String> colHeaders = new ArrayList();
    colHeaders.add(0, "DEPARTMENT");
    colHeaders.add(1, "ACTUAL");
    colHeaders.add(2, "BUDGET");
    ArrayList r1 = new ArrayList();
    r1.add("Sales");
    r1.add(11);
    ArrayList r2 = new ArrayList();
    r2.add("Finance");
    r2.add(14);
    ArrayList r3 = new ArrayList();
    r3.add("Human Resource");
    r3.add(7);
    ArrayList data = new ArrayList();
    data.add(r1);
    data.add(r2);
    data.add(r3);
    ips = MemoryResultSet.createFromLists(colHeaders, data);
    System.out.println(ips.getRowCount());
    return ips;
}
Also used : IPentahoResultSet(org.pentaho.commons.connection.IPentahoResultSet) ArrayList(java.util.ArrayList)

Example 37 with IPentahoResultSet

use of org.pentaho.commons.connection.IPentahoResultSet in project pentaho-platform by pentaho.

the class PentahoFlashChartTest method testBogusData.

@Test
public void testBogusData() {
    String chart = "<chart>" + "<chart-type>BarChart</chart-type>" + "</chart>";
    IPentahoResultSet rs = getRelationBogusData();
    Node chartNode = getChartNode(chart);
    try {
        PentahoOFC4JChartHelper.generateChartJson(chartNode, rs, false, null);
        Assert.fail();
    } catch (RuntimeException e) {
        Assert.assertTrue(e.getMessage().toLowerCase().indexOf("result set") >= 0);
    }
}
Also used : IPentahoResultSet(org.pentaho.commons.connection.IPentahoResultSet) Node(org.dom4j.Node) Test(org.junit.Test)

Example 38 with IPentahoResultSet

use of org.pentaho.commons.connection.IPentahoResultSet in project pentaho-platform by pentaho.

the class PentahoFlashChartTest method testAreaChart.

@Test
public void testAreaChart() {
    String chart = "<chart>" + "<chart-type>AreaChart</chart-type>" + "</chart>";
    IPentahoResultSet rs = getRelationData();
    Node chartNode = getChartNode(chart);
    String c2 = PentahoOFC4JChartHelper.generateChartJson(chartNode, rs, false, null);
    assertJsonEquals("{\"y_axis\":{\"min\":0,\"colour\":\"#000000\",\"grid-colour\":\"#aaaaaa\",\"stroke\":1,\"max\":110," + "\"steps\":10},\"x_legend\":{\"text\":\"DEPARTMENT\",\"style\":\"font-family: Arial; " + "font-size: 14px; " + "font-weight: normal; font-style: normal;\"},\"elements\":[{\"colour\":\"#006666\",\"text\"" + ":\"ACTUAL\"," + "\"values\":[11,14,7],\"fill\":\"#006666\",\"font-size\":10,\"fillAlpha\":0.35,\"type\":" + "\"area_line\"}," + "{\"colour\":\"#0066CC\",\"text\":\"BUDGET\",\"values\":[12,9,100],\"fill\":\"#0066CC\"," + "\"font-size\":10," + "\"fillAlpha\":0.35,\"type\":\"area_line\"}],\"x_axis\":{\"colour\":\"#000000\"," + "\"grid-colour\":\"#aaaaaa\",\"stroke\":1,\"labels\":{\"labels\":[\"Sales\",\"Finance\"," + "\"Human Resource\"]}}}", c2, when(IGNORING_ARRAY_ORDER));
}
Also used : IPentahoResultSet(org.pentaho.commons.connection.IPentahoResultSet) Node(org.dom4j.Node) Test(org.junit.Test)

Example 39 with IPentahoResultSet

use of org.pentaho.commons.connection.IPentahoResultSet in project pentaho-platform by pentaho.

the class PentahoFlashChartTest method testBubbleChart.

@Test
public void testBubbleChart() {
    String chart = "<chart>" + "<chart-type>BubbleChart</chart-type>" + "<dataset-type>XYZSeriesCollection</dataset-type>" + "</chart>";
    IPentahoResultSet rs = getXYZRelationData();
    Node chartNode = getChartNode(chart);
    String c2 = PentahoOFC4JChartHelper.generateChartJson(chartNode, rs, false, null);
    assertJsonEquals("{\"y_axis\":{\"min\":0,\"colour\":\"#000000\",\"grid-colour\":\"#aaaaaa\",\"stroke\":1,\"max\":110," + "\"steps\":10},\"x_legend\":{\"text\":\"DEPARTMENT\",\"style\":\"font-family: Arial; font-size: 14px; " + "font-weight: normal; font-style: normal;\"},\"elements\":[{\"colour\":\"#006666\",\"dot-size\":1," + "\"text\":\"Sales\",\"values\":[{\"y\":12,\"x\":11}],\"type\":\"scatter\"},{\"colour\":\"#0066CC\"," + "\"dot-size\":5,\"text\":\"Finance\",\"values\":[{\"y\":9,\"x\":14}],\"type\":\"scatter\"}," + "{\"colour\":\"#009999\",\"dot-size\":100,\"text\":\"Human Resource\",\"values\":[{\"y\":100,\"x\":7}]," + "\"type\":\"scatter\"}],\"x_axis\":{\"min\":7,\"colour\":\"#000000\",\"grid-colour\":\"#aaaaaa\"," + "\"stroke\":1,\"max\":14,\"labels\":{}}}", c2, when(IGNORING_ARRAY_ORDER));
}
Also used : IPentahoResultSet(org.pentaho.commons.connection.IPentahoResultSet) Node(org.dom4j.Node) Test(org.junit.Test)

Example 40 with IPentahoResultSet

use of org.pentaho.commons.connection.IPentahoResultSet in project pentaho-platform by pentaho.

the class PentahoFlashChartTest method testBarChart.

@Test
public void testBarChart() {
    String chart = "<chart>" + "<chart-type>BarChart</chart-type>" + "</chart>";
    IPentahoResultSet rs = getRelationData();
    Node chartNode = getChartNode(chart);
    String c2 = PentahoOFC4JChartHelper.generateChartJson(chartNode, rs, false, null);
    assertJsonEquals("{\"y_axis\":{\"min\":0,\"colour\":\"#000000\",\"grid-colour\":\"#aaaaaa\",\"stroke\":1,\"max\":121," + "\"steps\":11},\"x_legend\":{\"text\":\"DEPARTMENT\",\"style\":\"font-family: Arial; font-size: 14px; " + "font-weight: normal; font-style: normal;\"},\"elements\":[{\"colour\":\"#006666\",\"text\":\"ACTUAL\"," + "\"values\":[{\"top\":11},{\"top\":14},{\"top\":7}],\"type\":\"bar\"},{\"colour\":\"#0066CC\"," + "\"text\":\"BUDGET\",\"values\":[{\"top\":12},{\"top\":9},{\"top\":100}],\"type\":\"bar\"}]," + "\"x_axis\":{\"colour\":\"#000000\",\"grid-colour\":\"#aaaaaa\",\"stroke\":1," + "\"labels\":{\"labels\":[\"Sales\",\"Finance\",\"Human Resource\"]},\"offset\":1}}", c2, when(IGNORING_ARRAY_ORDER));
}
Also used : IPentahoResultSet(org.pentaho.commons.connection.IPentahoResultSet) Node(org.dom4j.Node) Test(org.junit.Test)

Aggregations

IPentahoResultSet (org.pentaho.commons.connection.IPentahoResultSet)113 Test (org.junit.Test)26 Node (org.dom4j.Node)18 ArrayList (java.util.ArrayList)17 IPentahoMetaData (org.pentaho.commons.connection.IPentahoMetaData)12 Iterator (java.util.Iterator)10 List (java.util.List)10 IPentahoConnection (org.pentaho.commons.connection.IPentahoConnection)10 IActionParameter (org.pentaho.platform.api.engine.IActionParameter)10 IPentahoSession (org.pentaho.platform.api.engine.IPentahoSession)10 OutputStream (java.io.OutputStream)9 ResultSetCompareAction (org.pentaho.actionsequence.dom.actions.ResultSetCompareAction)8 IRuntimeContext (org.pentaho.platform.api.engine.IRuntimeContext)8 XQConnection (org.pentaho.platform.plugin.services.connections.xquery.XQConnection)8 SQLException (java.sql.SQLException)7 HashMap (java.util.HashMap)6 StandaloneSession (org.pentaho.platform.engine.core.system.StandaloneSession)6 Map (java.util.Map)5 Set (java.util.Set)5 IPreparedComponent (org.pentaho.platform.api.data.IPreparedComponent)5