Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JSON: Join Condition on Array #222

Open
tobiasschweizer opened this issue Oct 31, 2023 · 2 comments
Open

JSON: Join Condition on Array #222

tobiasschweizer opened this issue Oct 31, 2023 · 2 comments
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@tobiasschweizer
Copy link

Hi there,

I am using rmlmapper-6.2.2-r371-all.jar.
I have a join condition on an array property in JSON:

   rr:predicateObjectMap [
        rr:predicate schema:fundedItem ;
        rr:objectMap [
            rr:parentTriplesMap <#project>;
               rr:joinCondition [
                rr:child "__id";
                rr:parent "grants.*";
            ];
        ];
    ] .
"grants": [
        "http://ns.dasch.swiss/repository#dsp-REMA-grant-000"
      ],

The property schema:fundedItem is not created. It is created if grants is a string value (rr:parent "grants").
Is this a problem related to grants being an array?

This works with carml-jar-rdf4j-1.2.0-0.4.7.jar.

Thanks for your feedback!

Here is the full example:

data:

[{
  "id": "0118",
  "name": "Rome in the Early Middle Ages: Arts and Culture",
  "description": "The project addresses the visual culture of the city of Rome (Vth-XIth ct.) by means of an interdisciplinary approach (art history, architecture, archaeology archaeometry, liturgy, epigraphy).",
  "status": "ongoing",
  "metadata": {
    "$schema": "https://raw.githubusercontent.com/dasch-swiss/dsp-meta-svc/main/docs/services/metadata/schema-metadata.json",
    "datasets": [
      {
        "__createdAt": "1657709546374431000",
        "__createdBy": "dsp-metadata-gui",
        "__id": "http://ns.dasch.swiss/repository#dsp-REMA-dataset-000",
        "__type": "Dataset",
        "abstracts": [
          {
            "en": "The ontology of the database comprises three main classes, making it possible to describe paintings and mosaics in the buildings where they are found. The class “Oggetto” (i.e.: mosaic, painting) falls under the class “Cappella” and/or the class “Edificio”. Each of these three classes contains properties (custom controlled vocabularies and text fields), making it possible to characterize the building, chapel, paintings or mosaic using names, location, description, state of preservation, analysis, dating, patrons, inscriptions, sources, critical commentary, bibliography. Illustrations can be added to the three main categories using two further classes, ‘Illustrazioni’ and ‘Illustrazioni ad accesso limitato’, whose properties (also text fields and controlled vocabularies) include information on the type of image and photograph credits."
          }
        ],
        "accessConditions": "restricted",
        "alternativeTitles": [
          {
            "fr": "rome-siecles-obscurs"
          }
        ],
        "attributions": [
          {
            "__type": "Attribution",
            "agent": "http://ns.dasch.swiss/repository#dsp-REMA-person-000",
            "roles": [
              "Project Leader"
            ]
          },
          {
            "__type": "Attribution",
            "agent": "http://ns.dasch.swiss/repository#dsp-REMA-person-004",
            "roles": [
              "Data Collector"
            ]
          },
          {
            "__type": "Attribution",
            "agent": "http://ns.dasch.swiss/repository#dsp-REMA-person-002",
            "roles": [
              "Data Curator"
            ]
          },
          {
            "__type": "Attribution",
            "agent": "http://ns.dasch.swiss/repository#dsp-REMA-person-007",
            "roles": [
              "Data Collector"
            ]
          },
          {
            "__type": "Attribution",
            "agent": "http://ns.dasch.swiss/repository#dsp-REMA-person-003",
            "roles": [
              "Data Collector"
            ]
          },
          {
            "__type": "Attribution",
            "agent": "http://ns.dasch.swiss/repository#dsp-REMA-person-006",
            "roles": [
              "Project Member"
            ]
          },
          {
            "__type": "Attribution",
            "agent": "http://ns.dasch.swiss/repository#dsp-REMA-person-005",
            "roles": [
              "Project Member"
            ]
          },
          {
            "__type": "Attribution",
            "agent": "http://ns.dasch.swiss/repository#dsp-REMA-person-001",
            "roles": [
              "Project Leader"
            ]
          },
          {
            "__type": "Attribution",
            "agent": "http://ns.dasch.swiss/repository#dsp-REMA-person-008",
            "roles": [
              "Data Collector"
            ]
          }
        ],
        "howToCite": "Croci, C., Quadri, I, Gianandrea, M., Romano, S., Tosti, E., Chiaraella, M., Ventura, D., Rivoal, M., 2022, Rome in the Early Middle Ages: Arts and Culture [database] (DaSCH), https://ark.dasch.swiss/ark:/72163/1/0118",
        "languages": [
          {
            "de": "Italienisch",
            "en": "Italian",
            "fr": "italien"
          }
        ],
        "licenses": [
          {
            "__type": "License",
            "date": "2022-07-13",
            "license": {
              "__type": "URL",
              "text": "CC BY-SA 4.0",
              "type": "Creative Commons",
              "url": "https://creativecommons.org/licenses/by-sa/4.0/"
            }
          }
        ],
        "status": "Ongoing",
        "title": "Database of the project Rome in the Early Middle Ages: Arts and Culture",
        "typeOfData": [
          "Image",
          "Text"
        ]
      }
    ],
    "grants": [
      {
        "__createdAt": "1657709547313726000",
        "__createdBy": "dsp-metadata-gui",
        "__id": "http://ns.dasch.swiss/repository#dsp-REMA-grant-000",
        "__type": "Grant",
        "funders": [
          "http://ns.dasch.swiss/repository#dsp-REMA-organization-001"
        ],
        "name": "Project funding",
        "number": "192854",
        "url": {
          "__type": "URL",
          "text": "https://data.snf.ch/grants/grant/192854",
          "type": "URL",
          "url": "https://data.snf.ch/grants/grant/192854"
        }
      }
    ],
    "organizations": [
      {
        "__createdAt": "1657709547135008000",
        "__createdBy": "dsp-metadata-gui",
        "__id": "http://ns.dasch.swiss/repository#dsp-REMA-organization-002",
        "__type": "Organization",
        "address": {
          "__type": "Address",
          "country": "Italy",
          "locality": "Sapienza",
          "postalCode": "",
          "street": ""
        },
        "name": "University of Rome"
      },
      {
        "__createdAt": "1657709547222387000",
        "__createdBy": "dsp-metadata-gui",
        "__id": "http://ns.dasch.swiss/repository#dsp-REMA-organization-001",
        "__type": "Organization",
        "address": {
          "__type": "Address",
          "country": "Switzerland",
          "locality": "Bern",
          "postalCode": "3001",
          "street": "Wildhainweg 3 Postfach"
        },
        "email": "[email protected]",
        "name": "Swiss National Science Foundation (SNSF)",
        "url": {
          "__type": "URL",
          "text": "http://www.snf.ch/",
          "type": "URL",
          "url": "http://www.snf.ch/"
        }
      },
      {
        "__createdAt": "1657709547268009000",
        "__createdBy": "dsp-metadata-gui",
        "__id": "http://ns.dasch.swiss/repository#dsp-REMA-organization-000",
        "__type": "Organization",
        "address": {
          "__type": "Address",
          "country": "Switzerland",
          "locality": "Lausanne",
          "postalCode": "1015",
          "street": "Unicentre"
        },
        "name": "University of Lausanne",
        "url": {
          "__type": "URL",
          "text": "www.unil.ch",
          "type": "URL",
          "url": "http://www.unil.ch"
        }
      }
    ],
    "persons": [
      {
        "__createdAt": "1657709547134209000",
        "__createdBy": "dsp-metadata-gui",
        "__id": "http://ns.dasch.swiss/repository#dsp-REMA-person-001",
        "__type": "Person",
        "affiliation": [
          "http://ns.dasch.swiss/repository#dsp-REMA-organization-000"
        ],
        "email": "[email protected]",
        "familyNames": [
          "Quadri"
        ],
        "givenNames": [
          "Irene"
        ],
        "jobTitles": [
          "Post-doctoral researcher"
        ]
      },
      {
        "__createdAt": "1657709547134310000",
        "__createdBy": "dsp-metadata-gui",
        "__id": "http://ns.dasch.swiss/repository#dsp-REMA-person-002",
        "__type": "Person",
        "affiliation": [
          "http://ns.dasch.swiss/repository#dsp-REMA-organization-000"
        ],
        "email": "[email protected]",
        "familyNames": [
          "Rivoal"
        ],
        "givenNames": [
          "Marion"
        ],
        "jobTitles": [
          "Research Manager"
        ]
      },
      {
        "__createdAt": "1657709547134410000",
        "__createdBy": "dsp-metadata-gui",
        "__id": "http://ns.dasch.swiss/repository#dsp-REMA-person-003",
        "__type": "Person",
        "affiliation": [
          "http://ns.dasch.swiss/repository#dsp-REMA-organization-000"
        ],
        "email": "[email protected]",
        "familyNames": [
          "Chiarella"
        ],
        "givenNames": [
          "Maria Elena"
        ],
        "jobTitles": [
          "PhD Student"
        ]
      },
      {
        "__createdAt": "1657709547134507000",
        "__createdBy": "dsp-metadata-gui",
        "__id": "http://ns.dasch.swiss/repository#dsp-REMA-person-004",
        "__type": "Person",
        "affiliation": [
          "http://ns.dasch.swiss/repository#dsp-REMA-organization-000"
        ],
        "email": "[email protected]",
        "familyNames": [
          "Tosti"
        ],
        "givenNames": [
          "Eleonora"
        ],
        "jobTitles": [
          "Post-doctoral researcher"
        ]
      },
      {
        "__createdAt": "1657709547134588000",
        "__createdBy": "dsp-metadata-gui",
        "__id": "http://ns.dasch.swiss/repository#dsp-REMA-person-005",
        "__type": "Person",
        "affiliation": [
          "http://ns.dasch.swiss/repository#dsp-REMA-organization-000"
        ],
        "email": "[email protected]",
        "familyNames": [
          "Romano"
        ],
        "givenNames": [
          "Serena"
        ],
        "jobTitles": [
          "Professor Emeritus"
        ]
      },
      {
        "__createdAt": "1657709547134672000",
        "__createdBy": "dsp-metadata-gui",
        "__id": "http://ns.dasch.swiss/repository#dsp-REMA-person-006",
        "__type": "Person",
        "affiliation": [
          "http://ns.dasch.swiss/repository#dsp-REMA-organization-000",
          "http://ns.dasch.swiss/repository#dsp-REMA-organization-002"
        ],
        "email": "[email protected]",
        "familyNames": [
          "Gianandrea"
        ],
        "givenNames": [
          "Manuela"
        ],
        "jobTitles": [
          "Associate Professor"
        ]
      },
      {
        "__createdAt": "1657709547134778000",
        "__createdBy": "dsp-metadata-gui",
        "__id": "http://ns.dasch.swiss/repository#dsp-REMA-person-007",
        "__type": "Person",
        "affiliation": [
          "http://ns.dasch.swiss/repository#dsp-REMA-organization-000"
        ],
        "email": "[email protected]",
        "familyNames": [
          "Ventura"
        ],
        "givenNames": [
          "Domenico"
        ],
        "jobTitles": [
          "Freelance photographer"
        ]
      },
      {
        "__createdAt": "1657709547134887000",
        "__createdBy": "dsp-metadata-gui",
        "__id": "http://ns.dasch.swiss/repository#dsp-REMA-person-000",
        "__type": "Person",
        "affiliation": [
          "http://ns.dasch.swiss/repository#dsp-REMA-organization-000"
        ],
        "email": "[email protected]",
        "familyNames": [
          "Croci"
        ],
        "givenNames": [
          "Chiara"
        ],
        "jobTitles": [
          "Post-doctoral researcher"
        ]
      },
      {
        "__id": "http://ns.dasch.swiss/repository#dsp-REMA-person-008",
        "__type": "Person",
        "affiliation": [
          "http://ns.dasch.swiss/repository#dsp-REMA-organization-000"
        ],
        "email": "[email protected]",
        "familyNames": [
          "Cassandre"
        ],
        "givenNames": [
          "Lejosne"
        ],
        "jobTitles": [
          "PhD student"
        ]
      }
    ],
    "project": {
      "__createdAt": "1657709544615698000",
      "__createdBy": "dsp-metadata-gui",
      "__id": "http://ns.dasch.swiss/repository#dsp-REMA-project",
      "__type": "Project",
      "alternativeNames": [
        {
          "fr": "rome-siecles-obscurs"
        }
      ],
      "contactPoint": "http://ns.dasch.swiss/repository#dsp-REMA-person-000",
      "dataManagementPlan": {
        "__type": "DataManagementPlan",
        "available": true
      },
      "datasets": [
        "http://ns.dasch.swiss/repository#dsp-REMA-dataset-000"
      ],
      "description": {
        "en": "The project addresses the visual culture of the city of Rome (Vth-XIth ct.) by means of an interdisciplinary approach (art history, architecture, archaeology archaeometry, liturgy, epigraphy)."
      },
      "disciplines": [
        {
          "en": "10402 Archaeology"
        },
        {
          "en": "10404 Visual arts and Art history"
        }
      ],
      "endDate": "2023-08-31",
      "funders": [
        "http://ns.dasch.swiss/repository#dsp-REMA-organization-001"
      ],
      "grants": [
        "http://ns.dasch.swiss/repository#dsp-REMA-grant-000"
      ],
      "howToCite": "Croci, C., Quadri, I, Gianandrea, M., Romano, S., Tosti, E., Chiaraella, M., Ventura, D., Rivoal, M., 2022, Rome in the Early Middle Ages: Arts and Culture [database] (DaSCH), https://ark.dasch.swiss/ark:/72163/1/0118",
      "keywords": [
        {
          "en": "painting; mosaic; visual culture; iconography; style; archaeometry; epigraphy; archaeology; historiography; papacy; Rome; artistic geography; early Middle Ages; Goths; Byzantines; Carolingians; Ottonians"
        }
      ],
      "name": "Rome in the Early Middle Ages: Arts and Culture",
      "shortcode": "0118",
      "spatialCoverage": [
        {
          "__type": "URL",
          "text": "Rome (inhabited place)",
          "type": "URL",
          "url": "http://vocab.getty.edu/page/tgn/7000874"
        }
      ],
      "startDate": "2020-09-01",
      "teaserText": "The project addresses the visual culture of the city of Rome (Vth-XIth ct.) by means of an interdisciplinary approach (art history, architecture, archaeology archaeometry, liturgy, epigraphy).",
      "temporalCoverage": [
        {
          "__type": "URL",
          "text": "Middle Ages, 500-1500",
          "type": "Chronontology",
          "url": "https://chronontology.dainst.org/period/ZkwNN4oimUDM"
        }
      ],
      "url": {
        "__type": "URL",
        "text": "Discover Project Data",
        "type": "URL",
        "url": "https://admin.dasch.swiss/project/0118"
      }
    }
  }
}]

mapping:

PREFIX rr: <http://www.w3.org/ns/r2rml#>
PREFIX rml: <http://semweb.mmlab.be/ns/rml#>
PREFIX ql: <http://semweb.mmlab.be/ns/ql#>
PREFIX carml: <http://carml.taxonic.com/carml/>
PREFIX dct: <http://purl.org/dc/terms/>
PREFIX premis: <http://id.loc.gov/vocabulary/preservation/>
PREFIX schema: <http://schema.org/>
@base <http://example.com/ns#>.

<#LogicalSourceProject> a rml:BaseSource ;
  rml:referenceFormulation ql:JSONPath;
  rml:source "test/test-data/dasch/0118.json" ;
  rml:iterator "$.*.metadata.project" .

<#LogicalSourceGrant> a rml:BaseSource ;
  rml:referenceFormulation ql:JSONPath;
  rml:source "test/test-data/dasch/0118.json" ;
  rml:iterator "$.*.metadata.grants.*" .

<#project> a rr:TriplesMap ;
	rml:logicalSource <#LogicalSourceProject> ;

	rr:subjectMap [
		rr:template "https://data.connectome.ch/dasch/researchproject/{__id}" ;
		rr:class schema:ResearchProject ;
	] ;

	rr:predicateObjectMap [
		rr:predicate schema:name ;
		rr:objectMap [
			rml:reference "name" ;
		];
	] ;

    rr:predicateObjectMap [
		rr:predicate schema:description ;
		rr:objectMap [
			rml:reference "description.en" ;
		];
	] ;

	rr:predicateObjectMap [
		rr:predicate schema:keywords ;
		rr:objectMap [
			rml:reference "keywords.*.en" ;
		];
	] ;

    rr:predicateObjectMap [
		rr:predicate schema:startDate ;
		rr:objectMap [
			rml:reference "startDate" ;
			rr:datatype xsd:date
		];
	] ;

	rr:predicateObjectMap [
		rr:predicate schema:endDate ;
		rr:objectMap [
			rml:reference "endDate" ;
			rr:datatype xsd:date
		];
	] .

<#grant> a rr:TriplesMap ;
	rml:logicalSource <#LogicalSourceGrant> ;

	rr:subjectMap [
		rr:template "https://data.connectome.ch/dasch/monetarygrant/{__id}" ;
		rr:class schema:MonetaryGrant
	] ;

	rr:predicateObjectMap [
		rr:predicate schema:name ;
		rr:objectMap [
			rml:reference "number" ;
		];
	] ;

	rr:predicateObjectMap [
        rr:predicate schema:fundedItem ;
        rr:objectMap [
            rr:parentTriplesMap <#project>;
               rr:joinCondition [
                rr:child "__id";
                rr:parent "grants.*";
            ];
        ];
    ] .
@DylanVanAssche
Copy link
Contributor

Hi,

Thanks for the issue and a detailed example!
Arrays are kinda undefined in their behavior in the spec which is why the RMLMapper and CARML differ here. It should be improved in the new W3C kg-construct community group spec, but that doesn't help your current problem of course.
We will have a look at it this issue. Thanks!

@DylanVanAssche DylanVanAssche added help wanted Extra attention is needed bug Something isn't working labels Nov 3, 2023
@tobiasschweizer
Copy link
Author

It should be improved in the new W3C kg-construct community group spec, but that doesn't help your current problem of course.
We will have a look at it this issue. Thanks!

See you on Wednesday then (I am part of the group) ;-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants