Appendix : Legacy Presto components : Business Analytics Development and APIs : Map Business Analytics Attributes to Artifact Input Parameters : Define Business Analytics Session Attributes
Define Business Analytics Session Attributes
You define Business Analytics session attributes in the request that generates the response with the data to be saved. Session attributes allow you to save data from one request and use it in subsequent requests for the current session. It is useful for sensitive or personal information that should remain in the Business Analytics Server for security or privacy reasons.
You use the optional Business Analytics Header/Parameter x-p-sessionbinding to define session attributes. This header takes an object with attribute definition expressions. Each expression provides the name for a new session attribute and an XPath expression that identifies the node within the response that should be saved in this attribute for the current session.
The XPath expression can identify a node with a simple value, such as '@session.ssn':'/customer/SSN'.
They can also identify nodes sets, such as '@session.articles':'/rss/channel/item' or one node with complex content, such as '@session.firstArticle':'/rss/channel/item[1]'. See A Brief Introduction to XPath 2.0 for more information on XPath expressions.
Note:  
The @ symbol defines a session attribute. You refer to session parameters with $, just as you do with global or user parameters. See Define Business Analytics Session Attributes for this syntax.
This first session mapping example takes a query response and maps two nodes with simple content to two Business Analytics session attributes.
Defining Session Attributes with Simple Values
...
connection.request({
url: "/mashzone/edge/api/rest/CustomerQuery/getCustomer?id=mr321y98&x-presto-resultFormat=
json&x-p-sessionbinding={'@session.ssn':'/customer/SSN','@session.name':'customer/name'},
type: "get",
contentType: "application/x-www-form-urlencoded",
data: requestBody
},
{ onSuccess: function(response, responseHeaders) {
//handle response data
},
onFailure: function(e) {
//handle error message
}
});
A later request then maps these Business Analytics session attributes to mashable input parameters:
Mapping Session Attributes with Simple Values
...
connection.request({
url: "/mashzone/edge/api/rest/CustomerNotices/renewalNotice?x-presto-resultFormat=
json&custSSN=$session/ssn&custName=$session/name,
type: "get",
contentType: "application/x-www-form-urlencoded",
data: requestBody
},
{ onSuccess: function(response, responseHeaders) {
//handle response data
},
onFailure: function(e) {
//handle error message
}
});
The next session mapping example shows a mapping from an RSS feed. This defines a complex Business Analytics session attribute that contains feed data for the first article from this web feed.
Defining Session Attributes with Complex Content
...
connection.request({
url: "/mashzone/edge/api/rest/someRSSFeed/getData?x-presto-resultFormat=json&x-p-sessionbinding={'@session.firstArticle':'/rss/channel/item[1]'},
type: "get",
contentType: "application/x-www-form-urlencoded",
data: requestBody
},
{ onSuccess: function(response, responseHeaders) {
//handle response data
},
onFailure: function(e) {
//handle error message
}
});
A later request then maps data from nodes within this Business Analytics session attribute to input parameters:
Mapping Session Attributes with Complex Content
...
connection.request({
url: "/mashzone/edge/api/rest/myMayshup/Invoke?x-presto-resultFormat=json&article=$session/
firstArticle/item/title&link=$session/firstArticle/rss/channel/item/link,
type: "get",
contentType: "application/x-www-form-urlencoded",
data: requestBody
},
{ onSuccess: function(response, responseHeaders) {
//handle response data
},
onFailure: function(e) {
//handle error message
}
});
Copyright © 2013-2017 Software AG, Darmstadt, Germany. (Innovation Release)

Product LogoContact Support   |   Community   |   Feedback