Examples of BpmnModelInstance


Examples of org.camunda.bpm.model.bpmn.BpmnModelInstance

      throw new SuspendedEntityInteractionException("task " + id + " is suspended");
    }
  }

  public UserTask getBpmnModelElementInstance() {
    BpmnModelInstance bpmnModelInstance = getBpmnModelInstance();
    if(bpmnModelInstance != null) {
      ModelElementInstance modelElementInstance = bpmnModelInstance.getModelElementById(taskDefinitionKey);
      try {
        return (UserTask) modelElementInstance;
      } catch(ClassCastException e) {
        ModelElementType elementType = modelElementInstance.getElementType();
        throw new ProcessEngineException("Cannot cast "+modelElementInstance+" to UserTask. "
View Full Code Here

Examples of org.camunda.bpm.model.bpmn.BpmnModelInstance

    }
    return cachedProcessDefinition;
  }

  public BpmnModelInstance findBpmnModelInstanceForProcessDefinition(String processDefinitionId) {
    BpmnModelInstance bpmnModelInstance = bpmnModelInstanceCache.get(processDefinitionId);
    if(bpmnModelInstance == null) {

      ProcessDefinitionEntity processDefinition = findDeployedProcessDefinitionById(processDefinitionId);
      String deploymentId = processDefinition.getDeploymentId();
      String resourceName = processDefinition.getResourceName();
View Full Code Here

Examples of org.camunda.bpm.model.bpmn.BpmnModelInstance

    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());
        }
      }
    }
View Full Code Here

Examples of org.camunda.bpm.model.bpmn.BpmnModelInstance

  public void testRepositoryService() {
    deployTestProcess();
    runtimeService.startProcessInstanceByKey(PROCESS_KEY);
    String processDefinitionId = repositoryService.createProcessDefinitionQuery().processDefinitionKey(PROCESS_KEY).singleResult().getId();

    BpmnModelInstance modelInstance = repositoryService.getBpmnModelInstance(processDefinitionId);
    assertNotNull(modelInstance);
    Collection<ModelElementInstance> events = modelInstance.getModelElementsByType(modelInstance.getModel().getType(Event.class));
    assertEquals(2, events.size());
    Collection<ModelElementInstance> tasks = modelInstance.getModelElementsByType(modelInstance.getModel().getType(UserTask.class));
    assertEquals(1, tasks.size());

    Task task = taskService.createTaskQuery().singleResult();
    UserTask userTask = modelInstance.getModelElementById(task.getTaskDefinitionKey());
    assertNotNull(userTask);

    taskService.complete(task.getId());
  }
View Full Code Here

Examples of org.camunda.bpm.model.bpmn.BpmnModelInstance

    taskService.complete(task.getId());
  }

  private void deployTestProcess() {
    BpmnModelInstance modelInstance = Bpmn.createExecutableProcess(PROCESS_KEY)
      .startEvent().userTask().endEvent().done();
    deploymentId = repositoryService.createDeployment().addModelInstance("process.bpmn", modelInstance).deploy().getId();
  }
View Full Code Here

Examples of org.camunda.bpm.model.bpmn.BpmnModelInstance

   * Test case for handing over process variables without target attribute set
   */
  public void testSubProcessWithDataInputOutputWithoutTarget() {
    String processId = "subProcessDataInputOutputWithoutTarget";

    BpmnModelInstance modelInstance = Bpmn.createExecutableProcess(processId)
      .startEvent()
      .callActivity("callActivity")
        .calledElement("simpleSubProcess")
      .userTask()
      .endEvent()
      .done();

    CallActivityBuilder callActivityBuilder = ((CallActivity) modelInstance.getModelElementById("callActivity")).builder();

    // create camunda:in with source but without target
    CamundaIn camundaIn = modelInstance.newInstance(CamundaIn.class);
    camundaIn.setCamundaSource("superVariable");
    callActivityBuilder.addExtensionElement(camundaIn);

    deployAndExpectException(modelInstance);
    // set target
    camundaIn.setCamundaTarget("subVariable");

    // create camunda:in with sourceExpression but without target
    camundaIn = modelInstance.newInstance(CamundaIn.class);
    camundaIn.setCamundaSourceExpression("${x+5}");
    callActivityBuilder.addExtensionElement(camundaIn);

    deployAndExpectException(modelInstance);
    // set target
    camundaIn.setCamundaTarget("subVariable2");

    // create camunda:out with source but without target
    CamundaOut camundaOut = modelInstance.newInstance(CamundaOut.class);
    camundaOut.setCamundaSource("subVariable");
    callActivityBuilder.addExtensionElement(camundaOut);

    deployAndExpectException(modelInstance);
    // set target
    camundaOut.setCamundaTarget("superVariable");

    // create camunda:out with sourceExpression but without target
    camundaOut = modelInstance.newInstance(CamundaOut.class);
    camundaOut.setCamundaSourceExpression("${y+1}");
    callActivityBuilder.addExtensionElement(camundaOut);

    deployAndExpectException(modelInstance);
    // set target
View Full Code Here

Examples of org.camunda.bpm.model.bpmn.BpmnModelInstance

    assertModelInstance();
    assertUserTask(eventName);
  }

  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());
  }
View Full Code Here

Examples of org.camunda.bpm.model.bpmn.BpmnModelInstance

    }
    this.processDefinitionId = processDefinitionId;
  }

  public BpmnModelInstance execute(CommandContext commandContext) {
    BpmnModelInstance modelInstance = Context
      .getProcessEngineConfiguration()
      .getDeploymentCache()
      .findBpmnModelInstanceForProcessDefinition(processDefinitionId);

    ensureNotNull("no BPMN model instance found for process definition id " + processDefinitionId, "modelInstance", modelInstance);
View Full Code Here

Examples of org.camunda.bpm.model.bpmn.BpmnModelInstance

    ModelElementInstance taskListener = userTask.getExtensionElements().getUniqueChildElementByNameNs(CAMUNDA_NS, "taskListener");
    assertEquals(eventName, taskListener.getAttributeValueNs(CAMUNDA_NS, "event"));
    assertEquals(ModelExecutionContextTaskListener.class.getName(), taskListener.getAttributeValueNs(CAMUNDA_NS, "class"));

    BpmnModelInstance modelInstance = ModelExecutionContextTaskListener.modelInstance;
    Collection<ModelElementInstance> tasks = modelInstance.getModelElementsByType(modelInstance.getModel().getType(Task.class));
    assertTrue(tasks.contains(userTask));
  }
View Full Code Here

Examples of org.camunda.bpm.model.bpmn.BpmnModelInstance

    Collection<ModelElementInstance> tasks = modelInstance.getModelElementsByType(modelInstance.getModel().getType(Task.class));
    assertTrue(tasks.contains(userTask));
  }

  private void deployProcess(String eventName) {
    BpmnModelInstance modelInstance = Bpmn.createExecutableProcess(PROCESS_ID)
      .startEvent()
      .userTask(USER_TASK_ID)
      .endEvent()
      .done();

    ExtensionElements extensionElements = modelInstance.newInstance(ExtensionElements.class);
    ModelElementInstance taskListener = extensionElements.addExtensionElement(CAMUNDA_NS, "taskListener");
    taskListener.setAttributeValueNs(CAMUNDA_NS, "class", ModelExecutionContextTaskListener.class.getName());
    taskListener.setAttributeValueNs(CAMUNDA_NS, "event", eventName);

    UserTask userTask = modelInstance.getModelElementById(USER_TASK_ID);
    userTask.setExtensionElements(extensionElements);

    deploymentId = repositoryService.createDeployment().addModelInstance("process.bpmn", modelInstance).deploy().getId();
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.