Skip to content

Commit

Permalink
Merge branch 'release/1.2.6'
Browse files Browse the repository at this point in the history
  • Loading branch information
zambrovski committed Apr 7, 2022
2 parents 89a424a + a3c4b9a commit 346a55a
Show file tree
Hide file tree
Showing 26 changed files with 298 additions and 129 deletions.
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[![Build Status](https://github.com/holunda-io/camunda-bpm-data/workflows/default/badge.svg)](https://github.com/holunda-io/camunda-bpm-data/actions)
[![Maven Central](https://maven-badges.herokuapp.com/maven-central/io.holunda.data/camunda-bpm-data/badge.svg)](https://maven-badges.herokuapp.com/maven-central/io.holunda.data/camunda-bpm-data)
[![CodeCov](https://codecov.io/gh/holunda-io/camunda-bpm-data/branch/master/graph/badge.svg)](https://codecov.io/gh/holunda-io/camunda-bpm-data)
[![Codacy](https://api.codacy.com/project/badge/Grade/653136bd5cad48c8a9f2621ee304ff26)](https://app.codacy.com/app/zambrovski/camunda-bpm-data?utm_source=github.com&utm_medium=referral&utm_content=holunda-io/camunda-bpm-data&utm_campaign)
[![Codacy Badge](https://app.codacy.com/project/badge/Grade/02d238f71a8243cb96fd2fe322a710eb)](https://www.codacy.com/gh/holunda-io/camunda-bpm-data/dashboard?utm_source=github.com&utm_medium=referral&utm_content=holunda-io/camunda-bpm-data&utm_campaign=Badge_Grade)
[![Changes](https://img.shields.io/badge/CHANGES---yellow)](https://www.holunda.io/camunda-bpm-data/changelog)
[![gitter](https://badges.gitter.im/holunda-io/camunda-bpm-data.svg)](https://gitter.im/holunda-io/camunda-bpm-data?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)

Expand All @@ -26,6 +26,7 @@ easy and convenient. We leverage the Camunda API and offer you not only a better

If you want to read more about data in Camunda processes, have a look on those articles:

* [Camunda Nation Podcast - Managing Data in Processes, with Simon Zambrovski](https://podcasts.apple.com/us/podcast/managing-data-in-processes-with-simon-zambrovski/id1478382505?i=1000547023972)
* [Data in Process (Part 1)](https://medium.com/holisticon-consultants/data-in-process-part-1-2620bf9abd76)
* [Data in Process (Part 2)](https://medium.com/holisticon-consultants/data-in-process-part-2-7c6a109e6ee2)

Expand All @@ -39,20 +40,20 @@ If you just want to start using the library, put the following dependency into y
<dependency>
<groupId>io.holunda.data</groupId>
<artifactId>camunda-bpm-data</artifactId>
<version>1.2.3</version>
<version>1.2.5</version>
</dependency>
```

If you are using Gradle Kotlin DSL add to your `build.gradle.kts`:

``` kotlin
implementation("io.holunda.data:camunda-bpm-data:1.2.3")
implementation("io.holunda.data:camunda-bpm-data:1.2.5")
```

For Gradle Groovy DSL add to your `build.gradle`:

``` groovy
implementation 'io.holunda.data:camunda-bpm-data:1.2.3'
implementation 'io.holunda.data:camunda-bpm-data:1.2.5'
```
### Variable declaration
Now your setup is completed, and you can declare your variables like this:
Expand Down
2 changes: 1 addition & 1 deletion docs/developer-guide/project-setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ If you want to skip the build of examples, please specify the `-DskipExamples` s
We are using MkDocs for generation of a static site documentation and rely on markdown as much as possible.
To install it, please run once:

``sh
```sh
python3 -m pip install -r ./docs/requirements.txt
```

Expand Down
31 changes: 16 additions & 15 deletions docs/quick-start.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
## Quick Start

### Add dependency
## Add dependency

Current version available in Sonatype OSS Maven Central is:

In Apache Maven add to your `pom.xml`:

``` xml
```xml
<dependency>
<groupId>io.holunda.data</groupId>
<artifactId>camunda-bpm-data</artifactId>
Expand All @@ -16,24 +14,24 @@ In Apache Maven add to your `pom.xml`:

For Gradle Kotlin DSL add to your `build.gradle.kts`:

``` kotlin
```kotlin
implementation("io.holunda.data:camunda-bpm-data:${camunda-bpm-data.version}")
```

For Gradle Groovy DSL add to your `build.gradle`:

``` groovy
```groovy
implementation 'io.holunda.data:camunda-bpm-data:${camunda-bpm-data.version}'
```

### Declare process variable factories
## Declare process variable factories

First you have to define your process variables, by providing the variable name and type. For providing the type,
different convenience methods exist:

Here is an example in Java:

``` java
```java

import io.holunda.camunda.bpm.data.factory.VariableFactory;
import static io.holunda.camunda.bpm.data.CamundaBpmData.*;
Expand All @@ -47,15 +45,15 @@ public class OrderApproval {
}
```

### Access process variables from Java Delegate
## Access process variables from Java Delegate

If you want to access the process variable, call methods on the `ProcessVariableFactory` to configure the usage context,
and then invoke the variable access methods.

Here is an example, how it looks like to access variable from `JavaDelegate` implemented in Java. In this example,
the total amount is calculated from the amounts of order positions and stored in the process variable.

``` java
```java

@Configuration
class JavaDelegates {
Expand All @@ -72,15 +70,16 @@ class JavaDelegates {
}
```

### Variable access from REST Controller
## Variable access from REST Controller

Now imagine you are implementing a REST controller for a user task form which
loads data from the process application, displays it, captures some input and
sends that back to the process application to complete the user task. By doing so,
you will usually need to access process variables. Here is an example:


``` java
```java

@RestController
@RequestMapping("/task/approve-order")
public class ApproveOrderTaskController {
Expand Down Expand Up @@ -109,14 +108,15 @@ public class ApproveOrderTaskController {

```

### Testing correct variable access
## Testing correct variable access

If you want to write the test for the REST controller, you will need to stub
the task service and verify that the correct variables has been set. To simplify
these tests, we created an additional library module `camunda-bpm-data-test`.
Please put the following dependency into your `pom.xml`:

``` xml
```xml

<dependency>
<groupId>io.holunda.data</groupId>
<artifactId>camunda-bpm-data-test</artifactId>
Expand All @@ -130,7 +130,8 @@ and `TaskServiceVerifier` to verify the correct access to variables easily. Here
test of the REST controller above, making use of `camunda-bpm-data-test`.


``` java
```java

public class ApproveOrderTaskControllerTest {

private static Order order = new Order("ORDER-ID-1", new Date(), new ArrayList<>());
Expand Down
24 changes: 13 additions & 11 deletions docs/user-guide/examples-java.md
Original file line number Diff line number Diff line change
Expand Up @@ -229,17 +229,19 @@ class VariableGuardConfiguration {
@Bean(VariableGuardConfiguration.MY_GUARD_BEANNAME)
public ExecutionListener myGuardBeanName(Supplier<Validator> validatorSupplier) {
return new DefaultGuardExecutionListener(
Arrays.asList(
exists(REQUIRED_VALUE),
notExists(FUTURE_VALUE),
hasValue(THE_ANSWER, 42),
hasOneOfValues(MY_DIRECTION, Set.of("left", "up", "down")),
isEmail(USER_EMAIL),
isUuid(DOCUMENT_ID),
matches(DOCUMENT_BODY, this::myDocumentBodyMatcher),
matches(DOCUMENT_BODY, this::myDocumentBodyMatcher, this::validationMessageSupplier),
matchesRegex(DOCUMENT_BODY, "^Dude.*", "Starts with 'Dude'"),
isValidBean(My_DOCUMENT, validatorSupplier)
new VariablesGuard(
Arrays.asList(
exists(REQUIRED_VALUE),
notExists(FUTURE_VALUE),
hasValue(THE_ANSWER, 42),
hasOneOfValues(MY_DIRECTION, Set.of("left", "up", "down")),
isEmail(USER_EMAIL),
isUuid(DOCUMENT_ID),
matches(DOCUMENT_BODY, this::myDocumentBodyMatcher),
matches(DOCUMENT_BODY, this::myDocumentBodyMatcher, this::validationMessageSupplier),
matchesRegex(DOCUMENT_BODY, "^Dude.*", "Starts with 'Dude'"),
isValidBean(My_DOCUMENT, validatorSupplier)
)
), true);
}

Expand Down
24 changes: 13 additions & 11 deletions docs/user-guide/examples-kotlin.md
Original file line number Diff line number Diff line change
Expand Up @@ -219,17 +219,19 @@ class VariableGuardConfiguration {
@Bean(LOAD_OPERATIONAL_FILE_GUARD)
fun loadOperationalFileGuard(validatorSupplier : Supplier<Validator>): ExecutionListener =
DefaultGuardExecutionListener(
listOf(
REQUIRED_VALUE.exists(),
FUTURE_VALUE.notExists(),
THE_ANSWER.hasValue(42),
MY_DIRECTION.hasOneOfValues(setOf("left", "up", "down")),
USER_EMAIL.isEmail(),
DOCUMENT_ID.isUuid(),
DOCUMENT_BODY.matches { return@matches true },
DOCUMENT_BODY.matches(this::validationMessageSupplier) { return@matches true },
DOCUMENT_BODY.matchesRegexLocal(Regex("^Dude.*"), "Starts with 'Dude'"),
MY_DOCUMENT.isValidBean(validatorSupplier)
VariablesGuard(
listOf(
REQUIRED_VALUE.exists(),
FUTURE_VALUE.notExists(),
THE_ANSWER.hasValue(42),
MY_DIRECTION.hasOneOfValues(setOf("left", "up", "down")),
USER_EMAIL.isEmail(),
DOCUMENT_ID.isUuid(),
DOCUMENT_BODY.matches { return@matches true },
DOCUMENT_BODY.matches(this::validationMessageSupplier) { return@matches true },
DOCUMENT_BODY.matchesRegexLocal(Regex("^Dude.*"), "Starts with 'Dude'"),
MY_DOCUMENT.isValidBean(validatorSupplier)
)
), true
)

Expand Down
15 changes: 12 additions & 3 deletions docs/user-guide/motivation.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ conditions on process variables during the execution of business processes, a co
the library. A guard consists of a set of `VariableConditions` and can be evaluated in all contexts, the variables
are used in: `DelegateTask`, `DelegateExecution`, `TaskService`, `RuntimeService`, `VariableMap`.

Here is an example of a task listener verifying that a process variable `ORDER_APPROVED` is set, which
will throw a `GuardViolationException` if the condition is not met.
Here is an example of a task listener defining a `VariablesGuard` to test that the process variables `ORDER_APPROVED` and
`APPROVER_ID` are set, which will throw a `GuardViolationException` if the condition is not met.


``` java
Expand All @@ -49,11 +49,20 @@ import static io.holunda.camunda.bpm.data.guard.CamundaBpmDataGuards.exists;
class MyGuardListener extends DefaultGuardTaskListener {

public MyGuardListener() {
super(newArrayList(exists(ORDER_APPROVED)), true);
super(new VariablesGuard(List.of(exists(ORDER_APPROVED), exists(APPROVER_ID)), true);
}
}
```

By default, all conditions of a `VariablesGuard` must be met in order to pass the validations. This behaviour can be explicitly
defined by passing the `reduceOperator = VariablesGuard.ALL` when creating the `VariablesGuard`. The `reduceOperator` can take
the following values:

| `reduceOperator` | Semantics |
|-------------------------|----------------------------------------------|
| `VariablesGuard.ALL` | All `VariableCondition`s must be met |
| `VariablesGuard.ONE_OF` | At least ONE `VariableCondition` must be met |

## Anti-Corruption-Layer

If a process is signalled or hit by a correlated message, there is no way to check if the transported variables are set correctly.
Expand Down
2 changes: 1 addition & 1 deletion 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.2.5</version>
<version>1.2.6</version>
</parent>

<artifactId>camunda-bpm-data-coverage-report</artifactId>
Expand Down
11 changes: 7 additions & 4 deletions 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.2.5</version>
<version>1.2.6</version>
</parent>

<artifactId>camunda-bpm-data-example-java</artifactId>
Expand All @@ -26,10 +26,13 @@
<artifactId>camunda-bpm-data-spin-type-detector</artifactId>
<version>${project.parent.version}</version>
</dependency>

<dependency>
<groupId>io.toolisticon.springboot</groupId>
<artifactId>springboot-swagger-starter</artifactId>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-ui</artifactId>
</dependency>
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-webmvc-core</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,10 @@
import io.holunda.camunda.bpm.data.example.domain.OrderPosition;
import io.holunda.camunda.bpm.data.example.domain.OrderRepository;
import io.holunda.camunda.bpm.data.factory.VariableFactory;
import io.holunda.camunda.bpm.data.guard.VariablesGuard;
import io.holunda.camunda.bpm.data.guard.integration.DefaultGuardExecutionListener;
import io.holunda.camunda.bpm.data.guard.integration.DefaultGuardTaskListener;
import org.camunda.bpm.engine.delegate.DelegateExecution;
import org.camunda.bpm.engine.delegate.DelegateTask;
import org.camunda.bpm.engine.delegate.ExecutionListener;
import org.camunda.bpm.engine.delegate.JavaDelegate;
import org.camunda.bpm.engine.delegate.TaskListener;
import org.camunda.bpm.engine.delegate.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
Expand All @@ -19,12 +16,10 @@
import org.springframework.context.event.EventListener;

import java.math.BigDecimal;
import java.util.List;

import static com.google.common.collect.Lists.newArrayList;
import static io.holunda.camunda.bpm.data.CamundaBpmData.booleanVariable;
import static io.holunda.camunda.bpm.data.CamundaBpmData.customVariable;
import static io.holunda.camunda.bpm.data.CamundaBpmData.stringVariable;
import static io.holunda.camunda.bpm.data.guard.CamundaBpmDataGuards.*;
import static io.holunda.camunda.bpm.data.CamundaBpmData.*;
import static io.holunda.camunda.bpm.data.guard.CamundaBpmDataGuards.exists;

/**
* Process backing bean.
Expand Down Expand Up @@ -108,7 +103,7 @@ public ExecutionListener writeOrderTotal() {
*/
@Bean
public ExecutionListener guardExecutionListener() {
return new DefaultGuardExecutionListener(newArrayList(exists(ORDER_ID)), true);
return new DefaultGuardExecutionListener(new VariablesGuard(List.of(exists(ORDER_ID))), true);
}

/**
Expand All @@ -120,9 +115,12 @@ public ExecutionListener guardExecutionListener() {
@Bean
public TaskListener guardTaskListener() {
return new DefaultGuardTaskListener(
newArrayList(
exists(ORDER_APPROVED)
), true
new VariablesGuard(
"namedGuard",
List.of(
exists(ORDER_APPROVED)
),
VariablesGuard.ALL), true
);
}

Expand Down
15 changes: 12 additions & 3 deletions 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.2.5</version>
<version>1.2.6</version>
</parent>

<artifactId>camunda-bpm-data-example-kotlin</artifactId>
Expand Down Expand Up @@ -133,8 +133,17 @@
</exclusions>
</dependency>
<dependency>
<groupId>io.toolisticon.springboot</groupId>
<artifactId>springboot-swagger-starter</artifactId>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-ui</artifactId>
</dependency>
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-webmvc-core</artifactId>
</dependency>
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-kotlin</artifactId>
<version>${springdoc.version}</version>
</dependency>

<!-- Testing -->
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.2.5</version>
<version>1.2.6</version>
</parent>

<artifactId>camunda-bpm-data-example-no-engine</artifactId>
Expand Down
Loading

0 comments on commit 346a55a

Please sign in to comment.