From b0798caeb9406543882419063d5431b40993ccfb Mon Sep 17 00:00:00 2001 From: Natanael Arndt Date: Fri, 11 Nov 2016 15:12:35 +0100 Subject: [PATCH 1/4] Improve readability of Erfurt_Store_Adapter_EfZendDb Remove commented out code and apply coding standards of Erfurt_Store_Adapter_EfZendDb --- library/Erfurt/Store/Adapter/EfZendDb.php | 217 +++++++--------------- 1 file changed, 69 insertions(+), 148 deletions(-) diff --git a/library/Erfurt/Store/Adapter/EfZendDb.php b/library/Erfurt/Store/Adapter/EfZendDb.php index afea1fdc..9406c6bf 100644 --- a/library/Erfurt/Store/Adapter/EfZendDb.php +++ b/library/Erfurt/Store/Adapter/EfZendDb.php @@ -53,9 +53,6 @@ public function __construct($adapterOptions = array()) $this->_connect(); - // we want indexed results - //$this->_dbConn->setFetchMode(Zend_Db::FETCH_NUM); - // load title properties for model titles $config = Erfurt_App::getInstance()->getConfig(); if (isset($config->properties->title)) { @@ -63,7 +60,8 @@ public function __construct($adapterOptions = array()) } } - protected function _connect(){ + protected function _connect() + { switch (strtolower($this->_adapterOptions['dbtype'])) { case 'mysql': if (extension_loaded('mysqli')) { @@ -99,37 +97,22 @@ protected function _connect(){ // maybe a needed php extension is not loaded?! throw new Erfurt_Exception('An error with the specified database adapter occured.', -1); } - - // we want indexed results - //$this->_dbConn->setFetchMode(Zend_Db::FETCH_NUM); } /** * save all but except the db connection * @return array keys to save */ - function __sleep(){ + function __sleep() + { $vars = get_object_vars($this); unset($vars['_dbConn']); return array_keys($vars); } - function __wakeUp(){ - $this->_connect(); - } - - public function __destruct() + function __wakeUp() { - #$log = Erfurt_App::getInstance()->getLog(); - - #$profiles = $this->_dbConn->getProfiler()->getQueryProfiles(); - - #foreach ($profiles as $profile) { - # $debugStr = 'Query: ' . $profile->getQuery() . PHP_EOL; - # $debugStr .= 'Time: ' . $profile->getElapsedSecs() . PHP_EOL; - # - # $log->debug($debugStr); - #} + $this->_connect(); } // ------------------------------------------------------------------------ @@ -237,15 +220,6 @@ public function addMultipleStatements($graphUri, array $statementsArray, array $ $sqlString .= "($graphId, $sValue, $pValue, $oValue,"; - #$data = array( - # 'g' => $graphId, - # 's' => $subject, - # 'p' => $predicate, - # 'o' => $object['value'], - # 'st' => $subjectIs, - # 'ot' => $objectIs - #); - if ($sRef !== false) { $sqlString .= "$sRef,"; } else { @@ -264,9 +238,6 @@ public function addMultipleStatements($graphUri, array $statementsArray, array $ $sqlString .= "$subjectIs,$objectIs,'$lang',"; - #$data['ol'] = $lang; - - if (strlen((string)$dType) > $this->_getSchemaRefThreshold()) { $dTypeHash = md5((string)$dType); @@ -282,25 +253,11 @@ public function addMultipleStatements($graphUri, array $statementsArray, array $ $sqlString .= "'$dType',$dtRef)"; } else { - #$data['od'] = $dType; $sqlString .= "'$dType',\N)"; } $insertArray[] = $sqlString; $counter++; - - #try { - # $this->_dbConn->insert('ef_stmt', $data); - # $counter++; - #} catch (Exception $e) { - # if ($this->_getNormalizedErrorCode() === 1000) { - # continue; - # } else { - # $this->_dbConn->rollback(); - # throw new Erfurt_Store_Adapter_Exception('Bulk insertion of statements failed: ' . - # $this->_dbConn->getConnection()->error); - # } - #} } } } @@ -360,7 +317,7 @@ public function countWhereMatches($graphIris, $whereSpec, $countSpec, $distinct $query->setSelectClause("COUNT DISTINCT $countSpec"); } else { // i made a (uncool) hack to fix this, the "-" is there because i didnt want to change tokenization - $query->setSelectClause("COUNT-DISTINCT $countSpec"); + $query->setSelectClause("COUNT-DISTINCT $countSpec"); } $query->setFrom($graphIris) ->setWherePart($whereSpec); @@ -474,7 +431,6 @@ public function deleteMatchingStatements($graphUri, $subject, $predicate, $objec $whereString .= " AND p = '$predicate'"; } - if (null !== $subject) { if (substr($subject, 0, 2) === '_:') { $whereString .= ' AND st = 1'; @@ -807,7 +763,7 @@ public function getSupportedImportFormats() /** @see Erfurt_Store_Adapter_Interface */ public function importRdf($modelUri, $data, $type, $locator) { -// TODO fix or remove + // TODO fix or remove if ($this->_dbConn instanceof Zend_Db_Adapter_Mysqli) { $parser = Erfurt_Syntax_RdfParser::rdfParserWithFormat($type); $parsedArray = $parser->parse($data, $locator, $modelUri, false); @@ -996,8 +952,6 @@ public function importRdf($modelUri, $data, $type, $locator) } else { $sql .= "\N,\N)"; } - - //$this->_dbConn->getConnection()->query($sql); } if ($count > 10000) { @@ -1042,16 +996,15 @@ public function listTables($prefix = '') /** @see Erfurt_Store_Adapter_Interface */ public function sparqlAsk($query) { - //TODO works for me...., why hasnt this be enabled earlier? is the same as sparqlQuery... - //looks like the engine supports it. but there is probably a reason for this not to be supported - $start = microtime(true); + $start = microtime(true); $engine = new Erfurt_Sparql_EngineDb_Adapter_EfZendDb($this->_dbConn, $this->_getModelInfos()); $parser = new Erfurt_Sparql_Parser(); - if(!($query instanceof Erfurt_Sparql_Query)) - $query = $parser->parse((string)$query); + if (!($query instanceof Erfurt_Sparql_Query)) { + $query = $parser->parse((string)$query); + } $result = $engine->queryModel($query); @@ -1067,7 +1020,11 @@ public function sparqlAsk($query) /** @see Erfurt_Store_Adapter_Interface */ public function sparqlQuery($query, $options=array()) { - $resultform =(isset($options[Erfurt_Store::RESULTFORMAT]))?$options[Erfurt_Store::RESULTFORMAT]:Erfurt_Store::RESULTFORMAT_PLAIN; + $resultform = Erfurt_Store::RESULTFORMAT_PLAIN; + + if (isset($options[Erfurt_Store::RESULTFORMAT])) { + $resultform = $options[Erfurt_Store::RESULTFORMAT]; + } $start = microtime(true); @@ -1115,8 +1072,6 @@ public function sqlQuery($sqlQuery, $limit = PHP_INT_MAX, $offset = 0) $result = $this->_dbConn->getConnection()->query($sqlQuery); } - - if ( $result !== true ) { throw new Erfurt_Store_Adapter_Exception( 'SQL query failed: ' . @@ -1155,22 +1110,22 @@ private function _createTableMysql($tableName, array $columns) $createTable = 'CREATE TABLE `' . (string) $tableName . '` ('; $i = 0; - foreach ( $columns as $columnName => $columnSpec ) { - $createTable .= PHP_EOL - . '`' . $columnName . '` ' - . $columnSpec . (($i < count($columns)-1) ? ',' : ''); - ++$i; - } - $createTable .= PHP_EOL - . ')'; - $success = $this->_dbConn->getConnection()->query($createTable); - - if ( !$success ) { -// TODO dedicated exception - throw new Exception('Could not create database table with name ' . $tableName . '.'); - } else { - return $success; - } + foreach ( $columns as $columnName => $columnSpec ) { + $createTable .= PHP_EOL + . '`' . $columnName . '` ' + . $columnSpec . (($i < count($columns)-1) ? ',' : ''); + ++$i; + } + $createTable .= PHP_EOL + . ')'; + $success = $this->_dbConn->getConnection()->query($createTable); + + if ( !$success ) { + // TODO dedicated exception + throw new Exception('Could not create database table with name ' . $tableName . '.'); + } else { + return $success; + } } /** @@ -1206,7 +1161,6 @@ private function _createTablesMysql() ); } - // Insert id of the current schema into the ef_info table. $sql = 'INSERT INTO ef_info (schema_id) VALUES ("1.0")'; @@ -1220,15 +1174,14 @@ private function _createTablesMysql() ); } - // Create ef_graph table. $sql = 'CREATE TABLE IF NOT EXISTS ef_graph ( - id INT UNSIGNED PRIMARY KEY AUTO_INCREMENT, - uri VARCHAR(160) COLLATE ascii_bin NOT NULL, - uri_r INT UNSIGNED DEFAULT NULL, - base VARCHAR(160) COLLATE ascii_bin DEFAULT NULL, - base_r INT UNSIGNED DEFAULT NULL, - UNIQUE unique_graph (uri) + id INT UNSIGNED PRIMARY KEY AUTO_INCREMENT, + uri VARCHAR(160) COLLATE ascii_bin NOT NULL, + uri_r INT UNSIGNED DEFAULT NULL, + base VARCHAR(160) COLLATE ascii_bin DEFAULT NULL, + base_r INT UNSIGNED DEFAULT NULL, + UNIQUE unique_graph (uri) ) ENGINE = MyISAM DEFAULT CHARSET = ascii;'; $success = false; @@ -1245,24 +1198,24 @@ private function _createTablesMysql() // Create ef_stmt table. $sql = 'CREATE TABLE IF NOT EXISTS ef_stmt ( - id INT UNSIGNED PRIMARY KEY AUTO_INCREMENT, - g INT UNSIGNED NOT NULL, # foreign key to ef_graph - s VARCHAR(160) COLLATE ascii_bin NOT NULL, # subject or subject hash - p VARCHAR(160) COLLATE ascii_bin NOT NULL, # predicate or predicate hash - o VARCHAR(160) COLLATE utf8_bin NOT NULL, # object or object hash - s_r INT UNSIGNED DEFAULT NULL, # foreign key to ef_uri - p_r INT UNSIGNED DEFAULT NULL, # foreign key to ef_uri - o_r INT UNSIGNED DEFAULT NULL, # foreign key to ef_uri or ef_lit - st TINYINT(1) UNSIGNED NOT NULL, # 0 - uri, 1 - bnode - ot TINYINT(1) UNSIGNED NOT NULL, # 0 - uri, 1 - bnode, 2 - literal - ol VARCHAR(10) COLLATE ascii_bin NOT NULL, - od VARCHAR(160) COLLATE ascii_bin NOT NULL, - od_r INT UNSIGNED DEFAULT NULL, - UNIQUE unique_stmt (g, s, p, o, st, ot, ol, od), - INDEX idx_g_p_o_ot (g, p, o, ot), - INDEX idx_g_o_ot (g, o, ot) - #INDEX idx_o_g_p_ot (o, g, p, ot) - #INDEX idx_s_g_p_st (s, g, p, st) + id INT UNSIGNED PRIMARY KEY AUTO_INCREMENT, + g INT UNSIGNED NOT NULL, # foreign key to ef_graph + s VARCHAR(160) COLLATE ascii_bin NOT NULL, # subject or subject hash + p VARCHAR(160) COLLATE ascii_bin NOT NULL, # predicate or predicate hash + o VARCHAR(160) COLLATE utf8_bin NOT NULL, # object or object hash + s_r INT UNSIGNED DEFAULT NULL, # foreign key to ef_uri + p_r INT UNSIGNED DEFAULT NULL, # foreign key to ef_uri + o_r INT UNSIGNED DEFAULT NULL, # foreign key to ef_uri or ef_lit + st TINYINT(1) UNSIGNED NOT NULL, # 0 - uri, 1 - bnode + ot TINYINT(1) UNSIGNED NOT NULL, # 0 - uri, 1 - bnode, 2 - literal + ol VARCHAR(10) COLLATE ascii_bin NOT NULL, + od VARCHAR(160) COLLATE ascii_bin NOT NULL, + od_r INT UNSIGNED DEFAULT NULL, + UNIQUE unique_stmt (g, s, p, o, st, ot, ol, od), + INDEX idx_g_p_o_ot (g, p, o, ot), + INDEX idx_g_o_ot (g, o, ot) + #INDEX idx_o_g_p_ot (o, g, p, ot) + #INDEX idx_s_g_p_st (s, g, p, st) ) ENGINE = MyISAM DEFAULT CHARSET = ascii;'; $success = false; @@ -1275,33 +1228,13 @@ private function _createTablesMysql() ); } - /* - // Create ef_ns table. - $sql = 'CREATE TABLE IF NOT EXISTS ef_ns ( - id INT UNSIGNED PRIMARY KEY AUTO_INCREMENT, - g INT UNSIGNED NOT NULL, - ns VARCHAR(160) COLLATE ascii_bin NOT NULL, - ns_r INT UNSIGNED DEFAULT NULL, - prefix VARCHAR(160) COLLATE ascii_bin NOT NULL, - UNIQUE unique_ns (g, ns, prefix) - ) ENGINE = MyISAM DEFAULT CHARSET = ascii;'; - - $success = false; - $success = $this->_dbConn->getConnection()->query($sql); - - if (!$success) { - throw new Erfurt_Store_Adapter_Exception('Creation of table "ef_ns" failed: ' . - $this->_dbConn->getConnection()->error); - } - */ - // Create ef_uri table. $sql = 'CREATE TABLE IF NOT EXISTS ef_uri ( - id INT UNSIGNED PRIMARY KEY AUTO_INCREMENT, - g INT UNSIGNED NOT NULL, - v LONGTEXT COLLATE ascii_bin NOT NULL, - vh CHAR(32) COLLATE ascii_bin NOT NULL, - UNIQUE unique_uri (g, vh) + id INT UNSIGNED PRIMARY KEY AUTO_INCREMENT, + g INT UNSIGNED NOT NULL, + v LONGTEXT COLLATE ascii_bin NOT NULL, + vh CHAR(32) COLLATE ascii_bin NOT NULL, + UNIQUE unique_uri (g, vh) ) ENGINE = MyISAM DEFAULT CHARSET = ascii;'; $success = false; @@ -1314,14 +1247,13 @@ private function _createTablesMysql() ); } - // Create ef_lit table. $sql = 'CREATE TABLE IF NOT EXISTS ef_lit ( - id INT UNSIGNED PRIMARY KEY AUTO_INCREMENT, - g INT UNSIGNED NOT NULL, - v LONGTEXT COLLATE utf8_bin NOT NULL, - vh CHAR(32) COLLATE ascii_bin NOT NULL, - UNIQUE unique_lit (g, vh) + id INT UNSIGNED PRIMARY KEY AUTO_INCREMENT, + g INT UNSIGNED NOT NULL, + v LONGTEXT COLLATE utf8_bin NOT NULL, + vh CHAR(32) COLLATE ascii_bin NOT NULL, + UNIQUE unique_lit (g, vh) ) ENGINE = MyISAM DEFAULT CHARSET = ascii;'; $success = false; @@ -1340,7 +1272,7 @@ private function _createTablesMysql() */ private function _createTablesSqlsrv() { - //##################################################################### + //##################################################################### // Create table ef_info if not existing $sqlsrv ='IF NOT EXISTS @@ -1359,7 +1291,6 @@ private function _createTablesSqlsrv() ); } - // Insert id of the current schema into the ef_info table. $sql = 'INSERT INTO ef_info (schema_id) VALUES (1.0)'; @@ -1373,8 +1304,6 @@ private function _createTablesSqlsrv() ); } - - //##################################################################### // Create table ef_graph if not existing @@ -1435,7 +1364,7 @@ private function _createTablesSqlsrv() ); } -//##################################################################### + //##################################################################### // Create table ef_uri if not existing $sqlsrv ='IF NOT EXISTS @@ -1513,7 +1442,6 @@ protected function _getModelInfos() ); } } - } else { throw new Erfurt_Store_Adapter_Exception( 'Store: Error while fetching model and namespace infos.', @@ -1591,8 +1519,6 @@ protected function _cleanUpValueTables($graphUri) } } - - protected function _insertValueInto($tableName, $graphId, $value, $valueHash) { $data = array( @@ -1657,14 +1583,11 @@ private function _fetchModelInfos() throw new Erfurt_Exception('Error while fetching model and namespace informations.'); } - if ($result === false) { throw new Erfurt_Exception('Error while fetching model and namespace informations.'); } else { $this->_modelInfoCache = array(); - #$rowSet = $result->fetchAll(); - #var_dump($result);exit; foreach ($result as $row) { if (!isset($this->_modelInfoCache[$row['uri']])) { $this->_modelInfoCache[$row['uri']]['modelId'] = $row['id']; @@ -1692,8 +1615,6 @@ private function _fetchModelInfos() } } - //var_dump($this->_modelInfoCache);exit; - // build the transitive closure for owl:imports // check for recursive owl:imports; also check for cylces! do { From 0d3d389cdc787d332c23b1540080ca705f0a6f3f Mon Sep 17 00:00:00 2001 From: shinobu Date: Fri, 9 Dec 2016 12:41:35 +0100 Subject: [PATCH 2/4] removes outcommented code, done depth first, finished until the store folder --- library/Erfurt/Ac/Default.php | 18 --- library/Erfurt/Auth/Adapter/FoafSsl.php | 1 - library/Erfurt/Auth/Adapter/OpenId.php | 8 -- library/Erfurt/Auth/Adapter/Rdf.php | 14 +-- library/Erfurt/Cache/Backend/Database.php | 8 -- library/Erfurt/Plugin/Manager.php | 35 ------ library/Erfurt/Rdf/Model.php | 8 -- library/Erfurt/Rdf/Resource.php | 2 - .../Sparql/EngineDb/Adapter/EfZendDb.php | 109 ---------------- .../Sparql/EngineDb/FilterGenerator.php | 2 - .../Erfurt/Sparql/EngineDb/QueryOptimizer.php | 118 +----------------- .../Sparql/EngineDb/QuerySimplifier.php | 8 +- .../EngineDb/ResultRenderer/Extended.php | 4 - .../Sparql/EngineDb/ResultRenderer/Plain.php | 30 +---- .../EngineDb/SqlGenerator/Adapter/Ef.php | 16 --- library/Erfurt/Sparql/EngineDb/TypeSorter.php | 11 -- library/Erfurt/Sparql/Parser.php | 14 +-- library/Erfurt/Sparql/Parser/Sparql10.php | 5 - .../Parser/Sparql10/Sparql10/Sparql10.php | 110 ++++------------ .../Parser/Sparql10/Sparql10/Tokenizer.php | 8 +- .../Erfurt/Sparql/Parser/Sparql11update.php | 3 - .../Parser/Util/CaseInsensitiveStream.php | 4 - library/Erfurt/Sparql/Query2.php | 22 ---- .../Sparql/Query2/Abstraction/ClassNode.php | 9 -- .../Erfurt/Sparql/Query2/ContainerHelper.php | 3 - .../Erfurt/Sparql/Query2/ElementHelper.php | 2 - library/Erfurt/Sparql/SimpleQuery.php | 4 - library/Erfurt/Store/Adapter/EfZendDb.php | 2 +- library/Erfurt/Store/Adapter/Mssql.php | 33 ----- library/Erfurt/Store/Adapter/Virtuoso.php | 15 --- 30 files changed, 37 insertions(+), 589 deletions(-) diff --git a/library/Erfurt/Ac/Default.php b/library/Erfurt/Ac/Default.php index 2ba550e8..06c432b4 100644 --- a/library/Erfurt/Ac/Default.php +++ b/library/Erfurt/Ac/Default.php @@ -373,24 +373,6 @@ public function isActionAllowed($action, $isFullUri = false) // Every Action allowed return true; } else { - // create action instance - // array for new statements (an action instance pus label) - /* - $actionStmt = array( - $actionUri => array ( - EF_RDF_TYPE => array ( - array ( 'type' => 'uri' , 'value' => $this->_uris['actionClassUri'] ) - ) , - EF_RDFS_LABEL => array ( - array ( 'type' => 'literal' , 'value' => $action ) - ) - ) - ); - - $store = Erfurt_App::getInstance()->getStore(); - $store->addMultipleStatements($this->_uris['acModelUri'], $actionStmt, false); - */ - return false; } } diff --git a/library/Erfurt/Auth/Adapter/FoafSsl.php b/library/Erfurt/Auth/Adapter/FoafSsl.php index c3ec43a6..0d43d01b 100644 --- a/library/Erfurt/Auth/Adapter/FoafSsl.php +++ b/library/Erfurt/Auth/Adapter/FoafSsl.php @@ -634,7 +634,6 @@ public function verifyIdpResult($get) if ((null === $this->_publicKey) || !extension_loaded('openssl')) { return false; } - //$this->_publicKey = str_replace(str_split(" \t\n\r\0\x0B"), '', $this->_publicKey); $schema = (isset($_SERVER['HTTPS']) && ($_SERVER['HTTPS'])) ? 'https://' : 'http://'; $url = $schema . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI']; diff --git a/library/Erfurt/Auth/Adapter/OpenId.php b/library/Erfurt/Auth/Adapter/OpenId.php index 2330fdf7..098e6b7f 100644 --- a/library/Erfurt/Auth/Adapter/OpenId.php +++ b/library/Erfurt/Auth/Adapter/OpenId.php @@ -206,14 +206,6 @@ public function authenticate() if (!isset($this->_get['openid_identity'])) { $result = false; $msg = 'OpenID authentication failed.'; - - /* - $identity = array( - 'uri' => null, - 'dbuser' => false, - 'anonymous' => false - ); - */ return new Zend_Auth_Result($result, null, array($msg)); } diff --git a/library/Erfurt/Auth/Adapter/Rdf.php b/library/Erfurt/Auth/Adapter/Rdf.php index d86784d2..cd0116a9 100644 --- a/library/Erfurt/Auth/Adapter/Rdf.php +++ b/library/Erfurt/Auth/Adapter/Rdf.php @@ -88,19 +88,7 @@ public function authenticate() 'anonymous' => false ); - // have a look at the cache... - /*$cache = Erfurt_App::getInstance()->getCache(); - $id = $cache->makeId($this, '_fetchDataForUser', array($this->_username)); - OntoWiki::getInstance()->appendMessage( new OntoWiki_Message($id)); - $cachedVal = $cache->load($id); - if ($cachedVal) { - OntoWiki::getInstance()->appendMessage( new OntoWiki_Message("cached")); - $this->_users[$this->_username] = $cachedVal; - } else { - */$this->_users[$this->_username] = $this->_fetchDataForUser($this->_username); - /*$cache->save($this->_users[$this->_username], $id, array('_fetchDataForUser')); - OntoWiki::getInstance()->appendMessage( new OntoWiki_Message("uncached")); - }*/ + $this->_users[$this->_username] = $this->_fetchDataForUser($this->_username); // if login is denied return failure auth result if ($this->_users[$this->_username]['denyLogin'] === true) { diff --git a/library/Erfurt/Cache/Backend/Database.php b/library/Erfurt/Cache/Backend/Database.php index f3b35ce9..77199cf8 100644 --- a/library/Erfurt/Cache/Backend/Database.php +++ b/library/Erfurt/Cache/Backend/Database.php @@ -80,7 +80,6 @@ public function load($id, $doNotTestCacheValidity = false) { if ($result !== false) { if (isset($result[0])) { $content = $result[0]['content']; - #$content = base64_decode($content); return $content; } } @@ -123,7 +122,6 @@ public function save($data, $id, $tags = array(), $specificLifetime = false) { } $lifetime = $this->getLifetime($specificLifetime); - #$data = $this->_getConnection()->real_escape_string($data); $data = addslashes($data); $mktime = time(); if (is_null($lifetime)) { @@ -177,12 +175,6 @@ public function test($id) { * This method will build the database structure. */ private function _buildStructure() { -# $this->_query('DROP INDEX ef_cache_tag_id_index'); -# $this->_query('DROP INDEX ef_cache_tag_name_index'); -# $this->_query('DROP INDEX ef_cache_id_expire_index'); -# $this->_query('DROP TABLE ef_cache_version'); -# $this->_query('DROP TABLE ef_cache'); -# $this->_query('DROP TABLE ef_cache_tag'); $this->_query(' CREATE TABLE ef_cache_version ( num INT, diff --git a/library/Erfurt/Plugin/Manager.php b/library/Erfurt/Plugin/Manager.php index 6b92d3d4..9b46a341 100644 --- a/library/Erfurt/Plugin/Manager.php +++ b/library/Erfurt/Plugin/Manager.php @@ -138,41 +138,6 @@ private function _addPlugin($pluginName, $pluginPath) } public function addPluginExternally($pluginName, $fileName, $pluginPath, $pluginConfig){ -// for use of array based config -// if($pluginConfig instanceof Zend_Config){ -// $pluginConfig = $pluginConfig->toArray(); -// } - -// $pluginConfig['pluginPath'] = $pluginPath; -// if(!isset($pluginConfig['enabled'])){ -// $pluginConfig['enabled'] = false; -// } -// $enabled = $pluginConfig['enabled']; -// -// // keep track of loaded plug-ins -// if (!array_key_exists($pluginName, $this->_plugins)) { -// $this->_plugins[$pluginName] = $pluginConfig; -// } -// -// if ($enabled && isset($pluginConfig['events']) && is_array($pluginConfig['events'])) { -// foreach ($pluginConfig['events'] as $event) { -// if (is_array($event)) { -// // TODO: allow trigger method that differs from event name -// } else if (is_string($event)) { -// $pluginSpec = array( -// 'class_name' => ucfirst($pluginName) . self::PLUGIN_CLASS_POSTFIX, -// 'file_name' => $fileName, -// 'include_path' => $pluginPath, -// 'config' => isset($pluginPrivateConfig) ? $pluginPrivateConfig : null -// ); -// -// $priority = isset($event['priority']) ? (int) $event['priority'] : 10; -// -// // register plugin events with event dispatcher -// $this->_eventDispatcher->register($event, $pluginSpec, $priority); -// } -// } -// } $pluginConfig->pluginPath = $pluginPath; if(!isset($pluginConfig->enabled)){ $pluginConfig->enabled = false; diff --git a/library/Erfurt/Rdf/Model.php b/library/Erfurt/Rdf/Model.php index 65d03a0f..ba6f5c29 100644 --- a/library/Erfurt/Rdf/Model.php +++ b/library/Erfurt/Rdf/Model.php @@ -655,14 +655,6 @@ public function sparqlQuery($query, $options = array()) return $this->getStore()->sparqlQuery($query, $options); } - /*public function sparqlQueryWithPlainResult($query) - { - $queryObject = Erfurt_Sparql_SimpleQuery::initWithString($query); - $queryObject->addFrom($this->_graphUri); - - return $this->getStore()->sparqlQuery($queryObject); - }*/ - /** * set the model store * diff --git a/library/Erfurt/Rdf/Resource.php b/library/Erfurt/Rdf/Resource.php index 2cb37bcd..ae9a70f3 100644 --- a/library/Erfurt/Rdf/Resource.php +++ b/library/Erfurt/Rdf/Resource.php @@ -262,8 +262,6 @@ protected function _fetchDescription($maxDepth) $this->_descriptionResource($property); $currentValue = array( - // typed-literal --> literal - // 'type' => str_replace('typed-', '', $row['o']['type']), 'type' => $row['o']['type'], 'value' => $row['o']['value'] ); diff --git a/library/Erfurt/Sparql/EngineDb/Adapter/EfZendDb.php b/library/Erfurt/Sparql/EngineDb/Adapter/EfZendDb.php index 0d31776c..bdd420aa 100644 --- a/library/Erfurt/Sparql/EngineDb/Adapter/EfZendDb.php +++ b/library/Erfurt/Sparql/EngineDb/Adapter/EfZendDb.php @@ -122,97 +122,6 @@ public function getTypeSorter() return $this->ts; } - /** - * Create a prepared statement that can be executed later. - * - * @param Dataset $dataset RDF Dataset - * @param Query $query Parsed SPARQL query - * - * @return SparqlEngineDb_PreparedStatement Prepared statment that can - * be execute()d later. - */ - /*public function prepare(Dataset $dataset, Query $query) - { - //require_once RDFAPI_INCLUDE_DIR . 'sparql/SparqlEngineDb/PreparedStatement.php'; - //require_once RDFAPI_INCLUDE_DIR . 'sparql/SparqlEngineDb/Preparator.php'; - - $this->query = $query; - $this->dataset = $dataset; - $this->sg = new SparqlEngineDb_SqlGenerator ($this->query, $this->dbConn, $this->arModelIds); - $this->rc = new SparqlEngineDb_ResultConverter($this->query, $this->sg, $this); - $this->ts = new SparqlEngineDb_TypeSorter ($this->query, $this->dbConn); - $this->pr = new SparqlEngineDb_Preparator ($this->query, $this->dbConn); - - $this->arPrepared = $this->sg->createSql(); - $this->ts->setData($this->sg); - - if ($this->ts->willBeDataDependent()) { - $this->bRealPrepared = false; - } else { - $this->bRealPrepared = true; - list($strSelect, $strFrom, $strWhere) = $this->arPrepared; - $this->arPreparedQueries = $this->ts->getOrderifiedSqls( - $strSelect, - $strFrom, - $strWhere - ); - $this->arDbStatements = $this->pr->prepareInDb( - $this->arPreparedQueries, - $this->sg->getPlaceholders() - ); - } - - - return new SparqlEngineDb_PreparedStatement( - $this - ); - }*/ - - /** - * Execute a prepared statement by filling it with variables - * - * @param array $arVariables Array with (variable name => value) pairs - * @param string $resultform Which form the result should have - * - * @return mixed Result according to $resultform - */ - /*public function execute($arVariables, $resultform = false) - { - if ($this->arPrepared === null) { - throw new Exception('You need to prepare() the query first.'); - } - - if ($this->bRealPrepared) { - return - SparqlEngineDb_ResultConverter::convertFromDbResults( - $this->pr->execute( - $this->arDbStatements, - $arVariables - ), - $this, - $resultform - ); - } else { - list($strSelect, $strFrom, $strWhere) = $this->arPrepared; - - return SparqlEngineDb_ResultConverter::convertFromDbResults( - $this->_queryMultiple( - $this->ts->getOrderifiedSqls( - $strSelect, - $strFrom, - $this->pr->replacePlaceholdersWithVariables( - $strWhere, - $this->sg->getPlaceholders(), - $arVariables - ) - ) - ), - $this, - $resultform - ); - } - }*/ - /** * Query the database with the given SPARQL query. * @@ -243,9 +152,6 @@ public function queryModel(Erfurt_Sparql_Query $query, $resultform = 'plain') case 'xml': $rc = new Erfurt_Sparql_EngineDb_ResultRenderer_Xml(); break; - //throw new Erfurt_Exception('XML result format not supported yet.'); - //$this->rc = new Erfurt_Sparql_EngineDb_ResultRenderer_RapZendDb_Xml(); - //break; case 'extended': $rc = new Erfurt_Sparql_EngineDb_ResultRenderer_Extended(); break; @@ -271,7 +177,6 @@ public function queryModel(Erfurt_Sparql_Query $query, $resultform = 'plain') $this->_setOptions(); $arSqls = $this->sg->createSql(); - #var_dump($arSqls);exit; $this->ts->setData($this->sg); @@ -298,8 +203,6 @@ public function sqlQuery($sql) protected function _queryDb($arSql, $nOffset, $nLimit) { $strSql = Erfurt_Sparql_EngineDb_SqlMerger::getSelect($this->query, $arSql); -#var_dump($nLimit, $nOffset); -#echo $strSql; if ($strSql === '()') { return array(); } @@ -361,16 +264,4 @@ protected function _queryMultiple($arSqls) return $arResults; } - /** - * Set options to subobjects like SqlGenerator - */ - protected function _setOptions() - { - // allow changing the statements' table name - //if (isset($GLOBALS['RAP']['conf']['database']['tblStatements'])) { - // $this->sg->setStatementsTable( - // $GLOBALS['RAP']['conf']['database']['tblStatements'] - // ); - //} - } } diff --git a/library/Erfurt/Sparql/EngineDb/FilterGenerator.php b/library/Erfurt/Sparql/EngineDb/FilterGenerator.php index 1f8ebf49..4c5be502 100644 --- a/library/Erfurt/Sparql/EngineDb/FilterGenerator.php +++ b/library/Erfurt/Sparql/EngineDb/FilterGenerator.php @@ -98,7 +98,6 @@ public function createFilterSql($tree, $bOptional, $nUnionCount) $this->bOptional = $bOptional; $this->nUnionCount = $nUnionCount; -#return ' AND ' . $this->createTreeSql($tree, null); try { return ' AND ' . $this->createTreeSql($tree, null); } catch (Exception $e) { @@ -610,7 +609,6 @@ protected function createFunction_regex($tree) break; default: - //var_dump($strMod);exit; throw new Erfurt_Sparql_EngineDb_SqlGeneratorException( 'Unsupported regex modifier "' . $strMod diff --git a/library/Erfurt/Sparql/EngineDb/QueryOptimizer.php b/library/Erfurt/Sparql/EngineDb/QueryOptimizer.php index 3d6f84f8..8be38350 100644 --- a/library/Erfurt/Sparql/EngineDb/QueryOptimizer.php +++ b/library/Erfurt/Sparql/EngineDb/QueryOptimizer.php @@ -30,8 +30,6 @@ public function optimize(Erfurt_Sparql_Query $query) $result = $query; // TODO Not working on all queries yet. -#return $result; - if ($resultForm === 'select distinct') { $result = $this->_optimizeDistinct($query); } @@ -123,26 +121,13 @@ protected function _optimizeDistinct($query) $orderifiedSqls = $ts->getOrderifiedSqls($arSqls); $originalVars = $sg->arVarAssignments; -#var_dump($originalVars); - - - - - $usedVars = array_unique($usedVars); $newResultVars = array(); $tempQuery = clone $query; // We need to adjust the limit, offset values. -// TODO limit offset support - #$sm = $tempQuery->getSolutionModifier(); - #if (isset($sm['limit'])) { - # $tempQuery->setSolutionModifier('limit', 1000); - #} - #if (isset($sm['offset'])) { - # $tempQuery->setSolutionModifier('offset', 0); - #} + // TODO limit offset support foreach ($tempQuery->getResultVars() as $var) { if (in_array($var->getVariable(), $usedVars)) { @@ -163,7 +148,6 @@ protected function _optimizeDistinct($query) $orderifiedSqls = $ts->getOrderifiedSqls($arSqls); $mandatoryResult = $this->_queryMultiple($tempQuery, $orderifiedSqls); $mandatoryVars = $sg->arVarAssignments; -#var_dump($mandatoryResult);exit; // If the mandatory result is empty... return it. $empty = true; @@ -205,82 +189,6 @@ protected function _optimizeDistinct($query) } reset($mandatoryResult); -#var_dump($replaceArray);exit; - // Remove all old mandatory constraints from the query (already done with the first query). - // Replace them with a new sameTerm constraint - #$cArray = array(); - - #$distinctKeys = array(); -// TODO Function nesting fatal error on big result :( - /*foreach ($replaceArray as $var => $values) { - $distinctKeys[] = $var; - $c = new Erfurt_Sparql_Constraint(); - - $valueSameTermArray = array(); - foreach ($values as $key => $true) { - $valueSameTermArray[] = 'sameTerm(' . $var . ', <' . $key . '>)'; - } - - $expr = '(' . implode(' || ', $valueSameTermArray) . ')'; - $c->addExpression($expr); - $c->parse(); - $cArray[] = $c; - }*/ -#var_dump($cArray);exit; - - /*$ids = array(); - foreach ($optionals as $graphPattern) { - $newCArray = array(); - foreach ($cArray as $c) { - $add = false; - $usedVars = $c->getUsedVars(); - foreach ($graphPattern->getVariables() as $v) { - if (in_array($v, $usedVars)) { - $add = true; - break; - } - } - - if ($add) { - $newCArray[] = $c; - } - } - - #$graphPattern->setConstraints($newCArray); - foreach ($oldMandatory as $gp) { - if ($graphPattern->getOptional() === $gp->getId() && !empty($newCArray)) { - $gp->setTriplePatterns(array()); - $gp->setConstraints($newCArray); - } - - - } - - $ids[$graphPattern->getOptional()] = true; - } - - foreach ($oldMandatory as $key => $pattern) { - if (!isset($ids[$pattern->getId()])) { - $unsetIds[$pattern->getId()] = true; - unset($oldMandatory[$key]); - } - } - foreach ($oldMandatory as $pattern) { - if (isset($unsetIds[$pattern->getUnion()])) { - $pattern->setUnion(null); - } - } - */ - - - - #$pattern = new Erfurt_Sparql_GraphPattern(); - #$pattern->setId(1000); - #$pattern->setOptional(0); - #$pattern->addTriplePattern(new Erfurt_Sparql_QueryTriple('?predicate', Erfurt_Rdf_Resource::initWithUri('dummy'), Erfurt_Rdf_Resource::initWithUri('dummy'))); - - # $optionals[] = $pattern; - foreach ($oldMandatory as $gp) { $gp->setTriplePatterns(array()); $gp->setConstraints(array()); @@ -288,7 +196,6 @@ protected function _optimizeDistinct($query) // Set new result form to select (not distinct) - #$newPatterns = $optionals; $newPatterns = array_merge($oldMandatory, $optionals); $usedVars = array(); foreach ($newPatterns as $pattern) { @@ -305,7 +212,6 @@ protected function _optimizeDistinct($query) $query->setResultVars($usedVarsObjects); $query->setResultPart($newPatterns); $query->setResultForm('select'); -#var_dump($query);exit; $sg = new Erfurt_Sparql_EngineDb_SqlGenerator_Adapter_Ef($query, $this->_engine->getModelIdMapping()); $ts = new Erfurt_Sparql_EngineDb_TypeSorter($query, $this->_engine); @@ -316,9 +222,6 @@ protected function _optimizeDistinct($query) $orderifiedSqls = $ts->getOrderifiedSqls($arSqls); $optionalVars = $sg->arVarAssignments; -#var_dump($optionalVars); -#var_dump($replaceArray);exit; - $whereAddition = array(); foreach ($optionalVars as $var => $varSpec) { foreach ($replaceArray as $key => $values) { @@ -335,15 +238,9 @@ protected function _optimizeDistinct($query) if(!empty($whereAddition)) $sql['where'] .= ' AND ' . implode(' AND ', $whereAddition); } } -#var_dump($orderifiedSqls);exit; $optionalResult = $this->_queryMultiple($query, $orderifiedSqls); - -#var_dump($optionalResult);exit; - -#var_dump($originalVars, $optionalVars, $optionalResult);exit; - $newOptResult = array(); // Remove double entries $alreadyIn = array(); @@ -358,12 +255,9 @@ protected function _optimizeDistinct($query) } } $optionalResult = array($newOptResult); -#var_dump($optionalVars);exit; - - + $newResult = array(); - -#var_dump($mandatoryResult);exit; + $mResult = current($mandatoryResult); while (true) { $rowSpec = array(); @@ -549,8 +443,6 @@ protected function _optimizeDistinct($query) } } -#var_dump($newResult);exit; - $retVal = array($newResult); return array('data' => $retVal, 'vars' => $originalVars); } @@ -558,7 +450,6 @@ protected function _optimizeDistinct($query) protected function _queryDb($query, $arSql, $nOffset, $nLimit) { $strSql = Erfurt_Sparql_EngineDb_SqlMerger::getSelect($query, $arSql); -#echo $strSql; if ($strSql === '()') { return array(); } @@ -570,7 +461,6 @@ protected function _queryDb($query, $arSql, $nOffset, $nLimit) } else { $ret = $this->_engine->sqlQuery($strSql . ' LIMIT ' . $nOffset . ', ' . $nLimit); } -#var_dump($ret->fetchAll());exit; return $ret; } @@ -593,7 +483,6 @@ protected function _queryMultiple($query, $arSqls) list($nSql, $nOffset) = $offsetter->determineOffset($arSqls); $nLimit = $arSM['limit']; } -#var_dump($arSqls, $offsetter->determineOffset($arSqls)); $nCount = 0; $arResults = array(); foreach ($arSqls as $nId => $arSql) { @@ -608,7 +497,6 @@ protected function _queryMultiple($query, $arSqls) } $dbResult = $this->_queryDb($query, $arSql, $nOffset, $nCurrentLimit); -#var_dump($dbResult); $nCount += count($dbResult); $arResults[] = $dbResult; $nOffset = 0; diff --git a/library/Erfurt/Sparql/EngineDb/QuerySimplifier.php b/library/Erfurt/Sparql/EngineDb/QuerySimplifier.php index 3cb475a4..8ab2459e 100644 --- a/library/Erfurt/Sparql/EngineDb/QuerySimplifier.php +++ b/library/Erfurt/Sparql/EngineDb/QuerySimplifier.php @@ -37,7 +37,7 @@ class Erfurt_Sparql_EngineDb_QuerySimplifier * Modifies the passed query object directly. */ public function simplify(Erfurt_Sparql_Query $query) { -#return; + $arPatterns = $query->getResultPart(); self::dropEmpty($arPatterns); @@ -91,7 +91,6 @@ protected function executePlan(&$arPatterns, &$arPlan) $id = count($arPatterns)+1; foreach ($arPlan as $nParent => $arChildren) { $base = $arPatterns[$nParent]; - #$grandParent = $base->getSubpatternOf(); $nNextId = $nParent; $oldConstraints = $base->getConstraints(); @@ -99,10 +98,7 @@ protected function executePlan(&$arPatterns, &$arPlan) $optionalIds = $this->_getOptionalIds($arPatterns, $nParent); foreach ($arChildren as $nChild => $null) { - #$new = clone $base; - #$new->addTriplePatterns($arPatterns[$nChild]->getTriplePatterns()); - #$new->addConstraints($arPatterns[$nChild]->getConstraints()); - + $arPatterns[$nChild]->addTriplePatterns($base->getTriplePatterns()); // Catch all used vars from child pattern. diff --git a/library/Erfurt/Sparql/EngineDb/ResultRenderer/Extended.php b/library/Erfurt/Sparql/EngineDb/ResultRenderer/Extended.php index b2ea6c7b..9bba2273 100644 --- a/library/Erfurt/Sparql/EngineDb/ResultRenderer/Extended.php +++ b/library/Erfurt/Sparql/EngineDb/ResultRenderer/Extended.php @@ -156,8 +156,6 @@ protected function _createObjectFromDbRecordSetPart($row, $strVarBase, $strVar, break; default: if ($row[$this->_vars[$strVarName]['sql_ref']] === null) { - #$result = $this->_createLiteral( - # $row[$this->_vars[$strVarName]['sql_value']], null, null); if ($row[$this->_vars[$strVarName]['sql_dt_ref']] === null) { $result = $this->_createLiteral( @@ -173,8 +171,6 @@ protected function _createObjectFromDbRecordSetPart($row, $strVarBase, $strVar, ); } } else { - #$result = $this->_createLiteral( - #$this->literalValues[$row[$this->_vars[$strVarName]['sql_ref']]], null, null); if ($row[$this->_vars[$strVarName]['sql_dt_ref']] === null) { $result = $this->_createLiteral( diff --git a/library/Erfurt/Sparql/EngineDb/ResultRenderer/Plain.php b/library/Erfurt/Sparql/EngineDb/ResultRenderer/Plain.php index 84ccace7..f3dfb7bc 100644 --- a/library/Erfurt/Sparql/EngineDb/ResultRenderer/Plain.php +++ b/library/Erfurt/Sparql/EngineDb/ResultRenderer/Plain.php @@ -258,37 +258,11 @@ protected function _createObjectFromDbRecordSetPart($row, $strVarBase, $strVar, if ($row[$this->_vars[$strVarName]['sql_ref']] === null) { $result = $this->_createLiteral( $row[$this->_vars[$strVarName]['sql_value']], null, null); - - #if ($row[$this->_vars[$strVarName]['sql_dt_ref']] === null) { - # $result = $this->_createLiteral( - # $row[$this->_vars[$strVarName]['sql_value']], - # $row[$this->_vars[$strVarName]['sql_lang']], - # $row[$this->_vars[$strVarName]['sql_type']] - # ); - #} else { - # $result = $this->_createLiteral( - # $row[$this->_vars[$strVarName]['sql_value']], - # $row[$this->_vars[$strVarName]['sql_lang']], - # $this->uriValues[$row[$this->_vars[$strVarName]['sql_dt_ref']]] - # ); - #} + } else { $result = $this->_createLiteral( $this->literalValues[$row[$this->_vars[$strVarName]['sql_ref']]], null, null); - - #if ($row[$this->_vars[$strVarName]['sql_dt_ref']] === null) { - # $result = $this->_createLiteral( - # $this->literalValues[$row[$this->_vars[$strVarName]['sql_ref']]], - # $row[$this->_vars[$strVarName]['sql_lang']], - # $row[$this->_vars[$strVarName]['sql_type']] - # ); - #} else { - # $result = $this->_createLiteral( - # $this->literalValues[$row[$this->_vars[$strVarName]['sql_ref']]], - # $row[$this->_vars[$strVarName]['sql_lang']], - # $this->uriValues[$row[$this->_vars[$strVarName]['sql_dt_ref']]] - # ); - #} + } } diff --git a/library/Erfurt/Sparql/EngineDb/SqlGenerator/Adapter/Ef.php b/library/Erfurt/Sparql/EngineDb/SqlGenerator/Adapter/Ef.php index c1a53658..c251e9e6 100644 --- a/library/Erfurt/Sparql/EngineDb/SqlGenerator/Adapter/Ef.php +++ b/library/Erfurt/Sparql/EngineDb/SqlGenerator/Adapter/Ef.php @@ -207,10 +207,6 @@ public function createSql() foreach ($this->query->getResultPart() as $graphPattern) { - #if ($graphPattern->isEmpty()) { - # continue; - #} - if ($graphPattern->getUnion() !== null) { ++$this->nUnionCount; $this->nTableId = 0; @@ -395,14 +391,10 @@ function getTripleSql(Erfurt_Sparql_QueryTriple $triple, Erfurt_Sparql_GraphPatt $bWhereEqualitySubject = true; $this->arUsedVarTypes[$subject]['s'] = true; } else { - #if (isset($this->arVarAssignments[$subject][0])) { - # $strTablePrefix = $this->arVarAssignments[$subject][0]; - #} if (!isset($this->arVarAssignments[$subject])) { $this->arVarAssignments[$subject] = array($strTablePrefix, 's'); } - #$this->arVarAssignments[$subject] = array($strTablePrefix, 's'); $this->arVarAssignments[$subject][1] = 's'; $this->arUnionVarAssignments[$this->nUnionCount][$subject] = array($strTablePrefix, 's'); $this->arUsedVarTypes[$subject]['s'] = true; @@ -433,14 +425,10 @@ function getTripleSql(Erfurt_Sparql_QueryTriple $triple, Erfurt_Sparql_GraphPatt $bWhereEqualityPredicate = true; $this->arUsedVarTypes[$predicate]['p'] = true; } else { - #if (isset($this->arVarAssignments[$predicate][0])) { - # $strTablePrefix = $this->arVarAssignments[$predicate][0]; - #} if (!isset($this->arVarAssignments[$predicate])) { $this->arVarAssignments[$predicate] = array($strTablePrefix, 'p'); } - #$this->arVarAssignments[$predicate] = array($strTablePrefix, 'p'); $this->arVarAssignments[$predicate][1] = 'p'; $this->arUnionVarAssignments[$this->nUnionCount][$predicate] = array($strTablePrefix, 'p'); $this->arUsedVarTypes[$predicate]['p'] = true; @@ -467,9 +455,6 @@ function getTripleSql(Erfurt_Sparql_QueryTriple $triple, Erfurt_Sparql_GraphPatt $bWhereEqualityObject = true; $this->arUsedVarTypes[$object]['o'] = true; } else { - #if (isset($this->arVarAssignments[$object][0])) { - # $strTablePrefix = $this->arVarAssignments[$object][0]; - #} if (!isset($this->arVarAssignments[$object])) { $this->arVarAssignments[$object] = array($strTablePrefix, 'o'); } @@ -712,7 +697,6 @@ protected function createEqualSelects($arSelect) $ar[] = implode(',', $arVarParts); $arHasItems = true; } - // if (count($ar) > 0) { if ( true === $arHasItems ) { $arNewSelect[0][] = implode(',', $ar); } diff --git a/library/Erfurt/Sparql/EngineDb/TypeSorter.php b/library/Erfurt/Sparql/EngineDb/TypeSorter.php index 4a9232a5..d89feb69 100644 --- a/library/Erfurt/Sparql/EngineDb/TypeSorter.php +++ b/library/Erfurt/Sparql/EngineDb/TypeSorter.php @@ -285,9 +285,6 @@ protected function getTypeSets($arSpecialVars, $strFrom, $strWhere, $nUnion) $var['datatype'] = array_values(array_unique($var['datatype'])); } } - - - //$arTypes = array_unique($arTypes); return $arTypes; } @@ -409,13 +406,6 @@ function getSqlOrderBy($arTypeSet = array(), $n = 0) return ''; } - #if (count($arTypeSet) === 0) { - # return ''; - #} - -//var_dump($arTypeSet); -//var_dump($this->arUnionVarAssignments); - $sqlOrder = array(); foreach ($arSM['order by'] as $arVar) { $strSparqlVar = $arVar['val']; @@ -452,7 +442,6 @@ function getSqlOrderBy($arTypeSet = array(), $n = 0) if (count($sqlOrder) === 0) { throw new Erfurt_Exception('Something went wrong with ORDER BY.'); } -//var_dump($sqlOrder);exit; return ' ORDER BY ' . implode(', ', $sqlOrder); }//function getSqlOrderBy($arTypeSet = array()) diff --git a/library/Erfurt/Sparql/Parser.php b/library/Erfurt/Sparql/Parser.php index 21a7a975..4e26d43d 100644 --- a/library/Erfurt/Sparql/Parser.php +++ b/library/Erfurt/Sparql/Parser.php @@ -445,10 +445,7 @@ protected function _dtypeCheck(&$node) /** FastForward until next token which is not blank. */ protected function _fastForward() - { - #next($this->_tokens); - #return; - + { $tok = next($this->_tokens); while ($tok === ' ') { $tok = next($this->_tokens); @@ -683,15 +680,6 @@ protected function _parseConstraintTree($nLevel = 0, $bParameter = false) } continue 2; break; -# case '>': -# $litQuotes = null; -# $part[] = array( -# 'type' => 'value', -# 'value' => $strQuoted, -# 'quoted'=> false -# ); -# continue 2; -# break; case '(': $parens = true; $bFunc1 = isset($part[0]['type']) && $part[0]['type'] === 'value'; diff --git a/library/Erfurt/Sparql/Parser/Sparql10.php b/library/Erfurt/Sparql/Parser/Sparql10.php index 17ab331a..3f4e8838 100644 --- a/library/Erfurt/Sparql/Parser/Sparql10.php +++ b/library/Erfurt/Sparql/Parser/Sparql10.php @@ -22,7 +22,6 @@ public static function initFromString($queryString, $parsePartial = null){ $retval=null; $input = new Erfurt_Sparql_Parser_Util_CaseInsensitiveStream($queryString); $lexer = new Erfurt_Sparql_Parser_Sparql10_Sparql10Lexer($input); -// if (!count($lexer->getErrors())) { $tokens = new CommonTokenStream($lexer); $parser = new Erfurt_Sparql_Parser_Sparql10_Sparql10Parser($tokens); if($parsePartial != null && is_string($parsePartial) && method_exists($parser, $parsePartial)){ @@ -30,12 +29,8 @@ public static function initFromString($queryString, $parsePartial = null){ } else { $retval = $parser->parse(); } -// } return array('retval' =>$retval, 'errors'=> - //array_merge($lexer->getErrors(), - //$parser? $parser->getErrors() - //:array()) ); } diff --git a/library/Erfurt/Sparql/Parser/Sparql10/Sparql10/Sparql10.php b/library/Erfurt/Sparql/Parser/Sparql10/Sparql10/Sparql10.php index 6b81aad4..9f404c85 100644 --- a/library/Erfurt/Sparql/Parser/Sparql10/Sparql10/Sparql10.php +++ b/library/Erfurt/Sparql/Parser/Sparql10/Sparql10/Sparql10.php @@ -5440,8 +5440,6 @@ static function getValues(){ class Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA9 extends DFA { public function __construct($recognizer) { -// global $Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA9; -// $DFA = $Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA9; $DFA = Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA9_static::getValues(); $this->recognizer = $recognizer; $this->decisionNumber = 9; @@ -5493,8 +5491,6 @@ static function getValues(){ class Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA21 extends DFA { public function __construct($recognizer) { -// global $Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA21; -// $DFA = $Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA21; $DFA = Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA21_static::getValues(); $this->recognizer = $recognizer; $this->decisionNumber = 21; @@ -5546,8 +5542,6 @@ static function getValues(){ class Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA24 extends DFA { public function __construct($recognizer) { -// global $Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA24; -// $DFA = $Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA24; $DFA = Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA24_static::getValues(); $this->recognizer = $recognizer; $this->decisionNumber = 24; @@ -5598,8 +5592,6 @@ static function getValues(){ class Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA23 extends DFA { public function __construct($recognizer) { -// global $Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA23; -// $DFA = $Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA23; $DFA = Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA23_static::getValues(); $this->recognizer = $recognizer; $this->decisionNumber = 23; @@ -5653,8 +5645,6 @@ static function getValues(){ class Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA25 extends DFA { public function __construct($recognizer) { -// global $Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA25; -// $DFA = $Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA25; $DFA = Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA25_static::getValues(); $this->recognizer = $recognizer; $this->decisionNumber = 25; @@ -5708,9 +5698,7 @@ static function getValues(){ class Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA27 extends DFA { public function __construct($recognizer) { -// global $Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA27; -// $DFA = $Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA27; - $DFA = Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA27_static::getValues(); + $DFA = Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA27_static::getValues(); $this->recognizer = $recognizer; $this->decisionNumber = 27; $this->eot = $DFA['eot']; @@ -5763,9 +5751,7 @@ static function getValues(){ class Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA28 extends DFA { public function __construct($recognizer) { -// global $Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA28; -// $DFA = $Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA28; - $DFA = Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA28_static::getValues(); + $DFA = Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA28_static::getValues(); $this->recognizer = $recognizer; $this->decisionNumber = 28; $this->eot = $DFA['eot']; @@ -5818,9 +5804,7 @@ static function getValues(){ class Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA30 extends DFA { public function __construct($recognizer) { -// global $Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA30; -// $DFA = $Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA30; - $DFA = Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA30_static::getValues(); + $DFA = Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA30_static::getValues(); $this->recognizer = $recognizer; $this->decisionNumber = 30; $this->eot = $DFA['eot']; @@ -5873,9 +5857,7 @@ static function getValues(){ class Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA33 extends DFA { public function __construct($recognizer) { -// global $Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA33; -// $DFA = $Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA33; - $DFA = Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA33_static::getValues(); + $DFA = Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA33_static::getValues(); $this->recognizer = $recognizer; $this->decisionNumber = 33; $this->eot = $DFA['eot']; @@ -5925,9 +5907,7 @@ static function getValues(){ class Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA34 extends DFA { public function __construct($recognizer) { -// global $Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA34; -// $DFA = $Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA34; - $DFA = Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA34_static::getValues(); + $DFA = Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA34_static::getValues(); $this->recognizer = $recognizer; $this->decisionNumber = 34; $this->eot = $DFA['eot']; @@ -5981,9 +5961,7 @@ static function getValues(){ class Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA37 extends DFA { public function __construct($recognizer) { -// global $Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA37; -// $DFA = $Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA37; - $DFA = Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA37_static::getValues(); + $DFA = Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA37_static::getValues(); $this->recognizer = $recognizer; $this->decisionNumber = 37; $this->eot = $DFA['eot']; @@ -6035,9 +6013,7 @@ static function getValues(){ class Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA38 extends DFA { public function __construct($recognizer) { -// global $Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA38; -// $DFA = $Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA38; - $DFA = Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA38_static::getValues(); + $DFA = Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA38_static::getValues(); $this->recognizer = $recognizer; $this->decisionNumber = 38; $this->eot = $DFA['eot']; @@ -6089,9 +6065,7 @@ static function getValues(){ class Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA39 extends DFA { public function __construct($recognizer) { -// global $Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA39; -// $DFA = $Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA39; - $DFA = Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA39_static::getValues(); + $DFA = Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA39_static::getValues(); $this->recognizer = $recognizer; $this->decisionNumber = 39; $this->eot = $DFA['eot']; @@ -6152,9 +6126,7 @@ static function getValues(){ class Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA41 extends DFA { public function __construct($recognizer) { -// global $Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA41; -// $DFA = $Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA41; - $DFA = Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA41_static::getValues(); + $DFA = Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA41_static::getValues(); $this->recognizer = $recognizer; $this->decisionNumber = 41; $this->eot = $DFA['eot']; @@ -6205,9 +6177,7 @@ static function getValues(){ class Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA42 extends DFA { public function __construct($recognizer) { -// global $Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA42; -// $DFA = $Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA42; - $DFA = Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA42_static::getValues(); + $DFA = Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA42_static::getValues(); $this->recognizer = $recognizer; $this->decisionNumber = 42; $this->eot = $DFA['eot']; @@ -6257,9 +6227,7 @@ static function getValues(){ class Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA44 extends DFA { public function __construct($recognizer) { -// global $Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA44; -// $DFA = $Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA44; - $DFA = Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA44_static::getValues(); + $DFA = Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA44_static::getValues(); $this->recognizer = $recognizer; $this->decisionNumber = 44; $this->eot = $DFA['eot']; @@ -6309,9 +6277,7 @@ static function getValues(){ class Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA45 extends DFA { public function __construct($recognizer) { -// global $Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA45; -// $DFA = $Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA45; - $DFA = Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA45_static::getValues(); + $DFA = Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA45_static::getValues(); $this->recognizer = $recognizer; $this->decisionNumber = 45; $this->eot = $DFA['eot']; @@ -6363,9 +6329,7 @@ static function getValues(){ class Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA48 extends DFA { public function __construct($recognizer) { -// global $Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA48; -// $DFA = $Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA48; - $DFA = Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA48_static::getValues(); + $DFA = Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA48_static::getValues(); $this->recognizer = $recognizer; $this->decisionNumber = 48; $this->eot = $DFA['eot']; @@ -6426,9 +6390,7 @@ static function getValues(){ class Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA49 extends DFA { public function __construct($recognizer) { -// global $Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA49; -// $DFA = $Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA49; - $DFA = Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA49_static::getValues(); + $DFA = Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA49_static::getValues(); $this->recognizer = $recognizer; $this->decisionNumber = 49; $this->eot = $DFA['eot']; @@ -6480,9 +6442,7 @@ static function getValues(){ class Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA50 extends DFA { public function __construct($recognizer) { -// global $Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA50; -// $DFA = $Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA50; - $DFA = Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA50_static::getValues(); + $DFA = Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA50_static::getValues(); $this->recognizer = $recognizer; $this->decisionNumber = 50; $this->eot = $DFA['eot']; @@ -6535,9 +6495,7 @@ static function getValues(){ class Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA54 extends DFA { public function __construct($recognizer) { -// global $Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA54; -// $DFA = $Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA54; - $DFA = Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA54_static::getValues(); + $DFA = Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA54_static::getValues(); $this->recognizer = $recognizer; $this->decisionNumber = 54; $this->eot = $DFA['eot']; @@ -6588,9 +6546,7 @@ static function getValues(){ class Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA57 extends DFA { public function __construct($recognizer) { -// global $Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA57; -// $DFA = $Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA57; - $DFA = Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA57_static::getValues(); + $DFA = Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA57_static::getValues(); $this->recognizer = $recognizer; $this->decisionNumber = 57; $this->eot = $DFA['eot']; @@ -6641,9 +6597,7 @@ static function getValues(){ class Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA59 extends DFA { public function __construct($recognizer) { -// global $Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA59; -// $DFA = $Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA59; - $DFA = Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA59_static::getValues(); + $DFA = Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA59_static::getValues(); $this->recognizer = $recognizer; $this->decisionNumber = 59; $this->eot = $DFA['eot']; @@ -6694,9 +6648,7 @@ static function getValues(){ class Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA61 extends DFA { public function __construct($recognizer) { -// global $Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA61; -// $DFA = $Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA61; - $DFA = Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA61_static::getValues(); + $DFA = Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA61_static::getValues(); $this->recognizer = $recognizer; $this->decisionNumber = 61; $this->eot = $DFA['eot']; @@ -6750,9 +6702,7 @@ static function getValues(){ class Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA62 extends DFA { public function __construct($recognizer) { -// global $Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA62; -// $DFA = $Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA62; - $DFA = Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA62_static::getValues(); + $DFA = Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA62_static::getValues(); $this->recognizer = $recognizer; $this->decisionNumber = 62; $this->eot = $DFA['eot']; @@ -6806,9 +6756,7 @@ static function getValues(){ class Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA63 extends DFA { public function __construct($recognizer) { -// global $Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA63; -// $DFA = $Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA63; - $DFA = Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA63_static::getValues(); + $DFA = Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA63_static::getValues(); $this->recognizer = $recognizer; $this->decisionNumber = 63; $this->eot = $DFA['eot']; @@ -6858,9 +6806,7 @@ static function getValues(){ class Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA64 extends DFA { public function __construct($recognizer) { -// global $Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA64; -// $DFA = $Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA64; - $DFA = Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA64_static::getValues(); + $DFA = Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA64_static::getValues(); $this->recognizer = $recognizer; $this->decisionNumber = 64; $this->eot = $DFA['eot']; @@ -6911,9 +6857,7 @@ static function getValues(){ class Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA66 extends DFA { public function __construct($recognizer) { -// global $Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA66; -// $DFA = $Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA66; - $DFA = Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA66_static::getValues(); + $DFA = Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA66_static::getValues(); $this->recognizer = $recognizer; $this->decisionNumber = 66; $this->eot = $DFA['eot']; @@ -6968,9 +6912,7 @@ static function getValues(){ class Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA67 extends DFA { public function __construct($recognizer) { -// global $Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA67; -// $DFA = $Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA67; - $DFA = Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA67_static::getValues(); + $DFA = Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA67_static::getValues(); $this->recognizer = $recognizer; $this->decisionNumber = 67; $this->eot = $DFA['eot']; @@ -7019,9 +6961,7 @@ static function getValues(){ class Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA68 extends DFA { public function __construct($recognizer) { -// global $Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA68; -// $DFA = $Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA68; - $DFA = Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA68_static::getValues(); + $DFA = Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA68_static::getValues(); $this->recognizer = $recognizer; $this->decisionNumber = 68; $this->eot = $DFA['eot']; diff --git a/library/Erfurt/Sparql/Parser/Sparql10/Sparql10/Tokenizer.php b/library/Erfurt/Sparql/Parser/Sparql10/Sparql10/Tokenizer.php index af55b0de..db0eab65 100644 --- a/library/Erfurt/Sparql/Parser/Sparql10/Sparql10/Tokenizer.php +++ b/library/Erfurt/Sparql/Parser/Sparql10/Sparql10/Tokenizer.php @@ -57,9 +57,7 @@ static function getValues(){ class Erfurt_Sparql_Parser_Sparql10_Sparql10_Tokenizer_DFA15 extends DFA { public function __construct($recognizer) { -// global $Erfurt_Sparql_Parser_Sparql10_Sparql10_Tokenizer_DFA15; -// $DFA = $Erfurt_Sparql_Parser_Sparql10_Sparql10_Tokenizer_DFA15; - $DFA = Erfurt_Sparql_Parser_Sparql10_Sparql10_Tokenizer_DFA15_static::getValues(); + $DFA = Erfurt_Sparql_Parser_Sparql10_Sparql10_Tokenizer_DFA15_static::getValues(); $this->recognizer = $recognizer; $this->decisionNumber = 15; $this->eot = $DFA['eot']; @@ -443,9 +441,7 @@ static function getValues(){ class Erfurt_Sparql_Parser_Sparql10_Sparql10_Tokenizer_DFA36 extends DFA { public function __construct($recognizer) { -// global $Erfurt_Sparql_Parser_Sparql10_Sparql10_Tokenizer_DFA36; -// $DFA = $Erfurt_Sparql_Parser_Sparql10_Sparql10_Tokenizer_DFA36; - $DFA = Erfurt_Sparql_Parser_Sparql10_Sparql10_Tokenizer_DFA36_static::getValues(); + $DFA = Erfurt_Sparql_Parser_Sparql10_Sparql10_Tokenizer_DFA36_static::getValues(); $this->recognizer = $recognizer; $this->decisionNumber = 36; $this->eot = $DFA['eot']; diff --git a/library/Erfurt/Sparql/Parser/Sparql11update.php b/library/Erfurt/Sparql/Parser/Sparql11update.php index 7ce6908b..92f2d55d 100644 --- a/library/Erfurt/Sparql/Parser/Sparql11update.php +++ b/library/Erfurt/Sparql/Parser/Sparql11update.php @@ -28,9 +28,6 @@ public static function initFromString($queryString, $parserOptions = array()){ $input = new Erfurt_Sparql_Parser_Util_CaseInsensitiveStream($queryString); $lexer = new Erfurt_Sparql_Parser_Sparql11_UpdateLexer($input); $tokens = new CommonTokenStream($lexer); - // foreach ($tokens->getTokens() as $t) { - // echo $t."\n"; - // } $parser = new Erfurt_Sparql_Parser_Sparql11_UpdateParser($tokens); $q = $parser->parse(); } diff --git a/library/Erfurt/Sparql/Parser/Util/CaseInsensitiveStream.php b/library/Erfurt/Sparql/Parser/Util/CaseInsensitiveStream.php index 4bb996e5..c31bb6a1 100644 --- a/library/Erfurt/Sparql/Parser/Util/CaseInsensitiveStream.php +++ b/library/Erfurt/Sparql/Parser/Util/CaseInsensitiveStream.php @@ -19,12 +19,8 @@ public function LA($i) } if ( ($this->p+$i-1) >= $this->n ) { - //System.out.println("char LA("+i+")=EOF; p="+p); return CharStreamConst::$EOF; } - // echo ord(strtolower(chr($this->data[$this->p+$i-1]))) . "\n"; - //System.out.println("char LA("+i+")="+(char)data[p+i-1]+"; p="+p); - //System.out.println("LA("+i+"); p="+p+" n="+n+" data.length="+data.length); return ord(strtolower(chr($this->data[$this->p+$i-1]))); } diff --git a/library/Erfurt/Sparql/Query2.php b/library/Erfurt/Sparql/Query2.php index 2292af14..068bfb20 100644 --- a/library/Erfurt/Sparql/Query2.php +++ b/library/Erfurt/Sparql/Query2.php @@ -84,7 +84,6 @@ static function getNextID() public function __construct($type = null) { - //parent::__construct(); $this->order = new Erfurt_Sparql_Query2_OrderClause(); $this->where = new Erfurt_Sparql_Query2_GroupGraphPattern; @@ -100,7 +99,6 @@ public function __clone() foreach ($this as $key => $val) { if (is_object($val)||(is_array($val))) { $this->{$key} = unserialize(serialize($val)); - //$this->$key= clone($this->$key); } } } @@ -229,11 +227,6 @@ public function setQueryType($type) break; case self::typeAsk: //ask has no solution modifyer - delete? - //$this->setLimit(0); - //$this->setOffset(0); - //$this->order = new Erfurt_Sparql_Query2_OrderClause(); - //$this->distinctReducedMode = 0; - //$this->projectionVars = array(); break; case self::typeDescribe: break; @@ -374,10 +367,6 @@ public function getLimit() */ public function setOffset($noffset) { - //if ($this->type == self::typeAsk) - // throw new RuntimeException("Trying to set solution modifier \"Offset\"". - // " in an ASK-Query - not possible"); - $this->offset = $noffset; return $this; //for chaining } @@ -734,12 +723,6 @@ public function addProjectionVar(Erfurt_Sparql_Query2_Var $var) } } - /*if (!in_array($var, $this->where->getVars())) { - trigger_error('Trying to add projection-var ('.$var->getSparql().') '. - * 'that is not used in pattern', E_USER_NOTICE); - return $this; //for chaining - }*/ - if (count($this->projectionVars) == 0){ //if the first var is added: deactivate the star. //maybe always? @@ -868,11 +851,6 @@ public function getVars() */ public function getOrder() { - //if ($this->type == self::typeAsk) { - // throw new RuntimeException( - // "Trying to set solution modifier \"Order\" in an ASK-Query - not possible" - // ); - //} return $this->order; } diff --git a/library/Erfurt/Sparql/Query2/Abstraction/ClassNode.php b/library/Erfurt/Sparql/Query2/Abstraction/ClassNode.php index f964c301..e30d8f2f 100644 --- a/library/Erfurt/Sparql/Query2/Abstraction/ClassNode.php +++ b/library/Erfurt/Sparql/Query2/Abstraction/ClassNode.php @@ -130,15 +130,6 @@ public static function addShownPropertyHelper(Erfurt_Sparql_Query2 $query, Erfur $optionalpart->addElement($triple); $query->getWhere()->addElement($optionalpart); - /* filtered now in php - $filter = new Erfurt_Sparql_Query2_Filter( - new Erfurt_Sparql_Query2_UnaryExpressionNot( - new Erfurt_Sparql_Query2_isBlank($var) - ) - );*/ - - //$optionalpart->addElement($filter); - $query->addProjectionVar($var); return array('optional' => $optionalpart, 'var' => $var, 'filter' => null); diff --git a/library/Erfurt/Sparql/Query2/ContainerHelper.php b/library/Erfurt/Sparql/Query2/ContainerHelper.php index 746f8444..8bd6c423 100644 --- a/library/Erfurt/Sparql/Query2/ContainerHelper.php +++ b/library/Erfurt/Sparql/Query2/ContainerHelper.php @@ -41,7 +41,6 @@ public function getParentContainer($needle){ return $parents; } - //abstract public function addElement($member); //not used because some use typehinting some do it internally for multiple types /** * getElement @@ -80,7 +79,6 @@ public function getVars() { return $ret; } - //abstract public function setElement($i, $member); //not used because some use typehinting some do it internally abstract public function setElements($elements); /** @@ -116,7 +114,6 @@ public function removeElement($toDelete, $equal = false) { } } } - //$toDelete->removeParent($this); $this->elements = $new; return $this; //for chaining diff --git a/library/Erfurt/Sparql/Query2/ElementHelper.php b/library/Erfurt/Sparql/Query2/ElementHelper.php index 1d96024a..d7ce51b3 100644 --- a/library/Erfurt/Sparql/Query2/ElementHelper.php +++ b/library/Erfurt/Sparql/Query2/ElementHelper.php @@ -23,8 +23,6 @@ public function __construct() { $this->id = Erfurt_Sparql_Query2::getNextID(); } - //abstract public function getSparql(); - /** * addParent * when a ElementHelper-object is added to a ContainerHelper-object this method is called. lets the child know of the new parent diff --git a/library/Erfurt/Sparql/SimpleQuery.php b/library/Erfurt/Sparql/SimpleQuery.php index 9a65a426..e632527e 100644 --- a/library/Erfurt/Sparql/SimpleQuery.php +++ b/library/Erfurt/Sparql/SimpleQuery.php @@ -120,7 +120,6 @@ public static function initWithString($queryString) $var = '[?$]{1}[\w\d]+'; $expr = '(\w*\(.*\))'; - // /(BASE.*?\s)?(PREFIX.*?\s)*(ASK|((COUNT(\s)*(\(.*?\))))|(SELECT(\s)+)(DISTINCT(\s)+)?(COUNT(\s)+(\(.*?\)(\s)))?(\?\w+\s+|\*)*)/si $tokens = array( 'prefix' => '/((PREFIX\s+[^:\s]+:\s+<[^\s]*>\s*)+)/si', 'base' => '/BASE\s+<(.+?)>/i', @@ -139,9 +138,6 @@ public static function initWithString($queryString) preg_match_all($pattern, $queryString, $parts[$key]); } - //echo $queryString; - //var_dump($parts); - $queryObject = new self(); if (isset($parts['prefix'][0][0]) || isset($parts['base'][0][0])) { $prologue = ''; diff --git a/library/Erfurt/Store/Adapter/EfZendDb.php b/library/Erfurt/Store/Adapter/EfZendDb.php index 9406c6bf..b65daa63 100644 --- a/library/Erfurt/Store/Adapter/EfZendDb.php +++ b/library/Erfurt/Store/Adapter/EfZendDb.php @@ -1081,7 +1081,7 @@ public function sqlQuery($sqlQuery, $limit = PHP_INT_MAX, $offset = 0) } else { try { $result = @$this->_dbConn->fetchAll($sqlQuery); - } catch (Zend_Db_Exception $e) { #return false; + } catch (Zend_Db_Exception $e) { throw new Erfurt_Store_Adapter_Exception( $e->getMessage() ); diff --git a/library/Erfurt/Store/Adapter/Mssql.php b/library/Erfurt/Store/Adapter/Mssql.php index 43223f0f..573e555d 100644 --- a/library/Erfurt/Store/Adapter/Mssql.php +++ b/library/Erfurt/Store/Adapter/Mssql.php @@ -80,9 +80,6 @@ public function __construct($adapterOptions = array()) throw new Erfurt_Exception('An error with the specified database adapter occured.', -1); } - // we want indexed results - //$this->_dbConn->setFetchMode(Zend_Db::FETCH_NUM); - // load title properties for model titles $config = Erfurt_App::getInstance()->getConfig(); if (isset($config->properties->title)) { @@ -92,16 +89,6 @@ public function __construct($adapterOptions = array()) public function __destruct() { - #$log = Erfurt_App::getInstance()->getLog(); - - #$profiles = $this->_dbConn->getProfiler()->getQueryProfiles(); - - #foreach ($profiles as $profile) { - # $debugStr = 'Query: ' . $profile->getQuery() . PHP_EOL; - # $debugStr .= 'Time: ' . $profile->getElapsedSecs() . PHP_EOL; - # - # $log->debug($debugStr); - #} } // ------------------------------------------------------------------------ @@ -209,15 +196,6 @@ public function addMultipleStatements($graphUri, array $statementsArray, array $ $sqlString .= "($graphId,'$s','$p','$oValue',"; - #$data = array( - # 'g' => $graphId, - # 's' => $subject, - # 'p' => $predicate, - # 'o' => $object['value'], - # 'st' => $subjectIs, - # 'ot' => $objectIs - #); - if ($sRef !== false) { $sqlString .= "$sRef,"; } else { @@ -236,9 +214,6 @@ public function addMultipleStatements($graphUri, array $statementsArray, array $ $sqlString .= "$subjectIs,$objectIs,'$lang',"; - #$data['ol'] = $lang; - - if (strlen((string)$dType) > $this->_getSchemaRefThreshold()) { $dTypeHash = md5((string)$dType); @@ -254,11 +229,9 @@ public function addMultipleStatements($graphUri, array $statementsArray, array $ $sqlString .= "'$dType',$dtRef)"; } else { - #$data['od'] = $dType; $sqlString .= "'$dType',NULL)"; } -// $insertArray[] = $sqlString; $counter++; $finalquery = 'IF NOT EXISTS(Select g, s, p, o, st, ot, ol, od from ef_stmt @@ -971,8 +944,6 @@ public function importRdf($modelUri, $data, $type, $locator) } else { $sql .= "NULL,NULL)"; } - - //$this->_dbConn->getConnection()->query($sql); } if ($count > 10000) { @@ -1437,8 +1408,6 @@ private function _fetchModelInfos() } else { $this->_modelInfoCache = array(); - #$rowSet = $result->fetchAll(); - #var_dump($result);exit; foreach ($result as $row) { if (!isset($this->_modelInfoCache[$row['uri']])) { $this->_modelInfoCache[$row['uri']]['modelId'] = $row['id']; @@ -1466,8 +1435,6 @@ private function _fetchModelInfos() } } - //var_dump($this->_modelInfoCache);exit; - // build the transitive closure for owl:imports // check for recursive owl:imports; also check for cylces! do { diff --git a/library/Erfurt/Store/Adapter/Virtuoso.php b/library/Erfurt/Store/Adapter/Virtuoso.php index 4eefc0ea..bac96c10 100644 --- a/library/Erfurt/Store/Adapter/Virtuoso.php +++ b/library/Erfurt/Store/Adapter/Virtuoso.php @@ -236,8 +236,6 @@ public function connection() if (!$this->_connection) { $options = $this->_adapterOptions; - // ini_set('odbc.default_cursortype', SQL_CURSOR_FORWARD_ONLY); - // determine connection function if ((isset($options['use_persistent_connection'])) && ((boolean) $options['use_persistent_connection'] === true)) { @@ -494,11 +492,6 @@ public function getSearchPatternWithNode($stringSpec, $predicateVariable, $optio new Erfurt_Sparql_Query2_Equals($strExpression, $literalExpression) ); } else { - // string >= bifLimit characters - // if (false === strpos($stringSpec, '*')) { - // $stringSpec .= '*'; - // } - $bifPrefix = new Erfurt_Sparql_Query2_Prefix( 'bif', new Erfurt_Sparql_Query2_IriRef('SparqlProcessorShouldKnow') @@ -527,7 +520,6 @@ public function getSearchPatternWithNode($stringSpec, $predicateVariable, $optio } $searchPattern[] = $filter; -#var_dump((string)$searchPattern[1]);exit; return $searchPattern; } @@ -1046,11 +1038,8 @@ private function _execSparql($sparqlQuery, $graphUri = null) $sparqlQuery = addcslashes($sparqlQuery, '\'\\'); //build Virtuoso/PL query - //$virtuosoPl = 'SPARQL ' . $sparqlQuery; $virtuosoPl = $graphSpec . 'CALL DB.DBA.SPARQL_EVAL(\'' . $sparqlQuery . '\', ' . $graphUri . ', 0)'; -# $resultId = odbc_prepare($this->connection(), $virtuosoPl); -# $resultId = odbc_exec($resultId, $virtuosoPl); $resultId = @odbc_exec($this->connection(), $virtuosoPl); if (false === $resultId) { @@ -1077,8 +1066,6 @@ private function _execSparqlUpdate($sparqlQuery, $graphUri = null) //build Virtuoso/PL query $virtuosoPl = 'SPARQL ' . $sparqlQuery; -# $resultId = odbc_prepare($this->connection(), $virtuosoPl); -# $resultId = odbc_exec($resultId, $virtuosoPl); $resultId = odbc_exec($this->connection(), $virtuosoPl); if (false === $resultId) { @@ -1098,8 +1085,6 @@ private function _execSparqlUpdate($sparqlQuery, $graphUri = null) */ protected function _execSql($sqlQuery) { -# $resultId = odbc_prepare($this->connection(), $sqlQuery); -# $resultId = odbc_exec($resultId, $sqlQuery); $resultId = @odbc_exec($this->connection(), $sqlQuery); if (false === $resultId) { $message = sprintf('SQL Error: %s in query: %s', $this->getLastError(), $sqlQuery); From 3d5e8b03884c750a80b5d32442dd3e4f7abc4870 Mon Sep 17 00:00:00 2001 From: shinobu Date: Fri, 9 Dec 2016 12:41:35 +0100 Subject: [PATCH 3/4] Removes outcommented code from all files in librar/Erfurt/ --- library/Erfurt/Ac/Default.php | 18 --- library/Erfurt/App.php | 7 -- library/Erfurt/Auth/Adapter/FoafSsl.php | 1 - library/Erfurt/Auth/Adapter/OpenId.php | 8 -- library/Erfurt/Auth/Adapter/Rdf.php | 14 +-- library/Erfurt/Cache/Backend/Database.php | 8 -- library/Erfurt/Ping.php | 7 +- library/Erfurt/Plugin/Manager.php | 35 ------ library/Erfurt/Rdf/Model.php | 8 -- library/Erfurt/Rdf/Resource.php | 2 - .../Sparql/EngineDb/Adapter/EfZendDb.php | 111 ---------------- .../Sparql/EngineDb/FilterGenerator.php | 2 - .../Erfurt/Sparql/EngineDb/QueryOptimizer.php | 118 +----------------- .../Sparql/EngineDb/QuerySimplifier.php | 8 +- .../EngineDb/ResultRenderer/Extended.php | 4 - .../Sparql/EngineDb/ResultRenderer/Plain.php | 30 +---- .../EngineDb/SqlGenerator/Adapter/Ef.php | 16 --- library/Erfurt/Sparql/EngineDb/TypeSorter.php | 11 -- library/Erfurt/Sparql/Parser.php | 14 +-- library/Erfurt/Sparql/Parser/Sparql10.php | 5 - .../Parser/Sparql10/Sparql10/Sparql10.php | 110 ++++------------ .../Parser/Sparql10/Sparql10/Tokenizer.php | 8 +- .../Erfurt/Sparql/Parser/Sparql11update.php | 3 - .../Parser/Util/CaseInsensitiveStream.php | 4 - library/Erfurt/Sparql/Query2.php | 25 ---- .../Sparql/Query2/Abstraction/ClassNode.php | 9 -- .../Erfurt/Sparql/Query2/ContainerHelper.php | 3 - .../Erfurt/Sparql/Query2/ElementHelper.php | 2 - library/Erfurt/Sparql/SimpleQuery.php | 4 - library/Erfurt/Store.php | 24 ---- library/Erfurt/Store/Adapter/EfZendDb.php | 11 +- library/Erfurt/Store/Adapter/Mssql.php | 26 +--- library/Erfurt/Store/Adapter/Virtuoso.php | 15 --- .../Syntax/RdfParser/Adapter/RdfXml.php | 25 ---- .../Syntax/RdfParser/Adapter/Turtle.php | 64 ---------- .../Adapter/RdfXml/RdfWriter.php | 5 - .../Syntax/RdfSerializer/Adapter/Turtle.php | 4 - library/Erfurt/Worker/Job/Abstract.php | 1 - library/Erfurt/Wrapper/Manager.php | 4 - 39 files changed, 48 insertions(+), 726 deletions(-) diff --git a/library/Erfurt/Ac/Default.php b/library/Erfurt/Ac/Default.php index 2ba550e8..06c432b4 100644 --- a/library/Erfurt/Ac/Default.php +++ b/library/Erfurt/Ac/Default.php @@ -373,24 +373,6 @@ public function isActionAllowed($action, $isFullUri = false) // Every Action allowed return true; } else { - // create action instance - // array for new statements (an action instance pus label) - /* - $actionStmt = array( - $actionUri => array ( - EF_RDF_TYPE => array ( - array ( 'type' => 'uri' , 'value' => $this->_uris['actionClassUri'] ) - ) , - EF_RDFS_LABEL => array ( - array ( 'type' => 'literal' , 'value' => $action ) - ) - ) - ); - - $store = Erfurt_App::getInstance()->getStore(); - $store->addMultipleStatements($this->_uris['acModelUri'], $actionStmt, false); - */ - return false; } } diff --git a/library/Erfurt/App.php b/library/Erfurt/App.php index 8c419b7f..b1f2943a 100644 --- a/library/Erfurt/App.php +++ b/library/Erfurt/App.php @@ -1160,13 +1160,6 @@ private function _getQueryCacheBackend() case 'database': $this->_queryCacheBackend = new Erfurt_Cache_Backend_QueryCache_Database(); break; -# case 'file': -# $this->_queryCacheBackend = new Erfurt_Cache_Backend_QueryCache_File(); -# break; -# -# case 'memory': -# $this->_queryCacheBackend = new Erfurt_Cache_Backend_QueryCache_Memory(); -# break; default: throw new Erfurt_Exception('Cache type is not supported.'); } diff --git a/library/Erfurt/Auth/Adapter/FoafSsl.php b/library/Erfurt/Auth/Adapter/FoafSsl.php index c3ec43a6..0d43d01b 100644 --- a/library/Erfurt/Auth/Adapter/FoafSsl.php +++ b/library/Erfurt/Auth/Adapter/FoafSsl.php @@ -634,7 +634,6 @@ public function verifyIdpResult($get) if ((null === $this->_publicKey) || !extension_loaded('openssl')) { return false; } - //$this->_publicKey = str_replace(str_split(" \t\n\r\0\x0B"), '', $this->_publicKey); $schema = (isset($_SERVER['HTTPS']) && ($_SERVER['HTTPS'])) ? 'https://' : 'http://'; $url = $schema . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI']; diff --git a/library/Erfurt/Auth/Adapter/OpenId.php b/library/Erfurt/Auth/Adapter/OpenId.php index 2330fdf7..098e6b7f 100644 --- a/library/Erfurt/Auth/Adapter/OpenId.php +++ b/library/Erfurt/Auth/Adapter/OpenId.php @@ -206,14 +206,6 @@ public function authenticate() if (!isset($this->_get['openid_identity'])) { $result = false; $msg = 'OpenID authentication failed.'; - - /* - $identity = array( - 'uri' => null, - 'dbuser' => false, - 'anonymous' => false - ); - */ return new Zend_Auth_Result($result, null, array($msg)); } diff --git a/library/Erfurt/Auth/Adapter/Rdf.php b/library/Erfurt/Auth/Adapter/Rdf.php index d86784d2..cd0116a9 100644 --- a/library/Erfurt/Auth/Adapter/Rdf.php +++ b/library/Erfurt/Auth/Adapter/Rdf.php @@ -88,19 +88,7 @@ public function authenticate() 'anonymous' => false ); - // have a look at the cache... - /*$cache = Erfurt_App::getInstance()->getCache(); - $id = $cache->makeId($this, '_fetchDataForUser', array($this->_username)); - OntoWiki::getInstance()->appendMessage( new OntoWiki_Message($id)); - $cachedVal = $cache->load($id); - if ($cachedVal) { - OntoWiki::getInstance()->appendMessage( new OntoWiki_Message("cached")); - $this->_users[$this->_username] = $cachedVal; - } else { - */$this->_users[$this->_username] = $this->_fetchDataForUser($this->_username); - /*$cache->save($this->_users[$this->_username], $id, array('_fetchDataForUser')); - OntoWiki::getInstance()->appendMessage( new OntoWiki_Message("uncached")); - }*/ + $this->_users[$this->_username] = $this->_fetchDataForUser($this->_username); // if login is denied return failure auth result if ($this->_users[$this->_username]['denyLogin'] === true) { diff --git a/library/Erfurt/Cache/Backend/Database.php b/library/Erfurt/Cache/Backend/Database.php index f3b35ce9..77199cf8 100644 --- a/library/Erfurt/Cache/Backend/Database.php +++ b/library/Erfurt/Cache/Backend/Database.php @@ -80,7 +80,6 @@ public function load($id, $doNotTestCacheValidity = false) { if ($result !== false) { if (isset($result[0])) { $content = $result[0]['content']; - #$content = base64_decode($content); return $content; } } @@ -123,7 +122,6 @@ public function save($data, $id, $tags = array(), $specificLifetime = false) { } $lifetime = $this->getLifetime($specificLifetime); - #$data = $this->_getConnection()->real_escape_string($data); $data = addslashes($data); $mktime = time(); if (is_null($lifetime)) { @@ -177,12 +175,6 @@ public function test($id) { * This method will build the database structure. */ private function _buildStructure() { -# $this->_query('DROP INDEX ef_cache_tag_id_index'); -# $this->_query('DROP INDEX ef_cache_tag_name_index'); -# $this->_query('DROP INDEX ef_cache_id_expire_index'); -# $this->_query('DROP TABLE ef_cache_version'); -# $this->_query('DROP TABLE ef_cache'); -# $this->_query('DROP TABLE ef_cache_tag'); $this->_query(' CREATE TABLE ef_cache_version ( num INT, diff --git a/library/Erfurt/Ping.php b/library/Erfurt/Ping.php index 3457feb5..c3b1d127 100644 --- a/library/Erfurt/Ping.php +++ b/library/Erfurt/Ping.php @@ -380,19 +380,14 @@ private function _getResourceFromWrapper ($sourceUri, $targetUri, $wrapperName = $wrapperResult = $wrapper->run($r, null, true); $newStatements = null; - if ($wrapperResult === false) { - // IMPORT_WRAPPER_NOT_AVAILABLE; - } else if (is_array($wrapperResult)) { + if (is_array($wrapperResult)) { $newStatements = $wrapperResult['add']; // TODO make sure to only import the specified resource $newModel = new Erfurt_Rdf_MemoryModel($newStatements); $newStatements = array(); $object = array('type' => 'uri', 'value' => $targetUri); $newStatements = $newModel->getP($sourceUri, $object); - } else { - // IMPORT_WRAPPER_ERR; } - return $newStatements; } diff --git a/library/Erfurt/Plugin/Manager.php b/library/Erfurt/Plugin/Manager.php index 6b92d3d4..9b46a341 100644 --- a/library/Erfurt/Plugin/Manager.php +++ b/library/Erfurt/Plugin/Manager.php @@ -138,41 +138,6 @@ private function _addPlugin($pluginName, $pluginPath) } public function addPluginExternally($pluginName, $fileName, $pluginPath, $pluginConfig){ -// for use of array based config -// if($pluginConfig instanceof Zend_Config){ -// $pluginConfig = $pluginConfig->toArray(); -// } - -// $pluginConfig['pluginPath'] = $pluginPath; -// if(!isset($pluginConfig['enabled'])){ -// $pluginConfig['enabled'] = false; -// } -// $enabled = $pluginConfig['enabled']; -// -// // keep track of loaded plug-ins -// if (!array_key_exists($pluginName, $this->_plugins)) { -// $this->_plugins[$pluginName] = $pluginConfig; -// } -// -// if ($enabled && isset($pluginConfig['events']) && is_array($pluginConfig['events'])) { -// foreach ($pluginConfig['events'] as $event) { -// if (is_array($event)) { -// // TODO: allow trigger method that differs from event name -// } else if (is_string($event)) { -// $pluginSpec = array( -// 'class_name' => ucfirst($pluginName) . self::PLUGIN_CLASS_POSTFIX, -// 'file_name' => $fileName, -// 'include_path' => $pluginPath, -// 'config' => isset($pluginPrivateConfig) ? $pluginPrivateConfig : null -// ); -// -// $priority = isset($event['priority']) ? (int) $event['priority'] : 10; -// -// // register plugin events with event dispatcher -// $this->_eventDispatcher->register($event, $pluginSpec, $priority); -// } -// } -// } $pluginConfig->pluginPath = $pluginPath; if(!isset($pluginConfig->enabled)){ $pluginConfig->enabled = false; diff --git a/library/Erfurt/Rdf/Model.php b/library/Erfurt/Rdf/Model.php index 65d03a0f..ba6f5c29 100644 --- a/library/Erfurt/Rdf/Model.php +++ b/library/Erfurt/Rdf/Model.php @@ -655,14 +655,6 @@ public function sparqlQuery($query, $options = array()) return $this->getStore()->sparqlQuery($query, $options); } - /*public function sparqlQueryWithPlainResult($query) - { - $queryObject = Erfurt_Sparql_SimpleQuery::initWithString($query); - $queryObject->addFrom($this->_graphUri); - - return $this->getStore()->sparqlQuery($queryObject); - }*/ - /** * set the model store * diff --git a/library/Erfurt/Rdf/Resource.php b/library/Erfurt/Rdf/Resource.php index 2cb37bcd..ae9a70f3 100644 --- a/library/Erfurt/Rdf/Resource.php +++ b/library/Erfurt/Rdf/Resource.php @@ -262,8 +262,6 @@ protected function _fetchDescription($maxDepth) $this->_descriptionResource($property); $currentValue = array( - // typed-literal --> literal - // 'type' => str_replace('typed-', '', $row['o']['type']), 'type' => $row['o']['type'], 'value' => $row['o']['value'] ); diff --git a/library/Erfurt/Sparql/EngineDb/Adapter/EfZendDb.php b/library/Erfurt/Sparql/EngineDb/Adapter/EfZendDb.php index 0d31776c..9b6d545a 100644 --- a/library/Erfurt/Sparql/EngineDb/Adapter/EfZendDb.php +++ b/library/Erfurt/Sparql/EngineDb/Adapter/EfZendDb.php @@ -122,97 +122,6 @@ public function getTypeSorter() return $this->ts; } - /** - * Create a prepared statement that can be executed later. - * - * @param Dataset $dataset RDF Dataset - * @param Query $query Parsed SPARQL query - * - * @return SparqlEngineDb_PreparedStatement Prepared statment that can - * be execute()d later. - */ - /*public function prepare(Dataset $dataset, Query $query) - { - //require_once RDFAPI_INCLUDE_DIR . 'sparql/SparqlEngineDb/PreparedStatement.php'; - //require_once RDFAPI_INCLUDE_DIR . 'sparql/SparqlEngineDb/Preparator.php'; - - $this->query = $query; - $this->dataset = $dataset; - $this->sg = new SparqlEngineDb_SqlGenerator ($this->query, $this->dbConn, $this->arModelIds); - $this->rc = new SparqlEngineDb_ResultConverter($this->query, $this->sg, $this); - $this->ts = new SparqlEngineDb_TypeSorter ($this->query, $this->dbConn); - $this->pr = new SparqlEngineDb_Preparator ($this->query, $this->dbConn); - - $this->arPrepared = $this->sg->createSql(); - $this->ts->setData($this->sg); - - if ($this->ts->willBeDataDependent()) { - $this->bRealPrepared = false; - } else { - $this->bRealPrepared = true; - list($strSelect, $strFrom, $strWhere) = $this->arPrepared; - $this->arPreparedQueries = $this->ts->getOrderifiedSqls( - $strSelect, - $strFrom, - $strWhere - ); - $this->arDbStatements = $this->pr->prepareInDb( - $this->arPreparedQueries, - $this->sg->getPlaceholders() - ); - } - - - return new SparqlEngineDb_PreparedStatement( - $this - ); - }*/ - - /** - * Execute a prepared statement by filling it with variables - * - * @param array $arVariables Array with (variable name => value) pairs - * @param string $resultform Which form the result should have - * - * @return mixed Result according to $resultform - */ - /*public function execute($arVariables, $resultform = false) - { - if ($this->arPrepared === null) { - throw new Exception('You need to prepare() the query first.'); - } - - if ($this->bRealPrepared) { - return - SparqlEngineDb_ResultConverter::convertFromDbResults( - $this->pr->execute( - $this->arDbStatements, - $arVariables - ), - $this, - $resultform - ); - } else { - list($strSelect, $strFrom, $strWhere) = $this->arPrepared; - - return SparqlEngineDb_ResultConverter::convertFromDbResults( - $this->_queryMultiple( - $this->ts->getOrderifiedSqls( - $strSelect, - $strFrom, - $this->pr->replacePlaceholdersWithVariables( - $strWhere, - $this->sg->getPlaceholders(), - $arVariables - ) - ) - ), - $this, - $resultform - ); - } - }*/ - /** * Query the database with the given SPARQL query. * @@ -243,9 +152,6 @@ public function queryModel(Erfurt_Sparql_Query $query, $resultform = 'plain') case 'xml': $rc = new Erfurt_Sparql_EngineDb_ResultRenderer_Xml(); break; - //throw new Erfurt_Exception('XML result format not supported yet.'); - //$this->rc = new Erfurt_Sparql_EngineDb_ResultRenderer_RapZendDb_Xml(); - //break; case 'extended': $rc = new Erfurt_Sparql_EngineDb_ResultRenderer_Extended(); break; @@ -268,10 +174,7 @@ public function queryModel(Erfurt_Sparql_Query $query, $resultform = 'plain') $this->ts = new Erfurt_Sparql_EngineDb_TypeSorter($this->query, $this); - $this->_setOptions(); - $arSqls = $this->sg->createSql(); - #var_dump($arSqls);exit; $this->ts->setData($this->sg); @@ -298,8 +201,6 @@ public function sqlQuery($sql) protected function _queryDb($arSql, $nOffset, $nLimit) { $strSql = Erfurt_Sparql_EngineDb_SqlMerger::getSelect($this->query, $arSql); -#var_dump($nLimit, $nOffset); -#echo $strSql; if ($strSql === '()') { return array(); } @@ -361,16 +262,4 @@ protected function _queryMultiple($arSqls) return $arResults; } - /** - * Set options to subobjects like SqlGenerator - */ - protected function _setOptions() - { - // allow changing the statements' table name - //if (isset($GLOBALS['RAP']['conf']['database']['tblStatements'])) { - // $this->sg->setStatementsTable( - // $GLOBALS['RAP']['conf']['database']['tblStatements'] - // ); - //} - } } diff --git a/library/Erfurt/Sparql/EngineDb/FilterGenerator.php b/library/Erfurt/Sparql/EngineDb/FilterGenerator.php index 1f8ebf49..4c5be502 100644 --- a/library/Erfurt/Sparql/EngineDb/FilterGenerator.php +++ b/library/Erfurt/Sparql/EngineDb/FilterGenerator.php @@ -98,7 +98,6 @@ public function createFilterSql($tree, $bOptional, $nUnionCount) $this->bOptional = $bOptional; $this->nUnionCount = $nUnionCount; -#return ' AND ' . $this->createTreeSql($tree, null); try { return ' AND ' . $this->createTreeSql($tree, null); } catch (Exception $e) { @@ -610,7 +609,6 @@ protected function createFunction_regex($tree) break; default: - //var_dump($strMod);exit; throw new Erfurt_Sparql_EngineDb_SqlGeneratorException( 'Unsupported regex modifier "' . $strMod diff --git a/library/Erfurt/Sparql/EngineDb/QueryOptimizer.php b/library/Erfurt/Sparql/EngineDb/QueryOptimizer.php index 3d6f84f8..8be38350 100644 --- a/library/Erfurt/Sparql/EngineDb/QueryOptimizer.php +++ b/library/Erfurt/Sparql/EngineDb/QueryOptimizer.php @@ -30,8 +30,6 @@ public function optimize(Erfurt_Sparql_Query $query) $result = $query; // TODO Not working on all queries yet. -#return $result; - if ($resultForm === 'select distinct') { $result = $this->_optimizeDistinct($query); } @@ -123,26 +121,13 @@ protected function _optimizeDistinct($query) $orderifiedSqls = $ts->getOrderifiedSqls($arSqls); $originalVars = $sg->arVarAssignments; -#var_dump($originalVars); - - - - - $usedVars = array_unique($usedVars); $newResultVars = array(); $tempQuery = clone $query; // We need to adjust the limit, offset values. -// TODO limit offset support - #$sm = $tempQuery->getSolutionModifier(); - #if (isset($sm['limit'])) { - # $tempQuery->setSolutionModifier('limit', 1000); - #} - #if (isset($sm['offset'])) { - # $tempQuery->setSolutionModifier('offset', 0); - #} + // TODO limit offset support foreach ($tempQuery->getResultVars() as $var) { if (in_array($var->getVariable(), $usedVars)) { @@ -163,7 +148,6 @@ protected function _optimizeDistinct($query) $orderifiedSqls = $ts->getOrderifiedSqls($arSqls); $mandatoryResult = $this->_queryMultiple($tempQuery, $orderifiedSqls); $mandatoryVars = $sg->arVarAssignments; -#var_dump($mandatoryResult);exit; // If the mandatory result is empty... return it. $empty = true; @@ -205,82 +189,6 @@ protected function _optimizeDistinct($query) } reset($mandatoryResult); -#var_dump($replaceArray);exit; - // Remove all old mandatory constraints from the query (already done with the first query). - // Replace them with a new sameTerm constraint - #$cArray = array(); - - #$distinctKeys = array(); -// TODO Function nesting fatal error on big result :( - /*foreach ($replaceArray as $var => $values) { - $distinctKeys[] = $var; - $c = new Erfurt_Sparql_Constraint(); - - $valueSameTermArray = array(); - foreach ($values as $key => $true) { - $valueSameTermArray[] = 'sameTerm(' . $var . ', <' . $key . '>)'; - } - - $expr = '(' . implode(' || ', $valueSameTermArray) . ')'; - $c->addExpression($expr); - $c->parse(); - $cArray[] = $c; - }*/ -#var_dump($cArray);exit; - - /*$ids = array(); - foreach ($optionals as $graphPattern) { - $newCArray = array(); - foreach ($cArray as $c) { - $add = false; - $usedVars = $c->getUsedVars(); - foreach ($graphPattern->getVariables() as $v) { - if (in_array($v, $usedVars)) { - $add = true; - break; - } - } - - if ($add) { - $newCArray[] = $c; - } - } - - #$graphPattern->setConstraints($newCArray); - foreach ($oldMandatory as $gp) { - if ($graphPattern->getOptional() === $gp->getId() && !empty($newCArray)) { - $gp->setTriplePatterns(array()); - $gp->setConstraints($newCArray); - } - - - } - - $ids[$graphPattern->getOptional()] = true; - } - - foreach ($oldMandatory as $key => $pattern) { - if (!isset($ids[$pattern->getId()])) { - $unsetIds[$pattern->getId()] = true; - unset($oldMandatory[$key]); - } - } - foreach ($oldMandatory as $pattern) { - if (isset($unsetIds[$pattern->getUnion()])) { - $pattern->setUnion(null); - } - } - */ - - - - #$pattern = new Erfurt_Sparql_GraphPattern(); - #$pattern->setId(1000); - #$pattern->setOptional(0); - #$pattern->addTriplePattern(new Erfurt_Sparql_QueryTriple('?predicate', Erfurt_Rdf_Resource::initWithUri('dummy'), Erfurt_Rdf_Resource::initWithUri('dummy'))); - - # $optionals[] = $pattern; - foreach ($oldMandatory as $gp) { $gp->setTriplePatterns(array()); $gp->setConstraints(array()); @@ -288,7 +196,6 @@ protected function _optimizeDistinct($query) // Set new result form to select (not distinct) - #$newPatterns = $optionals; $newPatterns = array_merge($oldMandatory, $optionals); $usedVars = array(); foreach ($newPatterns as $pattern) { @@ -305,7 +212,6 @@ protected function _optimizeDistinct($query) $query->setResultVars($usedVarsObjects); $query->setResultPart($newPatterns); $query->setResultForm('select'); -#var_dump($query);exit; $sg = new Erfurt_Sparql_EngineDb_SqlGenerator_Adapter_Ef($query, $this->_engine->getModelIdMapping()); $ts = new Erfurt_Sparql_EngineDb_TypeSorter($query, $this->_engine); @@ -316,9 +222,6 @@ protected function _optimizeDistinct($query) $orderifiedSqls = $ts->getOrderifiedSqls($arSqls); $optionalVars = $sg->arVarAssignments; -#var_dump($optionalVars); -#var_dump($replaceArray);exit; - $whereAddition = array(); foreach ($optionalVars as $var => $varSpec) { foreach ($replaceArray as $key => $values) { @@ -335,15 +238,9 @@ protected function _optimizeDistinct($query) if(!empty($whereAddition)) $sql['where'] .= ' AND ' . implode(' AND ', $whereAddition); } } -#var_dump($orderifiedSqls);exit; $optionalResult = $this->_queryMultiple($query, $orderifiedSqls); - -#var_dump($optionalResult);exit; - -#var_dump($originalVars, $optionalVars, $optionalResult);exit; - $newOptResult = array(); // Remove double entries $alreadyIn = array(); @@ -358,12 +255,9 @@ protected function _optimizeDistinct($query) } } $optionalResult = array($newOptResult); -#var_dump($optionalVars);exit; - - + $newResult = array(); - -#var_dump($mandatoryResult);exit; + $mResult = current($mandatoryResult); while (true) { $rowSpec = array(); @@ -549,8 +443,6 @@ protected function _optimizeDistinct($query) } } -#var_dump($newResult);exit; - $retVal = array($newResult); return array('data' => $retVal, 'vars' => $originalVars); } @@ -558,7 +450,6 @@ protected function _optimizeDistinct($query) protected function _queryDb($query, $arSql, $nOffset, $nLimit) { $strSql = Erfurt_Sparql_EngineDb_SqlMerger::getSelect($query, $arSql); -#echo $strSql; if ($strSql === '()') { return array(); } @@ -570,7 +461,6 @@ protected function _queryDb($query, $arSql, $nOffset, $nLimit) } else { $ret = $this->_engine->sqlQuery($strSql . ' LIMIT ' . $nOffset . ', ' . $nLimit); } -#var_dump($ret->fetchAll());exit; return $ret; } @@ -593,7 +483,6 @@ protected function _queryMultiple($query, $arSqls) list($nSql, $nOffset) = $offsetter->determineOffset($arSqls); $nLimit = $arSM['limit']; } -#var_dump($arSqls, $offsetter->determineOffset($arSqls)); $nCount = 0; $arResults = array(); foreach ($arSqls as $nId => $arSql) { @@ -608,7 +497,6 @@ protected function _queryMultiple($query, $arSqls) } $dbResult = $this->_queryDb($query, $arSql, $nOffset, $nCurrentLimit); -#var_dump($dbResult); $nCount += count($dbResult); $arResults[] = $dbResult; $nOffset = 0; diff --git a/library/Erfurt/Sparql/EngineDb/QuerySimplifier.php b/library/Erfurt/Sparql/EngineDb/QuerySimplifier.php index 3cb475a4..8ab2459e 100644 --- a/library/Erfurt/Sparql/EngineDb/QuerySimplifier.php +++ b/library/Erfurt/Sparql/EngineDb/QuerySimplifier.php @@ -37,7 +37,7 @@ class Erfurt_Sparql_EngineDb_QuerySimplifier * Modifies the passed query object directly. */ public function simplify(Erfurt_Sparql_Query $query) { -#return; + $arPatterns = $query->getResultPart(); self::dropEmpty($arPatterns); @@ -91,7 +91,6 @@ protected function executePlan(&$arPatterns, &$arPlan) $id = count($arPatterns)+1; foreach ($arPlan as $nParent => $arChildren) { $base = $arPatterns[$nParent]; - #$grandParent = $base->getSubpatternOf(); $nNextId = $nParent; $oldConstraints = $base->getConstraints(); @@ -99,10 +98,7 @@ protected function executePlan(&$arPatterns, &$arPlan) $optionalIds = $this->_getOptionalIds($arPatterns, $nParent); foreach ($arChildren as $nChild => $null) { - #$new = clone $base; - #$new->addTriplePatterns($arPatterns[$nChild]->getTriplePatterns()); - #$new->addConstraints($arPatterns[$nChild]->getConstraints()); - + $arPatterns[$nChild]->addTriplePatterns($base->getTriplePatterns()); // Catch all used vars from child pattern. diff --git a/library/Erfurt/Sparql/EngineDb/ResultRenderer/Extended.php b/library/Erfurt/Sparql/EngineDb/ResultRenderer/Extended.php index b2ea6c7b..9bba2273 100644 --- a/library/Erfurt/Sparql/EngineDb/ResultRenderer/Extended.php +++ b/library/Erfurt/Sparql/EngineDb/ResultRenderer/Extended.php @@ -156,8 +156,6 @@ protected function _createObjectFromDbRecordSetPart($row, $strVarBase, $strVar, break; default: if ($row[$this->_vars[$strVarName]['sql_ref']] === null) { - #$result = $this->_createLiteral( - # $row[$this->_vars[$strVarName]['sql_value']], null, null); if ($row[$this->_vars[$strVarName]['sql_dt_ref']] === null) { $result = $this->_createLiteral( @@ -173,8 +171,6 @@ protected function _createObjectFromDbRecordSetPart($row, $strVarBase, $strVar, ); } } else { - #$result = $this->_createLiteral( - #$this->literalValues[$row[$this->_vars[$strVarName]['sql_ref']]], null, null); if ($row[$this->_vars[$strVarName]['sql_dt_ref']] === null) { $result = $this->_createLiteral( diff --git a/library/Erfurt/Sparql/EngineDb/ResultRenderer/Plain.php b/library/Erfurt/Sparql/EngineDb/ResultRenderer/Plain.php index 84ccace7..f3dfb7bc 100644 --- a/library/Erfurt/Sparql/EngineDb/ResultRenderer/Plain.php +++ b/library/Erfurt/Sparql/EngineDb/ResultRenderer/Plain.php @@ -258,37 +258,11 @@ protected function _createObjectFromDbRecordSetPart($row, $strVarBase, $strVar, if ($row[$this->_vars[$strVarName]['sql_ref']] === null) { $result = $this->_createLiteral( $row[$this->_vars[$strVarName]['sql_value']], null, null); - - #if ($row[$this->_vars[$strVarName]['sql_dt_ref']] === null) { - # $result = $this->_createLiteral( - # $row[$this->_vars[$strVarName]['sql_value']], - # $row[$this->_vars[$strVarName]['sql_lang']], - # $row[$this->_vars[$strVarName]['sql_type']] - # ); - #} else { - # $result = $this->_createLiteral( - # $row[$this->_vars[$strVarName]['sql_value']], - # $row[$this->_vars[$strVarName]['sql_lang']], - # $this->uriValues[$row[$this->_vars[$strVarName]['sql_dt_ref']]] - # ); - #} + } else { $result = $this->_createLiteral( $this->literalValues[$row[$this->_vars[$strVarName]['sql_ref']]], null, null); - - #if ($row[$this->_vars[$strVarName]['sql_dt_ref']] === null) { - # $result = $this->_createLiteral( - # $this->literalValues[$row[$this->_vars[$strVarName]['sql_ref']]], - # $row[$this->_vars[$strVarName]['sql_lang']], - # $row[$this->_vars[$strVarName]['sql_type']] - # ); - #} else { - # $result = $this->_createLiteral( - # $this->literalValues[$row[$this->_vars[$strVarName]['sql_ref']]], - # $row[$this->_vars[$strVarName]['sql_lang']], - # $this->uriValues[$row[$this->_vars[$strVarName]['sql_dt_ref']]] - # ); - #} + } } diff --git a/library/Erfurt/Sparql/EngineDb/SqlGenerator/Adapter/Ef.php b/library/Erfurt/Sparql/EngineDb/SqlGenerator/Adapter/Ef.php index c1a53658..c251e9e6 100644 --- a/library/Erfurt/Sparql/EngineDb/SqlGenerator/Adapter/Ef.php +++ b/library/Erfurt/Sparql/EngineDb/SqlGenerator/Adapter/Ef.php @@ -207,10 +207,6 @@ public function createSql() foreach ($this->query->getResultPart() as $graphPattern) { - #if ($graphPattern->isEmpty()) { - # continue; - #} - if ($graphPattern->getUnion() !== null) { ++$this->nUnionCount; $this->nTableId = 0; @@ -395,14 +391,10 @@ function getTripleSql(Erfurt_Sparql_QueryTriple $triple, Erfurt_Sparql_GraphPatt $bWhereEqualitySubject = true; $this->arUsedVarTypes[$subject]['s'] = true; } else { - #if (isset($this->arVarAssignments[$subject][0])) { - # $strTablePrefix = $this->arVarAssignments[$subject][0]; - #} if (!isset($this->arVarAssignments[$subject])) { $this->arVarAssignments[$subject] = array($strTablePrefix, 's'); } - #$this->arVarAssignments[$subject] = array($strTablePrefix, 's'); $this->arVarAssignments[$subject][1] = 's'; $this->arUnionVarAssignments[$this->nUnionCount][$subject] = array($strTablePrefix, 's'); $this->arUsedVarTypes[$subject]['s'] = true; @@ -433,14 +425,10 @@ function getTripleSql(Erfurt_Sparql_QueryTriple $triple, Erfurt_Sparql_GraphPatt $bWhereEqualityPredicate = true; $this->arUsedVarTypes[$predicate]['p'] = true; } else { - #if (isset($this->arVarAssignments[$predicate][0])) { - # $strTablePrefix = $this->arVarAssignments[$predicate][0]; - #} if (!isset($this->arVarAssignments[$predicate])) { $this->arVarAssignments[$predicate] = array($strTablePrefix, 'p'); } - #$this->arVarAssignments[$predicate] = array($strTablePrefix, 'p'); $this->arVarAssignments[$predicate][1] = 'p'; $this->arUnionVarAssignments[$this->nUnionCount][$predicate] = array($strTablePrefix, 'p'); $this->arUsedVarTypes[$predicate]['p'] = true; @@ -467,9 +455,6 @@ function getTripleSql(Erfurt_Sparql_QueryTriple $triple, Erfurt_Sparql_GraphPatt $bWhereEqualityObject = true; $this->arUsedVarTypes[$object]['o'] = true; } else { - #if (isset($this->arVarAssignments[$object][0])) { - # $strTablePrefix = $this->arVarAssignments[$object][0]; - #} if (!isset($this->arVarAssignments[$object])) { $this->arVarAssignments[$object] = array($strTablePrefix, 'o'); } @@ -712,7 +697,6 @@ protected function createEqualSelects($arSelect) $ar[] = implode(',', $arVarParts); $arHasItems = true; } - // if (count($ar) > 0) { if ( true === $arHasItems ) { $arNewSelect[0][] = implode(',', $ar); } diff --git a/library/Erfurt/Sparql/EngineDb/TypeSorter.php b/library/Erfurt/Sparql/EngineDb/TypeSorter.php index 4a9232a5..d89feb69 100644 --- a/library/Erfurt/Sparql/EngineDb/TypeSorter.php +++ b/library/Erfurt/Sparql/EngineDb/TypeSorter.php @@ -285,9 +285,6 @@ protected function getTypeSets($arSpecialVars, $strFrom, $strWhere, $nUnion) $var['datatype'] = array_values(array_unique($var['datatype'])); } } - - - //$arTypes = array_unique($arTypes); return $arTypes; } @@ -409,13 +406,6 @@ function getSqlOrderBy($arTypeSet = array(), $n = 0) return ''; } - #if (count($arTypeSet) === 0) { - # return ''; - #} - -//var_dump($arTypeSet); -//var_dump($this->arUnionVarAssignments); - $sqlOrder = array(); foreach ($arSM['order by'] as $arVar) { $strSparqlVar = $arVar['val']; @@ -452,7 +442,6 @@ function getSqlOrderBy($arTypeSet = array(), $n = 0) if (count($sqlOrder) === 0) { throw new Erfurt_Exception('Something went wrong with ORDER BY.'); } -//var_dump($sqlOrder);exit; return ' ORDER BY ' . implode(', ', $sqlOrder); }//function getSqlOrderBy($arTypeSet = array()) diff --git a/library/Erfurt/Sparql/Parser.php b/library/Erfurt/Sparql/Parser.php index 21a7a975..4e26d43d 100644 --- a/library/Erfurt/Sparql/Parser.php +++ b/library/Erfurt/Sparql/Parser.php @@ -445,10 +445,7 @@ protected function _dtypeCheck(&$node) /** FastForward until next token which is not blank. */ protected function _fastForward() - { - #next($this->_tokens); - #return; - + { $tok = next($this->_tokens); while ($tok === ' ') { $tok = next($this->_tokens); @@ -683,15 +680,6 @@ protected function _parseConstraintTree($nLevel = 0, $bParameter = false) } continue 2; break; -# case '>': -# $litQuotes = null; -# $part[] = array( -# 'type' => 'value', -# 'value' => $strQuoted, -# 'quoted'=> false -# ); -# continue 2; -# break; case '(': $parens = true; $bFunc1 = isset($part[0]['type']) && $part[0]['type'] === 'value'; diff --git a/library/Erfurt/Sparql/Parser/Sparql10.php b/library/Erfurt/Sparql/Parser/Sparql10.php index 17ab331a..3f4e8838 100644 --- a/library/Erfurt/Sparql/Parser/Sparql10.php +++ b/library/Erfurt/Sparql/Parser/Sparql10.php @@ -22,7 +22,6 @@ public static function initFromString($queryString, $parsePartial = null){ $retval=null; $input = new Erfurt_Sparql_Parser_Util_CaseInsensitiveStream($queryString); $lexer = new Erfurt_Sparql_Parser_Sparql10_Sparql10Lexer($input); -// if (!count($lexer->getErrors())) { $tokens = new CommonTokenStream($lexer); $parser = new Erfurt_Sparql_Parser_Sparql10_Sparql10Parser($tokens); if($parsePartial != null && is_string($parsePartial) && method_exists($parser, $parsePartial)){ @@ -30,12 +29,8 @@ public static function initFromString($queryString, $parsePartial = null){ } else { $retval = $parser->parse(); } -// } return array('retval' =>$retval, 'errors'=> - //array_merge($lexer->getErrors(), - //$parser? $parser->getErrors() - //:array()) ); } diff --git a/library/Erfurt/Sparql/Parser/Sparql10/Sparql10/Sparql10.php b/library/Erfurt/Sparql/Parser/Sparql10/Sparql10/Sparql10.php index 6b81aad4..9f404c85 100644 --- a/library/Erfurt/Sparql/Parser/Sparql10/Sparql10/Sparql10.php +++ b/library/Erfurt/Sparql/Parser/Sparql10/Sparql10/Sparql10.php @@ -5440,8 +5440,6 @@ static function getValues(){ class Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA9 extends DFA { public function __construct($recognizer) { -// global $Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA9; -// $DFA = $Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA9; $DFA = Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA9_static::getValues(); $this->recognizer = $recognizer; $this->decisionNumber = 9; @@ -5493,8 +5491,6 @@ static function getValues(){ class Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA21 extends DFA { public function __construct($recognizer) { -// global $Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA21; -// $DFA = $Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA21; $DFA = Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA21_static::getValues(); $this->recognizer = $recognizer; $this->decisionNumber = 21; @@ -5546,8 +5542,6 @@ static function getValues(){ class Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA24 extends DFA { public function __construct($recognizer) { -// global $Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA24; -// $DFA = $Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA24; $DFA = Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA24_static::getValues(); $this->recognizer = $recognizer; $this->decisionNumber = 24; @@ -5598,8 +5592,6 @@ static function getValues(){ class Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA23 extends DFA { public function __construct($recognizer) { -// global $Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA23; -// $DFA = $Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA23; $DFA = Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA23_static::getValues(); $this->recognizer = $recognizer; $this->decisionNumber = 23; @@ -5653,8 +5645,6 @@ static function getValues(){ class Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA25 extends DFA { public function __construct($recognizer) { -// global $Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA25; -// $DFA = $Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA25; $DFA = Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA25_static::getValues(); $this->recognizer = $recognizer; $this->decisionNumber = 25; @@ -5708,9 +5698,7 @@ static function getValues(){ class Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA27 extends DFA { public function __construct($recognizer) { -// global $Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA27; -// $DFA = $Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA27; - $DFA = Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA27_static::getValues(); + $DFA = Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA27_static::getValues(); $this->recognizer = $recognizer; $this->decisionNumber = 27; $this->eot = $DFA['eot']; @@ -5763,9 +5751,7 @@ static function getValues(){ class Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA28 extends DFA { public function __construct($recognizer) { -// global $Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA28; -// $DFA = $Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA28; - $DFA = Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA28_static::getValues(); + $DFA = Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA28_static::getValues(); $this->recognizer = $recognizer; $this->decisionNumber = 28; $this->eot = $DFA['eot']; @@ -5818,9 +5804,7 @@ static function getValues(){ class Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA30 extends DFA { public function __construct($recognizer) { -// global $Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA30; -// $DFA = $Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA30; - $DFA = Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA30_static::getValues(); + $DFA = Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA30_static::getValues(); $this->recognizer = $recognizer; $this->decisionNumber = 30; $this->eot = $DFA['eot']; @@ -5873,9 +5857,7 @@ static function getValues(){ class Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA33 extends DFA { public function __construct($recognizer) { -// global $Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA33; -// $DFA = $Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA33; - $DFA = Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA33_static::getValues(); + $DFA = Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA33_static::getValues(); $this->recognizer = $recognizer; $this->decisionNumber = 33; $this->eot = $DFA['eot']; @@ -5925,9 +5907,7 @@ static function getValues(){ class Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA34 extends DFA { public function __construct($recognizer) { -// global $Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA34; -// $DFA = $Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA34; - $DFA = Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA34_static::getValues(); + $DFA = Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA34_static::getValues(); $this->recognizer = $recognizer; $this->decisionNumber = 34; $this->eot = $DFA['eot']; @@ -5981,9 +5961,7 @@ static function getValues(){ class Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA37 extends DFA { public function __construct($recognizer) { -// global $Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA37; -// $DFA = $Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA37; - $DFA = Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA37_static::getValues(); + $DFA = Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA37_static::getValues(); $this->recognizer = $recognizer; $this->decisionNumber = 37; $this->eot = $DFA['eot']; @@ -6035,9 +6013,7 @@ static function getValues(){ class Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA38 extends DFA { public function __construct($recognizer) { -// global $Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA38; -// $DFA = $Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA38; - $DFA = Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA38_static::getValues(); + $DFA = Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA38_static::getValues(); $this->recognizer = $recognizer; $this->decisionNumber = 38; $this->eot = $DFA['eot']; @@ -6089,9 +6065,7 @@ static function getValues(){ class Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA39 extends DFA { public function __construct($recognizer) { -// global $Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA39; -// $DFA = $Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA39; - $DFA = Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA39_static::getValues(); + $DFA = Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA39_static::getValues(); $this->recognizer = $recognizer; $this->decisionNumber = 39; $this->eot = $DFA['eot']; @@ -6152,9 +6126,7 @@ static function getValues(){ class Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA41 extends DFA { public function __construct($recognizer) { -// global $Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA41; -// $DFA = $Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA41; - $DFA = Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA41_static::getValues(); + $DFA = Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA41_static::getValues(); $this->recognizer = $recognizer; $this->decisionNumber = 41; $this->eot = $DFA['eot']; @@ -6205,9 +6177,7 @@ static function getValues(){ class Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA42 extends DFA { public function __construct($recognizer) { -// global $Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA42; -// $DFA = $Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA42; - $DFA = Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA42_static::getValues(); + $DFA = Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA42_static::getValues(); $this->recognizer = $recognizer; $this->decisionNumber = 42; $this->eot = $DFA['eot']; @@ -6257,9 +6227,7 @@ static function getValues(){ class Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA44 extends DFA { public function __construct($recognizer) { -// global $Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA44; -// $DFA = $Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA44; - $DFA = Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA44_static::getValues(); + $DFA = Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA44_static::getValues(); $this->recognizer = $recognizer; $this->decisionNumber = 44; $this->eot = $DFA['eot']; @@ -6309,9 +6277,7 @@ static function getValues(){ class Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA45 extends DFA { public function __construct($recognizer) { -// global $Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA45; -// $DFA = $Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA45; - $DFA = Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA45_static::getValues(); + $DFA = Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA45_static::getValues(); $this->recognizer = $recognizer; $this->decisionNumber = 45; $this->eot = $DFA['eot']; @@ -6363,9 +6329,7 @@ static function getValues(){ class Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA48 extends DFA { public function __construct($recognizer) { -// global $Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA48; -// $DFA = $Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA48; - $DFA = Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA48_static::getValues(); + $DFA = Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA48_static::getValues(); $this->recognizer = $recognizer; $this->decisionNumber = 48; $this->eot = $DFA['eot']; @@ -6426,9 +6390,7 @@ static function getValues(){ class Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA49 extends DFA { public function __construct($recognizer) { -// global $Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA49; -// $DFA = $Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA49; - $DFA = Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA49_static::getValues(); + $DFA = Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA49_static::getValues(); $this->recognizer = $recognizer; $this->decisionNumber = 49; $this->eot = $DFA['eot']; @@ -6480,9 +6442,7 @@ static function getValues(){ class Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA50 extends DFA { public function __construct($recognizer) { -// global $Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA50; -// $DFA = $Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA50; - $DFA = Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA50_static::getValues(); + $DFA = Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA50_static::getValues(); $this->recognizer = $recognizer; $this->decisionNumber = 50; $this->eot = $DFA['eot']; @@ -6535,9 +6495,7 @@ static function getValues(){ class Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA54 extends DFA { public function __construct($recognizer) { -// global $Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA54; -// $DFA = $Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA54; - $DFA = Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA54_static::getValues(); + $DFA = Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA54_static::getValues(); $this->recognizer = $recognizer; $this->decisionNumber = 54; $this->eot = $DFA['eot']; @@ -6588,9 +6546,7 @@ static function getValues(){ class Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA57 extends DFA { public function __construct($recognizer) { -// global $Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA57; -// $DFA = $Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA57; - $DFA = Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA57_static::getValues(); + $DFA = Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA57_static::getValues(); $this->recognizer = $recognizer; $this->decisionNumber = 57; $this->eot = $DFA['eot']; @@ -6641,9 +6597,7 @@ static function getValues(){ class Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA59 extends DFA { public function __construct($recognizer) { -// global $Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA59; -// $DFA = $Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA59; - $DFA = Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA59_static::getValues(); + $DFA = Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA59_static::getValues(); $this->recognizer = $recognizer; $this->decisionNumber = 59; $this->eot = $DFA['eot']; @@ -6694,9 +6648,7 @@ static function getValues(){ class Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA61 extends DFA { public function __construct($recognizer) { -// global $Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA61; -// $DFA = $Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA61; - $DFA = Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA61_static::getValues(); + $DFA = Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA61_static::getValues(); $this->recognizer = $recognizer; $this->decisionNumber = 61; $this->eot = $DFA['eot']; @@ -6750,9 +6702,7 @@ static function getValues(){ class Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA62 extends DFA { public function __construct($recognizer) { -// global $Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA62; -// $DFA = $Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA62; - $DFA = Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA62_static::getValues(); + $DFA = Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA62_static::getValues(); $this->recognizer = $recognizer; $this->decisionNumber = 62; $this->eot = $DFA['eot']; @@ -6806,9 +6756,7 @@ static function getValues(){ class Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA63 extends DFA { public function __construct($recognizer) { -// global $Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA63; -// $DFA = $Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA63; - $DFA = Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA63_static::getValues(); + $DFA = Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA63_static::getValues(); $this->recognizer = $recognizer; $this->decisionNumber = 63; $this->eot = $DFA['eot']; @@ -6858,9 +6806,7 @@ static function getValues(){ class Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA64 extends DFA { public function __construct($recognizer) { -// global $Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA64; -// $DFA = $Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA64; - $DFA = Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA64_static::getValues(); + $DFA = Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA64_static::getValues(); $this->recognizer = $recognizer; $this->decisionNumber = 64; $this->eot = $DFA['eot']; @@ -6911,9 +6857,7 @@ static function getValues(){ class Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA66 extends DFA { public function __construct($recognizer) { -// global $Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA66; -// $DFA = $Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA66; - $DFA = Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA66_static::getValues(); + $DFA = Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA66_static::getValues(); $this->recognizer = $recognizer; $this->decisionNumber = 66; $this->eot = $DFA['eot']; @@ -6968,9 +6912,7 @@ static function getValues(){ class Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA67 extends DFA { public function __construct($recognizer) { -// global $Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA67; -// $DFA = $Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA67; - $DFA = Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA67_static::getValues(); + $DFA = Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA67_static::getValues(); $this->recognizer = $recognizer; $this->decisionNumber = 67; $this->eot = $DFA['eot']; @@ -7019,9 +6961,7 @@ static function getValues(){ class Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA68 extends DFA { public function __construct($recognizer) { -// global $Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA68; -// $DFA = $Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA68; - $DFA = Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA68_static::getValues(); + $DFA = Erfurt_Sparql_Parser_Sparql10_Sparql10_Sparql10_DFA68_static::getValues(); $this->recognizer = $recognizer; $this->decisionNumber = 68; $this->eot = $DFA['eot']; diff --git a/library/Erfurt/Sparql/Parser/Sparql10/Sparql10/Tokenizer.php b/library/Erfurt/Sparql/Parser/Sparql10/Sparql10/Tokenizer.php index af55b0de..db0eab65 100644 --- a/library/Erfurt/Sparql/Parser/Sparql10/Sparql10/Tokenizer.php +++ b/library/Erfurt/Sparql/Parser/Sparql10/Sparql10/Tokenizer.php @@ -57,9 +57,7 @@ static function getValues(){ class Erfurt_Sparql_Parser_Sparql10_Sparql10_Tokenizer_DFA15 extends DFA { public function __construct($recognizer) { -// global $Erfurt_Sparql_Parser_Sparql10_Sparql10_Tokenizer_DFA15; -// $DFA = $Erfurt_Sparql_Parser_Sparql10_Sparql10_Tokenizer_DFA15; - $DFA = Erfurt_Sparql_Parser_Sparql10_Sparql10_Tokenizer_DFA15_static::getValues(); + $DFA = Erfurt_Sparql_Parser_Sparql10_Sparql10_Tokenizer_DFA15_static::getValues(); $this->recognizer = $recognizer; $this->decisionNumber = 15; $this->eot = $DFA['eot']; @@ -443,9 +441,7 @@ static function getValues(){ class Erfurt_Sparql_Parser_Sparql10_Sparql10_Tokenizer_DFA36 extends DFA { public function __construct($recognizer) { -// global $Erfurt_Sparql_Parser_Sparql10_Sparql10_Tokenizer_DFA36; -// $DFA = $Erfurt_Sparql_Parser_Sparql10_Sparql10_Tokenizer_DFA36; - $DFA = Erfurt_Sparql_Parser_Sparql10_Sparql10_Tokenizer_DFA36_static::getValues(); + $DFA = Erfurt_Sparql_Parser_Sparql10_Sparql10_Tokenizer_DFA36_static::getValues(); $this->recognizer = $recognizer; $this->decisionNumber = 36; $this->eot = $DFA['eot']; diff --git a/library/Erfurt/Sparql/Parser/Sparql11update.php b/library/Erfurt/Sparql/Parser/Sparql11update.php index 7ce6908b..92f2d55d 100644 --- a/library/Erfurt/Sparql/Parser/Sparql11update.php +++ b/library/Erfurt/Sparql/Parser/Sparql11update.php @@ -28,9 +28,6 @@ public static function initFromString($queryString, $parserOptions = array()){ $input = new Erfurt_Sparql_Parser_Util_CaseInsensitiveStream($queryString); $lexer = new Erfurt_Sparql_Parser_Sparql11_UpdateLexer($input); $tokens = new CommonTokenStream($lexer); - // foreach ($tokens->getTokens() as $t) { - // echo $t."\n"; - // } $parser = new Erfurt_Sparql_Parser_Sparql11_UpdateParser($tokens); $q = $parser->parse(); } diff --git a/library/Erfurt/Sparql/Parser/Util/CaseInsensitiveStream.php b/library/Erfurt/Sparql/Parser/Util/CaseInsensitiveStream.php index 4bb996e5..c31bb6a1 100644 --- a/library/Erfurt/Sparql/Parser/Util/CaseInsensitiveStream.php +++ b/library/Erfurt/Sparql/Parser/Util/CaseInsensitiveStream.php @@ -19,12 +19,8 @@ public function LA($i) } if ( ($this->p+$i-1) >= $this->n ) { - //System.out.println("char LA("+i+")=EOF; p="+p); return CharStreamConst::$EOF; } - // echo ord(strtolower(chr($this->data[$this->p+$i-1]))) . "\n"; - //System.out.println("char LA("+i+")="+(char)data[p+i-1]+"; p="+p); - //System.out.println("LA("+i+"); p="+p+" n="+n+" data.length="+data.length); return ord(strtolower(chr($this->data[$this->p+$i-1]))); } diff --git a/library/Erfurt/Sparql/Query2.php b/library/Erfurt/Sparql/Query2.php index 2292af14..84423825 100644 --- a/library/Erfurt/Sparql/Query2.php +++ b/library/Erfurt/Sparql/Query2.php @@ -84,7 +84,6 @@ static function getNextID() public function __construct($type = null) { - //parent::__construct(); $this->order = new Erfurt_Sparql_Query2_OrderClause(); $this->where = new Erfurt_Sparql_Query2_GroupGraphPattern; @@ -100,7 +99,6 @@ public function __clone() foreach ($this as $key => $val) { if (is_object($val)||(is_array($val))) { $this->{$key} = unserialize(serialize($val)); - //$this->$key= clone($this->$key); } } } @@ -226,15 +224,7 @@ public function setQueryType($type) //special configs for different types... switch($type) { case self::typeSelect: - break; case self::typeAsk: - //ask has no solution modifyer - delete? - //$this->setLimit(0); - //$this->setOffset(0); - //$this->order = new Erfurt_Sparql_Query2_OrderClause(); - //$this->distinctReducedMode = 0; - //$this->projectionVars = array(); - break; case self::typeDescribe: break; case self::typeConstruct: @@ -374,10 +364,6 @@ public function getLimit() */ public function setOffset($noffset) { - //if ($this->type == self::typeAsk) - // throw new RuntimeException("Trying to set solution modifier \"Offset\"". - // " in an ASK-Query - not possible"); - $this->offset = $noffset; return $this; //for chaining } @@ -734,12 +720,6 @@ public function addProjectionVar(Erfurt_Sparql_Query2_Var $var) } } - /*if (!in_array($var, $this->where->getVars())) { - trigger_error('Trying to add projection-var ('.$var->getSparql().') '. - * 'that is not used in pattern', E_USER_NOTICE); - return $this; //for chaining - }*/ - if (count($this->projectionVars) == 0){ //if the first var is added: deactivate the star. //maybe always? @@ -868,11 +848,6 @@ public function getVars() */ public function getOrder() { - //if ($this->type == self::typeAsk) { - // throw new RuntimeException( - // "Trying to set solution modifier \"Order\" in an ASK-Query - not possible" - // ); - //} return $this->order; } diff --git a/library/Erfurt/Sparql/Query2/Abstraction/ClassNode.php b/library/Erfurt/Sparql/Query2/Abstraction/ClassNode.php index f964c301..e30d8f2f 100644 --- a/library/Erfurt/Sparql/Query2/Abstraction/ClassNode.php +++ b/library/Erfurt/Sparql/Query2/Abstraction/ClassNode.php @@ -130,15 +130,6 @@ public static function addShownPropertyHelper(Erfurt_Sparql_Query2 $query, Erfur $optionalpart->addElement($triple); $query->getWhere()->addElement($optionalpart); - /* filtered now in php - $filter = new Erfurt_Sparql_Query2_Filter( - new Erfurt_Sparql_Query2_UnaryExpressionNot( - new Erfurt_Sparql_Query2_isBlank($var) - ) - );*/ - - //$optionalpart->addElement($filter); - $query->addProjectionVar($var); return array('optional' => $optionalpart, 'var' => $var, 'filter' => null); diff --git a/library/Erfurt/Sparql/Query2/ContainerHelper.php b/library/Erfurt/Sparql/Query2/ContainerHelper.php index 746f8444..8bd6c423 100644 --- a/library/Erfurt/Sparql/Query2/ContainerHelper.php +++ b/library/Erfurt/Sparql/Query2/ContainerHelper.php @@ -41,7 +41,6 @@ public function getParentContainer($needle){ return $parents; } - //abstract public function addElement($member); //not used because some use typehinting some do it internally for multiple types /** * getElement @@ -80,7 +79,6 @@ public function getVars() { return $ret; } - //abstract public function setElement($i, $member); //not used because some use typehinting some do it internally abstract public function setElements($elements); /** @@ -116,7 +114,6 @@ public function removeElement($toDelete, $equal = false) { } } } - //$toDelete->removeParent($this); $this->elements = $new; return $this; //for chaining diff --git a/library/Erfurt/Sparql/Query2/ElementHelper.php b/library/Erfurt/Sparql/Query2/ElementHelper.php index 1d96024a..d7ce51b3 100644 --- a/library/Erfurt/Sparql/Query2/ElementHelper.php +++ b/library/Erfurt/Sparql/Query2/ElementHelper.php @@ -23,8 +23,6 @@ public function __construct() { $this->id = Erfurt_Sparql_Query2::getNextID(); } - //abstract public function getSparql(); - /** * addParent * when a ElementHelper-object is added to a ContainerHelper-object this method is called. lets the child know of the new parent diff --git a/library/Erfurt/Sparql/SimpleQuery.php b/library/Erfurt/Sparql/SimpleQuery.php index 9a65a426..e632527e 100644 --- a/library/Erfurt/Sparql/SimpleQuery.php +++ b/library/Erfurt/Sparql/SimpleQuery.php @@ -120,7 +120,6 @@ public static function initWithString($queryString) $var = '[?$]{1}[\w\d]+'; $expr = '(\w*\(.*\))'; - // /(BASE.*?\s)?(PREFIX.*?\s)*(ASK|((COUNT(\s)*(\(.*?\))))|(SELECT(\s)+)(DISTINCT(\s)+)?(COUNT(\s)+(\(.*?\)(\s)))?(\?\w+\s+|\*)*)/si $tokens = array( 'prefix' => '/((PREFIX\s+[^:\s]+:\s+<[^\s]*>\s*)+)/si', 'base' => '/BASE\s+<(.+?)>/i', @@ -139,9 +138,6 @@ public static function initWithString($queryString) preg_match_all($pattern, $queryString, $parts[$key]); } - //echo $queryString; - //var_dump($parts); - $queryObject = new self(); if (isset($parts['prefix'][0][0]) || isset($parts['base'][0][0])) { $prologue = ''; diff --git a/library/Erfurt/Store.php b/library/Erfurt/Store.php index dc3ccb5e..26c65d27 100644 --- a/library/Erfurt/Store.php +++ b/library/Erfurt/Store.php @@ -1489,8 +1489,6 @@ protected function _prepareQuery($queryObject, &$options = array()) //the query will be altered here to implement AC and owl:imports //dont make these changes global $queryObject = clone $queryObject; - //bring triples etc. to canonical order - // $queryObject->optimize(); } $defaultOptions = array( @@ -1516,13 +1514,6 @@ protected function _prepareQuery($queryObject, &$options = array()) ); } - /* -if ($options[Erfurt_Store::USE_AC] == false) { - //we are done preparing early - return $queryObject; - } -*/ - $logger = $this->_getQueryLogger(); $noBindings = false; @@ -1716,8 +1707,6 @@ public function sparqlQuery($queryObject, $options = array()) $sparqlResult['results'] = array(); $sparqlResult['results']['bindings'] = array(); } else { - //var_dump($queryString);exit; - //exit; throw new Erfurt_Store_Exception('invalid query result.'); } } @@ -1791,9 +1780,6 @@ public function sqlQuery($sqlQuery, $limit = PHP_INT_MAX, $offset = 0) } return $result; } - - // TODO: will throw an exception - // throw new Erfurt_Store_Exception('Current backend doesn not support SQL queries.'); } /** @@ -2226,15 +2212,6 @@ private function _fetchResourceDescription( $row['p'], $row['o'] ); - - // todo: implement blank node fetching here - //if ($row['o']['type'] === 'bnode') { - //$nodeId = $row['o']['value']; - //$bNode = self::initWithBlankNode($nodeId, $this->_model); - //$nodeKey = sprintf('_:%s', $nodeId); - - //$description[$nodeKey] = $bNode->getDescription($maxDepth-1); - //} } } @@ -2410,7 +2387,6 @@ private function _getTransitiveClosure($modelIri, $property, $startResources, $i $classes = array(); foreach ($result as $row) { - // $key = $inverse ? $row['child'] : $row['parent']; $key = $inverse ? $row['child'] : $row['parent']; $closure[$key] = array( 'node' => $inverse ? $row['child'] : $row['parent'], diff --git a/library/Erfurt/Store/Adapter/EfZendDb.php b/library/Erfurt/Store/Adapter/EfZendDb.php index 9406c6bf..2b564777 100644 --- a/library/Erfurt/Store/Adapter/EfZendDb.php +++ b/library/Erfurt/Store/Adapter/EfZendDb.php @@ -220,6 +220,15 @@ public function addMultipleStatements($graphUri, array $statementsArray, array $ $sqlString .= "($graphId, $sValue, $pValue, $oValue,"; + #$data = array( + # 'g' => $graphId, + # 's' => $subject, + # 'p' => $predicate, + # 'o' => $object['value'], + # 'st' => $subjectIs, + # 'ot' => $objectIs + #); + if ($sRef !== false) { $sqlString .= "$sRef,"; } else { @@ -1081,7 +1090,7 @@ public function sqlQuery($sqlQuery, $limit = PHP_INT_MAX, $offset = 0) } else { try { $result = @$this->_dbConn->fetchAll($sqlQuery); - } catch (Zend_Db_Exception $e) { #return false; + } catch (Zend_Db_Exception $e) { throw new Erfurt_Store_Adapter_Exception( $e->getMessage() ); diff --git a/library/Erfurt/Store/Adapter/Mssql.php b/library/Erfurt/Store/Adapter/Mssql.php index 43223f0f..1209453f 100644 --- a/library/Erfurt/Store/Adapter/Mssql.php +++ b/library/Erfurt/Store/Adapter/Mssql.php @@ -80,9 +80,6 @@ public function __construct($adapterOptions = array()) throw new Erfurt_Exception('An error with the specified database adapter occured.', -1); } - // we want indexed results - //$this->_dbConn->setFetchMode(Zend_Db::FETCH_NUM); - // load title properties for model titles $config = Erfurt_App::getInstance()->getConfig(); if (isset($config->properties->title)) { @@ -92,16 +89,6 @@ public function __construct($adapterOptions = array()) public function __destruct() { - #$log = Erfurt_App::getInstance()->getLog(); - - #$profiles = $this->_dbConn->getProfiler()->getQueryProfiles(); - - #foreach ($profiles as $profile) { - # $debugStr = 'Query: ' . $profile->getQuery() . PHP_EOL; - # $debugStr .= 'Time: ' . $profile->getElapsedSecs() . PHP_EOL; - # - # $log->debug($debugStr); - #} } // ------------------------------------------------------------------------ @@ -208,7 +195,7 @@ public function addMultipleStatements($graphUri, array $statementsArray, array $ $oValue = addslashes($o['value']); $sqlString .= "($graphId,'$s','$p','$oValue',"; - + #$data = array( # 'g' => $graphId, # 's' => $subject, @@ -236,9 +223,6 @@ public function addMultipleStatements($graphUri, array $statementsArray, array $ $sqlString .= "$subjectIs,$objectIs,'$lang',"; - #$data['ol'] = $lang; - - if (strlen((string)$dType) > $this->_getSchemaRefThreshold()) { $dTypeHash = md5((string)$dType); @@ -254,11 +238,9 @@ public function addMultipleStatements($graphUri, array $statementsArray, array $ $sqlString .= "'$dType',$dtRef)"; } else { - #$data['od'] = $dType; $sqlString .= "'$dType',NULL)"; } -// $insertArray[] = $sqlString; $counter++; $finalquery = 'IF NOT EXISTS(Select g, s, p, o, st, ot, ol, od from ef_stmt @@ -971,8 +953,6 @@ public function importRdf($modelUri, $data, $type, $locator) } else { $sql .= "NULL,NULL)"; } - - //$this->_dbConn->getConnection()->query($sql); } if ($count > 10000) { @@ -1437,8 +1417,6 @@ private function _fetchModelInfos() } else { $this->_modelInfoCache = array(); - #$rowSet = $result->fetchAll(); - #var_dump($result);exit; foreach ($result as $row) { if (!isset($this->_modelInfoCache[$row['uri']])) { $this->_modelInfoCache[$row['uri']]['modelId'] = $row['id']; @@ -1466,8 +1444,6 @@ private function _fetchModelInfos() } } - //var_dump($this->_modelInfoCache);exit; - // build the transitive closure for owl:imports // check for recursive owl:imports; also check for cylces! do { diff --git a/library/Erfurt/Store/Adapter/Virtuoso.php b/library/Erfurt/Store/Adapter/Virtuoso.php index 4eefc0ea..bac96c10 100644 --- a/library/Erfurt/Store/Adapter/Virtuoso.php +++ b/library/Erfurt/Store/Adapter/Virtuoso.php @@ -236,8 +236,6 @@ public function connection() if (!$this->_connection) { $options = $this->_adapterOptions; - // ini_set('odbc.default_cursortype', SQL_CURSOR_FORWARD_ONLY); - // determine connection function if ((isset($options['use_persistent_connection'])) && ((boolean) $options['use_persistent_connection'] === true)) { @@ -494,11 +492,6 @@ public function getSearchPatternWithNode($stringSpec, $predicateVariable, $optio new Erfurt_Sparql_Query2_Equals($strExpression, $literalExpression) ); } else { - // string >= bifLimit characters - // if (false === strpos($stringSpec, '*')) { - // $stringSpec .= '*'; - // } - $bifPrefix = new Erfurt_Sparql_Query2_Prefix( 'bif', new Erfurt_Sparql_Query2_IriRef('SparqlProcessorShouldKnow') @@ -527,7 +520,6 @@ public function getSearchPatternWithNode($stringSpec, $predicateVariable, $optio } $searchPattern[] = $filter; -#var_dump((string)$searchPattern[1]);exit; return $searchPattern; } @@ -1046,11 +1038,8 @@ private function _execSparql($sparqlQuery, $graphUri = null) $sparqlQuery = addcslashes($sparqlQuery, '\'\\'); //build Virtuoso/PL query - //$virtuosoPl = 'SPARQL ' . $sparqlQuery; $virtuosoPl = $graphSpec . 'CALL DB.DBA.SPARQL_EVAL(\'' . $sparqlQuery . '\', ' . $graphUri . ', 0)'; -# $resultId = odbc_prepare($this->connection(), $virtuosoPl); -# $resultId = odbc_exec($resultId, $virtuosoPl); $resultId = @odbc_exec($this->connection(), $virtuosoPl); if (false === $resultId) { @@ -1077,8 +1066,6 @@ private function _execSparqlUpdate($sparqlQuery, $graphUri = null) //build Virtuoso/PL query $virtuosoPl = 'SPARQL ' . $sparqlQuery; -# $resultId = odbc_prepare($this->connection(), $virtuosoPl); -# $resultId = odbc_exec($resultId, $virtuosoPl); $resultId = odbc_exec($this->connection(), $virtuosoPl); if (false === $resultId) { @@ -1098,8 +1085,6 @@ private function _execSparqlUpdate($sparqlQuery, $graphUri = null) */ protected function _execSql($sqlQuery) { -# $resultId = odbc_prepare($this->connection(), $sqlQuery); -# $resultId = odbc_exec($resultId, $sqlQuery); $resultId = @odbc_exec($this->connection(), $sqlQuery); if (false === $resultId) { $message = sprintf('SQL Error: %s in query: %s', $this->getLastError(), $sqlQuery); diff --git a/library/Erfurt/Syntax/RdfParser/Adapter/RdfXml.php b/library/Erfurt/Syntax/RdfParser/Adapter/RdfXml.php index c0db7a18..34d09836 100644 --- a/library/Erfurt/Syntax/RdfParser/Adapter/RdfXml.php +++ b/library/Erfurt/Syntax/RdfParser/Adapter/RdfXml.php @@ -280,7 +280,6 @@ protected function _characterData($parser, $data) protected function _handleCharDataStatement() { -#var_dump($this->_currentCharData);exit; if (null !== $this->_currentCharData) { if (trim($this->_currentCharData) === '') { $this->_currentCharData = null; @@ -288,9 +287,6 @@ protected function _handleCharDataStatement() } if (!$this->_topElemIsProperty()) { -#var_dump($this->_currentCharData);exit; -#var_dump($this->_statements); -#var_dump($this->_elementStack);exit; $this->_throwException('Unexpected literal.'); } @@ -313,7 +309,6 @@ protected function _handleCharDataStatement() protected function _processNode($name, &$attrs) { $nodeResource = $this->_getNodeResource($attrs); -#var_dump($nodeResource); if (null === $nodeResource) { return; } @@ -475,17 +470,8 @@ protected function _processProperty($name, &$attrs) $predicate->setDatatype($datatype); } - // Check for about attribute - #$about = $this->_removeAttribute($attrs, EF_RDF_NS.'about'); - #if (null !== $about) { - # $aboutUri = $this->_resolveUri($about); - # $this->_addStatement($aboutUri, EF_RDF_TYPE, $predicate, 'uri'); -// TODO phil # - # $this->_processSubjectAttributes($aboutUri, $attrs); - #} } } -#var_dump($this->_currentElementIsEmpty); if ($this->_currentElementIsEmpty) { array_pop($this->_elementStack); } @@ -721,18 +707,8 @@ private function _getXmlParser() // Set the handler method for namespace definitions xml_set_start_namespace_decl_handler($this->_xmlParser, array($this, '_handleNamespaceDeclaration')); - //$this->_setNamespaceDeclarationHandler('_handleNamespaceDeclaration'); - - //xml_set_end_namespace_decl_handler($xmlParser, array(&$this, '_handleNamespaceDeclaration')); - xml_set_character_data_handler($this->_xmlParser, array($this, '_characterData')); - //xml_set_external_entity_ref_handler($this->_xmlParser, array($this, '_handleExternalEntityRef')); - - //xml_set_processing_instruction_handler($this->_xmlParser, array($this, '_handleProcessingInstruction')); - - //xml_set_unparsed_entity_decl_handler($this->_xmlParser, array($this, '_handleUnparsedEntityDecl')); - xml_set_element_handler( $this->_xmlParser, array($this, '_startElement'), @@ -746,7 +722,6 @@ private function _getXmlParser() protected function _handleDefault($parser, $data) { // Handles comments - //var_dump($data); } protected function _handleNamespaceDeclaration($parser, $prefix, $uri) diff --git a/library/Erfurt/Syntax/RdfParser/Adapter/Turtle.php b/library/Erfurt/Syntax/RdfParser/Adapter/Turtle.php index 7b44bf5d..3ed589cc 100644 --- a/library/Erfurt/Syntax/RdfParser/Adapter/Turtle.php +++ b/library/Erfurt/Syntax/RdfParser/Adapter/Turtle.php @@ -15,7 +15,6 @@ class Erfurt_Syntax_RdfParser_Adapter_Turtle extends Erfurt_Syntax_RdfParser_Ada { protected $_data = ''; protected $_pos = 0; - //protected $_lastCharLength = 1; protected $_subject = null; protected $_predicate = null; @@ -300,8 +299,6 @@ protected function _parseUri() $c = $this->_read(); } - #$c = $this->_skipWS(); - $uri = $this->_resolveUri($this->_decodeString($token, true)); return Erfurt_Rdf_Resource::initWithIri($uri); } @@ -501,18 +498,6 @@ protected function _parseQuotedLiteral() } } - /* - protected function _isLanguageChar($c) - { - return ($this->_isLanguageStartChar($c) || is_numeric($c) || $c === '-'); - }*/ - - /* - protected function _isLanguageStartChar($c) - { - return ($this->_ord($c) >= 0x41 && $this->_ord($c) <= 0x7A); - }*/ - protected function _parseQuotedString() { $result = null; @@ -589,9 +574,6 @@ protected function _parseNodeId() $this->_verifyChar($this->_read(), ':'); $c = $this->_read(); - #if (!$this->_isNameStartChar($c)) { - # $this->_throwException('Illegal char.'); - #} $result = $c; @@ -606,32 +588,10 @@ protected function _parseNodeId() return $this->_createBNode($result); } - /* - protected function _isNameChar($c) - { - return ( - $this->_isNameStartChar($c) || - is_numeric($c) || - $c === '-' || - $this->_ord($c) === 0x00B7 || - ($this->_ord($c) >= 0x0300 && $this->_ord($c) < 0x036F) || - ($this->_ord($c) >= 0x203F && $this->_ord($c) < 0x2040) - ); - }*/ - - /*protected function _isNameStartChar($c) - { - return ($c === '_' || $this->_isPrefixStartChar($c)); - }*/ - protected function _parseQNameOrBoolean() { $c = $this->_read(); - #if ($c !== ':' && !$this->_isPrefixStartChar($c)) { - # $this->_throwException('Expected ":" or letter.'); - #} - $namespace = null; if ($c === ':') { // QName with default namespace @@ -679,30 +639,6 @@ protected function _parseQNameOrBoolean() return Erfurt_Rdf_Resource::initWithNamespaceAndLocalName($namespace, $localName); } - /*protected function _isPrefixChar($c) - { - return $this->_isNameChar($c); - }*/ - - /*protected function _isPrefixStartChar($c) - { - return ( - ($this->_ord($c) >= 0x41 && $this->_ord($c) <= 0x7A) || - ($this->_ord($c) >= 0x00C0 && $this->_ord($c) <= 0x00D6) || - ($this->_ord($c) >= 0x00D8 && $this->_ord($c) <= 0x00F6) || - ($this->_ord($c) >= 0x00F8 && $this->_ord($c) <= 0x02FF) || - ($this->_ord($c) >= 0x0370 && $this->_ord($c) <= 0x037D) || - ($this->_ord($c) >= 0x037F && $this->_ord($c) <= 0x1FFF) || - ($this->_ord($c) >= 0x200C && $this->_ord($c) <= 0x200D) || - ($this->_ord($c) >= 0x2070 && $this->_ord($c) <= 0x218F) || - ($this->_ord($c) >= 0x2C00 && $this->_ord($c) <= 0x2FEF) || - ($this->_ord($c) >= 0x3001 && $this->_ord($c) <= 0xD7FF) || - ($this->_ord($c) >= 0xF900 && $this->_ord($c) <= 0xFDCF) || - ($this->_ord($c) >= 0xFDF0 && $this->_ord($c) <= 0xFFFD) || - ($this->_ord($c) >= 0x10000 && $this->_ord($c) <= 0xEFFFF) - ); - }*/ - protected function _parseImplicitBlank() { $this->_verifyChar($this->_read(), '['); diff --git a/library/Erfurt/Syntax/RdfSerializer/Adapter/RdfXml/RdfWriter.php b/library/Erfurt/Syntax/RdfSerializer/Adapter/RdfXml/RdfWriter.php index 45621c02..9dc0b7c1 100644 --- a/library/Erfurt/Syntax/RdfSerializer/Adapter/RdfXml/RdfWriter.php +++ b/library/Erfurt/Syntax/RdfSerializer/Adapter/RdfXml/RdfWriter.php @@ -359,9 +359,6 @@ private function propertyNested($value) } return false; - // TODO - #$this->serializeSubject($value); - #return true; } /** @@ -414,7 +411,6 @@ private function serializeProperty($property, $value) && !$this->propertyXMLLiteral($value) && !$this->propertyLiteral($value)) { - #var_dump($value);exit; throw new Exception('Could not serialize property '.$property.' with value '.$value); } @@ -439,7 +435,6 @@ private function shouldNest($node) return true; } else if ($node['type'] === 'bnode') { return false; - #return true; } else { return false; } diff --git a/library/Erfurt/Syntax/RdfSerializer/Adapter/Turtle.php b/library/Erfurt/Syntax/RdfSerializer/Adapter/Turtle.php index ff626e6a..e09a965c 100644 --- a/library/Erfurt/Syntax/RdfSerializer/Adapter/Turtle.php +++ b/library/Erfurt/Syntax/RdfSerializer/Adapter/Turtle.php @@ -311,10 +311,6 @@ protected function _writeUri($uri) $prefix = null; $uri = substr($uri, $splitIdx); } else { - // We need to support large exports so we add namespaces once and write uris that do not match as - // full uris. - //$this->_addNamespace($ns); - //$prefix = $this->_namespaces[$ns]; } if (null !== $prefix) { diff --git a/library/Erfurt/Worker/Job/Abstract.php b/library/Erfurt/Worker/Job/Abstract.php index c90aca87..2115272f 100644 --- a/library/Erfurt/Worker/Job/Abstract.php +++ b/library/Erfurt/Worker/Job/Abstract.php @@ -250,7 +250,6 @@ private function _getCacheIdForKeyAndScope($key, $scope) } else if ($scope == self::SCOPE_GLOBAL) { $cacheId = self::CACHEID_PREFIX . $key; } - //$this->logSuccess('uses cache id '$cacheId); return $cacheId; } diff --git a/library/Erfurt/Wrapper/Manager.php b/library/Erfurt/Wrapper/Manager.php index c3e84d92..1e8ab6ed 100644 --- a/library/Erfurt/Wrapper/Manager.php +++ b/library/Erfurt/Wrapper/Manager.php @@ -137,10 +137,6 @@ protected function _addWrapper($wrapperName, $wrapperPath) public function addWrapperExternally($wrapperName, $wrapperPath, $privateConfig) { -// if($privateConfig instanceof Zend_Config){ -// $privateConfig = $privateConfig->toArray(); -// } - $wrapperSpec = array( 'class_name' => ucfirst($wrapperName) . 'Wrapper', 'include_path' => $wrapperPath, From bfad8465adfd963ac76bf1d35cf2a8427cc94572 Mon Sep 17 00:00:00 2001 From: Natanael Arndt Date: Wed, 13 Sep 2017 11:33:28 +0200 Subject: [PATCH 4/4] Remove blank lines an commented out code in RdfXml adapter --- .../Syntax/RdfParser/Adapter/RdfXml.php | 305 ++++++++---------- 1 file changed, 137 insertions(+), 168 deletions(-) diff --git a/library/Erfurt/Syntax/RdfParser/Adapter/RdfXml.php b/library/Erfurt/Syntax/RdfParser/Adapter/RdfXml.php index c0db7a18..6c4b4de7 100644 --- a/library/Erfurt/Syntax/RdfParser/Adapter/RdfXml.php +++ b/library/Erfurt/Syntax/RdfParser/Adapter/RdfXml.php @@ -19,27 +19,27 @@ class Erfurt_Syntax_RdfParser_Adapter_RdfXml extends Erfurt_Syntax_RdfParser_Ada protected $_data = null; protected $_offset = 0; protected $_currentElementIsEmpty = false; - + const BNODE_PREFIX = 'node'; - + protected $_bnodeCounter = 0; - + protected $_elementStack = array(); protected $_currentXmlLang = null; - + protected $_statements = array(); - + protected $_xmlParser = null; - + protected $_currentCharData = null; - + protected $_parseToStore = false; protected $_graphUri = null; protected $_useAc = true; protected $_stmtCounter = 0; - + protected $_rdfElementParsed = false; - + protected $_namespaces = array(); private $_httpClient = null; @@ -53,25 +53,25 @@ public function parseFromDataString($dataString, $baseUri = null, $isUrl = false } else { $this->_setBaseUri($baseUri); } - + $xmlParser = $this->_getXmlParser(); - + $this->_data = $dataString; xml_parse($xmlParser, $dataString); - + if (xml_get_error_code($xmlParser) !== 0) { throw new Erfurt_Syntax_RdfParserException( 'Parsing failed: ' . xml_error_string(xml_get_error_code($xmlParser)) ); } - + return $this->_statements; } - + public function parseFromFilename($filename) { $this->_setLocalFileBaseUri($filename); - + stream_context_get_default(array( 'http' => array( 'header' => "Accept: application/rdf+xml" @@ -81,38 +81,38 @@ public function parseFromFilename($filename) 'http' => array( 'header' => "" ))); - + if ($fileHandle === false) { throw new Erfurt_Syntax_RdfParserException("Failed to open file with filename '$filename'"); } - + $xmlParser = $this->_getXmlParser(); - + // Let's parse. while ($data = fread($fileHandle, 4096)) { $this->_data = $data; xml_parse($xmlParser, $data, feof($fileHandle)); $this->_offset++; } - + fclose($fileHandle); return $this->_statements; } - + public function parseFromFilenameToStore($filename, $graphUri, $useAc = true) { $this->_parseToStore = true; $this->_graphUri = $graphUri; $this->_useAc = $useAc; $this->parseFromFilename($filename); - + $this->_writeStatementsToStore(); $this->_addNamespacesToStore(); - return true; + return true; } - + public function parseFromDataStringToStore($data, $graphUri, $useAc = true, $baseUri = null) { $this->_parseToStore = true; @@ -122,36 +122,36 @@ public function parseFromDataStringToStore($data, $graphUri, $useAc = true, $bas $this->_writeStatementsToStore(); $this->_addNamespacesToStore(); - + return true; } public function parseNamespacesFromDataString($data) { $xmlParser = $this->_getXmlParserNamespacesOnly(); - + xml_parse($xmlParser, $data); - + return $this->_namespaces; } - + public function parseNamespacesFromFilename($filename) { $fileHandle = fopen($filename, 'r'); - + if ($fileHandle === false) { throw new Erfurt_Syntax_RdfParserException("Failed to open file with filename '$filename'"); } - + $xmlParser = $this->_getXmlParserNamespacesOnly(); - + // Let's parse. while ($data = fread($fileHandle, 4096)) { $this->_data = $data; xml_parse($xmlParser, $data, feof($fileHandle)); $this->_offset++; } - + fclose($fileHandle); return $this->_namespaces; @@ -160,14 +160,14 @@ public function parseNamespacesFromFilename($filename) /** * Call this method after parsing only. The function parseToStore will add namespaces automatically. * This method is just for situations, where the namespaces are needed to after a in-memory parsing. - * + * * @return array */ public function getNamespaces() { return $this->_namespaces; } - + protected function _addNamespacesToStore() { $erfurtNamespaces = Erfurt_App::getInstance()->getNamespaces(); @@ -177,36 +177,36 @@ protected function _addNamespacesToStore() } catch (Erfurt_Namespaces_Exception $e) { // We need to catch the store exception, for the namespace component throws exceptions in case a prefix // already exists. - + // Do nothing... just continue with the next one... } } } - + protected function _startElement($parser, $name, $attrs) { if (strpos($name, ':') === false) { throw new Erfurt_Syntax_RdfParserException('Invalid element name: ' . $name . '.'); - } - + } + if ($name === EF_RDF_NS.'RDF') { if (isset($attrs[(EF_XML_NS . 'base')])) { $this->_setBaseUri($attrs[(EF_XML_NS . 'base')]); } return; } - + $idx = xml_get_current_byte_index($parser) - $this->_offset*4096; if (($idx >= 0) && (strlen($this->_data) > ($idx+1)) && ($this->_data[$idx].$this->_data[$idx+1]) === '/>') { $this->_currentElementIsEmpty = true; } else { $this->_currentElementIsEmpty = false; } - + if (isset($attrs['http://www.w3.org/XML/1998/namespacelang'])) { $this->_currentXmlLang = $attrs['http://www.w3.org/XML/1998/namespacelang']; } - + if ($this->_topElemIsProperty()) { // In this case the surrounding element is a property, so this element is a s and/or o. $this->_processNode($name, $attrs); @@ -215,31 +215,31 @@ protected function _startElement($parser, $name, $attrs) $this->_processProperty($name, $attrs); } } - + protected function _topElemIsProperty() { - if (count($this->_elementStack) === 0 || + if (count($this->_elementStack) === 0 || $this->_peekStack(0) instanceof Erfurt_Syntax_RdfParser_Adapter_RdfXml_PropertyElement) { - + return true; } else { return false; } } - + protected function _endElement($parser, $name) { $this->_handleCharDataStatement(); - + if ($this->_currentElementIsEmpty) { $this->_currentElementIsEmpty = false; - return; + return; } - + if ($name === EF_RDF_NS.'RDF') { return; } - + $topElement = $this->_peekStack(0); if ($topElement instanceof Erfurt_Syntax_RdfParser_Adapter_RdfXml_NodeElement) { @@ -253,10 +253,10 @@ protected function _endElement($parser, $name) if ($topElement->parseAsCollection()) { $lastListResource = $topElement->getLastListResource(); - + if (null === $lastListResource) { $subject = $this->_peekStack(1); - + $this->_addStatement($subject->getResource(), $topElement->getUri(), EF_RDF_NIL, 'uri'); $this->_handleReification(EF_RDF_NIL); } else { @@ -264,33 +264,29 @@ protected function _endElement($parser, $name) } } } - + array_pop($this->_elementStack); $this->_currentXmlLang = null; } - + protected function _characterData($parser, $data) { if (null !== $this->_currentCharData) { $this->_currentCharData .= $data; } else { $this->_currentCharData = $data; - } + } } - + protected function _handleCharDataStatement() { -#var_dump($this->_currentCharData);exit; if (null !== $this->_currentCharData) { if (trim($this->_currentCharData) === '') { $this->_currentCharData = null; return; } - + if (!$this->_topElemIsProperty()) { -#var_dump($this->_currentCharData);exit; -#var_dump($this->_statements); -#var_dump($this->_elementStack);exit; $this->_throwException('Unexpected literal.'); } @@ -301,36 +297,35 @@ protected function _handleCharDataStatement() $dt = $propElem->getDatatype(); $subjectElem = $this->_peekStack(1); - $this->_addStatement($subjectElem->getResource(), $propElem->getUri(), trim($this->_currentCharData), 'literal', + $this->_addStatement($subjectElem->getResource(), $propElem->getUri(), trim($this->_currentCharData), 'literal', $this->_currentXmlLang, $dt); $this->_handleReification(trim($this->_currentCharData)); - + $this->_currentCharData = null; } } - + protected function _processNode($name, &$attrs) { $nodeResource = $this->_getNodeResource($attrs); -#var_dump($nodeResource); if (null === $nodeResource) { return; } - + $nodeElem = new Erfurt_Syntax_RdfParser_Adapter_RdfXml_NodeElement($nodeResource); - - - + + + if (count($this->_elementStack) > 0) { // Node can be the object or part of an rdf:List $subject = $this->_peekStack(1); $predicate = $this->_peekStack(0); - + if ($predicate->parseAsCollection()) { $lastListResource = $predicate->getLastListResource(); $newListResource = $this->_createBNode(); - + if (null === $lastListResource) { // This is the first element in the list. $this->_addStatement($subject->getResource(), $predicate->getUri(), $newListResource); @@ -339,7 +334,7 @@ protected function _processNode($name, &$attrs) // Not the first element in the list. $this->_addStatement($lastListResource, EF_RDF_REST, $newListResource); } - + $this->_addStatement($newListResource, EF_RDF_FIRST, $nodeResource); $predicate->setLastListResource($newListResource); } else { @@ -347,26 +342,26 @@ protected function _processNode($name, &$attrs) $this->_handleReification($nodeResource); } } - + if ($name !== EF_RDF_NS.'Description') { // Element name is the type of the uri. $this->_addStatement($nodeResource, EF_RDF_TYPE, $name, 'uri'); } - + $type = $this->_removeAttribute($attrs, EF_RDF_TYPE); if (null !== $type) { $className = $this->_resolveUri($type); $this->_addStatement($nodeResource, EF_RDF_TYPE, $className, 'uri'); } - + // Process all remaining attributes of this element. $this->_processSubjectAttributes($nodeResource, $attrs); - + if (!$this->_currentElementIsEmpty) { $this->_elementStack[] = $nodeElem; } } - + protected function _processProperty($name, &$attrs) { $propUri = $name; @@ -376,18 +371,18 @@ protected function _processProperty($name, &$attrs) $subject = $this->_peekStack(0); $propUri = EF_RDF_NS . '_' . $subject->getNextLiCounter(); } - + // Push the property on the stack. $predicate = new Erfurt_Syntax_RdfParser_Adapter_RdfXml_PropertyElement($propUri); $this->_elementStack[] = $predicate; - + // Check, whether the prop has a reification id. $id = $this->_removeAttribute($attrs, EF_RDF_NS.'ID'); if (null !== $id) { $uri = $this->_buildUriFromId($id); $predicate->setReificationUri($uri); } - + // Check for rdf:parseType attribute. $parseType = $this->_removeAttribute($attrs, EF_RDF_NS.'parseType'); if (null !== $parseType) { @@ -395,9 +390,9 @@ protected function _processProperty($name, &$attrs) case 'Resource': $objectResource = $this->_createBNode(); $subject = $this->_peekStack(1); - + $this->_addStatement($subject->getResource(), $propUri, $objectResource, 'bnode'); - + if ($this->_currentElementIsEmpty) { $this->_handleReification($objectResource); } else { @@ -405,7 +400,7 @@ protected function _processProperty($name, &$attrs) $object->setIsVolatile(true); $this->_elementStack[] = $object; } - + break; case 'Collection': if ($this->_currentElementIsEmpty) { @@ -415,112 +410,101 @@ protected function _processProperty($name, &$attrs) } else { $predicate->setParseAsCollection(true); } - + break; - + case 'Literal': if ($this->_currentElementIsEmpty) { $subject = $this->_peekStack(1); - $this->_addStatement($subject->getResource(), $propUri, + $this->_addStatement($subject->getResource(), $propUri, '', 'literal', null, EF_RDF_NS.'XmlLiteral'); $this->_handleReification(''); } else { $predicate->setDatatype($value); } - - break; + + break; } } else { // No parseType - + if ($this->_currentElementIsEmpty) { if (count($attrs) === 0 || (count($attrs) === 1 && isset($attrs[EF_RDF_NS.'datatype']))) { // Element has no attributes, or only the optional // rdf:ID and/or rdf:datatype attributes. $subject = $this->_peekStack(1); - + $dt = null; if (isset($attrs[EF_RDF_NS.'datatype'])) { $dt = $attrs[EF_RDF_NS.'datatype']; } - + $this->_addStatement($subject->getResource(), $propUri, '', 'literal', $this->_currentXmlLang, $dt); $this->_handleReification(''); - } else { + } else { $resourceRes = $this->_getPropertyResource($attrs); - + if (null === $resourceRes) { return; } - + $subject = $this->_peekStack(1); - + $this->_addStatement($subject->getResource(), $propUri, $resourceRes); $this->_handleReification($resourceRes); - + $type = $this->_removeAttribute($attrs, EF_RDF_TYPE); if (null !== $type) { $className = $this->_resolveUri($type); - + $this->_addStatement($resourceRes, EF_RDF_TYPE, $className); } - + $this->_processSubjectAttributes($resourceRes, $attrs); } } else { // Not an empty element. - $datatype = $this->_removeAttribute($attrs, EF_RDF_NS.'datatype'); if (null !== $datatype) { $predicate->setDatatype($datatype); } - - // Check for about attribute - #$about = $this->_removeAttribute($attrs, EF_RDF_NS.'about'); - #if (null !== $about) { - # $aboutUri = $this->_resolveUri($about); - # $this->_addStatement($aboutUri, EF_RDF_TYPE, $predicate, 'uri'); -// TODO phil # - # $this->_processSubjectAttributes($aboutUri, $attrs); - #} } } -#var_dump($this->_currentElementIsEmpty); if ($this->_currentElementIsEmpty) { array_pop($this->_elementStack); - } + } } - + protected function _getPropertyResource(&$attrs) { $resource = $this->_removeAttribute($attrs, EF_RDF_NS.'resource'); $nodeId = $this->_removeAttribute($attrs, EF_RDF_NS.'nodeID'); - + if (null !== $resource) { return $this->_resolveUri($resource); } else if (null !== $nodeId) { return $this->_createBNode($nodeId); } else { return $this->_createBNode(); - } + } } - + protected function _processSubjectAttributes($subject, &$attrs) { - foreach ($attrs as $key=>$value) { + foreach ($attrs as $key=>$value) { $this->_addStatement($subject, $key, $value, 'literal', $this->_currentXmlLang, null); } } - + protected function _addStatement($s, $p, $o, $oType = null, $lang = null, $dType = null) - { + { if (!isset($this->_statements["$s"])) { $this->_statements["$s"] = array(); } if (!isset($this->_statements["$s"]["$p"])) { $this->_statements["$s"]["$p"] = array(); } - + if (null === $oType) { if (substr($o, 0, 2) === '_:') { $oType = 'bnode'; @@ -528,28 +512,28 @@ protected function _addStatement($s, $p, $o, $oType = null, $lang = null, $dType $oType = 'uri'; } } - + $objectArray = array( 'type' => $oType, 'value' => $o ); - + // If we have a language we use that language and datatype is string implicit. if ($oType === 'literal' && null !== $lang) { $objectArray['lang'] = $lang; } else if ($oType === 'literal' && null !== $dType) { $objectArray['datatype'] = $dType; } - + $this->_statements["$s"]["$p"][] = $objectArray; ++$this->_stmtCounter; - + if ($this->_parseToStore && $this->_stmtCounter >= 1000) { // Write the statements $this->_writeStatementsToStore(); } } - + protected function _writeStatementsToStore() { // Check whether model exists. @@ -558,45 +542,45 @@ protected function _writeStatementsToStore() if (!$store->isModelAvailable($this->_graphUri, $this->_useAc)) { throw new Exception('Model with uri ' . $this->_graphUri . ' not available.'); } - + if (count($this->_statements) > 0) { $store->addMultipleStatements($this->_graphUri, $this->_statements, $this->_useAc); $this->_statements = array(); $this->_stmtCounter = 0; } } - + protected function _handleReification($value) { $predicate = $this->_peekStack(0); - + if ($predicate->isReified()) { $subject = $this->_peekStack(1); $reifRes = $predicate->getReificationUri(); $this->_reifyStatement($reifRes, $subject->getResource(), $predicate->getUri(), $value); } } - + protected function _reifyStatement($reifNode, $s, $p, $o) { // TODO handle literals and bnodes the right way... - + $this->_addStatement($reifNode, EF_RDF_TYPE, EF_RDF_NS.'Statement'); $this->_addStatement($reifNode, EF_RDF_NS.'subject', $s); $this->_addStatement($reifNode, EF_RDF_NS.'predicate', $p); $this->_addStatement($reifNode, EF_RDF_NS.'object', $o); } - + protected function _getNodeResource(&$attrs) { $id = $this->_removeAttribute($attrs, EF_RDF_NS.'ID'); $about = $this->_removeAttribute($attrs, EF_RDF_NS.'about'); $nodeId = $this->_removeAttribute($attrs, EF_RDF_NS.'nodeID'); - + // We could throw an exception if more than one of the above attributes // are given, but we want to be as tolerant as possible, so we use the // first given. - + if (null !== $id) { return $this->_buildUriFromId($id); } else if (null !== $about) { @@ -608,7 +592,7 @@ protected function _getNodeResource(&$attrs) return $this->_createBNode(); } } - + protected function _removeAttribute(&$attrs, $name) { if (isset($attrs[$name])) { @@ -619,18 +603,18 @@ protected function _removeAttribute(&$attrs, $name) return null; } } - + protected function _buildUriFromId($id) { return $this->_resolveUri('#'.$id); } - + protected function _resolveUri($about) { if ($this->_checkSchemas($about)) { return $about; } - + // TODO Handle all relative URIs the right way... if (substr($about, 0, 1) === '#' || $about === '' || strpos($about, '/') === false) { // Relative URI... Resolve against the base URI. @@ -638,15 +622,15 @@ protected function _resolveUri($about) // prevent double hash (e.g. http://www.w3.org/TR/owl-guide/wine.rdf Issue 604) if ( substr($about,0,1) === '#' && substr($this->getBaseUri(),-1) === '#' ) { $about = substr($about,1); - } + } return $this->getBaseUri() . $about; } - } - + } + // Absolute URI... Return it. return $about; } - + protected function _checkSchemas($about) { $config = Erfurt_App::getInstance()->getConfig(); @@ -659,7 +643,7 @@ protected function _checkSchemas($about) return false; } } - + protected function _createBNode($id = null) { @@ -670,19 +654,19 @@ protected function _createBNode($id = null) if (!isset($this->_usedBnodeIds[$id])) { break; } - } + } } $this->_usedBnodeIds[$id] = true; return '_:'.$id; } - - + + protected function _throwException($msg) { throw new Erfurt_Syntax_RdfParserException($msg); } - + protected function _peekStack($distanceFromTop = 0) { $count = count($this->_elementStack); @@ -693,67 +677,52 @@ protected function _peekStack($distanceFromTop = 0) return null; } } - + private function _getXmlParserNamespacesOnly() { $xmlParser = xml_parser_create_ns(null, ''); - + xml_parser_set_option($xmlParser, XML_OPTION_CASE_FOLDING, 0); xml_parser_set_option($xmlParser, XML_OPTION_SKIP_WHITE, 1); - + xml_set_start_namespace_decl_handler($xmlParser, array($this, '_handleNamespaceDeclaration')); - + return $xmlParser; } - + private function _getXmlParser() { if (null === $this->_xmlParser) { $this->_xmlParser = xml_parser_create_ns(null, ''); - + // Disable case folding, for we need the uris. xml_parser_set_option($this->_xmlParser, XML_OPTION_CASE_FOLDING, 0); - xml_parser_set_option($this->_xmlParser, XML_OPTION_SKIP_WHITE, 1); - xml_set_default_handler($this->_xmlParser, array($this, '_handleDefault')); // Set the handler method for namespace definitions xml_set_start_namespace_decl_handler($this->_xmlParser, array($this, '_handleNamespaceDeclaration')); - - //$this->_setNamespaceDeclarationHandler('_handleNamespaceDeclaration'); - - //xml_set_end_namespace_decl_handler($xmlParser, array(&$this, '_handleNamespaceDeclaration')); - xml_set_character_data_handler($this->_xmlParser, array($this, '_characterData')); - - //xml_set_external_entity_ref_handler($this->_xmlParser, array($this, '_handleExternalEntityRef')); - - //xml_set_processing_instruction_handler($this->_xmlParser, array($this, '_handleProcessingInstruction')); - - //xml_set_unparsed_entity_decl_handler($this->_xmlParser, array($this, '_handleUnparsedEntityDecl')); - xml_set_element_handler( - $this->_xmlParser, + $this->_xmlParser, array($this, '_startElement'), array($this, '_endElement') ); } - + return $this->_xmlParser; } - + protected function _handleDefault($parser, $data) { // Handles comments - //var_dump($data); } - + protected function _handleNamespaceDeclaration($parser, $prefix, $uri) { $prefix = (string)$prefix; $uri = (string)$uri; - + if (!$this->_rdfElementParsed) { if ($prefix != '' && $uri != '') { $this->_namespaces[$uri] = $prefix;