-
Notifications
You must be signed in to change notification settings - Fork 191
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[serverless-workflow-diagram-editor] marshallers (json/yaml) must sup…
…port stateExecTimeout.(total/single) properties
- Loading branch information
1 parent
cc75f9b
commit cbe427b
Showing
10 changed files
with
242 additions
and
9 deletions.
There are no files selected for viewing
52 changes: 52 additions & 0 deletions
52
...or-api/src/main/java/org/kie/workbench/common/stunner/sw/definition/StateExecTimeout.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
73 changes: 73 additions & 0 deletions
73
...ava/org/kie/workbench/common/stunner/sw/marshall/json/StateExecTimeoutJsonSerializer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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<Object>, JsonbSerializer<Object> { | ||
|
||
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(); | ||
} | ||
} | ||
} |
83 changes: 83 additions & 0 deletions
83
...ava/org/kie/workbench/common/stunner/sw/marshall/yaml/StateExecTimeoutYamlSerializer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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<Object>, YAMLSerializer<Object> { | ||
|
||
|
||
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); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters