Repository: incubator-unomi
Updated Branches:
  refs/heads/master b5c5893e3 -> cae989b3b


http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/cae989b3/extensions/web-tracker/wab/pom.xml
----------------------------------------------------------------------
diff --git a/extensions/web-tracker/wab/pom.xml 
b/extensions/web-tracker/wab/pom.xml
index dbb462e..5040b51 100755
--- a/extensions/web-tracker/wab/pom.xml
+++ b/extensions/web-tracker/wab/pom.xml
@@ -74,7 +74,12 @@
         </plugins>
 
         <resources>
-            <resource><directory>../javascript/dist</directory></resource>
+            <resource>
+                <directory>../javascript/dist</directory>
+            </resource>
+            <resource>
+                <directory>src/main/resources</directory>
+            </resource>
         </resources>
     </build>
 

http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/cae989b3/extensions/web-tracker/wab/src/main/resources/META-INF/cxs/rules/form-mapping-example.json
----------------------------------------------------------------------
diff --git 
a/extensions/web-tracker/wab/src/main/resources/META-INF/cxs/rules/form-mapping-example.json
 
b/extensions/web-tracker/wab/src/main/resources/META-INF/cxs/rules/form-mapping-example.json
new file mode 100644
index 0000000..b03f91d
--- /dev/null
+++ 
b/extensions/web-tracker/wab/src/main/resources/META-INF/cxs/rules/form-mapping-example.json
@@ -0,0 +1,52 @@
+{
+  "itemId": "form-mapping-example",
+  "itemType": "rule",
+  "linkedItems": null,
+  "raiseEventOnlyOnceForProfile": false,
+  "raiseEventOnlyOnceForSession": false,
+  "priority": -1,
+  "metadata": {
+    "id": "form-mapping-example",
+    "name": "Example Form Mapping",
+    "description": "An example of how to map event properties to profile 
properties",
+    "scope": "realEstateManager",
+    "tags": [],
+    "enabled": true,
+    "missingPlugins": false,
+    "hidden": false,
+    "readOnly": false
+  },
+  "condition": {
+    "type": "formEventCondition",
+    "parameterValues": {
+      "formId": "testFormTracking",
+      "pagePath" : "/tracker/"
+    }
+  },
+  "actions": [
+    {
+      "type": "setPropertyAction",
+      "parameterValues": {
+        "setPropertyName": "properties(firstName)",
+        "setPropertyValue": "eventProperty::properties(firstName)",
+        "setPropertyStrategy": "alwaysSet"
+      }
+    },
+    {
+      "type": "setPropertyAction",
+      "parameterValues": {
+        "setPropertyName": "properties(lastName)",
+        "setPropertyValue": "eventProperty::properties(lastName)",
+        "setPropertyStrategy": "alwaysSet"
+      }
+    },
+    {
+      "type": "setPropertyAction",
+      "parameterValues": {
+        "setPropertyName": "properties(email)",
+        "setPropertyValue": "eventProperty::properties(email)",
+        "setPropertyStrategy": "alwaysSet"
+      }
+    }
+  ]
+}

http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/cae989b3/extensions/web-tracker/wab/src/main/webapp/index.html
----------------------------------------------------------------------
diff --git a/extensions/web-tracker/wab/src/main/webapp/index.html 
b/extensions/web-tracker/wab/src/main/webapp/index.html
index aa344a1..85437c7 100644
--- a/extensions/web-tracker/wab/src/main/webapp/index.html
+++ b/extensions/web-tracker/wab/src/main/webapp/index.html
@@ -20,17 +20,61 @@
 <html xmlns="http://www.w3.org/1999/xhtml"; xml:lang="en" lang="en">
 <head>
     <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
-    <title>Test</title>
+    <title>Apache Unomi Web Tracker Test Page</title>
 
     <meta name="Date-Revision-yyyymmdd" content="20180919"/>
     <meta http-equiv="Content-Language" content="en"/>
 
+    <style type="text/css">
+        form {
+            display: grid;
+            grid-template-columns: 200px 1fr;
+            grid-gap: 16px;
+        }
+
+        label {
+            grid-column: 1 / 2;
+        }
+
+        input,
+        button {
+            grid-column: 2 / 3;
+        }
+    </style>
+
     <script type="text/javascript">
         var unomiOption = {
             scope: 'realEstateManager',
             url: 'http://localhost:8181'
         };
-        window.unomiTracker||(window.unomiTracker={}),function(){function 
e(e){for(unomiTracker.initialize({"Apache Unomi":unomiOption});n.length>0;){var 
r=n.shift(),t=r.shift();unomiTracker[t]&&unomiTracker[t].apply(unomiTracker,r)}}for(var
 
n=[],r=["trackSubmit","trackClick","trackLink","trackForm","initialize","pageview","identify","reset","group","track","ready","alias","debug","page","once","off","on","personalize"],t=0;t<r.length;t++){var
 i=r[t];window.unomiTracker[i]=function(e){return function(){var 
r=Array.prototype.slice.call(arguments);return 
r.unshift(e),n.push(r),window.unomiTracker}}(i)}unomiTracker.load=function(){var
 
n=document.createElement("script");n.type="text/javascript",n.async=!0,n.src=unomiOption.url+"/tracker/unomi-tracker.min.js",n.addEventListener?n.addEventListener("load",function(n){"function"==typeof
 
e&&e(n)},!1):n.onreadystatechange=function(){"complete"!==this.readyState&&"loaded"!==this.readyState||e(window.event)};var
 r=document.getElementsByTagName(
 
"script")[0];r.parentNode.insertBefore(n,r)},document.addEventListener("DOMContentLoaded",unomiTracker.load),unomiTracker.page()}();
+        window.unomiTracker || (window.unomiTracker = {}), function () {
+            function e(e) {
+                for (unomiTracker.initialize({"Apache Unomi": unomiOption}); 
n.length > 0;) {
+                    var r = n.shift(), t = r.shift();
+                    unomiTracker[t] && unomiTracker[t].apply(unomiTracker, r)
+                }
+            }
+
+            for (var n = [], r = ["trackSubmit", "trackClick", "trackLink", 
"trackForm", "initialize", "pageview", "identify", "reset", "group", "track", 
"ready", "alias", "debug", "page", "once", "off", "on", "personalize"], t = 0; 
t < r.length; t++) {
+                var i = r[t];
+                window.unomiTracker[i] = function (e) {
+                    return function () {
+                        var r = Array.prototype.slice.call(arguments);
+                        return r.unshift(e), n.push(r), window.unomiTracker
+                    }
+                }(i)
+            }
+            unomiTracker.load = function () {
+                var n = document.createElement("script");
+                n.type = "text/javascript", n.async = !0, n.src = 
unomiOption.url + "/tracker/unomi-tracker.js", n.addEventListener ? 
n.addEventListener("load", function (n) {
+                    "function" == typeof e && e(n)
+                }, !1) : n.onreadystatechange = function () {
+                    "complete" !== this.readyState && "loaded" !== 
this.readyState || e(window.event)
+                };
+                var r = document.getElementsByTagName("script")[0];
+                r.parentNode.insertBefore(n, r)
+            }, document.addEventListener("DOMContentLoaded", 
unomiTracker.load), unomiTracker.page()
+        }();
     </script>
 
     <script type="text/javascript">
@@ -42,14 +86,14 @@
             path: path,
             pageInfo: {
                 destinationURL: location.href,
-                tags : [ "tag1", "tag2", "tag3"],
-                categories : ["category1", "category2", "category3"],
-                language : "en"
+                tags: ["tag1", "tag2", "tag3"],
+                categories: ["category1", "category2", "category3"],
+                language: "en"
             },
-            interests : {
-                "interest1" : 1,
-                "interest2" : 2,
-                "interest3" : 3
+            interests: {
+                "interest1": 1,
+                "interest2": 2,
+                "interest3": 3
             }
         };
         console.log(properties);
@@ -57,8 +101,11 @@
         window.unomiTracker.page(properties);
     </script>
 </head>
-<body class="composite">
-Test unomi
+<body>
+<h1>Apache Unomi Web Tracker Test Page</h1>
+
+<p>The line below this one will be personalized depending on whether you have 
been here for more or less than 5
+    seconds. Try reload the page to see the changes.</p>
 
 <div id="var1" style="display: none">
     You have been there for more than 5s
@@ -81,14 +128,38 @@ Test unomi
                     "type": "sessionDurationCondition"
                 }
             }]
-        },  {
+        }, {
             "id": "var2"
         }]
-    }, function(res) {
+    }, function (res) {
         console.log(res);
         document.getElementById(res[0]).style.display = 'block';
     });
 </script>
 
+<p>
+    The following form is an example of tracking form submissions with Apache 
Unomi's web tracker.
+</p>
+
+<form id="testFormTracking" action="#" name="testFormTracking">
+    <label for="firstName">First name</label>
+    <input type="text" id="firstName" name="firstName" value="John"/>
+
+    <label for="lastName">Last name</label>
+    <input type="text" id="lastName" name="lastName" value="Doe"/>
+
+    <label for="email">Email</label>
+    <input type="email" id="email" name="email" value="john...@acme.com"/>
+
+    <input type="submit" name="submitButton" value="Submit"/>
+</form>
+
+<script type="text/javascript">
+    window.addEventListener("load", function () {
+        var form = document.getElementById('testFormTracking');
+        unomiTracker.trackForm(form, 'formSubmitted', {formName: form.name});
+    });
+</script>
+
 </body>
 </html>

http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/cae989b3/manual/src/main/asciidoc/installing-tracker.adoc
----------------------------------------------------------------------
diff --git a/manual/src/main/asciidoc/installing-tracker.adoc 
b/manual/src/main/asciidoc/installing-tracker.adoc
index ed9766b..4314f89 100644
--- a/manual/src/main/asciidoc/installing-tracker.adoc
+++ b/manual/src/main/asciidoc/installing-tracker.adoc
@@ -112,4 +112,228 @@ object passed to the unomiTracker call. Default value : 
page path
 The `interests` object is basically list of interests with "weights" attached 
to them. These interests will be accumulated
 in Apache Unomi on profiles to indicate growing interest over time for 
specific topics. These are freely defined and
 will be accepted by Apache Unomi without needing to declare them previously 
anywhere (the same is true for tags and
-categories).
\ No newline at end of file
+categories).
+
+===== Tracking form submissions
+
+Using the web tracker you can also track form submissions. In order to do this 
a few steps are required to get a form's
+submission to be tracked and then its form values to be sent as events to 
Apache Unomi. Finally setting up a rule to
+react to the incoming event will help use the form values to perform any 
action that is desired.
+
+Let's look at a concrete example. Before we get started you should know that 
this example is already available to
+directly test in Apache Unomi at the following URL :
+
+    http://localhost:8181/tracker
+
+Simply modify the form values and click submit and it will perform all the 
steps we are describing below.
+
+So here is the form we want to track :
+
+[source]
+----
+<form id="testFormTracking" action="#" name="testFormTracking">
+    <label for="firstName">First name</label>
+    <input type="text" id="firstName" name="firstName" value="John"/>
+
+    <label for="lastName">Last name</label>
+    <input type="text" id="lastName" name="lastName" value="Doe"/>
+
+    <label for="email">Email</label>
+    <input type="email" id="email" name="email" value="john...@acme.com"/>
+
+    <input type="submit" name="submitButton" value="Submit"/>
+</form>
+----
+
+As you can see it's composed of three fields - firstName, lastName and email - 
as well as a submit button. In order to
+track it we can add directly under the following snippet :
+
+[source]
+----
+<script type="text/javascript">
+    window.addEventListener("load", function () {
+        var form = document.getElementById('testFormTracking');
+        unomiTracker.trackForm(form, 'formSubmitted', {formName: form.name});
+    });
+</script>
+----
+
+What this snippet does is retrieve the form using its element ID and then uses 
the unomiTracker to track form submissions.
+Be careful to always use in the form event name a string that starts with 
`form` in order for the event to be sent back
+to Unomi. Also the form name is also a mandatory parameter that will be passed 
to Unomi inside a event of type `form` under
+the `target.itemId` property name.
+
+Here is an example of the event that gets sent back to Apache Unomi:
+
+[source]
+----
+{
+  "itemId" : "cd627012-963e-4bb5-97f0-480990b41254",
+  "itemType" : "event",
+  "scope" : "realEstateManager",
+  "version" : 1,
+  "eventType" : "form",
+  "sessionId" : "aaad09aa-88c2-67bd-b106-5a47ded43ead",
+  "profileId" : "48563fd0-6319-4260-8dba-ae421beba26f",
+  "timeStamp" : "2018-11-23T16:32:26Z",
+  "properties" : {
+    "firstName" : "John",
+    "lastName" : "Doe",
+    "email" : "john...@acme.com",
+    "submitButton" : "Submit"
+  },
+  "source" : {
+    "itemId" : "/tracker/",
+    "itemType" : "page",
+    "scope" : "realEstateManager",
+    "version" : null,
+    "properties" : {
+      "pageInfo" : {
+        "destinationURL" : 
"http://localhost:8181/tracker/?firstName=Bill&lastName=Gates&email=bgates%40microsoft.com";,
+        "pageID" : "/tracker/",
+        "pagePath" : "/tracker/",
+        "pageName" : "Apache Unomi Web Tracker Test Page",
+        "referringURL" : 
"http://localhost:8181/tracker/?firstName=John&lastName=Doe&email=johndoe%40acme.com";
+      },
+      "attributes" : [ ],
+      "consentTypes" : [ ],
+      "interests" : { }
+    }
+  },
+  "target" : {
+    "itemId" : "testFormTracking",
+    "itemType" : "form",
+    "scope" : "realEstateManager",
+    "version" : null,
+    "properties" : { }
+  },
+  "persistent" : true
+}
+----
+
+You can see in this event that the form values are sent as properties of the 
event itself, while the form name is sent
+as the `target.itemId`
+
+While setting up form tracking, it can be very useful to use the Apache Unomi 
Karaf SSH shell commands : `event-tail`
+and `event-view` to check if you are properly receiving the form submission 
events and that they contain the expected
+data. If not, check your tracking code for any errors.
+
+Now that the data is properly sent using an event to Apache Unomi, we must 
still use it to perform some kind of actions.
+Using rules, we could do anything from updating the profile to sending the 
data to a third-party server (using a custom-
+developped action of course). In this example we will illustrate how to update 
the profile.
+
+In order to do so we will deploy a rule that will copy data coming from the 
event into a profile. But we will need to
+map the form field names to profile names, and this can be done using the 
`setPropertyAction` that's available out of the
+box in the Apache Unomi server.
+
+There are two ways to register rules : either by building a custom OSGi bundle 
plugin or using the REST API to directly
+send a JSON representation of the rule to be saved. We will in this example 
use the CURL shell command to make a call to
+the REST API.
+
+[source]
+----
+curl -X POST -k -u karaf:karaf https://localhost:9443/cxs/rules \
+  --header "Content-Type: application/json" \
+-d @- << EOF
+{
+  "itemId": "form-mapping-example",
+  "itemType": "rule",
+  "linkedItems": null,
+  "raiseEventOnlyOnceForProfile": false,
+  "raiseEventOnlyOnceForSession": false,
+  "priority": -1,
+  "metadata": {
+    "id": "form-mapping-example",
+    "name": "Example Form Mapping",
+    "description": "An example of how to map event properties to profile 
properties",
+    "scope": "realEstateManager",
+    "tags": [],
+    "enabled": true,
+    "missingPlugins": false,
+    "hidden": false,
+    "readOnly": false
+  },
+  "condition": {
+    "type": "formEventCondition",
+    "parameterValues": {
+      "formId": "testFormTracking",
+      "pagePath" : "/tracker/"
+    }
+  },
+  "actions": [
+    {
+      "type": "setPropertyAction",
+      "parameterValues": {
+        "setPropertyName": "properties(firstName)",
+        "setPropertyValue": "eventProperty::properties(firstName)",
+        "setPropertyStrategy": "alwaysSet"
+      }
+    },
+    {
+      "type": "setPropertyAction",
+      "parameterValues": {
+        "setPropertyName": "properties(lastName)",
+        "setPropertyValue": "eventProperty::properties(lastName)",
+        "setPropertyStrategy": "alwaysSet"
+      }
+    },
+    {
+      "type": "setPropertyAction",
+      "parameterValues": {
+        "setPropertyName": "properties(email)",
+        "setPropertyValue": "eventProperty::properties(email)",
+        "setPropertyStrategy": "alwaysSet"
+      }
+    }
+  ]
+}
+EOF
+----
+
+As you can see in this request, we have a few parameters that need explaining:
+
+- `-k` is used to accept any certificate as we are in this example using a 
default Apache Unomi server configuration that
+comes with its predefined HTTPS certificates
+- `-u karaf:karaf` is the default username/password for authenticating to the 
REST API. To change this value you should
+edit the `etc/users.properties`file and it is required to modify this login 
before going to production.
+
+Finally the rule itself should be pretty self-explanatory but there are a few 
important things to note :
+
+- the `itemId` and `metadata.id` values should be the same
+- the `scope` should be the same as the scope that was setup in the tracker 
initialization
+- the `formId` parameter must have the form name value
+- the `pagePath` should be the pagePath passed through the event (if you're 
not sure of its value, you could either using
+network debugging in the browser or use the `event-tail` and `event-view` 
commands in the Apache Unomi Karaf SSH shell).
+- the setPropertyAction may be repeated as many times as desired to copy the 
values from the event to the profile. Note that
+the `setPropertyName` will define the property to set on the profile and the 
`setPropertyValue` will define where the
+value is coming from. In this example the name and the value are the same but 
that is no way a requirement. It could
+even be possible to using multiple `setPropertyAction` instances to copy the 
same event property into different profile
+properties.
+
+To check if your rule is properly deployed you can use the following SSH shell 
command :
+
+`unomi:rule-view form-mapping-example`
+
+The parameter is the `itemId` of the rule. If you want to see all the rules 
deployed in the system you can use the
+command :
+
+`unomi:rule-list 1000`
+
+The `1000` parameter is the limit of number of objects to retrieve. As the 
number of rules can grow quickly in an Apache
+Unomi instance, it is recommended to put this value a bit high to make sure 
you get the full list of rules.
+
+Once the rule is in place, try submitting the form with some values and check 
that the profile is properly updated. One
+recommend way of doing this is to use the `event-tail` command that will 
output something like this :
+
+[source]
+----
+ID                                  |Type          |Session                    
         |Profile                             |Timestamp                    
|Scope          |Persi|
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+cef09b89-6b99-4e4f-a99c-a4159a66b42b|form          
|aaad09aa-88c2-67bd-b106-5a47ded43ead|48563fd0-6319-4260-8dba-ae421beba26f|Fri 
Nov 23 17:52:33 CET 2018 |realEstateManag|true |
+----
+
+You can directly see the profile that is being used, so you can then simply 
use the
+
+`unomi:profile-view 48563fd0-6319-4260-8dba-ae421beba26f`
+
+command to see a JSON dump of the profile and check that the form values have 
been properly positioned.
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/cae989b3/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/ProfileListCommand.java
----------------------------------------------------------------------
diff --git 
a/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/ProfileListCommand.java
 
b/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/ProfileListCommand.java
index 7af8a49..fe244c4 100644
--- 
a/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/ProfileListCommand.java
+++ 
b/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/ProfileListCommand.java
@@ -17,6 +17,7 @@
 package org.apache.unomi.shell.commands;
 
 import org.apache.commons.lang3.StringUtils;
+import org.apache.karaf.shell.commands.Argument;
 import org.apache.karaf.shell.commands.Command;
 import org.apache.unomi.api.PartialList;
 import org.apache.unomi.api.Profile;
@@ -42,6 +43,9 @@ public class ProfileListCommand extends ListCommandSupport {
         this.definitionsService = definitionsService;
     }
 
+    @Argument(index = 0, name = "maxEntries", description = "The maximum 
number of entries to retrieve (defaults to 100)", required = false, multiValued 
= false)
+    int maxEntries = 100;
+
     @java.lang.Override
     protected String[] getHeaders() {
         return new String[] {
@@ -57,6 +61,7 @@ public class ProfileListCommand extends ListCommandSupport {
     protected DataTable buildDataTable() {
         Query query = new Query();
         query.setSortby("properties.lastVisit:desc");
+        query.setLimit(maxEntries);
         Condition matchAllCondition = new 
Condition(definitionsService.getConditionType("matchAllCondition"));
         query.setCondition(matchAllCondition);
         PartialList<Profile> lastModifiedProfiles = 
profileService.search(query, Profile.class);

http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/cae989b3/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/RuleListCommand.java
----------------------------------------------------------------------
diff --git 
a/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/RuleListCommand.java
 
b/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/RuleListCommand.java
index d7ce5c6..23c9df3 100644
--- 
a/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/RuleListCommand.java
+++ 
b/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/RuleListCommand.java
@@ -17,25 +17,37 @@
 package org.apache.unomi.shell.commands;
 
 import org.apache.commons.lang3.StringUtils;
+import org.apache.karaf.shell.commands.Argument;
 import org.apache.karaf.shell.commands.Command;
 import org.apache.unomi.api.Metadata;
+import org.apache.unomi.api.PartialList;
+import org.apache.unomi.api.conditions.Condition;
+import org.apache.unomi.api.query.Query;
 import org.apache.unomi.api.rules.RuleStatistics;
+import org.apache.unomi.api.services.DefinitionsService;
 import org.apache.unomi.api.services.RulesService;
 import org.apache.unomi.common.DataTable;
 
 import java.util.ArrayList;
 import java.util.Map;
-import java.util.Set;
 
 @Command(scope = "unomi", name = "rule-list", description = "This will list 
all the rules deployed in the Apache Unomi Context Server")
 public class RuleListCommand extends ListCommandSupport {
 
     private RulesService rulesService;
+    private DefinitionsService definitionsService;
 
     public void setRulesService(RulesService rulesService) {
         this.rulesService = rulesService;
     }
 
+    public void setDefinitionsService(DefinitionsService definitionsService) {
+        this.definitionsService = definitionsService;
+    }
+
+    @Argument(index = 0, name = "maxEntries", description = "The maximum 
number of entries to retrieve (defaults to 100)", required = false, multiValued 
= false)
+    int maxEntries = 100;
+
     @Override
     protected String[] getHeaders() {
         return new String[] {
@@ -55,11 +67,18 @@ public class RuleListCommand extends ListCommandSupport {
 
     @Override
     protected DataTable buildDataTable() {
-        Set<Metadata> ruleMetadatas = rulesService.getRuleMetadatas();
+        Query query = new Query();
+        Condition matchAllCondition = new 
Condition(definitionsService.getConditionType("matchAllCondition"));
+        query.setCondition(matchAllCondition);
+        query.setLimit(maxEntries);
+        PartialList<Metadata> ruleMetadatas = 
rulesService.getRuleMetadatas(query);
+        if (ruleMetadatas.getList().size() != ruleMetadatas.getTotalSize()) {
+            System.out.println("WARNING : Only the first " + 
ruleMetadatas.getPageSize() + " have been retrieved, there are " + 
ruleMetadatas + " rules registered. Use the maxEntries parameter to retrieve 
more rules");
+        }
         Map<String,RuleStatistics> allRuleStatistics = 
rulesService.getAllRuleStatistics();
 
         DataTable dataTable = new DataTable();
-        for (Metadata ruleMetadata : ruleMetadatas) {
+        for (Metadata ruleMetadata : ruleMetadatas.getList()) {
             ArrayList<Comparable> rowData = new ArrayList<>();
             String ruleId = ruleMetadata.getId();
             rowData.add(ruleMetadata.isEnabled() ? "x" : "");

http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/cae989b3/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/SegmentListCommand.java
----------------------------------------------------------------------
diff --git 
a/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/SegmentListCommand.java
 
b/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/SegmentListCommand.java
index 858dc93..2c50403 100644
--- 
a/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/SegmentListCommand.java
+++ 
b/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/SegmentListCommand.java
@@ -17,6 +17,7 @@
 package org.apache.unomi.shell.commands;
 
 import org.apache.commons.lang3.StringUtils;
+import org.apache.karaf.shell.commands.Argument;
 import org.apache.karaf.shell.commands.Command;
 import org.apache.unomi.api.Metadata;
 import org.apache.unomi.api.PartialList;
@@ -34,6 +35,9 @@ public class SegmentListCommand extends ListCommandSupport {
         this.segmentService = segmentService;
     }
 
+    @Argument(index = 0, name = "maxEntries", description = "The maximum 
number of entries to retrieve (defaults to 100)", required = false, multiValued 
= false)
+    int maxEntries = 100;
+
     @Override
     protected String[] getHeaders() {
         return new String[] {
@@ -48,7 +52,7 @@ public class SegmentListCommand extends ListCommandSupport {
 
     @Override
     protected DataTable buildDataTable() {
-        PartialList<Metadata> segmentMetadatas = 
segmentService.getSegmentMetadatas(0, -1, null);
+        PartialList<Metadata> segmentMetadatas = 
segmentService.getSegmentMetadatas(0, maxEntries, null);
 
         DataTable dataTable = new DataTable();
         for (Metadata metadata : segmentMetadatas.getList()) {

http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/cae989b3/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/SessionListCommand.java
----------------------------------------------------------------------
diff --git 
a/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/SessionListCommand.java
 
b/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/SessionListCommand.java
index 237712a..1fc91c4 100644
--- 
a/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/SessionListCommand.java
+++ 
b/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/SessionListCommand.java
@@ -16,6 +16,7 @@
  */
 package org.apache.unomi.shell.commands;
 
+import org.apache.karaf.shell.commands.Argument;
 import org.apache.karaf.shell.commands.Command;
 import org.apache.unomi.api.PartialList;
 import org.apache.unomi.api.Session;
@@ -40,6 +41,9 @@ public class SessionListCommand extends ListCommandSupport {
         this.definitionsService = definitionsService;
     }
 
+    @Argument(index = 0, name = "maxEntries", description = "The maximum 
number of entries to retrieve (defaults to 100)", required = false, multiValued 
= false)
+    int maxEntries = 100;
+
     @java.lang.Override
     protected String[] getHeaders() {
         return new String[] {
@@ -56,6 +60,7 @@ public class SessionListCommand extends ListCommandSupport {
     protected DataTable buildDataTable() {
         Query query = new Query();
         query.setSortby("lastEventDate:desc");
+        query.setLimit(maxEntries);
         Condition matchAllCondition = new 
Condition(definitionsService.getConditionType("matchAllCondition"));
         query.setCondition(matchAllCondition);
         PartialList<Session> lastModifiedProfiles = 
profileService.searchSessions(query);

http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/cae989b3/tools/shell-dev-commands/src/main/resources/OSGI-INF/blueprint/blueprint.xml
----------------------------------------------------------------------
diff --git 
a/tools/shell-dev-commands/src/main/resources/OSGI-INF/blueprint/blueprint.xml 
b/tools/shell-dev-commands/src/main/resources/OSGI-INF/blueprint/blueprint.xml
index 8144a21..48ea840 100644
--- 
a/tools/shell-dev-commands/src/main/resources/OSGI-INF/blueprint/blueprint.xml
+++ 
b/tools/shell-dev-commands/src/main/resources/OSGI-INF/blueprint/blueprint.xml
@@ -36,6 +36,7 @@
         <shell:command>
             <shell:action 
class="org.apache.unomi.shell.commands.RuleListCommand">
                 <shell:property name="rulesService" ref="rulesService" />
+                <shell:property name="definitionsService" 
ref="definitionsService" />
             </shell:action>
         </shell:command>
         <shell:command>

Reply via email to