From ad02f4008581417a40b076f122e9db4241a35bd2 Mon Sep 17 00:00:00 2001 From: bskjon Date: Sun, 23 Feb 2025 23:30:07 +0100 Subject: [PATCH] Simplified canStart --- .../implementations/WorkTaskListener.kt | 28 +++---------------- 1 file changed, 4 insertions(+), 24 deletions(-) diff --git a/apps/coordinator/src/main/kotlin/no/iktdev/mediaprocessing/coordinator/tasksV2/implementations/WorkTaskListener.kt b/apps/coordinator/src/main/kotlin/no/iktdev/mediaprocessing/coordinator/tasksV2/implementations/WorkTaskListener.kt index b4564c4f..b7b8c573 100644 --- a/apps/coordinator/src/main/kotlin/no/iktdev/mediaprocessing/coordinator/tasksV2/implementations/WorkTaskListener.kt +++ b/apps/coordinator/src/main/kotlin/no/iktdev/mediaprocessing/coordinator/tasksV2/implementations/WorkTaskListener.kt @@ -19,34 +19,14 @@ abstract class WorkTaskListener: CoordinatorEventListener() { } fun canStart(incomingEvent: Event, events: List): Boolean { - assert(events.isNotEmpty()) { - "Events are nor present" + val autoStart = events.find { it.eventType == Events.ProcessStarted }?.az()?.data + if (autoStart == null) { + log.error { "Start event not found. Requiring permit event" } } - val startEvent = events.find { it.eventType == Events.ProcessStarted }?.az() - if (startEvent == null) { - log.error { "Start event not found on ${incomingEvent.referenceId()}." } - try { - log.error { WGson.toJson(startEvent) } - log.warn { "EvenTypes:\n" + events.map { it.eventType }.map { "\n\t$it" } } - log.warn { "Events provided:\n ${WGson.toJson(events)}" } - } catch (e: Exception) {} - return false - } - - - val startType = startEvent?.data?.type - if (startEvent == null) { - log.error { "Start type on ${incomingEvent.referenceId()}. Requiring permit event" } - try { - log.error { WGson.toJson(startEvent) } - } catch (e: Exception) {} - return false - } - return if (incomingEvent.eventType == Events.WorkProceedPermitted) { return true } else { - if (startType == ProcessType.MANUAL) { + if (autoStart == null || autoStart.type == ProcessType.MANUAL) { log.warn { "${incomingEvent.metadata.referenceId} waiting for Proceed event due to Manual process" } false } else true