Search in sources :

Example 6 with CalculatorMetaFunction

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();
}
Also used : TableItem(org.eclipse.swt.widgets.TableItem) CalculatorMetaFunction(org.pentaho.di.trans.steps.calculator.CalculatorMetaFunction)

Example 7 with CalculatorMetaFunction

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();
}
Also used : TableItem(org.eclipse.swt.widgets.TableItem) CalculatorMetaFunction(org.pentaho.di.trans.steps.calculator.CalculatorMetaFunction)

Aggregations

CalculatorMetaFunction (org.pentaho.di.trans.steps.calculator.CalculatorMetaFunction)7 CalculatorMeta (org.pentaho.di.trans.steps.calculator.CalculatorMeta)3 ArrayList (java.util.ArrayList)2 HashSet (java.util.HashSet)2 TableItem (org.eclipse.swt.widgets.TableItem)2 StepMeta (org.pentaho.di.trans.step.StepMeta)2 ColumnInfo (org.pentaho.platform.dataaccess.datasource.wizard.models.ColumnInfo)2 Test (org.junit.Test)1 ValueMetaInterface (org.pentaho.di.core.row.ValueMetaInterface)1 IifFunction (org.pentaho.di.core.sql.IifFunction)1 TransHopMeta (org.pentaho.di.trans.TransHopMeta)1 StepMetaInterface (org.pentaho.di.trans.step.StepMetaInterface)1 StreamInterface (org.pentaho.di.trans.step.errorhandling.StreamInterface)1 ConstantMeta (org.pentaho.di.trans.steps.constant.ConstantMeta)1 DummyTransMeta (org.pentaho.di.trans.steps.dummytrans.DummyTransMeta)1 FilterRowsMeta (org.pentaho.di.trans.steps.filterrows.FilterRowsMeta)1 ComponentDerivationRecord (org.pentaho.metaverse.api.analyzer.kettle.ComponentDerivationRecord)1 Operations (org.pentaho.metaverse.api.model.Operations)1 CalculatorStepNode (org.pentaho.metaverse.frames.CalculatorStepNode)1 StreamFieldNode (org.pentaho.metaverse.frames.StreamFieldNode)1