public void widgetSelected( SelectionEvent e ) { input.setEnabled( !input.isEnabled() ); input.setChanged(); } } );
/** * Removes input steps having only disabled output hops so they will not be executed. * @param transMeta transMeta to process */ private static void removeDisabledInputs( TransMeta transMeta ) { List<StepMeta> unusedInputs = findHops( transMeta, hop -> !hop.isEnabled() ).stream() .map( hop -> hop.getFromStep() ) .filter( step -> isUnusedInput( transMeta, step ) ) .collect( Collectors.toList() ); for ( StepMeta unusedInput : unusedInputs ) { List<TransHopMeta> outHops = transMeta.findAllTransHopFrom( unusedInput ); List<StepMeta> subsequentSteps = outHops.stream().map( hop -> hop.getToStep() ).collect( Collectors.toList() ); outHops.forEach( transMeta::removeTransHop ); transMeta.getSteps().remove( unusedInput ); removeInactivePaths( transMeta, subsequentSteps ); } }
/** * Retrieve an array of succeeding steps for a certain originating step. * * @param stepMeta * The originating step * @return an array of succeeding steps. * @deprecated use findNextSteps instead */ @Deprecated public StepMeta[] getNextSteps( StepMeta stepMeta ) { List<StepMeta> nextSteps = new ArrayList<>(); for ( int i = 0; i < nrTransHops(); i++ ) { // Look at all the hops; TransHopMeta hi = getTransHop( i ); if ( hi.isEnabled() && hi.getFromStep().equals( stepMeta ) ) { nextSteps.add( hi.getToStep() ); } } return nextSteps.toArray( new StepMeta[nextSteps.size()] ); }
private static boolean isUnusedInput( TransMeta trans, StepMeta step ) { int nrEnabledOutHops = findHops( trans, hop -> hop.getFromStep().equals( step ) && hop.isEnabled() ).size(); int nrDisabledOutHops = findHops( trans, hop -> hop.getFromStep().equals( step ) && !hop.isEnabled() ).size(); int nrInputHops = findHops( trans, hop -> hop.getToStep().equals( step ) ).size(); return ( nrEnabledOutHops == 0 && nrDisabledOutHops > 0 && nrInputHops == 0 ); }
@Override public List<ImportValidationFeedback> verifyRule( Object subject ) { List<ImportValidationFeedback> feedback = new ArrayList<ImportValidationFeedback>(); if ( !isEnabled() ) { return feedback; } if ( !( subject instanceof TransMeta ) ) { return feedback; } TransMeta transMeta = (TransMeta) subject; for ( int i = 0; i < transMeta.nrTransHops(); i++ ) { TransHopMeta hop = transMeta.getTransHop( i ); if ( !hop.isEnabled() ) { feedback.add( new ImportValidationFeedback( this, ImportValidationResultType.ERROR, "There is a disabled hop in the transformation." ) ); } } if ( feedback.isEmpty() ) { feedback.add( new ImportValidationFeedback( this, ImportValidationResultType.APPROVAL, "All hops are enabled in this transformation." ) ); } return feedback; }
/** * Retrieve an array of preceding steps for a certain destination step. This includes the info steps. * * @param stepMeta * The destination step * @return An array containing the preceding steps. */ public StepMeta[] getPrevSteps( StepMeta stepMeta ) { List<StepMeta> prevSteps = previousStepCache.get( getStepMetaCacheKey( stepMeta, true ) ); if ( prevSteps == null ) { prevSteps = new ArrayList<>(); for ( int i = 0; i < nrTransHops(); i++ ) { // Look at all the hops; TransHopMeta hopMeta = getTransHop( i ); if ( hopMeta.isEnabled() && hopMeta.getToStep().equals( stepMeta ) ) { prevSteps.add( hopMeta.getFromStep() ); } } } return prevSteps.toArray( new StepMeta[prevSteps.size()] ); }
/** * Retrieve a list of succeeding steps for a certain originating step. * * @param stepMeta * The originating step * @return an array of succeeding steps. */ public List<StepMeta> findNextSteps( StepMeta stepMeta ) { List<StepMeta> nextSteps = new ArrayList<>(); for ( int i = 0; i < nrTransHops(); i++ ) { // Look at all the hops; TransHopMeta hi = getTransHop( i ); if ( hi.isEnabled() && hi.getFromStep().equals( stepMeta ) ) { nextSteps.add( hi.getToStep() ); } } return nextSteps; }
private void updateErrorMetaForHop( TransHopMeta hop ) { if ( hop != null && hop.isErrorHop() ) { StepErrorMeta errorMeta = hop.getFromStep().getStepErrorMeta(); if ( errorMeta != null ) { errorMeta.setEnabled( hop.isEnabled() ); } } }
/** * Find the number of succeeding steps for a certain originating step. * * @param stepMeta * The originating step * @return The number of succeeding steps. * @deprecated use {@link #getNextSteps(StepMeta)} */ @Deprecated public int findNrNextSteps( StepMeta stepMeta ) { int count = 0; int i; for ( i = 0; i < nrTransHops(); i++ ) { // Look at all the hops; TransHopMeta hi = getTransHop( i ); if ( hi.isEnabled() && hi.getFromStep().equals( stepMeta ) ) { count++; } } return count; }
/** * Get the previous steps on a certain location taking into account the steps being informational or not. * * @param stepMeta * The name of the step * @param info * true if we only want the informational steps. * @return The list of the preceding steps */ public List<StepMeta> findPreviousSteps( StepMeta stepMeta, boolean info ) { if ( stepMeta == null ) { return new ArrayList<>(); } String cacheKey = getStepMetaCacheKey( stepMeta, info ); List<StepMeta> previousSteps = previousStepCache.get( cacheKey ); if ( previousSteps == null ) { previousSteps = new ArrayList<>(); for ( TransHopMeta hi : hops ) { if ( hi.getToStep() != null && hi.isEnabled() && hi.getToStep().equals( stepMeta ) ) { // Check if this previous step isn't informative (StreamValueLookup) // We don't want fields from this stream to show up! if ( info || !isStepInformative( stepMeta, hi.getFromStep() ) ) { previousSteps.add( hi.getFromStep() ); } } } previousStepCache.put( cacheKey, previousSteps ); } return previousSteps; }
private Set<StepMeta> enableDisableNextHops( StepMeta from, boolean enabled, Set<StepMeta> checkedEntries ) { checkedEntries.add( from ); transMeta.getTransHops().stream() .filter( hop -> from.equals( hop.getFromStep() ) ) .forEach( hop -> { if ( hop.isEnabled() != enabled ) { TransHopMeta before = (TransHopMeta) hop.clone(); setHopEnabled( hop, enabled ); TransHopMeta after = (TransHopMeta) hop.clone(); spoon.addUndoChange( transMeta, new TransHopMeta[] { before }, new TransHopMeta[] { after }, new int[] { transMeta .indexOfTransHop( hop ) } ); } if ( !checkedEntries.contains( hop.getToStep() ) ) { enableDisableNextHops( hop.getToStep(), enabled, checkedEntries ); } } ); return checkedEntries; }
/** * Find the succeeding step at a location for an originating step. * * @param stepMeta * The originating step * @param nr * The location * @return The step found. * @deprecated use {@link #getNextSteps(StepMeta)} */ @Deprecated public StepMeta findNextStep( StepMeta stepMeta, int nr ) { int count = 0; int i; for ( i = 0; i < nrTransHops(); i++ ) { // Look at all the hops; TransHopMeta hi = getTransHop( i ); if ( hi.isEnabled() && hi.getFromStep().equals( stepMeta ) ) { if ( count == nr ) { return hi.getToStep(); } count++; } } return null; }
@Test public void testWebsocketVersion() throws KettleException { props.setProperty( "KETTLE_AEL_PDI_DAEMON_VERSION", "2.0" ); when( meta.getVariable( "engine" ) ).thenReturn( "spark" ); when( meta.getVariable( "engine.host" ) ).thenReturn( "hostname" ); when( meta.getVariable( "engine.port" ) ).thenReturn( "8080" ); when( meta.nrTransHops() ).thenReturn( 0 ); when( meta.getTransHop( 0 ) ).thenReturn( transHopMeta ); when( meta.realClone( false ) ).thenReturn( meta ); when( transHopMeta.isEnabled() ).thenReturn( false ); transSupplier = new TransSupplier( meta, log, fallbackSupplier ); Trans transRet = transSupplier.get(); assertTrue( transRet instanceof TransWebSocketEngineAdapter ); }
/** * Copy information from the meta-data input to the dialog fields. */ public void getData() { if ( input.getFromStep() != null ) { wFrom.setText( input.getFromStep().getName() ); } if ( input.getToStep() != null ) { wTo.setText( input.getToStep().getName() ); } wEnabled.setSelection( input.isEnabled() ); }
/** * Count the number of previous steps on a certain location taking into account the steps being informational or not. * * @param stepMeta * The name of the step * @param info * true if only the informational steps are desired, false otherwise * @return The number of preceding steps * @deprecated please use method findPreviousSteps */ @Deprecated public int findNrPrevSteps( StepMeta stepMeta, boolean info ) { int count = 0; int i; for ( i = 0; i < nrTransHops(); i++ ) { // Look at all the hops; TransHopMeta hi = getTransHop( i ); if ( hi.getToStep() != null && hi.isEnabled() && hi.getToStep().equals( stepMeta ) ) { // Check if this previous step isn't informative (StreamValueLookup) // We don't want fields from this stream to show up! if ( info || !isStepInformative( stepMeta, hi.getFromStep() ) ) { count++; } } } return count; }
@Override public void refresh( AbstractMeta meta, TreeNode treeNode, String filter ) { TransMeta transMeta = (TransMeta) meta; // Put the steps below it. for ( int i = 0; i < transMeta.nrTransHops(); i++ ) { TransHopMeta hopMeta = transMeta.getTransHop( i ); if ( !filterMatch( hopMeta.toString(), filter ) ) { continue; } Image icon = hopMeta.isEnabled() ? guiResource.getImageHopTree() : guiResource.getImageDisabledHopTree(); createTreeNode( treeNode, hopMeta.toString(), icon ); } }
public void enableHop() { selectionRegion = null; TransHopMeta hi = getCurrentHop(); TransHopMeta before = (TransHopMeta) hi.clone(); setHopEnabled( hi, !hi.isEnabled() ); if ( hi.isEnabled() && transMeta.hasLoop( hi.getToStep() ) ) { setHopEnabled( hi, false ); modalMessageDialog( getString( "TransGraph.Dialog.LoopAfterHopEnabled.Title" ), getString( "TransGraph.Dialog.LoopAfterHopEnabled.Message" ), SWT.OK | SWT.ICON_ERROR ); } else { TransHopMeta after = (TransHopMeta) hi.clone(); spoon.addUndoChange( transMeta, new TransHopMeta[] { before }, new TransHopMeta[] { after }, new int[] { transMeta.indexOfTransHop( hi ) } ); spoon.refreshGraph(); spoon.refreshTree(); } updateErrorMetaForHop( hi ); }
/** * Search all hops for a hop where a certain step is at the start and another is at the end. * * @param from * The step at the start of the hop. * @param to * The step at the end of the hop. * @param disabledToo * the disabled too * @return The hop or null if no hop was found. */ public TransHopMeta findTransHop( StepMeta from, StepMeta to, boolean disabledToo ) { for ( int i = 0; i < nrTransHops(); i++ ) { TransHopMeta hi = getTransHop( i ); if ( hi.isEnabled() || disabledToo ) { if ( hi.getFromStep() != null && hi.getToStep() != null && hi.getFromStep().equals( from ) && hi.getToStep() .equals( to ) ) { return hi; } } } return null; }
public void saveTransHopMeta( TransHopMeta transHopMeta, ObjectId id_transformation ) throws KettleException { try { // See if a transformation hop with the same fromstep and tostep is // already available... ObjectId id_step_from = transHopMeta.getFromStep() == null ? null : transHopMeta.getFromStep().getObjectId(); ObjectId id_step_to = transHopMeta.getToStep() == null ? null : transHopMeta.getToStep().getObjectId(); // Insert new transMeta hop in repository transHopMeta.setObjectId( insertTransHop( id_transformation, id_step_from, id_step_to, transHopMeta .isEnabled() ) ); } catch ( KettleDatabaseException dbe ) { throw new KettleException( BaseMessages.getString( PKG, "TransHopMeta.Exception.UnableToSaveTransformationHopInfo" ) + id_transformation, dbe ); } }
/** * Find the informational fields coming from an informational step into the step specified. * * @param stepMeta * The receiving step * @return A row containing fields with origin. * @throws KettleStepException * the kettle step exception */ public RowMetaInterface getPrevInfoFields( StepMeta stepMeta ) throws KettleStepException { for ( int i = 0; i < nrTransHops(); i++ ) { // Look at all the hops; TransHopMeta hi = getTransHop( i ); if ( hi.isEnabled() && hi.getToStep().equals( stepMeta ) ) { StepMeta infoStep = hi.getFromStep(); if ( isStepInformative( stepMeta, infoStep ) ) { RowMetaInterface row = getPrevStepFields( infoStep ); return getThisStepFields( infoStep, stepMeta, row ); } } } return new RowMeta(); }