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" : "MyFirstPolicy",
33 "name" : "MyFirstPolicy",
36 "UUID" : "6c5e410f-489a-46ff-964e-982ce6e8b6d0",
37 "description" : "This is my first Apex policy. It checks if a sale should be authorised or not."
41 "name" : "MyFirstPolicyModel",
46 "name" : "MyFirstPolicyModel",
49 "UUID" : "540226fb-55ee-4f0e-a444-983a0494818e",
50 "description" : "This is my first Apex Policy Model."
54 "name" : "MyFirstPolicyModel_Albums",
59 "name" : "MyFirstPolicyModel_Albums",
62 "UUID" : "3f70ec50-f896-31ba-afec-5fd47e69045b",
63 "description" : "Generated description for concept referred to by key \"MyFirstPolicyModel_Albums:0.0.1\""
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" : {
346 "logicFlavour" : "UNDEFINED",
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"
382 "firstState" : "BoozeAuthDecide"
389 "name" : "MyFirstPolicyModel_Tasks",
395 "name" : "MorningBoozeCheck",
400 "name" : "MorningBoozeCheck",
409 "name" : "price_type",
415 "key" : "assistant_ID",
417 "key" : "assistant_ID",
419 "name" : "assistant_ID_type",
429 "name" : "branch_ID_type",
439 "name" : "item_ID_type",
449 "name" : "notes_type",
459 "name" : "quantity_type",
469 "name" : "sale_ID_type",
479 "name" : "timestamp_type",
492 "name" : "price_type",
498 "key" : "assistant_ID",
500 "key" : "assistant_ID",
502 "name" : "assistant_ID_type",
508 "key" : "authorised",
510 "key" : "authorised",
512 "name" : "authorised_type",
522 "name" : "branch_ID_type",
532 "name" : "item_ID_type",
542 "name" : "message_type",
552 "name" : "notes_type",
562 "name" : "quantity_type",
572 "name" : "sale_ID_type",
582 "name" : "timestamp_type",
592 "contextAlbumReference" : [ ],
595 "logicFlavour" : "MVEL",
596 "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*/"
604 "name" : "MyFirstPolicyModel_Events",
610 "name" : "SALE_AUTH",
615 "name" : "SALE_AUTH",
618 "nameSpace" : "com.hyperm",
627 "name" : "price_type",
633 "key" : "assistant_ID",
635 "key" : "assistant_ID",
637 "name" : "assistant_ID_type",
643 "key" : "authorised",
645 "key" : "authorised",
647 "name" : "authorised_type",
657 "name" : "branch_ID_type",
667 "name" : "item_ID_type",
677 "name" : "message_type",
687 "name" : "notes_type",
697 "name" : "quantity_type",
707 "name" : "sale_ID_type",
717 "name" : "timestamp_type",
727 "name" : "SALE_INPUT",
732 "name" : "SALE_INPUT",
735 "nameSpace" : "com.hyperm",
744 "name" : "price_type",
750 "key" : "assistant_ID",
752 "key" : "assistant_ID",
754 "name" : "assistant_ID_type",
764 "name" : "branch_ID_type",
774 "name" : "item_ID_type",
784 "name" : "notes_type",
794 "name" : "quantity_type",
804 "name" : "sale_ID_type",
814 "name" : "timestamp_type",
827 "name" : "MyFirstPolicyModel_Albums",
836 "name" : "MyFirstPolicyModel_Schemas",
842 "name" : "assistant_ID_type",
847 "name" : "assistant_ID_type",
850 "schemaFlavour" : "Java",
851 "schemaDefinition" : "java.lang.Long"
855 "name" : "authorised_type",
860 "name" : "authorised_type",
863 "schemaFlavour" : "Java",
864 "schemaDefinition" : "java.lang.Boolean"
868 "name" : "branch_ID_type",
873 "name" : "branch_ID_type",
876 "schemaFlavour" : "Java",
877 "schemaDefinition" : "java.lang.Long"
881 "name" : "item_ID_type",
886 "name" : "item_ID_type",
889 "schemaFlavour" : "Java",
890 "schemaDefinition" : "java.lang.Long"
894 "name" : "message_type",
899 "name" : "message_type",
902 "schemaFlavour" : "Java",
903 "schemaDefinition" : "java.lang.String"
907 "name" : "notes_type",
912 "name" : "notes_type",
915 "schemaFlavour" : "Java",
916 "schemaDefinition" : "java.lang.String"
920 "name" : "price_type",
925 "name" : "price_type",
928 "schemaFlavour" : "Java",
929 "schemaDefinition" : "java.lang.Long"
933 "name" : "quantity_type",
938 "name" : "quantity_type",
941 "schemaFlavour" : "Java",
942 "schemaDefinition" : "java.lang.Integer"
946 "name" : "sale_ID_type",
951 "name" : "sale_ID_type",
954 "schemaFlavour" : "Java",
955 "schemaDefinition" : "java.lang.Long"
959 "name" : "timestamp_type",
964 "name" : "timestamp_type",
967 "schemaFlavour" : "Java",
968 "schemaDefinition" : "java.lang.Long"