Java Code Examples for org.camunda.bpm.engine.delegate.DelegateTask#setVariable()

The following examples show how to use org.camunda.bpm.engine.delegate.DelegateTask#setVariable() . 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: MyTaskListener.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
public void notify(DelegateTask task, String event) {
  String eventCounterName = event + "EventCounter";

  Integer eventCounter = (Integer) task.getVariable(eventCounterName);

  if (eventCounter == null) {
    eventCounter = 0;
  }

  Integer counter = (Integer) task.getVariable("eventCounter");

  if (counter == null) {
    counter = 0;
  }

  task.setVariable(event, true);
  task.setVariable(eventCounterName, eventCounter + 1);
  task.setVariable("eventCounter", counter + 1);

}
 
Example 2
Source File: DelegateTaskTestTaskListener.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
public void notify(DelegateTask delegateTask) {
  Set<IdentityLink> candidates = delegateTask.getCandidates();
  Set<String> candidateUsers = new HashSet<String>();
  Set<String> candidateGroups = new HashSet<String>();
  for (IdentityLink candidate : candidates) {
    if (candidate.getUserId() != null) {
      candidateUsers.add(candidate.getUserId());
    } else if (candidate.getGroupId() != null) {
      candidateGroups.add(candidate.getGroupId());
    }
  }
  delegateTask.setVariable(VARNAME_CANDIDATE_USERS, candidateUsers);
  delegateTask.setVariable(VARNAME_CANDIDATE_GROUPS, candidateGroups);
}
 
Example 3
Source File: DelegateTaskTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Override
public void notify(DelegateTask delegateTask) {
  Date followUpDate = delegateTask.getFollowUpDate();
  assertThat(followUpDate, notNullValue());

  delegateTask.setVariable("followUp", followUpDate);
}
 
Example 4
Source File: FieldInjectionTaskListener.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
public void notify(DelegateTask delegateTask) {
  delegateTask.setVariable("greeting", "Hello from " + greeter.getValue(delegateTask));
  delegateTask.setVariable("helloWorld", helloWorld.getValue(delegateTask));
  delegateTask.setVariable("prefix", prefix.getValue(delegateTask));
  delegateTask.setVariable("suffix", suffix.getValue(delegateTask));

  // kind of workaround to pass through the test
  greeter = null;
  helloWorld = null;
  prefix = null;
  suffix = null;
}
 
Example 5
Source File: TaskCompletionListener.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
public void notify(DelegateTask delegateTask) {
  Integer counter = (Integer) delegateTask.getVariable("taskListenerCounter");
  if (counter == null) {
    counter = 0;
  }
  delegateTask.setVariable("taskListenerCounter", ++counter);
}
 
Example 6
Source File: TaskListenerProcessApplication.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
public TaskListener getTaskListener() {
  return new TaskListener() {
    public void notify(DelegateTask delegateTask) {
      delegateTask.setVariable(delegateTask.getEventName(), true);
    }
  };
}
 
Example 7
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 8
Source File: ExampleTaskListener.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
@Override
public void notify(DelegateTask delegateTask) {
  delegateTask.setVariable("listener", "listener-notified");
}
 
Example 9
Source File: SampleTaskListenerBean.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
@Override
public void notify(DelegateTask delegateTask) {
  delegateTask.setVariable("called", true);
}
 
Example 10
Source File: MyTaskListener.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
public void notify(DelegateTask delegateTask) {
  delegateTask.setVariable("calledThroughNotify", delegateTask.getName() + "-notify");
}
 
Example 11
Source File: MyTaskListener.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
public void calledInExpression(DelegateTask task, String eventName) {
  task.setVariable("calledInExpression", task.getName() + "-" + eventName);
}