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

The following examples show how to use org.pentaho.di.job.JobMeta#getJobEntry() . 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: JobEntriesFolderProvider.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
@Override
public void refresh( AbstractMeta meta, TreeNode treeNode, String filter ) {
  JobMeta jobMeta = (JobMeta) meta;
  for ( int i = 0; i < jobMeta.nrJobEntries(); i++ ) {
    JobEntryCopy jobEntry = jobMeta.getJobEntry( i );

    if ( !filterMatch( jobEntry.getName(), filter ) && !filterMatch( jobEntry.getDescription(), filter ) ) {
      continue;
    }

    Image icon;
    if ( jobEntry.isStart() ) {
      icon = GUIResource.getInstance().getImageStartMedium();
    } else if ( jobEntry.isDummy() ) {
      icon = GUIResource.getInstance().getImageDummyMedium();
    } else {
      String key = jobEntry.getEntry().getPluginId();
      icon = GUIResource.getInstance().getImagesJobentriesSmall().get( key );
    }

    createTreeNode( treeNode, jobEntry.getName(), icon );
  }
}
 
Example 2
Source File: JobGraph.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
public void selectInRect( JobMeta jobMeta, org.pentaho.di.core.gui.Rectangle rect ) {
  int i;
  for ( i = 0; i < jobMeta.nrJobEntries(); i++ ) {
    JobEntryCopy je = jobMeta.getJobEntry( i );
    Point p = je.getLocation();
    if ( ( ( p.x >= rect.x && p.x <= rect.x + rect.width ) || ( p.x >= rect.x + rect.width && p.x <= rect.x ) )
      && ( ( p.y >= rect.y && p.y <= rect.y + rect.height ) || ( p.y >= rect.y + rect.height && p.y <= rect.y ) ) ) {
      je.setSelected( true );
    }
  }
  for ( i = 0; i < jobMeta.nrNotes(); i++ ) {
    NotePadMeta ni = jobMeta.getNote( i );
    Point a = ni.getLocation();
    Point b = new Point( a.x + ni.width, a.y + ni.height );
    if ( rect.contains( a.x, a.y ) && rect.contains( b.x, b.y ) ) {
      ni.setSelected( true );
    }
  }
}
 
Example 3
Source File: JobFileListenerTest.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
@Test
public void testProcessLinkedTransWithFilename() {
  JobEntryTrans jobTransExecutor = spy( new JobEntryTrans() );
  jobTransExecutor.setFileName( "/path/to/Transformation2.ktr" );
  jobTransExecutor.setSpecificationMethod( ObjectLocationSpecificationMethod.FILENAME );
  JobEntryCopy jobEntry = mock( JobEntryCopy.class );
  when( jobEntry.getEntry() ).thenReturn( jobTransExecutor );

  JobMeta parent = mock( JobMeta.class );
  when( parent.nrJobEntries() ).thenReturn( 1 );
  when( parent.getJobEntry( 0 ) ).thenReturn( jobEntry );

  JobMeta result = jobFileListener.processLinkedTrans( parent );

  JobEntryCopy meta = result.getJobEntry( 0 );
  assertNotNull( meta );
  JobEntryTrans resultExecMeta = (JobEntryTrans) meta.getEntry();
  assertEquals( ObjectLocationSpecificationMethod.REPOSITORY_BY_NAME, resultExecMeta.getSpecificationMethod() );
  assertEquals( "/path/to", resultExecMeta.getDirectory() );
  assertEquals( "Transformation2", resultExecMeta.getTransname() );
}
 
Example 4
Source File: JobFileListenerTest.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
private void testProcessLinkedTransWithNoFilename( final ObjectLocationSpecificationMethod method ) {
  JobEntryTrans jobTransExecutor = spy( new JobEntryTrans() );
  jobTransExecutor.setFileName( null );
  jobTransExecutor.setDirectory( "/path/to" );
  jobTransExecutor.setTransname( "Transformation2" );
  jobTransExecutor.setSpecificationMethod( method );
  JobEntryCopy jobEntry = mock( JobEntryCopy.class );
  when( jobEntry.getEntry() ).thenReturn( jobTransExecutor );

  JobMeta parent = mock( JobMeta.class );
  when( parent.nrJobEntries() ).thenReturn( 1 );
  when( parent.getJobEntry( 0 ) ).thenReturn( jobEntry );

  JobMeta result = jobFileListener.processLinkedTrans( parent );

  JobEntryCopy meta = result.getJobEntry( 0 );
  assertNotNull( meta );
  JobEntryTrans resultExecMeta = (JobEntryTrans) meta.getEntry();
  assertEquals( ObjectLocationSpecificationMethod.REPOSITORY_BY_NAME, resultExecMeta.getSpecificationMethod() );
  assertEquals( "/path/to", resultExecMeta.getDirectory() );
  assertEquals( "Transformation2", resultExecMeta.getTransname() );
}
 
Example 5
Source File: JobFileListenerTest.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
@Test
public void testProcessLinkedJobsWithFilename() {
  JobEntryJob jobJobExecutor = spy( new JobEntryJob() );
  jobJobExecutor.setFileName( "/path/to/Job1.kjb" );
  jobJobExecutor.setSpecificationMethod( ObjectLocationSpecificationMethod.FILENAME );
  JobEntryCopy jobEntry = mock( JobEntryCopy.class );
  when( jobEntry.getEntry() ).thenReturn( jobJobExecutor );

  JobMeta parent = mock( JobMeta.class );
  when( parent.nrJobEntries() ).thenReturn( 1 );
  when( parent.getJobEntry( 0 ) ).thenReturn( jobEntry );

  JobMeta result = jobFileListener.processLinkedJobs( parent );

  JobEntryCopy meta = result.getJobEntry( 0 );
  assertNotNull( meta );
  JobEntryJob resultExecMeta = (JobEntryJob) meta.getEntry();
  assertEquals( ObjectLocationSpecificationMethod.REPOSITORY_BY_NAME, resultExecMeta.getSpecificationMethod() );
  assertEquals( resultExecMeta.getDirectory(), "/path/to" );
  assertEquals( resultExecMeta.getJobName(), "Job1" );
}
 
Example 6
Source File: JobFileListenerTest.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
private void testProcessLinkedJobsWithNoFilename( final ObjectLocationSpecificationMethod method ) {
  JobEntryJob jobJobExecutor = spy( new JobEntryJob() );
  jobJobExecutor.setFileName( null );
  jobJobExecutor.setDirectory( "/path/to" );
  jobJobExecutor.setJobName( "Job1" );
  jobJobExecutor.setSpecificationMethod( method );
  JobEntryCopy jobEntry = mock( JobEntryCopy.class );
  when( jobEntry.getEntry() ).thenReturn( jobJobExecutor );

  JobMeta parent = mock( JobMeta.class );
  when( parent.nrJobEntries() ).thenReturn( 1 );
  when( parent.getJobEntry( 0 ) ).thenReturn( jobEntry );

  JobMeta result = jobFileListener.processLinkedJobs( parent );

  JobEntryCopy meta = result.getJobEntry( 0 );
  assertNotNull( meta );
  JobEntryJob resultExecMeta = (JobEntryJob) meta.getEntry();
  assertEquals( ObjectLocationSpecificationMethod.REPOSITORY_BY_NAME, resultExecMeta.getSpecificationMethod() );
  assertEquals( resultExecMeta.getDirectory(), "/path/to" );
  assertEquals( resultExecMeta.getJobName(), "Job1" );
}
 
Example 7
Source File: JobFileListener.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
protected JobMeta processLinkedJobs( JobMeta jobMeta ) {
  for ( int i = 0; i < jobMeta.nrJobEntries(); i++ ) {
    JobEntryCopy jec = jobMeta.getJobEntry( i );
    if ( jec.getEntry() instanceof JobEntryJob ) {
      JobEntryJob jej = (JobEntryJob) jec.getEntry();
      ObjectLocationSpecificationMethod specMethod = jej.getSpecificationMethod();
      // If the reference is by filename, change it to Repository By Name. Otherwise it's fine so leave it alone
      if ( specMethod == ObjectLocationSpecificationMethod.FILENAME ) {
        jej.setSpecificationMethod( ObjectLocationSpecificationMethod.REPOSITORY_BY_NAME );
        String filename = jej.getFilename();
        // if the filename is a missing variable name, it will not contain a slash - we don't want to fail
        // ungracefully in this case, simply set the job name to the whole filename value and let the run-time
        // handle any exceptions that arise from this
        if ( filename != null ) {
          if ( filename.indexOf( "/" ) > -1 ) {
            String jobname = filename.substring( filename.lastIndexOf( "/" ) + 1, filename.lastIndexOf( '.' ) );
            String directory = filename.substring( 0, filename.lastIndexOf( "/" ) );
            jej.setJobName( jobname );
            jej.setDirectory( directory );
          } else {
            jej.setJobName( filename );
          }
        }
        jobMeta.setJobEntry( i, jec );
      }
    }
  }
  return jobMeta;
}
 
Example 8
Source File: JobFileListener.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
protected JobMeta processLinkedTrans( JobMeta jobMeta ) {
  for ( int i = 0; i < jobMeta.nrJobEntries(); i++ ) {
    JobEntryCopy jec = jobMeta.getJobEntry( i );
    if ( jec.getEntry() instanceof JobEntryTrans ) {
      JobEntryTrans jet = (JobEntryTrans) jec.getEntry();
      ObjectLocationSpecificationMethod specMethod = jet.getSpecificationMethod();
      // If the reference is by filename, change it to Repository By Name. Otherwise it's fine so leave it alone
      if ( specMethod == ObjectLocationSpecificationMethod.FILENAME ) {
        jet.setSpecificationMethod( ObjectLocationSpecificationMethod.REPOSITORY_BY_NAME );
        String filename = jet.getFilename();
        // if the filename is a missing variable name, it will not contain a slash - we don't want to fail
        // ungracefully in this case, simply set the trans name to the whole filename value and let the run-time
        // handle any exceptions that arise from this
        if ( filename != null ) {
          if ( filename.indexOf( "/" ) > -1 ) {
            String jobname = filename.substring( filename.lastIndexOf( "/" ) + 1, filename.lastIndexOf( '.' ) );
            String directory = filename.substring( 0, filename.lastIndexOf( "/" ) );
            jet.setTransname( jobname );
            jet.setDirectory( directory );
          } else {
            jet.setTransname( filename );
          }
        }
        jobMeta.setJobEntry( i, jec );
      }
    }
  }
  return jobMeta;
}
 
Example 9
Source File: JobLogDelegate.java    From pentaho-kettle with Apache License 2.0 4 votes vote down vote up
public void showErrors() {
  String all = jobLogText.getText();
  ArrayList<String> err = new ArrayList<String>();

  int i = 0;
  int startpos = 0;
  int crlen = Const.CR.length();

  String line = null;
  String lineUpper = null;
  while ( i < all.length() - crlen ) {
    if ( all.substring( i, i + crlen ).equalsIgnoreCase( Const.CR ) ) {
      line = all.substring( startpos, i );
      lineUpper = line.toUpperCase();
      if ( lineUpper.indexOf( BaseMessages.getString( PKG, "JobLog.System.ERROR" ) ) >= 0
        || lineUpper.indexOf( BaseMessages.getString( PKG, "JobLog.System.EXCEPTION" ) ) >= 0 ) {
        err.add( line );
      }
      // New start of line
      startpos = i + crlen;
    }

    i++;
  }
  line = all.substring( startpos );
  lineUpper = line.toUpperCase();
  if ( lineUpper.indexOf( BaseMessages.getString( PKG, "JobLog.System.ERROR" ) ) >= 0
    || lineUpper.indexOf( BaseMessages.getString( PKG, "JobLog.System.EXCEPTION" ) ) >= 0 ) {
    err.add( line );
  }

  if ( err.size() > 0 ) {
    String[] err_lines = new String[err.size()];
    for ( i = 0; i < err_lines.length; i++ ) {
      err_lines[i] = err.get( i );
    }

    EnterSelectionDialog esd = new EnterSelectionDialog( jobGraph.getShell(), err_lines,
      BaseMessages.getString( PKG, "JobLog.Dialog.ErrorLines.Title" ),
      BaseMessages.getString( PKG, "JobLog.Dialog.ErrorLines.Message" ) );
    line = esd.open();
    if ( line != null ) {
      JobMeta jobMeta = jobGraph.getManagedObject();
      for ( i = 0; i < jobMeta.nrJobEntries(); i++ ) {
        JobEntryCopy entryCopy = jobMeta.getJobEntry( i );
        if ( line.indexOf( entryCopy.getName() ) >= 0 ) {
          spoon.editJobEntry( jobMeta, entryCopy );
        }
      }
      // System.out.println("Error line selected: "+line);
    }
  }
}