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");
}
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;
}
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");
}
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);
}
}
}
Aggregations