Projection + aggregation change
This commit is contained in:
parent
8f06f8682d
commit
6a423365cd
@ -66,7 +66,7 @@ class MigrateCreateStoreTaskListener(
|
|||||||
).derivedOf(event)
|
).derivedOf(event)
|
||||||
|
|
||||||
|
|
||||||
if (!collectProjection.canStoreAutomatically()) {
|
if (!collectProjection.isStorePermitted()) {
|
||||||
log.info { "Not storing content and metadata automatically for collection: $collection @ ${useEvent.referenceId}" }
|
log.info { "Not storing content and metadata automatically for collection: $collection @ ${useEvent.referenceId}" }
|
||||||
log.info { "A manual allow completion event is required to proceed." }
|
log.info { "A manual allow completion event is required to proceed." }
|
||||||
return null
|
return null
|
||||||
|
|||||||
@ -2,6 +2,7 @@ package no.iktdev.mediaprocessing.coordinator.services
|
|||||||
|
|
||||||
import no.iktdev.eventi.ZDS.toEvent
|
import no.iktdev.eventi.ZDS.toEvent
|
||||||
import no.iktdev.eventi.models.store.PersistedEvent
|
import no.iktdev.eventi.models.store.PersistedEvent
|
||||||
|
import no.iktdev.mediaprocessing.shared.common.dto.CurrentState
|
||||||
import no.iktdev.mediaprocessing.shared.common.dto.Mode
|
import no.iktdev.mediaprocessing.shared.common.dto.Mode
|
||||||
import no.iktdev.mediaprocessing.shared.common.dto.SequenceSummary
|
import no.iktdev.mediaprocessing.shared.common.dto.SequenceSummary
|
||||||
import no.iktdev.mediaprocessing.shared.common.event_task_contract.events.CollectedEvent
|
import no.iktdev.mediaprocessing.shared.common.event_task_contract.events.CollectedEvent
|
||||||
@ -46,6 +47,10 @@ class SequenceAggregatorService() {
|
|||||||
|
|
||||||
val projection = CollectProjection(domainEvents)
|
val projection = CollectProjection(domainEvents)
|
||||||
|
|
||||||
|
val state = if (events.any { it.event == CollectedEvent::class.java.simpleName }) {
|
||||||
|
if (projection.isStorePermitted()) CurrentState.Continuing else CurrentState.OnHold
|
||||||
|
} else CurrentState.Continuing
|
||||||
|
|
||||||
return SequenceSummary(
|
return SequenceSummary(
|
||||||
referenceId = last.referenceId.toString(),
|
referenceId = last.referenceId.toString(),
|
||||||
title = "",
|
title = "",
|
||||||
@ -62,6 +67,7 @@ class SequenceAggregatorService() {
|
|||||||
StartFlow.Manual -> Mode.Manual
|
StartFlow.Manual -> Mode.Manual
|
||||||
else -> Mode.Auto
|
else -> Mode.Auto
|
||||||
},
|
},
|
||||||
|
currentState = state,
|
||||||
hasErrors = projection.getTaskStatus().any { it == CollectProjection.TaskStatus.Failed }
|
hasErrors = projection.getTaskStatus().any { it == CollectProjection.TaskStatus.Failed }
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -16,6 +16,7 @@ data class SequenceSummary(
|
|||||||
val convertTaskStatus: CollectProjection.TaskStatus,
|
val convertTaskStatus: CollectProjection.TaskStatus,
|
||||||
val coverDownloadTaskStatus: CollectProjection.TaskStatus,
|
val coverDownloadTaskStatus: CollectProjection.TaskStatus,
|
||||||
val mode: Mode,
|
val mode: Mode,
|
||||||
|
val currentState: CurrentState,
|
||||||
val hasErrors: Boolean,
|
val hasErrors: Boolean,
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -28,3 +29,8 @@ enum class Mode {
|
|||||||
Auto,
|
Auto,
|
||||||
Manual
|
Manual
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enum class CurrentState {
|
||||||
|
Continuing,
|
||||||
|
OnHold
|
||||||
|
}
|
||||||
@ -41,9 +41,13 @@ class CollectProjection(val events: List<Event>) {
|
|||||||
coverDownloadTaskStatus
|
coverDownloadTaskStatus
|
||||||
)
|
)
|
||||||
|
|
||||||
fun canStoreAutomatically(): Boolean {
|
fun isStorePermitted(): Boolean {
|
||||||
val manualEvent = events.filterIsInstance<StartProcessingEvent>().lastOrNull()
|
val isAuto = events.filterIsInstance<StartProcessingEvent>().lastOrNull()?.data?.flow == StartFlow.Auto
|
||||||
return manualEvent?.data?.flow != StartFlow.Manual
|
if (isAuto) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
val anyAllow = events.filterIsInstance<ManualAllowCompletionEvent>().lastOrNull()
|
||||||
|
return anyAllow != null
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun projectUseFile(): File? {
|
private fun projectUseFile(): File? {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user