use of org.dom4j.Node in project pentaho-platform by pentaho.
the class WidgetGridComponent method setDataAction.
public boolean setDataAction(final String widgetGridDataDefinition) {
try {
Document dataActionDocument = null;
try {
org.dom4j.io.SAXReader reader = XMLParserFactoryProducer.getSAXReader(new SolutionURIResolver());
dataActionDocument = reader.read(ActionSequenceResource.getInputStream(widgetGridDataDefinition, LocaleHelper.getLocale()));
} catch (Throwable t) {
return false;
}
// $NON-NLS-1$
Node dataNode = dataActionDocument.selectSingleNode("widgetgrid/data");
// $NON-NLS-1$
solution = XmlDom4JHelper.getNodeText("data-solution", dataNode);
// $NON-NLS-1$
actionPath = XmlDom4JHelper.getNodeText("data-path", dataNode);
// $NON-NLS-1$
actionName = XmlDom4JHelper.getNodeText("data-action", dataNode);
// $NON-NLS-1$
actionOutput = XmlDom4JHelper.getNodeText("data-output", dataNode);
// $NON-NLS-1$
valueItem = XmlDom4JHelper.getNodeText("data-value", dataNode);
// $NON-NLS-1$
nameItem = XmlDom4JHelper.getNodeText("data-name", dataNode);
// $NON-NLS-1$
widgetWidth = (int) XmlDom4JHelper.getNodeText("widgetgrid/width", dataActionDocument, 125);
// $NON-NLS-1$
widgetHeight = (int) XmlDom4JHelper.getNodeText("widgetgrid/height", dataActionDocument, 125);
// $NON-NLS-1$
columns = (int) XmlDom4JHelper.getNodeText("widgetgrid/columns", dataActionDocument, 2);
// $NON-NLS-1$
style = XmlDom4JHelper.getNodeText("widgetgrid/style", dataActionDocument);
} catch (Exception e) {
error(Messages.getInstance().getErrorString("WidgetGrid.ERROR_0003_DEFINITION_NOT_VALID", widgetGridDataDefinition), // $NON-NLS-1$
e);
return false;
}
return true;
}
use of org.dom4j.Node in project pentaho-platform by pentaho.
the class InputFormComponent method getXmlContent.
/*
* (non-Javadoc)
*
* @see org.pentaho.core.ui.component.BaseUIComponent#getXmlContent()
*/
@Override
public Document getXmlContent() {
ActionSequenceJCRHelper actionHelper = new ActionSequenceJCRHelper(getSession());
IActionSequence actionSequence = actionHelper.getActionSequence(ActionInfo.buildSolutionPath(solution, path, actionName), getLoggingLevel(), RepositoryFilePermission.READ);
if (actionSequence == null) {
// TODO log this
// $NON-NLS-1$
error(Messages.getInstance().getString("InputForm.ERROR_0004_ACTION_NOT_FOUND") + solution + path + actionName);
return null;
}
List actions = actionSequence.getActionDefinitionsAndSequences();
ISolutionActionDefinition action = (ISolutionActionDefinition) actions.get(0);
Node node = action.getComponentSection();
if (node == null) {
// $NON-NLS-1$
error(Messages.getInstance().getString("InputForm.ERROR_0005_INBOX_DEFINITION_MISSING") + solution + path + actionName);
return null;
}
if (templateName == null) {
// see if the template is specified in the action document
// $NON-NLS-1$
Node templateNode = node.selectSingleNode("//template");
if (templateNode != null) {
templateName = templateNode.getText();
}
if (templateName == null) {
// $NON-NLS-1$
error(Messages.getInstance().getString("InputForm.ERROR_0006_TEMPLATE_NOT_SPECIFIED"));
return null;
}
}
// $NON-NLS-1$
Node xFormNode = node.selectSingleNode("//xForm");
try {
String actionTitle = actionSequence.getTitle();
if (actionTitle != null) {
// $NON-NLS-1$
setXslProperty("title", actionTitle);
}
String description = actionSequence.getDescription();
if (description != null) {
// $NON-NLS-1$
setXslProperty("description", description);
}
String xFormHtml = XForm.transformSnippet(xFormNode, getSession(), new SolutionURIResolver());
if (xFormHtml == null) {
// $NON-NLS-1$
error(Messages.getInstance().getString("InputForm.ERROR_0007_INBOX_DEFINITION_INVALID") + solution + path + actionName);
return null;
}
Document document = DocumentHelper.parseText(xFormHtml);
// $NON-NLS-1$
Node xFormHtmlNode = document.selectSingleNode("//xForm");
// $NON-NLS-1$
setXslProperty("xForm", xFormHtmlNode.asXML());
if ((stylesheetName != null) && !"".equals(stylesheetName)) {
// $NON-NLS-1$
// $NON-NLS-1$
setXslProperty("css", stylesheetName);
}
// $NON-NLS-1$
setXsl("text/html", templateName);
return document;
} catch (Exception e) {
return null;
}
}
use of org.dom4j.Node in project pentaho-platform by pentaho.
the class PentahoFlashChartTest method testHorizontalBarChart.
@Test
public void testHorizontalBarChart() {
String chart = "<chart>" + "<chart-type>BarChart</chart-type>" + "<orientation>horizontal</orientation>" + "</chart>";
IPentahoResultSet rs = getRelationData();
Node chartNode = getChartNode(chart);
String c2 = PentahoOFC4JChartHelper.generateChartJson(chartNode, rs, false, null);
assertJsonEquals("{\"y_axis\":{\"colour\":\"#000000\",\"grid-colour\":\"#aaaaaa\",\"stroke\":1," + "\"labels\":[\"Human Resource\",\"Finance\",\"Sales\"],\"offset\":1}," + "\"x_legend\":{\"text\":\"DEPARTMENT\",\"style\":\"font-family: Arial; font-size: 14px; font-weight: " + "normal; font-style: normal;\"},\"elements\":[{\"colour\":\"#006666\",\"text\":\"ACTUAL\"," + "\"values\":[{\"right\":11},{\"right\":14},{\"right\":7}],\"type\":\"hbar\"},{\"colour\":\"#0066CC\"," + "\"text\":\"BUDGET\",\"values\":[{\"right\":12},{\"right\":9},{\"right\":100}],\"type\":\"hbar\"}]," + "\"x_axis\":{\"min\":0,\"colour\":\"#000000\",\"grid-colour\":\"#aaaaaa\",\"stroke\":1,\"max\":121," + "\"labels\":{},\"steps\":11},\"tooltip\":{\"mouse\":2}}", c2, when(IGNORING_ARRAY_ORDER));
}
use of org.dom4j.Node in project pentaho-platform by pentaho.
the class PentahoFlashChartTest method testPieChart.
@Test
public void testPieChart() {
String chart = "<chart>" + "<chart-type>PieChart</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\":[{\"animate\":false," + "\"values\":[{\"text\":\"Sales\",\"value\":11,\"label\":\"Sales\"},{\"text\":\"Finance\",\"value\":14," + "\"label\":\"Finance\"},{\"text\":\"Human Resource\",\"value\":7,\"label\":\"Human Resource\"}]," + "\"type\":\"pie\",\"colours\":[\"#006666\",\"#0066CC\",\"#009999\",\"#336699\",\"#339966\",\"#3399FF\"," + "\"#663366\",\"#666666\",\"#666699\",\"#669999\",\"#6699CC\",\"#66CCCC\",\"#993300\",\"#999933\"," + "\"#999966\",\"#999999\",\"#9999CC\",\"#9999FF\",\"#99CC33\",\"#99CCCC\",\"#99CCFF\",\"#CC6600\"," + "\"#CC9933\",\"#CCCC33\",\"#CCCC66\",\"#CCCC99\",\"#CCCCCC\",\"#FF9900\",\"#FFCC00\",\"#FFCC66\"]}]," + "\"x_axis\":{\"colour\":\"#000000\",\"grid-colour\":\"#aaaaaa\",\"stroke\":1," + "\"labels\":{\"labels\":[\"Sales\",\"Finance\",\"Human Resource\"]}}}", c2, when(IGNORING_ARRAY_ORDER));
}
use of org.dom4j.Node in project pentaho-platform by pentaho.
the class PentahoFlashChartTest method testBubbleChartDimensional.
@Test
public void testBubbleChartDimensional() {
String chart = "<chart>" + "<chart-type>BubbleChart</chart-type>" + "<dataset-type>XYZSeriesCollection</dataset-type>" + "</chart>";
IPentahoResultSet rs = getDimensionalData();
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\":\"ACTUAL\",\"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));
}
Aggregations