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

configurable yasgui prefix and query #1683

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
55 changes: 55 additions & 0 deletions jena-fuseki2/jena-fuseki-ui/src/services/fuseki.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,39 @@ import { BUS } from '@/events'

const DATASET_SIZE_QUERY_1 = 'select (count(*) as ?count) {?s ?p ?o}'
const DATASET_SIZE_QUERY_2 = 'select ?g (count(*) as ?count) {graph ?g {?s ?p ?o}} group by ?g'
const CONF_DATASET_NAME = 'yasgui-config'
const CONF_EXAMPLE_QUERIES_QUERY = `PREFIX conf: <https://yasgui.triply.cc/config#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#first>
PREFIX sd: <http://www.w3.org/ns/sparql-service-description#>
PREFIX list: <http://jena.apache.org/ARQ/list#>
JSON {
"text": ?text,
"value": ?value
} WHERE {
?root sd:endpoint "/@DATASET_NAME@/" .
?root conf:exampleQueries ?list .
?list list:index (?idx ?ex) .
?ex rdfs:label ?text .
?ex conf:query ?value .
}
ORDER BY ?idx`
const CONF_PREFIXES_QUERY = `PREFIX conf: <https://yasgui.triply.cc/config#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#first>
PREFIX sd: <http://www.w3.org/ns/sparql-service-description#>
PREFIX list: <http://jena.apache.org/ARQ/list#>
JSON {
"text": ?text,
"uri": ?uri
} WHERE {
?root sd:endpoint "/@DATASET_NAME@/" .
?root conf:prefixes ?list .
?list list:index (?idx ?ex) .
?ex rdfs:label ?text .
?ex conf:uri ?uri .
}
ORDER BY ?idx`

class FusekiService {
/**
Expand Down Expand Up @@ -208,6 +241,28 @@ class FusekiService {
throw new Error(error.response.data)
})
}

async getYasguiExampleQueries (datasetName) {
return await axios
.get(this.getFusekiUrl(`/${CONF_DATASET_NAME}`), {
params: {
query: CONF_EXAMPLE_QUERIES_QUERY.replaceAll("@DATASET_NAME@", datasetName)
}
})
}

async getYasguiPrefixes (datasetName) {
return await axios
.get(this.getFusekiUrl(`/${CONF_DATASET_NAME}`), {
params: {
query: CONF_PREFIXES_QUERY.replaceAll("@DATASET_NAME@", datasetName)
}
})
}

getYasguiConfigDsName () {
return CONF_DATASET_NAME
}
}

export default FusekiService
14 changes: 13 additions & 1 deletion jena-fuseki2/jena-fuseki-ui/src/views/dataset/Query.vue
Original file line number Diff line number Diff line change
Expand Up @@ -345,10 +345,22 @@ export default {
datasetUrl: function (val, oldVal) {
this.currentDatasetUrl = val
},
currentDatasetUrl: function (val, oldVal) {
currentDatasetUrl: async function (val, oldVal) {
if (this.yasqe) {
this.yasqe.options.requestConfig.endpoint = this.$fusekiService.getFusekiUrl(val)
}
if (this.serverData.datasets.find((ds) => ds['ds.name'] === `/${this.$fusekiService.getYasguiConfigDsName()}`)) {
const [queries_res, prefixes_res] = await Promise.all([
this.$fusekiService.getYasguiExampleQueries(this.datasetName),
this.$fusekiService.getYasguiPrefixes(this.datasetName)
])
if (queries_res.data.length !== 0) {
this.queries.splice(0, Infinity, ...queries_res.data)
}
if (prefixes_res.data.length !== 0) {
this.prefixes.splice(0, Infinity, ...prefixes_res.data)
}
}
},
contentTypeSelect: function (val, oldVal) {
if (this.yasqe) {
Expand Down