Java Code Examples for org.pentaho.di.trans.TransMeta#getObjectId()

The following examples show how to use org.pentaho.di.trans.TransMeta#getObjectId() . 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: SpoonEETransformationDelegate.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
@Override
public void addTransGraph( TransMeta transMeta ) {
  super.addTransGraph( transMeta );
  TabMapEntry tabEntry = spoon.delegates.tabs.findTabMapEntry( transMeta );
  if ( tabEntry != null ) {
    TabItem tabItem = tabEntry.getTabItem();
    try {
      if ( ( service != null ) && ( transMeta.getObjectId() != null )
          && ( service.getTransformationLock( transMeta.getObjectId() ) != null ) ) {
        tabItem.setImage( GUIResource.getInstance().getImageLocked() );
      }
    } catch ( Exception e ) {
      throw new RuntimeException( e );
    }
  }
}
 
Example 2
Source File: SpoonTabsDelegate.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
/**
 * Finds the tab for the transformation that matches the metadata provided (either the file must be the same or the
 * repository id).
 *
 * @param trans
 *          Transformation metadata to look for
 * @return Tab with transformation open whose metadata matches {@code trans} or {@code null} if no tab exists.
 * @throws KettleFileException
 *           If there is a problem loading the file object for an open transformation with an invalid a filename.
 */
public TabMapEntry findTabForTransformation( TransMeta trans ) throws KettleFileException {
  // File for the transformation we're looking for. It will be loaded upon first request.
  FileObject transFile = null;
  for ( TabMapEntry entry : tabMap ) {
    if ( entry != null && !entry.getTabItem().isDisposed() ) {
      if ( trans.getFilename() != null && entry.getFilename() != null ) {
        // If the entry has a file name it is the same as trans iff. they originated from the same files
        FileObject entryFile = KettleVFS.getFileObject( entry.getFilename() );
        if ( transFile == null ) {
          transFile = KettleVFS.getFileObject( trans.getFilename() );
        }
        if ( entryFile.equals( transFile ) ) {
          return entry;
        }
      } else if ( trans.getObjectId() != null && entry.getObject() != null ) {
        EngineMetaInterface meta = entry.getObject().getMeta();
        if ( meta != null && trans.getObjectId().equals( meta.getObjectId() ) ) {
          // If the transformation has an object id and the entry shares the same id they are the same
          return entry;
        }
      }
    }
  }
  // No tabs for the transformation exist and are not disposed
  return null;
}
 
Example 3
Source File: RepositoryBrowserController.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
private boolean isTransOpened( String id, String path, String name ) {
  List<TransMeta> openedTransFiles = getSpoon().delegates.trans.getTransformationList();
  for ( TransMeta t : openedTransFiles ) {
    if ( t.getObjectId() != null && id.equals( t.getObjectId().getId() )
      || ( path.equals( t.getRepositoryDirectory().getPath() ) && name.equals( t.getName() ) ) ) {
      return true;
    }
  }
  return false;
}
 
Example 4
Source File: RepositoryFileProvider.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
private boolean isTransOpened( String id, String path, String name ) {
  List<TransMeta> openedTransFiles = getSpoon().delegates.trans.getTransformationList();
  for ( TransMeta t : openedTransFiles ) {
    if ( t.getObjectId() != null && id.equals( t.getObjectId().getId() )
      || ( path.equals( t.getRepositoryDirectory().getPath() ) && name.equals( t.getName() ) ) ) {
      return true;
    }
  }
  return false;
}
 
Example 5
Source File: DataSetHelper.java    From pentaho-pdi-dataset with Apache License 2.0 4 votes vote down vote up
public static List<TransUnitTest> findTransformationUnitTest( TransMeta transMeta, IMetaStore metaStore ) {
  MetaStoreFactory<TransUnitTest> factory = new MetaStoreFactory<TransUnitTest>( TransUnitTest.class, metaStore, PentahoDefaults.NAMESPACE );
  List<TransUnitTest> tests = new ArrayList<TransUnitTest>();

  try {

    List<TransUnitTest> allTests = factory.getElements();
    for ( TransUnitTest test : allTests ) {
      // Match the filename
      //
      if ( StringUtils.isNotEmpty( transMeta.getFilename() ) ) {

        // What's the transformation absolute URI
        //
        FileObject transFile = KettleVFS.getFileObject( transMeta.getFilename() );
        String transUri = transFile.getName().getURI();

        // What's the filename referenced in the test?
        //
        FileObject testTransFile = KettleVFS.getFileObject( test.calculateCompleteFilename( transMeta ) );
        if ( testTransFile.exists() ) {
          String testTransUri = testTransFile.getName().getURI();

          if ( transUri.equals( testTransUri ) ) {
            tests.add( test );
          }
        }
      } else {
        if ( transMeta.getRepository() != null ) {
          // No filename, check the object_id ...
          //
          if ( transMeta.getObjectId() != null && transMeta.getObjectId().getId().equals( test.getTransObjectId() ) ) {
            tests.add( test );
          } else {
            // Try the repository path..
            //
            // What is the repsository path?
            String repositoryPath = transMeta.getRepositoryDirectory().getPath() + "/" + transMeta.getName();
            if ( repositoryPath.equals( test.getTransRepositoryPath() ) ) {
              tests.add( test );
            }
          }
        }
      }
    }

  } catch ( Exception exception ) {
    new ErrorDialog( Spoon.getInstance().getShell(),
      BaseMessages.getString( PKG, "ShowUnitTestMenuExtensionPoint.ErrorFindingUnitTestsForTransformation.Title" ),
      BaseMessages.getString( PKG, "ShowUnitTestMenuExtensionPoint.ErrorFindingUnitTestsForTransformation.Message" ),
      exception );
  }
  return tests;
}