]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.layer0.utils/src/org/simantics/layer0/utils/writer/GraphWriterPartial.java
Migrated source code from Simantics SVN
[simantics/platform.git] / bundles / org.simantics.layer0.utils / src / org / simantics / layer0 / utils / writer / GraphWriterPartial.java
1 /*******************************************************************************\r
2  * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
3  * in Industry THTH ry.\r
4  * All rights reserved. This program and the accompanying materials\r
5  * are made available under the terms of the Eclipse Public License v1.0\r
6  * which accompanies this distribution, and is available at\r
7  * http://www.eclipse.org/legal/epl-v10.html\r
8  *\r
9  * Contributors:\r
10  *     VTT Technical Research Centre of Finland - initial API and implementation\r
11  *******************************************************************************/\r
12 package org.simantics.layer0.utils.writer;\r
13 \r
14 import org.simantics.db.ReadGraph;\r
15 import org.simantics.db.Resource;\r
16 import org.simantics.db.exception.DatabaseException;\r
17 import org.simantics.db.service.ClusteringSupport;\r
18 import org.simantics.layer0.Layer0;\r
19 \r
20 public abstract class GraphWriterPartial implements GraphWriter {\r
21 \r
22         ClusteringSupport clustering;\r
23         ReadGraph graph;\r
24         Layer0 l0;\r
25         \r
26         public GraphWriterPartial(ReadGraph graph) {    \r
27                 this.graph = graph;\r
28                 this.l0 = Layer0.getInstance(graph);\r
29                 clustering = graph.getSession().getService(ClusteringSupport.class);\r
30         }\r
31         \r
32         @Override\r
33         public ReadGraph getGraph() {\r
34                 return graph;\r
35         }\r
36         \r
37 //      @Override\r
38 //      public GraphWriter create(Resource type) {\r
39 //              return create(type);\r
40 //              return let(b.InstanceOf, type);\r
41 //      }\r
42         \r
43         @Override\r
44         public GraphWriter create(String name, Resource type) throws DatabaseException  {\r
45                 create(type);\r
46                 return let(l0.HasName, name, l0.String);\r
47         }\r
48         \r
49         @Override\r
50         public GraphWriter create(int clusterHint, String name, Resource type) throws DatabaseException {\r
51                 create(clusterHint, type);\r
52                 return let(clusterHint, l0.HasName, name, l0.String);\r
53         }\r
54         \r
55         @Override\r
56         public GraphWriter create(int clusterHint) throws DatabaseException {\r
57                 return create();\r
58         }\r
59         \r
60         @Override\r
61         public GraphWriter create(int clusterHint, Resource type) throws DatabaseException {\r
62                 return create(type);\r
63         }\r
64         \r
65         @Override\r
66         public GraphWriter let(int clusterHint, Resource p, Object value,\r
67                 Resource dataType) throws DatabaseException {\r
68                 return let(p, value, dataType);\r
69         }\r
70         \r
71         @Override\r
72         public GraphWriter createLiteral(int clusterHint, Object value,\r
73                 Resource dataType) throws DatabaseException {\r
74                 return createLiteral(value, dataType);\r
75         }\r
76 \r
77     @Override\r
78     public GraphWriter stat(Resource s, Resource p, Resource o) throws DatabaseException {\r
79         return handle(s).let(p, o);     \r
80     }   \r
81     \r
82     @Override\r
83     public GraphWriter createInverse(int clusterHint, Resource r) throws DatabaseException {\r
84         return createInverse(r);\r
85     }\r
86     \r
87 }\r