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.db;
14 import org.simantics.databoard.binding.Binding;
15 import org.simantics.db.exception.BindingException;
16 import org.simantics.db.exception.ClusterSetExistException;
17 import org.simantics.db.exception.DatabaseException;
18 import org.simantics.db.exception.ManyObjectsForFunctionalRelationException;
19 import org.simantics.db.exception.ResourceNotFoundException;
20 import org.simantics.db.exception.ServiceException;
21 import org.simantics.db.request.AsyncMultiRead;
22 import org.simantics.db.request.Write;
23 import org.simantics.db.request.WriteOnly;
24 import org.simantics.db.request.WriteTraits;
28 * For accessing and manipulating the graph data.
30 * Instantiated by Session for use only during a transaction.
32 * @author Antti Villberg
37 public interface WriteOnlyGraph extends ServiceLocator, MetadataI {
39 Resource getRootLibrary();
42 * Gets a builtin resource. For a list of builtin resources see TODO Wiki
44 * @param uri the identifier
45 * @return the resource
46 * @throws ResourceNotFoundException if resouce was not found
47 * @throws ServiceException on connection and database failures
48 * @see AsyncReadGraph#forBuiltin
50 Resource getBuiltin(String id) throws ResourceNotFoundException, ServiceException;
53 * Creates a new resource.
54 * @throws ServiceException
56 * @returns the new resource
58 Resource newResource() throws ServiceException;
61 * Creates a resource into the specified cluster.
63 * @param clusterId the ID of the cluster to create the resource into
64 * @throws ServiceException
65 * @returns the new resource
67 Resource newResource(long clusterId) throws ServiceException;
70 * Creates a resource into the specified cluster set.
72 * @param clusterSet identifies the cluster set which must exist.
73 * @throws ServiceException
74 * @throws ClusterSetExistException if cluster set does not exist.
75 * @returns the new resource
78 Resource newResource(Resource clusterSet) throws ServiceException, ClusterSetExistException;
81 * Creates a new cluster set.
83 * @param clusterSet identifies the created cluster set.
84 * @throws ServiceException
85 * @throws ClusterSetExistException if cluster set exists already.
87 void newClusterSet(Resource clusterSet) throws ServiceException, ClusterSetExistException;
89 * Sets cluster set to be used for {@link #newResource()} method.
90 * If cluster set is null then newResource behaves as before.
93 * @return old cluster set.
94 * @throws ServiceException
96 Resource setClusterSet4NewResource(Resource clusterSet) throws ServiceException;
99 * Makes sure that the statements (s,p,o) and (o,i,s) are found in the
100 * graph. It is not asserted that p is an inverse relation of i, this is
101 * assumed and considered to be the client's responsibility.
104 * If no inverse relation (o,i,s) is desired, <code>null</code> may be given as inverse.
112 void claim(Resource subject, Resource predicate, Resource inverse, Resource object) throws ServiceException;
115 * Stores the specified literal value (boxed primitive/String or
116 * primitive/String array) into the specified resource. Any previous value
119 * @param resource the resource to store the literal value into
120 * @param value the literal value
122 void claimValue(Resource resource, Object value) throws ServiceException;
123 void claimValue(Resource resource, Object value, Binding binding) throws ServiceException;
125 void addLiteral(Resource resource, Resource predicate, Resource inverse, Object value, Binding binding) throws BindingException, ManyObjectsForFunctionalRelationException, ServiceException;
126 void addLiteral(Resource resource, Resource predicate, Resource inverse, Resource type, Object value, Binding binding) throws BindingException, ManyObjectsForFunctionalRelationException, ServiceException;
129 * Makes sure that the statements (s,p,o) and (o,i,s) are no longer found in
130 * the graph. It is not asserted that p is an inverse relation of i, this is
131 * assumed and considered to be the client's responsibility.
138 void deny(Resource subject, Resource predicate, Resource inverse, Resource object, VirtualGraph graph) throws ServiceException;
141 * If there is a literal value associated with the specified resource, it is
142 * removed. Otherwise does nothing.
146 void denyValue(Resource resource) throws ServiceException;
147 void denyValue(Resource resource, VirtualGraph graph) throws ServiceException;
150 * Ends writing into the current cluster and starts a new one. Any resources
151 * created with {@link #newResource()} after this call will go into the new
154 void flushCluster() throws ServiceException;
157 * Flush all modified data in the given cluster stream to server.
159 * @param r is resource used to identify cluster. If null then all clusters
160 * streams are flushed.
162 void flushCluster(Resource r) throws ServiceException;
165 * Synchronously performs the given {@link WriteOnly}.
167 * @param request an instance of {@link Write}.
169 void syncRequest(WriteOnly r) throws DatabaseException;
173 VirtualGraph getProvider();
176 * After current request is processed the undo list is cleared.
178 void clearUndoList(WriteTraits writeTraits);
180 boolean isImmutable(Resource resource) throws DatabaseException;
183 * Marks the beginning of the ongoing write transaction as an undo point.
184 * Calling this method several times during the same transaction has no
187 void markUndoPoint();