function loadDataFromItem() { $uri = $this->ConfigGraph->getCompletedItemTemplate(); $this->list_of_item_uris = array($uri); $viewerUri = $this->getViewer(); $this->viewQuery = $this->SparqlWriter->getViewQueryForUri($uri, $viewerUri); if (LOG_VIEW_QUERIES) { logViewQuery($this->Request, $this->viewQuery); } $response = $this->SparqlEndpoint->graph($this->viewQuery, PUELIA_RDF_ACCEPT_MIMES); $pageUri = $this->Request->getUriWithoutPageParam(); if ($response->is_success()) { $rdf = $response->body; $this->DataGraph->add_rdf($rdf); $this->DataGraph->add_resource_triple($pageUri, FOAF . 'primaryTopic', $uri); $label = $this->DataGraph->get_first_literal($uri, SKOS . 'prefLabel'); if (!empty($label) || ($label = $this->DataGraph->get_label($uri))) { $this->DataGraph->add_literal_triple($pageUri, RDFS_LABEL, $label); } $this->DataGraph->add_resource_triple($uri, FOAF . 'isPrimaryTopicOf', $pageUri); $this->DataGraph->add_resource_triple($this->Request->getUri(), API . 'definition', $this->endpointUrl); if ($datasetUri = $this->ConfigGraph->getDatasetUri()) { $this->DataGraph->add_resource_triple($pageUri, VOID . 'inDataset', $datasetUri); $voidRequest = $this->HttpRequestFactory->make('GET', $datasetUri); $voidRequest->set_accept(PUELIA_RDF_ACCEPT_MIMES); $voidResponse = $voidRequest->execute(); if ($voidResponse->is_success()) { $voidGraph = new SimpleGraph(); $base = array_shift(explode('#', $datasetUri)); $voidGraph->add_rdf($voidResponse->body, $base); if ($licenseUri = $voidGraph->get_first_resource($datasetUri, DCT . 'license')) { $this->DataGraph->add_resource_triple($this->Request->getUri(), DCT . 'license', $licenseUri); } else { logDebug($datasetUri . ' has no dct:license'); } } else { logDebug("VoID document could not be fetched from {$datasetUri}"); } } } else { logError("Endpoint returned {$response->status_code} {$response->body} View Query <<<{$this->viewQuery}>>> failed against {$this->SparqlEndpoint->uri}"); $this->setStatusCode(HTTP_Internal_Server_Error); $this->errorMessages[] = "The SPARQL endpoint used by this URI configuration did not return a successful response."; } $this->pageUri = $pageUri; }
function test_get_first_resource_ignores_literals() { $g = new SimpleGraph(); $g->add_resource_triple('http://example.org/subj', 'http://example.org/pred', 'http://example.org/obj'); $g->add_literal_triple('http://example.org/subj', 'http://example.org/pred', 'literal'); $this->assertEquals("http://example.org/obj", $g->get_first_resource('http://example.org/subj', 'http://example.org/pred')); }
/** * Return the current access status for the store. */ function get_access_status() { $accessStatusUri = $this->uri . '/access-status'; if (empty($this->request_factory)) { $this->request_factory = new HttpRequestFactory(); } $request = $this->request_factory->make('GET', $accessStatusUri, $this->credentials); $request->set_accept(MIME_RDFXML); $response = $request->execute(); if ($response->is_success()) { $graph = new SimpleGraph($response->body); $accessMode = $graph->get_first_resource($accessStatusUri, 'http://schemas.talis.com/2006/bigfoot/configuration#accessMode'); return $accessMode; } else { throw new Exception('Error determining access status: ' . $response->to_string()); } }