From a050a536437c5cedf5fa70bb417e79f1d17c2038 Mon Sep 17 00:00:00 2001 From: Francisco Javier Tirado Sarti Date: Thu, 27 Jun 2024 11:03:58 +0200 Subject: [PATCH] [Fix #380] SwitchPRoperty to SwitchItem Signed-off-by: Francisco Javier Tirado Sarti --- .../io/serverlessworkflow/api/ObjectMapperFactory.java | 6 +++--- ...chDeserializer.java => SwitchItemDeserializer.java} | 10 +++++----- ...SwitchSerializer.java => SwitchItemSerializer.java} | 8 ++++---- api/src/main/resources/schema/workflow.yaml | 2 ++ 4 files changed, 14 insertions(+), 12 deletions(-) rename api/src/main/java/io/serverlessworkflow/api/{SwitchDeserializer.java => SwitchItemDeserializer.java} (71%) rename api/src/main/java/io/serverlessworkflow/api/{SwitchSerializer.java => SwitchItemSerializer.java} (77%) diff --git a/api/src/main/java/io/serverlessworkflow/api/ObjectMapperFactory.java b/api/src/main/java/io/serverlessworkflow/api/ObjectMapperFactory.java index a245a07f..f45c7632 100644 --- a/api/src/main/java/io/serverlessworkflow/api/ObjectMapperFactory.java +++ b/api/src/main/java/io/serverlessworkflow/api/ObjectMapperFactory.java @@ -21,7 +21,7 @@ import com.fasterxml.jackson.dataformat.yaml.YAMLFactory; import com.fasterxml.jackson.dataformat.yaml.YAMLGenerator.Feature; import io.serverlessworkflow.api.types.CallTask; -import io.serverlessworkflow.api.types.Switch; +import io.serverlessworkflow.api.types.SwitchItem; import io.serverlessworkflow.api.types.Task; import io.serverlessworkflow.api.types.TaskItem; @@ -48,8 +48,8 @@ private static ObjectMapper configure(ObjectMapper mapper) { simpleModule.addSerializer(CallTask.class, new CallTaskSerializer()); simpleModule.addDeserializer(TaskItem.class, new TaskItemDeserializer()); simpleModule.addSerializer(TaskItem.class, new TaskItemSerializer()); - simpleModule.addSerializer(Switch.class, new SwitchSerializer()); - simpleModule.addDeserializer(Switch.class, new SwitchDeserializer()); + simpleModule.addSerializer(SwitchItem.class, new SwitchItemSerializer()); + simpleModule.addDeserializer(SwitchItem.class, new SwitchItemDeserializer()); return mapper .configure(SerializationFeature.INDENT_OUTPUT, true) diff --git a/api/src/main/java/io/serverlessworkflow/api/SwitchDeserializer.java b/api/src/main/java/io/serverlessworkflow/api/SwitchItemDeserializer.java similarity index 71% rename from api/src/main/java/io/serverlessworkflow/api/SwitchDeserializer.java rename to api/src/main/java/io/serverlessworkflow/api/SwitchItemDeserializer.java index 21ede4a3..02d93585 100644 --- a/api/src/main/java/io/serverlessworkflow/api/SwitchDeserializer.java +++ b/api/src/main/java/io/serverlessworkflow/api/SwitchItemDeserializer.java @@ -18,14 +18,14 @@ import com.fasterxml.jackson.core.JsonParser; import com.fasterxml.jackson.databind.DeserializationContext; import com.fasterxml.jackson.databind.JsonDeserializer; -import io.serverlessworkflow.api.types.Switch; -import io.serverlessworkflow.api.types.SwitchProperty; +import io.serverlessworkflow.api.types.SwitchCase; +import io.serverlessworkflow.api.types.SwitchItem; import java.io.IOException; -class SwitchDeserializer extends JsonDeserializer { +class SwitchItemDeserializer extends JsonDeserializer { @Override - public Switch deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - return DeserializeHelper.deserializeItem(p, Switch.class, SwitchProperty.class); + public SwitchItem deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + return DeserializeHelper.deserializeItem(p, SwitchItem.class, SwitchCase.class); } } diff --git a/api/src/main/java/io/serverlessworkflow/api/SwitchSerializer.java b/api/src/main/java/io/serverlessworkflow/api/SwitchItemSerializer.java similarity index 77% rename from api/src/main/java/io/serverlessworkflow/api/SwitchSerializer.java rename to api/src/main/java/io/serverlessworkflow/api/SwitchItemSerializer.java index ed64fcb9..f76582cb 100644 --- a/api/src/main/java/io/serverlessworkflow/api/SwitchSerializer.java +++ b/api/src/main/java/io/serverlessworkflow/api/SwitchItemSerializer.java @@ -18,16 +18,16 @@ import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.databind.JsonSerializer; import com.fasterxml.jackson.databind.SerializerProvider; -import io.serverlessworkflow.api.types.Switch; +import io.serverlessworkflow.api.types.SwitchItem; import java.io.IOException; -class SwitchSerializer extends JsonSerializer { +class SwitchItemSerializer extends JsonSerializer { @Override - public void serialize(Switch value, JsonGenerator gen, SerializerProvider serializers) + public void serialize(SwitchItem value, JsonGenerator gen, SerializerProvider serializers) throws IOException { gen.writeStartObject(); - gen.writeObjectField(value.getName(), value.getSwitchProperty()); + gen.writeObjectField(value.getName(), value.getSwitchCase()); gen.writeEndObject(); } } diff --git a/api/src/main/resources/schema/workflow.yaml b/api/src/main/resources/schema/workflow.yaml index d3a20f2f..1c6d1bcc 100644 --- a/api/src/main/resources/schema/workflow.yaml +++ b/api/src/main/resources/schema/workflow.yaml @@ -571,8 +571,10 @@ $defs: type: object minProperties: 1 maxProperties: 1 + title: SwitchItem additionalProperties: type: object + title: SwitchCase properties: name: type: string