Skip to content

Commit

Permalink
[Fix #2113] Support group containing different process instance ids
Browse files Browse the repository at this point in the history
  • Loading branch information
fjtirado committed Oct 14, 2024
1 parent da4cee6 commit bc68df2
Showing 1 changed file with 6 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@

import java.time.ZonedDateTime;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;

import org.kie.kogito.event.process.MultipleProcessInstanceDataEvent;
Expand Down Expand Up @@ -68,13 +69,10 @@ public ProcessInstanceEntityStorage(ProcessInstanceEntityRepository repository,

@Override
@Transactional
public void indexGroup(MultipleProcessInstanceDataEvent event) {
Iterator<ProcessInstanceDataEvent<?>> iter = event.getData().iterator();
ProcessInstanceDataEvent<?> firstEvent = iter.next();
ProcessInstanceEntity pi = findOrInit(firstEvent);
indexEvent(pi, firstEvent);
while (iter.hasNext()) {
indexEvent(pi, iter.next());
public void indexGroup(MultipleProcessInstanceDataEvent events) {
Map<String, ProcessInstanceEntity> piMap = new HashMap<>();
for (ProcessInstanceDataEvent<?> event : events.getData()) {
indexEvent(piMap.computeIfAbsent(event.getKogitoProcessInstanceId(), id -> findOrInit(event)), event);
}
repository.flush();
}
Expand Down

0 comments on commit bc68df2

Please sign in to comment.