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_Albums",
72 "name" : "MyFirstPolicyModel_Albums",
75 "UUID" : "3f70ec50-f896-31ba-afec-5fd47e69045b",
76 "description" : "Generated description for concept referred to by key \"MyFirstPolicyModel_Albums:0.0.1\""
80 "name" : "MyFirstPolicyModel_Events",
85 "name" : "MyFirstPolicyModel_Events",
88 "UUID" : "ef281318-5ac9-3ef0-8db3-8f9c4e4a81e2",
89 "description" : "Generated description for concept referred to by key \"MyFirstPolicyModel_Events:0.0.1\""
93 "name" : "MyFirstPolicyModel_KeyInfo",
98 "name" : "MyFirstPolicyModel_KeyInfo",
101 "UUID" : "d9248c6f-7c00-38df-8251-611463ba4065",
102 "description" : "Generated description for concept referred to by key \"MyFirstPolicyModel_KeyInfo:0.0.1\""
106 "name" : "MyFirstPolicyModel_Policies",
111 "name" : "MyFirstPolicyModel_Policies",
114 "UUID" : "77c01a6b-510c-3aa9-b640-b4db356aa03b",
115 "description" : "Generated description for concept referred to by key \"MyFirstPolicyModel_Policies:0.0.1\""
119 "name" : "MyFirstPolicyModel_Schemas",
124 "name" : "MyFirstPolicyModel_Schemas",
127 "UUID" : "d0cc3aa0-ea69-3a43-80ff-a0dbb0ebd885",
128 "description" : "Generated description for concept referred to by key \"MyFirstPolicyModel_Schemas:0.0.1\""
132 "name" : "MyFirstPolicyModel_Tasks",
137 "name" : "MyFirstPolicyModel_Tasks",
140 "UUID" : "b02a7e02-2cd0-39e6-b3cb-946fa83a8f08",
141 "description" : "Generated description for concept referred to by key \"MyFirstPolicyModel_Tasks:0.0.1\""
145 "name" : "SALE_AUTH",
150 "name" : "SALE_AUTH",
153 "UUID" : "c4500941-3f98-4080-a9cc-5b9753ed050b",
154 "description" : "An event emitted by the Policy to indicate whether the sale of an item has been authorised"
158 "name" : "SALE_INPUT",
163 "name" : "SALE_INPUT",
166 "UUID" : "4f04aa98-e917-4f4a-882a-c75ba5a99374",
167 "description" : "An event raised by the PoS system each time an item is scanned for purchase"
171 "name" : "assistant_ID_type",
176 "name" : "assistant_ID_type",
179 "UUID" : "36df4c71-9616-4206-8b53-976a5cd4bd87",
180 "description" : "A type for 'assistant_ID' values"
184 "name" : "authorised_type",
189 "name" : "authorised_type",
192 "UUID" : "d48b619e-d00d-4008-b884-02d76ea4350b",
193 "description" : "A type for 'authorised' values"
197 "name" : "branch_ID_type",
202 "name" : "branch_ID_type",
205 "UUID" : "6468845f-4122-4128-8e49-0f52c26078b5",
206 "description" : "A type for 'branch_ID' values"
210 "name" : "item_ID_type",
215 "name" : "item_ID_type",
218 "UUID" : "4f227ff1-aee0-453a-b6b6-9a4b2e0da932",
219 "description" : "A type for 'item_ID' values"
223 "name" : "message_type",
228 "name" : "message_type",
231 "UUID" : "ad1431bb-3155-4e73-b5a3-b89bee498749",
232 "description" : "A type for 'message' values"
236 "name" : "notes_type",
241 "name" : "notes_type",
244 "UUID" : "eecfde90-896c-4343-8f9c-2603ced94e2d",
245 "description" : "A type for 'notes' values"
249 "name" : "price_type",
254 "name" : "price_type",
257 "UUID" : "52c2fc45-fd8c-463c-bd6f-d91b0554aea7",
258 "description" : "A type for 'amount'/'price' values"
262 "name" : "quantity_type",
267 "name" : "quantity_type",
270 "UUID" : "ac3d9842-80af-4a98-951c-bd79a431c613",
271 "description" : "A type for 'quantity' values"
275 "name" : "sale_ID_type",
280 "name" : "sale_ID_type",
283 "UUID" : "cca47d74-7754-4a61-b163-ca31f66b157b",
284 "description" : "A type for 'sale_ID' values"
288 "name" : "timestamp_type",
293 "name" : "timestamp_type",
296 "UUID" : "fd594e88-411d-4a94-b2be-697b3a0d7adf",
297 "description" : "A type for 'time' values"
304 "name" : "MyFirstPolicyModel_Policies",
310 "name" : "MyFirstPolicy",
315 "name" : "MyFirstPolicy",
318 "template" : "FREEFORM",
321 "key" : "BoozeAuthDecide",
324 "parentKeyName" : "MyFirstPolicy",
325 "parentKeyVersion" : "0.0.1",
326 "parentLocalName" : "NULL",
327 "localName" : "BoozeAuthDecide"
330 "name" : "SALE_INPUT",
335 "key" : "MorningBoozeCheck_Output_Direct",
338 "parentKeyName" : "MyFirstPolicy",
339 "parentKeyVersion" : "0.0.1",
340 "parentLocalName" : "BoozeAuthDecide",
341 "localName" : "MorningBoozeCheck_Output_Direct"
344 "name" : "SALE_AUTH",
348 "parentKeyName" : "NULL",
349 "parentKeyVersion" : "0.0.0",
350 "parentLocalName" : "NULL",
356 "contextAlbumReference" : [ ],
357 "taskSelectionLogic" : {
358 "key" : "TaskSelectionLogic",
359 "logicFlavour" : "JAVASCRIPT",
360 "logic" : "/* * ============LICENSE_START======================================================= * Copyright (C) 2016-2018 Ericsson. 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. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an \"AS IS\" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * SPDX-License-Identifier: Apache-2.0 * ============LICENSE_END========================================================= */var returnValueType = Java.type(\"java.lang.Boolean\");\nvar returnValue = new returnValueType(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*/"
362 "stateFinalizerLogicMap" : {
366 "name" : "MorningBoozeCheck",
372 "name" : "MorningBoozeCheck",
377 "parentKeyName" : "MyFirstPolicy",
378 "parentKeyVersion" : "0.0.1",
379 "parentLocalName" : "BoozeAuthDecide",
380 "localName" : "MorningBoozeCheck"
382 "outputType" : "DIRECT",
384 "parentKeyName" : "MyFirstPolicy",
385 "parentKeyVersion" : "0.0.1",
386 "parentLocalName" : "BoozeAuthDecide",
387 "localName" : "MorningBoozeCheck_Output_Direct"
392 "name" : "MorningBoozeCheckAlt1",
397 "parentKeyName" : "MyFirstPolicy",
398 "parentKeyVersion" : "0.0.1",
399 "parentLocalName" : "BoozeAuthDecide",
400 "localName" : "MorningBoozeCheckAlt1"
402 "outputType" : "DIRECT",
404 "parentKeyName" : "MyFirstPolicy",
405 "parentKeyVersion" : "0.0.1",
406 "parentLocalName" : "BoozeAuthDecide",
407 "localName" : "MorningBoozeCheck_Output_Direct"
415 "firstState" : "BoozeAuthDecide"
422 "name" : "MyFirstPolicyModel_Tasks",
428 "name" : "MorningBoozeCheck",
433 "name" : "MorningBoozeCheck",
442 "name" : "price_type",
448 "key" : "assistant_ID",
450 "key" : "assistant_ID",
452 "name" : "assistant_ID_type",
462 "name" : "branch_ID_type",
472 "name" : "item_ID_type",
482 "name" : "notes_type",
492 "name" : "quantity_type",
502 "name" : "sale_ID_type",
512 "name" : "timestamp_type",
525 "name" : "price_type",
531 "key" : "assistant_ID",
533 "key" : "assistant_ID",
535 "name" : "assistant_ID_type",
541 "key" : "authorised",
543 "key" : "authorised",
545 "name" : "authorised_type",
555 "name" : "branch_ID_type",
565 "name" : "item_ID_type",
575 "name" : "message_type",
585 "name" : "notes_type",
595 "name" : "quantity_type",
605 "name" : "sale_ID_type",
615 "name" : "timestamp_type",
625 "contextAlbumReference" : [ ],
628 "logicFlavour" : "MVEL",
629 "logic" : "/*\n * ============LICENSE_START=======================================================\n * Copyright (C) 2016-2018 Ericsson. All rights reserved.\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*/"
634 "name" : "MorningBoozeCheckAlt1",
639 "name" : "MorningBoozeCheckAlt1",
648 "name" : "price_type",
654 "key" : "assistant_ID",
656 "key" : "assistant_ID",
658 "name" : "assistant_ID_type",
668 "name" : "branch_ID_type",
678 "name" : "item_ID_type",
688 "name" : "notes_type",
698 "name" : "quantity_type",
708 "name" : "sale_ID_type",
718 "name" : "timestamp_type",
731 "name" : "price_type",
737 "key" : "assistant_ID",
739 "key" : "assistant_ID",
741 "name" : "assistant_ID_type",
747 "key" : "authorised",
749 "key" : "authorised",
751 "name" : "authorised_type",
761 "name" : "branch_ID_type",
771 "name" : "item_ID_type",
781 "name" : "message_type",
791 "name" : "notes_type",
801 "name" : "quantity_type",
811 "name" : "sale_ID_type",
821 "name" : "timestamp_type",
831 "contextAlbumReference" : [ ],
834 "logicFlavour" : "MVEL",
835 "logic" : "/*\n * ============LICENSE_START=======================================================\n * Copyright (C) 2016-2018 Ericsson. All rights reserved.\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*/"
843 "name" : "MyFirstPolicyModel_Events",
849 "name" : "SALE_AUTH",
854 "name" : "SALE_AUTH",
857 "nameSpace" : "com.hyperm",
866 "name" : "price_type",
872 "key" : "assistant_ID",
874 "key" : "assistant_ID",
876 "name" : "assistant_ID_type",
882 "key" : "authorised",
884 "key" : "authorised",
886 "name" : "authorised_type",
896 "name" : "branch_ID_type",
906 "name" : "item_ID_type",
916 "name" : "message_type",
926 "name" : "notes_type",
936 "name" : "quantity_type",
946 "name" : "sale_ID_type",
956 "name" : "timestamp_type",
966 "name" : "SALE_INPUT",
971 "name" : "SALE_INPUT",
974 "nameSpace" : "com.hyperm",
983 "name" : "price_type",
989 "key" : "assistant_ID",
991 "key" : "assistant_ID",
993 "name" : "assistant_ID_type",
1001 "key" : "branch_ID",
1002 "fieldSchemaKey" : {
1003 "name" : "branch_ID_type",
1012 "fieldSchemaKey" : {
1013 "name" : "item_ID_type",
1022 "fieldSchemaKey" : {
1023 "name" : "notes_type",
1032 "fieldSchemaKey" : {
1033 "name" : "quantity_type",
1042 "fieldSchemaKey" : {
1043 "name" : "sale_ID_type",
1052 "fieldSchemaKey" : {
1053 "name" : "timestamp_type",
1066 "name" : "MyFirstPolicyModel_Albums",
1075 "name" : "MyFirstPolicyModel_Schemas",
1081 "name" : "assistant_ID_type",
1086 "name" : "assistant_ID_type",
1089 "schemaFlavour" : "Java",
1090 "schemaDefinition" : "java.lang.Long"
1094 "name" : "authorised_type",
1099 "name" : "authorised_type",
1102 "schemaFlavour" : "Java",
1103 "schemaDefinition" : "java.lang.Boolean"
1107 "name" : "branch_ID_type",
1112 "name" : "branch_ID_type",
1115 "schemaFlavour" : "Java",
1116 "schemaDefinition" : "java.lang.Long"
1120 "name" : "item_ID_type",
1125 "name" : "item_ID_type",
1128 "schemaFlavour" : "Java",
1129 "schemaDefinition" : "java.lang.Long"
1133 "name" : "message_type",
1138 "name" : "message_type",
1141 "schemaFlavour" : "Java",
1142 "schemaDefinition" : "java.lang.String"
1146 "name" : "notes_type",
1151 "name" : "notes_type",
1154 "schemaFlavour" : "Java",
1155 "schemaDefinition" : "java.lang.String"
1159 "name" : "price_type",
1164 "name" : "price_type",
1167 "schemaFlavour" : "Java",
1168 "schemaDefinition" : "java.lang.Long"
1172 "name" : "quantity_type",
1177 "name" : "quantity_type",
1180 "schemaFlavour" : "Java",
1181 "schemaDefinition" : "java.lang.Integer"
1185 "name" : "sale_ID_type",
1190 "name" : "sale_ID_type",
1193 "schemaFlavour" : "Java",
1194 "schemaDefinition" : "java.lang.Long"
1198 "name" : "timestamp_type",
1203 "name" : "timestamp_type",
1206 "schemaFlavour" : "Java",
1207 "schemaDefinition" : "java.lang.Long"