buda-base / editor-templates

SHACL templates for the BUDA editor
MIT License
1 stars 0 forks source link

getting "root" shapes #9

Open eroux opened 4 years ago

eroux commented 4 years ago

Some shapes will be used as templates and will be selectable in the UI (such as bds:PersonShape), some (ex: bds:FemaleShape) will be used as validation but never as templates. How do we discriminate between those? I think we should have a adm:useAsTemplate property that has a boolean as object that allows this distinction to be made. Note that in the case of bdo:Instance we will have multiple possible templates so we can't just say bdo:Person adm:hasTemplate bds:PersonShape. @xristy are you ok with that or do you have an alternative?

xristy commented 4 years ago

The person.shapes.ttl has been split into person.shapes.ttl and person.ui.shapes.ttl. The person.ui.shapes.ttl currently imports person.shapes.ttl.

The property bds:rootShape has been added which maps bdo:Entity to a sh:NodeShape that is the root validation shape.

We could consider a bit more separation of files in editor-templates like:

editor-templates
    shapes
        adm
        core
    templates
        adm
        core

so that validation shape info is in, for example, editor-templates/shapes/core/person.shapes.ttl and the UI shape info is in editor-templates/templates. Further separation might be a distinct repo for the validation shape info like, perhaps, bdo-validation that would have

bdo-validation/shapes/core/person.shapes.ttl

and so on.

It is possible that separate graph like bdg:PersonShapes and perhaps bdg:PersonUIShapes may be useful; and it may also be useful to introduce other properties like perhaps:

bds:uiShape : bdo:Entity => sh:NodeShape
xristy commented 4 years ago

In newcorerw there are now two graphs bdg:PersonShapes and bdg:PersonUIShapes.

MarcAgate commented 4 years ago

I just noticed that PersonUIShape class has a property adm:graphId set to bdg:PersonUIShapes ; which personShape doesn't have

(I suppose there should be in PersonShape the same prop set to bdg:personShapes)

Actually, looking at http://purl.bdrc.io/graph/PersonShapes I see that it includes shapes ontologies as well and also classes like http://purl.bdrc.io/ontology/shapes/core/WorkShape that do not pertain directly to the edition of a Person. Why is that?

MarcAgate commented 4 years ago

Moreover, we need a clear definition of what is a the root shape of a given bdo:Entity and what is the use of it. In the general case, what is the use of the root shape of an entity and where it is used (server, client or both)? For instance, is the following considered as the root shape of bdo:Person:

<http://purl.bdrc.io/ontology/shapes/core/PersonShape>
        a               sh:NodeShape ;
        rdfs:label      "Person Shape"@en ;
        sh:property     <http://purl.bdrc.io/ontology/shapes/core/PersonShape-hasBrother> , 
<http://purl.bdrc.io/ontology/shapes/core/PersonShape-hasSon> , 
<http://purl.bdrc.io/ontology/shapes/core/PersonShape-hasMother> , 
<http://purl.bdrc.io/ontology/shapes/core/PersonShape-hasCousin> , 
<http://purl.bdrc.io/ontology/shapes/core/PersonShape-personStudentOf> , 
<http://purl.bdrc.io/ontology/shapes/core/PersonShape-gender> , <http://purl.bdrc.io/ontology/shapes/core/PersonShape-kinWith> , <http://purl.bdrc.io/ontology/shapes/core/PersonShape-hasGrandfather> , 
<http://purl.bdrc.io/ontology/shapes/core/PersonShape-hasGrandmother> , 
<http://purl.bdrc.io/ontology/shapes/core/PersonShape-hasGranddaughter> , 
<http://purl.bdrc.io/ontology/shapes/core/PersonShape-hasParent> , 
<http://purl.bdrc.io/ontology/shapes/core/PersonShape-hasGrandParent> , 
<http://purl.bdrc.io/ontology/shapes/core/PersonShape-personTeacherOf> , <http://purl.bdrc.io/ontology/shapes/core/PersonShape-hasOlderBrother> , 
<http://purl.bdrc.io/ontology/shapes/core/PersonShape-hasGrandson> , 
<http://purl.bdrc.io/ontology/shapes/core/PersonShape-hasSpouse> , 
<http://purl.bdrc.io/ontology/shapes/core/PersonShape-hasFather> , 
<http://purl.bdrc.io/ontology/shapes/core/PersonShape-hasSister> , 
<http://purl.bdrc.io/ontology/shapes/core/PersonShape-hasGrandChild> , 
<http://purl.bdrc.io/ontology/shapes/core/PersonShape-hasOlderSister> , 
<http://purl.bdrc.io/ontology/shapes/core/PersonShape-hasYoungerSister> , 
<http://purl.bdrc.io/ontology/shapes/core/PersonShape-hasYoungerBrother>
 , <http://purl.bdrc.io/ontology/shapes/core/PersonShape-hasDaughter> , 
<http://purl.bdrc.io/ontology/shapes/core/PersonShape-hasSibling> , 
<http://purl.bdrc.io/ontology/shapes/core/PersonShape-personName> ;
        sh:targetClass  bdo:Person .

if not, what's missing ? Shouldn't we distinguish resources based on their types (sh:PropertyShape or sh:NodeShape), etc...

Let's clarify this notion of "root shape"

eroux commented 4 years ago

This is a reasonable start, but my understanding is that for SHACL to function, you have to give it a graph where the triples of PersonShape-hasYoungerBrother are present. So I think that would be the whole graph pointed to by the shape + the graphs imported by this graph (it's imported with owl:imports so I think we have some code to handle that properly). Otherwise perhaps the whole shapes graph would work... There are some things to try here when doing the getFocusGraph() function...

xristy commented 4 years ago

I just noticed that PersonUIShape class has a property adm:graphId set to bdg:PersonUIShapes ; which personShape doesn't have

(I suppose there should be in PersonShape the same prop set to bdg:personShapes)

person.shapes.ttl has adm:graphId bdg:PersonShapes ; similar to adm:graphId bdg:PersonUIShapes ;.

It's the same sort pattern as with other resources that identify their containing graph. We could use this approach with the core ontology and so on now that this approach is working a bit.

xristy commented 4 years ago

Actually, looking at http://purl.bdrc.io/graph/PersonShapes I see that it includes shapes ontologies as well and also classes like http://purl.bdrc.io/ontology/shapes/core/WorkShape that do not pertain directly to the edition of a Person. Why is that?

I need to adjust the imports. There are some Entity constraints that apply to all entities such as Person but the bibliographic constraints aren't appropriate as @MarcAgate has observed.

xristy commented 4 years ago

Moreover, we need a clear definition of what is a the root shape of a given bdo:Entity and what is the use of it. In the general case, what is the use of the root shape of an entity and where it is used (server, client or both)?

The bdg:PersonShapes should contain all the constraints needed to validate a putative bdo:Person and the bdg:PersonUIShapes includes the previous graph as well as triples that provide some UI guidance such as:

xristy commented 4 years ago

For instance, is the following considered as the root shape of bdo:Person: ... if not, what's missing ?

The bds:PersonShape identifies what's defining about a bdo:Person, but there's also the shape information for the super classes of bdo:Person which include information about such things as the requirement for at least one skos:prefLabel with a unique language tag among all other skos:prefLabels that may occur and so on.

The triples:

bdo:Person 
    bds:rootShape bds:PersonShape ;
    bds:uiShape bds:PersonUIShape ;
.

Serve to connect the bdo:Entity to its corresponding root (validational) shapes and (root) ui related shapes

Shouldn't we distinguish resources based on their types (sh:PropertyShape or sh:NodeShape), etc...

I'm not sure what this question means. A sh:PropertyShape describes a constraint on the property indicated by the sh:path of the shape. A sh:NodeShape essentially describes property shapes that are in a sense definitional for the :Entity resource indicated by the sh:targetClass.

I'm unsure what other distinctions are needed.

xristy commented 4 years ago

@MarcAgate I've trimmed the imports to what should be needed to recursively load just the needed triples into the graphs indicated in the ont-policy.rdf; however, the bdg:PersonShapes and bdg:PersonUIShapes are still showing extraneous triples like related to bds:WorkShape and bda:AccessRestrictedTemporarily.

These triples apparently are coming from some importing of some sort that isn't specified in person.shapes.ttl and person.ui.shapes.ttl as far as i can see.

Shapes such as

bds:PersonShape-hasBrother
    a               sh:PropertyShape ;
    sh:description  "this Person may have zero or more brothers."@en ;
    sh:inversePath  bdo:hasSibling ;
    sh:node         bds:MaleShape ;
    sh:path         bdo:hasBrother .

from bdg:PersonShapes, and from bdg:PersonUIShapes:

bds:PersonShape-hasBrother
    a               sh:PropertyShape ;
    dash:editor     dash:InstancesSelectEditor ;
    sh:description  "this Person may have zero or more brothers."@en ;
    sh:group        bds:KinshipPropertyGroup ;
    sh:inversePath  bdo:hasSibling ;
    sh:name         "has brother"@en ;
    sh:node         bds:MaleShape ;
    sh:order        "2"^^xsd:decimal ;
    sh:path         bdo:hasBrother .

are as expected. I.e., the PersonUIShapes has the information from bdg:PersonShapes as well as additional information related to UI.

The editor-templates/ont-policy.rdf ignores, in particular, imports of:

<ignoreImport   rdf:resource="http://purl.bdrc.io/ontology/core/"/>
<ignoreImport   rdf:resource="http://purl.bdrc.io/ontology/admin/"/>
<ignoreImport   rdf:resource="http://purl.bdrc.io/ontology/adm/types/Access"/>

And the sequence of imports starting w/ person.ui.shapes.ttl is:

http://purl.bdrc.io/ontology/shapes/core/PersonUIShapes/
    http://purl.bdrc.io/ontology/shapes/core/PersonShapes/
        http://purl.bdrc.io/ontology/shapes/core/
        http://purl.bdrc.io/ontology/shapes/core/PersonEventShapes/
            http://purl.bdrc.io/ontology/shapes/core/EventShapes/
                http://purl.bdrc.io/ontology/shapes/core/
                    http://purl.bdrc.io/ontology/core/

but the import of http://purl.bdrc.io/ontology/core/ is explicitly ignore, as indicated above, and indeed the bdo: is not being imported in toto into either bdg:PersonUIShapes or bdg:PersonShapes.

Yet there are various other shapes being included in the graphs as well as triples from http://purl.bdrc.io/ontology/adm/types/Access/.

It looks sort of like all the OntologySpecs in editor-templates/ont-policy.rdf are being imported for each of bdg:PersonShapes and bdg:PersonUIShapes instead of just the top-level file like person.ui.shapes.ttl and the sequence of explicitly specified imports.

Is this what is happening or do the ldspdi-dev logs show something else going on?

Thanks