コード例 #1
0
 function get_candidate_values($pool_uri, $max = 5)
 {
     if (!isset($this->bigfootSparqlService)) {
         $bigfoot = new Store(STORE_URI);
         $this->bigfootSparqlService = $bigfoot->get_sparql_service();
     }
     $query = "PREFIX p: <http://purl.org/vocab/value-pools/schema#> CONSTRUCT {<{$pool_uri}> p:value ?v . } WHERE { <{$pool_uri}> p:value ?v . } LIMIT {$max}";
     $triples = $this->bigfootSparqlService->graph_to_triple_list($query);
     $candidates = array();
     if (is_array($triples)) {
         foreach ($triples as $triple) {
             if ($triple['p'] = 'http://purl.org/vocab/value-pools/schema#value' && $triple['o_type'] == 'literal') {
                 array_push($candidates, $triple['o']);
             }
         }
     }
     return $candidates;
 }
コード例 #2
0
 /**
  * Runs the constructed query and returns the results as an instance of DataTableResult
  */
 function get()
 {
     $store = new Store($this->_store_uri, $this->_credentials, $this->_request_factory);
     $ss = $store->get_sparql_service();
     $query = $this->get_sparql();
     $response = $ss->query($query, 'json');
     if ($response->is_success()) {
         return new DataTableResult($response->body, $this->_subject);
     } else {
         //trigger_error("SPARQL query failed with HTTP result " . $response->status_code. " and body " . $response->to_string(), E_USER_WARNING);
         return new DataTableResult('{"head": {"vars": [ ] } , "results": { "bindings": [] } }', $this->_subject);
     }
 }
コード例 #3
0
 function test_get_sparql_service_sets_credentials()
 {
     $credentials = new Credentials('scooby', 'shaggy');
     $store = new Store("http://example.org/store", $credentials);
     $this->assertEquals($credentials, $store->get_sparql_service()->credentials);
 }