]> gerrit.simantics Code Review - simantics/platform.git/commitdiff
More meaningful debug printing to PrettyPrintTG 38/638/1
authorjsimomaa <jani.simomaa@gmail.com>
Mon, 19 Jun 2017 05:35:32 +0000 (08:35 +0300)
committerjsimomaa <jani.simomaa@gmail.com>
Mon, 19 Jun 2017 05:40:27 +0000 (08:40 +0300)
Also removing commented out code

refs #7276

Change-Id: I1aee2b8424444a7ee0b3a08be31dbc3375b3e21f

bundles/org.simantics.graph/src/org/simantics/graph/representation/PrettyPrintTG.java

index 0a0a86f0be45be0c0aff59fe6927a989df675120..2d4171e1ce8855f097999eb033b77db3d158de2e 100644 (file)
@@ -239,70 +239,8 @@ public class PrettyPrintTG {
         } else {
             return formattedOutput;
         }
-        //
-        // Variant variant = value.value;
-        // Datatype dt = variant.getBinding().type();
-        // if (Datatypes.STRING.equals(dt)) {
-        // String s = (String) variant.getValue(Bindings.STRING);
-        // if (s.contains("\n")) {
-        // return "\"\"\"" + s + "\"\"\"";
-        // } else {
-        // return "\"" + s + "\"";
-        // }
-        // } else if (Datatypes.BOOLEAN.equals(dt)) {
-        // Boolean i = (Boolean) variant.getValue(Bindings.BOOLEAN);
-        // return i ? "true" : "false";
-        // } else if (Datatypes.INTEGER.equals(dt)) {
-        // Integer i = (Integer) variant.getValue(Bindings.INTEGER);
-        // return i.toString();
-        // } else if (Datatypes.LONG.equals(dt)) {
-        // Long i = (Long) variant.getValue(Bindings.LONG);
-        // return i.toString();
-        // } else if (Datatypes.DOUBLE.equals(dt)) {
-        // Double d = (Double) variant.getValue();
-        // return d.toString();
-        // } else if (Datatypes.FLOAT.equals(dt)) {
-        // Float f = (Float) variant.getValue();
-        // return f.toString();
-        // } else if (Datatypes.STRING_ARRAY.equals(dt)) {
-        // return Arrays.toString((String []) variant.getValue());
-        // } else if (Datatypes.BOOLEAN_ARRAY.equals(dt)) {
-        // return Arrays.toString((boolean []) variant.getValue());
-        // } else if (Datatypes.INTEGER_ARRAY.equals(dt)) {
-        // return Arrays.toString((int []) variant.getValue());
-        // } else if (Datatypes.LONG_ARRAY.equals(dt)) {
-        // return Arrays.toString((long []) variant.getValue());
-        // } else if (Datatypes.DOUBLE_ARRAY.equals(dt)) {
-        // return Arrays.toString((double []) variant.getValue());
-        // } else if (Datatypes.FLOAT_ARRAY.equals(dt)) {
-        // return Arrays.toString((float []) variant.getValue());
-        // } else if (Datatypes.BYTE_ARRAY.equals(dt)) {
-        // return Arrays.toString((byte []) variant.getValue());
-        //// } else if (dt instanceof ArrayType) {
-        //// return Arrays.toString((Object []) variant.getValue());
-        // } else {
-        // byte[] data =
-        // Bindings.getSerializerUnchecked(variant.getBinding()).serialize(variant.getValue());
-        // m.reset();
-        // m.update(data, 0, data.length);
-        // return "\"" + new BigInteger(1, m.digest()).toString(16) + "\"";
-        // }
-
     }
 
-    // void fixInstanceOf(TransferableGraph1 graph, ResourceInfo info) {
-    // Identity id = getIdentity(graph, info.resource);
-    // if(id == null) return;
-    // if(id.definition instanceof Internal) {
-    // Identity instanceOf = findExternal(graph,
-    // "http://www.simantics.org/Layer0-1.1/InstanceOf");
-    // Identity library = findExternal(graph,
-    // "http://www.simantics.org/Layer0-1.1/Library");
-    // info.statements.add(instanceOf.resource);
-    // info.statements.add(library.resource);
-    // }
-    // }
-
     public static String getExternalURI(TransferableGraph1 tg, External ext) {
         String name = ext.name;
         if (name.contains(" "))
@@ -787,8 +725,7 @@ public class PrettyPrintTG {
                 "http://www.simantics.org/Modeling-1.2/DiagramConnectionToConnection");
 
         for (ResourceInfo infoo : infos.valueCollection()) {
-            Identity elemTo = TransferableGraphUtils.findExternal(graph,
-                    "http://www.simantics.org/Modeling-1.2/ElementToComponent");
+            Identity elemTo = TransferableGraphUtils.findExternal(graph, "http://www.simantics.org/Modeling-1.2/ElementToComponent");
             if (elemTo != null) {
                 int elemToComponent = TransferableGraphUtils.getPossibleObject2(graph, infoo.resource, elemTo);
                 if (elemToComponent != TransferableGraphUtils.NOT_FOUND) {
@@ -796,8 +733,8 @@ public class PrettyPrintTG {
                     Identity component = TransferableGraphUtils.getIdentity(graph, elemToComponent);
                     Identity internal = TransferableGraphUtils.getIdentity(graph, infoo.resource);
                     if (internal.definition instanceof Internal && component.definition instanceof Internal) {
-                        Internal iCOmponent = (Internal) component.definition;
-                        infoo.name = infoo.name.substring(0, infoo.name.lastIndexOf(".") + 1) + iCOmponent.name;
+                        Internal iComponent = (Internal) component.definition;
+                        infoo.name = infoo.name.substring(0, infoo.name.lastIndexOf(".") + 1) + iComponent.name;
                     }
                 }
             }
@@ -829,7 +766,7 @@ public class PrettyPrintTG {
                                                     connection, possibleInverse);
                                             parentId = iPossibleInverse.parent;
                                         } else {
-                                            LOGGER.error("THIS UNSUPPORTED for " + infoo + " " + iPossibleInverse);
+                                            log("Unsupported inverse relation found for {} {}", infoo, iPossibleInverse);
                                         }
                                     } else if (possibleInverse.definition instanceof External) {
                                         External ePossibleInverse = (External) possibleInverse.definition;
@@ -838,12 +775,10 @@ public class PrettyPrintTG {
                                                     connection, possibleInverse);
                                             parentId = ePossibleInverse.parent;
                                         } else {
-                                            // This is not an inverse
-                                            // LOGGER.error("THIS UNSUPPORTED
-                                            // TOO");
+                                            log("This external inverse is unsupported for {} {}", infoo, ePossibleInverse);
                                         }
                                     } else {
-                                        LOGGER.error("UNSUPPORTED for " + infoo + " ");
+                                        log("This type of definition is not supported {}", infoo);
                                     }
                                     if (inverseRelation != TransferableGraphUtils.NOT_FOUND) {
                                         // Ok found something
@@ -855,7 +790,7 @@ public class PrettyPrintTG {
                                         } else if (object.definition instanceof External) {
                                             objectName = ((External) object.definition).name;
                                         } else {
-                                            LOGGER.error("UNSUPPORTED " + infoo);
+                                            log("This type of definition is not supported {}", infoo);
                                             throw new Error("UNSUPPORTED " + infoo);
                                         }
                                         if (parent.definition instanceof Internal) {
@@ -863,16 +798,16 @@ public class PrettyPrintTG {
                                         } else if (parent.definition instanceof External) {
                                             parentName = ((External) parent.definition).name;
                                         } else {
-                                            LOGGER.error("UNSUPPORTED " + infoo);
+                                            log("This type of definition is not supported {}", infoo);
                                             throw new Error("UNSUPPORTED " + infoo);
                                         }
                                         String fullName = parentName + "_" + objectName;
                                         nameParts.add(fullName);
                                     } else {
-                                        LOGGER.error("THIS IS ALSO UNSupported");
+                                        log("No inverse relation found for {}", infoo);
                                     }
                                 } else {
-                                    LOGGER.error("HERE");
+                                    log("Did not find possible inverse relation for {}", infoo);
                                 }
                             }
                             nameParts.sort((o1, o2) -> o1.compareTo(o2));