Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Fixed

- Link in table result header is no longer arbitrary if more than one predicate has the same object (#230.)
- Avoided "Error getting variable options..." in templated queries with indirect sources to which the user has no read access (#231).
- Corrected fetch status in templated queries with indirect sources to which the user has no read access (#232).

Expand Down
26 changes: 26 additions & 0 deletions main/configs/test/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -581,6 +581,32 @@
"http://localhost:8080/example/favourite-musicians-file-does-not-exist"
]
}
},
{
"id": "9200",
"queryGroupId": "gr-test",
"queryLocation": "schema_name.rq",
"name": "A query that looks for names that are the object of predicate schema:name",
"description": "Tests a single link in the 'name' column header.",
"comunicaContext": {
"sources": [
"http://localhost:8080/example/names-labels"
],
"lenient": true
}
},
{
"id": "9201",
"queryGroupId": "gr-test",
"queryLocation": "schema_name_rdfs_label.rq",
"name": "A query that looks for names that are both the objects of predicates schema:name and rdfs:label",
"description": "Tests two links in the 'name' column header.",
"comunicaContext": {
"sources": [
"http://localhost:8080/example/names-labels"
],
"lenient": true
}
}
]
}
6 changes: 6 additions & 0 deletions main/configs/test/public/queries/schema_name.rq
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
PREFIX schema: <http://schema.org/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>

SELECT ?name WHERE {
?s schema:name ?name.
}
7 changes: 7 additions & 0 deletions main/configs/test/public/queries/schema_name_rdfs_label.rq
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
PREFIX schema: <http://schema.org/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>

SELECT ?name WHERE {
?s schema:name ?name.
?s rdfs:label ?name.
}
Original file line number Diff line number Diff line change
Expand Up @@ -60,16 +60,18 @@ function TableHeader({ children }) {
</span>
</Tooltip>}
{!!variableOntology && variableOntology[child.props.source] && (
<Link
target="_blank"
href={variableOntology[child.props.source]}
sx={{ height: "100%", margin: "0 5px", "& > *": { verticalAlign: "middle" } }}
>
<LinkIcon
fontSize="small"
sx={{ height: "100%", color: "gray" }}
/>
</Link>
variableOntology[child.props.source].map((link) => (
<Link
target="_blank"
href={link}
sx={{ height: "100%", margin: "0 0 0 5px", "& > *": { verticalAlign: "middle" } }}
>
<LinkIcon
fontSize="small"
sx={{ height: "100%", color: "gray" }}
/>
</Link>
))
)}
{sort.field === child.props.source && (
<>
Expand Down
10 changes: 7 additions & 3 deletions main/src/dataProvider/SparqlDataProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -189,10 +189,10 @@ function replaceVariables(rawText, variableValues) {
}

/**
* Given a query and an object, this function returns the predicate of the object in the query.
* Given a query and an object, this function returns the predicates of the object in the query.
*
* @param {object} query - the parsed query in which the predicate is to be looked for.
* @returns {object} an object with the variable as key and the predicate as value.
* @returns {object} an object with the variable as key and as value an array of predicates.
*/
function findPredicates(query) {
const ontologyMapper = {};
Expand All @@ -204,7 +204,11 @@ function findPredicates(query) {
if (part.triples) {
for (const triple of part.triples) {
if (triple.predicate.termType !== "Variable") {
ontologyMapper[triple.object.value] = triple.predicate.value;
if (!ontologyMapper[triple.object.value]) {
ontologyMapper[triple.object.value] = [triple.predicate.value];
} else if (!ontologyMapper[triple.object.value].includes(triple.predicate.value)) {
ontologyMapper[triple.object.value].push(triple.predicate.value);
}
}
}
}
Expand Down
24 changes: 19 additions & 5 deletions test/cypress/e2e/column-header.cy.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,23 @@
describe("Column header", () => {
it("Variables link to ontology", () => {
it("One link to ontology", () => {
cy.visit("/");
cy.contains("Example queries").click();
cy.contains("A query about musicians").click();
cy.contains("For testing only").click();
cy.contains("A query that looks for names that are the object of predicate schema:name").click();
cy.contains("Finished in:");
cy.get('a[href="http://schema.org/name"]');
})
cy.get('th').contains("name").parent().within(() => {
cy.get('a[href="http://schema.org/name"]');
});
});

it("Two links to ontology", () => {
cy.visit("/");
cy.contains("For testing only").click();
cy.contains("A query that looks for names that are both the objects of predicates schema:name and rdfs:label").click();
cy.contains("Finished in:");
cy.get('th').contains("name").parent().within(() => {
cy.get('a[href="http://schema.org/name"]');
cy.get('a[href="http://www.w3.org/2000/01/rdf-schema#label"]');
});
});

});
8 changes: 8 additions & 0 deletions test/initial-pod-data/names-labels$.ttl
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
PREFIX schema: <http://schema.org/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX ex: <https://www.example.com/ont/>

ex:1 schema:name "A name, given with predicates schema:name and rdfs:label" ;
rdfs:label "A name, given with predicates schema:name and rdfs:label" .
ex:2 schema:name "A name, given with predicate schema:name" ;
rdfs:label "A name, given with predicate rdfs:label" .
14 changes: 14 additions & 0 deletions test/initial-pod-data/names-labels.acl
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
@prefix acl: <http://www.w3.org/ns/auth/acl#>.
@prefix foaf: <http://xmlns.com/foaf/0.1/>.

<#public>
a acl:Authorization;
acl:accessTo <./names-labels>;
acl:agentClass foaf:Agent;
acl:mode acl:Read.

<#owner>
a acl:Authorization;
acl:accessTo <./names-labels>;
acl:agent <http://localhost:8080/example/profile/card#me>;
acl:mode acl:Read, acl:Write, acl:Control.