diff --git a/.gitignore b/.gitignore
index 8e1b336..b1d74b4 100644
--- a/.gitignore
+++ b/.gitignore
@@ -418,6 +418,10 @@ FodyWeavers.xsd
# Mocha CUP output directory
output
+# Mocha compiled files
+*.mcl
+*.mcx
+
# Backups (made by Notepad++)
*.bak
diff --git a/mocha-common b/mocha-common
index 94de4f0..47d874d 160000
--- a/mocha-common
+++ b/mocha-common
@@ -1 +1 @@
-Subproject commit 94de4f0a8e855543c0f1b0679aebf7caa2db56c9
+Subproject commit 47d874d77af1f29f7870ee6d885cbf6138b7651d
diff --git a/mocha-dotnet.sln b/mocha-dotnet.sln
index 1923f04..6437a58 100644
--- a/mocha-dotnet.sln
+++ b/mocha-dotnet.sln
@@ -55,6 +55,12 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Mocha.Oms.Server.Tests", "m
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Mocha.Testing", "mocha-dotnet\src\lib\Mocha.Testing\Mocha.Testing.csproj", "{5DE4A4AF-9B11-4844-B9C3-D93E17536267}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Mocha.Compilers.XmlPreprocessor", "mocha-dotnet\src\app\Mocha.Compilers.XmlPreprocessor\Mocha.Compilers.XmlPreprocessor.csproj", "{EA82944B-9720-4126-898F-3E3EDDAE44F4}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Mocha.Modeling", "mocha-dotnet\src\lib\Mocha.Modeling\Mocha.Modeling.csproj", "{E3DB95D7-9B56-4624-9961-50B0CDAFDC78}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Mocha.Modeling.Tests", "mocha-dotnet\tests\Mocha.Modeling.Tests\Mocha.Modeling.Tests.csproj", "{B2A51995-3440-45C5-BB84-FF49A26CF00B}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -113,6 +119,18 @@ Global
{5DE4A4AF-9B11-4844-B9C3-D93E17536267}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5DE4A4AF-9B11-4844-B9C3-D93E17536267}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5DE4A4AF-9B11-4844-B9C3-D93E17536267}.Release|Any CPU.Build.0 = Release|Any CPU
+ {EA82944B-9720-4126-898F-3E3EDDAE44F4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {EA82944B-9720-4126-898F-3E3EDDAE44F4}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {EA82944B-9720-4126-898F-3E3EDDAE44F4}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {EA82944B-9720-4126-898F-3E3EDDAE44F4}.Release|Any CPU.Build.0 = Release|Any CPU
+ {E3DB95D7-9B56-4624-9961-50B0CDAFDC78}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {E3DB95D7-9B56-4624-9961-50B0CDAFDC78}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {E3DB95D7-9B56-4624-9961-50B0CDAFDC78}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {E3DB95D7-9B56-4624-9961-50B0CDAFDC78}.Release|Any CPU.Build.0 = Release|Any CPU
+ {B2A51995-3440-45C5-BB84-FF49A26CF00B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {B2A51995-3440-45C5-BB84-FF49A26CF00B}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {B2A51995-3440-45C5-BB84-FF49A26CF00B}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {B2A51995-3440-45C5-BB84-FF49A26CF00B}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@@ -141,6 +159,9 @@ Global
{ADD7359E-0E3B-4435-B812-EC961C52DA2A} = {A2C401E9-FED4-43BA-A928-566239894CEE}
{271CBF6A-07E4-46EB-A418-513E9FD89E36} = {27C300F5-5172-4225-A6F7-3503B9007DD8}
{5DE4A4AF-9B11-4844-B9C3-D93E17536267} = {A2C401E9-FED4-43BA-A928-566239894CEE}
+ {EA82944B-9720-4126-898F-3E3EDDAE44F4} = {11486802-8136-4958-8B32-FC34630B0306}
+ {E3DB95D7-9B56-4624-9961-50B0CDAFDC78} = {A2C401E9-FED4-43BA-A928-566239894CEE}
+ {B2A51995-3440-45C5-BB84-FF49A26CF00B} = {27C300F5-5172-4225-A6F7-3503B9007DD8}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {D28A9CF8-0235-4F8F-865F-C460BDCAE16D}
diff --git a/mocha-dotnet/src/app/Mocha.Compilers.XmlPreprocessor/Mocha.Compilers.XmlPreprocessor.csproj b/mocha-dotnet/src/app/Mocha.Compilers.XmlPreprocessor/Mocha.Compilers.XmlPreprocessor.csproj
new file mode 100644
index 0000000..8e9683e
--- /dev/null
+++ b/mocha-dotnet/src/app/Mocha.Compilers.XmlPreprocessor/Mocha.Compilers.XmlPreprocessor.csproj
@@ -0,0 +1,16 @@
+
+
+
+ Exe
+ net8.0
+ enable
+ enable
+
+
+
+
+
+
+
+
+
diff --git a/mocha-dotnet/src/app/Mocha.Compilers.XmlPreprocessor/ObjectModel/ElementContent.cs b/mocha-dotnet/src/app/Mocha.Compilers.XmlPreprocessor/ObjectModel/ElementContent.cs
new file mode 100644
index 0000000..9930809
--- /dev/null
+++ b/mocha-dotnet/src/app/Mocha.Compilers.XmlPreprocessor/ObjectModel/ElementContent.cs
@@ -0,0 +1,9 @@
+using System;
+
+namespace Mocha.Compilers.XmlPreprocessor.ObjectModel;
+
+public class ElementContent : Instance
+{
+ public ElementContent() : base() { }
+ public ElementContent(InstanceReference reference) : base(reference) { }
+}
diff --git a/mocha-dotnet/src/app/Mocha.Compilers.XmlPreprocessor/ObjectModel/Instance.cs b/mocha-dotnet/src/app/Mocha.Compilers.XmlPreprocessor/ObjectModel/Instance.cs
new file mode 100644
index 0000000..afe2b8b
--- /dev/null
+++ b/mocha-dotnet/src/app/Mocha.Compilers.XmlPreprocessor/ObjectModel/Instance.cs
@@ -0,0 +1,17 @@
+using System;
+
+namespace Mocha.Compilers.XmlPreprocessor.ObjectModel;
+
+public class Instance
+{
+ public InstanceReference? Reference { get; }
+
+ public Instance()
+ {
+ Reference = null;
+ }
+ public Instance(InstanceReference reference)
+ {
+ Reference = reference;
+ }
+}
diff --git a/mocha-dotnet/src/app/Mocha.Compilers.XmlPreprocessor/ObjectModel/Task.cs b/mocha-dotnet/src/app/Mocha.Compilers.XmlPreprocessor/ObjectModel/Task.cs
new file mode 100644
index 0000000..7f6efb6
--- /dev/null
+++ b/mocha-dotnet/src/app/Mocha.Compilers.XmlPreprocessor/ObjectModel/Task.cs
@@ -0,0 +1,24 @@
+using System;
+
+namespace Mocha.Compilers.XmlPreprocessor.ObjectModel;
+
+public class Task : Instance
+{
+ public Task() : base() { }
+ public Task(InstanceReference reference) : base(reference) { }
+
+ public class TaskSelection
+ {
+ public List ElementContents { get; } = new List();
+
+ }
+ public class TaskProcessing
+ {
+ public List ElementContents { get; } = new List();
+
+ }
+
+ public TaskSelection Selection { get; } = new TaskSelection();
+ public TaskProcessing Processing { get; } = new TaskProcessing();
+
+}
diff --git a/mocha-dotnet/src/app/Mocha.Compilers.XmlPreprocessor/Parser.cs b/mocha-dotnet/src/app/Mocha.Compilers.XmlPreprocessor/Parser.cs
new file mode 100644
index 0000000..7d26b68
--- /dev/null
+++ b/mocha-dotnet/src/app/Mocha.Compilers.XmlPreprocessor/Parser.cs
@@ -0,0 +1,81 @@
+// Copyright (C) 2025 Michael Becker
+//
+// This file is part of Mocha.NET.
+//
+// Mocha.NET is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Mocha.NET is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Mocha.NET. If not, see .
+
+using System.Xml;
+using Mocha.Compilers.XmlPreprocessor.ObjectModel;
+
+class Parser
+{
+ public Dictionary EntityDefinitions { get; } = new Dictionary();
+ private string EvaluateEntityDefinitions(string value)
+ {
+ foreach (KeyValuePair kvp in EntityDefinitions)
+ {
+ value = value.Replace(String.Concat("@", kvp.Key, ";"), kvp.Value);
+ }
+ return value;
+ }
+
+ public List Instances { get; } = new List();
+
+ public void Load(Stream st)
+ {
+ XmlDocument xd = new XmlDocument();
+ xd.Load(st);
+
+ if (xd["task"] is XmlNode x_task)
+ {
+ LoadTask(x_task);
+ }
+ }
+
+ private void LoadTask(XmlNode x_task)
+ {
+ Mocha.Compilers.XmlPreprocessor.ObjectModel.Task task = new Mocha.Compilers.XmlPreprocessor.ObjectModel.Task();
+ if (x_task["selection"]?["layout"] is XmlNode x_task_selection_layout)
+ {
+ List list = new List();
+
+ foreach (XmlNode xn in x_task_selection_layout)
+ {
+ if (xn.Name == "instance")
+ {
+ if (xn.Attributes?["globalIdentifier"] is XmlAttribute attrGlobalIdentifier)
+ {
+ task.Selection.ElementContents.Add(new ElementContent(new InstanceReference(Guid.Parse(EvaluateEntityDefinitions(attrGlobalIdentifier.Value)))));
+ }
+ }
+ }
+ }
+ if (x_task["processing"]?["layout"] is XmlNode x_task_processing_layout)
+ {
+ List list = new List();
+
+ foreach (XmlNode xn in x_task_processing_layout)
+ {
+ if (xn.Name == "instance")
+ {
+ if (xn.Attributes?["globalIdentifier"] is XmlAttribute attrGlobalIdentifier)
+ {
+ task.Processing.ElementContents.Add(new ElementContent(new InstanceReference(Guid.Parse(EvaluateEntityDefinitions(attrGlobalIdentifier.Value)))));
+ }
+ }
+ }
+ }
+ Instances.Add(task);
+ }
+}
\ No newline at end of file
diff --git a/mocha-dotnet/src/app/Mocha.Compilers.XmlPreprocessor/Program.cs b/mocha-dotnet/src/app/Mocha.Compilers.XmlPreprocessor/Program.cs
new file mode 100644
index 0000000..40f5ce6
--- /dev/null
+++ b/mocha-dotnet/src/app/Mocha.Compilers.XmlPreprocessor/Program.cs
@@ -0,0 +1,30 @@
+using System.Xml;
+using Mocha.Core;
+using Mocha.Plugins.Libraries.McxMini;
+
+namespace Mocha.Compilers.XmlPreprocesssor;
+
+public class Program
+{
+
+ public static void Main(string[] args)
+ {
+ string filename = "/home/beckermj/Documents/Projects/mochapowered/mocha-dotnet/mocha-common/mocha-common/data/libraries/yaml/net.alcetech.Mocha.System/005-UserInterface/Tasks/WorkSet.xml";
+
+ System.IO.FileStream fs = System.IO.File.Open(filename, FileMode.Open, FileAccess.Read, FileShare.Read);
+
+ Parser p = new Parser();
+
+ Library libSystem = new Library();
+ McxMiniLibraryPlugin plug = new McxMiniLibraryPlugin();
+ plug.Load("/home/beckermj/Documents/Projects/mochapowered/mocha-dotnet/mocha-common/mocha-common/output/net.alcetech.Mocha.System.mcl", libSystem);
+
+ // yay!
+ foreach (KeyValuePair kvp in libSystem.EntityDefinitions)
+ {
+ p.EntityDefinitions[kvp.Key] = kvp.Value;
+ }
+
+ p.Load(fs);
+ }
+}
\ No newline at end of file
diff --git a/mocha-dotnet/src/app/Mocha.Oms.Server/Program.cs b/mocha-dotnet/src/app/Mocha.Oms.Server/Program.cs
index 25549da..bd1b610 100644
--- a/mocha-dotnet/src/app/Mocha.Oms.Server/Program.cs
+++ b/mocha-dotnet/src/app/Mocha.Oms.Server/Program.cs
@@ -176,10 +176,16 @@ public class Program : WebApplication
if (jo.ContainsKey("name"))
{
string name = jo["name"].GetValue();
- Log.WriteLine("oms-dotnet: Mochafile says create tenant '{0}'", name);
+ int count = 1;
- TenantHandle th = Oms.CreateTenant(name);
- Log.WriteLine("oms-dotnet: create tenant ok, handle is '{0}'", th);
+ if (jo.ContainsKey("count"))
+ {
+ count = jo["count"].GetValue();
+ }
+ for (int i = 0; i < count; i++)
+ {
+ CreateTenant2(name);
+ }
}
}
}
@@ -189,6 +195,39 @@ public class Program : WebApplication
return true;
}
+ private void CreateTenant2(string name)
+ {
+ int ct = 0;
+ TenantHandle th = Oms.GetTenantByName(name);
+ if (th != TenantHandle.Empty)
+ {
+ while (true)
+ {
+ ct++;
+ string name2 = String.Concat(name, ct.ToString());
+ Log.WriteLine("oms-dotnet: Mochafile says create tenant '{0}'", name2);
+
+ th = Oms.GetTenantByName(name2);
+ if (th == TenantHandle.Empty)
+ {
+ th = Oms.CreateTenant(name2);
+ break;
+ }
+ }
+ }
+ else
+ {
+ Log.WriteLine("oms-dotnet: Mochafile says create tenant '{0}'", name);
+ th = Oms.CreateTenant(name);
+ }
+
+ Oms.SelectTenant(th);
+ Oms.AddLibraryReference(Oms.GetLibrary("net.alcetech.Mocha.System"));
+ Oms.AddLibraryReference(Oms.GetLibrary("net.alcetech.Mocha.Web"));
+
+ Log.WriteLine("oms-dotnet: create tenant ok, handle is '{0}'", th);
+ }
+
private bool TryLoadLibrary(Oms oms, string path, string fileName)
{
string fullyQualifiedFileName = System.IO.Path.Combine(new string[] { path, fileName });
diff --git a/mocha-dotnet/src/lib/Mocha.Core.UI.Server/Commands/ElementCommand.cs b/mocha-dotnet/src/lib/Mocha.Core.UI.Server/Commands/ElementCommand.cs
index 01d29e6..0a330b9 100644
--- a/mocha-dotnet/src/lib/Mocha.Core.UI.Server/Commands/ElementCommand.cs
+++ b/mocha-dotnet/src/lib/Mocha.Core.UI.Server/Commands/ElementCommand.cs
@@ -120,7 +120,7 @@ public class ElementCommand : InstanceCommand
}
else if (oms.IsInstanceOf(ProcessingInstance, oms.GetInstance(KnownInstanceGuids.Classes.Task)))
{
- RespndWithTask(oms, sw, e.Context, ctx, ProcessingInstance);
+ RespondWithTask(oms, sw, e.Context, ctx, ProcessingInstance);
}
else
{
@@ -131,25 +131,43 @@ public class ElementCommand : InstanceCommand
if (defaultTask != InstanceHandle.Empty)
{
ctx.InitiatingInstance = ProcessingInstance;
- RespndWithTask(oms, sw, e.Context, ctx, defaultTask);
+ RespondWithTask(oms, sw, e.Context, ctx, defaultTask);
}
}
}
}
- private void RespndWithTask(Oms oms, StreamWriter sw, WebContext context, OmsContext omsContext, InstanceHandle task)
+ private void RespondWithTask(Oms oms, StreamWriter sw, WebContext context, OmsContext omsContext, InstanceHandle task)
{
// fill out the initiating element and execute the task
InstanceHandle elem = oms.GetRelatedInstance(task, oms.GetInstance(KnownRelationshipGuids.Task__has_initiating__Element));
omsContext.InitiatingTask = task;
- Response r = oms.ProcessElement(omsContext, elem, null);
- JsonObject obj = r.GetResponse(oms, omsContext);
+ if (context.Request.Method == "POST")
+ {
+ // !! FIXME !! this doesn't work
+ // POST http://localhost:4436/tenants/super/instances/2997$1/element
+ // relatedInstance=4170$1
- /*
-
- */
-
- RespondWithJson(oms, sw, context, 200, "OK", obj);
+ Response r = oms.ProcessElement(omsContext, elem, context.Request.Form);
+ JsonObject obj = r.GetResponse(oms, omsContext);
+
+ /*
+
+ */
+
+ RespondWithJson(oms, sw, context, 200, "OK", obj);
+ }
+ else
+ {
+ Response r = oms.ProcessElement(omsContext, elem, null);
+ JsonObject obj = r.GetResponse(oms, omsContext);
+
+ /*
+
+ */
+
+ RespondWithJson(oms, sw, context, 200, "OK", obj);
+ }
}
}
\ No newline at end of file
diff --git a/mocha-dotnet/src/lib/Mocha.Core/InstanceKey.cs b/mocha-dotnet/src/lib/Mocha.Core/InstanceKey.cs
index 2d9438d..7e7c986 100755
--- a/mocha-dotnet/src/lib/Mocha.Core/InstanceKey.cs
+++ b/mocha-dotnet/src/lib/Mocha.Core/InstanceKey.cs
@@ -158,16 +158,11 @@ namespace Mocha.Core
return String.Format("{0}${1}", ClassIndex, InstanceIndex);
}
- internal string GetDerivedDataString(Dictionary? derivedData = null)
+ internal static string GetDerivedDataString(Dictionary derivedData)
{
MemoryStream ms = new MemoryStream();
BinaryWriter bw = new BinaryWriter(ms);
- if (derivedData == null)
- {
- derivedData = GetDerivedData();
- }
-
foreach (KeyValuePair kvp in derivedData)
{
if (kvp.Value is string)
diff --git a/mocha-dotnet/src/lib/Mocha.Core/KnownInstanceGuids.cs b/mocha-dotnet/src/lib/Mocha.Core/KnownInstanceGuids.cs
index 13a34db..9556856 100755
--- a/mocha-dotnet/src/lib/Mocha.Core/KnownInstanceGuids.cs
+++ b/mocha-dotnet/src/lib/Mocha.Core/KnownInstanceGuids.cs
@@ -224,7 +224,10 @@ namespace Mocha.Core
public static class MethodClasses
{
public static Guid ControlTransactionMethod { get; } = new Guid("{BF73CEAC-F972-46E8-BFA1-7807F39F1B91}"); // 8
- // PU - Process Updates Method - 11
+ ///
+ /// PU - Process Updates Method - 11
+ ///
+ public static Guid ProcessUpdatesMethod { get; } = new Guid("{f042c68d-8187-4dd6-93fa-7119bb949a16}");
public static Guid GetAttributeMethod { get; } = new Guid("{c3ecf8c9-597f-417b-ad65-fae0401719c6}"); // 12
// Perform System Routine Method - 13
public static Guid GetReferencedAttributeMethod { get; } = new Guid("{9205c54e-921a-484c-9be2-3d3deb877474}"); // 18
diff --git a/mocha-dotnet/src/lib/Mocha.Core/KnownRelationshipGuids.cs b/mocha-dotnet/src/lib/Mocha.Core/KnownRelationshipGuids.cs
index 964aff1..e90c8a7 100755
--- a/mocha-dotnet/src/lib/Mocha.Core/KnownRelationshipGuids.cs
+++ b/mocha-dotnet/src/lib/Mocha.Core/KnownRelationshipGuids.cs
@@ -435,6 +435,9 @@ namespace Mocha.Core
public static Guid Domain__secures__Route { get; } = new Guid("{95725379-7b45-4e0c-a04e-b06eead84c60}");
public static Guid Element__processed_by__Process_Related_Updates_Method { get; } = new Guid("{ed9c836a-04a4-4505-8953-3c567e841c66}");
public static Guid Process_Related_Updates_Method__uses__Executable_for_PUMB { get; } = new Guid("{50e1f14a-d6e5-4c71-b7ab-1755442728dc}");
+
+ public static Guid Process_Updates_Method__has__PUM_Process { get; } = new Guid("{0ffaf08e-dbb5-49d0-8de9-d253ce6cbe7c}");
+ public static Guid PUM_Process__invokes__Execute_Update_Method_Binding { get; } = new Guid("{d3e83c17-fd38-46a0-a055-66281eabe9b0}");
public static Guid BEM_Process__uses_loop__Executable_returning_Instance_Set { get; } = new Guid("{0fb2b538-eacb-418a-b7d8-43a584b85952}");
diff --git a/mocha-dotnet/src/lib/Mocha.Core/Library.cs b/mocha-dotnet/src/lib/Mocha.Core/Library.cs
index 891fe1a..345f3d2 100644
--- a/mocha-dotnet/src/lib/Mocha.Core/Library.cs
+++ b/mocha-dotnet/src/lib/Mocha.Core/Library.cs
@@ -7,9 +7,9 @@ public class Library
/// Applies all attribute and relationship assignments once all instances have been
/// accounted for.
///
- public void Link()
- {
- }
+ public void Link()
+ {
+ }
public Guid GlobalIdentifier { get; set; } = Guid.Empty;
@@ -17,4 +17,5 @@ public class Library
public List Attributes { get; } = new List();
public List Relationships { get; } = new List();
public List LibraryReferences { get; } = new List();
+ public Dictionary EntityDefinitions { get; } = new Dictionary();
}
diff --git a/mocha-dotnet/src/lib/Mocha.Core/MethodImplementations/ProcessUpdatesMethodImplementation.cs b/mocha-dotnet/src/lib/Mocha.Core/MethodImplementations/ProcessUpdatesMethodImplementation.cs
new file mode 100644
index 0000000..7cb1881
--- /dev/null
+++ b/mocha-dotnet/src/lib/Mocha.Core/MethodImplementations/ProcessUpdatesMethodImplementation.cs
@@ -0,0 +1,40 @@
+// Copyright (C) 2024 Michael Becker
+//
+// This file is part of Mocha.NET.
+//
+// Mocha.NET is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Mocha.NET is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Mocha.NET. If not, see .
+
+namespace Mocha.Core.MethodImplementations;
+
+public class ProcessUpdatesMethodImplementation : MethodImplementation
+{
+ public override Guid MethodClassGuid => KnownInstanceGuids.MethodClasses.ProcessUpdatesMethod;
+ protected override InstanceHandle ExecuteInternal(Oms oms, OmsContext context, InstanceHandle method)
+ {
+ InstanceHandle forClass = oms.GetRelatedInstance(method, oms.GetInstance(KnownRelationshipGuids.Method__for__Class));
+
+ InstanceHandle hasPUMProcess = oms.GetRelatedInstance(method, oms.GetInstance(KnownRelationshipGuids.Process_Updates_Method__has__PUM_Process));
+
+ IEnumerable invokesExecuteUpdateMethodBindings = oms.GetRelatedInstances(hasPUMProcess, oms.GetInstance(KnownRelationshipGuids.PUM_Process__invokes__Execute_Update_Method_Binding));
+ // InstanceHandle invokesProcessRelatedUpdatesMethod = oms.GetRelatedInstance(hasPUMProcess, oms.GetInstance(KnownRelationshipGuids.PUM_Process__invokes__Process_Related_Updates_Method));
+ Console.Error.WriteLine("---> has {0} EUMBs", invokesExecuteUpdateMethodBindings.Count());
+
+ foreach (InstanceHandle eumb in invokesExecuteUpdateMethodBindings)
+ {
+ Console.Error.WriteLine("---> executing EUMB {0}", eumb.GlobalIdentifier);
+ oms.Execute(context, eumb) ;
+ }
+ return InstanceHandle.Empty;
+ }
+}
\ No newline at end of file
diff --git a/mocha-dotnet/src/lib/Mocha.Core/Oms.cs b/mocha-dotnet/src/lib/Mocha.Core/Oms.cs
index ab33b6b..820e580 100644
--- a/mocha-dotnet/src/lib/Mocha.Core/Oms.cs
+++ b/mocha-dotnet/src/lib/Mocha.Core/Oms.cs
@@ -131,6 +131,14 @@ public abstract class Oms
}
return (decimal)r.NextDouble();
});
+ RegisterSystemUpdateRoutine(new Guid("256327f3-6f21-403d-8c58-0eabdbf10a6a"), delegate (Oms oms, OmsContext context)
+ {
+ // create instance
+ // but how do we get the InstanceHandle back?
+ // originally implemented create instance as a GSS - Get Instance Set by System Routine
+ // which would do the create and then return the newly-created instance in a Work Set
+ // via Method Binding, then use the Work Set in further method calls
+ });
RegisterSystemUpdateRoutine(KnownInstanceGuids.SystemUpdateRoutines.LoginUser, delegate (Oms oms, OmsContext context)
{
Console.Error.WriteLine("oms: executing system update routine {0}", KnownInstanceGuids.SystemUpdateRoutines.LoginUser);
@@ -683,11 +691,18 @@ public abstract class Oms
public bool IsDerivedInstance(IInstanceReference source)
{
// !!! we cannot use GetAttributeValue here !!!
- InstanceHandle pclass = GetParentClass(source);
- object? o = GetAttributeValueInternal(pclass, GetInstance(KnownAttributeGuids.Boolean.Derived), DateTime.Now);
- if (o is bool b && b)
+ if (TryGetInstance(KnownAttributeGuids.Boolean.Derived, out InstanceHandle ihDerived))
{
- return true;
+ InstanceHandle pclass = GetParentClass(source);
+ object? o = GetAttributeValueInternal(pclass, GetInstance(KnownAttributeGuids.Boolean.Derived), DateTime.Now);
+ if (o is bool b && b)
+ {
+ return true;
+ }
+ }
+ else
+ {
+ Console.Error.WriteLine("warning: Boolean Attribute `Derived` doesn't exist; assuming instance is not derived");
}
return false;
}
@@ -1240,7 +1255,8 @@ public abstract class Oms
}
if (retval == null)
{
- throw new NotImplementedException(String.Format("method implementation not found for method class {0}", GetGlobalIdentifier(parentClass)));
+ return InstanceHandle.Empty;
+ //throw new NotImplementedException(String.Format("method implementation not found for method class {0}", GetGlobalIdentifier(parentClass)));
}
else
{
@@ -1514,7 +1530,7 @@ public abstract class Oms
{
return ee.ReturnValue;
}
-
+
object? value = sr.Execute(this, context);
OnSystemRoutineExecuted(new SystemRoutineExecutedEventArgs(this, context, sr, value));
@@ -2096,7 +2112,7 @@ public abstract class Oms
{
targetURL = targetURLAttr;
}
-
+
if (targetURL != null)
{
return new RedirectResponse(targetURL);
@@ -2126,6 +2142,42 @@ public abstract class Oms
*/
return FailureResponse.NotImplemented;
}
+
+ bool use_hack = false;
+ if (use_hack)
+ {
+ // if we get to here, let's just fall back and hardcode whatever
+
+ // HACK
+ InstanceHandle ih = CreateInstanceOf(GetInstance(KnownInstanceGuids.Classes.Class));
+
+ foreach (InstanceHandle ec in elementContents)
+ {
+ string ecid = GetInstanceKey(ec).ToString();
+ InstanceHandle relinst = GetRelatedInstance(ec, GetInstance(KnownRelationshipGuids.Element_Content__has__Instance));
+ if (relinst != InstanceHandle.Empty)
+ {
+ if (IsInstanceOf(relinst, GetInstance(KnownInstanceGuids.Classes.Attribute)))
+ {
+ SetAttributeValue(ih, relinst, form[ecid]);
+ }
+ else if (IsInstanceOf(relinst, GetInstance(KnownInstanceGuids.Classes.Relationship)))
+ {
+ if (TryParseInstanceRef(form[ecid], out InstanceHandle ihr))
+ {
+ AssignRelationship(ih, relinst, ihr);
+ }
+ else
+ {
+ Console.Error.WriteLine("unable to parse instance ref '{0}'", form[ecid]);
+ }
+ }
+ }
+ }
+
+ // HACK
+ return new RedirectResponse(String.Format("~/d/inst/{0}.htmld", GetInstanceKey(ih)));
+ }
}
else
{
@@ -2136,7 +2188,7 @@ public abstract class Oms
{
return FailureResponse.UnexpectedFailure;
}
-
+
return new PageResponse(delegate (Oms oms, OmsContext ctx)
{
JsonObject obj3 = widget.ToJSONObject(ctx);
@@ -2144,7 +2196,7 @@ public abstract class Oms
JsonObject obj2 = new JsonObject();
obj2.Add("widget", JsonValue.Create("root"));
obj2.Add("body", widget.ToJSONObject(ctx));
-
+
JsonObject objTitle = new JsonObject();
// hack
if (String.IsNullOrEmpty(title) && ctx.InitiatingTask != InstanceHandle.Empty)
@@ -2161,7 +2213,7 @@ public abstract class Oms
return obj;
});
}
- return FailureResponse.UnexpectedFailure;
+ return null; // FailureResponse.UnexpectedFailure;
}
private Response? ProcessElementContent(OmsContext context, InstanceHandle elementContent, IDictionary form, string fqecidPrefix)
@@ -2352,4 +2404,50 @@ public abstract class Oms
}
throw new FormatException();
}
+
+ public object? Evaluate(OmsContext context, InstanceHandle workDataInstance, InstanceHandle sourceInstance, object? defaultValue = null)
+ {
+ object? value = defaultValue;
+ if (IsInstanceOf(workDataInstance, GetInstance(KnownInstanceGuids.Classes.TextAttribute)))
+ {
+ if (sourceInstance != InstanceHandle.Empty)
+ {
+ // first check our target instance for the attribute. this MAY be empty
+ value = GetAttributeValue(sourceInstance, workDataInstance);
+ }
+ }
+ else if (IsInstanceOf(workDataInstance, GetInstance(KnownInstanceGuids.Classes.BooleanAttribute)))
+ {
+ if (sourceInstance != InstanceHandle.Empty)
+ {
+ // first check our target instance for the attribute. this MAY be empty
+ value = GetAttributeValue(sourceInstance, workDataInstance);
+ }
+ }
+ else if (IsInstanceOf(workDataInstance, GetInstance(KnownInstanceGuids.Classes.NumericAttribute)))
+ {
+ if (sourceInstance != InstanceHandle.Empty)
+ {
+ // first check our target instance for the attribute. this MAY be empty
+ value = GetAttributeValue(sourceInstance, workDataInstance);
+ }
+ }
+ else if (IsInstanceOf(workDataInstance, GetInstance(KnownInstanceGuids.Classes.DateAttribute)))
+ {
+ if (sourceInstance != InstanceHandle.Empty)
+ {
+ // first check our target instance for the attribute. this MAY be empty
+ value = GetAttributeValue(sourceInstance, workDataInstance);
+ }
+ }
+ else
+ {
+ context.SetWorkData(GetInstance(KnownInstanceGuids.WorkSets.TaskRelatedInstance), context.InitiatingInstance);
+
+ InstanceHandle workData = Execute(context, workDataInstance);
+ object? val = context.GetWorkData(workData);
+ value = val?.ToString();
+ }
+ return value;
+ }
}
diff --git a/mocha-dotnet/src/lib/Mocha.Core/Transaction.cs b/mocha-dotnet/src/lib/Mocha.Core/Transaction.cs
index 6c9bdea..0616e55 100755
--- a/mocha-dotnet/src/lib/Mocha.Core/Transaction.cs
+++ b/mocha-dotnet/src/lib/Mocha.Core/Transaction.cs
@@ -15,26 +15,6 @@
// You should have received a copy of the GNU General Public License
// along with Mocha.NET. If not, see .
-//
-// Transaction.cs
-//
-// Author:
-// Michael Becker
-//
-// Copyright (c) 2021 Mike Becker's Software
-//
-// This program is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program. If not, see .
using System;
using System.Collections;
using System.Collections.Generic;
diff --git a/mocha-dotnet/src/lib/Mocha.Core/UI/Widgets/CheckBox.cs b/mocha-dotnet/src/lib/Mocha.Core/UI/Widgets/CheckBox.cs
new file mode 100644
index 0000000..b61d29f
--- /dev/null
+++ b/mocha-dotnet/src/lib/Mocha.Core/UI/Widgets/CheckBox.cs
@@ -0,0 +1,54 @@
+// Copyright (C) 2024 Michael Becker
+//
+// This file is part of Mocha.NET.
+//
+// Mocha.NET is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Mocha.NET is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Mocha.NET. If not, see .
+
+
+using System.Text.Json.Nodes;
+
+namespace Mocha.Core.UI;
+
+public class CheckBox : Widget
+{
+ protected override string GetWidgetName()
+ {
+ return "checkbox";
+ }
+ public override Guid[] SupportedClassGuids => new Guid[] { KnownInstanceGuids.Classes.BooleanAttribute };
+
+ protected override void RenderJSONInternal(OmsContext context, JsonObject obj)
+ {
+ string? value = null;
+
+ object? val = OMS.Evaluate(context, ParentInstance, TargetInstance);
+ if (val != null)
+ {
+ value = val.ToString();
+ }
+
+ if (value == null)
+ {
+ // no value specified for the target instance, so get default value of the Text Attribute
+ value = OMS.GetAttributeValue(ParentInstance, OMS.GetInstance(KnownAttributeGuids.Text.Value));
+ }
+
+
+ if (value != null)
+ {
+ // if we finally have a value, use it
+ obj.Add("value", value);
+ }
+ }
+}
diff --git a/mocha-dotnet/src/lib/Mocha.Core/UI/Widgets/Text.cs b/mocha-dotnet/src/lib/Mocha.Core/UI/Widgets/Text.cs
index 488e4e2..4954600 100644
--- a/mocha-dotnet/src/lib/Mocha.Core/UI/Widgets/Text.cs
+++ b/mocha-dotnet/src/lib/Mocha.Core/UI/Widgets/Text.cs
@@ -34,29 +34,18 @@ public class Text : Widget
}
return "text";
}
- public override Guid[] SupportedClassGuids => new Guid[] { KnownInstanceGuids.Classes.TextAttribute, KnownInstanceGuids.Classes.ExecutableReturningAttribute };
+ public override Guid[] SupportedClassGuids => new Guid[] { KnownInstanceGuids.Classes.TextAttribute };
protected override void RenderJSONInternal(OmsContext context, JsonObject obj)
{
string? value = null;
- if (OMS.IsInstanceOf(ParentInstance, OMS.GetInstance(KnownInstanceGuids.Classes.TextAttribute)))
+ object? val = OMS.Evaluate(context, ParentInstance, TargetInstance);
+ if (val != null)
{
- if (TargetInstance != InstanceHandle.Empty)
- {
- // first check our target instance for the attribute. this MAY be empty
- value = OMS.GetAttributeValue(TargetInstance, ParentInstance);
- }
+ value = val.ToString();
}
- else
- {
- context.SetWorkData(OMS.GetInstance(KnownInstanceGuids.WorkSets.TaskRelatedInstance), context.InitiatingInstance);
-
- InstanceHandle workData = OMS.Execute(context, ParentInstance);
- object? val = context.GetWorkData(workData);
- value = val?.ToString();
- }
-
+
if (value == null)
{
// no value specified for the target instance, so get default value of the Text Attribute
diff --git a/mocha-dotnet/src/lib/Mocha.Modeling/CodeGeneration/AccessModifier.cs b/mocha-dotnet/src/lib/Mocha.Modeling/CodeGeneration/AccessModifier.cs
new file mode 100644
index 0000000..2897d5f
--- /dev/null
+++ b/mocha-dotnet/src/lib/Mocha.Modeling/CodeGeneration/AccessModifier.cs
@@ -0,0 +1,28 @@
+// Copyright (C) 2025 Michael Becker
+//
+// This file is part of Mocha.NET.
+//
+// Mocha.NET is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Mocha.NET is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Mocha.NET. If not, see .
+
+namespace Mocha.Modeling.CodeGeneration;
+
+public enum AccessModifier
+{
+ None,
+ Public,
+ Protected,
+ Internal,
+ ProtectedInternal,
+ Private
+}
\ No newline at end of file
diff --git a/mocha-dotnet/src/lib/Mocha.Modeling/CodeGeneration/Class.cs b/mocha-dotnet/src/lib/Mocha.Modeling/CodeGeneration/Class.cs
new file mode 100644
index 0000000..f8098d6
--- /dev/null
+++ b/mocha-dotnet/src/lib/Mocha.Modeling/CodeGeneration/Class.cs
@@ -0,0 +1,28 @@
+// Copyright (C) 2025 Michael Becker
+//
+// This file is part of Mocha.NET.
+//
+// Mocha.NET is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Mocha.NET is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Mocha.NET. If not, see .
+
+namespace Mocha.Modeling.CodeGeneration;
+
+using System.Collections.Generic;
+
+public class Class : ICodeType, IClassMember
+{
+ public AccessModifier AccessModifier { get; set; } = AccessModifier.None;
+ public string? Name { get; set; } = "";
+ public ObjectReference? InheritsClass { get; set; } = null;
+ public List Items { get; } = new List();
+}
\ No newline at end of file
diff --git a/mocha-dotnet/src/lib/Mocha.Modeling/CodeGeneration/CodeGenerator.cs b/mocha-dotnet/src/lib/Mocha.Modeling/CodeGeneration/CodeGenerator.cs
new file mode 100644
index 0000000..916e1f1
--- /dev/null
+++ b/mocha-dotnet/src/lib/Mocha.Modeling/CodeGeneration/CodeGenerator.cs
@@ -0,0 +1,29 @@
+// Copyright (C) 2025 Michael Becker
+//
+// This file is part of Mocha.NET.
+//
+// Mocha.NET is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Mocha.NET is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Mocha.NET. If not, see .
+
+namespace Mocha.Modeling.CodeGeneration;
+
+using System.Text;
+
+public abstract class CodeGenerator
+{
+ protected abstract string GenerateCodeInternal(ICodeItem item);
+ public string GenerateCode(ICodeItem item)
+ {
+ return GenerateCodeInternal(item);
+ }
+}
\ No newline at end of file
diff --git a/mocha-dotnet/src/lib/Mocha.Modeling/CodeGeneration/Document.cs b/mocha-dotnet/src/lib/Mocha.Modeling/CodeGeneration/Document.cs
new file mode 100644
index 0000000..393519c
--- /dev/null
+++ b/mocha-dotnet/src/lib/Mocha.Modeling/CodeGeneration/Document.cs
@@ -0,0 +1,25 @@
+// Copyright (C) 2025 Michael Becker
+//
+// This file is part of Mocha.NET.
+//
+// Mocha.NET is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Mocha.NET is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Mocha.NET. If not, see .
+
+namespace Mocha.Modeling.CodeGeneration;
+
+using System.Collections.Generic;
+
+public class Document
+{
+ public List Classes { get; } = new List();
+}
\ No newline at end of file
diff --git a/mocha-dotnet/src/lib/Mocha.Modeling/CodeGeneration/Expressions/CreateInstance.cs b/mocha-dotnet/src/lib/Mocha.Modeling/CodeGeneration/Expressions/CreateInstance.cs
new file mode 100644
index 0000000..5afebd7
--- /dev/null
+++ b/mocha-dotnet/src/lib/Mocha.Modeling/CodeGeneration/Expressions/CreateInstance.cs
@@ -0,0 +1,30 @@
+// Copyright (C) 2025 Michael Becker
+//
+// This file is part of Mocha.NET.
+//
+// Mocha.NET is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Mocha.NET is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Mocha.NET. If not, see .
+
+namespace Mocha.Modeling.CodeGeneration;
+
+public class CreateInstance : IMethodMember
+{
+ public ObjectReference ObjectReference { get; set; }
+ public List