-
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
52 changed files
with
676 additions
and
220 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
17 changes: 17 additions & 0 deletions
17
...tapool-api/src/test/kotlin/io/holunda/camunda/taskpool/api/business/ProcessingTypeTest.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,17 @@ | ||
package io.holunda.camunda.taskpool.api.business | ||
|
||
import org.assertj.core.api.Assertions.assertThat | ||
import org.junit.jupiter.api.Test | ||
|
||
internal class ProcessingTypeTest { | ||
|
||
@Test | ||
fun `creates processing type`() { | ||
assertThat(ProcessingType.PRELIMINARY.of("draft")).isEqualTo(DataEntryStateImpl(processingType = ProcessingType.PRELIMINARY, state = "draft")) | ||
assertThat(ProcessingType.IN_PROGRESS.of("doing")).isEqualTo(DataEntryStateImpl(processingType = ProcessingType.IN_PROGRESS, state = "doing")) | ||
assertThat(ProcessingType.COMPLETED.of("done")).isEqualTo(DataEntryStateImpl(processingType = ProcessingType.COMPLETED, state = "done")) | ||
assertThat(ProcessingType.DELETED.of("thrashed")).isEqualTo(DataEntryStateImpl(processingType = ProcessingType.DELETED, state = "thrashed")) | ||
assertThat(ProcessingType.CANCELLED.of("rejected")).isEqualTo(DataEntryStateImpl(processingType = ProcessingType.CANCELLED, state = "rejected")) | ||
assertThat(ProcessingType.UNDEFINED.of("custom")).isEqualTo(DataEntryStateImpl(processingType = ProcessingType.UNDEFINED, state = "custom")) | ||
} | ||
} |
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
104 changes: 104 additions & 0 deletions
104
...l-core/src/main/kotlin/io/holunda/polyflow/datapool/core/DataPoolCoreAxonConfiguration.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,104 @@ | ||
package io.holunda.polyflow.datapool.core | ||
|
||
import io.holunda.polyflow.datapool.core.business.CreateOrUpdateCommandHandler | ||
import io.holunda.polyflow.datapool.core.business.DataEntryAggregate | ||
import io.holunda.polyflow.datapool.core.business.upcaster.DataEntryCreatedEventUpcaster | ||
import io.holunda.polyflow.datapool.core.repository.FirstEventOnlyEventSourcingRepository | ||
import mu.KLogging | ||
import org.axonframework.common.caching.Cache | ||
import org.axonframework.common.caching.WeakReferenceCache | ||
import org.axonframework.eventsourcing.EventCountSnapshotTriggerDefinition | ||
import org.axonframework.eventsourcing.EventSourcingRepository | ||
import org.axonframework.eventsourcing.SnapshotTriggerDefinition | ||
import org.axonframework.eventsourcing.Snapshotter | ||
import org.axonframework.eventsourcing.eventstore.EventStore | ||
import org.axonframework.messaging.annotation.ParameterResolverFactory | ||
import org.springframework.beans.factory.annotation.Qualifier | ||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty | ||
import org.springframework.context.annotation.Bean | ||
import org.springframework.context.annotation.Configuration | ||
import org.springframework.context.annotation.Import | ||
|
||
|
||
/** | ||
* Configuration of polyflow data pool core axon setup. | ||
*/ | ||
@Configuration | ||
@Import( | ||
DataEntryAggregate::class, | ||
CreateOrUpdateCommandHandler::class, | ||
DataEntryCreatedEventUpcaster::class | ||
) | ||
class DataPoolCoreAxonConfiguration( | ||
deletionStrategy: DeletionStrategy | ||
) { | ||
companion object : KLogging() { | ||
const val DATA_ENTRY_REPOSITORY = "dataEntryEventSourcingRepository" | ||
const val DATA_ENTRY_SNAPSHOTTER = "dataEntrySnapshotter" | ||
const val DATA_ENTRY_CACHE = "dataEntryCache" | ||
} | ||
|
||
/** | ||
* Provides an event sourcing repository for data entry aggregates that creates the aggregate and uses the first event in the stream only. | ||
* This repository avoids loading of all events and will avoid usage of snapshots. | ||
*/ | ||
@ConditionalOnProperty( | ||
name = ["polyflow.core.data-entry.event-sourcing-repository-type"], | ||
havingValue = "io.holunda.polyflow.datapool.core.repository.FirstEventOnlyEventSourcingRepository" | ||
) | ||
@Bean(DATA_ENTRY_REPOSITORY) | ||
fun firstEventDataEntryAggregateRepository( | ||
eventStore: EventStore, | ||
factory: ParameterResolverFactory, | ||
@Qualifier(DATA_ENTRY_CACHE) dataEntryCache: Cache, | ||
@Qualifier(DATA_ENTRY_SNAPSHOTTER) dataEntryAggregateSnapshotterTriggerDefinition: SnapshotTriggerDefinition | ||
): EventSourcingRepository<DataEntryAggregate> { | ||
return FirstEventOnlyEventSourcingRepository | ||
.builder(DataEntryAggregate::class.java) | ||
.parameterResolverFactory(factory) | ||
.cache(dataEntryCache) | ||
.snapshotTriggerDefinition(dataEntryAggregateSnapshotterTriggerDefinition) | ||
.eventStore(eventStore) | ||
.build() | ||
} | ||
|
||
/** | ||
* Provides a standard event sourcing repository for data entry aggregate. | ||
*/ | ||
@ConditionalOnProperty( | ||
name = ["polyflow.core.data-entry.event-sourcing-repository-type"], | ||
havingValue = "org.axonframework.eventsourcing.EventSourcingRepository", | ||
matchIfMissing = true | ||
) | ||
@Bean(DATA_ENTRY_REPOSITORY) | ||
fun dataEntryAggregateRepository( | ||
eventStore: EventStore, | ||
factory: ParameterResolverFactory, | ||
@Qualifier(DATA_ENTRY_CACHE) dataEntryCache: Cache, | ||
@Qualifier(DATA_ENTRY_SNAPSHOTTER) dataEntryAggregateSnapshotterTriggerDefinition: SnapshotTriggerDefinition | ||
): EventSourcingRepository<DataEntryAggregate> { | ||
return EventSourcingRepository | ||
.builder(DataEntryAggregate::class.java) | ||
.parameterResolverFactory(factory) | ||
.cache(dataEntryCache) | ||
.snapshotTriggerDefinition(dataEntryAggregateSnapshotterTriggerDefinition) | ||
.eventStore(eventStore) | ||
.build() | ||
} | ||
|
||
/** | ||
* Register snapshotter. It will trigger if the aggregate is loaded by the series of events and the series is exceeding the snapshot. | ||
* This is the case by the standard [EventSourcingRepository] is used, but will never happen if the [FirstEventOnlyEventSourcingRepository] is used. | ||
*/ | ||
@Bean(DATA_ENTRY_SNAPSHOTTER) | ||
fun dataEntryAggregateSnapshotterTriggerDefinition(snapshotter: Snapshotter, dataPoolProperties: DataPoolProperties): SnapshotTriggerDefinition { | ||
return EventCountSnapshotTriggerDefinition(snapshotter, dataPoolProperties.snapshotThreshold) | ||
} | ||
|
||
/** | ||
* Use weak reference cache. | ||
*/ | ||
@Bean(DATA_ENTRY_CACHE) | ||
fun dataEntryCache(): Cache = WeakReferenceCache() | ||
} | ||
|
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.