4 "name" : "MyFirstPolicyModel",
9 "name" : "MyFirstPolicyModel_KeyInfo",
15 "name" : "MorningBoozeCheck",
20 "name" : "MorningBoozeCheck",
23 "UUID" : "3351b0f4-cf06-4fa2-8823-edf67bd30223",
24 "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 :-)"
28 "name" : "MorningBoozeCheckAlt1",
33 "name" : "MorningBoozeCheckAlt1",
36 "UUID" : "bc6d90c9-c902-4686-afd3-925b30e39990",
37 "description" : "This task checks if a sale request is for an item that is an alcoholic drink.\nIf the local time is between 00:00:00 CET and 13:00:00 CET then the sale is not authorised.\nAlso alcohol sales are not allowed on Sundays. Otherwise the sale is authorised.\nIn this implementation we assume that items with item_ID between 1000 and 2000 are all alcoholic drinks"
41 "name" : "MyFirstPolicy",
46 "name" : "MyFirstPolicy",
49 "UUID" : "6c5e410f-489a-46ff-964e-982ce6e8b6d0",
50 "description" : "This is my first Apex policy. It checks if a sale should be authorised or not."
54 "name" : "MyFirstPolicyModel",
59 "name" : "MyFirstPolicyModel",
62 "UUID" : "540226fb-55ee-4f0e-a444-983a0494818e",
63 "description" : "This is my first Apex Policy Model."
67 "name" : "MyFirstPolicyModel_Events",
72 "name" : "MyFirstPolicyModel_Events",
75 "UUID" : "ef281318-5ac9-3ef0-8db3-8f9c4e4a81e2",
76 "description" : "Generated description for concept referred to by key \"MyFirstPolicyModel_Events:0.0.1\""
80 "name" : "MyFirstPolicyModel_KeyInfo",
85 "name" : "MyFirstPolicyModel_KeyInfo",
88 "UUID" : "d9248c6f-7c00-38df-8251-611463ba4065",
89 "description" : "Generated description for concept referred to by key \"MyFirstPolicyModel_KeyInfo:0.0.1\""
93 "name" : "MyFirstPolicyModel_Policies",
98 "name" : "MyFirstPolicyModel_Policies",
101 "UUID" : "77c01a6b-510c-3aa9-b640-b4db356aa03b",
102 "description" : "Generated description for concept referred to by key \"MyFirstPolicyModel_Policies:0.0.1\""
106 "name" : "MyFirstPolicyModel_Schemas",
111 "name" : "MyFirstPolicyModel_Schemas",
114 "UUID" : "d0cc3aa0-ea69-3a43-80ff-a0dbb0ebd885",
115 "description" : "Generated description for concept referred to by key \"MyFirstPolicyModel_Schemas:0.0.1\""
119 "name" : "MyFirstPolicyModel_Tasks",
124 "name" : "MyFirstPolicyModel_Tasks",
127 "UUID" : "b02a7e02-2cd0-39e6-b3cb-946fa83a8f08",
128 "description" : "Generated description for concept referred to by key \"MyFirstPolicyModel_Tasks:0.0.1\""
132 "name" : "SALE_AUTH",
137 "name" : "SALE_AUTH",
140 "UUID" : "c4500941-3f98-4080-a9cc-5b9753ed050b",
141 "description" : "An event emitted by the Policy to indicate whether the sale of an item has been authorised"
145 "name" : "SALE_INPUT",
150 "name" : "SALE_INPUT",
153 "UUID" : "4f04aa98-e917-4f4a-882a-c75ba5a99374",
154 "description" : "An event raised by the PoS system each time an item is scanned for purchase"
158 "name" : "assistant_ID_type",
163 "name" : "assistant_ID_type",
166 "UUID" : "36df4c71-9616-4206-8b53-976a5cd4bd87",
167 "description" : "A type for 'assistant_ID' values"
171 "name" : "authorised_type",
176 "name" : "authorised_type",
179 "UUID" : "d48b619e-d00d-4008-b884-02d76ea4350b",
180 "description" : "A type for 'authorised' values"
184 "name" : "branch_ID_type",
189 "name" : "branch_ID_type",
192 "UUID" : "6468845f-4122-4128-8e49-0f52c26078b5",
193 "description" : "A type for 'branch_ID' values"
197 "name" : "item_ID_type",
202 "name" : "item_ID_type",
205 "UUID" : "4f227ff1-aee0-453a-b6b6-9a4b2e0da932",
206 "description" : "A type for 'item_ID' values"
210 "name" : "message_type",
215 "name" : "message_type",
218 "UUID" : "ad1431bb-3155-4e73-b5a3-b89bee498749",
219 "description" : "A type for 'message' values"
223 "name" : "notes_type",
228 "name" : "notes_type",
231 "UUID" : "eecfde90-896c-4343-8f9c-2603ced94e2d",
232 "description" : "A type for 'notes' values"
236 "name" : "price_type",
241 "name" : "price_type",
244 "UUID" : "52c2fc45-fd8c-463c-bd6f-d91b0554aea7",
245 "description" : "A type for 'amount'/'price' values"
249 "name" : "quantity_type",
254 "name" : "quantity_type",
257 "UUID" : "ac3d9842-80af-4a98-951c-bd79a431c613",
258 "description" : "A type for 'quantity' values"
262 "name" : "sale_ID_type",
267 "name" : "sale_ID_type",
270 "UUID" : "cca47d74-7754-4a61-b163-ca31f66b157b",
271 "description" : "A type for 'sale_ID' values"
275 "name" : "timestamp_type",
280 "name" : "timestamp_type",
283 "UUID" : "fd594e88-411d-4a94-b2be-697b3a0d7adf",
284 "description" : "A type for 'time' values"
291 "name" : "MyFirstPolicyModel_Policies",
297 "name" : "MyFirstPolicy",
302 "name" : "MyFirstPolicy",
305 "template" : "FREEFORM",
308 "key" : "BoozeAuthDecide",
311 "parentKeyName" : "MyFirstPolicy",
312 "parentKeyVersion" : "0.0.1",
313 "parentLocalName" : "NULL",
314 "localName" : "BoozeAuthDecide"
317 "name" : "SALE_INPUT",
322 "key" : "MorningBoozeCheck_Output_Direct",
325 "parentKeyName" : "MyFirstPolicy",
326 "parentKeyVersion" : "0.0.1",
327 "parentLocalName" : "BoozeAuthDecide",
328 "localName" : "MorningBoozeCheck_Output_Direct"
331 "name" : "SALE_AUTH",
335 "parentKeyName" : "NULL",
336 "parentKeyVersion" : "0.0.0",
337 "parentLocalName" : "NULL",
343 "contextAlbumReference" : [ ],
344 "taskSelectionLogic" : {
345 "key" : "TaskSelectionLogic",
346 "logicFlavour" : "JAVASCRIPT",
347 "logic" : "/*\n * ============LICENSE_START=======================================================\n * Copyright (C) 2016-2018 Ericsson. All rights reserved.\n * Modifications Copyright (C) 2020 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 */\n\nvar returnValue = true;\n\nexecutor.logger.info(\"Task Selection Execution: '\"+executor.subject.id+\"'. Input Event: '\"+executor.inFields+\"'\");\n\nbranchid = executor.inFields.get(\"branch_ID\");\ntaskorig = executor.subject.getTaskKey(\"MorningBoozeCheck\");\ntaskalt = executor.subject.getTaskKey(\"MorningBoozeCheckAlt1\");\ntaskdef = executor.subject.getDefaultTaskKey();\n\nif(branchid >=0 && branchid <1000){\n taskorig.copyTo(executor.selectedTask);\n}\nelse if (branchid >=1000 && branchid <2000){\n taskalt.copyTo(executor.selectedTask);\n}\nelse{\n taskdef.copyTo(executor.selectedTask);\n}\n\n/*\nThis task selection logic selects task \"MorningBoozeCheck\" for branches with 0<=branch_ID<1000 and selects task \"MorningBoozeCheckAlt1\" for branches with 1000<=branch_ID<2000. Otherwise the default task is selected. In this case the default task is also \"MorningBoozeCheck\"\n*/\n\nreturnValue;"
349 "stateFinalizerLogicMap" : {
353 "name" : "MorningBoozeCheck",
359 "name" : "MorningBoozeCheck",
364 "parentKeyName" : "MyFirstPolicy",
365 "parentKeyVersion" : "0.0.1",
366 "parentLocalName" : "BoozeAuthDecide",
367 "localName" : "MorningBoozeCheck"
369 "outputType" : "DIRECT",
371 "parentKeyName" : "MyFirstPolicy",
372 "parentKeyVersion" : "0.0.1",
373 "parentLocalName" : "BoozeAuthDecide",
374 "localName" : "MorningBoozeCheck_Output_Direct"
379 "name" : "MorningBoozeCheckAlt1",
384 "parentKeyName" : "MyFirstPolicy",
385 "parentKeyVersion" : "0.0.1",
386 "parentLocalName" : "BoozeAuthDecide",
387 "localName" : "MorningBoozeCheckAlt1"
389 "outputType" : "DIRECT",
391 "parentKeyName" : "MyFirstPolicy",
392 "parentKeyVersion" : "0.0.1",
393 "parentLocalName" : "BoozeAuthDecide",
394 "localName" : "MorningBoozeCheck_Output_Direct"
402 "firstState" : "BoozeAuthDecide"
409 "name" : "MyFirstPolicyModel_Tasks",
415 "name" : "MorningBoozeCheck",
420 "name" : "MorningBoozeCheck",
429 "name" : "price_type",
435 "key" : "assistant_ID",
437 "key" : "assistant_ID",
439 "name" : "assistant_ID_type",
449 "name" : "branch_ID_type",
459 "name" : "item_ID_type",
469 "name" : "notes_type",
479 "name" : "quantity_type",
489 "name" : "sale_ID_type",
499 "name" : "timestamp_type",
512 "name" : "price_type",
518 "key" : "assistant_ID",
520 "key" : "assistant_ID",
522 "name" : "assistant_ID_type",
528 "key" : "authorised",
530 "key" : "authorised",
532 "name" : "authorised_type",
542 "name" : "branch_ID_type",
552 "name" : "item_ID_type",
562 "name" : "message_type",
572 "name" : "notes_type",
582 "name" : "quantity_type",
592 "name" : "sale_ID_type",
602 "name" : "timestamp_type",
612 "contextAlbumReference" : [ ],
615 "logicFlavour" : "MVEL",
616 "logic" : "/*\n * ============LICENSE_START=======================================================\n * Copyright (C) 2016-2018 Ericsson. All rights reserved.\n * Modifications Copyright (C) 2020 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*/"
621 "name" : "MorningBoozeCheckAlt1",
626 "name" : "MorningBoozeCheckAlt1",
635 "name" : "price_type",
641 "key" : "assistant_ID",
643 "key" : "assistant_ID",
645 "name" : "assistant_ID_type",
655 "name" : "branch_ID_type",
665 "name" : "item_ID_type",
675 "name" : "notes_type",
685 "name" : "quantity_type",
695 "name" : "sale_ID_type",
705 "name" : "timestamp_type",
718 "name" : "price_type",
724 "key" : "assistant_ID",
726 "key" : "assistant_ID",
728 "name" : "assistant_ID_type",
734 "key" : "authorised",
736 "key" : "authorised",
738 "name" : "authorised_type",
748 "name" : "branch_ID_type",
758 "name" : "item_ID_type",
768 "name" : "message_type",
778 "name" : "notes_type",
788 "name" : "quantity_type",
798 "name" : "sale_ID_type",
808 "name" : "timestamp_type",
818 "contextAlbumReference" : [ ],
821 "logicFlavour" : "MVEL",
822 "logic" : "/*\n * ============LICENSE_START=======================================================\n * Copyright (C) 2016-2018 Ericsson. All rights reserved.\n * Modifications Copyright (C) 2020 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 Event: '\"+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 CET timezone!\ncet = TimeZone.getTimeZone(\"CET\");\ntimenow = Calendar.getInstance(cet);\ndf = new SimpleDateFormat(\"HH:mm:ss z\");\ndf.setTimeZone(cet);\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);\nonepm = timenow.clone();\nonepm.set(\n timenow.get(Calendar.YEAR),timenow.get(Calendar.MONTH),\n timenow.get(Calendar.DATE),13,0,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(onepm))\n ||\n (timenow.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY)\n )){\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(onepm.getTime()) +\" or on Sunday\");\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 CET and 13:00:00 CET then the sale is not authorised.\nAlso alcohol sales are not allowed on Sundays. Otherwise the sale is authorised.\nIn this implementation we assume that items with item_ID between 1000 and 2000 are all alcoholic drinks :-)\n*/"
830 "name" : "MyFirstPolicyModel_Events",
836 "name" : "SALE_AUTH",
841 "name" : "SALE_AUTH",
844 "nameSpace" : "com.hyperm",
853 "name" : "price_type",
859 "key" : "assistant_ID",
861 "key" : "assistant_ID",
863 "name" : "assistant_ID_type",
869 "key" : "authorised",
871 "key" : "authorised",
873 "name" : "authorised_type",
883 "name" : "branch_ID_type",
893 "name" : "item_ID_type",
903 "name" : "message_type",
913 "name" : "notes_type",
923 "name" : "quantity_type",
933 "name" : "sale_ID_type",
943 "name" : "timestamp_type",
953 "name" : "SALE_INPUT",
958 "name" : "SALE_INPUT",
961 "nameSpace" : "com.hyperm",
970 "name" : "price_type",
976 "key" : "assistant_ID",
978 "key" : "assistant_ID",
980 "name" : "assistant_ID_type",
990 "name" : "branch_ID_type",
1000 "name" : "item_ID_type",
1009 "fieldSchemaKey" : {
1010 "name" : "notes_type",
1019 "fieldSchemaKey" : {
1020 "name" : "quantity_type",
1029 "fieldSchemaKey" : {
1030 "name" : "sale_ID_type",
1039 "fieldSchemaKey" : {
1040 "name" : "timestamp_type",
1053 "name" : "MyFirstPolicyModel_Schemas",
1059 "name" : "assistant_ID_type",
1064 "name" : "assistant_ID_type",
1067 "schemaFlavour" : "Java",
1068 "schemaDefinition" : "java.lang.Long"
1072 "name" : "authorised_type",
1077 "name" : "authorised_type",
1080 "schemaFlavour" : "Java",
1081 "schemaDefinition" : "java.lang.Boolean"
1085 "name" : "branch_ID_type",
1090 "name" : "branch_ID_type",
1093 "schemaFlavour" : "Java",
1094 "schemaDefinition" : "java.lang.Long"
1098 "name" : "item_ID_type",
1103 "name" : "item_ID_type",
1106 "schemaFlavour" : "Java",
1107 "schemaDefinition" : "java.lang.Long"
1111 "name" : "message_type",
1116 "name" : "message_type",
1119 "schemaFlavour" : "Java",
1120 "schemaDefinition" : "java.lang.String"
1124 "name" : "notes_type",
1129 "name" : "notes_type",
1132 "schemaFlavour" : "Java",
1133 "schemaDefinition" : "java.lang.String"
1137 "name" : "price_type",
1142 "name" : "price_type",
1145 "schemaFlavour" : "Java",
1146 "schemaDefinition" : "java.lang.Long"
1150 "name" : "quantity_type",
1155 "name" : "quantity_type",
1158 "schemaFlavour" : "Java",
1159 "schemaDefinition" : "java.lang.Integer"
1163 "name" : "sale_ID_type",
1168 "name" : "sale_ID_type",
1171 "schemaFlavour" : "Java",
1172 "schemaDefinition" : "java.lang.Long"
1176 "name" : "timestamp_type",
1181 "name" : "timestamp_type",
1184 "schemaFlavour" : "Java",
1185 "schemaDefinition" : "java.lang.Long"