Skip to content

Commit

Permalink
implement smarter graph IRI autocompletion (and thus resolve #4)
Browse files Browse the repository at this point in the history
  • Loading branch information
jiemakel committed Sep 17, 2014
1 parent a7d68c5 commit c74dc3d
Showing 1 changed file with 36 additions and 10 deletions.
46 changes: 36 additions & 10 deletions app/scripts/main/main-ctrl.ls
Original file line number Diff line number Diff line change
Expand Up @@ -104,20 +104,46 @@ angular.module('app').controller('MainCtrl', ($scope, $http, toastr, $stateParam
$scope.errorMessage = response.data
$scope.showError = true
canceler = null
!function updateGraphs
if (canceler?) then canceler.resolve!
canceler := $q.defer!
response <-! sparql.query($scope.sparqlEndpoint,'''
SELECT ?graphIRI (COUNT(*) AS ?triples) {
$scope.$watch('graphIRI', (newValue,oldValue) ->
if (!allGraphsFetched) then updateGraphs!
)
graphQuery = '''
SELECT DISTINCT ?graphIRI ?triples {
{
{
GRAPH ?graphIRI { ?s ?p ?o }
} UNION {
?s ?p ?o
SELECT (COUNT(*) AS ?triples) {
?s ?p ?o
}
}
} UNION {
{
SELECT ?graphIRI (COUNT(*) AS ?triples) {
GRAPH ?graphIRI { }
FILTER STRSTARTS(STR(?graphIRI),"<QUERY>")
GRAPH ?graphIRI { ?s ?p ?o }
}
GROUP BY ?graphIRI
ORDER BY DESC(?triples)
}
} UNION {
{
SELECT ?graphIRI (COUNT(*) AS ?triples) {
GRAPH ?graphIRI { ?s ?p ?o }
}
GROUP BY ?graphIRI
ORDER BY DESC(?triples)
}
}
GROUP BY ?graphIRI
''',{timeout: canceler.promise}).then(_,handleError)
}
LIMIT 500
'''
allGraphsFetched = true
!function updateGraphs
if (canceler?) then canceler.resolve!
canceler := $q.defer!
response <-! sparql.query($scope.sparqlEndpoint,graphQuery.replace("<QUERY>",$scope.graphIRI ? ""),{timeout: canceler.promise}).then(_)
$scope.graphs = response.data.results.bindings
if ($scope.graphs.length<500) then allGraphsFetched := true else allGraphsFetched := false
function getLineAfterPrefixes(data)
pos = 0
i = 0
Expand Down

0 comments on commit c74dc3d

Please sign in to comment.