Search in sources :

Example 6 with DmnModelInstance

use of org.camunda.bpm.model.dmn.DmnModelInstance in project camunda-bpm-platform by camunda.

the class GetDeploymentDmnModelInstanceCmd method execute.

public DmnModelInstance execute(CommandContext commandContext) {
    ensureNotNull("decisionDefinitionId", decisionDefinitionId);
    DeploymentCache deploymentCache = Context.getProcessEngineConfiguration().getDeploymentCache();
    DecisionDefinitionEntity decisionDefinition = deploymentCache.findDeployedDecisionDefinitionById(decisionDefinitionId);
    for (CommandChecker checker : commandContext.getProcessEngineConfiguration().getCommandCheckers()) {
        checker.checkReadDecisionDefinition(decisionDefinition);
    }
    DmnModelInstance modelInstance = deploymentCache.findDmnModelInstanceForDecisionDefinition(decisionDefinitionId);
    ensureNotNull(DmnModelInstanceNotFoundException.class, "No DMN model instance found for decision definition id " + decisionDefinitionId, "modelInstance", modelInstance);
    return modelInstance;
}
Also used : DeploymentCache(org.camunda.bpm.engine.impl.persistence.deploy.cache.DeploymentCache) CommandChecker(org.camunda.bpm.engine.impl.cfg.CommandChecker) DecisionDefinitionEntity(org.camunda.bpm.engine.impl.dmn.entity.repository.DecisionDefinitionEntity) DmnModelInstance(org.camunda.bpm.model.dmn.DmnModelInstance)

Example 7 with DmnModelInstance

use of org.camunda.bpm.model.dmn.DmnModelInstance in project camunda-bpm-platform by camunda.

the class DecisionDefinitionAuthorizationTest method testGetDmnModelInstance.

public void testGetDmnModelInstance() {
    // given
    String decisionDefinitionId = selectDecisionDefinitionByKey(DECISION_DEFINITION_KEY).getId();
    createGrantAuthorization(DECISION_DEFINITION, DECISION_DEFINITION_KEY, userId, READ);
    // when
    DmnModelInstance modelInstance = repositoryService.getDmnModelInstance(decisionDefinitionId);
    // then
    assertNotNull(modelInstance);
}
Also used : DmnModelInstance(org.camunda.bpm.model.dmn.DmnModelInstance)

Example 8 with DmnModelInstance

use of org.camunda.bpm.model.dmn.DmnModelInstance in project camunda-bpm-platform by camunda.

the class DecisionDefinitionDeployerTest method createDmnModelInstanceNegativeHistoryTimeToLive.

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;
}
Also used : Definitions(org.camunda.bpm.model.dmn.instance.Definitions) Decision(org.camunda.bpm.model.dmn.instance.Decision) DmnModelInstance(org.camunda.bpm.model.dmn.DmnModelInstance)

Example 9 with DmnModelInstance

use of org.camunda.bpm.model.dmn.DmnModelInstance in project camunda-bpm-platform by camunda.

the class DecisionDefinitionDeployerTest method createDmnModelInstance.

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;
}
Also used : DecisionTable(org.camunda.bpm.model.dmn.instance.DecisionTable) Input(org.camunda.bpm.model.dmn.instance.Input) Definitions(org.camunda.bpm.model.dmn.instance.Definitions) Output(org.camunda.bpm.model.dmn.instance.Output) Text(org.camunda.bpm.model.dmn.instance.Text) InputExpression(org.camunda.bpm.model.dmn.instance.InputExpression) Decision(org.camunda.bpm.model.dmn.instance.Decision) DmnModelInstance(org.camunda.bpm.model.dmn.DmnModelInstance)

Example 10 with DmnModelInstance

use of org.camunda.bpm.model.dmn.DmnModelInstance in project camunda-bpm-platform by camunda.

the class DecisionDefinitionDeployerTest method testDeployDmnModelInstanceNegativeHistoryTimeToLive.

@Test
public void testDeployDmnModelInstanceNegativeHistoryTimeToLive() throws Exception {
    // given
    DmnModelInstance dmnModelInstance = createDmnModelInstanceNegativeHistoryTimeToLive();
    try {
        testRule.deploy(repositoryService.createDeployment().addModelInstance("foo.dmn", dmnModelInstance));
        fail("Exception for negative time to live value is expected.");
    } catch (ProcessEngineException ex) {
        assertTrue(ex.getCause().getMessage().contains("negative value is not allowed"));
    }
}
Also used : ProcessEngineException(org.camunda.bpm.engine.ProcessEngineException) DmnModelInstance(org.camunda.bpm.model.dmn.DmnModelInstance) Test(org.junit.Test)

Aggregations

DmnModelInstance (org.camunda.bpm.model.dmn.DmnModelInstance)21 Test (org.junit.Test)16 InputStream (java.io.InputStream)10 DmnEngineTest (org.camunda.bpm.dmn.engine.test.DmnEngineTest)10 DmnDecision (org.camunda.bpm.dmn.engine.DmnDecision)5 Decision (org.camunda.bpm.model.dmn.instance.Decision)4 DmnTransformException (org.camunda.bpm.dmn.engine.impl.transform.DmnTransformException)3 Definitions (org.camunda.bpm.model.dmn.instance.Definitions)3 DecisionTable (org.camunda.bpm.model.dmn.instance.DecisionTable)2 Input (org.camunda.bpm.model.dmn.instance.Input)2 Output (org.camunda.bpm.model.dmn.instance.Output)2 DmnDecisionRequirementsGraph (org.camunda.bpm.dmn.engine.DmnDecisionRequirementsGraph)1 ProcessEngineException (org.camunda.bpm.engine.ProcessEngineException)1 CommandChecker (org.camunda.bpm.engine.impl.cfg.CommandChecker)1 DecisionDefinitionEntity (org.camunda.bpm.engine.impl.dmn.entity.repository.DecisionDefinitionEntity)1 DeploymentCache (org.camunda.bpm.engine.impl.persistence.deploy.cache.DeploymentCache)1 Deployment (org.camunda.bpm.engine.test.Deployment)1 InputExpression (org.camunda.bpm.model.dmn.instance.InputExpression)1 Rule (org.camunda.bpm.model.dmn.instance.Rule)1 Text (org.camunda.bpm.model.dmn.instance.Text)1