getStore() static public method

* store
static public getStore ( $a = '', $caller = '' )
コード例 #1
0
    public function __construct() {
        parent::__construct();
        global $wgDBserver, $wgDBname, $wgDBuser, $wgDBpassword, $smwgARC2StoreConfig;

        /* instantiation */
        $this->arc2store = ARC2::getStore( $smwgARC2StoreConfig );
    }
コード例 #2
0
ファイル: DOMDocTest.php プロジェクト: patrickmj/Rubrick
 public function testAddGraphToStore()
 {
     $storeConf = array('db_host' => 'localhost', 'db_name' => 'negtest', 'db_user' => 'negtest', 'db_pwd' => 'negtest');
     $store = ARC2::getStore($storeConf);
     $store->reset();
     if (!$store->isSetUp()) {
         $store->setUp();
     }
     $docNeg = $this->getDOMDocNeg();
     $docNeg->setStore($store);
     $docNeg->process();
     $docNeg->gatherSubnegotiatorGraphs(false);
     $docNeg->addGraphToStore();
     $q = 'SELECT DISTINCT ?s ?p ?o WHERE { ?s ?p ?o }';
     $rs = $store->query($q);
     if (!$store->getErrors()) {
         $rows = $rs['result']['rows'];
         $this->assertEquals('http://example.org/domDoc', $rows[0]['s']);
     }
     $q = 'SELECT DISTINCT ?s ?p ?o WHERE { GRAPH <http://example.org/graphURI> { ?s ?p ?o } }';
     $rs = $store->query($q);
     if (!$store->getErrors()) {
         $rows = $rs['result']['rows'];
         $this->assertEquals('http://example.org/domDoc', $rows[0]['s']);
         $this->assertEquals(2, count($rows));
     }
     $q = 'SELECT DISTINCT ?s ?p ?o WHERE { GRAPH <http://example.org/graphURIX> { ?s ?p ?o } }';
     $rs = $store->query($q);
     if (!$store->getErrors()) {
         $rows = $rs['result']['rows'];
         $this->assertEquals(0, count($rows));
     }
 }
コード例 #3
0
ファイル: rdf.class.php プロジェクト: noble82/proyectos-ULS
 /**
  * Connexion au store
  * @return bool
  */
 private function connect()
 {
     $this->store = ARC2::getStore($this->config);
     if (!@$this->store->getDBCon()) {
         //On regarde si l'on peut se connecter avec les informations fournies
         $this->errors[] = "Error connexion";
         return false;
     } else {
         if (!$this->store->isSetUp()) {
             //Si les tables du store n'existent pas
             $this->store->setUp();
             //On crée les tables
             if ($erreurs = $this->store->getErrors()) {
                 //Si la création à échouée
                 foreach ($erreurs as $value) {
                     $this->errors[] = $value;
                 }
                 return false;
                 $this->store->closeDBCon();
             } else {
                 //Si on vient de faire la création pour pouvoir faire autre chose on doit se déconnecter et se reconnecter
                 $this->store->closeDBCon();
                 $this->store = ARC2::getStore($this->config);
             }
         }
     }
     return true;
 }
コード例 #4
0
ファイル: ContextReporter.php プロジェクト: patrickmj/Rubrick
 public function __construct($contextURI)
 {
     global $config;
     $this->store = ARC2::getStore($config);
     $this->contextURI = $contextURI;
     $this->query = "\n\nSELECT DISTINCT ?rName ?pURL ?pTitle  ?lvDesc  ?lvScore \nWHERE  {\n\t<{$this->contextURI}> r:hasRubric ?rubric ; \nr:hasRubric ?rubric ; \n\t    r:hasRecording ?rec .\n        ?rubric sioc:name ?rName . \n\t?rec r:hasLineValue ?lv ;\n\t\tr:hasPage ?pURL ; \n\t\t sioc:has_creator ?recCreator . \n\t?lv r:score ?lvScore ;\n\t\tr:description ?lvDesc . \nOPTIONAL {\n\t?pURL dc:title ?pTitle . \n}\t\n}\n\n\t";
 }
コード例 #5
0
 public function __construct($contextURIs)
 {
     global $config;
     global $graphConfig;
     $this->store = ARC2::getStore($config);
     $this->uris = $contextURIs;
     $this->graph = ARC2::getComponent('PMJ_ResourceGraphPlugin', $graphConfig);
 }
コード例 #6
0
 /**
  * Get the triple store.
  * @return ARC2_Store A triple store.
  */
 public function getStore()
 {
     /** @var ARC2_Store $store */
     $store = ARC2::getStore($this->getConfig());
     if (!$store->isSetUp()) {
         $store->setUp();
     }
     return $store;
 }
コード例 #7
0
ファイル: RDF_Store.php プロジェクト: paulshannon/scalar
 public function __construct()
 {
     $ci =& get_instance();
     $config = array('db_host' => $ci->db->hostname, 'db_name' => $ci->db->database, 'db_user' => $ci->db->username, 'db_pwd' => $ci->db->password, 'store_name' => rtrim($ci->db->ARC_dbprefix, '_'));
     $this->store = @ARC2::getStore($config);
     if (!$this->store->isSetUp()) {
         $this->store->setUp();
     }
     $this->ns = $ci->config->item('namespaces');
 }
コード例 #8
0
ファイル: StoreRDF.php プロジェクト: paskalkris/rdfrep-php
 public function __construct()
 {
     $this->store = ARC2::getStore($this->config);
     if (!$this->store->isSetUp()) {
         $this->store->setUp();
     }
     //$this->store->reset();
     //$this->store->query('LOAD <person.rdf>');
     //$this->store->query('LOAD <http://xmlns.com/foaf/0.1/>');
     $this->ns = array('rdf' => 'http://www.w3.org/1999/02/22-rdf-syntax-ns#', 'foaf' => 'http://xmlns.com/foaf/0.1/', 's' => 'http://www.w3.org/2000/01/rdf-schema#', 'view' => 'http://purl.org/aquarium/engine/MVC/', 'tal' => 'http://xml.zope.org/namespaces/tal');
 }
コード例 #9
0
ファイル: Constructor.php プロジェクト: patrickmj/Rubrick
 public function __construct($vars)
 {
     global $config;
     global $graphConfig;
     $this->store = ARC2::getStore($config);
     foreach ($vars as $var => $val) {
         $this->{$var} = $val;
     }
     $this->graph = ARC2::getComponent('PMJ_ResourceGraphPlugin', $graphConfig);
     $this->setQuery();
     $this->doQuery();
     $this->processResultSet();
 }
コード例 #10
0
ファイル: TagCollector.php プロジェクト: patrickmj/Rubrick
 public function __construct($array)
 {
     global $config;
     global $graphConfig;
     $this->store = ARC2::getStore($config);
     if (isset($array['uris'])) {
         $this->uris = $array['uris'];
     }
     if (isset($array['tagURIs'])) {
         $this->tagURIs = $array['tagURIs'];
     }
     $this->graph = ARC2::getComponent('PMJ_ResourceGraphPlugin', $graphConfig);
 }
コード例 #11
0
    function execute($par)
    {
        global $wgRequest, $wgOut, $smwgARC2StoreConfig, $wgServer, $wgScriptPath, $wgUser;
        if (!$this->userCanExecute($this->getUser())) {
            $this->displayRestrictionError();
            return;
        }
        $this->setHeaders();
        $output = "";
        # Get request data from, e.g.
        $rdfioAction = $wgRequest->getText('rdfio_action');
        # instantiation
        $store = ARC2::getStore($smwgARC2StoreConfig);
        $output .= "\n===RDF Store Setup===\n'''Status:'''\n\n";
        if (!$store->isSetUp()) {
            $output .= "* Store is '''not''' set up\n";
            if ($rdfioAction == "setup") {
                if (!$wgUser->matchEditToken($wgRequest->getText('token'))) {
                    die('Cross-site request forgery detected!');
                } else {
                    if ($this->isSysop) {
                        $output .= "* Setting up now ...\n";
                        $store->setUp();
                        if ($store->isSetUp()) {
                            $output .= "* Done!\n";
                        } else {
                            $output .= "Setup failed:\n";
                            $store->getErrors();
                        }
                    } else {
                        $errorMessage = "Only sysops can perform this operation!";
                        $wgOut->addHTML("<pre>Permission Error: " . $errorMessage . "</pre>");
                    }
                }
            }
        } else {
            $output .= "* Store is already set up.\n";
        }
        $wgOut->addWikiText($output);
        $htmlOutput = '<form method="get" action="' . $wgServer . $wgScriptPath . '/index.php/Special:RDFIOAdmin"
			name="createEditQuery">
			<input type="submit" name="rdfio_action" value="setup">' . Html::Hidden('token', $wgUser->getEditToken()) . '
			</form>';
        $wgOut->addHTML($htmlOutput);
        $wgOut->addWikiText("\n===Data Sources===\n");
        $wgOut->addWikiText("\n{{#ask: [[Category:RDFIO Data Source]]\n\t\t\t\t\t|?Equivalent URI\n\t\t\t\t\t|?RDFIO Import Type\n\t\t\t\t\t|format=table\n\t\t\t\t\t|mainlabel=Data Source\n\t\t\t\t\t|limit=10\n\t\t\t\t\t}}\n");
        $wgOut->addWikiText("\n===Pages and Templates===\n");
        $wgOut->addWikiText("To associate a template with a category, add <nowiki>[[Has template::Template:Name]]</nowiki> to the Category page");
        $wgOut->addWikiText("{{#ask:  [[:Category:+]]\n\t\t\t\t\t|?Equivalent URI\n\t\t\t\t\t|?Has template\n\t\t\t\t\t|format=table\n\t\t\t\t\t|mainlabel=Category\n\t\t\t\t\t|limit=10\n\t\t\t\t\t}}");
    }
コード例 #12
0
    function execute( $par ) {
		global $wgRequest, $wgOut, $smwgARC2StoreConfig,
			$wgServer, $wgScriptPath, $wgUser;

		$this->setHeaders();
		$output = "";

		# Get request data from, e.g.
		$rdfio_action = $wgRequest->getText( 'rdfio_action' );

		# instantiation
		$store = ARC2::getStore( $smwgARC2StoreConfig );

		$output .= "\n===RDF Store Setup===\n'''Status:'''\n\n";

		if ( !$store->isSetUp() ) {
			$output .= "* Store is '''not''' set up\n";
			if ( $rdfio_action == "setup" ) {
				if ( !$wgUser->matchEditToken( $wgRequest->getText( 'token' ) ) ) {
					die( 'Cross-site request forgery detected!' );
				} else {
					if ( $this->m_issysop ) {
						$output .= "* Setting up now ...\n";
						$store->setUp();
						$output .= "* Done!\n";
					} else {
						$errormessage = "Only sysops can perform this operation!";
						$wgOut->addHTML( RDFIOUtils::formatErrorHTML( "Permission Error", $errormessage ) );
					}
				}
			}
		} else {
			$output .= "* Store is already set up.\n";
		}

		$wgOut->addWikiText( $output );

		$htmlOutput = '<form method="get" action="' . $wgServer . $wgScriptPath . '/index.php/Special:ARC2Admin"
			name="createEditQuery">
			<input type="submit" name="rdfio_action" value="setup">' .
			Html::Hidden( 'token', $wgUser->editToken() ) . '
			</form>';

		$wgOut->addHTML( $htmlOutput );

	}
コード例 #13
0
ファイル: install.php プロジェクト: anukat2015/smob
function createStore($host, $name, $user, $pwd, $store_name)
{
    include_once dirname(__FILE__) . '/../lib/arc/ARC2.php';
    $config = array('db_host' => $host, 'db_name' => $name, 'db_user' => $user, 'db_pwd' => $pwd, 'store_name' => $store_name);
    $store = ARC2::getStore($config);
    if (!$store->isSetUp()) {
        $store->setUp();
        print "<p>Database correctly set-up.</p>";
    } else {
        print "<p>The store was already set up.</p>";
    }
    // write databsed information in the config file
    $config = "<?php\n\ninclude_once(dirname(__FILE__).'/../lib/arc/ARC2.php');\ninclude_once(dirname(__FILE__).'/../lib/xmlrpc/lib/xmlrpc.inc');\n\ndefine('DB_HOST', '{$host}');\ndefine('DB_NAME', '{$name}');\ndefine('DB_USER', '{$user}');\ndefine('DB_PASS', '{$pwd}');\ndefine('DB_STORE', '{$store_name}');\n\t\n";
    $f = fopen(dirname(__FILE__) . '/../config/config.php', 'w');
    fwrite($f, $config);
    fclose($f);
}
コード例 #14
0
ファイル: setupStore.php プロジェクト: rdfio/RDFIO
 public function execute()
 {
     global $smwgARC2StoreConfig;
     # Get ARC2 Store
     $store = ARC2::getStore($smwgARC2StoreConfig);
     if (!$store->isSetUp()) {
         echo "ARC2 Store is NOT setup, so setting up now ... ";
         $store->setUp();
         if ($store->isSetUp()) {
             echo "Done!\n";
         } else {
             echo "Setup failed with the following errors reported by the ARC2 library:\n";
             echo $store->getErrors();
             exit(1);
         }
     } else {
         echo "Store is already set up, so not doing anything.\n";
     }
 }
コード例 #15
0
ファイル: install.php プロジェクト: p6/arc2-starter-pack
function createStore()
{
    global $DEBUG;
    $host = urldecode($_GET['host']);
    $name = $_GET['name'];
    $user = $_GET['user'];
    $pwd = $_GET['pwd'];
    $store_name = $_GET['store'];
    print "<p>";
    $config = array('db_host' => $host, 'db_name' => $name, 'db_user' => $user, 'db_pwd' => $pwd, 'store_name' => $store_name);
    $store = ARC2::getStore($config);
    if (!$store->isSetUp()) {
        print "Setting up the store...";
        $store->setUp();
        print "Done.";
    } else {
        print "The store was already set up.";
    }
    print "\n<p>Now just paste the following snippet into the file <code>config.php</code>,\nmaking sure that <code>&lt;?php</code> is the first line:\n</p>\n<pre>\n&lt;?php\n\ninclude_once(dirname(__FILE__).'/arc/ARC2.php'); // path to the file ARC2.php\n\n// SQL database configuration for storing the postings:\n\$arc_config = array(\n  /* MySQL database settings */\n  'db_host' => '{$host}',\n  'db_user' => '{$user}',\n  'db_pwd' => '{$pwd}',\n  'db_name' => '{$name}',\n\n  /* ARC2 store settings */\n  'store_name' => '{$store_name}',\n\n  /* SPARQL endpoint settings */\n  'endpoint_features' => array(\n    'select', 'construct', 'ask', 'describe', // allow read\n    'load', 'insert', 'delete',               // allow update\n    'dump'                                    // allow backup\n  ),\n  'endpoint_timeout' => 60, /* not implemented in ARC2 preview */\n  'endpoint_read_key' => '', /* optional */\n  'endpoint_write_key' => '', /* optional */\n  'endpoint_max_limit' => 250, /* optional */\n);\n</pre>";
}
コード例 #16
0
 private function __construct($store_name)
 {
     // Load configuration options:
     $config = Kohana::config('rdform');
     $db_connection = $config['mysql_connection'] ? $config['mysql_connection'] : 'default';
     $rdf_connection = $config['rdf_connection'] ? $config['rdf_connection'] : 'default';
     if (!isset($config['mysql_connections'][$db_connection])) {
         throw new Kohana_Sparql_Exception('Mysql connection information not found for connection ' . $db_connection);
     }
     if (!isset($config['rdf_connections'][$rdf_connection])) {
         throw new Kohana_Sparql_Exception('RDF connection information not found for connection ' . $rdf_connection);
     }
     $arc_config = array_merge($config['mysql_connections'][$db_connection], $config['rdf_connections'][$rdf_connection]);
     // Instantiate an ARC object:
     $this->store = ARC2::getStore($arc_config);
     // Set up the new ARC object if not done yet:
     if (!$this->store->isSetUp()) {
         $this->store->setUp();
     }
 }
コード例 #17
0
ファイル: SMOBStore.php プロジェクト: anukat2015/smob
 function query($query, $ask = false)
 {
     global $arc_config;
     if (!$arc_config) {
         include_once dirname(__FILE__) . '/../arc/ARC2.php';
         include_once dirname(__FILE__) . '/../../config/config.php';
     }
     $store = ARC2::getStore(SMOBTools::arc_config());
     if (!$store->isSetUp()) {
         $store->setUp();
     }
     $query = "\n\tPREFIX sioc: <http://rdfs.org/sioc/ns#>\n\tPREFIX sioct: <http://rdfs.org/sioc/types#>\n\tPREFIX foaf: <http://xmlns.com/foaf/0.1/>\n\tPREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>\n\tPREFIX dct: <http://purl.org/dc/terms/>\n\tPREFIX tags: <http://www.holygoat.co.uk/owl/redwood/0.1/tags/>\n\tPREFIX moat: <http://moat-project.org/ns#>\n\tPREFIX opo: <http://online-presence.net/opo/ns#>\n\tPREFIX opo-actions: <http://online-presence.net/opo-actions/ns#>\n\tPREFIX ctag: <http://commontag.org/ns#>\n\tPREFIX smob: <http://smob.me/ns#>\n\tPREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>\n\tPREFIX xsd: <http://www.w3.org/2001/XMLSchema#>\n\tPREFIX rev: <http://purl.org/stuff/rev#>\n\tPREFIX geo: <http://www.w3.org/2003/01/geo/wgs84_pos#>\n\tPREFIX rel: <http://purl.org/vocab/relationship/>\n\n\t\t{$query}";
     $rs = $store->query($query);
     if ($errors = $store->getErrors()) {
         error_log("SMOB SPARQL Error:\n" . join("\n", $errors));
         return array();
     }
     if ($ask) {
         return $rs['result'];
     } else {
         return $rs['result']['rows'];
     }
 }
コード例 #18
0
ファイル: load.blade.php プロジェクト: Bine0511/RDF-Demo
@extends("layout")
@section("content")
	<?php 
include_once "../../arc2-master/ARC2.php";
$configLocal = array('db_name' => 'rdfdemo', 'db_user' => 'root', 'db_pwd' => '', 'store_name' => 'arc_rdf', 'max_errors' => 100);
$storeLocal = ARC2::getStore($configLocal);
if (!$storeLocal->isSetUp()) {
    $storeLocal->setUp();
}
$config = array('remote_store_endpoint' => 'http://dbpedia.org/sparql');
$store = ARC2::getRemoteStore($config);
$query = '
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX dc: <http://purl.org/dc/elements/1.1/>
PREFIX : <http://dbpedia.org/resource/>
PREFIX dbpedia2: <http://dbpedia.org/property/>
PREFIX dbpedia: <http://dbpedia.org/>
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
PREFIX dbpedia-owl: <http://dbpedia.org/ontology/>
PREFIX dcterms: <http://purl.org/dc/terms/>
PREFIX category: <http://dbpedia.org/resource/Category:>

SELECT DISTINCT *
WHERE  {{?x dcterms:subject category:Middle-earth_realms}
 UNION {?x dcterms:subject category:Middle-earth_castles_and_fortresses}
 UNION {?x dcterms:subject category:Middle-earth_races}
 UNION {?x dcterms:subject category:Middle-earth_Orcs}
コード例 #19
0
 function processQueryBlock($block)
 {
     if ($this->max_queries && $this->env['query_count'] >= $this->max_queries) {
         return $this->addError('Number of ' . $this->max_queries . ' allowed queries exceeded.');
     }
     $this->env['query_count']++;
     $ep_uri = $this->env['endpoint'];
     /* q */
     $q = 'BASE <' . $block['base'] . '>';
     $ns = isset($this->a['ns']) ? array_merge($this->a['ns'], $block['prefixes']) : $block['prefixes'];
     foreach ($ns as $k => $v) {
         $k = rtrim($k, ':');
         $q .= strpos($block['query'], $k . ':') !== false ? "\n" . 'PREFIX ' . $k . ': <' . $v . '>' : '';
     }
     $q .= "\n" . $block['query'];
     /* placeholders */
     $q = $this->replacePlaceholders($q, 'query');
     $this->env['query_log'][] = '(' . $ep_uri . ') ' . $q;
     /* local store */
     if ((!$ep_uri || $ep_uri == ARC2::getScriptURI()) && $this->v('sparqlscript_default_endpoint', '', $this->a) == 'local') {
         if (!isset($this->local_store)) {
             $this->local_store = ARC2::getStore($this->a);
         }
         /* @@todo error checking */
         return $this->local_store->query($q);
     } elseif ($ep_uri) {
         ARC2::inc('RemoteStore');
         $conf = array_merge($this->a, array('remote_store_endpoint' => $ep_uri));
         $store =& new ARC2_RemoteStore($conf, $this);
         return $store->query($q, '', $ep_uri);
     } else {
         return $this->addError("no store");
     }
 }
コード例 #20
0
ファイル: TripleRepository.php プロジェクト: tdt/triples
 /**
  * Initialize the ARC2 MySQL triplestore (if necessary) and return the instance
  * https://github.com/semsol/arc2/wiki/Using-ARC%27s-RDF-Store
  *
  * @return mixed
  */
 private function setUpArc2Store()
 {
     // Get the MySQL configuration, abort when not applicable
     $mysql_config = \Config::get('database.connections.mysql');
     if (empty($mysql_config) || $mysql_config['driver'] != 'mysql') {
         \App::abort(404, "No configuration for a MySQL connection was found. This is obligatory for the tdt/triples package.");
     }
     // Set up the configuration for the arc2 store
     $config = array('db_host' => $mysql_config['host'], 'db_name' => $mysql_config['database'], 'db_user' => $mysql_config['username'], 'db_pwd' => $mysql_config['password'], 'store_name' => $mysql_config['prefix']);
     $store = \ARC2::getStore($config);
     // Check if the store has been setup
     if (!$store->isSetUp()) {
         $store->setUp();
     }
     return $store;
 }
コード例 #21
0
function create_store($uri)
{
    $store = ARC2::getStore($GLOBALS['config']);
    if (!$store->isSetUp()) {
        $store->setUp();
    }
    $store->reset();
    /* LOAD will call the Web reader, which will call the
       format detector, which in turn triggers the inclusion of an
       appropriate parser, etc. until the triples end up in the store. */
    $store->query('LOAD <' . $uri . '>');
    return $store;
}
コード例 #22
0
 function __construct()
 {
     global $smwgARC2StoreConfig;
     $this->arcStore = ARC2::getStore($smwgARC2StoreConfig);
     $this->uriResolverUrl = '';
 }
コード例 #23
0
ファイル: index.php プロジェクト: p6/arc2-starter-pack
    </ul>
</li>

</ol>

<h2>Developing this into your own PHP application</h2>

<p>You can <strong>edit this <code>index.php</code></strong> to become 
your own application. Here's a start:</p>

<blockquote>
<?php 
print "<em>Running PHP code...</em>";
include_once dirname(__FILE__) . '/config.php';
/* store instantiation */
$store = ARC2::getStore($arc_config);
if (!$store->isSetUp()) {
    $store->setUp();
    /* create MySQL tables */
}
$result = $store->query("SELECT DISTINCT ?property WHERE { ?subject ?property ?object . }");
$rows = $result["result"]["rows"];
if ($rows) {
    print "<table border='1'>\n";
    print "<tr><th>Properties currently in use in the triple store</th></tr>\n";
    foreach ($rows as $row) {
        $item = $row["property"];
        if (strpos($item, "http://www.w3.org/1999/02/22-rdf-syntax-ns#_") !== 0) {
            print "<tr><td>" . htmlspecialchars($item) . "</td></tr>\n";
        }
    }
コード例 #24
0
 function processQueryBlock($block)
 {
     $ep_uri = $this->env['endpoint'];
     /* q */
     $q = 'BASE <' . $block['base'] . '>';
     foreach ($block['prefixes'] as $k => $v) {
         $q .= "\n" . 'PREFIX ' . $k . ' <' . $v . '>';
     }
     $q .= "\n" . $block['query'];
     /* placeholders */
     $q = $this->replacePlaceholders($q);
     /* local store */
     if ((!$ep_uri || $ep_uri == ARC2::getScriptURI()) && $this->v('sparqlscript_default_endpoint', '', $this->a) == 'local') {
         $store = ARC2::getStore($this->a);
         /* @@todo error checking */
         return $store->query($q);
     } elseif ($ep_uri) {
         ARC2::inc('RemoteStore');
         $conf = array_merge($this->a, array('remote_store_endpoint' => $ep_uri));
         $store =& new ARC2_RemoteStore($conf, $this);
         return $store->query($q, '', $ep_uri);
     } else {
         return $this->addError("no store");
     }
 }
コード例 #25
0
ファイル: synchro_rdf.class.php プロジェクト: bouchra012/PMB
 function initStore()
 {
     $this->store = ARC2::getStore($this->config);
     if (!$this->store->isSetUp()) {
         $this->store->setUp();
     }
     return;
 }
コード例 #26
0
 public function __construct()
 {
     $storeConf = array('db_host' => 'localhost', 'db_name' => 'my_db', 'db_user' => 'user', 'db_pwd' => 'secret', 'store_name' => 'my_store');
     $this->store = ARC2::getStore($storeConf);
 }
コード例 #27
0
 function replicateTo($name)
 {
     $conf = array_merge($this->a, array('store_name' => $name));
     $new_store = ARC2::getStore($conf);
     $new_store->setUp();
     $new_store->reset();
     $con = $this->getDBCon();
     $tbls = $this->getTables();
     $old_prefix = $this->getTablePrefix();
     $new_prefix = $new_store->getTablePrefix();
     foreach ($tbls as $tbl) {
         $rs = mysql_query('INSERT IGNORE INTO ' . $new_prefix . $tbl . ' SELECT * FROM ' . $old_prefix . $tbl, $con);
         if ($er = mysql_error($con)) {
             return $this->addError($er);
         }
     }
     return $new_store->query('SELECT COUNT(*) AS t_count WHERE { ?s ?p ?o}', 'row');
 }
コード例 #28
0
 function store_rdf($url, $triples)
 {
     $store = ARC2::getStore($this->a);
     if (!$store->isSetUp()) {
         $store->setUp();
     }
     if ($this->reset_tables == 1) {
         $store->reset();
     }
     if (rand(1, 50) == 1 && $this->store_size != '') {
         if ($this->store_size < $this->get_store_size()) {
             $this->store_dump();
         }
     }
     $store->delete('', $this->path . $this->type . '/' . $url);
     $store->insert($triples, '/' . $this->type . '/' . $url, $keep_bnode_ids = 1);
 }
コード例 #29
0
ファイル: testBuilder.php プロジェクト: patrickmj/Rubrick
<?php

//error_reporting(E_ALL);
include 'config.php';
include_once 'checkLogin.php';
include ARC_DIR . 'ARC2.php';
include_once CLASSES_DIR . 'RubrickBuilder.php';
include_once CLASSES_DIR . 'Rubric.php';
include_once CLASSES_DIR . 'Context.php';
include_once CLASSES_DIR . 'RubricLine.php';
include_once CLASSES_DIR . 'RubricLineValue.php';
include_once CLASSES_DIR . 'Tagging.php';
header("Content-type: application/json");
$store = ARC2::getStore($config);
//$jsonStr = '{"rubricLines":[{"action":"create","fields":[{"Name":["line%201"]},{"Description":["Describe%20the%20skills%20that%20this%20line%20evaluates"]},{"Tags":["Add%20a%20tag"]},{"Public":[1]},{"order":["0"]},{"v5":["Describe%20the%20Rubric%20Value%20here."],"score":1},{"v4":["Describe%20the%20Rubric%20Value%20here."],"score":2},{"v3":["Describe%20the%20Rubric%20Value%20here."],"score":3},{"v2":["Describe%20the%20Rubric%20Value%20here."],"score":4},{"v1":["Describe%20the%20Rubric%20Value%20here."],"score":5}]},{"action":"create","fields":[{"Name":["line%202"]},{"Description":["Describe%20the%20skills%20that%20this%20line%20evaluates"]},{"Tags":["line%20tag"]},{"Public":[1]},{"order":["1"]},{"v5":["Describe%20the%20Rubric%20Value%20here."],"score":1},{"v4":["Describe%20the%20Rubric%20Value%20here."],"score":2},{"v3":["Describe%20the%20Rubric%20Value%20here."],"score":3},{"v2":["Describe%20the%20Rubric%20Value%20here."],"score":4},{"v1":["Describe%20the%20Rubric%20Value%20here."],"score":5}]}],"rubricMeta":{"name":{"rName":["Rubric%20Name"]},"desc":{"rDesc":["Rubric%20Description"]},"tags":{"rTags":["t1","t2"]},"pub":{"rPublic":[1]},"contexts":{"rContexts":["http%3A%2F%2Fdata.rubrick-jetpack.org%2FContext%2F7af867eb16d35a749874fb71a62ecea2714c14b0"]}}}';
$jsonStr = ' {   "literals" : [ { "p" : "tagging:tagging" , "o" : "test tag" } ,

							{ "p" : "tagging:tagging" , "o" : "stuff" } ]} ';
$jsonObj = json_decode($jsonStr);
$init = array('post' => $jsonObj);
$bigGraph = ARC2::getComponent('PMJ_ResourceGraphPlugin', $graphConfig);
$newRes = new Tagging(false, $init);
$newRes->buildAddGraph();
//echo count($newRes->aggregates);
//$ag = $newRes->aggregates[0];
//echo $ag->getRevTriple();
//echo $ag->revResourceURI;
$bigGraph->mergeResourceGraph($newRes->addGraph);
foreach ($newRes->aggregates as $ag) {
    $bigGraph->mergeResourceGraph($ag->addGraph);
}
コード例 #30
0
 function getStore($ep_uri)
 {
     /* local store */
     if ((!$ep_uri || $ep_uri == ARC2::getScriptURI()) && $this->v('sparqlscript_default_endpoint', '', $this->a) == 'local') {
         if (!isset($this->local_store)) {
             $this->local_store = ARC2::getStore($this->a);
         }
         /* @@todo error checking */
         return $this->local_store;
     } elseif ($ep_uri) {
         ARC2::inc('RemoteStore');
         $conf = array_merge($this->a, array('remote_store_endpoint' => $ep_uri, 'reader_timeout' => 10));
         return new ARC2_RemoteStore($conf, $this);
     }
     return 0;
 }