use of io.zeebe.monitor.entity.VariableEntity in project zeebe-simple-monitor by camunda-community-hub.
the class InstancesVariableListController method fillViewDetailsIntoDto.
@Override
protected void fillViewDetailsIntoDto(ProcessInstanceEntity instance, List<ElementInstanceEntity> events, List<IncidentEntity> incidents, Map<Long, String> elementIdsForKeys, Map<String, Object> model, Pageable pageable, ProcessInstanceDto dto) {
final Map<VariableTuple, List<VariableEntity>> variablesByScopeAndName = variableRepository.findByProcessInstanceKey(instance.getKey(), pageable).stream().collect(Collectors.groupingBy(v -> new VariableTuple(v.getScopeKey(), v.getName())));
variablesByScopeAndName.forEach((scopeKeyName, variables) -> {
final VariableEntry variableDto = new VariableEntry();
final long scopeKey = scopeKeyName.scopeKey;
variableDto.setScopeKey(scopeKey);
variableDto.setElementId(elementIdsForKeys.get(scopeKey));
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().map(v -> {
final VariableUpdateEntry varUpdate = new VariableUpdateEntry();
varUpdate.setValue(v.getValue());
varUpdate.setTimestamp(Instant.ofEpochMilli(v.getTimestamp()).toString());
return varUpdate;
}).collect(Collectors.toList());
variableDto.setUpdates(varUpdates);
dto.getVariables().add(variableDto);
});
final long count = variableRepository.countByProcessInstanceKey(instance.getKey());
addPaginationToModel(model, pageable, count);
}
use of io.zeebe.monitor.entity.VariableEntity in project zeebe-simple-monitor by camunda-community-hub.
the class VariableImporter method importVariable.
public void importVariable(final Schema.VariableRecord record) {
final VariableEntity newVariable = new VariableEntity();
newVariable.setPosition(record.getMetadata().getPosition());
newVariable.setPartitionId(record.getMetadata().getPartitionId());
if (!variableRepository.existsById(newVariable.getGeneratedIdentifier())) {
newVariable.setTimestamp(record.getMetadata().getTimestamp());
newVariable.setProcessInstanceKey(record.getProcessInstanceKey());
newVariable.setName(record.getName());
newVariable.setValue(record.getValue());
newVariable.setScopeKey(record.getScopeKey());
newVariable.setState(record.getMetadata().getIntent().toLowerCase());
variableRepository.save(newVariable);
}
}
use of io.zeebe.monitor.entity.VariableEntity in project zeebe-simple-monitor by camunda-community-hub.
the class VariableRepositoryTest method createVariable.
private VariableEntity createVariable() {
VariableEntity variable = new VariableEntity();
variable.setPartitionId(123);
variable.setPosition(456L);
return variable;
}
use of io.zeebe.monitor.entity.VariableEntity in project zeebe-simple-monitor by camunda-community-hub.
the class VariableRepositoryTest method JPA_will_automatically_update_the_ID_attribute.
@Test
public void JPA_will_automatically_update_the_ID_attribute() {
// given
VariableEntity variable = createVariable();
// when
variableRepository.save(variable);
// then
assertThat(variable.getId()).isEqualTo("123-456");
}
use of io.zeebe.monitor.entity.VariableEntity in project zeebe-simple-monitor by camunda-community-hub.
the class VariableRepositoryTest method variable_can_be_retrieved_by_transient_ID.
@Test
public void variable_can_be_retrieved_by_transient_ID() {
// given
VariableEntity variable = createVariable();
// when
variableRepository.save(variable);
// then
Optional<VariableEntity> entity = variableRepository.findById("123-456");
assertThat(entity).isPresent();
}
Aggregations