X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.spreadsheet.graph%2Fsrc%2Forg%2Fsimantics%2Fspreadsheet%2Fgraph%2FSheets.java;fp=bundles%2Forg.simantics.spreadsheet.graph%2Fsrc%2Forg%2Fsimantics%2Fspreadsheet%2Fgraph%2FSheets.java;h=23ce784affd8ea2f44e2626db2c207672c1f1622;hb=0ae2b770234dfc3cbb18bd38f324125cf0faca07;hp=cd6105027641c0e9a60b67ff04aef281f001c94e;hpb=24e2b34260f219f0d1644ca7a138894980e25b14;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.spreadsheet.graph/src/org/simantics/spreadsheet/graph/Sheets.java b/bundles/org.simantics.spreadsheet.graph/src/org/simantics/spreadsheet/graph/Sheets.java index cd6105027..23ce784af 100644 --- a/bundles/org.simantics.spreadsheet.graph/src/org/simantics/spreadsheet/graph/Sheets.java +++ b/bundles/org.simantics.spreadsheet.graph/src/org/simantics/spreadsheet/graph/Sheets.java @@ -1,41 +1,41 @@ -package org.simantics.spreadsheet.graph; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; - -import org.simantics.databoard.Bindings; -import org.simantics.db.ReadGraph; -import org.simantics.db.Resource; -import org.simantics.db.common.request.ObjectsWithType; -import org.simantics.db.exception.DatabaseException; -import org.simantics.db.layer0.request.VariableRead; -import org.simantics.db.layer0.variable.Variable; -import org.simantics.layer0.Layer0; -import org.simantics.spreadsheet.resource.SpreadsheetResource; - -public class Sheets extends VariableRead> { - - public Sheets(Variable variable) { - super(variable); - } - - @Override - public List perform(ReadGraph graph) throws DatabaseException { - Resource book = variable.getParent(graph).getRepresents(graph); - Layer0 L0 = Layer0.getInstance(graph); - Collection sheets = graph.syncRequest(new ObjectsWithType(book, L0.ConsistsOf, SpreadsheetResource.getInstance(graph).Spreadsheet)); - List result = new ArrayList<>(sheets.size()); - sheets.forEach(sheet -> { - try { - String name = graph.getPossibleRelatedValue(sheet, L0.HasName, Bindings.STRING); - result.add(name); - } catch (Exception e) { - e.printStackTrace(); - } - }); - return result; - - } - -} +package org.simantics.spreadsheet.graph; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + +import org.simantics.databoard.Bindings; +import org.simantics.db.ReadGraph; +import org.simantics.db.Resource; +import org.simantics.db.common.request.ObjectsWithType; +import org.simantics.db.exception.DatabaseException; +import org.simantics.db.layer0.request.VariableRead; +import org.simantics.db.layer0.variable.Variable; +import org.simantics.layer0.Layer0; +import org.simantics.spreadsheet.resource.SpreadsheetResource; + +public class Sheets extends VariableRead> { + + public Sheets(Variable variable) { + super(variable); + } + + @Override + public List perform(ReadGraph graph) throws DatabaseException { + Resource book = variable.getParent(graph).getRepresents(graph); + Layer0 L0 = Layer0.getInstance(graph); + Collection sheets = graph.syncRequest(new ObjectsWithType(book, L0.ConsistsOf, SpreadsheetResource.getInstance(graph).Spreadsheet)); + List result = new ArrayList<>(sheets.size()); + sheets.forEach(sheet -> { + try { + String name = graph.getPossibleRelatedValue(sheet, L0.HasName, Bindings.STRING); + result.add(name); + } catch (Exception e) { + e.printStackTrace(); + } + }); + return result; + + } + +}