/** * Warning - this method is incomplete * @param SimpleGraph $graph an RDF graph that should be augmented * @return HttpResponse */ function augment_graph($graph) { if (empty($this->request_factory)) { $this->request_factory = new HttpRequestFactory(); } $request = $this->request_factory->make('POST', $this->uri, $this->credentials); $request->set_accept(MIME_RSS); $request->set_content_type(MIME_RSS); $request->set_body($graph->to_rdfxml()); return $request->execute(); }
function test_get_access_status() { $accessStatusUri = 'http://example.org/store/config/access-status'; $dummyGraph = new SimpleGraph(); $dummyGraph->add_resource_triple($accessStatusUri, 'http://schemas.talis.com/2006/bigfoot/configuration#accessMode', 'http://expected'); $response = new HttpResponse(200); $response->body = $dummyGraph->to_rdfxml(); $mockRequest = $this->getMock('HttpRequest', array('set_accept', 'execute'), array('GET', $accessStatusUri)); $mockRequest->expects($this->once())->method('set_accept')->with(MIME_RDFXML); $mockRequest->expects($this->once())->method('execute')->will($this->returnValue($response)); $mockRequestFactory = $this->getMock('HttpRequestFactory', array('make')); $mockRequestFactory->expects($this->once())->method('make')->will($this->returnValue($mockRequest)); $config = new Config("http://example.org/store/config", null, $mockRequestFactory); $actual = $config->get_access_status(); $this->assertEquals('http://expected', $actual, 'Access status should be correct'); }
/** * Create a new store on the platform. This is currently restricted to Talis administrators. * @param string name the name of the store * @param string template_uri the URI of the store template to use * @return HttpRequest */ function create_store($name, $template_uri) { if (empty($this->request_factory)) { $this->request_factory = new HttpRequestFactory(); } $uri = $this->uri; $mimetype = MIME_RDFXML; $request = $this->request_factory->make('POST', $uri, $this->credentials); $request->set_accept("*/*"); $request->set_content_type($mimetype); $sr = new SimpleGraph(); $sr->add_resource_triple('_:req', BF_STORETEMPLATE, $template_uri); $sr->add_literal_triple('_:req', BF_STOREREF, $name); $request->set_body($sr->to_rdfxml()); return $request->execute(); }
$g->add_resource_triple($doc_uri, RDF_TYPE, FOAF_DOCUMENT); $g->add_resource_triple($doc_uri, RDF_TYPE, 'http://purl.org/dc/dcmitype/Text'); $g->add_resource_triple($doc_uri, FOAF_PRIMARYTOPIC, $resource_uri); $g->add_literal_triple($doc_uri, 'http://purl.org/dc/terms/title', 'Linked Data for ' . $g->get_label($resource_uri, TRUE)); foreach ($media_types as $extension => $type_info) { $alt_uri = $resource_uri . '.' . $extension; $g->add_resource_triple($doc_uri, 'http://purl.org/dc/terms/hasFormat', $alt_uri); $g->add_resource_triple($alt_uri, 'http://purl.org/dc/terms/isFormatOf', $doc_uri); $g->add_resource_triple($alt_uri, RDF_TYPE, 'http://purl.org/dc/dcmitype/Text'); $g->add_resource_triple($alt_uri, RDF_TYPE, FOAF_DOCUMENT); $g->add_resource_triple($alt_uri, FOAF_PRIMARYTOPIC, $resource_uri); $g->add_literal_triple($alt_uri, 'http://purl.org/dc/terms/format', $type_info['type']); $g->add_literal_triple($alt_uri, 'http://purl.org/dc/terms/title', 'Linked Data in ' . $type_info['label'] . ' format for ' . $g->get_label($resource_uri, TRUE)); } if ($doc_type == 'rdf') { send_rdfxml('200 OK', $g->to_rdfxml(), $content_location, $etag); } else { if ($doc_type == 'ttl') { send_turtle('200 OK', $g->to_turtle(), $content_location, $etag); } else { if ($doc_type == 'json') { send_json('200 OK', $g->to_json(), $content_location, $etag); } else { header("Content-Type: text/html; charset=UTF-8"); $title = $g->get_label($resource_uri, TRUE); $page_title = 'Linked Data for ' . $g->get_label($resource_uri, TRUE) . ' | ' . htmlspecialchars($this_host); $body .= '<p>A description of the resource identified by <a href="' . htmlspecialchars($resource_uri) . '">' . htmlspecialchars($resource_uri) . '</a></p>' . "\n"; $body .= ' <table class="linkeddata" summary="RDF description of the resource identified by ' . htmlspecialchars($resource_uri) . '. Property names are in the first column, values are in the second.">' . "\n"; $body .= ' <tbody>' . "\n"; $properties = $g->get_subject_properties($resource_uri, TRUE); $priority_properties = array_intersect($ordered_properties, $properties);