Java Code Examples for org.camunda.bpm.model.dmn.DmnModelInstance#newInstance()

The following examples show how to use org.camunda.bpm.model.dmn.DmnModelInstance#newInstance() . 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: 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 2
Source File: DecisionDefinitionDeployerTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Test
public void testDeployEmptyDecisionDefinition() throws Exception {

  // given empty decision model
  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);

  // when decision model is deployed
  DeploymentBuilder deploymentBuilder = repositoryService.createDeployment().addModelInstance("foo.dmn", modelInstance);
  DeploymentWithDefinitions deployment = testRule.deploy(deploymentBuilder);

  // then deployment contains no definitions
  assertNull(deployment.getDeployedDecisionDefinitions());
  assertNull(deployment.getDeployedDecisionRequirementsDefinitions());

  // and there are no persisted definitions
  assertNull(repositoryService.createDecisionDefinitionQuery()
    .decisionDefinitionResourceName("foo.dmn").singleResult());
}
 
Example 3
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 4
Source File: DmnHelper.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
public static <E extends DmnElement> E generateElement(final Class<E> elementClass,
                                                       final DmnModelInstance modelInstance) {
  E element = modelInstance.newInstance(elementClass);
  String identifier = elementClass.getSimpleName();
  identifier = Character.toLowerCase(identifier.charAt(0)) + identifier.substring(1);
  element.setId(identifier);
  return element;
}
 
Example 5
Source File: XlsxWorksheetConverter.java    From camunda-dmn-xlsx with Apache License 2.0 4 votes vote down vote up
public <E extends DmnElement> E generateElement(DmnModelInstance modelInstance, Class<E> elementClass, String id) {
  E element = modelInstance.newInstance(elementClass);
  element.setId(id);
  return element;
}
 
Example 6
Source File: XlsxWorksheetConverter.java    From camunda-dmn-xlsx with Apache License 2.0 4 votes vote down vote up
protected Text generateText(DmnModelInstance dmnModel, String content) {
  Text text = dmnModel.newInstance(Text.class);
  text.setTextContent(content);
  return text;
}
 
Example 7
Source File: XlsxWorksheetConverter.java    From camunda-dmn-xlsx with Apache License 2.0 4 votes vote down vote up
protected  Description generateDescription(DmnModelInstance dmnModel, String content) {
    Description description =  dmnModel.newInstance(Description.class);
    description.setTextContent(content);
    return description;
}