Skip to content

Commit

Permalink
Merge pull request #60 from zazuko/BenjaminHofstetter/issue54
Browse files Browse the repository at this point in the history
  • Loading branch information
BenjaminHofstetter authored Sep 12, 2023
2 parents 2badc89 + 73a4099 commit 69c6776
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 4 deletions.
2 changes: 1 addition & 1 deletion samples/first.sparqlbook
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
{
"kind": 2,
"language": "sparql",
"value": "# [endpoint=http://test.lindas.admin.ch/query]\nPREFIX schema: <http://schema.org/>\n\nSELECT ?propertyShape ?p ?o WHERE {\n BIND (<https://politics.ld.admin.ch/vocabulary/party> as ?set)\n ?set <http://www.w3.org/ns/shacl#property> ?propertyShape . \n ?propertyShape ?p ?o .\n} ",
"value": "# [endpoint=http://test.lindas.admin.ch/query]\nPREFIX schema: <http://schema.org/>\n\nSELECT ?propertyShape ?p ?o WHERE {\n {\n SELECT ?propertyShape WHERE {\n ?set <http://www.w3.org/ns/shacl#property> ?propertyShape . \n FILTER(isBlank(?propertyShape))\n } LIMIT 30\n }\n ?propertyShape ?p ?o .\n} ",
"metadata": {}
}
]
5 changes: 3 additions & 2 deletions src/renderer/components/bnode-component/bnode-component.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { useEffect, useState } from 'react';

import { Term } from '../../model/sparql-result-json.model';
import { shrinkBnode } from './shrink-bnode';

interface BNodeComponentProps {
term: Term;
Expand All @@ -16,7 +17,7 @@ export const BNodeComponent: React.FC<BNodeComponentProps> = ({ term }) => {
throw new Error('Term is not a blank node');
}

const value = term.value;
const value = shrinkBnode(term.value);


const bNode: BlankNode = {
Expand All @@ -32,7 +33,7 @@ export const BNodeComponent: React.FC<BNodeComponentProps> = ({ term }) => {

return (
<div style={{ display: 'flex', flexDirection: 'row' }}>
<span>[{blankNode?.value}]</span>
<span title="Blank Node">{blankNode?.value}</span>
</div>
);
};
Expand Down
12 changes: 12 additions & 0 deletions src/renderer/components/bnode-component/shrink-bnode.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@

let bNodeIdIndex = 0;
const bNodeMap = new Map<string, string>();

export function shrinkBnode(bNodeId: string): string {
if (bNodeMap.has(bNodeId)) {
return bNodeMap.get(bNodeId) ?? '';
}
const newBNodeId = `_:b${bNodeIdIndex++}`;
bNodeMap.set(bNodeId, newBNodeId);
return newBNodeId;
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export const LiteralComponent: React.FC<LiteralComponentProps> = ({ term }) => {

return (
<div className="row">
<span className="value">{literal?.value}</span>
<span title="Literal" className="value">{literal?.value}</span>
<span className="meta">
{' '}
{literal?.languageTag ? '@' + literal.languageTag : ''}
Expand Down

0 comments on commit 69c6776

Please sign in to comment.