Class ChartAction
- java.lang.Object
-
- org.pentaho.platform.plugin.action.chartbeans.ChartAction
-
- All Implemented Interfaces:
org.pentaho.platform.api.action.IAction,org.pentaho.platform.api.action.IStreamingAction
public class ChartAction extends Object implements org.pentaho.platform.api.action.IStreamingAction
This class was adapted fromChartComponentby cboyden This is a bean that permits easy access to the ChartBeans functionality and was specifically designed to be run from within the Pentaho Platform as an Action Sequence Action.- Author:
- cboyden, aphillips
-
-
Field Summary
Fields Modifier and Type Field Description protected ExceptionbootExceptionprotected intcategoryColumnprotected StringcategoryColumnNameprotected OutputStreamchartContentStreamprotected org.pentaho.commons.connection.IPentahoResultSetchartDataprotected StringchartEngineprotected intchartHeightprotected org.pentaho.chart.model.ChartModelchartModelprotected StringchartModelJsonprotected StringchartModelXmlprotected intchartWidthprotected StringcontentLinkingTemplateprotected booleanconvertNullsToZeroprotected static intDEFAULT_CHART_HEIGHTprotected static intDEFAULT_CHART_WIDTHprotected StringoutputTypeprotected NumberscalingFactorprotected intseriesColumnprotected StringseriesColumnNameprotected Stringtitleprotected intvalueColumnprotected StringvalueColumnName
-
Constructor Summary
Constructors Constructor Description ChartAction()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidexecute()Called to process the chart definition and data set to produce a usable chart.StringgetChartEngine()Get the chart engine that the resulting chart was created throughbooleangetConvertNullsToZero()StringgetMimeType(String streamPropertyName)protected org.pentaho.chart.plugin.api.IOutput.OutputTypesgetOutputType()Fetch the desired output typeStringgetSwfName()StringgetSwfPath()protected voidloadChartEngine()Sets the chart engine based on the order of precedence: 1) Chart Definition 2) Action Sequence 3) System Setting 4) Hard Codedprotected voidloadChartModel()protected Object[][]processChartData(org.pentaho.commons.connection.IPentahoResultSet resultSet, int valueColumnIndex)Transform the IPentahoResultSet into the data format suitable for chart creation.voidsetCategoryColumn(String categoryCol)Define the column in the data set that contains the Category datavoidsetChartContentStream(OutputStream outStream)Define the OutputStream to which the resulting chart shall be writtenvoidsetChartData(org.pentaho.commons.connection.IPentahoResultSet chartDataSet)Define the data set that will populate the chartvoidsetChartEngine(String chartEngine)Set the chart engine to render the chartvoidsetChartHeight(int chartHeight)Set the height of the chart in units specific to the ChartPluginvoidsetChartHeight(String chartHeight)Set the height of the chart in units specific to the ChartPluginvoidsetChartModel(org.pentaho.chart.model.ChartModel chartModel)Set the ChartModelvoidsetChartModelJson(String chartModelJson)Set the JSON representation of the ChartModelvoidsetChartModelXml(String chartModelXml)Set the XML representation of the ChartModelvoidsetChartModelXmlStream(InputStream chartModelStream)Set the XML representation of the ChartModel as an InputStreamvoidsetChartWidth(int chartWidth)Set the width of the chart in units specific to the ChartPluginvoidsetChartWidth(String chartWidth)Set the width of the chart in units specific to the ChartPluginvoidsetContentLinkingTemplate(String template)voidsetConvertNullsToZero(boolean convert)voidsetOutputStream(OutputStream outputStream)voidsetOutputType(String outputType)voidsetScalingFactor(Double scalingFactor)voidsetSeriesColumn(String seriesCol)Define the column in the data set that contains the Series/Domain datavoidsetValueColumn(String valueCol)Define the column in the data set that contains the Value/Range datavoidvalidate()Validate the current settings of the ChartAction.
-
-
-
Field Detail
-
DEFAULT_CHART_WIDTH
protected static final int DEFAULT_CHART_WIDTH
- See Also:
- Constant Field Values
-
DEFAULT_CHART_HEIGHT
protected static final int DEFAULT_CHART_HEIGHT
- See Also:
- Constant Field Values
-
convertNullsToZero
protected boolean convertNullsToZero
-
seriesColumnName
protected String seriesColumnName
-
seriesColumn
protected int seriesColumn
-
categoryColumnName
protected String categoryColumnName
-
categoryColumn
protected int categoryColumn
-
valueColumnName
protected String valueColumnName
-
valueColumn
protected int valueColumn
-
chartData
protected org.pentaho.commons.connection.IPentahoResultSet chartData
-
chartEngine
protected String chartEngine
-
bootException
protected Exception bootException
-
outputType
protected String outputType
-
chartWidth
protected int chartWidth
-
chartHeight
protected int chartHeight
-
contentLinkingTemplate
protected String contentLinkingTemplate
-
scalingFactor
protected Number scalingFactor
-
chartContentStream
protected OutputStream chartContentStream
-
chartModelJson
protected String chartModelJson
-
chartModelXml
protected String chartModelXml
-
chartModel
protected org.pentaho.chart.model.ChartModel chartModel
-
title
protected String title
-
-
Method Detail
-
execute
public void execute() throws ExceptionCalled to process the chart definition and data set to produce a usable chart.- Specified by:
executein interfaceorg.pentaho.platform.api.action.IAction- Throws:
ChartBootExceptionChartProcessingExceptionResourceExceptionInvalidChartDefinitionIOExceptionPersistenceExceptionException- See Also:
IAction.execute()
-
setContentLinkingTemplate
public void setContentLinkingTemplate(String template)
-
processChartData
protected Object[][] processChartData(org.pentaho.commons.connection.IPentahoResultSet resultSet, int valueColumnIndex)
Transform the IPentahoResultSet into the data format suitable for chart creation.- Returns:
- Row / Column data table or null
-
setOutputStream
public void setOutputStream(OutputStream outputStream)
- Specified by:
setOutputStreamin interfaceorg.pentaho.platform.api.action.IStreamingAction
-
setChartContentStream
public void setChartContentStream(OutputStream outStream)
Define the OutputStream to which the resulting chart shall be written- Parameters:
outStream- Stream to receive the chart
-
setChartData
public void setChartData(org.pentaho.commons.connection.IPentahoResultSet chartDataSet)
Define the data set that will populate the chart- Parameters:
chartDataSet- data set for charting
-
validate
public void validate() throws ExceptionValidate the current settings of the ChartAction. If validate() returns true, then execute may be called. If validate() returns false, a call to execute() is guaranteed to fail.- Throws:
Exception
-
setSeriesColumn
public void setSeriesColumn(String seriesCol)
Define the column in the data set that contains the Series/Domain data- Parameters:
seriesCol- name of column that contains the Series/Domain for the chart
-
setConvertNullsToZero
public void setConvertNullsToZero(boolean convert)
-
getConvertNullsToZero
public boolean getConvertNullsToZero()
-
setCategoryColumn
public void setCategoryColumn(String categoryCol)
Define the column in the data set that contains the Category data- Parameters:
seriesCol- name of column that contains the Category for the chart
-
setValueColumn
public void setValueColumn(String valueCol)
Define the column in the data set that contains the Value/Range data- Parameters:
seriesCol- name of column that contains the Value/Range for the chart
-
getOutputType
protected org.pentaho.chart.plugin.api.IOutput.OutputTypes getOutputType()
Fetch the desired output type- Returns:
- output type
-
getMimeType
public String getMimeType(String streamPropertyName)
- Specified by:
getMimeTypein interfaceorg.pentaho.platform.api.action.IStreamingAction
-
loadChartEngine
protected void loadChartEngine()
Sets the chart engine based on the order of precedence: 1) Chart Definition 2) Action Sequence 3) System Setting 4) Hard Coded
-
loadChartModel
protected void loadChartModel()
-
setChartModelJson
public void setChartModelJson(String chartModelJson)
Set the JSON representation of the ChartModel- Parameters:
chartModelJson- JSON serialized representation of the ChartModel
-
setChartModelXmlStream
public void setChartModelXmlStream(InputStream chartModelStream) throws IOException
Set the XML representation of the ChartModel as an InputStream- Parameters:
chartModelStream- XML serialized representation of the ChartModel- Throws:
IOException- if there is a problem converting the input stream to an encoded string
-
setChartModelXml
public void setChartModelXml(String chartModelXml)
Set the XML representation of the ChartModel- Parameters:
chartStyleXml- XML serialized representation of the ChartModel
-
setChartModel
public void setChartModel(org.pentaho.chart.model.ChartModel chartModel)
Set the ChartModel- Parameters:
chartModel- model of the chart to be generated
-
setChartWidth
public void setChartWidth(int chartWidth)
Set the width of the chart in units specific to the ChartPlugin- Parameters:
chartWidth- width of the chart
-
setChartHeight
public void setChartHeight(int chartHeight)
Set the height of the chart in units specific to the ChartPlugin- Parameters:
chartHeight- height of the chart
-
setChartWidth
public void setChartWidth(String chartWidth)
Set the width of the chart in units specific to the ChartPlugin- Parameters:
chartWidth- width of the chart
-
setChartHeight
public void setChartHeight(String chartHeight)
Set the height of the chart in units specific to the ChartPlugin- Parameters:
chartHeight- height of the chart
-
getChartEngine
public String getChartEngine()
Get the chart engine that the resulting chart was created through- Returns:
-
setChartEngine
public void setChartEngine(String chartEngine)
Set the chart engine to render the chart- Parameters:
chartEngine- Value of "JFreeChart" or "OpenFlashChart"
-
setOutputType
public void setOutputType(String outputType)
-
setScalingFactor
public void setScalingFactor(Double scalingFactor)
-
getSwfPath
public String getSwfPath()
-
getSwfName
public String getSwfName()
-
-