]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.db.common/src/org/simantics/db/common/request/DependentInstances3.java
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.db.common / src / org / simantics / db / common / request / DependentInstances3.java
index 9ef98c8bbec771ec968dad0fbad1753f87a2d8a3..e0e53493774fb81e4242f9d4cb8798213b2cce06 100644 (file)
@@ -1,84 +1,84 @@
-/*******************************************************************************\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.common.request;\r
-\r
-import java.util.Set;\r
-\r
-import org.simantics.db.ReadGraph;\r
-import org.simantics.db.Resource;\r
-import org.simantics.db.Statement;\r
-import org.simantics.db.common.utils.NameUtils;\r
-import org.simantics.db.exception.DatabaseException;\r
-import org.simantics.db.service.CollectionSupport;\r
-import org.simantics.layer0.Layer0;\r
-import org.simantics.utils.Development;\r
-\r
-import gnu.trove.map.hash.THashMap;\r
-\r
-public class DependentInstances3 extends ResourceRead<ResourceSetGraph> {\r
-\r
-    private static final boolean DEBUG = false;\r
-\r
-    private static ThreadLocal<THashMap<DependentInstances3, ResourceSetGraph>> workArea = new ThreadLocal<THashMap<DependentInstances3, ResourceSetGraph>>() {\r
-        protected gnu.trove.map.hash.THashMap<DependentInstances3,ResourceSetGraph> initialValue() {\r
-            return new THashMap<>();\r
-        }\r
-    };\r
-\r
-       public DependentInstances3(Resource resource) {\r
-               super(resource);\r
-       }\r
-\r
-       @Override\r
-       public ResourceSetGraph perform(ReadGraph graph) throws DatabaseException {\r
-               \r
-               if(resource.equals(graph.getRootLibrary())) return new ResourceSetGraph(graph, resource);\r
-        \r
-               if(Development.DEVELOPMENT)\r
-                       if(graph.isImmutable(resource))\r
-                               System.err.println("Immutable resource in DependentInstances3: " + NameUtils.getSafeName(graph, resource, true));\r
-               \r
-        // This is a loop\r
-        THashMap<DependentInstances3, ResourceSetGraph> workingSet = workArea.get();\r
-        ResourceSetGraph result = workingSet.get(this);\r
-        if(result != null) return result;\r
-\r
-        result = new ResourceSetGraph(graph, resource);\r
-        \r
-        workingSet.put(this, result);\r
-        \r
-        CollectionSupport cs = graph.getService(CollectionSupport.class);\r
-        Set<Resource> objects = cs.createSet();\r
-        \r
-               Layer0 L0 = Layer0.getInstance(graph);\r
-               for(Statement dep : graph.getStatements(resource, L0.IsDependencyOf)) {\r
-                       if(graph.isSubrelationOf(dep.getPredicate(), L0.HasPrevious)) continue;\r
-                       Resource object = dep.getObject();\r
-                       if(graph.isImmutable(object)) continue;\r
-                       objects.add(object);\r
-               }\r
-               \r
-               for(Resource object : objects ) {\r
-            if(DEBUG)\r
-                System.err.println(NameUtils.getSafeName(graph, object, true) + " depends on " + NameUtils.getSafeName(graph, resource, true));\r
-                   DependentInstances3 query = new DependentInstances3(object);\r
-                   ResourceSetGraph instances = workingSet.get(query);\r
-                   if(instances == null) instances = graph.syncRequest(query);\r
-                       result.references.add(instances);\r
-               }\r
-               \r
-               workingSet.remove(this);\r
-               return result;\r
-               \r
-       }\r
-\r
-}\r
+/*******************************************************************************
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management
+ * in Industry THTH ry.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     VTT Technical Research Centre of Finland - initial API and implementation
+ *******************************************************************************/
+package org.simantics.db.common.request;
+
+import java.util.Set;
+
+import org.simantics.db.ReadGraph;
+import org.simantics.db.Resource;
+import org.simantics.db.Statement;
+import org.simantics.db.common.utils.NameUtils;
+import org.simantics.db.exception.DatabaseException;
+import org.simantics.db.service.CollectionSupport;
+import org.simantics.layer0.Layer0;
+import org.simantics.utils.Development;
+
+import gnu.trove.map.hash.THashMap;
+
+public class DependentInstances3 extends ResourceRead<ResourceSetGraph> {
+
+    private static final boolean DEBUG = false;
+
+    private static ThreadLocal<THashMap<DependentInstances3, ResourceSetGraph>> workArea = new ThreadLocal<THashMap<DependentInstances3, ResourceSetGraph>>() {
+        protected gnu.trove.map.hash.THashMap<DependentInstances3,ResourceSetGraph> initialValue() {
+            return new THashMap<>();
+        }
+    };
+
+       public DependentInstances3(Resource resource) {
+               super(resource);
+       }
+
+       @Override
+       public ResourceSetGraph perform(ReadGraph graph) throws DatabaseException {
+               
+               if(resource.equals(graph.getRootLibrary())) return new ResourceSetGraph(graph, resource);
+        
+               if(Development.DEVELOPMENT)
+                       if(graph.isImmutable(resource))
+                               System.err.println("Immutable resource in DependentInstances3: " + NameUtils.getSafeName(graph, resource, true));
+               
+        // This is a loop
+        THashMap<DependentInstances3, ResourceSetGraph> workingSet = workArea.get();
+        ResourceSetGraph result = workingSet.get(this);
+        if(result != null) return result;
+
+        result = new ResourceSetGraph(graph, resource);
+        
+        workingSet.put(this, result);
+        
+        CollectionSupport cs = graph.getService(CollectionSupport.class);
+        Set<Resource> objects = cs.createSet();
+        
+               Layer0 L0 = Layer0.getInstance(graph);
+               for(Statement dep : graph.getStatements(resource, L0.IsDependencyOf)) {
+                       if(graph.isSubrelationOf(dep.getPredicate(), L0.HasPrevious)) continue;
+                       Resource object = dep.getObject();
+                       if(graph.isImmutable(object)) continue;
+                       objects.add(object);
+               }
+               
+               for(Resource object : objects ) {
+            if(DEBUG)
+                System.err.println(NameUtils.getSafeName(graph, object, true) + " depends on " + NameUtils.getSafeName(graph, resource, true));
+                   DependentInstances3 query = new DependentInstances3(object);
+                   ResourceSetGraph instances = workingSet.get(query);
+                   if(instances == null) instances = graph.syncRequest(query);
+                       result.references.add(instances);
+               }
+               
+               workingSet.remove(this);
+               return result;
+               
+       }
+
+}