/** * Relation constructor * Private function to prevent outside instantiation of Relations. Use Relation::getRelation($relationSignature) * * @param array $relationDef */ public function __construct($relationDef) { $this->db = Database::singleton(); $this->logger = Logger::getLogger('FW'); $this->name = $relationDef['name']; $this->srcConcept = Concept::getConcept($relationDef['srcConceptId']); $this->tgtConcept = Concept::getConcept($relationDef['tgtConceptId']); $this->signature = $relationDef['signature']; $this->isUni = $relationDef['uni']; $this->isTot = $relationDef['tot']; $this->isInj = $relationDef['inj']; $this->isSur = $relationDef['sur']; $this->isProp = $relationDef['prop']; foreach ((array) $relationDef['affectedConjuncts'] as $conjId) { $conj = Conjunct::getConjunct($conjId); $this->affectedConjuncts[] = $conj; if ($conj->isSigConj()) { $this->affectedSigConjuncts[] = $conj; } if ($conj->isInvConj()) { $this->affectedInvConjuncts[] = $conj; } // if (!$conj->isSigConj() && !$conj->isInvConj()) $this->logger->warning("Affected conjunct '{$conj->id}' (specified for relation '{$this->__toString()}') is not part of an invariant or signal rule"); } // Specify mysql table information $this->mysqlTable = new RelationTable($relationDef['mysqlTable']['name'], $relationDef['mysqlTable']['tableOf']); $srcCol = $relationDef['mysqlTable']['srcCol']; $tgtCol = $relationDef['mysqlTable']['tgtCol']; $this->mysqlTable->addSrcCol(new DatabaseTableCol($srcCol['name'], $srcCol['null'], $srcCol['unique'])); $this->mysqlTable->addTgtCol(new DatabaseTableCol($tgtCol['name'], $tgtCol['null'], $tgtCol['unique'])); }
/** * Rule constructor * Private function to prevent outside instantiation. Use Rule::getRule($ruleName) * * @param array $ruleDef * @param boolean $type */ private function __construct($ruleDef, $type = null) { $this->logger = Logger::getLogger('FW'); $this->id = $ruleDef['name']; $this->origin = $ruleDef['origin']; $this->ruleAdl = $ruleDef['ruleAdl']; $this->srcConcept = Concept::getConcept($ruleDef['srcConceptId']); $this->tgtConcept = Concept::getConcept($ruleDef['tgtConceptId']); $this->meaning = $ruleDef['meaning']; $this->message = $ruleDef['message']; // Conjuncts foreach ($ruleDef['conjunctIds'] as $conjId) { $this->conjuncts[] = Conjunct::getConjunct($conjId); } $this->violationSegments = (array) $ruleDef['pairView']; switch ($type) { case 'sig': $this->isSignal = true; break; case 'inv': $this->isInvariant = true; break; case null: break; default: throw new Exception("Unknown/unsupported rule type. Allowed types are signal or invariant", 500); } }
$groupBy = $app->request->params('groupBy'); if (is_null($groupBy)) { $groupBy = 'conjuncts'; } $from = $app->request->params('from'); if (is_null($from)) { $from = 0; } $to = $app->request->params('to'); if (is_null($to)) { $to = 10; } $performanceArr = array(); // run all conjuncts (from - to) for ($i = $from; $i <= $to; $i++) { $conjunct = Conjunct::getConjunct('conj_' . $i); $startTimeStamp = microtime(true); // true means get as float instead of string $conjunct->evaluateConjunct(false); $endTimeStamp = microtime(true); $performanceArr[$conjunct->id] = array('id' => $conjunct->id, 'start' => round($startTimeStamp, 6), 'end' => round($endTimeStamp, 6), 'duration' => round($endTimeStamp - $startTimeStamp, 6), 'invariantRules' => implode(';', $conjunct->invRuleNames), 'signalRules' => implode(';', $conjunct->sigRuleNames)); } switch ($groupBy) { case 'conjuncts': $content = array_values($performanceArr); break; case 'rules': $ruleArr = array(); foreach (Rule::getAllRules() as $rule) { $duration = 0; $conjunctIds = array();
/** * Concept constructor * Private function to prevent outside instantiation of concepts. Use Concept::getConcept($conceptName) * * @param array $conceptDef */ private function __construct($conceptDef) { $this->database = Database::singleton(); $this->logger = Logger::getLogger('FW'); $this->def = $conceptDef; $this->name = $conceptDef['id']; $this->label = $conceptDef['label']; $this->type = $conceptDef['type']; $this->isObject = $this->type == "OBJECT" ? true : false; $this->affectedConjunctIds = (array) $conceptDef['affectedConjuncts']; foreach ($this->affectedConjunctIds as $conjId) { $conj = Conjunct::getConjunct($conjId); if ($conj->isSigConj()) { $this->affectedSigConjuncts[] = $conj; } if ($conj->isInvConj()) { $this->affectedInvConjuncts[] = $conj; } // if (!$conj->isSigConj() && !$conj->isInvConj()) $this->logger->warning("Affected conjunct '{$conj->id}' (specified for concept '[{$this->name}]') is not part of an invariant or signal rule"); } $this->specializations = (array) $conceptDef['specializations']; $this->generalizations = (array) $conceptDef['generalizations']; $this->interfaceIds = (array) $conceptDef['interfaces']; $this->largestConceptId = $conceptDef['largestConcept']; if (!is_null($conceptDef['defaultViewId'])) { $this->defaultView = View::getView($conceptDef['defaultViewId']); } $this->mysqlConceptTable = new DatabaseTable($conceptDef['conceptTable']['name']); foreach ($conceptDef['conceptTable']['cols'] as $colName) { $this->mysqlConceptTable->addCol(new DatabaseTableCol($colName)); } }