function test_set_comment_add_rdfs_comment_triple() { $fpmap = new QueryProfile("http://example.org/store/queryprofiles/1"); $fpmap->set_comment('my qp is kewl'); $index = ARC2::getSimpleIndex($fpmap->get_triples(), true); $this->assertEquals("my qp is kewl", $index[$fpmap->uri]['http://www.w3.org/2000/01/rdf-schema#comment'][0]); }
function test_copy_to() { $qp = new QueryProfile("http://example.org/store1/config/queryprofiles/1"); $qp->from_rdfxml($this->_qp); $index = $qp->get_index(); $this->assertEquals(1, count($index[$qp->uri][BF_FIELDWEIGHT])); $qp2 = $qp->copy_to("http://example.org/store2/config/queryprofiles/1"); $index2 = $qp2->get_index(); $this->assertEquals(1, count($index2[$qp2->uri][RDF_TYPE])); $this->assertEquals("http://schemas.talis.com/2006/bigfoot/configuration#QueryProfile", $index2[$qp2->uri][RDF_TYPE][0]['value']); $this->assertEquals(1, count($index2[$qp2->uri][BF_FIELDWEIGHT])); $this->assertEquals("http://example.org/store2/config/queryprofiles/1#label", $index2[$qp2->uri][BF_FIELDWEIGHT][0]['value']); $this->assertEquals(1, count($index2[$index2[$qp2->uri][BF_FIELDWEIGHT][0]['value']][FRM_NAME])); $this->assertEquals("label", $index2[$index2[$qp2->uri][BF_FIELDWEIGHT][0]['value']][FRM_NAME][0]['value']); }
/** * Copies the field weights and other properties into new query profile. * Any URIs that are prefixed by the source query profile URI will be converted to * be prefixed with this query profile's URI * * For example * http://example.org/source/queryprofile/1#name * Would become * http://example.org/destination/queryprofile/1#name * * @return QueryProfile **/ function copy_to($new_uri) { $qp = new QueryProfile($new_uri, $this->credentials); $index = $this->get_index(); foreach ($index as $uri => $uri_info) { $subject_uri = preg_replace('/^' . preg_quote($this->uri, '/') . '(.*)$/', $qp->uri . '$1', $uri); foreach ($uri_info as $qp_property_uri => $qp_property_values) { foreach ($qp_property_values as $qp_property_info) { if ($qp_property_info['type'] == 'uri') { $value_uri = preg_replace('/^' . preg_quote($this->uri, '/') . '(.+)$/', $qp->uri . '$1', $qp_property_info['value']); $qp->add_resource_triple($subject_uri, $qp_property_uri, $value_uri); } elseif ($qp_property_info['type'] == 'bnode') { $qp->add_resource_triple($subject_uri, $qp_property_uri, $qp_property_info['value']); } else { $qp->add_literal_triple($subject_uri, $qp_property_uri, $qp_property_info['value']); } } } } return $qp; }
/** * Execute a stored procedure * * @param string $procedure name of the stored procedure * @param array $args arguments for the procedure * @return mixed whatever the procedure returns... * @experimental * @todo EVERYTHING... :) * Implemented in child classes. Most RDBMS use ANSI-92 syntax, * @todo Make sure it's MultiByte safe * ( CALL procname ( param1, param2, ... ), * so they return the call to here. Those that don't, handle the call individually */ public function execute_procedure($procedure, $args = array()) { /* Local scope caching */ $pdo = $this->pdo; $pdo_statement = $this->pdo_statement; if ($pdo_statement != null) { $pdo_statement->closeCursor(); } $query = 'CALL ' . $procedure . '( '; if (count($args) > 0) { $query .= str_repeat('?,', count($args)); // Add the placeholders $query = substr($query, 0, strlen($query) - 1); // Strip the last comma } $query .= ' )'; $query = $this->sql_t($query, $args); if ($pdo_statement = $pdo->prepare($query)) { /* If we are profiling, then time the query */ if ($this->keep_profile) { $profile = new QueryProfile($query); $profile->start(); } if (!$pdo_statement->execute($args)) { $this->add_error(array('query' => $query, 'error' => $pdo_statement->errorInfo())); return false; } if ($this->keep_profile) { $profile->stop(); $this->profiles[] = $profile; } return true; } else { $this->add_error(array('query' => $query, 'error' => $pdo_statement->errorInfo())); return false; } }