
After you design and create a composite activity (a block or a process), you may need to add, rename or consolidate roles. Roles are used to define processors for the different activities:
IGPAction
IGPModifiableBlockStructureItem.getActionRole()
IGPBlockIGPProcess
If not modified, the block roles are the union of all the roles of its children. When adding a new child to the block, its roles are copied automatically to the parent.
IGPModifiableRoleInfo
Adding New Roles
IGPModifiableBlock
| Adding New Roles to a Block |
|---|
importcom.sap.caf.eu.gp.process.api.IGPModifiableBlock; // add role "Block role 1" with technical name "role1" block.addRole("role1","Block Role 1");// add role "Block role 2"with technical name "role2" block.addRole("role2","Block Role 2");// remove role "Block role 1" block.removeRole("role1"); |
The technical name should not contain white spaces and should be no longer than 32 characters. It is unique amongst all the roles that have already been defined for the block.
IGPModifiableProcess
ROLE_TYPE_INITIATION_DEFINED
ROLE_TYPE_INITIATOR
ROLE_TYPE_RT_DEFINED
| Adding New Roles to a Process |
|---|
importcom.sap.caf.eu.gp.process.api.IGPModifiableProcess; importcom.sap.caf.eu.gp.process.api.GPRoleType; // add role "Processor" of type Initiator process.addRole("processor","Processor", GPRoleType.ROLE_TYPE_INITIATOR);// add role "Advisor" of type Runtime Defined process.addRole("advisor","Advisor", GPRoleType.ROLE_TYPE_RT_DEFINED);// add role "Processor" of type Initiation Defined process.addRole("employee","Employee", GPRoleType.ROLE_TYPE_INITIATION_DEFINED); |
Modifying Existing Roles
You can modify the roles you have created and all other existing roles by changing their properties.
In addition to the roles that processes inherit from their child activities, there are three more automatically created built-in roles, which cannot be removed:
| Modifying Roles |
|---|
importcom.sap.caf.eu.gp.process.api.IGPModifiableProcess; importcom.sap.caf.eu.gp.process.api.IGPModifiableBlock; importcom.sap.caf.eu.gp.process.api.IGPModifiableRoleInfo; importcom.sap.caf.eu.gp.process.api.GPRoleType; // modify description of block role "Advisor" IGPModifiableRoleInfo blockRole = block.getRole("advisor").setText("New Advisor");// change type of built-in process role "Overseer" IGPModifiableRoleInfo processRole = process.getModifiableOverseerRole().setRoleType(GPRoleType. ROLE_TYPE_INITIATOR); |
Consolidating Roles
IGPRoleMapIGPRoleMapping
The example below maps the default roles of two child actions to a single block role, thus consolidating the roles.
| Mapping Roles |
|---|
importcom.sap.caf.eu.gp.process.api.IGPModifiableBlock; importcom.sap.caf.eu.gp.process.api.IGPRoleMapping; // map role of action_1 to block role "processor" IGPRoleMapping mapping_1 = block.getRoleMap().mapRole(block.getRole("action_1"),block.getModifiableStructure().getItem(0).getID(), block.getRole("processor"));// map role of action_2 to block role "processor" IGPRoleMapping mapping_2 = block.getRoleMap().mapRole(block.getRole("action_2"),block.getModifiableStructure().getItem(1).getID(), block.getRole("processor")); |
You can also view available mappings or remove them if you no longer need them:
| Retrieving and Removing Role Mappings |
|---|
importcom.sap.caf.eu.gp.process.api.IGPModifiableBlock; importcom.sap.caf.eu.gp.process.api.IGPRoleMapping; importjava.util.Iterator; // remove "mapping_1" created previously block.getRoleMap().unmapRole(mapping_1); // view all available role mappings for a block Iterator listAll = block.getRoleMap().getRoleMappings(); // view available mappings for a given parent role in a block Iterator listRole = block.getRoleMap().getRoleMappings("processor"); |