Author: husted
Date: Fri Oct 14 09:23:44 2005
New Revision: 321144
URL: http://svn.apache.org/viewcvs?rev=321144&view=rev
Log:
OVR-5
* Update Directory2 to use a paged result set. Only the records shown are
retreived from the data source.
Added:
struts/sandbox/trunk/overdrive/PhoneBook/Core/Commands/BaseCount.cs
Modified:
struts/sandbox/trunk/overdrive/PhoneBook/Core/App.cs
struts/sandbox/trunk/overdrive/PhoneBook/Core/Core.csproj
struts/sandbox/trunk/overdrive/PhoneBook/PhoneBook.sln
struts/sandbox/trunk/overdrive/PhoneBook/Test/Commands/SelectAllTest.cs
struts/sandbox/trunk/overdrive/PhoneBook/Test/Resources/AppBase.xml
struts/sandbox/trunk/overdrive/PhoneBook/Test/Resources/AppFields.xml
struts/sandbox/trunk/overdrive/PhoneBook/Test/Resources/Catalog.xml
struts/sandbox/trunk/overdrive/PhoneBook/Test/Resources/Queries.xml
struts/sandbox/trunk/overdrive/PhoneBook/Web/Controls/Lister2.ascx.cs
struts/sandbox/trunk/overdrive/PhoneBook/Web/Resources/AppBase.xml
struts/sandbox/trunk/overdrive/PhoneBook/Web/Resources/AppFields.xml
struts/sandbox/trunk/overdrive/PhoneBook/Web/Resources/Catalog.xml
struts/sandbox/trunk/overdrive/PhoneBook/Web/Resources/Queries.xml
Modified: struts/sandbox/trunk/overdrive/PhoneBook/Core/App.cs
URL:
http://svn.apache.org/viewcvs/struts/sandbox/trunk/overdrive/PhoneBook/Core/App.cs?rev=321144&r1=321143&r2=321144&view=diff
==============================================================================
--- struts/sandbox/trunk/overdrive/PhoneBook/Core/App.cs (original)
+++ struts/sandbox/trunk/overdrive/PhoneBook/Core/App.cs Fri Oct 14 09:23:44
2005
@@ -85,13 +85,19 @@
/// Token for SQL LIMIT clause.
/// </summary>
///
- public const string QUERY_LIMIT = "query_limit";
+ public const string ITEM_LIMIT = "item_limit";
/// <summary>
/// Token for SQL OFFSET clause.
/// </summary>
///
- public const string QUERY_OFFSET = "query_offset";
+ public const string ITEM_OFFSET = "item_offset";
+
+ /// <summary>
+ /// Token for SQL COUNT clause.
+ /// </summary>
+ ///
+ public const string ITEM_COUNT = "item_count";
/// <summary>
/// Token for select one command.
@@ -104,6 +110,12 @@
/// </summary>
///
public const string ENTRY_LIST = "entry_list";
+
+ /// <summary>
+ /// Token for the count of a select all command.
+ /// </summary>
+ ///
+ public const string ENTRY_LIST_COUNT = "entry_list_count";
/// <summary>
/// Token for List Last Names command.
Added: struts/sandbox/trunk/overdrive/PhoneBook/Core/Commands/BaseCount.cs
URL:
http://svn.apache.org/viewcvs/struts/sandbox/trunk/overdrive/PhoneBook/Core/Commands/BaseCount.cs?rev=321144&view=auto
==============================================================================
--- struts/sandbox/trunk/overdrive/PhoneBook/Core/Commands/BaseCount.cs (added)
+++ struts/sandbox/trunk/overdrive/PhoneBook/Core/Commands/BaseCount.cs Fri Oct
14 09:23:44 2005
@@ -0,0 +1,17 @@
+using Nexus.Core;
+
+namespace PhoneBook.Core.Commands
+{
+ /// <summary>
+ /// Invoke a query that returns the count of a result set.
+ /// </summary>
+ public class BaseCount: AppCommand
+ {
+ public override bool RequestExecute(IRequestContext
context)
+ {
+ object result = Mapper.QueryForObject(QueryID,
context);
+ context[App.ITEM_COUNT] = result;
+ return CONTINUE;
+ }
+ }
+}
Modified: struts/sandbox/trunk/overdrive/PhoneBook/Core/Core.csproj
URL:
http://svn.apache.org/viewcvs/struts/sandbox/trunk/overdrive/PhoneBook/Core/Core.csproj?rev=321144&r1=321143&r2=321144&view=diff
==============================================================================
--- struts/sandbox/trunk/overdrive/PhoneBook/Core/Core.csproj (original)
+++ struts/sandbox/trunk/overdrive/PhoneBook/Core/Core.csproj Fri Oct 14
09:23:44 2005
@@ -144,6 +144,11 @@
BuildAction = "Compile"
/>
<File
+ RelPath = "Commands\BaseCount.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
RelPath = "Commands\BaseEntry.cs"
SubType = "Code"
BuildAction = "Compile"
Modified: struts/sandbox/trunk/overdrive/PhoneBook/PhoneBook.sln
URL:
http://svn.apache.org/viewcvs/struts/sandbox/trunk/overdrive/PhoneBook/PhoneBook.sln?rev=321144&r1=321143&r2=321144&view=diff
==============================================================================
--- struts/sandbox/trunk/overdrive/PhoneBook/PhoneBook.sln (original)
+++ struts/sandbox/trunk/overdrive/PhoneBook/PhoneBook.sln Fri Oct 14 09:23:44
2005
@@ -33,6 +33,7 @@
{2F4D056B-4211-4A17-8F47-37901085B3AE}.Release.Build.0 =
Release|.NET
EndGlobalSection
GlobalSection(SolutionItems) = postSolution
+ ..\Nexus\Web\GridControl.ascx.cs =
..\Nexus\Web\GridControl.ascx.cs
prebuild.bat = prebuild.bat
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
Modified:
struts/sandbox/trunk/overdrive/PhoneBook/Test/Commands/SelectAllTest.cs
URL:
http://svn.apache.org/viewcvs/struts/sandbox/trunk/overdrive/PhoneBook/Test/Commands/SelectAllTest.cs?rev=321144&r1=321143&r2=321144&view=diff
==============================================================================
--- struts/sandbox/trunk/overdrive/PhoneBook/Test/Commands/SelectAllTest.cs
(original)
+++ struts/sandbox/trunk/overdrive/PhoneBook/Test/Commands/SelectAllTest.cs Fri
Oct 14 09:23:44 2005
@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+using System;
using System.Collections;
using Nexus.Core;
using Nexus.Core.Helpers;
@@ -79,24 +80,34 @@
}
[Test]
- public void SelectAll_Offset()
+ public void SelectAll_Limit()
{
IViewHelper helper =
catalog.GetHelperFor(App.ENTRY_LIST);
- helper.Criteria[App.QUERY_LIMIT] = 2;
- helper.Criteria[App.QUERY_OFFSET] = 4;
+ helper.Criteria[App.ITEM_LIMIT] = 2;
+ helper.Criteria[App.ITEM_OFFSET] = 4;
helper.Execute();
if (!helper.IsNominal) Assert.Fail(helper.ErrorsText);
IList list = helper.Outcome;
- Assert.IsTrue(list.Count==2);
+ Assert.IsTrue(list.Count==2,"Expected result set to be
limited to two entries.");
AppEntry entry = list[0] as AppEntry;
- helper.Criteria[App.QUERY_LIMIT] = 2;
- helper.Criteria[App.QUERY_OFFSET] = 2;
+ helper.Criteria[App.ITEM_LIMIT] = 2;
+ helper.Criteria[App.ITEM_OFFSET] = 2;
helper.Execute();
IList list2 = helper.Outcome;
AppEntry entry2 = list2[0] as AppEntry;
-
Assert.IsFalse(entry.entry_key.Equals(entry2.entry_key));
+
Assert.IsFalse(entry.entry_key.Equals(entry2.entry_key),"Expected result sets
to be different");
}
+ [Test]
+ public void SelectAll_Count()
+ {
+ IViewHelper helper =
catalog.GetHelperFor(App.ENTRY_LIST_COUNT);
+ helper.Execute();
+ if (!helper.IsNominal) Assert.Fail(helper.ErrorsText);
+ IDictionary entry = helper.Criteria;
+ int count = Convert.ToInt32(entry[App.ITEM_COUNT]);
+ Assert.IsTrue(count==7);
+ }
}
}
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=321144&r1=321143&r2=321144&view=diff
==============================================================================
--- struts/sandbox/trunk/overdrive/PhoneBook/Test/Resources/AppBase.xml
(original)
+++ struts/sandbox/trunk/overdrive/PhoneBook/Test/Resources/AppBase.xml Fri Oct
14 09:23:44 2005
@@ -13,6 +13,8 @@
<object id="BaseChain" type="Nexus.Core.RequestChain, Nexus.Core"/>
+ <object id="BaseCount" type="PhoneBook.Core.Commands.BaseCount,
PhoneBook.Core" parent="BaseMapper"/>
+
<object id="BaseEntry" type="PhoneBook.Core.Commands.BaseEntry,
PhoneBook.Core" parent="BaseMapper"/>
<object id="BaseFilterList"
type="PhoneBook.Core.Commands.BaseFilterList, PhoneBook.Core"
parent="BaseMapper"/>
Modified: struts/sandbox/trunk/overdrive/PhoneBook/Test/Resources/AppFields.xml
URL:
http://svn.apache.org/viewcvs/struts/sandbox/trunk/overdrive/PhoneBook/Test/Resources/AppFields.xml?rev=321144&r1=321143&r2=321144&view=diff
==============================================================================
--- struts/sandbox/trunk/overdrive/PhoneBook/Test/Resources/AppFields.xml
(original)
+++ struts/sandbox/trunk/overdrive/PhoneBook/Test/Resources/AppFields.xml Fri
Oct 14 09:23:44 2005
@@ -23,6 +23,7 @@
<ref object="hired"/>
<ref object="hours"/>
<ref object="_entry_list"/>
+ <ref object="_entry_list_count"/>
<ref object="_extension_list"/>
<ref object="_hired_list"/>
</list>
@@ -75,6 +76,11 @@
<property name="Processor"><ref
object="EntryListProcessor"/></property>
</object>
+ <object id="_entry_list_count" parent="BaseFieldContext">
+ <property name="ID"><value>entry_list_count</value></property>
+ <property name="Processor"><ref
object="CollectionProcessor"/></property>
+ </object>
+
<object id="_extension_list" parent="BaseFieldContext">
<property name="ID"><value>extension_list</value></property>
<property name="Processor"><ref
object="ExtensionListProcessor"/></property>
@@ -85,6 +91,10 @@
<property name="Processor"><ref
object="HiredListProcessor"/></property>
</object>
+ <object id="CollectionProcessor"
type="Nexus.Core.Validators.CollectionProcessor, Nexus.Core">
+ <property
name="ID"><value>EntryCountProcessor</value></property>
+ </object>
+
<!-- "d" is .NET for "short date" -->
<object id="DateTimeProcessor"
type="Nexus.Core.Validators.DateTimeProcessor">
<property name="ID"><value>DateTimeProcessor</value></property>
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=321144&r1=321143&r2=321144&view=diff
==============================================================================
--- struts/sandbox/trunk/overdrive/PhoneBook/Test/Resources/Catalog.xml
(original)
+++ struts/sandbox/trunk/overdrive/PhoneBook/Test/Resources/Catalog.xml Fri Oct
14 09:23:44 2005
@@ -5,7 +5,7 @@
<!-- entry commands -->
- <object id="entry_list" parent="BaseList">
+ <object id="entry_list_rows" parent="BaseList">
<property name="ID"><value>entry_list</value></property>
<property name="QueryID"><value>entry</value></property>
<property name="RelatedIDs">
@@ -19,12 +19,30 @@
<value>hired</value>
<value>hours</value>
<value>editor</value>
- <value>query_offset</value>
- <value>query_limit</value>
+ <value>item_offset</value>
+ <value>item_limit</value>
</list>
</property>
</object>
+ <object id="entry_list_count" parent="BaseCount">
+ <property name="ID"><value>entry_list_count</value></property>
+ <property name="QueryID"><value>entry_count</value></property>
+ <property name="RelatedIDs">
+ <list>
+ <value>item_count</value>
+ <value>entry_key</value>
+ <value>last_name</value>
+ <value>first_name</value>
+ <value>extension</value>
+ <value>user_name</value>
+ <value>hired</value>
+ <value>hours</value>
+ <value>editor</value>
+ </list>
+ </property>
+ </object>
+
<object id="entry" parent="BaseEntry">
<property name="ID"><value>entry</value></property>
<property name="RelatedIDs">
@@ -77,7 +95,19 @@
<!-- chains -->
-
+
+ <object id="entry_list" parent="BaseChain">
+ <property name="ID">
+ <value>entry_list</value>
+ </property>
+ <property name="AddCommands">
+ <list>
+ <ref object="entry_list_rows" />
+ <ref object="entry_list_count" />
+ </list>
+ </property>
+ </object>
+
<object id="entry_find" parent="BaseChain">
<property name="ID">
<value>entry_find</value>
Modified: struts/sandbox/trunk/overdrive/PhoneBook/Test/Resources/Queries.xml
URL:
http://svn.apache.org/viewcvs/struts/sandbox/trunk/overdrive/PhoneBook/Test/Resources/Queries.xml?rev=321144&r1=321143&r2=321144&view=diff
==============================================================================
--- struts/sandbox/trunk/overdrive/PhoneBook/Test/Resources/Queries.xml
(original)
+++ struts/sandbox/trunk/overdrive/PhoneBook/Test/Resources/Queries.xml Fri Oct
14 09:23:44 2005
@@ -102,12 +102,42 @@
</isNotNull>
</dynamic>
<dynamic>
- <isNotNull property="query_limit">
- LIMIT #query_limit# OFFSET
#query_offset#
+ <isNotNull property="item_limit">
+ LIMIT #item_limit# OFFSET #item_offset#
</isNotNull>
</dynamic>
</select>
+ <select id="entry_count" paramClass="Hashtable"
resultClass="string">
+ SELECT COUNT(*) FROM entry
+ <dynamic prepend="WHERE">
+ <isNotNull property="last_name" prepend="AND">
+ last_name=#last_name#
+ </isNotNull>
+ <isNotNull property="first_name" prepend="AND">
+ first_name=#first_name#
+ </isNotNull>
+ <isNotNull property="extension" prepend="AND">
+ extension=#extension#
+ </isNotNull>
+ <isNotNull property="user_name" prepend="AND">
+ user_name=#user_name#
+ </isNotNull>
+ <isNotNull property="hired" prepend="AND">
+ hired=#hired#
+ </isNotNull>
+ <isNotNull property="hours" prepend="AND">
+ hours=#hours#
+ </isNotNull>
+ <isNotNull property="editor" prepend="AND">
+ hours=#editor#
+ </isNotNull>
+ <isNotNull property="entry_key" prepend="AND">
+ pk_entry=#entry_key#
+ </isNotNull>
+ </dynamic>
+ </select>
+
<insert id="entry_insert" parameterMap="entry_save_param">
  INSERT INTO entry (  Â
last_name,
Modified: struts/sandbox/trunk/overdrive/PhoneBook/Web/Controls/Lister2.ascx.cs
URL:
http://svn.apache.org/viewcvs/struts/sandbox/trunk/overdrive/PhoneBook/Web/Controls/Lister2.ascx.cs?rev=321144&r1=321143&r2=321144&view=diff
==============================================================================
--- struts/sandbox/trunk/overdrive/PhoneBook/Web/Controls/Lister2.ascx.cs
(original)
+++ struts/sandbox/trunk/overdrive/PhoneBook/Web/Controls/Lister2.ascx.cs Fri
Oct 14 09:23:44 2005
@@ -1,7 +1,6 @@
using System;
using System.Collections;
using System.Web.UI.WebControls;
-using Nexus.Core.Helpers;
using Nexus.Core.Profile;
using PhoneBook.Core;
@@ -12,20 +11,6 @@
protected DataGrid list;
protected Button add;
- public override bool Open(IDictionary criteria)
- {
- IViewHelper helper = ReadExecute(App.ENTRY_LIST,
criteria);
- bool ok = helper.IsNominal;
- if (!ok) Page_Error = helper;
- else
- {
- IList result = helper.Outcome;
- list.DataSource = result;
- list.DataBind();
- }
- return ok;
- }
-
private static string LABEL = "_label";
private void Grid_Load()
@@ -40,7 +25,7 @@
ListCommand = App.ENTRY_LIST;
SaveCommand = App.ENTRY_SAVE;
DataKeyField = App.ENTRY_KEY;
- HasItemColumn = false;
+ AllowCustomPaging = true;
IList f = new ArrayList(7);
f.Add(App.LAST_NAME);
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=321144&r1=321143&r2=321144&view=diff
==============================================================================
--- struts/sandbox/trunk/overdrive/PhoneBook/Web/Resources/AppBase.xml
(original)
+++ struts/sandbox/trunk/overdrive/PhoneBook/Web/Resources/AppBase.xml Fri Oct
14 09:23:44 2005
@@ -13,6 +13,8 @@
<object id="BaseChain" type="Nexus.Core.RequestChain, Nexus.Core"/>
+ <object id="BaseCount" type="PhoneBook.Core.Commands.BaseCount,
PhoneBook.Core" parent="BaseMapper"/>
+
<object id="BaseEntry" type="PhoneBook.Core.Commands.BaseEntry,
PhoneBook.Core" parent="BaseMapper"/>
<object id="BaseFilterList"
type="PhoneBook.Core.Commands.BaseFilterList, PhoneBook.Core"
parent="BaseMapper"/>
Modified: struts/sandbox/trunk/overdrive/PhoneBook/Web/Resources/AppFields.xml
URL:
http://svn.apache.org/viewcvs/struts/sandbox/trunk/overdrive/PhoneBook/Web/Resources/AppFields.xml?rev=321144&r1=321143&r2=321144&view=diff
==============================================================================
--- struts/sandbox/trunk/overdrive/PhoneBook/Web/Resources/AppFields.xml
(original)
+++ struts/sandbox/trunk/overdrive/PhoneBook/Web/Resources/AppFields.xml Fri
Oct 14 09:23:44 2005
@@ -23,6 +23,7 @@
<ref object="hired"/>
<ref object="hours"/>
<ref object="_entry_list"/>
+ <ref object="_entry_list_count"/>
<ref object="_extension_list"/>
<ref object="_hired_list"/>
</list>
@@ -75,6 +76,11 @@
<property name="Processor"><ref
object="EntryListProcessor"/></property>
</object>
+ <object id="_entry_list_count" parent="BaseFieldContext">
+ <property name="ID"><value>entry_list_count</value></property>
+ <property name="Processor"><ref
object="CollectionProcessor"/></property>
+ </object>
+
<object id="_extension_list" parent="BaseFieldContext">
<property name="ID"><value>extension_list</value></property>
<property name="Processor"><ref
object="ExtensionListProcessor"/></property>
@@ -85,6 +91,10 @@
<property name="Processor"><ref
object="HiredListProcessor"/></property>
</object>
+ <object id="CollectionProcessor"
type="Nexus.Core.Validators.CollectionProcessor, Nexus.Core">
+ <property
name="ID"><value>EntryCountProcessor</value></property>
+ </object>
+
<!-- "d" is .NET for "short date" -->
<object id="DateTimeProcessor"
type="Nexus.Core.Validators.DateTimeProcessor">
<property name="ID"><value>DateTimeProcessor</value></property>
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=321144&r1=321143&r2=321144&view=diff
==============================================================================
--- struts/sandbox/trunk/overdrive/PhoneBook/Web/Resources/Catalog.xml
(original)
+++ struts/sandbox/trunk/overdrive/PhoneBook/Web/Resources/Catalog.xml Fri Oct
14 09:23:44 2005
@@ -5,7 +5,7 @@
<!-- entry commands -->
- <object id="entry_list" parent="BaseList">
+ <object id="entry_list_rows" parent="BaseList">
<property name="ID"><value>entry_list</value></property>
<property name="QueryID"><value>entry</value></property>
<property name="RelatedIDs">
@@ -19,10 +19,30 @@
<value>hired</value>
<value>hours</value>
<value>editor</value>
+ <value>item_offset</value>
+ <value>item_limit</value>
</list>
</property>
</object>
+ <object id="entry_list_count" parent="BaseCount">
+ <property name="ID"><value>entry_list_count</value></property>
+ <property name="QueryID"><value>entry_count</value></property>
+ <property name="RelatedIDs">
+ <list>
+ <value>item_count</value>
+ <value>entry_key</value>
+ <value>last_name</value>
+ <value>first_name</value>
+ <value>extension</value>
+ <value>user_name</value>
+ <value>hired</value>
+ <value>hours</value>
+ <value>editor</value>
+ </list>
+ </property>
+ </object>
+
<object id="entry" parent="BaseEntry">
<property name="ID"><value>entry</value></property>
<property name="RelatedIDs">
@@ -75,7 +95,19 @@
<!-- chains -->
-
+
+ <object id="entry_list" parent="BaseChain">
+ <property name="ID">
+ <value>entry_list</value>
+ </property>
+ <property name="AddCommands">
+ <list>
+ <ref object="entry_list_rows" />
+ <ref object="entry_list_count" />
+ </list>
+ </property>
+ </object>
+
<object id="entry_find" parent="BaseChain">
<property name="ID">
<value>entry_find</value>
Modified: struts/sandbox/trunk/overdrive/PhoneBook/Web/Resources/Queries.xml
URL:
http://svn.apache.org/viewcvs/struts/sandbox/trunk/overdrive/PhoneBook/Web/Resources/Queries.xml?rev=321144&r1=321143&r2=321144&view=diff
==============================================================================
--- struts/sandbox/trunk/overdrive/PhoneBook/Web/Resources/Queries.xml
(original)
+++ struts/sandbox/trunk/overdrive/PhoneBook/Web/Resources/Queries.xml Fri Oct
14 09:23:44 2005
@@ -102,12 +102,42 @@
</isNotNull>
</dynamic>
<dynamic>
- <isNotNull property="query_limit">
- LIMIT #query_limit# OFFSET
#query_offset#
+ <isNotNull property="item_limit">
+ LIMIT #item_limit# OFFSET #item_offset#
</isNotNull>
</dynamic>
</select>
+ <select id="entry_count" paramClass="Hashtable"
resultClass="string">
+ SELECT COUNT(*) FROM entry
+ <dynamic prepend="WHERE">
+ <isNotNull property="last_name" prepend="AND">
+ last_name=#last_name#
+ </isNotNull>
+ <isNotNull property="first_name" prepend="AND">
+ first_name=#first_name#
+ </isNotNull>
+ <isNotNull property="extension" prepend="AND">
+ extension=#extension#
+ </isNotNull>
+ <isNotNull property="user_name" prepend="AND">
+ user_name=#user_name#
+ </isNotNull>
+ <isNotNull property="hired" prepend="AND">
+ hired=#hired#
+ </isNotNull>
+ <isNotNull property="hours" prepend="AND">
+ hours=#hours#
+ </isNotNull>
+ <isNotNull property="editor" prepend="AND">
+ hours=#editor#
+ </isNotNull>
+ <isNotNull property="entry_key" prepend="AND">
+ pk_entry=#entry_key#
+ </isNotNull>
+ </dynamic>
+ </select>
+
<insert id="entry_insert" parameterMap="entry_save_param">
  INSERT INTO entry (  Â
last_name,
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]