X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.spreadsheet.graph%2Fsrc%2Forg%2Fsimantics%2Fspreadsheet%2Fgraph%2Fadapter%2FSheetVariableSpaceManipulator.java;fp=bundles%2Forg.simantics.spreadsheet.graph%2Fsrc%2Forg%2Fsimantics%2Fspreadsheet%2Fgraph%2Fadapter%2FSheetVariableSpaceManipulator.java;h=82ace910d0f521473b92caa0c917e37d302916f4;hb=0ae2b770234dfc3cbb18bd38f324125cf0faca07;hp=66adc074130e0ea3dabb3dd3d86826f8c9075e71;hpb=24e2b34260f219f0d1644ca7a138894980e25b14;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.spreadsheet.graph/src/org/simantics/spreadsheet/graph/adapter/SheetVariableSpaceManipulator.java b/bundles/org.simantics.spreadsheet.graph/src/org/simantics/spreadsheet/graph/adapter/SheetVariableSpaceManipulator.java index 66adc0741..82ace910d 100644 --- a/bundles/org.simantics.spreadsheet.graph/src/org/simantics/spreadsheet/graph/adapter/SheetVariableSpaceManipulator.java +++ b/bundles/org.simantics.spreadsheet.graph/src/org/simantics/spreadsheet/graph/adapter/SheetVariableSpaceManipulator.java @@ -1,43 +1,43 @@ -package org.simantics.spreadsheet.graph.adapter; - -import org.simantics.databoard.Bindings; -import org.simantics.db.Resource; -import org.simantics.db.WriteGraph; -import org.simantics.db.exception.DatabaseException; -import org.simantics.db.layer0.variable.Variable; -import org.simantics.db.layer0.variable.VariableSpaceManipulator; -import org.simantics.layer0.Layer0; - -public class SheetVariableSpaceManipulator implements VariableSpaceManipulator { - - private Variable variable; - public SheetVariableSpaceManipulator(Variable variable) { - this.variable = variable; - } - - @Override - public void apply(WriteGraph graph, Modification modification) throws DatabaseException { - - Layer0 L0 = Layer0.getInstance(graph); - for(String name : modification.removedChildren) { - Variable child = variable.getChild(graph, name); - Resource represents = child.getRepresents(graph); - graph.deny(represents, L0.PartOf); - } - - for(ChildCreationData data : modification.newChildren) { - Resource container = variable.getRepresents(graph); - Resource cell = graph.newResource(); - Resource type = graph.getResource(data.type); - graph.claim(cell, L0.InstanceOf, null, type); - graph.addLiteral(cell, L0.HasName, L0.NameOf, L0.String, data.name, Bindings.STRING); - for(PropertyCreationData p : data.properties) { - Resource property = graph.getResource(p.name); - graph.claimLiteral(cell, property, p.value.getValue()); - } - graph.claim(cell, L0.PartOf, container); - - } - } - -} +package org.simantics.spreadsheet.graph.adapter; + +import org.simantics.databoard.Bindings; +import org.simantics.db.Resource; +import org.simantics.db.WriteGraph; +import org.simantics.db.exception.DatabaseException; +import org.simantics.db.layer0.variable.Variable; +import org.simantics.db.layer0.variable.VariableSpaceManipulator; +import org.simantics.layer0.Layer0; + +public class SheetVariableSpaceManipulator implements VariableSpaceManipulator { + + private Variable variable; + public SheetVariableSpaceManipulator(Variable variable) { + this.variable = variable; + } + + @Override + public void apply(WriteGraph graph, Modification modification) throws DatabaseException { + + Layer0 L0 = Layer0.getInstance(graph); + for(String name : modification.removedChildren) { + Variable child = variable.getChild(graph, name); + Resource represents = child.getRepresents(graph); + graph.deny(represents, L0.PartOf); + } + + for(ChildCreationData data : modification.newChildren) { + Resource container = variable.getRepresents(graph); + Resource cell = graph.newResource(); + Resource type = graph.getResource(data.type); + graph.claim(cell, L0.InstanceOf, null, type); + graph.addLiteral(cell, L0.HasName, L0.NameOf, L0.String, data.name, Bindings.STRING); + for(PropertyCreationData p : data.properties) { + Resource property = graph.getResource(p.name); + graph.claimLiteral(cell, property, p.value.getValue()); + } + graph.claim(cell, L0.PartOf, container); + + } + } + +}