Java Code Examples for org.camunda.bpm.engine.variable.Variables#untypedValue()
The following examples show how to use
org.camunda.bpm.engine.variable.Variables#untypedValue() .
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: DefaultDmnHistoryEventProducer.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
protected List<HistoricDecisionInputInstance> createHistoricDecisionInputInstances(DmnDecisionTableEvaluationEvent evaluationEvent, String rootProcessInstanceId, Date removalTime) { List<HistoricDecisionInputInstance> inputInstances = new ArrayList<HistoricDecisionInputInstance>(); for(DmnEvaluatedInput inputClause : evaluationEvent.getInputs()) { HistoricDecisionInputInstanceEntity inputInstance = new HistoricDecisionInputInstanceEntity(rootProcessInstanceId, removalTime); inputInstance.setClauseId(inputClause.getId()); inputInstance.setClauseName(inputClause.getName()); inputInstance.setCreateTime(ClockUtil.getCurrentTime()); TypedValue typedValue = Variables.untypedValue(inputClause.getValue()); inputInstance.setValue(typedValue); inputInstances.add(inputInstance); } return inputInstances; }
Example 2
Source File: DateValueMapperTest.java From camunda-external-task-client-java with Apache License 2.0 | 5 votes |
@Test public void shouldConvertToTypedValue() { // given UntypedValueImpl untypedValue = (UntypedValueImpl) Variables.untypedValue(VARIABLE_VALUE_DATE); // when DateValue dateValue = dateValueMapper.convertToTypedValue(untypedValue); // then assertThat(dateValue.getType()).isInstanceOf(PrimitiveValueTypeImpl.DateTypeImpl.class); assertThat(dateValue.getValue()).isEqualTo(VARIABLE_VALUE_DATE); }
Example 3
Source File: FormFieldHandler.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
public void handleSubmit(VariableScope variableScope, VariableMap values, VariableMap allValues) { TypedValue submittedValue = (TypedValue) values.getValueTyped(id); values.remove(id); // perform validation for (FormFieldValidationConstraintHandler validationHandler : validationHandlers) { Object value = null; if(submittedValue != null) { value = submittedValue.getValue(); } validationHandler.validate(value, allValues, this, variableScope); } // update variable(s) TypedValue modelValue = null; if (submittedValue != null) { if (type != null) { modelValue = type.convertToModelValue(submittedValue); } else { modelValue = submittedValue; } } else if (defaultValueExpression != null) { final TypedValue expressionValue = Variables.untypedValue(defaultValueExpression.getValue(variableScope)); if (type != null) { // first, need to convert to model value since the default value may be a String Constant specified in the model xml. modelValue = type.convertToModelValue(Variables.untypedValue(expressionValue)); } else if (expressionValue != null) { modelValue = Variables.stringValue(expressionValue.getValue().toString()); } } if (modelValue != null) { if (id != null) { variableScope.setVariable(id, modelValue); } } }
Example 4
Source File: AbstractVariableScope.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
public void initializeVariableStore(Map<String, Object> variables) { for (String variableName : variables.keySet()) { TypedValue value = Variables.untypedValue(variables.get(variableName)); CoreVariableInstance variableValue = getVariableInstanceFactory().build(variableName, value, false); getVariableStore().addVariable(variableValue); } }
Example 5
Source File: AbstractVariableScope.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
/** * Sets a variable in the local scope. In contrast to * {@link #setVariableLocal(String, Object)}, the variable is transient that * means it will not be stored in the data base. For example, a transient * variable can be used for a result variable that is only available for * output mapping. */ public void setVariableLocalTransient(String variableName, Object value) { TypedValue typedValue = Variables.untypedValue(value, true); checkJavaSerialization(variableName, typedValue); CoreVariableInstance coreVariableInstance = getVariableInstanceFactory().build(variableName, typedValue, true); getVariableStore().addVariable(coreVariableInstance); }
Example 6
Source File: QueryVariableValue.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
public QueryVariableValue(String name, Object value, QueryOperator operator, boolean local, boolean variableNameIgnoreCase, boolean variableValueIgnoreCase) { this.name = name; this.value = Variables.untypedValue(value); this.operator = operator; this.local = local; this.variableNameIgnoreCase = variableNameIgnoreCase; this.variableValueIgnoreCase = variableValueIgnoreCase; }
Example 7
Source File: VariableMapImpl.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
public Object put(String key, Object value) { TypedValue typedValue = Variables.untypedValue(value); TypedValue prevValue = variables.put(key, typedValue); if(prevValue != null) { return prevValue.getValue(); } else { return null; } }
Example 8
Source File: IdentityDataTypeTransformer.java From camunda-engine-dmn with Apache License 2.0 | 4 votes |
@Override public TypedValue transform(Object value) throws IllegalArgumentException { return Variables.untypedValue(value); }
Example 9
Source File: DefaultTypeDefinition.java From camunda-engine-dmn with Apache License 2.0 | 4 votes |
@Override public TypedValue transform(Object value) throws IllegalArgumentException { return Variables.untypedValue(value); }
Example 10
Source File: IdentityDataTypeTransformer.java From camunda-bpm-platform with Apache License 2.0 | 4 votes |
@Override public TypedValue transform(Object value) throws IllegalArgumentException { return Variables.untypedValue(value); }
Example 11
Source File: DefaultTypeDefinition.java From camunda-bpm-platform with Apache License 2.0 | 4 votes |
@Override public TypedValue transform(Object value) throws IllegalArgumentException { return Variables.untypedValue(value); }
Example 12
Source File: AbstractVariableScope.java From camunda-bpm-platform with Apache License 2.0 | 4 votes |
public void setVariable(String variableName, Object value) { TypedValue typedValue = Variables.untypedValue(value); setVariable(variableName, typedValue, getSourceActivityVariableScope()); }
Example 13
Source File: AbstractVariableScope.java From camunda-bpm-platform with Apache License 2.0 | 4 votes |
public void setVariableLocal(String variableName, Object value) { TypedValue typedValue = Variables.untypedValue(value); setVariableLocal(variableName, typedValue, getSourceActivityVariableScope()); }
Example 14
Source File: VariableValueDto.java From camunda-bpm-platform with Apache License 2.0 | 4 votes |
public TypedValue toTypedValue(ProcessEngine processEngine, ObjectMapper objectMapper) { ValueTypeResolver valueTypeResolver = processEngine.getProcessEngineConfiguration().getValueTypeResolver(); if (type == null) { if (valueInfo != null && valueInfo.get(ValueType.VALUE_INFO_TRANSIENT) instanceof Boolean) { return Variables.untypedValue(value, (Boolean) valueInfo.get(ValueType.VALUE_INFO_TRANSIENT)); } return Variables.untypedValue(value); } ValueType valueType = valueTypeResolver.typeForName(fromRestApiTypeName(type)); if(valueType == null) { throw new RestException(Status.BAD_REQUEST, String.format("Unsupported value type '%s'", type)); } else { if(valueType instanceof PrimitiveValueType) { PrimitiveValueType primitiveValueType = (PrimitiveValueType) valueType; Class<?> javaType = primitiveValueType.getJavaType(); Object mappedValue = null; try { if(value != null) { if(javaType.isAssignableFrom(value.getClass())) { mappedValue = value; } else { // use jackson to map the value to the requested java type mappedValue = objectMapper.readValue("\""+value+"\"", javaType); } } return valueType.createValue(mappedValue, valueInfo); } catch (Exception e) { throw new InvalidRequestException(Status.BAD_REQUEST, e, String.format("Cannot convert value '%s' of type '%s' to java type %s", value, type, javaType.getName())); } } else if(valueType instanceof SerializableValueType) { if(value != null && !(value instanceof String)) { throw new InvalidRequestException(Status.BAD_REQUEST, "Must provide 'null' or String value for value of SerializableValue type '"+type+"'."); } return ((SerializableValueType) valueType).createValueFromSerialized((String) value, valueInfo); } else if(valueType instanceof FileValueType) { if (value instanceof String) { value = Base64.decodeBase64((String) value); } return valueType.createValue(value, valueInfo); } else { return valueType.createValue(value, valueInfo); } } }