The Simantics database client allows for defining memory-based and disk-based graph fragments which are applied on top of the server-based semantic graph.
A reading user perceives the combined model and the virtual graph information can be specifically queried if necessary.
A modifying user needs to specify in which virtual graph the modifications are made.
Virtual graphs are manipulated via the following interfaces
- org.simantics.db.service.VirtualGraphSupport, for management
- org.simantics.db.request.WriteTraits, for identifying the graph to write into
A write request has a single graph into which it writes. This is determined by WriteTraits and usually as a parameter to WriteRequest. If null is provided, the client applies modifications into the persistent graph. The following rules apply:
- New resources are created into the given virtual graph
- Claim statements are added into the given virtual graph
- Value changes are applied into the given virtual graph
- When the virtual graph provided to the WriteRequest is:
- For denied statements the location of the statement is determined and the statement is removed from that virtual graph. If the denied statement is not a part of any virtual graph, it is removed from the persistent graph.
- Statements are only removed from the virtual graph specified for the write request
The user can perform modifications into multiple virtual graphs within a single transaction. This is accomplished by issuing a new synchronous modification (WriteGraph.sync) into a new virtual graph.
The following code examples show in practice how to write into virtual graphs, both memory- and disk-based. Writing to several virtual graphs within the same write transaction is also demonstrated.
The standard Simantics Graph Debugger view shows for every statement which virtual graph it belongs to. This information is visible on the Graph column of the statement table. The Graph column will show:
- when the statement is in the persistent graph
- 'name' (W)
- when the statement is in a named workspace-persistent virtual graph
- 'name' (M)
- when the statement is in a named memory-persistent (transient) virtual graph