コード例 #1
0
 /**
  * Adds configured variables to the variable service.
  *
  * @param variableService service to add to
  * @param variables configured variables
  */
 protected static void initVariables(
     VariableService variableService,
     Map<String, ConfigurationVariable> variables,
     EngineImportService engineImportService) {
   for (Map.Entry<String, ConfigurationVariable> entry : variables.entrySet()) {
     try {
       Pair<String, Boolean> arrayType =
           JavaClassHelper.isGetArrayType(entry.getValue().getType());
       variableService.createNewVariable(
           null,
           entry.getKey(),
           arrayType.getFirst(),
           entry.getValue().isConstant(),
           arrayType.getSecond(),
           false,
           entry.getValue().getInitializationValue(),
           engineImportService);
       variableService.allocateVariableState(entry.getKey(), 0, null);
     } catch (VariableExistsException e) {
       throw new ConfigurationException("Error configuring variables: " + e.getMessage(), e);
     } catch (VariableTypeException e) {
       throw new ConfigurationException("Error configuring variables: " + e.getMessage(), e);
     }
   }
 }
 public void addVariable(
     String variableName, String type, Object initializationValue, boolean constant)
     throws ConfigurationException {
   try {
     Pair<String, Boolean> arrayType = JavaClassHelper.isGetArrayType(type);
     variableService.createNewVariable(
         variableName,
         arrayType.getFirst(),
         initializationValue,
         constant,
         arrayType.getSecond(),
         null,
         engineImportService);
     statementVariableRef.addConfiguredVariable(variableName);
   } catch (VariableExistsException e) {
     throw new ConfigurationException("Error creating variable: " + e.getMessage(), e);
   } catch (VariableTypeException e) {
     throw new ConfigurationException("Error creating variable: " + e.getMessage(), e);
   }
 }