---
# System prepended metadata

title: Intersecting Shape Trees

---

# Intersecting Shape Trees

* /data/#registry  # the data registry
    # data registration for notes#notebook-tree must be validated against data registration shape           # AND must indicate it contains Notebooks inside of it
    * /data/49a5259/#registration  
        * /data/49a5259/12345-65735/#notebook   # instance of notes#notebook-tree 
        * /data/49a5259/77562-43213/#notebook   # instance of notes#notebook-tree 
    

* /data/  # the data Container
    * Notebook/  # Notebook instance Container ```<> tree:shapeTree <...>```
        * 12345-65735/#notebook   # instance of notes#notebook-tree 
        * 49a5259/77562-43213/#notebook   # instance of notes#notebook-tree 
# /metadata/ (server managed)
    * Notebook/_meta.ttl ```<../data/Notebook/> tree:shapeTree <...>```
``` turtle
<> eco:registration <#registration> .
<#registration> a eco:DataRegistration ;
  
```

```
<>@<RegisteredContainer>

<RegisteredContainer> CLOSED {
  a [lpd:Container] ;
  dc:title xsd:string ;
  eco:registration @eco-shex:DataRegistrationShape ;
} 
```



* POST (plant w ShapeTree #data-registry-tree) 
    * Parent Container: / 
    * Slug: data
    * includes the #registry body
    * ShapeTree Validation:
        * Graph body: #DataRegistryShape
        * Contents: #data-registration-tree

* POST (plant w ShapeTree #data-registration-tree)
    * Parent Container: /data
    * Slug: 49a..5259
    * includes the #registration body
    * ShapeTree Validation:
        * Graph body: #DataRegistrationShape (implied by Ecosystem)

* POST 
    * Parent Container: /data/49a..5259
    * Slug: 12345-65735
    * includes content of a notebook




# Josh Proposal

## Existing Metadata (prefixes removed)
Stored at: https://ldp.local-ess.inrupt.com/podid/shapetree-testing/Git-Orgs/.meta

Note that 4 metadata triples are part of subject: https://ldp.local-ess.inrupt.com/podid/shapetree-testing/Git-Orgs/  (not the subject of the metadata file)

https://ldp.local-ess.inrupt.com/podid/shapetree-testing/Git-Orgs/ has a describedBy of https://ldp.local-ess.inrupt.com/podid/shapetree-testing/Git-Orgs/.meta (which has a describes of the former). The .meta file contains these assertions about the document it describes:

```turtle
@prefix tree: <http://www.w3.org/ns/shapetree#> .

<https://ldp.local-ess.inrupt.com/podid/shapetree-testing/Git-Orgs/>
        a tree:Locator ; # -ish, 'cause it's also the instance itself.
        tree:shapeTreeInstancePath  "." ;
        tree:shapeTreeInstanceRoot  <https://ldp.local-ess.inrupt.com/podid/shapetree-testing/Git-Orgs/> ;
        tree:shapeTreeRoot  <http://localhost:9999/static/gh-flat/gh-flat-ShapeTree.jsonld#orgs> ;
        tree:shapeTreeStep  <http://localhost:9999/static/gh-flat/gh-flat-ShapeTree.jsonld#orgs> .

<https://ldp.local-ess.inrupt.com/podid/shapetree-testing/Git-Orgs/.meta>
        rdf:type  ldp:RDFSource .
```

## Proposed Metadata (prefixes removed)
Stored at: https://ldp.local-ess.inrupt.com/podid/shapetree-testing/Git-Orgs/.meta

```turtle
@prefix tree: <http://www.w3.org/ns/shapetree#> .

# On the subject of the container, we provide "follow your nose" method to get to any planted shapetrees on the container
<https://ldp.local-ess.inrupt.com/podid/shapetree-testing/Git-Orgs/>
    tree:hasShapeTreeLocator 
        <https://ldp.local-ess.inrupt.com/podid/shapetree-testing/Git-Orgs/#UUID1>,
        <https://ldp.local-ess.inrupt.com/podid/shapetree-testing/Git-Orgs/#UUID2> .
    
# ShapeTrees are planted with UUID subjects since they are navigated instead of explicitly retrieved.
# This represents the ecosystem shapetree
<https://ldp.local-ess.inrupt.com/podid/shapetree-testing/Git-
Orgs/#UUID1>
        a tree:Locator ;
        tree:shapeTreeInstancePath  "." ;
        tree:shapeTreeInstanceRoot  <https://ldp.local-ess.inrupt.com/podid/shapetree-testing/Git-Orgs/> ;
        tree:shapeTreeRoot  <http://localhost:9999/static/ecosystem/ecosystem-shapetree.jsonld#data-registration-tree> ;
        tree:shapeTreeStep  <http://localhost:9999/static/ecosystem/ecosystem-shapetree.jsonld#data-registration-tree> .

# This represents the application shapetree
<https://ldp.local-ess.inrupt.com/podid/shapetree-testing/Git-Orgs/#UUID2>    
        a tree:Locator ;
        tree:shapeTreeInstancePath  "." ;
        tree:shapeTreeInstanceRoot  <https://ldp.local-ess.inrupt.com/podid/shapetree-testing/Git-Orgs/> ;
        tree:shapeTreeRoot  <http://localhost:9999/static/gh-flat/gh-flat-ShapeTree.jsonld#orgs> ;
        tree:shapeTreeStep  <http://localhost:9999/static/gh-flat/gh-flat-ShapeTree.jsonld#orgs> .

<https://ldp.local-ess.inrupt.com/podid/shapetree-testing/Git-Orgs/.meta>
        rdf:type  ldp:RDFSource .
```

### Proposed Revised Workflow
1. When performing a PUT/PATCH/POST/DELETE determine if the in-context container (the parent container being POSTed to or the one containing the target of the PUT/PATCH/DELETE)
1. A container is a ```managed``` if:
    * A metadata resource exists for that container (regardless of how it is obtained... .meta, in graph, rel=describedby)
    * The metadata resource contains one or more ```tree:hasShapeTree``` predicate
1. If the container is ```managed```, iterate each triple with a predicate of ```tree:hasShapeTree``` 
1. Apply the appropriate rules for each ShapeTree

### Proposed Revised 'Plant' workflow
1. When planting a ShapeTree, determine if there is already a ShapeTree via the ```tree:hasShapeTree``` predicate.  If so, validation should occur to ensure there is no "conflict" between the ShapeTrees.  Current conflict rules:
    * Only one ShapeTree can specify the ```tree:shape``` predicate
    * Only one ShapeTree can specify the ```tree:contents``` predicate
    * All ShapeTrees must have the same ```tree:expectedType``` 