]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.issues.common/src/org/simantics/issues/common/ChildMaxIssueSeverity.java
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.issues.common / src / org / simantics / issues / common / ChildMaxIssueSeverity.java
index 760f75dbb06325be388ebec372bbe3e58cabddd3..1103b5f262af788774072ef3d400ada1800fea51 100644 (file)
@@ -1,97 +1,97 @@
-/*******************************************************************************\r
- * Copyright (c) 2007, 2011 Association for Decentralized Information Management in\r
- * 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.issues.common;\r
-\r
-import java.util.Collections;\r
-import java.util.Set;\r
-import java.util.concurrent.atomic.AtomicReference;\r
-\r
-import org.simantics.db.AsyncReadGraph;\r
-import org.simantics.db.Resource;\r
-import org.simantics.db.common.request.TernaryAsyncRead;\r
-import org.simantics.db.procedure.AsyncMultiProcedure;\r
-import org.simantics.db.procedure.AsyncProcedure;\r
-import org.simantics.issues.Severity;\r
-\r
-/**\r
- * @author Tuukka Lehtonen\r
- */\r
-public class ChildMaxIssueSeverity extends TernaryAsyncRead<Resource, Resource, Set<Resource>, Severity>{\r
-\r
-    public ChildMaxIssueSeverity(Resource resource, Resource childRelation, Set<Resource> typesToRecurse) {\r
-        super(resource, childRelation, typesToRecurse);\r
-    }\r
-\r
-//    @Override\r
-//    public Severity perform(ReadGraph graph) throws DatabaseException {\r
-//        Severity maxSeverity = null;\r
-//        //System.out.println("severityForChildren: " + NameUtils.getSafeName(graph, resource));\r
-//        for (Resource child : graph.getObjects(resource, resource2)) {\r
-//            Severity s = graph.syncRequest(new MaxIssueSeverityRecursive(child));\r
-//            maxSeverity = Severity.moreSevere(maxSeverity, s);\r
-//        }\r
-//        //System.out.println("severityForChildren: " + NameUtils.getSafeName(graph, resource) + " : " + maxSeverity);\r
-//        return maxSeverity;\r
-//    }\r
-\r
-    @Override\r
-    public void perform(AsyncReadGraph graph, final AsyncProcedure<Severity> procedure) {\r
-        //System.out.println(getClass().getSimpleName() + ": " + parameter);\r
-        \r
-        graph.forTypes(parameter, new AsyncProcedure<Set<Resource>>() {\r
-            @Override\r
-            public void execute(AsyncReadGraph graph, Set<Resource> result) {\r
-                if (!Collections.disjoint(parameter3, result)) {\r
-                    checkChildren(graph, procedure);\r
-                } else {\r
-                    procedure.execute(graph, null);\r
-                }\r
-            }\r
-            @Override\r
-            public void exception(AsyncReadGraph graph, Throwable throwable) {\r
-                procedure.exception(graph, throwable);\r
-            }\r
-        });\r
-    }\r
-\r
-    protected void checkChildren(AsyncReadGraph graph, final AsyncProcedure<Severity> procedure) {\r
-        graph.forEachObject(parameter, parameter2, new AsyncMultiProcedure<Resource>() {\r
-            AtomicReference<Severity> maxSeverity = new AtomicReference<Severity>();\r
-            @Override\r
-            public void execute(AsyncReadGraph graph, Resource child) {\r
-                graph.asyncRequest(new MaxIssueSeverityRecursive(child, parameter2, parameter3), new AsyncProcedure<Severity>() {\r
-                    @Override\r
-                    public void execute(AsyncReadGraph graph, Severity severity) {\r
-                        if (severity != null) {\r
-                            synchronized (maxSeverity) {\r
-                                maxSeverity.set(Severity.moreSevere(maxSeverity.get(), severity));\r
-                            }\r
-                        }\r
-                    }\r
-                    @Override\r
-                    public void exception(AsyncReadGraph graph, Throwable throwable) {\r
-                        procedure.exception(graph, throwable);\r
-                    }\r
-                });\r
-            }\r
-            @Override\r
-            public void finished(AsyncReadGraph graph) {\r
-                procedure.execute(graph, maxSeverity.get());\r
-            }\r
-            @Override\r
-            public void exception(AsyncReadGraph graph, Throwable throwable) {\r
-                procedure.exception(graph, throwable);\r
-            }\r
-        });\r
-    }\r
-\r
-}\r
+/*******************************************************************************
+ * Copyright (c) 2007, 2011 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.issues.common;
+
+import java.util.Collections;
+import java.util.Set;
+import java.util.concurrent.atomic.AtomicReference;
+
+import org.simantics.db.AsyncReadGraph;
+import org.simantics.db.Resource;
+import org.simantics.db.common.request.TernaryAsyncRead;
+import org.simantics.db.procedure.AsyncMultiProcedure;
+import org.simantics.db.procedure.AsyncProcedure;
+import org.simantics.issues.Severity;
+
+/**
+ * @author Tuukka Lehtonen
+ */
+public class ChildMaxIssueSeverity extends TernaryAsyncRead<Resource, Resource, Set<Resource>, Severity>{
+
+    public ChildMaxIssueSeverity(Resource resource, Resource childRelation, Set<Resource> typesToRecurse) {
+        super(resource, childRelation, typesToRecurse);
+    }
+
+//    @Override
+//    public Severity perform(ReadGraph graph) throws DatabaseException {
+//        Severity maxSeverity = null;
+//        //System.out.println("severityForChildren: " + NameUtils.getSafeName(graph, resource));
+//        for (Resource child : graph.getObjects(resource, resource2)) {
+//            Severity s = graph.syncRequest(new MaxIssueSeverityRecursive(child));
+//            maxSeverity = Severity.moreSevere(maxSeverity, s);
+//        }
+//        //System.out.println("severityForChildren: " + NameUtils.getSafeName(graph, resource) + " : " + maxSeverity);
+//        return maxSeverity;
+//    }
+
+    @Override
+    public void perform(AsyncReadGraph graph, final AsyncProcedure<Severity> procedure) {
+        //System.out.println(getClass().getSimpleName() + ": " + parameter);
+        
+        graph.forTypes(parameter, new AsyncProcedure<Set<Resource>>() {
+            @Override
+            public void execute(AsyncReadGraph graph, Set<Resource> result) {
+                if (!Collections.disjoint(parameter3, result)) {
+                    checkChildren(graph, procedure);
+                } else {
+                    procedure.execute(graph, null);
+                }
+            }
+            @Override
+            public void exception(AsyncReadGraph graph, Throwable throwable) {
+                procedure.exception(graph, throwable);
+            }
+        });
+    }
+
+    protected void checkChildren(AsyncReadGraph graph, final AsyncProcedure<Severity> procedure) {
+        graph.forEachObject(parameter, parameter2, new AsyncMultiProcedure<Resource>() {
+            AtomicReference<Severity> maxSeverity = new AtomicReference<Severity>();
+            @Override
+            public void execute(AsyncReadGraph graph, Resource child) {
+                graph.asyncRequest(new MaxIssueSeverityRecursive(child, parameter2, parameter3), new AsyncProcedure<Severity>() {
+                    @Override
+                    public void execute(AsyncReadGraph graph, Severity severity) {
+                        if (severity != null) {
+                            synchronized (maxSeverity) {
+                                maxSeverity.set(Severity.moreSevere(maxSeverity.get(), severity));
+                            }
+                        }
+                    }
+                    @Override
+                    public void exception(AsyncReadGraph graph, Throwable throwable) {
+                        procedure.exception(graph, throwable);
+                    }
+                });
+            }
+            @Override
+            public void finished(AsyncReadGraph graph) {
+                procedure.execute(graph, maxSeverity.get());
+            }
+            @Override
+            public void exception(AsyncReadGraph graph, Throwable throwable) {
+                procedure.exception(graph, throwable);
+            }
+        });
+    }
+
+}