]> gerrit.simantics Code Review - simantics/sysdyn.git/blob
296fe5c55890bad07ef5b6429d33f77e037f0d82
[simantics/sysdyn.git] /
1 package org.simantics.sysdyn.modelImport.model.expression;\r
2 \r
3 import java.util.Arrays;\r
4 \r
5 import org.simantics.db.Resource;\r
6 import org.simantics.db.WriteGraph;\r
7 import org.simantics.db.common.utils.ListUtils;\r
8 import org.simantics.db.exception.DatabaseException;\r
9 import org.simantics.layer0.Layer0;\r
10 import org.simantics.layer0.utils.direct.GraphUtils;\r
11 import org.simantics.sysdyn.SysdynResource;\r
12 import org.simantics.sysdyn.modelImport.model.WriteContext;\r
13 \r
14 public class NormalExpression implements IExpression {\r
15 \r
16         private String equation;\r
17         \r
18         public NormalExpression(String equation) {\r
19                 this.equation = equation;\r
20         }\r
21 \r
22         @Override\r
23         public void write(WriteGraph graph, Resource variable, WriteContext context) throws DatabaseException {\r
24                 Layer0 l0 = Layer0.getInstance(graph);\r
25                 SysdynResource sr = SysdynResource.getInstance(graph);\r
26 \r
27                 Resource expression = GraphUtils.create2(graph, sr.NormalExpression,\r
28                                 sr.Expression_equation, equation,\r
29                                 l0.PartOf, variable);\r
30                 // TODO: why is the expression stored in two places?\r
31                 graph.claim(variable, sr.Variable_expressionList, ListUtils.create(graph, Arrays.asList(expression)));\r
32         }\r
33 }\r