diff --git a/package-lock.json b/package-lock.json index 02b55990..a3b28812 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12,7 +12,7 @@ "@babel/plugin-transform-private-property-in-object": "^7.24.7", "@emotion/react": "^11.11.4", "@emotion/styled": "^11.11.5", - "@foerderfunke/matching-engine": "^0.7.0", + "@foerderfunke/matching-engine": "^0.7.1", "@mui/icons-material": "^5.15.19", "@mui/material": "^5.15.19", "@mui/x-charts": "^7.6.2", @@ -8567,9 +8567,9 @@ "integrity": "sha512-J4yDIIthosAsRZ5CPYP/jQvUAQtlZTTD/4suA08/FEnlxqW3sKS9iAhgsa9VYLZ6vDHn/ixJgIqRQPotoBjxIw==" }, "node_modules/@foerderfunke/matching-engine": { - "version": "0.7.0", - "resolved": "https://registry.npmjs.org/@foerderfunke/matching-engine/-/matching-engine-0.7.0.tgz", - "integrity": "sha512-Orke9w6JPPGJEQiQr0jGWusu1rj5EMV1y2DRkPjtwIo09Bf/GloILro9IbtKdU8f97Pt+YBFB9vKOso/edyCYw==", + "version": "0.7.1", + "resolved": "https://registry.npmjs.org/@foerderfunke/matching-engine/-/matching-engine-0.7.1.tgz", + "integrity": "sha512-q434f/HWT3jgOsUfot08aET39Rc0pfQwD7LRUnesK/kfYmgYIEvTYtHL1BONtIdzY4X+G1TV5Gx4gqp5DZyzvA==", "dependencies": { "@comunica/query-sparql-rdfjs": "^2.10.2", "n3": "^1.17.2", diff --git a/package.json b/package.json index b47d6834..9eccd1ce 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,7 @@ "@babel/plugin-transform-private-property-in-object": "^7.24.7", "@emotion/react": "^11.11.4", "@emotion/styled": "^11.11.5", - "@foerderfunke/matching-engine": "^0.7.0", + "@foerderfunke/matching-engine": "^0.7.1", "@mui/icons-material": "^5.15.19", "@mui/material": "^5.15.19", "@mui/x-charts": "^7.6.2", diff --git a/src/screens/resolve-uri/ResolveUriScreen.js b/src/screens/resolve-uri/ResolveUriScreen.js index 4232256e..1789afec 100644 --- a/src/screens/resolve-uri/ResolveUriScreen.js +++ b/src/screens/resolve-uri/ResolveUriScreen.js @@ -1,21 +1,93 @@ -import React from 'react'; +import React, {useEffect, useState} from 'react'; import Layout from "../../components/Layout"; import AppScreenWrapper from "../../components/AppScreenWrapper"; import {useStore} from "../../components/ViewportUpdater"; import {useLocation} from "react-router-dom"; +import {fetchTurtleResource} from "../../services/githubService"; +import readJson from "../../utilities/readJson"; +import {getAllTriplesContainingUri} from "@foerderfunke/matching-engine/src/utils"; const ResolveUriScreen = () => { const isDesktop = useStore((state) => state.isDesktop); const location = useLocation(); const localName = location.hash.substring(1) + const [triples, setTriples] = useState({ + asSubject: [], + asPredicate: [], + asObject: [], + }); + + const buildUri = () => { + return `https://foerderfunke.org/default#${localName}`; + } + + useEffect(() => { + const fetchTriples = async () => { + if (!localName) return; + const validationConfig = await readJson('assets/data/requirement-profiles/requirement-profiles.json'); + const datafieldsString = await fetchTurtleResource(validationConfig['datafields']); + const materializationString = await fetchTurtleResource(validationConfig['materialization']); + let rdfStrings = [datafieldsString, materializationString]; + for (const requirementProfile of validationConfig['queries']) { + const {fileUrl, rpUri} = requirementProfile; + rdfStrings.push(await fetchTurtleResource(fileUrl)); + } + let triples = await getAllTriplesContainingUri(buildUri(), rdfStrings); + setTriples(triples); + }; + fetchTriples(); + }, [localName]); + + const format = (str) => { + if (str.startsWith('https://foerderfunke.org/default#')) { + return "ff:" + str.split('#')[1]; + } + // TODO + return str; + } return ( {localName ? - <> - {`https://foerderfunke.org/default#${localName}`} - + <> +

{buildUri()}

+ + + + + + {triples.asSubject.map((triple, idx) => ( + + + + + + ))} + + + + {triples.asPredicate.map((triple, idx) => ( + + + + + + ))} + + + + {triples.asObject.map((triple, idx) => ( + + + + + + ))} + +
Appears as subject in these triples:
{format(buildUri())}{format(triple.p)}{format(triple.o)}
Appears as predicate in these triples:
{format(triple.s)}{format(buildUri())}{format(triple.o)}
Appears as object in these triples:
{format(triple.s)}{format(triple.p)}{format(buildUri())}
+ + : 'No local name in URI' }