
You can create blocks using the GP design time API. The interface allows you to manipulate with block types and structure.
You have instantiated the IGPDesigntimeUpdateManager . For more information, see Instantiating the Design Time Manager .
You need to specify a category for the newly-created block. For this purpose, you can create a new category or provide the Id of an existing one.
| Creating a Block |
|---|
importjava.util.Locale; importcom.sap.caf.eu.gp.context.api.IGPUserContext; importcom.sap.caf.eu.gp.process.api.IGPCategory; importcom.sap.caf.eu.gp.process.api.IGPModifiableBlock; importcom.sap.caf.eu.gp.process.api.GPProcessFactory; importcom.sap.caf.eu.gp.process.dt.api.IGPDesigntimeManager; importcom.sap.caf.eu.gp.process.dt.api.IGPDesigntimeUpdateManager; importcom.sap.caf.eu.gp.process.api.GPBlockType; // instantiate the design time manager to get the root category IGPDesigntimeManagerdtManager = GPProcessFactory.getDesigntimeManager(); IGPCategoryroot = dtManager.getRootCategory(userContext); // create a new category "test" in the root category IGPCategory cat = manager.createCategory("test","A test category", root);// create a block in the cat category StringbName = "Block"; StringbDescription = "A test block"; IGPModifiableBlockb = manager.createBlock( GPBlockType.BLOCK_TYPE_SEQUENTIAL, Locale.getDefault(), bName, bDescription, cat.getID() ); |
The example above implements a sequential block type. Currently, the GP API supports the following block types:
For more information on block types, see Creating Blocks in Modeling and Configuring Workflows.
The block content is represented by a block structure ( IGPModifiableBlockStructure ). It is an indexed sequence of items ( IGPModifiableBlockStructureItem ), which hold object references to activities within the block.
Block 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 block structure manipulation:
We define a block b with three actions: a_0 , a_1 , a_2 .
importcom.sap.caf.eu.gp.process.api.IGPModifiableAction; IGPModifiableBlockb = null; try{// create the block and the actions ... // add the actions to the structure b.getModifiableStructure().addItem(a_0); b.getModifiableStructure().addItem(a_1); b.getModifiableStructure().addItem(a_2); // save the block object manager.save(b); } finally { if (b != null) {// release the block object manager.release(b); } } |
For more information on how to implement actions, see Creating Actions .
Suppose you have already created and saved block b, and for some reason you decide that you need to execute another activity before action a_1 , a block named b_0 for example. You insert the block into the structure on position 2. Thus, action a_1 is shifted to position 3.
b.getModifiableStructure().insertItem(2,b_0); |
a_1b_0
| b.getModifiableStructure().setItem(3, b_0); |
b_0a_2
| b.getModifiableStructure().swap(3, 4); |
To delete the item on position 1 (a _0 ), write:
| b.getModifiableStructure().removeItem(1); |
manager.save(b); manager.release(b); |
Once you have assigned actions to the block, you can also:
See Defining Transitions .
For more information about block editing, see Editing GP Development Objects .