Search in sources :

Example 16 with CaseDefinitionEntity

use of org.camunda.bpm.engine.impl.cmmn.entity.repository.CaseDefinitionEntity in project camunda-bpm-platform by camunda.

the class CmmnTransformerTest method testCasePlanModel.

/**
 *   +-----------------+                    +-----------------+
 *   | Case1            \                   | aCaseDefinition |
 *   +-------------------+---+              +-----------------+
 *   |                       |                      |
 *   |                       |   ==>        +-----------------+
 *   |                       |              |  aCasePlanModel |
 *   |                       |              +-----------------+
 *   |                       |
 *   +-----------------------+
 */
@Test
public void testCasePlanModel() {
    // given
    // when
    List<CaseDefinitionEntity> caseDefinitions = transform();
    // then
    assertEquals(1, caseDefinitions.size());
    CmmnCaseDefinition caseModel = caseDefinitions.get(0);
    List<CmmnActivity> activities = caseModel.getActivities();
    assertEquals(1, activities.size());
    CmmnActivity casePlanModelActivity = activities.get(0);
    assertEquals(casePlanModel.getId(), casePlanModelActivity.getId());
    assertTrue(casePlanModelActivity.getActivities().isEmpty());
}
Also used : CmmnCaseDefinition(org.camunda.bpm.engine.impl.cmmn.model.CmmnCaseDefinition) CaseDefinitionEntity(org.camunda.bpm.engine.impl.cmmn.entity.repository.CaseDefinitionEntity) CmmnActivity(org.camunda.bpm.engine.impl.cmmn.model.CmmnActivity) Test(org.junit.Test)

Example 17 with CaseDefinitionEntity

use of org.camunda.bpm.engine.impl.cmmn.entity.repository.CaseDefinitionEntity in project camunda-bpm-platform by camunda.

the class CmmnTransformerTest method testActivityTreeWithOneHumanTask.

/**
 *   +-----------------+                    +-----------------+
 *   | Case1            \                   | aCaseDefinition |
 *   +-------------------+---+              +-----------------+
 *   |                       |                      |
 *   |     +-------+         |   ==>        +-----------------+
 *   |     |   A   |         |              |  aCasePlanModel |
 *   |     +-------+         |              +-----------------+
 *   |                       |                      |
 *   +-----------------------+              +-----------------+
 *                                          |       A         |
 *                                          +-----------------+
 */
@Test
public void testActivityTreeWithOneHumanTask() {
    // given
    HumanTask humanTask = createElement(casePlanModel, "A", HumanTask.class);
    PlanItem planItem = createElement(casePlanModel, "PI_A", PlanItem.class);
    planItem.setDefinition(humanTask);
    // when
    List<CaseDefinitionEntity> caseDefinitions = transform();
    // then
    assertEquals(1, caseDefinitions.size());
    CaseDefinitionEntity caseDefinition = caseDefinitions.get(0);
    List<CmmnActivity> activities = caseDefinition.getActivities();
    CmmnActivity casePlanModelActivity = activities.get(0);
    List<CmmnActivity> planItemActivities = casePlanModelActivity.getActivities();
    assertEquals(1, planItemActivities.size());
    CmmnActivity child = planItemActivities.get(0);
    assertEquals(planItem.getId(), child.getId());
    assertTrue(child.getActivities().isEmpty());
}
Also used : CaseDefinitionEntity(org.camunda.bpm.engine.impl.cmmn.entity.repository.CaseDefinitionEntity) HumanTask(org.camunda.bpm.model.cmmn.instance.HumanTask) PlanItem(org.camunda.bpm.model.cmmn.instance.PlanItem) CmmnActivity(org.camunda.bpm.engine.impl.cmmn.model.CmmnActivity) Test(org.junit.Test)

Example 18 with CaseDefinitionEntity

use of org.camunda.bpm.engine.impl.cmmn.entity.repository.CaseDefinitionEntity in project camunda-bpm-platform by camunda.

the class CmmnTransformerTest method transform.

protected List<CaseDefinitionEntity> transform() {
    // convert the model to the XML string representation
    OutputStream outputStream = new ByteArrayOutputStream();
    Cmmn.writeModelToStream(outputStream, modelInstance);
    InputStream inputStream = IoUtil.convertOutputStreamToInputStream(outputStream);
    byte[] model = org.camunda.bpm.engine.impl.util.IoUtil.readInputStream(inputStream, "model");
    ResourceEntity resource = new ResourceEntity();
    resource.setBytes(model);
    resource.setName("test");
    transformer.setResource(resource);
    List<CaseDefinitionEntity> definitions = transformer.transform();
    IoUtil.closeSilently(outputStream);
    IoUtil.closeSilently(inputStream);
    return definitions;
}
Also used : InputStream(java.io.InputStream) ByteArrayOutputStream(java.io.ByteArrayOutputStream) OutputStream(java.io.OutputStream) CaseDefinitionEntity(org.camunda.bpm.engine.impl.cmmn.entity.repository.CaseDefinitionEntity) ResourceEntity(org.camunda.bpm.engine.impl.persistence.entity.ResourceEntity) ByteArrayOutputStream(java.io.ByteArrayOutputStream)

Example 19 with CaseDefinitionEntity

use of org.camunda.bpm.engine.impl.cmmn.entity.repository.CaseDefinitionEntity in project camunda-bpm-platform by camunda.

the class DefaultHistoryEventProducer method initHistoricVariableUpdateEvt.

protected void initHistoricVariableUpdateEvt(HistoricVariableUpdateEventEntity evt, VariableInstanceEntity variableInstance, HistoryEventType eventType) {
    // init properties
    evt.setEventType(eventType.getEventName());
    evt.setTimestamp(ClockUtil.getCurrentTime());
    evt.setVariableInstanceId(variableInstance.getId());
    evt.setProcessInstanceId(variableInstance.getProcessInstanceId());
    evt.setExecutionId(variableInstance.getExecutionId());
    evt.setCaseInstanceId(variableInstance.getCaseInstanceId());
    evt.setCaseExecutionId(variableInstance.getCaseExecutionId());
    evt.setTaskId(variableInstance.getTaskId());
    evt.setRevision(variableInstance.getRevision());
    evt.setVariableName(variableInstance.getName());
    evt.setSerializerName(variableInstance.getSerializerName());
    evt.setTenantId(variableInstance.getTenantId());
    evt.setUserOperationId(Context.getCommandContext().getOperationId());
    ExecutionEntity execution = variableInstance.getExecution();
    if (execution != null) {
        ProcessDefinitionEntity definition = execution.getProcessDefinition();
        if (definition != null) {
            evt.setProcessDefinitionId(definition.getId());
            evt.setProcessDefinitionKey(definition.getKey());
        }
    }
    CaseExecutionEntity caseExecution = variableInstance.getCaseExecution();
    if (caseExecution != null) {
        CaseDefinitionEntity definition = (CaseDefinitionEntity) caseExecution.getCaseDefinition();
        if (definition != null) {
            evt.setCaseDefinitionId(definition.getId());
            evt.setCaseDefinitionKey(definition.getKey());
        }
    }
    // copy value
    evt.setTextValue(variableInstance.getTextValue());
    evt.setTextValue2(variableInstance.getTextValue2());
    evt.setDoubleValue(variableInstance.getDoubleValue());
    evt.setLongValue(variableInstance.getLongValue());
    if (variableInstance.getByteArrayValueId() != null) {
        evt.setByteValue(variableInstance.getByteArrayValue());
    }
}
Also used : CaseExecutionEntity(org.camunda.bpm.engine.impl.cmmn.entity.runtime.CaseExecutionEntity) ExecutionEntity(org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity) CaseExecutionEntity(org.camunda.bpm.engine.impl.cmmn.entity.runtime.CaseExecutionEntity) CaseDefinitionEntity(org.camunda.bpm.engine.impl.cmmn.entity.repository.CaseDefinitionEntity) ProcessDefinitionEntity(org.camunda.bpm.engine.impl.persistence.entity.ProcessDefinitionEntity)

Example 20 with CaseDefinitionEntity

use of org.camunda.bpm.engine.impl.cmmn.entity.repository.CaseDefinitionEntity in project camunda-bpm-platform by camunda.

the class CaseHandlerTest method testHistoryTimeToLive.

@Test
public void testHistoryTimeToLive() {
    // given: a caseDefinition
    Integer historyTimeToLive = 6;
    caseDefinition.setCamundaHistoryTimeToLive(historyTimeToLive);
    // when
    CaseDefinitionEntity activity = (CaseDefinitionEntity) handler.handleElement(caseDefinition, context);
    // then
    assertEquals(Integer.valueOf(historyTimeToLive), activity.getHistoryTimeToLive());
}
Also used : CaseDefinitionEntity(org.camunda.bpm.engine.impl.cmmn.entity.repository.CaseDefinitionEntity) Test(org.junit.Test)

Aggregations

CaseDefinitionEntity (org.camunda.bpm.engine.impl.cmmn.entity.repository.CaseDefinitionEntity)31 Test (org.junit.Test)9 CommandChecker (org.camunda.bpm.engine.impl.cfg.CommandChecker)6 CmmnActivity (org.camunda.bpm.engine.impl.cmmn.model.CmmnActivity)5 CaseExecutionEntity (org.camunda.bpm.engine.impl.cmmn.entity.runtime.CaseExecutionEntity)4 TaskDefinition (org.camunda.bpm.engine.impl.task.TaskDefinition)4 InputStream (java.io.InputStream)3 DeploymentCache (org.camunda.bpm.engine.impl.persistence.deploy.cache.DeploymentCache)3 HumanTask (org.camunda.bpm.model.cmmn.instance.HumanTask)3 PlanItem (org.camunda.bpm.model.cmmn.instance.PlanItem)3 ProcessEngineConfigurationImpl (org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl)2 GetDeploymentResourceCmd (org.camunda.bpm.engine.impl.cmd.GetDeploymentResourceCmd)2 CmmnCaseDefinition (org.camunda.bpm.engine.impl.cmmn.model.CmmnCaseDefinition)2 ExpressionManager (org.camunda.bpm.engine.impl.el.ExpressionManager)2 ExecutionEntity (org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity)2 ProcessDefinitionEntity (org.camunda.bpm.engine.impl.persistence.entity.ProcessDefinitionEntity)2 CmmnModelInstance (org.camunda.bpm.model.cmmn.CmmnModelInstance)2 Case (org.camunda.bpm.model.cmmn.instance.Case)2 CasePlanModel (org.camunda.bpm.model.cmmn.instance.CasePlanModel)2 Definitions (org.camunda.bpm.model.cmmn.instance.Definitions)2