From b850445eb16423a8689405d912f3d74614274a05 Mon Sep 17 00:00:00 2001 From: Enrique Date: Mon, 13 May 2024 08:56:35 +0200 Subject: [PATCH 01/18] [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/18] 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/18] [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/18] 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/18] 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/18] 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/18] 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/18] 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/18] [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/18] [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/18] 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/18] [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/18] [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/18] [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/18] 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/18] 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/18] 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/18] [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