You can create processes using the GP design time API. The interface allows you to manipulate the process structure and properties.
You have instantiated the IGPDesigntimeUpdateManager. For more information, see Instantiating the Design Time Manager.
...
1. Create a process by providing its basic data:
You need to specify a category for the newly-created process. For this purpose, you can create a new category or provide the Id of an existing one.
Creating a Process |
import java.util.Locale; import com.sap.caf.eu.gp.context.api.IGPUserContext; import com.sap.caf.eu.gp.process.api.IGPCategory; import com.sap.caf.eu.gp.process.api.IGPModifiableProcess; import com.sap.caf.eu.gp.process.api.GPProcessFactory; import com.sap.caf.eu.gp.process.dt.api.IGPDesigntimeManager; import com.sap.caf.eu.gp.process.dt.api.IGPDesigntimeUpdateManager;
// instantiate the design time manager to get the root category IGPDesigntimeManager dtManager = GPProcessFactory.getDesigntimeManager(); IGPCategory root = dtManager.getRootCategory(userContext);
// create a new category “test” in the root category IGPCategory cat = manager.createCategory("test", "A test category", root);
// create a process in the cat category String pName = "Test API Process"; String pDescription = "Test API Process Description"; IGPModifiableProcess process = manager.createProcess( Locale.getDefault(), pName, pDescription, cat.getID() ); |
2. Add blocks to the process.
The process content is represented by a structure (IGPModifiableBlockStructure). It is an indexed sequence of items (IGPModifiableBlockStructureItem), which hold object references to activities within the process.
Process structure items also hold information about parameter mappings, transitions between activities, exception handling and role information.
The GP design time API provides the following functionalities for process structure manipulation:
○ Adding an item to the structure
○ Inserting an item into a specific position in the structure
○ Replacing an item in the structure
○ Exchanging two items in the structure
○ Deleting an item from the structure
Since the process itself is a top-level block, the operations listed above are equivalent to the ones described in Creating Blocks.
import com.sap.caf.eu.gp.process.api.IGPModifiableBlockStructure; import com.sap.caf.eu.gp.process.api.IGPModifiableBlock; // add a block to the process structure IGPModifiableBlockStructure pStruct = process.getModifiableStructure(); pStruct.addItem(block);
|
3. Optionally, you can add new roles to the process, specify their type, and assign default users.
Default users can be changed at runtime if you allow it with the setIsOverWriteAllowed() method. If you do not provide defaults, and the role type is Initiation Defined, you must create a role instance and assign a specific user to it before you start the process.
import com.sap.caf.eu.gp.process.api.GPRoleType;
// add role Processor of type Initiator IGPModifiableRoleInfo role = process.addRole("processor", "Processor", GPRoleType.ROLE_TYPE_INITIATOR);
// add role Advisor of type Initiation Defined process.addRole("advisor", "Advisor", GPRoleType.ROLE_TYPE_INITIATION_DEFINED);
// add a default principal to the role (IPrincipal)
role.addDefault(defaultPrincipal);
// allow defaults to be overwritten at runtime
role.setIsOverWriteAllowed(true);
|
4. Make sure you save and release the process after you have created and modified it.
manager.save(process); manager.release(process);
|
Once you have created a process, assigned blocks and roles to it, you can also:
● Map local, input and output parameters
See Implementing Parameter Mapping.
● Consolidate process roles
See Implementing Role Consolidation.
For more information on how to edit processes, see Editing GP Development Objects.