org.camunda.bpm.engine.TaskService.setVariableLocal()方法的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(11.4k)|赞(0)|评价(0)|浏览(124)

本文整理了Java中org.camunda.bpm.engine.TaskService.setVariableLocal()方法的一些代码示例,展示了TaskService.setVariableLocal()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。TaskService.setVariableLocal()方法的具体详情如下:
包路径:org.camunda.bpm.engine.TaskService
类名称:TaskService
方法名:setVariableLocal

TaskService.setVariableLocal介绍

[英]Set variable on a task. If the variable is not already existing, it will be created in the task.
[中]在任务上设置变量。如果变量尚未存在,则将在任务中创建该变量。

代码示例

代码示例来源:origin: camunda/camunda-bpm-platform

public Void call() throws Exception {
  taskService.setVariableLocal(taskId, name, value);
  return null;
 }
});

代码示例来源:origin: camunda/camunda-bpm-platform

protected void setVariableEntity(String variableKey, TypedValue variableValue) {
 engine.getTaskService().setVariableLocal(resourceId, variableKey, variableValue);
}

代码示例来源:origin: camunda/camunda-bpm-platform

protected void setVariableEntity(String variableKey, TypedValue variableValue) {
 engine.getTaskService().setVariableLocal(resourceId, variableKey, variableValue);
}

代码示例来源:origin: camunda/camunda-bpm-platform

@Test
public void testPutSingleLocalVariableWithNoValue() {
 String variableKey = "aVariableKey";
 given().pathParam("id", EXAMPLE_TASK_ID).pathParam("varId", variableKey)
  .contentType(ContentType.JSON).body(EMPTY_JSON_OBJECT)
  .header("accept", MediaType.APPLICATION_JSON)
  .then().expect().statusCode(Status.NO_CONTENT.getStatusCode())
  .when().put(SINGLE_TASK_PUT_SINGLE_VARIABLE_URL);
 verify(taskServiceMock).setVariableLocal(eq(EXAMPLE_TASK_ID), eq(variableKey),
   argThat(EqualsNullValue.matcher()));
}

代码示例来源:origin: camunda/camunda-bpm-platform

@Test
public void testPostSingleLocalBinaryVariableWithNoValue() throws Exception {
 byte[] bytes = new byte[0];
 String variableKey = "aVariableKey";
 given()
  .pathParam("id", EXAMPLE_TASK_ID).pathParam("varId", variableKey)
  .multiPart("data", null, bytes)
  .header("accept", MediaType.APPLICATION_JSON)
 .expect()
  .statusCode(Status.NO_CONTENT.getStatusCode())
 .when()
  .post(SINGLE_TASK_SINGLE_BINARY_VARIABLE_URL);
 verify(taskServiceMock).setVariableLocal(eq(EXAMPLE_TASK_ID), eq(variableKey),
   argThat(EqualsPrimitiveValue.bytesValue(bytes)));
}

代码示例来源:origin: camunda/camunda-bpm-platform

@Test
public void testPutSingleVariableWithTypeLong() {
 String variableKey = "aVariableKey";
 Long variableValue = Long.valueOf(123);
 String type = "Long";
 Map<String, Object> variableJson = VariablesBuilder.getVariableValueMap(variableValue, type);
 given().pathParam("id", EXAMPLE_TASK_ID).pathParam("varId", variableKey)
  .contentType(ContentType.JSON).body(variableJson)
  .header("accept", MediaType.APPLICATION_JSON)
  .then().expect().statusCode(Status.NO_CONTENT.getStatusCode())
  .when().put(SINGLE_TASK_PUT_SINGLE_VARIABLE_URL);
 verify(taskServiceMock).setVariableLocal(eq(EXAMPLE_TASK_ID), eq(variableKey),
   argThat(EqualsPrimitiveValue.longValue(variableValue)));
}

代码示例来源:origin: camunda/camunda-bpm-platform

@Test
public void testPutSingleLocalVariableFromSerializedWithNoValue() {
 String variableKey = "aVariableKey";
 Map<String, Object> requestJson = VariablesBuilder
   .getObjectValueMap(null, ValueType.OBJECT.getName(), null, null);
 given().pathParam("id", MockProvider.EXAMPLE_TASK_ID).pathParam("varId", variableKey)
  .contentType(ContentType.JSON).body(requestJson)
  .then().expect().statusCode(Status.NO_CONTENT.getStatusCode())
  .when().put(SINGLE_TASK_PUT_SINGLE_VARIABLE_URL);
 verify(taskServiceMock).setVariableLocal(
   eq(MockProvider.EXAMPLE_TASK_ID), eq(variableKey),
   argThat(EqualsObjectValue.objectValueMatcher()));
}

代码示例来源:origin: camunda/camunda-bpm-platform

@Test
public void testPutSingleVariableWithTypeShort() {
 String variableKey = "aVariableKey";
 Short variableValue = 123;
 String type = "Short";
 Map<String, Object> variableJson = VariablesBuilder.getVariableValueMap(variableValue, type);
 given().pathParam("id", EXAMPLE_TASK_ID).pathParam("varId", variableKey)
  .contentType(ContentType.JSON).body(variableJson)
  .header("accept", MediaType.APPLICATION_JSON)
  .then().expect().statusCode(Status.NO_CONTENT.getStatusCode())
  .when().put(SINGLE_TASK_PUT_SINGLE_VARIABLE_URL);
 verify(taskServiceMock).setVariableLocal(eq(EXAMPLE_TASK_ID), eq(variableKey),
   argThat(EqualsPrimitiveValue.shortValue(variableValue)));
}

代码示例来源:origin: camunda/camunda-bpm-platform

@Test
public void testPutSingleVariableWithTypeBoolean() {
 String variableKey = "aVariableKey";
 Boolean variableValue = true;
 String type = "Boolean";
 Map<String, Object> variableJson = VariablesBuilder.getVariableValueMap(variableValue, type);
 given().pathParam("id", EXAMPLE_TASK_ID).pathParam("varId", variableKey)
  .contentType(ContentType.JSON).body(variableJson)
  .header("accept", MediaType.APPLICATION_JSON)
  .then().expect().statusCode(Status.NO_CONTENT.getStatusCode())
  .when().put(SINGLE_TASK_PUT_SINGLE_VARIABLE_URL);
 verify(taskServiceMock).setVariableLocal(eq(EXAMPLE_TASK_ID), eq(variableKey),
   argThat(EqualsPrimitiveValue.booleanValue(variableValue)));
}

代码示例来源:origin: camunda/camunda-bpm-platform

@Test
public void testPutSingleVariableWithTypeDouble() {
 String variableKey = "aVariableKey";
 Double variableValue = 123.456;
 String type = "Double";
 Map<String, Object> variableJson = VariablesBuilder.getVariableValueMap(variableValue, type);
 given().pathParam("id", EXAMPLE_TASK_ID).pathParam("varId", variableKey)
  .contentType(ContentType.JSON).body(variableJson)
  .header("accept", MediaType.APPLICATION_JSON)
  .then().expect().statusCode(Status.NO_CONTENT.getStatusCode())
  .when().put(SINGLE_TASK_PUT_SINGLE_VARIABLE_URL);
 verify(taskServiceMock).setVariableLocal(eq(EXAMPLE_TASK_ID), eq(variableKey),
   argThat(EqualsPrimitiveValue.doubleValue(variableValue)));
}

代码示例来源:origin: camunda/camunda-bpm-platform

@Test
public void testPutSingleVariableWithTypeInteger() {
 String variableKey = "aVariableKey";
 Integer variableValue = 123;
 String type = "Integer";
 Map<String, Object> variableJson = VariablesBuilder.getVariableValueMap(variableValue, type);
 given().pathParam("id", EXAMPLE_TASK_ID).pathParam("varId", variableKey)
  .contentType(ContentType.JSON).body(variableJson)
  .header("accept", MediaType.APPLICATION_JSON)
  .then().expect().statusCode(Status.NO_CONTENT.getStatusCode())
  .when().put(SINGLE_TASK_PUT_SINGLE_VARIABLE_URL);
 verify(taskServiceMock).setVariableLocal(eq(EXAMPLE_TASK_ID), eq(variableKey),
   argThat(EqualsPrimitiveValue.integerValue(variableValue)));
}

代码示例来源:origin: camunda/camunda-bpm-platform

@Test
public void testPutSingleLocalVariable() {
 String variableKey = "aVariableKey";
 String variableValue = "aVariableValue";
 Map<String, Object> variableJson = VariablesBuilder.getVariableValueMap(variableValue);
 given().pathParam("id", EXAMPLE_TASK_ID).pathParam("varId", variableKey)
  .contentType(ContentType.JSON).body(variableJson)
  .header("accept", MediaType.APPLICATION_JSON)
  .then().expect().statusCode(Status.NO_CONTENT.getStatusCode())
  .when().put(SINGLE_TASK_PUT_SINGLE_VARIABLE_URL);
 verify(taskServiceMock).setVariableLocal(eq(EXAMPLE_TASK_ID), eq(variableKey),
   argThat(EqualsUntypedValue.matcher().value(variableValue)));
}

代码示例来源:origin: camunda/camunda-bpm-platform

public void testCaseTaskSetVariableLocal() {
 // given
 createCaseInstanceByKey(CASE_KEY);
 String taskId = selectSingleTask().getId();
 // when
 taskService.setVariableLocal(taskId, VARIABLE_NAME, VARIABLE_VALUE);
 // then
 disableAuthorization();
 VariableInstanceQuery query = runtimeService.createVariableInstanceQuery();
 verifyQueryResults(query, 1);
 enableAuthorization();
}

代码示例来源:origin: camunda/camunda-bpm-platform

public void testStandaloneTaskSetVariableLocalWithReadPermissionOnAnyTask() {
 // given
 String taskId = "myTask";
 createTask(taskId);
 createGrantAuthorization(TASK, ANY, userId, UPDATE);
 // when
 taskService.setVariableLocal(taskId, VARIABLE_NAME, VARIABLE_VALUE);
 // then
 disableAuthorization();
 VariableInstanceQuery query = runtimeService.createVariableInstanceQuery();
 verifyQueryResults(query, 1);
 enableAuthorization();
 deleteTask(taskId, true);
}

代码示例来源:origin: camunda/camunda-bpm-platform

public void testStandaloneTaskSetVariableLocalWithReadPermissionOnTask() {
 // given
 String taskId = "myTask";
 createTask(taskId);
 createGrantAuthorization(TASK, taskId, userId, UPDATE);
 // when
 taskService.setVariableLocal(taskId, VARIABLE_NAME, VARIABLE_VALUE);
 // then
 disableAuthorization();
 VariableInstanceQuery query = runtimeService.createVariableInstanceQuery();
 verifyQueryResults(query, 1);
 enableAuthorization();
 deleteTask(taskId, true);
}

代码示例来源:origin: camunda/camunda-bpm-platform

public void testProcessTaskSetVariableLocalWithReadPermissionOnAnyTask() {
 // given
 startProcessInstanceByKey(PROCESS_KEY);
 String taskId = selectSingleTask().getId();
 createGrantAuthorization(TASK, ANY, userId, UPDATE);
 // when
 taskService.setVariableLocal(taskId, VARIABLE_NAME, VARIABLE_VALUE);
 // then
 disableAuthorization();
 VariableInstanceQuery query = runtimeService.createVariableInstanceQuery();
 verifyQueryResults(query, 1);
 enableAuthorization();
}

代码示例来源:origin: camunda/camunda-bpm-platform

public void testProcessTaskSetVariableLocalWithReadTaskPermissionOnAnyProcessDefinition() {
 // given
 startProcessInstanceByKey(PROCESS_KEY);
 String taskId = selectSingleTask().getId();
 createGrantAuthorization(PROCESS_DEFINITION, ANY, userId, UPDATE_TASK);
 // when
 taskService.setVariableLocal(taskId, VARIABLE_NAME, VARIABLE_VALUE);
 // then
 disableAuthorization();
 VariableInstanceQuery query = runtimeService.createVariableInstanceQuery();
 verifyQueryResults(query, 1);
 enableAuthorization();
}

代码示例来源:origin: camunda/camunda-bpm-platform

public void testProcessTaskSetVariableLocalWithReadPermissionOnTask() {
 // given
 startProcessInstanceByKey(PROCESS_KEY);
 String taskId = selectSingleTask().getId();
 createGrantAuthorization(TASK, taskId, userId, UPDATE);
 // when
 taskService.setVariableLocal(taskId, VARIABLE_NAME, VARIABLE_VALUE);
 // then
 disableAuthorization();
 VariableInstanceQuery query = runtimeService.createVariableInstanceQuery();
 verifyQueryResults(query, 1);
 enableAuthorization();
}

代码示例来源:origin: camunda/camunda-bpm-platform

public void testProcessTaskSetVariableLocalWithReadTaskPermissionOnProcessDefinition() {
 // given
 startProcessInstanceByKey(PROCESS_KEY);
 String taskId = selectSingleTask().getId();
 createGrantAuthorization(PROCESS_DEFINITION, PROCESS_KEY, userId, UPDATE_TASK);
 // when
 taskService.setVariableLocal(taskId, VARIABLE_NAME, VARIABLE_VALUE);
 // then
 disableAuthorization();
 VariableInstanceQuery query = runtimeService.createVariableInstanceQuery();
 verifyQueryResults(query, 1);
 enableAuthorization();
}

代码示例来源:origin: camunda/camunda-bpm-platform

@Deployment(resources = {
"org/camunda/bpm/engine/test/api/oneTaskProcess.bpmn20.xml" })
@Test
public void testRemoveVariableLocal() {
 ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("oneTaskProcess");
 Task currentTask = taskService.createTaskQuery().singleResult();
 taskService.setVariableLocal(currentTask.getId(), "variable1", "value1");
 assertEquals("value1", taskService.getVariable(currentTask.getId(), "variable1"));
 assertEquals("value1", taskService.getVariableLocal(currentTask.getId(), "variable1"));
 taskService.removeVariableLocal(currentTask.getId(), "variable1");
 assertNull(taskService.getVariable(currentTask.getId(), "variable1"));
 assertNull(taskService.getVariableLocal(currentTask.getId(), "variable1"));
 checkHistoricVariableUpdateEntity("variable1", processInstance.getId());
}

相关文章

微信公众号

最新文章

更多