Author: husted
Date: Fri Jun 10 14:07:37 2005
New Revision: 190021

URL: http://svn.apache.org/viewcvs?rev=190021&view=rev
Log:
OVR-10
* Design interface and begin default implementation.

Added:
    struts/sandbox/trunk/overdrive/Nexus/Web/WebHelper.cs
    struts/sandbox/trunk/overdrive/Nexus/Web/WebViewHelper.cs
Modified:
    struts/sandbox/trunk/overdrive/Nexus/Core/Core.csproj
    struts/sandbox/trunk/overdrive/Nexus/Core/IController.cs
    struts/sandbox/trunk/overdrive/Nexus/Core/IRequestContext.cs
    struts/sandbox/trunk/overdrive/Nexus/Core/RequestContext.cs
    struts/sandbox/trunk/overdrive/Nexus/Core/Tokens.cs
    struts/sandbox/trunk/overdrive/Nexus/Extras/Spring/Controller.cs
    struts/sandbox/trunk/overdrive/Nexus/Test/BaseNexusTest.cs
    struts/sandbox/trunk/overdrive/Nexus/Web/Web.csproj

Modified: struts/sandbox/trunk/overdrive/Nexus/Core/Core.csproj
URL: 
http://svn.apache.org/viewcvs/struts/sandbox/trunk/overdrive/Nexus/Core/Core.csproj?rev=190021&r1=190020&r2=190021&view=diff
==============================================================================
--- struts/sandbox/trunk/overdrive/Nexus/Core/Core.csproj (original)
+++ struts/sandbox/trunk/overdrive/Nexus/Core/Core.csproj Fri Jun 10 14:07:37 
2005
@@ -123,6 +123,31 @@
                     SubType = "Code"
                     BuildAction = "Compile"
                 />
+                <File
+                    RelPath = "Helpers\IViewHelper.cs"
+                    SubType = "Code"
+                    BuildAction = "Compile"
+                />
+                <File
+                    RelPath = "Helpers\ViewHelper.cs"
+                    SubType = "Code"
+                    BuildAction = "Compile"
+                />
+                <File
+                    RelPath = "Tables\IFieldContext.cs"
+                    SubType = "Code"
+                    BuildAction = "Compile"
+                />
+                <File
+                    RelPath = "Tables\IFieldTable.cs"
+                    SubType = "Code"
+                    BuildAction = "Compile"
+                />
+                <File
+                    RelPath = "Validators\IValidatorContext.cs"
+                    SubType = "Code"
+                    BuildAction = "Compile"
+                />
             </Include>
         </Files>
     </CSHARP>

Modified: struts/sandbox/trunk/overdrive/Nexus/Core/IController.cs
URL: 
http://svn.apache.org/viewcvs/struts/sandbox/trunk/overdrive/Nexus/Core/IController.cs?rev=190021&r1=190020&r2=190021&view=diff
==============================================================================
--- struts/sandbox/trunk/overdrive/Nexus/Core/IController.cs (original)
+++ struts/sandbox/trunk/overdrive/Nexus/Core/IController.cs Fri Jun 10 
14:07:37 2005
@@ -35,11 +35,33 @@
                object GetObject (string name);
 
                /// <summary>
+               /// Obtain new NexusContext for command, including embedded 
resources.
+               /// </summary>
+               /// <param name="command">Our command</param>
+               /// <returns>NexusContext with embedded resources.</returns>
+               /// 
+               IRequestContext GetContext (IRequestCommand command);
+
+               /// <summary>
                /// Obtain and execute the IRequestContext.
                /// </summary>
                /// <param name="command">Our command name</param>
                /// <returns>Context after execution</returns>
                /// 
                IRequestContext ExecuteContext (string command);
+
+
+               /// <summary>
+               /// Execute a Command as part of a View layer chain.
+               /// </summary>
+               /// <remarks><p>
+               /// Among other things, the View layer chain may transfer 
+               /// data between the FieldState and the root Context. 
+               /// The View layer chain acts as a  Front Controller.
+               /// </p></remarks>
+               /// <param name="context">Context to execute</param>
+               /// 
+               void ExecuteView (IRequestContext context);
+
        }
 }

Modified: struts/sandbox/trunk/overdrive/Nexus/Core/IRequestContext.cs
URL: 
http://svn.apache.org/viewcvs/struts/sandbox/trunk/overdrive/Nexus/Core/IRequestContext.cs?rev=190021&r1=190020&r2=190021&view=diff
==============================================================================
--- struts/sandbox/trunk/overdrive/Nexus/Core/IRequestContext.cs (original)
+++ struts/sandbox/trunk/overdrive/Nexus/Core/IRequestContext.cs Fri Jun 10 
14:07:37 2005
@@ -14,7 +14,9 @@
  * limitations under the License.
  */
 using System;
+using System.Collections;
 using Agility.Core;
+using Nexus.Core.Tables;
 
 namespace Nexus.Core
 {
@@ -36,6 +38,7 @@
                /// <remarks>
                /// Corresponds to ID of INexusCommand for the initial Command 
or Chain.
                /// </remarks>
+               /// 
                string Command { get; set; }
 
                /// <summary>
@@ -44,12 +47,31 @@
                /// <remarks>
                /// Corresponds to ID of INexusCommand for the initial Command 
or Chain.
                /// </remarks>
+               /// 
                IRequestCommand CommandBin { get; set; }
 
+
+               /// <summary>
+               /// Instance of the global Field Table for this application.
+               /// </summary>
+               /// <remarks>
+               /// Corresponds to ID of INexusCommand for the initial Command 
or Chain.
+               /// </remarks>
+               /// 
+               IFieldTable FieldTable { get; set; }
+
+
+               /// <summary>
+               /// 
+               /// </summary>
+               IList FieldSet { get; set; }
+
+
                /// <summary>
                /// Return true if an Outcome object is present.
                /// </summary>
                /// <returns>True if an Outcome context is present.</returns>
+               /// 
                bool HasOutcome { get; }
 
                /// <summary>
@@ -93,6 +115,7 @@
                /// in its own right. 
                /// </p>
                ///     </remarks>
+               ///     
                object Outcome { get; set; }
 
                /// <summary>
@@ -101,18 +124,21 @@
                /// <remark>
                /// TODO: Refactor as NameValueCollection ?
                /// </remark>
-               IContext Errors { get; set; }
+               /// 
+               IDictionary Errors { get; set; }
 
                /// <summary>
                /// Add an error message under the "global" key.
                /// </summary>
                /// <param name="template">Message template.</param>
+               /// 
                void AddError (string template);
 
                /// <summary>
                /// Indicate whether errors exist.
                /// </summary>
                /// <returns>True if there are errors. False 
otherwise.</returns>
+               /// 
                bool HasErrors { get; }
 
                /// <summary>
@@ -122,18 +148,49 @@
                /// A IViewContext is readonly, 
                /// but another interface (e.g. IHelperContext) may extend to 
add a setter, if needed.
                /// </remark>
+               /// 
                Exception Fault { get; set; }
 
                /// <summary>
                /// Indicate whether an Exception was caught.
                /// </summary>
                /// <returns>True if an Exception was caught.</returns>
+               /// 
                bool HasFault { get; }
 
                /// <summary>
                /// Indicate whether context is free of faults and errors.
                /// </summary>
                /// <returns>True if there are no faults or errors.</returns>
+               /// 
                bool IsNominal { get; }
+
+               /// <summary>
+               /// A list of error messages, keyed by the field causing the 
error, or to a magic global key.
+               /// </summary>
+               IDictionary Messages { get; set; }
+
+               /// <summary>
+               /// Add a message, creating the context if needed.
+               /// </summary>
+               /// <remarks>
+               /// Multiple messages can be added for a key and retrieved as a 
List.
+               /// </remarks>
+               /// <param name="template">Message template.</param>
+               /// <param name="message">Message key.</param>
+               void AddMessage (string template, string message);
+
+               /// <summary>
+               /// Add a message under the "global" key.
+               /// </summary>
+               /// <param name="template">Message template.</param>
+               void AddMessage (string template);
+
+               /// <summary>
+               /// Indicate whether messages exist.
+               /// </summary>
+               /// <returns>True if there are messages. False 
otherwise.</returns>
+               bool HasMessages {get;}
+
        }
 }

Modified: struts/sandbox/trunk/overdrive/Nexus/Core/RequestContext.cs
URL: 
http://svn.apache.org/viewcvs/struts/sandbox/trunk/overdrive/Nexus/Core/RequestContext.cs?rev=190021&r1=190020&r2=190021&view=diff
==============================================================================
--- struts/sandbox/trunk/overdrive/Nexus/Core/RequestContext.cs (original)
+++ struts/sandbox/trunk/overdrive/Nexus/Core/RequestContext.cs Fri Jun 10 
14:07:37 2005
@@ -16,6 +16,7 @@
 using System;
 using System.Collections;
 using Agility.Core;
+using Nexus.Core.Tables;
 
 namespace Nexus.Core
 {
@@ -52,6 +53,17 @@
                        set { this [Tokens.COMMAND_BIN] = value; }
                }
 
+               public IFieldTable FieldTable
+               {
+                       get { return this [Tokens.FIELD_TABLE] as IFieldTable; }
+                       set { this [Tokens.FIELD_TABLE] = value; }              
        
+               }
+
+               public IList FieldSet
+               {
+                       get { return this [Tokens.FIELD_SET] as IList; }
+                       set { this [Tokens.FIELD_SET] = value; }
+               }
 
                public bool HasOutcome
                {
@@ -64,12 +76,6 @@
                        set { this [Command] = value; }
                }
 
-               public IContext Errors
-               {
-                       get { return this [Tokens.ERRORS] as IContext; }
-                       set { this [Tokens.ERRORS] = value; }
-               }
-
                /// <summary>
                /// Convenience method to lazily instantiate a message store.
                /// </summary>
@@ -95,12 +101,17 @@
                        list.Add (template);
                }
 
+               public IDictionary Errors
+               {
+                       get { return this [Tokens.ERRORS] as IDictionary; }
+                       set { this [Tokens.ERRORS] = value; }
+               }
+
                public void AddError (string template)
                {
                        AddStore (template, Tokens.GENERIC_MESSAGE, 
Tokens.ERRORS);
                }
 
-
                public bool HasErrors
                {
                        get { return this.ContainsKey (Tokens.ERRORS); }
@@ -125,6 +136,27 @@
                public bool IsNominal
                {
                        get { return (!HasErrors && !HasFault); }
+               }
+
+               public IDictionary Messages
+               {
+                       get { return this [Tokens.MESSAGES] as IDictionary; }
+                       set { this [Tokens.MESSAGES] = value; }
+               }
+
+               public void AddMessage (string template)
+               {
+                       AddStore (template, Tokens.GENERIC_MESSAGE, 
Tokens.MESSAGES);
+               }
+
+               public void AddMessage (string template, string queue)
+               {
+                       AddStore (template, queue, Tokens.MESSAGES);
+               }
+
+               public bool HasMessages
+               {
+                       get { return this.ContainsKey (Tokens.MESSAGES); }
                }
 
        }

Modified: struts/sandbox/trunk/overdrive/Nexus/Core/Tokens.cs
URL: 
http://svn.apache.org/viewcvs/struts/sandbox/trunk/overdrive/Nexus/Core/Tokens.cs?rev=190021&r1=190020&r2=190021&view=diff
==============================================================================
--- struts/sandbox/trunk/overdrive/Nexus/Core/Tokens.cs (original)
+++ struts/sandbox/trunk/overdrive/Nexus/Core/Tokens.cs Fri Jun 10 14:07:37 2005
@@ -42,6 +42,26 @@
                public const string ERRORS = "__ERRORS";
 
                /// <summary>
+               /// Token for Messages property.
+               /// </summary>
+               public const string MESSAGES = "__MESSAGES";
+
+               /// <summary>
+               /// Token for FieldTable property.
+               /// </summary>
+               public const string FIELD_TABLE = "__FIELD_TABLE";
+
+               /// <summary>
+               /// Token for IFieldTable object.
+               /// </summary>
+               public const string FIELD_ID = "FieldTable";
+
+               /// <summary>
+               /// Token for FieldSet property.
+               /// </summary>
+               public const string FIELD_SET = "__FIELD_SET";
+
+               /// <summary>
                /// Token for a generic message.
                /// </summary>
                public const string GENERIC_MESSAGE = "__GENERIC_MESSAGE";
@@ -51,6 +71,15 @@
                /// </summary>
                public const string FAULT = "__FAULT";
 
+               /// <summary>
+               /// Token for pre-op command.
+               /// </summary>
+               public const string PRE_OP = "pre-op";
+
+               /// <summary>
+               /// Token for post-op command.
+               /// </summary>
+               public const string POST_OP = "post-op";
 
        }
 }

Modified: struts/sandbox/trunk/overdrive/Nexus/Extras/Spring/Controller.cs
URL: 
http://svn.apache.org/viewcvs/struts/sandbox/trunk/overdrive/Nexus/Extras/Spring/Controller.cs?rev=190021&r1=190020&r2=190021&view=diff
==============================================================================
--- struts/sandbox/trunk/overdrive/Nexus/Extras/Spring/Controller.cs (original)
+++ struts/sandbox/trunk/overdrive/Nexus/Extras/Spring/Controller.cs Fri Jun 10 
14:07:37 2005
@@ -14,7 +14,9 @@
  * limitations under the License.
  */
 using System;
+using Agility.Core;
 using Nexus.Core;
+using Nexus.Core.Tables;
 using Spring.Context;
 
 namespace Nexus.Extras.Spring
@@ -75,11 +77,26 @@
                        return command;
                }
 
-               /// <summary>
-               /// Token for Command object.
-               /// </summary>
-               private string COMMAND_BIN = Tokens.COMMAND_BIN;
+               public IRequestContext GetContext (IRequestCommand command)
+               {
+                       IRequestContext context = null;
+                       try
+                       {
+                               context = command.NewContext ();
+                               context [Tokens.COMMAND_BIN] = command;
+                               context [Tokens.FIELD_TABLE] = GetFieldTable ();
+                       }
+                       catch (Exception e)
+                       {
+                               context = new RequestContext ();
+                               context.Fault = e;
+                               // TODO: Log exception(faults) (Log all errors 
in verbose mode?)
+                               // TODO: Provide an alternate location on 
fault? -- Declarative exception handing
+                       }
+                       return context;
 
+               }
+               
                public IRequestContext GetContext (string name)
                {
                        IRequestContext context = null;
@@ -87,7 +104,7 @@
                        {
                                IRequestCommand command = GetCommand (name);
                                context = command.NewContext ();
-                               context [COMMAND_BIN] = command;
+                               context [Tokens.COMMAND_BIN] = command;
                        }
                        catch (Exception e)
                        {
@@ -99,6 +116,22 @@
                        return context;
                }
 
+               /// <summary>
+               /// Field for GetFieldTable method.
+               /// </summary>
+               private IFieldTable _FieldTable = null;
+
+               /// <summary>
+               /// Access method for the Controller's FieldTable.
+               /// </summary>
+               /// <returns></returns>
+               public IFieldTable GetFieldTable ()
+               {
+                       if (_FieldTable == null)
+                               _FieldTable = GetObject (Tokens.FIELD_ID) as 
IFieldTable;
+                       return _FieldTable;
+               }
+
                public void Execute (IRequestContext context)
                {
                        if (null == context)
@@ -107,7 +140,7 @@
                                // TODO: Add a message about null context
                        }
 
-                       IRequestCommand command = context [COMMAND_BIN] as 
IRequestCommand;
+                       IRequestCommand command = context [Tokens.COMMAND_BIN] 
as IRequestCommand;
 
                        if (null == command)
                        {
@@ -135,6 +168,24 @@
                        Execute (context);
                        return context;
                }
+
+               public void ExecuteView (IRequestContext context)
+               {
+                       IRequestCommand command = context [Tokens.COMMAND_BIN] 
as IRequestCommand;
+                       IChain chain = new Chain ();
+                       chain.AddCommand (GetCommand (Tokens.PRE_OP));
+                       chain.AddCommand (command);
+                       chain.AddCommand (GetCommand (Tokens.POST_OP));
+                       try
+                       {
+                               chain.Execute (context);
+                       }
+                       catch (Exception e)
+                       {
+                               context.Fault = e;
+                       }
+               }
+
 
        }
 }

Modified: struts/sandbox/trunk/overdrive/Nexus/Test/BaseNexusTest.cs
URL: 
http://svn.apache.org/viewcvs/struts/sandbox/trunk/overdrive/Nexus/Test/BaseNexusTest.cs?rev=190021&r1=190020&r2=190021&view=diff
==============================================================================
--- struts/sandbox/trunk/overdrive/Nexus/Test/BaseNexusTest.cs (original)
+++ struts/sandbox/trunk/overdrive/Nexus/Test/BaseNexusTest.cs Fri Jun 10 
14:07:37 2005
@@ -15,7 +15,6 @@
  */
 using System.Collections;
 using System.Text;
-using Agility.Core;
 using Agility.Extras.Spring;
 using Nexus.Extras.Spring;
 using NUnit.Framework;
@@ -73,7 +72,7 @@
                        if (hasErrors)
                        {
                                StringBuilder outer = new StringBuilder ();
-                               IContext store = context.Errors;
+                               IDictionary store = context.Errors;
                                ICollection keys = store.Keys;
                                foreach (string key in keys)
                                {

Modified: struts/sandbox/trunk/overdrive/Nexus/Web/Web.csproj
URL: 
http://svn.apache.org/viewcvs/struts/sandbox/trunk/overdrive/Nexus/Web/Web.csproj?rev=190021&r1=190020&r2=190021&view=diff
==============================================================================
--- struts/sandbox/trunk/overdrive/Nexus/Web/Web.csproj (original)
+++ struts/sandbox/trunk/overdrive/Nexus/Web/Web.csproj Fri Jun 10 14:07:37 2005
@@ -89,6 +89,16 @@
                     AssemblyName = "System.Xml"
                     HintPath = 
"..\..\..\..\..\..\..\WINDOWS\Microsoft.NET\Framework\v1.1.4322\System.XML.dll"
                 />
+                <Reference
+                    Name = "Nexus.Core"
+                    AssemblyName = "Nexus.Core"
+                    HintPath = "..\Core\bin\Debug\Nexus.Core.dll"
+                />
+                <Reference
+                    Name = "Agility.Core"
+                    AssemblyName = "Agility.Core"
+                    HintPath = "..\..\Agility\Core\bin\Debug\Agility.Core.dll"
+                />
             </References>
         </Build>
         <Files>
@@ -117,6 +127,16 @@
                 <File
                     RelPath = "Web.config"
                     BuildAction = "Content"
+                />
+                <File
+                    RelPath = "WebHelper.cs"
+                    SubType = "Code"
+                    BuildAction = "Compile"
+                />
+                <File
+                    RelPath = "WebViewHelper.cs"
+                    SubType = "Code"
+                    BuildAction = "Compile"
                 />
             </Include>
         </Files>

Added: struts/sandbox/trunk/overdrive/Nexus/Web/WebHelper.cs
URL: 
http://svn.apache.org/viewcvs/struts/sandbox/trunk/overdrive/Nexus/Web/WebHelper.cs?rev=190021&view=auto
==============================================================================
--- struts/sandbox/trunk/overdrive/Nexus/Web/WebHelper.cs (added)
+++ struts/sandbox/trunk/overdrive/Nexus/Web/WebHelper.cs Fri Jun 10 14:07:37 
2005
@@ -0,0 +1,17 @@
+using System;
+
+namespace Nexus
+{
+       /// <summary>
+       /// Summary description for WebHelper.
+       /// </summary>
+       public class WebHelper
+       {
+               public WebHelper()
+               {
+                       //
+                       // TODO: Add constructor logic here
+                       //
+               }
+       }
+}

Added: struts/sandbox/trunk/overdrive/Nexus/Web/WebViewHelper.cs
URL: 
http://svn.apache.org/viewcvs/struts/sandbox/trunk/overdrive/Nexus/Web/WebViewHelper.cs?rev=190021&view=auto
==============================================================================
--- struts/sandbox/trunk/overdrive/Nexus/Web/WebViewHelper.cs (added)
+++ struts/sandbox/trunk/overdrive/Nexus/Web/WebViewHelper.cs Fri Jun 10 
14:07:37 2005
@@ -0,0 +1,95 @@
+using System;
+using System.Collections;
+using System.Text;
+using Nexus.Core.Helpers;
+
+namespace Nexus.Web.Helpers
+{
+       /// <summary>
+       /// Summary description for WebViewHelper.
+       /// </summary>
+       public class WebViewHelper : ViewHelper
+       {
+
+               #region Error Builders
+
+               /// <summary>
+               /// Build a set of error messages using HTML markup.
+               /// </summary>
+               /// <param name="errors">A list of error messages</param>
+               /// <returns>HTML markup presenting the errors.</returns>
+               public static string HtmlErrorList (IList errors)
+               {
+                       StringBuilder sb = new StringBuilder ("<ul>");
+                       foreach (object o in errors)
+                       {
+                               sb.Append ("<li>");
+                               sb.Append (o.ToString ());
+                               sb.Append ("</li>");
+                       }
+                       sb.Append ("</ul>");
+
+                       return sb.ToString ();
+               }
+
+               /// <summary>
+               /// Build a set error messages using HTML markup.
+               /// </summary>
+               /// <param name="fault">An exception instance, if any</param>
+               /// <param name="store">A context listing errors, if any</param>
+               /// <returns>HTML markup presenting the errors.</returns>
+               public string HtmlErrorBuilder (Exception fault, IDictionary 
store)
+               {
+                       string errorMarkup = null;
+                       if (store != null)
+                       {
+                               IList errors = new ArrayList ();
+                               ICollection keys = Context.Keys;
+                               foreach (string key in keys)
+                               {
+                                       IList sublist = store [key] as IList;
+                                       foreach (string message in sublist) 
errors.Add (message);
+                               }
+                               errorMarkup = HtmlErrorList (errors);
+                       }
+
+                       if (errorMarkup != null)
+                       {
+                               StringBuilder sb = new StringBuilder 
(errorMarkup);
+                               return sb.ToString ();
+                       }
+                       return null;
+               }
+
+               public string HtmlErrorBuilder ()
+               {
+                       return HtmlErrorBuilder (Fault, Errors);
+               }
+
+               #endregion 
+
+               #region IViewHelper
+
+               public override void ExecuteBind (ICollection controls)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public override void ReadExecute (ICollection controls)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public override void Bind (ICollection controls)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public override void Read (ICollection controls)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               #endregion
+       }
+}



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to