forked from apache/incubator-kie-kogito-runtimes
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[incubator-kie-issues-1108] Add capability to create node instances (…
…node states) from the nodes (apache#3482)
- Loading branch information
1 parent
111c75f
commit 92c33c5
Showing
10 changed files
with
317 additions
and
157 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
.../jbpm-flow/src/main/java/org/jbpm/workflow/instance/impl/NodeInstanceFactoryProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* | ||
* 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.workflow.instance.impl; | ||
|
||
import java.util.List; | ||
|
||
public interface NodeInstanceFactoryProvider { | ||
|
||
List<NodeInstanceFactory> provide(); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
...ow/src/main/java/org/jbpm/workflow/instance/impl/factory/AbstractNodeInstanceFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* | ||
* 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.workflow.instance.impl.factory; | ||
|
||
import org.jbpm.workflow.instance.WorkflowProcessInstance; | ||
import org.jbpm.workflow.instance.impl.NodeInstanceFactory; | ||
import org.jbpm.workflow.instance.impl.NodeInstanceImpl; | ||
import org.kie.api.definition.process.Node; | ||
import org.kie.api.runtime.process.NodeInstance; | ||
import org.kie.api.runtime.process.NodeInstanceContainer; | ||
import org.kie.kogito.internal.process.runtime.KogitoNodeInstanceContainer; | ||
|
||
import static org.jbpm.ruleflow.core.Metadata.CUSTOM_ASYNC; | ||
|
||
public abstract class AbstractNodeInstanceFactory implements NodeInstanceFactory { | ||
|
||
protected NodeInstance createInstance(NodeInstanceImpl nodeInstance, Node node, WorkflowProcessInstance processInstance, NodeInstanceContainer nodeInstanceContainer) { | ||
nodeInstance.setNodeId(node.getId()); | ||
nodeInstance.setNodeInstanceContainer((KogitoNodeInstanceContainer) nodeInstanceContainer); | ||
nodeInstance.setProcessInstance(processInstance); | ||
nodeInstance.setMetaData(CUSTOM_ASYNC, node.getMetaData().get(CUSTOM_ASYNC)); | ||
|
||
int level = ((org.jbpm.workflow.instance.NodeInstanceContainer) nodeInstanceContainer).getLevelForNode(node.getUniqueId()); | ||
nodeInstance.setLevel(level); | ||
return nodeInstance; | ||
} | ||
} |
50 changes: 50 additions & 0 deletions
50
...low/src/main/java/org/jbpm/workflow/instance/impl/factory/DefaultNodeInstanceFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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.workflow.instance.impl.factory; | ||
|
||
import java.util.function.Supplier; | ||
|
||
import org.jbpm.workflow.core.impl.NodeImpl; | ||
import org.jbpm.workflow.instance.WorkflowProcessInstance; | ||
import org.jbpm.workflow.instance.impl.NodeInstanceImpl; | ||
import org.kie.api.definition.process.Node; | ||
import org.kie.api.runtime.process.NodeInstance; | ||
import org.kie.api.runtime.process.NodeInstanceContainer; | ||
|
||
public class DefaultNodeInstanceFactory extends AbstractNodeInstanceFactory { | ||
|
||
private Class<? extends NodeImpl> nodeDefinition; | ||
private Supplier<NodeInstanceImpl> nodeInstanceSupplier; | ||
|
||
@Override | ||
public Class<? extends Node> forClass() { | ||
return nodeDefinition; | ||
} | ||
|
||
public DefaultNodeInstanceFactory(Class<? extends NodeImpl> nodeDefinition, Supplier<NodeInstanceImpl> supplier) { | ||
this.nodeDefinition = nodeDefinition; | ||
this.nodeInstanceSupplier = supplier; | ||
} | ||
|
||
@Override | ||
public NodeInstance getNodeInstance(Node node, WorkflowProcessInstance processInstance, NodeInstanceContainer nodeInstanceContainer) { | ||
return createInstance(nodeInstanceSupplier.get(), node, processInstance, nodeInstanceContainer); | ||
} | ||
|
||
} |
Oops, something went wrong.