From 751aa0f3c7f090bc10bc59f74aaace1f297a7c2c Mon Sep 17 00:00:00 2001 From: "a.sreekumar" Date: Mon, 25 Jul 2022 10:46:57 +0100 Subject: Update APEX example to use JSON Schema plugin Change-Id: Ic8b412ce0ca71b4452d67b1e4445e423b0ec5b54 Issue-ID: POLICY-4292 Signed-off-by: a.sreekumar --- .../src/main/resources/logic/CreateSubscriptionPayloadTask.js | 11 ++++++----- .../src/main/resources/logic/CreateSubscriptionRequestTask.js | 5 +++-- .../src/main/resources/logic/DeleteSubscriptionPayloadTask.js | 11 ++++++----- .../src/main/resources/logic/DeleteSubscriptionRequestTask.js | 5 +++-- .../src/main/resources/logic/ReceivePMSubscriptionTask.js | 3 ++- .../examples-grpc/src/main/resources/logic/ResponseTask.js | 6 +++--- 6 files changed, 23 insertions(+), 18 deletions(-) (limited to 'examples/examples-grpc/src/main/resources/logic') diff --git a/examples/examples-grpc/src/main/resources/logic/CreateSubscriptionPayloadTask.js b/examples/examples-grpc/src/main/resources/logic/CreateSubscriptionPayloadTask.js index 85e7ae2e9..4cacf81e0 100644 --- a/examples/examples-grpc/src/main/resources/logic/CreateSubscriptionPayloadTask.js +++ b/examples/examples-grpc/src/main/resources/logic/CreateSubscriptionPayloadTask.js @@ -1,6 +1,7 @@ /* * ============LICENSE_START======================================================= * Copyright (C) 2020 Nordix. All rights reserved. + * Modifications Copyright (C) 2022 Bell Canada. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,7 +23,7 @@ executor.logger.info(executor.subject.id); var pmSubscriptionInfo = executor.getContextAlbum("PMSubscriptionAlbum").get(executor.inFields.get("albumID").toString()) -var payloadProperties = executor.subject.getOutFieldSchemaHelper("payload").createNewSubInstance("create_DasH_subscription_DasH_properties_record"); +var payloadProperties = new java.util.HashMap(); payloadProperties.put("nfName", pmSubscriptionInfo.get("nfName")) payloadProperties.put("subscriptionName", pmSubscriptionInfo.get("subscription").get("subscriptionName")) @@ -31,12 +32,12 @@ payloadProperties.put("fileBasedGP", pmSubscriptionInfo.get("subscription").get payloadProperties.put("fileLocation", pmSubscriptionInfo.get("subscription").get("fileLocation")) payloadProperties.put("measurementGroups", pmSubscriptionInfo.get("subscription").get("measurementGroups")) -var payloadEntry = executor.subject.getOutFieldSchemaHelper("payload").createNewSubInstance("CDSRequestPayloadEntry"); -payloadEntry.put("create_DasH_subscription_DasH_properties", payloadProperties) +var payloadEntry = new java.util.HashMap(); +payloadEntry.put("create-subscription-properties", payloadProperties) -var payload = executor.subject.getOutFieldSchemaHelper("payload").createNewInstance(); +var payload = new java.util.HashMap(); var payloadSchemaHelper = executor.subject.getOutFieldSchemaHelper("payload"); -payload.put("create_DasH_subscription_DasH_request", payloadEntry); +payload.put("create-subscription-request", payloadEntry); executor.logger.info("CDS payload - " + executor.stringify2Json( payload, payloadSchemaHelper)); diff --git a/examples/examples-grpc/src/main/resources/logic/CreateSubscriptionRequestTask.js b/examples/examples-grpc/src/main/resources/logic/CreateSubscriptionRequestTask.js index 638429817..33f12036c 100644 --- a/examples/examples-grpc/src/main/resources/logic/CreateSubscriptionRequestTask.js +++ b/examples/examples-grpc/src/main/resources/logic/CreateSubscriptionRequestTask.js @@ -1,6 +1,7 @@ /* * ============LICENSE_START======================================================= * Copyright (C) 2020 Nordix. All rights reserved. + * Modifications Copyright (C) 2022 Bell Canada. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,12 +25,12 @@ var pmSubscriptionInfo = executor.getContextAlbum("PMSubscriptionAlbum").get(exe var payload = executor.inFields.get("payload") var actionName = "create-subscription" -var commonHeader = executor.subject.getOutFieldSchemaHelper("commonHeader").createNewInstance(); +var commonHeader = new java.util.HashMap(); commonHeader.put("originatorId", "sdnc"); commonHeader.put("requestId", "123456-1000"); commonHeader.put("subRequestId", "sub-123456-1000"); -var actionIdentifiers = executor.subject.getOutFieldSchemaHelper("actionIdentifiers").createNewInstance(); +var actionIdentifiers = new java.util.HashMap(); actionIdentifiers.put("actionName", actionName); actionIdentifiers.put("blueprintName", "pm_control"); actionIdentifiers.put("blueprintVersion", "1.0.0"); diff --git a/examples/examples-grpc/src/main/resources/logic/DeleteSubscriptionPayloadTask.js b/examples/examples-grpc/src/main/resources/logic/DeleteSubscriptionPayloadTask.js index 180dcba71..7a897ea91 100644 --- a/examples/examples-grpc/src/main/resources/logic/DeleteSubscriptionPayloadTask.js +++ b/examples/examples-grpc/src/main/resources/logic/DeleteSubscriptionPayloadTask.js @@ -1,6 +1,7 @@ /* * ============LICENSE_START======================================================= * Copyright (C) 2020 Nordix. All rights reserved. + * Modifications Copyright (C) 2022 Bell Canada. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,7 +23,7 @@ executor.logger.info(executor.subject.id); var pmSubscriptionInfo = executor.getContextAlbum("PMSubscriptionAlbum").get(executor.inFields.get("albumID").toString()) -var payloadProperties = executor.subject.getOutFieldSchemaHelper("payload").createNewSubInstance("delete_DasH_subscription_DasH_properties_record"); +var payloadProperties = new java.util.HashMap(); payloadProperties.put("nfName", pmSubscriptionInfo.get("nfName")) payloadProperties.put("subscriptionName", pmSubscriptionInfo.get("subscription").get("subscriptionName")) @@ -31,11 +32,11 @@ payloadProperties.put("fileBasedGP", pmSubscriptionInfo.get("subscription").get payloadProperties.put("fileLocation", pmSubscriptionInfo.get("subscription").get("fileLocation")) payloadProperties.put("measurementGroups", pmSubscriptionInfo.get("subscription").get("measurementGroups")) -var payloadEntry = executor.subject.getOutFieldSchemaHelper("payload").createNewSubInstance("CDSRequestPayloadEntry"); -payloadEntry.put("delete_DasH_subscription_DasH_properties", payloadProperties) +var payloadEntry = new java.util.HashMap(); +payloadEntry.put("delete-subscription-properties", payloadProperties) -var payload = executor.subject.getOutFieldSchemaHelper("payload").createNewInstance(); -payload.put("delete_DasH_subscription_DasH_request", payloadEntry); +var payload = new java.util.HashMap(); +payload.put("delete-subscription-request", payloadEntry); executor.outFields.put("albumID", executor.inFields.get("albumID")) executor.outFields.put("payload", payload); diff --git a/examples/examples-grpc/src/main/resources/logic/DeleteSubscriptionRequestTask.js b/examples/examples-grpc/src/main/resources/logic/DeleteSubscriptionRequestTask.js index 9ec2a119b..dc0f23563 100644 --- a/examples/examples-grpc/src/main/resources/logic/DeleteSubscriptionRequestTask.js +++ b/examples/examples-grpc/src/main/resources/logic/DeleteSubscriptionRequestTask.js @@ -1,6 +1,7 @@ /* * ============LICENSE_START======================================================= * Copyright (C) 2020 Nordix. All rights reserved. + * Modifications Copyright (C) 2022 Bell Canada. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,12 +25,12 @@ var pmSubscriptionInfo = executor.getContextAlbum("PMSubscriptionAlbum").get(exe var payload = executor.inFields.get("payload") var actionName = "delete-subscription" -var commonHeader = executor.subject.getOutFieldSchemaHelper("commonHeader").createNewInstance(); +var commonHeader = new java.util.HashMap(); commonHeader.put("originatorId", "sdnc"); commonHeader.put("requestId", "123456-1000"); commonHeader.put("subRequestId", "sub-123456-1000"); -var actionIdentifiers = executor.subject.getOutFieldSchemaHelper("actionIdentifiers").createNewInstance(); +var actionIdentifiers = new java.util.HashMap(); actionIdentifiers.put("actionName", actionName); actionIdentifiers.put("blueprintName", "pm_control"); actionIdentifiers.put("blueprintVersion", "1.0.0"); diff --git a/examples/examples-grpc/src/main/resources/logic/ReceivePMSubscriptionTask.js b/examples/examples-grpc/src/main/resources/logic/ReceivePMSubscriptionTask.js index 0134b6bca..ea3a9e494 100644 --- a/examples/examples-grpc/src/main/resources/logic/ReceivePMSubscriptionTask.js +++ b/examples/examples-grpc/src/main/resources/logic/ReceivePMSubscriptionTask.js @@ -1,6 +1,7 @@ /* * ============LICENSE_START======================================================= * Copyright (C) 2020 Nordix. All rights reserved. + * Modifications Copyright (C) 2022 Bell Canada. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,7 +24,7 @@ var HashMapType = java.util.HashMap; //albumID will be used to fetch info from our album later var albumID = uuidType.fromString("d0050623-18e5-46c9-9298-9a567990cd7c"); -var pmSubscriptionInfo = executor.getContextAlbum("PMSubscriptionAlbum").getSchemaHelper().createNewInstance(); +var pmSubscriptionInfo = new java.util.HashMap(); var returnValue = true;; if (executor.inFields.get("policyName") != null) { diff --git a/examples/examples-grpc/src/main/resources/logic/ResponseTask.js b/examples/examples-grpc/src/main/resources/logic/ResponseTask.js index dc4948990..d3424bdc1 100644 --- a/examples/examples-grpc/src/main/resources/logic/ResponseTask.js +++ b/examples/examples-grpc/src/main/resources/logic/ResponseTask.js @@ -1,7 +1,7 @@ /* * ============LICENSE_START======================================================= * Copyright (C) 2020 Nordix. All rights reserved. - * Modifications Copyright (C) 2021 Bell Canada. All rights reserved. + * Modifications Copyright (C) 2021-2022 Bell Canada. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -26,7 +26,7 @@ var albumID = uuidType.fromString("d0050623-18e5-46c9-9298-9a567990cd7c"); var pmSubscriptionInfo = executor.getContextAlbum("PMSubscriptionAlbum").get(albumID.toString()); -var responseStatus = executor.subject.getOutFieldSchemaHelper("CDSResponseStatusEvent", "status").createNewInstance(); +var responseStatus = new java.util.HashMap(); responseStatus.put("subscriptionName", pmSubscriptionInfo.get("subscription").get("subscriptionName")) responseStatus.put("nfName", pmSubscriptionInfo.get("nfName")) @@ -34,7 +34,7 @@ responseStatus.put("changeType", pmSubscriptionInfo.get("changeType")) var response = executor.inFields.get("payload") -if ("failure".equals(response.get("create_DasH_subscription_DasH_response").get("odl_DasH_response").get("status"))) { +if ("failure".equals(response.get("create-subscription-response").get("odl-response").get("status"))) { responseStatus.put("message", "failed") } else { responseStatus.put("message", "success") -- cgit 1.2.3-korg