function select_value($pool_uri, $value, $pool_size)
    {
        if (!isset($this->bigfootMetabox)) {
            $bigfoot = new Store(STORE_URI);
            $this->bigfootMetabox = $bigfoot->get_metabox();
        }
        $changeset = '<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" 
    xmlns:cs="http://purl.org/vocab/changeset/schema#">
  <cs:ChangeSet>
    <cs:subjectOfChange rdf:resource="' . $pool_uri . '"/>
    <cs:creatorName>pool</cs:creatorName>
    <cs:changeReason>Selecting key</cs:changeReason>
    <cs:removal>
      <rdf:Statement>
        <rdf:subject rdf:resource="' . $pool_uri . '"/>
        <rdf:predicate rdf:resource="http://purl.org/vocab/value-pools/schema#value"/>
        <rdf:object>' . $value . '</rdf:object>
      </rdf:Statement>
    </cs:removal>
    <cs:addition>
      <rdf:Statement>
        <rdf:subject rdf:resource="' . $pool_uri . '"/>
        <rdf:predicate rdf:resource="http://purl.org/vocab/value-pools/schema#value"/>
        <rdf:object>' . ($pool_size + $value) . '</rdf:object>
      </rdf:Statement>
    </cs:addition>
  </cs:ChangeSet>
</rdf:RDF>';
        $response = $this->bigfootMetabox->apply_changeset_rdfxml($changeset);
        // echo "<pre>";
        // echo htmlspecialchars(print_r($response, true));
        // echo "</pre>";
        return true;
    }
 /**
  * Updates data in a platform store.
  *
  * Note that this method is in beta: it has been tested but there may be unusual corner cases that could result in data corruption
  *
  * Update the resource description for anything with a name of "shaggy" to have a name of "scooby":
  *
  * <code language="php">
  * $dt = new DataTable('http://api.talis.com/stores/mystore');
  * $dt->map('http://example.org/name', 'name');
  * $dt->set('name', 'scooby');
  * $dt->where('name', 'shaggy');
  * $response = $dt->update();
  * </code>
  *
  * The special variable "!_uri" can be used to refer to a specific resource.
  *
  * Update the resource description for http://example.com/thing to have a name of "scooby"
  *
  * <code language="php">
  * $dt = new DataTable('http://api.talis.com/stores/mystore');
  * $dt->map('http://example.org/name', 'name');
  * $dt->set('name', 'scooby');
  * $dt->where('_uri', 'http://example.com/thing');
  * $response = $dt->update();
  * </code>
  *
  * @return HttpResponse
  */
 function update()
 {
     $cs = $this->get_update_changeset();
     $changesets = $cs->get_subjects_of_type(CS_CHANGESET);
     $store = new Store($this->_store_uri, $this->_credentials, $this->_request_factory);
     $mb = $store->get_metabox();
     if (count($changesets) > 0 && count($cs->get_resource_triple_values($changesets[0], CS_REMOVAL)) > 0) {
         //printf("<p><strong>Posting a changeset</strong></p><pre>%s</pre>", $cs->to_turtle());
         return $mb->apply_changeset_rdfxml($cs->to_rdfxml());
     } else {
         $g = $this->get_insert_graph('');
         //printf("<p><strong>Submitting RDF</strong></p><pre>%s</pre>", $g->to_turtle());
         return $mb->submit_turtle($g->to_turtle());
     }
 }
예제 #3
0
 function test_get_metabox_includes_sets_credentials()
 {
     $credentials = new Credentials('scooby', 'shaggy');
     $store = new Store("http://example.org/store", $credentials);
     $this->assertEquals($credentials, $store->get_metabox()->credentials);
 }