major update

This commit is contained in:
Michael Becker 2024-05-28 16:22:42 -04:00
parent 338a99f41d
commit 1fd022c0c6
25 changed files with 888 additions and 209 deletions

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 8.6 KiB

View File

@ -1,5 +1,7 @@
<?php <?php
use Mocha\Core\OmsContext;
use Mocha\UI\Renderers\HTML\HTMLRenderer;
use Phast\System; use Phast\System;
require_once("mochacommon.inc.php"); require_once("mochacommon.inc.php");
@ -76,18 +78,6 @@ System::$BeforeLaunchEventHandler = function($path)
System::Redirect("~/" . System::$Configuration["Application.DefaultTenant"], true); System::Redirect("~/" . System::$Configuration["Application.DefaultTenant"], true);
return false; return false;
} }
if (count($path) == 1)
{
if ($path[0] != "invalid-url")
{
System::Redirect("~/" . $path[0] . "/d/home.htmld", true);
return false;
}
else
{
return true;
}
}
if ($path[0] == "madi") if ($path[0] == "madi")
{ {
@ -105,12 +95,23 @@ System::$BeforeLaunchEventHandler = function($path)
if ($currentTenant == null) if ($currentTenant == null)
{ {
System::Redirect("~/invalid-url", true); $ctx = new OmsContext();
$html = new HTMLRenderer($ctx, true);
$html->IncludeTopNavigationBar = false;
$html->renderBeginErrorPage("Tenant not found", "Tenant not found");
echo ("<p>The specified tenant does not exist or is not available.</p>");
echo ("<p>We apologize for the inconvenience. If you are a MochaPowered customer and require additional assistance please contact the Designated Support Contact within your organization. Otherwise, please check back later.</p>");
$html->renderEndErrorPage();
return false; return false;
} }
else else
{ {
$oms->setTenant($currentTenant); $oms->setTenant($currentTenant);
if (count($path) == 1)
{
System::Redirect("~/" . $path[0] . "/d/home.htmld", true);
return false;
}
} }
return true; return true;
}; };

View File

@ -4,7 +4,9 @@ use Mocha\Core\InstanceReference;
use Mocha\Core\KnownAttributeGuids; use Mocha\Core\KnownAttributeGuids;
use Mocha\Core\KnownInstanceGuids; use Mocha\Core\KnownInstanceGuids;
use Mocha\Core\KnownRelationshipGuids; use Mocha\Core\KnownRelationshipGuids;
use Mocha\Core\OmsContext;
use Mocha\Oms\MySQLDatabaseOms; use Mocha\Oms\MySQLDatabaseOms;
use Mocha\UI\Renderers\HTML\HTMLRenderer;
use Phast\System; use Phast\System;
function mocha_asset_get_physical_path($package, $version, $path) function mocha_asset_get_physical_path($package, $version, $path)
@ -28,9 +30,24 @@ function mocha_get_oms()
return $_SESSION["OMS"]; return $_SESSION["OMS"];
*/ */
global $oms; global $oms;
if ($oms === null) if ($oms === null)
{ {
$oms = new MySQLDatabaseOms(System::GetConfigurationValue("Database.ServerName"), System::GetConfigurationValue("Database.PortNumber"), System::GetConfigurationValue("Database.DatabaseName"), System::GetConfigurationValue("Database.UserName"), System::GetConfigurationValue("Database.Password")); try
{
$oms = new MySQLDatabaseOms(System::GetConfigurationValue("Database.ServerName"), System::GetConfigurationValue("Database.PortNumber"), System::GetConfigurationValue("Database.DatabaseName"), System::GetConfigurationValue("Database.UserName"), System::GetConfigurationValue("Database.Password"));
}
catch (\PDOException $ex)
{
$ctx = new OmsContext();
$html = new HTMLRenderer($ctx, true);
$html->IncludeTopNavigationBar = false;
$html->renderBeginErrorPage("Mocha is currrently unavailable", "We are experiencing a service interruption");
echo ("<p>Your service will be restored as quickly as possible.</p>");
echo ("<p>We apologize for the inconvenience. If you are a MochaPowered customer and require additional assistance please contact the Designated Support Contact within your organization. Otherwise, please check back later.</p>");
$html->renderEndErrorPage();
die();
}
} }
$oms->setCurrentUser(mocha_get_current_user()); $oms->setCurrentUser(mocha_get_current_user());
return $oms; return $oms;

View File

@ -15,6 +15,8 @@ class KnownAttributeGuids
const Order = "{49423f66-8837-430d-8cac-7892ebdcb1fe}"; const Order = "{49423f66-8837-430d-8cac-7892ebdcb1fe}";
const MethodType = "{47ae57a9-7723-48a8-80f2-dd410d929e14}"; const MethodType = "{47ae57a9-7723-48a8-80f2-dd410d929e14}";
const EvaluateWorkSet = "{62c28f9e-5ce8-4ce5-8a56-1e80f1af7f6a}";
const ClassName = "c7e8d78ecfac4dacae242ac67a0ba9d3"; const ClassName = "c7e8d78ecfac4dacae242ac67a0ba9d3";
const ThemeName = "{8cfc012c-52fd-4a66-8b2f-1b9b5e4af474}"; const ThemeName = "{8cfc012c-52fd-4a66-8b2f-1b9b5e4af474}";
@ -25,7 +27,7 @@ class KnownAttributeGuids
const TargetURL = "970F79A09EFE4E7D92869908C6F06A67"; const TargetURL = "970F79A09EFE4E7D92869908C6F06A67";
const UserName = "960FAF025C5940F791A720012A99D9ED"; const UserName = "{960faf02-5c59-40f7-91a7-20012a99d9ed}";
const PasswordHash = "F377FC294DF14AFB96434191F37A00A9"; const PasswordHash = "F377FC294DF14AFB96434191F37A00A9";
const PasswordSalt = "8C5A99BC40ED4FA2B23FF373C1F3F4BE"; const PasswordSalt = "8C5A99BC40ED4FA2B23FF373C1F3F4BE";

View File

@ -71,8 +71,12 @@ class KnownInstanceGuids
const WorkSet__RelatedInstance = "{d9634929-0bb4-482a-85cc-9c8f1251556f}"; const WorkSet__RelatedInstance = "{d9634929-0bb4-482a-85cc-9c8f1251556f}";
const WorkSet_ClassForMethod = "{d8eeff45-acbc-4031-8b09-bf9b8085c185}"; const WorkSet_ClassForMethod = "{d8eeff45-acbc-4031-8b09-bf9b8085c185}";
const WorkSet__TaskRelatedInstance = "{d3860252-491e-469e-939e-702d56d88063}"; const WorkSet__TaskRelatedInstance = "{d3860252-491e-469e-939e-702d56d88063}";
const WorkSet__ClassOfInstanceToCreate = "{1f1170ac-ee7e-405c-99bb-b922f3d598fa}";
const SystemAttributeRoutine_GetGlobalIdentifier = "{1a7ebec3-dc02-4c9b-a5df-0c72646453c9}"; const SystemAttributeRoutine_GetGlobalIdentifier = "{1a7ebec3-dc02-4c9b-a5df-0c72646453c9}";
const SystemAttributeRoutine_GetInstanceText = "{b024abd6-1f2b-495a-9da3-c9ce29fb0c2f}"; const SystemAttributeRoutine_GetInstanceText = "{b024abd6-1f2b-495a-9da3-c9ce29fb0c2f}";
const SystemInstanceSetRoutine_CreateInstance = "{f46135f6-e812-49e6-9755-d63eb6ef1305}";
const SystemInstanceSetRoutine_GetUserForUserNameParm = "{430f572d-d116-4b04-97b2-65a9e9230ce5}";
} }
?> ?>

View File

@ -227,7 +227,9 @@ class KnownRelationshipGuids
const Integration_ID_Usage__for__Integration_ID = "d8d981ec768640dab89f006c85042444"; const Integration_ID_Usage__for__Integration_ID = "d8d981ec768640dab89f006c85042444";
const Conditional_Select_from_Instance_Set_Method__has__Conditional_Select_from_Instance_Set_Case = "b6715132b4384073b81d3ecf19584b7d"; const Conditional_Select_from_Instance_Set_Method__has__Conditional_Select_from_Instance_Set_Case = "b6715132b4384073b81d3ecf19584b7d";
const Conditional_Select_from_Instance_Set_Case__for__Conditional_Select_from_Instance_Set_Method = "1c868a068fb7432d839b7a5a02a50eb6"; const Conditional_Select_from_Instance_Set_Case__invokes__Executable_returning_Instance_Set = "{8fde1baa-ce2e-4245-a775-bc4c66eac7b5}";
const Conditional_Select_from_Instance_Set_Method__returns__Work_Set = "{49396bd0-b5a9-4384-99f4-2126d80b3b66}";
const Condition_Group__has_true_condition__Executable_returning_Attribute = "d955da3f7ef443748b86167c73434f75"; const Condition_Group__has_true_condition__Executable_returning_Attribute = "d955da3f7ef443748b86167c73434f75";
const Executable_returning_Attribute__true_condition_for__Condition_Group = "1acdefd1e1b445bb99e1bf73dea71da5"; const Executable_returning_Attribute__true_condition_for__Condition_Group = "1acdefd1e1b445bb99e1bf73dea71da5";

View File

@ -38,49 +38,88 @@
} }
return $defaultValue; return $defaultValue;
} }
public function setWorkData(string|InstanceReference $parmId, $value) public function setWorkData(InstanceReference|string|InstanceKey|array $parm, $value)
{ {
/** /**
* @var \Mocha\Oms\MySQLDatabaseOms * @var \Mocha\Oms\MySQLDatabaseOms
*/ */
$oms = mocha_get_oms(); $oms = mocha_get_oms();
$key = $parmId; // "Work Data" are .. "smart" variables
if ($key instanceof InstanceReference) // They can be restricted to a set of "valid classes" (via `Work Data.has valid Class`)
// They could potentially also do a whole bunch of other validations if we want them to
$parm = $oms->normalizeInstanceReference($parm);
$key = $parm->GlobalIdentifier->__toString();
// When setting a Work Data, first check to make sure the passed-in value is appropriate
// for the given Work Data. If the Work Data is a Work Set, check to make sure the value
// is indeed an InstanceReference, and that its parent class is in the selection list of
// `Work Set.has valid Class` for the given Work Set.
$expectedDataType = "";
$actualDataType = "";
if (!$oms->validateWorkDataType($parm, $value, $expectedDataType, $actualDataType))
{ {
$key = $key->GlobalIdentifier->__toString(); $printBacktrace = false;
if ($value === null) trigger_error("invalid work data (expected: " . $expectedDataType . ", got: " . $actualDataType . " [ " . $value . " ] " . ") for attribute " . $parm->InstanceKey . " @ " . $parm->GlobalIdentifier);
if ($printBacktrace)
{ {
//echo ("[ set wd " . $parmId->InstanceKey->__toString() . " = null ]"); debug_print_backtrace();
} }
else }
// Now here's where we start fudging things... If the Work Data is a Work Set, and the
// value is a Class, AND the Work Set valid classes DOES NOT include `Class`, THEN we
// should *evaluate* the Class value *as a work set* and see if THAT value is of a class
// valid for the Work Set. This should only happen once. If we are satisfied, assign THAT
// value to the given Work Set and we're all good.
if ($oms->is_a($parm, KnownClassGuids::WorkSet))
{
$Valid_Classes_for_Work_Set = $oms->getRelatedInstances($parm, KnownRelationshipGuids::Work_Set__has_valid__Class);
if ($oms->is_a($value, KnownClassGuids::Clasz))
{ {
if (is_string($value)) if (!$oms->instanceSetContains($Valid_Classes_for_Work_Set, KnownClassGuids::Clasz))
{ {
//echo ("[ set wd " . $parmId->InstanceKey . " = STR'" . $value . "' ]"); $Evaluated_Value_for_Class = $this->getWorkData($value);
if ($Evaluated_Value_for_Class !== null)
{
$pclass = $oms->getParentClass($Evaluated_Value_for_Class);
if ($oms->instanceSetContains($Valid_Classes_for_Work_Set, $pclass))
{
$value = $Evaluated_Value_for_Class;
echo ("Work Set evaluated for class OK");
}
else
{
echo ("Evaluated value for Class not valid for Work Set ");
}
}
else
{
// echo ("Evaluated value for Class was null! ");
}
} }
else else
{ {
//echo ("[ set wd " . $parmId->InstanceKey . " = IK'" . $value->InstanceKey . "' ]"); echo ("Valid Classes for Work Set contains Class");
} }
} }
$expectedDataType = "";
$actualDataType = "";
if (!$oms->validateWorkDataType($parmId, $value, $expectedDataType, $actualDataType))
{
//echo("invalid work data (expected: " . $expectedDataType . ", got: " . $actualDataType . ") for attribute " . $parmId->InstanceKey . " @ " . $parmId->GlobalIdentifier);
}
} }
$this->workData[$key] = $value; $this->workData[$key] = $value;
} }
public function getWorkData(string|InstanceReference $parmId, $defaultValue = null) public function getWorkData(InstanceReference|string|InstanceKey|array $parmId, $defaultValue = null)
{ {
$key = $parmId; /**
if ($key instanceof InstanceReference) * @var \Mocha\Oms\MySQLDatabaseOms
{ */
$key = $key->GlobalIdentifier->__toString(); $oms = mocha_get_oms();
}
$parmId = $oms->normalizeInstanceReference($parmId);
$key = $parmId->GlobalIdentifier->__toString();
if (array_key_exists($key, $this->workData)) if (array_key_exists($key, $this->workData))
{ {
return $this->workData[$key]; return $this->workData[$key];

View File

@ -29,6 +29,8 @@
$this->MethodImplementations = null; $this->MethodImplementations = null;
} }
public abstract function getUserByUserName(string $username) : ?InstanceReference;
private function registerMethodImplementation(InstanceReference|string|InstanceKey $methodImplementationClass, MethodImplementation $implementation) private function registerMethodImplementation(InstanceReference|string|InstanceKey $methodImplementationClass, MethodImplementation $implementation)
{ {
$methodImplementationClass = $this->normalizeInstanceReference($methodImplementationClass); $methodImplementationClass = $this->normalizeInstanceReference($methodImplementationClass);
@ -39,6 +41,7 @@
{ {
$this->registerMethodImplementation(KnownClassGuids::BuildAttributeMethod, new \Mocha\Oop\MethodImplementations\BuildAttributeMethodImplementation()); $this->registerMethodImplementation(KnownClassGuids::BuildAttributeMethod, new \Mocha\Oop\MethodImplementations\BuildAttributeMethodImplementation());
$this->registerMethodImplementation(KnownClassGuids::ConditionalSelectAttributeMethod, new \Mocha\Oop\MethodImplementations\ConditionalSelectAttributeMethodImplementation()); $this->registerMethodImplementation(KnownClassGuids::ConditionalSelectAttributeMethod, new \Mocha\Oop\MethodImplementations\ConditionalSelectAttributeMethodImplementation());
$this->registerMethodImplementation(KnownClassGuids::ConditionalSelectFromInstanceSetMethod, new \Mocha\Oop\MethodImplementations\ConditionalSelectInstanceSetMethodImplementation());
$this->registerMethodImplementation(KnownClassGuids::EvaluateBooleanExpressionMethod, new \Mocha\Oop\MethodImplementations\EvaluateBooleanExpressionMethodImplementation()); $this->registerMethodImplementation(KnownClassGuids::EvaluateBooleanExpressionMethod, new \Mocha\Oop\MethodImplementations\EvaluateBooleanExpressionMethodImplementation());
$this->registerMethodImplementation(KnownClassGuids::GetAttributeBySystemRoutineMethod, new \Mocha\Oop\MethodImplementations\GetAttributeBySystemRoutineMethodImplementation()); $this->registerMethodImplementation(KnownClassGuids::GetAttributeBySystemRoutineMethod, new \Mocha\Oop\MethodImplementations\GetAttributeBySystemRoutineMethodImplementation());
$this->registerMethodImplementation(KnownClassGuids::GetAttributeMethod, new \Mocha\Oop\MethodImplementations\GetAttributeMethodImplementation()); $this->registerMethodImplementation(KnownClassGuids::GetAttributeMethod, new \Mocha\Oop\MethodImplementations\GetAttributeMethodImplementation());
@ -373,8 +376,9 @@
echo ($this->getInstanceKeysString($instanceReferences, $separator)); echo ($this->getInstanceKeysString($instanceReferences, $separator));
} }
public function instanceSetContains(array /*<InstanceReference>*/ $haystack, InstanceReference $needle) public function instanceSetContains(array /*<InstanceReference>*/ $haystack, InstanceReference|string|InstanceKey|UUID $needle)
{ {
$needle = $this->normalizeInstanceReference($needle);
foreach ($haystack as $v) foreach ($haystack as $v)
{ {
if ($v->DatabaseId == $needle->DatabaseId) if ($v->DatabaseId == $needle->DatabaseId)
@ -528,7 +532,7 @@
// loop through all valid classes and check them // loop through all valid classes and check them
foreach ($workDataHasValidClasses as $validClass) foreach ($workDataHasValidClasses as $validClass)
{ {
if ($this->is_a($instWorkData, $validClass)) if ($this->is_a($value, $validClass))
{ {
$expectedTypeName = $this->getAttributeValue($validClass, KnownAttributeGuids::Name); $expectedTypeName = $this->getAttributeValue($validClass, KnownAttributeGuids::Name);
// our work set declares a valid class, and it passes // our work set declares a valid class, and it passes
@ -536,7 +540,7 @@
} }
} }
// none of the valid classes pass validation for $instWorkData // none of the valid classes pass validation for $instWorkData
$actualTypeName = $this->getAttributeValue($this->getParentClass($instWorkData), KnownAttributeGuids::Name); $actualTypeName = $this->getAttributeValue($this->getParentClass($value), KnownAttributeGuids::Name);
$expectedTypeName = $this->getAttributeValue($validClass, KnownAttributeGuids::Name); $expectedTypeName = $this->getAttributeValue($validClass, KnownAttributeGuids::Name);
return false; return false;
} }
@ -544,6 +548,17 @@
// this work set doesn't care whether or not $instWorkData passes validation // this work set doesn't care whether or not $instWorkData passes validation
return true; return true;
} }
else if ($this->is_a($instWorkData, KnownClassGuids::Clasz))
{
// Work Data is a Class, so make sure the value is of that class
if (!$this->is_a($value, $instWorkData))
{
$actualTypeName = $this->getAttributeValue($this->getParentClass($value), KnownAttributeGuids::Name);
$expectedTypeName = $this->getAttributeValue($instWorkData, KnownAttributeGuids::Name);
return false;
}
return true;
}
// we are not a work set, so we can't validate anything // we are not a work set, so we can't validate anything
return true; return true;
@ -602,7 +617,11 @@
private function createHtmlLinkToInstanceReference($val) private function createHtmlLinkToInstanceReference($val)
{ {
return "<a href=\"" . System::ExpandRelativePath("~/d/inst/" . $val->InstanceKey . ".htmld") . "\">" . $val->InstanceKey->__toString() . "</a>"; if ($val === null)
{
return "";
}
return "<a href=\"" . System::ExpandRelativePath("~/d/inst/" . $val->InstanceKey . ".htmld") . "\">" . $val->InstanceKey . "</a>";
} }
public function getStackTraceWithLinks(array $arr) public function getStackTraceWithLinks(array $arr)
{ {
@ -634,7 +653,8 @@
$value = $this->execute($context, $inst); $value = $this->execute($context, $inst);
if ($value !== null) if ($value !== null)
{ {
return $context->getWorkData($value); $val = $context->getWorkData($value);
return $val;
} }
return null; return null;
} }
@ -672,7 +692,7 @@
{ {
$this->applyParameterAssignment($context, $parameterAssignment); $this->applyParameterAssignment($context, $parameterAssignment);
} }
/*
if (is_array(value: $parms)) if (is_array(value: $parms))
{ {
foreach ($parms as $gid => $value) foreach ($parms as $gid => $value)
@ -680,7 +700,7 @@
$context->setWorkData($gid, $value); $context->setWorkData($gid, $value);
} }
} }
*/
// echo ("MB stack: " . $methodInstance->InstanceKey . ":" . $methodBindingExecutesMethod->InstanceKey); // echo ("MB stack: " . $methodInstance->InstanceKey . ":" . $methodBindingExecutesMethod->InstanceKey);
$retval = $this->execute($context, $methodBindingExecutesMethod, $parms); $retval = $this->execute($context, $methodBindingExecutesMethod, $parms);
} }
@ -706,9 +726,10 @@
public function applyParameterAssignment(OmsContext $context, InstanceReference $parameterAssignment) public function applyParameterAssignment(OmsContext $context, InstanceReference $parameterAssignment)
{ {
$evaluateWorkData = $this->getAttributeValue($parameterAssignment, KnownAttributeGuids::EvaluateWorkSet, false);
$assignsFromWorkData = $this->getRelatedInstance($parameterAssignment, KnownRelationshipGuids::Parameter_Assignment__assigns_from__Executable_returning_Work_Data); $assignsFromWorkData = $this->getRelatedInstance($parameterAssignment, KnownRelationshipGuids::Parameter_Assignment__assigns_from__Executable_returning_Work_Data);
$assignsToParm = $this->getRelatedInstance($parameterAssignment, KnownRelationshipGuids::Parameter_Assignment__assigns_to__Work_Data); $assignsToParm = $this->getRelatedInstance($parameterAssignment, KnownRelationshipGuids::Parameter_Assignment__assigns_to__Work_Data);
if ($assignsFromWorkData !== null && $assignsToParm !== null) if ($assignsFromWorkData !== null && $assignsToParm !== null)
{ {
$workData = $this->execute($context, $assignsFromWorkData); $workData = $this->execute($context, $assignsFromWorkData);
@ -724,12 +745,14 @@
// !! HACK !! // !! HACK !!
$workData = $workDataValue; $workData = $workDataValue;
} }
//echo ("update with " . $assignsToParm->InstanceKey . " = " . $workDataValue); //echo ("update with " . $assignsToParm->InstanceKey . " = " . $workDataValue);
$context->setWorkData($assignsToParm, $workData); $context->setWorkData($assignsToParm, $workData);
} }
else else
{ {
//echo ("setting null on " . $assignsToParm->InstanceKey); // echo ("setting null on " . $assignsToParm->InstanceKey);
$context->setWorkData($assignsToParm, $assignsFromWorkData);
} }
} }
} }
@ -770,6 +793,23 @@
{ {
echo ("[" . $this->createHtmlLinkToInstanceReference($value) . "]"); echo ("[" . $this->createHtmlLinkToInstanceReference($value) . "]");
} }
else if (is_array($value))
{
echo("[ ");
foreach ($value as $val)
{
if ($val instanceof InstanceReference)
{
echo ("[" . $this->createHtmlLinkToInstanceReference($value) . "]");
}
else
{
echo ("'" . $val . "'");
}
echo (", ");
}
echo (" ]");
}
else else
{ {
echo ("'" . $value . "'"); echo ("'" . $value . "'");
@ -812,9 +852,8 @@
return false; return false;
} }
private function __is_a_impl(InstanceReference $inst, InstanceReference|string|InstanceKey $what, int $reentrant_counter) private function __is_a_impl(InstanceReference $inst, InstanceReference $what, int $reentrant_counter)
{ {
$what = $this->normalizeInstanceReference($what);
if ($reentrant_counter > 10) if ($reentrant_counter > 10)
{ {
if ($reentrant_counter == 11) if ($reentrant_counter == 11)
@ -851,8 +890,19 @@
return false; return false;
} }
public function is_a(InstanceReference $inst, InstanceReference|string|InstanceKey $what) public function is_a(InstanceReference|string|InstanceKey|array|null $inst, InstanceReference|string|InstanceKey $what)
{ {
if ($inst === null)
{
return false;
}
if (is_array($inst))
{
return false;
}
$inst = $this->normalizeInstanceReference($inst);
$what = $this->normalizeInstanceReference($what);
return $this->__is_a_impl($inst, $what, 0); return $this->__is_a_impl($inst, $what, 0);
} }

View File

@ -0,0 +1,55 @@
<?php
namespace Mocha\Oop\MethodImplementations;
use Mocha\Core\InstanceReference;
use Mocha\Core\KnownAttributeGuids;
use Mocha\Core\KnownInstanceGuids;
use Mocha\Core\KnownRelationshipGuids;
use Mocha\Core\OmsContext;
use Mocha\Oms\Oms;
use Mocha\Oop\MethodImplementation;
class ConditionalSelectInstanceSetMethodImplementation extends MethodImplementation
{
protected function executeInternal(Oms $oms, OmsContext $context, InstanceReference $method, ?array $parms)
{
echo ("<br /> Conditional Select Instance Set <br />");
echo ("<br />The work data is: <br />");
$oms->printWorkData($context->workData);
echo ("<br /><br />");
$retval = null;
$returnsWorkSet = $oms->getRelatedInstance($method, KnownRelationshipGuids::Conditional_Select_from_Instance_Set_Method__returns__Work_Set);
$cases = $oms->getRelatedInstances($method, KnownRelationshipGuids::Conditional_Select_from_Instance_Set_Method__has__Conditional_Select_from_Instance_Set_Case);
foreach ($cases as $case)
{
$trueConditions = $oms->getRelatedInstances($case, KnownRelationshipGuids::Condition_Group__has_true_condition__Executable_returning_Attribute);
$falseConditions = $oms->getRelatedInstances($case, KnownRelationshipGuids::Condition_Group__has_false_condition__Executable_returning_Attribute);
if (!$oms->evaluateConditions($context, $trueConditions, $falseConditions))
{
continue;
}
$invokesExecutableReturningInstanceSet = $oms->getRelatedInstance($case, KnownRelationshipGuids::Conditional_Select_from_Instance_Set_Case__invokes__Executable_returning_Instance_Set);
if ($invokesExecutableReturningInstanceSet !== null)
{
$ws = $oms->execute($context, $invokesExecutableReturningInstanceSet);
echo ("<br /><br />setting work data " . $returnsWorkSet . " = " . $ws . " [ from " . $invokesExecutableReturningInstanceSet . " ]<br /><br />");
$context->setWorkData($returnsWorkSet, $ws);
$retval = $returnsWorkSet;
}
else
{
$context->setWorkData($returnsWorkSet, "SSC case with NULL instance set");
$retval = $returnsWorkSet;
}
}
if ($retval === null)
{
$context->setWorkData($returnsWorkSet, "SSC returned no case");
$retval = $returnsWorkSet;
}
return $retval;
}
}
?>

View File

@ -22,23 +22,65 @@
$booleanOperator = $oms->getRelatedInstance($method, KnownRelationshipGuids::IDR_Evaluate_Boolean_Expression_Method__uses__Boolean_Operator); $booleanOperator = $oms->getRelatedInstance($method, KnownRelationshipGuids::IDR_Evaluate_Boolean_Expression_Method__uses__Boolean_Operator);
$targetInstanceRef = $oms->getRelatedInstance($method, KnownRelationshipGuids::Evaluate_Boolean_Expression_Method__has_target__Executable_returning_Work_Data); $targetInstanceRef = $oms->getRelatedInstance($method, KnownRelationshipGuids::Evaluate_Boolean_Expression_Method__has_target__Executable_returning_Work_Data);
$sourceInstanceWD = $oms->execute($context, $sourceInstanceRef); $sourceInstance = null;
$sourceInstance = $sourceInstanceWD; if ($oms->is_a($sourceInstanceRef, KnownClassGuids::WorkSet))
if ($oms->is_a($sourceInstanceWD, KnownClassGuids::WorkSet))
{ {
$sourceInstance = $context->getWorkData($sourceInstanceWD); $sourceInstance = $context->getWorkData($sourceInstanceRef);
}
else
{
$sourceInstanceWD = $oms->execute($context, $sourceInstanceRef);
$sourceInstance = $sourceInstanceWD;
if ($oms->is_a($sourceInstanceWD, KnownClassGuids::WorkSet))
{
$sourceInstance = $context->getWorkData($sourceInstanceWD);
}
} }
if ($sourceInstanceWD === null) if ($sourceInstance === null)
{ {
$oms->MetadataExceptions[] = new OmsMetadataException("Evaluate Boolean Expression `source instance` is null", array $oms->MetadataExceptions[] = new OmsMetadataException("Evaluate Boolean Expression `source instance` is null", array
( (
"Source Instance Method Binding" => $sourceInstanceRef "Source Instance Method Binding" => $sourceInstanceRef
)); ));
// echo ("ERR: `source inst` [ from " . $sourceInstanceRef->InstanceKey . " ] null"); echo ("ERR: `source inst` [ from " . $sourceInstanceRef . " ] null");
return false; return false;
} }
if ($targetInstanceRef !== null)
if ($booleanOperator->GlobalIdentifier == UUID::parse(KnownInstanceGuids::RelationalOperator__Empty))
{
echo ("source instance : " . $sourceInstanceRef);
if ($oms->is_a($sourceInstanceRef, KnownClassGuids::WorkSet))
{
$si = $sourceInstance;
$sourceInstance = $context->getWorkData($sourceInstance);
echo ("WARN: work set hack used ( " . $si . " := " . $sourceInstance . " )");
}
echo (" compare : " . $sourceInstance);
echo (" is empty ? ");
if ($sourceInstance == null)
{
echo (" ! yes !");
$value = true;
}
else
{
echo (" ! no !");
$value = false;
}
}
else if ($booleanOperator->GlobalIdentifier == UUID::parse(KnownInstanceGuids::RelationalOperator__NotEmpty))
{
if ($sourceInstance !== null)
{
$value = true;
}
else
{
$value = false;
}
}
else if ($targetInstanceRef !== null)
{ {
$targetInstanceWD = $oms->execute($context, $targetInstanceRef, false); $targetInstanceWD = $oms->execute($context, $targetInstanceRef, false);
$targetInstance = $targetInstanceWD; $targetInstance = $targetInstanceWD;
@ -76,6 +118,10 @@
// echo ("EBE check: " . $source->Instance . " ?? " . $target); // echo ("EBE check: " . $source->Instance . " ?? " . $target);
$value = $source === $target; $value = $source === $target;
} }
else
{
echo("err: not implement bool operator " . $booleanOperator);
}
} }
else else
{ {
@ -83,10 +129,12 @@
} }
if ($returnsAttribute !== null) if ($returnsAttribute !== null)
{ {
echo ("setting attribute " . $returnsAttribute . " = " . ($value ? "true" : "false"));
$context->setWorkData($returnsAttribute, $value); $context->setWorkData($returnsAttribute, $value);
} }
else else
{ {
echo ("EBE returned null attribute");
$oms->MetadataExceptions[] = new OmsMetadataException("EBE : returned null attribute", array $oms->MetadataExceptions[] = new OmsMetadataException("EBE : returned null attribute", array
( (
"Method Instance" => $method "Method Instance" => $method

View File

@ -4,6 +4,7 @@
use Mocha\Core\InstanceReference; use Mocha\Core\InstanceReference;
use Mocha\Core\KnownAttributeGuids; use Mocha\Core\KnownAttributeGuids;
use Mocha\Core\KnownClassGuids; use Mocha\Core\KnownClassGuids;
use Mocha\Core\KnownInstanceGuids;
use Mocha\Core\KnownRelationshipGuids; use Mocha\Core\KnownRelationshipGuids;
use Mocha\Core\OmsContext; use Mocha\Core\OmsContext;
use Mocha\Oms\Oms; use Mocha\Oms\Oms;
@ -16,26 +17,40 @@
protected function executeInternal(Oms $oms, OmsContext $context, InstanceReference $method, ?array $parms) protected function executeInternal(Oms $oms, OmsContext $context, InstanceReference $method, ?array $parms)
{ {
$instSystemRoutine = $oms->getRelatedInstance($method, $oms->getInstanceByGlobalIdentifier(KnownRelationshipGuids::Get_Instance_Set_by_System_Routine_Method__uses__System_Instance_Set_Routine)); $instSystemRoutine = $oms->getRelatedInstance($method, $oms->getInstanceByGlobalIdentifier(KnownRelationshipGuids::Get_Instance_Set_by_System_Routine_Method__uses__System_Instance_Set_Routine));
echo ("exec sys routine " . $instSystemRoutine->GlobalIdentifier);
$returnsWorkData = $oms->getRelatedInstance($method, KnownRelationshipGuids::Get_Instance_Set_by_System_Routine_Method__returns__Instance_Set); $returnsWorkData = $oms->getRelatedInstance($method, KnownRelationshipGuids::Get_Instance_Set_by_System_Routine_Method__returns__Instance_Set);
$singular = false; $oms->getAttributeValue($instSystemRoutine, $oms->getInstanceByGlobalIdentifier(KnownAttributeGuids::Singular)); $singular = $oms->getAttributeValue($instSystemRoutine, $oms->getInstanceByGlobalIdentifier(KnownAttributeGuids::Singular));
$value = null;
if ($instSystemRoutine->GlobalIdentifier->__is_equal(UUID::parse("430f572dd1164b0497b265a9e9230ce5"))) if ($instSystemRoutine->GlobalIdentifier->__is_equal(UUID::parse(KnownInstanceGuids::SystemInstanceSetRoutine_CreateInstance)))
{
$clasz = $context->getWorkData(KnownInstanceGuids::WorkSet__ClassOfInstanceToCreate);
if (is_array($clasz))
{
$clasz = $clasz[0];
}
$inst = $oms->createInstanceOf($clasz);
$value = $inst;
echo ("create instance of " . $clasz . " = " . $inst . " , returned in " . $returnsWorkData);
}
else if ($instSystemRoutine->GlobalIdentifier->__is_equal(UUID::parse(KnownInstanceGuids::SystemInstanceSetRoutine_GetUserForUserNameParm)))
{ {
// get User for User Name parm // get User for User Name parm
// this System Attribute Routine has a required parm: `User Name [TX]` [4$11] // this System Attribute Routine has a required parm: `User Name [TX]` [4$11]
$userName = $context->getWorkData(KnownAttributeGuids::UserName); // $parms[KnownAttributeGuids::UserName]; $userName = $context->getWorkData(KnownAttributeGuids::UserName); // $parms[KnownAttributeGuids::UserName];
$singular = true; $value = $oms->getUserByUserName($userName);
if ($singular)
{
$value = $oms->getUserByUserName($userName);
}
else
{
$value = [ $oms->getUserByUserName($userName) ];
}
$context->setWorkData($returnsWorkData, $value);
} }
if (is_array($value) && $singular)
{
$value = $value[0];
}
else if (!is_array($value) && !$singular)
{
$value = [ $value ];
}
$context->setWorkData($returnsWorkData, $value);
return $returnsWorkData; return $returnsWorkData;
} }

View File

@ -53,6 +53,7 @@
$usesExecutableReturningAttribute = $oms->getRelatedInstance($instExecutableForPUMB, KnownRelationshipGuids::Assign_Attribute_Method__uses__Executable_returning_Attribute); $usesExecutableReturningAttribute = $oms->getRelatedInstance($instExecutableForPUMB, KnownRelationshipGuids::Assign_Attribute_Method__uses__Executable_returning_Attribute);
//$context->setWorkData($assignsAttribute->GlobalIdentifier->__toString(), $usesExecutableReturningAttribute); //$context->setWorkData($assignsAttribute->GlobalIdentifier->__toString(), $usesExecutableReturningAttribute);
echo ("for PRU inst: " . $instForPRU->InstanceKey);
echo ("assigning attribute '" . $assignsAttribute->GlobalIdentifier . "' the value from executable '" . $usesExecutableReturningAttribute->GlobalIdentifier . "'"); echo ("assigning attribute '" . $assignsAttribute->GlobalIdentifier . "' the value from executable '" . $usesExecutableReturningAttribute->GlobalIdentifier . "'");
$value = $context->getWorkData($usesExecutableReturningAttribute); $value = $context->getWorkData($usesExecutableReturningAttribute);

View File

@ -10,6 +10,7 @@
use Mocha\Core\KnownRelationshipGuids; use Mocha\Core\KnownRelationshipGuids;
use Mocha\Core\OmsContext; use Mocha\Core\OmsContext;
use Mocha\Oms\Oms;
use Mocha\Oms\MySQLDatabaseOms; use Mocha\Oms\MySQLDatabaseOms;
use Mocha\Oms\OmsMetadataException; use Mocha\Oms\OmsMetadataException;
@ -67,13 +68,16 @@
public $FailedValidationElements; public $FailedValidationElements;
public $Scripts;
public $StyleClasses; public $StyleClasses;
public bool $IsPostback; public bool $IsPostback;
public string $SubmitButtonText; public string $SubmitButtonText;
public bool $IncludeTopNavigationBar; public bool $IncludeTopNavigationBar;
public function __construct(OmsContext $context) public ?Oms $OMS;
public function __construct(OmsContext $context, bool $withoutOms = false)
{ {
$this->DebugMode = false; $this->DebugMode = false;
$this->Context = $context; $this->Context = $context;
@ -81,12 +85,18 @@
$this->FailedValidations = []; $this->FailedValidations = [];
$this->FailedValidationElements = []; $this->FailedValidationElements = [];
$this->IsPostback = false; $this->IsPostback = false;
$this->Scripts = [];
$this->StyleClasses = []; $this->StyleClasses = [];
$this->SubmitButtonText = "OK"; // "Save Changes"; $this->SubmitButtonText = "OK"; // "Save Changes";
$this->IncludeTopNavigationBar = true; $this->IncludeTopNavigationBar = true;
$this->__renderingElement = null; $this->__renderingElement = null;
$this->__processingElement = null; $this->__processingElement = null;
$this->OMS = null;
if (!$withoutOms)
{
$this->OMS = mocha_get_oms();
}
$this->registerEditors(); $this->registerEditors();
} }
@ -95,7 +105,8 @@
/** /**
* @var MySQLDatabaseOms * @var MySQLDatabaseOms
*/ */
$oms = mocha_get_oms(); $oms = $this->OMS;
if ($oms == null) return;
$genericViewFunc = function($oms, $parentElementContents, $elementContent, $ecInst, $value) $genericViewFunc = function($oms, $parentElementContents, $elementContent, $ecInst, $value)
{ {
@ -208,6 +219,35 @@
} }
return $fullyQualifiedECID; return $fullyQualifiedECID;
} }
public function renderBeginContent()
{
echo ("<div class=\"uwt-page-content\">");
}
public function renderEndContent()
{
echo ("</div>");
}
public function renderBeginErrorPage(string $title, string $heading)
{
$this->renderBeginPage($title);
$this->renderBeginContent();
echo ("<div style=\"text-align: center; background-color: #fff; border: 1px solid #e7eaec; padding: 32px; width: 600px; margin-left: auto; margin-right: auto; margin-top: 64px;\">");
echo ("<img style=\"display: block; width: 256px; margin: 32px; margin-left: auto; margin-right: auto;\" src=\"/images/logo-error.svg\" alt=\"Error\" />");
echo ("<h1>" . $heading . "</h1>");
}
public function renderEndErrorPage()
{
echo ("</div>");
$this->renderSystemFooter();
$this->renderEndContent();
$this->renderEndPage();
}
public function renderSystemFooter()
{
echo ("<div style=\"font-size: 9pt; color: #aaa; margin: 64px; text-align: center;\">Powered by Mocha<br />&copy; 2024 MBS Business Solutions</div>");
}
public function renderPageHeader(InstanceReference|string $title, InstanceReference|string|null $subtitle) public function renderPageHeader(InstanceReference|string $title, InstanceReference|string|null $subtitle)
{ {
@ -297,9 +337,6 @@
echo ("<input type=\"hidden\" name=\"target_inst_id\" value=\"" . $this->TargetInstance->InstanceKey . "\" />"); echo ("<input type=\"hidden\" name=\"target_inst_id\" value=\"" . $this->TargetInstance->InstanceKey . "\" />");
$this->renderPageHeader($title, $this->TargetInstance); $this->renderPageHeader($title, $this->TargetInstance);
echo ("work data!");
print_r($this->Context->workData);
$this->renderBeginTag("div", [ ], [ "uwt-page-content" ]); $this->renderBeginTag("div", [ ], [ "uwt-page-content" ]);
$this->renderElement($parentElementContents, $usesElement, [ $oms->getInstanceByGlobalIdentifier(KnownInstanceGuids::DisplayOption__Singular), $oms->getInstanceByGlobalIdentifier(KnownInstanceGuids::DisplayOption__ShowSubelementsVertically) ]); $this->renderElement($parentElementContents, $usesElement, [ $oms->getInstanceByGlobalIdentifier(KnownInstanceGuids::DisplayOption__Singular), $oms->getInstanceByGlobalIdentifier(KnownInstanceGuids::DisplayOption__ShowSubelementsVertically) ]);
$this->renderEndTag("div"); $this->renderEndTag("div");
@ -677,7 +714,8 @@ EOF
} }
$subelementInstances = $this->getSubelementInstances($parentElementContent); $subelementInstances = $this->getSubelementInstances($parentElementContent);
$count = $_POST[$ecid_count]; $count = $_POST[$ecid_count];
echo ("check count : " . $count . " vs existing : " . count($subelementInstances));
if ($count != count($subelementInstances)) if ($count != count($subelementInstances))
{ {
echo ("WARN: count mismatch (got " . $count . "; expected " . count($subelementInstances) . ") - add / remove sub elements not implemented"); //die(); echo ("WARN: count mismatch (got " . $count . "; expected " . count($subelementInstances) . ") - add / remove sub elements not implemented"); //die();
@ -685,16 +723,12 @@ EOF
for ($i = 0; $i < $count; $i++) for ($i = 0; $i < $count; $i++)
{ {
$targetRelatedInstance = $subelementInstances[$i]; $targetRelatedInstance = null;
if ($i >= count($subelementInstances)) if ($i < count($subelementInstances))
{
// we are creating a new instance of the class of the subelement (element content #0)
echo ("creating instance of " . $classParent->InstanceKey);
$targetRelatedInstance = $oms->createInstanceOf($classParent);
}
else
{ {
$targetRelatedInstance = $subelementInstances[$i];
} }
echo ("target rel inst: " . $targetRelatedInstance->InstanceKey); echo ("target rel inst: " . $targetRelatedInstance->InstanceKey);
$this->updateWorkDataWithElementContents($parentElementContents, $element, false, $i); $this->updateWorkDataWithElementContents($parentElementContents, $element, false, $i);
@ -812,11 +846,6 @@ EOF
foreach ($relatedECs as $relatedEC) foreach ($relatedECs as $relatedEC)
{ {
$fullyQualifiedECID = $this->getElementContentId($parentElementContents, $relatedEC); $fullyQualifiedECID = $this->getElementContentId($parentElementContents, $relatedEC);
if ($this->DebugMode)
{
echo ("FQECID : " . $fullyQualifiedECID . "<br />");
}
$value = null; $value = null;
if (isset($_POST["ec_" . $fullyQualifiedECID])) if (isset($_POST["ec_" . $fullyQualifiedECID]))
{ {
@ -836,11 +865,6 @@ EOF
$relatedECInst = $oms->getRelatedInstance($relatedEC, KnownRelationshipGuids::Element_Content__has__Instance); $relatedECInst = $oms->getRelatedInstance($relatedEC, KnownRelationshipGuids::Element_Content__has__Instance);
if ($this->DebugMode)
{
echo ("updating singular EC : target = " . $targetInstance->InstanceKey . "; ec = " . $fullyQualifiedECID . " = '" . $value . "'");
}
array_push($parentElementContents, $relatedEC); array_push($parentElementContents, $relatedEC);
$this->updateElementContentInstance($parentElementContents, $targetInstance, $relatedECInst, $value); $this->updateElementContentInstance($parentElementContents, $targetInstance, $relatedECInst, $value);
array_pop($parentElementContents); array_pop($parentElementContents);
@ -2005,8 +2029,11 @@ EOF
/** /**
* @var MySQLDatabaseOms * @var MySQLDatabaseOms
*/ */
$oms = mocha_get_oms(); $oms = $this->OMS;
$oms->MetadataExceptions = array(); if ($oms !== null)
{
$oms->MetadataExceptions = array();
}
$this->_stopwatch = new Stopwatch(); $this->_stopwatch = new Stopwatch();
$this->_stopwatch->start(); $this->_stopwatch->start();
@ -2048,8 +2075,29 @@ EOF
$this->renderBeginTag("script", array("type" => "text/javascript")); $this->renderBeginTag("script", array("type" => "text/javascript"));
echo("System.BasePath = '" . System::GetConfigurationValue("Application.BasePath") . "';"); echo("System.BasePath = '" . System::GetConfigurationValue("Application.BasePath") . "';");
echo("System.IsTenantedHostingEnabled = function() { return false; };"); echo("System.IsTenantedHostingEnabled = function() { return false; };");
echo("System.TenantName = '" . $oms->getTenantName() . "';");
$tenantName = null;
if ($oms !== null)
{
$tenantName = $oms->getTenantName();
}
echo("System.TenantName = '" . $tenantName . "';");
$this->renderEndTag("script"); $this->renderEndTag("script");
foreach ($this->Scripts as $script)
{
if ($script->FileName !== null)
{
$this->renderBeginTag("script", array("type" => $script->ContentType, "src" => $script->FileName));
$this->renderEndTag("script");
}
else if ($script->Content !== null)
{
$this->renderBeginTag("script", array("type" => $script->ContentType));
echo($script->Content);
$this->renderEndTag("script");
}
}
$this->renderEndTag("head"); $this->renderEndTag("head");
$bodyClasses = [ "uwt-header-visible", "uwt-header-inverse", "uwt-javascript-disabled" ]; $bodyClasses = [ "uwt-header-visible", "uwt-header-inverse", "uwt-javascript-disabled" ];
foreach ($this->StyleClasses as $className) foreach ($this->StyleClasses as $className)
@ -2151,72 +2199,73 @@ EOF
/** /**
* @var MySQLDatabaseOms * @var MySQLDatabaseOms
*/ */
$oms = mocha_get_oms(); $oms = $this->OMS;
echo("<div class=\"uwt-alert-container\">"); echo("<div class=\"uwt-alert-container\">");
if ($this->IsPostback) if ($oms !== null)
{ {
if (count($this->FailedValidations) > 0) if ($this->IsPostback)
{ {
foreach ($this->FailedValidations as $validation) if (count($this->FailedValidations) > 0)
{ {
$oms->MetadataExceptions[] = new OmsMetadataException foreach ($this->FailedValidations as $validation)
( {
$validation->Title . " : " . $validation->Message $oms->MetadataExceptions[] = new OmsMetadataException
); (
/* $validation->Title . " : " . $validation->Message
$ik = ""; );
echo("<div class=\"uwt-alert uwt-color-danger\" data-instance-id=\"" . $ik . "\">"); /*
echo("<div class=\"uwt-title\">" . $validation->Title . "</div>"); $ik = "";
echo("<div class=\"uwt-content\">" . str_replace("\n", "<br />", $validation->Message) . "</div>"); echo("<div class=\"uwt-alert uwt-color-danger\" data-instance-id=\"" . $ik . "\">");
echo("<div class=\"uwt-title\">" . $validation->Title . "</div>");
echo("<div class=\"uwt-content\">" . str_replace("\n", "<br />", $validation->Message) . "</div>");
echo("</div>");
*/
}
}
/*
else
{
echo("<div class=\"uwt-alert uwt-color-success\">");
echo("<div class=\"uwt-title\">Saved</div>");
echo("</div>"); echo("</div>");
*/ }
*/
}
$errors = [ ];
$warnings = [ ];
$infos = [ ];
foreach ($oms->MetadataExceptions as $exc)
{
if ($exc->Severity == OmsMetadataExceptionSeverity::Error)
{
$errors[] = $exc;
}
else if ($exc->Severity == OmsMetadataExceptionSeverity::Warning)
{
$warnings[] = $exc;
}
else //if ($exc->Severity == OmsMetadataExceptionSeverity::Information)
{
$infos[] = $exc;
} }
} }
/* if (count($errors) > 0)
else
{ {
echo("<div class=\"uwt-alert uwt-color-success\">"); $this->renderOmsMetadataExceptions($errors, "Errors", "error", "errors", "uwt-color-danger");
echo("<div class=\"uwt-title\">Saved</div>");
echo("</div>");
} }
*/ if (count($warnings) > 0)
}
$errors = [ ];
$warnings = [ ];
$infos = [ ];
foreach ($oms->MetadataExceptions as $exc)
{
if ($exc->Severity == OmsMetadataExceptionSeverity::Error)
{ {
$errors[] = $exc; $this->renderOmsMetadataExceptions($warnings, "Warnings", "warning", "warnings", "uwt-color-warning");
} }
else if ($exc->Severity == OmsMetadataExceptionSeverity::Warning) if (count($infos) > 0)
{ {
$warnings[] = $exc; $this->renderOmsMetadataExceptions($infos, "Messages", "message", "messages", "uwt-color-info");
}
else //if ($exc->Severity == OmsMetadataExceptionSeverity::Information)
{
$infos[] = $exc;
} }
} }
if (count($errors) > 0)
{
$this->renderOmsMetadataExceptions($errors, "Errors", "error", "errors", "uwt-color-danger");
}
if (count($warnings) > 0)
{
$this->renderOmsMetadataExceptions($warnings, "Warnings", "warning", "warnings", "uwt-color-warning");
}
if (count($infos) > 0)
{
$this->renderOmsMetadataExceptions($infos, "Messages", "message", "messages", "uwt-color-info");
}
echo("</div>"); echo("</div>");
$this->renderEndTag("body"); $this->renderEndTag("body");

View File

@ -1,6 +1,23 @@
<?php <?php
$oms = mocha_get_oms(); //$oms = mocha_get_oms();
$tenantName = $oms->getTenantName();
$path = $_SERVER["REQUEST_URI"];
$parts = explode("/", $path);
$tenantName = null;
if (count($parts) > 3 && $parts[1] == "madi" && $parts[2] == "authgwy")
{
$tenantName = $parts[3];
}
else if (count($parts) > 1)
{
$tenantName = $parts[1];
}
//if ($oms !== null)
{
//$tenantName = $oms->getTenantName();
}
$cdn_url = "static.alcehosting.net"; $cdn_url = "static.alcehosting.net";
$tenant_environment_text = "Implementation - " . $tenantName; $tenant_environment_text = "Implementation - " . $tenantName;
@ -9,7 +26,7 @@
$ret = $_SERVER["REQUEST_SCHEME"] . "://" . $_SERVER["SERVER_NAME"]; $ret = $_SERVER["REQUEST_SCHEME"] . "://" . $_SERVER["SERVER_NAME"];
if ($path != "") if ($path != "")
{ {
$ret .= "/" . $path;; $ret .= "/" . $path;
} }
return $ret; return $ret;
} }

View File

@ -13,6 +13,14 @@ ul.uwt-menu
&> li:not(.uwt-section) &> li:not(.uwt-section)
{ {
&:not(.uwt-selected) > a:not(:hover)
{
&> span.uwt-description
{
color: #666666;
}
}
&> a &> a
{ {
/* /*
@ -20,14 +28,9 @@ ul.uwt-menu
font-weight: 600; font-weight: 600;
*/ */
font-size: 12pt; font-size: 12pt;
font-weight: 300; // font-weight: 300;
padding: 0.309375rem 0.9375rem; padding: 0.309375rem 0.9375rem;
&:not(:hover) > span.uwt-description
{
color: #aaaaaa;
}
} }
&:not(.uwt-disabled) > a &:not(.uwt-disabled) > a
{ {

View File

@ -0,0 +1,34 @@
div.uwt-combobox
{
display: inline-block;
box-sizing: border-box;
position: relative;
&::after
{
content: "\f0d7";
font-weight: bold;
display: inline-block;
height: 24px;
width: 18px;
font-family: "Font Awesome 6 Pro";
position: absolute;
right: 0px;
top: 8px;
font-size: 9pt;
color: var(--uwt-color-gray);
pointer-events: none;
}
&> input
{
display: block;
width: 100%;
box-sizing: border-box;
padding-right: 24px;
&:not(:focus)
{
cursor: default;
}
}
}

View File

@ -4,6 +4,12 @@ ul.uwt-menu
padding-left: 0px; padding-left: 0px;
margin: 0px; margin: 0px;
user-select: none; user-select: none;
&.uwt-popup
{
max-height: 200px;
overflow: scroll;
overflow-x: hidden;
}
&> li &> li
{ {
padding: .438rem 1.25rem; padding: .438rem 1.25rem;
@ -30,6 +36,10 @@ ul.uwt-menu
{ {
//font-weight: bold; //font-weight: bold;
} }
&.uwt-description
{
font-size: 0.8em;
}
} }
} }
&.uwt-menu-item-command &.uwt-menu-item-command
@ -90,17 +100,25 @@ ul.uwt-menu
padding: 4px; padding: 4px;
} }
} }
&.uwt-selected }
}
&> li:not(.uwt-section)
{
&.uwt-selected
{
&> a
{ {
&> a /*
&::before
{ {
&::before background-color: var(--uwt-color-accent);
{ border-color: var(--uwt-color-accent);
background-color: var(--uwt-color-accent); content: "\f00c";
border-color: var(--uwt-color-accent);
content: "\f00c";
}
} }
*/
background-color: var(--uwt-color-accent);
border-color: var(--uwt-color-accent);
color: #fff;
} }
} }
} }

View File

@ -8,6 +8,7 @@
@import "uwt-calendar.less"; @import "uwt-calendar.less";
@import "uwt-checkbox.less"; @import "uwt-checkbox.less";
@import "uwt-column.less"; @import "uwt-column.less";
@import "uwt-combobox.less";
@import "uwt-dialog.less"; @import "uwt-dialog.less";
@import "uwt-disclosure.less"; @import "uwt-disclosure.less";
@import "uwt-expand.less"; @import "uwt-expand.less";

View File

@ -50,6 +50,8 @@
$ext = "svg"; $ext = "svg";
} }
$path = "/var/mocha/uploads/" . $inst->GlobalIdentifier->__toStringFormat(false, null, null) . "." . $ext; $path = "/var/mocha/uploads/" . $inst->GlobalIdentifier->__toStringFormat(false, null, null) . "." . $ext;
//echo ("iid: " . $inst->GlobalIdentifier);
if (file_exists($path)) if (file_exists($path))
{ {
$fsz = filesize($path); $fsz = filesize($path);

View File

@ -8,8 +8,6 @@
<Content> <Content>
<wcx:Section PlaceholderID="aspcContent"> <wcx:Section PlaceholderID="aspcContent">
<div style="display: block;"> <div style="display: block;">
<h1><html:Literal id="taskTitle">Test Instance</html:Literal></h1>
<p>Instance ID: <html:Literal id="instId" /></p>
</div> </div>
</wcx:Section> </wcx:Section>
</Content> </Content>

View File

@ -9,6 +9,7 @@
use Mocha\Core\OmsContext; use Mocha\Core\OmsContext;
use Mocha\Oms\MySQLDatabaseOms; use Mocha\Oms\MySQLDatabaseOms;
use Mocha\UI\Controls\InstanceBrowser;
use Mocha\UI\Renderers\HTML\HTMLRenderer; use Mocha\UI\Renderers\HTML\HTMLRenderer;
use Phast\RenderingEventArgs; use Phast\RenderingEventArgs;
use Phast\WebPage; use Phast\WebPage;
@ -71,12 +72,15 @@
} }
else else
{ {
$ctx = new OmsContext();
$htmlRenderer = new HTMLRenderer($ctx);
$parentClass = $oms->getParentClass($inst); $parentClass = $oms->getParentClass($inst);
if ($castkey !== null) if ($castkey !== null)
{ {
$parentClass = $oms->getInstanceByKey($castkey); $parentClass = $oms->getInstanceByKey($castkey);
} }
$rel_Class__has_default__Task = $oms->getInstanceByGlobalIdentifier(KnownRelationshipGuids::Class__has_default__Task); $rel_Class__has_default__Task = $oms->getInstanceByGlobalIdentifier(KnownRelationshipGuids::Class__has_default__Task);
if ($rel_Class__has_default__Task !== null) if ($rel_Class__has_default__Task !== null)
{ {
@ -101,7 +105,59 @@
$taskRenderer->renderTask($defaultTask, $inst); $taskRenderer->renderTask($defaultTask, $inst);
exit(); exit();
} }
else
{
$htmlRenderer->renderBeginPage("View Instance [Hardcoded]");
$htmlRenderer->renderPageHeader("View Instance [Hardcoded]", $inst);
$htmlRenderer->renderBeginContent();
$htmlRenderer->renderBeginTag("div", [ ], [ "uwt-formview", "mcx-element" ]);
$htmlRenderer->renderBeginTag("div", [ ], [ "mcx-elementcontent", "uwt-formview-item" ]);
$htmlRenderer->renderBeginTag("div", [ ], [ "uwt-formview-item-label" ]);
$htmlRenderer->renderBeginTag("label",[ ], [ ]);
echo("Instance");
$htmlRenderer->renderEndTag("label");
$htmlRenderer->renderEndTag("div");
$htmlRenderer->renderBeginTag("div", [ ], [ "uwt-formview-item-content" ]);
$htmlRenderer->renderEndTag("div");
$adw = new InstanceBrowser();
$adw->SelectedInstances[] = $inst;
$adw->Render();
$htmlRenderer->renderEndTag("div");
$htmlRenderer->renderBeginTag("div", [ ], [ "mcx-elementcontent", "uwt-formview-item" ]);
$htmlRenderer->renderBeginTag("div", [ ], [ "uwt-formview-item-label" ]);
$htmlRenderer->renderBeginTag("label",[ ], [ ]);
echo("Parent Class");
$htmlRenderer->renderEndTag("label");
$htmlRenderer->renderEndTag("div");
$htmlRenderer->renderBeginTag("div", [ ], [ "uwt-formview-item-content" ]);
$htmlRenderer->renderEndTag("div");
$adw = new InstanceBrowser();
$adw->SelectedInstances[] = $parentClass;
$adw->Render();
$htmlRenderer->renderEndTag("div");
$htmlRenderer->renderEndTag("div");
$htmlRenderer->renderEndContent();
}
} }
$htmlRenderer->renderEndPage();
} }
} }

View File

@ -131,12 +131,9 @@
echo("`User@get User for User Name parm`: method not found ('" . KnownMethodBindingGuids::User__get__User_for_User_Name_parm . "')");die(); echo("`User@get User for User Name parm`: method not found ('" . KnownMethodBindingGuids::User__get__User_for_User_Name_parm . "')");die();
} }
$context = new OmsContext(); $instUser = $oms->execute($sender->Context, $mbUser__get__User_for_User_Name_parm);
$instUser = $oms->execute($context, $mbUser__get__User_for_User_Name_parm, true, array( KnownAttributeGuids::UserName => $userName )); $instUser = $sender->Context->getWorkData($instUser);
$instUser = $context->getWorkData($instUser);
echo ("user: " . $instUser->InstanceKey);
if ($instUser !== null) if ($instUser !== null)
{ {
$passwordSalt = $oms->getAttributeValue($instUser, $oms->getInstanceByGlobalIdentifier(KnownAttributeGuids::PasswordSalt)); $passwordSalt = $oms->getAttributeValue($instUser, $oms->getInstanceByGlobalIdentifier(KnownAttributeGuids::PasswordSalt));
@ -189,6 +186,7 @@
} }
$renderer->SubmitButtonText = "Log In"; $renderer->SubmitButtonText = "Log In";
$renderer->renderInitialElement($pageElement); $renderer->renderInitialElement($pageElement);
exit(); exit();
} }

View File

@ -213,9 +213,9 @@
$json["result"] = "success"; $json["result"] = "success";
$messages = array(); $messages = array();
foreach ($oms->Messages as $message) foreach ($oms->MetadataExceptions as $message)
{ {
$messages[] = array("title" => $message->Title, "content" => $message->Message, "severity" => $message->Severity); $messages[] = array("title" => $message->Message, "content" => $message->Message, "severity" => $message->Severity);
} }
$json["messages"] = $messages; $json["messages"] = $messages;

View File

@ -1,6 +1,6 @@
<Website> <Website>
<Pages> <Pages>
<Page MasterPageFileName="masterPages/Blank2.phpx" FileName="suv/suvinfo.html" CodeBehindClassName="Mocha\UI\Pages\SUVPage" /> <Page FileName="suv/suvinfo.html" CodeBehindClassName="Mocha\UI\Pages\SUVPage" />
<Page FileName="suv/phpinfo.html" CodeBehindClassName="Mocha\UI\Pages\SUVPage" /> <Page FileName="suv/phpinfo.html" CodeBehindClassName="Mocha\UI\Pages\SUVPage" />
</Pages> </Pages>
</Website> </Website>

View File

@ -2,52 +2,298 @@
namespace Mocha\UI\Pages; namespace Mocha\UI\Pages;
use Mocha\Core\OmsContext;
use Mocha\UI\Renderers\HTML\HTMLRenderer;
use Phast\CancelEventArgs;
use Phast\RenderingEventArgs; use Phast\RenderingEventArgs;
use Phast\System; use Phast\System;
use Phast\WebControls\TabContainer;
use Phast\WebControls\TabPage;
use Phast\WebControls\Window;
use Phast\WebPage; use Phast\WebPage;
use Phast\WebScript;
class SUVPage extends WebPage class SUVPage extends WebPage
{ {
protected function RenderContents() protected function OnPreRender(CancelEventArgs $e)
{ {
$e->Cancel = true;
$path = System::GetVirtualPath(); $path = System::GetVirtualPath();
$tenantName = null;
if ($path[1] == "phpinfo.html") if ($path[1] == "phpinfo.html")
{ {
phpinfo(); phpinfo();
return;
} }
else if ($path[1] == "suvinfo.html")
$ctx = new OmsContext();
$htmlRenderer = new HTMLRenderer($ctx, true);
$htmlRenderer->Scripts[] = WebScript::FromContent(<<<EOF
window.addEventListener("load", function()
{ {
?> var wndCreateTenant = document.getElementById("windowCreateTenant").NativeObject;
<h1>SUV Self Service</h1> wndCreateTenant.validate = function()
<h2>General</h2> {
<div class="uwt-panel"> var txtTenantName = document.getElementById("txtTenantName");
<div class="uwt-content"> var cboTenantType = document.getElementById("cboTenantType").NativeObject;
<table class="uwt-listview"> var retval = true;
<thead> if (txtTenantName.value == "")
<tr> {
<th>Property</th> System.ClassList.Add(txtTenantName, "uwt-required");
<th>Value</th> System.ClassList.Add(txtTenantName, "uwt-failed-validation");
</tr> retval = false;
</thead> }
<tbody> if (cboTenantType.SelectElement.value == "")
<tr> {
<td>Name</td> System.ClassList.Add(cboTenantType.InputElement, "uwt-required");
<td>suv</td> System.ClassList.Add(cboTenantType.InputElement, "uwt-failed-validation");
</tr> retval = false;
<tr> }
<td>Instance Id</td>
<td><?php echo($_SERVER["SERVERNAME"]); ?></td> if (!retval)
</tr> return retval;
</tbody>
</table> var cboTenantType = document.getElementById("cboTenantType");
<h3>Actions</h3> //alert("create tenant '" + txtTenantName.value + "' with type: " + cboTenantType.value + "!");
<button class="uwt-button uwt-color-primary">SUV Logs</button> return true;
</div> };
</div> wndCreateTenant.reset = function()
<?php {
var txtTenantName = document.getElementById("txtTenantName");
var cboTenantType = document.getElementById("cboTenantType").NativeObject;
System.ClassList.Remove(txtTenantName, "uwt-required");
System.ClassList.Remove(txtTenantName, "uwt-failed-validation");
System.ClassList.Remove(cboTenantType.InputElement, "uwt-required");
System.ClassList.Remove(cboTenantType.InputElement, "uwt-failed-validation");
};
var btnAddTenant = document.getElementById("btnAddTenant");
btnAddTenant.addEventListener("click", function(e)
{
var windowCreateTenant = document.getElementById("windowCreateTenant").NativeObject;
if (!windowCreateTenant.initialized)
{
var footer = windowCreateTenant.ParentElement.children[2];
var btnCancel = footer.children[0];
btnCancel.addEventListener("click", function(ee)
{
windowCreateTenant.Hide();
});
windowCreateTenant.initialized = true;
}
windowCreateTenant.reset();
windowCreateTenant.ShowDialog();
e.preventDefault();
e.stopPropagation();
return false;
});
var wndCreateTenant_btnSaveChanges = document.getElementById("wndCreateTenant_btnSaveChanges");
wndCreateTenant_btnSaveChanges.ni = wndCreateTenant;
wndCreateTenant_btnSaveChanges.addEventListener("click", function(e)
{
if (!this.ni.validate())
{
return;
}
});
});
EOF
, "text/javascript");
$htmlRenderer->renderBeginPage("SUV Self Service");
if ($path[1] == "suvinfo.html")
{
$htmlRenderer->renderPageHeader("SUV Self Service", "");
$htmlRenderer->renderBeginContent();
$windowCreateTenant = new Window();
$windowCreateTenant->ID = "windowCreateTenant";
$windowCreateTenant->Title = "Create Tenant";
$windowCreateTenant->Content = function()
{
?>
<div class="uwt-header">
<span class="uwt-title">Create Tenant</span>
</div>
<div class="uwt-content">
<div class="uwt-formview">
<div class="uwt-formview-item mcx-editable mcx-required">
<div class="uwt-formview-item-label"><label>Tenant Name</label></div>
<div class="uwt-formview-item-content"><input id="txtTenantName" type="text" value="" style="width: 256px;" /></div>
</div>
<div class="uwt-formview-item mcx-editable mcx-required">
<div class="uwt-formview-item-label"><label>Tenant Type</label></div>
<div class="uwt-formview-item-content">
<select id="cboTenantType">
<option data-description="The primary tenant for your organization.">Production</option>
<option data-description="The testing tenant for your organization. Automatically refreshes from Production weekly.">Sandbox</option>
<option data-description="Test out new platform functionality before it releases to production.">Sandbox Preview</option>
<option data-description="Additional testing tenants for developing custom application objects. Refreshes manually.">Implementation</option>
<option data-description="Quality Assurance Preview">QA Preview</option>
</select>
</div>
</div>
<div class="uwt-formview-item">
<div class="uwt-formview-item-label"><label>Purpose</label></div>
<div class="uwt-formview-item-content"><textarea style="width: 256px; height: 100px;"></textarea></div>
</div>
</div>
</div>
<div class="uwt-footer">
<a class="uwt-button" href="#">Cancel</a>
<a id="wndCreateTenant_btnSaveChanges" class="uwt-button uwt-color-primary" href="#">Save Changes</a>
</div>
<?php
};
$windowCreateTenant->Render();
$tabContainer = new TabContainer();
$page = new TabPage();
$page->Title = "General";
$page->Content = function()
{
?>
<table class="uwt-listview">
<thead>
<tr>
<th>Property</th>
<th>Value</th>
</tr>
</thead>
<tbody>
<tr>
<td>Name</td>
<td>suv</td>
</tr>
<tr>
<td>Instance Id</td>
<td><?php echo($_SERVER["SERVER_NAME"]); ?></td>
</tr>
<tr>
<td>Host Name</td>
<td><?php echo($_SERVER["SERVER_NAME"]); ?></td>
</tr>
<tr>
<td>Environment Version</td>
<td>58132</td>
</tr>
<tr>
<td>Confidence Level</td>
<td>prod</td>
</tr>
<tr>
<td>Status</td>
<td style="background-color: #ccffcc;">completed</td>
</tr>
</tbody>
</table>
<h3>Actions</h3>
<button class="uwt-button uwt-color-primary">SUV Logs</button>
<?php
};
$tabContainer->TabPages[] = $page;
$page = new TabPage();
$page->Title = "Tenants";
$page->Content = function()
{
?>
<div style="margin-bottom: 16px;">
<a id="btnAddTenant" class="uwt-button uwt-color-primary" href="#">Add Tenant</a>
<button class="uwt-button">Reset Tenants</button>
</div>
<table class="uwt-listview">
<thead>
<tr>
<th>Tenant Name</th>
<th>Status</th>
<th>Tenant Type</th>
<th>Data Center</th>
<th>Charge</th>
<th>Initial Term</th>
<th>Renewal Term</th>
<th>Tenant Start Date</th>
<th>Tenant Expiration Date</th>
<th>Purpose</th>
</tr>
</thead>
<tbody>
<?php
?>
<tr>
<td>super</td>
<td>Active</td>
<td>Development</td>
<td>Local</td>
<td>No Charge</td>
<td></td>
<td></td>
<td></td>
<td></td>
<td>Default Tenant</td>
</tr>
</tbody>
</table>
<?php
};
$tabContainer->TabPages[] = $page;
$page = new TabPage();
$page->Title = "Database";
$page->Content = function()
{
?>
<table class="uwt-listview">
<thead>
<tr>
<th>Property</th>
<th>Value</th>
</tr>
</thead>
<tbody>
<tr>
<td>Backend</td>
<td>mysql</td>
</tr>
<tr>
<td>User</td>
<td><?php echo(System::GetConfigurationValue("Database.UserName")); ?></td>
</tr>
<tr>
<td>Host</td>
<td><?php echo(System::GetConfigurationValue("Database.ServerName")); ?></td>
</tr>
<tr>
<td>Port</td>
<td><?php echo(System::GetConfigurationValue("Database.PortNumber")); ?></td>
</tr>
<tr>
<td>Status</td>
<td style="background-color: #ccffcc;">running</td>
</tr>
</tbody>
</table>
<?php
};
$tabContainer->TabPages[] = $page;
$tabContainer->Render();
} }
$htmlRenderer->renderEndContent();
$htmlRenderer->renderEndPage();
} }
} }