Exemplo n.º 1
0
 /**
  * Récupère les cardinalités entre une classe et une propriété
  *
  * @param string uri_class 
  * @param string uri_property 
  * @return onto_restriction
  * @access public
  */
 public function get_restriction($uri_class, $uri_property)
 {
     $restriction = new onto_restriction();
     //recherche des exlusions !
     $query = "select ?distinct where {\n\t\t\t<" . $uri_property . "> pmb:distinctWith ?distinct\n\t\t}";
     if ($this->store->query($query)) {
         if ($this->store->num_rows()) {
             $results = $this->store->get_result();
             foreach ($results as $result) {
                 $restriction->set_new_distinct($this->get_property($uri_class, $result->distinct));
             }
         }
     } else {
         var_dump($this->store->get_errors());
     }
     $query = "select ?max ?min where {\n\t\t\t<" . $uri_class . "> rdf:type <http://www.w3.org/2002/07/owl#Class> .\n\t\t\t<" . $uri_class . "> rdfs:subClassOf ?restrict .\t\n\t\t\t?restrict rdf:type <http://www.w3.org/2002/07/owl#Restriction> .\n\t\t\t?restrict owl:onProperty <" . $uri_property . "> .\t\t\n\t\t\toptional {\n\t\t\t\t?restrict owl:maxCardinality ?max\n\t\t\t} .\n\t\t\toptional {\n\t\t\t\t?restrict owl:minCardinality ?min\n\t\t\t}\n\t\t}";
     if ($this->store->query($query)) {
         if ($this->store->num_rows()) {
             $results = $this->store->get_result();
             foreach ($results as $result) {
                 if ($result->min) {
                     $restriction->set_min($result->min);
                 }
                 if ($result->max) {
                     $restriction->set_max($result->max);
                 }
             }
         }
     } else {
         var_dump($this->store->get_errors());
     }
     return $restriction;
 }