From: PatrikBuhr Date: Tue, 22 Sep 2020 11:37:52 +0000 (+0200) Subject: Added EI Job jobTarget X-Git-Tag: 2.1.0~42^2 X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=commitdiff_plain;h=66e22e301bd3a4a0a03c7a62a6b399c037c297d6;hp=-c;p=nonrtric.git Added EI Job jobTarget Change-Id: I0bf1a50843ab15a442a6edd20f86e44bced7d3df Issue-ID: NONRTRIC-173 Signed-off-by: PatrikBuhr --- 66e22e301bd3a4a0a03c7a62a6b399c037c297d6 diff --git a/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/clients/ProducerCallbacks.java b/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/clients/ProducerCallbacks.java index a77b7727..07b188d9 100644 --- a/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/clients/ProducerCallbacks.java +++ b/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/clients/ProducerCallbacks.java @@ -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) // diff --git a/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/clients/ProducerJobInfo.java b/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/clients/ProducerJobInfo.java index ff912215..164159b3 100644 --- a/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/clients/ProducerJobInfo.java +++ b/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/clients/ProducerJobInfo.java @@ -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() { diff --git a/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/consumer/ConsumerController.java b/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/consumer/ConsumerController.java index a74e4874..e167eb85 100644 --- a/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/consumer/ConsumerController.java +++ b/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/consumer/ConsumerController.java @@ -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()); } } diff --git a/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/consumer/ConsumerEiJobInfo.java b/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/consumer/ConsumerEiJobInfo.java index 8255c43b..4d11a841 100644 --- a/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/consumer/ConsumerEiJobInfo.java +++ b/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/consumer/ConsumerEiJobInfo.java @@ -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; } } diff --git a/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/producer/ProducerController.java b/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/producer/ProducerController.java index c24e5593..af259510 100644 --- a/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/producer/ProducerController.java +++ b/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/producer/ProducerController.java @@ -180,7 +180,7 @@ public class ProducerController { Collection 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); } } diff --git a/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/repository/EiJob.java b/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/repository/EiJob.java index 7df4a50e..b36e38d6 100644 --- a/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/repository/EiJob.java +++ b/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/repository/EiJob.java @@ -37,4 +37,6 @@ public interface EiJob { String owner(); Object jobData(); + + String targetUri(); } diff --git a/enrichment-coordinator-service/src/test/java/org/oransc/enrichment/ApplicationTest.java b/enrichment-coordinator-service/src/test/java/org/oransc/enrichment/ApplicationTest.java index e92705e9..4c844884 100644 --- a/enrichment-coordinator-service/src/test/java/org/oransc/enrichment/ApplicationTest.java +++ b/enrichment-coordinator-service/src/test/java/org/oransc/enrichment/ApplicationTest.java @@ -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) {