]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.db.procore/src/fi/vtt/simantics/procore/internal/DebugSupportImpl.java
DB query swapping to file system
[simantics/platform.git] / bundles / org.simantics.db.procore / src / fi / vtt / simantics / procore / internal / DebugSupportImpl.java
index 3b05bcba6d67baabc0ee5afcf48557f522f3b384..ca5eb0825a3c6462676dcee91124d4b2384b2021 100644 (file)
@@ -45,6 +45,7 @@ import org.simantics.scl.runtime.function.FunctionImpl2;
 import org.simantics.scl.runtime.function.FunctionImpl3;
 import org.simantics.utils.Development;
 import org.simantics.utils.FileUtils;
+import org.slf4j.LoggerFactory;
 
 import gnu.trove.map.hash.TIntIntHashMap;
 import gnu.trove.procedure.TIntIntProcedure;
@@ -53,6 +54,8 @@ import gnu.trove.set.hash.TIntHashSet;
 
 public class DebugSupportImpl implements DebugSupport {
 
+    private static final org.slf4j.Logger LOGGER = LoggerFactory.getLogger(DebugSupportImpl.class);
+
        final private Map<String, Function2<WriteGraph, String, Object>> getCommands = new HashMap<String, Function2<WriteGraph, String, Object>>();
        final private Map<String, Function3<WriteGraph, File, String, String>> listCommands = new HashMap<String, Function3<WriteGraph, File, String, String>>();
        final private Map<String, Function2<WriteGraph, String, String>> execCommands = new HashMap<String, Function2<WriteGraph, String, String>>();
@@ -106,6 +109,21 @@ public class DebugSupportImpl implements DebugSupport {
 
                });
 
+        listCommands.put("queryData", new FunctionImpl3<WriteGraph, File, String, String>() {
+
+            @Override
+            public String apply(WriteGraph graph, File file, String args) {
+                try {
+                    getSession(graph).queryProvider2.save();
+                    return "Saved queries";
+                } catch (IOException e) {
+                    LOGGER.error("Error while saving queries", e);
+                    return e.getMessage();
+                }
+            }
+
+        });
+
                listCommands.put("queryActivity", new FunctionImpl3<WriteGraph, File, String, String>() {
 
                        @Override