Search in sources :

Example 6 with MemoryResultSet

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

the class JavaScriptResultSetIT method testPeek.

public void testPeek() {
    MemoryMetaData metadata = new MemoryMetaData(new String[][] { { "col1", "col2" } }, null);
    MemoryResultSet dataSet = new MemoryResultSet(metadata);
    JavaScriptResultSet data = new JavaScriptResultSet();
    data.setResultSet(dataSet);
    data.addRow(new Object[] { "a", new Integer(1) });
    data.addRow(new Object[] { "b", new Integer(2) });
    data.addRow(new Object[] { "c", new Integer(3) });
    Object[] row = data.peek();
    assertEquals("a", row[0]);
    assertEquals(1, row[1]);
    row = data.peek();
    assertEquals("a", row[0]);
    assertEquals(1, row[1]);
    row = data.peek();
    assertEquals("a", row[0]);
    assertEquals(1, row[1]);
    row = data.next();
    assertEquals("a", row[0]);
    assertEquals(1, row[1]);
    row = data.peek();
    assertEquals("b", row[0]);
    assertEquals(2, row[1]);
    row = data.peek();
    assertEquals("b", row[0]);
    assertEquals(2, row[1]);
    row = data.next();
    assertEquals("b", row[0]);
    assertEquals(2, row[1]);
    row = data.peek();
    assertEquals("c", row[0]);
    assertEquals(3, row[1]);
    row = data.peek();
    assertEquals("c", row[0]);
    assertEquals(3, row[1]);
    row = data.next();
    assertEquals("c", row[0]);
    assertEquals(3, row[1]);
    row = data.peek();
    assertNull(row);
    row = data.peek();
    assertNull(row);
    row = data.peek();
    assertNull(row);
    row = data.next();
    assertNull(row);
    data.beforeFirst();
    row = data.peek();
    assertEquals("a", row[0]);
    assertEquals(1, row[1]);
}
Also used : JavaScriptResultSet(org.pentaho.platform.plugin.services.connections.javascript.JavaScriptResultSet) MemoryMetaData(org.pentaho.commons.connection.memory.MemoryMetaData) MemoryResultSet(org.pentaho.commons.connection.memory.MemoryResultSet)

Example 7 with MemoryResultSet

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

the class JavaScriptResultSetIT method testAddRow.

public void testAddRow() {
    MemoryMetaData metadata = new MemoryMetaData(new String[][] { { "col1", "col2" } }, null);
    MemoryResultSet dataSet = new MemoryResultSet(metadata);
    JavaScriptResultSet data = new JavaScriptResultSet();
    data.setResultSet(dataSet);
    data.addRow(new Object[] { "a", new Integer(1) });
    data.addRow(new Object[] { "b", new Integer(2) });
    data.addRow(new Object[] { "c", new Integer(3) });
    assertEquals(3, data.getRowCount());
    assertEquals("a", data.getValueAt(0, 0));
    assertEquals(1, data.getValueAt(0, 1));
    assertEquals("b", data.getValueAt(1, 0));
    assertEquals(2, data.getValueAt(1, 1));
    assertEquals("c", data.getValueAt(2, 0));
    assertEquals(3, data.getValueAt(2, 1));
}
Also used : JavaScriptResultSet(org.pentaho.platform.plugin.services.connections.javascript.JavaScriptResultSet) MemoryMetaData(org.pentaho.commons.connection.memory.MemoryMetaData) MemoryResultSet(org.pentaho.commons.connection.memory.MemoryResultSet)

Example 8 with MemoryResultSet

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

the class MultipleComponentIT method getResultSet2.

private IPentahoResultSet getResultSet2() {
    // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    Object[][] columnHeaders = new Object[][] { { "COL1", "COL2", "COL3" } };
    List columnHeadersList = new ArrayList();
    // $NON-NLS-1$
    columnHeadersList.add("COL1");
    // $NON-NLS-1$
    columnHeadersList.add("COL2");
    // $NON-NLS-1$
    columnHeadersList.add("COL3");
    MemoryMetaData md2 = new MemoryMetaData(columnHeaders, null);
    // emd.getAttribute(1, 1, "COL1"); //$NON-NLS-1$
    // emd.setBusinessColumns(columnHeadersList);
    MemoryResultSet rs = new MemoryResultSet(md2);
    // $NON-NLS-1$ //$NON-NLS-2$
    rs.addRow(new Object[] { "DATA1", "DATA2", new Date() });
    return rs;
}
Also used : ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) MemoryMetaData(org.pentaho.commons.connection.memory.MemoryMetaData) Date(java.util.Date) MemoryResultSet(org.pentaho.commons.connection.memory.MemoryResultSet)

Example 9 with MemoryResultSet

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

the class MultipleComponentIT method getResultSet3.

private IPentahoResultSet getResultSet3() {
    List columnHeadersList = new ArrayList();
    // $NON-NLS-1$
    columnHeadersList.add("COL1");
    // $NON-NLS-1$
    columnHeadersList.add("COL2");
    // $NON-NLS-1$
    columnHeadersList.add("COL3");
    MemoryMetaData md3 = new MemoryMetaData(columnHeadersList);
    MemoryResultSet rs = new MemoryResultSet(md3);
    // $NON-NLS-1$ //$NON-NLS-2$
    rs.addRow(new Object[] { "DATA1", "DATA2", new Date() });
    return rs;
}
Also used : ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) MemoryMetaData(org.pentaho.commons.connection.memory.MemoryMetaData) Date(java.util.Date) MemoryResultSet(org.pentaho.commons.connection.memory.MemoryResultSet)

Example 10 with MemoryResultSet

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

the class DialChartComponent method createChart.

@Override
public Dataset createChart(final Document doc) {
    // get the chart node from the document
    // $NON-NLS-1$
    Node chartAttributes = doc.selectSingleNode("//" + AbstractChartComponent.CHART_NODE_NAME);
    // Try to retrieve the data values from the <data> XML block
    if (actionPath != null) {
        values = getActionData();
    }
    // No <data> node; check for <dialvalue>, <dialmaximum>, <dialminimum> nodes
    if (values == null) {
        Node valueNode = chartAttributes.selectSingleNode(DialChartComponent.VALUE_NODE_NAME);
        Node maxValueNode = chartAttributes.selectSingleNode(DialChartComponent.MAXVALUE_NODE_NAME);
        Node minValueNode = chartAttributes.selectSingleNode(DialChartComponent.MINVALUE_NODE_NAME);
        double val = 0;
        double min = -1;
        double max = -1;
        if (valueNode != null) {
            try {
                val = Double.parseDouble(valueNode.getText());
            } catch (Exception e) {
                AbstractChartComponent.logger.error(Messages.getInstance().getErrorString("DIALCHARTCOMPONENT.ERROR_0001_ERROR_PARSING_VALUE", valueNode.getText()), // $NON-NLS-1$
                e);
                val = 0;
            }
            if ((minValueNode != null) && (maxValueNode != null)) {
                try {
                    min = Double.parseDouble(minValueNode.getText());
                    max = Double.parseDouble(maxValueNode.getText());
                } catch (Exception e) {
                    AbstractChartComponent.logger.error(Messages.getInstance().getErrorString(// $NON-NLS-1$
                    "DIALCHARTCOMPONENT.ERROR_0001_ERROR_PARSING_VALUE", minValueNode.getText(), maxValueNode.getText()), e);
                    min = -1;
                    max = -1;
                }
            }
            // Its OK if there is no min and max - we will derive it later if absent.
            MemoryResultSet set = new MemoryResultSet();
            if ((min == -1) && (max == -1)) {
                set.addRow(new Object[] { new Double(val) });
            } else {
                set.addRow(new Object[] { new Double(val), new Double(min), new Double(max) });
            }
            values = set;
        }
    }
    // If, at this point, the values object is null, we will continue to execute, and assume
    // the user is has set the dial value using the API.
    // create the definition
    DialWidgetDefinition chartDefinition = new DialWidgetDefinition((IPentahoResultSet) values, byRow, chartAttributes, width, height, getSession());
    // If value gets set, all other data methods executed previously are overridden.
    if (value != null) {
        chartDefinition.setValue(value.doubleValue());
        chartDefinition.deriveMinMax(value.doubleValue());
    }
    // set the misc values from chartDefinition
    setChartType(JFreeChartEngine.DIAL_CHART_TYPE);
    setTitle(chartDefinition.getTitle());
    // get the URL template
    Node urlTemplateNode = chartAttributes.selectSingleNode(AbstractChartComponent.URLTEMPLATE_NODE_NAME);
    if (urlTemplateNode != null) {
        setUrlTemplate(urlTemplateNode.getText());
    }
    if ((chartDefinition.getWidth() != -1) && (width == -1)) {
        setWidth(chartDefinition.getWidth());
    }
    if ((chartDefinition.getHeight() != -1) && (height == -1)) {
        setHeight(chartDefinition.getHeight());
    }
    return chartDefinition;
}
Also used : Node(org.dom4j.Node) MemoryResultSet(org.pentaho.commons.connection.memory.MemoryResultSet)

Aggregations

MemoryResultSet (org.pentaho.commons.connection.memory.MemoryResultSet)31 MemoryMetaData (org.pentaho.commons.connection.memory.MemoryMetaData)24 IPentahoMetaData (org.pentaho.commons.connection.IPentahoMetaData)7 JavaScriptResultSet (org.pentaho.platform.plugin.services.connections.javascript.JavaScriptResultSet)7 Date (java.util.Date)3 ArrayList (java.util.ArrayList)2 List (java.util.List)2 RowMetaInterface (org.pentaho.di.core.row.RowMetaInterface)2 StepMetaDataCombi (org.pentaho.di.trans.step.StepMetaDataCombi)2 SQLException (java.sql.SQLException)1 HashMap (java.util.HashMap)1 Iterator (java.util.Iterator)1 Map (java.util.Map)1 StringTokenizer (java.util.StringTokenizer)1 MimeHeaders (javax.xml.soap.MimeHeaders)1 Name (javax.xml.soap.Name)1 Node (javax.xml.soap.Node)1 SOAPBody (javax.xml.soap.SOAPBody)1 SOAPConnection (javax.xml.soap.SOAPConnection)1 SOAPElement (javax.xml.soap.SOAPElement)1