Skip to content

Commit

Permalink
Merge pull request #223 from Spyderisk/104-palette-generation-is-too-…
Browse files Browse the repository at this point in the history
…slow

#104: Optimised query for getPaletteRelations
  • Loading branch information
kenmeacham authored Dec 9, 2024
2 parents 88f1ee1 + 31beacc commit c534b41
Showing 1 changed file with 19 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1200,24 +1200,21 @@ public Map<String, ControlStrategy> getControlStrategiesForModel(Model model, Ma
*/
public List<Map<String, String>> getPaletteAssets(String domainURI) {


String query = "PREFIX rdfs:<http://www.w3.org/2000/01/rdf-schema#>\n" +
"PREFIX core:<http://it-innovation.soton.ac.uk/ontologies/trustworthiness/core#>\n" +
"SELECT DISTINCT ?asset ?al (GROUP_CONCAT(?c;separator=\",\") AS ?type) ?category ?cl ?description ?a (STR(?minCardinality) AS ?min) (STR(?maxCardinality) AS ?max)\n" +
"WHERE {\n" +
//" GRAPH <http://it-innovation.soton.ac.uk/ontologies/trustworthiness/domain/> {\n" +
" ?c rdfs:subClassOf+ core:Asset .\n" +
" ?asset rdfs:subClassOf* ?c .\n" +
" ?asset rdfs:label ?al .\n" +
" ?asset rdfs:subClassOf* ?category .\n" +
" ?category rdfs:subClassOf core:PaletteType .\n" +
" ?category rdfs:label ?cl .\n" +
" OPTIONAL { ?asset rdfs:comment ?description }\n" +
" OPTIONAL { ?asset core:isAssertable ?assertable }\n" +
" OPTIONAL { ?asset core:minCardinality ?minCardinality }\n" +
" OPTIONAL { ?asset core:maxCardinality ?maxCardinality }\n" +
" BIND(IF(BOUND(?assertable),STR(?assertable),\"false\") AS ?a)\n" +
//" }\n" +
" ?c rdfs:subClassOf+ core:Asset .\n" +
" ?asset rdfs:subClassOf* ?c .\n" +
" ?asset rdfs:label ?al .\n" +
" ?asset rdfs:subClassOf* ?category .\n" +
" ?category rdfs:subClassOf core:PaletteType .\n" +
" ?category rdfs:label ?cl .\n" +
" OPTIONAL { ?asset rdfs:comment ?description }\n" +
" OPTIONAL { ?asset core:isAssertable ?assertable }\n" +
" OPTIONAL { ?asset core:minCardinality ?minCardinality }\n" +
" OPTIONAL { ?asset core:maxCardinality ?maxCardinality }\n" +
" BIND(IF(BOUND(?assertable),STR(?assertable),\"false\") AS ?a)\n" +
" FILTER(!isBlank(?asset))\n" +
" FILTER(!isBlank(?category))\n" +
"} GROUP BY ?asset ?al ?category ?cl ?description ?a ?minCardinality ?maxCardinality ORDER BY ?type ?asset";
Expand All @@ -1235,39 +1232,20 @@ public List<Map<String, String>> getPaletteAssets(String domainURI) {
*/
public List<Map<String, String>> getPaletteRelations(String domainURI) {


String query = "#Retrieve all relations and their domain and range\n" +
"PREFIX rdf:<http://www.w3.org/1999/02/22-rdf-syntax-ns#>\n" +
"PREFIX rdfs:<http://www.w3.org/2000/01/rdf-schema#>\n" +
"PREFIX core:<http://it-innovation.soton.ac.uk/ontologies/trustworthiness/core#>\n" +
"PREFIX owl:<http://www.w3.org/2002/07/owl#>\n" +
"SELECT DISTINCT ?from ?prop ?label ?comment ?to (STR(?hidden) AS ?isHidden) WHERE {\n" +
//"GRAPH <http://it-innovation.soton.ac.uk/ontologies/trustworthiness/domain/> {\n" +
" ?prop a owl:ObjectProperty .\n" +
" ?prop rdfs:domain ?domain .\n" +
" ?prop rdfs:range ?range .\n" +
" ?prop rdfs:label ?label .\n" +
" ?prop rdfs:comment ?comment .\n" +
" OPTIONAL {?prop core:hidden ?hidden }\n" +
" {\n" +
" ?dasset rdfs:subClassOf* core:Asset .\n" +
" ?domain rdfs:subClassOf* ?dasset .\n" +
" ?from rdfs:subClassOf* ?domain .\n" +
" } UNION {\n" +
" ?domain owl:unionOf ?du .\n" +
" ?du (rdf:rest)*/rdf:first ?da .\n" +
" ?from rdfs:subClassOf* ?da .\n" +
" }\n" +
" {\n" +
" ?rasset rdfs:subClassOf* core:Asset .\n" +
" ?range rdfs:subClassOf* ?rasset .\n" +
" ?to rdfs:subClassOf* ?range .\n" +
" } UNION {\n" +
" ?range owl:unionOf ?ru .\n" +
" ?ru (rdf:rest)*/rdf:first ?ra .\n" +
" ?to rdfs:subClassOf* ?ra .\n" +
" }\n" +
//" }\n" +
" ?prop a owl:ObjectProperty .\n" +
" ?prop rdfs:domain ?domain .\n" +
" ?prop rdfs:range ?range .\n" +
" ?prop rdfs:label ?label .\n" +
" ?prop rdfs:comment ?comment .\n" +
" ?prop core:hidden ?hidden .\n" +
" ?from rdfs:subClassOf* ?domain .\n" +
" ?to rdfs:subClassOf* ?range .\n" +
"} ORDER BY ?prop ?from ?to";

AStoreWrapper store = storeManager.getStore();
Expand Down

0 comments on commit c534b41

Please sign in to comment.