Skip to content

Commit

Permalink
chore(app): update Zeebe to 0.20.0
Browse files Browse the repository at this point in the history
  • Loading branch information
npepinpe committed Jul 16, 2019
1 parent dbec1b9 commit a816128
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 59 deletions.
123 changes: 66 additions & 57 deletions app/src/main/java/io/zeebe/monitor/rest/ViewController.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import io.zeebe.monitor.repository.VariableRepository;
import io.zeebe.monitor.repository.WorkflowInstanceRepository;
import io.zeebe.monitor.repository.WorkflowRepository;
import io.zeebe.util.collection.Tuple;
import java.time.Instant;
import java.util.ArrayList;
import java.util.Arrays;
Expand Down Expand Up @@ -102,16 +101,16 @@ private WorkflowDto toDto(WorkflowEntity workflowEntity) {
public String workflowDetail(
@PathVariable long key, Map<String, Object> model, Pageable pageable) {

final WorkflowEntity workflow =
workflowRepository
.findByKey(key)
.orElseThrow(() -> new RuntimeException("No workflow found with key: " + key));
final WorkflowEntity workflow =
workflowRepository
.findByKey(key)
.orElseThrow(() -> new RuntimeException("No workflow found with key: " + key));

model.put("workflow", toDto(workflow));
model.put("resource", workflow.getResource());
model.put("workflow", toDto(workflow));
model.put("resource", workflow.getResource());

final List<ElementInstanceState> elementInstanceStates = getElementInstanceStates(key);
model.put("instance.elementInstances", elementInstanceStates);
final List<ElementInstanceState> elementInstanceStates = getElementInstanceStates(key);
model.put("instance.elementInstances", elementInstanceStates);

final long count = workflowInstanceRepository.countByWorkflowKey(key);

Expand All @@ -124,17 +123,17 @@ public String workflowDetail(
model.put("instances", instances);
model.put("count", count);

final List<TimerDto> timers =
timerRepository.findByWorkflowKeyAndWorkflowInstanceKeyIsNull(key).stream()
.map(this::toDto)
.collect(Collectors.toList());
model.put("timers", timers);
final List<TimerDto> timers =
timerRepository.findByWorkflowKeyAndWorkflowInstanceKeyIsNull(key).stream()
.map(this::toDto)
.collect(Collectors.toList());
model.put("timers", timers);

final List<MessageSubscriptionDto> messageSubscriptions =
messageSubscriptionRepository.findByWorkflowKeyAndWorkflowInstanceKeyIsNull(key).stream()
.map(this::toDto)
.collect(Collectors.toList());
model.put("messageSubscriptions", messageSubscriptions);
final List<MessageSubscriptionDto> messageSubscriptions =
messageSubscriptionRepository.findByWorkflowKeyAndWorkflowInstanceKeyIsNull(key).stream()
.map(this::toDto)
.collect(Collectors.toList());
model.put("messageSubscriptions", messageSubscriptions);

addPaginationToModel(model, pageable, count);

Expand All @@ -156,7 +155,7 @@ private List<ElementInstanceState> getElementInstanceStates(long key) {
ElementInstanceStatistics::getElementId, ElementInstanceStatistics::getCount));

final List<ElementInstanceState> elementInstanceStates =
elementEnteredStatistics.stream()
elementEnteredStatistics.stream()
.map(
s -> {
final ElementInstanceState state = new ElementInstanceState();
Expand Down Expand Up @@ -219,16 +218,16 @@ public String instanceList(Map<String, Object> model, Pageable pageable) {
public String instanceDetail(
@PathVariable long key, Map<String, Object> model, Pageable pageable) {

final WorkflowInstanceEntity instance =
workflowInstanceRepository
.findByKey(key)
.orElseThrow(() -> new RuntimeException("No workflow instance found with key: " + key));
final WorkflowInstanceEntity instance =
workflowInstanceRepository
.findByKey(key)
.orElseThrow(() -> new RuntimeException("No workflow instance found with key: " + key));

workflowRepository
.findByKey(instance.getWorkflowKey())
.ifPresent(workflow -> model.put("resource", workflow.getResource()));
workflowRepository
.findByKey(instance.getWorkflowKey())
.ifPresent(workflow -> model.put("resource", workflow.getResource()));

model.put("instance", toInstanceDto(instance));
model.put("instance", toInstanceDto(instance));

return "instance-detail-view";
}
Expand Down Expand Up @@ -263,40 +262,40 @@ private WorkflowInstanceDto toInstanceDto(WorkflowInstanceEntity instance) {
}

final List<String> completedActivities =
events.stream()
events.stream()
.filter(e -> WORKFLOW_INSTANCE_COMPLETED_INTENTS.contains(e.getIntent()))
.map(ElementInstanceEntity::getElementId)
.collect(Collectors.toList());

final List<String> activeActivities =
events.stream()
events.stream()
.filter(e -> WORKFLOW_INSTANCE_ENTERED_INTENTS.contains(e.getIntent()))
.map(ElementInstanceEntity::getElementId)
.filter(id -> !completedActivities.contains(id))
.collect(Collectors.toList());
dto.setActiveActivities(activeActivities);

final List<String> takenSequenceFlows =
events.stream()
events.stream()
.filter(e -> e.getIntent().equals("SEQUENCE_FLOW_TAKEN"))
.map(ElementInstanceEntity::getElementId)
.collect(Collectors.toList());
dto.setTakenSequenceFlows(takenSequenceFlows);

final Map<String, Long> completedElementsById =
events.stream()
events.stream()
.filter(e -> WORKFLOW_INSTANCE_COMPLETED_INTENTS.contains(e.getIntent()))
.collect(
Collectors.groupingBy(ElementInstanceEntity::getElementId, Collectors.counting()));

final Map<String, Long> enteredElementsById =
events.stream()
events.stream()
.filter(e -> WORKFLOW_INSTANCE_ENTERED_INTENTS.contains(e.getIntent()))
.collect(
Collectors.groupingBy(ElementInstanceEntity::getElementId, Collectors.counting()));

final List<ElementInstanceState> elementStates =
enteredElementsById.entrySet().stream()
enteredElementsById.entrySet().stream()
.map(
e -> {
final String elementId = e.getKey();
Expand All @@ -316,7 +315,7 @@ private WorkflowInstanceDto toInstanceDto(WorkflowInstanceEntity instance) {
dto.setElementInstances(elementStates);

final List<AuditLogEntry> auditLogEntries =
events.stream()
events.stream()
.map(
e -> {
final AuditLogEntry entry = new AuditLogEntry();
Expand Down Expand Up @@ -344,10 +343,10 @@ private WorkflowInstanceDto toInstanceDto(WorkflowInstanceEntity instance) {
events.forEach(e -> elementIdsForKeys.put(e.getKey(), e.getElementId()));

final List<IncidentDto> incidentDtos =
incidents.stream()
incidents.stream()
.map(
i -> {
final long incidentKey = i.getKey();
final long incidentKey = i.getKey();

final IncidentDto incidentDto = new IncidentDto();
incidentDto.setKey(incidentKey);
Expand Down Expand Up @@ -381,7 +380,7 @@ private WorkflowInstanceDto toInstanceDto(WorkflowInstanceEntity instance) {
dto.setIncidents(incidentDtos);

final List<String> activitiesWitIncidents =
incidents.stream()
incidents.stream()
.filter(i -> i.getResolved() == null || i.getResolved() <= 0)
.map(i -> elementIdsForKeys.get(i.getElementInstanceKey()))
.distinct()
Expand All @@ -392,25 +391,25 @@ private WorkflowInstanceDto toInstanceDto(WorkflowInstanceEntity instance) {
activeActivities.removeAll(activitiesWitIncidents);
dto.setActiveActivities(activeActivities);

final Map<Tuple<Long, String>, List<VariableEntity>> variablesByScopeAndName =
variableRepository.findByWorkflowInstanceKey(instance.getKey()).stream()
.collect(Collectors.groupingBy(v -> new Tuple<>(v.getScopeKey(), v.getName())));
final Map<VariableTuple, List<VariableEntity>> variablesByScopeAndName =
variableRepository.findByWorkflowInstanceKey(instance.getKey()).stream()
.collect(Collectors.groupingBy(v -> new VariableTuple(v.getScopeKey(), v.getName())));
variablesByScopeAndName.forEach(
(scopeKeyName, variables) -> {
final VariableEntry variableDto = new VariableEntry();
final long scopeKey = scopeKeyName.getLeft();
final long scopeKey = scopeKeyName.scopeKey;

variableDto.setScopeKey(scopeKey);
variableDto.setScopeName(elementIdsForKeys.get(scopeKey));

variableDto.setName(scopeKeyName.getRight());
variableDto.setName(scopeKeyName.name);

final VariableEntity lastUpdate = variables.get(variables.size() - 1);
variableDto.setValue(lastUpdate.getValue());
variableDto.setTimestamp(Instant.ofEpochMilli(lastUpdate.getTimestamp()).toString());

final List<VariableUpdateEntry> varUpdates =
variables.stream()
variables.stream()
.map(
v -> {
final VariableUpdateEntry varUpdate = new VariableUpdateEntry();
Expand All @@ -429,13 +428,13 @@ private WorkflowInstanceDto toInstanceDto(WorkflowInstanceEntity instance) {
activeScopes.add(new ActiveScope(instance.getKey(), instance.getBpmnProcessId()));

final List<Long> completedElementInstances =
events.stream()
events.stream()
.filter(e -> WORKFLOW_INSTANCE_COMPLETED_INTENTS.contains(e.getIntent()))
.map(ElementInstanceEntity::getKey)
.collect(Collectors.toList());

final List<ActiveScope> activeElementInstances =
events.stream()
events.stream()
.filter(e -> WORKFLOW_INSTANCE_ENTERED_INTENTS.contains(e.getIntent()))
.map(ElementInstanceEntity::getKey)
.filter(id -> !completedElementInstances.contains(id))
Expand All @@ -447,7 +446,7 @@ private WorkflowInstanceDto toInstanceDto(WorkflowInstanceEntity instance) {
dto.setActiveScopes(activeScopes);

final List<JobDto> jobDtos =
jobRepository.findByWorkflowInstanceKey(instance.getKey()).stream()
jobRepository.findByWorkflowInstanceKey(instance.getKey()).stream()
.map(
job -> {
final JobDto jobDto = toDto(job);
Expand All @@ -466,7 +465,7 @@ private WorkflowInstanceDto toInstanceDto(WorkflowInstanceEntity instance) {
dto.setJobs(jobDtos);

final List<MessageSubscriptionDto> messageSubscriptions =
messageSubscriptionRepository.findByWorkflowInstanceKey(instance.getKey()).stream()
messageSubscriptionRepository.findByWorkflowInstanceKey(instance.getKey()).stream()
.map(
subscription -> {
final MessageSubscriptionDto subscriptionDto = toDto(subscription);
Expand All @@ -479,7 +478,7 @@ private WorkflowInstanceDto toInstanceDto(WorkflowInstanceEntity instance) {
dto.setMessageSubscriptions(messageSubscriptions);

final List<TimerDto> timers =
timerRepository.findByWorkflowInstanceKey(instance.getKey()).stream()
timerRepository.findByWorkflowInstanceKey(instance.getKey()).stream()
.map(timer -> toDto(timer))
.collect(Collectors.toList());
dto.setTimers(timers);
Expand Down Expand Up @@ -508,11 +507,11 @@ public String incidentList(Map<String, Object> model, Pageable pageable) {

private IncidentListDto toDto(IncidentEntity incident) {
final IncidentListDto dto = new IncidentListDto();
dto.setKey(incident.getKey());
dto.setKey(incident.getKey());

dto.setBpmnProcessId(incident.getBpmnProcessId());
dto.setWorkflowKey(incident.getWorkflowKey());
;
dto.setWorkflowKey(incident.getWorkflowKey());
;
dto.setWorkflowInstanceKey(incident.getWorkflowInstanceKey());

dto.setErrorType(incident.getErrorType());
Expand Down Expand Up @@ -609,7 +608,7 @@ private MessageSubscriptionDto toDto(MessageSubscriptionEntity subscription) {
dto.setWorkflowInstanceKey(subscription.getWorkflowInstanceKey());
dto.setActivityInstanceKey(subscription.getElementInstanceKey());

dto.setActivityId(subscription.getTargetFlowNodeId());
dto.setActivityId(subscription.getTargetFlowNodeId());

dto.setState(subscription.getState());
dto.setTimestamp(Instant.ofEpochMilli(subscription.getTimestamp()).toString());
Expand All @@ -622,14 +621,14 @@ private MessageSubscriptionDto toDto(MessageSubscriptionEntity subscription) {
private TimerDto toDto(TimerEntity timer) {
final TimerDto dto = new TimerDto();

dto.setActivityId(timer.getTargetFlowNodeId());
dto.setActivityId(timer.getTargetFlowNodeId());
dto.setState(timer.getState());
dto.setDueDate(Instant.ofEpochMilli(timer.getDueDate()).toString());
dto.setTimestamp(Instant.ofEpochMilli(timer.getTimestamp()).toString());
dto.setActivityInstanceKey(timer.getElementInstanceKey());
dto.setActivityInstanceKey(timer.getElementInstanceKey());

final int repetitions = timer.getRepetitions();
dto.setRepetitions(repetitions >= 0 ? String.valueOf(repetitions) : "∞");
final int repetitions = timer.getRepetitions();
dto.setRepetitions(repetitions >= 0 ? String.valueOf(repetitions) : "∞");

return dto;
}
Expand All @@ -646,4 +645,14 @@ private void addPaginationToModel(
model.put("nextPage", currentPage + 1);
}
}

private static class VariableTuple {
private final long scopeKey;
private final String name;

VariableTuple(long scopeKey, String name) {
this.scopeKey = scopeKey;
this.name = name;
}
}
}
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>

<zeebe.version>0.19.0</zeebe.version>
<zeebe.version>0.20.0</zeebe.version>
<spring.boot.version>2.1.2.RELEASE</spring.boot.version>
<hazelcast.exporter.version>0.4.0</hazelcast.exporter.version>
<hazelcast.exporter.version>0.5.0</hazelcast.exporter.version>

<!-- release parent settings -->
<version.java>1.8</version.java>
Expand Down

0 comments on commit a816128

Please sign in to comment.