]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.db/src/org/simantics/db/WriteOnlyGraph.java
Migrated source code from Simantics SVN
[simantics/platform.git] / bundles / org.simantics.db / src / org / simantics / db / WriteOnlyGraph.java
diff --git a/bundles/org.simantics.db/src/org/simantics/db/WriteOnlyGraph.java b/bundles/org.simantics.db/src/org/simantics/db/WriteOnlyGraph.java
new file mode 100644 (file)
index 0000000..5aeeef9
--- /dev/null
@@ -0,0 +1,189 @@
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
+ * in Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ *     VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.db;\r
+\r
+import org.simantics.databoard.binding.Binding;\r
+import org.simantics.db.exception.BindingException;\r
+import org.simantics.db.exception.ClusterSetExistException;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.exception.ManyObjectsForFunctionalRelationException;\r
+import org.simantics.db.exception.ResourceNotFoundException;\r
+import org.simantics.db.exception.ServiceException;\r
+import org.simantics.db.request.AsyncMultiRead;\r
+import org.simantics.db.request.Write;\r
+import org.simantics.db.request.WriteOnly;\r
+import org.simantics.db.request.WriteTraits;\r
+\r
+\r
+/**\r
+ * For accessing and manipulating the graph data.\r
+ * \r
+ * Instantiated by Session for use only during a transaction.\r
+ * \r
+ * @author Antti Villberg\r
+ * @see AsyncMultiRead\r
+ * @see Resource\r
+ * @see Statement\r
+ */\r
+public interface WriteOnlyGraph extends ServiceLocator, MetadataI {\r
+\r
+    Resource getRootLibrary();\r
+\r
+    /**\r
+     * Gets a builtin resource. For a list of builtin resources see TODO Wiki\r
+     * \r
+     * @param uri the identifier\r
+     * @return the resource\r
+     * @throws ResourceNotFoundException if resouce was not found\r
+     * @throws ServiceException on connection and database failures\r
+     * @see AsyncReadGraph#forBuiltin\r
+     */\r
+    Resource getBuiltin(String id) throws ResourceNotFoundException, ServiceException;\r
+\r
+    /**\r
+     * Creates a new resource.\r
+     * @throws ServiceException\r
+     * \r
+     * @returns the new resource\r
+     */\r
+    Resource newResource() throws ServiceException;\r
+\r
+    /**\r
+     * Creates a resource into the specified cluster.\r
+     * \r
+     * @param clusterId the ID of the cluster to create the resource into\r
+     * @throws ServiceException\r
+     * @returns the new resource\r
+     */\r
+    Resource newResource(long clusterId) throws ServiceException;\r
+\r
+    /**\r
+     * Creates a resource into the specified cluster set.\r
+     * \r
+     * @param clusterSet identifies the cluster set which must exist.\r
+     * @throws ServiceException \r
+     * @throws ClusterSetExistException if cluster set does not exist.\r
+     * @returns the new resource\r
+     * @see #newClusterSet\r
+     */\r
+    Resource newResource(Resource clusterSet) throws ServiceException, ClusterSetExistException;\r
+\r
+    /**\r
+     * Creates a new cluster set.\r
+     * \r
+     * @param clusterSet identifies the created cluster set.\r
+     * @throws ServiceException\r
+     * @throws ClusterSetExistException if cluster set exists already.\r
+     */\r
+    void newClusterSet(Resource clusterSet) throws ServiceException, ClusterSetExistException;\r
+    /**\r
+     * Sets cluster set to be used for {@link #newResource()} method.\r
+     * If cluster set is null then newResource behaves as before. \r
+     * \r
+     * @param clusterSet\r
+     * @return old cluster set.\r
+     * @throws ServiceException\r
+     */\r
+    Resource setClusterSet4NewResource(Resource clusterSet) throws ServiceException;\r
+    \r
+    /**\r
+     * Makes sure that the statements (s,p,o) and (o,i,s) are found in the\r
+     * graph. It is not asserted that p is an inverse relation of i, this is\r
+     * assumed and considered to be the client's responsibility.\r
+     * \r
+     * <p>\r
+     * If no inverse relation (o,i,s) is desired, <code>null</code> may be given as inverse.\r
+     * </p>\r
+     * \r
+     * @param subject\r
+     * @param predicate\r
+     * @param inverse\r
+     * @param object\r
+     */\r
+    void claim(Resource subject, Resource predicate, Resource inverse, Resource object) throws ServiceException;\r
+\r
+    /**\r
+     * Stores the specified literal value (boxed primitive/String or\r
+     * primitive/String array) into the specified resource. Any previous value\r
+     * is overridden.\r
+     * \r
+     * @param resource the resource to store the literal value into\r
+     * @param value the literal value\r
+     */\r
+    void claimValue(Resource resource, Object value) throws ServiceException;\r
+    void claimValue(Resource resource, Object value, Binding binding) throws ServiceException;\r
+\r
+    void addLiteral(Resource resource, Resource predicate, Resource inverse, Object value, Binding binding) throws BindingException, ManyObjectsForFunctionalRelationException, ServiceException;\r
+    void addLiteral(Resource resource, Resource predicate, Resource inverse, Resource type, Object value, Binding binding) throws BindingException, ManyObjectsForFunctionalRelationException, ServiceException;\r
+\r
+    /**\r
+     * Makes sure that the statements (s,p,o) and (o,i,s) are no longer found in\r
+     * the graph. It is not asserted that p is an inverse relation of i, this is\r
+     * assumed and considered to be the client's responsibility.\r
+     * \r
+     * @param subject\r
+     * @param predicate\r
+     * @param inverse\r
+     * @param object\r
+     */\r
+    void deny(Resource subject, Resource predicate, Resource inverse, Resource object, VirtualGraph graph) throws ServiceException;\r
+\r
+    /**\r
+     * If there is a literal value associated with the specified resource, it is\r
+     * removed. Otherwise does nothing.\r
+     * \r
+     * @param resource\r
+     */\r
+    void denyValue(Resource resource) throws ServiceException;\r
+    void denyValue(Resource resource, VirtualGraph graph) throws ServiceException;\r
+\r
+    /**\r
+     * Ends writing into the current cluster and starts a new one. Any resources\r
+     * created with {@link #newResource()} after this call will go into the new\r
+     * cluster.\r
+     */\r
+    void flushCluster() throws ServiceException;\r
+\r
+    /**\r
+     * Flush all modified data in the given cluster stream to server.\r
+     * \r
+     * @param r is resource used to identify cluster. If null then all clusters\r
+     *        streams are flushed.\r
+     */\r
+    void flushCluster(Resource r) throws ServiceException;\r
+\r
+    /**\r
+     * Synchronously performs the given {@link WriteOnly}.\r
+     * \r
+     * @param request an instance of {@link Write}.\r
+     */\r
+    void syncRequest(WriteOnly r) throws DatabaseException;\r
+\r
+    int thread();\r
+\r
+    VirtualGraph getProvider();\r
+    \r
+    /**\r
+     * After current request is processed the undo list is cleared.\r
+     */\r
+    void clearUndoList(WriteTraits writeTraits);\r
+    \r
+    boolean isImmutable(Resource resource) throws DatabaseException;\r
+\r
+    /**\r
+     * Marks the beginning of the ongoing write transaction as an undo point.\r
+     * Calling this method several times during the same transaction has no\r
+     * effect.\r
+     */\r
+    void markUndoPoint();\r
+\r
+}\r