Permalink
Browse files

tune get_indirect_cards_by_type_name

  • Loading branch information...
mrichter
mrichter committed Dec 19, 2011
1 parent 1fce365 commit 497bea98be634a8ffad2fb4745d72df1085d24f4
@@ -89,7 +89,7 @@ public interface IMingleProject
/// <param name="cardType">Card_type of cards to be returned</param>
/// <param name="forceRead">Force cache to be filled. If false then data from the cache is returned.</param>
/// <returns></returns>
- MingleCardCollection GetIndirectCardsByTypeName(string cardType, bool forceRead);
+ List<string> GetIndirectCardsByTypeName(string cardType, bool forceRead);
/// <summary>
/// Execute an MQL request and return results in a MingleCardCollection
@@ -14,6 +14,7 @@
// limitations under the License.
//
+using System.Collections;
using System.Collections.Generic;
using System.Xml.Linq;
@@ -85,13 +86,13 @@ public int Position
/// <summary>
/// Returns the list of property_definition names associated with this card type
/// </summary>
- public SortedList<string, XElement> PropertyDefinitions
+ public Hashtable PropertyDefinitions
{
get
{
- var properties = new SortedList<string, XElement>();
+ var properties = new Hashtable();
foreach (var property in RawData.Element("property_definitions").Elements("property_definition"))
- properties.Add(property.Element("name").Value, property);
+ properties.Add(property.Element("name").Value, "");
return properties;
}
@@ -16,6 +16,7 @@
using System;
using System.Collections;
+using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.Globalization;
@@ -398,33 +399,19 @@ public MingleCardCollection GetIndirectCardsByNumber(string cardNumber, bool for
/// <param name="cardType"></param>
/// <param name="forceRead"></param>
/// <returns></returns>
- public MingleCardCollection GetIndirectCardsByTypeName(string cardType, bool forceRead)
+ public List<string> GetIndirectCardsByTypeName(string cardType, bool forceRead)
{
- var me = new StackFrame().GetMethod().Name;
-
- if (string.IsNullOrEmpty(cardType)) return new MingleCardCollection(this);
-
- try
- {
- var cards = new MingleCardCollection(this);
-
- // If we're being asked to fill the cache, or we do not have a cache, then fill it.
- if (forceRead || !CardSetPropertyValues.ContainsKey(cardType))
- {
- var filter = new MingleFilter {Name = "Type", Condition = "Is", Value = cardType};
- cards.Parse(new Collection<string> {filter.FilterFormatString, "page=all"});
- }
+ if (string.IsNullOrEmpty(cardType)) return new List<string>();
- if (!CardSetPropertyValues.ContainsKey(cardType))
- CardSetPropertyValues.Add(cardType, cards);
+ var types = new List<string>();
- return (MingleCardCollection) CardSetPropertyValues[cardType];
- }
- catch (Exception ex)
+ foreach (var ct in CardTypes.Where(ct => ct.PropertyDefinitions.ContainsKey(cardType)))
{
- TraceLog.Exception(me, ex);
- throw;
+ types.Add(ct.Name);
+ break;
}
+
+ return types;
}
/// <summary>
View
@@ -54,7 +54,7 @@
end
it 'gets the indirect cards by type name' do
- @project.get_indirect_cards_by_type_name("Story", false).count.should == 25
+ @project.get_indirect_cards_by_type_name("Epic Story", false).count.should == 1
end
it 'gets a view' do
@@ -74,7 +74,6 @@
it 'should get a property of managed list of text items' do
proj = MingleServer.new("http://localhost:8080", "mingleuser", "secret").GetProject("apitest")
- #System::Diagnostics::Debugger.break
card = proj.get_card(181)
card.card_properties["Priority"].value.should == "Essential"
card.card_properties["Story Status"].value.should == "New"

0 comments on commit 497bea9

Please sign in to comment.