Search in sources :

Example 1 with PluginTypeInterface

use of org.pentaho.di.core.plugins.PluginTypeInterface in project pentaho-kettle by pentaho.

the class JobEntryEvalTableContentTest method setUpBeforeClass.

// private static DBMockIface dbi = DBMockIface();
@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();
    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);
}
Also used : DatabaseMeta(org.pentaho.di.core.database.DatabaseMeta) Result(org.pentaho.di.core.Result) RestorePDIEngineEnvironment(org.pentaho.di.junit.rules.RestorePDIEngineEnvironment) BeforeClass(org.junit.BeforeClass) HashMap(java.util.HashMap) KettleClientEnvironment(org.pentaho.di.core.KettleClientEnvironment) DatabasePluginType(org.pentaho.di.core.plugins.DatabasePluginType) Matchers.anyString(org.mockito.Matchers.anyString) PluginInterface(org.pentaho.di.core.plugins.PluginInterface) Answer(org.mockito.stubbing.Answer) KettleDatabaseException(org.pentaho.di.core.exception.KettleDatabaseException) Const(org.pentaho.di.core.Const) Map(java.util.Map) After(org.junit.After) PluginRegistry(org.pentaho.di.core.plugins.PluginRegistry) Job(org.pentaho.di.job.Job) DatabaseInterface(org.pentaho.di.core.database.DatabaseInterface) ClassRule(org.junit.ClassRule) JobEntryCopy(org.pentaho.di.job.entry.JobEntryCopy) Before(org.junit.Before) InfobrightDatabaseMeta(org.pentaho.di.core.database.InfobrightDatabaseMeta) AfterClass(org.junit.AfterClass) BaseDatabaseMeta(org.pentaho.di.core.database.BaseDatabaseMeta) JobMeta(org.pentaho.di.job.JobMeta) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) Mockito.when(org.mockito.Mockito.when) PluginTypeInterface(org.pentaho.di.core.plugins.PluginTypeInterface) Assert.assertFalse(org.junit.Assert.assertFalse) ValueMetaInterface(org.pentaho.di.core.row.ValueMetaInterface) Assert.assertEquals(org.junit.Assert.assertEquals) Mockito.mock(org.mockito.Mockito.mock) PluginTypeInterface(org.pentaho.di.core.plugins.PluginTypeInterface) DatabaseInterface(org.pentaho.di.core.database.DatabaseInterface) DatabasePluginType(org.pentaho.di.core.plugins.DatabasePluginType) PluginRegistry(org.pentaho.di.core.plugins.PluginRegistry) PluginInterface(org.pentaho.di.core.plugins.PluginInterface) BeforeClass(org.junit.BeforeClass) AfterClass(org.junit.AfterClass) InfobrightDatabaseMeta(org.pentaho.di.core.database.InfobrightDatabaseMeta) BeforeClass(org.junit.BeforeClass)

Example 2 with PluginTypeInterface

use of org.pentaho.di.core.plugins.PluginTypeInterface in project pentaho-kettle by pentaho.

the class KettleMissingPluginsException method getPluginsMessage.

public String getPluginsMessage() {
    StringBuilder message = new StringBuilder();
    for (PluginDetails details : missingPluginDetailsList) {
        message.append(Const.CR);
        try {
            PluginTypeInterface pluginType = PluginRegistry.getInstance().getPluginType(details.pluginTypeClass);
            message.append(pluginType.getName());
        } catch (Exception e) {
            message.append("UnknownPluginType-").append(details.pluginTypeClass.getName());
        }
        message.append(" : ").append(details.pluginId);
    }
    return message.toString();
}
Also used : PluginTypeInterface(org.pentaho.di.core.plugins.PluginTypeInterface)

Example 3 with PluginTypeInterface

use of org.pentaho.di.core.plugins.PluginTypeInterface in project pentaho-kettle by pentaho.

the class Spoon method showPluginInfo.

/**
 * Show a plugin browser
 */
public void showPluginInfo() {
    try {
        // First we collect information concerning all the plugin types...
        // 
        Map<String, RowMetaInterface> metaMap = new HashMap<>();
        Map<String, List<Object[]>> dataMap = new HashMap<>();
        PluginRegistry registry = PluginRegistry.getInstance();
        List<Class<? extends PluginTypeInterface>> pluginTypeClasses = registry.getPluginTypes();
        for (Class<? extends PluginTypeInterface> pluginTypeClass : pluginTypeClasses) {
            PluginTypeInterface pluginTypeInterface = registry.getPluginType(pluginTypeClass);
            if (pluginTypeInterface.isFragment()) {
                continue;
            }
            String subject = pluginTypeInterface.getName();
            RowBuffer pluginInformation = registry.getPluginInformation(pluginTypeClass);
            metaMap.put(subject, pluginInformation.getRowMeta());
            dataMap.put(subject, pluginInformation.getBuffer());
        }
        // Now push it all to a subject data browser...
        // 
        SubjectDataBrowserDialog dialog = new SubjectDataBrowserDialog(shell, metaMap, dataMap, "Plugin browser", "Plugin type");
        dialog.open();
    } catch (Exception e) {
        new ErrorDialog(shell, "Error", "Error listing plugins", e);
    }
}
Also used : PluginTypeInterface(org.pentaho.di.core.plugins.PluginTypeInterface) HashMap(java.util.HashMap) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) RowMetaInterface(org.pentaho.di.core.row.RowMetaInterface) ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) RowBuffer(org.pentaho.di.core.row.RowBuffer) SWTException(org.eclipse.swt.SWTException) KettleRowException(org.pentaho.di.core.exception.KettleRowException) FileSystemException(org.apache.commons.vfs2.FileSystemException) MetaStoreException(org.pentaho.metastore.api.exceptions.MetaStoreException) KettleValueException(org.pentaho.di.core.exception.KettleValueException) KettleAuthException(org.pentaho.di.core.exception.KettleAuthException) KettleRepositoryLostException(org.pentaho.di.repository.KettleRepositoryLostException) KettleXMLException(org.pentaho.di.core.exception.KettleXMLException) LifecycleException(org.pentaho.di.core.lifecycle.LifecycleException) KettleMissingPluginsException(org.pentaho.di.core.exception.KettleMissingPluginsException) KettleFileException(org.pentaho.di.core.exception.KettleFileException) KettleException(org.pentaho.di.core.exception.KettleException) MalformedURLException(java.net.MalformedURLException) SubjectDataBrowserDialog(org.pentaho.di.ui.core.dialog.SubjectDataBrowserDialog) PluginRegistry(org.pentaho.di.core.plugins.PluginRegistry) ArrayList(java.util.ArrayList) List(java.util.List) RepositoryObject(org.pentaho.di.repository.RepositoryObject) SimpleLoggingObject(org.pentaho.di.core.logging.SimpleLoggingObject) FileObject(org.apache.commons.vfs2.FileObject)

Example 4 with PluginTypeInterface

use of org.pentaho.di.core.plugins.PluginTypeInterface in project pentaho-kettle by pentaho.

the class PluginRegistryConcurrencyTest method getPlugins_WhenRegisteringPluginTypes.

@Test
public void getPlugins_WhenRegisteringPluginTypes() throws Exception {
    final int gettersAmount = 30;
    AtomicBoolean condition = new AtomicBoolean(true);
    List<Getter> getters = new ArrayList<Getter>(gettersAmount);
    for (int i = 0; i < gettersAmount; i++) {
        Class<? extends PluginTypeInterface> type = (i % 2 == 0) ? type1 : type2;
        getters.add(new Getter(condition, type));
    }
    PluginTypeInterface type = mock(PluginTypeInterface.class);
    ConcurrencyTestRunner.runAndCheckNoExceptionRaised(Collections.singletonList(new Registrar(condition, type.getClass(), 1, "")), getters, condition);
}
Also used : PluginTypeInterface(org.pentaho.di.core.plugins.PluginTypeInterface) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 5 with PluginTypeInterface

use of org.pentaho.di.core.plugins.PluginTypeInterface in project pentaho-kettle by pentaho.

the class StringEvaluatorIT method loadValueMetaPlugins.

private void loadValueMetaPlugins() {
    // Need to load the ValueMeta plugins
    PluginRegistry registry = PluginRegistry.getInstance();
    assertNotNull("Registry singleton was not found!", registry);
    // Register a new plugin type...
    // 
    PluginRegistry.addPluginType(ValueMetaPluginType.getInstance());
    // Plugin Registry should initialize without exception
    Exception initException = null;
    try {
        PluginRegistry.init();
    } catch (Exception e) {
        initException = e;
    }
    assertNull(initException);
    // There will always be a PluginRegistryPluginType, so see if we enough plugin types here.
    // 
    List<Class<? extends PluginTypeInterface>> pluginTypes = registry.getPluginTypes();
    assertTrue("At least two plugin types expected in the registry", pluginTypes.size() > 1);
    // ... and have at least 1 ValueMetaPlugin
    List<PluginInterface> valueMetaPlugins = registry.getPlugins(ValueMetaPluginType.class);
    assertTrue("Size of plugins list expected to be >1", valueMetaPlugins.size() > 1);
}
Also used : PluginTypeInterface(org.pentaho.di.core.plugins.PluginTypeInterface) PluginRegistry(org.pentaho.di.core.plugins.PluginRegistry) PluginInterface(org.pentaho.di.core.plugins.PluginInterface) ParseException(java.text.ParseException)

Aggregations

PluginTypeInterface (org.pentaho.di.core.plugins.PluginTypeInterface)5 PluginRegistry (org.pentaho.di.core.plugins.PluginRegistry)3 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 Test (org.junit.Test)2 MalformedURLException (java.net.MalformedURLException)1 ParseException (java.text.ParseException)1 List (java.util.List)1 Map (java.util.Map)1 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1 FileObject (org.apache.commons.vfs2.FileObject)1 FileSystemException (org.apache.commons.vfs2.FileSystemException)1 SWTException (org.eclipse.swt.SWTException)1 After (org.junit.After)1 AfterClass (org.junit.AfterClass)1 Assert.assertEquals (org.junit.Assert.assertEquals)1 Assert.assertFalse (org.junit.Assert.assertFalse)1 Assert.assertTrue (org.junit.Assert.assertTrue)1 Before (org.junit.Before)1 BeforeClass (org.junit.BeforeClass)1