/** * Find job hop from. * * @param jge the jge * @return the job hop meta */ public JobHopMeta findJobHopFrom( JobEntryCopy jge ) { if ( jge != null ) { for ( JobHopMeta hi : jobhops ) { // Return the first we find! // if ( hi != null && ( hi.getFromEntry() != null ) && hi.getFromEntry().equals( jge ) ) { return hi; } } } return null; }
/** * Find nr next job entries. * * @param from the from * @return the int */ public int findNrNextJobEntries( JobEntryCopy from ) { int count = 0; for ( JobHopMeta hi : jobhops ) { // Look at all the hops if ( hi.isEnabled() && ( hi.getFromEntry() != null ) && hi.getFromEntry().equals( from ) ) { count++; } } return count; }
/** * Gets the all job hops using. * * @param name the name * @return the all job hops using */ public JobHopMeta[] getAllJobHopsUsing( String name ) { List<JobHopMeta> hops = new ArrayList<JobHopMeta>(); for ( JobHopMeta hi : jobhops ) { // Look at all the hops if ( hi.getFromEntry() != null && hi.getToEntry() != null ) { if ( hi.getFromEntry().getName().equalsIgnoreCase( name ) || hi.getToEntry().getName() .equalsIgnoreCase( name ) ) { hops.add( hi ); } } } return hops.toArray( new JobHopMeta[hops.size()] ); }
/** * Find next job entry. * * @param from the from * @param cnt the cnt * @return the job entry copy */ public JobEntryCopy findNextJobEntry( JobEntryCopy from, int cnt ) { int count = 0; for ( JobHopMeta hi : jobhops ) { // Look at all the hops if ( hi.isEnabled() && ( hi.getFromEntry() != null ) && hi.getFromEntry().equals( from ) ) { if ( count == cnt ) { return hi.getToEntry(); } count++; } } return null; }
protected void drawJobHop( JobHopMeta hop, boolean candidate ) { if ( hop == null || hop.getFromEntry() == null || hop.getToEntry() == null ) { return; } if ( !hop.getFromEntry().isDrawn() || !hop.getToEntry().isDrawn() ) { return; } drawLine( hop, candidate ); }
/** * Find job hop. * * @param from the from * @param to the to * @param includeDisabled the include disabled * @return the job hop meta */ public JobHopMeta findJobHop( JobEntryCopy from, JobEntryCopy to, boolean includeDisabled ) { for ( JobHopMeta hi : jobhops ) { if ( hi.isEnabled() || includeDisabled ) { if ( hi != null && hi.getFromEntry() != null && hi.getToEntry() != null && hi.getFromEntry().equals( from ) && hi.getToEntry().equals( to ) ) { return hi; } } } return null; }
public boolean isPathExist( JobEntryInterface from, JobEntryInterface to ) { for ( JobHopMeta hi : jobhops ) { if ( hi.getFromEntry() != null && hi.getToEntry() != null ) { if ( hi.getFromEntry().getName().equalsIgnoreCase( from.getName() ) ) { if ( hi.getToEntry().getName().equalsIgnoreCase( to.getName() ) ) { return true; } if ( isPathExist( hi.getToEntry().getEntry(), to ) ) { return true; } } } } return false; }
/** * Find prev job entry. * * @param to the to * @param nr the nr * @param info the info * @return the job entry copy */ public JobEntryCopy findPrevJobEntry( JobEntryCopy to, int nr, boolean info ) { int count = 0; for ( JobHopMeta hi : jobhops ) { // Look at all the hops if ( hi.isEnabled() && hi.getToEntry().equals( to ) ) { if ( count == nr ) { return hi.getFromEntry(); } count++; } } return null; }
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; }
if ( jobHop.getFromEntry().isLaunchingInParallel() ) {
public void saveJobHopMeta( JobHopMeta hop, ObjectId id_job ) throws KettleException { try { ObjectId id_jobentry_from = null; ObjectId id_jobentry_to = null; id_jobentry_from = hop.getFromEntry() == null ? null : hop.getFromEntry().getObjectId(); id_jobentry_to = hop.getToEntry() == null ? null : hop.getToEntry().getObjectId(); // Insert new job hop in repository // hop.setObjectId( insertJobHop( id_job, id_jobentry_from, id_jobentry_to, hop.isEnabled(), hop .getEvaluation(), hop.isUnconditional() ) ); } catch ( KettleDatabaseException dbe ) { throw new KettleException( BaseMessages.getString( PKG, "JobHopMeta.Exception.UnableToSaveHopInfoRep", "" + id_job ), dbe ); } }
public boolean checkIfHopAlreadyExists( JobMeta jobMeta, JobHopMeta newHop ) { boolean ok = true; if ( jobMeta.findJobHop( newHop.getFromEntry(), newHop.getToEntry(), true ) != null ) { MessageBox mb = new MessageBox( shell, SWT.OK | SWT.ICON_ERROR ); mb.setMessage( BaseMessages.getString( PKG, "JobGraph.Dialog.HopExists.Message" ) ); // "This hop already exists!" mb.setText( BaseMessages.getString( PKG, "JobGraph.Dialog.HopExists.Title" ) ); // Error! mb.open(); ok = false; } return ok; }
JobHopMeta hi = job.getJobHop( i ); for ( int j = 0; j < jobEntries.length && hopIndex < hopIndexes.length; j++ ) { if ( hi.getFromEntry().equals( jobEntries[j] ) || hi.getToEntry().equals( jobEntries[j] ) ) { int idx = job.indexOfJobHop( hi ); jobHops.add( (JobHopMeta) hi.clone() );
private void addCandidateAsHop() { if ( hop_candidate != null ) { if ( !hop_candidate.getFromEntry().evaluates() && hop_candidate.getFromEntry().isUnconditional() ) { hop_candidate.setUnconditional(); } else { hop_candidate.setConditional(); int nr = jobMeta.findNrNextJobEntries( hop_candidate.getFromEntry() ); JobEntryCopy jge = jobMeta.findNextJobEntry( hop_candidate.getFromEntry(), 0 ); JobHopMeta other = jobMeta.findJobHop( hop_candidate.getFromEntry(), jge ); if ( other != null ) { hop_candidate.setEvaluation( !other.getEvaluation() );
for ( i = 0; i < jobMeta.nrJobHops(); i++ ) { JobHopMeta hi = jobMeta.getJobHop( i ); JobEntryCopy fs = hi.getFromEntry(); JobEntryCopy ts = hi.getToEntry();
protected void detach( JobEntryCopy je ) { JobHopMeta hfrom = jobMeta.findJobHopTo( je ); JobHopMeta hto = jobMeta.findJobHopFrom( je ); if ( hfrom != null && hto != null ) { if ( jobMeta.findJobHop( hfrom.getFromEntry(), hto.getToEntry() ) == null ) { JobHopMeta hnew = new JobHopMeta( hfrom.getFromEntry(), hto.getToEntry() ); jobMeta.addJobHop( hnew ); spoon.addUndoNew( jobMeta, new JobHopMeta[] { (JobHopMeta) hnew.clone() }, new int[] { jobMeta .indexOfJobHop( hnew ) } ); } } if ( hfrom != null ) { int fromidx = jobMeta.indexOfJobHop( hfrom ); if ( fromidx >= 0 ) { jobMeta.removeJobHop( fromidx ); spoon.addUndoDelete( jobMeta, new JobHopMeta[] { hfrom }, new int[] { fromidx } ); } } if ( hto != null ) { int toidx = jobMeta.indexOfJobHop( hto ); if ( toidx >= 0 ) { jobMeta.removeJobHop( toidx ); spoon.addUndoDelete( jobMeta, new JobHopMeta[] { hto }, new int[] { toidx } ); } } spoon.refreshTree(); redraw(); }
/** * 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(); }
int[] line = getLine( jobHop.getFromEntry(), jobHop.getToEntry() ); if ( jobHop.getFromEntry().isLaunchingInParallel() ) { gc.setLineStyle( ELineStyle.PARALLEL ); } else {
public void deleteJobEntryCopies( JobMeta jobMeta, JobEntryCopy jobEntry ) { for ( int i = jobMeta.nrJobHops() - 1; i >= 0; i-- ) { JobHopMeta hi = jobMeta.getJobHop( i ); if ( hi.getFromEntry().equals( jobEntry ) || hi.getToEntry().equals( jobEntry ) ) { int idx = jobMeta.indexOfJobHop( hi ); spoon.addUndoDelete( jobMeta, new JobHopMeta[] { (JobHopMeta) hi.clone() }, new int[] { idx } ); jobMeta.removeJobHop( idx ); spoon.refreshTree(); } } int pos = jobMeta.indexOfJobEntry( jobEntry ); jobMeta.removeJobEntry( pos ); spoon.addUndoDelete( jobMeta, new JobEntryCopy[] { jobEntry }, new int[] { pos } ); spoon.refreshTree(); spoon.refreshGraph(); }
public void flipHop() { selectionRegion = null; JobEntryCopy origFrom = currentHop.getFromEntry(); JobEntryCopy origTo = currentHop.getToEntry(); currentHop.setFromEntry( currentHop.getToEntry() ); currentHop.setToEntry( origFrom ); boolean cancel = false; if ( jobMeta.hasLoop( currentHop.getToEntry() ) ) { MessageBox mb = new MessageBox( shell, SWT.OK | SWT.CANCEL | SWT.ICON_WARNING ); mb.setMessage( BaseMessages.getString( PKG, "JobGraph.Dialog.HopFlipCausesLoop.Message" ) ); mb.setText( BaseMessages.getString( PKG, "JobGraph.Dialog.HopCausesLoop.Title" ) ); int choice = mb.open(); if ( choice == SWT.CANCEL ) { cancel = true; currentHop.setFromEntry( origFrom ); currentHop.setToEntry( origTo ); } } if ( !cancel ) { currentHop.setChanged(); } spoon.refreshGraph(); spoon.refreshTree(); spoon.setShellText(); }