diff options
author | 2020-04-01 10:19:52 +0000 | |
---|---|---|
committer | 2020-04-01 10:19:52 +0000 | |
commit | 45787c2471e689e6ca63419bd31db647afe954d6 (patch) | |
tree | 0764a9c406dd113fbad15a97bfac27b80f37db3e /src/main | |
parent | 99f15c6328f77649ccfc7b1b790c98385754fd6a (diff) | |
parent | 51de07c4250ac0b9502c6e5c6fe35ed1b310c8b4 (diff) |
Merge "Rework the CDS Json schema"
Diffstat (limited to 'src/main')
-rw-r--r-- | src/main/java/org/onap/clamp/clds/tosca/update/execution/cds/ToscaMetadataCdsProcess.java | 31 |
1 files changed, 26 insertions, 5 deletions
diff --git a/src/main/java/org/onap/clamp/clds/tosca/update/execution/cds/ToscaMetadataCdsProcess.java b/src/main/java/org/onap/clamp/clds/tosca/update/execution/cds/ToscaMetadataCdsProcess.java index b1c889031..b81e46bf4 100644 --- a/src/main/java/org/onap/clamp/clds/tosca/update/execution/cds/ToscaMetadataCdsProcess.java +++ b/src/main/java/org/onap/clamp/clds/tosca/update/execution/cds/ToscaMetadataCdsProcess.java @@ -110,19 +110,40 @@ public class ToscaMetadataCdsProcess extends ToscaMetadataProcess { } } } - addToJsonArray(childObject, "enum", schemaAnyOf); + addToJsonArray(childObject, "anyOf", schemaAnyOf); } private static JsonObject createPayloadProperty(JsonObject workFlow, JsonObject controllerProperties) { JsonObject payloadResult = new JsonObject(); - payloadResult.addProperty("artifact_name", controllerProperties.get("sdnc_model_name").getAsString()); - payloadResult.addProperty("artifact_version", controllerProperties.get("sdnc_model_version").getAsString()); - payloadResult.addProperty("mode", "async"); - payloadResult.add("data", workFlow.getAsJsonObject("inputs")); + payloadResult.add("artifact_name", + createAnyOfJsonProperty("artifact_name", controllerProperties.get("sdnc_model_name").getAsString())); + payloadResult.add("artifact_version", + createAnyOfJsonProperty("artifact_version", + controllerProperties.get("sdnc_model_version").getAsString())); + payloadResult.add("mode", createAnyOfJsonProperty("mode", "async")); + + payloadResult.add("data", createAnyOfJsonObject("data", workFlow.getAsJsonObject("inputs"))); return payloadResult; } + private static JsonObject createAnyOfJsonProperty(String name, String defaultValue) { + JsonObject result = new JsonObject(); + result.addProperty("title", name); + result.addProperty("type", "string"); + result.addProperty("default", defaultValue); + result.addProperty("readOnly", "True"); + return result; + } + + private static JsonObject createAnyOfJsonObject(String name, JsonObject allProperties) { + JsonObject result = new JsonObject(); + result.addProperty("title", name); + result.addProperty("type", "object"); + result.add("properties", allProperties); + return result; + } + private static void addToJsonArray(JsonObject childObject, String section, JsonArray value) { if (childObject.getAsJsonArray(section) != null) { childObject.getAsJsonArray(section).addAll(value); |