1 package org.simantics.sysdyn.modelImport.model.expression;
\r
3 import java.util.Arrays;
\r
5 import org.simantics.db.ReadGraph;
\r
6 import org.simantics.db.Resource;
\r
7 import org.simantics.db.WriteGraph;
\r
8 import org.simantics.db.common.utils.ListUtils;
\r
9 import org.simantics.db.exception.DatabaseException;
\r
10 import org.simantics.layer0.Layer0;
\r
11 import org.simantics.layer0.utils.direct.GraphUtils;
\r
12 import org.simantics.sysdyn.SysdynResource;
\r
13 import org.simantics.sysdyn.modelImport.model.IWriteableObject;
\r
14 import org.simantics.sysdyn.modelImport.model.WriteContext;
\r
16 public abstract class Expression implements IWriteableObject {
\r
18 private Resource expr;
\r
21 public Resource write(WriteGraph graph, Resource parent, WriteContext context) throws DatabaseException {
\r
22 Layer0 l0 = Layer0.getInstance(graph);
\r
23 SysdynResource sr = SysdynResource.getInstance(graph);
\r
25 expr = GraphUtils.create2(graph, getExpressionType(graph),
\r
28 // insert the expression into the expression list of the variable
\r
29 // (necessary because of enumeration expressions)
\r
30 Resource list = graph.getPossibleObject(parent, sr.Variable_expressionList);
\r
32 ListUtils.insertBack(graph, list, Arrays.asList(expr));
\r
34 graph.claim(parent, sr.Variable_expressionList, ListUtils.create(graph, Arrays.asList(expr)));
\r
39 public abstract Resource getExpressionType(ReadGraph graph);
\r
42 public Resource getResource() {
\r