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

The following examples show how to use org.camunda.bpm.model.dmn.instance.Decision. 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: DefaultDmnTransform.java    From camunda-engine-dmn with Apache License 2.0 6 votes vote down vote up
protected DmnDecisionRequirementsGraph transformDefinitions(Definitions definitions) {
  DmnElementTransformHandler<Definitions, DmnDecisionRequirementsGraphImpl> handler = handlerRegistry.getHandler(Definitions.class);
  DmnDecisionRequirementsGraphImpl dmnDrg = handler.handleElement(this, definitions);

  // validate id of drd
  if (dmnDrg.getKey() == null) {
    throw LOG.drdIdIsMissing(dmnDrg);
  }

  Collection<Decision> decisions = definitions.getChildElementsByType(Decision.class);
  List<DmnDecision> dmnDecisions = transformDecisions(decisions);
  for (DmnDecision dmnDecision : dmnDecisions) {
    dmnDrg.addDecision(dmnDecision);
  }

  notifyTransformListeners(definitions, dmnDrg);
  return dmnDrg;
}
 
Example #2
Source File: DefaultDmnTransform.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
protected DmnDecisionLiteralExpressionImpl transformDecisionLiteralExpression(Decision decision, LiteralExpression literalExpression) {
  DmnDecisionLiteralExpressionImpl dmnDecisionLiteralExpression = new DmnDecisionLiteralExpressionImpl();

  Variable variable = decision.getVariable();
  if (variable == null) {
    throw LOG.decisionVariableIsMissing(decision.getId());
  }

  DmnVariableImpl dmnVariable = transformVariable(variable);
  dmnDecisionLiteralExpression.setVariable(dmnVariable);

  DmnExpressionImpl dmnLiteralExpression = transformLiteralExpression(literalExpression);
  dmnDecisionLiteralExpression.setExpression(dmnLiteralExpression);

  return dmnDecisionLiteralExpression;
}
 
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: DmnTransformListenerTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Test
public void shouldVerifyTransformedDmnDecision() {
  InputStream inputStream =  IoUtil.fileAsStream(DECISION_TRANSFORM_DMN);
  DmnModelInstance modelInstance = Dmn.readModelFromStream(inputStream);
  dmnEngine.parseDecisionRequirementsGraph(modelInstance);
  
  DmnDecision dmnDecision = listener.getDmnDecision();
  Decision decision = listener.getDecision();

  assertThat(dmnDecision.getKey())
    .isEqualTo(decision.getId())
    .isEqualTo("decision1");
  
  assertThat(dmnDecision.getName())
    .isEqualTo(decision.getName())
    .isEqualTo("camunda");    
}
 
Example #5
Source File: OrganizationUnitImpl.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(OrganizationUnit.class, DMN_ELEMENT_ORGANIZATION_UNIT)
    .namespaceUri(DMN11_NS)
    .extendsType(BusinessContextElement.class)
    .instanceProvider(new ModelTypeInstanceProvider<OrganizationUnit>() {
      public OrganizationUnit newInstance(ModelTypeInstanceContext instanceContext) {
        return new OrganizationUnitImpl(instanceContext);
      }
    });

  SequenceBuilder sequenceBuilder = typeBuilder.sequence();

  decisionDecisionMadeRefCollection = sequenceBuilder.elementCollection(DecisionMadeReference.class)
    .uriElementReferenceCollection(Decision.class)
    .build();

  decisionDecisionOwnedRefCollection = sequenceBuilder.elementCollection(DecisionOwnedReference.class)
    .uriElementReferenceCollection(Decision.class)
    .build();

  typeBuilder.build();
}
 
Example #6
Source File: DefaultDmnTransform.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
protected DmnDecisionRequirementsGraph transformDefinitions(Definitions definitions) {
  DmnElementTransformHandler<Definitions, DmnDecisionRequirementsGraphImpl> handler = handlerRegistry.getHandler(Definitions.class);
  DmnDecisionRequirementsGraphImpl dmnDrg = handler.handleElement(this, definitions);

  // validate id of drd
  if (dmnDrg.getKey() == null) {
    throw LOG.drdIdIsMissing(dmnDrg);
  }

  Collection<Decision> decisions = definitions.getChildElementsByType(Decision.class);
  List<DmnDecision> dmnDecisions = transformDecisions(decisions);
  for (DmnDecision dmnDecision : dmnDecisions) {
    dmnDrg.addDecision(dmnDecision);
  }

  notifyTransformListeners(definitions, dmnDrg);
  return dmnDrg;
}
 
Example #7
Source File: AuthorityRequirementImpl.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(AuthorityRequirement.class, DMN_ELEMENT_AUTHORITY_REQUIREMENT)
    .namespaceUri(DMN11_NS)
    .instanceProvider(new ModelTypeInstanceProvider<AuthorityRequirement>() {
      public AuthorityRequirement newInstance(ModelTypeInstanceContext instanceContext) {
        return new AuthorityRequirementImpl(instanceContext);
      }
    });

  SequenceBuilder sequenceBuilder = typeBuilder.sequence();

  requiredDecisionRef = sequenceBuilder.element(RequiredDecisionReference.class)
    .uriElementReference(Decision.class)
    .build();

  requiredInputRef = sequenceBuilder.element(RequiredInputReference.class)
    .uriElementReference(InputData.class)
    .build();

  requiredAuthorityRef = sequenceBuilder.element(RequiredAuthorityReference.class)
    .uriElementReference(KnowledgeSource.class)
    .build();

  typeBuilder.build();
}
 
Example #8
Source File: XlsxWorksheetConverter.java    From camunda-dmn-xlsx with Apache License 2.0 6 votes vote down vote up
public DmnModelInstance convert() {

    DmnModelInstance dmnModel = initializeEmptyDmnModel();

    Decision decision = generateElement(dmnModel, Decision.class, worksheetContext.getName());
    decision.setName(spreadsheetAdapter.determineDecisionName(worksheetContext));
    dmnModel.getDefinitions().addChildElement(decision);

    DecisionTable decisionTable = generateElement(dmnModel, DecisionTable.class, "decisionTable");
    decision.addChildElement(decisionTable);

    setHitPolicy(decisionTable);
    convertInputsOutputs(dmnModel, decisionTable);
    convertRules(dmnModel, decisionTable, spreadsheetAdapter.determineRuleRows(worksheetContext));

    return dmnModel;
  }
 
Example #9
Source File: PerformanceIndicatorImpl.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(PerformanceIndicator.class, DMN_ELEMENT_PERFORMANCE_INDICATOR)
    .namespaceUri(DMN11_NS)
    .extendsType(BusinessContextElement.class)
    .instanceProvider(new ModelTypeInstanceProvider<PerformanceIndicator>() {
      public PerformanceIndicator newInstance(ModelTypeInstanceContext instanceContext) {
        return new PerformanceIndicatorImpl(instanceContext);
      }
    });

  SequenceBuilder sequenceBuilder = typeBuilder.sequence();

  impactingDecisionRefCollection = sequenceBuilder.elementCollection(ImpactingDecisionReference.class)
    .uriElementReferenceCollection(Decision.class)
    .build();

  typeBuilder.build();
}
 
Example #10
Source File: DmnTransformListenerTest.java    From camunda-engine-dmn with Apache License 2.0 6 votes vote down vote up
@Test
public void shouldVerifyTransformedDmnDecision() {
  InputStream inputStream =  IoUtil.fileAsStream(DECISION_TRANSFORM_DMN);
  DmnModelInstance modelInstance = Dmn.readModelFromStream(inputStream);
  dmnEngine.parseDecisionRequirementsGraph(modelInstance);
  
  DmnDecision dmnDecision = listener.getDmnDecision();
  Decision decision = listener.getDecision();

  assertThat(dmnDecision.getKey())
    .isEqualTo(decision.getId())
    .isEqualTo("decision1");
  
  assertThat(dmnDecision.getName())
    .isEqualTo(decision.getName())
    .isEqualTo("camunda");    
}
 
Example #11
Source File: InformationRequirementImpl.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(InformationRequirement.class, DMN_ELEMENT_INFORMATION_REQUIREMENT)
    .namespaceUri(DMN11_NS)
    .instanceProvider(new ModelTypeInstanceProvider<InformationRequirement>() {
      public InformationRequirement newInstance(ModelTypeInstanceContext instanceContext) {
        return new InformationRequirementImpl(instanceContext);
      }
    });

  SequenceBuilder sequenceBuilder = typeBuilder.sequence();

  requiredDecisionRef = sequenceBuilder.element(RequiredDecisionReference.class)
    .uriElementReference(Decision.class)
    .build();

  requiredInputRef = sequenceBuilder.element(RequiredInputReference.class)
    .uriElementReference(InputData.class)
    .build();

  typeBuilder.build();
}
 
Example #12
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 #13
Source File: DefaultDmnTransform.java    From camunda-engine-dmn with Apache License 2.0 6 votes vote down vote up
protected DmnDecisionLiteralExpressionImpl transformDecisionLiteralExpression(Decision decision, LiteralExpression literalExpression) {
  DmnDecisionLiteralExpressionImpl dmnDecisionLiteralExpression = new DmnDecisionLiteralExpressionImpl();

  Variable variable = decision.getVariable();
  if (variable == null) {
    throw LOG.decisionVariableIsMissing(decision.getId());
  }

  DmnVariableImpl dmnVariable = transformVariable(variable);
  dmnDecisionLiteralExpression.setVariable(dmnVariable);

  DmnExpressionImpl dmnLiteralExpression = transformLiteralExpression(literalExpression);
  dmnDecisionLiteralExpression.setExpression(dmnLiteralExpression);

  return dmnDecisionLiteralExpression;
}
 
Example #14
Source File: DmnHelper.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
public static DmnModelInstance createSimpleDmnModel(final String decisionKey) {
  final DmnModelInstance modelInstance = Dmn.createEmptyModel();

  final Definitions definitions = generateNamedElement(Definitions.class, "definitions", modelInstance);
  definitions.setNamespace(TEST_NAMESPACE);

  modelInstance.setDefinitions(definitions);

  Decision decision = generateNamedElement(Decision.class, "decision1", modelInstance);
  decision.setId(decisionKey);
  DecisionTable decisionTable = generateElement(DecisionTable.class, modelInstance);
  decision.setExpression(decisionTable);
  Output output = generateElement(Output.class, modelInstance);
  decisionTable.getOutputs().add(output);
  definitions.addChildElement(decision);
  return modelInstance;
}
 
Example #15
Source File: DmnModelElementInstanceCmdTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Deployment(resources = "org/camunda/bpm/engine/test/repository/one.dmn")
public void testRepositoryService() {
  String decisionDefinitionId = repositoryService
    .createDecisionDefinitionQuery()
    .decisionDefinitionKey(DECISION_KEY)
    .singleResult()
    .getId();

  DmnModelInstance modelInstance = repositoryService.getDmnModelInstance(decisionDefinitionId);
  assertNotNull(modelInstance);

  Collection<Decision> decisions = modelInstance.getModelElementsByType(Decision.class);
  assertEquals(1, decisions.size());

  Collection<DecisionTable> decisionTables = modelInstance.getModelElementsByType(DecisionTable.class);
  assertEquals(1, decisionTables.size());

  Collection<Input> inputs = modelInstance.getModelElementsByType(Input.class);
  assertEquals(1, inputs.size());

  Collection<Output> outputs = modelInstance.getModelElementsByType(Output.class);
  assertEquals(1, outputs.size());

  Collection<Rule> rules = modelInstance.getModelElementsByType(Rule.class);
  assertEquals(2, rules.size());
}
 
Example #16
Source File: DecisionDefinitionDeployerTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
protected static DmnModelInstance createDmnModelInstanceNegativeHistoryTimeToLive() {
  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);

  return modelInstance;
}
 
Example #17
Source File: DefaultDmnTransform.java    From camunda-engine-dmn with Apache License 2.0 5 votes vote down vote up
protected List<DmnDecision> getRequiredDmnDecisions(Decision decision, Map<String, DmnDecisionImpl> dmnDecisions) {
  List<DmnDecision> requiredDecisionList = new ArrayList<DmnDecision>();
  for(InformationRequirement informationRequirement: decision.getInformationRequirements()) {

    Decision requiredDecision = informationRequirement.getRequiredDecision();
    if(requiredDecision != null) {
      DmnDecision requiredDmnDecision = dmnDecisions.get(requiredDecision.getId());
      requiredDecisionList.add(requiredDmnDecision);
    }
  }
  return requiredDecisionList;
}
 
Example #18
Source File: DmnDecisionTransformHandler.java    From camunda-engine-dmn with Apache License 2.0 5 votes vote down vote up
protected DmnDecisionImpl createFromDecision(DmnElementTransformContext context, Decision decision) {
  DmnDecisionImpl decisionEntity = createDmnElement();

  decisionEntity.setKey(decision.getId());
  decisionEntity.setName(decision.getName());
  return decisionEntity;
}
 
Example #19
Source File: DefaultDmnTransform.java    From camunda-engine-dmn with Apache License 2.0 5 votes vote down vote up
protected DmnDecisionImpl transformDecision(Decision decision) {

    DmnElementTransformHandler<Decision, DmnDecisionImpl> handler = handlerRegistry.getHandler(Decision.class);
    DmnDecisionImpl dmnDecision = handler.handleElement(this, decision);
    this.decision = dmnDecision;
    // validate decision id
    if (dmnDecision.getKey() == null) {
      throw LOG.decisionIdIsMissing(dmnDecision);
    }

    Expression expression = decision.getExpression();
    if (expression == null) {
      LOG.decisionWithoutExpression(decision);
      return null;
    }

    if (expression instanceof DecisionTable) {
      DmnDecisionTableImpl dmnDecisionTable = transformDecisionTable((DecisionTable) expression);
      dmnDecision.setDecisionLogic(dmnDecisionTable);

    } else if (expression instanceof LiteralExpression) {
      DmnDecisionLiteralExpressionImpl dmnDecisionLiteralExpression = transformDecisionLiteralExpression(decision, (LiteralExpression) expression);
      dmnDecision.setDecisionLogic(dmnDecisionLiteralExpression);

    } else {
      LOG.decisionTypeNotSupported(expression, decision);
      return null;
    }

    return dmnDecision;
  }
 
Example #20
Source File: TestHelper.java    From camunda-dmn-xlsx with Apache License 2.0 5 votes vote down vote up
public static DecisionTable assertAndGetSingleDecisionTable(DmnModelInstance dmnModel) {
  assertThat(dmnModel.getDefinitions()).isNotNull();
  Collection<Decision> decisions = dmnModel.getDefinitions().getChildElementsByType(Decision.class);
  assertThat(decisions).hasSize(1);

  Decision decision = decisions.iterator().next();
  assertThat(decision).isNotNull();

  Collection<DecisionTable> decisionTables = decision.getChildElementsByType(DecisionTable.class);
  assertThat(decisionTables).hasSize(1);

  return decisionTables.iterator().next();
}
 
Example #21
Source File: DefaultDmnTransform.java    From camunda-engine-dmn with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
public <T extends DmnDecision> List<T> transformDecisions() {
  try {
    Definitions definitions = modelInstance.getDefinitions();
    Collection<Decision> decisions = definitions.getChildElementsByType(Decision.class);
    return (List<T>) transformDecisions(decisions);
  }
  catch (Exception e) {
    throw LOG.errorWhileTransformingDecisions(e);
  }
}
 
Example #22
Source File: DmnDecisionTransformHandler.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
protected DmnDecisionImpl createFromDecision(DmnElementTransformContext context, Decision decision) {
  DmnDecisionImpl decisionEntity = createDmnElement();

  decisionEntity.setKey(decision.getId());
  decisionEntity.setName(decision.getName());
  return decisionEntity;
}
 
Example #23
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 #24
Source File: DecisionDefinitionHandler.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Override
protected DmnDecisionImpl createFromDecision(DmnElementTransformContext context, Decision decision) {
  DecisionDefinitionEntity decisionDefinition = (DecisionDefinitionEntity) super.createFromDecision(context, decision);

  String category = context.getModelInstance().getDefinitions().getNamespace();
  decisionDefinition.setCategory(category);
  decisionDefinition.setHistoryTimeToLive(ParseUtil.parseHistoryTimeToLive(decision.getCamundaHistoryTimeToLiveString()));
  decisionDefinition.setVersionTag(decision.getVersionTag());

  return decisionDefinition;
}
 
Example #25
Source File: DmnEngineConfigurationBuilder.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
/**
 * Modify the given DMN engine configuration and return it.
 */
public DefaultDmnEngineConfiguration build() {

  List<DmnDecisionEvaluationListener> decisionEvaluationListeners = createCustomPostDecisionEvaluationListeners();
  dmnEngineConfiguration.setCustomPostDecisionEvaluationListeners(decisionEvaluationListeners);

  // override the decision table handler
  DmnTransformer dmnTransformer = dmnEngineConfiguration.getTransformer();
  dmnTransformer.getElementTransformHandlerRegistry().addHandler(Definitions.class, new DecisionRequirementsDefinitionTransformHandler());
  dmnTransformer.getElementTransformHandlerRegistry().addHandler(Decision.class, new DecisionDefinitionHandler());

  // do not override the script engine resolver if set
  if (dmnEngineConfiguration.getScriptEngineResolver() == null) {
    ensureNotNull("scriptEngineResolver", scriptEngineResolver);

    dmnEngineConfiguration.setScriptEngineResolver(scriptEngineResolver);
  }

  // do not override the el provider if set
  if (dmnEngineConfiguration.getElProvider() == null) {
    ensureNotNull("expressionManager", expressionManager);

    ProcessEngineElProvider elProvider = new ProcessEngineElProvider(expressionManager);
    dmnEngineConfiguration.setElProvider(elProvider);
  }

  if (dmnEngineConfiguration.getFeelCustomFunctionProviders() == null) {
    dmnEngineConfiguration.setFeelCustomFunctionProviders(feelCustomFunctionProviders);
  }

  return dmnEngineConfiguration;
}
 
Example #26
Source File: DecisionServiceImpl.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(DecisionService.class, DMN_ELEMENT_DECISION_SERVICE)
    .namespaceUri(DMN11_NS)
    .extendsType(NamedElement.class)
    .instanceProvider(new ModelTypeInstanceProvider<DecisionService>() {
      public DecisionService newInstance(ModelTypeInstanceContext instanceContext) {
        return new DecisionServiceImpl(instanceContext);
      }
    });

  SequenceBuilder sequenceBuilder = typeBuilder.sequence();

  outputDecisionRefCollection = sequenceBuilder.elementCollection(OutputDecisionReference.class)
    .required()
    .uriElementReferenceCollection(Decision.class)
    .build();

  encapsulatedDecisionRefCollection = sequenceBuilder.elementCollection(EncapsulatedDecisionReference.class)
    .uriElementReferenceCollection(Decision.class)
    .build();

  inputDecisionRefCollection = sequenceBuilder.elementCollection(InputDecisionReference.class)
    .uriElementReferenceCollection(Decision.class)
    .build();

  inputDataRefCollection = sequenceBuilder.elementCollection(InputDataReference.class)
    .uriElementReferenceCollection(InputData.class)
    .build();

  typeBuilder.build();
}
 
Example #27
Source File: GenerateIdTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Test
public void shouldGenerateIdsOnCreate() {
  DmnModelInstance modelInstance = Dmn.createEmptyModel();
  Definitions definitions = modelInstance.newInstance(Definitions.class);
  assertThat(definitions.getId()).isNotNull();

  Decision decision = modelInstance.newInstance(Decision.class);
  assertThat(decision.getId()).isNotNull();

  DecisionTable decisionTable = modelInstance.newInstance(DecisionTable.class);
  assertThat(decisionTable.getId()).isNotNull();

  Output output = modelInstance.newInstance(Output.class);
  assertThat(output.getId()).isNotNull();
}
 
Example #28
Source File: GenerateIdTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Test
public void shouldNotGenerateIdsOnRead() {
  DmnModelInstance modelInstance = Dmn.readModelFromStream(GenerateIdTest.class.getResourceAsStream("GenerateIdTest.dmn"));
  Definitions definitions = modelInstance.getDefinitions();
  assertThat(definitions.getId()).isNull();

  Decision decision = modelInstance.getModelElementsByType(Decision.class).iterator().next();
  assertThat(decision.getId()).isNull();

  DecisionTable decisionTable = modelInstance.getModelElementsByType(DecisionTable.class).iterator().next();
  assertThat(decisionTable.getId()).isNull();

  Output output = modelInstance.getModelElementsByType(Output.class).iterator().next();
  assertThat(output.getId()).isNull();
}
 
Example #29
Source File: CamundaExtensionsTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Test
public void testCamundaHistoryTimeToLive() {
  Decision decision = modelInstance.getModelElementById("decision");
  assertThat(decision.getCamundaHistoryTimeToLive()).isEqualTo(5);
  decision.setCamundaHistoryTimeToLive(6);
  assertThat(decision.getCamundaHistoryTimeToLive()).isEqualTo(6);
}
 
Example #30
Source File: CamundaExtensionsTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Test
public void testCamundaVersionTag() {
  Decision decision = modelInstance.getModelElementById("decision");
  assertThat(decision.getVersionTag()).isEqualTo("1.0.0");
  decision.setVersionTag("1.1.0");
  assertThat(decision.getVersionTag()).isEqualTo("1.1.0");
}