From 8e5ec9ba0617881c1cd5f72c3cce2bdfca4461fb Mon Sep 17 00:00:00 2001 From: PatrikBuhr Date: Fri, 10 Sep 2021 10:49:11 +0200 Subject: [PATCH] NONRTRIC - Enrichment Coordinator Service, extend information in information type The information type definition is extended to contain generic information of the type. This can be used to pass information about the types to the data consumer. As an example, this could be available reporting periods. Signed-off-by: PatrikBuhr Issue-ID: NONRTRIC-594 Change-Id: Ia5620e08a5c60903e2d5d8232ad3601b5091535c --- enrichment-coordinator-service/api/ecs-api.json | 19 ++++++++++++++----- enrichment-coordinator-service/api/ecs-api.yaml | 4 ++++ .../controllers/r1producer/ProducerController.java | 5 +++-- .../controllers/r1producer/ProducerInfoTypeInfo.java | 11 ++++++++++- .../org/oransc/enrichment/repository/InfoType.java | 6 +++++- .../java/org/oransc/enrichment/ApplicationTest.java | 7 ++++++- 6 files changed, 42 insertions(+), 10 deletions(-) diff --git a/enrichment-coordinator-service/api/ecs-api.json b/enrichment-coordinator-service/api/ecs-api.json index b2d800bd..982633ba 100644 --- a/enrichment-coordinator-service/api/ecs-api.json +++ b/enrichment-coordinator-service/api/ecs-api.json @@ -207,11 +207,20 @@ "producer_info_type_info": { "description": "Information for an Information Type", "type": "object", - "required": ["info_job_data_schema"], - "properties": {"info_job_data_schema": { - "description": "Json schema for the job data", - "type": "object" - }} + "required": [ + "info_job_data_schema", + "info_type_information" + ], + "properties": { + "info_type_information": { + "description": "Type specific information for the information type", + "type": "object" + }, + "info_job_data_schema": { + "description": "Json schema for the job data", + "type": "object" + } + } }, "producer_info_job_request": { "description": "The body of the Information Producer callbacks for Information Job creation and deletion", diff --git a/enrichment-coordinator-service/api/ecs-api.yaml b/enrichment-coordinator-service/api/ecs-api.yaml index 3f2a1cd8..1900215a 100644 --- a/enrichment-coordinator-service/api/ecs-api.yaml +++ b/enrichment-coordinator-service/api/ecs-api.yaml @@ -1171,8 +1171,12 @@ components: producer_info_type_info: required: - info_job_data_schema + - info_type_information type: object properties: + info_type_information: + type: object + description: Type specific information for the information type info_job_data_schema: type: object description: Json schema for the job data diff --git a/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/r1producer/ProducerController.java b/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/r1producer/ProducerController.java index 6c3c05dd..0aa6974e 100644 --- a/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/r1producer/ProducerController.java +++ b/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/r1producer/ProducerController.java @@ -149,7 +149,8 @@ public class ProducerController { if (registrationInfo.jobDataSchema == null) { return ErrorResponse.create("No schema provided", HttpStatus.BAD_REQUEST); } - InfoType newDefinition = new InfoType(infoTypeId, registrationInfo.jobDataSchema); + InfoType newDefinition = + new InfoType(infoTypeId, registrationInfo.jobDataSchema, registrationInfo.typeSpecificInformation); this.infoTypes.put(newDefinition); this.typeSubscriptions.notifyTypeRegistered(newDefinition); return new ResponseEntity<>(previousDefinition == null ? HttpStatus.CREATED : HttpStatus.OK); @@ -394,7 +395,7 @@ public class ProducerController { } private ProducerInfoTypeInfo toInfoTypeInfo(InfoType t) { - return new ProducerInfoTypeInfo(t.getJobDataSchema()); + return new ProducerInfoTypeInfo(t.getJobDataSchema(), t.getTypeSpecificInfo()); } private InfoProducers.InfoProducerRegistrationInfo toProducerRegistrationInfo(String infoProducerId, diff --git a/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/r1producer/ProducerInfoTypeInfo.java b/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/r1producer/ProducerInfoTypeInfo.java index 0e066bc9..b0375c24 100644 --- a/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/r1producer/ProducerInfoTypeInfo.java +++ b/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/r1producer/ProducerInfoTypeInfo.java @@ -36,8 +36,17 @@ public class ProducerInfoTypeInfo { @JsonProperty(value = "info_job_data_schema", required = true) public Object jobDataSchema; - public ProducerInfoTypeInfo(Object jobDataSchema) { + @Schema( + name = "info_type_information", + description = "Type specific information for the information type", + required = true) + @SerializedName("info_type_information") + @JsonProperty(value = "info_type_information", required = true) + public Object typeSpecificInformation; + + public ProducerInfoTypeInfo(Object jobDataSchema, Object typeSpecificInformation) { this.jobDataSchema = jobDataSchema; + this.typeSpecificInformation = typeSpecificInformation; } public ProducerInfoTypeInfo() { diff --git a/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/repository/InfoType.java b/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/repository/InfoType.java index e89f0bc2..3f8dd9c2 100644 --- a/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/repository/InfoType.java +++ b/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/repository/InfoType.java @@ -29,9 +29,13 @@ public class InfoType { @Getter private final Object jobDataSchema; - public InfoType(String id, Object jobDataSchema) { + @Getter + private final Object typeSpecificInfo; + + public InfoType(String id, Object jobDataSchema, Object typeSpecificInfo) { this.id = id; this.jobDataSchema = jobDataSchema; + this.typeSpecificInfo = typeSpecificInfo; } } 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 8a2b5280..fa5b7e31 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 @@ -765,6 +765,7 @@ class ApplicationTest { ResponseEntity resp = restClient().getForEntity(url).block(); ProducerInfoTypeInfo info = gson.fromJson(resp.getBody(), ProducerInfoTypeInfo.class); assertThat(info.jobDataSchema).isNotNull(); + assertThat(info.typeSpecificInformation).isNotNull(); } @Test @@ -1050,7 +1051,7 @@ class ApplicationTest { ProducerInfoTypeInfo producerEiTypeRegistrationInfo(String typeId) throws JsonMappingException, JsonProcessingException { - return new ProducerInfoTypeInfo(jsonSchemaObject()); + return new ProducerInfoTypeInfo(jsonSchemaObject(), typeSpecifcInfoObject()); } ProducerRegistrationInfo producerEiRegistratioInfoRejecting(String typeId) @@ -1093,6 +1094,10 @@ class ApplicationTest { } } + private Object typeSpecifcInfoObject() { + return jsonObject("{ \"propertyName\" : \"value\" }"); + } + private Object jsonSchemaObject() { // a json schema with one mandatory property named "string" String schemaStr = "{" // -- 2.16.6