/** Helpfull method to display the state of the job queue */ public synchronized String toString() { StringBuilder string = new StringBuilder(); for (JobMetadata job : jobs) { string.append(job.getId()); string.append(": "); string.append(job.getStatus().name()); string.append(", "); string.append(job.getProgress().toString()); if (job.getOwnerId() != null) { string.append(" ("); string.append(job.getOwnerId()); string.append(")"); } string.append("\n"); } return string.toString(); }
@Override public synchronized List<JobMetadata> findJobsByOwner(Person owner) { if (owner == null || owner.getId() == null) throw new IllegalArgumentException( "Unable to find background operations from a specific owner without the owner specified."); List<JobMetadata> found = new ArrayList<JobMetadata>(); Long personId = owner.getId(); for (JobMetadata job : jobs) { if (personId.equals(job.getOwnerId())) { found.add(job); } } Collections.reverse(found); return found; }