You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by hu...@apache.org on 2005/06/23 17:38:56 UTC
svn commit: r193166 - in /struts/sandbox/trunk/overdrive/PhoneBook: Core/
Core/Commands/ Test/Commands/ Test/Resources/Command/ Test/Resources/Query/
Author: husted
Date: Thu Jun 23 08:38:56 2005
New Revision: 193166
URL: http://svn.apache.org/viewcvs?rev=193166&view=rev
Log:
OVR-5
*Apply new KeyValueProcessor to Extension and Hired filters. Now, the dropdown lists are automatically formatted using the same Processor as the fields.
Added:
struts/sandbox/trunk/overdrive/PhoneBook/Core/ExtensionListProcessor.cs
Modified:
struts/sandbox/trunk/overdrive/PhoneBook/Core/AppProcessor.cs
struts/sandbox/trunk/overdrive/PhoneBook/Core/Commands/BaseFilterList.cs
struts/sandbox/trunk/overdrive/PhoneBook/Core/Core.csproj
struts/sandbox/trunk/overdrive/PhoneBook/Test/Commands/FilterLists.cs
struts/sandbox/trunk/overdrive/PhoneBook/Test/Resources/Command/AppBase.xml
struts/sandbox/trunk/overdrive/PhoneBook/Test/Resources/Command/AppConfig.xml
struts/sandbox/trunk/overdrive/PhoneBook/Test/Resources/Query/FilterLists.xml
Modified: struts/sandbox/trunk/overdrive/PhoneBook/Core/AppProcessor.cs
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/overdrive/PhoneBook/Core/AppProcessor.cs?rev=193166&r1=193165&r2=193166&view=diff
==============================================================================
--- struts/sandbox/trunk/overdrive/PhoneBook/Core/AppProcessor.cs (original)
+++ struts/sandbox/trunk/overdrive/PhoneBook/Core/AppProcessor.cs Thu Jun 23 08:38:56 2005
@@ -10,7 +10,6 @@
/// </summary>
public class AppProcessor : Processor
{
-
public override bool ConvertInput (IProcessorContext incoming)
{
incoming.Target = incoming.Source;
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=193166&r1=193165&r2=193166&view=diff
==============================================================================
--- struts/sandbox/trunk/overdrive/PhoneBook/Core/Commands/BaseFilterList.cs (original)
+++ struts/sandbox/trunk/overdrive/PhoneBook/Core/Commands/BaseFilterList.cs Thu Jun 23 08:38:56 2005
@@ -30,9 +30,9 @@
{
IList rows = Mapper ().QueryForList (QueryID, null);
IKeyValueList list = new KeyValueList ();
- foreach (string key in rows)
+ foreach (object key in rows)
{
- list.Add (new KeyValue (key, key));
+ list.Add (new KeyValue (key.ToString (), key));
}
context [ID] = list;
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=193166&r1=193165&r2=193166&view=diff
==============================================================================
--- struts/sandbox/trunk/overdrive/PhoneBook/Core/Core.csproj (original)
+++ struts/sandbox/trunk/overdrive/PhoneBook/Core/Core.csproj Thu Jun 23 08:38:56 2005
@@ -124,6 +124,11 @@
BuildAction = "Compile"
/>
<File
+ RelPath = "ExtensionListProcessor.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
RelPath = "TelephoneProcessor.cs"
SubType = "Code"
BuildAction = "Compile"
Added: struts/sandbox/trunk/overdrive/PhoneBook/Core/ExtensionListProcessor.cs
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/overdrive/PhoneBook/Core/ExtensionListProcessor.cs?rev=193166&view=auto
==============================================================================
--- struts/sandbox/trunk/overdrive/PhoneBook/Core/ExtensionListProcessor.cs (added)
+++ struts/sandbox/trunk/overdrive/PhoneBook/Core/ExtensionListProcessor.cs Thu Jun 23 08:38:56 2005
@@ -0,0 +1,15 @@
+namespace PhoneBook.Core
+{
+ /// <summary>
+ /// Summary description for ExtensionListProcessor.
+ /// </summary>
+ public class ExtensionListProcessor
+ {
+ public ExtensionListProcessor ()
+ {
+ //
+ // TODO: Add constructor logic here
+ //
+ }
+ }
+}
\ No newline at end of file
Modified: struts/sandbox/trunk/overdrive/PhoneBook/Test/Commands/FilterLists.cs
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/overdrive/PhoneBook/Test/Commands/FilterLists.cs?rev=193166&r1=193165&r2=193166&view=diff
==============================================================================
--- struts/sandbox/trunk/overdrive/PhoneBook/Test/Commands/FilterLists.cs (original)
+++ struts/sandbox/trunk/overdrive/PhoneBook/Test/Commands/FilterLists.cs Thu Jun 23 08:38:56 2005
@@ -15,6 +15,7 @@
*/
using System.Collections;
using Nexus.Core;
+using Nexus.Core.Helpers;
using NUnit.Framework;
namespace PhoneBook.Core.Commands
@@ -39,14 +40,15 @@
foreach (IKeyValue item in list)
{
Assert.IsNotNull (item, "Expected each item to be non-null");
- string key = item.Value as string;
+ object key = item.Value;
Assert.IsNotNull (key, "Expected each key to be non-null");
- Assert.IsTrue (key.Length > 0, "Expected each key to be non-empty");
+ string keystring = key.ToString ();
+ Assert.IsTrue (keystring.Length > 0, "Expected each key to be non-empty");
}
IDictionary keys = new Hashtable (list.Count);
foreach (IKeyValue item in list)
{
- string key = item.Value as string;
+ string key = item.Value.ToString ();
if (keys.Contains (key)) Assert.Fail (key + ": Expected each item to be unique");
keys.Add (key, key);
}
@@ -67,5 +69,36 @@
}
}
+ private IKeyValueList FilterList (string key)
+ {
+ IViewHelper helper = catalog.GetHelper ("directory_view_helper");
+ helper.Execute ();
+ IKeyValueList list = helper.Context.Criteria [key] as IKeyValueList;
+ Assert.IsNotNull (list, "Expected KeyValueList");
+ return list;
+ }
+
+ [Test]
+ public void TestFilterFormat_extension ()
+ {
+ IKeyValueList list = FilterList (App.EXTENSION_LIST);
+ foreach (IKeyValue item in list)
+ {
+ string key = item.Value as string;
+ Assert.IsTrue (key.Length > "1234567890".Length, "Expected formatted extension, not: " + key);
+ }
+ }
+
+ [Test]
+ public void TestFilterFormat_hired ()
+ {
+ IKeyValueList list = FilterList (App.HIRED_LIST);
+ foreach (IKeyValue item in list)
+ {
+ string key = item.Value as string;
+ bool okay = (key.Length > 0) && (key.Length < "##/##/#### ".Length);
+ Assert.IsTrue (okay, "Expected short date format, not: " + key);
+ }
+ }
}
}
Modified: struts/sandbox/trunk/overdrive/PhoneBook/Test/Resources/Command/AppBase.xml
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/overdrive/PhoneBook/Test/Resources/Command/AppBase.xml?rev=193166&r1=193165&r2=193166&view=diff
==============================================================================
--- struts/sandbox/trunk/overdrive/PhoneBook/Test/Resources/Command/AppBase.xml (original)
+++ struts/sandbox/trunk/overdrive/PhoneBook/Test/Resources/Command/AppBase.xml Thu Jun 23 08:38:56 2005
@@ -8,6 +8,8 @@
<object id="BaseFilterList" type="PhoneBook.Core.Commands.BaseFilterList, PhoneBook.Core"/>
<object id="BaseFieldContext" type="Nexus.Core.Tables.FieldContext"/>
+
+ <object id="BaseKeyValueProcessor" type="Nexus.Core.Validators.KeyValueProcessor"/>
<!-- All child helpers must also specify singleton=false; otherwise, Context is shared. -->
<object id="BaseHelper" type="PhoneBook.Web.AppHelper, PhoneBook.Web" singleton="false">
Modified: struts/sandbox/trunk/overdrive/PhoneBook/Test/Resources/Command/AppConfig.xml
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/overdrive/PhoneBook/Test/Resources/Command/AppConfig.xml?rev=193166&r1=193165&r2=193166&view=diff
==============================================================================
--- struts/sandbox/trunk/overdrive/PhoneBook/Test/Resources/Command/AppConfig.xml (original)
+++ struts/sandbox/trunk/overdrive/PhoneBook/Test/Resources/Command/AppConfig.xml Thu Jun 23 08:38:56 2005
@@ -11,6 +11,8 @@
<ref object="hired"/>
<ref object="extension"/>
<ref object="_filter"/>
+ <ref object="_extension_list"/>
+ <ref object="_hired_list"/>
</list>
</property>
<property name="AddProcessors">
@@ -18,6 +20,8 @@
<ref object="DateTimeProcessor"/>
<ref object="TelephoneProcessor"/>
<ref object="AppProcessor"/>
+ <ref object="ExtensionListProcessor"/>
+ <ref object="HiredListProcessor"/>
</list>
</property>
</object>
@@ -33,11 +37,22 @@
<property name="ProcessorID"><value>TelephoneProcessor</value></property>
</object>
+ <!-- We need to "hash" the name with "_" to avoid conflict with the filter Command -->
<object id="_filter" parent="BaseFieldContext">
<property name="ID"><value>filter</value></property>
<property name="ProcessorID"><value>AppProcessor</value></property>
</object>
+ <object id="_extension_list" parent="BaseFieldContext">
+ <property name="ID"><value>extension_list</value></property>
+ <property name="ProcessorID"><value>ExtensionListProcessor</value></property>
+ </object>
+
+ <object id="_hired_list" parent="BaseFieldContext">
+ <property name="ID"><value>hired_list</value></property>
+ <property name="ProcessorID"><value>HiredListProcessor</value></property>
+ </object>
+
<!-- "d" is .NET for "short date" -->
<object id="DateTimeProcessor" type="Nexus.Core.Validators.DateTimeProcessor">
<property name="ID"><value>DateTimeProcessor</value></property>
@@ -50,6 +65,16 @@
<object id="AppProcessor" type="PhoneBook.Core.AppProcessor">
<property name="ID"><value>AppProcessor</value></property>
+ </object>
+
+ <object id="ExtensionListProcessor" parent="BaseKeyValueProcessor">
+ <property name="ID"><value>ExtensionListProcessor</value></property>
+ <property name="Key"><value>extension</value></property>
+ </object>
+
+ <object id="HiredListProcessor" parent="BaseKeyValueProcessor">
+ <property name="ID"><value>HiredListProcessor</value></property>
+ <property name="Key"><value>hired</value></property>
</object>
<!-- Catalog -->
Modified: struts/sandbox/trunk/overdrive/PhoneBook/Test/Resources/Query/FilterLists.xml
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/overdrive/PhoneBook/Test/Resources/Query/FilterLists.xml?rev=193166&r1=193165&r2=193166&view=diff
==============================================================================
--- struts/sandbox/trunk/overdrive/PhoneBook/Test/Resources/Query/FilterLists.xml (original)
+++ struts/sandbox/trunk/overdrive/PhoneBook/Test/Resources/Query/FilterLists.xml Thu Jun 23 08:38:56 2005
@@ -35,14 +35,14 @@
ORDER BY user_name
</select>
- <select id="hired_list" resultClass="string">
+ <select id="hired_list" resultClass="date">
SELECT DISTINCT
hired
FROM entry
ORDER BY hired
</select>
- <select id="hours_list" resultClass="string">
+ <select id="hours_list" resultClass="string">
SELECT DISTINCT
hours
FROM entry
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org