summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorJim Hahn <jrh3@att.com>2020-11-16 17:27:49 +0000
committerGerrit Code Review <gerrit@onap.org>2020-11-16 17:27:49 +0000
commit885dfa06c63adc8fc6ae4d6d34e857152a31ff0b (patch)
treebc00567187a0ee0d6c145a5144a846f6683d959a /examples
parent1ec08dc844b064174926550543f3843f824c159c (diff)
parent937561509d22d265838368165d534636ebd0c70b (diff)
Merge "Update gRPC example for JSON Stringify" into guilin
Diffstat (limited to 'examples')
-rw-r--r--examples/examples-grpc/src/main/resources/logic/CreateSubscriptionPayloadTask.js9
-rw-r--r--examples/examples-grpc/src/main/resources/logic/ReceivePMSubscriptionTask.js44
2 files changed, 48 insertions, 5 deletions
diff --git a/examples/examples-grpc/src/main/resources/logic/CreateSubscriptionPayloadTask.js b/examples/examples-grpc/src/main/resources/logic/CreateSubscriptionPayloadTask.js
index 48f31847b..85e7ae2e9 100644
--- a/examples/examples-grpc/src/main/resources/logic/CreateSubscriptionPayloadTask.js
+++ b/examples/examples-grpc/src/main/resources/logic/CreateSubscriptionPayloadTask.js
@@ -35,11 +35,14 @@ var payloadEntry = executor.subject.getOutFieldSchemaHelper("payload").createNew
payloadEntry.put("create_DasH_subscription_DasH_properties", payloadProperties)
var payload = executor.subject.getOutFieldSchemaHelper("payload").createNewInstance();
+var payloadSchemaHelper = executor.subject.getOutFieldSchemaHelper("payload");
payload.put("create_DasH_subscription_DasH_request", payloadEntry);
-executor.outFields.put("albumID", executor.inFields.get("albumID"))
+executor.logger.info("CDS payload - " + executor.stringify2Json( payload, payloadSchemaHelper));
+
+executor.outFields.put("albumID", executor.inFields.get("albumID"));
executor.outFields.put("payload", payload);
-executor.logger.info("Sending Create Subscription Event to CDS")
+executor.logger.info("Sending Create Subscription Event to CDS");
-true;
+true; \ No newline at end of file
diff --git a/examples/examples-grpc/src/main/resources/logic/ReceivePMSubscriptionTask.js b/examples/examples-grpc/src/main/resources/logic/ReceivePMSubscriptionTask.js
index bc4028a32..0134b6bca 100644
--- a/examples/examples-grpc/src/main/resources/logic/ReceivePMSubscriptionTask.js
+++ b/examples/examples-grpc/src/main/resources/logic/ReceivePMSubscriptionTask.js
@@ -18,6 +18,7 @@
* ============LICENSE_END=========================================================
*/
var uuidType = java.util.UUID;
+var HashMapType = java.util.HashMap;
//albumID will be used to fetch info from our album later
@@ -25,13 +26,21 @@ var albumID = uuidType.fromString("d0050623-18e5-46c9-9298-9a567990cd7c");
var pmSubscriptionInfo = executor.getContextAlbum("PMSubscriptionAlbum").getSchemaHelper().createNewInstance();
var returnValue = true;;
-if(executor.inFields.get("policyName") != null) {
+if (executor.inFields.get("policyName") != null) {
var changeType = executor.inFields.get("changeType")
var nfName = executor.inFields.get("nfName")
var policyName = executor.inFields.get("policyName")
var closedLoopControlName = executor.inFields.get("closedLoopControlName")
var subscription = executor.inFields.get("subscription")
+ var obj = {};
+ obj["nfName"] = executor.inFields.get("nfName")
+ executor.logger.info("nfName" + executor.stringify2Json(obj))
+
+ var ticketInfo = new HashMapType();
+ populate_creator_info(ticketInfo);
+ executor.logger.info("ticketInfo" + executor.stringify2Json(ticketInfo))
+
pmSubscriptionInfo.put("nfName", executor.inFields.get("nfName"));
pmSubscriptionInfo.put("changeType", executor.inFields.get("changeType"))
pmSubscriptionInfo.put("policyName", executor.inFields.get("policyName"))
@@ -45,4 +54,35 @@ if(executor.inFields.get("policyName") != null) {
executor.message = "Received invalid event"
returnValue = false;
}
-returnValue; \ No newline at end of file
+
+function populate_creator_info(ticketInfo){
+ populate_field(ticketInfo, "appId", "NSO");
+ populate_field(ticketInfo, "creatorId", "fidLab");
+ populate_field(ticketInfo, "creatorFirstName", "PSO");
+ populate_field(ticketInfo, "creatorLastName", "team7");
+ populate_field(ticketInfo, "creatorGroup", "PSO-team7");
+ populate_field(ticketInfo, "creatorPEIN", "0000000");
+ populate_field(ticketInfo, "creatorPhoneNumber", "800-450-7771");
+ populate_field(ticketInfo, "fid", "fidLab");
+ populate_field(ticketInfo, "organizationCode", "PSO");
+ populate_field(ticketInfo, "source", create_caEn_value("SURV/ALARM FROM/PSO"));
+ populate_field(ticketInfo, "customerName", "XYZ");
+ populate_field(ticketInfo, "authorization", "Basic dGVzdHVzZXI=");
+}
+
+function populate_field(mapname, name, value){
+ if (value == null){
+ mapname.put(name, "none");
+ } else{
+ mapname.put(name, value);
+ }
+
+}
+
+function create_caEn_value(value){
+ var attr = {};
+ attr["caEn"] = String(value);
+ return attr;
+}
+
+returnValue;