Author: husted
Date: Thu Oct 13 12:45:54 2005
New Revision: 320896

URL: http://svn.apache.org/viewcvs?rev=320896&view=rev
Log:
OVR-22
* Refactor Mapper as property. 
* Refine base elements.

Modified:
    struts/sandbox/trunk/overdrive/PhoneBook/Core/Commands/AppCommand.cs
    struts/sandbox/trunk/overdrive/PhoneBook/Core/Commands/BaseEntry.cs
    struts/sandbox/trunk/overdrive/PhoneBook/Core/Commands/BaseFilterList.cs
    struts/sandbox/trunk/overdrive/PhoneBook/Core/Commands/BaseList.cs
    struts/sandbox/trunk/overdrive/PhoneBook/Core/Commands/BaseSave.cs
    struts/sandbox/trunk/overdrive/PhoneBook/Test/Resources/AppBase.xml
    struts/sandbox/trunk/overdrive/PhoneBook/Test/Resources/AppConfig.xml
    struts/sandbox/trunk/overdrive/PhoneBook/Test/Resources/Catalog.xml
    struts/sandbox/trunk/overdrive/PhoneBook/Web/Resources/AppBase.xml
    struts/sandbox/trunk/overdrive/PhoneBook/Web/Resources/AppConfig.xml
    struts/sandbox/trunk/overdrive/PhoneBook/Web/Resources/Catalog.xml

Modified: struts/sandbox/trunk/overdrive/PhoneBook/Core/Commands/AppCommand.cs
URL: 
http://svn.apache.org/viewcvs/struts/sandbox/trunk/overdrive/PhoneBook/Core/Commands/AppCommand.cs?rev=320896&r1=320895&r2=320896&view=diff
==============================================================================
--- struts/sandbox/trunk/overdrive/PhoneBook/Core/Commands/AppCommand.cs 
(original)
+++ struts/sandbox/trunk/overdrive/PhoneBook/Core/Commands/AppCommand.cs Thu 
Oct 13 12:45:54 2005
@@ -25,17 +25,54 @@
        /// 
        public abstract class AppCommand : RequestCommand
        {
-               public SqlMapper Mapper()
+               /// <summary>
+               /// Provide a filed for Mapper property.
+               /// </summary>
+               /// 
+               private SqlMapper _Mapper;
+
+               /// <summary>
+               /// Expose a preconfigured SqlMapper instance that Commands can 
use to run statements.
+               /// </summary>
+               /// <remarks><p>
+               /// Commands use Mapper to invoke SqlMap statements, such as 
+               /// <code>
+               /// object row = Mapper ().QueryForObject (QueryID, context);
+               /// </code>.
+               /// </p><p>
+               /// Any SqlMapper API method may be called. 
+               /// </p><p>
+               /// The default behavior of BAseNexusCommand is to use the 
+               /// command ID if the QueryID is null.
+               /// </p></remarks>
+               /// <returns>Preconfigured Mapper instance</returns>
+               /// 
+               public SqlMapper Mapper
                {
-                       // return IBatisNet.DataMapper.Mapper.Instance();
-                       return IBatisNet.DataMapper.Mapper.Instance();
+                       get { return _Mapper; }
+                       set { _Mapper = value; }
+
                }
 
+               /// <summary>
+               /// Indicate whether string is null or zero length.
+               /// </summary>
+               /// <param name="input">Input to validate</param>
+               /// <returns>True if string is nyull or zero length</returns>
+               /// 
                public bool IsEmpty(string input)
                {
                        return ((input == null) || 
(input.Equals(String.Empty)));
                }
 
+               /// <summary>
+               /// Create new Global Universal Identifer as a formatted string.
+               /// </summary>
+               /// <returns>String representing a new GUID</returns>
+               /// <remarks><p>
+               /// No two calls to this method will ever return duplicate 
strings.
+               /// </p></remarks>
+               /// 
                public string GuidString()
                {
                        Guid guid = Guid.NewGuid();

Modified: struts/sandbox/trunk/overdrive/PhoneBook/Core/Commands/BaseEntry.cs
URL: 
http://svn.apache.org/viewcvs/struts/sandbox/trunk/overdrive/PhoneBook/Core/Commands/BaseEntry.cs?rev=320896&r1=320895&r2=320896&view=diff
==============================================================================
--- struts/sandbox/trunk/overdrive/PhoneBook/Core/Commands/BaseEntry.cs 
(original)
+++ struts/sandbox/trunk/overdrive/PhoneBook/Core/Commands/BaseEntry.cs Thu Oct 
13 12:45:54 2005
@@ -27,7 +27,7 @@
        {
                public override bool RequestExecute(IRequestContext context)
                {
-                       object o = Mapper().QueryForObject(QueryID, context);
+                       object o = Mapper.QueryForObject(QueryID, context);
                        context[ID] = o;
                        IDictionary entry = o as IDictionary;
                        foreach (DictionaryEntry e in entry)

Modified: 
struts/sandbox/trunk/overdrive/PhoneBook/Core/Commands/BaseFilterList.cs
URL: 
http://svn.apache.org/viewcvs/struts/sandbox/trunk/overdrive/PhoneBook/Core/Commands/BaseFilterList.cs?rev=320896&r1=320895&r2=320896&view=diff
==============================================================================
--- struts/sandbox/trunk/overdrive/PhoneBook/Core/Commands/BaseFilterList.cs 
(original)
+++ struts/sandbox/trunk/overdrive/PhoneBook/Core/Commands/BaseFilterList.cs 
Thu Oct 13 12:45:54 2005
@@ -28,7 +28,7 @@
        {
                public override bool RequestExecute(IRequestContext context)
                {
-                       IList rows = Mapper().QueryForList(QueryID, null);
+                       IList rows = Mapper.QueryForList(QueryID, null);
                        IKeyValueList list = new KeyValueList();
                        foreach (object key in rows)
                        {

Modified: struts/sandbox/trunk/overdrive/PhoneBook/Core/Commands/BaseList.cs
URL: 
http://svn.apache.org/viewcvs/struts/sandbox/trunk/overdrive/PhoneBook/Core/Commands/BaseList.cs?rev=320896&r1=320895&r2=320896&view=diff
==============================================================================
--- struts/sandbox/trunk/overdrive/PhoneBook/Core/Commands/BaseList.cs 
(original)
+++ struts/sandbox/trunk/overdrive/PhoneBook/Core/Commands/BaseList.cs Thu Oct 
13 12:45:54 2005
@@ -28,7 +28,7 @@
        {
                public override bool RequestExecute(IRequestContext context)
                {
-                       IList rows = Mapper().QueryForList(QueryID, context);
+                       IList rows = Mapper.QueryForList(QueryID, context);
                        context[ID] = rows;
                        return CONTINUE;
                }

Modified: struts/sandbox/trunk/overdrive/PhoneBook/Core/Commands/BaseSave.cs
URL: 
http://svn.apache.org/viewcvs/struts/sandbox/trunk/overdrive/PhoneBook/Core/Commands/BaseSave.cs?rev=320896&r1=320895&r2=320896&view=diff
==============================================================================
--- struts/sandbox/trunk/overdrive/PhoneBook/Core/Commands/BaseSave.cs 
(original)
+++ struts/sandbox/trunk/overdrive/PhoneBook/Core/Commands/BaseSave.cs Thu Oct 
13 12:45:54 2005
@@ -56,10 +56,10 @@
                        if (insert)
                        {
                                context[fieldID] = GuidString();
-                               Mapper().Insert(insertID, context);
+                               Mapper.Insert(insertID, context);
                        }
                        else
-                               Mapper().Update(updateID, context);
+                               Mapper.Update(updateID, context);
 
                        return CONTINUE;
                }

Modified: struts/sandbox/trunk/overdrive/PhoneBook/Test/Resources/AppBase.xml
URL: 
http://svn.apache.org/viewcvs/struts/sandbox/trunk/overdrive/PhoneBook/Test/Resources/AppBase.xml?rev=320896&r1=320895&r2=320896&view=diff
==============================================================================
--- struts/sandbox/trunk/overdrive/PhoneBook/Test/Resources/AppBase.xml 
(original)
+++ struts/sandbox/trunk/overdrive/PhoneBook/Test/Resources/AppBase.xml Thu Oct 
13 12:45:54 2005
@@ -3,9 +3,19 @@
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
        xsi:schemaLocation="http://www.springframework.net 
http://www.springframework.net/xsd/spring-objects.xsd";>
 
+ <!-- Base element (super parent)-->
+ 
+ <object id="BaseMapper" abstract="true">
+     <property name="Mapper"><ref object="Mapper"/></property>
+ </object>
+ 
+ <!-- Base class parents --> 
+
        <object id="BaseChain" type="Nexus.Core.RequestChain, Nexus.Core"/>
        
-       <object id="BaseFilterList" 
type="PhoneBook.Core.Commands.BaseFilterList, PhoneBook.Core"/>
+       <object id="BaseEntry" type="PhoneBook.Core.Commands.BaseEntry, 
PhoneBook.Core" parent="BaseMapper"/>
+       
+       <object id="BaseFilterList" 
type="PhoneBook.Core.Commands.BaseFilterList, PhoneBook.Core" 
parent="BaseMapper"/>
        
        <object id="BaseFieldContext" type="Nexus.Extras.Spring.FieldContext">
                <property name="MessageSource">
@@ -14,5 +24,9 @@
        </object>
        
        <object id="BaseKeyValueProcessor" 
type="Nexus.Core.Validators.KeyValueProcessor"/>
+
+       <object id="BaseList" type="PhoneBook.Core.Commands.BaseList, 
PhoneBook.Core" parent="BaseMapper"/>
+
+       <object id="BaseSave" type="PhoneBook.Core.Commands.BaseSave, 
PhoneBook.Core" parent="BaseMapper"/>
 
 </objects>

Modified: struts/sandbox/trunk/overdrive/PhoneBook/Test/Resources/AppConfig.xml
URL: 
http://svn.apache.org/viewcvs/struts/sandbox/trunk/overdrive/PhoneBook/Test/Resources/AppConfig.xml?rev=320896&r1=320895&r2=320896&view=diff
==============================================================================
--- struts/sandbox/trunk/overdrive/PhoneBook/Test/Resources/AppConfig.xml 
(original)
+++ struts/sandbox/trunk/overdrive/PhoneBook/Test/Resources/AppConfig.xml Thu 
Oct 13 12:45:54 2005
@@ -58,4 +58,9 @@
          <property name="ViewHelper"><object type="Nexus.Web.WebHelper, 
Nexus.Web" singleton="false"/></property>
  </object>
  
+<!-- iBATIS Mapper -->
+  
+  <object id="Mapper" type="IBatisNet.DataMapper.Mapper, IBatisNet.DataMapper" 
+               factory-method="Instance"/> 
+      
 </objects>

Modified: struts/sandbox/trunk/overdrive/PhoneBook/Test/Resources/Catalog.xml
URL: 
http://svn.apache.org/viewcvs/struts/sandbox/trunk/overdrive/PhoneBook/Test/Resources/Catalog.xml?rev=320896&r1=320895&r2=320896&view=diff
==============================================================================
--- struts/sandbox/trunk/overdrive/PhoneBook/Test/Resources/Catalog.xml 
(original)
+++ struts/sandbox/trunk/overdrive/PhoneBook/Test/Resources/Catalog.xml Thu Oct 
13 12:45:54 2005
@@ -5,7 +5,7 @@
 
        <!-- entry commands -->
 
-  <object id="entry_list" type="PhoneBook.Core.Commands.BaseList, 
PhoneBook.Core">
+  <object id="entry_list" parent="BaseList">
                <property name="ID"><value>entry_list</value></property>
                <property name="QueryID"><value>entry</value></property>
                <property name="RelatedIDs">
@@ -23,7 +23,7 @@
                </property>
   </object>
   
-  <object id="entry" type="PhoneBook.Core.Commands.BaseEntry, PhoneBook.Core">
+  <object id="entry" parent="BaseEntry">
                <property name="ID"><value>entry</value></property>
                <property name="RelatedIDs">
                        <list>
@@ -92,7 +92,7 @@
                </property>
        </object>
                        
-  <object id="entry_save" type="PhoneBook.Core.Commands.BaseSave, 
PhoneBook.Core">
+  <object id="entry_save" parent="BaseSave">
                <property name="ID">
                        <value>entry_save</value>
                </property>

Modified: struts/sandbox/trunk/overdrive/PhoneBook/Web/Resources/AppBase.xml
URL: 
http://svn.apache.org/viewcvs/struts/sandbox/trunk/overdrive/PhoneBook/Web/Resources/AppBase.xml?rev=320896&r1=320895&r2=320896&view=diff
==============================================================================
--- struts/sandbox/trunk/overdrive/PhoneBook/Web/Resources/AppBase.xml 
(original)
+++ struts/sandbox/trunk/overdrive/PhoneBook/Web/Resources/AppBase.xml Thu Oct 
13 12:45:54 2005
@@ -3,9 +3,19 @@
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
        xsi:schemaLocation="http://www.springframework.net 
http://www.springframework.net/xsd/spring-objects.xsd";>
 
+ <!-- Base element (super parent)-->
+ 
+ <object id="BaseMapper" abstract="true">
+     <property name="Mapper"><ref object="Mapper"/></property>
+ </object>
+ 
+ <!-- Base class parents --> 
+
        <object id="BaseChain" type="Nexus.Core.RequestChain, Nexus.Core"/>
        
-       <object id="BaseFilterList" 
type="PhoneBook.Core.Commands.BaseFilterList, PhoneBook.Core"/>
+       <object id="BaseEntry" type="PhoneBook.Core.Commands.BaseEntry, 
PhoneBook.Core" parent="BaseMapper"/>
+       
+       <object id="BaseFilterList" 
type="PhoneBook.Core.Commands.BaseFilterList, PhoneBook.Core" 
parent="BaseMapper"/>
        
        <object id="BaseFieldContext" type="Nexus.Extras.Spring.FieldContext">
                <property name="MessageSource">
@@ -14,5 +24,9 @@
        </object>
        
        <object id="BaseKeyValueProcessor" 
type="Nexus.Core.Validators.KeyValueProcessor"/>
+
+       <object id="BaseList" type="PhoneBook.Core.Commands.BaseList, 
PhoneBook.Core" parent="BaseMapper"/>
+
+       <object id="BaseSave" type="PhoneBook.Core.Commands.BaseSave, 
PhoneBook.Core" parent="BaseMapper"/>
 
 </objects>

Modified: struts/sandbox/trunk/overdrive/PhoneBook/Web/Resources/AppConfig.xml
URL: 
http://svn.apache.org/viewcvs/struts/sandbox/trunk/overdrive/PhoneBook/Web/Resources/AppConfig.xml?rev=320896&r1=320895&r2=320896&view=diff
==============================================================================
--- struts/sandbox/trunk/overdrive/PhoneBook/Web/Resources/AppConfig.xml 
(original)
+++ struts/sandbox/trunk/overdrive/PhoneBook/Web/Resources/AppConfig.xml Thu 
Oct 13 12:45:54 2005
@@ -55,7 +55,12 @@
          <property name="FieldTable"><ref object="FieldTable"/></property>
          <property name="PreOp"><ref object="pre-op"/></property>
          <property name="PostOp"><ref object="post-op"/></property>
-         <property name="ViewHelper"><object type="Nexus.Web.WebHelper" 
singleton="false"/></property>
+         <property name="ViewHelper"><object type="Nexus.Web.WebHelper, 
Nexus.Web" singleton="false"/></property>
  </object>
  
+<!-- iBATIS Mapper -->
+  
+  <object id="Mapper" type="IBatisNet.DataMapper.Mapper, IBatisNet.DataMapper" 
+               factory-method="Instance"/> 
+      
 </objects>

Modified: struts/sandbox/trunk/overdrive/PhoneBook/Web/Resources/Catalog.xml
URL: 
http://svn.apache.org/viewcvs/struts/sandbox/trunk/overdrive/PhoneBook/Web/Resources/Catalog.xml?rev=320896&r1=320895&r2=320896&view=diff
==============================================================================
--- struts/sandbox/trunk/overdrive/PhoneBook/Web/Resources/Catalog.xml 
(original)
+++ struts/sandbox/trunk/overdrive/PhoneBook/Web/Resources/Catalog.xml Thu Oct 
13 12:45:54 2005
@@ -5,7 +5,7 @@
 
        <!-- entry commands -->
 
-  <object id="entry_list" type="PhoneBook.Core.Commands.BaseList, 
PhoneBook.Core">
+  <object id="entry_list" parent="BaseList">
                <property name="ID"><value>entry_list</value></property>
                <property name="QueryID"><value>entry</value></property>
                <property name="RelatedIDs">
@@ -23,7 +23,7 @@
                </property>
   </object>
   
-  <object id="entry" type="PhoneBook.Core.Commands.BaseEntry, PhoneBook.Core">
+  <object id="entry" parent="BaseEntry">
                <property name="ID"><value>entry</value></property>
                <property name="RelatedIDs">
                        <list>
@@ -92,7 +92,7 @@
                </property>
        </object>
                        
-  <object id="entry_save" type="PhoneBook.Core.Commands.BaseSave, 
PhoneBook.Core">
+  <object id="entry_save" parent="BaseSave">
                <property name="ID">
                        <value>entry_save</value>
                </property>



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

Reply via email to