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

The following examples show how to use org.camunda.bpm.engine.variable.Variables#longValue() . 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: LongFormType.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
public TypedValue convertValue(TypedValue propertyValue) {
  if(propertyValue instanceof LongValue) {
    return propertyValue;
  }
  else {
    Object value = propertyValue.getValue();
    if(value == null) {
      return Variables.longValue(null, propertyValue.isTransient());
    }
    else if((value instanceof Number) || (value instanceof String)) {
      return Variables.longValue(new Long(value.toString()), propertyValue.isTransient());
    }
    else {
      throw new ProcessEngineException("Value '"+value+"' is not of type Long.");
    }
  }
}
 
Example 2
Source File: ProcessInstanceRestServiceInteractionTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Test
public void testCannotDownloadVariableOtherThanFile() {
  String variableKey = "aVariableKey";
  LongValue variableValue = Variables.longValue(123L);

  when(runtimeServiceMock.getVariableTyped(eq(MockProvider.EXAMPLE_PROCESS_INSTANCE_ID), eq(variableKey), anyBoolean()))
  .thenReturn(variableValue);

 given()
  .pathParam("id", MockProvider.EXAMPLE_PROCESS_INSTANCE_ID)
  .pathParam("varId", variableKey)
.then().expect()
    .statusCode(Status.BAD_REQUEST.getStatusCode())
    .contentType(MediaType.APPLICATION_JSON)
  .and()
  .when().get(SINGLE_PROCESS_INSTANCE_BINARY_VARIABLE_URL);
}
 
Example 3
Source File: PrimitiveValueTypeImpl.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Override
public LongValue convertFromTypedValue(TypedValue typedValue) {
  if (typedValue.getType() != ValueType.NUMBER) {
    throw unsupportedConversion(typedValue.getType());
  }

  LongValueImpl longvalue = null;
  NumberValue numberValue = (NumberValue) typedValue;

  if (numberValue.getValue() != null) {
    longvalue = (LongValueImpl) Variables.longValue(numberValue.getValue().longValue());
  } else {
    longvalue =  (LongValueImpl) Variables.longValue(null);
  }
  longvalue.setTransient(numberValue.isTransient());
  return longvalue;
}
 
Example 4
Source File: LongValueMapper.java    From camunda-external-task-client-java with Apache License 2.0 5 votes vote down vote up
public LongValue readValue(TypedValueField typedValueField) {
  Long longValue = null;

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

  return Variables.longValue(longValue);
}
 
Example 5
Source File: LongValueMapper.java    From camunda-external-task-client-java with Apache License 2.0 4 votes vote down vote up
public LongValue convertToTypedValue(UntypedValueImpl untypedValue) {
  return Variables.longValue((Long) untypedValue.getValue());
}
 
Example 6
Source File: LongValueSerlializer.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
public LongValue convertToTypedValue(UntypedValueImpl untypedValue) {
  return Variables.longValue((Long) untypedValue.getValue(), untypedValue.isTransient());
}
 
Example 7
Source File: LongValueSerlializer.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
public LongValue readValue(ValueFields valueFields, boolean asTransientValue) {
  return Variables.longValue(valueFields.getLongValue(), asTransientValue);
}
 
Example 8
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 9
Source File: PrimitiveValueTypeImpl.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
public LongValue createValue(Object value, Map<String, Object> valueInfo) {
  return Variables.longValue((Long) value, isTransient(valueInfo));
}