Search in sources :

Example 1 with NumberRangeRule

use of org.pentaho.di.trans.steps.numberrange.NumberRangeRule in project pentaho-metaverse by pentaho.

the class NumberRangeStepAnalyzer method getChangeRecords.

@Override
public Set<ComponentDerivationRecord> getChangeRecords(final NumberRangeMeta meta) throws MetaverseAnalyzerException {
    Set<ComponentDerivationRecord> changeRecords = new HashSet<>();
    ComponentDerivationRecord changeRecord = new ComponentDerivationRecord(meta.getInputField(), meta.getOutputField(), ChangeType.DATA);
    List<NumberRangeRule> rules = meta.getRules();
    if (rules != null) {
        for (NumberRangeRule rule : rules) {
            changeRecord.addOperation(new Operation(Operation.MAPPING_CATEGORY, ChangeType.DATA, DictionaryConst.PROPERTY_TRANSFORMS, rule.getLowerBound() + " <= " + meta.getInputField() + " <= " + rule.getUpperBound() + " -> " + rule.getValue()));
        }
    }
    changeRecords.add(changeRecord);
    return changeRecords;
}
Also used : NumberRangeRule(org.pentaho.di.trans.steps.numberrange.NumberRangeRule) ComponentDerivationRecord(org.pentaho.metaverse.api.analyzer.kettle.ComponentDerivationRecord) Operation(org.pentaho.metaverse.api.model.Operation) HashSet(java.util.HashSet)

Example 2 with NumberRangeRule

use of org.pentaho.di.trans.steps.numberrange.NumberRangeRule in project pentaho-kettle by pentaho.

the class NumberRangeDialog method getData.

// Read data from input (TextFileInputInfo)
public void getData() {
    // Get fields
    wStepname.setText(stepname);
    String inputField = input.getInputField();
    if (inputField != null) {
        inputFieldControl.setText(inputField);
    }
    String outputField = input.getOutputField();
    if (outputField != null) {
        outputFieldControl.setText(outputField);
    }
    String fallBackValue = input.getFallBackValue();
    if (fallBackValue != null) {
        fallBackValueControl.setText(fallBackValue);
    }
    for (int i = 0; i < input.getRules().size(); i++) {
        NumberRangeRule rule = input.getRules().get(i);
        TableItem item = rulesControl.table.getItem(i);
        // Empty value is equal to minimal possible value
        if (rule.getLowerBound() > -Double.MAX_VALUE) {
            String lowerBoundStr = String.valueOf(rule.getLowerBound());
            item.setText(1, lowerBoundStr);
        }
        // Empty value is equal to maximal possible value
        if (rule.getUpperBound() < Double.MAX_VALUE) {
            String upperBoundStr = String.valueOf(rule.getUpperBound());
            item.setText(2, upperBoundStr);
        }
        item.setText(3, rule.getValue());
    }
    rulesControl.setRowNums();
    rulesControl.optWidth(true);
}
Also used : NumberRangeRule(org.pentaho.di.trans.steps.numberrange.NumberRangeRule) TableItem(org.eclipse.swt.widgets.TableItem)

Aggregations

NumberRangeRule (org.pentaho.di.trans.steps.numberrange.NumberRangeRule)2 HashSet (java.util.HashSet)1 TableItem (org.eclipse.swt.widgets.TableItem)1 ComponentDerivationRecord (org.pentaho.metaverse.api.analyzer.kettle.ComponentDerivationRecord)1 Operation (org.pentaho.metaverse.api.model.Operation)1