
With the Guided Procedures (GP) runtime API, you can dynamically add or remove attachments to the processes you have initiated at runtime.
You can also view design time attachments but you cannot modify them.
For more information, see Setting Up Your Project .
For more information, see Starting and Terminating Processes Within a Composite .
For more information, see Attachments in Including Additional Functionality .
| Instantiating the Runtime Manager |
|---|
importcom.sap.caf.eu.gp.process.api.GPProcessFactory; importcom.sap.caf.eu.gp.process.rt.api.IGPRuntimeManager; IGPRuntimeManagerruntimeManager = GPProcessFactory.getRuntimeManager(); |
You must supply the process instance ID and the relevant user. You may enter null for the activity instance ID, since these are only the attachments at process level.
| Retrieving Attachments of a Process Instance |
|---|
importcom.sap.caf.eu.gp.process.rt.api.IGPRuntimeAttachmentList; importcom.sap.caf.eu.gp.process.api.IGPProcessInstance; importcom.sap.security.api.IUser; importjava.util.Enumeration; importcom.sap.caf.eu.gp.attachment.api.IGPAttachment; // retrieve attachment list IGPRuntimeAttachmentListrtList = runtimeManager.getAttachmentList(processInstance.getID(), null, user); // retrieve a single attachment Enumeratione = rtList.elements(); IGPAttachmentattachment = (IGPAttachment) e.nextElement(); |
The list contains both design time and runtime attachments. You cannot modify the design time attachments.
| Adding a Runtime Attachment |
|---|
IGPAttachmentrtAttachment = rtList.add( "Display Name", "Filename", // attachment type IGPAttachment.TYPE_URL, "Creator", // raw byte content of attachment "content".getBytes() ); |
| Persisting the Attachment List |
|---|
runtimeManager.persistAttachmentList(processInstance.getID(),null, rtList, user); |
The algorithm behind the persistAttachmentList() method ensures that only the relevant changes are saved each time you use it.
| Removing an Attachment |
|---|
rtList.removeAttachment(rtAttachment.getId()); |
If you try to remove a design time attachment from the list, an invocation exception is raised.
See also: