diff --git a/.github/workflows/deploy-to-github-packages.yaml b/.github/workflows/deploy-to-github-packages.yaml new file mode 100644 index 0000000..9ffd2f9 --- /dev/null +++ b/.github/workflows/deploy-to-github-packages.yaml @@ -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 }} diff --git a/.github/workflows/github-packages-settings.xml b/.github/workflows/github-packages-settings.xml new file mode 100644 index 0000000..4e46af5 --- /dev/null +++ b/.github/workflows/github-packages-settings.xml @@ -0,0 +1,44 @@ + + + + github + + + + github + + + central + https://repo1.maven.org/maven2 + + + vanillabp-spring-boot-support + https://maven.pkg.github.com/vanillabp/spring-boot-support + + true + + + true + + + + + + + + + vanillabp-spring-boot-support + ${env.USER_NAME} + ${env.USER_TOKEN} + + + github + ${env.USER_NAME} + ${env.CAMUNDA_USER_TOKEN} + + + + + diff --git a/pom.xml b/pom.xml index 44eb14e..7993f9a 100644 --- a/pom.xml +++ b/pom.xml @@ -31,6 +31,13 @@ ${version.java} + + org.apache.maven.plugins + maven-deploy-plugin + + false + + @@ -60,4 +67,12 @@ scm:git:https://github.com/camunda-community-hub/vanillabp-camunda8-adapter.git http://github.com/camunda-community-hub/vanillabp-camunda8-adapter/tree/main + + + + github + Github Packages + https://maven.pkg.github.com/camunda-community-hub/vanillabp-camunda8-adapter + + diff --git a/spring-boot/pom.xml b/spring-boot/pom.xml index 8cec1dc..831bcc5 100644 --- a/spring-boot/pom.xml +++ b/spring-boot/pom.xml @@ -35,7 +35,7 @@ io.vanillabp spring-boot-support - 1.0.4 + 1.0.5 io.camunda diff --git a/spring-boot/src/main/java/io/vanillabp/camunda8/wiring/Camunda8TaskHandler.java b/spring-boot/src/main/java/io/vanillabp/camunda8/wiring/Camunda8TaskHandler.java index 8d10da8..3d5d39f 100644 --- a/spring-boot/src/main/java/io/vanillabp/camunda8/wiring/Camunda8TaskHandler.java +++ b/spring-boot/src/main/java/io/vanillabp/camunda8/wiring/Camunda8TaskHandler.java @@ -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; @@ -57,6 +58,7 @@ protected Logger getLogger() { } + @SuppressWarnings("unchecked") @Override @Transactional public void handle( @@ -75,19 +77,57 @@ public void handle( final var taskIdRetrieved = new AtomicBoolean(false); - final var workflowAggregate = super.execute( + final Function 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); diff --git a/spring-boot/src/main/java/io/vanillabp/camunda8/wiring/Camunda8TaskWiring.java b/spring-boot/src/main/java/io/vanillabp/camunda8/wiring/Camunda8TaskWiring.java index 2e7a5cd..f43e562 100644 --- a/spring-boot/src/main/java/io/vanillabp/camunda8/wiring/Camunda8TaskWiring.java +++ b/spring-boot/src/main/java/io/vanillabp/camunda8/wiring/Camunda8TaskWiring.java @@ -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; @@ -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> +public class Camunda8TaskWiring extends TaskWiringBase, Camunda8MethodParameterFactory> implements Consumer { private final String workerId; @@ -65,6 +67,13 @@ public Camunda8TaskWiring( } + @Override + protected Class getAnnotationType() { + + return WorkflowTask.class; + + } + /** * Called by * {@link Camunda8DeploymentAdapter#processBpmnModel(BpmnModelInstanceImpl)} to @@ -317,5 +326,19 @@ private List 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)); + + } + } diff --git a/spring-boot/src/main/java/io/vanillabp/camunda8/wiring/parameters/Camunda8MethodParameterFactory.java b/spring-boot/src/main/java/io/vanillabp/camunda8/wiring/parameters/Camunda8MethodParameterFactory.java index 7990a6d..5138dfd 100644 --- a/spring-boot/src/main/java/io/vanillabp/camunda8/wiring/parameters/Camunda8MethodParameterFactory.java +++ b/spring-boot/src/main/java/io/vanillabp/camunda8/wiring/parameters/Camunda8MethodParameterFactory.java @@ -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); } diff --git a/spring-boot/src/main/java/io/vanillabp/camunda8/wiring/parameters/Camunda8MultiInstanceElementMethodParameter.java b/spring-boot/src/main/java/io/vanillabp/camunda8/wiring/parameters/Camunda8MultiInstanceElementMethodParameter.java index f77125b..fe6472a 100644 --- a/spring-boot/src/main/java/io/vanillabp/camunda8/wiring/parameters/Camunda8MultiInstanceElementMethodParameter.java +++ b/spring-boot/src/main/java/io/vanillabp/camunda8/wiring/parameters/Camunda8MultiInstanceElementMethodParameter.java @@ -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); } diff --git a/spring-boot/src/main/java/io/vanillabp/camunda8/wiring/parameters/Camunda8MultiInstanceIndexMethodParameter.java b/spring-boot/src/main/java/io/vanillabp/camunda8/wiring/parameters/Camunda8MultiInstanceIndexMethodParameter.java index 6fbb01c..0ca0272 100644 --- a/spring-boot/src/main/java/io/vanillabp/camunda8/wiring/parameters/Camunda8MultiInstanceIndexMethodParameter.java +++ b/spring-boot/src/main/java/io/vanillabp/camunda8/wiring/parameters/Camunda8MultiInstanceIndexMethodParameter.java @@ -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); } diff --git a/spring-boot/src/main/java/io/vanillabp/camunda8/wiring/parameters/Camunda8MultiInstanceTotalMethodParameter.java b/spring-boot/src/main/java/io/vanillabp/camunda8/wiring/parameters/Camunda8MultiInstanceTotalMethodParameter.java index 2bc0085..262adb9 100644 --- a/spring-boot/src/main/java/io/vanillabp/camunda8/wiring/parameters/Camunda8MultiInstanceTotalMethodParameter.java +++ b/spring-boot/src/main/java/io/vanillabp/camunda8/wiring/parameters/Camunda8MultiInstanceTotalMethodParameter.java @@ -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); } diff --git a/spring-boot/src/main/java/io/vanillabp/camunda8/wiring/parameters/Camunda8ResolverBasedMethodParameter.java b/spring-boot/src/main/java/io/vanillabp/camunda8/wiring/parameters/Camunda8ResolverBasedMethodParameter.java index ac2dffa..c5e9846 100644 --- a/spring-boot/src/main/java/io/vanillabp/camunda8/wiring/parameters/Camunda8ResolverBasedMethodParameter.java +++ b/spring-boot/src/main/java/io/vanillabp/camunda8/wiring/parameters/Camunda8ResolverBasedMethodParameter.java @@ -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); } diff --git a/spring-boot/src/main/java/io/vanillabp/camunda8/wiring/parameters/Camunda8TaskParameter.java b/spring-boot/src/main/java/io/vanillabp/camunda8/wiring/parameters/Camunda8TaskParameter.java index a76dbc5..9bf6b0c 100644 --- a/spring-boot/src/main/java/io/vanillabp/camunda8/wiring/parameters/Camunda8TaskParameter.java +++ b/spring-boot/src/main/java/io/vanillabp/camunda8/wiring/parameters/Camunda8TaskParameter.java @@ -7,9 +7,11 @@ public class Camunda8TaskParameter extends TaskParameter implements ParameterVariables { public Camunda8TaskParameter( + final int index, + final String parameter, final String name) { - super(name); + super(index, parameter, name); }