Search in sources :

Example 41 with PluginInterface

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

the class KettleClientEnvironment method initLogginPlugins.

private static void initLogginPlugins(List<PluginInterface> logginPlugins) throws KettlePluginException {
    for (PluginInterface plugin : logginPlugins) {
        LoggingPluginInterface loggingPlugin = (LoggingPluginInterface) PluginRegistry.getInstance().loadClass(plugin);
        loggingPlugin.init();
    }
}
Also used : LoggingPluginInterface(org.pentaho.di.core.logging.LoggingPluginInterface) LoggingPluginInterface(org.pentaho.di.core.logging.LoggingPluginInterface) PluginInterface(org.pentaho.di.core.plugins.PluginInterface)

Example 42 with PluginInterface

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

the class DatabaseMeta method findDatabaseInterface.

/**
 * Search for the right type of DatabaseInterface object and return it.
 *
 * @param databaseTypeDesc
 *          the type of DatabaseInterface to look for (id or description)
 * @return The requested DatabaseInterface
 *
 * @throws KettleDatabaseException
 *           when the type could not be found or referenced.
 */
private static final DatabaseInterface findDatabaseInterface(String databaseTypeDesc) throws KettleDatabaseException {
    PluginRegistry registry = PluginRegistry.getInstance();
    PluginInterface plugin = registry.getPlugin(DatabasePluginType.class, databaseTypeDesc);
    if (plugin == null) {
        plugin = registry.findPluginWithName(DatabasePluginType.class, databaseTypeDesc);
    }
    if (plugin == null) {
        throw new KettleDatabaseException("database type with plugin id [" + databaseTypeDesc + "] couldn't be found!");
    }
    return getDatabaseInterfacesMap().get(plugin.getIds()[0]);
}
Also used : DatabasePluginType(org.pentaho.di.core.plugins.DatabasePluginType) KettleDatabaseException(org.pentaho.di.core.exception.KettleDatabaseException) PluginRegistry(org.pentaho.di.core.plugins.PluginRegistry) PluginInterface(org.pentaho.di.core.plugins.PluginInterface)

Example 43 with PluginInterface

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

the class DatabaseConfigurationImportRuleIT method testRule.

public void testRule() throws Exception {
    // Assemble a new database.
    // 
    String DBNAME = "test";
    String HOSTNAME = "localhost";
    String PORT = "3306";
    String USERNAME = "foo";
    String PASSWORD = "bar";
    DatabaseMeta verifyMeta = new DatabaseMeta("LOGDB", "MYSQL", "JDBC", HOSTNAME, DBNAME, PORT, USERNAME, PASSWORD);
    // Create a transformation to test.
    // 
    TransMeta transMeta = new TransMeta();
    transMeta.addDatabase((DatabaseMeta) verifyMeta.clone());
    // Load the plugin to test from the registry.
    // 
    PluginRegistry registry = PluginRegistry.getInstance();
    PluginInterface plugin = registry.findPluginWithId(ImportRulePluginType.class, "DatabaseConfiguration");
    assertNotNull("The 'database configuration' rule could not be found in the plugin registry!", plugin);
    DatabaseConfigurationImportRule rule = (DatabaseConfigurationImportRule) registry.loadClass(plugin);
    assertNotNull("The 'database configuration' class could not be loaded by the plugin registry!", plugin);
    // Set the appropriate rule..
    // 
    rule.setEnabled(true);
    List<ImportValidationFeedback> feedback = rule.verifyRule(transMeta);
    assertTrue("We didn't get any feedback from the 'database configuration'", !feedback.isEmpty());
    assertTrue("An error ruling was expected", feedback.get(0).getResultType() == ImportValidationResultType.ERROR);
    rule.setDatabaseMeta(verifyMeta);
    feedback = rule.verifyRule(transMeta);
    assertTrue("We didn't get any feedback from the 'transformation has description rule'", !feedback.isEmpty());
    assertTrue("An approval ruling was expected", feedback.get(0).getResultType() == ImportValidationResultType.APPROVAL);
    // Create some errors...
    // 
    verifyMeta.setDBName("incorrect-test");
    feedback = rule.verifyRule(transMeta);
    assertTrue("We didn't get any feedback from the 'transformation has description rule'", !feedback.isEmpty());
    assertTrue("An error ruling was expected validating the db name", feedback.get(0).getResultType() == ImportValidationResultType.ERROR);
    verifyMeta.setDBName(DBNAME);
    verifyMeta.setHostname("incorrect-hostname");
    feedback = rule.verifyRule(transMeta);
    assertTrue("We didn't get any feedback from the 'transformation has description rule'", !feedback.isEmpty());
    assertTrue("An error ruling was expected validating the db hostname", feedback.get(0).getResultType() == ImportValidationResultType.ERROR);
    verifyMeta.setHostname(HOSTNAME);
    verifyMeta.setDBPort("incorrect-port");
    feedback = rule.verifyRule(transMeta);
    assertTrue("We didn't get any feedback from the 'transformation has description rule'", !feedback.isEmpty());
    assertTrue("An error ruling was expected validating the db port", feedback.get(0).getResultType() == ImportValidationResultType.ERROR);
    verifyMeta.setDBPort(PORT);
    verifyMeta.setUsername("incorrect-username");
    feedback = rule.verifyRule(transMeta);
    assertTrue("We didn't get any feedback from the 'transformation has description rule'", !feedback.isEmpty());
    assertTrue("An error ruling was expected validating the db username", feedback.get(0).getResultType() == ImportValidationResultType.ERROR);
    verifyMeta.setUsername(USERNAME);
    verifyMeta.setPassword("incorrect-password");
    feedback = rule.verifyRule(transMeta);
    assertTrue("We didn't get any feedback from the 'transformation has description rule'", !feedback.isEmpty());
    assertTrue("An error ruling was expected validating the db password", feedback.get(0).getResultType() == ImportValidationResultType.ERROR);
    verifyMeta.setPassword(PASSWORD);
    // No feedback expected!
    // 
    rule.setEnabled(false);
    feedback = rule.verifyRule(transMeta);
    assertTrue("We didn't expect any feedback from the 'transformation has trans log table configured' since disabled", feedback.isEmpty());
}
Also used : PluginRegistry(org.pentaho.di.core.plugins.PluginRegistry) PluginInterface(org.pentaho.di.core.plugins.PluginInterface) DatabaseConfigurationImportRule(org.pentaho.di.imp.rules.DatabaseConfigurationImportRule) TransMeta(org.pentaho.di.trans.TransMeta) DatabaseMeta(org.pentaho.di.core.database.DatabaseMeta)

Example 44 with PluginInterface

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

the class TransformationHasANoteImportRuleIT method testRule.

public void testRule() throws Exception {
    // Create a transformation to test.
    // 
    TransMeta transMeta = new TransMeta();
    NotePadMeta note = new NotePadMeta("A note documenting the transformation", 50, 50, 200, 50);
    transMeta.addNote(note);
    // Load the plugin to test from the registry.
    // 
    PluginRegistry registry = PluginRegistry.getInstance();
    PluginInterface plugin = registry.findPluginWithId(ImportRulePluginType.class, "TransformationHasANote");
    assertNotNull("The 'transformation has a note' rule could not be found in the plugin registry!", plugin);
    TransformationHasANoteImportRule rule = (TransformationHasANoteImportRule) registry.loadClass(plugin);
    assertNotNull("The 'transformation has a note' class could not be loaded by the plugin registry!", plugin);
    rule.setEnabled(true);
    List<ImportValidationFeedback> feedback = rule.verifyRule(transMeta);
    assertTrue("We didn't get any feedback from the 'transformation has a note' rule", !feedback.isEmpty());
    assertTrue("An approval ruling was expected", feedback.get(0).getResultType() == ImportValidationResultType.APPROVAL);
    transMeta.removeNote(0);
    feedback = rule.verifyRule(transMeta);
    assertTrue("We didn't get any feedback from the 'transformation has a note' rule", !feedback.isEmpty());
    assertTrue("An error ruling was expected", feedback.get(0).getResultType() == ImportValidationResultType.ERROR);
    rule.setEnabled(false);
    feedback = rule.verifyRule(transMeta);
    assertTrue("We didn't expect any feedback from the 'transformation has a note' rule while disabled", feedback.isEmpty());
}
Also used : TransformationHasANoteImportRule(org.pentaho.di.imp.rules.TransformationHasANoteImportRule) PluginRegistry(org.pentaho.di.core.plugins.PluginRegistry) PluginInterface(org.pentaho.di.core.plugins.PluginInterface) TransMeta(org.pentaho.di.trans.TransMeta) NotePadMeta(org.pentaho.di.core.NotePadMeta)

Example 45 with PluginInterface

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

the class TransformationHasNoDisabledHopsImportRuleIT method testRule.

public void testRule() throws Exception {
    // Create a transformation to test.
    // 
    TransMeta transMeta = new TransMeta();
    // Add 3 dummy steps connected with hops.
    // 
    StepMeta lastStep = null;
    for (int i = 0; i < 3; i++) {
        DummyTransMeta dummyTransMeta = new DummyTransMeta();
        StepMeta stepMeta = new StepMeta("dummy" + (i + 1), dummyTransMeta);
        stepMeta.setLocation(50 + i * 50, 50);
        stepMeta.setDraw(true);
        transMeta.addStep(stepMeta);
        if (lastStep != null) {
            TransHopMeta hop = new TransHopMeta(lastStep, stepMeta);
            transMeta.addTransHop(hop);
        }
        lastStep = stepMeta;
    }
    // Load the plugin to test from the registry.
    // 
    PluginRegistry registry = PluginRegistry.getInstance();
    PluginInterface plugin = registry.findPluginWithId(ImportRulePluginType.class, "TransformationHasNoDisabledHops");
    assertNotNull("The 'transformation has no disabled hops' rule could not be found in the plugin registry!", plugin);
    TransformationHasNoDisabledHopsImportRule rule = (TransformationHasNoDisabledHopsImportRule) registry.loadClass(plugin);
    assertNotNull("The 'transformation has no disabled hops' class could not be loaded by the plugin registry!", plugin);
    rule.setEnabled(true);
    List<ImportValidationFeedback> feedback = rule.verifyRule(transMeta);
    assertTrue("We didn't get any feedback from the 'transformation has no disabled hops'", !feedback.isEmpty());
    assertTrue("An approval ruling was expected", feedback.get(0).getResultType() == ImportValidationResultType.APPROVAL);
    transMeta.getTransHop(0).setEnabled(false);
    feedback = rule.verifyRule(transMeta);
    assertTrue("We didn't get any feedback from the 'transformation has no disabled hops'", !feedback.isEmpty());
    assertTrue("An error ruling was expected", feedback.get(0).getResultType() == ImportValidationResultType.ERROR);
    rule.setEnabled(false);
    feedback = rule.verifyRule(transMeta);
    assertTrue("We didn't expect any feedback from the 'transformation has no disabled hops' while disabled", feedback.isEmpty());
}
Also used : TransformationHasNoDisabledHopsImportRule(org.pentaho.di.imp.rules.TransformationHasNoDisabledHopsImportRule) PluginRegistry(org.pentaho.di.core.plugins.PluginRegistry) PluginInterface(org.pentaho.di.core.plugins.PluginInterface) TransMeta(org.pentaho.di.trans.TransMeta) DummyTransMeta(org.pentaho.di.trans.steps.dummytrans.DummyTransMeta) TransHopMeta(org.pentaho.di.trans.TransHopMeta) StepMeta(org.pentaho.di.trans.step.StepMeta) DummyTransMeta(org.pentaho.di.trans.steps.dummytrans.DummyTransMeta)

Aggregations

PluginInterface (org.pentaho.di.core.plugins.PluginInterface)99 PluginRegistry (org.pentaho.di.core.plugins.PluginRegistry)45 KettleException (org.pentaho.di.core.exception.KettleException)24 ArrayList (java.util.ArrayList)17 ValueMetaString (org.pentaho.di.core.row.value.ValueMetaString)14 ErrorDialog (org.pentaho.di.ui.core.dialog.ErrorDialog)12 TransMeta (org.pentaho.di.trans.TransMeta)11 StepMeta (org.pentaho.di.trans.step.StepMeta)11 JobEntryCopy (org.pentaho.di.job.entry.JobEntryCopy)10 Test (org.junit.Test)9 DatabaseMeta (org.pentaho.di.core.database.DatabaseMeta)9 KettleExtensionPoint (org.pentaho.di.core.extension.KettleExtensionPoint)8 Point (org.pentaho.di.core.gui.Point)8 JobMeta (org.pentaho.di.job.JobMeta)8 KettlePluginException (org.pentaho.di.core.exception.KettlePluginException)7 TransHopMeta (org.pentaho.di.trans.TransHopMeta)7 TreeItem (org.eclipse.swt.widgets.TreeItem)6 KettleDatabaseException (org.pentaho.di.core.exception.KettleDatabaseException)6 LongObjectId (org.pentaho.di.repository.LongObjectId)6 ObjectId (org.pentaho.di.repository.ObjectId)6