use of org.pentaho.di.core.plugins.PluginInterface in project pentaho-kettle by pentaho.
the class JobHasNoDisabledHopsImportRuleIT method testRule.
public void testRule() throws Exception {
// Create a job to test.
//
JobMeta jobMeta = new JobMeta();
// Add 3 dummy steps connected with hops.
//
JobEntryCopy lastCopy = null;
for (int i = 0; i < 3; i++) {
JobEntrySpecial dummy = new JobEntrySpecial();
dummy.setDummy(true);
dummy.setName("dummy" + (i + 1));
JobEntryCopy copy = new JobEntryCopy(dummy);
copy.setLocation(50 + i * 50, 50);
copy.setDrawn();
jobMeta.addJobEntry(copy);
if (lastCopy != null) {
JobHopMeta hop = new JobHopMeta(lastCopy, copy);
jobMeta.addJobHop(hop);
}
lastCopy = copy;
}
// Load the plugin to test from the registry.
//
PluginRegistry registry = PluginRegistry.getInstance();
PluginInterface plugin = registry.findPluginWithId(ImportRulePluginType.class, "JobHasNoDisabledHops");
assertNotNull("The 'job has no disabled hops' rule could not be found in the plugin registry!", plugin);
JobHasNoDisabledHopsImportRule rule = (JobHasNoDisabledHopsImportRule) registry.loadClass(plugin);
assertNotNull("The 'job has no disabled hops' class could not be loaded by the plugin registry!", plugin);
rule.setEnabled(true);
List<ImportValidationFeedback> feedback = rule.verifyRule(jobMeta);
assertTrue("We didn't get any feedback from the 'job has no disabled hops'", !feedback.isEmpty());
assertTrue("An approval ruling was expected", feedback.get(0).getResultType() == ImportValidationResultType.APPROVAL);
jobMeta.getJobHop(0).setEnabled(false);
feedback = rule.verifyRule(jobMeta);
assertTrue("We didn't get any feedback from the 'job has no disabled hops'", !feedback.isEmpty());
assertTrue("An error ruling was expected", feedback.get(0).getResultType() == ImportValidationResultType.ERROR);
rule.setEnabled(false);
feedback = rule.verifyRule(jobMeta);
assertTrue("We didn't expect any feedback from the 'job has no disabled hops' while disabled", feedback.isEmpty());
}
use of org.pentaho.di.core.plugins.PluginInterface 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());
}
use of org.pentaho.di.core.plugins.PluginInterface in project pentaho-kettle by pentaho.
the class RepositoriesHelper method editRepository.
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);
}
}
use of org.pentaho.di.core.plugins.PluginInterface in project pentaho-kettle by pentaho.
the class RepositoryExplorerDialog method getVersionBrowserDialog.
public static final RepositoryRevisionBrowserDialogInterface getVersionBrowserDialog(Shell shell, Repository repository, final RepositoryElementInterface element) throws Exception {
String className = repository.getRepositoryMeta().getRevisionBrowserDialogClassName();
PluginRegistry registry = PluginRegistry.getInstance();
PluginInterface plugin = registry.getPlugin(RepositoryPluginType.class, repository.getRepositoryMeta().getId());
Class<? extends RepositoryRevisionBrowserDialogInterface> dialogClass = registry.getClass(plugin, className);
Constructor<?> constructor = dialogClass.getConstructor(Shell.class, Integer.TYPE, Repository.class, RepositoryElementInterface.class);
return (RepositoryRevisionBrowserDialogInterface) constructor.newInstance(new Object[] { shell, Integer.valueOf(SWT.NONE), repository, element });
}
Aggregations