Search in sources :

Example 1 with VariableType

use of org.activiti.engine.impl.variable.VariableType in project herd by FINRAOS.

the class HerdProcessEngineConfigurator method replaceVariableType.

/**
 * Inserts the variableType in variableTypes at the given index. If variableType already exists, then it replaces the type at the location where it already
 * exists.
 *
 * @param variableTypes the variableTypes
 * @param variableTypeToReplace the variableType to insert
 * @param indexToInsert the index to insert variableType
 *
 * @return the index where variableType was inserted.
 */
private int replaceVariableType(VariableTypes variableTypes, VariableType variableTypeToReplace, int indexToInsert) {
    int indexToInsertReturn = indexToInsert;
    VariableType existingVariableType = variableTypes.getVariableType(variableTypeToReplace.getTypeName());
    if (existingVariableType != null) {
        indexToInsertReturn = variableTypes.getTypeIndex(existingVariableType.getTypeName());
        variableTypes.removeType(existingVariableType);
    }
    variableTypes.addType(variableTypeToReplace, indexToInsertReturn);
    return indexToInsertReturn;
}
Also used : VariableType(org.activiti.engine.impl.variable.VariableType)

Example 2 with VariableType

use of org.activiti.engine.impl.variable.VariableType in project Activiti by Activiti.

the class VariableScopeImpl method createVariableInstance.

protected VariableInstanceEntity createVariableInstance(String variableName, Object value, ExecutionEntity sourceActivityExecution) {
    VariableTypes variableTypes = Context.getProcessEngineConfiguration().getVariableTypes();
    VariableType type = variableTypes.findVariableType(value);
    VariableInstanceEntity variableInstance = Context.getCommandContext().getVariableInstanceEntityManager().create(variableName, type, value);
    initializeVariableInstanceBackPointer(variableInstance);
    Context.getCommandContext().getVariableInstanceEntityManager().insert(variableInstance);
    if (variableInstances != null) {
        variableInstances.put(variableName, variableInstance);
    }
    // Record historic variable
    Context.getCommandContext().getHistoryManager().recordVariableCreate(variableInstance);
    // Record historic detail
    Context.getCommandContext().getHistoryManager().recordHistoricDetailVariableCreate(variableInstance, sourceActivityExecution, isActivityIdUsedForDetails());
    return variableInstance;
}
Also used : VariableTypes(org.activiti.engine.impl.variable.VariableTypes) VariableType(org.activiti.engine.impl.variable.VariableType)

Example 3 with VariableType

use of org.activiti.engine.impl.variable.VariableType 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 4 with VariableType

use of org.activiti.engine.impl.variable.VariableType in project Activiti by Activiti.

the class IbatisVariableTypeHandler method getResult.

public VariableType getResult(ResultSet rs, String columnName) throws SQLException {
    String typeName = rs.getString(columnName);
    VariableType type = getVariableTypes().getVariableType(typeName);
    if (type == null && typeName != null) {
        throw new ActivitiException("unknown variable type name " + typeName);
    }
    return type;
}
Also used : ActivitiException(org.activiti.engine.ActivitiException) VariableType(org.activiti.engine.impl.variable.VariableType)

Example 5 with VariableType

use of org.activiti.engine.impl.variable.VariableType in project herd by FINRAOS.

the class HerdProcessEngineConfigurator method configure.

@Override
public void configure(ProcessEngineConfigurationImpl processEngineConfiguration) {
    // There is an issue when using Activiti with Oracle. When workflow variables have a length greater then 2000 and smaller than 4001,
    // Activiti tries to store that as a String column, but the Oracle database column length (ACT_RU_VARIABLE.TEXT_, ACT_HI_VARINST.TEXT_) is 2000.
    // Since Activiti uses NVARCHAR as the column type which requires 2 bytes for every character, the maximum size Oracle allows for the column is
    // 2000 (i.e. 4000 bytes).
    // Replace the StringType and LongType to store greater than 2000 length variables as blob.
    VariableTypes variableTypes = processEngineConfiguration.getVariableTypes();
    VariableType stringType = new StringType(2000);
    int indexToInsert = replaceVariableType(variableTypes, stringType, 0);
    VariableType longStringType = new LongStringType(2001);
    replaceVariableType(variableTypes, longStringType, ++indexToInsert);
}
Also used : VariableTypes(org.activiti.engine.impl.variable.VariableTypes) VariableType(org.activiti.engine.impl.variable.VariableType) LongStringType(org.activiti.engine.impl.variable.LongStringType) StringType(org.activiti.engine.impl.variable.StringType) LongStringType(org.activiti.engine.impl.variable.LongStringType)

Aggregations

VariableType (org.activiti.engine.impl.variable.VariableType)12 LongStringType (org.activiti.engine.impl.variable.LongStringType)4 StringType (org.activiti.engine.impl.variable.StringType)4 VariableTypes (org.activiti.engine.impl.variable.VariableTypes)4 ActivitiException (org.activiti.engine.ActivitiException)3 BooleanType (org.activiti.engine.impl.variable.BooleanType)3 DateType (org.activiti.engine.impl.variable.DateType)3 DefaultVariableTypes (org.activiti.engine.impl.variable.DefaultVariableTypes)3 DoubleType (org.activiti.engine.impl.variable.DoubleType)3 IntegerType (org.activiti.engine.impl.variable.IntegerType)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 UUIDType (org.activiti.engine.impl.variable.UUIDType)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 JPAEntityListVariableType (org.activiti.engine.impl.variable.JPAEntityListVariableType)2 JPAEntityVariableType (org.activiti.engine.impl.variable.JPAEntityVariableType)2