aboutsummaryrefslogtreecommitdiffstats
path: root/examples/myfirstpolicy
diff options
context:
space:
mode:
Diffstat (limited to 'examples/myfirstpolicy')
-rw-r--r--examples/myfirstpolicy/pom.xml109
-rw-r--r--examples/myfirstpolicy/src/main/java/org/onap/policy/apex/examples/myfirstpolicy/model/MFPDomainModelFactory.java86
-rw-r--r--examples/myfirstpolicy/src/main/java/org/onap/policy/apex/examples/myfirstpolicy/model/MFPDomainModelSaver.java62
-rw-r--r--examples/myfirstpolicy/src/main/java/org/onap/policy/apex/examples/myfirstpolicy/model/package-info.java27
-rw-r--r--examples/myfirstpolicy/src/main/resources/SampleData/csv/AssistantInput.csv7
-rw-r--r--examples/myfirstpolicy/src/main/resources/SampleData/csv/BranchInput.csv8
-rw-r--r--examples/myfirstpolicy/src/main/resources/SampleData/csv/ItemInput.csv6
-rw-r--r--examples/myfirstpolicy/src/main/resources/SampleData/csv/SalesInput.csv45
-rw-r--r--examples/myfirstpolicy/src/main/resources/SampleData/sql/apex_sales.sql232
-rw-r--r--examples/myfirstpolicy/src/main/resources/SampleData/sql/readme.txt31
-rw-r--r--examples/myfirstpolicy/src/main/resources/examples/events/MyFirstPolicy/1/EventIn_BoozeItem_084106GMT.json12
-rw-r--r--examples/myfirstpolicy/src/main/resources/examples/events/MyFirstPolicy/1/EventIn_BoozeItem_201713GMT.json12
-rw-r--r--examples/myfirstpolicy/src/main/resources/examples/events/MyFirstPolicy/1/EventIn_NonBoozeItem_101309GMT.json13
-rw-r--r--examples/myfirstpolicy/src/main/resources/examples/events/MyFirstPolicy/1/EventOut_BoozeItem_084106GMT.json17
-rw-r--r--examples/myfirstpolicy/src/main/resources/examples/events/MyFirstPolicy/1/EventOut_BoozeItem_201713GMT.json17
-rw-r--r--examples/myfirstpolicy/src/main/resources/examples/events/MyFirstPolicy/1/EventOut_NonBoozeItem_101309GMT.json17
-rw-r--r--examples/myfirstpolicy/src/main/resources/examples/events/MyFirstPolicy/1/EventsIn.json.txt37
-rw-r--r--examples/myfirstpolicy/src/main/resources/examples/events/MyFirstPolicy/1/EventsOut.json.txt51
-rw-r--r--examples/myfirstpolicy/src/main/resources/examples/events/MyFirstPolicy/2/EventIn_BoozeItem_101433CET_thurs.json12
-rw-r--r--examples/myfirstpolicy/src/main/resources/examples/events/MyFirstPolicy/2/EventIn_BoozeItem_171937CET_sun.json13
-rw-r--r--examples/myfirstpolicy/src/main/resources/examples/events/MyFirstPolicy/2/EventIn_NonBoozeItem_111309CET_mon.json13
-rw-r--r--examples/myfirstpolicy/src/main/resources/examples/events/MyFirstPolicy/2/EventOut_BoozeItem_101433CET_thurs.json17
-rw-r--r--examples/myfirstpolicy/src/main/resources/examples/events/MyFirstPolicy/2/EventOut_BoozeItem_171937CET_sun.json17
-rw-r--r--examples/myfirstpolicy/src/main/resources/examples/events/MyFirstPolicy/2/EventOut_NonBoozeItem_111309CET_mon.json17
-rw-r--r--examples/myfirstpolicy/src/main/resources/examples/events/MyFirstPolicy/2/EventsIn.json.txt75
-rw-r--r--examples/myfirstpolicy/src/main/resources/examples/events/MyFirstPolicy/2/EventsOut.json.txt102
-rw-r--r--examples/myfirstpolicy/src/main/resources/examples/models/MyFirstPolicy/1/MorningBoozeCheck.js79
-rw-r--r--examples/myfirstpolicy/src/main/resources/examples/models/MyFirstPolicy/1/MorningBoozeCheck.mvel80
-rw-r--r--examples/myfirstpolicy/src/main/resources/examples/models/MyFirstPolicy/1/MyFirstPolicyModel_0.0.1.alt.json974
-rw-r--r--examples/myfirstpolicy/src/main/resources/examples/models/MyFirstPolicy/1/MyFirstPolicyModel_0.0.1.apex178
-rw-r--r--examples/myfirstpolicy/src/main/resources/examples/models/MyFirstPolicy/1/MyFirstPolicyModel_0.0.1.json974
-rw-r--r--examples/myfirstpolicy/src/main/resources/examples/models/MyFirstPolicy/2/MorningBoozeCheck.mvel76
-rw-r--r--examples/myfirstpolicy/src/main/resources/examples/models/MyFirstPolicy/2/MorningBoozeCheckAlt1.mvel82
-rw-r--r--examples/myfirstpolicy/src/main/resources/examples/models/MyFirstPolicy/2/MyFirstPolicyModel_0.0.1.apex333
-rw-r--r--examples/myfirstpolicy/src/main/resources/examples/models/MyFirstPolicy/2/MyFirstPolicyModel_0.0.1.json1213
-rw-r--r--examples/myfirstpolicy/src/main/resources/examples/models/MyFirstPolicy/2/MyFirstPolicy_BoozeAuthDecideTSL.js48
-rw-r--r--examples/myfirstpolicy/src/main/resources/org/onap/policy/apex/examples/myfirstpolicy/1/config/MyFirstPolicyConfigStdin2StdoutJsonEvent.json46
-rw-r--r--examples/myfirstpolicy/src/main/resources/org/onap/policy/apex/examples/myfirstpolicy/1/config/MyFirstPolicyConfigWs2WsServerJsonEvent.json50
-rw-r--r--examples/myfirstpolicy/src/main/resources/org/onap/policy/apex/examples/myfirstpolicy/2/config/MyFirstPolicyConfigStdin2StdoutJsonEvent.json46
-rw-r--r--examples/myfirstpolicy/src/main/resources/org/onap/policy/apex/examples/myfirstpolicy/2/config/MyFirstPolicyConfigWs2WsServerJsonEvent.json50
-rw-r--r--examples/myfirstpolicy/src/test/java/org/onap/policy/apex/examples/myfirstpolicy/TestMFPLogic.java183
-rw-r--r--examples/myfirstpolicy/src/test/java/org/onap/policy/apex/examples/myfirstpolicy/TestMFPModel.java106
-rw-r--r--examples/myfirstpolicy/src/test/java/org/onap/policy/apex/examples/myfirstpolicy/TestMFPModelCLI.java96
-rw-r--r--examples/myfirstpolicy/src/test/java/org/onap/policy/apex/examples/myfirstpolicy/TestMFPModelCreator.java106
-rw-r--r--examples/myfirstpolicy/src/test/java/org/onap/policy/apex/examples/myfirstpolicy/TestMFPUseCase.java331
-rw-r--r--examples/myfirstpolicy/src/test/java/org/onap/policy/apex/examples/myfirstpolicy/TestSaleAuthListener.java93
-rw-r--r--examples/myfirstpolicy/src/test/resources/META-INF/persistence.xml69
-rw-r--r--examples/myfirstpolicy/src/test/resources/logback-test.xml74
48 files changed, 0 insertions, 6342 deletions
diff --git a/examples/myfirstpolicy/pom.xml b/examples/myfirstpolicy/pom.xml
deleted file mode 100644
index 56a9fe40a..000000000
--- a/examples/myfirstpolicy/pom.xml
+++ /dev/null
@@ -1,109 +0,0 @@
-<!--
- ============LICENSE_START=======================================================
- Copyright (C) 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=========================================================
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>org.onap.policy.apex-pdp.examples</groupId>
- <artifactId>examples</artifactId>
- <version>2.0.0-SNAPSHOT</version>
- </parent>
-
- <artifactId>myfirstpolicy</artifactId>
- <name>${project.artifactId}</name>
- <description>Specific code for the Apex MyFirstPolicy Example</description>
-
- <properties>
- <apex-domains-myfirstpolicy-dir>${project.basedir}/src</apex-domains-myfirstpolicy-dir>
- </properties>
-
- <dependencies>
- <dependency>
- <groupId>org.onap.policy.apex-pdp.model</groupId>
- <artifactId>policy-model</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.onap.policy.apex-pdp.core</groupId>
- <artifactId>core-engine</artifactId>
- <version>${project.version}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.onap.policy.apex-pdp.core</groupId>
- <artifactId>core-infrastructure</artifactId>
- <version>${project.version}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.onap.policy.apex-pdp.auth</groupId>
- <artifactId>cli-editor</artifactId>
- <version>${project.version}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.onap.policy.apex-pdp.plugins.plugins-executor</groupId>
- <artifactId>plugins-executor-mvel</artifactId>
- <version>${project.version}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.onap.policy.apex-pdp.plugins.plugins-executor</groupId>
- <artifactId>plugins-executor-javascript</artifactId>
- <version>${project.version}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.derby</groupId>
- <artifactId>derby</artifactId>
- <version>${version.derby}</version>
- <scope>test</scope>
- </dependency>
- </dependencies>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>exec-maven-plugin</artifactId>
- <executions>
- <execution>
- <id>generate-models</id>
- <phase>process-classes</phase>
- <goals>
- <goal>exec</goal>
- </goals>
- <configuration>
- <executable>java</executable>
- <arguments>
- <argument>-classpath</argument>
- <!-- automatically creates the classpath using all project dependencies,
- also adding the project build directory -->
- <classpath />
- <argument>org.onap.policy.apex.examples.myfirstpolicy.model.MFPDomainModelSaver</argument>
- <argument>${project.build.directory}/classes/examples/models/MyFirstPolicy</argument>
- </arguments>
- </configuration>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
-</project> \ No newline at end of file
diff --git a/examples/myfirstpolicy/src/main/java/org/onap/policy/apex/examples/myfirstpolicy/model/MFPDomainModelFactory.java b/examples/myfirstpolicy/src/main/java/org/onap/policy/apex/examples/myfirstpolicy/model/MFPDomainModelFactory.java
deleted file mode 100644
index 9b3f6cc8a..000000000
--- a/examples/myfirstpolicy/src/main/java/org/onap/policy/apex/examples/myfirstpolicy/model/MFPDomainModelFactory.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*-
- * ============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=========================================================
- */
-
-package org.onap.policy.apex.examples.myfirstpolicy.model;
-
-import org.onap.policy.apex.model.basicmodel.concepts.ApexRuntimeException;
-import org.onap.policy.apex.model.basicmodel.handling.ApexModelReader;
-import org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel;
-import org.onap.policy.apex.model.utilities.ResourceUtils;
-
-/**
- * A factory for creating MFPDomainModel objects.
- *
- * @author John Keeney (john.keeney@ericsson.com)
- */
-public class MFPDomainModelFactory {
-
- private static final String MFP1PATH = "examples/models/MyFirstPolicy/1/MyFirstPolicyModel_0.0.1.json";
- private static final String MFP1_ALT_PATH = "examples/models/MyFirstPolicy/1/MyFirstPolicyModel_0.0.1.alt.json";
- private static final String MFP2PATH = "examples/models/MyFirstPolicy/2/MyFirstPolicyModel_0.0.1.json";
-
- /**
- * Gets the MyFirstPolicy#1 policy model.
- *
- * @return the MyFirstPolicy#1 policy model
- */
- public AxPolicyModel getMFP1PolicyModel() {
- java.util.TimeZone.getTimeZone("gmt");
- try {
- final ApexModelReader<AxPolicyModel> reader = new ApexModelReader<>(AxPolicyModel.class);
- return reader.read(ResourceUtils.getResourceAsString(MFPDomainModelFactory.MFP1PATH));
- } catch (final Exception e) {
- throw new ApexRuntimeException("Failed to build MyFirstPolicy from path: " + MFPDomainModelFactory.MFP1PATH,
- e);
- }
- }
-
- /**
- * Gets the MyFirstPolicy#1 policy model, with alternate JavaScript task logic.
- *
- * @return the MyFirstPolicy#1 policy model
- */
- public AxPolicyModel getMFP1AltPolicyModel() {
- java.util.TimeZone.getTimeZone("gmt");
- try {
- final ApexModelReader<AxPolicyModel> reader = new ApexModelReader<>(AxPolicyModel.class);
- return reader.read(ResourceUtils.getResourceAsString(MFPDomainModelFactory.MFP1_ALT_PATH));
- } catch (final Exception e) {
- throw new ApexRuntimeException(
- "Failed to build MyFirstPolicy_ALT from path: " + MFPDomainModelFactory.MFP1_ALT_PATH, e);
- }
- }
-
- /**
- * Gets the MyFirstPolicy#1 policy model.
- *
- * @return the MyFirstPolicy#1 policy model
- */
- public AxPolicyModel getMFP2PolicyModel() {
- try {
- final ApexModelReader<AxPolicyModel> reader = new ApexModelReader<>(AxPolicyModel.class);
- return reader.read(ResourceUtils.getResourceAsString(MFPDomainModelFactory.MFP2PATH));
- } catch (final Exception e) {
- throw new ApexRuntimeException("Failed to build MyFirstPolicy from path: " + MFPDomainModelFactory.MFP2PATH,
- e);
- }
- }
-
-}
diff --git a/examples/myfirstpolicy/src/main/java/org/onap/policy/apex/examples/myfirstpolicy/model/MFPDomainModelSaver.java b/examples/myfirstpolicy/src/main/java/org/onap/policy/apex/examples/myfirstpolicy/model/MFPDomainModelSaver.java
deleted file mode 100644
index 7343f747d..000000000
--- a/examples/myfirstpolicy/src/main/java/org/onap/policy/apex/examples/myfirstpolicy/model/MFPDomainModelSaver.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*-
- * ============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=========================================================
- */
-
-package org.onap.policy.apex.examples.myfirstpolicy.model;
-
-import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
-import org.onap.policy.apex.model.basicmodel.handling.ApexModelSaver;
-import org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel;
-
-/**
- * The Class MFPDomainModelSaver.
- *
- * @author John Keeney (john.keeney@ericsson.com)
- */
-public final class MFPDomainModelSaver {
-
- /** Private constructor to prevent instantiation. */
- private MFPDomainModelSaver() {}
-
- /**
- * Write the MyFirstPolicy model to args[0].
- *
- * @param args uses <code>arg[0]</code> for directory information
- * @throws ApexException the apex exception
- */
- public static void main(final String[] args) throws ApexException {
- if (args.length != 1) {
- System.err.println("usage: " + MFPDomainModelSaver.class.getCanonicalName() + " modelDirectory");
- return;
- }
-
- // Save Java model
- AxPolicyModel mfpPolicyModel = new MFPDomainModelFactory().getMFP1PolicyModel();
- ApexModelSaver<AxPolicyModel> mfpModelSaver =
- new ApexModelSaver<>(AxPolicyModel.class, mfpPolicyModel, args[0] + "/1/");
- mfpModelSaver.apexModelWriteJSON();
- mfpModelSaver.apexModelWriteXML();
-
- mfpPolicyModel = new MFPDomainModelFactory().getMFP2PolicyModel();
- mfpModelSaver = new ApexModelSaver<>(AxPolicyModel.class, mfpPolicyModel, args[0] + "/2/");
- mfpModelSaver.apexModelWriteJSON();
- mfpModelSaver.apexModelWriteXML();
-
- }
-}
diff --git a/examples/myfirstpolicy/src/main/java/org/onap/policy/apex/examples/myfirstpolicy/model/package-info.java b/examples/myfirstpolicy/src/main/java/org/onap/policy/apex/examples/myfirstpolicy/model/package-info.java
deleted file mode 100644
index ed03da4ca..000000000
--- a/examples/myfirstpolicy/src/main/java/org/onap/policy/apex/examples/myfirstpolicy/model/package-info.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*-
- * ============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=========================================================
- */
-
-/**
- * Contains the model for My-First-Policy.
- *
- * @author John Keeney (john.keeney@ericsson.com)
- */
-
-package org.onap.policy.apex.examples.myfirstpolicy.model;
diff --git a/examples/myfirstpolicy/src/main/resources/SampleData/csv/AssistantInput.csv b/examples/myfirstpolicy/src/main/resources/SampleData/csv/AssistantInput.csv
deleted file mode 100644
index cd59d06c4..000000000
--- a/examples/myfirstpolicy/src/main/resources/SampleData/csv/AssistantInput.csv
+++ /dev/null
@@ -1,7 +0,0 @@
-AssistantID,Surname,Firstname,Middlename,Age,Grade,PhoneNo
-1222,Citizen,Sean,Tadhg,23,3,871234321
-126,Doe,Jane,Donna,56,2,861234567
-13213,Svensson,Sven,Lars,72,1,854323456
-22,Bloggs,Joe,John,19,3,839877654
-33,Yamada,Taro,Nanno,34,3,892344333
-343,Mustermann,Max,Fritz,21,2,887655432 \ No newline at end of file
diff --git a/examples/myfirstpolicy/src/main/resources/SampleData/csv/BranchInput.csv b/examples/myfirstpolicy/src/main/resources/SampleData/csv/BranchInput.csv
deleted file mode 100644
index 8d37e1ccd..000000000
--- a/examples/myfirstpolicy/src/main/resources/SampleData/csv/BranchInput.csv
+++ /dev/null
@@ -1,8 +0,0 @@
-BranchName,BranchID,BranchCategory,Street,City,Country,Postcode
-Al Raqqah,5667,Main,7 April Park,Al Raqqa,Syria,SY.RA.RA
-Athlone,99556,Sub,Church Street,Athlone,Ireland,N37 E733
-Cork,326,Main,Saint Patrick's Street,Cork,Ireland,T12 TE45
-Dallas,323,Main,John West Road,"Dallas, TX",USA,75228
-Pyongyang,3233,Sub,Sungri Street,Pyongyang,Korea,23060
-Tullamore,59,Franchise,O'Moore Street,Tullamore,Ireland,R35 YP55
-Vladivostok,7884,Main,Admiral Yumasheva Street,Vladivostok,Russian Federation,690000 \ No newline at end of file
diff --git a/examples/myfirstpolicy/src/main/resources/SampleData/csv/ItemInput.csv b/examples/myfirstpolicy/src/main/resources/SampleData/csv/ItemInput.csv
deleted file mode 100644
index 08416546c..000000000
--- a/examples/myfirstpolicy/src/main/resources/SampleData/csv/ItemInput.csv
+++ /dev/null
@@ -1,6 +0,0 @@
-ItemID,Description,CostPrice,Barcode,SupplierID,Category
-1232,Table and Chairs,122.34,233454432,12452,Furniture
-1277689,Crested Ten,15.23,45543345,134435,Alcahol
-16775645,Marlboro Lights,2.25,13215321,2332,Tobacco
-234424,Stool,23.23,2132132,12452,Furniture
-3455634,Bed,96.78,123123,13325,Furniture \ No newline at end of file
diff --git a/examples/myfirstpolicy/src/main/resources/SampleData/csv/SalesInput.csv b/examples/myfirstpolicy/src/main/resources/SampleData/csv/SalesInput.csv
deleted file mode 100644
index 302430789..000000000
--- a/examples/myfirstpolicy/src/main/resources/SampleData/csv/SalesInput.csv
+++ /dev/null
@@ -1,45 +0,0 @@
-SaleID,Amount,ItemID,Quantity,AssistantID,BranchName,Notes
-6778392,22.45,234424,10,126,Athlone,Fabulous Sale
-7883454,167.89,1277689,2,343,Tullamore,
-8988516,2445.62,16775645,3545,1222,Cork,
-10093578,10.11,1277689,5,22,Athlone,Good Product
-11198640,233.45,234424,32,13213,Dallas,
-12303702,8585.74,3455634,435,33,Vladivostok,
-13408764,55,1232,45,1222,Vladivostok,
-14513826,955,16775645,2,33,Pyongyang,
-15618888,788.52,16775645,56,33,Dallas,
-16723950,9555.12,234424,84,33,Al Raqqah,
-17829012,8.78,3455634,5,1222,Cork,
-18934074,1,1232,9,126,Al Raqqah,
-20039136,0,16775645,9,126,Cork,
-21144198,28.63,1277689,4515,126,Athlone,
-22249260,9944.6,234424,4,126,Pyongyang,
-23354322,8.74,3455634,5,343,Dallas,
-24459384,8.77,1232,65,1222,Pyongyang,
-25564446,2722.88,16775645,5,22,Vladivostok,
-26669508,855.21,16775645,65,13213,Athlone,
-27774570,644.37,234424,56,33,Tullamore,
-28879632,633.8,3455634,56,1222,Al Raqqah,
-29984694,743.74,1232,7787,33,Cork,
-31089756,144.63,234424,65,33,Cork,
-32194818,5.7,1277689,89,33,Athlone,
-33299880,522.36,16775645,8,1222,Dallas,
-34404942,855.36,1277689,897,126,Al Raqqah,
-35510004,455.79,234424,5,126,Pyongyang,
-36615066,1.1,3455634,6,343,Pyongyang,
-37720128,966.37,1232,2,1222,Vladivostok,
-38825190,5.27,16775645,2,22,Pyongyang,
-39930252,444.5,16775645,232,13213,Dallas,
-41035314,214.59,234424,2,33,Al Raqqah,
-42140376,6.3,3455634,1,1222,Cork,
-43245438,455.17,1232,1,33,Al Raqqah,
-44350500,658.74,16775645,1,33,Cork,
-45455562,75755.8,1277689,2313,33,Athlone,
-46560624,0.01,234424,1165,1222,Pyongyang,
-47665686,855.96,3455634,33,126,Dallas,
-48770748,44444,1232,3,126,Pyongyang,
-49875810,8555.6,16775645,3131,343,Vladivostok,
-50980872,444577.2,16775645,8,1222,Pyongyang,
-52085934,8277,234424,1,22,Dallas,
-53190996,987.65,3455634,561,13213,Al Raqqah,
-54296058,123.54,1232,6551,33,Cork, \ No newline at end of file
diff --git a/examples/myfirstpolicy/src/main/resources/SampleData/sql/apex_sales.sql b/examples/myfirstpolicy/src/main/resources/SampleData/sql/apex_sales.sql
deleted file mode 100644
index a2ff5733b..000000000
--- a/examples/myfirstpolicy/src/main/resources/SampleData/sql/apex_sales.sql
+++ /dev/null
@@ -1,232 +0,0 @@
-/*
- * ============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=========================================================
- */
-
---
--- Create apex_sales database and populate it
---
-
-SET statement_timeout = 0;
-SET lock_timeout = 0;
-SET client_encoding = 'UTF8';
-SET standard_conforming_strings = on;
-SET check_function_bodies = false;
-SET client_min_messages = warning;
-
---
--- Name: plpgsql; Type: EXTENSION; Schema: -; Owner:
---
-
-CREATE EXTENSION IF NOT EXISTS plpgsql WITH SCHEMA pg_catalog;
-
-
---
--- Name: EXTENSION plpgsql; Type: COMMENT; Schema: -; Owner:
---
-
-COMMENT ON EXTENSION plpgsql IS 'PL/pgSQL procedural language';
-
-
-SET search_path = public, pg_catalog;
-
-SET default_tablespace = '';
-
-SET default_with_oids = false;
-
---
--- Create the database and switch to it
---
-CREATE DATABASE apex_sales;
-\connect apex_sales;
-
---
--- Name: assistants; Type: TABLE; Schema: public; Owner: postgres; Tablespace:
---
-
-CREATE TABLE assistants (
- assistantid text,
- surname text,
- firstname text,
- middlename text,
- age text,
- grade text,
- phoneno text
-);
-
-
-ALTER TABLE assistants OWNER TO postgres;
-
---
--- Name: branches; Type: TABLE; Schema: public; Owner: postgres; Tablespace:
---
-
-CREATE TABLE branches (
- branchname text,
- branchid text,
- branchcategory text,
- street text,
- city text,
- country text,
- postcode text
-);
-
-
-ALTER TABLE branches OWNER TO postgres;
-
---
--- Name: items; Type: TABLE; Schema: public; Owner: postgres; Tablespace:
---
-
-CREATE TABLE items (
- itemid text,
- description text,
- costprice text,
- barcode text,
- supplierid text,
- category text
-);
-
-
-ALTER TABLE items OWNER TO postgres;
-
---
--- Name: sales; Type: TABLE; Schema: public; Owner: postgres; Tablespace:
---
-
-CREATE TABLE sales (
- saleid text,
- amount text,
- itemid text,
- quantity text,
- assistantid text,
- branchname text,
- notes text
-);
-
-
-ALTER TABLE sales OWNER TO postgres;
-
---
--- Data for Name: assistants; Type: TABLE DATA; Schema: public; Owner: postgres
---
-
-COPY assistants (assistantid, surname, firstname, middlename, age, grade, phoneno) FROM stdin;
-1222 Citizen Sean Tadhg 23 3 871234321
-126 Doe Jane Donna 56 2 861234567
-13213 Svensson Sven Lars 72 1 854323456
-22 Bloggs Joe John 19 3 839877654
-33 Yamada Taro Nanno 34 3 892344333
-343 Mustermann Max Fritz 21 2 887655432
-\.
-
-
---
--- Data for Name: branches; Type: TABLE DATA; Schema: public; Owner: postgres
---
-
-COPY branches (branchname, branchid, branchcategory, street, city, country, postcode) FROM stdin;
-Al Raqqah 5667 Main 7 April Park Al Raqqa Syria SY.RA.RA
-Athlone 99556 Sub Church Street Athlone Ireland N37 E733
-Cork 326 Main Saint Patrick's Street Cork Ireland T12 TE45
-Dallas 323 Main John West Road Dallas, TX USA 75228
-Pyongyang 3233 Sub Sungri Street Pyongyang Korea 23060
-Tullamore 59 Franchise O'Moore Street Tullamore Ireland R35 YP55
-Vladivostok 7884 Main Admiral Yumasheva Street Vladivostok Russian Federation 690000
-\.
-
-
---
--- Data for Name: items; Type: TABLE DATA; Schema: public; Owner: postgres
---
-
-COPY items (itemid, description, costprice, barcode, supplierid, category) FROM stdin;
-1232 Table and Chairs 122.34 233454432 12452 Furniture
-1277689 Crested Ten 15.23 45543345 134435 Alcahol
-16775645 Marlboro Lights 2.25 13215321 2332 Tobacco
-234424 Stool 23.23 2132132 12452 Furniture
-3455634 Bed 96.78 123123 13325 Furniture
-\.
-
-
---
--- Data for Name: sales; Type: TABLE DATA; Schema: public; Owner: postgres
---
-
-COPY sales (saleid, amount, itemid, quantity, assistantid, branchname, notes) FROM stdin;
-6778392 22.45 234424 10 126 Athlone Fabulous Sale
-7883454 167.89 1277689 2 343 Tullamore \N
-8988516 2445.62 16775645 3545 1222 Cork \N
-10093578 10.11 1277689 5 22 Athlone Good Product
-11198640 233.45 234424 32 13213 Dallas \N
-12303702 8585.74 3455634 435 33 Vladivostok \N
-13408764 55 1232 45 1222 Vladivostok \N
-14513826 955 16775645 2 33 Pyongyang \N
-15618888 788.52 16775645 56 33 Dallas \N
-16723950 9555.12 234424 84 33 Al Raqqah \N
-17829012 8.78 3455634 5 1222 Cork \N
-18934074 1 1232 9 126 Al Raqqah \N
-20039136 0 16775645 9 126 Cork \N
-21144198 28.63 1277689 4515 126 Athlone \N
-22249260 9944.6 234424 4 126 Pyongyang \N
-23354322 8.74 3455634 5 343 Dallas \N
-24459384 8.77 1232 65 1222 Pyongyang \N
-25564446 2722.88 16775645 5 22 Vladivostok \N
-26669508 855.21 16775645 65 13213 Athlone \N
-27774570 644.37 234424 56 33 Tullamore \N
-28879632 633.8 3455634 56 1222 Al Raqqah \N
-29984694 743.74 1232 7787 33 Cork \N
-31089756 144.63 234424 65 33 Cork \N
-32194818 5.7 1277689 89 33 Athlone \N
-33299880 522.36 16775645 8 1222 Dallas \N
-34404942 855.36 1277689 897 126 Al Raqqah \N
-35510004 455.79 234424 5 126 Pyongyang \N
-36615066 1.1 3455634 6 343 Pyongyang \N
-37720128 966.37 1232 2 1222 Vladivostok \N
-38825190 5.27 16775645 2 22 Pyongyang \N
-39930252 444.5 16775645 232 13213 Dallas \N
-41035314 214.59 234424 2 33 Al Raqqah \N
-42140376 6.3 3455634 1 1222 Cork \N
-43245438 455.17 1232 1 33 Al Raqqah \N
-44350500 658.74 16775645 1 33 Cork \N
-45455562 75755.8 1277689 2313 33 Athlone \N
-46560624 0.01 234424 1165 1222 Pyongyang \N
-47665686 855.96 3455634 33 126 Dallas \N
-48770748 44444 1232 3 126 Pyongyang \N
-49875810 8555.6 16775645 3131 343 Vladivostok \N
-50980872 444577.2 16775645 8 1222 Pyongyang \N
-52085934 8277 234424 1 22 Dallas \N
-53190996 987.65 3455634 561 13213 Al Raqqah \N
-54296058 123.54 1232 6551 33 Cork \N
-\.
-
-
---
--- Name: public; Type: ACL; Schema: -; Owner: postgres
---
-
-REVOKE ALL ON SCHEMA public FROM PUBLIC;
-REVOKE ALL ON SCHEMA public FROM postgres;
-GRANT ALL ON SCHEMA public TO postgres;
-GRANT ALL ON SCHEMA public TO PUBLIC;
-
-
---
--- PostgreSQL database dump complete
---
-
diff --git a/examples/myfirstpolicy/src/main/resources/SampleData/sql/readme.txt b/examples/myfirstpolicy/src/main/resources/SampleData/sql/readme.txt
deleted file mode 100644
index f86aeb02c..000000000
--- a/examples/myfirstpolicy/src/main/resources/SampleData/sql/readme.txt
+++ /dev/null
@@ -1,31 +0,0 @@
-#-------------------------------------------------------------------------------
-# ============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=========================================================
-#-------------------------------------------------------------------------------
-
-To set up the apex_sales database, simply run the following command:
-psql -U postgres -a -f apex_sales.sql
-
-To test if the database has been set up correctly, rin the psql client as follows:
-
-psql -U postgres -d apex_sales
-select * from sales;
-select * from items;
-select * from assistants;
-select * from branches;
-
diff --git a/examples/myfirstpolicy/src/main/resources/examples/events/MyFirstPolicy/1/EventIn_BoozeItem_084106GMT.json b/examples/myfirstpolicy/src/main/resources/examples/events/MyFirstPolicy/1/EventIn_BoozeItem_084106GMT.json
deleted file mode 100644
index 4c5af6c2d..000000000
--- a/examples/myfirstpolicy/src/main/resources/examples/events/MyFirstPolicy/1/EventIn_BoozeItem_084106GMT.json
+++ /dev/null
@@ -1,12 +0,0 @@
-{
- "nameSpace": "com.hyperm",
- "name": "SALE_INPUT",
- "version": "0.0.1",
- "time": 1483346466000,
- "sale_ID": 99999992,
- "amount": 1249,
- "item_ID": 1012,
- "quantity": 1,
- "assistant_ID": 12,
- "branch_ID": 2
-} \ No newline at end of file
diff --git a/examples/myfirstpolicy/src/main/resources/examples/events/MyFirstPolicy/1/EventIn_BoozeItem_201713GMT.json b/examples/myfirstpolicy/src/main/resources/examples/events/MyFirstPolicy/1/EventIn_BoozeItem_201713GMT.json
deleted file mode 100644
index cc18e7ddd..000000000
--- a/examples/myfirstpolicy/src/main/resources/examples/events/MyFirstPolicy/1/EventIn_BoozeItem_201713GMT.json
+++ /dev/null
@@ -1,12 +0,0 @@
-{
- "nameSpace": "com.hyperm",
- "name": "SALE_INPUT",
- "version": "0.0.1",
- "time": 1482265033000,
- "sale_ID": 99999993,
- "amount": 4799,
- "item_ID": 1943,
- "quantity": 2,
- "assistant_ID": 9,
- "branch_ID": 3
-} \ No newline at end of file
diff --git a/examples/myfirstpolicy/src/main/resources/examples/events/MyFirstPolicy/1/EventIn_NonBoozeItem_101309GMT.json b/examples/myfirstpolicy/src/main/resources/examples/events/MyFirstPolicy/1/EventIn_NonBoozeItem_101309GMT.json
deleted file mode 100644
index 1cdc4992c..000000000
--- a/examples/myfirstpolicy/src/main/resources/examples/events/MyFirstPolicy/1/EventIn_NonBoozeItem_101309GMT.json
+++ /dev/null
@@ -1,13 +0,0 @@
-{
- "nameSpace": "com.hyperm",
- "name": "SALE_INPUT",
- "version": "0.0.1",
- "time": 1483351989000,
- "sale_ID": 99999991,
- "amount": 299,
- "item_ID": 5123,
- "quantity": 1,
- "assistant_ID": 23,
- "branch_ID": 1,
- "notes": "Special Offer!!"
-} \ No newline at end of file
diff --git a/examples/myfirstpolicy/src/main/resources/examples/events/MyFirstPolicy/1/EventOut_BoozeItem_084106GMT.json b/examples/myfirstpolicy/src/main/resources/examples/events/MyFirstPolicy/1/EventOut_BoozeItem_084106GMT.json
deleted file mode 100644
index 3625f908f..000000000
--- a/examples/myfirstpolicy/src/main/resources/examples/events/MyFirstPolicy/1/EventOut_BoozeItem_084106GMT.json
+++ /dev/null
@@ -1,17 +0,0 @@
-{
- "nameSpace": "com.hyperm",
- "name": "SALE_AUTH",
- "version": "0.0.1",
- "source": "",
- "target": "",
- "amount": 1249,
- "assistant_ID": 12,
- "authorised": false,
- "branch_ID": 2,
- "item_ID": 1012,
- "message": "Sale not authorised by policy task MorningBoozeCheck for time 08:41:06 GMT. Alcohol can not be sold between 00:00:00 GMT and 11:30:00 GMT",
- "notes": null,
- "quantity": 1,
- "sale_ID": 99999992,
- "time": 1483346466000
-} \ No newline at end of file
diff --git a/examples/myfirstpolicy/src/main/resources/examples/events/MyFirstPolicy/1/EventOut_BoozeItem_201713GMT.json b/examples/myfirstpolicy/src/main/resources/examples/events/MyFirstPolicy/1/EventOut_BoozeItem_201713GMT.json
deleted file mode 100644
index 2b760d5f1..000000000
--- a/examples/myfirstpolicy/src/main/resources/examples/events/MyFirstPolicy/1/EventOut_BoozeItem_201713GMT.json
+++ /dev/null
@@ -1,17 +0,0 @@
-{
- "name": "SALE_AUTH",
- "version": "0.0.1",
- "nameSpace": "com.hyperm",
- "source": "",
- "target": "",
- "amount": 4799,
- "assistant_ID": 9,
- "authorised": true,
- "branch_ID": 3,
- "item_ID": 1943,
- "message": "Sale authorised by policy task MorningBoozeCheck for time 20:17:13 GMT",
- "notes": null,
- "quantity": 2,
- "sale_ID": 99999993,
- "time": 1482265033000
-} \ No newline at end of file
diff --git a/examples/myfirstpolicy/src/main/resources/examples/events/MyFirstPolicy/1/EventOut_NonBoozeItem_101309GMT.json b/examples/myfirstpolicy/src/main/resources/examples/events/MyFirstPolicy/1/EventOut_NonBoozeItem_101309GMT.json
deleted file mode 100644
index b90c6fa0c..000000000
--- a/examples/myfirstpolicy/src/main/resources/examples/events/MyFirstPolicy/1/EventOut_NonBoozeItem_101309GMT.json
+++ /dev/null
@@ -1,17 +0,0 @@
-{
- "name": "SALE_AUTH",
- "version": "0.0.1",
- "nameSpace": "com.hyperm",
- "source": "",
- "target": "",
- "amount": 299,
- "assistant_ID": 23,
- "authorised": true,
- "branch_ID": 1,
- "item_ID": 5123,
- "message": "Sale authorised by policy task MorningBoozeCheck for time 10:13:09 GMT",
- "notes": "Special Offer!!",
- "quantity": 1,
- "sale_ID": 99999991,
- "time": 1483351989000
-} \ No newline at end of file
diff --git a/examples/myfirstpolicy/src/main/resources/examples/events/MyFirstPolicy/1/EventsIn.json.txt b/examples/myfirstpolicy/src/main/resources/examples/events/MyFirstPolicy/1/EventsIn.json.txt
deleted file mode 100644
index a9570f989..000000000
--- a/examples/myfirstpolicy/src/main/resources/examples/events/MyFirstPolicy/1/EventsIn.json.txt
+++ /dev/null
@@ -1,37 +0,0 @@
-{
- "nameSpace": "com.hyperm",
- "name": "SALE_INPUT",
- "version": "0.0.1",
- "time": 1483346466000,
- "sale_ID": 99999992,
- "amount": 1249,
- "item_ID": 1012,
- "quantity": 1,
- "assistant_ID": 12,
- "branch_ID": 2
-}
-{
- "nameSpace": "com.hyperm",
- "name": "SALE_INPUT",
- "version": "0.0.1",
- "time": 1482265033000,
- "sale_ID": 99999993,
- "amount": 4799,
- "item_ID": 1943,
- "quantity": 2,
- "assistant_ID": 9,
- "branch_ID": 3
-}
-{
- "nameSpace": "com.hyperm",
- "name": "SALE_INPUT",
- "version": "0.0.1",
- "time": 1483351989000,
- "sale_ID": 99999991,
- "amount": 299,
- "item_ID": 5123,
- "quantity": 1,
- "assistant_ID": 23,
- "branch_ID": 1,
- "notes": "Special Offer!!"
-} \ No newline at end of file
diff --git a/examples/myfirstpolicy/src/main/resources/examples/events/MyFirstPolicy/1/EventsOut.json.txt b/examples/myfirstpolicy/src/main/resources/examples/events/MyFirstPolicy/1/EventsOut.json.txt
deleted file mode 100644
index 46fd887f4..000000000
--- a/examples/myfirstpolicy/src/main/resources/examples/events/MyFirstPolicy/1/EventsOut.json.txt
+++ /dev/null
@@ -1,51 +0,0 @@
-{
- "nameSpace": "com.hyperm",
- "name": "SALE_AUTH",
- "version": "0.0.1",
- "source": "",
- "target": "",
- "amount": 1249,
- "assistant_ID": 12,
- "authorised": false,
- "branch_ID": 2,
- "item_ID": 1012,
- "message": "Sale not authorised by policy task MorningBoozeCheck for time 08:41:06 GMT. Alcohol can not be sold between 00:00:00 GMT and 11:30:00 GMT",
- "notes": null,
- "quantity": 1,
- "sale_ID": 99999992,
- "time": 1483346466000
-}
-{
- "name": "SALE_AUTH",
- "version": "0.0.1",
- "nameSpace": "com.hyperm",
- "source": "",
- "target": "",
- "amount": 4799,
- "assistant_ID": 9,
- "authorised": true,
- "branch_ID": 3,
- "item_ID": 1943,
- "message": "Sale authorised by policy task MorningBoozeCheck for time 20:17:13 GMT",
- "notes": null,
- "quantity": 2,
- "sale_ID": 99999993,
- "time": 1482265033000
-}
-{
- "name": "SALE_AUTH",
- "version": "0.0.1",
- "nameSpace": "com.hyperm",
- "source": "",
- "target": "",
- "amount": 299,
- "assistant_ID": 23,
- "authorised": true,
- "branch_ID": 1,
- "item_ID": 5123,
- "message": "Sale authorised by policy task MorningBoozeCheck for time 10:13:09 GMT",
- "notes": "Special Offer!!",
- "quantity": 1,
- "sale_ID": 99999991,
- "time": 1483351989000
-} \ No newline at end of file
diff --git a/examples/myfirstpolicy/src/main/resources/examples/events/MyFirstPolicy/2/EventIn_BoozeItem_101433CET_thurs.json b/examples/myfirstpolicy/src/main/resources/examples/events/MyFirstPolicy/2/EventIn_BoozeItem_101433CET_thurs.json
deleted file mode 100644
index 952b4b189..000000000
--- a/examples/myfirstpolicy/src/main/resources/examples/events/MyFirstPolicy/2/EventIn_BoozeItem_101433CET_thurs.json
+++ /dev/null
@@ -1,12 +0,0 @@
-{
- "nameSpace": "com.hyperm",
- "name": "SALE_INPUT",
- "version": "0.0.1",
- "time": 1482398073000,
- "sale_ID": 99999981,
- "amount": 299,
- "item_ID": 1047,
- "quantity": 1,
- "assistant_ID": 1212,
- "branch_ID": 1002
-}
diff --git a/examples/myfirstpolicy/src/main/resources/examples/events/MyFirstPolicy/2/EventIn_BoozeItem_171937CET_sun.json b/examples/myfirstpolicy/src/main/resources/examples/events/MyFirstPolicy/2/EventIn_BoozeItem_171937CET_sun.json
deleted file mode 100644
index 7c8fb2bf8..000000000
--- a/examples/myfirstpolicy/src/main/resources/examples/events/MyFirstPolicy/2/EventIn_BoozeItem_171937CET_sun.json
+++ /dev/null
@@ -1,13 +0,0 @@
-{
- "nameSpace": "com.hyperm",
- "name": "SALE_INPUT",
- "version": "0.0.1",
- "time": 1482077977000,
- "sale_ID": 99999982,
- "amount": 2199,
- "item_ID": 1443,
- "quantity": 12,
- "assistant_ID": 94,
- "branch_ID": 1003,
- "notes": "Buy 3, get 1 free!!"
-}
diff --git a/examples/myfirstpolicy/src/main/resources/examples/events/MyFirstPolicy/2/EventIn_NonBoozeItem_111309CET_mon.json b/examples/myfirstpolicy/src/main/resources/examples/events/MyFirstPolicy/2/EventIn_NonBoozeItem_111309CET_mon.json
deleted file mode 100644
index f8aa8760e..000000000
--- a/examples/myfirstpolicy/src/main/resources/examples/events/MyFirstPolicy/2/EventIn_NonBoozeItem_111309CET_mon.json
+++ /dev/null
@@ -1,13 +0,0 @@
-{
- "nameSpace": "com.hyperm",
- "name": "SALE_INPUT",
- "version": "0.0.1",
- "time": 1483351989000,
- "sale_ID": 99999983,
- "amount": 699,
- "item_ID": 5321,
- "quantity": 1,
- "assistant_ID": 2323,
- "branch_ID": 1001,
- "notes": ""
-}
diff --git a/examples/myfirstpolicy/src/main/resources/examples/events/MyFirstPolicy/2/EventOut_BoozeItem_101433CET_thurs.json b/examples/myfirstpolicy/src/main/resources/examples/events/MyFirstPolicy/2/EventOut_BoozeItem_101433CET_thurs.json
deleted file mode 100644
index d7c3a3781..000000000
--- a/examples/myfirstpolicy/src/main/resources/examples/events/MyFirstPolicy/2/EventOut_BoozeItem_101433CET_thurs.json
+++ /dev/null
@@ -1,17 +0,0 @@
-{
- "nameSpace" : "com.hyperm",
- "name" : "SALE_AUTH",
- "version" : "0.0.1",
- "source" : "",
- "target" : "",
- "sale_ID" : 99999981,
- "amount" : 299,
- "assistant_ID" : 1212,
- "notes" : null,
- "quantity" : 1,
- "branch_ID" : 1002,
- "item_ID" : 1047,
- "authorised" : false,
- "time" : 1482398073000,
- "message" : "Sale not authorised by policy task MorningBoozeCheckAlt1 for time 10:14:33 CET. Alcohol can not be sold between 00:00:00 CET and 13:00:00 CET or on Sunday"
-}
diff --git a/examples/myfirstpolicy/src/main/resources/examples/events/MyFirstPolicy/2/EventOut_BoozeItem_171937CET_sun.json b/examples/myfirstpolicy/src/main/resources/examples/events/MyFirstPolicy/2/EventOut_BoozeItem_171937CET_sun.json
deleted file mode 100644
index cb838b838..000000000
--- a/examples/myfirstpolicy/src/main/resources/examples/events/MyFirstPolicy/2/EventOut_BoozeItem_171937CET_sun.json
+++ /dev/null
@@ -1,17 +0,0 @@
-{
- "nameSpace" : "com.hyperm",
- "name" : "SALE_AUTH",
- "version" : "0.0.1",
- "source" : "",
- "target" : "",
- "sale_ID" : 99999982,
- "amount" : 2199,
- "assistant_ID" : 94,
- "notes" : "Buy 3, get 1 free!!",
- "quantity" : 12,
- "branch_ID" : 1003,
- "item_ID" : 1443,
- "authorised" : false,
- "time" : 1482077977000,
- "message" : "Sale not authorised by policy task MorningBoozeCheckAlt1 for time 17:19:37 CET. Alcohol can not be sold between 00:00:00 CET and 13:00:00 CET or on Sunday"
-}
diff --git a/examples/myfirstpolicy/src/main/resources/examples/events/MyFirstPolicy/2/EventOut_NonBoozeItem_111309CET_mon.json b/examples/myfirstpolicy/src/main/resources/examples/events/MyFirstPolicy/2/EventOut_NonBoozeItem_111309CET_mon.json
deleted file mode 100644
index 4b031e453..000000000
--- a/examples/myfirstpolicy/src/main/resources/examples/events/MyFirstPolicy/2/EventOut_NonBoozeItem_111309CET_mon.json
+++ /dev/null
@@ -1,17 +0,0 @@
-{
- "nameSpace" : "com.hyperm",
- "name" : "SALE_AUTH",
- "version" : "0.0.1",
- "source" : "",
- "target" : "",
- "sale_ID" : 99999983,
- "amount" : 699,
- "assistant_ID" : 2323,
- "notes" : "",
- "quantity" : 1,
- "branch_ID" : 1001,
- "item_ID" : 5321,
- "authorised" : true,
- "time" : 1483351989000,
- "message" : "Sale authorised by policy task MorningBoozeCheckAlt1 for time 11:13:09 CET"
-}
diff --git a/examples/myfirstpolicy/src/main/resources/examples/events/MyFirstPolicy/2/EventsIn.json.txt b/examples/myfirstpolicy/src/main/resources/examples/events/MyFirstPolicy/2/EventsIn.json.txt
deleted file mode 100644
index a38fcdbc8..000000000
--- a/examples/myfirstpolicy/src/main/resources/examples/events/MyFirstPolicy/2/EventsIn.json.txt
+++ /dev/null
@@ -1,75 +0,0 @@
-{
- "nameSpace": "com.hyperm",
- "name": "SALE_INPUT",
- "version": "0.0.1",
- "time": 1483346466000,
- "sale_ID": 99999992,
- "amount": 1249,
- "item_ID": 1012,
- "quantity": 1,
- "assistant_ID": 12,
- "branch_ID": 2
-}
-{
- "nameSpace": "com.hyperm",
- "name": "SALE_INPUT",
- "version": "0.0.1",
- "time": 1482265033000,
- "sale_ID": 99999993,
- "amount": 4799,
- "item_ID": 1943,
- "quantity": 2,
- "assistant_ID": 9,
- "branch_ID": 3
-}
-{
- "nameSpace": "com.hyperm",
- "name": "SALE_INPUT",
- "version": "0.0.1",
- "time": 1483351989000,
- "sale_ID": 99999991,
- "amount": 299,
- "item_ID": 5123,
- "quantity": 1,
- "assistant_ID": 23,
- "branch_ID": 1,
- "notes": "Special Offer!!"
-}
-{
- "nameSpace": "com.hyperm",
- "name": "SALE_INPUT",
- "version": "0.0.1",
- "time": 1482398073000,
- "sale_ID": 99999981,
- "amount": 299,
- "item_ID": 1047,
- "quantity": 1,
- "assistant_ID": 1212,
- "branch_ID": 1002
-}
-{
- "nameSpace": "com.hyperm",
- "name": "SALE_INPUT",
- "version": "0.0.1",
- "time": 1482077977000,
- "sale_ID": 99999982,
- "amount": 2199,
- "item_ID": 1443,
- "quantity": 12,
- "assistant_ID": 94,
- "branch_ID": 1003,
- "notes": "Buy 3, get 1 free!!"
-}
-{
- "nameSpace": "com.hyperm",
- "name": "SALE_INPUT",
- "version": "0.0.1",
- "time": 1483351989000,
- "sale_ID": 99999983,
- "amount": 699,
- "item_ID": 5321,
- "quantity": 1,
- "assistant_ID": 2323,
- "branch_ID": 1001,
- "notes": ""
-}
diff --git a/examples/myfirstpolicy/src/main/resources/examples/events/MyFirstPolicy/2/EventsOut.json.txt b/examples/myfirstpolicy/src/main/resources/examples/events/MyFirstPolicy/2/EventsOut.json.txt
deleted file mode 100644
index 16cff198c..000000000
--- a/examples/myfirstpolicy/src/main/resources/examples/events/MyFirstPolicy/2/EventsOut.json.txt
+++ /dev/null
@@ -1,102 +0,0 @@
-{
- "nameSpace": "com.hyperm",
- "name": "SALE_AUTH",
- "version": "0.0.1",
- "source": "",
- "target": "",
- "amount": 1249,
- "assistant_ID": 12,
- "authorised": false,
- "branch_ID": 2,
- "item_ID": 1012,
- "message": "Sale not authorised by policy task MorningBoozeCheck for time 08:41:06 GMT. Alcohol can not be sold between 00:00:00 GMT and 11:30:00 GMT",
- "notes": null,
- "quantity": 1,
- "sale_ID": 99999992,
- "time": 1483346466000
-}
-{
- "name": "SALE_AUTH",
- "version": "0.0.1",
- "nameSpace": "com.hyperm",
- "source": "",
- "target": "",
- "amount": 4799,
- "assistant_ID": 9,
- "authorised": true,
- "branch_ID": 3,
- "item_ID": 1943,
- "message": "Sale authorised by policy task MorningBoozeCheck for time 20:17:13 GMT",
- "notes": null,
- "quantity": 2,
- "sale_ID": 99999993,
- "time": 1482265033000
-}
-{
- "name": "SALE_AUTH",
- "version": "0.0.1",
- "nameSpace": "com.hyperm",
- "source": "",
- "target": "",
- "amount": 299,
- "assistant_ID": 23,
- "authorised": true,
- "branch_ID": 1,
- "item_ID": 5123,
- "message": "Sale authorised by policy task MorningBoozeCheck for time 10:13:09 GMT",
- "notes": "Special Offer!!",
- "quantity": 1,
- "sale_ID": 99999991,
- "time": 1483351989000
-}
-{
- "nameSpace" : "com.hyperm",
- "name" : "SALE_AUTH",
- "version" : "0.0.1",
- "source" : "",
- "target" : "",
- "sale_ID" : 99999981,
- "amount" : 299,
- "assistant_ID" : 1212,
- "notes" : null,
- "quantity" : 1,
- "branch_ID" : 1002,
- "item_ID" : 1047,
- "authorised" : false,
- "time" : 1482398073000,
- "message" : "Sale not authorised by policy task MorningBoozeCheckAlt1 for time 10:14:33 CET. Alcohol can not be sold between 00:00:00 CET and 13:00:00 CET or on Sunday"
-}
-{
- "nameSpace" : "com.hyperm",
- "name" : "SALE_AUTH",
- "version" : "0.0.1",
- "source" : "",
- "target" : "",
- "sale_ID" : 99999982,
- "amount" : 2199,
- "assistant_ID" : 94,
- "notes" : "Buy 3, get 1 free!!",
- "quantity" : 12,
- "branch_ID" : 1003,
- "item_ID" : 1443,
- "authorised" : false,
- "time" : 1482077977000,
- "message" : "Sale not authorised by policy task MorningBoozeCheckAlt1 for time 17:19:37 CET. Alcohol can not be sold between 00:00:00 CET and 13:00:00 CET or on Sunday"
-}
-{
- "nameSpace" : "com.hyperm",
- "name" : "SALE_AUTH",
- "version" : "0.0.1",
- "source" : "",
- "target" : "",
- "sale_ID" : 99999983,
- "amount" : 699,
- "assistant_ID" : 2323,
- "notes" : "",
- "quantity" : 1,
- "branch_ID" : 1001,
- "item_ID" : 5321,
- "authorised" : true,
- "time" : 1483351989000,
- "message" : "Sale authorised by policy task MorningBoozeCheckAlt1 for time 11:13:09 CET"
-}
diff --git a/examples/myfirstpolicy/src/main/resources/examples/models/MyFirstPolicy/1/MorningBoozeCheck.js b/examples/myfirstpolicy/src/main/resources/examples/models/MyFirstPolicy/1/MorningBoozeCheck.js
deleted file mode 100644
index 8ec15a992..000000000
--- a/examples/myfirstpolicy/src/main/resources/examples/models/MyFirstPolicy/1/MorningBoozeCheck.js
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * ============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");
-var returnValue = new returnValueType(true);
-
-// Load compatibility script for imports etc
-load("nashorn:mozilla_compat.js");
-importPackage(java.text);
-importClass(java.text.SimpleDateFormat);
-
-executor.logger.info("Task Execution: '"+executor.subject.id+"'. Input Fields: '"+executor.inFields+"'");
-
-executor.outFields.put("amount" , executor.inFields.get("amount"));
-executor.outFields.put("assistant_ID", executor.inFields.get("assistant_ID"));
-executor.outFields.put("notes" , executor.inFields.get("notes"));
-executor.outFields.put("quantity" , executor.inFields.get("quantity"));
-executor.outFields.put("branch_ID" , executor.inFields.get("branch_ID"));
-executor.outFields.put("item_ID" , executor.inFields.get("item_ID"));
-executor.outFields.put("time" , executor.inFields.get("time"));
-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.
-var timenow_gmt = new Date(Number(executor.inFields.get("time")));
-
-var midnight_gmt = new Date(Number(executor.inFields.get("time")));
-midnight_gmt.setUTCHours(0,0,0,0);
-
-var eleven30_gmt = new Date(Number(executor.inFields.get("time")));
-eleven30_gmt.setUTCHours(11,30,0,0);
-
-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()) {
-
- executor.outFields.put("authorised", false);
- executor.outFields.put("message", "Sale not authorised by policy task " +
- executor.subject.taskName+ " for time " + timeformatter.format(timenow_gmt.getTime()) +
- ". Alcohol can not be sold between " + timeformatter.format(midnight_gmt.getTime()) +
- " and " + timeformatter.format(eleven30_gmt.getTime()));
-}
-else{
- executor.outFields.put("authorised", true);
- 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
-2000 are all alcoholic drinks :-)
-*/
diff --git a/examples/myfirstpolicy/src/main/resources/examples/models/MyFirstPolicy/1/MorningBoozeCheck.mvel b/examples/myfirstpolicy/src/main/resources/examples/models/MyFirstPolicy/1/MorningBoozeCheck.mvel
deleted file mode 100644
index 5d1af17de..000000000
--- a/examples/myfirstpolicy/src/main/resources/examples/models/MyFirstPolicy/1/MorningBoozeCheck.mvel
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * ============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=========================================================
- */
-import java.util.Date;
-import java.util.Calendar;
-import java.util.TimeZone;
-import java.text.SimpleDateFormat;
-
-logger.info("Task Execution: '"+subject.id+"'. Input Fields: '"+inFields+"'");
-
-outFields.put("amount" , inFields.get("amount"));
-outFields.put("assistant_ID", inFields.get("assistant_ID"));
-outFields.put("notes" , inFields.get("notes"));
-outFields.put("quantity" , inFields.get("quantity"));
-outFields.put("branch_ID" , inFields.get("branch_ID"));
-outFields.put("item_ID" , inFields.get("item_ID"));
-outFields.put("time" , inFields.get("time"));
-outFields.put("sale_ID" , inFields.get("sale_ID"));
-
-item_id = inFields.get("item_ID");
-
-//The events used later to test this task use GMT timezone!
-gmt = TimeZone.getTimeZone("GMT");
-timenow = Calendar.getInstance(gmt);
-df = new SimpleDateFormat("HH:mm:ss z");
-df.setTimeZone(gmt);
-timenow.setTimeInMillis(inFields.get("time"));
-
-midnight = timenow.clone();
-midnight.set(
- timenow.get(Calendar.YEAR),timenow.get(Calendar.MONTH),
- timenow.get(Calendar.DATE),0,0,0);
-eleven30 = timenow.clone();
-eleven30.set(
- timenow.get(Calendar.YEAR),timenow.get(Calendar.MONTH),
- timenow.get(Calendar.DATE),11,30,0);
-
-itemisalcohol = false;
-if(item_id != null && item_id >=1000 && item_id < 2000)
- itemisalcohol = true;
-
-if( itemisalcohol
- && timenow.after(midnight) && timenow.before(eleven30)){
- outFields.put("authorised", false);
- outFields.put("message", "Sale not authorised by policy task "+subject.taskName+
- " for time "+df.format(timenow.getTime())+
- ". Alcohol can not be sold between "+df.format(midnight.getTime())+
- " and "+df.format(eleven30.getTime()));
- return true;
-}
-else{
- outFields.put("authorised", true);
- outFields.put("message", "Sale authorised by policy task "+subject.taskName+
- " for time "+df.format(timenow.getTime()));
- return true;
-}
-
-/*
-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
-2000 are all alcoholic drinks :-)
-*/
diff --git a/examples/myfirstpolicy/src/main/resources/examples/models/MyFirstPolicy/1/MyFirstPolicyModel_0.0.1.alt.json b/examples/myfirstpolicy/src/main/resources/examples/models/MyFirstPolicy/1/MyFirstPolicyModel_0.0.1.alt.json
deleted file mode 100644
index 2651355fd..000000000
--- a/examples/myfirstpolicy/src/main/resources/examples/models/MyFirstPolicy/1/MyFirstPolicyModel_0.0.1.alt.json
+++ /dev/null
@@ -1,974 +0,0 @@
-{
- "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_Albums",
- "version" : "0.0.1"
- },
- "value" : {
- "key" : {
- "name" : "MyFirstPolicyModel_Albums",
- "version" : "0.0.1"
- },
- "UUID" : "3f70ec50-f896-31ba-afec-5fd47e69045b",
- "description" : "Generated description for concept referred to by key \"MyFirstPolicyModel_Albums:0.0.1\""
- }
- }, {
- "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" : "JAVASCRIPT",
- "logic" : "/**============LICENSE_START=======================================================*Copyright(C)2016-2018Ericsson.Allrightsreserved.*================================================================================*LicensedundertheApacheLicense,Version2.0(the\"License\");*youmaynotusethisfileexceptincompliancewiththeLicense.*YoumayobtainacopyoftheLicenseat**http://www.apache.org/licenses/LICENSE-2.0**Unlessrequiredbyapplicablelaworagreedtoinwriting,software*distributedundertheLicenseisdistributedonan\"ASIS\"BASIS,*WITHOUTWARRANTIESORCONDITIONSOFANYKIND,eitherexpressorimplied.*SeetheLicenseforthespecificlanguagegoverningpermissionsand*limitationsundertheLicense.**SPDX-License-Identifier:Apache-2.0*============LICENSE_END=========================================================*/\nvar returnValueType = Java.type(\"java.lang.Boolean\");\nvar returnValue = new returnValueType(true);\n\n// Load compatibility script for imports etc \nload(\"nashorn:mozilla_compat.js\");\nimportPackage(java.text);\nimportClass(java.text.SimpleDateFormat);\n\nexecutor.logger.info(\"Task Execution: '\"+executor.subject.id+\"'. Input Fields: '\"+executor.inFields+\"'\");\n\nexecutor.outFields.put(\"amount\" , executor.inFields.get(\"amount\"));\nexecutor.outFields.put(\"assistant_ID\", executor.inFields.get(\"assistant_ID\"));\nexecutor.outFields.put(\"notes\" , executor.inFields.get(\"notes\"));\nexecutor.outFields.put(\"quantity\" , executor.inFields.get(\"quantity\"));\nexecutor.outFields.put(\"branch_ID\" , executor.inFields.get(\"branch_ID\"));\nexecutor.outFields.put(\"item_ID\" , executor.inFields.get(\"item_ID\"));\nexecutor.outFields.put(\"time\" , executor.inFields.get(\"time\"));\nexecutor.outFields.put(\"sale_ID\" , executor.inFields.get(\"sale_ID\"));\n\nitem_id = executor.inFields.get(\"item_ID\");\n\n//All times in this script are in GMT/UTC since the policy and events assume time is in GMT. \nvar timenow_gmt = new Date(Number(executor.inFields.get(\"time\")));\n\nvar midnight_gmt = new Date(Number(executor.inFields.get(\"time\")));\nmidnight_gmt.setUTCHours(0,0,0,0);\n\nvar eleven30_gmt = new Date(Number(executor.inFields.get(\"time\")));\neleven30_gmt.setUTCHours(11,30,0,0);\n\nvar timeformatter = new java.text.SimpleDateFormat(\"HH:mm:ss z\");\n\nvar itemisalcohol = false;\nif(item_id != null && item_id >=1000 && item_id < 2000)\n itemisalcohol = true;\n \nif( itemisalcohol\n && timenow_gmt.getTime() >= midnight_gmt.getTime()\n && timenow_gmt.getTime() < eleven30_gmt.getTime()) {\n\n executor.outFields.put(\"authorised\", false);\n executor.outFields.put(\"message\", \"Sale not authorised by policy task \" +\n executor.subject.taskName+ \" for time \" + timeformatter.format(timenow_gmt.getTime()) +\n \". Alcohol can not be sold between \" + timeformatter.format(midnight_gmt.getTime()) +\n \" and \" + timeformatter.format(eleven30_gmt.getTime()));\n}\nelse{\n executor.outFields.put(\"authorised\", true);\n executor.outFields.put(\"message\", \"Sale authorised by policy task \" + \n executor.subject.taskName + \" for time \"+timeformatter.format(timenow_gmt.getTime()));\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
- }
- } ]
- }
- }
- } ]
- }
- },
- "albums" : {
- "key" : {
- "name" : "MyFirstPolicyModel_Albums",
- "version" : "0.0.1"
- },
- "albums" : {
- "entry" : [ ]
- }
- },
- "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"
- }
- } ]
- }
- }
- }
-}
diff --git a/examples/myfirstpolicy/src/main/resources/examples/models/MyFirstPolicy/1/MyFirstPolicyModel_0.0.1.apex b/examples/myfirstpolicy/src/main/resources/examples/models/MyFirstPolicy/1/MyFirstPolicyModel_0.0.1.apex
deleted file mode 100644
index 1cb678777..000000000
--- a/examples/myfirstpolicy/src/main/resources/examples/models/MyFirstPolicy/1/MyFirstPolicyModel_0.0.1.apex
+++ /dev/null
@@ -1,178 +0,0 @@
-#-------------------------------------------------------------------------------
-# ============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=========================================================
-#-------------------------------------------------------------------------------
-
-model create name=MyFirstPolicyModel version=0.0.1 uuid=540226fb-55ee-4f0e-a444-983a0494818e description="This is my first Apex Policy Model."
-
-schema create name=assistant_ID_type version=0.0.1 uuid=36df4c71-9616-4206-8b53-976a5cd4bd87 description="A type for 'assistant_ID' values" flavour=Java schema=java.lang.Long
-
-schema create name=authorised_type version=0.0.1 uuid=d48b619e-d00d-4008-b884-02d76ea4350b description="A type for 'authorised' values" flavour=Java schema=java.lang.Boolean
-
-schema create name=branch_ID_type version=0.0.1 uuid=6468845f-4122-4128-8e49-0f52c26078b5 description="A type for 'branch_ID' values" flavour=Java schema=java.lang.Long
-
-schema create name=item_ID_type version=0.0.1 uuid=4f227ff1-aee0-453a-b6b6-9a4b2e0da932 description="A type for 'item_ID' values" flavour=Java schema=java.lang.Long
-
-schema create name=message_type version=0.0.1 uuid=ad1431bb-3155-4e73-b5a3-b89bee498749 description="A type for 'message' values" flavour=Java schema=java.lang.String
-
-schema create name=notes_type version=0.0.1 uuid=eecfde90-896c-4343-8f9c-2603ced94e2d description="A type for 'notes' values" flavour=Java schema=java.lang.String
-
-schema create name=price_type version=0.0.1 uuid=52c2fc45-fd8c-463c-bd6f-d91b0554aea7 description="A type for 'amount'/'price' values" flavour=Java schema=java.lang.Long
-
-schema create name=quantity_type version=0.0.1 uuid=ac3d9842-80af-4a98-951c-bd79a431c613 description="A type for 'quantity' values" flavour=Java schema=java.lang.Integer
-
-schema create name=sale_ID_type version=0.0.1 uuid=cca47d74-7754-4a61-b163-ca31f66b157b description="A type for 'sale_ID' values" flavour=Java schema=java.lang.Long
-
-schema create name=timestamp_type version=0.0.1 uuid=fd594e88-411d-4a94-b2be-697b3a0d7adf description="A type for 'time' values" flavour=Java schema=java.lang.Long
-
-task create name=MorningBoozeCheck version=0.0.1 uuid=3351b0f4-cf06-4fa2-8823-edf67bd30223 description=LS
-This task checks if the sales request is for an item that contains alcohol.
-If the local time is between 00:00:00 and 11:30:00 then the sale is not authorised. Otherwise the sale is authorised.
-In this implementation we assume that all items with item_ID values between 1000 and 2000 contain alcohol :-)
-LE
-task inputfield create name=MorningBoozeCheck version=0.0.1 fieldName=sale_ID schemaName=sale_ID_type schemaVersion=0.0.1
-task inputfield create name=MorningBoozeCheck version=0.0.1 fieldName=amount schemaName=price_type schemaVersion=0.0.1
-task inputfield create name=MorningBoozeCheck version=0.0.1 fieldName=assistant_ID schemaName=assistant_ID_type schemaVersion=0.0.1
-task inputfield create name=MorningBoozeCheck version=0.0.1 fieldName=notes schemaName=notes_type schemaVersion=0.0.1 optional=true
-task inputfield create name=MorningBoozeCheck version=0.0.1 fieldName=quantity schemaName=quantity_type schemaVersion=0.0.1
-task inputfield create name=MorningBoozeCheck version=0.0.1 fieldName=branch_ID schemaName=branch_ID_type schemaVersion=0.0.1
-task inputfield create name=MorningBoozeCheck version=0.0.1 fieldName=item_ID schemaName=item_ID_type schemaVersion=0.0.1
-task inputfield create name=MorningBoozeCheck version=0.0.1 fieldName=time schemaName=timestamp_type schemaVersion=0.0.1
-task outputfield create name=MorningBoozeCheck version=0.0.1 fieldName=sale_ID schemaName=sale_ID_type schemaVersion=0.0.1
-task outputfield create name=MorningBoozeCheck version=0.0.1 fieldName=amount schemaName=price_type schemaVersion=0.0.1
-task outputfield create name=MorningBoozeCheck version=0.0.1 fieldName=assistant_ID schemaName=assistant_ID_type schemaVersion=0.0.1
-task outputfield create name=MorningBoozeCheck version=0.0.1 fieldName=notes schemaName=notes_type schemaVersion=0.0.1 optional=true
-task outputfield create name=MorningBoozeCheck version=0.0.1 fieldName=quantity schemaName=quantity_type schemaVersion=0.0.1
-task outputfield create name=MorningBoozeCheck version=0.0.1 fieldName=branch_ID schemaName=branch_ID_type schemaVersion=0.0.1
-task outputfield create name=MorningBoozeCheck version=0.0.1 fieldName=item_ID schemaName=item_ID_type schemaVersion=0.0.1
-task outputfield create name=MorningBoozeCheck version=0.0.1 fieldName=authorised schemaName=authorised_type schemaVersion=0.0.1
-task outputfield create name=MorningBoozeCheck version=0.0.1 fieldName=time schemaName=timestamp_type schemaVersion=0.0.1
-task outputfield create name=MorningBoozeCheck version=0.0.1 fieldName=message schemaName=message_type schemaVersion=0.0.1 optional=true
-task logic create name=MorningBoozeCheck version=0.0.1 logicFlavour=MVEL logic=LS
-/*
- * ============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=========================================================
- */
-import java.util.Date;
-import java.util.Calendar;
-import java.util.TimeZone;
-import java.text.SimpleDateFormat;
-
-logger.info("Task Execution: '"+subject.id+"'. Input Fields: '"+inFields+"'");
-
-outFields.put("amount" , inFields.get("amount"));
-outFields.put("assistant_ID", inFields.get("assistant_ID"));
-outFields.put("notes" , inFields.get("notes"));
-outFields.put("quantity" , inFields.get("quantity"));
-outFields.put("branch_ID" , inFields.get("branch_ID"));
-outFields.put("item_ID" , inFields.get("item_ID"));
-outFields.put("time" , inFields.get("time"));
-outFields.put("sale_ID" , inFields.get("sale_ID"));
-
-item_id = inFields.get("item_ID");
-
-//The events used later to test this task use GMT timezone!
-gmt = TimeZone.getTimeZone("GMT");
-timenow = Calendar.getInstance(gmt);
-df = new SimpleDateFormat("HH:mm:ss z");
-df.setTimeZone(gmt);
-timenow.setTimeInMillis(inFields.get("time"));
-
-midnight = timenow.clone();
-midnight.set(
- timenow.get(Calendar.YEAR),timenow.get(Calendar.MONTH),
- timenow.get(Calendar.DATE),0,0,0);
-eleven30 = timenow.clone();
-eleven30.set(
- timenow.get(Calendar.YEAR),timenow.get(Calendar.MONTH),
- timenow.get(Calendar.DATE),11,30,0);
-
-itemisalcohol = false;
-if(item_id != null && item_id >=1000 && item_id < 2000)
- itemisalcohol = true;
-
-if( itemisalcohol
- && timenow.after(midnight) && timenow.before(eleven30)){
- outFields.put("authorised", false);
- outFields.put("message", "Sale not authorised by policy task "+subject.taskName+
- " for time "+df.format(timenow.getTime())+
- ". Alcohol can not be sold between "+df.format(midnight.getTime())+
- " and "+df.format(eleven30.getTime()));
- return true;
-}
-else{
- outFields.put("authorised", true);
- outFields.put("message", "Sale authorised by policy task "+subject.taskName+
- " for time "+df.format(timenow.getTime()));
- return true;
-}
-
-/*
-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
-2000 are all alcoholic drinks :-)
-*/
-LE
-
-event create 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" nameSpace=com.hyperm source="APEX" target="POS"
-event parameter create name=SALE_AUTH version=0.0.1 parName=amount schemaName=price_type schemaVersion=0.0.1
-event parameter create name=SALE_AUTH version=0.0.1 parName=assistant_ID schemaName=assistant_ID_type schemaVersion=0.0.1
-event parameter create name=SALE_AUTH version=0.0.1 parName=authorised schemaName=authorised_type schemaVersion=0.0.1
-event parameter create name=SALE_AUTH version=0.0.1 parName=branch_ID schemaName=branch_ID_type schemaVersion=0.0.1
-event parameter create name=SALE_AUTH version=0.0.1 parName=item_ID schemaName=item_ID_type schemaVersion=0.0.1
-event parameter create name=SALE_AUTH version=0.0.1 parName=message schemaName=message_type schemaVersion=0.0.1 optional=true
-event parameter create name=SALE_AUTH version=0.0.1 parName=notes schemaName=notes_type schemaVersion=0.0.1 optional=true
-event parameter create name=SALE_AUTH version=0.0.1 parName=quantity schemaName=quantity_type schemaVersion=0.0.1
-event parameter create name=SALE_AUTH version=0.0.1 parName=sale_ID schemaName=sale_ID_type schemaVersion=0.0.1
-event parameter create name=SALE_AUTH version=0.0.1 parName=time schemaName=timestamp_type schemaVersion=0.0.1
-
-event create 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" nameSpace=com.hyperm source="POS" target="APEX"
-event parameter create name=SALE_INPUT version=0.0.1 parName=amount schemaName=price_type schemaVersion=0.0.1
-event parameter create name=SALE_INPUT version=0.0.1 parName=assistant_ID schemaName=assistant_ID_type schemaVersion=0.0.1
-event parameter create name=SALE_INPUT version=0.0.1 parName=branch_ID schemaName=branch_ID_type schemaVersion=0.0.1
-event parameter create name=SALE_INPUT version=0.0.1 parName=item_ID schemaName=item_ID_type schemaVersion=0.0.1
-event parameter create name=SALE_INPUT version=0.0.1 parName=notes schemaName=notes_type schemaVersion=0.0.1 optional=true
-event parameter create name=SALE_INPUT version=0.0.1 parName=quantity schemaName=quantity_type schemaVersion=0.0.1
-event parameter create name=SALE_INPUT version=0.0.1 parName=sale_ID schemaName=sale_ID_type schemaVersion=0.0.1
-event parameter create name=SALE_INPUT version=0.0.1 parName=time schemaName=timestamp_type schemaVersion=0.0.1
-
-
-policy create 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." template=FREEFORM firstState=BoozeAuthDecide
-policy state create name=MyFirstPolicy version=0.0.1 stateName=BoozeAuthDecide triggerName=SALE_INPUT triggerVersion=0.0.1 defaultTaskName=MorningBoozeCheck defaultTaskVersion=0.0.1
-policy state output create name=MyFirstPolicy version=0.0.1 stateName=BoozeAuthDecide outputName=MorningBoozeCheck_Output_Direct eventName=SALE_AUTH eventVersion=0.0.1 nextState=NULL
-policy state taskref create name=MyFirstPolicy version=0.0.1 stateName=BoozeAuthDecide taskLocalName=MorningBoozeCheck taskName=MorningBoozeCheck taskVersion=0.0.1 outputType=DIRECT outputName=MorningBoozeCheck_Output_Direct
-
-
-
diff --git a/examples/myfirstpolicy/src/main/resources/examples/models/MyFirstPolicy/1/MyFirstPolicyModel_0.0.1.json b/examples/myfirstpolicy/src/main/resources/examples/models/MyFirstPolicy/1/MyFirstPolicyModel_0.0.1.json
deleted file mode 100644
index d93f8f370..000000000
--- a/examples/myfirstpolicy/src/main/resources/examples/models/MyFirstPolicy/1/MyFirstPolicyModel_0.0.1.json
+++ /dev/null
@@ -1,974 +0,0 @@
-{
- "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_Albums",
- "version" : "0.0.1"
- },
- "value" : {
- "key" : {
- "name" : "MyFirstPolicyModel_Albums",
- "version" : "0.0.1"
- },
- "UUID" : "3f70ec50-f896-31ba-afec-5fd47e69045b",
- "description" : "Generated description for concept referred to by key \"MyFirstPolicyModel_Albums:0.0.1\""
- }
- }, {
- "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 * ================================================================================\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
- }
- } ]
- }
- }
- } ]
- }
- },
- "albums" : {
- "key" : {
- "name" : "MyFirstPolicyModel_Albums",
- "version" : "0.0.1"
- },
- "albums" : {
- "entry" : [ ]
- }
- },
- "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"
- }
- } ]
- }
- }
- }
-}
diff --git a/examples/myfirstpolicy/src/main/resources/examples/models/MyFirstPolicy/2/MorningBoozeCheck.mvel b/examples/myfirstpolicy/src/main/resources/examples/models/MyFirstPolicy/2/MorningBoozeCheck.mvel
deleted file mode 100644
index 6c24cdf36..000000000
--- a/examples/myfirstpolicy/src/main/resources/examples/models/MyFirstPolicy/2/MorningBoozeCheck.mvel
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * ============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=========================================================
- */
-import java.util.Date;
-import java.util.Calendar;
-import java.util.TimeZone;
-import java.text.SimpleDateFormat;
-
-logger.info("Task Execution: '"+subject.id+"'. Input Fields: '"+inFields+"'");
-
-outFields.put("amount" , inFields.get("amount"));
-outFields.put("assistant_ID", inFields.get("assistant_ID"));
-outFields.put("notes" , inFields.get("notes"));
-outFields.put("quantity" , inFields.get("quantity"));
-outFields.put("branch_ID" , inFields.get("branch_ID"));
-outFields.put("item_ID" , inFields.get("item_ID"));
-outFields.put("time" , inFields.get("time"));
-outFields.put("sale_ID" , inFields.get("sale_ID"));
-
-item_id = inFields.get("item_ID");
-
-//The events used later to test this task use GMT timezone!
-gmt = TimeZone.getTimeZone("GMT");
-timenow = Calendar.getInstance(gmt);
-df = new SimpleDateFormat("HH:mm:ss z");
-df.setTimeZone(gmt);
-timenow.setTimeInMillis(inFields.get("time"));
-
-midnight = timenow.clone();
-midnight.set(
- timenow.get(Calendar.YEAR),timenow.get(Calendar.MONTH),
- timenow.get(Calendar.DATE),0,0,0);
-eleven30 = timenow.clone();
-eleven30.set(
- timenow.get(Calendar.YEAR),timenow.get(Calendar.MONTH),
- timenow.get(Calendar.DATE),11,30,0);
-
-itemisalcohol = false;
-if(item_id != null && item_id >=1000 && item_id < 2000)
- itemisalcohol = true;
-
-if( itemisalcohol
- && timenow.after(midnight) && timenow.before(eleven30)){
- outFields.put("authorised", false);
- outFields.put("message", "Sale not authorised by policy task "+subject.taskName+
- " for time "+df.format(timenow.getTime())+
- ". Alcohol can not be sold between "+df.format(midnight.getTime())+
- " and "+df.format(eleven30.getTime()));
- return true;
-}
-else{
- outFields.put("authorised", true);
- outFields.put("message", "Sale authorised by policy task "+subject.taskName+
- " for time "+df.format(timenow.getTime()));
- return true;
-}
-
-/*
-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 2000 are all alcoholic drinks :-)
-*/
diff --git a/examples/myfirstpolicy/src/main/resources/examples/models/MyFirstPolicy/2/MorningBoozeCheckAlt1.mvel b/examples/myfirstpolicy/src/main/resources/examples/models/MyFirstPolicy/2/MorningBoozeCheckAlt1.mvel
deleted file mode 100644
index 93fbb85f6..000000000
--- a/examples/myfirstpolicy/src/main/resources/examples/models/MyFirstPolicy/2/MorningBoozeCheckAlt1.mvel
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * ============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=========================================================
- */
-import java.util.Date;
-import java.util.Calendar;
-import java.util.TimeZone;
-import java.text.SimpleDateFormat;
-
-logger.info("Task Execution: '"+subject.id+"'. Input Event: '"+inFields+"'");
-
-outFields.put("amount" , inFields.get("amount"));
-outFields.put("assistant_ID", inFields.get("assistant_ID"));
-outFields.put("notes" , inFields.get("notes"));
-outFields.put("quantity" , inFields.get("quantity"));
-outFields.put("branch_ID" , inFields.get("branch_ID"));
-outFields.put("item_ID" , inFields.get("item_ID"));
-outFields.put("time" , inFields.get("time"));
-outFields.put("sale_ID" , inFields.get("sale_ID"));
-
-item_id = inFields.get("item_ID");
-
-//The events used later to test this task use CET timezone!
-cet = TimeZone.getTimeZone("CET");
-timenow = Calendar.getInstance(cet);
-df = new SimpleDateFormat("HH:mm:ss z");
-df.setTimeZone(cet);
-timenow.setTimeInMillis(inFields.get("time"));
-
-midnight = timenow.clone();
-midnight.set(
- timenow.get(Calendar.YEAR),timenow.get(Calendar.MONTH),
- timenow.get(Calendar.DATE),0,0,0);
-onepm = timenow.clone();
-onepm.set(
- timenow.get(Calendar.YEAR),timenow.get(Calendar.MONTH),
- timenow.get(Calendar.DATE),13,0,0);
-
-itemisalcohol = false;
-if(item_id != null && item_id >=1000 && item_id < 2000)
- itemisalcohol = true;
-
-if( itemisalcohol &&
- ( (timenow.after(midnight) && timenow.before(onepm))
- ||
- (timenow.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY)
- )){
- outFields.put("authorised", false);
- outFields.put("message", "Sale not authorised by policy task "+subject.taskName+
- " for time "+df.format(timenow.getTime())+
- ". Alcohol can not be sold between "+df.format(midnight.getTime())+
- " and "+df.format(onepm.getTime()) +" or on Sunday");
- return true;
-}
-else{
- outFields.put("authorised", true);
- outFields.put("message", "Sale authorised by policy task "+subject.taskName+
- " for time "+df.format(timenow.getTime()));
- return true;
-}
-
-/*
-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 CET and 13:00:00 CET then the sale is not authorised.
-Also alcohol sales are not allowed on Sundays. Otherwise the sale is authorised.
-In this implementation we assume that items with item_ID between 1000 and 2000 are all alcoholic drinks :-)
-*/
diff --git a/examples/myfirstpolicy/src/main/resources/examples/models/MyFirstPolicy/2/MyFirstPolicyModel_0.0.1.apex b/examples/myfirstpolicy/src/main/resources/examples/models/MyFirstPolicy/2/MyFirstPolicyModel_0.0.1.apex
deleted file mode 100644
index 1599ff20b..000000000
--- a/examples/myfirstpolicy/src/main/resources/examples/models/MyFirstPolicy/2/MyFirstPolicyModel_0.0.1.apex
+++ /dev/null
@@ -1,333 +0,0 @@
-#-------------------------------------------------------------------------------
-# ============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=========================================================
-#-------------------------------------------------------------------------------
-
-model create name=MyFirstPolicyModel version=0.0.1 uuid=540226fb-55ee-4f0e-a444-983a0494818e description="This is my first Apex Policy Model."
-
-schema create name=assistant_ID_type version=0.0.1 uuid=36df4c71-9616-4206-8b53-976a5cd4bd87 description="A type for 'assistant_ID' values" flavour=Java schema=java.lang.Long
-
-schema create name=authorised_type version=0.0.1 uuid=d48b619e-d00d-4008-b884-02d76ea4350b description="A type for 'authorised' values" flavour=Java schema=java.lang.Boolean
-
-schema create name=branch_ID_type version=0.0.1 uuid=6468845f-4122-4128-8e49-0f52c26078b5 description="A type for 'branch_ID' values" flavour=Java schema=java.lang.Long
-
-schema create name=item_ID_type version=0.0.1 uuid=4f227ff1-aee0-453a-b6b6-9a4b2e0da932 description="A type for 'item_ID' values" flavour=Java schema=java.lang.Long
-
-schema create name=message_type version=0.0.1 uuid=ad1431bb-3155-4e73-b5a3-b89bee498749 description="A type for 'message' values" flavour=Java schema=java.lang.String
-
-schema create name=notes_type version=0.0.1 uuid=eecfde90-896c-4343-8f9c-2603ced94e2d description="A type for 'notes' values" flavour=Java schema=java.lang.String
-
-schema create name=price_type version=0.0.1 uuid=52c2fc45-fd8c-463c-bd6f-d91b0554aea7 description="A type for 'amount'/'price' values" flavour=Java schema=java.lang.Long
-
-schema create name=quantity_type version=0.0.1 uuid=ac3d9842-80af-4a98-951c-bd79a431c613 description="A type for 'quantity' values" flavour=Java schema=java.lang.Integer
-
-schema create name=sale_ID_type version=0.0.1 uuid=cca47d74-7754-4a61-b163-ca31f66b157b description="A type for 'sale_ID' values" flavour=Java schema=java.lang.Long
-
-schema create name=timestamp_type version=0.0.1 uuid=fd594e88-411d-4a94-b2be-697b3a0d7adf description="A type for 'time' values" flavour=Java schema=java.lang.Long
-
-task create name=MorningBoozeCheck version=0.0.1 uuid=3351b0f4-cf06-4fa2-8823-edf67bd30223 description=LS
-This task checks if the sales request is for an item that contains alcohol.
-If the local time is between 00:00:00 and 11:30:00 then the sale is not authorised. Otherwise the sale is authorised.
-In this implementation we assume that all items with item_ID values between 1000 and 2000 contain alcohol :-)
-LE
-task inputfield create name=MorningBoozeCheck version=0.0.1 fieldName=sale_ID schemaName=sale_ID_type schemaVersion=0.0.1
-task inputfield create name=MorningBoozeCheck version=0.0.1 fieldName=amount schemaName=price_type schemaVersion=0.0.1
-task inputfield create name=MorningBoozeCheck version=0.0.1 fieldName=assistant_ID schemaName=assistant_ID_type schemaVersion=0.0.1
-task inputfield create name=MorningBoozeCheck version=0.0.1 fieldName=notes schemaName=notes_type schemaVersion=0.0.1 optional=true
-task inputfield create name=MorningBoozeCheck version=0.0.1 fieldName=quantity schemaName=quantity_type schemaVersion=0.0.1
-task inputfield create name=MorningBoozeCheck version=0.0.1 fieldName=branch_ID schemaName=branch_ID_type schemaVersion=0.0.1
-task inputfield create name=MorningBoozeCheck version=0.0.1 fieldName=item_ID schemaName=item_ID_type schemaVersion=0.0.1
-task inputfield create name=MorningBoozeCheck version=0.0.1 fieldName=time schemaName=timestamp_type schemaVersion=0.0.1
-task outputfield create name=MorningBoozeCheck version=0.0.1 fieldName=sale_ID schemaName=sale_ID_type schemaVersion=0.0.1
-task outputfield create name=MorningBoozeCheck version=0.0.1 fieldName=amount schemaName=price_type schemaVersion=0.0.1
-task outputfield create name=MorningBoozeCheck version=0.0.1 fieldName=assistant_ID schemaName=assistant_ID_type schemaVersion=0.0.1
-task outputfield create name=MorningBoozeCheck version=0.0.1 fieldName=notes schemaName=notes_type schemaVersion=0.0.1 optional=true
-task outputfield create name=MorningBoozeCheck version=0.0.1 fieldName=quantity schemaName=quantity_type schemaVersion=0.0.1
-task outputfield create name=MorningBoozeCheck version=0.0.1 fieldName=branch_ID schemaName=branch_ID_type schemaVersion=0.0.1
-task outputfield create name=MorningBoozeCheck version=0.0.1 fieldName=item_ID schemaName=item_ID_type schemaVersion=0.0.1
-task outputfield create name=MorningBoozeCheck version=0.0.1 fieldName=authorised schemaName=authorised_type schemaVersion=0.0.1
-task outputfield create name=MorningBoozeCheck version=0.0.1 fieldName=time schemaName=timestamp_type schemaVersion=0.0.1
-task outputfield create name=MorningBoozeCheck version=0.0.1 fieldName=message schemaName=message_type schemaVersion=0.0.1 optional=true
-task logic create name=MorningBoozeCheck version=0.0.1 logicFlavour=MVEL logic=LS
-/*
- * ============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=========================================================
- */
-import java.util.Date;
-import java.util.Calendar;
-import java.util.TimeZone;
-import java.text.SimpleDateFormat;
-
-logger.info("Task Execution: '"+subject.id+"'. Input Fields: '"+inFields+"'");
-
-outFields.put("amount" , inFields.get("amount"));
-outFields.put("assistant_ID", inFields.get("assistant_ID"));
-outFields.put("notes" , inFields.get("notes"));
-outFields.put("quantity" , inFields.get("quantity"));
-outFields.put("branch_ID" , inFields.get("branch_ID"));
-outFields.put("item_ID" , inFields.get("item_ID"));
-outFields.put("time" , inFields.get("time"));
-outFields.put("sale_ID" , inFields.get("sale_ID"));
-
-item_id = inFields.get("item_ID");
-
-//The events used later to test this task use GMT timezone!
-gmt = TimeZone.getTimeZone("GMT");
-timenow = Calendar.getInstance(gmt);
-df = new SimpleDateFormat("HH:mm:ss z");
-df.setTimeZone(gmt);
-timenow.setTimeInMillis(inFields.get("time"));
-
-midnight = timenow.clone();
-midnight.set(
- timenow.get(Calendar.YEAR),timenow.get(Calendar.MONTH),
- timenow.get(Calendar.DATE),0,0,0);
-eleven30 = timenow.clone();
-eleven30.set(
- timenow.get(Calendar.YEAR),timenow.get(Calendar.MONTH),
- timenow.get(Calendar.DATE),11,30,0);
-
-itemisalcohol = false;
-if(item_id != null && item_id >=1000 && item_id < 2000)
- itemisalcohol = true;
-
-if( itemisalcohol
- && timenow.after(midnight) && timenow.before(eleven30)){
- outFields.put("authorised", false);
- outFields.put("message", "Sale not authorised by policy task "+subject.taskName+
- " for time "+df.format(timenow.getTime())+
- ". Alcohol can not be sold between "+df.format(midnight.getTime())+
- " and "+df.format(eleven30.getTime()));
- return true;
-}
-else{
- outFields.put("authorised", true);
- outFields.put("message", "Sale authorised by policy task "+subject.taskName+
- " for time "+df.format(timenow.getTime()));
- return true;
-}
-
-/*
-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
-2000 are all alcoholic drinks :-)
-*/
-LE
-
-task create name=MorningBoozeCheckAlt1 version=0.0.1 uuid=bc6d90c9-c902-4686-afd3-925b30e39990 description=LS
-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 CET and 13:00:00 CET then the sale is not authorised.
-Also alcohol sales are not allowed on Sundays. Otherwise the sale is authorised.
-In this implementation we assume that items with item_ID between 1000 and 2000 are all alcoholic drinks
-LE
-task inputfield create name=MorningBoozeCheckAlt1 version=0.0.1 fieldName=sale_ID schemaName=sale_ID_type schemaVersion=0.0.1
-task inputfield create name=MorningBoozeCheckAlt1 version=0.0.1 fieldName=amount schemaName=price_type schemaVersion=0.0.1
-task inputfield create name=MorningBoozeCheckAlt1 version=0.0.1 fieldName=assistant_ID schemaName=assistant_ID_type schemaVersion=0.0.1
-task inputfield create name=MorningBoozeCheckAlt1 version=0.0.1 fieldName=notes schemaName=notes_type schemaVersion=0.0.1 optional=true
-task inputfield create name=MorningBoozeCheckAlt1 version=0.0.1 fieldName=quantity schemaName=quantity_type schemaVersion=0.0.1
-task inputfield create name=MorningBoozeCheckAlt1 version=0.0.1 fieldName=branch_ID schemaName=branch_ID_type schemaVersion=0.0.1
-task inputfield create name=MorningBoozeCheckAlt1 version=0.0.1 fieldName=item_ID schemaName=item_ID_type schemaVersion=0.0.1
-task inputfield create name=MorningBoozeCheckAlt1 version=0.0.1 fieldName=time schemaName=timestamp_type schemaVersion=0.0.1
-task outputfield create name=MorningBoozeCheckAlt1 version=0.0.1 fieldName=sale_ID schemaName=sale_ID_type schemaVersion=0.0.1
-task outputfield create name=MorningBoozeCheckAlt1 version=0.0.1 fieldName=amount schemaName=price_type schemaVersion=0.0.1
-task outputfield create name=MorningBoozeCheckAlt1 version=0.0.1 fieldName=assistant_ID schemaName=assistant_ID_type schemaVersion=0.0.1
-task outputfield create name=MorningBoozeCheckAlt1 version=0.0.1 fieldName=notes schemaName=notes_type schemaVersion=0.0.1 optional=true
-task outputfield create name=MorningBoozeCheckAlt1 version=0.0.1 fieldName=quantity schemaName=quantity_type schemaVersion=0.0.1
-task outputfield create name=MorningBoozeCheckAlt1 version=0.0.1 fieldName=branch_ID schemaName=branch_ID_type schemaVersion=0.0.1
-task outputfield create name=MorningBoozeCheckAlt1 version=0.0.1 fieldName=item_ID schemaName=item_ID_type schemaVersion=0.0.1
-task outputfield create name=MorningBoozeCheckAlt1 version=0.0.1 fieldName=authorised schemaName=authorised_type schemaVersion=0.0.1
-task outputfield create name=MorningBoozeCheckAlt1 version=0.0.1 fieldName=time schemaName=timestamp_type schemaVersion=0.0.1
-task outputfield create name=MorningBoozeCheckAlt1 version=0.0.1 fieldName=message schemaName=message_type schemaVersion=0.0.1 optional=true
-task logic create name=MorningBoozeCheckAlt1 version=0.0.1 logicFlavour=MVEL logic=LS
-/*
- * ============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=========================================================
- */
-import java.util.Date;
-import java.util.Calendar;
-import java.util.TimeZone;
-import java.text.SimpleDateFormat;
-
-logger.info("Task Execution: '"+subject.id+"'. Input Event: '"+inFields+"'");
-
-outFields.put("amount" , inFields.get("amount"));
-outFields.put("assistant_ID", inFields.get("assistant_ID"));
-outFields.put("notes" , inFields.get("notes"));
-outFields.put("quantity" , inFields.get("quantity"));
-outFields.put("branch_ID" , inFields.get("branch_ID"));
-outFields.put("item_ID" , inFields.get("item_ID"));
-outFields.put("time" , inFields.get("time"));
-outFields.put("sale_ID" , inFields.get("sale_ID"));
-
-item_id = inFields.get("item_ID");
-
-//The events used later to test this task use CET timezone!
-cet = TimeZone.getTimeZone("CET");
-timenow = Calendar.getInstance(cet);
-df = new SimpleDateFormat("HH:mm:ss z");
-df.setTimeZone(cet);
-timenow.setTimeInMillis(inFields.get("time"));
-
-midnight = timenow.clone();
-midnight.set(
- timenow.get(Calendar.YEAR),timenow.get(Calendar.MONTH),
- timenow.get(Calendar.DATE),0,0,0);
-onepm = timenow.clone();
-onepm.set(
- timenow.get(Calendar.YEAR),timenow.get(Calendar.MONTH),
- timenow.get(Calendar.DATE),13,0,0);
-
-itemisalcohol = false;
-if(item_id != null && item_id >=1000 && item_id < 2000)
- itemisalcohol = true;
-
-if( itemisalcohol &&
- ( (timenow.after(midnight) && timenow.before(onepm))
- ||
- (timenow.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY)
- )){
- outFields.put("authorised", false);
- outFields.put("message", "Sale not authorised by policy task "+subject.taskName+
- " for time "+df.format(timenow.getTime())+
- ". Alcohol can not be sold between "+df.format(midnight.getTime())+
- " and "+df.format(onepm.getTime()) +" or on Sunday");
- return true;
-}
-else{
- outFields.put("authorised", true);
- outFields.put("message", "Sale authorised by policy task "+subject.taskName+
- " for time "+df.format(timenow.getTime()));
- return true;
-}
-
-/*
-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 CET and 13:00:00 CET then the sale is not authorised.
-Also alcohol sales are not allowed on Sundays. Otherwise the sale is authorised.
-In this implementation we assume that items with item_ID between 1000 and 2000 are all alcoholic drinks :-)
-*/
-LE
-
-event create 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" nameSpace=com.hyperm source="APEX" target="POS"
-event parameter create name=SALE_AUTH version=0.0.1 parName=amount schemaName=price_type schemaVersion=0.0.1
-event parameter create name=SALE_AUTH version=0.0.1 parName=assistant_ID schemaName=assistant_ID_type schemaVersion=0.0.1
-event parameter create name=SALE_AUTH version=0.0.1 parName=authorised schemaName=authorised_type schemaVersion=0.0.1
-event parameter create name=SALE_AUTH version=0.0.1 parName=branch_ID schemaName=branch_ID_type schemaVersion=0.0.1
-event parameter create name=SALE_AUTH version=0.0.1 parName=item_ID schemaName=item_ID_type schemaVersion=0.0.1
-event parameter create name=SALE_AUTH version=0.0.1 parName=message schemaName=message_type schemaVersion=0.0.1 optional=true
-event parameter create name=SALE_AUTH version=0.0.1 parName=notes schemaName=notes_type schemaVersion=0.0.1 optional=true
-event parameter create name=SALE_AUTH version=0.0.1 parName=quantity schemaName=quantity_type schemaVersion=0.0.1
-event parameter create name=SALE_AUTH version=0.0.1 parName=sale_ID schemaName=sale_ID_type schemaVersion=0.0.1
-event parameter create name=SALE_AUTH version=0.0.1 parName=time schemaName=timestamp_type schemaVersion=0.0.1
-
-event create 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" nameSpace=com.hyperm source="POS" target="APEX"
-event parameter create name=SALE_INPUT version=0.0.1 parName=amount schemaName=price_type schemaVersion=0.0.1
-event parameter create name=SALE_INPUT version=0.0.1 parName=assistant_ID schemaName=assistant_ID_type schemaVersion=0.0.1
-event parameter create name=SALE_INPUT version=0.0.1 parName=branch_ID schemaName=branch_ID_type schemaVersion=0.0.1
-event parameter create name=SALE_INPUT version=0.0.1 parName=item_ID schemaName=item_ID_type schemaVersion=0.0.1
-event parameter create name=SALE_INPUT version=0.0.1 parName=notes schemaName=notes_type schemaVersion=0.0.1 optional=true
-event parameter create name=SALE_INPUT version=0.0.1 parName=quantity schemaName=quantity_type schemaVersion=0.0.1
-event parameter create name=SALE_INPUT version=0.0.1 parName=sale_ID schemaName=sale_ID_type schemaVersion=0.0.1
-event parameter create name=SALE_INPUT version=0.0.1 parName=time schemaName=timestamp_type schemaVersion=0.0.1
-
-
-policy create 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." template=FREEFORM firstState=BoozeAuthDecide
-policy state create name=MyFirstPolicy version=0.0.1 stateName=BoozeAuthDecide triggerName=SALE_INPUT triggerVersion=0.0.1 defaultTaskName=MorningBoozeCheck defaultTaskVersion=0.0.1
-policy state output create name=MyFirstPolicy version=0.0.1 stateName=BoozeAuthDecide outputName=MorningBoozeCheck_Output_Direct eventName=SALE_AUTH eventVersion=0.0.1 nextState=NULL
-policy state taskref create name=MyFirstPolicy version=0.0.1 stateName=BoozeAuthDecide taskLocalName=MorningBoozeCheckAlt1 taskName=MorningBoozeCheckAlt1 taskVersion=0.0.1 outputType=DIRECT outputName=MorningBoozeCheck_Output_Direct
-policy state taskref create name=MyFirstPolicy version=0.0.1 stateName=BoozeAuthDecide taskLocalName=MorningBoozeCheck taskName=MorningBoozeCheck taskVersion=0.0.1 outputType=DIRECT outputName=MorningBoozeCheck_Output_Direct
-policy state selecttasklogic create name=MyFirstPolicy version=0.0.1 stateName=BoozeAuthDecide logicFlavour=JAVASCRIPT logic=LS
-/*
- * ============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");
-var returnValue = new returnValueType(true);
-
-executor.logger.info("Task Selection Execution: '"+executor.subject.id+"'. Input Event: '"+executor.inFields+"'");
-
-branchid = executor.inFields.get("branch_ID");
-taskorig = executor.subject.getTaskKey("MorningBoozeCheck");
-taskalt = executor.subject.getTaskKey("MorningBoozeCheckAlt1");
-taskdef = executor.subject.getDefaultTaskKey();
-
-if(branchid >=0 && branchid <1000){
- taskorig.copyTo(executor.selectedTask);
-}
-else if (branchid >=1000 && branchid <2000){
- taskalt.copyTo(executor.selectedTask);
-}
-else{
- taskdef.copyTo(executor.selectedTask);
-}
-
-/*
-This 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"
-*/
-LE
-
-
-
diff --git a/examples/myfirstpolicy/src/main/resources/examples/models/MyFirstPolicy/2/MyFirstPolicyModel_0.0.1.json b/examples/myfirstpolicy/src/main/resources/examples/models/MyFirstPolicy/2/MyFirstPolicyModel_0.0.1.json
deleted file mode 100644
index 2e50a8126..000000000
--- a/examples/myfirstpolicy/src/main/resources/examples/models/MyFirstPolicy/2/MyFirstPolicyModel_0.0.1.json
+++ /dev/null
@@ -1,1213 +0,0 @@
-{
- "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" : "MorningBoozeCheckAlt1",
- "version" : "0.0.1"
- },
- "value" : {
- "key" : {
- "name" : "MorningBoozeCheckAlt1",
- "version" : "0.0.1"
- },
- "UUID" : "bc6d90c9-c902-4686-afd3-925b30e39990",
- "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"
- }
- }, {
- "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_Albums",
- "version" : "0.0.1"
- },
- "value" : {
- "key" : {
- "name" : "MyFirstPolicyModel_Albums",
- "version" : "0.0.1"
- },
- "UUID" : "3f70ec50-f896-31ba-afec-5fd47e69045b",
- "description" : "Generated description for concept referred to by key \"MyFirstPolicyModel_Albums:0.0.1\""
- }
- }, {
- "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" : "TaskSelectionLogic",
- "logicFlavour" : "JAVASCRIPT",
- "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*/"
- },
- "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"
- }
- }
- }, {
- "key" : {
- "name" : "MorningBoozeCheckAlt1",
- "version" : "0.0.1"
- },
- "value" : {
- "key" : {
- "parentKeyName" : "MyFirstPolicy",
- "parentKeyVersion" : "0.0.1",
- "parentLocalName" : "BoozeAuthDecide",
- "localName" : "MorningBoozeCheckAlt1"
- },
- "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 * ================================================================================\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*/"
- }
- }
- }, {
- "key" : {
- "name" : "MorningBoozeCheckAlt1",
- "version" : "0.0.1"
- },
- "value" : {
- "key" : {
- "name" : "MorningBoozeCheckAlt1",
- "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 * ================================================================================\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*/"
- }
- }
- } ]
- }
- },
- "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
- }
- } ]
- }
- }
- } ]
- }
- },
- "albums" : {
- "key" : {
- "name" : "MyFirstPolicyModel_Albums",
- "version" : "0.0.1"
- },
- "albums" : {
- "entry" : [ ]
- }
- },
- "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"
- }
- } ]
- }
- }
- }
-}
diff --git a/examples/myfirstpolicy/src/main/resources/examples/models/MyFirstPolicy/2/MyFirstPolicy_BoozeAuthDecideTSL.js b/examples/myfirstpolicy/src/main/resources/examples/models/MyFirstPolicy/2/MyFirstPolicy_BoozeAuthDecideTSL.js
deleted file mode 100644
index 643e3446b..000000000
--- a/examples/myfirstpolicy/src/main/resources/examples/models/MyFirstPolicy/2/MyFirstPolicy_BoozeAuthDecideTSL.js
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * ============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");
-var returnValue = new returnValueType(true);
-
-executor.logger.info("Task Selection Execution: '"+executor.subject.id+
- "'. Input Event: '"+executor.inFields+"'");
-
-branchid = executor.inFields.get("branch_ID");
-taskorig = executor.subject.getTaskKey("MorningBoozeCheck");
-taskalt = executor.subject.getTaskKey("MorningBoozeCheckAlt1");
-taskdef = executor.subject.getDefaultTaskKey();
-
-if(branchid >=0 && branchid <1000){
- taskorig.copyTo(executor.selectedTask);
-}
-else if (branchid >=1000 && branchid <2000){
- taskalt.copyTo(executor.selectedTask);
-}
-else{
- taskdef.copyTo(executor.selectedTask);
-}
-
-/*
-This 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"
-*/
diff --git a/examples/myfirstpolicy/src/main/resources/org/onap/policy/apex/examples/myfirstpolicy/1/config/MyFirstPolicyConfigStdin2StdoutJsonEvent.json b/examples/myfirstpolicy/src/main/resources/org/onap/policy/apex/examples/myfirstpolicy/1/config/MyFirstPolicyConfigStdin2StdoutJsonEvent.json
deleted file mode 100644
index 06601e5d1..000000000
--- a/examples/myfirstpolicy/src/main/resources/org/onap/policy/apex/examples/myfirstpolicy/1/config/MyFirstPolicyConfigStdin2StdoutJsonEvent.json
+++ /dev/null
@@ -1,46 +0,0 @@
-{
- "engineServiceParameters" : {
- "name" : "MyFirstPolicyApexEngine",
- "version" : "0.0.1",
- "id" : 101,
- "instanceCount" : 4,
- "deploymentPort" : 12345,
- "policyModelFileName" : "examples/models/MyFirstPolicy/1/MyFirstPolicyModel_0.0.1.json",
- "engineParameters" : {
- "executorParameters" : {
- "MVEL" : {
- "parameterClassName" : "org.onap.policy.apex.plugins.executor.mvel.MVELExecutorParameters"
- },
- "JAVASCRIPT" : {
- "parameterClassName" : "org.onap.policy.apex.plugins.executor.javascript.JavascriptExecutorParameters"
- }
- }
- }
- },
- "eventOutputParameters": {
- "FirstProducer": {
- "carrierTechnologyParameters" : {
- "carrierTechnology" : "FILE",
- "parameters" : {
- "standardIO" : true
- }
- },
- "eventProtocolParameters" : {
- "eventProtocol" : "JSON"
- }
- }
- },
- "eventInputParameters": {
- "FirstConsumer": {
- "carrierTechnologyParameters" : {
- "carrierTechnology" : "FILE",
- "parameters" : {
- "standardIO" : true
- }
- },
- "eventProtocolParameters" : {
- "eventProtocol" : "JSON"
- }
- }
- }
-}
diff --git a/examples/myfirstpolicy/src/main/resources/org/onap/policy/apex/examples/myfirstpolicy/1/config/MyFirstPolicyConfigWs2WsServerJsonEvent.json b/examples/myfirstpolicy/src/main/resources/org/onap/policy/apex/examples/myfirstpolicy/1/config/MyFirstPolicyConfigWs2WsServerJsonEvent.json
deleted file mode 100644
index 657371f3c..000000000
--- a/examples/myfirstpolicy/src/main/resources/org/onap/policy/apex/examples/myfirstpolicy/1/config/MyFirstPolicyConfigWs2WsServerJsonEvent.json
+++ /dev/null
@@ -1,50 +0,0 @@
-{
- "engineServiceParameters" : {
- "name" : "MyFirstPolicyApexEngine",
- "version" : "0.0.1",
- "id" : 101,
- "instanceCount" : 4,
- "deploymentPort" : 12345,
- "policyModelFileName" : "examples/models/MyFirstPolicy/1/MyFirstPolicyModel_0.0.1.json",
- "engineParameters" : {
- "executorParameters" : {
- "MVEL" : {
- "parameterClassName" : "org.onap.policy.apex.plugins.executor.mvel.MVELExecutorParameters"
- },
- "JAVASCRIPT" : {
- "parameterClassName" : "org.onap.policy.apex.plugins.executor.javascript.JavascriptExecutorParameters"
- }
- }
- }
- },
- "eventOutputParameters": {
- "aProducer": {
- "carrierTechnologyParameters":{
- "carrierTechnology" : "WEBSOCKET",
- "parameterClassName" : "org.onap.policy.apex.plugins.event.carrier.websocket.WEBSOCKETCarrierTechnologyParameters",
- "parameters" : {
- "wsClient" : false,
- "port" : 30000
- }
- },
- "eventProtocolParameters":{
- "eventProtocol" : "JSON"
- }
- }
- },
- "eventInputParameters": {
- "aConsumer": {
- "carrierTechnologyParameters":{
- "carrierTechnology" : "WEBSOCKET",
- "parameterClassName" : "org.onap.policy.apex.plugins.event.carrier.websocket.WEBSOCKETCarrierTechnologyParameters",
- "parameters" : {
- "wsClient" : false,
- "port" : 40000
- }
- },
- "eventProtocolParameters":{
- "eventProtocol" : "JSON"
- }
- }
- }
-}
diff --git a/examples/myfirstpolicy/src/main/resources/org/onap/policy/apex/examples/myfirstpolicy/2/config/MyFirstPolicyConfigStdin2StdoutJsonEvent.json b/examples/myfirstpolicy/src/main/resources/org/onap/policy/apex/examples/myfirstpolicy/2/config/MyFirstPolicyConfigStdin2StdoutJsonEvent.json
deleted file mode 100644
index c9c29cdd2..000000000
--- a/examples/myfirstpolicy/src/main/resources/org/onap/policy/apex/examples/myfirstpolicy/2/config/MyFirstPolicyConfigStdin2StdoutJsonEvent.json
+++ /dev/null
@@ -1,46 +0,0 @@
-{
- "engineServiceParameters" : {
- "name" : "MyFirstPolicyApexEngine",
- "version" : "0.0.1",
- "id" : 102,
- "instanceCount" : 4,
- "deploymentPort" : 12345,
- "policyModelFileName" : "examples/models/MyFirstPolicy/2/MyFirstPolicyModel_0.0.1.json",
- "engineParameters" : {
- "executorParameters" : {
- "MVEL" : {
- "parameterClassName" : "org.onap.policy.apex.plugins.executor.mvel.MVELExecutorParameters"
- },
- "JAVASCRIPT" : {
- "parameterClassName" : "org.onap.policy.apex.plugins.executor.javascript.JavascriptExecutorParameters"
- }
- }
- }
- },
- "eventOutputParameters": {
- "FirstProducer": {
- "carrierTechnologyParameters" : {
- "carrierTechnology" : "FILE",
- "parameters" : {
- "standardIO" : true
- }
- },
- "eventProtocolParameters" : {
- "eventProtocol" : "JSON"
- }
- }
- },
- "eventInputParameters": {
- "FirstConsumer": {
- "carrierTechnologyParameters" : {
- "carrierTechnology" : "FILE",
- "parameters" : {
- "standardIO" : true
- }
- },
- "eventProtocolParameters" : {
- "eventProtocol" : "JSON"
- }
- }
- }
-}
diff --git a/examples/myfirstpolicy/src/main/resources/org/onap/policy/apex/examples/myfirstpolicy/2/config/MyFirstPolicyConfigWs2WsServerJsonEvent.json b/examples/myfirstpolicy/src/main/resources/org/onap/policy/apex/examples/myfirstpolicy/2/config/MyFirstPolicyConfigWs2WsServerJsonEvent.json
deleted file mode 100644
index 3faf4ca32..000000000
--- a/examples/myfirstpolicy/src/main/resources/org/onap/policy/apex/examples/myfirstpolicy/2/config/MyFirstPolicyConfigWs2WsServerJsonEvent.json
+++ /dev/null
@@ -1,50 +0,0 @@
-{
- "engineServiceParameters" : {
- "name" : "MyFirstPolicyApexEngine",
- "version" : "0.0.1",
- "id" : 102,
- "instanceCount" : 4,
- "deploymentPort" : 12345,
- "policyModelFileName" : "examples/models/MyFirstPolicy/2/MyFirstPolicyModel_0.0.1.json",
- "engineParameters" : {
- "executorParameters" : {
- "MVEL" : {
- "parameterClassName" : "org.onap.policy.apex.plugins.executor.mvel.MVELExecutorParameters"
- },
- "JAVASCRIPT" : {
- "parameterClassName" : "org.onap.policy.apex.plugins.executor.javascript.JavascriptExecutorParameters"
- }
- }
- }
- },
- "eventOutputParameters": {
- "aProducer": {
- "carrierTechnologyParameters":{
- "carrierTechnology" : "WEBSOCKET",
- "parameterClassName" : "org.onap.policy.apex.plugins.event.carrier.websocket.WEBSOCKETCarrierTechnologyParameters",
- "parameters" : {
- "wsClient" : false,
- "port" : 30000
- }
- },
- "eventProtocolParameters":{
- "eventProtocol" : "JSON"
- }
- }
- },
- "eventInputParameters": {
- "aConsumer": {
- "carrierTechnologyParameters":{
- "carrierTechnology" : "WEBSOCKET",
- "parameterClassName" : "org.onap.policy.apex.plugins.event.carrier.websocket.WEBSOCKETCarrierTechnologyParameters",
- "parameters" : {
- "wsClient" : false,
- "port" : 40000
- }
- },
- "eventProtocolParameters":{
- "eventProtocol" : "JSON"
- }
- }
- }
-}
diff --git a/examples/myfirstpolicy/src/test/java/org/onap/policy/apex/examples/myfirstpolicy/TestMFPLogic.java b/examples/myfirstpolicy/src/test/java/org/onap/policy/apex/examples/myfirstpolicy/TestMFPLogic.java
deleted file mode 100644
index 652e228c8..000000000
--- a/examples/myfirstpolicy/src/test/java/org/onap/policy/apex/examples/myfirstpolicy/TestMFPLogic.java
+++ /dev/null
@@ -1,183 +0,0 @@
-/*-
- * ============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=========================================================
- */
-
-package org.onap.policy.apex.examples.myfirstpolicy;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
-import java.util.LinkedHashMap;
-import java.util.Map;
-import java.util.Map.Entry;
-
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.onap.policy.apex.examples.myfirstpolicy.model.MFPDomainModelFactory;
-import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
-import org.onap.policy.apex.model.policymodel.concepts.AxPolicy;
-import org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel;
-import org.onap.policy.apex.model.policymodel.concepts.AxState;
-import org.onap.policy.apex.model.policymodel.concepts.AxTask;
-import org.onap.policy.apex.model.utilities.ResourceUtils;
-
-/**
- * The Class TestMFPLogic.
- */
-public class TestMFPLogic {
-
- private static final Map<String, String> LOGICEXTENSIONS = new LinkedHashMap<>();
-
- /**
- * Test setup.
- */
- @BeforeClass
- public static void testMFPUseCaseSetup() {
- LOGICEXTENSIONS.put("MVEL", "mvel");
- LOGICEXTENSIONS.put("JAVASCRIPT", "js");
- }
-
- /**
- * Check logic for MyFirstPolicy#1.
- */
- @Test
- public void testMFP1TaskLogic() {
- final AxPolicyModel apexPolicyModel = new MFPDomainModelFactory().getMFP1PolicyModel();
- assertNotNull(apexPolicyModel);
-
- final Map<String, String> logics = new LinkedHashMap<>();
- logics.putAll(getTSLLogics(apexPolicyModel));
- logics.putAll(getTaskLogics(apexPolicyModel));
-
- for (final Entry<String, String> logicvalue : logics.entrySet()) {
- final String filename = "examples/models/MyFirstPolicy/1/" + logicvalue.getKey();
- final String logic = logicvalue.getValue();
- final String expectedlogic = ResourceUtils.getResourceAsString(filename);
- assertNotNull("File " + filename + " was not found. It should contain logic for PolicyModel "
- + apexPolicyModel.getKey(), expectedlogic);
- assertEquals(
- "The task in " + filename + " is not the same as the relevant logic in PolicyModel "
- + apexPolicyModel.getKey(),
- expectedlogic.replaceAll("\\s", ""), logic.replaceAll("\\s", ""));
- }
- }
-
-
- /**
- * Check logic for MyFirstPolicyAlt#1.
- */
- @Test
- public void testMFP1AltTaskLogic() {
- final AxPolicyModel apexPolicyModel = new MFPDomainModelFactory().getMFP1AltPolicyModel();
- assertNotNull(apexPolicyModel);
-
- final Map<String, String> logics = new LinkedHashMap<>();
- logics.putAll(getTSLLogics(apexPolicyModel));
- logics.putAll(getTaskLogics(apexPolicyModel));
-
- for (final Entry<String, String> logicvalue : logics.entrySet()) {
- final String filename = "examples/models/MyFirstPolicy/1/" + logicvalue.getKey();
- final String logic = logicvalue.getValue();
- final String expectedlogic = ResourceUtils.getResourceAsString(filename);
- assertNotNull("File " + filename + " was not found. It should contain logic for PolicyModel "
- + apexPolicyModel.getKey(), expectedlogic);
- assertEquals(
- "The task in " + filename + " is not the same as the relevant logic in PolicyModel "
- + apexPolicyModel.getKey(),
- expectedlogic.replaceAll("\\s", ""), logic.replaceAll("\\s", ""));
- }
- }
-
- /**
- * Check logic for MyFirstPolicy2.
- */
- @Test
- public void testMFP2TaskLogic() {
- final AxPolicyModel apexPolicyModel = new MFPDomainModelFactory().getMFP2PolicyModel();
- assertNotNull(apexPolicyModel);
-
- final Map<String, String> logics = new LinkedHashMap<>();
- logics.putAll(getTSLLogics(apexPolicyModel));
- logics.putAll(getTaskLogics(apexPolicyModel));
-
- for (final Entry<String, String> logicvalue : logics.entrySet()) {
- final String filename = "examples/models/MyFirstPolicy/2/" + logicvalue.getKey();
- final String logic = logicvalue.getValue();
- final String expectedlogic = ResourceUtils.getResourceAsString(filename);
- assertNotNull("File " + filename + " was not found. It should contain logic for PolicyModel "
- + apexPolicyModel.getKey(), expectedlogic);
- assertEquals(
- "The task in " + filename + " is not the same as the relevant logic in PolicyModel "
- + apexPolicyModel.getKey(),
- expectedlogic.replaceAll("\\s", ""), logic.replaceAll("\\s", ""));
- }
- }
-
- /**
- * Gets the TSL logics.
- *
- * @param apexPolicyModel the apex policy model
- * @return the TSL logics
- */
- private Map<String, String> getTSLLogics(final AxPolicyModel apexPolicyModel) {
- final Map<String, String> ret = new LinkedHashMap<>();
- for (final Entry<AxArtifactKey, AxPolicy> policyentry : apexPolicyModel.getPolicies().getPolicyMap()
- .entrySet()) {
- for (final Entry<String, AxState> statesentry : policyentry.getValue().getStateMap().entrySet()) {
- final AxState state = statesentry.getValue();
- final String tsllogic = state.getTaskSelectionLogic().getLogic();
- final String tsllogicflavour = state.getTaskSelectionLogic().getLogicFlavour();
- if (tsllogic != null && tsllogic.trim().length() > 0) {
- assertNotNull(
- "Logic Type \"" + tsllogicflavour + "\" in state " + statesentry.getKey() + " in policy "
- + policyentry.getKey() + " is not supported in this test",
- LOGICEXTENSIONS.get(tsllogicflavour.toUpperCase()));
- final String filename = policyentry.getKey().getName() + "_" + statesentry.getKey() + "TSL."
- + LOGICEXTENSIONS.get(tsllogicflavour.toUpperCase());
- ret.put(filename, tsllogic);
- }
- }
- }
- return ret;
- }
-
- /**
- * Gets the task logics.
- *
- * @param apexPolicyModel the apex policy model
- * @return the task logics
- */
- private Map<String, String> getTaskLogics(final AxPolicyModel apexPolicyModel) {
- final Map<String, String> ret = new LinkedHashMap<>();
- for (final Entry<AxArtifactKey, AxTask> taskentry : apexPolicyModel.getTasks().getTaskMap().entrySet()) {
- final AxTask task = taskentry.getValue();
- final String tasklogic = task.getTaskLogic().getLogic();
- final String tasklogicflavour = task.getTaskLogic().getLogicFlavour();
- assertTrue("No/Blank logic found in task " + taskentry.getKey(),
- (tasklogic != null && tasklogic.trim().length() > 0));
- assertNotNull("Logic Type \"" + tasklogicflavour + "\" in task " + taskentry.getKey()
- + " is not supported in this test", LOGICEXTENSIONS.get(tasklogicflavour.toUpperCase()));
- final String filename =
- taskentry.getKey().getName() + "." + LOGICEXTENSIONS.get(tasklogicflavour.toUpperCase());
- ret.put(filename, tasklogic);
- }
- return ret;
- }
-}
diff --git a/examples/myfirstpolicy/src/test/java/org/onap/policy/apex/examples/myfirstpolicy/TestMFPModel.java b/examples/myfirstpolicy/src/test/java/org/onap/policy/apex/examples/myfirstpolicy/TestMFPModel.java
deleted file mode 100644
index a8be6c4e4..000000000
--- a/examples/myfirstpolicy/src/test/java/org/onap/policy/apex/examples/myfirstpolicy/TestMFPModel.java
+++ /dev/null
@@ -1,106 +0,0 @@
-/*-
- * ============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=========================================================
- */
-
-package org.onap.policy.apex.examples.myfirstpolicy;
-
-import static org.junit.Assert.assertTrue;
-
-import java.io.File;
-import java.sql.Connection;
-import java.sql.DriverManager;
-
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult;
-import org.onap.policy.apex.model.basicmodel.test.TestApexModel;
-import org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel;
-
-/**
- * Test MyFirstPolicy Model.
- *
- * @author John Keeney (john.keeney@ericsson.com)
- */
-public class TestMFPModel {
-
- private static Connection connection;
- private static TestApexModel<AxPolicyModel> testApexModel1;
- private static TestApexModel<AxPolicyModel> testApexModel2;
-
- /**
- * Setup.
- *
- * @throws Exception if there is an error
- */
- @BeforeClass
- public static void setup() throws Exception {
- Class.forName("org.apache.derby.jdbc.EmbeddedDriver").newInstance();
- connection = DriverManager.getConnection("jdbc:derby:memory:apex_test;create=true");
- testApexModel1 = new TestApexModel<>(AxPolicyModel.class, new TestMFPModelCreator.TestMFP1ModelCreator());
- testApexModel2 = new TestApexModel<>(AxPolicyModel.class, new TestMFPModelCreator.TestMFP2ModelCreator());
- }
-
- /**
- * Teardown.
- *
- * @throws Exception if there is an error
- */
- @AfterClass
- public static void teardown() throws Exception {
- connection.close();
- new File("derby.log").delete();
- }
-
- /**
- * Test model is valid.
- *
- * @throws Exception if there is an error
- */
- @Test
- public void testModelValid() throws Exception {
- AxValidationResult result = testApexModel1.testApexModelValid();
- assertTrue("Model did not validate cleanly", result.isOK());
-
- result = testApexModel2.testApexModelValid();
- assertTrue("Model did not validate cleanly", result.isOK());
- }
-
- /**
- * Test model write and read XML.
- *
- * @throws Exception if there is an error
- */
- @Test
- public void testModelWriteReadXML() throws Exception {
- testApexModel1.testApexModelWriteReadXML();
- testApexModel2.testApexModelWriteReadXML();
- }
-
- /**
- * Test model write and read JSON.
- *
- * @throws Exception if there is an error
- */
- @Test
- public void testModelWriteReadJSON() throws Exception {
- testApexModel1.testApexModelWriteReadJSON();
- testApexModel2.testApexModelWriteReadJSON();
- }
-}
diff --git a/examples/myfirstpolicy/src/test/java/org/onap/policy/apex/examples/myfirstpolicy/TestMFPModelCLI.java b/examples/myfirstpolicy/src/test/java/org/onap/policy/apex/examples/myfirstpolicy/TestMFPModelCLI.java
deleted file mode 100644
index fe9d3a205..000000000
--- a/examples/myfirstpolicy/src/test/java/org/onap/policy/apex/examples/myfirstpolicy/TestMFPModelCLI.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/*-
- * ============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=========================================================
- */
-
-package org.onap.policy.apex.examples.myfirstpolicy;
-
-import static org.junit.Assert.assertEquals;
-
-import java.io.File;
-import java.io.IOException;
-
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.onap.policy.apex.auth.clieditor.ApexCLIEditorMain;
-import org.onap.policy.apex.model.basicmodel.handling.ApexModelException;
-import org.onap.policy.apex.model.basicmodel.handling.ApexModelReader;
-import org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel;
-import org.onap.policy.apex.model.utilities.TextFileUtils;
-
-/**
- * Test MyFirstPolicyModel CLI.
- */
-public class TestMFPModelCLI {
- private static AxPolicyModel testApexModel1;
- private static AxPolicyModel testApexModel2;
-
- /**
- * Setup the test.
- *
- * @throws Exception if there is an error
- */
- @BeforeClass
- public static void setup() throws Exception {
- testApexModel1 = new TestMFPModelCreator.TestMFP1ModelCreator().getModel();
- testApexModel2 = new TestMFPModelCreator.TestMFP2ModelCreator().getModel();
- }
-
- /**
- * Test CLI policy.
- *
- * @throws IOException Signals that an I/O exception has occurred.
- * @throws ApexModelException ifd there is an Apex Error
- */
- @Test
- public void testCLIPolicy() throws IOException, ApexModelException {
-
- final File tempLogFile1 = File.createTempFile("TestMyFirstPolicy1CLI", ".log");
- final File tempModelFile1 = File.createTempFile("TestMyFirstPolicy1CLI", ".json");
- final File tempLogFile2 = File.createTempFile("TestMyFirstPolicy2CLI", ".log");
- final File tempModelFile2 = File.createTempFile("TestMyFirstPolicy2CLI", ".json");
- final String[] testApexModel1CliArgs =
- { "-c", "src/main/resources/examples/models/MyFirstPolicy/1/MyFirstPolicyModel_0.0.1.apex", "-l",
- tempLogFile1.getAbsolutePath(), "-o", tempModelFile1.getAbsolutePath() };
- final String[] testApexModel2CliArgs =
- { "-c", "src/main/resources/examples/models/MyFirstPolicy/2/MyFirstPolicyModel_0.0.1.apex", "-l",
- tempLogFile2.getAbsolutePath(), "-o", tempModelFile2.getAbsolutePath() };
-
- new ApexCLIEditorMain(testApexModel1CliArgs);
- new ApexCLIEditorMain(testApexModel2CliArgs);
-
- final ApexModelReader<AxPolicyModel> reader = new ApexModelReader<>(AxPolicyModel.class);
- AxPolicyModel generatedmodel = reader.read(TextFileUtils.getTextFileAsString(tempModelFile1.getAbsolutePath()));
-
- assertEquals("Model generated from the CLI (" + testApexModel1CliArgs[1] + ") into file "
- + tempModelFile1.getAbsolutePath() + " is not the same as the test Model for "
- + testApexModel1.getKey(), testApexModel1, generatedmodel);
-
- generatedmodel = reader.read(TextFileUtils.getTextFileAsString(tempModelFile2.getAbsolutePath()));
- assertEquals("Model generated from the CLI (" + testApexModel2CliArgs[1] + ") into file "
- + tempModelFile2.getAbsolutePath() + " is not the same as the test Model for "
- + testApexModel2.getKey(), testApexModel2, generatedmodel);
-
- tempLogFile1.delete();
- tempModelFile1.delete();
-
- tempLogFile2.delete();
- tempModelFile2.delete();
-
- }
-}
diff --git a/examples/myfirstpolicy/src/test/java/org/onap/policy/apex/examples/myfirstpolicy/TestMFPModelCreator.java b/examples/myfirstpolicy/src/test/java/org/onap/policy/apex/examples/myfirstpolicy/TestMFPModelCreator.java
deleted file mode 100644
index 2f51f2851..000000000
--- a/examples/myfirstpolicy/src/test/java/org/onap/policy/apex/examples/myfirstpolicy/TestMFPModelCreator.java
+++ /dev/null
@@ -1,106 +0,0 @@
-/*-
- * ============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=========================================================
- */
-
-package org.onap.policy.apex.examples.myfirstpolicy;
-
-import org.onap.policy.apex.examples.myfirstpolicy.model.MFPDomainModelFactory;
-import org.onap.policy.apex.model.basicmodel.test.TestApexModelCreator;
-import org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel;
-
-/**
- * Create the MyFirstPolicyModel - base class.
- *
- * @author John Keeney (John.Keeney@ericsson.com)
- */
-public abstract class TestMFPModelCreator implements TestApexModelCreator<AxPolicyModel> {
-
- /*
- * (non-Javadoc)
- *
- * @see org.onap.policy.apex.model.basicmodel.test.TestApexModelCreator#getMalstructuredModel()
- */
- @Override
- public AxPolicyModel getMalstructuredModel() {
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.onap.policy.apex.model.basicmodel.test.TestApexModelCreator#getObservationModel()
- */
- @Override
- public AxPolicyModel getObservationModel() {
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.onap.policy.apex.model.basicmodel.test.TestApexModelCreator#getWarningModel()
- */
- @Override
- public AxPolicyModel getWarningModel() {
- return getModel();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.onap.policy.apex.model.basicmodel.test.TestApexModelCreator#getInvalidModel()
- */
- @Override
- public AxPolicyModel getInvalidModel() {
- return null;
- }
-
- /**
- * Create the MyFirstPolicyModel #1.
- */
- public static class TestMFP1ModelCreator extends TestMFPModelCreator {
-
- /*
- * (non-Javadoc)
- *
- * @see org.onap.policy.apex.model.basicmodel.handling.ApexModelCreator#getModel()
- */
- @Override
- public AxPolicyModel getModel() {
- return new MFPDomainModelFactory().getMFP1PolicyModel();
- }
- }
-
- /**
- * Create the MyFirstPolicyModel#2.
- */
- public static class TestMFP2ModelCreator extends TestMFPModelCreator {
-
- /*
- * (non-Javadoc)
- *
- * @see org.onap.policy.apex.model.basicmodel.handling.ApexModelCreator#getModel()
- */
- @Override
- public AxPolicyModel getModel() {
- return new MFPDomainModelFactory().getMFP2PolicyModel();
- }
- }
-
-}
diff --git a/examples/myfirstpolicy/src/test/java/org/onap/policy/apex/examples/myfirstpolicy/TestMFPUseCase.java b/examples/myfirstpolicy/src/test/java/org/onap/policy/apex/examples/myfirstpolicy/TestMFPUseCase.java
deleted file mode 100644
index 194072d99..000000000
--- a/examples/myfirstpolicy/src/test/java/org/onap/policy/apex/examples/myfirstpolicy/TestMFPUseCase.java
+++ /dev/null
@@ -1,331 +0,0 @@
-/*-
- * ============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=========================================================
- */
-
-package org.onap.policy.apex.examples.myfirstpolicy;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
-import com.google.gson.GsonBuilder;
-import com.google.gson.JsonObject;
-
-import java.io.IOException;
-import java.util.Arrays;
-import java.util.List;
-import java.util.Map;
-
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.onap.policy.apex.core.engine.EngineParameters;
-import org.onap.policy.apex.core.engine.engine.impl.ApexEngineFactory;
-import org.onap.policy.apex.core.engine.engine.impl.ApexEngineImpl;
-import org.onap.policy.apex.core.engine.event.EnEvent;
-import org.onap.policy.apex.examples.myfirstpolicy.model.MFPDomainModelFactory;
-import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
-import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
-import org.onap.policy.apex.model.eventmodel.concepts.AxEvent;
-import org.onap.policy.apex.model.eventmodel.concepts.AxField;
-import org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel;
-import org.onap.policy.apex.model.utilities.ResourceUtils;
-import org.onap.policy.apex.plugins.executor.javascript.JavascriptExecutorParameters;
-import org.onap.policy.apex.plugins.executor.mvel.MVELExecutorParameters;
-
-/**
- * Test MyFirstPolicy Use Case.
- */
-public class TestMFPUseCase {
- // CHECKSTYLE:OFF: MagicNumber
-
- private static ApexEngineImpl apexEngine;
-
- /**
- * Test MFP use case setup.
- */
- @BeforeClass
- public static void testMFPUseCaseSetup() {
- final AxArtifactKey key = new AxArtifactKey("MyFirstPolicyApexEngine", "0.0.1");
- final EngineParameters parameters = new EngineParameters();
- parameters.getExecutorParameterMap().put("MVEL", new MVELExecutorParameters());
- parameters.getExecutorParameterMap().put("JAVASCRIPT", new JavascriptExecutorParameters());
- apexEngine = (ApexEngineImpl) new ApexEngineFactory().createApexEngine(key);
- }
-
- /**
- * Test MyFirstPolicy#1 use case.
- *
- * @throws ApexException if there is an Apex error
- * @throws InterruptedException if there is an Interruption.
- * @throws IOException Signals that an I/O exception has occurred.
- */
- @Test
- public void testMFP1Case() throws ApexException, InterruptedException, IOException {
- final AxPolicyModel apexPolicyModel = new MFPDomainModelFactory().getMFP1PolicyModel();
- assertNotNull(apexPolicyModel);
-
- final TestSaleAuthListener listener = new TestSaleAuthListener("Test");
- apexEngine.addEventListener("listener", listener);
- apexEngine.updateModel(apexPolicyModel);
- apexEngine.start();
-
- final AxEvent axEventin = apexPolicyModel.getEvents().get(new AxArtifactKey("SALE_INPUT:0.0.1"));
- assertNotNull(axEventin);
- final AxEvent axEventout = apexPolicyModel.getEvents().get(new AxArtifactKey("SALE_AUTH:0.0.1"));
- assertNotNull(axEventout);
-
- EnEvent event = fillTriggerEvent(axEventin, "examples/events/MyFirstPolicy/1/EventIn_BoozeItem_084106GMT.json");
- apexEngine.handleEvent(event);
- EnEvent resultout = listener.getResult();
- EnEvent resulexpected =
- fillResultEvent(axEventout, "examples/events/MyFirstPolicy/1/EventOut_BoozeItem_084106GMT.json");
- assertEquals(resulexpected, resultout);
-
- event = fillTriggerEvent(axEventin, "examples/events/MyFirstPolicy/1/EventIn_BoozeItem_201713GMT.json");
- apexEngine.handleEvent(event);
- resultout = listener.getResult();
- resulexpected =
- fillResultEvent(axEventout, "examples/events/MyFirstPolicy/1/EventOut_BoozeItem_201713GMT.json");
- assertEquals(resulexpected, resultout);
- assertEquals("ExecutionIDs are different", event.getExecutionID(), resultout.getExecutionID());
-
- event = fillTriggerEvent(axEventin, "examples/events/MyFirstPolicy/1/EventIn_NonBoozeItem_101309GMT.json");
- apexEngine.handleEvent(event);
- resultout = listener.getResult();
- resulexpected =
- fillResultEvent(axEventout, "examples/events/MyFirstPolicy/1/EventOut_NonBoozeItem_101309GMT.json");
- assertEquals(resulexpected, resultout);
- assertEquals("ExecutionIDs are different", event.getExecutionID(), resultout.getExecutionID());
-
- apexEngine.stop();
- }
-
- /**
- * Test MyFirstPolicy#2 use case.
- *
- * @throws ApexException if there is an Apex error
- * @throws InterruptedException if there is an Interruption.
- * @throws IOException Signals that an I/O exception has occurred.
- */
- @Test
- public void testMFP2Case() throws ApexException, InterruptedException, IOException {
- final AxPolicyModel apexPolicyModel = new MFPDomainModelFactory().getMFP2PolicyModel();
- assertNotNull(apexPolicyModel);
-
- final TestSaleAuthListener listener = new TestSaleAuthListener("Test");
- apexEngine.addEventListener("listener", listener);
- apexEngine.updateModel(apexPolicyModel);
- apexEngine.start();
-
- final AxEvent axEventin = apexPolicyModel.getEvents().get(new AxArtifactKey("SALE_INPUT:0.0.1"));
- assertNotNull(axEventin);
- final AxEvent axEventout = apexPolicyModel.getEvents().get(new AxArtifactKey("SALE_AUTH:0.0.1"));
- assertNotNull(axEventout);
-
- EnEvent event = fillTriggerEvent(axEventin, "examples/events/MyFirstPolicy/1/EventIn_BoozeItem_084106GMT.json");
- apexEngine.handleEvent(event);
- EnEvent resultout = listener.getResult();
- EnEvent resulexpected =
- fillResultEvent(axEventout, "examples/events/MyFirstPolicy/1/EventOut_BoozeItem_084106GMT.json");
- assertEquals(resulexpected, resultout);
- assertEquals("ExecutionIDs are different", event.getExecutionID(), resultout.getExecutionID());
-
- event = fillTriggerEvent(axEventin, "examples/events/MyFirstPolicy/1/EventIn_BoozeItem_201713GMT.json");
- apexEngine.handleEvent(event);
- resultout = listener.getResult();
- resulexpected =
- fillResultEvent(axEventout, "examples/events/MyFirstPolicy/1/EventOut_BoozeItem_201713GMT.json");
- assertEquals(resulexpected, resultout);
- assertEquals("ExecutionIDs are different", event.getExecutionID(), resultout.getExecutionID());
-
- event = fillTriggerEvent(axEventin, "examples/events/MyFirstPolicy/1/EventIn_NonBoozeItem_101309GMT.json");
- apexEngine.handleEvent(event);
- resultout = listener.getResult();
- resulexpected =
- fillResultEvent(axEventout, "examples/events/MyFirstPolicy/1/EventOut_NonBoozeItem_101309GMT.json");
- assertEquals(resulexpected, resultout);
- assertEquals("ExecutionIDs are different", event.getExecutionID(), resultout.getExecutionID());
-
- event = fillTriggerEvent(axEventin, "examples/events/MyFirstPolicy/2/EventIn_BoozeItem_101433CET_thurs.json");
- apexEngine.handleEvent(event);
- resultout = listener.getResult();
- resulexpected =
- fillResultEvent(axEventout, "examples/events/MyFirstPolicy/2/EventOut_BoozeItem_101433CET_thurs.json");
- assertEquals(resulexpected, resultout);
- assertEquals("ExecutionIDs are different", event.getExecutionID(), resultout.getExecutionID());
-
- event = fillTriggerEvent(axEventin, "examples/events/MyFirstPolicy/2/EventIn_BoozeItem_171937CET_sun.json");
- apexEngine.handleEvent(event);
- resultout = listener.getResult();
- resulexpected =
- fillResultEvent(axEventout, "examples/events/MyFirstPolicy/2/EventOut_BoozeItem_171937CET_sun.json");
- assertEquals(resulexpected, resultout);
- assertEquals("ExecutionIDs are different", event.getExecutionID(), resultout.getExecutionID());
-
- event = fillTriggerEvent(axEventin, "examples/events/MyFirstPolicy/2/EventIn_NonBoozeItem_111309CET_mon.json");
- apexEngine.handleEvent(event);
- resultout = listener.getResult();
- resulexpected =
- fillResultEvent(axEventout, "examples/events/MyFirstPolicy/2/EventOut_NonBoozeItem_111309CET_mon.json");
- assertEquals(resulexpected, resultout);
- assertEquals("ExecutionIDs are different", event.getExecutionID(), resultout.getExecutionID());
-
- apexEngine.stop();
- }
-
- /**
- * Fill trigger event for test.
- *
- * @param event the event
- * @param inputFile the input file
- * @return the filled event
- */
- private EnEvent fillTriggerEvent(final AxEvent event, final String inputFile) {
- final EnEvent ret = new EnEvent(event.getKey());
- final GsonBuilder gb = new GsonBuilder();
- gb.serializeNulls().enableComplexMapKeySerialization();
- final JsonObject jsonObject =
- gb.create().fromJson(ResourceUtils.getResourceAsString(inputFile), JsonObject.class);
- assertNotNull(jsonObject);
- assertTrue(jsonObject.has("name"));
- assertTrue(ret.getName().equals(jsonObject.get("name").getAsString()));
- assertTrue(ret.getAxEvent().getKey().getName().equals(jsonObject.get("name").getAsString()));
- assertTrue(jsonObject.has("nameSpace"));
- assertTrue(ret.getAxEvent().getNameSpace().equals(jsonObject.get("nameSpace").getAsString()));
- assertTrue(jsonObject.has("version"));
- assertTrue(ret.getAxEvent().getKey().getVersion().equals(jsonObject.get("version").getAsString()));
- final List<String> reserved = Arrays.asList("name", "nameSpace", "version", "source", "target");
- for (final Map.Entry<String, ?> e : jsonObject.entrySet()) {
- if (reserved.contains(e.getKey())) {
- continue;
- }
- assertTrue("Event file " + inputFile + " has a field " + e.getKey() + " but this is not defined for "
- + event.getID(), (event.getParameterMap().containsKey(e.getKey())));
- if (jsonObject.get(e.getKey()).isJsonNull()) {
- ret.put(e.getKey(), null);
- }
- }
- for (final AxField field : event.getFields()) {
- if (!field.getOptional()) {
- assertTrue("Event file " + inputFile + " is missing a mandatory field " + field.getKey().getLocalName()
- + " for " + event.getID(), jsonObject.has(field.getKey().getLocalName()));
- } else {
- ret.put(field.getKey().getLocalName(), null);
- }
- }
- if (jsonObject.has("time") && !jsonObject.get("time").isJsonNull()) {
- ret.put("time", jsonObject.get("time").getAsLong());
- }
- if (jsonObject.has("sale_ID") && !jsonObject.get("sale_ID").isJsonNull()) {
- ret.put("sale_ID", jsonObject.get("sale_ID").getAsLong());
- }
- if (jsonObject.has("amount") && !jsonObject.get("amount").isJsonNull()) {
- ret.put("amount", jsonObject.get("amount").getAsDouble());
- }
- if (jsonObject.has("item_ID") && !jsonObject.get("item_ID").isJsonNull()) {
- ret.put("item_ID", jsonObject.get("item_ID").getAsLong());
- }
- if (jsonObject.has("quantity") && !jsonObject.get("quantity").isJsonNull()) {
- ret.put("quantity", jsonObject.get("quantity").getAsInt());
- }
- if (jsonObject.has("assistant_ID") && !jsonObject.get("assistant_ID").isJsonNull()) {
- ret.put("assistant_ID", jsonObject.get("assistant_ID").getAsLong());
- }
- if (jsonObject.has("branch_ID") && !jsonObject.get("branch_ID").isJsonNull()) {
- ret.put("branch_ID", jsonObject.get("branch_ID").getAsLong());
- }
- if (jsonObject.has("notes") && !jsonObject.get("notes").isJsonNull()) {
- ret.put("notes", jsonObject.get("notes").getAsString());
- }
- return ret;
- }
-
- /**
- * Fill result event for test.
- *
- * @param event the event
- * @param inputFile the input file
- * @return the filled event
- */
- private EnEvent fillResultEvent(final AxEvent event, final String inputFile) {
- final EnEvent ret = new EnEvent(event.getKey());
- final GsonBuilder gb = new GsonBuilder();
- gb.serializeNulls().enableComplexMapKeySerialization();
- final JsonObject jsonObject =
- gb.create().fromJson(ResourceUtils.getResourceAsString(inputFile), JsonObject.class);
- assertNotNull(jsonObject);
- assertTrue(jsonObject.has("name"));
- assertTrue(ret.getName().equals(jsonObject.get("name").getAsString()));
- assertTrue(ret.getAxEvent().getKey().getName().equals(jsonObject.get("name").getAsString()));
- assertTrue(jsonObject.has("nameSpace"));
- assertTrue(ret.getAxEvent().getNameSpace().equals(jsonObject.get("nameSpace").getAsString()));
- assertTrue(jsonObject.has("version"));
- assertTrue(ret.getAxEvent().getKey().getVersion().equals(jsonObject.get("version").getAsString()));
- final List<String> reserved = Arrays.asList("name", "nameSpace", "version", "source", "target");
- for (final Map.Entry<String, ?> e : jsonObject.entrySet()) {
- if (reserved.contains(e.getKey())) {
- continue;
- }
- assertTrue("Event file " + inputFile + " has a field " + e.getKey() + " but this is not defined for "
- + event.getID(), (event.getParameterMap().containsKey(e.getKey())));
- if (jsonObject.get(e.getKey()).isJsonNull()) {
- ret.put(e.getKey(), null);
- }
- }
- for (final AxField field : event.getFields()) {
- if (!field.getOptional()) {
- assertTrue("Event file " + inputFile + " is missing a mandatory field " + field.getKey().getLocalName()
- + " for " + event.getID(), jsonObject.has(field.getKey().getLocalName()));
- } else {
- ret.put(field.getKey().getLocalName(), null);
- }
- }
- if (jsonObject.has("time") && !jsonObject.get("time").isJsonNull()) {
- ret.put("time", jsonObject.get("time").getAsLong());
- }
- if (jsonObject.has("sale_ID") && !jsonObject.get("sale_ID").isJsonNull()) {
- ret.put("sale_ID", jsonObject.get("sale_ID").getAsLong());
- }
- if (jsonObject.has("amount") && !jsonObject.get("amount").isJsonNull()) {
- ret.put("amount", jsonObject.get("amount").getAsDouble());
- }
- if (jsonObject.has("item_ID") && !jsonObject.get("item_ID").isJsonNull()) {
- ret.put("item_ID", jsonObject.get("item_ID").getAsLong());
- }
- if (jsonObject.has("quantity") && !jsonObject.get("quantity").isJsonNull()) {
- ret.put("quantity", jsonObject.get("quantity").getAsInt());
- }
- if (jsonObject.has("assistant_ID") && !jsonObject.get("assistant_ID").isJsonNull()) {
- ret.put("assistant_ID", jsonObject.get("assistant_ID").getAsLong());
- }
- if (jsonObject.has("branch_ID") && !jsonObject.get("branch_ID").isJsonNull()) {
- ret.put("branch_ID", jsonObject.get("branch_ID").getAsLong());
- }
- if (jsonObject.has("notes") && !jsonObject.get("notes").isJsonNull()) {
- ret.put("notes", jsonObject.get("notes").getAsString());
- }
- if (jsonObject.has("authorised") && !jsonObject.get("authorised").isJsonNull()) {
- ret.put("authorised", jsonObject.get("authorised").getAsString());
- }
- if (jsonObject.has("message") && !jsonObject.get("message").isJsonNull()) {
- ret.put("message", jsonObject.get("message").getAsString());
- }
- return ret;
- }
-}
diff --git a/examples/myfirstpolicy/src/test/java/org/onap/policy/apex/examples/myfirstpolicy/TestSaleAuthListener.java b/examples/myfirstpolicy/src/test/java/org/onap/policy/apex/examples/myfirstpolicy/TestSaleAuthListener.java
deleted file mode 100644
index 2dfd1af61..000000000
--- a/examples/myfirstpolicy/src/test/java/org/onap/policy/apex/examples/myfirstpolicy/TestSaleAuthListener.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*-
- * ============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=========================================================
- */
-
-package org.onap.policy.apex.examples.myfirstpolicy;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.onap.policy.apex.core.engine.engine.EnEventListener;
-import org.onap.policy.apex.core.engine.event.EnEvent;
-import org.onap.policy.apex.core.infrastructure.threading.ThreadUtilities;
-
-/**
- * The listener interface for receiving SaleAuth events. The class that is interested in processing a SaleAuth event
- * implements this interface, and the object created with that class is registered with a component using the
- * component's <code>addTestApexActionListener</code> method. When the testApexAction event occurs, that object's
- * appropriate method is invoked.
- *
- * @author Liam Fallon (liam.fallon@ericsson.com)
- */
-public class TestSaleAuthListener implements EnEventListener {
- // CHECKSTYLE:OFF: MagicNumber
-
- private final List<EnEvent> resultEvents = new ArrayList<>();
-
- private final String id;
-
- /**
- * Instantiates a new action listener.
- *
- * @param id the id
- */
- public TestSaleAuthListener(final String id) {
- this.id = id;
- }
-
- /**
- * Gets the result.
- *
- * @return the result
- */
- public EnEvent getResult() {
- while (resultEvents.isEmpty()) {
- ThreadUtilities.sleep(100);
- }
- return resultEvents.remove(0);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.onap.policy.apex.core.engine.engine.EnEventListener#onEnEvent(org.onap.policy.apex.core.engine.event.EnEvent)
- */
- @Override
- public void onEnEvent(final EnEvent saleauthEvent) {
- try {
- Thread.sleep(100);
- } catch (final InterruptedException e) {
- e.printStackTrace();
- }
- if (saleauthEvent != null) {
- System.out.println("SaleAuth event from engine:" + saleauthEvent.getName());
- resultEvents.add(saleauthEvent);
- }
- }
-
- /**
- * Gets the id.
- *
- * @return the id
- */
- public String getId() {
- return id;
- }
-}
diff --git a/examples/myfirstpolicy/src/test/resources/META-INF/persistence.xml b/examples/myfirstpolicy/src/test/resources/META-INF/persistence.xml
deleted file mode 100644
index 4dcba14b7..000000000
--- a/examples/myfirstpolicy/src/test/resources/META-INF/persistence.xml
+++ /dev/null
@@ -1,69 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- ============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=========================================================
--->
-
-<persistence xmlns="http://java.sun.com/xml/ns/persistence" version="2.0">
- <persistence-unit name="MFPModelTest" transaction-type="RESOURCE_LOCAL">
- <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
-
- <class>org.onap.policy.apex.model.basicmodel.dao.converters.CDATAConditioner</class>
- <class>org.onap.policy.apex.model.basicmodel.dao.converters.UUID2String</class>
- <class>org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey</class>
- <class>org.onap.policy.apex.model.basicmodel.concepts.AxConcept</class>
- <class>org.onap.policy.apex.model.basicmodel.concepts.AxKeyInfo</class>
- <class>org.onap.policy.apex.model.basicmodel.concepts.AxKeyInformation</class>
- <class>org.onap.policy.apex.model.basicmodel.concepts.AxModel</class>
- <class>org.onap.policy.apex.model.basicmodel.concepts.TestEntity</class>
- <class>org.onap.policy.apex.model.contextmodel.concepts.AxContextSchema</class>
- <class>org.onap.policy.apex.model.contextmodel.concepts.AxContextSchemas</class>
- <class>org.onap.policy.apex.model.contextmodel.concepts.AxContextAlbum</class>
- <class>org.onap.policy.apex.model.contextmodel.concepts.AxContextAlbums</class>
- <class>org.onap.policy.apex.model.contextmodel.concepts.AxContextModel</class>
- <class>org.onap.policy.apex.model.eventmodel.concepts.AxField</class>
- <class>org.onap.policy.apex.model.eventmodel.concepts.AxInputField</class>
- <class>org.onap.policy.apex.model.eventmodel.concepts.AxOutputField</class>
- <class>org.onap.policy.apex.model.eventmodel.concepts.AxEvent</class>
- <class>org.onap.policy.apex.model.eventmodel.concepts.AxEvents</class>
- <class>org.onap.policy.apex.model.eventmodel.concepts.AxEventModel</class>
- <class>org.onap.policy.apex.model.policymodel.concepts.AxLogic</class>
- <class>org.onap.policy.apex.model.policymodel.concepts.AxTaskParameter</class>
- <class>org.onap.policy.apex.model.policymodel.concepts.AxTaskLogic</class>
- <class>org.onap.policy.apex.model.policymodel.concepts.AxTask</class>
- <class>org.onap.policy.apex.model.policymodel.concepts.AxTasks</class>
- <class>org.onap.policy.apex.model.policymodel.concepts.AxTaskSelectionLogic</class>
- <class>org.onap.policy.apex.model.policymodel.concepts.AxStateFinalizerLogic</class>
- <class>org.onap.policy.apex.model.policymodel.concepts.AxStateOutput</class>
- <class>org.onap.policy.apex.model.policymodel.concepts.AxStateTaskReference</class>
- <class>org.onap.policy.apex.model.policymodel.concepts.AxState</class>
- <class>org.onap.policy.apex.model.policymodel.concepts.AxPolicy</class>
- <class>org.onap.policy.apex.model.policymodel.concepts.AxPolicies</class>
- <class>org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel</class>
-
- <properties>
- <property name="javax.persistence.jdbc.url" value="jdbc:derby:memory:apex_test" />
- <property name="javax.persistence.target-database" value="Derby" />
- <property name="javax.persistence.jdbc.driver" value="org.apache.derby.jdbc.EmbeddedDriver" />
-
- <property name="eclipselink.ddl-generation" value="drop-and-create-tables" />
- <property name="eclipselink.ddl-generation.output-mode" value="database" />
- <property name="eclipselink.logging.level" value="INFO" />
- </properties>
- </persistence-unit>
-</persistence>
diff --git a/examples/myfirstpolicy/src/test/resources/logback-test.xml b/examples/myfirstpolicy/src/test/resources/logback-test.xml
deleted file mode 100644
index ea201e0a9..000000000
--- a/examples/myfirstpolicy/src/test/resources/logback-test.xml
+++ /dev/null
@@ -1,74 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- ============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=========================================================
--->
-
-<configuration>
- <contextName>Apex</contextName>
-
- <statusListener class="ch.qos.logback.core.status.OnConsoleStatusListener" />
- <property name="LOG_DIR" value="${java.io.tmpdir}/apex_logging/" />
-
- <!-- USE FOR STD OUT ONLY -->
- <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
- <encoder>
- <Pattern>%d %contextName [%t] %level %logger{36} - %msg%n</Pattern>
- </encoder>
- </appender>
-
- <root level="INFO">
- <appender-ref ref="STDOUT" />
- </root>
-
- <logger name="org.infinispan" level="INFO" additivity="false">
- <appender-ref ref="STDOUT" />
- </logger>
-
- <logger name="org.apache.zookeeper.ClientCnxn" level="OFF" additivity="false">
- <appender-ref ref="STDOUT" />
- </logger>
-
- <appender name="FILE" class="ch.qos.logback.core.FileAppender">
- <file>${LOG_DIR}/apex.log</file>
- <encoder>
- <pattern>%d %-5relative [procId=${processId}] [%thread] %-5level
- %logger{26} - %msg %n %ex{full}</pattern>
- </encoder>
- </appender>
-
- <appender name="CTXT_FILE" class="ch.qos.logback.core.FileAppender">
- <file>${LOG_DIR}/apex_ctxt.log</file>
- <encoder>
- <pattern>%d %-5relative [procId=${processId}] [%thread] %-5level
- %logger{26} - %msg %n %ex{full}</pattern>
- </encoder>
- </appender>
-
- <logger name="org.onap.policy.apex.core.context.impl.monitoring" level="TRACE" additivity="false">
- <appender-ref ref="CTXT_FILE" />
- </logger>
-
- <logger name="org.onap.policy.apex" level="TRACE" additivity="false">
- <appender-ref ref="STDOUT" />
- </logger>
-
- <logger name="org.onap.policy.apex.core.infrastructure" level="INFO" additivity="false">
- <appender-ref ref="STDOUT" />
- </logger>
-</configuration>