Beispiel #1
0
<?php

echo "test script";
include 'rdfdb.inc';
//require 'http.inc';
include 'arc/ARC2.php';
include 'http.inc';
global $rdfdb_connections;
$rdfdb_connections['rdfdb1']['default'] = array('driver' => 'arc2', 'endpoint' => 'http://localhost/d7git3/sparql', 'apikey' => 'somekey');
$rdfdb_connections['rdfdb2']['default'] = array('driver' => '4store', 'endpoint' => 'http://localhost:8080/data/', 'apikey' => '');
$rdfdb_connections['rdfdb3']['default'] = array('driver' => 'virtuoso', 'endpoint' => 'http://localhost:18890/sparql', 'apikey' => '');
Rdfdb::addConnectionInfo('default', 'default', $rdfdb_connections['rdfdb3']['default']);
rdfdb_set_active('defaut');
//var_dump(rdfdb_insert_data('http://example/bookStore', '<http://example/book4>  <http://ex.org/title>  "Fundamentals of Compiler Desig4n"')->execute());
//var_dump(Rdfdb::getConnectionInfo('default'));
//echo realpath(dirname(__FILE__));
// Insert data into a graph
// INSERT DATA { graph_triples }
//  graph_triples :: = TriplesBlock | GRAPH <graph_uri> { TriplesBlock }
// INSERT DATA { GRAPH <http://example/bookStore> { <http://example/book3>  dc:title  "Fundamentals of Compiler Design" } }
// ARC2 INSERT INTO <http://example.com/> { <#foo> <bar> "baz" .}
//var_dump(rdfdb_insert_data('http://example/bookStore', '<http://example/book3>  <http://ex.org/title>  "Fundamentals of Compiler Design"')->execute());
rdfdb_insert_data('http://example/bookStore', '<http://example/book3>  <http://ex.org/title>  "Fundamentals of Compiler Design"')->execute();
rdfdb_insert_data('http://example/bookStore', '<http://example/book4>  <http://ex.org/title>  "Fundamentals of Compiler Design4"')->execute();
// An array containing prefix and namespaces as name/value pairs.
$options = array('namespaces' => array('dc' => 'http://purl.org/dc/terms/'));
//var_dump(rdfdb_insert_data('http://example/bookStore', '<http://example/book3>  dc:title  "Fundamentals of Compiler Design with ns34"', $options)->execute());
///////////////////////////////////////////////////
///////////////////////////////////////////////////
// Delete data from a graph
// DELETE DATA { graph_triples }
Beispiel #2
0
<?php

require_once 'simpletest/autorun.php';
require_once '../rdfdb.inc';
require_once '../arc/ARC2.php';
require_once '../http.inc';
$rdfdb_connection = array('driver' => 'virtuoso', 'endpoint' => 'http://localhost:18890/sparql', 'apikey' => '');
Rdfdb::addConnectionInfo('default', 'default', $rdfdb_connection);
rdfdb_set_active('defaut');
class TestRdfdb_arc2 extends UnitTestCase
{
    function testInsertData()
    {
        // Start with clean store.
        $this->_reset();
        // Insert some dummy data into 2 graphs.
        $graph1 = 'http://example/testClearGraph1';
        $rs = $this->_insertData($graph1, '<http://example/book1>  <http://ex.org/title>  "Fundamentals of Compiler Design" . <http://example/book1>  <http://ex.org/author>  "Bob" .', 2);
        // Check the content of the store.
        $expected_tsv = '
http://example/book1	http://ex.org/author	Bob
http://example/book1	http://ex.org/title	Fundamentals of Compiler Design';
        $sorted_rs = explode("\n", $this->dumpTSV());
        sort($sorted_rs);
        $sorted_rs = implode("\n", $sorted_rs);
        $this->assertEqual($sorted_rs, $expected_tsv, 'The data has been inserted in the store [%s]');
    }
    function _insertData($graph, $triples, $expected_count = NULL, $options = array())
    {
        $count = $this->countQuads();
        $rs = rdfdb_insert_data($graph, $triples)->execute();