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

The following examples show how to use org.pentaho.di.job.JobMeta#initializeVariablesFrom() . 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: JobEntryJob.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
protected JobMeta getJobMetaFromRepository( Repository rep, CurrentDirectoryResolver r, String transPath, VariableSpace tmpSpace ) throws KettleException {
  String realJobName = "";
  String realDirectory = "/";

  int index = transPath.lastIndexOf( RepositoryFile.SEPARATOR );
  if ( index != -1 ) {
    realJobName = transPath.substring( index + 1 );
    realDirectory = index == 0 ? RepositoryFile.SEPARATOR : transPath.substring( 0, index );
  }

  realDirectory = r.normalizeSlashes( realDirectory );
  RepositoryDirectoryInterface repositoryDirectory = rep.loadRepositoryDirectoryTree().findDirectory( realDirectory );
  if ( repositoryDirectory == null ) {
    throw new KettleException( "Unable to find repository directory [" + Const.NVL( realDirectory, "" ) + "]" );
  }
  JobMeta jobMeta = rep.loadJob( realJobName, repositoryDirectory, null, null ); //reads
  if ( jobMeta != null ) {
    jobMeta.initializeVariablesFrom( tmpSpace );
  }
  return jobMeta;
}
 
Example 2
Source File: JobEntryJobDialog.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
private boolean askToCreateNewJob( String prevName ) {
  MessageBox mb = new MessageBox( shell, SWT.YES | SWT.NO | SWT.ICON_QUESTION );
  mb.setMessage( BaseMessages.getString( PKG, "JobJob.Dialog.CreateJobQuestion.Message" ) );
  mb.setText( BaseMessages.getString( PKG, "JobJob.Dialog.CreateJobQuestion.Title" ) );
  int answer = mb.open();
  if ( answer == SWT.YES ) {
    Spoon spoon = Spoon.getInstance();
    spoon.newJobFile();
    JobMeta newJobMeta = spoon.getActiveJob();
    newJobMeta.initializeVariablesFrom( jobEntry );
    newJobMeta.setFilename( jobMeta.environmentSubstitute( prevName ) );
    wPath.setText( prevName );
    specificationMethod = ObjectLocationSpecificationMethod.FILENAME;
    spoon.saveFile();
    return true;
  }
  return false;
}