Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Separate API and add deprications #406

Draft
wants to merge 6 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
.meta-data/
.DS_Store
target/
site/
pom.xml.versionsBackup

# java mem
Expand Down
8 changes: 4 additions & 4 deletions docs/quick-start.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,10 @@ class JavaDelegates {
@Bean
public JavaDelegate calculateOrderPositions() {
return execution -> {
OrderPosition orderPosition = ORDER_POSITION.from(execution).get();
BigDecimal oldTotal = ORDER_TOTAL.from(execution).getOptional().orElse(BigDecimal.ZERO);
OrderPosition orderPosition = VariableScopeReader.of(ORDER_POSITION, execution).get();
BigDecimal oldTotal = VariableScopeReader.of(ORDER_TOTAL, execution).getOptional().orElse(BigDecimal.ZERO);
BigDecimal newTotal = oldTotal.add(orderPosition.getNetCost().multiply(BigDecimal.valueOf(orderPosition.getAmount())));
ORDER_TOTAL.on(execution).setLocal(newTotal);
VariableScopeWriter.of(ORDER_TOTAL, execution).setLocal(newTotal);
};
}
}
Expand Down Expand Up @@ -92,7 +92,7 @@ public class ApproveOrderTaskController {

@GetMapping("/{taskId}")
public ResponseEntity<ApproveTaskDto> loadTask(@PathVariable("taskId") String taskId) {
Order order = ORDER.from(taskService, taskId).get();
Order order = VariableScopeReader.of(ORDER, taskService, taskId).get();
return ResponseEntity.ok(new ApproveTaskDto(order));
}

Expand Down
12 changes: 6 additions & 6 deletions docs/user-guide/examples-kotlin.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class JavaDelegates {

@Bean
fun calculateOrderPositions() = JavaDelegate { execution ->
val orderPosition = ORDER_POSITION.from(execution).get()
val orderPosition = VariableScopeReader.of(ORDER_POSITION, execution).get()
// order position is of type OrderPosition
}
}
Expand All @@ -39,8 +39,8 @@ class JavaDelegates {

@Bean
fun calculateOrderPositions() = JavaDelegate { execution ->
val orderPosition = ORDER_POSITION.from(execution).get()
ORDER_TOTAL.on(execution).set {
val orderPosition = VariableScopeReader.of(ORDER_POSITION, execution).get()
VariableScopeWriter.of(ORDER_TOTAL, execution).set {
orderPosition.netCost.times(BigDecimal.valueOf(orderPosition.amount))
}
}
Expand All @@ -55,7 +55,7 @@ class JavaDelegates {

@Bean
fun removeTotal() = JavaDelegate { execution ->
ORDER_TOTAL.on(execution).remove()
VariableScopeWriter.of(ORDER_TOTAL, execution).remove()
}
}
```
Expand All @@ -69,8 +69,8 @@ class JavaDelegates {

@Bean
fun calculateOrderPositions() = JavaDelegate { execution ->
val orderPosition = ORDER_POSITION.from(execution).get()
ORDER_TOTAL.on(execution).update {
val orderPosition = VariableScopeReader.of(ORDER_POSITION, execution).get()
VariableScopeWriter.of(ORDER_TOTAL, execution).update {
it.plus(orderPosition.netCost.times(BigDecimal.valueOf(orderPosition.amount)))
}
}
Expand Down
6 changes: 3 additions & 3 deletions docs/user-guide/examples-no-engine.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ In the same time, we started a discussion with Camunda Team to provide a dedicat

``` xml
<dependency>
<groupId>io.holunda.camunda-api</groupId>
<artifactId>camunda-bpm-engine-api</artifactId>
<version>${camunda.version}</version>
<groupId>io.holunda.camunda-api</groupId>
<artifactId>camunda-bpm-engine-api</artifactId>
<version>${camunda.version}</version>
</dependency>
```

Expand Down
2 changes: 2 additions & 0 deletions docs/user-guide/motivation.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ This consists of:

* `RuntimeService` methods
* `TaskService` methods
* `CaseService` methods
* `ExernalTaskService` methods
* Methods on `DelegateExecution`
* Methods on `DelegateTask`
* `VariableMap`
Expand Down
4 changes: 2 additions & 2 deletions example/coverage-report-aggregator/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>io.holunda.data.example</groupId>
<artifactId>camunda-bpm-data-example-parent</artifactId>
<version>1.5.1-SNAPSHOT</version>
<version>1.6.0-SNAPSHOT</version>
</parent>

<artifactId>camunda-bpm-data-coverage-report</artifactId>
Expand All @@ -20,7 +20,7 @@
<dependencies>
<dependency>
<groupId>io.holunda.data</groupId>
<artifactId>camunda-bpm-data</artifactId>
<artifactId>camunda-bpm-data-c7</artifactId>
<version>${project.version}</version>
<scope>compile</scope>
</dependency>
Expand Down
2 changes: 1 addition & 1 deletion example/example-java/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>io.holunda.data.example</groupId>
<artifactId>camunda-bpm-data-example-parent</artifactId>
<version>1.5.1-SNAPSHOT</version>
<version>1.6.0-SNAPSHOT</version>
</parent>

<artifactId>camunda-bpm-data-example-java</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion example/example-kotlin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>io.holunda.data.example</groupId>
<artifactId>camunda-bpm-data-example-parent</artifactId>
<version>1.5.1-SNAPSHOT</version>
<version>1.6.0-SNAPSHOT</version>
</parent>

<artifactId>camunda-bpm-data-example-kotlin</artifactId>
Expand Down
17 changes: 9 additions & 8 deletions example/example-kotlin/src/main/kotlin/process/OrderApproval.kt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ import io.holunda.camunda.bpm.data.guard.VariablesGuard
import io.holunda.camunda.bpm.data.guard.condition.exists
import io.holunda.camunda.bpm.data.guard.condition.matches
import io.holunda.camunda.bpm.data.guard.integration.DefaultGuardTaskListener
import io.holunda.camunda.bpm.data.reader.VariableScopeReader
import io.holunda.camunda.bpm.data.writer.VariableScopeWriter
import mu.KLogging
import org.camunda.bpm.engine.delegate.DelegateExecution
import org.camunda.bpm.engine.delegate.DelegateTask
Expand Down Expand Up @@ -54,29 +56,28 @@ class OrderApproval {
*/
@Bean
fun loadOrder() = JavaDelegate { execution ->
val orderId = ORDER_ID.from(execution).get()
val orderId = VariableScopeReader.of(ORDER_ID, execution).get()
val order = orderRepository.loadOrder(orderId)
ORDER.on(execution).set(order)
ORDER_TOTAL.on(execution).set(BigDecimal.ZERO)
VariableScopeWriter.of(ORDER, execution).set(order)
VariableScopeWriter.of(ORDER_TOTAL, execution).set(BigDecimal.ZERO)
}

/**
* Load a local order position, write a local variable.
*/
@Bean
fun calculateOrderPositions() = JavaDelegate { execution ->
val orderPosition = ORDER_POSITION.from(execution).get()

ORDER_TOTAL.on(execution).update { total -> total.plus(orderPosition.netCost.times(BigDecimal.valueOf(orderPosition.amount))) }
val orderPosition = VariableScopeReader.of(ORDER_POSITION, execution).get()
VariableScopeWriter.of(ORDER_TOTAL, execution).update { total -> total.plus(orderPosition.netCost.times(BigDecimal.valueOf(orderPosition.amount))) }
}

/**
* Read a local variable and store it in global variable.
*/
@Bean
fun writeOrderTotal() = ExecutionListener { execution ->
val total = ORDER_TOTAL.from(execution).get()
ORDER_TOTAL.on(execution).set(total)
val total = VariableScopeReader.of(ORDER_TOTAL, execution).get()
VariableScopeWriter.of(ORDER_TOTAL, execution).set(total)
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import io.holunda.camunda.bpm.data.example.kotlin.domain.Order
import io.holunda.camunda.bpm.data.example.kotlin.process.OrderApproval.Variables.ORDER
import io.holunda.camunda.bpm.data.example.kotlin.process.OrderApproval.Variables.ORDER_APPROVED
import io.holunda.camunda.bpm.data.example.kotlin.process.OrderApproval.Variables.ORDER_TOTAL
import io.holunda.camunda.bpm.data.reader.TaskServiceVariableReader
import io.holunda.camunda.bpm.data.writer.VariableMapWriter
import org.camunda.bpm.engine.TaskService
import org.camunda.bpm.engine.variable.Variables.createVariables
import org.springframework.http.ResponseEntity
Expand All @@ -18,15 +20,15 @@ class ApproveOrderTaskController(

@GetMapping("/{taskId}")
fun loadTask(@PathVariable("taskId") taskId: String): ResponseEntity<ApproveTaskDto> {
val order = ORDER.from(taskService, taskId).get()
val orderTotal = ORDER_TOTAL.from(taskService, taskId).get()
val order = TaskServiceVariableReader.of(ORDER, taskService, taskId).get()
val orderTotal = TaskServiceVariableReader.of(ORDER_TOTAL, taskService, taskId).get()
return ResponseEntity.ok(ApproveTaskDto(order, orderTotal))
}

@PostMapping("/{taskId}")
fun completeTask(@PathVariable("taskId") taskId: String, @RequestBody approveTaskComplete: ApproveTaskCompleteDto): ResponseEntity<Void> {
val vars = createVariables()
ORDER_APPROVED.on(vars).set(approveTaskComplete.approved)
VariableMapWriter.of(ORDER_APPROVED, vars).set(approveTaskComplete.approved)
taskService.complete(taskId, vars)
return ResponseEntity.noContent().build()
}
Expand Down
2 changes: 1 addition & 1 deletion example/example-no-engine/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>io.holunda.data.example</groupId>
<artifactId>camunda-bpm-data-example-parent</artifactId>
<version>1.5.1-SNAPSHOT</version>
<version>1.6.0-SNAPSHOT</version>
</parent>

<artifactId>camunda-bpm-data-example-no-engine</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion example/itest/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>io.holunda.data.example</groupId>
<artifactId>camunda-bpm-data-example-parent</artifactId>
<version>1.5.1-SNAPSHOT</version>
<version>1.6.0-SNAPSHOT</version>
</parent>

<artifactId>camunda-bpm-data-integration-test</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ fun <G, W, T> ScenarioTestBase<G, W, T>.whenever(): W = `when`()
@ExtendWith(SpringExtension::class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, classes = [CamundaBpmDataITestBase.TestApplication::class])
@ActiveProfiles("itest")
@Suppress("DEPRECATION") // FIXME: remove this suppression as soon as deprecation is removed
abstract class CamundaBpmDataITestBase : SpringScenarioTest<ActionStage, ActionStage, AssertStage>() {

companion object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import org.junit.jupiter.api.Test
import org.springframework.beans.factory.annotation.Autowired
import java.util.*

@Suppress("DEPRECATION") // FIXME: remove this suppression as soon as deprecation is removed
class RuntimeServiceAdapterITest : CamundaBpmDataITestBase() {

@Autowired
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import org.springframework.beans.factory.annotation.Autowired
import java.util.*
import kotlin.collections.HashMap

@Suppress("DEPRECATION") // FIXME: remove this suppression as soon as deprecation is removed
class TaskServiceAdapterITest : CamundaBpmDataITestBase() {

@Autowired
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ import org.junit.jupiter.api.Test
import org.springframework.beans.factory.annotation.Autowired
import java.util.*


@Suppress("DEPRECATION") // FIXME: remove this suppression as soon as deprecation is removed
class VariableMapAdapterITest : CamundaBpmDataITestBase() {

@Autowired
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import org.junit.jupiter.api.Test
import org.springframework.beans.factory.annotation.Autowired
import java.util.*

@Suppress("DEPRECATION") // FIXME: remove this suppression as soon as deprecation is removed
class VariableScopeAdapterITest : CamundaBpmDataITestBase() {

@Autowired
Expand Down
2 changes: 1 addition & 1 deletion example/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>io.holunda.data</groupId>
<artifactId>camunda-bpm-data-parent</artifactId>
<version>1.5.1-SNAPSHOT</version>
<version>1.6.0-SNAPSHOT</version>
</parent>

<groupId>io.holunda.data.example</groupId>
Expand Down
2 changes: 1 addition & 1 deletion example/spin-type-detector/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>io.holunda.data.example</groupId>
<artifactId>camunda-bpm-data-example-parent</artifactId>
<version>1.5.1-SNAPSHOT</version>
<version>1.6.0-SNAPSHOT</version>
</parent>

<artifactId>camunda-bpm-data-spin-type-detector</artifactId>
Expand Down
47 changes: 47 additions & 0 deletions extension/api/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>io.holunda.data</groupId>
<artifactId>camunda-bpm-data-parent</artifactId>
<version>1.6.0-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>

<artifactId>camunda-bpm-data-api</artifactId>
<name>${project.artifactId}</name>
<packaging>jar</packaging>

<properties>
<jacoco.skip>false</jacoco.skip>
<dokka.skip>false</dokka.skip>
</properties>

<dependencies>
<!-- Kotlin -->
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-stdlib-common</artifactId>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-reflect</artifactId>
</dependency>
<dependency>
<groupId>org.camunda.bpm</groupId>
<artifactId>camunda-engine</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
Loading