Skip to content

Commit

Permalink
Merge pull request #11 from camunda-community-hub/feature/generalize-…
Browse files Browse the repository at this point in the history
…for-business-cockpit

Generalize for business cockpit
  • Loading branch information
stephanpelikan authored Sep 20, 2023
2 parents 8ee45fd + e073457 commit 3bd9bcb
Show file tree
Hide file tree
Showing 12 changed files with 214 additions and 35 deletions.
22 changes: 22 additions & 0 deletions .github/workflows/deploy-to-github-packages.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Publish to GitHub Packages
on: push
jobs:
publish:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v3
- uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'adopt'
cache: 'maven'
- name: Publish package
run: mvn -s $GITHUB_WORKSPACE/.github/workflows/github-packages-settings.xml --batch-mode deploy
env:
USER_NAME: ${{ secrets.VANILLABP_USER_NAME }}
USER_TOKEN: ${{ secrets.VANILLABP_USER_TOKEN }}
CAMUNDA_USER_TOKEN: ${{ secrets.CAMUNDA_USER_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
44 changes: 44 additions & 0 deletions .github/workflows/github-packages-settings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
<activeProfiles>
<activeProfile>github</activeProfile>
</activeProfiles>
<profiles>
<profile>
<id>github</id>
<repositories>
<repository>
<id>central</id>
<url>https://repo1.maven.org/maven2</url>
</repository>
<repository>
<id>vanillabp-spring-boot-support</id>
<url>https://maven.pkg.github.com/vanillabp/spring-boot-support</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
<releases>
<enabled>true</enabled>
</releases>
</repository>
</repositories>
</profile>
</profiles>

<servers>
<server>
<id>vanillabp-spring-boot-support</id>
<username>${env.USER_NAME}</username>
<password>${env.USER_TOKEN}</password>
</server>
<server>
<id>github</id>
<username>${env.USER_NAME}</username>
<password>${env.CAMUNDA_USER_TOKEN}</password>
</server>
</servers>

</settings>

15 changes: 15 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,13 @@
<release>${version.java}</release>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<configuration>
<skip>false</skip>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
Expand Down Expand Up @@ -60,4 +67,12 @@
<developerConnection>scm:git:https://github.com/camunda-community-hub/vanillabp-camunda8-adapter.git</developerConnection>
<url>http://github.com/camunda-community-hub/vanillabp-camunda8-adapter/tree/main</url>
</scm>

<distributionManagement>
<snapshotRepository>
<id>github</id>
<name>Github Packages</name>
<url>https://maven.pkg.github.com/camunda-community-hub/vanillabp-camunda8-adapter</url>
</snapshotRepository>
</distributionManagement>
</project>
2 changes: 1 addition & 1 deletion spring-boot/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
<dependency>
<groupId>io.vanillabp</groupId>
<artifactId>spring-boot-support</artifactId>
<version>1.0.4</version>
<version>1.0.5</version>
</dependency>
<dependency>
<groupId>io.camunda</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import io.vanillabp.spi.service.TaskException;
import io.vanillabp.springboot.adapter.MultiInstance;
import io.vanillabp.springboot.adapter.TaskHandlerBase;
import io.vanillabp.springboot.adapter.wiring.WorkflowAggregateCache;
import io.vanillabp.springboot.parameters.MethodParameter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down Expand Up @@ -57,6 +58,7 @@ protected Logger getLogger() {

}

@SuppressWarnings("unchecked")
@Override
@Transactional
public void handle(
Expand All @@ -75,19 +77,57 @@ public void handle(

final var taskIdRetrieved = new AtomicBoolean(false);

final var workflowAggregate = super.execute(
final Function<String, Object> multiInstanceSupplier
= multiInstanceVariable -> getVariable(job, multiInstanceVariable);

final var workflowAggregateCache = new WorkflowAggregateCache();

super.execute(
workflowAggregateCache,
businessKey,
multiInstanceVariable -> getVariable(job, multiInstanceVariable),
taskParameter -> getVariable(job, taskParameter),
() -> {
taskIdRetrieved.set(true);
return Long.toHexString(job.getKey());
},
() -> Event.CREATED);
true,
(args, param) -> processTaskParameter(
args,
param,
taskParameter -> getVariable(job, taskParameter)),
(args, param) -> processTaskIdParameter(
args,
param,
() -> {
taskIdRetrieved.set(true);
return Long.toHexString(job.getKey());
}),
(args, param) -> processTaskEventParameter(
args,
param,
() -> Event.CREATED),
(args, param) -> processMultiInstanceIndexParameter(
args,
param,
multiInstanceSupplier),
(args, param) -> processMultiInstanceTotalParameter(
args,
param,
multiInstanceSupplier),
(args, param) -> processMultiInstanceElementParameter(
args,
param,
multiInstanceSupplier),
(args, param) -> processMultiInstanceResolverParameter(
args,
param,
() -> {
if (workflowAggregateCache.workflowAggregate == null) {
workflowAggregateCache.workflowAggregate = workflowAggregateRepository
.findById(businessKey)
.orElseThrow();
}
return workflowAggregateCache.workflowAggregate;
}, multiInstanceSupplier));

if ((taskType != Type.USERTASK)
&& !taskIdRetrieved.get()) {
command = createCompleteCommand(client, job, workflowAggregate);
command = createCompleteCommand(client, job, workflowAggregateCache.workflowAggregate);
}
} catch (TaskException bpmnError) {
command = createThrowErrorCommand(client, job, bpmnError);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
package io.vanillabp.camunda8.wiring;

import java.lang.reflect.Method;
import java.util.Arrays;
import java.util.Collection;
import java.util.LinkedList;
import java.util.List;
import java.util.function.Consumer;
import java.util.stream.Stream;

import javax.persistence.Id;

import org.camunda.bpm.model.xml.instance.ModelElementInstance;
import org.springframework.beans.factory.ObjectProvider;
import org.springframework.context.ApplicationContext;

import io.camunda.zeebe.client.ZeebeClient;
import io.camunda.zeebe.client.api.worker.JobWorkerBuilderStep1.JobWorkerBuilderStep3;
import io.camunda.zeebe.model.bpmn.impl.BpmnModelInstanceImpl;
Expand All @@ -14,24 +28,12 @@
import io.vanillabp.camunda8.wiring.Camunda8Connectable.Type;
import io.vanillabp.camunda8.wiring.parameters.Camunda8MethodParameterFactory;
import io.vanillabp.camunda8.wiring.parameters.ParameterVariables;
import io.vanillabp.spi.service.WorkflowTask;
import io.vanillabp.springboot.adapter.SpringDataUtil;
import io.vanillabp.springboot.adapter.TaskWiringBase;
import io.vanillabp.springboot.parameters.MethodParameter;
import org.camunda.bpm.model.xml.instance.ModelElementInstance;
import org.springframework.beans.factory.ObjectProvider;
import org.springframework.context.ApplicationContext;

import java.lang.reflect.Method;
import java.util.Arrays;
import java.util.Collection;
import java.util.LinkedList;
import java.util.List;
import java.util.function.Consumer;
import java.util.stream.Stream;

import javax.persistence.Id;

public class Camunda8TaskWiring extends TaskWiringBase<Camunda8Connectable, Camunda8ProcessService<?>>
public class Camunda8TaskWiring extends TaskWiringBase<Camunda8Connectable, Camunda8ProcessService<?>, Camunda8MethodParameterFactory>
implements Consumer<ZeebeClient> {

private final String workerId;
Expand Down Expand Up @@ -65,6 +67,13 @@ public Camunda8TaskWiring(

}

@Override
protected Class<WorkflowTask> getAnnotationType() {

return WorkflowTask.class;

}

/**
* Called by
* {@link Camunda8DeploymentAdapter#processBpmnModel(BpmnModelInstanceImpl)} to
Expand Down Expand Up @@ -317,5 +326,19 @@ private List<String> getVariablesToFetch(
return result;

}


public void wireTask(
final Camunda8ProcessService<?> processService,
final Camunda8Connectable connectable) {

super.wireTask(
connectable,
false,
(method, annotation) -> methodMatchesTaskDefinition(connectable, method, annotation),
(method, annotation) -> methodMatchesElementId(connectable, method, annotation),
(method, annotation) -> validateParameters(processService, method),
(bean, method, parameters) -> connectToBpms(processService, bean, connectable, method, parameters));

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -12,41 +12,66 @@ public class Camunda8MethodParameterFactory extends MethodParameterFactory {

@Override
public ResolverBasedMultiInstanceMethodParameter getResolverBasedMultiInstanceMethodParameter(
final int index,
final String parameter,
final MultiInstanceElementResolver<?, ?> resolverBean) {

return new Camunda8ResolverBasedMethodParameter(resolverBean);
return new Camunda8ResolverBasedMethodParameter(
index,
parameter,
resolverBean);

}

@Override
public MultiInstanceElementMethodParameter getMultiInstanceElementMethodParameter(
final int index,
final String parameter,
final String name) {

return new Camunda8MultiInstanceElementMethodParameter(name);
return new Camunda8MultiInstanceElementMethodParameter(
index,
parameter,
name);

}

@Override
public MultiInstanceIndexMethodParameter getMultiInstanceIndexMethodParameter(
final int index,
final String parameter,
final String name) {

return new Camunda8MultiInstanceIndexMethodParameter(name);
return new Camunda8MultiInstanceIndexMethodParameter(
index,
parameter,
name);

}

@Override
public MultiInstanceTotalMethodParameter getMultiInstanceTotalMethodParameter(
final int index,
final String parameter,
final String name) {

return new Camunda8MultiInstanceTotalMethodParameter(name);
return new Camunda8MultiInstanceTotalMethodParameter(
index,
parameter,
name);

}

@Override
public TaskParameter getTaskParameter(
final int index,
final String parameter,
final String name) {

return new Camunda8TaskParameter(name);
return new Camunda8TaskParameter(
index,
parameter,
name);

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@ public class Camunda8MultiInstanceElementMethodParameter extends MultiInstanceEl
implements ParameterVariables {

public Camunda8MultiInstanceElementMethodParameter(
final int index,
final String parameter,
final String name) {

super(name);
super(index, parameter, name);

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@ public class Camunda8MultiInstanceIndexMethodParameter extends MultiInstanceInde
public static final String SUFFIX = "_index";

public Camunda8MultiInstanceIndexMethodParameter(
final int index,
final String parameter,
final String name) {

super(name);
super(index, parameter, name);

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@ public class Camunda8MultiInstanceTotalMethodParameter extends MultiInstanceTota
public static final String SUFFIX = "_total";

public Camunda8MultiInstanceTotalMethodParameter(
final int index,
final String parameter,
final String name) {

super(name);
super(index, parameter, name);

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@ public class Camunda8ResolverBasedMethodParameter extends ResolverBasedMultiInst
implements ParameterVariables {

public Camunda8ResolverBasedMethodParameter(
final int index,
final String parameter,
final MultiInstanceElementResolver<?, ?> resolverBean) {

super(resolverBean);
super(index, parameter, resolverBean);

}

Expand Down
Loading

0 comments on commit 3bd9bcb

Please sign in to comment.