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

The following examples show how to use org.camunda.bpm.model.dmn.instance.OutputEntry. 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: 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 #3
Source File: DecisionRuleImpl.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
public static void registerType(ModelBuilder modelBuilder) {
  ModelElementTypeBuilder typeBuilder = modelBuilder.defineType(DecisionRule.class, DMN_ELEMENT_DECISION_RULE)
    .namespaceUri(DMN11_NS)
    .extendsType(DmnElement.class)
    .instanceProvider(new ModelTypeInstanceProvider<DecisionRule>() {
      public DecisionRule newInstance(ModelTypeInstanceContext instanceContext) {
        return new DecisionRuleImpl(instanceContext);
      }
    });

  SequenceBuilder sequenceBuilder = typeBuilder.sequence();

  inputEntryCollection = sequenceBuilder.elementCollection(InputEntry.class)
    .build();

  outputEntryCollection = sequenceBuilder.elementCollection(OutputEntry.class)
    .required()
    .build();

  typeBuilder.build();
}
 
Example #4
Source File: ExpressionLanguageTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Test
@DmnModelResource(resource = EXPRESSION_LANGUAGE_DMN)
public void shouldReadExpressionLanguage() {
  Definitions definitions = modelInstance.getDefinitions();
  assertThat(definitions.getExpressionLanguage()).isEqualTo(EXPRESSION_LANGUAGE);

  DecisionTable decisionTable = modelInstance.getModelElementById("decisionTable");
  Input input = decisionTable.getInputs().iterator().next();
  assertThat(input.getInputExpression().getExpressionLanguage()).isEqualTo(EXPRESSION_LANGUAGE);
  assertThat(input.getInputValues().getExpressionLanguage()).isEqualTo(EXPRESSION_LANGUAGE);
  Output output = decisionTable.getOutputs().iterator().next();
  assertThat(output.getOutputValues().getExpressionLanguage()).isEqualTo(EXPRESSION_LANGUAGE);

  Rule rule = decisionTable.getRules().iterator().next();
  InputEntry inputEntry = rule.getInputEntries().iterator().next();
  assertThat(inputEntry.getExpressionLanguage()).isEqualTo(EXPRESSION_LANGUAGE);
  OutputEntry outputEntry = rule.getOutputEntries().iterator().next();
  assertThat(outputEntry.getExpressionLanguage()).isEqualTo(EXPRESSION_LANGUAGE);
}
 
Example #5
Source File: DefaultDmnTransform.java    From camunda-engine-dmn with Apache License 2.0 5 votes vote down vote up
protected DmnDecisionTableRuleImpl transformDecisionTableRule(Rule rule) {
  DmnElementTransformHandler<Rule, DmnDecisionTableRuleImpl> handler = handlerRegistry.getHandler(Rule.class);
  DmnDecisionTableRuleImpl dmnRule = handler.handleElement(this, rule);

  // validate rule id
  if (dmnRule.getId() == null) {
    throw LOG.decisionTableRuleIdIsMissing(decision, dmnRule);
  }

  List<DmnDecisionTableInputImpl> inputs = this.decisionTable.getInputs();
  List<InputEntry> inputEntries = new ArrayList<InputEntry>(rule.getInputEntries());
  if (inputs.size() != inputEntries.size()) {
    throw LOG.differentNumberOfInputsAndInputEntries(inputs.size(), inputEntries.size(), dmnRule);
  }

  for (InputEntry inputEntry : inputEntries) {
    parent = dmnRule;

    DmnExpressionImpl condition = transformInputEntry(inputEntry);
    dmnRule.getConditions().add(condition);
  }

  List<DmnDecisionTableOutputImpl> outputs = this.decisionTable.getOutputs();
  List<OutputEntry> outputEntries = new ArrayList<OutputEntry>(rule.getOutputEntries());
  if (outputs.size() != outputEntries.size()) {
    throw LOG.differentNumberOfOutputsAndOutputEntries(outputs.size(), outputEntries.size(), dmnRule);
  }

  for (OutputEntry outputEntry : outputEntries) {
    parent = dmnRule;
    DmnExpressionImpl conclusion = transformOutputEntry(outputEntry);
    dmnRule.getConclusions().add(conclusion);
  }

  return dmnRule;
}
 
Example #6
Source File: DefaultDmnTransform.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
protected DmnDecisionTableRuleImpl transformDecisionTableRule(Rule rule) {
  DmnElementTransformHandler<Rule, DmnDecisionTableRuleImpl> handler = handlerRegistry.getHandler(Rule.class);
  DmnDecisionTableRuleImpl dmnRule = handler.handleElement(this, rule);

  // validate rule id
  if (dmnRule.getId() == null) {
    throw LOG.decisionTableRuleIdIsMissing(decision, dmnRule);
  }

  List<DmnDecisionTableInputImpl> inputs = this.decisionTable.getInputs();
  List<InputEntry> inputEntries = new ArrayList<InputEntry>(rule.getInputEntries());
  if (inputs.size() != inputEntries.size()) {
    throw LOG.differentNumberOfInputsAndInputEntries(inputs.size(), inputEntries.size(), dmnRule);
  }

  for (InputEntry inputEntry : inputEntries) {
    parent = dmnRule;

    DmnExpressionImpl condition = transformInputEntry(inputEntry);
    dmnRule.getConditions().add(condition);
  }

  List<DmnDecisionTableOutputImpl> outputs = this.decisionTable.getOutputs();
  List<OutputEntry> outputEntries = new ArrayList<OutputEntry>(rule.getOutputEntries());
  if (outputs.size() != outputEntries.size()) {
    throw LOG.differentNumberOfOutputsAndOutputEntries(outputs.size(), outputEntries.size(), dmnRule);
  }

  for (OutputEntry outputEntry : outputEntries) {
    parent = dmnRule;
    DmnExpressionImpl conclusion = transformOutputEntry(outputEntry);
    dmnRule.getConclusions().add(conclusion);
  }

  return dmnRule;
}
 
Example #7
Source File: OutputEntryImpl.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(OutputEntry.class, DMN_ELEMENT_OUTPUT_ENTRY)
    .namespaceUri(DMN11_NS)
    .extendsType(LiteralExpression.class)
    .instanceProvider(new ModelTypeInstanceProvider<OutputEntry>() {
      public OutputEntry newInstance(ModelTypeInstanceContext instanceContext) {
        return new OutputEntryImpl(instanceContext);
      }
    });

  typeBuilder.build();
}
 
Example #8
Source File: DefaultDmnTransform.java    From camunda-engine-dmn with Apache License 2.0 4 votes vote down vote up
protected DmnExpressionImpl transformOutputEntry(OutputEntry outputEntry) {
  DmnElementTransformHandler<OutputEntry, DmnExpressionImpl> handler = handlerRegistry.getHandler(OutputEntry.class);
  return handler.handleElement(this, outputEntry);
}
 
Example #9
Source File: DefaultDmnTransform.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
protected DmnExpressionImpl transformOutputEntry(OutputEntry outputEntry) {
  DmnElementTransformHandler<OutputEntry, DmnExpressionImpl> handler = handlerRegistry.getHandler(OutputEntry.class);
  return handler.handleElement(this, outputEntry);
}
 
Example #10
Source File: DecisionRuleImpl.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
public Collection<OutputEntry> getOutputEntries() {
  return outputEntryCollection.get(this);
}
 
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);
}