]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.modeling/src/org/simantics/modeling/utils/VariableReferences.java
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.modeling / src / org / simantics / modeling / utils / VariableReferences.java
index c995f723c0510da05b5adee98cb3f60a1a964355..9d0f8312ea7397ce7a79aad8356f16fb9a9698ae 100644 (file)
@@ -1,89 +1,89 @@
-package org.simantics.modeling.utils;\r
-\r
-import java.util.ArrayList;\r
-import java.util.List;\r
-\r
-import org.simantics.databoard.type.Datatype;\r
-import org.simantics.databoard.util.ObjectUtils;\r
-import org.simantics.db.ReadGraph;\r
-import org.simantics.db.Resource;\r
-import org.simantics.db.exception.DatabaseException;\r
-import org.simantics.db.layer0.variable.RVI;\r
-import org.simantics.db.layer0.variable.Variable;\r
-import org.simantics.db.layer0.variable.VariableReference;\r
-import org.simantics.db.layer0.variable.Variables;\r
-import org.simantics.db.request.Read;\r
-import org.simantics.modeling.PropertyVariables;\r
-\r
-/**\r
- * A intermediate hack solution for converting variables to variable references.\r
- * {@link NodeReference}s and {@link Datatype}s for subscription and charting\r
- * purposes.\r
- * \r
- * @author Tuukka Lehtonen\r
- */\r
-public final class VariableReferences {\r
-\r
-    public static Read<List<VariableReference>> toReferences(final List<PropertyVariables> vars) {\r
-        return toReferences(null, vars);\r
-    }\r
-\r
-    public static Read<List<VariableReference>> toReferences(final Resource expectedModel, final List<PropertyVariables> vars) {\r
-        return new Read<List<VariableReference>>() {\r
-            @Override\r
-            public List<VariableReference> perform(ReadGraph graph) throws DatabaseException {\r
-                List<VariableReference> result = new ArrayList<VariableReference>();\r
-                for (PropertyVariables v : vars) {\r
-                    if (expectedModel != null) {\r
-                        // Check that the model of the variable matches the target model.\r
-                        Resource model = Variables.getModel(graph, v.getContainer());\r
-                        if (!ObjectUtils.objectEquals(expectedModel, model))\r
-                            continue;\r
-                    }\r
-\r
-                    Datatype datatype = v.getVisualVariable().getPossibleDatatype(graph);\r
-\r
-//                    System.out.println("URI1: " + v.getContainer().getURI(graph));\r
-//                    System.out.println("URI2: " + v.getExperiment().getURI(graph));\r
-//                    System.out.println("URI3: " + v.getProperty().getURI(graph));\r
-//                    System.out.println("RVI: " + Variables.getRVI(graph, v.getProperty()));\r
-                    RVI rvi = Variables.getRVI2(graph, v.getVisualVariable());\r
-//                    String rvi = Variables.getRVI(graph, v.getVisualVariable());\r
-//                    String nodeReference = rvi.replaceFirst("/", "");\r
-//                    System.out.println("NODEREF: " + nodeReference);\r
-//                    System.out.println("DATATYPE: " + datatype);\r
-                    result.add( VariableReference.of( rvi, datatype, null ) );\r
-                }\r
-                return result;\r
-            }\r
-        };\r
-    }\r
-\r
-    public static Read<List<VariableReference>> variablesToReferences(final List<Variable> vars) {\r
-        return variablesToReferences((Resource) null, vars);\r
-    }\r
-\r
-    public static Read<List<VariableReference>> variablesToReferences(final Resource expectedModel, final List<Variable> vars) {\r
-        return new Read<List<VariableReference>>() {\r
-            @Override\r
-            public List<VariableReference> perform(ReadGraph graph) throws DatabaseException {\r
-                List<VariableReference> result = new ArrayList<VariableReference>();\r
-                for (Variable v : vars) {\r
-                    if (expectedModel != null) {\r
-                        // Check that the model of the variable matches the target model.\r
-                        Resource model = Variables.getModel(graph, v);\r
-                        if (!ObjectUtils.objectEquals(expectedModel, model))\r
-                            continue;\r
-                    }\r
-                    Datatype datatype = v.getPossibleDatatype(graph);\r
-                    RVI rvi = Variables.getRVI2(graph, v);\r
-//                    String rvi = Variables.getRVI(graph, v);\r
-//                    String nodeReference = rvi.replaceFirst("/", "");\r
-                    result.add( VariableReference.of( rvi, datatype, null ) );\r
-                }\r
-                return result;\r
-            }\r
-        };\r
-    }\r
-\r
-}\r
+package org.simantics.modeling.utils;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.simantics.databoard.type.Datatype;
+import org.simantics.databoard.util.ObjectUtils;
+import org.simantics.db.ReadGraph;
+import org.simantics.db.Resource;
+import org.simantics.db.exception.DatabaseException;
+import org.simantics.db.layer0.variable.RVI;
+import org.simantics.db.layer0.variable.Variable;
+import org.simantics.db.layer0.variable.VariableReference;
+import org.simantics.db.layer0.variable.Variables;
+import org.simantics.db.request.Read;
+import org.simantics.modeling.PropertyVariables;
+
+/**
+ * A intermediate hack solution for converting variables to variable references.
+ * {@link NodeReference}s and {@link Datatype}s for subscription and charting
+ * purposes.
+ * 
+ * @author Tuukka Lehtonen
+ */
+public final class VariableReferences {
+
+    public static Read<List<VariableReference>> toReferences(final List<PropertyVariables> vars) {
+        return toReferences(null, vars);
+    }
+
+    public static Read<List<VariableReference>> toReferences(final Resource expectedModel, final List<PropertyVariables> vars) {
+        return new Read<List<VariableReference>>() {
+            @Override
+            public List<VariableReference> perform(ReadGraph graph) throws DatabaseException {
+                List<VariableReference> result = new ArrayList<VariableReference>();
+                for (PropertyVariables v : vars) {
+                    if (expectedModel != null) {
+                        // Check that the model of the variable matches the target model.
+                        Resource model = Variables.getModel(graph, v.getContainer());
+                        if (!ObjectUtils.objectEquals(expectedModel, model))
+                            continue;
+                    }
+
+                    Datatype datatype = v.getVisualVariable().getPossibleDatatype(graph);
+
+//                    System.out.println("URI1: " + v.getContainer().getURI(graph));
+//                    System.out.println("URI2: " + v.getExperiment().getURI(graph));
+//                    System.out.println("URI3: " + v.getProperty().getURI(graph));
+//                    System.out.println("RVI: " + Variables.getRVI(graph, v.getProperty()));
+                    RVI rvi = Variables.getRVI2(graph, v.getVisualVariable());
+//                    String rvi = Variables.getRVI(graph, v.getVisualVariable());
+//                    String nodeReference = rvi.replaceFirst("/", "");
+//                    System.out.println("NODEREF: " + nodeReference);
+//                    System.out.println("DATATYPE: " + datatype);
+                    result.add( VariableReference.of( rvi, datatype, null ) );
+                }
+                return result;
+            }
+        };
+    }
+
+    public static Read<List<VariableReference>> variablesToReferences(final List<Variable> vars) {
+        return variablesToReferences((Resource) null, vars);
+    }
+
+    public static Read<List<VariableReference>> variablesToReferences(final Resource expectedModel, final List<Variable> vars) {
+        return new Read<List<VariableReference>>() {
+            @Override
+            public List<VariableReference> perform(ReadGraph graph) throws DatabaseException {
+                List<VariableReference> result = new ArrayList<VariableReference>();
+                for (Variable v : vars) {
+                    if (expectedModel != null) {
+                        // Check that the model of the variable matches the target model.
+                        Resource model = Variables.getModel(graph, v);
+                        if (!ObjectUtils.objectEquals(expectedModel, model))
+                            continue;
+                    }
+                    Datatype datatype = v.getPossibleDatatype(graph);
+                    RVI rvi = Variables.getRVI2(graph, v);
+//                    String rvi = Variables.getRVI(graph, v);
+//                    String nodeReference = rvi.replaceFirst("/", "");
+                    result.add( VariableReference.of( rvi, datatype, null ) );
+                }
+                return result;
+            }
+        };
+    }
+
+}