}); // Output $output = new OutputCSV(); $output->addColumns(array_keys($content[0])); foreach ($content as $row) { $output->addRow($row); } $output->render('conj-performance-report.csv'); // print json_encode($content, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES); }); $app->get('/admin/report/relations', function () use($app) { if (Config::get('productionEnv')) { throw new Exception("Reports are not allowed in production environment", 403); } $content = array(); foreach (Relation::getAllRelations() as $relation) { $relArr = array(); $relArr['signature'] = $relation->signature; $relArr['constraints'] .= $relation->isUni ? "[UNI]" : ""; $relArr['constraints'] .= $relation->isTot ? "[TOT]" : ""; $relArr['constraints'] .= $relation->isInj ? "[INJ]" : ""; $relArr['constraints'] .= $relation->isSur ? "[SUR]" : ""; if (empty($relArr['constraints'])) { $relArr['constraints'] = "no constraints"; } $relArr['affectedConjuncts'] = array(); foreach ($relation->affectedConjuncts as $conjunct) { $relArr['affectedConjuncts'][$conjunct->id] = array(); foreach ($conjunct->invRuleNames as $ruleName) { $relArr['affectedConjuncts'][$conjunct->id]['invRules'][] = $ruleName; }
/** * Remove all occurrences of $atom in the database (all concept tables and all relation tables) * In tables where the atom may not be null, the entire row is removed. * TODO: If all relation fields in a wide table are null, the entire row could be deleted, but this doesn't happen now. As a result, relation queries may return some nulls, but these are filtered out anyway. * @param \Ampersand\Core\Atom $atom * @return void */ function deleteAtom($atom) { $this->logger->debug("deleteAtom({$atom->__toString()})"); // This function is under control of transaction check! if (!isset($this->transaction)) { $this->startTransaction(); } $concept = $atom->concept; // Delete atom from concept table $conceptTable = $concept->getConceptTableInfo(); $query = "DELETE FROM `{$conceptTable->name}` WHERE `{$conceptTable->getFirstCol()->name}` = '{$atom->idEsc}' LIMIT 1"; $this->Exe($query); // Check if query resulted in an affected row $this->checkForAffectedRows(); $this->addAffectedConcept($concept); // add concept to affected concepts. Needed for conjunct evaluation. // Delete atom from relation tables where atom is mentioned as src or tgt atom foreach (Relation::getAllRelations() as $relation) { $tableName = $relation->getMysqlTable()->name; $cols = array(); if ($relation->srcConcept->inSameClassificationTree($concept)) { $cols[] = $relation->getMysqlTable()->srcCol(); } if ($relation->tgtConcept->inSameClassificationTree($concept)) { $cols[] = $relation->getMysqlTable()->tgtCol(); } foreach ($cols as $col) { // If n-n table, remove row if (is_null($relation->getMysqlTable()->tableOf)) { $query = "DELETE FROM `{$tableName}` WHERE `{$col->name}` = '{$atom->idEsc}'"; } elseif ($col->null) { $query = "UPDATE `{$tableName}` SET `{$col->name}` = NULL WHERE `{$col->name}` = '{$atom->idEsc}'"; } else { $query = "DELETE FROM `{$tableName}` WHERE `{$col->name}` = '{$atom->idEsc}'"; } $this->Exe($query); $this->addAffectedRelations($relation); } } $this->logger->debug("Atom '{$atom->__toString()}' (and all related links) deleted in database"); Hooks::callHooks('postDatabaseDeleteAtom', get_defined_vars()); }