Search in sources :

Example 1 with TransformationHasDescriptionImportRule

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

the class TransformationHasDescriptionImportRuleComposite method setCompositeData.

public void setCompositeData(ImportRuleInterface importRule) {
    TransformationHasDescriptionImportRule rule = (TransformationHasDescriptionImportRule) importRule;
    text.setText(Integer.toString(rule.getMinLength()));
}
Also used : TransformationHasDescriptionImportRule(org.pentaho.di.imp.rules.TransformationHasDescriptionImportRule)

Example 2 with TransformationHasDescriptionImportRule

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

the class RepositoryExporterTest method getImportRules.

private ImportRules getImportRules() {
    ImportRules imp = new ImportRules();
    List<ImportRuleInterface> impRules = new ArrayList<ImportRuleInterface>(1);
    JobHasDescriptionImportRule rule = new JobHasDescriptionImportRule();
    rule.setEnabled(true);
    rule.setMinLength(19000);
    impRules.add(rule);
    TransformationHasDescriptionImportRule trRule = new TransformationHasDescriptionImportRule() {

        public String toString() {
            return "stub to avoid call to Plugin registry";
        }
    };
    trRule.setEnabled(true);
    trRule.setMinLength(19001);
    impRules.add(trRule);
    imp.setRules(impRules);
    return imp;
}
Also used : ImportRules(org.pentaho.di.imp.ImportRules) JobHasDescriptionImportRule(org.pentaho.di.imp.rules.JobHasDescriptionImportRule) ImportRuleInterface(org.pentaho.di.imp.rule.ImportRuleInterface) ArrayList(java.util.ArrayList) TransformationHasDescriptionImportRule(org.pentaho.di.imp.rules.TransformationHasDescriptionImportRule)

Example 3 with TransformationHasDescriptionImportRule

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

the class TransformationHasDescriptionImportRuleComposite method getCompositeData.

public void getCompositeData(ImportRuleInterface importRule) {
    TransformationHasDescriptionImportRule rule = (TransformationHasDescriptionImportRule) importRule;
    rule.setMinLength(Const.toInt(text.getText(), 0));
}
Also used : TransformationHasDescriptionImportRule(org.pentaho.di.imp.rules.TransformationHasDescriptionImportRule)

Example 4 with TransformationHasDescriptionImportRule

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

the class TransformationHasDescriptionImportRuleIT method testRule.

public void testRule() throws Exception {
    TransMeta transMeta = new TransMeta();
    transMeta.setDescription("This transformation is used for testing an import rule");
    PluginRegistry registry = PluginRegistry.getInstance();
    PluginInterface plugin = registry.findPluginWithId(ImportRulePluginType.class, "TransformationHasDescription");
    assertNotNull("The 'transformation has description' rule could not be found in the plugin registry!", plugin);
    TransformationHasDescriptionImportRule rule = (TransformationHasDescriptionImportRule) registry.loadClass(plugin);
    assertNotNull("The 'transformation has description rule' class could not be loaded by the plugin registry!", plugin);
    rule.setMinLength(20);
    rule.setEnabled(true);
    List<ImportValidationFeedback> 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);
    rule.setMinLength(2000);
    rule.setEnabled(true);
    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.setEnabled(false);
    feedback = rule.verifyRule(transMeta);
    assertTrue("We didn't expect any feedback from the 'transformation has description rule' while disabled", feedback.isEmpty());
}
Also used : PluginRegistry(org.pentaho.di.core.plugins.PluginRegistry) PluginInterface(org.pentaho.di.core.plugins.PluginInterface) TransMeta(org.pentaho.di.trans.TransMeta) TransformationHasDescriptionImportRule(org.pentaho.di.imp.rules.TransformationHasDescriptionImportRule)

Aggregations

TransformationHasDescriptionImportRule (org.pentaho.di.imp.rules.TransformationHasDescriptionImportRule)4 ArrayList (java.util.ArrayList)1 PluginInterface (org.pentaho.di.core.plugins.PluginInterface)1 PluginRegistry (org.pentaho.di.core.plugins.PluginRegistry)1 ImportRules (org.pentaho.di.imp.ImportRules)1 ImportRuleInterface (org.pentaho.di.imp.rule.ImportRuleInterface)1 JobHasDescriptionImportRule (org.pentaho.di.imp.rules.JobHasDescriptionImportRule)1 TransMeta (org.pentaho.di.trans.TransMeta)1