AssociationClassEditor for named node records #284

Open
opened 2025-12-16 12:34:40 +00:00 by jsheunis · 2 comments
jsheunis commented 2025-12-16 12:34:40 +00:00 (Migrated from github.com)

For example, if one wants to make it simple for users to fill in a form that expects many floating point values, while still making those particular fields have the range of e.g. DataItem, which is a Thing and has a PID, i.e. is a named node in shacl-vue.

Currently, the AssociationClassEditor together with a dash:KeyInfoRole annotation on an association class (i.e. blank node) record will render the editor for the annotated property of the association class record. However, this currently assumes that the functionality is only used for blank node records.

For example, if one wants to make it simple for users to fill in a form that expects many floating point values, while still making those particular fields have the range of e.g. [`DataItem`](https://concepts.datalad.org/s/demo-research-assets/unreleased/DataItem/), which is a `Thing` and has a PID, i.e. is a named node in `shacl-vue`. Currently, the `AssociationClassEditor` together with a `dash:KeyInfoRole` annotation on an association class (i.e. blank node) record will render the editor for the annotated property of the association class record. However, this currently assumes that the functionality is only used for blank node records.
Owner

It could be possible to the generalize the AssociationClassEditor (currently limited to blank nodes / assocation classes) to a KeyInfoRoleEditor which allows for all node types. After all, the important bit is that there is a weight-carrying slot on the linked record (whether it's an association class or a PID-record) that needs to be rendered directly to the user, so that they don't have to create the interim linked record.

First revisiting the commit history to get a thorough understanding of the working principles of the current component:

So the current operating principles are:

  1. The component matches when the slot has a class as a range, AND that class does not have the PID slot (i.e. is an association class), AND any slot of that class has the dash:keyInfoRole annotation:

    if (shape.hasOwnProperty(SHACL.nodeKind.value) && 
        shape.hasOwnProperty(SHACL.class.value)) {
        // sh:nodeKind == sh:IRI ||
        // sh:nodeKind == sh:BlankNodeOrIRI ||
        // sh:class exists
        var shClass = shape[SHACL.class.value]
        return [SHACL.IRI.value, SHACL.BlankNodeOrIRI.value].includes(
            shape[SHACL.nodeKind.value]
        ) && !nodeShapeHasPID(shClass, shapesDS, id_iri) &&
        nodeShapeHasPropertyWithAnnotations(shClass, shapesDS, {"dash:propertyRole": "dash:KeyInfoRole"}, prefixes)
    }
    
  2. When the component mounts (in onBeforeMount), it creates the association class record quad (with blank node subject), and adds it to the graph, if it does not exist yet:

    // if props.modelValue does not exist
    associationClassRecordID.value = crypto.randomUUID();
    let newSubTerm = blankNode(associationClassRecordID.value)
    associationClassQuad.value = quad(newSubTerm, namedNode(RDF.type.value), namedNode(associationClass.value), null)
    rdfDS.data.graph.add(associationClassQuad.value)
    savedNodes.value.push({
        nodeshape_iri: associationClass.value,
        node_iri: associationClassRecordID.value,
    });
    
  3. It provides an 'information' icon, which will display a 'BlankNodeViewer' for the association class record once any additional relations are set on the record. This viewer will show all relations.

As far as I can see, to make this work for PID records we should be able to replace the currently used blank nodes with named nodes, without too much fallout (if any).

It could be possible to the generalize the `AssociationClassEditor` (currently limited to blank nodes / assocation classes) to a `KeyInfoRoleEditor` which allows for all node types. After all, the important bit is that there is a weight-carrying slot on the linked record (whether it's an association class or a PID-record) that needs to be rendered directly to the user, so that they don't have to create the interim linked record. First revisiting the commit history to get a thorough understanding of the working principles of the current component: - Initial commit: https://hub.psychoinformatics.de/datalink/shacl-vue/commit/51ce6c0af79682af092b9de885ef8538de2dab10 - Further addition: https://hub.psychoinformatics.de/datalink/shacl-vue/commit/2d9ce5700601a19d57a5873b71da6e4153a9b595 So the current operating principles are: 1. The component matches when the slot has a class as a range, AND that class does not have the PID slot (i.e. is an association class), AND any slot of that class has the `dash:keyInfoRole` annotation: ```javascript if (shape.hasOwnProperty(SHACL.nodeKind.value) && shape.hasOwnProperty(SHACL.class.value)) { // sh:nodeKind == sh:IRI || // sh:nodeKind == sh:BlankNodeOrIRI || // sh:class exists var shClass = shape[SHACL.class.value] return [SHACL.IRI.value, SHACL.BlankNodeOrIRI.value].includes( shape[SHACL.nodeKind.value] ) && !nodeShapeHasPID(shClass, shapesDS, id_iri) && nodeShapeHasPropertyWithAnnotations(shClass, shapesDS, {"dash:propertyRole": "dash:KeyInfoRole"}, prefixes) } ``` 2. When the component mounts (in `onBeforeMount`), it creates the association class record quad (with blank node subject), and adds it to the graph, if it does not exist yet: ```javascript // if props.modelValue does not exist associationClassRecordID.value = crypto.randomUUID(); let newSubTerm = blankNode(associationClassRecordID.value) associationClassQuad.value = quad(newSubTerm, namedNode(RDF.type.value), namedNode(associationClass.value), null) rdfDS.data.graph.add(associationClassQuad.value) savedNodes.value.push({ nodeshape_iri: associationClass.value, node_iri: associationClassRecordID.value, }); ``` 3. It provides an 'information' icon, which will display a 'BlankNodeViewer' for the association class record once any additional relations are set on the record. This viewer will show all relations. As far as I can see, to make this work for PID records we should be able to replace the currently used blank nodes with named nodes, without too much fallout (if any).
Owner

@mih do you know of a current use case that would motivate this development?

@mih do you know of a current use case that would motivate this development?
Sign in to join this conversation.
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
orinoco/shacl-vue#284
No description provided.