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