Apex-pdp documentation conversion from .adoc to .rst
[policy/parent.git] / docs / apex / APEX-Policy-Guide.rst
index f76ed13..cb2388e 100644 (file)
@@ -664,6 +664,13 @@ Concept: TaskParameter
                   values in the configuration information passed to APEX
                   engines.
 
                   values in the configuration information passed to APEX
                   engines.
 
+               .. container:: paragraph
+
+                  The *taskParameters* field is specified under *engineParameters*
+                  in the ApexConfig. It can contain one or more task parameters, where each
+                  item can contain the parameter key, value as well as the taskId to which it is associated.
+                  If the taskId is not specified, then the parameters are added to all tasks.
+
 Concept: Logic
 ##############
 
 Concept: Logic
 ##############
 
@@ -1567,6 +1574,22 @@ Writing APEX Task Selection Logic
 |            |             |                                |                .getOutFieldSchemaHelper("authorised")                               |
 |            |             |                                |               .createNewInstance("false");                                          |
 +------------+-------------+--------------------------------+-------------------------------------------------------------------------------------+
 |            |             |                                |                .getOutFieldSchemaHelper("authorised")                               |
 |            |             |                                |               .createNewInstance("false");                                          |
 +------------+-------------+--------------------------------+-------------------------------------------------------------------------------------+
+| parameters | Fields      | java.util.Map <String,String>  | .. container:: paragraph                                                            |
+|            |             |                                |                                                                                     |
+|            |             |                                |    All parameters in the current task. This is implemented as a standard Java Map.  |
+|            |             |                                |                                                                                     |
+|            |             |                                | .. container::                                                                      |
+|            |             |                                |                                                                                     |
+|            |             |                                |    .. container:: content                                                           |
+|            |             |                                |                                                                                     |
+|            |             |                                |       .. container:: paragraph                                                      |
+|            |             |                                |                                                                                     |
+|            |             |                                |          **Example:**                                                               |
+|            |             |                                |                                                                                     |
+|            |             |                                |       .. code:: javascript                                                          |
+|            |             |                                |                                                                                     |
+|            |             |                                |          executor.parameters.get("ParameterKey1"))                                  |
++------------+-------------+--------------------------------+-------------------------------------------------------------------------------------+
 | ContextAlbum getContextAlbum(String ctxtAlbumName )       | .. container:: paragraph                                                            |
 |                                                           |                                                                                     |
 |                                                           |    A utility method to retrieve a ``ContextAlbum`` for use in the task.             |
 | ContextAlbum getContextAlbum(String ctxtAlbumName )       | .. container:: paragraph                                                            |
 |                                                           |                                                                                     |
 |                                                           |    A utility method to retrieve a ``ContextAlbum`` for use in the task.             |
@@ -1604,32 +1627,13 @@ Logic Cheatsheet
       Examples given here use Javascript (if not stated otherwise),
       other execution environments will be similar.
 
       Examples given here use Javascript (if not stated otherwise),
       other execution environments will be similar.
 
-Add Nashorn
-###########
-
-      .. container:: paragraph
-
-         First line in the logic use this import.
-
-      .. container:: listingblock
-
-         .. container:: title
-
-            JS Nashorn
-
-         .. container:: content
-
-            .. code:: javascript
-
-               load("nashorn:mozilla_compat.js");
-
 Finish Logic with Success or Error
 ##################################
 
       .. container:: paragraph
 
          To finish logic, i.e. return to APEX, with success use the
 Finish Logic with Success or Error
 ##################################
 
       .. container:: paragraph
 
          To finish logic, i.e. return to APEX, with success use the
-         following lines close to the end of the logic.
+         following line close to the end of the logic.
 
       .. container:: listingblock
 
 
       .. container:: listingblock
 
@@ -1641,8 +1645,7 @@ Finish Logic with Success or Error
 
             .. code:: javascript
 
 
             .. code:: javascript
 
-               var returnValueType = Java.type("java.lang.Boolean");
-               var returnValue = new returnValueType(true);
+               true;
 
       .. container:: paragraph
 
 
       .. container:: paragraph
 
@@ -1658,8 +1661,7 @@ Finish Logic with Success or Error
 
             .. code:: javascript
 
 
             .. code:: javascript
 
-               var returnValueType = Java.type("java.lang.Boolean");
-               var returnValue = new returnValueType(false);
+               false;
 
 Logic Logging
 #############
 
 Logic Logging
 #############
@@ -1731,6 +1733,43 @@ Logic Logging
 
                rootLogger.error("Serious error in logic detected: " + executor.subject.id);
 
 
                rootLogger.error("Serious error in logic detected: " + executor.subject.id);
 
+Accessing TaskParameters
+########################
+
+      .. container:: paragraph
+
+         TaskParameters available in a Task can be accessed in the logic.
+         The parameters in each task are made available at the executor level.
+         This example assumes a parameter with key ``ParameterKey1``.
+
+      .. container:: listingblock
+
+         .. container:: title
+
+            JS TaskParameter value
+
+         .. container:: content
+
+            .. code:: javascript
+
+               executor.parameters.get("ParameterKey1"))
+
+      .. container:: paragraph
+
+         Alternatively, the task parameters can also be accessed from the task object.
+
+      .. container:: listingblock
+
+         .. container:: title
+
+            JS TaskParameter value using task object
+
+         .. container:: content
+
+            .. code:: javascript
+
+               executor.subject.task.getTaskParameters.get("ParameterKey1").getTaskParameterValue()
+
 Local Variable for Infields
 ###########################
 
 Local Variable for Infields
 ###########################
 
@@ -2054,69 +2093,6 @@ Using Java in Scripting Logic
                importClass(java.util.ArrayList);
                var myList = new ArrayList();
 
                importClass(java.util.ArrayList);
                var myList = new ArrayList();
 
-Policy Examples
-^^^^^^^^^^^^^^^
-
-My First Policy
----------------
-
-         .. container:: paragraph
-
-            A good starting point is the ``My First Policy`` example. It
-            describes a sales problem, to which policy can be applied.
-            The example details the policy background, shows how to use
-            the REST Editor to create a policy, and provides details for
-            running the policies. The documentation can be found:
-
-         .. container:: ulist
-
-            -  `My-First-Policy on the APEX
-               site <https://ericsson.github.io/apex-docs/modules/examples/examples-myfirstpolicy/MyFirstPolicyHowto.html>`__
-
-            -  `Stand-alone
-               HTML <https://ericsson.github.io/apex-docs/docs-apex/html/HowTo-MyFirstPolicy.html>`__
-
-            -  `Stand-alone
-               PDF <https://ericsson.github.io/apex-docs/docs-apex/pdf/HowTo-MyFirstPolicy.pdf>`__
-
-VPN SLA
--------
-
-         .. container:: paragraph
-
-            The domain Policy-controlled Video Streaming (PCVS) contains
-            a policy for controlling video streams with different
-            strategies. It also provides details for installing an
-            actual testbed with off-the-shelve software (Mininet,
-            Floodlight, Kafka, Zookeeper). The policy model here
-            demonstrates virtually all APEX features: local context and
-            policies controlling it, task selection logic and multiple
-            tasks in a single state, AVRO schemas for context, AVOR
-            schemas for events (trigger and local), and a CLI editor
-            specification of the policy. The documentation can be found:
-
-         .. container:: ulist
-
-            -  `VPN SLA Policy on the APEX
-               site <https://ericsson.github.io/apex-docs/modules/examples/examples-pcvs/vpnsla/policy.html>`__
-
-Decision Maker
---------------
-
-         .. container:: paragraph
-
-            The domain Decision Maker shows a very simple policy for
-            decisions. Interesting here is that the it creates a Docker
-            image to run the policy and that it uses the APEX REST
-            applications to update the policy on the-fly. It also has
-            local context to remember past decisions, and shows how to
-            use that to no make the same decision twice in a row. The
-            documentation can be found:
-
-         .. container:: ulist
-
-            -  `Decision Maker on APEX
-               site <https://ericsson.github.io/apex-docs/modules/examples/examples-decisionmaker/index.html>`__
 
 .. container::
    :name: footer
 
 .. container::
    :name: footer
@@ -2124,8 +2100,8 @@ Decision Maker
    .. container::
       :name: footer-text
 
    .. container::
       :name: footer-text
 
-      2.0.0-SNAPSHOT
-      Last updated 2018-09-04 16:04:24 IST
+      2.3.0-SNAPSHOT
+      Last updated 2020-03-16 16:04:24 GMT
 
 .. |APEX Policy Matrix| image:: images/apex-intro/ApexPolicyMatrix.png
 .. |APEX Policy Model for Execution| image:: images/apex-policy-model/UmlPolicyModels.png
 
 .. |APEX Policy Matrix| image:: images/apex-intro/ApexPolicyMatrix.png
 .. |APEX Policy Model for Execution| image:: images/apex-policy-model/UmlPolicyModels.png