diff --git a/src/main/java/org/lorislab/zeebe/dev/monitor/data/ImportDataService.java b/src/main/java/org/lorislab/zeebe/dev/monitor/data/ImportDataService.java index 37e8bd8..8e0d162 100644 --- a/src/main/java/org/lorislab/zeebe/dev/monitor/data/ImportDataService.java +++ b/src/main/java/org/lorislab/zeebe/dev/monitor/data/ImportDataService.java @@ -7,6 +7,7 @@ import io.camunda.zeebe.protocol.record.value.*; import io.camunda.zeebe.protocol.record.value.deployment.DeploymentResource; import io.camunda.zeebe.protocol.record.value.deployment.ProcessMetadataValue; +import io.camunda.zeebe.protocol.record.value.deployment.Process; import org.lorislab.zeebe.dev.monitor.models.*; import org.lorislab.zeebe.dev.monitor.models.Error; import org.lorislab.zeebe.dev.monitor.ws.NotificationService; @@ -18,9 +19,7 @@ import java.time.LocalDateTime; import java.time.OffsetDateTime; import java.time.ZoneOffset; -import java.time.format.DateTimeFormatter; import java.util.Map; -import java.util.TimeZone; import java.util.UUID; import java.util.stream.Collectors; @@ -147,6 +146,33 @@ private void importWorkflowProcess(final ProcessMetadataValue value, LocalDateTi dr.persistAndFlush(); } + public void importProcess(final Record record) { + if (record.getPartitionId() != Protocol.DEPLOYMENT_PARTITION) { + return; + } + Process value = record.getValue(); + + Definition def = Definition.findById(value.getProcessDefinitionKey()); + if (def != null) { + //TODO: check version and duplicates + return; + } + Definition entity = new Definition(); + entity.key = value.getProcessDefinitionKey(); + entity.bpmnProcessId = value.getBpmnProcessId(); + entity.version = value.getVersion(); + entity.timestamp = localDateTime(record.getTimestamp()); + entity.persistAndFlush(); + + BpmnXmlResource dr = new BpmnXmlResource(); + dr.name = value.getResourceName(); + dr.key = entity.key; + dr.resource = value.getResource(); + dr.persistAndFlush(); + + instanceNotificationService.sendEvent(new NotificationService.ProcessEvent(NotificationService.ProcessEventType.DEPLOYED)); + } + public void importTimer(final Record record) { Timer timer = Timer.findById(record.getKey()); if (timer == null) { diff --git a/src/main/java/org/lorislab/zeebe/dev/monitor/data/ImportRestController.java b/src/main/java/org/lorislab/zeebe/dev/monitor/data/ImportRestController.java index 6a41db3..12fe57d 100644 --- a/src/main/java/org/lorislab/zeebe/dev/monitor/data/ImportRestController.java +++ b/src/main/java/org/lorislab/zeebe/dev/monitor/data/ImportRestController.java @@ -72,7 +72,8 @@ public Response records(byte[] body) { if (record.getRecordType() == RecordType.EVENT) { switch (record.getValueType()) { case PROCESS_INSTANCE -> importDataService.importProcessInstance(value(record)); - case DEPLOYMENT -> importDataService.importWorkflowProcess(value(record)); + case PROCESS -> importDataService.importProcess(value(record)); +// case DEPLOYMENT -> importDataService.importWorkflowProcess(value(record)); case TIMER -> importDataService.importTimer(value(record)); case PROCESS_MESSAGE_SUBSCRIPTION -> importDataService.importMessageSubscription(value(record)); case MESSAGE_START_EVENT_SUBSCRIPTION -> importDataService.importMessageStartEventSubscription(value(record)); diff --git a/src/main/resources/reflection-config.json b/src/main/resources/reflection-config.json index c6fcc75..073afd0 100644 --- a/src/main/resources/reflection-config.json +++ b/src/main/resources/reflection-config.json @@ -34,8 +34,8 @@ {"name" : "io.camunda.zeebe.protocol.record.value.deployment.ImmutableDeploymentResource$Builder", "allDeclaredConstructors" : true, "allPublicConstructors" : true, "allDeclaredMethods" : true, "allPublicMethods" : true, "allDeclaredFields" : true, "allPublicFields" : true}, {"name" : "io.camunda.zeebe.protocol.record.value.deployment.ImmutableProcess$Builder", "allDeclaredConstructors" : true, "allPublicConstructors" : true, "allDeclaredMethods" : true, "allPublicMethods" : true, "allDeclaredFields" : true, "allPublicFields" : true}, {"name" : "io.camunda.zeebe.protocol.record.value.deployment.ImmutableProcessMetadataValue$Builder", "allDeclaredConstructors" : true, "allPublicConstructors" : true, "allDeclaredMethods" : true, "allPublicMethods" : true, "allDeclaredFields" : true, "allPublicFields" : true}, - {"name" : "io.camunda.zeebe.protocol.record.value.deployment.ImmutableForm$Builder,", "allDeclaredConstructors" : true, "allPublicConstructors" : true, "allDeclaredMethods" : true, "allPublicMethods" : true, "allDeclaredFields" : true, "allPublicFields" : true}, - {"name" : "io.camunda.zeebe.protocol.record.value.deployment.ImmutableFormMetadataValue$Builder,", "allDeclaredConstructors" : true, "allPublicConstructors" : true, "allDeclaredMethods" : true, "allPublicMethods" : true, "allDeclaredFields" : true, "allPublicFields" : true}, + {"name" : "io.camunda.zeebe.protocol.record.value.deployment.ImmutableForm$Builder", "allDeclaredConstructors" : true, "allPublicConstructors" : true, "allDeclaredMethods" : true, "allPublicMethods" : true, "allDeclaredFields" : true, "allPublicFields" : true}, + {"name" : "io.camunda.zeebe.protocol.record.value.deployment.ImmutableFormMetadataValue$Builder", "allDeclaredConstructors" : true, "allPublicConstructors" : true, "allDeclaredMethods" : true, "allPublicMethods" : true, "allDeclaredFields" : true, "allPublicFields" : true}, {"name" : "com.sun.org.apache.xerces.internal.impl.dv.xs.SchemaDVFactoryImpl", "allDeclaredConstructors" : true, "allPublicConstructors" : true, "allDeclaredMethods" : true, "allPublicMethods" : true, "allDeclaredFields" : true, "allPublicFields" : true}, {"name" : "io.camunda.zeebe.protocol.record.value.ImmutableProcessInstanceCreationStartInstructionValue$Builder", "allDeclaredConstructors" : true, "allPublicConstructors" : true, "allDeclaredMethods" : true, "allPublicMethods" : true, "allDeclaredFields" : true, "allPublicFields" : true}, {"name" : "io.camunda.zeebe.protocol.record.value.ImmutableProcessInstanceModificationActivateInstructionValue$Builder", "allDeclaredConstructors" : true, "allPublicConstructors" : true, "allDeclaredMethods" : true, "allPublicMethods" : true, "allDeclaredFields" : true, "allPublicFields" : true},