public static ProcessBuilder createProcess() { BpmnModelInstance modelInstance = INSTANCE.doCreateEmptyModel(); Definitions definitions = modelInstance.newInstance(Definitions.class); definitions.setTargetNamespace(BPMN20_NS); definitions.getDomElement().registerNamespace("camunda", CAMUNDA_NS); modelInstance.setDefinitions(definitions); Process process = modelInstance.newInstance(Process.class); definitions.addChildElement(process); BpmnDiagram bpmnDiagram = modelInstance.newInstance(BpmnDiagram.class); BpmnPlane bpmnPlane = modelInstance.newInstance(BpmnPlane.class); bpmnPlane.setBpmnElement(process); bpmnDiagram.addChildElement(bpmnPlane); definitions.addChildElement(bpmnDiagram); return process.builder(); }
protected Set<String> retrieveProcessKeysFromResources(Map<String, ResourceEntity> resources) { Set<String> keys = new HashSet<String>(); for (ResourceEntity resource : resources.values()) { if (isBpmnResource(resource)) { ByteArrayInputStream byteStream = new ByteArrayInputStream(resource.getBytes()); BpmnModelInstance model = Bpmn.readModelFromStream(byteStream); for (Process process : model.getDefinitions().getChildElementsByType(Process.class)) { keys.add(process.getId()); } } else if (isCmmnResource(resource)) { ByteArrayInputStream byteStream = new ByteArrayInputStream(resource.getBytes()); CmmnModelInstance model = Cmmn.readModelFromStream(byteStream); for (Case cmmnCase : model.getDefinitions().getCases()) { keys.add(cmmnCase.getId()); } } } return keys; }
protected ProcessInstance deployAndStartProcess(BpmnModelInstance bpmnModelInstance) { testHelper.deploy(bpmnModelInstance); String processDefinitionKey = bpmnModelInstance.getDefinitions().getRootElements().iterator().next().getId(); return runtimeService.startProcessInstanceByKey(processDefinitionKey); }
private void addMessageEventDefinition(CatchEvent catchEvent) { BpmnModelInstance modelInstance = (BpmnModelInstance) catchEvent.getModelInstance(); Message message = modelInstance.newInstance(Message.class); message.setId(MESSAGE_ID); message.setName(MESSAGE_NAME); modelInstance.getDefinitions().addChildElement(message); MessageEventDefinition messageEventDefinition = modelInstance.newInstance(MessageEventDefinition.class); messageEventDefinition.setMessage(message); catchEvent.getEventDefinitions().add(messageEventDefinition); }
private void addMessageEventDefinition(CatchEvent catchEvent) { BpmnModelInstance modelInstance = (BpmnModelInstance) catchEvent.getModelInstance(); Message message = modelInstance.newInstance(Message.class); message.setId(MESSAGE_ID); message.setName(MESSAGE_NAME); modelInstance.getDefinitions().addChildElement(message); MessageEventDefinition messageEventDefinition = modelInstance.newInstance(MessageEventDefinition.class); messageEventDefinition.setMessage(message); catchEvent.getEventDefinitions().add(messageEventDefinition); }
public static ProcessBuilder createProcess() { BpmnModelInstance modelInstance = INSTANCE.doCreateEmptyModel(); Definitions definitions = modelInstance.newInstance(Definitions.class); definitions.setTargetNamespace(BPMN20_NS); definitions.getDomElement().registerNamespace("camunda", CAMUNDA_NS); modelInstance.setDefinitions(definitions); Process process = modelInstance.newInstance(Process.class); definitions.addChildElement(process); BpmnDiagram bpmnDiagram = modelInstance.newInstance(BpmnDiagram.class); BpmnPlane bpmnPlane = modelInstance.newInstance(BpmnPlane.class); bpmnPlane.setBpmnElement(process); bpmnDiagram.addChildElement(bpmnPlane); definitions.addChildElement(bpmnDiagram); return process.builder(); }
protected ProcessInstance deployAndStartProcess(BpmnModelInstance bpmnModelInstance, Map<String, Object> variablesMap) { deploymentId = repositoryService.createDeployment() .addModelInstance("process.bpmn", bpmnModelInstance) .deploy().getId(); String processDefinitionKey = bpmnModelInstance.getDefinitions().getRootElements().iterator().next().getId(); return runtimeService.startProcessInstanceByKey(processDefinitionKey, variablesMap); }
protected Set<String> retrieveProcessKeysFromResources(Map<String, ResourceEntity> resources) { Set<String> keys = new HashSet<String>(); for (ResourceEntity resource : resources.values()) { if (isBpmnResource(resource)) { ByteArrayInputStream byteStream = new ByteArrayInputStream(resource.getBytes()); BpmnModelInstance model = Bpmn.readModelFromStream(byteStream); for (Process process : model.getDefinitions().getChildElementsByType(Process.class)) { keys.add(process.getId()); } } else if (isCmmnResource(resource)) { ByteArrayInputStream byteStream = new ByteArrayInputStream(resource.getBytes()); CmmnModelInstance model = Cmmn.readModelFromStream(byteStream); for (Case cmmnCase : model.getDefinitions().getCases()) { keys.add(cmmnCase.getId()); } } } return keys; }
public static ProcessBuilder createProcess() { BpmnModelInstance modelInstance = INSTANCE.doCreateEmptyModel(); Definitions definitions = modelInstance.newInstance(Definitions.class); definitions.setTargetNamespace(BPMN20_NS); definitions.getDomElement().registerNamespace("camunda", CAMUNDA_NS); modelInstance.setDefinitions(definitions); Process process = modelInstance.newInstance(Process.class); definitions.addChildElement(process); BpmnDiagram bpmnDiagram = modelInstance.newInstance(BpmnDiagram.class); BpmnPlane bpmnPlane = modelInstance.newInstance(BpmnPlane.class); bpmnPlane.setBpmnElement(process); bpmnDiagram.addChildElement(bpmnPlane); definitions.addChildElement(bpmnDiagram); return process.builder(); }
private void assertModelInstance() { BpmnModelInstance modelInstance = ModelExecutionContextTaskListener.modelInstance; assertNotNull(modelInstance); Collection<ModelElementInstance> events = modelInstance.getModelElementsByType(modelInstance.getModel().getType(Event.class)); assertEquals(2, events.size()); Collection<ModelElementInstance> tasks = modelInstance.getModelElementsByType(modelInstance.getModel().getType(Task.class)); assertEquals(1, tasks.size()); Process process = (Process) modelInstance.getDefinitions().getRootElements().iterator().next(); assertEquals(PROCESS_ID, process.getId()); assertTrue(process.isExecutable()); }
protected Set<String> retrieveProcessKeysFromResources(Map<String, ResourceEntity> resources) { Set<String> keys = new HashSet<String>(); for (ResourceEntity resource : resources.values()) { if (isBpmnResource(resource)) { ByteArrayInputStream byteStream = new ByteArrayInputStream(resource.getBytes()); BpmnModelInstance model = Bpmn.readModelFromStream(byteStream); for (Process process : model.getDefinitions().getChildElementsByType(Process.class)) { keys.add(process.getId()); } } else if (isCmmnResource(resource)) { ByteArrayInputStream byteStream = new ByteArrayInputStream(resource.getBytes()); CmmnModelInstance model = Cmmn.readModelFromStream(byteStream); for (Case cmmnCase : model.getDefinitions().getCases()) { keys.add(cmmnCase.getId()); } } } return keys; }
@Test public void shouldReturnBpmnModelInstance() { runtimeService.startProcessInstanceByKey(TEST_PROCESS); BpmnElementRetrievalDelegate delegate = ProgrammaticBeanLookup.lookup(BpmnElementRetrievalDelegate.class); Assert.assertNotNull(delegate.getBpmnModelElementInstance()); Assert.assertNotNull(delegate.getBpmnModelInstance()); Assert.assertEquals(TEST_PROCESS, delegate.getBpmnModelInstance().getDefinitions().getRootElements().iterator().next().getId()); } }
public void testJavaDelegateModelExecutionContext() { deploy(); runtimeService.startProcessInstanceByKey(PROCESS_ID); BpmnModelInstance modelInstance = ModelExecutionContextServiceTask.modelInstance; assertNotNull(modelInstance); Model model = modelInstance.getModel(); Collection<ModelElementInstance> events = modelInstance.getModelElementsByType(model.getType(Event.class)); assertEquals(2, events.size()); Collection<ModelElementInstance> tasks = modelInstance.getModelElementsByType(model.getType(Task.class)); assertEquals(1, tasks.size()); Process process = (Process) modelInstance.getDefinitions().getRootElements().iterator().next(); assertEquals(PROCESS_ID, process.getId()); assertTrue(process.isExecutable()); ServiceTask serviceTask = ModelExecutionContextServiceTask.serviceTask; assertNotNull(serviceTask); assertEquals(ModelExecutionContextServiceTask.class.getName(), serviceTask.getCamundaClass()); }
protected ProcessInstance deployAndStartProcess(BpmnModelInstance bpmnModelInstance) { testHelper.deploy(bpmnModelInstance); String processDefinitionKey = bpmnModelInstance.getDefinitions().getRootElements().iterator().next().getId(); return runtimeService.startProcessInstanceByKey(processDefinitionKey); }
protected ProcessInstance deployAndStartProcess(BpmnModelInstance bpmnModelInstance, Map<String, Object> variablesMap) { deploymentId = repositoryService.createDeployment() .addModelInstance("process.bpmn", bpmnModelInstance) .deploy().getId(); String processDefinitionKey = bpmnModelInstance.getDefinitions().getRootElements().iterator().next().getId(); return runtimeService.startProcessInstanceByKey(processDefinitionKey, variablesMap); }
private void assertModelInstance() { BpmnModelInstance modelInstance = ModelExecutionContextTaskListener.modelInstance; assertNotNull(modelInstance); Collection<ModelElementInstance> events = modelInstance.getModelElementsByType(modelInstance.getModel().getType(Event.class)); assertEquals(2, events.size()); Collection<ModelElementInstance> tasks = modelInstance.getModelElementsByType(modelInstance.getModel().getType(Task.class)); assertEquals(1, tasks.size()); Process process = (Process) modelInstance.getDefinitions().getRootElements().iterator().next(); assertEquals(PROCESS_ID, process.getId()); assertTrue(process.isExecutable()); }
public void testJavaDelegateModelExecutionContext() { deploy(); runtimeService.startProcessInstanceByKey(PROCESS_ID); BpmnModelInstance modelInstance = ModelExecutionContextServiceTask.modelInstance; assertNotNull(modelInstance); Model model = modelInstance.getModel(); Collection<ModelElementInstance> events = modelInstance.getModelElementsByType(model.getType(Event.class)); assertEquals(2, events.size()); Collection<ModelElementInstance> tasks = modelInstance.getModelElementsByType(model.getType(Task.class)); assertEquals(1, tasks.size()); Process process = (Process) modelInstance.getDefinitions().getRootElements().iterator().next(); assertEquals(PROCESS_ID, process.getId()); assertTrue(process.isExecutable()); ServiceTask serviceTask = ModelExecutionContextServiceTask.serviceTask; assertNotNull(serviceTask); assertEquals(ModelExecutionContextServiceTask.class.getName(), serviceTask.getCamundaClass()); }