aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorXue Gao <xg353y@intl.att.com>2020-04-01 10:19:52 +0000
committerGerrit Code Review <gerrit@onap.org>2020-04-01 10:19:52 +0000
commit45787c2471e689e6ca63419bd31db647afe954d6 (patch)
tree0764a9c406dd113fbad15a97bfac27b80f37db3e
parent99f15c6328f77649ccfc7b1b790c98385754fd6a (diff)
parent51de07c4250ac0b9502c6e5c6fe35ed1b310c8b4 (diff)
Merge "Rework the CDS Json schema"
-rw-r--r--src/main/java/org/onap/clamp/clds/tosca/update/execution/cds/ToscaMetadataCdsProcess.java31
-rw-r--r--src/test/resources/tosca/new-converter/tosca_apex_with_metadata.json248
2 files changed, 207 insertions, 72 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 b1c88903..b81e46bf 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);
diff --git a/src/test/resources/tosca/new-converter/tosca_apex_with_metadata.json b/src/test/resources/tosca/new-converter/tosca_apex_with_metadata.json
index 687e9b23..4cb5bd8c 100644
--- a/src/test/resources/tosca/new-converter/tosca_apex_with_metadata.json
+++ b/src/test/resources/tosca/new-converter/tosca_apex_with_metadata.json
@@ -64,22 +64,41 @@
"payload": {
"type": "object",
"description": "Name/value pairs of payload information passed by Policy to the actor",
- "enum": [
+ "anyOf": [
{
"title": "resource-assignment",
"properties": {
- "artifact_name": "baseconfiguration",
- "artifact_version": "1.0.0",
- "mode": "async",
+ "artifact_name": {
+ "title": "artifact_name",
+ "type": "string",
+ "default": "baseconfiguration",
+ "readOnly": "True"
+ },
+ "artifact_version": {
+ "title": "artifact_version",
+ "type": "string",
+ "default": "1.0.0",
+ "readOnly": "True"
+ },
+ "mode": {
+ "title": "mode",
+ "type": "string",
+ "default": "async",
+ "readOnly": "True"
+ },
"data": {
- "resource-assignment-properties": {
- "request-id": "",
- "service-instance-id": "",
- "vnf-id": "",
- "action-name": "",
- "scope-type": "",
- "hostname": "",
- "vnf_name": ""
+ "title": "data",
+ "type": "object",
+ "properties": {
+ "resource-assignment-properties": {
+ "request-id": "",
+ "service-instance-id": "",
+ "vnf-id": "",
+ "action-name": "",
+ "scope-type": "",
+ "hostname": "",
+ "vnf_name": ""
+ }
}
}
}
@@ -87,18 +106,37 @@
{
"title": "activate",
"properties": {
- "artifact_name": "baseconfiguration",
- "artifact_version": "1.0.0",
- "mode": "async",
+ "artifact_name": {
+ "title": "artifact_name",
+ "type": "string",
+ "default": "baseconfiguration",
+ "readOnly": "True"
+ },
+ "artifact_version": {
+ "title": "artifact_version",
+ "type": "string",
+ "default": "1.0.0",
+ "readOnly": "True"
+ },
+ "mode": {
+ "title": "mode",
+ "type": "string",
+ "default": "async",
+ "readOnly": "True"
+ },
"data": {
- "resource-assignment-properties": {
- "request-id": "",
- "service-instance-id": "",
- "vnf-id": "",
- "action-name": "",
- "scope-type": "",
- "hostname": "",
- "vnf_name": ""
+ "title": "data",
+ "type": "object",
+ "properties": {
+ "resource-assignment-properties": {
+ "request-id": "",
+ "service-instance-id": "",
+ "vnf-id": "",
+ "action-name": "",
+ "scope-type": "",
+ "hostname": "",
+ "vnf_name": ""
+ }
}
}
}
@@ -106,18 +144,37 @@
{
"title": "activate-restconf",
"properties": {
- "artifact_name": "baseconfiguration",
- "artifact_version": "1.0.0",
- "mode": "async",
+ "artifact_name": {
+ "title": "artifact_name",
+ "type": "string",
+ "default": "baseconfiguration",
+ "readOnly": "True"
+ },
+ "artifact_version": {
+ "title": "artifact_version",
+ "type": "string",
+ "default": "1.0.0",
+ "readOnly": "True"
+ },
+ "mode": {
+ "title": "mode",
+ "type": "string",
+ "default": "async",
+ "readOnly": "True"
+ },
"data": {
- "resource-assignment-properties": {
- "request-id": "",
- "service-instance-id": "",
- "vnf-id": "",
- "action-name": "",
- "scope-type": "",
- "hostname": "",
- "vnf_name": ""
+ "title": "data",
+ "type": "object",
+ "properties": {
+ "resource-assignment-properties": {
+ "request-id": "",
+ "service-instance-id": "",
+ "vnf-id": "",
+ "action-name": "",
+ "scope-type": "",
+ "hostname": "",
+ "vnf_name": ""
+ }
}
}
}
@@ -125,18 +182,37 @@
{
"title": "activate-cli",
"properties": {
- "artifact_name": "baseconfiguration",
- "artifact_version": "1.0.0",
- "mode": "async",
+ "artifact_name": {
+ "title": "artifact_name",
+ "type": "string",
+ "default": "baseconfiguration",
+ "readOnly": "True"
+ },
+ "artifact_version": {
+ "title": "artifact_version",
+ "type": "string",
+ "default": "1.0.0",
+ "readOnly": "True"
+ },
+ "mode": {
+ "title": "mode",
+ "type": "string",
+ "default": "async",
+ "readOnly": "True"
+ },
"data": {
- "resource-assignment-properties": {
- "request-id": "",
- "service-instance-id": "",
- "vnf-id": "",
- "action-name": "",
- "scope-type": "",
- "hostname": "",
- "vnf_name": ""
+ "title": "data",
+ "type": "object",
+ "properties": {
+ "resource-assignment-properties": {
+ "request-id": "",
+ "service-instance-id": "",
+ "vnf-id": "",
+ "action-name": "",
+ "scope-type": "",
+ "hostname": "",
+ "vnf_name": ""
+ }
}
}
}
@@ -144,18 +220,37 @@
{
"title": "assign-activate",
"properties": {
- "artifact_name": "baseconfiguration",
- "artifact_version": "1.0.0",
- "mode": "async",
+ "artifact_name": {
+ "title": "artifact_name",
+ "type": "string",
+ "default": "baseconfiguration",
+ "readOnly": "True"
+ },
+ "artifact_version": {
+ "title": "artifact_version",
+ "type": "string",
+ "default": "1.0.0",
+ "readOnly": "True"
+ },
+ "mode": {
+ "title": "mode",
+ "type": "string",
+ "default": "async",
+ "readOnly": "True"
+ },
"data": {
- "resource-assignment-properties": {
- "request-id": "",
- "service-instance-id": "",
- "vnf-id": "",
- "action-name": "",
- "scope-type": "",
- "hostname": "",
- "vnf_name": ""
+ "title": "data",
+ "type": "object",
+ "properties": {
+ "resource-assignment-properties": {
+ "request-id": "",
+ "service-instance-id": "",
+ "vnf-id": "",
+ "action-name": "",
+ "scope-type": "",
+ "hostname": "",
+ "vnf_name": ""
+ }
}
}
}
@@ -163,18 +258,37 @@
{
"title": "imperative-test-wf",
"properties": {
- "artifact_name": "baseconfiguration",
- "artifact_version": "1.0.0",
- "mode": "async",
+ "artifact_name": {
+ "title": "artifact_name",
+ "type": "string",
+ "default": "baseconfiguration",
+ "readOnly": "True"
+ },
+ "artifact_version": {
+ "title": "artifact_version",
+ "type": "string",
+ "default": "1.0.0",
+ "readOnly": "True"
+ },
+ "mode": {
+ "title": "mode",
+ "type": "string",
+ "default": "async",
+ "readOnly": "True"
+ },
"data": {
- "resource-assignment-properties": {
- "request-id": "",
- "service-instance-id": "",
- "vnf-id": "",
- "action-name": "",
- "scope-type": "",
- "hostname": "",
- "vnf_name": ""
+ "title": "data",
+ "type": "object",
+ "properties": {
+ "resource-assignment-properties": {
+ "request-id": "",
+ "service-instance-id": "",
+ "vnf-id": "",
+ "action-name": "",
+ "scope-type": "",
+ "hostname": "",
+ "vnf_name": ""
+ }
}
}
}