11-06-2013 06:44 AM
public InputStream createInstanceDiagram(String processInstanceId) {
ProcessInstance pi = runtimeService.createProcessInstanceQuery().processInstanceId(processInstanceId).singleResult();
ProcessDefinitionEntity pde = (ProcessDefinitionEntity) repositoryService.createProcessDefinitionQuery()
.processDefinitionId(pi.getProcessDefinitionId()).singleResult();
System.out.println("******* isGraphicalNotationDefined? " + pde.isGraphicalNotationDefined()); // always false
System.out.println("******* diagramResourceName: " + pde.getDiagramResourceName()); // returns resource name from database
List<String> activities = runtimeService.getActiveActivityIds(idInstanciaProcesso);
InputStream is = ProcessDiagramGenerator.generateDiagram(pde, "png", activities);
return is;
}
public InputStream createDefinitionDiagram(String processDefinitionId) {
ProcessDefinitionEntity pde = (ProcessDefinitionEntity) repositoryService.createProcessDefinitionQuery()
.processDefinitionId(processDefinitionId).singleResult();
repositoryService.getResourceAsStream(pde.getDeploymentId(), pde.getDiagramResourceName());
InputStream is = repositoryService.getResourceAsStream(pde.getDeploymentId(), pde.getDiagramResourceName());
return is;
}
public String publishProcess(File file) throws IOException {
try (ZipInputStream inputStream = new ZipInputStream(new FileInputStream(file))) {
return repositoryService.createDeployment().name(arquivoPublicacao.getName()).addZipInputStream(inputStream).deploy().getId();
}
}
<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:activiti="http://activiti.org/bpmn" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:omgdc="http://www.omg.org/spec/DD/20100524/DC" xmlns:omgdi="http://www.omg.org/spec/DD/20100524/DI" typeLanguage="http://www.w3.org/2001/XMLSchema" expressionLanguage="http://www.w3.org/1999/XPath" targetNamespace="http://www.bpmnwithactiviti.org">
<process id="admissao" name="admissao" isExecutable="true">
<startEvent id="inicioAdmissao" name="Start" activiti:formKey="tarefa_novaAdmissao.xhtml"></startEvent>
<sequenceFlow id="indoParaDigitacao" sourceRef="inicioAdmissao" targetRef="digitaAdmissao"></sequenceFlow>
<userTask id="digitaAdmissao" name="Digita Admissao" activiti:assignee="consultor" activiti:formKey="tarefa_digitaAdmissao.xhtml">
<documentation>Digitar admissão para cargo: ${funAdmissaoWF.cargo}</documentation>
</userTask>
<sequenceFlow id="indoParaEfetivacao" sourceRef="digitaAdmissao" targetRef="efetivaAdmissao"></sequenceFlow>
<serviceTask id="efetivaAdmissao" name="Efetiva Admissao" activiti:expression="#{servicoAdmissao.admiteFuncionario()}"></serviceTask>
<sequenceFlow id="indoParaFim" sourceRef="efetivaAdmissao" targetRef="fim"></sequenceFlow>
<endEvent id="fim" name="End"></endEvent>
</process>
<bpmndi:BPMNDiagram id="BPMNDiagram_admissao">
<bpmndi:BPMNPlane bpmnElement="admissao" id="BPMNPlane_admissao">
<bpmndi:BPMNShape bpmnElement="inicioAdmissao" id="BPMNShape_inicioAdmissao">
<omgdc:Bounds height="49.0" width="51.0" x="10.0" y="22.0"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="fim" id="BPMNShape_fim">
<omgdc:Bounds height="49.0" width="61.0" x="420.0" y="22.0"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="digitaAdmissao" id="BPMNShape_digitaAdmissao">
<omgdc:Bounds height="66.0" width="121.0" x="110.0" y="15.0"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="efetivaAdmissao" id="BPMNShape_efetivaAdmissao">
<omgdc:Bounds height="65.0" width="134.0" x="267.0" y="16.0"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge bpmnElement="indoParaDigitacao" id="BPMNEdge_indoParaDigitacao">
<omgdi:waypoint x="61.0" y="46.0"></omgdi:waypoint>
<omgdi:waypoint x="80.0" y="39.0"></omgdi:waypoint>
<omgdi:waypoint x="110.0" y="48.0"></omgdi:waypoint>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="indoParaEfetivacao" id="BPMNEdge_indoParaEfetivacao">
<omgdi:waypoint x="231.0" y="48.0"></omgdi:waypoint>
<omgdi:waypoint x="249.0" y="39.0"></omgdi:waypoint>
<omgdi:waypoint x="234.0" y="39.0"></omgdi:waypoint>
<omgdi:waypoint x="249.0" y="39.0"></omgdi:waypoint>
<omgdi:waypoint x="267.0" y="48.0"></omgdi:waypoint>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="indoParaFim" id="BPMNEdge_indoParaFim">
<omgdi:waypoint x="401.0" y="48.0"></omgdi:waypoint>
<omgdi:waypoint x="397.0" y="39.0"></omgdi:waypoint>
<omgdi:waypoint x="420.0" y="46.0"></omgdi:waypoint>
</bpmndi:BPMNEdge>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</definitions>
11-12-2013 02:22 PM
BpmnModel model = repositoryService.getBpmnModel(pde.getProcessDefinition().getId());
InputStream is = ProcessDiagramGenerator.generateDiagram(model, "png", activities);
Tags
Find what you came for
We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.