/** * Find the plugin ID based on the class * * @param pluginClass * @return The ID of the plugin to which this class belongs (checks the plugin class maps) */ public String getPluginId( Object pluginClass ) { return getPluginTypes().stream() .map( pluginType -> getPluginId( pluginType, pluginClass ) ) .filter( Objects::nonNull ) .findFirst() .orElse( null ); }
/** * Retrieve the Plugin for a given class * * @param pluginType The type of plugin to search for * @param pluginClass The class of this object is used to look around * @return the plugin or null if nothing could be found */ public PluginInterface getPlugin( Class<? extends PluginTypeInterface> pluginType, Object pluginClass ) { String pluginId = getPluginId( pluginType, pluginClass ); if ( pluginId == null ) { return null; } return getPlugin( pluginType, pluginId ); }
private StepMetaInterface getNewMeta() throws KettleException { PluginRegistry pluginRegistry = PluginRegistry.getInstance(); String id = pluginRegistry.getPluginId( StepPluginType.class, this ); PluginInterface plugin = pluginRegistry.getPlugin( StepPluginType.class, id ); return (StepMetaInterface) pluginRegistry.loadClass( plugin ); } }
@Override public String toString() { // The rule name with an indication of whether or not this rule is enabled should do for now. // String pluginId = PluginRegistry.getInstance().getPluginId( this ); PluginInterface plugin = PluginRegistry.getInstance().findPluginWithId( ImportRulePluginType.class, pluginId ); return plugin.getName() + " (" + ( enabled ? "enabled" : "disabled" ) + ")."; }
/** * @param stepname * The name of the new step * @param stepMetaInterface * The step metadata interface to use (TextFileInputMeta, etc) */ public StepMeta( String stepname, StepMetaInterface stepMetaInterface ) { if ( stepMetaInterface != null ) { PluginRegistry registry = PluginRegistry.getInstance(); this.stepid = registry.getPluginId( StepPluginType.class, stepMetaInterface ); setDeprecationAndSuggestedStep(); } this.name = stepname; setStepMetaInterface( stepMetaInterface ); selected = false; distributes = true; copiesString = "1"; location = new Point( 0, 0 ); drawstep = false; description = null; stepPartitioningMeta = new StepPartitioningMeta(); // targetStepPartitioningMeta = new StepPartitioningMeta(); clusterSchema = null; // non selected by default. remoteInputSteps = new ArrayList<RemoteStep>(); remoteOutputSteps = new ArrayList<RemoteStep>(); attributesMap = new HashMap<String, Map<String, String>>(); }
public void setShellImage( Shell shell, StepMetaInterface stepMetaInterface ) { try { String id = PluginRegistry.getInstance().getPluginId( StepPluginType.class, stepMetaInterface ); if ( getShell() != null && id != null ) { getShell().setImage( GUIResource.getInstance().getImagesSteps().get( id ).getAsBitmap( shell.getDisplay() ) ); } } catch ( Throwable e ) { // Ignore } }
public void setEntry( JobEntryInterface je ) { entry = je; if ( entry != null ) { if ( entry.getPluginId() == null ) { entry.setPluginId( PluginRegistry.getInstance().getPluginId( JobEntryPluginType.class, entry ) ); } setDeprecationAndSuggestedJobEntry(); } }
public static final TransMeta generatePreviewTransformation( VariableSpace parent, StepMetaInterface oneMeta, String oneStepname ) { PluginRegistry registry = PluginRegistry.getInstance(); TransMeta previewMeta = new TransMeta( parent ); // The following operation resets the internal variables! // previewMeta.setName( parent == null ? "Preview transformation" : parent.toString() ); // At it to the first step. StepMeta one = new StepMeta( registry.getPluginId( StepPluginType.class, oneMeta ), oneStepname, oneMeta ); one.setLocation( 50, 50 ); one.setDraw( true ); previewMeta.addStep( one ); DummyTransMeta twoMeta = new DummyTransMeta(); StepMeta two = new StepMeta( registry.getPluginId( StepPluginType.class, twoMeta ), "dummy", twoMeta ); two.setLocation( 250, 50 ); two.setDraw( true ); previewMeta.addStep( two ); TransHopMeta hop = new TransHopMeta( one, two ); previewMeta.addTransHop( hop ); return previewMeta; } }
static StepMeta getReadStepMeta( String name ) { DummyTransMeta twoMeta = new DummyTransMeta(); StepMeta two = new StepMeta( registry.getPluginId( StepPluginType.class, twoMeta ), name, twoMeta ); two.setLocation( 250, 50 ); two.setDraw( true ); return two; }
String loaderPid = plugReg.getPluginId( StepPluginType.class, lm );
@Before public void setUp() { TransMeta transMeta = new TransMeta(); transMeta.setName( "delete1" ); Map<String, String> vars = new HashMap<String, String>(); vars.put( "max.sz", "10" ); transMeta.injectVariables( vars ); umi = new InsertUpdateMeta(); ud = new InsertUpdateData(); PluginRegistry plugReg = PluginRegistry.getInstance(); String deletePid = plugReg.getPluginId( StepPluginType.class, umi ); stepMeta = new StepMeta( deletePid, "delete", umi ); Trans trans = new Trans( transMeta ); transMeta.addStep( stepMeta ); upd = new InsertUpdate( stepMeta, ud, 1, transMeta, trans ); upd.copyVariablesFrom( transMeta ); mockHelper = new StepMockHelper<>( "insertUpdate", InsertUpdateMeta.class, InsertUpdateData.class ); Mockito.when( mockHelper.logChannelInterfaceFactory.create( Mockito.any(), Mockito.any( LoggingObjectInterface.class ) ) ) .thenReturn( mockHelper.logChannelInterface ); Mockito.when( mockHelper.stepMeta.getStepMetaInterface() ).thenReturn( new InsertUpdateMeta() ); }
@Before public void setup() throws FileSystemException { fs = VFS.getManager(); filesPath = '/' + this.getClass().getPackage().getName().replace( '.', '/' ) + "/files/"; transName = "LoadFileInput"; transMeta = new TransMeta(); transMeta.setName( transName ); trans = new Trans( transMeta ); stepMetaInterface = spy( new LoadFileInputMeta() ); stepInputFiles = new FileInputList(); Mockito.doReturn( stepInputFiles ).when( stepMetaInterface ).getFiles( any( VariableSpace.class ) ); String stepId = PluginRegistry.getInstance().getPluginId( StepPluginType.class, stepMetaInterface ); stepMeta = new StepMeta( stepId, "Load File Input", stepMetaInterface ); transMeta.addStep( stepMeta ); stepDataInterface = new LoadFileInputData(); stepCopyNr = 0; stepLoadFileInput = new LoadFileInput( stepMeta, stepDataInterface, stepCopyNr, transMeta, trans ); assertSame( stepMetaInterface, stepMeta.getStepMetaInterface() ); runtimeSMI = stepMetaInterface; runtimeSDI = runtimeSMI.getStepData(); inputField = new LoadFileInputField(); ((LoadFileInputMeta) runtimeSMI).setInputFields( new LoadFileInputField[] { inputField } ); stepLoadFileInput.init( runtimeSMI, runtimeSDI ); }
@Before public void setUp() { TransMeta transMeta = new TransMeta(); transMeta.setName( "delete1" ); Map<String, String> vars = new HashMap<String, String>(); vars.put( "max.sz", "10" ); transMeta.injectVariables( vars ); dmi = new DeleteMeta(); dd = new DeleteData(); PluginRegistry plugReg = PluginRegistry.getInstance(); String deletePid = plugReg.getPluginId( StepPluginType.class, dmi ); stepMeta = new StepMeta( deletePid, "delete", dmi ); Trans trans = new Trans( transMeta ); transMeta.addStep( stepMeta ); del = new Delete( stepMeta, dd, 1, transMeta, trans ); del.copyVariablesFrom( transMeta ); }
String loaderPid = plugReg.getPluginId( StepPluginType.class, lm ); StepMeta stepMeta = new StepMeta( loaderPid, "loader", lm ); Trans trans = new Trans( transMeta );
ldata = new MySQLBulkLoaderData(); PluginRegistry plugReg = PluginRegistry.getInstance(); String mblPid = plugReg.getPluginId( StepPluginType.class, lmeta ); smeta = new StepMeta( mblPid, "MySqlBulkLoader", lmeta ); Trans trans = new Trans( transMeta );
@Before public void setUp() { TransMeta transMeta = new TransMeta(); transMeta.setName( "loader" ); lm = new PGBulkLoaderMeta(); ld = new PGBulkLoaderData(); PluginRegistry plugReg = PluginRegistry.getInstance(); String loaderPid = plugReg.getPluginId( StepPluginType.class, lm ); stepMeta = new StepMeta( loaderPid, "loader", lm ); Trans trans = new Trans( transMeta ); transMeta.addStep( stepMeta ); loader = new PGBulkLoader( stepMeta, ld, 1, transMeta, trans ); }
@Test( expected = KettleException.class ) public void failsWhenGivenNonSingleThreadSteps() throws Exception { Meta metaInterface = createMeta(); PluginRegistry plugReg = PluginRegistry.getInstance(); String id = plugReg.getPluginId( StepPluginType.class, metaInterface ); assertNotNull( "pluginId", id ); StepMeta stepMeta = new StepMeta( id, "stepMetrics", metaInterface ); stepMeta.setDraw( true ); TransMeta transMeta = new TransMeta(); transMeta.setName( "failsWhenGivenNonSingleThreadSteps" ); transMeta.addStep( stepMeta ); Trans trans = new Trans( transMeta ); trans.prepareExecution( null ); SingleThreadedTransExecutor executor = new SingleThreadedTransExecutor( trans ); executor.init(); } }
public static TransMeta generateTestTransformation( VariableSpace parent, StepMetaInterface oneMeta, String oneStepname, RowMetaInterface injectorRowMeta ) { TransMeta previewMeta = new TransMeta( parent ); // First the injector step... StepMeta zero = getInjectorStepMeta( injectorRowMeta ); previewMeta.addStep( zero ); // Then the middle step to test... // StepMeta one = new StepMeta( registry.getPluginId( StepPluginType.class, oneMeta ), oneStepname, oneMeta ); one.setLocation( 150, 50 ); one.setDraw( true ); previewMeta.addStep( one ); // Then we add the dummy step to read the results from StepMeta two = getReadStepMeta(); previewMeta.addStep( two ); // Add the hops between the 3 steps. TransHopMeta zeroOne = new TransHopMeta( zero, one ); previewMeta.addTransHop( zeroOne ); TransHopMeta oneTwo = new TransHopMeta( one, two ); previewMeta.addTransHop( oneTwo ); return previewMeta; }
static StepMeta getInjectorStepMeta( RowMetaInterface outputRowMeta ) { InjectorMeta zeroMeta = new InjectorMeta(); // Sets output fields for cases when no rows are sent to the test step, but metadata is still needed if ( outputRowMeta != null && outputRowMeta.size() > 0 ) { String[] fieldName = new String[outputRowMeta.size()]; int[] fieldLength = new int[outputRowMeta.size()]; int[] fieldPrecision = new int[outputRowMeta.size()]; int[] fieldType = new int[outputRowMeta.size()]; for ( int i = 0; i < outputRowMeta.size(); i++ ) { ValueMetaInterface field = outputRowMeta.getValueMeta( i ); fieldName[i] = field.getName(); fieldLength[i] = field.getLength(); fieldPrecision[i] = field.getPrecision(); fieldType[i] = field.getType(); } zeroMeta.setFieldname( fieldName ); zeroMeta.setLength( fieldLength ); zeroMeta.setPrecision( fieldPrecision ); zeroMeta.setType( fieldType ); } StepMeta zero = new StepMeta( registry.getPluginId( StepPluginType.class, zeroMeta ), INJECTOR_STEPNAME, zeroMeta ); zero.setLocation( 50, 50 ); zero.setDraw( true ); return zero; }
StepMeta one = new StepMeta( registry.getPluginId( StepPluginType.class, oneMeta ), oneStepname, oneMeta ); one.setLocation( 150, 50 ); one.setDraw( true );