private function _odbc_sparul_delete_language($graphURI, $languageProperties) { //*********************** //LANGUAGE //*********************** //delete all triples with the current subject //where the lang properties with string object //from other language version are given, which should stay $x = 0; Timer::start('LiveUpdateDestination::_odbc_sparul_delete_english_total'); foreach ($languageProperties as $one) { $u = new URI($one, false); $sparul = 'DELETE FROM <' . $graphURI . '> { ' . $this->subjectSPARULpattern . ' ' . $u->toSPARULPattern() . ' ?o } FROM <' . $graphURI . '> WHERE { ' . $this->subjectSPARULpattern . ' ' . $u->toSPARULPattern() . ' ?o . FILTER ( lang(?o) = \'en\'). }'; Timer::start('LiveUpdateDestination::_odbc_sparul_delete_english' . $x); if ($this->_odbc_sparul_execute($sparul)) { $this->counterDelete += 1; } Timer::stop('LiveUpdateDestination::_odbc_sparul_delete_english' . $x); $x++; } //end foreach $needed = Timer::stopAsString('LiveUpdateDestination::_odbc_sparul_delete_english_total'); $this->log(DEBUG, 'deleted language' . $needed); //TESTS>>>>>>>>>>>> if (Options::getOption('debug_run_tests')) { $this->log(INFO, 'no test for language currently'); } //TESTS<<<<<<<<<<< }
private function _odbc_clean_sparul_delete_subresources($log = '') { $subject = $this->uri->getURI(); $sparul = 'DELETE FROM <' . $this->graphURI . '> { ?subresource ?p ?o . } FROM <' . $this->graphURI . '> '; $where = 'WHERE { ' . $this->subjectSPARULpattern . ' ?somep ?subresource . ?subresource ?p ?o . FILTER (?subresource LIKE <' . $subject . '/%>) }'; $sparul .= $where; //TESTS>>>>>>>>>>>> if (Options::getOption('debug_run_tests')) { $countbefore = $this->_testwherepart($where); } Timer::start('LiveUpdateDestination::_odbc_clean_sparul_delete_subresources'); if ($this->_odbc_sparul_execute($sparul)) { $this->counterDelete += 1; } $needed = Timer::stopAsString('LiveUpdateDestination::_odbc_clean_sparul_delete_subresources'); $this->log(DEBUG, 'deleted subresources, needed ' . $needed); //TESTS>>>>>>>>>>>> if (Options::getOption('debug_run_tests')) { sleep(TEST_DELAY); $this->log(INFO, "delaying: " . TEST_DELAY); $countafter = $this->_testwherepart($where); $this->log(INFO, 'TEST delete_subResources, before: ' . $countbefore . ' after: ' . $countafter . ' triples'); if ($countafter > 0 && $countbefore > 0) { $this->log(WARN, 'TEST FAILED, AFTER SHOULD BE 0'); $this->log(WARN, "Test: " . $this->_testwhereQuery($where)); $this->log(WARN, "Delete: " . $sparul); } else { $this->log(INFO, 'SUCCESS'); } } //TESTS<<<<<<<<<<<< }
public function insertIntoDB() { if (!$this->active) { return; } Timer::start('Hash::insertIntoDB'); $json = json_encode($this->newJSONObject); $sql = 'Insert Into ' . TABLENAME . ' (' . FIELD_OAIID . ', ' . FIELD_RESOURCE . ' , ' . FIELD_JSON_BLOB . ' ) Values ( ?, ? , ? ) '; $stmt = $this->odbc->prepare($sql, 'Hash::insertIntoDB'); $odbc_result = odbc_execute($stmt, array($this->oaiId, $this->subject, $json)); $needed = Timer::stopAsString('Hash::insertIntoDB'); if ($odbc_result == false) { $this->log(WARN, 'FAIL insert hashes for ' . count($this->newJSONObject) . ' extractors'); } else { $this->log(DEBUG, $this->subject . ' inserted hashes for ' . count($this->newJSONObject) . ' extractors ' . $needed); /* foreach(odbc_fetch_array($odbc_result) as $one){ $this->log(DEBUG,$one); } */ } }