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