X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=org.simantics.interop%2Fsrc%2Forg%2Fsimantics%2Finterop%2Ftest%2FGraphChanges.java;fp=org.simantics.interop%2Fsrc%2Forg%2Fsimantics%2Finterop%2Ftest%2FGraphChanges.java;h=a68890651f2a38b522ce6ef13066f7b5df89a8fe;hb=e334209213fe36fd7b4f209fa41a15f1e3b9c751;hp=ce7af6d1aee6c3f8ff1f81cffa6c33cfe06f1b86;hpb=cd86a96617eaacfd9893bf98c09681be44072365;p=simantics%2Finterop.git diff --git a/org.simantics.interop/src/org/simantics/interop/test/GraphChanges.java b/org.simantics.interop/src/org/simantics/interop/test/GraphChanges.java index ce7af6d..a688906 100644 --- a/org.simantics.interop/src/org/simantics/interop/test/GraphChanges.java +++ b/org.simantics.interop/src/org/simantics/interop/test/GraphChanges.java @@ -157,48 +157,58 @@ public class GraphChanges { StringBuilder sb = new StringBuilder(); sb.append("Del:\n"); for (Statement stm : deletions) { - sb.append(NameUtils.getSafeName(graph, stm.getSubject()) + " "+ - NameUtils.getSafeName(graph, stm.getPredicate()) + " " + - NameUtils.getSafeName(graph, stm.getObject()) + " (" + - stm.getSubject() + " " +stm.getPredicate() + " " + stm.getObject() + ")\n"); + sb.append(toString(graph, stm)); + sb.append("\n"); } sb.append("Add:\n"); for (Statement stm : additions) { - sb.append(NameUtils.getSafeName(graph, stm.getSubject()) + " "+ - NameUtils.getSafeName(graph, stm.getPredicate()) + " " + - NameUtils.getSafeName(graph, stm.getObject()) + " (" + - stm.getSubject() + " " +stm.getPredicate() + " " + stm.getObject() + ")\n"); + sb.append(toString(graph, stm)); + sb.append("\n"); } sb.append("Mod:\n"); for (Modification mod :modifications) { - { - Statement stm = mod.getLeftStm(); - if (stm != null) { - sb.append(NameUtils.getSafeName(graph, mod.getLeftSub()) + " "+ - NameUtils.getSafeName(graph, stm.getPredicate()) + " " + - truncate(NameUtils.getSafeName(graph, stm.getObject())) + " (" + - mod.getLeftSub() + " " + stm.getSubject() + " " +stm.getPredicate() + " " + stm.getObject() + ")\n"); - } else { - sb.append(NameUtils.getSafeName(graph, mod.getLeftSub()) + " "+ mod.getLeftSub() + " N/A\n"); - } + sb.append(toString(graph, mod)); + sb.append("\n"); + } + return sb.toString(); + } + + public static String toString(ReadGraph graph, Statement stm) throws DatabaseException{ + return NameUtils.getSafeName(graph, stm.getSubject()) + " "+ + NameUtils.getSafeName(graph, stm.getPredicate()) + " " + + NameUtils.getSafeName(graph, stm.getObject()) + " (" + + stm.getSubject() + " " +stm.getPredicate() + " " + stm.getObject(); + } + + public static String toString(ReadGraph graph, Modification mod) throws DatabaseException{ + StringBuilder sb = new StringBuilder(); + { + Statement stm = mod.getLeftStm(); + if (stm != null) { + sb.append(NameUtils.getSafeName(graph, mod.getLeftSub()) + " "+ + NameUtils.getSafeName(graph, stm.getPredicate()) + " " + + truncate(NameUtils.getSafeName(graph, stm.getObject())) + " (" + + mod.getLeftSub() + " " + stm.getSubject() + " " +stm.getPredicate() + " " + stm.getObject() + ")\n"); + } else { + sb.append(NameUtils.getSafeName(graph, mod.getLeftSub()) + " "+ mod.getLeftSub() + " N/A\n"); } - { - Statement stm = mod.getRightStm(); - if (stm != null) { - sb.append(NameUtils.getSafeName(graph, mod.getRightSub()) + " "+ - NameUtils.getSafeName(graph, stm.getPredicate()) + " " + - truncate(NameUtils.getSafeName(graph, stm.getObject())) + " (" + - mod.getRightSub() + " " + stm.getSubject() + " " +stm.getPredicate() + " " + stm.getObject() + ")\n"); - } else { - sb.append(NameUtils.getSafeName(graph, mod.getRightSub()) + " "+ mod.getRightSub() + " N/A\n"); - } - + } + { + Statement stm = mod.getRightStm(); + if (stm != null) { + sb.append(NameUtils.getSafeName(graph, mod.getRightSub()) + " "+ + NameUtils.getSafeName(graph, stm.getPredicate()) + " " + + truncate(NameUtils.getSafeName(graph, stm.getObject())) + " (" + + mod.getRightSub() + " " + stm.getSubject() + " " +stm.getPredicate() + " " + stm.getObject() + ")"); + } else { + sb.append(NameUtils.getSafeName(graph, mod.getRightSub()) + " "+ mod.getRightSub() + " N/A"); } - } + + } return sb.toString(); } - public String truncate(String s) { + public static String truncate(String s) { if (s.length() < 100) return s; return s.substring(0, 100)+"...";