Java Code Examples for org.pentaho.di.ui.spoon.Spoon#refreshGraph()

The following examples show how to use org.pentaho.di.ui.spoon.Spoon#refreshGraph() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ShowUnitTestMenuExtensionPoint.java    From pentaho-pdi-dataset with Apache License 2.0 6 votes vote down vote up
private void editLocation( TransUnitTestSetLocation location, Spoon spoon, TransMeta transMeta ) {
  try {
    FactoriesHierarchy hierarchy = new FactoriesHierarchy( spoon.getMetaStore(), spoon.getActiveDatabases() );

    Map<String, RowMetaInterface> stepFieldsMap = new HashMap<>();
    for ( StepMeta stepMeta : transMeta.getSteps() ) {
      stepFieldsMap.put( stepMeta.getName(), transMeta.getStepFields( stepMeta ) );
    }
    TransUnitTestSetLocationDialog dialog = new TransUnitTestSetLocationDialog( spoon.getShell(), location, hierarchy.getSetFactory().getElements(), stepFieldsMap );
    if ( dialog.open() ) {
      spoon.refreshGraph();
    }
  } catch ( Exception e ) {
    new ErrorDialog( spoon.getShell(), "Error", "Error editing dataset location", e );
  }
}
 
Example 2
Source File: DataSetHelper.java    From pentaho-pdi-dataset with Apache License 2.0 6 votes vote down vote up
public void detachUnitTest() {
  Spoon spoon = ( (Spoon) SpoonFactory.getInstance() );
  try {
    TransGraph transGraph = spoon.getActiveTransGraph();
    if ( transGraph == null ) {
      return;
    }
    TransMeta transMeta = spoon.getActiveTransformation();
    if ( transMeta == null ) {
      return;
    }


    // Remove
    //
    activeTests.remove( transMeta );
    transMeta.setVariable( DataSetConst.VAR_RUN_UNIT_TEST, "N" );

    spoon.refreshGraph();
  } catch ( Exception e ) {
    new ErrorDialog( spoon.getShell(), "Error", "Error detaching unit test", e );
  }
}
 
Example 3
Source File: DataSetHelper.java    From pentaho-pdi-dataset with Apache License 2.0 5 votes vote down vote up
public void createUnitTest( Spoon spoon, TransMeta transMeta ) {
  try {
    TransUnitTest unitTest = new TransUnitTest();
    unitTest.setName( transMeta.getName() + " Test" );
    unitTest.setTransFilename( transMeta.getFilename() );
    if ( spoon.getRepository() != null ) {
      unitTest.setTransObjectId( transMeta.getObjectId() == null ? null : transMeta.getObjectId().getId() );
      String path = transMeta.getRepositoryDirectory().getPath();
      if ( !path.endsWith( "/" ) ) {
        path += "/";
      }
      path += transMeta.getName();
      unitTest.setTransRepositoryPath( path );
    }

    FactoriesHierarchy hierarchy = getHierarchy();

    TransUnitTestDialog dialog = new TransUnitTestDialog( spoon.getShell(), transMeta, spoon.getMetaStore(), unitTest );
    if ( dialog.open() ) {
      saveUnitTest( hierarchy.getTestFactory(), unitTest, transMeta );

      activeTests.put( transMeta, unitTest );

      spoon.refreshGraph();
    }

  } catch ( Exception e ) {
    new ErrorDialog( spoon.getShell(), "Error", "Error creating a new transformation unit test", e );
  }
}
 
Example 4
Source File: DataSetHelper.java    From pentaho-pdi-dataset with Apache License 2.0 5 votes vote down vote up
private void tweakUnitTestStep( TransTweak stepTweak, boolean enable ) {
  Spoon spoon = ( (Spoon) SpoonFactory.getInstance() );
  TransGraph transGraph = spoon.getActiveTransGraph();
  IMetaStore metaStore = spoon.getMetaStore();
  if ( transGraph == null ) {
    return;
  }
  StepMeta stepMeta = transGraph.getCurrentStep();
  TransMeta transMeta = spoon.getActiveTransformation();
  if ( stepMeta == null || transMeta == null ) {
    return;
  }
  if ( checkTestPresent( spoon, transMeta ) ) {
    return;
  }

  try {
    TransUnitTest unitTest = getCurrentUnitTest( transMeta );
    TransUnitTestTweak unitTestTweak = unitTest.findTweak( stepMeta.getName() );
    if ( unitTestTweak != null ) {
      unitTest.getTweaks().remove( unitTestTweak );
    }
    if ( enable ) {
      unitTest.getTweaks().add( new TransUnitTestTweak( stepTweak, stepMeta.getName() ) );
    }

    saveUnitTest( getHierarchy().getTestFactory(), unitTest, transMeta );

    spoon.refreshGraph();

  } catch ( Exception exception ) {
    new ErrorDialog( spoon.getShell(), "Error", "Error tweaking transformation unit test on step '" + stepMeta.getName() + "' with operation " + stepTweak.name(), exception );
  }
}