org.camunda.bpm.model.bpmn.instance.UserTask Java Examples

The following examples show how to use org.camunda.bpm.model.bpmn.instance.UserTask. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CompensationModels.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
public static void addUserTaskCompensationHandler(BpmnModelInstance modelInstance, String boundaryEventId, String compensationHandlerId) {

    BoundaryEvent boundaryEvent = modelInstance.getModelElementById(boundaryEventId);
    BaseElement scope = (BaseElement) boundaryEvent.getParentElement();

    UserTask compensationHandler = modelInstance.newInstance(UserTask.class);
    compensationHandler.setId(compensationHandlerId);
    compensationHandler.setForCompensation(true);
    scope.addChildElement(compensationHandler);

    Association association = modelInstance.newInstance(Association.class);
    association.setAssociationDirection(AssociationDirection.One);
    association.setSource(boundaryEvent);
    association.setTarget(compensationHandler);
    scope.addChildElement(association);

  }
 
Example #2
Source File: TaskEntity.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Override
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 LOG.castModelInstanceException(modelElementInstance, "UserTask", elementType.getTypeName(),
        elementType.getTypeNamespace(), e);
    }
  } else {
    return null;
  }
}
 
Example #3
Source File: ResourceRolesTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Test
public void testGetPerformer() {
  UserTask userTask = modelInstance.getModelElementById("_3");
  Collection<ResourceRole> resourceRoles = userTask.getResourceRoles();
  assertThat(resourceRoles.size()).isEqualTo(1);
  ResourceRole resourceRole = resourceRoles.iterator().next();
  assertThat(resourceRole instanceof Performer).isTrue();
  assertThat(resourceRole.getName()).isEqualTo("Task performer");
}
 
Example #4
Source File: UserTaskBpmnModelExecutionContextTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
private void assertUserTask(String eventName) {
  UserTask userTask = ModelExecutionContextTaskListener.userTask;
  assertNotNull(userTask);

  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));
}
 
Example #5
Source File: TaskListenerProcessEngineServicesAccessTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
protected Task createModelAccessTask(BpmnModelInstance modelInstance, Class<?> delegateClass) {
  UserTask task = modelInstance.newInstance(UserTask.class);
  task.setId("userTask");
  CamundaTaskListener executionListener = modelInstance.newInstance(CamundaTaskListener.class);
  executionListener.setCamundaEvent(TaskListener.EVENTNAME_CREATE);
  executionListener.setCamundaClass(delegateClass.getName());
  task.builder().addExtensionElement(executionListener);
  return task;
}
 
Example #6
Source File: MigrationUserTaskTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
protected static void addTaskListener(BpmnModelInstance targetModel, String activityId, String event, String className) {
  CamundaTaskListener taskListener = targetModel.newInstance(CamundaTaskListener.class);
  taskListener.setCamundaClass(className);
  taskListener.setCamundaEvent(event);

  UserTask task = targetModel.getModelElementById(activityId);
  task.builder().addExtensionElement(taskListener);
}
 
Example #7
Source File: MigrationPlanGenerationTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Test
public void testMapEqualActivitiesWithParallelMultiInstance() {
  BpmnModelInstance testProcess = modify(ProcessModels.ONE_TASK_PROCESS)
    .<UserTask>getModelElementById("userTask").builder()
      .multiInstance().parallel().cardinality("3").multiInstanceDone().done();

  assertGeneratedMigrationPlan(testProcess, testProcess)
    .hasInstructions(
      migrate("userTask").to("userTask"),
      migrate("userTask#multiInstanceBody").to("userTask#multiInstanceBody"));
}
 
Example #8
Source File: GenerateIdTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Test
public void shouldGenerateIdsOnCreate() {
  BpmnModelInstance modelInstance = Bpmn.createEmptyModel();
  Definitions definitions = modelInstance.newInstance(Definitions.class);
  assertThat(definitions.getId()).isNotNull();

  Process process = modelInstance.newInstance(Process.class);
  assertThat(process.getId()).isNotNull();

  StartEvent startEvent = modelInstance.newInstance(StartEvent.class);
  assertThat(startEvent.getId()).isNotNull();

  UserTask userTask = modelInstance.newInstance(UserTask.class);
  assertThat(userTask.getId()).isNotNull();
}
 
Example #9
Source File: GenerateIdTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Test
public void shouldNotGenerateIdsOnRead() {
  BpmnModelInstance modelInstance = Bpmn.readModelFromStream(GenerateIdTest.class.getResourceAsStream("GenerateIdTest.bpmn"));
  Definitions definitions = modelInstance.getDefinitions();
  assertThat(definitions.getId()).isNull();

  Process process = modelInstance.getModelElementsByType(Process.class).iterator().next();
  assertThat(process.getId()).isNull();

  StartEvent startEvent = modelInstance.getModelElementsByType(StartEvent.class).iterator().next();
  assertThat(startEvent.getId()).isNull();

  UserTask userTask = modelInstance.getModelElementsByType(UserTask.class).iterator().next();
  assertThat(userTask.getId()).isNull();
}
 
Example #10
Source File: ResourceRolesTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Test
public void testGetPotentialOwner() {
  UserTask userTask = modelInstance.getModelElementById("_9");
  Collection<ResourceRole> resourceRoles = userTask.getResourceRoles();
  assertThat(resourceRoles.size()).isEqualTo(1);
  ResourceRole resourceRole = resourceRoles.iterator().next();
  assertThat(resourceRole instanceof PotentialOwner).isTrue();
  assertThat(resourceRole.getName()).isEqualTo("Task potential owner");
}
 
Example #11
Source File: ResourceRolesTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Test
public void testGetHumanPerformer() {
  UserTask userTask = modelInstance.getModelElementById("_7");
  Collection<ResourceRole> resourceRoles = userTask.getResourceRoles();
  assertThat(resourceRoles.size()).isEqualTo(1);
  ResourceRole resourceRole = resourceRoles.iterator().next();
  assertThat(resourceRole instanceof HumanPerformer).isTrue();
  assertThat(resourceRole.getName()).isEqualTo("Task human performer");
}
 
Example #12
Source File: GenerateIdTest.java    From camunda-bpmn-model with Apache License 2.0 5 votes vote down vote up
@Test
public void shouldGenerateIdsOnCreate() {
  BpmnModelInstance modelInstance = Bpmn.createEmptyModel();
  Definitions definitions = modelInstance.newInstance(Definitions.class);
  assertThat(definitions.getId()).isNotNull();

  Process process = modelInstance.newInstance(Process.class);
  assertThat(process.getId()).isNotNull();

  StartEvent startEvent = modelInstance.newInstance(StartEvent.class);
  assertThat(startEvent.getId()).isNotNull();

  UserTask userTask = modelInstance.newInstance(UserTask.class);
  assertThat(userTask.getId()).isNotNull();
}
 
Example #13
Source File: GenerateIdTest.java    From camunda-bpmn-model with Apache License 2.0 5 votes vote down vote up
@Test
public void shouldNotGenerateIdsOnRead() {
  BpmnModelInstance modelInstance = Bpmn.readModelFromStream(GenerateIdTest.class.getResourceAsStream("GenerateIdTest.bpmn"));
  Definitions definitions = modelInstance.getDefinitions();
  assertThat(definitions.getId()).isNull();

  Process process = modelInstance.getModelElementsByType(Process.class).iterator().next();
  assertThat(process.getId()).isNull();

  StartEvent startEvent = modelInstance.getModelElementsByType(StartEvent.class).iterator().next();
  assertThat(startEvent.getId()).isNull();

  UserTask userTask = modelInstance.getModelElementsByType(UserTask.class).iterator().next();
  assertThat(userTask.getId()).isNull();
}
 
Example #14
Source File: ResourceRolesTest.java    From camunda-bpmn-model with Apache License 2.0 5 votes vote down vote up
@Test
public void testGetPotentialOwner() {
  UserTask userTask = modelInstance.getModelElementById("_9");
  Collection<ResourceRole> resourceRoles = userTask.getResourceRoles();
  assertThat(resourceRoles.size()).isEqualTo(1);
  ResourceRole resourceRole = resourceRoles.iterator().next();
  assertThat(resourceRole instanceof PotentialOwner).isTrue();
  assertThat(resourceRole.getName()).isEqualTo("Task potential owner");
}
 
Example #15
Source File: ResourceRolesTest.java    From camunda-bpmn-model with Apache License 2.0 5 votes vote down vote up
@Test
public void testGetHumanPerformer() {
  UserTask userTask = modelInstance.getModelElementById("_7");
  Collection<ResourceRole> resourceRoles = userTask.getResourceRoles();
  assertThat(resourceRoles.size()).isEqualTo(1);
  ResourceRole resourceRole = resourceRoles.iterator().next();
  assertThat(resourceRole instanceof HumanPerformer).isTrue();
  assertThat(resourceRole.getName()).isEqualTo("Task human performer");
}
 
Example #16
Source File: ResourceRolesTest.java    From camunda-bpmn-model with Apache License 2.0 5 votes vote down vote up
@Test
public void testGetPerformer() {
  UserTask userTask = modelInstance.getModelElementById("_3");
  Collection<ResourceRole> resourceRoles = userTask.getResourceRoles();
  assertThat(resourceRoles.size()).isEqualTo(1);
  ResourceRole resourceRole = resourceRoles.iterator().next();
  assertThat(resourceRole instanceof Performer).isTrue();
  assertThat(resourceRole.getName()).isEqualTo("Task performer");
}
 
Example #17
Source File: AbstractUserTaskBuilder.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
protected AbstractUserTaskBuilder(BpmnModelInstance modelInstance, UserTask element, Class<?> selfType) {
  super(modelInstance, element, selfType);
}
 
Example #18
Source File: DelegateTaskFake.java    From camunda-bpm-mockito with Apache License 2.0 4 votes vote down vote up
@Override
public UserTask getBpmnModelElementInstance() {
  throw new UnsupportedOperationException("not implemented");
}
 
Example #19
Source File: UserTaskBuilder.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
public UserTaskBuilder(BpmnModelInstance modelInstance, UserTask element) {
  super(modelInstance, element, UserTaskBuilder.class);
}
 
Example #20
Source File: UserTaskImpl.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
public static void registerType(ModelBuilder modelBuilder) {
  ModelElementTypeBuilder typeBuilder = modelBuilder.defineType(UserTask.class, BPMN_ELEMENT_USER_TASK)
    .namespaceUri(BPMN20_NS)
    .extendsType(Task.class)
    .instanceProvider(new ModelTypeInstanceProvider<UserTask>() {
      public UserTask newInstance(ModelTypeInstanceContext instanceContext) {
        return new UserTaskImpl(instanceContext);
      }
    });

  implementationAttribute = typeBuilder.stringAttribute(BPMN_ATTRIBUTE_IMPLEMENTATION)
    .defaultValue("##unspecified")
    .build();

  SequenceBuilder sequenceBuilder = typeBuilder.sequence();

  renderingCollection = sequenceBuilder.elementCollection(Rendering.class)
    .build();

  /** camunda extensions */

  camundaAssigneeAttribute = typeBuilder.stringAttribute(CAMUNDA_ATTRIBUTE_ASSIGNEE)
    .namespace(CAMUNDA_NS)
    .build();

  camundaCandidateGroupsAttribute = typeBuilder.stringAttribute(CAMUNDA_ATTRIBUTE_CANDIDATE_GROUPS)
    .namespace(CAMUNDA_NS)
    .build();

  camundaCandidateUsersAttribute = typeBuilder.stringAttribute(CAMUNDA_ATTRIBUTE_CANDIDATE_USERS)
    .namespace(CAMUNDA_NS)
    .build();

  camundaDueDateAttribute = typeBuilder.stringAttribute(CAMUNDA_ATTRIBUTE_DUE_DATE)
    .namespace(CAMUNDA_NS)
    .build();

  camundaFollowUpDateAttribute = typeBuilder.stringAttribute(CAMUNDA_ATTRIBUTE_FOLLOW_UP_DATE)
    .namespace(CAMUNDA_NS)
    .build();

  camundaFormHandlerClassAttribute = typeBuilder.stringAttribute(CAMUNDA_ATTRIBUTE_FORM_HANDLER_CLASS)
    .namespace(CAMUNDA_NS)
    .build();

  camundaFormKeyAttribute = typeBuilder.stringAttribute(CAMUNDA_ATTRIBUTE_FORM_KEY)
    .namespace(CAMUNDA_NS)
    .build();

  camundaPriorityAttribute = typeBuilder.stringAttribute(CAMUNDA_ATTRIBUTE_PRIORITY)
    .namespace(CAMUNDA_NS)
    .build();

  typeBuilder.build();
}
 
Example #21
Source File: AbstractUserTaskBuilder.java    From camunda-bpmn-model with Apache License 2.0 4 votes vote down vote up
protected AbstractUserTaskBuilder(BpmnModelInstance modelInstance, UserTask element, Class<?> selfType) {
  super(modelInstance, element, selfType);
}
 
Example #22
Source File: AccessModelInstanceTaskListener.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
@Override
public void notify(DelegateTask delegateTask) {
  UserTask userTask = delegateTask.getBpmnModelElementInstance();
  delegateTask.setVariable(VARIABLE_NAME, userTask.getId());
}
 
Example #23
Source File: UserTaskBuilder.java    From camunda-bpmn-model with Apache License 2.0 4 votes vote down vote up
public UserTaskBuilder(BpmnModelInstance modelInstance, UserTask element) {
  super(modelInstance, element, UserTaskBuilder.class);
}
 
Example #24
Source File: UserTaskImpl.java    From camunda-bpmn-model with Apache License 2.0 4 votes vote down vote up
public static void registerType(ModelBuilder modelBuilder) {
  ModelElementTypeBuilder typeBuilder = modelBuilder.defineType(UserTask.class, BPMN_ELEMENT_USER_TASK)
    .namespaceUri(BPMN20_NS)
    .extendsType(Task.class)
    .instanceProvider(new ModelTypeInstanceProvider<UserTask>() {
      public UserTask newInstance(ModelTypeInstanceContext instanceContext) {
        return new UserTaskImpl(instanceContext);
      }
    });

  implementationAttribute = typeBuilder.stringAttribute(BPMN_ATTRIBUTE_IMPLEMENTATION)
    .defaultValue("##unspecified")
    .build();

  SequenceBuilder sequenceBuilder = typeBuilder.sequence();

  renderingCollection = sequenceBuilder.elementCollection(Rendering.class)
    .build();

  /** camunda extensions */

  camundaAssigneeAttribute = typeBuilder.stringAttribute(CAMUNDA_ATTRIBUTE_ASSIGNEE)
    .namespace(CAMUNDA_NS)
    .build();

  camundaCandidateGroupsAttribute = typeBuilder.stringAttribute(CAMUNDA_ATTRIBUTE_CANDIDATE_GROUPS)
    .namespace(CAMUNDA_NS)
    .build();

  camundaCandidateUsersAttribute = typeBuilder.stringAttribute(CAMUNDA_ATTRIBUTE_CANDIDATE_USERS)
    .namespace(CAMUNDA_NS)
    .build();

  camundaDueDateAttribute = typeBuilder.stringAttribute(CAMUNDA_ATTRIBUTE_DUE_DATE)
    .namespace(CAMUNDA_NS)
    .build();

  camundaFollowUpDateAttribute = typeBuilder.stringAttribute(CAMUNDA_ATTRIBUTE_FOLLOW_UP_DATE)
    .namespace(CAMUNDA_NS)
    .build();

  camundaFormHandlerClassAttribute = typeBuilder.stringAttribute(CAMUNDA_ATTRIBUTE_FORM_HANDLER_CLASS)
    .namespace(CAMUNDA_NS)
    .build();

  camundaFormKeyAttribute = typeBuilder.stringAttribute(CAMUNDA_ATTRIBUTE_FORM_KEY)
    .namespace(CAMUNDA_NS)
    .build();

  camundaPriorityAttribute = typeBuilder.stringAttribute(CAMUNDA_ATTRIBUTE_PRIORITY)
    .namespace(CAMUNDA_NS)
    .build();

  typeBuilder.build();
}
 
Example #25
Source File: DelegateTask.java    From camunda-bpm-platform with Apache License 2.0 2 votes vote down vote up
/**
 * Provides access to the current {@link UserTask} Element from the Bpmn Model.
 * @return the current {@link UserTask} Element from the Bpmn Model.
 */
@Override
public UserTask getBpmnModelElementInstance();