-package org.simantics.spreadsheet.graph;\r
-\r
-import java.util.Collections;\r
-import java.util.HashMap;\r
-import java.util.List;\r
-import java.util.Map;\r
-\r
-import org.simantics.Simantics;\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.adapter.Instances;\r
-import org.simantics.db.layer0.request.VariableRead;\r
-import org.simantics.db.layer0.variable.Variable;\r
-import org.simantics.db.layer0.variable.Variables;\r
-import org.simantics.scl.runtime.function.Function;\r
-import org.simantics.spreadsheet.resource.SpreadsheetResource;\r
-\r
-public class Sources extends VariableRead<Map<String,Variable>> {\r
-\r
- public Sources(Variable variable) {\r
- super(variable);\r
- }\r
-\r
- @Override\r
- public Map<String,Variable> perform(ReadGraph graph) throws DatabaseException {\r
- \r
- SpreadsheetResource SHEET = SpreadsheetResource.getInstance(graph);\r
- Instances query = graph.adapt(SHEET.SourceContribution, Instances.class);\r
- Resource indexRoot = variable.getIndexRoot(graph);\r
- if(indexRoot == null) return Collections.emptyMap();\r
- \r
- Map<String,Variable> result = new HashMap<String,Variable>();\r
- for(Resource source : query.find(graph, indexRoot)) {\r
-\r
- Variable sv = Variables.getVariable(graph, source);\r
- @SuppressWarnings("rawtypes")\r
- Function f = sv.getPropertyValue(graph, SHEET.SourceContribution_function);\r
- List<Variable> in = Simantics.<List<Variable>>applySCLRead(graph, f, variable.getRepresents(graph));\r
- for(Variable var : in) {\r
- Function f2 = sv.getPropertyValue(graph, SHEET.SourceContribution_labeler);\r
- String key = Simantics.<String>applySCLRead(graph, f2, var);\r
- result.put(key, var);\r
- }\r
- }\r
- return result;\r
- }\r
- \r
-}\r
+package org.simantics.spreadsheet.graph;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.simantics.Simantics;
+import org.simantics.db.ReadGraph;
+import org.simantics.db.Resource;
+import org.simantics.db.exception.DatabaseException;
+import org.simantics.db.layer0.adapter.Instances;
+import org.simantics.db.layer0.request.VariableRead;
+import org.simantics.db.layer0.variable.Variable;
+import org.simantics.db.layer0.variable.Variables;
+import org.simantics.scl.runtime.function.Function;
+import org.simantics.spreadsheet.resource.SpreadsheetResource;
+
+public class Sources extends VariableRead<Map<String,Variable>> {
+
+ public Sources(Variable variable) {
+ super(variable);
+ }
+
+ @Override
+ public Map<String,Variable> perform(ReadGraph graph) throws DatabaseException {
+
+ SpreadsheetResource SHEET = SpreadsheetResource.getInstance(graph);
+ Instances query = graph.adapt(SHEET.SourceContribution, Instances.class);
+ Resource indexRoot = variable.getIndexRoot(graph);
+ if(indexRoot == null) return Collections.emptyMap();
+
+ Map<String,Variable> result = new HashMap<String,Variable>();
+ for(Resource source : query.find(graph, indexRoot)) {
+
+ Variable sv = Variables.getVariable(graph, source);
+ @SuppressWarnings("rawtypes")
+ Function f = sv.getPropertyValue(graph, SHEET.SourceContribution_function);
+ List<Variable> in = Simantics.<List<Variable>>applySCLRead(graph, f, variable.getRepresents(graph));
+ for(Variable var : in) {
+ Function f2 = sv.getPropertyValue(graph, SHEET.SourceContribution_labeler);
+ String key = Simantics.<String>applySCLRead(graph, f2, var);
+ result.put(key, var);
+ }
+ }
+ return result;
+ }
+
+}