Exemplo n.º 1
0
 public function atomClearConcept($concept, $atom)
 {
     Notifications::addLog("atomSetConcept({$conceptA}, {$atom}, {$conceptB})", 'DATABASE');
     try {
         // Check if concept is a specialization of another concept
         $conceptGeneralizations = Concept::getGeneralizations($concept);
         if (empty($conceptGeneralizations)) {
             throw new Exception("Concept {$concept} has no generalizations, atom can therefore not be removed as member from this set", 500);
         }
         // Check if atom is part of conceptA
         if (!$this->atomExists($atom, $concept)) {
             throw new Exception("Atom {$atom} is not a member of {$concept}", 500);
         }
         // this function is under control of transaction check!
         if (!isset($this->transaction)) {
             $this->startTransaction();
         }
         // Get col information for $concept and its specializations
         $cols = array();
         $conceptTableInfo = Concept::getConceptTableInfo($concept);
         $conceptTable = $conceptTableInfo['table'];
         $conceptCol = reset($conceptTableInfo['cols']);
         $cols[] = $conceptCol;
         foreach (Concept::getSpecializations($concept) as $specConcept) {
             $conceptTableInfo = Concept::getConceptTableInfo($specConcept);
             $cols[] = reset($conceptTableInfo['cols']);
         }
         // Create query string: "<col1>" = '<atom>', "<col2>" = '<atom>', etc
         $atomEsc = $this->escape($atom);
         $queryString = "\"" . implode("\" = NULL, \"", $cols) . "\" = NULL";
         $this->Exe("UPDATE \"{$conceptTable}\" SET {$queryString} WHERE \"{$conceptCol}\" = '{$atomEsc}'");
         $this->addAffectedConcept($concept);
         // add concept to affected concepts. Needed for conjunct evaluation.
         Notifications::addLog("Atom '{$atom}' removed as member from concept '{$concept}'", 'DATABASE');
     } catch (Exception $e) {
         throw $e;
     }
 }
Exemplo n.º 2
0
 public function hasGeneralization($conceptName)
 {
     return in_array($conceptName, Concept::getGeneralizations($this->name));
 }