]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.db.procore/src/org/simantics/db/procore/cluster/ClusterPrintDebugInfo.java
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.db.procore / src / org / simantics / db / procore / cluster / ClusterPrintDebugInfo.java
1 /*******************************************************************************
2  * Copyright (c) 2007, 2010 Association for Decentralized Information Management
3  * in Industry THTH ry.
4  * All rights reserved. This program and the accompanying materials
5  * are made available under the terms of the Eclipse Public License v1.0
6  * which accompanies this distribution, and is available at
7  * http://www.eclipse.org/legal/epl-v10.html
8  *
9  * Contributors:
10  *     VTT Technical Research Centre of Finland - initial API and implementation
11  *******************************************************************************/
12 package org.simantics.db.procore.cluster;
13
14 import org.simantics.db.exception.DatabaseException;
15 import org.simantics.db.impl.ClusterBase;
16 import org.simantics.db.impl.ClusterI;
17 import org.simantics.db.impl.ClusterSupport;
18
19 public class ClusterPrintDebugInfo
20 implements ClusterI.ObjectProcedure<Integer> {
21     private ClusterBase cluster;
22     private ClusterSupport support;
23     private ObjectTable ot;
24     private int n = 0;
25         public ClusterPrintDebugInfo(ClusterBase cluster, ResourceTable resourceTable
26                         , PredicateTable predicateTable, ClusterSupport support,
27                      ObjectTable ot) throws DatabaseException {
28                 this.cluster = cluster;
29                 if (null == support)
30                     throw new DatabaseException("Illegal argument.");
31                 this.support = support;
32                 this.ot = ot;
33         }
34         
35     @Override
36     public boolean execute(Integer i, int resourceRef) {
37         int resourceKey;
38         try {
39             resourceKey = ClusterTraits.createResourceKey(cluster.getClusterKey(), resourceRef);
40         } catch (DatabaseException e) {
41             e.printStackTrace();
42             return false; // continue loop
43         }
44         CalculateStatements cs = new CalculateStatements(resourceRef, ot);
45         try {
46             cluster.forPredicates(resourceKey, cs, cs, support);
47         } catch (Throwable t) {
48             t.printStackTrace();
49         }
50         return false; // continue loop
51     }
52         public int getSize() {
53                 return n;
54         }
55         
56 }