Search in sources :

Example 1 with Workflow

use of io.zeebe.model.bpmn.instance.Workflow in project zeebe by zeebe-io.

the class WorkflowDeploymentCache method getWorkflowIndex.

private int getWorkflowIndex(WorkflowEvent event) {
    final DirectBuffer bpmnProcessId = event.getBpmnProcessId();
    final DirectBuffer bpmnXml = event.getBpmnXml();
    int index = 0;
    final WorkflowDefinition workflowDefinition = bpmn.readFromXmlBuffer(bpmnXml);
    final Iterator<Workflow> workflows = workflowDefinition.getWorkflows().iterator();
    while (workflows.hasNext()) {
        final Workflow workflow = workflows.next();
        if (BufferUtil.equals(bpmnProcessId, workflow.getBpmnProcessId())) {
            return index;
        }
        index += 1;
    }
    throw new RuntimeException("workflow not found");
}
Also used : DirectBuffer(org.agrona.DirectBuffer) WorkflowDefinition(io.zeebe.model.bpmn.instance.WorkflowDefinition) Workflow(io.zeebe.model.bpmn.instance.Workflow)

Example 2 with Workflow

use of io.zeebe.model.bpmn.instance.Workflow in project zeebe by zeebe-io.

the class WorkflowDeploymentCache method lookupWorkflow.

private DeployedWorkflow lookupWorkflow(long key) {
    DeployedWorkflow deployedWorkflow = null;
    final DirectBuffer positionWorkflowBuffer = keyToPositionWorkflowMap.get(key);
    if (positionWorkflowBuffer != null) {
        final long eventPosition = positionWorkflowBuffer.getLong(POSITION_OFFSET, BYTE_ORDER);
        final int workflowIndex = positionWorkflowBuffer.getInt(WORKFLOW_INDEX_OFFSET, BYTE_ORDER);
        final boolean found = logStreamReader.seek(eventPosition);
        if (found && logStreamReader.hasNext()) {
            final LoggedEvent event = logStreamReader.next();
            workflowEvent.reset();
            event.readValue(workflowEvent);
            final WorkflowDefinition workflowDefinition = bpmn.readFromXmlBuffer(workflowEvent.getBpmnXml());
            final Workflow workflow = getWorkflowAt(workflowDefinition, workflowIndex);
            deployedWorkflow = new DeployedWorkflow(workflow, workflowEvent.getVersion());
        }
    }
    return deployedWorkflow;
}
Also used : DirectBuffer(org.agrona.DirectBuffer) LoggedEvent(io.zeebe.logstreams.log.LoggedEvent) WorkflowDefinition(io.zeebe.model.bpmn.instance.WorkflowDefinition) Workflow(io.zeebe.model.bpmn.instance.Workflow)

Example 3 with Workflow

use of io.zeebe.model.bpmn.instance.Workflow in project zeebe by zeebe-io.

the class WorkflowDeploymentCache method getWorkflowAt.

private Workflow getWorkflowAt(final WorkflowDefinition workflowDefinition, final int index) {
    int i = 0;
    final Iterator<Workflow> workflows = workflowDefinition.getWorkflows().iterator();
    while (workflows.hasNext()) {
        final Workflow workflow = workflows.next();
        if (index == i) {
            return workflow;
        }
        i += 1;
    }
    throw new RuntimeException("no workflow found");
}
Also used : Workflow(io.zeebe.model.bpmn.instance.Workflow)

Example 4 with Workflow

use of io.zeebe.model.bpmn.instance.Workflow in project zeebe by zeebe-io.

the class DeploymentCreateProcessor method assignVersionToWorkflows.

private void assignVersionToWorkflows(final DeploymentResourceIterator resourceIterator, final DirectBuffer topicName, final WorkflowDefinition definition) {
    for (Workflow workflow : definition.getWorkflows()) {
        if (workflow.isExecutable()) {
            final DirectBuffer bpmnProcessId = workflow.getBpmnProcessId();
            final int latestVersion = workflowVersions.getLatestVersion(topicName, bpmnProcessId, 0);
            resourceIterator.addDeployedWorkflow().setBpmnProcessId(bpmnProcessId).setVersion(latestVersion + 1);
        }
    }
}
Also used : DirectBuffer(org.agrona.DirectBuffer) DeployedWorkflow(io.zeebe.broker.workflow.data.DeployedWorkflow) Workflow(io.zeebe.model.bpmn.instance.Workflow)

Aggregations

Workflow (io.zeebe.model.bpmn.instance.Workflow)4 DirectBuffer (org.agrona.DirectBuffer)3 WorkflowDefinition (io.zeebe.model.bpmn.instance.WorkflowDefinition)2 DeployedWorkflow (io.zeebe.broker.workflow.data.DeployedWorkflow)1 LoggedEvent (io.zeebe.logstreams.log.LoggedEvent)1