public function getConceptsByTag($OntologyID = '1', $Tag, $userId = '1')
 {
     if (empty($Tag)) {
         return null;
     }
     $TagLabel = $Tag->getLabel();
     //Going curl!
     $url = $this->_mapping_endpoint . $OntologyID . '/mapping';
     $ch = curl_init($url);
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
     curl_setopt($ch, CURLOPT_POST, 1);
     $params = "tag={$TagLabel}&userId={$userId}&doGreedyMatch=false";
     //TODO set variable userid!!!!!
     curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
     $xmlanswer = curl_exec($ch);
     curl_close($ch);
     //No answer from tagonto
     if (empty($xmlanswer)) {
         return array();
     }
     //Answer gotten
     //TODO error handling!
     $doc = new DOMDocument();
     $doc->preserveWhiteSpace = false;
     //Loading the XML doc
     $doc->LoadXML($xmlanswer);
     $xpath = new DOMXPath($doc);
     //Extracting tag information
     $query = '//mapping';
     //TODO error handling here too
     $mappings = $xpath->query($query);
     //Setupping ontologyconcepts
     foreach ($mappings as $mapping) {
         $concept = new OntologyConcept();
         //Setting name and uri
         $concept->setName($mapping->getAttribute('concept'));
         $concept->setUri($mapping->getAttribute('conceptUri'));
         echo $CONCEPTS_TABLE;
         //Here we get the element ID
         $ONT = new Ontology($OntologyID);
         $concept->setId($ONT->getConceptIDFromURI($mapping->getAttribute('conceptUri')));
         //Preparing an array that will be merged to a given element mapping
         //TODO caching here?!
         $maparray[1] = $mapping->getAttribute('significance');
         $tagarray[$mapping->getAttribute('tag')] = $maparray;
         $concept->addAssociatedTag($tagarray);
         $Concepts[] = $concept;
     }
     return $Concepts;
 }
Beispiel #2
0
 /**
  * will return every concept in the ontology
  ***/
 function getAllConcepts()
 {
     foreach ($this->conceptsURItoID as $uri => $id) {
         $concept = new OntologyConcept();
         $concept->setId($id);
         $concept->setUri($uri);
         //removing the # and getting the concept name
         $concept->setName(str_replace('#', '', strrchr($uri, '#')));
         $concepts[] = $concept;
     }
     return $concepts;
 }