use of org.dom4j.Node in project pentaho-platform by pentaho.
the class KettleComponent method validateAction.
@SuppressWarnings("unchecked")
@Override
public boolean validateAction() {
// If there are any mappings, validate their xml and values
if (getComponentDefinition().selectNodes(PARAMETER_MAP_CMD_ARG + " | " + PARAMETER_MAP_VARIABLE + " | " + PARAMETER_MAP_PARAMETER).size() > 0) {
// $NON-NLS-1$ //$NON-NLS-2$
Map<String, String> argumentMap = null;
Node name = null, mapping = null;
// they have a 'name' and 'mapping' child element
for (Node n : (List<Node>) getComponentDefinition().selectNodes(PARAMETER_MAP_CMD_ARG)) {
// $NON-NLS-1$
name = n.selectSingleNode("name");
// $NON-NLS-1$
mapping = n.selectSingleNode("mapping");
if (checkMapping(name, mapping)) {
if (argumentMap == null) {
argumentMap = new HashMap<String, String>();
}
argumentMap.put(name.getText(), applyInputsToFormat(getInputStringValue(mapping.getText())));
} else {
return false;
}
}
for (Node n : (List<Node>) getComponentDefinition().selectNodes(PARAMETER_MAP_VARIABLE)) {
// $NON-NLS-1$
name = n.selectSingleNode("name");
// $NON-NLS-1$
mapping = n.selectSingleNode("mapping");
if (!checkMapping(name, mapping)) {
return false;
}
}
for (Node n : (List<Node>) getComponentDefinition().selectNodes(PARAMETER_MAP_PARAMETER)) {
// $NON-NLS-1$
name = n.selectSingleNode("name");
// $NON-NLS-1$
mapping = n.selectSingleNode("mapping");
if (!checkMapping(name, mapping)) {
return false;
}
}
// that there are not more then 10 (currently supported by Kettle)
if (argumentMap != null) {
String val = null;
for (int i = 1; i <= argumentMap.size(); i++) {
val = argumentMap.get(Integer.toString(i));
if (val == null) {
// $NON-NLS-1$
error(Messages.getInstance().getErrorString("Kettle.ERROR_0030_INVALID_ARGUMENT_MAPPING"));
return false;
}
}
}
}
if (isDefinedResource(KettleComponent.TRANSFORMFILE) || isDefinedResource(KettleComponent.JOBFILE)) {
return true;
}
boolean useRepository = // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
PentahoSystem.getSystemSetting("kettle/settings.xml", "repository.type", "files").equals("rdbms");
if (!useRepository) {
// $NON-NLS-1$
error(Messages.getInstance().getErrorString("Kettle.ERROR_0019_REPOSITORY_TYPE_FILES"));
return false;
}
if (isDefinedInput(KettleComponent.DIRECTORY) && (isDefinedInput(KettleComponent.TRANSFORMATION) || isDefinedInput(KettleComponent.JOB))) {
return true;
}
if (!isDefinedInput(KettleComponent.DIRECTORY)) {
// $NON-NLS-1$
error(Messages.getInstance().getErrorString("Kettle.ERROR_0002_DIR_OR_FILE__NOT_DEFINED", getActionName()));
return false;
} else {
if (!isDefinedInput(KettleComponent.TRANSFORMATION)) {
// $NON-NLS-1$
error(Messages.getInstance().getErrorString("Kettle.ERROR_0003_TRANS_NOT_DEFINED", getActionName()));
return false;
}
}
return false;
}
use of org.dom4j.Node in project pentaho-platform by pentaho.
the class AbstractChartFactory method setupColors.
/**
* Setup colors for the series and also background
*/
protected void setupColors() {
Node temp = chartNode.selectSingleNode(COLOR_PALETTE_NODE_LOC);
if (temp != null) {
Object[] colorNodes = temp.selectNodes(COLOR_NODE_LOC).toArray();
for (int j = 0; j < colorNodes.length; j++) {
colors.add(getValue((Node) colorNodes[j]));
}
} else {
for (int i = 0; i < COLORS_DEFAULT.length; i++) {
colors.add(COLORS_DEFAULT[i]);
}
}
// Use either chart-background or plot-background (chart takes precendence)
temp = chartNode.selectSingleNode(PLOT_BACKGROUND_NODE_LOC);
if (getValue(temp) != null) {
String type = temp.valueOf(PLOT_BACKGROUND_COLOR_XPATH);
if (type != null && COLOR_TYPE.equals(type)) {
chart.setBackgroundColour(getValue(temp));
chart.setInnerBackgroundColour(getValue(temp));
}
}
temp = chartNode.selectSingleNode(CHART_BACKGROUND_NODE_LOC);
if (getValue(temp) != null) {
String type = temp.valueOf(CHART_BACKGROUND_COLOR_XPATH);
if (type != null && COLOR_TYPE.equals(type)) {
chart.setBackgroundColour(getValue(temp));
}
}
}
use of org.dom4j.Node in project pentaho-platform by pentaho.
the class BarLineChartFactory method setupLineRange.
@SuppressWarnings("unchecked")
public void setupLineRange() {
int rangeMin = 0;
int rangeMax = 100;
int steps = 9;
String rangeColor = AXIS_COLOR_DEFAULT;
String rangeGridColor = AXIS_GRID_COLOR_DEFAULT;
int rangeStroke = 1;
if (CATEGORY_TYPE.equals(datasetType) || XYZ_TYPE.equals(datasetType)) {
rangeMin = Integer.MAX_VALUE;
rangeMax = Integer.MIN_VALUE;
List nodes = chartNode.selectNodes(LINE_SERIES_SERIES_NODE_LOC);
List<String> bars = new ArrayList<String>();
for (Object node : nodes) {
if (getValue((Node) node) != null) {
bars.add(getValue((Node) node));
}
}
for (int c = 0; c < getColumnCount(); c++) {
String text = getColumnHeader(c);
if (bars.contains(text)) {
for (int r = 0; r < getRowCount(); r++) {
if (rangeMin > ((Number) getValueAt(r, c)).intValue()) {
rangeMin = ((Number) getValueAt(r, c)).intValue();
}
if (rangeMax < ((Number) getValueAt(r, c)).intValue()) {
rangeMax = ((Number) getValueAt(r, c)).intValue();
}
}
}
}
}
boolean minDefined = false;
boolean maxDefined = false;
Node temp = chartNode.selectSingleNode(LINES_RANGE_MINIMUM_NODE_LOC);
if (getValue(temp) != null) {
rangeMin = new Integer(getValue(temp)).intValue();
minDefined = true;
}
temp = chartNode.selectSingleNode(LINES_RANGE_MAXIMUM_NODE_LOC);
if (getValue(temp) != null) {
rangeMax = new Integer(getValue(temp)).intValue();
maxDefined = true;
}
temp = chartNode.selectSingleNode(LINES_RANGE_COLOR_NODE_LOC);
if (getValue(temp) != null) {
rangeColor = getValue(temp);
}
temp = chartNode.selectSingleNode(LINES_RANGE_GRID_COLOR_NODE_LOC);
if (getValue(temp) != null) {
rangeGridColor = getValue(temp);
}
temp = chartNode.selectSingleNode(LINES_RANGE_STROKE_NODE_LOC);
if (getValue(temp) != null) {
rangeStroke = Integer.parseInt(getValue(temp));
}
temp = chartNode.selectSingleNode(LINE_RANGE_STEPS_NODE_LOC);
if (getValue(temp) != null) {
steps = new Integer(getValue(temp)).intValue();
}
int diff = rangeMax - rangeMin;
int chunksize = diff / steps;
Integer stepforchart = null;
if (chunksize > 0) {
stepforchart = new Integer(chunksize);
}
// Readjust mins/maxs only if they weren't specified
if (!minDefined) {
// If actual min is positive, don't go below ZERO
if (rangeMin >= 0 && rangeMin - chunksize < 0) {
rangeMin = 0;
} else {
rangeMin = rangeMin - chunksize;
}
}
if (!maxDefined) {
rangeMax = rangeMin + (chunksize * (steps + 2));
}
YAxis yaxis = new YAxis();
yaxis.setRange(rangeMin, rangeMax, stepforchart);
yaxis.setStroke(rangeStroke);
yaxis.setColour(rangeColor);
yaxis.setGridColour(rangeGridColor);
chart.setYAxisRight(yaxis);
}
use of org.dom4j.Node in project pentaho-platform by pentaho.
the class BarLineChartFactory method getRangeMinMax.
@SuppressWarnings("unchecked")
public MinMax getRangeMinMax() {
int rangeMin = 0;
int rangeMax = 0;
if (isstacked) {
rangeMin = 0;
rangeMax = getStackedMaxRange();
} else {
rangeMin = Integer.MAX_VALUE;
rangeMax = Integer.MIN_VALUE;
List nodes = chartNode.selectNodes(BAR_SERIES_SERIES_NODE_LOC);
List<String> bars = new ArrayList<String>();
for (Object node : nodes) {
if (getValue((Node) node) != null) {
bars.add(getValue((Node) node));
}
}
for (int c = 0; c < getColumnCount(); c++) {
String text = getColumnHeader(c);
if (bars.contains(text)) {
for (int r = 0; r < getRowCount(); r++) {
if (rangeMin > ((Number) getValueAt(r, c)).intValue()) {
rangeMin = ((Number) getValueAt(r, c)).intValue();
}
if (rangeMax < ((Number) getValueAt(r, c)).intValue()) {
rangeMax = ((Number) getValueAt(r, c)).intValue();
}
}
}
}
}
if (rangeMin > 0) {
rangeMin = 0;
}
return new MinMax(rangeMin, rangeMax);
}
use of org.dom4j.Node in project pentaho-platform by pentaho.
the class DotChartFactory method setupStyles.
@Override
protected void setupStyles() {
super.setupStyles();
Node temp = chartNode.selectSingleNode(DOT_WIDTH_NODE_LOC);
if (getValue(temp) != null) {
dotwidth = Integer.parseInt(getValue(temp));
}
}
Aggregations