Search in sources :

Example 1 with LongType

use of org.activiti.engine.impl.variable.LongType 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);
            }
        }
    }
}
Also used : JsonType(org.activiti.engine.impl.variable.JsonType) LongJsonType(org.activiti.engine.impl.variable.LongJsonType) LongType(org.activiti.engine.impl.variable.LongType) JPAEntityListVariableType(org.activiti.engine.impl.variable.JPAEntityListVariableType) VariableType(org.activiti.engine.impl.variable.VariableType) JPAEntityVariableType(org.activiti.engine.impl.variable.JPAEntityVariableType) LongStringType(org.activiti.engine.impl.variable.LongStringType) StringType(org.activiti.engine.impl.variable.StringType) SerializableType(org.activiti.engine.impl.variable.SerializableType) ShortType(org.activiti.engine.impl.variable.ShortType) LongStringType(org.activiti.engine.impl.variable.LongStringType) BooleanType(org.activiti.engine.impl.variable.BooleanType) JodaDateTimeType(org.activiti.engine.impl.variable.JodaDateTimeType) BigDecimal(java.math.BigDecimal) CustomObjectType(org.activiti.engine.impl.variable.CustomObjectType) DefaultVariableTypes(org.activiti.engine.impl.variable.DefaultVariableTypes) IntegerType(org.activiti.engine.impl.variable.IntegerType) MessageInstance(org.activiti.engine.impl.bpmn.webservice.MessageInstance) DoubleType(org.activiti.engine.impl.variable.DoubleType) ByteArrayType(org.activiti.engine.impl.variable.ByteArrayType) UUIDType(org.activiti.engine.impl.variable.UUIDType) JsonTypeConverter(org.activiti.engine.impl.variable.JsonTypeConverter) NullType(org.activiti.engine.impl.variable.NullType) JodaDateType(org.activiti.engine.impl.variable.JodaDateType) DateType(org.activiti.engine.impl.variable.DateType) JodaDateType(org.activiti.engine.impl.variable.JodaDateType) LongJsonType(org.activiti.engine.impl.variable.LongJsonType) ItemInstance(org.activiti.engine.impl.bpmn.data.ItemInstance)

Example 2 with LongType

use of org.activiti.engine.impl.variable.LongType 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);
}
Also used : ExtendedJsonType(org.wso2.carbon.bpmn.core.types.datatypes.json.ExtendedJsonType) LongJsonType(org.activiti.engine.impl.variable.LongJsonType) JsonType(org.activiti.engine.impl.variable.JsonType) VariableTypes(org.activiti.engine.impl.variable.VariableTypes) DefaultVariableTypes(org.activiti.engine.impl.variable.DefaultVariableTypes) LongType(org.activiti.engine.impl.variable.LongType) VariableType(org.activiti.engine.impl.variable.VariableType) ExtendedJsonType(org.wso2.carbon.bpmn.core.types.datatypes.json.ExtendedJsonType) StringType(org.activiti.engine.impl.variable.StringType) LongStringType(org.activiti.engine.impl.variable.LongStringType) SerializableType(org.activiti.engine.impl.variable.SerializableType) ShortType(org.activiti.engine.impl.variable.ShortType) LongStringType(org.activiti.engine.impl.variable.LongStringType) BooleanType(org.activiti.engine.impl.variable.BooleanType) CustomObjectType(org.activiti.engine.impl.variable.CustomObjectType) XmlType(org.wso2.carbon.bpmn.core.types.datatypes.xml.XmlType) DefaultVariableTypes(org.activiti.engine.impl.variable.DefaultVariableTypes) IntegerType(org.activiti.engine.impl.variable.IntegerType) MessageInstance(org.activiti.engine.impl.bpmn.webservice.MessageInstance) DoubleType(org.activiti.engine.impl.variable.DoubleType) ByteArrayType(org.activiti.engine.impl.variable.ByteArrayType) UUIDType(org.activiti.engine.impl.variable.UUIDType) NullType(org.activiti.engine.impl.variable.NullType) DateType(org.activiti.engine.impl.variable.DateType) LongJsonType(org.activiti.engine.impl.variable.LongJsonType) ItemInstance(org.activiti.engine.impl.bpmn.data.ItemInstance)

Example 3 with LongType

use of org.activiti.engine.impl.variable.LongType 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;
}
Also used : LongType(org.activiti.engine.impl.variable.LongType) VariableType(org.activiti.engine.impl.variable.VariableType) HashMap(java.util.HashMap) StringType(org.activiti.engine.impl.variable.StringType) LongStringType(org.activiti.engine.impl.variable.LongStringType) SerializableType(org.activiti.engine.impl.variable.SerializableType) ShortType(org.activiti.engine.impl.variable.ShortType) BooleanType(org.activiti.engine.impl.variable.BooleanType) LongStringType(org.activiti.engine.impl.variable.LongStringType) Date(java.util.Date) IntegerType(org.activiti.engine.impl.variable.IntegerType) DoubleType(org.activiti.engine.impl.variable.DoubleType) UUIDType(org.activiti.engine.impl.variable.UUIDType) UUID(java.util.UUID) DateType(org.activiti.engine.impl.variable.DateType) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Aggregations

BooleanType (org.activiti.engine.impl.variable.BooleanType)3 DateType (org.activiti.engine.impl.variable.DateType)3 DoubleType (org.activiti.engine.impl.variable.DoubleType)3 IntegerType (org.activiti.engine.impl.variable.IntegerType)3 LongStringType (org.activiti.engine.impl.variable.LongStringType)3 LongType (org.activiti.engine.impl.variable.LongType)3 SerializableType (org.activiti.engine.impl.variable.SerializableType)3 ShortType (org.activiti.engine.impl.variable.ShortType)3 StringType (org.activiti.engine.impl.variable.StringType)3 UUIDType (org.activiti.engine.impl.variable.UUIDType)3 VariableType (org.activiti.engine.impl.variable.VariableType)3 ItemInstance (org.activiti.engine.impl.bpmn.data.ItemInstance)2 MessageInstance (org.activiti.engine.impl.bpmn.webservice.MessageInstance)2 ByteArrayType (org.activiti.engine.impl.variable.ByteArrayType)2 CustomObjectType (org.activiti.engine.impl.variable.CustomObjectType)2 DefaultVariableTypes (org.activiti.engine.impl.variable.DefaultVariableTypes)2 JsonType (org.activiti.engine.impl.variable.JsonType)2 LongJsonType (org.activiti.engine.impl.variable.LongJsonType)2 NullType (org.activiti.engine.impl.variable.NullType)2 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)1