]> gerrit.simantics Code Review - simantics/sysdyn.git/blob
40d096b40e3432eac3edea8f6afe2686b60869e2
[simantics/sysdyn.git] /
1 package org.simantics.sysdyn.modelImport.model;\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 \r
13 public class IntegralExpression implements IExpression {\r
14         \r
15         private String integral;\r
16         private String initial;\r
17         \r
18         public IntegralExpression(String integral, String initial) {\r
19                 this.integral = integral;\r
20                 this.initial = initial;\r
21         }\r
22         \r
23         @Override\r
24         public void write(WriteGraph graph, Resource parent) throws DatabaseException {\r
25                 Layer0 l0 = Layer0.getInstance(graph);\r
26                 SysdynResource sr = SysdynResource.getInstance(graph);\r
27                 \r
28                 Resource expression = GraphUtils.create2(graph, sr.StockExpression,\r
29                                 sr.StockExpression_integralEquation, integral,\r
30                                 sr.StockExpression_initialEquation, initial,\r
31                                 l0.PartOf, parent);\r
32                 // TODO: why is the expression stored in two places?\r
33                 graph.claim(parent, sr.Variable_expressionList, ListUtils.create(graph, Arrays.asList(expression)));\r
34         }\r
35 \r
36 }\r