org.camunda.bpm.model.dmn.instance.InputExpression Java Examples

The following examples show how to use org.camunda.bpm.model.dmn.instance.InputExpression. 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: DefaultElementTransformHandlerRegistry.java    From camunda-engine-dmn with Apache License 2.0 6 votes vote down vote up
protected static Map<Class<? extends DmnModelElementInstance>, DmnElementTransformHandler> getDefaultElementTransformHandlers() {
  Map<Class<? extends DmnModelElementInstance>, DmnElementTransformHandler> handlers = new HashMap<Class<? extends DmnModelElementInstance>, DmnElementTransformHandler>();

  handlers.put(Definitions.class, new DmnDecisionRequirementsGraphTransformHandler());
  handlers.put(Decision.class, new DmnDecisionTransformHandler());

  handlers.put(DecisionTable.class, new DmnDecisionTableTransformHandler());
  handlers.put(Input.class, new DmnDecisionTableInputTransformHandler());
  handlers.put(InputExpression.class, new DmnDecisionTableInputExpressionTransformHandler());
  handlers.put(Output.class, new DmnDecisionTableOutputTransformHandler());
  handlers.put(Rule.class, new DmnDecisionTableRuleTransformHandler());
  handlers.put(InputEntry.class, new DmnDecisionTableConditionTransformHandler());
  handlers.put(OutputEntry.class, new DmnLiternalExpressionTransformHandler());

  handlers.put(LiteralExpression.class, new DmnLiternalExpressionTransformHandler());
  handlers.put(Variable.class, new DmnVariableTransformHandler());

  return handlers;
}
 
Example #2
Source File: DefaultDmnTransform.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
protected DmnDecisionTableInputImpl transformDecisionTableInput(Input input) {
  DmnElementTransformHandler<Input, DmnDecisionTableInputImpl> handler = handlerRegistry.getHandler(Input.class);
  DmnDecisionTableInputImpl dmnInput = handler.handleElement(this, input);

  // validate input id
  if (dmnInput.getId() == null) {
    throw LOG.decisionTableInputIdIsMissing(decision, dmnInput);
  }

  InputExpression inputExpression = input.getInputExpression();
  if (inputExpression != null) {
    parent = dmnInput;
    DmnExpressionImpl dmnExpression = transformInputExpression(inputExpression);
    if (dmnExpression != null) {
      dmnInput.setExpression(dmnExpression);
    }
  }

  return dmnInput;
}
 
Example #3
Source File: DefaultElementTransformHandlerRegistry.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
protected static Map<Class<? extends DmnModelElementInstance>, DmnElementTransformHandler> getDefaultElementTransformHandlers() {
  Map<Class<? extends DmnModelElementInstance>, DmnElementTransformHandler> handlers = new HashMap<Class<? extends DmnModelElementInstance>, DmnElementTransformHandler>();

  handlers.put(Definitions.class, new DmnDecisionRequirementsGraphTransformHandler());
  handlers.put(Decision.class, new DmnDecisionTransformHandler());

  handlers.put(DecisionTable.class, new DmnDecisionTableTransformHandler());
  handlers.put(Input.class, new DmnDecisionTableInputTransformHandler());
  handlers.put(InputExpression.class, new DmnDecisionTableInputExpressionTransformHandler());
  handlers.put(Output.class, new DmnDecisionTableOutputTransformHandler());
  handlers.put(Rule.class, new DmnDecisionTableRuleTransformHandler());
  handlers.put(InputEntry.class, new DmnDecisionTableConditionTransformHandler());
  handlers.put(OutputEntry.class, new DmnLiternalExpressionTransformHandler());

  handlers.put(LiteralExpression.class, new DmnLiternalExpressionTransformHandler());
  handlers.put(Variable.class, new DmnVariableTransformHandler());

  return handlers;
}
 
Example #4
Source File: DefaultDmnTransform.java    From camunda-engine-dmn with Apache License 2.0 6 votes vote down vote up
protected DmnDecisionTableInputImpl transformDecisionTableInput(Input input) {
  DmnElementTransformHandler<Input, DmnDecisionTableInputImpl> handler = handlerRegistry.getHandler(Input.class);
  DmnDecisionTableInputImpl dmnInput = handler.handleElement(this, input);

  // validate input id
  if (dmnInput.getId() == null) {
    throw LOG.decisionTableInputIdIsMissing(decision, dmnInput);
  }

  InputExpression inputExpression = input.getInputExpression();
  if (inputExpression != null) {
    parent = dmnInput;
    DmnExpressionImpl dmnExpression = transformInputExpression(inputExpression);
    if (dmnExpression != null) {
      dmnInput.setExpression(dmnExpression);
    }
  }

  return dmnInput;
}
 
Example #5
Source File: DecisionDefinitionDeployerTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
protected static DmnModelInstance createDmnModelInstance() {
  DmnModelInstance modelInstance = Dmn.createEmptyModel();
  Definitions definitions = modelInstance.newInstance(Definitions.class);
  definitions.setId(DmnModelConstants.DMN_ELEMENT_DEFINITIONS);
  definitions.setName(DmnModelConstants.DMN_ELEMENT_DEFINITIONS);
  definitions.setNamespace(DmnModelConstants.CAMUNDA_NS);
  modelInstance.setDefinitions(definitions);

  Decision decision = modelInstance.newInstance(Decision.class);
  decision.setId("Decision-1");
  decision.setName("foo");
  decision.setCamundaHistoryTimeToLive(5);
  modelInstance.getDefinitions().addChildElement(decision);

  DecisionTable decisionTable = modelInstance.newInstance(DecisionTable.class);
  decisionTable.setId(DmnModelConstants.DMN_ELEMENT_DECISION_TABLE);
  decisionTable.setHitPolicy(HitPolicy.FIRST);
  decision.addChildElement(decisionTable);

  Input input = modelInstance.newInstance(Input.class);
  input.setId("Input-1");
  input.setLabel("Input");
  decisionTable.addChildElement(input);

  InputExpression inputExpression = modelInstance.newInstance(InputExpression.class);
  inputExpression.setId("InputExpression-1");
  Text inputExpressionText = modelInstance.newInstance(Text.class);
  inputExpressionText.setTextContent("input");
  inputExpression.setText(inputExpressionText);
  inputExpression.setTypeRef("string");
  input.setInputExpression(inputExpression);

  Output output = modelInstance.newInstance(Output.class);
  output.setName("output");
  output.setLabel("Output");
  output.setTypeRef("string");
  decisionTable.addChildElement(output);

  return modelInstance;
}
 
Example #6
Source File: DmnDecisionTableInputExpressionTransformHandler.java    From camunda-engine-dmn with Apache License 2.0 5 votes vote down vote up
protected DmnExpressionImpl createFromInputExpression(DmnElementTransformContext context, InputExpression inputExpression) {
  DmnExpressionImpl dmnExpression = createDmnElement(context, inputExpression);

  dmnExpression.setId(inputExpression.getId());
  dmnExpression.setName(inputExpression.getLabel());
  dmnExpression.setTypeDefinition(createTypeDefinition(context, inputExpression));
  dmnExpression.setExpressionLanguage(getExpressionLanguage(context, inputExpression));
  dmnExpression.setExpression(getExpression(inputExpression));

  return dmnExpression;
}
 
Example #7
Source File: InputClauseImpl.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
public static void registerType(ModelBuilder modelBuilder) {
  ModelElementTypeBuilder typeBuilder = modelBuilder.defineType(InputClause.class, DMN_ELEMENT_INPUT_CLAUSE)
    .namespaceUri(DMN11_NS)
    .extendsType(DmnElement.class)
    .instanceProvider(new ModelTypeInstanceProvider<InputClause>() {
      public InputClause newInstance(ModelTypeInstanceContext instanceContext) {
        return new InputClauseImpl(instanceContext);
      }
    });

  SequenceBuilder sequenceBuilder = typeBuilder.sequence();

  inputExpressionChild = sequenceBuilder.element(InputExpression.class)
    .required()
    .build();

  inputValuesChild = sequenceBuilder.element(InputValues.class)
    .build();

  // camunda extensions

  camundaInputVariableAttribute = typeBuilder.stringAttribute(CAMUNDA_ATTRIBUTE_INPUT_VARIABLE)
    .namespace(CAMUNDA_NS)
    .build();

  typeBuilder.build();
}
 
Example #8
Source File: DmnDecisionTableInputExpressionTransformHandler.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
protected DmnExpressionImpl createFromInputExpression(DmnElementTransformContext context, InputExpression inputExpression) {
  DmnExpressionImpl dmnExpression = createDmnElement(context, inputExpression);

  dmnExpression.setId(inputExpression.getId());
  dmnExpression.setName(inputExpression.getLabel());
  dmnExpression.setTypeDefinition(createTypeDefinition(context, inputExpression));
  dmnExpression.setExpressionLanguage(getExpressionLanguage(context, inputExpression));
  dmnExpression.setExpression(getExpression(inputExpression));

  return dmnExpression;
}
 
Example #9
Source File: InputExpressionImpl.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
public static void registerType(ModelBuilder modelBuilder) {
  ModelElementTypeBuilder typeBuilder = modelBuilder.defineType(InputExpression.class, DMN_ELEMENT_INPUT_EXPRESSION)
    .namespaceUri(DMN11_NS)
    .extendsType(LiteralExpression.class)
    .instanceProvider(new ModelTypeInstanceProvider<InputExpression>() {
      public InputExpression newInstance(ModelTypeInstanceContext instanceContext) {
        return new InputExpressionImpl(instanceContext);
      }
    });

  typeBuilder.build();
}
 
Example #10
Source File: DmnDecisionTableInputExpressionTransformHandler.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
public DmnExpressionImpl handleElement(DmnElementTransformContext context, InputExpression inputExpression) {
  return createFromInputExpression(context, inputExpression);
}
 
Example #11
Source File: ExpressionLanguageTest.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
@Test
public void shouldWriteExpressionLanguage() throws Exception {
  modelInstance = Dmn.createEmptyModel();
  Definitions definitions = generateNamedElement(Definitions.class, "definitions");
  definitions.setNamespace(TEST_NAMESPACE);
  definitions.setExpressionLanguage(EXPRESSION_LANGUAGE);
  modelInstance.setDocumentElement(definitions);

  Decision decision = generateNamedElement(Decision.class, "Check Order");
  definitions.addChildElement(decision);

  DecisionTable decisionTable = generateElement(DecisionTable.class);
  decision.addChildElement(decisionTable);

  Input input = generateElement(Input.class);
  decisionTable.getInputs().add(input);
  InputExpression inputExpression = generateElement(InputExpression.class);
  inputExpression.setExpressionLanguage(EXPRESSION_LANGUAGE);
  input.setInputExpression(inputExpression);
  InputValues inputValues = generateElement(InputValues.class);
  inputValues.setExpressionLanguage(EXPRESSION_LANGUAGE);
  inputValues.setText(generateElement(Text.class));
  input.setInputValues(inputValues);

  Output output = generateElement(Output.class);
  decisionTable.getOutputs().add(output);
  OutputValues outputValues = generateElement(OutputValues.class);
  outputValues.setExpressionLanguage(EXPRESSION_LANGUAGE);
  outputValues.setText(generateElement(Text.class));
  output.setOutputValues(outputValues);

  Rule rule = generateElement(Rule.class);
  decisionTable.getRules().add(rule);
  InputEntry inputEntry = generateElement(InputEntry.class);
  inputEntry.setExpressionLanguage(EXPRESSION_LANGUAGE);
  inputEntry.setText(generateElement(Text.class));
  rule.getInputEntries().add(inputEntry);
  OutputEntry outputEntry = generateElement(OutputEntry.class);
  outputEntry.setExpressionLanguage(EXPRESSION_LANGUAGE);
  rule.getOutputEntries().add(outputEntry);

  assertModelEqualsFile(EXPRESSION_LANGUAGE_DMN);
}
 
Example #12
Source File: InputClauseImpl.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
public void setInputExpression(InputExpression inputExpression) {
  inputExpressionChild.setChild(this, inputExpression);
}
 
Example #13
Source File: InputClauseImpl.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
public InputExpression getInputExpression() {
  return inputExpressionChild.getChild(this);
}
 
Example #14
Source File: DmnDecisionTableInputExpressionTransformHandler.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
protected DmnExpressionImpl createDmnElement(DmnElementTransformContext context, InputExpression inputExpression) {
  return new DmnExpressionImpl();
}
 
Example #15
Source File: DefaultDmnTransform.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
protected DmnExpressionImpl transformInputExpression(InputExpression inputExpression) {
  DmnElementTransformHandler<InputExpression, DmnExpressionImpl> handler = handlerRegistry.getHandler(InputExpression.class);
  return handler.handleElement(this, inputExpression);
}
 
Example #16
Source File: DmnDecisionTableInputExpressionTransformHandler.java    From camunda-engine-dmn with Apache License 2.0 4 votes vote down vote up
protected DmnExpressionImpl createDmnElement(DmnElementTransformContext context, InputExpression inputExpression) {
  return new DmnExpressionImpl();
}
 
Example #17
Source File: DmnDecisionTableInputExpressionTransformHandler.java    From camunda-engine-dmn with Apache License 2.0 4 votes vote down vote up
public DmnExpressionImpl handleElement(DmnElementTransformContext context, InputExpression inputExpression) {
  return createFromInputExpression(context, inputExpression);
}
 
Example #18
Source File: DefaultDmnTransform.java    From camunda-engine-dmn with Apache License 2.0 4 votes vote down vote up
protected DmnExpressionImpl transformInputExpression(InputExpression inputExpression) {
  DmnElementTransformHandler<InputExpression, DmnExpressionImpl> handler = handlerRegistry.getHandler(InputExpression.class);
  return handler.handleElement(this, inputExpression);
}