private JobEntryResult findJobEntryResult( JobEntryCopy jobEntryCopy ) { if ( jobEntryResults == null ) { return null; } Iterator<JobEntryResult> iterator = jobEntryResults.iterator(); while ( iterator.hasNext() ) { JobEntryResult jobEntryResult = iterator.next(); if ( jobEntryResult.getJobEntryName().equals( jobEntryCopy.getName() ) && jobEntryResult.getJobEntryNr() == jobEntryCopy.getNr() ) { return jobEntryResult; } } return null; }
/** * Finds the JobTracker for the job entry specified. Use this to * * @param jobEntryCopy * The entry to search the job tracker for * @return The JobTracker of null if none could be found... */ public JobTracker findJobTracker( JobEntryCopy jobEntryCopy ) { if ( jobEntryCopy.getName() == null ) { return null; } lock.readLock().lock(); try { ListIterator<JobTracker> it = jobTrackers.listIterator( jobTrackers.size() ); while ( it.hasPrevious() ) { JobTracker tracker = it.previous(); JobEntryResult result = tracker.getJobEntryResult(); if ( result != null ) { if ( jobEntryCopy.getName().equals( result.getJobEntryName() ) && jobEntryCopy.getNr() == result.getJobEntryNr() ) { return tracker; } } } } finally { lock.readLock().unlock(); } return null; }
@Override public int compare( JobEntryResult one, JobEntryResult two ) { if ( one == null && two != null ) { return -1; } if ( one != null && two == null ) { return 1; } if ( one == null && two == null ) { return 0; } if ( one.getJobEntryName() == null && two.getJobEntryName() != null ) { return -1; } if ( one.getJobEntryName() != null && two.getJobEntryName() == null ) { return 1; } if ( one.getJobEntryName() == null && two.getJobEntryName() == null ) { return 0; } int cmp = one.getJobEntryName().compareTo( two.getJobEntryName() ); if ( cmp != 0 ) { return cmp; } return Integer.valueOf( one.getJobEntryNr() ).compareTo( Integer.valueOf( two.getJobEntryNr() ) ); }
private static JobTracker createTracker( String jobEntryName, int jobEntryNr ) { JobMeta jobMeta = mock( JobMeta.class ); JobTracker jobTracker = new JobTracker( jobMeta ); if ( jobEntryName != null ) { JobEntryResult result = mock( JobEntryResult.class ); when( result.getJobEntryName() ).thenReturn( jobEntryName ); when( result.getJobEntryNr() ).thenReturn( jobEntryNr ); jobTracker.setJobEntryResult( result ); } return jobTracker; }