You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@unomi.apache.org by am...@apache.org on 2017/04/14 13:07:08 UTC

[1/2] incubator-unomi git commit: UNOMI-86 : Implement overrides for scores and put segments, scores and profileproperties in the same object (Profile object)

Repository: incubator-unomi
Updated Branches:
  refs/heads/master daaa332a2 -> 28b63e665


UNOMI-86 : Implement overrides for scores and put segments,scores and profileproperties in the same object (Profile object)


Project: http://git-wip-us.apache.org/repos/asf/incubator-unomi/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-unomi/commit/a8e52038
Tree: http://git-wip-us.apache.org/repos/asf/incubator-unomi/tree/a8e52038
Diff: http://git-wip-us.apache.org/repos/asf/incubator-unomi/diff/a8e52038

Branch: refs/heads/master
Commit: a8e5203820f8b38283f1f03ce6ef882d6a1d1dd8
Parents: 4ff30d4
Author: rizak <ri...@gmail.com>
Authored: Thu Mar 16 10:09:11 2017 +0100
Committer: rizak <ri...@gmail.com>
Committed: Thu Mar 16 10:09:11 2017 +0100

----------------------------------------------------------------------
 .../org/apache/unomi/api/ContextRequest.java    | 38 +++++---------------
 .../markdown/versions/1.1/getting-started.md    |  8 +++--
 .../markdown/versions/master/getting-started.md |  8 +++--
 .../org/apache/unomi/web/ContextServlet.java    | 32 +++++++++++------
 4 files changed, 41 insertions(+), 45 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/a8e52038/api/src/main/java/org/apache/unomi/api/ContextRequest.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/unomi/api/ContextRequest.java b/api/src/main/java/org/apache/unomi/api/ContextRequest.java
index 5e2c115..1803bf6 100644
--- a/api/src/main/java/org/apache/unomi/api/ContextRequest.java
+++ b/api/src/main/java/org/apache/unomi/api/ContextRequest.java
@@ -60,9 +60,7 @@ public class ContextRequest {
     // the following overrides make it possible to override temporarily the current profile segments, properties or
     // even session properties. This is useful for building UIs to temporarily override one of these parameters to
     // test different filter results.
-
-    private Set<String> segmentOverrides;
-    private Map<String, Object> profilePropertiesOverrides;
+    private Profile profileOverrides;
     private Map<String, Object> sessionPropertiesOverrides;
 
     /**
@@ -182,39 +180,21 @@ public class ContextRequest {
     }
 
     /**
-     * Retrieves the segment overrides.
-     *
-     * @return the segment overrides
-     */
-    public Set<String> getSegmentOverrides() {
-        return segmentOverrides;
-    }
-
-    /**
-     * Sets the segment overrides.
-     *
-     * @param segmentOverrides the segment overrides
-     */
-    public void setSegmentOverrides(Set<String> segmentOverrides) {
-        this.segmentOverrides = segmentOverrides;
-    }
-
-    /**
-     * Retrieves the profile properties overrides.
+     * Retrieves the overrides.
      *
-     * @return the profile properties overrides
+     * @return the overrides
      */
-    public Map<String, Object> getProfilePropertiesOverrides() {
-        return profilePropertiesOverrides;
+    public Profile getProfileOverrides() {
+        return profileOverrides;
     }
 
     /**
-     * Sets the profile properties overrides.
+     * Sets the overrides.
      *
-     * @param profilePropertiesOverrides the profile properties overrides
+     * @param overrides the collection<String> overrides out of profileProperties and sessionProperties
      */
-    public void setProfilePropertiesOverrides(Map<String, Object> profilePropertiesOverrides) {
-        this.profilePropertiesOverrides = profilePropertiesOverrides;
+    public void setProfileOverrides(Profile overrides) {
+        this.profileOverrides = overrides;
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/a8e52038/src/site/markdown/versions/1.1/getting-started.md
----------------------------------------------------------------------
diff --git a/src/site/markdown/versions/1.1/getting-started.md b/src/site/markdown/versions/1.1/getting-started.md
index f052649..80d3b95 100644
--- a/src/site/markdown/versions/1.1/getting-started.md
+++ b/src/site/markdown/versions/1.1/getting-started.md
@@ -198,8 +198,10 @@ Let's look at the context request structure:
     requiredProfileProperties: <optional array of property identifiers>,
     requiredSessionProperties: <optional array of property identifiers>,
     filters: <optional array of filters to evaluate>,
-    segmentOverrides: <optional array of segment identifiers>,
-    profilePropertiesOverrides: <optional map of property name / value pairs>,
+    profileOverrides: <optional profile containing segments,scores or profile properties to override>,
+        - segments: <optional array of segment identifiers>,
+        - profileProperties: <optional map of property name / value pairs>,
+        - scores: <optional map of score id / value pairs>
     sessionPropertiesOverrides: <optional map of property name / value pairs>,
     requiresSegments: <boolean, whether to return the associated segments>
 }
@@ -214,7 +216,7 @@ A context request payload needs to at least specify some information about the s
 A client wishing to perform content personalization might also specify filtering conditions to be evaluated by the context server so that it can tell the client whether the content associated with the filter should be activated for this profile/session. This is accomplished by providing a list of filter definitions to be evaluated by the context server via the `filters` field of the payload. If provided, the evaluation results will be provided in the `filteringResults` field of the resulting `cxs` object the context server will send.
 
 #### Overrides
-It is also possible for clients wishing to perform user impersonation to specify properties or segments to override the proper ones so as to emulate a specific profile, in which case the overridden value will temporarily replace the proper values so that all rules will be evaluated with these values instead of the proper ones. The `segmentOverrides` (array of segment identifiers), `profilePropertiesOverrides` and `sessionPropertiesOverrides` (maps of property name and associated object value) fields allow to provide such information. Providing such overrides will, of course, impact content filtering results and segments matching for this specific request.
+It is also possible for clients wishing to perform user impersonation to specify properties, segments or scores to override the proper ones so as to emulate a specific profile, in which case the overridden value will temporarily replace the proper values so that all rules will be evaluated with these values instead of the proper ones. The `segments` (array of segment identifiers), `profileProperties` (maps of property name and associated object value) and `scores` (maps of score id and value) all wrapped in a profileOverrides object and the `sessionPropertiesOverrides` (maps of property name and associated object value) fields allow to provide such information. Providing such overrides will, of course, impact content filtering results and segments matching for this specific request.
 
 #### Controlling the content of the response
 The clients can also specify which information to include in the response by setting the `requiresSegments` property to true if segments the current profile matches should be returned or provide an array of property identifiers for `requiredProfileProperties` or `requiredSessionProperties` fields to ask the context server to return the values for the specified profile or session properties, respectively. This information is provided by the `profileProperties`, `sessionProperties` and `profileSegments` fields of the context server response.

http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/a8e52038/src/site/markdown/versions/master/getting-started.md
----------------------------------------------------------------------
diff --git a/src/site/markdown/versions/master/getting-started.md b/src/site/markdown/versions/master/getting-started.md
index f052649..2885965 100644
--- a/src/site/markdown/versions/master/getting-started.md
+++ b/src/site/markdown/versions/master/getting-started.md
@@ -198,8 +198,10 @@ Let's look at the context request structure:
     requiredProfileProperties: <optional array of property identifiers>,
     requiredSessionProperties: <optional array of property identifiers>,
     filters: <optional array of filters to evaluate>,
-    segmentOverrides: <optional array of segment identifiers>,
-    profilePropertiesOverrides: <optional map of property name / value pairs>,
+    profileOverrides: <optional profile containing segments,scores or profile properties to override>,
+            - segments: <optional array of segment identifiers>,
+            - profileProperties: <optional map of property name / value pairs>,
+            - scores: <optional map of score id / value pairs>
     sessionPropertiesOverrides: <optional map of property name / value pairs>,
     requiresSegments: <boolean, whether to return the associated segments>
 }
@@ -214,7 +216,7 @@ A context request payload needs to at least specify some information about the s
 A client wishing to perform content personalization might also specify filtering conditions to be evaluated by the context server so that it can tell the client whether the content associated with the filter should be activated for this profile/session. This is accomplished by providing a list of filter definitions to be evaluated by the context server via the `filters` field of the payload. If provided, the evaluation results will be provided in the `filteringResults` field of the resulting `cxs` object the context server will send.
 
 #### Overrides
-It is also possible for clients wishing to perform user impersonation to specify properties or segments to override the proper ones so as to emulate a specific profile, in which case the overridden value will temporarily replace the proper values so that all rules will be evaluated with these values instead of the proper ones. The `segmentOverrides` (array of segment identifiers), `profilePropertiesOverrides` and `sessionPropertiesOverrides` (maps of property name and associated object value) fields allow to provide such information. Providing such overrides will, of course, impact content filtering results and segments matching for this specific request.
+It is also possible for clients wishing to perform user impersonation to specify properties or segments to override the proper ones so as to emulate a specific profile, in which case the overridden value will temporarily replace the proper values so that all rules will be evaluated with these values instead of the proper ones. The `segments` (array of segment identifiers), `profileProperties` (maps of property name and associated object value) and `scores` (maps of score id and value) all wrapped in a profileOverrides object and the `sessionPropertiesOverrides` (maps of property name and associated object value) fields allow to provide such information. Providing such overrides will, of course, impact content filtering results and segments matching for this specific request.
 
 #### Controlling the content of the response
 The clients can also specify which information to include in the response by setting the `requiresSegments` property to true if segments the current profile matches should be returned or provide an array of property identifiers for `requiredProfileProperties` or `requiredSessionProperties` fields to ask the context server to return the values for the specified profile or session properties, respectively. This information is provided by the `profileProperties`, `sessionProperties` and `profileSegments` fields of the context server response.

http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/a8e52038/wab/src/main/java/org/apache/unomi/web/ContextServlet.java
----------------------------------------------------------------------
diff --git a/wab/src/main/java/org/apache/unomi/web/ContextServlet.java b/wab/src/main/java/org/apache/unomi/web/ContextServlet.java
index c1c096c..d3cd840 100644
--- a/wab/src/main/java/org/apache/unomi/web/ContextServlet.java
+++ b/wab/src/main/java/org/apache/unomi/web/ContextServlet.java
@@ -372,18 +372,30 @@ public class ContextServlet extends HttpServlet {
         return changes;
     }
 
+    /**
+     * This function will update the profile if it is from Persona instance.
+     * The profile will be updated using the overrides attributes :
+     * - profileOverrides for profile properties, segments and scores
+     * - sessionPropertiesOverrides for session properties
+     * @param contextRequest
+     * @param profile
+     * @param session
+     */
     private void processOverrides(ContextRequest contextRequest, Profile profile, Session session) {
         if (profile instanceof Persona) {
-            if (contextRequest.getSegmentOverrides() != null) {
-                profile.setSegments(contextRequest.getSegmentOverrides());
-            }
-
-            if (contextRequest.getProfilePropertiesOverrides() != null) {
-                profile.setProperties(contextRequest.getProfilePropertiesOverrides());
-            }
-
-            if (contextRequest.getSessionPropertiesOverrides() != null) {
-                session.setProperties(contextRequest.getSessionPropertiesOverrides()); // we do this just in case a cache is behind this
+            if (contextRequest.getProfileOverrides() != null) {
+                if(contextRequest.getProfileOverrides().getScores()!=null){
+                    profile.setScores(contextRequest.getProfileOverrides().getScores());
+                }
+                if(contextRequest.getProfileOverrides().getSegments()!=null){
+                    profile.setSegments(contextRequest.getProfileOverrides().getSegments());
+                }
+                if(contextRequest.getProfileOverrides().getProperties()!=null){
+                    profile.setProperties(contextRequest.getProfileOverrides().getProperties());
+                }
+                if(contextRequest.getSessionPropertiesOverrides()!=null){
+                    session.setProperties(contextRequest.getSessionPropertiesOverrides());
+                }
             }
         }
     }


[2/2] incubator-unomi git commit: This closes pull request number #27

Posted by am...@apache.org.
This closes pull request number #27


Project: http://git-wip-us.apache.org/repos/asf/incubator-unomi/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-unomi/commit/28b63e66
Tree: http://git-wip-us.apache.org/repos/asf/incubator-unomi/tree/28b63e66
Diff: http://git-wip-us.apache.org/repos/asf/incubator-unomi/diff/28b63e66

Branch: refs/heads/master
Commit: 28b63e6651ec01bfb08b8b19dbd1ebb7d567107c
Parents: daaa332 a8e5203
Author: Abdelkader Midani <am...@apache.org>
Authored: Fri Apr 14 15:04:18 2017 +0200
Committer: Abdelkader Midani <am...@apache.org>
Committed: Fri Apr 14 15:04:18 2017 +0200

----------------------------------------------------------------------
 .../org/apache/unomi/api/ContextRequest.java    | 38 +++++---------------
 .../markdown/versions/1.1/getting-started.md    |  8 +++--
 .../markdown/versions/master/getting-started.md |  8 +++--
 .../org/apache/unomi/web/ContextServlet.java    | 33 +++++++++++------
 4 files changed, 41 insertions(+), 46 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/28b63e66/wab/src/main/java/org/apache/unomi/web/ContextServlet.java
----------------------------------------------------------------------