summaryrefslogtreecommitdiffstats
path: root/examples/examples-myfirstpolicy/src/main/resources/examples/models/MyFirstPolicy/1/MorningBoozeCheck.js
diff options
context:
space:
mode:
Diffstat (limited to 'examples/examples-myfirstpolicy/src/main/resources/examples/models/MyFirstPolicy/1/MorningBoozeCheck.js')
-rw-r--r--examples/examples-myfirstpolicy/src/main/resources/examples/models/MyFirstPolicy/1/MorningBoozeCheck.js19
1 files changed, 10 insertions, 9 deletions
diff --git a/examples/examples-myfirstpolicy/src/main/resources/examples/models/MyFirstPolicy/1/MorningBoozeCheck.js b/examples/examples-myfirstpolicy/src/main/resources/examples/models/MyFirstPolicy/1/MorningBoozeCheck.js
index 8ec15a992..359bbd425 100644
--- a/examples/examples-myfirstpolicy/src/main/resources/examples/models/MyFirstPolicy/1/MorningBoozeCheck.js
+++ b/examples/examples-myfirstpolicy/src/main/resources/examples/models/MyFirstPolicy/1/MorningBoozeCheck.js
@@ -1,19 +1,20 @@
/*
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 2020 Nordix Foundation.
* ================================================================================
* 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=========================================================
*/
@@ -21,7 +22,7 @@
var returnValueType = Java.type("java.lang.Boolean");
var returnValue = new returnValueType(true);
-// Load compatibility script for imports etc
+// Load compatibility script for imports etc
load("nashorn:mozilla_compat.js");
importPackage(java.text);
importClass(java.text.SimpleDateFormat);
@@ -39,7 +40,7 @@ executor.outFields.put("sale_ID" , executor.inFields.get("sale_ID"));
item_id = executor.inFields.get("item_ID");
-//All times in this script are in GMT/UTC since the policy and events assume time is in GMT.
+//All times in this script are in GMT/UTC since the policy and events assume time is in GMT.
var timenow_gmt = new Date(Number(executor.inFields.get("time")));
var midnight_gmt = new Date(Number(executor.inFields.get("time")));
@@ -53,7 +54,7 @@ var timeformatter = new java.text.SimpleDateFormat("HH:mm:ss z");
var itemisalcohol = false;
if(item_id != null && item_id >=1000 && item_id < 2000)
itemisalcohol = true;
-
+
if( itemisalcohol
&& timenow_gmt.getTime() >= midnight_gmt.getTime()
&& timenow_gmt.getTime() < eleven30_gmt.getTime()) {
@@ -66,14 +67,14 @@ if( itemisalcohol
}
else{
executor.outFields.put("authorised", true);
- executor.outFields.put("message", "Sale authorised by policy task " +
+ executor.outFields.put("message", "Sale authorised by policy task " +
executor.subject.taskName + " for time "+timeformatter.format(timenow_gmt.getTime()));
}
/*
This task checks if a sale request is for an item that is an alcoholic drink.
If the local time is between 00:00:00 GMT and 11:30:00 GMT then the sale is not
-authorised. Otherwise the sale is authorised.
-In this implementation we assume that items with item_ID value between 1000 and
+authorised. Otherwise the sale is authorised.
+In this implementation we assume that items with item_ID value between 1000 and
2000 are all alcoholic drinks :-)
*/