Search in sources :

Example 11 with ParameterGeneration

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

the class BaseStepValidationTest method setupMockedParamGen.

ParameterGeneration setupMockedParamGen(String paramName, String stepName) {
    ParameterGeneration pushDownType = mock(ParameterGeneration.class);
    when(pushDownType.getParameterName()).thenReturn(paramName);
    PushDownOptimizationMeta optMeta = new PushDownOptimizationMeta();
    optMeta.setType(pushDownType);
    optMeta.setStepName(stepName);
    pushDownOptMetas.add(optMeta);
    return pushDownType;
}
Also used : ParameterGeneration(org.pentaho.di.trans.dataservice.optimization.paramgen.ParameterGeneration) PushDownOptimizationMeta(org.pentaho.di.trans.dataservice.optimization.PushDownOptimizationMeta)

Example 12 with ParameterGeneration

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

the class ParameterGenerationController method removeParameter.

public void removeParameter() throws XulException {
    PushDownOptimizationMeta meta = checkNotNull(model.getSelectedOptimization());
    String parameterName = ((ParameterGeneration) meta.getType()).getParameterName();
    XulMessageBox messageBox = createMessageBox();
    messageBox.setTitle(getString(PKG, "ParameterGenerationController.Delete.Title"));
    messageBox.setMessage(getString(PKG, "ParameterGenerationController.Delete.Message", parameterName));
    messageBox.setIcon(SWT.ICON_QUESTION);
    messageBox.setButtons(new Object[] { SWT.YES, SWT.NO });
    if (messageBox.open() == SWT.YES) {
        model.setSelectedParameter(null);
        model.remove(meta);
    }
}
Also used : ParameterGeneration(org.pentaho.di.trans.dataservice.optimization.paramgen.ParameterGeneration) XulMessageBox(org.pentaho.ui.xul.components.XulMessageBox) PushDownOptimizationMeta(org.pentaho.di.trans.dataservice.optimization.PushDownOptimizationMeta) BaseMessages.getString(org.pentaho.di.i18n.BaseMessages.getString)

Example 13 with ParameterGeneration

use of org.pentaho.di.trans.dataservice.optimization.paramgen.ParameterGeneration 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

ParameterGeneration (org.pentaho.di.trans.dataservice.optimization.paramgen.ParameterGeneration)13 PushDownOptimizationMeta (org.pentaho.di.trans.dataservice.optimization.PushDownOptimizationMeta)10 Test (org.junit.Test)6 XulPromptBox (org.pentaho.ui.xul.components.XulPromptBox)2 BaseMessages.getString (org.pentaho.di.i18n.BaseMessages.getString)1 StepMeta (org.pentaho.di.trans.step.StepMeta)1 TableInputMeta (org.pentaho.di.trans.steps.tableinput.TableInputMeta)1 XulMessageBox (org.pentaho.ui.xul.components.XulMessageBox)1