Filtering the Data Shown in a Report Based on the Logged in User's Team Membership
The Process Monitor dashboard demonstrates how you can use ActiveMatrix BPM web services to obtain organizational information about the dashboard user (in this case, whether they are a team leader, and of which team), and so restrict the data presented to that user based on their team membership and role.
In the example Claims application, the organization model provides a simplistic model of EasyAs Insurance's claims processing organization, comprising a front desk team and a back desk team, each with a manager:
In TIBCO Business Studio:
- The front desk team, back desk team and managers are each modeled as a Group.
- a TeamName resource attribute is added to the CompanyOrganizationModel project.
At runtime (see Mapping Users from the EasyAs LDAP Source to the Claims Organization Model):
- The following resources are mapped to each group.
- The team managers have the following values assigned to their TeamName resource attribute. (Other team members do not have a TeamName value assigned.)
When the Process Monitor dashboard (jaspershowcase.html) is opened in Openspace, the onReportLoaded function calls getTeam (in Jaspershowcase.java).
function onReportLoaded() { // This method will be called when the GWT onModuleLoad has run so we // know at this point that it will have exported any methods we may // need. // Now call into GWT Layer to trigger it to go and work out the team. // Because this is async it will not return it here, but rather will // call a method later to set it. // We pass in a callback function which we would like to be called when // this operation is complete getTeam(setMyTeam); }
- getTeam calls the BPM Web Client API GetAuthenticatedUserName operation to find the name of the logged in user.
- getTeam now needs to look up the value of that user's TeamName attribute. However, this cannot be done directly from the BPM Web Client API, so it calls getMyResourceAttribute, which is a JSNI method that in turn invokes the callGetResource function in osApi.js.
- callGetResource uses the following BPM REST API calls to obtain the value of the user's TeamName attribute, which it then passes back to the setResourceAttribute function (in Jaspershowcase.java):
- setResourceAttribute:
- setMyTeam initializes required variables with the team information and updates the context object.
function setMyTeam(teamname, teamnames) { teamName = teamname; myTeam = teamnames; updateContext(); setTeamMode(true); //Now we initialise Visualise.js initVisualise(init); }
The team information can now be passed as a parameter (via context.team) to the various reports when they are called or updated. Each report can use the team information as required to filter, construct and/or display the required data.