/** * Obtain a bounded description of a given resource as a SimpleGraph. An empty SimpleGraph is returned if any HTTP errors occur. * @param mixed uri the URI of the resource to be described or an array of URIs * @return SimpleGraph */ function describe_to_simple_graph($uri, $type = 'cbd') { $graph = new SimpleGraph(); $response = $this->describe($uri, $type, OUTPUT_TYPE_JSON); if ($response->is_success()) { $graph->from_json($response->body); } return $graph; }
function test_from_json() { $g = new SimpleGraph(); $g->from_json($this->_single_triple_json); $this->assertEquals(1, count($g->get_triples())); $index = $g->get_index(); $this->assertEquals("foo", $index['http://example.org/subj']['http://example.org/pred'][0]['value']); }
if ($describer_class) { $describer = new $describer_class(); } else { require_once MORIARTY_DIR . 'store.class.php'; $describer = new Store($store_uri); } $response = $describer->describe($resource_uri, 'cbd', 'json'); $body = ''; $content_location = ''; $etag = ''; if ($response->is_success()) { if (array_key_exists('etag', $response->headers)) { $etag = $response->headers['etag']; } $g = new SimpleGraph(); $g->from_json($response->body); if (!$g->has_triples_about($resource_uri)) { send_not_found($uri, $template); } else { $g->remove_property_values($resource_uri, 'http://schemas.talis.com/2005/dir/schema#etag'); if ($uri != $doc_uri) { header("HTTP/1.1 303 See Other"); header("Location: " . $doc_uri); exit; } else { $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;