variableTypes.addType(new StringType(getMaxLengthString())); variableTypes.addType(new LongStringType(getMaxLengthString() + 1)); variableTypes.addType(new BooleanType());
@Override public Object getValue(ValueFields valueFields) { // In case the string is stored as a byte-array, create a string from the stored bytes // using platform encoding and return this instead of the text-value if(valueFields.getBytes() != null) { return new String(valueFields.getBytes()); } return super.getValue(valueFields); } }
@Override public void setValue(Object value, ValueFields valueFields) { if(value != null && ((String) value).length() > MAX_TEXT_LENGTH) { byte[] bytes = ((String) value).getBytes(); valueFields.setBytes(bytes); } else { // Make sure NO byte-array is present anymore in case this variable exceeded the // length before this update, but is shorter now valueFields.setBytes(null); // Revert to storing regular string super.setValue(value, valueFields); } }
@Override public void setValue(Object value, ValueFields valueFields) { if(value != null && ((String) value).length() > MAX_TEXT_LENGTH) { byte[] bytes = ((String) value).getBytes(); valueFields.setBytes(bytes); } else { // Make sure NO byte-array is present anymore in case this variable exceeded the // length before this update, but is shorter now valueFields.setBytes(null); // Revert to storing regular string super.setValue(value, valueFields); } }
@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); }
@Override public Object getValue(ValueFields valueFields) { // In case the string is stored as a byte-array, create a string from the stored bytes // using platform encoding and return this instead of the text-value if(valueFields.getBytes() != null) { return new String(valueFields.getBytes()); } return super.getValue(valueFields); } }
@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); }
protected 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()); 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 ByteArrayType()); variableTypes.addType(new SerializableType()); variableTypes.addType(new CustomObjectType("item", ItemInstance.class)); variableTypes.addType(new CustomObjectType("message", MessageInstance.class)); if (customPostVariableTypes!=null) { for (VariableType customVariableType: customPostVariableTypes) { variableTypes.addType(customVariableType); } } } }
protected 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()); 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 ByteArrayType()); variableTypes.addType(new SerializableType()); variableTypes.addType(new CustomObjectType("item", ItemInstance.class)); variableTypes.addType(new CustomObjectType("message", MessageInstance.class)); if (customPostVariableTypes!=null) { for (VariableType customVariableType: customPostVariableTypes) { variableTypes.addType(customVariableType); } } } }
variableTypes.addType(new StringType()); variableTypes.addType(new BooleanType()); variableTypes.addType(new ShortType());
variableTypes.addType(new StringType(getMaxLengthString())); variableTypes.addType(new LongStringType(getMaxLengthString() + 1)); variableTypes.addType(new BooleanType());