Search in sources :

Example 46 with Node

use of org.dom4j.Node in project pentaho-platform by pentaho.

the class PentahoFlashChartTest method getChartNode.

public static Node getChartNode(String xml) {
    try {
        Document chartDocument = XmlDom4JHelper.getDocFromString(xml, new PentahoEntityResolver());
        Node chartNode = chartDocument.selectSingleNode("chart");
        if (chartNode == null) {
            chartNode = chartDocument.selectSingleNode("chart-attributes");
        }
        return chartNode;
    } catch (XmlParseException e) {
        e.printStackTrace();
    }
    return null;
}
Also used : Node(org.dom4j.Node) XmlParseException(org.pentaho.platform.api.util.XmlParseException) Document(org.dom4j.Document) PentahoEntityResolver(org.pentaho.platform.engine.services.solution.PentahoEntityResolver)

Example 47 with Node

use of org.dom4j.Node 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 48 with Node

use of org.dom4j.Node 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 49 with Node

use of org.dom4j.Node 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 50 with Node

use of org.dom4j.Node 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

Node (org.dom4j.Node)253 Document (org.dom4j.Document)83 Element (org.dom4j.Element)61 ArrayList (java.util.ArrayList)56 List (java.util.List)54 Test (org.junit.Test)40 SAXReader (org.dom4j.io.SAXReader)28 File (java.io.File)25 Iterator (java.util.Iterator)18 ReturnedDocument (org.collectionspace.chain.csp.persistence.services.connection.ReturnedDocument)18 IPentahoResultSet (org.pentaho.commons.connection.IPentahoResultSet)18 HashMap (java.util.HashMap)16 URL (java.net.URL)15 ReturnedMultipartDocument (org.collectionspace.chain.csp.persistence.services.connection.ReturnedMultipartDocument)15 InputStream (java.io.InputStream)14 Attribute (org.dom4j.Attribute)14 Image (java.awt.Image)12 ConnectionException (org.collectionspace.chain.csp.persistence.services.connection.ConnectionException)11 VFSItem (org.olat.core.util.vfs.VFSItem)10 VFSLeaf (org.olat.core.util.vfs.VFSLeaf)10