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

The following examples show how to use org.pentaho.di.job.JobMeta#nrJobEntries() . 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: 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 4
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 5
Source File: RunConfigurationDelegate.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
protected void updateLoadedJobs( String key, RunConfiguration runConfig ) {
  for ( JobMeta job : spoonSupplier.get().getLoadedJobs() ) {
    for ( int i = 0; i < job.nrJobEntries(); i++ ) {
      JobEntryInterface entry = job.getJobEntry( i ).getEntry();

      if ( entry instanceof JobEntryRunConfigurableInterface ) {
        JobEntryRunConfigurableInterface jet = (JobEntryRunConfigurableInterface) entry;
        if ( jet.getRunConfiguration() != null ) {
          if ( jet.getRunConfiguration().equals( key ) ) {
            try {
              ExtensionPointHandler.callExtensionPoint( job.getLogChannel(), KettleExtensionPoint.JobEntryTransSave.id,
                new Object[] { job, runConfig.getName() } );
            } catch ( KettleException e ) {
              spoonSupplier.get().getLog().logBasic( "Unable to set run configuration in job " + job.getName() );
            }

            jet.setRunConfiguration( runConfig.getName() );
            if ( runConfig instanceof DefaultRunConfiguration ) {
              jet.setRemoteSlaveServerName( ( (DefaultRunConfiguration) runConfig ).getServer() );
              jet.setLoggingRemoteWork( ( (DefaultRunConfiguration) runConfig ).isLogRemoteExecutionLocally() );
            }
            jet.setChanged();
          }
        }
      }
    }
  }
}
 
Example 6
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);
    }
  }
}