예제 #1
0
 /**
  * Helper method to group changes for $changeUri of a given type by namespaced predicate
  * @param \Tripod\ChangeSet $cs
  * @param array $changes
  * @return array
  * @throws \Tripod\Exceptions\Exception
  */
 private function getChangesGroupedByNsPredicate(\Tripod\ChangeSet $cs, $changeUri, $changePredicate)
 {
     $changes = $cs->get_subject_property_values($changeUri, $changePredicate);
     $changesGroupedByNsPredicate = array();
     foreach ($changes as $c) {
         $predicate = $cs->get_first_resource($c["value"], $this->labeller->qname_to_uri("rdf:predicate"));
         $nsPredicate = $this->labeller->uri_to_qname($predicate);
         if (!array_key_exists($nsPredicate, $changesGroupedByNsPredicate)) {
             $changesGroupedByNsPredicate[$nsPredicate] = array();
         }
         $object = $cs->get_subject_property_values($c["value"], $this->labeller->qname_to_uri("rdf:object"));
         if (count($object) != 1) {
             $this->getLogger()->error("Expecting object array with exactly 1 element", $object);
             throw new \Tripod\Exceptions\Exception("Object of removal malformed");
         }
         $valueType = $object[0]['type'] == "uri" ? VALUE_URI : VALUE_LITERAL;
         $value = $valueType === VALUE_URI ? $this->labeller->uri_to_alias($object[0]["value"]) : $object[0]["value"];
         $changesGroupedByNsPredicate[$nsPredicate][] = array($valueType => $value);
     }
     return $changesGroupedByNsPredicate;
 }