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.service;
\r
14 import java.util.Collection;
\r
16 import org.simantics.db.ReadGraph;
\r
17 import org.simantics.db.Resource;
\r
18 import org.simantics.db.ServiceLocator;
\r
19 import org.simantics.db.Session;
\r
20 import org.simantics.db.Statement;
\r
21 import org.simantics.db.VirtualGraph;
\r
22 import org.simantics.db.VirtualGraph.Persistency;
\r
23 import org.simantics.db.WriteOnlyGraph;
\r
24 import org.simantics.db.exception.DatabaseException;
\r
28 * A {@link Session} service for working with virtual graphs. Virtual graphs
\r
29 * offer a way to augment the persistent graph database with
\r
30 * memory/workspace-persistent information. Use
\r
31 * {@link ServiceLocator#getService(Class)} to retrieve this support from a
\r
34 * See <a href="http://dev.simantics.org/index.php/Virtual_Graphs">Simantics
\r
35 * developer wiki</a> for documentation.
\r
37 * @author Antti Villberg
\r
39 public interface VirtualGraphSupport {
\r
42 * Gets previously initialized or creates new memory-persistent
\r
43 * (session-transient) virtual graph by the specified identifier.
\r
45 * The contents of memory-persistent graphs are lost
\r
46 * when the session finishes.
\r
48 * @param identifier memory-persistent virtual graph identifier
\r
50 VirtualGraph getMemoryPersistent(String identifier);
\r
53 * First tries to return a previously loaded workspace-persistent graph by
\r
54 * identifier. Then tries to restore the graph from disk by identifier.
\r
55 * Finally creates a new workspace-persistent graph.
\r
57 * The graph is automatically persisted to disk.
\r
59 * @param identifier workspace-persistent virtual graph identifier
\r
61 VirtualGraph getWorkspacePersistent(String identifier);
\r
64 * Removes this graph from the set of active graphs. If the graph is
\r
65 * workspace persistent, the contents are deleted from disk.
\r
67 * @return <code>true</code> if the virtual graph was properly discarded
\r
69 boolean discard(VirtualGraph graph);
\r
72 * Transfers the contents of this virtual graph into the persistent store
\r
74 * @return <code>true</code> if the virtual graph was properly integrated
\r
76 boolean integrate(WriteOnlyGraph graph, VirtualGraph vg) throws DatabaseException;
\r
79 * Lists all active virtual graphs currently attached to the owner database
\r
82 * @return list of active virtual graphs
\r
84 Collection<VirtualGraph> listGraphs();
\r
87 * List all statements in the specified virtual graph.
\r
89 * @param graph the virtual graph to get statements from
\r
90 * @return statements in the specified virtual graph
\r
92 Collection<Statement> listStatements(VirtualGraph graph);
\r
95 * List all resources that contain literal values in the specified virtual
\r
98 * @param graph the virtual graph to get resources from
\r
99 * @return resources in the specified virtual graph containing literals
\r
101 Collection<Resource> listValues(VirtualGraph graph);
\r
103 VirtualGraph getGraph(ReadGraph graph, Resource subject, Resource predicate, Resource object) throws DatabaseException;
\r
105 VirtualGraph getGraph(ReadGraph graph, Resource subject, Resource predicate) throws DatabaseException;
\r
107 VirtualGraph getGraph(ReadGraph graph, Resource subject) throws DatabaseException;
\r
110 * A simple method for persisting the current state of all managed virtual
\r
111 * graphs where {@link VirtualGraph#getPersistency()} is
\r
112 * {@link Persistency#WORKSPACE}.
\r
114 void saveAll() throws DatabaseException;
\r