Java Code Examples for org.pentaho.di.job.JobMeta#getName()

The following examples show how to use org.pentaho.di.job.JobMeta#getName() . 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: JobTracker.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
/**
 * @param jobMeta
 *          The job metadata to track
 * @param maxChildren
 *          The maximum number of children to keep track of (1000 is the default)
 */
public JobTracker( JobMeta jobMeta, int maxChildren ) {
  if ( jobMeta != null ) {
    this.jobName = jobMeta.getName();
    this.jobFilename = jobMeta.getFilename();
  }

  this.jobTrackers = new LinkedList<JobTracker>();
  this.maxChildren = maxChildren;
  this.lock = new ReentrantReadWriteLock();
}
 
Example 2
Source File: RepositoryTestBase.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
@Ignore
@Test
public void testRenameAndUndelete() throws Exception {
  RepositoryDirectoryInterface rootDir = initRepo();
  JobMeta jobMeta = createJobMeta( EXP_JOB_NAME );
  RepositoryDirectoryInterface jobsDir = rootDir.findDirectory( DIR_JOBS );
  repository.save( jobMeta, VERSION_COMMENT_V1, null );
  deleteStack.push( jobMeta );

  repository.deleteJob( jobMeta.getObjectId() );
  assertFalse( repository.exists( EXP_JOB_NAME, jobsDir, RepositoryObjectType.JOB ) );
  RepositoryObject robj =
      new RepositoryObject( jobMeta.getObjectId(), jobMeta.getName(), jobMeta.getRepositoryDirectory(), null, null,
          jobMeta.getRepositoryElementType(), null, false );
  repository.undeleteObject( robj );
  assertTrue( repository.exists( EXP_JOB_NAME, jobsDir, RepositoryObjectType.JOB ) );

  repository.renameJob( jobMeta.getObjectId(), jobsDir, EXP_JOB_NAME_NEW );
  assertFalse( repository.exists( EXP_JOB_NAME, jobsDir, RepositoryObjectType.JOB ) );
  assertTrue( repository.exists( EXP_JOB_NAME_NEW, jobsDir, RepositoryObjectType.JOB ) );

  TransMeta transMeta = createTransMeta( EXP_DBMETA_NAME );
  RepositoryDirectoryInterface transDir = rootDir.findDirectory( DIR_TRANSFORMATIONS );
  repository.save( transMeta, VERSION_COMMENT_V1, null );
  deleteStack.push( transMeta );
  repository.renameTransformation( transMeta.getObjectId(), transDir, EXP_TRANS_NAME_NEW );
  assertFalse( repository.exists( EXP_TRANS_NAME.concat( EXP_DBMETA_NAME ), transDir,
      RepositoryObjectType.TRANSFORMATION ) );
  assertTrue( repository.exists( EXP_TRANS_NAME_NEW, transDir, RepositoryObjectType.TRANSFORMATION ) );

  DatabaseMeta dbMeta = createDatabaseMeta( EXP_DBMETA2_NAME );
  repository.save( dbMeta, VERSION_COMMENT_V1, null );
  deleteStack.push( dbMeta );

  dbMeta.setName( EXP_DBMETA_NAME_NEW );
  repository.save( dbMeta, VERSION_COMMENT_V2, null );
  assertFalse( repository.exists( EXP_DBMETA2_NAME, null, RepositoryObjectType.DATABASE ) );
  assertTrue( repository.exists( EXP_DBMETA_NAME_NEW, null, RepositoryObjectType.DATABASE ) );
}
 
Example 3
Source File: JobEntryJob.java    From pentaho-kettle with Apache License 2.0 4 votes vote down vote up
/**
 * Make sure that we are not loading jobs recursively...
 *
 * @param parentJobMeta
 *          the parent job metadata
 * @param jobMeta
 *          the job metadata
 * @throws KettleException
 *           in case both jobs are loaded from the same source
 */
private void verifyRecursiveExecution( Job parentJob, JobMeta jobMeta ) throws KettleException {

  if ( parentJob == null ) {
    return; // OK!
  }

  JobMeta parentJobMeta = parentJob.getJobMeta();

  if ( parentJobMeta.getName() == null && jobMeta.getName() != null ) {
    return; // OK
  }
  if ( parentJobMeta.getName() != null && jobMeta.getName() == null ) {
    return; // OK as well.
  }

  // Not from the repository? just verify the filename
  //
  if ( jobMeta.getFilename() != null && jobMeta.getFilename().equals( parentJobMeta.getFilename() ) ) {
    throw new KettleException( BaseMessages.getString( PKG, "JobJobError.Recursive", jobMeta.getFilename() ) );
  }

  // Different directories: OK
  if ( parentJobMeta.getRepositoryDirectory() == null && jobMeta.getRepositoryDirectory() != null ) {
    return;
  }
  if ( parentJobMeta.getRepositoryDirectory() != null && jobMeta.getRepositoryDirectory() == null ) {
    return;
  }
  if ( jobMeta.getRepositoryDirectory().getObjectId() != parentJobMeta.getRepositoryDirectory().getObjectId() ) {
    return;
  }

  // Same names, same directories : loaded from same location in the
  // repository:
  // --> recursive loading taking place!
  //
  if ( parentJobMeta.getName().equals( jobMeta.getName() ) ) {
    throw new KettleException( BaseMessages.getString( PKG, "JobJobError.Recursive", jobMeta.getFilename() ) );
  }

  // Also compare with the grand-parent (if there is any)
  verifyRecursiveExecution( parentJob.getParentJob(), jobMeta );
}