summaryrefslogtreecommitdiffstats
path: root/auth
diff options
context:
space:
mode:
authora.sreekumar <ajith.sreekumar@bell.ca>2021-06-22 15:55:46 +0100
committera.sreekumar <ajith.sreekumar@bell.ca>2021-06-28 10:36:48 +0100
commit926646d8e5e86e680a119360f93d7bdb46c89435 (patch)
tree7ff431e59672b19f658faed87c80b4d147253c9c /auth
parent63637d939697451d3ac63216d938780a157ff895 (diff)
Changes to support multiple outputs from a state
This review addresses two main changes: 1) inputFields and outputFields are not tied to task definition anymore. Instead inputEvent and outputEvents associated to a task is populated as part of the policy state definition, as the state definition have the information anyway. - Clean up of the usage of inputFields and outputFields in task definition will happen in a future review - inputFields and outputFields defined in task definition in policies until honolulu will not make the policy invalid as the changes are done in backward compatible way. 2) Multiple output events can come out of a final state now. - Define another policy state output with the relevant eventName in the command file - In the task logic, create a map to store the fields of the relevant outputEvent, and then just call "executor.addFieldsToOutput(<the_map_of_fields>)" These 2 steps are enough to send multiple events to relevant components as per the apex configuration. Change-Id: Id88ca402704106404f529e595e1a76f6bf167876 Issue-ID: POLICY-3336 Signed-off-by: a.sreekumar <ajith.sreekumar@bell.ca>
Diffstat (limited to 'auth')
-rw-r--r--auth/cli-codegen/src/test/java/org/onap/policy/apex/auth/clicodegen/CodeGeneratorCliEditorTest.java5
-rw-r--r--auth/cli-editor/src/test/java/org/onap/policy/apex/auth/clieditor/CommandLineEditorEventsContextTest.java5
-rw-r--r--auth/cli-editor/src/test/resources/tosca/PolicyModel.json2204
-rw-r--r--auth/cli-editor/src/test/resources/tosca/ToscaPolicyOutput_compare.json2
4 files changed, 1270 insertions, 946 deletions
diff --git a/auth/cli-codegen/src/test/java/org/onap/policy/apex/auth/clicodegen/CodeGeneratorCliEditorTest.java b/auth/cli-codegen/src/test/java/org/onap/policy/apex/auth/clicodegen/CodeGeneratorCliEditorTest.java
index 921591b32..cec261c2a 100644
--- a/auth/cli-codegen/src/test/java/org/onap/policy/apex/auth/clicodegen/CodeGeneratorCliEditorTest.java
+++ b/auth/cli-codegen/src/test/java/org/onap/policy/apex/auth/clicodegen/CodeGeneratorCliEditorTest.java
@@ -3,6 +3,7 @@
* Copyright (C) 2018 Ericsson. All rights reserved.
* Modifications Copyright (C) 2019 Samsung Electronics Co., Ltd.
* Modifications Copyright (C) 2020 Nordix Foundation
+ * Modifications Copyright (C) 2021 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.
@@ -425,8 +426,8 @@ public class CodeGeneratorCliEditorTest {
final AxReferenceKey outkey = out.getKey();
final ST val = cg.createPolicyStateOutput(kig.getPName(skey), kig.getPVersion(skey), kig.getLName(skey),
- kig.getLName(outkey), kig.getName(out.getOutgingEvent()),
- kig.getVersion(out.getOutgingEvent()), kig.getLName(out.getNextState()));
+ kig.getLName(outkey), kig.getName(out.getOutgoingEvent()), kig.getVersion(out.getOutgoingEvent()),
+ kig.getLName(out.getNextState()));
ret.add(val);
}
diff --git a/auth/cli-editor/src/test/java/org/onap/policy/apex/auth/clieditor/CommandLineEditorEventsContextTest.java b/auth/cli-editor/src/test/java/org/onap/policy/apex/auth/clieditor/CommandLineEditorEventsContextTest.java
index d00a9232b..0e87950d2 100644
--- a/auth/cli-editor/src/test/java/org/onap/policy/apex/auth/clieditor/CommandLineEditorEventsContextTest.java
+++ b/auth/cli-editor/src/test/java/org/onap/policy/apex/auth/clieditor/CommandLineEditorEventsContextTest.java
@@ -2,6 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
* Modifications Copyright (C) 2020 Nordix Foundation.
+ * Modifications Copyright (C) 2021 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.
@@ -84,7 +85,7 @@ public class CommandLineEditorEventsContextTest {
final int modelCharCount = modelString.replaceAll(SPACES, EMPTY_STRING).length();
assertEquals(25892, logCharCount);
- assertEquals(46048, modelCharCount);
+ assertEquals(51975, modelCharCount);
}
/**
@@ -114,7 +115,7 @@ public class CommandLineEditorEventsContextTest {
final int modelCharCount = modelString.replaceAll(SPACES, EMPTY_STRING).length();
assertEquals(30068, logCharCount);
- assertEquals(52596, modelCharCount);
+ assertEquals(59015, modelCharCount);
}
diff --git a/auth/cli-editor/src/test/resources/tosca/PolicyModel.json b/auth/cli-editor/src/test/resources/tosca/PolicyModel.json
index 0e9cfca11..3672be430 100644
--- a/auth/cli-editor/src/test/resources/tosca/PolicyModel.json
+++ b/auth/cli-editor/src/test/resources/tosca/PolicyModel.json
@@ -1,952 +1,1274 @@
{
- "apexPolicyModel" : {
- "key" : {
- "name" : "MyFirstPolicyModel",
- "version" : "0.0.1"
+ "apexPolicyModel": {
+ "key": {
+ "name": "MyFirstPolicyModel",
+ "version": "0.0.1"
+ },
+ "keyInformation": {
+ "key": {
+ "name": "MyFirstPolicyModel_KeyInfo",
+ "version": "0.0.1"
},
- "keyInformation" : {
- "key" : {
- "name" : "MyFirstPolicyModel_KeyInfo",
- "version" : "0.0.1"
- },
- "keyInfoMap" : {
- "entry" : [ {
- "key" : {
- "name" : "MorningBoozeCheck",
- "version" : "0.0.1"
- },
- "value" : {
- "key" : {
- "name" : "MorningBoozeCheck",
- "version" : "0.0.1"
- },
- "UUID" : "3351b0f4-cf06-4fa2-8823-edf67bd30223",
- "description" : "This task checks if the sales request is for an item that contains alcohol. \nIf the local time is between 00:00:00 and 11:30:00 then the sale is not authorised. Otherwise the sale is authorised. \nIn this implementation we assume that all items with item_ID values between 1000 and 2000 contain alcohol :-)"
- }
- }, {
- "key" : {
- "name" : "MyFirstPolicy",
- "version" : "0.0.1"
- },
- "value" : {
- "key" : {
- "name" : "MyFirstPolicy",
- "version" : "0.0.1"
- },
- "UUID" : "6c5e410f-489a-46ff-964e-982ce6e8b6d0",
- "description" : "This is my first Apex policy. It checks if a sale should be authorised or not."
- }
- }, {
- "key" : {
- "name" : "MyFirstPolicyModel",
- "version" : "0.0.1"
- },
- "value" : {
- "key" : {
- "name" : "MyFirstPolicyModel",
- "version" : "0.0.1"
- },
- "UUID" : "540226fb-55ee-4f0e-a444-983a0494818e",
- "description" : "This is my first Apex Policy Model."
- }
- }, {
- "key" : {
- "name" : "MyFirstPolicyModel_Events",
- "version" : "0.0.1"
- },
- "value" : {
- "key" : {
- "name" : "MyFirstPolicyModel_Events",
- "version" : "0.0.1"
- },
- "UUID" : "ef281318-5ac9-3ef0-8db3-8f9c4e4a81e2",
- "description" : "Generated description for concept referred to by key \"MyFirstPolicyModel_Events:0.0.1\""
- }
- }, {
- "key" : {
- "name" : "MyFirstPolicyModel_KeyInfo",
- "version" : "0.0.1"
- },
- "value" : {
- "key" : {
- "name" : "MyFirstPolicyModel_KeyInfo",
- "version" : "0.0.1"
- },
- "UUID" : "d9248c6f-7c00-38df-8251-611463ba4065",
- "description" : "Generated description for concept referred to by key \"MyFirstPolicyModel_KeyInfo:0.0.1\""
- }
- }, {
- "key" : {
- "name" : "MyFirstPolicyModel_Policies",
- "version" : "0.0.1"
- },
- "value" : {
- "key" : {
- "name" : "MyFirstPolicyModel_Policies",
- "version" : "0.0.1"
- },
- "UUID" : "77c01a6b-510c-3aa9-b640-b4db356aa03b",
- "description" : "Generated description for concept referred to by key \"MyFirstPolicyModel_Policies:0.0.1\""
- }
- }, {
- "key" : {
- "name" : "MyFirstPolicyModel_Schemas",
- "version" : "0.0.1"
- },
- "value" : {
- "key" : {
- "name" : "MyFirstPolicyModel_Schemas",
- "version" : "0.0.1"
- },
- "UUID" : "d0cc3aa0-ea69-3a43-80ff-a0dbb0ebd885",
- "description" : "Generated description for concept referred to by key \"MyFirstPolicyModel_Schemas:0.0.1\""
- }
- }, {
- "key" : {
- "name" : "MyFirstPolicyModel_Tasks",
- "version" : "0.0.1"
- },
- "value" : {
- "key" : {
- "name" : "MyFirstPolicyModel_Tasks",
- "version" : "0.0.1"
- },
- "UUID" : "b02a7e02-2cd0-39e6-b3cb-946fa83a8f08",
- "description" : "Generated description for concept referred to by key \"MyFirstPolicyModel_Tasks:0.0.1\""
- }
- }, {
- "key" : {
- "name" : "SALE_AUTH",
- "version" : "0.0.1"
- },
- "value" : {
- "key" : {
- "name" : "SALE_AUTH",
- "version" : "0.0.1"
- },
- "UUID" : "c4500941-3f98-4080-a9cc-5b9753ed050b",
- "description" : "An event emitted by the Policy to indicate whether the sale of an item has been authorised"
- }
- }, {
- "key" : {
- "name" : "SALE_INPUT",
- "version" : "0.0.1"
- },
- "value" : {
- "key" : {
- "name" : "SALE_INPUT",
- "version" : "0.0.1"
- },
- "UUID" : "4f04aa98-e917-4f4a-882a-c75ba5a99374",
- "description" : "An event raised by the PoS system each time an item is scanned for purchase"
- }
- }, {
- "key" : {
- "name" : "assistant_ID_type",
- "version" : "0.0.1"
- },
- "value" : {
- "key" : {
- "name" : "assistant_ID_type",
- "version" : "0.0.1"
- },
- "UUID" : "36df4c71-9616-4206-8b53-976a5cd4bd87",
- "description" : "A type for 'assistant_ID' values"
- }
- }, {
- "key" : {
- "name" : "authorised_type",
- "version" : "0.0.1"
- },
- "value" : {
- "key" : {
- "name" : "authorised_type",
- "version" : "0.0.1"
- },
- "UUID" : "d48b619e-d00d-4008-b884-02d76ea4350b",
- "description" : "A type for 'authorised' values"
- }
- }, {
- "key" : {
- "name" : "branch_ID_type",
- "version" : "0.0.1"
- },
- "value" : {
- "key" : {
- "name" : "branch_ID_type",
- "version" : "0.0.1"
- },
- "UUID" : "6468845f-4122-4128-8e49-0f52c26078b5",
- "description" : "A type for 'branch_ID' values"
- }
- }, {
- "key" : {
- "name" : "item_ID_type",
- "version" : "0.0.1"
- },
- "value" : {
- "key" : {
- "name" : "item_ID_type",
- "version" : "0.0.1"
- },
- "UUID" : "4f227ff1-aee0-453a-b6b6-9a4b2e0da932",
- "description" : "A type for 'item_ID' values"
- }
- }, {
- "key" : {
- "name" : "message_type",
- "version" : "0.0.1"
- },
- "value" : {
- "key" : {
- "name" : "message_type",
- "version" : "0.0.1"
- },
- "UUID" : "ad1431bb-3155-4e73-b5a3-b89bee498749",
- "description" : "A type for 'message' values"
- }
- }, {
- "key" : {
- "name" : "notes_type",
- "version" : "0.0.1"
- },
- "value" : {
- "key" : {
- "name" : "notes_type",
- "version" : "0.0.1"
- },
- "UUID" : "eecfde90-896c-4343-8f9c-2603ced94e2d",
- "description" : "A type for 'notes' values"
- }
- }, {
- "key" : {
- "name" : "price_type",
- "version" : "0.0.1"
- },
- "value" : {
- "key" : {
- "name" : "price_type",
- "version" : "0.0.1"
- },
- "UUID" : "52c2fc45-fd8c-463c-bd6f-d91b0554aea7",
- "description" : "A type for 'amount'/'price' values"
- }
- }, {
- "key" : {
- "name" : "quantity_type",
- "version" : "0.0.1"
- },
- "value" : {
- "key" : {
- "name" : "quantity_type",
- "version" : "0.0.1"
- },
- "UUID" : "ac3d9842-80af-4a98-951c-bd79a431c613",
- "description" : "A type for 'quantity' values"
- }
- }, {
- "key" : {
- "name" : "sale_ID_type",
- "version" : "0.0.1"
- },
- "value" : {
- "key" : {
- "name" : "sale_ID_type",
- "version" : "0.0.1"
- },
- "UUID" : "cca47d74-7754-4a61-b163-ca31f66b157b",
- "description" : "A type for 'sale_ID' values"
- }
- }, {
- "key" : {
- "name" : "timestamp_type",
- "version" : "0.0.1"
- },
- "value" : {
- "key" : {
- "name" : "timestamp_type",
- "version" : "0.0.1"
- },
- "UUID" : "fd594e88-411d-4a94-b2be-697b3a0d7adf",
- "description" : "A type for 'time' values"
- }
- } ]
- }
+ "keyInfoMap": {
+ "entry": [
+ {
+ "key": {
+ "name": "MorningBoozeCheck",
+ "version": "0.0.1"
+ },
+ "value": {
+ "key": {
+ "name": "MorningBoozeCheck",
+ "version": "0.0.1"
+ },
+ "UUID": "3351b0f4-cf06-4fa2-8823-edf67bd30223",
+ "description": "This task checks if the sales request is for an item that contains alcohol. \nIf the local time is between 00:00:00 and 11:30:00 then the sale is not authorised. Otherwise the sale is authorised. \nIn this implementation we assume that all items with item_ID values between 1000 and 2000 contain alcohol :-)"
+ }
+ },
+ {
+ "key": {
+ "name": "MyFirstPolicy",
+ "version": "0.0.1"
+ },
+ "value": {
+ "key": {
+ "name": "MyFirstPolicy",
+ "version": "0.0.1"
+ },
+ "UUID": "6c5e410f-489a-46ff-964e-982ce6e8b6d0",
+ "description": "This is my first Apex policy. It checks if a sale should be authorised or not."
+ }
+ },
+ {
+ "key": {
+ "name": "MyFirstPolicyModel",
+ "version": "0.0.1"
+ },
+ "value": {
+ "key": {
+ "name": "MyFirstPolicyModel",
+ "version": "0.0.1"
+ },
+ "UUID": "540226fb-55ee-4f0e-a444-983a0494818e",
+ "description": "This is my first Apex Policy Model."
+ }
+ },
+ {
+ "key": {
+ "name": "MyFirstPolicyModel_Events",
+ "version": "0.0.1"
+ },
+ "value": {
+ "key": {
+ "name": "MyFirstPolicyModel_Events",
+ "version": "0.0.1"
+ },
+ "UUID": "ef281318-5ac9-3ef0-8db3-8f9c4e4a81e2",
+ "description": "Generated description for concept referred to by key \"MyFirstPolicyModel_Events:0.0.1\""
+ }
+ },
+ {
+ "key": {
+ "name": "MyFirstPolicyModel_KeyInfo",
+ "version": "0.0.1"
+ },
+ "value": {
+ "key": {
+ "name": "MyFirstPolicyModel_KeyInfo",
+ "version": "0.0.1"
+ },
+ "UUID": "d9248c6f-7c00-38df-8251-611463ba4065",
+ "description": "Generated description for concept referred to by key \"MyFirstPolicyModel_KeyInfo:0.0.1\""
+ }
+ },
+ {
+ "key": {
+ "name": "MyFirstPolicyModel_Policies",
+ "version": "0.0.1"
+ },
+ "value": {
+ "key": {
+ "name": "MyFirstPolicyModel_Policies",
+ "version": "0.0.1"
+ },
+ "UUID": "77c01a6b-510c-3aa9-b640-b4db356aa03b",
+ "description": "Generated description for concept referred to by key \"MyFirstPolicyModel_Policies:0.0.1\""
+ }
+ },
+ {
+ "key": {
+ "name": "MyFirstPolicyModel_Schemas",
+ "version": "0.0.1"
+ },
+ "value": {
+ "key": {
+ "name": "MyFirstPolicyModel_Schemas",
+ "version": "0.0.1"
+ },
+ "UUID": "d0cc3aa0-ea69-3a43-80ff-a0dbb0ebd885",
+ "description": "Generated description for concept referred to by key \"MyFirstPolicyModel_Schemas:0.0.1\""
+ }
+ },
+ {
+ "key": {
+ "name": "MyFirstPolicyModel_Tasks",
+ "version": "0.0.1"
+ },
+ "value": {
+ "key": {
+ "name": "MyFirstPolicyModel_Tasks",
+ "version": "0.0.1"
+ },
+ "UUID": "b02a7e02-2cd0-39e6-b3cb-946fa83a8f08",
+ "description": "Generated description for concept referred to by key \"MyFirstPolicyModel_Tasks:0.0.1\""
+ }
+ },
+ {
+ "key": {
+ "name": "SALE_AUTH",
+ "version": "0.0.1"
+ },
+ "value": {
+ "key": {
+ "name": "SALE_AUTH",
+ "version": "0.0.1"
+ },
+ "UUID": "c4500941-3f98-4080-a9cc-5b9753ed050b",
+ "description": "An event emitted by the Policy to indicate whether the sale of an item has been authorised"
+ }
+ },
+ {
+ "key": {
+ "name": "SALE_INPUT",
+ "version": "0.0.1"
+ },
+ "value": {
+ "key": {
+ "name": "SALE_INPUT",
+ "version": "0.0.1"
+ },
+ "UUID": "4f04aa98-e917-4f4a-882a-c75ba5a99374",
+ "description": "An event raised by the PoS system each time an item is scanned for purchase"
+ }
+ },
+ {
+ "key": {
+ "name": "assistant_ID_type",
+ "version": "0.0.1"
+ },
+ "value": {
+ "key": {
+ "name": "assistant_ID_type",
+ "version": "0.0.1"
+ },
+ "UUID": "36df4c71-9616-4206-8b53-976a5cd4bd87",
+ "description": "A type for 'assistant_ID' values"
+ }
+ },
+ {
+ "key": {
+ "name": "authorised_type",
+ "version": "0.0.1"
+ },
+ "value": {
+ "key": {
+ "name": "authorised_type",
+ "version": "0.0.1"
+ },
+ "UUID": "d48b619e-d00d-4008-b884-02d76ea4350b",
+ "description": "A type for 'authorised' values"
+ }
+ },
+ {
+ "key": {
+ "name": "branch_ID_type",
+ "version": "0.0.1"
+ },
+ "value": {
+ "key": {
+ "name": "branch_ID_type",
+ "version": "0.0.1"
+ },
+ "UUID": "6468845f-4122-4128-8e49-0f52c26078b5",
+ "description": "A type for 'branch_ID' values"
+ }
+ },
+ {
+ "key": {
+ "name": "item_ID_type",
+ "version": "0.0.1"
+ },
+ "value": {
+ "key": {
+ "name": "item_ID_type",
+ "version": "0.0.1"
+ },
+ "UUID": "4f227ff1-aee0-453a-b6b6-9a4b2e0da932",
+ "description": "A type for 'item_ID' values"
+ }
+ },
+ {
+ "key": {
+ "name": "message_type",
+ "version": "0.0.1"
+ },
+ "value": {
+ "key": {
+ "name": "message_type",
+ "version": "0.0.1"
+ },
+ "UUID": "ad1431bb-3155-4e73-b5a3-b89bee498749",
+ "description": "A type for 'message' values"
+ }
+ },
+ {
+ "key": {
+ "name": "notes_type",
+ "version": "0.0.1"
+ },
+ "value": {
+ "key": {
+ "name": "notes_type",
+ "version": "0.0.1"
+ },
+ "UUID": "eecfde90-896c-4343-8f9c-2603ced94e2d",
+ "description": "A type for 'notes' values"
+ }
+ },
+ {
+ "key": {
+ "name": "price_type",
+ "version": "0.0.1"
+ },
+ "value": {
+ "key": {
+ "name": "price_type",
+ "version": "0.0.1"
+ },
+ "UUID": "52c2fc45-fd8c-463c-bd6f-d91b0554aea7",
+ "description": "A type for 'amount'/'price' values"
+ }
+ },
+ {
+ "key": {
+ "name": "quantity_type",
+ "version": "0.0.1"
+ },
+ "value": {
+ "key": {
+ "name": "quantity_type",
+ "version": "0.0.1"
+ },
+ "UUID": "ac3d9842-80af-4a98-951c-bd79a431c613",
+ "description": "A type for 'quantity' values"
+ }
+ },
+ {
+ "key": {
+ "name": "sale_ID_type",
+ "version": "0.0.1"
+ },
+ "value": {
+ "key": {
+ "name": "sale_ID_type",
+ "version": "0.0.1"
+ },
+ "UUID": "cca47d74-7754-4a61-b163-ca31f66b157b",
+ "description": "A type for 'sale_ID' values"
+ }
+ },
+ {
+ "key": {
+ "name": "timestamp_type",
+ "version": "0.0.1"
+ },
+ "value": {
+ "key": {
+ "name": "timestamp_type",
+ "version": "0.0.1"
+ },
+ "UUID": "fd594e88-411d-4a94-b2be-697b3a0d7adf",
+ "description": "A type for 'time' values"
+ }
+ }
+ ]
+ }
+ },
+ "policies": {
+ "key": {
+ "name": "MyFirstPolicyModel_Policies",
+ "version": "0.0.1"
},
- "policies" : {
- "key" : {
- "name" : "MyFirstPolicyModel_Policies",
- "version" : "0.0.1"
- },
- "policyMap" : {
- "entry" : [ {
- "key" : {
- "name" : "MyFirstPolicy",
- "version" : "0.0.1"
- },
- "value" : {
- "policyKey" : {
- "name" : "MyFirstPolicy",
- "version" : "0.0.1"
- },
- "template" : "FREEFORM",
- "state" : {
- "entry" : [ {
- "key" : "BoozeAuthDecide",
- "value" : {
- "stateKey" : {
- "parentKeyName" : "MyFirstPolicy",
- "parentKeyVersion" : "0.0.1",
- "parentLocalName" : "NULL",
- "localName" : "BoozeAuthDecide"
- },
- "trigger" : {
- "name" : "SALE_INPUT",
- "version" : "0.0.1"
- },
- "stateOutputs" : {
- "entry" : [ {
- "key" : "MorningBoozeCheck_Output_Direct",
- "value" : {
- "key" : {
- "parentKeyName" : "MyFirstPolicy",
- "parentKeyVersion" : "0.0.1",
- "parentLocalName" : "BoozeAuthDecide",
- "localName" : "MorningBoozeCheck_Output_Direct"
- },
- "outgoingEvent" : {
- "name" : "SALE_AUTH",
- "version" : "0.0.1"
- },
- "nextState" : {
- "parentKeyName" : "NULL",
- "parentKeyVersion" : "0.0.0",
- "parentLocalName" : "NULL",
- "localName" : "NULL"
- }
- }
- } ]
- },
- "contextAlbumReference" : [ ],
- "taskSelectionLogic" : {
- "key" : "NULL",
- "logicFlavour" : "UNDEFINED",
- "logic" : ""
- },
- "stateFinalizerLogicMap" : {
- "entry" : [ ]
- },
- "defaultTask" : {
- "name" : "MorningBoozeCheck",
- "version" : "0.0.1"
- },
- "taskReferences" : {
- "entry" : [ {
- "key" : {
- "name" : "MorningBoozeCheck",
- "version" : "0.0.1"
- },
- "value" : {
- "key" : {
- "parentKeyName" : "MyFirstPolicy",
- "parentKeyVersion" : "0.0.1",
- "parentLocalName" : "BoozeAuthDecide",
- "localName" : "MorningBoozeCheck"
- },
- "outputType" : "DIRECT",
- "output" : {
- "parentKeyName" : "MyFirstPolicy",
- "parentKeyVersion" : "0.0.1",
- "parentLocalName" : "BoozeAuthDecide",
- "localName" : "MorningBoozeCheck_Output_Direct"
- }
- }
- } ]
- }
- }
- } ]
- },
- "firstState" : "BoozeAuthDecide"
- }
- } ]
- }
+ "policyMap": {
+ "entry": [
+ {
+ "key": {
+ "name": "MyFirstPolicy",
+ "version": "0.0.1"
+ },
+ "value": {
+ "policyKey": {
+ "name": "MyFirstPolicy",
+ "version": "0.0.1"
+ },
+ "template": "FREEFORM",
+ "state": {
+ "entry": [
+ {
+ "key": "BoozeAuthDecide",
+ "value": {
+ "stateKey": {
+ "parentKeyName": "MyFirstPolicy",
+ "parentKeyVersion": "0.0.1",
+ "parentLocalName": "NULL",
+ "localName": "BoozeAuthDecide"
+ },
+ "trigger": {
+ "name": "SALE_INPUT",
+ "version": "0.0.1"
+ },
+ "stateOutputs": {
+ "entry": [
+ {
+ "key": "MorningBoozeCheck_Output_Direct",
+ "value": {
+ "key": {
+ "parentKeyName": "MyFirstPolicy",
+ "parentKeyVersion": "0.0.1",
+ "parentLocalName": "BoozeAuthDecide",
+ "localName": "MorningBoozeCheck_Output_Direct"
+ },
+ "outgoingEvent": {
+ "name": "SALE_AUTH",
+ "version": "0.0.1"
+ },
+ "outgoingEventReference": [
+ {
+ "name": "SALE_AUTH",
+ "version": "0.0.1"
+ }
+ ],
+ "nextState": {
+ "parentKeyName": "NULL",
+ "parentKeyVersion": "0.0.0",
+ "parentLocalName": "NULL",
+ "localName": "NULL"
+ }
+ }
+ }
+ ]
+ },
+ "contextAlbumReference": [],
+ "taskSelectionLogic": {
+ "key": "NULL",
+ "logicFlavour": "UNDEFINED",
+ "logic": ""
+ },
+ "stateFinalizerLogicMap": {
+ "entry": []
+ },
+ "defaultTask": {
+ "name": "MorningBoozeCheck",
+ "version": "0.0.1"
+ },
+ "taskReferences": {
+ "entry": [
+ {
+ "key": {
+ "name": "MorningBoozeCheck",
+ "version": "0.0.1"
+ },
+ "value": {
+ "key": {
+ "parentKeyName": "MyFirstPolicy",
+ "parentKeyVersion": "0.0.1",
+ "parentLocalName": "BoozeAuthDecide",
+ "localName": "MorningBoozeCheck"
+ },
+ "outputType": "DIRECT",
+ "output": {
+ "parentKeyName": "MyFirstPolicy",
+ "parentKeyVersion": "0.0.1",
+ "parentLocalName": "BoozeAuthDecide",
+ "localName": "MorningBoozeCheck_Output_Direct"
+ }
+ }
+ }
+ ]
+ }
+ }
+ }
+ ]
+ },
+ "firstState": "BoozeAuthDecide"
+ }
+ }
+ ]
+ }
+ },
+ "tasks": {
+ "key": {
+ "name": "MyFirstPolicyModel_Tasks",
+ "version": "0.0.1"
},
- "tasks" : {
- "key" : {
- "name" : "MyFirstPolicyModel_Tasks",
- "version" : "0.0.1"
- },
- "taskMap" : {
- "entry" : [ {
- "key" : {
- "name" : "MorningBoozeCheck",
- "version" : "0.0.1"
- },
- "value" : {
- "key" : {
- "name" : "MorningBoozeCheck",
- "version" : "0.0.1"
- },
- "inputFields" : {
- "entry" : [ {
- "key" : "amount",
- "value" : {
- "key" : "amount",
- "fieldSchemaKey" : {
- "name" : "price_type",
- "version" : "0.0.1"
- },
- "optional" : false
- }
- }, {
- "key" : "assistant_ID",
- "value" : {
- "key" : "assistant_ID",
- "fieldSchemaKey" : {
- "name" : "assistant_ID_type",
- "version" : "0.0.1"
- },
- "optional" : false
- }
- }, {
- "key" : "branch_ID",
- "value" : {
- "key" : "branch_ID",
- "fieldSchemaKey" : {
- "name" : "branch_ID_type",
- "version" : "0.0.1"
- },
- "optional" : false
- }
- }, {
- "key" : "item_ID",
- "value" : {
- "key" : "item_ID",
- "fieldSchemaKey" : {
- "name" : "item_ID_type",
- "version" : "0.0.1"
- },
- "optional" : false
- }
- }, {
- "key" : "notes",
- "value" : {
- "key" : "notes",
- "fieldSchemaKey" : {
- "name" : "notes_type",
- "version" : "0.0.1"
- },
- "optional" : true
- }
- }, {
- "key" : "quantity",
- "value" : {
- "key" : "quantity",
- "fieldSchemaKey" : {
- "name" : "quantity_type",
- "version" : "0.0.1"
- },
- "optional" : false
- }
- }, {
- "key" : "sale_ID",
- "value" : {
- "key" : "sale_ID",
- "fieldSchemaKey" : {
- "name" : "sale_ID_type",
- "version" : "0.0.1"
- },
- "optional" : false
- }
- }, {
- "key" : "time",
- "value" : {
- "key" : "time",
- "fieldSchemaKey" : {
- "name" : "timestamp_type",
- "version" : "0.0.1"
- },
- "optional" : false
- }
- } ]
- },
- "outputFields" : {
- "entry" : [ {
- "key" : "amount",
- "value" : {
- "key" : "amount",
- "fieldSchemaKey" : {
- "name" : "price_type",
- "version" : "0.0.1"
- },
- "optional" : false
- }
- }, {
- "key" : "assistant_ID",
- "value" : {
- "key" : "assistant_ID",
- "fieldSchemaKey" : {
- "name" : "assistant_ID_type",
- "version" : "0.0.1"
- },
- "optional" : false
- }
- }, {
- "key" : "authorised",
- "value" : {
- "key" : "authorised",
- "fieldSchemaKey" : {
- "name" : "authorised_type",
- "version" : "0.0.1"
- },
- "optional" : false
- }
- }, {
- "key" : "branch_ID",
- "value" : {
- "key" : "branch_ID",
- "fieldSchemaKey" : {
- "name" : "branch_ID_type",
- "version" : "0.0.1"
- },
- "optional" : false
- }
- }, {
- "key" : "item_ID",
- "value" : {
- "key" : "item_ID",
- "fieldSchemaKey" : {
- "name" : "item_ID_type",
- "version" : "0.0.1"
- },
- "optional" : false
- }
- }, {
- "key" : "message",
- "value" : {
- "key" : "message",
- "fieldSchemaKey" : {
- "name" : "message_type",
- "version" : "0.0.1"
- },
- "optional" : true
- }
- }, {
- "key" : "notes",
- "value" : {
- "key" : "notes",
- "fieldSchemaKey" : {
- "name" : "notes_type",
- "version" : "0.0.1"
- },
- "optional" : true
- }
- }, {
- "key" : "quantity",
- "value" : {
- "key" : "quantity",
- "fieldSchemaKey" : {
- "name" : "quantity_type",
- "version" : "0.0.1"
- },
- "optional" : false
- }
- }, {
- "key" : "sale_ID",
- "value" : {
- "key" : "sale_ID",
- "fieldSchemaKey" : {
- "name" : "sale_ID_type",
- "version" : "0.0.1"
- },
- "optional" : false
- }
- }, {
- "key" : "time",
- "value" : {
- "key" : "time",
- "fieldSchemaKey" : {
- "name" : "timestamp_type",
- "version" : "0.0.1"
- },
- "optional" : false
- }
- } ]
- },
- "taskParameters" : {
- "entry" : [ ]
- },
- "contextAlbumReference" : [ ],
- "taskLogic" : {
- "key" : "TaskLogic",
- "logicFlavour" : "MVEL",
- "logic" : "/*\n * ============LICENSE_START=======================================================\n * Copyright (C) 2016-2018 Ericsson. All rights reserved.\n * Modifications Copyright (C) 2019 Nordix Foundation.\n * ================================================================================\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n * SPDX-License-Identifier: Apache-2.0\n * ============LICENSE_END=========================================================\n */\nimport java.util.Date;\nimport java.util.Calendar;\nimport java.util.TimeZone;\nimport java.text.SimpleDateFormat;\n\nlogger.info(\"Task Execution: '\"+subject.id+\"'. Input Fields: '\"+inFields+\"'\");\n\noutFields.put(\"amount\" , inFields.get(\"amount\"));\noutFields.put(\"assistant_ID\", inFields.get(\"assistant_ID\"));\noutFields.put(\"notes\" , inFields.get(\"notes\"));\noutFields.put(\"quantity\" , inFields.get(\"quantity\"));\noutFields.put(\"branch_ID\" , inFields.get(\"branch_ID\"));\noutFields.put(\"item_ID\" , inFields.get(\"item_ID\"));\noutFields.put(\"time\" , inFields.get(\"time\"));\noutFields.put(\"sale_ID\" , inFields.get(\"sale_ID\"));\n\nitem_id = inFields.get(\"item_ID\");\n\n//The events used later to test this task use GMT timezone!\ngmt = TimeZone.getTimeZone(\"GMT\");\ntimenow = Calendar.getInstance(gmt);\ndf = new SimpleDateFormat(\"HH:mm:ss z\");\ndf.setTimeZone(gmt);\ntimenow.setTimeInMillis(inFields.get(\"time\"));\n\nmidnight = timenow.clone();\nmidnight.set(\n timenow.get(Calendar.YEAR),timenow.get(Calendar.MONTH),\n timenow.get(Calendar.DATE),0,0,0);\neleven30 = timenow.clone();\neleven30.set(\n timenow.get(Calendar.YEAR),timenow.get(Calendar.MONTH),\n timenow.get(Calendar.DATE),11,30,0);\n\nitemisalcohol = false;\nif(item_id != null && item_id >=1000 && item_id < 2000)\n itemisalcohol = true;\n\nif( itemisalcohol\n && timenow.after(midnight) && timenow.before(eleven30)){\n outFields.put(\"authorised\", false);\n outFields.put(\"message\", \"Sale not authorised by policy task \"+subject.taskName+\n \" for time \"+df.format(timenow.getTime())+\n \". Alcohol can not be sold between \"+df.format(midnight.getTime())+\n \" and \"+df.format(eleven30.getTime()));\n return true;\n}\nelse{\n outFields.put(\"authorised\", true);\n outFields.put(\"message\", \"Sale authorised by policy task \"+subject.taskName+\n \" for time \"+df.format(timenow.getTime()));\n return true;\n}\n\n/*\nThis task checks if a sale request is for an item that is an alcoholic drink.\nIf the local time is between 00:00:00 GMT and 11:30:00 GMT then the sale is not\nauthorised. Otherwise the sale is authorised.\nIn this implementation we assume that items with item_ID value between 1000 and\n2000 are all alcoholic drinks :-)\n*/"
+ "taskMap": {
+ "entry": [
+ {
+ "key": {
+ "name": "MorningBoozeCheck",
+ "version": "0.0.1"
+ },
+ "value": {
+ "key": {
+ "name": "MorningBoozeCheck",
+ "version": "0.0.1"
+ },
+ "inputEvent": {
+ "key": {
+ "name": "SALE_INPUT",
+ "version": "0.0.1"
+ },
+ "nameSpace": "com.hyperm",
+ "source": "POS",
+ "target": "APEX",
+ "parameter": {
+ "entry": [
+ {
+ "key": "amount",
+ "value": {
+ "key": "amount",
+ "fieldSchemaKey": {
+ "name": "price_type",
+ "version": "0.0.1"
+ },
+ "optional": false
+ }
+ },
+ {
+ "key": "assistant_ID",
+ "value": {
+ "key": "assistant_ID",
+ "fieldSchemaKey": {
+ "name": "assistant_ID_type",
+ "version": "0.0.1"
+ },
+ "optional": false
+ }
+ },
+ {
+ "key": "branch_ID",
+ "value": {
+ "key": "branch_ID",
+ "fieldSchemaKey": {
+ "name": "branch_ID_type",
+ "version": "0.0.1"
+ },
+ "optional": false
+ }
+ },
+ {
+ "key": "item_ID",
+ "value": {
+ "key": "item_ID",
+ "fieldSchemaKey": {
+ "name": "item_ID_type",
+ "version": "0.0.1"
+ },
+ "optional": false
+ }
+ },
+ {
+ "key": "notes",
+ "value": {
+ "key": "notes",
+ "fieldSchemaKey": {
+ "name": "notes_type",
+ "version": "0.0.1"
+ },
+ "optional": true
+ }
+ },
+ {
+ "key": "quantity",
+ "value": {
+ "key": "quantity",
+ "fieldSchemaKey": {
+ "name": "quantity_type",
+ "version": "0.0.1"
+ },
+ "optional": false
+ }
+ },
+ {
+ "key": "sale_ID",
+ "value": {
+ "key": "sale_ID",
+ "fieldSchemaKey": {
+ "name": "sale_ID_type",
+ "version": "0.0.1"
+ },
+ "optional": false
+ }
+ },
+ {
+ "key": "time",
+ "value": {
+ "key": "time",
+ "fieldSchemaKey": {
+ "name": "timestamp_type",
+ "version": "0.0.1"
+ },
+ "optional": false
+ }
+ }
+ ]
+ }
+ },
+ "outputEvents": {
+ "entry": [
+ {
+ "key": "SALE_AUTH",
+ "value": {
+ "key": {
+ "name": "SALE_AUTH",
+ "version": "0.0.1"
+ },
+ "nameSpace": "com.hyperm",
+ "source": "APEX",
+ "target": "POS",
+ "parameter": {
+ "entry": [
+ {
+ "key": "amount",
+ "value": {
+ "key": "amount",
+ "fieldSchemaKey": {
+ "name": "price_type",
+ "version": "0.0.1"
+ },
+ "optional": false
+ }
+ },
+ {
+ "key": "assistant_ID",
+ "value": {
+ "key": "assistant_ID",
+ "fieldSchemaKey": {
+ "name": "assistant_ID_type",
+ "version": "0.0.1"
+ },
+ "optional": false
+ }
+ },
+ {
+ "key": "authorised",
+ "value": {
+ "key": "authorised",
+ "fieldSchemaKey": {
+ "name": "authorised_type",
+ "version": "0.0.1"
+ },
+ "optional": false
+ }
+ },
+ {
+ "key": "branch_ID",
+ "value": {
+ "key": "branch_ID",
+ "fieldSchemaKey": {
+ "name": "branch_ID_type",
+ "version": "0.0.1"
+ },
+ "optional": false
+ }
+ },
+ {
+ "key": "item_ID",
+ "value": {
+ "key": "item_ID",
+ "fieldSchemaKey": {
+ "name": "item_ID_type",
+ "version": "0.0.1"
+ },
+ "optional": false
+ }
+ },
+ {
+ "key": "message",
+ "value": {
+ "key": "message",
+ "fieldSchemaKey": {
+ "name": "message_type",
+ "version": "0.0.1"
+ },
+ "optional": true
+ }
+ },
+ {
+ "key": "notes",
+ "value": {
+ "key": "notes",
+ "fieldSchemaKey": {
+ "name": "notes_type",
+ "version": "0.0.1"
+ },
+ "optional": true
+ }
+ },
+ {
+ "key": "quantity",
+ "value": {
+ "key": "quantity",
+ "fieldSchemaKey": {
+ "name": "quantity_type",
+ "version": "0.0.1"
+ },
+ "optional": false
+ }
+ },
+ {
+ "key": "sale_ID",
+ "value": {
+ "key": "sale_ID",
+ "fieldSchemaKey": {
+ "name": "sale_ID_type",
+ "version": "0.0.1"
+ },
+ "optional": false
+ }
+ },
+ {
+ "key": "time",
+ "value": {
+ "key": "time",
+ "fieldSchemaKey": {
+ "name": "timestamp_type",
+ "version": "0.0.1"
+ },
+ "optional": false
+ }
+ }
+ ]
+ }
+ }
+ }
+ ]
+ },
+ "inputFields": {
+ "entry": [
+ {
+ "key": "amount",
+ "value": {
+ "key": "amount",
+ "fieldSchemaKey": {
+ "name": "price_type",
+ "version": "0.0.1"
+ },
+ "optional": false
+ }
+ },
+ {
+ "key": "assistant_ID",
+ "value": {
+ "key": "assistant_ID",
+ "fieldSchemaKey": {
+ "name": "assistant_ID_type",
+ "version": "0.0.1"
+ },
+ "optional": false
+ }
+ },
+ {
+ "key": "branch_ID",
+ "value": {
+ "key": "branch_ID",
+ "fieldSchemaKey": {
+ "name": "branch_ID_type",
+ "version": "0.0.1"
+ },
+ "optional": false
+ }
+ },
+ {
+ "key": "item_ID",
+ "value": {
+ "key": "item_ID",
+ "fieldSchemaKey": {
+ "name": "item_ID_type",
+ "version": "0.0.1"
+ },
+ "optional": false
+ }
+ },
+ {
+ "key": "notes",
+ "value": {
+ "key": "notes",
+ "fieldSchemaKey": {
+ "name": "notes_type",
+ "version": "0.0.1"
+ },
+ "optional": true
+ }
+ },
+ {
+ "key": "quantity",
+ "value": {
+ "key": "quantity",
+ "fieldSchemaKey": {
+ "name": "quantity_type",
+ "version": "0.0.1"
+ },
+ "optional": false
+ }
+ },
+ {
+ "key": "sale_ID",
+ "value": {
+ "key": "sale_ID",
+ "fieldSchemaKey": {
+ "name": "sale_ID_type",
+ "version": "0.0.1"
+ },
+ "optional": false
+ }
+ },
+ {
+ "key": "time",
+ "value": {
+ "key": "time",
+ "fieldSchemaKey": {
+ "name": "timestamp_type",
+ "version": "0.0.1"
+ },
+ "optional": false
+ }
}
- }
- } ]
- }
+ ]
+ },
+ "outputFields": {
+ "entry": [
+ {
+ "key": "amount",
+ "value": {
+ "key": "amount",
+ "fieldSchemaKey": {
+ "name": "price_type",
+ "version": "0.0.1"
+ },
+ "optional": false
+ }
+ },
+ {
+ "key": "assistant_ID",
+ "value": {
+ "key": "assistant_ID",
+ "fieldSchemaKey": {
+ "name": "assistant_ID_type",
+ "version": "0.0.1"
+ },
+ "optional": false
+ }
+ },
+ {
+ "key": "authorised",
+ "value": {
+ "key": "authorised",
+ "fieldSchemaKey": {
+ "name": "authorised_type",
+ "version": "0.0.1"
+ },
+ "optional": false
+ }
+ },
+ {
+ "key": "branch_ID",
+ "value": {
+ "key": "branch_ID",
+ "fieldSchemaKey": {
+ "name": "branch_ID_type",
+ "version": "0.0.1"
+ },
+ "optional": false
+ }
+ },
+ {
+ "key": "item_ID",
+ "value": {
+ "key": "item_ID",
+ "fieldSchemaKey": {
+ "name": "item_ID_type",
+ "version": "0.0.1"
+ },
+ "optional": false
+ }
+ },
+ {
+ "key": "message",
+ "value": {
+ "key": "message",
+ "fieldSchemaKey": {
+ "name": "message_type",
+ "version": "0.0.1"
+ },
+ "optional": true
+ }
+ },
+ {
+ "key": "notes",
+ "value": {
+ "key": "notes",
+ "fieldSchemaKey": {
+ "name": "notes_type",
+ "version": "0.0.1"
+ },
+ "optional": true
+ }
+ },
+ {
+ "key": "quantity",
+ "value": {
+ "key": "quantity",
+ "fieldSchemaKey": {
+ "name": "quantity_type",
+ "version": "0.0.1"
+ },
+ "optional": false
+ }
+ },
+ {
+ "key": "sale_ID",
+ "value": {
+ "key": "sale_ID",
+ "fieldSchemaKey": {
+ "name": "sale_ID_type",
+ "version": "0.0.1"
+ },
+ "optional": false
+ }
+ },
+ {
+ "key": "time",
+ "value": {
+ "key": "time",
+ "fieldSchemaKey": {
+ "name": "timestamp_type",
+ "version": "0.0.1"
+ },
+ "optional": false
+ }
+ }
+ ]
+ },
+ "taskParameters": {
+ "entry": []
+ },
+ "contextAlbumReference": [],
+ "taskLogic": {
+ "key": "TaskLogic",
+ "logicFlavour": "MVEL",
+ "logic": "/*\n * ============LICENSE_START=======================================================\n * Copyright (C) 2016-2018 Ericsson. All rights reserved.\n * Modifications Copyright (C) 2019 Nordix Foundation.\n * ================================================================================\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n * SPDX-License-Identifier: Apache-2.0\n * ============LICENSE_END=========================================================\n */\nimport java.util.Date;\nimport java.util.Calendar;\nimport java.util.TimeZone;\nimport java.text.SimpleDateFormat;\n\nlogger.info(\"Task Execution: '\"+subject.id+\"'. Input Fields: '\"+inFields+\"'\");\n\noutFields.put(\"amount\" , inFields.get(\"amount\"));\noutFields.put(\"assistant_ID\", inFields.get(\"assistant_ID\"));\noutFields.put(\"notes\" , inFields.get(\"notes\"));\noutFields.put(\"quantity\" , inFields.get(\"quantity\"));\noutFields.put(\"branch_ID\" , inFields.get(\"branch_ID\"));\noutFields.put(\"item_ID\" , inFields.get(\"item_ID\"));\noutFields.put(\"time\" , inFields.get(\"time\"));\noutFields.put(\"sale_ID\" , inFields.get(\"sale_ID\"));\n\nitem_id = inFields.get(\"item_ID\");\n\n//The events used later to test this task use GMT timezone!\ngmt = TimeZone.getTimeZone(\"GMT\");\ntimenow = Calendar.getInstance(gmt);\ndf = new SimpleDateFormat(\"HH:mm:ss z\");\ndf.setTimeZone(gmt);\ntimenow.setTimeInMillis(inFields.get(\"time\"));\n\nmidnight = timenow.clone();\nmidnight.set(\n timenow.get(Calendar.YEAR),timenow.get(Calendar.MONTH),\n timenow.get(Calendar.DATE),0,0,0);\neleven30 = timenow.clone();\neleven30.set(\n timenow.get(Calendar.YEAR),timenow.get(Calendar.MONTH),\n timenow.get(Calendar.DATE),11,30,0);\n\nitemisalcohol = false;\nif(item_id != null && item_id >=1000 && item_id < 2000)\n itemisalcohol = true;\n\nif( itemisalcohol\n && timenow.after(midnight) && timenow.before(eleven30)){\n outFields.put(\"authorised\", false);\n outFields.put(\"message\", \"Sale not authorised by policy task \"+subject.taskName+\n \" for time \"+df.format(timenow.getTime())+\n \". Alcohol can not be sold between \"+df.format(midnight.getTime())+\n \" and \"+df.format(eleven30.getTime()));\n return true;\n}\nelse{\n outFields.put(\"authorised\", true);\n outFields.put(\"message\", \"Sale authorised by policy task \"+subject.taskName+\n \" for time \"+df.format(timenow.getTime()));\n return true;\n}\n\n/*\nThis task checks if a sale request is for an item that is an alcoholic drink.\nIf the local time is between 00:00:00 GMT and 11:30:00 GMT then the sale is not\nauthorised. Otherwise the sale is authorised.\nIn this implementation we assume that items with item_ID value between 1000 and\n2000 are all alcoholic drinks :-)\n*/"
+ }
+ }
+ }
+ ]
+ }
+ },
+ "events": {
+ "key": {
+ "name": "MyFirstPolicyModel_Events",
+ "version": "0.0.1"
},
- "events" : {
- "key" : {
- "name" : "MyFirstPolicyModel_Events",
- "version" : "0.0.1"
- },
- "eventMap" : {
- "entry" : [ {
- "key" : {
- "name" : "SALE_AUTH",
- "version" : "0.0.1"
- },
- "value" : {
- "key" : {
- "name" : "SALE_AUTH",
- "version" : "0.0.1"
- },
- "nameSpace" : "com.hyperm",
- "source" : "APEX",
- "target" : "POS",
- "parameter" : {
- "entry" : [ {
- "key" : "amount",
- "value" : {
- "key" : "amount",
- "fieldSchemaKey" : {
- "name" : "price_type",
- "version" : "0.0.1"
- },
- "optional" : false
- }
- }, {
- "key" : "assistant_ID",
- "value" : {
- "key" : "assistant_ID",
- "fieldSchemaKey" : {
- "name" : "assistant_ID_type",
- "version" : "0.0.1"
- },
- "optional" : false
- }
- }, {
- "key" : "authorised",
- "value" : {
- "key" : "authorised",
- "fieldSchemaKey" : {
- "name" : "authorised_type",
- "version" : "0.0.1"
- },
- "optional" : false
- }
- }, {
- "key" : "branch_ID",
- "value" : {
- "key" : "branch_ID",
- "fieldSchemaKey" : {
- "name" : "branch_ID_type",
- "version" : "0.0.1"
- },
- "optional" : false
- }
- }, {
- "key" : "item_ID",
- "value" : {
- "key" : "item_ID",
- "fieldSchemaKey" : {
- "name" : "item_ID_type",
- "version" : "0.0.1"
- },
- "optional" : false
- }
- }, {
- "key" : "message",
- "value" : {
- "key" : "message",
- "fieldSchemaKey" : {
- "name" : "message_type",
- "version" : "0.0.1"
- },
- "optional" : true
- }
- }, {
- "key" : "notes",
- "value" : {
- "key" : "notes",
- "fieldSchemaKey" : {
- "name" : "notes_type",
- "version" : "0.0.1"
- },
- "optional" : true
- }
- }, {
- "key" : "quantity",
- "value" : {
- "key" : "quantity",
- "fieldSchemaKey" : {
- "name" : "quantity_type",
- "version" : "0.0.1"
- },
- "optional" : false
- }
- }, {
- "key" : "sale_ID",
- "value" : {
- "key" : "sale_ID",
- "fieldSchemaKey" : {
- "name" : "sale_ID_type",
- "version" : "0.0.1"
- },
- "optional" : false
- }
- }, {
- "key" : "time",
- "value" : {
- "key" : "time",
- "fieldSchemaKey" : {
- "name" : "timestamp_type",
- "version" : "0.0.1"
- },
- "optional" : false
- }
- } ]
+ "eventMap": {
+ "entry": [
+ {
+ "key": {
+ "name": "SALE_AUTH",
+ "version": "0.0.1"
+ },
+ "value": {
+ "key": {
+ "name": "SALE_AUTH",
+ "version": "0.0.1"
+ },
+ "nameSpace": "com.hyperm",
+ "source": "APEX",
+ "target": "POS",
+ "parameter": {
+ "entry": [
+ {
+ "key": "amount",
+ "value": {
+ "key": "amount",
+ "fieldSchemaKey": {
+ "name": "price_type",
+ "version": "0.0.1"
+ },
+ "optional": false
+ }
+ },
+ {
+ "key": "assistant_ID",
+ "value": {
+ "key": "assistant_ID",
+ "fieldSchemaKey": {
+ "name": "assistant_ID_type",
+ "version": "0.0.1"
+ },
+ "optional": false
+ }
+ },
+ {
+ "key": "authorised",
+ "value": {
+ "key": "authorised",
+ "fieldSchemaKey": {
+ "name": "authorised_type",
+ "version": "0.0.1"
+ },
+ "optional": false
+ }
+ },
+ {
+ "key": "branch_ID",
+ "value": {
+ "key": "branch_ID",
+ "fieldSchemaKey": {
+ "name": "branch_ID_type",
+ "version": "0.0.1"
+ },
+ "optional": false
+ }
+ },
+ {
+ "key": "item_ID",
+ "value": {
+ "key": "item_ID",
+ "fieldSchemaKey": {
+ "name": "item_ID_type",
+ "version": "0.0.1"
+ },
+ "optional": false
+ }
+ },
+ {
+ "key": "message",
+ "value": {
+ "key": "message",
+ "fieldSchemaKey": {
+ "name": "message_type",
+ "version": "0.0.1"
+ },
+ "optional": true
+ }
+ },
+ {
+ "key": "notes",
+ "value": {
+ "key": "notes",
+ "fieldSchemaKey": {
+ "name": "notes_type",
+ "version": "0.0.1"
+ },
+ "optional": true
+ }
+ },
+ {
+ "key": "quantity",
+ "value": {
+ "key": "quantity",
+ "fieldSchemaKey": {
+ "name": "quantity_type",
+ "version": "0.0.1"
+ },
+ "optional": false
+ }
+ },
+ {
+ "key": "sale_ID",
+ "value": {
+ "key": "sale_ID",
+ "fieldSchemaKey": {
+ "name": "sale_ID_type",
+ "version": "0.0.1"
+ },
+ "optional": false
+ }
+ },
+ {
+ "key": "time",
+ "value": {
+ "key": "time",
+ "fieldSchemaKey": {
+ "name": "timestamp_type",
+ "version": "0.0.1"
+ },
+ "optional": false
+ }
}
- }
- }, {
- "key" : {
- "name" : "SALE_INPUT",
- "version" : "0.0.1"
- },
- "value" : {
- "key" : {
- "name" : "SALE_INPUT",
- "version" : "0.0.1"
- },
- "nameSpace" : "com.hyperm",
- "source" : "POS",
- "target" : "APEX",
- "parameter" : {
- "entry" : [ {
- "key" : "amount",
- "value" : {
- "key" : "amount",
- "fieldSchemaKey" : {
- "name" : "price_type",
- "version" : "0.0.1"
- },
- "optional" : false
- }
- }, {
- "key" : "assistant_ID",
- "value" : {
- "key" : "assistant_ID",
- "fieldSchemaKey" : {
- "name" : "assistant_ID_type",
- "version" : "0.0.1"
- },
- "optional" : false
- }
- }, {
- "key" : "branch_ID",
- "value" : {
- "key" : "branch_ID",
- "fieldSchemaKey" : {
- "name" : "branch_ID_type",
- "version" : "0.0.1"
- },
- "optional" : false
- }
- }, {
- "key" : "item_ID",
- "value" : {
- "key" : "item_ID",
- "fieldSchemaKey" : {
- "name" : "item_ID_type",
- "version" : "0.0.1"
- },
- "optional" : false
- }
- }, {
- "key" : "notes",
- "value" : {
- "key" : "notes",
- "fieldSchemaKey" : {
- "name" : "notes_type",
- "version" : "0.0.1"
- },
- "optional" : true
- }
- }, {
- "key" : "quantity",
- "value" : {
- "key" : "quantity",
- "fieldSchemaKey" : {
- "name" : "quantity_type",
- "version" : "0.0.1"
- },
- "optional" : false
- }
- }, {
- "key" : "sale_ID",
- "value" : {
- "key" : "sale_ID",
- "fieldSchemaKey" : {
- "name" : "sale_ID_type",
- "version" : "0.0.1"
- },
- "optional" : false
- }
- }, {
- "key" : "time",
- "value" : {
- "key" : "time",
- "fieldSchemaKey" : {
- "name" : "timestamp_type",
- "version" : "0.0.1"
- },
- "optional" : false
- }
- } ]
+ ]
+ }
+ }
+ },
+ {
+ "key": {
+ "name": "SALE_INPUT",
+ "version": "0.0.1"
+ },
+ "value": {
+ "key": {
+ "name": "SALE_INPUT",
+ "version": "0.0.1"
+ },
+ "nameSpace": "com.hyperm",
+ "source": "POS",
+ "target": "APEX",
+ "parameter": {
+ "entry": [
+ {
+ "key": "amount",
+ "value": {
+ "key": "amount",
+ "fieldSchemaKey": {
+ "name": "price_type",
+ "version": "0.0.1"
+ },
+ "optional": false
+ }
+ },
+ {
+ "key": "assistant_ID",
+ "value": {
+ "key": "assistant_ID",
+ "fieldSchemaKey": {
+ "name": "assistant_ID_type",
+ "version": "0.0.1"
+ },
+ "optional": false
+ }
+ },
+ {
+ "key": "branch_ID",
+ "value": {
+ "key": "branch_ID",
+ "fieldSchemaKey": {
+ "name": "branch_ID_type",
+ "version": "0.0.1"
+ },
+ "optional": false
+ }
+ },
+ {
+ "key": "item_ID",
+ "value": {
+ "key": "item_ID",
+ "fieldSchemaKey": {
+ "name": "item_ID_type",
+ "version": "0.0.1"
+ },
+ "optional": false
+ }
+ },
+ {
+ "key": "notes",
+ "value": {
+ "key": "notes",
+ "fieldSchemaKey": {
+ "name": "notes_type",
+ "version": "0.0.1"
+ },
+ "optional": true
+ }
+ },
+ {
+ "key": "quantity",
+ "value": {
+ "key": "quantity",
+ "fieldSchemaKey": {
+ "name": "quantity_type",
+ "version": "0.0.1"
+ },
+ "optional": false
+ }
+ },
+ {
+ "key": "sale_ID",
+ "value": {
+ "key": "sale_ID",
+ "fieldSchemaKey": {
+ "name": "sale_ID_type",
+ "version": "0.0.1"
+ },
+ "optional": false
+ }
+ },
+ {
+ "key": "time",
+ "value": {
+ "key": "time",
+ "fieldSchemaKey": {
+ "name": "timestamp_type",
+ "version": "0.0.1"
+ },
+ "optional": false
+ }
}
- }
- } ]
- }
+ ]
+ }
+ }
+ }
+ ]
+ }
+ },
+ "schemas": {
+ "key": {
+ "name": "MyFirstPolicyModel_Schemas",
+ "version": "0.0.1"
},
- "schemas" : {
- "key" : {
- "name" : "MyFirstPolicyModel_Schemas",
- "version" : "0.0.1"
- },
- "schemas" : {
- "entry" : [ {
- "key" : {
- "name" : "assistant_ID_type",
- "version" : "0.0.1"
- },
- "value" : {
- "key" : {
- "name" : "assistant_ID_type",
- "version" : "0.0.1"
- },
- "schemaFlavour" : "Java",
- "schemaDefinition" : "java.lang.Long"
- }
- }, {
- "key" : {
- "name" : "authorised_type",
- "version" : "0.0.1"
- },
- "value" : {
- "key" : {
- "name" : "authorised_type",
- "version" : "0.0.1"
- },
- "schemaFlavour" : "Java",
- "schemaDefinition" : "java.lang.Boolean"
- }
- }, {
- "key" : {
- "name" : "branch_ID_type",
- "version" : "0.0.1"
- },
- "value" : {
- "key" : {
- "name" : "branch_ID_type",
- "version" : "0.0.1"
- },
- "schemaFlavour" : "Java",
- "schemaDefinition" : "java.lang.Long"
- }
- }, {
- "key" : {
- "name" : "item_ID_type",
- "version" : "0.0.1"
- },
- "value" : {
- "key" : {
- "name" : "item_ID_type",
- "version" : "0.0.1"
- },
- "schemaFlavour" : "Java",
- "schemaDefinition" : "java.lang.Long"
- }
- }, {
- "key" : {
- "name" : "message_type",
- "version" : "0.0.1"
- },
- "value" : {
- "key" : {
- "name" : "message_type",
- "version" : "0.0.1"
- },
- "schemaFlavour" : "Java",
- "schemaDefinition" : "java.lang.String"
- }
- }, {
- "key" : {
- "name" : "notes_type",
- "version" : "0.0.1"
- },
- "value" : {
- "key" : {
- "name" : "notes_type",
- "version" : "0.0.1"
- },
- "schemaFlavour" : "Java",
- "schemaDefinition" : "java.lang.String"
- }
- }, {
- "key" : {
- "name" : "price_type",
- "version" : "0.0.1"
- },
- "value" : {
- "key" : {
- "name" : "price_type",
- "version" : "0.0.1"
- },
- "schemaFlavour" : "Java",
- "schemaDefinition" : "java.lang.Long"
- }
- }, {
- "key" : {
- "name" : "quantity_type",
- "version" : "0.0.1"
- },
- "value" : {
- "key" : {
- "name" : "quantity_type",
- "version" : "0.0.1"
- },
- "schemaFlavour" : "Java",
- "schemaDefinition" : "java.lang.Integer"
- }
- }, {
- "key" : {
- "name" : "sale_ID_type",
- "version" : "0.0.1"
- },
- "value" : {
- "key" : {
- "name" : "sale_ID_type",
- "version" : "0.0.1"
- },
- "schemaFlavour" : "Java",
- "schemaDefinition" : "java.lang.Long"
- }
- }, {
- "key" : {
- "name" : "timestamp_type",
- "version" : "0.0.1"
- },
- "value" : {
- "key" : {
- "name" : "timestamp_type",
- "version" : "0.0.1"
- },
- "schemaFlavour" : "Java",
- "schemaDefinition" : "java.lang.Long"
- }
- } ]
- }
+ "schemas": {
+ "entry": [
+ {
+ "key": {
+ "name": "assistant_ID_type",
+ "version": "0.0.1"
+ },
+ "value": {
+ "key": {
+ "name": "assistant_ID_type",
+ "version": "0.0.1"
+ },
+ "schemaFlavour": "Java",
+ "schemaDefinition": "java.lang.Long"
+ }
+ },
+ {
+ "key": {
+ "name": "authorised_type",
+ "version": "0.0.1"
+ },
+ "value": {
+ "key": {
+ "name": "authorised_type",
+ "version": "0.0.1"
+ },
+ "schemaFlavour": "Java",
+ "schemaDefinition": "java.lang.Boolean"
+ }
+ },
+ {
+ "key": {
+ "name": "branch_ID_type",
+ "version": "0.0.1"
+ },
+ "value": {
+ "key": {
+ "name": "branch_ID_type",
+ "version": "0.0.1"
+ },
+ "schemaFlavour": "Java",
+ "schemaDefinition": "java.lang.Long"
+ }
+ },
+ {
+ "key": {
+ "name": "item_ID_type",
+ "version": "0.0.1"
+ },
+ "value": {
+ "key": {
+ "name": "item_ID_type",
+ "version": "0.0.1"
+ },
+ "schemaFlavour": "Java",
+ "schemaDefinition": "java.lang.Long"
+ }
+ },
+ {
+ "key": {
+ "name": "message_type",
+ "version": "0.0.1"
+ },
+ "value": {
+ "key": {
+ "name": "message_type",
+ "version": "0.0.1"
+ },
+ "schemaFlavour": "Java",
+ "schemaDefinition": "java.lang.String"
+ }
+ },
+ {
+ "key": {
+ "name": "notes_type",
+ "version": "0.0.1"
+ },
+ "value": {
+ "key": {
+ "name": "notes_type",
+ "version": "0.0.1"
+ },
+ "schemaFlavour": "Java",
+ "schemaDefinition": "java.lang.String"
+ }
+ },
+ {
+ "key": {
+ "name": "price_type",
+ "version": "0.0.1"
+ },
+ "value": {
+ "key": {
+ "name": "price_type",
+ "version": "0.0.1"
+ },
+ "schemaFlavour": "Java",
+ "schemaDefinition": "java.lang.Long"
+ }
+ },
+ {
+ "key": {
+ "name": "quantity_type",
+ "version": "0.0.1"
+ },
+ "value": {
+ "key": {
+ "name": "quantity_type",
+ "version": "0.0.1"
+ },
+ "schemaFlavour": "Java",
+ "schemaDefinition": "java.lang.Integer"
+ }
+ },
+ {
+ "key": {
+ "name": "sale_ID_type",
+ "version": "0.0.1"
+ },
+ "value": {
+ "key": {
+ "name": "sale_ID_type",
+ "version": "0.0.1"
+ },
+ "schemaFlavour": "Java",
+ "schemaDefinition": "java.lang.Long"
+ }
+ },
+ {
+ "key": {
+ "name": "timestamp_type",
+ "version": "0.0.1"
+ },
+ "value": {
+ "key": {
+ "name": "timestamp_type",
+ "version": "0.0.1"
+ },
+ "schemaFlavour": "Java",
+ "schemaDefinition": "java.lang.Long"
+ }
+ }
+ ]
}
- }
+ }
+ }
}
diff --git a/auth/cli-editor/src/test/resources/tosca/ToscaPolicyOutput_compare.json b/auth/cli-editor/src/test/resources/tosca/ToscaPolicyOutput_compare.json
index ab2ae890e..55bd95eca 100644
--- a/auth/cli-editor/src/test/resources/tosca/ToscaPolicyOutput_compare.json
+++ b/auth/cli-editor/src/test/resources/tosca/ToscaPolicyOutput_compare.json
@@ -1 +1 @@
-{"tosca_definitions_version":"tosca_simple_yaml_1_1_0","topology_template":{"policies":[{"native.sampledomain":{"type":"onap.policies.native.Apex","type_version":"1.0.0","name":"native.sampledomain","version":"1.0.0","properties":{"engineServiceParameters":{"name":"MyFirstPolicyApexEngine","version":"0.0.1","id":101,"instanceCount":4,"deploymentPort":12345,"engineParameters":{"executorParameters":{"MVEL":{"parameterClassName":"org.onap.policy.apex.plugins.executor.mvel.MvelExecutorParameters"},"JAVASCRIPT":{"parameterClassName":"org.onap.policy.apex.plugins.executor.javascript.JavascriptExecutorParameters"}}},"policy_type_impl":{"apexPolicyModel":{"key":{"name":"MyFirstPolicyModel","version":"0.0.1"},"keyInformation":{"key":{"name":"MyFirstPolicyModel_KeyInfo","version":"0.0.1"},"keyInfoMap":{"entry":[{"key":{"name":"MorningBoozeCheck","version":"0.0.1"},"value":{"key":{"name":"MorningBoozeCheck","version":"0.0.1"},"UUID":"3351b0f4-cf06-4fa2-8823-edf67bd30223","description":"This task checks if the sales request is for an item that contains alcohol. \nIf the local time is between 00:00:00 and 11:30:00 then the sale is not authorised. Otherwise the sale is authorised. \nIn this implementation we assume that all items with item_ID values between 1000 and 2000 contain alcohol :-)"}},{"key":{"name":"MyFirstPolicy","version":"0.0.1"},"value":{"key":{"name":"MyFirstPolicy","version":"0.0.1"},"UUID":"6c5e410f-489a-46ff-964e-982ce6e8b6d0","description":"This is my first Apex policy. It checks if a sale should be authorised or not."}},{"key":{"name":"MyFirstPolicyModel","version":"0.0.1"},"value":{"key":{"name":"MyFirstPolicyModel","version":"0.0.1"},"UUID":"540226fb-55ee-4f0e-a444-983a0494818e","description":"This is my first Apex Policy Model."}},{"key":{"name":"MyFirstPolicyModel_Events","version":"0.0.1"},"value":{"key":{"name":"MyFirstPolicyModel_Events","version":"0.0.1"},"UUID":"ef281318-5ac9-3ef0-8db3-8f9c4e4a81e2","description":"Generated description for concept referred to by key \"MyFirstPolicyModel_Events:0.0.1\""}},{"key":{"name":"MyFirstPolicyModel_KeyInfo","version":"0.0.1"},"value":{"key":{"name":"MyFirstPolicyModel_KeyInfo","version":"0.0.1"},"UUID":"d9248c6f-7c00-38df-8251-611463ba4065","description":"Generated description for concept referred to by key \"MyFirstPolicyModel_KeyInfo:0.0.1\""}},{"key":{"name":"MyFirstPolicyModel_Policies","version":"0.0.1"},"value":{"key":{"name":"MyFirstPolicyModel_Policies","version":"0.0.1"},"UUID":"77c01a6b-510c-3aa9-b640-b4db356aa03b","description":"Generated description for concept referred to by key \"MyFirstPolicyModel_Policies:0.0.1\""}},{"key":{"name":"MyFirstPolicyModel_Schemas","version":"0.0.1"},"value":{"key":{"name":"MyFirstPolicyModel_Schemas","version":"0.0.1"},"UUID":"d0cc3aa0-ea69-3a43-80ff-a0dbb0ebd885","description":"Generated description for concept referred to by key \"MyFirstPolicyModel_Schemas:0.0.1\""}},{"key":{"name":"MyFirstPolicyModel_Tasks","version":"0.0.1"},"value":{"key":{"name":"MyFirstPolicyModel_Tasks","version":"0.0.1"},"UUID":"b02a7e02-2cd0-39e6-b3cb-946fa83a8f08","description":"Generated description for concept referred to by key \"MyFirstPolicyModel_Tasks:0.0.1\""}},{"key":{"name":"SALE_AUTH","version":"0.0.1"},"value":{"key":{"name":"SALE_AUTH","version":"0.0.1"},"UUID":"c4500941-3f98-4080-a9cc-5b9753ed050b","description":"An event emitted by the Policy to indicate whether the sale of an item has been authorised"}},{"key":{"name":"SALE_INPUT","version":"0.0.1"},"value":{"key":{"name":"SALE_INPUT","version":"0.0.1"},"UUID":"4f04aa98-e917-4f4a-882a-c75ba5a99374","description":"An event raised by the PoS system each time an item is scanned for purchase"}},{"key":{"name":"assistant_ID_type","version":"0.0.1"},"value":{"key":{"name":"assistant_ID_type","version":"0.0.1"},"UUID":"36df4c71-9616-4206-8b53-976a5cd4bd87","description":"A type for 'assistant_ID' values"}},{"key":{"name":"authorised_type","version":"0.0.1"},"value":{"key":{"name":"authorised_type","version":"0.0.1"},"UUID":"d48b619e-d00d-4008-b884-02d76ea4350b","description":"A type for 'authorised' values"}},{"key":{"name":"branch_ID_type","version":"0.0.1"},"value":{"key":{"name":"branch_ID_type","version":"0.0.1"},"UUID":"6468845f-4122-4128-8e49-0f52c26078b5","description":"A type for 'branch_ID' values"}},{"key":{"name":"item_ID_type","version":"0.0.1"},"value":{"key":{"name":"item_ID_type","version":"0.0.1"},"UUID":"4f227ff1-aee0-453a-b6b6-9a4b2e0da932","description":"A type for 'item_ID' values"}},{"key":{"name":"message_type","version":"0.0.1"},"value":{"key":{"name":"message_type","version":"0.0.1"},"UUID":"ad1431bb-3155-4e73-b5a3-b89bee498749","description":"A type for 'message' values"}},{"key":{"name":"notes_type","version":"0.0.1"},"value":{"key":{"name":"notes_type","version":"0.0.1"},"UUID":"eecfde90-896c-4343-8f9c-2603ced94e2d","description":"A type for 'notes' values"}},{"key":{"name":"price_type","version":"0.0.1"},"value":{"key":{"name":"price_type","version":"0.0.1"},"UUID":"52c2fc45-fd8c-463c-bd6f-d91b0554aea7","description":"A type for 'amount'/'price' values"}},{"key":{"name":"quantity_type","version":"0.0.1"},"value":{"key":{"name":"quantity_type","version":"0.0.1"},"UUID":"ac3d9842-80af-4a98-951c-bd79a431c613","description":"A type for 'quantity' values"}},{"key":{"name":"sale_ID_type","version":"0.0.1"},"value":{"key":{"name":"sale_ID_type","version":"0.0.1"},"UUID":"cca47d74-7754-4a61-b163-ca31f66b157b","description":"A type for 'sale_ID' values"}},{"key":{"name":"timestamp_type","version":"0.0.1"},"value":{"key":{"name":"timestamp_type","version":"0.0.1"},"UUID":"fd594e88-411d-4a94-b2be-697b3a0d7adf","description":"A type for 'time' values"}}]}},"policies":{"key":{"name":"MyFirstPolicyModel_Policies","version":"0.0.1"},"policyMap":{"entry":[{"key":{"name":"MyFirstPolicy","version":"0.0.1"},"value":{"policyKey":{"name":"MyFirstPolicy","version":"0.0.1"},"template":"FREEFORM","state":{"entry":[{"key":"BoozeAuthDecide","value":{"stateKey":{"parentKeyName":"MyFirstPolicy","parentKeyVersion":"0.0.1","parentLocalName":"NULL","localName":"BoozeAuthDecide"},"trigger":{"name":"SALE_INPUT","version":"0.0.1"},"stateOutputs":{"entry":[{"key":"MorningBoozeCheck_Output_Direct","value":{"key":{"parentKeyName":"MyFirstPolicy","parentKeyVersion":"0.0.1","parentLocalName":"BoozeAuthDecide","localName":"MorningBoozeCheck_Output_Direct"},"outgoingEvent":{"name":"SALE_AUTH","version":"0.0.1"},"nextState":{"parentKeyName":"NULL","parentKeyVersion":"0.0.0","parentLocalName":"NULL","localName":"NULL"}}}]},"contextAlbumReference":[],"taskSelectionLogic":{"key":"NULL","logicFlavour":"UNDEFINED","logic":""},"stateFinalizerLogicMap":{"entry":[]},"defaultTask":{"name":"MorningBoozeCheck","version":"0.0.1"},"taskReferences":{"entry":[{"key":{"name":"MorningBoozeCheck","version":"0.0.1"},"value":{"key":{"parentKeyName":"MyFirstPolicy","parentKeyVersion":"0.0.1","parentLocalName":"BoozeAuthDecide","localName":"MorningBoozeCheck"},"outputType":"DIRECT","output":{"parentKeyName":"MyFirstPolicy","parentKeyVersion":"0.0.1","parentLocalName":"BoozeAuthDecide","localName":"MorningBoozeCheck_Output_Direct"}}}]}}}]},"firstState":"BoozeAuthDecide"}}]}},"tasks":{"key":{"name":"MyFirstPolicyModel_Tasks","version":"0.0.1"},"taskMap":{"entry":[{"key":{"name":"MorningBoozeCheck","version":"0.0.1"},"value":{"key":{"name":"MorningBoozeCheck","version":"0.0.1"},"inputFields":{"entry":[{"key":"amount","value":{"key":"amount","fieldSchemaKey":{"name":"price_type","version":"0.0.1"},"optional":false}},{"key":"assistant_ID","value":{"key":"assistant_ID","fieldSchemaKey":{"name":"assistant_ID_type","version":"0.0.1"},"optional":false}},{"key":"branch_ID","value":{"key":"branch_ID","fieldSchemaKey":{"name":"branch_ID_type","version":"0.0.1"},"optional":false}},{"key":"item_ID","value":{"key":"item_ID","fieldSchemaKey":{"name":"item_ID_type","version":"0.0.1"},"optional":false}},{"key":"notes","value":{"key":"notes","fieldSchemaKey":{"name":"notes_type","version":"0.0.1"},"optional":true}},{"key":"quantity","value":{"key":"quantity","fieldSchemaKey":{"name":"quantity_type","version":"0.0.1"},"optional":false}},{"key":"sale_ID","value":{"key":"sale_ID","fieldSchemaKey":{"name":"sale_ID_type","version":"0.0.1"},"optional":false}},{"key":"time","value":{"key":"time","fieldSchemaKey":{"name":"timestamp_type","version":"0.0.1"},"optional":false}}]},"outputFields":{"entry":[{"key":"amount","value":{"key":"amount","fieldSchemaKey":{"name":"price_type","version":"0.0.1"},"optional":false}},{"key":"assistant_ID","value":{"key":"assistant_ID","fieldSchemaKey":{"name":"assistant_ID_type","version":"0.0.1"},"optional":false}},{"key":"authorised","value":{"key":"authorised","fieldSchemaKey":{"name":"authorised_type","version":"0.0.1"},"optional":false}},{"key":"branch_ID","value":{"key":"branch_ID","fieldSchemaKey":{"name":"branch_ID_type","version":"0.0.1"},"optional":false}},{"key":"item_ID","value":{"key":"item_ID","fieldSchemaKey":{"name":"item_ID_type","version":"0.0.1"},"optional":false}},{"key":"message","value":{"key":"message","fieldSchemaKey":{"name":"message_type","version":"0.0.1"},"optional":true}},{"key":"notes","value":{"key":"notes","fieldSchemaKey":{"name":"notes_type","version":"0.0.1"},"optional":true}},{"key":"quantity","value":{"key":"quantity","fieldSchemaKey":{"name":"quantity_type","version":"0.0.1"},"optional":false}},{"key":"sale_ID","value":{"key":"sale_ID","fieldSchemaKey":{"name":"sale_ID_type","version":"0.0.1"},"optional":false}},{"key":"time","value":{"key":"time","fieldSchemaKey":{"name":"timestamp_type","version":"0.0.1"},"optional":false}}]},"taskParameters":{"entry":[]},"contextAlbumReference":[],"taskLogic":{"key":"TaskLogic","logicFlavour":"MVEL","logic":"/*\n * ============LICENSE_START=======================================================\n * Copyright (C) 2016-2018 Ericsson. All rights reserved.\n * Modifications Copyright (C) 2019 Nordix Foundation.\n * ================================================================================\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n * SPDX-License-Identifier: Apache-2.0\n * ============LICENSE_END=========================================================\n */\nimport java.util.Date;\nimport java.util.Calendar;\nimport java.util.TimeZone;\nimport java.text.SimpleDateFormat;\n\nlogger.info(\"Task Execution: '\"+subject.id+\"'. Input Fields: '\"+inFields+\"'\");\n\noutFields.put(\"amount\" , inFields.get(\"amount\"));\noutFields.put(\"assistant_ID\", inFields.get(\"assistant_ID\"));\noutFields.put(\"notes\" , inFields.get(\"notes\"));\noutFields.put(\"quantity\" , inFields.get(\"quantity\"));\noutFields.put(\"branch_ID\" , inFields.get(\"branch_ID\"));\noutFields.put(\"item_ID\" , inFields.get(\"item_ID\"));\noutFields.put(\"time\" , inFields.get(\"time\"));\noutFields.put(\"sale_ID\" , inFields.get(\"sale_ID\"));\n\nitem_id = inFields.get(\"item_ID\");\n\n//The events used later to test this task use GMT timezone!\ngmt = TimeZone.getTimeZone(\"GMT\");\ntimenow = Calendar.getInstance(gmt);\ndf = new SimpleDateFormat(\"HH:mm:ss z\");\ndf.setTimeZone(gmt);\ntimenow.setTimeInMillis(inFields.get(\"time\"));\n\nmidnight = timenow.clone();\nmidnight.set(\n timenow.get(Calendar.YEAR),timenow.get(Calendar.MONTH),\n timenow.get(Calendar.DATE),0,0,0);\neleven30 = timenow.clone();\neleven30.set(\n timenow.get(Calendar.YEAR),timenow.get(Calendar.MONTH),\n timenow.get(Calendar.DATE),11,30,0);\n\nitemisalcohol = false;\nif(item_id != null && item_id >=1000 && item_id < 2000)\n itemisalcohol = true;\n\nif( itemisalcohol\n && timenow.after(midnight) && timenow.before(eleven30)){\n outFields.put(\"authorised\", false);\n outFields.put(\"message\", \"Sale not authorised by policy task \"+subject.taskName+\n \" for time \"+df.format(timenow.getTime())+\n \". Alcohol can not be sold between \"+df.format(midnight.getTime())+\n \" and \"+df.format(eleven30.getTime()));\n return true;\n}\nelse{\n outFields.put(\"authorised\", true);\n outFields.put(\"message\", \"Sale authorised by policy task \"+subject.taskName+\n \" for time \"+df.format(timenow.getTime()));\n return true;\n}\n\n/*\nThis task checks if a sale request is for an item that is an alcoholic drink.\nIf the local time is between 00:00:00 GMT and 11:30:00 GMT then the sale is not\nauthorised. Otherwise the sale is authorised.\nIn this implementation we assume that items with item_ID value between 1000 and\n2000 are all alcoholic drinks :-)\n*/"}}}]}},"events":{"key":{"name":"MyFirstPolicyModel_Events","version":"0.0.1"},"eventMap":{"entry":[{"key":{"name":"SALE_AUTH","version":"0.0.1"},"value":{"key":{"name":"SALE_AUTH","version":"0.0.1"},"nameSpace":"com.hyperm","source":"APEX","target":"POS","parameter":{"entry":[{"key":"amount","value":{"key":"amount","fieldSchemaKey":{"name":"price_type","version":"0.0.1"},"optional":false}},{"key":"assistant_ID","value":{"key":"assistant_ID","fieldSchemaKey":{"name":"assistant_ID_type","version":"0.0.1"},"optional":false}},{"key":"authorised","value":{"key":"authorised","fieldSchemaKey":{"name":"authorised_type","version":"0.0.1"},"optional":false}},{"key":"branch_ID","value":{"key":"branch_ID","fieldSchemaKey":{"name":"branch_ID_type","version":"0.0.1"},"optional":false}},{"key":"item_ID","value":{"key":"item_ID","fieldSchemaKey":{"name":"item_ID_type","version":"0.0.1"},"optional":false}},{"key":"message","value":{"key":"message","fieldSchemaKey":{"name":"message_type","version":"0.0.1"},"optional":true}},{"key":"notes","value":{"key":"notes","fieldSchemaKey":{"name":"notes_type","version":"0.0.1"},"optional":true}},{"key":"quantity","value":{"key":"quantity","fieldSchemaKey":{"name":"quantity_type","version":"0.0.1"},"optional":false}},{"key":"sale_ID","value":{"key":"sale_ID","fieldSchemaKey":{"name":"sale_ID_type","version":"0.0.1"},"optional":false}},{"key":"time","value":{"key":"time","fieldSchemaKey":{"name":"timestamp_type","version":"0.0.1"},"optional":false}}]}}},{"key":{"name":"SALE_INPUT","version":"0.0.1"},"value":{"key":{"name":"SALE_INPUT","version":"0.0.1"},"nameSpace":"com.hyperm","source":"POS","target":"APEX","parameter":{"entry":[{"key":"amount","value":{"key":"amount","fieldSchemaKey":{"name":"price_type","version":"0.0.1"},"optional":false}},{"key":"assistant_ID","value":{"key":"assistant_ID","fieldSchemaKey":{"name":"assistant_ID_type","version":"0.0.1"},"optional":false}},{"key":"branch_ID","value":{"key":"branch_ID","fieldSchemaKey":{"name":"branch_ID_type","version":"0.0.1"},"optional":false}},{"key":"item_ID","value":{"key":"item_ID","fieldSchemaKey":{"name":"item_ID_type","version":"0.0.1"},"optional":false}},{"key":"notes","value":{"key":"notes","fieldSchemaKey":{"name":"notes_type","version":"0.0.1"},"optional":true}},{"key":"quantity","value":{"key":"quantity","fieldSchemaKey":{"name":"quantity_type","version":"0.0.1"},"optional":false}},{"key":"sale_ID","value":{"key":"sale_ID","fieldSchemaKey":{"name":"sale_ID_type","version":"0.0.1"},"optional":false}},{"key":"time","value":{"key":"time","fieldSchemaKey":{"name":"timestamp_type","version":"0.0.1"},"optional":false}}]}}}]}},"schemas":{"key":{"name":"MyFirstPolicyModel_Schemas","version":"0.0.1"},"schemas":{"entry":[{"key":{"name":"assistant_ID_type","version":"0.0.1"},"value":{"key":{"name":"assistant_ID_type","version":"0.0.1"},"schemaFlavour":"Java","schemaDefinition":"java.lang.Long"}},{"key":{"name":"authorised_type","version":"0.0.1"},"value":{"key":{"name":"authorised_type","version":"0.0.1"},"schemaFlavour":"Java","schemaDefinition":"java.lang.Boolean"}},{"key":{"name":"branch_ID_type","version":"0.0.1"},"value":{"key":{"name":"branch_ID_type","version":"0.0.1"},"schemaFlavour":"Java","schemaDefinition":"java.lang.Long"}},{"key":{"name":"item_ID_type","version":"0.0.1"},"value":{"key":{"name":"item_ID_type","version":"0.0.1"},"schemaFlavour":"Java","schemaDefinition":"java.lang.Long"}},{"key":{"name":"message_type","version":"0.0.1"},"value":{"key":{"name":"message_type","version":"0.0.1"},"schemaFlavour":"Java","schemaDefinition":"java.lang.String"}},{"key":{"name":"notes_type","version":"0.0.1"},"value":{"key":{"name":"notes_type","version":"0.0.1"},"schemaFlavour":"Java","schemaDefinition":"java.lang.String"}},{"key":{"name":"price_type","version":"0.0.1"},"value":{"key":{"name":"price_type","version":"0.0.1"},"schemaFlavour":"Java","schemaDefinition":"java.lang.Long"}},{"key":{"name":"quantity_type","version":"0.0.1"},"value":{"key":{"name":"quantity_type","version":"0.0.1"},"schemaFlavour":"Java","schemaDefinition":"java.lang.Integer"}},{"key":{"name":"sale_ID_type","version":"0.0.1"},"value":{"key":{"name":"sale_ID_type","version":"0.0.1"},"schemaFlavour":"Java","schemaDefinition":"java.lang.Long"}},{"key":{"name":"timestamp_type","version":"0.0.1"},"value":{"key":{"name":"timestamp_type","version":"0.0.1"},"schemaFlavour":"Java","schemaDefinition":"java.lang.Long"}}]}}}}},"eventOutputParameters":{"FirstProducer":{"carrierTechnologyParameters":{"carrierTechnology":"FILE","parameters":{"standardIo":true}},"eventProtocolParameters":{"eventProtocol":"JSON"}}},"eventInputParameters":{"FirstConsumer":{"carrierTechnologyParameters":{"carrierTechnology":"FILE","parameters":{"standardIo":true}},"eventProtocolParameters":{"eventProtocol":"JSON"}}}}}}]}} \ No newline at end of file
+{"tosca_definitions_version":"tosca_simple_yaml_1_1_0","topology_template":{"policies":[{"native.sampledomain":{"type":"onap.policies.native.Apex","type_version":"1.0.0","name":"native.sampledomain","version":"1.0.0","properties":{"engineServiceParameters":{"name":"MyFirstPolicyApexEngine","version":"0.0.1","id":101,"instanceCount":4,"deploymentPort":12345,"engineParameters":{"executorParameters":{"MVEL":{"parameterClassName":"org.onap.policy.apex.plugins.executor.mvel.MvelExecutorParameters"},"JAVASCRIPT":{"parameterClassName":"org.onap.policy.apex.plugins.executor.javascript.JavascriptExecutorParameters"}}},"policy_type_impl":{"apexPolicyModel":{"key":{"name":"MyFirstPolicyModel","version":"0.0.1"},"keyInformation":{"key":{"name":"MyFirstPolicyModel_KeyInfo","version":"0.0.1"},"keyInfoMap":{"entry":[{"key":{"name":"MorningBoozeCheck","version":"0.0.1"},"value":{"key":{"name":"MorningBoozeCheck","version":"0.0.1"},"UUID":"3351b0f4-cf06-4fa2-8823-edf67bd30223","description":"This task checks if the sales request is for an item that contains alcohol. \nIf the local time is between 00:00:00 and 11:30:00 then the sale is not authorised. Otherwise the sale is authorised. \nIn this implementation we assume that all items with item_ID values between 1000 and 2000 contain alcohol :-)"}},{"key":{"name":"MyFirstPolicy","version":"0.0.1"},"value":{"key":{"name":"MyFirstPolicy","version":"0.0.1"},"UUID":"6c5e410f-489a-46ff-964e-982ce6e8b6d0","description":"This is my first Apex policy. It checks if a sale should be authorised or not."}},{"key":{"name":"MyFirstPolicyModel","version":"0.0.1"},"value":{"key":{"name":"MyFirstPolicyModel","version":"0.0.1"},"UUID":"540226fb-55ee-4f0e-a444-983a0494818e","description":"This is my first Apex Policy Model."}},{"key":{"name":"MyFirstPolicyModel_Events","version":"0.0.1"},"value":{"key":{"name":"MyFirstPolicyModel_Events","version":"0.0.1"},"UUID":"ef281318-5ac9-3ef0-8db3-8f9c4e4a81e2","description":"Generated description for concept referred to by key \"MyFirstPolicyModel_Events:0.0.1\""}},{"key":{"name":"MyFirstPolicyModel_KeyInfo","version":"0.0.1"},"value":{"key":{"name":"MyFirstPolicyModel_KeyInfo","version":"0.0.1"},"UUID":"d9248c6f-7c00-38df-8251-611463ba4065","description":"Generated description for concept referred to by key \"MyFirstPolicyModel_KeyInfo:0.0.1\""}},{"key":{"name":"MyFirstPolicyModel_Policies","version":"0.0.1"},"value":{"key":{"name":"MyFirstPolicyModel_Policies","version":"0.0.1"},"UUID":"77c01a6b-510c-3aa9-b640-b4db356aa03b","description":"Generated description for concept referred to by key \"MyFirstPolicyModel_Policies:0.0.1\""}},{"key":{"name":"MyFirstPolicyModel_Schemas","version":"0.0.1"},"value":{"key":{"name":"MyFirstPolicyModel_Schemas","version":"0.0.1"},"UUID":"d0cc3aa0-ea69-3a43-80ff-a0dbb0ebd885","description":"Generated description for concept referred to by key \"MyFirstPolicyModel_Schemas:0.0.1\""}},{"key":{"name":"MyFirstPolicyModel_Tasks","version":"0.0.1"},"value":{"key":{"name":"MyFirstPolicyModel_Tasks","version":"0.0.1"},"UUID":"b02a7e02-2cd0-39e6-b3cb-946fa83a8f08","description":"Generated description for concept referred to by key \"MyFirstPolicyModel_Tasks:0.0.1\""}},{"key":{"name":"SALE_AUTH","version":"0.0.1"},"value":{"key":{"name":"SALE_AUTH","version":"0.0.1"},"UUID":"c4500941-3f98-4080-a9cc-5b9753ed050b","description":"An event emitted by the Policy to indicate whether the sale of an item has been authorised"}},{"key":{"name":"SALE_INPUT","version":"0.0.1"},"value":{"key":{"name":"SALE_INPUT","version":"0.0.1"},"UUID":"4f04aa98-e917-4f4a-882a-c75ba5a99374","description":"An event raised by the PoS system each time an item is scanned for purchase"}},{"key":{"name":"assistant_ID_type","version":"0.0.1"},"value":{"key":{"name":"assistant_ID_type","version":"0.0.1"},"UUID":"36df4c71-9616-4206-8b53-976a5cd4bd87","description":"A type for 'assistant_ID' values"}},{"key":{"name":"authorised_type","version":"0.0.1"},"value":{"key":{"name":"authorised_type","version":"0.0.1"},"UUID":"d48b619e-d00d-4008-b884-02d76ea4350b","description":"A type for 'authorised' values"}},{"key":{"name":"branch_ID_type","version":"0.0.1"},"value":{"key":{"name":"branch_ID_type","version":"0.0.1"},"UUID":"6468845f-4122-4128-8e49-0f52c26078b5","description":"A type for 'branch_ID' values"}},{"key":{"name":"item_ID_type","version":"0.0.1"},"value":{"key":{"name":"item_ID_type","version":"0.0.1"},"UUID":"4f227ff1-aee0-453a-b6b6-9a4b2e0da932","description":"A type for 'item_ID' values"}},{"key":{"name":"message_type","version":"0.0.1"},"value":{"key":{"name":"message_type","version":"0.0.1"},"UUID":"ad1431bb-3155-4e73-b5a3-b89bee498749","description":"A type for 'message' values"}},{"key":{"name":"notes_type","version":"0.0.1"},"value":{"key":{"name":"notes_type","version":"0.0.1"},"UUID":"eecfde90-896c-4343-8f9c-2603ced94e2d","description":"A type for 'notes' values"}},{"key":{"name":"price_type","version":"0.0.1"},"value":{"key":{"name":"price_type","version":"0.0.1"},"UUID":"52c2fc45-fd8c-463c-bd6f-d91b0554aea7","description":"A type for 'amount'/'price' values"}},{"key":{"name":"quantity_type","version":"0.0.1"},"value":{"key":{"name":"quantity_type","version":"0.0.1"},"UUID":"ac3d9842-80af-4a98-951c-bd79a431c613","description":"A type for 'quantity' values"}},{"key":{"name":"sale_ID_type","version":"0.0.1"},"value":{"key":{"name":"sale_ID_type","version":"0.0.1"},"UUID":"cca47d74-7754-4a61-b163-ca31f66b157b","description":"A type for 'sale_ID' values"}},{"key":{"name":"timestamp_type","version":"0.0.1"},"value":{"key":{"name":"timestamp_type","version":"0.0.1"},"UUID":"fd594e88-411d-4a94-b2be-697b3a0d7adf","description":"A type for 'time' values"}}]}},"policies":{"key":{"name":"MyFirstPolicyModel_Policies","version":"0.0.1"},"policyMap":{"entry":[{"key":{"name":"MyFirstPolicy","version":"0.0.1"},"value":{"policyKey":{"name":"MyFirstPolicy","version":"0.0.1"},"template":"FREEFORM","state":{"entry":[{"key":"BoozeAuthDecide","value":{"stateKey":{"parentKeyName":"MyFirstPolicy","parentKeyVersion":"0.0.1","parentLocalName":"NULL","localName":"BoozeAuthDecide"},"trigger":{"name":"SALE_INPUT","version":"0.0.1"},"stateOutputs":{"entry":[{"key":"MorningBoozeCheck_Output_Direct","value":{"key":{"parentKeyName":"MyFirstPolicy","parentKeyVersion":"0.0.1","parentLocalName":"BoozeAuthDecide","localName":"MorningBoozeCheck_Output_Direct"},"outgoingEvent":{"name":"SALE_AUTH","version":"0.0.1"},"outgoingEventReference":[{"name":"SALE_AUTH","version":"0.0.1"}],"nextState":{"parentKeyName":"NULL","parentKeyVersion":"0.0.0","parentLocalName":"NULL","localName":"NULL"}}}]},"contextAlbumReference":[],"taskSelectionLogic":{"key":"NULL","logicFlavour":"UNDEFINED","logic":""},"stateFinalizerLogicMap":{"entry":[]},"defaultTask":{"name":"MorningBoozeCheck","version":"0.0.1"},"taskReferences":{"entry":[{"key":{"name":"MorningBoozeCheck","version":"0.0.1"},"value":{"key":{"parentKeyName":"MyFirstPolicy","parentKeyVersion":"0.0.1","parentLocalName":"BoozeAuthDecide","localName":"MorningBoozeCheck"},"outputType":"DIRECT","output":{"parentKeyName":"MyFirstPolicy","parentKeyVersion":"0.0.1","parentLocalName":"BoozeAuthDecide","localName":"MorningBoozeCheck_Output_Direct"}}}]}}}]},"firstState":"BoozeAuthDecide"}}]}},"tasks":{"key":{"name":"MyFirstPolicyModel_Tasks","version":"0.0.1"},"taskMap":{"entry":[{"key":{"name":"MorningBoozeCheck","version":"0.0.1"},"value":{"key":{"name":"MorningBoozeCheck","version":"0.0.1"},"inputEvent":{"key":{"name":"SALE_INPUT","version":"0.0.1"},"nameSpace":"com.hyperm","source":"POS","target":"APEX","parameter":{"entry":[{"key":"amount","value":{"key":"amount","fieldSchemaKey":{"name":"price_type","version":"0.0.1"},"optional":false}},{"key":"assistant_ID","value":{"key":"assistant_ID","fieldSchemaKey":{"name":"assistant_ID_type","version":"0.0.1"},"optional":false}},{"key":"branch_ID","value":{"key":"branch_ID","fieldSchemaKey":{"name":"branch_ID_type","version":"0.0.1"},"optional":false}},{"key":"item_ID","value":{"key":"item_ID","fieldSchemaKey":{"name":"item_ID_type","version":"0.0.1"},"optional":false}},{"key":"notes","value":{"key":"notes","fieldSchemaKey":{"name":"notes_type","version":"0.0.1"},"optional":true}},{"key":"quantity","value":{"key":"quantity","fieldSchemaKey":{"name":"quantity_type","version":"0.0.1"},"optional":false}},{"key":"sale_ID","value":{"key":"sale_ID","fieldSchemaKey":{"name":"sale_ID_type","version":"0.0.1"},"optional":false}},{"key":"time","value":{"key":"time","fieldSchemaKey":{"name":"timestamp_type","version":"0.0.1"},"optional":false}}]}},"outputEvents":{"entry":[{"key":"SALE_AUTH","value":{"key":{"name":"SALE_AUTH","version":"0.0.1"},"nameSpace":"com.hyperm","source":"APEX","target":"POS","parameter":{"entry":[{"key":"amount","value":{"key":"amount","fieldSchemaKey":{"name":"price_type","version":"0.0.1"},"optional":false}},{"key":"assistant_ID","value":{"key":"assistant_ID","fieldSchemaKey":{"name":"assistant_ID_type","version":"0.0.1"},"optional":false}},{"key":"authorised","value":{"key":"authorised","fieldSchemaKey":{"name":"authorised_type","version":"0.0.1"},"optional":false}},{"key":"branch_ID","value":{"key":"branch_ID","fieldSchemaKey":{"name":"branch_ID_type","version":"0.0.1"},"optional":false}},{"key":"item_ID","value":{"key":"item_ID","fieldSchemaKey":{"name":"item_ID_type","version":"0.0.1"},"optional":false}},{"key":"message","value":{"key":"message","fieldSchemaKey":{"name":"message_type","version":"0.0.1"},"optional":true}},{"key":"notes","value":{"key":"notes","fieldSchemaKey":{"name":"notes_type","version":"0.0.1"},"optional":true}},{"key":"quantity","value":{"key":"quantity","fieldSchemaKey":{"name":"quantity_type","version":"0.0.1"},"optional":false}},{"key":"sale_ID","value":{"key":"sale_ID","fieldSchemaKey":{"name":"sale_ID_type","version":"0.0.1"},"optional":false}},{"key":"time","value":{"key":"time","fieldSchemaKey":{"name":"timestamp_type","version":"0.0.1"},"optional":false}}]}}}]},"inputFields":{"entry":[{"key":"amount","value":{"key":"amount","fieldSchemaKey":{"name":"price_type","version":"0.0.1"},"optional":false}},{"key":"assistant_ID","value":{"key":"assistant_ID","fieldSchemaKey":{"name":"assistant_ID_type","version":"0.0.1"},"optional":false}},{"key":"branch_ID","value":{"key":"branch_ID","fieldSchemaKey":{"name":"branch_ID_type","version":"0.0.1"},"optional":false}},{"key":"item_ID","value":{"key":"item_ID","fieldSchemaKey":{"name":"item_ID_type","version":"0.0.1"},"optional":false}},{"key":"notes","value":{"key":"notes","fieldSchemaKey":{"name":"notes_type","version":"0.0.1"},"optional":true}},{"key":"quantity","value":{"key":"quantity","fieldSchemaKey":{"name":"quantity_type","version":"0.0.1"},"optional":false}},{"key":"sale_ID","value":{"key":"sale_ID","fieldSchemaKey":{"name":"sale_ID_type","version":"0.0.1"},"optional":false}},{"key":"time","value":{"key":"time","fieldSchemaKey":{"name":"timestamp_type","version":"0.0.1"},"optional":false}}]},"outputFields":{"entry":[{"key":"amount","value":{"key":"amount","fieldSchemaKey":{"name":"price_type","version":"0.0.1"},"optional":false}},{"key":"assistant_ID","value":{"key":"assistant_ID","fieldSchemaKey":{"name":"assistant_ID_type","version":"0.0.1"},"optional":false}},{"key":"authorised","value":{"key":"authorised","fieldSchemaKey":{"name":"authorised_type","version":"0.0.1"},"optional":false}},{"key":"branch_ID","value":{"key":"branch_ID","fieldSchemaKey":{"name":"branch_ID_type","version":"0.0.1"},"optional":false}},{"key":"item_ID","value":{"key":"item_ID","fieldSchemaKey":{"name":"item_ID_type","version":"0.0.1"},"optional":false}},{"key":"message","value":{"key":"message","fieldSchemaKey":{"name":"message_type","version":"0.0.1"},"optional":true}},{"key":"notes","value":{"key":"notes","fieldSchemaKey":{"name":"notes_type","version":"0.0.1"},"optional":true}},{"key":"quantity","value":{"key":"quantity","fieldSchemaKey":{"name":"quantity_type","version":"0.0.1"},"optional":false}},{"key":"sale_ID","value":{"key":"sale_ID","fieldSchemaKey":{"name":"sale_ID_type","version":"0.0.1"},"optional":false}},{"key":"time","value":{"key":"time","fieldSchemaKey":{"name":"timestamp_type","version":"0.0.1"},"optional":false}}]},"taskParameters":{"entry":[]},"contextAlbumReference":[],"taskLogic":{"key":"TaskLogic","logicFlavour":"MVEL","logic":"/*\n * ============LICENSE_START=======================================================\n * Copyright (C) 2016-2018 Ericsson. All rights reserved.\n * Modifications Copyright (C) 2019 Nordix Foundation.\n * ================================================================================\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n * SPDX-License-Identifier: Apache-2.0\n * ============LICENSE_END=========================================================\n */\nimport java.util.Date;\nimport java.util.Calendar;\nimport java.util.TimeZone;\nimport java.text.SimpleDateFormat;\n\nlogger.info(\"Task Execution: '\"+subject.id+\"'. Input Fields: '\"+inFields+\"'\");\n\noutFields.put(\"amount\" , inFields.get(\"amount\"));\noutFields.put(\"assistant_ID\", inFields.get(\"assistant_ID\"));\noutFields.put(\"notes\" , inFields.get(\"notes\"));\noutFields.put(\"quantity\" , inFields.get(\"quantity\"));\noutFields.put(\"branch_ID\" , inFields.get(\"branch_ID\"));\noutFields.put(\"item_ID\" , inFields.get(\"item_ID\"));\noutFields.put(\"time\" , inFields.get(\"time\"));\noutFields.put(\"sale_ID\" , inFields.get(\"sale_ID\"));\n\nitem_id = inFields.get(\"item_ID\");\n\n//The events used later to test this task use GMT timezone!\ngmt = TimeZone.getTimeZone(\"GMT\");\ntimenow = Calendar.getInstance(gmt);\ndf = new SimpleDateFormat(\"HH:mm:ss z\");\ndf.setTimeZone(gmt);\ntimenow.setTimeInMillis(inFields.get(\"time\"));\n\nmidnight = timenow.clone();\nmidnight.set(\n timenow.get(Calendar.YEAR),timenow.get(Calendar.MONTH),\n timenow.get(Calendar.DATE),0,0,0);\neleven30 = timenow.clone();\neleven30.set(\n timenow.get(Calendar.YEAR),timenow.get(Calendar.MONTH),\n timenow.get(Calendar.DATE),11,30,0);\n\nitemisalcohol = false;\nif(item_id != null && item_id >=1000 && item_id < 2000)\n itemisalcohol = true;\n\nif( itemisalcohol\n && timenow.after(midnight) && timenow.before(eleven30)){\n outFields.put(\"authorised\", false);\n outFields.put(\"message\", \"Sale not authorised by policy task \"+subject.taskName+\n \" for time \"+df.format(timenow.getTime())+\n \". Alcohol can not be sold between \"+df.format(midnight.getTime())+\n \" and \"+df.format(eleven30.getTime()));\n return true;\n}\nelse{\n outFields.put(\"authorised\", true);\n outFields.put(\"message\", \"Sale authorised by policy task \"+subject.taskName+\n \" for time \"+df.format(timenow.getTime()));\n return true;\n}\n\n/*\nThis task checks if a sale request is for an item that is an alcoholic drink.\nIf the local time is between 00:00:00 GMT and 11:30:00 GMT then the sale is not\nauthorised. Otherwise the sale is authorised.\nIn this implementation we assume that items with item_ID value between 1000 and\n2000 are all alcoholic drinks :-)\n*/"}}}]}},"events":{"key":{"name":"MyFirstPolicyModel_Events","version":"0.0.1"},"eventMap":{"entry":[{"key":{"name":"SALE_AUTH","version":"0.0.1"},"value":{"key":{"name":"SALE_AUTH","version":"0.0.1"},"nameSpace":"com.hyperm","source":"APEX","target":"POS","parameter":{"entry":[{"key":"amount","value":{"key":"amount","fieldSchemaKey":{"name":"price_type","version":"0.0.1"},"optional":false}},{"key":"assistant_ID","value":{"key":"assistant_ID","fieldSchemaKey":{"name":"assistant_ID_type","version":"0.0.1"},"optional":false}},{"key":"authorised","value":{"key":"authorised","fieldSchemaKey":{"name":"authorised_type","version":"0.0.1"},"optional":false}},{"key":"branch_ID","value":{"key":"branch_ID","fieldSchemaKey":{"name":"branch_ID_type","version":"0.0.1"},"optional":false}},{"key":"item_ID","value":{"key":"item_ID","fieldSchemaKey":{"name":"item_ID_type","version":"0.0.1"},"optional":false}},{"key":"message","value":{"key":"message","fieldSchemaKey":{"name":"message_type","version":"0.0.1"},"optional":true}},{"key":"notes","value":{"key":"notes","fieldSchemaKey":{"name":"notes_type","version":"0.0.1"},"optional":true}},{"key":"quantity","value":{"key":"quantity","fieldSchemaKey":{"name":"quantity_type","version":"0.0.1"},"optional":false}},{"key":"sale_ID","value":{"key":"sale_ID","fieldSchemaKey":{"name":"sale_ID_type","version":"0.0.1"},"optional":false}},{"key":"time","value":{"key":"time","fieldSchemaKey":{"name":"timestamp_type","version":"0.0.1"},"optional":false}}]}}},{"key":{"name":"SALE_INPUT","version":"0.0.1"},"value":{"key":{"name":"SALE_INPUT","version":"0.0.1"},"nameSpace":"com.hyperm","source":"POS","target":"APEX","parameter":{"entry":[{"key":"amount","value":{"key":"amount","fieldSchemaKey":{"name":"price_type","version":"0.0.1"},"optional":false}},{"key":"assistant_ID","value":{"key":"assistant_ID","fieldSchemaKey":{"name":"assistant_ID_type","version":"0.0.1"},"optional":false}},{"key":"branch_ID","value":{"key":"branch_ID","fieldSchemaKey":{"name":"branch_ID_type","version":"0.0.1"},"optional":false}},{"key":"item_ID","value":{"key":"item_ID","fieldSchemaKey":{"name":"item_ID_type","version":"0.0.1"},"optional":false}},{"key":"notes","value":{"key":"notes","fieldSchemaKey":{"name":"notes_type","version":"0.0.1"},"optional":true}},{"key":"quantity","value":{"key":"quantity","fieldSchemaKey":{"name":"quantity_type","version":"0.0.1"},"optional":false}},{"key":"sale_ID","value":{"key":"sale_ID","fieldSchemaKey":{"name":"sale_ID_type","version":"0.0.1"},"optional":false}},{"key":"time","value":{"key":"time","fieldSchemaKey":{"name":"timestamp_type","version":"0.0.1"},"optional":false}}]}}}]}},"schemas":{"key":{"name":"MyFirstPolicyModel_Schemas","version":"0.0.1"},"schemas":{"entry":[{"key":{"name":"assistant_ID_type","version":"0.0.1"},"value":{"key":{"name":"assistant_ID_type","version":"0.0.1"},"schemaFlavour":"Java","schemaDefinition":"java.lang.Long"}},{"key":{"name":"authorised_type","version":"0.0.1"},"value":{"key":{"name":"authorised_type","version":"0.0.1"},"schemaFlavour":"Java","schemaDefinition":"java.lang.Boolean"}},{"key":{"name":"branch_ID_type","version":"0.0.1"},"value":{"key":{"name":"branch_ID_type","version":"0.0.1"},"schemaFlavour":"Java","schemaDefinition":"java.lang.Long"}},{"key":{"name":"item_ID_type","version":"0.0.1"},"value":{"key":{"name":"item_ID_type","version":"0.0.1"},"schemaFlavour":"Java","schemaDefinition":"java.lang.Long"}},{"key":{"name":"message_type","version":"0.0.1"},"value":{"key":{"name":"message_type","version":"0.0.1"},"schemaFlavour":"Java","schemaDefinition":"java.lang.String"}},{"key":{"name":"notes_type","version":"0.0.1"},"value":{"key":{"name":"notes_type","version":"0.0.1"},"schemaFlavour":"Java","schemaDefinition":"java.lang.String"}},{"key":{"name":"price_type","version":"0.0.1"},"value":{"key":{"name":"price_type","version":"0.0.1"},"schemaFlavour":"Java","schemaDefinition":"java.lang.Long"}},{"key":{"name":"quantity_type","version":"0.0.1"},"value":{"key":{"name":"quantity_type","version":"0.0.1"},"schemaFlavour":"Java","schemaDefinition":"java.lang.Integer"}},{"key":{"name":"sale_ID_type","version":"0.0.1"},"value":{"key":{"name":"sale_ID_type","version":"0.0.1"},"schemaFlavour":"Java","schemaDefinition":"java.lang.Long"}},{"key":{"name":"timestamp_type","version":"0.0.1"},"value":{"key":{"name":"timestamp_type","version":"0.0.1"},"schemaFlavour":"Java","schemaDefinition":"java.lang.Long"}}]}}}}},"eventOutputParameters":{"FirstProducer":{"carrierTechnologyParameters":{"carrierTechnology":"FILE","parameters":{"standardIo":true}},"eventProtocolParameters":{"eventProtocol":"JSON"}}},"eventInputParameters":{"FirstConsumer":{"carrierTechnologyParameters":{"carrierTechnology":"FILE","parameters":{"standardIo":true}},"eventProtocolParameters":{"eventProtocol":"JSON"}}}}}}]}} \ No newline at end of file