org.pentaho.di.core.annotations.Step Java Examples

The following examples show how to use org.pentaho.di.core.annotations.Step. 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: KafkaConsumerMetaTest.java    From pentaho-kafka-consumer with Apache License 2.0 6 votes vote down vote up
@Test
public void testStepAnnotations() {

    // PDI Plugin Annotation-based Classloader checks
    Step stepAnnotation = KafkaConsumerMeta.class.getAnnotation(Step.class);
    assertNotNull(stepAnnotation);
    assertFalse(Utils.isEmpty(stepAnnotation.id()));
    assertFalse(Utils.isEmpty(stepAnnotation.name()));
    assertFalse(Utils.isEmpty(stepAnnotation.description()));
    assertFalse(Utils.isEmpty(stepAnnotation.image()));
    assertFalse(Utils.isEmpty(stepAnnotation.categoryDescription()));
    assertFalse(Utils.isEmpty(stepAnnotation.i18nPackageName()));
    assertFalse(Utils.isEmpty(stepAnnotation.documentationUrl()));
    assertFalse(Utils.isEmpty(stepAnnotation.casesUrl()));
    assertEquals(KafkaConsumerMeta.class.getPackage().getName(), stepAnnotation.i18nPackageName());
    hasi18nValue(stepAnnotation.i18nPackageName(), stepAnnotation.name());
    hasi18nValue(stepAnnotation.i18nPackageName(), stepAnnotation.description());
    hasi18nValue(stepAnnotation.i18nPackageName(), stepAnnotation.documentationUrl());
    hasi18nValue(stepAnnotation.i18nPackageName(), stepAnnotation.casesUrl());
}
 
Example #2
Source File: BeamKettle.java    From kettle-beam with Apache License 2.0 6 votes vote down vote up
public static PluginInterface getStepPluginForClass( Class<? extends StepMetaInterface> metaClass ) {
  Step stepAnnotation = metaClass.getAnnotation( Step.class );

  return new Plugin(
    new String[] { stepAnnotation.id() },
    StepPluginType.class,
    metaClass,
    stepAnnotation.categoryDescription(),
    stepAnnotation.name(),
    stepAnnotation.description(),
    stepAnnotation.image(),
    stepAnnotation.isSeparateClassLoaderNeeded(),
    false,
    new HashMap<>(),
    new ArrayList<>(),
    stepAnnotation.documentationUrl(),
    null
  );
}
 
Example #3
Source File: MQTTProducerTest.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
@BeforeClass
public static void setupClass() throws Exception {

  StepPluginType.getInstance().handlePluginAnnotation(
    MQTTProducerMeta.class,
    MQTTProducerMeta.class.getAnnotation( Step.class ),
    Collections.emptyList(), false, null );
  KettleEnvironment.init();
}
 
Example #4
Source File: TransMetaPipelineConverter.java    From kettle-beam with Apache License 2.0 5 votes vote down vote up
public void addClassesFromPluginsToStage( String pluginsToStage ) throws KettleException {
  // Find the plugins in the jar files in the plugin folders to stage...
  //
  if ( StringUtils.isNotEmpty( pluginsToStage ) ) {
    String[] pluginFolders = pluginsToStage.split( "," );
    for ( String pluginFolder : pluginFolders ) {
      List<String> stepClasses = findAnnotatedClasses( pluginFolder, Step.class.getName() );
      stepPluginClasses.addAll( stepClasses );
      List<String> xpClasses = findAnnotatedClasses( pluginFolder, ExtensionPoint.class.getName() );
      xpPluginClasses.addAll( xpClasses );
    }
  }
}
 
Example #5
Source File: StepPluginType.java    From pentaho-kettle with Apache License 2.0 4 votes vote down vote up
@Override
protected String extractImageFile( Annotation annotation ) {
  return ( (Step) annotation ).image();
}
 
Example #6
Source File: StepPluginType.java    From pentaho-kettle with Apache License 2.0 4 votes vote down vote up
@Override
protected String extractSuggestion( Annotation annotation ) {
  return ( (Step) annotation ).suggestion();
}
 
Example #7
Source File: StepPluginType.java    From pentaho-kettle with Apache License 2.0 4 votes vote down vote up
@Override
protected String extractClassLoaderGroup( Annotation annotation ) {
  return ( (Step) annotation ).classLoaderGroup();
}
 
Example #8
Source File: StepPluginType.java    From pentaho-kettle with Apache License 2.0 4 votes vote down vote up
@Override
protected String extractForumUrl( Annotation annotation ) {
  return ( (Step) annotation ).forumUrl();
}
 
Example #9
Source File: StepPluginType.java    From pentaho-kettle with Apache License 2.0 4 votes vote down vote up
@Override
protected String extractCasesUrl( Annotation annotation ) {
  return ( (Step) annotation ).casesUrl();
}
 
Example #10
Source File: StepPluginType.java    From pentaho-kettle with Apache License 2.0 4 votes vote down vote up
@Override
protected String extractDocumentationUrl( Annotation annotation ) {
  return Const.getDocUrl( ( (Step) annotation ).documentationUrl() );
}
 
Example #11
Source File: StepPluginType.java    From pentaho-kettle with Apache License 2.0 4 votes vote down vote up
@Override
protected String extractI18nPackageName( Annotation annotation ) {
  return ( (Step) annotation ).i18nPackageName();
}
 
Example #12
Source File: StepPluginType.java    From pentaho-kettle with Apache License 2.0 4 votes vote down vote up
@Override
protected boolean extractSeparateClassLoader( Annotation annotation ) {
  return ( (Step) annotation ).isSeparateClassLoaderNeeded();
}
 
Example #13
Source File: StepPluginType.java    From pentaho-kettle with Apache License 2.0 4 votes vote down vote up
@Override
protected String extractName( Annotation annotation ) {
  return ( (Step) annotation ).name();
}
 
Example #14
Source File: StepPluginType.java    From pentaho-kettle with Apache License 2.0 4 votes vote down vote up
@Override
protected String extractID( Annotation annotation ) {
  return ( (Step) annotation ).id();
}
 
Example #15
Source File: StepPluginType.java    From pentaho-kettle with Apache License 2.0 4 votes vote down vote up
@Override
protected String extractDesc( Annotation annotation ) {
  return ( (Step) annotation ).description();
}
 
Example #16
Source File: StepPluginType.java    From pentaho-kettle with Apache License 2.0 4 votes vote down vote up
@Override
protected String extractCategory( Annotation annotation ) {
  return ( (Step) annotation ).categoryDescription();
}
 
Example #17
Source File: StepPluginType.java    From pentaho-kettle with Apache License 2.0 4 votes vote down vote up
protected StepPluginType() {
  super( Step.class, "STEP", "Step" );
  populateFolders( "steps" );
}
 
Example #18
Source File: BeamJobConfigDialog.java    From kettle-beam with Apache License 2.0 4 votes vote down vote up
private void findStepClasses( Event event ) {
  String stepPluginClasses = findPluginClasses( Step.class.getName() );
  if ( stepPluginClasses != null ) {
    wStepPluginClasses.setText( stepPluginClasses );
  }
}
 
Example #19
Source File: BeamJobConfigDialog.java    From kettle-beam with Apache License 2.0 4 votes vote down vote up
private void buildFatJar( Event event ) {
  try {
    VariableSpace space = Variables.getADefaultVariableSpace();

    BeamJobConfig jobConfig = new BeamJobConfig();
    getInfo( jobConfig );

    FileDialog dialog = new FileDialog( shell, SWT.SAVE );
    dialog.setText( "Select the location of the Kettle+Beam+Plugins fat jar" );
    dialog.setFilterNames( new String[] { "Jar files (*.jar)", "All Files (*.*)" } );
    dialog.setFilterExtensions( new String[] { "*.jar", "*.*" } ); // Windows
    if ( StringUtils.isNotEmpty( jobConfig.getFatJar() ) ) {
      dialog.setFileName( space.environmentSubstitute( jobConfig.getFatJar() ) );
    }
    String filename = dialog.open();
    if ( StringUtils.isEmpty( filename ) ) {
      return;
    }

    List<String> files = BeamConst.findLibraryFilesToStage( null, jobConfig.getPluginsToStage(), true, true );
    files.removeIf( s -> s.contains( "commons-logging" ) || s.startsWith( "log4j" ) || s.contains( "xml-apis" ) );

    // Find the plugin classes for the specified plugins...
    //
    String stepPluginClasses = findPluginClasses( Step.class.getName() );
    if (StringUtils.isNotEmpty(jobConfig.getStepPluginClasses())) {
      if (StringUtils.isEmpty( stepPluginClasses )) {
        stepPluginClasses="";
      } else {
        stepPluginClasses+=",";
      }
      stepPluginClasses+=jobConfig.getStepPluginClasses();
    }
    String xpPluginClasses = findPluginClasses( ExtensionPoint.class.getName() );
    if (StringUtils.isNotEmpty(jobConfig.getXpPluginClasses())) {
      if (StringUtils.isEmpty( xpPluginClasses )) {
        xpPluginClasses="";
      } else {
        xpPluginClasses+=",";
      }
      xpPluginClasses+=jobConfig.getStepPluginClasses();
    }


    FatJarBuilder fatJarBuilder = new FatJarBuilder( filename, files );
    fatJarBuilder.setExtraStepPluginClasses( stepPluginClasses );
    fatJarBuilder.setExtraXpPluginClasses( xpPluginClasses );
    Cursor waitCursor = new Cursor( shell.getDisplay(), SWT.CURSOR_WAIT );
    Cursor regularCursor = shell.getCursor();

    try {
      shell.setCursor( waitCursor );
      fatJarBuilder.buildTargetJar();
    } finally {
      shell.setCursor( regularCursor );
      waitCursor.dispose();
    }

    // All went well, insert the filename...
    //
    wFatJar.setText( filename );

  } catch ( Exception e ) {
    new ErrorDialog( shell, "Error", "Error building fat jar: " + e.getMessage(), e );
  }
}