当前位置: 首页>>代码示例>>Java>>正文


Java PluginRegistry.findPluginWithId方法代码示例

本文整理汇总了Java中org.pentaho.di.core.plugins.PluginRegistry.findPluginWithId方法的典型用法代码示例。如果您正苦于以下问题:Java PluginRegistry.findPluginWithId方法的具体用法?Java PluginRegistry.findPluginWithId怎么用?Java PluginRegistry.findPluginWithId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.pentaho.di.core.plugins.PluginRegistry的用法示例。


在下文中一共展示了PluginRegistry.findPluginWithId方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: loadXML

import org.pentaho.di.core.plugins.PluginRegistry; //导入方法依赖的package包/类
public void loadXML(Node rulesNode) throws KettleException {
  List<Node> ruleNodes = XMLHandler.getNodes(rulesNode, BaseImportRule.XML_TAG);
  for (Node ruleNode : ruleNodes) {
    String id = XMLHandler.getTagValue(ruleNode, "id");

    PluginRegistry registry = PluginRegistry.getInstance();

    PluginInterface plugin = registry.findPluginWithId(ImportRulePluginType.class, id);
    if (plugin==null) {
      throw new KettleException("The import rule of type '"+id+"' could not be found in the plugin registry.");
    }
    ImportRuleInterface rule = (ImportRuleInterface) registry.loadClass(plugin);
    
    rule.loadXML(ruleNode);

    getRules().add(rule);
  }
}
 
开发者ID:yintaoxue,项目名称:read-open-source-code,代码行数:19,代码来源:ImportRules.java

示例2: createPartitioner

import org.pentaho.di.core.plugins.PluginRegistry; //导入方法依赖的package包/类
public void createPartitioner( String method ) throws KettlePluginException {
	methodType = getMethodType(method);
    switch ( methodType ) {
    case PARTITIONING_METHOD_SPECIAL: {
    	PluginRegistry registry = PluginRegistry.getInstance();
    	PluginInterface plugin = registry.findPluginWithId(PartitionerPluginType.class, method);
    	partitioner = (Partitioner) registry.loadClass(plugin);
    	partitioner.setId(plugin.getIds()[0]);
    	break;
    }
    case PARTITIONING_METHOD_NONE:
    default: partitioner = null;
    }
    if( partitioner != null ) 
    {
    	partitioner.setMeta(this);
    }
}
 
开发者ID:yintaoxue,项目名称:read-open-source-code,代码行数:19,代码来源:StepPartitioningMeta.java

示例3: JobEntryCopy

import org.pentaho.di.core.plugins.PluginRegistry; //导入方法依赖的package包/类
public JobEntryCopy(Node entrynode, List<DatabaseMeta> databases, List<SlaveServer> slaveServers, Repository rep) throws KettleXMLException
{
	try
	{
		String stype = XMLHandler.getTagValue(entrynode, "type");
		PluginRegistry registry = PluginRegistry.getInstance();
		PluginInterface jobPlugin = registry.findPluginWithId(JobEntryPluginType.class, stype);
		if (jobPlugin == null)
			throw new KettleStepLoaderException("No valid step/plugin specified (jobPlugin=null) for " + stype);

		// Get an empty JobEntry of the appropriate class...
		entry = (JobEntryInterface) registry.loadClass(jobPlugin, JobEntryInterface.class);
		if (entry != null)
		{
			// System.out.println("New JobEntryInterface built of type:
			// "+entry.getTypeDesc());
			entry.setPluginId(jobPlugin.getIds()[0]);
			entry.loadXML(entrynode, databases, slaveServers, rep);

			// Handle GUI information: nr & location?
			setNr(Const.toInt(XMLHandler.getTagValue(entrynode, "nr"), 0));
			setLaunchingInParallel("Y".equalsIgnoreCase(XMLHandler.getTagValue(entrynode, "parallel")));
			setDrawn("Y".equalsIgnoreCase(XMLHandler.getTagValue(entrynode, "draw")));
			int x = Const.toInt(XMLHandler.getTagValue(entrynode, "xloc"), 0);
			int y = Const.toInt(XMLHandler.getTagValue(entrynode, "yloc"), 0);
			setLocation(x, y);
		}
	} catch (Throwable e)
	{
		String message = "Unable to read Job Entry copy info from XML node : " + e.toString();
		throw new KettleXMLException(message, e);
	}
}
 
开发者ID:yintaoxue,项目名称:read-open-source-code,代码行数:34,代码来源:JobEntryCopy.java

示例4: getMethod

import org.pentaho.di.core.plugins.PluginRegistry; //导入方法依赖的package包/类
public static final String getMethod(String name)
{
	if (Const.isEmpty(name)) return methodCodes[PARTITIONING_METHOD_NONE];
	
    for (int i=0;i<methodDescriptions.length;i++)
    {
        if (methodDescriptions[i].equalsIgnoreCase(name)){
        	return methodCodes[i];
        }
    }
    
    for (int i=0;i<methodCodes.length;i++)
    {
        if (methodCodes[i].equalsIgnoreCase(name)) return methodCodes[i];
    }
    
    PluginRegistry registry = PluginRegistry.getInstance();
    PluginInterface plugin = registry.findPluginWithName(PartitionerPluginType.class, name);
    if( plugin != null ) {
    	return name;
    }
    plugin = registry.findPluginWithId(PartitionerPluginType.class, name);
    if( plugin != null ) {
    	return name;
    }

    
    return methodCodes[PARTITIONING_METHOD_NONE];
}
 
开发者ID:yintaoxue,项目名称:read-open-source-code,代码行数:30,代码来源:StepPartitioningMeta.java

示例5: testRule

import org.pentaho.di.core.plugins.PluginRegistry; //导入方法依赖的package包/类
public void testRule() throws Exception {

    // Create a job to test.
    //
    JobMeta jobMeta = new JobMeta();
    NotePadMeta note = new NotePadMeta( "A note documenting the transformation", 50, 50, 200, 50 );
    jobMeta.addNote( note );

    // Load the plugin to test from the registry.
    //
    PluginRegistry registry = PluginRegistry.getInstance();
    PluginInterface plugin = registry.findPluginWithId( ImportRulePluginType.class, "JobHasANote" );
    assertNotNull( "The 'job has a note' rule could not be found in the plugin registry!", plugin );

    JobHasANoteImportRule rule = (JobHasANoteImportRule) registry.loadClass( plugin );
    assertNotNull( "The 'job has a note' rule 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 a note'", !feedback.isEmpty() );
    assertTrue(
      "An approval ruling was expected",
      feedback.get( 0 ).getResultType() == ImportValidationResultType.APPROVAL );

    jobMeta.removeNote( 0 );

    feedback = rule.verifyRule( jobMeta );
    assertTrue( "We didn't get any feedback from the 'job has a note' rule", !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 note' rule while disabled", feedback.isEmpty() );
  }
 
开发者ID:pentaho,项目名称:pentaho-kettle,代码行数:38,代码来源:JobHasANoteImportRuleIT.java

示例6: testRule

import org.pentaho.di.core.plugins.PluginRegistry; //导入方法依赖的package包/类
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());
  
}
 
开发者ID:bsspirit,项目名称:kettle-4.4.0-stable,代码行数:36,代码来源:TransformationHasANoteImportRuleTest.java

示例7: testRule

import org.pentaho.di.core.plugins.PluginRegistry; //导入方法依赖的package包/类
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() );

  }
 
开发者ID:pentaho,项目名称:pentaho-kettle,代码行数:40,代码来源:TransformationHasANoteImportRuleIT.java

示例8: testRule

import org.pentaho.di.core.plugins.PluginRegistry; //导入方法依赖的package包/类
public void testRule() throws Exception {
  
  JobMeta jobMeta = new JobMeta();
  jobMeta.setDescription("This job is used for testing an import rule");
 
  PluginRegistry registry = PluginRegistry.getInstance();
  
  PluginInterface plugin = registry.findPluginWithId(ImportRulePluginType.class, "JobHasDescription");
  assertNotNull("The 'job has description' rule could not be found in the plugin registry!", plugin);
  
  JobHasDescriptionImportRule rule = (JobHasDescriptionImportRule) registry.loadClass(plugin);
  assertNotNull("The 'job has description rule' class could not be loaded by the plugin registry!", plugin);

  rule.setMinLength(20);
  rule.setEnabled(true);

  List<ImportValidationFeedback> feedback = rule.verifyRule(jobMeta);
  assertTrue("We didn't get any feedback from the 'job 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(jobMeta);
  assertTrue("We didn't get any feedback from the 'job has description rule'", !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 description rule' while disabled", feedback.isEmpty());
}
 
开发者ID:bsspirit,项目名称:kettle-4.4.0-stable,代码行数:33,代码来源:JobHasDescriptionImportRuleTest.java

示例9: testRule

import org.pentaho.di.core.plugins.PluginRegistry; //导入方法依赖的package包/类
public void testRule() throws Exception {
  
  // Create a job to test.
  //
  JobMeta jobMeta = new JobMeta();
  NotePadMeta note = new NotePadMeta("A note documenting the transformation", 50, 50, 200, 50);
  jobMeta.addNote(note);

  // Load the plugin to test from the registry.
  //
  PluginRegistry registry = PluginRegistry.getInstance();
  PluginInterface plugin = registry.findPluginWithId(ImportRulePluginType.class, "JobHasANote");
  assertNotNull("The 'job has a note' rule could not be found in the plugin registry!", plugin);

  JobHasANoteImportRule rule = (JobHasANoteImportRule) registry.loadClass(plugin);
  assertNotNull("The 'job has a note' rule 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 a note'", !feedback.isEmpty());
  assertTrue("An approval ruling was expected", feedback.get(0).getResultType()==ImportValidationResultType.APPROVAL);

  jobMeta.removeNote(0);

  feedback = rule.verifyRule(jobMeta);
  assertTrue("We didn't get any feedback from the 'job has a note' rule", !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 note' rule while disabled", feedback.isEmpty());
}
 
开发者ID:bsspirit,项目名称:kettle-4.4.0-stable,代码行数:35,代码来源:JobHasANoteImportRuleTest.java

示例10: testRule

import org.pentaho.di.core.plugins.PluginRegistry; //导入方法依赖的package包/类
public void testRule() throws Exception {

    JobMeta jobMeta = new JobMeta();
    jobMeta.setDescription( "This job is used for testing an import rule" );

    PluginRegistry registry = PluginRegistry.getInstance();

    PluginInterface plugin = registry.findPluginWithId( ImportRulePluginType.class, "JobHasDescription" );
    assertNotNull( "The 'job has description' rule could not be found in the plugin registry!", plugin );

    JobHasDescriptionImportRule rule = (JobHasDescriptionImportRule) registry.loadClass( plugin );
    assertNotNull( "The 'job has description rule' class could not be loaded by the plugin registry!", plugin );

    rule.setMinLength( 20 );
    rule.setEnabled( true );

    List<ImportValidationFeedback> feedback = rule.verifyRule( jobMeta );
    assertTrue( "We didn't get any feedback from the 'job 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( jobMeta );
    assertTrue( "We didn't get any feedback from the 'job has description rule'", !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 description rule' while disabled", feedback
      .isEmpty() );
  }
 
开发者ID:pentaho,项目名称:pentaho-kettle,代码行数:37,代码来源:JobHasDescriptionImportRuleIT.java

示例11: getMethod

import org.pentaho.di.core.plugins.PluginRegistry; //导入方法依赖的package包/类
public static final String getMethod( String name ) {
  if ( Utils.isEmpty( name ) ) {
    return methodCodes[PARTITIONING_METHOD_NONE];
  }

  for ( int i = 0; i < methodDescriptions.length; i++ ) {
    if ( methodDescriptions[i].equalsIgnoreCase( name ) ) {
      return methodCodes[i];
    }
  }

  for ( int i = 0; i < methodCodes.length; i++ ) {
    if ( methodCodes[i].equalsIgnoreCase( name ) ) {
      return methodCodes[i];
    }
  }

  PluginRegistry registry = PluginRegistry.getInstance();
  PluginInterface plugin = registry.findPluginWithName( PartitionerPluginType.class, name );
  if ( plugin != null ) {
    return name;
  }
  plugin = registry.findPluginWithId( PartitionerPluginType.class, name );
  if ( plugin != null ) {
    return name;
  }

  return methodCodes[PARTITIONING_METHOD_NONE];
}
 
开发者ID:pentaho,项目名称:pentaho-kettle,代码行数:30,代码来源:StepPartitioningMeta.java

示例12: loadStepMeta

import org.pentaho.di.core.plugins.PluginRegistry; //导入方法依赖的package包/类
/**
    * Create a new step by loading the metadata from the specified repository.  
    * @param rep
    * @param id_step
    * @param databases
    * @param counters
    * @param partitionSchemas
    * @throws KettleException
    */
public StepMeta loadStepMeta( ObjectId id_step, List<DatabaseMeta> databases, Map<String, Counter> counters, List<PartitionSchema> partitionSchemas) throws KettleException
{
       StepMeta stepMeta = new StepMeta();
       PluginRegistry registry = PluginRegistry.getInstance();

	try
	{
		RowMetaAndData r = getStep(id_step);
		if (r!=null)
		{
			stepMeta.setObjectId(id_step);
			
			stepMeta.setName( r.getString("NAME", null) ); //$NON-NLS-1$
			stepMeta.setDescription( r.getString("DESCRIPTION", null) ); //$NON-NLS-1$
			
			long id_step_type = r.getInteger("ID_STEP_TYPE", -1L); //$NON-NLS-1$
			RowMetaAndData steptyperow = getStepType(new LongObjectId(id_step_type));
			
			stepMeta.setStepID( steptyperow.getString("CODE", null) ); //$NON-NLS-1$
			stepMeta.setDistributes( r.getBoolean("DISTRIBUTE", true) ); //$NON-NLS-1$
			stepMeta.setCopies( (int)r.getInteger("COPIES", 1) ); //$NON-NLS-1$
			int x = (int)r.getInteger("GUI_LOCATION_X", 0); //$NON-NLS-1$
			int y = (int)r.getInteger("GUI_LOCATION_Y", 0); //$NON-NLS-1$
			stepMeta.setLocation( new Point(x,y) );
			stepMeta.setDraw( r.getBoolean("GUI_DRAW", false) ); //$NON-NLS-1$
			
			// Generate the appropriate class...
			PluginInterface sp = registry.findPluginWithId(StepPluginType.class, stepMeta.getStepID());
               if (sp!=null)
               {
               	stepMeta.setStepMetaInterface( (StepMetaInterface)registry.loadClass(sp) );
               }
               else
               {
                   throw new KettleStepLoaderException(BaseMessages.getString(PKG, "StepMeta.Exception.UnableToLoadClass",stepMeta.getStepID()+Const.CR)); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
               }

			if (stepMeta.getStepMetaInterface()!=null)
			{
				// Read the step info from the repository!
				stepMeta.getStepMetaInterface().readRep(repository, stepMeta.getObjectId(), databases, counters);
			}
               
               // Get the partitioning as well...
			stepMeta.setStepPartitioningMeta( loadStepPartitioningMeta(stepMeta.getObjectId()) );
			stepMeta.getStepPartitioningMeta().setPartitionSchemaAfterLoading(partitionSchemas);
               
               // Get the cluster schema name
               stepMeta.setClusterSchemaName( repository.getStepAttributeString(id_step, "cluster_schema") );
               
               // Done!
               return stepMeta;
		}
		else
		{
			throw new KettleException(BaseMessages.getString(PKG, "StepMeta.Exception.StepInfoCouldNotBeFound",String.valueOf(id_step))); //$NON-NLS-1$ //$NON-NLS-2$
		}
	}
	catch(KettleDatabaseException dbe)
	{
		throw new KettleException(BaseMessages.getString(PKG, "StepMeta.Exception.StepCouldNotBeLoaded",String.valueOf(stepMeta.getObjectId())), dbe); //$NON-NLS-1$ //$NON-NLS-2$
	}
}
 
开发者ID:yintaoxue,项目名称:read-open-source-code,代码行数:73,代码来源:KettleDatabaseRepositoryStepDelegate.java

示例13: readJobEntry

import org.pentaho.di.core.plugins.PluginRegistry; //导入方法依赖的package包/类
protected JobEntryInterface readJobEntry( DataNode copyNode, JobMeta jobMeta, List<JobEntryInterface> jobentries )
  throws KettleException {
  try {
    String name = getString( copyNode, PROP_NAME );
    for ( JobEntryInterface entry : jobentries ) {
      if ( entry.getName().equalsIgnoreCase( name ) ) {
        return entry; // already loaded!
      }
    }

    // load the entry from the node
    //
    String typeId = getString( copyNode, PROP_JOBENTRY_TYPE );

    PluginRegistry registry = PluginRegistry.getInstance();
    PluginInterface jobPlugin = registry.findPluginWithId( JobEntryPluginType.class, typeId );
    JobEntryInterface jobMetaInterface = null;
    boolean isMissing = jobPlugin == null;
    if ( !isMissing ) {
      jobMetaInterface = (JobEntryInterface) registry.loadClass( jobPlugin );
    } else {
      MissingEntry missingEntry = new MissingEntry( jobMeta.getName(), typeId );
      jobMeta.addMissingEntry( missingEntry );
      jobMetaInterface = missingEntry;
    }
    jobMetaInterface.setName( name );
    jobMetaInterface.setDescription( getString( copyNode, PROP_DESCRIPTION ) );
    jobMetaInterface.setObjectId( new StringObjectId( copyNode.getId().toString() ) );
    RepositoryProxy proxy = new RepositoryProxy( copyNode.getNode( NODE_CUSTOM ) );

    jobMetaInterface.setMetaStore( jobMeta.getMetaStore() ); // make sure metastore is passed
    if ( !isMissing ) {
      compatibleJobEntryLoadRep( jobMetaInterface, proxy, null, jobMeta.getDatabases(), jobMeta.getSlaveServers() );
      jobMetaInterface.loadRep( proxy, jobMeta.getMetaStore(), null, jobMeta.getDatabases(), jobMeta
          .getSlaveServers() );
    }
    jobentries.add( jobMetaInterface );
    return jobMetaInterface;
  } catch ( Exception e ) {
    throw new KettleException( "Unable to read job entry interface information from repository", e );
  }
}
 
开发者ID:pentaho,项目名称:pentaho-kettle,代码行数:43,代码来源:JobDelegate.java

示例14: testRule

import org.pentaho.di.core.plugins.PluginRegistry; //导入方法依赖的package包/类
public void testRule() throws Exception {

    JobMeta jobMeta = new JobMeta();
    DatabaseMeta logDbMeta =
      new DatabaseMeta( "LOGDB", "MYSQL", "JDBC", "localhost", "test", "3306", "foo", "bar" );
    jobMeta.addDatabase( logDbMeta );
    JobLogTable logTable = jobMeta.getJobLogTable();

    PluginRegistry registry = PluginRegistry.getInstance();

    PluginInterface plugin = registry.findPluginWithId( ImportRulePluginType.class, "JobHasJobLogConfigured" );
    assertNotNull(
      "The 'job has job log table configured' rule could not be found in the plugin registry!", plugin );

    JobHasJobLogConfiguredImportRule rule = (JobHasJobLogConfiguredImportRule) registry.loadClass( plugin );
    assertNotNull(
      "The 'job has job log table configured' 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 job 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( jobMeta );
    assertTrue( "We didn't get any feedback from the 'job 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( jobMeta );
    assertTrue( "We didn't get any feedback from the 'job 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( jobMeta );
    assertTrue( "We didn't get any feedback from the 'job 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( jobMeta );
    assertTrue( "We didn't get any feedback from the 'job 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( jobMeta );
    assertTrue( "We didn't get any feedback from the 'job 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( jobMeta );
    assertTrue(
      "We didn't expect any feedback from the 'job has job log table configured' since the rule is not enabled",
      feedback.isEmpty() );
  }
 
开发者ID:pentaho,项目名称:pentaho-kettle,代码行数:81,代码来源:JobHasJobLogConfiguredImportRuleIT.java

示例15: testRule

import org.pentaho.di.core.plugins.PluginRegistry; //导入方法依赖的package包/类
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());
  }
 
开发者ID:bsspirit,项目名称:kettle-4.4.0-stable,代码行数:78,代码来源:DatabaseConfigurationImportRuleTest.java


注:本文中的org.pentaho.di.core.plugins.PluginRegistry.findPluginWithId方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。