]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.db/src/org/simantics/db/service/VirtualGraphSupport.java
Fixed multiple issues causing dangling references to discarded queries
[simantics/platform.git] / bundles / org.simantics.db / src / org / simantics / db / service / VirtualGraphSupport.java
index a1512ec46c5b0d8af6a72e2317fbd2a9f7803efe..5f91e9d0ff7538e63b8a4fc4805e619761afd5c5 100644 (file)
-/*******************************************************************************\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.service;\r
-\r
-import java.util.Collection;\r
-\r
-import org.simantics.db.ReadGraph;\r
-import org.simantics.db.Resource;\r
-import org.simantics.db.ServiceLocator;\r
-import org.simantics.db.Session;\r
-import org.simantics.db.Statement;\r
-import org.simantics.db.VirtualGraph;\r
-import org.simantics.db.VirtualGraph.Persistency;\r
-import org.simantics.db.WriteOnlyGraph;\r
-import org.simantics.db.exception.DatabaseException;\r
-\r
-\r
-/**\r
- * A {@link Session} service for working with virtual graphs. Virtual graphs\r
- * offer a way to augment the persistent graph database with\r
- * memory/workspace-persistent information. Use\r
- * {@link ServiceLocator#getService(Class)} to retrieve this support from a\r
- * {@link Session}.\r
- * \r
- * See <a href="http://dev.simantics.org/index.php/Virtual_Graphs">Simantics\r
- * developer wiki</a> for documentation.\r
- * \r
- * @author Antti Villberg\r
- */\r
-public interface VirtualGraphSupport {\r
-\r
-    /**\r
-     * Gets previously initialized or creates new memory-persistent\r
-     * (session-transient) virtual graph by the specified identifier.\r
-     * \r
-     * The contents of memory-persistent graphs are lost\r
-     * when the session finishes.\r
-     * \r
-     * @param identifier memory-persistent virtual graph identifier\r
-     */\r
-    VirtualGraph getMemoryPersistent(String identifier);\r
-\r
-    /**\r
-     * First tries to return a previously loaded workspace-persistent graph by\r
-     * identifier. Then tries to restore the graph from disk by identifier.\r
-     * Finally creates a new workspace-persistent graph.\r
-     * \r
-     * The graph is automatically persisted to disk.\r
-     * \r
-     * @param identifier workspace-persistent virtual graph identifier\r
-     */\r
-    VirtualGraph getWorkspacePersistent(String identifier);\r
-\r
-    /**\r
-     * Removes this graph from the set of active graphs. If the graph is\r
-     * workspace persistent, the contents are deleted from disk.\r
-     * \r
-     * @return <code>true</code> if the virtual graph was properly discarded\r
-     */\r
-    boolean discard(VirtualGraph graph);\r
-\r
-    /**\r
-     * Transfers the contents of this virtual graph into the persistent store\r
-     * \r
-     * @return <code>true</code> if the virtual graph was properly integrated\r
-     */\r
-    boolean integrate(WriteOnlyGraph graph, VirtualGraph vg) throws DatabaseException;\r
-    \r
-    /**\r
-     * Lists all active virtual graphs currently attached to the owner database\r
-     * session.\r
-     * \r
-     * @return list of active virtual graphs\r
-     */\r
-    Collection<VirtualGraph> listGraphs();\r
-\r
-    /**\r
-     * List all statements in the specified virtual graph.\r
-     * \r
-     * @param graph the virtual graph to get statements from\r
-     * @return statements in the specified virtual graph\r
-     */\r
-    Collection<Statement> listStatements(VirtualGraph graph);\r
-\r
-    /**\r
-     * List all resources that contain literal values in the specified virtual\r
-     * graph.\r
-     * \r
-     * @param graph the virtual graph to get resources from\r
-     * @return resources in the specified virtual graph containing literals\r
-     */\r
-    Collection<Resource> listValues(VirtualGraph graph);\r
-    \r
-    VirtualGraph getGraph(ReadGraph graph, Resource subject, Resource predicate, Resource object) throws DatabaseException;\r
-\r
-    VirtualGraph getGraph(ReadGraph graph, Resource subject, Resource predicate) throws DatabaseException;\r
-\r
-    VirtualGraph getGraph(ReadGraph graph, Resource subject) throws DatabaseException;\r
-\r
-    /**\r
-     * A simple method for persisting the current state of all managed virtual\r
-     * graphs where {@link VirtualGraph#getPersistency()} is\r
-     * {@link Persistency#WORKSPACE}.\r
-     */\r
-    void saveAll() throws DatabaseException;\r
-\r
-}\r
+/*******************************************************************************
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management
+ * in Industry THTH ry.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     VTT Technical Research Centre of Finland - initial API and implementation
+ *******************************************************************************/
+package org.simantics.db.service;
+
+import java.util.Collection;
+
+import org.simantics.db.ReadGraph;
+import org.simantics.db.Resource;
+import org.simantics.db.ServiceLocator;
+import org.simantics.db.Session;
+import org.simantics.db.Statement;
+import org.simantics.db.VirtualGraph;
+import org.simantics.db.VirtualGraph.Persistency;
+import org.simantics.db.WriteOnlyGraph;
+import org.simantics.db.exception.DatabaseException;
+
+
+/**
+ * A {@link Session} service for working with virtual graphs. Virtual graphs
+ * offer a way to augment the persistent graph database with
+ * memory/workspace-persistent information. Use
+ * {@link ServiceLocator#getService(Class)} to retrieve this support from a
+ * {@link Session}.
+ * 
+ * See <a href="http://dev.simantics.org/index.php/Virtual_Graphs">Simantics
+ * developer wiki</a> for documentation.
+ * 
+ * @author Antti Villberg
+ */
+public interface VirtualGraphSupport {
+
+    /**
+     * Gets previously initialized or creates new memory-persistent
+     * (session-transient) virtual graph by the specified identifier.
+     * 
+     * The contents of memory-persistent graphs are lost
+     * when the session finishes.
+     * 
+     * @param identifier memory-persistent virtual graph identifier
+     */
+    VirtualGraph getMemoryPersistent(String identifier);
+
+    /**
+     * First tries to return a previously loaded workspace-persistent graph by
+     * identifier. Then tries to restore the graph from disk by identifier.
+     * Finally creates a new workspace-persistent graph.
+     * 
+     * The graph is automatically persisted to disk.
+     * 
+     * @param identifier workspace-persistent virtual graph identifier
+     */
+    VirtualGraph getWorkspacePersistent(String identifier);
+
+    /**
+     * Removes this graph from the set of active graphs. If the graph is
+     * workspace persistent, the contents are deleted from disk.
+     * 
+     * @return <code>true</code> if the virtual graph was properly discarded
+     */
+    boolean discard(VirtualGraph graph);
+
+    /**
+     * Transfers the contents of this virtual graph into the persistent store
+     * 
+     * @return <code>true</code> if the virtual graph was properly integrated
+     */
+    boolean integrate(WriteOnlyGraph graph, VirtualGraph vg) throws DatabaseException;
+    
+    /**
+     * Lists all active virtual graphs currently attached to the owner database
+     * session.
+     * 
+     * @return list of active virtual graphs
+     */
+    Collection<VirtualGraph> listGraphs();
+
+    /**
+     * List all statements in the specified virtual graph.
+     * 
+     * @param graph the virtual graph to get statements from
+     * @return statements in the specified virtual graph
+     */
+    Collection<Statement> listStatements(VirtualGraph graph);
+
+    /**
+     * List all resources that contain literal values in the specified virtual
+     * graph.
+     * 
+     * @param graph the virtual graph to get resources from
+     * @return resources in the specified virtual graph containing literals
+     */
+    Collection<Resource> listValues(VirtualGraph graph);
+    
+    VirtualGraph getGraph(ReadGraph graph, Resource subject, Resource predicate, Resource object) throws DatabaseException;
+
+    VirtualGraph getGraph(ReadGraph graph, Resource subject, Resource predicate) throws DatabaseException;
+
+    VirtualGraph getGraph(ReadGraph graph, Resource subject) throws DatabaseException;
+
+    /**
+     * A simple method for persisting the current state of all managed virtual
+     * graphs where {@link VirtualGraph#getPersistency()} is
+     * {@link Persistency#WORKSPACE}.
+     */
+    void saveAll() throws DatabaseException;
+
+}