]> gerrit.simantics Code Review - simantics/platform.git/blob - docs/Developer/Database/SubgraphExtents.md
First test on Simantics documentation using gitbook
[simantics/platform.git] / docs / Developer / Database / SubgraphExtents.md
1 ## Overview\r
2 \r
3 A subgraph extent is a set of statements bound by a given set of root resources. Subgraph extents are needed in\r
4 \r
5 * Copy-paste\r
6 * Import and export\r
7 * Delete\r
8 \r
9 ## Domain\r
10 \r
11 A subgraph extent domain is the set of resources for which all parent resources are included in the root set. The set of parents for resource *r* are found by\r
12 \r
13 * including all resources `par` for statements `(r, p <R http://www.simantics.org/Layer0-1.0/PartOf, par)`\r
14 * including all containing ordered sets `ord` from statements `(*r*, *ord* <R http://www.simantics.org/Layer0-1.0/HasNext, _)` where `ord` is not `r`.\r
15 \r
16 If the preceding procedure yielded no parents then the parent set is determined by\r
17 \r
18 * including all resources `par` for statements `(par, p <R http://www.simantics.org/Layer0-1.0/IsRelatedTo, r)`\r
19 \r
20 ## Extent descriptions\r
21 \r
22 The set of statements in a subgraph extent is determined by applying subgraph extent descriptions to the domain resources. The extent descriptions are specified in ontologies and attached to types. An extent description is implemented using the following adapter class\r
23 \r
24 ~~~\r
25 public interface SubgraphExtent {\r
26 \r
27     interface Callback {\r
28         void statement(ReadGraph graph, Statement statement) throws DatabaseException;\r
29         void value(ReadGraph graph, Resource resource, byte[] value) throws DatabaseException;\r
30     }\r
31 \r
32     Set<Resource> types(ReadGraph graph) throws DatabaseException;\r
33     void traverse(ReadGraph graph, Resource resource, Collection<Resource> domain, Callback callback) throws DatabaseException;\r
34 \r
35 }\r
36 ~~~\r
37 \r
38 ## Extent determination procedure\r
39 \r
40 * Determine the domain set by walking `IsRelatedTo` from root set and the discovered domain.\r
41 * Determine the set of extent descriptions found from root set dependencies (ontologies).\r
42 * Divide the set of available extent descriptions into included and excluded sets.\r
43 * Determine the set of (potentially) included statements by applying included extent descriptions on the domain set\r
44 * Determine the set of excluded statements by applying excluded extent descriptions on the domain set\r
45 * Remove the set of excluded statements from the included statement set\r