1 /*******************************************************************************
2 * Copyright (c) 2007, 2010 Association for Decentralized Information Management
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
10 * VTT Technical Research Centre of Finland - initial API and implementation
11 *******************************************************************************/
12 package org.simantics.layer0.utils.writer;
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;
20 public abstract class GraphWriterPartial implements GraphWriter {
22 ClusteringSupport clustering;
26 public GraphWriterPartial(ReadGraph graph) {
28 this.l0 = Layer0.getInstance(graph);
29 clustering = graph.getSession().getService(ClusteringSupport.class);
33 public ReadGraph getGraph() {
38 // public GraphWriter create(Resource type) {
39 // return create(type);
40 // return let(b.InstanceOf, type);
44 public GraphWriter create(String name, Resource type) throws DatabaseException {
46 return let(l0.HasName, name, l0.String);
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);
56 public GraphWriter create(int clusterHint) throws DatabaseException {
61 public GraphWriter create(int clusterHint, Resource type) throws DatabaseException {
66 public GraphWriter let(int clusterHint, Resource p, Object value,
67 Resource dataType) throws DatabaseException {
68 return let(p, value, dataType);
72 public GraphWriter createLiteral(int clusterHint, Object value,
73 Resource dataType) throws DatabaseException {
74 return createLiteral(value, dataType);
78 public GraphWriter stat(Resource s, Resource p, Resource o) throws DatabaseException {
79 return handle(s).let(p, o);
83 public GraphWriter createInverse(int clusterHint, Resource r) throws DatabaseException {
84 return createInverse(r);