Skip to content

Commit

Permalink
[incubator-kie-issues-1556] Unify task parameters in jbpm-flow
Browse files Browse the repository at this point in the history
  • Loading branch information
elguardian committed Oct 23, 2024
1 parent 8525f22 commit d0aedfd
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@

import java.util.ArrayList;
import java.util.List;
import java.util.Set;

import org.jbpm.compiler.xml.Parser;
import org.jbpm.process.core.Work;
Expand All @@ -42,22 +41,6 @@ public Class<HumanTaskNode> generateNodeFor() {
return HumanTaskNode.class;
}

private static final Set<String> taskParameters = Set.of(
"NotStartedNotify",
"NotCompletedNotify",
"NotCompletedReassign",
"NotStartedReassign",
"Description",
"Comment",
"ActorId",
"GroupId",
"Priority",
"Skippable",
"Content",
"ExcludedOwnerId",
"BusinessAdministratorId",
"BusinessAdministratorGroupId");

@Override
protected Node handleNode(final Node node, final Element element, final String uri,
final String localName, final Parser parser) throws SAXException {
Expand All @@ -66,7 +49,7 @@ protected Node handleNode(final Node node, final Element element, final String u
Work work = humanTaskNode.getWork();
work.setName("Human Task");

taskParameters.forEach(p -> setParameter(work, p, humanTaskNode.getIoSpecification().getDataInputAssociation()));
HumanTaskNode.TASK_PARAMETERS.forEach(p -> setParameter(work, p, humanTaskNode.getIoSpecification().getDataInputAssociation()));

List<String> owners = new ArrayList<>();
org.w3c.dom.Node xmlNode = element.getFirstChild();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@
*/
package org.jbpm.compiler.canonical;

import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Optional;
Expand All @@ -30,6 +28,7 @@
import org.jbpm.process.core.datatype.DataType;
import org.jbpm.process.core.datatype.DataTypeResolver;
import org.jbpm.util.PatternConstants;
import org.jbpm.workflow.core.node.HumanTaskNode;
import org.jbpm.workflow.core.node.WorkItemNode;
import org.kie.api.definition.process.WorkflowElementIdentifier;
import org.kie.kogito.UserTask;
Expand Down Expand Up @@ -79,9 +78,6 @@ public class WorkItemModelMetaData {
private static final String WORK_ITEM = "workItem";
private static final String PARAMS = "params";

protected static final List<String> INTERNAL_FIELDS = Arrays.asList(TASK_NAME, "NodeName", "ActorId", "GroupId", "Priority", "Comment", "Skippable", "Content", "Locale",
"NotStartedNotify", "NotCompletedNotify", "NotCompletedReassign", "NotStartedReassign");

private final String packageName;

private final VariableScope processVariableScope;
Expand Down Expand Up @@ -192,7 +188,7 @@ private CompilationUnit compilationUnitInput() {
// map is task input -> context variable / process variable
Map<String, String> inputTypes = workItemNode.getIoSpecification().getInputTypes();
for (Entry<String, String> entry : workItemNode.getIoSpecification().getInputMapping().entrySet()) {
if (INTERNAL_FIELDS.contains(entry.getKey())) {
if (HumanTaskNode.TASK_PARAMETERS.contains(entry.getKey())) {
continue;
}

Expand Down Expand Up @@ -237,7 +233,7 @@ private CompilationUnit compilationUnitInput() {

for (Entry<String, Object> entry : workItemNode.getWork().getParameters().entrySet()) {

if (entry.getValue() == null || INTERNAL_FIELDS.contains(entry.getKey())) {
if (entry.getValue() == null || HumanTaskNode.TASK_PARAMETERS.contains(entry.getKey())) {
continue;
}

Expand Down Expand Up @@ -304,7 +300,7 @@ private CompilationUnit compilationUnitOutput() {
// map is task output -> context variable / process variable
Map<String, String> outputTypes = workItemNode.getIoSpecification().getOutputTypes();
for (Entry<String, String> entry : workItemNode.getIoSpecification().getOutputMappingBySources().entrySet()) {
if (entry.getValue() == null || INTERNAL_FIELDS.contains(entry.getKey())) {
if (entry.getValue() == null || HumanTaskNode.TASK_PARAMETERS.contains(entry.getKey())) {
continue;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,26 @@ public class HumanTaskNode extends WorkItemNode {

private String swimlane;

public static final Set<String> TASK_PARAMETERS = Set.of(
Work.PARAMETER_UNIQUE_TASK_ID,
"TaskName",
"NodeName",
"NotStartedNotify",
"NotCompletedNotify",
"NotCompletedReassign",
"NotStartedReassign",
"Description",
"Comment",
"ActorId",
"GroupId",
"Priority",
"Skippable",
"Content",
"Locale",
"ExcludedOwnerId",
"BusinessAdministratorId",
"BusinessAdministratorGroupId");

public HumanTaskNode() {
Work work = new WorkImpl();
work.setName("Human Task");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,9 @@
public class HumanTaskNodeInstance extends WorkItemNodeInstance {

private static final long serialVersionUID = 510l;
private static final String NODE_NAME = "NodeName";
private static final String DESCRIPTION = "Description";
private static final String PRIORITY = "Priority";
private static final String TASK_NAME = "TaskName";
private String separator = System.getProperty("org.jbpm.ht.user.separator", ",");

private static final String ACTUAL_OWNER = "ActualOwner";
private static final String ACTOR_ID = "ActorId";
private static final String GROUP_ID = "GroupId";
private static final String BUSINESSADMINISTRATOR_ID = "BusinessAdministratorId";
private static final String BUSINESSADMINISTRATOR_GROUP_ID = "BusinessAdministratorGroupId";
private static final String EXCLUDED_OWNER_ID = "ExcludedOwnerId";

private static final String WORK_ITEM_TRANSITION = "workItemTransition";

private transient SwimlaneContextInstance swimlaneContextInstance;
Expand Down
4 changes: 4 additions & 0 deletions jbpm/jbpm-usertask-workitem/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@
<groupId>org.kie.kogito</groupId>
<artifactId>kogito-api</artifactId>
</dependency>
<dependency>
<groupId>org.kie.kogito</groupId>
<artifactId>jbpm-flow</artifactId>
</dependency>
<dependency>
<groupId>org.kie.kogito</groupId>
<artifactId>jbpm-usertask</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import java.util.Optional;
import java.util.Set;

import org.jbpm.workflow.core.node.HumanTaskNode;
import org.kie.kogito.Application;
import org.kie.kogito.auth.IdentityProviders;
import org.kie.kogito.internal.process.workitem.KogitoWorkItem;
Expand Down Expand Up @@ -88,7 +89,7 @@ public Optional<WorkItemTransition> activateWorkItemHandler(KogitoWorkItemManage

userTask.instances().create(instance);
instance.fireInitialStateChange();
workItem.getParameters().forEach(instance::setInput);
workItem.getParameters().entrySet().stream().filter(e -> !HumanTaskNode.TASK_PARAMETERS.contains(e.getKey())).forEach(e -> instance.setInput(e.getKey(), e.getValue()));

ofNullable(workItem.getParameters().get(ACTOR_ID)).map(String.class::cast).map(this::toSet).ifPresent(instance::setPotentialUsers);
ofNullable(workItem.getParameters().get(GROUP_ID)).map(String.class::cast).map(this::toSet).ifPresent(instance::setPotentialGroups);
Expand Down

0 comments on commit d0aedfd

Please sign in to comment.