当前位置: 首页>>代码示例>>Java>>正文


Java VariableContext类代码示例

本文整理汇总了Java中org.camunda.bpm.engine.variable.context.VariableContext的典型用法代码示例。如果您正苦于以下问题:Java VariableContext类的具体用法?Java VariableContext怎么用?Java VariableContext使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


VariableContext类属于org.camunda.bpm.engine.variable.context包,在下文中一共展示了VariableContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: evaluate

import org.camunda.bpm.engine.variable.context.VariableContext; //导入依赖的package包/类
@Override
public DmnDecisionLogicEvaluationEvent evaluate(DmnDecision decision, VariableContext variableContext) {
  DmnDecisionTableEvaluationEventImpl evaluationResult = new DmnDecisionTableEvaluationEventImpl();
  evaluationResult.setDecisionTable(decision);

  DmnDecisionTableImpl decisionTable = (DmnDecisionTableImpl) decision.getDecisionLogic();
  evaluationResult.setExecutedDecisionElements(calculateExecutedDecisionElements(decisionTable));

  evaluateDecisionTable(decisionTable, variableContext, evaluationResult);

  // apply hit policy
  decisionTable.getHitPolicyHandler().apply(evaluationResult);

  // notify listeners
  for (DmnDecisionTableEvaluationListener evaluationListener : evaluationListeners) {
    evaluationListener.notify(evaluationResult);
  }

  return evaluationResult;
}
 
开发者ID:camunda,项目名称:camunda-engine-dmn,代码行数:21,代码来源:DecisionTableEvaluationHandler.java

示例2: evaluateDecisionTable

import org.camunda.bpm.engine.variable.context.VariableContext; //导入依赖的package包/类
protected void evaluateDecisionTable(DmnDecisionTableImpl decisionTable, VariableContext variableContext, DmnDecisionTableEvaluationEventImpl evaluationResult) {
  int inputSize = decisionTable.getInputs().size();
  List<DmnDecisionTableRuleImpl> matchingRules = new ArrayList<DmnDecisionTableRuleImpl>(decisionTable.getRules());
  for (int inputIdx = 0; inputIdx < inputSize; inputIdx++) {
    // evaluate input
    DmnDecisionTableInputImpl input = decisionTable.getInputs().get(inputIdx);
    DmnEvaluatedInput evaluatedInput = evaluateInput(input, variableContext);
    evaluationResult.getInputs().add(evaluatedInput);

    // compose local variable context out of global variable context enhanced with the value of the current input.
    VariableContext localVariableContext = getLocalVariableContext(input, evaluatedInput, variableContext);

    // filter rules applicable with this input
    matchingRules = evaluateInputForAvailableRules(inputIdx, input, matchingRules, localVariableContext);
  }

  setEvaluationOutput(decisionTable, matchingRules, variableContext, evaluationResult);
}
 
开发者ID:camunda,项目名称:camunda-engine-dmn,代码行数:19,代码来源:DecisionTableEvaluationHandler.java

示例3: evaluateInputEntry

import org.camunda.bpm.engine.variable.context.VariableContext; //导入依赖的package包/类
protected Object evaluateInputEntry(DmnDecisionTableInputImpl input, DmnExpressionImpl condition, VariableContext variableContext) {
  if (isNonEmptyExpression(condition)) {
    String expressionLanguage = condition.getExpressionLanguage();
    if (expressionLanguage == null) {
      expressionLanguage = inputEntryExpressionLanguage;
    }
    if (expressionEvaluationHandler.isFeelExpressionLanguage(expressionLanguage)) {
      return evaluateFeelSimpleUnaryTests(input, condition, variableContext);
    } else {
      return expressionEvaluationHandler.evaluateExpression(expressionLanguage, condition, variableContext);
    }
  }
  else {
    return true; // input entries without expressions are true
  }
}
 
开发者ID:camunda,项目名称:camunda-engine-dmn,代码行数:17,代码来源:DecisionTableEvaluationHandler.java

示例4: evaluateOutputEntries

import org.camunda.bpm.engine.variable.context.VariableContext; //导入依赖的package包/类
protected Map<String, DmnEvaluatedOutput> evaluateOutputEntries(List<DmnDecisionTableOutputImpl> decisionTableOutputs, DmnDecisionTableRuleImpl matchingRule, VariableContext variableContext) {
  Map<String, DmnEvaluatedOutput> outputEntries = new LinkedHashMap<String, DmnEvaluatedOutput>();

  for (int outputIdx = 0; outputIdx < decisionTableOutputs.size(); outputIdx++) {
    // evaluate output entry, skip empty expressions
    DmnExpressionImpl conclusion = matchingRule.getConclusions().get(outputIdx);
    if (isNonEmptyExpression(conclusion)) {
      Object value = evaluateOutputEntry(conclusion, variableContext);

      // transform to output type
      DmnDecisionTableOutputImpl decisionTableOutput = decisionTableOutputs.get(outputIdx);
      TypedValue typedValue = decisionTableOutput.getTypeDefinition().transform(value);

      // set on result
      DmnEvaluatedOutputImpl evaluatedOutput = new DmnEvaluatedOutputImpl(decisionTableOutput, typedValue);
      outputEntries.put(decisionTableOutput.getOutputName(), evaluatedOutput);
    }
  }

  return outputEntries;
}
 
开发者ID:camunda,项目名称:camunda-engine-dmn,代码行数:22,代码来源:DecisionTableEvaluationHandler.java

示例5: evaluateExpression

import org.camunda.bpm.engine.variable.context.VariableContext; //导入依赖的package包/类
public Object evaluateExpression(String expressionLanguage, DmnExpressionImpl expression, VariableContext variableContext) {
  String expressionText = getExpressionTextForLanguage(expression, expressionLanguage);
  if (expressionText != null) {

    if (isFeelExpressionLanguage(expressionLanguage)) {
      return evaluateFeelSimpleExpression(expressionText, variableContext);

    } else if (isElExpression(expressionLanguage)) {
      return evaluateElExpression(expressionLanguage, expressionText, variableContext, expression);

    } else {
      return evaluateScriptExpression(expressionLanguage, variableContext, expressionText, expression);
    }
  } else {
    return null;
  }
}
 
开发者ID:camunda,项目名称:camunda-engine-dmn,代码行数:18,代码来源:ExpressionEvaluationHandler.java

示例6: evaluateElExpression

import org.camunda.bpm.engine.variable.context.VariableContext; //导入依赖的package包/类
protected Object evaluateElExpression(String expressionLanguage, String expressionText, VariableContext variableContext, CachedExpressionSupport cachedExpressionSupport) {
  try {
    ElExpression elExpression = cachedExpressionSupport.getCachedExpression();

    if (elExpression == null) {
      synchronized (cachedExpressionSupport) {
        elExpression = cachedExpressionSupport.getCachedExpression();
        if(elExpression == null) {
          elExpression = elProvider.createExpression(expressionText);
          cachedExpressionSupport.setCachedExpression(elExpression);
        }
      }
    }

    return elExpression.getValue(variableContext);
  }
  // yes, we catch all exceptions
  catch(Exception e) {
    throw LOG.unableToEvaluateExpression(expressionText, expressionLanguage, e);
  }
}
 
开发者ID:camunda,项目名称:camunda-engine-dmn,代码行数:22,代码来源:ExpressionEvaluationHandler.java

示例7: evaluate

import org.camunda.bpm.engine.variable.context.VariableContext; //导入依赖的package包/类
@Override
public DmnDecisionLogicEvaluationEvent evaluate(DmnDecision decision, VariableContext variableContext) {
  DmnDecisionLiteralExpressionEvaluationEventImpl evaluationResult = new DmnDecisionLiteralExpressionEvaluationEventImpl();
  evaluationResult.setDecision(decision);
  evaluationResult.setExecutedDecisionElements(1);

  DmnDecisionLiteralExpressionImpl dmnDecisionLiteralExpression = (DmnDecisionLiteralExpressionImpl) decision.getDecisionLogic();
  DmnVariableImpl variable = dmnDecisionLiteralExpression.getVariable();
  DmnExpressionImpl expression = dmnDecisionLiteralExpression.getExpression();

  Object evaluateExpression = evaluateLiteralExpression(expression, variableContext);
  TypedValue typedValue = variable.getTypeDefinition().transform(evaluateExpression);

  evaluationResult.setOutputValue(typedValue);
  evaluationResult.setOutputName(variable.getName());

  return evaluationResult;
}
 
开发者ID:camunda,项目名称:camunda-engine-dmn,代码行数:19,代码来源:DecisionLiteralExpressionEvaluationHandler.java

示例8: getValue

import org.camunda.bpm.engine.variable.context.VariableContext; //导入依赖的package包/类
@Override
public Object getValue(ELContext context, Object base, Object property) {
  VariableContext variableContext = (VariableContext) context.getContext(VariableContext.class);
  if(variableContext != null) {
    if(VARIABLE_CONTEXT_KEY.equals(property)) {
      context.setPropertyResolved(true);
      return variableContext;
    }
    TypedValue typedValue = variableContext.resolve((String) property);
    if(typedValue != null) {
      context.setPropertyResolved(true);
      return unpack(typedValue);
    }
  }
  return null;
}
 
开发者ID:camunda,项目名称:camunda-engine-dmn,代码行数:17,代码来源:VariableContextElResolver.java

示例9: testFeelInputExpression

import org.camunda.bpm.engine.variable.context.VariableContext; //导入依赖的package包/类
@Test
@DecisionResource(resource = DMN)
public void testFeelInputExpression() {
  DefaultDmnEngineConfiguration configuration = (DefaultDmnEngineConfiguration) getDmnEngineConfiguration();
  configuration.setDefaultInputExpressionExpressionLanguage(DefaultDmnEngineConfiguration.FEEL_EXPRESSION_LANGUAGE);
  DmnEngine engine = configuration.buildEngine();

  try {
    engine.evaluateDecision(decision, Variables.createVariables().putValue("score", 3));

    failBecauseExceptionWasNotThrown(UnsupportedOperationException.class);
  }
  catch (UnsupportedOperationException e) {
    assertThat(e).hasMessageStartingWith("FEEL-01016");
    verify(feelEngineSpy).evaluateSimpleExpression(anyString(), any(VariableContext.class));
  }
}
 
开发者ID:camunda,项目名称:camunda-engine-dmn,代码行数:18,代码来源:FeelIntegrationTest.java

示例10: testFeelOutputEntry

import org.camunda.bpm.engine.variable.context.VariableContext; //导入依赖的package包/类
@Test
@DecisionResource(resource = DMN)
public void testFeelOutputEntry() {
  DefaultDmnEngineConfiguration configuration = (DefaultDmnEngineConfiguration) getDmnEngineConfiguration();
  configuration.setDefaultOutputEntryExpressionLanguage(DefaultDmnEngineConfiguration.FEEL_EXPRESSION_LANGUAGE);
  DmnEngine engine = configuration.buildEngine();

  try {
    engine.evaluateDecision(decision, Variables.createVariables().putValue("score", 3));

    failBecauseExceptionWasNotThrown(UnsupportedOperationException.class);
  }
  catch (UnsupportedOperationException e) {
    assertThat(e).hasMessageStartingWith("FEEL-01016");
    verify(feelEngineSpy).evaluateSimpleExpression(anyString(), any(VariableContext.class));
  }
}
 
开发者ID:camunda,项目名称:camunda-engine-dmn,代码行数:18,代码来源:FeelIntegrationTest.java

示例11: testFeelInputExpressionWithCustomEngine

import org.camunda.bpm.engine.variable.context.VariableContext; //导入依赖的package包/类
@Test
@DecisionResource(resource = DMN)
public void testFeelInputExpressionWithCustomEngine() {
  DefaultDmnEngineConfiguration configuration = (DefaultDmnEngineConfiguration) getDmnEngineConfiguration();
  configuration.setDefaultInputExpressionExpressionLanguage(DefaultDmnEngineConfiguration.FEEL_EXPRESSION_LANGUAGE);
  DmnEngine engine = configuration.buildEngine();

  // stubbing the default FEEL engine behavior
  doReturn(3).when(feelEngineSpy).evaluateSimpleExpression(eq("score"), any(VariableContext.class));

  DmnDecisionResult decisionResult = engine.evaluateDecision(decision, Variables.createVariables().putValue("score", 3));

  assertThat(decisionResult.getSingleEntry()).isEqualTo("a");

  verify(feelEngineSpy).evaluateSimpleExpression(anyString(), any(VariableContext.class));
}
 
开发者ID:camunda,项目名称:camunda-engine-dmn,代码行数:17,代码来源:FeelIntegrationTest.java

示例12: testFeelOutputEntryWithCustomEngine

import org.camunda.bpm.engine.variable.context.VariableContext; //导入依赖的package包/类
@Test
@DecisionResource(resource = DMN)
public void testFeelOutputEntryWithCustomEngine() {
  DefaultDmnEngineConfiguration configuration = (DefaultDmnEngineConfiguration) getDmnEngineConfiguration();
  configuration.setDefaultOutputEntryExpressionLanguage(DefaultDmnEngineConfiguration.FEEL_EXPRESSION_LANGUAGE);
  DmnEngine engine = configuration.buildEngine();

  // stubbing the default FEEL engine behavior
  doReturn("a").when(feelEngineSpy).evaluateSimpleExpression(eq("\"a\""), any(VariableContext.class));

  DmnDecisionResult decisionResult = engine.evaluateDecision(decision, Variables.createVariables().putValue("score", 3));

  assertThat(decisionResult.getSingleEntry()).isEqualTo("a");

  verify(feelEngineSpy).evaluateSimpleExpression(anyString(), any(VariableContext.class));
}
 
开发者ID:camunda,项目名称:camunda-engine-dmn,代码行数:17,代码来源:FeelIntegrationTest.java

示例13: getValue

import org.camunda.bpm.engine.variable.context.VariableContext; //导入依赖的package包/类
@Override
public Object getValue(ELContext context, Object base, Object property) {
  VariableContext variableContext = (VariableContext) context.getContext(VariableContext.class);
  if(variableContext != null) {
    if(VAR_CTX_KEY.equals(property)) {
      context.setPropertyResolved(true);
      return variableContext;
    }
    TypedValue typedValue = variableContext.resolve((String) property);
    if(typedValue != null) {
      context.setPropertyResolved(true);
      return unpack(typedValue);
    }
  }
  return null;
}
 
开发者ID:camunda,项目名称:camunda-bpm-platform,代码行数:17,代码来源:VariableContextElResolver.java

示例14: buildVariableMapFromVariableContext

import org.camunda.bpm.engine.variable.context.VariableContext; //导入依赖的package包/类
protected VariableMap buildVariableMapFromVariableContext(VariableContext variableContext) {

    VariableMap variableMap = Variables.createVariables();

    Set<String> variables = variableContext.keySet();
    for(String variable: variables) {
      variableMap.put(variable, variableContext.resolve(variable));
    }

    return variableMap;
  }
 
开发者ID:camunda,项目名称:camunda-engine-dmn,代码行数:12,代码来源:DefaultDmnDecisionContext.java

示例15: evaluateInput

import org.camunda.bpm.engine.variable.context.VariableContext; //导入依赖的package包/类
protected DmnEvaluatedInput evaluateInput(DmnDecisionTableInputImpl input, VariableContext variableContext) {
  DmnEvaluatedInputImpl evaluatedInput = new DmnEvaluatedInputImpl(input);

  DmnExpressionImpl expression = input.getExpression();
  if (expression != null) {
    Object value = evaluateInputExpression(expression, variableContext);
    TypedValue typedValue = expression.getTypeDefinition().transform(value);
    evaluatedInput.setValue(typedValue);
  }
  else {
    evaluatedInput.setValue(Variables.untypedNullValue());
  }

  return evaluatedInput;
}
 
开发者ID:camunda,项目名称:camunda-engine-dmn,代码行数:16,代码来源:DecisionTableEvaluationHandler.java


注:本文中的org.camunda.bpm.engine.variable.context.VariableContext类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。