slievrly commented on code in PR #7316: URL: https://github.com/apache/incubator-seata/pull/7316#discussion_r2065607862
########## saga/seata-saga-statelang/src/main/java/org/apache/seata/saga/statelang/parser/utils/DesignerJsonTransformer.java: ########## @@ -37,44 +37,47 @@ */ public class DesignerJsonTransformer { - public static Map<String, Object> toStandardJson(Map<String, Object> designerJsonObject) { + public static boolean isDesignerJson(Map<String, Object> jsonObject) { + return jsonObject != null && jsonObject.containsKey("nodes") && jsonObject.containsKey("edges"); + } + public static Map<String, Object> toStandardJson(Map<String, Object> designerJsonObject) { if (!isDesignerJson(designerJsonObject)) { return designerJsonObject; } - Map<String, Object> machineJsonObject = new LinkedHashMap<>(); List<Object> nodes = (List) designerJsonObject.get("nodes"); - if (CollectionUtils.isNotEmpty(nodes)) { - Map<String, Object> nodeMap = new LinkedHashMap<>(nodes.size()); + List<Object> edges = (List) designerJsonObject.get("edges"); + if (CollectionUtils.isEmpty(nodes) || CollectionUtils.isEmpty(edges)) { + throw new RuntimeException("Nodes or edges are empty, please check them."); + } - for (Object node : nodes) { - Map<String, Object> nodeObj = (Map<String, Object>) node; + Map<String, Object> machineJsonObject = new LinkedHashMap<>(); + Map<String, Object> nodeMap = new LinkedHashMap<>(nodes.size()); - transformNode(machineJsonObject, nodeMap, nodeObj); - } + for (Object node : nodes) { Review Comment: From the syntax is correct. However, in terms of business semantics, nodes are the basis of edges. Without nodes, there must be no edges. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: notifications-unsubscr...@seata.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: notifications-unsubscr...@seata.apache.org For additional commands, e-mail: notifications-h...@seata.apache.org