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());
}
}
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());
}
}
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();
}
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();
}
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);
}
Aggregations