org.activiti.engine.impl.variable.VariableTypes Java Examples

The following examples show how to use org.activiti.engine.impl.variable.VariableTypes. 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: HerdProcessEngineConfigurator.java    From herd with Apache License 2.0 6 votes vote down vote up
/**
 * 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;
}
 
Example #2
Source File: HerdProcessEngineConfigurator.java    From herd with Apache License 2.0 6 votes vote down vote up
@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);
}
 
Example #3
Source File: VariableScopeImpl.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
protected VariableInstanceEntity createVariableInstance(String variableName, Object value, ExecutionEntity sourceActivityExecution) {
  VariableTypes variableTypes = Context
    .getProcessEngineConfiguration()
    .getVariableTypes();
  
  VariableType type = variableTypes.findVariableType(value);
 
  VariableInstanceEntity variableInstance = VariableInstanceEntity.createAndInsert(variableName, type, value);
  initializeVariableInstanceBackPointer(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;
}
 
Example #4
Source File: VariableScopeImpl.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
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;
}
 
Example #5
Source File: VariableScopeImpl.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
protected void updateVariableInstance(VariableInstanceEntity variableInstance, Object value, ExecutionEntity sourceActivityExecution) {

    // Always check if the type should be altered. It's possible that the
    // previous type is lower in the type
    // checking chain (e.g. serializable) and will return true on
    // isAbleToStore(), even though another type
    // higher in the chain is eligible for storage.

    VariableTypes variableTypes = Context.getProcessEngineConfiguration().getVariableTypes();

    VariableType newType = variableTypes.findVariableType(value);

    if (newType != null && !newType.equals(variableInstance.getType())) {
      variableInstance.setValue(null);
      variableInstance.setType(newType);
      variableInstance.forceUpdate();
      variableInstance.setValue(value);
    } else {
      variableInstance.setValue(value);
    }

    Context.getCommandContext().getHistoryManager().recordHistoricDetailVariableCreate(variableInstance, sourceActivityExecution, isActivityIdUsedForDetails());

    Context.getCommandContext().getHistoryManager().recordVariableUpdate(variableInstance);
  }
 
Example #6
Source File: TaskQueryImpl.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
protected void ensureVariablesInitialized() {
  VariableTypes types = Context.getProcessEngineConfiguration().getVariableTypes();
  for (QueryVariableValue var : queryVariableValues) {
    var.initialize(types);
  }
  
  for (TaskQueryImpl orQueryObject : orQueryObjects) {
    orQueryObject.ensureVariablesInitialized();
  }
}
 
Example #7
Source File: TaskQueryImpl.java    From lemon with Apache License 2.0 5 votes vote down vote up
protected void ensureVariablesInitialized() {
    VariableTypes types = Context.getProcessEngineConfiguration()
            .getVariableTypes();

    for (QueryVariableValue var : queryVariableValues) {
        var.initialize(types);
    }

    for (TaskQueryImpl orQueryObject : orQueryObjects) {
        orQueryObject.ensureVariablesInitialized();
    }
}
 
Example #8
Source File: QueryVariableValue.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
public void initialize(VariableTypes types) {
  if (variableInstanceEntity == null) {
    VariableType type = types.findVariableType(value);
    if (type instanceof ByteArrayType) {
      throw new ActivitiIllegalArgumentException("Variables of type ByteArray cannot be used to query");
    } else if (type instanceof JPAEntityVariableType && operator != QueryOperator.EQUALS) {
      throw new ActivitiIllegalArgumentException("JPA entity variables can only be used in 'variableValueEquals'");
    } else if (type instanceof JPAEntityListVariableType) {
      throw new ActivitiIllegalArgumentException("Variables containing a list of JPA entities cannot be used to query");
    } else {
      // Type implementation determines which fields are set on the entity
      variableInstanceEntity = Context.getCommandContext().getVariableInstanceEntityManager().create(name, type, value);
    }
  }
}
 
Example #9
Source File: HistoricTaskInstanceQueryImpl.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
protected void ensureVariablesInitialized() {
  VariableTypes types = Context.getProcessEngineConfiguration().getVariableTypes();
  for (QueryVariableValue var : queryVariableValues) {
    var.initialize(types);
  }
  
  for (HistoricTaskInstanceQueryImpl orQueryObject : orQueryObjects) {
    orQueryObject.ensureVariablesInitialized();
  }
}
 
Example #10
Source File: AbstractVariableQueryImpl.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
protected void ensureVariablesInitialized() {
  if (!queryVariableValues.isEmpty()) {
    VariableTypes variableTypes = Context.getProcessEngineConfiguration().getVariableTypes();
    for (QueryVariableValue queryVariableValue : queryVariableValues) {
      queryVariableValue.initialize(variableTypes);
    }
  }
}
 
Example #11
Source File: QueryVariableValue.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
public void initialize(VariableTypes types) {
  if(variableInstanceEntity == null) {
    VariableType type = types.findVariableType(value);
    if(type instanceof ByteArrayType) {
      throw new ActivitiIllegalArgumentException("Variables of type ByteArray cannot be used to query");
    } else if(type instanceof JPAEntityVariableType && operator != QueryOperator.EQUALS) {
      throw new ActivitiIllegalArgumentException("JPA entity variables can only be used in 'variableValueEquals'");
    } else if(type instanceof JPAEntityListVariableType) {
      throw new ActivitiIllegalArgumentException("Variables containing a list of JPA entities cannot be used to query");
    } else {
      // Type implementation determines which fields are set on the entity
      variableInstanceEntity = VariableInstanceEntity.create(name, type, value);
    }
  }
}
 
Example #12
Source File: HistoricTaskInstanceQueryImpl.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
protected void ensureVariablesInitialized() {    
  VariableTypes types = Context.getProcessEngineConfiguration().getVariableTypes();
  for (QueryVariableValue var : queryVariableValues) {
    var.initialize(types);
  }
  
  for (HistoricTaskInstanceQueryImpl orQueryObject : orQueryObjects) {
    orQueryObject.ensureVariablesInitialized();
  }
}
 
Example #13
Source File: AbstractVariableQueryImpl.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
protected void ensureVariablesInitialized() {
  if (!queryVariableValues.isEmpty()) {
    VariableTypes variableTypes = Context
            .getProcessEngineConfiguration()
            .getVariableTypes();
    for(QueryVariableValue queryVariableValue : queryVariableValues) {
      queryVariableValue.initialize(variableTypes);
    }
  }
}
 
Example #14
Source File: IbatisVariableTypeHandler.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
protected VariableTypes getVariableTypes() {
  if (variableTypes==null) {
    variableTypes = Context
      .getProcessEngineConfiguration()
      .getVariableTypes();
  }
  return variableTypes;
}
 
Example #15
Source File: VariableScopeImpl.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
protected void updateVariableInstance(VariableInstanceEntity variableInstance, Object value, ExecutionEntity sourceActivityExecution) {

   // Always check if the type should be altered. It's possible that the previous type is lower in the type
   // checking chain (e.g. serializable) and will return true on isAbleToStore(), even though another type
   // higher in the chain is eligible for storage.
   
   VariableTypes variableTypes = Context
       .getProcessEngineConfiguration()
       .getVariableTypes();
   
   VariableType newType = variableTypes.findVariableType(value);
   
   if (newType != null && !newType.equals(variableInstance.getType())) {
     variableInstance.setValue(null);
     variableInstance.setType(newType);
     variableInstance.forceUpdate();
     variableInstance.setValue(value);
   } else {
     variableInstance.setValue(value);
   }

   Context.getCommandContext().getHistoryManager()
     .recordHistoricDetailVariableCreate(variableInstance, sourceActivityExecution, isActivityIdUsedForDetails());
   
   Context.getCommandContext().getHistoryManager()
     .recordVariableUpdate(variableInstance);
 }
 
Example #16
Source File: TaskQueryImpl.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
protected void ensureVariablesInitialized() {    
  VariableTypes types = Context.getProcessEngineConfiguration().getVariableTypes();
  for (QueryVariableValue var : queryVariableValues) {
    var.initialize(types);
  }
  
  for (TaskQueryImpl orQueryObject : orQueryObjects) {
    orQueryObject.ensureVariablesInitialized();
  }
}
 
Example #17
Source File: ProcessEngineConfigurationImpl.java    From activiti6-boot2 with Apache License 2.0 4 votes vote down vote up
public VariableTypes getVariableTypes() {
  return variableTypes;
}
 
Example #18
Source File: HistoricVariableInstanceQueryImpl.java    From activiti6-boot2 with Apache License 2.0 4 votes vote down vote up
protected void ensureVariablesInitialized() {
  if (this.queryVariableValue != null) {
    VariableTypes variableTypes = Context.getProcessEngineConfiguration().getVariableTypes();
    queryVariableValue.initialize(variableTypes);
  }
}
 
Example #19
Source File: IbatisVariableTypeHandler.java    From activiti6-boot2 with Apache License 2.0 4 votes vote down vote up
protected VariableTypes getVariableTypes() {
  if (variableTypes == null) {
    variableTypes = Context.getProcessEngineConfiguration().getVariableTypes();
  }
  return variableTypes;
}
 
Example #20
Source File: HistoricVariableInstanceQueryImpl.java    From activiti6-boot2 with Apache License 2.0 4 votes vote down vote up
protected void ensureVariablesInitialized() {
  if (this.queryVariableValue != null) {
    VariableTypes variableTypes = Context.getProcessEngineConfiguration().getVariableTypes();
    queryVariableValue.initialize(variableTypes);
  }
}
 
Example #21
Source File: DefaultVariableTypes.java    From activiti6-boot2 with Apache License 2.0 4 votes vote down vote up
public VariableTypes removeType(VariableType type) {
  typesList.remove(type);
  typesMap.remove(type.getTypeName());
  return this;
}
 
Example #22
Source File: ProcessEngineConfigurationImpl.java    From activiti6-boot2 with Apache License 2.0 4 votes vote down vote up
public ProcessEngineConfigurationImpl setVariableTypes(VariableTypes variableTypes) {
  this.variableTypes = variableTypes;
  return this;
}