Search in sources :

Example 1 with TransformationHasTransLogConfiguredImportRule

use of org.pentaho.di.imp.rules.TransformationHasTransLogConfiguredImportRule in project pentaho-kettle by pentaho.

the class TransformationHasTransLogConfiguredImportRuleComposite method setCompositeData.

public void setCompositeData(ImportRuleInterface importRule) {
    TransformationHasTransLogConfiguredImportRule rule = (TransformationHasTransLogConfiguredImportRule) importRule;
    schemaText.setText(Const.NVL(rule.getSchemaName(), ""));
    tableText.setText(Const.NVL(rule.getTableName(), ""));
    connectionText.setText(Const.NVL(rule.getConnectionName(), ""));
}
Also used : TransformationHasTransLogConfiguredImportRule(org.pentaho.di.imp.rules.TransformationHasTransLogConfiguredImportRule)

Example 2 with TransformationHasTransLogConfiguredImportRule

use of org.pentaho.di.imp.rules.TransformationHasTransLogConfiguredImportRule in project pentaho-kettle by pentaho.

the class TransformationHasTransLogConfiguredImportRuleIT method testRule.

public void testRule() throws Exception {
    TransMeta transMeta = new TransMeta();
    DatabaseMeta logDbMeta = new DatabaseMeta("LOGDB", "MYSQL", "JDBC", "localhost", "test", "3306", "foo", "bar");
    transMeta.addDatabase(logDbMeta);
    TransLogTable logTable = transMeta.getTransLogTable();
    PluginRegistry registry = PluginRegistry.getInstance();
    PluginInterface plugin = registry.findPluginWithId(ImportRulePluginType.class, "TransformationHasTransLogConfigured");
    assertNotNull("The 'transformation has trans log table configured' rule could not be found in the plugin registry!", plugin);
    TransformationHasTransLogConfiguredImportRule rule = (TransformationHasTransLogConfiguredImportRule) registry.loadClass(plugin);
    assertNotNull("The 'transformation has trans log table configured' 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 trans log table configured'", !feedback.isEmpty());
    assertTrue("An error ruling was expected", feedback.get(0).getResultType() == ImportValidationResultType.ERROR);
    logTable.setTableName("SCHEMA");
    logTable.setTableName("LOGTABLE");
    logTable.setConnectionName(logDbMeta.getName());
    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);
    // Make the rules stricter!
    // 
    rule.setTableName("SCHEMA");
    rule.setTableName("LOGTABLE");
    rule.setConnectionName(logDbMeta.getName());
    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);
    // Break the rule
    // 
    rule.setSchemaName("INCORRECT_SCHEMA");
    rule.setTableName("LOGTABLE");
    rule.setConnectionName(logDbMeta.getName());
    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", feedback.get(0).getResultType() == ImportValidationResultType.ERROR);
    rule.setSchemaName("SCHEMA");
    rule.setTableName("INCORRECT_LOGTABLE");
    rule.setConnectionName(logDbMeta.getName());
    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", feedback.get(0).getResultType() == ImportValidationResultType.ERROR);
    rule.setSchemaName("SCHEMA");
    rule.setTableName("LOGTABLE");
    rule.setConnectionName("INCORRECT_DATABASE");
    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", feedback.get(0).getResultType() == ImportValidationResultType.ERROR);
    // 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 the rule is not enabled", feedback.isEmpty());
}
Also used : TransformationHasTransLogConfiguredImportRule(org.pentaho.di.imp.rules.TransformationHasTransLogConfiguredImportRule) PluginRegistry(org.pentaho.di.core.plugins.PluginRegistry) PluginInterface(org.pentaho.di.core.plugins.PluginInterface) TransMeta(org.pentaho.di.trans.TransMeta) TransLogTable(org.pentaho.di.core.logging.TransLogTable) DatabaseMeta(org.pentaho.di.core.database.DatabaseMeta)

Example 3 with TransformationHasTransLogConfiguredImportRule

use of org.pentaho.di.imp.rules.TransformationHasTransLogConfiguredImportRule in project pentaho-kettle by pentaho.

the class TransformationHasTransLogConfiguredImportRuleComposite method getCompositeData.

public void getCompositeData(ImportRuleInterface importRule) {
    TransformationHasTransLogConfiguredImportRule rule = (TransformationHasTransLogConfiguredImportRule) importRule;
    rule.setSchemaName(schemaText.getText());
    rule.setTableName(tableText.getText());
    rule.setConnectionName(connectionText.getText());
}
Also used : TransformationHasTransLogConfiguredImportRule(org.pentaho.di.imp.rules.TransformationHasTransLogConfiguredImportRule)

Aggregations

TransformationHasTransLogConfiguredImportRule (org.pentaho.di.imp.rules.TransformationHasTransLogConfiguredImportRule)3 DatabaseMeta (org.pentaho.di.core.database.DatabaseMeta)1 TransLogTable (org.pentaho.di.core.logging.TransLogTable)1 PluginInterface (org.pentaho.di.core.plugins.PluginInterface)1 PluginRegistry (org.pentaho.di.core.plugins.PluginRegistry)1 TransMeta (org.pentaho.di.trans.TransMeta)1