org.pentaho.di.core.plugins.PluginInterface Java Examples
The following examples show how to use
org.pentaho.di.core.plugins.PluginInterface.
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: StepPartitioningMeta.java From pentaho-kettle with Apache License 2.0 | 6 votes |
public static final int getMethodType( String description ) { for ( int i = 0; i < methodDescriptions.length; i++ ) { if ( methodDescriptions[i].equalsIgnoreCase( description ) ) { return i; } } for ( int i = 0; i < methodCodes.length; i++ ) { if ( methodCodes[i].equalsIgnoreCase( description ) ) { return i; } } PluginInterface plugin = PluginRegistry.getInstance().findPluginWithId( PartitionerPluginType.class, description ); if ( plugin != null ) { return PARTITIONING_METHOD_SPECIAL; } return PARTITIONING_METHOD_NONE; }
Example #2
Source File: PentahoMapReduceJobBuilderImpl.java From pentaho-hadoop-shims with Apache License 2.0 | 6 votes |
@VisibleForTesting PentahoMapReduceJobBuilderImpl( NamedCluster namedCluster, HadoopShim hadoopShim, LogChannelInterface log, VariableSpace variableSpace, PluginInterface pluginInterface, FileObject vfsPluginDirectory, Properties pmrProperties, TransFactory transFactory, PMRArchiveGetter pmrArchiveGetter, List<TransformationVisitorService> visitorServices ) { super( namedCluster, hadoopShim, log, variableSpace ); this.hadoopShim = hadoopShim; this.log = log; this.vfsPluginDirectory = vfsPluginDirectory; this.pmrProperties = pmrProperties; this.transFactory = transFactory; this.installId = buildInstallIdBase( hadoopShim ); this.pmrArchiveGetter = pmrArchiveGetter; this.visitorServices = addDefaultVisitors( visitorServices ); }
Example #3
Source File: HelpUtils.java From pentaho-kettle with Apache License 2.0 | 6 votes |
public static ShowHelpDialog openHelpDialog( Shell shell, PluginInterface plugin ) { if ( shell == null || plugin == null ) { return null; } if ( isPluginDocumented( plugin ) ) { return openHelpDialog( shell, getHelpDialogTitle( plugin ), plugin.getDocumentationUrl(), plugin.getName() ); } else { MessageBox mb = new MessageBox( shell, SWT.OK | SWT.ICON_ERROR ); String msgKey = ""; // TODO currently support only Step and JobEntry - extend if required. if ( plugin.getPluginType().equals( StepPluginType.class ) ) { msgKey = "System.ShowHelpDialog.Step.HelpIsNotAvailable"; } else { msgKey = "System.ShowHelpDialog.JobEntry.HelpIsNotAvailable"; } mb.setMessage( BaseMessages.getString( PKG, msgKey, plugin.getName() ) ); mb.setText( BaseMessages.getString( PKG, "System.Dialog.Error.Title" ) ); mb.open(); } return null; }
Example #4
Source File: PluginPropertiesUtil.java From pentaho-hadoop-shims with Apache License 2.0 | 6 votes |
/** * Loads a properties file from the plugin directory for the plugin interface provided * * @param plugin * @return * @throws KettleFileException * @throws IOException */ protected Properties loadProperties( PluginInterface plugin, String relativeName ) throws KettleFileException, IOException { if ( plugin == null ) { throw new NullPointerException(); } FileObject propFile = KettleVFS.getFileObject( plugin.getPluginDirectory().getPath() + Const.FILE_SEPARATOR + relativeName ); if ( !propFile.exists() ) { throw new FileNotFoundException( propFile.toString() ); } try { return new PropertiesConfigurationProperties( propFile ); } catch ( ConfigurationException e ) { throw new IOException( e ); } }
Example #5
Source File: RepositoryConnectControllerTest.java From pentaho-kettle with Apache License 2.0 | 6 votes |
@Before public void setUp() { controller = new RepositoryConnectController( pluginRegistry, () -> spoon, repositoriesMeta ); when( pluginInterface.getName() ).thenReturn( PLUGIN_NAME ); when( pluginInterface.getIds() ).thenReturn( new String[] { ID } ); when( pluginInterface.getDescription() ).thenReturn( PLUGIN_DESCRIPTION ); List<PluginInterface> plugins = new ArrayList<>(); plugins.add( pluginInterface ); when( pluginRegistry.getPlugins( RepositoryPluginType.class ) ).thenReturn( plugins ); when( repositoryMeta.getId() ).thenReturn( ID ); when( repositoryMeta.getName() ).thenReturn( PLUGIN_NAME ); when( repositoryMeta.getDescription() ).thenReturn( PLUGIN_DESCRIPTION ); }
Example #6
Source File: Encr.java From pentaho-kettle with Apache License 2.0 | 6 votes |
public static void init( String encoderPluginId ) throws KettleException { if ( Utils.isEmpty( encoderPluginId ) ) { throw new KettleException( "Unable to initialize the two way password encoder: No encoder plugin type specified." ); } PluginRegistry registry = PluginRegistry.getInstance(); PluginInterface plugin = registry.findPluginWithId( TwoWayPasswordEncoderPluginType.class, encoderPluginId ); if ( plugin == null ) { throw new KettleException( "Unable to find plugin with ID '" + encoderPluginId + "'. If this is a test, make sure" + " kettle-core tests jar is a dependency. If this is live make sure a kettle-password-encoder-plugins.xml" + " exits in the classpath" ); } encoder = (TwoWayPasswordEncoderInterface) registry.loadClass( plugin ); // Load encoder specific options... // try { encoder.init(); } catch ( PasswordEncoderException e ) { throw new KettleException( e ); } }
Example #7
Source File: LegacyShimLocator.java From pentaho-hadoop-shims with Apache License 2.0 | 6 votes |
public static String getLegacyDefaultShimDir( String shimFolder ) throws IOException { PluginInterface pluginInterface = PluginRegistry.getInstance().findPluginWithId( LifecyclePluginType.class, HADOOP_SPOON_PLUGIN ); Properties legacyProperties; try { legacyProperties = loadProperties( pluginInterface, BIG_DATA_PLUGIN_PROPERTIES ); String legacyShimsFolder = legacyProperties.getProperty( HADOOP_CONFIGURATIONS_PATH ); FileObject shimDirectoryObject = KettleVFS.getFileObject( pluginInterface.getPluginDirectory().getPath() + Const.FILE_SEPARATOR + legacyShimsFolder + Const.FILE_SEPARATOR + shimFolder ); return shimDirectoryObject.getURL().getPath(); } catch ( KettleFileException | NullPointerException e ) { throw new IOException( e ); } }
Example #8
Source File: LegacyShimLocator.java From pentaho-hadoop-shims with Apache License 2.0 | 6 votes |
/** * Loads a properties file from the plugin directory for the plugin interface provided * * @param plugin * @return * @throws KettleFileException * @throws IOException */ private static Properties loadProperties( PluginInterface plugin, String relativeName ) throws KettleFileException, IOException { if ( plugin == null ) { throw new NullPointerException(); } FileObject propFile = KettleVFS.getFileObject( plugin.getPluginDirectory().getPath() + Const.FILE_SEPARATOR + relativeName ); if ( !propFile.exists() ) { throw new FileNotFoundException( propFile.toString() ); } try { Properties pluginProperties = new Properties(); pluginProperties.load( new FileInputStream( propFile.getName().getPath() ) ); return pluginProperties; } catch ( Exception e ) { // Do not catch ConfigurationException. Different shims will use different // packages for this exception. throw new IOException( e ); } }
Example #9
Source File: RepositoriesHelper.java From pentaho-kettle with Apache License 2.0 | 6 votes |
public void editRepository() { try { PluginInterface plugin = null; RepositoryMeta ri = input.searchRepository( model.getSelectedRepository().getName() ); if ( ri != null ) { plugin = PluginRegistry.getInstance().getPlugin( RepositoryPluginType.class, ri.getId() ); if ( plugin == null ) { throw new KettleException( BaseMessages .getString( PKG, "RepositoryLogin.ErrorFindingPlugin", ri.getId() ) ); } } RepositoryDialogInterface dd = getRepositoryDialog( plugin, ri, input, this.shell ); if ( dd.open( MODE.EDIT ) != null ) { fillRepositories(); int idx = input.indexOfRepository( ri ); model.setSelectedRepository( input.getRepository( idx ) ); writeData(); } } catch ( Exception e ) { log.logDetailed( BaseMessages.getString( PKG, "RepositoryLogin.ErrorEditingRepository", e .getLocalizedMessage() ) ); new ErrorDialog( shell, BaseMessages.getString( PKG, "Dialog.Error" ), BaseMessages.getString( PKG, "RepositoryLogin.ErrorEditingRepository", e.getLocalizedMessage() ), e ); } }
Example #10
Source File: JobEntryEvalTableContentTest.java From pentaho-kettle with Apache License 2.0 | 6 votes |
@BeforeClass public static void setUpBeforeClass() throws Exception { KettleClientEnvironment.init(); dbMap.put( DatabaseInterface.class, DBMockIface.class.getName() ); dbMap.put( InfobrightDatabaseMeta.class, InfobrightDatabaseMeta.class.getName() ); PluginRegistry preg = PluginRegistry.getInstance(); PluginInterface mockDbPlugin = mock( PluginInterface.class ); when( mockDbPlugin.matches( anyString() ) ).thenReturn( true ); when( mockDbPlugin.isNativePlugin() ).thenReturn( true ); when( mockDbPlugin.getMainType() ).thenAnswer( (Answer<Class<?>>) invocation -> DatabaseInterface.class ); when( mockDbPlugin.getPluginType() ).thenAnswer( (Answer<Class<? extends PluginTypeInterface>>) invocation -> DatabasePluginType.class ); when( mockDbPlugin.getIds() ).thenReturn( new String[] { "Oracle", "mock-db-id" } ); when( mockDbPlugin.getName() ).thenReturn( "mock-db-name" ); when( mockDbPlugin.getClassMap() ).thenReturn( dbMap ); preg.registerPlugin( DatabasePluginType.class, mockDbPlugin ); }
Example #11
Source File: SwingGUIResource.java From pentaho-kettle with Apache License 2.0 | 6 votes |
private Map<String, SwingUniversalImage> loadStepImages() { Map<String, SwingUniversalImage> map = new HashMap<>(); for ( PluginInterface plugin : PluginRegistry.getInstance().getPlugins( StepPluginType.class ) ) { try { SwingUniversalImage image = getUniversalImageIcon( plugin ); for ( String id : plugin.getIds() ) { map.put( id, image ); } } catch ( Exception e ) { log.logError( "Unable to load step icon image for plugin: " + plugin.getName() + " (id=" + plugin.getIds()[0] + ")", e ); } } return map; }
Example #12
Source File: JobDialog.java From pentaho-kettle with Apache License 2.0 | 6 votes |
public static final Button setShellImage( Shell shell, JobEntryInterface jobEntryInterface ) { Button helpButton = null; try { final PluginInterface plugin = getPlugin( jobEntryInterface ); if ( plugin.getCategory().equals( BaseMessages.getString( PKGBASE, "JobCategory.Category.Deprecated" ) ) ) { addDeprecation( shell ); } helpButton = HelpUtils.createHelpButton( shell, HelpUtils.getHelpDialogTitle( plugin ), plugin ); shell.setImage( getImage( shell, plugin ) ); } catch ( Throwable e ) { // Ignore unexpected errors, not worth it } return helpButton; }
Example #13
Source File: CompressionProviderFactory.java From pentaho-kettle with Apache License 2.0 | 6 votes |
@Override public CompressionProvider getCompressionProviderByName( String name ) { if ( name == null ) { return null; } CompressionProvider foundProvider = null; List<PluginInterface> providers = getPlugins(); if ( providers != null ) { for ( PluginInterface plugin : providers ) { try { CompressionProvider provider = PluginRegistry.getInstance().loadClass( plugin, CompressionProvider.class ); if ( provider != null && name.equals( provider.getName() ) ) { foundProvider = provider; } } catch ( Exception e ) { // Do nothing here, if we can't load the provider, don't add it to the list } } } return foundProvider; }
Example #14
Source File: CompressionProviderFactory.java From pentaho-kettle with Apache License 2.0 | 6 votes |
@Override public String[] getCompressionProviderNames() { ArrayList<String> providerNames = new ArrayList<String>(); List<PluginInterface> providers = getPlugins(); if ( providers != null ) { for ( PluginInterface plugin : providers ) { try { CompressionProvider provider = PluginRegistry.getInstance().loadClass( plugin, CompressionProvider.class ); if ( provider != null ) { providerNames.add( provider.getName() ); } } catch ( Exception e ) { // Do nothing here, if we can't load the provider, don't add it to the list } } } return providerNames.toArray( new String[providerNames.size()] ); }
Example #15
Source File: CompressionProviderFactory.java From pentaho-kettle with Apache License 2.0 | 6 votes |
@Override public CompressionProvider createCompressionProviderInstance( String name ) { CompressionProvider provider = null; List<PluginInterface> providers = getPlugins(); if ( providers != null ) { for ( PluginInterface plugin : providers ) { if ( name != null && name.equalsIgnoreCase( plugin.getName() ) ) { try { return PluginRegistry.getInstance().loadClass( plugin, CompressionProvider.class ); } catch ( Exception e ) { provider = null; } } } } return provider; }
Example #16
Source File: ImportRules.java From pentaho-kettle with Apache License 2.0 | 6 votes |
public void loadXML( Node rulesNode ) throws KettleException { List<Node> ruleNodes = XMLHandler.getNodes( rulesNode, BaseImportRule.XML_TAG ); for ( Node ruleNode : ruleNodes ) { String id = XMLHandler.getTagValue( ruleNode, "id" ); PluginRegistry registry = PluginRegistry.getInstance(); PluginInterface plugin = registry.findPluginWithId( ImportRulePluginType.class, id ); if ( plugin == null ) { throw new KettleException( "The import rule of type '" + id + "' could not be found in the plugin registry." ); } ImportRuleInterface rule = (ImportRuleInterface) registry.loadClass( plugin ); rule.loadXML( ruleNode ); getRules().add( rule ); } }
Example #17
Source File: SpoonUiExtenderPluginType.java From pentaho-kettle with Apache License 2.0 | 6 votes |
public List<SpoonUiExtenderPluginInterface> getRelevantExtenders( Class<?> clazz, String uiEvent ) { PluginRegistry instance = PluginRegistry.getInstance(); List<PluginInterface> pluginInterfaces = instance.getPlugins( SpoonUiExtenderPluginType.class ); List<SpoonUiExtenderPluginInterface> relevantPluginInterfaces = new ArrayList<SpoonUiExtenderPluginInterface>( ); if ( pluginInterfaces != null ) { for ( PluginInterface pluginInterface : pluginInterfaces ) { try { Object loadClass = instance.loadClass( pluginInterface ); SpoonUiExtenderPluginInterface spoonUiExtenderPluginInterface = (SpoonUiExtenderPluginInterface) loadClass; Set<String> events = spoonUiExtenderPluginInterface.respondsTo().get( clazz ); if ( events != null && events.contains( uiEvent ) ) { relevantPluginInterfaces.add( spoonUiExtenderPluginInterface ); } } catch ( KettlePluginException e ) { e.printStackTrace(); } } } return relevantPluginInterfaces; }
Example #18
Source File: KettleLifecycleSupportTest.java From pentaho-kettle with Apache License 2.0 | 5 votes |
private KettleLifecycleListener createLifecycleListener() throws org.pentaho.di.core.exception.KettlePluginException { PluginInterface pluginInterface = mock( PluginInterface.class ); KettleLifecycleListener kettleLifecycleListener = mock( KettleLifecycleListener.class ); registeredPlugins.add( pluginInterface ); when( registry.loadClass( pluginInterface, KettleLifecycleListener.class ) ).thenReturn( kettleLifecycleListener ); when( registry.loadClass( pluginInterface ) ).thenReturn( kettleLifecycleListener ); if ( !typeListenerRegistration.getAllValues().isEmpty() ) { typeListenerRegistration.getValue().pluginAdded( pluginInterface ); } return kettleLifecycleListener; }
Example #19
Source File: JobDialog.java From pentaho-kettle with Apache License 2.0 | 5 votes |
public static Image getImage( Shell shell, PluginInterface plugin ) { String id = plugin.getIds()[0]; if ( id != null ) { return GUIResource.getInstance().getImagesJobentries().get( id ).getAsBitmapForSize( shell.getDisplay(), ConstUI.ICON_SIZE, ConstUI.ICON_SIZE ); } return null; }
Example #20
Source File: RepositoryConnectController.java From pentaho-kettle with Apache License 2.0 | 5 votes |
@SuppressWarnings( "unchecked" ) public String getPlugins() { List<PluginInterface> plugins = pluginRegistry.getPlugins( RepositoryPluginType.class ); JSONArray list = new JSONArray(); for ( PluginInterface pluginInterface : plugins ) { if ( !pluginInterface.getIds()[0].equals( "PentahoEnterpriseRepository" ) ) { JSONObject repoJSON = new JSONObject(); repoJSON.put( "id", pluginInterface.getIds()[ 0 ] ); repoJSON.put( "name", pluginInterface.getName() ); repoJSON.put( "description", pluginInterface.getDescription() ); list.add( repoJSON ); } } return list.toString(); }
Example #21
Source File: DenormaliserMetaInjectionIT.java From pentaho-kettle with Apache License 2.0 | 5 votes |
@BeforeClass public static void initKettle() throws Exception { KettleEnvironment.init( false ); Map<Class<?>, String> classMap = new HashMap<>(); classMap.put( StepMetaInterface.class, "org.pentaho.di.trans.steps.metainject.MetaInjectMeta" ); List<String> libraries = new ArrayList<>(); PluginInterface plugin = new Plugin( new String[] { "MetaInject" }, StepPluginType.class, StepMetaInterface.class, "Flow", "MetaInjectMeta", null, null, false, false, classMap, libraries, null, null ); PluginRegistry.getInstance().registerPlugin( StepPluginType.class, plugin ); }
Example #22
Source File: SpoonTreeDelegateTest.java From pentaho-kettle with Apache License 2.0 | 5 votes |
@Test public void getTreeObjects_getStepByName() { SpoonTreeDelegate std = spy( new SpoonTreeDelegate( spoon ) ); Tree selection = mock( Tree.class ); Tree core = mock( Tree.class ); TreeItem item = mock( TreeItem.class ); PluginInterface step = mock( PluginInterface.class ); PluginRegistry registry = mock( PluginRegistry.class ); TreeItem[] items = new TreeItem[] { item }; when( ConstUI.getTreeStrings( item ) ).thenReturn( new String[] { "Output", "Delete" } ); when( PluginRegistry.getInstance() ).thenReturn( registry ); doReturn( items ).when( core ).getSelection(); doReturn( null ).when( item ).getData( anyString() ); doReturn( step ).when( registry ).findPluginWithName( StepPluginType.class, "Delete" ); spoon.showJob = false; spoon.showTrans = true; TreeSelection[] ts = std.getTreeObjects( core, selection, core ); assertEquals( 1, ts.length ); assertEquals( step, ts[ 0 ].getSelection() ); }
Example #23
Source File: NormaliserMetaInjectionIT.java From pentaho-kettle with Apache License 2.0 | 5 votes |
@BeforeClass public static void initKettle() throws Exception { KettleEnvironment.init( false ); Map<Class<?>, String> classMap = new HashMap<>(); classMap.put( StepMetaInterface.class, "org.pentaho.di.trans.steps.metainject.MetaInjectMeta" ); List<String> libraries = new ArrayList<>(); PluginInterface plugin = new Plugin( new String[] { "MetaInject" }, StepPluginType.class, StepMetaInterface.class, "Flow", "MetaInjectMeta", null, null, false, false, classMap, libraries, null, null ); PluginRegistry.getInstance().registerPlugin( StepPluginType.class, plugin ); }
Example #24
Source File: BaseStreamingDialog.java From pentaho-kettle with Apache License 2.0 | 5 votes |
private Image getImage() { PluginInterface plugin = PluginRegistry.getInstance().getPlugin( StepPluginType.class, stepMeta.getStepMetaInterface() ); String id = plugin.getIds()[ 0 ]; if ( id != null ) { return GUIResource.getInstance().getImagesSteps().get( id ).getAsBitmapForSize( shell.getDisplay(), ConstUI.LARGE_ICON_SIZE, ConstUI.LARGE_ICON_SIZE ); } return null; }
Example #25
Source File: LifecycleSupport.java From pentaho-kettle with Apache License 2.0 | 5 votes |
/** * Instantiate the main plugin class types for the plugin type provided from the set of registered plugins via * {@link PluginRegistry}. * * @param pluginType * Type of plugin whose main class types should be instanticated * @return Set of plugin main class instances (a.k.a. plugins) */ static <T> Set<T> loadPlugins( Class<? extends PluginTypeInterface> pluginType, Class<T> mainPluginClass ) { Set<T> pluginInstances = new HashSet<T>(); List<PluginInterface> plugins = registry.getPlugins( pluginType ); for ( PluginInterface plugin : plugins ) { try { pluginInstances.add( registry.loadClass( plugin, mainPluginClass ) ); } catch ( Throwable e ) { LogChannel.GENERAL.logError( "Unexpected error loading class for plugin " + plugin.getName(), e ); } } return pluginInstances; }
Example #26
Source File: CommonStepDialog.java From pentaho-kettle with Apache License 2.0 | 5 votes |
protected Image getImage() { final PluginInterface plugin = PluginRegistry.getInstance().getPlugin( StepPluginType.class, stepMeta.getStepMetaInterface() ); final String id = plugin.getIds()[ 0 ]; if ( id != null ) { return GUIResource.getInstance().getImagesSteps().get( id ).getAsBitmapForSize( shell.getDisplay(), ConstUI.LARGE_ICON_SIZE, ConstUI.LARGE_ICON_SIZE ); } return null; }
Example #27
Source File: ExtensionPointMap.java From pentaho-kettle with Apache License 2.0 | 5 votes |
/** * Reinitialize the extension point plugins map */ public void reInitialize() { lock.writeLock().lock(); try { extensionPointPluginMap = HashBasedTable.create(); final PluginRegistry registry = PluginRegistry.getInstance(); List<PluginInterface> extensionPointPlugins = registry.getPlugins( ExtensionPointPluginType.class ); for ( PluginInterface extensionPointPlugin : extensionPointPlugins ) { addExtensionPoint( extensionPointPlugin ); } } finally { lock.writeLock().unlock(); } }
Example #28
Source File: TransSupplier.java From pentaho-kettle with Apache License 2.0 | 5 votes |
/** * Uses a trans variable called "engine" to determine which engine to use. */ private Predicate<PluginInterface> useThisEngine() { return plugin -> Arrays.stream( plugin.getIds() ) .filter( id -> id.equals( ( transMeta.getVariable( "engine" ) ) ) ) .findAny() .isPresent(); }
Example #29
Source File: FatJarBuilder.java From kettle-beam with Apache License 2.0 | 5 votes |
private PluginInterface findPluginWithMainClass( String extraPluginClass, Class<? extends PluginTypeInterface> pluginTypeClass, Class<?> mainClass) { List<PluginInterface> plugins = PluginRegistry.getInstance().getPlugins( pluginTypeClass ); for (PluginInterface plugin : plugins) { String check = plugin.getClassMap().get( mainClass ); if (check!=null && check.equals(extraPluginClass)) { return plugin; } } return null; }
Example #30
Source File: StepPartitioningMeta.java From pentaho-kettle with Apache License 2.0 | 5 votes |
public static final String getMethod( String name ) { if ( Utils.isEmpty( name ) ) { return methodCodes[PARTITIONING_METHOD_NONE]; } for ( int i = 0; i < methodDescriptions.length; i++ ) { if ( methodDescriptions[i].equalsIgnoreCase( name ) ) { return methodCodes[i]; } } for ( int i = 0; i < methodCodes.length; i++ ) { if ( methodCodes[i].equalsIgnoreCase( name ) ) { return methodCodes[i]; } } PluginRegistry registry = PluginRegistry.getInstance(); PluginInterface plugin = registry.findPluginWithName( PartitionerPluginType.class, name ); if ( plugin != null ) { return name; } plugin = registry.findPluginWithId( PartitionerPluginType.class, name ); if ( plugin != null ) { return name; } return methodCodes[PARTITIONING_METHOD_NONE]; }