diff --git a/api/kogito-api/pom.xml b/api/kogito-api/pom.xml index cec9ac55aab..abb006d4e5a 100755 --- a/api/kogito-api/pom.xml +++ b/api/kogito-api/pom.xml @@ -61,14 +61,13 @@ jakarta.xml.bind jakarta.xml.bind-api provided - 4.0.1 - org.kie - kie-api + org.kie.kogito + jbpm-flow-api - + com.fasterxml.jackson.core jackson-annotations diff --git a/jbpm/jbpm-bpmn2/pom.xml b/jbpm/jbpm-bpmn2/pom.xml index a801e38ba57..fe7b5da76f9 100755 --- a/jbpm/jbpm-bpmn2/pom.xml +++ b/jbpm/jbpm-bpmn2/pom.xml @@ -77,7 +77,6 @@ jakarta.xml.bind jakarta.xml.bind-api provided - 4.0.1 com.sun.xml.bind @@ -88,7 +87,6 @@ org.glassfish.jaxb jaxb-runtime provided - 4.0.4 org.eclipse.angus diff --git a/jbpm/jbpm-flow-api/pom.xml b/jbpm/jbpm-flow-api/pom.xml new file mode 100644 index 00000000000..43c6c3a053b --- /dev/null +++ b/jbpm/jbpm-flow-api/pom.xml @@ -0,0 +1,41 @@ + + + 4.0.0 + + jbpm + org.kie.kogito + 999-SNAPSHOT + + + jbpm-flow-api + + Kogito :: jBPM :: API + jBPM Flow API + + + UTF-8 + org.kie.kogito.jbpm.flow.api + + + + + org.kie + kie-api + + + + + + + org.kie.kogito + kogito-kie-bom + ${project.version} + pom + import + + + + + diff --git a/jbpm/jbpm-flow-api/src/main/java/org/kie/api/event/usertask/Attachment.java b/jbpm/jbpm-flow-api/src/main/java/org/kie/api/event/usertask/Attachment.java new file mode 100644 index 00000000000..ded0ce0df24 --- /dev/null +++ b/jbpm/jbpm-flow-api/src/main/java/org/kie/api/event/usertask/Attachment.java @@ -0,0 +1,37 @@ +/* + * 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.kie.api.event.usertask; + +import java.net.URI; +import java.util.Date; + +public interface Attachment { + + String getAttachmentId(); + + String getAttachmentName(); + + URI getAttachmentURI(); + + String getUpdatedBy(); + + Date getUpdatedAt(); + +} diff --git a/jbpm/jbpm-flow-api/src/main/java/org/kie/api/event/usertask/Comment.java b/jbpm/jbpm-flow-api/src/main/java/org/kie/api/event/usertask/Comment.java new file mode 100644 index 00000000000..c361bccdd5a --- /dev/null +++ b/jbpm/jbpm-flow-api/src/main/java/org/kie/api/event/usertask/Comment.java @@ -0,0 +1,34 @@ +/* + * 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.kie.api.event.usertask; + +import java.util.Date; + +public interface Comment { + + String getCommentId(); + + String getCommentContent(); + + String getUpdatedBy(); + + Date getUpdatedAt(); + +} diff --git a/jbpm/jbpm-flow-api/src/main/java/org/kie/api/event/usertask/UserTaskAssignmentEvent.java b/jbpm/jbpm-flow-api/src/main/java/org/kie/api/event/usertask/UserTaskAssignmentEvent.java new file mode 100644 index 00000000000..01d460e0ddb --- /dev/null +++ b/jbpm/jbpm-flow-api/src/main/java/org/kie/api/event/usertask/UserTaskAssignmentEvent.java @@ -0,0 +1,30 @@ +/* + * 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.kie.api.event.usertask; + +public interface UserTaskAssignmentEvent extends UserTaskEvent { + + String getAssignmentType(); + + String[] getNewUsersId(); + + String[] getOldUsersId(); + +} diff --git a/jbpm/jbpm-flow/src/main/java/org/jbpm/process/instance/command/KogitoProcessInstanceIdCommand.java b/jbpm/jbpm-flow-api/src/main/java/org/kie/api/event/usertask/UserTaskAttachmentEvent.java similarity index 82% rename from jbpm/jbpm-flow/src/main/java/org/jbpm/process/instance/command/KogitoProcessInstanceIdCommand.java rename to jbpm/jbpm-flow-api/src/main/java/org/kie/api/event/usertask/UserTaskAttachmentEvent.java index eca0dedd8cc..9f82c73605e 100644 --- a/jbpm/jbpm-flow/src/main/java/org/jbpm/process/instance/command/KogitoProcessInstanceIdCommand.java +++ b/jbpm/jbpm-flow-api/src/main/java/org/kie/api/event/usertask/UserTaskAttachmentEvent.java @@ -16,11 +16,13 @@ * specific language governing permissions and limitations * under the License. */ -package org.jbpm.process.instance.command; -public interface KogitoProcessInstanceIdCommand { +package org.kie.api.event.usertask; - void setProcessInstanceId(String procInstId); +public interface UserTaskAttachmentEvent extends UserTaskEvent { + + Attachment getOldAttachment(); + + Attachment getNewAttachment(); - String getProcessInstanceId(); } diff --git a/jbpm/jbpm-flow-api/src/main/java/org/kie/api/event/usertask/UserTaskCommentEvent.java b/jbpm/jbpm-flow-api/src/main/java/org/kie/api/event/usertask/UserTaskCommentEvent.java new file mode 100644 index 00000000000..cae307a17f1 --- /dev/null +++ b/jbpm/jbpm-flow-api/src/main/java/org/kie/api/event/usertask/UserTaskCommentEvent.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.kie.api.event.usertask; + +public interface UserTaskCommentEvent extends UserTaskEvent { + + Comment getOldComment(); + + Comment getNewComment(); + +} diff --git a/jbpm/jbpm-flow-api/src/main/java/org/kie/api/event/usertask/UserTaskDeadlineEvent.java b/jbpm/jbpm-flow-api/src/main/java/org/kie/api/event/usertask/UserTaskDeadlineEvent.java new file mode 100644 index 00000000000..c1c46b7a1d0 --- /dev/null +++ b/jbpm/jbpm-flow-api/src/main/java/org/kie/api/event/usertask/UserTaskDeadlineEvent.java @@ -0,0 +1,56 @@ +/* + * 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.kie.api.event.usertask; + +import java.util.Map; + +import org.kie.api.runtime.process.WorkItem; + +/** + * An event when a dealine for task has expired + */ +public interface UserTaskDeadlineEvent extends UserTaskEvent { + + enum DeadlineType { + Started, + Completed + } + + /** + * Returns work item which timeout expires + * + * @return work item + */ + WorkItem getWorkItem(); + + /** + * Returns notification data + * + * @return key-value pair list + */ + Map getNotification(); + + /** + * Returns dealine type + * + * @return not started or not completed + */ + DeadlineType getType(); +} \ No newline at end of file diff --git a/jbpm/jbpm-flow-api/src/main/java/org/kie/api/event/usertask/UserTaskEvent.java b/jbpm/jbpm-flow-api/src/main/java/org/kie/api/event/usertask/UserTaskEvent.java new file mode 100644 index 00000000000..3c8a8dcacb2 --- /dev/null +++ b/jbpm/jbpm-flow-api/src/main/java/org/kie/api/event/usertask/UserTaskEvent.java @@ -0,0 +1,63 @@ +/* + * 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.kie.api.event.usertask; + +import java.util.Date; + +import org.kie.api.event.KieRuntimeEvent; +import org.kie.api.runtime.process.NodeInstance; +import org.kie.api.runtime.process.ProcessInstance; +import org.kie.api.runtime.process.WorkItem; + +/** + * A runtime event related to the execution of process instances. + */ +public interface UserTaskEvent + extends + KieRuntimeEvent { + + /** + * The ProcessInstance this event relates to. + * + * @return the process instance + */ + ProcessInstance getProcessInstance(); + + NodeInstance getNodeInstance(); + + WorkItem getWorkItem(); + + String getUserTaskId(); + + String getUserTaskDefinitionId(); + + /** + * Returns exact date when the event was created + * + * @return time when event was created + */ + Date getEventDate(); + + /** + * @return associated identity that performed the event + */ + String getEventUser(); + +} diff --git a/jbpm/jbpm-flow-api/src/main/java/org/kie/api/event/usertask/UserTaskStateEvent.java b/jbpm/jbpm-flow-api/src/main/java/org/kie/api/event/usertask/UserTaskStateEvent.java new file mode 100644 index 00000000000..b87d76b6583 --- /dev/null +++ b/jbpm/jbpm-flow-api/src/main/java/org/kie/api/event/usertask/UserTaskStateEvent.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.kie.api.event.usertask; + +public interface UserTaskStateEvent extends UserTaskEvent { + + String getNewStatus(); + + String getOldStatus(); + +} diff --git a/jbpm/jbpm-flow-api/src/main/java/org/kie/api/event/usertask/UserTaskVariableEvent.java b/jbpm/jbpm-flow-api/src/main/java/org/kie/api/event/usertask/UserTaskVariableEvent.java new file mode 100644 index 00000000000..06ed3f67bbc --- /dev/null +++ b/jbpm/jbpm-flow-api/src/main/java/org/kie/api/event/usertask/UserTaskVariableEvent.java @@ -0,0 +1,35 @@ +/* + * 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.kie.api.event.usertask; + +public interface UserTaskVariableEvent extends UserTaskEvent { + + enum VariableEventType { + INPUT, + OUTPUT + } + + String getVariableName(); + + Object getOldValue(); + + Object getNewValue(); + + VariableEventType getVariableType(); +} diff --git a/jbpm/jbpm-flow-api/src/main/java/org/kie/api/fluent/ActionNodeBuilder.java b/jbpm/jbpm-flow-api/src/main/java/org/kie/api/fluent/ActionNodeBuilder.java new file mode 100644 index 00000000000..f233f1fe51c --- /dev/null +++ b/jbpm/jbpm-flow-api/src/main/java/org/kie/api/fluent/ActionNodeBuilder.java @@ -0,0 +1,24 @@ +/** + * 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.kie.api.fluent; + +public interface ActionNodeBuilder> extends NodeBuilder, T> { + + ActionNodeBuilder action(Dialect dialect, String code); +} diff --git a/jbpm/jbpm-flow-api/src/main/java/org/kie/api/fluent/BoundaryEventNodeBuilder.java b/jbpm/jbpm-flow-api/src/main/java/org/kie/api/fluent/BoundaryEventNodeBuilder.java new file mode 100644 index 00000000000..3ff3f2fbbb2 --- /dev/null +++ b/jbpm/jbpm-flow-api/src/main/java/org/kie/api/fluent/BoundaryEventNodeBuilder.java @@ -0,0 +1,34 @@ +/** + * 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.kie.api.fluent; + +public interface BoundaryEventNodeBuilder> extends EventNodeOperations, T>, NodeBuilder, T> { + + BoundaryEventNodeBuilder attachedTo(long attachedToId); + + BoundaryEventNodeBuilder eventType(String prefix, String Suffix); + + BoundaryEventNodeBuilder timeCycle(String timeCycle); + + BoundaryEventNodeBuilder timeCycle(String timeCycle, Dialect dialect); + + BoundaryEventNodeBuilder timeDuration(String timeDuration); + + BoundaryEventNodeBuilder cancelActivity(boolean cancelActivity); +} diff --git a/jbpm/jbpm-flow-api/src/main/java/org/kie/api/fluent/CompositeNodeBuilder.java b/jbpm/jbpm-flow-api/src/main/java/org/kie/api/fluent/CompositeNodeBuilder.java new file mode 100644 index 00000000000..71ac1db37d6 --- /dev/null +++ b/jbpm/jbpm-flow-api/src/main/java/org/kie/api/fluent/CompositeNodeBuilder.java @@ -0,0 +1,22 @@ +/** + * 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.kie.api.fluent; + +public interface CompositeNodeBuilder> extends NodeContainerBuilder, T>, CompositeNodeOperations, T> { +} diff --git a/jbpm/jbpm-flow-api/src/main/java/org/kie/api/fluent/CompositeNodeOperations.java b/jbpm/jbpm-flow-api/src/main/java/org/kie/api/fluent/CompositeNodeOperations.java new file mode 100644 index 00000000000..40ab9a38380 --- /dev/null +++ b/jbpm/jbpm-flow-api/src/main/java/org/kie/api/fluent/CompositeNodeOperations.java @@ -0,0 +1,26 @@ +/** + * 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.kie.api.fluent; + +public interface CompositeNodeOperations, P extends NodeContainerBuilder> { + + T linkIncomingConnections(long nodeId); + + T linkOutgoingConnections(long nodeId); +} diff --git a/jbpm/jbpm-flow-api/src/main/java/org/kie/api/fluent/Dialect.java b/jbpm/jbpm-flow-api/src/main/java/org/kie/api/fluent/Dialect.java new file mode 100644 index 00000000000..558c66f1871 --- /dev/null +++ b/jbpm/jbpm-flow-api/src/main/java/org/kie/api/fluent/Dialect.java @@ -0,0 +1,30 @@ +/** + * 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.kie.api.fluent; + +/** + * Supported programming languages for action scripts + */ +public enum Dialect { + JAVA, + JAVASCRIPT, + XPATH, + MVEL, + FEEL +} diff --git a/jbpm/jbpm-flow-api/src/main/java/org/kie/api/fluent/DynamicNodeBuilder.java b/jbpm/jbpm-flow-api/src/main/java/org/kie/api/fluent/DynamicNodeBuilder.java new file mode 100644 index 00000000000..1e9716e6d18 --- /dev/null +++ b/jbpm/jbpm-flow-api/src/main/java/org/kie/api/fluent/DynamicNodeBuilder.java @@ -0,0 +1,24 @@ +/** + * 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.kie.api.fluent; + +public interface DynamicNodeBuilder> extends NodeContainerBuilder, T>, CompositeNodeOperations, T> { + + DynamicNodeBuilder autoComplete(boolean autoComplete); +} diff --git a/jbpm/jbpm-flow-api/src/main/java/org/kie/api/fluent/EndNodeBuilder.java b/jbpm/jbpm-flow-api/src/main/java/org/kie/api/fluent/EndNodeBuilder.java new file mode 100644 index 00000000000..afddc8ba39c --- /dev/null +++ b/jbpm/jbpm-flow-api/src/main/java/org/kie/api/fluent/EndNodeBuilder.java @@ -0,0 +1,25 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.kie.api.fluent; + +public interface EndNodeBuilder> extends NodeBuilder, T> { + + EndNodeBuilder terminate(boolean terminate); + +} diff --git a/jbpm/jbpm-flow-api/src/main/java/org/kie/api/fluent/EventNodeBuilder.java b/jbpm/jbpm-flow-api/src/main/java/org/kie/api/fluent/EventNodeBuilder.java new file mode 100644 index 00000000000..3e4baebdb96 --- /dev/null +++ b/jbpm/jbpm-flow-api/src/main/java/org/kie/api/fluent/EventNodeBuilder.java @@ -0,0 +1,22 @@ +/** + * 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.kie.api.fluent; + +public interface EventNodeBuilder> extends NodeBuilder, T>, EventNodeOperations, T> { +} diff --git a/jbpm/jbpm-flow-api/src/main/java/org/kie/api/fluent/EventNodeOperations.java b/jbpm/jbpm-flow-api/src/main/java/org/kie/api/fluent/EventNodeOperations.java new file mode 100644 index 00000000000..2b074816ce5 --- /dev/null +++ b/jbpm/jbpm-flow-api/src/main/java/org/kie/api/fluent/EventNodeOperations.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.kie.api.fluent; + +import java.util.function.UnaryOperator; + +interface EventNodeOperations, P extends NodeContainerBuilder> { + + T eventType(String eventType); + + T eventTransformer(UnaryOperator function); + + T scope(String scope); + + T variableName(String name); +} diff --git a/jbpm/jbpm-flow-api/src/main/java/org/kie/api/fluent/FaultNodeBuilder.java b/jbpm/jbpm-flow-api/src/main/java/org/kie/api/fluent/FaultNodeBuilder.java new file mode 100644 index 00000000000..0f3c6e316e6 --- /dev/null +++ b/jbpm/jbpm-flow-api/src/main/java/org/kie/api/fluent/FaultNodeBuilder.java @@ -0,0 +1,26 @@ +/** + * 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.kie.api.fluent; + +public interface FaultNodeBuilder> extends NodeBuilder, T> { + + FaultNodeBuilder setFaultVariable(String faultVariable); + + FaultNodeBuilder setFaultName(String faultName); +} diff --git a/jbpm/jbpm-flow-api/src/main/java/org/kie/api/fluent/ForEachNodeBuilder.java b/jbpm/jbpm-flow-api/src/main/java/org/kie/api/fluent/ForEachNodeBuilder.java new file mode 100644 index 00000000000..7cf14df225b --- /dev/null +++ b/jbpm/jbpm-flow-api/src/main/java/org/kie/api/fluent/ForEachNodeBuilder.java @@ -0,0 +1,26 @@ +/** + * 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.kie.api.fluent; + +public interface ForEachNodeBuilder> extends NodeContainerBuilder, T>, CompositeNodeOperations, T> { + + ForEachNodeBuilder collectionExpression(String collectionExpression); + + ForEachNodeBuilder waitForCompletion(boolean waitForCompletion); +} diff --git a/jbpm/jbpm-flow-api/src/main/java/org/kie/api/fluent/HumanNodeOperations.java b/jbpm/jbpm-flow-api/src/main/java/org/kie/api/fluent/HumanNodeOperations.java new file mode 100644 index 00000000000..ca553a479fb --- /dev/null +++ b/jbpm/jbpm-flow-api/src/main/java/org/kie/api/fluent/HumanNodeOperations.java @@ -0,0 +1,26 @@ +/** + * 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.kie.api.fluent; + +interface HumanNodeOperations, P extends NodeContainerBuilder> extends TimerOperations { + + T onEntryAction(Dialect dialect, String action); + + T onExitAction(Dialect dialect, String action); +} diff --git a/jbpm/jbpm-flow-api/src/main/java/org/kie/api/fluent/HumanTaskNodeBuilder.java b/jbpm/jbpm-flow-api/src/main/java/org/kie/api/fluent/HumanTaskNodeBuilder.java new file mode 100644 index 00000000000..f8c932807b7 --- /dev/null +++ b/jbpm/jbpm-flow-api/src/main/java/org/kie/api/fluent/HumanTaskNodeBuilder.java @@ -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.kie.api.fluent; + +public interface HumanTaskNodeBuilder> extends NodeBuilder, T>, HumanNodeOperations, T> { + + HumanTaskNodeBuilder taskName(String taskName); + + HumanTaskNodeBuilder actorId(String actorId); + + HumanTaskNodeBuilder priority(String priority); + + HumanTaskNodeBuilder comment(String comment); + + HumanTaskNodeBuilder skippable(boolean skippable); + + HumanTaskNodeBuilder content(String content); + + HumanTaskNodeBuilder inMapping(String parameterName, String variableName); + + HumanTaskNodeBuilder outMapping(String parameterName, String variableName); + + HumanTaskNodeBuilder waitForCompletion(boolean waitForCompletion); + + HumanTaskNodeBuilder swimlane(String swimlane); + + HumanTaskNodeBuilder workParameter(String name, Object value); +} diff --git a/jbpm/jbpm-flow-api/src/main/java/org/kie/api/fluent/JoinNodeBuilder.java b/jbpm/jbpm-flow-api/src/main/java/org/kie/api/fluent/JoinNodeBuilder.java new file mode 100644 index 00000000000..4e5162bbc6a --- /dev/null +++ b/jbpm/jbpm-flow-api/src/main/java/org/kie/api/fluent/JoinNodeBuilder.java @@ -0,0 +1,26 @@ +/** + * 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.kie.api.fluent; + +public interface JoinNodeBuilder> extends NodeBuilder, T> { + + JoinNodeBuilder type(int type); + + JoinNodeBuilder type(String type); +} diff --git a/jbpm/jbpm-flow-api/src/main/java/org/kie/api/fluent/MilestoneNodeBuilder.java b/jbpm/jbpm-flow-api/src/main/java/org/kie/api/fluent/MilestoneNodeBuilder.java new file mode 100644 index 00000000000..06dd6eabb2b --- /dev/null +++ b/jbpm/jbpm-flow-api/src/main/java/org/kie/api/fluent/MilestoneNodeBuilder.java @@ -0,0 +1,24 @@ +/** + * 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.kie.api.fluent; + +public interface MilestoneNodeBuilder> extends NodeBuilder, T>, HumanNodeOperations, T> { + + MilestoneNodeBuilder constraint(String constraint); +} diff --git a/jbpm/jbpm-flow-api/src/main/java/org/kie/api/fluent/NodeBuilder.java b/jbpm/jbpm-flow-api/src/main/java/org/kie/api/fluent/NodeBuilder.java new file mode 100644 index 00000000000..30e8e81a79e --- /dev/null +++ b/jbpm/jbpm-flow-api/src/main/java/org/kie/api/fluent/NodeBuilder.java @@ -0,0 +1,39 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.kie.api.fluent; + +/** + * Contains common operations for all nodes, basically naming, metadata and definition completion. + * + * @param concrete node instance + * @param

container parent node + */ +public interface NodeBuilder, P extends NodeContainerBuilder> { + + /** + * Method to notify that definition of this node is done + * + * @return container parent node + */ + P done(); + + T name(String name); + + T setMetadata(String key, Object value); +} diff --git a/jbpm/jbpm-flow-api/src/main/java/org/kie/api/fluent/NodeContainerBuilder.java b/jbpm/jbpm-flow-api/src/main/java/org/kie/api/fluent/NodeContainerBuilder.java new file mode 100644 index 00000000000..29e54f5f73a --- /dev/null +++ b/jbpm/jbpm-flow-api/src/main/java/org/kie/api/fluent/NodeContainerBuilder.java @@ -0,0 +1,73 @@ +/** + * 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.kie.api.fluent; + +/** + * Include operations to define a container node.
+ * As it name indicates, a container node contains nodes (a process is also a container node), so this class defines all methods to create children nodes.
+ * A container node also holds variables, exception handlers and establish connections between nodes. + * + * @param Concrete container node + * @param

Parent container node + */ +public interface NodeContainerBuilder, P extends NodeContainerBuilder> extends NodeBuilder { + + StartNodeBuilder startNode(long id); + + EndNodeBuilder endNode(long id); + + ActionNodeBuilder actionNode(long id); + + MilestoneNodeBuilder milestoneNode(long id); + + TimerNodeBuilder timerNode(long id); + + HumanTaskNodeBuilder humanTaskNode(long id); + + SubProcessNodeBuilder subProcessNode(long id); + + SplitNodeBuilder splitNode(long id); + + JoinNodeBuilder joinNode(long id); + + RuleSetNodeBuilder ruleSetNode(long id); + + FaultNodeBuilder faultNode(long id); + + EventNodeBuilder eventNode(long id); + + BoundaryEventNodeBuilder boundaryEventNode(long id); + + CompositeNodeBuilder compositeNode(long id); + + ForEachNodeBuilder forEachNode(long id); + + DynamicNodeBuilder dynamicNode(long id); + + WorkItemNodeBuilder workItemNode(long id); + + T exceptionHandler(Class exceptionClass, Dialect dialect, String code); + + T connection(long fromId, long toId); + + /** + * Adds a variable to this container + */ + T variable(Variable variable); +} diff --git a/jbpm/jbpm-flow-api/src/main/java/org/kie/api/fluent/ProcessBuilder.java b/jbpm/jbpm-flow-api/src/main/java/org/kie/api/fluent/ProcessBuilder.java new file mode 100644 index 00000000000..09fc9fc0c91 --- /dev/null +++ b/jbpm/jbpm-flow-api/src/main/java/org/kie/api/fluent/ProcessBuilder.java @@ -0,0 +1,56 @@ +/** + * 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.kie.api.fluent; + +import java.util.Collection; +import java.util.Map; + +import org.kie.api.definition.process.Process; + +/** + * Builder that contains methods to create a process definition. + * + * @see ProcessBuilderFactory + */ +public interface ProcessBuilder extends NodeContainerBuilder { + + ProcessBuilder dynamic(boolean dynamic); + + ProcessBuilder version(String version); + + ProcessBuilder packageName(String packageName); + + ProcessBuilder imports(Collection imports); + + ProcessBuilder functionImports(Collection functionImports); + + ProcessBuilder globals(Map globals); + + ProcessBuilder global(String name, String type); + + ProcessBuilder swimlane(String name); + + /** + * Validates and returns process definition.
+ * Should be invoked after all other method calls. + * + * @return validated process definition + */ + Process build(); +} diff --git a/jbpm/jbpm-flow-api/src/main/java/org/kie/api/fluent/ProcessBuilderFactories.java b/jbpm/jbpm-flow-api/src/main/java/org/kie/api/fluent/ProcessBuilderFactories.java new file mode 100644 index 00000000000..9cecb1226a7 --- /dev/null +++ b/jbpm/jbpm-flow-api/src/main/java/org/kie/api/fluent/ProcessBuilderFactories.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.kie.api.fluent; + +import org.slf4j.LoggerFactory; + +/** + * Holds an utility method to retrieve ProcessBuilderFactory default instance.
+ * Default instance returned by get method can be modified by setting property "org.jbpm.processBuilder.factoryClass"
+ * Value should be full class name of a ProcessBuilderFactory implementation that contains a default public constructor + */ +public class ProcessBuilderFactories { + + private ProcessBuilderFactories() { + } + + private static ProcessBuilderFactory instance; + + public static synchronized ProcessBuilderFactory get() { + if (instance == null) { + try { + instance = + Class.forName(System.getProperty("org.jbpm.processBuilder.factoryClass", + "org.jbpm.ruleflow.core.RuleFlowProcessFactoryBuilder")) + .asSubclass(ProcessBuilderFactory.class) + .newInstance(); + } catch (ReflectiveOperationException e) { + LoggerFactory.getLogger(ProcessBuilderFactories.class).error("Unable to instance ProcessBuilderFactory", e); + throw new IllegalStateException(e); + } + } + return instance; + } +} diff --git a/jbpm/jbpm-flow-api/src/main/java/org/kie/api/fluent/ProcessBuilderFactory.java b/jbpm/jbpm-flow-api/src/main/java/org/kie/api/fluent/ProcessBuilderFactory.java new file mode 100644 index 00000000000..acaeaba9166 --- /dev/null +++ b/jbpm/jbpm-flow-api/src/main/java/org/kie/api/fluent/ProcessBuilderFactory.java @@ -0,0 +1,45 @@ +/** + * 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.kie.api.fluent; + +import org.kie.api.definition.process.Process; + +/** + * Factory to create process builder instance.
+ * It is also a convenient place holder for additional utility methods + */ +public interface ProcessBuilderFactory { + + /** + * Returns a ProcessBuilder that can be used to create a process definition + * + * @param processId the unique id of the process being defined + * @return builder instance to create process definition + */ + ProcessBuilder processBuilder(String processId); + + /** + * Converts process definition into an array of bytes.
+ * Typically this array will be converted to a Resource for a KIE base + * + * @param builder process definition to be converted to byte[] + * @return byte[] containing process definition + */ + byte[] toBytes(Process builder); +} diff --git a/jbpm/jbpm-flow-api/src/main/java/org/kie/api/fluent/RuleSetNodeBuilder.java b/jbpm/jbpm-flow-api/src/main/java/org/kie/api/fluent/RuleSetNodeBuilder.java new file mode 100644 index 00000000000..ce54d461dc8 --- /dev/null +++ b/jbpm/jbpm-flow-api/src/main/java/org/kie/api/fluent/RuleSetNodeBuilder.java @@ -0,0 +1,24 @@ +/** + * 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.kie.api.fluent; + +public interface RuleSetNodeBuilder> extends NodeBuilder, T>, TimerOperations, T> { + + RuleSetNodeBuilder ruleFlowGroup(String ruleFlowGroup); +} diff --git a/jbpm/jbpm-flow-api/src/main/java/org/kie/api/fluent/SplitNodeBuilder.java b/jbpm/jbpm-flow-api/src/main/java/org/kie/api/fluent/SplitNodeBuilder.java new file mode 100644 index 00000000000..0b75e496eba --- /dev/null +++ b/jbpm/jbpm-flow-api/src/main/java/org/kie/api/fluent/SplitNodeBuilder.java @@ -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.kie.api.fluent; + +public interface SplitNodeBuilder> extends NodeBuilder, T> { + + SplitNodeBuilder type(int type); + + SplitNodeBuilder constraint(long toNodeId, String name, String type, Dialect dialect, String constraint, int priority); + +} diff --git a/jbpm/jbpm-flow-api/src/main/java/org/kie/api/fluent/StartNodeBuilder.java b/jbpm/jbpm-flow-api/src/main/java/org/kie/api/fluent/StartNodeBuilder.java new file mode 100644 index 00000000000..a4c629516fc --- /dev/null +++ b/jbpm/jbpm-flow-api/src/main/java/org/kie/api/fluent/StartNodeBuilder.java @@ -0,0 +1,23 @@ +/** + * 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.kie.api.fluent; + +public interface StartNodeBuilder> extends NodeBuilder, T> { + // TODO event triggers? +} diff --git a/jbpm/jbpm-flow-api/src/main/java/org/kie/api/fluent/SubProcessNodeBuilder.java b/jbpm/jbpm-flow-api/src/main/java/org/kie/api/fluent/SubProcessNodeBuilder.java new file mode 100644 index 00000000000..3311e709b33 --- /dev/null +++ b/jbpm/jbpm-flow-api/src/main/java/org/kie/api/fluent/SubProcessNodeBuilder.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.kie.api.fluent; + +public interface SubProcessNodeBuilder> extends NodeBuilder, T>, HumanNodeOperations, T> { + + SubProcessNodeBuilder processId(final String processId); + + SubProcessNodeBuilder waitForCompletion(boolean waitForCompletion); + + SubProcessNodeBuilder inMapping(String parameterName, String variableName); + + SubProcessNodeBuilder outMapping(String parameterName, String variableName); + + SubProcessNodeBuilder independent(boolean independent); + +} diff --git a/jbpm/jbpm-flow-api/src/main/java/org/kie/api/fluent/TimerNodeBuilder.java b/jbpm/jbpm-flow-api/src/main/java/org/kie/api/fluent/TimerNodeBuilder.java new file mode 100644 index 00000000000..9999c288df6 --- /dev/null +++ b/jbpm/jbpm-flow-api/src/main/java/org/kie/api/fluent/TimerNodeBuilder.java @@ -0,0 +1,26 @@ +/** + * 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.kie.api.fluent; + +public interface TimerNodeBuilder> extends NodeBuilder, T> { + + TimerNodeBuilder delay(String delay); + + TimerNodeBuilder period(String period); +} diff --git a/jbpm/jbpm-flow-api/src/main/java/org/kie/api/fluent/TimerOperations.java b/jbpm/jbpm-flow-api/src/main/java/org/kie/api/fluent/TimerOperations.java new file mode 100644 index 00000000000..5711e62e9b0 --- /dev/null +++ b/jbpm/jbpm-flow-api/src/main/java/org/kie/api/fluent/TimerOperations.java @@ -0,0 +1,24 @@ +/** + * 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.kie.api.fluent; + +interface TimerOperations, P extends NodeContainerBuilder> { + + T timer(String delay, String period, Dialect dialect, String action); +} diff --git a/jbpm/jbpm-flow-api/src/main/java/org/kie/api/fluent/Variable.java b/jbpm/jbpm-flow-api/src/main/java/org/kie/api/fluent/Variable.java new file mode 100644 index 00000000000..61c1dbd5c93 --- /dev/null +++ b/jbpm/jbpm-flow-api/src/main/java/org/kie/api/fluent/Variable.java @@ -0,0 +1,89 @@ +/** + * 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.kie.api.fluent; + +import java.util.HashMap; +import java.util.Map; + +/** + * Builder pattern like class used to build a variable.
+ * A variable requires a name and a data type.
+ * Value and metadata are optional.
+ * Usage: + * + *

+ *  Variable.var("test",String.class)
+ *          .value("example value")
+ *          .metadata("readOnly",true).
+ *          .metadata("required",false)
+ * 
+ * + * @param data type of the variable + * @see NodeContainerBuilder#variable(Variable) + */ +public class Variable { + + private String name; + private T value; + private Class type; + private Map metadata; + + private Variable(String name, Class type) { + this.name = name; + this.type = type; + } + + public static Variable var(String name, Class type) { + return new Variable<>(name, type); + } + + public Variable value(T value) { + this.value = value; + return this; + } + + public Variable metadata(String key, Object value) { + if (metadata == null) { + metadata = new HashMap<>(); + } + metadata.put(key, value); + return this; + } + + public String getName() { + return name; + } + + public T getValue() { + return value; + } + + public Class getType() { + return type; + } + + public Map getMetadata() { + return metadata; + } + + @Override + public String toString() { + return "Variable [name=" + name + ", value=" + value + ", type=" + type + ", metadata=" + metadata + "]"; + } +} diff --git a/jbpm/jbpm-flow-api/src/main/java/org/kie/api/fluent/WorkItemNodeBuilder.java b/jbpm/jbpm-flow-api/src/main/java/org/kie/api/fluent/WorkItemNodeBuilder.java new file mode 100644 index 00000000000..c3e92ff5a8f --- /dev/null +++ b/jbpm/jbpm-flow-api/src/main/java/org/kie/api/fluent/WorkItemNodeBuilder.java @@ -0,0 +1,34 @@ +/** + * 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.kie.api.fluent; + +public interface WorkItemNodeBuilder> extends NodeBuilder, T>, HumanNodeOperations, T> { + + WorkItemNodeBuilder waitForCompletion(boolean waitForCompletion); + + WorkItemNodeBuilder inMapping(String parameterName, String variableName); + + WorkItemNodeBuilder outMapping(String parameterName, String variableName); + + WorkItemNodeBuilder workName(String name); + + WorkItemNodeBuilder workParameter(String name, Object value); + + WorkItemNodeBuilder workParameterDefinition(String name, Class type); +} diff --git a/jbpm/jbpm-flow-api/src/main/java/org/kie/api/fluent/package-info.java b/jbpm/jbpm-flow-api/src/main/java/org/kie/api/fluent/package-info.java new file mode 100644 index 00000000000..ef6b68e86ee --- /dev/null +++ b/jbpm/jbpm-flow-api/src/main/java/org/kie/api/fluent/package-info.java @@ -0,0 +1,90 @@ +/** + * 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. + */ +/** + * Process Fluent API allows programmer to build an in memory representation of a bpmn file.
+ * This information can later be used to build a KIE resource and execute the process . + * Typical use of fluent API will be: + *
  • Build a process definition that prints action string in console using ProcessBuilder several methods
  • + * + *
    + * // Obtain default ProcessBuilderFactory
    + * ProcessBuilderFactory factory = ProcessBuilderFactories.get();
    + * ProcessBuilderFactory factory = ProcessBuilderFactories.get();
    + * Process process =
    + *         // Create process builder
    + *         factory.processBuilder(processId)
    + *                 // package and name 
    + *                 .packageName("org.jbpm")
    + *                 .name("My process")
    + *                 // start node
    + *                 .startNode(1).name("Start").done()
    + *                 // Add variable of type string
    + *                 .variable(var("pepe", String.class))
    + *                 // Add exception handler
    + *                 .exceptionHandler(IllegalArgumentException.class, Dialect.JAVA, "System.out.println(\"Exception\");")
    + *                 // script node in Java language that prints "action"
    + *                 .actionNode(2).name("Action")
    + *                 .action(Dialect.JAVA,
    + *                         "System.out.println(\"Action\");")
    + *                 .done()
    + *                 // end node
    + *                 .endNode(3).name("End").done()
    + *                 // connections
    + *                 .connection(1,
    + *                         2)
    + *                 .connection(2,
    + *                         3)
    + *                 .build();
    + * 
    + * + *
  • Create a resource from the process definition (process needs to be converted to byte[] using ProcessBuilderFactory)
  • + * + *
    + * // Build resource from ProcessBuilder
    + * KieResources resources = ServiceRegistry.getInstance().get(KieResources.class);
    + * Resource res = resources
    + *         .newByteArrayResource(factory.toBytes(process))
    + *         .setSourcePath("/tmp/processFactory.bpmn2"); // source path or target path must be set to be added into kbase
    + * 
    + * + *
  • Build kie base from this resource using KIE API
  • + * + *
    + * KieServices ks = KieServices.Factory.get();
    + * KieRepository kr = ks.getRepository();
    + * KieFileSystem kfs = ks.newKieFileSystem();
    + * kfs.write(res);
    + * KieBuilder kb = ks.newKieBuilder(kfs);
    + * kb.buildAll(); // kieModule is automatically deployed to KieRepository if successfully built.
    + * KieContainer kContainer = ks.newKieContainer(kr.getDefaultReleaseId());
    + * KieBase kbase = kContainer.getKieBase();
    + * 
    + * + *
  • Create kie session using this kie base and execute the process
  • + * + *
    +        // Create kie session
    +        KieSessionConfiguration conf = ...;
    +        Environment env = ....; 
    +        KieSession ksession = kbase.newKieSession(conf,env);
    +        // execute process using same process id that was used to obtain ProcessBuilder instance
    +        ksession.startProcess(processId);
    + * 
    + */ +package org.kie.api.fluent; diff --git a/jbpm/jbpm-flow-api/src/main/java/org/kie/api/runtime/process/DataTransformer.java b/jbpm/jbpm-flow-api/src/main/java/org/kie/api/runtime/process/DataTransformer.java new file mode 100644 index 00000000000..6f71e2d80fe --- /dev/null +++ b/jbpm/jbpm-flow-api/src/main/java/org/kie/api/runtime/process/DataTransformer.java @@ -0,0 +1,55 @@ +/** + * 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.kie.api.runtime.process; + +import java.util.Map; + +/** + * Data transformation capabilities used by data input and data output transformation + * as part of BPMN2 process definition. It allows plugable implementations. + * + */ +public interface DataTransformer { + + /** + * Compiles given expression into reusable unit. This is optional operation and in case + * it's not supported by given transformed it should return the same expression that was + * given in the input. If compilation is supported a compiled instance of the expression + * should be returned. + * + * @param expression language specific expression + * @param parameters parameters e.g. imports defined in the process + * @return compiled expression instance or same as given as argument expression + * @throws RuntimeException in case of unexpected errors during compilation + */ + public Object compile(String expression, Map parameters); + + /** + * Transforms the given expression object (might be compiled expression) using + * parameters as contextual information (aka bindings) used during + * evaluation of the expression. + * + * @param expression expression to evaluate + * @param parameters binding parameters + * @return result of the evaluation + * @throws RuntimeException in case of unexpected errors during evaluation of the expression + */ + public Object transform(Object expression, Map parameters); + +} diff --git a/jbpm/jbpm-flow-api/src/main/java/org/kie/api/runtime/process/ProcessWorkItemHandlerException.java b/jbpm/jbpm-flow-api/src/main/java/org/kie/api/runtime/process/ProcessWorkItemHandlerException.java new file mode 100644 index 00000000000..9c10c374d9b --- /dev/null +++ b/jbpm/jbpm-flow-api/src/main/java/org/kie/api/runtime/process/ProcessWorkItemHandlerException.java @@ -0,0 +1,75 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.kie.api.runtime.process; + +public class ProcessWorkItemHandlerException extends RuntimeException { + + private static final long serialVersionUID = 328927887939759492L; + + private static final int MAX_NUMBER_OF_RETRIES = 3; + + public enum HandlingStrategy { + RETRY, + COMPLETE, + ABORT, + RETHROW + } + + private String processId; + private HandlingStrategy strategy; + private int retries; + + public ProcessWorkItemHandlerException(String processId, String strategy, Throwable cause) { + this(processId, HandlingStrategy.valueOf(strategy), cause, MAX_NUMBER_OF_RETRIES); + } + + public ProcessWorkItemHandlerException(String processId, String strategy, Throwable cause, int retries) { + this(processId, HandlingStrategy.valueOf(strategy), cause, retries); + } + + public ProcessWorkItemHandlerException(String processId, HandlingStrategy strategy, Throwable cause) { + this(processId, strategy, cause, MAX_NUMBER_OF_RETRIES); + } + + public ProcessWorkItemHandlerException(String processId, HandlingStrategy strategy, Throwable cause, int retries) { + super(cause); + this.processId = processId; + this.strategy = strategy; + this.retries = retries; + if (processId == null || strategy == null) { + throw new IllegalArgumentException("Process id and strategy are required"); + } + if (retries < 0) { + throw new IllegalArgumentException("Retries cannot be negative"); + } + } + + public String getProcessId() { + return processId; + } + + public HandlingStrategy getStrategy() { + return strategy; + } + + public int getRetries() { + return retries; + } + +} diff --git a/jbpm/jbpm-flow/pom.xml b/jbpm/jbpm-flow/pom.xml index d0fc15edb26..0c63fafcb38 100755 --- a/jbpm/jbpm-flow/pom.xml +++ b/jbpm/jbpm-flow/pom.xml @@ -49,10 +49,21 @@ pom import + + org.kie.kogito + kogito-bom + ${project.version} + pom + import + + + org.kie.kogito + jbpm-flow-api + org.kie.kogito kogito-api diff --git a/jbpm/jbpm-flow/src/main/java/org/jbpm/process/instance/command/GetProcessInstanceVariableCommand.java b/jbpm/jbpm-flow/src/main/java/org/jbpm/process/instance/command/GetProcessInstanceVariableCommand.java deleted file mode 100755 index 9db510c92f9..00000000000 --- a/jbpm/jbpm-flow/src/main/java/org/jbpm/process/instance/command/GetProcessInstanceVariableCommand.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jbpm.process.instance.command; - -import org.kie.api.command.ExecutableCommand; -import org.kie.api.runtime.Context; -import org.kie.api.runtime.KieSession; -import org.kie.internal.command.RegistryContext; -import org.kie.kogito.internal.process.runtime.KogitoProcessInstance; -import org.kie.kogito.internal.process.runtime.KogitoProcessRuntime; -import org.kie.kogito.internal.process.runtime.KogitoWorkflowProcessInstance; - -import jakarta.xml.bind.annotation.XmlAccessType; -import jakarta.xml.bind.annotation.XmlAccessorType; -import jakarta.xml.bind.annotation.XmlAttribute; -import jakarta.xml.bind.annotation.XmlSchemaType; - -@XmlAccessorType(XmlAccessType.NONE) -public class GetProcessInstanceVariableCommand implements ExecutableCommand, KogitoProcessInstanceIdCommand { - - private static final long serialVersionUID = 6L; - - @XmlAttribute(required = true) - @XmlSchemaType(name = "string") - private String processInstanceId; - - @XmlAttribute(required = true) - @XmlSchemaType(name = "string") - private String variableId; - - @Override - public String getProcessInstanceId() { - return processInstanceId; - } - - @Override - public void setProcessInstanceId(String processInstanceId) { - this.processInstanceId = processInstanceId; - } - - public String getVariableId() { - return variableId; - } - - public void setVariableId(String variableId) { - this.variableId = variableId; - } - - public Object execute(Context context) { - KogitoProcessRuntime runtime = (KogitoProcessRuntime) ((RegistryContext) context).lookup(KieSession.class); - if (processInstanceId == null) { - return null; - } - KogitoProcessInstance processInstance = runtime.getProcessInstance(processInstanceId); - if (processInstance == null) { - throw new IllegalArgumentException("Could not find process instance for id " + processInstanceId); - } - if (processInstance instanceof KogitoWorkflowProcessInstance) { - return ((KogitoWorkflowProcessInstance) processInstance).getVariable(variableId); - } else { - throw new IllegalStateException("Could not retrieve variable " + variableId - + " because process instance " + processInstanceId + " was inaccessible!"); - } - } - - public String toString() { - return "session.getProcessInstanceVariable(" + processInstanceId + ", " + variableId + ");"; - } - -} diff --git a/jbpm/jbpm-flow/src/main/java/org/jbpm/process/instance/command/MigrateProcessInstanceCommand.java b/jbpm/jbpm-flow/src/main/java/org/jbpm/process/instance/command/MigrateProcessInstanceCommand.java deleted file mode 100755 index ca6b47a19eb..00000000000 --- a/jbpm/jbpm-flow/src/main/java/org/jbpm/process/instance/command/MigrateProcessInstanceCommand.java +++ /dev/null @@ -1,148 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jbpm.process.instance.command; - -import java.util.HashMap; -import java.util.Map; - -import org.drools.core.common.InternalKnowledgeRuntime; -import org.jbpm.workflow.core.impl.NodeImpl; -import org.jbpm.workflow.instance.NodeInstanceContainer; -import org.jbpm.workflow.instance.impl.NodeInstanceImpl; -import org.jbpm.workflow.instance.impl.WorkflowProcessInstanceImpl; -import org.kie.api.command.ExecutableCommand; -import org.kie.api.definition.process.WorkflowElementIdentifier; -import org.kie.api.definition.process.WorkflowProcess; -import org.kie.api.runtime.Context; -import org.kie.api.runtime.KieSession; -import org.kie.api.runtime.process.NodeInstance; -import org.kie.internal.command.RegistryContext; -import org.kie.kogito.internal.process.runtime.KogitoProcessRuntime; - -import jakarta.xml.bind.annotation.XmlAccessType; -import jakarta.xml.bind.annotation.XmlAccessorType; -import jakarta.xml.bind.annotation.XmlElement; -import jakarta.xml.bind.annotation.XmlRootElement; -import jakarta.xml.bind.annotation.XmlSchemaType; - -@XmlRootElement(name = "get-completed-tasks-command") -@XmlAccessorType(XmlAccessType.NONE) -public class MigrateProcessInstanceCommand implements ExecutableCommand, KogitoProcessInstanceIdCommand { - - private static final long serialVersionUID = 6L; - - @XmlElement - @XmlSchemaType(name = "string") - private String processInstanceId; - - @XmlElement - @XmlSchemaType(name = "string") - private String processId; - - @XmlElement - private Map nodeMapping; - - public MigrateProcessInstanceCommand(String processInstanceId, String processId) { - this.processInstanceId = processInstanceId; - this.processId = processId; - } - - public MigrateProcessInstanceCommand(String processInstanceId, String processId, Map nodeMapping) { - this.processInstanceId = processInstanceId; - this.processId = processId; - this.nodeMapping = nodeMapping; - } - - @Override - public String getProcessInstanceId() { - return processInstanceId; - } - - @Override - public void setProcessInstanceId(String processInstanceId) { - this.processInstanceId = processInstanceId; - } - - public String getProcessId() { - return processId; - } - - public void setProcessId(String processId) { - this.processId = processId; - } - - public Map getNodeMapping() { - return nodeMapping; - } - - public void setNodeMapping(Map nodeMapping) { - this.nodeMapping = nodeMapping; - } - - public Void execute(Context context) { - KogitoProcessRuntime runtime = (KogitoProcessRuntime) ((RegistryContext) context).lookup(KieSession.class); - WorkflowProcessInstanceImpl processInstance = (WorkflowProcessInstanceImpl) runtime.getProcessInstance(processInstanceId); - if (processInstance == null) { - throw new IllegalArgumentException("Could not find process instance " + processInstanceId); - } - if (processId == null) { - throw new IllegalArgumentException("Null process id"); - } - - WorkflowProcess process = (WorkflowProcess) runtime.getKieBase().getProcess(processId); - if (process == null) { - throw new IllegalArgumentException("Could not find process " + processId); - } - if (processInstance.getProcessId().equals(processId)) { - return null; - } - synchronized (processInstance) { - org.kie.api.definition.process.Process oldProcess = processInstance.getProcess(); - processInstance.disconnect(); - processInstance.setProcess(oldProcess); - if (nodeMapping == null) { - nodeMapping = new HashMap<>(); - } - updateNodeInstances(processInstance, nodeMapping); - processInstance.setKnowledgeRuntime((InternalKnowledgeRuntime) runtime); - processInstance.setProcess(process); - processInstance.reconnect(); - } - return null; - } - - private void updateNodeInstances(NodeInstanceContainer nodeInstanceContainer, Map nodeMapping) { - for (NodeInstance nodeInstance : nodeInstanceContainer.getNodeInstances()) { - WorkflowElementIdentifier oldNodeId = ((NodeImpl) ((org.jbpm.workflow.instance.NodeInstance) nodeInstance).getNode()).getId(); - WorkflowElementIdentifier newNodeId = nodeMapping.get(oldNodeId); - if (newNodeId == null) { - newNodeId = nodeInstance.getNodeId(); - } - ((NodeInstanceImpl) nodeInstance).setNodeId(newNodeId); - if (nodeInstance instanceof NodeInstanceContainer) { - updateNodeInstances((NodeInstanceContainer) nodeInstance, nodeMapping); - } - } - } - - public String toString() { - return "migrateProcessInstance(" + processInstanceId + ", \"" + processId + "\");"; - } - -} diff --git a/jbpm/jbpm-flow/src/main/java/org/jbpm/process/instance/command/ResumeProcessInstanceCommand.java b/jbpm/jbpm-flow/src/main/java/org/jbpm/process/instance/command/ResumeProcessInstanceCommand.java deleted file mode 100755 index 7e737c3f8e3..00000000000 --- a/jbpm/jbpm-flow/src/main/java/org/jbpm/process/instance/command/ResumeProcessInstanceCommand.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jbpm.process.instance.command; - -import org.kie.api.command.ExecutableCommand; -import org.kie.api.runtime.Context; -import org.kie.api.runtime.KieSession; -import org.kie.internal.command.RegistryContext; -import org.kie.kogito.internal.process.runtime.KogitoProcessInstance; -import org.kie.kogito.internal.process.runtime.KogitoProcessRuntime; - -import jakarta.xml.bind.annotation.XmlAccessType; -import jakarta.xml.bind.annotation.XmlAccessorType; -import jakarta.xml.bind.annotation.XmlAttribute; -import jakarta.xml.bind.annotation.XmlRootElement; -import jakarta.xml.bind.annotation.XmlSchemaType; - -@XmlRootElement(name = "get-completed-tasks-command") -@XmlAccessorType(XmlAccessType.NONE) -public class ResumeProcessInstanceCommand implements ExecutableCommand, KogitoProcessInstanceIdCommand { - - /** Generated serial version UID */ - private static final long serialVersionUID = 3153292964867981793L; - - @XmlAttribute - @XmlSchemaType(name = "string") - private String processInstanceId; - - @Override - public String getProcessInstanceId() { - return processInstanceId; - } - - @Override - public void setProcessInstanceId(String processInstanceId) { - this.processInstanceId = processInstanceId; - } - - public Object execute(Context context) { - KogitoProcessRuntime runtime = (KogitoProcessRuntime) ((RegistryContext) context).lookup(KieSession.class); - if (processInstanceId == null) { - return null; - } - KogitoProcessInstance processInstance = runtime.getProcessInstance(processInstanceId); - if (processInstance == null) { - throw new IllegalArgumentException("Could not find process instance for id " + processInstanceId); - } - if (processInstance.getState() != KogitoProcessInstance.STATE_SUSPENDED) { - throw new IllegalArgumentException("Process instance with id " + processInstanceId + " in state " + processInstance.getState()); - } - ((org.jbpm.process.instance.ProcessInstance) processInstance).setState(KogitoProcessInstance.STATE_ACTIVE); - return null; - } - - public String toString() { - return "session.abortProcessInstance(" + processInstanceId + ");"; - } - -} diff --git a/jbpm/jbpm-flow/src/main/java/org/jbpm/process/instance/command/SuspendProcessInstanceCommand.java b/jbpm/jbpm-flow/src/main/java/org/jbpm/process/instance/command/SuspendProcessInstanceCommand.java deleted file mode 100755 index 40217c3c9f2..00000000000 --- a/jbpm/jbpm-flow/src/main/java/org/jbpm/process/instance/command/SuspendProcessInstanceCommand.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jbpm.process.instance.command; - -import org.kie.api.command.ExecutableCommand; -import org.kie.api.runtime.Context; -import org.kie.api.runtime.KieSession; -import org.kie.internal.command.RegistryContext; -import org.kie.kogito.internal.process.runtime.KogitoProcessInstance; -import org.kie.kogito.internal.process.runtime.KogitoProcessRuntime; - -import jakarta.xml.bind.annotation.XmlAccessType; -import jakarta.xml.bind.annotation.XmlAccessorType; -import jakarta.xml.bind.annotation.XmlAttribute; -import jakarta.xml.bind.annotation.XmlRootElement; -import jakarta.xml.bind.annotation.XmlSchemaType; - -@XmlRootElement(name = "suspend-process-instance-command") -@XmlAccessorType(XmlAccessType.NONE) -public class SuspendProcessInstanceCommand implements ExecutableCommand, KogitoProcessInstanceIdCommand { - - /** Generated serial version UID */ - private static final long serialVersionUID = 5824052805419980114L; - - @XmlAttribute - @XmlSchemaType(name = "string") - private String processInstanceId; - - @Override - public String getProcessInstanceId() { - return processInstanceId; - } - - @Override - public void setProcessInstanceId(String processInstanceId) { - this.processInstanceId = processInstanceId; - } - - public Object execute(Context context) { - KogitoProcessRuntime runtime = (KogitoProcessRuntime) ((RegistryContext) context).lookup(KieSession.class); - if (processInstanceId == null) { - return null; - } - KogitoProcessInstance processInstance = runtime.getProcessInstance(processInstanceId); - if (processInstance == null) { - throw new IllegalArgumentException("Could not find process instance for id " + processInstanceId); - } - if (processInstance.getState() != KogitoProcessInstance.STATE_ACTIVE) { - throw new IllegalArgumentException("Process instance with id " + processInstanceId + " in state " + processInstance.getState()); - } - ((org.jbpm.process.instance.ProcessInstance) processInstance).setState(KogitoProcessInstance.STATE_SUSPENDED); - return null; - } - - public String toString() { - return "session.abortProcessInstance(" + processInstanceId + ");"; - } - -} diff --git a/jbpm/jbpm-flow/src/main/java/org/jbpm/process/instance/command/UpdateProcessCommand.java b/jbpm/jbpm-flow/src/main/java/org/jbpm/process/instance/command/UpdateProcessCommand.java deleted file mode 100755 index 7aa140a0aac..00000000000 --- a/jbpm/jbpm-flow/src/main/java/org/jbpm/process/instance/command/UpdateProcessCommand.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jbpm.process.instance.command; - -import org.jbpm.process.instance.impl.ProcessInstanceImpl; -import org.kie.api.command.ExecutableCommand; -import org.kie.api.runtime.Context; -import org.kie.api.runtime.KieSession; -import org.kie.internal.command.RegistryContext; -import org.kie.kogito.internal.process.runtime.KogitoProcessRuntime; - -import jakarta.xml.bind.annotation.XmlAccessType; -import jakarta.xml.bind.annotation.XmlAccessorType; -import jakarta.xml.bind.annotation.XmlElement; -import jakarta.xml.bind.annotation.XmlRootElement; -import jakarta.xml.bind.annotation.XmlSchemaType; - -@XmlRootElement(name = "update-process-command") -@XmlAccessorType(XmlAccessType.NONE) -public class UpdateProcessCommand implements ExecutableCommand, KogitoProcessInstanceIdCommand { - - private static final long serialVersionUID = 6L; - - @XmlElement - @XmlSchemaType(name = "string") - private String processInstanceId; - - @XmlElement - @XmlSchemaType(name = "string") - private String processXml; - - public UpdateProcessCommand(String processInstanceId, String processXml) { - this.processInstanceId = processInstanceId; - this.processXml = processXml; - } - - @Override - public String getProcessInstanceId() { - return processInstanceId; - } - - @Override - public void setProcessInstanceId(String processInstanceId) { - this.processInstanceId = processInstanceId; - } - - public String getProcessXml() { - return processXml; - } - - public void setProcessXml(String processXml) { - this.processXml = processXml; - } - - public Void execute(Context context) { - KogitoProcessRuntime runtime = (KogitoProcessRuntime) ((RegistryContext) context).lookup(KieSession.class); - ProcessInstanceImpl processInstance = (ProcessInstanceImpl) runtime.getProcessInstance(processInstanceId); - if (processInstance != null) { - processInstance.setProcessXml(processXml); - } - return null; - } - - public String toString() { - return "((ProcessInstanceImpl) ksession.getProcessInstance(" - + processInstanceId + ")).setProcessXml(" + processXml + ");"; - } -} diff --git a/jbpm/pom.xml b/jbpm/pom.xml index 5925fbe239f..b7e233e11d5 100755 --- a/jbpm/pom.xml +++ b/jbpm/pom.xml @@ -38,6 +38,7 @@ http://www.jbpm.org + jbpm-flow-api jbpm-flow jbpm-flow-builder jbpm-bpmn2 diff --git a/kogito-bom/pom.xml b/kogito-bom/pom.xml index 61ce872c187..ec1009e51c0 100755 --- a/kogito-bom/pom.xml +++ b/kogito-bom/pom.xml @@ -1758,6 +1758,11 @@ ${project.version} sources + + org.kie.kogito + jbpm-flow-api + ${project.version} + org.kie.kogito jbpm-flow-migration