private Set<JobEntryCopy> enableDisableNextHops( JobEntryCopy from, boolean enabled, Set<JobEntryCopy> checkedEntries ) { checkedEntries.add( from ); jobMeta.getJobhops().stream() .filter( hop -> from.equals( hop.getFromEntry() ) ) .forEach( hop -> { if ( hop.isEnabled() != enabled ) { JobHopMeta before = (JobHopMeta) hop.clone(); hop.setEnabled( enabled ); JobHopMeta after = (JobHopMeta) hop.clone(); spoon.addUndoChange( jobMeta, new JobHopMeta[]{ before }, new JobHopMeta[]{ after }, new int[]{ jobMeta .indexOfJobHop( hop ) } ); } if ( !checkedEntries.contains( hop.getToEntry() ) ) { enableDisableNextHops( hop.getToEntry(), enabled, checkedEntries ); } } ); return checkedEntries; }
public void disableHop() { selectionRegion = null; boolean orig = currentHop.isEnabled(); currentHop.setEnabled( !currentHop.isEnabled() ); if ( !orig && ( jobMeta.hasLoop( currentHop.getToEntry() ) ) ) { MessageBox mb = new MessageBox( shell, SWT.CANCEL | SWT.OK | SWT.ICON_WARNING ); mb.setMessage( BaseMessages.getString( PKG, "JobGraph.Dialog.LoopAfterHopEnabled.Message" ) ); mb.setText( BaseMessages.getString( PKG, "JobGraph.Dialog.LoopAfterHopEnabled.Title" ) ); int choice = mb.open(); if ( choice == SWT.CANCEL ) { currentHop.setEnabled( orig ); } } spoon.refreshGraph(); spoon.refreshTree(); }
public void enableDisableHopsDownstream( boolean enabled ) { if ( currentHop == null ) { return; } JobHopMeta before = (JobHopMeta) currentHop.clone(); currentHop.setEnabled( enabled ); JobHopMeta after = (JobHopMeta) currentHop.clone(); spoon.addUndoChange( jobMeta, new JobHopMeta[] { before }, new JobHopMeta[] { after }, new int[] { jobMeta .indexOfJobHop( currentHop ) } ); Set<JobEntryCopy> checkedEntries = enableDisableNextHops( currentHop.getToEntry(), enabled, new HashSet<>() ); if ( checkedEntries.stream().anyMatch( entry -> jobMeta.hasLoop( entry ) ) ) { MessageBox mb = new MessageBox( shell, SWT.OK | SWT.ICON_WARNING ); mb.setMessage( BaseMessages.getString( PKG, "JobGraph.Dialog.LoopAfterHopEnabled.Message" ) ); mb.setText( BaseMessages.getString( PKG, "JobGraph.Dialog.LoopAfterHopEnabled.Title" ) ); mb.open(); } spoon.refreshGraph(); }
/** * This method enables or disables all the hops between the selected Entries. * **/ public void enableHopsBetweenSelectedEntries( boolean enabled ) { List<JobEntryCopy> list = jobMeta.getSelectedEntries(); boolean hasLoop = false; for ( int i = 0; i < jobMeta.nrJobHops(); i++ ) { JobHopMeta hop = jobMeta.getJobHop( i ); if ( list.contains( hop.getFromEntry() ) && list.contains( hop.getToEntry() ) ) { JobHopMeta before = (JobHopMeta) hop.clone(); hop.setEnabled( enabled ); JobHopMeta after = (JobHopMeta) hop.clone(); spoon.addUndoChange( jobMeta, new JobHopMeta[] { before }, new JobHopMeta[] { after }, new int[] { jobMeta .indexOfJobHop( hop ) } ); if ( jobMeta.hasLoop( hop.getToEntry() ) ) { hasLoop = true; } } } if ( hasLoop && enabled ) { MessageBox mb = new MessageBox( shell, SWT.OK | SWT.ICON_WARNING ); mb.setMessage( BaseMessages.getString( PKG, "JobGraph.Dialog.LoopAfterHopEnabled.Message" ) ); mb.setText( BaseMessages.getString( PKG, "JobGraph.Dialog.LoopAfterHopEnabled.Title" ) ); mb.open(); } spoon.refreshGraph(); }
public JobHopMeta loadJobHopMeta( ObjectId id_job_hop, List<JobEntryCopy> jobcopies ) throws KettleException { JobHopMeta jobHopMeta = new JobHopMeta(); try { RowMetaAndData r = getJobHop( id_job_hop ); if ( r != null ) { long id_jobentry_copy_from = r.getInteger( "ID_JOBENTRY_COPY_FROM", -1L ); long id_jobentry_copy_to = r.getInteger( "ID_JOBENTRY_COPY_TO", -1L ); jobHopMeta.setEnabled( r.getBoolean( "ENABLED", true ) ); jobHopMeta.setEvaluation( r.getBoolean( "EVALUATION", true ) ); jobHopMeta.setConditional(); if ( r.getBoolean( "UNCONDITIONAL", !jobHopMeta.getEvaluation() ) ) { jobHopMeta.setUnconditional(); } jobHopMeta.setFromEntry( JobMeta.findJobEntryCopy( jobcopies, new LongObjectId( id_jobentry_copy_from ) ) ); jobHopMeta.setToEntry( JobMeta.findJobEntryCopy( jobcopies, new LongObjectId( id_jobentry_copy_to ) ) ); return jobHopMeta; } else { throw new KettleException( "Unable to find job hop with ID : " + id_job_hop ); } } catch ( KettleDatabaseException dbe ) { throw new KettleException( BaseMessages.getString( PKG, "JobHopMeta.Exception.UnableToLoadHopInfoRep", "" + id_job_hop ), dbe ); } }
jobHopMeta.setEnabled( enabled ); jobHopMeta.setEvaluation( evaluation ); jobHopMeta.setUnconditional( unconditional );
if ( hop != null ) { JobHopMeta before = (JobHopMeta) hop.clone(); hop.setEnabled( !hop.isEnabled() ); if ( hop.isEnabled() && ( jobMeta.hasLoop( hop.getToEntry() ) ) ) { MessageBox mb = new MessageBox( shell, SWT.CANCEL | SWT.OK | SWT.ICON_WARNING ); int choice = mb.open(); if ( choice == SWT.CANCEL ) { hop.setEnabled( false );