function ParseTermText($rel, $SrcConcept, $TermAtom, $TgtConcept, $parsetext) { // Logger::getLogger('EXECENGINE')->debug("ParseTermText($rel,$SrcConcept,$TermAtom,$TgtConcept,$parsetext)"); $itemizedText = $parsetext; while (strlen($parsetext)) { if ($parsetext[0] == '[') { // handle variable-names if (strpos($parsetext, ']') === false) { break; } // variable names must be properly terminated with a ']' character $chars = substr($parsetext, 1, strpos($parsetext, ']') - 1); // the name of the variable is within '[' and ']'. $parsetext = substr($parsetext, strpos($parsetext, ']') + 1); // set the remainder of the text to be parsed // Logger::getLogger('EXECENGINE')->debug("ParseTermText - create VAR item $chars"); InsPair($rel, $SrcConcept, $TermAtom, $TgtConcept, $chars); } else { // handle phrase-texts $charspos = strpos($parsetext, '['); if ($charspos) { $chars = substr($parsetext, 0, $charspos); } else { $chars = substr($parsetext, 0); } $parsetext = substr($parsetext, strlen($chars)); // set the remainder of the text to be parsed } } // Logger::getLogger('EXECENGINE')->debug("ParseTermText ------ done ------"); return; }
function Percentage($relation, $srcConcept, $srcAtom, $tgtConcept, $teller, $noemer) { if ($noemer == 0) { throw new Exception("Cannot divide by zero: {$teller}, {$noemer}"); } $tgtAtom = number_format(100 * $teller / $noemer, 0); InsPair($relation, $srcConcept, $srcAtom, $tgtConcept, $tgtAtom); return; }
function CompTariffedCharge($relation, $srcConcept, $srcAtom, $tgtConcept, $ctcNrOfDays, $ctcDailyAmount) { emitLog("CompTariffedCharge({$relation},{$srcConcept},{$srcAtom},{$tgtConcept},{$ctcNrOfDays},{$ctcDailyAmount})"); $result = intval($ctcNrOfDays) * intval($ctcDailyAmount); $result = strval($result); // Writing a '0' (integer) results in an empty string. InsPair($relation, $srcConcept, $srcAtom, $tgtConcept, $result); return; }
function sinComputeItemText($relation, $srcConcept, $srcAtom, $tgtConcept, $prefix, $itemSinValue, $postfix) { $tgtAtom = $itemSinValue; if ($prefix != '_NULL') { $tgtAtom = $prefix . $tgtAtom; } if ($postfix != '_NULL') { $tgtAtom = $tgtAtom . $postfix; } InsPair($relation, $srcConcept, $srcAtom, $tgtConcept, $tgtAtom); }
function Decrement($relation, $srcConcept, $srcAtom, $tgtConcept, $tgtAtom) { if ($tgtAtom === "") { $tgtAtom = 0; } if ($tgtAtom < 1) { throw new Exception("Decrement below zero: {$relation}, {$srcConcept}, {$srcAtom}, {$tgtConcept}, {$tgtAtom}"); } $tgtAtom = $tgtAtom - 1; InsPair($relation, $srcConcept, $srcAtom, $tgtConcept, $tgtAtom); return; }
function SetPeriod($relation, $DateConcept, $srcAtom, $Period) { emitLog("SetPeriod({$relation},{$DateConcept},{$srcAtom},{$Period})"); // Insert the pair ($srcAtom,$srcAtom + $period) into $relation if (($dt1 = strtotime($srcAtom)) === false) { ExecEngineSHOUTS("SetPeriod: Illegal date {$dt1} specified in srcAtom (3rd arg): {$srcAtom}"); } if (($dt3 = strtotime($srcAtom . $Period)) === false) { ExecEngineSHOUTS("SetPeriod: Illegal period {$dt3} specified as period (4th arg): {$Period}"); } $tgtAtom = date('d-m-Y', $dt3); global $execEngineWhispers; // Defined in 'pluginsettings.php' $execEngineWhispers = false; // ExecEngineWhispers("SetPeriod: InsPair($relation,$DateConcept,$srcAtom,$DateConcept,$tgtAtom)"); // Als '$tgtAtom' nog niet in de database bestaat als een instantie van $DateConcept, dan moet die nog wel worden toegevoegd: if (!isAtomInConcept($tgtAtom, $DateConcept)) { addAtomToConcept($tgtAtom, $DateConcept); } InsPair($relation, $DateConcept, $srcAtom, $DateConcept, $tgtAtom); return; }
function datimeGT($gtRelation, $DateConcept, $srcAtom, $tgtAtom) { Logger::getLogger('EXECENGINE')->debug("datimeGT({$gtRelation},{$DateConcept},{$srcAtom},{$tgtAtom})"); if (($dt1 = strtotime($srcAtom)) === false) { Logger::getUserLogger()->error("datimeGT: Illegal date {$dt1} specified in srcAtom (3rd arg): {$srcAtom}"); } if (($dt2 = strtotime($tgtAtom)) === false) { Logger::getUserLogger()->error("datimeGT: Illegal date {$dt2} specified in tgtAtom (4th arg): {$tgtAtom}"); } if ($dt1 == $dt2) { return; } if ($dt1 > $dt2) { InsPair($gtRelation, $DateConcept, $srcAtom, $DateConcept, $tgtAtom); } else { InsPair($gtRelation, $DateConcept, $tgtAtom, $DateConcept, $srcAtom); } }
function timeofdayGT($relation, $TimeofdayConcept, $srcAtom, $tgtAtom) { emitLog("timeofdayGT({$relation},{$TimeofdayConcept},{$srcAtom},{$tgtAtom})"); if (($dt1 = strtotime($srcAtom)) === false) { ExecEngineSHOUTS("timeofdayGT: Illegal timeofday {$dt1} specified in srcAtom (3rd arg): {$srcAtom}"); } if (($dt2 = strtotime($tgtAtom)) === false) { ExecEngineSHOUTS("timeofdayGT: Illegal timeofday {$dt2} specified in tgtAtom (4th arg): {$tgtAtom}"); } global $execEngineWhispers; // Defined in 'pluginsettings.php' $execEngineWhispers = false; if ($dt1 > $dt2) { InsPair($relation, $TimeofdayConcept, $srcAtom, $TimeofdayConcept, $tgtAtom); } return; }
function NewStruct() { // arglist: ($ConceptC[,$newAtom][,$relation,$srcConcept,$srcAtom,$tgtConcept,$tgtAtom]+) Notifications::addLog("Newstruct", 'ExecEngine'); try { $database = Database::singleton(); // We start with parsing the first one or two arguments $ConceptC = func_get_arg(0); // Name of concept for which atom is to be created $AtomC = Concept::createNewAtom($ConceptC); // Default marker for atom-to-be-created. if (func_num_args() % 5 == 2) { // Check if name of new atom is explicitly specified $AtomC = func_get_arg(1); // If so, we'll be using this to create the new atom } elseif (func_num_args() % 5 != 1) { // check for valid number of arguments throw new Exception("Wrong number of arguments supplied for function Newstruct(): " . func_num_args() . " arguments", 500); } // Then, we create a new atom of type $ConceptC $database->addAtomToConcept($AtomC, $ConceptC); // insert new atom in database // Next, for every relation that follows in the argument list, we create a link for ($i = func_num_args() % 5; $i < func_num_args(); $i = $i + 5) { $relation = func_get_arg($i); $srcConcept = func_get_arg($i + 1); $srcAtom = func_get_arg($i + 2); $tgtConcept = func_get_arg($i + 3); $tgtAtom = func_get_arg($i + 4); if ($srcAtom == "NULL" or $tgtAtom == "NULL") { throw new Exception("Use of keyword NULL is deprecated, use '_NEW'", 500); } // if either srcAtom or tgtAtom is not provided by the pairview function (i.e. value set to '_NULL'): skip the insPair if ($srcAtom == '_NULL' or $tgtAtom == '_NULL') { continue; } // populate relation r1, first checking for allowed syntax: if (!($srcAtom == '_NEW' or $tgtAtom == '_NEW')) { // Note: when populating a [PROP] relation, both atoms can be new // NewStruct: relation $relation requires that atom $srcAtom or $tgtAtom must be _NEW throw new Exception("NewStruct: relation {$relation} requires that atom {$srcAtom} or {$tgtAtom} must be _NEW", 500); } if (!($srcConcept == $ConceptC or $tgtConcept == $ConceptC)) { // NewStruct: relation $relation requires that concept $srcConcept or $tgtConcept must be $ConceptC throw new Exception("NewStruct: relation {$relation} requires that concept {$srcConcept} or {$tgtConcept} must be {$ConceptC}", 500); } if ($srcConcept == $ConceptC) { if ($srcAtom == '_NEW') { $srcAtom = $AtomC; /* The following code prevents ASY (and other homogeneous) relations to be populated, and is therefore declared obsolete. }else{ // While it strictly not necessary to err here, for most cases this helps to find errors in the ADL script // NewStruct: $srcAtom must be _NEW when $ConceptC is the concept (in relation $relation) throw new Exception("NewStruct: $srcAtom must be _NEW when $ConceptC is the concept (in relation $relation)", 500); */ } } if ($tgtConcept == $ConceptC) { if ($tgtAtom == '_NEW') { $tgtAtom = $AtomC; /* The following code prevents ASY (and other homogeneous) relations to be populated, and is therefore declared obsolete. }else{ // While it strictly not necessary to err here, for most cases this helps to find errors in the ADL script // NewStruct: $tgtAtom must be _NEW when $ConceptC is the concept (in relation $relation) throw new Exception("NewStruct: $tgtAtom must be _NEW when $ConceptC is the concept (in relation $relation)", 500); */ } } // Any logging is done by InsPair: InsPair($relation, $srcConcept, $srcAtom, $tgtConcept, $tgtAtom); } return "New structure '" . $AtomC . "' created"; } catch (Exception $e) { Notifications::addError('NewStruct: ' . $e->getMessage()); } }
function NewStruct() { // We start with parsing the first one or two arguments $ConceptC = func_get_arg(0); // Name of concept for which atom is to be created $AtomC = mkUniqueAtomByTime($ConceptC); // Default marker for atom-to-be-created. if (func_num_args() % 5 == 2) { $AtomC = func_get_arg(1); // If so, we'll be using this to create the new atom } elseif (func_num_args() % 5 != 1) { ExecEngineSHOUTS("NewStruct: Illegal number of arguments: " . func_num_args()); die; } // Then, we create a new atom of type $ConceptC ExecEngineWhispers("Creating a structure based on an atom '{$AtomC}' for concept '{$ConceptC}'"); addAtomToConcept($AtomC, $ConceptC); // insert new atom in database // Next, for every relation that follows in the argument list, we create a link for ($i = func_num_args() % 5; $i < func_num_args(); $i = $i + 5) { emitLog("i = {$i}"); $relation = func_get_arg($i); $srcConcept = func_get_arg($i + 1); $srcAtom = func_get_arg($i + 2); $tgtConcept = func_get_arg($i + 3); $tgtAtom = func_get_arg($i + 4); // populate relation r1, first checking for allowed syntax: if (!($srcAtom === 'NULL' or $tgtAtom === 'NULL')) { ExecEngineSHOUTS("NewStruct: relation {$relation} requires that atom {$srcAtom} or {$tgtAtom} must be NULL"); throw new Exception("Failure 1 in NewStruct in InsDelPairAtom.php"); } if (!($srcConcept == $ConceptC or $tgtConcept == $ConceptC)) { ExecEngineSHOUTS("NewStruct: relation {$relation} requires that concept {$srcConcept} or {$tgtConcept} must be {$ConceptC}"); throw new Exception("Failure 2 in NewStruct in InsDelPairAtom.php"); } if ($srcConcept == $ConceptC) { if ($srcAtom === 'NULL') { $srcAtom = $AtomC; } } if ($tgtConcept == $ConceptC) { if ($tgtAtom === 'NULL') { $tgtAtom = $AtomC; } } /* Als '$tgtAtom' nog niet in de database bestaat als een instantie van $tgtConcept, dan moet die nog wel worden toegevoegd; dat gebeurt bijvoorbeeld als '$tgtAtom' ontstaat uit de volgende ADL tekst: VIOLATION (TXT "{EX} NewStruct;Beslissing" ,TXT ";op;Beslissing;NULL;Verzoek;", SRC I ... ,TXT ";reden;Beslissing;NULL;Reden;'Voldoen aan artikel 2 lid 10 Wet aanpassing arbeidsduur'" ... -- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ deze tekst moet als een instantie van het concept 'Reden' worden toegevoegd (als-ie nog niet als een Reden bestaat). ) */ if (!isAtomInConcept($tgtAtom, $tgtConcept)) { addAtomToConcept($tgtAtom, $tgtConcept); } // Any logging is done by InsPair: InsPair($relation, $srcConcept, $srcAtom, $tgtConcept, $tgtAtom); } ExecEngineWhispers("Completed structure creation."); }
function datimeGT($gtRelation, $DateConcept, $srcAtom, $tgtAtom) { Notifications::addLog("datimeGT({$gtRelation},{$DateConcept},{$srcAtom},{$tgtAtom})", 'ExecEngine'); if (($dt1 = strtotime($srcAtom)) === false) { Notifications::addError("datimeGT: Illegal date {$dt1} specified in srcAtom (3rd arg): {$srcAtom}"); } if (($dt2 = strtotime($tgtAtom)) === false) { Notifications::addError("datimeGT: Illegal date {$dt2} specified in tgtAtom (4th arg): {$tgtAtom}"); } if ($dt1 == $dt2) { return; } if ($dt1 > $dt2) { InsPair($gtRelation, $DateConcept, $srcAtom, $DateConcept, $tgtAtom); } else { InsPair($gtRelation, $DateConcept, $tgtAtom, $DateConcept, $srcAtom); } return; }
function NewStruct() { // arglist: ($ConceptC[,$newAtom][,$relation,$srcConcept,$srcAtom,$tgtConcept,$tgtAtom]+) try { // We start with parsing the first one or two arguments $c = Concept::getConceptByLabel(func_get_arg(0)); // Concept for which atom is to be created $atom = $c->createNewAtom(); // Default marker for atom-to-be-created. Logger::getLogger('EXECENGINE')->info("Newstruct for concept '{$c}'"); // Check if name of new atom is explicitly specified if (func_num_args() % 5 == 2) { $atom = new Atom(func_get_arg(1), $c); } elseif (func_num_args() % 5 != 1) { throw new Exception("Wrong number of arguments supplied for function Newstruct(): " . func_num_args() . " arguments", 500); } // Add atom to concept $atom->addAtom(); // Next, for every relation that follows in the argument list, we create a link for ($i = func_num_args() % 5; $i < func_num_args(); $i = $i + 5) { $relation = func_get_arg($i); $srcConcept = Concept::getConceptByLabel(func_get_arg($i + 1)); $srcAtomId = func_get_arg($i + 2); $tgtConcept = Concept::getConceptByLabel(func_get_arg($i + 3)); $tgtAtomId = func_get_arg($i + 4); if ($srcAtomId == "NULL" or $tgtAtomId == "NULL") { throw new Exception("NewStruct: use of keyword NULL is deprecated, use '_NEW'", 500); } // NewStruct requires that atom $srcAtomId or $tgtAtomId must be _NEW // Note: when populating a [PROP] relation, both atoms can be new if (!($srcAtomId == '_NEW' or $tgtAtomId == '_NEW')) { throw new Exception("NewStruct: relation '{$relation}' requires that atom '{$srcAtomId}' or '{$tgtAtomId}' must be '_NEW'", 500); } // NewStruct requires that concept $srcConcept or $tgtConcept must be concept $c if (!in_array($srcConcept, $c->getGeneralizationsIncl()) && !in_array($tgtConcept, $c->getGeneralizationsIncl())) { throw new Exception("NewStruct: relation '{$relation}' requires that src or tgt concept must be '{$c}' (or any of its generalizations)", 500); } // Replace atom by the newstruct atom if _NEW is used if (in_array($srcConcept, $c->getGeneralizationsIncl()) && $srcAtomId == '_NEW') { $srcAtomId = $atom->id; } if (in_array($tgtConcept, $c->getGeneralizationsIncl()) && $tgtAtomId == '_NEW') { $tgtAtomId = $atom->id; } // Any logging is done by InsPair InsPair($relation, $srcConcept->name, $srcAtomId, $tgtConcept->name, $tgtAtomId); } Logger::getLogger('EXECENGINE')->debug("Newstruct: atom '{$atom}' created"); } catch (Exception $e) { Logger::getUserLogger()->error("NewStruct: {$e->getMessage()}"); } }