use of org.pentaho.di.trans.steps.calculator.CalculatorMetaFunction in project pentaho-kettle by pentaho.
the class CalculatorDialog method ok.
private void ok() {
if (Utils.isEmpty(wStepname.getText())) {
return;
}
// return value
stepname = wStepname.getText();
int nrNonEmptyFields = wFields.nrNonEmpty();
currentMeta.allocate(nrNonEmptyFields);
for (int i = 0; i < nrNonEmptyFields; i++) {
TableItem item = wFields.getNonEmpty(i);
String fieldName = item.getText(1);
int calcType = CalculatorMetaFunction.getCalcFunctionType(item.getText(2));
String fieldA = item.getText(3);
String fieldB = item.getText(4);
String fieldC = item.getText(5);
int valueType = ValueMetaFactory.getIdForValueMeta(item.getText(6));
int valueLength = Const.toInt(item.getText(7), -1);
int valuePrecision = Const.toInt(item.getText(8), -1);
boolean removed = BaseMessages.getString(PKG, "System.Combo.Yes").equalsIgnoreCase(item.getText(9));
String conversionMask = item.getText(10);
String decimalSymbol = item.getText(11);
String groupingSymbol = item.getText(12);
String currencySymbol = item.getText(13);
// CHECKSTYLE:Indentation:OFF
currentMeta.getCalculation()[i] = new CalculatorMetaFunction(fieldName, calcType, fieldA, fieldB, fieldC, valueType, valueLength, valuePrecision, removed, conversionMask, decimalSymbol, groupingSymbol, currencySymbol);
}
if (!originalMeta.equals(currentMeta)) {
currentMeta.setChanged();
changed = currentMeta.hasChanged();
}
dispose();
}
use of org.pentaho.di.trans.steps.calculator.CalculatorMetaFunction in project pentaho-kettle by pentaho.
the class CalculatorDialog method getData.
/**
* Copy information from the meta-data currentMeta to the dialog fields.
*/
public void getData() {
if (currentMeta.getCalculation() != null) {
for (int i = 0; i < currentMeta.getCalculation().length; i++) {
CalculatorMetaFunction fn = currentMeta.getCalculation()[i];
TableItem item = wFields.table.getItem(i);
item.setText(1, Const.NVL(fn.getFieldName(), ""));
item.setText(2, Const.NVL(fn.getCalcTypeLongDesc(), ""));
item.setText(3, Const.NVL(fn.getFieldA(), ""));
item.setText(4, Const.NVL(fn.getFieldB(), ""));
item.setText(5, Const.NVL(fn.getFieldC(), ""));
item.setText(6, Const.NVL(ValueMetaFactory.getValueMetaName(fn.getValueType()), ""));
if (fn.getValueLength() >= 0) {
item.setText(7, "" + fn.getValueLength());
}
if (fn.getValuePrecision() >= 0) {
item.setText(8, "" + fn.getValuePrecision());
}
item.setText(9, fn.isRemovedFromResult() ? BaseMessages.getString(PKG, "System.Combo.Yes") : BaseMessages.getString(PKG, "System.Combo.No"));
item.setText(10, Const.NVL(fn.getConversionMask(), ""));
item.setText(11, Const.NVL(fn.getDecimalSymbol(), ""));
item.setText(12, Const.NVL(fn.getGroupingSymbol(), ""));
item.setText(13, Const.NVL(fn.getCurrencySymbol(), ""));
}
}
wFields.setRowNums();
wFields.optWidth(true);
wStepname.selectAll();
wStepname.setFocus();
}
Aggregations