Added EI Job jobTarget 55/4755/3
authorPatrikBuhr <patrik.buhr@est.tech>
Tue, 22 Sep 2020 11:37:52 +0000 (13:37 +0200)
committerPatrik Buhr <patrik.buhr@est.tech>
Wed, 23 Sep 2020 12:01:50 +0000 (12:01 +0000)
Change-Id: I0bf1a50843ab15a442a6edd20f86e44bced7d3df
Issue-ID: NONRTRIC-173
Signed-off-by: PatrikBuhr <patrik.buhr@est.tech>
enrichment-coordinator-service/src/main/java/org/oransc/enrichment/clients/ProducerCallbacks.java
enrichment-coordinator-service/src/main/java/org/oransc/enrichment/clients/ProducerJobInfo.java
enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/consumer/ConsumerController.java
enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/consumer/ConsumerEiJobInfo.java
enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/producer/ProducerController.java
enrichment-coordinator-service/src/main/java/org/oransc/enrichment/repository/EiJob.java
enrichment-coordinator-service/src/test/java/org/oransc/enrichment/ApplicationTest.java

index a77b772..07b188d 100644 (file)
@@ -56,7 +56,7 @@ public class ProducerCallbacks {
 
     public void notifyProducersJobDeleted(EiJob eiJob) {
         AsyncRestClient restClient = restClient(false);
-        ProducerJobInfo request = new ProducerJobInfo(eiJob.jobData(), eiJob, eiJob.type());
+        ProducerJobInfo request = new ProducerJobInfo(eiJob);
         String body = gson.toJson(request);
         for (EiProducer producer : eiJob.type().getProducers()) {
             restClient.post(producer.jobDeletionCallbackUrl(), body) //
@@ -67,7 +67,7 @@ public class ProducerCallbacks {
 
     public void notifyProducerJobStarted(EiProducer producer, EiJob eiJob) {
         AsyncRestClient restClient = restClient(false);
-        ProducerJobInfo request = new ProducerJobInfo(eiJob.jobData(), eiJob, eiJob.type());
+        ProducerJobInfo request = new ProducerJobInfo(eiJob);
         String body = gson.toJson(request);
 
         restClient.post(producer.jobCreationCallbackUrl(), body) //
index ff91221..164159b 100644 (file)
@@ -28,7 +28,6 @@ import io.swagger.annotations.ApiModelProperty;
 
 import org.immutables.gson.Gson;
 import org.oransc.enrichment.repository.EiJob;
-import org.oransc.enrichment.repository.EiType;
 
 @Gson.TypeAdapters
 @ApiModel(
@@ -51,14 +50,20 @@ public class ProducerJobInfo {
     @JsonProperty("ei_job_data")
     public Object jobData;
 
-    public ProducerJobInfo(Object jobData, String id, String typeId) {
+    @ApiModelProperty(value = "URI for the target of the EI")
+    @SerializedName("target_uri")
+    @JsonProperty("target_uri")
+    public String targetUri;
+
+    public ProducerJobInfo(Object jobData, String id, String typeId, String targetUri) {
         this.id = id;
         this.jobData = jobData;
         this.typeId = typeId;
+        this.targetUri = targetUri;
     }
 
-    public ProducerJobInfo(Object jobData, EiJob job, EiType type) {
-        this(jobData, job.id(), type.getId());
+    public ProducerJobInfo(EiJob job) {
+        this(job.jobData(), job.id(), job.type().getId(), job.targetUri());
     }
 
     public ProducerJobInfo() {
index a74e487..e167eb8 100644 (file)
@@ -290,6 +290,7 @@ public class ConsumerController {
             .type(type) //
             .owner(info.owner) //
             .jobData(info.jobData) //
+            .targetUri(info.targetUri) //
             .build();
     }
 
@@ -298,6 +299,6 @@ public class ConsumerController {
     }
 
     private ConsumerEiJobInfo toEiJobInfo(EiJob s) {
-        return new ConsumerEiJobInfo(s.jobData(), s.owner());
+        return new ConsumerEiJobInfo(s.jobData(), s.owner(), s.targetUri());
     }
 }
index 8255c43..4d11a84 100644 (file)
@@ -42,11 +42,17 @@ public class ConsumerEiJobInfo {
     @JsonProperty(value = "job_data", required = true)
     public Object jobData;
 
+    @ApiModelProperty(value = "The target of the EI data", required = true)
+    @SerializedName("target_uri")
+    @JsonProperty(value = "target_uri", required = true)
+    public String targetUri;
+
     public ConsumerEiJobInfo() {
     }
 
-    public ConsumerEiJobInfo(Object jobData, String owner) {
+    public ConsumerEiJobInfo(Object jobData, String owner, String targetUri) {
         this.jobData = jobData;
         this.owner = owner;
+        this.targetUri = targetUri;
     }
 }
index c24e559..af25951 100644 (file)
@@ -180,7 +180,7 @@ public class ProducerController {
             Collection<ProducerJobInfo> producerJobs = new ArrayList<>();
             for (EiType type : producer.eiTypes()) {
                 for (EiJob eiJob : this.eiJobs.getJobsForType(type)) {
-                    ProducerJobInfo request = new ProducerJobInfo(eiJob.jobData(), eiJob, eiJob.type());
+                    ProducerJobInfo request = new ProducerJobInfo(eiJob);
                     producerJobs.add(request);
                 }
             }
index e92705e..4c84488 100644 (file)
@@ -233,7 +233,8 @@ class ApplicationTest {
 
         String url = ConsumerConsts.API_ROOT + "/eitypes/typeId/eijobs/jobId";
         // The element with name "property1" is mandatory in the schema
-        ConsumerEiJobInfo jobInfo = new ConsumerEiJobInfo(jsonObject("{ \"XXstring\" : \"value\" }"), "owner");
+        ConsumerEiJobInfo jobInfo =
+            new ConsumerEiJobInfo(jsonObject("{ \"XXstring\" : \"value\" }"), "owner", "targetUri");
         String body = gson.toJson(jobInfo);
 
         testErrorCode(restClient().put(url, body), HttpStatus.NOT_FOUND, "Json validation failure");
@@ -359,7 +360,7 @@ class ApplicationTest {
     }
 
     ConsumerEiJobInfo eiJobInfo() throws JsonMappingException, JsonProcessingException {
-        return new ConsumerEiJobInfo(jsonObject(), "owner");
+        return new ConsumerEiJobInfo(jsonObject(), "owner", "targetUri");
     }
 
     Object jsonObject(String json) {