Search in sources :

Example 1 with TimerIntent

use of io.camunda.zeebe.protocol.record.intent.TimerIntent in project zeebe-simple-monitor by camunda-community-hub.

the class TimerImporter method importTimer.

public void importTimer(final Schema.TimerRecord record) {
    final TimerIntent intent = TimerIntent.valueOf(record.getMetadata().getIntent());
    final long key = record.getMetadata().getKey();
    final long timestamp = record.getMetadata().getTimestamp();
    final TimerEntity entity = timerRepository.findById(key).orElseGet(() -> {
        final TimerEntity newEntity = new TimerEntity();
        newEntity.setKey(key);
        newEntity.setProcessDefinitionKey(record.getProcessDefinitionKey());
        newEntity.setTargetElementId(record.getTargetElementId());
        newEntity.setDueDate(record.getDueDate());
        newEntity.setRepetitions(record.getRepetitions());
        if (record.getProcessInstanceKey() > 0) {
            newEntity.setProcessInstanceKey(record.getProcessInstanceKey());
            newEntity.setElementInstanceKey(record.getElementInstanceKey());
        }
        return newEntity;
    });
    entity.setState(intent.name().toLowerCase());
    entity.setTimestamp(timestamp);
    timerRepository.save(entity);
}
Also used : TimerIntent(io.camunda.zeebe.protocol.record.intent.TimerIntent) TimerEntity(io.zeebe.monitor.entity.TimerEntity)

Aggregations

TimerIntent (io.camunda.zeebe.protocol.record.intent.TimerIntent)1 TimerEntity (io.zeebe.monitor.entity.TimerEntity)1