use of io.camunda.zeebe.protocol.impl.record.value.deployment.ProcessRecord in project zeebe by camunda.
the class BpmnResourceTransformer method transformProcessResource.
private void transformProcessResource(final DeploymentRecord deploymentEvent, final DeploymentResource deploymentResource, final BpmnModelInstance definition) {
final Collection<Process> processes = definition.getDefinitions().getChildElementsByType(Process.class);
for (final Process process : processes) {
if (process.isExecutable()) {
final String bpmnProcessId = process.getId();
final DeployedProcess lastProcess = processState.getLatestProcessVersionByProcessId(BufferUtil.wrapString(bpmnProcessId));
final DirectBuffer lastDigest = processState.getLatestVersionDigest(wrapString(bpmnProcessId));
final DirectBuffer resourceDigest = checksumGenerator.apply(deploymentResource);
// adds process record to deployment record
final var processMetadata = deploymentEvent.processesMetadata().add();
processMetadata.setBpmnProcessId(BufferUtil.wrapString(process.getId())).setChecksum(resourceDigest).setResourceName(deploymentResource.getResourceNameBuffer());
final var isDuplicate = isDuplicateOfLatest(deploymentResource, resourceDigest, lastProcess, lastDigest);
if (isDuplicate) {
processMetadata.setVersion(lastProcess.getVersion()).setKey(lastProcess.getKey()).markAsDuplicate();
} else {
final var key = keyGenerator.nextKey();
processMetadata.setKey(key).setVersion(processState.getProcessVersion(bpmnProcessId) + 1);
stateWriter.appendFollowUpEvent(key, ProcessIntent.CREATED, new ProcessRecord().wrap(processMetadata, deploymentResource.getResource()));
}
}
}
}
use of io.camunda.zeebe.protocol.impl.record.value.deployment.ProcessRecord in project zeebe by camunda.
the class ProcessStateTest method creatingProcessRecord.
public static ProcessRecord creatingProcessRecord(final MutableZeebeState zeebeState, final String processId, final int version) {
final BpmnModelInstance modelInstance = Bpmn.createExecutableProcess(processId).startEvent().serviceTask("test", task -> task.zeebeJobType("type")).endEvent().done();
final ProcessRecord processRecord = new ProcessRecord();
final String resourceName = "process.bpmn";
final var resource = wrapString(Bpmn.convertToString(modelInstance));
final var checksum = wrapString("checksum");
final KeyGenerator keyGenerator = zeebeState.getKeyGenerator();
final long key = keyGenerator.nextKey();
processRecord.setResourceName(wrapString(resourceName)).setResource(resource).setBpmnProcessId(BufferUtil.wrapString(processId)).setVersion(version).setKey(key).setResourceName(resourceName).setChecksum(checksum);
return processRecord;
}
use of io.camunda.zeebe.protocol.impl.record.value.deployment.ProcessRecord in project zeebe by camunda-cloud.
the class ProcessStateTest method creatingProcessRecord.
public static ProcessRecord creatingProcessRecord(final MutableZeebeState zeebeState, final String processId, final int version) {
final BpmnModelInstance modelInstance = Bpmn.createExecutableProcess(processId).startEvent().serviceTask("test", task -> task.zeebeJobType("type")).endEvent().done();
final ProcessRecord processRecord = new ProcessRecord();
final String resourceName = "process.bpmn";
final var resource = wrapString(Bpmn.convertToString(modelInstance));
final var checksum = wrapString("checksum");
final KeyGenerator keyGenerator = zeebeState.getKeyGenerator();
final long key = keyGenerator.nextKey();
processRecord.setResourceName(wrapString(resourceName)).setResource(resource).setBpmnProcessId(BufferUtil.wrapString(processId)).setVersion(version).setKey(key).setResourceName(resourceName).setChecksum(checksum);
return processRecord;
}
use of io.camunda.zeebe.protocol.impl.record.value.deployment.ProcessRecord in project zeebe by camunda-cloud.
the class BpmnResourceTransformer method transformProcessResource.
private void transformProcessResource(final DeploymentRecord deploymentEvent, final DeploymentResource deploymentResource, final BpmnModelInstance definition) {
final Collection<Process> processes = definition.getDefinitions().getChildElementsByType(Process.class);
for (final Process process : processes) {
if (process.isExecutable()) {
final String bpmnProcessId = process.getId();
final DeployedProcess lastProcess = processState.getLatestProcessVersionByProcessId(BufferUtil.wrapString(bpmnProcessId));
final DirectBuffer lastDigest = processState.getLatestVersionDigest(wrapString(bpmnProcessId));
final DirectBuffer resourceDigest = checksumGenerator.apply(deploymentResource);
// adds process record to deployment record
final var processMetadata = deploymentEvent.processesMetadata().add();
processMetadata.setBpmnProcessId(BufferUtil.wrapString(process.getId())).setChecksum(resourceDigest).setResourceName(deploymentResource.getResourceNameBuffer());
final var isDuplicate = isDuplicateOfLatest(deploymentResource, resourceDigest, lastProcess, lastDigest);
if (isDuplicate) {
processMetadata.setVersion(lastProcess.getVersion()).setKey(lastProcess.getKey()).markAsDuplicate();
} else {
final var key = keyGenerator.nextKey();
processMetadata.setKey(key).setVersion(processState.getProcessVersion(bpmnProcessId) + 1);
stateWriter.appendFollowUpEvent(key, ProcessIntent.CREATED, new ProcessRecord().wrap(processMetadata, deploymentResource.getResource()));
}
}
}
}
use of io.camunda.zeebe.protocol.impl.record.value.deployment.ProcessRecord in project zeebe by zeebe-io.
the class ProcessStateTest method creatingProcessRecord.
public static ProcessRecord creatingProcessRecord(final MutableZeebeState zeebeState, final String processId, final int version) {
final BpmnModelInstance modelInstance = Bpmn.createExecutableProcess(processId).startEvent().serviceTask("test", task -> task.zeebeJobType("type")).endEvent().done();
final ProcessRecord processRecord = new ProcessRecord();
final String resourceName = "process.bpmn";
final var resource = wrapString(Bpmn.convertToString(modelInstance));
final var checksum = wrapString("checksum");
final KeyGenerator keyGenerator = zeebeState.getKeyGenerator();
final long key = keyGenerator.nextKey();
processRecord.setResourceName(wrapString(resourceName)).setResource(resource).setBpmnProcessId(BufferUtil.wrapString(processId)).setVersion(version).setKey(key).setResourceName(resourceName).setChecksum(checksum);
return processRecord;
}
Aggregations