use of org.activiti.engine.impl.variable.DoubleType in project Activiti by Activiti.
the class ProcessEngineConfigurationImpl method initVariableTypes.
public void initVariableTypes() {
if (variableTypes == null) {
variableTypes = new DefaultVariableTypes();
if (customPreVariableTypes != null) {
for (VariableType customVariableType : customPreVariableTypes) {
variableTypes.addType(customVariableType);
}
}
variableTypes.addType(new NullType());
variableTypes.addType(new StringType(getMaxLengthString()));
variableTypes.addType(new LongStringType(getMaxLengthString() + 1));
variableTypes.addType(new BooleanType());
variableTypes.addType(new ShortType());
variableTypes.addType(new IntegerType());
variableTypes.addType(new LongType());
variableTypes.addType(new DateType());
variableTypes.addType(new JodaDateType());
variableTypes.addType(new JodaDateTimeType());
variableTypes.addType(new DoubleType());
variableTypes.addType(new UUIDType());
objectMapper.configOverride(BigDecimal.class).setFormat(JsonFormat.Value.forShape(JsonFormat.Shape.STRING));
JsonTypeConverter jsonTypeConverter = new JsonTypeConverter(objectMapper, javaClassFieldForJackson);
variableTypes.addType(new JsonType(getMaxLengthString(), objectMapper, serializePOJOsInVariablesToJson, jsonTypeConverter));
variableTypes.addType(new LongJsonType(getMaxLengthString() + 1, objectMapper, serializePOJOsInVariablesToJson, jsonTypeConverter));
// if java serliazation needed together with json defaulting then add to customPostVariableTypes
if (!serializePOJOsInVariablesToJson) {
variableTypes.addType(new ByteArrayType());
variableTypes.addType(new SerializableType(serializableVariableTypeTrackDeserializedObjects));
variableTypes.addType(new CustomObjectType("item", ItemInstance.class));
variableTypes.addType(new CustomObjectType("message", MessageInstance.class));
}
if (customPostVariableTypes != null) {
for (VariableType customVariableType : customPostVariableTypes) {
variableTypes.addType(customVariableType);
}
}
}
}
use of org.activiti.engine.impl.variable.DoubleType in project carbon-business-process by wso2.
the class ActivitiEngineBuilder method setSupportedVariableTypes.
/**
* Function to set supported variable types
* @param processEngineConfiguration
*/
private void setSupportedVariableTypes(ProcessEngineConfigurationImpl processEngineConfiguration) {
VariableTypes variableTypes = new DefaultVariableTypes();
List<VariableType> customPreVariableTypes = processEngineConfiguration.getCustomPreVariableTypes();
if (customPreVariableTypes != null) {
for (VariableType customVariableType : customPreVariableTypes) {
variableTypes.addType(customVariableType);
}
}
// Default types in Activiti
variableTypes.addType(new NullType());
variableTypes.addType(new StringType(ProcessEngineConfigurationImpl.DEFAULT_ORACLE_MAX_LENGTH_STRING));
variableTypes.addType(new LongStringType(ProcessEngineConfigurationImpl.DEFAULT_ORACLE_MAX_LENGTH_STRING + 1));
variableTypes.addType(new BooleanType());
variableTypes.addType(new ShortType());
variableTypes.addType(new IntegerType());
variableTypes.addType(new LongType());
variableTypes.addType(new DateType());
variableTypes.addType(new DoubleType());
variableTypes.addType(new UUIDType());
;
variableTypes.addType(new JsonType(ProcessEngineConfigurationImpl.DEFAULT_ORACLE_MAX_LENGTH_STRING, objectMapper));
variableTypes.addType(new LongJsonType(ProcessEngineConfigurationImpl.DEFAULT_ORACLE_MAX_LENGTH_STRING + 1, objectMapper));
variableTypes.addType(new ByteArrayType());
variableTypes.addType(new SerializableType());
variableTypes.addType(new CustomObjectType("item", ItemInstance.class));
variableTypes.addType(new CustomObjectType("message", MessageInstance.class));
// types added for WSO2 BPS
variableTypes.addType(new ExtendedJsonType(ProcessEngineConfigurationImpl.DEFAULT_ORACLE_MAX_LENGTH_STRING, objectMapper));
variableTypes.addType(new XmlType());
List<VariableType> customPostVariableTypes = processEngineConfiguration.getCustomPostVariableTypes();
if (customPostVariableTypes != null) {
for (VariableType customVariableType : customPostVariableTypes) {
variableTypes.addType(customVariableType);
}
}
processEngineConfiguration.setVariableTypes(variableTypes);
}
use of org.activiti.engine.impl.variable.DoubleType in project Activiti by Activiti.
the class VariableEventHandler method createData.
protected Map<String, Object> createData(ActivitiVariableEvent variableEvent) {
Map<String, Object> data = new HashMap<String, Object>();
putInMapIfNotNull(data, Fields.NAME, variableEvent.getVariableName());
putInMapIfNotNull(data, Fields.PROCESS_DEFINITION_ID, variableEvent.getProcessDefinitionId());
putInMapIfNotNull(data, Fields.PROCESS_INSTANCE_ID, variableEvent.getProcessInstanceId());
putInMapIfNotNull(data, Fields.EXECUTION_ID, variableEvent.getExecutionId());
putInMapIfNotNull(data, Fields.VALUE, variableEvent.getVariableValue());
VariableType variableType = variableEvent.getVariableType();
if (variableType instanceof BooleanType) {
putInMapIfNotNull(data, Fields.VALUE_BOOLEAN, (Boolean) variableEvent.getVariableValue());
putInMapIfNotNull(data, Fields.VALUE, variableEvent.getVariableValue());
putInMapIfNotNull(data, Fields.VARIABLE_TYPE, TYPE_BOOLEAN);
} else if (variableType instanceof StringType || variableType instanceof LongStringType) {
putInMapIfNotNull(data, Fields.VALUE_STRING, (String) variableEvent.getVariableValue());
putInMapIfNotNull(data, Fields.VARIABLE_TYPE, TYPE_STRING);
} else if (variableType instanceof ShortType) {
Short value = (Short) variableEvent.getVariableValue();
putInMapIfNotNull(data, Fields.VALUE_SHORT, value);
putInMapIfNotNull(data, Fields.VARIABLE_TYPE, TYPE_SHORT);
if (value != null) {
putInMapIfNotNull(data, Fields.VALUE_INTEGER, value.intValue());
putInMapIfNotNull(data, Fields.VALUE_LONG, value.longValue());
putInMapIfNotNull(data, Fields.VALUE_DOUBLE, value.doubleValue());
}
} else if (variableType instanceof IntegerType) {
Integer value = (Integer) variableEvent.getVariableValue();
putInMapIfNotNull(data, Fields.VALUE_INTEGER, value);
putInMapIfNotNull(data, Fields.VARIABLE_TYPE, TYPE_INTEGER);
if (value != null) {
putInMapIfNotNull(data, Fields.VALUE_LONG, value.longValue());
putInMapIfNotNull(data, Fields.VALUE_DOUBLE, value.doubleValue());
}
} else if (variableType instanceof LongType) {
Long value = (Long) variableEvent.getVariableValue();
putInMapIfNotNull(data, Fields.VALUE_LONG, value);
putInMapIfNotNull(data, Fields.VARIABLE_TYPE, TYPE_LONG);
if (value != null) {
putInMapIfNotNull(data, Fields.VALUE_DOUBLE, value.doubleValue());
}
} else if (variableType instanceof DoubleType) {
Double value = (Double) variableEvent.getVariableValue();
putInMapIfNotNull(data, Fields.VALUE_DOUBLE, value);
putInMapIfNotNull(data, Fields.VARIABLE_TYPE, TYPE_DOUBLE);
if (value != null) {
putInMapIfNotNull(data, Fields.VALUE_INTEGER, value.intValue());
putInMapIfNotNull(data, Fields.VALUE_LONG, value.longValue());
}
} else if (variableType instanceof DateType) {
Date value = (Date) variableEvent.getVariableValue();
putInMapIfNotNull(data, Fields.VALUE_DATE, value != null ? value.getTime() : null);
putInMapIfNotNull(data, Fields.VARIABLE_TYPE, TYPE_DATE);
} else if (variableType instanceof UUIDType) {
String value = null;
if (variableEvent.getVariableValue() instanceof UUID) {
value = ((UUID) variableEvent.getVariableValue()).toString();
} else {
value = (String) variableEvent.getVariableValue();
}
putInMapIfNotNull(data, Fields.VALUE_UUID, value);
putInMapIfNotNull(data, Fields.VALUE_STRING, value);
putInMapIfNotNull(data, Fields.VARIABLE_TYPE, TYPE_UUID);
} else if (variableType instanceof SerializableType || (variableEvent.getVariableValue() != null && (variableEvent.getVariableValue() instanceof Object))) {
// Last try: serialize it to json
ObjectMapper objectMapper = new ObjectMapper();
try {
String value = objectMapper.writeValueAsString(variableEvent.getVariableValue());
putInMapIfNotNull(data, Fields.VALUE_JSON, value);
putInMapIfNotNull(data, Fields.VARIABLE_TYPE, TYPE_JSON);
putInMapIfNotNull(data, Fields.VALUE, value);
} catch (JsonProcessingException e) {
// Nothing to do about it
logger.debug("Could not serialize variable value " + variableEvent.getVariableValue());
}
}
return data;
}
Aggregations