common-workflow-language / schema_salad

Semantic Annotations for Linked Avro Data
https://www.commonwl.org/v1.2/SchemaSalad.html
Apache License 2.0
72 stars 62 forks source link

RDF Schema Output: Property-Triple for SaladRecordField missing if jsonldPredicate contains JsonldPredicate instead of Predicate URI ID only #785

Open stmbaier opened 7 months ago

stmbaier commented 7 months ago

Description

If a SALAD Schema contains a SaladRecordField with a jsonldPredicate object instead of a simple string for the predicate URI no Property-Triple is contained anymore in the RDFS output.

Minimal working example

Input schema:

$base: "http://www.example.org/basketSchema
$graph:
  - name: Basket
    type: record
    documentRoot: true
    fields:
      - name: basket
        type:
          type: array
          items: string
        jsonldPredicate: "http://www.example.org/basketSchema#hasProducts"

RDFS Output:

@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .

<http://www.example.org/basketSchema#Basket> a rdfs:Class .

<http://www.example.org/basketSchema#hasProducts> a rdf:Property ;
    rdfs:domain <http://www.example.org/basketSchema#Basket> .

Equivalent not working example

Input schema:

$base: "http://www.example.org/basketSchema"
$graph:
  - name: Basket
    type: record
    documentRoot: true
    fields:
      - name: basket
        type:
          type: array
          items: string
        jsonldPredicate: 
          _id: "http://www.example.org/basketSchema#hasProducts"

RDFS Output:

@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .

<http://www.example.org/basketSchema#Basket> a rdfs:Class .

Cause Analysis

In the jsonld_context.py in the method process_type in line 142 is, if the jsonldPredicate predicate is an object, erroneously checked for the property "_@id", which is never set. The pred method used to acquire the predicate object (line 135) re-writes the _idpredicate to @id (line 55) or creates the @id predicate (line 57).