import org.oransc.enrichment.exceptions.ServiceException;
/**
- * Dynamic representation of all EI Jobs in the system.
+ * Dynamic representation of all existing EI jobs.
*/
public class EiJobs {
private Map<String, EiJob> allEiJobs = new HashMap<>();
private MultiMap<EiJob> jobsByType = new MultiMap<>();
+ private MultiMap<EiJob> jobsByOwner = new MultiMap<>();
public synchronized void put(EiJob job) {
allEiJobs.put(job.id(), job);
- jobsByType.put(job.type().getId(), job.id(), job);
+ jobsByType.put(job.typeId(), job.id(), job);
+ jobsByOwner.put(job.owner(), job.id(), job);
}
public synchronized Collection<EiJob> getJobs() {
return jobsByType.get(type.getId());
}
+ public synchronized Collection<EiJob> getJobsForOwner(String owner) {
+ return jobsByOwner.get(owner);
+ }
+
public synchronized EiJob get(String id) {
return allEiJobs.get(id);
}
public synchronized void remove(EiJob job) {
this.allEiJobs.remove(job.id());
- jobsByType.remove(job.type().getId(), job.id());
+ jobsByType.remove(job.typeId(), job.id());
+ jobsByOwner.remove(job.owner(), job.id());
}
public synchronized int size() {
public synchronized void clear() {
this.allEiJobs.clear();
this.jobsByType.clear();
+ jobsByOwner.clear();
}
}