Merge "Integrated PMS 2.0 to test env and test cases"
[nonrtric.git] / enrichment-coordinator-service / src / main / java / org / oransc / enrichment / repository / EiJobs.java
index 606ee41..706c8dd 100644 (file)
@@ -28,16 +28,18 @@ import java.util.Vector;
 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() {
@@ -60,6 +62,10 @@ public class EiJobs {
         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);
     }
@@ -74,7 +80,8 @@ public class EiJobs {
 
     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() {
@@ -84,6 +91,7 @@ public class EiJobs {
     public synchronized void clear() {
         this.allEiJobs.clear();
         this.jobsByType.clear();
+        jobsByOwner.clear();
     }
 
 }