Пример #1
0
 public function atomSetConcept($conceptA, $atom, $conceptB)
 {
     Notifications::addLog("atomSetConcept({$conceptA}, {$atom}, {$conceptB})", 'DATABASE');
     try {
         // Check if conceptA and conceptB are in the same classification tree
         if (!Concept::inSameClassificationTree($conceptA, $conceptB)) {
             throw new Exception("Concepts {$conceptA} and {$conceptB} are not in the same classification tree", 500);
         }
         // Check if atom is part of conceptA
         if (!$this->atomExists($atom, $conceptA)) {
             throw new Exception("Atom {$atom} is not a member of {$conceptA}", 500);
         }
         // this function is under control of transaction check!
         if (!isset($this->transaction)) {
             $this->startTransaction();
         }
         // Get table info
         $conceptTableInfoB = Concept::getConceptTableInfo($conceptB);
         $conceptTableB = $conceptTableInfoB['table'];
         $conceptColsB = $conceptTableInfoB['cols'];
         // Concept are registered in multiple cols in case of specializations. We insert the new atom in every column.
         // Create query string: "<col1>" = '<atom>', "<col2>" = '<atom>', etc
         $atomEsc = $this->escape($atom);
         $queryString = "\"" . implode("\" = '{$atomEsc}', \"", $conceptColsB) . "\" = '{$atomEsc}'";
         $conceptTableInfoA = Concept::getConceptTableInfo($conceptA);
         $conceptTableA = $conceptTableInfoA['table'];
         $anyConceptColForA = current($conceptTableInfoA['cols']);
         // Perform update
         $this->Exe("UPDATE \"{$conceptTableB}\" SET {$queryString} WHERE \"{$anyConceptColForA}\" = '{$atomEsc}'");
         $this->addAffectedConcept($conceptB);
         // add concept to affected concepts. Needed for conjunct evaluation.
         Notifications::addLog("Atom '{$atom}' added as member to concept '{$conceptB}'", 'DATABASE');
     } catch (Exception $e) {
         throw $e;
     }
 }