Java Code Examples for org.camunda.bpm.engine.variable.Variables#integerValue()

The following examples show how to use org.camunda.bpm.engine.variable.Variables#integerValue() . 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: CaseCallActivityTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Deployment(resources = {
    "org/camunda/bpm/engine/test/bpmn/callactivity/CaseCallActivityTest.testOutputAll.bpmn20.xml",
    "org/camunda/bpm/engine/test/api/cmmn/oneTaskCaseWithManualActivation.cmmn"
  })
public void testCallCaseOutputAllVariablesTypedToProcess(){
  startProcessInstanceByKey("process");
  CaseInstance caseInstance = queryOneTaskCaseInstance();
  String variableName = "foo";
  String variableName2 = "null";
  TypedValue variableValue = Variables.stringValue("bar");
  TypedValue variableValue2 = Variables.integerValue(null);
  caseService.withCaseExecution(caseInstance.getId())
    .setVariable(variableName, variableValue)
    .setVariable(variableName2, variableValue2)
    .execute();
  complete(caseInstance.getId());

  Task task = taskService.createTaskQuery().singleResult();
  TypedValue value = runtimeService.getVariableTyped(task.getProcessInstanceId(), variableName);
  assertThat(value, is(variableValue));
  value = runtimeService.getVariableTyped(task.getProcessInstanceId(), variableName2);
  assertThat(value, is(variableValue2));
}
 
Example 2
Source File: PrimitiveValueTypeImpl.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Override
public IntegerValue convertFromTypedValue(TypedValue typedValue) {
  if (typedValue.getType() != ValueType.NUMBER) {
    throw unsupportedConversion(typedValue.getType());
  }

  IntegerValueImpl integerValue = null;
  NumberValue numberValue = (NumberValue) typedValue;
  if (numberValue.getValue() != null) {
    integerValue = (IntegerValueImpl) Variables.integerValue(numberValue.getValue().intValue());
  } else {
    integerValue = (IntegerValueImpl) Variables.integerValue(null);
  }
  integerValue.setTransient(numberValue.isTransient());
  return integerValue;
}
 
Example 3
Source File: IntegerValueMapper.java    From camunda-external-task-client-java with Apache License 2.0 5 votes vote down vote up
public IntegerValue readValue(TypedValueField typedValueField) {
  Integer intValue = null;

  Object value = typedValueField.getValue();
  if (value != null) {
    Number numValue = (Number) value;
    intValue = numValue.intValue();
  }

  return Variables.integerValue(intValue);
}
 
Example 4
Source File: IntegerValueSerializer.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
public IntegerValue readValue(ValueFields valueFields, boolean asTransientValue) {
  Integer intValue = null;

  if(valueFields.getLongValue() != null) {
    intValue = Integer.valueOf(valueFields.getLongValue().intValue());
  }

  return Variables.integerValue(intValue, asTransientValue);
}
 
Example 5
Source File: IntegerValueMapper.java    From camunda-external-task-client-java with Apache License 2.0 4 votes vote down vote up
public IntegerValue convertToTypedValue(UntypedValueImpl untypedValue) {
  return Variables.integerValue((Integer) untypedValue.getValue());
}
 
Example 6
Source File: CollectCountHitPolicyHandler.java    From camunda-engine-dmn with Apache License 2.0 4 votes vote down vote up
@Override
protected TypedValue aggregateValues(List<TypedValue> values) {
  return Variables.integerValue(values.size());
}
 
Example 7
Source File: CollectCountHitPolicyHandler.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
@Override
protected TypedValue aggregateValues(List<TypedValue> values) {
  return Variables.integerValue(values.size());
}
 
Example 8
Source File: IntegerValueSerializer.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
public IntegerValue convertToTypedValue(UntypedValueImpl untypedValue) {
  return Variables.integerValue((Integer) untypedValue.getValue(), untypedValue.isTransient());
}
 
Example 9
Source File: ProcessTaskTest.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
@Deployment(resources = {
    "org/camunda/bpm/engine/test/cmmn/processtask/ProcessTaskTest.testInputOutputAll.cmmn",
    "org/camunda/bpm/engine/test/api/oneTaskProcess.bpmn20.xml"
  })
public void testInputOutputAllTypedVariables() {
  String variableName = "aVariable";
  String variableName2 = "anotherVariable";
  String variableName3 = "theThirdVariable";
  TypedValue variableValue = Variables.stringValue("abc");
  TypedValue variableValue2 = Variables.longValue(null);

  String caseInstanceId = createCaseInstanceByKey(ONE_PROCESS_TASK_CASE,
      Variables.createVariables()
      .putValue(variableName, variableValue)
      .putValue(variableName2, variableValue2))
      .getId();
  String processTaskId = queryCaseExecutionByActivityId(PROCESS_TASK).getId();

  String processInstanceId = queryProcessInstance().getId();

  TypedValue value = runtimeService.getVariableTyped(processInstanceId, variableName);
  assertThat(value, is(variableValue));
  value = runtimeService.getVariableTyped(processInstanceId, variableName2);
  assertThat(value, is(variableValue2));

  String taskId = queryTask().getId();

  TypedValue variableValue3 = Variables.integerValue(1);
  runtimeService.setVariable(processInstanceId, variableName3, variableValue3);

  // should also complete process instance
  taskService.complete(taskId);

  value = caseService.getVariableTyped(caseInstanceId, variableName3);

  assertThat(value, is(variableValue3));

  // complete ////////////////////////////////////////////////////////

  assertProcessEnded(processInstanceId);

  close(caseInstanceId);
  assertCaseEnded(caseInstanceId);
}
 
Example 10
Source File: ProcessTaskTest.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
@Deployment(resources = {
    "org/camunda/bpm/engine/test/cmmn/processtask/ProcessTaskTest.testVariablesRoundtrip.cmmn",
    "org/camunda/bpm/engine/test/api/oneTaskProcess.bpmn20.xml"
  })
public void testInputOutputLimitedTypedVariables() {
  String variableName = "aVariable";
  String variableName2 = "anotherVariable";
  TypedValue caseVariableValue = Variables.stringValue("abc");
  TypedValue caseVariableValue2 = Variables.integerValue(null);

  String caseInstanceId = createCaseInstanceByKey(ONE_PROCESS_TASK_CASE,
      Variables.createVariables().putValue(variableName, caseVariableValue)
      .putValue(variableName2, caseVariableValue2)).getId();

  String processInstanceId = queryProcessInstance().getId();
  TypedValue value = runtimeService.getVariableTyped(processInstanceId, variableName);
  assertThat(value, is(caseVariableValue));
  value = runtimeService.getVariableTyped(processInstanceId, variableName2);
  assertThat(value, is(caseVariableValue2));


  TypedValue processVariableValue = Variables.stringValue("cba");
  TypedValue processVariableValue2 = Variables.booleanValue(null);
  runtimeService.setVariable(processInstanceId, variableName, processVariableValue);
  runtimeService.setVariable(processInstanceId, variableName2, processVariableValue2);

  // should also complete process instance
  taskService.complete(queryTask().getId());

  value = caseService.getVariableTyped(caseInstanceId, variableName);
  assertThat(value, is(processVariableValue));
  value = caseService.getVariableTyped(caseInstanceId, variableName2);
  assertThat(value, is(processVariableValue2));
  // complete ////////////////////////////////////////////////////////

  assertProcessEnded(processInstanceId);

  close(caseInstanceId);
  assertCaseEnded(caseInstanceId);

}
 
Example 11
Source File: PrimitiveValueTypeImpl.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
public IntegerValue createValue(Object value, Map<String, Object> valueInfo) {
  return Variables.integerValue((Integer) value, isTransient(valueInfo));
}