Search in sources :

Example 1 with ParameterGeneration

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

the class ParameterGenerationController method editParameter.

public void editParameter() throws XulException {
    ParameterGeneration parameterGeneration = checkNotNull(model.getParameterGeneration());
    XulPromptBox promptBox = createPromptBox();
    promptBox.setTitle(getString(PKG, "ParameterGenerationController.Edit.Title"));
    promptBox.setMessage(getString(PKG, "ParameterGenerationController.Edit.Message"));
    promptBox.setValue(parameterGeneration.getParameterName());
    ParameterEditor editor = new ParameterEditor(parameterGeneration);
    promptBox.addDialogCallback(editor);
    if (promptBox.open() == 0 && editor.modified) {
        model.updateParameterMap();
        model.setSelectedParameter(parameterGeneration.getParameterName());
    }
}
Also used : ParameterGeneration(org.pentaho.di.trans.dataservice.optimization.paramgen.ParameterGeneration) XulPromptBox(org.pentaho.ui.xul.components.XulPromptBox)

Example 2 with ParameterGeneration

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

the class ParameterGenerationController method addParameter.

public void addParameter() throws XulException {
    PushDownOptimizationMeta meta = new PushDownOptimizationMeta();
    ParameterGeneration parameterGeneration = factory.createPushDown();
    meta.setType(parameterGeneration);
    meta.setStepName(getStepMenuList().getSelectedItem());
    XulPromptBox promptBox = createPromptBox();
    promptBox.setTitle(getString(PKG, "ParameterGenerationController.Create.Title"));
    promptBox.setMessage(getString(PKG, "ParameterGenerationController.Create.Message"));
    ParameterEditor editor = new ParameterEditor(parameterGeneration);
    promptBox.addDialogCallback(editor);
    if (promptBox.open() == 0 && editor.modified) {
        model.add(meta);
        model.setSelectedParameter(parameterGeneration.getParameterName());
    }
}
Also used : ParameterGeneration(org.pentaho.di.trans.dataservice.optimization.paramgen.ParameterGeneration) XulPromptBox(org.pentaho.ui.xul.components.XulPromptBox) PushDownOptimizationMeta(org.pentaho.di.trans.dataservice.optimization.PushDownOptimizationMeta)

Example 3 with ParameterGeneration

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

the class ParameterGenerationControllerTest method testEditParameter.

@Test
public void testEditParameter() throws Exception {
    PushDownOptimizationMeta meta = new PushDownOptimizationMeta();
    ParameterGeneration parameterGeneration = new ParameterGeneration(factory);
    parameterGeneration.setParameterName("parameterName");
    setSelected(meta, parameterGeneration);
    mockPromptBox("newParameterName", XulDialogCallback.Status.ACCEPT);
    controller.editParameter();
    assertThat(parameterGeneration.getParameterName(), equalTo("newParameterName"));
    verify(model).setSelectedParameter("newParameterName");
    verify(model).updateParameterMap();
}
Also used : ParameterGeneration(org.pentaho.di.trans.dataservice.optimization.paramgen.ParameterGeneration) PushDownOptimizationMeta(org.pentaho.di.trans.dataservice.optimization.PushDownOptimizationMeta) Test(org.junit.Test)

Example 4 with ParameterGeneration

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

the class ParameterGenerationControllerTest method testEditParameterFailure.

@Test
public void testEditParameterFailure() throws Exception {
    PushDownOptimizationMeta meta = new PushDownOptimizationMeta();
    ParameterGeneration parameterGeneration = new ParameterGeneration(factory);
    parameterGeneration.setParameterName("parameterName");
    setSelected(meta, parameterGeneration);
    mockPromptBox("newParameterName", XulDialogCallback.Status.CANCEL);
    controller.editParameter();
    mockPromptBox("parameterName", XulDialogCallback.Status.ACCEPT);
    controller.editParameter();
    mockPromptBox("", XulDialogCallback.Status.ACCEPT);
    controller.editParameter();
    mockPromptBox("newParameterName", XulDialogCallback.Status.ACCEPT);
    when(model.getParameterMap()).thenReturn(ImmutableMap.of("parameterName", meta, "newParameterName", mock(PushDownOptimizationMeta.class)));
    controller.editParameter();
    assertThat(parameterGeneration.getParameterName(), equalTo("parameterName"));
    verify(model, never()).updateParameterMap();
    verify(messageBox, times(2)).setIcon(SWT.ICON_WARNING);
    verify(messageBox, times(2)).open();
}
Also used : ParameterGeneration(org.pentaho.di.trans.dataservice.optimization.paramgen.ParameterGeneration) PushDownOptimizationMeta(org.pentaho.di.trans.dataservice.optimization.PushDownOptimizationMeta) Test(org.junit.Test)

Example 5 with ParameterGeneration

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

the class ParameterGenerationControllerTest method testRemoveParameter.

@Test
public void testRemoveParameter() throws Exception {
    PushDownOptimizationMeta meta = new PushDownOptimizationMeta();
    ParameterGeneration parameterGeneration = new ParameterGeneration(factory);
    parameterGeneration.setParameterName("parameterName");
    setSelected(meta, parameterGeneration);
    when(messageBox.open()).thenReturn(SWT.NO);
    controller.removeParameter();
    verify(model, never()).remove(any(PushDownOptimizationMeta.class));
    when(messageBox.open()).thenReturn(SWT.YES);
    controller.removeParameter();
    verify(model).setSelectedParameter(null);
    verify(model).remove(meta);
    verify(messageBox, times(2)).setIcon(SWT.ICON_QUESTION);
}
Also used : ParameterGeneration(org.pentaho.di.trans.dataservice.optimization.paramgen.ParameterGeneration) PushDownOptimizationMeta(org.pentaho.di.trans.dataservice.optimization.PushDownOptimizationMeta) Test(org.junit.Test)

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