Skip to content

Commit

Permalink
Merge branch 'release/3.6.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
zambrovski committed Dec 7, 2022
2 parents 680f0c6 + 166ede2 commit 14a5151
Show file tree
Hide file tree
Showing 102 changed files with 2,643 additions and 1,466 deletions.
2 changes: 2 additions & 0 deletions .github/release-notes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ changelog:
sections:
- title: ":rocket: Enhancements & Features"
labels: [ "Type: enhancement", "Type: documentation", "Type: example" ]
- title: ":zap: Breaking Changes"
labels: [ "Type: breaking" ]
- title: ":bug: Bug Fixes"
labels: [ "Type: bug" ]
- title: ":hammer_and_wrench: Chore"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/codacy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,6 @@ jobs:

# Upload the SARIF file generated in the previous step
- name: Upload SARIF results file
uses: github/codeql-action/upload-sarif@v1
uses: github/codeql-action/upload-sarif@v2
with:
sarif_file: results.sarif
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.5.0</version>
<version>3.6.0</version>
<relativePath>../parent/pom.xml</relativePath>
</parent>

Expand Down
18 changes: 16 additions & 2 deletions 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.5.0</version>
<version>3.6.0</version>
<relativePath>../../pom.xml</relativePath>
</parent>

Expand All @@ -32,6 +32,7 @@

<pattern.class.itest>**/*ITest.*</pattern.class.itest>
<pattern.package.itest>**/itest/**/*.*</pattern.package.itest>
<jgiven-kotlin.version>1.2.4.0</jgiven-kotlin.version>
</properties>

<modules>
Expand Down Expand Up @@ -240,6 +241,13 @@
<version>${jgiven.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.toolisticon.testing</groupId>
<artifactId>jgiven-kotlin</artifactId>
<scope>test</scope>
<version>${jgiven-kotlin.version}</version>
</dependency>


</dependencies>
</dependencyManagement>
Expand Down Expand Up @@ -268,6 +276,12 @@
<artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
Expand Down Expand Up @@ -441,7 +455,7 @@
<!-- for loading and unpacking artifacts -->
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>3.3.0</version>
<version>3.4.0</version>
</plugin>

<plugin>
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.5.0</version>
<version>3.6.0</version>
<relativePath>../parent/pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion core/bus-jackson/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.5.0</version>
<version>3.6.0</version>
<relativePath>../../bom/parent/pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion 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.5.0</version>
<version>3.6.0</version>
</parent>

<artifactId>polyflow-datapool-api</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion 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.5.0</version>
<version>3.6.0</version>
</parent>

<artifactId>polyflow-datapool-core</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,7 @@ import org.springframework.context.annotation.Import
CreateOrUpdateCommandHandler::class,
DataEntryCreatedEventUpcaster::class
)
class DataPoolCoreAxonConfiguration(
deletionStrategy: DeletionStrategy
) {
class DataPoolCoreAxonConfiguration {
companion object : KLogging() {
const val DATA_ENTRY_REPOSITORY = "dataEntryEventSourcingRepository"
const val DATA_ENTRY_SNAPSHOTTER = "dataEntrySnapshotter"
Expand Down
2 changes: 1 addition & 1 deletion core/datapool/datapool-event/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-datapool-parent</artifactId>
<version>3.5.0</version>
<version>3.6.0</version>
</parent>

<artifactId>polyflow-datapool-event</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion core/datapool/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-parent</artifactId>
<version>3.5.0</version>
<version>3.6.0</version>
<relativePath>../../bom/parent/pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion core/taskpool/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-parent</artifactId>
<version>3.5.0</version>
<version>3.6.0</version>
<relativePath>../../bom/parent/pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion core/taskpool/taskpool-api/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-taskpool-parent</artifactId>
<version>3.5.0</version>
<version>3.6.0</version>
</parent>

<artifactId>polyflow-taskpool-api</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,11 @@ interface CamundaTaskEventType {
const val DELETE = "delete"
const val COMPLETE = "complete"
const val ATTRIBUTES = "attribute-update"
const val ATTRIBUTES_LISTENER_UPDATE = "attribute-listener-update"
const val CANDIDATE_GROUP_ADD = "candidate-group-add"
const val CANDIDATE_GROUP_DELETE = "candidate-group-delete"
const val CANDIDATE_USER_ADD = "candidate-user-add"
const val CANDIDATE_USER_DELETE = "candidate-user-delete"
const val BATCH = "batch"
}
}
Original file line number Diff line number Diff line change
@@ -1,16 +1,29 @@
package io.holunda.camunda.taskpool.api.task

// defines a partial order on EngineTaskCommand
/**
* Create can carry almost everything of changes.
*/
const val ORDER_TASK_CREATION = -3

/**
* Complete can carry assignee.
*/
const val ORDER_TASK_COMPLETION = -2
const val ORDER_TASK_DELETION = -1
const val ORDER_TASK_ASSIGNMENT = 0
const val ORDER_TASK_CANDIDATES_UPDATE = 1
const val ORDER_TASK_ATTRIBUTE_UPDATE = 2
const val ORDER_TASK_BATCH = 100

/**
* Special command that is never an intent, but is used for enrichment of other commands.
*/
const val ORDER_TASK_HISTORIC_ATTRIBUTE_UPDATE = 10


/**
* Provides an ordering for EngineTaskCommand based on their order property.
* This is used to determine the intent of the command batch.
*/
class EngineTaskCommandSorter : Comparator<EngineTaskCommand> {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import io.holunda.camunda.taskpool.api.business.CorrelationMap
import io.holunda.camunda.taskpool.api.business.newCorrelations
import io.holunda.camunda.taskpool.api.task.CamundaTaskEventType.Companion.ASSIGN
import io.holunda.camunda.taskpool.api.task.CamundaTaskEventType.Companion.ATTRIBUTES
import io.holunda.camunda.taskpool.api.task.CamundaTaskEventType.Companion.BATCH
import io.holunda.camunda.taskpool.api.task.CamundaTaskEventType.Companion.CANDIDATE_GROUP_ADD
import io.holunda.camunda.taskpool.api.task.CamundaTaskEventType.Companion.CANDIDATE_GROUP_DELETE
import io.holunda.camunda.taskpool.api.task.CamundaTaskEventType.Companion.CANDIDATE_USER_ADD
Expand Down Expand Up @@ -187,10 +188,6 @@ data class UpdateAttributeTaskCommand(
* Enrichment flag.
*/
override var enriched: Boolean = false,
/**
* Form key used to create a task URL.
*/
override val formKey: String? = null,
/**
* Optional task name.
*/
Expand All @@ -216,7 +213,7 @@ data class UpdateAttributeTaskCommand(
*/
val priority: Int?,

) : TaskIdentityWithPayloadAndCorrelations, EngineTaskCommand, WithFormKey
) : TaskIdentityWithPayloadAndCorrelations, EngineTaskCommand


/**
Expand Down Expand Up @@ -286,3 +283,77 @@ data class DeleteCandidateUsersCommand(
candidateUsers = candidateUsers,
candidateGroups = setOf()
)

/**
* A special command to detect changes originated from TaskListeners.
* This command has no command handler in the core and is never sent to it.
* There is currently no way to detect those changes than collecting the history Camunda event and use details to enrich the original intent.
*/
data class UpdateAttributesHistoricTaskCommand(
@TargetAggregateIdentifier
override val id: String,

override val order: Int = ORDER_TASK_HISTORIC_ATTRIBUTE_UPDATE,
override val eventName: String = CamundaTaskEventType.ATTRIBUTES_LISTENER_UPDATE,
/**
* Source reference, indicating why this task exists.
*/
override val sourceReference: SourceReference,
/**
* Task definition key aka task type.
*/
override val taskDefinitionKey: String,
/**
* Business key of the underlying process instance. Will be ignored, since there is neither a reason to change a business key
* nor an easy way to get the changed one.
*/
override val businessKey: String? = null,
/**
* Task payload.
*/
override val payload: VariableMap = Variables.createVariables(),
/**
* Task correlations.
*/
override val correlations: CorrelationMap = newCorrelations(),
/**
* Enrichment flag.
*/
override var enriched: Boolean = false,
/**
* Optional task name.
*/
val description: String?,
/**
* Optional task due date.
*/
val dueDate: Date? = null,
/**
* Optional task follow-up date.
*/
val followUpDate: Date? = null,
/**
* Optional task name.
*/
val name: String?,
/**
* Optional task owner (assignee).
*/
val owner: String?,
/**
* Optional task priority.
*/
val priority: Int?,

) : TaskIdentityWithPayloadAndCorrelations, EngineTaskCommand

/**
* A batch command to be able to transmit several commands in one unit of work.s
*/
data class BatchCommand(
@TargetAggregateIdentifier
override val id: String,
val commands: List<EngineTaskCommand> = listOf(),
override val order: Int = ORDER_TASK_CANDIDATES_UPDATE,
override val eventName: String = BATCH
) : EngineTaskCommand
2 changes: 1 addition & 1 deletion core/taskpool/taskpool-core/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-taskpool-parent</artifactId>
<version>3.5.0</version>
<version>3.6.0</version>
</parent>

<artifactId>polyflow-taskpool-core</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ fun <T : Any> EventSourcingRepository<T>.loadOptional(id: String): Optional<Aggr
/**
* Extending optional to be able to react on presence and absence with kotlin callback functions.
* @param presentConsumer consumer if present.
* @param missingCallback callback if absend.
* @param missingCallback callback if absent.
*/
fun <T> Optional<T>.ifPresentOrElse(presentConsumer: (T) -> Unit, missingCallback: () -> Unit) {
if (this.isPresent) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
package io.holunda.polyflow.taskpool.core.task

import io.holunda.camunda.taskpool.api.task.BatchCommand
import io.holunda.camunda.taskpool.api.task.CreateTaskCommand
import io.holunda.polyflow.taskpool.core.ifPresentOrElse
import io.holunda.polyflow.taskpool.core.loadOptional
import org.axonframework.commandhandling.CommandHandler
import org.axonframework.commandhandling.GenericCommandMessage
import org.axonframework.eventsourcing.EventSourcingRepository
import org.axonframework.messaging.MetaData
import org.axonframework.messaging.unitofwork.BatchingUnitOfWork
import org.axonframework.messaging.unitofwork.DefaultUnitOfWork
import org.springframework.context.annotation.Lazy
import org.springframework.stereotype.Component

/**
* Handler allowing to re-submit a create command for already existing task.
*/
@Component
class ExternalCommandHandler(
@Lazy
val eventSourcingRepository: EventSourcingRepository<TaskAggregate>
) {

/**
* Create a new aggregate (default) or load existing and replay the creation command if already there.
*/
@CommandHandler
fun create(command: CreateTaskCommand, metadata: MetaData) {
eventSourcingRepository.loadOptional(command.id).ifPresentOrElse(
presentConsumer = { aggregate -> aggregate.handle(GenericCommandMessage(command, metadata)) },
missingCallback = { eventSourcingRepository.newInstance { TaskAggregate() }.handle(GenericCommandMessage(command, metadata)) }
)
}

/**
* Delivers a batch.
* @param batch batch command.
*/
@CommandHandler
fun handleBatch(batch: BatchCommand, metadata: MetaData) {
eventSourcingRepository.loadOptional(batch.id).ifPresentOrElse(
presentConsumer = { aggregate ->
aggregate
.apply {
batch.commands.forEach { command ->
val message = GenericCommandMessage(command, metadata)
val handling = { handle(message) }
val uow = DefaultUnitOfWork.startAndGet(message)
uow.executeWithResult(handling)
}
}
},
missingCallback = {
eventSourcingRepository.newInstance { TaskAggregate() }
.apply { batch.commands.forEach { command -> handle(GenericCommandMessage(command, metadata)) } }
}
)
}
}
Loading

0 comments on commit 14a5151

Please sign in to comment.