Search in sources :

Example 1 with IncidentIntent

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

the class IncidentImporter method importIncident.

public void importIncident(final Schema.IncidentRecord record) {
    final IncidentIntent intent = IncidentIntent.valueOf(record.getMetadata().getIntent());
    final long key = record.getMetadata().getKey();
    final long timestamp = record.getMetadata().getTimestamp();
    final IncidentEntity entity = incidentRepository.findById(key).orElseGet(() -> {
        final IncidentEntity newEntity = new IncidentEntity();
        newEntity.setKey(key);
        newEntity.setBpmnProcessId(record.getBpmnProcessId());
        newEntity.setProcessDefinitionKey(record.getProcessDefinitionKey());
        newEntity.setProcessInstanceKey(record.getProcessInstanceKey());
        newEntity.setElementInstanceKey(record.getElementInstanceKey());
        newEntity.setJobKey(record.getJobKey());
        newEntity.setErrorType(record.getErrorType());
        newEntity.setErrorMessage(record.getErrorMessage());
        return newEntity;
    });
    if (intent == IncidentIntent.CREATED) {
        entity.setCreated(timestamp);
        incidentRepository.save(entity);
    } else if (intent == IncidentIntent.RESOLVED) {
        entity.setResolved(timestamp);
        incidentRepository.save(entity);
    }
}
Also used : IncidentEntity(io.zeebe.monitor.entity.IncidentEntity) IncidentIntent(io.camunda.zeebe.protocol.record.intent.IncidentIntent)

Aggregations

IncidentIntent (io.camunda.zeebe.protocol.record.intent.IncidentIntent)1 IncidentEntity (io.zeebe.monitor.entity.IncidentEntity)1