Author: husted
Date: Wed Jun 22 08:42:37 2005
New Revision: 192943

URL: http://svn.apache.org/viewcvs?rev=192943&view=rev
Log:
OVR-12
OVR-13
* Refactor IFieldTable, IValidator, and related members before restructuring 
transformation guantlet.

Modified:
    struts/sandbox/trunk/overdrive/Nexus/Core/Helpers/IViewHelper.cs
    struts/sandbox/trunk/overdrive/Nexus/Core/Helpers/ViewHelper.cs
    struts/sandbox/trunk/overdrive/Nexus/Core/IKeyValueList.cs
    struts/sandbox/trunk/overdrive/Nexus/Core/KeyValueList.cs
    struts/sandbox/trunk/overdrive/Nexus/Core/RequestContext.cs
    struts/sandbox/trunk/overdrive/Nexus/Core/Tables/FieldContext.cs
    struts/sandbox/trunk/overdrive/Nexus/Core/Tables/FieldTable.cs
    struts/sandbox/trunk/overdrive/Nexus/Core/Tables/IFieldTable.cs
    struts/sandbox/trunk/overdrive/Nexus/Core/Tokens.cs
    struts/sandbox/trunk/overdrive/Nexus/Core/Validators/ConvertInput.cs
    struts/sandbox/trunk/overdrive/Nexus/Core/Validators/FormatOutput.cs
    struts/sandbox/trunk/overdrive/Nexus/Core/Validators/IValidator.cs
    struts/sandbox/trunk/overdrive/Nexus/Core/Validators/IValidatorContext.cs
    struts/sandbox/trunk/overdrive/Nexus/Core/Validators/Validator.cs
    struts/sandbox/trunk/overdrive/Nexus/Core/Validators/ValidatorContext.cs
    struts/sandbox/trunk/overdrive/Nexus/Web/WebViewHelper.cs

Modified: struts/sandbox/trunk/overdrive/Nexus/Core/Helpers/IViewHelper.cs
URL: 
http://svn.apache.org/viewcvs/struts/sandbox/trunk/overdrive/Nexus/Core/Helpers/IViewHelper.cs?rev=192943&r1=192942&r2=192943&view=diff
==============================================================================
--- struts/sandbox/trunk/overdrive/Nexus/Core/Helpers/IViewHelper.cs (original)
+++ struts/sandbox/trunk/overdrive/Nexus/Core/Helpers/IViewHelper.cs Wed Jun 22 
08:42:37 2005
@@ -85,14 +85,14 @@
                /// 
                void Read (ICollection controls);
 
-               
+
                /// <summary>
                /// Store input and output values.
                /// </summary>
                /// 
-               IRequestContext Context {get;}
+               IRequestContext Context { get; }
+
 
-               
                /// <summary>
                /// Access result of operation as an IList.
                /// </summary>
@@ -103,7 +103,7 @@
                /// this method returns a single-value result as a one-entry 
list.
                /// </remarks>
                /// 
-               IList Outcome {get;}
+               IList Outcome { get; }
 
                // ----
 
@@ -160,7 +160,7 @@
                /// UI specific implementation may markup the errors as needed.
                /// </remarks>
                /// 
-               string ErrorsText { get; } 
+               string ErrorsText { get; }
 
                /// <summary>
                /// Record a list of hint (or advisory) messages, 
@@ -188,7 +188,7 @@
                /// UI specific implementatiosn may markup the messages as 
needed.
                /// </remarks>
                /// 
-               string HintsText { get; } 
+               string HintsText { get; }
 
                // ----
 

Modified: struts/sandbox/trunk/overdrive/Nexus/Core/Helpers/ViewHelper.cs
URL: 
http://svn.apache.org/viewcvs/struts/sandbox/trunk/overdrive/Nexus/Core/Helpers/ViewHelper.cs?rev=192943&r1=192942&r2=192943&view=diff
==============================================================================
--- struts/sandbox/trunk/overdrive/Nexus/Core/Helpers/ViewHelper.cs (original)
+++ struts/sandbox/trunk/overdrive/Nexus/Core/Helpers/ViewHelper.cs Wed Jun 22 
08:42:37 2005
@@ -25,7 +25,6 @@
        /// 
        public abstract class ViewHelper : IViewHelper
        {
-
                /// <summary>
                /// Default setting for ListSuffix ["_list"].
                /// </summary>
@@ -97,17 +96,17 @@
                        {
                                IList result = null;
                                object o = Context.Outcome;
-                               if (o==null)
+                               if (o == null)
                                {
-                                       result = new ArrayList(1);
+                                       result = new ArrayList (1);
                                        result.Add (Context.Criteria);
                                }
                                else
                                {
                                        result = o as IList;
-                                       if (result==null)
+                                       if (result == null)
                                        {
-                                               result = new ArrayList(1);
+                                               result = new ArrayList (1);
                                                result.Add (o);
                                        }
                                }
@@ -192,14 +191,8 @@
                private bool _NullIfEmpty = NULL_IF_EMPTY;
                public bool NullIfEmpty
                {
-                       get
-                       {
-                               return _NullIfEmpty;
-                       }
-                       set
-                       {
-                               _NullIfEmpty = value; 
-                       }
+                       get { return _NullIfEmpty; }
+                       set { _NullIfEmpty = value; }
                }
 
                private string _SelectItemPrompt = SELECT_ITEM_PROMPT;
@@ -240,7 +233,7 @@
                public IRequestCommand Command
                {
                        get { return _Command; }
-                       set { _Command  = value; }
+                       set { _Command = value; }
                }
 
                #endregion 

Modified: struts/sandbox/trunk/overdrive/Nexus/Core/IKeyValueList.cs
URL: 
http://svn.apache.org/viewcvs/struts/sandbox/trunk/overdrive/Nexus/Core/IKeyValueList.cs?rev=192943&r1=192942&r2=192943&view=diff
==============================================================================
--- struts/sandbox/trunk/overdrive/Nexus/Core/IKeyValueList.cs (original)
+++ struts/sandbox/trunk/overdrive/Nexus/Core/IKeyValueList.cs Wed Jun 22 
08:42:37 2005
@@ -8,4 +8,4 @@
        public interface IKeyValueList : IList
        {
        }
-}
+}
\ No newline at end of file

Modified: struts/sandbox/trunk/overdrive/Nexus/Core/KeyValueList.cs
URL: 
http://svn.apache.org/viewcvs/struts/sandbox/trunk/overdrive/Nexus/Core/KeyValueList.cs?rev=192943&r1=192942&r2=192943&view=diff
==============================================================================
--- struts/sandbox/trunk/overdrive/Nexus/Core/KeyValueList.cs (original)
+++ struts/sandbox/trunk/overdrive/Nexus/Core/KeyValueList.cs Wed Jun 22 
08:42:37 2005
@@ -7,11 +7,12 @@
        /// </summary>
        public class KeyValueList : ArrayList, IKeyValueList
        {
-
                /// <summary>
                /// Construct instance without parameters.
                /// </summary>
-               public KeyValueList() {}
+               public KeyValueList ()
+               {
+               }
 
                /// <summary>
                /// Add members of given list to this list.

Modified: struts/sandbox/trunk/overdrive/Nexus/Core/RequestContext.cs
URL: 
http://svn.apache.org/viewcvs/struts/sandbox/trunk/overdrive/Nexus/Core/RequestContext.cs?rev=192943&r1=192942&r2=192943&view=diff
==============================================================================
--- struts/sandbox/trunk/overdrive/Nexus/Core/RequestContext.cs (original)
+++ struts/sandbox/trunk/overdrive/Nexus/Core/RequestContext.cs Wed Jun 22 
08:42:37 2005
@@ -81,12 +81,6 @@
                        set { this [Tokens.FieldTable] = value; }
                }
 
-               public IList FieldSet
-               {
-                       get { return this [Tokens.FieldSet] as IList; }
-                       set { this [Tokens.FieldSet] = value; }
-               }
-
                public bool HasOutcome
                {
                        get { return Contains (Command); }

Modified: struts/sandbox/trunk/overdrive/Nexus/Core/Tables/FieldContext.cs
URL: 
http://svn.apache.org/viewcvs/struts/sandbox/trunk/overdrive/Nexus/Core/Tables/FieldContext.cs?rev=192943&r1=192942&r2=192943&view=diff
==============================================================================
--- struts/sandbox/trunk/overdrive/Nexus/Core/Tables/FieldContext.cs (original)
+++ struts/sandbox/trunk/overdrive/Nexus/Core/Tables/FieldContext.cs Wed Jun 22 
08:42:37 2005
@@ -37,7 +37,7 @@
                        get
                        {
                                Type v = this [Tokens.DataType] as Type;
-                               if (v==null) v = typeof(String);
+                               if (v == null) v = typeof (String);
                                return v;
                        }
                        set

Modified: struts/sandbox/trunk/overdrive/Nexus/Core/Tables/FieldTable.cs
URL: 
http://svn.apache.org/viewcvs/struts/sandbox/trunk/overdrive/Nexus/Core/Tables/FieldTable.cs?rev=192943&r1=192942&r2=192943&view=diff
==============================================================================
--- struts/sandbox/trunk/overdrive/Nexus/Core/Tables/FieldTable.cs (original)
+++ struts/sandbox/trunk/overdrive/Nexus/Core/Tables/FieldTable.cs Wed Jun 22 
08:42:37 2005
@@ -6,7 +6,7 @@
 namespace Nexus.Core.Tables
 {
        /// <summary>
-       /// Default implementation of IFieldTable.
+       /// Implement IFieldTable.
        /// </summary>
        /// <remarks><p>
        /// Validator
@@ -21,6 +21,8 @@
        [Serializable]
        public class FieldTable : Context, IFieldTable
        {
+               #region IFieldTable
+
                private bool _Strict = false;
                public virtual bool Strict
                {
@@ -51,49 +53,20 @@
 
                public virtual string Alert (string id)
                {
-                       return Get (id).Alert;
-               }
-
-               private bool IsStringType (Type dataType)
-               {
-                       bool v = (typeof (string).IsAssignableFrom (dataType));
-                       return v;
-               }
-
-               private bool IsCollectionType (Type dataType)
-               {
-                       bool v = (typeof (ICollection)).IsAssignableFrom 
(dataType);
-                       return (v);
+                       return GetField (id).Alert;
                }
 
-               public bool IsRichControl (string name)
-               {
-                       return !(Tokens.INPUT_CONTROL.Equals (name));
-               }
-
-               public virtual bool Convert (IValidatorContext context)
+               // FIXME: This is begging for a Chain
+               public virtual bool Convert_Execute (IValidatorContext context)
                {
                        bool okay = false;
-
-                       // FIXME: This is begging for a Chain
-
-                       #region non DataTypes
-
                        string id = context.FieldKey;
                        string source = context.Source as string;
-                       IFieldContext fieldContext = Get (id);
-                       if ((fieldContext == null))
-                       {
-                               if (Strict)
-                                       throw new ArgumentNullException 
("Nexus.Core.FieldTable.Convert", id);
-                               else
-                               {
-                                       context.Target = source;
-                                       return true;
-                               }
-                       }
+                       IFieldContext fieldContext = GetField (id); // enforces 
Strict
 
-                       if (IsRichControl (fieldContext.ControlTypeName))
+                       #region Not registered
+
+                       if ((fieldContext == null))
                        {
                                context.Target = source;
                                return true;
@@ -101,14 +74,23 @@
 
                        #endregion
 
-                       #region DataTypes
+                       #region Registered
 
                        bool processed = false;
 
-                       if ((typeof (DateTime) == fieldContext.DataType))
+                       // Collection
+                       if (IsCollectionType (fieldContext.DataType))
+                       {
+                               processed = true;
+                               context.Target = source; // TODO: Recurse into 
collection
+                               okay = true;
+                       }
+
+                       // Date
+                       if (IsDateType (fieldContext.DataType))
                        {
                                processed = true;
-                               if (IsInput (source))
+                               if (IsStringEmpty (source))
                                {
                                        DateTime t = DateTime_Convert 
(fieldContext, source);
                                        bool isDateTimeEmpty = 
DateTime_Empty.Equals (t);
@@ -117,11 +99,12 @@
                                }
                                else
                                {
-                                       context.Target = null; // We could use 
DateTime_Empty here,
-                                       okay = true; //  but there's an issue 
with iBATIS
+                                       context.Target = null; // FIXME: We 
could use DateTime_Empty here,
+                                       okay = true; //  but there was an issue 
with iBATIS (is there still?)
                                }
                        }
 
+                       // String
                        if (IsStringType (fieldContext.DataType))
                        {
                                processed = true;
@@ -139,44 +122,48 @@
                        return okay;
                }
 
-               public virtual bool Format (IValidatorContext context)
+               // FIXME: This is begging for a Chain
+               public virtual bool Format_Execute (IValidatorContext context)
                {
                        bool okay = false;
                        string id = context.FieldKey;
                        object source = context.Source;
-                       IFieldContext fieldContext = Get (id);
+                       IFieldContext fieldContext = GetField (id); // Enforces 
Strict
+
+                       #region Not Registered
+
                        if ((fieldContext == null))
                        {
-                               if (Strict)
-                                       throw new ArgumentNullException 
("Nexus.Core.FieldTable.Format", id);
+                               if (source == null)
+                                       context.Target = null;
                                else
                                {
-                                       if (source == null)
-                                               context.Target = null;
-                                       else
-                                       {
-                                               Type sourceType = 
source.GetType ();
-                                               if (IsCollectionType 
(sourceType)) context.Target = source;
-                                               else context.Target = 
source.ToString ();
-                                       }
-                                       return true;
+                                       Type sourceType = source.GetType ();
+                                       if (IsCollectionType (sourceType)) 
context.Target = source;
+                                       else context.Target = source.ToString 
();
                                }
+                               return true;
                        }
 
-                       if (IsRichControl (fieldContext.ControlTypeName))
+                       #endregion
+
+                       #region Registered
+
+                       bool processed = false;
+
+                       // Collection
+                       if (IsCollectionType (fieldContext.DataType))
                        {
-                               context.Target = source;
-                               return true;
+                               processed = true;
+                               context.Target = source; // TODO: Recurse into 
collection
+                               okay = true;
                        }
 
-                       bool processed = false;
-                       if ((typeof (DateTime) == fieldContext.DataType))
+                       // Date
+                       if (IsDateType (fieldContext.DataType))
                        {
                                processed = true;
-                               SByte dbNull = 0;
-                               bool isDateTimeEmpty = ((null == source) || 
(DBNull.Value.Equals (source)) || (dbNull.Equals (source) || 
String.Empty.Equals (source)));
-                               // We could use DateTime_Empty here, but 
there's an issue with iBATIS
-                               if (isDateTimeEmpty)
+                               if (IsDateEmpty (source))
                                {
                                        context.Target = String.Empty;
                                        okay = true;
@@ -185,10 +172,11 @@
                                {
                                        string target = DateTime_Format 
(fieldContext, source);
                                        context.Target = target;
-                                       okay = IsInput (target);
+                                       okay = IsStringEmpty (target);
                                }
                        }
 
+                       // String
                        if (IsStringType (fieldContext.DataType))
                        {
                                processed = true;
@@ -198,54 +186,115 @@
 
                        // TODO: Other types. 
 
+                       #endregion
+
                        if (!processed)
                                throw new ArgumentOutOfRangeException 
("Agility.Nexus.FieldTable.DataType", id);
 
                        return okay;
                }
 
-               public virtual IFieldContext Get (string id)
+               public virtual IFieldContext GetField (string id)
                {
                        IFieldContext fieldContext = this [id] as IFieldContext;
                        bool problem = ((fieldContext == null) && (Strict));
                        if (problem)
-                               throw new ArgumentNullException 
("Agility.Nexus.FieldTable", "Get");
+                               throw new ArgumentNullException 
("Agility.Nexus.FieldTable", "GetField");
                        return fieldContext;
                }
 
+               #endregion
 
-               /// <summary>
-               /// Determine whether string is null or empty.
-               /// </summary>
-               /// <param name="v">String to test.</param>
-               /// <returns>True if the string is valid input (not null and 
not empty).</returns>
-               /// 
-               private bool IsInput (string v)
+               // TODO: Create a IDataTrip interface with IsType, IsEmpty, 
Convert, and Format methods. 
+               // The runtime instances could then be injected into FieldTable
+               // or added to a list, for extensibility
+
+               #region Collection Convert/Format 
+
+               private bool IsCollectionType (Type dataType)
                {
-                       return ((v != null) && (!String.Empty.Equals (v)));
+                       bool v = (typeof (ICollection)).IsAssignableFrom 
(dataType);
+                       return (v);
                }
 
-               #region DateTime
+               #region Notes
 
-               // TODO: Create a IDataTrip interface with Convert and Format 
methods. 
-               // The runtime instances could then be injected into FieldTable
-               // or added to a list, for extensibility
+               /*
+                       /// <summary>
+                       /// Instantiate from an IDictionary, 
+                       /// formatting each entry using the FieldTable from a 
INexusContext, 
+                       /// and reporting any conversion or formatting errors 
in the INexusContext.
+                       /// </summary>
+                       /// <remarks><p>
+                       /// The result of a query will come back as a list of 
IDictionaries, 
+                       /// using native, unformatted data types. 
+                       /// This constructor can be used to loop through a list 
of IDictionaires, 
+                       /// create a AppContext for each entry, and formatting 
any values 
+                       /// along the way. (Dates being the best example.) 
+                       /// The result is a AppContextList that can be used as 
a DataGrid 
+                       /// DataSource (or whatever). 
+                       /// </p></remarks>
+                       /// <param name="dictionary">Values for new 
object</param>
+                       /// <param name="context">Context with FieldTable and 
error handler</param>
+                       public AppContext (IDictionary dictionary, 
IRequestContext context)
+                       {
+                       #region Assert parameters
+
+                               if (null == dictionary) throw new 
ArgumentNullException ("dictionary", "AppContext(IDictionary,INexusContext");
+                               if (null == context) throw new 
ArgumentNullException ("context", "AppContext(IDictionary,INexusContext");
+                               IFieldTable table = context.FieldTable;
+                               if (null == table) throw new 
ArgumentNullException ("FieldTable", "AppContext(IDictionary,INexusContext");
+
+                       #endregion
+
+                               IEnumerator keys = 
dictionary.Keys.GetEnumerator ();
+                               while (keys.MoveNext ())
+                               {
+                                       string key = keys.Current as string;
+                                       IValidatorContext input = new 
ValidatorContext (); // ISSUE: Spring? [WNE-63]
+                                       input.FieldKey = key;
+                                       input.Source = dictionary [key];
+                                       bool okay = table.Format (input);
+                                       if (!okay)
+                                               // OR, do we just want to push 
convert/format(id) up?
+                                               context.AddAlertForField (key);
+                                       this.Add (key, input.Target);
+                               }
+                       }
+                       */
+
+               #endregion
+
+               #endregion
+
+               #region DateTime Convert/Format
 
                private DateTime DateTime_Empty = DateTime.MinValue;
 
+               private bool IsDateEmpty (object source)
+               {
+                       SByte dbNull = 0;
+                       return ((null == source) || (DBNull.Value.Equals 
(source)) || (dbNull.Equals (source) || String.Empty.Equals (source)));
+               }
+
+               private bool IsDateType (Type dataType)
+               {
+                       bool v = (typeof (DateTime)).IsAssignableFrom 
(dataType);
+                       return (v);
+               }
+
                /// <summary>
                /// Substitute default value (MinValue) if conversion fails. 
                /// </summary>
                /// <param name="fieldContext">Our field definition.</param>
                /// <param name="input">The string to convert.</param>
                /// <returns>A DateTime value, using MinValue to represent 
failure.</returns>
-               public DateTime DateTime_Convert (IFieldContext fieldContext, 
string input)
+               private DateTime DateTime_Convert (IFieldContext fieldContext, 
string input)
                {
                        DateTime t = DateTime_Empty;
                        try
                        {
-                               // t = System.Convert.ToDateTime (input);
-                               t = System.Convert.ToDateTime (input);
+                               t = Convert.ToDateTime (input);
                        }
                        catch (InvalidCastException e)
                        {
@@ -265,7 +314,7 @@
                /// <param name="fieldContext">Our field definition.</param>
                /// <param name="value">The value to format.</param>
                /// <returns>Formatted representation or an empty 
string.</returns>
-               public string DateTime_Format (IFieldContext fieldContext, 
object value)
+               private string DateTime_Format (IFieldContext fieldContext, 
object value)
                {
                        DateTime t = DateTime_Empty;
                        try
@@ -282,26 +331,44 @@
 
                #endregion
 
-               #region Utilities
+               #region String Convert/Format
 
                private string String_Empty = String.Empty;
 
-               public string String_Convert (IFieldContext fieldContext, 
string input)
+               /// <summary>
+               /// Determine whether string is null or empty.
+               /// </summary>
+               /// <param name="v">String to test.</param>
+               /// <returns>True if the string is valid input (not null and 
not empty).</returns>
+               /// 
+               private bool IsStringEmpty (string v)
+               {
+                       return ((v != null) && (!String_Empty.Equals (v)));
+               }
+
+               private bool IsStringType (Type dataType)
+               {
+                       bool v = (typeof (string).IsAssignableFrom (dataType));
+                       return v;
+               }
+
+               private string String_Convert (IFieldContext fieldContext, 
string input)
                {
                        bool isNull = (input == null);
                        return isNull ? String_Empty : input;
                        // If null, return empty string rather than null
-
                }
 
-               public string String_Format (IFieldContext fieldContext, object 
value)
+               private string String_Format (IFieldContext fieldContext, 
object value)
                {
                        string t = String_Empty;
-                       bool valid = (value != null);
-                       string format = (fieldContext.DataFormat != null) ? 
fieldContext.DataFormat : String.Empty;
-                       return valid ? String.Format (format, value) : t;
+                       if (value == null) return t;
+                       string format = (fieldContext.DataFormat == null) ? t : 
fieldContext.DataFormat;
+                       if (format.Equals (t)) return value.ToString ();
+                       return String.Format (format, value);
                }
 
                #endregion
        }
+
 }

Modified: struts/sandbox/trunk/overdrive/Nexus/Core/Tables/IFieldTable.cs
URL: 
http://svn.apache.org/viewcvs/struts/sandbox/trunk/overdrive/Nexus/Core/Tables/IFieldTable.cs?rev=192943&r1=192942&r2=192943&view=diff
==============================================================================
--- struts/sandbox/trunk/overdrive/Nexus/Core/Tables/IFieldTable.cs (original)
+++ struts/sandbox/trunk/overdrive/Nexus/Core/Tables/IFieldTable.cs Wed Jun 22 
08:42:37 2005
@@ -45,7 +45,7 @@
                /// <param name="context">Context to process (including 
Criteria)</param>
                /// <returns>True if nominal</returns>
                /// 
-               bool Convert (IValidatorContext context);
+               bool Convert_Execute (IValidatorContext context);
 
                /// <summary>
                /// Format and copy values from the main Context into the 
Criteria,
@@ -54,24 +54,14 @@
                /// <param name="context">Context to process (including 
Criteria)</param>
                /// <returns>True if nominal</returns>
                /// 
-               bool Format (IValidatorContext context);
+               bool Format_Execute (IValidatorContext context);
 
                /// <summary>
-               /// Determine if the control is a simple value or a rich 
-               /// control, like a drop down list. 
-               /// </summary>
-               /// <param name="name">ID for Control</param>
-               /// <returns>True if control is a multivalue control,
-               /// like a list</returns>
-               /// 
-               bool IsRichControl (string name);
-
-               /// <summary>
-               /// Obtain the FieldContext for the given ID.
+               /// Obtain the FieldContext for the given ID, observering 
Strict setting.
                /// </summary>
                /// <param name="id">FieldContext ID</param>
                /// <returns>FieldContext for ID</returns>
                /// 
-               IFieldContext Get (string id);
+               IFieldContext GetField (string id);
        }
 }

Modified: struts/sandbox/trunk/overdrive/Nexus/Core/Tokens.cs
URL: 
http://svn.apache.org/viewcvs/struts/sandbox/trunk/overdrive/Nexus/Core/Tokens.cs?rev=192943&r1=192942&r2=192943&view=diff
==============================================================================
--- struts/sandbox/trunk/overdrive/Nexus/Core/Tokens.cs (original)
+++ struts/sandbox/trunk/overdrive/Nexus/Core/Tokens.cs Wed Jun 22 08:42:37 2005
@@ -77,6 +77,12 @@
                public const string ControlTypeName = "_ControlTypeName";
 
                /// <summary>
+               /// Token for Context property.
+               /// </summary>
+               /// 
+               public const string Context = "_Context";
+
+               /// <summary>
                /// Token for Criteria property.
                /// </summary>
                /// 
@@ -111,12 +117,6 @@
                /// </summary>
                /// 
                public const string FieldKey = "_FieldKey";
-
-               /// <summary>
-               /// Token for FieldSet property.
-               /// </summary>
-               /// 
-               public const string FieldSet = "_FieldSet";
 
                /// <summary>
                /// Token for FieldTable property.

Modified: struts/sandbox/trunk/overdrive/Nexus/Core/Validators/ConvertInput.cs
URL: 
http://svn.apache.org/viewcvs/struts/sandbox/trunk/overdrive/Nexus/Core/Validators/ConvertInput.cs?rev=192943&r1=192942&r2=192943&view=diff
==============================================================================
--- struts/sandbox/trunk/overdrive/Nexus/Core/Validators/ConvertInput.cs 
(original)
+++ struts/sandbox/trunk/overdrive/Nexus/Core/Validators/ConvertInput.cs Wed 
Jun 22 08:42:37 2005
@@ -1,3 +1,6 @@
+using System.Collections;
+using Nexus.Core.Tables;
+
 namespace Nexus.Core.Validators
 {
        /// <summary>
@@ -6,10 +9,26 @@
        /// </summary>
        public class ConvertInput : Validator
        {
-               public ConvertInput ()
+               public override bool ProcessExecute (IValidatorContext incoming)
                {
-                       Mode = MODE_INPUT;
-               }
+                       string key = incoming.FieldKey;
+                       IRequestContext context = incoming.Context;
+                       IDictionary criteria = incoming.Criteria;
+                       IFieldTable table = incoming.FieldTable;
 
+                       bool have = (criteria.Contains (key));
+                       if (have)
+                       {
+                               incoming.Source = criteria [key];
+                               bool okay = table.Convert_Execute (incoming);
+                               if (okay)
+                                       // set to main context
+                                       context [key] = incoming.Target;
+                               else context.AddAlertForField (key);
+                               return STOP;
+                       }
+
+                       return CONTINUE;
+               }
        }
 }

Modified: struts/sandbox/trunk/overdrive/Nexus/Core/Validators/FormatOutput.cs
URL: 
http://svn.apache.org/viewcvs/struts/sandbox/trunk/overdrive/Nexus/Core/Validators/FormatOutput.cs?rev=192943&r1=192942&r2=192943&view=diff
==============================================================================
--- struts/sandbox/trunk/overdrive/Nexus/Core/Validators/FormatOutput.cs 
(original)
+++ struts/sandbox/trunk/overdrive/Nexus/Core/Validators/FormatOutput.cs Wed 
Jun 22 08:42:37 2005
@@ -1,3 +1,6 @@
+using System.Collections;
+using Nexus.Core.Tables;
+
 namespace Nexus.Core.Validators
 {
        /// <summary>
@@ -6,9 +9,26 @@
        /// </summary>
        public class FormatOutput : Validator
        {
-               public FormatOutput ()
+               public override bool ProcessExecute (IValidatorContext outgoing)
                {
-                       Mode = MODE_OUTPUT;
+                       string key = outgoing.FieldKey;
+                       IRequestContext context = outgoing.Context;
+                       IDictionary criteria = outgoing.Criteria;
+                       IFieldTable table = outgoing.FieldTable;
+
+                       bool have = (context.Contains (key));
+                       if (have)
+                       {
+                               outgoing.Source = context [key];
+                               bool okay = table.Format_Execute (outgoing);
+                               if (okay)
+                                       // set to field buffer
+                                       criteria [key] = outgoing.Target;
+                               else context.AddAlertForField (key);
+                               return STOP;
+                       }
+
+                       return CONTINUE;
                }
        }
 }

Modified: struts/sandbox/trunk/overdrive/Nexus/Core/Validators/IValidator.cs
URL: 
http://svn.apache.org/viewcvs/struts/sandbox/trunk/overdrive/Nexus/Core/Validators/IValidator.cs?rev=192943&r1=192942&r2=192943&view=diff
==============================================================================
--- struts/sandbox/trunk/overdrive/Nexus/Core/Validators/IValidator.cs 
(original)
+++ struts/sandbox/trunk/overdrive/Nexus/Core/Validators/IValidator.cs Wed Jun 
22 08:42:37 2005
@@ -7,5 +7,7 @@
        {
                string Template { get; set; }
                bool Continue { get; set; }
+               bool ProcessExecute (IValidatorContext context);
+
        }
 }

Modified: 
struts/sandbox/trunk/overdrive/Nexus/Core/Validators/IValidatorContext.cs
URL: 
http://svn.apache.org/viewcvs/struts/sandbox/trunk/overdrive/Nexus/Core/Validators/IValidatorContext.cs?rev=192943&r1=192942&r2=192943&view=diff
==============================================================================
--- struts/sandbox/trunk/overdrive/Nexus/Core/Validators/IValidatorContext.cs 
(original)
+++ struts/sandbox/trunk/overdrive/Nexus/Core/Validators/IValidatorContext.cs 
Wed Jun 22 08:42:37 2005
@@ -1,4 +1,6 @@
+using System.Collections;
 using Agility.Core;
+using Nexus.Core.Tables;
 
 namespace Nexus.Core.Validators
 {
@@ -9,21 +11,36 @@
        public interface IValidatorContext : IContext
        {
                /// <summary>
-               /// The identifer for the field under validation.
+               /// Identify the field under validation.
                /// </summary>
                /// 
                string FieldKey { get; set; }
 
                /// <summary>
-               /// The source value that we to process.
+               /// Record the source value to process.
                /// </summary>
                /// 
                object Source { get; set; }
 
                /// <summary>
-               /// The target value after conversion or formatting.
+               /// Reorod the target value after conversion or formatting.
                /// </summary>
                /// 
                object Target { get; set; }
+
+               /// <summary>
+               /// Identify the main IRequestContext being processed.
+               /// </summary>
+               IRequestContext Context { get; }
+
+               /// <summary>
+               /// Identify the set of input/output fields being processed.
+               /// </summary>
+               IDictionary Criteria { get; }
+
+               /// <summary>
+               /// Identify the FieldTable being utilized.
+               /// </summary>
+               IFieldTable FieldTable { get; }
        }
 }

Modified: struts/sandbox/trunk/overdrive/Nexus/Core/Validators/Validator.cs
URL: 
http://svn.apache.org/viewcvs/struts/sandbox/trunk/overdrive/Nexus/Core/Validators/Validator.cs?rev=192943&r1=192942&r2=192943&view=diff
==============================================================================
--- struts/sandbox/trunk/overdrive/Nexus/Core/Validators/Validator.cs (original)
+++ struts/sandbox/trunk/overdrive/Nexus/Core/Validators/Validator.cs Wed Jun 
22 08:42:37 2005
@@ -11,7 +11,7 @@
        /// <remarks>
        /// Subclasses must provide a NexusExecute method.
        /// </remarks>
-       public class Validator : RequestCommand, IValidatorCommand
+       public abstract class Validator : RequestCommand, IValidatorCommand
        {
                #region Properties
 
@@ -51,72 +51,6 @@
                        return combined.Keys;
                }
 
-               #region ProcessRelated
-
-               public void AssertProcessRelated (IRequestContext context)
-               {
-                       AssertProcessRequired (context);
-
-                       IFieldTable table = context.FieldTable;
-                       if (null == table)
-                               throw new ArgumentNullException ("FieldTable", 
"BaseValidator.NexusExecute.AssertProcessRelated");
-               }
-
-               public virtual void ProcessRelated (IRequestContext context, 
bool mode)
-               {
-                       AssertProcessRelated (context);
-
-                       IDictionary fields = context.Criteria;
-                       IFieldTable table = context.FieldTable;
-                       ICollection related = CombinedIDs (context);
-                       foreach (string key in related)
-                       {
-                               bool have = false;
-                               bool okay = false;
-
-                               switch (mode)
-                               {
-                                       case MODE_INPUT:
-                                               {
-                                                       have = (fields.Contains 
(key));
-                                                       if (have)
-                                                       {
-                                                               string source = 
fields [key] as string;
-                                                               // TODO: Spring?
-                                                               
IValidatorContext _context = new ValidatorContext (key, source);
-                                                               okay = 
table.Convert (_context);
-                                                               if (okay)
-                                                                       // set 
to main context
-                                                                       context 
[key] = _context.Target;
-                                                       }
-                                                       break;
-                                               }
-
-                                       case MODE_OUTPUT:
-                                               {
-                                                       have = 
(context.Contains (key));
-                                                       if (have)
-                                                       {
-                                                               object source = 
context [key];
-                                                               // TODO: Spring?
-                                                               
IValidatorContext _context = new ValidatorContext (key, source);
-                                                               okay = 
table.Format (_context);
-                                                               if (okay)
-                                                                       // set 
to field buffer
-                                                                       fields 
[key] = _context.Target;
-                                                       }
-                                                       break;
-                                               }
-                               }
-
-                               if ((have) && (!okay))
-                                       context.AddAlertForField (key);
-
-                       } // end while          
-               }
-
-               #endregion
-
                #region ProcessRequired
 
                public void AssertProcessRequired (IRequestContext context)
@@ -156,6 +90,35 @@
                }
 
                #endregion 
+
+               #region ProcessRelated
+
+               public void AssertProcessRelated (IRequestContext context)
+               {
+                       AssertProcessRequired (context);
+
+                       IFieldTable table = context.FieldTable;
+                       if (null == table)
+                               throw new ArgumentNullException ("FieldTable", 
"BaseValidator.NexusExecute.AssertProcessRelated");
+               }
+
+               public abstract bool ProcessExecute (IValidatorContext context);
+
+               public virtual void ProcessRelated (IRequestContext context, 
bool mode)
+               {
+                       AssertProcessRelated (context);
+
+                       ICollection related = CombinedIDs (context);
+                       foreach (string key in related)
+                       {
+                               IValidatorContext _context = new 
ValidatorContext (key, context);
+                               ProcessExecute (_context);
+                       }
+               }
+
+               #endregion
+
+               // public abstract bool ProcessExecute(ValidatorContext 
context);
 
                public override bool RequestExecute (IRequestContext context)
                {

Modified: 
struts/sandbox/trunk/overdrive/Nexus/Core/Validators/ValidatorContext.cs
URL: 
http://svn.apache.org/viewcvs/struts/sandbox/trunk/overdrive/Nexus/Core/Validators/ValidatorContext.cs?rev=192943&r1=192942&r2=192943&view=diff
==============================================================================
--- struts/sandbox/trunk/overdrive/Nexus/Core/Validators/ValidatorContext.cs 
(original)
+++ struts/sandbox/trunk/overdrive/Nexus/Core/Validators/ValidatorContext.cs 
Wed Jun 22 08:42:37 2005
@@ -1,5 +1,7 @@
+using System.Collections;
 using Agility.Core;
 using Nexus.Core;
+using Nexus.Core.Tables;
 using Nexus.Core.Validators;
 
 namespace Agility.Nexus.Validators
@@ -19,6 +21,12 @@
                        Source = source;
                }
 
+               public ValidatorContext (string key, IRequestContext context)
+               {
+                       FieldKey = key;
+                       this [Tokens.Context] = context;
+               }
+
                public string FieldKey
                {
                        get { return this [Tokens.FieldKey] as string; }
@@ -35,6 +43,21 @@
                {
                        get { return this [Tokens.Target]; }
                        set { this [Tokens.Target] = value; }
+               }
+
+               public IRequestContext Context
+               {
+                       get { return this [Tokens.Context] as IRequestContext; }
+               }
+
+               public IDictionary Criteria
+               {
+                       get { return Context.Criteria; }
+               }
+
+               public IFieldTable FieldTable
+               {
+                       get { return Context.FieldTable; }
                }
        }
 }

Modified: struts/sandbox/trunk/overdrive/Nexus/Web/WebViewHelper.cs
URL: 
http://svn.apache.org/viewcvs/struts/sandbox/trunk/overdrive/Nexus/Web/WebViewHelper.cs?rev=192943&r1=192942&r2=192943&view=diff
==============================================================================
--- struts/sandbox/trunk/overdrive/Nexus/Web/WebViewHelper.cs (original)
+++ struts/sandbox/trunk/overdrive/Nexus/Web/WebViewHelper.cs Wed Jun 22 
08:42:37 2005
@@ -57,21 +57,14 @@
 
                public override string ErrorsText
                {
-                       get
-                       {
-                               return HtmlMessageBuilder (Alerts);
-                       }
+                       get { return HtmlMessageBuilder (Alerts); }
                }
 
                public override string HintsText
                {
-                       get
-                       {
-                               return HtmlMessageBuilder (Hints);
-                       }
+                       get { return HtmlMessageBuilder (Hints); }
                }
 
-
                #endregion
 
                #region Bind methods
@@ -246,7 +239,7 @@
                private string RootId (string id, string prefix, string suffix)
                {
                        int v = id.LastIndexOf (suffix);
-                       if (v<1) return id;
+                       if (v < 1) return id;
                        string fore = id.Substring (0, v);
                        string root = ToColumn (fore, prefix);
                        return root;



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

Reply via email to