When you insert callable objects into actions, you need to map their parameters. Depending on the type of the callable object, you have to define different mappings:
· Callable object for execution – map its input and output parameters to the local context of the action
· Callable object for display – map its input parameters to the output parameters of the callable object for execution
Mapping information is always stored in the IGPObjectReference corresponding to the inserted callable object.
...
● You have instantiated the IGPDesigntimeUpdateManager.
See Instantiating the Design Time Manager.
● You have created a callable object with context parameters and inserted it into an action.
See Creating GP Development Objects.
1. Copy the input and output parameters of the callable object for execution to the input and output contexts of the action respectively. For more information, see Creating Actions.
2. Copy the input and output parameters of the callable object for execution to the local context of the action.
Copying Input Parameters to Local Context |
import com.sap.caf.eu.gp.process.api.IGPCallableObject; import com.sap.caf.eu.gp.process.api.IGPModifiableAction; import com.sap.caf.eu.gp.structure.api.IGPStructureInfo; import com.sap.caf.eu.gp.structure.api.IGPAttributeInfo; import java.util.Collection; import java.util.Iterator;
// retrieve action’s local context IGPStructureInfo local = action.getLocalParameters();
// retrieve the callable object for execution IGPCallableObject exco = a.getExecuteCallableObject().getCallableObject();
// retrieve object’s input context IGPStructureInfo in = exco.getInputParameters();
// retrieve input attributes Collection attributes = in.getAttributes(); // for each attribute in the list for (Iterator iter = attributes.iterator(); iter.hasNext();) { IGPAttributeInfo attribute = (IGPAttributeInfo) iter.next(); // create a corresponding attribute in local structure IGPAttributeInfo aCopy = local.addAttribute(attribute.getTechName(), attribute.getNamespace(), attribute.getType()); // set multiplicity of the new attribute aCopy.setMultiplicity(attribute.getMultiplicity());}
// retrieve input substructures Collection structures = in.getStructures(); // for each structure in the list for (Iterator iter = structures.iterator(); iter.hasNext();) { IGPStructureInfo struct = (IGPStructureInfo) iter.next(); // create a corresponding structure in local structure IGPStructureInfo sCopy = local.addStructure(struct.getTechName(), struct.getNamespace()); // set multiplicity of the new structure sCopy.setMultiplicity(struct.getMultiplicity());
// use recursion to copy content of structure ... } // finally, save the modified local context action.setLocalParameters(local);
|
By analogy, copy the output parameters you need to pass to the action.
3. Define the mappings as follows:
a. Local parameters of the action to input parameters of the callable object
Mapping Local Action Parameters to Input Callable Object Parameters |
import java.util.Iterator; import com.sap.caf.eu.gp.base.api.IGPObjectReference; import com.sap.caf.eu.gp.process.api.IGPModifiableAction; import com.sap.caf.eu.gp.structure.api.IGPMappingGroup; import com.sap.caf.eu.gp.structure.api.IGPStructureInfo; import com.sap.caf.eu.gp.structure.api.IGPAttributeInfo;
// retrieve the object reference to the callable object for execution in action “a” IGPObjectReference ref = a.getExecuteCallableObject();
// retrieve the input mapping information IGPMappingGroup inMap = ref.getInputMapping();
// retrieve input definition of CO IGPStructureInfo in = ref.getReferencedObject().getInputParameters();
// for each attribute in CO’s input Iterator attrList = in.getAttributes().iterator(); while (attrList.hasNext()) { IGPAttributeInfo attr = (IGPAttributeInfo) attrList.next();
// map action’s local to CO’s input attribute inMap.addMappingRule( new String[] {attr.getTechName()}, new String[] {attr.getTechName()} ); } // for each structure in CO’s input Iterator structList = in.getStructures().iterator(); while (structList.hasNext()) { IGPStructureInfo struct = (IGPStructureInfo) structList.next();
// map action’s local to CO’s input structure inMap.addMappingRule( new String[] {struct.getTechName()}, new String[] {struct.getTechName()} ); } // save input mapping ref.setInputMapping(inMap);
|
b. Output parameters of the callable object to local parameters of the action
Mapping Output Callable Object Parameters to Local Action Parameters |
// retrieve output definition of CO IGPMappingGroup outMap = ref.getOutputMapping(); // map everything from CO’s output to action’s local parameters outMap.addMappingRule( new String[] {}, new String[] {} ); // save output mapping ref.setOutputMapping(outMap);
|
c. Input-to-local and local-to-input within the action.
For more information, see Defining Mappings Within an Activity in Defining Activity Mappings.
4. Optionally, you can consolidate the input parameters of the callable object for display with those parameters in the local context of the action which you need to display after the action is completed.