Skip to content

Commit

Permalink
Merge branch 'release/3.4.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
zambrovski committed Nov 23, 2022
2 parents 1d0e1bf + 7cf7874 commit 7ae517e
Show file tree
Hide file tree
Showing 52 changed files with 676 additions and 220 deletions.
2 changes: 1 addition & 1 deletion bom/datapool-dependencies/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>io.holunda.polyflow</groupId>
<artifactId>polyflow-parent</artifactId>
<version>3.4.1</version>
<version>3.4.2</version>
<relativePath>../parent/pom.xml</relativePath>
</parent>

Expand Down
8 changes: 7 additions & 1 deletion bom/parent/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>io.holunda.polyflow</groupId>
<artifactId>polyflow-root</artifactId>
<version>3.4.1</version>
<version>3.4.2</version>
<relativePath>../../pom.xml</relativePath>
</parent>

Expand Down Expand Up @@ -268,6 +268,11 @@
<artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<build>
Expand Down Expand Up @@ -532,6 +537,7 @@
<configuration>
<useSystemClassLoader>false</useSystemClassLoader>
<runOrder>random</runOrder>
<failIfNoTests>true</failIfNoTests>
<excludes>
<exclude>${pattern.class.itest}</exclude>
<exclude>${pattern.package.itest}</exclude>
Expand Down
2 changes: 1 addition & 1 deletion bom/taskpool-dependencies/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>io.holunda.polyflow</groupId>
<artifactId>polyflow-parent</artifactId>
<version>3.4.1</version>
<version>3.4.2</version>
<relativePath>../parent/pom.xml</relativePath>
</parent>

Expand Down
25 changes: 21 additions & 4 deletions core/bus-jackson/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@
<parent>
<groupId>io.holunda.polyflow</groupId>
<artifactId>polyflow-parent</artifactId>
<version>3.4.1</version>
<version>3.4.2</version>
<relativePath>../../bom/parent/pom.xml</relativePath>
</parent>

<artifactId>polyflow-bus-jackson</artifactId>
<name>core/bus/${project.artifactId}</name>

<dependencies>
<!-- Polyflow API -->
<dependency>
<groupId>io.holunda.polyflow</groupId>
<artifactId>polyflow-datapool-api</artifactId>
Expand All @@ -29,6 +30,8 @@
<artifactId>polyflow-view-api</artifactId>
<version>${project.version}</version>
</dependency>

<!-- Jackson -->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
Expand All @@ -44,11 +47,25 @@
<artifactId>jackson-module-kotlin</artifactId>
<scope>provided</scope>
</dependency>

<!-- Spring boot -->
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<scope>test</scope>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-autoconfigure</artifactId>
<scope>provided</scope>
</dependency>

<!-- For test only -->
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jsr310</artifactId>
Expand Down
6 changes: 1 addition & 5 deletions core/datapool/datapool-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>io.holunda.polyflow</groupId>
<artifactId>polyflow-datapool-parent</artifactId>
<version>3.4.1</version>
<version>3.4.2</version>
</parent>

<artifactId>polyflow-datapool-api</artifactId>
Expand All @@ -16,10 +16,6 @@
<groupId>org.axonframework</groupId>
<artifactId>axon-modelling</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.camunda.commons</groupId>
<artifactId>camunda-commons-typed-values</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ data class DataEntryChange(
*/
val entryId: EntryId,
/**
* Human readable type e.g. "purchase order"
* Human-readable type e.g. "purchase order"
*/
val type: String,
/**
* Application name (origin)
*/
val applicationName: String,
/**
* Human readable identifier or name, e.g. "BANF-4711 - TV for meeting room"
* Human-readable identifier or name, e.g. "BANF-4711 - TV for meeting room"
*/
val name: String,
/**
Expand Down
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"))
}
}
7 changes: 1 addition & 6 deletions core/datapool/datapool-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>io.holunda.polyflow</groupId>
<artifactId>polyflow-datapool-parent</artifactId>
<version>3.4.1</version>
<version>3.4.2</version>
</parent>

<artifactId>polyflow-datapool-core</artifactId>
Expand Down Expand Up @@ -55,11 +55,6 @@
<artifactId>axon-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
Expand Down
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()
}

Original file line number Diff line number Diff line change
@@ -1,79 +1,23 @@
package io.holunda.polyflow.datapool.core

import io.holunda.polyflow.datapool.core.business.DataEntryAggregate
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.springframework.boot.autoconfigure.condition.ConditionalOnProperty
import org.springframework.boot.context.properties.EnableConfigurationProperties
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.ComponentScan
import org.springframework.context.annotation.Configuration
import org.springframework.context.annotation.Import


/**
* Configuration of polyflow data pool core.
*/
@Configuration
@ComponentScan
@EnableConfigurationProperties(
DataPoolProperties::class
)
class DataPoolCoreConfiguration {

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): EventSourcingRepository<DataEntryAggregate> {
return FirstEventOnlyEventSourcingRepository.builder(DataEntryAggregate::class.java).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): EventSourcingRepository<DataEntryAggregate> {
return EventSourcingRepository.builder(DataEntryAggregate::class.java).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()

companion object: KLogging()
/**
* Deletion strategy for lax handling of updates after deletion (default).
*/
Expand All @@ -85,6 +29,8 @@ class DataPoolCoreConfiguration {
@Bean
fun laxDeletionStrategy(): DeletionStrategy = object : DeletionStrategy {
override fun strictMode(): Boolean = false
}.also {
logger.info { "Data pool core: using LAX deletion strategy." }
}

/**
Expand All @@ -97,7 +43,9 @@ class DataPoolCoreConfiguration {
)
@Bean
fun strictDeletionStrategy(): DeletionStrategy = object : DeletionStrategy {
override fun strictMode(): Boolean = false
override fun strictMode(): Boolean = true
}.also {
logger.info { "Data pool core: using STRICT deletion strategy." }
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,10 @@ data class DataPoolProperties(
* Defaults to [org.axonframework.eventsourcing.EventSourcingRepository].
* Consider to use [io.holunda.polyflow.datapool.core.repository.FirstEventOnlyEventSourcingRepository] if you want to load the aggregate with first event only.
*/
val eventSourcingRepositoryType: String = EventSourcingRepository::class.java.canonicalName
val eventSourcingRepositoryType: String = EventSourcingRepository::class.java.canonicalName,

/**
* Specifies the deletion strategy for data entries.
*/
val deletionStrategy: DeletionStrategyValue? = DeletionStrategyValue.lax
)
Loading

0 comments on commit 7ae517e

Please sign in to comment.