--- tags: Solid, Shape Trees --- # Shape Trees - Regular Plant This example builds the following physical hierarchy over the course of several operations: * /data/ * /projects/ * /project-1/ * task-43/ * task-48/ * /attachment-48 * /random.png The scenario begins with no planted shape trees, and none of the above resources existing yet. 1. `Native:` Client creates the `/data/` container to store various types of data. * Parent container `/` is checked for a shape tree locator with any shape trees that `/data/` must conform to. In this case, `/` is unmanaged, so there are none. 2. `ShapeTree:` Client plants ex:DataTree to manage the `/data/` container. * `/` is checked for a shape tree locator with any locations that `/data/` must conform to. In this case, `/` is unmanaged, so there are none. * `/data/` is checked for conformance to `st:expectsType` of `ex:DataTree` (container) * `/data/` is checked for conformance to `ex:DataSetShape` of `ex:DataTree` * Server creates the locator (included below) and assigns it to `/data/` ```turtle # Shape Tree Definition <#DataTree> a st:ShapeTree ; st:expectsType st:ShapeTreeContainer ; st:shape ex:DataShape ; st:contains ex:DataCollectionTree ; st:AllowNone . ``` ```turtle # Shape Tree Locator assigned to /data/ <#locator> a st:ShapeTreeLocator ; st:location [ st:hasShapeTree ex:DataTree ; st:hasRootShapeTree ex:DataTree ; st:hasRootShapeTreeInstance </data/> ; st:node </data/#dataset> ; st:shape ex:DataSetShape ; ] . ``` 3. `Native:` Client creates the `/data/projects/` container * Client provides a shape tree hint of `ex:DataCollectionTree` and focus node of `#collection` * Server sees that `/data/` is managed, and validates that `ex:DataCollectionTree` is allowed * `/data/projects/` is checked for conformance to `st:expectsType` (container) * `/data/projects/` is checked for conformance to `ex:DataCollectionShape` * Server creates the locator (included below) and assigns it to `/data/projects/` ```turtle # Shape Tree Definition <#DataCollectionTree> a st:ShapeTree ; st:expectsType st:ShapeTreeContainer ; st:shape ex:DataCollectionShape . ``` ```turtle # Shape Tree Locator created and assigned to /data/projects/ <#locator> a st:ShapeTreeLocator ; st:location [ st:hasShapeTree ex:DataCollectionTree ; st:hasRootShapeTree ex:DataTree ; st:hasRootShapeTreeInstance </data/> ; st:node </data/projects/#collection> ; st:shape ex:DataCollectionShape ; ] . ``` 4. `Native:` Client plants another shape tree `ex:ProjectCollectionTree` on the `/data/projects/` container * `/data/projects/` is checked for conformance to `st:expectsType` of `ex:ProjectCollectionTree` * `/data/projects/` is checked for conformance to `ex:ProjectCollectionShape` of `ex:ProjectCollectionTree` * Server adds another `st:location` to the already existing locator assigned to `/data/projects` (included below) ```turtle # Shape Tree Definition <#ProjectCollectionTree> a st:ShapeTree ; st:expectsType st:ShapeTreeContainer ; st:shape ex:ProjectCollectionShape ; st:contains ex:ProjectTree ; st:AllowNone . ``` ```turtle # Shape Tree Locator assigned to /data/projects/ with multiple locations <#locator> a st:ShapeTreeLocator ; st:location [ st:hasShapeTree ex:DataCollectionTree ; st:hasRootShapeTree ex:DataTree ; st:hasRootShapeTreeInstance </data/> ; st:node </data/projects/#collection> ; st:shape ex:DataCollectionShape ; ], [ st:hasShapeTree ex:ProjectCollectionTree ; st:hasRootShapeTree ex:ProjectCollectionTree ; st:hasRootShapeTreeInstance </data/projects/> ; st:node </data/projects/#collection> ; st:shape ex:ProjectCollectionShape ; ] . ``` 5. `Native + ShapeTree:` Client creates `/data/projects/project-1` container * Client provides a shape tree hint of `ex:ProjectTree` and focus node of `#project` * Server sees that `/data/projects` is managed, and validates that `ex:ProjectTree` is allowed. Sees that it is allowed by `ex:ProjectCollectionTree`. * `/data/projects/project-1` is checked for conformance to `st:expectsType` * `/data/projects/project-1` is checked for conformance to `ex:ProjectShape` * Server creates the locator (included below) and assigns it to `/data/projects/project-1` ```turtle # Shape Tree Definition <#ProjectTree> a st:ShapeTree ; st:expectsType st:ShapeTreeContainer ; st:shape ex:ProjectShape ; st:contains <#TaskTree> , st:AllowNone . ``` ```turtle # Shape Tree Locator created and assigned to /data/projects/project-1 <#locator> a st:ShapeTreeLocator ; st:location [ st:hasShapeTree ex:ProjectTree ; st:hasRootShapeTree ex:ProjectsTree ; st:hasRootShapeTreeInstance </data/projects/> ; st:node </data/projects/project-1#project> ; st:shape ex:DataCollectionShape ; ] . ``` 6. `Native + ShapeTree:` Client creates `/data/projects/project-1/task-48` container without providing focus node * Client provides a shape tree hint of `ex:TaskTree` but doesn't include a focus node * Server sees that `/data/projects/project-1` is managed, and validates that `ex:TaskTree` is allowed. Sees that it is allowed by `ex:ProjectTree`. * `/data/projects/project-1/task-48` is checked for conformance to `st:expectsType` of `ex:TaskTree` * All subject nodes in `/data/projects/project-1/task-48` are checked for conformance to `ex:TaskShape` of `ex:TaskTree`. The first match is considered the focus node. * Server creates the locator (included below) and assigns it to `/data/projects/project-1/task-48` ```turtle # Shape Tree Definition <#TaskTree> a st:ShapeTree ; st:expectsType st:ShapeTreeContainer ; st:shape ex:TaskShape ; st:contains ex:AttachmentTree , st:AllowAll . ``` ```turtle # Shape Tree Locator created and assigned to /data/projects/project-1/task-48 <#locator> a st:ShapeTreeLocator ; st:location [ st:hasShapeTree ex:TaskTree ; st:hasRootShapeTree ex:ProjectsTree ; st:hasRootShapeTreeInstance </data/projects/> ; st:node </data/projects/project-1/task-48#task> ; st:shape ex:TaskShape ; ] . ``` 7. `Native + ShapeTree:` Client creates `/data/projects/project-1/task-43` container without providing shape tree hint or focus node * Server sees that `/data/projects/project-1` is managed. Since no shape tree hint or focus node was provided, and `/data/projects/project-1` is not `st:AllowAll`, the server must evaluate `task-43` against every acceptable option. * For each contained shape tree TREE in `ex:ProjectTree` which manages `/data/projects/project-1` * `/data/projects/project-1/task-43` is checked for conformance to `TREE st:expectsType` * All subject nodes in `/data/projects/project-1/task-43` are checked for conformance to `TREE st:shape` * The first matching subject node is considered the focus node (`st:node`) * Fail if no matches are found to pass validation. * If a validation is found, Server creates the locator (included below) and assigns it to `/data/projects/project-1/task-43` ```turtle # Shape Tree Definition <#TaskTree> a st:ShapeTree ; st:expectsType st:ShapeTreeContainer ; st:shape ex:TaskShape ; st:contains st:AllowAll . ``` ```turtle # Shape Tree Locator created and assigned to /data/projects/project-1/task-43 <#locator> a st:ShapeTreeLocator ; st:location [ st:hasShapeTree ex:TaskTree ; st:hasRootShapeTree ex:ProjectsTree ; st:hasRootShapeTreeInstance </data/projects/> ; st:node </data/projects/project-1/task-43#task> ; st:shape ex:TaskShape ; ] . ``` 8. `Native + ShapeTree:` Client creates an attachment resource at `/data/projects/project-1/task-48/random.png` * Client does not provide a shape tree hint or focus node because there is neither * Since there are no contained shape trees in shape trees associated with the parent (task-48), and st:AllowAll set, the resource is free to be stored. * Server does not create a locator because the resource is not considered managed.