public static function isCombination($relationName, $srcConcept, $tgtConcept) { $allRelations = Relation::getAllRelations(); foreach ($allRelations as $key => $relationInfo) { // Match relationName with relation name as specified in Ampersand script. // Includes support for specializations. if ($relationInfo['name'] == $relationName && ($relationInfo['srcConcept'] == $srcConcept || in_array($srcConcept, Concept::getSpecializations($relationInfo['srcConcept']))) && ($relationInfo['tgtConcept'] == $tgtConcept || in_array($tgtConcept, Concept::getSpecializations($relationInfo['tgtConcept'])))) { return $key; } // return fullRelationSignature // Match relationName with fullRelationSignature (format: 'rel_<relationName>_<srcConcept>_<tgtConcept>') if ($key == $relationName && ($relationInfo['srcConcept'] == $srcConcept || in_array($srcConcept, Concept::getSpecializations($relationInfo['srcConcept']))) && ($relationInfo['tgtConcept'] == $tgtConcept || in_array($tgtConcept, Concept::getSpecializations($relationInfo['tgtConcept'])))) { return $key; } // return fullRelationSignature } // If relation not found in $allRelations throw new Exception("Cannot find relation with signature '" . $relationName . "[" . $srcConcept . "*" . $tgtConcept . "]'", 500); }
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; } }
public static function getView($concept, $viewId = null) { global $allViews; // from Generics.php if (is_null($viewId)) { $viewId = Concept::getDefaultViewId($concept); } // Get defaultViewId // No view defined for this concept if (is_null($viewId)) { return null; // Get specified view } else { // Selecting all relevant views for this concept from $allViews in Generics.php foreach ((array) $allViews as $view) { if ($view['label'] == $viewId) { if (!($concept == $view['concept'] || in_array($concept, Concept::getSpecializations($view['concept'])))) { throw new Exception("View '{$viewId}' is not for concept '{$concept}'"); } return $view; } } } // Otherwise throw exception throw new Exception("View '{$viewId}' is not defined"); }
public function getInterfacesToReadConcept($concept) { $interfaces = array(); foreach ($this->accessibleInterfaces as $interface) { if ($interface->srcConcept == $concept || in_array($concept, Concept::getSpecializations($interface->srcConcept)) && $interface->crudR) { $interfaces[] = $interface; } } return $interfaces; }
private function getInterfacesForConcept($concept) { $interfaces = array(); foreach ($this->getSessionInterfaces() as $interface) { if ($interface->srcConcept == $concept || in_array($concept, Concept::getSpecializations($interface->srcConcept))) { $interfaces[] = $interface; } } return $interfaces; }