-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
66 changed files
with
863 additions
and
170 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
...kpool-api/src/main/kotlin/io/holunda/camunda/taskpool/api/task/EngineTaskCommandFilter.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package io.holunda.camunda.taskpool.api.task | ||
|
||
import java.util.function.Predicate | ||
|
||
/** | ||
* Filter for task commands. | ||
*/ | ||
interface EngineTaskCommandFilter : Predicate<EngineTaskCommand> { | ||
/** | ||
* Tests if the task command should be sent. | ||
* @param engineTaskCommand commend to test. | ||
* @return true, if command should be emitted. Defaults to false. | ||
*/ | ||
override fun test(engineTaskCommand: EngineTaskCommand): Boolean = false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
...ain/kotlin/io/holunda/polyflow/taskpool/core/task/TaskAggregateEngineTaskCommandFilter.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package io.holunda.polyflow.taskpool.core.task | ||
|
||
import io.holunda.camunda.taskpool.api.task.CreateTaskCommand | ||
import io.holunda.camunda.taskpool.api.task.EngineTaskCommand | ||
import io.holunda.camunda.taskpool.api.task.EngineTaskCommandFilter | ||
import io.holunda.polyflow.taskpool.core.loadOptional | ||
import org.axonframework.eventsourcing.EventSourcingRepository | ||
import org.axonframework.messaging.GenericMessage | ||
import org.axonframework.messaging.unitofwork.DefaultUnitOfWork | ||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty | ||
import org.springframework.stereotype.Component | ||
|
||
/** | ||
* Filter checking the tasks in the event store. | ||
*/ | ||
@Component | ||
@ConditionalOnProperty( | ||
prefix = "polyflow.integration.collector.camunda.task.importer", | ||
name = ["task-filter-type"], | ||
havingValue = "eventstore", | ||
matchIfMissing = false | ||
) | ||
class TaskAggregateEngineTaskCommandFilter( | ||
private val eventSourcingRepository: EventSourcingRepository<TaskAggregate> | ||
) : EngineTaskCommandFilter { | ||
|
||
override fun test(engineTaskCommand: EngineTaskCommand): Boolean { | ||
return when (engineTaskCommand) { | ||
|
||
is CreateTaskCommand -> { | ||
|
||
DefaultUnitOfWork.startAndGet(GenericMessage.asMessage(engineTaskCommand)).executeWithResult { | ||
eventSourcingRepository.loadOptional(engineTaskCommand.id) | ||
.map { false } // if the task exists, the CreateCommand should not be emitted | ||
.orElse(true) // if the task doesn't exist, emit the CreateTaskCommand | ||
}.payload | ||
|
||
} | ||
|
||
else -> false // reject all others | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.