]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.db.procore/src/org/simantics/db/procore/cluster/ClusterPrintDebugInfo.java
Migrated source code from Simantics SVN
[simantics/platform.git] / bundles / org.simantics.db.procore / src / org / simantics / db / procore / cluster / ClusterPrintDebugInfo.java
diff --git a/bundles/org.simantics.db.procore/src/org/simantics/db/procore/cluster/ClusterPrintDebugInfo.java b/bundles/org.simantics.db.procore/src/org/simantics/db/procore/cluster/ClusterPrintDebugInfo.java
new file mode 100644 (file)
index 0000000..a8d4b05
--- /dev/null
@@ -0,0 +1,56 @@
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
+ * in Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ *     VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.db.procore.cluster;\r
+\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.impl.ClusterBase;\r
+import org.simantics.db.impl.ClusterI;\r
+import org.simantics.db.impl.ClusterSupport;\r
+\r
+public class ClusterPrintDebugInfo\r
+implements ClusterI.ObjectProcedure<Integer> {\r
+    private ClusterBase cluster;\r
+    private ClusterSupport support;\r
+    private ObjectTable ot;\r
+    private int n = 0;\r
+       public ClusterPrintDebugInfo(ClusterBase cluster, ResourceTable resourceTable\r
+                       , PredicateTable predicateTable, ClusterSupport support,\r
+                    ObjectTable ot) throws DatabaseException {\r
+               this.cluster = cluster;\r
+               if (null == support)\r
+                   throw new DatabaseException("Illegal argument.");\r
+               this.support = support;\r
+               this.ot = ot;\r
+       }\r
+       \r
+    @Override\r
+    public boolean execute(Integer i, int resourceRef) {\r
+        int resourceKey;\r
+        try {\r
+            resourceKey = ClusterTraits.createResourceKey(cluster.getClusterKey(), resourceRef);\r
+        } catch (DatabaseException e) {\r
+            e.printStackTrace();\r
+            return false; // continue loop\r
+        }\r
+        CalculateStatements cs = new CalculateStatements(resourceRef, ot);\r
+        try {\r
+            cluster.forPredicates(resourceKey, cs, cs, support);\r
+        } catch (Throwable t) {\r
+            t.printStackTrace();\r
+        }\r
+        return false; // continue loop\r
+    }\r
+       public int getSize() {\r
+               return n;\r
+       }\r
+       \r
+}\r