Pages

Monday, January 21, 2019

Groovy Series 2: Privileged Methods

“With great power comes great responsibility” is what Oracle wants to remind us by assigning certain methods in Groovy classes as privileged methods. Privileged methods restrict executing these methods in groovy rules unless user has administrator privileges.
Privileged Methods:
  • delete: Delete method in the Member Class. This method deletes the member and all its descendants from Planning outline
  • saveMember: saveMember method in the Dimension Class. This method returns the member that was created based on the properties map defined for the member
  • execute: execute method in DataMap Class. This method executes the already defined data map in the application
So what happens if a user with non admin privileges attempt to execute any groovy rule using any of these three functions? Here’s an example where a non admin user tries to execute a rule with data map and receives following error.

image

It’s obvious that these three functionalities should be controlled and handled with responsibility as an administrator, but some use cases where this functionality can be used to offer administrators a convenient way to manage things as well better user experience
  • Example 1: Consider a multi cube application and administrator is required to execute rules on BSO plan type, execute the data map to move data from BSO to ASO and then run a business rule on ASO. In a regular non-groovy environment would require an admin to juggle between multiple screens to perform all tasks, whereas with groovy being available, all the steps can be clubbed together into a ruleset and all admin needs to do is, trigger it from the rules card.
  • Example 2: Consider a scenario to implement a workflow to add a new project or a new asset. Users add their projects under “New Projects” parent and administrator is expected to approve the project and move it to new parent based on project type. Above that administrator is also expected to rename the project to follow the member name and alias name naming convention. Groovy can handle it all with ease and that too with click of a button. We need to define the member properties and use the saveMember method to perform the required functionality.
  • Example 3: Consider project dimension’s metadata gets refreshed daily and there are three attributes tagged to each level zero project member. Since business logic is driven by these attributes, admin needs to ensure all members of project dimension have correct attributes associated with them. Either admin evaluates it via smart view admin plug-in or a nice webform can be created which highlights which all members are missing attributes and set their properties.

Cheers !!!

No comments:

Post a Comment