Search in sources :

Example 41 with PushDownOptimizationMeta

use of org.pentaho.di.trans.dataservice.optimization.PushDownOptimizationMeta in project pdi-dataservice-server-plugin by pentaho.

the class ParameterGenerationModel method updateParameterMap.

protected void updateParameterMap() {
    ImmutableList<PushDownOptimizationMeta> list = dialogModel.getPushDownOptimizations(ParameterGeneration.class);
    Map<String, PushDownOptimizationMeta> map = Maps.newHashMapWithExpectedSize(list.size());
    for (PushDownOptimizationMeta meta : list) {
        ParameterGeneration parameterGeneration = (ParameterGeneration) meta.getType();
        String parameterName = parameterGeneration.getParameterName();
        // If parameter already exists, add a unique suffix
        int offset = 0;
        while (map.containsKey(parameterName)) {
            parameterName = String.format("%s_%d", parameterGeneration.getParameterName(), ++offset);
        }
        if (offset > 0) {
            parameterGeneration.setParameterName(parameterName);
        }
        map.put(parameterName, meta);
    }
    setParameterMap(map);
    if (!map.containsKey(getSelectedParameter())) {
        setSelectedParameter(null);
    }
}
Also used : ParameterGeneration(org.pentaho.di.trans.dataservice.optimization.paramgen.ParameterGeneration) PushDownOptimizationMeta(org.pentaho.di.trans.dataservice.optimization.PushDownOptimizationMeta)

Aggregations

PushDownOptimizationMeta (org.pentaho.di.trans.dataservice.optimization.PushDownOptimizationMeta)41 Test (org.junit.Test)23 ParameterGeneration (org.pentaho.di.trans.dataservice.optimization.paramgen.ParameterGeneration)10 DataServiceMeta (org.pentaho.di.trans.dataservice.DataServiceMeta)8 SQL (org.pentaho.di.core.sql.SQL)7 IMetaStore (org.pentaho.metastore.api.IMetaStore)7 Matchers.anyString (org.mockito.Matchers.anyString)5 ValueMetaString (org.pentaho.di.core.row.value.ValueMetaString)4 ImmutableSet (com.google.common.collect.ImmutableSet)3 ByteArrayOutputStream (java.io.ByteArrayOutputStream)3 DataOutputStream (java.io.DataOutputStream)3 Set (java.util.Set)3 RowProducer (org.pentaho.di.trans.RowProducer)3 PushDownType (org.pentaho.di.trans.dataservice.optimization.PushDownType)3 DataServiceModel (org.pentaho.di.trans.dataservice.ui.model.DataServiceModel)3 XulException (org.pentaho.ui.xul.XulException)3 Shell (org.eclipse.swt.widgets.Shell)2 Before (org.junit.Before)2 InOrder (org.mockito.InOrder)2 KettleException (org.pentaho.di.core.exception.KettleException)2