Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ft: Added filter option for Process Instance Record Stream #50

Merged
merged 1 commit into from
Oct 25, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH under
* one or more contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright ownership.
* Licensed under the Zeebe Community License 1.1. You may not use this file
* except in compliance with the Zeebe Community License 1.1.
*/
package org.camunda.community.eze

import io.camunda.zeebe.protocol.record.Record
import io.camunda.zeebe.protocol.record.value.ProcessInstanceRecordValue

class ProcessInstanceRecordStream(private val records: Iterable<Record<ProcessInstanceRecordValue>>) :
Iterable<Record<ProcessInstanceRecordValue>> {

override fun iterator(): Iterator<Record<ProcessInstanceRecordValue>> {
return records.iterator()
}

fun withBpmnProcessId(bpmnProcessId: String): ProcessInstanceRecordStream {
return ProcessInstanceRecordStream(filter { it.value.bpmnProcessId == bpmnProcessId })
}

fun withProcessDefinitionKey(processDefinitionKey: Long): ProcessInstanceRecordStream {
return ProcessInstanceRecordStream(filter { it.value.processDefinitionKey == processDefinitionKey })
}

fun withElementId(elementId: String): ProcessInstanceRecordStream {
return ProcessInstanceRecordStream(filter { it.value.elementId == elementId })
}

fun withFlowScopeKey(flowScopeKey: Long): ProcessInstanceRecordStream {
return ProcessInstanceRecordStream(filter { it.value.flowScopeKey == flowScopeKey })
}

fun withParentProcessInstanceKey(parentProcessInstanceKey: Long): ProcessInstanceRecordStream {
return ProcessInstanceRecordStream(filter { it.value.parentProcessInstanceKey == parentProcessInstanceKey })
}

fun withParentElementInstanceKey(parentElementInstanceKey: Long): ProcessInstanceRecordStream {
return ProcessInstanceRecordStream(filter { it.value.parentElementInstanceKey == parentElementInstanceKey })
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ interface RecordStreamSource {
.filterIsInstance<Record<T>>()
}

fun processInstanceRecords(): Iterable<Record<ProcessInstanceRecordValue>> {
return records().ofValueType(ValueType.PROCESS_INSTANCE)
fun processInstanceRecords(): ProcessInstanceRecordStream {
return ProcessInstanceRecordStream(records().ofValueType(ValueType.PROCESS_INSTANCE))
}

fun jobRecords(): JobRecordStream {
Expand Down