Thank you for following up on my question. I followed your advice in trying to get the diagram but the return value of is (see below) is null.
Is there anything else I should do during initialization? I see for instance that "isGraphicalNotationDefined" is false for the processDefinition?
Thank you
package org.ncia.npc.ProcessViewerActiviti;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import org.activiti.engine.ProcessEngine;
import org.activiti.engine.ProcessEngineConfiguration;
import org.activiti.engine.RepositoryService;
import org.activiti.engine.repository.Deployment;
import org.activiti.engine.repository.DeploymentBuilder;
import org.activiti.engine.repository.ProcessDefinition;
/**
*
* @author JPH
*/
public class ProcessDiagramActiviti {
private RepositoryService repositoryService;
private String pdID;
public void deploy() {
ProcessEngine processEngine = ProcessEngineConfiguration.createStandaloneInMemProcessEngineConfiguration()
.setDatabaseSchemaUpdate(ProcessEngineConfiguration.DB_SCHEMA_UPDATE_TRUE)
.setJdbcUrl("jdbc:h2:mem:my-own-db;DB_CLOSE_DELAY=1000")
.setJobExecutorActivate(true)
.buildProcessEngine();
repositoryService = processEngine.getRepositoryService();
DeploymentBuilder deployBuilder = repositoryService.createDeployment()
.name("userWorkflow.bar")
.addClasspathResource("resources/userWorkflow.bpmn20.xml");
Deployment deployment = deployBuilder.deploy();
}
public void getDiagram() throws FileNotFoundException, IOException {
ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().singleResult();
pdID = processDefinition.getId();
try{
InputStream is = repositoryService.getProcessDiagram(pdID);
OutputStream os = new FileOutputStream("images\\userWorkflow.png");
byte[] buffer = new byte[1024];
int bytesRead;
//read from is to buffer
while ((bytesRead = is.read(buffer)) != -1) {
os.write(buffer, 0, bytesRead);
}
is.close();
os.flush();
os.close();
}
catch(IOException e) {
}
}
}