Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.
Stardust/Knowledge Base/API/ExamplesofAPIUsage/LinkProcesses
< Stardust | Knowledge Base
Revision as of 09:36, 15 March 2016 by Anusha.swaminathan.fisglobal.com (Talk | contribs) (Created page with "__NOTOC__ == Linking Processes == ==== Purpose ==== To link two processes using the API. ==== Pre Defined Link Types ==== SWITCH("Peer Process Instance"), JOIN("Joi...")
Linking Processes
Purpose
To link two processes using the API.
Pre Defined Link Types
SWITCH("Peer Process Instance"), JOIN("Join Process Instance"), UPGRADE("Upgrade Process Instance"), SPAWN("Spawn Process Instance"), RELATED("Related Process Instance");
Implementation
@Override public void addProcessLink(long poid, long joinedPoid) { try { Object object = getWorkflowService().execute(new LinkProcessServiceCommand(poid, joinedPoid)); } catch (ServiceCommandException e) { LOG.warn("Could not link process instance " + poid + " and " + joinedPoid); } }
package com.sungard.infinity; import java.io.Serializable; import org.eclipse.stardust.common.error.ObjectNotFoundException; import org.eclipse.stardust.engine.api.runtime.PredefinedProcessInstanceLinkTypes; import org.eclipse.stardust.engine.api.runtime.ServiceFactory; import org.eclipse.stardust.engine.core.runtime.beans.IProcessInstance; import org.eclipse.stardust.engine.core.runtime.beans.IProcessInstanceLinkType; import org.eclipse.stardust.engine.core.runtime.beans.ProcessInstanceBean; import org.eclipse.stardust.engine.core.runtime.beans.ProcessInstanceLinkBean; import org.eclipse.stardust.engine.core.runtime.beans.ProcessInstanceLinkTypeBean; import org.eclipse.stardust.engine.core.runtime.command.ServiceCommand; public class LinkProcessServiceCommand implements ServiceCommand { public long poid; public long joinedPoid; public LinkProcessServiceCommand(long poid, long joinedPoid) { super(); this.poid = poid; this.joinedPoid = joinedPoid; } public Serializable execute(ServiceFactory sf) { addProcessLink(poid, joinedPoid); return "success"; } public void addProcessLink(long poid, long joinedPoid) { IProcessInstance originatingProcessInstance = ProcessInstanceBean.findByOID(joinedPoid); IProcessInstance targetProcessInstance = ProcessInstanceBean.findByOID(poid); IProcessInstanceLinkType linkType = null; try { linkType = ProcessInstanceLinkTypeBean.findById(PredefinedProcessInstanceLinkTypes.JOIN); } catch (ObjectNotFoundException e) { linkType = new ProcessInstanceLinkTypeBean(PredefinedProcessInstanceLinkTypes.JOIN.getId(), PredefinedProcessInstanceLinkTypes.RELATED.getDescription()); } IProcessInstance linkSource = originatingProcessInstance.getRootProcessInstance().isCaseProcessInstance() ? originatingProcessInstance : originatingProcessInstance.getRootProcessInstance(); new ProcessInstanceLinkBean(linkSource, targetProcessInstance, linkType, "Joined Process Instance"); } }