Skip to content

Commit

Permalink
feat(camunda 7.20): WIP camunda 7.20, spring boot 3, java 17
Browse files Browse the repository at this point in the history
  • Loading branch information
janvonneree committed Oct 10, 2023
1 parent c9161f2 commit 7957ebc
Show file tree
Hide file tree
Showing 10 changed files with 86 additions and 68 deletions.
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
package io.holunda.polyflow.example.infrastructure.jpa

import org.hibernate.boot.model.TypeContributions
import org.hibernate.dialect.H2Dialect
import org.hibernate.service.ServiceRegistry
import org.hibernate.type.descriptor.sql.internal.DdlTypeImpl
import java.sql.Types

class FixedH2Dialect : H2Dialect() {
init {
// registerColumnType(Types.VARBINARY, "bytea")
registerColumnType(Types.BLOB, "bytea")
// registerColumnType(Types.LONGVARBINARY, "bytea");

override fun registerColumnTypes(typeContributions: TypeContributions, serviceRegistry: ServiceRegistry) {
super.registerColumnTypes(typeContributions, serviceRegistry)
val ddlTypeRegistry = typeContributions.typeConfiguration.ddlTypeRegistry
ddlTypeRegistry.addDescriptor(DdlTypeImpl(Types.BLOB, "bytea", this))
ddlTypeRegistry.addDescriptor(DdlTypeImpl(Types.CLOB, "bytea", this))
ddlTypeRegistry.addDescriptor(DdlTypeImpl(Types.NCLOB, "bytea", this))
}

}
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
package io.holunda.polyflow.example.infrastructure.jpa

import org.hibernate.boot.model.TypeContributions
import org.hibernate.dialect.PostgreSQLDialect
import org.hibernate.type.descriptor.sql.BinaryTypeDescriptor
import org.hibernate.type.descriptor.sql.SqlTypeDescriptor
import org.hibernate.service.ServiceRegistry
import org.hibernate.type.descriptor.sql.internal.DdlTypeImpl
import java.sql.Types

class NoToastPostgresSQLDialect : PostgreSQLDialect() {
init {
this.registerColumnType(Types.BLOB, "BYTEA")
}

override fun remapSqlTypeDescriptor(sqlTypeDescriptor: SqlTypeDescriptor): SqlTypeDescriptor {
return if (sqlTypeDescriptor.sqlType == Types.BLOB) {
BinaryTypeDescriptor.INSTANCE
} else super.remapSqlTypeDescriptor(sqlTypeDescriptor)
override fun registerColumnTypes(typeContributions: TypeContributions, serviceRegistry: ServiceRegistry) {
super.registerColumnTypes(typeContributions, serviceRegistry)
val ddlTypeRegistry = typeContributions.typeConfiguration.ddlTypeRegistry
ddlTypeRegistry.addDescriptor(DdlTypeImpl(Types.BLOB, "bytea", this))
ddlTypeRegistry.addDescriptor(DdlTypeImpl(Types.CLOB, "bytea", this))
ddlTypeRegistry.addDescriptor(DdlTypeImpl(Types.NCLOB, "bytea", this))
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,13 @@ class ProcessApproveRequestSPAConfiguration(
.allowedOrigins("http://localhost:4200")
.allowedOrigins("http://localhost:4300")
.allowedMethods(
HttpMethod.GET.name,
HttpMethod.HEAD.name,
HttpMethod.POST.name,
HttpMethod.DELETE.name,
HttpMethod.OPTIONS.name,
HttpMethod.PATCH.name,
HttpMethod.PUT.name
HttpMethod.GET.name(),
HttpMethod.HEAD.name(),
HttpMethod.POST.name(),
HttpMethod.DELETE.name(),
HttpMethod.OPTIONS.name(),
HttpMethod.PATCH.name(),
HttpMethod.PUT.name()
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@ import io.holunda.polyflow.example.process.approval.process.RequestApprovalProce
import io.holunda.polyflow.example.process.approval.process.RequestApprovalProcess.Variables.ORIGINATOR
import io.holunda.polyflow.example.process.approval.process.RequestApprovalProcess.Variables.PROJECTION_REVISION
import io.holunda.polyflow.example.process.approval.process.RequestApprovalProcess.Variables.REQUEST_ID
import io.holunda.polyflow.example.process.approval.service.*
import io.holunda.polyflow.example.process.approval.service.BusinessDataEntry
import io.holunda.polyflow.example.process.approval.service.Request
import io.holunda.polyflow.example.process.approval.service.RequestService
import io.holunda.polyflow.taskpool.collector.task.TaskEventCollectorService
import org.camunda.bpm.engine.delegate.DelegateExecution
import org.camunda.bpm.engine.delegate.DelegateTask
Expand All @@ -32,7 +33,6 @@ import org.springframework.context.event.EventListener
import org.springframework.core.annotation.Order
import org.springframework.stereotype.Component
import java.time.OffsetDateTime
import java.util.*

@Component
class RequestStatusListener(
Expand Down Expand Up @@ -182,6 +182,6 @@ class RequestStatusListener(
return newRevision
}

private fun getRevision(variableScope: VariableScope): Long = PROJECTION_REVISION.from(variableScope).optional.orElseGet { 0L }
private fun getRevision(variableScope: VariableScope): Long = PROJECTION_REVISION.from(variableScope).getOrDefault(0L)

}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package io.holunda.polyflow.example.process.approval.process

import io.holunda.camunda.bpm.data.CamundaBpmDataKotlin.customVariable
import io.holunda.camunda.bpm.data.CamundaBpmData.longVariable
import io.holunda.camunda.bpm.data.CamundaBpmData.stringVariable
import io.holunda.camunda.bpm.data.CamundaBpmDataKotlin.longVariable
import io.holunda.camunda.bpm.data.CamundaBpmDataKotlin.stringVariable
import java.math.BigDecimal

object RequestApprovalProcess {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package io.holunda.polyflow.example.process.approval.process

import io.holunda.camunda.bpm.data.CamundaBpmData.builder
import io.holunda.camunda.taskpool.api.task.ProcessReference
import io.holunda.camunda.taskpool.api.task.TaskToBeCompletedEvent
import io.holunda.polyflow.example.process.approval.process.RequestApprovalProcess.Values.RESUBMIT
import io.holunda.polyflow.example.process.approval.process.RequestApprovalProcess.Variables.AMEND_ACTION
import io.holunda.polyflow.example.process.approval.process.RequestApprovalProcess.Variables.APPROVE_DECISION
Expand All @@ -13,12 +11,9 @@ import io.holunda.polyflow.example.process.approval.process.RequestApprovalProce
import io.holunda.polyflow.example.process.approval.service.Request
import io.holunda.polyflow.example.process.approval.service.RequestService
import org.axonframework.commandhandling.CommandHandler
import org.axonframework.eventhandling.gateway.EventGateway
import org.camunda.bpm.engine.RuntimeService
import org.camunda.bpm.engine.TaskService
import org.camunda.bpm.engine.task.Task
import org.camunda.bpm.engine.variable.Variables.createVariables
import org.springframework.beans.factory.annotation.Value
import org.springframework.stereotype.Component
import org.springframework.transaction.annotation.Propagation
import org.springframework.transaction.annotation.Transactional
Expand Down Expand Up @@ -78,8 +73,11 @@ class RequestApprovalProcessBean(
taskService.complete(
task.id,
builder()
.set(APPROVE_DECISION, decision.uppercase(Locale.getDefault()))
.set(COMMENT, comment)
.set(APPROVE_DECISION, decision.uppercase(Locale.getDefault())).apply {
if (comment != null) {
this.set(COMMENT, comment)
}
}
.build()
)
}
Expand Down Expand Up @@ -110,8 +108,11 @@ class RequestApprovalProcessBean(
}

val variables = builder()
.set(AMEND_ACTION, action.uppercase(Locale.getDefault()))
.set(COMMENT, comment)
.set(AMEND_ACTION, action.uppercase(Locale.getDefault())).apply {
if (comment != null) {
this.set(COMMENT, comment)
}
}


if (action == RESUBMIT) {
Expand Down Expand Up @@ -160,9 +161,13 @@ class RequestApprovalProcessBean(
.initializeFormKeys()
.singleResult() ?: throw NoSuchElementException("Task with id $taskId not found.")

val requestId = REQUEST_ID.from(runtimeService, task.executionId).optional.orElseThrow { NoSuchElementException("Request id could not be found for task $taskId") }
val requestId =
REQUEST_ID.from(runtimeService, task.executionId).getOptional().orElseThrow { NoSuchElementException("Request id could not be found for task $taskId") }
val revision =
PROJECTION_REVISION.from(runtimeService, task.executionId).optional.orElseThrow { NoSuchElementException("Project revision could not be found for task $taskId") }
PROJECTION_REVISION.from(
runtimeService,
task.executionId
).getOptional().orElseThrow { NoSuchElementException("Project revision could not be found for task $taskId") }

val request = this.requestService.getRequest(requestId, revision)
return TaskAndRequest(task = task, approvalRequest = request)
Expand Down Expand Up @@ -192,11 +197,11 @@ class RequestApprovalProcessBean(

@CommandHandler
fun changeAssignment(command: AssignmentCommand) {
command.newCandidateUsers.forEach { user -> taskService.addCandidateUser(command.taskId, user) }
command.newCandidateGroups.forEach { group -> taskService.addCandidateGroup(command.taskId, group) }
command.deleteCandidateUsers.forEach { user -> taskService.deleteCandidateUser(command.taskId, user) }
command.deleteCandidateGroups.forEach { group -> taskService.deleteCandidateGroup(command.taskId, group) }
command.deleteCandidateGroups.forEach { group -> taskService.deleteCandidateGroup(command.taskId, group) }
command.newCandidateUsers.forEach { user -> taskService.addCandidateUser(command.taskId, user) }
command.newCandidateGroups.forEach { group -> taskService.addCandidateGroup(command.taskId, group) }
command.deleteCandidateUsers.forEach { user -> taskService.deleteCandidateUser(command.taskId, user) }
command.deleteCandidateGroups.forEach { group -> taskService.deleteCandidateGroup(command.taskId, group) }
command.deleteCandidateGroups.forEach { group -> taskService.deleteCandidateGroup(command.taskId, group) }
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package io.holunda.polyflow.example.process.approval.service.impl.datajpa

import jakarta.persistence.Column
import jakarta.persistence.Entity
import jakarta.persistence.Id
import jakarta.persistence.Table
import java.math.BigDecimal
import javax.persistence.Column
import javax.persistence.Entity
import javax.persistence.Id
import javax.persistence.Table

@Entity
@Table(name = "APP_APPROVAL_REQUEST")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
package io.holunda.polyflow.example.process.approval.service.impl.datajpa

import org.springframework.data.repository.PagingAndSortingRepository
import java.util.*

/**
* Spring Data JPA repository.
*/
interface RequestEntityRepository : PagingAndSortingRepository<RequestEntity, String>
interface RequestEntityRepository : PagingAndSortingRepository<RequestEntity, String> {

fun save(requestEntity: RequestEntity): RequestEntity
fun findAll(): List<RequestEntity>
fun findById(id: String): Optional<RequestEntity>
fun existsById(id: String): Boolean
}

Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
package io.holunda.polyflow.example.infrastructure

import org.hibernate.dialect.PostgreSQL94Dialect
import org.hibernate.type.descriptor.sql.BinaryTypeDescriptor
import org.hibernate.type.descriptor.sql.SqlTypeDescriptor
import org.hibernate.boot.model.TypeContributions
import org.hibernate.dialect.PostgreSQLDialect
import org.hibernate.service.ServiceRegistry
import org.hibernate.type.descriptor.sql.internal.DdlTypeImpl
import java.sql.Types

class NoToastPostgresSQLDialect : PostgreSQL94Dialect() {
init {
this.registerColumnType(Types.BLOB, "BYTEA")
}
class NoToastPostgresSQLDialect : PostgreSQLDialect() {

override fun remapSqlTypeDescriptor(sqlTypeDescriptor: SqlTypeDescriptor): SqlTypeDescriptor {
return if (sqlTypeDescriptor.sqlType == Types.BLOB) {
BinaryTypeDescriptor.INSTANCE
} else super.remapSqlTypeDescriptor(sqlTypeDescriptor)
override fun registerColumnTypes(typeContributions: TypeContributions, serviceRegistry: ServiceRegistry) {
super.registerColumnTypes(typeContributions, serviceRegistry)
val ddlTypeRegistry = typeContributions.typeConfiguration.ddlTypeRegistry
ddlTypeRegistry.addDescriptor(DdlTypeImpl(Types.BLOB, "bytea", this))
ddlTypeRegistry.addDescriptor(DdlTypeImpl(Types.CLOB, "bytea", this))
ddlTypeRegistry.addDescriptor(DdlTypeImpl(Types.NCLOB, "bytea", this))
}
}
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
package io.holunda.polyflow.example.process.infrastructure

import org.hibernate.dialect.PostgreSQL94Dialect
import org.hibernate.type.descriptor.sql.BinaryTypeDescriptor
import org.hibernate.type.descriptor.sql.SqlTypeDescriptor
import org.hibernate.boot.model.TypeContributions
import org.hibernate.dialect.PostgreSQLDialect
import org.hibernate.service.ServiceRegistry
import org.hibernate.type.descriptor.sql.internal.DdlTypeImpl
import java.sql.Types

class NoToastPostgresSQLDialect : PostgreSQL94Dialect() {
init {
this.registerColumnType(Types.BLOB, "BYTEA")
}
class NoToastPostgresSQLDialect : PostgreSQLDialect() {

override fun remapSqlTypeDescriptor(sqlTypeDescriptor: SqlTypeDescriptor): SqlTypeDescriptor {
return if (sqlTypeDescriptor.sqlType == Types.BLOB) {
BinaryTypeDescriptor.INSTANCE
} else super.remapSqlTypeDescriptor(sqlTypeDescriptor)
override fun registerColumnTypes(typeContributions: TypeContributions, serviceRegistry: ServiceRegistry) {
super.registerColumnTypes(typeContributions, serviceRegistry)
val ddlTypeRegistry = typeContributions.typeConfiguration.ddlTypeRegistry
ddlTypeRegistry.addDescriptor(DdlTypeImpl(Types.BLOB, "bytea", this))
ddlTypeRegistry.addDescriptor(DdlTypeImpl(Types.CLOB, "bytea", this))
ddlTypeRegistry.addDescriptor(DdlTypeImpl(Types.NCLOB, "bytea", this))
}
}

0 comments on commit 7957ebc

Please sign in to comment.