Search in sources :

Example 41 with Condition

use of org.pentaho.di.core.Condition in project pdi-dataservice-server-plugin by pentaho.

the class ParameterGeneration method getPushDownCondition.

private Condition getPushDownCondition(SQL query) {
    // Get user query conditions
    Condition whereCondition;
    if (query.getWhereCondition() != null) {
        whereCondition = query.getWhereCondition().getCondition();
    } else {
        return null;
    }
    // Attempt to map fields to where clause
    Condition pushDownCondition = mapConditionFields(whereCondition);
    if (pushDownCondition == null || StringUtils.isBlank(getParameterName())) {
        return null;
    }
    return pushDownCondition;
}
Also used : Condition(org.pentaho.di.core.Condition)

Example 42 with Condition

use of org.pentaho.di.core.Condition in project pdi-dataservice-server-plugin by pentaho.

the class ParameterGeneration method mapConditionFields.

protected Condition mapConditionFields(Condition condition) {
    Condition clone = (Condition) condition.clone();
    HashMap<String, SourceTargetFields> sourceMap;
    sourceMap = new HashMap<String, SourceTargetFields>();
    for (SourceTargetFields fieldMapping : fieldMappings) {
        sourceMap.put(fieldMapping.getSourceFieldName(), fieldMapping);
    }
    if (applyMapping(clone, sourceMap)) {
        clone.simplify();
        return clone;
    } else {
        return null;
    }
}
Also used : Condition(org.pentaho.di.core.Condition) SourceTargetFields(org.pentaho.di.trans.dataservice.optimization.SourceTargetFields)

Aggregations

Condition (org.pentaho.di.core.Condition)42 Test (org.junit.Test)14 Matchers.anyString (org.mockito.Matchers.anyString)6 RowMeta (org.pentaho.di.core.row.RowMeta)6 SQLCondition (org.pentaho.di.core.sql.SQLCondition)6 StepMeta (org.pentaho.di.trans.step.StepMeta)6 KettleException (org.pentaho.di.core.exception.KettleException)5 ValueMetaString (org.pentaho.di.core.row.value.ValueMetaString)5 SQL (org.pentaho.di.core.sql.SQL)5 ParameterGenerationTest.newCondition (org.pentaho.di.trans.dataservice.optimization.paramgen.ParameterGenerationTest.newCondition)5 KettleStepException (org.pentaho.di.core.exception.KettleStepException)4 KettleXMLException (org.pentaho.di.core.exception.KettleXMLException)4 ValueMetaAndData (org.pentaho.di.core.row.ValueMetaAndData)4 JUnitMatchers.containsString (org.junit.matchers.JUnitMatchers.containsString)3 RowMetaAndData (org.pentaho.di.core.RowMetaAndData)3 ArrayList (java.util.ArrayList)2 LinkedList (java.util.LinkedList)2 Map (java.util.Map)2 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)2 SelectionEvent (org.eclipse.swt.events.SelectionEvent)2