diff --git a/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-api/src/main/java/org/kie/workbench/common/stunner/sw/definition/StateExecTimeout.java b/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-api/src/main/java/org/kie/workbench/common/stunner/sw/definition/StateExecTimeout.java new file mode 100644 index 00000000000..7b007f41e92 --- /dev/null +++ b/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-api/src/main/java/org/kie/workbench/common/stunner/sw/definition/StateExecTimeout.java @@ -0,0 +1,52 @@ +/* + * 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.workbench.common.stunner.sw.definition; + +import jsinterop.annotations.JsType; +import org.kie.j2cl.tools.json.mapper.annotation.JSONMapper; +import org.kie.j2cl.tools.processors.annotations.GWT3Export; +import org.kie.j2cl.tools.yaml.mapper.api.annotation.YAMLMapper; + +@JSONMapper +@YAMLMapper +@JsType +@GWT3Export +public class StateExecTimeout { + + private String single; + private String total; + + public final String getSingle() { + return single; + } + + public final void setSingle(String single) { + this.single = single; + } + + public final String getTotal() { + return total; + } + + public final void setTotal(String total) { + this.total = total; + } +} diff --git a/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-api/src/main/java/org/kie/workbench/common/stunner/sw/definition/WorkflowTimeouts.java b/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-api/src/main/java/org/kie/workbench/common/stunner/sw/definition/WorkflowTimeouts.java index 1f6f5fc806a..b7e71230b5b 100644 --- a/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-api/src/main/java/org/kie/workbench/common/stunner/sw/definition/WorkflowTimeouts.java +++ b/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-api/src/main/java/org/kie/workbench/common/stunner/sw/definition/WorkflowTimeouts.java @@ -28,7 +28,9 @@ import org.kie.j2cl.tools.yaml.mapper.api.annotation.YAMLMapper; import org.kie.j2cl.tools.yaml.mapper.api.annotation.YamlTypeDeserializer; import org.kie.j2cl.tools.yaml.mapper.api.annotation.YamlTypeSerializer; +import org.kie.workbench.common.stunner.sw.marshall.json.StateExecTimeoutJsonSerializer; import org.kie.workbench.common.stunner.sw.marshall.json.WorkflowExecTimeoutJsonSerializer; +import org.kie.workbench.common.stunner.sw.marshall.yaml.StateExecTimeoutYamlSerializer; import org.kie.workbench.common.stunner.sw.marshall.yaml.WorkflowExecTimeoutYamlSerializer; @JSONMapper @@ -42,7 +44,12 @@ public class WorkflowTimeouts { @YamlTypeSerializer(WorkflowExecTimeoutYamlSerializer.class) @YamlTypeDeserializer(WorkflowExecTimeoutYamlSerializer.class) private Object workflowExecTimeout; - private String stateExecTimeout; + + @JsonbTypeSerializer(StateExecTimeoutJsonSerializer.class) + @JsonbTypeDeserializer(StateExecTimeoutJsonSerializer.class) + @YamlTypeSerializer(StateExecTimeoutYamlSerializer.class) + @YamlTypeDeserializer(StateExecTimeoutYamlSerializer.class) + private Object stateExecTimeout; private String actionExecTimeout; private String branchExecTimeout; private String eventTimeout; @@ -55,11 +62,11 @@ public final void setWorkflowExecTimeout(Object workflowExecTimeout) { this.workflowExecTimeout = workflowExecTimeout; } - public final String getStateExecTimeout() { + public final Object getStateExecTimeout() { return stateExecTimeout; } - public final void setStateExecTimeout(String stateExecTimeout) { + public final void setStateExecTimeout(Object stateExecTimeout) { this.stateExecTimeout = stateExecTimeout; } diff --git a/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-api/src/main/java/org/kie/workbench/common/stunner/sw/marshall/json/StateExecTimeoutJsonSerializer.java b/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-api/src/main/java/org/kie/workbench/common/stunner/sw/marshall/json/StateExecTimeoutJsonSerializer.java new file mode 100644 index 00000000000..490d99d5d26 --- /dev/null +++ b/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-api/src/main/java/org/kie/workbench/common/stunner/sw/marshall/json/StateExecTimeoutJsonSerializer.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.workbench.common.stunner.sw.marshall.json; + +import java.lang.reflect.Type; + +import jakarta.json.JsonValue; +import jakarta.json.bind.serializer.DeserializationContext; +import jakarta.json.bind.serializer.JsonbDeserializer; +import jakarta.json.bind.serializer.JsonbSerializer; +import jakarta.json.bind.serializer.SerializationContext; +import jakarta.json.stream.JsonGenerator; +import jakarta.json.stream.JsonParser; +import org.kie.j2cl.tools.json.mapper.internal.deserializer.StringJsonDeserializer; +import org.kie.j2cl.tools.json.mapper.internal.serializer.StringJsonSerializer; +import org.kie.workbench.common.stunner.sw.definition.StateExecTimeout; +import org.kie.workbench.common.stunner.sw.definition.StateExecTimeout_JsonDeserializerImpl; +import org.kie.workbench.common.stunner.sw.definition.StateExecTimeout_JsonSerializerImpl; + +public class StateExecTimeoutJsonSerializer implements JsonbDeserializer, JsonbSerializer { + + private static final StateExecTimeout_JsonSerializerImpl serializer = + StateExecTimeout_JsonSerializerImpl.INSTANCE; + + private static final StateExecTimeout_JsonDeserializerImpl deserializer = + StateExecTimeout_JsonDeserializerImpl.INSTANCE; + private static final StringJsonSerializer stringJsonSerializer = new StringJsonSerializer(); + + private static final StringJsonDeserializer stringJsonDeserializer = new StringJsonDeserializer(); + + @Override + public Object deserialize(JsonParser parser, DeserializationContext ctx, Type type) { + JsonValue value = parser.getValue(); + if(value != null) { + if (value.getValueType() != JsonValue.ValueType.NULL) { + if (value.getValueType() == JsonValue.ValueType.STRING) { + return stringJsonDeserializer.deserialize(value, ctx); + } else if (value.getValueType() == JsonValue.ValueType.OBJECT) { + return deserializer.deserialize(parser.getValue(), ctx); + } + } + } + return null; + } + + @Override + public void serialize(Object stateExecTimeout, JsonGenerator generator, SerializationContext serializationContext) { + if (stateExecTimeout instanceof String) { + stringJsonSerializer.serialize((String) stateExecTimeout, generator, serializationContext); + } else if (stateExecTimeout instanceof StateExecTimeout) { + JsonGenerator jsonGenerator = generator.writeStartObject(); + serializer.serialize((StateExecTimeout) stateExecTimeout, jsonGenerator, serializationContext); + jsonGenerator.writeEnd(); + } + } +} diff --git a/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-api/src/main/java/org/kie/workbench/common/stunner/sw/marshall/yaml/StateExecTimeoutYamlSerializer.java b/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-api/src/main/java/org/kie/workbench/common/stunner/sw/marshall/yaml/StateExecTimeoutYamlSerializer.java new file mode 100644 index 00000000000..c9899f2da80 --- /dev/null +++ b/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-api/src/main/java/org/kie/workbench/common/stunner/sw/marshall/yaml/StateExecTimeoutYamlSerializer.java @@ -0,0 +1,83 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.kie.workbench.common.stunner.sw.marshall.yaml; + +import org.kie.j2cl.tools.yaml.mapper.api.YAMLDeserializer; +import org.kie.j2cl.tools.yaml.mapper.api.YAMLSerializer; +import org.kie.j2cl.tools.yaml.mapper.api.exception.YAMLDeserializationException; +import org.kie.j2cl.tools.yaml.mapper.api.internal.deser.StringYAMLDeserializer; +import org.kie.j2cl.tools.yaml.mapper.api.internal.deser.YAMLDeserializationContext; +import org.kie.j2cl.tools.yaml.mapper.api.internal.ser.StringYAMLSerializer; +import org.kie.j2cl.tools.yaml.mapper.api.internal.ser.YAMLSerializationContext; +import org.kie.j2cl.tools.yaml.mapper.api.node.NodeType; +import org.kie.j2cl.tools.yaml.mapper.api.node.YamlMapping; +import org.kie.j2cl.tools.yaml.mapper.api.node.YamlNode; +import org.kie.j2cl.tools.yaml.mapper.api.node.YamlSequence; +import org.kie.workbench.common.stunner.sw.definition.StateExecTimeout; +import org.kie.workbench.common.stunner.sw.definition.StateExecTimeout_YamlMapperImpl; + +public class StateExecTimeoutYamlSerializer implements YAMLDeserializer, YAMLSerializer { + + + private static final StateExecTimeout_YamlMapperImpl mapper = + StateExecTimeout_YamlMapperImpl.INSTANCE; + + private static final StringYAMLSerializer stringYAMLSerializer = new StringYAMLSerializer(); + private static final StringYAMLDeserializer stringYAMLDeserializer = new StringYAMLDeserializer(); + + @Override + public Object deserialize(YamlMapping yaml, String key, YAMLDeserializationContext ctx) throws YAMLDeserializationException { + YamlNode value = yaml.getNode(key); + if (value == null) { + return null; + } + return deserialize(value, ctx); + } + + @Override + public Object deserialize(YamlNode node, YAMLDeserializationContext ctx) { + if (node == null) { + return null; + } + if(node.type() == NodeType.SCALAR) { + return stringYAMLDeserializer.deserialize(node, ctx); + } else { + return mapper.getDeserializer().deserialize(node, ctx); + } + } + + @Override + public void serialize(YamlMapping writer, String propertyName, Object value, YAMLSerializationContext ctx) { + if (value instanceof String) { + stringYAMLSerializer.serialize(writer, propertyName, (String) value, ctx); + } else if (value instanceof StateExecTimeout) { + mapper.getSerializer().serialize(writer, propertyName, (StateExecTimeout) value, ctx); + } + } + + @Override + public void serialize(YamlSequence writer, Object value, YAMLSerializationContext ctx) { + if (value instanceof String) { + stringYAMLSerializer.serialize(writer, (String) value, ctx); + } else if (value instanceof StateExecTimeout) { + mapper.getSerializer().serialize(writer, (StateExecTimeout) value, ctx); + } + } +} diff --git a/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-client/src/main/java/org/kie/workbench/common/stunner/sw/client/shapes/CallbackStateShape.java b/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-client/src/main/java/org/kie/workbench/common/stunner/sw/client/shapes/CallbackStateShape.java index 97a774d07bb..1ad660e084f 100644 --- a/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-client/src/main/java/org/kie/workbench/common/stunner/sw/client/shapes/CallbackStateShape.java +++ b/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-client/src/main/java/org/kie/workbench/common/stunner/sw/client/shapes/CallbackStateShape.java @@ -32,6 +32,7 @@ import org.kie.workbench.common.stunner.sw.definition.ActionNode; import org.kie.workbench.common.stunner.sw.definition.CallbackState; import org.kie.workbench.common.stunner.sw.definition.State; +import org.kie.workbench.common.stunner.sw.definition.StateExecTimeout; import org.kie.workbench.common.stunner.sw.definition.WorkflowTimeouts; import static org.kie.workbench.common.stunner.sw.client.shapes.icons.IconPath.CLOCK; @@ -66,7 +67,9 @@ public void applyProperties(Node, Edge> element, MutationContext mut getView().addChild(new CornerIcon(CLOCK, CENTER_TOP, getTranslation(TIMEOUT_EVENT) + ": " + truncate(((WorkflowTimeouts) state.getTimeouts()).getEventTimeout()) + "\r\n" - + getTranslation(TIMEOUT_STATE) + ": " + truncate(((WorkflowTimeouts) state.getTimeouts()).getStateExecTimeout()) + "\r\n" + + getTranslation(TIMEOUT_STATE) + ": " + truncate(((WorkflowTimeouts) state.getTimeouts()).getStateExecTimeout() instanceof String ? + (String) ((WorkflowTimeouts) state.getTimeouts()).getStateExecTimeout() + : ((StateExecTimeout) ((WorkflowTimeouts) state.getTimeouts()).getStateExecTimeout()).getTotal()) + "\r\n" + getTranslation(TIMEOUT_ACTION) + ": " + truncate(((WorkflowTimeouts) state.getTimeouts()).getActionExecTimeout()))); } diff --git a/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-client/src/main/java/org/kie/workbench/common/stunner/sw/client/shapes/EventStateShape.java b/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-client/src/main/java/org/kie/workbench/common/stunner/sw/client/shapes/EventStateShape.java index b12a2bc557d..41b35f2000c 100644 --- a/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-client/src/main/java/org/kie/workbench/common/stunner/sw/client/shapes/EventStateShape.java +++ b/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-client/src/main/java/org/kie/workbench/common/stunner/sw/client/shapes/EventStateShape.java @@ -30,6 +30,7 @@ import org.kie.workbench.common.stunner.sw.client.theme.ColorTheme; import org.kie.workbench.common.stunner.sw.definition.EventState; import org.kie.workbench.common.stunner.sw.definition.State; +import org.kie.workbench.common.stunner.sw.definition.StateExecTimeout; import org.kie.workbench.common.stunner.sw.definition.WorkflowTimeouts; import static org.kie.workbench.common.stunner.sw.client.shapes.icons.IconPath.CLOCK; @@ -56,7 +57,9 @@ public void applyProperties(Node, Edge> element, MutationContext mut getView().addChild(new CornerIcon(CLOCK, RIGHT_TOP_CORNER, getTranslation(TIMEOUT_EVENT) + ": " + truncate(((WorkflowTimeouts) state.getTimeouts()).getEventTimeout()) + "\r\n" - + getTranslation(TIMEOUT_STATE) + ": " + truncate(((WorkflowTimeouts) state.getTimeouts()).getStateExecTimeout()) + "\r\n" + + getTranslation(TIMEOUT_STATE) + ": " + truncate(((WorkflowTimeouts) state.getTimeouts()).getStateExecTimeout() instanceof String ? + (String) ((WorkflowTimeouts) state.getTimeouts()).getStateExecTimeout() + : ((StateExecTimeout) ((WorkflowTimeouts) state.getTimeouts()).getStateExecTimeout()).getTotal()) + "\r\n" + getTranslation(TIMEOUT_ACTION) + ": " + truncate(((WorkflowTimeouts) state.getTimeouts()).getActionExecTimeout()))); } diff --git a/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-client/src/main/java/org/kie/workbench/common/stunner/sw/client/shapes/ForEachStateShape.java b/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-client/src/main/java/org/kie/workbench/common/stunner/sw/client/shapes/ForEachStateShape.java index e3e39176d84..42e438a74a3 100644 --- a/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-client/src/main/java/org/kie/workbench/common/stunner/sw/client/shapes/ForEachStateShape.java +++ b/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-client/src/main/java/org/kie/workbench/common/stunner/sw/client/shapes/ForEachStateShape.java @@ -32,6 +32,7 @@ import org.kie.workbench.common.stunner.sw.client.theme.ColorTheme; import org.kie.workbench.common.stunner.sw.definition.ForEachState; import org.kie.workbench.common.stunner.sw.definition.State; +import org.kie.workbench.common.stunner.sw.definition.StateExecTimeout; import org.kie.workbench.common.stunner.sw.definition.WorkflowTimeouts; import static org.kie.workbench.common.stunner.sw.client.shapes.icons.IconPath.CLOCK; @@ -65,7 +66,9 @@ public void applyProperties(Node, Edge> element, MutationContext mut if (state.getTimeouts() != null && state.getTimeouts() instanceof WorkflowTimeouts) { getView().addChild(new CornerIcon(CLOCK, LEFT_FROM_RIGHT_TOP_CORNER, - getTranslation(TIMEOUT_STATE) + ": " + truncate(((WorkflowTimeouts) state.getTimeouts()).getStateExecTimeout()) + "\r\n" + getTranslation(TIMEOUT_STATE) + ": " + truncate(((WorkflowTimeouts) state.getTimeouts()).getStateExecTimeout() instanceof String ? + (String) ((WorkflowTimeouts) state.getTimeouts()).getStateExecTimeout() + : ((StateExecTimeout) ((WorkflowTimeouts) state.getTimeouts()).getStateExecTimeout()).getTotal()) + "\r\n" + getTranslation(TIMEOUT_ACTION) + ": " + truncate(((WorkflowTimeouts) state.getTimeouts()).getActionExecTimeout()))); } diff --git a/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-client/src/main/java/org/kie/workbench/common/stunner/sw/client/shapes/OperationStateShape.java b/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-client/src/main/java/org/kie/workbench/common/stunner/sw/client/shapes/OperationStateShape.java index 48cd810b08d..aafccadfb36 100644 --- a/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-client/src/main/java/org/kie/workbench/common/stunner/sw/client/shapes/OperationStateShape.java +++ b/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-client/src/main/java/org/kie/workbench/common/stunner/sw/client/shapes/OperationStateShape.java @@ -32,6 +32,7 @@ import org.kie.workbench.common.stunner.sw.client.theme.ColorTheme; import org.kie.workbench.common.stunner.sw.definition.OperationState; import org.kie.workbench.common.stunner.sw.definition.State; +import org.kie.workbench.common.stunner.sw.definition.StateExecTimeout; import org.kie.workbench.common.stunner.sw.definition.WorkflowTimeouts; import static org.kie.workbench.common.stunner.sw.client.shapes.icons.IconPath.CLOCK; @@ -63,7 +64,9 @@ public void applyProperties(Node, Edge> element, MutationContext mut if (state.getTimeouts() != null && state.getTimeouts() instanceof WorkflowTimeouts) { getView().addChild(new CornerIcon(CLOCK, LEFT_FROM_RIGHT_TOP_CORNER, - getTranslation(TIMEOUT_STATE) + ": " + truncate(((WorkflowTimeouts) state.getTimeouts()).getStateExecTimeout()) + "\r\n" + getTranslation(TIMEOUT_STATE) + ": " + truncate(((WorkflowTimeouts) state.getTimeouts()).getStateExecTimeout() instanceof String ? + (String) ((WorkflowTimeouts) state.getTimeouts()).getStateExecTimeout() + : ((StateExecTimeout) ((WorkflowTimeouts) state.getTimeouts()).getStateExecTimeout()).getTotal()) + "\r\n" + getTranslation(TIMEOUT_ACTION) + ": " + truncate(((WorkflowTimeouts) state.getTimeouts()).getActionExecTimeout()))); } diff --git a/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-client/src/main/java/org/kie/workbench/common/stunner/sw/client/shapes/ParallelStateShape.java b/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-client/src/main/java/org/kie/workbench/common/stunner/sw/client/shapes/ParallelStateShape.java index 68ea0f62958..cbc3c926768 100644 --- a/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-client/src/main/java/org/kie/workbench/common/stunner/sw/client/shapes/ParallelStateShape.java +++ b/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-client/src/main/java/org/kie/workbench/common/stunner/sw/client/shapes/ParallelStateShape.java @@ -32,6 +32,7 @@ import org.kie.workbench.common.stunner.sw.client.theme.ColorTheme; import org.kie.workbench.common.stunner.sw.definition.ParallelState; import org.kie.workbench.common.stunner.sw.definition.State; +import org.kie.workbench.common.stunner.sw.definition.StateExecTimeout; import org.kie.workbench.common.stunner.sw.definition.WorkflowTimeouts; import static org.kie.workbench.common.stunner.sw.client.shapes.icons.IconPath.BRANCH; @@ -62,7 +63,9 @@ public void applyProperties(Node, Edge> element, MutationContext mut getView().addChild(new CornerIcon(CLOCK, LEFT_FROM_RIGHT_TOP_CORNER, getTranslation(TIMEOUT_BRANCH) + ": " + truncate(((WorkflowTimeouts) state.getTimeouts()).getBranchExecTimeout()) + "\r\n" - + getTranslation(TIMEOUT_STATE) + ": " + truncate(((WorkflowTimeouts) state.getTimeouts()).getStateExecTimeout()))); + + getTranslation(TIMEOUT_STATE) + ": " + truncate(((WorkflowTimeouts) state.getTimeouts()).getStateExecTimeout() instanceof String ? + (String) ((WorkflowTimeouts) state.getTimeouts()).getStateExecTimeout() + : ((StateExecTimeout) ((WorkflowTimeouts) state.getTimeouts()).getStateExecTimeout()).getTotal()))); } getView().addChild(new CornerIcon(BRANCH, diff --git a/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-client/src/main/java/org/kie/workbench/common/stunner/sw/client/shapes/SwitchStateShape.java b/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-client/src/main/java/org/kie/workbench/common/stunner/sw/client/shapes/SwitchStateShape.java index cd449d5d304..ba01b2a8989 100644 --- a/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-client/src/main/java/org/kie/workbench/common/stunner/sw/client/shapes/SwitchStateShape.java +++ b/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-client/src/main/java/org/kie/workbench/common/stunner/sw/client/shapes/SwitchStateShape.java @@ -29,6 +29,7 @@ import org.kie.workbench.common.stunner.sw.client.shapes.icons.CornerIcon; import org.kie.workbench.common.stunner.sw.client.theme.ColorTheme; import org.kie.workbench.common.stunner.sw.definition.State; +import org.kie.workbench.common.stunner.sw.definition.StateExecTimeout; import org.kie.workbench.common.stunner.sw.definition.SwitchState; import org.kie.workbench.common.stunner.sw.definition.WorkflowTimeouts; @@ -57,7 +58,9 @@ public void applyProperties(Node, Edge> element, MutationContext mut getView().addChild(new CornerIcon(CLOCK, LEFT_FROM_RIGHT_TOP_CORNER, getTranslation(TIMEOUT_EVENT) + ": " + truncate(((WorkflowTimeouts) state.getTimeouts()).getEventTimeout()) + "\r\n" - + getTranslation(TIMEOUT_STATE) + ": " + truncate(((WorkflowTimeouts) state.getTimeouts()).getStateExecTimeout()))); + + getTranslation(TIMEOUT_STATE) + ": " + truncate(((WorkflowTimeouts) state.getTimeouts()).getStateExecTimeout() instanceof String ? + (String) ((WorkflowTimeouts) state.getTimeouts()).getStateExecTimeout() + : ((StateExecTimeout) ((WorkflowTimeouts) state.getTimeouts()).getStateExecTimeout()).getTotal()))); } if (state.getStateDataFilter() != null) { diff --git a/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-kogito-app/src/test/java/org/kie/workbench/common/stunner/sw/client/selenium/SWEditorSeleniumIT.java b/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-kogito-app/src/test/java/org/kie/workbench/common/stunner/sw/client/selenium/SWEditorSeleniumIT.java index 8067f6ea17a..dc051f18f49 100644 --- a/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-kogito-app/src/test/java/org/kie/workbench/common/stunner/sw/client/selenium/SWEditorSeleniumIT.java +++ b/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-kogito-app/src/test/java/org/kie/workbench/common/stunner/sw/client/selenium/SWEditorSeleniumIT.java @@ -190,6 +190,11 @@ public void testProcessTransactionsExample() throws Exception { testExample("ProcessTransactionsExample.sw.json"); } + @Test + public void testStateExecTimeoutExample() throws Exception { + testExample("StateExecTimeoutExample.sw.json"); + } + @Test public void testAutoLayoutMultipleConnectionsCPs() throws Exception { String resource = "EventBasedSwitchStateExample.sw.json"; diff --git a/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-kogito-app/src/test/resources/org/kie/workbench/common/stunner/sw/client/selenium/StateExecTimeoutExample.sw.json b/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-kogito-app/src/test/resources/org/kie/workbench/common/stunner/sw/client/selenium/StateExecTimeoutExample.sw.json new file mode 100644 index 00000000000..235254dd3d5 --- /dev/null +++ b/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-kogito-app/src/test/resources/org/kie/workbench/common/stunner/sw/client/selenium/StateExecTimeoutExample.sw.json @@ -0,0 +1,102 @@ +{ + "id": "getcatfactinformation", + "description": "Description", + "version": "1.0", + "specVersion": "0.8", + "expressionLang": "jq", + "states": [ + { + "name": "GreetOrCatFact", + "type": "switch", + "defaultCondition": { + "transition": { + "nextState": "GetOneStaticFact" + } + }, + "dataConditions": [ + { + "condition": "${ .fact == \"random\"}", + "transition": { + "nextState": "GetRandomFact" + } + } + ], + "timeouts": { + "stateExecTimeout": { + "total": "P4D" + }, + "eventTimeout": "P4D" + } + }, + { + "name": "GetOneStaticFact", + "type": "inject", + "transition": { + "nextState": "PrintTheFact" + }, + "data": { + "message": "Cats are very cute" + } + }, + { + "name": "GetRandomFact", + "type": "operation", + "transition": { + "nextState": "PrintTheFact" + }, + "actionMode": "sequential", + "actions": [ + { + "name": "getRandomFact", + "functionRef": { + "refName": "getCatFact", + "invoke": "sync" + }, + "actionDataFilter": { + "useResults": true + } + } + ], + "timeouts": { + "stateExecTimeout": { + "total": "P4D" + } + } + }, + { + "name": "PrintTheFact", + "type": "operation", + "end": { + "terminate": true + }, + "actionMode": "sequential", + "actions": [ + { + "name": "greetAction", + "functionRef": { + "refName": "sysOutFunction", + "arguments": { + "message": "${\"Fact is that: \" + .message + .fact }" + }, + "invoke": "sync" + }, + "actionDataFilter": { + "useResults": true + } + } + ] + } + ], + "functions": [ + { + "name": "getCatFact", + "operation": "specs/catfacts.json#getRandomFact", + "type": "rest" + }, + { + "name": "sysOutFunction", + "operation": "sysout", + "type": "custom" + } + ] +}