Can I receive information about process diagram in svg using Bonita API?

I want to receive information about process diagram (marking, sequence of steps) through Bonita API and save in svg.

This is a feature of the Subscription Model and is not available in Community.

That being said I can imagine a scenario whereby for a case you could do the following (in pseudo code):

get case getActivities (API) getArchivedActivityInstances (API)

then sort them into order and create your own HTML that can display an SVG diagram of the process.

reference here

regards
Seán

PS: As this reply offers an answer your question, and if you like it, please Mark UP and/or as Resolved.

I’ve developed some code that gets the process information as follows,

  • Start
  • End
  • Processes (operations)
  • Conditions (gateways)
  • Transitions

The numbers are the respective items id’s and the output is shown here:

7533755246857467906=>start: Start1 5056439953452068172=>end: End1 5282329866329449709=>operation: getActivitiesForDiagram1 5072827248852522222=>operation: getActivitiesForDiagram2 8304515131711232508=>operation: getActivitiesForDiagram3 7421274932560925310=>operation: Step1 8048306028807336420=>condition: Gateway1 8593787269775937543=>condition: Gateway2

5282329866329449709->7421274932560925310
8593787269775937543->5072827248852522222
8304515131711232508->8048306028807336420
8593787269775937543->8304515131711232508
5072827248852522222->8048306028807336420
7421274932560925310->8593787269775937543
7533755246857467906->5282329866329449709
8048306028807336420->5056439953452068172

You will have to work out how to “develop” the solution for your chosen flow-charting software, from here it should be quite easy. However I hope you will also share it :slight_smile:

From here it should be easy to develop something that gets the status and colours the flow diagram appropriately.

To execute add a Script Connector to an activity, copy the code and execute, it will work for the current process. I’ve not created to to work for a particular case etc.

You can then look at your log to see the printed output, how you then use it is up to you.

import java.util.List; import java.util.logging.Logger; import java.lang.StringBuilder;

import org.bonitasoft.engine.api.ProcessAPI
import org.bonitasoft.engine.bpm.businessdata.BusinessDataDefinition
import org.bonitasoft.engine.bpm.connector.ConnectorDefinition
import org.bonitasoft.engine.bpm.data.DataDefinition
import org.bonitasoft.engine.bpm.document.DocumentDefinition
import org.bonitasoft.engine.bpm.flownode.ActivityDefinition
import org.bonitasoft.engine.bpm.flownode.EndEventDefinition
import org.bonitasoft.engine.bpm.flownode.FlowElementContainerDefinition
import org.bonitasoft.engine.bpm.flownode.GatewayDefinition
import org.bonitasoft.engine.bpm.flownode.IntermediateCatchEventDefinition
import org.bonitasoft.engine.bpm.flownode.IntermediateThrowEventDefinition
import org.bonitasoft.engine.bpm.flownode.StartEventDefinition
import org.bonitasoft.engine.bpm.flownode.TransitionDefinition
import org.bonitasoft.engine.bpm.process.DesignProcessDefinition
import org.bonitasoft.engine.bpm.process.ProcessDeploymentInfo
import org.bonitasoft.engine.bpm.process.ProcessDeploymentInfoCriterion;
import org.bonitasoft.engine.bpm.process.ProcessDeploymentInfoSearchDescriptor;
import org.bonitasoft.engine.bpm.process.ProcessInstance;
import org.bonitasoft.engine.bpm.process.ProcessInstanceSearchDescriptor;
import org.bonitasoft.engine.bpm.process.ProcessInstanceState;

int dI = 0;
boolean debug = true;
StringBuilder logWrite = new StringBuilder();
StringBuilder flowChartJS1 = new StringBuilder();
Logger logger = Logger.getLogger(“org.bonitasoft”);

ProcessAPI processAPI = apiAccessor.getProcessAPI();
//set the name of the routine
String processName =processAPI.getProcessInstance(processInstanceId).getName();
logWrite.append("\n\nProcess Name: “+ processName);
logWrite.append(”\nprocessInstanceId: “+ processInstanceId.toString());
logWrite.append(”\nprocessDefinitionId: "+ processDefinitionId.toString());

logWrite.append(“\nactivityInstanceId: “+ activityInstanceId.toString());
logWrite.append(”\ntaskAssigneeId: “+ taskAssigneeId.toString());
logWrite.append(”\nrootProcessInstanceId: “+ rootProcessInstanceId.toString());
logWrite.append(”\n\t” + dI++ + " Trace Start");

//TODO - Code goes in here - START
DesignProcessDefinition resultDesignProcessDefinition = processAPI.getDesignProcessDefinition(processDefinitionId);
FlowElementContainerDefinition flowElementContainer = resultDesignProcessDefinition.getFlowElementContainer();

//Start
List startEvents = flowElementContainer.getStartEvents();
for(StartEventDefinition q : startEvents){

		 flowChartJS1.append(q.getId().toString()+"=>start: "+q.getName().toString()+"\n");
		 
		 //logWrite.append("\n\t\t" + dI++ + " startEvents 				= " + q.toString());
		 logWrite.append("\n\t\t" + dI++ + " startEvents Name 			= " + q.getName().toString());
		 logWrite.append("\n\t\t" + dI++ + " startEvents Id 			= " + q.getId().toString());
		 logWrite.append("\n\t\t" + dI++ + " startEvents IncomingTransitions= " + String.valueOf(q.getIncomingTransitions()));
		 logWrite.append("\n\t\t" + dI++ + " startEvents OutgoingTransitions= " + String.valueOf(q.getOutgoingTransitions()));
		 logWrite.append("\n");
	 }

//flowchart.js
//End
List endEvents = flowElementContainer.getEndEvents();
for(EndEventDefinition q : endEvents){

		 flowChartJS1.append(q.getId().toString()+"=>end: "+q.getName().toString()+"\n");

// logWrite.append(“\n\t\t” + dI++ + " endEvents = " + q.toString());
logWrite.append(“\n\t\t” + dI++ + " endEvents Name = " + q.getName().toString());
logWrite.append(“\n\t\t” + dI++ + " endEvents Id = " + q.getId().toString());
logWrite.append(“\n\t\t” + dI++ + " endEvents IncomingTransitions= " + String.valueOf(q.getIncomingTransitions()));
logWrite.append(“\n\t\t” + dI++ + " endEvents OutgoingTransitions= " + String.valueOf(q.getOutgoingTransitions()));
logWrite.append(“\n”);
}

//Activities
List processActivities = flowElementContainer.getActivities();
for(ActivityDefinition q : processActivities){

		 flowChartJS1.append(q.getId().toString()+"=>operation: "+q.getName().toString()+"\n");

// logWrite.append(“\n\t\t” + dI++ + " processActivities = " + q.toString());
logWrite.append(“\n\t\t” + dI++ + " processActivities Name = " + q.getName().toString());
logWrite.append(“\n\t\t” + dI++ + " processActivities Id = " + q.getId().toString());
logWrite.append(“\n\t\t” + dI++ + " processActivities Condition = " + q.getDefaultTransition().toString());// .getCondition().toString());
logWrite.append(“\n\t\t” + dI++ + " processActivities IncomingTransitions= " + q.getIncomingTransitions().toString());
logWrite.append(“\n\t\t” + dI++ + " processActivities LoopCharacteristics= " + q.getLoopCharacteristics().toString());
logWrite.append(“\n\t\t” + dI++ + " processActivities OutgoingTransitions= " + q.getOutgoingTransitions().toString());
logWrite.append(“\n\t\t” + dI++ + " processActivities Operations = " + q.getOperations().toString());
logWrite.append(“\n”);
}

//flowchart.js
//Conditions
List gatewaysList = flowElementContainer.getGatewaysList();
for(GatewayDefinition q : gatewaysList){

		 flowChartJS1.append(q.getId().toString()+"=>condition: "+q.getName().toString()+"\n");
					  
		 //logWrite.append("\n\t\t" + dI++ + " gatewaysList 				= " + q.toString());
		 logWrite.append("\n\t\t" + dI++ + " gatewaysList Name			= " + q.getName().toString());
		 logWrite.append("\n\t\t" + dI++ + " gatewaysList Id			= " + q.getId().toString());
		 logWrite.append("\n\t\t" + dI++ + " gatewaysList GatewayType	= " + q.getGatewayType().toString());
		 logWrite.append("\n\t\t" + dI++ + " gatewaysList IncomingTransitions 	= " + q.getIncomingTransitions().toString());
		 logWrite.append("\n\t\t" + dI++ + " gatewaysList getOutgoingTransitions= " + q.getOutgoingTransitions().toString());
		 logWrite.append("\n");
	 }

//flowchart.js
//Transitions
Set transitions = flowElementContainer.getTransitions();
for(TransitionDefinition q : transitions){

		 flowChartJS1.append("\n"+q.getSource().toString()+"->"+q.getTarget().toString()+"\n");
		 
		 //logWrite.append("\n\t\t" + dI++ + " transitions = " + q.toString());
		 logWrite.append("\n\t\t" + dI++ + " transitions Source 		= " + q.getSource().toString());
		 logWrite.append("\n\t\t" + dI++ + " transitions SourceFlowNode = " + q.getSourceFlowNode().getName().toString());
		 logWrite.append("\n\t\t" + dI++ + " transitions Target 		= " + q.getTarget().toString());
		 logWrite.append("\n\t\t" + dI++ + " transitions TargetFlowNode = " + q.getTargetFlowNode().getName().toString());
		 logWrite.append("\n\t\t" + dI++ + " transitions Condition 		= " + q.getCondition().toString());
		 logWrite.append("\n");
	 }

//TODO - Code goes in here - END

logWrite.append(“\n\t” + dI++ + " Trace End");
logWrite.append(“\n\n”);
if(debug){logger.severe(logWrite.toString())}

logger.severe(“\n\n”+flowChartJS1.toString()+“\n\n”);

regards