X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.spreadsheet.graph%2Fsrc%2Forg%2Fsimantics%2Fspreadsheet%2Fgraph%2FSources.java;fp=bundles%2Forg.simantics.spreadsheet.graph%2Fsrc%2Forg%2Fsimantics%2Fspreadsheet%2Fgraph%2FSources.java;h=97b16e803bff278e81887eb85674dce0f3bb0646;hb=0ae2b770234dfc3cbb18bd38f324125cf0faca07;hp=8d1cfd0166dc672b24c2ead9260635ac3f9882f8;hpb=24e2b34260f219f0d1644ca7a138894980e25b14;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.spreadsheet.graph/src/org/simantics/spreadsheet/graph/Sources.java b/bundles/org.simantics.spreadsheet.graph/src/org/simantics/spreadsheet/graph/Sources.java index 8d1cfd016..97b16e803 100644 --- a/bundles/org.simantics.spreadsheet.graph/src/org/simantics/spreadsheet/graph/Sources.java +++ b/bundles/org.simantics.spreadsheet.graph/src/org/simantics/spreadsheet/graph/Sources.java @@ -1,49 +1,49 @@ -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> { - - public Sources(Variable variable) { - super(variable); - } - - @Override - public Map 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 result = new HashMap(); - for(Resource source : query.find(graph, indexRoot)) { - - Variable sv = Variables.getVariable(graph, source); - @SuppressWarnings("rawtypes") - Function f = sv.getPropertyValue(graph, SHEET.SourceContribution_function); - List in = Simantics.>applySCLRead(graph, f, variable.getRepresents(graph)); - for(Variable var : in) { - Function f2 = sv.getPropertyValue(graph, SHEET.SourceContribution_labeler); - String key = Simantics.applySCLRead(graph, f2, var); - result.put(key, var); - } - } - return result; - } - -} +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> { + + public Sources(Variable variable) { + super(variable); + } + + @Override + public Map 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 result = new HashMap(); + for(Resource source : query.find(graph, indexRoot)) { + + Variable sv = Variables.getVariable(graph, source); + @SuppressWarnings("rawtypes") + Function f = sv.getPropertyValue(graph, SHEET.SourceContribution_function); + List in = Simantics.>applySCLRead(graph, f, variable.getRepresents(graph)); + for(Variable var : in) { + Function f2 = sv.getPropertyValue(graph, SHEET.SourceContribution_labeler); + String key = Simantics.applySCLRead(graph, f2, var); + result.put(key, var); + } + } + return result; + } + +}