From b850445eb16423a8689405d912f3d74614274a05 Mon Sep 17 00:00:00 2001 From: Enrique Date: Mon, 13 May 2024 08:56:35 +0200 Subject: [PATCH 01/32] [incubator-kie-issues-1109] Add capability to extends the flow builder (#3497) This allows includes new nodes dynamically --- .../core/RuleFlowNodeContainerFactory.java | 88 +++++++++++++------ .../ruleflow/core/RuleFlowProcessFactory.java | 9 +- .../factory/AbstractCompositeNodeFactory.java | 7 +- .../core/factory/ActionNodeFactory.java | 1 + .../core/factory/DynamicNodeFactory.java | 1 + .../core/factory/ExtendedNodeFactory.java | 23 +++++ .../ruleflow/core/factory/NodeFactory.java | 28 ------ .../provider/ActionNodeFactoryProvider.java | 38 ++++++++ .../BoundaryEventNodeFactoryProvider.java | 38 ++++++++ .../CatchLinkNodeFactoryProvider.java | 40 +++++++++ .../CompositeContextNodeFactoryProvider.java | 40 +++++++++ .../provider/DynamicNodeFactoryProvider.java | 40 +++++++++ .../provider/EndNodeFactoryProvider.java | 40 +++++++++ .../provider/EventNodeFactoryProvider.java | 40 +++++++++ .../EventSubProcessNodeFactoryProvider.java | 40 +++++++++ .../provider/FaultNodeFactoryProvider.java | 40 +++++++++ .../provider/ForEachNodeFactoryProvider.java | 40 +++++++++ .../HumanTaskNodeFactoryProvider.java | 40 +++++++++ .../provider/JoinNodeFactoryProvider.java | 40 +++++++++ .../MilestoneNodeFactoryProvider.java | 40 +++++++++ .../factory/provider/NodeFactoryProvider.java | 32 +++++++ .../provider/NodeFactoryProviderService.java | 50 +++++++++++ .../provider/RuleSetNodeFactoryProvider.java | 40 +++++++++ .../provider/SplitNodeFactoryProvider.java | 40 +++++++++ .../provider/StartNodeFactoryProvider.java | 40 +++++++++ .../provider/StateNodeFactoryProvider.java | 40 +++++++++ .../SubProcessNodeFactoryProvider.java | 40 +++++++++ .../ThrowLinkNodeFactoryProvider.java | 41 +++++++++ .../provider/TimerNodeFactoryProvider.java | 40 +++++++++ .../provider/WorkItemNodeFactoryProvider.java | 40 +++++++++ ....core.factory.provider.NodeFactoryProvider | 21 +++++ .../model}/Movie.java | 0 .../model}/MovieGenre.java | 0 .../model}/Rating.java | 0 .../VersionRestController.java | 2 +- 35 files changed, 1039 insertions(+), 60 deletions(-) create mode 100644 jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/factory/provider/ActionNodeFactoryProvider.java create mode 100644 jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/factory/provider/BoundaryEventNodeFactoryProvider.java create mode 100644 jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/factory/provider/CatchLinkNodeFactoryProvider.java create mode 100644 jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/factory/provider/CompositeContextNodeFactoryProvider.java create mode 100644 jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/factory/provider/DynamicNodeFactoryProvider.java create mode 100644 jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/factory/provider/EndNodeFactoryProvider.java create mode 100644 jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/factory/provider/EventNodeFactoryProvider.java create mode 100644 jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/factory/provider/EventSubProcessNodeFactoryProvider.java create mode 100644 jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/factory/provider/FaultNodeFactoryProvider.java create mode 100644 jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/factory/provider/ForEachNodeFactoryProvider.java create mode 100644 jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/factory/provider/HumanTaskNodeFactoryProvider.java create mode 100644 jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/factory/provider/JoinNodeFactoryProvider.java create mode 100644 jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/factory/provider/MilestoneNodeFactoryProvider.java create mode 100644 jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/factory/provider/NodeFactoryProvider.java create mode 100644 jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/factory/provider/NodeFactoryProviderService.java create mode 100644 jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/factory/provider/RuleSetNodeFactoryProvider.java create mode 100644 jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/factory/provider/SplitNodeFactoryProvider.java create mode 100644 jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/factory/provider/StartNodeFactoryProvider.java create mode 100644 jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/factory/provider/StateNodeFactoryProvider.java create mode 100644 jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/factory/provider/SubProcessNodeFactoryProvider.java create mode 100644 jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/factory/provider/ThrowLinkNodeFactoryProvider.java create mode 100644 jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/factory/provider/TimerNodeFactoryProvider.java create mode 100644 jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/factory/provider/WorkItemNodeFactoryProvider.java create mode 100644 jbpm/jbpm-flow/src/main/resources/META-INF/services/org.jbpm.ruleflow.core.factory.provider.NodeFactoryProvider rename springboot/integration-tests/src/it/integration-tests-springboot-processes-it/src/main/java/org/acme/{examples.model => examples/model}/Movie.java (100%) rename springboot/integration-tests/src/it/integration-tests-springboot-processes-it/src/main/java/org/acme/{examples.model => examples/model}/MovieGenre.java (100%) rename springboot/integration-tests/src/it/integration-tests-springboot-processes-it/src/main/java/org/acme/{examples.model => examples/model}/Rating.java (100%) diff --git a/jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/RuleFlowNodeContainerFactory.java b/jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/RuleFlowNodeContainerFactory.java index 66c1e2e16df..8dbdc4769c2 100755 --- a/jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/RuleFlowNodeContainerFactory.java +++ b/jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/RuleFlowNodeContainerFactory.java @@ -34,6 +34,7 @@ import org.jbpm.ruleflow.core.factory.EndNodeFactory; import org.jbpm.ruleflow.core.factory.EventNodeFactory; import org.jbpm.ruleflow.core.factory.EventSubProcessNodeFactory; +import org.jbpm.ruleflow.core.factory.ExtendedNodeFactory; import org.jbpm.ruleflow.core.factory.FaultNodeFactory; import org.jbpm.ruleflow.core.factory.ForEachNodeFactory; import org.jbpm.ruleflow.core.factory.HumanTaskNodeFactory; @@ -48,10 +49,32 @@ import org.jbpm.ruleflow.core.factory.ThrowLinkNodeFactory; import org.jbpm.ruleflow.core.factory.TimerNodeFactory; import org.jbpm.ruleflow.core.factory.WorkItemNodeFactory; +import org.jbpm.ruleflow.core.factory.provider.NodeFactoryProviderService; import org.jbpm.workflow.core.Connection; import org.jbpm.workflow.core.NodeContainer; import org.jbpm.workflow.core.impl.ConnectionImpl; import org.jbpm.workflow.core.impl.DroolsConsequenceAction; +import org.jbpm.workflow.core.node.ActionNode; +import org.jbpm.workflow.core.node.BoundaryEventNode; +import org.jbpm.workflow.core.node.CatchLinkNode; +import org.jbpm.workflow.core.node.CompositeContextNode; +import org.jbpm.workflow.core.node.DynamicNode; +import org.jbpm.workflow.core.node.EndNode; +import org.jbpm.workflow.core.node.EventNode; +import org.jbpm.workflow.core.node.EventSubProcessNode; +import org.jbpm.workflow.core.node.FaultNode; +import org.jbpm.workflow.core.node.ForEachNode; +import org.jbpm.workflow.core.node.HumanTaskNode; +import org.jbpm.workflow.core.node.Join; +import org.jbpm.workflow.core.node.MilestoneNode; +import org.jbpm.workflow.core.node.RuleSetNode; +import org.jbpm.workflow.core.node.Split; +import org.jbpm.workflow.core.node.StartNode; +import org.jbpm.workflow.core.node.StateNode; +import org.jbpm.workflow.core.node.SubProcessNode; +import org.jbpm.workflow.core.node.ThrowLinkNode; +import org.jbpm.workflow.core.node.TimerNode; +import org.jbpm.workflow.core.node.WorkItemNode; import org.kie.api.definition.process.Node; import org.kie.api.definition.process.WorkflowElementIdentifier; @@ -60,97 +83,106 @@ import static org.jbpm.ruleflow.core.Metadata.UNIQUE_ID; import static org.jbpm.workflow.core.Node.CONNECTION_DEFAULT_TYPE; -public abstract class RuleFlowNodeContainerFactory, P extends RuleFlowNodeContainerFactory> extends NodeFactory { +public abstract class RuleFlowNodeContainerFactory, P extends RuleFlowNodeContainerFactory> extends ExtendedNodeFactory { public static final String METHOD_CONNECTION = "connection"; public static final String METHOD_ASSOCIATION = "association"; - protected RuleFlowNodeContainerFactory(P nodeContainerFactory, NodeContainer nodeContainer, NodeContainer node, WorkflowElementIdentifier id) { + private NodeFactoryProviderService provider; + + public RuleFlowNodeContainerFactory(P nodeContainerFactory, NodeContainer nodeContainer, org.jbpm.workflow.core.Node node, WorkflowElementIdentifier id) { super(nodeContainerFactory, nodeContainer, node, id); + provider = new NodeFactoryProviderService(); + } + + protected abstract NodeContainer getNodeContainer(); + + public > R newNode(Class node, WorkflowElementIdentifier id) { + return provider.newNodeFactory(node, (T) this, getNodeContainer(), id); } public StartNodeFactory startNode(WorkflowElementIdentifier id) { - return new StartNodeFactory<>((T) this, (NodeContainer) node, id); + return newNode(StartNode.class, id); } public EndNodeFactory endNode(WorkflowElementIdentifier id) { - return new EndNodeFactory<>((T) this, (NodeContainer) node, id); + return newNode(EndNode.class, id); } public CatchLinkNodeFactory catchLinkNode(WorkflowElementIdentifier id) { - return new CatchLinkNodeFactory<>((T) this, (NodeContainer) node, id); + return newNode(CatchLinkNode.class, id); } public ThrowLinkNodeFactory throwLinkNode(WorkflowElementIdentifier id) { - return new ThrowLinkNodeFactory<>((T) this, (NodeContainer) node, id); + return newNode(ThrowLinkNode.class, id); } public ActionNodeFactory actionNode(WorkflowElementIdentifier id) { - return new ActionNodeFactory<>((T) this, (NodeContainer) node, id); + return newNode(ActionNode.class, id); } public MilestoneNodeFactory milestoneNode(WorkflowElementIdentifier id) { - return new MilestoneNodeFactory<>((T) this, (NodeContainer) node, id); + return newNode(MilestoneNode.class, id); } public TimerNodeFactory timerNode(WorkflowElementIdentifier id) { - return new TimerNodeFactory<>((T) this, (NodeContainer) node, id); + return newNode(TimerNode.class, id); } public HumanTaskNodeFactory humanTaskNode(WorkflowElementIdentifier id) { - return new HumanTaskNodeFactory<>((T) this, (NodeContainer) node, id); + return newNode(HumanTaskNode.class, id); } public SubProcessNodeFactory subProcessNode(WorkflowElementIdentifier id) { - return new SubProcessNodeFactory<>((T) this, (NodeContainer) node, id); + return newNode(SubProcessNode.class, id); } public SplitFactory splitNode(WorkflowElementIdentifier id) { - return new SplitFactory<>((T) this, (NodeContainer) node, id); + return newNode(Split.class, id); } public JoinFactory joinNode(WorkflowElementIdentifier id) { - return new JoinFactory<>((T) this, (NodeContainer) node, id); + return newNode(Join.class, id); } public RuleSetNodeFactory ruleSetNode(WorkflowElementIdentifier id) { - return new RuleSetNodeFactory<>((T) this, (NodeContainer) node, id); + return newNode(RuleSetNode.class, id); } public FaultNodeFactory faultNode(WorkflowElementIdentifier id) { - return new FaultNodeFactory<>((T) this, (NodeContainer) node, id); + return newNode(FaultNode.class, id); } public EventNodeFactory eventNode(WorkflowElementIdentifier id) { - return new EventNodeFactory<>((T) this, (NodeContainer) node, id); + return newNode(EventNode.class, id); } public BoundaryEventNodeFactory boundaryEventNode(WorkflowElementIdentifier id) { - return new BoundaryEventNodeFactory<>((T) this, (NodeContainer) node, id); + return newNode(BoundaryEventNode.class, id); } public CompositeContextNodeFactory compositeContextNode(WorkflowElementIdentifier id) { - return new CompositeContextNodeFactory<>((T) this, (NodeContainer) node, id); + return newNode(CompositeContextNode.class, id); } public ForEachNodeFactory forEachNode(WorkflowElementIdentifier id) { - return new ForEachNodeFactory<>((T) this, (NodeContainer) node, id); + return newNode(ForEachNode.class, id); } public DynamicNodeFactory dynamicNode(WorkflowElementIdentifier id) { - return new DynamicNodeFactory<>((T) this, (NodeContainer) node, id); + return newNode(DynamicNode.class, id); } public WorkItemNodeFactory workItemNode(WorkflowElementIdentifier id) { - return new WorkItemNodeFactory<>((T) this, (NodeContainer) node, id); + return newNode(WorkItemNode.class, id); } public EventSubProcessNodeFactory eventSubProcessNode(WorkflowElementIdentifier id) { - return new EventSubProcessNodeFactory<>((T) this, (NodeContainer) node, id); + return newNode(EventSubProcessNode.class, id); } public StateNodeFactory stateNode(WorkflowElementIdentifier id) { - return new StateNodeFactory<>((T) this, (NodeContainer) node, id); + return newNode(StateNode.class, id); } public T connection(WorkflowElementIdentifier fromId, WorkflowElementIdentifier toId) { @@ -170,8 +202,8 @@ public T association(WorkflowElementIdentifier fromId, WorkflowElementIdentifier } private Connection getConnection(WorkflowElementIdentifier fromId, WorkflowElementIdentifier toId, String uniqueId) { - Node from = ((NodeContainer) node).getNode(fromId); - Node to = ((NodeContainer) node).getNode(toId); + Node from = ((NodeContainer) getNodeContainer()).getNode(fromId); + Node to = ((NodeContainer) getNodeContainer()).getNode(toId); Connection connection = new ConnectionImpl(from, CONNECTION_DEFAULT_TYPE, to, CONNECTION_DEFAULT_TYPE); if (uniqueId != null) { connection.setMetaData(UNIQUE_ID, uniqueId); @@ -212,7 +244,7 @@ public T errorExceptionHandler(String signalType, String faultCode, String fault public abstract T variable(String name, DataType type, Object value, String metaDataName, Object metaDataValue); private S getScope(String scopeType, Class scopeClass) { - ContextContainer contextContainer = (ContextContainer) node; + ContextContainer contextContainer = (ContextContainer) getNodeContainer(); Context scope = contextContainer.getDefaultContext(scopeType); if (scope == null) { try { @@ -227,9 +259,9 @@ private S getScope(String scopeType, Class scopeClass) { } public RuleFlowNodeContainerFactory addCompensationContext(String contextId) { - if (node instanceof ContextContainer) { + if (getNodeContainer() instanceof ContextContainer) { CompensationScope compensationScope = new CompensationScope(); - ContextContainer contextNode = (ContextContainer) node; + ContextContainer contextNode = (ContextContainer) getNodeContainer(); contextNode.addContext(compensationScope); contextNode.setDefaultContext(compensationScope); compensationScope.setContextContainerId(contextId); diff --git a/jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/RuleFlowProcessFactory.java b/jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/RuleFlowProcessFactory.java index 881a28be781..a0acf5d140e 100755 --- a/jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/RuleFlowProcessFactory.java +++ b/jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/RuleFlowProcessFactory.java @@ -95,8 +95,13 @@ public static RuleFlowProcessFactory createProcess(String id, boolean autoComple return new RuleFlowProcessFactory(id, autoComplete); } + @Override + protected org.jbpm.workflow.core.NodeContainer getNodeContainer() { + return nodeContainer; + } + protected RuleFlowProcessFactory(String id, boolean autoComplete) { - super(null, null, new RuleFlowProcess(), WorkflowElementIdentifierFactory.fromExternalFormat(id)); + super(null, new RuleFlowProcess(), null, WorkflowElementIdentifierFactory.fromExternalFormat(id)); getRuleFlowProcess().setAutoComplete(autoComplete); } @@ -111,7 +116,7 @@ public RuleFlowProcessFactory expressionLanguage(String exprLanguage) { } protected RuleFlowProcess getRuleFlowProcess() { - return (RuleFlowProcess) node; + return (RuleFlowProcess) nodeContainer; } @Override diff --git a/jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/factory/AbstractCompositeNodeFactory.java b/jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/factory/AbstractCompositeNodeFactory.java index 329534bbedc..aacc99b20b8 100644 --- a/jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/factory/AbstractCompositeNodeFactory.java +++ b/jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/factory/AbstractCompositeNodeFactory.java @@ -33,10 +33,15 @@ public abstract class AbstractCompositeNodeFactory action(Action action) { getActionNode().setAction(droolsAction); return this; } + } diff --git a/jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/factory/DynamicNodeFactory.java b/jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/factory/DynamicNodeFactory.java index 8c9dffb8ce5..53acb5bcdcf 100755 --- a/jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/factory/DynamicNodeFactory.java +++ b/jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/factory/DynamicNodeFactory.java @@ -54,4 +54,5 @@ public DynamicNodeFactory completionExpression(Predicate comp getDynamicNode().setCompletionExpression(completionExpression); return this; } + } diff --git a/jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/factory/ExtendedNodeFactory.java b/jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/factory/ExtendedNodeFactory.java index 0a22a65261d..9eecb0bbf17 100755 --- a/jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/factory/ExtendedNodeFactory.java +++ b/jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/factory/ExtendedNodeFactory.java @@ -18,9 +18,13 @@ */ package org.jbpm.ruleflow.core.factory; +import java.util.ArrayList; + +import org.jbpm.process.instance.impl.Action; import org.jbpm.ruleflow.core.RuleFlowNodeContainerFactory; import org.jbpm.workflow.core.Node; import org.jbpm.workflow.core.NodeContainer; +import org.jbpm.workflow.core.impl.DroolsConsequenceAction; import org.jbpm.workflow.core.impl.ExtendedNodeImpl; import org.kie.api.definition.process.WorkflowElementIdentifier; @@ -34,4 +38,23 @@ protected ExtendedNodeImpl getExtendedNode() { return (ExtendedNodeImpl) getNode(); } + public T onEntryAction(String dialect, String action) { + return onActionScript(ExtendedNodeImpl.EVENT_NODE_ENTER, dialect, action, null); + } + + public T onExitAction(String dialect, String action) { + return onActionScript(ExtendedNodeImpl.EVENT_NODE_EXIT, dialect, action, null); + } + + public T onActionScript(String type, String dialect, String script, Action compiledScript) { + DroolsConsequenceAction action = new DroolsConsequenceAction(dialect, script); + if (compiledScript != null) { + action.setMetaData("Action", compiledScript); + } + if (getExtendedNode().getActions(type) == null) { + getExtendedNode().setActions(type, new ArrayList<>()); + } + getExtendedNode().getActions(type).add(action); + return (T) this; + } } diff --git a/jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/factory/NodeFactory.java b/jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/factory/NodeFactory.java index ba22a6d53bc..bcbfb1f475f 100755 --- a/jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/factory/NodeFactory.java +++ b/jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/factory/NodeFactory.java @@ -18,15 +18,10 @@ */ package org.jbpm.ruleflow.core.factory; -import java.util.ArrayList; - import org.jbpm.process.core.context.variable.Mappable; -import org.jbpm.process.instance.impl.Action; import org.jbpm.ruleflow.core.RuleFlowNodeContainerFactory; import org.jbpm.workflow.core.Node; import org.jbpm.workflow.core.NodeContainer; -import org.jbpm.workflow.core.impl.DroolsConsequenceAction; -import org.jbpm.workflow.core.impl.ExtendedNodeImpl; import org.kie.api.definition.process.WorkflowElementIdentifier; public abstract class NodeFactory, P extends RuleFlowNodeContainerFactory> implements MappableNodeFactory { @@ -76,27 +71,4 @@ public Mappable getMappableNode() { return (Mappable) node; } - public T onEntryAction(String dialect, String action) { - return onActionScript(ExtendedNodeImpl.EVENT_NODE_ENTER, dialect, action, null); - } - - public T onExitAction(String dialect, String action) { - return onActionScript(ExtendedNodeImpl.EVENT_NODE_EXIT, dialect, action, null); - } - - public T onActionScript(String type, String dialect, String script, Action compiledScript) { - DroolsConsequenceAction action = new DroolsConsequenceAction(dialect, script); - if (compiledScript != null) { - action.setMetaData("Action", compiledScript); - } - if (getExtendedNode().getActions(type) == null) { - getExtendedNode().setActions(type, new ArrayList<>()); - } - getExtendedNode().getActions(type).add(action); - return (T) this; - } - - private ExtendedNodeImpl getExtendedNode() { - return (ExtendedNodeImpl) getNode(); - } } diff --git a/jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/factory/provider/ActionNodeFactoryProvider.java b/jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/factory/provider/ActionNodeFactoryProvider.java new file mode 100644 index 00000000000..7bf44360bf1 --- /dev/null +++ b/jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/factory/provider/ActionNodeFactoryProvider.java @@ -0,0 +1,38 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.jbpm.ruleflow.core.factory.provider; + +import org.jbpm.ruleflow.core.RuleFlowNodeContainerFactory; +import org.jbpm.ruleflow.core.factory.ActionNodeFactory; +import org.jbpm.ruleflow.core.factory.NodeFactory; +import org.jbpm.workflow.core.NodeContainer; +import org.jbpm.workflow.core.node.ActionNode; +import org.kie.api.definition.process.WorkflowElementIdentifier; + +public class ActionNodeFactoryProvider implements NodeFactoryProvider { + @Override + public boolean accept(Class type) { + return ActionNode.class.equals(type); + } + + @Override + public , P extends RuleFlowNodeContainerFactory> R provide(P nodeContainerFactory, NodeContainer container, WorkflowElementIdentifier id) { + return (R) new ActionNodeFactory

(nodeContainerFactory, container, id); + } +} diff --git a/jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/factory/provider/BoundaryEventNodeFactoryProvider.java b/jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/factory/provider/BoundaryEventNodeFactoryProvider.java new file mode 100644 index 00000000000..ef900417779 --- /dev/null +++ b/jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/factory/provider/BoundaryEventNodeFactoryProvider.java @@ -0,0 +1,38 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.jbpm.ruleflow.core.factory.provider; + +import org.jbpm.ruleflow.core.RuleFlowNodeContainerFactory; +import org.jbpm.ruleflow.core.factory.BoundaryEventNodeFactory; +import org.jbpm.ruleflow.core.factory.NodeFactory; +import org.jbpm.workflow.core.NodeContainer; +import org.jbpm.workflow.core.node.BoundaryEventNode; +import org.kie.api.definition.process.WorkflowElementIdentifier; + +public class BoundaryEventNodeFactoryProvider implements NodeFactoryProvider { + @Override + public boolean accept(Class type) { + return BoundaryEventNode.class.equals(type); + } + + @Override + public , P extends RuleFlowNodeContainerFactory> R provide(P nodeContainerFactory, NodeContainer container, WorkflowElementIdentifier id) { + return (R) new BoundaryEventNodeFactory

(nodeContainerFactory, container, id); + } +} diff --git a/jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/factory/provider/CatchLinkNodeFactoryProvider.java b/jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/factory/provider/CatchLinkNodeFactoryProvider.java new file mode 100644 index 00000000000..5f74211ae80 --- /dev/null +++ b/jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/factory/provider/CatchLinkNodeFactoryProvider.java @@ -0,0 +1,40 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.jbpm.ruleflow.core.factory.provider; + +import org.jbpm.ruleflow.core.RuleFlowNodeContainerFactory; +import org.jbpm.ruleflow.core.factory.CatchLinkNodeFactory; +import org.jbpm.ruleflow.core.factory.NodeFactory; +import org.jbpm.workflow.core.NodeContainer; +import org.jbpm.workflow.core.node.CatchLinkNode; +import org.kie.api.definition.process.WorkflowElementIdentifier; + +public class CatchLinkNodeFactoryProvider implements NodeFactoryProvider { + + @Override + public boolean accept(Class type) { + return CatchLinkNode.class.equals(type); + } + + @Override + public , P extends RuleFlowNodeContainerFactory> T provide(P nodeContainerFactory, NodeContainer container, WorkflowElementIdentifier id) { + return (T) new CatchLinkNodeFactory

(nodeContainerFactory, container, id); + } + +} diff --git a/jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/factory/provider/CompositeContextNodeFactoryProvider.java b/jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/factory/provider/CompositeContextNodeFactoryProvider.java new file mode 100644 index 00000000000..8dbe4255aae --- /dev/null +++ b/jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/factory/provider/CompositeContextNodeFactoryProvider.java @@ -0,0 +1,40 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.jbpm.ruleflow.core.factory.provider; + +import org.jbpm.ruleflow.core.RuleFlowNodeContainerFactory; +import org.jbpm.ruleflow.core.factory.CompositeContextNodeFactory; +import org.jbpm.ruleflow.core.factory.NodeFactory; +import org.jbpm.workflow.core.NodeContainer; +import org.jbpm.workflow.core.node.CompositeContextNode; +import org.kie.api.definition.process.WorkflowElementIdentifier; + +public class CompositeContextNodeFactoryProvider implements NodeFactoryProvider { + + @Override + public boolean accept(Class type) { + return CompositeContextNode.class.equals(type); + } + + @Override + public , P extends RuleFlowNodeContainerFactory> R provide(P nodeContainerFactory, NodeContainer container, WorkflowElementIdentifier id) { + return (R) new CompositeContextNodeFactory(nodeContainerFactory, container, id); + } + +} diff --git a/jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/factory/provider/DynamicNodeFactoryProvider.java b/jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/factory/provider/DynamicNodeFactoryProvider.java new file mode 100644 index 00000000000..915a273ffe6 --- /dev/null +++ b/jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/factory/provider/DynamicNodeFactoryProvider.java @@ -0,0 +1,40 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.jbpm.ruleflow.core.factory.provider; + +import org.jbpm.ruleflow.core.RuleFlowNodeContainerFactory; +import org.jbpm.ruleflow.core.factory.DynamicNodeFactory; +import org.jbpm.ruleflow.core.factory.NodeFactory; +import org.jbpm.workflow.core.NodeContainer; +import org.jbpm.workflow.core.node.DynamicNode; +import org.kie.api.definition.process.WorkflowElementIdentifier; + +public class DynamicNodeFactoryProvider implements NodeFactoryProvider { + + @Override + public boolean accept(Class type) { + return DynamicNode.class.equals(type); + } + + @Override + public , P extends RuleFlowNodeContainerFactory> R provide(P nodeContainerFactory, NodeContainer container, WorkflowElementIdentifier id) { + return (R) new DynamicNodeFactory

(nodeContainerFactory, container, id); + } + +} diff --git a/jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/factory/provider/EndNodeFactoryProvider.java b/jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/factory/provider/EndNodeFactoryProvider.java new file mode 100644 index 00000000000..17ada6a17f7 --- /dev/null +++ b/jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/factory/provider/EndNodeFactoryProvider.java @@ -0,0 +1,40 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.jbpm.ruleflow.core.factory.provider; + +import org.jbpm.ruleflow.core.RuleFlowNodeContainerFactory; +import org.jbpm.ruleflow.core.factory.EndNodeFactory; +import org.jbpm.ruleflow.core.factory.NodeFactory; +import org.jbpm.workflow.core.NodeContainer; +import org.jbpm.workflow.core.node.EndNode; +import org.kie.api.definition.process.WorkflowElementIdentifier; + +public class EndNodeFactoryProvider implements NodeFactoryProvider { + + @Override + public boolean accept(Class type) { + return EndNode.class.equals(type); + } + + @Override + public , P extends RuleFlowNodeContainerFactory> T provide(P nodeContainerFactory, NodeContainer container, WorkflowElementIdentifier id) { + return (T) new EndNodeFactory

(nodeContainerFactory, container, id); + } + +} diff --git a/jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/factory/provider/EventNodeFactoryProvider.java b/jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/factory/provider/EventNodeFactoryProvider.java new file mode 100644 index 00000000000..c0643fa38e2 --- /dev/null +++ b/jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/factory/provider/EventNodeFactoryProvider.java @@ -0,0 +1,40 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.jbpm.ruleflow.core.factory.provider; + +import org.jbpm.ruleflow.core.RuleFlowNodeContainerFactory; +import org.jbpm.ruleflow.core.factory.EventNodeFactory; +import org.jbpm.ruleflow.core.factory.NodeFactory; +import org.jbpm.workflow.core.NodeContainer; +import org.jbpm.workflow.core.node.EventNode; +import org.kie.api.definition.process.WorkflowElementIdentifier; + +public class EventNodeFactoryProvider implements NodeFactoryProvider { + + @Override + public boolean accept(Class type) { + return EventNode.class.equals(type); + } + + @Override + public , P extends RuleFlowNodeContainerFactory> R provide(P nodeContainerFactory, NodeContainer container, WorkflowElementIdentifier id) { + return (R) new EventNodeFactory

(nodeContainerFactory, container, id); + } + +} diff --git a/jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/factory/provider/EventSubProcessNodeFactoryProvider.java b/jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/factory/provider/EventSubProcessNodeFactoryProvider.java new file mode 100644 index 00000000000..91c10cba38d --- /dev/null +++ b/jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/factory/provider/EventSubProcessNodeFactoryProvider.java @@ -0,0 +1,40 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.jbpm.ruleflow.core.factory.provider; + +import org.jbpm.ruleflow.core.RuleFlowNodeContainerFactory; +import org.jbpm.ruleflow.core.factory.EventSubProcessNodeFactory; +import org.jbpm.ruleflow.core.factory.NodeFactory; +import org.jbpm.workflow.core.NodeContainer; +import org.jbpm.workflow.core.node.EventSubProcessNode; +import org.kie.api.definition.process.WorkflowElementIdentifier; + +public class EventSubProcessNodeFactoryProvider implements NodeFactoryProvider { + + @Override + public boolean accept(Class type) { + return EventSubProcessNode.class.equals(type); + } + + @Override + public , P extends RuleFlowNodeContainerFactory> R provide(P nodeContainerFactory, NodeContainer container, WorkflowElementIdentifier id) { + return (R) new EventSubProcessNodeFactory

(nodeContainerFactory, container, id); + } + +} diff --git a/jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/factory/provider/FaultNodeFactoryProvider.java b/jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/factory/provider/FaultNodeFactoryProvider.java new file mode 100644 index 00000000000..f5922d1392a --- /dev/null +++ b/jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/factory/provider/FaultNodeFactoryProvider.java @@ -0,0 +1,40 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.jbpm.ruleflow.core.factory.provider; + +import org.jbpm.ruleflow.core.RuleFlowNodeContainerFactory; +import org.jbpm.ruleflow.core.factory.FaultNodeFactory; +import org.jbpm.ruleflow.core.factory.NodeFactory; +import org.jbpm.workflow.core.NodeContainer; +import org.jbpm.workflow.core.node.FaultNode; +import org.kie.api.definition.process.WorkflowElementIdentifier; + +public class FaultNodeFactoryProvider implements NodeFactoryProvider { + + @Override + public boolean accept(Class type) { + return FaultNode.class.equals(type); + } + + @Override + public , P extends RuleFlowNodeContainerFactory> R provide(P nodeContainerFactory, NodeContainer container, WorkflowElementIdentifier id) { + return (R) new FaultNodeFactory(nodeContainerFactory, container, id); + } + +} diff --git a/jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/factory/provider/ForEachNodeFactoryProvider.java b/jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/factory/provider/ForEachNodeFactoryProvider.java new file mode 100644 index 00000000000..750c7591660 --- /dev/null +++ b/jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/factory/provider/ForEachNodeFactoryProvider.java @@ -0,0 +1,40 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.jbpm.ruleflow.core.factory.provider; + +import org.jbpm.ruleflow.core.RuleFlowNodeContainerFactory; +import org.jbpm.ruleflow.core.factory.ForEachNodeFactory; +import org.jbpm.ruleflow.core.factory.NodeFactory; +import org.jbpm.workflow.core.NodeContainer; +import org.jbpm.workflow.core.node.ForEachNode; +import org.kie.api.definition.process.WorkflowElementIdentifier; + +public class ForEachNodeFactoryProvider implements NodeFactoryProvider { + + @Override + public boolean accept(Class type) { + return ForEachNode.class.equals(type); + } + + @Override + public , P extends RuleFlowNodeContainerFactory> R provide(P nodeContainerFactory, NodeContainer container, WorkflowElementIdentifier id) { + return (R) new ForEachNodeFactory

(nodeContainerFactory, container, id); + } + +} diff --git a/jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/factory/provider/HumanTaskNodeFactoryProvider.java b/jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/factory/provider/HumanTaskNodeFactoryProvider.java new file mode 100644 index 00000000000..7a11553d8a3 --- /dev/null +++ b/jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/factory/provider/HumanTaskNodeFactoryProvider.java @@ -0,0 +1,40 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.jbpm.ruleflow.core.factory.provider; + +import org.jbpm.ruleflow.core.RuleFlowNodeContainerFactory; +import org.jbpm.ruleflow.core.factory.HumanTaskNodeFactory; +import org.jbpm.ruleflow.core.factory.NodeFactory; +import org.jbpm.workflow.core.NodeContainer; +import org.jbpm.workflow.core.node.HumanTaskNode; +import org.kie.api.definition.process.WorkflowElementIdentifier; + +public class HumanTaskNodeFactoryProvider implements NodeFactoryProvider { + + @Override + public boolean accept(Class type) { + return HumanTaskNode.class.equals(type); + } + + @Override + public , P extends RuleFlowNodeContainerFactory> R provide(P nodeContainerFactory, NodeContainer container, WorkflowElementIdentifier id) { + return (R) new HumanTaskNodeFactory

(nodeContainerFactory, container, id); + } + +} diff --git a/jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/factory/provider/JoinNodeFactoryProvider.java b/jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/factory/provider/JoinNodeFactoryProvider.java new file mode 100644 index 00000000000..d873bb042e9 --- /dev/null +++ b/jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/factory/provider/JoinNodeFactoryProvider.java @@ -0,0 +1,40 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.jbpm.ruleflow.core.factory.provider; + +import org.jbpm.ruleflow.core.RuleFlowNodeContainerFactory; +import org.jbpm.ruleflow.core.factory.JoinFactory; +import org.jbpm.ruleflow.core.factory.NodeFactory; +import org.jbpm.workflow.core.NodeContainer; +import org.jbpm.workflow.core.node.Join; +import org.kie.api.definition.process.WorkflowElementIdentifier; + +public class JoinNodeFactoryProvider implements NodeFactoryProvider { + + @Override + public boolean accept(Class type) { + return Join.class.equals(type); + } + + @Override + public , P extends RuleFlowNodeContainerFactory> R provide(P nodeContainerFactory, NodeContainer container, WorkflowElementIdentifier id) { + return (R) new JoinFactory

(nodeContainerFactory, container, id); + } + +} diff --git a/jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/factory/provider/MilestoneNodeFactoryProvider.java b/jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/factory/provider/MilestoneNodeFactoryProvider.java new file mode 100644 index 00000000000..05f61257320 --- /dev/null +++ b/jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/factory/provider/MilestoneNodeFactoryProvider.java @@ -0,0 +1,40 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.jbpm.ruleflow.core.factory.provider; + +import org.jbpm.ruleflow.core.RuleFlowNodeContainerFactory; +import org.jbpm.ruleflow.core.factory.MilestoneNodeFactory; +import org.jbpm.ruleflow.core.factory.NodeFactory; +import org.jbpm.workflow.core.NodeContainer; +import org.jbpm.workflow.core.node.MilestoneNode; +import org.kie.api.definition.process.WorkflowElementIdentifier; + +public class MilestoneNodeFactoryProvider implements NodeFactoryProvider { + + @Override + public boolean accept(Class type) { + return MilestoneNode.class.equals(type); + } + + @Override + public , P extends RuleFlowNodeContainerFactory> R provide(P nodeContainerFactory, NodeContainer container, WorkflowElementIdentifier id) { + return (R) new MilestoneNodeFactory(nodeContainerFactory, container, id); + } + +} diff --git a/jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/factory/provider/NodeFactoryProvider.java b/jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/factory/provider/NodeFactoryProvider.java new file mode 100644 index 00000000000..ae12e7ff810 --- /dev/null +++ b/jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/factory/provider/NodeFactoryProvider.java @@ -0,0 +1,32 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.jbpm.ruleflow.core.factory.provider; + +import org.jbpm.ruleflow.core.RuleFlowNodeContainerFactory; +import org.jbpm.ruleflow.core.factory.NodeFactory; +import org.jbpm.workflow.core.NodeContainer; +import org.kie.api.definition.process.WorkflowElementIdentifier; + +public interface NodeFactoryProvider { + + boolean accept(Class name); + + , P extends RuleFlowNodeContainerFactory> T provide(P nodeContainerFactory, NodeContainer container, WorkflowElementIdentifier id); + +} diff --git a/jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/factory/provider/NodeFactoryProviderService.java b/jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/factory/provider/NodeFactoryProviderService.java new file mode 100644 index 00000000000..7f628a9aff7 --- /dev/null +++ b/jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/factory/provider/NodeFactoryProviderService.java @@ -0,0 +1,50 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.jbpm.ruleflow.core.factory.provider; + +import java.util.ArrayList; +import java.util.List; +import java.util.Optional; +import java.util.ServiceLoader; +import java.util.function.Predicate; + +import org.jbpm.ruleflow.core.RuleFlowNodeContainerFactory; +import org.jbpm.ruleflow.core.factory.NodeFactory; +import org.jbpm.workflow.core.NodeContainer; +import org.kie.api.definition.process.WorkflowElementIdentifier; + +public class NodeFactoryProviderService { + + List providers; + + public NodeFactoryProviderService() { + this.providers = new ArrayList<>(); + ServiceLoader.load(NodeFactoryProvider.class).forEach(this.providers::add); + } + + public , P extends RuleFlowNodeContainerFactory> T newNodeFactory(Class type, P nodeContainerFactory, NodeContainer container, WorkflowElementIdentifier id) { + Predicate typeFilter = provider -> provider.accept(type); + Optional provider = providers.stream().filter(typeFilter).findAny(); + if (provider.isEmpty()) { + throw new IllegalArgumentException("Provider for " + type.getCanonicalName() + " not found"); + } + return provider.get().provide(nodeContainerFactory, container, id); + } + +} diff --git a/jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/factory/provider/RuleSetNodeFactoryProvider.java b/jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/factory/provider/RuleSetNodeFactoryProvider.java new file mode 100644 index 00000000000..08804787eba --- /dev/null +++ b/jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/factory/provider/RuleSetNodeFactoryProvider.java @@ -0,0 +1,40 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.jbpm.ruleflow.core.factory.provider; + +import org.jbpm.ruleflow.core.RuleFlowNodeContainerFactory; +import org.jbpm.ruleflow.core.factory.NodeFactory; +import org.jbpm.ruleflow.core.factory.RuleSetNodeFactory; +import org.jbpm.workflow.core.NodeContainer; +import org.jbpm.workflow.core.node.RuleSetNode; +import org.kie.api.definition.process.WorkflowElementIdentifier; + +public class RuleSetNodeFactoryProvider implements NodeFactoryProvider { + + @Override + public boolean accept(Class type) { + return RuleSetNode.class.equals(type); + } + + @Override + public , P extends RuleFlowNodeContainerFactory> R provide(P nodeContainerFactory, NodeContainer container, WorkflowElementIdentifier id) { + return (R) new RuleSetNodeFactory

(nodeContainerFactory, container, id); + } + +} diff --git a/jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/factory/provider/SplitNodeFactoryProvider.java b/jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/factory/provider/SplitNodeFactoryProvider.java new file mode 100644 index 00000000000..a8dbffecd9d --- /dev/null +++ b/jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/factory/provider/SplitNodeFactoryProvider.java @@ -0,0 +1,40 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.jbpm.ruleflow.core.factory.provider; + +import org.jbpm.ruleflow.core.RuleFlowNodeContainerFactory; +import org.jbpm.ruleflow.core.factory.NodeFactory; +import org.jbpm.ruleflow.core.factory.SplitFactory; +import org.jbpm.workflow.core.NodeContainer; +import org.jbpm.workflow.core.node.Split; +import org.kie.api.definition.process.WorkflowElementIdentifier; + +public class SplitNodeFactoryProvider implements NodeFactoryProvider { + + @Override + public boolean accept(Class type) { + return Split.class.equals(type); + } + + @Override + public , P extends RuleFlowNodeContainerFactory> R provide(P nodeContainerFactory, NodeContainer container, WorkflowElementIdentifier id) { + return (R) new SplitFactory

(nodeContainerFactory, container, id); + } + +} diff --git a/jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/factory/provider/StartNodeFactoryProvider.java b/jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/factory/provider/StartNodeFactoryProvider.java new file mode 100644 index 00000000000..ee7fd455448 --- /dev/null +++ b/jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/factory/provider/StartNodeFactoryProvider.java @@ -0,0 +1,40 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.jbpm.ruleflow.core.factory.provider; + +import org.jbpm.ruleflow.core.RuleFlowNodeContainerFactory; +import org.jbpm.ruleflow.core.factory.NodeFactory; +import org.jbpm.ruleflow.core.factory.StartNodeFactory; +import org.jbpm.workflow.core.NodeContainer; +import org.jbpm.workflow.core.node.StartNode; +import org.kie.api.definition.process.WorkflowElementIdentifier; + +public class StartNodeFactoryProvider implements NodeFactoryProvider { + + @Override + public boolean accept(Class type) { + return StartNode.class.equals(type); + } + + @Override + public , P extends RuleFlowNodeContainerFactory> T provide(P nodeContainerFactory, NodeContainer container, WorkflowElementIdentifier id) { + return (T) new StartNodeFactory

(nodeContainerFactory, container, id); + } + +} diff --git a/jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/factory/provider/StateNodeFactoryProvider.java b/jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/factory/provider/StateNodeFactoryProvider.java new file mode 100644 index 00000000000..e42aa0f10d3 --- /dev/null +++ b/jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/factory/provider/StateNodeFactoryProvider.java @@ -0,0 +1,40 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.jbpm.ruleflow.core.factory.provider; + +import org.jbpm.ruleflow.core.RuleFlowNodeContainerFactory; +import org.jbpm.ruleflow.core.factory.NodeFactory; +import org.jbpm.ruleflow.core.factory.StateNodeFactory; +import org.jbpm.workflow.core.NodeContainer; +import org.jbpm.workflow.core.node.StateNode; +import org.kie.api.definition.process.WorkflowElementIdentifier; + +public class StateNodeFactoryProvider implements NodeFactoryProvider { + + @Override + public boolean accept(Class type) { + return StateNode.class.equals(type); + } + + @Override + public , P extends RuleFlowNodeContainerFactory> T provide(P nodeContainerFactory, NodeContainer container, WorkflowElementIdentifier id) { + return (T) new StateNodeFactory

(nodeContainerFactory, container, id); + } + +} diff --git a/jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/factory/provider/SubProcessNodeFactoryProvider.java b/jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/factory/provider/SubProcessNodeFactoryProvider.java new file mode 100644 index 00000000000..504ccc0898e --- /dev/null +++ b/jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/factory/provider/SubProcessNodeFactoryProvider.java @@ -0,0 +1,40 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.jbpm.ruleflow.core.factory.provider; + +import org.jbpm.ruleflow.core.RuleFlowNodeContainerFactory; +import org.jbpm.ruleflow.core.factory.NodeFactory; +import org.jbpm.ruleflow.core.factory.SubProcessNodeFactory; +import org.jbpm.workflow.core.NodeContainer; +import org.jbpm.workflow.core.node.SubProcessNode; +import org.kie.api.definition.process.WorkflowElementIdentifier; + +public class SubProcessNodeFactoryProvider implements NodeFactoryProvider { + + @Override + public boolean accept(Class type) { + return SubProcessNode.class.equals(type); + } + + @Override + public , P extends RuleFlowNodeContainerFactory> R provide(P nodeContainerFactory, NodeContainer container, WorkflowElementIdentifier id) { + return (R) new SubProcessNodeFactory

(nodeContainerFactory, container, id); + } + +} diff --git a/jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/factory/provider/ThrowLinkNodeFactoryProvider.java b/jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/factory/provider/ThrowLinkNodeFactoryProvider.java new file mode 100644 index 00000000000..b1abdcbaff2 --- /dev/null +++ b/jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/factory/provider/ThrowLinkNodeFactoryProvider.java @@ -0,0 +1,41 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.jbpm.ruleflow.core.factory.provider; + +import org.jbpm.ruleflow.core.RuleFlowNodeContainerFactory; +import org.jbpm.ruleflow.core.factory.NodeFactory; +import org.jbpm.ruleflow.core.factory.ThrowLinkNodeFactory; +import org.jbpm.workflow.core.NodeContainer; +import org.jbpm.workflow.core.node.ThrowLinkNode; +import org.kie.api.definition.process.WorkflowElementIdentifier; + +public class ThrowLinkNodeFactoryProvider implements NodeFactoryProvider { + + @Override + public boolean accept(Class type) { + return ThrowLinkNode.class.equals(type); + } + + @Override + public , P extends RuleFlowNodeContainerFactory> R provide(P nodeContainerFactory, NodeContainer container, WorkflowElementIdentifier id) { + // TODO Auto-generated method stub + return (R) new ThrowLinkNodeFactory

(nodeContainerFactory, container, id); + } + +} diff --git a/jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/factory/provider/TimerNodeFactoryProvider.java b/jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/factory/provider/TimerNodeFactoryProvider.java new file mode 100644 index 00000000000..ddcebe915c4 --- /dev/null +++ b/jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/factory/provider/TimerNodeFactoryProvider.java @@ -0,0 +1,40 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.jbpm.ruleflow.core.factory.provider; + +import org.jbpm.ruleflow.core.RuleFlowNodeContainerFactory; +import org.jbpm.ruleflow.core.factory.NodeFactory; +import org.jbpm.ruleflow.core.factory.TimerNodeFactory; +import org.jbpm.workflow.core.NodeContainer; +import org.jbpm.workflow.core.node.TimerNode; +import org.kie.api.definition.process.WorkflowElementIdentifier; + +public class TimerNodeFactoryProvider implements NodeFactoryProvider { + + @Override + public boolean accept(Class type) { + return TimerNode.class.equals(type); + } + + @Override + public , P extends RuleFlowNodeContainerFactory> R provide(P nodeContainerFactory, NodeContainer container, WorkflowElementIdentifier id) { + return (R) new TimerNodeFactory

(nodeContainerFactory, container, id); + } + +} diff --git a/jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/factory/provider/WorkItemNodeFactoryProvider.java b/jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/factory/provider/WorkItemNodeFactoryProvider.java new file mode 100644 index 00000000000..e014dac4a9e --- /dev/null +++ b/jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/factory/provider/WorkItemNodeFactoryProvider.java @@ -0,0 +1,40 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.jbpm.ruleflow.core.factory.provider; + +import org.jbpm.ruleflow.core.RuleFlowNodeContainerFactory; +import org.jbpm.ruleflow.core.factory.NodeFactory; +import org.jbpm.ruleflow.core.factory.WorkItemNodeFactory; +import org.jbpm.workflow.core.NodeContainer; +import org.jbpm.workflow.core.node.WorkItemNode; +import org.kie.api.definition.process.WorkflowElementIdentifier; + +public class WorkItemNodeFactoryProvider implements NodeFactoryProvider { + + @Override + public boolean accept(Class type) { + return WorkItemNode.class.equals(type); + } + + @Override + public , P extends RuleFlowNodeContainerFactory> R provide(P nodeContainerFactory, NodeContainer container, WorkflowElementIdentifier id) { + return (R) new WorkItemNodeFactory

(nodeContainerFactory, container, id); + } + +} diff --git a/jbpm/jbpm-flow/src/main/resources/META-INF/services/org.jbpm.ruleflow.core.factory.provider.NodeFactoryProvider b/jbpm/jbpm-flow/src/main/resources/META-INF/services/org.jbpm.ruleflow.core.factory.provider.NodeFactoryProvider new file mode 100644 index 00000000000..e9a993216ee --- /dev/null +++ b/jbpm/jbpm-flow/src/main/resources/META-INF/services/org.jbpm.ruleflow.core.factory.provider.NodeFactoryProvider @@ -0,0 +1,21 @@ +org.jbpm.ruleflow.core.factory.provider.ActionNodeFactoryProvider +org.jbpm.ruleflow.core.factory.provider.BoundaryEventNodeFactoryProvider +org.jbpm.ruleflow.core.factory.provider.CatchLinkNodeFactoryProvider +org.jbpm.ruleflow.core.factory.provider.CompositeContextNodeFactoryProvider +org.jbpm.ruleflow.core.factory.provider.DynamicNodeFactoryProvider +org.jbpm.ruleflow.core.factory.provider.EndNodeFactoryProvider +org.jbpm.ruleflow.core.factory.provider.EventNodeFactoryProvider +org.jbpm.ruleflow.core.factory.provider.EventSubProcessNodeFactoryProvider +org.jbpm.ruleflow.core.factory.provider.FaultNodeFactoryProvider +org.jbpm.ruleflow.core.factory.provider.ForEachNodeFactoryProvider +org.jbpm.ruleflow.core.factory.provider.HumanTaskNodeFactoryProvider +org.jbpm.ruleflow.core.factory.provider.JoinNodeFactoryProvider +org.jbpm.ruleflow.core.factory.provider.MilestoneNodeFactoryProvider +org.jbpm.ruleflow.core.factory.provider.RuleSetNodeFactoryProvider +org.jbpm.ruleflow.core.factory.provider.SplitNodeFactoryProvider +org.jbpm.ruleflow.core.factory.provider.StartNodeFactoryProvider +org.jbpm.ruleflow.core.factory.provider.StateNodeFactoryProvider +org.jbpm.ruleflow.core.factory.provider.SubProcessNodeFactoryProvider +org.jbpm.ruleflow.core.factory.provider.ThrowLinkNodeFactoryProvider +org.jbpm.ruleflow.core.factory.provider.TimerNodeFactoryProvider +org.jbpm.ruleflow.core.factory.provider.WorkItemNodeFactoryProvider \ No newline at end of file diff --git a/springboot/integration-tests/src/it/integration-tests-springboot-processes-it/src/main/java/org/acme/examples.model/Movie.java b/springboot/integration-tests/src/it/integration-tests-springboot-processes-it/src/main/java/org/acme/examples/model/Movie.java similarity index 100% rename from springboot/integration-tests/src/it/integration-tests-springboot-processes-it/src/main/java/org/acme/examples.model/Movie.java rename to springboot/integration-tests/src/it/integration-tests-springboot-processes-it/src/main/java/org/acme/examples/model/Movie.java diff --git a/springboot/integration-tests/src/it/integration-tests-springboot-processes-it/src/main/java/org/acme/examples.model/MovieGenre.java b/springboot/integration-tests/src/it/integration-tests-springboot-processes-it/src/main/java/org/acme/examples/model/MovieGenre.java similarity index 100% rename from springboot/integration-tests/src/it/integration-tests-springboot-processes-it/src/main/java/org/acme/examples.model/MovieGenre.java rename to springboot/integration-tests/src/it/integration-tests-springboot-processes-it/src/main/java/org/acme/examples/model/MovieGenre.java diff --git a/springboot/integration-tests/src/it/integration-tests-springboot-processes-it/src/main/java/org/acme/examples.model/Rating.java b/springboot/integration-tests/src/it/integration-tests-springboot-processes-it/src/main/java/org/acme/examples/model/Rating.java similarity index 100% rename from springboot/integration-tests/src/it/integration-tests-springboot-processes-it/src/main/java/org/acme/examples.model/Rating.java rename to springboot/integration-tests/src/it/integration-tests-springboot-processes-it/src/main/java/org/acme/examples/model/Rating.java diff --git a/springboot/integration-tests/src/it/integration-tests-springboot-processes-it/src/main/java/org/kie/kogito/integrationtests/VersionRestController.java b/springboot/integration-tests/src/it/integration-tests-springboot-processes-it/src/main/java/org/kie/kogito/integrationtests/VersionRestController.java index 31df8705808..7bc079282c8 100644 --- a/springboot/integration-tests/src/it/integration-tests-springboot-processes-it/src/main/java/org/kie/kogito/integrationtests/VersionRestController.java +++ b/springboot/integration-tests/src/it/integration-tests-springboot-processes-it/src/main/java/org/kie/kogito/integrationtests/VersionRestController.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.kie.kogito.process.management; +package org.kie.kogito.integrationtests; import java.util.Map; From f4daa0f25203acfd17591bf0bd38c751d64d99aa Mon Sep 17 00:00:00 2001 From: jstastny-cz Date: Fri, 10 May 2024 09:47:21 +0200 Subject: [PATCH 02/32] kie-issues#776: automate PR merge into protected branches --- .ci/jenkins/Jenkinsfile.promote | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/.ci/jenkins/Jenkinsfile.promote b/.ci/jenkins/Jenkinsfile.promote index 92158e07c2f..d23cab98624 100644 --- a/.ci/jenkins/Jenkinsfile.promote +++ b/.ci/jenkins/Jenkinsfile.promote @@ -64,8 +64,8 @@ pipeline { steps { script { dir(getRepoName()) { + approveAndMergePR(getDeployPrLink()) checkoutRepo() - mergeAndPush(getDeployPrLink()) tagLatest() } } @@ -78,10 +78,10 @@ pipeline { dir(getRepoName()) { checkoutRepo() if(githubscm.isReleaseExist(getGitTag(), getGitAuthorCredsId())) { - githubscm.deleteRelease(getGitTag(), getGitAuthorCredsId()) + githubscm.deleteRelease(getGitTag(), getGitAuthorPushCredsId()) } - githubscm.createReleaseWithGeneratedReleaseNotes(getGitTag(), getBuildBranch(), githubscm.getPreviousTagFromVersion(getGitTag()), getGitAuthorCredsId()) - githubscm.updateReleaseBody(getGitTag(), getGitAuthorCredsId()) + githubscm.createReleaseWithGeneratedReleaseNotes(getGitTag(), getBuildBranch(), githubscm.getPreviousTagFromVersion(getGitTag()), getGitAuthorPushCredsId()) + githubscm.updateReleaseBody(getGitTag(), getGitAuthorPushCredsId()) } } } @@ -201,10 +201,10 @@ void checkoutRepo() { sh "git checkout ${getBuildBranch()}" } -void mergeAndPush(String prLink) { - if (prLink) { - githubscm.mergePR(prLink, getGitAuthorCredsId()) - githubscm.pushObject('origin', getBuildBranch(), getGitAuthorPushCredsId()) +void approveAndMergePR(String prLink) { + if (prLink?.trim()) { + githubscm.approvePR(prLink, getGitAuthorPushCredsId()) + githubscm.mergePR(prLink, getGitAuthorPushCredsId()) } } From 4d5ef8386860756628d0c004c589651cb867bd08 Mon Sep 17 00:00:00 2001 From: Gabriele Cardosi Date: Mon, 13 May 2024 11:46:36 +0200 Subject: [PATCH 03/32] [incubator-kie-issues#1187] Fix FEEL instantiation (#3502) Co-authored-by: Gabriele-Cardosi --- .../main/java/org/jbpm/bpmn2/feel/FeelProcessValidator.java | 3 ++- .../java/org/jbpm/bpmn2/feel/FeelReturnValueEvaluator.java | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/jbpm/jbpm-bpmn2/src/main/java/org/jbpm/bpmn2/feel/FeelProcessValidator.java b/jbpm/jbpm-bpmn2/src/main/java/org/jbpm/bpmn2/feel/FeelProcessValidator.java index ccf60a5a4cd..3273ddbe141 100755 --- a/jbpm/jbpm-bpmn2/src/main/java/org/jbpm/bpmn2/feel/FeelProcessValidator.java +++ b/jbpm/jbpm-bpmn2/src/main/java/org/jbpm/bpmn2/feel/FeelProcessValidator.java @@ -36,6 +36,7 @@ import org.kie.api.definition.process.Node; import org.kie.dmn.feel.FEEL; import org.kie.dmn.feel.lang.CompilerContext; +import org.kie.dmn.feel.lang.impl.FEELBuilder; import org.kie.dmn.feel.parser.feel11.profiles.KieExtendedFEELProfile; import static java.lang.String.format; @@ -87,7 +88,7 @@ protected void validateNodes(Node[] nodes, List errors, * use the FEEL compiler capabilities to verify if mere compilation of the FEEL expression may contain any error. */ private void verifyFEELbyCompilingExpression(VariableScope variableScope, String feelExpression) { - FEEL feel = FEEL.newInstance(Collections.singletonList(new KieExtendedFEELProfile())); + FEEL feel = FEELBuilder.builder().withProfiles(Collections.singletonList(new KieExtendedFEELProfile())).build(); FeelErrorEvaluatorListener feelErrorListener = new FeelErrorEvaluatorListener(); feel.addListener(feelErrorListener); CompilerContext cc = feel.newCompilerContext(); diff --git a/jbpm/jbpm-bpmn2/src/main/java/org/jbpm/bpmn2/feel/FeelReturnValueEvaluator.java b/jbpm/jbpm-bpmn2/src/main/java/org/jbpm/bpmn2/feel/FeelReturnValueEvaluator.java index 1c1a8afefac..d1191b7f8af 100644 --- a/jbpm/jbpm-bpmn2/src/main/java/org/jbpm/bpmn2/feel/FeelReturnValueEvaluator.java +++ b/jbpm/jbpm-bpmn2/src/main/java/org/jbpm/bpmn2/feel/FeelReturnValueEvaluator.java @@ -35,6 +35,7 @@ import org.kie.api.runtime.Globals; import org.kie.dmn.api.feel.runtime.events.FEELEvent; import org.kie.dmn.feel.FEEL; +import org.kie.dmn.feel.lang.impl.FEELBuilder; import org.kie.dmn.feel.parser.feel11.profiles.KieExtendedFEELProfile; import org.kie.kogito.internal.process.runtime.KogitoProcessContext; @@ -78,7 +79,7 @@ public Object evaluate(KogitoProcessContext context) throws Exception { variables.putAll(variableScope.getVariables()); } - FEEL feel = FEEL.newInstance(Collections.singletonList(new KieExtendedFEELProfile())); + FEEL feel = FEELBuilder.builder().withProfiles(Collections.singletonList(new KieExtendedFEELProfile())).build(); FeelErrorEvaluatorListener listener = new FeelErrorEvaluatorListener(); feel.addListener(listener); From 5780cd4e0d710705cdc2096f052c0f68d686cd6d Mon Sep 17 00:00:00 2001 From: Jan Stastny Date: Tue, 14 May 2024 09:49:25 +0200 Subject: [PATCH 04/32] kie-issues#1123:unify maven projects configuration (#3487) * kie-issues#1123:unify maven projects configuration * adjust deploy operation * Revert "adjust deploy operation" This reverts commit 10658b0cbcca3c2e3b49b3aad628ce98cc343d8a. * use https repository address --------- Co-authored-by: jstastny-cz --- .../kogito-build-no-bom-parent/pom.xml | 6 +- pom.xml | 96 ++++++------------- 2 files changed, 32 insertions(+), 70 deletions(-) diff --git a/kogito-build/kogito-build-no-bom-parent/pom.xml b/kogito-build/kogito-build-no-bom-parent/pom.xml index ab2e6a2191e..3be39d19722 100644 --- a/kogito-build/kogito-build-no-bom-parent/pom.xml +++ b/kogito-build/kogito-build-no-bom-parent/pom.xml @@ -110,7 +110,6 @@ 1.0 3.5.0 1.1.0 - 2.8.2 3.0.0-M2 3.1.1 3.0.5 @@ -300,10 +299,7 @@ maven-deploy-plugin - ${version.deploy.plugin} - - 10 - + ${version.maven-deploy-plugin} maven-compiler-plugin diff --git a/pom.xml b/pom.xml index c49d45469b0..039cb0f1460 100644 --- a/pom.xml +++ b/pom.xml @@ -24,7 +24,7 @@ org.apache apache - 30 + 32 4.0.0 @@ -53,17 +53,44 @@ scm:git:https://github.com/apache/incubator-kie-kogito-runtimes.git - scm:git:git@github.com:apache/incubator-kie-kogito-runtimes.git + scm:git:https://github.com/apache/incubator-kie-kogito-runtimes.git https://github.com/apache/incubator-kie-kogito-runtimes - All developers are listed in the KIE GitHub organization - https://github.com/orgs/kiegroup/people + The Apache KIE Team + dev@kie.apache.org + https://kie.apache.org + Apache Software Foundation + http://apache.org/ + + + Development List + dev-subscribe@kie.apache.org + dev-unsubscribe@kie.apache.org + dev@kie.apache.org + https://lists.apache.org/list.html?dev@kie.apache.org + + + User List + users-subscribe@kie.apache.org + users-unsubscribe@kie.apache.org + users@kie.apache.org + https://lists.apache.org/list.html?users@kie.apache.org + + + Commits List + commits-subscribe@kie.apache.org + commits-unsubscribe@kie.apache.org + commits@kie.apache.org + https://lists.apache.org/list.html?commits@kie.apache.org + + + - - - apache-release-staging-repository - Apache Release Staging Repository - https://repository.apache.org/service/local/staging/deploy/maven2 - - - apache-snapshots-repository - Apache Snapshot Repository - https://repository.apache.org/content/repositories/snapshots/ - - - - - - - apache-public-repository-group - Apache Public Repository Group - https://repository.apache.org/content/groups/public/ - default - - true - never - - - true - daily - - - - - - - - central - Central Repository - https://repo.maven.apache.org/maven2 - default - - false - - - - apache-public-repository-group - Apache Public Repository Group - https://repository.apache.org/content/groups/public/ - - true - - - true - - - - kogito-build kogito-bom From eb6def81b4bad97718fc64d2f085de796e41ce31 Mon Sep 17 00:00:00 2001 From: Alex Porcelli Date: Tue, 14 May 2024 11:27:53 +0200 Subject: [PATCH 05/32] kie-issues#1197 - CVE-2023-6481 logback upgrade. (#3509) --- kogito-build/kogito-dependencies-bom/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kogito-build/kogito-dependencies-bom/pom.xml b/kogito-build/kogito-dependencies-bom/pom.xml index 2a8f0d2d879..ed8f8f66d06 100644 --- a/kogito-build/kogito-dependencies-bom/pom.xml +++ b/kogito-build/kogito-dependencies-bom/pom.xml @@ -65,7 +65,7 @@ 2.0.1 2.0.1 3.1.1 - 1.4.12 + 1.4.14 2.1.1 3.0.2 4.0.1 From dd10e6ede5552fd64d1ec5f35e3dd43f8fe594e7 Mon Sep 17 00:00:00 2001 From: Alex Porcelli Date: Tue, 14 May 2024 11:28:17 +0200 Subject: [PATCH 06/32] kie-issues#1199 - CVE-2024-30171, CVE-2024-30172, CVE-2024-29857: bc*-jdk18on upgrade. (#3510) --- kogito-build/kogito-dependencies-bom/pom.xml | 21 ++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/kogito-build/kogito-dependencies-bom/pom.xml b/kogito-build/kogito-dependencies-bom/pom.xml index ed8f8f66d06..7c1c971788b 100644 --- a/kogito-build/kogito-dependencies-bom/pom.xml +++ b/kogito-build/kogito-dependencies-bom/pom.xml @@ -40,6 +40,8 @@ 3.2.4 3.6.1 + 1.78.1 + 1.0.86 2.16.1 @@ -154,6 +156,25 @@ + + + org.bouncycastle + bcpkix-jdk18on + ${version.org.bouncycastle.bc.jdk18on} + + + + org.bouncycastle + bcprov-jdk18on + ${version.org.bouncycastle.bc.jdk18on} + + + + org.bouncycastle + bcutil-jdk18on + ${version.org.bouncycastle.bc.jdk18on} + + com.google.guava From 1a6319d9ae2becf7d4ecc102c08809f7abbfd770 Mon Sep 17 00:00:00 2001 From: Alex Porcelli Date: Tue, 14 May 2024 15:57:10 +0200 Subject: [PATCH 07/32] kie-issues#1202 - Upgrading SpringBoot 3.2.5 to address CVE-2024-22262 found on spring-web. (#3515) --- kogito-build/kogito-dependencies-bom/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kogito-build/kogito-dependencies-bom/pom.xml b/kogito-build/kogito-dependencies-bom/pom.xml index 7c1c971788b..aa81109bb8c 100644 --- a/kogito-build/kogito-dependencies-bom/pom.xml +++ b/kogito-build/kogito-dependencies-bom/pom.xml @@ -37,7 +37,7 @@ 3.8.4 ${version.io.quarkus} - 3.2.4 + 3.2.5 3.6.1 1.78.1 From 28c9ec512092aadeba59b297889cbbdcbffb5725 Mon Sep 17 00:00:00 2001 From: Alex Porcelli Date: Tue, 14 May 2024 15:58:18 +0200 Subject: [PATCH 08/32] kie-issues#1200 - CVE-2024-31573: xmlunit-core upgrade. (#3511) --- kogito-build/kogito-dependencies-bom/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kogito-build/kogito-dependencies-bom/pom.xml b/kogito-build/kogito-dependencies-bom/pom.xml index aa81109bb8c..818b4113931 100644 --- a/kogito-build/kogito-dependencies-bom/pom.xml +++ b/kogito-build/kogito-dependencies-bom/pom.xml @@ -128,7 +128,7 @@ 1.10.2 5.2.0 1.19.6 - 2.9.1 + 2.10.0 5.3.2 1.14.11 From 0359cebfff03a8ed9f8b186a578ab0bd72c08ba2 Mon Sep 17 00:00:00 2001 From: Francisco Javier Tirado Sarti <65240126+fjtirado@users.noreply.github.com> Date: Tue, 14 May 2024 17:37:05 +0200 Subject: [PATCH 09/32] [Fix #3513] Different jsonnode instance for parent and children process (#3514) --- .../serverless/workflow/models/JsonNodeModel.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/kogito-serverless-workflow/kogito-serverless-workflow-runtime/src/main/java/org/kie/kogito/serverless/workflow/models/JsonNodeModel.java b/kogito-serverless-workflow/kogito-serverless-workflow-runtime/src/main/java/org/kie/kogito/serverless/workflow/models/JsonNodeModel.java index 72b8c8145f4..fd7596ec6e7 100644 --- a/kogito-serverless-workflow/kogito-serverless-workflow-runtime/src/main/java/org/kie/kogito/serverless/workflow/models/JsonNodeModel.java +++ b/kogito-serverless-workflow/kogito-serverless-workflow-runtime/src/main/java/org/kie/kogito/serverless/workflow/models/JsonNodeModel.java @@ -82,22 +82,22 @@ public JsonNodeModelOutput toModel() { @Override public void update(Map params) { - update(params, w -> w); + update(params, w -> w instanceof JsonNode ? ((JsonNode) w).deepCopy() : JsonObjectUtils.fromValue(w)); } @Override public Map updatePartially(Map params) { - update(params, w -> MergeUtils.merge(w, this.workflowdata)); + update(params, w -> MergeUtils.merge(JsonObjectUtils.fromValue(w), this.workflowdata)); return toMap(); } - private void update(Map params, Function merger) { + private void update(Map params, Function merger) { if (params.containsKey(SWFConstants.DEFAULT_WORKFLOW_VAR)) { params = mutableMap(params); - this.workflowdata = merger.apply(JsonObjectUtils.fromValue(params.remove(SWFConstants.DEFAULT_WORKFLOW_VAR))); + this.workflowdata = merger.apply(params.remove(SWFConstants.DEFAULT_WORKFLOW_VAR)); this.additionalProperties = params; } else { - this.workflowdata = merger.apply(JsonObjectUtils.fromValue(params)); + this.workflowdata = merger.apply(params); this.additionalProperties = Collections.emptyMap(); } } From e53d706385c627339c8661526e46f5440e59512d Mon Sep 17 00:00:00 2001 From: Enrique Date: Wed, 15 May 2024 11:15:38 +0200 Subject: [PATCH 10/32] [incubator-kie-isssues-1139] Add support for xpath in conditional paths (#3493) --- .../jbpm/bpmn2/feel/FeelProcessValidator.java | 2 + .../feel/FeelReturnValueEvaluatorBuilder.java | 1 + .../compiler/canonical/SplitNodeVisitor.java | 37 +--------- .../builtin/ConstraintEvaluatorBuilder.java | 33 +++++++++ .../ConstraintEvaluatorBuilderService.java | 57 +++++++++++++++ .../ExpressionConstraintEvaluatorBuilder.java | 41 +++++++++++ .../FEELConstraintEvaluatorBuilder.java | 46 +++++++++++++ .../JavaConstraintEvaluatorBuilder.java | 69 +++++++++++++++++++ .../MVELConstraintEvaluatorBuilder.java | 47 +++++++++++++ .../XPATHConstraintEvaluatorBuilder.java | 47 +++++++++++++ ...nonical.builtin.ConstraintEvaluatorBuilder | 5 ++ .../impl}/FeelErrorEvaluatorListener.java | 2 +- .../impl}/FeelReturnValueEvaluator.java | 3 +- .../FeelReturnValueEvaluatorException.java | 2 +- .../MVELInterpretedReturnValueEvaluator.java | 50 ++++++++++++++ .../activity}/BPMN2-XpathExpression.bpmn2 | 2 +- .../BPMN2-ErrorsBetweenSubProcess.bpmn2 | 2 +- .../test/java/org/jbpm/bpmn2/DataTest.java | 20 ++++-- .../jbpm-tools-maven-plugin/pom.xml | 5 ++ ...N2-DataInputAssociations-two-assigns.bpmn2 | 60 ++++++++++++++++ ...MN2-DataOutputAssociations-HumanTask.bpmn2 | 57 +++++++++++++++ 21 files changed, 541 insertions(+), 47 deletions(-) create mode 100644 jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/builtin/ConstraintEvaluatorBuilder.java create mode 100644 jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/builtin/ConstraintEvaluatorBuilderService.java create mode 100644 jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/builtin/ExpressionConstraintEvaluatorBuilder.java create mode 100644 jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/builtin/FEELConstraintEvaluatorBuilder.java create mode 100644 jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/builtin/JavaConstraintEvaluatorBuilder.java create mode 100644 jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/builtin/MVELConstraintEvaluatorBuilder.java create mode 100644 jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/builtin/XPATHConstraintEvaluatorBuilder.java create mode 100644 jbpm/jbpm-flow-builder/src/main/resources/META-INF/services/org.jbpm.compiler.canonical.builtin.ConstraintEvaluatorBuilder rename jbpm/{jbpm-bpmn2/src/main/java/org/jbpm/bpmn2/feel => jbpm-flow/src/main/java/org/jbpm/process/instance/impl}/FeelErrorEvaluatorListener.java (97%) rename jbpm/{jbpm-bpmn2/src/main/java/org/jbpm/bpmn2/feel => jbpm-flow/src/main/java/org/jbpm/process/instance/impl}/FeelReturnValueEvaluator.java (98%) rename jbpm/{jbpm-bpmn2/src/main/java/org/jbpm/bpmn2/feel => jbpm-flow/src/main/java/org/jbpm/process/instance/impl}/FeelReturnValueEvaluatorException.java (96%) create mode 100644 jbpm/jbpm-flow/src/main/java/org/jbpm/process/instance/impl/MVELInterpretedReturnValueEvaluator.java rename jbpm/jbpm-tests/src/test/{resources => bpmn/org/jbpm/bpmn2/activity}/BPMN2-XpathExpression.bpmn2 (98%) create mode 100755 jbpm/jbpm-tools/jbpm-tools-maven-plugin/src/test/resources/unit/project/src/main/bpmn/BPMN2-DataInputAssociations-two-assigns.bpmn2 create mode 100755 jbpm/jbpm-tools/jbpm-tools-maven-plugin/src/test/resources/unit/project/src/main/bpmn/BPMN2-DataOutputAssociations-HumanTask.bpmn2 diff --git a/jbpm/jbpm-bpmn2/src/main/java/org/jbpm/bpmn2/feel/FeelProcessValidator.java b/jbpm/jbpm-bpmn2/src/main/java/org/jbpm/bpmn2/feel/FeelProcessValidator.java index 3273ddbe141..358a47211d3 100755 --- a/jbpm/jbpm-bpmn2/src/main/java/org/jbpm/bpmn2/feel/FeelProcessValidator.java +++ b/jbpm/jbpm-bpmn2/src/main/java/org/jbpm/bpmn2/feel/FeelProcessValidator.java @@ -28,6 +28,8 @@ import org.jbpm.process.core.context.variable.Variable; import org.jbpm.process.core.context.variable.VariableScope; import org.jbpm.process.core.validation.ProcessValidationError; +import org.jbpm.process.instance.impl.FeelErrorEvaluatorListener; +import org.jbpm.process.instance.impl.FeelReturnValueEvaluator; import org.jbpm.ruleflow.core.RuleFlowProcess; import org.jbpm.ruleflow.core.validation.RuleFlowProcessValidator; import org.jbpm.workflow.core.Constraint; diff --git a/jbpm/jbpm-bpmn2/src/main/java/org/jbpm/bpmn2/feel/FeelReturnValueEvaluatorBuilder.java b/jbpm/jbpm-bpmn2/src/main/java/org/jbpm/bpmn2/feel/FeelReturnValueEvaluatorBuilder.java index be3d14cd15b..f49ad5cdb91 100755 --- a/jbpm/jbpm-bpmn2/src/main/java/org/jbpm/bpmn2/feel/FeelReturnValueEvaluatorBuilder.java +++ b/jbpm/jbpm-bpmn2/src/main/java/org/jbpm/bpmn2/feel/FeelReturnValueEvaluatorBuilder.java @@ -22,6 +22,7 @@ import org.drools.drl.ast.descr.ReturnValueDescr; import org.jbpm.process.builder.ReturnValueEvaluatorBuilder; import org.jbpm.process.core.ContextResolver; +import org.jbpm.process.instance.impl.FeelReturnValueEvaluator; import org.jbpm.process.instance.impl.ReturnValueConstraintEvaluator; public class FeelReturnValueEvaluatorBuilder implements ReturnValueEvaluatorBuilder { diff --git a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/SplitNodeVisitor.java b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/SplitNodeVisitor.java index a4f0039fc1d..346c044cdc7 100644 --- a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/SplitNodeVisitor.java +++ b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/SplitNodeVisitor.java @@ -20,28 +20,19 @@ import java.util.Collection; import java.util.Map.Entry; -import java.util.function.Supplier; -import org.jbpm.process.core.context.variable.Variable; +import org.jbpm.compiler.canonical.builtin.ConstraintEvaluatorBuilderService; import org.jbpm.process.core.context.variable.VariableScope; -import org.jbpm.process.instance.impl.ReturnValueConstraintEvaluator; import org.jbpm.ruleflow.core.factory.SplitFactory; import org.jbpm.workflow.core.Constraint; import org.jbpm.workflow.core.impl.ConnectionRef; import org.jbpm.workflow.core.node.Split; -import org.kie.kogito.internal.utils.ConversionUtils; -import com.github.javaparser.StaticJavaParser; -import com.github.javaparser.ast.NodeList; -import com.github.javaparser.ast.body.Parameter; import com.github.javaparser.ast.expr.BooleanLiteralExpr; import com.github.javaparser.ast.expr.Expression; import com.github.javaparser.ast.expr.IntegerLiteralExpr; -import com.github.javaparser.ast.expr.LambdaExpr; -import com.github.javaparser.ast.expr.ObjectCreationExpr; import com.github.javaparser.ast.expr.StringLiteralExpr; import com.github.javaparser.ast.stmt.BlockStmt; -import com.github.javaparser.ast.type.UnknownType; import static org.jbpm.ruleflow.core.factory.SplitFactory.METHOD_CONSTRAINT; import static org.jbpm.ruleflow.core.factory.SplitFactory.METHOD_TYPE; @@ -66,26 +57,7 @@ public void visitNode(String factoryField, Split node, BlockStmt body, VariableS if (entry.getValue() != null) { for (Constraint constraint : entry.getValue()) { if (constraint != null) { - Expression returnValueEvaluator; - if (constraint instanceof ReturnValueConstraintEvaluator && ((ReturnValueConstraintEvaluator) constraint).getReturnValueEvaluator() instanceof Supplier) { - returnValueEvaluator = ((Supplier) ((ReturnValueConstraintEvaluator) constraint).getReturnValueEvaluator()).get(); - } else if ("FEEL".equals(constraint.getDialect())) { - returnValueEvaluator = buildFEELReturnValueEvaluator(constraint); - } else { - BlockStmt actionBody = new BlockStmt(); - LambdaExpr lambda = new LambdaExpr( - new Parameter(new UnknownType(), KCONTEXT_VAR), // (kcontext) -> - actionBody); - - for (Variable v : variableScope.getVariables()) { - actionBody.addStatement(makeAssignment(v)); - } - - BlockStmt blockStmt = StaticJavaParser.parseBlock("{" + constraint.getConstraint() + "}"); - blockStmt.getStatements().forEach(actionBody::addStatement); - - returnValueEvaluator = lambda; - } + Expression returnValueEvaluator = ConstraintEvaluatorBuilderService.instance().build(node, constraint); body.addStatement(getFactoryMethod(getNodeId(node), METHOD_CONSTRAINT, getWorkflowElementConstructor(entry.getKey().getNodeId()), new StringLiteralExpr(getOrDefault(entry.getKey().getConnectionId(), "")), @@ -102,9 +74,4 @@ public void visitNode(String factoryField, Split node, BlockStmt body, VariableS body.addStatement(getDoneMethod(getNodeId(node))); } - private static ObjectCreationExpr buildFEELReturnValueEvaluator(Constraint constraint) { - return new ObjectCreationExpr(null, - StaticJavaParser.parseClassOrInterfaceType("org.jbpm.bpmn2.feel.FeelReturnValueEvaluator"), - new NodeList<>(new StringLiteralExpr(ConversionUtils.sanitizeString(constraint.getConstraint())))); - } } diff --git a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/builtin/ConstraintEvaluatorBuilder.java b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/builtin/ConstraintEvaluatorBuilder.java new file mode 100644 index 00000000000..71f0c09a226 --- /dev/null +++ b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/builtin/ConstraintEvaluatorBuilder.java @@ -0,0 +1,33 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.jbpm.compiler.canonical.builtin; + +import org.jbpm.process.core.ContextResolver; +import org.jbpm.workflow.core.Constraint; + +import com.github.javaparser.ast.expr.Expression; + +public interface ConstraintEvaluatorBuilder { + + String KCONTEXT_VAR = "kcontext"; + + boolean accept(Constraint constraint); + + Expression build(ContextResolver resolver, org.jbpm.workflow.core.Constraint constraint); +} diff --git a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/builtin/ConstraintEvaluatorBuilderService.java b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/builtin/ConstraintEvaluatorBuilderService.java new file mode 100644 index 00000000000..6216414cdca --- /dev/null +++ b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/builtin/ConstraintEvaluatorBuilderService.java @@ -0,0 +1,57 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.jbpm.compiler.canonical.builtin; + +import java.util.List; +import java.util.ServiceLoader; + +import org.jbpm.process.core.ContextResolver; +import org.jbpm.util.JbpmClassLoaderUtil; +import org.jbpm.workflow.core.Constraint; + +import com.github.javaparser.ast.expr.Expression; + +public class ConstraintEvaluatorBuilderService { + + private static ConstraintEvaluatorBuilderService INSTANCE; + private List builders; + + public static ConstraintEvaluatorBuilderService instance() { + if (INSTANCE == null) { + INSTANCE = new ConstraintEvaluatorBuilderService(); + } + return INSTANCE; + } + + public ConstraintEvaluatorBuilderService() { + builders = ServiceLoader.load(ConstraintEvaluatorBuilder.class, JbpmClassLoaderUtil.findClassLoader()) + .stream() + .map(ServiceLoader.Provider::get) + .toList(); + } + + public Expression build(ContextResolver resolver, Constraint constraint) { + for (ConstraintEvaluatorBuilder builder : builders) { + if (builder.accept(constraint)) { + return builder.build(resolver, constraint); + } + } + throw new IllegalArgumentException("No dialect found " + constraint.getDialect() + " for building constraint"); + } +} diff --git a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/builtin/ExpressionConstraintEvaluatorBuilder.java b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/builtin/ExpressionConstraintEvaluatorBuilder.java new file mode 100644 index 00000000000..ccf09b757a0 --- /dev/null +++ b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/builtin/ExpressionConstraintEvaluatorBuilder.java @@ -0,0 +1,41 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.jbpm.compiler.canonical.builtin; + +import java.util.function.Supplier; + +import org.jbpm.process.core.ContextResolver; +import org.jbpm.process.instance.impl.ReturnValueConstraintEvaluator; +import org.jbpm.workflow.core.Constraint; + +import com.github.javaparser.ast.expr.Expression; + +public class ExpressionConstraintEvaluatorBuilder implements ConstraintEvaluatorBuilder { + + @Override + public boolean accept(Constraint constraint) { + return constraint instanceof ReturnValueConstraintEvaluator && ((ReturnValueConstraintEvaluator) constraint).getReturnValueEvaluator() instanceof Supplier; + } + + @Override + public Expression build(ContextResolver resolver, Constraint constraint) { + return ((Supplier) ((ReturnValueConstraintEvaluator) constraint).getReturnValueEvaluator()).get(); + } + +} diff --git a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/builtin/FEELConstraintEvaluatorBuilder.java b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/builtin/FEELConstraintEvaluatorBuilder.java new file mode 100644 index 00000000000..1f07e814697 --- /dev/null +++ b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/builtin/FEELConstraintEvaluatorBuilder.java @@ -0,0 +1,46 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.jbpm.compiler.canonical.builtin; + +import org.jbpm.process.core.ContextResolver; +import org.jbpm.process.instance.impl.FeelReturnValueEvaluator; +import org.jbpm.workflow.core.Constraint; +import org.kie.kogito.internal.utils.ConversionUtils; + +import com.github.javaparser.StaticJavaParser; +import com.github.javaparser.ast.NodeList; +import com.github.javaparser.ast.expr.Expression; +import com.github.javaparser.ast.expr.ObjectCreationExpr; +import com.github.javaparser.ast.expr.StringLiteralExpr; + +public class FEELConstraintEvaluatorBuilder implements ConstraintEvaluatorBuilder { + + @Override + public boolean accept(Constraint constraint) { + return "FEEL".equals(constraint.getDialect()); + } + + @Override + public Expression build(ContextResolver resolver, Constraint constraint) { + return new ObjectCreationExpr(null, + StaticJavaParser.parseClassOrInterfaceType(FeelReturnValueEvaluator.class.getName()), + new NodeList<>(new StringLiteralExpr(ConversionUtils.sanitizeString(constraint.getConstraint())))); + } + +} diff --git a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/builtin/JavaConstraintEvaluatorBuilder.java b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/builtin/JavaConstraintEvaluatorBuilder.java new file mode 100644 index 00000000000..f9f7a803d7d --- /dev/null +++ b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/builtin/JavaConstraintEvaluatorBuilder.java @@ -0,0 +1,69 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.jbpm.compiler.canonical.builtin; + +import java.util.HashSet; +import java.util.Set; + +import org.jbpm.compiler.canonical.AbstractNodeVisitor; +import org.jbpm.process.core.ContextResolver; +import org.jbpm.process.core.context.variable.Variable; +import org.jbpm.process.core.context.variable.VariableScope; +import org.jbpm.workflow.core.Constraint; + +import com.github.javaparser.StaticJavaParser; +import com.github.javaparser.ast.body.Parameter; +import com.github.javaparser.ast.expr.Expression; +import com.github.javaparser.ast.expr.LambdaExpr; +import com.github.javaparser.ast.expr.NameExpr; +import com.github.javaparser.ast.stmt.BlockStmt; +import com.github.javaparser.ast.type.UnknownType; + +public class JavaConstraintEvaluatorBuilder implements ConstraintEvaluatorBuilder { + + @Override + public boolean accept(Constraint constraint) { + return constraint.getDialect().contains("java"); + } + + @Override + public Expression build(ContextResolver resolver, Constraint constraint) { + BlockStmt actionBody = new BlockStmt(); + LambdaExpr lambda = new LambdaExpr( + new Parameter(new UnknownType(), KCONTEXT_VAR), // (kcontext) -> + actionBody); + + BlockStmt blockStmt = StaticJavaParser.parseBlock("{" + constraint.getConstraint() + "}"); + Set identifiers = new HashSet<>(blockStmt.findAll(NameExpr.class)); + + for (NameExpr v : identifiers) { + VariableScope variableScope = (VariableScope) resolver.resolveContext(VariableScope.VARIABLE_SCOPE, v.getNameAsString()); + if (variableScope == null) { + continue; + } + Variable variable = variableScope.findVariable(v.getNameAsString()); + actionBody.addStatement(AbstractNodeVisitor.makeAssignment(variable)); + } + + blockStmt.getStatements().forEach(actionBody::addStatement); + + return lambda; + } + +} diff --git a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/builtin/MVELConstraintEvaluatorBuilder.java b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/builtin/MVELConstraintEvaluatorBuilder.java new file mode 100644 index 00000000000..124c8168735 --- /dev/null +++ b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/builtin/MVELConstraintEvaluatorBuilder.java @@ -0,0 +1,47 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.jbpm.compiler.canonical.builtin; + +import org.jbpm.process.core.ContextResolver; +import org.jbpm.process.instance.impl.MVELInterpretedReturnValueEvaluator; +import org.jbpm.workflow.core.Constraint; +import org.kie.kogito.internal.utils.ConversionUtils; + +import com.github.javaparser.StaticJavaParser; +import com.github.javaparser.ast.NodeList; +import com.github.javaparser.ast.expr.Expression; +import com.github.javaparser.ast.expr.ObjectCreationExpr; +import com.github.javaparser.ast.expr.StringLiteralExpr; + +public class MVELConstraintEvaluatorBuilder implements ConstraintEvaluatorBuilder { + + @Override + public boolean accept(Constraint constraint) { + return "mvel".equals(constraint.getDialect()); + } + + @Override + public Expression build(ContextResolver resolver, Constraint constraint) { + + return new ObjectCreationExpr(null, + StaticJavaParser.parseClassOrInterfaceType(MVELInterpretedReturnValueEvaluator.class.getName()), + new NodeList<>(new StringLiteralExpr(ConversionUtils.sanitizeString(constraint.getConstraint())))); + } + +} diff --git a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/builtin/XPATHConstraintEvaluatorBuilder.java b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/builtin/XPATHConstraintEvaluatorBuilder.java new file mode 100644 index 00000000000..a2f3fac0c59 --- /dev/null +++ b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/builtin/XPATHConstraintEvaluatorBuilder.java @@ -0,0 +1,47 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.jbpm.compiler.canonical.builtin; + +import org.jbpm.process.core.ContextResolver; +import org.jbpm.process.instance.impl.XPATHReturnValueEvaluator; +import org.jbpm.workflow.core.Constraint; +import org.kie.kogito.internal.utils.ConversionUtils; + +import com.github.javaparser.StaticJavaParser; +import com.github.javaparser.ast.NodeList; +import com.github.javaparser.ast.expr.Expression; +import com.github.javaparser.ast.expr.NullLiteralExpr; +import com.github.javaparser.ast.expr.ObjectCreationExpr; +import com.github.javaparser.ast.expr.StringLiteralExpr; + +public class XPATHConstraintEvaluatorBuilder implements ConstraintEvaluatorBuilder { + + @Override + public boolean accept(Constraint constraint) { + return constraint.getDialect().toLowerCase().contains("xpath"); + } + + @Override + public Expression build(ContextResolver resolver, Constraint constraint) { + return new ObjectCreationExpr(null, + StaticJavaParser.parseClassOrInterfaceType(XPATHReturnValueEvaluator.class.getName()), + new NodeList<>(new StringLiteralExpr(ConversionUtils.sanitizeString(constraint.getConstraint())), new NullLiteralExpr())); + } + +} diff --git a/jbpm/jbpm-flow-builder/src/main/resources/META-INF/services/org.jbpm.compiler.canonical.builtin.ConstraintEvaluatorBuilder b/jbpm/jbpm-flow-builder/src/main/resources/META-INF/services/org.jbpm.compiler.canonical.builtin.ConstraintEvaluatorBuilder new file mode 100644 index 00000000000..2b3fc98021d --- /dev/null +++ b/jbpm/jbpm-flow-builder/src/main/resources/META-INF/services/org.jbpm.compiler.canonical.builtin.ConstraintEvaluatorBuilder @@ -0,0 +1,5 @@ +org.jbpm.compiler.canonical.builtin.ExpressionConstraintEvaluatorBuilder +org.jbpm.compiler.canonical.builtin.FEELConstraintEvaluatorBuilder +org.jbpm.compiler.canonical.builtin.JavaConstraintEvaluatorBuilder +org.jbpm.compiler.canonical.builtin.XPATHConstraintEvaluatorBuilder +org.jbpm.compiler.canonical.builtin.MVELConstraintEvaluatorBuilder \ No newline at end of file diff --git a/jbpm/jbpm-bpmn2/src/main/java/org/jbpm/bpmn2/feel/FeelErrorEvaluatorListener.java b/jbpm/jbpm-flow/src/main/java/org/jbpm/process/instance/impl/FeelErrorEvaluatorListener.java similarity index 97% rename from jbpm/jbpm-bpmn2/src/main/java/org/jbpm/bpmn2/feel/FeelErrorEvaluatorListener.java rename to jbpm/jbpm-flow/src/main/java/org/jbpm/process/instance/impl/FeelErrorEvaluatorListener.java index 4da2e49c776..25dba5a1117 100644 --- a/jbpm/jbpm-bpmn2/src/main/java/org/jbpm/bpmn2/feel/FeelErrorEvaluatorListener.java +++ b/jbpm/jbpm-flow/src/main/java/org/jbpm/process/instance/impl/FeelErrorEvaluatorListener.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.jbpm.bpmn2.feel; +package org.jbpm.process.instance.impl; import java.util.ArrayList; import java.util.List; diff --git a/jbpm/jbpm-bpmn2/src/main/java/org/jbpm/bpmn2/feel/FeelReturnValueEvaluator.java b/jbpm/jbpm-flow/src/main/java/org/jbpm/process/instance/impl/FeelReturnValueEvaluator.java similarity index 98% rename from jbpm/jbpm-bpmn2/src/main/java/org/jbpm/bpmn2/feel/FeelReturnValueEvaluator.java rename to jbpm/jbpm-flow/src/main/java/org/jbpm/process/instance/impl/FeelReturnValueEvaluator.java index d1191b7f8af..608c0bd7905 100644 --- a/jbpm/jbpm-bpmn2/src/main/java/org/jbpm/bpmn2/feel/FeelReturnValueEvaluator.java +++ b/jbpm/jbpm-flow/src/main/java/org/jbpm/process/instance/impl/FeelReturnValueEvaluator.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.jbpm.bpmn2.feel; +package org.jbpm.process.instance.impl; import java.io.Externalizable; import java.io.IOException; @@ -30,7 +30,6 @@ import org.jbpm.process.core.context.variable.VariableScope; import org.jbpm.process.instance.context.variable.VariableScopeInstance; -import org.jbpm.process.instance.impl.ReturnValueEvaluator; import org.jbpm.workflow.instance.WorkflowProcessInstance; import org.kie.api.runtime.Globals; import org.kie.dmn.api.feel.runtime.events.FEELEvent; diff --git a/jbpm/jbpm-bpmn2/src/main/java/org/jbpm/bpmn2/feel/FeelReturnValueEvaluatorException.java b/jbpm/jbpm-flow/src/main/java/org/jbpm/process/instance/impl/FeelReturnValueEvaluatorException.java similarity index 96% rename from jbpm/jbpm-bpmn2/src/main/java/org/jbpm/bpmn2/feel/FeelReturnValueEvaluatorException.java rename to jbpm/jbpm-flow/src/main/java/org/jbpm/process/instance/impl/FeelReturnValueEvaluatorException.java index 9878e6f1a13..66b3a00f37a 100644 --- a/jbpm/jbpm-bpmn2/src/main/java/org/jbpm/bpmn2/feel/FeelReturnValueEvaluatorException.java +++ b/jbpm/jbpm-flow/src/main/java/org/jbpm/process/instance/impl/FeelReturnValueEvaluatorException.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.jbpm.bpmn2.feel; +package org.jbpm.process.instance.impl; public class FeelReturnValueEvaluatorException extends RuntimeException { diff --git a/jbpm/jbpm-flow/src/main/java/org/jbpm/process/instance/impl/MVELInterpretedReturnValueEvaluator.java b/jbpm/jbpm-flow/src/main/java/org/jbpm/process/instance/impl/MVELInterpretedReturnValueEvaluator.java new file mode 100644 index 00000000000..fb57b53f963 --- /dev/null +++ b/jbpm/jbpm-flow/src/main/java/org/jbpm/process/instance/impl/MVELInterpretedReturnValueEvaluator.java @@ -0,0 +1,50 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.jbpm.process.instance.impl; + +import org.kie.kogito.internal.process.runtime.KogitoProcessContext; +import org.mvel2.MVEL; +import org.mvel2.integration.VariableResolver; +import org.mvel2.integration.impl.ImmutableDefaultFactory; +import org.mvel2.integration.impl.SimpleValueResolver; + +public class MVELInterpretedReturnValueEvaluator implements ReturnValueEvaluator { + + private String expr; + + public MVELInterpretedReturnValueEvaluator(String expression) { + this.expr = expression; + } + + public Object evaluate(KogitoProcessContext context) throws Exception { + Object value = MVEL.eval(this.expr, new ImmutableDefaultFactory() { + @Override + public boolean isResolveable(String name) { + return context.getVariable(name) != null; + }; + + @Override + public VariableResolver getVariableResolver(String name) { + return new SimpleValueResolver(context.getVariable(name)); + }; + }); + return value; + } + +} diff --git a/jbpm/jbpm-tests/src/test/resources/BPMN2-XpathExpression.bpmn2 b/jbpm/jbpm-tests/src/test/bpmn/org/jbpm/bpmn2/activity/BPMN2-XpathExpression.bpmn2 similarity index 98% rename from jbpm/jbpm-tests/src/test/resources/BPMN2-XpathExpression.bpmn2 rename to jbpm/jbpm-tests/src/test/bpmn/org/jbpm/bpmn2/activity/BPMN2-XpathExpression.bpmn2 index dadbb455970..93d72711cfd 100755 --- a/jbpm/jbpm-tests/src/test/resources/BPMN2-XpathExpression.bpmn2 +++ b/jbpm/jbpm-tests/src/test/bpmn/org/jbpm/bpmn2/activity/BPMN2-XpathExpression.bpmn2 @@ -33,7 +33,7 @@ - + diff --git a/jbpm/jbpm-tests/src/test/bpmn/org/jbpm/bpmn2/subprocess/BPMN2-ErrorsBetweenSubProcess.bpmn2 b/jbpm/jbpm-tests/src/test/bpmn/org/jbpm/bpmn2/subprocess/BPMN2-ErrorsBetweenSubProcess.bpmn2 index e9fc8e1c78b..3e56901cc4f 100755 --- a/jbpm/jbpm-tests/src/test/bpmn/org/jbpm/bpmn2/subprocess/BPMN2-ErrorsBetweenSubProcess.bpmn2 +++ b/jbpm/jbpm-tests/src/test/bpmn/org/jbpm/bpmn2/subprocess/BPMN2-ErrorsBetweenSubProcess.bpmn2 @@ -85,7 +85,7 @@ return (te.equals("error")); SequenceFlow_1 - String te=(String) kcontext.getVariable("tipoEventoAdentro"); + String te=(String) kcontext.getVariable("tipoEventoAdentro"); return (te.equals("nada")); diff --git a/jbpm/jbpm-tests/src/test/java/org/jbpm/bpmn2/DataTest.java b/jbpm/jbpm-tests/src/test/java/org/jbpm/bpmn2/DataTest.java index 6390dbb499c..2f46fa66c53 100755 --- a/jbpm/jbpm-tests/src/test/java/org/jbpm/bpmn2/DataTest.java +++ b/jbpm/jbpm-tests/src/test/java/org/jbpm/bpmn2/DataTest.java @@ -27,19 +27,24 @@ import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; +import org.jbpm.bpmn2.activity.XPathProcessModel; +import org.jbpm.bpmn2.activity.XPathProcessProcess; import org.jbpm.bpmn2.core.Association; import org.jbpm.bpmn2.core.DataStore; import org.jbpm.bpmn2.core.Definitions; import org.jbpm.bpmn2.xml.ProcessHandler; import org.jbpm.process.core.datatype.impl.type.ObjectDataType; import org.jbpm.process.instance.impl.demo.SystemOutWorkItemHandler; +import org.jbpm.test.utils.ProcessTestHelper; import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; +import org.kie.kogito.Application; import org.kie.kogito.internal.process.runtime.KogitoProcessInstance; import org.kie.kogito.internal.process.runtime.KogitoWorkItem; import org.kie.kogito.internal.process.runtime.KogitoWorkItemHandler; import org.kie.kogito.internal.process.runtime.KogitoWorkItemManager; import org.kie.kogito.internal.process.runtime.KogitoWorkflowProcessInstance; +import org.kie.kogito.process.ProcessInstance; import org.w3c.dom.Document; import org.w3c.dom.Element; @@ -139,18 +144,21 @@ public void testEvaluationProcess3() throws Exception { @Test public void testXpathExpression() throws Exception { - kruntime = createKogitoProcessRuntime("BPMN2-XpathExpression.bpmn2"); + Application app = ProcessTestHelper.newApplication(); + org.kie.kogito.process.Process process = XPathProcessProcess.newProcess(app); + XPathProcessModel model = process.createModel(); + Document document = DocumentBuilderFactory .newInstance() .newDocumentBuilder() .parse(new ByteArrayInputStream( "" .getBytes())); - Map params = new HashMap<>(); - params.put("instanceMetadata", document); - KogitoProcessInstance processInstance = kruntime.startProcess("XPathProcess", - params); - assertProcessInstanceCompleted(processInstance); + + model.setInstanceMetadata(document); + ProcessInstance processInstance = process.createInstance(model); + processInstance.start(); + assertThat(processInstance).extracting(ProcessInstance::status).isEqualTo(ProcessInstance.STATE_COMPLETED); } diff --git a/jbpm/jbpm-tools/jbpm-tools-maven-plugin/pom.xml b/jbpm/jbpm-tools/jbpm-tools-maven-plugin/pom.xml index 4a98a490e8d..3a159e40323 100644 --- a/jbpm/jbpm-tools/jbpm-tools-maven-plugin/pom.xml +++ b/jbpm/jbpm-tools/jbpm-tools-maven-plugin/pom.xml @@ -66,6 +66,11 @@ provided + + org.slf4j + slf4j-simple + test + org.junit.jupiter junit-jupiter-api diff --git a/jbpm/jbpm-tools/jbpm-tools-maven-plugin/src/test/resources/unit/project/src/main/bpmn/BPMN2-DataInputAssociations-two-assigns.bpmn2 b/jbpm/jbpm-tools/jbpm-tools-maven-plugin/src/test/resources/unit/project/src/main/bpmn/BPMN2-DataInputAssociations-two-assigns.bpmn2 new file mode 100755 index 00000000000..e514a8b2b2b --- /dev/null +++ b/jbpm/jbpm-tools/jbpm-tools-maven-plugin/src/test/resources/unit/project/src/main/bpmn/BPMN2-DataInputAssociations-two-assigns.bpmn2 @@ -0,0 +1,60 @@ + + + + + + + + + + + + + _BF09B923-BE11-4447-BECB-609BD86C59EF_Comment + + + + instanceMetadata + _BF09B923-BE11-4447-BECB-609BD86C59EF_Comment + + . + foo + + + . + foo/bar + + + + + true() + + + + + + + + + + count($instanceMetadata/user) = 2 + + + + + + + + + diff --git a/jbpm/jbpm-tools/jbpm-tools-maven-plugin/src/test/resources/unit/project/src/main/bpmn/BPMN2-DataOutputAssociations-HumanTask.bpmn2 b/jbpm/jbpm-tools/jbpm-tools-maven-plugin/src/test/resources/unit/project/src/main/bpmn/BPMN2-DataOutputAssociations-HumanTask.bpmn2 new file mode 100755 index 00000000000..6dbff6573dc --- /dev/null +++ b/jbpm/jbpm-tools/jbpm-tools-maven-plugin/src/test/resources/unit/project/src/main/bpmn/BPMN2-DataOutputAssociations-HumanTask.bpmn2 @@ -0,0 +1,57 @@ + + + + + + + + + + + + + + _BF09B923-BE11-4447-BECB-609BD86C59EF_PreviousOwner + + + + _BF09B923-BE11-4447-BECB-609BD86C59EF_PreviousOwner + instanceMetadata + + @primaryname + previoustasksowner + + + + + true() + + + + + + + + + + count($instanceMetadata/user) = 2 + + + + + + + + + From 2c4bdc9d33ba37dc583f73d8c4697b5b56f1bae4 Mon Sep 17 00:00:00 2001 From: Walter Medvedeo Date: Fri, 17 May 2024 12:34:26 +0200 Subject: [PATCH 11/32] kie-kogito-runtimes-3521: Align jobs service knative eventing http connector config with runtime events config (#3522) --- .../knative/eventing/quarkus/KnativeEventingJobsService.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/quarkus/addons/jobs/knative-eventing/runtime/src/main/java/org/kie/kogito/jobs/knative/eventing/quarkus/KnativeEventingJobsService.java b/quarkus/addons/jobs/knative-eventing/runtime/src/main/java/org/kie/kogito/jobs/knative/eventing/quarkus/KnativeEventingJobsService.java index f445b3bf8ac..a7bb8bc4858 100644 --- a/quarkus/addons/jobs/knative-eventing/runtime/src/main/java/org/kie/kogito/jobs/knative/eventing/quarkus/KnativeEventingJobsService.java +++ b/quarkus/addons/jobs/knative-eventing/runtime/src/main/java/org/kie/kogito/jobs/knative/eventing/quarkus/KnativeEventingJobsService.java @@ -24,6 +24,7 @@ import org.eclipse.microprofile.reactive.messaging.Channel; import org.eclipse.microprofile.reactive.messaging.Emitter; import org.eclipse.microprofile.reactive.messaging.Message; +import org.eclipse.microprofile.reactive.messaging.OnOverflow; import org.kie.kogito.addon.quarkus.common.reactive.messaging.http.CloudEventHttpOutgoingDecorator; import org.kie.kogito.jobs.messaging.quarkus.AbstractReactiveMessagingJobsService; @@ -43,7 +44,7 @@ public class KnativeEventingJobsService extends AbstractReactiveMessagingJobsSer public KnativeEventingJobsService( @ConfigProperty(name = "kogito.service.url") URI serviceUrl, ObjectMapper objectMapper, - @Channel(KOGITO_JOB_SERVICE_JOB_REQUEST_EVENTS_CHANNEL) Emitter eventsEmitter) { + @Channel(KOGITO_JOB_SERVICE_JOB_REQUEST_EVENTS_CHANNEL) @OnOverflow(value = OnOverflow.Strategy.UNBOUNDED_BUFFER) Emitter eventsEmitter) { super(serviceUrl, objectMapper, eventsEmitter); } From 0c5b65ff839df8fe209b2d90d8ab90e99cdf0f5b Mon Sep 17 00:00:00 2001 From: Enrique Date: Mon, 20 May 2024 12:21:02 +0200 Subject: [PATCH 12/32] [incubator-kie-issues-1111] Add capability to extends for code generation (#3507) * [incubator-kie-issues-1111] Add capability to extends for code generation * class loader corrections --- .../AbstractCompositeNodeVisitor.java | 11 ++-- .../CompositeContextNodeVisitor.java | 7 +- .../canonical/DynamicNodeVisitor.java | 7 +- .../canonical/EventSubProcessNodeVisitor.java | 7 +- .../canonical/ForEachNodeVisitor.java | 6 +- .../canonical/HumanTaskNodeVisitor.java | 4 +- .../compiler/canonical/ProcessVisitor.java | 66 ++++--------------- .../compiler/canonical/StateNodeVisitor.java | 6 +- .../node/ActionNodeVisitorBuilder.java | 38 +++++++++++ .../node/BoundaryEventNodeVisitorBuilder.java | 38 +++++++++++ .../node/CatchLinkNodeVisitorBuilder.java | 38 +++++++++++ .../CompositeContextNodeVisitorBuilder.java | 38 +++++++++++ .../node/DynamicNodeVisitorBuilder.java | 38 +++++++++++ .../canonical/node/EndNodeVisitorBuilder.java | 38 +++++++++++ .../node/EventNodeVisitorBuilder.java | 38 +++++++++++ .../EventSubProcessNodeVisitorBuilder.java | 38 +++++++++++ .../node/FaultNodeVisitorBuilder.java | 38 +++++++++++ .../node/ForEachNodeVisitorBuilder.java | 38 +++++++++++ .../node/HumanTaskNodeVisitorBuilder.java | 38 +++++++++++ .../node/JoinNodeVisitorBuilder.java | 38 +++++++++++ .../node/MilestoneNodeVisitorBuilder.java | 38 +++++++++++ .../canonical/node/NodeVisitorBuilder.java | 28 ++++++++ .../node/NodeVisitorBuilderService.java | 51 ++++++++++++++ .../node/RuleSetNodeVisitorBuilder.java | 38 +++++++++++ .../node/SplitNodeVisitorBuilder.java | 38 +++++++++++ .../node/StartNodeVisitorBuilder.java | 38 +++++++++++ .../node/StateNodeVisitorBuilder.java | 38 +++++++++++ .../node/SubProcessNodeVisitorBuilder.java | 38 +++++++++++ .../node/ThrowLinkNodeVisitorBuilder.java | 38 +++++++++++ .../node/TimerNodeVisitorBuilder.java | 38 +++++++++++ .../node/WorkItemNodeVisitorBuilder.java | 38 +++++++++++ ...compiler.canonical.node.NodeVisitorBuilder | 21 ++++++ 32 files changed, 934 insertions(+), 78 deletions(-) create mode 100644 jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/ActionNodeVisitorBuilder.java create mode 100644 jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/BoundaryEventNodeVisitorBuilder.java create mode 100644 jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/CatchLinkNodeVisitorBuilder.java create mode 100644 jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/CompositeContextNodeVisitorBuilder.java create mode 100644 jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/DynamicNodeVisitorBuilder.java create mode 100644 jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/EndNodeVisitorBuilder.java create mode 100644 jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/EventNodeVisitorBuilder.java create mode 100644 jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/EventSubProcessNodeVisitorBuilder.java create mode 100644 jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/FaultNodeVisitorBuilder.java create mode 100644 jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/ForEachNodeVisitorBuilder.java create mode 100644 jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/HumanTaskNodeVisitorBuilder.java create mode 100644 jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/JoinNodeVisitorBuilder.java create mode 100644 jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/MilestoneNodeVisitorBuilder.java create mode 100644 jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/NodeVisitorBuilder.java create mode 100644 jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/NodeVisitorBuilderService.java create mode 100644 jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/RuleSetNodeVisitorBuilder.java create mode 100644 jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/SplitNodeVisitorBuilder.java create mode 100644 jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/StartNodeVisitorBuilder.java create mode 100644 jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/StateNodeVisitorBuilder.java create mode 100644 jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/SubProcessNodeVisitorBuilder.java create mode 100644 jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/ThrowLinkNodeVisitorBuilder.java create mode 100644 jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/TimerNodeVisitorBuilder.java create mode 100644 jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/WorkItemNodeVisitorBuilder.java create mode 100644 jbpm/jbpm-flow-builder/src/main/resources/META-INF/services/org.jbpm.compiler.canonical.node.NodeVisitorBuilder diff --git a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/AbstractCompositeNodeVisitor.java b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/AbstractCompositeNodeVisitor.java index 96b9d205f59..b9143a9d762 100644 --- a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/AbstractCompositeNodeVisitor.java +++ b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/AbstractCompositeNodeVisitor.java @@ -18,8 +18,7 @@ */ package org.jbpm.compiler.canonical; -import java.util.Map; - +import org.jbpm.compiler.canonical.node.NodeVisitorBuilderService; import org.jbpm.process.core.context.variable.VariableScope; import org.jbpm.workflow.core.node.CompositeContextNode; import org.kie.api.definition.process.Node; @@ -28,15 +27,15 @@ public abstract class AbstractCompositeNodeVisitor extends AbstractNodeVisitor { - protected Map, AbstractNodeVisitor> nodesVisitors; + protected NodeVisitorBuilderService nodevisitorService; - public AbstractCompositeNodeVisitor(Map, AbstractNodeVisitor> nodesVisitors) { - this.nodesVisitors = nodesVisitors; + public AbstractCompositeNodeVisitor(NodeVisitorBuilderService nodevisitorService) { + this.nodevisitorService = nodevisitorService; } protected void visitNodes(String factoryField, U[] nodes, BlockStmt body, VariableScope variableScope, ProcessMetaData metadata) { for (U node : nodes) { - AbstractNodeVisitor visitor = (AbstractNodeVisitor) nodesVisitors.get(node.getClass()); + AbstractNodeVisitor visitor = (AbstractNodeVisitor) nodevisitorService.findNodeVisitor(node.getClass()); if (visitor == null) { continue; } diff --git a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/CompositeContextNodeVisitor.java b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/CompositeContextNodeVisitor.java index 12d7946aefb..7bb9c149d88 100644 --- a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/CompositeContextNodeVisitor.java +++ b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/CompositeContextNodeVisitor.java @@ -19,13 +19,12 @@ package org.jbpm.compiler.canonical; import java.util.HashSet; -import java.util.Map; import java.util.stream.Stream; +import org.jbpm.compiler.canonical.node.NodeVisitorBuilderService; import org.jbpm.process.core.context.variable.VariableScope; import org.jbpm.ruleflow.core.factory.CompositeContextNodeFactory; import org.jbpm.workflow.core.node.CompositeContextNode; -import org.kie.api.definition.process.Node; import com.github.javaparser.ast.expr.BooleanLiteralExpr; import com.github.javaparser.ast.expr.MethodCallExpr; @@ -34,8 +33,8 @@ public class CompositeContextNodeVisitor extends AbstractCompositeNodeVisitor { - public CompositeContextNodeVisitor(Map, AbstractNodeVisitor> nodesVisitors) { - super(nodesVisitors); + public CompositeContextNodeVisitor(NodeVisitorBuilderService nodeVisitorService) { + super(nodeVisitorService); } @Override diff --git a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/DynamicNodeVisitor.java b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/DynamicNodeVisitor.java index 26c802d4948..6535aa5466f 100644 --- a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/DynamicNodeVisitor.java +++ b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/DynamicNodeVisitor.java @@ -20,13 +20,12 @@ import java.util.ArrayList; import java.util.Collection; -import java.util.Map; import java.util.stream.Stream; +import org.jbpm.compiler.canonical.node.NodeVisitorBuilderService; import org.jbpm.process.core.context.variable.VariableScope; import org.jbpm.ruleflow.core.factory.DynamicNodeFactory; import org.jbpm.workflow.core.node.DynamicNode; -import org.kie.api.definition.process.Node; import com.github.javaparser.ast.expr.MethodCallExpr; @@ -36,8 +35,8 @@ public class DynamicNodeVisitor extends CompositeContextNodeVisitor { - public DynamicNodeVisitor(Map, AbstractNodeVisitor> nodesVisitors) { - super(nodesVisitors); + public DynamicNodeVisitor(NodeVisitorBuilderService nodeVisitorService) { + super(nodeVisitorService); } @Override diff --git a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/EventSubProcessNodeVisitor.java b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/EventSubProcessNodeVisitor.java index 815f637039d..ef9c441e44f 100644 --- a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/EventSubProcessNodeVisitor.java +++ b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/EventSubProcessNodeVisitor.java @@ -20,13 +20,12 @@ import java.util.ArrayList; import java.util.Collection; -import java.util.Map; import java.util.stream.Stream; +import org.jbpm.compiler.canonical.node.NodeVisitorBuilderService; import org.jbpm.process.core.context.variable.VariableScope; import org.jbpm.ruleflow.core.factory.EventSubProcessNodeFactory; import org.jbpm.workflow.core.node.EventSubProcessNode; -import org.kie.api.definition.process.Node; import com.github.javaparser.ast.expr.BooleanLiteralExpr; import com.github.javaparser.ast.expr.MethodCallExpr; @@ -37,8 +36,8 @@ public class EventSubProcessNodeVisitor extends CompositeContextNodeVisitor { - public EventSubProcessNodeVisitor(Map, AbstractNodeVisitor> nodesVisitors) { - super(nodesVisitors); + public EventSubProcessNodeVisitor(NodeVisitorBuilderService nodeVisitorService) { + super(nodeVisitorService); } @Override diff --git a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/ForEachNodeVisitor.java b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/ForEachNodeVisitor.java index bb9bf76a415..45e4ffdaa63 100644 --- a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/ForEachNodeVisitor.java +++ b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/ForEachNodeVisitor.java @@ -21,8 +21,8 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; -import java.util.Map; +import org.jbpm.compiler.canonical.node.NodeVisitorBuilderService; import org.jbpm.process.core.context.variable.VariableScope; import org.jbpm.ruleflow.core.factory.ForEachNodeFactory; import org.jbpm.workflow.core.Node; @@ -45,8 +45,8 @@ public class ForEachNodeVisitor extends AbstractCompositeNodeVisitor { - public ForEachNodeVisitor(Map, AbstractNodeVisitor> nodesVisitors) { - super(nodesVisitors); + public ForEachNodeVisitor(NodeVisitorBuilderService nodeVisitorService) { + super(nodeVisitorService); } @Override diff --git a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/HumanTaskNodeVisitor.java b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/HumanTaskNodeVisitor.java index 2c2849dc008..474c55cc5ee 100644 --- a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/HumanTaskNodeVisitor.java +++ b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/HumanTaskNodeVisitor.java @@ -27,8 +27,8 @@ public class HumanTaskNodeVisitor extends WorkItemNodeVisitor { - public HumanTaskNodeVisitor() { - super(null); + public HumanTaskNodeVisitor(ClassLoader classLoader) { + super(classLoader); } @Override diff --git a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/ProcessVisitor.java b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/ProcessVisitor.java index 355ab77aa45..223f9a84288 100644 --- a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/ProcessVisitor.java +++ b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/ProcessVisitor.java @@ -19,7 +19,6 @@ package org.jbpm.compiler.canonical; import java.util.ArrayList; -import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; @@ -28,6 +27,7 @@ import java.util.stream.Stream; import org.jbpm.compiler.canonical.descriptors.ExpressionUtils; +import org.jbpm.compiler.canonical.node.NodeVisitorBuilderService; import org.jbpm.process.core.Context; import org.jbpm.process.core.ContextContainer; import org.jbpm.process.core.Work; @@ -40,27 +40,7 @@ import org.jbpm.workflow.core.Node; import org.jbpm.workflow.core.NodeContainer; import org.jbpm.workflow.core.impl.ConnectionImpl; -import org.jbpm.workflow.core.node.ActionNode; -import org.jbpm.workflow.core.node.BoundaryEventNode; -import org.jbpm.workflow.core.node.CatchLinkNode; -import org.jbpm.workflow.core.node.CompositeContextNode; import org.jbpm.workflow.core.node.CompositeNode; -import org.jbpm.workflow.core.node.DynamicNode; -import org.jbpm.workflow.core.node.EndNode; -import org.jbpm.workflow.core.node.EventNode; -import org.jbpm.workflow.core.node.EventSubProcessNode; -import org.jbpm.workflow.core.node.FaultNode; -import org.jbpm.workflow.core.node.ForEachNode; -import org.jbpm.workflow.core.node.HumanTaskNode; -import org.jbpm.workflow.core.node.Join; -import org.jbpm.workflow.core.node.MilestoneNode; -import org.jbpm.workflow.core.node.RuleSetNode; -import org.jbpm.workflow.core.node.Split; -import org.jbpm.workflow.core.node.StartNode; -import org.jbpm.workflow.core.node.StateNode; -import org.jbpm.workflow.core.node.SubProcessNode; -import org.jbpm.workflow.core.node.ThrowLinkNode; -import org.jbpm.workflow.core.node.TimerNode; import org.jbpm.workflow.core.node.WorkItemNode; import org.kie.api.definition.process.Connection; import org.kie.api.definition.process.Process; @@ -98,30 +78,10 @@ public class ProcessVisitor extends AbstractVisitor { public static final String DEFAULT_VERSION = "1.0"; - private Map, AbstractNodeVisitor> nodesVisitors = new HashMap<>(); + private NodeVisitorBuilderService nodeVisitorService; public ProcessVisitor(ClassLoader contextClassLoader) { - this.nodesVisitors.put(StartNode.class, new StartNodeVisitor()); - this.nodesVisitors.put(ActionNode.class, new ActionNodeVisitor()); - this.nodesVisitors.put(EndNode.class, new EndNodeVisitor()); - this.nodesVisitors.put(HumanTaskNode.class, new HumanTaskNodeVisitor()); - this.nodesVisitors.put(WorkItemNode.class, new WorkItemNodeVisitor<>(contextClassLoader)); - this.nodesVisitors.put(SubProcessNode.class, new LambdaSubProcessNodeVisitor()); - this.nodesVisitors.put(Split.class, new SplitNodeVisitor()); - this.nodesVisitors.put(Join.class, new JoinNodeVisitor()); - this.nodesVisitors.put(FaultNode.class, new FaultNodeVisitor()); - this.nodesVisitors.put(RuleSetNode.class, new RuleSetNodeVisitor(contextClassLoader)); - this.nodesVisitors.put(BoundaryEventNode.class, new BoundaryEventNodeVisitor()); - this.nodesVisitors.put(EventNode.class, new EventNodeVisitor()); - this.nodesVisitors.put(ForEachNode.class, new ForEachNodeVisitor(nodesVisitors)); - this.nodesVisitors.put(CompositeContextNode.class, new CompositeContextNodeVisitor<>(nodesVisitors)); - this.nodesVisitors.put(EventSubProcessNode.class, new EventSubProcessNodeVisitor(nodesVisitors)); - this.nodesVisitors.put(TimerNode.class, new TimerNodeVisitor()); - this.nodesVisitors.put(MilestoneNode.class, new MilestoneNodeVisitor()); - this.nodesVisitors.put(DynamicNode.class, new DynamicNodeVisitor(nodesVisitors)); - this.nodesVisitors.put(StateNode.class, new StateNodeVisitor(nodesVisitors)); - this.nodesVisitors.put(CatchLinkNode.class, new CatchLinkNodeVisitor()); - this.nodesVisitors.put(ThrowLinkNode.class, new ThrowLinkNodeVisitor()); + nodeVisitorService = new NodeVisitorBuilderService(contextClassLoader); } public void visitProcess(WorkflowProcess process, MethodDeclaration processMethod, ProcessMetaData metadata) { @@ -221,7 +181,8 @@ private void visitHeader(WorkflowProcess process, BlockStmt body) { private void visitNodes(List nodes, BlockStmt body, VariableScope variableScope, ProcessMetaData metadata) { for (U node : nodes) { - AbstractNodeVisitor visitor = (AbstractNodeVisitor) nodesVisitors.get(node.getClass()); + @SuppressWarnings("unchecked") + AbstractNodeVisitor visitor = (AbstractNodeVisitor) this.nodeVisitorService.findNodeVisitor(node.getClass()); if (visitor == null) { throw new IllegalStateException("No visitor found for node " + node.getClass().getName()); } @@ -229,6 +190,15 @@ private void visitNodes(List } } + @SuppressWarnings("unchecked") + private String getFieldName(ContextContainer contextContainer) { + AbstractNodeVisitor visitor = null; + if (contextContainer instanceof CompositeNode) { + visitor = this.nodeVisitorService.findNodeVisitor(contextContainer.getClass()); + } + return visitor != null ? visitor.getNodeId(((Node) contextContainer)) : FACTORY_FIELD_NAME; + } + private void visitConnections(org.kie.api.definition.process.Node[] nodes, BlockStmt body) { List connections = new ArrayList<>(); @@ -302,14 +272,6 @@ faultVariable. map(StringLiteralExpr::new) } } - private String getFieldName(ContextContainer contextContainer) { - AbstractNodeVisitor visitor = null; - if (contextContainer instanceof CompositeNode) { - visitor = this.nodesVisitors.get(contextContainer.getClass()); - } - return visitor != null ? visitor.getNodeId(((Node) contextContainer)) : FACTORY_FIELD_NAME; - } - private void visitSubExceptionScope(org.kie.api.definition.process.Node[] nodes, BlockStmt body) { Stream.of(nodes) .peek(node -> { diff --git a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/StateNodeVisitor.java b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/StateNodeVisitor.java index 8c4d95aa9fb..c800c3d65fc 100644 --- a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/StateNodeVisitor.java +++ b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/StateNodeVisitor.java @@ -23,12 +23,12 @@ import java.util.Map; import java.util.stream.Stream; +import org.jbpm.compiler.canonical.node.NodeVisitorBuilderService; import org.jbpm.process.core.context.variable.VariableScope; import org.jbpm.ruleflow.core.factory.StateNodeFactory; import org.jbpm.workflow.core.Constraint; import org.jbpm.workflow.core.impl.ConnectionRef; import org.jbpm.workflow.core.node.StateNode; -import org.kie.api.definition.process.Node; import com.github.javaparser.ast.expr.IntegerLiteralExpr; import com.github.javaparser.ast.expr.MethodCallExpr; @@ -39,8 +39,8 @@ public class StateNodeVisitor extends CompositeContextNodeVisitor { - public StateNodeVisitor(Map, AbstractNodeVisitor> nodesVisitors) { - super(nodesVisitors); + public StateNodeVisitor(NodeVisitorBuilderService nodeVisitorService) { + super(nodeVisitorService); } @Override diff --git a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/ActionNodeVisitorBuilder.java b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/ActionNodeVisitorBuilder.java new file mode 100644 index 00000000000..9349e5bc617 --- /dev/null +++ b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/ActionNodeVisitorBuilder.java @@ -0,0 +1,38 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.jbpm.compiler.canonical.node; + +import org.jbpm.compiler.canonical.AbstractNodeVisitor; +import org.jbpm.compiler.canonical.ActionNodeVisitor; +import org.jbpm.workflow.core.node.ActionNode; +import org.kie.api.definition.process.Node; + +public class ActionNodeVisitorBuilder implements NodeVisitorBuilder { + + @Override + public Class type() { + return ActionNode.class; + } + + @Override + public AbstractNodeVisitor visitor(NodeVisitorBuilderService nodeVisitorService, ClassLoader classLoader) { + return new ActionNodeVisitor(); + } + +} diff --git a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/BoundaryEventNodeVisitorBuilder.java b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/BoundaryEventNodeVisitorBuilder.java new file mode 100644 index 00000000000..7380e2194be --- /dev/null +++ b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/BoundaryEventNodeVisitorBuilder.java @@ -0,0 +1,38 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.jbpm.compiler.canonical.node; + +import org.jbpm.compiler.canonical.AbstractNodeVisitor; +import org.jbpm.compiler.canonical.BoundaryEventNodeVisitor; +import org.jbpm.workflow.core.node.BoundaryEventNode; +import org.kie.api.definition.process.Node; + +public class BoundaryEventNodeVisitorBuilder implements NodeVisitorBuilder { + + @Override + public Class type() { + return BoundaryEventNode.class; + } + + @Override + public AbstractNodeVisitor visitor(NodeVisitorBuilderService nodeVisitorService, ClassLoader classLoader) { + return new BoundaryEventNodeVisitor(); + } + +} diff --git a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/CatchLinkNodeVisitorBuilder.java b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/CatchLinkNodeVisitorBuilder.java new file mode 100644 index 00000000000..aa5484ceab2 --- /dev/null +++ b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/CatchLinkNodeVisitorBuilder.java @@ -0,0 +1,38 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.jbpm.compiler.canonical.node; + +import org.jbpm.compiler.canonical.AbstractNodeVisitor; +import org.jbpm.compiler.canonical.CatchLinkNodeVisitor; +import org.jbpm.workflow.core.node.CatchLinkNode; +import org.kie.api.definition.process.Node; + +public class CatchLinkNodeVisitorBuilder implements NodeVisitorBuilder { + + @Override + public Class type() { + return CatchLinkNode.class; + } + + @Override + public AbstractNodeVisitor visitor(NodeVisitorBuilderService nodeVisitorService, ClassLoader classLoader) { + return new CatchLinkNodeVisitor(); + } + +} diff --git a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/CompositeContextNodeVisitorBuilder.java b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/CompositeContextNodeVisitorBuilder.java new file mode 100644 index 00000000000..c30cbc98985 --- /dev/null +++ b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/CompositeContextNodeVisitorBuilder.java @@ -0,0 +1,38 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.jbpm.compiler.canonical.node; + +import org.jbpm.compiler.canonical.AbstractNodeVisitor; +import org.jbpm.compiler.canonical.CompositeContextNodeVisitor; +import org.jbpm.workflow.core.node.CompositeContextNode; +import org.kie.api.definition.process.Node; + +public class CompositeContextNodeVisitorBuilder implements NodeVisitorBuilder { + + @Override + public Class type() { + return CompositeContextNode.class; + } + + @Override + public AbstractNodeVisitor visitor(NodeVisitorBuilderService nodeVisitorService, ClassLoader classLoader) { + return new CompositeContextNodeVisitor(nodeVisitorService); + } + +} diff --git a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/DynamicNodeVisitorBuilder.java b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/DynamicNodeVisitorBuilder.java new file mode 100644 index 00000000000..f463651f74a --- /dev/null +++ b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/DynamicNodeVisitorBuilder.java @@ -0,0 +1,38 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.jbpm.compiler.canonical.node; + +import org.jbpm.compiler.canonical.AbstractNodeVisitor; +import org.jbpm.compiler.canonical.DynamicNodeVisitor; +import org.jbpm.workflow.core.node.DynamicNode; +import org.kie.api.definition.process.Node; + +public class DynamicNodeVisitorBuilder implements NodeVisitorBuilder { + + @Override + public Class type() { + return DynamicNode.class; + } + + @Override + public AbstractNodeVisitor visitor(NodeVisitorBuilderService nodeVisitorService, ClassLoader classLoader) { + return new DynamicNodeVisitor(nodeVisitorService); + } + +} diff --git a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/EndNodeVisitorBuilder.java b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/EndNodeVisitorBuilder.java new file mode 100644 index 00000000000..75c54c42146 --- /dev/null +++ b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/EndNodeVisitorBuilder.java @@ -0,0 +1,38 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.jbpm.compiler.canonical.node; + +import org.jbpm.compiler.canonical.AbstractNodeVisitor; +import org.jbpm.compiler.canonical.EndNodeVisitor; +import org.jbpm.workflow.core.node.EndNode; +import org.kie.api.definition.process.Node; + +public class EndNodeVisitorBuilder implements NodeVisitorBuilder { + + @Override + public Class type() { + return EndNode.class; + } + + @Override + public AbstractNodeVisitor visitor(NodeVisitorBuilderService nodeVisitorService, ClassLoader classLoader) { + return new EndNodeVisitor(); + } + +} diff --git a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/EventNodeVisitorBuilder.java b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/EventNodeVisitorBuilder.java new file mode 100644 index 00000000000..030ef556756 --- /dev/null +++ b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/EventNodeVisitorBuilder.java @@ -0,0 +1,38 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.jbpm.compiler.canonical.node; + +import org.jbpm.compiler.canonical.AbstractNodeVisitor; +import org.jbpm.compiler.canonical.EventNodeVisitor; +import org.jbpm.workflow.core.node.EventNode; +import org.kie.api.definition.process.Node; + +public class EventNodeVisitorBuilder implements NodeVisitorBuilder { + + @Override + public Class type() { + return EventNode.class; + } + + @Override + public AbstractNodeVisitor visitor(NodeVisitorBuilderService nodeVisitorService, ClassLoader classLoader) { + return new EventNodeVisitor(); + } + +} diff --git a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/EventSubProcessNodeVisitorBuilder.java b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/EventSubProcessNodeVisitorBuilder.java new file mode 100644 index 00000000000..afae970aa51 --- /dev/null +++ b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/EventSubProcessNodeVisitorBuilder.java @@ -0,0 +1,38 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.jbpm.compiler.canonical.node; + +import org.jbpm.compiler.canonical.AbstractNodeVisitor; +import org.jbpm.compiler.canonical.EventSubProcessNodeVisitor; +import org.jbpm.workflow.core.node.EventSubProcessNode; +import org.kie.api.definition.process.Node; + +public class EventSubProcessNodeVisitorBuilder implements NodeVisitorBuilder { + + @Override + public Class type() { + return EventSubProcessNode.class; + } + + @Override + public AbstractNodeVisitor visitor(NodeVisitorBuilderService nodeVisitorService, ClassLoader classLoader) { + return new EventSubProcessNodeVisitor(nodeVisitorService); + } + +} diff --git a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/FaultNodeVisitorBuilder.java b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/FaultNodeVisitorBuilder.java new file mode 100644 index 00000000000..9c6dfe5f2dc --- /dev/null +++ b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/FaultNodeVisitorBuilder.java @@ -0,0 +1,38 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.jbpm.compiler.canonical.node; + +import org.jbpm.compiler.canonical.AbstractNodeVisitor; +import org.jbpm.compiler.canonical.FaultNodeVisitor; +import org.jbpm.workflow.core.node.FaultNode; +import org.kie.api.definition.process.Node; + +public class FaultNodeVisitorBuilder implements NodeVisitorBuilder { + + @Override + public Class type() { + return FaultNode.class; + } + + @Override + public AbstractNodeVisitor visitor(NodeVisitorBuilderService nodeVisitorService, ClassLoader classLoader) { + return new FaultNodeVisitor(); + } + +} diff --git a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/ForEachNodeVisitorBuilder.java b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/ForEachNodeVisitorBuilder.java new file mode 100644 index 00000000000..0ddb803c05d --- /dev/null +++ b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/ForEachNodeVisitorBuilder.java @@ -0,0 +1,38 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.jbpm.compiler.canonical.node; + +import org.jbpm.compiler.canonical.AbstractNodeVisitor; +import org.jbpm.compiler.canonical.ForEachNodeVisitor; +import org.jbpm.workflow.core.node.ForEachNode; +import org.kie.api.definition.process.Node; + +public class ForEachNodeVisitorBuilder implements NodeVisitorBuilder { + + @Override + public Class type() { + return ForEachNode.class; + } + + @Override + public AbstractNodeVisitor visitor(NodeVisitorBuilderService nodeVisitorService, ClassLoader classLoader) { + return new ForEachNodeVisitor(nodeVisitorService); + } + +} diff --git a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/HumanTaskNodeVisitorBuilder.java b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/HumanTaskNodeVisitorBuilder.java new file mode 100644 index 00000000000..475ed0824eb --- /dev/null +++ b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/HumanTaskNodeVisitorBuilder.java @@ -0,0 +1,38 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.jbpm.compiler.canonical.node; + +import org.jbpm.compiler.canonical.AbstractNodeVisitor; +import org.jbpm.compiler.canonical.HumanTaskNodeVisitor; +import org.jbpm.workflow.core.node.HumanTaskNode; +import org.kie.api.definition.process.Node; + +public class HumanTaskNodeVisitorBuilder implements NodeVisitorBuilder { + + @Override + public Class type() { + return HumanTaskNode.class; + } + + @Override + public AbstractNodeVisitor visitor(NodeVisitorBuilderService nodeVisitorService, ClassLoader classLoader) { + return new HumanTaskNodeVisitor(classLoader); + } + +} diff --git a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/JoinNodeVisitorBuilder.java b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/JoinNodeVisitorBuilder.java new file mode 100644 index 00000000000..6a14cbdb405 --- /dev/null +++ b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/JoinNodeVisitorBuilder.java @@ -0,0 +1,38 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.jbpm.compiler.canonical.node; + +import org.jbpm.compiler.canonical.AbstractNodeVisitor; +import org.jbpm.compiler.canonical.JoinNodeVisitor; +import org.jbpm.workflow.core.node.Join; +import org.kie.api.definition.process.Node; + +public class JoinNodeVisitorBuilder implements NodeVisitorBuilder { + + @Override + public Class type() { + return Join.class; + } + + @Override + public AbstractNodeVisitor visitor(NodeVisitorBuilderService nodeVisitorService, ClassLoader classLoader) { + return new JoinNodeVisitor(); + } + +} diff --git a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/MilestoneNodeVisitorBuilder.java b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/MilestoneNodeVisitorBuilder.java new file mode 100644 index 00000000000..7d50d9d8597 --- /dev/null +++ b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/MilestoneNodeVisitorBuilder.java @@ -0,0 +1,38 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.jbpm.compiler.canonical.node; + +import org.jbpm.compiler.canonical.AbstractNodeVisitor; +import org.jbpm.compiler.canonical.MilestoneNodeVisitor; +import org.jbpm.workflow.core.node.MilestoneNode; +import org.kie.api.definition.process.Node; + +public class MilestoneNodeVisitorBuilder implements NodeVisitorBuilder { + + @Override + public Class type() { + return MilestoneNode.class; + } + + @Override + public AbstractNodeVisitor visitor(NodeVisitorBuilderService nodeVisitorService, ClassLoader classLoader) { + return new MilestoneNodeVisitor(); + } + +} diff --git a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/NodeVisitorBuilder.java b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/NodeVisitorBuilder.java new file mode 100644 index 00000000000..5aab0f3eba3 --- /dev/null +++ b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/NodeVisitorBuilder.java @@ -0,0 +1,28 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.jbpm.compiler.canonical.node; + +import org.jbpm.compiler.canonical.AbstractNodeVisitor; + +public interface NodeVisitorBuilder { + + Class type(); + + AbstractNodeVisitor visitor(NodeVisitorBuilderService nodeVisitorService, ClassLoader contextClassLoader); +} diff --git a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/NodeVisitorBuilderService.java b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/NodeVisitorBuilderService.java new file mode 100644 index 00000000000..8363aab0041 --- /dev/null +++ b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/NodeVisitorBuilderService.java @@ -0,0 +1,51 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.jbpm.compiler.canonical.node; + +import java.util.Map; +import java.util.ServiceLoader; +import java.util.function.Function; +import java.util.stream.Collectors; + +import org.jbpm.compiler.canonical.AbstractNodeVisitor; +import org.jbpm.util.JbpmClassLoaderUtil; + +public class NodeVisitorBuilderService { + + private Map, NodeVisitorBuilder> nodesVisitors; + private ClassLoader contextClassLoader; + + public NodeVisitorBuilderService() { + this(JbpmClassLoaderUtil.findClassLoader()); + } + + public NodeVisitorBuilderService(ClassLoader contextClassLoader) { + this.nodesVisitors = ServiceLoader.load(NodeVisitorBuilder.class).stream().map(ServiceLoader.Provider::get).collect(Collectors.toMap(NodeVisitorBuilder::type, Function.identity())); + this.contextClassLoader = contextClassLoader; + } + + public AbstractNodeVisitor findNodeVisitor(Class clazz) { + NodeVisitorBuilder nodeVisitor = nodesVisitors.get(clazz); + if (nodeVisitor != null) { + return nodeVisitor.visitor(this, contextClassLoader); + } + throw new IllegalArgumentException(clazz + " visitor not supported"); + } + +} diff --git a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/RuleSetNodeVisitorBuilder.java b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/RuleSetNodeVisitorBuilder.java new file mode 100644 index 00000000000..a1df78d2341 --- /dev/null +++ b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/RuleSetNodeVisitorBuilder.java @@ -0,0 +1,38 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.jbpm.compiler.canonical.node; + +import org.jbpm.compiler.canonical.AbstractNodeVisitor; +import org.jbpm.compiler.canonical.RuleSetNodeVisitor; +import org.jbpm.workflow.core.node.RuleSetNode; +import org.kie.api.definition.process.Node; + +public class RuleSetNodeVisitorBuilder implements NodeVisitorBuilder { + + @Override + public Class type() { + return RuleSetNode.class; + } + + @Override + public AbstractNodeVisitor visitor(NodeVisitorBuilderService nodeVisitorService, ClassLoader classLoader) { + return new RuleSetNodeVisitor(classLoader); + } + +} diff --git a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/SplitNodeVisitorBuilder.java b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/SplitNodeVisitorBuilder.java new file mode 100644 index 00000000000..3d29c31d317 --- /dev/null +++ b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/SplitNodeVisitorBuilder.java @@ -0,0 +1,38 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.jbpm.compiler.canonical.node; + +import org.jbpm.compiler.canonical.AbstractNodeVisitor; +import org.jbpm.compiler.canonical.SplitNodeVisitor; +import org.jbpm.workflow.core.node.Split; +import org.kie.api.definition.process.Node; + +public class SplitNodeVisitorBuilder implements NodeVisitorBuilder { + + @Override + public Class type() { + return Split.class; + } + + @Override + public AbstractNodeVisitor visitor(NodeVisitorBuilderService nodeVisitorService, ClassLoader classLoader) { + return new SplitNodeVisitor(); + } + +} diff --git a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/StartNodeVisitorBuilder.java b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/StartNodeVisitorBuilder.java new file mode 100644 index 00000000000..76feb9af440 --- /dev/null +++ b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/StartNodeVisitorBuilder.java @@ -0,0 +1,38 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.jbpm.compiler.canonical.node; + +import org.jbpm.compiler.canonical.AbstractNodeVisitor; +import org.jbpm.compiler.canonical.StartNodeVisitor; +import org.jbpm.workflow.core.node.StartNode; +import org.kie.api.definition.process.Node; + +public class StartNodeVisitorBuilder implements NodeVisitorBuilder { + + @Override + public Class type() { + return StartNode.class; + } + + @Override + public AbstractNodeVisitor visitor(NodeVisitorBuilderService nodeVisitorService, ClassLoader classLoader) { + return new StartNodeVisitor(); + } + +} diff --git a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/StateNodeVisitorBuilder.java b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/StateNodeVisitorBuilder.java new file mode 100644 index 00000000000..50a50b9b065 --- /dev/null +++ b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/StateNodeVisitorBuilder.java @@ -0,0 +1,38 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.jbpm.compiler.canonical.node; + +import org.jbpm.compiler.canonical.AbstractNodeVisitor; +import org.jbpm.compiler.canonical.StateNodeVisitor; +import org.jbpm.workflow.core.node.StateNode; +import org.kie.api.definition.process.Node; + +public class StateNodeVisitorBuilder implements NodeVisitorBuilder { + + @Override + public Class type() { + return StateNode.class; + } + + @Override + public AbstractNodeVisitor visitor(NodeVisitorBuilderService nodeVisitorService, ClassLoader classLoader) { + return new StateNodeVisitor(nodeVisitorService); + } + +} diff --git a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/SubProcessNodeVisitorBuilder.java b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/SubProcessNodeVisitorBuilder.java new file mode 100644 index 00000000000..671aff96b47 --- /dev/null +++ b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/SubProcessNodeVisitorBuilder.java @@ -0,0 +1,38 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.jbpm.compiler.canonical.node; + +import org.jbpm.compiler.canonical.AbstractNodeVisitor; +import org.jbpm.compiler.canonical.LambdaSubProcessNodeVisitor; +import org.jbpm.workflow.core.node.SubProcessNode; +import org.kie.api.definition.process.Node; + +public class SubProcessNodeVisitorBuilder implements NodeVisitorBuilder { + + @Override + public Class type() { + return SubProcessNode.class; + } + + @Override + public AbstractNodeVisitor visitor(NodeVisitorBuilderService nodeVisitorService, ClassLoader classLoader) { + return new LambdaSubProcessNodeVisitor(); + } + +} diff --git a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/ThrowLinkNodeVisitorBuilder.java b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/ThrowLinkNodeVisitorBuilder.java new file mode 100644 index 00000000000..df851519b78 --- /dev/null +++ b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/ThrowLinkNodeVisitorBuilder.java @@ -0,0 +1,38 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.jbpm.compiler.canonical.node; + +import org.jbpm.compiler.canonical.AbstractNodeVisitor; +import org.jbpm.compiler.canonical.ThrowLinkNodeVisitor; +import org.jbpm.workflow.core.node.ThrowLinkNode; +import org.kie.api.definition.process.Node; + +public class ThrowLinkNodeVisitorBuilder implements NodeVisitorBuilder { + + @Override + public Class type() { + return ThrowLinkNode.class; + } + + @Override + public AbstractNodeVisitor visitor(NodeVisitorBuilderService nodeVisitorService, ClassLoader classLoader) { + return new ThrowLinkNodeVisitor(); + } + +} diff --git a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/TimerNodeVisitorBuilder.java b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/TimerNodeVisitorBuilder.java new file mode 100644 index 00000000000..658e31c68fa --- /dev/null +++ b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/TimerNodeVisitorBuilder.java @@ -0,0 +1,38 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.jbpm.compiler.canonical.node; + +import org.jbpm.compiler.canonical.AbstractNodeVisitor; +import org.jbpm.compiler.canonical.TimerNodeVisitor; +import org.jbpm.workflow.core.node.TimerNode; +import org.kie.api.definition.process.Node; + +public class TimerNodeVisitorBuilder implements NodeVisitorBuilder { + + @Override + public Class type() { + return TimerNode.class; + } + + @Override + public AbstractNodeVisitor visitor(NodeVisitorBuilderService nodeVisitorService, ClassLoader classLoader) { + return new TimerNodeVisitor(); + } + +} diff --git a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/WorkItemNodeVisitorBuilder.java b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/WorkItemNodeVisitorBuilder.java new file mode 100644 index 00000000000..a8142bac2b3 --- /dev/null +++ b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/WorkItemNodeVisitorBuilder.java @@ -0,0 +1,38 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.jbpm.compiler.canonical.node; + +import org.jbpm.compiler.canonical.AbstractNodeVisitor; +import org.jbpm.compiler.canonical.WorkItemNodeVisitor; +import org.jbpm.workflow.core.node.WorkItemNode; +import org.kie.api.definition.process.Node; + +public class WorkItemNodeVisitorBuilder implements NodeVisitorBuilder { + + @Override + public Class type() { + return WorkItemNode.class; + } + + @Override + public AbstractNodeVisitor visitor(NodeVisitorBuilderService nodeVisitorService, ClassLoader classLoader) { + return new WorkItemNodeVisitor(classLoader); + } + +} diff --git a/jbpm/jbpm-flow-builder/src/main/resources/META-INF/services/org.jbpm.compiler.canonical.node.NodeVisitorBuilder b/jbpm/jbpm-flow-builder/src/main/resources/META-INF/services/org.jbpm.compiler.canonical.node.NodeVisitorBuilder new file mode 100644 index 00000000000..1cd11599480 --- /dev/null +++ b/jbpm/jbpm-flow-builder/src/main/resources/META-INF/services/org.jbpm.compiler.canonical.node.NodeVisitorBuilder @@ -0,0 +1,21 @@ +org.jbpm.compiler.canonical.node.ActionNodeVisitorBuilder +org.jbpm.compiler.canonical.node.BoundaryEventNodeVisitorBuilder +org.jbpm.compiler.canonical.node.CatchLinkNodeVisitorBuilder +org.jbpm.compiler.canonical.node.CompositeContextNodeVisitorBuilder +org.jbpm.compiler.canonical.node.DynamicNodeVisitorBuilder +org.jbpm.compiler.canonical.node.EndNodeVisitorBuilder +org.jbpm.compiler.canonical.node.EventNodeVisitorBuilder +org.jbpm.compiler.canonical.node.EventSubProcessNodeVisitorBuilder +org.jbpm.compiler.canonical.node.FaultNodeVisitorBuilder +org.jbpm.compiler.canonical.node.ForEachNodeVisitorBuilder +org.jbpm.compiler.canonical.node.HumanTaskNodeVisitorBuilder +org.jbpm.compiler.canonical.node.JoinNodeVisitorBuilder +org.jbpm.compiler.canonical.node.MilestoneNodeVisitorBuilder +org.jbpm.compiler.canonical.node.RuleSetNodeVisitorBuilder +org.jbpm.compiler.canonical.node.SplitNodeVisitorBuilder +org.jbpm.compiler.canonical.node.StartNodeVisitorBuilder +org.jbpm.compiler.canonical.node.StateNodeVisitorBuilder +org.jbpm.compiler.canonical.node.SubProcessNodeVisitorBuilder +org.jbpm.compiler.canonical.node.ThrowLinkNodeVisitorBuilder +org.jbpm.compiler.canonical.node.TimerNodeVisitorBuilder +org.jbpm.compiler.canonical.node.WorkItemNodeVisitorBuilder \ No newline at end of file From c4edb3b57967a1a1643592f9410bce98ad875e8e Mon Sep 17 00:00:00 2001 From: Abhiram Gundala <164050036+Abhitocode@users.noreply.github.com> Date: Tue, 21 May 2024 02:30:26 -0400 Subject: [PATCH 13/32] [incubator-kie-issues-1131] Process test migration from v7 legacy runtime to code generation (#3516) --- .../java/org/jbpm/bpmn2/ActivityTest.java | 188 +++++++++++------- 1 file changed, 116 insertions(+), 72 deletions(-) diff --git a/jbpm/jbpm-tests/src/test/java/org/jbpm/bpmn2/ActivityTest.java b/jbpm/jbpm-tests/src/test/java/org/jbpm/bpmn2/ActivityTest.java index 319595851d3..c396cf8abbd 100755 --- a/jbpm/jbpm-tests/src/test/java/org/jbpm/bpmn2/ActivityTest.java +++ b/jbpm/jbpm-tests/src/test/java/org/jbpm/bpmn2/ActivityTest.java @@ -20,12 +20,34 @@ import java.math.BigDecimal; import java.util.ArrayList; +import java.util.Collection; import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.Objects; import org.drools.compiler.rule.builder.PackageBuildContext; +import org.jbpm.bpmn2.activity.ScriptTaskModel; +import org.jbpm.bpmn2.activity.ScriptTaskProcess; +import org.jbpm.bpmn2.activity.ScriptTaskWithIOModel; +import org.jbpm.bpmn2.activity.ScriptTaskWithIOProcess; +import org.jbpm.bpmn2.activity.UserTaskWithSimulationMetaDataModel; +import org.jbpm.bpmn2.activity.UserTaskWithSimulationMetaDataProcess; +import org.jbpm.bpmn2.flow.CompositeWithDIGraphicalModel; +import org.jbpm.bpmn2.flow.CompositeWithDIGraphicalProcess; +import org.jbpm.bpmn2.flow.MinimalImplicitModel; +import org.jbpm.bpmn2.flow.MinimalImplicitProcess; +import org.jbpm.bpmn2.flow.MinimalModel; +import org.jbpm.bpmn2.flow.MinimalProcess; +import org.jbpm.bpmn2.flow.MinimalWithDIGraphicalModel; +import org.jbpm.bpmn2.flow.MinimalWithDIGraphicalProcess; +import org.jbpm.bpmn2.flow.MinimalWithGraphicalModel; +import org.jbpm.bpmn2.flow.MinimalWithGraphicalProcess; +import org.jbpm.bpmn2.flow.ProcessWithVariableNameModel; +import org.jbpm.bpmn2.flow.ProcessWithVariableNameProcess; +import org.jbpm.bpmn2.flow.UserTaskModel; +import org.jbpm.bpmn2.flow.UserTaskProcess; import org.jbpm.bpmn2.handler.ReceiveTaskHandler; import org.jbpm.bpmn2.handler.SendTaskHandler; import org.jbpm.bpmn2.handler.ServiceTaskHandler; @@ -36,6 +58,8 @@ import org.jbpm.bpmn2.objects.TestWorkItemHandler; import org.jbpm.bpmn2.subprocess.SubProcessWithEntryExitScriptsModel; import org.jbpm.bpmn2.subprocess.SubProcessWithEntryExitScriptsProcess; +import org.jbpm.bpmn2.task.SendTaskModel; +import org.jbpm.bpmn2.task.SendTaskProcess; import org.jbpm.bpmn2.test.RequirePersistence; import org.jbpm.process.builder.ActionBuilder; import org.jbpm.process.builder.AssignmentBuilder; @@ -81,7 +105,9 @@ import org.kie.api.runtime.process.DataTransformer; import org.kie.api.runtime.process.NodeInstance; import org.kie.kogito.Application; +import org.kie.kogito.auth.SecurityPolicy; import org.kie.kogito.internal.process.event.DefaultKogitoProcessEventListener; +import org.kie.kogito.internal.process.runtime.KogitoNode; import org.kie.kogito.internal.process.runtime.KogitoNodeInstanceContainer; import org.kie.kogito.internal.process.runtime.KogitoProcessInstance; import org.kie.kogito.internal.process.runtime.KogitoProcessRuntime; @@ -98,31 +124,43 @@ public class ActivityTest extends JbpmBpmn2TestCase { @Test - public void testMinimalProcess() throws Exception { - kruntime = createKogitoProcessRuntime("org/jbpm/bpmn2/flow/BPMN2-MinimalProcess.bpmn2"); - KogitoProcessInstance processInstance = kruntime.startProcess("Minimal"); - assertProcessInstanceCompleted(processInstance); + public void testMinimalProcess() { + Application app = ProcessTestHelper.newApplication(); + org.kie.kogito.process.Process minimalProcess = MinimalProcess.newProcess(app); + MinimalModel model = minimalProcess.createModel(); + org.kie.kogito.process.ProcessInstance instance = minimalProcess.createInstance(model); + instance.start(); + assertThat(instance.status()).isEqualTo(org.kie.kogito.process.ProcessInstance.STATE_COMPLETED); } @Test - public void testMinimalProcessImplicit() throws Exception { - kruntime = createKogitoProcessRuntime("org/jbpm/bpmn2/flow/BPMN2-MinimalProcessImplicit.bpmn2"); - KogitoProcessInstance processInstance = kruntime.startProcess("MinimalImplicit"); - assertProcessInstanceCompleted(processInstance); + public void testMinimalProcessImplicit() { + Application app = ProcessTestHelper.newApplication(); + org.kie.kogito.process.Process minimalImplicitProcess = MinimalImplicitProcess.newProcess(app); + MinimalImplicitModel model = minimalImplicitProcess.createModel(); + ProcessInstance instance = minimalImplicitProcess.createInstance(model); + instance.start(); + assertThat(instance.status()).isEqualTo(ProcessInstance.STATE_COMPLETED); } @Test - public void testMinimalProcessWithGraphical() throws Exception { - kruntime = createKogitoProcessRuntime("org/jbpm/bpmn2/flow/BPMN2-MinimalProcessWithGraphical.bpmn2"); - KogitoProcessInstance processInstance = kruntime.startProcess("MinimalWithGraphical"); - assertProcessInstanceCompleted(processInstance); + public void testMinimalProcessWithGraphical() { + Application app = ProcessTestHelper.newApplication(); + org.kie.kogito.process.Process minimalWithGraphicalProcess = MinimalWithGraphicalProcess.newProcess(app); + MinimalWithGraphicalModel model = minimalWithGraphicalProcess.createModel(); + ProcessInstance instance = minimalWithGraphicalProcess.createInstance(model); + instance.start(); + assertThat(instance.status()).isEqualTo(ProcessInstance.STATE_COMPLETED); } @Test - public void testMinimalProcessWithDIGraphical() throws Exception { - kruntime = createKogitoProcessRuntime("org/jbpm/bpmn2/flow/BPMN2-MinimalProcessWithDIGraphical.bpmn2"); - KogitoProcessInstance processInstance = kruntime.startProcess("MinimalWithDIGraphical"); - assertProcessInstanceCompleted(processInstance); + public void testMinimalProcessWithDIGraphical() { + Application app = ProcessTestHelper.newApplication(); + org.kie.kogito.process.Process minimalWithDIGraphicalProcess = MinimalWithDIGraphicalProcess.newProcess(app); + MinimalWithDIGraphicalModel model = minimalWithDIGraphicalProcess.createModel(); + ProcessInstance instance = minimalWithDIGraphicalProcess.createInstance(model); + instance.start(); + assertThat(instance.status()).isEqualTo(ProcessInstance.STATE_COMPLETED); } @Test @@ -194,34 +232,38 @@ public void afterProcessStarted(ProcessStartedEvent event) { } @Test - public void testCompositeProcessWithDIGraphical() throws Exception { - kruntime = createKogitoProcessRuntime("org/jbpm/bpmn2/flow/BPMN2-CompositeProcessWithDIGraphical.bpmn2"); - KogitoProcessInstance processInstance = kruntime.startProcess("CompositeWithDIGraphical"); - assertProcessInstanceCompleted(processInstance); + public void testCompositeProcessWithDIGraphical() { + Application app = ProcessTestHelper.newApplication(); + org.kie.kogito.process.Process compositeWithDIGraphicalProcess = CompositeWithDIGraphicalProcess.newProcess(app); + CompositeWithDIGraphicalModel model = compositeWithDIGraphicalProcess.createModel(); + ProcessInstance instance = compositeWithDIGraphicalProcess.createInstance(model); + instance.start(); + assertThat(instance.status()).isEqualTo(ProcessInstance.STATE_COMPLETED); } @Test - public void testScriptTask() throws Exception { - kruntime = createKogitoProcessRuntime("org/jbpm/bpmn2/activity/BPMN2-ScriptTask.bpmn2"); - KogitoProcessInstance processInstance = kruntime.startProcess("ScriptTask"); - assertProcessInstanceCompleted(processInstance); + public void testScriptTask() { + Application app = ProcessTestHelper.newApplication(); + org.kie.kogito.process.Process scriptTasklProcess = ScriptTaskProcess.newProcess(app); + ScriptTaskModel model = scriptTasklProcess.createModel(); + ProcessInstance instance = scriptTasklProcess.createInstance(model); + instance.start(); + assertThat(instance.status()).isEqualTo(ProcessInstance.STATE_COMPLETED); } @Test - public void testScriptTaskWithIO() throws Exception { - kruntime = createKogitoProcessRuntime("org/jbpm/bpmn2/activity/BPMN2-ScriptTaskWithIO.bpmn2"); - - Process scriptProcess = kruntime.getKieBase().getProcess("ScriptTaskWithIO"); - assertThat(scriptProcess).isNotNull(); - Node[] nodes = ((NodeContainer) scriptProcess).getNodes(); + public void testScriptTaskWithIO() { + Application app = ProcessTestHelper.newApplication(); + org.kie.kogito.process.Process scriptTaskWithIOProcess = ScriptTaskWithIOProcess.newProcess(app); + ScriptTaskWithIOModel model = scriptTaskWithIOProcess.createModel(); + model.setName("john"); + ProcessInstance instance = scriptTaskWithIOProcess.createInstance(model); + instance.start(); + assertThat(scriptTaskWithIOProcess).isNotNull(); + Collection nodes = scriptTaskWithIOProcess.findNodes(Objects::nonNull); assertThat(nodes).hasSize(3); assertThat(nodes).filteredOn(n -> n instanceof ActionNode).allMatch(n -> ((ActionNode) n).getInAssociations().size() == 1 && ((ActionNode) n).getOutAssociations().size() == 1); - - Map params = new HashMap<>(); - params.put("name", "John"); - KogitoProcessInstance processInstance = kruntime.startProcess("ScriptTaskWithIO", params); - - assertProcessInstanceCompleted(processInstance); + assertThat(instance.status()).isEqualTo(ProcessInstance.STATE_COMPLETED); } @Test @@ -357,19 +399,20 @@ public void testUserTaskWithDataStoreScenario() throws Exception { } @Test - public void testUserTask() throws Exception { - kruntime = createKogitoProcessRuntime("org/jbpm/bpmn2/activity/BPMN2-UserTask.bpmn2"); - + public void testUserTask() { + Application app = ProcessTestHelper.newApplication(); TestWorkItemHandler workItemHandler = new TestWorkItemHandler(); - kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Human Task", - workItemHandler); - KogitoProcessInstance processInstance = kruntime.startProcess("UserTask"); - assertThat(processInstance.getState()).isEqualTo(KogitoProcessInstance.STATE_ACTIVE); - org.kie.kogito.internal.process.runtime.KogitoWorkItem workItem = workItemHandler.getWorkItem(); + ProcessTestHelper.registerHandler(app, "Human Task", workItemHandler); + org.kie.kogito.process.Process processDefinition = UserTaskProcess.newProcess(app); + UserTaskModel model = processDefinition.createModel(); + org.kie.kogito.process.ProcessInstance instance = processDefinition.createInstance(model); + instance.start(); + assertThat(instance).extracting(ProcessInstance::status).isEqualTo(ProcessInstance.STATE_ACTIVE); + KogitoWorkItem workItem = workItemHandler.getWorkItem(); assertThat(workItem).isNotNull(); assertThat(workItem.getParameter("ActorId")).isEqualTo("john"); - kruntime.getKogitoWorkItemManager().completeWorkItem(workItem.getStringId(), null); - assertProcessInstanceFinished(processInstance, kruntime); + instance.completeWorkItem(workItem.getStringId(), Collections.emptyMap(), SecurityPolicy.of("john", Collections.emptyList())); + assertThat(instance).extracting(ProcessInstance::status).isEqualTo(ProcessInstance.STATE_COMPLETED); } @Test @@ -827,16 +870,15 @@ public void executeWorkItem(KogitoWorkItem workItem, KogitoWorkItemManager manag } @Test - public void testSendTask() throws Exception { - kruntime = createKogitoProcessRuntime("org/jbpm/bpmn2/task/BPMN2-SendTask.bpmn2"); - - kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Send Task", - new SendTaskHandler()); - Map params = new HashMap<>(); - params.put("s", "john"); - KogitoWorkflowProcessInstance processInstance = (KogitoWorkflowProcessInstance) kruntime - .startProcess("SendTask", params); - assertProcessInstanceFinished(processInstance, kruntime); + public void testSendTask() { + Application app = ProcessTestHelper.newApplication(); + ProcessTestHelper.registerHandler(app, "Send Task", new SendTaskHandler()); + org.kie.kogito.process.Process processDefinition = SendTaskProcess.newProcess(app); + SendTaskModel model = processDefinition.createModel(); + model.setS("john"); + org.kie.kogito.process.ProcessInstance instance = processDefinition.createInstance(model); + instance.start(); + assertThat(instance.status()).isEqualTo(org.kie.kogito.process.ProcessInstance.STATE_COMPLETED); } @Test @@ -938,13 +980,14 @@ public void testBusinessRuleTaskWithContionalEvent() throws Exception { @Test public void testScriptTaskWithVariableByName() throws Exception { - Map params = new HashMap<>(); - params.put("myVar", "test"); - kruntime = createKogitoProcessRuntime("org/jbpm/bpmn2/flow/BPMN2-ProcessWithVariableName.bpmn2"); - KogitoProcessInstance processInstance = kruntime.startProcess( - "ProcessWithVariableName", params); - assertProcessInstanceCompleted(processInstance); + Application app = ProcessTestHelper.newApplication(); + org.kie.kogito.process.Process processDefinition = ProcessWithVariableNameProcess.newProcess(app); + ProcessWithVariableNameModel model = processDefinition.createModel(); + model.setMyVar("test"); + org.kie.kogito.process.ProcessInstance instance = processDefinition.createInstance(model); + instance.start(); + assertThat(instance.status()).isEqualTo(org.kie.kogito.process.ProcessInstance.STATE_COMPLETED); } @Test @@ -1021,19 +1064,20 @@ public void testUserTaskWithBooleanOutput() throws Exception { } @Test - public void testUserTaskWithSimData() throws Exception { - kruntime = createKogitoProcessRuntime("org/jbpm/bpmn2/activity/BPMN2-UserTaskWithSimulationMetaData.bpmn2"); - + public void testUserTaskWithSimData() { + Application app = ProcessTestHelper.newApplication(); TestWorkItemHandler workItemHandler = new TestWorkItemHandler(); - kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Human Task", - workItemHandler); - KogitoProcessInstance processInstance = kruntime.startProcess("UserTaskWithSimulationMetaData"); - assertThat(processInstance.getState()).isEqualTo(KogitoProcessInstance.STATE_ACTIVE); - org.kie.kogito.internal.process.runtime.KogitoWorkItem workItem = workItemHandler.getWorkItem(); + ProcessTestHelper.registerHandler(app, "Human Task", workItemHandler); + org.kie.kogito.process.Process processDefinition = UserTaskWithSimulationMetaDataProcess.newProcess(app); + UserTaskWithSimulationMetaDataModel model = processDefinition.createModel(); + org.kie.kogito.process.ProcessInstance instance = processDefinition.createInstance(model); + instance.start(); + assertThat(instance).extracting(ProcessInstance::status).isEqualTo(org.kie.kogito.process.ProcessInstance.STATE_ACTIVE); + KogitoWorkItem workItem = workItemHandler.getWorkItem(); assertThat(workItem).isNotNull(); assertThat(workItem.getParameter("ActorId")).isEqualTo("john"); - kruntime.getKogitoWorkItemManager().completeWorkItem(workItem.getStringId(), null); - assertProcessInstanceFinished(processInstance, kruntime); + instance.completeWorkItem(workItem.getStringId(), Collections.emptyMap(), SecurityPolicy.of("john", Collections.emptyList())); + assertThat(instance).extracting(ProcessInstance::status).isEqualTo(org.kie.kogito.process.ProcessInstance.STATE_COMPLETED); } @Test From fcd5d3aecb826dc842bbead3ea338e844842356f Mon Sep 17 00:00:00 2001 From: Jan Stastny Date: Tue, 21 May 2024 16:24:56 +0200 Subject: [PATCH 14/32] [kie-issues#1123] adjust deploy operation (#3517) * [kie-issues#1123] adjust deploy operation * fix missing curly --------- Co-authored-by: jstastny-cz --- .ci/jenkins/Jenkinsfile.deploy | 94 +++------------------------ .ci/jenkins/Jenkinsfile.weekly.deploy | 58 ++++++----------- .ci/jenkins/dsl/jobs.groovy | 5 -- 3 files changed, 29 insertions(+), 128 deletions(-) diff --git a/.ci/jenkins/Jenkinsfile.deploy b/.ci/jenkins/Jenkinsfile.deploy index f9aca3a402b..795ed5f8a15 100644 --- a/.ci/jenkins/Jenkinsfile.deploy +++ b/.ci/jenkins/Jenkinsfile.deploy @@ -21,7 +21,6 @@ import org.jenkinsci.plugins.workflow.libs.Library @Library('jenkins-pipeline-shared-libraries')_ import org.kie.jenkins.MavenCommand -import org.kie.jenkins.MavenStagingHelper deployProperties = [:] @@ -49,7 +48,6 @@ pipeline { KOGITO_CI_EMAIL_TO = credentials("${JENKINS_EMAIL_CREDS_ID}") PR_BRANCH_HASH = "${util.generateHash(10)}" - MAVEN_DEPLOY_LOCAL_DIR = "/tmp/maven_deploy_dir" } stages { @@ -136,10 +134,16 @@ pipeline { } } } - stage('Build & Test') { + stage('Deploy kogito-runtimes') { steps { script { - dir(getRepoName()) { + withCredentials([usernamePassword(credentialsId: env.MAVEN_REPO_CREDS_ID, usernameVariable: 'REPOSITORY_USER', passwordVariable: 'REPOSITORY_TOKEN')]) { + def installOrDeploy + if (shouldDeployToRepository()) { + installOrDeploy = "deploy -DdeployAtEnd -Dapache.repository.username=${REPOSITORY_USER} -Dapache.repository.password=${REPOSITORY_TOKEN} -DretryFailedDeploymentCount=5" + } else { + installOrDeploy = 'install' + } def mvnCmd = getMavenCommand() .withOptions(env.BUILD_MVN_OPTS_CURRENT ? [ env.BUILD_MVN_OPTS_CURRENT ] : []) .withOptions(env.KOGITO_RUNTIMES_BUILD_MVN_OPTS ? [ env.KOGITO_RUNTIMES_BUILD_MVN_OPTS ] : []) @@ -151,7 +155,7 @@ pipeline { configFileProvider([configFile(fileId: env.MAVEN_SETTINGS_CONFIG_FILE_ID, variable: 'MAVEN_SETTINGS_FILE')]){ mvnCmd .withSettingsXmlFile(MAVEN_SETTINGS_FILE) - .run('clean install') + .run("clean $installOrDeploy") } } } @@ -165,37 +169,6 @@ pipeline { } } } - stage('Deploy locally') { - steps { - script { - dir(getRepoName()) { - runMavenDeploy(true) - } - } - } - } - stage('Upload artifacts to given repository') { - when { - expression { return !isRelease() && shouldDeployToRepository() } - } - steps { - script { - // Deploy to specific repository with credentials - maven.uploadLocalArtifacts(env.MAVEN_REPO_CREDS_ID, getLocalDeploymentFolder(), getMavenRepoZipUrl()) - } - } - } - stage('Stage artifacts') { - when { - expression { return shouldStageArtifacts() } - } - steps { - script { - // Stage release artifacts - runMavenStage() - } - } - } stage('Create PR') { when { expression { return isRelease() || isCreatePr() } @@ -268,14 +241,6 @@ void sendNotification() { } } -boolean isSpecificArtifactsUpload() { - return env.MAVEN_DEPLOY_REPOSITORY && env.MAVEN_REPO_CREDS_ID -} - -boolean shouldStageArtifacts() { - return isRelease() -} - boolean shouldDeployToRepository() { return env.MAVEN_DEPLOY_REPOSITORY && env.MAVEN_REPO_CREDS_ID && getGitAuthor() == 'apache' } @@ -335,47 +300,6 @@ MavenCommand getMavenCommand(String directory = '') { .withProperty('full') } -void runMavenDeploy(boolean localDeployment = false) { - mvnCmd = getMavenCommand() - .withOptions(env.KOGITO_RUNTIMES_BUILD_MVN_OPTS ? [ env.KOGITO_RUNTIMES_BUILD_MVN_OPTS ] : []) - .withOptions(env.BUILD_MVN_OPTS_CURRENT ? [ env.BUILD_MVN_OPTS_CURRENT ] : []) - - if (localDeployment) { - mvnCmd.withLocalDeployFolder(getLocalDeploymentFolder()) - } else if (env.MAVEN_DEPLOY_REPOSITORY) { - mvnCmd.withDeployRepository(env.MAVEN_DEPLOY_REPOSITORY) - } - - configFileProvider([configFile(fileId: env.MAVEN_SETTINGS_CONFIG_FILE_ID, variable: 'MAVEN_SETTINGS_FILE')]){ - mvnCmd - .skipTests(true) - .withSettingsXmlFile(MAVEN_SETTINGS_FILE) - .run('clean deploy') - } -} - -String getMavenRepoZipUrl() { - return "${env.MAVEN_DEPLOY_REPOSITORY.replaceAll('/content/', '/service/local/').replaceFirst('/*$', '')}/content-compressed" -} - -void runMavenStage() { - configFileProvider([configFile(fileId: env.MAVEN_SETTINGS_CONFIG_FILE_ID, variable: 'MAVEN_SETTINGS_FILE')]){ - MavenStagingHelper stagingHelper = getStagingHelper(getMavenCommand().withSettingsXmlFile(MAVEN_SETTINGS_FILE)) - deployProperties.putAll(stagingHelper.stageLocalArtifacts(env.NEXUS_STAGING_PROFILE_ID, getLocalDeploymentFolder())) - stagingHelper.promoteStagingRepository(env.NEXUS_BUILD_PROMOTION_PROFILE_ID) - } -} - -MavenStagingHelper getStagingHelper(MavenCommand mavenCommand) { - return new MavenStagingHelper(this, mavenCommand) - .withNexusReleaseUrl(env.NEXUS_RELEASE_URL) - .withNexusReleaseRepositoryId(env.NEXUS_RELEASE_REPOSITORY_ID) -} - -String getLocalDeploymentFolder() { - return "${env.MAVEN_DEPLOY_LOCAL_DIR}/${getRepoName()}" -} - String getWorkflowCommonDeploymentPath() { return "${getRepoName()}/quarkus/extensions/kogito-quarkus-workflow-extension-common/kogito-quarkus-workflow-common-deployment" } diff --git a/.ci/jenkins/Jenkinsfile.weekly.deploy b/.ci/jenkins/Jenkinsfile.weekly.deploy index 24b98483652..e2c1b958862 100644 --- a/.ci/jenkins/Jenkinsfile.weekly.deploy +++ b/.ci/jenkins/Jenkinsfile.weekly.deploy @@ -101,10 +101,28 @@ pipeline { } } - stage('Build & Test & Deploy locally') { + stage('Build & Test & Install/Deploy') { steps { script { - runMavenLocalDeploy(params.SKIP_TESTS) + withCredentials([usernamePassword(credentialsId: env.MAVEN_REPO_CREDS_ID, usernameVariable: 'REPOSITORY_USER', passwordVariable: 'REPOSITORY_TOKEN')]) { + def installOrDeploy + if (shouldDeployToRepository()) { + installOrDeploy = "deploy -DdeployAtEnd -Dapache.repository.username=${REPOSITORY_USER} -Dapache.repository.password=${REPOSITORY_TOKEN} -DretryFailedDeploymentCount=5" + } else { + installOrDeploy = 'install' + } + def mvnCmd = getMavenCommand().withProperty('maven.test.failure.ignore', true) + .withOptions(env.BUILD_MVN_OPTS_CURRENT ? [ env.BUILD_MVN_OPTS_CURRENT ] : []) + .withOptions(env.KOGITO_RUNTIMES_BUILD_MVN_OPTS ? [ env.KOGITO_RUNTIMES_BUILD_MVN_OPTS ] : []) + if (params.SKIP_TESTS) { + mvnCmd.skipTests() // Conflict somehow with Python testing. If `skipTests={anyvalue}` is set, then exec plugin is not executed ... + } + configFileProvider([configFile(fileId: env.MAVEN_SETTINGS_CONFIG_FILE_ID, variable: 'MAVEN_SETTINGS_FILE')]){ + mvnCmd + .withSettingsXmlFile(MAVEN_SETTINGS_FILE) + .run("clean $installOrDeploy") + } + } } } post { @@ -117,28 +135,6 @@ pipeline { } } - stage('Upload artifacts to given repository') { - when { - expression { return shouldDeployToRepository() } - } - steps { - script { - withCredentials([usernamePassword(credentialsId: env.MAVEN_REPO_CREDS_ID, usernameVariable: 'REPOSITORY_USER', passwordVariable: 'REPOSITORY_TOKEN')]) { - configFileProvider([configFile(fileId: env.MAVEN_SETTINGS_CONFIG_FILE_ID, variable: 'MAVEN_SETTINGS_FILE')]) { - getMavenCommand() - .withSettingsXmlFile(MAVEN_SETTINGS_FILE) - .withProperty('wagon.source', "file://${getLocalDeploymentFolder()}") - .withProperty('wagon.target', env.MAVEN_DEPLOY_REPOSITORY) - .withProperty('wagon.targetId', 'apache-snapshots-repository') - .withProperty('apache.snapshot.repository.username', REPOSITORY_USER) - .withProperty('apache.snapshot.repository.password', REPOSITORY_TOKEN) - .run("org.codehaus.mojo:wagon-maven-plugin:2.0.2:merge-maven-repos") - } - } - } - } - } - stage('Create and push a new tag') { steps { script { @@ -237,20 +233,6 @@ MavenCommand getMavenCommand(String directory = '') { .withProperty('full') } -void runMavenLocalDeploy(boolean skipTests = true) { - mvnCmd = getMavenCommand() - mvnCmd.withLocalDeployFolder(getLocalDeploymentFolder()) - - configFileProvider([configFile(fileId: env.MAVEN_SETTINGS_CONFIG_FILE_ID, variable: 'MAVEN_SETTINGS_FILE')]){ - mvnCmd.withProperty('maven.test.failure.ignore', true) - .withOptions(env.BUILD_MVN_OPTS_CURRENT ? [ env.BUILD_MVN_OPTS_CURRENT ] : []) - .withOptions(env.KOGITO_RUNTIMES_BUILD_MVN_OPTS ? [ env.KOGITO_RUNTIMES_BUILD_MVN_OPTS ] : []) - //.skipTests(skipTests) // Conflict somehow with Python testing. If `skipTests={anyvalue}` is set, then exec plugin is not executed ... - .withSettingsXmlFile(MAVEN_SETTINGS_FILE) - .run('clean deploy') - } -} - String getLocalDeploymentFolder() { return "${env.MAVEN_DEPLOY_LOCAL_DIR}/${getRepoName()}" } diff --git a/.ci/jenkins/dsl/jobs.groovy b/.ci/jenkins/dsl/jobs.groovy index fce2201fab4..aba056af657 100644 --- a/.ci/jenkins/dsl/jobs.groovy +++ b/.ci/jenkins/dsl/jobs.groovy @@ -196,11 +196,6 @@ void setupReleaseDeployJob() { MAVEN_DEPENDENCIES_REPOSITORY: "${MAVEN_ARTIFACTS_REPOSITORY}", MAVEN_DEPLOY_REPOSITORY: "${MAVEN_ARTIFACTS_UPLOAD_REPOSITORY_URL}", MAVEN_REPO_CREDS_ID: "${MAVEN_ARTIFACTS_UPLOAD_REPOSITORY_CREDS_ID}", - - NEXUS_RELEASE_URL: "${MAVEN_NEXUS_RELEASE_URL}", - NEXUS_RELEASE_REPOSITORY_ID: "${MAVEN_NEXUS_RELEASE_REPOSITORY}", - NEXUS_STAGING_PROFILE_ID: "${MAVEN_NEXUS_STAGING_PROFILE_ID}", - NEXUS_BUILD_PROMOTION_PROFILE_ID: "${MAVEN_NEXUS_BUILD_PROMOTION_PROFILE_ID}", ]) KogitoJobTemplate.createPipelineJob(this, jobParams)?.with { parameters { From 030a82acf41f72f25b78392e0a12596f518a5ecc Mon Sep 17 00:00:00 2001 From: Ricardo Zanini <1538000+ricardozanini@users.noreply.github.com> Date: Wed, 22 May 2024 12:23:43 -0300 Subject: [PATCH 15/32] Fix kie-issues #1217 - Replace quay.io with docker.io (#3525) * Fix kie-issues #1217 - Replace quay.io with docker.io Signed-off-by: Ricardo Zanini * Replace outdated image with bananas :banana: Signed-off-by: Ricardo Zanini --------- Signed-off-by: Ricardo Zanini --- .ci/jenkins/Jenkinsfile.deploy | 2 +- .ci/jenkins/Jenkinsfile.setup-branch | 6 +++--- .../test/resources/deployment/deployment-no-service.yaml | 2 +- .../runtime/src/test/resources/deployment/deployment.yaml | 2 +- .../resources/deployment/pod-deployment-no-service.yaml | 4 ++-- .../deployment/replica-set-deployment-no-service.yaml | 2 +- .../deploymentConfig/deployment-config-no-service.yaml | 2 +- .../test/resources/deploymentConfig/deployment-config.yaml | 2 +- .../deploymentConfig/pod-deployment-config-no-service.yaml | 4 ++-- .../deploymentConfig/replication-controller-dc-no-svc.yaml | 4 ++-- .../test/resources/pod/pod-no-service-custom-port-name.yaml | 2 +- .../runtime/src/test/resources/pod/pod-no-service.yaml | 4 ++-- .../test/resources/statefulset/statefulset-no-service.yaml | 2 +- .../resources/statefulset/statefulset-pod-no-service.yaml | 4 ++-- .../runtime/src/test/resources/statefulset/statefulset.yaml | 2 +- .../deployment/src/main/resources/application.properties | 2 +- .../src/test/resources/application.properties | 2 +- .../kogito-quarkus-workflow-common-deployment/pom.xml | 2 +- 18 files changed, 25 insertions(+), 25 deletions(-) diff --git a/.ci/jenkins/Jenkinsfile.deploy b/.ci/jenkins/Jenkinsfile.deploy index 795ed5f8a15..316c7271cd6 100644 --- a/.ci/jenkins/Jenkinsfile.deploy +++ b/.ci/jenkins/Jenkinsfile.deploy @@ -305,5 +305,5 @@ String getWorkflowCommonDeploymentPath() { } String getDataIndexEphemeralReleaseImage() { - return "quay.io/kiegroup/kogito-data-index-ephemeral:${util.getMajorMinorVersion(getProjectVersion())}" + return "docker.io/apache/incubator-kie-kogito-data-index-ephemeral:${util.getMajorMinorVersion(getProjectVersion())}" } diff --git a/.ci/jenkins/Jenkinsfile.setup-branch b/.ci/jenkins/Jenkinsfile.setup-branch index 59e32b42f79..904887fa449 100644 --- a/.ci/jenkins/Jenkinsfile.setup-branch +++ b/.ci/jenkins/Jenkinsfile.setup-branch @@ -23,7 +23,7 @@ import org.jenkinsci.plugins.workflow.libs.Library import org.kie.jenkins.MavenCommand droolsRepo = 'incubator-kie-drools' -dataIndexEphemeralImageName = 'quay.io/kiegroup/kogito-data-index-ephemeral' +dataIndexEphemeralImageName = 'docker.io/apache/incubator-kie-kogito-data-index-ephemeral' pipeline { agent { @@ -213,11 +213,11 @@ String getWorkflowCommonDeploymentRelativePath() { String getDataIndexEphemeralImage() { if (isMainBranch()) { - return "${dataIndexEphemeralImageName}-nightly:latest" + return "${dataIndexEphemeralImageName}:main" } String version = getKogitoVersion() if (version.endsWith('-SNAPSHOT')) { - return "${dataIndexEphemeralImageName}-nightly:${util.getMajorMinorVersion(version)}" + return "${dataIndexEphemeralImageName}:${util.getMajorMinorVersion(version)}" } return "${dataIndexEphemeralImageName}:${util.getMajorMinorVersion(version)}" } diff --git a/quarkus/addons/fabric8-kubernetes-service-catalog/runtime/src/test/resources/deployment/deployment-no-service.yaml b/quarkus/addons/fabric8-kubernetes-service-catalog/runtime/src/test/resources/deployment/deployment-no-service.yaml index 7a12392bc74..8a81464caf9 100644 --- a/quarkus/addons/fabric8-kubernetes-service-catalog/runtime/src/test/resources/deployment/deployment-no-service.yaml +++ b/quarkus/addons/fabric8-kubernetes-service-catalog/runtime/src/test/resources/deployment/deployment-no-service.yaml @@ -36,7 +36,7 @@ spec: spec: containers: - name: example-deployment-no-service - image: quay.io/kiegroup/process-quarkus-example:latest + image: docker.io/namespace/bananas:latest imagePullPolicy: IfNotPresent ports: - containerPort: 8080 diff --git a/quarkus/addons/fabric8-kubernetes-service-catalog/runtime/src/test/resources/deployment/deployment.yaml b/quarkus/addons/fabric8-kubernetes-service-catalog/runtime/src/test/resources/deployment/deployment.yaml index 257ad459e28..7c082518188 100644 --- a/quarkus/addons/fabric8-kubernetes-service-catalog/runtime/src/test/resources/deployment/deployment.yaml +++ b/quarkus/addons/fabric8-kubernetes-service-catalog/runtime/src/test/resources/deployment/deployment.yaml @@ -35,7 +35,7 @@ spec: spec: containers: - name: example-deployment-with-service - image: quay.io/kiegroup/process-quarkus-example:latest + image: docker.io/namespace/bananas:latest imagePullPolicy: IfNotPresent ports: - containerPort: 8080 diff --git a/quarkus/addons/fabric8-kubernetes-service-catalog/runtime/src/test/resources/deployment/pod-deployment-no-service.yaml b/quarkus/addons/fabric8-kubernetes-service-catalog/runtime/src/test/resources/deployment/pod-deployment-no-service.yaml index d73c84577c8..cc712c87bcb 100644 --- a/quarkus/addons/fabric8-kubernetes-service-catalog/runtime/src/test/resources/deployment/pod-deployment-no-service.yaml +++ b/quarkus/addons/fabric8-kubernetes-service-catalog/runtime/src/test/resources/deployment/pod-deployment-no-service.yaml @@ -57,7 +57,7 @@ spec: defaultMode: 420 containers: - name: example-deployment-no-service - image: quay.io/kiegroup/process-quarkus-example:latest + image: docker.io/namespace/bananas:latest ports: - containerPort: 8080 protocol: TCP @@ -121,6 +121,6 @@ status: lastState: {} ready: true restartCount: 0 - image: quay.io/kiegroup/process-quarkus-example:latest + image: docker.io/namespace/bananas:latest started: true qosClass: BestEffort \ No newline at end of file diff --git a/quarkus/addons/fabric8-kubernetes-service-catalog/runtime/src/test/resources/deployment/replica-set-deployment-no-service.yaml b/quarkus/addons/fabric8-kubernetes-service-catalog/runtime/src/test/resources/deployment/replica-set-deployment-no-service.yaml index 7154aadfa81..98176f5fdf2 100644 --- a/quarkus/addons/fabric8-kubernetes-service-catalog/runtime/src/test/resources/deployment/replica-set-deployment-no-service.yaml +++ b/quarkus/addons/fabric8-kubernetes-service-catalog/runtime/src/test/resources/deployment/replica-set-deployment-no-service.yaml @@ -46,7 +46,7 @@ spec: spec: containers: - name: example-deployment-no-service - image: quay.io/kiegroup/process-quarkus-example:latest + image: docker.io/namespace/bananas:latest ports: - containerPort: 8080 protocol: TCP diff --git a/quarkus/addons/fabric8-kubernetes-service-catalog/runtime/src/test/resources/deploymentConfig/deployment-config-no-service.yaml b/quarkus/addons/fabric8-kubernetes-service-catalog/runtime/src/test/resources/deploymentConfig/deployment-config-no-service.yaml index 0c40e9631f9..e2d139a7cfe 100644 --- a/quarkus/addons/fabric8-kubernetes-service-catalog/runtime/src/test/resources/deploymentConfig/deployment-config-no-service.yaml +++ b/quarkus/addons/fabric8-kubernetes-service-catalog/runtime/src/test/resources/deploymentConfig/deployment-config-no-service.yaml @@ -34,7 +34,7 @@ spec: spec: containers: - name: example-dc-no-service - image: quay.io/kiegroup/process-quarkus-example:latest + image: docker.io/namespace/bananas:latest ports: - containerPort: 8080 name: web diff --git a/quarkus/addons/fabric8-kubernetes-service-catalog/runtime/src/test/resources/deploymentConfig/deployment-config.yaml b/quarkus/addons/fabric8-kubernetes-service-catalog/runtime/src/test/resources/deploymentConfig/deployment-config.yaml index 87160fe6565..d85881657f7 100644 --- a/quarkus/addons/fabric8-kubernetes-service-catalog/runtime/src/test/resources/deploymentConfig/deployment-config.yaml +++ b/quarkus/addons/fabric8-kubernetes-service-catalog/runtime/src/test/resources/deploymentConfig/deployment-config.yaml @@ -34,7 +34,7 @@ spec: spec: containers: - name: example-dc-with-service - image: quay.io/kiegroup/process-quarkus-example:latest + image: docker.io/namespace/bananas:latest ports: - containerPort: 8080 name: http diff --git a/quarkus/addons/fabric8-kubernetes-service-catalog/runtime/src/test/resources/deploymentConfig/pod-deployment-config-no-service.yaml b/quarkus/addons/fabric8-kubernetes-service-catalog/runtime/src/test/resources/deploymentConfig/pod-deployment-config-no-service.yaml index db0ccff0fcd..98ec421829b 100644 --- a/quarkus/addons/fabric8-kubernetes-service-catalog/runtime/src/test/resources/deploymentConfig/pod-deployment-config-no-service.yaml +++ b/quarkus/addons/fabric8-kubernetes-service-catalog/runtime/src/test/resources/deploymentConfig/pod-deployment-config-no-service.yaml @@ -81,7 +81,7 @@ spec: readOnly: true mountPath: /var/run/secrets/kubernetes.io/serviceaccount terminationMessagePolicy: File - image: 'quay.io/kiegroup/process-quarkus-example:latest' + image: 'docker.io/namespace/bananas:latest' serviceAccount: default volumes: - name: kube-api-access-mg9n9 @@ -149,5 +149,5 @@ status: state: running: startedAt: '2022-08-22T17:30:29Z' - image: 'quay.io/kiegroup/process-quarkus-example:latest' + image: 'docker.io/namespace/bananas:latest' qosClass: BestEffort diff --git a/quarkus/addons/fabric8-kubernetes-service-catalog/runtime/src/test/resources/deploymentConfig/replication-controller-dc-no-svc.yaml b/quarkus/addons/fabric8-kubernetes-service-catalog/runtime/src/test/resources/deploymentConfig/replication-controller-dc-no-svc.yaml index b4059d87fcc..9960f0eb253 100644 --- a/quarkus/addons/fabric8-kubernetes-service-catalog/runtime/src/test/resources/deploymentConfig/replication-controller-dc-no-svc.yaml +++ b/quarkus/addons/fabric8-kubernetes-service-catalog/runtime/src/test/resources/deploymentConfig/replication-controller-dc-no-svc.yaml @@ -26,7 +26,7 @@ metadata: openshift.io/deployment.status-reason: config change openshift.io/deployment.replicas: '1' openshift.io/encoded-deployment-config: > - {"kind":"DeploymentConfig","apiVersion":"apps.openshift.io/v1","metadata":{"name":"example-dc-no-service","namespace":"serverless-workflow-greeting-quarkus","uid":"a01d76e9-6b3a-48bf-8224-acb9de3c4ca0","resourceVersion":"1127454401","generation":1,"creationTimestamp":"2022-08-22T17:30:09Z","labels":{"app":"example-dc-no-service"},"managedFields":[{"manager":"Mozilla","operation":"Update","apiVersion":"apps.openshift.io/v1","time":"2022-08-22T17:30:09Z","fieldsType":"FieldsV1","fieldsV1":{"f:metadata":{"f:labels":{".":{},"f:app":{}}},"f:spec":{"f:replicas":{},"f:selector":{".":{},"f:app":{}},"f:strategy":{"f:activeDeadlineSeconds":{},"f:rollingParams":{".":{},"f:intervalSeconds":{},"f:maxSurge":{},"f:maxUnavailable":{},"f:timeoutSeconds":{},"f:updatePeriodSeconds":{}},"f:type":{}},"f:template":{".":{},"f:metadata":{".":{},"f:creationTimestamp":{},"f:labels":{".":{},"f:app":{}}},"f:spec":{".":{},"f:containers":{".":{},"k:{\"name\":\"example-dc-no-service\"}":{".":{},"f:image":{},"f:imagePullPolicy":{},"f:name":{},"f:ports":{".":{},"k:{\"containerPort\":8009,\"protocol\":\"TCP\"}":{".":{},"f:containerPort":{},"f:name":{},"f:protocol":{}},"k:{\"containerPort\":8080,\"protocol\":\"TCP\"}":{".":{},"f:containerPort":{},"f:name":{},"f:protocol":{}}},"f:resources":{},"f:terminationMessagePath":{},"f:terminationMessagePolicy":{}}},"f:dnsPolicy":{},"f:restartPolicy":{},"f:schedulerName":{},"f:securityContext":{},"f:terminationGracePeriodSeconds":{}}},"f:triggers":{}}}},{"manager":"openshift-controller-manager","operation":"Update","apiVersion":"apps.openshift.io/v1","time":"2022-08-22T17:30:09Z","fieldsType":"FieldsV1","fieldsV1":{"f:status":{"f:details":{".":{},"f:causes":{},"f:message":{}},"f:latestVersion":{}}},"subresource":"status"}]},"spec":{"strategy":{"type":"Rolling","rollingParams":{"updatePeriodSeconds":1,"intervalSeconds":1,"timeoutSeconds":600,"maxUnavailable":"25%","maxSurge":"25%"},"resources":{},"activeDeadlineSeconds":21600},"triggers":[{"type":"ConfigChange"}],"replicas":1,"revisionHistoryLimit":10,"test":false,"selector":{"app":"example-dc-no-service"},"template":{"metadata":{"creationTimestamp":null,"labels":{"app":"example-dc-no-service"}},"spec":{"containers":[{"name":"example-dc-no-service","image":"quay.io/kiegroup/process-quarkus-example:latest","ports":[{"name":"http","containerPort":8080,"protocol":"TCP"},{"name":"another-http","containerPort":8009,"protocol":"TCP"}],"resources":{},"terminationMessagePath":"/dev/termination-log","terminationMessagePolicy":"File","imagePullPolicy":"Always"}],"restartPolicy":"Always","terminationGracePeriodSeconds":30,"dnsPolicy":"ClusterFirst","securityContext":{},"schedulerName":"default-scheduler"}}},"status":{"latestVersion":1,"observedGeneration":0,"replicas":0,"updatedReplicas":0,"availableReplicas":0,"unavailableReplicas":0,"details":{"message":"config + {"kind":"DeploymentConfig","apiVersion":"apps.openshift.io/v1","metadata":{"name":"example-dc-no-service","namespace":"serverless-workflow-greeting-quarkus","uid":"a01d76e9-6b3a-48bf-8224-acb9de3c4ca0","resourceVersion":"1127454401","generation":1,"creationTimestamp":"2022-08-22T17:30:09Z","labels":{"app":"example-dc-no-service"},"managedFields":[{"manager":"Mozilla","operation":"Update","apiVersion":"apps.openshift.io/v1","time":"2022-08-22T17:30:09Z","fieldsType":"FieldsV1","fieldsV1":{"f:metadata":{"f:labels":{".":{},"f:app":{}}},"f:spec":{"f:replicas":{},"f:selector":{".":{},"f:app":{}},"f:strategy":{"f:activeDeadlineSeconds":{},"f:rollingParams":{".":{},"f:intervalSeconds":{},"f:maxSurge":{},"f:maxUnavailable":{},"f:timeoutSeconds":{},"f:updatePeriodSeconds":{}},"f:type":{}},"f:template":{".":{},"f:metadata":{".":{},"f:creationTimestamp":{},"f:labels":{".":{},"f:app":{}}},"f:spec":{".":{},"f:containers":{".":{},"k:{\"name\":\"example-dc-no-service\"}":{".":{},"f:image":{},"f:imagePullPolicy":{},"f:name":{},"f:ports":{".":{},"k:{\"containerPort\":8009,\"protocol\":\"TCP\"}":{".":{},"f:containerPort":{},"f:name":{},"f:protocol":{}},"k:{\"containerPort\":8080,\"protocol\":\"TCP\"}":{".":{},"f:containerPort":{},"f:name":{},"f:protocol":{}}},"f:resources":{},"f:terminationMessagePath":{},"f:terminationMessagePolicy":{}}},"f:dnsPolicy":{},"f:restartPolicy":{},"f:schedulerName":{},"f:securityContext":{},"f:terminationGracePeriodSeconds":{}}},"f:triggers":{}}}},{"manager":"openshift-controller-manager","operation":"Update","apiVersion":"apps.openshift.io/v1","time":"2022-08-22T17:30:09Z","fieldsType":"FieldsV1","fieldsV1":{"f:status":{"f:details":{".":{},"f:causes":{},"f:message":{}},"f:latestVersion":{}}},"subresource":"status"}]},"spec":{"strategy":{"type":"Rolling","rollingParams":{"updatePeriodSeconds":1,"intervalSeconds":1,"timeoutSeconds":600,"maxUnavailable":"25%","maxSurge":"25%"},"resources":{},"activeDeadlineSeconds":21600},"triggers":[{"type":"ConfigChange"}],"replicas":1,"revisionHistoryLimit":10,"test":false,"selector":{"app":"example-dc-no-service"},"template":{"metadata":{"creationTimestamp":null,"labels":{"app":"example-dc-no-service"}},"spec":{"containers":[{"name":"example-dc-no-service","image":"docker.io/namespace/bananas:latest","ports":[{"name":"http","containerPort":8080,"protocol":"TCP"},{"name":"another-http","containerPort":8009,"protocol":"TCP"}],"resources":{},"terminationMessagePath":"/dev/termination-log","terminationMessagePolicy":"File","imagePullPolicy":"Always"}],"restartPolicy":"Always","terminationGracePeriodSeconds":30,"dnsPolicy":"ClusterFirst","securityContext":{},"schedulerName":"default-scheduler"}}},"status":{"latestVersion":1,"observedGeneration":0,"replicas":0,"updatedReplicas":0,"availableReplicas":0,"unavailableReplicas":0,"details":{"message":"config change","causes":[{"type":"ConfigChange"}]}}} openshift.io/deployer-pod.name: example-dc-no-service-1-deploy resourceVersion: '1127455589' @@ -64,7 +64,7 @@ spec: spec: containers: - name: example-dc-no-service - image: 'quay.io/kiegroup/process-quarkus-example:latest' + image: 'docker.io/namespace/bananas:latest' ports: - name: http containerPort: 8080 diff --git a/quarkus/addons/fabric8-kubernetes-service-catalog/runtime/src/test/resources/pod/pod-no-service-custom-port-name.yaml b/quarkus/addons/fabric8-kubernetes-service-catalog/runtime/src/test/resources/pod/pod-no-service-custom-port-name.yaml index af8e9c0f1cf..5b655c94577 100644 --- a/quarkus/addons/fabric8-kubernetes-service-catalog/runtime/src/test/resources/pod/pod-no-service-custom-port-name.yaml +++ b/quarkus/addons/fabric8-kubernetes-service-catalog/runtime/src/test/resources/pod/pod-no-service-custom-port-name.yaml @@ -26,7 +26,7 @@ metadata: spec: containers: - name: pod-no-service-custom-port - image: quay.io/kiegroup/process-quarkus-example:latest + image: docker.io/namespace/bananas:latest imagePullPolicy: Never ports: - name: http diff --git a/quarkus/addons/fabric8-kubernetes-service-catalog/runtime/src/test/resources/pod/pod-no-service.yaml b/quarkus/addons/fabric8-kubernetes-service-catalog/runtime/src/test/resources/pod/pod-no-service.yaml index 9b7ec8882d8..9addea7e0fb 100644 --- a/quarkus/addons/fabric8-kubernetes-service-catalog/runtime/src/test/resources/pod/pod-no-service.yaml +++ b/quarkus/addons/fabric8-kubernetes-service-catalog/runtime/src/test/resources/pod/pod-no-service.yaml @@ -26,7 +26,7 @@ metadata: spec: containers: - name: process-quarkus-example-pod-no-service - image: quay.io/kiegroup/process-quarkus-example:latest + image: docker.io/namespace/bananas:latest imagePullPolicy: Never ports: - name: http @@ -64,5 +64,5 @@ status: lastState: {} ready: true restartCount: 0 - image: quay.io/kiegroup/process-quarkus-example:latest + image: docker.io/namespace/bananas:latest started: true \ No newline at end of file diff --git a/quarkus/addons/fabric8-kubernetes-service-catalog/runtime/src/test/resources/statefulset/statefulset-no-service.yaml b/quarkus/addons/fabric8-kubernetes-service-catalog/runtime/src/test/resources/statefulset/statefulset-no-service.yaml index 1e2e930fb8f..93e089a2e24 100644 --- a/quarkus/addons/fabric8-kubernetes-service-catalog/runtime/src/test/resources/statefulset/statefulset-no-service.yaml +++ b/quarkus/addons/fabric8-kubernetes-service-catalog/runtime/src/test/resources/statefulset/statefulset-no-service.yaml @@ -36,7 +36,7 @@ spec: spec: containers: - name: process-quarkus-example-statefulset-no-service - image: quay.io/kiegroup/process-quarkus-example:latest + image: docker.io/namespace/bananas:latest ports: - containerPort: 8080 name: http diff --git a/quarkus/addons/fabric8-kubernetes-service-catalog/runtime/src/test/resources/statefulset/statefulset-pod-no-service.yaml b/quarkus/addons/fabric8-kubernetes-service-catalog/runtime/src/test/resources/statefulset/statefulset-pod-no-service.yaml index 54af981bd08..1e1e0959534 100644 --- a/quarkus/addons/fabric8-kubernetes-service-catalog/runtime/src/test/resources/statefulset/statefulset-pod-no-service.yaml +++ b/quarkus/addons/fabric8-kubernetes-service-catalog/runtime/src/test/resources/statefulset/statefulset-pod-no-service.yaml @@ -59,7 +59,7 @@ spec: defaultMode: 420 containers: - name: example-statefulset-without-service - image: quay.io/kiegroup/process-quarkus-example:latest + image: docker.io/namespace/bananas:latest ports: - name: http containerPort: 8080 @@ -126,6 +126,6 @@ status: lastState: {} ready: true restartCount: 0 - image: quay.io/kiegroup/process-quarkus-example:latest + image: docker.io/namespace/bananas:latest started: true qosClass: BestEffort \ No newline at end of file diff --git a/quarkus/addons/fabric8-kubernetes-service-catalog/runtime/src/test/resources/statefulset/statefulset.yaml b/quarkus/addons/fabric8-kubernetes-service-catalog/runtime/src/test/resources/statefulset/statefulset.yaml index a05be4f7e17..97c862db52c 100644 --- a/quarkus/addons/fabric8-kubernetes-service-catalog/runtime/src/test/resources/statefulset/statefulset.yaml +++ b/quarkus/addons/fabric8-kubernetes-service-catalog/runtime/src/test/resources/statefulset/statefulset.yaml @@ -36,7 +36,7 @@ spec: spec: containers: - name: example-statefulset-with-service - image: quay.io/kiegroup/process-quarkus-example:latest + image: docker.io/namespace/bananas:latest imagePullPolicy: IfNotPresent ports: - containerPort: 8080 diff --git a/quarkus/addons/tracing-decision/deployment/src/main/resources/application.properties b/quarkus/addons/tracing-decision/deployment/src/main/resources/application.properties index c9560946f85..f066e175897 100644 --- a/quarkus/addons/tracing-decision/deployment/src/main/resources/application.properties +++ b/quarkus/addons/tracing-decision/deployment/src/main/resources/application.properties @@ -17,4 +17,4 @@ # under the License. # -quarkus.kogito.dev-services-trusty.image-name=quay.io/kiegroup/kogito-trusty-postgresql:${version.org.kie.kogito.trusty-service-postgresql} +quarkus.kogito.dev-services-trusty.image-name=docker.io/apache/incubator-kie-kogito-trusty-postgresql:${version.org.kie.kogito.trusty-service-postgresql} diff --git a/quarkus/addons/tracing-decision/integration-tests/src/test/resources/application.properties b/quarkus/addons/tracing-decision/integration-tests/src/test/resources/application.properties index 8a21528aabd..2483412d5da 100644 --- a/quarkus/addons/tracing-decision/integration-tests/src/test/resources/application.properties +++ b/quarkus/addons/tracing-decision/integration-tests/src/test/resources/application.properties @@ -31,6 +31,6 @@ mp.messaging.outgoing.kogito-tracing-model.topic=kogito-tracing-model mp.messaging.outgoing.kogito-tracing-model.value.serializer=org.apache.kafka.common.serialization.StringSerializer mp.messaging.outgoing.kogito-tracing-model.auto.offset.reset=earliest -quarkus.kogito.dev-services-trusty.image-name=quay.io/kiegroup/kogito-trusty-postgresql:latest +quarkus.kogito.dev-services-trusty.image-name=docker.io/apache/incubator-kie-kogito-trusty-postgresql:latest #quarkus.kogito.dev-services-trusty.image-name=org.kie.kogito/trusty-service-postgresql:2.0.0-SNAPSHOT quarkus.kogito.dev-services-trusty.port-used-by-test=-1 diff --git a/quarkus/extensions/kogito-quarkus-workflow-extension-common/kogito-quarkus-workflow-common-deployment/pom.xml b/quarkus/extensions/kogito-quarkus-workflow-extension-common/kogito-quarkus-workflow-common-deployment/pom.xml index 02057a9fa6d..a215a838e84 100644 --- a/quarkus/extensions/kogito-quarkus-workflow-extension-common/kogito-quarkus-workflow-common-deployment/pom.xml +++ b/quarkus/extensions/kogito-quarkus-workflow-extension-common/kogito-quarkus-workflow-common-deployment/pom.xml @@ -33,7 +33,7 @@ Kogito :: Quarkus Workflow Extension Common :: Deployment - quay.io/kiegroup/kogito-data-index-ephemeral-nightly:latest + docker.io/apache/incubator-kie-kogito-data-index-ephemeral:main org.kie.kogito.quarkus.workflow.deployment From edbfc64ee63b97948c19fe70aa8c75649a544d8d Mon Sep 17 00:00:00 2001 From: Jan Stastny Date: Wed, 22 May 2024 17:57:45 +0200 Subject: [PATCH 16/32] kie-issues#1237: stay on x.y.999-SNAPSHOT in release branches (#3527) Co-authored-by: jstastny-cz --- .ci/jenkins/Jenkinsfile.setup-branch | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/.ci/jenkins/Jenkinsfile.setup-branch b/.ci/jenkins/Jenkinsfile.setup-branch index 904887fa449..30b87417ec1 100644 --- a/.ci/jenkins/Jenkinsfile.setup-branch +++ b/.ci/jenkins/Jenkinsfile.setup-branch @@ -53,7 +53,7 @@ pipeline { currentBuild.displayName = params.DISPLAY_NAME } - checkoutRepo(droolsRepo, getDroolsTargetBranch()) + checkoutRepo(droolsRepo, getBuildBranch()) checkoutRepo(getRepoName(), getBuildBranch()) } } @@ -151,18 +151,6 @@ void checkoutRepo(String repository, String branch) { } } -String getDroolsTargetBranch() { - String targetBranch = getBuildBranch() - List versionSplit = targetBranch.split("\\.") as List - - if (versionSplit[0].isNumber()) { - targetBranch = "${Integer.parseInt(versionSplit[0]) + 7}.${versionSplit.tail().join('.')}" - } else { - echo "Cannot parse targetBranch as release branch so going further with current value: ${targetBranch}" - } - return targetBranch -} - String getRepoName() { return env.REPO_NAME } From 1267dffd89f5b642bc4f06e295aa4bd09503640d Mon Sep 17 00:00:00 2001 From: Tiago Bento <1584568+tiagobento@users.noreply.github.com> Date: Thu, 23 May 2024 13:45:45 -0400 Subject: [PATCH 17/32] kie-issues#1252: Configure tagVersion programmatically for `data-index-ephemeral` image. (#3529) * New property to configure only the tagVersion * Change CI --- .ci/jenkins/Jenkinsfile.setup-branch | 14 +++++--------- .../pom.xml | 3 ++- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/.ci/jenkins/Jenkinsfile.setup-branch b/.ci/jenkins/Jenkinsfile.setup-branch index 30b87417ec1..9a4357bca83 100644 --- a/.ci/jenkins/Jenkinsfile.setup-branch +++ b/.ci/jenkins/Jenkinsfile.setup-branch @@ -23,7 +23,6 @@ import org.jenkinsci.plugins.workflow.libs.Library import org.kie.jenkins.MavenCommand droolsRepo = 'incubator-kie-drools' -dataIndexEphemeralImageName = 'docker.io/apache/incubator-kie-kogito-data-index-ephemeral' pipeline { agent { @@ -98,8 +97,8 @@ pipeline { getMavenCommand(getRepoName()) .withOptions(['-pl :kogito-quarkus-workflow-common-deployment']) .withSettingsXmlFile(MAVEN_SETTINGS_FILE), - 'data-index-ephemeral.image', - getDataIndexEphemeralImage() + 'data-index-ephemeral.image.tagVersion', + getDataIndexEphemeralImageTagVersion() ) } } @@ -199,13 +198,10 @@ String getWorkflowCommonDeploymentRelativePath() { return 'quarkus/extensions/kogito-quarkus-workflow-extension-common/kogito-quarkus-workflow-common-deployment' } -String getDataIndexEphemeralImage() { - if (isMainBranch()) { - return "${dataIndexEphemeralImageName}:main" - } +String getDataIndexEphemeralImageTagVersion() { String version = getKogitoVersion() if (version.endsWith('-SNAPSHOT')) { - return "${dataIndexEphemeralImageName}:${util.getMajorMinorVersion(version)}" + return getBuildBranch() // E.g., `main` or `10.0.x` } - return "${dataIndexEphemeralImageName}:${util.getMajorMinorVersion(version)}" + return util.getMajorMinorVersion(version) // E.g., `10.0` } diff --git a/quarkus/extensions/kogito-quarkus-workflow-extension-common/kogito-quarkus-workflow-common-deployment/pom.xml b/quarkus/extensions/kogito-quarkus-workflow-extension-common/kogito-quarkus-workflow-common-deployment/pom.xml index a215a838e84..cf9e3b9ea6d 100644 --- a/quarkus/extensions/kogito-quarkus-workflow-extension-common/kogito-quarkus-workflow-common-deployment/pom.xml +++ b/quarkus/extensions/kogito-quarkus-workflow-extension-common/kogito-quarkus-workflow-common-deployment/pom.xml @@ -33,7 +33,8 @@ Kogito :: Quarkus Workflow Extension Common :: Deployment - docker.io/apache/incubator-kie-kogito-data-index-ephemeral:main + main + docker.io/apache/incubator-kie-kogito-data-index-ephemeral:${data-index-ephemeral.image.tagVersion} org.kie.kogito.quarkus.workflow.deployment From 7f04f1f2230bb2a14eac3cdaaec572ca3efe406a Mon Sep 17 00:00:00 2001 From: Gabriele Cardosi Date: Thu, 23 May 2024 20:40:10 +0200 Subject: [PATCH 18/32] [disabling_tracing-decision_module] Removing tracing-decision module from maven reactor (#3531) * [disabling_tracing-decision_module] Removing tracing-decision module from maven reactor * [disabling_tracing-decision_module] Removing tracing-decision devservices --------- Co-authored-by: Gabriele-Cardosi --- quarkus/addons/tracing-decision/pom.xml | 2 -- 1 file changed, 2 deletions(-) diff --git a/quarkus/addons/tracing-decision/pom.xml b/quarkus/addons/tracing-decision/pom.xml index 7376a6ec7a1..26d2c5ca2e7 100644 --- a/quarkus/addons/tracing-decision/pom.xml +++ b/quarkus/addons/tracing-decision/pom.xml @@ -34,9 +34,7 @@ pom - deployment runtime - integration-tests \ No newline at end of file From a4e53450c90c3b834a31d30e2745c7248a198114 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tibor=20Zim=C3=A1nyi?= Date: Fri, 24 May 2024 11:27:26 +0200 Subject: [PATCH 19/32] [NO-ISSUE] Use apache-release profile when doing a release build (#3530) * Add apache-release profile to release builds. * Override javadoc version. * Fix JavaDoc build. * Add password to gpg signing setup. * Add GPG password to signing command * Run from within withCredentials block for release. --- .ci/jenkins/Jenkinsfile.deploy | 29 ++++++++++++++++--- .../kogito-build-no-bom-parent/pom.xml | 10 +++++++ pom.xml | 1 + 3 files changed, 36 insertions(+), 4 deletions(-) diff --git a/.ci/jenkins/Jenkinsfile.deploy b/.ci/jenkins/Jenkinsfile.deploy index 316c7271cd6..d71a8ee87c1 100644 --- a/.ci/jenkins/Jenkinsfile.deploy +++ b/.ci/jenkins/Jenkinsfile.deploy @@ -152,11 +152,32 @@ pipeline { if (params.SKIP_TESTS) { mvnCmd.skipTests() // Conflict somehow with Python testing. If `skipTests={anyvalue}` is set, then exec plugin is not executed ... } - configFileProvider([configFile(fileId: env.MAVEN_SETTINGS_CONFIG_FILE_ID, variable: 'MAVEN_SETTINGS_FILE')]){ - mvnCmd - .withSettingsXmlFile(MAVEN_SETTINGS_FILE) - .run("clean $installOrDeploy") + if (isRelease()) { + withCredentials([file(credentialsId: 'asf-release-gpg-signing-key', variable: 'SIGNING_KEY')]) { + withCredentials([file(credentialsId: 'asf-release-gpg-signing-key-password', variable: 'SIGNING_KEY_PASSWORD')]) { + // copy the key to singkey.gpg file in *plain text* so we can import it + sh ('cat $SIGNING_KEY > $WORKSPACE/signkey.gpg') + // Please do not remove list keys command. When gpg is run for the first time, it may initialize some internals. + sh ('gpg --list-keys') + sh ("gpg --batch --pinentry-mode=loopback --passphrase \"${SIGNING_KEY_PASSWORD}\" --import signkey.gpg") + sh ('rm $WORKSPACE/signkey.gpg') + + mvnCmd.withProperty('gpg.passphrase', SIGNING_KEY_PASSWORD) + .withProfiles(['apache-release']) + + configFileProvider([configFile(fileId: env.MAVEN_SETTINGS_CONFIG_FILE_ID, variable: 'MAVEN_SETTINGS_FILE')]){ + mvnCmd.withSettingsXmlFile(MAVEN_SETTINGS_FILE) + .run("clean $installOrDeploy") + } + } + } + } else { + configFileProvider([configFile(fileId: env.MAVEN_SETTINGS_CONFIG_FILE_ID, variable: 'MAVEN_SETTINGS_FILE')]){ + mvnCmd.withSettingsXmlFile(MAVEN_SETTINGS_FILE) + .run("clean $installOrDeploy") + } } + } } } diff --git a/kogito-build/kogito-build-no-bom-parent/pom.xml b/kogito-build/kogito-build-no-bom-parent/pom.xml index 3be39d19722..8b3101c356f 100644 --- a/kogito-build/kogito-build-no-bom-parent/pom.xml +++ b/kogito-build/kogito-build-no-bom-parent/pom.xml @@ -661,6 +661,16 @@ + + org.apache.maven.plugins + maven-javadoc-plugin + ${version.maven-javadoc-plugin} + + true + none + true + + diff --git a/pom.xml b/pom.xml index 039cb0f1460..d4a05d4f29f 100644 --- a/pom.xml +++ b/pom.xml @@ -101,6 +101,7 @@ 2024-01-16T00:00:00Z 3.4.1 0.16.1 + 3.6.2 From f8c8f2ef12b47f3d0d0ed97e2f94d71e4910ab93 Mon Sep 17 00:00:00 2001 From: Francisco Javier Tirado Sarti <65240126+fjtirado@users.noreply.github.com> Date: Mon, 27 May 2024 12:28:50 +0200 Subject: [PATCH 20/32] [Fix #3524] Use timeout per Event state, not per Event type (#3528) --- .../handlers/CompositeContextNodeHandler.java | 1 - .../parser/handlers/EventHandler.java | 58 ++++++------------- .../parser/handlers/ForEachStateHandler.java | 1 + .../parser/handlers/OperationHandler.java | 5 +- .../parser/handlers/ParallelHandler.java | 1 + 5 files changed, 23 insertions(+), 43 deletions(-) diff --git a/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/parser/handlers/CompositeContextNodeHandler.java b/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/parser/handlers/CompositeContextNodeHandler.java index 052b720f406..c4341e399ae 100644 --- a/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/parser/handlers/CompositeContextNodeHandler.java +++ b/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/parser/handlers/CompositeContextNodeHandler.java @@ -83,7 +83,6 @@ protected final CompositeContextNodeFactory makeCompositeNode(RuleFlowNodeCon } else { connect(embeddedSubProcess.startNode(parserContext.newId()).name("EmbeddedStart"), embeddedSubProcess.endNode(parserContext.newId()).name("EmbeddedEnd").terminate(true)).done(); } - handleErrors(parserContext.factory(), embeddedSubProcess); return embeddedSubProcess; } diff --git a/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/parser/handlers/EventHandler.java b/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/parser/handlers/EventHandler.java index 0a9c385b331..9ccecb22a79 100644 --- a/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/parser/handlers/EventHandler.java +++ b/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/parser/handlers/EventHandler.java @@ -33,14 +33,10 @@ import org.kie.kogito.serverless.workflow.parser.ServerlessWorkflowParser; import io.serverlessworkflow.api.Workflow; -import io.serverlessworkflow.api.actions.Action; import io.serverlessworkflow.api.events.OnEvents; import io.serverlessworkflow.api.states.EventState; -import static org.kie.kogito.serverless.workflow.parser.handlers.NodeFactoryUtils.eventBasedSplitNode; -import static org.kie.kogito.serverless.workflow.parser.handlers.NodeFactoryUtils.joinExclusiveNode; import static org.kie.kogito.serverless.workflow.parser.handlers.NodeFactoryUtils.startMessageNode; -import static org.kie.kogito.serverless.workflow.utils.TimeoutsConfigResolver.resolveEventTimeout; public class EventHandler extends CompositeContextNodeHandler { @@ -53,47 +49,27 @@ public void handleStart() { // disable standard procedure } - @Override public MakeNodeResult makeNode(RuleFlowNodeContainerFactory factory) { - return joinNodes(factory, state.getOnEvents(), this::processOnEvent); - } - - private MakeNodeResult processOnEvent(RuleFlowNodeContainerFactory factory, OnEvents onEvent) { if (isStartState) { - MakeNodeResult result = joinNodes(factory, - onEvent.getEventRefs(), (fact, onEventRef) -> filterAndMergeNode(fact, onEvent.getEventDataFilter(), ServerlessWorkflowParser.DEFAULT_WORKFLOW_VAR, - (f, inputVar, outputVar) -> buildEventNode(f, onEventRef, inputVar, outputVar))); - CompositeContextNodeFactory embeddedSubProcess = handleActions(makeCompositeNode(factory), onEvent.getActions()); - connect(result.getOutgoingNode(), embeddedSubProcess); - return new MakeNodeResult(result.getIncomingNode(), embeddedSubProcess); + return joinNodes(factory, state.getOnEvents(), this::processOnEvent); } else { - String varName = getVarName(); - CompositeContextNodeFactory embeddedSubProcess = makeCompositeNode(factory); - NodeFactory startNode = embeddedSubProcess.startNode(parserContext.newId()).name("EmbeddedStart"); - JoinFactory joinNode = null; - String eventTimeout = resolveEventTimeout(state, workflow); - if (eventTimeout != null) { - // creating a split-join branch for the timer - SplitFactory splitNode = eventBasedSplitNode(embeddedSubProcess.splitNode(parserContext.newId()), Split.TYPE_XAND); - joinNode = joinExclusiveNode(embeddedSubProcess.joinNode(parserContext.newId())); - startNode = connect(startNode, splitNode); - createTimerNode(embeddedSubProcess, splitNode, joinNode, eventTimeout); - } - MakeNodeResult result = joinNodes(embeddedSubProcess, - onEvent.getEventRefs(), (fact, onEventRef) -> filterAndMergeNode(fact, onEvent.getEventDataFilter(), varName, - (f, inputVar, outputVar) -> buildEventNode(f, onEventRef, inputVar, outputVar))); - connect(startNode, result.getIncomingNode()); - NodeFactory currentNode = result.getOutgoingNode(); - for (Action action : onEvent.getActions()) { - currentNode = connect(currentNode, getActionNode(embeddedSubProcess, action, varName, true)); - } - if (joinNode != null) { - currentNode = connect(currentNode, joinNode); - } - connect(currentNode, embeddedSubProcess.endNode(parserContext.newId()).name("EmbeddedEnd").terminate(true)).done(); - handleErrors(parserContext.factory(), embeddedSubProcess); - return new MakeNodeResult(embeddedSubProcess); + CompositeContextNodeFactory embeddedContainer = makeCompositeNode(factory); + connect(connect(embeddedContainer.startNode(parserContext.newId()).name("EmbeddedStart"), + makeTimeoutNode(embeddedContainer, joinNodes(embeddedContainer, state.getOnEvents(), this::processOnEvent))), + embeddedContainer.endNode(parserContext.newId()).name("EmbeddedEnd").terminate(true)).done(); + handleErrors(factory, embeddedContainer); + return new MakeNodeResult(embeddedContainer); } + + } + + private MakeNodeResult processOnEvent(RuleFlowNodeContainerFactory factory, OnEvents onEvent) { + MakeNodeResult result = joinNodes(factory, + onEvent.getEventRefs(), (fact, onEventRef) -> filterAndMergeNode(fact, onEvent.getEventDataFilter(), isStartState ? ServerlessWorkflowParser.DEFAULT_WORKFLOW_VAR : getVarName(), + (f, inputVar, outputVar) -> buildEventNode(f, onEventRef, inputVar, outputVar))); + CompositeContextNodeFactory embeddedSubProcess = handleActions(makeCompositeNode(factory), onEvent.getActions()); + connect(result.getOutgoingNode(), embeddedSubProcess); + return new MakeNodeResult(result.getIncomingNode(), embeddedSubProcess); } private MakeNodeResult joinNodes(RuleFlowNodeContainerFactory factory, List events, BiFunction, T, MakeNodeResult> function) { diff --git a/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/parser/handlers/ForEachStateHandler.java b/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/parser/handlers/ForEachStateHandler.java index b9fab37eeac..d76cbee7f37 100644 --- a/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/parser/handlers/ForEachStateHandler.java +++ b/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/parser/handlers/ForEachStateHandler.java @@ -54,6 +54,7 @@ protected MakeNodeResult makeNode(RuleFlowNodeContainerFactory factory) { result.completionAction(new CollectorActionSupplier(workflow.getExpressionLang(), state.getOutputCollection(), DEFAULT_WORKFLOW_VAR, TEMP_OUTPUT_VAR)); } handleActions(result, state.getActions(), FOR_EACH_OUTPUT_VARIABLE, false); + handleErrors(factory, result); return new MakeNodeResult(result); } diff --git a/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/parser/handlers/OperationHandler.java b/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/parser/handlers/OperationHandler.java index 1ea49f22c7f..af278271e8c 100644 --- a/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/parser/handlers/OperationHandler.java +++ b/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/parser/handlers/OperationHandler.java @@ -19,6 +19,7 @@ package org.kie.kogito.serverless.workflow.parser.handlers; import org.jbpm.ruleflow.core.RuleFlowNodeContainerFactory; +import org.jbpm.ruleflow.core.factory.CompositeContextNodeFactory; import org.kie.kogito.serverless.workflow.parser.ParserContext; import io.serverlessworkflow.api.Workflow; @@ -37,6 +38,8 @@ public boolean usedForCompensation() { @Override public MakeNodeResult makeNode(RuleFlowNodeContainerFactory factory) { - return new MakeNodeResult(handleActions(makeCompositeNode(factory), state.getActions())); + CompositeContextNodeFactory embeddedContainer = handleActions(makeCompositeNode(factory), state.getActions()); + handleErrors(parserContext.factory(), embeddedContainer); + return new MakeNodeResult(embeddedContainer); } } diff --git a/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/parser/handlers/ParallelHandler.java b/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/parser/handlers/ParallelHandler.java index 044824aedaa..db07cbdf220 100644 --- a/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/parser/handlers/ParallelHandler.java +++ b/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/parser/handlers/ParallelHandler.java @@ -66,6 +66,7 @@ public MakeNodeResult makeNode(RuleFlowNodeContainerFactory factory) { for (Branch branch : state.getBranches()) { currentBranch = branch; CompositeContextNodeFactory embeddedSubProcess = handleActions(makeCompositeNode(factory, getName(branch)), branch.getActions()); + handleErrors(factory, embeddedSubProcess); WorkflowElementIdentifier branchId = embeddedSubProcess.getNode().getId(); embeddedSubProcess.done().connection(nodeFactory.getNode().getId(), branchId).connection(branchId, connectionNode.getNode().getId()); } From ae2264766402f0aa9e8eab24fef3a526a5dc9d14 Mon Sep 17 00:00:00 2001 From: Enrique Date: Tue, 28 May 2024 10:40:53 +0200 Subject: [PATCH 21/32] [incubator-kie-issues-1204] Add built in support for org.w3c.dom.Document (#3518) * [incubator-kie-issues-1204] Add built in support for org.w3c.dom.Document --- .../impl/coverter/DocumentConverter.java | 39 + .../impl/coverter/DocumentUnconverter.java | 46 + .../impl/coverter/TypeConverterRegistry.java | 3 + jbpm/process-serialization-protobuf/pom.xml | 25 +- .../ObjectMarshallerStrategyHelper.java | 41 + .../ProcessInstanceMarshallerService.java | 5 +- ...ProtobufDocumentNodeMessageMarshaller.java | 83 ++ .../KogitoNodeInstanceContentsProtobuf.java | 782 +++++++++-- .../KogitoProcessInstanceProtobuf.java | 91 +- .../protobuf/KogitoTypesProtobuf.java | 1202 +++++++++++++++-- .../protobuf/KogitoWorkItemsProtobuf.java | 601 +++++++-- ...low.serialization.ObjectMarshallerStrategy | 1 + .../serialization/protobuf/kogito_types.proto | 4 + .../ProcessInstanceMarshallTest.java | 71 +- .../proto/AbstractProtoGenerator.java | 107 +- .../persistence/proto/ProtoGenerator.java | 79 +- .../proto/ReflectionProtoGenerator.java | 116 +- .../deployment/JandexProtoGenerator.java | 30 +- 18 files changed, 2783 insertions(+), 543 deletions(-) create mode 100644 jbpm/jbpm-flow/src/main/java/org/jbpm/process/core/datatype/impl/coverter/DocumentConverter.java create mode 100644 jbpm/jbpm-flow/src/main/java/org/jbpm/process/core/datatype/impl/coverter/DocumentUnconverter.java create mode 100644 jbpm/process-serialization-protobuf/src/main/java/org/jbpm/flow/serialization/ObjectMarshallerStrategyHelper.java create mode 100644 jbpm/process-serialization-protobuf/src/main/java/org/jbpm/flow/serialization/impl/marshallers/ProtobufDocumentNodeMessageMarshaller.java diff --git a/jbpm/jbpm-flow/src/main/java/org/jbpm/process/core/datatype/impl/coverter/DocumentConverter.java b/jbpm/jbpm-flow/src/main/java/org/jbpm/process/core/datatype/impl/coverter/DocumentConverter.java new file mode 100644 index 00000000000..eebe8bd9c20 --- /dev/null +++ b/jbpm/jbpm-flow/src/main/java/org/jbpm/process/core/datatype/impl/coverter/DocumentConverter.java @@ -0,0 +1,39 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.jbpm.process.core.datatype.impl.coverter; + +import java.util.function.Function; + +import javax.xml.parsers.DocumentBuilderFactory; + +public class DocumentConverter implements Function { + + @Override + public Object apply(String xml) { + try { + DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); + factory.setExpandEntityReferences(false); + factory.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false); + return factory.newDocumentBuilder().parse(xml); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + +} diff --git a/jbpm/jbpm-flow/src/main/java/org/jbpm/process/core/datatype/impl/coverter/DocumentUnconverter.java b/jbpm/jbpm-flow/src/main/java/org/jbpm/process/core/datatype/impl/coverter/DocumentUnconverter.java new file mode 100644 index 00000000000..5160d61632a --- /dev/null +++ b/jbpm/jbpm-flow/src/main/java/org/jbpm/process/core/datatype/impl/coverter/DocumentUnconverter.java @@ -0,0 +1,46 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.jbpm.process.core.datatype.impl.coverter; + +import java.io.StringWriter; +import java.util.function.Function; + +import javax.xml.transform.Transformer; +import javax.xml.transform.TransformerFactory; +import javax.xml.transform.dom.DOMSource; +import javax.xml.transform.stream.StreamResult; + +import org.w3c.dom.Document; + +public class DocumentUnconverter implements Function { + + @Override + public String apply(Document document) { + try { + TransformerFactory tf = TransformerFactory.newInstance(); + Transformer trans = tf.newTransformer(); + StringWriter sw = new StringWriter(); + trans.transform(new DOMSource(document), new StreamResult(sw)); + return sw.toString(); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + +} diff --git a/jbpm/jbpm-flow/src/main/java/org/jbpm/process/core/datatype/impl/coverter/TypeConverterRegistry.java b/jbpm/jbpm-flow/src/main/java/org/jbpm/process/core/datatype/impl/coverter/TypeConverterRegistry.java index c4dd61705e0..3d022cfa681 100644 --- a/jbpm/jbpm-flow/src/main/java/org/jbpm/process/core/datatype/impl/coverter/TypeConverterRegistry.java +++ b/jbpm/jbpm-flow/src/main/java/org/jbpm/process/core/datatype/impl/coverter/TypeConverterRegistry.java @@ -28,6 +28,7 @@ import org.kie.kogito.jackson.utils.JsonNodeConverter; import org.kie.kogito.jackson.utils.ObjectMapperFactory; import org.kie.kogito.jackson.utils.StringConverter; +import org.w3c.dom.Document; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.module.SimpleModule; @@ -43,7 +44,9 @@ public class TypeConverterRegistry { private TypeConverterRegistry() { converters.put(Date.class.getName(), new DateTypeConverter()); converters.put(JsonNode.class.getName(), new JsonNodeConverter(ObjectMapperFactory::listenerAware)); + converters.put(Document.class.getName(), new DocumentConverter()); unconverters.put(JsonNode.class.getName(), new StringConverter()); + unconverters.put(Document.class.getName(), new DocumentUnconverter()); addJacksonPair(Variable.class, Map.class); } diff --git a/jbpm/process-serialization-protobuf/pom.xml b/jbpm/process-serialization-protobuf/pom.xml index 647da48aeb1..1348ef50642 100644 --- a/jbpm/process-serialization-protobuf/pom.xml +++ b/jbpm/process-serialization-protobuf/pom.xml @@ -105,7 +105,21 @@ assertj-core test - + + com.sun.xml.bind + jaxb-core + test + + + org.glassfish.jaxb + jaxb-runtime + test + + + org.xmlunit + xmlunit-core + test + @@ -144,6 +158,15 @@ org.xolstice.maven.plugins protobuf-maven-plugin + + + default + + compile + + generate-sources + + org.apache.maven.plugins diff --git a/jbpm/process-serialization-protobuf/src/main/java/org/jbpm/flow/serialization/ObjectMarshallerStrategyHelper.java b/jbpm/process-serialization-protobuf/src/main/java/org/jbpm/flow/serialization/ObjectMarshallerStrategyHelper.java new file mode 100644 index 00000000000..b475f11f295 --- /dev/null +++ b/jbpm/process-serialization-protobuf/src/main/java/org/jbpm/flow/serialization/ObjectMarshallerStrategyHelper.java @@ -0,0 +1,41 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.jbpm.flow.serialization; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.ServiceLoader; + +import org.jbpm.util.JbpmClassLoaderUtil; + +public class ObjectMarshallerStrategyHelper { + + public static ObjectMarshallerStrategy[] defaultStrategies() { + List strats = new ArrayList<>(); + ServiceLoader loader = ServiceLoader.load(ObjectMarshallerStrategy.class, JbpmClassLoaderUtil.findClassLoader()); + + for (ObjectMarshallerStrategy strategy : loader) { + strats.add(strategy); + } + Collections.sort(strats); + return strats.stream().toArray(ObjectMarshallerStrategy[]::new); + } + +} diff --git a/jbpm/process-serialization-protobuf/src/main/java/org/jbpm/flow/serialization/ProcessInstanceMarshallerService.java b/jbpm/process-serialization-protobuf/src/main/java/org/jbpm/flow/serialization/ProcessInstanceMarshallerService.java index 6b0fbd300d9..3611b26e7a5 100644 --- a/jbpm/process-serialization-protobuf/src/main/java/org/jbpm/flow/serialization/ProcessInstanceMarshallerService.java +++ b/jbpm/process-serialization-protobuf/src/main/java/org/jbpm/flow/serialization/ProcessInstanceMarshallerService.java @@ -82,11 +82,8 @@ public Builder withDefaultListeners() { } public Builder withDefaultObjectMarshallerStrategies() { - ServiceLoader loader = ServiceLoader.load(ObjectMarshallerStrategy.class, JbpmClassLoaderUtil.findClassLoader()); - for (ObjectMarshallerStrategy strategy : loader) { - ProcessInstanceMarshallerService.this.strats.add(strategy); - } + ProcessInstanceMarshallerService.this.strats.addAll(List.of(ObjectMarshallerStrategyHelper.defaultStrategies())); ServiceLoader readerLoader = ServiceLoader.load(NodeInstanceReader.class, JbpmClassLoaderUtil.findClassLoader()); diff --git a/jbpm/process-serialization-protobuf/src/main/java/org/jbpm/flow/serialization/impl/marshallers/ProtobufDocumentNodeMessageMarshaller.java b/jbpm/process-serialization-protobuf/src/main/java/org/jbpm/flow/serialization/impl/marshallers/ProtobufDocumentNodeMessageMarshaller.java new file mode 100644 index 00000000000..20e0fef3069 --- /dev/null +++ b/jbpm/process-serialization-protobuf/src/main/java/org/jbpm/flow/serialization/impl/marshallers/ProtobufDocumentNodeMessageMarshaller.java @@ -0,0 +1,83 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.jbpm.flow.serialization.impl.marshallers; + +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.io.StringWriter; + +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.ParserConfigurationException; +import javax.xml.transform.Transformer; +import javax.xml.transform.TransformerException; +import javax.xml.transform.TransformerFactory; +import javax.xml.transform.dom.DOMSource; +import javax.xml.transform.stream.StreamResult; + +import org.jbpm.flow.serialization.ObjectMarshallerStrategy; +import org.jbpm.flow.serialization.ProcessInstanceMarshallerException; +import org.jbpm.flow.serialization.protobuf.KogitoTypesProtobuf; +import org.w3c.dom.Document; +import org.xml.sax.SAXException; + +import com.google.protobuf.Any; + +public class ProtobufDocumentNodeMessageMarshaller implements ObjectMarshallerStrategy { + + @Override + public boolean acceptForMarshalling(Object value) { + return value instanceof Document; + } + + @Override + public boolean acceptForUnmarshalling(Any value) { + return value.is(KogitoTypesProtobuf.Document.class); + } + + @Override + public Any marshall(Object unmarshalled) { + try { + KogitoTypesProtobuf.Document.Builder builder = KogitoTypesProtobuf.Document.newBuilder(); + Document document = (Document) unmarshalled; + TransformerFactory tf = TransformerFactory.newInstance(); + Transformer trans = tf.newTransformer(); + StringWriter sw = new StringWriter(); + trans.transform(new DOMSource(document), new StreamResult(sw)); + builder.setContent(sw.toString()); + return Any.pack(builder.build()); + } catch (TransformerException e) { + throw new ProcessInstanceMarshallerException("Error trying to marshalling a Document Node value", e); + } + } + + @Override + public Object unmarshall(Any data) { + try { + KogitoTypesProtobuf.Document storedValue = data.unpack(KogitoTypesProtobuf.Document.class); + StringBuilder xmlStringBuilder = new StringBuilder(storedValue.getContent()); + ByteArrayInputStream input = new ByteArrayInputStream(xmlStringBuilder.toString().getBytes("UTF-8")); + DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); + factory.setExpandEntityReferences(false); + factory.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false); + return factory.newDocumentBuilder().parse(input); + } catch (IOException | SAXException | ParserConfigurationException e1) { + throw new ProcessInstanceMarshallerException("Error trying to unmarshalling a Document Node value", e1); + } + } +} \ No newline at end of file diff --git a/jbpm/process-serialization-protobuf/src/main/java/org/jbpm/flow/serialization/protobuf/KogitoNodeInstanceContentsProtobuf.java b/jbpm/process-serialization-protobuf/src/main/java/org/jbpm/flow/serialization/protobuf/KogitoNodeInstanceContentsProtobuf.java index 142057afb43..df604aff015 100644 --- a/jbpm/process-serialization-protobuf/src/main/java/org/jbpm/flow/serialization/protobuf/KogitoNodeInstanceContentsProtobuf.java +++ b/jbpm/process-serialization-protobuf/src/main/java/org/jbpm/flow/serialization/protobuf/KogitoNodeInstanceContentsProtobuf.java @@ -1,25 +1,25 @@ -/** -* Licensed to the Apache Software Foundation (ASF) under one -* or more contributor license agreements. See the NOTICE file -* distributed with this work for additional information -* regarding copyright ownership. The ASF licenses this file -* to you under the Apache License, Version 2.0 (the -* "License"); you may not use this file except in compliance -* with the License. You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, -* software distributed under the License is distributed on an -* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -* KIND, either express or implied. See the License for the -* specific language governing permissions and limitations -* under the License. -*/ - +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ // Generated by the protocol buffer compiler. DO NOT EDIT! // source: org/jbpm/flow/serialization/protobuf/kogito_node_instance_contents.proto +// Protobuf Java Version: 3.25.0 package org.jbpm.flow.serialization.protobuf; public final class KogitoNodeInstanceContentsProtobuf { @@ -168,7 +168,7 @@ protected java.lang.Object newInstance( @SuppressWarnings({ "rawtypes" }) @java.lang.Override - protected com.google.protobuf.MapField internalGetMapField( + protected com.google.protobuf.MapFieldReflectionAccessor internalGetMapFieldReflection( int number) { switch (number) { case 3: @@ -615,7 +615,7 @@ public static final class Builder extends } @SuppressWarnings({ "rawtypes" }) - protected com.google.protobuf.MapField internalGetMapField( + protected com.google.protobuf.MapFieldReflectionAccessor internalGetMapFieldReflection( int number) { switch (number) { case 3: @@ -627,7 +627,7 @@ protected com.google.protobuf.MapField internalGetMapField( } @SuppressWarnings({ "rawtypes" }) - protected com.google.protobuf.MapField internalGetMutableMapField( + protected com.google.protobuf.MapFieldReflectionAccessor internalGetMutableMapFieldReflection( int number) { switch (number) { case 3: @@ -718,6 +718,44 @@ private void buildPartial0(org.jbpm.flow.serialization.protobuf.KogitoNodeInstan result.bitField0_ |= to_bitField0_; } + @java.lang.Override + public Builder clone() { + return super.clone(); + } + + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.setField(field, value); + } + + @java.lang.Override + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + + @java.lang.Override + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.addRepeatedField(field, value); + } + @java.lang.Override public Builder mergeFrom(com.google.protobuf.Message other) { if (other instanceof org.jbpm.flow.serialization.protobuf.KogitoNodeInstanceContentsProtobuf.RuleSetNodeInstanceContent) { @@ -1590,7 +1628,7 @@ protected java.lang.Object newInstance( @SuppressWarnings({ "rawtypes" }) @java.lang.Override - protected com.google.protobuf.MapField internalGetMapField( + protected com.google.protobuf.MapFieldReflectionAccessor internalGetMapFieldReflection( int number) { switch (number) { case 13: @@ -2580,7 +2618,7 @@ public static final class Builder extends } @SuppressWarnings({ "rawtypes" }) - protected com.google.protobuf.MapField internalGetMapField( + protected com.google.protobuf.MapFieldReflectionAccessor internalGetMapFieldReflection( int number) { switch (number) { case 13: @@ -2592,7 +2630,7 @@ protected com.google.protobuf.MapField internalGetMapField( } @SuppressWarnings({ "rawtypes" }) - protected com.google.protobuf.MapField internalGetMutableMapField( + protected com.google.protobuf.MapFieldReflectionAccessor internalGetMutableMapFieldReflection( int number) { switch (number) { case 13: @@ -2771,6 +2809,44 @@ private void buildPartial0(org.jbpm.flow.serialization.protobuf.KogitoNodeInstan result.bitField0_ |= to_bitField0_; } + @java.lang.Override + public Builder clone() { + return super.clone(); + } + + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.setField(field, value); + } + + @java.lang.Override + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + + @java.lang.Override + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.addRepeatedField(field, value); + } + @java.lang.Override public Builder mergeFrom(com.google.protobuf.Message other) { if (other instanceof org.jbpm.flow.serialization.protobuf.KogitoNodeInstanceContentsProtobuf.WorkItemNodeInstanceContent) { @@ -4352,8 +4428,10 @@ public Builder mergeWorkItemData(com.google.protobuf.Any value) { } else { workItemDataBuilder_.mergeFrom(value); } - bitField0_ |= 0x00000800; - onChanged(); + if (workItemData_ != null) { + bitField0_ |= 0x00000800; + onChanged(); + } return this; } @@ -4751,7 +4829,7 @@ protected java.lang.Object newInstance( @SuppressWarnings({ "rawtypes" }) @java.lang.Override - protected com.google.protobuf.MapField internalGetMapField( + protected com.google.protobuf.MapFieldReflectionAccessor internalGetMapFieldReflection( int number) { switch (number) { case 3: @@ -5198,7 +5276,7 @@ public static final class Builder extends } @SuppressWarnings({ "rawtypes" }) - protected com.google.protobuf.MapField internalGetMapField( + protected com.google.protobuf.MapFieldReflectionAccessor internalGetMapFieldReflection( int number) { switch (number) { case 3: @@ -5210,7 +5288,7 @@ protected com.google.protobuf.MapField internalGetMapField( } @SuppressWarnings({ "rawtypes" }) - protected com.google.protobuf.MapField internalGetMutableMapField( + protected com.google.protobuf.MapFieldReflectionAccessor internalGetMutableMapFieldReflection( int number) { switch (number) { case 3: @@ -5301,6 +5379,44 @@ private void buildPartial0(org.jbpm.flow.serialization.protobuf.KogitoNodeInstan result.bitField0_ |= to_bitField0_; } + @java.lang.Override + public Builder clone() { + return super.clone(); + } + + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.setField(field, value); + } + + @java.lang.Override + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + + @java.lang.Override + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.addRepeatedField(field, value); + } + @java.lang.Override public Builder mergeFrom(com.google.protobuf.Message other) { if (other instanceof org.jbpm.flow.serialization.protobuf.KogitoNodeInstanceContentsProtobuf.LambdaSubProcessNodeInstanceContent) { @@ -5972,7 +6088,7 @@ protected java.lang.Object newInstance( @SuppressWarnings({ "rawtypes" }) @java.lang.Override - protected com.google.protobuf.MapField internalGetMapField( + protected com.google.protobuf.MapFieldReflectionAccessor internalGetMapFieldReflection( int number) { switch (number) { case 3: @@ -6419,7 +6535,7 @@ public static final class Builder extends } @SuppressWarnings({ "rawtypes" }) - protected com.google.protobuf.MapField internalGetMapField( + protected com.google.protobuf.MapFieldReflectionAccessor internalGetMapFieldReflection( int number) { switch (number) { case 3: @@ -6431,7 +6547,7 @@ protected com.google.protobuf.MapField internalGetMapField( } @SuppressWarnings({ "rawtypes" }) - protected com.google.protobuf.MapField internalGetMutableMapField( + protected com.google.protobuf.MapFieldReflectionAccessor internalGetMutableMapFieldReflection( int number) { switch (number) { case 3: @@ -6522,6 +6638,44 @@ private void buildPartial0(org.jbpm.flow.serialization.protobuf.KogitoNodeInstan result.bitField0_ |= to_bitField0_; } + @java.lang.Override + public Builder clone() { + return super.clone(); + } + + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.setField(field, value); + } + + @java.lang.Override + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + + @java.lang.Override + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.addRepeatedField(field, value); + } + @java.lang.Override public Builder mergeFrom(com.google.protobuf.Message other) { if (other instanceof org.jbpm.flow.serialization.protobuf.KogitoNodeInstanceContentsProtobuf.SubProcessNodeInstanceContent) { @@ -7170,7 +7324,7 @@ protected java.lang.Object newInstance( @SuppressWarnings({ "rawtypes" }) @java.lang.Override - protected com.google.protobuf.MapField internalGetMapField( + protected com.google.protobuf.MapFieldReflectionAccessor internalGetMapFieldReflection( int number) { switch (number) { case 2: @@ -7546,7 +7700,7 @@ public static final class Builder extends } @SuppressWarnings({ "rawtypes" }) - protected com.google.protobuf.MapField internalGetMapField( + protected com.google.protobuf.MapFieldReflectionAccessor internalGetMapFieldReflection( int number) { switch (number) { case 2: @@ -7558,7 +7712,7 @@ protected com.google.protobuf.MapField internalGetMapField( } @SuppressWarnings({ "rawtypes" }) - protected com.google.protobuf.MapField internalGetMutableMapField( + protected com.google.protobuf.MapFieldReflectionAccessor internalGetMutableMapFieldReflection( int number) { switch (number) { case 2: @@ -7642,6 +7796,44 @@ private void buildPartial0(org.jbpm.flow.serialization.protobuf.KogitoNodeInstan } } + @java.lang.Override + public Builder clone() { + return super.clone(); + } + + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.setField(field, value); + } + + @java.lang.Override + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + + @java.lang.Override + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.addRepeatedField(field, value); + } + @java.lang.Override public Builder mergeFrom(com.google.protobuf.Message other) { if (other instanceof org.jbpm.flow.serialization.protobuf.KogitoNodeInstanceContentsProtobuf.MilestoneNodeInstanceContent) { @@ -8353,6 +8545,44 @@ public org.jbpm.flow.serialization.protobuf.KogitoNodeInstanceContentsProtobuf.E return result; } + @java.lang.Override + public Builder clone() { + return super.clone(); + } + + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.setField(field, value); + } + + @java.lang.Override + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + + @java.lang.Override + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.addRepeatedField(field, value); + } + @java.lang.Override public Builder mergeFrom(com.google.protobuf.Message other) { if (other instanceof org.jbpm.flow.serialization.protobuf.KogitoNodeInstanceContentsProtobuf.EventNodeInstanceContent) { @@ -8856,6 +9086,44 @@ private void buildPartial0(org.jbpm.flow.serialization.protobuf.KogitoNodeInstan result.bitField0_ |= to_bitField0_; } + @java.lang.Override + public Builder clone() { + return super.clone(); + } + + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.setField(field, value); + } + + @java.lang.Override + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + + @java.lang.Override + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.addRepeatedField(field, value); + } + @java.lang.Override public Builder mergeFrom(com.google.protobuf.Message other) { if (other instanceof org.jbpm.flow.serialization.protobuf.KogitoNodeInstanceContentsProtobuf.TimerNodeInstanceContent) { @@ -9597,6 +9865,44 @@ private void buildPartial0(org.jbpm.flow.serialization.protobuf.KogitoNodeInstan result.bitField0_ |= to_bitField0_; } + @java.lang.Override + public Builder clone() { + return super.clone(); + } + + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.setField(field, value); + } + + @java.lang.Override + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + + @java.lang.Override + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.addRepeatedField(field, value); + } + @java.lang.Override public Builder mergeFrom(com.google.protobuf.Message other) { if (other instanceof org.jbpm.flow.serialization.protobuf.KogitoNodeInstanceContentsProtobuf.JoinNodeInstanceContent.JoinTrigger) { @@ -10199,6 +10505,44 @@ private void buildPartial0(org.jbpm.flow.serialization.protobuf.KogitoNodeInstan int from_bitField0_ = bitField0_; } + @java.lang.Override + public Builder clone() { + return super.clone(); + } + + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.setField(field, value); + } + + @java.lang.Override + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + + @java.lang.Override + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.addRepeatedField(field, value); + } + @java.lang.Override public Builder mergeFrom(com.google.protobuf.Message other) { if (other instanceof org.jbpm.flow.serialization.protobuf.KogitoNodeInstanceContentsProtobuf.JoinNodeInstanceContent) { @@ -10723,7 +11067,7 @@ protected java.lang.Object newInstance( @SuppressWarnings({ "rawtypes" }) @java.lang.Override - protected com.google.protobuf.MapField internalGetMapField( + protected com.google.protobuf.MapFieldReflectionAccessor internalGetMapFieldReflection( int number) { switch (number) { case 2: @@ -11099,7 +11443,7 @@ public static final class Builder extends } @SuppressWarnings({ "rawtypes" }) - protected com.google.protobuf.MapField internalGetMapField( + protected com.google.protobuf.MapFieldReflectionAccessor internalGetMapFieldReflection( int number) { switch (number) { case 2: @@ -11111,7 +11455,7 @@ protected com.google.protobuf.MapField internalGetMapField( } @SuppressWarnings({ "rawtypes" }) - protected com.google.protobuf.MapField internalGetMutableMapField( + protected com.google.protobuf.MapFieldReflectionAccessor internalGetMutableMapFieldReflection( int number) { switch (number) { case 2: @@ -11195,6 +11539,44 @@ private void buildPartial0(org.jbpm.flow.serialization.protobuf.KogitoNodeInstan } } + @java.lang.Override + public Builder clone() { + return super.clone(); + } + + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.setField(field, value); + } + + @java.lang.Override + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + + @java.lang.Override + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.addRepeatedField(field, value); + } + @java.lang.Override public Builder mergeFrom(com.google.protobuf.Message other) { if (other instanceof org.jbpm.flow.serialization.protobuf.KogitoNodeInstanceContentsProtobuf.StateNodeInstanceContent) { @@ -11757,7 +12139,7 @@ protected java.lang.Object newInstance( @SuppressWarnings({ "rawtypes" }) @java.lang.Override - protected com.google.protobuf.MapField internalGetMapField( + protected com.google.protobuf.MapFieldReflectionAccessor internalGetMapFieldReflection( int number) { switch (number) { case 3: @@ -11777,6 +12159,7 @@ protected com.google.protobuf.MapField internalGetMapField( org.jbpm.flow.serialization.protobuf.KogitoNodeInstanceContentsProtobuf.CompositeContextNodeInstanceContent.Builder.class); } + private int bitField0_; public static final int TIMER_INSTANCE_ID_FIELD_NUMBER = 1; @SuppressWarnings("serial") private com.google.protobuf.LazyStringArrayList timerInstanceId_ = @@ -11832,7 +12215,7 @@ public java.lang.String getTimerInstanceId(int index) { */ @java.lang.Override public boolean hasContext() { - return context_ != null; + return ((bitField0_ & 0x00000001) != 0); } /** @@ -11964,7 +12347,7 @@ public void writeTo(com.google.protobuf.CodedOutputStream output) for (int i = 0; i < timerInstanceId_.size(); i++) { com.google.protobuf.GeneratedMessageV3.writeString(output, 1, timerInstanceId_.getRaw(i)); } - if (context_ != null) { + if (((bitField0_ & 0x00000001) != 0)) { output.writeMessage(2, getContext()); } com.google.protobuf.GeneratedMessageV3 @@ -11991,7 +12374,7 @@ public int getSerializedSize() { size += dataSize; size += 1 * getTimerInstanceIdList().size(); } - if (context_ != null) { + if (((bitField0_ & 0x00000001) != 0)) { size += com.google.protobuf.CodedOutputStream .computeMessageSize(2, getContext()); } @@ -12182,7 +12565,7 @@ public static final class Builder extends } @SuppressWarnings({ "rawtypes" }) - protected com.google.protobuf.MapField internalGetMapField( + protected com.google.protobuf.MapFieldReflectionAccessor internalGetMapFieldReflection( int number) { switch (number) { case 3: @@ -12194,7 +12577,7 @@ protected com.google.protobuf.MapField internalGetMapField( } @SuppressWarnings({ "rawtypes" }) - protected com.google.protobuf.MapField internalGetMutableMapField( + protected com.google.protobuf.MapFieldReflectionAccessor internalGetMutableMapFieldReflection( int number) { switch (number) { case 3: @@ -12216,13 +12599,19 @@ protected com.google.protobuf.MapField internalGetMutableMapField( // Construct using org.jbpm.flow.serialization.protobuf.KogitoNodeInstanceContentsProtobuf.CompositeContextNodeInstanceContent.newBuilder() private Builder() { - + maybeForceBuilderInitialization(); } private Builder( com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders) { + getContextFieldBuilder(); + } } @java.lang.Override @@ -12277,15 +12666,56 @@ private void buildPartial0(org.jbpm.flow.serialization.protobuf.KogitoNodeInstan timerInstanceId_.makeImmutable(); result.timerInstanceId_ = timerInstanceId_; } + int to_bitField0_ = 0; if (((from_bitField0_ & 0x00000002) != 0)) { result.context_ = contextBuilder_ == null ? context_ : contextBuilder_.build(); + to_bitField0_ |= 0x00000001; } if (((from_bitField0_ & 0x00000004) != 0)) { result.timerInstanceReference_ = internalGetTimerInstanceReference(); result.timerInstanceReference_.makeImmutable(); } + result.bitField0_ |= to_bitField0_; + } + + @java.lang.Override + public Builder clone() { + return super.clone(); + } + + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.setField(field, value); + } + + @java.lang.Override + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + + @java.lang.Override + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.addRepeatedField(field, value); } @java.lang.Override @@ -12591,8 +13021,10 @@ public Builder mergeContext(org.jbpm.flow.serialization.protobuf.KogitoTypesProt } else { contextBuilder_.mergeFrom(value); } - bitField0_ |= 0x00000002; - onChanged(); + if (context_ != null) { + bitField0_ |= 0x00000002; + onChanged(); + } return this; } @@ -12987,7 +13419,7 @@ protected java.lang.Object newInstance( @SuppressWarnings({ "rawtypes" }) @java.lang.Override - protected com.google.protobuf.MapField internalGetMapField( + protected com.google.protobuf.MapFieldReflectionAccessor internalGetMapFieldReflection( int number) { switch (number) { case 3: @@ -13007,6 +13439,7 @@ protected com.google.protobuf.MapField internalGetMapField( org.jbpm.flow.serialization.protobuf.KogitoNodeInstanceContentsProtobuf.DynamicNodeInstanceContent.Builder.class); } + private int bitField0_; public static final int TIMER_INSTANCE_ID_FIELD_NUMBER = 1; @SuppressWarnings("serial") private com.google.protobuf.LazyStringArrayList timerInstanceId_ = @@ -13062,7 +13495,7 @@ public java.lang.String getTimerInstanceId(int index) { */ @java.lang.Override public boolean hasContext() { - return context_ != null; + return ((bitField0_ & 0x00000001) != 0); } /** @@ -13194,7 +13627,7 @@ public void writeTo(com.google.protobuf.CodedOutputStream output) for (int i = 0; i < timerInstanceId_.size(); i++) { com.google.protobuf.GeneratedMessageV3.writeString(output, 1, timerInstanceId_.getRaw(i)); } - if (context_ != null) { + if (((bitField0_ & 0x00000001) != 0)) { output.writeMessage(2, getContext()); } com.google.protobuf.GeneratedMessageV3 @@ -13221,7 +13654,7 @@ public int getSerializedSize() { size += dataSize; size += 1 * getTimerInstanceIdList().size(); } - if (context_ != null) { + if (((bitField0_ & 0x00000001) != 0)) { size += com.google.protobuf.CodedOutputStream .computeMessageSize(2, getContext()); } @@ -13412,7 +13845,7 @@ public static final class Builder extends } @SuppressWarnings({ "rawtypes" }) - protected com.google.protobuf.MapField internalGetMapField( + protected com.google.protobuf.MapFieldReflectionAccessor internalGetMapFieldReflection( int number) { switch (number) { case 3: @@ -13424,7 +13857,7 @@ protected com.google.protobuf.MapField internalGetMapField( } @SuppressWarnings({ "rawtypes" }) - protected com.google.protobuf.MapField internalGetMutableMapField( + protected com.google.protobuf.MapFieldReflectionAccessor internalGetMutableMapFieldReflection( int number) { switch (number) { case 3: @@ -13446,13 +13879,19 @@ protected com.google.protobuf.MapField internalGetMutableMapField( // Construct using org.jbpm.flow.serialization.protobuf.KogitoNodeInstanceContentsProtobuf.DynamicNodeInstanceContent.newBuilder() private Builder() { - + maybeForceBuilderInitialization(); } private Builder( com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders) { + getContextFieldBuilder(); + } } @java.lang.Override @@ -13507,15 +13946,56 @@ private void buildPartial0(org.jbpm.flow.serialization.protobuf.KogitoNodeInstan timerInstanceId_.makeImmutable(); result.timerInstanceId_ = timerInstanceId_; } + int to_bitField0_ = 0; if (((from_bitField0_ & 0x00000002) != 0)) { result.context_ = contextBuilder_ == null ? context_ : contextBuilder_.build(); + to_bitField0_ |= 0x00000001; } if (((from_bitField0_ & 0x00000004) != 0)) { result.timerInstanceReference_ = internalGetTimerInstanceReference(); result.timerInstanceReference_.makeImmutable(); } + result.bitField0_ |= to_bitField0_; + } + + @java.lang.Override + public Builder clone() { + return super.clone(); + } + + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.setField(field, value); + } + + @java.lang.Override + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + + @java.lang.Override + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.addRepeatedField(field, value); } @java.lang.Override @@ -13821,8 +14301,10 @@ public Builder mergeContext(org.jbpm.flow.serialization.protobuf.KogitoTypesProt } else { contextBuilder_.mergeFrom(value); } - bitField0_ |= 0x00000002; - onChanged(); + if (context_ != null) { + bitField0_ |= 0x00000002; + onChanged(); + } return this; } @@ -14217,7 +14699,7 @@ protected java.lang.Object newInstance( @SuppressWarnings({ "rawtypes" }) @java.lang.Override - protected com.google.protobuf.MapField internalGetMapField( + protected com.google.protobuf.MapFieldReflectionAccessor internalGetMapFieldReflection( int number) { switch (number) { case 3: @@ -14237,6 +14719,7 @@ protected com.google.protobuf.MapField internalGetMapField( org.jbpm.flow.serialization.protobuf.KogitoNodeInstanceContentsProtobuf.EventSubProcessNodeInstanceContent.Builder.class); } + private int bitField0_; public static final int TIMER_INSTANCE_ID_FIELD_NUMBER = 1; @SuppressWarnings("serial") private com.google.protobuf.LazyStringArrayList timerInstanceId_ = @@ -14292,7 +14775,7 @@ public java.lang.String getTimerInstanceId(int index) { */ @java.lang.Override public boolean hasContext() { - return context_ != null; + return ((bitField0_ & 0x00000001) != 0); } /** @@ -14424,7 +14907,7 @@ public void writeTo(com.google.protobuf.CodedOutputStream output) for (int i = 0; i < timerInstanceId_.size(); i++) { com.google.protobuf.GeneratedMessageV3.writeString(output, 1, timerInstanceId_.getRaw(i)); } - if (context_ != null) { + if (((bitField0_ & 0x00000001) != 0)) { output.writeMessage(2, getContext()); } com.google.protobuf.GeneratedMessageV3 @@ -14451,7 +14934,7 @@ public int getSerializedSize() { size += dataSize; size += 1 * getTimerInstanceIdList().size(); } - if (context_ != null) { + if (((bitField0_ & 0x00000001) != 0)) { size += com.google.protobuf.CodedOutputStream .computeMessageSize(2, getContext()); } @@ -14642,7 +15125,7 @@ public static final class Builder extends } @SuppressWarnings({ "rawtypes" }) - protected com.google.protobuf.MapField internalGetMapField( + protected com.google.protobuf.MapFieldReflectionAccessor internalGetMapFieldReflection( int number) { switch (number) { case 3: @@ -14654,7 +15137,7 @@ protected com.google.protobuf.MapField internalGetMapField( } @SuppressWarnings({ "rawtypes" }) - protected com.google.protobuf.MapField internalGetMutableMapField( + protected com.google.protobuf.MapFieldReflectionAccessor internalGetMutableMapFieldReflection( int number) { switch (number) { case 3: @@ -14676,13 +15159,19 @@ protected com.google.protobuf.MapField internalGetMutableMapField( // Construct using org.jbpm.flow.serialization.protobuf.KogitoNodeInstanceContentsProtobuf.EventSubProcessNodeInstanceContent.newBuilder() private Builder() { - + maybeForceBuilderInitialization(); } private Builder( com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders) { + getContextFieldBuilder(); + } } @java.lang.Override @@ -14737,15 +15226,56 @@ private void buildPartial0(org.jbpm.flow.serialization.protobuf.KogitoNodeInstan timerInstanceId_.makeImmutable(); result.timerInstanceId_ = timerInstanceId_; } + int to_bitField0_ = 0; if (((from_bitField0_ & 0x00000002) != 0)) { result.context_ = contextBuilder_ == null ? context_ : contextBuilder_.build(); + to_bitField0_ |= 0x00000001; } if (((from_bitField0_ & 0x00000004) != 0)) { result.timerInstanceReference_ = internalGetTimerInstanceReference(); result.timerInstanceReference_.makeImmutable(); } + result.bitField0_ |= to_bitField0_; + } + + @java.lang.Override + public Builder clone() { + return super.clone(); + } + + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.setField(field, value); + } + + @java.lang.Override + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + + @java.lang.Override + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.addRepeatedField(field, value); } @java.lang.Override @@ -15051,8 +15581,10 @@ public Builder mergeContext(org.jbpm.flow.serialization.protobuf.KogitoTypesProt } else { contextBuilder_.mergeFrom(value); } - bitField0_ |= 0x00000002; - onChanged(); + if (context_ != null) { + bitField0_ |= 0x00000002; + onChanged(); + } return this; } @@ -15468,7 +16000,7 @@ protected java.lang.Object newInstance( @SuppressWarnings({ "rawtypes" }) @java.lang.Override - protected com.google.protobuf.MapField internalGetMapField( + protected com.google.protobuf.MapFieldReflectionAccessor internalGetMapFieldReflection( int number) { switch (number) { case 6: @@ -15488,6 +16020,7 @@ protected com.google.protobuf.MapField internalGetMapField( org.jbpm.flow.serialization.protobuf.KogitoNodeInstanceContentsProtobuf.ForEachNodeInstanceContent.Builder.class); } + private int bitField0_; public static final int TIMER_INSTANCE_ID_FIELD_NUMBER = 1; @SuppressWarnings("serial") private com.google.protobuf.LazyStringArrayList timerInstanceId_ = @@ -15543,7 +16076,7 @@ public java.lang.String getTimerInstanceId(int index) { */ @java.lang.Override public boolean hasContext() { - return context_ != null; + return ((bitField0_ & 0x00000001) != 0); } /** @@ -15714,7 +16247,7 @@ public void writeTo(com.google.protobuf.CodedOutputStream output) for (int i = 0; i < timerInstanceId_.size(); i++) { com.google.protobuf.GeneratedMessageV3.writeString(output, 1, timerInstanceId_.getRaw(i)); } - if (context_ != null) { + if (((bitField0_ & 0x00000001) != 0)) { output.writeMessage(2, getContext()); } if (totalInstances_ != 0) { @@ -15750,7 +16283,7 @@ public int getSerializedSize() { size += dataSize; size += 1 * getTimerInstanceIdList().size(); } - if (context_ != null) { + if (((bitField0_ & 0x00000001) != 0)) { size += com.google.protobuf.CodedOutputStream .computeMessageSize(2, getContext()); } @@ -15966,7 +16499,7 @@ public static final class Builder extends } @SuppressWarnings({ "rawtypes" }) - protected com.google.protobuf.MapField internalGetMapField( + protected com.google.protobuf.MapFieldReflectionAccessor internalGetMapFieldReflection( int number) { switch (number) { case 6: @@ -15978,7 +16511,7 @@ protected com.google.protobuf.MapField internalGetMapField( } @SuppressWarnings({ "rawtypes" }) - protected com.google.protobuf.MapField internalGetMutableMapField( + protected com.google.protobuf.MapFieldReflectionAccessor internalGetMutableMapFieldReflection( int number) { switch (number) { case 6: @@ -16000,13 +16533,19 @@ protected com.google.protobuf.MapField internalGetMutableMapField( // Construct using org.jbpm.flow.serialization.protobuf.KogitoNodeInstanceContentsProtobuf.ForEachNodeInstanceContent.newBuilder() private Builder() { - + maybeForceBuilderInitialization(); } private Builder( com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders) { + getContextFieldBuilder(); + } } @java.lang.Override @@ -16064,10 +16603,12 @@ private void buildPartial0(org.jbpm.flow.serialization.protobuf.KogitoNodeInstan timerInstanceId_.makeImmutable(); result.timerInstanceId_ = timerInstanceId_; } + int to_bitField0_ = 0; if (((from_bitField0_ & 0x00000002) != 0)) { result.context_ = contextBuilder_ == null ? context_ : contextBuilder_.build(); + to_bitField0_ |= 0x00000001; } if (((from_bitField0_ & 0x00000004) != 0)) { result.totalInstances_ = totalInstances_; @@ -16082,6 +16623,45 @@ private void buildPartial0(org.jbpm.flow.serialization.protobuf.KogitoNodeInstan result.timerInstanceReference_ = internalGetTimerInstanceReference(); result.timerInstanceReference_.makeImmutable(); } + result.bitField0_ |= to_bitField0_; + } + + @java.lang.Override + public Builder clone() { + return super.clone(); + } + + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.setField(field, value); + } + + @java.lang.Override + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + + @java.lang.Override + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.addRepeatedField(field, value); } @java.lang.Override @@ -16411,8 +16991,10 @@ public Builder mergeContext(org.jbpm.flow.serialization.protobuf.KogitoTypesProt } else { contextBuilder_.mergeFrom(value); } - bitField0_ |= 0x00000002; - onChanged(); + if (context_ != null) { + bitField0_ |= 0x00000002; + onChanged(); + } return this; } @@ -17152,6 +17734,44 @@ private void buildPartial0(org.jbpm.flow.serialization.protobuf.KogitoNodeInstan } } + @java.lang.Override + public Builder clone() { + return super.clone(); + } + + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.setField(field, value); + } + + @java.lang.Override + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + + @java.lang.Override + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.addRepeatedField(field, value); + } + @java.lang.Override public Builder mergeFrom(com.google.protobuf.Message other) { if (other instanceof org.jbpm.flow.serialization.protobuf.KogitoNodeInstanceContentsProtobuf.AsyncEventNodeInstanceContent) { @@ -17542,7 +18162,7 @@ public org.jbpm.flow.serialization.protobuf.KogitoNodeInstanceContentsProtobuf.A getDescriptor().getMessageTypes().get(0); internal_static_org_jbpm_flow_serialization_protobuf_RuleSetNodeInstanceContent_fieldAccessorTable = new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( internal_static_org_jbpm_flow_serialization_protobuf_RuleSetNodeInstanceContent_descriptor, - new java.lang.String[] { "TimerInstanceId", "RuleFlowGroup", "TimerInstanceReference", "RuleFlowGroup", }); + new java.lang.String[] { "TimerInstanceId", "RuleFlowGroup", "TimerInstanceReference", }); internal_static_org_jbpm_flow_serialization_protobuf_RuleSetNodeInstanceContent_TimerInstanceReferenceEntry_descriptor = internal_static_org_jbpm_flow_serialization_protobuf_RuleSetNodeInstanceContent_descriptor.getNestedTypes().get(0); internal_static_org_jbpm_flow_serialization_protobuf_RuleSetNodeInstanceContent_TimerInstanceReferenceEntry_fieldAccessorTable = new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( @@ -17553,7 +18173,7 @@ public org.jbpm.flow.serialization.protobuf.KogitoNodeInstanceContentsProtobuf.A internal_static_org_jbpm_flow_serialization_protobuf_WorkItemNodeInstanceContent_fieldAccessorTable = new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( internal_static_org_jbpm_flow_serialization_protobuf_WorkItemNodeInstanceContent_descriptor, new java.lang.String[] { "WorkItemId", "TimerInstanceId", "ErrorHandlingProcessInstanceId", "State", "Variable", "Result", "PhaseId", "PhaseStatus", "Name", "StartDate", - "CompleteDate", "WorkItemData", "TimerInstanceReference", "ErrorHandlingProcessInstanceId", "PhaseId", "PhaseStatus", "Name", "StartDate", "CompleteDate", "WorkItemData", }); + "CompleteDate", "WorkItemData", "TimerInstanceReference", }); internal_static_org_jbpm_flow_serialization_protobuf_WorkItemNodeInstanceContent_TimerInstanceReferenceEntry_descriptor = internal_static_org_jbpm_flow_serialization_protobuf_WorkItemNodeInstanceContent_descriptor.getNestedTypes().get(0); internal_static_org_jbpm_flow_serialization_protobuf_WorkItemNodeInstanceContent_TimerInstanceReferenceEntry_fieldAccessorTable = new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( @@ -17563,7 +18183,7 @@ public org.jbpm.flow.serialization.protobuf.KogitoNodeInstanceContentsProtobuf.A getDescriptor().getMessageTypes().get(2); internal_static_org_jbpm_flow_serialization_protobuf_LambdaSubProcessNodeInstanceContent_fieldAccessorTable = new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( internal_static_org_jbpm_flow_serialization_protobuf_LambdaSubProcessNodeInstanceContent_descriptor, - new java.lang.String[] { "ProcessInstanceId", "TimerInstanceId", "TimerInstanceReference", "ProcessInstanceId", }); + new java.lang.String[] { "ProcessInstanceId", "TimerInstanceId", "TimerInstanceReference", }); internal_static_org_jbpm_flow_serialization_protobuf_LambdaSubProcessNodeInstanceContent_TimerInstanceReferenceEntry_descriptor = internal_static_org_jbpm_flow_serialization_protobuf_LambdaSubProcessNodeInstanceContent_descriptor.getNestedTypes().get(0); internal_static_org_jbpm_flow_serialization_protobuf_LambdaSubProcessNodeInstanceContent_TimerInstanceReferenceEntry_fieldAccessorTable = @@ -17574,7 +18194,7 @@ public org.jbpm.flow.serialization.protobuf.KogitoNodeInstanceContentsProtobuf.A getDescriptor().getMessageTypes().get(3); internal_static_org_jbpm_flow_serialization_protobuf_SubProcessNodeInstanceContent_fieldAccessorTable = new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( internal_static_org_jbpm_flow_serialization_protobuf_SubProcessNodeInstanceContent_descriptor, - new java.lang.String[] { "ProcessInstanceId", "TimerInstanceId", "TimerInstanceReference", "ProcessInstanceId", }); + new java.lang.String[] { "ProcessInstanceId", "TimerInstanceId", "TimerInstanceReference", }); internal_static_org_jbpm_flow_serialization_protobuf_SubProcessNodeInstanceContent_TimerInstanceReferenceEntry_descriptor = internal_static_org_jbpm_flow_serialization_protobuf_SubProcessNodeInstanceContent_descriptor.getNestedTypes().get(0); internal_static_org_jbpm_flow_serialization_protobuf_SubProcessNodeInstanceContent_TimerInstanceReferenceEntry_fieldAccessorTable = @@ -17601,7 +18221,7 @@ public org.jbpm.flow.serialization.protobuf.KogitoNodeInstanceContentsProtobuf.A getDescriptor().getMessageTypes().get(6); internal_static_org_jbpm_flow_serialization_protobuf_TimerNodeInstanceContent_fieldAccessorTable = new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( internal_static_org_jbpm_flow_serialization_protobuf_TimerNodeInstanceContent_descriptor, - new java.lang.String[] { "TimerId", "TimerId", }); + new java.lang.String[] { "TimerId", }); internal_static_org_jbpm_flow_serialization_protobuf_JoinNodeInstanceContent_descriptor = getDescriptor().getMessageTypes().get(7); internal_static_org_jbpm_flow_serialization_protobuf_JoinNodeInstanceContent_fieldAccessorTable = new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( @@ -17611,7 +18231,7 @@ public org.jbpm.flow.serialization.protobuf.KogitoNodeInstanceContentsProtobuf.A internal_static_org_jbpm_flow_serialization_protobuf_JoinNodeInstanceContent_descriptor.getNestedTypes().get(0); internal_static_org_jbpm_flow_serialization_protobuf_JoinNodeInstanceContent_JoinTrigger_fieldAccessorTable = new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( internal_static_org_jbpm_flow_serialization_protobuf_JoinNodeInstanceContent_JoinTrigger_descriptor, - new java.lang.String[] { "NodeId", "Counter", "NodeId", "Counter", }); + new java.lang.String[] { "NodeId", "Counter", }); internal_static_org_jbpm_flow_serialization_protobuf_StateNodeInstanceContent_descriptor = getDescriptor().getMessageTypes().get(8); internal_static_org_jbpm_flow_serialization_protobuf_StateNodeInstanceContent_fieldAccessorTable = new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( diff --git a/jbpm/process-serialization-protobuf/src/main/java/org/jbpm/flow/serialization/protobuf/KogitoProcessInstanceProtobuf.java b/jbpm/process-serialization-protobuf/src/main/java/org/jbpm/flow/serialization/protobuf/KogitoProcessInstanceProtobuf.java index b7f4410f764..1e09647188b 100644 --- a/jbpm/process-serialization-protobuf/src/main/java/org/jbpm/flow/serialization/protobuf/KogitoProcessInstanceProtobuf.java +++ b/jbpm/process-serialization-protobuf/src/main/java/org/jbpm/flow/serialization/protobuf/KogitoProcessInstanceProtobuf.java @@ -1,25 +1,25 @@ -/** -* Licensed to the Apache Software Foundation (ASF) under one -* or more contributor license agreements. See the NOTICE file -* distributed with this work for additional information -* regarding copyright ownership. The ASF licenses this file -* to you under the Apache License, Version 2.0 (the -* "License"); you may not use this file except in compliance -* with the License. You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, -* software distributed under the License is distributed on an -* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -* KIND, either express or implied. See the License for the -* specific language governing permissions and limitations -* under the License. -*/ - +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ // Generated by the protocol buffer compiler. DO NOT EDIT! // source: org/jbpm/flow/serialization/protobuf/kogito_process_instance.proto +// Protobuf Java Version: 3.25.0 package org.jbpm.flow.serialization.protobuf; public final class KogitoProcessInstanceProtobuf { @@ -2168,6 +2168,44 @@ private void buildPartial0(org.jbpm.flow.serialization.protobuf.KogitoProcessIns result.bitField0_ |= to_bitField0_; } + @java.lang.Override + public Builder clone() { + return super.clone(); + } + + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.setField(field, value); + } + + @java.lang.Override + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + + @java.lang.Override + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.addRepeatedField(field, value); + } + @java.lang.Override public Builder mergeFrom(com.google.protobuf.Message other) { if (other instanceof org.jbpm.flow.serialization.protobuf.KogitoProcessInstanceProtobuf.ProcessInstance) { @@ -3914,8 +3952,10 @@ public Builder mergeSla(org.jbpm.flow.serialization.protobuf.KogitoTypesProtobuf } else { slaBuilder_.mergeFrom(value); } - bitField0_ |= 0x00020000; - onChanged(); + if (sla_ != null) { + bitField0_ |= 0x00020000; + onChanged(); + } return this; } @@ -4041,8 +4081,10 @@ public Builder mergeContext(org.jbpm.flow.serialization.protobuf.KogitoTypesProt } else { contextBuilder_.mergeFrom(value); } - bitField0_ |= 0x00040000; - onChanged(); + if (context_ != null) { + bitField0_ |= 0x00040000; + onChanged(); + } return this; } @@ -4702,8 +4744,7 @@ public org.jbpm.flow.serialization.protobuf.KogitoProcessInstanceProtobuf.Proces internal_static_org_jbpm_flow_serialization_protobuf_ProcessInstance_descriptor, new java.lang.String[] { "ProcessType", "ProcessId", "ProcessVersion", "Id", "ParentProcessInstanceId", "BusinessKey", "DeploymentId", "Description", "State", "StartDate", "NodeInstanceCounter", "SignalCompletion", "RootProcessInstanceId", "RootProcessId", "ErrorNodeId", "ErrorMessage", "ReferenceId", "Sla", "Context", "SwimlaneContext", - "CompletedNodeIds", "CancelTimerId", "ParentProcessInstanceId", "BusinessKey", "DeploymentId", "Description", "StartDate", "NodeInstanceCounter", "RootProcessInstanceId", - "RootProcessId", "ErrorNodeId", "ErrorMessage", "ReferenceId", "Sla", "Context", "CancelTimerId", }); + "CompletedNodeIds", "CancelTimerId", }); org.jbpm.flow.serialization.protobuf.KogitoTypesProtobuf.getDescriptor(); } diff --git a/jbpm/process-serialization-protobuf/src/main/java/org/jbpm/flow/serialization/protobuf/KogitoTypesProtobuf.java b/jbpm/process-serialization-protobuf/src/main/java/org/jbpm/flow/serialization/protobuf/KogitoTypesProtobuf.java index 6e27e48caae..51922a02ed5 100644 --- a/jbpm/process-serialization-protobuf/src/main/java/org/jbpm/flow/serialization/protobuf/KogitoTypesProtobuf.java +++ b/jbpm/process-serialization-protobuf/src/main/java/org/jbpm/flow/serialization/protobuf/KogitoTypesProtobuf.java @@ -1,25 +1,25 @@ -/** -* Licensed to the Apache Software Foundation (ASF) under one -* or more contributor license agreements. See the NOTICE file -* distributed with this work for additional information -* regarding copyright ownership. The ASF licenses this file -* to you under the Apache License, Version 2.0 (the -* "License"); you may not use this file except in compliance -* with the License. You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, -* software distributed under the License is distributed on an -* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -* KIND, either express or implied. See the License for the -* specific language governing permissions and limitations -* under the License. -*/ - +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ // Generated by the protocol buffer compiler. DO NOT EDIT! // source: org/jbpm/flow/serialization/protobuf/kogito_types.proto +// Protobuf Java Version: 3.25.0 package org.jbpm.flow.serialization.protobuf; public final class KogitoTypesProtobuf { @@ -36,8 +36,616 @@ public static void registerAllExtensions( (com.google.protobuf.ExtensionRegistryLite) registry); } - public interface JsonNodeOrBuilder extends - // @@protoc_insertion_point(interface_extends:org.jbpm.flow.serialization.protobuf.JsonNode) + public interface JsonNodeOrBuilder extends + // @@protoc_insertion_point(interface_extends:org.jbpm.flow.serialization.protobuf.JsonNode) + com.google.protobuf.MessageOrBuilder { + + /** + * string content = 1; + * + * @return The content. + */ + java.lang.String getContent(); + + /** + * string content = 1; + * + * @return The bytes for content. + */ + com.google.protobuf.ByteString + getContentBytes(); + } + + /** + * Protobuf type {@code org.jbpm.flow.serialization.protobuf.JsonNode} + */ + public static final class JsonNode extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:org.jbpm.flow.serialization.protobuf.JsonNode) + JsonNodeOrBuilder { + private static final long serialVersionUID = 0L; + + // Use JsonNode.newBuilder() to construct. + private JsonNode(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + + private JsonNode() { + content_ = ""; + } + + @java.lang.Override + @SuppressWarnings({ "unused" }) + protected java.lang.Object newInstance( + UnusedPrivateParameter unused) { + return new JsonNode(); + } + + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.jbpm.flow.serialization.protobuf.KogitoTypesProtobuf.internal_static_org_jbpm_flow_serialization_protobuf_JsonNode_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.jbpm.flow.serialization.protobuf.KogitoTypesProtobuf.internal_static_org_jbpm_flow_serialization_protobuf_JsonNode_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.jbpm.flow.serialization.protobuf.KogitoTypesProtobuf.JsonNode.class, org.jbpm.flow.serialization.protobuf.KogitoTypesProtobuf.JsonNode.Builder.class); + } + + public static final int CONTENT_FIELD_NUMBER = 1; + @SuppressWarnings("serial") + private volatile java.lang.Object content_ = ""; + + /** + * string content = 1; + * + * @return The content. + */ + @java.lang.Override + public java.lang.String getContent() { + java.lang.Object ref = content_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + content_ = s; + return s; + } + } + + /** + * string content = 1; + * + * @return The bytes for content. + */ + @java.lang.Override + public com.google.protobuf.ByteString + getContentBytes() { + java.lang.Object ref = content_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + content_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) + return true; + if (isInitialized == 0) + return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(content_)) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 1, content_); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) + return size; + + size = 0; + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(content_)) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, content_); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof org.jbpm.flow.serialization.protobuf.KogitoTypesProtobuf.JsonNode)) { + return super.equals(obj); + } + org.jbpm.flow.serialization.protobuf.KogitoTypesProtobuf.JsonNode other = (org.jbpm.flow.serialization.protobuf.KogitoTypesProtobuf.JsonNode) obj; + + if (!getContent() + .equals(other.getContent())) + return false; + if (!getUnknownFields().equals(other.getUnknownFields())) + return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + CONTENT_FIELD_NUMBER; + hash = (53 * hash) + getContent().hashCode(); + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static org.jbpm.flow.serialization.protobuf.KogitoTypesProtobuf.JsonNode parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static org.jbpm.flow.serialization.protobuf.KogitoTypesProtobuf.JsonNode parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static org.jbpm.flow.serialization.protobuf.KogitoTypesProtobuf.JsonNode parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static org.jbpm.flow.serialization.protobuf.KogitoTypesProtobuf.JsonNode parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static org.jbpm.flow.serialization.protobuf.KogitoTypesProtobuf.JsonNode parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static org.jbpm.flow.serialization.protobuf.KogitoTypesProtobuf.JsonNode parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static org.jbpm.flow.serialization.protobuf.KogitoTypesProtobuf.JsonNode parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + + public static org.jbpm.flow.serialization.protobuf.KogitoTypesProtobuf.JsonNode parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public static org.jbpm.flow.serialization.protobuf.KogitoTypesProtobuf.JsonNode parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + + public static org.jbpm.flow.serialization.protobuf.KogitoTypesProtobuf.JsonNode parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + + public static org.jbpm.flow.serialization.protobuf.KogitoTypesProtobuf.JsonNode parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + + public static org.jbpm.flow.serialization.protobuf.KogitoTypesProtobuf.JsonNode parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(org.jbpm.flow.serialization.protobuf.KogitoTypesProtobuf.JsonNode prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() + : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * Protobuf type {@code org.jbpm.flow.serialization.protobuf.JsonNode} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:org.jbpm.flow.serialization.protobuf.JsonNode) + org.jbpm.flow.serialization.protobuf.KogitoTypesProtobuf.JsonNodeOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.jbpm.flow.serialization.protobuf.KogitoTypesProtobuf.internal_static_org_jbpm_flow_serialization_protobuf_JsonNode_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.jbpm.flow.serialization.protobuf.KogitoTypesProtobuf.internal_static_org_jbpm_flow_serialization_protobuf_JsonNode_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.jbpm.flow.serialization.protobuf.KogitoTypesProtobuf.JsonNode.class, org.jbpm.flow.serialization.protobuf.KogitoTypesProtobuf.JsonNode.Builder.class); + } + + // Construct using org.jbpm.flow.serialization.protobuf.KogitoTypesProtobuf.JsonNode.newBuilder() + private Builder() { + + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + content_ = ""; + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.jbpm.flow.serialization.protobuf.KogitoTypesProtobuf.internal_static_org_jbpm_flow_serialization_protobuf_JsonNode_descriptor; + } + + @java.lang.Override + public org.jbpm.flow.serialization.protobuf.KogitoTypesProtobuf.JsonNode getDefaultInstanceForType() { + return org.jbpm.flow.serialization.protobuf.KogitoTypesProtobuf.JsonNode.getDefaultInstance(); + } + + @java.lang.Override + public org.jbpm.flow.serialization.protobuf.KogitoTypesProtobuf.JsonNode build() { + org.jbpm.flow.serialization.protobuf.KogitoTypesProtobuf.JsonNode result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public org.jbpm.flow.serialization.protobuf.KogitoTypesProtobuf.JsonNode buildPartial() { + org.jbpm.flow.serialization.protobuf.KogitoTypesProtobuf.JsonNode result = new org.jbpm.flow.serialization.protobuf.KogitoTypesProtobuf.JsonNode(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartial0(org.jbpm.flow.serialization.protobuf.KogitoTypesProtobuf.JsonNode result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.content_ = content_; + } + } + + @java.lang.Override + public Builder clone() { + return super.clone(); + } + + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.setField(field, value); + } + + @java.lang.Override + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + + @java.lang.Override + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.addRepeatedField(field, value); + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof org.jbpm.flow.serialization.protobuf.KogitoTypesProtobuf.JsonNode) { + return mergeFrom((org.jbpm.flow.serialization.protobuf.KogitoTypesProtobuf.JsonNode) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.jbpm.flow.serialization.protobuf.KogitoTypesProtobuf.JsonNode other) { + if (other == org.jbpm.flow.serialization.protobuf.KogitoTypesProtobuf.JsonNode.getDefaultInstance()) + return this; + if (!other.getContent().isEmpty()) { + content_ = other.content_; + bitField0_ |= 0x00000001; + onChanged(); + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: { + content_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000001; + break; + } // case 10 + default: { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int bitField0_; + + private java.lang.Object content_ = ""; + + /** + * string content = 1; + * + * @return The content. + */ + public java.lang.String getContent() { + java.lang.Object ref = content_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + content_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + + /** + * string content = 1; + * + * @return The bytes for content. + */ + public com.google.protobuf.ByteString + getContentBytes() { + java.lang.Object ref = content_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + content_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * string content = 1; + * + * @param value The content to set. + * @return This builder for chaining. + */ + public Builder setContent( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + content_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * string content = 1; + * + * @return This builder for chaining. + */ + public Builder clearContent() { + content_ = getDefaultInstance().getContent(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + return this; + } + + /** + * string content = 1; + * + * @param value The bytes for content to set. + * @return This builder for chaining. + */ + public Builder setContentBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + content_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + @java.lang.Override + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + // @@protoc_insertion_point(builder_scope:org.jbpm.flow.serialization.protobuf.JsonNode) + } + + // @@protoc_insertion_point(class_scope:org.jbpm.flow.serialization.protobuf.JsonNode) + private static final org.jbpm.flow.serialization.protobuf.KogitoTypesProtobuf.JsonNode DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new org.jbpm.flow.serialization.protobuf.KogitoTypesProtobuf.JsonNode(); + } + + public static org.jbpm.flow.serialization.protobuf.KogitoTypesProtobuf.JsonNode getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = new com.google.protobuf.AbstractParser() { + @java.lang.Override + public JsonNode parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public org.jbpm.flow.serialization.protobuf.KogitoTypesProtobuf.JsonNode getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + public interface DocumentOrBuilder extends + // @@protoc_insertion_point(interface_extends:org.jbpm.flow.serialization.protobuf.Document) com.google.protobuf.MessageOrBuilder { /** @@ -57,20 +665,20 @@ public interface JsonNodeOrBuilder extends } /** - * Protobuf type {@code org.jbpm.flow.serialization.protobuf.JsonNode} + * Protobuf type {@code org.jbpm.flow.serialization.protobuf.Document} */ - public static final class JsonNode extends + public static final class Document extends com.google.protobuf.GeneratedMessageV3 implements - // @@protoc_insertion_point(message_implements:org.jbpm.flow.serialization.protobuf.JsonNode) - JsonNodeOrBuilder { + // @@protoc_insertion_point(message_implements:org.jbpm.flow.serialization.protobuf.Document) + DocumentOrBuilder { private static final long serialVersionUID = 0L; - // Use JsonNode.newBuilder() to construct. - private JsonNode(com.google.protobuf.GeneratedMessageV3.Builder builder) { + // Use Document.newBuilder() to construct. + private Document(com.google.protobuf.GeneratedMessageV3.Builder builder) { super(builder); } - private JsonNode() { + private Document() { content_ = ""; } @@ -78,20 +686,20 @@ private JsonNode() { @SuppressWarnings({ "unused" }) protected java.lang.Object newInstance( UnusedPrivateParameter unused) { - return new JsonNode(); + return new Document(); } public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { - return org.jbpm.flow.serialization.protobuf.KogitoTypesProtobuf.internal_static_org_jbpm_flow_serialization_protobuf_JsonNode_descriptor; + return org.jbpm.flow.serialization.protobuf.KogitoTypesProtobuf.internal_static_org_jbpm_flow_serialization_protobuf_Document_descriptor; } @java.lang.Override protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable internalGetFieldAccessorTable() { - return org.jbpm.flow.serialization.protobuf.KogitoTypesProtobuf.internal_static_org_jbpm_flow_serialization_protobuf_JsonNode_fieldAccessorTable + return org.jbpm.flow.serialization.protobuf.KogitoTypesProtobuf.internal_static_org_jbpm_flow_serialization_protobuf_Document_fieldAccessorTable .ensureFieldAccessorsInitialized( - org.jbpm.flow.serialization.protobuf.KogitoTypesProtobuf.JsonNode.class, org.jbpm.flow.serialization.protobuf.KogitoTypesProtobuf.JsonNode.Builder.class); + org.jbpm.flow.serialization.protobuf.KogitoTypesProtobuf.Document.class, org.jbpm.flow.serialization.protobuf.KogitoTypesProtobuf.Document.Builder.class); } public static final int CONTENT_FIELD_NUMBER = 1; @@ -180,10 +788,10 @@ public boolean equals(final java.lang.Object obj) { if (obj == this) { return true; } - if (!(obj instanceof org.jbpm.flow.serialization.protobuf.KogitoTypesProtobuf.JsonNode)) { + if (!(obj instanceof org.jbpm.flow.serialization.protobuf.KogitoTypesProtobuf.Document)) { return super.equals(obj); } - org.jbpm.flow.serialization.protobuf.KogitoTypesProtobuf.JsonNode other = (org.jbpm.flow.serialization.protobuf.KogitoTypesProtobuf.JsonNode) obj; + org.jbpm.flow.serialization.protobuf.KogitoTypesProtobuf.Document other = (org.jbpm.flow.serialization.protobuf.KogitoTypesProtobuf.Document) obj; if (!getContent() .equals(other.getContent())) @@ -207,51 +815,51 @@ public int hashCode() { return hash; } - public static org.jbpm.flow.serialization.protobuf.KogitoTypesProtobuf.JsonNode parseFrom( + public static org.jbpm.flow.serialization.protobuf.KogitoTypesProtobuf.Document parseFrom( java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException { return PARSER.parseFrom(data); } - public static org.jbpm.flow.serialization.protobuf.KogitoTypesProtobuf.JsonNode parseFrom( + public static org.jbpm.flow.serialization.protobuf.KogitoTypesProtobuf.Document parseFrom( java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws com.google.protobuf.InvalidProtocolBufferException { return PARSER.parseFrom(data, extensionRegistry); } - public static org.jbpm.flow.serialization.protobuf.KogitoTypesProtobuf.JsonNode parseFrom( + public static org.jbpm.flow.serialization.protobuf.KogitoTypesProtobuf.Document parseFrom( com.google.protobuf.ByteString data) throws com.google.protobuf.InvalidProtocolBufferException { return PARSER.parseFrom(data); } - public static org.jbpm.flow.serialization.protobuf.KogitoTypesProtobuf.JsonNode parseFrom( + public static org.jbpm.flow.serialization.protobuf.KogitoTypesProtobuf.Document parseFrom( com.google.protobuf.ByteString data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws com.google.protobuf.InvalidProtocolBufferException { return PARSER.parseFrom(data, extensionRegistry); } - public static org.jbpm.flow.serialization.protobuf.KogitoTypesProtobuf.JsonNode parseFrom(byte[] data) + public static org.jbpm.flow.serialization.protobuf.KogitoTypesProtobuf.Document parseFrom(byte[] data) throws com.google.protobuf.InvalidProtocolBufferException { return PARSER.parseFrom(data); } - public static org.jbpm.flow.serialization.protobuf.KogitoTypesProtobuf.JsonNode parseFrom( + public static org.jbpm.flow.serialization.protobuf.KogitoTypesProtobuf.Document parseFrom( byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws com.google.protobuf.InvalidProtocolBufferException { return PARSER.parseFrom(data, extensionRegistry); } - public static org.jbpm.flow.serialization.protobuf.KogitoTypesProtobuf.JsonNode parseFrom(java.io.InputStream input) + public static org.jbpm.flow.serialization.protobuf.KogitoTypesProtobuf.Document parseFrom(java.io.InputStream input) throws java.io.IOException { return com.google.protobuf.GeneratedMessageV3 .parseWithIOException(PARSER, input); } - public static org.jbpm.flow.serialization.protobuf.KogitoTypesProtobuf.JsonNode parseFrom( + public static org.jbpm.flow.serialization.protobuf.KogitoTypesProtobuf.Document parseFrom( java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException { @@ -259,13 +867,13 @@ public static org.jbpm.flow.serialization.protobuf.KogitoTypesProtobuf.JsonNode .parseWithIOException(PARSER, input, extensionRegistry); } - public static org.jbpm.flow.serialization.protobuf.KogitoTypesProtobuf.JsonNode parseDelimitedFrom(java.io.InputStream input) + public static org.jbpm.flow.serialization.protobuf.KogitoTypesProtobuf.Document parseDelimitedFrom(java.io.InputStream input) throws java.io.IOException { return com.google.protobuf.GeneratedMessageV3 .parseDelimitedWithIOException(PARSER, input); } - public static org.jbpm.flow.serialization.protobuf.KogitoTypesProtobuf.JsonNode parseDelimitedFrom( + public static org.jbpm.flow.serialization.protobuf.KogitoTypesProtobuf.Document parseDelimitedFrom( java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException { @@ -273,14 +881,14 @@ public static org.jbpm.flow.serialization.protobuf.KogitoTypesProtobuf.JsonNode .parseDelimitedWithIOException(PARSER, input, extensionRegistry); } - public static org.jbpm.flow.serialization.protobuf.KogitoTypesProtobuf.JsonNode parseFrom( + public static org.jbpm.flow.serialization.protobuf.KogitoTypesProtobuf.Document parseFrom( com.google.protobuf.CodedInputStream input) throws java.io.IOException { return com.google.protobuf.GeneratedMessageV3 .parseWithIOException(PARSER, input); } - public static org.jbpm.flow.serialization.protobuf.KogitoTypesProtobuf.JsonNode parseFrom( + public static org.jbpm.flow.serialization.protobuf.KogitoTypesProtobuf.Document parseFrom( com.google.protobuf.CodedInputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException { @@ -297,7 +905,7 @@ public static Builder newBuilder() { return DEFAULT_INSTANCE.toBuilder(); } - public static Builder newBuilder(org.jbpm.flow.serialization.protobuf.KogitoTypesProtobuf.JsonNode prototype) { + public static Builder newBuilder(org.jbpm.flow.serialization.protobuf.KogitoTypesProtobuf.Document prototype) { return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); } @@ -316,26 +924,26 @@ protected Builder newBuilderForType( } /** - * Protobuf type {@code org.jbpm.flow.serialization.protobuf.JsonNode} + * Protobuf type {@code org.jbpm.flow.serialization.protobuf.Document} */ public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder implements - // @@protoc_insertion_point(builder_implements:org.jbpm.flow.serialization.protobuf.JsonNode) - org.jbpm.flow.serialization.protobuf.KogitoTypesProtobuf.JsonNodeOrBuilder { + // @@protoc_insertion_point(builder_implements:org.jbpm.flow.serialization.protobuf.Document) + org.jbpm.flow.serialization.protobuf.KogitoTypesProtobuf.DocumentOrBuilder { public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { - return org.jbpm.flow.serialization.protobuf.KogitoTypesProtobuf.internal_static_org_jbpm_flow_serialization_protobuf_JsonNode_descriptor; + return org.jbpm.flow.serialization.protobuf.KogitoTypesProtobuf.internal_static_org_jbpm_flow_serialization_protobuf_Document_descriptor; } @java.lang.Override protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable internalGetFieldAccessorTable() { - return org.jbpm.flow.serialization.protobuf.KogitoTypesProtobuf.internal_static_org_jbpm_flow_serialization_protobuf_JsonNode_fieldAccessorTable + return org.jbpm.flow.serialization.protobuf.KogitoTypesProtobuf.internal_static_org_jbpm_flow_serialization_protobuf_Document_fieldAccessorTable .ensureFieldAccessorsInitialized( - org.jbpm.flow.serialization.protobuf.KogitoTypesProtobuf.JsonNode.class, org.jbpm.flow.serialization.protobuf.KogitoTypesProtobuf.JsonNode.Builder.class); + org.jbpm.flow.serialization.protobuf.KogitoTypesProtobuf.Document.class, org.jbpm.flow.serialization.protobuf.KogitoTypesProtobuf.Document.Builder.class); } - // Construct using org.jbpm.flow.serialization.protobuf.KogitoTypesProtobuf.JsonNode.newBuilder() + // Construct using org.jbpm.flow.serialization.protobuf.KogitoTypesProtobuf.Document.newBuilder() private Builder() { } @@ -357,17 +965,17 @@ public Builder clear() { @java.lang.Override public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { - return org.jbpm.flow.serialization.protobuf.KogitoTypesProtobuf.internal_static_org_jbpm_flow_serialization_protobuf_JsonNode_descriptor; + return org.jbpm.flow.serialization.protobuf.KogitoTypesProtobuf.internal_static_org_jbpm_flow_serialization_protobuf_Document_descriptor; } @java.lang.Override - public org.jbpm.flow.serialization.protobuf.KogitoTypesProtobuf.JsonNode getDefaultInstanceForType() { - return org.jbpm.flow.serialization.protobuf.KogitoTypesProtobuf.JsonNode.getDefaultInstance(); + public org.jbpm.flow.serialization.protobuf.KogitoTypesProtobuf.Document getDefaultInstanceForType() { + return org.jbpm.flow.serialization.protobuf.KogitoTypesProtobuf.Document.getDefaultInstance(); } @java.lang.Override - public org.jbpm.flow.serialization.protobuf.KogitoTypesProtobuf.JsonNode build() { - org.jbpm.flow.serialization.protobuf.KogitoTypesProtobuf.JsonNode result = buildPartial(); + public org.jbpm.flow.serialization.protobuf.KogitoTypesProtobuf.Document build() { + org.jbpm.flow.serialization.protobuf.KogitoTypesProtobuf.Document result = buildPartial(); if (!result.isInitialized()) { throw newUninitializedMessageException(result); } @@ -375,8 +983,8 @@ public org.jbpm.flow.serialization.protobuf.KogitoTypesProtobuf.JsonNode build() } @java.lang.Override - public org.jbpm.flow.serialization.protobuf.KogitoTypesProtobuf.JsonNode buildPartial() { - org.jbpm.flow.serialization.protobuf.KogitoTypesProtobuf.JsonNode result = new org.jbpm.flow.serialization.protobuf.KogitoTypesProtobuf.JsonNode(this); + public org.jbpm.flow.serialization.protobuf.KogitoTypesProtobuf.Document buildPartial() { + org.jbpm.flow.serialization.protobuf.KogitoTypesProtobuf.Document result = new org.jbpm.flow.serialization.protobuf.KogitoTypesProtobuf.Document(this); if (bitField0_ != 0) { buildPartial0(result); } @@ -384,25 +992,63 @@ public org.jbpm.flow.serialization.protobuf.KogitoTypesProtobuf.JsonNode buildPa return result; } - private void buildPartial0(org.jbpm.flow.serialization.protobuf.KogitoTypesProtobuf.JsonNode result) { + private void buildPartial0(org.jbpm.flow.serialization.protobuf.KogitoTypesProtobuf.Document result) { int from_bitField0_ = bitField0_; if (((from_bitField0_ & 0x00000001) != 0)) { result.content_ = content_; } } + @java.lang.Override + public Builder clone() { + return super.clone(); + } + + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.setField(field, value); + } + + @java.lang.Override + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + + @java.lang.Override + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.addRepeatedField(field, value); + } + @java.lang.Override public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof org.jbpm.flow.serialization.protobuf.KogitoTypesProtobuf.JsonNode) { - return mergeFrom((org.jbpm.flow.serialization.protobuf.KogitoTypesProtobuf.JsonNode) other); + if (other instanceof org.jbpm.flow.serialization.protobuf.KogitoTypesProtobuf.Document) { + return mergeFrom((org.jbpm.flow.serialization.protobuf.KogitoTypesProtobuf.Document) other); } else { super.mergeFrom(other); return this; } } - public Builder mergeFrom(org.jbpm.flow.serialization.protobuf.KogitoTypesProtobuf.JsonNode other) { - if (other == org.jbpm.flow.serialization.protobuf.KogitoTypesProtobuf.JsonNode.getDefaultInstance()) + public Builder mergeFrom(org.jbpm.flow.serialization.protobuf.KogitoTypesProtobuf.Document other) { + if (other == org.jbpm.flow.serialization.protobuf.KogitoTypesProtobuf.Document.getDefaultInstance()) return this; if (!other.getContent().isEmpty()) { content_ = other.content_; @@ -556,22 +1202,22 @@ public final Builder mergeUnknownFields( return super.mergeUnknownFields(unknownFields); } - // @@protoc_insertion_point(builder_scope:org.jbpm.flow.serialization.protobuf.JsonNode) + // @@protoc_insertion_point(builder_scope:org.jbpm.flow.serialization.protobuf.Document) } - // @@protoc_insertion_point(class_scope:org.jbpm.flow.serialization.protobuf.JsonNode) - private static final org.jbpm.flow.serialization.protobuf.KogitoTypesProtobuf.JsonNode DEFAULT_INSTANCE; + // @@protoc_insertion_point(class_scope:org.jbpm.flow.serialization.protobuf.Document) + private static final org.jbpm.flow.serialization.protobuf.KogitoTypesProtobuf.Document DEFAULT_INSTANCE; static { - DEFAULT_INSTANCE = new org.jbpm.flow.serialization.protobuf.KogitoTypesProtobuf.JsonNode(); + DEFAULT_INSTANCE = new org.jbpm.flow.serialization.protobuf.KogitoTypesProtobuf.Document(); } - public static org.jbpm.flow.serialization.protobuf.KogitoTypesProtobuf.JsonNode getDefaultInstance() { + public static org.jbpm.flow.serialization.protobuf.KogitoTypesProtobuf.Document getDefaultInstance() { return DEFAULT_INSTANCE; } - private static final com.google.protobuf.Parser PARSER = new com.google.protobuf.AbstractParser() { + private static final com.google.protobuf.Parser PARSER = new com.google.protobuf.AbstractParser() { @java.lang.Override - public JsonNode parsePartialFrom( + public Document parsePartialFrom( com.google.protobuf.CodedInputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws com.google.protobuf.InvalidProtocolBufferException { @@ -590,17 +1236,17 @@ public JsonNode parsePartialFrom( } }; - public static com.google.protobuf.Parser parser() { + public static com.google.protobuf.Parser parser() { return PARSER; } @java.lang.Override - public com.google.protobuf.Parser getParserForType() { + public com.google.protobuf.Parser getParserForType() { return PARSER; } @java.lang.Override - public org.jbpm.flow.serialization.protobuf.KogitoTypesProtobuf.JsonNode getDefaultInstanceForType() { + public org.jbpm.flow.serialization.protobuf.KogitoTypesProtobuf.Document getDefaultInstanceForType() { return DEFAULT_INSTANCE; } @@ -1123,6 +1769,44 @@ private void buildPartial0(org.jbpm.flow.serialization.protobuf.KogitoTypesProto result.bitField0_ |= to_bitField0_; } + @java.lang.Override + public Builder clone() { + return super.clone(); + } + + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.setField(field, value); + } + + @java.lang.Override + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + + @java.lang.Override + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.addRepeatedField(field, value); + } + @java.lang.Override public Builder mergeFrom(com.google.protobuf.Message other) { if (other instanceof org.jbpm.flow.serialization.protobuf.KogitoTypesProtobuf.Variable) { @@ -1454,8 +2138,10 @@ public Builder mergeValue(com.google.protobuf.Any value) { } else { valueBuilder_.mergeFrom(value); } - bitField0_ |= 0x00000004; - onChanged(); + if (value_ != null) { + bitField0_ |= 0x00000004; + onChanged(); + } return this; } @@ -1807,7 +2493,7 @@ public java.lang.String getNodeId() { */ @java.lang.Override public boolean hasContent() { - return content_ != null; + return ((bitField0_ & 0x00000001) != 0); } /** @@ -1838,7 +2524,7 @@ public com.google.protobuf.AnyOrBuilder getContentOrBuilder() { */ @java.lang.Override public boolean hasLevel() { - return ((bitField0_ & 0x00000001) != 0); + return ((bitField0_ & 0x00000002) != 0); } /** @@ -1861,7 +2547,7 @@ public int getLevel() { */ @java.lang.Override public boolean hasTriggerDate() { - return ((bitField0_ & 0x00000002) != 0); + return ((bitField0_ & 0x00000004) != 0); } /** @@ -1884,7 +2570,7 @@ public long getTriggerDate() { */ @java.lang.Override public boolean hasSla() { - return ((bitField0_ & 0x00000004) != 0); + return ((bitField0_ & 0x00000008) != 0); } /** @@ -1928,16 +2614,16 @@ public void writeTo(com.google.protobuf.CodedOutputStream output) if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(nodeId_)) { com.google.protobuf.GeneratedMessageV3.writeString(output, 2, nodeId_); } - if (content_ != null) { + if (((bitField0_ & 0x00000001) != 0)) { output.writeMessage(3, getContent()); } - if (((bitField0_ & 0x00000001) != 0)) { + if (((bitField0_ & 0x00000002) != 0)) { output.writeInt32(4, level_); } - if (((bitField0_ & 0x00000002) != 0)) { + if (((bitField0_ & 0x00000004) != 0)) { output.writeInt64(5, triggerDate_); } - if (((bitField0_ & 0x00000004) != 0)) { + if (((bitField0_ & 0x00000008) != 0)) { output.writeMessage(6, getSla()); } getUnknownFields().writeTo(output); @@ -1956,19 +2642,19 @@ public int getSerializedSize() { if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(nodeId_)) { size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, nodeId_); } - if (content_ != null) { + if (((bitField0_ & 0x00000001) != 0)) { size += com.google.protobuf.CodedOutputStream .computeMessageSize(3, getContent()); } - if (((bitField0_ & 0x00000001) != 0)) { + if (((bitField0_ & 0x00000002) != 0)) { size += com.google.protobuf.CodedOutputStream .computeInt32Size(4, level_); } - if (((bitField0_ & 0x00000002) != 0)) { + if (((bitField0_ & 0x00000004) != 0)) { size += com.google.protobuf.CodedOutputStream .computeInt64Size(5, triggerDate_); } - if (((bitField0_ & 0x00000004) != 0)) { + if (((bitField0_ & 0x00000008) != 0)) { size += com.google.protobuf.CodedOutputStream .computeMessageSize(6, getSla()); } @@ -2262,29 +2948,68 @@ private void buildPartial0(org.jbpm.flow.serialization.protobuf.KogitoTypesProto if (((from_bitField0_ & 0x00000002) != 0)) { result.nodeId_ = nodeId_; } + int to_bitField0_ = 0; if (((from_bitField0_ & 0x00000004) != 0)) { result.content_ = contentBuilder_ == null ? content_ : contentBuilder_.build(); + to_bitField0_ |= 0x00000001; } - int to_bitField0_ = 0; if (((from_bitField0_ & 0x00000008) != 0)) { result.level_ = level_; - to_bitField0_ |= 0x00000001; + to_bitField0_ |= 0x00000002; } if (((from_bitField0_ & 0x00000010) != 0)) { result.triggerDate_ = triggerDate_; - to_bitField0_ |= 0x00000002; + to_bitField0_ |= 0x00000004; } if (((from_bitField0_ & 0x00000020) != 0)) { result.sla_ = slaBuilder_ == null ? sla_ : slaBuilder_.build(); - to_bitField0_ |= 0x00000004; + to_bitField0_ |= 0x00000008; } result.bitField0_ |= to_bitField0_; } + @java.lang.Override + public Builder clone() { + return super.clone(); + } + + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.setField(field, value); + } + + @java.lang.Override + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + + @java.lang.Override + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.addRepeatedField(field, value); + } + @java.lang.Override public Builder mergeFrom(com.google.protobuf.Message other) { if (other instanceof org.jbpm.flow.serialization.protobuf.KogitoTypesProtobuf.NodeInstance) { @@ -2642,8 +3367,10 @@ public Builder mergeContent(com.google.protobuf.Any value) { } else { contentBuilder_.mergeFrom(value); } - bitField0_ |= 0x00000004; - onChanged(); + if (content_ != null) { + bitField0_ |= 0x00000004; + onChanged(); + } return this; } @@ -2864,8 +3591,10 @@ public Builder mergeSla(org.jbpm.flow.serialization.protobuf.KogitoTypesProtobuf } else { slaBuilder_.mergeFrom(value); } - bitField0_ |= 0x00000020; - onChanged(); + if (sla_ != null) { + bitField0_ |= 0x00000020; + onChanged(); + } return this; } @@ -3686,6 +4415,44 @@ private void buildPartial0(org.jbpm.flow.serialization.protobuf.KogitoTypesProto int from_bitField0_ = bitField0_; } + @java.lang.Override + public Builder clone() { + return super.clone(); + } + + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.setField(field, value); + } + + @java.lang.Override + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + + @java.lang.Override + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.addRepeatedField(field, value); + } + @java.lang.Override public Builder mergeFrom(com.google.protobuf.Message other) { if (other instanceof org.jbpm.flow.serialization.protobuf.KogitoTypesProtobuf.WorkflowContext) { @@ -5469,6 +6236,44 @@ private void buildPartial0(org.jbpm.flow.serialization.protobuf.KogitoTypesProto result.bitField0_ |= to_bitField0_; } + @java.lang.Override + public Builder clone() { + return super.clone(); + } + + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.setField(field, value); + } + + @java.lang.Override + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + + @java.lang.Override + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.addRepeatedField(field, value); + } + @java.lang.Override public Builder mergeFrom(com.google.protobuf.Message other) { if (other instanceof org.jbpm.flow.serialization.protobuf.KogitoTypesProtobuf.SwimlaneContext) { @@ -6299,6 +7104,44 @@ private void buildPartial0(org.jbpm.flow.serialization.protobuf.KogitoTypesProto result.bitField0_ |= to_bitField0_; } + @java.lang.Override + public Builder clone() { + return super.clone(); + } + + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.setField(field, value); + } + + @java.lang.Override + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + + @java.lang.Override + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.addRepeatedField(field, value); + } + @java.lang.Override public Builder mergeFrom(com.google.protobuf.Message other) { if (other instanceof org.jbpm.flow.serialization.protobuf.KogitoTypesProtobuf.SLAContext) { @@ -7076,6 +7919,44 @@ private void buildPartial0(org.jbpm.flow.serialization.protobuf.KogitoTypesProto result.bitField0_ |= to_bitField0_; } + @java.lang.Override + public Builder clone() { + return super.clone(); + } + + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.setField(field, value); + } + + @java.lang.Override + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + + @java.lang.Override + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.addRepeatedField(field, value); + } + @java.lang.Override public Builder mergeFrom(com.google.protobuf.Message other) { if (other instanceof org.jbpm.flow.serialization.protobuf.KogitoTypesProtobuf.IterationLevel) { @@ -7741,6 +8622,44 @@ private void buildPartial0(org.jbpm.flow.serialization.protobuf.KogitoTypesProto } } + @java.lang.Override + public Builder clone() { + return super.clone(); + } + + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.setField(field, value); + } + + @java.lang.Override + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + + @java.lang.Override + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.addRepeatedField(field, value); + } + @java.lang.Override public Builder mergeFrom(com.google.protobuf.Message other) { if (other instanceof org.jbpm.flow.serialization.protobuf.KogitoTypesProtobuf.NodeInstanceGroup) { @@ -8015,6 +8934,8 @@ public org.jbpm.flow.serialization.protobuf.KogitoTypesProtobuf.NodeInstanceGrou private static final com.google.protobuf.Descriptors.Descriptor internal_static_org_jbpm_flow_serialization_protobuf_JsonNode_descriptor; private static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable internal_static_org_jbpm_flow_serialization_protobuf_JsonNode_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor internal_static_org_jbpm_flow_serialization_protobuf_Document_descriptor; + private static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable internal_static_org_jbpm_flow_serialization_protobuf_Document_fieldAccessorTable; private static final com.google.protobuf.Descriptors.Descriptor internal_static_org_jbpm_flow_serialization_protobuf_Variable_descriptor; private static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable internal_static_org_jbpm_flow_serialization_protobuf_Variable_fieldAccessorTable; private static final com.google.protobuf.Descriptors.Descriptor internal_static_org_jbpm_flow_serialization_protobuf_NodeInstance_descriptor; @@ -8041,34 +8962,34 @@ public org.jbpm.flow.serialization.protobuf.KogitoTypesProtobuf.NodeInstanceGrou "\n7org/jbpm/flow/serialization/protobuf/k" + "ogito_types.proto\022$org.jbpm.flow.seriali" + "zation.protobuf\032\031google/protobuf/any.pro" + - "to\"\033\n\010JsonNode\022\017\n\007content\030\001 \001(\t\"_\n\010Varia" + - "ble\022\014\n\004name\030\001 \001(\t\022\021\n\tdata_type\030\002 \001(\t\022(\n\005" + - "value\030\003 \001(\0132\024.google.protobuf.AnyH\000\210\001\001B\010" + - "\n\006_value\"\350\001\n\014NodeInstance\022\n\n\002id\030\001 \001(\t\022\017\n" + - "\007node_id\030\002 \001(\t\022%\n\007content\030\003 \001(\0132\024.google" + - ".protobuf.Any\022\022\n\005level\030\004 \001(\005H\000\210\001\001\022\031\n\014tri" + - "gger_date\030\005 \001(\003H\001\210\001\001\022B\n\003sla\030\006 \001(\01320.org." + - "jbpm.flow.serialization.protobuf.SLACont" + - "extH\002\210\001\001B\010\n\006_levelB\017\n\r_trigger_dateB\006\n\004_" + - "sla\"\277\002\n\017WorkflowContext\022@\n\010variable\030\001 \003(" + - "\0132..org.jbpm.flow.serialization.protobuf" + - ".Variable\022I\n\rnode_instance\030\002 \003(\01322.org.j" + - "bpm.flow.serialization.protobuf.NodeInst" + - "ance\022P\n\017exclusive_group\030\003 \003(\01327.org.jbpm" + - ".flow.serialization.protobuf.NodeInstanc" + - "eGroup\022M\n\017iterationLevels\030\004 \003(\01324.org.jb" + - "pm.flow.serialization.protobuf.Iteration" + - "Level\"Y\n\017SwimlaneContext\022\025\n\010swimlane\030\001 \001" + - "(\tH\000\210\001\001\022\025\n\010actor_id\030\002 \001(\tH\001\210\001\001B\013\n\t_swiml" + - "aneB\013\n\t_actor_id\"\224\001\n\nSLAContext\022\031\n\014sla_t" + - "imer_id\030\001 \001(\tH\000\210\001\001\022\031\n\014sla_due_date\030\002 \001(\003" + - "H\001\210\001\001\022\033\n\016sla_compliance\030\003 \001(\005H\002\210\001\001B\017\n\r_s" + - "la_timer_idB\017\n\r_sla_due_dateB\021\n\017_sla_com" + - "pliance\"F\n\016IterationLevel\022\017\n\002id\030\001 \001(\tH\000\210" + - "\001\001\022\022\n\005level\030\002 \001(\005H\001\210\001\001B\005\n\003_idB\010\n\006_level\"" + - "3\n\021NodeInstanceGroup\022\036\n\026group_node_insta" + - "nce_id\030\001 \003(\tB\025B\023KogitoTypesProtobufb\006pro" + - "to3" + "to\"\033\n\010JsonNode\022\017\n\007content\030\001 \001(\t\"\033\n\010Docum" + + "ent\022\017\n\007content\030\001 \001(\t\"_\n\010Variable\022\014\n\004name" + + "\030\001 \001(\t\022\021\n\tdata_type\030\002 \001(\t\022(\n\005value\030\003 \001(\013" + + "2\024.google.protobuf.AnyH\000\210\001\001B\010\n\006_value\"\350\001" + + "\n\014NodeInstance\022\n\n\002id\030\001 \001(\t\022\017\n\007node_id\030\002 " + + "\001(\t\022%\n\007content\030\003 \001(\0132\024.google.protobuf.A" + + "ny\022\022\n\005level\030\004 \001(\005H\000\210\001\001\022\031\n\014trigger_date\030\005" + + " \001(\003H\001\210\001\001\022B\n\003sla\030\006 \001(\01320.org.jbpm.flow.s" + + "erialization.protobuf.SLAContextH\002\210\001\001B\010\n" + + "\006_levelB\017\n\r_trigger_dateB\006\n\004_sla\"\277\002\n\017Wor" + + "kflowContext\022@\n\010variable\030\001 \003(\0132..org.jbp" + + "m.flow.serialization.protobuf.Variable\022I" + + "\n\rnode_instance\030\002 \003(\01322.org.jbpm.flow.se" + + "rialization.protobuf.NodeInstance\022P\n\017exc" + + "lusive_group\030\003 \003(\01327.org.jbpm.flow.seria" + + "lization.protobuf.NodeInstanceGroup\022M\n\017i" + + "terationLevels\030\004 \003(\01324.org.jbpm.flow.ser" + + "ialization.protobuf.IterationLevel\"Y\n\017Sw" + + "imlaneContext\022\025\n\010swimlane\030\001 \001(\tH\000\210\001\001\022\025\n\010" + + "actor_id\030\002 \001(\tH\001\210\001\001B\013\n\t_swimlaneB\013\n\t_act" + + "or_id\"\224\001\n\nSLAContext\022\031\n\014sla_timer_id\030\001 \001" + + "(\tH\000\210\001\001\022\031\n\014sla_due_date\030\002 \001(\003H\001\210\001\001\022\033\n\016sl" + + "a_compliance\030\003 \001(\005H\002\210\001\001B\017\n\r_sla_timer_id" + + "B\017\n\r_sla_due_dateB\021\n\017_sla_compliance\"F\n\016" + + "IterationLevel\022\017\n\002id\030\001 \001(\tH\000\210\001\001\022\022\n\005level" + + "\030\002 \001(\005H\001\210\001\001B\005\n\003_idB\010\n\006_level\"3\n\021NodeInst" + + "anceGroup\022\036\n\026group_node_instance_id\030\001 \003(" + + "\tB\025B\023KogitoTypesProtobufb\006proto3" }; descriptor = com.google.protobuf.Descriptors.FileDescriptor .internalBuildGeneratedFileFrom(descriptorData, @@ -8080,38 +9001,43 @@ public org.jbpm.flow.serialization.protobuf.KogitoTypesProtobuf.NodeInstanceGrou internal_static_org_jbpm_flow_serialization_protobuf_JsonNode_fieldAccessorTable = new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( internal_static_org_jbpm_flow_serialization_protobuf_JsonNode_descriptor, new java.lang.String[] { "Content", }); - internal_static_org_jbpm_flow_serialization_protobuf_Variable_descriptor = + internal_static_org_jbpm_flow_serialization_protobuf_Document_descriptor = getDescriptor().getMessageTypes().get(1); + internal_static_org_jbpm_flow_serialization_protobuf_Document_fieldAccessorTable = new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_org_jbpm_flow_serialization_protobuf_Document_descriptor, + new java.lang.String[] { "Content", }); + internal_static_org_jbpm_flow_serialization_protobuf_Variable_descriptor = + getDescriptor().getMessageTypes().get(2); internal_static_org_jbpm_flow_serialization_protobuf_Variable_fieldAccessorTable = new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( internal_static_org_jbpm_flow_serialization_protobuf_Variable_descriptor, - new java.lang.String[] { "Name", "DataType", "Value", "Value", }); + new java.lang.String[] { "Name", "DataType", "Value", }); internal_static_org_jbpm_flow_serialization_protobuf_NodeInstance_descriptor = - getDescriptor().getMessageTypes().get(2); + getDescriptor().getMessageTypes().get(3); internal_static_org_jbpm_flow_serialization_protobuf_NodeInstance_fieldAccessorTable = new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( internal_static_org_jbpm_flow_serialization_protobuf_NodeInstance_descriptor, - new java.lang.String[] { "Id", "NodeId", "Content", "Level", "TriggerDate", "Sla", "Level", "TriggerDate", "Sla", }); + new java.lang.String[] { "Id", "NodeId", "Content", "Level", "TriggerDate", "Sla", }); internal_static_org_jbpm_flow_serialization_protobuf_WorkflowContext_descriptor = - getDescriptor().getMessageTypes().get(3); + getDescriptor().getMessageTypes().get(4); internal_static_org_jbpm_flow_serialization_protobuf_WorkflowContext_fieldAccessorTable = new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( internal_static_org_jbpm_flow_serialization_protobuf_WorkflowContext_descriptor, new java.lang.String[] { "Variable", "NodeInstance", "ExclusiveGroup", "IterationLevels", }); internal_static_org_jbpm_flow_serialization_protobuf_SwimlaneContext_descriptor = - getDescriptor().getMessageTypes().get(4); + getDescriptor().getMessageTypes().get(5); internal_static_org_jbpm_flow_serialization_protobuf_SwimlaneContext_fieldAccessorTable = new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( internal_static_org_jbpm_flow_serialization_protobuf_SwimlaneContext_descriptor, - new java.lang.String[] { "Swimlane", "ActorId", "Swimlane", "ActorId", }); + new java.lang.String[] { "Swimlane", "ActorId", }); internal_static_org_jbpm_flow_serialization_protobuf_SLAContext_descriptor = - getDescriptor().getMessageTypes().get(5); + getDescriptor().getMessageTypes().get(6); internal_static_org_jbpm_flow_serialization_protobuf_SLAContext_fieldAccessorTable = new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( internal_static_org_jbpm_flow_serialization_protobuf_SLAContext_descriptor, - new java.lang.String[] { "SlaTimerId", "SlaDueDate", "SlaCompliance", "SlaTimerId", "SlaDueDate", "SlaCompliance", }); + new java.lang.String[] { "SlaTimerId", "SlaDueDate", "SlaCompliance", }); internal_static_org_jbpm_flow_serialization_protobuf_IterationLevel_descriptor = - getDescriptor().getMessageTypes().get(6); + getDescriptor().getMessageTypes().get(7); internal_static_org_jbpm_flow_serialization_protobuf_IterationLevel_fieldAccessorTable = new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( internal_static_org_jbpm_flow_serialization_protobuf_IterationLevel_descriptor, - new java.lang.String[] { "Id", "Level", "Id", "Level", }); + new java.lang.String[] { "Id", "Level", }); internal_static_org_jbpm_flow_serialization_protobuf_NodeInstanceGroup_descriptor = - getDescriptor().getMessageTypes().get(7); + getDescriptor().getMessageTypes().get(8); internal_static_org_jbpm_flow_serialization_protobuf_NodeInstanceGroup_fieldAccessorTable = new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( internal_static_org_jbpm_flow_serialization_protobuf_NodeInstanceGroup_descriptor, new java.lang.String[] { "GroupNodeInstanceId", }); diff --git a/jbpm/process-serialization-protobuf/src/main/java/org/jbpm/flow/serialization/protobuf/KogitoWorkItemsProtobuf.java b/jbpm/process-serialization-protobuf/src/main/java/org/jbpm/flow/serialization/protobuf/KogitoWorkItemsProtobuf.java index 277465a7155..fac37c8b677 100644 --- a/jbpm/process-serialization-protobuf/src/main/java/org/jbpm/flow/serialization/protobuf/KogitoWorkItemsProtobuf.java +++ b/jbpm/process-serialization-protobuf/src/main/java/org/jbpm/flow/serialization/protobuf/KogitoWorkItemsProtobuf.java @@ -1,25 +1,25 @@ -/** -* Licensed to the Apache Software Foundation (ASF) under one -* or more contributor license agreements. See the NOTICE file -* distributed with this work for additional information -* regarding copyright ownership. The ASF licenses this file -* to you under the Apache License, Version 2.0 (the -* "License"); you may not use this file except in compliance -* with the License. You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, -* software distributed under the License is distributed on an -* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -* KIND, either express or implied. See the License for the -* specific language governing permissions and limitations -* under the License. -*/ - +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ // Generated by the protocol buffer compiler. DO NOT EDIT! // source: org/jbpm/flow/serialization/protobuf/kogito_work_items.proto +// Protobuf Java Version: 3.25.0 package org.jbpm.flow.serialization.protobuf; public final class KogitoWorkItemsProtobuf { @@ -571,7 +571,7 @@ protected java.lang.Object newInstance( @SuppressWarnings({ "rawtypes" }) @java.lang.Override - protected com.google.protobuf.MapField internalGetMapField( + protected com.google.protobuf.MapFieldReflectionAccessor internalGetMapFieldReflection( int number) { switch (number) { case 13: @@ -2015,7 +2015,7 @@ public static final class Builder extends } @SuppressWarnings({ "rawtypes" }) - protected com.google.protobuf.MapField internalGetMapField( + protected com.google.protobuf.MapFieldReflectionAccessor internalGetMapFieldReflection( int number) { switch (number) { case 13: @@ -2033,7 +2033,7 @@ protected com.google.protobuf.MapField internalGetMapField( } @SuppressWarnings({ "rawtypes" }) - protected com.google.protobuf.MapField internalGetMutableMapField( + protected com.google.protobuf.MapFieldReflectionAccessor internalGetMutableMapFieldReflection( int number) { switch (number) { case 13: @@ -2207,24 +2207,58 @@ private void buildPartial0(org.jbpm.flow.serialization.protobuf.KogitoWorkItemsP to_bitField0_ |= 0x00000010; } if (((from_bitField0_ & 0x00001000) != 0)) { - result.startDeadlines_ = internalGetStartDeadlines(); - result.startDeadlines_.makeImmutable(); + result.startDeadlines_ = internalGetStartDeadlines().build(StartDeadlinesDefaultEntryHolder.defaultEntry); } if (((from_bitField0_ & 0x00002000) != 0)) { - result.completedDeadlines_ = internalGetCompletedDeadlines(); - result.completedDeadlines_.makeImmutable(); + result.completedDeadlines_ = internalGetCompletedDeadlines().build(CompletedDeadlinesDefaultEntryHolder.defaultEntry); } if (((from_bitField0_ & 0x00004000) != 0)) { - result.startReassigments_ = internalGetStartReassigments(); - result.startReassigments_.makeImmutable(); + result.startReassigments_ = internalGetStartReassigments().build(StartReassigmentsDefaultEntryHolder.defaultEntry); } if (((from_bitField0_ & 0x00008000) != 0)) { - result.completedReassigments_ = internalGetCompletedReassigments(); - result.completedReassigments_.makeImmutable(); + result.completedReassigments_ = internalGetCompletedReassigments().build(CompletedReassigmentsDefaultEntryHolder.defaultEntry); } result.bitField0_ |= to_bitField0_; } + @java.lang.Override + public Builder clone() { + return super.clone(); + } + + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.setField(field, value); + } + + @java.lang.Override + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + + @java.lang.Override + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.addRepeatedField(field, value); + } + @java.lang.Override public Builder mergeFrom(com.google.protobuf.Message other) { if (other instanceof org.jbpm.flow.serialization.protobuf.KogitoWorkItemsProtobuf.HumanTaskWorkItemData) { @@ -2485,7 +2519,7 @@ public Builder mergeFrom( case 106: { com.google.protobuf.MapEntry startDeadlines__ = input.readMessage( StartDeadlinesDefaultEntryHolder.defaultEntry.getParserForType(), extensionRegistry); - internalGetMutableStartDeadlines().getMutableMap().put( + internalGetMutableStartDeadlines().ensureBuilderMap().put( startDeadlines__.getKey(), startDeadlines__.getValue()); bitField0_ |= 0x00001000; break; @@ -2493,7 +2527,7 @@ public Builder mergeFrom( case 114: { com.google.protobuf.MapEntry completedDeadlines__ = input.readMessage( CompletedDeadlinesDefaultEntryHolder.defaultEntry.getParserForType(), extensionRegistry); - internalGetMutableCompletedDeadlines().getMutableMap().put( + internalGetMutableCompletedDeadlines().ensureBuilderMap().put( completedDeadlines__.getKey(), completedDeadlines__.getValue()); bitField0_ |= 0x00002000; break; @@ -2501,7 +2535,7 @@ public Builder mergeFrom( case 122: { com.google.protobuf.MapEntry startReassigments__ = input.readMessage( StartReassigmentsDefaultEntryHolder.defaultEntry.getParserForType(), extensionRegistry); - internalGetMutableStartReassigments().getMutableMap().put( + internalGetMutableStartReassigments().ensureBuilderMap().put( startReassigments__.getKey(), startReassigments__.getValue()); bitField0_ |= 0x00004000; break; @@ -2509,7 +2543,7 @@ public Builder mergeFrom( case 130: { com.google.protobuf.MapEntry completedReassigments__ = input.readMessage( CompletedReassigmentsDefaultEntryHolder.defaultEntry.getParserForType(), extensionRegistry); - internalGetMutableCompletedReassigments().getMutableMap().put( + internalGetMutableCompletedReassigments().ensureBuilderMap().put( completedReassigments__.getKey(), completedReassigments__.getValue()); bitField0_ |= 0x00008000; break; @@ -4208,25 +4242,38 @@ public org.jbpm.flow.serialization.protobuf.KogitoWorkItemsProtobuf.Attachment.B return attachmentsBuilder_; } - private com.google.protobuf.MapField startDeadlines_; + private static final class StartDeadlinesConverter implements + com.google.protobuf.MapFieldBuilder.Converter { + @java.lang.Override + public org.jbpm.flow.serialization.protobuf.KogitoWorkItemsProtobuf.Deadline build(org.jbpm.flow.serialization.protobuf.KogitoWorkItemsProtobuf.DeadlineOrBuilder val) { + if (val instanceof org.jbpm.flow.serialization.protobuf.KogitoWorkItemsProtobuf.Deadline) { + return (org.jbpm.flow.serialization.protobuf.KogitoWorkItemsProtobuf.Deadline) val; + } + return ((org.jbpm.flow.serialization.protobuf.KogitoWorkItemsProtobuf.Deadline.Builder) val).build(); + } + + @java.lang.Override + public com.google.protobuf.MapEntry defaultEntry() { + return StartDeadlinesDefaultEntryHolder.defaultEntry; + } + }; - private com.google.protobuf.MapField + private static final StartDeadlinesConverter startDeadlinesConverter = new StartDeadlinesConverter(); + + private com.google.protobuf.MapFieldBuilder startDeadlines_; + + private com.google.protobuf.MapFieldBuilder internalGetStartDeadlines() { if (startDeadlines_ == null) { - return com.google.protobuf.MapField.emptyMapField( - StartDeadlinesDefaultEntryHolder.defaultEntry); + return new com.google.protobuf.MapFieldBuilder<>(startDeadlinesConverter); } return startDeadlines_; } - private com.google.protobuf.MapField + private com.google.protobuf.MapFieldBuilder internalGetMutableStartDeadlines() { if (startDeadlines_ == null) { - startDeadlines_ = com.google.protobuf.MapField.newMapField( - StartDeadlinesDefaultEntryHolder.defaultEntry); - } - if (!startDeadlines_.isMutable()) { - startDeadlines_ = startDeadlines_.copy(); + startDeadlines_ = new com.google.protobuf.MapFieldBuilder<>(startDeadlinesConverter); } bitField0_ |= 0x00001000; onChanged(); @@ -4234,7 +4281,7 @@ public org.jbpm.flow.serialization.protobuf.KogitoWorkItemsProtobuf.Attachment.B } public int getStartDeadlinesCount() { - return internalGetStartDeadlines().getMap().size(); + return internalGetStartDeadlines().ensureBuilderMap().size(); } /** @@ -4246,7 +4293,7 @@ public boolean containsStartDeadlines( if (key == null) { throw new NullPointerException("map key"); } - return internalGetStartDeadlines().getMap().containsKey(key); + return internalGetStartDeadlines().ensureBuilderMap().containsKey(key); } /** @@ -4263,7 +4310,7 @@ public java.util.Map getStartDeadlinesMap() { - return internalGetStartDeadlines().getMap(); + return internalGetStartDeadlines().getImmutableMap(); } /** @@ -4278,9 +4325,8 @@ org.jbpm.flow.serialization.protobuf.KogitoWorkItemsProtobuf.Deadline getStartDe if (key == null) { throw new NullPointerException("map key"); } - java.util.Map map = - internalGetStartDeadlines().getMap(); - return map.containsKey(key) ? map.get(key) : defaultValue; + java.util.Map map = internalGetMutableStartDeadlines().ensureBuilderMap(); + return map.containsKey(key) ? startDeadlinesConverter.build(map.get(key)) : defaultValue; } /** @@ -4292,18 +4338,16 @@ public org.jbpm.flow.serialization.protobuf.KogitoWorkItemsProtobuf.Deadline get if (key == null) { throw new NullPointerException("map key"); } - java.util.Map map = - internalGetStartDeadlines().getMap(); + java.util.Map map = internalGetMutableStartDeadlines().ensureBuilderMap(); if (!map.containsKey(key)) { throw new java.lang.IllegalArgumentException(); } - return map.get(key); + return startDeadlinesConverter.build(map.get(key)); } public Builder clearStartDeadlines() { bitField0_ = (bitField0_ & ~0x00001000); - internalGetMutableStartDeadlines().getMutableMap() - .clear(); + internalGetMutableStartDeadlines().clear(); return this; } @@ -4315,7 +4359,7 @@ public Builder removeStartDeadlines( if (key == null) { throw new NullPointerException("map key"); } - internalGetMutableStartDeadlines().getMutableMap() + internalGetMutableStartDeadlines().ensureBuilderMap() .remove(key); return this; } @@ -4327,7 +4371,7 @@ public Builder removeStartDeadlines( public java.util.Map getMutableStartDeadlines() { bitField0_ |= 0x00001000; - return internalGetMutableStartDeadlines().getMutableMap(); + return internalGetMutableStartDeadlines().ensureMessageMap(); } /** @@ -4342,7 +4386,7 @@ public Builder putStartDeadlines( if (value == null) { throw new NullPointerException("map value"); } - internalGetMutableStartDeadlines().getMutableMap() + internalGetMutableStartDeadlines().ensureBuilderMap() .put(key, value); bitField0_ |= 0x00001000; return this; @@ -4353,31 +4397,67 @@ public Builder putStartDeadlines( */ public Builder putAllStartDeadlines( java.util.Map values) { - internalGetMutableStartDeadlines().getMutableMap() + for (java.util.Map.Entry e : values.entrySet()) { + if (e.getKey() == null || e.getValue() == null) { + throw new NullPointerException(); + } + } + internalGetMutableStartDeadlines().ensureBuilderMap() .putAll(values); bitField0_ |= 0x00001000; return this; } - private com.google.protobuf.MapField completedDeadlines_; + /** + * map<string, .org.jbpm.flow.serialization.protobuf.Deadline> start_deadlines = 13; + */ + public org.jbpm.flow.serialization.protobuf.KogitoWorkItemsProtobuf.Deadline.Builder putStartDeadlinesBuilderIfAbsent( + java.lang.String key) { + java.util.Map builderMap = internalGetMutableStartDeadlines().ensureBuilderMap(); + org.jbpm.flow.serialization.protobuf.KogitoWorkItemsProtobuf.DeadlineOrBuilder entry = builderMap.get(key); + if (entry == null) { + entry = org.jbpm.flow.serialization.protobuf.KogitoWorkItemsProtobuf.Deadline.newBuilder(); + builderMap.put(key, entry); + } + if (entry instanceof org.jbpm.flow.serialization.protobuf.KogitoWorkItemsProtobuf.Deadline) { + entry = ((org.jbpm.flow.serialization.protobuf.KogitoWorkItemsProtobuf.Deadline) entry).toBuilder(); + builderMap.put(key, entry); + } + return (org.jbpm.flow.serialization.protobuf.KogitoWorkItemsProtobuf.Deadline.Builder) entry; + } + + private static final class CompletedDeadlinesConverter implements + com.google.protobuf.MapFieldBuilder.Converter { + @java.lang.Override + public org.jbpm.flow.serialization.protobuf.KogitoWorkItemsProtobuf.Deadline build(org.jbpm.flow.serialization.protobuf.KogitoWorkItemsProtobuf.DeadlineOrBuilder val) { + if (val instanceof org.jbpm.flow.serialization.protobuf.KogitoWorkItemsProtobuf.Deadline) { + return (org.jbpm.flow.serialization.protobuf.KogitoWorkItemsProtobuf.Deadline) val; + } + return ((org.jbpm.flow.serialization.protobuf.KogitoWorkItemsProtobuf.Deadline.Builder) val).build(); + } + + @java.lang.Override + public com.google.protobuf.MapEntry defaultEntry() { + return CompletedDeadlinesDefaultEntryHolder.defaultEntry; + } + }; + + private static final CompletedDeadlinesConverter completedDeadlinesConverter = new CompletedDeadlinesConverter(); + + private com.google.protobuf.MapFieldBuilder completedDeadlines_; - private com.google.protobuf.MapField + private com.google.protobuf.MapFieldBuilder internalGetCompletedDeadlines() { if (completedDeadlines_ == null) { - return com.google.protobuf.MapField.emptyMapField( - CompletedDeadlinesDefaultEntryHolder.defaultEntry); + return new com.google.protobuf.MapFieldBuilder<>(completedDeadlinesConverter); } return completedDeadlines_; } - private com.google.protobuf.MapField + private com.google.protobuf.MapFieldBuilder internalGetMutableCompletedDeadlines() { if (completedDeadlines_ == null) { - completedDeadlines_ = com.google.protobuf.MapField.newMapField( - CompletedDeadlinesDefaultEntryHolder.defaultEntry); - } - if (!completedDeadlines_.isMutable()) { - completedDeadlines_ = completedDeadlines_.copy(); + completedDeadlines_ = new com.google.protobuf.MapFieldBuilder<>(completedDeadlinesConverter); } bitField0_ |= 0x00002000; onChanged(); @@ -4385,7 +4465,7 @@ public Builder putAllStartDeadlines( } public int getCompletedDeadlinesCount() { - return internalGetCompletedDeadlines().getMap().size(); + return internalGetCompletedDeadlines().ensureBuilderMap().size(); } /** @@ -4397,7 +4477,7 @@ public boolean containsCompletedDeadlines( if (key == null) { throw new NullPointerException("map key"); } - return internalGetCompletedDeadlines().getMap().containsKey(key); + return internalGetCompletedDeadlines().ensureBuilderMap().containsKey(key); } /** @@ -4414,7 +4494,7 @@ public java.util.Map getCompletedDeadlinesMap() { - return internalGetCompletedDeadlines().getMap(); + return internalGetCompletedDeadlines().getImmutableMap(); } /** @@ -4429,9 +4509,8 @@ org.jbpm.flow.serialization.protobuf.KogitoWorkItemsProtobuf.Deadline getComplet if (key == null) { throw new NullPointerException("map key"); } - java.util.Map map = - internalGetCompletedDeadlines().getMap(); - return map.containsKey(key) ? map.get(key) : defaultValue; + java.util.Map map = internalGetMutableCompletedDeadlines().ensureBuilderMap(); + return map.containsKey(key) ? completedDeadlinesConverter.build(map.get(key)) : defaultValue; } /** @@ -4443,18 +4522,16 @@ public org.jbpm.flow.serialization.protobuf.KogitoWorkItemsProtobuf.Deadline get if (key == null) { throw new NullPointerException("map key"); } - java.util.Map map = - internalGetCompletedDeadlines().getMap(); + java.util.Map map = internalGetMutableCompletedDeadlines().ensureBuilderMap(); if (!map.containsKey(key)) { throw new java.lang.IllegalArgumentException(); } - return map.get(key); + return completedDeadlinesConverter.build(map.get(key)); } public Builder clearCompletedDeadlines() { bitField0_ = (bitField0_ & ~0x00002000); - internalGetMutableCompletedDeadlines().getMutableMap() - .clear(); + internalGetMutableCompletedDeadlines().clear(); return this; } @@ -4466,7 +4543,7 @@ public Builder removeCompletedDeadlines( if (key == null) { throw new NullPointerException("map key"); } - internalGetMutableCompletedDeadlines().getMutableMap() + internalGetMutableCompletedDeadlines().ensureBuilderMap() .remove(key); return this; } @@ -4478,7 +4555,7 @@ public Builder removeCompletedDeadlines( public java.util.Map getMutableCompletedDeadlines() { bitField0_ |= 0x00002000; - return internalGetMutableCompletedDeadlines().getMutableMap(); + return internalGetMutableCompletedDeadlines().ensureMessageMap(); } /** @@ -4493,7 +4570,7 @@ public Builder putCompletedDeadlines( if (value == null) { throw new NullPointerException("map value"); } - internalGetMutableCompletedDeadlines().getMutableMap() + internalGetMutableCompletedDeadlines().ensureBuilderMap() .put(key, value); bitField0_ |= 0x00002000; return this; @@ -4504,31 +4581,67 @@ public Builder putCompletedDeadlines( */ public Builder putAllCompletedDeadlines( java.util.Map values) { - internalGetMutableCompletedDeadlines().getMutableMap() + for (java.util.Map.Entry e : values.entrySet()) { + if (e.getKey() == null || e.getValue() == null) { + throw new NullPointerException(); + } + } + internalGetMutableCompletedDeadlines().ensureBuilderMap() .putAll(values); bitField0_ |= 0x00002000; return this; } - private com.google.protobuf.MapField startReassigments_; + /** + * map<string, .org.jbpm.flow.serialization.protobuf.Deadline> completed_deadlines = 14; + */ + public org.jbpm.flow.serialization.protobuf.KogitoWorkItemsProtobuf.Deadline.Builder putCompletedDeadlinesBuilderIfAbsent( + java.lang.String key) { + java.util.Map builderMap = internalGetMutableCompletedDeadlines().ensureBuilderMap(); + org.jbpm.flow.serialization.protobuf.KogitoWorkItemsProtobuf.DeadlineOrBuilder entry = builderMap.get(key); + if (entry == null) { + entry = org.jbpm.flow.serialization.protobuf.KogitoWorkItemsProtobuf.Deadline.newBuilder(); + builderMap.put(key, entry); + } + if (entry instanceof org.jbpm.flow.serialization.protobuf.KogitoWorkItemsProtobuf.Deadline) { + entry = ((org.jbpm.flow.serialization.protobuf.KogitoWorkItemsProtobuf.Deadline) entry).toBuilder(); + builderMap.put(key, entry); + } + return (org.jbpm.flow.serialization.protobuf.KogitoWorkItemsProtobuf.Deadline.Builder) entry; + } - private com.google.protobuf.MapField + private static final class StartReassigmentsConverter implements + com.google.protobuf.MapFieldBuilder.Converter { + @java.lang.Override + public org.jbpm.flow.serialization.protobuf.KogitoWorkItemsProtobuf.Reassignment build(org.jbpm.flow.serialization.protobuf.KogitoWorkItemsProtobuf.ReassignmentOrBuilder val) { + if (val instanceof org.jbpm.flow.serialization.protobuf.KogitoWorkItemsProtobuf.Reassignment) { + return (org.jbpm.flow.serialization.protobuf.KogitoWorkItemsProtobuf.Reassignment) val; + } + return ((org.jbpm.flow.serialization.protobuf.KogitoWorkItemsProtobuf.Reassignment.Builder) val).build(); + } + + @java.lang.Override + public com.google.protobuf.MapEntry defaultEntry() { + return StartReassigmentsDefaultEntryHolder.defaultEntry; + } + }; + + private static final StartReassigmentsConverter startReassigmentsConverter = new StartReassigmentsConverter(); + + private com.google.protobuf.MapFieldBuilder startReassigments_; + + private com.google.protobuf.MapFieldBuilder internalGetStartReassigments() { if (startReassigments_ == null) { - return com.google.protobuf.MapField.emptyMapField( - StartReassigmentsDefaultEntryHolder.defaultEntry); + return new com.google.protobuf.MapFieldBuilder<>(startReassigmentsConverter); } return startReassigments_; } - private com.google.protobuf.MapField + private com.google.protobuf.MapFieldBuilder internalGetMutableStartReassigments() { if (startReassigments_ == null) { - startReassigments_ = com.google.protobuf.MapField.newMapField( - StartReassigmentsDefaultEntryHolder.defaultEntry); - } - if (!startReassigments_.isMutable()) { - startReassigments_ = startReassigments_.copy(); + startReassigments_ = new com.google.protobuf.MapFieldBuilder<>(startReassigmentsConverter); } bitField0_ |= 0x00004000; onChanged(); @@ -4536,7 +4649,7 @@ public Builder putAllCompletedDeadlines( } public int getStartReassigmentsCount() { - return internalGetStartReassigments().getMap().size(); + return internalGetStartReassigments().ensureBuilderMap().size(); } /** @@ -4548,7 +4661,7 @@ public boolean containsStartReassigments( if (key == null) { throw new NullPointerException("map key"); } - return internalGetStartReassigments().getMap().containsKey(key); + return internalGetStartReassigments().ensureBuilderMap().containsKey(key); } /** @@ -4565,7 +4678,7 @@ public java.util.Map getStartReassigmentsMap() { - return internalGetStartReassigments().getMap(); + return internalGetStartReassigments().getImmutableMap(); } /** @@ -4580,9 +4693,8 @@ org.jbpm.flow.serialization.protobuf.KogitoWorkItemsProtobuf.Reassignment getSta if (key == null) { throw new NullPointerException("map key"); } - java.util.Map map = - internalGetStartReassigments().getMap(); - return map.containsKey(key) ? map.get(key) : defaultValue; + java.util.Map map = internalGetMutableStartReassigments().ensureBuilderMap(); + return map.containsKey(key) ? startReassigmentsConverter.build(map.get(key)) : defaultValue; } /** @@ -4594,18 +4706,16 @@ public org.jbpm.flow.serialization.protobuf.KogitoWorkItemsProtobuf.Reassignment if (key == null) { throw new NullPointerException("map key"); } - java.util.Map map = - internalGetStartReassigments().getMap(); + java.util.Map map = internalGetMutableStartReassigments().ensureBuilderMap(); if (!map.containsKey(key)) { throw new java.lang.IllegalArgumentException(); } - return map.get(key); + return startReassigmentsConverter.build(map.get(key)); } public Builder clearStartReassigments() { bitField0_ = (bitField0_ & ~0x00004000); - internalGetMutableStartReassigments().getMutableMap() - .clear(); + internalGetMutableStartReassigments().clear(); return this; } @@ -4617,7 +4727,7 @@ public Builder removeStartReassigments( if (key == null) { throw new NullPointerException("map key"); } - internalGetMutableStartReassigments().getMutableMap() + internalGetMutableStartReassigments().ensureBuilderMap() .remove(key); return this; } @@ -4629,7 +4739,7 @@ public Builder removeStartReassigments( public java.util.Map getMutableStartReassigments() { bitField0_ |= 0x00004000; - return internalGetMutableStartReassigments().getMutableMap(); + return internalGetMutableStartReassigments().ensureMessageMap(); } /** @@ -4644,7 +4754,7 @@ public Builder putStartReassigments( if (value == null) { throw new NullPointerException("map value"); } - internalGetMutableStartReassigments().getMutableMap() + internalGetMutableStartReassigments().ensureBuilderMap() .put(key, value); bitField0_ |= 0x00004000; return this; @@ -4655,31 +4765,68 @@ public Builder putStartReassigments( */ public Builder putAllStartReassigments( java.util.Map values) { - internalGetMutableStartReassigments().getMutableMap() + for (java.util.Map.Entry e : values.entrySet()) { + if (e.getKey() == null || e.getValue() == null) { + throw new NullPointerException(); + } + } + internalGetMutableStartReassigments().ensureBuilderMap() .putAll(values); bitField0_ |= 0x00004000; return this; } - private com.google.protobuf.MapField completedReassigments_; + /** + * map<string, .org.jbpm.flow.serialization.protobuf.Reassignment> start_reassigments = 15; + */ + public org.jbpm.flow.serialization.protobuf.KogitoWorkItemsProtobuf.Reassignment.Builder putStartReassigmentsBuilderIfAbsent( + java.lang.String key) { + java.util.Map builderMap = + internalGetMutableStartReassigments().ensureBuilderMap(); + org.jbpm.flow.serialization.protobuf.KogitoWorkItemsProtobuf.ReassignmentOrBuilder entry = builderMap.get(key); + if (entry == null) { + entry = org.jbpm.flow.serialization.protobuf.KogitoWorkItemsProtobuf.Reassignment.newBuilder(); + builderMap.put(key, entry); + } + if (entry instanceof org.jbpm.flow.serialization.protobuf.KogitoWorkItemsProtobuf.Reassignment) { + entry = ((org.jbpm.flow.serialization.protobuf.KogitoWorkItemsProtobuf.Reassignment) entry).toBuilder(); + builderMap.put(key, entry); + } + return (org.jbpm.flow.serialization.protobuf.KogitoWorkItemsProtobuf.Reassignment.Builder) entry; + } + + private static final class CompletedReassigmentsConverter implements + com.google.protobuf.MapFieldBuilder.Converter { + @java.lang.Override + public org.jbpm.flow.serialization.protobuf.KogitoWorkItemsProtobuf.Reassignment build(org.jbpm.flow.serialization.protobuf.KogitoWorkItemsProtobuf.ReassignmentOrBuilder val) { + if (val instanceof org.jbpm.flow.serialization.protobuf.KogitoWorkItemsProtobuf.Reassignment) { + return (org.jbpm.flow.serialization.protobuf.KogitoWorkItemsProtobuf.Reassignment) val; + } + return ((org.jbpm.flow.serialization.protobuf.KogitoWorkItemsProtobuf.Reassignment.Builder) val).build(); + } + + @java.lang.Override + public com.google.protobuf.MapEntry defaultEntry() { + return CompletedReassigmentsDefaultEntryHolder.defaultEntry; + } + }; + + private static final CompletedReassigmentsConverter completedReassigmentsConverter = new CompletedReassigmentsConverter(); + + private com.google.protobuf.MapFieldBuilder completedReassigments_; - private com.google.protobuf.MapField + private com.google.protobuf.MapFieldBuilder internalGetCompletedReassigments() { if (completedReassigments_ == null) { - return com.google.protobuf.MapField.emptyMapField( - CompletedReassigmentsDefaultEntryHolder.defaultEntry); + return new com.google.protobuf.MapFieldBuilder<>(completedReassigmentsConverter); } return completedReassigments_; } - private com.google.protobuf.MapField + private com.google.protobuf.MapFieldBuilder internalGetMutableCompletedReassigments() { if (completedReassigments_ == null) { - completedReassigments_ = com.google.protobuf.MapField.newMapField( - CompletedReassigmentsDefaultEntryHolder.defaultEntry); - } - if (!completedReassigments_.isMutable()) { - completedReassigments_ = completedReassigments_.copy(); + completedReassigments_ = new com.google.protobuf.MapFieldBuilder<>(completedReassigmentsConverter); } bitField0_ |= 0x00008000; onChanged(); @@ -4687,7 +4834,7 @@ public Builder putAllStartReassigments( } public int getCompletedReassigmentsCount() { - return internalGetCompletedReassigments().getMap().size(); + return internalGetCompletedReassigments().ensureBuilderMap().size(); } /** @@ -4699,7 +4846,7 @@ public boolean containsCompletedReassigments( if (key == null) { throw new NullPointerException("map key"); } - return internalGetCompletedReassigments().getMap().containsKey(key); + return internalGetCompletedReassigments().ensureBuilderMap().containsKey(key); } /** @@ -4716,7 +4863,7 @@ public java.util.Map getCompletedReassigmentsMap() { - return internalGetCompletedReassigments().getMap(); + return internalGetCompletedReassigments().getImmutableMap(); } /** @@ -4731,9 +4878,8 @@ org.jbpm.flow.serialization.protobuf.KogitoWorkItemsProtobuf.Reassignment getCom if (key == null) { throw new NullPointerException("map key"); } - java.util.Map map = - internalGetCompletedReassigments().getMap(); - return map.containsKey(key) ? map.get(key) : defaultValue; + java.util.Map map = internalGetMutableCompletedReassigments().ensureBuilderMap(); + return map.containsKey(key) ? completedReassigmentsConverter.build(map.get(key)) : defaultValue; } /** @@ -4745,18 +4891,16 @@ public org.jbpm.flow.serialization.protobuf.KogitoWorkItemsProtobuf.Reassignment if (key == null) { throw new NullPointerException("map key"); } - java.util.Map map = - internalGetCompletedReassigments().getMap(); + java.util.Map map = internalGetMutableCompletedReassigments().ensureBuilderMap(); if (!map.containsKey(key)) { throw new java.lang.IllegalArgumentException(); } - return map.get(key); + return completedReassigmentsConverter.build(map.get(key)); } public Builder clearCompletedReassigments() { bitField0_ = (bitField0_ & ~0x00008000); - internalGetMutableCompletedReassigments().getMutableMap() - .clear(); + internalGetMutableCompletedReassigments().clear(); return this; } @@ -4768,7 +4912,7 @@ public Builder removeCompletedReassigments( if (key == null) { throw new NullPointerException("map key"); } - internalGetMutableCompletedReassigments().getMutableMap() + internalGetMutableCompletedReassigments().ensureBuilderMap() .remove(key); return this; } @@ -4780,7 +4924,7 @@ public Builder removeCompletedReassigments( public java.util.Map getMutableCompletedReassigments() { bitField0_ |= 0x00008000; - return internalGetMutableCompletedReassigments().getMutableMap(); + return internalGetMutableCompletedReassigments().ensureMessageMap(); } /** @@ -4795,7 +4939,7 @@ public Builder putCompletedReassigments( if (value == null) { throw new NullPointerException("map value"); } - internalGetMutableCompletedReassigments().getMutableMap() + internalGetMutableCompletedReassigments().ensureBuilderMap() .put(key, value); bitField0_ |= 0x00008000; return this; @@ -4806,12 +4950,36 @@ public Builder putCompletedReassigments( */ public Builder putAllCompletedReassigments( java.util.Map values) { - internalGetMutableCompletedReassigments().getMutableMap() + for (java.util.Map.Entry e : values.entrySet()) { + if (e.getKey() == null || e.getValue() == null) { + throw new NullPointerException(); + } + } + internalGetMutableCompletedReassigments().ensureBuilderMap() .putAll(values); bitField0_ |= 0x00008000; return this; } + /** + * map<string, .org.jbpm.flow.serialization.protobuf.Reassignment> completed_reassigments = 16; + */ + public org.jbpm.flow.serialization.protobuf.KogitoWorkItemsProtobuf.Reassignment.Builder putCompletedReassigmentsBuilderIfAbsent( + java.lang.String key) { + java.util.Map builderMap = + internalGetMutableCompletedReassigments().ensureBuilderMap(); + org.jbpm.flow.serialization.protobuf.KogitoWorkItemsProtobuf.ReassignmentOrBuilder entry = builderMap.get(key); + if (entry == null) { + entry = org.jbpm.flow.serialization.protobuf.KogitoWorkItemsProtobuf.Reassignment.newBuilder(); + builderMap.put(key, entry); + } + if (entry instanceof org.jbpm.flow.serialization.protobuf.KogitoWorkItemsProtobuf.Reassignment) { + entry = ((org.jbpm.flow.serialization.protobuf.KogitoWorkItemsProtobuf.Reassignment) entry).toBuilder(); + builderMap.put(key, entry); + } + return (org.jbpm.flow.serialization.protobuf.KogitoWorkItemsProtobuf.Reassignment.Builder) entry; + } + @java.lang.Override public final Builder setUnknownFields( final com.google.protobuf.UnknownFieldSet unknownFields) { @@ -5488,6 +5656,44 @@ private void buildPartial0(org.jbpm.flow.serialization.protobuf.KogitoWorkItemsP result.bitField0_ |= to_bitField0_; } + @java.lang.Override + public Builder clone() { + return super.clone(); + } + + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.setField(field, value); + } + + @java.lang.Override + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + + @java.lang.Override + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.addRepeatedField(field, value); + } + @java.lang.Override public Builder mergeFrom(com.google.protobuf.Message other) { if (other instanceof org.jbpm.flow.serialization.protobuf.KogitoWorkItemsProtobuf.Comment) { @@ -6681,6 +6887,44 @@ private void buildPartial0(org.jbpm.flow.serialization.protobuf.KogitoWorkItemsP result.bitField0_ |= to_bitField0_; } + @java.lang.Override + public Builder clone() { + return super.clone(); + } + + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.setField(field, value); + } + + @java.lang.Override + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + + @java.lang.Override + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.addRepeatedField(field, value); + } + @java.lang.Override public Builder mergeFrom(com.google.protobuf.Message other) { if (other instanceof org.jbpm.flow.serialization.protobuf.KogitoWorkItemsProtobuf.Attachment) { @@ -7342,7 +7586,7 @@ protected java.lang.Object newInstance( @SuppressWarnings({ "rawtypes" }) @java.lang.Override - protected com.google.protobuf.MapField internalGetMapField( + protected com.google.protobuf.MapFieldReflectionAccessor internalGetMapFieldReflection( int number) { switch (number) { case 1: @@ -7653,7 +7897,7 @@ public static final class Builder extends } @SuppressWarnings({ "rawtypes" }) - protected com.google.protobuf.MapField internalGetMapField( + protected com.google.protobuf.MapFieldReflectionAccessor internalGetMapFieldReflection( int number) { switch (number) { case 1: @@ -7665,7 +7909,7 @@ protected com.google.protobuf.MapField internalGetMapField( } @SuppressWarnings({ "rawtypes" }) - protected com.google.protobuf.MapField internalGetMutableMapField( + protected com.google.protobuf.MapFieldReflectionAccessor internalGetMutableMapFieldReflection( int number) { switch (number) { case 1: @@ -7741,6 +7985,44 @@ private void buildPartial0(org.jbpm.flow.serialization.protobuf.KogitoWorkItemsP } } + @java.lang.Override + public Builder clone() { + return super.clone(); + } + + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.setField(field, value); + } + + @java.lang.Override + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + + @java.lang.Override + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.addRepeatedField(field, value); + } + @java.lang.Override public Builder mergeFrom(com.google.protobuf.Message other) { if (other instanceof org.jbpm.flow.serialization.protobuf.KogitoWorkItemsProtobuf.Deadline) { @@ -8510,6 +8792,44 @@ private void buildPartial0(org.jbpm.flow.serialization.protobuf.KogitoWorkItemsP } } + @java.lang.Override + public Builder clone() { + return super.clone(); + } + + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.setField(field, value); + } + + @java.lang.Override + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + + @java.lang.Override + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.addRepeatedField(field, value); + } + @java.lang.Override public Builder mergeFrom(com.google.protobuf.Message other) { if (other instanceof org.jbpm.flow.serialization.protobuf.KogitoWorkItemsProtobuf.Reassignment) { @@ -9025,8 +9345,7 @@ public org.jbpm.flow.serialization.protobuf.KogitoWorkItemsProtobuf.Reassignment internal_static_org_jbpm_flow_serialization_protobuf_HumanTaskWorkItemData_fieldAccessorTable = new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( internal_static_org_jbpm_flow_serialization_protobuf_HumanTaskWorkItemData_descriptor, new java.lang.String[] { "TaskName", "TaskDescription", "TaskPriority", "ActualOwner", "PotUsers", "PotGroups", "ExcludedUsers", "AdminUsers", "AdminGroups", "TaskReferenceName", - "Comments", "Attachments", "StartDeadlines", "CompletedDeadlines", "StartReassigments", "CompletedReassigments", "TaskName", "TaskDescription", "TaskPriority", "ActualOwner", - "TaskReferenceName", }); + "Comments", "Attachments", "StartDeadlines", "CompletedDeadlines", "StartReassigments", "CompletedReassigments", }); internal_static_org_jbpm_flow_serialization_protobuf_HumanTaskWorkItemData_StartDeadlinesEntry_descriptor = internal_static_org_jbpm_flow_serialization_protobuf_HumanTaskWorkItemData_descriptor.getNestedTypes().get(0); internal_static_org_jbpm_flow_serialization_protobuf_HumanTaskWorkItemData_StartDeadlinesEntry_fieldAccessorTable = new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( @@ -9051,12 +9370,12 @@ public org.jbpm.flow.serialization.protobuf.KogitoWorkItemsProtobuf.Reassignment getDescriptor().getMessageTypes().get(1); internal_static_org_jbpm_flow_serialization_protobuf_Comment_fieldAccessorTable = new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( internal_static_org_jbpm_flow_serialization_protobuf_Comment_descriptor, - new java.lang.String[] { "Id", "Content", "UpdatedAt", "UpdatedBy", "Content", "UpdatedAt", "UpdatedBy", }); + new java.lang.String[] { "Id", "Content", "UpdatedAt", "UpdatedBy", }); internal_static_org_jbpm_flow_serialization_protobuf_Attachment_descriptor = getDescriptor().getMessageTypes().get(2); internal_static_org_jbpm_flow_serialization_protobuf_Attachment_fieldAccessorTable = new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( internal_static_org_jbpm_flow_serialization_protobuf_Attachment_descriptor, - new java.lang.String[] { "Id", "Content", "UpdatedAt", "UpdatedBy", "Name", "Content", "UpdatedAt", "UpdatedBy", "Name", }); + new java.lang.String[] { "Id", "Content", "UpdatedAt", "UpdatedBy", "Name", }); internal_static_org_jbpm_flow_serialization_protobuf_Deadline_descriptor = getDescriptor().getMessageTypes().get(3); internal_static_org_jbpm_flow_serialization_protobuf_Deadline_fieldAccessorTable = new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( diff --git a/jbpm/process-serialization-protobuf/src/main/resources/META-INF/services/org.jbpm.flow.serialization.ObjectMarshallerStrategy b/jbpm/process-serialization-protobuf/src/main/resources/META-INF/services/org.jbpm.flow.serialization.ObjectMarshallerStrategy index ed8d8a019ed..854682475fa 100644 --- a/jbpm/process-serialization-protobuf/src/main/resources/META-INF/services/org.jbpm.flow.serialization.ObjectMarshallerStrategy +++ b/jbpm/process-serialization-protobuf/src/main/resources/META-INF/services/org.jbpm.flow.serialization.ObjectMarshallerStrategy @@ -26,3 +26,4 @@ org.jbpm.flow.serialization.impl.marshallers.ProtobufIntegerMarshallerStrategy org.jbpm.flow.serialization.impl.marshallers.ProtobufDateMarshallerStrategy org.jbpm.flow.serialization.impl.marshallers.ProtobufDoubleMarshallerStrategy org.jbpm.flow.serialization.impl.marshallers.ProtobufJsonNodeMessageMarshaller +org.jbpm.flow.serialization.impl.marshallers.ProtobufDocumentNodeMessageMarshaller diff --git a/jbpm/process-serialization-protobuf/src/main/resources/org/jbpm/flow/serialization/protobuf/kogito_types.proto b/jbpm/process-serialization-protobuf/src/main/resources/org/jbpm/flow/serialization/protobuf/kogito_types.proto index 91fc4357c52..2bde0599716 100644 --- a/jbpm/process-serialization-protobuf/src/main/resources/org/jbpm/flow/serialization/protobuf/kogito_types.proto +++ b/jbpm/process-serialization-protobuf/src/main/resources/org/jbpm/flow/serialization/protobuf/kogito_types.proto @@ -29,6 +29,10 @@ message JsonNode { string content = 1; } +message Document { + string content = 1; +} + message Variable { string name = 1; string data_type = 2; diff --git a/jbpm/process-serialization-protobuf/src/test/java/org/jbpm/flow/serialization/ProcessInstanceMarshallTest.java b/jbpm/process-serialization-protobuf/src/test/java/org/jbpm/flow/serialization/ProcessInstanceMarshallTest.java index 4fb09ea4f5d..427311a1eaa 100644 --- a/jbpm/process-serialization-protobuf/src/test/java/org/jbpm/flow/serialization/ProcessInstanceMarshallTest.java +++ b/jbpm/process-serialization-protobuf/src/test/java/org/jbpm/flow/serialization/ProcessInstanceMarshallTest.java @@ -21,6 +21,7 @@ import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.Serializable; +import java.io.StringWriter; import java.math.BigDecimal; import java.sql.Timestamp; import java.time.Duration; @@ -29,14 +30,19 @@ import java.time.LocalDateTime; import java.time.OffsetDateTime; import java.time.ZonedDateTime; -import java.util.ArrayList; -import java.util.Collections; +import java.util.Comparator; import java.util.Date; import java.util.List; -import java.util.ServiceLoader; import java.util.stream.Collectors; import java.util.stream.Stream; +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.transform.Transformer; +import javax.xml.transform.TransformerFactory; +import javax.xml.transform.dom.DOMSource; +import javax.xml.transform.stream.StreamResult; + import org.jbpm.flow.serialization.impl.ProtobufMarshallerReaderContext; import org.jbpm.flow.serialization.impl.ProtobufProcessInstanceReader; import org.jbpm.flow.serialization.impl.ProtobufProcessInstanceWriter; @@ -62,9 +68,13 @@ import org.junit.jupiter.params.provider.NullSource; import org.kie.kogito.internal.process.runtime.KogitoProcessRuntime; import org.kie.kogito.process.impl.AbstractProcess; +import org.w3c.dom.Document; import com.fasterxml.jackson.databind.ObjectMapper; +import jakarta.xml.bind.JAXBContext; +import jakarta.xml.bind.annotation.XmlRootElement; + import static java.util.Collections.singletonMap; import static org.assertj.core.api.Assertions.assertThat; import static org.kie.kogito.internal.process.runtime.KogitoWorkflowProcess.RULEFLOW_TYPE; @@ -113,6 +123,7 @@ public static void init() { when(process.get()).thenReturn(workflow); } + @XmlRootElement public static class MarshableObject implements Serializable { private static final long serialVersionUID = 1481370154514125687L; @@ -167,6 +178,16 @@ private static RuleFlowProcessInstance buildInstance(boolean orphan) { } private static Stream testRoundTrip() throws Exception { + MarshableObject marshableObject = new MarshableObject("henry"); + JAXBContext jaxbContext = JAXBContext.newInstance(MarshableObject.class); + jakarta.xml.bind.Marshaller jaxbMarshaller = jaxbContext.createMarshaller(); + + jaxbMarshaller.setProperty(jakarta.xml.bind.Marshaller.JAXB_FORMATTED_OUTPUT, true); + DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); + DocumentBuilder db = dbf.newDocumentBuilder(); + Document document = db.newDocument(); + jaxbMarshaller.marshal(marshableObject, document); + return Stream.of( Arguments.of(1), Arguments.of("hello"), @@ -177,7 +198,7 @@ private static Stream testRoundTrip() throws Exception { Arguments.of(BigDecimal.valueOf(10l)), Arguments.of(new MarshableObject("henry")), Arguments.of(new ObjectMapper().readTree("{ \"key\" : \"value\" }")), - Arguments.of(new ObjectMapper().valueToTree(new MarshableObject("henry"))), + Arguments.of(new ObjectMapper().valueToTree(marshableObject)), Arguments.of(new Date()), Arguments.of(Instant.now()), Arguments.of(OffsetDateTime.now()), @@ -185,9 +206,8 @@ private static Stream testRoundTrip() throws Exception { Arguments.of(LocalDate.now()), Arguments.of(ZonedDateTime.now()), Arguments.of(new Timestamp(System.currentTimeMillis())), - Arguments.of(Duration.ofDays(1)) - - ); + Arguments.of(Duration.ofDays(1)), + Arguments.of(document)); } @ParameterizedTest @@ -195,7 +215,7 @@ private static Stream testRoundTrip() throws Exception { public void testProcessInstanceMarshalling(RuleFlowProcessInstance toMarshall) throws Exception { ByteArrayOutputStream out = new ByteArrayOutputStream(); ProtobufProcessMarshallerWriteContext ctxOut = new ProtobufProcessMarshallerWriteContext(out); - ctxOut.set(MarshallerContextName.OBJECT_MARSHALLING_STRATEGIES, defaultStrategies()); + ctxOut.set(MarshallerContextName.OBJECT_MARSHALLING_STRATEGIES, ObjectMarshallerStrategyHelper.defaultStrategies()); ctxOut.set(MarshallerContextName.MARSHALLER_PROCESS, process); ProtobufProcessInstanceWriter writer = new ProtobufProcessInstanceWriter(ctxOut); @@ -204,7 +224,7 @@ public void testProcessInstanceMarshalling(RuleFlowProcessInstance toMarshall) t ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray()); ProtobufMarshallerReaderContext ctxIn = new ProtobufMarshallerReaderContext(in); - ctxIn.set(MarshallerContextName.OBJECT_MARSHALLING_STRATEGIES, defaultStrategies()); + ctxIn.set(MarshallerContextName.OBJECT_MARSHALLING_STRATEGIES, ObjectMarshallerStrategyHelper.defaultStrategies()); ctxIn.set(MarshallerContextName.MARSHALLER_PROCESS, process); ProtobufProcessInstanceReader reader = new ProtobufProcessInstanceReader(ctxIn); RuleFlowProcessInstance unmarshalled = reader.read(in); @@ -228,29 +248,42 @@ public void testProcessInstanceMarshalling(RuleFlowProcessInstance toMarshall) t public void testRoundTrip(Object toMarshall) { ByteArrayOutputStream out = new ByteArrayOutputStream(); ProtobufProcessMarshallerWriteContext ctxOut = new ProtobufProcessMarshallerWriteContext(out); - ctxOut.set(MarshallerContextName.OBJECT_MARSHALLING_STRATEGIES, defaultStrategies()); + ctxOut.set(MarshallerContextName.OBJECT_MARSHALLING_STRATEGIES, ObjectMarshallerStrategyHelper.defaultStrategies()); ctxOut.set(MarshallerContextName.MARSHALLER_PROCESS, process); ProtobufVariableWriter writer = new ProtobufVariableWriter(ctxOut); List variables = writer.buildVariables(singletonMap("var", toMarshall).entrySet().stream().collect(Collectors.toList())); ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray()); ProtobufMarshallerReaderContext ctxIn = new ProtobufMarshallerReaderContext(in); - ctxIn.set(MarshallerContextName.OBJECT_MARSHALLING_STRATEGIES, defaultStrategies()); + ctxIn.set(MarshallerContextName.OBJECT_MARSHALLING_STRATEGIES, ObjectMarshallerStrategyHelper.defaultStrategies()); ctxIn.set(MarshallerContextName.MARSHALLER_PROCESS, process); ProtobufVariableReader reader = new ProtobufVariableReader(ctxIn); List unmarshalledVars = reader.buildVariables(variables); assertThat(unmarshalledVars).hasSize(1); - assertThat(unmarshalledVars.get(0).getValue()).isEqualTo(toMarshall); + assertThat(unmarshalledVars.get(0).getValue()) + .usingComparatorForType(new DocumentComparator(), Document.class) + .usingRecursiveComparison() + .isEqualTo(toMarshall); } - private ObjectMarshallerStrategy[] defaultStrategies() { - List strats = new ArrayList<>(); - ServiceLoader loader = ServiceLoader.load(ObjectMarshallerStrategy.class); + public class DocumentComparator implements Comparator { - for (ObjectMarshallerStrategy strategy : loader) { - strats.add(strategy); + @Override + public int compare(Document doc1, Document doc2) { + return toXml(doc1).compareTo(toXml(doc2)); } - Collections.sort(strats); - return strats.stream().toArray(ObjectMarshallerStrategy[]::new); } + + private String toXml(Document document) { + try { + TransformerFactory tf = TransformerFactory.newInstance(); + Transformer trans = tf.newTransformer(); + StringWriter sw = new StringWriter(); + trans.transform(new DOMSource(document), new StreamResult(sw)); + return sw.toString(); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + } diff --git a/kogito-codegen-modules/kogito-codegen-processes/src/main/java/org/kie/kogito/codegen/process/persistence/proto/AbstractProtoGenerator.java b/kogito-codegen-modules/kogito-codegen-processes/src/main/java/org/kie/kogito/codegen/process/persistence/proto/AbstractProtoGenerator.java index 462e555a05f..b7e55ec8369 100644 --- a/kogito-codegen-modules/kogito-codegen-processes/src/main/java/org/kie/kogito/codegen/process/persistence/proto/AbstractProtoGenerator.java +++ b/kogito-codegen-modules/kogito-codegen-processes/src/main/java/org/kie/kogito/codegen/process/persistence/proto/AbstractProtoGenerator.java @@ -19,10 +19,14 @@ package org.kie.kogito.codegen.process.persistence.proto; import java.io.IOException; +import java.io.Serializable; import java.io.UncheckedIOException; +import java.lang.reflect.Constructor; +import java.time.Instant; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; +import java.util.Date; import java.util.HashSet; import java.util.List; import java.util.Optional; @@ -30,13 +34,20 @@ import java.util.stream.Collectors; import org.drools.codegen.common.GeneratedFile; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.w3c.dom.Document; +import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; import static java.lang.String.format; public abstract class AbstractProtoGenerator implements ProtoGenerator { + private static final Logger LOGGER = LoggerFactory.getLogger(AbstractProtoGenerator.class); + + protected static final List PROTO_BUILTINS = List.of(JsonNode.class.getName(), Document.class.getName()); private static final String GENERATED_PROTO_RES_PATH = "persistence/protobuf/"; private static final String LISTING_FILE = "list.json"; @@ -55,6 +66,11 @@ public Proto protoOfDataClasses(String packageName, String... headers) { return generate(null, null, packageName, dataClasses, headers); } + @Override + public List protoBuiltins() { + return PROTO_BUILTINS; + } + @Override public Collection generateProtoFiles() { validateClasses(); @@ -94,6 +110,10 @@ private void validateClasses() { protected abstract boolean isEnum(T dataModel); + protected Optional fqn(T dataModel) { + return extractName(dataModel); + } + protected abstract Optional extractName(T dataModel); protected abstract ProtoEnum enumFromClass(Proto proto, T clazz) throws Exception; @@ -148,8 +168,10 @@ protected Proto generate(String messageComment, String fieldComment, String pack protected Proto generate(String messageComment, String fieldComment, String packageName, Collection dataModels, String... headers) { Proto proto = new Proto(packageName, headers); Set alreadyGenerated = new HashSet<>(); - for (T dataModel : dataModels) { + alreadyGenerated.addAll(protoBuiltins()); + for (T dataModel : dataModels.stream().filter(this::filterDataModels).toList()) { try { + LOGGER.debug("internal proto geneartion {}", fqn(dataModel)); internalGenerate( proto, alreadyGenerated, @@ -163,6 +185,15 @@ protected Proto generate(String messageComment, String fieldComment, String pack return proto; } + private boolean filterDataModels(T type) { + Optional stringType = fqn(type); + if (stringType.isEmpty()) { + return false; + } + + return !protoBuiltins().contains(stringType.get()); + } + protected abstract String modelClassName(T dataModel); protected Optional internalGenerate(Proto proto, Set alreadyGenerated, String messageComment, String fieldComment, T dataModel) throws Exception { @@ -200,4 +231,78 @@ public Builder withDataClasses(Collection dataClasses) { return this; } } + + protected String computeCardinalityModifier(String type) { + if (type.equals(COLLECTION) || type.equals(ARRAY)) { + return "repeated"; + } + + return "optional"; + } + + protected String protoType(String type) { + if (protoBuiltins().contains(type)) { + return null; + } + LOGGER.debug("Computing proto type for {}", type); + + if (String.class.getCanonicalName().equals(type) || String.class.getSimpleName().equalsIgnoreCase(type)) { + return "string"; + } else if (Integer.class.getCanonicalName().equals(type) || "int".equalsIgnoreCase(type)) { + return "int32"; + } else if (Long.class.getCanonicalName().equals(type) || "long".equalsIgnoreCase(type)) { + return "int64"; + } else if (Double.class.getCanonicalName().equals(type) || "double".equalsIgnoreCase(type)) { + return "double"; + } else if (Float.class.getCanonicalName().equals(type) || "float".equalsIgnoreCase(type)) { + return "float"; + } else if (Boolean.class.getCanonicalName().equals(type) || "boolean".equalsIgnoreCase(type)) { + return "bool"; + } else if (Date.class.getCanonicalName().equals(type) || "date".equalsIgnoreCase(type)) { + return "kogito.Date"; + } else if (byte[].class.getCanonicalName().equals(type) || "[B".equalsIgnoreCase(type)) { + return "bytes"; + } else if (Instant.class.getCanonicalName().equals(type)) { + return "kogito.Instant"; + } else if (type.startsWith("java.lang") || type.startsWith("java.util") || type.startsWith("java.time") || type.startsWith("java.math")) { + try { + Class cls = Class.forName(type); + if (cls.isInterface()) { + return null; + } + boolean assignable = Serializable.class.isAssignableFrom(cls); + if (assignable) { + return KOGITO_SERIALIZABLE; + } else { + throw new IllegalArgumentException(format("Java type %s is no supported by Kogito persistence, please consider using a class that extends java.io.Serializable", type)); + } + } catch (ClassNotFoundException e) { + return null; + } + } else { + try { + Class cls = Class.forName(type); + if (cls.isEnum() || hasDefaultConstructor(cls)) { + return null; + } else if (Serializable.class.isAssignableFrom(cls)) { + return KOGITO_SERIALIZABLE; + } else { + throw new IllegalArgumentException( + format("Custom type %s is no supported by Kogito persistence, please consider using a class that extends java.io.Serializable and contains a no arg constructor", type)); + } + } catch (ClassNotFoundException e) { + return null; + } + } + } + + protected boolean hasDefaultConstructor(Class cls) { + for (Constructor c : cls.getConstructors()) { + if (c.getParameterCount() == 0) { + return true; + } + } + return false; + } + } diff --git a/kogito-codegen-modules/kogito-codegen-processes/src/main/java/org/kie/kogito/codegen/process/persistence/proto/ProtoGenerator.java b/kogito-codegen-modules/kogito-codegen-processes/src/main/java/org/kie/kogito/codegen/process/persistence/proto/ProtoGenerator.java index 3edcbf9ac63..9009a29c7ec 100644 --- a/kogito-codegen-modules/kogito-codegen-processes/src/main/java/org/kie/kogito/codegen/process/persistence/proto/ProtoGenerator.java +++ b/kogito-codegen-modules/kogito-codegen-processes/src/main/java/org/kie/kogito/codegen/process/persistence/proto/ProtoGenerator.java @@ -18,19 +18,12 @@ */ package org.kie.kogito.codegen.process.persistence.proto; -import java.io.Serializable; -import java.lang.reflect.Constructor; -import java.time.Instant; import java.util.Collection; -import java.util.Date; +import java.util.List; import org.drools.codegen.common.GeneratedFile; import org.drools.codegen.common.GeneratedFileType; -import com.fasterxml.jackson.databind.JsonNode; - -import static java.lang.String.format; - public interface ProtoGenerator { GeneratedFileType PROTO_TYPE = GeneratedFileType.of("PROTO", GeneratedFileType.Category.STATIC_HTTP_RESOURCE); @@ -44,75 +37,7 @@ public interface ProtoGenerator { Collection generateProtoFiles(); - default String applicabilityByType(String type) { - if (type.equals(COLLECTION) || type.equals(ARRAY)) { - return "repeated"; - } - - return "optional"; - } - - default String protoType(String type) { - if (String.class.getCanonicalName().equals(type) || String.class.getSimpleName().equalsIgnoreCase(type)) { - return "string"; - } else if (Integer.class.getCanonicalName().equals(type) || "int".equalsIgnoreCase(type)) { - return "int32"; - } else if (Long.class.getCanonicalName().equals(type) || "long".equalsIgnoreCase(type)) { - return "int64"; - } else if (Double.class.getCanonicalName().equals(type) || "double".equalsIgnoreCase(type)) { - return "double"; - } else if (Float.class.getCanonicalName().equals(type) || "float".equalsIgnoreCase(type)) { - return "float"; - } else if (Boolean.class.getCanonicalName().equals(type) || "boolean".equalsIgnoreCase(type)) { - return "bool"; - } else if (Date.class.getCanonicalName().equals(type) || "date".equalsIgnoreCase(type)) { - return "kogito.Date"; - } else if (byte[].class.getCanonicalName().equals(type) || "[B".equalsIgnoreCase(type)) { - return "bytes"; - } else if (Instant.class.getCanonicalName().equals(type)) { - return "kogito.Instant"; - } else if (JsonNode.class.getCanonicalName().equals(type)) { - return KOGITO_SERIALIZABLE; - } else if (type.startsWith("java.lang") || type.startsWith("java.util") || type.startsWith("java.time") || type.startsWith("java.math")) { - try { - Class cls = Class.forName(type); - if (cls.isInterface()) { - return null; - } - boolean assignable = Serializable.class.isAssignableFrom(cls); - if (assignable) { - return KOGITO_SERIALIZABLE; - } else { - throw new IllegalArgumentException(format("Java type %s is no supported by Kogito persistence, please consider using a class that extends java.io.Serializable", type)); - } - } catch (ClassNotFoundException e) { - return null; - } - } else { - try { - Class cls = Class.forName(type); - if (cls.isEnum() || containsValidConstructor(cls)) { - return null; - } else if (Serializable.class.isAssignableFrom(cls)) { - return KOGITO_SERIALIZABLE; - } else { - throw new IllegalArgumentException( - format("Custom type %s is no supported by Kogito persistence, please consider using a class that extends java.io.Serializable and contains a no arg constructor", type)); - } - } catch (ClassNotFoundException e) { - return null; - } - } - } - - private boolean containsValidConstructor(Class cls) { - for (Constructor c : cls.getConstructors()) { - if (c.getParameterCount() == 0) { - return true; - } - } - return false; - } + List protoBuiltins(); interface Builder { diff --git a/kogito-codegen-modules/kogito-codegen-processes/src/main/java/org/kie/kogito/codegen/process/persistence/proto/ReflectionProtoGenerator.java b/kogito-codegen-modules/kogito-codegen-processes/src/main/java/org/kie/kogito/codegen/process/persistence/proto/ReflectionProtoGenerator.java index 7b509ddd438..730ed02dd34 100644 --- a/kogito-codegen-modules/kogito-codegen-processes/src/main/java/org/kie/kogito/codegen/process/persistence/proto/ReflectionProtoGenerator.java +++ b/kogito-codegen-modules/kogito-codegen-processes/src/main/java/org/kie/kogito/codegen/process/persistence/proto/ReflectionProtoGenerator.java @@ -30,6 +30,7 @@ import java.util.Comparator; import java.util.Date; import java.util.HashSet; +import java.util.List; import java.util.Optional; import java.util.Set; import java.util.function.Predicate; @@ -61,33 +62,20 @@ protected boolean isEnum(Class dataModel) { @Override protected ProtoMessage messageFromClass(Proto proto, Set alreadyGenerated, Class clazz, String messageComment, String fieldComment) throws Exception { - String name = extractName(clazz).orElse(null); - if (name == null) { - // since class is marked as hidden skip processing of that class + + if (!shouldGenerateProto(clazz)) { + LOGGER.info("Skipping generating reflection proto for class {}", clazz); return null; } + LOGGER.debug("Generating reflection proto for class {}", clazz); - ProtoMessage message = new ProtoMessage(name, clazz.getPackage().getName()); + String clazzName = extractName(clazz).get(); + ProtoMessage message = new ProtoMessage(clazzName, clazz.getPackage().getName()); + Predicate validPropertyFilter = property -> this.isValidProperty(clazz, property); + List propertiesDescriptor = List.of(Introspector.getBeanInfo(clazz).getPropertyDescriptors()).stream().filter(validPropertyFilter).toList(); + for (PropertyDescriptor pd : propertiesDescriptor) { - for (PropertyDescriptor pd : Introspector.getBeanInfo(clazz).getPropertyDescriptors()) { - if (pd.getName().equals("class")) { - continue; - } - - Field propertyField; - try { - propertyField = getFieldFromClass(clazz, pd.getName()); - } catch (IllegalArgumentException ex) { - LOGGER.warn(ex.getMessage()); - // a method starting with get or set without a corresponding backing field makes java beans to - // still generate a property descriptor, it should be ignored - continue; - } - // ignore static and/or transient fields - int mod = propertyField.getModifiers(); - if (Modifier.isStatic(mod) || Modifier.isTransient(mod)) { - continue; - } + Field propertyField = getFieldFromClass(clazz, pd.getName()); // By default, only index id field from Model generated class String completeFieldComment = "id".equals(pd.getName()) && Model.class.isAssignableFrom(clazz) ? fieldComment.replace("Index.NO", "Index.YES") : fieldComment; @@ -129,7 +117,7 @@ protected ProtoMessage messageFromClass(Proto proto, Set alreadyGenerate protoType = optionalProtoType.get(); } - ProtoField protoField = message.addField(applicabilityByType(fieldTypeString), protoType, pd.getName()); + ProtoField protoField = message.addField(computeCardinalityModifier(fieldTypeString), protoType, pd.getName()); protoField.setComment(completeFieldComment); if (KOGITO_SERIALIZABLE.equals(protoType)) { protoField.setOption(format("[(%s) = \"%s\"]", KOGITO_JAVA_CLASS_OPTION, pd.getPropertyType().getCanonicalName())); @@ -140,6 +128,36 @@ protected ProtoMessage messageFromClass(Proto proto, Set alreadyGenerate return message; } + protected boolean shouldGenerateProto(Class clazz) { + return extractName(clazz).isPresent(); + } + + @Override + protected Optional extractName(Class clazz) { + try { + // builtins should not generate proto files + BeanInfo beanInfo = Introspector.getBeanInfo(clazz); + String name = beanInfo.getBeanDescriptor().getBeanClass().getSimpleName(); + + Predicate typeExclusions = ExclusionTypeUtils.createTypeExclusions(); + if (typeExclusions.test(clazz.getCanonicalName())) { + return Optional.empty(); + } + Generated generatedData = clazz.getAnnotation(Generated.class); + if (generatedData != null) { + name = generatedData.name().isEmpty() ? name : generatedData.name(); + if (generatedData.hidden()) { + // since class is marked as hidden skip processing of that class + return Optional.empty(); + } + } + return Optional.of(name); + } catch (IntrospectionException e) { + throw new RuntimeException(e); + } + + } + @Override protected String modelClassName(Class dataModel) { return dataModel.getName(); @@ -164,7 +182,7 @@ protected ProtoEnum enumFromClass(Proto proto, Class clazz) throws Exception .map(name -> { ProtoEnum modelEnum = new ProtoEnum(name, clazz.getPackage().getName()); Stream.of(clazz.getDeclaredFields()) - .filter(f -> !f.getName().startsWith("$")) + .filter(Field::isEnumConstant) .sorted(Comparator.comparing(Field::getName)) .forEach(f -> addEnumField(f, modelEnum)); proto.addEnum(modelEnum); @@ -175,31 +193,6 @@ protected ProtoEnum enumFromClass(Proto proto, Class clazz) throws Exception } } - @Override - protected Optional extractName(Class clazz) { - BeanInfo beanInfo; - try { - beanInfo = Introspector.getBeanInfo(clazz); - } catch (IntrospectionException e) { - throw new RuntimeException(e); - } - String name = beanInfo.getBeanDescriptor().getBeanClass().getSimpleName(); - - Predicate typeExclusions = ExclusionTypeUtils.createTypeExclusions(); - if (typeExclusions.test(clazz.getCanonicalName())) { - return Optional.empty(); - } - Generated generatedData = clazz.getAnnotation(Generated.class); - if (generatedData != null) { - name = generatedData.name().isEmpty() ? name : generatedData.name(); - if (generatedData.hidden()) { - // since class is marked as hidden skip processing of that class - return Optional.empty(); - } - } - return Optional.of(name); - } - private void addEnumField(Field field, ProtoEnum pEnum) { ProtoEnumValue protoEnumValue = field.getAnnotation(ProtoEnumValue.class); Integer ordinal = null; @@ -286,4 +279,27 @@ public ReflectionProtoGenerator build(Collection> modelClasses) { return new ReflectionProtoGenerator(modelClasses, extractDataClasses(modelClasses)); } } + + private boolean isValidProperty(Class clazz, PropertyDescriptor propertyDescriptor) { + try { + if (propertyDescriptor.getName().equals("class")) { + return false; + } + + Field propertyField = getFieldFromClass(clazz, propertyDescriptor.getName()); + + // ignore static and/or transient fields + int mod = propertyField.getModifiers(); + if (Modifier.isStatic(mod) || Modifier.isTransient(mod)) { + return false; + } + + return true; + } catch (IllegalArgumentException ex) { + LOGGER.warn(ex.getMessage()); + // a method starting with get or set without a corresponding backing field makes java beans to + // still generate a property descriptor, it should be ignored + return false; + } + } } diff --git a/quarkus/extensions/kogito-quarkus-workflow-extension-common/kogito-quarkus-workflow-common-deployment/src/main/java/org/kie/kogito/quarkus/workflow/deployment/JandexProtoGenerator.java b/quarkus/extensions/kogito-quarkus-workflow-extension-common/kogito-quarkus-workflow-common-deployment/src/main/java/org/kie/kogito/quarkus/workflow/deployment/JandexProtoGenerator.java index 558a042ae09..08ac15a972f 100644 --- a/quarkus/extensions/kogito-quarkus-workflow-extension-common/kogito-quarkus-workflow-common-deployment/src/main/java/org/kie/kogito/quarkus/workflow/deployment/JandexProtoGenerator.java +++ b/quarkus/extensions/kogito-quarkus-workflow-extension-common/kogito-quarkus-workflow-common-deployment/src/main/java/org/kie/kogito/quarkus/workflow/deployment/JandexProtoGenerator.java @@ -54,7 +54,7 @@ import static java.util.stream.Collectors.toList; public class JandexProtoGenerator extends AbstractProtoGenerator { - + private static final Logger LOGGER = LoggerFactory.getLogger(JandexProtoGenerator.class); private static final DotName ENUM_VALUE_ANNOTATION = DotName.createSimple(ProtoEnumValue.class.getName()); private static final DotName generatedAnnotation = DotName.createSimple(Generated.class.getCanonicalName()); private static final DotName variableInfoAnnotation = DotName.createSimple(VariableInfo.class.getCanonicalName()); @@ -92,15 +92,29 @@ protected Optional extractName(ClassInfo clazz) { return Optional.of(name); } + protected Optional fqn(ClassInfo dataModel) { + if (isHidden(dataModel)) { + // since class is marked as hidden skip processing of that class + return Optional.empty(); + } + + String name = dataModel.simpleName(); + String altName = getReferenceOfModel(dataModel, "name"); + if (altName != null) { + name = altName; + } + return Optional.of(dataModel.name().packagePrefix() + "." + name); + } + @Override protected ProtoMessage messageFromClass(Proto proto, Set alreadyGenerated, ClassInfo clazz, String messageComment, String fieldComment) throws Exception { - Optional optionalName = extractName(clazz); - if (!optionalName.isPresent()) { - // if name cannot be extracted let skip the object + if (!shouldGenerateProto(clazz)) { + LOGGER.info("Skipping generating jandex proto for class {}", clazz); return null; } + LOGGER.debug("Generating reflection proto for class {}", clazz); - String name = optionalName.get(); + String name = extractName(clazz).get(); ProtoMessage message = new ProtoMessage(name, clazz.name().prefix().toString()); for (FieldInfo pd : extractAllFields(clazz)) { @@ -157,7 +171,7 @@ protected ProtoMessage messageFromClass(Proto proto, Set alreadyGenerate protoType = optionalProtoType.get(); } - ProtoField protoField = message.addField(applicabilityByType(fieldTypeString), protoType, pd.name()); + ProtoField protoField = message.addField(computeCardinalityModifier(fieldTypeString), protoType, pd.name()); protoField.setComment(completeFieldComment); if (KOGITO_SERIALIZABLE.equals(protoType)) { protoField.setOption(format("[(%s) = \"%s\"]", KOGITO_JAVA_CLASS_OPTION, fieldTypeString.equals(ARRAY) ? pd.type().toString() : pd.type().name().toString())); @@ -168,6 +182,10 @@ protected ProtoMessage messageFromClass(Proto proto, Set alreadyGenerate return message; } + protected boolean shouldGenerateProto(ClassInfo clazz) { + return extractName(clazz).isPresent(); + } + private boolean isCollection(FieldInfo pd) { if (pd.type().kind() == Kind.PARAMETERIZED_TYPE || pd.type().kind() == Kind.CLASS) { try { From cc84426b6d1e3ab931041c087466fafe2ba0b464 Mon Sep 17 00:00:00 2001 From: Enrique Date: Tue, 28 May 2024 10:41:26 +0200 Subject: [PATCH 22/32] [incubator-kie-issues-1152] Add support for collaborations (#3523) --- .../jbpm/bpmn2/xml/BoundaryEventHandler.java | 2 + .../xml/IntermediateCatchEventHandler.java | 2 + .../org/jbpm/bpmn2/xml/ProcessHandler.java | 8 +- .../org/jbpm/bpmn2/xml/StartEventHandler.java | 2 + .../XPATHReturnValueEvaluatorBuilder.java | 3 +- .../compiler/canonical/ActionNodeVisitor.java | 2 +- .../canonical/BoundaryEventNodeVisitor.java | 6 +- .../compiler/canonical/EventNodeVisitor.java | 7 +- .../compiler/canonical/ProcessVisitor.java | 46 +++++- .../compiler/canonical/SplitNodeVisitor.java | 52 +++++-- .../ExpressionConstraintEvaluatorBuilder.java | 41 ------ .../FEELConstraintEvaluatorBuilder.java | 11 +- .../JavaConstraintEvaluatorBuilder.java | 11 +- .../JqReturnValueEvaluatorBuilder.java | 51 +++++++ .../JsonpathReturnValueEvaluatorBuilder.java | 51 +++++++ .../MVELConstraintEvaluatorBuilder.java | 11 +- ....java => ReturnValueEvaluatorBuilder.java} | 12 +- ...> ReturnValueEvaluatorBuilderService.java} | 43 +++--- .../XPATHConstraintEvaluatorBuilder.java | 12 +- .../node/SplitNodeVisitorBuilder.java | 3 +- .../mvel/MVELReturnValueEvaluatorBuilder.java | 3 +- ...nical.builtin.ReturnValueEvaluatorBuilder} | 5 +- .../builder/dialect/java/javaInvokers.mvel | 8 +- .../CorrelationExpressionEvaluator.java | 29 ---- .../core/correlation/CorrelationManager.java | 30 +++- .../correlation/CorrelationProperties.java | 8 +- .../process/core/event/EventTypeFilter.java | 2 +- .../event/MVELMessageExpressionEvaluator.java | 62 --------- .../instance/KogitoProcessContextImpl.java | 16 +++ .../instance/LightProcessRuntimeContext.java | 2 +- .../impl/AbstractReturnValueEvaluator.java | 76 ++++++++++ .../impl/EmtpyKogitoProcessContext.java | 75 ++++++++++ .../impl/ExpressionReturnValueEvaluator.java | 11 +- .../impl/FeelReturnValueEvaluator.java | 30 +--- .../MVELInterpretedReturnValueEvaluator.java | 39 +++++- .../impl/MVELReturnValueEvaluator.java | 45 ++---- .../instance/impl/ReturnValueEvaluator.java | 29 +++- .../impl/XPATHReturnValueEvaluator.java | 131 +++++++----------- .../java/org/jbpm/ruleflow/core/Metadata.java | 1 + .../ruleflow/core/RuleFlowProcessFactory.java | 28 ++++ .../factory/AbstractEventNodeFactory.java | 5 + .../factory/EventSubProcessNodeFactory.java | 5 + .../core/factory/StartNodeFactory.java | 7 + .../kogito/process/impl/AbstractProcess.java | 1 + .../org/jbpm/bpmn2/CollaborationTest.java | 106 ++++++++++---- .../src/main/bpmn/BPMN2-XpathExpression.bpmn2 | 114 +++++++++++++++ 46 files changed, 846 insertions(+), 398 deletions(-) delete mode 100644 jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/builtin/ExpressionConstraintEvaluatorBuilder.java create mode 100644 jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/builtin/JqReturnValueEvaluatorBuilder.java create mode 100644 jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/builtin/JsonpathReturnValueEvaluatorBuilder.java rename jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/builtin/{ConstraintEvaluatorBuilder.java => ReturnValueEvaluatorBuilder.java} (74%) rename jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/builtin/{ConstraintEvaluatorBuilderService.java => ReturnValueEvaluatorBuilderService.java} (50%) rename jbpm/jbpm-flow-builder/src/main/resources/META-INF/services/{org.jbpm.compiler.canonical.builtin.ConstraintEvaluatorBuilder => org.jbpm.compiler.canonical.builtin.ReturnValueEvaluatorBuilder} (65%) delete mode 100644 jbpm/jbpm-flow/src/main/java/org/jbpm/process/core/correlation/CorrelationExpressionEvaluator.java delete mode 100644 jbpm/jbpm-flow/src/main/java/org/jbpm/process/core/event/MVELMessageExpressionEvaluator.java create mode 100644 jbpm/jbpm-flow/src/main/java/org/jbpm/process/instance/impl/AbstractReturnValueEvaluator.java create mode 100644 jbpm/jbpm-flow/src/main/java/org/jbpm/process/instance/impl/EmtpyKogitoProcessContext.java create mode 100755 jbpm/jbpm-tools/jbpm-tools-maven-plugin/src/test/resources/unit/project/src/main/bpmn/BPMN2-XpathExpression.bpmn2 diff --git a/jbpm/jbpm-bpmn2/src/main/java/org/jbpm/bpmn2/xml/BoundaryEventHandler.java b/jbpm/jbpm-bpmn2/src/main/java/org/jbpm/bpmn2/xml/BoundaryEventHandler.java index dbd45edfa23..d3ef36e0dec 100755 --- a/jbpm/jbpm-bpmn2/src/main/java/org/jbpm/bpmn2/xml/BoundaryEventHandler.java +++ b/jbpm/jbpm-bpmn2/src/main/java/org/jbpm/bpmn2/xml/BoundaryEventHandler.java @@ -45,6 +45,7 @@ import org.xml.sax.SAXException; import static org.jbpm.ruleflow.core.Metadata.EVENT_TYPE; +import static org.jbpm.ruleflow.core.Metadata.MESSAGE_REF; public class BoundaryEventHandler extends AbstractNodeHandler { @@ -408,6 +409,7 @@ protected void handleMessageNode(final Node node, final Element element, eventNode.setMetaData("MessageType", message.getType()); eventNode.setMetaData("TriggerType", "ConsumeMessage"); eventNode.setMetaData("TriggerRef", message.getName()); + eventNode.setMetaData(MESSAGE_REF, message.getId()); List eventFilters = new ArrayList<>(); EventTypeFilter eventFilter = new EventTypeFilter(); eventFilter.setCorrelationManager(((RuleFlowProcess) parser.getMetaData().get("CurrentProcessDefinition")).getCorrelationManager()); diff --git a/jbpm/jbpm-bpmn2/src/main/java/org/jbpm/bpmn2/xml/IntermediateCatchEventHandler.java b/jbpm/jbpm-bpmn2/src/main/java/org/jbpm/bpmn2/xml/IntermediateCatchEventHandler.java index 267a7fa4622..c8329b5b0f1 100755 --- a/jbpm/jbpm-bpmn2/src/main/java/org/jbpm/bpmn2/xml/IntermediateCatchEventHandler.java +++ b/jbpm/jbpm-bpmn2/src/main/java/org/jbpm/bpmn2/xml/IntermediateCatchEventHandler.java @@ -55,6 +55,7 @@ import static org.jbpm.ruleflow.core.Metadata.EVENT_TYPE_SIGNAL; import static org.jbpm.ruleflow.core.Metadata.EVENT_TYPE_TIMER; import static org.jbpm.ruleflow.core.Metadata.LINK_NAME; +import static org.jbpm.ruleflow.core.Metadata.MESSAGE_REF; import static org.jbpm.ruleflow.core.Metadata.MESSAGE_TYPE; import static org.jbpm.ruleflow.core.Metadata.SIGNAL_TYPE; import static org.jbpm.ruleflow.core.Metadata.TRIGGER_REF; @@ -240,6 +241,7 @@ protected void handleMessageNode(final Node node, final Element element, eventNode.setMetaData(MESSAGE_TYPE, message.getType()); eventNode.setMetaData(TRIGGER_TYPE, CONSUME_MESSAGE); eventNode.setMetaData(TRIGGER_REF, message.getName()); + eventNode.setMetaData(MESSAGE_REF, message.getId()); List eventFilters = new ArrayList<>(); EventTypeFilter eventFilter = new EventTypeFilter(); eventFilter.setCorrelationManager(((RuleFlowProcess) parser.getMetaData().get("CurrentProcessDefinition")).getCorrelationManager()); diff --git a/jbpm/jbpm-bpmn2/src/main/java/org/jbpm/bpmn2/xml/ProcessHandler.java b/jbpm/jbpm-bpmn2/src/main/java/org/jbpm/bpmn2/xml/ProcessHandler.java index 836248b6dfa..e9c8b060e50 100755 --- a/jbpm/jbpm-bpmn2/src/main/java/org/jbpm/bpmn2/xml/ProcessHandler.java +++ b/jbpm/jbpm-bpmn2/src/main/java/org/jbpm/bpmn2/xml/ProcessHandler.java @@ -59,9 +59,10 @@ import org.jbpm.process.core.correlation.CorrelationManager; import org.jbpm.process.core.event.EventFilter; import org.jbpm.process.core.event.EventTypeFilter; -import org.jbpm.process.core.event.MVELMessageExpressionEvaluator; import org.jbpm.process.core.timer.Timer; import org.jbpm.process.instance.impl.Action; +import org.jbpm.process.instance.impl.MVELInterpretedReturnValueEvaluator; +import org.jbpm.process.instance.impl.ReturnValueEvaluator; import org.jbpm.process.instance.impl.actions.CancelNodeInstanceAction; import org.jbpm.process.instance.impl.actions.ProcessInstanceCompensationAction; import org.jbpm.process.instance.impl.actions.SignalProcessInstanceAction; @@ -240,7 +241,7 @@ private void postProcessCollaborations(RuleFlowProcess process, Parser parser) { correlationProperty.getMessageRefs().forEach(messageRef -> { // for now only MVEL expressions - MVELMessageExpressionEvaluator evaluator = new MVELMessageExpressionEvaluator(correlationProperty.getRetrievalExpression(messageRef).getScript()); + ReturnValueEvaluator evaluator = new MVELInterpretedReturnValueEvaluator(correlationProperty.getRetrievalExpression(messageRef).getScript()); correlationManager.addMessagePropertyExpression(key.getId(), messageRef, correlationProperty.getId(), evaluator); }); } @@ -251,7 +252,8 @@ private void postProcessCollaborations(RuleFlowProcess process, Parser parser) { for (CorrelationSubscription subscription : HandlerUtil.correlationSubscription(process).values()) { correlationManager.subscribeTo(subscription.getCorrelationKeyRef()); for (Map.Entry binding : subscription.getPropertyExpressions().entrySet()) { - MVELMessageExpressionEvaluator evaluator = new MVELMessageExpressionEvaluator(binding.getValue().getScript()); + + ReturnValueEvaluator evaluator = new MVELInterpretedReturnValueEvaluator(binding.getValue().getScript()); correlationManager.addProcessSubscriptionPropertyExpression(subscription.getCorrelationKeyRef(), binding.getKey(), evaluator); } } diff --git a/jbpm/jbpm-bpmn2/src/main/java/org/jbpm/bpmn2/xml/StartEventHandler.java b/jbpm/jbpm-bpmn2/src/main/java/org/jbpm/bpmn2/xml/StartEventHandler.java index 7334cd40193..b6b276cb92c 100755 --- a/jbpm/jbpm-bpmn2/src/main/java/org/jbpm/bpmn2/xml/StartEventHandler.java +++ b/jbpm/jbpm-bpmn2/src/main/java/org/jbpm/bpmn2/xml/StartEventHandler.java @@ -50,6 +50,7 @@ import static org.jbpm.ruleflow.core.Metadata.EVENT_TYPE; import static org.jbpm.ruleflow.core.Metadata.EVENT_TYPE_MESSAGE; import static org.jbpm.ruleflow.core.Metadata.MAPPING_VARIABLE; +import static org.jbpm.ruleflow.core.Metadata.MESSAGE_REF; import static org.jbpm.ruleflow.core.Metadata.MESSAGE_TYPE; import static org.jbpm.ruleflow.core.Metadata.TRIGGER_MAPPING; import static org.jbpm.ruleflow.core.Metadata.TRIGGER_MAPPING_INPUT; @@ -138,6 +139,7 @@ protected Node handleNode(final Node node, final Element element, final String u startNode.setMetaData(MESSAGE_TYPE, message.getType()); startNode.setMetaData(TRIGGER_TYPE, TriggerMetaData.TriggerType.ConsumeMessage.name()); startNode.setMetaData(TRIGGER_REF, message.getName()); + startNode.setMetaData(MESSAGE_REF, message.getId()); addTriggerWithInMappings(startNode, "Message-" + message.getName(), message.getId(), ((RuleFlowProcess) parser.getMetaData().get("CurrentProcessDefinition")).getCorrelationManager()); } else if ("timerEventDefinition".equals(nodeName)) { diff --git a/jbpm/jbpm-bpmn2/src/main/java/org/jbpm/bpmn2/xpath/XPATHReturnValueEvaluatorBuilder.java b/jbpm/jbpm-bpmn2/src/main/java/org/jbpm/bpmn2/xpath/XPATHReturnValueEvaluatorBuilder.java index 704453aed2b..3aaa04cbb7a 100755 --- a/jbpm/jbpm-bpmn2/src/main/java/org/jbpm/bpmn2/xpath/XPATHReturnValueEvaluatorBuilder.java +++ b/jbpm/jbpm-bpmn2/src/main/java/org/jbpm/bpmn2/xpath/XPATHReturnValueEvaluatorBuilder.java @@ -42,8 +42,7 @@ public void build(final PackageBuildContext context, String text = descr.getText(); try { - XPATHReturnValueEvaluator expr = new XPATHReturnValueEvaluator(text, - null); + XPATHReturnValueEvaluator expr = new XPATHReturnValueEvaluator(text); constraintNode.setEvaluator(expr); diff --git a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/ActionNodeVisitor.java b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/ActionNodeVisitor.java index e77502776e4..86ae851d3d9 100644 --- a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/ActionNodeVisitor.java +++ b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/ActionNodeVisitor.java @@ -63,6 +63,7 @@ protected String getNodeKey() { public void visitNode(String factoryField, ActionNode node, BlockStmt body, VariableScope variableScope, ProcessMetaData metadata) { body.addStatement(getAssignedFactoryMethod(factoryField, ActionNodeFactory.class, getNodeId(node), getNodeKey(), getWorkflowElementConstructor(node.getId()))) .addStatement(getNameMethod(node, "Script")); + visitMetaData(node.getMetaData(), body, getNodeId(node)); Optional supplierAction = getAction(node, ExpressionSupplier.class); if (isIntermediateCompensation(node)) { @@ -101,7 +102,6 @@ public void visitNode(String factoryField, ActionNode node, BlockStmt body, Vari body.addStatement(getFactoryMethod(getNodeId(node), METHOD_ACTION, lambda)); } addNodeMappings(node, body, getNodeId(node)); - visitMetaData(node.getMetaData(), body, getNodeId(node)); body.addStatement(getDoneMethod(getNodeId(node))); } diff --git a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/BoundaryEventNodeVisitor.java b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/BoundaryEventNodeVisitor.java index e42e95c719a..ab0051d501c 100644 --- a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/BoundaryEventNodeVisitor.java +++ b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/BoundaryEventNodeVisitor.java @@ -46,8 +46,9 @@ protected String getNodeKey() { @Override public void visitNode(String factoryField, BoundaryEventNode node, BlockStmt body, VariableScope variableScope, ProcessMetaData metadata) { - body.addStatement(getAssignedFactoryMethod(factoryField, BoundaryEventNodeFactory.class, getNodeId(node), getNodeKey(), getWorkflowElementConstructor(node.getId()))) - .addStatement(getNameMethod(node, "BoundaryEvent")) + body.addStatement(getAssignedFactoryMethod(factoryField, BoundaryEventNodeFactory.class, getNodeId(node), getNodeKey(), getWorkflowElementConstructor(node.getId()))); + visitMetaData(node.getMetaData(), body, getNodeId(node)); + body.addStatement(getNameMethod(node, "BoundaryEvent")) .addStatement(getFactoryMethod(getNodeId(node), METHOD_EVENT_TYPE, new StringLiteralExpr(node.getType()))) .addStatement(getFactoryMethod(getNodeId(node), METHOD_ATTACHED_TO, new StringLiteralExpr(node.getAttachedToNodeId()))) .addStatement(getFactoryMethod(getNodeId(node), METHOD_SCOPE, getOrNullExpr(node.getScope()))); @@ -70,7 +71,6 @@ public void visitNode(String factoryField, BoundaryEventNode node, BlockStmt bod body.addStatement(getFactoryMethod(getNodeId(node), METHOD_ADD_COMPENSATION_HANDLER, new StringLiteralExpr(node.getAttachedToNodeId()))); } addNodeMappings(node, body, getNodeId(node)); - visitMetaData(node.getMetaData(), body, getNodeId(node)); body.addStatement(getDoneMethod(getNodeId(node))); } } diff --git a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/EventNodeVisitor.java b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/EventNodeVisitor.java index 17db88370f5..66051eb049f 100644 --- a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/EventNodeVisitor.java +++ b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/EventNodeVisitor.java @@ -44,8 +44,9 @@ protected String getNodeKey() { @Override public void visitNode(String factoryField, EventNode node, BlockStmt body, VariableScope variableScope, ProcessMetaData metadata) { - body.addStatement(getAssignedFactoryMethod(factoryField, EventNodeFactory.class, getNodeId(node), getNodeKey(), getWorkflowElementConstructor(node.getId()))) - .addStatement(getNameMethod(node, "Event")) + body.addStatement(getAssignedFactoryMethod(factoryField, EventNodeFactory.class, getNodeId(node), getNodeKey(), getWorkflowElementConstructor(node.getId()))); + visitMetaData(node.getMetaData(), body, getNodeId(node)); + body.addStatement(getNameMethod(node, "Event")) .addStatement(getFactoryMethod(getNodeId(node), METHOD_EVENT_TYPE, new StringLiteralExpr(node.getType()))); Variable variable = null; @@ -72,7 +73,7 @@ public void visitNode(String factoryField, EventNode node, BlockStmt body, Varia } } addNodeMappings(node, body, getNodeId(node)); - visitMetaData(node.getMetaData(), body, getNodeId(node)); + body.addStatement(getDoneMethod(getNodeId(node))); } diff --git a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/ProcessVisitor.java b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/ProcessVisitor.java index 223f9a84288..30316ea7293 100644 --- a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/ProcessVisitor.java +++ b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/ProcessVisitor.java @@ -26,6 +26,7 @@ import java.util.Set; import java.util.stream.Stream; +import org.jbpm.compiler.canonical.builtin.ReturnValueEvaluatorBuilderService; import org.jbpm.compiler.canonical.descriptors.ExpressionUtils; import org.jbpm.compiler.canonical.node.NodeVisitorBuilderService; import org.jbpm.process.core.Context; @@ -34,6 +35,11 @@ import org.jbpm.process.core.context.exception.ActionExceptionHandler; import org.jbpm.process.core.context.exception.ExceptionScope; import org.jbpm.process.core.context.variable.VariableScope; +import org.jbpm.process.core.correlation.Correlation; +import org.jbpm.process.core.correlation.CorrelationManager; +import org.jbpm.process.core.correlation.CorrelationProperties; +import org.jbpm.process.core.correlation.Message; +import org.jbpm.process.instance.impl.ReturnValueEvaluator; import org.jbpm.process.instance.impl.actions.SignalProcessInstanceAction; import org.jbpm.ruleflow.core.RuleFlowProcess; import org.jbpm.ruleflow.core.RuleFlowProcessFactory; @@ -80,8 +86,11 @@ public class ProcessVisitor extends AbstractVisitor { private NodeVisitorBuilderService nodeVisitorService; + private ReturnValueEvaluatorBuilderService returnValueEvaluatorBuilderService; + public ProcessVisitor(ClassLoader contextClassLoader) { nodeVisitorService = new NodeVisitorBuilderService(contextClassLoader); + returnValueEvaluatorBuilderService = ReturnValueEvaluatorBuilderService.instance(contextClassLoader); } public void visitProcess(WorkflowProcess process, MethodDeclaration processMethod, ProcessMetaData metadata) { @@ -131,8 +140,9 @@ public void visitProcess(WorkflowProcess process, MethodDeclaration processMetho ((org.jbpm.workflow.core.WorkflowProcess) process).getOutputValidator().ifPresent( v -> body.addStatement(getFactoryMethod(FACTORY_FIELD_NAME, "outputValidator", ExpressionUtils.getLiteralExpr(v)))); - visitCompensationScope(process, body); visitMetaData(process.getMetaData(), body, FACTORY_FIELD_NAME); + visitCollaboration(process, body); + visitCompensationScope(process, body); visitHeader(process, body); List processNodes = new ArrayList<>(); @@ -150,6 +160,40 @@ public void visitProcess(WorkflowProcess process, MethodDeclaration processMetho body.addStatement(new ReturnStmt(getProcessMethod)); } + private void visitCollaboration(WorkflowProcess process, BlockStmt body) { + RuleFlowProcess ruleFlowProcess = (RuleFlowProcess) process; + CorrelationManager correlationManager = ruleFlowProcess.getCorrelationManager(); + + for (String messageId : correlationManager.getMessagesId()) { + Message message = correlationManager.findMessageById(messageId); + body.addStatement(getFactoryMethod(FACTORY_FIELD_NAME, "newCorrelationMessage", + new StringLiteralExpr(message.getMessageRef()), new StringLiteralExpr(message.getMessageName()), new StringLiteralExpr(message.getMessageType()))); + } + + for (String correlationId : correlationManager.getCorrelationsId()) { + Correlation correlation = correlationManager.findCorrelationById(correlationId); + body.addStatement(getFactoryMethod(FACTORY_FIELD_NAME, "newCorrelationKey", + new StringLiteralExpr(correlation.getId()), new StringLiteralExpr(correlation.getName()))); + + for (String messageId : correlationManager.getMessagesId()) { + CorrelationProperties properties = correlation.getMessageCorrelationFor(messageId); + for (String propertyName : properties.names()) { + ReturnValueEvaluator evaluator = properties.getExpressionFor(propertyName); + Expression returnValueEvaluator = returnValueEvaluatorBuilderService.build(ruleFlowProcess, evaluator.dialect(), evaluator.expression()); + body.addStatement(getFactoryMethod(FACTORY_FIELD_NAME, "newCorrelationProperty", + new StringLiteralExpr(correlation.getId()), new StringLiteralExpr(messageId), new StringLiteralExpr(propertyName), returnValueEvaluator)); + } + } + CorrelationProperties subscriptions = correlation.getProcessSubscription(); + for (String propertyName : subscriptions.names()) { + ReturnValueEvaluator evaluator = subscriptions.getExpressionFor(propertyName); + Expression returnValueEvaluator = returnValueEvaluatorBuilderService.build(ruleFlowProcess, evaluator.dialect(), evaluator.expression()); + body.addStatement(getFactoryMethod(FACTORY_FIELD_NAME, "newCorrelationSubscription", + new StringLiteralExpr(correlation.getId()), new StringLiteralExpr(propertyName), returnValueEvaluator)); + } + } + } + private void visitSubVariableScopes(org.kie.api.definition.process.Node[] nodes, BlockStmt body, Set visitedVariables) { for (org.kie.api.definition.process.Node node : nodes) { if (node instanceof ContextContainer) { diff --git a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/SplitNodeVisitor.java b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/SplitNodeVisitor.java index 346c044cdc7..de434a17a77 100644 --- a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/SplitNodeVisitor.java +++ b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/SplitNodeVisitor.java @@ -20,9 +20,13 @@ import java.util.Collection; import java.util.Map.Entry; +import java.util.Objects; +import java.util.function.Predicate; -import org.jbpm.compiler.canonical.builtin.ConstraintEvaluatorBuilderService; +import org.jbpm.compiler.canonical.builtin.ReturnValueEvaluatorBuilderService; import org.jbpm.process.core.context.variable.VariableScope; +import org.jbpm.process.instance.impl.ReturnValueConstraintEvaluator; +import org.jbpm.process.instance.impl.ReturnValueEvaluator; import org.jbpm.ruleflow.core.factory.SplitFactory; import org.jbpm.workflow.core.Constraint; import org.jbpm.workflow.core.impl.ConnectionRef; @@ -39,6 +43,12 @@ public class SplitNodeVisitor extends AbstractNodeVisitor { + ReturnValueEvaluatorBuilderService returnValueEvaluatorBuilderService; + + public SplitNodeVisitor(ReturnValueEvaluatorBuilderService returnValueEvaluatorBuilderService) { + this.returnValueEvaluatorBuilderService = returnValueEvaluatorBuilderService; + } + @Override protected String getNodeKey() { return "splitNode"; @@ -54,20 +64,34 @@ public void visitNode(String factoryField, Split node, BlockStmt body, VariableS if (node.getType() == Split.TYPE_OR || node.getType() == Split.TYPE_XOR) { for (Entry> entry : node.getConstraints().entrySet()) { - if (entry.getValue() != null) { - for (Constraint constraint : entry.getValue()) { - if (constraint != null) { - Expression returnValueEvaluator = ConstraintEvaluatorBuilderService.instance().build(node, constraint); - body.addStatement(getFactoryMethod(getNodeId(node), METHOD_CONSTRAINT, - getWorkflowElementConstructor(entry.getKey().getNodeId()), - new StringLiteralExpr(getOrDefault(entry.getKey().getConnectionId(), "")), - new StringLiteralExpr(entry.getKey().getToType()), - new StringLiteralExpr(constraint.getDialect()), - returnValueEvaluator, - new IntegerLiteralExpr(constraint.getPriority()), - new BooleanLiteralExpr(constraint.isDefault()))); - } + if (entry.getValue() == null || entry.getValue().isEmpty()) { + continue; + } + + for (Constraint constraint : entry.getValue().stream().filter(Predicate.not(Objects::isNull)).toList()) { + Expression returnValueEvaluator; + if (constraint instanceof ReturnValueConstraintEvaluator) { + ReturnValueEvaluator evaluator = ((ReturnValueConstraintEvaluator) constraint).getReturnValueEvaluator(); + returnValueEvaluator = returnValueEvaluatorBuilderService.build(node, + evaluator.dialect(), + evaluator.expression(), + evaluator.type(), + evaluator.root()); + + } else { + returnValueEvaluator = returnValueEvaluatorBuilderService.build(node, + constraint.getDialect(), + constraint.getConstraint()); } + body.addStatement(getFactoryMethod(getNodeId(node), METHOD_CONSTRAINT, + getWorkflowElementConstructor(entry.getKey().getNodeId()), + new StringLiteralExpr(getOrDefault(entry.getKey().getConnectionId(), "")), + new StringLiteralExpr(entry.getKey().getToType()), + new StringLiteralExpr(constraint.getDialect()), + returnValueEvaluator, + new IntegerLiteralExpr(constraint.getPriority()), + new BooleanLiteralExpr(constraint.isDefault()))); + } } } diff --git a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/builtin/ExpressionConstraintEvaluatorBuilder.java b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/builtin/ExpressionConstraintEvaluatorBuilder.java deleted file mode 100644 index ccf09b757a0..00000000000 --- a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/builtin/ExpressionConstraintEvaluatorBuilder.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jbpm.compiler.canonical.builtin; - -import java.util.function.Supplier; - -import org.jbpm.process.core.ContextResolver; -import org.jbpm.process.instance.impl.ReturnValueConstraintEvaluator; -import org.jbpm.workflow.core.Constraint; - -import com.github.javaparser.ast.expr.Expression; - -public class ExpressionConstraintEvaluatorBuilder implements ConstraintEvaluatorBuilder { - - @Override - public boolean accept(Constraint constraint) { - return constraint instanceof ReturnValueConstraintEvaluator && ((ReturnValueConstraintEvaluator) constraint).getReturnValueEvaluator() instanceof Supplier; - } - - @Override - public Expression build(ContextResolver resolver, Constraint constraint) { - return ((Supplier) ((ReturnValueConstraintEvaluator) constraint).getReturnValueEvaluator()).get(); - } - -} diff --git a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/builtin/FEELConstraintEvaluatorBuilder.java b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/builtin/FEELConstraintEvaluatorBuilder.java index 1f07e814697..33c5f95dfa5 100644 --- a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/builtin/FEELConstraintEvaluatorBuilder.java +++ b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/builtin/FEELConstraintEvaluatorBuilder.java @@ -20,7 +20,6 @@ import org.jbpm.process.core.ContextResolver; import org.jbpm.process.instance.impl.FeelReturnValueEvaluator; -import org.jbpm.workflow.core.Constraint; import org.kie.kogito.internal.utils.ConversionUtils; import com.github.javaparser.StaticJavaParser; @@ -29,18 +28,18 @@ import com.github.javaparser.ast.expr.ObjectCreationExpr; import com.github.javaparser.ast.expr.StringLiteralExpr; -public class FEELConstraintEvaluatorBuilder implements ConstraintEvaluatorBuilder { +public class FEELConstraintEvaluatorBuilder implements ReturnValueEvaluatorBuilder { @Override - public boolean accept(Constraint constraint) { - return "FEEL".equals(constraint.getDialect()); + public boolean accept(String dialect) { + return dialect.toLowerCase().contains("feel"); } @Override - public Expression build(ContextResolver resolver, Constraint constraint) { + public Expression build(ContextResolver resolver, String expresssion, Class type, String rootName) { return new ObjectCreationExpr(null, StaticJavaParser.parseClassOrInterfaceType(FeelReturnValueEvaluator.class.getName()), - new NodeList<>(new StringLiteralExpr(ConversionUtils.sanitizeString(constraint.getConstraint())))); + new NodeList<>(new StringLiteralExpr(ConversionUtils.sanitizeString(expresssion)))); } } diff --git a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/builtin/JavaConstraintEvaluatorBuilder.java b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/builtin/JavaConstraintEvaluatorBuilder.java index f9f7a803d7d..d85f3fe76ba 100644 --- a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/builtin/JavaConstraintEvaluatorBuilder.java +++ b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/builtin/JavaConstraintEvaluatorBuilder.java @@ -25,7 +25,6 @@ import org.jbpm.process.core.ContextResolver; import org.jbpm.process.core.context.variable.Variable; import org.jbpm.process.core.context.variable.VariableScope; -import org.jbpm.workflow.core.Constraint; import com.github.javaparser.StaticJavaParser; import com.github.javaparser.ast.body.Parameter; @@ -35,21 +34,21 @@ import com.github.javaparser.ast.stmt.BlockStmt; import com.github.javaparser.ast.type.UnknownType; -public class JavaConstraintEvaluatorBuilder implements ConstraintEvaluatorBuilder { +public class JavaConstraintEvaluatorBuilder implements ReturnValueEvaluatorBuilder { @Override - public boolean accept(Constraint constraint) { - return constraint.getDialect().contains("java"); + public boolean accept(String dialect) { + return dialect.toLowerCase().contains("java"); } @Override - public Expression build(ContextResolver resolver, Constraint constraint) { + public Expression build(ContextResolver resolver, String expression, Class type, String rootName) { BlockStmt actionBody = new BlockStmt(); LambdaExpr lambda = new LambdaExpr( new Parameter(new UnknownType(), KCONTEXT_VAR), // (kcontext) -> actionBody); - BlockStmt blockStmt = StaticJavaParser.parseBlock("{" + constraint.getConstraint() + "}"); + BlockStmt blockStmt = StaticJavaParser.parseBlock("{" + expression + "}"); Set identifiers = new HashSet<>(blockStmt.findAll(NameExpr.class)); for (NameExpr v : identifiers) { diff --git a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/builtin/JqReturnValueEvaluatorBuilder.java b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/builtin/JqReturnValueEvaluatorBuilder.java new file mode 100644 index 00000000000..bb4dae77be5 --- /dev/null +++ b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/builtin/JqReturnValueEvaluatorBuilder.java @@ -0,0 +1,51 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.jbpm.compiler.canonical.builtin; + +import org.jbpm.process.core.ContextResolver; +import org.jbpm.process.instance.impl.ExpressionReturnValueEvaluator; +import org.kie.kogito.internal.utils.ConversionUtils; + +import com.github.javaparser.StaticJavaParser; +import com.github.javaparser.ast.NodeList; +import com.github.javaparser.ast.expr.ClassExpr; +import com.github.javaparser.ast.expr.Expression; +import com.github.javaparser.ast.expr.ObjectCreationExpr; +import com.github.javaparser.ast.expr.StringLiteralExpr; + +public class JqReturnValueEvaluatorBuilder implements ReturnValueEvaluatorBuilder { + + @Override + public boolean accept(String dialect) { + return dialect.toLowerCase().contains("jq"); + } + + @Override + public Expression build(ContextResolver resolver, String expression, Class type, String rootName) { + NodeList arguments = new NodeList<>(); + arguments.add(new StringLiteralExpr("jq")); + arguments.add(new StringLiteralExpr(ConversionUtils.sanitizeString(expression))); + arguments.add(new StringLiteralExpr(rootName)); + arguments.add(new ClassExpr(StaticJavaParser.parseClassOrInterfaceType(type.getName()))); + + return new ObjectCreationExpr(null, StaticJavaParser.parseClassOrInterfaceType(ExpressionReturnValueEvaluator.class.getName()), arguments); + + } + +} diff --git a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/builtin/JsonpathReturnValueEvaluatorBuilder.java b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/builtin/JsonpathReturnValueEvaluatorBuilder.java new file mode 100644 index 00000000000..c2035c64ba5 --- /dev/null +++ b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/builtin/JsonpathReturnValueEvaluatorBuilder.java @@ -0,0 +1,51 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.jbpm.compiler.canonical.builtin; + +import org.jbpm.process.core.ContextResolver; +import org.jbpm.process.instance.impl.ExpressionReturnValueEvaluator; +import org.kie.kogito.internal.utils.ConversionUtils; + +import com.github.javaparser.StaticJavaParser; +import com.github.javaparser.ast.NodeList; +import com.github.javaparser.ast.expr.ClassExpr; +import com.github.javaparser.ast.expr.Expression; +import com.github.javaparser.ast.expr.ObjectCreationExpr; +import com.github.javaparser.ast.expr.StringLiteralExpr; + +public class JsonpathReturnValueEvaluatorBuilder implements ReturnValueEvaluatorBuilder { + + @Override + public boolean accept(String dialect) { + return dialect.toLowerCase().contains("jsonpath"); + } + + @Override + public Expression build(ContextResolver resolver, String expression, Class type, String rootName) { + NodeList arguments = new NodeList<>(); + arguments.add(new StringLiteralExpr("jsonpath")); + arguments.add(new StringLiteralExpr(ConversionUtils.sanitizeString(expression))); + arguments.add(new StringLiteralExpr(rootName)); + arguments.add(new ClassExpr(StaticJavaParser.parseClassOrInterfaceType(type.getName()))); + + return new ObjectCreationExpr(null, StaticJavaParser.parseClassOrInterfaceType(ExpressionReturnValueEvaluator.class.getName()), arguments); + + } + +} diff --git a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/builtin/MVELConstraintEvaluatorBuilder.java b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/builtin/MVELConstraintEvaluatorBuilder.java index 124c8168735..822327e36a2 100644 --- a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/builtin/MVELConstraintEvaluatorBuilder.java +++ b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/builtin/MVELConstraintEvaluatorBuilder.java @@ -20,7 +20,6 @@ import org.jbpm.process.core.ContextResolver; import org.jbpm.process.instance.impl.MVELInterpretedReturnValueEvaluator; -import org.jbpm.workflow.core.Constraint; import org.kie.kogito.internal.utils.ConversionUtils; import com.github.javaparser.StaticJavaParser; @@ -29,19 +28,19 @@ import com.github.javaparser.ast.expr.ObjectCreationExpr; import com.github.javaparser.ast.expr.StringLiteralExpr; -public class MVELConstraintEvaluatorBuilder implements ConstraintEvaluatorBuilder { +public class MVELConstraintEvaluatorBuilder implements ReturnValueEvaluatorBuilder { @Override - public boolean accept(Constraint constraint) { - return "mvel".equals(constraint.getDialect()); + public boolean accept(String dialect) { + return dialect.toLowerCase().contains("mvel"); } @Override - public Expression build(ContextResolver resolver, Constraint constraint) { + public Expression build(ContextResolver resolver, String expression, Class type, String rootName) { return new ObjectCreationExpr(null, StaticJavaParser.parseClassOrInterfaceType(MVELInterpretedReturnValueEvaluator.class.getName()), - new NodeList<>(new StringLiteralExpr(ConversionUtils.sanitizeString(constraint.getConstraint())))); + new NodeList<>(new StringLiteralExpr(ConversionUtils.sanitizeString(expression)))); } } diff --git a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/builtin/ConstraintEvaluatorBuilder.java b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/builtin/ReturnValueEvaluatorBuilder.java similarity index 74% rename from jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/builtin/ConstraintEvaluatorBuilder.java rename to jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/builtin/ReturnValueEvaluatorBuilder.java index 71f0c09a226..b07f793ec98 100644 --- a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/builtin/ConstraintEvaluatorBuilder.java +++ b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/builtin/ReturnValueEvaluatorBuilder.java @@ -19,15 +19,19 @@ package org.jbpm.compiler.canonical.builtin; import org.jbpm.process.core.ContextResolver; -import org.jbpm.workflow.core.Constraint; import com.github.javaparser.ast.expr.Expression; -public interface ConstraintEvaluatorBuilder { +public interface ReturnValueEvaluatorBuilder { String KCONTEXT_VAR = "kcontext"; - boolean accept(Constraint constraint); + boolean accept(String constraint); + + Expression build(ContextResolver resolver, String expression, Class type, String rootName); + + default Expression build(ContextResolver resolver, String expression) { + return this.build(resolver, expression, Object.class, null); + } - Expression build(ContextResolver resolver, org.jbpm.workflow.core.Constraint constraint); } diff --git a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/builtin/ConstraintEvaluatorBuilderService.java b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/builtin/ReturnValueEvaluatorBuilderService.java similarity index 50% rename from jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/builtin/ConstraintEvaluatorBuilderService.java rename to jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/builtin/ReturnValueEvaluatorBuilderService.java index 6216414cdca..7c4b999bf98 100644 --- a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/builtin/ConstraintEvaluatorBuilderService.java +++ b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/builtin/ReturnValueEvaluatorBuilderService.java @@ -23,35 +23,46 @@ import org.jbpm.process.core.ContextResolver; import org.jbpm.util.JbpmClassLoaderUtil; -import org.jbpm.workflow.core.Constraint; import com.github.javaparser.ast.expr.Expression; -public class ConstraintEvaluatorBuilderService { +public class ReturnValueEvaluatorBuilderService { - private static ConstraintEvaluatorBuilderService INSTANCE; - private List builders; + private static ReturnValueEvaluatorBuilderService INSTANCE; + private List builders; - public static ConstraintEvaluatorBuilderService instance() { + private ReturnValueEvaluatorBuilderService(ClassLoader contextClassLoader) { + builders = ServiceLoader.load(ReturnValueEvaluatorBuilder.class, contextClassLoader) + .stream() + .map(ServiceLoader.Provider::get) + .toList(); + } + + public static ReturnValueEvaluatorBuilderService instance() { if (INSTANCE == null) { - INSTANCE = new ConstraintEvaluatorBuilderService(); + INSTANCE = instance(JbpmClassLoaderUtil.findClassLoader()); } return INSTANCE; } - public ConstraintEvaluatorBuilderService() { - builders = ServiceLoader.load(ConstraintEvaluatorBuilder.class, JbpmClassLoaderUtil.findClassLoader()) - .stream() - .map(ServiceLoader.Provider::get) - .toList(); + public static ReturnValueEvaluatorBuilderService instance(ClassLoader contextClassLoader) { + return new ReturnValueEvaluatorBuilderService(contextClassLoader); + } + + public ReturnValueEvaluatorBuilderService() { + this(JbpmClassLoaderUtil.findClassLoader()); + } + + public Expression build(ContextResolver resolver, String dialect, String expression) { + return build(resolver, dialect, expression, Object.class, null); } - public Expression build(ContextResolver resolver, Constraint constraint) { - for (ConstraintEvaluatorBuilder builder : builders) { - if (builder.accept(constraint)) { - return builder.build(resolver, constraint); + public Expression build(ContextResolver resolver, String dialect, String expression, Class type, String root) { + for (ReturnValueEvaluatorBuilder builder : builders) { + if (builder.accept(dialect)) { + return builder.build(resolver, expression, type, root); } } - throw new IllegalArgumentException("No dialect found " + constraint.getDialect() + " for building constraint"); + throw new IllegalArgumentException("No dialect found " + dialect + " for return expression evaluator building return value expression"); } } diff --git a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/builtin/XPATHConstraintEvaluatorBuilder.java b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/builtin/XPATHConstraintEvaluatorBuilder.java index a2f3fac0c59..a6451f25ef4 100644 --- a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/builtin/XPATHConstraintEvaluatorBuilder.java +++ b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/builtin/XPATHConstraintEvaluatorBuilder.java @@ -20,28 +20,26 @@ import org.jbpm.process.core.ContextResolver; import org.jbpm.process.instance.impl.XPATHReturnValueEvaluator; -import org.jbpm.workflow.core.Constraint; import org.kie.kogito.internal.utils.ConversionUtils; import com.github.javaparser.StaticJavaParser; import com.github.javaparser.ast.NodeList; import com.github.javaparser.ast.expr.Expression; -import com.github.javaparser.ast.expr.NullLiteralExpr; import com.github.javaparser.ast.expr.ObjectCreationExpr; import com.github.javaparser.ast.expr.StringLiteralExpr; -public class XPATHConstraintEvaluatorBuilder implements ConstraintEvaluatorBuilder { +public class XPATHConstraintEvaluatorBuilder implements ReturnValueEvaluatorBuilder { @Override - public boolean accept(Constraint constraint) { - return constraint.getDialect().toLowerCase().contains("xpath"); + public boolean accept(String dialect) { + return dialect.toLowerCase().contains("xpath"); } @Override - public Expression build(ContextResolver resolver, Constraint constraint) { + public Expression build(ContextResolver resolver, String expression, Class type, String rootName) { return new ObjectCreationExpr(null, StaticJavaParser.parseClassOrInterfaceType(XPATHReturnValueEvaluator.class.getName()), - new NodeList<>(new StringLiteralExpr(ConversionUtils.sanitizeString(constraint.getConstraint())), new NullLiteralExpr())); + new NodeList<>(new StringLiteralExpr(ConversionUtils.sanitizeString(expression)))); } } diff --git a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/SplitNodeVisitorBuilder.java b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/SplitNodeVisitorBuilder.java index 3d29c31d317..ca874e76af6 100644 --- a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/SplitNodeVisitorBuilder.java +++ b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/SplitNodeVisitorBuilder.java @@ -20,6 +20,7 @@ import org.jbpm.compiler.canonical.AbstractNodeVisitor; import org.jbpm.compiler.canonical.SplitNodeVisitor; +import org.jbpm.compiler.canonical.builtin.ReturnValueEvaluatorBuilderService; import org.jbpm.workflow.core.node.Split; import org.kie.api.definition.process.Node; @@ -32,7 +33,7 @@ public Class type() { @Override public AbstractNodeVisitor visitor(NodeVisitorBuilderService nodeVisitorService, ClassLoader classLoader) { - return new SplitNodeVisitor(); + return new SplitNodeVisitor(ReturnValueEvaluatorBuilderService.instance(classLoader)); } } diff --git a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/process/builder/dialect/mvel/MVELReturnValueEvaluatorBuilder.java b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/process/builder/dialect/mvel/MVELReturnValueEvaluatorBuilder.java index 9fe85827023..6ee7990f961 100755 --- a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/process/builder/dialect/mvel/MVELReturnValueEvaluatorBuilder.java +++ b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/process/builder/dialect/mvel/MVELReturnValueEvaluatorBuilder.java @@ -120,8 +120,7 @@ public void buildReturnValueEvaluator(final PackageBuildContext context, false, MVELCompilationUnit.Scope.EXPRESSION); - MVELReturnValueEvaluator expr = new MVELReturnValueEvaluator(unit, - dialect.getId()); + MVELReturnValueEvaluator expr = new MVELReturnValueEvaluator(unit); constraintNode.setEvaluator(expr); diff --git a/jbpm/jbpm-flow-builder/src/main/resources/META-INF/services/org.jbpm.compiler.canonical.builtin.ConstraintEvaluatorBuilder b/jbpm/jbpm-flow-builder/src/main/resources/META-INF/services/org.jbpm.compiler.canonical.builtin.ReturnValueEvaluatorBuilder similarity index 65% rename from jbpm/jbpm-flow-builder/src/main/resources/META-INF/services/org.jbpm.compiler.canonical.builtin.ConstraintEvaluatorBuilder rename to jbpm/jbpm-flow-builder/src/main/resources/META-INF/services/org.jbpm.compiler.canonical.builtin.ReturnValueEvaluatorBuilder index 2b3fc98021d..425017a9b70 100644 --- a/jbpm/jbpm-flow-builder/src/main/resources/META-INF/services/org.jbpm.compiler.canonical.builtin.ConstraintEvaluatorBuilder +++ b/jbpm/jbpm-flow-builder/src/main/resources/META-INF/services/org.jbpm.compiler.canonical.builtin.ReturnValueEvaluatorBuilder @@ -1,5 +1,6 @@ -org.jbpm.compiler.canonical.builtin.ExpressionConstraintEvaluatorBuilder org.jbpm.compiler.canonical.builtin.FEELConstraintEvaluatorBuilder org.jbpm.compiler.canonical.builtin.JavaConstraintEvaluatorBuilder org.jbpm.compiler.canonical.builtin.XPATHConstraintEvaluatorBuilder -org.jbpm.compiler.canonical.builtin.MVELConstraintEvaluatorBuilder \ No newline at end of file +org.jbpm.compiler.canonical.builtin.MVELConstraintEvaluatorBuilder +org.jbpm.compiler.canonical.builtin.JsonpathReturnValueEvaluatorBuilder +org.jbpm.compiler.canonical.builtin.JqReturnValueEvaluatorBuilder \ No newline at end of file diff --git a/jbpm/jbpm-flow-builder/src/main/resources/org/jbpm/process/builder/dialect/java/javaInvokers.mvel b/jbpm/jbpm-flow-builder/src/main/resources/org/jbpm/process/builder/dialect/java/javaInvokers.mvel index 3a6f2569589..22c345478c9 100755 --- a/jbpm/jbpm-flow-builder/src/main/resources/org/jbpm/process/builder/dialect/java/javaInvokers.mvel +++ b/jbpm/jbpm-flow-builder/src/main/resources/org/jbpm/process/builder/dialect/java/javaInvokers.mvel @@ -53,7 +53,8 @@ public class @{invokerClassName} implements org.jbpm.process.instance.impl.Retur { private static final long serialVersionUID = 510l; - public Object evaluate(org.kie.kogito.internal.process.runtime.KogitoProcessContext processContext) throws Exception { + public Object evaluate(org.kie.kogito.internal.process.runtime.KogitoProcessContext processContext) { + try { @foreach{type : globalTypes, identifier : globals} @{type} @{identifier} = ( @{type} ) processContext.getKieRuntime().getGlobal( "@{identifier}" ); @end{} @@ -67,8 +68,11 @@ public class @{invokerClassName} implements org.jbpm.process.instance.impl.Retur @end{","}@if{variables != empty},@end{} @foreach{identifier : variables} @{identifier} @end{","} ); + } catch(Exception e) { + return new RuntimeException(e); + } } - + public String getMethodBytecode() { return null; } diff --git a/jbpm/jbpm-flow/src/main/java/org/jbpm/process/core/correlation/CorrelationExpressionEvaluator.java b/jbpm/jbpm-flow/src/main/java/org/jbpm/process/core/correlation/CorrelationExpressionEvaluator.java deleted file mode 100644 index dc6dbafdea8..00000000000 --- a/jbpm/jbpm-flow/src/main/java/org/jbpm/process/core/correlation/CorrelationExpressionEvaluator.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jbpm.process.core.correlation; - -import java.io.Serializable; -import java.util.function.Function; - -public interface CorrelationExpressionEvaluator extends Serializable { - - Object eval(Object event); - - Object eval(Function resolver); -} \ No newline at end of file diff --git a/jbpm/jbpm-flow/src/main/java/org/jbpm/process/core/correlation/CorrelationManager.java b/jbpm/jbpm-flow/src/main/java/org/jbpm/process/core/correlation/CorrelationManager.java index 7124c9d018e..0237938fd30 100644 --- a/jbpm/jbpm-flow/src/main/java/org/jbpm/process/core/correlation/CorrelationManager.java +++ b/jbpm/jbpm-flow/src/main/java/org/jbpm/process/core/correlation/CorrelationManager.java @@ -21,8 +21,12 @@ import java.io.Serializable; import java.util.HashMap; import java.util.Map; +import java.util.Set; import java.util.function.Function; +import org.jbpm.process.instance.impl.ReturnValueEvaluator; +import org.jbpm.util.JbpmClassLoaderUtil; + public class CorrelationManager implements Serializable { private static final long serialVersionUID = -1557112455565607001L; @@ -35,6 +39,7 @@ public class CorrelationManager implements Serializable { public CorrelationManager() { this.correlations = new HashMap<>(); this.messages = new HashMap<>(); + this.classLoader = JbpmClassLoaderUtil.findClassLoader(); } public void setClassLoader(ClassLoader classLoader) { @@ -91,7 +96,7 @@ public CorrelationInstance computeCorrelationInstance(String messageRef, Object CorrelationInstance correlationInstance = new CorrelationInstance(correlation.getId(), correlation.getName()); CorrelationProperties properties = correlation.getMessageCorrelationFor(messageRef); for (String name : properties.names()) { - CorrelationExpressionEvaluator evaluator = properties.getExpressionFor(name); + ReturnValueEvaluator evaluator = properties.getExpressionFor(name); Object val = evaluator.eval(event); if (val == null) { throw new IllegalArgumentException("Message property evaluated to null is not possible: " + messageRef + " property " + name); @@ -110,7 +115,7 @@ public CorrelationInstance computeSubscription(String messageRef, Function getMessagesId() { + return messages.keySet(); + } + + public Message findMessageById(String messageId) { + return messages.get(messageId); + } + + public Set getCorrelationsId() { + return correlations.keySet(); + } + + public Correlation findCorrelationById(String correlationId) { + return correlations.get(correlationId); + } + } \ No newline at end of file diff --git a/jbpm/jbpm-flow/src/main/java/org/jbpm/process/core/correlation/CorrelationProperties.java b/jbpm/jbpm-flow/src/main/java/org/jbpm/process/core/correlation/CorrelationProperties.java index 9fa437ff05a..92d77747064 100644 --- a/jbpm/jbpm-flow/src/main/java/org/jbpm/process/core/correlation/CorrelationProperties.java +++ b/jbpm/jbpm-flow/src/main/java/org/jbpm/process/core/correlation/CorrelationProperties.java @@ -23,17 +23,19 @@ import java.util.HashMap; import java.util.Map; +import org.jbpm.process.instance.impl.ReturnValueEvaluator; + public class CorrelationProperties implements Serializable { private static final long serialVersionUID = 4740957354662392843L; - private Map properties; + private Map properties; public CorrelationProperties() { this.properties = new HashMap<>(); } - public void addProperty(String name, CorrelationExpressionEvaluator expression) { + public void addProperty(String name, ReturnValueEvaluator expression) { properties.put(name, expression); } @@ -45,7 +47,7 @@ public Collection names() { return properties.keySet(); } - public CorrelationExpressionEvaluator getExpressionFor(String propertyName) { + public ReturnValueEvaluator getExpressionFor(String propertyName) { return properties.get(propertyName); } diff --git a/jbpm/jbpm-flow/src/main/java/org/jbpm/process/core/event/EventTypeFilter.java b/jbpm/jbpm-flow/src/main/java/org/jbpm/process/core/event/EventTypeFilter.java index 6177d6cbcc5..01ee3388e2a 100755 --- a/jbpm/jbpm-flow/src/main/java/org/jbpm/process/core/event/EventTypeFilter.java +++ b/jbpm/jbpm-flow/src/main/java/org/jbpm/process/core/event/EventTypeFilter.java @@ -61,7 +61,7 @@ public String toString() { @Override public boolean acceptsEvent(String type, Object event, Function resolver) { - logger.info("This event is subscribed to a message ref {} {}", type, event); + logger.debug("This event is subscribed to a message type {} with payload {}", type, event); if (resolver == null) { return this.type != null && this.type.equals(type); } diff --git a/jbpm/jbpm-flow/src/main/java/org/jbpm/process/core/event/MVELMessageExpressionEvaluator.java b/jbpm/jbpm-flow/src/main/java/org/jbpm/process/core/event/MVELMessageExpressionEvaluator.java deleted file mode 100644 index a16e9e920cc..00000000000 --- a/jbpm/jbpm-flow/src/main/java/org/jbpm/process/core/event/MVELMessageExpressionEvaluator.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jbpm.process.core.event; - -import java.util.function.Function; - -import org.jbpm.process.core.correlation.CorrelationExpressionEvaluator; -import org.mvel2.MVEL; -import org.mvel2.integration.VariableResolver; -import org.mvel2.integration.impl.ImmutableDefaultFactory; -import org.mvel2.integration.impl.SimpleValueResolver; - -public class MVELMessageExpressionEvaluator implements CorrelationExpressionEvaluator { - - private static final long serialVersionUID = 3516244528735842694L; - - private String expression; - - public MVELMessageExpressionEvaluator(String expression) { - this.expression = expression; - } - - @Override - public Object eval(Object event) { - return MVEL.eval(expression, event); - } - - @Override - public Object eval(Function resolver) { - ImmutableDefaultFactory factory = new ImmutableDefaultFactory() { - private static final long serialVersionUID = 1L; - - @Override - public boolean isResolveable(String name) { - return resolver.apply("#{" + name + "}") != null; - }; - - @Override - public VariableResolver getVariableResolver(String name) { - return new SimpleValueResolver(resolver.apply("#{" + name + "}")); - }; - }; - return MVEL.eval(expression, factory); - } - -} \ No newline at end of file diff --git a/jbpm/jbpm-flow/src/main/java/org/jbpm/process/instance/KogitoProcessContextImpl.java b/jbpm/jbpm-flow/src/main/java/org/jbpm/process/instance/KogitoProcessContextImpl.java index d562db27a7b..1b2bba1bda2 100755 --- a/jbpm/jbpm-flow/src/main/java/org/jbpm/process/instance/KogitoProcessContextImpl.java +++ b/jbpm/jbpm-flow/src/main/java/org/jbpm/process/instance/KogitoProcessContextImpl.java @@ -22,6 +22,8 @@ import java.util.Map; import org.drools.core.process.AbstractProcessContext; +import org.jbpm.process.core.ContextResolver; +import org.jbpm.process.core.context.variable.VariableScope; import org.kie.api.runtime.KieRuntime; import org.kie.kogito.internal.process.runtime.KogitoNodeInstance; import org.kie.kogito.internal.process.runtime.KogitoProcessContext; @@ -37,6 +39,20 @@ public KogitoProcessContextImpl(KieRuntime kruntime) { contextData = new HashMap<>(); } + public boolean isVariableResolvable(String variableId) { + if (contextData.containsKey(variableId)) { + return true; + } + + KogitoNodeInstance nodeInstance = getNodeInstance(); + if (nodeInstance instanceof ContextResolver) { + ContextResolver resolver = (ContextResolver) nodeInstance; + return resolver.resolveContext(VariableScope.VARIABLE_SCOPE, variableId) != null; + } + + return nodeInstance.getVariable(variableId) != null; + } + @Override public KogitoProcessInstance getProcessInstance() { return (KogitoProcessInstance) super.getProcessInstance(); diff --git a/jbpm/jbpm-flow/src/main/java/org/jbpm/process/instance/LightProcessRuntimeContext.java b/jbpm/jbpm-flow/src/main/java/org/jbpm/process/instance/LightProcessRuntimeContext.java index 29749236421..3fe0f58ebc6 100644 --- a/jbpm/jbpm-flow/src/main/java/org/jbpm/process/instance/LightProcessRuntimeContext.java +++ b/jbpm/jbpm-flow/src/main/java/org/jbpm/process/instance/LightProcessRuntimeContext.java @@ -71,7 +71,7 @@ public void addEventListener(DefaultAgendaEventListener conditional) { @Override public boolean isActive() { - return false; + return true; } @Override diff --git a/jbpm/jbpm-flow/src/main/java/org/jbpm/process/instance/impl/AbstractReturnValueEvaluator.java b/jbpm/jbpm-flow/src/main/java/org/jbpm/process/instance/impl/AbstractReturnValueEvaluator.java new file mode 100644 index 00000000000..465a8452b3d --- /dev/null +++ b/jbpm/jbpm-flow/src/main/java/org/jbpm/process/instance/impl/AbstractReturnValueEvaluator.java @@ -0,0 +1,76 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.jbpm.process.instance.impl; + +import java.io.Externalizable; +import java.io.IOException; +import java.io.ObjectInput; +import java.io.ObjectOutput; + +public abstract class AbstractReturnValueEvaluator implements ReturnValueEvaluator, Externalizable { + + protected String dialect; + protected String expression; + protected Class type; + private String root; + + public AbstractReturnValueEvaluator(String dialect, String expression) { + this(dialect, expression, Object.class, null); + } + + public AbstractReturnValueEvaluator(String dialect, String expression, Class type, String root) { + this.dialect = dialect; + this.expression = expression; + this.type = type; + this.root = root; + } + + @Override + public String root() { + return root; + } + + @Override + public Class type() { + return type; + } + + @Override + public String dialect() { + return dialect; + } + + @Override + public String expression() { + return expression; + } + + public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { + this.expression = in.readUTF(); + } + + public void writeExternal(ObjectOutput out) throws IOException { + out.writeUTF(this.expression); + } + + public String toString() { + return "[" + dialect + "] (" + this.expression + ")"; + } + +} diff --git a/jbpm/jbpm-flow/src/main/java/org/jbpm/process/instance/impl/EmtpyKogitoProcessContext.java b/jbpm/jbpm-flow/src/main/java/org/jbpm/process/instance/impl/EmtpyKogitoProcessContext.java new file mode 100644 index 00000000000..3d1e3477e6e --- /dev/null +++ b/jbpm/jbpm-flow/src/main/java/org/jbpm/process/instance/impl/EmtpyKogitoProcessContext.java @@ -0,0 +1,75 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.jbpm.process.instance.impl; + +import java.util.Collections; +import java.util.Map; +import java.util.function.Function; + +import org.kie.api.runtime.KieRuntime; +import org.kie.kogito.internal.process.runtime.KogitoNodeInstance; +import org.kie.kogito.internal.process.runtime.KogitoProcessContext; +import org.kie.kogito.internal.process.runtime.KogitoProcessInstance; +import org.kie.kogito.internal.process.runtime.KogitoProcessRuntime; + +public class EmtpyKogitoProcessContext implements KogitoProcessContext { + + private Function resolver; + + public EmtpyKogitoProcessContext(Function resolver) { + this.resolver = resolver; + } + + @Override + public KogitoProcessInstance getProcessInstance() { + throw new UnsupportedOperationException(); + } + + @Override + public KogitoNodeInstance getNodeInstance() { + throw new UnsupportedOperationException(); + } + + @Override + public Object getVariable(String variableName) { + return resolver.apply(variableName); + } + + @Override + public void setVariable(String variableName, Object value) { + throw new UnsupportedOperationException(); + } + + @Override + public KieRuntime getKieRuntime() { + throw new UnsupportedOperationException(); + } + + @Override + public KogitoProcessRuntime getKogitoProcessRuntime() { + throw new UnsupportedOperationException(); + } + + @Override + public Map getContextData() { + return Collections.emptyMap(); + } + +} \ No newline at end of file diff --git a/jbpm/jbpm-flow/src/main/java/org/jbpm/process/instance/impl/ExpressionReturnValueEvaluator.java b/jbpm/jbpm-flow/src/main/java/org/jbpm/process/instance/impl/ExpressionReturnValueEvaluator.java index 4b406140a6e..e4c7ae03d49 100644 --- a/jbpm/jbpm-flow/src/main/java/org/jbpm/process/instance/impl/ExpressionReturnValueEvaluator.java +++ b/jbpm/jbpm-flow/src/main/java/org/jbpm/process/instance/impl/ExpressionReturnValueEvaluator.java @@ -22,23 +22,20 @@ import org.kie.kogito.process.expr.Expression; import org.kie.kogito.process.expr.ExpressionHandlerFactory; -public class ExpressionReturnValueEvaluator implements ReturnValueEvaluator { +public class ExpressionReturnValueEvaluator extends AbstractReturnValueEvaluator { private Expression expression; - private String rootName; - private Class returnType; public ExpressionReturnValueEvaluator(String lang, String expression, String rootName) { this(lang, expression, rootName, Boolean.class); } public ExpressionReturnValueEvaluator(String lang, String expression, String rootName, Class returnType) { + super(lang, expression, returnType, rootName); this.expression = ExpressionHandlerFactory.get(lang, expression); - this.rootName = rootName; - this.returnType = returnType; } @Override - public Object evaluate(KogitoProcessContext processContext) throws Exception { - return expression.eval(processContext.getVariable(rootName), returnType, processContext); + public Object evaluate(KogitoProcessContext processContext) { + return expression.eval(processContext.getVariable(root()), type(), processContext); } } diff --git a/jbpm/jbpm-flow/src/main/java/org/jbpm/process/instance/impl/FeelReturnValueEvaluator.java b/jbpm/jbpm-flow/src/main/java/org/jbpm/process/instance/impl/FeelReturnValueEvaluator.java index 608c0bd7905..9f09d86ff1f 100644 --- a/jbpm/jbpm-flow/src/main/java/org/jbpm/process/instance/impl/FeelReturnValueEvaluator.java +++ b/jbpm/jbpm-flow/src/main/java/org/jbpm/process/instance/impl/FeelReturnValueEvaluator.java @@ -18,10 +18,6 @@ */ package org.jbpm.process.instance.impl; -import java.io.Externalizable; -import java.io.IOException; -import java.io.ObjectInput; -import java.io.ObjectOutput; import java.util.Collections; import java.util.HashMap; import java.util.List; @@ -38,28 +34,17 @@ import org.kie.dmn.feel.parser.feel11.profiles.KieExtendedFEELProfile; import org.kie.kogito.internal.process.runtime.KogitoProcessContext; -public class FeelReturnValueEvaluator implements ReturnValueEvaluator, Externalizable { - - private static final long serialVersionUID = 630l; - - private String expr; +public class FeelReturnValueEvaluator extends AbstractReturnValueEvaluator { public FeelReturnValueEvaluator() { + super("FEEL", "true()"); } public FeelReturnValueEvaluator(String expr) { - this.expr = expr; - } - - public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { - expr = in.readUTF(); + super("FEEL", expr); } - public void writeExternal(ObjectOutput out) throws IOException { - out.writeUTF(expr); - } - - public Object evaluate(KogitoProcessContext context) throws Exception { + public Object evaluate(KogitoProcessContext context) { Map variables = new HashMap<>(); variables.put("kcontext", context); @@ -82,12 +67,12 @@ public Object evaluate(KogitoProcessContext context) throws Exception { FeelErrorEvaluatorListener listener = new FeelErrorEvaluatorListener(); feel.addListener(listener); - Object value = feel.evaluate(expr, variables); + Object value = feel.evaluate(expression(), variables); processErrorEvents(listener.getErrorEvents()); if (!(value instanceof Boolean)) { throw new RuntimeException("Constraints must return boolean values: " + - expr + " returns " + value + + expression() + " returns " + value + (value == null ? "" : " (type=" + value.getClass())); } @@ -113,7 +98,4 @@ public static String eventToMessage(FEELEvent event) { return messageBuilder.toString(); } - public String toString() { - return this.expr; - } } diff --git a/jbpm/jbpm-flow/src/main/java/org/jbpm/process/instance/impl/MVELInterpretedReturnValueEvaluator.java b/jbpm/jbpm-flow/src/main/java/org/jbpm/process/instance/impl/MVELInterpretedReturnValueEvaluator.java index fb57b53f963..5a969fbb5b0 100644 --- a/jbpm/jbpm-flow/src/main/java/org/jbpm/process/instance/impl/MVELInterpretedReturnValueEvaluator.java +++ b/jbpm/jbpm-flow/src/main/java/org/jbpm/process/instance/impl/MVELInterpretedReturnValueEvaluator.java @@ -18,24 +18,51 @@ */ package org.jbpm.process.instance.impl; +import java.util.function.Function; + +import org.jbpm.process.instance.KogitoProcessContextImpl; import org.kie.kogito.internal.process.runtime.KogitoProcessContext; import org.mvel2.MVEL; import org.mvel2.integration.VariableResolver; import org.mvel2.integration.impl.ImmutableDefaultFactory; import org.mvel2.integration.impl.SimpleValueResolver; -public class MVELInterpretedReturnValueEvaluator implements ReturnValueEvaluator { - - private String expr; +public class MVELInterpretedReturnValueEvaluator extends AbstractReturnValueEvaluator { public MVELInterpretedReturnValueEvaluator(String expression) { - this.expr = expression; + super("mvel", expression); + } + + @Override + public Object eval(Object event) { + return MVEL.eval(expression, event); + } + + @Override + public Object eval(Function resolver) { + ImmutableDefaultFactory factory = new ImmutableDefaultFactory() { + private static final long serialVersionUID = 1L; + + @Override + public boolean isResolveable(String name) { + return resolver.apply("#{" + name + "}") != null; + }; + + @Override + public VariableResolver getVariableResolver(String name) { + return new SimpleValueResolver(resolver.apply("#{" + name + "}")); + }; + }; + return MVEL.eval(expression, factory); } - public Object evaluate(KogitoProcessContext context) throws Exception { - Object value = MVEL.eval(this.expr, new ImmutableDefaultFactory() { + public Object evaluate(KogitoProcessContext context) { + Object value = MVEL.eval(this.expression(), new ImmutableDefaultFactory() { @Override public boolean isResolveable(String name) { + if (context instanceof KogitoProcessContextImpl) { + return ((KogitoProcessContextImpl) context).isVariableResolvable(name); + } return context.getVariable(name) != null; }; diff --git a/jbpm/jbpm-flow/src/main/java/org/jbpm/process/instance/impl/MVELReturnValueEvaluator.java b/jbpm/jbpm-flow/src/main/java/org/jbpm/process/instance/impl/MVELReturnValueEvaluator.java index 40fa4b912ef..48950a5ce47 100755 --- a/jbpm/jbpm-flow/src/main/java/org/jbpm/process/instance/impl/MVELReturnValueEvaluator.java +++ b/jbpm/jbpm-flow/src/main/java/org/jbpm/process/instance/impl/MVELReturnValueEvaluator.java @@ -18,7 +18,6 @@ */ package org.jbpm.process.instance.impl; -import java.io.Externalizable; import java.io.IOException; import java.io.ObjectInput; import java.io.ObjectOutput; @@ -36,51 +35,35 @@ import org.kie.kogito.internal.process.runtime.KogitoProcessContext; import org.mvel2.integration.VariableResolverFactory; -public class MVELReturnValueEvaluator - implements - ReturnValueEvaluator, - MVELCompileable, - Externalizable { - private static final long serialVersionUID = 510l; +public class MVELReturnValueEvaluator extends AbstractReturnValueEvaluator implements MVELCompileable { private MVELCompilationUnit unit; - private String id; - private Serializable expr; + private Serializable compiledExpression; - public MVELReturnValueEvaluator() { - } - - public MVELReturnValueEvaluator(final MVELCompilationUnit unit, - final String id) { + public MVELReturnValueEvaluator(MVELCompilationUnit unit) { + super("MVEL", unit.getExpression()); this.unit = unit; - this.id = id; } public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { - id = in.readUTF(); unit = (MVELCompilationUnit) in.readObject(); } public void writeExternal(ObjectOutput out) throws IOException { - out.writeUTF(id); out.writeObject(unit); } public void compile(MVELDialectRuntimeData data) { - expr = unit.getCompiledExpression(data); + compiledExpression = unit.getCompiledExpression(data); } public void compile(MVELDialectRuntimeData data, RuleImpl rule) { - expr = unit.getCompiledExpression(data); - } - - public String getDialect() { - return this.id; + compiledExpression = unit.getCompiledExpression(data); } - public Object evaluate(KogitoProcessContext context) throws Exception { + public Object evaluate(KogitoProcessContext context) { int length = unit.getOtherIdentifiers().length; Object[] vars = new Object[length]; if (unit.getOtherIdentifiers() != null) { @@ -103,13 +86,11 @@ public Object evaluate(KogitoProcessContext context) throws Exception { // do we have any functions for this namespace? KiePackage pkg = context.getKieRuntime().getKieBase().getKiePackage("MAIN"); if (pkg instanceof KnowledgePackageImpl) { - MVELDialectRuntimeData data = (MVELDialectRuntimeData) ((KnowledgePackageImpl) pkg).getDialectRuntimeRegistry().getDialectData(id); + MVELDialectRuntimeData data = (MVELDialectRuntimeData) ((KnowledgePackageImpl) pkg).getDialectRuntimeRegistry().getDialectData(dialect()); factory.setNextFactory(data.getFunctionFactory()); } - Object value = MVELProcessHelper.evaluator().executeExpression(this.expr, - null, - factory); + Object value = MVELProcessHelper.evaluator().executeExpression(compiledExpression, null, factory); if (!(value instanceof Boolean)) { throw new RuntimeException("Constraints must return boolean values: " + @@ -120,12 +101,4 @@ public Object evaluate(KogitoProcessContext context) throws Exception { } - public Serializable getCompExpr() { - return expr; - } - - public String toString() { - return this.unit.getExpression(); - } - } diff --git a/jbpm/jbpm-flow/src/main/java/org/jbpm/process/instance/impl/ReturnValueEvaluator.java b/jbpm/jbpm-flow/src/main/java/org/jbpm/process/instance/impl/ReturnValueEvaluator.java index 351503fec9d..0ee01b45b9e 100755 --- a/jbpm/jbpm-flow/src/main/java/org/jbpm/process/instance/impl/ReturnValueEvaluator.java +++ b/jbpm/jbpm-flow/src/main/java/org/jbpm/process/instance/impl/ReturnValueEvaluator.java @@ -18,9 +18,36 @@ */ package org.jbpm.process.instance.impl; +import java.util.function.Function; + import org.kie.kogito.internal.process.runtime.KogitoProcessContext; public interface ReturnValueEvaluator { - Object evaluate(KogitoProcessContext processContext) throws Exception; + default Class type() { + return Object.class; + } + + default String dialect() { + return "functional"; + } + + default String expression() { + return "functional"; + } + + Object evaluate(KogitoProcessContext processContext); + + default Object eval(Object event) { + return this.eval(name -> "value".equals(name) ? event : null); + } + + default Object eval(Function resolver) { + return this.evaluate(new EmtpyKogitoProcessContext(resolver)); + } + + default String root() { + return null; + } + } diff --git a/jbpm/jbpm-flow/src/main/java/org/jbpm/process/instance/impl/XPATHReturnValueEvaluator.java b/jbpm/jbpm-flow/src/main/java/org/jbpm/process/instance/impl/XPATHReturnValueEvaluator.java index d40c9601a20..3c9fa372d66 100755 --- a/jbpm/jbpm-flow/src/main/java/org/jbpm/process/instance/impl/XPATHReturnValueEvaluator.java +++ b/jbpm/jbpm-flow/src/main/java/org/jbpm/process/instance/impl/XPATHReturnValueEvaluator.java @@ -18,10 +18,6 @@ */ package org.jbpm.process.instance.impl; -import java.io.Externalizable; -import java.io.IOException; -import java.io.ObjectInput; -import java.io.ObjectOutput; import java.util.Arrays; import java.util.Iterator; import java.util.List; @@ -40,97 +36,76 @@ import org.kie.kogito.internal.process.runtime.KogitoProcessContext; -public class XPATHReturnValueEvaluator - implements - ReturnValueEvaluator, - Externalizable { - private static final long serialVersionUID = 510l; - - private String expression; - private String id; +public class XPATHReturnValueEvaluator extends AbstractReturnValueEvaluator { public XPATHReturnValueEvaluator() { + super("XPath", "true()"); } - public XPATHReturnValueEvaluator(final String expression, - final String id) { - this.expression = expression; - this.id = id; - } - - public void readExternal(ObjectInput in) throws IOException, - ClassNotFoundException { - expression = (String) in.readObject(); - } - - public void writeExternal(ObjectOutput out) throws IOException { - out.writeObject(expression); - } - - public String getDialect() { - return this.id; + public XPATHReturnValueEvaluator(final String expression) { + super("XPath", expression); } - public Object evaluate(final KogitoProcessContext context) throws Exception { - XPathFactory factory = XPathFactory.newInstance(); - XPath xpathEvaluator = factory.newXPath(); - xpathEvaluator.setXPathFunctionResolver( - new XPathFunctionResolver() { - public XPathFunction resolveFunction(QName functionName, int arity) { - String localName = functionName.getLocalPart(); - if ("getVariable".equals(localName)) { - return new GetVariableData(); - } else { - throw new IllegalArgumentException("Unknown BPMN function: " + functionName); + public Object evaluate(final KogitoProcessContext context) { + try { + XPathFactory factory = XPathFactory.newInstance(); + XPath xpathEvaluator = factory.newXPath(); + xpathEvaluator.setXPathFunctionResolver( + new XPathFunctionResolver() { + public XPathFunction resolveFunction(QName functionName, int arity) { + String localName = functionName.getLocalPart(); + if ("getVariable".equals(localName)) { + return new GetVariableData(); + } else { + throw new IllegalArgumentException("Unknown BPMN function: " + functionName); + } } - } - class GetVariableData implements XPathFunction { - public Object evaluate(List args) throws XPathFunctionException { - String varname = (String) args.get(0); - return context.getVariable(varname); + class GetVariableData implements XPathFunction { + public Object evaluate(List args) throws XPathFunctionException { + String varname = (String) args.get(0); + return context.getVariable(varname); + } } - } - }); - xpathEvaluator.setXPathVariableResolver(new XPathVariableResolver() { - - public Object resolveVariable(QName variableName) { - return context.getVariable(variableName.getLocalPart()); - } - }); + }); + xpathEvaluator.setXPathVariableResolver(new XPathVariableResolver() { - xpathEvaluator.setNamespaceContext(new NamespaceContext() { - private static final String DROOLS_NAMESPACE_URI = "http://www.jboss.org/drools"; - private String[] prefixes = { "drools", "bpmn2" }; + public Object resolveVariable(QName variableName) { + return context.getVariable(variableName.getLocalPart()); + } + }); - @Override - public Iterator getPrefixes(String namespaceURI) { - return Arrays.asList(prefixes).iterator(); - } + xpathEvaluator.setNamespaceContext(new NamespaceContext() { + private static final String DROOLS_NAMESPACE_URI = "http://www.jboss.org/drools"; + private String[] prefixes = { "drools", "bpmn2" }; - @Override - public String getPrefix(String namespaceURI) { - if (DROOLS_NAMESPACE_URI.equalsIgnoreCase(namespaceURI)) { - return "bpmn2"; + @Override + public Iterator getPrefixes(String namespaceURI) { + return Arrays.asList(prefixes).iterator(); } - return null; - } - @Override - public String getNamespaceURI(String prefix) { - if ("bpmn2".equalsIgnoreCase(prefix)) { - return DROOLS_NAMESPACE_URI; + @Override + public String getPrefix(String namespaceURI) { + if (DROOLS_NAMESPACE_URI.equalsIgnoreCase(namespaceURI)) { + return "bpmn2"; + } + return null; } - return null; - } - }); - DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder(); - return xpathEvaluator.evaluate(this.expression, builder.newDocument(), XPathConstants.BOOLEAN); - } + @Override + public String getNamespaceURI(String prefix) { + if ("bpmn2".equalsIgnoreCase(prefix)) { + return DROOLS_NAMESPACE_URI; + } + return null; + } + }); - public String toString() { - return this.expression; + DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder(); + return xpathEvaluator.evaluate(this.expression, builder.newDocument(), XPathConstants.BOOLEAN); + } catch (Exception ex) { + throw new RuntimeException(ex); + } } } diff --git a/jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/Metadata.java b/jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/Metadata.java index e7b8e0bac25..5b9f6a14286 100644 --- a/jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/Metadata.java +++ b/jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/Metadata.java @@ -26,6 +26,7 @@ public class Metadata { public static final String TRIGGER_REF = "TriggerRef"; public static final String REF = "Ref"; public static final String MESSAGE_TYPE = "MessageType"; + public static final String MESSAGE_REF = "MessageRef"; public static final String SIGNAL_TYPE = "SignalType"; public static final String PRODUCE_MESSAGE = "ProduceMessage"; public static final String CONSUME_MESSAGE = "ConsumeMessage"; diff --git a/jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/RuleFlowProcessFactory.java b/jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/RuleFlowProcessFactory.java index a0acf5d140e..ccfdb3d9933 100755 --- a/jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/RuleFlowProcessFactory.java +++ b/jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/RuleFlowProcessFactory.java @@ -38,6 +38,7 @@ import org.jbpm.process.core.timer.Timer; import org.jbpm.process.core.validation.ProcessValidationError; import org.jbpm.process.instance.impl.Action; +import org.jbpm.process.instance.impl.ReturnValueEvaluator; import org.jbpm.process.instance.impl.actions.CancelNodeInstanceAction; import org.jbpm.process.instance.impl.actions.SignalProcessInstanceAction; import org.jbpm.ruleflow.core.validation.RuleFlowProcessValidator; @@ -243,6 +244,33 @@ public RuleFlowProcessFactory validate() { return this; } + public RuleFlowProcessFactory newCorrelationMessage(String messageId, String messageName, String messageType) { + RuleFlowProcess process = getRuleFlowProcess(); + process.getCorrelationManager().newMessage(messageId, messageName, messageType); + return this; + } + + public RuleFlowProcessFactory newCorrelationKey(String correlationKey, String correlationName) { + RuleFlowProcess process = getRuleFlowProcess(); + process.getCorrelationManager().newCorrelation(correlationKey, correlationName); + return this; + } + + public RuleFlowProcessFactory newCorrelationProperty(String correlationKeyId, String messageId, String propertyId, ReturnValueEvaluator evaluator) { + RuleFlowProcess process = getRuleFlowProcess(); + process.getCorrelationManager().addMessagePropertyExpression(correlationKeyId, messageId, propertyId, evaluator); + return this; + } + + public RuleFlowProcessFactory newCorrelationSubscription(String correlationKeyId, String propertyId, ReturnValueEvaluator evaluator) { + RuleFlowProcess process = getRuleFlowProcess(); + if (!process.getCorrelationManager().isSubscribe(correlationKeyId)) { + process.getCorrelationManager().subscribeTo(correlationKeyId); + } + process.getCorrelationManager().addProcessSubscriptionPropertyExpression(correlationKeyId, propertyId, evaluator); + return this; + } + public RuleFlowProcessFactory link() { RuleFlowProcess process = getRuleFlowProcess(); linkBoundaryEvents(process); diff --git a/jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/factory/AbstractEventNodeFactory.java b/jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/factory/AbstractEventNodeFactory.java index d2dd9209985..ead0080ae2f 100644 --- a/jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/factory/AbstractEventNodeFactory.java +++ b/jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/factory/AbstractEventNodeFactory.java @@ -21,11 +21,14 @@ import org.jbpm.process.core.event.EventFilter; import org.jbpm.process.core.event.EventTypeFilter; import org.jbpm.ruleflow.core.RuleFlowNodeContainerFactory; +import org.jbpm.ruleflow.core.RuleFlowProcess; import org.jbpm.workflow.core.Node; import org.jbpm.workflow.core.NodeContainer; import org.jbpm.workflow.core.node.EventNode; import org.kie.api.definition.process.WorkflowElementIdentifier; +import static org.jbpm.ruleflow.core.Metadata.MESSAGE_REF; + public abstract class AbstractEventNodeFactory, P extends RuleFlowNodeContainerFactory> extends ExtendedNodeFactory { protected AbstractEventNodeFactory(P nodeContainerFactory, NodeContainer nodeContainer, Node node, WorkflowElementIdentifier id) { @@ -54,6 +57,8 @@ public T eventFilter(EventFilter eventFilter) { public T eventType(String eventType) { EventTypeFilter filter = new EventTypeFilter(); filter.setType(eventType); + filter.setCorrelationManager(((RuleFlowProcess) getEventNode().getProcess()).getCorrelationManager()); + filter.setMessageRef((String) getNode().getMetaData().get(MESSAGE_REF)); return eventFilter(filter); } diff --git a/jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/factory/EventSubProcessNodeFactory.java b/jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/factory/EventSubProcessNodeFactory.java index 1244b349934..46aad92e265 100644 --- a/jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/factory/EventSubProcessNodeFactory.java +++ b/jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/factory/EventSubProcessNodeFactory.java @@ -20,10 +20,13 @@ import org.jbpm.process.core.event.EventTypeFilter; import org.jbpm.ruleflow.core.RuleFlowNodeContainerFactory; +import org.jbpm.ruleflow.core.RuleFlowProcess; import org.jbpm.workflow.core.NodeContainer; import org.jbpm.workflow.core.node.EventSubProcessNode; import org.kie.api.definition.process.WorkflowElementIdentifier; +import static org.jbpm.ruleflow.core.Metadata.MESSAGE_REF; + public class EventSubProcessNodeFactory> extends AbstractCompositeNodeFactory, T> { public static final String METHOD_KEEP_ACTIVE = "keepActive"; @@ -41,6 +44,8 @@ public EventSubProcessNodeFactory keepActive(boolean keepActive) { public EventSubProcessNodeFactory event(String event) { EventTypeFilter filter = new EventTypeFilter(); filter.setType(event); + filter.setCorrelationManager(((RuleFlowProcess) getCompositeNode().getProcess()).getCorrelationManager()); + filter.setMessageRef((String) getNode().getMetaData().get(MESSAGE_REF)); ((EventSubProcessNode) getCompositeNode()).addEvent(filter); return this; } diff --git a/jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/factory/StartNodeFactory.java b/jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/factory/StartNodeFactory.java index 27954c9d1fd..3aa38c4b33a 100755 --- a/jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/factory/StartNodeFactory.java +++ b/jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/factory/StartNodeFactory.java @@ -23,12 +23,15 @@ import org.jbpm.process.core.event.EventTypeFilter; import org.jbpm.process.core.timer.Timer; import org.jbpm.ruleflow.core.RuleFlowNodeContainerFactory; +import org.jbpm.ruleflow.core.RuleFlowProcess; import org.jbpm.workflow.core.NodeContainer; import org.jbpm.workflow.core.impl.DataAssociation; import org.jbpm.workflow.core.node.EventTrigger; import org.jbpm.workflow.core.node.StartNode; import org.kie.api.definition.process.WorkflowElementIdentifier; +import static org.jbpm.ruleflow.core.Metadata.MESSAGE_REF; + public class StartNodeFactory> extends NodeFactory, T> { public static final String METHOD_INTERRUPTING = "interrupting"; @@ -51,7 +54,9 @@ public StartNodeFactory interrupting(boolean interrupting) { public StartNodeFactory trigger(String triggerEventType, List dataAssociations) { EventTrigger trigger = new EventTrigger(); EventTypeFilter eventFilter = new EventTypeFilter(); + eventFilter.setCorrelationManager(((RuleFlowProcess) getStartNode().getProcess()).getCorrelationManager()); eventFilter.setType(triggerEventType); + eventFilter.setMessageRef((String) getNode().getMetaData().get(MESSAGE_REF)); trigger.addEventFilter(eventFilter); dataAssociations.forEach(trigger::addInAssociation); getStartNode().addTrigger(trigger); @@ -65,6 +70,8 @@ public StartNodeFactory trigger(String triggerEventType, String target) { public StartNodeFactory trigger(String triggerEventType, String source, String target) { EventTrigger trigger = new EventTrigger(); EventTypeFilter eventFilter = new EventTypeFilter(); + eventFilter.setCorrelationManager(((RuleFlowProcess) getStartNode().getProcess()).getCorrelationManager()); + eventFilter.setMessageRef((String) getNode().getMetaData().get(MESSAGE_REF)); eventFilter.setType(triggerEventType); trigger.addEventFilter(eventFilter); if (source != null) { diff --git a/jbpm/jbpm-flow/src/main/java/org/kie/kogito/process/impl/AbstractProcess.java b/jbpm/jbpm-flow/src/main/java/org/kie/kogito/process/impl/AbstractProcess.java index 355431254c4..3881821765d 100644 --- a/jbpm/jbpm-flow/src/main/java/org/kie/kogito/process/impl/AbstractProcess.java +++ b/jbpm/jbpm-flow/src/main/java/org/kie/kogito/process/impl/AbstractProcess.java @@ -170,6 +170,7 @@ public CorrelationService correlations() { @Override public void send(Signal signal) { + getProcessRuntime().signalEvent(signal.channel(), signal.payload()); try (Stream> stream = instances.stream()) { stream.forEach(pi -> pi.send(signal)); } diff --git a/jbpm/jbpm-tests/src/test/java/org/jbpm/bpmn2/CollaborationTest.java b/jbpm/jbpm-tests/src/test/java/org/jbpm/bpmn2/CollaborationTest.java index b924be42f14..fb88b9b55b5 100644 --- a/jbpm/jbpm-tests/src/test/java/org/jbpm/bpmn2/CollaborationTest.java +++ b/jbpm/jbpm-tests/src/test/java/org/jbpm/bpmn2/CollaborationTest.java @@ -18,11 +18,23 @@ */ package org.jbpm.bpmn2; -import java.util.Collections; +import java.util.ArrayList; +import java.util.List; +import org.jbpm.bpmn2.collaboration.CollaborationBoundaryMessageModel; +import org.jbpm.bpmn2.collaboration.CollaborationBoundaryMessageProcess; +import org.jbpm.bpmn2.collaboration.CollaborationIntermediateMessageModel; +import org.jbpm.bpmn2.collaboration.CollaborationIntermediateMessageProcess; +import org.jbpm.bpmn2.collaboration.CollaborationStartMessageModel; +import org.jbpm.bpmn2.collaboration.CollaborationStartMessageProcess; import org.jbpm.process.instance.impl.demo.DoNothingWorkItemHandler; +import org.jbpm.test.utils.ProcessTestHelper; import org.junit.jupiter.api.Test; -import org.kie.kogito.internal.process.runtime.KogitoProcessInstance; +import org.kie.api.event.process.ProcessStartedEvent; +import org.kie.api.runtime.process.ProcessInstance; +import org.kie.kogito.Application; +import org.kie.kogito.internal.process.event.DefaultKogitoProcessEventListener; +import org.kie.kogito.process.impl.Sig; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; @@ -31,49 +43,91 @@ public class CollaborationTest extends JbpmBpmn2TestCase { @Test public void testBoundaryMessageCollaboration() throws Exception { - kruntime = createKogitoProcessRuntime("org/jbpm/bpmn2/collaboration/BPMN2-CollaborationBoundaryMessage.bpmn2"); - kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Human Task", new DoNothingWorkItemHandler()); - KogitoProcessInstance pid = kruntime.startProcess("CollaborationBoundaryMessage", Collections.singletonMap("MessageId", "2")); - kruntime.signalEvent("Message-collaboration", new Message("1", "example"), pid.getStringId()); - assertProcessInstanceActive(pid); - kruntime.signalEvent("Message-collaboration", new Message("2", "example"), pid.getStringId()); - assertProcessInstanceCompleted(pid); + Application application = ProcessTestHelper.newApplication(); + ProcessTestHelper.registerHandler(application, "Human Task", new DoNothingWorkItemHandler()); + org.kie.kogito.process.Process processDefinition = CollaborationBoundaryMessageProcess.newProcess(application); + CollaborationBoundaryMessageModel variables = processDefinition.createModel(); + variables.setMessageId("2"); + org.kie.kogito.process.ProcessInstance processInstance = processDefinition.createInstance(variables); + processInstance.start(); + processInstance.send(Sig.of("Message-collaboration", new Message("1", "example"))); + + assertThat(processInstance.status()).isEqualTo(ProcessInstance.STATE_ACTIVE); + processInstance.send(Sig.of("Message-collaboration", new Message("2", "example"))); + assertThat(processInstance.status()).isEqualTo(ProcessInstance.STATE_COMPLETED); + } @Test public void testStartMessageCollaboration() throws Exception { - kruntime = createKogitoProcessRuntime("org/jbpm/bpmn2/collaboration/BPMN2-CollaborationStartMessage.bpmn2"); - kruntime.signalEvent("Message-collaboration", new Message("1", "example")); - assertThat(getNumberOfProcessInstances("CollaborationStartMessage")).isEqualTo(1); + final List processInstanceId = new ArrayList<>(); + Application application = ProcessTestHelper.newApplication(); + ProcessTestHelper.registerProcessEventListener(application, new DefaultKogitoProcessEventListener() { + @Override + public void beforeProcessStarted(ProcessStartedEvent event) { + processInstanceId.add(event.getProcessInstance().getId()); + } + }); + ProcessTestHelper.registerHandler(application, "Human Task", new DoNothingWorkItemHandler()); + org.kie.kogito.process.Process processDefinition = CollaborationStartMessageProcess.newProcess(application); + + processDefinition.send(Sig.of("collaboration", new Message("1", "example"))); + + assertThat(processInstanceId).hasSize(1); + } @Test public void testStartMessageCollaborationNoMatch() throws Exception { - kruntime = createKogitoProcessRuntime("org/jbpm/bpmn2/collaboration/BPMN2-CollaborationStartMessage.bpmn2"); + final List processInstanceId = new ArrayList<>(); + Application application = ProcessTestHelper.newApplication(); + ProcessTestHelper.registerProcessEventListener(application, new DefaultKogitoProcessEventListener() { + @Override + public void beforeProcessStarted(ProcessStartedEvent event) { + processInstanceId.add(event.getProcessInstance().getId()); + } + }); + ProcessTestHelper.registerHandler(application, "Human Task", new DoNothingWorkItemHandler()); + org.kie.kogito.process.Process processDefinition = CollaborationStartMessageProcess.newProcess(application); + + processDefinition.send(Sig.of("Message-collaboration", new Message("2", "example"))); + + assertThat(processInstanceId).hasSize(0); - kruntime.signalEvent("Message-collaboration", new Message("2", "example")); - assertThat(getNumberOfProcessInstances("CollaborationStartMessage")).isZero(); } @Test public void testIntermediateMessageCollaboration() throws Exception { - kruntime = createKogitoProcessRuntime("org/jbpm/bpmn2/collaboration/BPMN2-CollaborationIntermediateMessage.bpmn2"); - KogitoProcessInstance pid = kruntime.startProcess("CollaborationIntermediateMessage", Collections.singletonMap("MessageId", "2")); - kruntime.signalEvent("Message-collaboration", new Message("1", "example"), pid.getStringId()); - assertProcessInstanceActive(pid); - kruntime.signalEvent("Message-collaboration", new Message("2", "example"), pid.getStringId()); - assertProcessInstanceCompleted(pid); + Application application = ProcessTestHelper.newApplication(); + ProcessTestHelper.registerHandler(application, "Human Task", new DoNothingWorkItemHandler()); + org.kie.kogito.process.Process processDefinition = CollaborationIntermediateMessageProcess.newProcess(application); + CollaborationIntermediateMessageModel variables = processDefinition.createModel(); + variables.setMessageId("2"); + org.kie.kogito.process.ProcessInstance processInstance = processDefinition.createInstance(variables); + processInstance.start(); + processInstance.send(Sig.of("Message-collaboration", new Message("1", "example"))); + + assertThat(processInstance.status()).isEqualTo(ProcessInstance.STATE_ACTIVE); + processInstance.send(Sig.of("Message-collaboration", new Message("2", "example"))); + assertThat(processInstance.status()).isEqualTo(ProcessInstance.STATE_COMPLETED); + } @Test public void testInvalidIntermediateMessageCollaboration() throws Exception { - kruntime = createKogitoProcessRuntime("org/jbpm/bpmn2/collaboration/BPMN2-CollaborationIntermediateMessage.bpmn2"); + Application application = ProcessTestHelper.newApplication(); + ProcessTestHelper.registerHandler(application, "Human Task", new DoNothingWorkItemHandler()); + org.kie.kogito.process.Process processDefinition = CollaborationIntermediateMessageProcess.newProcess(application); + CollaborationIntermediateMessageModel variables = processDefinition.createModel(); + variables.setMessageId("2"); + org.kie.kogito.process.ProcessInstance processInstance = processDefinition.createInstance(variables); + processInstance.start(); - KogitoProcessInstance pid = kruntime.startProcess("CollaborationIntermediateMessage", Collections.singletonMap("MessageId", "2")); assertThatExceptionOfType(IllegalArgumentException.class).isThrownBy(() -> { - kruntime.signalEvent("Message-collaboration", new Message(null, "example"), pid.getStringId()); + processInstance.send(Sig.of("Message-collaboration", new Message(null, "example"))); }); - - assertProcessInstanceActive(pid); + assertThat(processInstance.status()).isEqualTo(ProcessInstance.STATE_ACTIVE); + processInstance.send(Sig.of("Message-collaboration", new Message("2", "example"))); + assertThat(processInstance.status()).isEqualTo(ProcessInstance.STATE_COMPLETED); } } diff --git a/jbpm/jbpm-tools/jbpm-tools-maven-plugin/src/test/resources/unit/project/src/main/bpmn/BPMN2-XpathExpression.bpmn2 b/jbpm/jbpm-tools/jbpm-tools-maven-plugin/src/test/resources/unit/project/src/main/bpmn/BPMN2-XpathExpression.bpmn2 new file mode 100755 index 00000000000..93d72711cfd --- /dev/null +++ b/jbpm/jbpm-tools/jbpm-tools-maven-plugin/src/test/resources/unit/project/src/main/bpmn/BPMN2-XpathExpression.bpmn2 @@ -0,0 +1,114 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + count($instanceMetadata/instanceMetadata/user[@approved='true']) = 1 + + + count($instanceMetadata/instanceMetadata/user[@approved='false']) = 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file From 534f7dc1ccc8f33ea2e0344cb245f8b671d5d28a Mon Sep 17 00:00:00 2001 From: Enrique Date: Tue, 28 May 2024 10:41:46 +0200 Subject: [PATCH 23/32] [incubator-kie-issues-1146] Add support for transformations in input/output in activities (#3494) --- .../jbpm/bpmn2/xml/AbstractNodeHandler.java | 5 +- .../canonical/AbstractNodeVisitor.java | 10 +- .../DataTransformerCompiler.java | 39 ++++ .../DataTransformerCompilerRegistry.java | 72 +++++++ .../DefaultDataTransformerCompiler.java | 57 ++++++ .../JavaDataTransformerCompiler.java | 65 +++++++ ...der.transformation.DataTransformerCompiler | 2 + .../core/impl/DataTransformerRegistry.java | 2 + .../transformation/JavaDataTransformer.java | 39 ++++ .../workflow/core/impl/DataDefinition.java | 15 +- .../workflow/core/node/Transformation.java | 16 +- ...rySignalEventOnTaskWithTransformation.bpmn | 175 ++++++++++++++++++ .../org/jbpm/bpmn2/IntermediateEventTest.java | 40 ++-- .../jbpm-tools-maven-plugin/pom.xml | 5 + ...rySignalEventOnTaskWithTransformation.bpmn | 2 +- 15 files changed, 502 insertions(+), 42 deletions(-) create mode 100644 jbpm/jbpm-flow-builder/src/main/java/org/jbpm/process/builder/transformation/DataTransformerCompiler.java create mode 100755 jbpm/jbpm-flow-builder/src/main/java/org/jbpm/process/builder/transformation/DataTransformerCompilerRegistry.java create mode 100644 jbpm/jbpm-flow-builder/src/main/java/org/jbpm/process/builder/transformation/DefaultDataTransformerCompiler.java create mode 100644 jbpm/jbpm-flow-builder/src/main/java/org/jbpm/process/builder/transformation/JavaDataTransformerCompiler.java create mode 100644 jbpm/jbpm-flow-builder/src/main/resources/META-INF/services/org.jbpm.process.builder.transformation.DataTransformerCompiler create mode 100644 jbpm/jbpm-flow/src/main/java/org/jbpm/process/core/transformation/JavaDataTransformer.java create mode 100755 jbpm/jbpm-tests/src/test/bpmn/org/jbpm/bpmn2/activity/BPMN2-BoundarySignalEventOnTaskWithTransformation.bpmn rename jbpm/{jbpm-tests/src/test/resources => jbpm-tools/jbpm-tools-maven-plugin/src/test/resources/unit/project/src/main/bpmn}/BPMN2-BoundarySignalEventOnTaskWithTransformation.bpmn (99%) diff --git a/jbpm/jbpm-bpmn2/src/main/java/org/jbpm/bpmn2/xml/AbstractNodeHandler.java b/jbpm/jbpm-bpmn2/src/main/java/org/jbpm/bpmn2/xml/AbstractNodeHandler.java index 93d771f0caa..7a16ef7380e 100755 --- a/jbpm/jbpm-bpmn2/src/main/java/org/jbpm/bpmn2/xml/AbstractNodeHandler.java +++ b/jbpm/jbpm-bpmn2/src/main/java/org/jbpm/bpmn2/xml/AbstractNodeHandler.java @@ -409,7 +409,7 @@ protected DataDefinition getVariableDataSpec(Parser parser, String propertyIdRef return null; } Variable variable = var.get(); - return new DataDefinition(variable.getId(), variable.getName(), variable.getType().getStringType()); + return new DataDefinition(variable.getId(), variable.getName(), variable); } protected ItemDefinition getStructureRef(Parser parser, String id) { @@ -630,10 +630,9 @@ private String cleanUp(String expression) { } private DataDefinition toDataExpression(String expression) { - DataDefinition dataSpec = new DataDefinition(UUID.randomUUID().toString(), "EXPRESSION (" + expression + ")", null); + DataDefinition dataSpec = new DataDefinition(UUID.randomUUID().toString(), "EXPRESSION (" + expression + ")", (String) null); dataSpec.setExpression(expression); return dataSpec; - } private boolean isExpr(String mvelExpression) { diff --git a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/AbstractNodeVisitor.java b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/AbstractNodeVisitor.java index e3429dcdbb4..27595fe2e74 100644 --- a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/AbstractNodeVisitor.java +++ b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/AbstractNodeVisitor.java @@ -25,6 +25,7 @@ import java.util.stream.Collectors; import org.jbpm.process.builder.action.ActionCompilerRegistry; +import org.jbpm.process.builder.transformation.DataTransformerCompilerRegistry; import org.jbpm.process.core.ContextContainer; import org.jbpm.process.core.context.variable.Mappable; import org.jbpm.process.core.context.variable.Variable; @@ -69,6 +70,7 @@ import com.github.javaparser.ast.type.WildcardType; import static com.github.javaparser.StaticJavaParser.parseClassOrInterfaceType; +import static java.util.Collections.singletonList; import static org.drools.util.StringUtils.ucFirst; import static org.jbpm.ruleflow.core.Metadata.CUSTOM_AUTO_START; import static org.jbpm.ruleflow.core.Metadata.HIDDEN; @@ -230,7 +232,7 @@ protected Expression buildDataAssociationExpression(DataAssociation dataAssociat DataDefinition targetExpr = dataAssociation.getTarget(); Transformation transformation = dataAssociation.getTransformation(); List assignments = dataAssociation.getAssignments(); - return toDataAssociation(toDataDef(sourceExpr), toDataDef(targetExpr), toAssignmentExpr(assignments), toTransformation(transformation)); + return toDataAssociation(toDataDef(sourceExpr), toDataDef(targetExpr), toAssignmentExpr(assignments), toTransformation(sourceExpr, singletonList(targetExpr), transformation)); } private Expression toAssignmentExpr(List assignments) { @@ -250,15 +252,15 @@ private Expression toAssignmentExpr(List assignments) { return new MethodCallExpr(null, "java.util.Arrays.asList", NodeList.nodeList(expressions)); } - protected Expression toTransformation(Transformation transformation) { + protected Expression toTransformation(List inputs, List outputs, Transformation transformation) { if (transformation == null) { return new NullLiteralExpr(); } Expression lang = new StringLiteralExpr(transformation.getLanguage()); Expression expression = new StringLiteralExpr(transformation.getExpression()); - Expression source = new StringLiteralExpr(transformation.getSource()); + Expression compiledExpression = DataTransformerCompilerRegistry.instance().find(transformation.getLanguage()).compile(inputs, outputs, transformation); ClassOrInterfaceType clazz = new ClassOrInterfaceType(null, "org.jbpm.workflow.core.node.Transformation"); - return new ObjectCreationExpr(null, clazz, NodeList.nodeList(lang, expression, source)); + return new ObjectCreationExpr(null, clazz, NodeList.nodeList(lang, expression, compiledExpression)); } diff --git a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/process/builder/transformation/DataTransformerCompiler.java b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/process/builder/transformation/DataTransformerCompiler.java new file mode 100644 index 00000000000..0e85a0b0b0a --- /dev/null +++ b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/process/builder/transformation/DataTransformerCompiler.java @@ -0,0 +1,39 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.jbpm.process.builder.transformation; + +import java.util.List; + +import org.jbpm.workflow.core.impl.DataDefinition; +import org.jbpm.workflow.core.node.Transformation; + +import com.github.javaparser.ast.expr.Expression; + +public interface DataTransformerCompiler { + + default String[] dialects() { + return new String[0]; + } + + default boolean accept(String dialect) { + return List.of(dialects()).contains(dialect); + } + + Expression compile(List inputs, List outputs, Transformation source); +} diff --git a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/process/builder/transformation/DataTransformerCompilerRegistry.java b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/process/builder/transformation/DataTransformerCompilerRegistry.java new file mode 100755 index 00000000000..54f506da76e --- /dev/null +++ b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/process/builder/transformation/DataTransformerCompilerRegistry.java @@ -0,0 +1,72 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.jbpm.process.builder.transformation; + +import java.util.ArrayList; +import java.util.List; +import java.util.ServiceLoader; + +import org.jbpm.util.JbpmClassLoaderUtil; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Registry for all available on runtime DataTransformers for performing + * data input and output transformation. + * There is MVEL based transformer available out of the box that is registered under + * http://www.mvel.org/2.0 key. + *
+ * Custom implementations can be provided and if they are compliant with JSR 223 then follows above registration approach + * otherwise they need to be registered manually with register method. + * + */ +public class DataTransformerCompilerRegistry { + + private static final Logger logger = LoggerFactory.getLogger(DataTransformerCompilerRegistry.class); + + private static DataTransformerCompilerRegistry INSTANCE; + + private List registry; + + public static DataTransformerCompilerRegistry instance() { + if (INSTANCE == null) { + INSTANCE = new DataTransformerCompilerRegistry(); + } + return INSTANCE; + } + + protected DataTransformerCompilerRegistry() { + this.registry = new ArrayList<>(); + ServiceLoader.load(DataTransformerCompiler.class, JbpmClassLoaderUtil.findClassLoader()).forEach(registry::add); + } + + public void register(DataTransformerCompiler transformer) { + this.registry.add(transformer); + logger.debug("Manual registration of scripting language {} with instance {}", transformer.dialects(), transformer); + } + + public DataTransformerCompiler find(String language) { + for (DataTransformerCompiler transformer : registry) { + if (transformer.accept(language)) { + return transformer; + } + } + throw new IllegalArgumentException("transformer not support for dialect " + language); + } +} diff --git a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/process/builder/transformation/DefaultDataTransformerCompiler.java b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/process/builder/transformation/DefaultDataTransformerCompiler.java new file mode 100644 index 00000000000..377076b3466 --- /dev/null +++ b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/process/builder/transformation/DefaultDataTransformerCompiler.java @@ -0,0 +1,57 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.jbpm.process.builder.transformation; + +import java.util.Collections; +import java.util.List; + +import org.jbpm.process.core.impl.DataTransformerRegistry; +import org.jbpm.workflow.core.impl.DataDefinition; +import org.jbpm.workflow.core.node.Transformation; +import org.kie.kogito.internal.utils.ConversionUtils; + +import com.github.javaparser.ast.NodeList; +import com.github.javaparser.ast.expr.Expression; +import com.github.javaparser.ast.expr.FieldAccessExpr; +import com.github.javaparser.ast.expr.MethodCallExpr; +import com.github.javaparser.ast.expr.NameExpr; +import com.github.javaparser.ast.expr.StringLiteralExpr; + +public class DefaultDataTransformerCompiler implements DataTransformerCompiler { + + @Override + public String[] dialects() { + return new String[] { "http://www.mvel.org/2.0" }; + } + + @Override + public Expression compile(List inputs, List outputs, Transformation transformation) { + Expression expr = null; + expr = new FieldAccessExpr(new NameExpr(DataTransformerRegistry.class.getPackageName()), DataTransformerRegistry.class.getSimpleName()); + expr = new MethodCallExpr(expr, "get"); + expr = new MethodCallExpr(expr, "find", NodeList.nodeList(new StringLiteralExpr(transformation.getLanguage()))); + + Expression emptyCollection = new MethodCallExpr(new FieldAccessExpr(new NameExpr(Collections.class.getPackageName()), Collections.class.getSimpleName()), "emptyMap"); + + expr = new MethodCallExpr(expr, "compile", NodeList. nodeList( + new StringLiteralExpr(ConversionUtils.sanitizeString(transformation.getExpression())), emptyCollection)); + return expr; + } + +} diff --git a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/process/builder/transformation/JavaDataTransformerCompiler.java b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/process/builder/transformation/JavaDataTransformerCompiler.java new file mode 100644 index 00000000000..d2dc13c0521 --- /dev/null +++ b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/process/builder/transformation/JavaDataTransformerCompiler.java @@ -0,0 +1,65 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.jbpm.process.builder.transformation; + +import java.util.List; +import java.util.Map; + +import org.jbpm.workflow.core.impl.DataDefinition; +import org.jbpm.workflow.core.node.Transformation; + +import com.github.javaparser.StaticJavaParser; +import com.github.javaparser.ast.NodeList; +import com.github.javaparser.ast.body.Parameter; +import com.github.javaparser.ast.expr.AssignExpr; +import com.github.javaparser.ast.expr.CastExpr; +import com.github.javaparser.ast.expr.Expression; +import com.github.javaparser.ast.expr.LambdaExpr; +import com.github.javaparser.ast.expr.MethodCallExpr; +import com.github.javaparser.ast.expr.NameExpr; +import com.github.javaparser.ast.expr.StringLiteralExpr; +import com.github.javaparser.ast.expr.VariableDeclarationExpr; +import com.github.javaparser.ast.stmt.BlockStmt; +import com.github.javaparser.ast.type.ClassOrInterfaceType; + +public class JavaDataTransformerCompiler implements DataTransformerCompiler { + + @Override + public String[] dialects() { + return new String[] { "http://www.java.com/java" }; + } + + @Override + public Expression compile(List inputs, List outputs, Transformation transformation) { + // build lambda function + BlockStmt body = StaticJavaParser.parseBlock("{" + transformation.getExpression() + "}"); + for (DataDefinition input : inputs) { + ClassOrInterfaceType type = StaticJavaParser.parseClassOrInterfaceType(input.getType()); + VariableDeclarationExpr target = new VariableDeclarationExpr(type, input.getLabel()); + Expression source = new CastExpr(type, new MethodCallExpr(new NameExpr("parameters"), "get", NodeList.nodeList(new StringLiteralExpr(input.getLabel())))); + AssignExpr assignment = new AssignExpr(target, source, AssignExpr.Operator.ASSIGN); + body.addStatement(0, assignment); + } + + Expression lambda = new LambdaExpr(NodeList.nodeList(new Parameter(StaticJavaParser.parseClassOrInterfaceType(Map.class.getName()), "parameters")), body, true); + ClassOrInterfaceType type = StaticJavaParser.parseClassOrInterfaceType("java.util.function.Function"); + return new CastExpr(type, lambda); + } + +} diff --git a/jbpm/jbpm-flow-builder/src/main/resources/META-INF/services/org.jbpm.process.builder.transformation.DataTransformerCompiler b/jbpm/jbpm-flow-builder/src/main/resources/META-INF/services/org.jbpm.process.builder.transformation.DataTransformerCompiler new file mode 100644 index 00000000000..598412f6119 --- /dev/null +++ b/jbpm/jbpm-flow-builder/src/main/resources/META-INF/services/org.jbpm.process.builder.transformation.DataTransformerCompiler @@ -0,0 +1,2 @@ +org.jbpm.process.builder.transformation.DefaultDataTransformerCompiler +org.jbpm.process.builder.transformation.JavaDataTransformerCompiler \ No newline at end of file diff --git a/jbpm/jbpm-flow/src/main/java/org/jbpm/process/core/impl/DataTransformerRegistry.java b/jbpm/jbpm-flow/src/main/java/org/jbpm/process/core/impl/DataTransformerRegistry.java index 97f4349bbe9..5cd596786e4 100755 --- a/jbpm/jbpm-flow/src/main/java/org/jbpm/process/core/impl/DataTransformerRegistry.java +++ b/jbpm/jbpm-flow/src/main/java/org/jbpm/process/core/impl/DataTransformerRegistry.java @@ -21,6 +21,7 @@ import java.util.Map; import java.util.concurrent.ConcurrentHashMap; +import org.jbpm.process.core.transformation.JavaDataTransformer; import org.jbpm.process.core.transformation.MVELDataTransformer; import org.kie.api.runtime.process.DataTransformer; import org.slf4j.Logger; @@ -46,6 +47,7 @@ public class DataTransformerRegistry { protected DataTransformerRegistry() { this.registry = new ConcurrentHashMap<>(); this.registry.put("http://www.mvel.org/2.0", new MVELDataTransformer()); + this.registry.put("http://www.java.com/java", new JavaDataTransformer()); } public static DataTransformerRegistry get() { diff --git a/jbpm/jbpm-flow/src/main/java/org/jbpm/process/core/transformation/JavaDataTransformer.java b/jbpm/jbpm-flow/src/main/java/org/jbpm/process/core/transformation/JavaDataTransformer.java new file mode 100644 index 00000000000..daefaf43cc9 --- /dev/null +++ b/jbpm/jbpm-flow/src/main/java/org/jbpm/process/core/transformation/JavaDataTransformer.java @@ -0,0 +1,39 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.jbpm.process.core.transformation; + +import java.util.Map; +import java.util.function.Function; + +import org.kie.api.runtime.process.DataTransformer; + +public class JavaDataTransformer implements DataTransformer { + + @Override + public Object compile(String expression, Map parameters) { + return null; + } + + @SuppressWarnings("unchecked") + @Override + public Object transform(Object expression, Map parameters) { + return ((Function, Object>) expression).apply(parameters); + } + +} diff --git a/jbpm/jbpm-flow/src/main/java/org/jbpm/workflow/core/impl/DataDefinition.java b/jbpm/jbpm-flow/src/main/java/org/jbpm/workflow/core/impl/DataDefinition.java index e36b7a940da..0b96a2a73c2 100644 --- a/jbpm/jbpm-flow/src/main/java/org/jbpm/workflow/core/impl/DataDefinition.java +++ b/jbpm/jbpm-flow/src/main/java/org/jbpm/workflow/core/impl/DataDefinition.java @@ -21,6 +21,8 @@ import java.io.Serializable; import java.util.UUID; +import org.jbpm.process.core.context.variable.Variable; + public class DataDefinition implements Serializable { private static final long serialVersionUID = -1819075545956349183L; @@ -30,6 +32,8 @@ public class DataDefinition implements Serializable { private String type; private String expression; + private Variable variable; + public DataDefinition(String expression) { this.id = UUID.randomUUID().toString(); this.label = "EXPRESSION - (" + expression + ")"; @@ -48,6 +52,12 @@ public DataDefinition(String id, String label, String type) { this(id, label, type, null); } + public DataDefinition(String id, String label, Variable variable) { + this.id = id; + this.label = label != null && !label.isEmpty() ? label : id; + this.variable = variable; + } + public String getId() { return id; } @@ -65,6 +75,9 @@ public void setExpression(String expression) { } public String getType() { + if (variable != null) { + return variable.getType().getStringType(); + } return type; } @@ -128,7 +141,7 @@ public boolean equals(Object obj) { if (type == null) { if (other.type != null) return false; - } else if (!type.equals(other.type)) + } else if (!getType().equals(other.getType())) return false; return true; } diff --git a/jbpm/jbpm-flow/src/main/java/org/jbpm/workflow/core/node/Transformation.java b/jbpm/jbpm-flow/src/main/java/org/jbpm/workflow/core/node/Transformation.java index d49b3a30f84..97533ec90a0 100755 --- a/jbpm/jbpm-flow/src/main/java/org/jbpm/workflow/core/node/Transformation.java +++ b/jbpm/jbpm-flow/src/main/java/org/jbpm/workflow/core/node/Transformation.java @@ -24,20 +24,18 @@ public class Transformation implements Serializable { private static final long serialVersionUID = 1641905060375832661L; - private String source; private String language; private String expression; private Object compiledExpression; public Transformation(String lang, String expression) { - this.language = lang; - this.expression = expression; + this(lang, expression, null); } - public Transformation(String lang, String expression, String source) { + public Transformation(String lang, String expression, Object compiledExpression) { this.language = lang; this.expression = expression; - this.source = source; + this.compiledExpression = compiledExpression; } public String getLanguage() { @@ -64,12 +62,4 @@ public void setCompiledExpression(Object compliedExpression) { this.compiledExpression = compliedExpression; } - public String getSource() { - return source; - } - - public void setSource(String source) { - this.source = source; - } - } diff --git a/jbpm/jbpm-tests/src/test/bpmn/org/jbpm/bpmn2/activity/BPMN2-BoundarySignalEventOnTaskWithTransformation.bpmn b/jbpm/jbpm-tests/src/test/bpmn/org/jbpm/bpmn2/activity/BPMN2-BoundarySignalEventOnTaskWithTransformation.bpmn new file mode 100755 index 00000000000..abf5d076e7a --- /dev/null +++ b/jbpm/jbpm-tests/src/test/bpmn/org/jbpm/bpmn2/activity/BPMN2-BoundarySignalEventOnTaskWithTransformation.bpmn @@ -0,0 +1,175 @@ + + + + + + + SequenceFlow_1 + + + SequenceFlow_5 + SequenceFlow_4 + + + + SequenceFlow_4 + + + + SequenceFlow_1 + SequenceFlow_2 + + + + + + + + + _DataInput_2 + _DataInput_3 + _DataInput_4 + _DataInput_5 + _DataInput_6 + _DataInput_7 + + + + + _DataInput_2 + + + _DataInput_3 + + + _DataInput_4 + + + _DataInput_5 + + + _DataInput_6 + + + _DataInput_7 + + + + john + + + + + SequenceFlow_5 + + + _4_Output + x + return param.toUpperCase(); + + + _4_Output + + + + + + + + + SequenceFlow_3 + + + + SequenceFlow_2 + SequenceFlow_3 + + + + + + + + + _DataInput_8 + _DataInput_9 + _DataInput_10 + _DataInput_11 + _DataInput_12 + _DataInput_13 + + + + + _DataInput_8 + + + _DataInput_9 + + + _DataInput_10 + + + _DataInput_11 + + + _DataInput_12 + + + _DataInput_13 + + + + john + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/jbpm/jbpm-tests/src/test/java/org/jbpm/bpmn2/IntermediateEventTest.java b/jbpm/jbpm-tests/src/test/java/org/jbpm/bpmn2/IntermediateEventTest.java index 4d4a7242530..f5d2dd08227 100755 --- a/jbpm/jbpm-tests/src/test/java/org/jbpm/bpmn2/IntermediateEventTest.java +++ b/jbpm/jbpm-tests/src/test/java/org/jbpm/bpmn2/IntermediateEventTest.java @@ -28,8 +28,12 @@ import java.util.Set; import java.util.concurrent.atomic.AtomicBoolean; +import org.jbpm.bpmn2.activity.BoundarySignalEventOnTaskWithTransformationModel; +import org.jbpm.bpmn2.activity.BoundarySignalEventOnTaskWithTransformationProcess; import org.jbpm.bpmn2.handler.ReceiveTaskHandler; import org.jbpm.bpmn2.handler.SendTaskHandler; +import org.jbpm.bpmn2.intermediate.IntermediateThrowEventSignalModel; +import org.jbpm.bpmn2.intermediate.IntermediateThrowEventSignalProcess; import org.jbpm.bpmn2.objects.Person; import org.jbpm.bpmn2.objects.TestWorkItemHandler; import org.jbpm.bpmn2.test.RequirePersistence; @@ -39,6 +43,7 @@ import org.jbpm.process.instance.impl.demo.SystemOutWorkItemHandler; import org.jbpm.test.util.NodeLeftCountDownProcessEventListener; import org.jbpm.test.util.ProcessCompletedCountDownProcessEventListener; +import org.jbpm.test.utils.ProcessTestHelper; import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import org.kie.api.command.ExecutableCommand; @@ -47,6 +52,7 @@ import org.kie.api.event.process.ProcessNodeTriggeredEvent; import org.kie.api.event.process.ProcessStartedEvent; import org.kie.api.runtime.rule.FactHandle; +import org.kie.kogito.Application; import org.kie.kogito.internal.process.event.DefaultKogitoProcessEventListener; import org.kie.kogito.internal.process.event.KogitoProcessEventListener; import org.kie.kogito.internal.process.runtime.KogitoNodeInstance; @@ -58,6 +64,7 @@ import org.kie.kogito.internal.process.runtime.KogitoWorkflowProcessInstance; import org.kie.kogito.process.EventDescription; import org.kie.kogito.process.NamedDataType; +import org.kie.kogito.process.ProcessInstance; import org.kie.kogito.process.workitems.InternalKogitoWorkItem; import static org.assertj.core.api.Assertions.assertThat; @@ -1794,27 +1801,20 @@ public void testSignalIntermediateThrowEventWithTransformation() throws Exceptio } @Test - @Disabled("Transfomer has been disabled") public void testSignalBoundaryEventWithTransformation() throws Exception { - kruntime = createKogitoProcessRuntime( - "BPMN2-BoundarySignalEventOnTaskWithTransformation.bpmn", - "BPMN2-IntermediateThrowEventSignal.bpmn2"); - - TestWorkItemHandler handler = new TestWorkItemHandler(); - kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Human Task", - handler); - - Map params = new HashMap<>(); - params.put("x", "john"); - KogitoProcessInstance processInstance = kruntime.startProcess("BoundarySignalOnTask"); - - KogitoProcessInstance processInstance2 = kruntime.startProcess("SignalIntermediateEvent", params); - assertProcessInstanceFinished(processInstance2, kruntime); - - assertProcessInstanceFinished(processInstance, kruntime); - - String var = getProcessVarValue(processInstance, "x"); - assertThat(var).isEqualTo("JOHN"); + Application application = ProcessTestHelper.newApplication(); + org.kie.kogito.process.Process processBoundary = BoundarySignalEventOnTaskWithTransformationProcess.newProcess(application); + org.kie.kogito.process.Process processIntermediate = IntermediateThrowEventSignalProcess.newProcess(application); + + ProcessInstance instanceBoundary = processBoundary.createInstance(processBoundary.createModel()); + instanceBoundary.start(); + IntermediateThrowEventSignalModel modelIntermediate = processIntermediate.createModel(); + modelIntermediate.setX("john"); + ProcessInstance instanceIntermediate = processIntermediate.createInstance(modelIntermediate); + instanceIntermediate.start(); + assertThat(instanceIntermediate).extracting(ProcessInstance::status).isEqualTo(ProcessInstance.STATE_COMPLETED); + assertThat(instanceBoundary).extracting(ProcessInstance::status).isEqualTo(ProcessInstance.STATE_COMPLETED); + assertThat(instanceBoundary.variables().getX()).isEqualTo("JOHN"); } @Test diff --git a/jbpm/jbpm-tools/jbpm-tools-maven-plugin/pom.xml b/jbpm/jbpm-tools/jbpm-tools-maven-plugin/pom.xml index 3a159e40323..39420a95e30 100644 --- a/jbpm/jbpm-tools/jbpm-tools-maven-plugin/pom.xml +++ b/jbpm/jbpm-tools/jbpm-tools-maven-plugin/pom.xml @@ -96,6 +96,11 @@ google-collections test + + org.slf4j + slf4j-simple + test + diff --git a/jbpm/jbpm-tests/src/test/resources/BPMN2-BoundarySignalEventOnTaskWithTransformation.bpmn b/jbpm/jbpm-tools/jbpm-tools-maven-plugin/src/test/resources/unit/project/src/main/bpmn/BPMN2-BoundarySignalEventOnTaskWithTransformation.bpmn similarity index 99% rename from jbpm/jbpm-tests/src/test/resources/BPMN2-BoundarySignalEventOnTaskWithTransformation.bpmn rename to jbpm/jbpm-tools/jbpm-tools-maven-plugin/src/test/resources/unit/project/src/main/bpmn/BPMN2-BoundarySignalEventOnTaskWithTransformation.bpmn index 8c88dc39add..d6eb0a8cb47 100755 --- a/jbpm/jbpm-tests/src/test/resources/BPMN2-BoundarySignalEventOnTaskWithTransformation.bpmn +++ b/jbpm/jbpm-tools/jbpm-tools-maven-plugin/src/test/resources/unit/project/src/main/bpmn/BPMN2-BoundarySignalEventOnTaskWithTransformation.bpmn @@ -80,7 +80,7 @@ SequenceFlow_5 - + _4_Output x From 434b5af1e4f99570281ace48a3d297e511fabcd6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tibor=20Zim=C3=A1nyi?= Date: Wed, 29 May 2024 08:36:03 +0200 Subject: [PATCH 24/32] [disabling_tracing-decision_module] Removing tracing-decision module from maven reactor (#3533) --- kogito-bom/pom.xml | 22 ---------------------- quarkus/addons/pom.xml | 1 - 2 files changed, 23 deletions(-) diff --git a/kogito-bom/pom.xml b/kogito-bom/pom.xml index ff530de56e8..6e6671e62e3 100755 --- a/kogito-bom/pom.xml +++ b/kogito-bom/pom.xml @@ -2588,28 +2588,6 @@ ${project.version} sources - - org.kie - kie-addons-quarkus-tracing-decision - ${project.version} - - - org.kie - kie-addons-quarkus-tracing-decision - ${project.version} - sources - - - org.kie - kie-addons-quarkus-tracing-decision-deployment - ${project.version} - - - org.kie - kie-addons-quarkus-tracing-decision-deployment - ${project.version} - sources - org.kie kie-addons-springboot-tracing-decision diff --git a/quarkus/addons/pom.xml b/quarkus/addons/pom.xml index d579b4aa5eb..eb068baddb0 100644 --- a/quarkus/addons/pom.xml +++ b/quarkus/addons/pom.xml @@ -55,7 +55,6 @@ monitoring process-svg task-notification - tracing-decision task-management marshallers process-definitions From 0ac1b733dd47b2dcb1ea5c83ede1209e5db9732f Mon Sep 17 00:00:00 2001 From: Enrique Date: Wed, 29 May 2024 09:45:52 +0200 Subject: [PATCH 25/32] [incubator-kie-issues-1273] Add validate formatting to kogito runtimes and kogito-apps (#3534) --- .github/workflows/pr-kogito-runtimes.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pr-kogito-runtimes.yml b/.github/workflows/pr-kogito-runtimes.yml index 8513220b2c1..7ef84970c95 100644 --- a/.github/workflows/pr-kogito-runtimes.yml +++ b/.github/workflows/pr-kogito-runtimes.yml @@ -65,7 +65,7 @@ jobs: github-token: "${{ secrets.GITHUB_TOKEN }}" definition-file: https://raw.githubusercontent.com/${GROUP:apache}/incubator-kie-kogito-pipelines/${BRANCH:main}/.ci/pull-request-config.yaml env: - BUILD_MVN_OPTS_CURRENT: '-T 1.5C' + BUILD_MVN_OPTS_CURRENT: '-T 1.5C -Dvalidate-formatting' - name: Junit Report uses: apache/incubator-kie-kogito-pipelines/.ci/actions/action-junit-report@main if: ${{ always() }} From a913910966183a5fdacd825211a027655a66828e Mon Sep 17 00:00:00 2001 From: Enrique Date: Wed, 29 May 2024 10:52:24 +0200 Subject: [PATCH 26/32] [incubator-kie-issues-1195] Process Variable support multiple metadata fields (#3508) --- .../compiler/canonical/AbstractVisitor.java | 27 ++++++++++++++----- .../ProcessToExecModelGeneratorTest.java | 6 +++-- .../core/RuleFlowNodeContainerFactory.java | 8 +++--- .../ruleflow/core/RuleFlowProcessFactory.java | 18 +++++++------ .../factory/AbstractCompositeNodeFactory.java | 17 +++++++----- .../java/org/jbpm/bpmn2/VariableTagsTest.java | 20 ++++++++++++++ .../parser/handlers/StateHandler.java | 2 +- .../ServerlessWorkflowCodestartTest.java | 4 +++ 8 files changed, 75 insertions(+), 27 deletions(-) diff --git a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/AbstractVisitor.java b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/AbstractVisitor.java index 17dd3cd9d36..65932b1d760 100644 --- a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/AbstractVisitor.java +++ b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/AbstractVisitor.java @@ -32,11 +32,11 @@ import org.kie.api.definition.process.NodeContainer; import org.kie.api.definition.process.WorkflowElementIdentifier; import org.kie.kogito.internal.process.runtime.KogitoNode; -import org.kie.kogito.internal.utils.KogitoTags; import com.github.javaparser.ast.NodeList; import com.github.javaparser.ast.expr.ClassExpr; import com.github.javaparser.ast.expr.Expression; +import com.github.javaparser.ast.expr.FieldAccessExpr; import com.github.javaparser.ast.expr.MethodCallExpr; import com.github.javaparser.ast.expr.NameExpr; import com.github.javaparser.ast.expr.NullLiteralExpr; @@ -102,13 +102,28 @@ protected void visitVariableScope(String field, VariableScope variableScope, Blo if (!visitedVariables.add(variable.getName())) { continue; } - String tags = (String) variable.getMetaData(KogitoTags.VARIABLE_TAGS); + + Map metaData = variable.getMetaData(); + NodeList parameters = new NodeList<>(); + for (Map.Entry entry : metaData.entrySet().stream().filter(e -> e.getValue() != null).toList()) { + parameters.add(new StringLiteralExpr(entry.getKey())); + parameters.add(new StringLiteralExpr(entry.getValue().toString())); + } + + Expression metadataExpression = new FieldAccessExpr(new NameExpr(Map.class.getPackage().getName()), Map.class.getSimpleName()); + metadataExpression = new MethodCallExpr(metadataExpression, "of", parameters); Object defaultValue = variable.getValue(); body.tryAddImportToParentCompilationUnit(variable.getType().getClass()); - body.addStatement(getFactoryMethod(field, METHOD_VARIABLE, new StringLiteralExpr(variable.getName()), - new MethodCallExpr(DataTypeResolver.class.getName() + ".fromClass", new ClassExpr(parseClassOrInterfaceType(variable.getType().getStringType()).removeTypeArguments())), - defaultValue != null ? new StringLiteralExpr(defaultValue.toString()) : new NullLiteralExpr(), new StringLiteralExpr(KogitoTags.VARIABLE_TAGS), - tags != null ? new StringLiteralExpr(tags) : new NullLiteralExpr())); + + NodeList variableFactoryParameters = new NodeList<>(); + variableFactoryParameters.add(new StringLiteralExpr(variable.getName())); + variableFactoryParameters + .add(new MethodCallExpr(DataTypeResolver.class.getName() + ".fromClass", new ClassExpr(parseClassOrInterfaceType(variable.getType().getStringType()).removeTypeArguments()))); + if (defaultValue != null) { + variableFactoryParameters.add(new StringLiteralExpr(defaultValue.toString())); + } + variableFactoryParameters.add(metadataExpression); + body.addStatement(getFactoryMethod(field, METHOD_VARIABLE, variableFactoryParameters.stream().toArray(Expression[]::new))); } } } diff --git a/jbpm/jbpm-flow-builder/src/test/java/org/jbpm/compiler/canonical/ProcessToExecModelGeneratorTest.java b/jbpm/jbpm-flow-builder/src/test/java/org/jbpm/compiler/canonical/ProcessToExecModelGeneratorTest.java index e454d26ee09..eec5facfafa 100644 --- a/jbpm/jbpm-flow-builder/src/test/java/org/jbpm/compiler/canonical/ProcessToExecModelGeneratorTest.java +++ b/jbpm/jbpm-flow-builder/src/test/java/org/jbpm/compiler/canonical/ProcessToExecModelGeneratorTest.java @@ -18,6 +18,8 @@ */ package org.jbpm.compiler.canonical; +import java.util.Collections; + import org.jbpm.process.core.datatype.impl.type.IntegerDataType; import org.jbpm.process.core.datatype.impl.type.ObjectDataType; import org.jbpm.process.core.datatype.impl.type.StringDataType; @@ -130,8 +132,8 @@ public void testScriptVariablewithDefaultValue() { RuleFlowProcessFactory factory = RuleFlowProcessFactory.createProcess("demo.orders"); factory .variable("order", new ObjectDataType("com.myspace.demo.Order")) - .variable("approver", new StringDataType(), "john", "customTags", null) - .variable("age", new IntegerDataType(), "1", "customTags", null) + .variable("approver", new StringDataType(), "john", Collections.singletonMap("customTags", null)) + .variable("age", new IntegerDataType(), "1", Collections.singletonMap("customTags", null)) .name("orders") .packageName("com.myspace.demo") .dynamic(false) diff --git a/jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/RuleFlowNodeContainerFactory.java b/jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/RuleFlowNodeContainerFactory.java index 8dbdc4769c2..b994fc5042e 100755 --- a/jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/RuleFlowNodeContainerFactory.java +++ b/jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/RuleFlowNodeContainerFactory.java @@ -18,6 +18,8 @@ */ package org.jbpm.ruleflow.core; +import java.util.Map; + import org.jbpm.process.core.Context; import org.jbpm.process.core.ContextContainer; import org.jbpm.process.core.context.exception.ActionExceptionHandler; @@ -237,11 +239,11 @@ public T errorExceptionHandler(String signalType, String faultCode, String fault public abstract T variable(String name, DataType type); - public abstract T variable(String name, DataType type, Object value); + public abstract T variable(String name, DataType type, Map metadata); - public abstract T variable(String name, DataType type, String metaDataName, Object metaDataValue); + public abstract T variable(String name, DataType type, Object value); - public abstract T variable(String name, DataType type, Object value, String metaDataName, Object metaDataValue); + public abstract T variable(String name, DataType type, Object value, Map metadata); private S getScope(String scopeType, Class scopeClass) { ContextContainer contextContainer = (ContextContainer) getNodeContainer(); diff --git a/jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/RuleFlowProcessFactory.java b/jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/RuleFlowProcessFactory.java index ccfdb3d9933..3c6089e19ae 100755 --- a/jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/RuleFlowProcessFactory.java +++ b/jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/RuleFlowProcessFactory.java @@ -20,6 +20,7 @@ import java.util.ArrayList; import java.util.Arrays; +import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -201,29 +202,30 @@ public RuleFlowProcessFactory variable(String name, Class clazz) { @Override public RuleFlowProcessFactory variable(String name, DataType type) { - return variable(name, type, null); + return variable(name, type, Collections.emptyMap()); } @Override public RuleFlowProcessFactory variable(String name, DataType type, Object value) { - return variable(name, type, value, null, null); + return variable(name, type, value, Collections.emptyMap()); } @Override - public RuleFlowProcessFactory variable(String name, DataType type, String metaDataName, Object metaDataValue) { - return variable(name, type, null, metaDataName, metaDataValue); + public RuleFlowProcessFactory variable(String name, DataType type, Map metadata) { + return this.variable(name, type, null, metadata); } @Override - public RuleFlowProcessFactory variable(String name, DataType type, Object value, String metaDataName, Object metaDataValue) { - + public RuleFlowProcessFactory variable(String name, DataType type, Object value, Map metadata) { Variable variable = new Variable(); variable.setName(name); variable.setType(type); variable.setValue(type.verifyDataType(value) ? value : type.readValue((String) value)); - if (metaDataName != null && metaDataValue != null) { - variable.setMetaData(metaDataName, metaDataValue); + + for (Map.Entry entry : metadata.entrySet()) { + variable.setMetaData(entry.getKey(), entry.getValue()); } + getRuleFlowProcess().getVariableScope().getVariables().add(variable); return this; } diff --git a/jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/factory/AbstractCompositeNodeFactory.java b/jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/factory/AbstractCompositeNodeFactory.java index aacc99b20b8..144de670ac7 100644 --- a/jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/factory/AbstractCompositeNodeFactory.java +++ b/jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/factory/AbstractCompositeNodeFactory.java @@ -18,6 +18,9 @@ */ package org.jbpm.ruleflow.core.factory; +import java.util.Collections; +import java.util.Map; + import org.jbpm.process.core.context.variable.Variable; import org.jbpm.process.core.context.variable.VariableScope; import org.jbpm.process.core.datatype.DataType; @@ -53,28 +56,28 @@ public T timeout(String timeout) { @Override public T variable(String name, DataType type) { - return variable(name, type, null); + return variable(name, type, Collections.emptyMap()); } @Override public T variable(String name, DataType type, Object value) { - return variable(name, type, value, null, null); + return variable(name, type, value, Collections.emptyMap()); } @Override - public T variable(String name, DataType type, String metaDataName, Object metaDataValue) { - return variable(name, type, null, metaDataName, metaDataValue); + public T variable(String name, DataType type, Map metaData) { + return variable(name, type, null, metaData); } @Override - public T variable(String name, DataType type, Object value, String metaDataName, Object metaDataValue) { + public T variable(String name, DataType type, Object value, Map metadata) { Variable variable = new Variable(); variable.setName(name); variable.setType(type); variable.setValue(value); VariableScope variableScope = (VariableScope) getCompositeNode().getDefaultContext(VariableScope.VARIABLE_SCOPE); - if (metaDataName != null && metaDataValue != null) { - variable.setMetaData(metaDataName, metaDataValue); + for (Map.Entry entry : metadata.entrySet()) { + variable.setMetaData(entry.getKey(), entry.getValue()); } if (variableScope == null) { variableScope = new VariableScope(); diff --git a/jbpm/jbpm-tests/src/test/java/org/jbpm/bpmn2/VariableTagsTest.java b/jbpm/jbpm-tests/src/test/java/org/jbpm/bpmn2/VariableTagsTest.java index 20542c6671f..90d63909c93 100644 --- a/jbpm/jbpm-tests/src/test/java/org/jbpm/bpmn2/VariableTagsTest.java +++ b/jbpm/jbpm-tests/src/test/java/org/jbpm/bpmn2/VariableTagsTest.java @@ -22,11 +22,17 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.Optional; import org.drools.io.ClassPathResource; import org.jbpm.bpmn2.objects.TestWorkItemHandler; +import org.jbpm.bpmn2.tags.ApprovalWithRequiredVariableTagsProcess; +import org.jbpm.process.core.context.variable.Variable; +import org.jbpm.ruleflow.core.RuleFlowProcess; +import org.jbpm.test.utils.ProcessTestHelper; import org.junit.jupiter.api.Test; import org.kie.api.event.process.ProcessVariableChangedEvent; +import org.kie.kogito.Application; import org.kie.kogito.internal.process.event.DefaultKogitoProcessEventListener; import org.kie.kogito.internal.process.runtime.KogitoProcessInstance; import org.kie.kogito.internal.process.runtime.KogitoWorkItem; @@ -36,11 +42,25 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; +import static org.assertj.core.api.Assertions.entry; import static org.kie.kogito.internal.process.runtime.KogitoProcessInstance.STATE_ABORTED; import static org.kie.kogito.internal.process.runtime.KogitoProcessInstance.STATE_ACTIVE; public class VariableTagsTest extends JbpmBpmn2TestCase { + @Test + public void testVariableMultipleMetadata() throws Exception { + Application app = ProcessTestHelper.newApplication(); + ApprovalWithRequiredVariableTagsProcess processDefinition = (ApprovalWithRequiredVariableTagsProcess) ApprovalWithRequiredVariableTagsProcess.newProcess(app); + + RuleFlowProcess processEngine = (RuleFlowProcess) processDefinition.process(); + Optional var = processEngine.getVariableScope().getVariables().stream().filter(e -> "approver".equals(e.getName())).findAny(); + assertThat(var).isPresent(); + assertThat(var.get().getMetaData()).hasSize(3); + assertThat(var.get().getMetaData()).containsExactly(entry("approver", "approver"), entry("customTags", "required"), entry("ItemSubjectRef", "ItemDefinition_9")); + + } + @Test public void testProcessWithMissingRequiredVariable() throws Exception { kruntime = createKogitoProcessRuntime("org/jbpm/bpmn2/tags/BPMN2-ApprovalWithRequiredVariableTags.bpmn2"); diff --git a/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/parser/handlers/StateHandler.java b/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/parser/handlers/StateHandler.java index 3cec858b915..63610ad6b71 100644 --- a/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/parser/handlers/StateHandler.java +++ b/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/parser/handlers/StateHandler.java @@ -436,7 +436,7 @@ protected final MakeNodeResult filterAndMergeNode(RuleFlowNodeContainerFactory startNode, currentNode; if (fromStateExpr != null) { diff --git a/quarkus/extensions/kogito-quarkus-serverless-workflow-extension/kogito-quarkus-serverless-workflow-integration-test/src/test/java/org/kie/kogito/quarkus/ServerlessWorkflowCodestartTest.java b/quarkus/extensions/kogito-quarkus-serverless-workflow-extension/kogito-quarkus-serverless-workflow-integration-test/src/test/java/org/kie/kogito/quarkus/ServerlessWorkflowCodestartTest.java index ffce8e0e5c3..9c1dbf98c50 100644 --- a/quarkus/extensions/kogito-quarkus-serverless-workflow-extension/kogito-quarkus-serverless-workflow-integration-test/src/test/java/org/kie/kogito/quarkus/ServerlessWorkflowCodestartTest.java +++ b/quarkus/extensions/kogito-quarkus-serverless-workflow-extension/kogito-quarkus-serverless-workflow-integration-test/src/test/java/org/kie/kogito/quarkus/ServerlessWorkflowCodestartTest.java @@ -20,19 +20,23 @@ import java.util.Map; +import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import io.quarkus.devtools.codestarts.quarkus.QuarkusCodestartData; +import io.quarkus.devtools.project.BuildTool; import io.quarkus.devtools.testing.codestarts.QuarkusCodestartTest; import io.quarkus.maven.dependency.ArtifactKey; import static io.quarkus.devtools.codestarts.quarkus.QuarkusCodestartCatalog.Language.JAVA; +@Disabled public class ServerlessWorkflowCodestartTest { @RegisterExtension public static QuarkusCodestartTest codestartTest = QuarkusCodestartTest.builder() + .buildTool(BuildTool.MAVEN) .setupStandaloneExtensionTest("org.apache.kie.sonataflow:sonataflow-quarkus") .extension(ArtifactKey.fromString("io.quarkus:quarkus-config-yaml")) .putData(QuarkusCodestartData.QuarkusDataKey.APP_CONFIG, Map.of("quarkus.devservices.enabled", "false")) From bfb00fd5e0075e82f1a42c31849478550b22b739 Mon Sep 17 00:00:00 2001 From: Abhiram Gundala <164050036+Abhitocode@users.noreply.github.com> Date: Wed, 29 May 2024 09:57:31 -0400 Subject: [PATCH 27/32] [incubator-kie-issues-1131] Process test migration from v7 legacy runtime to code generation (#3519) --- .../java/org/jbpm/bpmn2/ActivityTest.java | 137 +++++++++++------- 1 file changed, 85 insertions(+), 52 deletions(-) diff --git a/jbpm/jbpm-tests/src/test/java/org/jbpm/bpmn2/ActivityTest.java b/jbpm/jbpm-tests/src/test/java/org/jbpm/bpmn2/ActivityTest.java index c396cf8abbd..4beb906a828 100755 --- a/jbpm/jbpm-tests/src/test/java/org/jbpm/bpmn2/ActivityTest.java +++ b/jbpm/jbpm-tests/src/test/java/org/jbpm/bpmn2/ActivityTest.java @@ -26,6 +26,8 @@ import java.util.List; import java.util.Map; import java.util.Objects; +import java.util.Set; +import java.util.stream.Collectors; import org.drools.compiler.rule.builder.PackageBuildContext; import org.jbpm.bpmn2.activity.ScriptTaskModel; @@ -56,8 +58,21 @@ import org.jbpm.bpmn2.objects.HelloService; import org.jbpm.bpmn2.objects.Person; import org.jbpm.bpmn2.objects.TestWorkItemHandler; +import org.jbpm.bpmn2.subprocess.CallActivityModel; +import org.jbpm.bpmn2.subprocess.CallActivityProcess; +import org.jbpm.bpmn2.subprocess.CallActivitySubProcessProcess; +import org.jbpm.bpmn2.subprocess.InputMappingUsingValueModel; +import org.jbpm.bpmn2.subprocess.InputMappingUsingValueProcess; +import org.jbpm.bpmn2.subprocess.SingleTaskWithVarDefModel; +import org.jbpm.bpmn2.subprocess.SingleTaskWithVarDefProcess; import org.jbpm.bpmn2.subprocess.SubProcessWithEntryExitScriptsModel; import org.jbpm.bpmn2.subprocess.SubProcessWithEntryExitScriptsProcess; +import org.jbpm.bpmn2.subprocess.SubProcessWithTerminateEndEventModel; +import org.jbpm.bpmn2.subprocess.SubProcessWithTerminateEndEventProcess; +import org.jbpm.bpmn2.subprocess.SubProcessWithTerminateEndEventProcessScopeModel; +import org.jbpm.bpmn2.subprocess.SubProcessWithTerminateEndEventProcessScopeProcess; +import org.jbpm.bpmn2.task.ReceiveTaskModel; +import org.jbpm.bpmn2.task.ReceiveTaskProcess; import org.jbpm.bpmn2.task.SendTaskModel; import org.jbpm.bpmn2.task.SendTaskProcess; import org.jbpm.bpmn2.test.RequirePersistence; @@ -85,6 +100,8 @@ import org.jbpm.workflow.instance.WorkflowRuntimeException; import org.jbpm.workflow.instance.impl.WorkflowProcessInstanceImpl; import org.jbpm.workflow.instance.node.DynamicUtils; +import org.jbpm.workflow.instance.node.EndNodeInstance; +import org.jbpm.workflow.instance.node.StartNodeInstance; import org.jbpm.workflow.instance.node.WorkItemNodeInstance; import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; @@ -94,6 +111,7 @@ import org.kie.api.definition.process.NodeContainer; import org.kie.api.definition.process.Process; import org.kie.api.definition.process.WorkflowElementIdentifier; +import org.kie.api.event.process.ProcessNodeEvent; import org.kie.api.event.process.ProcessNodeTriggeredEvent; import org.kie.api.event.process.ProcessStartedEvent; import org.kie.api.event.process.ProcessVariableChangedEvent; @@ -453,25 +471,26 @@ public void testUserTaskVerifyParameters() throws Exception { } @Test - public void testCallActivityWithContantsAssignment() throws Exception { - kruntime = createKogitoProcessRuntime( - "org/jbpm/bpmn2/subprocess/BPMN2-SingleTaskWithVarDef.bpmn2", - "org/jbpm/bpmn2/subprocess/BPMN2-InputMappingUsingValue.bpmn2"); - - TestWorkItemHandler handler = new TestWorkItemHandler(); - kruntime.getKogitoWorkItemManager().registerWorkItemHandler("CustomTask", handler); - Map params = new HashMap<>(); - KogitoProcessInstance processInstance = kruntime.startProcess("InputMappingUsingValue", params); + public void testCallActivityWithContantsAssignment() { + Application app = ProcessTestHelper.newApplication(); + TestWorkItemHandler workItemHandler = new TestWorkItemHandler(); + ProcessTestHelper.registerHandler(app, "CustomTask", workItemHandler); + org.kie.kogito.process.Process singleTaskWithVarDefModelProcess = SingleTaskWithVarDefProcess.newProcess(app); + SingleTaskWithVarDefModel singleTaskWithVarDefModel = singleTaskWithVarDefModelProcess.createModel(); + ProcessInstance singleTaskWithVarDefModelProcessInstance = singleTaskWithVarDefModelProcess.createInstance(singleTaskWithVarDefModel); + org.kie.kogito.process.Process processDefinition = InputMappingUsingValueProcess.newProcess(app); + InputMappingUsingValueModel model = processDefinition.createModel(); + org.kie.kogito.process.ProcessInstance instance = processDefinition.createInstance(model); + instance.start(); - org.kie.kogito.internal.process.runtime.KogitoWorkItem workItem = handler.getWorkItem(); + assertThat(instance).extracting(ProcessInstance::status).isEqualTo(ProcessInstance.STATE_ACTIVE); + KogitoWorkItem workItem = workItemHandler.getWorkItem(); assertThat(workItem).isNotNull(); - Object value = workItem.getParameter("TaskName"); assertThat(value).isNotNull().isEqualTo("test string"); - kruntime.getKogitoWorkItemManager().completeWorkItem(workItem.getStringId(), null); - - assertProcessInstanceCompleted(processInstance); + singleTaskWithVarDefModelProcessInstance.completeWorkItem(workItem.getStringId(), Collections.emptyMap()); + assertThat(instance).extracting(ProcessInstance::status).isEqualTo(org.kie.kogito.process.ProcessInstance.STATE_COMPLETED); } @Test @@ -499,16 +518,18 @@ public void testSubProcessWithEntryExitScripts() throws Exception { } @Test - public void testCallActivity() throws Exception { - kruntime = createKogitoProcessRuntime("org/jbpm/bpmn2/subprocess/BPMN2-CallActivity.bpmn2", - "org/jbpm/bpmn2/subprocess/BPMN2-CallActivitySubProcess.bpmn2"); + public void testCallActivity() { + Application app = ProcessTestHelper.newApplication(); + org.kie.kogito.process.Process processDefinition = CallActivityProcess.newProcess(app); + CallActivityModel model = processDefinition.createModel(); + model.setX("oldValue"); + ProcessInstance instance = processDefinition.createInstance(model); - Map params = new HashMap<>(); - params.put("x", "oldValue"); - KogitoProcessInstance processInstance = kruntime.startProcess( - "CallActivity", params); - assertProcessInstanceCompleted(processInstance); - assertThat(((KogitoWorkflowProcessInstance) processInstance).getVariable("y")).isEqualTo("new value"); + CallActivitySubProcessProcess.newProcess(app); + + instance.start(); + assertThat(instance).extracting(ProcessInstance::status).isEqualTo(ProcessInstance.STATE_COMPLETED); + assertThat(instance.variables().getY()).isEqualTo("new value"); } @Test @@ -650,36 +671,46 @@ public void testMultiinstanceSubProcessWrongStartEvent() throws Exception { } @Test - public void testSubProcessWithTerminateEndEvent() throws Exception { - kruntime = createKogitoProcessRuntime("org/jbpm/bpmn2/subprocess/BPMN2-SubProcessWithTerminateEndEvent.bpmn2"); - final List list = new ArrayList<>(); - kruntime.getProcessEventManager().addEventListener(new DefaultKogitoProcessEventListener() { + public void testSubProcessWithTerminateEndEvent() { + Application app = ProcessTestHelper.newApplication(); + EventTrackerProcessListener listener = new EventTrackerProcessListener(); + ProcessTestHelper.registerProcessEventListener(app, listener); + org.kie.kogito.process.Process processDefinition = SubProcessWithTerminateEndEventProcess.newProcess(app); + SubProcessWithTerminateEndEventModel model = processDefinition.createModel(); + + org.kie.kogito.process.ProcessInstance instance = processDefinition.createInstance(model); + instance.start(); + Set processNodeEvents = listener.tracked().stream() + .map(ProcessNodeEvent::getNodeInstance) + .collect(Collectors.toSet()); + assertThat(instance).extracting(ProcessInstance::status).isEqualTo(ProcessInstance.STATE_COMPLETED); + assertThat(processNodeEvents).hasSize(7); - @Override - public void afterNodeTriggered(ProcessNodeTriggeredEvent event) { - list.add(event.getNodeInstance().getNodeName()); - } - }); - KogitoProcessInstance processInstance = kruntime.startProcess("SubProcessWithTerminateEndEvent"); - assertProcessInstanceCompleted(processInstance); - assertThat(list).hasSize(7); } @Test - public void testSubProcessWithTerminateEndEventProcessScope() - throws Exception { - kruntime = createKogitoProcessRuntime("org/jbpm/bpmn2/subprocess/BPMN2-SubProcessWithTerminateEndEventProcessScope.bpmn2"); - final List list = new ArrayList<>(); - kruntime.getProcessEventManager().addEventListener(new DefaultKogitoProcessEventListener() { + public void testSubProcessWithTerminateEndEventProcessScope() { + + Application app = ProcessTestHelper.newApplication(); + final List nodeList = new ArrayList<>(); + EventTrackerProcessListener listener = new EventTrackerProcessListener() { @Override public void afterNodeTriggered(ProcessNodeTriggeredEvent event) { - list.add(event.getNodeInstance().getNodeName()); + NodeInstance nodeInstance = event.getNodeInstance(); + if (!(nodeInstance instanceof EndNodeInstance || nodeInstance instanceof StartNodeInstance)) { + nodeList.add(nodeInstance.getNodeName()); + } } - }); - KogitoProcessInstance processInstance = kruntime.startProcess("SubProcessWithTerminateEndEventProcessScope"); - assertProcessInstanceCompleted(processInstance); - assertThat(list).hasSize(5); + }; + ProcessTestHelper.registerProcessEventListener(app, listener); + org.kie.kogito.process.Process processDefinition = SubProcessWithTerminateEndEventProcessScopeProcess.newProcess(app); + SubProcessWithTerminateEndEventProcessScopeModel model = processDefinition.createModel(); + + org.kie.kogito.process.ProcessInstance instance = processDefinition.createInstance(model); + instance.start(); + assertThat(instance).extracting(ProcessInstance::status).isEqualTo(ProcessInstance.STATE_COMPLETED); + assertThat(nodeList).hasSize(3); } @Test @@ -883,17 +914,19 @@ public void testSendTask() { @Test public void testReceiveTask() throws Exception { + Application app = ProcessTestHelper.newApplication(); kruntime = createKogitoProcessRuntime("org/jbpm/bpmn2/task/BPMN2-ReceiveTask.bpmn2"); ReceiveTaskHandler receiveTaskHandler = new ReceiveTaskHandler(kruntime); - - kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Receive Task", - receiveTaskHandler); - KogitoWorkflowProcessInstance processInstance = (KogitoWorkflowProcessInstance) kruntime - .startProcess("ReceiveTask"); - assertProcessInstanceActive(processInstance); + ProcessTestHelper.registerHandler(app, "Receive Task", receiveTaskHandler); + org.kie.kogito.process.Process processDefinition = ReceiveTaskProcess.newProcess(app); + ReceiveTaskModel model = processDefinition.createModel(); + org.kie.kogito.process.ProcessInstance instance = processDefinition.createInstance(model); + instance.start(); + assertThat(instance).extracting(ProcessInstance::status).isEqualTo(ProcessInstance.STATE_ACTIVE); receiveTaskHandler.setKnowledgeRuntime(kruntime); receiveTaskHandler.messageReceived("HelloMessage", "Hello john!"); - assertProcessInstanceFinished(processInstance, kruntime); + ProcessTestHelper.completeWorkItem(instance, "john", Collections.emptyMap()); + assertThat(instance.status()).isEqualTo(org.kie.kogito.process.ProcessInstance.STATE_COMPLETED); } @Test From 79b0819608212b95e5d515819cfcd283a0e18678 Mon Sep 17 00:00:00 2001 From: Alex Porcelli Date: Thu, 30 May 2024 06:15:30 -0400 Subject: [PATCH 28/32] kie-issues#1282: updating spring boot version that address some important CVEs (#3538) --- kogito-build/kogito-dependencies-bom/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kogito-build/kogito-dependencies-bom/pom.xml b/kogito-build/kogito-dependencies-bom/pom.xml index 818b4113931..9e0e21dea0d 100644 --- a/kogito-build/kogito-dependencies-bom/pom.xml +++ b/kogito-build/kogito-dependencies-bom/pom.xml @@ -37,7 +37,7 @@ 3.8.4 ${version.io.quarkus} - 3.2.5 + 3.2.6 3.6.1 1.78.1 From 47e57329910867a37d949cbe6b5b58e2daba6f44 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pere=20Fern=C3=A1ndez?= Date: Fri, 31 May 2024 10:58:00 +0200 Subject: [PATCH 29/32] incubator-kie-issues#1283: Fix Kogito Addons Quarkus Data Index `DevMode` (#3540) --- .../KogitoDevServicesProcessor.java | 32 +++++++++++++------ ...erverlessWorkflowDevServicesProcessor.java | 32 +++++++++++++------ .../AbstractDevServicesProcessor.java | 2 +- 3 files changed, 45 insertions(+), 21 deletions(-) diff --git a/quarkus/extensions/kogito-quarkus-processes-extension/kogito-quarkus-processes-deployment/src/main/java/org/kie/kogito/quarkus/processes/deployment/KogitoDevServicesProcessor.java b/quarkus/extensions/kogito-quarkus-processes-extension/kogito-quarkus-processes-deployment/src/main/java/org/kie/kogito/quarkus/processes/deployment/KogitoDevServicesProcessor.java index 05fb6777d5d..51e9b5b090c 100644 --- a/quarkus/extensions/kogito-quarkus-processes-extension/kogito-quarkus-processes-deployment/src/main/java/org/kie/kogito/quarkus/processes/deployment/KogitoDevServicesProcessor.java +++ b/quarkus/extensions/kogito-quarkus-processes-extension/kogito-quarkus-processes-deployment/src/main/java/org/kie/kogito/quarkus/processes/deployment/KogitoDevServicesProcessor.java @@ -27,6 +27,7 @@ import io.quarkus.arc.deployment.AdditionalBeanBuildItem; import io.quarkus.arc.processor.DotNames; +import io.quarkus.deployment.Capabilities; import io.quarkus.deployment.IsDevelopment; import io.quarkus.deployment.annotations.BuildProducer; import io.quarkus.deployment.annotations.BuildStep; @@ -36,6 +37,8 @@ import io.quarkus.devui.spi.page.CardPageBuildItem; import io.quarkus.devui.spi.page.Page; +import static org.kie.kogito.quarkus.workflow.devservices.DataIndexEventPublisher.KOGITO_DATA_INDEX; + /** * Starts a Data Index as dev service if needed. */ @@ -49,16 +52,25 @@ public void logger(BuildProducer additionalBean, Launch } @BuildStep(onlyIf = { GlobalDevServicesConfig.Enabled.class, IsDevelopment.class }) - CardPageBuildItem createDevUILink(List systemPropertyBuildItems) { - Optional dataindex_url_prop = getProperty(systemPropertyBuildItems, "kogito.data-index.url"); - if (dataindex_url_prop.isPresent()) { - CardPageBuildItem cardPageBuildItem = new CardPageBuildItem(); - cardPageBuildItem.addPage(Page.externalPageBuilder("Data Index GraphQL UI") - .url(dataindex_url_prop.get() + "/q/graphql-ui/") - .isHtmlContent() - .icon("font-awesome-solid:signs-post")); - return cardPageBuildItem; + CardPageBuildItem createDataIndexDevUILink(Capabilities capabilities, + KogitoWorkflowBuildTimeConfig kogitoBuildTimeConfig, + List systemPropertyBuildItems) { + + Optional dataIndexUrlProp = getProperty(systemPropertyBuildItems, KOGITO_DATA_INDEX); + + if (capabilities.isPresent(DATA_INDEX_CAPABILITY) || !areDevServicesEnabled(kogitoBuildTimeConfig) || dataIndexUrlProp.isEmpty()) { + return null; } - return null; + + CardPageBuildItem cardPageBuildItem = new CardPageBuildItem(); + cardPageBuildItem.addPage(Page.externalPageBuilder("Data Index GraphQL UI") + .url(dataIndexUrlProp.get() + "/q/graphql-ui/") + .isHtmlContent() + .icon("font-awesome-solid:signs-post")); + return cardPageBuildItem; + } + + private boolean areDevServicesEnabled(KogitoWorkflowBuildTimeConfig kogitoBuildTimeConfig) { + return kogitoBuildTimeConfig.devservices.enabled.orElse(true); } } diff --git a/quarkus/extensions/kogito-quarkus-serverless-workflow-extension/kogito-quarkus-serverless-workflow-deployment/src/main/java/org/kie/kogito/quarkus/serverless/workflow/deployment/ServerlessWorkflowDevServicesProcessor.java b/quarkus/extensions/kogito-quarkus-serverless-workflow-extension/kogito-quarkus-serverless-workflow-deployment/src/main/java/org/kie/kogito/quarkus/serverless/workflow/deployment/ServerlessWorkflowDevServicesProcessor.java index 02cba0f8d7d..31d86e51a58 100644 --- a/quarkus/extensions/kogito-quarkus-serverless-workflow-extension/kogito-quarkus-serverless-workflow-deployment/src/main/java/org/kie/kogito/quarkus/serverless/workflow/deployment/ServerlessWorkflowDevServicesProcessor.java +++ b/quarkus/extensions/kogito-quarkus-serverless-workflow-extension/kogito-quarkus-serverless-workflow-deployment/src/main/java/org/kie/kogito/quarkus/serverless/workflow/deployment/ServerlessWorkflowDevServicesProcessor.java @@ -27,6 +27,7 @@ import io.quarkus.arc.deployment.AdditionalBeanBuildItem; import io.quarkus.arc.processor.DotNames; +import io.quarkus.deployment.Capabilities; import io.quarkus.deployment.IsDevelopment; import io.quarkus.deployment.annotations.BuildProducer; import io.quarkus.deployment.annotations.BuildStep; @@ -36,6 +37,8 @@ import io.quarkus.devui.spi.page.CardPageBuildItem; import io.quarkus.devui.spi.page.Page; +import static org.kie.kogito.quarkus.workflow.devservices.DataIndexEventPublisher.KOGITO_DATA_INDEX; + public class ServerlessWorkflowDevServicesProcessor extends AbstractDevServicesProcessor { @BuildStep public void logger(BuildProducer additionalBean, LaunchModeBuildItem launchMode, KogitoWorkflowBuildTimeConfig config) { @@ -45,16 +48,25 @@ public void logger(BuildProducer additionalBean, Launch } @BuildStep(onlyIf = { GlobalDevServicesConfig.Enabled.class, IsDevelopment.class }) - CardPageBuildItem createDevUILink(List systemPropertyBuildItems) { - Optional dataindex_url_prop = getProperty(systemPropertyBuildItems, "kogito.data-index.url"); - if (dataindex_url_prop.isPresent()) { - CardPageBuildItem cardPageBuildItem = new CardPageBuildItem(); - cardPageBuildItem.addPage(Page.externalPageBuilder("Data Index GraphQL UI") - .url(dataindex_url_prop.get() + "/q/graphql-ui/") - .isHtmlContent() - .icon("font-awesome-solid:signs-post")); - return cardPageBuildItem; + CardPageBuildItem createDataIndexDevUILink(Capabilities capabilities, + KogitoWorkflowBuildTimeConfig kogitoBuildTimeConfig, + List systemPropertyBuildItems) { + + Optional dataIndexUrlProp = getProperty(systemPropertyBuildItems, KOGITO_DATA_INDEX); + + if (capabilities.isPresent(DATA_INDEX_CAPABILITY) || !areDevServicesEnabled(kogitoBuildTimeConfig) || dataIndexUrlProp.isEmpty()) { + return null; } - return null; + + CardPageBuildItem cardPageBuildItem = new CardPageBuildItem(); + cardPageBuildItem.addPage(Page.externalPageBuilder("Data Index GraphQL UI") + .url(dataIndexUrlProp.get() + "/q/graphql-ui/") + .isHtmlContent() + .icon("font-awesome-solid:signs-post")); + return cardPageBuildItem; + } + + private boolean areDevServicesEnabled(KogitoWorkflowBuildTimeConfig kogitoBuildTimeConfig) { + return kogitoBuildTimeConfig.devservices.enabled.orElse(true); } } diff --git a/quarkus/extensions/kogito-quarkus-workflow-extension-common/kogito-quarkus-workflow-common-deployment/src/main/java/org/kie/kogito/quarkus/workflow/deployment/AbstractDevServicesProcessor.java b/quarkus/extensions/kogito-quarkus-workflow-extension-common/kogito-quarkus-workflow-common-deployment/src/main/java/org/kie/kogito/quarkus/workflow/deployment/AbstractDevServicesProcessor.java index 6bbb90352cc..7517da1c86d 100644 --- a/quarkus/extensions/kogito-quarkus-workflow-extension-common/kogito-quarkus-workflow-common-deployment/src/main/java/org/kie/kogito/quarkus/workflow/deployment/AbstractDevServicesProcessor.java +++ b/quarkus/extensions/kogito-quarkus-workflow-extension-common/kogito-quarkus-workflow-common-deployment/src/main/java/org/kie/kogito/quarkus/workflow/deployment/AbstractDevServicesProcessor.java @@ -60,7 +60,7 @@ public abstract class AbstractDevServicesProcessor { private static final Logger LOGGER = LoggerFactory.getLogger(AbstractDevServicesProcessor.class); private static final ContainerLocator LOCATOR = new ContainerLocator(DataIndexInMemoryContainer.DEV_SERVICE_LABEL, DataIndexInMemoryContainer.PORT); - private static final String DATA_INDEX_CAPABILITY = "org.kie.kogito.data-index"; + protected static final String DATA_INDEX_CAPABILITY = "org.kie.kogito.data-index"; static Closeable closeable; static DataIndexDevServiceConfig cfg; static volatile boolean first = true; From 7e2a311260bc417b8775d4313d7e126787a245d6 Mon Sep 17 00:00:00 2001 From: Enrique Date: Mon, 3 Jun 2024 09:41:06 +0200 Subject: [PATCH 30/32] [incubator-kie-issues-1277] Remove unused bpmn in jbpm-test (#3536) --- .../BPMN2-Compensation-Transaction.bpmn2 | 201 ----- .../BPMN2-TravelBookingExample.bpmn2 | 703 ------------------ .../resources/correlationkey/Process1.bpmn2 | 165 ---- .../resources/correlationkey/Process2.bpmn2 | 165 ---- .../resources/correlationkey/Process3.bpmn2 | 165 ---- .../resources/correlationkey/Process4.bpmn2 | 165 ---- .../resources/correlationkey/Process5.bpmn2 | 166 ----- 7 files changed, 1730 deletions(-) delete mode 100755 jbpm/jbpm-tests/src/test/resources/compensation/unimplemented/BPMN2-Compensation-Transaction.bpmn2 delete mode 100755 jbpm/jbpm-tests/src/test/resources/compensation/unimplemented/BPMN2-TravelBookingExample.bpmn2 delete mode 100755 jbpm/jbpm-tests/src/test/resources/correlationkey/Process1.bpmn2 delete mode 100755 jbpm/jbpm-tests/src/test/resources/correlationkey/Process2.bpmn2 delete mode 100755 jbpm/jbpm-tests/src/test/resources/correlationkey/Process3.bpmn2 delete mode 100755 jbpm/jbpm-tests/src/test/resources/correlationkey/Process4.bpmn2 delete mode 100755 jbpm/jbpm-tests/src/test/resources/correlationkey/Process5.bpmn2 diff --git a/jbpm/jbpm-tests/src/test/resources/compensation/unimplemented/BPMN2-Compensation-Transaction.bpmn2 b/jbpm/jbpm-tests/src/test/resources/compensation/unimplemented/BPMN2-Compensation-Transaction.bpmn2 deleted file mode 100755 index 69928fe1b46..00000000000 --- a/jbpm/jbpm-tests/src/test/resources/compensation/unimplemented/BPMN2-Compensation-Transaction.bpmn2 +++ /dev/null @@ -1,201 +0,0 @@ - - - - - - - - - - _1-_2 - - - - _1-_2 - _2-_3 - - _2-1-_2-2 - - - - _2-1-_2-2 - _2-2-_2-3 - System.out.println("x = "); - - - - _2-2-_2-3 - _2-3-2-4a - _2-3-2-4c - - - return x == "normal"; - - - return x == "cancel"; - - - _2-3-2-4a - - - _2-3-2-4c - - - - - - - System.out.println("x = "); - - - - - _2-_3 - - - - _10 - - - - _10 - System.out.println("x = "); - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/jbpm/jbpm-tests/src/test/resources/compensation/unimplemented/BPMN2-TravelBookingExample.bpmn2 b/jbpm/jbpm-tests/src/test/resources/compensation/unimplemented/BPMN2-TravelBookingExample.bpmn2 deleted file mode 100755 index 5392de2174c..00000000000 --- a/jbpm/jbpm-tests/src/test/resources/compensation/unimplemented/BPMN2-TravelBookingExample.bpmn2 +++ /dev/null @@ -1,703 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/jbpm/jbpm-tests/src/test/resources/correlationkey/Process1.bpmn2 b/jbpm/jbpm-tests/src/test/resources/correlationkey/Process1.bpmn2 deleted file mode 100755 index 7698cb20c35..00000000000 --- a/jbpm/jbpm-tests/src/test/resources/correlationkey/Process1.bpmn2 +++ /dev/null @@ -1,165 +0,0 @@ - - - - - - - - - - - - _C49952D8-3347-45A0-954A-EFB585B6F3B8 - - - - - - - - _C49952D8-3347-45A0-954A-EFB585B6F3B8 - _6DF23EF1-3C05-4974-9ACA-DB5FD86E0662 - - - - - - - - - - _6DF23EF1-3C05-4974-9ACA-DB5FD86E0662 - _0FCFBC75-ED97-4A46-975D-A0477EFA0767 - - - - - - - - _0FCFBC75-ED97-4A46-975D-A0477EFA0767 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - _nPBtwMLiEeiG6-VRHK3TqQ - _nPBtwMLiEeiG6-VRHK3TqQ - - diff --git a/jbpm/jbpm-tests/src/test/resources/correlationkey/Process2.bpmn2 b/jbpm/jbpm-tests/src/test/resources/correlationkey/Process2.bpmn2 deleted file mode 100755 index 166ebc84aee..00000000000 --- a/jbpm/jbpm-tests/src/test/resources/correlationkey/Process2.bpmn2 +++ /dev/null @@ -1,165 +0,0 @@ - - - - - - - - - - - - _AC6A8707-5DF1-4D21-8C80-41452B4D93E6 - - - - - - - - _AC6A8707-5DF1-4D21-8C80-41452B4D93E6 - _A3AEB5E4-43F9-447B-86C2-F9B0539148CF - - - - - - - - - - _A3AEB5E4-43F9-447B-86C2-F9B0539148CF - _8146887F-EC59-4764-8EE8-F7188A3B244A - - - - - - - - _8146887F-EC59-4764-8EE8-F7188A3B244A - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - _pPzSsMLiEeiG6-VRHK3TqQ - _pPzSsMLiEeiG6-VRHK3TqQ - - diff --git a/jbpm/jbpm-tests/src/test/resources/correlationkey/Process3.bpmn2 b/jbpm/jbpm-tests/src/test/resources/correlationkey/Process3.bpmn2 deleted file mode 100755 index ebda1acc755..00000000000 --- a/jbpm/jbpm-tests/src/test/resources/correlationkey/Process3.bpmn2 +++ /dev/null @@ -1,165 +0,0 @@ - - - - - - - - - - - - _227BBF90-3EC7-4911-80B3-D2C12C172E07 - - - - - - - - _227BBF90-3EC7-4911-80B3-D2C12C172E07 - _943009C4-792F-462A-AF81-5A20C5B4D2C6 - - - - - - - - - - _943009C4-792F-462A-AF81-5A20C5B4D2C6 - _376B2FD2-96C2-48FA-9A7A-BF30F2DBB4AF - - - - - - - - _376B2FD2-96C2-48FA-9A7A-BF30F2DBB4AF - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - _rQD6QMLiEeiG6-VRHK3TqQ - _rQD6QMLiEeiG6-VRHK3TqQ - - diff --git a/jbpm/jbpm-tests/src/test/resources/correlationkey/Process4.bpmn2 b/jbpm/jbpm-tests/src/test/resources/correlationkey/Process4.bpmn2 deleted file mode 100755 index 2d2311fd3fa..00000000000 --- a/jbpm/jbpm-tests/src/test/resources/correlationkey/Process4.bpmn2 +++ /dev/null @@ -1,165 +0,0 @@ - - - - - - - - - - - - _AB7A0A8F-5BB7-4432-A133-FBB1117FFC69 - - - - - - - - _AB7A0A8F-5BB7-4432-A133-FBB1117FFC69 - _326982AC-3AE5-4383-A25D-ECC30B17C2BE - - - - - - - - - - _326982AC-3AE5-4383-A25D-ECC30B17C2BE - _51579233-3949-4142-8B20-B20B1E6A8566 - - - - - - - - _51579233-3949-4142-8B20-B20B1E6A8566 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - _tVYA8MLiEeiG6-VRHK3TqQ - _tVYA8MLiEeiG6-VRHK3TqQ - - diff --git a/jbpm/jbpm-tests/src/test/resources/correlationkey/Process5.bpmn2 b/jbpm/jbpm-tests/src/test/resources/correlationkey/Process5.bpmn2 deleted file mode 100755 index c270809f499..00000000000 --- a/jbpm/jbpm-tests/src/test/resources/correlationkey/Process5.bpmn2 +++ /dev/null @@ -1,166 +0,0 @@ - - - - - - - - - - - - _608D663D-B91B-4D76-A521-57542AA715FD - - - - - - - - _608D663D-B91B-4D76-A521-57542AA715FD - _7EEE8F72-8D01-4BEC-9E56-21E97DE6A175 - - - - - - - - - - _7EEE8F72-8D01-4BEC-9E56-21E97DE6A175 - _F8BAA499-95A4-4B35-8AB9-A234355DF618 - - - - - - - - - - _F8BAA499-95A4-4B35-8AB9-A234355DF618 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - _51jkAMLiEeiG6-VRHK3TqQ - _51jkAMLiEeiG6-VRHK3TqQ - - From c822a66a9bae463f46e5f44968e98dbaaa0d90fa Mon Sep 17 00:00:00 2001 From: Francisco Javier Tirado Sarti <65240126+fjtirado@users.noreply.github.com> Date: Tue, 4 Jun 2024 12:51:55 +0200 Subject: [PATCH 31/32] [Fix_#3451] Fixing start event state filtering (#3542) * [Fix_#3451] Fixing start event state filtering * [Fix_#3451] Add IT test --- .../parser/handlers/EventHandler.java | 3 +- .../parser/handlers/StateHandler.java | 12 +++++- .../src/main/resources/application.properties | 6 +++ .../src/main/resources/greetCustomer.sw.json | 41 +++++++++++++++++++ .../kogito/quarkus/workflows/EventFlowIT.java | 22 ++++++++++ 5 files changed, 80 insertions(+), 4 deletions(-) create mode 100644 quarkus/extensions/kogito-quarkus-serverless-workflow-extension/kogito-quarkus-serverless-workflow-integration-test/src/main/resources/greetCustomer.sw.json diff --git a/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/parser/handlers/EventHandler.java b/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/parser/handlers/EventHandler.java index 9ccecb22a79..6c95879a018 100644 --- a/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/parser/handlers/EventHandler.java +++ b/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/parser/handlers/EventHandler.java @@ -30,7 +30,6 @@ import org.jbpm.workflow.core.node.Join; import org.jbpm.workflow.core.node.Split; import org.kie.kogito.serverless.workflow.parser.ParserContext; -import org.kie.kogito.serverless.workflow.parser.ServerlessWorkflowParser; import io.serverlessworkflow.api.Workflow; import io.serverlessworkflow.api.events.OnEvents; @@ -65,7 +64,7 @@ public MakeNodeResult makeNode(RuleFlowNodeContainerFactory factory) { private MakeNodeResult processOnEvent(RuleFlowNodeContainerFactory factory, OnEvents onEvent) { MakeNodeResult result = joinNodes(factory, - onEvent.getEventRefs(), (fact, onEventRef) -> filterAndMergeNode(fact, onEvent.getEventDataFilter(), isStartState ? ServerlessWorkflowParser.DEFAULT_WORKFLOW_VAR : getVarName(), + onEvent.getEventRefs(), (fact, onEventRef) -> filterAndMergeNode(fact, onEvent.getEventDataFilter(), getVarName(), (f, inputVar, outputVar) -> buildEventNode(f, onEventRef, inputVar, outputVar))); CompositeContextNodeFactory embeddedSubProcess = handleActions(makeCompositeNode(factory), onEvent.getActions()); connect(result.getOutgoingNode(), embeddedSubProcess); diff --git a/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/parser/handlers/StateHandler.java b/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/parser/handlers/StateHandler.java index 63610ad6b71..5c9caf6f451 100644 --- a/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/parser/handlers/StateHandler.java +++ b/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/parser/handlers/StateHandler.java @@ -50,6 +50,7 @@ import org.kie.kogito.serverless.workflow.SWFConstants; import org.kie.kogito.serverless.workflow.parser.ParserContext; import org.kie.kogito.serverless.workflow.parser.ServerlessWorkflowParser; +import org.kie.kogito.serverless.workflow.parser.VariableInfo; import org.kie.kogito.serverless.workflow.suppliers.CollectorActionSupplier; import org.kie.kogito.serverless.workflow.suppliers.CompensationActionSupplier; import org.kie.kogito.serverless.workflow.suppliers.ErrorExpressionActionSupplier; @@ -424,7 +425,8 @@ protected final MakeNodeResult filterAndMergeNode(RuleFlowNodeContainerFactory embeddedSubProcess, String actionVarName, String fromStateExpr, String resultExpr, String toStateExpr, boolean useData, boolean shouldMerge, FilterableNodeSupplier nodeSupplier) { + return filterAndMergeNode(embeddedSubProcess, new VariableInfo(actionVarName, actionVarName), fromStateExpr, resultExpr, toStateExpr, useData, shouldMerge, nodeSupplier); + } + protected final MakeNodeResult filterAndMergeNode(RuleFlowNodeContainerFactory embeddedSubProcess, VariableInfo variableInfo, String fromStateExpr, String resultExpr, String toStateExpr, + boolean useData, + boolean shouldMerge, FilterableNodeSupplier nodeSupplier) { + String actionVarName = variableInfo.getOutputVar(); if (isTempVariable(actionVarName)) { embeddedSubProcess.variable(actionVarName, new ObjectDataType(JsonNode.class.getCanonicalName()), Map.of(KogitoTags.VARIABLE_TAGS, KogitoTags.INTERNAL_TAG)); } @@ -451,7 +459,7 @@ protected final MakeNodeResult filterAndMergeNode(RuleFlowNodeContainerFactory Date: Tue, 4 Jun 2024 16:28:10 +0200 Subject: [PATCH 32/32] [incubator-kie-issues#1294] Allow RuntimeTypeCheckOption configuration via environment property (#3547) Co-authored-by: Gabriele-Cardosi --- .../src/main/java/org/kie/kogito/dmn/DMNKogito.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drools/kogito-dmn/src/main/java/org/kie/kogito/dmn/DMNKogito.java b/drools/kogito-dmn/src/main/java/org/kie/kogito/dmn/DMNKogito.java index 12391a7f79f..9905a4b6d5b 100644 --- a/drools/kogito-dmn/src/main/java/org/kie/kogito/dmn/DMNKogito.java +++ b/drools/kogito-dmn/src/main/java/org/kie/kogito/dmn/DMNKogito.java @@ -28,6 +28,8 @@ import org.kie.api.io.Resource; import org.kie.dmn.api.core.DMNModel; import org.kie.dmn.api.core.DMNRuntime; +import org.kie.dmn.core.compiler.RuntimeTypeCheckOption; +import org.kie.dmn.core.impl.DMNRuntimeImpl; import org.kie.dmn.core.internal.utils.DMNEvaluationUtils; import org.kie.dmn.core.internal.utils.DMNEvaluationUtils.DMNEvaluationResult; import org.kie.dmn.core.internal.utils.DMNRuntimeBuilder; @@ -59,6 +61,9 @@ public static DMNRuntime createGenericDMNRuntime(Reader... readers) { .buildConfiguration() .fromResources(resources) .getOrElseThrow(e -> new RuntimeException("Error initializing DMNRuntime", e)); + boolean enableRuntimeTypeCheckOption = "true".equals(System.getProperty(RuntimeTypeCheckOption.PROPERTY_NAME, "false")); + RuntimeTypeCheckOption runtimeTypeCheckOption = new RuntimeTypeCheckOption(enableRuntimeTypeCheckOption); + ((DMNRuntimeImpl) dmnRuntime).setOption(runtimeTypeCheckOption); DMNKogitoCallbacks.afterCreateGenericDMNRuntime(dmnRuntime); return dmnRuntime; }