private function _addTestData() { $model = $this->_store->getNewModel($this->_modelUri, '', Erfurt_Store::MODEL_TYPE_OWL, false); $this->authenticateDbUser(); $turtleString = '<http://purl.org/dc/terms/title> <http://www.w3.org/2000/01/rdf-schema#label> "testABC_en"@en .' . '<http://example.org/resourceXYZ> <http://www.w3.org/2004/02/skos/core#prefLabel> "testABC_noLang" ;' . ' <http://www.w3.org/2000/01/rdf-schema#label> "testABC_de"@de .' . '<http://example.org/graph123/resourceABC> <http://www.w3.org/2000/01/rdf-schema#label> "testABC" ;' . ' <http://ns.ontowiki.net/SysOnt/Site/menuLabel> "testMenuLabel" .'; $this->_store->importRdf($this->_modelUri, $turtleString, 'turtle', Erfurt_Syntax_RdfParser::LOCATOR_DATASTRING, false); }
public function setUp() { $this->markTestNeedsTestConfig(); $this->_storeAdapter = new Erfurt_Store_Adapter_Test(); $this->_store = new Erfurt_Store(array('adapterInstance' => $this->_storeAdapter), 'Test'); $this->_store->setAc(new Erfurt_Ac_Test()); $this->_instances = new OntoWiki_Model_Instances($this->_store, new Erfurt_Rdf_Model('http://graph.com/123/', null, $this->_store)); }
public function simpleValue($propertyName) { $query = 'PREFIX ' . $this->vocabulary->name . ': <' . $this->vocabulary->prefix . '> ' . 'SELECT ?' . $propertyName . ' ' . 'WHERE { ' . '<' . $this->url . '> ' . $this->vocabulary->name . ':' . $propertyName . ' ?' . $propertyName . ' ' . '}'; $result = $this->store->sparqlQuery($query); if (!empty($result[0][$propertyName])) { return $result[0][$propertyName]; } return NULL; }
public function addTestData() { $this->authenticateDbUser(); $turtleString = '<http://model.org/model#i1> a <' . $this->_class . '> ; <http://www.w3.org/2000/01/rdf-schema#label> "instance1"; <http://model.org/prop> "val1", "val2" . <http://model.org/model#i2> a <' . $this->_class . '> ; <http://www.w3.org/2000/01/rdf-schema#label> "instance2" ; <http://model.org/prop> "val3" .'; $this->_store->importRdf($this->_modelUri, $turtleString, 'turtle', Erfurt_Syntax_RdfParser::LOCATOR_DATASTRING, false); }
/** * Checks a given OpenID against the store and fetches the required informations. * * @param string $openId * @return array */ protected function _checkOpenId($openId) { $retVal = array('userUri' => false, 'denyLogin' => false); // Query the store. require_once 'Erfurt/Sparql/SimpleQuery.php'; $query = new Erfurt_Sparql_SimpleQuery(); $query->setProloguePart('SELECT ?s ?p ?o'); $query->addFrom($this->_acModelUri); $where = 'WHERE { ?s ?p ?o . ?s <' . EF_RDF_TYPE . '> <' . $this->_uris['user_class'] . "> .\n FILTER (sameTerm(?s, <{$openId}>))\n }"; $query->setWherePart($where); $result = $this->_store->sparqlQuery($query, array('use_ac' => false)); foreach ((array) $result as $row) { // Set user URI if ($retVal['userUri'] === false) { $retVal['userUri'] = $row['s']; } // Check predicates, whether needed. switch ($row['p']) { case $this->_uris['action_deny']: // if login is disallowed if ($row['o'] === $this->_uris['action_login']) { $retVal['denyLogin'] = true; } break; case EF_RDFS_LABEL: $retVal['userLabel'] = $row['o']; break; case $this->_uris['user_username']: $retVal['username'] = $row['o']; break; case $this->_uris['user_mail']: $retVal['email'] = $row['o']; default: // Ignore all other statements. } } return $retVal; }
/** * Returns a instance of the store. * * @return Erfurt_Store * @throws Erfurt_Exception Throws an exception if the store is not configured right. */ public function getStore() { if (null === $this->_store) { $config = $this->getConfig(); // Backend must be set, else throw an exception. if (isset($config->store->backend)) { $backend = strtolower($config->store->backend); } else { require_once 'Erfurt/Exception.php'; throw new Erfurt_Exception('Backend must be set in configuration.'); } // Check configured schema and if not set set it as empty (e.g. virtuoso needs no special schema. if (isset($config->store->schema)) { $schema = $config->store->schema; } else { $schema = null; } // fetch backend specific options from config. $backendOptions = array(); if ($backendConfig = $config->store->get($backend)) { $backendOptions = $backendConfig->toArray(); } // store config options if (isset($config->sysont)) { $storeOptions = $config->sysont->toArray(); } else { $storeOptions = array(); } require_once 'Erfurt/Store.php'; $this->_store = new Erfurt_Store($storeOptions, $backend, $backendOptions, $schema); // Make sure the store is initialized try { $this->_store->checkSetup(); } catch (Erfurt_Store_Exception $e) { if ($e->getCode() != 20) { throw $e; } } } return $this->_store; }