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 01b162d
Showing 1 changed file with 6 additions and 9 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 Expand Up @@ -157,7 +155,6 @@ private void indexNode(ProcessInstanceEntity pi, ProcessInstanceNodeEventBody da
if ("MilestoneNode".equals(data.getNodeType())) {
pi.getMilestones().stream().filter(n -> n.getId().equals(data.getNodeInstanceId())).findAny().ifPresentOrElse(n -> updateMilestone(n, data), () -> createMilestone(pi, data));
}

}

private MilestoneEntity createMilestone(ProcessInstanceEntity pi, ProcessInstanceNodeEventBody data) {
Expand Down

0 comments on commit 01b162d

Please sign in to comment.